fastapi-rtk 0.2.32 → 0.2.36

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