@dso-toolkit/core 66.1.0 → 66.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (456) hide show
  1. package/dist/cjs/{annotation-body-b062e93f.js → annotation-body-0cf33638.js} +2 -2
  2. package/dist/cjs/{annotation-body-b062e93f.js.map → annotation-body-0cf33638.js.map} +1 -1
  3. package/dist/cjs/{annotation-symbol-slot-e9741f0b.js → annotation-symbol-slot-6665ae62.js} +2 -2
  4. package/dist/cjs/{annotation-symbol-slot-e9741f0b.js.map → annotation-symbol-slot-6665ae62.js.map} +1 -1
  5. package/dist/cjs/dso-accordion-section.cjs.entry.js +1 -1
  6. package/dist/cjs/dso-accordion.cjs.entry.js +1 -1
  7. package/dist/cjs/dso-action-list-item.cjs.entry.js +1 -1
  8. package/dist/cjs/dso-action-list.cjs.entry.js +1 -1
  9. package/dist/cjs/dso-advanced-select.cjs.entry.js +1 -1
  10. package/dist/cjs/dso-alert_6.cjs.entry.js +31 -15
  11. package/dist/cjs/dso-alert_6.cjs.entry.js.map +1 -1
  12. package/dist/cjs/dso-annotation-activiteit.cjs.entry.js +4 -4
  13. package/dist/cjs/dso-annotation-activiteit.cjs.entry.js.map +1 -1
  14. package/dist/cjs/dso-annotation-gebiedsaanwijzing.cjs.entry.js +4 -4
  15. package/dist/cjs/dso-annotation-gebiedsaanwijzing.cjs.entry.js.map +1 -1
  16. package/dist/cjs/dso-annotation-kaart.cjs.entry.js +3 -3
  17. package/dist/cjs/dso-annotation-kaart.cjs.entry.js.map +1 -1
  18. package/dist/cjs/dso-annotation-locatie_2.cjs.entry.js +6 -6
  19. package/dist/cjs/dso-annotation-locatie_2.cjs.entry.js.map +1 -1
  20. package/dist/cjs/dso-annotation-omgevingsnormwaarde.cjs.entry.js +4 -4
  21. package/dist/cjs/dso-annotation-omgevingsnormwaarde.cjs.entry.js.map +1 -1
  22. package/dist/cjs/dso-attachments-counter_2.cjs.entry.js +1 -1
  23. package/dist/cjs/dso-autosuggest.cjs.entry.js +24 -8
  24. package/dist/cjs/dso-autosuggest.cjs.entry.js.map +1 -1
  25. package/dist/cjs/dso-banner.cjs.entry.js +1 -1
  26. package/dist/cjs/dso-card-container.cjs.entry.js +1 -1
  27. package/dist/cjs/dso-card.cjs.entry.js +1 -1
  28. package/dist/cjs/dso-date-picker-legacy.cjs.entry.js +1 -1
  29. package/dist/cjs/dso-date-picker.cjs.entry.js +1 -1
  30. package/dist/cjs/dso-document-card.cjs.entry.js +1 -1
  31. package/dist/cjs/dso-dropdown-menu.cjs.entry.js +2 -2
  32. package/dist/cjs/dso-header.cjs.entry.js +29 -4
  33. package/dist/cjs/dso-header.cjs.entry.js.map +1 -1
  34. package/dist/cjs/dso-helpcenter-panel.cjs.entry.js +1 -1
  35. package/dist/cjs/dso-highlight-box.cjs.entry.js +1 -1
  36. package/dist/cjs/dso-icon.cjs.entry.js +1 -1
  37. package/dist/cjs/dso-info-button.cjs.entry.js +1 -1
  38. package/dist/cjs/dso-info_2.cjs.entry.js +2 -2
  39. package/dist/cjs/dso-input-range.cjs.entry.js +1 -1
  40. package/dist/cjs/dso-label_2.cjs.entry.js +2 -2
  41. package/dist/cjs/dso-legend-item.cjs.entry.js +1 -1
  42. package/dist/cjs/dso-list-button.cjs.entry.js +1 -1
  43. package/dist/cjs/dso-logo.cjs.entry.js +8 -4
  44. package/dist/cjs/dso-logo.cjs.entry.js.map +1 -1
  45. package/dist/cjs/dso-map-base-layers.cjs.entry.js +19 -3
  46. package/dist/cjs/dso-map-base-layers.cjs.entry.js.map +1 -1
  47. package/dist/cjs/dso-map-controls.cjs.entry.js +26 -3
  48. package/dist/cjs/dso-map-controls.cjs.entry.js.map +1 -1
  49. package/dist/cjs/dso-map-overlays.cjs.entry.js +19 -3
  50. package/dist/cjs/dso-map-overlays.cjs.entry.js.map +1 -1
  51. package/dist/cjs/dso-mark-bar.cjs.entry.js +2 -2
  52. package/dist/cjs/dso-modal.cjs.entry.js +21 -4
  53. package/dist/cjs/dso-modal.cjs.entry.js.map +1 -1
  54. package/dist/cjs/dso-pagination.cjs.entry.js +1 -1
  55. package/dist/cjs/dso-plekinfo-card.cjs.entry.js +7 -3
  56. package/dist/cjs/dso-plekinfo-card.cjs.entry.js.map +1 -1
  57. package/dist/cjs/dso-progress-bar.cjs.entry.js +2 -2
  58. package/dist/cjs/dso-progress-indicator.cjs.entry.js +19 -3
  59. package/dist/cjs/dso-progress-indicator.cjs.entry.js.map +1 -1
  60. package/dist/cjs/dso-project-item.cjs.entry.js +2 -2
  61. package/dist/cjs/dso-renvooi_2.cjs.entry.js +21 -18
  62. package/dist/cjs/dso-renvooi_2.cjs.entry.js.map +1 -1
  63. package/dist/cjs/dso-responsive-element.cjs.entry.js +2 -2
  64. package/dist/cjs/dso-scrollable.cjs.entry.js +3 -3
  65. package/dist/cjs/dso-tab.cjs.entry.js +1 -1
  66. package/dist/cjs/dso-tabs.cjs.entry.js +2 -2
  67. package/dist/cjs/dso-toggletip.cjs.entry.js +2 -2
  68. package/dist/cjs/dso-toolkit.cjs.js +3 -3
  69. package/dist/cjs/dso-toolkit.cjs.js.map +1 -1
  70. package/dist/cjs/dso-tree-view.cjs.entry.js +2 -2
  71. package/dist/cjs/dso-viewer-grid.cjs.entry.js +2 -2
  72. package/dist/cjs/dsot-document-component-demo.cjs.entry.js +9 -3
  73. package/dist/cjs/dsot-document-component-demo.cjs.entry.js.map +1 -1
  74. package/dist/cjs/i18n-a63b3b9b.js +2384 -0
  75. package/dist/cjs/i18n-a63b3b9b.js.map +1 -0
  76. package/dist/cjs/{index-848434f1.js → index-af1ebee1.js} +31 -14
  77. package/dist/cjs/index-af1ebee1.js.map +1 -0
  78. package/dist/cjs/loader.cjs.js +2 -2
  79. package/dist/cjs/v4-6fbeaa38.js +65 -0
  80. package/dist/cjs/v4-6fbeaa38.js.map +1 -0
  81. package/dist/collection/collection-manifest.json +2 -2
  82. package/dist/collection/components/alert/alert.i18n.js +19 -0
  83. package/dist/collection/components/alert/alert.i18n.js.map +1 -0
  84. package/dist/collection/components/alert/alert.js +6 -8
  85. package/dist/collection/components/alert/alert.js.map +1 -1
  86. package/dist/collection/components/annotation/annotation.css +5 -0
  87. package/dist/collection/components/autosuggest/autosuggest.i18n.js +13 -0
  88. package/dist/collection/components/autosuggest/autosuggest.i18n.js.map +1 -0
  89. package/dist/collection/components/autosuggest/autosuggest.js +11 -7
  90. package/dist/collection/components/autosuggest/autosuggest.js.map +1 -1
  91. package/dist/collection/components/document-component/document-component.css +35 -4
  92. package/dist/collection/components/document-component/document-component.js +2 -2
  93. package/dist/collection/components/document-component/document-component.js.map +1 -1
  94. package/dist/collection/components/document-component-demo/document-component.demo.js +8 -2
  95. package/dist/collection/components/document-component-demo/document-component.demo.js.map +1 -1
  96. package/dist/collection/components/header/header.i18n.js +23 -0
  97. package/dist/collection/components/header/header.i18n.js.map +1 -0
  98. package/dist/collection/components/header/header.js +6 -3
  99. package/dist/collection/components/header/header.js.map +1 -1
  100. package/dist/collection/components/image-overlay/image-overlay.css +10 -0
  101. package/dist/collection/components/logo/logo.js +25 -3
  102. package/dist/collection/components/logo/logo.js.map +1 -1
  103. package/dist/collection/components/map-base-layers/map-base-layers.i18n.js +13 -0
  104. package/dist/collection/components/map-base-layers/map-base-layers.i18n.js.map +1 -0
  105. package/dist/collection/components/map-base-layers/map-base-layers.js +5 -1
  106. package/dist/collection/components/map-base-layers/map-base-layers.js.map +1 -1
  107. package/dist/collection/components/map-controls/map-controls.i18n.js +21 -0
  108. package/dist/collection/components/map-controls/map-controls.i18n.js.map +1 -0
  109. package/dist/collection/components/map-controls/map-controls.js +6 -3
  110. package/dist/collection/components/map-controls/map-controls.js.map +1 -1
  111. package/dist/collection/components/map-overlays/map-overlays.i18n.js +13 -0
  112. package/dist/collection/components/map-overlays/map-overlays.i18n.js.map +1 -0
  113. package/dist/collection/components/map-overlays/map-overlays.js +5 -1
  114. package/dist/collection/components/map-overlays/map-overlays.js.map +1 -1
  115. package/dist/collection/components/mark-bar/mark-bar.js +1 -1
  116. package/dist/collection/components/modal/modal.i18n.js +15 -0
  117. package/dist/collection/components/modal/modal.i18n.js.map +1 -0
  118. package/dist/collection/components/modal/modal.js +5 -2
  119. package/dist/collection/components/modal/modal.js.map +1 -1
  120. package/dist/collection/components/ozon-content/ozon-content.css +19 -0
  121. package/dist/collection/components/ozon-content/ozon-content.js +1 -1
  122. package/dist/collection/components/panel/panel.css +7 -5
  123. package/dist/collection/components/plekinfo-card/plekinfo-card.css +12 -4
  124. package/dist/collection/components/plekinfo-card/plekinfo-card.js +26 -2
  125. package/dist/collection/components/plekinfo-card/plekinfo-card.js.map +1 -1
  126. package/dist/collection/components/progress-bar/progress-bar.js +1 -1
  127. package/dist/collection/components/progress-indicator/progress-indicator.i18n.js +13 -0
  128. package/dist/collection/components/progress-indicator/progress-indicator.i18n.js.map +1 -0
  129. package/dist/collection/components/progress-indicator/progress-indicator.js +9 -6
  130. package/dist/collection/components/progress-indicator/progress-indicator.js.map +1 -1
  131. package/dist/collection/components/project-item/project-item.js +1 -1
  132. package/dist/collection/components/renvooi/renvooi.css +9 -0
  133. package/dist/collection/components/renvooi/renvooi.js +17 -14
  134. package/dist/collection/components/renvooi/renvooi.js.map +1 -1
  135. package/dist/collection/components/responsive-element/responsive-element.js +1 -1
  136. package/dist/collection/components/scrollable/scrollable.js +2 -2
  137. package/dist/collection/components/selectable/selectable.js +1 -1
  138. package/dist/collection/components/slide-toggle/slide-toggle.js +1 -1
  139. package/dist/collection/components/table/table.js +1 -1
  140. package/dist/collection/components/tabs/tabs.js +1 -1
  141. package/dist/collection/components/toggletip/toggletip.js +1 -1
  142. package/dist/collection/components/tooltip/tooltip.js +1 -1
  143. package/dist/collection/components/tree-view/tree-view.js +1 -1
  144. package/dist/collection/components/viewer-grid/viewer-grid.js +1 -1
  145. package/dist/collection/utils/i18n.js +31 -0
  146. package/dist/collection/utils/i18n.js.map +1 -0
  147. package/dist/components/alert.js +24 -8
  148. package/dist/components/alert.js.map +1 -1
  149. package/dist/components/annotation-locatie.js +1 -1
  150. package/dist/components/annotation-locatie.js.map +1 -1
  151. package/dist/components/document-component.js +3 -3
  152. package/dist/components/document-component.js.map +1 -1
  153. package/dist/components/dso-annotation-activiteit.js +1 -1
  154. package/dist/components/dso-annotation-activiteit.js.map +1 -1
  155. package/dist/components/dso-annotation-gebiedsaanwijzing.js +1 -1
  156. package/dist/components/dso-annotation-gebiedsaanwijzing.js.map +1 -1
  157. package/dist/components/dso-annotation-kaart.js +1 -1
  158. package/dist/components/dso-annotation-kaart.js.map +1 -1
  159. package/dist/components/dso-annotation-omgevingsnormwaarde.js +1 -1
  160. package/dist/components/dso-annotation-omgevingsnormwaarde.js.map +1 -1
  161. package/dist/components/dso-autosuggest.js +22 -6
  162. package/dist/components/dso-autosuggest.js.map +1 -1
  163. package/dist/components/dso-header.js +28 -3
  164. package/dist/components/dso-header.js.map +1 -1
  165. package/dist/components/dso-logo.js +8 -3
  166. package/dist/components/dso-logo.js.map +1 -1
  167. package/dist/components/dso-map-base-layers.js +17 -1
  168. package/dist/components/dso-map-base-layers.js.map +1 -1
  169. package/dist/components/dso-map-controls.js +26 -3
  170. package/dist/components/dso-map-controls.js.map +1 -1
  171. package/dist/components/dso-map-overlays.js +17 -1
  172. package/dist/components/dso-map-overlays.js.map +1 -1
  173. package/dist/components/dso-mark-bar.js +1 -1
  174. package/dist/components/dso-modal.js +19 -2
  175. package/dist/components/dso-modal.js.map +1 -1
  176. package/dist/components/dso-plekinfo-card.js +8 -3
  177. package/dist/components/dso-plekinfo-card.js.map +1 -1
  178. package/dist/components/dso-progress-bar.js +1 -1
  179. package/dist/components/dso-project-item.js +1 -1
  180. package/dist/components/dso-tabs.js +1 -1
  181. package/dist/components/dso-tree-view.js +1 -1
  182. package/dist/components/dso-viewer-grid.js +1 -1
  183. package/dist/components/dsot-document-component-demo.js +8 -2
  184. package/dist/components/dsot-document-component-demo.js.map +1 -1
  185. package/dist/components/i18n.js +2382 -0
  186. package/dist/components/i18n.js.map +1 -0
  187. package/dist/components/image-overlay.js +1 -1
  188. package/dist/components/image-overlay.js.map +1 -1
  189. package/dist/components/ozon-content.js +2 -2
  190. package/dist/components/ozon-content.js.map +1 -1
  191. package/dist/components/panel.js +1 -1
  192. package/dist/components/panel.js.map +1 -1
  193. package/dist/components/progress-indicator.js +18 -2
  194. package/dist/components/progress-indicator.js.map +1 -1
  195. package/dist/components/renvooi.js +19 -21
  196. package/dist/components/renvooi.js.map +1 -1
  197. package/dist/components/responsive-element.js +1 -1
  198. package/dist/components/scrollable.js +2 -2
  199. package/dist/components/selectable.js +1 -1
  200. package/dist/components/slide-toggle.js +1 -1
  201. package/dist/components/table.js +1 -1
  202. package/dist/components/toggletip.js +1 -1
  203. package/dist/components/tooltip.js +1 -1
  204. package/dist/components/v4.js +46 -48
  205. package/dist/components/v4.js.map +1 -1
  206. package/dist/dso-toolkit/dso-toolkit.esm.js +1 -1
  207. package/dist/dso-toolkit/dso-toolkit.esm.js.map +1 -1
  208. package/dist/dso-toolkit/{p-dd6cf2cd.entry.js → p-08121fee.entry.js} +2 -2
  209. package/dist/dso-toolkit/p-1022c4bd.entry.js +2 -0
  210. package/dist/dso-toolkit/p-1022c4bd.entry.js.map +1 -0
  211. package/dist/dso-toolkit/{p-64bf55d1.entry.js → p-10603e10.entry.js} +2 -2
  212. package/dist/dso-toolkit/p-13396f6d.js +2 -0
  213. package/dist/dso-toolkit/p-1616c445.entry.js +2 -0
  214. package/dist/dso-toolkit/p-1616c445.entry.js.map +1 -0
  215. package/dist/dso-toolkit/{p-8e699eb2.entry.js → p-226833eb.entry.js} +2 -2
  216. package/dist/dso-toolkit/p-3225dd02.entry.js +2 -0
  217. package/dist/dso-toolkit/p-3225dd02.entry.js.map +1 -0
  218. package/dist/dso-toolkit/{p-e9896db2.entry.js → p-38cc23e1.entry.js} +2 -2
  219. package/dist/dso-toolkit/{p-cd1a65e7.entry.js → p-40810e10.entry.js} +2 -2
  220. package/dist/dso-toolkit/{p-6a414b15.entry.js → p-47ae7799.entry.js} +2 -2
  221. package/dist/dso-toolkit/{p-ea46d648.entry.js → p-49e93ef5.entry.js} +2 -2
  222. package/dist/dso-toolkit/{p-a705c684.entry.js → p-4cb8ef54.entry.js} +2 -2
  223. package/dist/dso-toolkit/{p-2dc8e61f.entry.js.map → p-4cb8ef54.entry.js.map} +1 -1
  224. package/dist/dso-toolkit/{p-404ea2b9.entry.js → p-52a2c0b3.entry.js} +2 -2
  225. package/dist/dso-toolkit/{p-404ea2b9.entry.js.map → p-52a2c0b3.entry.js.map} +1 -1
  226. package/dist/dso-toolkit/{p-b5744b74.entry.js → p-5c047dfd.entry.js} +2 -2
  227. package/dist/dso-toolkit/{p-9ebf26d8.entry.js → p-5e6704bb.entry.js} +2 -2
  228. package/dist/dso-toolkit/{p-331f52b3.entry.js → p-636a2ad2.entry.js} +2 -2
  229. package/dist/dso-toolkit/{p-a801f428.entry.js → p-74e0e63e.entry.js} +2 -2
  230. package/dist/dso-toolkit/{p-bda2d5ce.entry.js → p-75c65097.entry.js} +2 -2
  231. package/dist/dso-toolkit/{p-54fff8c0.entry.js → p-76dfbee3.entry.js} +2 -2
  232. package/dist/dso-toolkit/p-7cfa6ab1.entry.js +2 -0
  233. package/dist/dso-toolkit/p-7cfa6ab1.entry.js.map +1 -0
  234. package/dist/dso-toolkit/p-7fc1e494.js +3 -0
  235. package/dist/dso-toolkit/p-7fc1e494.js.map +1 -0
  236. package/dist/dso-toolkit/{p-cc6c428b.entry.js → p-83f89965.entry.js} +2 -2
  237. package/dist/dso-toolkit/{p-a6f19891.entry.js → p-8bc5ab4d.entry.js} +2 -2
  238. package/dist/dso-toolkit/p-8f0e00b0.entry.js +2 -0
  239. package/dist/dso-toolkit/p-8f0e00b0.entry.js.map +1 -0
  240. package/dist/dso-toolkit/{p-8b9ee8d3.entry.js → p-921fe0b7.entry.js} +2 -2
  241. package/dist/dso-toolkit/{p-3cdfb92e.entry.js → p-9424e171.entry.js} +2 -2
  242. package/dist/dso-toolkit/p-954b3715.entry.js +2 -0
  243. package/dist/dso-toolkit/p-954b3715.entry.js.map +1 -0
  244. package/dist/dso-toolkit/p-992c287c.entry.js +2 -0
  245. package/dist/dso-toolkit/p-992c287c.entry.js.map +1 -0
  246. package/dist/dso-toolkit/{p-065ea3f8.entry.js → p-99995b02.entry.js} +2 -2
  247. package/dist/dso-toolkit/{p-3be4c978.entry.js → p-9a0927eb.entry.js} +2 -2
  248. package/dist/dso-toolkit/p-a2a9f5da.entry.js +2 -0
  249. package/dist/dso-toolkit/p-a2a9f5da.entry.js.map +1 -0
  250. package/dist/dso-toolkit/{p-2dc8e61f.entry.js → p-a3c7e119.entry.js} +2 -2
  251. package/dist/dso-toolkit/{p-a705c684.entry.js.map → p-a3c7e119.entry.js.map} +1 -1
  252. package/dist/dso-toolkit/{p-e96183ae.entry.js → p-a64e9cd5.entry.js} +2 -2
  253. package/dist/dso-toolkit/p-abe7047e.entry.js +2 -0
  254. package/dist/dso-toolkit/p-abe7047e.entry.js.map +1 -0
  255. package/dist/dso-toolkit/{p-e8322c5b.entry.js → p-afc4bca7.entry.js} +2 -2
  256. package/dist/dso-toolkit/{p-e132910b.entry.js → p-b032496d.entry.js} +2 -2
  257. package/dist/dso-toolkit/{p-d885c651.entry.js → p-b0a3dfcb.entry.js} +2 -2
  258. package/dist/dso-toolkit/{p-bb87ef29.entry.js → p-b2f92815.entry.js} +2 -2
  259. package/dist/dso-toolkit/p-b2f92815.entry.js.map +1 -0
  260. package/dist/dso-toolkit/p-bc0a6bac.entry.js +2 -0
  261. package/dist/dso-toolkit/p-bc0a6bac.entry.js.map +1 -0
  262. package/dist/dso-toolkit/{p-ea804e9e.entry.js → p-c05d8f55.entry.js} +2 -2
  263. package/dist/dso-toolkit/{p-34f1afd3.entry.js → p-c3e38404.entry.js} +2 -2
  264. package/dist/dso-toolkit/p-c3e750cc.js +2 -0
  265. package/dist/dso-toolkit/p-c3e750cc.js.map +1 -0
  266. package/dist/dso-toolkit/{p-786f3a41.entry.js → p-cdbb39ad.entry.js} +2 -2
  267. package/dist/dso-toolkit/p-d4317bc8.entry.js +2 -0
  268. package/dist/dso-toolkit/p-d4317bc8.entry.js.map +1 -0
  269. package/dist/dso-toolkit/{p-ab22347c.entry.js → p-de63f553.entry.js} +2 -2
  270. package/dist/dso-toolkit/{p-ef8fbe01.entry.js → p-e42e0cb4.entry.js} +2 -2
  271. package/dist/dso-toolkit/{p-778c0381.entry.js → p-e665556c.entry.js} +2 -2
  272. package/dist/dso-toolkit/p-e80292b5.entry.js +2 -0
  273. package/dist/dso-toolkit/p-e80292b5.entry.js.map +1 -0
  274. package/dist/dso-toolkit/{p-e283ee51.entry.js → p-ea87d930.entry.js} +2 -2
  275. package/dist/dso-toolkit/{p-e283ee51.entry.js.map → p-ea87d930.entry.js.map} +1 -1
  276. package/dist/dso-toolkit/{p-a644f41c.entry.js → p-ef087d87.entry.js} +2 -2
  277. package/dist/dso-toolkit/{p-ae8b8810.js → p-f11d080a.js} +2 -2
  278. package/dist/dso-toolkit/{p-487469c5.entry.js → p-f3717d91.entry.js} +2 -2
  279. package/dist/dso-toolkit/{p-fc82b0d0.entry.js → p-f412ab80.entry.js} +2 -2
  280. package/dist/dso-toolkit/{p-05094f69.entry.js → p-fb5e4dc9.entry.js} +2 -2
  281. package/dist/dso-toolkit/p-ffb34aa5.js +2 -0
  282. package/dist/dso-toolkit/p-ffb34aa5.js.map +1 -0
  283. package/dist/esm/{annotation-body-75f77191.js → annotation-body-b9b58856.js} +2 -2
  284. package/dist/esm/{annotation-body-75f77191.js.map → annotation-body-b9b58856.js.map} +1 -1
  285. package/dist/esm/{annotation-symbol-slot-1947dce6.js → annotation-symbol-slot-74bf6f43.js} +2 -2
  286. package/dist/esm/{annotation-symbol-slot-1947dce6.js.map → annotation-symbol-slot-74bf6f43.js.map} +1 -1
  287. package/dist/esm/dso-accordion-section.entry.js +1 -1
  288. package/dist/esm/dso-accordion.entry.js +1 -1
  289. package/dist/esm/dso-action-list-item.entry.js +1 -1
  290. package/dist/esm/dso-action-list.entry.js +1 -1
  291. package/dist/esm/dso-advanced-select.entry.js +1 -1
  292. package/dist/esm/dso-alert_6.entry.js +31 -15
  293. package/dist/esm/dso-alert_6.entry.js.map +1 -1
  294. package/dist/esm/dso-annotation-activiteit.entry.js +4 -4
  295. package/dist/esm/dso-annotation-activiteit.entry.js.map +1 -1
  296. package/dist/esm/dso-annotation-gebiedsaanwijzing.entry.js +4 -4
  297. package/dist/esm/dso-annotation-gebiedsaanwijzing.entry.js.map +1 -1
  298. package/dist/esm/dso-annotation-kaart.entry.js +3 -3
  299. package/dist/esm/dso-annotation-kaart.entry.js.map +1 -1
  300. package/dist/esm/dso-annotation-locatie_2.entry.js +6 -6
  301. package/dist/esm/dso-annotation-locatie_2.entry.js.map +1 -1
  302. package/dist/esm/dso-annotation-omgevingsnormwaarde.entry.js +4 -4
  303. package/dist/esm/dso-annotation-omgevingsnormwaarde.entry.js.map +1 -1
  304. package/dist/esm/dso-attachments-counter_2.entry.js +1 -1
  305. package/dist/esm/dso-autosuggest.entry.js +24 -8
  306. package/dist/esm/dso-autosuggest.entry.js.map +1 -1
  307. package/dist/esm/dso-banner.entry.js +1 -1
  308. package/dist/esm/dso-card-container.entry.js +1 -1
  309. package/dist/esm/dso-card.entry.js +1 -1
  310. package/dist/esm/dso-date-picker-legacy.entry.js +1 -1
  311. package/dist/esm/dso-date-picker.entry.js +1 -1
  312. package/dist/esm/dso-document-card.entry.js +1 -1
  313. package/dist/esm/dso-dropdown-menu.entry.js +2 -2
  314. package/dist/esm/dso-header.entry.js +29 -4
  315. package/dist/esm/dso-header.entry.js.map +1 -1
  316. package/dist/esm/dso-helpcenter-panel.entry.js +1 -1
  317. package/dist/esm/dso-highlight-box.entry.js +1 -1
  318. package/dist/esm/dso-icon.entry.js +1 -1
  319. package/dist/esm/dso-info-button.entry.js +1 -1
  320. package/dist/esm/dso-info_2.entry.js +2 -2
  321. package/dist/esm/dso-input-range.entry.js +1 -1
  322. package/dist/esm/dso-label_2.entry.js +2 -2
  323. package/dist/esm/dso-legend-item.entry.js +1 -1
  324. package/dist/esm/dso-list-button.entry.js +1 -1
  325. package/dist/esm/dso-logo.entry.js +8 -4
  326. package/dist/esm/dso-logo.entry.js.map +1 -1
  327. package/dist/esm/dso-map-base-layers.entry.js +19 -3
  328. package/dist/esm/dso-map-base-layers.entry.js.map +1 -1
  329. package/dist/esm/dso-map-controls.entry.js +26 -3
  330. package/dist/esm/dso-map-controls.entry.js.map +1 -1
  331. package/dist/esm/dso-map-overlays.entry.js +19 -3
  332. package/dist/esm/dso-map-overlays.entry.js.map +1 -1
  333. package/dist/esm/dso-mark-bar.entry.js +2 -2
  334. package/dist/esm/dso-modal.entry.js +21 -4
  335. package/dist/esm/dso-modal.entry.js.map +1 -1
  336. package/dist/esm/dso-pagination.entry.js +1 -1
  337. package/dist/esm/dso-plekinfo-card.entry.js +7 -3
  338. package/dist/esm/dso-plekinfo-card.entry.js.map +1 -1
  339. package/dist/esm/dso-progress-bar.entry.js +2 -2
  340. package/dist/esm/dso-progress-indicator.entry.js +19 -3
  341. package/dist/esm/dso-progress-indicator.entry.js.map +1 -1
  342. package/dist/esm/dso-project-item.entry.js +2 -2
  343. package/dist/esm/dso-renvooi_2.entry.js +21 -18
  344. package/dist/esm/dso-renvooi_2.entry.js.map +1 -1
  345. package/dist/esm/dso-responsive-element.entry.js +2 -2
  346. package/dist/esm/dso-scrollable.entry.js +3 -3
  347. package/dist/esm/dso-tab.entry.js +1 -1
  348. package/dist/esm/dso-tabs.entry.js +2 -2
  349. package/dist/esm/dso-toggletip.entry.js +2 -2
  350. package/dist/esm/dso-toolkit.js +4 -4
  351. package/dist/esm/dso-toolkit.js.map +1 -1
  352. package/dist/esm/dso-tree-view.entry.js +2 -2
  353. package/dist/esm/dso-viewer-grid.entry.js +2 -2
  354. package/dist/esm/dsot-document-component-demo.entry.js +9 -3
  355. package/dist/esm/dsot-document-component-demo.entry.js.map +1 -1
  356. package/dist/esm/i18n-c9ec6445.js +2382 -0
  357. package/dist/esm/i18n-c9ec6445.js.map +1 -0
  358. package/dist/esm/{index-1a8f2a10.js → index-75547ccd.js} +31 -14
  359. package/dist/esm/index-75547ccd.js.map +1 -0
  360. package/dist/esm/loader.js +3 -3
  361. package/dist/esm/v4-692dad5f.js +63 -0
  362. package/dist/esm/v4-692dad5f.js.map +1 -0
  363. package/dist/types/components/alert/alert.d.ts +2 -1
  364. package/dist/types/components/alert/alert.i18n.d.ts +2 -0
  365. package/dist/types/components/autosuggest/autosuggest.d.ts +1 -0
  366. package/dist/types/components/autosuggest/autosuggest.i18n.d.ts +2 -0
  367. package/dist/types/components/document-component-demo/document-component.demo.d.ts +1 -0
  368. package/dist/types/components/header/header.d.ts +2 -1
  369. package/dist/types/components/header/header.i18n.d.ts +2 -0
  370. package/dist/types/components/logo/logo.d.ts +9 -1
  371. package/dist/types/components/map-base-layers/map-base-layers.d.ts +3 -1
  372. package/dist/types/components/map-base-layers/map-base-layers.i18n.d.ts +2 -0
  373. package/dist/types/components/map-controls/map-controls.d.ts +2 -1
  374. package/dist/types/components/map-controls/map-controls.i18n.d.ts +2 -0
  375. package/dist/types/components/map-overlays/map-overlays.d.ts +3 -1
  376. package/dist/types/components/map-overlays/map-overlays.i18n.d.ts +2 -0
  377. package/dist/types/components/modal/modal.d.ts +1 -0
  378. package/dist/types/components/modal/modal.i18n.d.ts +2 -0
  379. package/dist/types/components/plekinfo-card/plekinfo-card.d.ts +7 -0
  380. package/dist/types/components/progress-indicator/progress-indicator.d.ts +3 -1
  381. package/dist/types/components/progress-indicator/progress-indicator.i18n.d.ts +2 -0
  382. package/dist/types/components.d.ts +17 -1
  383. package/dist/types/stencil-public-runtime.d.ts +6 -0
  384. package/dist/types/utils/i18n.d.ts +5 -0
  385. package/package.json +10 -9
  386. package/dist/cjs/index-848434f1.js.map +0 -1
  387. package/dist/cjs/v4-7014b8b0.js +0 -67
  388. package/dist/cjs/v4-7014b8b0.js.map +0 -1
  389. package/dist/dso-toolkit/p-00caab3b.js +0 -2
  390. package/dist/dso-toolkit/p-228e4c2d.entry.js +0 -2
  391. package/dist/dso-toolkit/p-228e4c2d.entry.js.map +0 -1
  392. package/dist/dso-toolkit/p-2d9b7138.entry.js +0 -2
  393. package/dist/dso-toolkit/p-2d9b7138.entry.js.map +0 -1
  394. package/dist/dso-toolkit/p-46e446b0.entry.js +0 -2
  395. package/dist/dso-toolkit/p-46e446b0.entry.js.map +0 -1
  396. package/dist/dso-toolkit/p-587779a5.entry.js +0 -2
  397. package/dist/dso-toolkit/p-587779a5.entry.js.map +0 -1
  398. package/dist/dso-toolkit/p-608835d8.entry.js +0 -2
  399. package/dist/dso-toolkit/p-608835d8.entry.js.map +0 -1
  400. package/dist/dso-toolkit/p-950d43d8.entry.js +0 -2
  401. package/dist/dso-toolkit/p-950d43d8.entry.js.map +0 -1
  402. package/dist/dso-toolkit/p-a168dbd1.entry.js +0 -2
  403. package/dist/dso-toolkit/p-a168dbd1.entry.js.map +0 -1
  404. package/dist/dso-toolkit/p-a9427715.entry.js +0 -2
  405. package/dist/dso-toolkit/p-a9427715.entry.js.map +0 -1
  406. package/dist/dso-toolkit/p-ae076d5b.entry.js +0 -2
  407. package/dist/dso-toolkit/p-ae076d5b.entry.js.map +0 -1
  408. package/dist/dso-toolkit/p-b623c74b.js +0 -3
  409. package/dist/dso-toolkit/p-b623c74b.js.map +0 -1
  410. package/dist/dso-toolkit/p-bb87ef29.entry.js.map +0 -1
  411. package/dist/dso-toolkit/p-dcea90be.entry.js +0 -2
  412. package/dist/dso-toolkit/p-dcea90be.entry.js.map +0 -1
  413. package/dist/dso-toolkit/p-e3fea9f8.entry.js +0 -2
  414. package/dist/dso-toolkit/p-e3fea9f8.entry.js.map +0 -1
  415. package/dist/dso-toolkit/p-e773c47e.entry.js +0 -2
  416. package/dist/dso-toolkit/p-e773c47e.entry.js.map +0 -1
  417. package/dist/dso-toolkit/p-f5ff676c.js +0 -2
  418. package/dist/dso-toolkit/p-f5ff676c.js.map +0 -1
  419. package/dist/esm/index-1a8f2a10.js.map +0 -1
  420. package/dist/esm/v4-a79185f4.js +0 -65
  421. package/dist/esm/v4-a79185f4.js.map +0 -1
  422. /package/dist/dso-toolkit/{p-dd6cf2cd.entry.js.map → p-08121fee.entry.js.map} +0 -0
  423. /package/dist/dso-toolkit/{p-64bf55d1.entry.js.map → p-10603e10.entry.js.map} +0 -0
  424. /package/dist/dso-toolkit/{p-00caab3b.js.map → p-13396f6d.js.map} +0 -0
  425. /package/dist/dso-toolkit/{p-8e699eb2.entry.js.map → p-226833eb.entry.js.map} +0 -0
  426. /package/dist/dso-toolkit/{p-e9896db2.entry.js.map → p-38cc23e1.entry.js.map} +0 -0
  427. /package/dist/dso-toolkit/{p-cd1a65e7.entry.js.map → p-40810e10.entry.js.map} +0 -0
  428. /package/dist/dso-toolkit/{p-6a414b15.entry.js.map → p-47ae7799.entry.js.map} +0 -0
  429. /package/dist/dso-toolkit/{p-ea46d648.entry.js.map → p-49e93ef5.entry.js.map} +0 -0
  430. /package/dist/dso-toolkit/{p-b5744b74.entry.js.map → p-5c047dfd.entry.js.map} +0 -0
  431. /package/dist/dso-toolkit/{p-9ebf26d8.entry.js.map → p-5e6704bb.entry.js.map} +0 -0
  432. /package/dist/dso-toolkit/{p-331f52b3.entry.js.map → p-636a2ad2.entry.js.map} +0 -0
  433. /package/dist/dso-toolkit/{p-a801f428.entry.js.map → p-74e0e63e.entry.js.map} +0 -0
  434. /package/dist/dso-toolkit/{p-bda2d5ce.entry.js.map → p-75c65097.entry.js.map} +0 -0
  435. /package/dist/dso-toolkit/{p-54fff8c0.entry.js.map → p-76dfbee3.entry.js.map} +0 -0
  436. /package/dist/dso-toolkit/{p-cc6c428b.entry.js.map → p-83f89965.entry.js.map} +0 -0
  437. /package/dist/dso-toolkit/{p-a6f19891.entry.js.map → p-8bc5ab4d.entry.js.map} +0 -0
  438. /package/dist/dso-toolkit/{p-8b9ee8d3.entry.js.map → p-921fe0b7.entry.js.map} +0 -0
  439. /package/dist/dso-toolkit/{p-3cdfb92e.entry.js.map → p-9424e171.entry.js.map} +0 -0
  440. /package/dist/dso-toolkit/{p-065ea3f8.entry.js.map → p-99995b02.entry.js.map} +0 -0
  441. /package/dist/dso-toolkit/{p-3be4c978.entry.js.map → p-9a0927eb.entry.js.map} +0 -0
  442. /package/dist/dso-toolkit/{p-e96183ae.entry.js.map → p-a64e9cd5.entry.js.map} +0 -0
  443. /package/dist/dso-toolkit/{p-e8322c5b.entry.js.map → p-afc4bca7.entry.js.map} +0 -0
  444. /package/dist/dso-toolkit/{p-e132910b.entry.js.map → p-b032496d.entry.js.map} +0 -0
  445. /package/dist/dso-toolkit/{p-d885c651.entry.js.map → p-b0a3dfcb.entry.js.map} +0 -0
  446. /package/dist/dso-toolkit/{p-ea804e9e.entry.js.map → p-c05d8f55.entry.js.map} +0 -0
  447. /package/dist/dso-toolkit/{p-34f1afd3.entry.js.map → p-c3e38404.entry.js.map} +0 -0
  448. /package/dist/dso-toolkit/{p-786f3a41.entry.js.map → p-cdbb39ad.entry.js.map} +0 -0
  449. /package/dist/dso-toolkit/{p-ab22347c.entry.js.map → p-de63f553.entry.js.map} +0 -0
  450. /package/dist/dso-toolkit/{p-ef8fbe01.entry.js.map → p-e42e0cb4.entry.js.map} +0 -0
  451. /package/dist/dso-toolkit/{p-778c0381.entry.js.map → p-e665556c.entry.js.map} +0 -0
  452. /package/dist/dso-toolkit/{p-a644f41c.entry.js.map → p-ef087d87.entry.js.map} +0 -0
  453. /package/dist/dso-toolkit/{p-ae8b8810.js.map → p-f11d080a.js.map} +0 -0
  454. /package/dist/dso-toolkit/{p-487469c5.entry.js.map → p-f3717d91.entry.js.map} +0 -0
  455. /package/dist/dso-toolkit/{p-fc82b0d0.entry.js.map → p-f412ab80.entry.js.map} +0 -0
  456. /package/dist/dso-toolkit/{p-05094f69.entry.js.map → p-fb5e4dc9.entry.js.map} +0 -0
@@ -0,0 +1,2382 @@
1
+ const isString = obj => typeof obj === 'string';
2
+ const defer = () => {
3
+ let res;
4
+ let rej;
5
+ const promise = new Promise((resolve, reject) => {
6
+ res = resolve;
7
+ rej = reject;
8
+ });
9
+ promise.resolve = res;
10
+ promise.reject = rej;
11
+ return promise;
12
+ };
13
+ const makeString = object => {
14
+ if (object == null) return '';
15
+ return '' + object;
16
+ };
17
+ const copy = (a, s, t) => {
18
+ a.forEach(m => {
19
+ if (s[m]) t[m] = s[m];
20
+ });
21
+ };
22
+ const lastOfPathSeparatorRegExp = /###/g;
23
+ const cleanKey = key => key && key.indexOf('###') > -1 ? key.replace(lastOfPathSeparatorRegExp, '.') : key;
24
+ const canNotTraverseDeeper = object => !object || isString(object);
25
+ const getLastOfPath = (object, path, Empty) => {
26
+ const stack = !isString(path) ? path : path.split('.');
27
+ let stackIndex = 0;
28
+ while (stackIndex < stack.length - 1) {
29
+ if (canNotTraverseDeeper(object)) return {};
30
+ const key = cleanKey(stack[stackIndex]);
31
+ if (!object[key] && Empty) object[key] = new Empty();
32
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
33
+ object = object[key];
34
+ } else {
35
+ object = {};
36
+ }
37
+ ++stackIndex;
38
+ }
39
+ if (canNotTraverseDeeper(object)) return {};
40
+ return {
41
+ obj: object,
42
+ k: cleanKey(stack[stackIndex])
43
+ };
44
+ };
45
+ const setPath = (object, path, newValue) => {
46
+ const {
47
+ obj,
48
+ k
49
+ } = getLastOfPath(object, path, Object);
50
+ if (obj !== undefined || path.length === 1) {
51
+ obj[k] = newValue;
52
+ return;
53
+ }
54
+ let e = path[path.length - 1];
55
+ let p = path.slice(0, path.length - 1);
56
+ let last = getLastOfPath(object, p, Object);
57
+ while (last.obj === undefined && p.length) {
58
+ e = `${p[p.length - 1]}.${e}`;
59
+ p = p.slice(0, p.length - 1);
60
+ last = getLastOfPath(object, p, Object);
61
+ if (last && last.obj && typeof last.obj[`${last.k}.${e}`] !== 'undefined') {
62
+ last.obj = undefined;
63
+ }
64
+ }
65
+ last.obj[`${last.k}.${e}`] = newValue;
66
+ };
67
+ const pushPath = (object, path, newValue, concat) => {
68
+ const {
69
+ obj,
70
+ k
71
+ } = getLastOfPath(object, path, Object);
72
+ obj[k] = obj[k] || [];
73
+ obj[k].push(newValue);
74
+ };
75
+ const getPath = (object, path) => {
76
+ const {
77
+ obj,
78
+ k
79
+ } = getLastOfPath(object, path);
80
+ if (!obj) return undefined;
81
+ return obj[k];
82
+ };
83
+ const getPathWithDefaults = (data, defaultData, key) => {
84
+ const value = getPath(data, key);
85
+ if (value !== undefined) {
86
+ return value;
87
+ }
88
+ return getPath(defaultData, key);
89
+ };
90
+ const deepExtend = (target, source, overwrite) => {
91
+ for (const prop in source) {
92
+ if (prop !== '__proto__' && prop !== 'constructor') {
93
+ if (prop in target) {
94
+ if (isString(target[prop]) || target[prop] instanceof String || isString(source[prop]) || source[prop] instanceof String) {
95
+ if (overwrite) target[prop] = source[prop];
96
+ } else {
97
+ deepExtend(target[prop], source[prop], overwrite);
98
+ }
99
+ } else {
100
+ target[prop] = source[prop];
101
+ }
102
+ }
103
+ }
104
+ return target;
105
+ };
106
+ const regexEscape = str => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
107
+ var _entityMap = {
108
+ '&': '&amp;',
109
+ '<': '&lt;',
110
+ '>': '&gt;',
111
+ '"': '&quot;',
112
+ "'": '&#39;',
113
+ '/': '&#x2F;'
114
+ };
115
+ const escape = data => {
116
+ if (isString(data)) {
117
+ return data.replace(/[&<>"'\/]/g, s => _entityMap[s]);
118
+ }
119
+ return data;
120
+ };
121
+ class RegExpCache {
122
+ constructor(capacity) {
123
+ this.capacity = capacity;
124
+ this.regExpMap = new Map();
125
+ this.regExpQueue = [];
126
+ }
127
+ getRegExp(pattern) {
128
+ const regExpFromCache = this.regExpMap.get(pattern);
129
+ if (regExpFromCache !== undefined) {
130
+ return regExpFromCache;
131
+ }
132
+ const regExpNew = new RegExp(pattern);
133
+ if (this.regExpQueue.length === this.capacity) {
134
+ this.regExpMap.delete(this.regExpQueue.shift());
135
+ }
136
+ this.regExpMap.set(pattern, regExpNew);
137
+ this.regExpQueue.push(pattern);
138
+ return regExpNew;
139
+ }
140
+ }
141
+ const chars = [' ', ',', '?', '!', ';'];
142
+ const looksLikeObjectPathRegExpCache = new RegExpCache(20);
143
+ const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
144
+ nsSeparator = nsSeparator || '';
145
+ keySeparator = keySeparator || '';
146
+ const possibleChars = chars.filter(c => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
147
+ if (possibleChars.length === 0) return true;
148
+ const r = looksLikeObjectPathRegExpCache.getRegExp(`(${possibleChars.map(c => c === '?' ? '\\?' : c).join('|')})`);
149
+ let matched = !r.test(key);
150
+ if (!matched) {
151
+ const ki = key.indexOf(keySeparator);
152
+ if (ki > 0 && !r.test(key.substring(0, ki))) {
153
+ matched = true;
154
+ }
155
+ }
156
+ return matched;
157
+ };
158
+ const deepFind = function (obj, path) {
159
+ let keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
160
+ if (!obj) return undefined;
161
+ if (obj[path]) return obj[path];
162
+ const tokens = path.split(keySeparator);
163
+ let current = obj;
164
+ for (let i = 0; i < tokens.length;) {
165
+ if (!current || typeof current !== 'object') {
166
+ return undefined;
167
+ }
168
+ let next;
169
+ let nextPath = '';
170
+ for (let j = i; j < tokens.length; ++j) {
171
+ if (j !== i) {
172
+ nextPath += keySeparator;
173
+ }
174
+ nextPath += tokens[j];
175
+ next = current[nextPath];
176
+ if (next !== undefined) {
177
+ if (['string', 'number', 'boolean'].indexOf(typeof next) > -1 && j < tokens.length - 1) {
178
+ continue;
179
+ }
180
+ i += j - i + 1;
181
+ break;
182
+ }
183
+ }
184
+ current = next;
185
+ }
186
+ return current;
187
+ };
188
+ const getCleanedCode = code => code && code.replace('_', '-');
189
+
190
+ const consoleLogger = {
191
+ type: 'logger',
192
+ log(args) {
193
+ this.output('log', args);
194
+ },
195
+ warn(args) {
196
+ this.output('warn', args);
197
+ },
198
+ error(args) {
199
+ this.output('error', args);
200
+ },
201
+ output(type, args) {
202
+ if (console && console[type]) console[type].apply(console, args);
203
+ }
204
+ };
205
+ class Logger {
206
+ constructor(concreteLogger) {
207
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
208
+ this.init(concreteLogger, options);
209
+ }
210
+ init(concreteLogger) {
211
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
212
+ this.prefix = options.prefix || 'i18next:';
213
+ this.logger = concreteLogger || consoleLogger;
214
+ this.options = options;
215
+ this.debug = options.debug;
216
+ }
217
+ log() {
218
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
219
+ args[_key] = arguments[_key];
220
+ }
221
+ return this.forward(args, 'log', '', true);
222
+ }
223
+ warn() {
224
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
225
+ args[_key2] = arguments[_key2];
226
+ }
227
+ return this.forward(args, 'warn', '', true);
228
+ }
229
+ error() {
230
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
231
+ args[_key3] = arguments[_key3];
232
+ }
233
+ return this.forward(args, 'error', '');
234
+ }
235
+ deprecate() {
236
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
237
+ args[_key4] = arguments[_key4];
238
+ }
239
+ return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
240
+ }
241
+ forward(args, lvl, prefix, debugOnly) {
242
+ if (debugOnly && !this.debug) return null;
243
+ if (isString(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
244
+ return this.logger[lvl](args);
245
+ }
246
+ create(moduleName) {
247
+ return new Logger(this.logger, {
248
+ ...{
249
+ prefix: `${this.prefix}:${moduleName}:`
250
+ },
251
+ ...this.options
252
+ });
253
+ }
254
+ clone(options) {
255
+ options = options || this.options;
256
+ options.prefix = options.prefix || this.prefix;
257
+ return new Logger(this.logger, options);
258
+ }
259
+ }
260
+ var baseLogger = new Logger();
261
+
262
+ class EventEmitter {
263
+ constructor() {
264
+ this.observers = {};
265
+ }
266
+ on(events, listener) {
267
+ events.split(' ').forEach(event => {
268
+ if (!this.observers[event]) this.observers[event] = new Map();
269
+ const numListeners = this.observers[event].get(listener) || 0;
270
+ this.observers[event].set(listener, numListeners + 1);
271
+ });
272
+ return this;
273
+ }
274
+ off(event, listener) {
275
+ if (!this.observers[event]) return;
276
+ if (!listener) {
277
+ delete this.observers[event];
278
+ return;
279
+ }
280
+ this.observers[event].delete(listener);
281
+ }
282
+ emit(event) {
283
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
284
+ args[_key - 1] = arguments[_key];
285
+ }
286
+ if (this.observers[event]) {
287
+ const cloned = Array.from(this.observers[event].entries());
288
+ cloned.forEach(_ref => {
289
+ let [observer, numTimesAdded] = _ref;
290
+ for (let i = 0; i < numTimesAdded; i++) {
291
+ observer(...args);
292
+ }
293
+ });
294
+ }
295
+ if (this.observers['*']) {
296
+ const cloned = Array.from(this.observers['*'].entries());
297
+ cloned.forEach(_ref2 => {
298
+ let [observer, numTimesAdded] = _ref2;
299
+ for (let i = 0; i < numTimesAdded; i++) {
300
+ observer.apply(observer, [event, ...args]);
301
+ }
302
+ });
303
+ }
304
+ }
305
+ }
306
+
307
+ class ResourceStore extends EventEmitter {
308
+ constructor(data) {
309
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
310
+ ns: ['translation'],
311
+ defaultNS: 'translation'
312
+ };
313
+ super();
314
+ this.data = data || {};
315
+ this.options = options;
316
+ if (this.options.keySeparator === undefined) {
317
+ this.options.keySeparator = '.';
318
+ }
319
+ if (this.options.ignoreJSONStructure === undefined) {
320
+ this.options.ignoreJSONStructure = true;
321
+ }
322
+ }
323
+ addNamespaces(ns) {
324
+ if (this.options.ns.indexOf(ns) < 0) {
325
+ this.options.ns.push(ns);
326
+ }
327
+ }
328
+ removeNamespaces(ns) {
329
+ const index = this.options.ns.indexOf(ns);
330
+ if (index > -1) {
331
+ this.options.ns.splice(index, 1);
332
+ }
333
+ }
334
+ getResource(lng, ns, key) {
335
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
336
+ const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
337
+ const ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
338
+ let path;
339
+ if (lng.indexOf('.') > -1) {
340
+ path = lng.split('.');
341
+ } else {
342
+ path = [lng, ns];
343
+ if (key) {
344
+ if (Array.isArray(key)) {
345
+ path.push(...key);
346
+ } else if (isString(key) && keySeparator) {
347
+ path.push(...key.split(keySeparator));
348
+ } else {
349
+ path.push(key);
350
+ }
351
+ }
352
+ }
353
+ const result = getPath(this.data, path);
354
+ if (!result && !ns && !key && lng.indexOf('.') > -1) {
355
+ lng = path[0];
356
+ ns = path[1];
357
+ key = path.slice(2).join('.');
358
+ }
359
+ if (result || !ignoreJSONStructure || !isString(key)) return result;
360
+ return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);
361
+ }
362
+ addResource(lng, ns, key, value) {
363
+ let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
364
+ silent: false
365
+ };
366
+ const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
367
+ let path = [lng, ns];
368
+ if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
369
+ if (lng.indexOf('.') > -1) {
370
+ path = lng.split('.');
371
+ value = ns;
372
+ ns = path[1];
373
+ }
374
+ this.addNamespaces(ns);
375
+ setPath(this.data, path, value);
376
+ if (!options.silent) this.emit('added', lng, ns, key, value);
377
+ }
378
+ addResources(lng, ns, resources) {
379
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
380
+ silent: false
381
+ };
382
+ for (const m in resources) {
383
+ if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
384
+ silent: true
385
+ });
386
+ }
387
+ if (!options.silent) this.emit('added', lng, ns, resources);
388
+ }
389
+ addResourceBundle(lng, ns, resources, deep, overwrite) {
390
+ let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
391
+ silent: false,
392
+ skipCopy: false
393
+ };
394
+ let path = [lng, ns];
395
+ if (lng.indexOf('.') > -1) {
396
+ path = lng.split('.');
397
+ deep = resources;
398
+ resources = ns;
399
+ ns = path[1];
400
+ }
401
+ this.addNamespaces(ns);
402
+ let pack = getPath(this.data, path) || {};
403
+ if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
404
+ if (deep) {
405
+ deepExtend(pack, resources, overwrite);
406
+ } else {
407
+ pack = {
408
+ ...pack,
409
+ ...resources
410
+ };
411
+ }
412
+ setPath(this.data, path, pack);
413
+ if (!options.silent) this.emit('added', lng, ns, resources);
414
+ }
415
+ removeResourceBundle(lng, ns) {
416
+ if (this.hasResourceBundle(lng, ns)) {
417
+ delete this.data[lng][ns];
418
+ }
419
+ this.removeNamespaces(ns);
420
+ this.emit('removed', lng, ns);
421
+ }
422
+ hasResourceBundle(lng, ns) {
423
+ return this.getResource(lng, ns) !== undefined;
424
+ }
425
+ getResourceBundle(lng, ns) {
426
+ if (!ns) ns = this.options.defaultNS;
427
+ if (this.options.compatibilityAPI === 'v1') return {
428
+ ...{},
429
+ ...this.getResource(lng, ns)
430
+ };
431
+ return this.getResource(lng, ns);
432
+ }
433
+ getDataByLanguage(lng) {
434
+ return this.data[lng];
435
+ }
436
+ hasLanguageSomeTranslations(lng) {
437
+ const data = this.getDataByLanguage(lng);
438
+ const n = data && Object.keys(data) || [];
439
+ return !!n.find(v => data[v] && Object.keys(data[v]).length > 0);
440
+ }
441
+ toJSON() {
442
+ return this.data;
443
+ }
444
+ }
445
+
446
+ var postProcessor = {
447
+ processors: {},
448
+ addPostProcessor(module) {
449
+ this.processors[module.name] = module;
450
+ },
451
+ handle(processors, value, key, options, translator) {
452
+ processors.forEach(processor => {
453
+ if (this.processors[processor]) value = this.processors[processor].process(value, key, options, translator);
454
+ });
455
+ return value;
456
+ }
457
+ };
458
+
459
+ const checkedLoadedFor = {};
460
+ class Translator extends EventEmitter {
461
+ constructor(services) {
462
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
463
+ super();
464
+ copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, this);
465
+ this.options = options;
466
+ if (this.options.keySeparator === undefined) {
467
+ this.options.keySeparator = '.';
468
+ }
469
+ this.logger = baseLogger.create('translator');
470
+ }
471
+ changeLanguage(lng) {
472
+ if (lng) this.language = lng;
473
+ }
474
+ exists(key) {
475
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
476
+ interpolation: {}
477
+ };
478
+ if (key === undefined || key === null) {
479
+ return false;
480
+ }
481
+ const resolved = this.resolve(key, options);
482
+ return resolved && resolved.res !== undefined;
483
+ }
484
+ extractFromKey(key, options) {
485
+ let nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
486
+ if (nsSeparator === undefined) nsSeparator = ':';
487
+ const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
488
+ let namespaces = options.ns || this.options.defaultNS || [];
489
+ const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
490
+ const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
491
+ if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
492
+ const m = key.match(this.interpolator.nestingRegexp);
493
+ if (m && m.length > 0) {
494
+ return {
495
+ key,
496
+ namespaces
497
+ };
498
+ }
499
+ const parts = key.split(nsSeparator);
500
+ if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
501
+ key = parts.join(keySeparator);
502
+ }
503
+ if (isString(namespaces)) namespaces = [namespaces];
504
+ return {
505
+ key,
506
+ namespaces
507
+ };
508
+ }
509
+ translate(keys, options, lastKey) {
510
+ if (typeof options !== 'object' && this.options.overloadTranslationOptionHandler) {
511
+ options = this.options.overloadTranslationOptionHandler(arguments);
512
+ }
513
+ if (typeof options === 'object') options = {
514
+ ...options
515
+ };
516
+ if (!options) options = {};
517
+ if (keys === undefined || keys === null) return '';
518
+ if (!Array.isArray(keys)) keys = [String(keys)];
519
+ const returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
520
+ const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
521
+ const {
522
+ key,
523
+ namespaces
524
+ } = this.extractFromKey(keys[keys.length - 1], options);
525
+ const namespace = namespaces[namespaces.length - 1];
526
+ const lng = options.lng || this.language;
527
+ const appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
528
+ if (lng && lng.toLowerCase() === 'cimode') {
529
+ if (appendNamespaceToCIMode) {
530
+ const nsSeparator = options.nsSeparator || this.options.nsSeparator;
531
+ if (returnDetails) {
532
+ return {
533
+ res: `${namespace}${nsSeparator}${key}`,
534
+ usedKey: key,
535
+ exactUsedKey: key,
536
+ usedLng: lng,
537
+ usedNS: namespace,
538
+ usedParams: this.getUsedParamsDetails(options)
539
+ };
540
+ }
541
+ return `${namespace}${nsSeparator}${key}`;
542
+ }
543
+ if (returnDetails) {
544
+ return {
545
+ res: key,
546
+ usedKey: key,
547
+ exactUsedKey: key,
548
+ usedLng: lng,
549
+ usedNS: namespace,
550
+ usedParams: this.getUsedParamsDetails(options)
551
+ };
552
+ }
553
+ return key;
554
+ }
555
+ const resolved = this.resolve(keys, options);
556
+ let res = resolved && resolved.res;
557
+ const resUsedKey = resolved && resolved.usedKey || key;
558
+ const resExactUsedKey = resolved && resolved.exactUsedKey || key;
559
+ const resType = Object.prototype.toString.apply(res);
560
+ const noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
561
+ const joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
562
+ const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
563
+ const handleAsObject = !isString(res) && typeof res !== 'boolean' && typeof res !== 'number';
564
+ if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(res))) {
565
+ if (!options.returnObjects && !this.options.returnObjects) {
566
+ if (!this.options.returnedObjectHandler) {
567
+ this.logger.warn('accessing an object - but returnObjects options is not enabled!');
568
+ }
569
+ const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, {
570
+ ...options,
571
+ ns: namespaces
572
+ }) : `key '${key} (${this.language})' returned an object instead of string.`;
573
+ if (returnDetails) {
574
+ resolved.res = r;
575
+ resolved.usedParams = this.getUsedParamsDetails(options);
576
+ return resolved;
577
+ }
578
+ return r;
579
+ }
580
+ if (keySeparator) {
581
+ const resTypeIsArray = Array.isArray(res);
582
+ const copy = resTypeIsArray ? [] : {};
583
+ const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
584
+ for (const m in res) {
585
+ if (Object.prototype.hasOwnProperty.call(res, m)) {
586
+ const deepKey = `${newKeyToUse}${keySeparator}${m}`;
587
+ copy[m] = this.translate(deepKey, {
588
+ ...options,
589
+ ...{
590
+ joinArrays: false,
591
+ ns: namespaces
592
+ }
593
+ });
594
+ if (copy[m] === deepKey) copy[m] = res[m];
595
+ }
596
+ }
597
+ res = copy;
598
+ }
599
+ } else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
600
+ res = res.join(joinArrays);
601
+ if (res) res = this.extendTranslation(res, keys, options, lastKey);
602
+ } else {
603
+ let usedDefault = false;
604
+ let usedKey = false;
605
+ const needsPluralHandling = options.count !== undefined && !isString(options.count);
606
+ const hasDefaultValue = Translator.hasDefaultValue(options);
607
+ const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
608
+ const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {
609
+ ordinal: false
610
+ }) : '';
611
+ const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();
612
+ const defaultValue = needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] || options[`defaultValue${defaultValueSuffix}`] || options[`defaultValue${defaultValueSuffixOrdinalFallback}`] || options.defaultValue;
613
+ if (!this.isValidLookup(res) && hasDefaultValue) {
614
+ usedDefault = true;
615
+ res = defaultValue;
616
+ }
617
+ if (!this.isValidLookup(res)) {
618
+ usedKey = true;
619
+ res = key;
620
+ }
621
+ const missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
622
+ const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
623
+ const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
624
+ if (usedKey || usedDefault || updateMissing) {
625
+ this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
626
+ if (keySeparator) {
627
+ const fk = this.resolve(key, {
628
+ ...options,
629
+ keySeparator: false
630
+ });
631
+ 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.');
632
+ }
633
+ let lngs = [];
634
+ const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
635
+ if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
636
+ for (let i = 0; i < fallbackLngs.length; i++) {
637
+ lngs.push(fallbackLngs[i]);
638
+ }
639
+ } else if (this.options.saveMissingTo === 'all') {
640
+ lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
641
+ } else {
642
+ lngs.push(options.lng || this.language);
643
+ }
644
+ const send = (l, k, specificDefaultValue) => {
645
+ const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
646
+ if (this.options.missingKeyHandler) {
647
+ this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
648
+ } else if (this.backendConnector && this.backendConnector.saveMissing) {
649
+ this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
650
+ }
651
+ this.emit('missingKey', l, namespace, k, res);
652
+ };
653
+ if (this.options.saveMissing) {
654
+ if (this.options.saveMissingPlurals && needsPluralHandling) {
655
+ lngs.forEach(language => {
656
+ const suffixes = this.pluralResolver.getSuffixes(language, options);
657
+ if (needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
658
+ suffixes.push(`${this.options.pluralSeparator}zero`);
659
+ }
660
+ suffixes.forEach(suffix => {
661
+ send([language], key + suffix, options[`defaultValue${suffix}`] || defaultValue);
662
+ });
663
+ });
664
+ } else {
665
+ send(lngs, key, defaultValue);
666
+ }
667
+ }
668
+ }
669
+ res = this.extendTranslation(res, keys, options, resolved, lastKey);
670
+ if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
671
+ if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
672
+ if (this.options.compatibilityAPI !== 'v1') {
673
+ res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : undefined);
674
+ } else {
675
+ res = this.options.parseMissingKeyHandler(res);
676
+ }
677
+ }
678
+ }
679
+ if (returnDetails) {
680
+ resolved.res = res;
681
+ resolved.usedParams = this.getUsedParamsDetails(options);
682
+ return resolved;
683
+ }
684
+ return res;
685
+ }
686
+ extendTranslation(res, key, options, resolved, lastKey) {
687
+ var _this = this;
688
+ if (this.i18nFormat && this.i18nFormat.parse) {
689
+ res = this.i18nFormat.parse(res, {
690
+ ...this.options.interpolation.defaultVariables,
691
+ ...options
692
+ }, options.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
693
+ resolved
694
+ });
695
+ } else if (!options.skipInterpolation) {
696
+ if (options.interpolation) this.interpolator.init({
697
+ ...options,
698
+ ...{
699
+ interpolation: {
700
+ ...this.options.interpolation,
701
+ ...options.interpolation
702
+ }
703
+ }
704
+ });
705
+ const skipOnVariables = isString(res) && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
706
+ let nestBef;
707
+ if (skipOnVariables) {
708
+ const nb = res.match(this.interpolator.nestingRegexp);
709
+ nestBef = nb && nb.length;
710
+ }
711
+ let data = options.replace && !isString(options.replace) ? options.replace : options;
712
+ if (this.options.interpolation.defaultVariables) data = {
713
+ ...this.options.interpolation.defaultVariables,
714
+ ...data
715
+ };
716
+ res = this.interpolator.interpolate(res, data, options.lng || this.language || resolved.usedLng, options);
717
+ if (skipOnVariables) {
718
+ const na = res.match(this.interpolator.nestingRegexp);
719
+ const nestAft = na && na.length;
720
+ if (nestBef < nestAft) options.nest = false;
721
+ }
722
+ if (!options.lng && this.options.compatibilityAPI !== 'v1' && resolved && resolved.res) options.lng = this.language || resolved.usedLng;
723
+ if (options.nest !== false) res = this.interpolator.nest(res, function () {
724
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
725
+ args[_key] = arguments[_key];
726
+ }
727
+ if (lastKey && lastKey[0] === args[0] && !options.context) {
728
+ _this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
729
+ return null;
730
+ }
731
+ return _this.translate(...args, key);
732
+ }, options);
733
+ if (options.interpolation) this.interpolator.reset();
734
+ }
735
+ const postProcess = options.postProcess || this.options.postProcess;
736
+ const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
737
+ if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
738
+ res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
739
+ i18nResolved: {
740
+ ...resolved,
741
+ usedParams: this.getUsedParamsDetails(options)
742
+ },
743
+ ...options
744
+ } : options, this);
745
+ }
746
+ return res;
747
+ }
748
+ resolve(keys) {
749
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
750
+ let found;
751
+ let usedKey;
752
+ let exactUsedKey;
753
+ let usedLng;
754
+ let usedNS;
755
+ if (isString(keys)) keys = [keys];
756
+ keys.forEach(k => {
757
+ if (this.isValidLookup(found)) return;
758
+ const extracted = this.extractFromKey(k, options);
759
+ const key = extracted.key;
760
+ usedKey = key;
761
+ let namespaces = extracted.namespaces;
762
+ if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
763
+ const needsPluralHandling = options.count !== undefined && !isString(options.count);
764
+ const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();
765
+ const needsContextHandling = options.context !== undefined && (isString(options.context) || typeof options.context === 'number') && options.context !== '';
766
+ const codes = options.lngs ? options.lngs : this.languageUtils.toResolveHierarchy(options.lng || this.language, options.fallbackLng);
767
+ namespaces.forEach(ns => {
768
+ if (this.isValidLookup(found)) return;
769
+ usedNS = ns;
770
+ if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils && this.utils.hasLoadedNamespace && !this.utils.hasLoadedNamespace(usedNS)) {
771
+ checkedLoadedFor[`${codes[0]}-${ns}`] = true;
772
+ this.logger.warn(`key "${usedKey}" for languages "${codes.join(', ')}" won't get resolved as namespace "${usedNS}" was not yet loaded`, 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');
773
+ }
774
+ codes.forEach(code => {
775
+ if (this.isValidLookup(found)) return;
776
+ usedLng = code;
777
+ const finalKeys = [key];
778
+ if (this.i18nFormat && this.i18nFormat.addLookupKeys) {
779
+ this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
780
+ } else {
781
+ let pluralSuffix;
782
+ if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, options.count, options);
783
+ const zeroSuffix = `${this.options.pluralSeparator}zero`;
784
+ const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
785
+ if (needsPluralHandling) {
786
+ finalKeys.push(key + pluralSuffix);
787
+ if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
788
+ finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
789
+ }
790
+ if (needsZeroSuffixLookup) {
791
+ finalKeys.push(key + zeroSuffix);
792
+ }
793
+ }
794
+ if (needsContextHandling) {
795
+ const contextKey = `${key}${this.options.contextSeparator}${options.context}`;
796
+ finalKeys.push(contextKey);
797
+ if (needsPluralHandling) {
798
+ finalKeys.push(contextKey + pluralSuffix);
799
+ if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
800
+ finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
801
+ }
802
+ if (needsZeroSuffixLookup) {
803
+ finalKeys.push(contextKey + zeroSuffix);
804
+ }
805
+ }
806
+ }
807
+ }
808
+ let possibleKey;
809
+ while (possibleKey = finalKeys.pop()) {
810
+ if (!this.isValidLookup(found)) {
811
+ exactUsedKey = possibleKey;
812
+ found = this.getResource(code, ns, possibleKey, options);
813
+ }
814
+ }
815
+ });
816
+ });
817
+ });
818
+ return {
819
+ res: found,
820
+ usedKey,
821
+ exactUsedKey,
822
+ usedLng,
823
+ usedNS
824
+ };
825
+ }
826
+ isValidLookup(res) {
827
+ return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
828
+ }
829
+ getResource(code, ns, key) {
830
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
831
+ if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
832
+ return this.resourceStore.getResource(code, ns, key, options);
833
+ }
834
+ getUsedParamsDetails() {
835
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
836
+ const optionsKeys = ['defaultValue', 'ordinal', 'context', 'replace', 'lng', 'lngs', 'fallbackLng', 'ns', 'keySeparator', 'nsSeparator', 'returnObjects', 'returnDetails', 'joinArrays', 'postProcess', 'interpolation'];
837
+ const useOptionsReplaceForData = options.replace && !isString(options.replace);
838
+ let data = useOptionsReplaceForData ? options.replace : options;
839
+ if (useOptionsReplaceForData && typeof options.count !== 'undefined') {
840
+ data.count = options.count;
841
+ }
842
+ if (this.options.interpolation.defaultVariables) {
843
+ data = {
844
+ ...this.options.interpolation.defaultVariables,
845
+ ...data
846
+ };
847
+ }
848
+ if (!useOptionsReplaceForData) {
849
+ data = {
850
+ ...data
851
+ };
852
+ for (const key of optionsKeys) {
853
+ delete data[key];
854
+ }
855
+ }
856
+ return data;
857
+ }
858
+ static hasDefaultValue(options) {
859
+ const prefix = 'defaultValue';
860
+ for (const option in options) {
861
+ if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
862
+ return true;
863
+ }
864
+ }
865
+ return false;
866
+ }
867
+ }
868
+
869
+ const capitalize = string => string.charAt(0).toUpperCase() + string.slice(1);
870
+ class LanguageUtil {
871
+ constructor(options) {
872
+ this.options = options;
873
+ this.supportedLngs = this.options.supportedLngs || false;
874
+ this.logger = baseLogger.create('languageUtils');
875
+ }
876
+ getScriptPartFromCode(code) {
877
+ code = getCleanedCode(code);
878
+ if (!code || code.indexOf('-') < 0) return null;
879
+ const p = code.split('-');
880
+ if (p.length === 2) return null;
881
+ p.pop();
882
+ if (p[p.length - 1].toLowerCase() === 'x') return null;
883
+ return this.formatLanguageCode(p.join('-'));
884
+ }
885
+ getLanguagePartFromCode(code) {
886
+ code = getCleanedCode(code);
887
+ if (!code || code.indexOf('-') < 0) return code;
888
+ const p = code.split('-');
889
+ return this.formatLanguageCode(p[0]);
890
+ }
891
+ formatLanguageCode(code) {
892
+ if (isString(code) && code.indexOf('-') > -1) {
893
+ if (typeof Intl !== 'undefined' && typeof Intl.getCanonicalLocales !== 'undefined') {
894
+ try {
895
+ let formattedCode = Intl.getCanonicalLocales(code)[0];
896
+ if (formattedCode && this.options.lowerCaseLng) {
897
+ formattedCode = formattedCode.toLowerCase();
898
+ }
899
+ if (formattedCode) return formattedCode;
900
+ } catch (e) {}
901
+ }
902
+ const specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
903
+ let p = code.split('-');
904
+ if (this.options.lowerCaseLng) {
905
+ p = p.map(part => part.toLowerCase());
906
+ } else if (p.length === 2) {
907
+ p[0] = p[0].toLowerCase();
908
+ p[1] = p[1].toUpperCase();
909
+ if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
910
+ } else if (p.length === 3) {
911
+ p[0] = p[0].toLowerCase();
912
+ if (p[1].length === 2) p[1] = p[1].toUpperCase();
913
+ if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();
914
+ if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
915
+ if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
916
+ }
917
+ return p.join('-');
918
+ }
919
+ return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
920
+ }
921
+ isSupportedCode(code) {
922
+ if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
923
+ code = this.getLanguagePartFromCode(code);
924
+ }
925
+ return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
926
+ }
927
+ getBestMatchFromCodes(codes) {
928
+ if (!codes) return null;
929
+ let found;
930
+ codes.forEach(code => {
931
+ if (found) return;
932
+ const cleanedLng = this.formatLanguageCode(code);
933
+ if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
934
+ });
935
+ if (!found && this.options.supportedLngs) {
936
+ codes.forEach(code => {
937
+ if (found) return;
938
+ const lngOnly = this.getLanguagePartFromCode(code);
939
+ if (this.isSupportedCode(lngOnly)) return found = lngOnly;
940
+ found = this.options.supportedLngs.find(supportedLng => {
941
+ if (supportedLng === lngOnly) return supportedLng;
942
+ if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return;
943
+ if (supportedLng.indexOf('-') > 0 && lngOnly.indexOf('-') < 0 && supportedLng.substring(0, supportedLng.indexOf('-')) === lngOnly) return supportedLng;
944
+ if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng;
945
+ });
946
+ });
947
+ }
948
+ if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
949
+ return found;
950
+ }
951
+ getFallbackCodes(fallbacks, code) {
952
+ if (!fallbacks) return [];
953
+ if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
954
+ if (isString(fallbacks)) fallbacks = [fallbacks];
955
+ if (Array.isArray(fallbacks)) return fallbacks;
956
+ if (!code) return fallbacks.default || [];
957
+ let found = fallbacks[code];
958
+ if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
959
+ if (!found) found = fallbacks[this.formatLanguageCode(code)];
960
+ if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
961
+ if (!found) found = fallbacks.default;
962
+ return found || [];
963
+ }
964
+ toResolveHierarchy(code, fallbackCode) {
965
+ const fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
966
+ const codes = [];
967
+ const addCode = c => {
968
+ if (!c) return;
969
+ if (this.isSupportedCode(c)) {
970
+ codes.push(c);
971
+ } else {
972
+ this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
973
+ }
974
+ };
975
+ if (isString(code) && (code.indexOf('-') > -1 || code.indexOf('_') > -1)) {
976
+ if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
977
+ if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
978
+ if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
979
+ } else if (isString(code)) {
980
+ addCode(this.formatLanguageCode(code));
981
+ }
982
+ fallbackCodes.forEach(fc => {
983
+ if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
984
+ });
985
+ return codes;
986
+ }
987
+ }
988
+
989
+ let sets = [{
990
+ lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'tl', 'ti', 'tr', 'uz', 'wa'],
991
+ nr: [1, 2],
992
+ fc: 1
993
+ }, {
994
+ lngs: ['af', 'an', 'ast', 'az', 'bg', 'bn', 'ca', 'da', 'de', 'dev', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fi', 'fo', 'fur', 'fy', 'gl', 'gu', 'ha', 'hi', 'hu', 'hy', 'ia', 'it', 'kk', 'kn', 'ku', 'lb', 'mai', 'ml', 'mn', 'mr', 'nah', 'nap', 'nb', 'ne', 'nl', 'nn', 'no', 'nso', 'pa', 'pap', 'pms', 'ps', 'pt-PT', 'rm', 'sco', 'se', 'si', 'so', 'son', 'sq', 'sv', 'sw', 'ta', 'te', 'tk', 'ur', 'yo'],
995
+ nr: [1, 2],
996
+ fc: 2
997
+ }, {
998
+ lngs: ['ay', 'bo', 'cgg', 'fa', 'ht', 'id', 'ja', 'jbo', 'ka', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'],
999
+ nr: [1],
1000
+ fc: 3
1001
+ }, {
1002
+ lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'],
1003
+ nr: [1, 2, 5],
1004
+ fc: 4
1005
+ }, {
1006
+ lngs: ['ar'],
1007
+ nr: [0, 1, 2, 3, 11, 100],
1008
+ fc: 5
1009
+ }, {
1010
+ lngs: ['cs', 'sk'],
1011
+ nr: [1, 2, 5],
1012
+ fc: 6
1013
+ }, {
1014
+ lngs: ['csb', 'pl'],
1015
+ nr: [1, 2, 5],
1016
+ fc: 7
1017
+ }, {
1018
+ lngs: ['cy'],
1019
+ nr: [1, 2, 3, 8],
1020
+ fc: 8
1021
+ }, {
1022
+ lngs: ['fr'],
1023
+ nr: [1, 2],
1024
+ fc: 9
1025
+ }, {
1026
+ lngs: ['ga'],
1027
+ nr: [1, 2, 3, 7, 11],
1028
+ fc: 10
1029
+ }, {
1030
+ lngs: ['gd'],
1031
+ nr: [1, 2, 3, 20],
1032
+ fc: 11
1033
+ }, {
1034
+ lngs: ['is'],
1035
+ nr: [1, 2],
1036
+ fc: 12
1037
+ }, {
1038
+ lngs: ['jv'],
1039
+ nr: [0, 1],
1040
+ fc: 13
1041
+ }, {
1042
+ lngs: ['kw'],
1043
+ nr: [1, 2, 3, 4],
1044
+ fc: 14
1045
+ }, {
1046
+ lngs: ['lt'],
1047
+ nr: [1, 2, 10],
1048
+ fc: 15
1049
+ }, {
1050
+ lngs: ['lv'],
1051
+ nr: [1, 2, 0],
1052
+ fc: 16
1053
+ }, {
1054
+ lngs: ['mk'],
1055
+ nr: [1, 2],
1056
+ fc: 17
1057
+ }, {
1058
+ lngs: ['mnk'],
1059
+ nr: [0, 1, 2],
1060
+ fc: 18
1061
+ }, {
1062
+ lngs: ['mt'],
1063
+ nr: [1, 2, 11, 20],
1064
+ fc: 19
1065
+ }, {
1066
+ lngs: ['or'],
1067
+ nr: [2, 1],
1068
+ fc: 2
1069
+ }, {
1070
+ lngs: ['ro'],
1071
+ nr: [1, 2, 20],
1072
+ fc: 20
1073
+ }, {
1074
+ lngs: ['sl'],
1075
+ nr: [5, 1, 2, 3],
1076
+ fc: 21
1077
+ }, {
1078
+ lngs: ['he', 'iw'],
1079
+ nr: [1, 2, 20, 21],
1080
+ fc: 22
1081
+ }];
1082
+ let _rulesPluralsTypes = {
1083
+ 1: n => Number(n > 1),
1084
+ 2: n => Number(n != 1),
1085
+ 3: n => 0,
1086
+ 4: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
1087
+ 5: n => Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5),
1088
+ 6: n => Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2),
1089
+ 7: n => Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
1090
+ 8: n => Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3),
1091
+ 9: n => Number(n >= 2),
1092
+ 10: n => Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4),
1093
+ 11: n => Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3),
1094
+ 12: n => Number(n % 10 != 1 || n % 100 == 11),
1095
+ 13: n => Number(n !== 0),
1096
+ 14: n => Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3),
1097
+ 15: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
1098
+ 16: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2),
1099
+ 17: n => Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1),
1100
+ 18: n => Number(n == 0 ? 0 : n == 1 ? 1 : 2),
1101
+ 19: n => Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3),
1102
+ 20: n => Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2),
1103
+ 21: n => Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0),
1104
+ 22: n => Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3)
1105
+ };
1106
+ const nonIntlVersions = ['v1', 'v2', 'v3'];
1107
+ const intlVersions = ['v4'];
1108
+ const suffixesOrder = {
1109
+ zero: 0,
1110
+ one: 1,
1111
+ two: 2,
1112
+ few: 3,
1113
+ many: 4,
1114
+ other: 5
1115
+ };
1116
+ const createRules = () => {
1117
+ const rules = {};
1118
+ sets.forEach(set => {
1119
+ set.lngs.forEach(l => {
1120
+ rules[l] = {
1121
+ numbers: set.nr,
1122
+ plurals: _rulesPluralsTypes[set.fc]
1123
+ };
1124
+ });
1125
+ });
1126
+ return rules;
1127
+ };
1128
+ class PluralResolver {
1129
+ constructor(languageUtils) {
1130
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1131
+ this.languageUtils = languageUtils;
1132
+ this.options = options;
1133
+ this.logger = baseLogger.create('pluralResolver');
1134
+ if ((!this.options.compatibilityJSON || intlVersions.includes(this.options.compatibilityJSON)) && (typeof Intl === 'undefined' || !Intl.PluralRules)) {
1135
+ this.options.compatibilityJSON = 'v3';
1136
+ this.logger.error('Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.');
1137
+ }
1138
+ this.rules = createRules();
1139
+ this.pluralRulesCache = {};
1140
+ }
1141
+ addRule(lng, obj) {
1142
+ this.rules[lng] = obj;
1143
+ }
1144
+ clearCache() {
1145
+ this.pluralRulesCache = {};
1146
+ }
1147
+ getRule(code) {
1148
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1149
+ if (this.shouldUseIntlApi()) {
1150
+ try {
1151
+ const cleanedCode = getCleanedCode(code === 'dev' ? 'en' : code);
1152
+ const type = options.ordinal ? 'ordinal' : 'cardinal';
1153
+ const cacheKey = JSON.stringify({
1154
+ cleanedCode,
1155
+ type
1156
+ });
1157
+ if (cacheKey in this.pluralRulesCache) {
1158
+ return this.pluralRulesCache[cacheKey];
1159
+ }
1160
+ const rule = new Intl.PluralRules(cleanedCode, {
1161
+ type
1162
+ });
1163
+ this.pluralRulesCache[cacheKey] = rule;
1164
+ return rule;
1165
+ } catch (err) {
1166
+ return;
1167
+ }
1168
+ }
1169
+ return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
1170
+ }
1171
+ needsPlural(code) {
1172
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1173
+ const rule = this.getRule(code, options);
1174
+ if (this.shouldUseIntlApi()) {
1175
+ return rule && rule.resolvedOptions().pluralCategories.length > 1;
1176
+ }
1177
+ return rule && rule.numbers.length > 1;
1178
+ }
1179
+ getPluralFormsOfKey(code, key) {
1180
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1181
+ return this.getSuffixes(code, options).map(suffix => `${key}${suffix}`);
1182
+ }
1183
+ getSuffixes(code) {
1184
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1185
+ const rule = this.getRule(code, options);
1186
+ if (!rule) {
1187
+ return [];
1188
+ }
1189
+ if (this.shouldUseIntlApi()) {
1190
+ return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map(pluralCategory => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${pluralCategory}`);
1191
+ }
1192
+ return rule.numbers.map(number => this.getSuffix(code, number, options));
1193
+ }
1194
+ getSuffix(code, count) {
1195
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1196
+ const rule = this.getRule(code, options);
1197
+ if (rule) {
1198
+ if (this.shouldUseIntlApi()) {
1199
+ return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${rule.select(count)}`;
1200
+ }
1201
+ return this.getSuffixRetroCompatible(rule, count);
1202
+ }
1203
+ this.logger.warn(`no plural rule found for: ${code}`);
1204
+ return '';
1205
+ }
1206
+ getSuffixRetroCompatible(rule, count) {
1207
+ const idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
1208
+ let suffix = rule.numbers[idx];
1209
+ if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
1210
+ if (suffix === 2) {
1211
+ suffix = 'plural';
1212
+ } else if (suffix === 1) {
1213
+ suffix = '';
1214
+ }
1215
+ }
1216
+ const returnSuffix = () => this.options.prepend && suffix.toString() ? this.options.prepend + suffix.toString() : suffix.toString();
1217
+ if (this.options.compatibilityJSON === 'v1') {
1218
+ if (suffix === 1) return '';
1219
+ if (typeof suffix === 'number') return `_plural_${suffix.toString()}`;
1220
+ return returnSuffix();
1221
+ } else if (this.options.compatibilityJSON === 'v2') {
1222
+ return returnSuffix();
1223
+ } else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
1224
+ return returnSuffix();
1225
+ }
1226
+ return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
1227
+ }
1228
+ shouldUseIntlApi() {
1229
+ return !nonIntlVersions.includes(this.options.compatibilityJSON);
1230
+ }
1231
+ }
1232
+
1233
+ const deepFindWithDefaults = function (data, defaultData, key) {
1234
+ let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
1235
+ let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
1236
+ let path = getPathWithDefaults(data, defaultData, key);
1237
+ if (!path && ignoreJSONStructure && isString(key)) {
1238
+ path = deepFind(data, key, keySeparator);
1239
+ if (path === undefined) path = deepFind(defaultData, key, keySeparator);
1240
+ }
1241
+ return path;
1242
+ };
1243
+ const regexSafe = val => val.replace(/\$/g, '$$$$');
1244
+ class Interpolator {
1245
+ constructor() {
1246
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1247
+ this.logger = baseLogger.create('interpolator');
1248
+ this.options = options;
1249
+ this.format = options.interpolation && options.interpolation.format || (value => value);
1250
+ this.init(options);
1251
+ }
1252
+ init() {
1253
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1254
+ if (!options.interpolation) options.interpolation = {
1255
+ escapeValue: true
1256
+ };
1257
+ const {
1258
+ escape: escape$1,
1259
+ escapeValue,
1260
+ useRawValueToEscape,
1261
+ prefix,
1262
+ prefixEscaped,
1263
+ suffix,
1264
+ suffixEscaped,
1265
+ formatSeparator,
1266
+ unescapeSuffix,
1267
+ unescapePrefix,
1268
+ nestingPrefix,
1269
+ nestingPrefixEscaped,
1270
+ nestingSuffix,
1271
+ nestingSuffixEscaped,
1272
+ nestingOptionsSeparator,
1273
+ maxReplaces,
1274
+ alwaysFormat
1275
+ } = options.interpolation;
1276
+ this.escape = escape$1 !== undefined ? escape$1 : escape;
1277
+ this.escapeValue = escapeValue !== undefined ? escapeValue : true;
1278
+ this.useRawValueToEscape = useRawValueToEscape !== undefined ? useRawValueToEscape : false;
1279
+ this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || '{{';
1280
+ this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || '}}';
1281
+ this.formatSeparator = formatSeparator || ',';
1282
+ this.unescapePrefix = unescapeSuffix ? '' : unescapePrefix || '-';
1283
+ this.unescapeSuffix = this.unescapePrefix ? '' : unescapeSuffix || '';
1284
+ this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape('$t(');
1285
+ this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(')');
1286
+ this.nestingOptionsSeparator = nestingOptionsSeparator || ',';
1287
+ this.maxReplaces = maxReplaces || 1000;
1288
+ this.alwaysFormat = alwaysFormat !== undefined ? alwaysFormat : false;
1289
+ this.resetRegExp();
1290
+ }
1291
+ reset() {
1292
+ if (this.options) this.init(this.options);
1293
+ }
1294
+ resetRegExp() {
1295
+ const getOrResetRegExp = (existingRegExp, pattern) => {
1296
+ if (existingRegExp && existingRegExp.source === pattern) {
1297
+ existingRegExp.lastIndex = 0;
1298
+ return existingRegExp;
1299
+ }
1300
+ return new RegExp(pattern, 'g');
1301
+ };
1302
+ this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
1303
+ this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
1304
+ this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}(.+?)${this.nestingSuffix}`);
1305
+ }
1306
+ interpolate(str, data, lng, options) {
1307
+ let match;
1308
+ let value;
1309
+ let replaces;
1310
+ const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
1311
+ const handleFormat = key => {
1312
+ if (key.indexOf(this.formatSeparator) < 0) {
1313
+ const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
1314
+ return this.alwaysFormat ? this.format(path, undefined, lng, {
1315
+ ...options,
1316
+ ...data,
1317
+ interpolationkey: key
1318
+ }) : path;
1319
+ }
1320
+ const p = key.split(this.formatSeparator);
1321
+ const k = p.shift().trim();
1322
+ const f = p.join(this.formatSeparator).trim();
1323
+ return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
1324
+ ...options,
1325
+ ...data,
1326
+ interpolationkey: k
1327
+ });
1328
+ };
1329
+ this.resetRegExp();
1330
+ const missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
1331
+ const skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
1332
+ const todos = [{
1333
+ regex: this.regexpUnescape,
1334
+ safeValue: val => regexSafe(val)
1335
+ }, {
1336
+ regex: this.regexp,
1337
+ safeValue: val => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
1338
+ }];
1339
+ todos.forEach(todo => {
1340
+ replaces = 0;
1341
+ while (match = todo.regex.exec(str)) {
1342
+ const matchedVar = match[1].trim();
1343
+ value = handleFormat(matchedVar);
1344
+ if (value === undefined) {
1345
+ if (typeof missingInterpolationHandler === 'function') {
1346
+ const temp = missingInterpolationHandler(str, match, options);
1347
+ value = isString(temp) ? temp : '';
1348
+ } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
1349
+ value = '';
1350
+ } else if (skipOnVariables) {
1351
+ value = match[0];
1352
+ continue;
1353
+ } else {
1354
+ this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
1355
+ value = '';
1356
+ }
1357
+ } else if (!isString(value) && !this.useRawValueToEscape) {
1358
+ value = makeString(value);
1359
+ }
1360
+ const safeValue = todo.safeValue(value);
1361
+ str = str.replace(match[0], safeValue);
1362
+ if (skipOnVariables) {
1363
+ todo.regex.lastIndex += value.length;
1364
+ todo.regex.lastIndex -= match[0].length;
1365
+ } else {
1366
+ todo.regex.lastIndex = 0;
1367
+ }
1368
+ replaces++;
1369
+ if (replaces >= this.maxReplaces) {
1370
+ break;
1371
+ }
1372
+ }
1373
+ });
1374
+ return str;
1375
+ }
1376
+ nest(str, fc) {
1377
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1378
+ let match;
1379
+ let value;
1380
+ let clonedOptions;
1381
+ const handleHasOptions = (key, inheritedOptions) => {
1382
+ const sep = this.nestingOptionsSeparator;
1383
+ if (key.indexOf(sep) < 0) return key;
1384
+ const c = key.split(new RegExp(`${sep}[ ]*{`));
1385
+ let optionsString = `{${c[1]}`;
1386
+ key = c[0];
1387
+ optionsString = this.interpolate(optionsString, clonedOptions);
1388
+ const matchedSingleQuotes = optionsString.match(/'/g);
1389
+ const matchedDoubleQuotes = optionsString.match(/"/g);
1390
+ if (matchedSingleQuotes && matchedSingleQuotes.length % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
1391
+ optionsString = optionsString.replace(/'/g, '"');
1392
+ }
1393
+ try {
1394
+ clonedOptions = JSON.parse(optionsString);
1395
+ if (inheritedOptions) clonedOptions = {
1396
+ ...inheritedOptions,
1397
+ ...clonedOptions
1398
+ };
1399
+ } catch (e) {
1400
+ this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
1401
+ return `${key}${sep}${optionsString}`;
1402
+ }
1403
+ if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
1404
+ return key;
1405
+ };
1406
+ while (match = this.nestingRegexp.exec(str)) {
1407
+ let formatters = [];
1408
+ clonedOptions = {
1409
+ ...options
1410
+ };
1411
+ clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
1412
+ clonedOptions.applyPostProcessor = false;
1413
+ delete clonedOptions.defaultValue;
1414
+ let doReduce = false;
1415
+ if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {
1416
+ const r = match[1].split(this.formatSeparator).map(elem => elem.trim());
1417
+ match[1] = r.shift();
1418
+ formatters = r;
1419
+ doReduce = true;
1420
+ }
1421
+ value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
1422
+ if (value && match[0] === str && !isString(value)) return value;
1423
+ if (!isString(value)) value = makeString(value);
1424
+ if (!value) {
1425
+ this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
1426
+ value = '';
1427
+ }
1428
+ if (doReduce) {
1429
+ value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
1430
+ ...options,
1431
+ interpolationkey: match[1].trim()
1432
+ }), value.trim());
1433
+ }
1434
+ str = str.replace(match[0], value);
1435
+ this.regexp.lastIndex = 0;
1436
+ }
1437
+ return str;
1438
+ }
1439
+ }
1440
+
1441
+ const parseFormatStr = formatStr => {
1442
+ let formatName = formatStr.toLowerCase().trim();
1443
+ const formatOptions = {};
1444
+ if (formatStr.indexOf('(') > -1) {
1445
+ const p = formatStr.split('(');
1446
+ formatName = p[0].toLowerCase().trim();
1447
+ const optStr = p[1].substring(0, p[1].length - 1);
1448
+ if (formatName === 'currency' && optStr.indexOf(':') < 0) {
1449
+ if (!formatOptions.currency) formatOptions.currency = optStr.trim();
1450
+ } else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
1451
+ if (!formatOptions.range) formatOptions.range = optStr.trim();
1452
+ } else {
1453
+ const opts = optStr.split(';');
1454
+ opts.forEach(opt => {
1455
+ if (opt) {
1456
+ const [key, ...rest] = opt.split(':');
1457
+ const val = rest.join(':').trim().replace(/^'+|'+$/g, '');
1458
+ const trimmedKey = key.trim();
1459
+ if (!formatOptions[trimmedKey]) formatOptions[trimmedKey] = val;
1460
+ if (val === 'false') formatOptions[trimmedKey] = false;
1461
+ if (val === 'true') formatOptions[trimmedKey] = true;
1462
+ if (!isNaN(val)) formatOptions[trimmedKey] = parseInt(val, 10);
1463
+ }
1464
+ });
1465
+ }
1466
+ }
1467
+ return {
1468
+ formatName,
1469
+ formatOptions
1470
+ };
1471
+ };
1472
+ const createCachedFormatter = fn => {
1473
+ const cache = {};
1474
+ return (val, lng, options) => {
1475
+ let optForCache = options;
1476
+ if (options && options.interpolationkey && options.formatParams && options.formatParams[options.interpolationkey] && options[options.interpolationkey]) {
1477
+ optForCache = {
1478
+ ...optForCache,
1479
+ [options.interpolationkey]: undefined
1480
+ };
1481
+ }
1482
+ const key = lng + JSON.stringify(optForCache);
1483
+ let formatter = cache[key];
1484
+ if (!formatter) {
1485
+ formatter = fn(getCleanedCode(lng), options);
1486
+ cache[key] = formatter;
1487
+ }
1488
+ return formatter(val);
1489
+ };
1490
+ };
1491
+ class Formatter {
1492
+ constructor() {
1493
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1494
+ this.logger = baseLogger.create('formatter');
1495
+ this.options = options;
1496
+ this.formats = {
1497
+ number: createCachedFormatter((lng, opt) => val => new Intl.NumberFormat(lng, {
1498
+ ...opt
1499
+ }).format(val)),
1500
+ currency: createCachedFormatter((lng, opt) => val => new Intl.NumberFormat(lng, {
1501
+ ...opt,
1502
+ style: 'currency'
1503
+ }).format(val)),
1504
+ datetime: createCachedFormatter((lng, opt) => val => new Intl.DateTimeFormat(lng, {
1505
+ ...opt
1506
+ }).format(val)),
1507
+ relativetime: createCachedFormatter((lng, opt) => val => new Intl.RelativeTimeFormat(lng, {
1508
+ ...opt
1509
+ }).format(val, opt.range || 'day')),
1510
+ list: createCachedFormatter((lng, opt) => val => new Intl.ListFormat(lng, {
1511
+ ...opt
1512
+ }).format(val))
1513
+ };
1514
+ this.init(options);
1515
+ }
1516
+ init(services) {
1517
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
1518
+ interpolation: {}
1519
+ };
1520
+ this.formatSeparator = options.interpolation.formatSeparator || ',';
1521
+ }
1522
+ add(name, fc) {
1523
+ this.formats[name.toLowerCase().trim()] = fc;
1524
+ }
1525
+ addCached(name, fc) {
1526
+ this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
1527
+ }
1528
+ format(value, format, lng) {
1529
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1530
+ const formats = format.split(this.formatSeparator);
1531
+ if (formats.length > 1 && formats[0].indexOf('(') > 1 && formats[0].indexOf(')') < 0 && formats.find(f => f.indexOf(')') > -1)) {
1532
+ const lastIndex = formats.findIndex(f => f.indexOf(')') > -1);
1533
+ formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
1534
+ }
1535
+ const result = formats.reduce((mem, f) => {
1536
+ const {
1537
+ formatName,
1538
+ formatOptions
1539
+ } = parseFormatStr(f);
1540
+ if (this.formats[formatName]) {
1541
+ let formatted = mem;
1542
+ try {
1543
+ const valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};
1544
+ const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
1545
+ formatted = this.formats[formatName](mem, l, {
1546
+ ...formatOptions,
1547
+ ...options,
1548
+ ...valOptions
1549
+ });
1550
+ } catch (error) {
1551
+ this.logger.warn(error);
1552
+ }
1553
+ return formatted;
1554
+ } else {
1555
+ this.logger.warn(`there was no format function for ${formatName}`);
1556
+ }
1557
+ return mem;
1558
+ }, value);
1559
+ return result;
1560
+ }
1561
+ }
1562
+
1563
+ const removePending = (q, name) => {
1564
+ if (q.pending[name] !== undefined) {
1565
+ delete q.pending[name];
1566
+ q.pendingCount--;
1567
+ }
1568
+ };
1569
+ class Connector extends EventEmitter {
1570
+ constructor(backend, store, services) {
1571
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1572
+ super();
1573
+ this.backend = backend;
1574
+ this.store = store;
1575
+ this.services = services;
1576
+ this.languageUtils = services.languageUtils;
1577
+ this.options = options;
1578
+ this.logger = baseLogger.create('backendConnector');
1579
+ this.waitingReads = [];
1580
+ this.maxParallelReads = options.maxParallelReads || 10;
1581
+ this.readingCalls = 0;
1582
+ this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
1583
+ this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
1584
+ this.state = {};
1585
+ this.queue = [];
1586
+ if (this.backend && this.backend.init) {
1587
+ this.backend.init(services, options.backend, options);
1588
+ }
1589
+ }
1590
+ queueLoad(languages, namespaces, options, callback) {
1591
+ const toLoad = {};
1592
+ const pending = {};
1593
+ const toLoadLanguages = {};
1594
+ const toLoadNamespaces = {};
1595
+ languages.forEach(lng => {
1596
+ let hasAllNamespaces = true;
1597
+ namespaces.forEach(ns => {
1598
+ const name = `${lng}|${ns}`;
1599
+ if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
1600
+ this.state[name] = 2;
1601
+ } else if (this.state[name] < 0) ; else if (this.state[name] === 1) {
1602
+ if (pending[name] === undefined) pending[name] = true;
1603
+ } else {
1604
+ this.state[name] = 1;
1605
+ hasAllNamespaces = false;
1606
+ if (pending[name] === undefined) pending[name] = true;
1607
+ if (toLoad[name] === undefined) toLoad[name] = true;
1608
+ if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
1609
+ }
1610
+ });
1611
+ if (!hasAllNamespaces) toLoadLanguages[lng] = true;
1612
+ });
1613
+ if (Object.keys(toLoad).length || Object.keys(pending).length) {
1614
+ this.queue.push({
1615
+ pending,
1616
+ pendingCount: Object.keys(pending).length,
1617
+ loaded: {},
1618
+ errors: [],
1619
+ callback
1620
+ });
1621
+ }
1622
+ return {
1623
+ toLoad: Object.keys(toLoad),
1624
+ pending: Object.keys(pending),
1625
+ toLoadLanguages: Object.keys(toLoadLanguages),
1626
+ toLoadNamespaces: Object.keys(toLoadNamespaces)
1627
+ };
1628
+ }
1629
+ loaded(name, err, data) {
1630
+ const s = name.split('|');
1631
+ const lng = s[0];
1632
+ const ns = s[1];
1633
+ if (err) this.emit('failedLoading', lng, ns, err);
1634
+ if (!err && data) {
1635
+ this.store.addResourceBundle(lng, ns, data, undefined, undefined, {
1636
+ skipCopy: true
1637
+ });
1638
+ }
1639
+ this.state[name] = err ? -1 : 2;
1640
+ if (err && data) this.state[name] = 0;
1641
+ const loaded = {};
1642
+ this.queue.forEach(q => {
1643
+ pushPath(q.loaded, [lng], ns);
1644
+ removePending(q, name);
1645
+ if (err) q.errors.push(err);
1646
+ if (q.pendingCount === 0 && !q.done) {
1647
+ Object.keys(q.loaded).forEach(l => {
1648
+ if (!loaded[l]) loaded[l] = {};
1649
+ const loadedKeys = q.loaded[l];
1650
+ if (loadedKeys.length) {
1651
+ loadedKeys.forEach(n => {
1652
+ if (loaded[l][n] === undefined) loaded[l][n] = true;
1653
+ });
1654
+ }
1655
+ });
1656
+ q.done = true;
1657
+ if (q.errors.length) {
1658
+ q.callback(q.errors);
1659
+ } else {
1660
+ q.callback();
1661
+ }
1662
+ }
1663
+ });
1664
+ this.emit('loaded', loaded);
1665
+ this.queue = this.queue.filter(q => !q.done);
1666
+ }
1667
+ read(lng, ns, fcName) {
1668
+ let tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1669
+ let wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
1670
+ let callback = arguments.length > 5 ? arguments[5] : undefined;
1671
+ if (!lng.length) return callback(null, {});
1672
+ if (this.readingCalls >= this.maxParallelReads) {
1673
+ this.waitingReads.push({
1674
+ lng,
1675
+ ns,
1676
+ fcName,
1677
+ tried,
1678
+ wait,
1679
+ callback
1680
+ });
1681
+ return;
1682
+ }
1683
+ this.readingCalls++;
1684
+ const resolver = (err, data) => {
1685
+ this.readingCalls--;
1686
+ if (this.waitingReads.length > 0) {
1687
+ const next = this.waitingReads.shift();
1688
+ this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
1689
+ }
1690
+ if (err && data && tried < this.maxRetries) {
1691
+ setTimeout(() => {
1692
+ this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
1693
+ }, wait);
1694
+ return;
1695
+ }
1696
+ callback(err, data);
1697
+ };
1698
+ const fc = this.backend[fcName].bind(this.backend);
1699
+ if (fc.length === 2) {
1700
+ try {
1701
+ const r = fc(lng, ns);
1702
+ if (r && typeof r.then === 'function') {
1703
+ r.then(data => resolver(null, data)).catch(resolver);
1704
+ } else {
1705
+ resolver(null, r);
1706
+ }
1707
+ } catch (err) {
1708
+ resolver(err);
1709
+ }
1710
+ return;
1711
+ }
1712
+ return fc(lng, ns, resolver);
1713
+ }
1714
+ prepareLoading(languages, namespaces) {
1715
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1716
+ let callback = arguments.length > 3 ? arguments[3] : undefined;
1717
+ if (!this.backend) {
1718
+ this.logger.warn('No backend was added via i18next.use. Will not load resources.');
1719
+ return callback && callback();
1720
+ }
1721
+ if (isString(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
1722
+ if (isString(namespaces)) namespaces = [namespaces];
1723
+ const toLoad = this.queueLoad(languages, namespaces, options, callback);
1724
+ if (!toLoad.toLoad.length) {
1725
+ if (!toLoad.pending.length) callback();
1726
+ return null;
1727
+ }
1728
+ toLoad.toLoad.forEach(name => {
1729
+ this.loadOne(name);
1730
+ });
1731
+ }
1732
+ load(languages, namespaces, callback) {
1733
+ this.prepareLoading(languages, namespaces, {}, callback);
1734
+ }
1735
+ reload(languages, namespaces, callback) {
1736
+ this.prepareLoading(languages, namespaces, {
1737
+ reload: true
1738
+ }, callback);
1739
+ }
1740
+ loadOne(name) {
1741
+ let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1742
+ const s = name.split('|');
1743
+ const lng = s[0];
1744
+ const ns = s[1];
1745
+ this.read(lng, ns, 'read', undefined, undefined, (err, data) => {
1746
+ if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
1747
+ if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
1748
+ this.loaded(name, err, data);
1749
+ });
1750
+ }
1751
+ saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
1752
+ let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
1753
+ let clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : () => {};
1754
+ if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
1755
+ this.logger.warn(`did not save key "${key}" as the namespace "${namespace}" was not yet loaded`, 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');
1756
+ return;
1757
+ }
1758
+ if (key === undefined || key === null || key === '') return;
1759
+ if (this.backend && this.backend.create) {
1760
+ const opts = {
1761
+ ...options,
1762
+ isUpdate
1763
+ };
1764
+ const fc = this.backend.create.bind(this.backend);
1765
+ if (fc.length < 6) {
1766
+ try {
1767
+ let r;
1768
+ if (fc.length === 5) {
1769
+ r = fc(languages, namespace, key, fallbackValue, opts);
1770
+ } else {
1771
+ r = fc(languages, namespace, key, fallbackValue);
1772
+ }
1773
+ if (r && typeof r.then === 'function') {
1774
+ r.then(data => clb(null, data)).catch(clb);
1775
+ } else {
1776
+ clb(null, r);
1777
+ }
1778
+ } catch (err) {
1779
+ clb(err);
1780
+ }
1781
+ } else {
1782
+ fc(languages, namespace, key, fallbackValue, clb, opts);
1783
+ }
1784
+ }
1785
+ if (!languages || !languages[0]) return;
1786
+ this.store.addResource(languages[0], namespace, key, fallbackValue);
1787
+ }
1788
+ }
1789
+
1790
+ const get = () => ({
1791
+ debug: false,
1792
+ initImmediate: true,
1793
+ ns: ['translation'],
1794
+ defaultNS: ['translation'],
1795
+ fallbackLng: ['dev'],
1796
+ fallbackNS: false,
1797
+ supportedLngs: false,
1798
+ nonExplicitSupportedLngs: false,
1799
+ load: 'all',
1800
+ preload: false,
1801
+ simplifyPluralSuffix: true,
1802
+ keySeparator: '.',
1803
+ nsSeparator: ':',
1804
+ pluralSeparator: '_',
1805
+ contextSeparator: '_',
1806
+ partialBundledLanguages: false,
1807
+ saveMissing: false,
1808
+ updateMissing: false,
1809
+ saveMissingTo: 'fallback',
1810
+ saveMissingPlurals: true,
1811
+ missingKeyHandler: false,
1812
+ missingInterpolationHandler: false,
1813
+ postProcess: false,
1814
+ postProcessPassResolved: false,
1815
+ returnNull: false,
1816
+ returnEmptyString: true,
1817
+ returnObjects: false,
1818
+ joinArrays: false,
1819
+ returnedObjectHandler: false,
1820
+ parseMissingKeyHandler: false,
1821
+ appendNamespaceToMissingKey: false,
1822
+ appendNamespaceToCIMode: false,
1823
+ overloadTranslationOptionHandler: args => {
1824
+ let ret = {};
1825
+ if (typeof args[1] === 'object') ret = args[1];
1826
+ if (isString(args[1])) ret.defaultValue = args[1];
1827
+ if (isString(args[2])) ret.tDescription = args[2];
1828
+ if (typeof args[2] === 'object' || typeof args[3] === 'object') {
1829
+ const options = args[3] || args[2];
1830
+ Object.keys(options).forEach(key => {
1831
+ ret[key] = options[key];
1832
+ });
1833
+ }
1834
+ return ret;
1835
+ },
1836
+ interpolation: {
1837
+ escapeValue: true,
1838
+ format: value => value,
1839
+ prefix: '{{',
1840
+ suffix: '}}',
1841
+ formatSeparator: ',',
1842
+ unescapePrefix: '-',
1843
+ nestingPrefix: '$t(',
1844
+ nestingSuffix: ')',
1845
+ nestingOptionsSeparator: ',',
1846
+ maxReplaces: 1000,
1847
+ skipOnVariables: true
1848
+ }
1849
+ });
1850
+ const transformOptions = options => {
1851
+ if (isString(options.ns)) options.ns = [options.ns];
1852
+ if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
1853
+ if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
1854
+ if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {
1855
+ options.supportedLngs = options.supportedLngs.concat(['cimode']);
1856
+ }
1857
+ return options;
1858
+ };
1859
+
1860
+ const noop = () => {};
1861
+ const bindMemberFunctions = inst => {
1862
+ const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
1863
+ mems.forEach(mem => {
1864
+ if (typeof inst[mem] === 'function') {
1865
+ inst[mem] = inst[mem].bind(inst);
1866
+ }
1867
+ });
1868
+ };
1869
+ class I18n extends EventEmitter {
1870
+ constructor() {
1871
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1872
+ let callback = arguments.length > 1 ? arguments[1] : undefined;
1873
+ super();
1874
+ this.options = transformOptions(options);
1875
+ this.services = {};
1876
+ this.logger = baseLogger;
1877
+ this.modules = {
1878
+ external: []
1879
+ };
1880
+ bindMemberFunctions(this);
1881
+ if (callback && !this.isInitialized && !options.isClone) {
1882
+ if (!this.options.initImmediate) {
1883
+ this.init(options, callback);
1884
+ return this;
1885
+ }
1886
+ setTimeout(() => {
1887
+ this.init(options, callback);
1888
+ }, 0);
1889
+ }
1890
+ }
1891
+ init() {
1892
+ var _this = this;
1893
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1894
+ let callback = arguments.length > 1 ? arguments[1] : undefined;
1895
+ this.isInitializing = true;
1896
+ if (typeof options === 'function') {
1897
+ callback = options;
1898
+ options = {};
1899
+ }
1900
+ if (!options.defaultNS && options.defaultNS !== false && options.ns) {
1901
+ if (isString(options.ns)) {
1902
+ options.defaultNS = options.ns;
1903
+ } else if (options.ns.indexOf('translation') < 0) {
1904
+ options.defaultNS = options.ns[0];
1905
+ }
1906
+ }
1907
+ const defOpts = get();
1908
+ this.options = {
1909
+ ...defOpts,
1910
+ ...this.options,
1911
+ ...transformOptions(options)
1912
+ };
1913
+ if (this.options.compatibilityAPI !== 'v1') {
1914
+ this.options.interpolation = {
1915
+ ...defOpts.interpolation,
1916
+ ...this.options.interpolation
1917
+ };
1918
+ }
1919
+ if (options.keySeparator !== undefined) {
1920
+ this.options.userDefinedKeySeparator = options.keySeparator;
1921
+ }
1922
+ if (options.nsSeparator !== undefined) {
1923
+ this.options.userDefinedNsSeparator = options.nsSeparator;
1924
+ }
1925
+ const createClassOnDemand = ClassOrObject => {
1926
+ if (!ClassOrObject) return null;
1927
+ if (typeof ClassOrObject === 'function') return new ClassOrObject();
1928
+ return ClassOrObject;
1929
+ };
1930
+ if (!this.options.isClone) {
1931
+ if (this.modules.logger) {
1932
+ baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
1933
+ } else {
1934
+ baseLogger.init(null, this.options);
1935
+ }
1936
+ let formatter;
1937
+ if (this.modules.formatter) {
1938
+ formatter = this.modules.formatter;
1939
+ } else if (typeof Intl !== 'undefined') {
1940
+ formatter = Formatter;
1941
+ }
1942
+ const lu = new LanguageUtil(this.options);
1943
+ this.store = new ResourceStore(this.options.resources, this.options);
1944
+ const s = this.services;
1945
+ s.logger = baseLogger;
1946
+ s.resourceStore = this.store;
1947
+ s.languageUtils = lu;
1948
+ s.pluralResolver = new PluralResolver(lu, {
1949
+ prepend: this.options.pluralSeparator,
1950
+ compatibilityJSON: this.options.compatibilityJSON,
1951
+ simplifyPluralSuffix: this.options.simplifyPluralSuffix
1952
+ });
1953
+ if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
1954
+ s.formatter = createClassOnDemand(formatter);
1955
+ s.formatter.init(s, this.options);
1956
+ this.options.interpolation.format = s.formatter.format.bind(s.formatter);
1957
+ }
1958
+ s.interpolator = new Interpolator(this.options);
1959
+ s.utils = {
1960
+ hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
1961
+ };
1962
+ s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
1963
+ s.backendConnector.on('*', function (event) {
1964
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1965
+ args[_key - 1] = arguments[_key];
1966
+ }
1967
+ _this.emit(event, ...args);
1968
+ });
1969
+ if (this.modules.languageDetector) {
1970
+ s.languageDetector = createClassOnDemand(this.modules.languageDetector);
1971
+ if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
1972
+ }
1973
+ if (this.modules.i18nFormat) {
1974
+ s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
1975
+ if (s.i18nFormat.init) s.i18nFormat.init(this);
1976
+ }
1977
+ this.translator = new Translator(this.services, this.options);
1978
+ this.translator.on('*', function (event) {
1979
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1980
+ args[_key2 - 1] = arguments[_key2];
1981
+ }
1982
+ _this.emit(event, ...args);
1983
+ });
1984
+ this.modules.external.forEach(m => {
1985
+ if (m.init) m.init(this);
1986
+ });
1987
+ }
1988
+ this.format = this.options.interpolation.format;
1989
+ if (!callback) callback = noop;
1990
+ if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1991
+ const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1992
+ if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
1993
+ }
1994
+ if (!this.services.languageDetector && !this.options.lng) {
1995
+ this.logger.warn('init: no languageDetector is used and no lng is defined');
1996
+ }
1997
+ const storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
1998
+ storeApi.forEach(fcName => {
1999
+ this[fcName] = function () {
2000
+ return _this.store[fcName](...arguments);
2001
+ };
2002
+ });
2003
+ const storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
2004
+ storeApiChained.forEach(fcName => {
2005
+ this[fcName] = function () {
2006
+ _this.store[fcName](...arguments);
2007
+ return _this;
2008
+ };
2009
+ });
2010
+ const deferred = defer();
2011
+ const load = () => {
2012
+ const finish = (err, t) => {
2013
+ this.isInitializing = false;
2014
+ if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn('init: i18next is already initialized. You should call init just once!');
2015
+ this.isInitialized = true;
2016
+ if (!this.options.isClone) this.logger.log('initialized', this.options);
2017
+ this.emit('initialized', this.options);
2018
+ deferred.resolve(t);
2019
+ callback(err, t);
2020
+ };
2021
+ if (this.languages && this.options.compatibilityAPI !== 'v1' && !this.isInitialized) return finish(null, this.t.bind(this));
2022
+ this.changeLanguage(this.options.lng, finish);
2023
+ };
2024
+ if (this.options.resources || !this.options.initImmediate) {
2025
+ load();
2026
+ } else {
2027
+ setTimeout(load, 0);
2028
+ }
2029
+ return deferred;
2030
+ }
2031
+ loadResources(language) {
2032
+ let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
2033
+ let usedCallback = callback;
2034
+ const usedLng = isString(language) ? language : this.language;
2035
+ if (typeof language === 'function') usedCallback = language;
2036
+ if (!this.options.resources || this.options.partialBundledLanguages) {
2037
+ if (usedLng && usedLng.toLowerCase() === 'cimode' && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
2038
+ const toLoad = [];
2039
+ const append = lng => {
2040
+ if (!lng) return;
2041
+ if (lng === 'cimode') return;
2042
+ const lngs = this.services.languageUtils.toResolveHierarchy(lng);
2043
+ lngs.forEach(l => {
2044
+ if (l === 'cimode') return;
2045
+ if (toLoad.indexOf(l) < 0) toLoad.push(l);
2046
+ });
2047
+ };
2048
+ if (!usedLng) {
2049
+ const fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
2050
+ fallbacks.forEach(l => append(l));
2051
+ } else {
2052
+ append(usedLng);
2053
+ }
2054
+ if (this.options.preload) {
2055
+ this.options.preload.forEach(l => append(l));
2056
+ }
2057
+ this.services.backendConnector.load(toLoad, this.options.ns, e => {
2058
+ if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
2059
+ usedCallback(e);
2060
+ });
2061
+ } else {
2062
+ usedCallback(null);
2063
+ }
2064
+ }
2065
+ reloadResources(lngs, ns, callback) {
2066
+ const deferred = defer();
2067
+ if (typeof lngs === 'function') {
2068
+ callback = lngs;
2069
+ lngs = undefined;
2070
+ }
2071
+ if (typeof ns === 'function') {
2072
+ callback = ns;
2073
+ ns = undefined;
2074
+ }
2075
+ if (!lngs) lngs = this.languages;
2076
+ if (!ns) ns = this.options.ns;
2077
+ if (!callback) callback = noop;
2078
+ this.services.backendConnector.reload(lngs, ns, err => {
2079
+ deferred.resolve();
2080
+ callback(err);
2081
+ });
2082
+ return deferred;
2083
+ }
2084
+ use(module) {
2085
+ if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
2086
+ if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
2087
+ if (module.type === 'backend') {
2088
+ this.modules.backend = module;
2089
+ }
2090
+ if (module.type === 'logger' || module.log && module.warn && module.error) {
2091
+ this.modules.logger = module;
2092
+ }
2093
+ if (module.type === 'languageDetector') {
2094
+ this.modules.languageDetector = module;
2095
+ }
2096
+ if (module.type === 'i18nFormat') {
2097
+ this.modules.i18nFormat = module;
2098
+ }
2099
+ if (module.type === 'postProcessor') {
2100
+ postProcessor.addPostProcessor(module);
2101
+ }
2102
+ if (module.type === 'formatter') {
2103
+ this.modules.formatter = module;
2104
+ }
2105
+ if (module.type === '3rdParty') {
2106
+ this.modules.external.push(module);
2107
+ }
2108
+ return this;
2109
+ }
2110
+ setResolvedLanguage(l) {
2111
+ if (!l || !this.languages) return;
2112
+ if (['cimode', 'dev'].indexOf(l) > -1) return;
2113
+ for (let li = 0; li < this.languages.length; li++) {
2114
+ const lngInLngs = this.languages[li];
2115
+ if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
2116
+ if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
2117
+ this.resolvedLanguage = lngInLngs;
2118
+ break;
2119
+ }
2120
+ }
2121
+ }
2122
+ changeLanguage(lng, callback) {
2123
+ var _this2 = this;
2124
+ this.isLanguageChangingTo = lng;
2125
+ const deferred = defer();
2126
+ this.emit('languageChanging', lng);
2127
+ const setLngProps = l => {
2128
+ this.language = l;
2129
+ this.languages = this.services.languageUtils.toResolveHierarchy(l);
2130
+ this.resolvedLanguage = undefined;
2131
+ this.setResolvedLanguage(l);
2132
+ };
2133
+ const done = (err, l) => {
2134
+ if (l) {
2135
+ setLngProps(l);
2136
+ this.translator.changeLanguage(l);
2137
+ this.isLanguageChangingTo = undefined;
2138
+ this.emit('languageChanged', l);
2139
+ this.logger.log('languageChanged', l);
2140
+ } else {
2141
+ this.isLanguageChangingTo = undefined;
2142
+ }
2143
+ deferred.resolve(function () {
2144
+ return _this2.t(...arguments);
2145
+ });
2146
+ if (callback) callback(err, function () {
2147
+ return _this2.t(...arguments);
2148
+ });
2149
+ };
2150
+ const setLng = lngs => {
2151
+ if (!lng && !lngs && this.services.languageDetector) lngs = [];
2152
+ const l = isString(lngs) ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
2153
+ if (l) {
2154
+ if (!this.language) {
2155
+ setLngProps(l);
2156
+ }
2157
+ if (!this.translator.language) this.translator.changeLanguage(l);
2158
+ if (this.services.languageDetector && this.services.languageDetector.cacheUserLanguage) this.services.languageDetector.cacheUserLanguage(l);
2159
+ }
2160
+ this.loadResources(l, err => {
2161
+ done(err, l);
2162
+ });
2163
+ };
2164
+ if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
2165
+ setLng(this.services.languageDetector.detect());
2166
+ } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
2167
+ if (this.services.languageDetector.detect.length === 0) {
2168
+ this.services.languageDetector.detect().then(setLng);
2169
+ } else {
2170
+ this.services.languageDetector.detect(setLng);
2171
+ }
2172
+ } else {
2173
+ setLng(lng);
2174
+ }
2175
+ return deferred;
2176
+ }
2177
+ getFixedT(lng, ns, keyPrefix) {
2178
+ var _this3 = this;
2179
+ const fixedT = function (key, opts) {
2180
+ let options;
2181
+ if (typeof opts !== 'object') {
2182
+ for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
2183
+ rest[_key3 - 2] = arguments[_key3];
2184
+ }
2185
+ options = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2186
+ } else {
2187
+ options = {
2188
+ ...opts
2189
+ };
2190
+ }
2191
+ options.lng = options.lng || fixedT.lng;
2192
+ options.lngs = options.lngs || fixedT.lngs;
2193
+ options.ns = options.ns || fixedT.ns;
2194
+ if (options.keyPrefix !== '') options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
2195
+ const keySeparator = _this3.options.keySeparator || '.';
2196
+ let resultKey;
2197
+ if (options.keyPrefix && Array.isArray(key)) {
2198
+ resultKey = key.map(k => `${options.keyPrefix}${keySeparator}${k}`);
2199
+ } else {
2200
+ resultKey = options.keyPrefix ? `${options.keyPrefix}${keySeparator}${key}` : key;
2201
+ }
2202
+ return _this3.t(resultKey, options);
2203
+ };
2204
+ if (isString(lng)) {
2205
+ fixedT.lng = lng;
2206
+ } else {
2207
+ fixedT.lngs = lng;
2208
+ }
2209
+ fixedT.ns = ns;
2210
+ fixedT.keyPrefix = keyPrefix;
2211
+ return fixedT;
2212
+ }
2213
+ t() {
2214
+ return this.translator && this.translator.translate(...arguments);
2215
+ }
2216
+ exists() {
2217
+ return this.translator && this.translator.exists(...arguments);
2218
+ }
2219
+ setDefaultNamespace(ns) {
2220
+ this.options.defaultNS = ns;
2221
+ }
2222
+ hasLoadedNamespace(ns) {
2223
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2224
+ if (!this.isInitialized) {
2225
+ this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
2226
+ return false;
2227
+ }
2228
+ if (!this.languages || !this.languages.length) {
2229
+ this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
2230
+ return false;
2231
+ }
2232
+ const lng = options.lng || this.resolvedLanguage || this.languages[0];
2233
+ const fallbackLng = this.options ? this.options.fallbackLng : false;
2234
+ const lastLng = this.languages[this.languages.length - 1];
2235
+ if (lng.toLowerCase() === 'cimode') return true;
2236
+ const loadNotPending = (l, n) => {
2237
+ const loadState = this.services.backendConnector.state[`${l}|${n}`];
2238
+ return loadState === -1 || loadState === 0 || loadState === 2;
2239
+ };
2240
+ if (options.precheck) {
2241
+ const preResult = options.precheck(this, loadNotPending);
2242
+ if (preResult !== undefined) return preResult;
2243
+ }
2244
+ if (this.hasResourceBundle(lng, ns)) return true;
2245
+ if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
2246
+ if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
2247
+ return false;
2248
+ }
2249
+ loadNamespaces(ns, callback) {
2250
+ const deferred = defer();
2251
+ if (!this.options.ns) {
2252
+ if (callback) callback();
2253
+ return Promise.resolve();
2254
+ }
2255
+ if (isString(ns)) ns = [ns];
2256
+ ns.forEach(n => {
2257
+ if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
2258
+ });
2259
+ this.loadResources(err => {
2260
+ deferred.resolve();
2261
+ if (callback) callback(err);
2262
+ });
2263
+ return deferred;
2264
+ }
2265
+ loadLanguages(lngs, callback) {
2266
+ const deferred = defer();
2267
+ if (isString(lngs)) lngs = [lngs];
2268
+ const preloaded = this.options.preload || [];
2269
+ const newLngs = lngs.filter(lng => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
2270
+ if (!newLngs.length) {
2271
+ if (callback) callback();
2272
+ return Promise.resolve();
2273
+ }
2274
+ this.options.preload = preloaded.concat(newLngs);
2275
+ this.loadResources(err => {
2276
+ deferred.resolve();
2277
+ if (callback) callback(err);
2278
+ });
2279
+ return deferred;
2280
+ }
2281
+ dir(lng) {
2282
+ if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);
2283
+ if (!lng) return 'rtl';
2284
+ const rtlLngs = ['ar', 'shu', 'sqr', 'ssh', 'xaa', 'yhd', 'yud', 'aao', 'abh', 'abv', 'acm', 'acq', 'acw', 'acx', 'acy', 'adf', 'ads', 'aeb', 'aec', 'afb', 'ajp', 'apc', 'apd', 'arb', 'arq', 'ars', 'ary', 'arz', 'auz', 'avl', 'ayh', 'ayl', 'ayn', 'ayp', 'bbz', 'pga', 'he', 'iw', 'ps', 'pbt', 'pbu', 'pst', 'prp', 'prd', 'ug', 'ur', 'ydd', 'yds', 'yih', 'ji', 'yi', 'hbo', 'men', 'xmn', 'fa', 'jpr', 'peo', 'pes', 'prs', 'dv', 'sam', 'ckb'];
2285
+ const languageUtils = this.services && this.services.languageUtils || new LanguageUtil(get());
2286
+ return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
2287
+ }
2288
+ static createInstance() {
2289
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2290
+ let callback = arguments.length > 1 ? arguments[1] : undefined;
2291
+ return new I18n(options, callback);
2292
+ }
2293
+ cloneInstance() {
2294
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2295
+ let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
2296
+ const forkResourceStore = options.forkResourceStore;
2297
+ if (forkResourceStore) delete options.forkResourceStore;
2298
+ const mergedOptions = {
2299
+ ...this.options,
2300
+ ...options,
2301
+ ...{
2302
+ isClone: true
2303
+ }
2304
+ };
2305
+ const clone = new I18n(mergedOptions);
2306
+ if (options.debug !== undefined || options.prefix !== undefined) {
2307
+ clone.logger = clone.logger.clone(options);
2308
+ }
2309
+ const membersToCopy = ['store', 'services', 'language'];
2310
+ membersToCopy.forEach(m => {
2311
+ clone[m] = this[m];
2312
+ });
2313
+ clone.services = {
2314
+ ...this.services
2315
+ };
2316
+ clone.services.utils = {
2317
+ hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2318
+ };
2319
+ if (forkResourceStore) {
2320
+ clone.store = new ResourceStore(this.store.data, mergedOptions);
2321
+ clone.services.resourceStore = clone.store;
2322
+ }
2323
+ clone.translator = new Translator(clone.services, mergedOptions);
2324
+ clone.translator.on('*', function (event) {
2325
+ for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
2326
+ args[_key4 - 1] = arguments[_key4];
2327
+ }
2328
+ clone.emit(event, ...args);
2329
+ });
2330
+ clone.init(mergedOptions, callback);
2331
+ clone.translator.options = mergedOptions;
2332
+ clone.translator.backendConnector.services.utils = {
2333
+ hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2334
+ };
2335
+ return clone;
2336
+ }
2337
+ toJSON() {
2338
+ return {
2339
+ options: this.options,
2340
+ store: this.store,
2341
+ language: this.language,
2342
+ languages: this.languages,
2343
+ resolvedLanguage: this.resolvedLanguage
2344
+ };
2345
+ }
2346
+ }
2347
+ const instance = I18n.createInstance();
2348
+ instance.createInstance = I18n.createInstance;
2349
+
2350
+ const DEFAULT_LANG = "nl";
2351
+ function getComponentClosestLanguage(el) {
2352
+ let element = el;
2353
+ let closestElement = element.closest("[lang]");
2354
+ while (element && element.parentNode !== document && !closestElement) {
2355
+ element = element.parentNode instanceof ShadowRoot ? element.parentNode.host : element.parentElement;
2356
+ if (element !== null) {
2357
+ closestElement = element.closest("[lang]");
2358
+ }
2359
+ }
2360
+ return closestElement ? closestElement.lang : DEFAULT_LANG;
2361
+ }
2362
+ function i18n(getElement, resources) {
2363
+ const element = getElement();
2364
+ const i18NextInstance = instance.createInstance();
2365
+ i18NextInstance.init({
2366
+ lng: getComponentClosestLanguage(element),
2367
+ fallbackLng: DEFAULT_LANG,
2368
+ resources,
2369
+ defaultNS: element.tagName.toLowerCase(),
2370
+ });
2371
+ const detectedLanguage = false;
2372
+ return (key, variables) => {
2373
+ if (!detectedLanguage) {
2374
+ i18NextInstance.language = getComponentClosestLanguage(element);
2375
+ }
2376
+ return i18NextInstance.t(key, variables);
2377
+ };
2378
+ }
2379
+
2380
+ export { i18n as i };
2381
+
2382
+ //# sourceMappingURL=i18n.js.map