@dreamcommerce/aurora 3.0.0-75 → 3.0.0-76

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 (239) hide show
  1. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +328 -0
  2. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
  3. package/build/cjs/external/@babel/runtime/helpers/esm/assertThisInitialized.js +11 -0
  4. package/build/cjs/external/@babel/runtime/helpers/esm/assertThisInitialized.js.map +1 -0
  5. package/build/cjs/external/@babel/runtime/helpers/esm/getPrototypeOf.js +12 -0
  6. package/build/cjs/external/@babel/runtime/helpers/esm/getPrototypeOf.js.map +1 -0
  7. package/build/cjs/external/@babel/runtime/helpers/esm/inherits.js +21 -0
  8. package/build/cjs/external/@babel/runtime/helpers/esm/inherits.js.map +1 -0
  9. package/build/cjs/external/@babel/runtime/helpers/esm/objectSpread.js +21 -0
  10. package/build/cjs/external/@babel/runtime/helpers/esm/objectSpread.js.map +1 -0
  11. package/build/cjs/external/@babel/runtime/helpers/esm/possibleConstructorReturn.js +15 -0
  12. package/build/cjs/external/@babel/runtime/helpers/esm/possibleConstructorReturn.js.map +1 -0
  13. package/build/cjs/external/@babel/runtime/helpers/esm/setPrototypeOf.js +12 -0
  14. package/build/cjs/external/@babel/runtime/helpers/esm/setPrototypeOf.js.map +1 -0
  15. package/build/cjs/external/i18next/dist/esm/i18next.js +2279 -0
  16. package/build/cjs/external/i18next/dist/esm/i18next.js.map +1 -0
  17. package/build/cjs/external/react-i18next/dist/es/context.js +21 -0
  18. package/build/cjs/external/react-i18next/dist/es/context.js.map +1 -1
  19. package/build/cjs/packages/aurora/src/assets/icons/delete_bin_icon.js +10 -0
  20. package/build/cjs/packages/aurora/src/assets/icons/delete_bin_icon.js.map +1 -0
  21. package/build/cjs/packages/aurora/src/assets/icons/image_edit_icon.js +10 -0
  22. package/build/cjs/packages/aurora/src/assets/icons/image_edit_icon.js.map +1 -0
  23. package/build/cjs/packages/aurora/src/assets/icons/upload_icon.js +10 -0
  24. package/build/cjs/packages/aurora/src/assets/icons/upload_icon.js.map +1 -0
  25. package/build/cjs/packages/aurora/src/components/controls/xhr_image_picker_control/xhr_image_picker_control.js +71 -0
  26. package/build/cjs/packages/aurora/src/components/controls/xhr_image_picker_control/xhr_image_picker_control.js.map +1 -0
  27. package/build/cjs/packages/aurora/src/components/image_picker/components/image_picker_input.js +51 -0
  28. package/build/cjs/packages/aurora/src/components/image_picker/components/image_picker_input.js.map +1 -0
  29. package/build/cjs/packages/aurora/src/components/image_picker/components/image_picker_preview.js +25 -0
  30. package/build/cjs/packages/aurora/src/components/image_picker/components/image_picker_preview.js.map +1 -0
  31. package/build/cjs/packages/aurora/src/components/image_picker/components/uploaded_image_picker_item.js +43 -0
  32. package/build/cjs/packages/aurora/src/components/image_picker/components/uploaded_image_picker_item.js.map +1 -0
  33. package/build/cjs/packages/aurora/src/components/image_picker/image_picker.js +157 -0
  34. package/build/cjs/packages/aurora/src/components/image_picker/image_picker.js.map +1 -0
  35. package/build/cjs/packages/aurora/src/components/image_picker/image_picker_constants.js +27 -0
  36. package/build/cjs/packages/aurora/src/components/image_picker/image_picker_constants.js.map +1 -0
  37. package/build/cjs/packages/aurora/src/components/image_picker/image_picker_utils.js +14 -0
  38. package/build/cjs/packages/aurora/src/components/image_picker/image_picker_utils.js.map +1 -0
  39. package/build/cjs/packages/aurora/src/components/image_picker/use_image_picker.js +160 -0
  40. package/build/cjs/packages/aurora/src/components/image_picker/use_image_picker.js.map +1 -0
  41. package/build/cjs/packages/aurora/src/components/xhr_image_picker/xhr_image_picker.js +202 -0
  42. package/build/cjs/packages/aurora/src/components/xhr_image_picker/xhr_image_picker.js.map +1 -0
  43. package/build/cjs/packages/aurora/src/hooks/use_http_api.js +27 -0
  44. package/build/cjs/packages/aurora/src/hooks/use_http_api.js.map +1 -0
  45. package/build/cjs/packages/aurora/src/hooks/use_lazy_ref.js +35 -0
  46. package/build/cjs/packages/aurora/src/hooks/use_lazy_ref.js.map +1 -0
  47. package/build/cjs/packages/aurora/src/i18n.js +28 -0
  48. package/build/cjs/packages/aurora/src/i18n.js.map +1 -0
  49. package/build/cjs/packages/aurora/src/index.js +4 -0
  50. package/build/cjs/packages/aurora/src/index.js.map +1 -1
  51. package/build/cjs/packages/aurora/src/translations/en.json.js +12 -0
  52. package/build/cjs/packages/aurora/src/translations/en.json.js.map +1 -0
  53. package/build/cjs/packages/aurora/src/translations/pl.json.js +12 -0
  54. package/build/cjs/packages/aurora/src/translations/pl.json.js.map +1 -0
  55. package/build/cjs/packages/star_core/build/esm/external/axios/index.js +10 -0
  56. package/build/cjs/packages/star_core/build/esm/external/axios/index.js.map +1 -0
  57. package/build/cjs/packages/star_core/build/esm/external/axios/lib/adapters/xhr.js +198 -0
  58. package/build/cjs/packages/star_core/build/esm/external/axios/lib/adapters/xhr.js.map +1 -0
  59. package/build/cjs/packages/star_core/build/esm/external/axios/lib/axios.js +67 -0
  60. package/build/cjs/packages/star_core/build/esm/external/axios/lib/axios.js.map +1 -0
  61. package/build/cjs/packages/star_core/build/esm/external/axios/lib/cancel/Cancel.js +21 -0
  62. package/build/cjs/packages/star_core/build/esm/external/axios/lib/cancel/Cancel.js.map +1 -0
  63. package/build/cjs/packages/star_core/build/esm/external/axios/lib/cancel/CancelToken.js +113 -0
  64. package/build/cjs/packages/star_core/build/esm/external/axios/lib/cancel/CancelToken.js.map +1 -0
  65. package/build/cjs/packages/star_core/build/esm/external/axios/lib/cancel/isCancel.js +10 -0
  66. package/build/cjs/packages/star_core/build/esm/external/axios/lib/cancel/isCancel.js.map +1 -0
  67. package/build/cjs/packages/star_core/build/esm/external/axios/lib/core/Axios.js +134 -0
  68. package/build/cjs/packages/star_core/build/esm/external/axios/lib/core/Axios.js.map +1 -0
  69. package/build/cjs/packages/star_core/build/esm/external/axios/lib/core/InterceptorManager.js +58 -0
  70. package/build/cjs/packages/star_core/build/esm/external/axios/lib/core/InterceptorManager.js.map +1 -0
  71. package/build/cjs/packages/star_core/build/esm/external/axios/lib/core/buildFullPath.js +25 -0
  72. package/build/cjs/packages/star_core/build/esm/external/axios/lib/core/buildFullPath.js.map +1 -0
  73. package/build/cjs/packages/star_core/build/esm/external/axios/lib/core/createError.js +23 -0
  74. package/build/cjs/packages/star_core/build/esm/external/axios/lib/core/createError.js.map +1 -0
  75. package/build/cjs/packages/star_core/build/esm/external/axios/lib/core/dispatchRequest.js +64 -0
  76. package/build/cjs/packages/star_core/build/esm/external/axios/lib/core/dispatchRequest.js.map +1 -0
  77. package/build/cjs/packages/star_core/build/esm/external/axios/lib/core/enhanceError.js +46 -0
  78. package/build/cjs/packages/star_core/build/esm/external/axios/lib/core/enhanceError.js.map +1 -0
  79. package/build/cjs/packages/star_core/build/esm/external/axios/lib/core/mergeConfig.js +100 -0
  80. package/build/cjs/packages/star_core/build/esm/external/axios/lib/core/mergeConfig.js.map +1 -0
  81. package/build/cjs/packages/star_core/build/esm/external/axios/lib/core/settle.js +24 -0
  82. package/build/cjs/packages/star_core/build/esm/external/axios/lib/core/settle.js.map +1 -0
  83. package/build/cjs/packages/star_core/build/esm/external/axios/lib/core/transformData.js +26 -0
  84. package/build/cjs/packages/star_core/build/esm/external/axios/lib/core/transformData.js.map +1 -0
  85. package/build/cjs/packages/star_core/build/esm/external/axios/lib/defaults.js +114 -0
  86. package/build/cjs/packages/star_core/build/esm/external/axios/lib/defaults.js.map +1 -0
  87. package/build/cjs/packages/star_core/build/esm/external/axios/lib/env/data.js +10 -0
  88. package/build/cjs/packages/star_core/build/esm/external/axios/lib/env/data.js.map +1 -0
  89. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/bind.js +16 -0
  90. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/bind.js.map +1 -0
  91. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/buildURL.js +61 -0
  92. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/buildURL.js.map +1 -0
  93. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/combineURLs.js +17 -0
  94. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/combineURLs.js.map +1 -0
  95. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/cookies.js +49 -0
  96. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/cookies.js.map +1 -0
  97. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/isAbsoluteURL.js +19 -0
  98. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/isAbsoluteURL.js.map +1 -0
  99. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/isAxiosError.js +18 -0
  100. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/isAxiosError.js.map +1 -0
  101. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/isURLSameOrigin.js +63 -0
  102. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/isURLSameOrigin.js.map +1 -0
  103. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/normalizeHeaderName.js +17 -0
  104. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/normalizeHeaderName.js.map +1 -0
  105. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/parseHeaders.js +51 -0
  106. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/parseHeaders.js.map +1 -0
  107. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/spread.js +32 -0
  108. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/spread.js.map +1 -0
  109. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/validator.js +80 -0
  110. package/build/cjs/packages/star_core/build/esm/external/axios/lib/helpers/validator.js.map +1 -0
  111. package/build/cjs/packages/star_core/build/esm/external/axios/lib/utils.js +346 -0
  112. package/build/cjs/packages/star_core/build/esm/external/axios/lib/utils.js.map +1 -0
  113. package/build/cjs/packages/star_core/build/esm/external/tslib/tslib.es6.js +19 -0
  114. package/build/cjs/packages/star_core/build/esm/external/tslib/tslib.es6.js.map +1 -0
  115. package/build/cjs/packages/star_core/build/esm/packages/star_core/src/classes/axios_http_client/axios_http_client.js +46 -0
  116. package/build/cjs/packages/star_core/build/esm/packages/star_core/src/classes/axios_http_client/axios_http_client.js.map +1 -0
  117. package/build/cjs/packages/star_core/build/esm/packages/star_core/src/features/http_requester/http_requester_contants.js +13 -0
  118. package/build/cjs/packages/star_core/build/esm/packages/star_core/src/features/http_requester/http_requester_contants.js.map +1 -0
  119. package/build/esm/_virtual/_rollupPluginBabelHelpers.js +327 -1
  120. package/build/esm/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
  121. package/build/esm/external/@babel/runtime/helpers/esm/assertThisInitialized.js +7 -0
  122. package/build/esm/external/@babel/runtime/helpers/esm/assertThisInitialized.js.map +1 -0
  123. package/build/esm/external/@babel/runtime/helpers/esm/getPrototypeOf.js +8 -0
  124. package/build/esm/external/@babel/runtime/helpers/esm/getPrototypeOf.js.map +1 -0
  125. package/build/esm/external/@babel/runtime/helpers/esm/inherits.js +17 -0
  126. package/build/esm/external/@babel/runtime/helpers/esm/inherits.js.map +1 -0
  127. package/build/esm/external/@babel/runtime/helpers/esm/objectSpread.js +17 -0
  128. package/build/esm/external/@babel/runtime/helpers/esm/objectSpread.js.map +1 -0
  129. package/build/esm/external/@babel/runtime/helpers/esm/possibleConstructorReturn.js +11 -0
  130. package/build/esm/external/@babel/runtime/helpers/esm/possibleConstructorReturn.js.map +1 -0
  131. package/build/esm/external/@babel/runtime/helpers/esm/setPrototypeOf.js +8 -0
  132. package/build/esm/external/@babel/runtime/helpers/esm/setPrototypeOf.js.map +1 -0
  133. package/build/esm/external/i18next/dist/esm/i18next.js +2275 -0
  134. package/build/esm/external/i18next/dist/esm/i18next.js.map +1 -0
  135. package/build/esm/external/react-i18next/dist/es/context.js +19 -1
  136. package/build/esm/external/react-i18next/dist/es/context.js.map +1 -1
  137. package/build/esm/packages/aurora/src/assets/icons/delete_bin_icon.js +5 -2
  138. package/build/esm/packages/aurora/src/assets/icons/delete_bin_icon.js.map +1 -1
  139. package/build/esm/packages/aurora/src/assets/icons/image_edit_icon.js +5 -2
  140. package/build/esm/packages/aurora/src/assets/icons/image_edit_icon.js.map +1 -1
  141. package/build/esm/packages/aurora/src/assets/icons/upload_icon.js +5 -2
  142. package/build/esm/packages/aurora/src/assets/icons/upload_icon.js.map +1 -1
  143. package/build/esm/packages/aurora/src/components/controls/xhr_image_picker_control/xhr_image_picker_control.js +61 -22
  144. package/build/esm/packages/aurora/src/components/controls/xhr_image_picker_control/xhr_image_picker_control.js.map +1 -1
  145. package/build/esm/packages/aurora/src/components/image_picker/components/image_picker_input.js +41 -17
  146. package/build/esm/packages/aurora/src/components/image_picker/components/image_picker_input.js.map +1 -1
  147. package/build/esm/packages/aurora/src/components/image_picker/components/image_picker_preview.js +15 -4
  148. package/build/esm/packages/aurora/src/components/image_picker/components/image_picker_preview.js.map +1 -1
  149. package/build/esm/packages/aurora/src/components/image_picker/components/uploaded_image_picker_item.js +33 -17
  150. package/build/esm/packages/aurora/src/components/image_picker/components/uploaded_image_picker_item.js.map +1 -1
  151. package/build/esm/packages/aurora/src/components/image_picker/image_picker.js +146 -73
  152. package/build/esm/packages/aurora/src/components/image_picker/image_picker.js.map +1 -1
  153. package/build/esm/packages/aurora/src/components/image_picker/image_picker_constants.js +17 -34
  154. package/build/esm/packages/aurora/src/components/image_picker/image_picker_constants.js.map +1 -1
  155. package/build/esm/packages/aurora/src/components/image_picker/image_picker_utils.js +9 -5
  156. package/build/esm/packages/aurora/src/components/image_picker/image_picker_utils.js.map +1 -1
  157. package/build/esm/packages/aurora/src/components/image_picker/use_image_picker.js +154 -115
  158. package/build/esm/packages/aurora/src/components/image_picker/use_image_picker.js.map +1 -1
  159. package/build/esm/packages/aurora/src/components/xhr_image_picker/xhr_image_picker.js +188 -96
  160. package/build/esm/packages/aurora/src/components/xhr_image_picker/xhr_image_picker.js.map +1 -1
  161. package/build/esm/packages/aurora/src/components/xhr_image_picker/xhr_image_picker_types.js +1 -1
  162. package/build/esm/packages/aurora/src/hooks/use_http_api.js +22 -15
  163. package/build/esm/packages/aurora/src/hooks/use_http_api.js.map +1 -1
  164. package/build/esm/packages/aurora/src/hooks/use_lazy_ref.js +26 -23
  165. package/build/esm/packages/aurora/src/hooks/use_lazy_ref.js.map +1 -1
  166. package/build/esm/packages/aurora/src/i18n.js +20 -18
  167. package/build/esm/packages/aurora/src/i18n.js.map +1 -1
  168. package/build/esm/packages/aurora/src/index.d.ts +5 -0
  169. package/build/esm/packages/aurora/src/index.js +2 -0
  170. package/build/esm/packages/aurora/src/index.js.map +1 -1
  171. package/build/esm/packages/aurora/src/translations/en.json.js +8 -0
  172. package/build/esm/packages/aurora/src/translations/en.json.js.map +1 -0
  173. package/build/esm/packages/aurora/src/translations/pl.json.js +8 -0
  174. package/build/esm/packages/aurora/src/translations/pl.json.js.map +1 -0
  175. package/build/esm/packages/star_core/build/esm/external/axios/index.js +6 -0
  176. package/build/esm/packages/star_core/build/esm/external/axios/index.js.map +1 -0
  177. package/build/esm/packages/star_core/build/esm/external/axios/lib/adapters/xhr.js +194 -0
  178. package/build/esm/packages/star_core/build/esm/external/axios/lib/adapters/xhr.js.map +1 -0
  179. package/build/esm/packages/star_core/build/esm/external/axios/lib/axios.js +63 -0
  180. package/build/esm/packages/star_core/build/esm/external/axios/lib/axios.js.map +1 -0
  181. package/build/esm/packages/star_core/build/esm/external/axios/lib/cancel/Cancel.js +17 -0
  182. package/build/esm/packages/star_core/build/esm/external/axios/lib/cancel/Cancel.js.map +1 -0
  183. package/build/esm/packages/star_core/build/esm/external/axios/lib/cancel/CancelToken.js +109 -0
  184. package/build/esm/packages/star_core/build/esm/external/axios/lib/cancel/CancelToken.js.map +1 -0
  185. package/build/esm/packages/star_core/build/esm/external/axios/lib/cancel/isCancel.js +6 -0
  186. package/build/esm/packages/star_core/build/esm/external/axios/lib/cancel/isCancel.js.map +1 -0
  187. package/build/esm/packages/star_core/build/esm/external/axios/lib/core/Axios.js +130 -0
  188. package/build/esm/packages/star_core/build/esm/external/axios/lib/core/Axios.js.map +1 -0
  189. package/build/esm/packages/star_core/build/esm/external/axios/lib/core/InterceptorManager.js +54 -0
  190. package/build/esm/packages/star_core/build/esm/external/axios/lib/core/InterceptorManager.js.map +1 -0
  191. package/build/esm/packages/star_core/build/esm/external/axios/lib/core/buildFullPath.js +21 -0
  192. package/build/esm/packages/star_core/build/esm/external/axios/lib/core/buildFullPath.js.map +1 -0
  193. package/build/esm/packages/star_core/build/esm/external/axios/lib/core/createError.js +19 -0
  194. package/build/esm/packages/star_core/build/esm/external/axios/lib/core/createError.js.map +1 -0
  195. package/build/esm/packages/star_core/build/esm/external/axios/lib/core/dispatchRequest.js +60 -0
  196. package/build/esm/packages/star_core/build/esm/external/axios/lib/core/dispatchRequest.js.map +1 -0
  197. package/build/esm/packages/star_core/build/esm/external/axios/lib/core/enhanceError.js +42 -0
  198. package/build/esm/packages/star_core/build/esm/external/axios/lib/core/enhanceError.js.map +1 -0
  199. package/build/esm/packages/star_core/build/esm/external/axios/lib/core/mergeConfig.js +96 -0
  200. package/build/esm/packages/star_core/build/esm/external/axios/lib/core/mergeConfig.js.map +1 -0
  201. package/build/esm/packages/star_core/build/esm/external/axios/lib/core/settle.js +20 -0
  202. package/build/esm/packages/star_core/build/esm/external/axios/lib/core/settle.js.map +1 -0
  203. package/build/esm/packages/star_core/build/esm/external/axios/lib/core/transformData.js +22 -0
  204. package/build/esm/packages/star_core/build/esm/external/axios/lib/core/transformData.js.map +1 -0
  205. package/build/esm/packages/star_core/build/esm/external/axios/lib/defaults.js +110 -0
  206. package/build/esm/packages/star_core/build/esm/external/axios/lib/defaults.js.map +1 -0
  207. package/build/esm/packages/star_core/build/esm/external/axios/lib/env/data.js +6 -0
  208. package/build/esm/packages/star_core/build/esm/external/axios/lib/env/data.js.map +1 -0
  209. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/bind.js +12 -0
  210. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/bind.js.map +1 -0
  211. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/buildURL.js +57 -0
  212. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/buildURL.js.map +1 -0
  213. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/combineURLs.js +13 -0
  214. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/combineURLs.js.map +1 -0
  215. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/cookies.js +45 -0
  216. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/cookies.js.map +1 -0
  217. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/isAbsoluteURL.js +15 -0
  218. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/isAbsoluteURL.js.map +1 -0
  219. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/isAxiosError.js +14 -0
  220. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/isAxiosError.js.map +1 -0
  221. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/isURLSameOrigin.js +59 -0
  222. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/isURLSameOrigin.js.map +1 -0
  223. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/normalizeHeaderName.js +13 -0
  224. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/normalizeHeaderName.js.map +1 -0
  225. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/parseHeaders.js +47 -0
  226. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/parseHeaders.js.map +1 -0
  227. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/spread.js +28 -0
  228. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/spread.js.map +1 -0
  229. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/validator.js +76 -0
  230. package/build/esm/packages/star_core/build/esm/external/axios/lib/helpers/validator.js.map +1 -0
  231. package/build/esm/packages/star_core/build/esm/external/axios/lib/utils.js +342 -0
  232. package/build/esm/packages/star_core/build/esm/external/axios/lib/utils.js.map +1 -0
  233. package/build/esm/packages/star_core/build/esm/external/tslib/tslib.es6.js +14 -0
  234. package/build/esm/packages/star_core/build/esm/external/tslib/tslib.es6.js.map +1 -0
  235. package/build/esm/packages/star_core/build/esm/packages/star_core/src/classes/axios_http_client/axios_http_client.js +42 -0
  236. package/build/esm/packages/star_core/build/esm/packages/star_core/src/classes/axios_http_client/axios_http_client.js.map +1 -0
  237. package/build/esm/packages/star_core/build/esm/packages/star_core/src/features/http_requester/http_requester_contants.js +9 -0
  238. package/build/esm/packages/star_core/build/esm/packages/star_core/src/features/http_requester/http_requester_contants.js.map +1 -0
  239. package/package.json +1 -1
@@ -0,0 +1,2275 @@
1
+ import _typeof from '../../../@babel/runtime/helpers/esm/typeof.js';
2
+ import _objectSpread from '../../../@babel/runtime/helpers/esm/objectSpread.js';
3
+ import _classCallCheck from '../../../@babel/runtime/helpers/esm/classCallCheck.js';
4
+ import _createClass from '../../../@babel/runtime/helpers/esm/createClass.js';
5
+ import _assertThisInitialized from '../../../@babel/runtime/helpers/esm/assertThisInitialized.js';
6
+ import _possibleConstructorReturn from '../../../@babel/runtime/helpers/esm/possibleConstructorReturn.js';
7
+ import _getPrototypeOf from '../../../@babel/runtime/helpers/esm/getPrototypeOf.js';
8
+ import _inherits from '../../../@babel/runtime/helpers/esm/inherits.js';
9
+
10
+ var consoleLogger = {
11
+ type: 'logger',
12
+ log: function log(args) {
13
+ this.output('log', args);
14
+ },
15
+ warn: function warn(args) {
16
+ this.output('warn', args);
17
+ },
18
+ error: function error(args) {
19
+ this.output('error', args);
20
+ },
21
+ output: function output(type, args) {
22
+ if (console && console[type]) console[type].apply(console, args);
23
+ }
24
+ };
25
+
26
+ var Logger = function () {
27
+ function Logger(concreteLogger) {
28
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
29
+
30
+ _classCallCheck(this, Logger);
31
+
32
+ this.init(concreteLogger, options);
33
+ }
34
+
35
+ _createClass(Logger, [{
36
+ key: "init",
37
+ value: function init(concreteLogger) {
38
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
39
+ this.prefix = options.prefix || 'i18next:';
40
+ this.logger = concreteLogger || consoleLogger;
41
+ this.options = options;
42
+ this.debug = options.debug;
43
+ }
44
+ }, {
45
+ key: "setDebug",
46
+ value: function setDebug(bool) {
47
+ this.debug = bool;
48
+ }
49
+ }, {
50
+ key: "log",
51
+ value: function log() {
52
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
53
+ args[_key] = arguments[_key];
54
+ }
55
+
56
+ return this.forward(args, 'log', '', true);
57
+ }
58
+ }, {
59
+ key: "warn",
60
+ value: function warn() {
61
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
62
+ args[_key2] = arguments[_key2];
63
+ }
64
+
65
+ return this.forward(args, 'warn', '', true);
66
+ }
67
+ }, {
68
+ key: "error",
69
+ value: function error() {
70
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
71
+ args[_key3] = arguments[_key3];
72
+ }
73
+
74
+ return this.forward(args, 'error', '');
75
+ }
76
+ }, {
77
+ key: "deprecate",
78
+ value: function deprecate() {
79
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
80
+ args[_key4] = arguments[_key4];
81
+ }
82
+
83
+ return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
84
+ }
85
+ }, {
86
+ key: "forward",
87
+ value: function forward(args, lvl, prefix, debugOnly) {
88
+ if (debugOnly && !this.debug) return null;
89
+ if (typeof args[0] === 'string') args[0] = "".concat(prefix).concat(this.prefix, " ").concat(args[0]);
90
+ return this.logger[lvl](args);
91
+ }
92
+ }, {
93
+ key: "create",
94
+ value: function create(moduleName) {
95
+ return new Logger(this.logger, _objectSpread({}, {
96
+ prefix: "".concat(this.prefix, ":").concat(moduleName, ":")
97
+ }, this.options));
98
+ }
99
+ }]);
100
+
101
+ return Logger;
102
+ }();
103
+
104
+ var baseLogger = new Logger();
105
+
106
+ var EventEmitter = function () {
107
+ function EventEmitter() {
108
+ _classCallCheck(this, EventEmitter);
109
+
110
+ this.observers = {};
111
+ }
112
+
113
+ _createClass(EventEmitter, [{
114
+ key: "on",
115
+ value: function on(events, listener) {
116
+ var _this = this;
117
+
118
+ events.split(' ').forEach(function (event) {
119
+ _this.observers[event] = _this.observers[event] || [];
120
+
121
+ _this.observers[event].push(listener);
122
+ });
123
+ return this;
124
+ }
125
+ }, {
126
+ key: "off",
127
+ value: function off(event, listener) {
128
+ if (!this.observers[event]) return;
129
+
130
+ if (!listener) {
131
+ delete this.observers[event];
132
+ return;
133
+ }
134
+
135
+ this.observers[event] = this.observers[event].filter(function (l) {
136
+ return l !== listener;
137
+ });
138
+ }
139
+ }, {
140
+ key: "emit",
141
+ value: function emit(event) {
142
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
143
+ args[_key - 1] = arguments[_key];
144
+ }
145
+
146
+ if (this.observers[event]) {
147
+ var cloned = [].concat(this.observers[event]);
148
+ cloned.forEach(function (observer) {
149
+ observer.apply(void 0, args);
150
+ });
151
+ }
152
+
153
+ if (this.observers['*']) {
154
+ var _cloned = [].concat(this.observers['*']);
155
+
156
+ _cloned.forEach(function (observer) {
157
+ observer.apply(observer, [event].concat(args));
158
+ });
159
+ }
160
+ }
161
+ }]);
162
+
163
+ return EventEmitter;
164
+ }();
165
+
166
+ function defer() {
167
+ var res;
168
+ var rej;
169
+ var promise = new Promise(function (resolve, reject) {
170
+ res = resolve;
171
+ rej = reject;
172
+ });
173
+ promise.resolve = res;
174
+ promise.reject = rej;
175
+ return promise;
176
+ }
177
+ function makeString(object) {
178
+ if (object == null) return '';
179
+ return '' + object;
180
+ }
181
+ function copy(a, s, t) {
182
+ a.forEach(function (m) {
183
+ if (s[m]) t[m] = s[m];
184
+ });
185
+ }
186
+
187
+ function getLastOfPath(object, path, Empty) {
188
+ function cleanKey(key) {
189
+ return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key;
190
+ }
191
+
192
+ function canNotTraverseDeeper() {
193
+ return !object || typeof object === 'string';
194
+ }
195
+
196
+ var stack = typeof path !== 'string' ? [].concat(path) : path.split('.');
197
+
198
+ while (stack.length > 1) {
199
+ if (canNotTraverseDeeper()) return {};
200
+ var key = cleanKey(stack.shift());
201
+ if (!object[key] && Empty) object[key] = new Empty();
202
+ object = object[key];
203
+ }
204
+
205
+ if (canNotTraverseDeeper()) return {};
206
+ return {
207
+ obj: object,
208
+ k: cleanKey(stack.shift())
209
+ };
210
+ }
211
+
212
+ function setPath(object, path, newValue) {
213
+ var _getLastOfPath = getLastOfPath(object, path, Object),
214
+ obj = _getLastOfPath.obj,
215
+ k = _getLastOfPath.k;
216
+
217
+ obj[k] = newValue;
218
+ }
219
+ function pushPath(object, path, newValue, concat) {
220
+ var _getLastOfPath2 = getLastOfPath(object, path, Object),
221
+ obj = _getLastOfPath2.obj,
222
+ k = _getLastOfPath2.k;
223
+
224
+ obj[k] = obj[k] || [];
225
+ if (concat) obj[k] = obj[k].concat(newValue);
226
+ if (!concat) obj[k].push(newValue);
227
+ }
228
+ function getPath(object, path) {
229
+ var _getLastOfPath3 = getLastOfPath(object, path),
230
+ obj = _getLastOfPath3.obj,
231
+ k = _getLastOfPath3.k;
232
+
233
+ if (!obj) return undefined;
234
+ return obj[k];
235
+ }
236
+ function getPathWithDefaults(data, defaultData, key) {
237
+ var value = getPath(data, key);
238
+
239
+ if (value !== undefined) {
240
+ return value;
241
+ }
242
+
243
+ return getPath(defaultData, key);
244
+ }
245
+ function deepExtend(target, source, overwrite) {
246
+ for (var prop in source) {
247
+ if (prop !== '__proto__') {
248
+ if (prop in target) {
249
+ if (typeof target[prop] === 'string' || target[prop] instanceof String || typeof source[prop] === 'string' || source[prop] instanceof String) {
250
+ if (overwrite) target[prop] = source[prop];
251
+ } else {
252
+ deepExtend(target[prop], source[prop], overwrite);
253
+ }
254
+ } else {
255
+ target[prop] = source[prop];
256
+ }
257
+ }
258
+ }
259
+
260
+ return target;
261
+ }
262
+ function regexEscape(str) {
263
+ return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
264
+ }
265
+ var _entityMap = {
266
+ '&': '&amp;',
267
+ '<': '&lt;',
268
+ '>': '&gt;',
269
+ '"': '&quot;',
270
+ "'": '&#39;',
271
+ '/': '&#x2F;'
272
+ };
273
+ function escape(data) {
274
+ if (typeof data === 'string') {
275
+ return data.replace(/[&<>"'\/]/g, function (s) {
276
+ return _entityMap[s];
277
+ });
278
+ }
279
+
280
+ return data;
281
+ }
282
+ var isIE10 = typeof window !== 'undefined' && window.navigator && window.navigator.userAgent && window.navigator.userAgent.indexOf('MSIE') > -1;
283
+
284
+ var ResourceStore = function (_EventEmitter) {
285
+ _inherits(ResourceStore, _EventEmitter);
286
+
287
+ function ResourceStore(data) {
288
+ var _this;
289
+
290
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
291
+ ns: ['translation'],
292
+ defaultNS: 'translation'
293
+ };
294
+
295
+ _classCallCheck(this, ResourceStore);
296
+
297
+ _this = _possibleConstructorReturn(this, _getPrototypeOf(ResourceStore).call(this));
298
+
299
+ if (isIE10) {
300
+ EventEmitter.call(_assertThisInitialized(_this));
301
+ }
302
+
303
+ _this.data = data || {};
304
+ _this.options = options;
305
+
306
+ if (_this.options.keySeparator === undefined) {
307
+ _this.options.keySeparator = '.';
308
+ }
309
+
310
+ return _this;
311
+ }
312
+
313
+ _createClass(ResourceStore, [{
314
+ key: "addNamespaces",
315
+ value: function addNamespaces(ns) {
316
+ if (this.options.ns.indexOf(ns) < 0) {
317
+ this.options.ns.push(ns);
318
+ }
319
+ }
320
+ }, {
321
+ key: "removeNamespaces",
322
+ value: function removeNamespaces(ns) {
323
+ var index = this.options.ns.indexOf(ns);
324
+
325
+ if (index > -1) {
326
+ this.options.ns.splice(index, 1);
327
+ }
328
+ }
329
+ }, {
330
+ key: "getResource",
331
+ value: function getResource(lng, ns, key) {
332
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
333
+ var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
334
+ var path = [lng, ns];
335
+ if (key && typeof key !== 'string') path = path.concat(key);
336
+ if (key && typeof key === 'string') path = path.concat(keySeparator ? key.split(keySeparator) : key);
337
+
338
+ if (lng.indexOf('.') > -1) {
339
+ path = lng.split('.');
340
+ }
341
+
342
+ return getPath(this.data, path);
343
+ }
344
+ }, {
345
+ key: "addResource",
346
+ value: function addResource(lng, ns, key, value) {
347
+ var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
348
+ silent: false
349
+ };
350
+ var keySeparator = this.options.keySeparator;
351
+ if (keySeparator === undefined) keySeparator = '.';
352
+ var path = [lng, ns];
353
+ if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
354
+
355
+ if (lng.indexOf('.') > -1) {
356
+ path = lng.split('.');
357
+ value = ns;
358
+ ns = path[1];
359
+ }
360
+
361
+ this.addNamespaces(ns);
362
+ setPath(this.data, path, value);
363
+ if (!options.silent) this.emit('added', lng, ns, key, value);
364
+ }
365
+ }, {
366
+ key: "addResources",
367
+ value: function addResources(lng, ns, resources) {
368
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
369
+ silent: false
370
+ };
371
+
372
+ for (var m in resources) {
373
+ if (typeof resources[m] === 'string' || Object.prototype.toString.apply(resources[m]) === '[object Array]') this.addResource(lng, ns, m, resources[m], {
374
+ silent: true
375
+ });
376
+ }
377
+
378
+ if (!options.silent) this.emit('added', lng, ns, resources);
379
+ }
380
+ }, {
381
+ key: "addResourceBundle",
382
+ value: function addResourceBundle(lng, ns, resources, deep, overwrite) {
383
+ var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
384
+ silent: false
385
+ };
386
+ var path = [lng, ns];
387
+
388
+ if (lng.indexOf('.') > -1) {
389
+ path = lng.split('.');
390
+ deep = resources;
391
+ resources = ns;
392
+ ns = path[1];
393
+ }
394
+
395
+ this.addNamespaces(ns);
396
+ var pack = getPath(this.data, path) || {};
397
+
398
+ if (deep) {
399
+ deepExtend(pack, resources, overwrite);
400
+ } else {
401
+ pack = _objectSpread({}, pack, resources);
402
+ }
403
+
404
+ setPath(this.data, path, pack);
405
+ if (!options.silent) this.emit('added', lng, ns, resources);
406
+ }
407
+ }, {
408
+ key: "removeResourceBundle",
409
+ value: function removeResourceBundle(lng, ns) {
410
+ if (this.hasResourceBundle(lng, ns)) {
411
+ delete this.data[lng][ns];
412
+ }
413
+
414
+ this.removeNamespaces(ns);
415
+ this.emit('removed', lng, ns);
416
+ }
417
+ }, {
418
+ key: "hasResourceBundle",
419
+ value: function hasResourceBundle(lng, ns) {
420
+ return this.getResource(lng, ns) !== undefined;
421
+ }
422
+ }, {
423
+ key: "getResourceBundle",
424
+ value: function getResourceBundle(lng, ns) {
425
+ if (!ns) ns = this.options.defaultNS;
426
+ if (this.options.compatibilityAPI === 'v1') return _objectSpread({}, {}, this.getResource(lng, ns));
427
+ return this.getResource(lng, ns);
428
+ }
429
+ }, {
430
+ key: "getDataByLanguage",
431
+ value: function getDataByLanguage(lng) {
432
+ return this.data[lng];
433
+ }
434
+ }, {
435
+ key: "toJSON",
436
+ value: function toJSON() {
437
+ return this.data;
438
+ }
439
+ }]);
440
+
441
+ return ResourceStore;
442
+ }(EventEmitter);
443
+
444
+ var postProcessor = {
445
+ processors: {},
446
+ addPostProcessor: function addPostProcessor(module) {
447
+ this.processors[module.name] = module;
448
+ },
449
+ handle: function handle(processors, value, key, options, translator) {
450
+ var _this = this;
451
+
452
+ processors.forEach(function (processor) {
453
+ if (_this.processors[processor]) value = _this.processors[processor].process(value, key, options, translator);
454
+ });
455
+ return value;
456
+ }
457
+ };
458
+
459
+ var checkedLoadedFor = {};
460
+
461
+ var Translator = function (_EventEmitter) {
462
+ _inherits(Translator, _EventEmitter);
463
+
464
+ function Translator(services) {
465
+ var _this;
466
+
467
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
468
+
469
+ _classCallCheck(this, Translator);
470
+
471
+ _this = _possibleConstructorReturn(this, _getPrototypeOf(Translator).call(this));
472
+
473
+ if (isIE10) {
474
+ EventEmitter.call(_assertThisInitialized(_this));
475
+ }
476
+
477
+ copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, _assertThisInitialized(_this));
478
+ _this.options = options;
479
+
480
+ if (_this.options.keySeparator === undefined) {
481
+ _this.options.keySeparator = '.';
482
+ }
483
+
484
+ _this.logger = baseLogger.create('translator');
485
+ return _this;
486
+ }
487
+
488
+ _createClass(Translator, [{
489
+ key: "changeLanguage",
490
+ value: function changeLanguage(lng) {
491
+ if (lng) this.language = lng;
492
+ }
493
+ }, {
494
+ key: "exists",
495
+ value: function exists(key) {
496
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
497
+ interpolation: {}
498
+ };
499
+ var resolved = this.resolve(key, options);
500
+ return resolved && resolved.res !== undefined;
501
+ }
502
+ }, {
503
+ key: "extractFromKey",
504
+ value: function extractFromKey(key, options) {
505
+ var nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
506
+ if (nsSeparator === undefined) nsSeparator = ':';
507
+ var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
508
+ var namespaces = options.ns || this.options.defaultNS;
509
+
510
+ if (nsSeparator && key.indexOf(nsSeparator) > -1) {
511
+ var m = key.match(this.interpolator.nestingRegexp);
512
+
513
+ if (m && m.length > 0) {
514
+ return {
515
+ key: key,
516
+ namespaces: namespaces
517
+ };
518
+ }
519
+
520
+ var parts = key.split(nsSeparator);
521
+ if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
522
+ key = parts.join(keySeparator);
523
+ }
524
+
525
+ if (typeof namespaces === 'string') namespaces = [namespaces];
526
+ return {
527
+ key: key,
528
+ namespaces: namespaces
529
+ };
530
+ }
531
+ }, {
532
+ key: "translate",
533
+ value: function translate(keys, options, lastKey) {
534
+ var _this2 = this;
535
+
536
+ if (_typeof(options) !== 'object' && this.options.overloadTranslationOptionHandler) {
537
+ options = this.options.overloadTranslationOptionHandler(arguments);
538
+ }
539
+
540
+ if (!options) options = {};
541
+ if (keys === undefined || keys === null) return '';
542
+ if (!Array.isArray(keys)) keys = [String(keys)];
543
+ var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
544
+
545
+ var _this$extractFromKey = this.extractFromKey(keys[keys.length - 1], options),
546
+ key = _this$extractFromKey.key,
547
+ namespaces = _this$extractFromKey.namespaces;
548
+
549
+ var namespace = namespaces[namespaces.length - 1];
550
+ var lng = options.lng || this.language;
551
+ var appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
552
+
553
+ if (lng && lng.toLowerCase() === 'cimode') {
554
+ if (appendNamespaceToCIMode) {
555
+ var nsSeparator = options.nsSeparator || this.options.nsSeparator;
556
+ return namespace + nsSeparator + key;
557
+ }
558
+
559
+ return key;
560
+ }
561
+
562
+ var resolved = this.resolve(keys, options);
563
+ var res = resolved && resolved.res;
564
+ var resUsedKey = resolved && resolved.usedKey || key;
565
+ var resExactUsedKey = resolved && resolved.exactUsedKey || key;
566
+ var resType = Object.prototype.toString.apply(res);
567
+ var noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
568
+ var joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
569
+ var handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
570
+ var handleAsObject = typeof res !== 'string' && typeof res !== 'boolean' && typeof res !== 'number';
571
+
572
+ if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(typeof joinArrays === 'string' && resType === '[object Array]')) {
573
+ if (!options.returnObjects && !this.options.returnObjects) {
574
+ this.logger.warn('accessing an object - but returnObjects options is not enabled!');
575
+ return this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, options) : "key '".concat(key, " (").concat(this.language, ")' returned an object instead of string.");
576
+ }
577
+
578
+ if (keySeparator) {
579
+ var resTypeIsArray = resType === '[object Array]';
580
+ var copy$$1 = resTypeIsArray ? [] : {};
581
+ var newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
582
+
583
+ for (var m in res) {
584
+ if (Object.prototype.hasOwnProperty.call(res, m)) {
585
+ var deepKey = "".concat(newKeyToUse).concat(keySeparator).concat(m);
586
+ copy$$1[m] = this.translate(deepKey, _objectSpread({}, options, {
587
+ joinArrays: false,
588
+ ns: namespaces
589
+ }));
590
+ if (copy$$1[m] === deepKey) copy$$1[m] = res[m];
591
+ }
592
+ }
593
+
594
+ res = copy$$1;
595
+ }
596
+ } else if (handleAsObjectInI18nFormat && typeof joinArrays === 'string' && resType === '[object Array]') {
597
+ res = res.join(joinArrays);
598
+ if (res) res = this.extendTranslation(res, keys, options, lastKey);
599
+ } else {
600
+ var usedDefault = false;
601
+ var usedKey = false;
602
+
603
+ if (!this.isValidLookup(res) && options.defaultValue !== undefined) {
604
+ usedDefault = true;
605
+
606
+ if (options.count !== undefined) {
607
+ var suffix = this.pluralResolver.getSuffix(lng, options.count);
608
+ res = options["defaultValue".concat(suffix)];
609
+ }
610
+
611
+ if (!res) res = options.defaultValue;
612
+ }
613
+
614
+ if (!this.isValidLookup(res)) {
615
+ usedKey = true;
616
+ res = key;
617
+ }
618
+
619
+ var updateMissing = options.defaultValue && options.defaultValue !== res && this.options.updateMissing;
620
+
621
+ if (usedKey || usedDefault || updateMissing) {
622
+ this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? options.defaultValue : res);
623
+
624
+ if (keySeparator) {
625
+ var fk = this.resolve(key, _objectSpread({}, 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
+
631
+ var lngs = [];
632
+ var fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
633
+
634
+ if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
635
+ for (var i = 0; i < fallbackLngs.length; i++) {
636
+ lngs.push(fallbackLngs[i]);
637
+ }
638
+ } else if (this.options.saveMissingTo === 'all') {
639
+ lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
640
+ } else {
641
+ lngs.push(options.lng || this.language);
642
+ }
643
+
644
+ var send = function send(l, k) {
645
+ if (_this2.options.missingKeyHandler) {
646
+ _this2.options.missingKeyHandler(l, namespace, k, updateMissing ? options.defaultValue : res, updateMissing, options);
647
+ } else if (_this2.backendConnector && _this2.backendConnector.saveMissing) {
648
+ _this2.backendConnector.saveMissing(l, namespace, k, updateMissing ? options.defaultValue : res, updateMissing, options);
649
+ }
650
+
651
+ _this2.emit('missingKey', l, namespace, k, res);
652
+ };
653
+
654
+ if (this.options.saveMissing) {
655
+ var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
656
+
657
+ if (this.options.saveMissingPlurals && needsPluralHandling) {
658
+ lngs.forEach(function (l) {
659
+ var plurals = _this2.pluralResolver.getPluralFormsOfKey(l, key);
660
+
661
+ plurals.forEach(function (p) {
662
+ return send([l], p);
663
+ });
664
+ });
665
+ } else {
666
+ send(lngs, key);
667
+ }
668
+ }
669
+ }
670
+
671
+ res = this.extendTranslation(res, keys, options, resolved, lastKey);
672
+ if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = "".concat(namespace, ":").concat(key);
673
+ if (usedKey && this.options.parseMissingKeyHandler) res = this.options.parseMissingKeyHandler(res);
674
+ }
675
+
676
+ return res;
677
+ }
678
+ }, {
679
+ key: "extendTranslation",
680
+ value: function extendTranslation(res, key, options, resolved, lastKey) {
681
+ var _this3 = this;
682
+
683
+ if (this.i18nFormat && this.i18nFormat.parse) {
684
+ res = this.i18nFormat.parse(res, options, resolved.usedLng, resolved.usedNS, resolved.usedKey, {
685
+ resolved: resolved
686
+ });
687
+ } else if (!options.skipInterpolation) {
688
+ if (options.interpolation) this.interpolator.init(_objectSpread({}, options, {
689
+ interpolation: _objectSpread({}, this.options.interpolation, options.interpolation)
690
+ }));
691
+ var skipOnVariables = options.interpolation && options.interpolation.skipOnVariables || this.options.interpolation.skipOnVariables;
692
+ var nestBef;
693
+
694
+ if (skipOnVariables) {
695
+ var nb = res.match(this.interpolator.nestingRegexp);
696
+ nestBef = nb && nb.length;
697
+ }
698
+
699
+ var data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
700
+ if (this.options.interpolation.defaultVariables) data = _objectSpread({}, this.options.interpolation.defaultVariables, data);
701
+ res = this.interpolator.interpolate(res, data, options.lng || this.language, options);
702
+
703
+ if (skipOnVariables) {
704
+ var na = res.match(this.interpolator.nestingRegexp);
705
+ var nestAft = na && na.length;
706
+ if (nestBef < nestAft) options.nest = false;
707
+ }
708
+
709
+ if (options.nest !== false) res = this.interpolator.nest(res, function () {
710
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
711
+ args[_key] = arguments[_key];
712
+ }
713
+
714
+ if (lastKey && lastKey[0] === args[0]) {
715
+ _this3.logger.warn("It seems you are nesting recursively key: ".concat(args[0], " in key: ").concat(key[0]));
716
+
717
+ return null;
718
+ }
719
+
720
+ return _this3.translate.apply(_this3, args.concat([key]));
721
+ }, options);
722
+ if (options.interpolation) this.interpolator.reset();
723
+ }
724
+
725
+ var postProcess = options.postProcess || this.options.postProcess;
726
+ var postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;
727
+
728
+ if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
729
+ res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? _objectSpread({
730
+ i18nResolved: resolved
731
+ }, options) : options, this);
732
+ }
733
+
734
+ return res;
735
+ }
736
+ }, {
737
+ key: "resolve",
738
+ value: function resolve(keys) {
739
+ var _this4 = this;
740
+
741
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
742
+ var found;
743
+ var usedKey;
744
+ var exactUsedKey;
745
+ var usedLng;
746
+ var usedNS;
747
+ if (typeof keys === 'string') keys = [keys];
748
+ keys.forEach(function (k) {
749
+ if (_this4.isValidLookup(found)) return;
750
+
751
+ var extracted = _this4.extractFromKey(k, options);
752
+
753
+ var key = extracted.key;
754
+ usedKey = key;
755
+ var namespaces = extracted.namespaces;
756
+ if (_this4.options.fallbackNS) namespaces = namespaces.concat(_this4.options.fallbackNS);
757
+ var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
758
+ var needsContextHandling = options.context !== undefined && typeof options.context === 'string' && options.context !== '';
759
+ var codes = options.lngs ? options.lngs : _this4.languageUtils.toResolveHierarchy(options.lng || _this4.language, options.fallbackLng);
760
+ namespaces.forEach(function (ns) {
761
+ if (_this4.isValidLookup(found)) return;
762
+ usedNS = ns;
763
+
764
+ if (!checkedLoadedFor["".concat(codes[0], "-").concat(ns)] && _this4.utils && _this4.utils.hasLoadedNamespace && !_this4.utils.hasLoadedNamespace(usedNS)) {
765
+ checkedLoadedFor["".concat(codes[0], "-").concat(ns)] = true;
766
+
767
+ _this4.logger.warn("key \"".concat(usedKey, "\" for languages \"").concat(codes.join(', '), "\" won't get resolved as namespace \"").concat(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!!!');
768
+ }
769
+
770
+ codes.forEach(function (code) {
771
+ if (_this4.isValidLookup(found)) return;
772
+ usedLng = code;
773
+ var finalKey = key;
774
+ var finalKeys = [finalKey];
775
+
776
+ if (_this4.i18nFormat && _this4.i18nFormat.addLookupKeys) {
777
+ _this4.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
778
+ } else {
779
+ var pluralSuffix;
780
+ if (needsPluralHandling) pluralSuffix = _this4.pluralResolver.getSuffix(code, options.count);
781
+ if (needsPluralHandling && needsContextHandling) finalKeys.push(finalKey + pluralSuffix);
782
+ if (needsContextHandling) finalKeys.push(finalKey += "".concat(_this4.options.contextSeparator).concat(options.context));
783
+ if (needsPluralHandling) finalKeys.push(finalKey += pluralSuffix);
784
+ }
785
+
786
+ var possibleKey;
787
+
788
+ while (possibleKey = finalKeys.pop()) {
789
+ if (!_this4.isValidLookup(found)) {
790
+ exactUsedKey = possibleKey;
791
+ found = _this4.getResource(code, ns, possibleKey, options);
792
+ }
793
+ }
794
+ });
795
+ });
796
+ });
797
+ return {
798
+ res: found,
799
+ usedKey: usedKey,
800
+ exactUsedKey: exactUsedKey,
801
+ usedLng: usedLng,
802
+ usedNS: usedNS
803
+ };
804
+ }
805
+ }, {
806
+ key: "isValidLookup",
807
+ value: function isValidLookup(res) {
808
+ return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
809
+ }
810
+ }, {
811
+ key: "getResource",
812
+ value: function getResource(code, ns, key) {
813
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
814
+ if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
815
+ return this.resourceStore.getResource(code, ns, key, options);
816
+ }
817
+ }]);
818
+
819
+ return Translator;
820
+ }(EventEmitter);
821
+
822
+ function capitalize(string) {
823
+ return string.charAt(0).toUpperCase() + string.slice(1);
824
+ }
825
+
826
+ var LanguageUtil = function () {
827
+ function LanguageUtil(options) {
828
+ _classCallCheck(this, LanguageUtil);
829
+
830
+ this.options = options;
831
+ this.whitelist = this.options.supportedLngs || false;
832
+ this.supportedLngs = this.options.supportedLngs || false;
833
+ this.logger = baseLogger.create('languageUtils');
834
+ }
835
+
836
+ _createClass(LanguageUtil, [{
837
+ key: "getScriptPartFromCode",
838
+ value: function getScriptPartFromCode(code) {
839
+ if (!code || code.indexOf('-') < 0) return null;
840
+ var p = code.split('-');
841
+ if (p.length === 2) return null;
842
+ p.pop();
843
+ if (p[p.length - 1].toLowerCase() === 'x') return null;
844
+ return this.formatLanguageCode(p.join('-'));
845
+ }
846
+ }, {
847
+ key: "getLanguagePartFromCode",
848
+ value: function getLanguagePartFromCode(code) {
849
+ if (!code || code.indexOf('-') < 0) return code;
850
+ var p = code.split('-');
851
+ return this.formatLanguageCode(p[0]);
852
+ }
853
+ }, {
854
+ key: "formatLanguageCode",
855
+ value: function formatLanguageCode(code) {
856
+ if (typeof code === 'string' && code.indexOf('-') > -1) {
857
+ var specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
858
+ var p = code.split('-');
859
+
860
+ if (this.options.lowerCaseLng) {
861
+ p = p.map(function (part) {
862
+ return part.toLowerCase();
863
+ });
864
+ } else if (p.length === 2) {
865
+ p[0] = p[0].toLowerCase();
866
+ p[1] = p[1].toUpperCase();
867
+ if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
868
+ } else if (p.length === 3) {
869
+ p[0] = p[0].toLowerCase();
870
+ if (p[1].length === 2) p[1] = p[1].toUpperCase();
871
+ if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();
872
+ if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
873
+ if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
874
+ }
875
+
876
+ return p.join('-');
877
+ }
878
+
879
+ return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
880
+ }
881
+ }, {
882
+ key: "isWhitelisted",
883
+ value: function isWhitelisted(code) {
884
+ this.logger.deprecate('languageUtils.isWhitelisted', 'function "isWhitelisted" will be renamed to "isSupportedCode" in the next major - please make sure to rename it\'s usage asap.');
885
+ return this.isSupportedCode(code);
886
+ }
887
+ }, {
888
+ key: "isSupportedCode",
889
+ value: function isSupportedCode(code) {
890
+ if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
891
+ code = this.getLanguagePartFromCode(code);
892
+ }
893
+
894
+ return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
895
+ }
896
+ }, {
897
+ key: "getBestMatchFromCodes",
898
+ value: function getBestMatchFromCodes(codes) {
899
+ var _this = this;
900
+
901
+ if (!codes) return null;
902
+ var found;
903
+ codes.forEach(function (code) {
904
+ if (found) return;
905
+
906
+ var cleanedLng = _this.formatLanguageCode(code);
907
+
908
+ if (!_this.options.supportedLngs || _this.isSupportedCode(cleanedLng)) found = cleanedLng;
909
+ });
910
+
911
+ if (!found && this.options.supportedLngs) {
912
+ codes.forEach(function (code) {
913
+ if (found) return;
914
+
915
+ var lngOnly = _this.getLanguagePartFromCode(code);
916
+
917
+ if (_this.isSupportedCode(lngOnly)) return found = lngOnly;
918
+ found = _this.options.supportedLngs.find(function (supportedLng) {
919
+ if (supportedLng.indexOf(lngOnly) === 0) return supportedLng;
920
+ });
921
+ });
922
+ }
923
+
924
+ if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
925
+ return found;
926
+ }
927
+ }, {
928
+ key: "getFallbackCodes",
929
+ value: function getFallbackCodes(fallbacks, code) {
930
+ if (!fallbacks) return [];
931
+ if (typeof fallbacks === 'string') fallbacks = [fallbacks];
932
+ if (Object.prototype.toString.apply(fallbacks) === '[object Array]') return fallbacks;
933
+ if (!code) return fallbacks["default"] || [];
934
+ var found = fallbacks[code];
935
+ if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
936
+ if (!found) found = fallbacks[this.formatLanguageCode(code)];
937
+ if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
938
+ if (!found) found = fallbacks["default"];
939
+ return found || [];
940
+ }
941
+ }, {
942
+ key: "toResolveHierarchy",
943
+ value: function toResolveHierarchy(code, fallbackCode) {
944
+ var _this2 = this;
945
+
946
+ var fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
947
+ var codes = [];
948
+
949
+ var addCode = function addCode(c) {
950
+ if (!c) return;
951
+
952
+ if (_this2.isSupportedCode(c)) {
953
+ codes.push(c);
954
+ } else {
955
+ _this2.logger.warn("rejecting language code not found in supportedLngs: ".concat(c));
956
+ }
957
+ };
958
+
959
+ if (typeof code === 'string' && code.indexOf('-') > -1) {
960
+ if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
961
+ if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
962
+ if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
963
+ } else if (typeof code === 'string') {
964
+ addCode(this.formatLanguageCode(code));
965
+ }
966
+
967
+ fallbackCodes.forEach(function (fc) {
968
+ if (codes.indexOf(fc) < 0) addCode(_this2.formatLanguageCode(fc));
969
+ });
970
+ return codes;
971
+ }
972
+ }]);
973
+
974
+ return LanguageUtil;
975
+ }();
976
+
977
+ var sets = [{
978
+ lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'ti', 'tr', 'uz', 'wa'],
979
+ nr: [1, 2],
980
+ fc: 1
981
+ }, {
982
+ lngs: ['af', 'an', 'ast', 'az', 'bg', 'bn', 'ca', 'da', 'de', 'dev', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fi', 'fo', 'fur', 'fy', 'gl', 'gu', 'ha', 'hi', 'hu', 'hy', 'ia', 'it', 'kn', 'ku', 'lb', 'mai', 'ml', 'mn', 'mr', 'nah', 'nap', 'nb', 'ne', 'nl', 'nn', 'no', 'nso', 'pa', 'pap', 'pms', 'ps', 'pt-PT', 'rm', 'sco', 'se', 'si', 'so', 'son', 'sq', 'sv', 'sw', 'ta', 'te', 'tk', 'ur', 'yo'],
983
+ nr: [1, 2],
984
+ fc: 2
985
+ }, {
986
+ lngs: ['ay', 'bo', 'cgg', 'fa', 'ht', 'id', 'ja', 'jbo', 'ka', 'kk', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'],
987
+ nr: [1],
988
+ fc: 3
989
+ }, {
990
+ lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'],
991
+ nr: [1, 2, 5],
992
+ fc: 4
993
+ }, {
994
+ lngs: ['ar'],
995
+ nr: [0, 1, 2, 3, 11, 100],
996
+ fc: 5
997
+ }, {
998
+ lngs: ['cs', 'sk'],
999
+ nr: [1, 2, 5],
1000
+ fc: 6
1001
+ }, {
1002
+ lngs: ['csb', 'pl'],
1003
+ nr: [1, 2, 5],
1004
+ fc: 7
1005
+ }, {
1006
+ lngs: ['cy'],
1007
+ nr: [1, 2, 3, 8],
1008
+ fc: 8
1009
+ }, {
1010
+ lngs: ['fr'],
1011
+ nr: [1, 2],
1012
+ fc: 9
1013
+ }, {
1014
+ lngs: ['ga'],
1015
+ nr: [1, 2, 3, 7, 11],
1016
+ fc: 10
1017
+ }, {
1018
+ lngs: ['gd'],
1019
+ nr: [1, 2, 3, 20],
1020
+ fc: 11
1021
+ }, {
1022
+ lngs: ['is'],
1023
+ nr: [1, 2],
1024
+ fc: 12
1025
+ }, {
1026
+ lngs: ['jv'],
1027
+ nr: [0, 1],
1028
+ fc: 13
1029
+ }, {
1030
+ lngs: ['kw'],
1031
+ nr: [1, 2, 3, 4],
1032
+ fc: 14
1033
+ }, {
1034
+ lngs: ['lt'],
1035
+ nr: [1, 2, 10],
1036
+ fc: 15
1037
+ }, {
1038
+ lngs: ['lv'],
1039
+ nr: [1, 2, 0],
1040
+ fc: 16
1041
+ }, {
1042
+ lngs: ['mk'],
1043
+ nr: [1, 2],
1044
+ fc: 17
1045
+ }, {
1046
+ lngs: ['mnk'],
1047
+ nr: [0, 1, 2],
1048
+ fc: 18
1049
+ }, {
1050
+ lngs: ['mt'],
1051
+ nr: [1, 2, 11, 20],
1052
+ fc: 19
1053
+ }, {
1054
+ lngs: ['or'],
1055
+ nr: [2, 1],
1056
+ fc: 2
1057
+ }, {
1058
+ lngs: ['ro'],
1059
+ nr: [1, 2, 20],
1060
+ fc: 20
1061
+ }, {
1062
+ lngs: ['sl'],
1063
+ nr: [5, 1, 2, 3],
1064
+ fc: 21
1065
+ }, {
1066
+ lngs: ['he', 'iw'],
1067
+ nr: [1, 2, 20, 21],
1068
+ fc: 22
1069
+ }];
1070
+ var _rulesPluralsTypes = {
1071
+ 1: function _(n) {
1072
+ return Number(n > 1);
1073
+ },
1074
+ 2: function _(n) {
1075
+ return Number(n != 1);
1076
+ },
1077
+ 3: function _(n) {
1078
+ return 0;
1079
+ },
1080
+ 4: function _(n) {
1081
+ return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
1082
+ },
1083
+ 5: function _(n) {
1084
+ return Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5);
1085
+ },
1086
+ 6: function _(n) {
1087
+ return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);
1088
+ },
1089
+ 7: function _(n) {
1090
+ return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
1091
+ },
1092
+ 8: function _(n) {
1093
+ return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);
1094
+ },
1095
+ 9: function _(n) {
1096
+ return Number(n >= 2);
1097
+ },
1098
+ 10: function _(n) {
1099
+ return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);
1100
+ },
1101
+ 11: function _(n) {
1102
+ return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);
1103
+ },
1104
+ 12: function _(n) {
1105
+ return Number(n % 10 != 1 || n % 100 == 11);
1106
+ },
1107
+ 13: function _(n) {
1108
+ return Number(n !== 0);
1109
+ },
1110
+ 14: function _(n) {
1111
+ return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);
1112
+ },
1113
+ 15: function _(n) {
1114
+ return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
1115
+ },
1116
+ 16: function _(n) {
1117
+ return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);
1118
+ },
1119
+ 17: function _(n) {
1120
+ return Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1);
1121
+ },
1122
+ 18: function _(n) {
1123
+ return Number(n == 0 ? 0 : n == 1 ? 1 : 2);
1124
+ },
1125
+ 19: function _(n) {
1126
+ return Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3);
1127
+ },
1128
+ 20: function _(n) {
1129
+ return Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2);
1130
+ },
1131
+ 21: function _(n) {
1132
+ return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);
1133
+ },
1134
+ 22: function _(n) {
1135
+ return Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);
1136
+ }
1137
+ };
1138
+
1139
+ function createRules() {
1140
+ var rules = {};
1141
+ sets.forEach(function (set) {
1142
+ set.lngs.forEach(function (l) {
1143
+ rules[l] = {
1144
+ numbers: set.nr,
1145
+ plurals: _rulesPluralsTypes[set.fc]
1146
+ };
1147
+ });
1148
+ });
1149
+ return rules;
1150
+ }
1151
+
1152
+ var PluralResolver = function () {
1153
+ function PluralResolver(languageUtils) {
1154
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1155
+
1156
+ _classCallCheck(this, PluralResolver);
1157
+
1158
+ this.languageUtils = languageUtils;
1159
+ this.options = options;
1160
+ this.logger = baseLogger.create('pluralResolver');
1161
+ this.rules = createRules();
1162
+ }
1163
+
1164
+ _createClass(PluralResolver, [{
1165
+ key: "addRule",
1166
+ value: function addRule(lng, obj) {
1167
+ this.rules[lng] = obj;
1168
+ }
1169
+ }, {
1170
+ key: "getRule",
1171
+ value: function getRule(code) {
1172
+ return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
1173
+ }
1174
+ }, {
1175
+ key: "needsPlural",
1176
+ value: function needsPlural(code) {
1177
+ var rule = this.getRule(code);
1178
+ return rule && rule.numbers.length > 1;
1179
+ }
1180
+ }, {
1181
+ key: "getPluralFormsOfKey",
1182
+ value: function getPluralFormsOfKey(code, key) {
1183
+ var _this = this;
1184
+
1185
+ var ret = [];
1186
+ var rule = this.getRule(code);
1187
+ if (!rule) return ret;
1188
+ rule.numbers.forEach(function (n) {
1189
+ var suffix = _this.getSuffix(code, n);
1190
+
1191
+ ret.push("".concat(key).concat(suffix));
1192
+ });
1193
+ return ret;
1194
+ }
1195
+ }, {
1196
+ key: "getSuffix",
1197
+ value: function getSuffix(code, count) {
1198
+ var _this2 = this;
1199
+
1200
+ var rule = this.getRule(code);
1201
+
1202
+ if (rule) {
1203
+ var idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
1204
+ var suffix = rule.numbers[idx];
1205
+
1206
+ if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
1207
+ if (suffix === 2) {
1208
+ suffix = 'plural';
1209
+ } else if (suffix === 1) {
1210
+ suffix = '';
1211
+ }
1212
+ }
1213
+
1214
+ var returnSuffix = function returnSuffix() {
1215
+ return _this2.options.prepend && suffix.toString() ? _this2.options.prepend + suffix.toString() : suffix.toString();
1216
+ };
1217
+
1218
+ if (this.options.compatibilityJSON === 'v1') {
1219
+ if (suffix === 1) return '';
1220
+ if (typeof suffix === 'number') return "_plural_".concat(suffix.toString());
1221
+ return returnSuffix();
1222
+ } else if (this.options.compatibilityJSON === 'v2') {
1223
+ return returnSuffix();
1224
+ } else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
1225
+ return returnSuffix();
1226
+ }
1227
+
1228
+ return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
1229
+ }
1230
+
1231
+ this.logger.warn("no plural rule found for: ".concat(code));
1232
+ return '';
1233
+ }
1234
+ }]);
1235
+
1236
+ return PluralResolver;
1237
+ }();
1238
+
1239
+ var Interpolator = function () {
1240
+ function Interpolator() {
1241
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1242
+
1243
+ _classCallCheck(this, Interpolator);
1244
+
1245
+ this.logger = baseLogger.create('interpolator');
1246
+ this.options = options;
1247
+
1248
+ this.format = options.interpolation && options.interpolation.format || function (value) {
1249
+ return value;
1250
+ };
1251
+
1252
+ this.init(options);
1253
+ }
1254
+
1255
+ _createClass(Interpolator, [{
1256
+ key: "init",
1257
+ value: function init() {
1258
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1259
+ if (!options.interpolation) options.interpolation = {
1260
+ escapeValue: true
1261
+ };
1262
+ var iOpts = options.interpolation;
1263
+ this.escape = iOpts.escape !== undefined ? iOpts.escape : escape;
1264
+ this.escapeValue = iOpts.escapeValue !== undefined ? iOpts.escapeValue : true;
1265
+ this.useRawValueToEscape = iOpts.useRawValueToEscape !== undefined ? iOpts.useRawValueToEscape : false;
1266
+ this.prefix = iOpts.prefix ? regexEscape(iOpts.prefix) : iOpts.prefixEscaped || '{{';
1267
+ this.suffix = iOpts.suffix ? regexEscape(iOpts.suffix) : iOpts.suffixEscaped || '}}';
1268
+ this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
1269
+ this.unescapePrefix = iOpts.unescapeSuffix ? '' : iOpts.unescapePrefix || '-';
1270
+ this.unescapeSuffix = this.unescapePrefix ? '' : iOpts.unescapeSuffix || '';
1271
+ this.nestingPrefix = iOpts.nestingPrefix ? regexEscape(iOpts.nestingPrefix) : iOpts.nestingPrefixEscaped || regexEscape('$t(');
1272
+ this.nestingSuffix = iOpts.nestingSuffix ? regexEscape(iOpts.nestingSuffix) : iOpts.nestingSuffixEscaped || regexEscape(')');
1273
+ this.nestingOptionsSeparator = iOpts.nestingOptionsSeparator ? iOpts.nestingOptionsSeparator : iOpts.nestingOptionsSeparator || ',';
1274
+ this.maxReplaces = iOpts.maxReplaces ? iOpts.maxReplaces : 1000;
1275
+ this.alwaysFormat = iOpts.alwaysFormat !== undefined ? iOpts.alwaysFormat : false;
1276
+ this.resetRegExp();
1277
+ }
1278
+ }, {
1279
+ key: "reset",
1280
+ value: function reset() {
1281
+ if (this.options) this.init(this.options);
1282
+ }
1283
+ }, {
1284
+ key: "resetRegExp",
1285
+ value: function resetRegExp() {
1286
+ var regexpStr = "".concat(this.prefix, "(.+?)").concat(this.suffix);
1287
+ this.regexp = new RegExp(regexpStr, 'g');
1288
+ var regexpUnescapeStr = "".concat(this.prefix).concat(this.unescapePrefix, "(.+?)").concat(this.unescapeSuffix).concat(this.suffix);
1289
+ this.regexpUnescape = new RegExp(regexpUnescapeStr, 'g');
1290
+ var nestingRegexpStr = "".concat(this.nestingPrefix, "(.+?)").concat(this.nestingSuffix);
1291
+ this.nestingRegexp = new RegExp(nestingRegexpStr, 'g');
1292
+ }
1293
+ }, {
1294
+ key: "interpolate",
1295
+ value: function interpolate(str, data, lng, options) {
1296
+ var _this = this;
1297
+
1298
+ var match;
1299
+ var value;
1300
+ var replaces;
1301
+ var defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
1302
+
1303
+ function regexSafe(val) {
1304
+ return val.replace(/\$/g, '$$$$');
1305
+ }
1306
+
1307
+ var handleFormat = function handleFormat(key) {
1308
+ if (key.indexOf(_this.formatSeparator) < 0) {
1309
+ var path = getPathWithDefaults(data, defaultData, key);
1310
+ return _this.alwaysFormat ? _this.format(path, undefined, lng) : path;
1311
+ }
1312
+
1313
+ var p = key.split(_this.formatSeparator);
1314
+ var k = p.shift().trim();
1315
+ var f = p.join(_this.formatSeparator).trim();
1316
+ return _this.format(getPathWithDefaults(data, defaultData, k), f, lng, options);
1317
+ };
1318
+
1319
+ this.resetRegExp();
1320
+ var missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
1321
+ var skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables || this.options.interpolation.skipOnVariables;
1322
+ var todos = [{
1323
+ regex: this.regexpUnescape,
1324
+ safeValue: function safeValue(val) {
1325
+ return regexSafe(val);
1326
+ }
1327
+ }, {
1328
+ regex: this.regexp,
1329
+ safeValue: function safeValue(val) {
1330
+ return _this.escapeValue ? regexSafe(_this.escape(val)) : regexSafe(val);
1331
+ }
1332
+ }];
1333
+ todos.forEach(function (todo) {
1334
+ replaces = 0;
1335
+
1336
+ while (match = todo.regex.exec(str)) {
1337
+ value = handleFormat(match[1].trim());
1338
+
1339
+ if (value === undefined) {
1340
+ if (typeof missingInterpolationHandler === 'function') {
1341
+ var temp = missingInterpolationHandler(str, match, options);
1342
+ value = typeof temp === 'string' ? temp : '';
1343
+ } else if (skipOnVariables) {
1344
+ value = match[0];
1345
+ continue;
1346
+ } else {
1347
+ _this.logger.warn("missed to pass in variable ".concat(match[1], " for interpolating ").concat(str));
1348
+
1349
+ value = '';
1350
+ }
1351
+ } else if (typeof value !== 'string' && !_this.useRawValueToEscape) {
1352
+ value = makeString(value);
1353
+ }
1354
+
1355
+ str = str.replace(match[0], todo.safeValue(value));
1356
+ todo.regex.lastIndex = 0;
1357
+ replaces++;
1358
+
1359
+ if (replaces >= _this.maxReplaces) {
1360
+ break;
1361
+ }
1362
+ }
1363
+ });
1364
+ return str;
1365
+ }
1366
+ }, {
1367
+ key: "nest",
1368
+ value: function nest(str, fc) {
1369
+ var _this2 = this;
1370
+
1371
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1372
+ var match;
1373
+ var value;
1374
+
1375
+ var clonedOptions = _objectSpread({}, options);
1376
+
1377
+ clonedOptions.applyPostProcessor = false;
1378
+ delete clonedOptions.defaultValue;
1379
+
1380
+ function handleHasOptions(key, inheritedOptions) {
1381
+ var sep = this.nestingOptionsSeparator;
1382
+ if (key.indexOf(sep) < 0) return key;
1383
+ var c = key.split(new RegExp("".concat(sep, "[ ]*{")));
1384
+ var optionsString = "{".concat(c[1]);
1385
+ key = c[0];
1386
+ optionsString = this.interpolate(optionsString, clonedOptions);
1387
+ optionsString = optionsString.replace(/'/g, '"');
1388
+
1389
+ try {
1390
+ clonedOptions = JSON.parse(optionsString);
1391
+ if (inheritedOptions) clonedOptions = _objectSpread({}, inheritedOptions, clonedOptions);
1392
+ } catch (e) {
1393
+ this.logger.warn("failed parsing options string in nesting for key ".concat(key), e);
1394
+ return "".concat(key).concat(sep).concat(optionsString);
1395
+ }
1396
+
1397
+ delete clonedOptions.defaultValue;
1398
+ return key;
1399
+ }
1400
+
1401
+ while (match = this.nestingRegexp.exec(str)) {
1402
+ var formatters = [];
1403
+ var doReduce = false;
1404
+
1405
+ if (match[0].includes(this.formatSeparator) && !/{.*}/.test(match[1])) {
1406
+ var r = match[1].split(this.formatSeparator).map(function (elem) {
1407
+ return elem.trim();
1408
+ });
1409
+ match[1] = r.shift();
1410
+ formatters = r;
1411
+ doReduce = true;
1412
+ }
1413
+
1414
+ value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
1415
+ if (value && match[0] === str && typeof value !== 'string') return value;
1416
+ if (typeof value !== 'string') value = makeString(value);
1417
+
1418
+ if (!value) {
1419
+ this.logger.warn("missed to resolve ".concat(match[1], " for nesting ").concat(str));
1420
+ value = '';
1421
+ }
1422
+
1423
+ if (doReduce) {
1424
+ value = formatters.reduce(function (v, f) {
1425
+ return _this2.format(v, f, options.lng, options);
1426
+ }, value.trim());
1427
+ }
1428
+
1429
+ str = str.replace(match[0], value);
1430
+ this.regexp.lastIndex = 0;
1431
+ }
1432
+
1433
+ return str;
1434
+ }
1435
+ }]);
1436
+
1437
+ return Interpolator;
1438
+ }();
1439
+
1440
+ function remove(arr, what) {
1441
+ var found = arr.indexOf(what);
1442
+
1443
+ while (found !== -1) {
1444
+ arr.splice(found, 1);
1445
+ found = arr.indexOf(what);
1446
+ }
1447
+ }
1448
+
1449
+ var Connector = function (_EventEmitter) {
1450
+ _inherits(Connector, _EventEmitter);
1451
+
1452
+ function Connector(backend, store, services) {
1453
+ var _this;
1454
+
1455
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1456
+
1457
+ _classCallCheck(this, Connector);
1458
+
1459
+ _this = _possibleConstructorReturn(this, _getPrototypeOf(Connector).call(this));
1460
+
1461
+ if (isIE10) {
1462
+ EventEmitter.call(_assertThisInitialized(_this));
1463
+ }
1464
+
1465
+ _this.backend = backend;
1466
+ _this.store = store;
1467
+ _this.services = services;
1468
+ _this.languageUtils = services.languageUtils;
1469
+ _this.options = options;
1470
+ _this.logger = baseLogger.create('backendConnector');
1471
+ _this.state = {};
1472
+ _this.queue = [];
1473
+
1474
+ if (_this.backend && _this.backend.init) {
1475
+ _this.backend.init(services, options.backend, options);
1476
+ }
1477
+
1478
+ return _this;
1479
+ }
1480
+
1481
+ _createClass(Connector, [{
1482
+ key: "queueLoad",
1483
+ value: function queueLoad(languages, namespaces, options, callback) {
1484
+ var _this2 = this;
1485
+
1486
+ var toLoad = [];
1487
+ var pending = [];
1488
+ var toLoadLanguages = [];
1489
+ var toLoadNamespaces = [];
1490
+ languages.forEach(function (lng) {
1491
+ var hasAllNamespaces = true;
1492
+ namespaces.forEach(function (ns) {
1493
+ var name = "".concat(lng, "|").concat(ns);
1494
+
1495
+ if (!options.reload && _this2.store.hasResourceBundle(lng, ns)) {
1496
+ _this2.state[name] = 2;
1497
+ } else if (_this2.state[name] < 0) ; else if (_this2.state[name] === 1) {
1498
+ if (pending.indexOf(name) < 0) pending.push(name);
1499
+ } else {
1500
+ _this2.state[name] = 1;
1501
+ hasAllNamespaces = false;
1502
+ if (pending.indexOf(name) < 0) pending.push(name);
1503
+ if (toLoad.indexOf(name) < 0) toLoad.push(name);
1504
+ if (toLoadNamespaces.indexOf(ns) < 0) toLoadNamespaces.push(ns);
1505
+ }
1506
+ });
1507
+ if (!hasAllNamespaces) toLoadLanguages.push(lng);
1508
+ });
1509
+
1510
+ if (toLoad.length || pending.length) {
1511
+ this.queue.push({
1512
+ pending: pending,
1513
+ loaded: {},
1514
+ errors: [],
1515
+ callback: callback
1516
+ });
1517
+ }
1518
+
1519
+ return {
1520
+ toLoad: toLoad,
1521
+ pending: pending,
1522
+ toLoadLanguages: toLoadLanguages,
1523
+ toLoadNamespaces: toLoadNamespaces
1524
+ };
1525
+ }
1526
+ }, {
1527
+ key: "loaded",
1528
+ value: function loaded(name, err, data) {
1529
+ var s = name.split('|');
1530
+ var lng = s[0];
1531
+ var ns = s[1];
1532
+ if (err) this.emit('failedLoading', lng, ns, err);
1533
+
1534
+ if (data) {
1535
+ this.store.addResourceBundle(lng, ns, data);
1536
+ }
1537
+
1538
+ this.state[name] = err ? -1 : 2;
1539
+ var loaded = {};
1540
+ this.queue.forEach(function (q) {
1541
+ pushPath(q.loaded, [lng], ns);
1542
+ remove(q.pending, name);
1543
+ if (err) q.errors.push(err);
1544
+
1545
+ if (q.pending.length === 0 && !q.done) {
1546
+ Object.keys(q.loaded).forEach(function (l) {
1547
+ if (!loaded[l]) loaded[l] = [];
1548
+
1549
+ if (q.loaded[l].length) {
1550
+ q.loaded[l].forEach(function (ns) {
1551
+ if (loaded[l].indexOf(ns) < 0) loaded[l].push(ns);
1552
+ });
1553
+ }
1554
+ });
1555
+ q.done = true;
1556
+
1557
+ if (q.errors.length) {
1558
+ q.callback(q.errors);
1559
+ } else {
1560
+ q.callback();
1561
+ }
1562
+ }
1563
+ });
1564
+ this.emit('loaded', loaded);
1565
+ this.queue = this.queue.filter(function (q) {
1566
+ return !q.done;
1567
+ });
1568
+ }
1569
+ }, {
1570
+ key: "read",
1571
+ value: function read(lng, ns, fcName) {
1572
+ var _this3 = this;
1573
+
1574
+ var tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1575
+ var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 350;
1576
+ var callback = arguments.length > 5 ? arguments[5] : undefined;
1577
+ if (!lng.length) return callback(null, {});
1578
+ return this.backend[fcName](lng, ns, function (err, data) {
1579
+ if (err && data && tried < 5) {
1580
+ setTimeout(function () {
1581
+ _this3.read.call(_this3, lng, ns, fcName, tried + 1, wait * 2, callback);
1582
+ }, wait);
1583
+ return;
1584
+ }
1585
+
1586
+ callback(err, data);
1587
+ });
1588
+ }
1589
+ }, {
1590
+ key: "prepareLoading",
1591
+ value: function prepareLoading(languages, namespaces) {
1592
+ var _this4 = this;
1593
+
1594
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1595
+ var callback = arguments.length > 3 ? arguments[3] : undefined;
1596
+
1597
+ if (!this.backend) {
1598
+ this.logger.warn('No backend was added via i18next.use. Will not load resources.');
1599
+ return callback && callback();
1600
+ }
1601
+
1602
+ if (typeof languages === 'string') languages = this.languageUtils.toResolveHierarchy(languages);
1603
+ if (typeof namespaces === 'string') namespaces = [namespaces];
1604
+ var toLoad = this.queueLoad(languages, namespaces, options, callback);
1605
+
1606
+ if (!toLoad.toLoad.length) {
1607
+ if (!toLoad.pending.length) callback();
1608
+ return null;
1609
+ }
1610
+
1611
+ toLoad.toLoad.forEach(function (name) {
1612
+ _this4.loadOne(name);
1613
+ });
1614
+ }
1615
+ }, {
1616
+ key: "load",
1617
+ value: function load(languages, namespaces, callback) {
1618
+ this.prepareLoading(languages, namespaces, {}, callback);
1619
+ }
1620
+ }, {
1621
+ key: "reload",
1622
+ value: function reload(languages, namespaces, callback) {
1623
+ this.prepareLoading(languages, namespaces, {
1624
+ reload: true
1625
+ }, callback);
1626
+ }
1627
+ }, {
1628
+ key: "loadOne",
1629
+ value: function loadOne(name) {
1630
+ var _this5 = this;
1631
+
1632
+ var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1633
+ var s = name.split('|');
1634
+ var lng = s[0];
1635
+ var ns = s[1];
1636
+ this.read(lng, ns, 'read', undefined, undefined, function (err, data) {
1637
+ if (err) _this5.logger.warn("".concat(prefix, "loading namespace ").concat(ns, " for language ").concat(lng, " failed"), err);
1638
+ if (!err && data) _this5.logger.log("".concat(prefix, "loaded namespace ").concat(ns, " for language ").concat(lng), data);
1639
+
1640
+ _this5.loaded(name, err, data);
1641
+ });
1642
+ }
1643
+ }, {
1644
+ key: "saveMissing",
1645
+ value: function saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
1646
+ var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
1647
+
1648
+ if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
1649
+ this.logger.warn("did not save key \"".concat(key, "\" as the namespace \"").concat(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!!!');
1650
+ return;
1651
+ }
1652
+
1653
+ if (key === undefined || key === null || key === '') return;
1654
+
1655
+ if (this.backend && this.backend.create) {
1656
+ this.backend.create(languages, namespace, key, fallbackValue, null, _objectSpread({}, options, {
1657
+ isUpdate: isUpdate
1658
+ }));
1659
+ }
1660
+
1661
+ if (!languages || !languages[0]) return;
1662
+ this.store.addResource(languages[0], namespace, key, fallbackValue);
1663
+ }
1664
+ }]);
1665
+
1666
+ return Connector;
1667
+ }(EventEmitter);
1668
+
1669
+ function get() {
1670
+ return {
1671
+ debug: false,
1672
+ initImmediate: true,
1673
+ ns: ['translation'],
1674
+ defaultNS: ['translation'],
1675
+ fallbackLng: ['dev'],
1676
+ fallbackNS: false,
1677
+ whitelist: false,
1678
+ nonExplicitWhitelist: false,
1679
+ supportedLngs: false,
1680
+ nonExplicitSupportedLngs: false,
1681
+ load: 'all',
1682
+ preload: false,
1683
+ simplifyPluralSuffix: true,
1684
+ keySeparator: '.',
1685
+ nsSeparator: ':',
1686
+ pluralSeparator: '_',
1687
+ contextSeparator: '_',
1688
+ partialBundledLanguages: false,
1689
+ saveMissing: false,
1690
+ updateMissing: false,
1691
+ saveMissingTo: 'fallback',
1692
+ saveMissingPlurals: true,
1693
+ missingKeyHandler: false,
1694
+ missingInterpolationHandler: false,
1695
+ postProcess: false,
1696
+ postProcessPassResolved: false,
1697
+ returnNull: true,
1698
+ returnEmptyString: true,
1699
+ returnObjects: false,
1700
+ joinArrays: false,
1701
+ returnedObjectHandler: false,
1702
+ parseMissingKeyHandler: false,
1703
+ appendNamespaceToMissingKey: false,
1704
+ appendNamespaceToCIMode: false,
1705
+ overloadTranslationOptionHandler: function handle(args) {
1706
+ var ret = {};
1707
+ if (_typeof(args[1]) === 'object') ret = args[1];
1708
+ if (typeof args[1] === 'string') ret.defaultValue = args[1];
1709
+ if (typeof args[2] === 'string') ret.tDescription = args[2];
1710
+
1711
+ if (_typeof(args[2]) === 'object' || _typeof(args[3]) === 'object') {
1712
+ var options = args[3] || args[2];
1713
+ Object.keys(options).forEach(function (key) {
1714
+ ret[key] = options[key];
1715
+ });
1716
+ }
1717
+
1718
+ return ret;
1719
+ },
1720
+ interpolation: {
1721
+ escapeValue: true,
1722
+ format: function format(value, _format, lng, options) {
1723
+ return value;
1724
+ },
1725
+ prefix: '{{',
1726
+ suffix: '}}',
1727
+ formatSeparator: ',',
1728
+ unescapePrefix: '-',
1729
+ nestingPrefix: '$t(',
1730
+ nestingSuffix: ')',
1731
+ nestingOptionsSeparator: ',',
1732
+ maxReplaces: 1000,
1733
+ skipOnVariables: false
1734
+ }
1735
+ };
1736
+ }
1737
+ function transformOptions(options) {
1738
+ if (typeof options.ns === 'string') options.ns = [options.ns];
1739
+ if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
1740
+ if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS];
1741
+
1742
+ if (options.whitelist) {
1743
+ if (options.whitelist && options.whitelist.indexOf('cimode') < 0) {
1744
+ options.whitelist = options.whitelist.concat(['cimode']);
1745
+ }
1746
+
1747
+ options.supportedLngs = options.whitelist;
1748
+ }
1749
+
1750
+ if (options.nonExplicitWhitelist) {
1751
+ options.nonExplicitSupportedLngs = options.nonExplicitWhitelist;
1752
+ }
1753
+
1754
+ if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {
1755
+ options.supportedLngs = options.supportedLngs.concat(['cimode']);
1756
+ }
1757
+
1758
+ return options;
1759
+ }
1760
+
1761
+ function noop() {}
1762
+
1763
+ var I18n = function (_EventEmitter) {
1764
+ _inherits(I18n, _EventEmitter);
1765
+
1766
+ function I18n() {
1767
+ var _this;
1768
+
1769
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1770
+ var callback = arguments.length > 1 ? arguments[1] : undefined;
1771
+
1772
+ _classCallCheck(this, I18n);
1773
+
1774
+ _this = _possibleConstructorReturn(this, _getPrototypeOf(I18n).call(this));
1775
+
1776
+ if (isIE10) {
1777
+ EventEmitter.call(_assertThisInitialized(_this));
1778
+ }
1779
+
1780
+ _this.options = transformOptions(options);
1781
+ _this.services = {};
1782
+ _this.logger = baseLogger;
1783
+ _this.modules = {
1784
+ external: []
1785
+ };
1786
+
1787
+ if (callback && !_this.isInitialized && !options.isClone) {
1788
+ if (!_this.options.initImmediate) {
1789
+ _this.init(options, callback);
1790
+
1791
+ return _possibleConstructorReturn(_this, _assertThisInitialized(_this));
1792
+ }
1793
+
1794
+ setTimeout(function () {
1795
+ _this.init(options, callback);
1796
+ }, 0);
1797
+ }
1798
+
1799
+ return _this;
1800
+ }
1801
+
1802
+ _createClass(I18n, [{
1803
+ key: "init",
1804
+ value: function init() {
1805
+ var _this2 = this;
1806
+
1807
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1808
+ var callback = arguments.length > 1 ? arguments[1] : undefined;
1809
+
1810
+ if (typeof options === 'function') {
1811
+ callback = options;
1812
+ options = {};
1813
+ }
1814
+
1815
+ if (options.whitelist && !options.supportedLngs) {
1816
+ this.logger.deprecate('whitelist', 'option "whitelist" will be renamed to "supportedLngs" in the next major - please make sure to rename this option asap.');
1817
+ }
1818
+
1819
+ if (options.nonExplicitWhitelist && !options.nonExplicitSupportedLngs) {
1820
+ this.logger.deprecate('whitelist', 'options "nonExplicitWhitelist" will be renamed to "nonExplicitSupportedLngs" in the next major - please make sure to rename this option asap.');
1821
+ }
1822
+
1823
+ this.options = _objectSpread({}, get(), this.options, transformOptions(options));
1824
+ this.format = this.options.interpolation.format;
1825
+ if (!callback) callback = noop;
1826
+
1827
+ function createClassOnDemand(ClassOrObject) {
1828
+ if (!ClassOrObject) return null;
1829
+ if (typeof ClassOrObject === 'function') return new ClassOrObject();
1830
+ return ClassOrObject;
1831
+ }
1832
+
1833
+ if (!this.options.isClone) {
1834
+ if (this.modules.logger) {
1835
+ baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
1836
+ } else {
1837
+ baseLogger.init(null, this.options);
1838
+ }
1839
+
1840
+ var lu = new LanguageUtil(this.options);
1841
+ this.store = new ResourceStore(this.options.resources, this.options);
1842
+ var s = this.services;
1843
+ s.logger = baseLogger;
1844
+ s.resourceStore = this.store;
1845
+ s.languageUtils = lu;
1846
+ s.pluralResolver = new PluralResolver(lu, {
1847
+ prepend: this.options.pluralSeparator,
1848
+ compatibilityJSON: this.options.compatibilityJSON,
1849
+ simplifyPluralSuffix: this.options.simplifyPluralSuffix
1850
+ });
1851
+ s.interpolator = new Interpolator(this.options);
1852
+ s.utils = {
1853
+ hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
1854
+ };
1855
+ s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
1856
+ s.backendConnector.on('*', function (event) {
1857
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1858
+ args[_key - 1] = arguments[_key];
1859
+ }
1860
+
1861
+ _this2.emit.apply(_this2, [event].concat(args));
1862
+ });
1863
+
1864
+ if (this.modules.languageDetector) {
1865
+ s.languageDetector = createClassOnDemand(this.modules.languageDetector);
1866
+ s.languageDetector.init(s, this.options.detection, this.options);
1867
+ }
1868
+
1869
+ if (this.modules.i18nFormat) {
1870
+ s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
1871
+ if (s.i18nFormat.init) s.i18nFormat.init(this);
1872
+ }
1873
+
1874
+ this.translator = new Translator(this.services, this.options);
1875
+ this.translator.on('*', function (event) {
1876
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1877
+ args[_key2 - 1] = arguments[_key2];
1878
+ }
1879
+
1880
+ _this2.emit.apply(_this2, [event].concat(args));
1881
+ });
1882
+ this.modules.external.forEach(function (m) {
1883
+ if (m.init) m.init(_this2);
1884
+ });
1885
+ }
1886
+
1887
+ if (!this.modules.languageDetector && !this.options.lng) {
1888
+ this.logger.warn('init: no languageDetector is used and no lng is defined');
1889
+ }
1890
+
1891
+ var storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
1892
+ storeApi.forEach(function (fcName) {
1893
+ _this2[fcName] = function () {
1894
+ var _this2$store;
1895
+
1896
+ return (_this2$store = _this2.store)[fcName].apply(_this2$store, arguments);
1897
+ };
1898
+ });
1899
+ var storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
1900
+ storeApiChained.forEach(function (fcName) {
1901
+ _this2[fcName] = function () {
1902
+ var _this2$store2;
1903
+
1904
+ (_this2$store2 = _this2.store)[fcName].apply(_this2$store2, arguments);
1905
+
1906
+ return _this2;
1907
+ };
1908
+ });
1909
+ var deferred = defer();
1910
+
1911
+ var load = function load() {
1912
+ _this2.changeLanguage(_this2.options.lng, function (err, t) {
1913
+ _this2.isInitialized = true;
1914
+
1915
+ _this2.logger.log('initialized', _this2.options);
1916
+
1917
+ _this2.emit('initialized', _this2.options);
1918
+
1919
+ deferred.resolve(t);
1920
+ callback(err, t);
1921
+ });
1922
+ };
1923
+
1924
+ if (this.options.resources || !this.options.initImmediate) {
1925
+ load();
1926
+ } else {
1927
+ setTimeout(load, 0);
1928
+ }
1929
+
1930
+ return deferred;
1931
+ }
1932
+ }, {
1933
+ key: "loadResources",
1934
+ value: function loadResources(language) {
1935
+ var _this3 = this;
1936
+
1937
+ var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
1938
+ var usedCallback = callback;
1939
+ var usedLng = typeof language === 'string' ? language : this.language;
1940
+ if (typeof language === 'function') usedCallback = language;
1941
+
1942
+ if (!this.options.resources || this.options.partialBundledLanguages) {
1943
+ if (usedLng && usedLng.toLowerCase() === 'cimode') return usedCallback();
1944
+ var toLoad = [];
1945
+
1946
+ var append = function append(lng) {
1947
+ if (!lng) return;
1948
+
1949
+ var lngs = _this3.services.languageUtils.toResolveHierarchy(lng);
1950
+
1951
+ lngs.forEach(function (l) {
1952
+ if (toLoad.indexOf(l) < 0) toLoad.push(l);
1953
+ });
1954
+ };
1955
+
1956
+ if (!usedLng) {
1957
+ var fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1958
+ fallbacks.forEach(function (l) {
1959
+ return append(l);
1960
+ });
1961
+ } else {
1962
+ append(usedLng);
1963
+ }
1964
+
1965
+ if (this.options.preload) {
1966
+ this.options.preload.forEach(function (l) {
1967
+ return append(l);
1968
+ });
1969
+ }
1970
+
1971
+ this.services.backendConnector.load(toLoad, this.options.ns, usedCallback);
1972
+ } else {
1973
+ usedCallback(null);
1974
+ }
1975
+ }
1976
+ }, {
1977
+ key: "reloadResources",
1978
+ value: function reloadResources(lngs, ns, callback) {
1979
+ var deferred = defer();
1980
+ if (!lngs) lngs = this.languages;
1981
+ if (!ns) ns = this.options.ns;
1982
+ if (!callback) callback = noop;
1983
+ this.services.backendConnector.reload(lngs, ns, function (err) {
1984
+ deferred.resolve();
1985
+ callback(err);
1986
+ });
1987
+ return deferred;
1988
+ }
1989
+ }, {
1990
+ key: "use",
1991
+ value: function use(module) {
1992
+ if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
1993
+ if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
1994
+
1995
+ if (module.type === 'backend') {
1996
+ this.modules.backend = module;
1997
+ }
1998
+
1999
+ if (module.type === 'logger' || module.log && module.warn && module.error) {
2000
+ this.modules.logger = module;
2001
+ }
2002
+
2003
+ if (module.type === 'languageDetector') {
2004
+ this.modules.languageDetector = module;
2005
+ }
2006
+
2007
+ if (module.type === 'i18nFormat') {
2008
+ this.modules.i18nFormat = module;
2009
+ }
2010
+
2011
+ if (module.type === 'postProcessor') {
2012
+ postProcessor.addPostProcessor(module);
2013
+ }
2014
+
2015
+ if (module.type === '3rdParty') {
2016
+ this.modules.external.push(module);
2017
+ }
2018
+
2019
+ return this;
2020
+ }
2021
+ }, {
2022
+ key: "changeLanguage",
2023
+ value: function changeLanguage(lng, callback) {
2024
+ var _this4 = this;
2025
+
2026
+ this.isLanguageChangingTo = lng;
2027
+ var deferred = defer();
2028
+ this.emit('languageChanging', lng);
2029
+
2030
+ var done = function done(err, l) {
2031
+ if (l) {
2032
+ _this4.language = l;
2033
+ _this4.languages = _this4.services.languageUtils.toResolveHierarchy(l);
2034
+
2035
+ _this4.translator.changeLanguage(l);
2036
+
2037
+ _this4.isLanguageChangingTo = undefined;
2038
+
2039
+ _this4.emit('languageChanged', l);
2040
+
2041
+ _this4.logger.log('languageChanged', l);
2042
+ } else {
2043
+ _this4.isLanguageChangingTo = undefined;
2044
+ }
2045
+
2046
+ deferred.resolve(function () {
2047
+ return _this4.t.apply(_this4, arguments);
2048
+ });
2049
+ if (callback) callback(err, function () {
2050
+ return _this4.t.apply(_this4, arguments);
2051
+ });
2052
+ };
2053
+
2054
+ var setLng = function setLng(lngs) {
2055
+ var l = typeof lngs === 'string' ? lngs : _this4.services.languageUtils.getBestMatchFromCodes(lngs);
2056
+
2057
+ if (l) {
2058
+ if (!_this4.language) {
2059
+ _this4.language = l;
2060
+ _this4.languages = _this4.services.languageUtils.toResolveHierarchy(l);
2061
+ }
2062
+
2063
+ if (!_this4.translator.language) _this4.translator.changeLanguage(l);
2064
+ if (_this4.services.languageDetector) _this4.services.languageDetector.cacheUserLanguage(l);
2065
+ }
2066
+
2067
+ _this4.loadResources(l, function (err) {
2068
+ done(err, l);
2069
+ });
2070
+ };
2071
+
2072
+ if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
2073
+ setLng(this.services.languageDetector.detect());
2074
+ } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
2075
+ this.services.languageDetector.detect(setLng);
2076
+ } else {
2077
+ setLng(lng);
2078
+ }
2079
+
2080
+ return deferred;
2081
+ }
2082
+ }, {
2083
+ key: "getFixedT",
2084
+ value: function getFixedT(lng, ns) {
2085
+ var _this5 = this;
2086
+
2087
+ var fixedT = function fixedT(key, opts) {
2088
+ var options;
2089
+
2090
+ if (_typeof(opts) !== 'object') {
2091
+ for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
2092
+ rest[_key3 - 2] = arguments[_key3];
2093
+ }
2094
+
2095
+ options = _this5.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2096
+ } else {
2097
+ options = _objectSpread({}, opts);
2098
+ }
2099
+
2100
+ options.lng = options.lng || fixedT.lng;
2101
+ options.lngs = options.lngs || fixedT.lngs;
2102
+ options.ns = options.ns || fixedT.ns;
2103
+ return _this5.t(key, options);
2104
+ };
2105
+
2106
+ if (typeof lng === 'string') {
2107
+ fixedT.lng = lng;
2108
+ } else {
2109
+ fixedT.lngs = lng;
2110
+ }
2111
+
2112
+ fixedT.ns = ns;
2113
+ return fixedT;
2114
+ }
2115
+ }, {
2116
+ key: "t",
2117
+ value: function t() {
2118
+ var _this$translator;
2119
+
2120
+ return this.translator && (_this$translator = this.translator).translate.apply(_this$translator, arguments);
2121
+ }
2122
+ }, {
2123
+ key: "exists",
2124
+ value: function exists() {
2125
+ var _this$translator2;
2126
+
2127
+ return this.translator && (_this$translator2 = this.translator).exists.apply(_this$translator2, arguments);
2128
+ }
2129
+ }, {
2130
+ key: "setDefaultNamespace",
2131
+ value: function setDefaultNamespace(ns) {
2132
+ this.options.defaultNS = ns;
2133
+ }
2134
+ }, {
2135
+ key: "hasLoadedNamespace",
2136
+ value: function hasLoadedNamespace(ns) {
2137
+ var _this6 = this;
2138
+
2139
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2140
+
2141
+ if (!this.isInitialized) {
2142
+ this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
2143
+ return false;
2144
+ }
2145
+
2146
+ if (!this.languages || !this.languages.length) {
2147
+ this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
2148
+ return false;
2149
+ }
2150
+
2151
+ var lng = this.languages[0];
2152
+ var fallbackLng = this.options ? this.options.fallbackLng : false;
2153
+ var lastLng = this.languages[this.languages.length - 1];
2154
+ if (lng.toLowerCase() === 'cimode') return true;
2155
+
2156
+ var loadNotPending = function loadNotPending(l, n) {
2157
+ var loadState = _this6.services.backendConnector.state["".concat(l, "|").concat(n)];
2158
+
2159
+ return loadState === -1 || loadState === 2;
2160
+ };
2161
+
2162
+ if (options.precheck) {
2163
+ var preResult = options.precheck(this, loadNotPending);
2164
+ if (preResult !== undefined) return preResult;
2165
+ }
2166
+
2167
+ if (this.hasResourceBundle(lng, ns)) return true;
2168
+ if (!this.services.backendConnector.backend) return true;
2169
+ if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
2170
+ return false;
2171
+ }
2172
+ }, {
2173
+ key: "loadNamespaces",
2174
+ value: function loadNamespaces(ns, callback) {
2175
+ var _this7 = this;
2176
+
2177
+ var deferred = defer();
2178
+
2179
+ if (!this.options.ns) {
2180
+ callback && callback();
2181
+ return Promise.resolve();
2182
+ }
2183
+
2184
+ if (typeof ns === 'string') ns = [ns];
2185
+ ns.forEach(function (n) {
2186
+ if (_this7.options.ns.indexOf(n) < 0) _this7.options.ns.push(n);
2187
+ });
2188
+ this.loadResources(function (err) {
2189
+ deferred.resolve();
2190
+ if (callback) callback(err);
2191
+ });
2192
+ return deferred;
2193
+ }
2194
+ }, {
2195
+ key: "loadLanguages",
2196
+ value: function loadLanguages(lngs, callback) {
2197
+ var deferred = defer();
2198
+ if (typeof lngs === 'string') lngs = [lngs];
2199
+ var preloaded = this.options.preload || [];
2200
+ var newLngs = lngs.filter(function (lng) {
2201
+ return preloaded.indexOf(lng) < 0;
2202
+ });
2203
+
2204
+ if (!newLngs.length) {
2205
+ if (callback) callback();
2206
+ return Promise.resolve();
2207
+ }
2208
+
2209
+ this.options.preload = preloaded.concat(newLngs);
2210
+ this.loadResources(function (err) {
2211
+ deferred.resolve();
2212
+ if (callback) callback(err);
2213
+ });
2214
+ return deferred;
2215
+ }
2216
+ }, {
2217
+ key: "dir",
2218
+ value: function dir(lng) {
2219
+ if (!lng) lng = this.languages && this.languages.length > 0 ? this.languages[0] : this.language;
2220
+ if (!lng) return 'rtl';
2221
+ var 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'];
2222
+ return rtlLngs.indexOf(this.services.languageUtils.getLanguagePartFromCode(lng)) >= 0 ? 'rtl' : 'ltr';
2223
+ }
2224
+ }, {
2225
+ key: "createInstance",
2226
+ value: function createInstance() {
2227
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2228
+ var callback = arguments.length > 1 ? arguments[1] : undefined;
2229
+ return new I18n(options, callback);
2230
+ }
2231
+ }, {
2232
+ key: "cloneInstance",
2233
+ value: function cloneInstance() {
2234
+ var _this8 = this;
2235
+
2236
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2237
+ var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
2238
+
2239
+ var mergedOptions = _objectSpread({}, this.options, options, {
2240
+ isClone: true
2241
+ });
2242
+
2243
+ var clone = new I18n(mergedOptions);
2244
+ var membersToCopy = ['store', 'services', 'language'];
2245
+ membersToCopy.forEach(function (m) {
2246
+ clone[m] = _this8[m];
2247
+ });
2248
+ clone.services = _objectSpread({}, this.services);
2249
+ clone.services.utils = {
2250
+ hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2251
+ };
2252
+ clone.translator = new Translator(clone.services, clone.options);
2253
+ clone.translator.on('*', function (event) {
2254
+ for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
2255
+ args[_key4 - 1] = arguments[_key4];
2256
+ }
2257
+
2258
+ clone.emit.apply(clone, [event].concat(args));
2259
+ });
2260
+ clone.init(mergedOptions, callback);
2261
+ clone.translator.options = clone.options;
2262
+ clone.translator.backendConnector.services.utils = {
2263
+ hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2264
+ };
2265
+ return clone;
2266
+ }
2267
+ }]);
2268
+
2269
+ return I18n;
2270
+ }(EventEmitter);
2271
+
2272
+ var i18next = new I18n();
2273
+
2274
+ export default i18next;
2275
+ //# sourceMappingURL=i18next.js.map