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