@coveo/atomic 3.28.0-pre.c758e56a2c → 3.28.0-pre.df6c8a3eb3

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 (745) hide show
  1. package/dist/atomic/_atomic.esm.js +1 -1
  2. package/dist/atomic/atomic.esm.js.map +1 -1
  3. package/dist/atomic/components/_index.d.ts +12 -0
  4. package/dist/atomic/components/_index.js +6 -0
  5. package/dist/atomic/components/analytics-config.js +2 -2938
  6. package/dist/atomic/components/analytics-config.js.map +1 -1
  7. package/dist/atomic/components/atomic-aria-live2.js +1 -1
  8. package/dist/atomic/components/atomic-category-facet.js +1 -1
  9. package/dist/atomic/components/atomic-citation.js +1 -1
  10. package/dist/atomic/components/atomic-commerce-category-facet2.js +1 -1
  11. package/dist/atomic/components/atomic-commerce-no-products.d.ts +11 -0
  12. package/dist/atomic/components/atomic-commerce-no-products.js +74 -0
  13. package/dist/atomic/components/atomic-commerce-no-products.js.map +1 -0
  14. package/dist/atomic/components/atomic-commerce-numeric-facet2.js +2 -2
  15. package/dist/atomic/components/atomic-commerce-query-error.js +1 -1
  16. package/dist/atomic/components/atomic-commerce-recommendation-interface.d.ts +11 -0
  17. package/dist/atomic/components/atomic-commerce-recommendation-interface.js +209 -0
  18. package/dist/atomic/components/atomic-commerce-recommendation-interface.js.map +1 -0
  19. package/dist/atomic/components/atomic-commerce-refine-modal.js +1 -215
  20. package/dist/atomic/components/atomic-commerce-refine-modal.js.map +1 -1
  21. package/dist/atomic/components/atomic-commerce-refine-modal2.js +219 -0
  22. package/dist/atomic/components/atomic-commerce-refine-modal2.js.map +1 -0
  23. package/dist/atomic/components/atomic-commerce-refine-toggle.d.ts +11 -0
  24. package/dist/atomic/{p-852ffdb4.entry.js → components/atomic-commerce-refine-toggle.js} +144 -2
  25. package/dist/atomic/components/atomic-commerce-refine-toggle.js.map +1 -0
  26. package/dist/atomic/components/atomic-commerce-text.d.ts +11 -0
  27. package/dist/atomic/components/atomic-commerce-text.js +8 -0
  28. package/dist/atomic/components/atomic-commerce-text.js.map +1 -0
  29. package/dist/atomic/components/atomic-commerce-text2.js +60 -0
  30. package/dist/atomic/components/atomic-commerce-text2.js.map +1 -0
  31. package/dist/atomic/components/atomic-commerce-timeframe-facet2.js +1 -1
  32. package/dist/atomic/components/atomic-facet-manager.js +1 -1
  33. package/dist/atomic/components/atomic-facet.js +1 -1
  34. package/dist/atomic/components/atomic-format-currency.js +1 -1
  35. package/dist/atomic/components/atomic-format-number.js +1 -1
  36. package/dist/atomic/components/atomic-format-unit.js +1 -1
  37. package/dist/atomic/components/atomic-generated-answer-feedback-modal.js +1 -1
  38. package/dist/atomic/components/atomic-html2.js +1 -1
  39. package/dist/atomic/components/atomic-insight-edit-toggle.js +1 -1
  40. package/dist/atomic/components/atomic-insight-facet.js +1 -1
  41. package/dist/atomic/components/atomic-insight-folded-result-list.js +1 -1
  42. package/dist/atomic/components/atomic-insight-full-search-button.js +1 -1
  43. package/dist/atomic/components/atomic-insight-history-toggle.js +1 -1
  44. package/dist/atomic/components/atomic-insight-interface.js +2 -9
  45. package/dist/atomic/components/atomic-insight-interface.js.map +1 -1
  46. package/dist/atomic/components/atomic-insight-no-results.js +1 -1
  47. package/dist/atomic/components/atomic-insight-numeric-facet.js +1 -1
  48. package/dist/atomic/components/atomic-insight-pager.js +3 -3
  49. package/dist/atomic/components/atomic-insight-query-error.js +1 -1
  50. package/dist/atomic/components/atomic-insight-refine-modal2.js +2 -2
  51. package/dist/atomic/components/atomic-insight-refine-toggle.js +1 -1
  52. package/dist/atomic/components/atomic-insight-result-attach-to-case-indicator.js +1 -1
  53. package/dist/atomic/components/atomic-insight-result-children.js +1 -1
  54. package/dist/atomic/components/atomic-insight-result-list.js +1 -1
  55. package/dist/atomic/components/atomic-insight-result-quickview-action.js +1 -1
  56. package/dist/atomic/components/atomic-insight-result2.js +1 -1
  57. package/dist/atomic/components/atomic-insight-search-box.js +2 -2
  58. package/dist/atomic/components/atomic-insight-smart-snippet-feedback-modal2.js +2 -2
  59. package/dist/atomic/components/atomic-insight-tabs.js +1 -1
  60. package/dist/atomic/components/atomic-insight-user-actions-session2.js +1 -1
  61. package/dist/atomic/components/atomic-insight-user-actions-toggle.js +1 -1
  62. package/dist/atomic/components/atomic-ipx-body2.js +2 -2
  63. package/dist/atomic/components/atomic-ipx-button.js +2 -2
  64. package/dist/atomic/components/atomic-ipx-embedded.js +1 -1
  65. package/dist/atomic/components/atomic-ipx-modal.js +2 -2
  66. package/dist/atomic/components/atomic-ipx-recs-list.js +1 -1
  67. package/dist/atomic/components/atomic-ipx-refine-modal2.js +1 -1
  68. package/dist/atomic/components/atomic-ipx-refine-toggle.js +1 -1
  69. package/dist/atomic/components/atomic-ipx-result-link.js +1 -1
  70. package/dist/atomic/components/atomic-ipx-tabs.js +1 -1
  71. package/dist/atomic/components/atomic-layout-section.d.ts +11 -0
  72. package/dist/atomic/components/atomic-layout-section.js +35 -0
  73. package/dist/atomic/components/atomic-layout-section.js.map +1 -0
  74. package/dist/atomic/components/atomic-load-more-results.js +1 -1
  75. package/dist/atomic/components/atomic-modal2.js +2 -2
  76. package/dist/atomic/components/atomic-no-results.js +2 -14
  77. package/dist/atomic/components/atomic-no-results.js.map +1 -1
  78. package/dist/atomic/components/atomic-numeric-facet.js +1 -1
  79. package/dist/atomic/components/atomic-pager.js +3 -3
  80. package/dist/atomic/components/atomic-product-children.js +7 -1
  81. package/dist/atomic/components/atomic-product-children.js.map +1 -1
  82. package/dist/atomic/components/atomic-product-description.js +13 -1
  83. package/dist/atomic/components/atomic-product-description.js.map +1 -1
  84. package/dist/atomic/components/atomic-product-excerpt.js +13 -1
  85. package/dist/atomic/components/atomic-product-excerpt.js.map +1 -1
  86. package/dist/atomic/components/atomic-product-link.js +13 -1
  87. package/dist/atomic/components/atomic-product-link.js.map +1 -1
  88. package/dist/atomic/components/atomic-product-price.js +1 -1
  89. package/dist/atomic/components/atomic-product-text.d.ts +11 -0
  90. package/dist/atomic/components/atomic-product-text.js +8 -0
  91. package/dist/atomic/components/atomic-product-text.js.map +1 -0
  92. package/dist/atomic/components/atomic-product-text2.js +83 -0
  93. package/dist/atomic/components/atomic-product-text2.js.map +1 -0
  94. package/dist/atomic/components/atomic-query-error.js +1 -1
  95. package/dist/atomic/components/atomic-query-summary.js +1 -1
  96. package/dist/atomic/components/atomic-quickview-modal2.js +1 -1
  97. package/dist/atomic/components/atomic-quickview.js +1 -1
  98. package/dist/atomic/components/atomic-recs-error.js +1 -1
  99. package/dist/atomic/components/atomic-recs-interface.js +2 -1
  100. package/dist/atomic/components/atomic-recs-interface.js.map +1 -1
  101. package/dist/atomic/components/atomic-recs-list.js +1 -1
  102. package/dist/atomic/components/atomic-refine-modal2.js +1 -1
  103. package/dist/atomic/components/atomic-refine-toggle.js +3 -20
  104. package/dist/atomic/components/atomic-refine-toggle.js.map +1 -1
  105. package/dist/atomic/components/atomic-relevance-inspector2.js +2 -2
  106. package/dist/atomic/components/atomic-result-children.js +1 -1
  107. package/dist/atomic/components/atomic-result-fields-list.js +1 -1
  108. package/dist/atomic/components/atomic-result-link.js +1 -1
  109. package/dist/atomic/components/atomic-result-list.js +1 -1
  110. package/dist/atomic/components/atomic-result-placeholder2.js +2 -2
  111. package/dist/atomic/components/atomic-result-table-placeholder2.js +1 -1
  112. package/dist/atomic/components/atomic-result-text2.js +2 -45
  113. package/dist/atomic/components/atomic-result-text2.js.map +1 -1
  114. package/dist/atomic/components/atomic-results-per-page.js +1 -1
  115. package/dist/atomic/components/atomic-search-box-query-suggestions2.js +1 -1
  116. package/dist/atomic/components/atomic-search-box-recent-queries2.js +1 -1
  117. package/dist/atomic/components/atomic-search-box.js +5 -4
  118. package/dist/atomic/components/atomic-search-box.js.map +1 -1
  119. package/dist/atomic/components/atomic-search-interface.js +2 -1
  120. package/dist/atomic/components/atomic-search-interface.js.map +1 -1
  121. package/dist/atomic/components/atomic-smart-snippet-answer2.js +1 -1
  122. package/dist/atomic/components/atomic-smart-snippet-collapse-wrapper2.js +2 -2
  123. package/dist/atomic/components/atomic-smart-snippet-expandable-answer2.js +1 -1
  124. package/dist/atomic/components/atomic-smart-snippet-feedback-modal2.js +2 -2
  125. package/dist/atomic/components/atomic-smart-snippet-source2.js +1 -1
  126. package/dist/atomic/components/atomic-sort-dropdown.js +2 -2
  127. package/dist/atomic/components/atomic-sort-expression.js +1 -1
  128. package/dist/atomic/components/atomic-suggestion-renderer2.js +1 -1
  129. package/dist/atomic/components/atomic-tab-manager.js +1 -1
  130. package/dist/atomic/components/components/commerce/atomic-commerce-layout/atomic-commerce-layout.js +1 -1
  131. package/dist/atomic/components/components/commerce/atomic-commerce-products-per-page/atomic-commerce-products-per-page.js +1 -1
  132. package/dist/atomic/components/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.js +1 -0
  133. package/dist/atomic/components/components/commerce/atomic-product-template/atomic-product-template.js +1 -4
  134. package/dist/atomic/components/components/commerce/index.js +0 -5
  135. package/dist/atomic/components/components/commerce/lazy-index.js +0 -5
  136. package/dist/atomic/components/components/common/index.js +0 -1
  137. package/dist/atomic/components/components/common/interface/interface-common.js +9 -8
  138. package/dist/atomic/components/components/common/lazy-index.js +0 -1
  139. package/dist/atomic/components/components/insight/atomic-insight-interface/store.js +0 -8
  140. package/dist/atomic/components/facet-date-input.js +3 -3
  141. package/dist/atomic/components/facet-number-input.js +2 -2
  142. package/dist/atomic/components/global/environment.js +1 -1
  143. package/dist/atomic/components/index.js.map +1 -1
  144. package/dist/atomic/components/interface-common-stencil.js +2941 -0
  145. package/dist/atomic/components/interface-common-stencil.js.map +1 -0
  146. package/dist/atomic/components/product-utils.js +8 -1
  147. package/dist/atomic/components/product-utils.js.map +1 -1
  148. package/dist/atomic/components/sections.js.map +1 -1
  149. package/dist/atomic/components/stencil-guard.js +23 -0
  150. package/dist/atomic/components/stencil-guard.js.map +1 -0
  151. package/dist/atomic/components/stencil-item-text-highlighted.js +49 -0
  152. package/dist/atomic/components/stencil-item-text-highlighted.js.map +1 -0
  153. package/dist/atomic/components/tab-button.js +1 -1
  154. package/dist/atomic/components/tab-popover.js +1 -1
  155. package/dist/atomic/components/{components/common/no-items/utils.js → utils2.js} +5 -1
  156. package/dist/atomic/components/utils2.js.map +1 -0
  157. package/dist/atomic/{p-f5cea23f.entry.js → p-0267a585.entry.js} +2 -2
  158. package/dist/atomic/p-0a7b0daa.entry.js +2 -0
  159. package/dist/atomic/{p-55b4fb2b.entry.js.map → p-0a7b0daa.entry.js.map} +1 -1
  160. package/dist/atomic/{p-dcded8cb.entry.js → p-0b0ea7d3.entry.js} +2 -2
  161. package/dist/atomic/{p-1326166a.entry.js → p-135be5aa.entry.js} +2 -2
  162. package/dist/atomic/p-1cb2280d.js +2 -0
  163. package/dist/atomic/p-1cb2280d.js.map +1 -0
  164. package/dist/atomic/{p-f3e9a9f8.entry.js → p-1cc97adc.entry.js} +2 -2
  165. package/dist/atomic/{p-ea5d2736.entry.js → p-22a0d1b9.entry.js} +2 -2
  166. package/dist/atomic/{p-d88aec96.entry.js → p-29d27418.entry.js} +2 -2
  167. package/dist/atomic/{p-90e88505.entry.js → p-2f0cb73c.entry.js} +2 -2
  168. package/dist/atomic/p-2ff906b9.entry.js +2 -0
  169. package/dist/atomic/p-2ff906b9.entry.js.map +1 -0
  170. package/dist/atomic/{p-fb060cc0.entry.js → p-306c83ea.entry.js} +2 -2
  171. package/dist/atomic/{p-b15ca291.entry.js → p-3195fa42.entry.js} +2 -2
  172. package/dist/atomic/{p-714c5c2c.entry.js → p-32b26cd0.entry.js} +2 -2
  173. package/dist/atomic/{p-1c72983f.entry.js → p-32c90fe9.entry.js} +2 -2
  174. package/dist/atomic/p-39223a2a.entry.js +2 -0
  175. package/dist/atomic/p-39223a2a.entry.js.map +1 -0
  176. package/dist/atomic/p-39447826.entry.js +2 -0
  177. package/dist/atomic/{p-fafea879.entry.js.map → p-39447826.entry.js.map} +1 -1
  178. package/dist/atomic/p-3cc601ad.entry.js +2 -0
  179. package/dist/atomic/p-3cc601ad.entry.js.map +1 -0
  180. package/dist/atomic/{p-4e2ec64c.entry.js → p-3ec18de9.entry.js} +2 -2
  181. package/dist/atomic/{p-a010dddb.entry.js → p-3f42a2db.entry.js} +2 -2
  182. package/dist/atomic/{p-4495b132.entry.js → p-45b26cc7.entry.js} +2 -2
  183. package/dist/atomic/p-46522ee4.entry.js +2 -0
  184. package/dist/atomic/{p-50ff35f8.entry.js.map → p-46522ee4.entry.js.map} +1 -1
  185. package/dist/atomic/{p-ffb15631.entry.js → p-47ee9d37.entry.js} +2 -2
  186. package/dist/atomic/p-4e57cee1.entry.js +2 -0
  187. package/dist/atomic/{p-1429fbdb.entry.js.map → p-4e57cee1.entry.js.map} +1 -1
  188. package/dist/atomic/{p-aa4fc96f.entry.js → p-50b9a5d2.entry.js} +2 -2
  189. package/dist/atomic/{p-e25287fd.entry.js → p-51c5acfc.entry.js} +2 -2
  190. package/dist/atomic/{p-f72a0133.entry.js → p-543e811e.entry.js} +2 -2
  191. package/dist/atomic/p-57f53200.entry.js +2 -0
  192. package/dist/atomic/{p-e4f872fb.entry.js.map → p-57f53200.entry.js.map} +1 -1
  193. package/dist/atomic/{p-0df077b7.entry.js → p-59017e0a.entry.js} +2 -2
  194. package/dist/atomic/p-59017e0a.entry.js.map +1 -0
  195. package/dist/atomic/p-5cf5bb98.entry.js +2 -0
  196. package/dist/atomic/p-5e73a3e8.js +2 -0
  197. package/dist/atomic/p-5e73a3e8.js.map +1 -0
  198. package/dist/atomic/{p-2866ca4d.entry.js → p-60a9e718.entry.js} +2 -2
  199. package/dist/atomic/{p-eabb4eae.entry.js → p-66683abd.entry.js} +2 -2
  200. package/dist/atomic/{p-8b579505.entry.js → p-67315415.entry.js} +2 -2
  201. package/dist/atomic/p-67afec23.js +2 -0
  202. package/dist/atomic/p-67afec23.js.map +1 -0
  203. package/dist/atomic/p-67ef14ac.entry.js +2 -0
  204. package/dist/atomic/p-67ef14ac.entry.js.map +1 -0
  205. package/dist/atomic/{p-714ee3bb.entry.js → p-689e063d.entry.js} +2 -2
  206. package/dist/atomic/{p-f5686c7e.entry.js → p-690b5853.entry.js} +2 -2
  207. package/dist/atomic/{p-ace45b24.entry.js → p-70ab347b.entry.js} +2 -2
  208. package/dist/atomic/p-733252f1.entry.js +2 -0
  209. package/dist/atomic/p-733252f1.entry.js.map +1 -0
  210. package/dist/atomic/{p-966509f8.entry.js → p-76122df5.entry.js} +2 -2
  211. package/dist/atomic/{p-9ec72c3b.entry.js → p-7d1f8d9c.entry.js} +2 -2
  212. package/dist/atomic/{p-f5323d5b.js → p-7ed31f46.js} +2 -2
  213. package/dist/atomic/p-7ed31f46.js.map +1 -0
  214. package/dist/atomic/{p-d37bb72b.entry.js → p-80dc3bab.entry.js} +2 -2
  215. package/dist/atomic/p-8392e900.entry.js +2 -0
  216. package/dist/atomic/p-8392e900.entry.js.map +1 -0
  217. package/dist/atomic/{p-6e11d4c6.entry.js → p-8d7f57d9.entry.js} +2 -2
  218. package/dist/atomic/{p-7d63f0e6.entry.js → p-8e09f796.entry.js} +2 -2
  219. package/dist/atomic/{p-a84d94cb.entry.js → p-95942ba2.entry.js} +2 -2
  220. package/dist/atomic/{p-21d55afc.entry.js → p-99604083.entry.js} +2 -2
  221. package/dist/atomic/{p-d4ec6961.entry.js → p-9a08dad7.entry.js} +2 -2
  222. package/dist/atomic/{p-03fa8481.entry.js → p-9ae88402.entry.js} +2 -2
  223. package/dist/atomic/p-9c7dbbdf.js.map +1 -1
  224. package/dist/atomic/{p-01c109cf.entry.js → p-9d2230db.entry.js} +2 -2
  225. package/dist/atomic/{p-fac32d34.entry.js → p-9eb108c9.entry.js} +2 -2
  226. package/dist/atomic/p-a046cf06.entry.js +2 -0
  227. package/dist/atomic/p-a046cf06.entry.js.map +1 -0
  228. package/dist/atomic/{p-5a3cd055.entry.js → p-a3169f59.entry.js} +2 -2
  229. package/dist/atomic/{p-50ff35f8.entry.js → p-a772b365.entry.js} +2 -2
  230. package/dist/atomic/{p-56d6d329.entry.js.map → p-a772b365.entry.js.map} +1 -1
  231. package/dist/atomic/{p-c6f15059.entry.js → p-a8281e9b.entry.js} +2 -2
  232. package/dist/atomic/{p-4f03327d.entry.js → p-ab5eec3d.entry.js} +2 -2
  233. package/dist/atomic/{p-1aedbfbf.entry.js → p-b19a8cbb.entry.js} +2 -2
  234. package/dist/atomic/p-b1a7d837.js +2 -0
  235. package/dist/atomic/p-b1a7d837.js.map +1 -0
  236. package/dist/atomic/{p-61f79055.entry.js → p-b4d47ca9.entry.js} +2 -2
  237. package/dist/atomic/{p-1e3f156e.entry.js → p-b4dfe5b2.entry.js} +2 -2
  238. package/dist/atomic/p-b747e4a9.entry.js +2 -0
  239. package/dist/atomic/{p-e4cc2a37.entry.js → p-b7824e0e.entry.js} +2 -2
  240. package/dist/atomic/p-bb081d4e.js +2 -0
  241. package/dist/atomic/p-bb081d4e.js.map +1 -0
  242. package/dist/atomic/p-bd0aa08f.entry.js +2 -0
  243. package/dist/atomic/{p-022784c5.entry.js.map → p-bd0aa08f.entry.js.map} +1 -1
  244. package/dist/atomic/{p-3632e456.entry.js → p-be13ed5c.entry.js} +2 -2
  245. package/dist/atomic/p-befca41f.entry.js +2 -0
  246. package/dist/atomic/p-befca41f.entry.js.map +1 -0
  247. package/dist/atomic/{p-2871034a.entry.js → p-bfeefcaa.entry.js} +2 -2
  248. package/dist/atomic/p-c0b3720d.entry.js +2 -0
  249. package/dist/atomic/p-c0b3720d.entry.js.map +1 -0
  250. package/dist/atomic/{p-b4b6f859.entry.js → p-c0d7b26d.entry.js} +2 -2
  251. package/dist/atomic/{p-9ef7ffc0.entry.js → p-c13d4039.entry.js} +2 -2
  252. package/dist/atomic/{p-4505f2e0.entry.js → p-c4f042ae.entry.js} +2 -2
  253. package/dist/atomic/p-c83f9cff.entry.js +2 -0
  254. package/dist/atomic/p-c83f9cff.entry.js.map +1 -0
  255. package/dist/atomic/p-cd725265.js +2 -0
  256. package/dist/atomic/{p-7d1c2ecd.js.map → p-cd725265.js.map} +1 -1
  257. package/dist/atomic/{p-faee1f57.entry.js → p-cd87574b.entry.js} +2 -2
  258. package/dist/atomic/{p-0875a7fb.entry.js → p-ce4e939b.entry.js} +2 -2
  259. package/dist/atomic/{p-1fbbed3e.entry.js → p-d1efd50f.entry.js} +2 -2
  260. package/dist/atomic/{p-7d773b22.entry.js → p-d30057a0.entry.js} +2 -2
  261. package/dist/atomic/{p-e7d5c4be.entry.js → p-d4aba9f9.entry.js} +2 -2
  262. package/dist/atomic/{p-ce1f6392.entry.js → p-d69756ae.entry.js} +2 -2
  263. package/dist/atomic/{p-08d1db60.entry.js → p-d827c148.entry.js} +2 -2
  264. package/dist/atomic/p-da578608.entry.js +2 -0
  265. package/dist/atomic/{p-852ffdb4.entry.js.map → p-da578608.entry.js.map} +1 -1
  266. package/dist/atomic/{p-d04ad3e5.entry.js → p-dd8c6bdd.entry.js} +2 -2
  267. package/dist/atomic/{p-886da915.entry.js → p-ddd52850.entry.js} +2 -2
  268. package/dist/atomic/{p-fecd79de.entry.js → p-e44155cc.entry.js} +2 -2
  269. package/dist/atomic/{p-7f5485ad.entry.js → p-e46517e9.entry.js} +2 -2
  270. package/dist/atomic/{p-8074a49d.entry.js.map → p-e46517e9.entry.js.map} +1 -1
  271. package/dist/atomic/{p-c074198a.entry.js → p-e4754fd0.entry.js} +2 -2
  272. package/dist/atomic/{p-55b4fb2b.entry.js → p-e604fd29.entry.js} +2 -2
  273. package/dist/atomic/{p-27054c71.entry.js.map → p-e604fd29.entry.js.map} +1 -1
  274. package/dist/atomic/p-eab28672.entry.js +2 -0
  275. package/dist/atomic/p-eab28672.entry.js.map +1 -0
  276. package/dist/atomic/{p-db5285b1.entry.js → p-ec0161b7.entry.js} +2 -2
  277. package/dist/atomic/p-ec03a238.entry.js +2 -0
  278. package/dist/atomic/{p-7f5485ad.entry.js.map → p-ec03a238.entry.js.map} +1 -1
  279. package/dist/atomic/{p-eea2128f.entry.js → p-ec6bc15b.entry.js} +2 -2
  280. package/dist/atomic/{p-e37f01fc.entry.js → p-eebb168b.entry.js} +2 -2
  281. package/dist/atomic/p-f4a1bfe3.entry.js +2 -0
  282. package/dist/atomic/p-f4a1bfe3.entry.js.map +1 -0
  283. package/dist/atomic/{p-870dbeef.entry.js → p-f4b98113.entry.js} +2 -2
  284. package/dist/atomic/p-f6283657.entry.js +2 -0
  285. package/dist/atomic/{p-0df077b7.entry.js.map → p-f6283657.entry.js.map} +1 -1
  286. package/dist/atomic/p-f68cee5d.entry.js +2 -0
  287. package/dist/atomic/{p-b90e5ea5.entry.js.map → p-f68cee5d.entry.js.map} +1 -1
  288. package/dist/atomic/{p-58268151.entry.js → p-f7f8096a.entry.js} +2 -2
  289. package/dist/atomic/{p-58268151.entry.js.map → p-f7f8096a.entry.js.map} +1 -1
  290. package/dist/atomic/{p-e988f378.js → p-f7f81710.js} +2 -2
  291. package/dist/atomic/{p-8403335e.entry.js → p-fb0bdcdb.entry.js} +2 -2
  292. package/dist/atomic/p-fb3e07e9.js +2 -0
  293. package/dist/atomic/p-fb3e07e9.js.map +1 -0
  294. package/dist/atomic/p-fbbbc454.entry.js +2 -0
  295. package/dist/atomic/{p-ebb35a4b.entry.js → p-fd9d1c3f.entry.js} +2 -2
  296. package/dist/cjs/_loader.cjs.js +1 -1
  297. package/dist/cjs/analytics-config-f82932e2.js +49 -0
  298. package/dist/cjs/analytics-config-f82932e2.js.map +1 -0
  299. package/dist/cjs/atomic-aria-live.cjs.entry.js +75 -0
  300. package/dist/cjs/atomic-aria-live.cjs.entry.js.map +1 -0
  301. package/dist/cjs/atomic-automatic-facet_2.cjs.entry.js +3 -4
  302. package/dist/cjs/atomic-automatic-facet_2.cjs.entry.js.map +1 -1
  303. package/dist/cjs/atomic-category-facet.cjs.entry.js +3 -4
  304. package/dist/cjs/atomic-category-facet.cjs.entry.js.map +1 -1
  305. package/dist/cjs/atomic-citation.cjs.entry.js +1 -1
  306. package/dist/cjs/atomic-color-facet.cjs.entry.js +3 -4
  307. package/dist/cjs/atomic-color-facet.cjs.entry.js.map +1 -1
  308. package/dist/cjs/{atomic-commerce-category-facet_6.cjs.entry.js → atomic-commerce-category-facet_5.cjs.entry.js} +109 -141
  309. package/dist/cjs/atomic-commerce-category-facet_5.cjs.entry.js.map +1 -0
  310. package/dist/cjs/atomic-commerce-facet-number-input_2.cjs.entry.js +149 -0
  311. package/dist/cjs/atomic-commerce-facet-number-input_2.cjs.entry.js.map +1 -0
  312. package/dist/cjs/atomic-commerce-no-products.cjs.entry.js +65 -0
  313. package/dist/cjs/atomic-commerce-no-products.cjs.entry.js.map +1 -0
  314. package/dist/cjs/atomic-commerce-query-error.cjs.entry.js +1 -1
  315. package/dist/cjs/atomic-commerce-recommendation-interface.cjs.entry.js +179 -0
  316. package/dist/cjs/atomic-commerce-recommendation-interface.cjs.entry.js.map +1 -0
  317. package/dist/cjs/atomic-commerce-refine-modal.cjs.entry.js +1 -1
  318. package/dist/cjs/atomic-commerce-refine-toggle.cjs.entry.js +74 -0
  319. package/dist/cjs/atomic-commerce-refine-toggle.cjs.entry.js.map +1 -0
  320. package/dist/cjs/atomic-commerce-text_2.cjs.entry.js +106 -0
  321. package/dist/cjs/atomic-commerce-text_2.cjs.entry.js.map +1 -0
  322. package/dist/cjs/atomic-facet-manager.cjs.entry.js +1 -1
  323. package/dist/cjs/atomic-facet-number-input.cjs.entry.js +2 -2
  324. package/dist/cjs/atomic-facet.cjs.entry.js +2 -3
  325. package/dist/cjs/atomic-facet.cjs.entry.js.map +1 -1
  326. package/dist/cjs/atomic-focus-trap_2.cjs.entry.js +2 -2
  327. package/dist/cjs/atomic-format-currency.cjs.entry.js +1 -1
  328. package/dist/cjs/atomic-format-number.cjs.entry.js +1 -1
  329. package/dist/cjs/atomic-format-unit.cjs.entry.js +1 -1
  330. package/dist/cjs/atomic-generated-answer-feedback-modal.cjs.entry.js +1 -1
  331. package/dist/cjs/atomic-html.cjs.entry.js +1 -1
  332. package/dist/cjs/atomic-insight-edit-toggle.cjs.entry.js +1 -1
  333. package/dist/cjs/atomic-insight-facet.cjs.entry.js +2 -3
  334. package/dist/cjs/atomic-insight-facet.cjs.entry.js.map +1 -1
  335. package/dist/cjs/atomic-insight-folded-result-list.cjs.entry.js +1 -1
  336. package/dist/cjs/atomic-insight-full-search-button.cjs.entry.js +1 -1
  337. package/dist/cjs/atomic-insight-history-toggle.cjs.entry.js +1 -1
  338. package/dist/cjs/atomic-insight-interface.cjs.entry.js +5 -12
  339. package/dist/cjs/atomic-insight-interface.cjs.entry.js.map +1 -1
  340. package/dist/cjs/atomic-insight-no-results.cjs.entry.js +1 -1
  341. package/dist/cjs/atomic-insight-numeric-facet.cjs.entry.js +2 -3
  342. package/dist/cjs/atomic-insight-numeric-facet.cjs.entry.js.map +1 -1
  343. package/dist/cjs/atomic-insight-pager.cjs.entry.js +3 -3
  344. package/dist/cjs/atomic-insight-query-error.cjs.entry.js +1 -1
  345. package/dist/cjs/atomic-insight-refine-modal.cjs.entry.js +2 -2
  346. package/dist/cjs/atomic-insight-refine-toggle.cjs.entry.js +1 -1
  347. package/dist/cjs/atomic-insight-result-attach-to-case-indicator.cjs.entry.js +1 -1
  348. package/dist/cjs/atomic-insight-result-children.cjs.entry.js +1 -1
  349. package/dist/cjs/atomic-insight-result-list.cjs.entry.js +1 -1
  350. package/dist/cjs/atomic-insight-result-quickview-action.cjs.entry.js +1 -1
  351. package/dist/cjs/atomic-insight-result.cjs.entry.js +1 -1
  352. package/dist/cjs/atomic-insight-search-box.cjs.entry.js +2 -2
  353. package/dist/cjs/atomic-insight-smart-snippet-feedback-modal.cjs.entry.js +2 -2
  354. package/dist/cjs/atomic-insight-tabs.cjs.entry.js +1 -1
  355. package/dist/cjs/atomic-insight-timeframe-facet.cjs.entry.js +5 -6
  356. package/dist/cjs/atomic-insight-timeframe-facet.cjs.entry.js.map +1 -1
  357. package/dist/cjs/atomic-insight-user-actions-session_2.cjs.entry.js +1 -1
  358. package/dist/cjs/atomic-insight-user-actions-toggle.cjs.entry.js +1 -1
  359. package/dist/cjs/atomic-ipx-body.cjs.entry.js +2 -2
  360. package/dist/cjs/atomic-ipx-button.cjs.entry.js +2 -2
  361. package/dist/cjs/atomic-ipx-embedded.cjs.entry.js +1 -1
  362. package/dist/cjs/atomic-ipx-modal.cjs.entry.js +2 -2
  363. package/dist/cjs/atomic-ipx-recs-list.cjs.entry.js +1 -1
  364. package/dist/cjs/atomic-ipx-refine-modal.cjs.entry.js +1 -1
  365. package/dist/cjs/atomic-ipx-refine-toggle.cjs.entry.js +1 -1
  366. package/dist/cjs/atomic-ipx-result-link.cjs.entry.js +1 -1
  367. package/dist/cjs/atomic-ipx-tabs.cjs.entry.js +1 -1
  368. package/dist/cjs/atomic-layout-section.cjs.entry.js +18 -0
  369. package/dist/cjs/atomic-layout-section.cjs.entry.js.map +1 -0
  370. package/dist/cjs/atomic-load-more-results.cjs.entry.js +1 -1
  371. package/dist/cjs/atomic-no-results.cjs.entry.js +3 -15
  372. package/dist/cjs/atomic-no-results.cjs.entry.js.map +1 -1
  373. package/dist/cjs/atomic-numeric-facet.cjs.entry.js +2 -3
  374. package/dist/cjs/atomic-numeric-facet.cjs.entry.js.map +1 -1
  375. package/dist/cjs/atomic-pager.cjs.entry.js +3 -3
  376. package/dist/cjs/atomic-product-link.cjs.entry.js +1 -1
  377. package/dist/cjs/atomic-product-numeric-field-value.cjs.entry.js +1 -1
  378. package/dist/cjs/atomic-product-price.cjs.entry.js +2 -2
  379. package/dist/cjs/atomic-query-error.cjs.entry.js +1 -1
  380. package/dist/cjs/atomic-query-summary.cjs.entry.js +1 -1
  381. package/dist/cjs/atomic-quickview-modal.cjs.entry.js +1 -1
  382. package/dist/cjs/atomic-quickview.cjs.entry.js +1 -1
  383. package/dist/cjs/atomic-rating-facet.cjs.entry.js +3 -4
  384. package/dist/cjs/atomic-rating-facet.cjs.entry.js.map +1 -1
  385. package/dist/cjs/atomic-rating-range-facet.cjs.entry.js +3 -4
  386. package/dist/cjs/atomic-rating-range-facet.cjs.entry.js.map +1 -1
  387. package/dist/cjs/atomic-recs-error.cjs.entry.js +1 -1
  388. package/dist/cjs/atomic-recs-interface.cjs.entry.js +7 -6
  389. package/dist/cjs/atomic-recs-interface.cjs.entry.js.map +1 -1
  390. package/dist/cjs/atomic-recs-list.cjs.entry.js +1 -1
  391. package/dist/cjs/atomic-refine-modal.cjs.entry.js +1 -1
  392. package/dist/cjs/atomic-refine-toggle.cjs.entry.js +3 -19
  393. package/dist/cjs/atomic-refine-toggle.cjs.entry.js.map +1 -1
  394. package/dist/cjs/{atomic-aria-live_2.cjs.entry.js → atomic-relevance-inspector.cjs.entry.js} +3 -70
  395. package/dist/cjs/atomic-relevance-inspector.cjs.entry.js.map +1 -0
  396. package/dist/cjs/atomic-result-children.cjs.entry.js +1 -1
  397. package/dist/cjs/atomic-result-fields-list.cjs.entry.js +1 -1
  398. package/dist/cjs/atomic-result-link.cjs.entry.js +1 -1
  399. package/dist/cjs/atomic-result-list.cjs.entry.js +1 -1
  400. package/dist/cjs/atomic-result-placeholder_8.cjs.entry.js +3 -3
  401. package/dist/cjs/atomic-result-text_2.cjs.entry.js +4 -46
  402. package/dist/cjs/atomic-result-text_2.cjs.entry.js.map +1 -1
  403. package/dist/cjs/atomic-results-per-page.cjs.entry.js +1 -1
  404. package/dist/cjs/atomic-search-box-query-suggestions_2.cjs.entry.js +2 -2
  405. package/dist/cjs/atomic-search-box.cjs.entry.js +5 -4
  406. package/dist/cjs/atomic-search-box.cjs.entry.js.map +1 -1
  407. package/dist/cjs/atomic-search-interface.cjs.entry.js +6 -5
  408. package/dist/cjs/atomic-search-interface.cjs.entry.js.map +1 -1
  409. package/dist/cjs/atomic-smart-snippet-answer_2.cjs.entry.js +2 -2
  410. package/dist/cjs/atomic-smart-snippet-collapse-wrapper_2.cjs.entry.js +3 -3
  411. package/dist/cjs/atomic-smart-snippet-feedback-modal.cjs.entry.js +2 -2
  412. package/dist/cjs/atomic-sort-dropdown.cjs.entry.js +2 -2
  413. package/dist/cjs/atomic-sort-expression.cjs.entry.js +1 -1
  414. package/dist/cjs/atomic-suggestion-renderer.cjs.entry.js +1 -1
  415. package/dist/cjs/atomic-tab-bar_2.cjs.entry.js +1 -1
  416. package/dist/cjs/atomic-tab-button.cjs.entry.js +1 -1
  417. package/dist/cjs/atomic-tab-manager.cjs.entry.js +1 -1
  418. package/dist/cjs/atomic-timeframe-facet.cjs.entry.js +5 -6
  419. package/dist/cjs/atomic-timeframe-facet.cjs.entry.js.map +1 -1
  420. package/dist/cjs/atomic.cjs.js +1 -1
  421. package/dist/cjs/{stencil-facet-header-a3dd9de0.js → facet-placeholder-ad0407f0.js} +12 -1
  422. package/dist/cjs/facet-placeholder-ad0407f0.js.map +1 -0
  423. package/dist/cjs/index-757bc886.js +34 -10
  424. package/dist/cjs/{analytics-config-d3622a33.js → interface-common-stencil-98f073f6.js} +4 -46
  425. package/dist/cjs/interface-common-stencil-98f073f6.js.map +1 -0
  426. package/dist/cjs/{product-utils-f6c780e3.js → product-utils-9507462c.js} +9 -1
  427. package/dist/cjs/product-utils-9507462c.js.map +1 -0
  428. package/dist/cjs/sections-4b4af2f8.js.map +1 -1
  429. package/dist/cjs/stencil-guard-caf49888.js +26 -0
  430. package/dist/cjs/stencil-guard-caf49888.js.map +1 -0
  431. package/dist/cjs/stencil-item-text-highlighted-91fd0fe8.js +52 -0
  432. package/dist/cjs/stencil-item-text-highlighted-91fd0fe8.js.map +1 -0
  433. package/dist/cjs/{timeframe-facet-common-d9078836.js → timeframe-facet-common-c555d20d.js} +4 -5
  434. package/dist/cjs/timeframe-facet-common-c555d20d.js.map +1 -0
  435. package/dist/cjs/utils-ca9c9aed.js +18 -0
  436. package/dist/cjs/utils-ca9c9aed.js.map +1 -0
  437. package/dist/cjs/version.cjs.js +2 -2
  438. package/dist/esm/_loader.js +1 -1
  439. package/dist/esm/analytics-config-253004a0.js +43 -0
  440. package/dist/esm/analytics-config-253004a0.js.map +1 -0
  441. package/dist/esm/atomic-aria-live.entry.js +71 -0
  442. package/dist/esm/atomic-aria-live.entry.js.map +1 -0
  443. package/dist/esm/atomic-automatic-facet_2.entry.js +1 -2
  444. package/dist/esm/atomic-automatic-facet_2.entry.js.map +1 -1
  445. package/dist/esm/atomic-category-facet.entry.js +2 -3
  446. package/dist/esm/atomic-category-facet.entry.js.map +1 -1
  447. package/dist/esm/atomic-citation.entry.js +1 -1
  448. package/dist/esm/atomic-color-facet.entry.js +1 -2
  449. package/dist/esm/atomic-color-facet.entry.js.map +1 -1
  450. package/dist/esm/{atomic-commerce-category-facet_6.entry.js → atomic-commerce-category-facet_5.entry.js} +109 -140
  451. package/dist/esm/atomic-commerce-category-facet_5.entry.js.map +1 -0
  452. package/dist/esm/atomic-commerce-facet-number-input_2.entry.js +144 -0
  453. package/dist/esm/atomic-commerce-facet-number-input_2.entry.js.map +1 -0
  454. package/dist/esm/atomic-commerce-no-products.entry.js +61 -0
  455. package/dist/esm/atomic-commerce-no-products.entry.js.map +1 -0
  456. package/dist/esm/atomic-commerce-query-error.entry.js +1 -1
  457. package/dist/esm/atomic-commerce-recommendation-interface.entry.js +175 -0
  458. package/dist/esm/atomic-commerce-recommendation-interface.entry.js.map +1 -0
  459. package/dist/esm/atomic-commerce-refine-modal.entry.js +1 -1
  460. package/dist/esm/atomic-commerce-refine-toggle.entry.js +70 -0
  461. package/dist/esm/atomic-commerce-refine-toggle.entry.js.map +1 -0
  462. package/dist/esm/atomic-commerce-text_2.entry.js +101 -0
  463. package/dist/esm/atomic-commerce-text_2.entry.js.map +1 -0
  464. package/dist/esm/atomic-facet-manager.entry.js +1 -1
  465. package/dist/esm/atomic-facet-number-input.entry.js +2 -2
  466. package/dist/esm/atomic-facet.entry.js +2 -3
  467. package/dist/esm/atomic-facet.entry.js.map +1 -1
  468. package/dist/esm/atomic-focus-trap_2.entry.js +2 -2
  469. package/dist/esm/atomic-format-currency.entry.js +1 -1
  470. package/dist/esm/atomic-format-number.entry.js +1 -1
  471. package/dist/esm/atomic-format-unit.entry.js +1 -1
  472. package/dist/esm/atomic-generated-answer-feedback-modal.entry.js +1 -1
  473. package/dist/esm/atomic-html.entry.js +1 -1
  474. package/dist/esm/atomic-insight-edit-toggle.entry.js +1 -1
  475. package/dist/esm/atomic-insight-facet.entry.js +2 -3
  476. package/dist/esm/atomic-insight-facet.entry.js.map +1 -1
  477. package/dist/esm/atomic-insight-folded-result-list.entry.js +1 -1
  478. package/dist/esm/atomic-insight-full-search-button.entry.js +1 -1
  479. package/dist/esm/atomic-insight-history-toggle.entry.js +1 -1
  480. package/dist/esm/atomic-insight-interface.entry.js +3 -10
  481. package/dist/esm/atomic-insight-interface.entry.js.map +1 -1
  482. package/dist/esm/atomic-insight-no-results.entry.js +2 -2
  483. package/dist/esm/atomic-insight-numeric-facet.entry.js +2 -3
  484. package/dist/esm/atomic-insight-numeric-facet.entry.js.map +1 -1
  485. package/dist/esm/atomic-insight-pager.entry.js +3 -3
  486. package/dist/esm/atomic-insight-query-error.entry.js +1 -1
  487. package/dist/esm/atomic-insight-refine-modal.entry.js +2 -2
  488. package/dist/esm/atomic-insight-refine-toggle.entry.js +1 -1
  489. package/dist/esm/atomic-insight-result-attach-to-case-indicator.entry.js +1 -1
  490. package/dist/esm/atomic-insight-result-children.entry.js +1 -1
  491. package/dist/esm/atomic-insight-result-list.entry.js +1 -1
  492. package/dist/esm/atomic-insight-result-quickview-action.entry.js +1 -1
  493. package/dist/esm/atomic-insight-result.entry.js +1 -1
  494. package/dist/esm/atomic-insight-search-box.entry.js +2 -2
  495. package/dist/esm/atomic-insight-smart-snippet-feedback-modal.entry.js +2 -2
  496. package/dist/esm/atomic-insight-tabs.entry.js +1 -1
  497. package/dist/esm/atomic-insight-timeframe-facet.entry.js +5 -6
  498. package/dist/esm/atomic-insight-timeframe-facet.entry.js.map +1 -1
  499. package/dist/esm/atomic-insight-user-actions-session_2.entry.js +1 -1
  500. package/dist/esm/atomic-insight-user-actions-toggle.entry.js +1 -1
  501. package/dist/esm/atomic-ipx-body.entry.js +2 -2
  502. package/dist/esm/atomic-ipx-button.entry.js +2 -2
  503. package/dist/esm/atomic-ipx-embedded.entry.js +1 -1
  504. package/dist/esm/atomic-ipx-modal.entry.js +2 -2
  505. package/dist/esm/atomic-ipx-recs-list.entry.js +1 -1
  506. package/dist/esm/atomic-ipx-refine-modal.entry.js +1 -1
  507. package/dist/esm/atomic-ipx-refine-toggle.entry.js +1 -1
  508. package/dist/esm/atomic-ipx-result-link.entry.js +1 -1
  509. package/dist/esm/atomic-ipx-tabs.entry.js +1 -1
  510. package/dist/esm/atomic-layout-section.entry.js +14 -0
  511. package/dist/esm/atomic-layout-section.entry.js.map +1 -0
  512. package/dist/esm/atomic-load-more-results.entry.js +1 -1
  513. package/dist/esm/atomic-no-results.entry.js +3 -15
  514. package/dist/esm/atomic-no-results.entry.js.map +1 -1
  515. package/dist/esm/atomic-numeric-facet.entry.js +2 -3
  516. package/dist/esm/atomic-numeric-facet.entry.js.map +1 -1
  517. package/dist/esm/atomic-pager.entry.js +3 -3
  518. package/dist/esm/atomic-product-link.entry.js +1 -1
  519. package/dist/esm/atomic-product-numeric-field-value.entry.js +1 -1
  520. package/dist/esm/atomic-product-price.entry.js +2 -2
  521. package/dist/esm/atomic-query-error.entry.js +1 -1
  522. package/dist/esm/atomic-query-summary.entry.js +1 -1
  523. package/dist/esm/atomic-quickview-modal.entry.js +1 -1
  524. package/dist/esm/atomic-quickview.entry.js +1 -1
  525. package/dist/esm/atomic-rating-facet.entry.js +1 -2
  526. package/dist/esm/atomic-rating-facet.entry.js.map +1 -1
  527. package/dist/esm/atomic-rating-range-facet.entry.js +1 -2
  528. package/dist/esm/atomic-rating-range-facet.entry.js.map +1 -1
  529. package/dist/esm/atomic-recs-error.entry.js +1 -1
  530. package/dist/esm/atomic-recs-interface.entry.js +3 -2
  531. package/dist/esm/atomic-recs-interface.entry.js.map +1 -1
  532. package/dist/esm/atomic-recs-list.entry.js +1 -1
  533. package/dist/esm/atomic-refine-modal.entry.js +1 -1
  534. package/dist/esm/atomic-refine-toggle.entry.js +4 -20
  535. package/dist/esm/atomic-refine-toggle.entry.js.map +1 -1
  536. package/dist/esm/{atomic-aria-live_2.entry.js → atomic-relevance-inspector.entry.js} +5 -71
  537. package/dist/esm/atomic-relevance-inspector.entry.js.map +1 -0
  538. package/dist/esm/atomic-result-children.entry.js +1 -1
  539. package/dist/esm/atomic-result-fields-list.entry.js +1 -1
  540. package/dist/esm/atomic-result-link.entry.js +1 -1
  541. package/dist/esm/atomic-result-list.entry.js +1 -1
  542. package/dist/esm/atomic-result-placeholder_8.entry.js +3 -3
  543. package/dist/esm/atomic-result-text_2.entry.js +3 -45
  544. package/dist/esm/atomic-result-text_2.entry.js.map +1 -1
  545. package/dist/esm/atomic-results-per-page.entry.js +1 -1
  546. package/dist/esm/atomic-search-box-query-suggestions_2.entry.js +2 -2
  547. package/dist/esm/atomic-search-box.entry.js +5 -4
  548. package/dist/esm/atomic-search-box.entry.js.map +1 -1
  549. package/dist/esm/atomic-search-interface.entry.js +2 -1
  550. package/dist/esm/atomic-search-interface.entry.js.map +1 -1
  551. package/dist/esm/atomic-smart-snippet-answer_2.entry.js +2 -2
  552. package/dist/esm/atomic-smart-snippet-collapse-wrapper_2.entry.js +3 -3
  553. package/dist/esm/atomic-smart-snippet-feedback-modal.entry.js +2 -2
  554. package/dist/esm/atomic-sort-dropdown.entry.js +2 -2
  555. package/dist/esm/atomic-sort-expression.entry.js +1 -1
  556. package/dist/esm/atomic-suggestion-renderer.entry.js +1 -1
  557. package/dist/esm/atomic-tab-bar_2.entry.js +1 -1
  558. package/dist/esm/atomic-tab-button.entry.js +1 -1
  559. package/dist/esm/atomic-tab-manager.entry.js +1 -1
  560. package/dist/esm/atomic-timeframe-facet.entry.js +5 -6
  561. package/dist/esm/atomic-timeframe-facet.entry.js.map +1 -1
  562. package/dist/esm/atomic.js +1 -1
  563. package/dist/esm/{stencil-facet-header-8a22d37d.js → facet-placeholder-1ed55384.js} +12 -2
  564. package/dist/esm/facet-placeholder-1ed55384.js.map +1 -0
  565. package/dist/esm/index-3f35faca.js +34 -10
  566. package/dist/esm/{analytics-config-9367c413.js → interface-common-stencil-4bb4d80c.js} +4 -42
  567. package/dist/esm/interface-common-stencil-4bb4d80c.js.map +1 -0
  568. package/dist/esm/{product-utils-85109d2e.js → product-utils-8348689f.js} +9 -2
  569. package/dist/esm/product-utils-8348689f.js.map +1 -0
  570. package/dist/esm/sections-ae00b53a.js.map +1 -1
  571. package/dist/esm/stencil-guard-9329c8cd.js +23 -0
  572. package/dist/esm/stencil-guard-9329c8cd.js.map +1 -0
  573. package/dist/esm/stencil-item-text-highlighted-0e1c6c08.js +49 -0
  574. package/dist/esm/stencil-item-text-highlighted-0e1c6c08.js.map +1 -0
  575. package/dist/esm/{stencil-tips-be95482d.js → stencil-tips-06e9b3c2.js} +2 -2
  576. package/dist/esm/{stencil-tips-be95482d.js.map → stencil-tips-06e9b3c2.js.map} +1 -1
  577. package/dist/esm/{timeframe-facet-common-e16ae647.js → timeframe-facet-common-987f9f89.js} +2 -3
  578. package/dist/esm/timeframe-facet-common-987f9f89.js.map +1 -0
  579. package/dist/esm/utils-bd51f737.js +16 -0
  580. package/dist/esm/utils-bd51f737.js.map +1 -0
  581. package/dist/esm/version.js +2 -2
  582. package/dist/types/components/commerce/atomic-commerce-layout/atomic-commerce-layout.d.ts +1 -1
  583. package/dist/types/components/commerce/atomic-commerce-no-products/atomic-commerce-no-products.d.ts +6 -15
  584. package/dist/types/components/commerce/atomic-commerce-recommendation-interface/atomic-commerce-recommendation-interface.d.ts +45 -63
  585. package/dist/types/components/commerce/atomic-commerce-refine-toggle/atomic-commerce-refine-toggle.d.ts +8 -14
  586. package/dist/types/components/commerce/atomic-commerce-text/atomic-commerce-text.d.ts +5 -13
  587. package/dist/types/components/commerce/atomic-product-template/atomic-product-template.d.ts +1 -4
  588. package/dist/types/components/commerce/atomic-product-text/atomic-product-text.d.ts +15 -29
  589. package/dist/types/components/commerce/index.d.ts +0 -5
  590. package/dist/types/components/common/atomic-layout-section/atomic-layout-section.d.ts +2 -11
  591. package/dist/types/components/common/atomic-layout-section/sections.d.ts +1 -2
  592. package/dist/types/components/common/index.d.ts +0 -1
  593. package/dist/types/components/common/interface/interface-common.d.ts +2 -1
  594. package/dist/types/components/common/items-per-page/label.d.ts +2 -2
  595. package/dist/types/components/common/no-items/container.d.ts +2 -2
  596. package/dist/types/components/common/no-items/magnifying-glass.d.ts +2 -2
  597. package/dist/types/components/common/refine-modal/button.d.ts +1 -1
  598. package/dist/types/components/insight/atomic-insight-interface/store.d.ts +0 -4
  599. package/dist/types/components.d.ts +300 -4
  600. package/dist/types/utils/functional-component-utils.d.ts +0 -3
  601. package/docs/atomic-docs.json +795 -31
  602. package/package.json +3 -3
  603. package/dist/atomic/components/components/commerce/atomic-commerce-no-products/atomic-commerce-no-products.js +0 -95
  604. package/dist/atomic/components/components/commerce/atomic-commerce-recommendation-interface/atomic-commerce-recommendation-interface.js +0 -235
  605. package/dist/atomic/components/components/commerce/atomic-commerce-recommendation-interface/atomic-commerce-recommendation-interface.tw.css.js +0 -2
  606. package/dist/atomic/components/components/commerce/atomic-commerce-refine-toggle/atomic-commerce-refine-toggle.js +0 -84
  607. package/dist/atomic/components/components/commerce/atomic-commerce-refine-toggle/atomic-commerce-refine-toggle.tw.css.js +0 -2
  608. package/dist/atomic/components/components/commerce/atomic-commerce-text/atomic-commerce-text.js +0 -54
  609. package/dist/atomic/components/components/commerce/atomic-product-text/atomic-product-text.js +0 -135
  610. package/dist/atomic/components/components/commerce/product-template-component-utils/error.js +0 -6
  611. package/dist/atomic/components/components/commerce/product-template-component-utils/product-utils.js +0 -35
  612. package/dist/atomic/components/components/common/atomic-layout-section/atomic-layout-section.js +0 -31
  613. package/dist/atomic/components/components/common/item-text/field-warning.js +0 -6
  614. package/dist/atomic/components/components/common/item-text/item-text-fallback.js +0 -15
  615. package/dist/atomic/components/components/common/item-text/item-text-highlighted.js +0 -17
  616. package/dist/atomic/components/components/common/item-text/render-highlights.js +0 -13
  617. package/dist/atomic/components/components/common/no-items/container.js +0 -7
  618. package/dist/atomic/components/components/common/no-items/guard.js +0 -11
  619. package/dist/atomic/components/components/common/no-items/magnifying-glass.js +0 -11
  620. package/dist/atomic/components/components/common/no-items/no-items.js +0 -30
  621. package/dist/atomic/components/components/common/no-items/tips.js +0 -8
  622. package/dist/atomic/components/components/common/refine-modal/button.js +0 -14
  623. package/dist/atomic/components/components/common/refine-modal/guard.js +0 -23
  624. package/dist/atomic/components/utils/object-utils.js +0 -13
  625. package/dist/atomic/p-022784c5.entry.js +0 -2
  626. package/dist/atomic/p-06037ffe.entry.js +0 -2
  627. package/dist/atomic/p-06037ffe.entry.js.map +0 -1
  628. package/dist/atomic/p-1429fbdb.entry.js +0 -2
  629. package/dist/atomic/p-27054c71.entry.js +0 -2
  630. package/dist/atomic/p-3025e992.entry.js +0 -2
  631. package/dist/atomic/p-56d6d329.entry.js +0 -2
  632. package/dist/atomic/p-7555ad6d.js +0 -2
  633. package/dist/atomic/p-7555ad6d.js.map +0 -1
  634. package/dist/atomic/p-7d1c2ecd.js +0 -2
  635. package/dist/atomic/p-8074a49d.entry.js +0 -2
  636. package/dist/atomic/p-a1c4ac09.js +0 -2
  637. package/dist/atomic/p-a1c4ac09.js.map +0 -1
  638. package/dist/atomic/p-a3f0aaf4.js +0 -2
  639. package/dist/atomic/p-a3f0aaf4.js.map +0 -1
  640. package/dist/atomic/p-b0f8c3ae.entry.js +0 -2
  641. package/dist/atomic/p-b700e040.entry.js +0 -2
  642. package/dist/atomic/p-b700e040.entry.js.map +0 -1
  643. package/dist/atomic/p-b90e5ea5.entry.js +0 -2
  644. package/dist/atomic/p-bb10a380.entry.js +0 -2
  645. package/dist/atomic/p-bb10a380.entry.js.map +0 -1
  646. package/dist/atomic/p-c46d5a44.entry.js +0 -2
  647. package/dist/atomic/p-c46d5a44.entry.js.map +0 -1
  648. package/dist/atomic/p-d5d0a472.entry.js +0 -2
  649. package/dist/atomic/p-d5d0a472.entry.js.map +0 -1
  650. package/dist/atomic/p-d76c5232.entry.js +0 -2
  651. package/dist/atomic/p-e4f872fb.entry.js +0 -2
  652. package/dist/atomic/p-e6f377c8.entry.js +0 -2
  653. package/dist/atomic/p-e6f377c8.entry.js.map +0 -1
  654. package/dist/atomic/p-f1bbe060.entry.js +0 -2
  655. package/dist/atomic/p-f1bbe060.entry.js.map +0 -1
  656. package/dist/atomic/p-f5323d5b.js.map +0 -1
  657. package/dist/atomic/p-fafea879.entry.js +0 -2
  658. package/dist/cjs/analytics-config-d3622a33.js.map +0 -1
  659. package/dist/cjs/atomic-aria-live_2.cjs.entry.js.map +0 -1
  660. package/dist/cjs/atomic-commerce-category-facet_6.cjs.entry.js.map +0 -1
  661. package/dist/cjs/atomic-commerce-facets.cjs.entry.js +0 -120
  662. package/dist/cjs/atomic-commerce-facets.cjs.entry.js.map +0 -1
  663. package/dist/cjs/facet-placeholder-0111f0f1.js +0 -17
  664. package/dist/cjs/facet-placeholder-0111f0f1.js.map +0 -1
  665. package/dist/cjs/product-utils-f6c780e3.js.map +0 -1
  666. package/dist/cjs/stencil-facet-header-a3dd9de0.js.map +0 -1
  667. package/dist/cjs/timeframe-facet-common-d9078836.js.map +0 -1
  668. package/dist/esm/analytics-config-9367c413.js.map +0 -1
  669. package/dist/esm/atomic-aria-live_2.entry.js.map +0 -1
  670. package/dist/esm/atomic-commerce-category-facet_6.entry.js.map +0 -1
  671. package/dist/esm/atomic-commerce-facets.entry.js +0 -116
  672. package/dist/esm/atomic-commerce-facets.entry.js.map +0 -1
  673. package/dist/esm/facet-placeholder-ecbe6e6f.js +0 -15
  674. package/dist/esm/facet-placeholder-ecbe6e6f.js.map +0 -1
  675. package/dist/esm/product-utils-85109d2e.js.map +0 -1
  676. package/dist/esm/stencil-facet-header-8a22d37d.js.map +0 -1
  677. package/dist/esm/timeframe-facet-common-e16ae647.js.map +0 -1
  678. /package/dist/atomic/{p-f5cea23f.entry.js.map → p-0267a585.entry.js.map} +0 -0
  679. /package/dist/atomic/{p-dcded8cb.entry.js.map → p-0b0ea7d3.entry.js.map} +0 -0
  680. /package/dist/atomic/{p-1326166a.entry.js.map → p-135be5aa.entry.js.map} +0 -0
  681. /package/dist/atomic/{p-f3e9a9f8.entry.js.map → p-1cc97adc.entry.js.map} +0 -0
  682. /package/dist/atomic/{p-ea5d2736.entry.js.map → p-22a0d1b9.entry.js.map} +0 -0
  683. /package/dist/atomic/{p-d88aec96.entry.js.map → p-29d27418.entry.js.map} +0 -0
  684. /package/dist/atomic/{p-90e88505.entry.js.map → p-2f0cb73c.entry.js.map} +0 -0
  685. /package/dist/atomic/{p-fb060cc0.entry.js.map → p-306c83ea.entry.js.map} +0 -0
  686. /package/dist/atomic/{p-b15ca291.entry.js.map → p-3195fa42.entry.js.map} +0 -0
  687. /package/dist/atomic/{p-714c5c2c.entry.js.map → p-32b26cd0.entry.js.map} +0 -0
  688. /package/dist/atomic/{p-1c72983f.entry.js.map → p-32c90fe9.entry.js.map} +0 -0
  689. /package/dist/atomic/{p-4e2ec64c.entry.js.map → p-3ec18de9.entry.js.map} +0 -0
  690. /package/dist/atomic/{p-a010dddb.entry.js.map → p-3f42a2db.entry.js.map} +0 -0
  691. /package/dist/atomic/{p-4495b132.entry.js.map → p-45b26cc7.entry.js.map} +0 -0
  692. /package/dist/atomic/{p-ffb15631.entry.js.map → p-47ee9d37.entry.js.map} +0 -0
  693. /package/dist/atomic/{p-aa4fc96f.entry.js.map → p-50b9a5d2.entry.js.map} +0 -0
  694. /package/dist/atomic/{p-e25287fd.entry.js.map → p-51c5acfc.entry.js.map} +0 -0
  695. /package/dist/atomic/{p-f72a0133.entry.js.map → p-543e811e.entry.js.map} +0 -0
  696. /package/dist/atomic/{p-d76c5232.entry.js.map → p-5cf5bb98.entry.js.map} +0 -0
  697. /package/dist/atomic/{p-2866ca4d.entry.js.map → p-60a9e718.entry.js.map} +0 -0
  698. /package/dist/atomic/{p-eabb4eae.entry.js.map → p-66683abd.entry.js.map} +0 -0
  699. /package/dist/atomic/{p-8b579505.entry.js.map → p-67315415.entry.js.map} +0 -0
  700. /package/dist/atomic/{p-714ee3bb.entry.js.map → p-689e063d.entry.js.map} +0 -0
  701. /package/dist/atomic/{p-f5686c7e.entry.js.map → p-690b5853.entry.js.map} +0 -0
  702. /package/dist/atomic/{p-ace45b24.entry.js.map → p-70ab347b.entry.js.map} +0 -0
  703. /package/dist/atomic/{p-966509f8.entry.js.map → p-76122df5.entry.js.map} +0 -0
  704. /package/dist/atomic/{p-9ec72c3b.entry.js.map → p-7d1f8d9c.entry.js.map} +0 -0
  705. /package/dist/atomic/{p-d37bb72b.entry.js.map → p-80dc3bab.entry.js.map} +0 -0
  706. /package/dist/atomic/{p-6e11d4c6.entry.js.map → p-8d7f57d9.entry.js.map} +0 -0
  707. /package/dist/atomic/{p-7d63f0e6.entry.js.map → p-8e09f796.entry.js.map} +0 -0
  708. /package/dist/atomic/{p-a84d94cb.entry.js.map → p-95942ba2.entry.js.map} +0 -0
  709. /package/dist/atomic/{p-21d55afc.entry.js.map → p-99604083.entry.js.map} +0 -0
  710. /package/dist/atomic/{p-d4ec6961.entry.js.map → p-9a08dad7.entry.js.map} +0 -0
  711. /package/dist/atomic/{p-03fa8481.entry.js.map → p-9ae88402.entry.js.map} +0 -0
  712. /package/dist/atomic/{p-01c109cf.entry.js.map → p-9d2230db.entry.js.map} +0 -0
  713. /package/dist/atomic/{p-fac32d34.entry.js.map → p-9eb108c9.entry.js.map} +0 -0
  714. /package/dist/atomic/{p-5a3cd055.entry.js.map → p-a3169f59.entry.js.map} +0 -0
  715. /package/dist/atomic/{p-c6f15059.entry.js.map → p-a8281e9b.entry.js.map} +0 -0
  716. /package/dist/atomic/{p-4f03327d.entry.js.map → p-ab5eec3d.entry.js.map} +0 -0
  717. /package/dist/atomic/{p-1aedbfbf.entry.js.map → p-b19a8cbb.entry.js.map} +0 -0
  718. /package/dist/atomic/{p-61f79055.entry.js.map → p-b4d47ca9.entry.js.map} +0 -0
  719. /package/dist/atomic/{p-1e3f156e.entry.js.map → p-b4dfe5b2.entry.js.map} +0 -0
  720. /package/dist/atomic/{p-3025e992.entry.js.map → p-b747e4a9.entry.js.map} +0 -0
  721. /package/dist/atomic/{p-e4cc2a37.entry.js.map → p-b7824e0e.entry.js.map} +0 -0
  722. /package/dist/atomic/{p-3632e456.entry.js.map → p-be13ed5c.entry.js.map} +0 -0
  723. /package/dist/atomic/{p-2871034a.entry.js.map → p-bfeefcaa.entry.js.map} +0 -0
  724. /package/dist/atomic/{p-b4b6f859.entry.js.map → p-c0d7b26d.entry.js.map} +0 -0
  725. /package/dist/atomic/{p-9ef7ffc0.entry.js.map → p-c13d4039.entry.js.map} +0 -0
  726. /package/dist/atomic/{p-4505f2e0.entry.js.map → p-c4f042ae.entry.js.map} +0 -0
  727. /package/dist/atomic/{p-faee1f57.entry.js.map → p-cd87574b.entry.js.map} +0 -0
  728. /package/dist/atomic/{p-0875a7fb.entry.js.map → p-ce4e939b.entry.js.map} +0 -0
  729. /package/dist/atomic/{p-1fbbed3e.entry.js.map → p-d1efd50f.entry.js.map} +0 -0
  730. /package/dist/atomic/{p-7d773b22.entry.js.map → p-d30057a0.entry.js.map} +0 -0
  731. /package/dist/atomic/{p-e7d5c4be.entry.js.map → p-d4aba9f9.entry.js.map} +0 -0
  732. /package/dist/atomic/{p-ce1f6392.entry.js.map → p-d69756ae.entry.js.map} +0 -0
  733. /package/dist/atomic/{p-08d1db60.entry.js.map → p-d827c148.entry.js.map} +0 -0
  734. /package/dist/atomic/{p-d04ad3e5.entry.js.map → p-dd8c6bdd.entry.js.map} +0 -0
  735. /package/dist/atomic/{p-886da915.entry.js.map → p-ddd52850.entry.js.map} +0 -0
  736. /package/dist/atomic/{p-fecd79de.entry.js.map → p-e44155cc.entry.js.map} +0 -0
  737. /package/dist/atomic/{p-c074198a.entry.js.map → p-e4754fd0.entry.js.map} +0 -0
  738. /package/dist/atomic/{p-db5285b1.entry.js.map → p-ec0161b7.entry.js.map} +0 -0
  739. /package/dist/atomic/{p-eea2128f.entry.js.map → p-ec6bc15b.entry.js.map} +0 -0
  740. /package/dist/atomic/{p-e37f01fc.entry.js.map → p-eebb168b.entry.js.map} +0 -0
  741. /package/dist/atomic/{p-870dbeef.entry.js.map → p-f4b98113.entry.js.map} +0 -0
  742. /package/dist/atomic/{p-e988f378.js.map → p-f7f81710.js.map} +0 -0
  743. /package/dist/atomic/{p-8403335e.entry.js.map → p-fb0bdcdb.entry.js.map} +0 -0
  744. /package/dist/atomic/{p-b0f8c3ae.entry.js.map → p-fbbbc454.entry.js.map} +0 -0
  745. /package/dist/atomic/{p-ebb35a4b.entry.js.map → p-fd9d1c3f.entry.js.map} +0 -0
@@ -1,2940 +1,4 @@
1
- import { d as dayjs } from './dayjs.min.js';
2
- import { h } from '@stencil/core/internal/client';
3
- import { D as DOMPurify } from './purify.js';
4
- import { VERSION } from '@coveo/headless';
5
-
6
- const isString = obj => typeof obj === 'string';
7
- const defer = () => {
8
- let res;
9
- let rej;
10
- const promise = new Promise((resolve, reject) => {
11
- res = resolve;
12
- rej = reject;
13
- });
14
- promise.resolve = res;
15
- promise.reject = rej;
16
- return promise;
17
- };
18
- const makeString = object => {
19
- if (object == null) return '';
20
- return '' + object;
21
- };
22
- const copy = (a, s, t) => {
23
- a.forEach(m => {
24
- if (s[m]) t[m] = s[m];
25
- });
26
- };
27
- const lastOfPathSeparatorRegExp = /###/g;
28
- const cleanKey = key => key && key.indexOf('###') > -1 ? key.replace(lastOfPathSeparatorRegExp, '.') : key;
29
- const canNotTraverseDeeper = object => !object || isString(object);
30
- const getLastOfPath = (object, path, Empty) => {
31
- const stack = !isString(path) ? path : path.split('.');
32
- let stackIndex = 0;
33
- while (stackIndex < stack.length - 1) {
34
- if (canNotTraverseDeeper(object)) return {};
35
- const key = cleanKey(stack[stackIndex]);
36
- if (!object[key] && Empty) object[key] = new Empty();
37
- if (Object.prototype.hasOwnProperty.call(object, key)) {
38
- object = object[key];
39
- } else {
40
- object = {};
41
- }
42
- ++stackIndex;
43
- }
44
- if (canNotTraverseDeeper(object)) return {};
45
- return {
46
- obj: object,
47
- k: cleanKey(stack[stackIndex])
48
- };
49
- };
50
- const setPath = (object, path, newValue) => {
51
- const {
52
- obj,
53
- k
54
- } = getLastOfPath(object, path, Object);
55
- if (obj !== undefined || path.length === 1) {
56
- obj[k] = newValue;
57
- return;
58
- }
59
- let e = path[path.length - 1];
60
- let p = path.slice(0, path.length - 1);
61
- let last = getLastOfPath(object, p, Object);
62
- while (last.obj === undefined && p.length) {
63
- e = `${p[p.length - 1]}.${e}`;
64
- p = p.slice(0, p.length - 1);
65
- last = getLastOfPath(object, p, Object);
66
- if (last?.obj && typeof last.obj[`${last.k}.${e}`] !== 'undefined') {
67
- last.obj = undefined;
68
- }
69
- }
70
- last.obj[`${last.k}.${e}`] = newValue;
71
- };
72
- const pushPath = (object, path, newValue, concat) => {
73
- const {
74
- obj,
75
- k
76
- } = getLastOfPath(object, path, Object);
77
- obj[k] = obj[k] || [];
78
- obj[k].push(newValue);
79
- };
80
- const getPath = (object, path) => {
81
- const {
82
- obj,
83
- k
84
- } = getLastOfPath(object, path);
85
- if (!obj) return undefined;
86
- if (!Object.prototype.hasOwnProperty.call(obj, k)) return undefined;
87
- return obj[k];
88
- };
89
- const getPathWithDefaults = (data, defaultData, key) => {
90
- const value = getPath(data, key);
91
- if (value !== undefined) {
92
- return value;
93
- }
94
- return getPath(defaultData, key);
95
- };
96
- const deepExtend = (target, source, overwrite) => {
97
- for (const prop in source) {
98
- if (prop !== '__proto__' && prop !== 'constructor') {
99
- if (prop in target) {
100
- if (isString(target[prop]) || target[prop] instanceof String || isString(source[prop]) || source[prop] instanceof String) {
101
- if (overwrite) target[prop] = source[prop];
102
- } else {
103
- deepExtend(target[prop], source[prop], overwrite);
104
- }
105
- } else {
106
- target[prop] = source[prop];
107
- }
108
- }
109
- }
110
- return target;
111
- };
112
- const regexEscape = str => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
113
- var _entityMap = {
114
- '&': '&amp;',
115
- '<': '&lt;',
116
- '>': '&gt;',
117
- '"': '&quot;',
118
- "'": '&#39;',
119
- '/': '&#x2F;'
120
- };
121
- const escape = data => {
122
- if (isString(data)) {
123
- return data.replace(/[&<>"'\/]/g, s => _entityMap[s]);
124
- }
125
- return data;
126
- };
127
- class RegExpCache {
128
- constructor(capacity) {
129
- this.capacity = capacity;
130
- this.regExpMap = new Map();
131
- this.regExpQueue = [];
132
- }
133
- getRegExp(pattern) {
134
- const regExpFromCache = this.regExpMap.get(pattern);
135
- if (regExpFromCache !== undefined) {
136
- return regExpFromCache;
137
- }
138
- const regExpNew = new RegExp(pattern);
139
- if (this.regExpQueue.length === this.capacity) {
140
- this.regExpMap.delete(this.regExpQueue.shift());
141
- }
142
- this.regExpMap.set(pattern, regExpNew);
143
- this.regExpQueue.push(pattern);
144
- return regExpNew;
145
- }
146
- }
147
- const chars = [' ', ',', '?', '!', ';'];
148
- const looksLikeObjectPathRegExpCache = new RegExpCache(20);
149
- const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
150
- nsSeparator = nsSeparator || '';
151
- keySeparator = keySeparator || '';
152
- const possibleChars = chars.filter(c => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
153
- if (possibleChars.length === 0) return true;
154
- const r = looksLikeObjectPathRegExpCache.getRegExp(`(${possibleChars.map(c => c === '?' ? '\\?' : c).join('|')})`);
155
- let matched = !r.test(key);
156
- if (!matched) {
157
- const ki = key.indexOf(keySeparator);
158
- if (ki > 0 && !r.test(key.substring(0, ki))) {
159
- matched = true;
160
- }
161
- }
162
- return matched;
163
- };
164
- const deepFind = function (obj, path) {
165
- let keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
166
- if (!obj) return undefined;
167
- if (obj[path]) {
168
- if (!Object.prototype.hasOwnProperty.call(obj, path)) return undefined;
169
- return obj[path];
170
- }
171
- const tokens = path.split(keySeparator);
172
- let current = obj;
173
- for (let i = 0; i < tokens.length;) {
174
- if (!current || typeof current !== 'object') {
175
- return undefined;
176
- }
177
- let next;
178
- let nextPath = '';
179
- for (let j = i; j < tokens.length; ++j) {
180
- if (j !== i) {
181
- nextPath += keySeparator;
182
- }
183
- nextPath += tokens[j];
184
- next = current[nextPath];
185
- if (next !== undefined) {
186
- if (['string', 'number', 'boolean'].indexOf(typeof next) > -1 && j < tokens.length - 1) {
187
- continue;
188
- }
189
- i += j - i + 1;
190
- break;
191
- }
192
- }
193
- current = next;
194
- }
195
- return current;
196
- };
197
- const getCleanedCode = code => code?.replace('_', '-');
198
-
199
- const consoleLogger = {
200
- type: 'logger',
201
- log(args) {
202
- this.output('log', args);
203
- },
204
- warn(args) {
205
- this.output('warn', args);
206
- },
207
- error(args) {
208
- this.output('error', args);
209
- },
210
- output(type, args) {
211
- console?.[type]?.apply?.(console, args);
212
- }
213
- };
214
- class Logger {
215
- constructor(concreteLogger) {
216
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
217
- this.init(concreteLogger, options);
218
- }
219
- init(concreteLogger) {
220
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
221
- this.prefix = options.prefix || 'i18next:';
222
- this.logger = concreteLogger || consoleLogger;
223
- this.options = options;
224
- this.debug = options.debug;
225
- }
226
- log() {
227
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
228
- args[_key] = arguments[_key];
229
- }
230
- return this.forward(args, 'log', '', true);
231
- }
232
- warn() {
233
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
234
- args[_key2] = arguments[_key2];
235
- }
236
- return this.forward(args, 'warn', '', true);
237
- }
238
- error() {
239
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
240
- args[_key3] = arguments[_key3];
241
- }
242
- return this.forward(args, 'error', '');
243
- }
244
- deprecate() {
245
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
246
- args[_key4] = arguments[_key4];
247
- }
248
- return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
249
- }
250
- forward(args, lvl, prefix, debugOnly) {
251
- if (debugOnly && !this.debug) return null;
252
- if (isString(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
253
- return this.logger[lvl](args);
254
- }
255
- create(moduleName) {
256
- return new Logger(this.logger, {
257
- ...{
258
- prefix: `${this.prefix}:${moduleName}:`
259
- },
260
- ...this.options
261
- });
262
- }
263
- clone(options) {
264
- options = options || this.options;
265
- options.prefix = options.prefix || this.prefix;
266
- return new Logger(this.logger, options);
267
- }
268
- }
269
- var baseLogger = new Logger();
270
-
271
- class EventEmitter {
272
- constructor() {
273
- this.observers = {};
274
- }
275
- on(events, listener) {
276
- events.split(' ').forEach(event => {
277
- if (!this.observers[event]) this.observers[event] = new Map();
278
- const numListeners = this.observers[event].get(listener) || 0;
279
- this.observers[event].set(listener, numListeners + 1);
280
- });
281
- return this;
282
- }
283
- off(event, listener) {
284
- if (!this.observers[event]) return;
285
- if (!listener) {
286
- delete this.observers[event];
287
- return;
288
- }
289
- this.observers[event].delete(listener);
290
- }
291
- emit(event) {
292
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
293
- args[_key - 1] = arguments[_key];
294
- }
295
- if (this.observers[event]) {
296
- const cloned = Array.from(this.observers[event].entries());
297
- cloned.forEach(_ref => {
298
- let [observer, numTimesAdded] = _ref;
299
- for (let i = 0; i < numTimesAdded; i++) {
300
- observer(...args);
301
- }
302
- });
303
- }
304
- if (this.observers['*']) {
305
- const cloned = Array.from(this.observers['*'].entries());
306
- cloned.forEach(_ref2 => {
307
- let [observer, numTimesAdded] = _ref2;
308
- for (let i = 0; i < numTimesAdded; i++) {
309
- observer.apply(observer, [event, ...args]);
310
- }
311
- });
312
- }
313
- }
314
- }
315
-
316
- class ResourceStore extends EventEmitter {
317
- constructor(data) {
318
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
319
- ns: ['translation'],
320
- defaultNS: 'translation'
321
- };
322
- super();
323
- this.data = data || {};
324
- this.options = options;
325
- if (this.options.keySeparator === undefined) {
326
- this.options.keySeparator = '.';
327
- }
328
- if (this.options.ignoreJSONStructure === undefined) {
329
- this.options.ignoreJSONStructure = true;
330
- }
331
- }
332
- addNamespaces(ns) {
333
- if (this.options.ns.indexOf(ns) < 0) {
334
- this.options.ns.push(ns);
335
- }
336
- }
337
- removeNamespaces(ns) {
338
- const index = this.options.ns.indexOf(ns);
339
- if (index > -1) {
340
- this.options.ns.splice(index, 1);
341
- }
342
- }
343
- getResource(lng, ns, key) {
344
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
345
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
346
- const ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
347
- let path;
348
- if (lng.indexOf('.') > -1) {
349
- path = lng.split('.');
350
- } else {
351
- path = [lng, ns];
352
- if (key) {
353
- if (Array.isArray(key)) {
354
- path.push(...key);
355
- } else if (isString(key) && keySeparator) {
356
- path.push(...key.split(keySeparator));
357
- } else {
358
- path.push(key);
359
- }
360
- }
361
- }
362
- const result = getPath(this.data, path);
363
- if (!result && !ns && !key && lng.indexOf('.') > -1) {
364
- lng = path[0];
365
- ns = path[1];
366
- key = path.slice(2).join('.');
367
- }
368
- if (result || !ignoreJSONStructure || !isString(key)) return result;
369
- return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
370
- }
371
- addResource(lng, ns, key, value) {
372
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
373
- silent: false
374
- };
375
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
376
- let path = [lng, ns];
377
- if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
378
- if (lng.indexOf('.') > -1) {
379
- path = lng.split('.');
380
- value = ns;
381
- ns = path[1];
382
- }
383
- this.addNamespaces(ns);
384
- setPath(this.data, path, value);
385
- if (!options.silent) this.emit('added', lng, ns, key, value);
386
- }
387
- addResources(lng, ns, resources) {
388
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
389
- silent: false
390
- };
391
- for (const m in resources) {
392
- if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
393
- silent: true
394
- });
395
- }
396
- if (!options.silent) this.emit('added', lng, ns, resources);
397
- }
398
- addResourceBundle(lng, ns, resources, deep, overwrite) {
399
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
400
- silent: false,
401
- skipCopy: false
402
- };
403
- let path = [lng, ns];
404
- if (lng.indexOf('.') > -1) {
405
- path = lng.split('.');
406
- deep = resources;
407
- resources = ns;
408
- ns = path[1];
409
- }
410
- this.addNamespaces(ns);
411
- let pack = getPath(this.data, path) || {};
412
- if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
413
- if (deep) {
414
- deepExtend(pack, resources, overwrite);
415
- } else {
416
- pack = {
417
- ...pack,
418
- ...resources
419
- };
420
- }
421
- setPath(this.data, path, pack);
422
- if (!options.silent) this.emit('added', lng, ns, resources);
423
- }
424
- removeResourceBundle(lng, ns) {
425
- if (this.hasResourceBundle(lng, ns)) {
426
- delete this.data[lng][ns];
427
- }
428
- this.removeNamespaces(ns);
429
- this.emit('removed', lng, ns);
430
- }
431
- hasResourceBundle(lng, ns) {
432
- return this.getResource(lng, ns) !== undefined;
433
- }
434
- getResourceBundle(lng, ns) {
435
- if (!ns) ns = this.options.defaultNS;
436
- return this.getResource(lng, ns);
437
- }
438
- getDataByLanguage(lng) {
439
- return this.data[lng];
440
- }
441
- hasLanguageSomeTranslations(lng) {
442
- const data = this.getDataByLanguage(lng);
443
- const n = data && Object.keys(data) || [];
444
- return !!n.find(v => data[v] && Object.keys(data[v]).length > 0);
445
- }
446
- toJSON() {
447
- return this.data;
448
- }
449
- }
450
-
451
- var postProcessor = {
452
- processors: {},
453
- addPostProcessor(module) {
454
- this.processors[module.name] = module;
455
- },
456
- handle(processors, value, key, options, translator) {
457
- processors.forEach(processor => {
458
- value = this.processors[processor]?.process(value, key, options, translator) ?? value;
459
- });
460
- return value;
461
- }
462
- };
463
-
464
- const checkedLoadedFor = {};
465
- const shouldHandleAsObject = res => !isString(res) && typeof res !== 'boolean' && typeof res !== 'number';
466
- class Translator extends EventEmitter {
467
- constructor(services) {
468
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
469
- super();
470
- copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, this);
471
- this.options = options;
472
- if (this.options.keySeparator === undefined) {
473
- this.options.keySeparator = '.';
474
- }
475
- this.logger = baseLogger.create('translator');
476
- }
477
- changeLanguage(lng) {
478
- if (lng) this.language = lng;
479
- }
480
- exists(key) {
481
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
482
- interpolation: {}
483
- };
484
- if (key == null) {
485
- return false;
486
- }
487
- const resolved = this.resolve(key, options);
488
- return resolved?.res !== undefined;
489
- }
490
- extractFromKey(key, options) {
491
- let nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
492
- if (nsSeparator === undefined) nsSeparator = ':';
493
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
494
- let namespaces = options.ns || this.options.defaultNS || [];
495
- const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
496
- const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
497
- if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
498
- const m = key.match(this.interpolator.nestingRegexp);
499
- if (m && m.length > 0) {
500
- return {
501
- key,
502
- namespaces: isString(namespaces) ? [namespaces] : namespaces
503
- };
504
- }
505
- const parts = key.split(nsSeparator);
506
- if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
507
- key = parts.join(keySeparator);
508
- }
509
- return {
510
- key,
511
- namespaces: isString(namespaces) ? [namespaces] : namespaces
512
- };
513
- }
514
- translate(keys, options, lastKey) {
515
- if (typeof options !== 'object' && this.options.overloadTranslationOptionHandler) {
516
- options = this.options.overloadTranslationOptionHandler(arguments);
517
- }
518
- if (typeof options === 'object') options = {
519
- ...options
520
- };
521
- if (!options) options = {};
522
- if (keys == null) return '';
523
- if (!Array.isArray(keys)) keys = [String(keys)];
524
- const returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
525
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
526
- const {
527
- key,
528
- namespaces
529
- } = this.extractFromKey(keys[keys.length - 1], options);
530
- const namespace = namespaces[namespaces.length - 1];
531
- const lng = options.lng || this.language;
532
- const appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
533
- if (lng?.toLowerCase() === 'cimode') {
534
- if (appendNamespaceToCIMode) {
535
- const nsSeparator = options.nsSeparator || this.options.nsSeparator;
536
- if (returnDetails) {
537
- return {
538
- res: `${namespace}${nsSeparator}${key}`,
539
- usedKey: key,
540
- exactUsedKey: key,
541
- usedLng: lng,
542
- usedNS: namespace,
543
- usedParams: this.getUsedParamsDetails(options)
544
- };
545
- }
546
- return `${namespace}${nsSeparator}${key}`;
547
- }
548
- if (returnDetails) {
549
- return {
550
- res: key,
551
- usedKey: key,
552
- exactUsedKey: key,
553
- usedLng: lng,
554
- usedNS: namespace,
555
- usedParams: this.getUsedParamsDetails(options)
556
- };
557
- }
558
- return key;
559
- }
560
- const resolved = this.resolve(keys, options);
561
- let res = resolved?.res;
562
- const resUsedKey = resolved?.usedKey || key;
563
- const resExactUsedKey = resolved?.exactUsedKey || key;
564
- const noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
565
- const joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
566
- const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
567
- const needsPluralHandling = options.count !== undefined && !isString(options.count);
568
- const hasDefaultValue = Translator.hasDefaultValue(options);
569
- const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
570
- const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {
571
- ordinal: false
572
- }) : '';
573
- const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0;
574
- const defaultValue = needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] || options[`defaultValue${defaultValueSuffix}`] || options[`defaultValue${defaultValueSuffixOrdinalFallback}`] || options.defaultValue;
575
- let resForObjHndl = res;
576
- if (handleAsObjectInI18nFormat && !res && hasDefaultValue) {
577
- resForObjHndl = defaultValue;
578
- }
579
- const handleAsObject = shouldHandleAsObject(resForObjHndl);
580
- const resType = Object.prototype.toString.apply(resForObjHndl);
581
- if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(resForObjHndl))) {
582
- if (!options.returnObjects && !this.options.returnObjects) {
583
- if (!this.options.returnedObjectHandler) {
584
- this.logger.warn('accessing an object - but returnObjects options is not enabled!');
585
- }
586
- const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
587
- ...options,
588
- ns: namespaces
589
- }) : `key '${key} (${this.language})' returned an object instead of string.`;
590
- if (returnDetails) {
591
- resolved.res = r;
592
- resolved.usedParams = this.getUsedParamsDetails(options);
593
- return resolved;
594
- }
595
- return r;
596
- }
597
- if (keySeparator) {
598
- const resTypeIsArray = Array.isArray(resForObjHndl);
599
- const copy = resTypeIsArray ? [] : {};
600
- const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
601
- for (const m in resForObjHndl) {
602
- if (Object.prototype.hasOwnProperty.call(resForObjHndl, m)) {
603
- const deepKey = `${newKeyToUse}${keySeparator}${m}`;
604
- if (hasDefaultValue && !res) {
605
- copy[m] = this.translate(deepKey, {
606
- ...options,
607
- defaultValue: shouldHandleAsObject(defaultValue) ? defaultValue[m] : undefined,
608
- ...{
609
- joinArrays: false,
610
- ns: namespaces
611
- }
612
- });
613
- } else {
614
- copy[m] = this.translate(deepKey, {
615
- ...options,
616
- ...{
617
- joinArrays: false,
618
- ns: namespaces
619
- }
620
- });
621
- }
622
- if (copy[m] === deepKey) copy[m] = resForObjHndl[m];
623
- }
624
- }
625
- res = copy;
626
- }
627
- } else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
628
- res = res.join(joinArrays);
629
- if (res) res = this.extendTranslation(res, keys, options, lastKey);
630
- } else {
631
- let usedDefault = false;
632
- let usedKey = false;
633
- if (!this.isValidLookup(res) && hasDefaultValue) {
634
- usedDefault = true;
635
- res = defaultValue;
636
- }
637
- if (!this.isValidLookup(res)) {
638
- usedKey = true;
639
- res = key;
640
- }
641
- const missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
642
- const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
643
- const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
644
- if (usedKey || usedDefault || updateMissing) {
645
- this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
646
- if (keySeparator) {
647
- const fk = this.resolve(key, {
648
- ...options,
649
- keySeparator: false
650
- });
651
- 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.');
652
- }
653
- let lngs = [];
654
- const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
655
- if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
656
- for (let i = 0; i < fallbackLngs.length; i++) {
657
- lngs.push(fallbackLngs[i]);
658
- }
659
- } else if (this.options.saveMissingTo === 'all') {
660
- lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
661
- } else {
662
- lngs.push(options.lng || this.language);
663
- }
664
- const send = (l, k, specificDefaultValue) => {
665
- const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
666
- if (this.options.missingKeyHandler) {
667
- this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
668
- } else if (this.backendConnector?.saveMissing) {
669
- this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
670
- }
671
- this.emit('missingKey', l, namespace, k, res);
672
- };
673
- if (this.options.saveMissing) {
674
- if (this.options.saveMissingPlurals && needsPluralHandling) {
675
- lngs.forEach(language => {
676
- const suffixes = this.pluralResolver.getSuffixes(language, options);
677
- if (needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
678
- suffixes.push(`${this.options.pluralSeparator}zero`);
679
- }
680
- suffixes.forEach(suffix => {
681
- send([language], key + suffix, options[`defaultValue${suffix}`] || defaultValue);
682
- });
683
- });
684
- } else {
685
- send(lngs, key, defaultValue);
686
- }
687
- }
688
- }
689
- res = this.extendTranslation(res, keys, options, resolved, lastKey);
690
- if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
691
- if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
692
- res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : undefined);
693
- }
694
- }
695
- if (returnDetails) {
696
- resolved.res = res;
697
- resolved.usedParams = this.getUsedParamsDetails(options);
698
- return resolved;
699
- }
700
- return res;
701
- }
702
- extendTranslation(res, key, options, resolved, lastKey) {
703
- var _this = this;
704
- if (this.i18nFormat?.parse) {
705
- res = this.i18nFormat.parse(res, {
706
- ...this.options.interpolation.defaultVariables,
707
- ...options
708
- }, options.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
709
- resolved
710
- });
711
- } else if (!options.skipInterpolation) {
712
- if (options.interpolation) this.interpolator.init({
713
- ...options,
714
- ...{
715
- interpolation: {
716
- ...this.options.interpolation,
717
- ...options.interpolation
718
- }
719
- }
720
- });
721
- const skipOnVariables = isString(res) && (options?.interpolation?.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
722
- let nestBef;
723
- if (skipOnVariables) {
724
- const nb = res.match(this.interpolator.nestingRegexp);
725
- nestBef = nb && nb.length;
726
- }
727
- let data = options.replace && !isString(options.replace) ? options.replace : options;
728
- if (this.options.interpolation.defaultVariables) data = {
729
- ...this.options.interpolation.defaultVariables,
730
- ...data
731
- };
732
- res = this.interpolator.interpolate(res, data, options.lng || this.language || resolved.usedLng, options);
733
- if (skipOnVariables) {
734
- const na = res.match(this.interpolator.nestingRegexp);
735
- const nestAft = na && na.length;
736
- if (nestBef < nestAft) options.nest = false;
737
- }
738
- if (!options.lng && resolved && resolved.res) options.lng = this.language || resolved.usedLng;
739
- if (options.nest !== false) res = this.interpolator.nest(res, function () {
740
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
741
- args[_key] = arguments[_key];
742
- }
743
- if (lastKey?.[0] === args[0] && !options.context) {
744
- _this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
745
- return null;
746
- }
747
- return _this.translate(...args, key);
748
- }, options);
749
- if (options.interpolation) this.interpolator.reset();
750
- }
751
- const postProcess = options.postProcess || this.options.postProcess;
752
- const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
753
- if (res != null && postProcessorNames?.length && options.applyPostProcessor !== false) {
754
- res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
755
- i18nResolved: {
756
- ...resolved,
757
- usedParams: this.getUsedParamsDetails(options)
758
- },
759
- ...options
760
- } : options, this);
761
- }
762
- return res;
763
- }
764
- resolve(keys) {
765
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
766
- let found;
767
- let usedKey;
768
- let exactUsedKey;
769
- let usedLng;
770
- let usedNS;
771
- if (isString(keys)) keys = [keys];
772
- keys.forEach(k => {
773
- if (this.isValidLookup(found)) return;
774
- const extracted = this.extractFromKey(k, options);
775
- const key = extracted.key;
776
- usedKey = key;
777
- let namespaces = extracted.namespaces;
778
- if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
779
- const needsPluralHandling = options.count !== undefined && !isString(options.count);
780
- const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0;
781
- const needsContextHandling = options.context !== undefined && (isString(options.context) || typeof options.context === 'number') && options.context !== '';
782
- const codes = options.lngs ? options.lngs : this.languageUtils.toResolveHierarchy(options.lng || this.language, options.fallbackLng);
783
- namespaces.forEach(ns => {
784
- if (this.isValidLookup(found)) return;
785
- usedNS = ns;
786
- if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(usedNS)) {
787
- checkedLoadedFor[`${codes[0]}-${ns}`] = true;
788
- 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!!!');
789
- }
790
- codes.forEach(code => {
791
- if (this.isValidLookup(found)) return;
792
- usedLng = code;
793
- const finalKeys = [key];
794
- if (this.i18nFormat?.addLookupKeys) {
795
- this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
796
- } else {
797
- let pluralSuffix;
798
- if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, options.count, options);
799
- const zeroSuffix = `${this.options.pluralSeparator}zero`;
800
- const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
801
- if (needsPluralHandling) {
802
- finalKeys.push(key + pluralSuffix);
803
- if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
804
- finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
805
- }
806
- if (needsZeroSuffixLookup) {
807
- finalKeys.push(key + zeroSuffix);
808
- }
809
- }
810
- if (needsContextHandling) {
811
- const contextKey = `${key}${this.options.contextSeparator}${options.context}`;
812
- finalKeys.push(contextKey);
813
- if (needsPluralHandling) {
814
- finalKeys.push(contextKey + pluralSuffix);
815
- if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
816
- finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
817
- }
818
- if (needsZeroSuffixLookup) {
819
- finalKeys.push(contextKey + zeroSuffix);
820
- }
821
- }
822
- }
823
- }
824
- let possibleKey;
825
- while (possibleKey = finalKeys.pop()) {
826
- if (!this.isValidLookup(found)) {
827
- exactUsedKey = possibleKey;
828
- found = this.getResource(code, ns, possibleKey, options);
829
- }
830
- }
831
- });
832
- });
833
- });
834
- return {
835
- res: found,
836
- usedKey,
837
- exactUsedKey,
838
- usedLng,
839
- usedNS
840
- };
841
- }
842
- isValidLookup(res) {
843
- return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
844
- }
845
- getResource(code, ns, key) {
846
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
847
- if (this.i18nFormat?.getResource) return this.i18nFormat.getResource(code, ns, key, options);
848
- return this.resourceStore.getResource(code, ns, key, options);
849
- }
850
- getUsedParamsDetails() {
851
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
852
- const optionsKeys = ['defaultValue', 'ordinal', 'context', 'replace', 'lng', 'lngs', 'fallbackLng', 'ns', 'keySeparator', 'nsSeparator', 'returnObjects', 'returnDetails', 'joinArrays', 'postProcess', 'interpolation'];
853
- const useOptionsReplaceForData = options.replace && !isString(options.replace);
854
- let data = useOptionsReplaceForData ? options.replace : options;
855
- if (useOptionsReplaceForData && typeof options.count !== 'undefined') {
856
- data.count = options.count;
857
- }
858
- if (this.options.interpolation.defaultVariables) {
859
- data = {
860
- ...this.options.interpolation.defaultVariables,
861
- ...data
862
- };
863
- }
864
- if (!useOptionsReplaceForData) {
865
- data = {
866
- ...data
867
- };
868
- for (const key of optionsKeys) {
869
- delete data[key];
870
- }
871
- }
872
- return data;
873
- }
874
- static hasDefaultValue(options) {
875
- const prefix = 'defaultValue';
876
- for (const option in options) {
877
- if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
878
- return true;
879
- }
880
- }
881
- return false;
882
- }
883
- }
884
-
885
- class LanguageUtil {
886
- constructor(options) {
887
- this.options = options;
888
- this.supportedLngs = this.options.supportedLngs || false;
889
- this.logger = baseLogger.create('languageUtils');
890
- }
891
- getScriptPartFromCode(code) {
892
- code = getCleanedCode(code);
893
- if (!code || code.indexOf('-') < 0) return null;
894
- const p = code.split('-');
895
- if (p.length === 2) return null;
896
- p.pop();
897
- if (p[p.length - 1].toLowerCase() === 'x') return null;
898
- return this.formatLanguageCode(p.join('-'));
899
- }
900
- getLanguagePartFromCode(code) {
901
- code = getCleanedCode(code);
902
- if (!code || code.indexOf('-') < 0) return code;
903
- const p = code.split('-');
904
- return this.formatLanguageCode(p[0]);
905
- }
906
- formatLanguageCode(code) {
907
- if (isString(code) && code.indexOf('-') > -1) {
908
- let formattedCode;
909
- try {
910
- formattedCode = Intl.getCanonicalLocales(code)[0];
911
- } catch (e) {}
912
- if (formattedCode && this.options.lowerCaseLng) {
913
- formattedCode = formattedCode.toLowerCase();
914
- }
915
- if (formattedCode) return formattedCode;
916
- if (this.options.lowerCaseLng) {
917
- return code.toLowerCase();
918
- }
919
- return code;
920
- }
921
- return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
922
- }
923
- isSupportedCode(code) {
924
- if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
925
- code = this.getLanguagePartFromCode(code);
926
- }
927
- return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
928
- }
929
- getBestMatchFromCodes(codes) {
930
- if (!codes) return null;
931
- let found;
932
- codes.forEach(code => {
933
- if (found) return;
934
- const cleanedLng = this.formatLanguageCode(code);
935
- if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
936
- });
937
- if (!found && this.options.supportedLngs) {
938
- codes.forEach(code => {
939
- if (found) return;
940
- const lngOnly = this.getLanguagePartFromCode(code);
941
- if (this.isSupportedCode(lngOnly)) return found = lngOnly;
942
- found = this.options.supportedLngs.find(supportedLng => {
943
- if (supportedLng === lngOnly) return supportedLng;
944
- if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return;
945
- if (supportedLng.indexOf('-') > 0 && lngOnly.indexOf('-') < 0 && supportedLng.substring(0, supportedLng.indexOf('-')) === lngOnly) return supportedLng;
946
- if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng;
947
- });
948
- });
949
- }
950
- if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
951
- return found;
952
- }
953
- getFallbackCodes(fallbacks, code) {
954
- if (!fallbacks) return [];
955
- if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
956
- if (isString(fallbacks)) fallbacks = [fallbacks];
957
- if (Array.isArray(fallbacks)) return fallbacks;
958
- if (!code) return fallbacks.default || [];
959
- let found = fallbacks[code];
960
- if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
961
- if (!found) found = fallbacks[this.formatLanguageCode(code)];
962
- if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
963
- if (!found) found = fallbacks.default;
964
- return found || [];
965
- }
966
- toResolveHierarchy(code, fallbackCode) {
967
- const fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
968
- const codes = [];
969
- const addCode = c => {
970
- if (!c) return;
971
- if (this.isSupportedCode(c)) {
972
- codes.push(c);
973
- } else {
974
- this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
975
- }
976
- };
977
- if (isString(code) && (code.indexOf('-') > -1 || code.indexOf('_') > -1)) {
978
- if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
979
- if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
980
- if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
981
- } else if (isString(code)) {
982
- addCode(this.formatLanguageCode(code));
983
- }
984
- fallbackCodes.forEach(fc => {
985
- if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
986
- });
987
- return codes;
988
- }
989
- }
990
-
991
- const suffixesOrder = {
992
- zero: 0,
993
- one: 1,
994
- two: 2,
995
- few: 3,
996
- many: 4,
997
- other: 5
998
- };
999
- const dummyRule = {
1000
- select: count => count === 1 ? 'one' : 'other',
1001
- resolvedOptions: () => ({
1002
- pluralCategories: ['one', 'other']
1003
- })
1004
- };
1005
- class PluralResolver {
1006
- constructor(languageUtils) {
1007
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1008
- this.languageUtils = languageUtils;
1009
- this.options = options;
1010
- this.logger = baseLogger.create('pluralResolver');
1011
- this.pluralRulesCache = {};
1012
- }
1013
- addRule(lng, obj) {
1014
- this.rules[lng] = obj;
1015
- }
1016
- clearCache() {
1017
- this.pluralRulesCache = {};
1018
- }
1019
- getRule(code) {
1020
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1021
- const cleanedCode = getCleanedCode(code === 'dev' ? 'en' : code);
1022
- const type = options.ordinal ? 'ordinal' : 'cardinal';
1023
- const cacheKey = JSON.stringify({
1024
- cleanedCode,
1025
- type
1026
- });
1027
- if (cacheKey in this.pluralRulesCache) {
1028
- return this.pluralRulesCache[cacheKey];
1029
- }
1030
- let rule;
1031
- try {
1032
- rule = new Intl.PluralRules(cleanedCode, {
1033
- type
1034
- });
1035
- } catch (err) {
1036
- if (!Intl) {
1037
- this.logger.error('No Intl support, please use an Intl polyfill!');
1038
- return dummyRule;
1039
- }
1040
- if (!code.match(/-|_/)) return dummyRule;
1041
- const lngPart = this.languageUtils.getLanguagePartFromCode(code);
1042
- rule = this.getRule(lngPart, options);
1043
- }
1044
- this.pluralRulesCache[cacheKey] = rule;
1045
- return rule;
1046
- }
1047
- needsPlural(code) {
1048
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1049
- let rule = this.getRule(code, options);
1050
- if (!rule) rule = this.getRule('dev', options);
1051
- return rule?.resolvedOptions().pluralCategories.length > 1;
1052
- }
1053
- getPluralFormsOfKey(code, key) {
1054
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1055
- return this.getSuffixes(code, options).map(suffix => `${key}${suffix}`);
1056
- }
1057
- getSuffixes(code) {
1058
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1059
- let rule = this.getRule(code, options);
1060
- if (!rule) rule = this.getRule('dev', options);
1061
- if (!rule) return [];
1062
- return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map(pluralCategory => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${pluralCategory}`);
1063
- }
1064
- getSuffix(code, count) {
1065
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1066
- const rule = this.getRule(code, options);
1067
- if (rule) {
1068
- return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${rule.select(count)}`;
1069
- }
1070
- this.logger.warn(`no plural rule found for: ${code}`);
1071
- return this.getSuffix('dev', count, options);
1072
- }
1073
- }
1074
-
1075
- const deepFindWithDefaults = function (data, defaultData, key) {
1076
- let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
1077
- let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
1078
- let path = getPathWithDefaults(data, defaultData, key);
1079
- if (!path && ignoreJSONStructure && isString(key)) {
1080
- path = deepFind(data, key, keySeparator);
1081
- if (path === undefined) path = deepFind(defaultData, key, keySeparator);
1082
- }
1083
- return path;
1084
- };
1085
- const regexSafe = val => val.replace(/\$/g, '$$$$');
1086
- class Interpolator {
1087
- constructor() {
1088
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1089
- this.logger = baseLogger.create('interpolator');
1090
- this.options = options;
1091
- this.format = options?.interpolation?.format || (value => value);
1092
- this.init(options);
1093
- }
1094
- init() {
1095
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1096
- if (!options.interpolation) options.interpolation = {
1097
- escapeValue: true
1098
- };
1099
- const {
1100
- escape: escape$1,
1101
- escapeValue,
1102
- useRawValueToEscape,
1103
- prefix,
1104
- prefixEscaped,
1105
- suffix,
1106
- suffixEscaped,
1107
- formatSeparator,
1108
- unescapeSuffix,
1109
- unescapePrefix,
1110
- nestingPrefix,
1111
- nestingPrefixEscaped,
1112
- nestingSuffix,
1113
- nestingSuffixEscaped,
1114
- nestingOptionsSeparator,
1115
- maxReplaces,
1116
- alwaysFormat
1117
- } = options.interpolation;
1118
- this.escape = escape$1 !== undefined ? escape$1 : escape;
1119
- this.escapeValue = escapeValue !== undefined ? escapeValue : true;
1120
- this.useRawValueToEscape = useRawValueToEscape !== undefined ? useRawValueToEscape : false;
1121
- this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || '{{';
1122
- this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || '}}';
1123
- this.formatSeparator = formatSeparator || ',';
1124
- this.unescapePrefix = unescapeSuffix ? '' : unescapePrefix || '-';
1125
- this.unescapeSuffix = this.unescapePrefix ? '' : unescapeSuffix || '';
1126
- this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape('$t(');
1127
- this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(')');
1128
- this.nestingOptionsSeparator = nestingOptionsSeparator || ',';
1129
- this.maxReplaces = maxReplaces || 1000;
1130
- this.alwaysFormat = alwaysFormat !== undefined ? alwaysFormat : false;
1131
- this.resetRegExp();
1132
- }
1133
- reset() {
1134
- if (this.options) this.init(this.options);
1135
- }
1136
- resetRegExp() {
1137
- const getOrResetRegExp = (existingRegExp, pattern) => {
1138
- if (existingRegExp?.source === pattern) {
1139
- existingRegExp.lastIndex = 0;
1140
- return existingRegExp;
1141
- }
1142
- return new RegExp(pattern, 'g');
1143
- };
1144
- this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
1145
- this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
1146
- this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}(.+?)${this.nestingSuffix}`);
1147
- }
1148
- interpolate(str, data, lng, options) {
1149
- let match;
1150
- let value;
1151
- let replaces;
1152
- const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
1153
- const handleFormat = key => {
1154
- if (key.indexOf(this.formatSeparator) < 0) {
1155
- const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
1156
- return this.alwaysFormat ? this.format(path, undefined, lng, {
1157
- ...options,
1158
- ...data,
1159
- interpolationkey: key
1160
- }) : path;
1161
- }
1162
- const p = key.split(this.formatSeparator);
1163
- const k = p.shift().trim();
1164
- const f = p.join(this.formatSeparator).trim();
1165
- return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
1166
- ...options,
1167
- ...data,
1168
- interpolationkey: k
1169
- });
1170
- };
1171
- this.resetRegExp();
1172
- const missingInterpolationHandler = options?.missingInterpolationHandler || this.options.missingInterpolationHandler;
1173
- const skipOnVariables = options?.interpolation?.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
1174
- const todos = [{
1175
- regex: this.regexpUnescape,
1176
- safeValue: val => regexSafe(val)
1177
- }, {
1178
- regex: this.regexp,
1179
- safeValue: val => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
1180
- }];
1181
- todos.forEach(todo => {
1182
- replaces = 0;
1183
- while (match = todo.regex.exec(str)) {
1184
- const matchedVar = match[1].trim();
1185
- value = handleFormat(matchedVar);
1186
- if (value === undefined) {
1187
- if (typeof missingInterpolationHandler === 'function') {
1188
- const temp = missingInterpolationHandler(str, match, options);
1189
- value = isString(temp) ? temp : '';
1190
- } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
1191
- value = '';
1192
- } else if (skipOnVariables) {
1193
- value = match[0];
1194
- continue;
1195
- } else {
1196
- this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
1197
- value = '';
1198
- }
1199
- } else if (!isString(value) && !this.useRawValueToEscape) {
1200
- value = makeString(value);
1201
- }
1202
- const safeValue = todo.safeValue(value);
1203
- str = str.replace(match[0], safeValue);
1204
- if (skipOnVariables) {
1205
- todo.regex.lastIndex += value.length;
1206
- todo.regex.lastIndex -= match[0].length;
1207
- } else {
1208
- todo.regex.lastIndex = 0;
1209
- }
1210
- replaces++;
1211
- if (replaces >= this.maxReplaces) {
1212
- break;
1213
- }
1214
- }
1215
- });
1216
- return str;
1217
- }
1218
- nest(str, fc) {
1219
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1220
- let match;
1221
- let value;
1222
- let clonedOptions;
1223
- const handleHasOptions = (key, inheritedOptions) => {
1224
- const sep = this.nestingOptionsSeparator;
1225
- if (key.indexOf(sep) < 0) return key;
1226
- const c = key.split(new RegExp(`${sep}[ ]*{`));
1227
- let optionsString = `{${c[1]}`;
1228
- key = c[0];
1229
- optionsString = this.interpolate(optionsString, clonedOptions);
1230
- const matchedSingleQuotes = optionsString.match(/'/g);
1231
- const matchedDoubleQuotes = optionsString.match(/"/g);
1232
- if ((matchedSingleQuotes?.length ?? 0) % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
1233
- optionsString = optionsString.replace(/'/g, '"');
1234
- }
1235
- try {
1236
- clonedOptions = JSON.parse(optionsString);
1237
- if (inheritedOptions) clonedOptions = {
1238
- ...inheritedOptions,
1239
- ...clonedOptions
1240
- };
1241
- } catch (e) {
1242
- this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
1243
- return `${key}${sep}${optionsString}`;
1244
- }
1245
- if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
1246
- return key;
1247
- };
1248
- while (match = this.nestingRegexp.exec(str)) {
1249
- let formatters = [];
1250
- clonedOptions = {
1251
- ...options
1252
- };
1253
- clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
1254
- clonedOptions.applyPostProcessor = false;
1255
- delete clonedOptions.defaultValue;
1256
- let doReduce = false;
1257
- if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {
1258
- const r = match[1].split(this.formatSeparator).map(elem => elem.trim());
1259
- match[1] = r.shift();
1260
- formatters = r;
1261
- doReduce = true;
1262
- }
1263
- value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
1264
- if (value && match[0] === str && !isString(value)) return value;
1265
- if (!isString(value)) value = makeString(value);
1266
- if (!value) {
1267
- this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
1268
- value = '';
1269
- }
1270
- if (doReduce) {
1271
- value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
1272
- ...options,
1273
- interpolationkey: match[1].trim()
1274
- }), value.trim());
1275
- }
1276
- str = str.replace(match[0], value);
1277
- this.regexp.lastIndex = 0;
1278
- }
1279
- return str;
1280
- }
1281
- }
1282
-
1283
- const parseFormatStr = formatStr => {
1284
- let formatName = formatStr.toLowerCase().trim();
1285
- const formatOptions = {};
1286
- if (formatStr.indexOf('(') > -1) {
1287
- const p = formatStr.split('(');
1288
- formatName = p[0].toLowerCase().trim();
1289
- const optStr = p[1].substring(0, p[1].length - 1);
1290
- if (formatName === 'currency' && optStr.indexOf(':') < 0) {
1291
- if (!formatOptions.currency) formatOptions.currency = optStr.trim();
1292
- } else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
1293
- if (!formatOptions.range) formatOptions.range = optStr.trim();
1294
- } else {
1295
- const opts = optStr.split(';');
1296
- opts.forEach(opt => {
1297
- if (opt) {
1298
- const [key, ...rest] = opt.split(':');
1299
- const val = rest.join(':').trim().replace(/^'+|'+$/g, '');
1300
- const trimmedKey = key.trim();
1301
- if (!formatOptions[trimmedKey]) formatOptions[trimmedKey] = val;
1302
- if (val === 'false') formatOptions[trimmedKey] = false;
1303
- if (val === 'true') formatOptions[trimmedKey] = true;
1304
- if (!isNaN(val)) formatOptions[trimmedKey] = parseInt(val, 10);
1305
- }
1306
- });
1307
- }
1308
- }
1309
- return {
1310
- formatName,
1311
- formatOptions
1312
- };
1313
- };
1314
- const createCachedFormatter = fn => {
1315
- const cache = {};
1316
- return (val, lng, options) => {
1317
- let optForCache = options;
1318
- if (options && options.interpolationkey && options.formatParams && options.formatParams[options.interpolationkey] && options[options.interpolationkey]) {
1319
- optForCache = {
1320
- ...optForCache,
1321
- [options.interpolationkey]: undefined
1322
- };
1323
- }
1324
- const key = lng + JSON.stringify(optForCache);
1325
- let formatter = cache[key];
1326
- if (!formatter) {
1327
- formatter = fn(getCleanedCode(lng), options);
1328
- cache[key] = formatter;
1329
- }
1330
- return formatter(val);
1331
- };
1332
- };
1333
- class Formatter {
1334
- constructor() {
1335
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1336
- this.logger = baseLogger.create('formatter');
1337
- this.options = options;
1338
- this.formats = {
1339
- number: createCachedFormatter((lng, opt) => {
1340
- const formatter = new Intl.NumberFormat(lng, {
1341
- ...opt
1342
- });
1343
- return val => formatter.format(val);
1344
- }),
1345
- currency: createCachedFormatter((lng, opt) => {
1346
- const formatter = new Intl.NumberFormat(lng, {
1347
- ...opt,
1348
- style: 'currency'
1349
- });
1350
- return val => formatter.format(val);
1351
- }),
1352
- datetime: createCachedFormatter((lng, opt) => {
1353
- const formatter = new Intl.DateTimeFormat(lng, {
1354
- ...opt
1355
- });
1356
- return val => formatter.format(val);
1357
- }),
1358
- relativetime: createCachedFormatter((lng, opt) => {
1359
- const formatter = new Intl.RelativeTimeFormat(lng, {
1360
- ...opt
1361
- });
1362
- return val => formatter.format(val, opt.range || 'day');
1363
- }),
1364
- list: createCachedFormatter((lng, opt) => {
1365
- const formatter = new Intl.ListFormat(lng, {
1366
- ...opt
1367
- });
1368
- return val => formatter.format(val);
1369
- })
1370
- };
1371
- this.init(options);
1372
- }
1373
- init(services) {
1374
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
1375
- interpolation: {}
1376
- };
1377
- this.formatSeparator = options.interpolation.formatSeparator || ',';
1378
- }
1379
- add(name, fc) {
1380
- this.formats[name.toLowerCase().trim()] = fc;
1381
- }
1382
- addCached(name, fc) {
1383
- this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
1384
- }
1385
- format(value, format, lng) {
1386
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1387
- const formats = format.split(this.formatSeparator);
1388
- if (formats.length > 1 && formats[0].indexOf('(') > 1 && formats[0].indexOf(')') < 0 && formats.find(f => f.indexOf(')') > -1)) {
1389
- const lastIndex = formats.findIndex(f => f.indexOf(')') > -1);
1390
- formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
1391
- }
1392
- const result = formats.reduce((mem, f) => {
1393
- const {
1394
- formatName,
1395
- formatOptions
1396
- } = parseFormatStr(f);
1397
- if (this.formats[formatName]) {
1398
- let formatted = mem;
1399
- try {
1400
- const valOptions = options?.formatParams?.[options.interpolationkey] || {};
1401
- const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
1402
- formatted = this.formats[formatName](mem, l, {
1403
- ...formatOptions,
1404
- ...options,
1405
- ...valOptions
1406
- });
1407
- } catch (error) {
1408
- this.logger.warn(error);
1409
- }
1410
- return formatted;
1411
- } else {
1412
- this.logger.warn(`there was no format function for ${formatName}`);
1413
- }
1414
- return mem;
1415
- }, value);
1416
- return result;
1417
- }
1418
- }
1419
-
1420
- const removePending = (q, name) => {
1421
- if (q.pending[name] !== undefined) {
1422
- delete q.pending[name];
1423
- q.pendingCount--;
1424
- }
1425
- };
1426
- class Connector extends EventEmitter {
1427
- constructor(backend, store, services) {
1428
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1429
- super();
1430
- this.backend = backend;
1431
- this.store = store;
1432
- this.services = services;
1433
- this.languageUtils = services.languageUtils;
1434
- this.options = options;
1435
- this.logger = baseLogger.create('backendConnector');
1436
- this.waitingReads = [];
1437
- this.maxParallelReads = options.maxParallelReads || 10;
1438
- this.readingCalls = 0;
1439
- this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
1440
- this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
1441
- this.state = {};
1442
- this.queue = [];
1443
- this.backend?.init?.(services, options.backend, options);
1444
- }
1445
- queueLoad(languages, namespaces, options, callback) {
1446
- const toLoad = {};
1447
- const pending = {};
1448
- const toLoadLanguages = {};
1449
- const toLoadNamespaces = {};
1450
- languages.forEach(lng => {
1451
- let hasAllNamespaces = true;
1452
- namespaces.forEach(ns => {
1453
- const name = `${lng}|${ns}`;
1454
- if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
1455
- this.state[name] = 2;
1456
- } else if (this.state[name] < 0) ; else if (this.state[name] === 1) {
1457
- if (pending[name] === undefined) pending[name] = true;
1458
- } else {
1459
- this.state[name] = 1;
1460
- hasAllNamespaces = false;
1461
- if (pending[name] === undefined) pending[name] = true;
1462
- if (toLoad[name] === undefined) toLoad[name] = true;
1463
- if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
1464
- }
1465
- });
1466
- if (!hasAllNamespaces) toLoadLanguages[lng] = true;
1467
- });
1468
- if (Object.keys(toLoad).length || Object.keys(pending).length) {
1469
- this.queue.push({
1470
- pending,
1471
- pendingCount: Object.keys(pending).length,
1472
- loaded: {},
1473
- errors: [],
1474
- callback
1475
- });
1476
- }
1477
- return {
1478
- toLoad: Object.keys(toLoad),
1479
- pending: Object.keys(pending),
1480
- toLoadLanguages: Object.keys(toLoadLanguages),
1481
- toLoadNamespaces: Object.keys(toLoadNamespaces)
1482
- };
1483
- }
1484
- loaded(name, err, data) {
1485
- const s = name.split('|');
1486
- const lng = s[0];
1487
- const ns = s[1];
1488
- if (err) this.emit('failedLoading', lng, ns, err);
1489
- if (!err && data) {
1490
- this.store.addResourceBundle(lng, ns, data, undefined, undefined, {
1491
- skipCopy: true
1492
- });
1493
- }
1494
- this.state[name] = err ? -1 : 2;
1495
- if (err && data) this.state[name] = 0;
1496
- const loaded = {};
1497
- this.queue.forEach(q => {
1498
- pushPath(q.loaded, [lng], ns);
1499
- removePending(q, name);
1500
- if (err) q.errors.push(err);
1501
- if (q.pendingCount === 0 && !q.done) {
1502
- Object.keys(q.loaded).forEach(l => {
1503
- if (!loaded[l]) loaded[l] = {};
1504
- const loadedKeys = q.loaded[l];
1505
- if (loadedKeys.length) {
1506
- loadedKeys.forEach(n => {
1507
- if (loaded[l][n] === undefined) loaded[l][n] = true;
1508
- });
1509
- }
1510
- });
1511
- q.done = true;
1512
- if (q.errors.length) {
1513
- q.callback(q.errors);
1514
- } else {
1515
- q.callback();
1516
- }
1517
- }
1518
- });
1519
- this.emit('loaded', loaded);
1520
- this.queue = this.queue.filter(q => !q.done);
1521
- }
1522
- read(lng, ns, fcName) {
1523
- let tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1524
- let wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
1525
- let callback = arguments.length > 5 ? arguments[5] : undefined;
1526
- if (!lng.length) return callback(null, {});
1527
- if (this.readingCalls >= this.maxParallelReads) {
1528
- this.waitingReads.push({
1529
- lng,
1530
- ns,
1531
- fcName,
1532
- tried,
1533
- wait,
1534
- callback
1535
- });
1536
- return;
1537
- }
1538
- this.readingCalls++;
1539
- const resolver = (err, data) => {
1540
- this.readingCalls--;
1541
- if (this.waitingReads.length > 0) {
1542
- const next = this.waitingReads.shift();
1543
- this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
1544
- }
1545
- if (err && data && tried < this.maxRetries) {
1546
- setTimeout(() => {
1547
- this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
1548
- }, wait);
1549
- return;
1550
- }
1551
- callback(err, data);
1552
- };
1553
- const fc = this.backend[fcName].bind(this.backend);
1554
- if (fc.length === 2) {
1555
- try {
1556
- const r = fc(lng, ns);
1557
- if (r && typeof r.then === 'function') {
1558
- r.then(data => resolver(null, data)).catch(resolver);
1559
- } else {
1560
- resolver(null, r);
1561
- }
1562
- } catch (err) {
1563
- resolver(err);
1564
- }
1565
- return;
1566
- }
1567
- return fc(lng, ns, resolver);
1568
- }
1569
- prepareLoading(languages, namespaces) {
1570
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1571
- let callback = arguments.length > 3 ? arguments[3] : undefined;
1572
- if (!this.backend) {
1573
- this.logger.warn('No backend was added via i18next.use. Will not load resources.');
1574
- return callback && callback();
1575
- }
1576
- if (isString(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
1577
- if (isString(namespaces)) namespaces = [namespaces];
1578
- const toLoad = this.queueLoad(languages, namespaces, options, callback);
1579
- if (!toLoad.toLoad.length) {
1580
- if (!toLoad.pending.length) callback();
1581
- return null;
1582
- }
1583
- toLoad.toLoad.forEach(name => {
1584
- this.loadOne(name);
1585
- });
1586
- }
1587
- load(languages, namespaces, callback) {
1588
- this.prepareLoading(languages, namespaces, {}, callback);
1589
- }
1590
- reload(languages, namespaces, callback) {
1591
- this.prepareLoading(languages, namespaces, {
1592
- reload: true
1593
- }, callback);
1594
- }
1595
- loadOne(name) {
1596
- let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1597
- const s = name.split('|');
1598
- const lng = s[0];
1599
- const ns = s[1];
1600
- this.read(lng, ns, 'read', undefined, undefined, (err, data) => {
1601
- if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
1602
- if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
1603
- this.loaded(name, err, data);
1604
- });
1605
- }
1606
- saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
1607
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
1608
- let clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : () => {};
1609
- if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(namespace)) {
1610
- 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!!!');
1611
- return;
1612
- }
1613
- if (key === undefined || key === null || key === '') return;
1614
- if (this.backend?.create) {
1615
- const opts = {
1616
- ...options,
1617
- isUpdate
1618
- };
1619
- const fc = this.backend.create.bind(this.backend);
1620
- if (fc.length < 6) {
1621
- try {
1622
- let r;
1623
- if (fc.length === 5) {
1624
- r = fc(languages, namespace, key, fallbackValue, opts);
1625
- } else {
1626
- r = fc(languages, namespace, key, fallbackValue);
1627
- }
1628
- if (r && typeof r.then === 'function') {
1629
- r.then(data => clb(null, data)).catch(clb);
1630
- } else {
1631
- clb(null, r);
1632
- }
1633
- } catch (err) {
1634
- clb(err);
1635
- }
1636
- } else {
1637
- fc(languages, namespace, key, fallbackValue, clb, opts);
1638
- }
1639
- }
1640
- if (!languages || !languages[0]) return;
1641
- this.store.addResource(languages[0], namespace, key, fallbackValue);
1642
- }
1643
- }
1644
-
1645
- const get = () => ({
1646
- debug: false,
1647
- initAsync: true,
1648
- ns: ['translation'],
1649
- defaultNS: ['translation'],
1650
- fallbackLng: ['dev'],
1651
- fallbackNS: false,
1652
- supportedLngs: false,
1653
- nonExplicitSupportedLngs: false,
1654
- load: 'all',
1655
- preload: false,
1656
- simplifyPluralSuffix: true,
1657
- keySeparator: '.',
1658
- nsSeparator: ':',
1659
- pluralSeparator: '_',
1660
- contextSeparator: '_',
1661
- partialBundledLanguages: false,
1662
- saveMissing: false,
1663
- updateMissing: false,
1664
- saveMissingTo: 'fallback',
1665
- saveMissingPlurals: true,
1666
- missingKeyHandler: false,
1667
- missingInterpolationHandler: false,
1668
- postProcess: false,
1669
- postProcessPassResolved: false,
1670
- returnNull: false,
1671
- returnEmptyString: true,
1672
- returnObjects: false,
1673
- joinArrays: false,
1674
- returnedObjectHandler: false,
1675
- parseMissingKeyHandler: false,
1676
- appendNamespaceToMissingKey: false,
1677
- appendNamespaceToCIMode: false,
1678
- overloadTranslationOptionHandler: args => {
1679
- let ret = {};
1680
- if (typeof args[1] === 'object') ret = args[1];
1681
- if (isString(args[1])) ret.defaultValue = args[1];
1682
- if (isString(args[2])) ret.tDescription = args[2];
1683
- if (typeof args[2] === 'object' || typeof args[3] === 'object') {
1684
- const options = args[3] || args[2];
1685
- Object.keys(options).forEach(key => {
1686
- ret[key] = options[key];
1687
- });
1688
- }
1689
- return ret;
1690
- },
1691
- interpolation: {
1692
- escapeValue: true,
1693
- format: value => value,
1694
- prefix: '{{',
1695
- suffix: '}}',
1696
- formatSeparator: ',',
1697
- unescapePrefix: '-',
1698
- nestingPrefix: '$t(',
1699
- nestingSuffix: ')',
1700
- nestingOptionsSeparator: ',',
1701
- maxReplaces: 1000,
1702
- skipOnVariables: true
1703
- }
1704
- });
1705
- const transformOptions = options => {
1706
- if (isString(options.ns)) options.ns = [options.ns];
1707
- if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
1708
- if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
1709
- if (options.supportedLngs?.indexOf?.('cimode') < 0) {
1710
- options.supportedLngs = options.supportedLngs.concat(['cimode']);
1711
- }
1712
- if (typeof options.initImmediate === 'boolean') options.initAsync = options.initImmediate;
1713
- return options;
1714
- };
1715
-
1716
- const noop = () => {};
1717
- const bindMemberFunctions = inst => {
1718
- const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
1719
- mems.forEach(mem => {
1720
- if (typeof inst[mem] === 'function') {
1721
- inst[mem] = inst[mem].bind(inst);
1722
- }
1723
- });
1724
- };
1725
- class I18n extends EventEmitter {
1726
- constructor() {
1727
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1728
- let callback = arguments.length > 1 ? arguments[1] : undefined;
1729
- super();
1730
- this.options = transformOptions(options);
1731
- this.services = {};
1732
- this.logger = baseLogger;
1733
- this.modules = {
1734
- external: []
1735
- };
1736
- bindMemberFunctions(this);
1737
- if (callback && !this.isInitialized && !options.isClone) {
1738
- if (!this.options.initAsync) {
1739
- this.init(options, callback);
1740
- return this;
1741
- }
1742
- setTimeout(() => {
1743
- this.init(options, callback);
1744
- }, 0);
1745
- }
1746
- }
1747
- init() {
1748
- var _this = this;
1749
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1750
- let callback = arguments.length > 1 ? arguments[1] : undefined;
1751
- this.isInitializing = true;
1752
- if (typeof options === 'function') {
1753
- callback = options;
1754
- options = {};
1755
- }
1756
- if (options.defaultNS == null && options.ns) {
1757
- if (isString(options.ns)) {
1758
- options.defaultNS = options.ns;
1759
- } else if (options.ns.indexOf('translation') < 0) {
1760
- options.defaultNS = options.ns[0];
1761
- }
1762
- }
1763
- const defOpts = get();
1764
- this.options = {
1765
- ...defOpts,
1766
- ...this.options,
1767
- ...transformOptions(options)
1768
- };
1769
- this.options.interpolation = {
1770
- ...defOpts.interpolation,
1771
- ...this.options.interpolation
1772
- };
1773
- if (options.keySeparator !== undefined) {
1774
- this.options.userDefinedKeySeparator = options.keySeparator;
1775
- }
1776
- if (options.nsSeparator !== undefined) {
1777
- this.options.userDefinedNsSeparator = options.nsSeparator;
1778
- }
1779
- const createClassOnDemand = ClassOrObject => {
1780
- if (!ClassOrObject) return null;
1781
- if (typeof ClassOrObject === 'function') return new ClassOrObject();
1782
- return ClassOrObject;
1783
- };
1784
- if (!this.options.isClone) {
1785
- if (this.modules.logger) {
1786
- baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
1787
- } else {
1788
- baseLogger.init(null, this.options);
1789
- }
1790
- let formatter;
1791
- if (this.modules.formatter) {
1792
- formatter = this.modules.formatter;
1793
- } else {
1794
- formatter = Formatter;
1795
- }
1796
- const lu = new LanguageUtil(this.options);
1797
- this.store = new ResourceStore(this.options.resources, this.options);
1798
- const s = this.services;
1799
- s.logger = baseLogger;
1800
- s.resourceStore = this.store;
1801
- s.languageUtils = lu;
1802
- s.pluralResolver = new PluralResolver(lu, {
1803
- prepend: this.options.pluralSeparator,
1804
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
1805
- });
1806
- if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
1807
- s.formatter = createClassOnDemand(formatter);
1808
- s.formatter.init(s, this.options);
1809
- this.options.interpolation.format = s.formatter.format.bind(s.formatter);
1810
- }
1811
- s.interpolator = new Interpolator(this.options);
1812
- s.utils = {
1813
- hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
1814
- };
1815
- s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
1816
- s.backendConnector.on('*', function (event) {
1817
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1818
- args[_key - 1] = arguments[_key];
1819
- }
1820
- _this.emit(event, ...args);
1821
- });
1822
- if (this.modules.languageDetector) {
1823
- s.languageDetector = createClassOnDemand(this.modules.languageDetector);
1824
- if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
1825
- }
1826
- if (this.modules.i18nFormat) {
1827
- s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
1828
- if (s.i18nFormat.init) s.i18nFormat.init(this);
1829
- }
1830
- this.translator = new Translator(this.services, this.options);
1831
- this.translator.on('*', function (event) {
1832
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1833
- args[_key2 - 1] = arguments[_key2];
1834
- }
1835
- _this.emit(event, ...args);
1836
- });
1837
- this.modules.external.forEach(m => {
1838
- if (m.init) m.init(this);
1839
- });
1840
- }
1841
- this.format = this.options.interpolation.format;
1842
- if (!callback) callback = noop;
1843
- if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1844
- const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1845
- if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
1846
- }
1847
- if (!this.services.languageDetector && !this.options.lng) {
1848
- this.logger.warn('init: no languageDetector is used and no lng is defined');
1849
- }
1850
- const storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
1851
- storeApi.forEach(fcName => {
1852
- this[fcName] = function () {
1853
- return _this.store[fcName](...arguments);
1854
- };
1855
- });
1856
- const storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
1857
- storeApiChained.forEach(fcName => {
1858
- this[fcName] = function () {
1859
- _this.store[fcName](...arguments);
1860
- return _this;
1861
- };
1862
- });
1863
- const deferred = defer();
1864
- const load = () => {
1865
- const finish = (err, t) => {
1866
- this.isInitializing = false;
1867
- if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn('init: i18next is already initialized. You should call init just once!');
1868
- this.isInitialized = true;
1869
- if (!this.options.isClone) this.logger.log('initialized', this.options);
1870
- this.emit('initialized', this.options);
1871
- deferred.resolve(t);
1872
- callback(err, t);
1873
- };
1874
- if (this.languages && !this.isInitialized) return finish(null, this.t.bind(this));
1875
- this.changeLanguage(this.options.lng, finish);
1876
- };
1877
- if (this.options.resources || !this.options.initAsync) {
1878
- load();
1879
- } else {
1880
- setTimeout(load, 0);
1881
- }
1882
- return deferred;
1883
- }
1884
- loadResources(language) {
1885
- let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
1886
- let usedCallback = callback;
1887
- const usedLng = isString(language) ? language : this.language;
1888
- if (typeof language === 'function') usedCallback = language;
1889
- if (!this.options.resources || this.options.partialBundledLanguages) {
1890
- if (usedLng?.toLowerCase() === 'cimode' && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
1891
- const toLoad = [];
1892
- const append = lng => {
1893
- if (!lng) return;
1894
- if (lng === 'cimode') return;
1895
- const lngs = this.services.languageUtils.toResolveHierarchy(lng);
1896
- lngs.forEach(l => {
1897
- if (l === 'cimode') return;
1898
- if (toLoad.indexOf(l) < 0) toLoad.push(l);
1899
- });
1900
- };
1901
- if (!usedLng) {
1902
- const fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1903
- fallbacks.forEach(l => append(l));
1904
- } else {
1905
- append(usedLng);
1906
- }
1907
- this.options.preload?.forEach?.(l => append(l));
1908
- this.services.backendConnector.load(toLoad, this.options.ns, e => {
1909
- if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
1910
- usedCallback(e);
1911
- });
1912
- } else {
1913
- usedCallback(null);
1914
- }
1915
- }
1916
- reloadResources(lngs, ns, callback) {
1917
- const deferred = defer();
1918
- if (typeof lngs === 'function') {
1919
- callback = lngs;
1920
- lngs = undefined;
1921
- }
1922
- if (typeof ns === 'function') {
1923
- callback = ns;
1924
- ns = undefined;
1925
- }
1926
- if (!lngs) lngs = this.languages;
1927
- if (!ns) ns = this.options.ns;
1928
- if (!callback) callback = noop;
1929
- this.services.backendConnector.reload(lngs, ns, err => {
1930
- deferred.resolve();
1931
- callback(err);
1932
- });
1933
- return deferred;
1934
- }
1935
- use(module) {
1936
- if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
1937
- if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
1938
- if (module.type === 'backend') {
1939
- this.modules.backend = module;
1940
- }
1941
- if (module.type === 'logger' || module.log && module.warn && module.error) {
1942
- this.modules.logger = module;
1943
- }
1944
- if (module.type === 'languageDetector') {
1945
- this.modules.languageDetector = module;
1946
- }
1947
- if (module.type === 'i18nFormat') {
1948
- this.modules.i18nFormat = module;
1949
- }
1950
- if (module.type === 'postProcessor') {
1951
- postProcessor.addPostProcessor(module);
1952
- }
1953
- if (module.type === 'formatter') {
1954
- this.modules.formatter = module;
1955
- }
1956
- if (module.type === '3rdParty') {
1957
- this.modules.external.push(module);
1958
- }
1959
- return this;
1960
- }
1961
- setResolvedLanguage(l) {
1962
- if (!l || !this.languages) return;
1963
- if (['cimode', 'dev'].indexOf(l) > -1) return;
1964
- for (let li = 0; li < this.languages.length; li++) {
1965
- const lngInLngs = this.languages[li];
1966
- if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
1967
- if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
1968
- this.resolvedLanguage = lngInLngs;
1969
- break;
1970
- }
1971
- }
1972
- }
1973
- changeLanguage(lng, callback) {
1974
- var _this2 = this;
1975
- this.isLanguageChangingTo = lng;
1976
- const deferred = defer();
1977
- this.emit('languageChanging', lng);
1978
- const setLngProps = l => {
1979
- this.language = l;
1980
- this.languages = this.services.languageUtils.toResolveHierarchy(l);
1981
- this.resolvedLanguage = undefined;
1982
- this.setResolvedLanguage(l);
1983
- };
1984
- const done = (err, l) => {
1985
- if (l) {
1986
- setLngProps(l);
1987
- this.translator.changeLanguage(l);
1988
- this.isLanguageChangingTo = undefined;
1989
- this.emit('languageChanged', l);
1990
- this.logger.log('languageChanged', l);
1991
- } else {
1992
- this.isLanguageChangingTo = undefined;
1993
- }
1994
- deferred.resolve(function () {
1995
- return _this2.t(...arguments);
1996
- });
1997
- if (callback) callback(err, function () {
1998
- return _this2.t(...arguments);
1999
- });
2000
- };
2001
- const setLng = lngs => {
2002
- if (!lng && !lngs && this.services.languageDetector) lngs = [];
2003
- const l = isString(lngs) ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
2004
- if (l) {
2005
- if (!this.language) {
2006
- setLngProps(l);
2007
- }
2008
- if (!this.translator.language) this.translator.changeLanguage(l);
2009
- this.services.languageDetector?.cacheUserLanguage?.(l);
2010
- }
2011
- this.loadResources(l, err => {
2012
- done(err, l);
2013
- });
2014
- };
2015
- if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
2016
- setLng(this.services.languageDetector.detect());
2017
- } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
2018
- if (this.services.languageDetector.detect.length === 0) {
2019
- this.services.languageDetector.detect().then(setLng);
2020
- } else {
2021
- this.services.languageDetector.detect(setLng);
2022
- }
2023
- } else {
2024
- setLng(lng);
2025
- }
2026
- return deferred;
2027
- }
2028
- getFixedT(lng, ns, keyPrefix) {
2029
- var _this3 = this;
2030
- const fixedT = function (key, opts) {
2031
- let options;
2032
- if (typeof opts !== 'object') {
2033
- for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
2034
- rest[_key3 - 2] = arguments[_key3];
2035
- }
2036
- options = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2037
- } else {
2038
- options = {
2039
- ...opts
2040
- };
2041
- }
2042
- options.lng = options.lng || fixedT.lng;
2043
- options.lngs = options.lngs || fixedT.lngs;
2044
- options.ns = options.ns || fixedT.ns;
2045
- if (options.keyPrefix !== '') options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
2046
- const keySeparator = _this3.options.keySeparator || '.';
2047
- let resultKey;
2048
- if (options.keyPrefix && Array.isArray(key)) {
2049
- resultKey = key.map(k => `${options.keyPrefix}${keySeparator}${k}`);
2050
- } else {
2051
- resultKey = options.keyPrefix ? `${options.keyPrefix}${keySeparator}${key}` : key;
2052
- }
2053
- return _this3.t(resultKey, options);
2054
- };
2055
- if (isString(lng)) {
2056
- fixedT.lng = lng;
2057
- } else {
2058
- fixedT.lngs = lng;
2059
- }
2060
- fixedT.ns = ns;
2061
- fixedT.keyPrefix = keyPrefix;
2062
- return fixedT;
2063
- }
2064
- t() {
2065
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
2066
- args[_key4] = arguments[_key4];
2067
- }
2068
- return this.translator?.translate(...args);
2069
- }
2070
- exists() {
2071
- for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
2072
- args[_key5] = arguments[_key5];
2073
- }
2074
- return this.translator?.exists(...args);
2075
- }
2076
- setDefaultNamespace(ns) {
2077
- this.options.defaultNS = ns;
2078
- }
2079
- hasLoadedNamespace(ns) {
2080
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2081
- if (!this.isInitialized) {
2082
- this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
2083
- return false;
2084
- }
2085
- if (!this.languages || !this.languages.length) {
2086
- this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
2087
- return false;
2088
- }
2089
- const lng = options.lng || this.resolvedLanguage || this.languages[0];
2090
- const fallbackLng = this.options ? this.options.fallbackLng : false;
2091
- const lastLng = this.languages[this.languages.length - 1];
2092
- if (lng.toLowerCase() === 'cimode') return true;
2093
- const loadNotPending = (l, n) => {
2094
- const loadState = this.services.backendConnector.state[`${l}|${n}`];
2095
- return loadState === -1 || loadState === 0 || loadState === 2;
2096
- };
2097
- if (options.precheck) {
2098
- const preResult = options.precheck(this, loadNotPending);
2099
- if (preResult !== undefined) return preResult;
2100
- }
2101
- if (this.hasResourceBundle(lng, ns)) return true;
2102
- if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
2103
- if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
2104
- return false;
2105
- }
2106
- loadNamespaces(ns, callback) {
2107
- const deferred = defer();
2108
- if (!this.options.ns) {
2109
- if (callback) callback();
2110
- return Promise.resolve();
2111
- }
2112
- if (isString(ns)) ns = [ns];
2113
- ns.forEach(n => {
2114
- if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
2115
- });
2116
- this.loadResources(err => {
2117
- deferred.resolve();
2118
- if (callback) callback(err);
2119
- });
2120
- return deferred;
2121
- }
2122
- loadLanguages(lngs, callback) {
2123
- const deferred = defer();
2124
- if (isString(lngs)) lngs = [lngs];
2125
- const preloaded = this.options.preload || [];
2126
- const newLngs = lngs.filter(lng => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
2127
- if (!newLngs.length) {
2128
- if (callback) callback();
2129
- return Promise.resolve();
2130
- }
2131
- this.options.preload = preloaded.concat(newLngs);
2132
- this.loadResources(err => {
2133
- deferred.resolve();
2134
- if (callback) callback(err);
2135
- });
2136
- return deferred;
2137
- }
2138
- dir(lng) {
2139
- if (!lng) lng = this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language);
2140
- if (!lng) return 'rtl';
2141
- 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'];
2142
- const languageUtils = this.services?.languageUtils || new LanguageUtil(get());
2143
- return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
2144
- }
2145
- static createInstance() {
2146
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2147
- let callback = arguments.length > 1 ? arguments[1] : undefined;
2148
- return new I18n(options, callback);
2149
- }
2150
- cloneInstance() {
2151
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2152
- let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
2153
- const forkResourceStore = options.forkResourceStore;
2154
- if (forkResourceStore) delete options.forkResourceStore;
2155
- const mergedOptions = {
2156
- ...this.options,
2157
- ...options,
2158
- ...{
2159
- isClone: true
2160
- }
2161
- };
2162
- const clone = new I18n(mergedOptions);
2163
- if (options.debug !== undefined || options.prefix !== undefined) {
2164
- clone.logger = clone.logger.clone(options);
2165
- }
2166
- const membersToCopy = ['store', 'services', 'language'];
2167
- membersToCopy.forEach(m => {
2168
- clone[m] = this[m];
2169
- });
2170
- clone.services = {
2171
- ...this.services
2172
- };
2173
- clone.services.utils = {
2174
- hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2175
- };
2176
- if (forkResourceStore) {
2177
- const clonedData = Object.keys(this.store.data).reduce((prev, l) => {
2178
- prev[l] = {
2179
- ...this.store.data[l]
2180
- };
2181
- return Object.keys(prev[l]).reduce((acc, n) => {
2182
- acc[n] = {
2183
- ...prev[l][n]
2184
- };
2185
- return acc;
2186
- }, {});
2187
- }, {});
2188
- clone.store = new ResourceStore(clonedData, mergedOptions);
2189
- clone.services.resourceStore = clone.store;
2190
- }
2191
- clone.translator = new Translator(clone.services, mergedOptions);
2192
- clone.translator.on('*', function (event) {
2193
- for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
2194
- args[_key6 - 1] = arguments[_key6];
2195
- }
2196
- clone.emit(event, ...args);
2197
- });
2198
- clone.init(mergedOptions, callback);
2199
- clone.translator.options = mergedOptions;
2200
- clone.translator.backendConnector.services.utils = {
2201
- hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2202
- };
2203
- return clone;
2204
- }
2205
- toJSON() {
2206
- return {
2207
- options: this.options,
2208
- store: this.store,
2209
- language: this.language,
2210
- languages: this.languages,
2211
- resolvedLanguage: this.resolvedLanguage
2212
- };
2213
- }
2214
- }
2215
- const instance = I18n.createInstance();
2216
- instance.createInstance = I18n.createInstance;
2217
-
2218
- function getWindow() {
2219
- return window;
2220
- }
2221
- function getAtomicEnvironment() {
2222
- return {
2223
- version: "3.28.0-pre.c758e56a2c",
2224
- headlessVersion: VERSION,
2225
- };
2226
- }
2227
- function setCoveoGlobal(globalVariableName) {
2228
- if (getWindow()[globalVariableName]) {
2229
- return;
2230
- }
2231
- getWindow()[globalVariableName] = getAtomicEnvironment();
2232
- }
2233
-
2234
- const locales = {
2235
- af: () => import('./af.js').then(function (n) { return n.a; }),
2236
- am: () => import('./am.js').then(function (n) { return n.a; }),
2237
- 'ar-DZ': () => import('./ar-dz.js').then(function (n) { return n.a; }),
2238
- 'ar-IQ': () => import('./ar-iq.js').then(function (n) { return n.a; }),
2239
- 'ar-KW': () => import('./ar-kw.js').then(function (n) { return n.a; }),
2240
- 'ar-LY': () => import('./ar-ly.js').then(function (n) { return n.a; }),
2241
- 'ar-MA': () => import('./ar-ma.js').then(function (n) { return n.a; }),
2242
- 'ar-SA': () => import('./ar-sa.js').then(function (n) { return n.a; }),
2243
- 'ar-TN': () => import('./ar-tn.js').then(function (n) { return n.a; }),
2244
- ar: () => import('./ar.js').then(function (n) { return n.a; }),
2245
- az: () => import('./az.js').then(function (n) { return n.a; }),
2246
- be: () => import('./be.js').then(function (n) { return n.b; }),
2247
- bg: () => import('./bg.js').then(function (n) { return n.b; }),
2248
- bi: () => import('./bi.js').then(function (n) { return n.b; }),
2249
- bm: () => import('./bm.js').then(function (n) { return n.b; }),
2250
- 'bn-BD': () => import('./bn-bd.js').then(function (n) { return n.b; }),
2251
- bn: () => import('./bn.js').then(function (n) { return n.b; }),
2252
- bo: () => import('./bo.js').then(function (n) { return n.b; }),
2253
- br: () => import('./br.js').then(function (n) { return n.b; }),
2254
- bs: () => import('./bs.js').then(function (n) { return n.b; }),
2255
- ca: () => import('./ca.js').then(function (n) { return n.c; }),
2256
- cs: () => import('./cs.js').then(function (n) { return n.c; }),
2257
- cv: () => import('./cv.js').then(function (n) { return n.c; }),
2258
- cy: () => import('./cy.js').then(function (n) { return n.c; }),
2259
- 'de-AT': () => import('./de-at.js').then(function (n) { return n.d; }),
2260
- da: () => import('./da.js').then(function (n) { return n.d; }),
2261
- 'de-CH': () => import('./de-ch.js').then(function (n) { return n.d; }),
2262
- de: () => import('./de.js').then(function (n) { return n.d; }),
2263
- dv: () => import('./dv.js').then(function (n) { return n.d; }),
2264
- el: () => import('./el.js').then(function (n) { return n.e; }),
2265
- 'en-AU': () => import('./en-au.js').then(function (n) { return n.e; }),
2266
- 'en-CA': () => import('./en-ca.js').then(function (n) { return n.e; }),
2267
- 'en-GB': () => import('./en-gb.js').then(function (n) { return n.e; }),
2268
- 'en-IE': () => import('./en-ie.js').then(function (n) { return n.e; }),
2269
- 'en-IL': () => import('./en-il.js').then(function (n) { return n.e; }),
2270
- 'en-IN': () => import('./en-in.js').then(function (n) { return n.e; }),
2271
- 'en-NZ': () => import('./en-nz.js').then(function (n) { return n.e; }),
2272
- 'en-SG': () => import('./en-sg.js').then(function (n) { return n.e; }),
2273
- 'en-TT': () => import('./en-tt.js').then(function (n) { return n.e; }),
2274
- eo: () => import('./eo.js').then(function (n) { return n.e; }),
2275
- en: () => import('./en.js').then(function (n) { return n.e; }),
2276
- 'es-DO': () => import('./es-do.js').then(function (n) { return n.e; }),
2277
- 'es-MX': () => import('./es-mx.js').then(function (n) { return n.e; }),
2278
- 'es-PR': () => import('./es-pr.js').then(function (n) { return n.e; }),
2279
- 'es-US': () => import('./es-us.js').then(function (n) { return n.e; }),
2280
- et: () => import('./et.js').then(function (n) { return n.e; }),
2281
- es: () => import('./es.js').then(function (n) { return n.e; }),
2282
- eu: () => import('./eu.js').then(function (n) { return n.e; }),
2283
- fa: () => import('./fa.js').then(function (n) { return n.f; }),
2284
- fo: () => import('./fo.js').then(function (n) { return n.f; }),
2285
- fi: () => import('./fi.js').then(function (n) { return n.f; }),
2286
- 'fr-CA': () => import('./fr-ca.js').then(function (n) { return n.f; }),
2287
- 'fr-CH': () => import('./fr-ch.js').then(function (n) { return n.f; }),
2288
- fr: () => import('./fr.js').then(function (n) { return n.f; }),
2289
- fy: () => import('./fy.js').then(function (n) { return n.f; }),
2290
- ga: () => import('./ga.js').then(function (n) { return n.g; }),
2291
- gd: () => import('./gd.js').then(function (n) { return n.g; }),
2292
- 'gom-LATN': () => import('./gom-latn.js').then(function (n) { return n.g; }),
2293
- gl: () => import('./gl.js').then(function (n) { return n.g; }),
2294
- gu: () => import('./gu.js').then(function (n) { return n.g; }),
2295
- he: () => import('./he.js').then(function (n) { return n.h; }),
2296
- hi: () => import('./hi.js').then(function (n) { return n.h; }),
2297
- hr: () => import('./hr.js').then(function (n) { return n.h; }),
2298
- hu: () => import('./hu.js').then(function (n) { return n.h; }),
2299
- ht: () => import('./ht.js').then(function (n) { return n.h; }),
2300
- 'hy-AM': () => import('./hy-am.js').then(function (n) { return n.h; }),
2301
- id: () => import('./id.js').then(function (n) { return n.i; }),
2302
- is: () => import('./is.js').then(function (n) { return n.i; }),
2303
- 'it-CH': () => import('./it-ch.js').then(function (n) { return n.i; }),
2304
- it: () => import('./it.js').then(function (n) { return n.i; }),
2305
- ja: () => import('./ja.js').then(function (n) { return n.j; }),
2306
- jv: () => import('./jv.js').then(function (n) { return n.j; }),
2307
- ka: () => import('./ka.js').then(function (n) { return n.k; }),
2308
- kk: () => import('./kk.js').then(function (n) { return n.k; }),
2309
- km: () => import('./km.js').then(function (n) { return n.k; }),
2310
- kn: () => import('./kn.js').then(function (n) { return n.k; }),
2311
- ko: () => import('./ko.js').then(function (n) { return n.k; }),
2312
- ku: () => import('./ku.js').then(function (n) { return n.k; }),
2313
- ky: () => import('./ky.js').then(function (n) { return n.k; }),
2314
- lb: () => import('./lb.js').then(function (n) { return n.l; }),
2315
- lo: () => import('./lo.js').then(function (n) { return n.l; }),
2316
- lt: () => import('./lt.js').then(function (n) { return n.l; }),
2317
- lv: () => import('./lv.js').then(function (n) { return n.l; }),
2318
- me: () => import('./me.js').then(function (n) { return n.m; }),
2319
- mi: () => import('./mi.js').then(function (n) { return n.m; }),
2320
- mk: () => import('./mk.js').then(function (n) { return n.m; }),
2321
- ml: () => import('./ml.js').then(function (n) { return n.m; }),
2322
- mn: () => import('./mn.js').then(function (n) { return n.m; }),
2323
- mr: () => import('./mr.js').then(function (n) { return n.m; }),
2324
- 'ms-MY': () => import('./ms-my.js').then(function (n) { return n.m; }),
2325
- ms: () => import('./ms.js').then(function (n) { return n.m; }),
2326
- mt: () => import('./mt.js').then(function (n) { return n.m; }),
2327
- my: () => import('./my.js').then(function (n) { return n.m; }),
2328
- nb: () => import('./nb.js').then(function (n) { return n.n; }),
2329
- ne: () => import('./ne.js').then(function (n) { return n.n; }),
2330
- 'nl-BE': () => import('./nl-be.js').then(function (n) { return n.n; }),
2331
- nl: () => import('./nl.js').then(function (n) { return n.n; }),
2332
- pl: () => import('./pl.js').then(function (n) { return n.p; }),
2333
- 'pt-BR': () => import('./pt-br.js').then(function (n) { return n.p; }),
2334
- pt: () => import('./pt.js').then(function (n) { return n.p; }),
2335
- rn: () => import('./rn.js').then(function (n) { return n.r; }),
2336
- ro: () => import('./ro.js').then(function (n) { return n.r; }),
2337
- ru: () => import('./ru.js').then(function (n) { return n.r; }),
2338
- rw: () => import('./rw.js').then(function (n) { return n.r; }),
2339
- sd: () => import('./sd.js').then(function (n) { return n.s; }),
2340
- se: () => import('./se.js').then(function (n) { return n.s; }),
2341
- si: () => import('./si.js').then(function (n) { return n.s; }),
2342
- sk: () => import('./sk.js').then(function (n) { return n.s; }),
2343
- sl: () => import('./sl.js').then(function (n) { return n.s; }),
2344
- sq: () => import('./sq.js').then(function (n) { return n.s; }),
2345
- 'sr-CYRL': () => import('./sr-cyrl.js').then(function (n) { return n.s; }),
2346
- ss: () => import('./ss.js').then(function (n) { return n.s; }),
2347
- 'sv-FI': () => import('./sv-fi.js').then(function (n) { return n.s; }),
2348
- sr: () => import('./sr.js').then(function (n) { return n.s; }),
2349
- sv: () => import('./sv.js').then(function (n) { return n.s; }),
2350
- sw: () => import('./sw.js').then(function (n) { return n.s; }),
2351
- ta: () => import('./ta.js').then(function (n) { return n.t; }),
2352
- te: () => import('./te.js').then(function (n) { return n.t; }),
2353
- tet: () => import('./tet.js').then(function (n) { return n.t; }),
2354
- tg: () => import('./tg.js').then(function (n) { return n.t; }),
2355
- th: () => import('./th.js').then(function (n) { return n.t; }),
2356
- tk: () => import('./tk.js').then(function (n) { return n.t; }),
2357
- 'tl-PH': () => import('./tl-ph.js').then(function (n) { return n.t; }),
2358
- tlh: () => import('./tlh.js').then(function (n) { return n.t; }),
2359
- tr: () => import('./tr.js').then(function (n) { return n.t; }),
2360
- tzl: () => import('./tzl.js').then(function (n) { return n.t; }),
2361
- 'tzm-LATN': () => import('./tzm-latn.js').then(function (n) { return n.t; }),
2362
- tzm: () => import('./tzm.js').then(function (n) { return n.t; }),
2363
- 'ug-CN': () => import('./ug-cn.js').then(function (n) { return n.u; }),
2364
- uk: () => import('./uk.js').then(function (n) { return n.u; }),
2365
- ur: () => import('./ur.js').then(function (n) { return n.u; }),
2366
- 'uz-LATN': () => import('./uz-latn.js').then(function (n) { return n.u; }),
2367
- uz: () => import('./uz.js').then(function (n) { return n.u; }),
2368
- vi: () => import('./vi.js').then(function (n) { return n.v; }),
2369
- 'x-PSEUDO': () => import('./x-pseudo.js').then(function (n) { return n.x; }),
2370
- yo: () => import('./yo.js').then(function (n) { return n.y; }),
2371
- 'zh-CN': () => import('./zh-cn.js').then(function (n) { return n.z; }),
2372
- 'zh-HK': () => import('./zh-hk.js').then(function (n) { return n.z; }),
2373
- 'zh-TW': () => import('./zh-tw.js').then(function (n) { return n.z; }),
2374
- zh: () => import('./zh.js').then(function (n) { return n.z; }),
2375
- 'oc-LNC': () => import('./oc-lnc.js').then(function (n) { return n.o; }),
2376
- nn: () => import('./nn.js').then(function (n) { return n.n; }),
2377
- 'pa-IN': () => import('./pa-in.js').then(function (n) { return n.p; }),
2378
- };
2379
-
2380
- const warn = (language) => console.warn(`Cannot load dayjs locale file for "${language}"`);
2381
- const resolveLanguage = (languageInput) => {
2382
- if (locales[languageInput]) {
2383
- return languageInput;
2384
- }
2385
- if (languageInput.includes('-')) {
2386
- const regionlessLanguage = languageInput.split('-')[0];
2387
- if (locales[regionlessLanguage]) {
2388
- return regionlessLanguage;
2389
- }
2390
- }
2391
- return languageInput;
2392
- };
2393
- function loadDayjsLocale(languageInput) {
2394
- const language = resolveLanguage(languageInput);
2395
- if (!locales[language]) {
2396
- warn(language);
2397
- return;
2398
- }
2399
- try {
2400
- locales[language]().then(() => dayjs.locale(language));
2401
- }
2402
- catch (error) {
2403
- warn(language);
2404
- }
2405
- }
2406
-
2407
- function _typeof$2(o) { "@babel/helpers - typeof"; return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$2(o); }
2408
- function hasXMLHttpRequest() {
2409
- return typeof XMLHttpRequest === 'function' || (typeof XMLHttpRequest === "undefined" ? "undefined" : _typeof$2(XMLHttpRequest)) === 'object';
2410
- }
2411
- function isPromise(maybePromise) {
2412
- return !!maybePromise && typeof maybePromise.then === 'function';
2413
- }
2414
- function makePromise(maybePromise) {
2415
- if (isPromise(maybePromise)) {
2416
- return maybePromise;
2417
- }
2418
- return Promise.resolve(maybePromise);
2419
- }
2420
-
2421
- function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2422
- function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2423
- function _defineProperty$1(e, r, t) { return (r = _toPropertyKey$1(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2424
- function _toPropertyKey$1(t) { var i = _toPrimitive$1(t, "string"); return "symbol" == _typeof$1(i) ? i : i + ""; }
2425
- function _toPrimitive$1(t, r) { if ("object" != _typeof$1(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof$1(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
2426
- function _typeof$1(o) { "@babel/helpers - typeof"; return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$1(o); }
2427
- var fetchApi = typeof fetch === 'function' ? fetch : undefined;
2428
- if (typeof global !== 'undefined' && global.fetch) {
2429
- fetchApi = global.fetch;
2430
- } else if (typeof window !== 'undefined' && window.fetch) {
2431
- fetchApi = window.fetch;
2432
- }
2433
- var XmlHttpRequestApi;
2434
- if (hasXMLHttpRequest()) {
2435
- if (typeof global !== 'undefined' && global.XMLHttpRequest) {
2436
- XmlHttpRequestApi = global.XMLHttpRequest;
2437
- } else if (typeof window !== 'undefined' && window.XMLHttpRequest) {
2438
- XmlHttpRequestApi = window.XMLHttpRequest;
2439
- }
2440
- }
2441
- var ActiveXObjectApi;
2442
- if (typeof ActiveXObject === 'function') {
2443
- if (typeof global !== 'undefined' && global.ActiveXObject) {
2444
- ActiveXObjectApi = global.ActiveXObject;
2445
- } else if (typeof window !== 'undefined' && window.ActiveXObject) {
2446
- ActiveXObjectApi = window.ActiveXObject;
2447
- }
2448
- }
2449
- if (typeof fetchApi !== 'function') fetchApi = undefined;
2450
- if (!fetchApi && !XmlHttpRequestApi && !ActiveXObjectApi) {
2451
- try {
2452
- import('./browser-ponyfill.js').then(function (n) { return n.b; }).then(function (mod) {
2453
- fetchApi = mod.default;
2454
- }).catch(function () {});
2455
- } catch (e) {}
2456
- }
2457
- var addQueryString = function addQueryString(url, params) {
2458
- if (params && _typeof$1(params) === 'object') {
2459
- var queryString = '';
2460
- for (var paramName in params) {
2461
- queryString += '&' + encodeURIComponent(paramName) + '=' + encodeURIComponent(params[paramName]);
2462
- }
2463
- if (!queryString) return url;
2464
- url = url + (url.indexOf('?') !== -1 ? '&' : '?') + queryString.slice(1);
2465
- }
2466
- return url;
2467
- };
2468
- var fetchIt = function fetchIt(url, fetchOptions, callback, altFetch) {
2469
- var resolver = function resolver(response) {
2470
- if (!response.ok) return callback(response.statusText || 'Error', {
2471
- status: response.status
2472
- });
2473
- response.text().then(function (data) {
2474
- callback(null, {
2475
- status: response.status,
2476
- data: data
2477
- });
2478
- }).catch(callback);
2479
- };
2480
- if (altFetch) {
2481
- var altResponse = altFetch(url, fetchOptions);
2482
- if (altResponse instanceof Promise) {
2483
- altResponse.then(resolver).catch(callback);
2484
- return;
2485
- }
2486
- }
2487
- if (typeof fetch === 'function') {
2488
- fetch(url, fetchOptions).then(resolver).catch(callback);
2489
- } else {
2490
- fetchApi(url, fetchOptions).then(resolver).catch(callback);
2491
- }
2492
- };
2493
- var omitFetchOptions = false;
2494
- var requestWithFetch = function requestWithFetch(options, url, payload, callback) {
2495
- if (options.queryStringParams) {
2496
- url = addQueryString(url, options.queryStringParams);
2497
- }
2498
- var headers = _objectSpread$1({}, typeof options.customHeaders === 'function' ? options.customHeaders() : options.customHeaders);
2499
- if (typeof window === 'undefined' && typeof global !== 'undefined' && typeof global.process !== 'undefined' && global.process.versions && global.process.versions.node) {
2500
- headers['User-Agent'] = "i18next-http-backend (node/".concat(global.process.version, "; ").concat(global.process.platform, " ").concat(global.process.arch, ")");
2501
- }
2502
- if (payload) headers['Content-Type'] = 'application/json';
2503
- var reqOptions = typeof options.requestOptions === 'function' ? options.requestOptions(payload) : options.requestOptions;
2504
- var fetchOptions = _objectSpread$1({
2505
- method: payload ? 'POST' : 'GET',
2506
- body: payload ? options.stringify(payload) : undefined,
2507
- headers: headers
2508
- }, omitFetchOptions ? {} : reqOptions);
2509
- var altFetch = typeof options.alternateFetch === 'function' && options.alternateFetch.length >= 1 ? options.alternateFetch : undefined;
2510
- try {
2511
- fetchIt(url, fetchOptions, callback, altFetch);
2512
- } catch (e) {
2513
- if (!reqOptions || Object.keys(reqOptions).length === 0 || !e.message || e.message.indexOf('not implemented') < 0) {
2514
- return callback(e);
2515
- }
2516
- try {
2517
- Object.keys(reqOptions).forEach(function (opt) {
2518
- delete fetchOptions[opt];
2519
- });
2520
- fetchIt(url, fetchOptions, callback, altFetch);
2521
- omitFetchOptions = true;
2522
- } catch (err) {
2523
- callback(err);
2524
- }
2525
- }
2526
- };
2527
- var requestWithXmlHttpRequest = function requestWithXmlHttpRequest(options, url, payload, callback) {
2528
- if (payload && _typeof$1(payload) === 'object') {
2529
- payload = addQueryString('', payload).slice(1);
2530
- }
2531
- if (options.queryStringParams) {
2532
- url = addQueryString(url, options.queryStringParams);
2533
- }
2534
- try {
2535
- var x = XmlHttpRequestApi ? new XmlHttpRequestApi() : new ActiveXObjectApi('MSXML2.XMLHTTP.3.0');
2536
- x.open(payload ? 'POST' : 'GET', url, 1);
2537
- if (!options.crossDomain) {
2538
- x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
2539
- }
2540
- x.withCredentials = !!options.withCredentials;
2541
- if (payload) {
2542
- x.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2543
- }
2544
- if (x.overrideMimeType) {
2545
- x.overrideMimeType('application/json');
2546
- }
2547
- var h = options.customHeaders;
2548
- h = typeof h === 'function' ? h() : h;
2549
- if (h) {
2550
- for (var i in h) {
2551
- x.setRequestHeader(i, h[i]);
2552
- }
2553
- }
2554
- x.onreadystatechange = function () {
2555
- x.readyState > 3 && callback(x.status >= 400 ? x.statusText : null, {
2556
- status: x.status,
2557
- data: x.responseText
2558
- });
2559
- };
2560
- x.send(payload);
2561
- } catch (e) {
2562
- console && console.log(e);
2563
- }
2564
- };
2565
- var request = function request(options, url, payload, callback) {
2566
- if (typeof payload === 'function') {
2567
- callback = payload;
2568
- payload = undefined;
2569
- }
2570
- callback = callback || function () {};
2571
- if (fetchApi && url.indexOf('file:') !== 0) {
2572
- return requestWithFetch(options, url, payload, callback);
2573
- }
2574
- if (hasXMLHttpRequest() || typeof ActiveXObject === 'function') {
2575
- return requestWithXmlHttpRequest(options, url, payload, callback);
2576
- }
2577
- callback(new Error('No fetch and no xhr implementation found!'));
2578
- };
2579
-
2580
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2581
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2582
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2583
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
2584
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
2585
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
2586
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2587
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
2588
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
2589
- var getDefaults = function getDefaults() {
2590
- return {
2591
- loadPath: '/locales/{{lng}}/{{ns}}.json',
2592
- addPath: '/locales/add/{{lng}}/{{ns}}',
2593
- parse: function parse(data) {
2594
- return JSON.parse(data);
2595
- },
2596
- stringify: JSON.stringify,
2597
- parsePayload: function parsePayload(namespace, key, fallbackValue) {
2598
- return _defineProperty({}, key, fallbackValue || '');
2599
- },
2600
- parseLoadPayload: function parseLoadPayload(languages, namespaces) {
2601
- return undefined;
2602
- },
2603
- request: request,
2604
- reloadInterval: typeof window !== 'undefined' ? false : 60 * 60 * 1000,
2605
- customHeaders: {},
2606
- queryStringParams: {},
2607
- crossDomain: false,
2608
- withCredentials: false,
2609
- overrideMimeType: false,
2610
- requestOptions: {
2611
- mode: 'cors',
2612
- credentials: 'same-origin',
2613
- cache: 'default'
2614
- }
2615
- };
2616
- };
2617
- var Backend = function () {
2618
- function Backend(services) {
2619
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2620
- var allOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2621
- _classCallCheck(this, Backend);
2622
- this.services = services;
2623
- this.options = options;
2624
- this.allOptions = allOptions;
2625
- this.type = 'backend';
2626
- this.init(services, options, allOptions);
2627
- }
2628
- return _createClass(Backend, [{
2629
- key: "init",
2630
- value: function init(services) {
2631
- var _this = this;
2632
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2633
- var allOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2634
- this.services = services;
2635
- this.options = _objectSpread(_objectSpread(_objectSpread({}, getDefaults()), this.options || {}), options);
2636
- this.allOptions = allOptions;
2637
- if (this.services && this.options.reloadInterval) {
2638
- var timer = setInterval(function () {
2639
- return _this.reload();
2640
- }, this.options.reloadInterval);
2641
- if (_typeof(timer) === 'object' && typeof timer.unref === 'function') timer.unref();
2642
- }
2643
- }
2644
- }, {
2645
- key: "readMulti",
2646
- value: function readMulti(languages, namespaces, callback) {
2647
- this._readAny(languages, languages, namespaces, namespaces, callback);
2648
- }
2649
- }, {
2650
- key: "read",
2651
- value: function read(language, namespace, callback) {
2652
- this._readAny([language], language, [namespace], namespace, callback);
2653
- }
2654
- }, {
2655
- key: "_readAny",
2656
- value: function _readAny(languages, loadUrlLanguages, namespaces, loadUrlNamespaces, callback) {
2657
- var _this2 = this;
2658
- var loadPath = this.options.loadPath;
2659
- if (typeof this.options.loadPath === 'function') {
2660
- loadPath = this.options.loadPath(languages, namespaces);
2661
- }
2662
- loadPath = makePromise(loadPath);
2663
- loadPath.then(function (resolvedLoadPath) {
2664
- if (!resolvedLoadPath) return callback(null, {});
2665
- var url = _this2.services.interpolator.interpolate(resolvedLoadPath, {
2666
- lng: languages.join('+'),
2667
- ns: namespaces.join('+')
2668
- });
2669
- _this2.loadUrl(url, callback, loadUrlLanguages, loadUrlNamespaces);
2670
- });
2671
- }
2672
- }, {
2673
- key: "loadUrl",
2674
- value: function loadUrl(url, callback, languages, namespaces) {
2675
- var _this3 = this;
2676
- var lng = typeof languages === 'string' ? [languages] : languages;
2677
- var ns = typeof namespaces === 'string' ? [namespaces] : namespaces;
2678
- var payload = this.options.parseLoadPayload(lng, ns);
2679
- this.options.request(this.options, url, payload, function (err, res) {
2680
- if (res && (res.status >= 500 && res.status < 600 || !res.status)) return callback('failed loading ' + url + '; status code: ' + res.status, true);
2681
- if (res && res.status >= 400 && res.status < 500) return callback('failed loading ' + url + '; status code: ' + res.status, false);
2682
- if (!res && err && err.message) {
2683
- var errorMessage = err.message.toLowerCase();
2684
- var isNetworkError = ['failed', 'fetch', 'network', 'load'].find(function (term) {
2685
- return errorMessage.indexOf(term) > -1;
2686
- });
2687
- if (isNetworkError) {
2688
- return callback('failed loading ' + url + ': ' + err.message, true);
2689
- }
2690
- }
2691
- if (err) return callback(err, false);
2692
- var ret, parseErr;
2693
- try {
2694
- if (typeof res.data === 'string') {
2695
- ret = _this3.options.parse(res.data, languages, namespaces);
2696
- } else {
2697
- ret = res.data;
2698
- }
2699
- } catch (e) {
2700
- parseErr = 'failed parsing ' + url + ' to json';
2701
- }
2702
- if (parseErr) return callback(parseErr, false);
2703
- callback(null, ret);
2704
- });
2705
- }
2706
- }, {
2707
- key: "create",
2708
- value: function create(languages, namespace, key, fallbackValue, callback) {
2709
- var _this4 = this;
2710
- if (!this.options.addPath) return;
2711
- if (typeof languages === 'string') languages = [languages];
2712
- var payload = this.options.parsePayload(namespace, key, fallbackValue);
2713
- var finished = 0;
2714
- var dataArray = [];
2715
- var resArray = [];
2716
- languages.forEach(function (lng) {
2717
- var addPath = _this4.options.addPath;
2718
- if (typeof _this4.options.addPath === 'function') {
2719
- addPath = _this4.options.addPath(lng, namespace);
2720
- }
2721
- var url = _this4.services.interpolator.interpolate(addPath, {
2722
- lng: lng,
2723
- ns: namespace
2724
- });
2725
- _this4.options.request(_this4.options, url, payload, function (data, res) {
2726
- finished += 1;
2727
- dataArray.push(data);
2728
- resArray.push(res);
2729
- if (finished === languages.length) {
2730
- if (typeof callback === 'function') callback(dataArray, resArray);
2731
- }
2732
- });
2733
- });
2734
- }
2735
- }, {
2736
- key: "reload",
2737
- value: function reload() {
2738
- var _this5 = this;
2739
- var _this$services = this.services,
2740
- backendConnector = _this$services.backendConnector,
2741
- languageUtils = _this$services.languageUtils,
2742
- logger = _this$services.logger;
2743
- var currentLanguage = backendConnector.language;
2744
- if (currentLanguage && currentLanguage.toLowerCase() === 'cimode') return;
2745
- var toLoad = [];
2746
- var append = function append(lng) {
2747
- var lngs = languageUtils.toResolveHierarchy(lng);
2748
- lngs.forEach(function (l) {
2749
- if (toLoad.indexOf(l) < 0) toLoad.push(l);
2750
- });
2751
- };
2752
- append(currentLanguage);
2753
- if (this.allOptions.preload) this.allOptions.preload.forEach(function (l) {
2754
- return append(l);
2755
- });
2756
- toLoad.forEach(function (lng) {
2757
- _this5.allOptions.ns.forEach(function (ns) {
2758
- backendConnector.read(lng, ns, 'read', null, null, function (err, data) {
2759
- if (err) logger.warn("loading namespace ".concat(ns, " for language ").concat(lng, " failed"), err);
2760
- if (!err && data) logger.log("loaded namespace ".concat(ns, " for language ").concat(lng), data);
2761
- backendConnector.loaded("".concat(lng, "|").concat(ns), err, data);
2762
- });
2763
- });
2764
- });
2765
- }
2766
- }]);
2767
- }();
2768
- Backend.type = 'backend';
2769
-
2770
- function getAssetPath(path) {
2771
- const baseUrl = new URL('./', window.document.baseURI).href;
2772
- const assetUrl = new URL(path, baseUrl);
2773
- return assetUrl.origin !== window.location.origin
2774
- ? assetUrl.href
2775
- : assetUrl.pathname;
2776
- }
2777
-
2778
- const availableLocales = [
2779
- "dev",
2780
- "en",
2781
- "fr",
2782
- "cs",
2783
- "da",
2784
- "de",
2785
- "el",
2786
- "es",
2787
- "fi",
2788
- "hu",
2789
- "id",
2790
- "it",
2791
- "ja",
2792
- "ko",
2793
- "nl",
2794
- "no",
2795
- "pl",
2796
- "pt",
2797
- "pt-br",
2798
- "ru",
2799
- "sv",
2800
- "th",
2801
- "tr",
2802
- "zh",
2803
- "zh-cn",
2804
- "zh-tw",
2805
- "zn",
2806
- "es-es"
2807
- ];
2808
-
2809
- const i18nTranslationNamespace = 'translation';
2810
- function isI18nLocaleAvailable(locale) {
2811
- return availableLocales.includes(locale.toLowerCase());
2812
- }
2813
- function i18nBackendOptions(atomicInterface) {
2814
- return {
2815
- loadPath: `${getAssetPath(atomicInterface.languageAssetsPath)}/{{lng}}.json?lng={{lng}}&ns={{ns}}`,
2816
- request: async (_options, url, _payload, callback) => {
2817
- try {
2818
- const [fetchUrl, searchParams] = url.split('?');
2819
- const urlParams = new URLSearchParams(searchParams);
2820
- const lng = urlParams.get('lng');
2821
- const ns = urlParams.get('ns');
2822
- if (!isI18nLocaleAvailable(lng)) {
2823
- throw new Error(`Unsupported locale "${lng}"`);
2824
- }
2825
- if (ns !== i18nTranslationNamespace) {
2826
- throw new Error(`Unsupported namespace "${ns}"`);
2827
- }
2828
- const response = await fetch(fetchUrl);
2829
- if (response.status !== 200 && response.status !== 304) {
2830
- throw new Error(`Unsuccessful request returned status "${response.status}"`);
2831
- }
2832
- callback(null, {
2833
- status: response.status,
2834
- data: await response.json(),
2835
- });
2836
- }
2837
- catch (error) {
2838
- callback(error, { status: 404, data: '' });
2839
- }
2840
- },
2841
- };
2842
- }
2843
- function init18n(atomicInterface) {
2844
- return atomicInterface.i18n.use(Backend).init({
2845
- debug: atomicInterface.logLevel === 'debug',
2846
- lng: atomicInterface.language,
2847
- nsSeparator: '___',
2848
- fallbackLng: 'en',
2849
- backend: i18nBackendOptions(atomicInterface),
2850
- interpolation: {
2851
- escape: (str) => DOMPurify.sanitize(str),
2852
- },
2853
- compatibilityJSON: 'v4',
2854
- });
2855
- }
2856
-
2857
- const mismatchedInterfaceAndEnginePropError = (interfaceKind, configurationName) => `A ${configurationName} is configured on the ${interfaceKind} interface element, but the ${interfaceKind} interface was initialized with an engine. You should only configure the ${configurationName} in the target engine.`;
2858
- class CommonAtomicInterfaceHelper {
2859
- constructor(atomicInterface, globalVariableName) {
2860
- this.atomicInterface = atomicInterface;
2861
- this.hangingComponentsInitialization = [];
2862
- setCoveoGlobal(globalVariableName);
2863
- const { connectedCallback: originalConnectedCallback, render: originalRender, } = atomicInterface;
2864
- atomicInterface.connectedCallback = () => {
2865
- this.i18nPromise = init18n(atomicInterface);
2866
- return (originalConnectedCallback &&
2867
- originalConnectedCallback.call(atomicInterface));
2868
- };
2869
- atomicInterface.render = () => {
2870
- if (atomicInterface.error) {
2871
- return (h("atomic-component-error", { element: atomicInterface.host, error: atomicInterface.error }));
2872
- }
2873
- return originalRender && originalRender.call(atomicInterface);
2874
- };
2875
- }
2876
- onComponentInitializing(event) {
2877
- event.preventDefault();
2878
- event.stopPropagation();
2879
- if (this.atomicInterface.engine) {
2880
- event.detail(this.atomicInterface.bindings);
2881
- return;
2882
- }
2883
- this.hangingComponentsInitialization.push(event);
2884
- }
2885
- async onInitialization(initEngine) {
2886
- if (this.atomicInterface.engine) {
2887
- this.atomicInterface.engine.logger.warn(`The ${this.interfaceTagname} component "initialize" has already been called.`, this.atomicInterface.host);
2888
- return;
2889
- }
2890
- this.atomicInterface.updateIconAssetsPath();
2891
- initEngine();
2892
- if (this.atomicInterface.registerFieldsToInclude) {
2893
- this.atomicInterface.registerFieldsToInclude();
2894
- }
2895
- loadDayjsLocale(this.language);
2896
- await this.i18nPromise;
2897
- this.initComponents();
2898
- }
2899
- onAnalyticsChange() {
2900
- const { engine, analytics } = this.atomicInterface;
2901
- if (!this.engineIsCreated(engine)) {
2902
- return;
2903
- }
2904
- if (!analytics) {
2905
- engine.disableAnalytics();
2906
- return;
2907
- }
2908
- engine.enableAnalytics();
2909
- }
2910
- onLanguageChange() {
2911
- const { i18n, language } = this.atomicInterface;
2912
- loadDayjsLocale(this.language);
2913
- const { resolve, promise } = Promise.withResolvers();
2914
- new Backend(i18n.services, i18nBackendOptions(this.atomicInterface)).read(this.language, i18nTranslationNamespace, async (_, data) => {
2915
- i18n.addResourceBundle(this.language, i18nTranslationNamespace, data, true, false);
2916
- await i18n.changeLanguage(language);
2917
- resolve();
2918
- });
2919
- return promise;
2920
- }
2921
- engineIsCreated(engine) {
2922
- if (!engine) {
2923
- console.error(`You have to call "initialize" on the ${this.interfaceTagname} component before modifying the props or calling other public methods.`, this.atomicInterface.host);
2924
- return false;
2925
- }
2926
- return true;
2927
- }
2928
- get interfaceTagname() {
2929
- return this.atomicInterface.host.tagName.toLowerCase();
2930
- }
2931
- initComponents() {
2932
- this.hangingComponentsInitialization.forEach((event) => event.detail(this.atomicInterface.bindings));
2933
- }
2934
- get language() {
2935
- return this.atomicInterface.language || 'en';
2936
- }
2937
- }
1
+ import { g as getAtomicEnvironment } from './interface-common-stencil.js';
2938
2
 
2939
3
  function augmentWithExternalMiddleware(event, payload, config) {
2940
4
  if (config.analytics?.analyticsClientMiddleware) {
@@ -2974,6 +38,6 @@ function getNextAnalyticsConfig(searchEngineConfig, enabled) {
2974
38
  return configuration;
2975
39
  }
2976
40
 
2977
- export { CommonAtomicInterfaceHelper as C, augmentWithExternalMiddleware as a, augmentAnalyticsWithAtomicVersion as b, augmentAnalyticsConfigWithDocument as c, augmentAnalyticsConfigWithAtomicVersion as d, getNextAnalyticsConfig as g, instance as i, mismatchedInterfaceAndEnginePropError as m };
41
+ export { augmentWithExternalMiddleware as a, augmentAnalyticsWithAtomicVersion as b, augmentAnalyticsConfigWithDocument as c, augmentAnalyticsConfigWithAtomicVersion as d, getNextAnalyticsConfig as g };
2978
42
 
2979
43
  //# sourceMappingURL=analytics-config.js.map