@coveo/atomic 3.34.0-pre.ebcb0fe404 → 3.34.0-pre.f310961b1a

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