@lifi/widget 4.0.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (485) hide show
  1. package/dist/esm/App.d.ts +4 -2
  2. package/dist/esm/App.d.ts.map +1 -1
  3. package/dist/esm/App.js +4 -4
  4. package/dist/esm/App.js.map +1 -1
  5. package/dist/esm/AppDefault.js +14 -0
  6. package/dist/esm/AppDefault.js.map +1 -1
  7. package/dist/esm/AppDrawer.d.ts +1 -1
  8. package/dist/esm/AppDrawer.d.ts.map +1 -1
  9. package/dist/esm/AppDrawer.js +5 -6
  10. package/dist/esm/AppDrawer.js.map +1 -1
  11. package/dist/esm/AppDrawerContext.js +2 -2
  12. package/dist/esm/AppDrawerContext.js.map +1 -1
  13. package/dist/esm/components/ActionRow/ActionRow.style.js.map +1 -1
  14. package/dist/esm/components/AmountInput/AmountInput.js +2 -1
  15. package/dist/esm/components/AmountInput/AmountInput.js.map +1 -1
  16. package/dist/esm/components/AmountInput/AmountInput.style.js.map +1 -1
  17. package/dist/esm/components/AmountInput/AmountInputEndAdornment.js +4 -2
  18. package/dist/esm/components/AmountInput/AmountInputEndAdornment.js.map +1 -1
  19. package/dist/esm/components/AmountInput/AmountInputEndAdornment.style.js +1 -1
  20. package/dist/esm/components/AmountInput/AmountInputEndAdornment.style.js.map +1 -1
  21. package/dist/esm/components/AmountInput/PriceFormHelperText.js +4 -2
  22. package/dist/esm/components/AmountInput/PriceFormHelperText.js.map +1 -1
  23. package/dist/esm/components/AmountInput/PriceFormHelperText.style.js.map +1 -1
  24. package/dist/esm/components/AmountInputCard/AmountInputCard.style.js +98 -0
  25. package/dist/esm/components/AmountInputCard/AmountInputCard.style.js.map +1 -0
  26. package/dist/esm/components/AmountInputCard/AmountInputCardPair.js +25 -0
  27. package/dist/esm/components/AmountInputCard/AmountInputCardPair.js.map +1 -0
  28. package/dist/esm/components/AmountInputCard/BalanceDisplay.js +35 -0
  29. package/dist/esm/components/AmountInputCard/BalanceDisplay.js.map +1 -0
  30. package/dist/esm/components/AmountInputCard/BalanceDisplay.style.js +11 -0
  31. package/dist/esm/components/AmountInputCard/BalanceDisplay.style.js.map +1 -0
  32. package/dist/esm/components/AmountInputCard/FiatValueToggle.js +41 -0
  33. package/dist/esm/components/AmountInputCard/FiatValueToggle.js.map +1 -0
  34. package/dist/esm/components/AmountInputCard/PercentageChips.js +80 -0
  35. package/dist/esm/components/AmountInputCard/PercentageChips.js.map +1 -0
  36. package/dist/esm/components/AmountInputCard/PercentageChips.style.js +43 -0
  37. package/dist/esm/components/AmountInputCard/PercentageChips.style.js.map +1 -0
  38. package/dist/esm/components/AmountInputCard/ReceiveAmountCard.js +137 -0
  39. package/dist/esm/components/AmountInputCard/ReceiveAmountCard.js.map +1 -0
  40. package/dist/esm/components/AmountInputCard/SendAmountCard.js +102 -0
  41. package/dist/esm/components/AmountInputCard/SendAmountCard.js.map +1 -0
  42. package/dist/esm/components/AppContainer.js.map +1 -1
  43. package/dist/esm/components/Avatar/AccountAvatar.js.map +1 -1
  44. package/dist/esm/components/Avatar/Avatar.js +12 -3
  45. package/dist/esm/components/Avatar/Avatar.js.map +1 -1
  46. package/dist/esm/components/Avatar/Avatar.style.js.map +1 -1
  47. package/dist/esm/components/Avatar/SmallAvatar.js.map +1 -1
  48. package/dist/esm/components/BaseTransactionButton/BaseTransactionButton.js +1 -0
  49. package/dist/esm/components/BaseTransactionButton/BaseTransactionButton.js.map +1 -1
  50. package/dist/esm/components/BottomSheet/BottomSheet.js +3 -3
  51. package/dist/esm/components/BottomSheet/BottomSheet.js.map +1 -1
  52. package/dist/esm/components/ButtonTertiary.js.map +1 -1
  53. package/dist/esm/components/Card/Card.js.map +1 -1
  54. package/dist/esm/components/Card/CardButton.style.js.map +1 -1
  55. package/dist/esm/components/Card/CardHeader.js.map +1 -1
  56. package/dist/esm/components/Card/CardIconButton.js.map +1 -1
  57. package/dist/esm/components/Card/CardLabel.js.map +1 -1
  58. package/dist/esm/components/Card/CardTitle.js.map +1 -1
  59. package/dist/esm/components/Card/InputCard.js.map +1 -1
  60. package/dist/esm/components/ChainSelect/ChainSelect.js.map +1 -1
  61. package/dist/esm/components/ChainSelect/ChainSelect.style.js.map +1 -1
  62. package/dist/esm/components/ChainSelect/useChainSelect.js.map +1 -1
  63. package/dist/esm/components/Chains/AllChainsAvatar.js.map +1 -1
  64. package/dist/esm/components/Chains/ChainList.js.map +1 -1
  65. package/dist/esm/components/Chains/ChainList.style.js.map +1 -1
  66. package/dist/esm/components/Chains/ChainsExpanded.style.js.map +1 -1
  67. package/dist/esm/components/Chains/VirtualizedChainList.js +2 -1
  68. package/dist/esm/components/Chains/VirtualizedChainList.js.map +1 -1
  69. package/dist/esm/components/ContextMenu.style.js.map +1 -1
  70. package/dist/esm/components/ContractComponent/NFT/NFT.style.js.map +1 -1
  71. package/dist/esm/components/Dialog/Dialog.style.js.map +1 -1
  72. package/dist/esm/components/EmptyListIndicator/EmptyListIndicator.style.js.map +1 -1
  73. package/dist/esm/components/ExecutionStatusCard/StatusIcon.js.map +1 -1
  74. package/dist/esm/components/ExecutionStatusCard/StatusIcon.style.js.map +1 -1
  75. package/dist/esm/components/ExecutionStatusCard/iconKey.js.map +1 -1
  76. package/dist/esm/components/Expansion/Expansion.style.js.map +1 -1
  77. package/dist/esm/components/Header/ActivitiesButton.style.js.map +1 -1
  78. package/dist/esm/components/Header/CloseDrawerButton.js +1 -0
  79. package/dist/esm/components/Header/CloseDrawerButton.js.map +1 -1
  80. package/dist/esm/components/Header/Header.js +7 -10
  81. package/dist/esm/components/Header/Header.js.map +1 -1
  82. package/dist/esm/components/Header/Header.style.js.map +1 -1
  83. package/dist/esm/components/Header/HeaderNavigationTabs.js +39 -0
  84. package/dist/esm/components/Header/HeaderNavigationTabs.js.map +1 -0
  85. package/dist/esm/components/Header/HeaderTabs.js +33 -0
  86. package/dist/esm/components/Header/HeaderTabs.js.map +1 -0
  87. package/dist/esm/components/Header/NavigationHeader.js +7 -5
  88. package/dist/esm/components/Header/NavigationHeader.js.map +1 -1
  89. package/dist/esm/components/Header/SettingsButton.style.js.map +1 -1
  90. package/dist/esm/components/Header/WalletMenu.style.js.map +1 -1
  91. package/dist/esm/components/IconCircle/IconCircle.style.js +1 -1
  92. package/dist/esm/components/IconCircle/IconCircle.style.js.map +1 -1
  93. package/dist/esm/components/IconTypography.js.map +1 -1
  94. package/dist/esm/components/Input.js.map +1 -1
  95. package/dist/esm/components/LimitOrderSettings/LimitOrderSettings.js +99 -0
  96. package/dist/esm/components/LimitOrderSettings/LimitOrderSettings.js.map +1 -0
  97. package/dist/esm/components/LimitOrderSettings/LimitOrderSettings.style.js +52 -0
  98. package/dist/esm/components/LimitOrderSettings/LimitOrderSettings.style.js.map +1 -0
  99. package/dist/esm/components/LimitPriceCard/LimitPriceCard.js +115 -0
  100. package/dist/esm/components/LimitPriceCard/LimitPriceCard.js.map +1 -0
  101. package/dist/esm/components/LimitPriceCard/LimitPriceCard.style.js +89 -0
  102. package/dist/esm/components/LimitPriceCard/LimitPriceCard.style.js.map +1 -0
  103. package/dist/esm/components/LimitPriceCard/LimitPricePresets.js +91 -0
  104. package/dist/esm/components/LimitPriceCard/LimitPricePresets.js.map +1 -0
  105. package/dist/esm/components/ListItem/ListItem.js.map +1 -1
  106. package/dist/esm/components/ListItem/ListItemButton.js.map +1 -1
  107. package/dist/esm/components/ListItemButton.js.map +1 -1
  108. package/dist/esm/components/ListItemText.js.map +1 -1
  109. package/dist/esm/components/Menu.js.map +1 -1
  110. package/dist/esm/components/Messages/AlertMessage.style.js.map +1 -1
  111. package/dist/esm/components/Messages/GasRefuelMessage.style.js.map +1 -1
  112. package/dist/esm/components/Messages/WarningMessages.js.map +1 -1
  113. package/dist/esm/components/PageContainer.js.map +1 -1
  114. package/dist/esm/components/PoweredBy/PoweredBy.js.map +1 -1
  115. package/dist/esm/components/PoweredBy/PoweredBy.style.js.map +1 -1
  116. package/dist/esm/components/ReverseTokensButton/ReverseTokensButton.js +1 -0
  117. package/dist/esm/components/ReverseTokensButton/ReverseTokensButton.js.map +1 -1
  118. package/dist/esm/components/ReverseTokensButton/ReverseTokensButton.style.js.map +1 -1
  119. package/dist/esm/components/RouteCard/RouteDetails.js.map +1 -1
  120. package/dist/esm/components/RouteCard/RouteDetails.style.js +2 -2
  121. package/dist/esm/components/RouteCard/RouteDetails.style.js.map +1 -1
  122. package/dist/esm/components/RouteCard/RouteProviderCard.js +118 -0
  123. package/dist/esm/components/RouteCard/RouteProviderCard.js.map +1 -0
  124. package/dist/esm/components/RouteCard/RouteToken.style.js.map +1 -1
  125. package/dist/esm/components/RouteCard/RouteTokens.js.map +1 -1
  126. package/dist/esm/components/RouteCard/getMatchingLabels.js.map +1 -1
  127. package/dist/esm/components/Routes/LimitOrderRoutes.js +34 -0
  128. package/dist/esm/components/Routes/LimitOrderRoutes.js.map +1 -0
  129. package/dist/esm/components/Routes/Routes.js +2 -2
  130. package/dist/esm/components/Routes/Routes.js.map +1 -1
  131. package/dist/esm/components/Routes/RoutesContent.js.map +1 -1
  132. package/dist/esm/components/Routes/RoutesExpanded.style.js.map +1 -1
  133. package/dist/esm/components/Search/SearchInput.style.js.map +1 -1
  134. package/dist/esm/components/Search/SearchNotFound.style.js.map +1 -1
  135. package/dist/esm/components/SelectTokenButton/SelectTokenButton.style.js.map +1 -1
  136. package/dist/esm/components/SendToWallet/SendToWalletButton.style.js.map +1 -1
  137. package/dist/esm/components/SettingsListItemButton.js.map +1 -1
  138. package/dist/esm/components/SettingsPanel/SettingsPanel.js +51 -0
  139. package/dist/esm/components/SettingsPanel/SettingsPanel.js.map +1 -0
  140. package/dist/esm/components/SettingsPanel/SettingsPanel.style.js +33 -0
  141. package/dist/esm/components/SettingsPanel/SettingsPanel.style.js.map +1 -0
  142. package/dist/esm/components/SettingsPanel/utils.js +14 -0
  143. package/dist/esm/components/SettingsPanel/utils.js.map +1 -0
  144. package/dist/esm/components/Skeleton/WidgetSkeleton.js +50 -47
  145. package/dist/esm/components/Skeleton/WidgetSkeleton.js.map +1 -1
  146. package/dist/esm/components/Skeleton/WidgetSkeleton.style.js.map +1 -1
  147. package/dist/esm/components/Step/StepActions.js.map +1 -1
  148. package/dist/esm/components/Step/StepActions.style.js.map +1 -1
  149. package/dist/esm/components/StepActions/SentToWalletRow.style.js.map +1 -1
  150. package/dist/esm/components/StepActions/StepActionRow.style.js.map +1 -1
  151. package/dist/esm/components/SwapButton/SwapButton.js +50 -0
  152. package/dist/esm/components/SwapButton/SwapButton.js.map +1 -0
  153. package/dist/esm/components/SwapButton/SwapButton.style.js +24 -0
  154. package/dist/esm/components/SwapButton/SwapButton.style.js.map +1 -0
  155. package/dist/esm/components/Switch.js.map +1 -1
  156. package/dist/esm/components/Tabs/NavigationTabs.js +3 -0
  157. package/dist/esm/components/Tabs/NavigationTabs.js.map +1 -1
  158. package/dist/esm/components/Tabs/Tabs.style.js.map +1 -1
  159. package/dist/esm/components/Timer/StepStatusTimer.style.js.map +1 -1
  160. package/dist/esm/components/Token/Token.style.js.map +1 -1
  161. package/dist/esm/components/TokenList/PinTokenButton.js.map +1 -1
  162. package/dist/esm/components/TokenList/TokenDetailsSheet.js +4 -4
  163. package/dist/esm/components/TokenList/TokenDetailsSheet.js.map +1 -1
  164. package/dist/esm/components/TokenList/TokenDetailsSheetContent.js +4 -4
  165. package/dist/esm/components/TokenList/TokenDetailsSheetContent.js.map +1 -1
  166. package/dist/esm/components/TokenList/TokenDetailsSheetContent.style.js.map +1 -1
  167. package/dist/esm/components/TokenList/TokenList.style.js.map +1 -1
  168. package/dist/esm/components/TokenList/TokenListItem.js +2 -2
  169. package/dist/esm/components/TokenList/TokenListItem.js.map +1 -1
  170. package/dist/esm/components/TokenList/VirtualizedTokenList.js.map +1 -1
  171. package/dist/esm/components/TokenList/useTokenSelect.js +3 -3
  172. package/dist/esm/components/TokenList/useTokenSelect.js.map +1 -1
  173. package/dist/esm/components/TokenPillButton/TokenPillButton.js +52 -0
  174. package/dist/esm/components/TokenPillButton/TokenPillButton.js.map +1 -0
  175. package/dist/esm/components/TokenPillButton/TokenPillButton.style.js +39 -0
  176. package/dist/esm/components/TokenPillButton/TokenPillButton.style.js.map +1 -0
  177. package/dist/esm/components/TokenRate/TokenRate.style.js.map +1 -1
  178. package/dist/esm/components/TransactionCard/ActiveTransactionCard.js.map +1 -1
  179. package/dist/esm/components/TransactionCard/ActiveTransactionCard.style.js.map +1 -1
  180. package/dist/esm/components/TransactionCard/TransactionCard.style.js.map +1 -1
  181. package/dist/esm/config/version.d.ts +1 -1
  182. package/dist/esm/config/version.js +1 -1
  183. package/dist/esm/config/version.js.map +1 -1
  184. package/dist/esm/hooks/timer/validate.js.map +1 -1
  185. package/dist/esm/hooks/useAccountsBalancesData.js.map +1 -1
  186. package/dist/esm/hooks/useAvailableChains.js +1 -1
  187. package/dist/esm/hooks/useChainSearch.js +2 -1
  188. package/dist/esm/hooks/useChainSearch.js.map +1 -1
  189. package/dist/esm/hooks/useChains.js +1 -1
  190. package/dist/esm/hooks/useExplorer.js.map +1 -1
  191. package/dist/esm/hooks/useFilteredByTokenBalances.js +1 -1
  192. package/dist/esm/hooks/useFilteredByTokenBalances.js.map +1 -1
  193. package/dist/esm/hooks/useFromTokenSufficiency.js.map +1 -1
  194. package/dist/esm/hooks/useGasSufficiency.js.map +1 -1
  195. package/dist/esm/hooks/useLanguages.js +2 -2
  196. package/dist/esm/hooks/useLanguages.js.map +1 -1
  197. package/dist/esm/hooks/useLimitMarketRate.js +24 -0
  198. package/dist/esm/hooks/useLimitMarketRate.js.map +1 -0
  199. package/dist/esm/hooks/useLinkedLimitFields.js +49 -0
  200. package/dist/esm/hooks/useLinkedLimitFields.js.map +1 -0
  201. package/dist/esm/hooks/useRouteExecution.js.map +1 -1
  202. package/dist/esm/hooks/useRouteExecutionMessage.js.map +1 -1
  203. package/dist/esm/hooks/useRouteRequiredAccountConnection.js.map +1 -1
  204. package/dist/esm/hooks/useRoutes.js +23 -6
  205. package/dist/esm/hooks/useRoutes.js.map +1 -1
  206. package/dist/esm/hooks/useSwapOnly.js +2 -4
  207. package/dist/esm/hooks/useSwapOnly.js.map +1 -1
  208. package/dist/esm/hooks/useToAddressRequirements.js +2 -2
  209. package/dist/esm/hooks/useToAddressRequirements.js.map +1 -1
  210. package/dist/esm/hooks/useToken.js.map +1 -1
  211. package/dist/esm/hooks/useTokenBalance.js.map +1 -1
  212. package/dist/esm/hooks/useTokenBalances.js.map +1 -1
  213. package/dist/esm/hooks/useTokenBalancesQueries.js.map +1 -1
  214. package/dist/esm/hooks/useTokenSearch.js +1 -1
  215. package/dist/esm/hooks/useTokenSearch.js.map +1 -1
  216. package/dist/esm/hooks/useTokens.js +17 -15
  217. package/dist/esm/hooks/useTokens.js.map +1 -1
  218. package/dist/esm/hooks/useTools.js +1 -1
  219. package/dist/esm/hooks/useTransactionDetails.js.map +1 -1
  220. package/dist/esm/hooks/useTransactionHistory.js.map +1 -1
  221. package/dist/esm/hooks/useTransactionList.js.map +1 -1
  222. package/dist/esm/hooks/useWideVariant.js +5 -2
  223. package/dist/esm/hooks/useWideVariant.js.map +1 -1
  224. package/dist/esm/i18n/en.json +25 -0
  225. package/dist/esm/index.d.ts +3 -3
  226. package/dist/esm/pages/ActivitiesPage/ActivitiesPage.js.map +1 -1
  227. package/dist/esm/pages/MainPage/LimitPageContent.js +23 -0
  228. package/dist/esm/pages/MainPage/LimitPageContent.js.map +1 -0
  229. package/dist/esm/pages/MainPage/MainPage.js +19 -22
  230. package/dist/esm/pages/MainPage/MainPage.js.map +1 -1
  231. package/dist/esm/pages/MainPage/MainPageActions.js +28 -0
  232. package/dist/esm/pages/MainPage/MainPageActions.js.map +1 -0
  233. package/dist/esm/pages/MainPage/ReviewButton.js +11 -4
  234. package/dist/esm/pages/MainPage/ReviewButton.js.map +1 -1
  235. package/dist/esm/pages/RoutePriorityPage.js +48 -0
  236. package/dist/esm/pages/RoutePriorityPage.js.map +1 -0
  237. package/dist/esm/pages/RoutesPage/RoutesPage.js.map +1 -1
  238. package/dist/esm/pages/RoutesPage/RoutesPage.style.js.map +1 -1
  239. package/dist/esm/pages/SelectEnabledToolsPage.js.map +1 -1
  240. package/dist/esm/pages/SendToWallet/BookmarkAddressSheet.js +3 -3
  241. package/dist/esm/pages/SendToWallet/BookmarkAddressSheet.js.map +1 -1
  242. package/dist/esm/pages/SendToWallet/ConfirmAddressSheet.js +3 -3
  243. package/dist/esm/pages/SendToWallet/ConfirmAddressSheet.js.map +1 -1
  244. package/dist/esm/pages/SendToWallet/SendToWalletPage.js.map +1 -1
  245. package/dist/esm/pages/SendToWallet/SendToWalletPage.style.js.map +1 -1
  246. package/dist/esm/pages/SettingsPage/BridgeAndExchangeSettings.js +2 -2
  247. package/dist/esm/pages/SettingsPage/BridgeAndExchangeSettings.js.map +1 -1
  248. package/dist/esm/pages/SettingsPage/GasPriceSettings.js +1 -1
  249. package/dist/esm/pages/SettingsPage/ResetSettingsButton.style.js.map +1 -1
  250. package/dist/esm/pages/SettingsPage/RoutePrioritySettings.js +12 -27
  251. package/dist/esm/pages/SettingsPage/RoutePrioritySettings.js.map +1 -1
  252. package/dist/esm/pages/SettingsPage/SettingsCard/SettingCard.style.js.map +1 -1
  253. package/dist/esm/pages/SettingsPage/SettingsCard/SettingCardExpandable.js +3 -3
  254. package/dist/esm/pages/SettingsPage/SettingsCard/SettingCardExpandable.js.map +1 -1
  255. package/dist/esm/pages/SettingsPage/SettingsCard/SettingsAccordian.js +3 -3
  256. package/dist/esm/pages/SettingsPage/SettingsCard/SettingsAccordian.js.map +1 -1
  257. package/dist/esm/pages/SettingsPage/SlippageSettings/SlippagePage.js +133 -0
  258. package/dist/esm/pages/SettingsPage/SlippageSettings/SlippagePage.js.map +1 -0
  259. package/dist/esm/pages/SettingsPage/SlippageSettings/SlippageSettings.js +14 -72
  260. package/dist/esm/pages/SettingsPage/SlippageSettings/SlippageSettings.js.map +1 -1
  261. package/dist/esm/pages/SettingsPage/SlippageSettings/SlippageSettings.style.js +26 -14
  262. package/dist/esm/pages/SettingsPage/SlippageSettings/SlippageSettings.style.js.map +1 -1
  263. package/dist/esm/pages/SettingsPage/ThemeSettings.js +4 -0
  264. package/dist/esm/pages/SettingsPage/ThemeSettings.js.map +1 -1
  265. package/dist/esm/pages/TransactionDetailsPage/ContactSupportButton.style.js.map +1 -1
  266. package/dist/esm/pages/TransactionDetailsPage/TransactionDetailsPage.js.map +1 -1
  267. package/dist/esm/pages/TransactionDetailsPage/TransactionDetailsSkeleton.js.map +1 -1
  268. package/dist/esm/pages/TransactionPage/ConfirmToAddressSheet.js +3 -3
  269. package/dist/esm/pages/TransactionPage/ConfirmToAddressSheet.js.map +1 -1
  270. package/dist/esm/pages/TransactionPage/ExchangeRateBottomSheet.js +16 -15
  271. package/dist/esm/pages/TransactionPage/ExchangeRateBottomSheet.js.map +1 -1
  272. package/dist/esm/pages/TransactionPage/ExchangeRateBottomSheet.style.js.map +1 -1
  273. package/dist/esm/pages/TransactionPage/RouteTracker.js.map +1 -1
  274. package/dist/esm/pages/TransactionPage/TokenValueBottomSheet.js +3 -3
  275. package/dist/esm/pages/TransactionPage/TokenValueBottomSheet.js.map +1 -1
  276. package/dist/esm/pages/TransactionPage/TokenValueBottomSheet.style.js.map +1 -1
  277. package/dist/esm/pages/TransactionPage/TransactionExecutionContent.js +27 -31
  278. package/dist/esm/pages/TransactionPage/TransactionExecutionContent.js.map +1 -1
  279. package/dist/esm/pages/TransactionPage/TransactionReview.js +4 -1
  280. package/dist/esm/pages/TransactionPage/TransactionReview.js.map +1 -1
  281. package/dist/esm/pages/TransactionPage/utils.js.map +1 -1
  282. package/dist/esm/providers/I18nProvider/I18nProvider.js +1 -1
  283. package/dist/esm/providers/I18nProvider/I18nProvider.js.map +1 -1
  284. package/dist/esm/providers/I18nProvider/enResource.d.ts +1 -1
  285. package/dist/esm/providers/I18nProvider/enResource.js +1 -1
  286. package/dist/esm/providers/I18nProvider/i18n.js.map +1 -1
  287. package/dist/esm/providers/I18nProvider/types.d.ts +2 -2
  288. package/dist/esm/providers/QueryClientProvider.js +2 -2
  289. package/dist/esm/providers/QueryClientProvider.js.map +1 -1
  290. package/dist/esm/providers/SDKClientProvider.js +3 -3
  291. package/dist/esm/providers/SDKClientProvider.js.map +1 -1
  292. package/dist/esm/providers/WidgetProvider/WidgetProvider.js +4 -5
  293. package/dist/esm/providers/WidgetProvider/WidgetProvider.js.map +1 -1
  294. package/dist/esm/stores/StoreProvider.js +3 -4
  295. package/dist/esm/stores/StoreProvider.js.map +1 -1
  296. package/dist/esm/stores/bookmarks/BookmarkStore.js +3 -3
  297. package/dist/esm/stores/bookmarks/BookmarkStore.js.map +1 -1
  298. package/dist/esm/stores/bookmarks/createBookmarkStore.js.map +1 -1
  299. package/dist/esm/stores/chains/ChainOrderStore.js +4 -4
  300. package/dist/esm/stores/chains/ChainOrderStore.js.map +1 -1
  301. package/dist/esm/stores/chains/createChainOrderStore.js.map +1 -1
  302. package/dist/esm/stores/form/FormStore.js +1 -1
  303. package/dist/esm/stores/form/FormStore.js.map +1 -1
  304. package/dist/esm/stores/form/URLSearchParamsBuilder.js +14 -3
  305. package/dist/esm/stores/form/URLSearchParamsBuilder.js.map +1 -1
  306. package/dist/esm/stores/form/createFormStore.js +6 -2
  307. package/dist/esm/stores/form/createFormStore.js.map +1 -1
  308. package/dist/esm/stores/form/getDefaultValuesFromQueryString.js +3 -0
  309. package/dist/esm/stores/form/getDefaultValuesFromQueryString.js.map +1 -1
  310. package/dist/esm/stores/form/types.d.ts +9 -1
  311. package/dist/esm/stores/form/types.d.ts.map +1 -1
  312. package/dist/esm/stores/form/types.js.map +1 -1
  313. package/dist/esm/stores/form/useClearAmountFields.js +1 -0
  314. package/dist/esm/stores/form/useClearAmountFields.js.map +1 -1
  315. package/dist/esm/stores/form/useFieldActions.js.map +1 -1
  316. package/dist/esm/stores/form/useFieldValues.js.map +1 -1
  317. package/dist/esm/stores/form/useFormRef.js.map +1 -1
  318. package/dist/esm/stores/form/useFormStore.js +2 -2
  319. package/dist/esm/stores/form/useFormStore.js.map +1 -1
  320. package/dist/esm/stores/header/useHeaderStore.js +3 -3
  321. package/dist/esm/stores/header/useHeaderStore.js.map +1 -1
  322. package/dist/esm/stores/inputMode/useInputModeStore.js.map +1 -1
  323. package/dist/esm/stores/navigationTabs/useNavigationTabLabel.js +22 -0
  324. package/dist/esm/stores/navigationTabs/useNavigationTabLabel.js.map +1 -0
  325. package/dist/esm/stores/navigationTabs/useNavigationTabsStore.js +64 -0
  326. package/dist/esm/stores/navigationTabs/useNavigationTabsStore.js.map +1 -0
  327. package/dist/esm/stores/navigationTabs/utils.js +122 -0
  328. package/dist/esm/stores/navigationTabs/utils.js.map +1 -0
  329. package/dist/esm/stores/pinnedTokens/PinnedTokensStore.js +3 -3
  330. package/dist/esm/stores/pinnedTokens/PinnedTokensStore.js.map +1 -1
  331. package/dist/esm/stores/pinnedTokens/createPinnedTokensStore.js.map +1 -1
  332. package/dist/esm/stores/routes/RouteExecutionStore.js +3 -3
  333. package/dist/esm/stores/routes/RouteExecutionStore.js.map +1 -1
  334. package/dist/esm/stores/routes/createRouteExecutionStore.js.map +1 -1
  335. package/dist/esm/stores/routes/useIntermediateRoutesStore.js.map +1 -1
  336. package/dist/esm/stores/routes/useRouteExecutionIndicator.js.map +1 -1
  337. package/dist/esm/stores/routes/utils.js.map +1 -1
  338. package/dist/esm/stores/settings/SettingsStore.js +3 -3
  339. package/dist/esm/stores/settings/SettingsStore.js.map +1 -1
  340. package/dist/esm/stores/settings/createSettingsStore.js +122 -96
  341. package/dist/esm/stores/settings/createSettingsStore.js.map +1 -1
  342. package/dist/esm/stores/settings/types.d.ts +0 -2
  343. package/dist/esm/stores/settings/types.d.ts.map +1 -1
  344. package/dist/esm/stores/settings/types.js.map +1 -1
  345. package/dist/esm/stores/settings/useSettingsActions.js.map +1 -1
  346. package/dist/esm/themes/createTheme.js.map +1 -1
  347. package/dist/esm/themes/utils.js.map +1 -1
  348. package/dist/esm/types/events.d.ts +10 -1
  349. package/dist/esm/types/events.d.ts.map +1 -1
  350. package/dist/esm/types/events.js +2 -0
  351. package/dist/esm/types/events.js.map +1 -1
  352. package/dist/esm/types/widget.d.ts +28 -2
  353. package/dist/esm/types/widget.d.ts.map +1 -1
  354. package/dist/esm/types/widget.js.map +1 -1
  355. package/dist/esm/utils/compactNumberFormatter.js.map +1 -1
  356. package/dist/esm/utils/converters.js.map +1 -1
  357. package/dist/esm/utils/deepEqual.js.map +1 -1
  358. package/dist/esm/utils/fees.js.map +1 -1
  359. package/dist/esm/utils/format.d.ts +1 -1
  360. package/dist/esm/utils/format.d.ts.map +1 -1
  361. package/dist/esm/utils/format.js +2 -2
  362. package/dist/esm/utils/format.js.map +1 -1
  363. package/dist/esm/utils/getActionMessage.js.map +1 -1
  364. package/dist/esm/utils/getErrorMessage.js.map +1 -1
  365. package/dist/esm/utils/item.js.map +1 -1
  366. package/dist/esm/utils/limitOrder.js +61 -0
  367. package/dist/esm/utils/limitOrder.js.map +1 -0
  368. package/dist/esm/utils/{variant.js → mode.js} +2 -2
  369. package/dist/esm/utils/mode.js.map +1 -0
  370. package/dist/esm/utils/navigationRoutes.d.ts +2 -0
  371. package/dist/esm/utils/navigationRoutes.d.ts.map +1 -1
  372. package/dist/esm/utils/navigationRoutes.js +6 -0
  373. package/dist/esm/utils/navigationRoutes.js.map +1 -1
  374. package/dist/esm/utils/prepareActions.js +1 -1
  375. package/dist/esm/utils/prepareActions.js.map +1 -1
  376. package/dist/esm/utils/timer.js.map +1 -1
  377. package/dist/esm/utils/token.js +1 -1
  378. package/dist/esm/utils/token.js.map +1 -1
  379. package/dist/esm/utils/tokenList.js.map +1 -1
  380. package/package.json +13 -13
  381. package/src/App.tsx +7 -7
  382. package/src/AppDefault.tsx +16 -0
  383. package/src/AppDrawer.tsx +77 -78
  384. package/src/AppDrawerContext.ts +2 -2
  385. package/src/components/AmountInput/AmountInputEndAdornment.style.ts +1 -1
  386. package/src/components/AmountInput/AmountInputEndAdornment.tsx +5 -2
  387. package/src/components/AmountInputCard/AmountInputCard.style.tsx +157 -0
  388. package/src/components/AmountInputCard/AmountInputCardPair.tsx +25 -0
  389. package/src/components/AmountInputCard/BalanceDisplay.style.tsx +9 -0
  390. package/src/components/AmountInputCard/BalanceDisplay.tsx +46 -0
  391. package/src/components/AmountInputCard/FiatValueToggle.tsx +55 -0
  392. package/src/components/AmountInputCard/PercentageChips.style.tsx +60 -0
  393. package/src/components/AmountInputCard/PercentageChips.tsx +100 -0
  394. package/src/components/AmountInputCard/ReceiveAmountCard.tsx +219 -0
  395. package/src/components/AmountInputCard/SendAmountCard.tsx +179 -0
  396. package/src/components/Avatar/Avatar.tsx +8 -3
  397. package/src/components/BaseTransactionButton/BaseTransactionButton.tsx +1 -0
  398. package/src/components/BottomSheet/BottomSheet.tsx +56 -52
  399. package/src/components/Header/CloseDrawerButton.tsx +5 -1
  400. package/src/components/Header/Header.tsx +20 -18
  401. package/src/components/Header/HeaderNavigationTabs.tsx +42 -0
  402. package/src/components/Header/HeaderTabs.tsx +48 -0
  403. package/src/components/Header/NavigationHeader.tsx +11 -8
  404. package/src/components/LimitOrderSettings/LimitOrderSettings.style.tsx +69 -0
  405. package/src/components/LimitOrderSettings/LimitOrderSettings.tsx +124 -0
  406. package/src/components/LimitPriceCard/LimitPriceCard.style.tsx +103 -0
  407. package/src/components/LimitPriceCard/LimitPriceCard.tsx +153 -0
  408. package/src/components/LimitPriceCard/LimitPricePresets.tsx +139 -0
  409. package/src/components/ReverseTokensButton/ReverseTokensButton.tsx +4 -1
  410. package/src/components/RouteCard/RouteProviderCard.tsx +113 -0
  411. package/src/components/Routes/LimitOrderRoutes.tsx +64 -0
  412. package/src/components/Routes/Routes.tsx +3 -2
  413. package/src/components/SettingsPanel/SettingsPanel.style.tsx +41 -0
  414. package/src/components/SettingsPanel/SettingsPanel.tsx +73 -0
  415. package/src/components/SettingsPanel/utils.ts +27 -0
  416. package/src/components/Skeleton/WidgetSkeleton.tsx +1 -1
  417. package/src/components/SwapButton/SwapButton.style.tsx +28 -0
  418. package/src/components/SwapButton/SwapButton.tsx +71 -0
  419. package/src/components/Tabs/NavigationTabs.tsx +3 -0
  420. package/src/components/TokenList/TokenDetailsSheet.tsx +9 -7
  421. package/src/components/TokenList/TokenDetailsSheetContent.tsx +176 -177
  422. package/src/components/TokenList/useTokenSelect.ts +2 -2
  423. package/src/components/TokenPillButton/TokenPillButton.style.tsx +50 -0
  424. package/src/components/TokenPillButton/TokenPillButton.tsx +81 -0
  425. package/src/config/version.ts +1 -1
  426. package/src/hooks/useLimitMarketRate.ts +39 -0
  427. package/src/hooks/useLinkedLimitFields.ts +74 -0
  428. package/src/hooks/useRoutes.ts +45 -4
  429. package/src/hooks/useSwapOnly.ts +2 -5
  430. package/src/hooks/useToAddressRequirements.ts +2 -2
  431. package/src/hooks/useWideVariant.ts +8 -2
  432. package/src/pages/MainPage/LimitPageContent.tsx +18 -0
  433. package/src/pages/MainPage/MainPage.tsx +43 -30
  434. package/src/pages/MainPage/MainPageActions.tsx +35 -0
  435. package/src/pages/MainPage/ReviewButton.tsx +15 -3
  436. package/src/pages/RoutePriorityPage.tsx +55 -0
  437. package/src/pages/SendToWallet/BookmarkAddressSheet.tsx +176 -185
  438. package/src/pages/SendToWallet/ConfirmAddressSheet.tsx +9 -6
  439. package/src/pages/SettingsPage/RoutePrioritySettings.tsx +14 -38
  440. package/src/pages/SettingsPage/SettingsCard/SettingCardExpandable.tsx +58 -65
  441. package/src/pages/SettingsPage/SettingsCard/SettingsAccordian.tsx +4 -4
  442. package/src/pages/SettingsPage/SlippageSettings/SlippagePage.tsx +176 -0
  443. package/src/pages/SettingsPage/SlippageSettings/SlippageSettings.style.tsx +32 -25
  444. package/src/pages/SettingsPage/SlippageSettings/SlippageSettings.tsx +14 -128
  445. package/src/pages/SettingsPage/ThemeSettings.tsx +4 -0
  446. package/src/pages/TransactionPage/ConfirmToAddressSheet.tsx +9 -6
  447. package/src/pages/TransactionPage/ExchangeRateBottomSheet.tsx +53 -58
  448. package/src/pages/TransactionPage/TokenValueBottomSheet.tsx +24 -21
  449. package/src/pages/TransactionPage/TransactionExecutionContent.tsx +8 -6
  450. package/src/providers/QueryClientProvider.tsx +2 -2
  451. package/src/providers/SDKClientProvider.tsx +3 -7
  452. package/src/providers/WidgetProvider/WidgetProvider.tsx +6 -7
  453. package/src/stores/StoreProvider.tsx +3 -10
  454. package/src/stores/bookmarks/BookmarkStore.tsx +4 -4
  455. package/src/stores/chains/ChainOrderStore.tsx +4 -4
  456. package/src/stores/form/FormStore.tsx +2 -2
  457. package/src/stores/form/URLSearchParamsBuilder.tsx +25 -3
  458. package/src/stores/form/createFormStore.ts +7 -3
  459. package/src/stores/form/getDefaultValuesFromQueryString.ts +11 -0
  460. package/src/stores/form/types.ts +14 -1
  461. package/src/stores/form/useClearAmountFields.ts +1 -0
  462. package/src/stores/form/useFormStore.ts +2 -2
  463. package/src/stores/header/useHeaderStore.tsx +3 -5
  464. package/src/stores/navigationTabs/types.ts +33 -0
  465. package/src/stores/navigationTabs/useNavigationTabLabel.ts +28 -0
  466. package/src/stores/navigationTabs/useNavigationTabsStore.tsx +113 -0
  467. package/src/stores/navigationTabs/utils.ts +196 -0
  468. package/src/stores/pinnedTokens/PinnedTokensStore.tsx +4 -4
  469. package/src/stores/routes/RouteExecutionStore.tsx +4 -4
  470. package/src/stores/settings/SettingsStore.tsx +4 -4
  471. package/src/stores/settings/createSettingsStore.ts +48 -12
  472. package/src/stores/settings/types.ts +1 -16
  473. package/src/types/events.ts +12 -0
  474. package/src/types/widget.ts +40 -1
  475. package/src/utils/format.ts +6 -2
  476. package/src/utils/limitOrder.ts +88 -0
  477. package/src/utils/navigationRoutes.ts +6 -0
  478. package/dist/esm/components/Header/SplitNavigationTabs.js +0 -33
  479. package/dist/esm/components/Header/SplitNavigationTabs.js.map +0 -1
  480. package/dist/esm/stores/settings/useSplitModeStore.js +0 -36
  481. package/dist/esm/stores/settings/useSplitModeStore.js.map +0 -1
  482. package/dist/esm/utils/variant.js.map +0 -1
  483. package/src/components/Header/SplitNavigationTabs.tsx +0 -32
  484. package/src/stores/settings/useSplitModeStore.tsx +0 -58
  485. /package/src/utils/{variant.ts → mode.ts} +0 -0
@@ -0,0 +1,122 @@
1
+ import { getSplitMode } from "../../utils/mode.js";
2
+ //#region src/stores/navigationTabs/utils.ts
3
+ /** Configured navigation tabs by key. Labels are resolved from the key by a hook. */
4
+ const navigationTabsByKey = {
5
+ default: {
6
+ key: "default",
7
+ variant: "wide",
8
+ mode: "default",
9
+ defaultUI: { layout: "cards" }
10
+ },
11
+ private: {
12
+ key: "private",
13
+ variant: "compact",
14
+ mode: "default",
15
+ defaultUI: { layout: "cards" },
16
+ requiredUI: { toAddress: true }
17
+ },
18
+ refuel: {
19
+ key: "refuel",
20
+ variant: "wide",
21
+ mode: "refuel",
22
+ defaultUI: { layout: "cards" }
23
+ },
24
+ limit: {
25
+ key: "limit",
26
+ variant: "compact",
27
+ mode: "limit",
28
+ defaultUI: { layout: "cards" }
29
+ },
30
+ "swap-advanced": {
31
+ key: "swap-advanced",
32
+ variant: "wide",
33
+ mode: "split",
34
+ modeOptions: { split: "swap" },
35
+ defaultUI: { layout: "cards" }
36
+ },
37
+ "bridge-advanced": {
38
+ key: "bridge-advanced",
39
+ variant: "wide",
40
+ mode: "split",
41
+ modeOptions: { split: "bridge" },
42
+ defaultUI: { layout: "cards" }
43
+ }
44
+ };
45
+ /** Split-mode tabs (Swap / Bridge), shown when no navigation tabs are configured. */
46
+ const splitTabs = [{
47
+ key: "swap",
48
+ mode: "split",
49
+ modeOptions: { split: "swap" }
50
+ }, {
51
+ key: "bridge",
52
+ mode: "split",
53
+ modeOptions: { split: "bridge" }
54
+ }];
55
+ const splitTabsByKey = Object.fromEntries(splitTabs.map((tab) => [tab.key, tab]));
56
+ /** Combined lookup across configured and split tabs. */
57
+ const tabByKey = {
58
+ ...navigationTabsByKey,
59
+ ...splitTabsByKey
60
+ };
61
+ /** Tab keys shown in split mode when no navigation tabs are configured. */
62
+ const splitTabKeys = splitTabs.map((tab) => tab.key);
63
+ /** Resolves which navigation tabs the header should render from the config. */
64
+ const getNavigationTabKeys = (config) => {
65
+ if (config._navigationTabs?.length) return config._navigationTabs;
66
+ if (config.mode === "split" && typeof config.modeOptions?.split !== "string") return splitTabKeys;
67
+ return [];
68
+ };
69
+ /**
70
+ * The tab the store seeds as active from the config. With navigation tabs it's
71
+ * the first configured tab; otherwise split mode's selection is itself a tab
72
+ * (`swap`/`bridge`), so it seeds the active tab too.
73
+ */
74
+ const getInitialActiveTab = (config) => {
75
+ if (config._navigationTabs?.length) return config._navigationTabs[0];
76
+ return config.mode === "split" ? getSplitMode(config.modeOptions?.split) : void 0;
77
+ };
78
+ /** Split mode (`swap`/`bridge`) implied by a tab, or `undefined` if not split. */
79
+ const getTabSplitMode = (key) => {
80
+ const tab = key ? tabByKey[key] : void 0;
81
+ return tab?.mode === "split" ? getSplitMode(tab.modeOptions?.split) : void 0;
82
+ };
83
+ /** Variant for a tab, falling back to the widget config's variant when unset. */
84
+ const getTabVariant = (config, key) => {
85
+ return (key ? tabByKey[key] : void 0)?.variant ?? config.variant;
86
+ };
87
+ /** Mode for a tab, falling back to the widget config's mode when unset. */
88
+ const getTabMode = (config, key) => {
89
+ return (key ? tabByKey[key] : void 0)?.mode ?? config.mode;
90
+ };
91
+ /** Mode options for a tab, falling back to the widget config's when unset. */
92
+ const getTabModeOptions = (config, key) => {
93
+ return (key ? tabByKey[key] : void 0)?.modeOptions ?? config.modeOptions;
94
+ };
95
+ /**
96
+ * Default UI for a tab, layered over the widget config's `defaultUI` so the
97
+ * tab overrides only the fields it sets and inherits the rest.
98
+ */
99
+ const getTabDefaultUI = (config, key) => {
100
+ const tab = key ? tabByKey[key] : void 0;
101
+ if (!tab?.defaultUI) return config.defaultUI;
102
+ return {
103
+ ...config.defaultUI,
104
+ ...tab.defaultUI
105
+ };
106
+ };
107
+ /**
108
+ * Required UI for a tab, layered over the widget config's `requiredUI` so the
109
+ * tab overrides only the fields it sets and inherits the rest.
110
+ */
111
+ const getTabRequiredUI = (config, key) => {
112
+ const tab = key ? tabByKey[key] : void 0;
113
+ if (!tab?.requiredUI) return config.requiredUI;
114
+ return {
115
+ ...config.requiredUI,
116
+ ...tab.requiredUI
117
+ };
118
+ };
119
+ //#endregion
120
+ export { getInitialActiveTab, getNavigationTabKeys, getTabDefaultUI, getTabMode, getTabModeOptions, getTabRequiredUI, getTabSplitMode, getTabVariant, splitTabKeys };
121
+
122
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../../../src/stores/navigationTabs/utils.ts"],"sourcesContent":["import type {\n DefaultUI,\n InternalNavigationTabKey,\n ModeOptions,\n NavigationTabKey,\n RequiredUIConfig,\n SplitMode,\n SplitNavigationTabKey,\n WidgetConfig,\n WidgetMode,\n WidgetVariant,\n} from '../../types/widget.js'\nimport { getSplitMode } from '../../utils/mode.js'\nimport type { NavigationTab } from './types.js'\n\n/** Configured navigation tabs by key. Labels are resolved from the key by a hook. */\nconst navigationTabsByKey: Record<InternalNavigationTabKey, NavigationTab> = {\n default: {\n key: 'default',\n variant: 'wide',\n mode: 'default',\n defaultUI: {\n layout: 'cards',\n },\n },\n private: {\n key: 'private',\n variant: 'compact',\n mode: 'default',\n defaultUI: {\n layout: 'cards',\n },\n requiredUI: { toAddress: true },\n },\n refuel: {\n key: 'refuel',\n variant: 'wide',\n mode: 'refuel',\n defaultUI: {\n layout: 'cards',\n },\n },\n limit: {\n key: 'limit',\n variant: 'compact',\n mode: 'limit',\n defaultUI: {\n layout: 'cards',\n },\n },\n 'swap-advanced': {\n key: 'swap-advanced',\n variant: 'wide',\n mode: 'split',\n modeOptions: { split: 'swap' },\n defaultUI: {\n layout: 'cards',\n },\n },\n 'bridge-advanced': {\n key: 'bridge-advanced',\n variant: 'wide',\n mode: 'split',\n modeOptions: { split: 'bridge' },\n defaultUI: {\n layout: 'cards',\n },\n },\n}\n\n/** Split-mode tabs (Swap / Bridge), shown when no navigation tabs are configured. */\nconst splitTabs: NavigationTab[] = [\n {\n key: 'swap',\n mode: 'split',\n modeOptions: { split: 'swap' },\n },\n {\n key: 'bridge',\n mode: 'split',\n modeOptions: { split: 'bridge' },\n },\n]\n\nconst splitTabsByKey = Object.fromEntries(\n splitTabs.map((tab) => [tab.key, tab])\n) as Record<SplitNavigationTabKey, NavigationTab>\n\n/** Combined lookup across configured and split tabs. */\nconst tabByKey: Record<NavigationTabKey, NavigationTab> = {\n ...navigationTabsByKey,\n ...splitTabsByKey,\n}\n\n/** Tab keys shown in split mode when no navigation tabs are configured. */\nexport const splitTabKeys: NavigationTabKey[] = splitTabs.map((tab) => tab.key)\n\n/** Resolves which navigation tabs the header should render from the config. */\nexport const getNavigationTabKeys = (\n config: WidgetConfig\n): NavigationTabKey[] => {\n if (config._navigationTabs?.length) {\n return config._navigationTabs\n }\n // Split mode shows Swap / Bridge tabs unless pinned to a single side.\n if (\n config.mode === 'split' &&\n typeof config.modeOptions?.split !== 'string'\n ) {\n return splitTabKeys\n }\n return []\n}\n\n/**\n * The tab the store seeds as active from the config. With navigation tabs it's\n * the first configured tab; otherwise split mode's selection is itself a tab\n * (`swap`/`bridge`), so it seeds the active tab too.\n */\nexport const getInitialActiveTab = (\n config: WidgetConfig\n): NavigationTabKey | undefined => {\n if (config._navigationTabs?.length) {\n return config._navigationTabs[0]\n }\n return config.mode === 'split'\n ? getSplitMode(config.modeOptions?.split)\n : undefined\n}\n\n/** Split mode (`swap`/`bridge`) implied by a tab, or `undefined` if not split. */\nexport const getTabSplitMode = (\n key?: NavigationTabKey\n): SplitMode | undefined => {\n const tab = key ? tabByKey[key] : undefined\n return tab?.mode === 'split'\n ? getSplitMode(tab.modeOptions?.split)\n : undefined\n}\n\n/** Variant for a tab, falling back to the widget config's variant when unset. */\nexport const getTabVariant = (\n config: WidgetConfig,\n key?: NavigationTabKey\n): WidgetVariant | undefined => {\n const tab = key ? tabByKey[key] : undefined\n return tab?.variant ?? config.variant\n}\n\n/** Mode for a tab, falling back to the widget config's mode when unset. */\nexport const getTabMode = (\n config: WidgetConfig,\n key?: NavigationTabKey\n): WidgetMode | undefined => {\n const tab = key ? tabByKey[key] : undefined\n return tab?.mode ?? config.mode\n}\n\n/** Mode options for a tab, falling back to the widget config's when unset. */\nexport const getTabModeOptions = (\n config: WidgetConfig,\n key?: NavigationTabKey\n): ModeOptions | undefined => {\n const tab = key ? tabByKey[key] : undefined\n return tab?.modeOptions ?? config.modeOptions\n}\n\n/**\n * Default UI for a tab, layered over the widget config's `defaultUI` so the\n * tab overrides only the fields it sets and inherits the rest.\n */\nexport const getTabDefaultUI = (\n config: WidgetConfig,\n key?: NavigationTabKey\n): DefaultUI | undefined => {\n const tab = key ? tabByKey[key] : undefined\n if (!tab?.defaultUI) {\n return config.defaultUI\n }\n return { ...config.defaultUI, ...tab.defaultUI }\n}\n\n/**\n * Required UI for a tab, layered over the widget config's `requiredUI` so the\n * tab overrides only the fields it sets and inherits the rest.\n */\nexport const getTabRequiredUI = (\n config: WidgetConfig,\n key?: NavigationTabKey\n): RequiredUIConfig | undefined => {\n const tab = key ? tabByKey[key] : undefined\n if (!tab?.requiredUI) {\n return config.requiredUI\n }\n return { ...config.requiredUI, ...tab.requiredUI }\n}\n"],"mappings":";;;AAgBA,MAAM,sBAAuE;CAC3E,SAAS;EACP,KAAK;EACL,SAAS;EACT,MAAM;EACN,WAAW,EACT,QAAQ,QACV;CACF;CACA,SAAS;EACP,KAAK;EACL,SAAS;EACT,MAAM;EACN,WAAW,EACT,QAAQ,QACV;EACA,YAAY,EAAE,WAAW,KAAK;CAChC;CACA,QAAQ;EACN,KAAK;EACL,SAAS;EACT,MAAM;EACN,WAAW,EACT,QAAQ,QACV;CACF;CACA,OAAO;EACL,KAAK;EACL,SAAS;EACT,MAAM;EACN,WAAW,EACT,QAAQ,QACV;CACF;CACA,iBAAiB;EACf,KAAK;EACL,SAAS;EACT,MAAM;EACN,aAAa,EAAE,OAAO,OAAO;EAC7B,WAAW,EACT,QAAQ,QACV;CACF;CACA,mBAAmB;EACjB,KAAK;EACL,SAAS;EACT,MAAM;EACN,aAAa,EAAE,OAAO,SAAS;EAC/B,WAAW,EACT,QAAQ,QACV;CACF;AACF;;AAGA,MAAM,YAA6B,CACjC;CACE,KAAK;CACL,MAAM;CACN,aAAa,EAAE,OAAO,OAAO;AAC/B,GACA;CACE,KAAK;CACL,MAAM;CACN,aAAa,EAAE,OAAO,SAAS;AACjC,CACF;AAEA,MAAM,iBAAiB,OAAO,YAC5B,UAAU,KAAK,QAAQ,CAAC,IAAI,KAAK,GAAG,CAAC,CACvC;;AAGA,MAAM,WAAoD;CACxD,GAAG;CACH,GAAG;AACL;;AAGA,MAAa,eAAmC,UAAU,KAAK,QAAQ,IAAI,GAAG;;AAG9E,MAAa,wBACX,WACuB;CACvB,IAAI,OAAO,iBAAiB,QAC1B,OAAO,OAAO;CAGhB,IACE,OAAO,SAAS,WAChB,OAAO,OAAO,aAAa,UAAU,UAErC,OAAO;CAET,OAAO,CAAC;AACV;;;;;;AAOA,MAAa,uBACX,WACiC;CACjC,IAAI,OAAO,iBAAiB,QAC1B,OAAO,OAAO,gBAAgB;CAEhC,OAAO,OAAO,SAAS,UACnB,aAAa,OAAO,aAAa,KAAK,IACtC,KAAA;AACN;;AAGA,MAAa,mBACX,QAC0B;CAC1B,MAAM,MAAM,MAAM,SAAS,OAAO,KAAA;CAClC,OAAO,KAAK,SAAS,UACjB,aAAa,IAAI,aAAa,KAAK,IACnC,KAAA;AACN;;AAGA,MAAa,iBACX,QACA,QAC8B;CAE9B,QADY,MAAM,SAAS,OAAO,KAAA,EAAA,EACtB,WAAW,OAAO;AAChC;;AAGA,MAAa,cACX,QACA,QAC2B;CAE3B,QADY,MAAM,SAAS,OAAO,KAAA,EAAA,EACtB,QAAQ,OAAO;AAC7B;;AAGA,MAAa,qBACX,QACA,QAC4B;CAE5B,QADY,MAAM,SAAS,OAAO,KAAA,EAAA,EACtB,eAAe,OAAO;AACpC;;;;;AAMA,MAAa,mBACX,QACA,QAC0B;CAC1B,MAAM,MAAM,MAAM,SAAS,OAAO,KAAA;CAClC,IAAI,CAAC,KAAK,WACR,OAAO,OAAO;CAEhB,OAAO;EAAE,GAAG,OAAO;EAAW,GAAG,IAAI;CAAU;AACjD;;;;;AAMA,MAAa,oBACX,QACA,QACiC;CACjC,MAAM,MAAM,MAAM,SAAS,OAAO,KAAA;CAClC,IAAI,CAAC,KAAK,YACR,OAAO,OAAO;CAEhB,OAAO;EAAE,GAAG,OAAO;EAAY,GAAG,IAAI;CAAW;AACnD"}
@@ -1,5 +1,5 @@
1
1
  import { createPinnedTokensStore } from "./createPinnedTokensStore.js";
2
- import { createContext, useContext, useRef } from "react";
2
+ import { createContext, use, useRef } from "react";
3
3
  import { useShallow } from "zustand/shallow";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  //#region src/stores/pinnedTokens/PinnedTokensStore.tsx
@@ -7,13 +7,13 @@ const PinnedTokensStoreContext = createContext(null);
7
7
  const PinnedTokensStoreProvider = ({ children, ...props }) => {
8
8
  const storeRef = useRef(null);
9
9
  if (!storeRef.current) storeRef.current = createPinnedTokensStore(props);
10
- return /* @__PURE__ */ jsx(PinnedTokensStoreContext.Provider, {
10
+ return /* @__PURE__ */ jsx(PinnedTokensStoreContext, {
11
11
  value: storeRef.current,
12
12
  children
13
13
  });
14
14
  };
15
15
  function usePinnedTokensStore(selector) {
16
- const useStore = useContext(PinnedTokensStoreContext);
16
+ const useStore = use(PinnedTokensStoreContext);
17
17
  if (!useStore) throw new Error(`You forgot to wrap your component in <${PinnedTokensStoreProvider.name}>.`);
18
18
  return useStore(useShallow(selector));
19
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PinnedTokensStore.js","names":[],"sources":["../../../../src/stores/pinnedTokens/PinnedTokensStore.tsx"],"sourcesContent":["import { createContext, useContext, useRef } from 'react'\nimport { useShallow } from 'zustand/shallow'\nimport type { PersistStoreProviderProps } from '../types.js'\nimport { createPinnedTokensStore } from './createPinnedTokensStore.js'\nimport type { PinnedTokensState, PinnedTokensStore } from './types.js'\n\nconst PinnedTokensStoreContext = createContext<PinnedTokensStore | null>(null)\n\nexport const PinnedTokensStoreProvider: React.FC<PersistStoreProviderProps> = ({\n children,\n ...props\n}) => {\n const storeRef = useRef<PinnedTokensStore>(null)\n\n if (!storeRef.current) {\n storeRef.current = createPinnedTokensStore(props)\n }\n\n return (\n <PinnedTokensStoreContext.Provider value={storeRef.current}>\n {children}\n </PinnedTokensStoreContext.Provider>\n )\n}\n\nexport function usePinnedTokensStore<T>(\n selector: (store: PinnedTokensState) => T\n): T {\n const useStore = useContext(PinnedTokensStoreContext)\n\n if (!useStore) {\n throw new Error(\n `You forgot to wrap your component in <${PinnedTokensStoreProvider.name}>.`\n )\n }\n\n return useStore(useShallow(selector))\n}\n"],"mappings":";;;;;AAMA,MAAM,2BAA2B,cAAwC,IAAI;AAE7E,MAAa,6BAAkE,EAC7E,UACA,GAAG,YACC;CACJ,MAAM,WAAW,OAA0B,IAAI;CAE/C,IAAI,CAAC,SAAS,SACZ,SAAS,UAAU,wBAAwB,KAAK;CAGlD,OACE,oBAAC,yBAAyB,UAA1B;EAAmC,OAAO,SAAS;EAChD;CACgC,CAAA;AAEvC;AAEA,SAAgB,qBACd,UACG;CACH,MAAM,WAAW,WAAW,wBAAwB;CAEpD,IAAI,CAAC,UACH,MAAM,IAAI,MACR,yCAAyC,0BAA0B,KAAK,GAC1E;CAGF,OAAO,SAAS,WAAW,QAAQ,CAAC;AACtC"}
1
+ {"version":3,"file":"PinnedTokensStore.js","names":[],"sources":["../../../../src/stores/pinnedTokens/PinnedTokensStore.tsx"],"sourcesContent":["import { createContext, use, useRef } from 'react'\nimport { useShallow } from 'zustand/shallow'\nimport type { PersistStoreProviderProps } from '../types.js'\nimport { createPinnedTokensStore } from './createPinnedTokensStore.js'\nimport type { PinnedTokensState, PinnedTokensStore } from './types.js'\n\nconst PinnedTokensStoreContext = createContext<PinnedTokensStore | null>(null)\n\nexport const PinnedTokensStoreProvider: React.FC<PersistStoreProviderProps> = ({\n children,\n ...props\n}) => {\n const storeRef = useRef<PinnedTokensStore>(null)\n\n if (!storeRef.current) {\n storeRef.current = createPinnedTokensStore(props)\n }\n\n return (\n <PinnedTokensStoreContext value={storeRef.current}>\n {children}\n </PinnedTokensStoreContext>\n )\n}\n\nexport function usePinnedTokensStore<T>(\n selector: (store: PinnedTokensState) => T\n): T {\n const useStore = use(PinnedTokensStoreContext)\n\n if (!useStore) {\n throw new Error(\n `You forgot to wrap your component in <${PinnedTokensStoreProvider.name}>.`\n )\n }\n\n return useStore(useShallow(selector))\n}\n"],"mappings":";;;;;AAMA,MAAM,2BAA2B,cAAwC,IAAI;AAE7E,MAAa,6BAAkE,EAC7E,UACA,GAAG,YACC;CACJ,MAAM,WAAW,OAA0B,IAAI;CAE/C,IAAI,CAAC,SAAS,SACZ,SAAS,UAAU,wBAAwB,KAAK;CAGlD,OACE,oBAAC,0BAAD;EAA0B,OAAO,SAAS;EACvC;CACuB,CAAA;AAE9B;AAEA,SAAgB,qBACd,UACG;CACH,MAAM,WAAW,IAAI,wBAAwB;CAE7C,IAAI,CAAC,UACH,MAAM,IAAI,MACR,yCAAyC,0BAA0B,KAAK,GAC1E;CAGF,OAAO,SAAS,WAAW,QAAQ,CAAC;AACtC"}
@@ -1 +1 @@
1
- {"version":3,"file":"createPinnedTokensStore.js","names":[],"sources":["../../../../src/stores/pinnedTokens/createPinnedTokensStore.ts"],"sourcesContent":["import type { StoreApi, UseBoundStore } from 'zustand'\nimport { create } from 'zustand'\nimport { persist } from 'zustand/middleware'\nimport type { PersistStoreProps } from '../types.js'\nimport type { PinnedTokensState } from './types.js'\n\nexport const createPinnedTokensStore = ({\n namePrefix,\n}: PersistStoreProps): UseBoundStore<StoreApi<PinnedTokensState>> =>\n create<PinnedTokensState>()(\n persist(\n (set, get) => ({\n pinnedTokens: {},\n pinToken: (chainId: number, tokenAddress: string) => {\n set((state) => {\n const normalizedAddress = tokenAddress.toLowerCase()\n const chainTokens = state.pinnedTokens[chainId] || []\n if (!chainTokens.includes(normalizedAddress)) {\n return {\n pinnedTokens: {\n ...state.pinnedTokens,\n [chainId]: [...chainTokens, normalizedAddress],\n },\n }\n }\n return state\n })\n },\n unpinToken: (chainId: number, tokenAddress: string) => {\n set((state) => {\n const normalizedAddress = tokenAddress.toLowerCase()\n const chainTokens = state.pinnedTokens[chainId] || []\n if (chainTokens.includes(normalizedAddress)) {\n return {\n pinnedTokens: {\n ...state.pinnedTokens,\n [chainId]: chainTokens.filter(\n (addr) => addr !== normalizedAddress\n ),\n },\n }\n }\n return state\n })\n },\n isPinned: (chainId: number, tokenAddress: string) => {\n const normalizedAddress = tokenAddress.toLowerCase()\n const chainTokens = get().pinnedTokens[chainId] || []\n return chainTokens.includes(normalizedAddress)\n },\n getPinnedTokens: (chainId: number) => {\n return get().pinnedTokens[chainId] || []\n },\n getAllPinnedTokens: () => {\n const allPinned: Array<{ chainId: number; tokenAddress: string }> = []\n const pinnedTokens = get().pinnedTokens\n Object.entries(pinnedTokens).forEach(([chainIdStr, addresses]) => {\n const chainId = Number.parseInt(chainIdStr, 10)\n addresses.forEach((address) => {\n allPinned.push({ chainId, tokenAddress: address })\n })\n })\n return allPinned\n },\n }),\n {\n name: `${namePrefix || 'li.fi'}-pinned-tokens`,\n version: 0,\n partialize: (state) => ({\n pinnedTokens: state.pinnedTokens,\n }),\n }\n )\n )\n"],"mappings":";;;AAMA,MAAa,2BAA2B,EACtC,iBAEA,OAA0B,EACxB,SACG,KAAK,SAAS;CACb,cAAc,CAAC;CACf,WAAW,SAAiB,iBAAyB;EACnD,KAAK,UAAU;GACb,MAAM,oBAAoB,aAAa,YAAY;GACnD,MAAM,cAAc,MAAM,aAAa,YAAY,CAAC;GACpD,IAAI,CAAC,YAAY,SAAS,iBAAiB,GACzC,OAAO,EACL,cAAc;IACZ,GAAG,MAAM;KACR,UAAU,CAAC,GAAG,aAAa,iBAAiB;GAC/C,EACF;GAEF,OAAO;EACT,CAAC;CACH;CACA,aAAa,SAAiB,iBAAyB;EACrD,KAAK,UAAU;GACb,MAAM,oBAAoB,aAAa,YAAY;GACnD,MAAM,cAAc,MAAM,aAAa,YAAY,CAAC;GACpD,IAAI,YAAY,SAAS,iBAAiB,GACxC,OAAO,EACL,cAAc;IACZ,GAAG,MAAM;KACR,UAAU,YAAY,QACpB,SAAS,SAAS,iBACrB;GACF,EACF;GAEF,OAAO;EACT,CAAC;CACH;CACA,WAAW,SAAiB,iBAAyB;EACnD,MAAM,oBAAoB,aAAa,YAAY;EAEnD,QADoB,IAAI,EAAE,aAAa,YAAY,CAAC,GACjC,SAAS,iBAAiB;CAC/C;CACA,kBAAkB,YAAoB;EACpC,OAAO,IAAI,EAAE,aAAa,YAAY,CAAC;CACzC;CACA,0BAA0B;EACxB,MAAM,YAA8D,CAAC;EACrE,MAAM,eAAe,IAAI,EAAE;EAC3B,OAAO,QAAQ,YAAY,EAAE,SAAS,CAAC,YAAY,eAAe;GAChE,MAAM,UAAU,OAAO,SAAS,YAAY,EAAE;GAC9C,UAAU,SAAS,YAAY;IAC7B,UAAU,KAAK;KAAE;KAAS,cAAc;IAAQ,CAAC;GACnD,CAAC;EACH,CAAC;EACD,OAAO;CACT;AACF,IACA;CACE,MAAM,GAAG,cAAc,QAAQ;CAC/B,SAAS;CACT,aAAa,WAAW,EACtB,cAAc,MAAM,aACtB;AACF,CACF,CACF"}
1
+ {"version":3,"file":"createPinnedTokensStore.js","names":[],"sources":["../../../../src/stores/pinnedTokens/createPinnedTokensStore.ts"],"sourcesContent":["import type { StoreApi, UseBoundStore } from 'zustand'\nimport { create } from 'zustand'\nimport { persist } from 'zustand/middleware'\nimport type { PersistStoreProps } from '../types.js'\nimport type { PinnedTokensState } from './types.js'\n\nexport const createPinnedTokensStore = ({\n namePrefix,\n}: PersistStoreProps): UseBoundStore<StoreApi<PinnedTokensState>> =>\n create<PinnedTokensState>()(\n persist(\n (set, get) => ({\n pinnedTokens: {},\n pinToken: (chainId: number, tokenAddress: string) => {\n set((state) => {\n const normalizedAddress = tokenAddress.toLowerCase()\n const chainTokens = state.pinnedTokens[chainId] || []\n if (!chainTokens.includes(normalizedAddress)) {\n return {\n pinnedTokens: {\n ...state.pinnedTokens,\n [chainId]: [...chainTokens, normalizedAddress],\n },\n }\n }\n return state\n })\n },\n unpinToken: (chainId: number, tokenAddress: string) => {\n set((state) => {\n const normalizedAddress = tokenAddress.toLowerCase()\n const chainTokens = state.pinnedTokens[chainId] || []\n if (chainTokens.includes(normalizedAddress)) {\n return {\n pinnedTokens: {\n ...state.pinnedTokens,\n [chainId]: chainTokens.filter(\n (addr) => addr !== normalizedAddress\n ),\n },\n }\n }\n return state\n })\n },\n isPinned: (chainId: number, tokenAddress: string) => {\n const normalizedAddress = tokenAddress.toLowerCase()\n const chainTokens = get().pinnedTokens[chainId] || []\n return chainTokens.includes(normalizedAddress)\n },\n getPinnedTokens: (chainId: number) => {\n return get().pinnedTokens[chainId] || []\n },\n getAllPinnedTokens: () => {\n const allPinned: Array<{ chainId: number; tokenAddress: string }> = []\n const pinnedTokens = get().pinnedTokens\n Object.entries(pinnedTokens).forEach(([chainIdStr, addresses]) => {\n const chainId = Number.parseInt(chainIdStr, 10)\n addresses.forEach((address) => {\n allPinned.push({ chainId, tokenAddress: address })\n })\n })\n return allPinned\n },\n }),\n {\n name: `${namePrefix || 'li.fi'}-pinned-tokens`,\n version: 0,\n partialize: (state) => ({\n pinnedTokens: state.pinnedTokens,\n }),\n }\n )\n )\n"],"mappings":";;;AAMA,MAAa,2BAA2B,EACtC,iBAEA,OAA0B,CAAC,CACzB,SACG,KAAK,SAAS;CACb,cAAc,CAAC;CACf,WAAW,SAAiB,iBAAyB;EACnD,KAAK,UAAU;GACb,MAAM,oBAAoB,aAAa,YAAY;GACnD,MAAM,cAAc,MAAM,aAAa,YAAY,CAAC;GACpD,IAAI,CAAC,YAAY,SAAS,iBAAiB,GACzC,OAAO,EACL,cAAc;IACZ,GAAG,MAAM;KACR,UAAU,CAAC,GAAG,aAAa,iBAAiB;GAC/C,EACF;GAEF,OAAO;EACT,CAAC;CACH;CACA,aAAa,SAAiB,iBAAyB;EACrD,KAAK,UAAU;GACb,MAAM,oBAAoB,aAAa,YAAY;GACnD,MAAM,cAAc,MAAM,aAAa,YAAY,CAAC;GACpD,IAAI,YAAY,SAAS,iBAAiB,GACxC,OAAO,EACL,cAAc;IACZ,GAAG,MAAM;KACR,UAAU,YAAY,QACpB,SAAS,SAAS,iBACrB;GACF,EACF;GAEF,OAAO;EACT,CAAC;CACH;CACA,WAAW,SAAiB,iBAAyB;EACnD,MAAM,oBAAoB,aAAa,YAAY;EAEnD,QADoB,IAAI,CAAC,CAAC,aAAa,YAAY,CAAC,EAAA,CACjC,SAAS,iBAAiB;CAC/C;CACA,kBAAkB,YAAoB;EACpC,OAAO,IAAI,CAAC,CAAC,aAAa,YAAY,CAAC;CACzC;CACA,0BAA0B;EACxB,MAAM,YAA8D,CAAC;EACrE,MAAM,eAAe,IAAI,CAAC,CAAC;EAC3B,OAAO,QAAQ,YAAY,CAAC,CAAC,SAAS,CAAC,YAAY,eAAe;GAChE,MAAM,UAAU,OAAO,SAAS,YAAY,EAAE;GAC9C,UAAU,SAAS,YAAY;IAC7B,UAAU,KAAK;KAAE;KAAS,cAAc;IAAQ,CAAC;GACnD,CAAC;EACH,CAAC;EACD,OAAO;CACT;AACF,IACA;CACE,MAAM,GAAG,cAAc,QAAQ;CAC/B,SAAS;CACT,aAAa,WAAW,EACtB,cAAc,MAAM,aACtB;AACF,CACF,CACF"}
@@ -1,5 +1,5 @@
1
1
  import { createRouteExecutionStore } from "./createRouteExecutionStore.js";
2
- import { createContext, useContext, useRef } from "react";
2
+ import { createContext, use, useRef } from "react";
3
3
  import { useShallow } from "zustand/shallow";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  //#region src/stores/routes/RouteExecutionStore.tsx
@@ -7,13 +7,13 @@ const RouteExecutionStoreContext = createContext(null);
7
7
  function RouteExecutionStoreProvider({ children, ...props }) {
8
8
  const storeRef = useRef(null);
9
9
  if (!storeRef.current) storeRef.current = createRouteExecutionStore(props);
10
- return /* @__PURE__ */ jsx(RouteExecutionStoreContext.Provider, {
10
+ return /* @__PURE__ */ jsx(RouteExecutionStoreContext, {
11
11
  value: storeRef.current,
12
12
  children
13
13
  });
14
14
  }
15
15
  function useRouteExecutionStoreContext() {
16
- const useStore = useContext(RouteExecutionStoreContext);
16
+ const useStore = use(RouteExecutionStoreContext);
17
17
  if (!useStore) throw new Error(`You forgot to wrap your component in <${RouteExecutionStoreProvider.name}>.`);
18
18
  return useStore;
19
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RouteExecutionStore.js","names":[],"sources":["../../../../src/stores/routes/RouteExecutionStore.tsx"],"sourcesContent":["import { createContext, type JSX, useContext, useRef } from 'react'\nimport type { StoreApi, UseBoundStore } from 'zustand'\nimport { useShallow } from 'zustand/shallow'\nimport type { PersistStoreProviderProps } from '../types.js'\nimport { createRouteExecutionStore } from './createRouteExecutionStore.js'\nimport type { RouteExecutionState } from './types.js'\n\ntype RouteExecutionStore = UseBoundStore<StoreApi<RouteExecutionState>>\n\nconst RouteExecutionStoreContext = createContext<RouteExecutionStore | null>(\n null\n)\n\nexport function RouteExecutionStoreProvider({\n children,\n ...props\n}: PersistStoreProviderProps): JSX.Element {\n const storeRef = useRef<RouteExecutionStore>(null)\n if (!storeRef.current) {\n storeRef.current = createRouteExecutionStore(props)\n }\n return (\n <RouteExecutionStoreContext.Provider value={storeRef.current}>\n {children}\n </RouteExecutionStoreContext.Provider>\n )\n}\n\nexport function useRouteExecutionStoreContext(): any {\n const useStore = useContext(RouteExecutionStoreContext)\n if (!useStore) {\n throw new Error(\n `You forgot to wrap your component in <${RouteExecutionStoreProvider.name}>.`\n )\n }\n return useStore\n}\n\nexport function useRouteExecutionStore<T>(\n selector: (state: RouteExecutionState) => T\n): T {\n const useStore = useRouteExecutionStoreContext()\n return useStore(useShallow(selector))\n}\n"],"mappings":";;;;;AASA,MAAM,6BAA6B,cACjC,IACF;AAEA,SAAgB,4BAA4B,EAC1C,UACA,GAAG,SACsC;CACzC,MAAM,WAAW,OAA4B,IAAI;CACjD,IAAI,CAAC,SAAS,SACZ,SAAS,UAAU,0BAA0B,KAAK;CAEpD,OACE,oBAAC,2BAA2B,UAA5B;EAAqC,OAAO,SAAS;EAClD;CACkC,CAAA;AAEzC;AAEA,SAAgB,gCAAqC;CACnD,MAAM,WAAW,WAAW,0BAA0B;CACtD,IAAI,CAAC,UACH,MAAM,IAAI,MACR,yCAAyC,4BAA4B,KAAK,GAC5E;CAEF,OAAO;AACT;AAEA,SAAgB,uBACd,UACG;CAEH,OADiB,8BACH,EAAE,WAAW,QAAQ,CAAC;AACtC"}
1
+ {"version":3,"file":"RouteExecutionStore.js","names":[],"sources":["../../../../src/stores/routes/RouteExecutionStore.tsx"],"sourcesContent":["import { createContext, type JSX, use, useRef } from 'react'\nimport type { StoreApi, UseBoundStore } from 'zustand'\nimport { useShallow } from 'zustand/shallow'\nimport type { PersistStoreProviderProps } from '../types.js'\nimport { createRouteExecutionStore } from './createRouteExecutionStore.js'\nimport type { RouteExecutionState } from './types.js'\n\ntype RouteExecutionStore = UseBoundStore<StoreApi<RouteExecutionState>>\n\nconst RouteExecutionStoreContext = createContext<RouteExecutionStore | null>(\n null\n)\n\nexport function RouteExecutionStoreProvider({\n children,\n ...props\n}: PersistStoreProviderProps): JSX.Element {\n const storeRef = useRef<RouteExecutionStore>(null)\n if (!storeRef.current) {\n storeRef.current = createRouteExecutionStore(props)\n }\n return (\n <RouteExecutionStoreContext value={storeRef.current}>\n {children}\n </RouteExecutionStoreContext>\n )\n}\n\nexport function useRouteExecutionStoreContext(): any {\n const useStore = use(RouteExecutionStoreContext)\n if (!useStore) {\n throw new Error(\n `You forgot to wrap your component in <${RouteExecutionStoreProvider.name}>.`\n )\n }\n return useStore\n}\n\nexport function useRouteExecutionStore<T>(\n selector: (state: RouteExecutionState) => T\n): T {\n const useStore = useRouteExecutionStoreContext()\n return useStore(useShallow(selector))\n}\n"],"mappings":";;;;;AASA,MAAM,6BAA6B,cACjC,IACF;AAEA,SAAgB,4BAA4B,EAC1C,UACA,GAAG,SACsC;CACzC,MAAM,WAAW,OAA4B,IAAI;CACjD,IAAI,CAAC,SAAS,SACZ,SAAS,UAAU,0BAA0B,KAAK;CAEpD,OACE,oBAAC,4BAAD;EAA4B,OAAO,SAAS;EACzC;CACyB,CAAA;AAEhC;AAEA,SAAgB,gCAAqC;CACnD,MAAM,WAAW,IAAI,0BAA0B;CAC/C,IAAI,CAAC,UACH,MAAM,IAAI,MACR,yCAAyC,4BAA4B,KAAK,GAC5E;CAEF,OAAO;AACT;AAEA,SAAgB,uBACd,UACG;CAEH,OADiB,8BACH,CAAC,CAAC,WAAW,QAAQ,CAAC;AACtC"}
@@ -1 +1 @@
1
- {"version":3,"file":"createRouteExecutionStore.js","names":[],"sources":["../../../../src/stores/routes/createRouteExecutionStore.ts"],"sourcesContent":["import type { Route, RouteExtended } from '@lifi/sdk'\nimport type { StoreApi, UseBoundStore } from 'zustand'\nimport { create } from 'zustand'\nimport { persist } from 'zustand/middleware'\nimport { hasEnumFlag } from '../../utils/enum.js'\nimport type { PersistStoreProps } from '../types.js'\nimport type { RouteExecution, RouteExecutionState } from './types.js'\nimport { RouteExecutionStatus } from './types.js'\nimport {\n isRouteDone,\n isRouteFailed,\n isRoutePartiallyDone,\n isRouteRefunded,\n} from './utils.js'\n\nexport const createRouteExecutionStore = ({\n namePrefix,\n}: PersistStoreProps): UseBoundStore<StoreApi<RouteExecutionState>> =>\n create<RouteExecutionState>()(\n persist(\n (set, get) => ({\n routes: {},\n setExecutableRoute: (route: Route, observableRouteIds?: string[]) => {\n if (!get().routes[route.id]) {\n set((state: RouteExecutionState) => {\n const routes = { ...state.routes }\n // clean previous idle routes\n Object.keys(routes)\n .filter(\n (routeId) =>\n !observableRouteIds?.includes(routeId) &&\n hasEnumFlag(\n routes[routeId]!.status,\n RouteExecutionStatus.Idle\n )\n )\n .forEach((routeId) => {\n delete routes[routeId]\n })\n routes[route.id] = {\n route,\n status: RouteExecutionStatus.Idle,\n }\n return {\n routes,\n }\n })\n }\n },\n updateRoute: (route: RouteExtended) => {\n if (get().routes[route.id]) {\n set((state: RouteExecutionState) => {\n const updatedState = {\n routes: {\n ...state.routes,\n [route.id]: { ...state.routes[route.id]!, route },\n },\n }\n const isFailed = isRouteFailed(route)\n if (isFailed) {\n updatedState.routes[route.id]!.status =\n RouteExecutionStatus.Failed\n return updatedState\n }\n const isDone = isRouteDone(route)\n if (isDone) {\n updatedState.routes[route.id]!.status =\n RouteExecutionStatus.Done\n if (isRoutePartiallyDone(route)) {\n updatedState.routes[route.id]!.status |=\n RouteExecutionStatus.Partial\n } else if (isRouteRefunded(route)) {\n updatedState.routes[route.id]!.status |=\n RouteExecutionStatus.Refunded\n }\n return updatedState\n }\n const isLoading = route.steps.some((step) => step.execution)\n if (isLoading) {\n updatedState.routes[route.id]!.status =\n RouteExecutionStatus.Pending\n }\n return updatedState\n })\n }\n },\n deleteRoutes: (type, accountAddresses) =>\n set((state: RouteExecutionState) => {\n const routes = { ...state.routes }\n Object.keys(routes)\n .filter((routeId) => {\n const route = routes[routeId]\n if (\n accountAddresses &&\n !accountAddresses.includes(route?.route.fromAddress ?? '')\n ) {\n return false\n }\n return type === 'completed'\n ? hasEnumFlag(route?.status ?? 0, RouteExecutionStatus.Done)\n : type === 'failed'\n ? hasEnumFlag(\n route?.status ?? 0,\n RouteExecutionStatus.Failed\n )\n : !hasEnumFlag(\n route?.status ?? 0,\n RouteExecutionStatus.Done\n )\n })\n .forEach((routeId) => {\n delete routes[routeId]\n })\n return {\n routes,\n }\n }),\n deleteRoute: (routeId: string) => {\n if (get().routes[routeId]) {\n set((state: RouteExecutionState) => {\n const routes = { ...state.routes }\n delete routes[routeId]\n return {\n routes,\n }\n })\n }\n },\n }),\n {\n name: `${namePrefix || 'li.fi'}-widget-routes`,\n // Bump version on breaking changes to the stored structure.\n version: 4,\n // Clear stored routes on any version mismatch to avoid errors from incompatible data shapes.\n migrate: () => ({ routes: {} }),\n partialize: (state) => ({ routes: state.routes }),\n merge: (persistedState: any, currentState: RouteExecutionState) => {\n const state = {\n ...currentState,\n ...persistedState,\n } as RouteExecutionState\n try {\n // Keep only the most recent 100 routes, evicting the oldest when the\n // limit is exceeded.\n const maxStoredRoutes = 100\n const allRoutes = Object.values(state.routes) as RouteExecution[]\n const storedRoutes = allRoutes\n .sort(\n (a, b) =>\n (b.route.steps[0]?.execution?.startedAt ?? 0) -\n (a.route.steps[0]?.execution?.startedAt ?? 0)\n )\n .slice(0, maxStoredRoutes)\n const keepIds = new Set(storedRoutes.map((r) => r.route.id))\n for (const id of Object.keys(state.routes)) {\n if (!keepIds.has(id)) {\n delete state.routes[id]\n }\n }\n } catch (error) {\n console.error(error)\n }\n return state\n },\n }\n )\n )\n"],"mappings":"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"}
1
+ {"version":3,"file":"createRouteExecutionStore.js","names":[],"sources":["../../../../src/stores/routes/createRouteExecutionStore.ts"],"sourcesContent":["import type { Route, RouteExtended } from '@lifi/sdk'\nimport type { StoreApi, UseBoundStore } from 'zustand'\nimport { create } from 'zustand'\nimport { persist } from 'zustand/middleware'\nimport { hasEnumFlag } from '../../utils/enum.js'\nimport type { PersistStoreProps } from '../types.js'\nimport type { RouteExecution, RouteExecutionState } from './types.js'\nimport { RouteExecutionStatus } from './types.js'\nimport {\n isRouteDone,\n isRouteFailed,\n isRoutePartiallyDone,\n isRouteRefunded,\n} from './utils.js'\n\nexport const createRouteExecutionStore = ({\n namePrefix,\n}: PersistStoreProps): UseBoundStore<StoreApi<RouteExecutionState>> =>\n create<RouteExecutionState>()(\n persist(\n (set, get) => ({\n routes: {},\n setExecutableRoute: (route: Route, observableRouteIds?: string[]) => {\n if (!get().routes[route.id]) {\n set((state: RouteExecutionState) => {\n const routes = { ...state.routes }\n // clean previous idle routes\n Object.keys(routes)\n .filter(\n (routeId) =>\n !observableRouteIds?.includes(routeId) &&\n hasEnumFlag(\n routes[routeId]!.status,\n RouteExecutionStatus.Idle\n )\n )\n .forEach((routeId) => {\n delete routes[routeId]\n })\n routes[route.id] = {\n route,\n status: RouteExecutionStatus.Idle,\n }\n return {\n routes,\n }\n })\n }\n },\n updateRoute: (route: RouteExtended) => {\n if (get().routes[route.id]) {\n set((state: RouteExecutionState) => {\n const updatedState = {\n routes: {\n ...state.routes,\n [route.id]: { ...state.routes[route.id]!, route },\n },\n }\n const isFailed = isRouteFailed(route)\n if (isFailed) {\n updatedState.routes[route.id]!.status =\n RouteExecutionStatus.Failed\n return updatedState\n }\n const isDone = isRouteDone(route)\n if (isDone) {\n updatedState.routes[route.id]!.status =\n RouteExecutionStatus.Done\n if (isRoutePartiallyDone(route)) {\n updatedState.routes[route.id]!.status |=\n RouteExecutionStatus.Partial\n } else if (isRouteRefunded(route)) {\n updatedState.routes[route.id]!.status |=\n RouteExecutionStatus.Refunded\n }\n return updatedState\n }\n const isLoading = route.steps.some((step) => step.execution)\n if (isLoading) {\n updatedState.routes[route.id]!.status =\n RouteExecutionStatus.Pending\n }\n return updatedState\n })\n }\n },\n deleteRoutes: (type, accountAddresses) =>\n set((state: RouteExecutionState) => {\n const routes = { ...state.routes }\n Object.keys(routes)\n .filter((routeId) => {\n const route = routes[routeId]\n if (\n accountAddresses &&\n !accountAddresses.includes(route?.route.fromAddress ?? '')\n ) {\n return false\n }\n return type === 'completed'\n ? hasEnumFlag(route?.status ?? 0, RouteExecutionStatus.Done)\n : type === 'failed'\n ? hasEnumFlag(\n route?.status ?? 0,\n RouteExecutionStatus.Failed\n )\n : !hasEnumFlag(\n route?.status ?? 0,\n RouteExecutionStatus.Done\n )\n })\n .forEach((routeId) => {\n delete routes[routeId]\n })\n return {\n routes,\n }\n }),\n deleteRoute: (routeId: string) => {\n if (get().routes[routeId]) {\n set((state: RouteExecutionState) => {\n const routes = { ...state.routes }\n delete routes[routeId]\n return {\n routes,\n }\n })\n }\n },\n }),\n {\n name: `${namePrefix || 'li.fi'}-widget-routes`,\n // Bump version on breaking changes to the stored structure.\n version: 4,\n // Clear stored routes on any version mismatch to avoid errors from incompatible data shapes.\n migrate: () => ({ routes: {} }),\n partialize: (state) => ({ routes: state.routes }),\n merge: (persistedState: any, currentState: RouteExecutionState) => {\n const state = {\n ...currentState,\n ...persistedState,\n } as RouteExecutionState\n try {\n // Keep only the most recent 100 routes, evicting the oldest when the\n // limit is exceeded.\n const maxStoredRoutes = 100\n const allRoutes = Object.values(state.routes) as RouteExecution[]\n const storedRoutes = allRoutes\n .sort(\n (a, b) =>\n (b.route.steps[0]?.execution?.startedAt ?? 0) -\n (a.route.steps[0]?.execution?.startedAt ?? 0)\n )\n .slice(0, maxStoredRoutes)\n const keepIds = new Set(storedRoutes.map((r) => r.route.id))\n for (const id of Object.keys(state.routes)) {\n if (!keepIds.has(id)) {\n delete state.routes[id]\n }\n }\n } catch (error) {\n console.error(error)\n }\n return state\n },\n }\n )\n )\n"],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"useIntermediateRoutesStore.js","names":[],"sources":["../../../../src/stores/routes/useIntermediateRoutesStore.ts"],"sourcesContent":["import type { Route } from '@lifi/sdk'\nimport type { StoreApi, UseBoundStore } from 'zustand'\nimport { create } from 'zustand'\n\ninterface IntermediateRoutesState {\n intermediateRoutes: Record<string, Route[] | undefined>\n setIntermediateRoutes: (\n key: readonly unknown[],\n routes: Route[] | undefined\n ) => void\n getIntermediateRoutes: (key: readonly unknown[]) => Route[] | undefined\n}\n\nexport const useIntermediateRoutesStore: UseBoundStore<\n StoreApi<IntermediateRoutesState>\n> = create<IntermediateRoutesState>((set, get) => ({\n intermediateRoutes: {},\n setIntermediateRoutes: (key, routes) => {\n const stringKey = JSON.stringify(key)\n // Create a new state with only the current key\n const newRoutesByKey: Record<string, Route[] | undefined> = {}\n newRoutesByKey[stringKey] = routes\n set({ intermediateRoutes: newRoutesByKey })\n },\n getIntermediateRoutes: (key) => {\n const stringKey = JSON.stringify(key)\n return get().intermediateRoutes[stringKey]\n },\n}))\n"],"mappings":";;AAaA,MAAa,6BAET,QAAiC,KAAK,SAAS;CACjD,oBAAoB,CAAC;CACrB,wBAAwB,KAAK,WAAW;EACtC,MAAM,YAAY,KAAK,UAAU,GAAG;EAEpC,MAAM,iBAAsD,CAAC;EAC7D,eAAe,aAAa;EAC5B,IAAI,EAAE,oBAAoB,eAAe,CAAC;CAC5C;CACA,wBAAwB,QAAQ;EAC9B,MAAM,YAAY,KAAK,UAAU,GAAG;EACpC,OAAO,IAAI,EAAE,mBAAmB;CAClC;AACF,EAAE"}
1
+ {"version":3,"file":"useIntermediateRoutesStore.js","names":[],"sources":["../../../../src/stores/routes/useIntermediateRoutesStore.ts"],"sourcesContent":["import type { Route } from '@lifi/sdk'\nimport type { StoreApi, UseBoundStore } from 'zustand'\nimport { create } from 'zustand'\n\ninterface IntermediateRoutesState {\n intermediateRoutes: Record<string, Route[] | undefined>\n setIntermediateRoutes: (\n key: readonly unknown[],\n routes: Route[] | undefined\n ) => void\n getIntermediateRoutes: (key: readonly unknown[]) => Route[] | undefined\n}\n\nexport const useIntermediateRoutesStore: UseBoundStore<\n StoreApi<IntermediateRoutesState>\n> = create<IntermediateRoutesState>((set, get) => ({\n intermediateRoutes: {},\n setIntermediateRoutes: (key, routes) => {\n const stringKey = JSON.stringify(key)\n // Create a new state with only the current key\n const newRoutesByKey: Record<string, Route[] | undefined> = {}\n newRoutesByKey[stringKey] = routes\n set({ intermediateRoutes: newRoutesByKey })\n },\n getIntermediateRoutes: (key) => {\n const stringKey = JSON.stringify(key)\n return get().intermediateRoutes[stringKey]\n },\n}))\n"],"mappings":";;AAaA,MAAa,6BAET,QAAiC,KAAK,SAAS;CACjD,oBAAoB,CAAC;CACrB,wBAAwB,KAAK,WAAW;EACtC,MAAM,YAAY,KAAK,UAAU,GAAG;EAEpC,MAAM,iBAAsD,CAAC;EAC7D,eAAe,aAAa;EAC5B,IAAI,EAAE,oBAAoB,eAAe,CAAC;CAC5C;CACA,wBAAwB,QAAQ;EAC9B,MAAM,YAAY,KAAK,UAAU,GAAG;EACpC,OAAO,IAAI,CAAC,CAAC,mBAAmB;CAClC;AACF,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"useRouteExecutionIndicator.js","names":[],"sources":["../../../../src/stores/routes/useRouteExecutionIndicator.ts"],"sourcesContent":["import { useAccount } from '@lifi/wallet-management'\nimport { useCallback, useMemo } from 'react'\nimport { useRouteExecutionStore } from './RouteExecutionStore.js'\nimport type { RouteExecution, RouteExecutionState } from './types.js'\nimport { RouteExecutionStatus } from './types.js'\n\nexport type RouteExecutionIndicator = {\n failed: boolean\n active: boolean\n}\n\nconst isRecentTransaction = (route: RouteExecution): boolean => {\n const startedAt = route.route.steps[0]?.execution?.startedAt ?? 0\n return startedAt > 0 && Date.now() - startedAt < 1000 * 60 * 60 * 24 // 1 day\n}\n\nexport const useRouteExecutionIndicator = (): RouteExecutionIndicator => {\n const { accounts } = useAccount()\n const accountAddresses = useMemo(\n () => accounts.map((account) => account.address),\n [accounts]\n )\n const selector = useCallback(\n (state: RouteExecutionState): RouteExecutionIndicator => {\n const routes = Object.values(state.routes) as RouteExecution[]\n const recentOwnedRoutes = routes.filter(\n (route) =>\n accountAddresses.includes(route.route.fromAddress) &&\n isRecentTransaction(route)\n )\n return {\n failed: recentOwnedRoutes.some(\n (r) => r.status === RouteExecutionStatus.Failed\n ),\n active: recentOwnedRoutes.some(\n (r) => r.status === RouteExecutionStatus.Pending\n ),\n }\n },\n [accountAddresses]\n )\n return useRouteExecutionStore(selector)\n}\n"],"mappings":";;;;AAWA,MAAM,uBAAuB,UAAmC;CAC9D,MAAM,YAAY,MAAM,MAAM,MAAM,IAAI,WAAW,aAAa;CAChE,OAAO,YAAY,KAAK,KAAK,IAAI,IAAI,YAAY,MAAO,KAAK,KAAK;AACpE;AAEA,MAAa,mCAA4D;CACvE,MAAM,EAAE,aAAa,WAAW;CAChC,MAAM,mBAAmB,cACjB,SAAS,KAAK,YAAY,QAAQ,OAAO,GAC/C,CAAC,QAAQ,CACX;CAoBA,OAAO,uBAnBU,aACd,UAAwD;EAEvD,MAAM,oBADS,OAAO,OAAO,MAAM,MACJ,EAAE,QAC9B,UACC,iBAAiB,SAAS,MAAM,MAAM,WAAW,KACjD,oBAAoB,KAAK,CAC7B;EACA,OAAO;GACL,QAAQ,kBAAkB,MACvB,MAAM,EAAE,WAAA,CACX;GACA,QAAQ,kBAAkB,MACvB,MAAM,EAAE,WAAA,CACX;EACF;CACF,GACA,CAAC,gBAAgB,CAEkB,CAAC;AACxC"}
1
+ {"version":3,"file":"useRouteExecutionIndicator.js","names":[],"sources":["../../../../src/stores/routes/useRouteExecutionIndicator.ts"],"sourcesContent":["import { useAccount } from '@lifi/wallet-management'\nimport { useCallback, useMemo } from 'react'\nimport { useRouteExecutionStore } from './RouteExecutionStore.js'\nimport type { RouteExecution, RouteExecutionState } from './types.js'\nimport { RouteExecutionStatus } from './types.js'\n\nexport type RouteExecutionIndicator = {\n failed: boolean\n active: boolean\n}\n\nconst isRecentTransaction = (route: RouteExecution): boolean => {\n const startedAt = route.route.steps[0]?.execution?.startedAt ?? 0\n return startedAt > 0 && Date.now() - startedAt < 1000 * 60 * 60 * 24 // 1 day\n}\n\nexport const useRouteExecutionIndicator = (): RouteExecutionIndicator => {\n const { accounts } = useAccount()\n const accountAddresses = useMemo(\n () => accounts.map((account) => account.address),\n [accounts]\n )\n const selector = useCallback(\n (state: RouteExecutionState): RouteExecutionIndicator => {\n const routes = Object.values(state.routes) as RouteExecution[]\n const recentOwnedRoutes = routes.filter(\n (route) =>\n accountAddresses.includes(route.route.fromAddress) &&\n isRecentTransaction(route)\n )\n return {\n failed: recentOwnedRoutes.some(\n (r) => r.status === RouteExecutionStatus.Failed\n ),\n active: recentOwnedRoutes.some(\n (r) => r.status === RouteExecutionStatus.Pending\n ),\n }\n },\n [accountAddresses]\n )\n return useRouteExecutionStore(selector)\n}\n"],"mappings":";;;;AAWA,MAAM,uBAAuB,UAAmC;CAC9D,MAAM,YAAY,MAAM,MAAM,MAAM,EAAE,EAAE,WAAW,aAAa;CAChE,OAAO,YAAY,KAAK,KAAK,IAAI,IAAI,YAAY,MAAO,KAAK,KAAK;AACpE;AAEA,MAAa,mCAA4D;CACvE,MAAM,EAAE,aAAa,WAAW;CAChC,MAAM,mBAAmB,cACjB,SAAS,KAAK,YAAY,QAAQ,OAAO,GAC/C,CAAC,QAAQ,CACX;CAoBA,OAAO,uBAnBU,aACd,UAAwD;EAEvD,MAAM,oBADS,OAAO,OAAO,MAAM,MACJ,CAAC,CAAC,QAC9B,UACC,iBAAiB,SAAS,MAAM,MAAM,WAAW,KACjD,oBAAoB,KAAK,CAC7B;EACA,OAAO;GACL,QAAQ,kBAAkB,MACvB,MAAM,EAAE,WAAA,CACX;GACA,QAAQ,kBAAkB,MACvB,MAAM,EAAE,WAAA,CACX;EACF;CACF,GACA,CAAC,gBAAgB,CAEkB,CAAC;AACxC"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":[],"sources":["../../../../src/stores/routes/utils.ts"],"sourcesContent":["import type { ExecutionAction, RouteExtended } from '@lifi/sdk'\nimport microdiff from 'microdiff'\n\nexport const isRouteDone = (route: RouteExtended): boolean => {\n return route.steps.every((step) => step.execution?.status === 'DONE')\n}\n\nexport const isRoutePartiallyDone = (route: RouteExtended): boolean => {\n return route.steps.some((step) =>\n step.execution?.actions?.some((action) => action.substatus === 'PARTIAL')\n )\n}\n\nexport const isRouteRefunded = (route: RouteExtended): boolean => {\n return route.steps.some((step) =>\n step.execution?.actions?.some((action) => action.substatus === 'REFUNDED')\n )\n}\n\nexport const isRouteFailed = (route: RouteExtended): boolean => {\n return route.steps.some((step) => step.execution?.status === 'FAILED')\n}\n\nexport const isRouteActive = (route?: RouteExtended): boolean => {\n if (!route) {\n return false\n }\n const isDone = isRouteDone(route)\n const isFailed = isRouteFailed(route)\n const alreadyStarted = route.steps.some((step) => step.execution)\n return !isDone && !isFailed && alreadyStarted\n}\n\nexport const getUpdatedAction = (\n currentRoute: RouteExtended,\n updatedRoute: RouteExtended\n): ExecutionAction | undefined => {\n const actionDiff = microdiff(currentRoute, updatedRoute).find((diff) =>\n diff.path.includes('actions')\n )\n if (!actionDiff) {\n return undefined\n }\n // Find action index in the diff array so we can slice the complete action object\n // e.g. ['steps', 0, 'execution', 'actions', 0, 'message']\n const actionDiffIndex = actionDiff.path.indexOf('actions') + 2\n const actionPathSlice = actionDiff.path.slice(0, actionDiffIndex)\n // Reduce updated route using the diff path to get updated process\n const action = actionPathSlice.reduce(\n (obj, path) => obj[path],\n updatedRoute as any\n ) as ExecutionAction\n return action\n}\n\nexport const getSourceTxHash = (route?: RouteExtended): string | undefined => {\n const sourceAction = route?.steps[0].execution?.actions\n ?.filter(\n (action) => !['RESET_ALLOWANCE', 'SET_ALLOWANCE'].includes(action.type)\n )\n .find((action) => action.txHash || action.taskId)\n return sourceAction?.txHash || sourceAction?.taskId\n}\n"],"mappings":";;AAGA,MAAa,eAAe,UAAkC;CAC5D,OAAO,MAAM,MAAM,OAAO,SAAS,KAAK,WAAW,WAAW,MAAM;AACtE;AAEA,MAAa,wBAAwB,UAAkC;CACrE,OAAO,MAAM,MAAM,MAAM,SACvB,KAAK,WAAW,SAAS,MAAM,WAAW,OAAO,cAAc,SAAS,CAC1E;AACF;AAEA,MAAa,mBAAmB,UAAkC;CAChE,OAAO,MAAM,MAAM,MAAM,SACvB,KAAK,WAAW,SAAS,MAAM,WAAW,OAAO,cAAc,UAAU,CAC3E;AACF;AAEA,MAAa,iBAAiB,UAAkC;CAC9D,OAAO,MAAM,MAAM,MAAM,SAAS,KAAK,WAAW,WAAW,QAAQ;AACvE;AAEA,MAAa,iBAAiB,UAAmC;CAC/D,IAAI,CAAC,OACH,OAAO;CAET,MAAM,SAAS,YAAY,KAAK;CAChC,MAAM,WAAW,cAAc,KAAK;CACpC,MAAM,iBAAiB,MAAM,MAAM,MAAM,SAAS,KAAK,SAAS;CAChE,OAAO,CAAC,UAAU,CAAC,YAAY;AACjC;AAEA,MAAa,oBACX,cACA,iBACgC;CAChC,MAAM,aAAa,UAAU,cAAc,YAAY,EAAE,MAAM,SAC7D,KAAK,KAAK,SAAS,SAAS,CAC9B;CACA,IAAI,CAAC,YACH;CAIF,MAAM,kBAAkB,WAAW,KAAK,QAAQ,SAAS,IAAI;CAO7D,OANwB,WAAW,KAAK,MAAM,GAAG,eAEpB,EAAE,QAC5B,KAAK,SAAS,IAAI,OACnB,YAEU;AACd;AAEA,MAAa,mBAAmB,UAA8C;CAC5E,MAAM,eAAe,OAAO,MAAM,GAAG,WAAW,SAC5C,QACC,WAAW,CAAC,CAAC,mBAAmB,eAAe,EAAE,SAAS,OAAO,IAAI,CACxE,EACC,MAAM,WAAW,OAAO,UAAU,OAAO,MAAM;CAClD,OAAO,cAAc,UAAU,cAAc;AAC/C"}
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../../../src/stores/routes/utils.ts"],"sourcesContent":["import type { ExecutionAction, RouteExtended } from '@lifi/sdk'\nimport microdiff from 'microdiff'\n\nexport const isRouteDone = (route: RouteExtended): boolean => {\n return route.steps.every((step) => step.execution?.status === 'DONE')\n}\n\nexport const isRoutePartiallyDone = (route: RouteExtended): boolean => {\n return route.steps.some((step) =>\n step.execution?.actions?.some((action) => action.substatus === 'PARTIAL')\n )\n}\n\nexport const isRouteRefunded = (route: RouteExtended): boolean => {\n return route.steps.some((step) =>\n step.execution?.actions?.some((action) => action.substatus === 'REFUNDED')\n )\n}\n\nexport const isRouteFailed = (route: RouteExtended): boolean => {\n return route.steps.some((step) => step.execution?.status === 'FAILED')\n}\n\nexport const isRouteActive = (route?: RouteExtended): boolean => {\n if (!route) {\n return false\n }\n const isDone = isRouteDone(route)\n const isFailed = isRouteFailed(route)\n const alreadyStarted = route.steps.some((step) => step.execution)\n return !isDone && !isFailed && alreadyStarted\n}\n\nexport const getUpdatedAction = (\n currentRoute: RouteExtended,\n updatedRoute: RouteExtended\n): ExecutionAction | undefined => {\n const actionDiff = microdiff(currentRoute, updatedRoute).find((diff) =>\n diff.path.includes('actions')\n )\n if (!actionDiff) {\n return undefined\n }\n // Find action index in the diff array so we can slice the complete action object\n // e.g. ['steps', 0, 'execution', 'actions', 0, 'message']\n const actionDiffIndex = actionDiff.path.indexOf('actions') + 2\n const actionPathSlice = actionDiff.path.slice(0, actionDiffIndex)\n // Reduce updated route using the diff path to get updated process\n const action = actionPathSlice.reduce(\n (obj, path) => obj[path],\n updatedRoute as any\n ) as ExecutionAction\n return action\n}\n\nexport const getSourceTxHash = (route?: RouteExtended): string | undefined => {\n const sourceAction = route?.steps[0].execution?.actions\n ?.filter(\n (action) => !['RESET_ALLOWANCE', 'SET_ALLOWANCE'].includes(action.type)\n )\n .find((action) => action.txHash || action.taskId)\n return sourceAction?.txHash || sourceAction?.taskId\n}\n"],"mappings":";;AAGA,MAAa,eAAe,UAAkC;CAC5D,OAAO,MAAM,MAAM,OAAO,SAAS,KAAK,WAAW,WAAW,MAAM;AACtE;AAEA,MAAa,wBAAwB,UAAkC;CACrE,OAAO,MAAM,MAAM,MAAM,SACvB,KAAK,WAAW,SAAS,MAAM,WAAW,OAAO,cAAc,SAAS,CAC1E;AACF;AAEA,MAAa,mBAAmB,UAAkC;CAChE,OAAO,MAAM,MAAM,MAAM,SACvB,KAAK,WAAW,SAAS,MAAM,WAAW,OAAO,cAAc,UAAU,CAC3E;AACF;AAEA,MAAa,iBAAiB,UAAkC;CAC9D,OAAO,MAAM,MAAM,MAAM,SAAS,KAAK,WAAW,WAAW,QAAQ;AACvE;AAEA,MAAa,iBAAiB,UAAmC;CAC/D,IAAI,CAAC,OACH,OAAO;CAET,MAAM,SAAS,YAAY,KAAK;CAChC,MAAM,WAAW,cAAc,KAAK;CACpC,MAAM,iBAAiB,MAAM,MAAM,MAAM,SAAS,KAAK,SAAS;CAChE,OAAO,CAAC,UAAU,CAAC,YAAY;AACjC;AAEA,MAAa,oBACX,cACA,iBACgC;CAChC,MAAM,aAAa,UAAU,cAAc,YAAY,CAAC,CAAC,MAAM,SAC7D,KAAK,KAAK,SAAS,SAAS,CAC9B;CACA,IAAI,CAAC,YACH;CAIF,MAAM,kBAAkB,WAAW,KAAK,QAAQ,SAAS,IAAI;CAO7D,OANwB,WAAW,KAAK,MAAM,GAAG,eAEpB,CAAC,CAAC,QAC5B,KAAK,SAAS,IAAI,OACnB,YAEU;AACd;AAEA,MAAa,mBAAmB,UAA8C;CAC5E,MAAM,eAAe,OAAO,MAAM,EAAE,CAAC,WAAW,SAC5C,QACC,WAAW,CAAC,CAAC,mBAAmB,eAAe,CAAC,CAAC,SAAS,OAAO,IAAI,CACxE,CAAC,CACA,MAAM,WAAW,OAAO,UAAU,OAAO,MAAM;CAClD,OAAO,cAAc,UAAU,cAAc;AAC/C"}
@@ -1,5 +1,5 @@
1
1
  import { createSettingsStore } from "./createSettingsStore.js";
2
- import { createContext, useContext, useRef } from "react";
2
+ import { createContext, use, useRef } from "react";
3
3
  import { useShallow } from "zustand/shallow";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  //#region src/stores/settings/SettingsStore.tsx
@@ -7,13 +7,13 @@ const SettingsStoreContext = createContext(null);
7
7
  const SettingsStoreProvider = ({ children, config }) => {
8
8
  const storeRef = useRef(null);
9
9
  if (!storeRef.current) storeRef.current = createSettingsStore(config);
10
- return /* @__PURE__ */ jsx(SettingsStoreContext.Provider, {
10
+ return /* @__PURE__ */ jsx(SettingsStoreContext, {
11
11
  value: storeRef.current,
12
12
  children
13
13
  });
14
14
  };
15
15
  function useSettingsStoreContext() {
16
- const useStore = useContext(SettingsStoreContext);
16
+ const useStore = use(SettingsStoreContext);
17
17
  if (!useStore) throw new Error("You forgot to wrap your component in SettingsStoreContext.");
18
18
  return useStore;
19
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsStore.js","names":[],"sources":["../../../../src/stores/settings/SettingsStore.tsx"],"sourcesContent":["import {\n createContext,\n type JSX,\n type PropsWithChildren,\n useContext,\n useRef,\n} from 'react'\nimport type { StoreApi, UseBoundStore } from 'zustand'\nimport { useShallow } from 'zustand/shallow'\nimport { createSettingsStore } from './createSettingsStore.js'\nimport type { SettingsState, SettingsStoreProviderProps } from './types.js'\n\ntype SettingsStore = UseBoundStore<StoreApi<SettingsState>>\n\nconst SettingsStoreContext = createContext<SettingsStore | null>(null)\n\nexport const SettingsStoreProvider = ({\n children,\n config,\n}: PropsWithChildren<SettingsStoreProviderProps>): JSX.Element => {\n const storeRef = useRef<SettingsStore>(null)\n if (!storeRef.current) {\n storeRef.current = createSettingsStore(config)\n }\n return (\n <SettingsStoreContext.Provider value={storeRef.current}>\n {children}\n </SettingsStoreContext.Provider>\n )\n}\n\nexport function useSettingsStoreContext(): any {\n const useStore = useContext(SettingsStoreContext)\n if (!useStore) {\n throw new Error(\n 'You forgot to wrap your component in SettingsStoreContext.'\n )\n }\n return useStore\n}\n\nexport function useSettingsStore<T>(selector: (state: SettingsState) => T): T {\n const useStore = useSettingsStoreContext()\n return useStore(useShallow(selector))\n}\n"],"mappings":";;;;;AAcA,MAAM,uBAAuB,cAAoC,IAAI;AAErE,MAAa,yBAAyB,EACpC,UACA,aACgE;CAChE,MAAM,WAAW,OAAsB,IAAI;CAC3C,IAAI,CAAC,SAAS,SACZ,SAAS,UAAU,oBAAoB,MAAM;CAE/C,OACE,oBAAC,qBAAqB,UAAtB;EAA+B,OAAO,SAAS;EAC5C;CAC4B,CAAA;AAEnC;AAEA,SAAgB,0BAA+B;CAC7C,MAAM,WAAW,WAAW,oBAAoB;CAChD,IAAI,CAAC,UACH,MAAM,IAAI,MACR,4DACF;CAEF,OAAO;AACT;AAEA,SAAgB,iBAAoB,UAA0C;CAE5E,OADiB,wBACH,EAAE,WAAW,QAAQ,CAAC;AACtC"}
1
+ {"version":3,"file":"SettingsStore.js","names":[],"sources":["../../../../src/stores/settings/SettingsStore.tsx"],"sourcesContent":["import {\n createContext,\n type JSX,\n type PropsWithChildren,\n use,\n useRef,\n} from 'react'\nimport type { StoreApi, UseBoundStore } from 'zustand'\nimport { useShallow } from 'zustand/shallow'\nimport { createSettingsStore } from './createSettingsStore.js'\nimport type { SettingsState, SettingsStoreProviderProps } from './types.js'\n\ntype SettingsStore = UseBoundStore<StoreApi<SettingsState>>\n\nconst SettingsStoreContext = createContext<SettingsStore | null>(null)\n\nexport const SettingsStoreProvider = ({\n children,\n config,\n}: PropsWithChildren<SettingsStoreProviderProps>): JSX.Element => {\n const storeRef = useRef<SettingsStore>(null)\n if (!storeRef.current) {\n storeRef.current = createSettingsStore(config)\n }\n return (\n <SettingsStoreContext value={storeRef.current}>\n {children}\n </SettingsStoreContext>\n )\n}\n\nexport function useSettingsStoreContext(): any {\n const useStore = use(SettingsStoreContext)\n if (!useStore) {\n throw new Error(\n 'You forgot to wrap your component in SettingsStoreContext.'\n )\n }\n return useStore\n}\n\nexport function useSettingsStore<T>(selector: (state: SettingsState) => T): T {\n const useStore = useSettingsStoreContext()\n return useStore(useShallow(selector))\n}\n"],"mappings":";;;;;AAcA,MAAM,uBAAuB,cAAoC,IAAI;AAErE,MAAa,yBAAyB,EACpC,UACA,aACgE;CAChE,MAAM,WAAW,OAAsB,IAAI;CAC3C,IAAI,CAAC,SAAS,SACZ,SAAS,UAAU,oBAAoB,MAAM;CAE/C,OACE,oBAAC,sBAAD;EAAsB,OAAO,SAAS;EACnC;CACmB,CAAA;AAE1B;AAEA,SAAgB,0BAA+B;CAC7C,MAAM,WAAW,IAAI,oBAAoB;CACzC,IAAI,CAAC,UACH,MAAM,IAAI,MACR,4DACF;CAEF,OAAO;AACT;AAEA,SAAgB,iBAAoB,UAA0C;CAE5E,OADiB,wBACH,CAAC,CAAC,WAAW,QAAQ,CAAC;AACtC"}
@@ -1,5 +1,6 @@
1
1
  import { allLanguages } from "../../providers/I18nProvider/constants.js";
2
2
  import { loadLocale } from "../../providers/I18nProvider/i18n.js";
3
+ import { getConfigItemSets, isItemAllowedForSets } from "../../utils/item.js";
3
4
  import { SettingsToolTypes } from "./types.js";
4
5
  import { getStateValues } from "./utils/getStateValues.js";
5
6
  import { create } from "zustand";
@@ -20,106 +21,131 @@ const defaultSettings = {
20
21
  _enabledExchanges: {},
21
22
  smallBalanceThreshold: void 0
22
23
  };
23
- const createSettingsStore = (config) => create()(persist((set, get) => ({
24
- ...defaultSettings,
25
- setValue: (key, value) => set(() => ({ [key]: value })),
26
- setValues: (values) => set(() => ({ ...values })),
27
- getSettings: () => getStateValues(get()),
28
- getValue: (key) => get()[key],
29
- initializeTools: (toolType, tools, reset) => {
30
- if (!tools.length) return;
31
- set((state) => {
32
- const updatedState = { ...state };
33
- if (!reset) {
34
- tools.forEach((tool) => {
35
- if (!Object.hasOwn(updatedState[`_enabled${toolType}`], tool)) updatedState[`_enabled${toolType}`][tool] = true;
36
- });
37
- updatedState[`_enabled${toolType}`] = Object.fromEntries(Object.entries(updatedState[`_enabled${toolType}`]).filter(([key]) => tools.includes(key)));
38
- } else tools.forEach((tool) => {
39
- updatedState[`_enabled${toolType}`][tool] = true;
40
- });
41
- const enabledToolKeys = Object.keys(updatedState[`_enabled${toolType}`]);
42
- updatedState[`enabled${toolType}`] = enabledToolKeys.filter((key) => updatedState[`_enabled${toolType}`][key]);
43
- updatedState[`disabled${toolType}`] = enabledToolKeys.filter((key) => !updatedState[`_enabled${toolType}`][key]);
44
- return updatedState;
45
- });
46
- },
47
- setToolValue: (toolType, tool, value) => set((state) => {
48
- const enabledTools = {
49
- ...state[`_enabled${toolType}`],
50
- [tool]: value
51
- };
52
- const enabledToolKeys = Object.keys(enabledTools);
24
+ const createSettingsStore = (config) => {
25
+ const configItemsByToolType = {
26
+ Bridges: config.bridges,
27
+ Exchanges: config.exchanges
28
+ };
29
+ const buildToolState = (toolType, enabledMap) => {
30
+ const configItemSets = getConfigItemSets(configItemsByToolType[toolType], (items) => new Set(items));
31
+ const allowed = Object.fromEntries(Object.entries(enabledMap).filter(([key]) => isItemAllowedForSets(key, configItemSets)));
32
+ const keys = Object.keys(allowed);
53
33
  return {
54
- [`_enabled${toolType}`]: enabledTools,
55
- [`enabled${toolType}`]: enabledToolKeys.filter((key) => enabledTools[key]),
56
- [`disabled${toolType}`]: enabledToolKeys.filter((key) => !enabledTools[key])
57
- };
58
- }),
59
- toggleToolKeys: (toolType, toolKeys) => set((state) => {
60
- const allKeysInCollectionEnabled = toolKeys.every((toolKey) => state[`_enabled${toolType}`][toolKey]);
61
- const updatedTools = toolKeys.reduce((accum, toolKey) => {
62
- accum[toolKey] = !allKeysInCollectionEnabled;
63
- return accum;
64
- }, { ...state[`_enabled${toolType}`] });
65
- const enableKeys = [];
66
- const disabledKeys = [];
67
- Object.entries(updatedTools).forEach(([key, value]) => {
68
- if (value) enableKeys.push(key);
69
- else disabledKeys.push(key);
70
- });
71
- return {
72
- [`_enabled${toolType}`]: updatedTools,
73
- [`enabled${toolType}`]: enableKeys,
74
- [`disabled${toolType}`]: disabledKeys
75
- };
76
- }),
77
- reset: (bridges, exchanges) => {
78
- set(() => ({
79
- ...defaultSettings,
80
- ...defaultConfigurableSettings
81
- }));
82
- get().initializeTools("Bridges", bridges, true);
83
- get().initializeTools("Exchanges", exchanges, true);
84
- return { ...get() };
85
- }
86
- }), {
87
- name: "li.fi-widget-settings",
88
- version: 6,
89
- partialize: (state) => {
90
- const { disabledBridges, disabledExchanges, enabledBridges, enabledExchanges, ...partializedState } = state;
91
- return partializedState;
92
- },
93
- merge: (persistedState, currentState) => {
94
- const state = {
95
- ...currentState,
96
- ...persistedState
34
+ [`_enabled${toolType}`]: allowed,
35
+ [`enabled${toolType}`]: keys.filter((key) => allowed[key]),
36
+ [`disabled${toolType}`]: keys.filter((key) => !allowed[key])
97
37
  };
98
- SettingsToolTypes.forEach((toolType) => {
99
- if (persistedState?.[`_enabled${toolType}`]) {
100
- const enabledToolKeys = Object.keys(persistedState[`_enabled${toolType}`]);
101
- state[`enabled${toolType}`] = enabledToolKeys.filter((key) => persistedState[`_enabled${toolType}`][key]);
102
- state[`disabled${toolType}`] = enabledToolKeys.filter((key) => !persistedState[`_enabled${toolType}`][key]);
103
- }
104
- });
105
- return state;
106
- },
107
- migrate: () => ({}),
108
- onRehydrateStorage: () => {
109
- const initializeLanguageSettings = async (state, initialLanguage) => {
110
- const customLanguages = Object.keys(config?.languageResources || {}).filter((key) => !allLanguages.includes(key));
111
- if (initialLanguage && initialLanguage !== "en" && !customLanguages.includes(initialLanguage)) await loadLocale(initialLanguage, config?.languageResources?.[initialLanguage]).then((languageResource) => {
112
- state.setValues({
113
- language: initialLanguage,
114
- languageCache: languageResource
38
+ };
39
+ const toEnabledMap = (keys = []) => Object.fromEntries(keys.map((key) => [key, true]));
40
+ const initialSettings = {
41
+ ...defaultSettings,
42
+ ...buildToolState("Bridges", toEnabledMap(config.bridges?.allow)),
43
+ ...buildToolState("Exchanges", toEnabledMap(config.exchanges?.allow))
44
+ };
45
+ return create()(persist((set, get) => ({
46
+ ...initialSettings,
47
+ setValue: (key, value) => set(() => ({ [key]: value })),
48
+ setValues: (values) => set(() => ({ ...values })),
49
+ getSettings: () => getStateValues(get()),
50
+ getValue: (key) => get()[key],
51
+ initializeTools: (toolType, tools, reset) => {
52
+ if (!tools.length) return;
53
+ set((state) => {
54
+ const updatedState = { ...state };
55
+ if (!reset) {
56
+ tools.forEach((tool) => {
57
+ if (!Object.hasOwn(updatedState[`_enabled${toolType}`], tool)) updatedState[`_enabled${toolType}`][tool] = true;
58
+ });
59
+ updatedState[`_enabled${toolType}`] = Object.fromEntries(Object.entries(updatedState[`_enabled${toolType}`]).filter(([key]) => tools.includes(key)));
60
+ } else tools.forEach((tool) => {
61
+ updatedState[`_enabled${toolType}`][tool] = true;
115
62
  });
63
+ const enabledToolKeys = Object.keys(updatedState[`_enabled${toolType}`]);
64
+ updatedState[`enabled${toolType}`] = enabledToolKeys.filter((key) => updatedState[`_enabled${toolType}`][key]);
65
+ updatedState[`disabled${toolType}`] = enabledToolKeys.filter((key) => !updatedState[`_enabled${toolType}`][key]);
66
+ return updatedState;
116
67
  });
117
- };
118
- return (state) => {
119
- if (state) initializeLanguageSettings(state, state.getValue("language") || config?.languages?.default);
120
- };
121
- }
122
- }));
68
+ },
69
+ setToolValue: (toolType, tool, value) => set((state) => {
70
+ const enabledTools = {
71
+ ...state[`_enabled${toolType}`],
72
+ [tool]: value
73
+ };
74
+ const enabledToolKeys = Object.keys(enabledTools);
75
+ return {
76
+ [`_enabled${toolType}`]: enabledTools,
77
+ [`enabled${toolType}`]: enabledToolKeys.filter((key) => enabledTools[key]),
78
+ [`disabled${toolType}`]: enabledToolKeys.filter((key) => !enabledTools[key])
79
+ };
80
+ }),
81
+ toggleToolKeys: (toolType, toolKeys) => set((state) => {
82
+ const allKeysInCollectionEnabled = toolKeys.every((toolKey) => state[`_enabled${toolType}`][toolKey]);
83
+ const updatedTools = toolKeys.reduce((accum, toolKey) => {
84
+ accum[toolKey] = !allKeysInCollectionEnabled;
85
+ return accum;
86
+ }, { ...state[`_enabled${toolType}`] });
87
+ const enableKeys = [];
88
+ const disabledKeys = [];
89
+ Object.entries(updatedTools).forEach(([key, value]) => {
90
+ if (value) enableKeys.push(key);
91
+ else disabledKeys.push(key);
92
+ });
93
+ return {
94
+ [`_enabled${toolType}`]: updatedTools,
95
+ [`enabled${toolType}`]: enableKeys,
96
+ [`disabled${toolType}`]: disabledKeys
97
+ };
98
+ }),
99
+ reset: (bridges, exchanges) => {
100
+ set(() => ({
101
+ ...defaultSettings,
102
+ ...defaultConfigurableSettings
103
+ }));
104
+ get().initializeTools("Bridges", bridges, true);
105
+ get().initializeTools("Exchanges", exchanges, true);
106
+ return { ...get() };
107
+ }
108
+ }), {
109
+ name: "li.fi-widget-settings",
110
+ version: 6,
111
+ partialize: (state) => {
112
+ const { disabledBridges, disabledExchanges, enabledBridges, enabledExchanges, ...partializedState } = state;
113
+ return partializedState;
114
+ },
115
+ merge: (persistedState, currentState) => {
116
+ const state = {
117
+ ...currentState,
118
+ ...persistedState
119
+ };
120
+ SettingsToolTypes.forEach((toolType) => {
121
+ const persistedEnabled = persistedState?.[`_enabled${toolType}`];
122
+ if (persistedEnabled) {
123
+ const allowMap = toEnabledMap(configItemsByToolType[toolType]?.allow);
124
+ Object.assign(state, buildToolState(toolType, {
125
+ ...allowMap,
126
+ ...persistedEnabled
127
+ }));
128
+ }
129
+ });
130
+ return state;
131
+ },
132
+ migrate: () => ({}),
133
+ onRehydrateStorage: () => {
134
+ const initializeLanguageSettings = async (state, initialLanguage) => {
135
+ const customLanguages = Object.keys(config?.languageResources || {}).filter((key) => !allLanguages.includes(key));
136
+ if (initialLanguage && initialLanguage !== "en" && !customLanguages.includes(initialLanguage)) await loadLocale(initialLanguage, config?.languageResources?.[initialLanguage]).then((languageResource) => {
137
+ state.setValues({
138
+ language: initialLanguage,
139
+ languageCache: languageResource
140
+ });
141
+ });
142
+ };
143
+ return (state) => {
144
+ if (state) initializeLanguageSettings(state, state.getValue("language") || config?.languages?.default);
145
+ };
146
+ }
147
+ }));
148
+ };
123
149
  //#endregion
124
150
  export { createSettingsStore, defaultConfigurableSettings };
125
151