@embarkai/ui-kit 0.4.36 → 0.4.37

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.
package/dist/index.js CHANGED
@@ -15691,38 +15691,33 @@ var init_MainMenu2 = __esm({
15691
15691
  // src/modules/linkedProfiles.ts
15692
15692
  import { useQuery as useQuery11, useQueryClient as useQueryClient11 } from "@tanstack/react-query";
15693
15693
  import { useCallback as useCallback16 } from "react";
15694
- async function getLinkProfilesData() {
15695
- const list = await getLinkedProviders();
15696
- const loadedProfiles = list.map((p) => {
15697
- const info = getProviderDisplayInfo(p.provider);
15698
- return { ...p, displayName: info.name, icon: info.icon };
15699
- });
15700
- let avatar = null;
15701
- try {
15702
- avatar = jwtTokenManager2.getAvatar() || null;
15703
- } catch {
15704
- avatar = null;
15705
- }
15706
- return { profiles: loadedProfiles, avatar };
15707
- }
15708
15694
  function useLinkedProfiles() {
15709
15695
  const qc = useQueryClient11();
15710
15696
  const address = useSession((st) => st.address);
15711
- const {
15712
- data,
15713
- isFetching: isLoading,
15714
- error
15715
- } = useQuery11({
15697
+ const { data, isFetching, isLoading, error } = useQuery11({
15716
15698
  retry: false,
15717
15699
  enabled: !!address,
15718
15700
  queryKey: [LINKED_PROFILES_QUERY_KEY, address],
15719
- queryFn: getLinkProfilesData
15701
+ queryFn: async () => {
15702
+ const list = await getLinkedProviders();
15703
+ const loadedProfiles = list.map((p) => {
15704
+ const info = getProviderDisplayInfo(p.provider);
15705
+ return { ...p, displayName: info.name, icon: info.icon };
15706
+ });
15707
+ let avatar2 = null;
15708
+ try {
15709
+ avatar2 = jwtTokenManager2.getAvatar() || null;
15710
+ } catch {
15711
+ avatar2 = null;
15712
+ }
15713
+ return { profiles: loadedProfiles, avatar: avatar2 };
15714
+ }
15720
15715
  });
15721
15716
  const { profiles = [], avatar = null } = data || {};
15722
15717
  const refresh = useCallback16(async () => {
15723
15718
  await qc.invalidateQueries({ queryKey: [LINKED_PROFILES_QUERY_KEY, address] });
15724
15719
  }, [qc, address]);
15725
- return { profiles, avatar, isLoading, error, refresh };
15720
+ return { profiles, avatar, isLoading, isFetching, error, refresh };
15726
15721
  }
15727
15722
  var LINKED_PROFILES_QUERY_KEY;
15728
15723
  var init_linkedProfiles = __esm({
@@ -16732,15 +16727,49 @@ var init_ManageWallet = __esm({
16732
16727
  }
16733
16728
  });
16734
16729
 
16730
+ // src/internal/stores/useExternalWalletStore.ts
16731
+ import { create as create8 } from "zustand";
16732
+ var useExternalWalletStore;
16733
+ var init_useExternalWalletStore = __esm({
16734
+ "src/internal/stores/useExternalWalletStore.ts"() {
16735
+ useExternalWalletStore = create8((set) => ({
16736
+ configMode: "linked",
16737
+ activeMode: "linked",
16738
+ externalAddress: null,
16739
+ externalChainId: null,
16740
+ isExternalConnected: false,
16741
+ connectorName: null,
16742
+ setConfigMode: (mode) => set({ configMode: mode }),
16743
+ setActiveMode: (mode) => set({ activeMode: mode }),
16744
+ setExternalWallet: ({ address, chainId, connectorName }) => set({
16745
+ externalAddress: address,
16746
+ externalChainId: chainId,
16747
+ isExternalConnected: true,
16748
+ connectorName
16749
+ }),
16750
+ clearExternalWallet: () => set({
16751
+ externalAddress: null,
16752
+ externalChainId: null,
16753
+ isExternalConnected: false,
16754
+ connectorName: null
16755
+ }),
16756
+ setExternalChainId: (chainId) => set({ externalChainId: chainId })
16757
+ }));
16758
+ }
16759
+ });
16760
+
16735
16761
  // src/internal/components/ManageWalletMenu/UnlinkProviderMenu.tsx
16736
16762
  import { useMutation as useMutation15, useQueryClient as useQueryClient16 } from "@tanstack/react-query";
16737
16763
  import { Key as Key6, Loader as Loader16 } from "lucide-react";
16738
16764
  import { useState as useState17 } from "react";
16765
+ import { useDisconnect } from "wagmi";
16739
16766
  import { jsx as jsx74, jsxs as jsxs68 } from "react/jsx-runtime";
16740
16767
  function UnlinkProviderMenu() {
16741
16768
  const qc = useQueryClient16();
16742
16769
  const address = useSession((st) => st.address);
16743
16770
  const { callbacksRef } = useProviderConfig();
16771
+ const { disconnect: disconnectExternalWallet } = useDisconnect();
16772
+ const isExternalConnected = useExternalWalletStore((st) => st.isExternalConnected);
16744
16773
  const { t } = useT();
16745
16774
  const setPage = useLayoutDataStore((st) => st.setPage);
16746
16775
  const { confirmUnlink, setConfirmUnlink, setAlert } = useManageWalletStore();
@@ -16751,6 +16780,13 @@ function UnlinkProviderMenu() {
16751
16780
  throw new Error("No provider to unlink");
16752
16781
  }
16753
16782
  const { provider, externalId } = confirmUnlink;
16783
+ if (provider === "wallet" && isExternalConnected) {
16784
+ await new Promise((resolve) => {
16785
+ disconnectExternalWallet();
16786
+ useExternalWalletStore.getState().clearExternalWallet();
16787
+ setTimeout(() => resolve(null), 1e3);
16788
+ });
16789
+ }
16754
16790
  await unlinkProvider(provider, externalId);
16755
16791
  },
16756
16792
  onSuccess: async () => {
@@ -16827,6 +16863,7 @@ var init_UnlinkProviderMenu = __esm({
16827
16863
  init_useT();
16828
16864
  init_linkedProfiles();
16829
16865
  init_auth();
16866
+ init_useExternalWalletStore();
16830
16867
  init_button();
16831
16868
  init_input();
16832
16869
  init_useProvidersList();
@@ -18972,37 +19009,6 @@ var init_wallet = __esm({
18972
19009
  }
18973
19010
  });
18974
19011
 
18975
- // src/internal/stores/useExternalWalletStore.ts
18976
- import { create as create8 } from "zustand";
18977
- var useExternalWalletStore;
18978
- var init_useExternalWalletStore = __esm({
18979
- "src/internal/stores/useExternalWalletStore.ts"() {
18980
- useExternalWalletStore = create8((set) => ({
18981
- configMode: "linked",
18982
- activeMode: "linked",
18983
- externalAddress: null,
18984
- externalChainId: null,
18985
- isExternalConnected: false,
18986
- connectorName: null,
18987
- setConfigMode: (mode) => set({ configMode: mode }),
18988
- setActiveMode: (mode) => set({ activeMode: mode }),
18989
- setExternalWallet: ({ address, chainId, connectorName }) => set({
18990
- externalAddress: address,
18991
- externalChainId: chainId,
18992
- isExternalConnected: true,
18993
- connectorName
18994
- }),
18995
- clearExternalWallet: () => set({
18996
- externalAddress: null,
18997
- externalChainId: null,
18998
- isExternalConnected: false,
18999
- connectorName: null
19000
- }),
19001
- setExternalChainId: (chainId) => set({ externalChainId: chainId })
19002
- }));
19003
- }
19004
- });
19005
-
19006
19012
  // src/internal/components/SendMenu/useFlowSelector.ts
19007
19013
  import { create as create9 } from "zustand";
19008
19014
  import { persist as persist2 } from "zustand/middleware";
@@ -19154,7 +19160,7 @@ import { useEffect as useEffect33, useRef as useRef17, useState as useState24 }
19154
19160
  import { useSignMessage } from "wagmi";
19155
19161
  import { jsx as jsx89, jsxs as jsxs83 } from "react/jsx-runtime";
19156
19162
  function SenderSelector(props) {
19157
- const { profiles } = props;
19163
+ const { directWalletProfile } = props;
19158
19164
  const { t } = useT();
19159
19165
  const config = useProviderConfig().config;
19160
19166
  const { signMessageAsync } = useSignMessage();
@@ -19169,22 +19175,15 @@ function SenderSelector(props) {
19169
19175
  useEffect33(() => {
19170
19176
  useFlowSelectorStore.getState().setRenderKey(`sender-selected-${Date.now()}`);
19171
19177
  }, [walletMessage]);
19172
- useEffect33(() => {
19173
- const pending = pendingWalletRef.current;
19174
- if (!pending || !directWalletIsConnected || !directWalletAddress) return;
19175
- if (directWalletAddress.toLowerCase() !== pending.externalId?.toLowerCase()) return;
19176
- pendingWalletRef.current = null;
19177
- directWalletFlow(pending);
19178
- }, [directWalletIsConnected, directWalletAddress]);
19179
- const { mutate: directWalletFlow, isPending: isDirectWalletLogin } = useMutation18({
19180
- mutationFn: async (walletProfile2) => {
19181
- if (!walletProfile2?.meta?.walletName || !walletProfile2?.externalId || !walletProfile2?.meta?.walletType) {
19182
- console.error("[SENDER SELECTOR] Invalid wallet profile:", walletProfile2);
19178
+ const { mutate: loginDirectWallet, isPending: isDirectWalletLoggingIn } = useMutation18({
19179
+ mutationFn: async (walletProfile) => {
19180
+ if (!walletProfile?.meta?.walletName || !walletProfile?.externalId || !walletProfile?.meta?.walletType) {
19181
+ console.error("[SENDER SELECTOR] Invalid wallet profile:", walletProfile);
19183
19182
  setWalletMessage("Invalid wallet profile. Please try connecting your wallet again.");
19184
19183
  return;
19185
19184
  }
19186
19185
  const projectName = config.current?.projectId ? await fetchProjectName(config.current.projectId) : "EmbarkAI";
19187
- const signingWalletAddress = walletProfile2?.externalId;
19186
+ const signingWalletAddress = walletProfile?.externalId;
19188
19187
  const message = createLoginMessage(signingWalletAddress, projectName);
19189
19188
  const signature = await Promise.race([
19190
19189
  signMessageAsync({ message, account: signingWalletAddress }),
@@ -19208,19 +19207,17 @@ function SenderSelector(props) {
19208
19207
  address: signingWalletAddress,
19209
19208
  signature,
19210
19209
  message,
19211
- walletName: walletProfile2.meta.walletName,
19212
- walletType: walletProfile2.meta.walletType
19210
+ walletName: walletProfile.meta.walletName,
19211
+ walletType: walletProfile.meta.walletType
19213
19212
  };
19214
- console.log("[SENDER SELECTOR] Wallet login data prepared:", walletData);
19215
19213
  const loginData = await walletLogin(walletData);
19216
- return { fromChainId, loginData, walletProfile: walletProfile2 };
19214
+ return { fromChainId, loginData, walletProfile };
19217
19215
  },
19218
- onSuccess: ({ fromChainId, loginData, walletProfile: walletProfile2 }) => {
19219
- console.log("[SENDER SELECTOR] Wallet login successful:", loginData);
19216
+ onSuccess: ({ fromChainId, loginData, walletProfile }) => {
19220
19217
  useExternalWalletStore.getState().setExternalWallet({
19221
- address: walletProfile2?.externalId,
19218
+ address: walletProfile?.externalId,
19222
19219
  chainId: fromChainId,
19223
- connectorName: walletProfile2?.meta?.walletName || "Unknown Wallet"
19220
+ connectorName: walletProfile?.meta?.walletName || "Unknown Wallet"
19224
19221
  });
19225
19222
  setWalletMessage(null);
19226
19223
  useBridgeStore.getState().setBridgeSender("direct-wallet");
@@ -19231,7 +19228,13 @@ function SenderSelector(props) {
19231
19228
  setWalletMessage(error instanceof Error ? error.message : "Wallet login failed. Please try again.");
19232
19229
  }
19233
19230
  });
19234
- const walletProfile = profiles.filter((p) => p.provider === "wallet")[0] || null;
19231
+ useEffect33(() => {
19232
+ const pendingProfile = pendingWalletRef.current;
19233
+ if (!pendingProfile || !directWalletIsConnected || !directWalletAddress) return;
19234
+ if (directWalletAddress.toLowerCase() !== pendingProfile.externalId?.toLowerCase()) return;
19235
+ pendingWalletRef.current = null;
19236
+ loginDirectWallet(pendingProfile);
19237
+ }, [directWalletIsConnected, directWalletAddress]);
19235
19238
  return /* @__PURE__ */ jsxs83("div", { className: "w-full flex flex-col gap-[var(--ui-kit-gap)]", children: [
19236
19239
  bridgeSenders.map((sender) => /* @__PURE__ */ jsxs83(
19237
19240
  Button,
@@ -19283,14 +19286,14 @@ function SenderSelector(props) {
19283
19286
  variant: "default",
19284
19287
  size: "large",
19285
19288
  className: "w-full",
19286
- disabled: !walletProfile || isDirectWalletLogin,
19289
+ disabled: !directWalletProfile || isDirectWalletLoggingIn,
19287
19290
  onClick: () => {
19288
- const isConnectedToRightWallet = directWalletIsConnected && directWalletAddress?.toLowerCase() === walletProfile?.externalId?.toLowerCase();
19291
+ const isConnectedToRightWallet = directWalletIsConnected && directWalletAddress?.toLowerCase() === directWalletProfile?.externalId?.toLowerCase();
19289
19292
  if (isConnectedToRightWallet) {
19290
- directWalletFlow(walletProfile);
19293
+ loginDirectWallet(directWalletProfile);
19291
19294
  } else {
19292
19295
  useLayoutDataStore.getState().setPage(null);
19293
- pendingWalletRef.current = walletProfile;
19296
+ pendingWalletRef.current = directWalletProfile;
19294
19297
  openConnectModal?.();
19295
19298
  }
19296
19299
  },
@@ -19415,7 +19418,6 @@ function useAvailableSenders() {
19415
19418
  const address = useSession((st) => st.address);
19416
19419
  const activeChainId = useSession((st) => st.activeChainId);
19417
19420
  const { profiles } = useLinkedProfiles();
19418
- const walletProfiles = profiles.filter((p) => p.provider === "wallet");
19419
19421
  const lastCalcedSenders = useRef18([]);
19420
19422
  useEffect34(() => {
19421
19423
  const sendersAccumulator = [
@@ -19427,15 +19429,14 @@ function useAvailableSenders() {
19427
19429
  Icon: TOKENS_ICONS["EMBARKAI"]
19428
19430
  }
19429
19431
  ];
19430
- if (!!walletProfiles.length) {
19431
- walletProfiles.forEach((wProfile) => {
19432
- sendersAccumulator.push({
19433
- type: "direct-wallet",
19434
- name: wProfile?.meta?.walletName || "External wallet",
19435
- chainId: null,
19436
- address: wProfile?.externalId,
19437
- Icon: WALLET_ICONS[wProfile?.meta?.walletName?.toLowerCase()] || WALLET_ICONS["default"]
19438
- });
19432
+ const walletProfile = profiles.filter((p) => p.provider === "wallet")[0] || null;
19433
+ if (!!walletProfile) {
19434
+ sendersAccumulator.push({
19435
+ type: "direct-wallet",
19436
+ name: walletProfile?.meta?.walletName || "External wallet",
19437
+ chainId: null,
19438
+ address: walletProfile?.externalId,
19439
+ Icon: WALLET_ICONS[walletProfile?.meta?.walletName?.toLowerCase()] || WALLET_ICONS["default"]
19439
19440
  });
19440
19441
  }
19441
19442
  if (sendersAccumulator.map((s) => `${s.name}-${s.address}`).join(",") === lastCalcedSenders.current.join(",")) {
@@ -19444,8 +19445,10 @@ function useAvailableSenders() {
19444
19445
  lastCalcedSenders.current = sendersAccumulator.map((s) => `${s.name}-${s.address}`);
19445
19446
  useBridgeStore.getState().setBridgeSenders(sendersAccumulator);
19446
19447
  useFlowSelectorStore.getState().setRenderKey(`sender-selected-${Date.now()}`);
19447
- }, [address, walletProfiles, activeChainId]);
19448
- return { profiles: walletProfiles };
19448
+ }, [address, profiles, activeChainId]);
19449
+ return {
19450
+ directWalletProfile: profiles.filter((p) => p.provider === "wallet")[0] || null
19451
+ };
19449
19452
  }
19450
19453
  var init_useAvailableSenders = __esm({
19451
19454
  "src/internal/components/SendMenu/hyperbridge/hooks/useAvailableSenders.ts"() {
@@ -20108,14 +20111,13 @@ function SelectStep(props) {
20108
20111
  destinationChain,
20109
20112
  hyperRoute,
20110
20113
  amount,
20111
- // bridgeSenders,
20112
20114
  isQuoteEstimating,
20113
20115
  recipient,
20114
20116
  setBridgeStep,
20115
20117
  setAmount,
20116
20118
  setRecipient
20117
20119
  } = useBridgeStore();
20118
- const selectedSender = useBridgeStore((st) => st.bridgeSenders.find((s) => s.type === st.bridgeSender));
20120
+ const selectedSender = useBridgeStore((st) => st.bridgeSenders?.find((s) => s.type === st.bridgeSender)) || null;
20119
20121
  const { routeTokenBalance, isRouteTokenBalanceLoading } = useBridgeBalance(hyperlaneWarpRoutes);
20120
20122
  const selectedWarpRoute = hyperlaneWarpRoutes.find((route) => {
20121
20123
  const { routeId, chainPair } = route;
@@ -20610,7 +20612,8 @@ var init_SuccessStep = __esm({
20610
20612
 
20611
20613
  // src/internal/components/SendMenu/hyperbridge/hooks/useHyperlaneHistory.ts
20612
20614
  import { useQuery as useQuery21 } from "@tanstack/react-query";
20613
- import { useEffect as useEffect38, useState as useState26 } from "react";
20615
+ import { debounce as debounce3 } from "lodash-es";
20616
+ import { useCallback as useCallback24, useEffect as useEffect38, useState as useState26 } from "react";
20614
20617
  function useHyperlaneHistory() {
20615
20618
  const address = useSession((st) => st.address);
20616
20619
  const page = useLayoutDataStore((st) => st.page);
@@ -20624,11 +20627,17 @@ function useHyperlaneHistory() {
20624
20627
  queryKey: [HYPERLANE_HISTORY_QUERY_KEY, address, currentPage],
20625
20628
  queryFn: async () => await getHyperlaneBridgeHistory({ page: currentPage, pageSize: TX_HISTORY_PAGE_SIZE })
20626
20629
  });
20630
+ const updateExpandable = useCallback24(
20631
+ debounce3(() => {
20632
+ useFlowSelectorStore.getState().setRenderKey(`hyperlane-history-loaded-${Date.now()}`);
20633
+ }, 500),
20634
+ []
20635
+ );
20627
20636
  useEffect38(() => {
20628
20637
  const { data, isLoading } = query;
20629
- if (isLoading || data.data.length === 0 || currentPage > 1) return;
20630
- useFlowSelectorStore.getState().setRenderKey(`hyperlane-history-loaded-${Date.now()}`);
20631
- }, [query, currentPage]);
20638
+ if (isLoading || data.data?.length === 0) return;
20639
+ updateExpandable();
20640
+ }, [query]);
20632
20641
  return {
20633
20642
  ...query,
20634
20643
  currentPage,
@@ -21035,7 +21044,7 @@ function HyperlaneBridge() {
21035
21044
  const bridgeStep = useBridgeStore((st) => st.bridgeStep);
21036
21045
  const { swapDirection, handleQuoteEstimation, bridgeAsset, isAssetBridging } = useBridge();
21037
21046
  const { hyperlaneWarpRoutes, isLoadingWarpRoutes } = useHyperlaneRoutes();
21038
- const { profiles } = useAvailableSenders();
21047
+ const { directWalletProfile } = useAvailableSenders();
21039
21048
  useMenuTitle(hyperlaneWarpRoutes);
21040
21049
  useEffect39(
21041
21050
  () => () => {
@@ -21044,7 +21053,7 @@ function HyperlaneBridge() {
21044
21053
  []
21045
21054
  );
21046
21055
  return /* @__PURE__ */ jsxs90(Fragment38, { children: [
21047
- bridgeStep === "sender-selector" && /* @__PURE__ */ jsx99(SenderSelector, { profiles }),
21056
+ bridgeStep === "sender-selector" && /* @__PURE__ */ jsx99(SenderSelector, { directWalletProfile }),
21048
21057
  bridgeStep === "select" && /* @__PURE__ */ jsx99(
21049
21058
  SelectStep,
21050
21059
  {
@@ -21266,7 +21275,7 @@ var init_useNicknameResolve = __esm({
21266
21275
  });
21267
21276
 
21268
21277
  // src/hooks/useSendTransaction.ts
21269
- import { useCallback as useCallback24, useState as useState29 } from "react";
21278
+ import { useCallback as useCallback25, useState as useState29 } from "react";
21270
21279
  import { encodeFunctionData as encodeFunctionData2, isAddress, parseEther as parseEther2, parseUnits } from "viem";
21271
21280
  function useSendTransaction() {
21272
21281
  const session = useSession((st) => st.session);
@@ -21274,7 +21283,7 @@ function useSendTransaction() {
21274
21283
  const [isLoading, setIsLoading] = useState29(false);
21275
21284
  const [error, setError] = useState29(null);
21276
21285
  const [userOpHash, setUserOpHash] = useState29(null);
21277
- const sendTransaction = useCallback24(
21286
+ const sendTransaction = useCallback25(
21278
21287
  async (params) => {
21279
21288
  if (!session || !address) {
21280
21289
  setError("No active session");
@@ -21371,7 +21380,7 @@ function useSendTransaction() {
21371
21380
  },
21372
21381
  [session, address]
21373
21382
  );
21374
- const reset = useCallback24(() => {
21383
+ const reset = useCallback25(() => {
21375
21384
  setError(null);
21376
21385
  setUserOpHash(null);
21377
21386
  setIsLoading(false);
@@ -23636,7 +23645,7 @@ var init_TransactionsGroup = __esm({
23636
23645
  // src/internal/components/TransactionsMenu/TransactionsMenu.tsx
23637
23646
  import { useQuery as useQuery24, useQueryClient as useQueryClient23 } from "@tanstack/react-query";
23638
23647
  import { ArrowLeft as ArrowLeft22, Loader as Loader33, RefreshCw as RefreshCw3, XCircle } from "lucide-react";
23639
- import { useCallback as useCallback25, useState as useState31 } from "react";
23648
+ import { useCallback as useCallback26, useState as useState31 } from "react";
23640
23649
  import { jsx as jsx114, jsxs as jsxs103 } from "react/jsx-runtime";
23641
23650
  function TransactionsMenu() {
23642
23651
  const qc = useQueryClient23();
@@ -23658,7 +23667,7 @@ function TransactionsMenu() {
23658
23667
  queryKey: [TRANSACTIONS_HISTORY_QUERY_KEY, chainConfig.id, address],
23659
23668
  queryFn: () => getTransactionsListQuery({ address, chainConfig })
23660
23669
  });
23661
- const refreshTxHistory = useCallback25(
23670
+ const refreshTxHistory = useCallback26(
23662
23671
  () => qc.invalidateQueries({ queryKey: [TRANSACTIONS_HISTORY_QUERY_KEY, chainConfig.id, address] }),
23663
23672
  [qc, chainConfig.id, address]
23664
23673
  );
@@ -23897,7 +23906,7 @@ var init_PageMap = __esm({
23897
23906
  });
23898
23907
 
23899
23908
  // src/internal/hooks/usePageMapper.tsx
23900
- import { useCallback as useCallback26, useEffect as useEffect44 } from "react";
23909
+ import { useCallback as useCallback27, useEffect as useEffect44 } from "react";
23901
23910
  import { jsx as jsx115 } from "react/jsx-runtime";
23902
23911
  function usePageMapper() {
23903
23912
  const page = useLayoutDataStore((st) => st.page);
@@ -23909,7 +23918,7 @@ function usePageMapper() {
23909
23918
  setIsDialogOpen,
23910
23919
  setIsDialogClosing
23911
23920
  } = useLayoutStore();
23912
- const closeDialog = useCallback26(() => {
23921
+ const closeDialog = useCallback27(() => {
23913
23922
  setIsDialogClosing(true);
23914
23923
  setTimeout(() => {
23915
23924
  setDialogContent(null);
@@ -23920,7 +23929,7 @@ function usePageMapper() {
23920
23929
  setIsDialogOpen(false);
23921
23930
  }, CLEAR_DIALOG_TIMEOUT);
23922
23931
  }, [setDialogContent, setDialogDescription, setDialogTitle, setIsDialogForced, setIsDialogOpen, setIsDialogClosing]);
23923
- const openDialog = useCallback26(
23932
+ const openDialog = useCallback27(
23924
23933
  (pageItem) => {
23925
23934
  const PageContentComponent = pageItem.component;
23926
23935
  setDialogTitle(pageItem.title);
@@ -24006,7 +24015,7 @@ var init_package = __esm({
24006
24015
  "package.json"() {
24007
24016
  package_default = {
24008
24017
  name: "@embarkai/ui-kit",
24009
- version: "0.4.36",
24018
+ version: "0.4.37",
24010
24019
  description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
24011
24020
  type: "module",
24012
24021
  main: "./dist/index.cjs",
@@ -24224,7 +24233,7 @@ var init_Footer2 = __esm({
24224
24233
  // src/internal/components/Header/Header.tsx
24225
24234
  import { useQuery as useQuery26 } from "@tanstack/react-query";
24226
24235
  import { Copy as Copy5, Loader as Loader35 } from "lucide-react";
24227
- import { useCallback as useCallback27, useRef as useRef20, useState as useState32 } from "react";
24236
+ import { useCallback as useCallback28, useRef as useRef20, useState as useState32 } from "react";
24228
24237
  import { Fragment as Fragment44, jsx as jsx117, jsxs as jsxs105 } from "react/jsx-runtime";
24229
24238
  function formatAddress2(addr) {
24230
24239
  if (!addr) return "";
@@ -24240,7 +24249,7 @@ function Header() {
24240
24249
  const [copied, setCopied] = useState32(false);
24241
24250
  const clickCountRef = useRef20(0);
24242
24251
  const clickTimerRef = useRef20(null);
24243
- const handleAvatarClick = useCallback27(() => {
24252
+ const handleAvatarClick = useCallback28(() => {
24244
24253
  clickCountRef.current += 1;
24245
24254
  if (clickTimerRef.current) {
24246
24255
  clearTimeout(clickTimerRef.current);
@@ -24620,7 +24629,7 @@ var init_Dialog2 = __esm({
24620
24629
  });
24621
24630
 
24622
24631
  // src/internal/components/TssManager.tsx
24623
- import React8, { useCallback as useCallback28 } from "react";
24632
+ import React8, { useCallback as useCallback29 } from "react";
24624
24633
  var TssManagerWithRef;
24625
24634
  var init_TssManager = __esm({
24626
24635
  "src/internal/components/TssManager.tsx"() {
@@ -24635,7 +24644,7 @@ var init_TssManager = __esm({
24635
24644
  const setStatus = useSession((st) => st.setStatus);
24636
24645
  const setSession = useSession((st) => st.setSession);
24637
24646
  const setAddress = useSession((st) => st.setAddress);
24638
- const onSessionCreated = useCallback28(
24647
+ const onSessionCreated = useCallback29(
24639
24648
  (session, address) => {
24640
24649
  setSession(session);
24641
24650
  setAddress(address);
@@ -24676,15 +24685,15 @@ var init_TssManager = __esm({
24676
24685
  // src/internal/components/WalletConnectHandler.tsx
24677
24686
  import { useConnectModal as useConnectModal2 } from "@rainbow-me/rainbowkit";
24678
24687
  import { useMutation as useMutation21, useQueryClient as useQueryClient25 } from "@tanstack/react-query";
24679
- import React9, { useCallback as useCallback29, useEffect as useEffect47 } from "react";
24680
- import { useAccount, useDisconnect, useSignMessage as useSignMessage2 } from "wagmi";
24688
+ import React9, { useCallback as useCallback30, useEffect as useEffect47 } from "react";
24689
+ import { useAccount, useDisconnect as useDisconnect2, useSignMessage as useSignMessage2 } from "wagmi";
24681
24690
  function WalletConnectHandler() {
24682
24691
  const qc = useQueryClient25();
24683
24692
  const { callbacksRef } = useProviderConfig();
24684
24693
  const passportWalletAddress = useSession((st) => st.address);
24685
24694
  const { address: walletAddress, isConnected, chain, connector } = useAccount();
24686
24695
  const { openConnectModal, connectModalOpen } = useConnectModal2();
24687
- const { disconnect } = useDisconnect();
24696
+ const { disconnect } = useDisconnect2();
24688
24697
  const { signMessageAsync } = useSignMessage2();
24689
24698
  const isWalletLinking = useLayoutDataStore((st) => st.isWalletLinking);
24690
24699
  const setPage = useLayoutDataStore((st) => st.setPage);
@@ -24699,7 +24708,7 @@ function WalletConnectHandler() {
24699
24708
  const projectId = providerConfig?.projectId;
24700
24709
  const setExternalWallet = useExternalWalletStore((st) => st.setExternalWallet);
24701
24710
  const setPendingWalletLogin = useLayoutDataStore((st) => st.setPendingWalletLogin);
24702
- const onLinkingComplete = useCallback29(
24711
+ const onLinkingComplete = useCallback30(
24703
24712
  async (success) => {
24704
24713
  setIsWalletLinking(false);
24705
24714
  if (!success && !passportWalletAddress) {
@@ -27849,7 +27858,7 @@ import { initSdkErrorTracking } from "@embarkai/core/internal/error-tracking";
27849
27858
  import { merge as merge3 } from "lodash-es";
27850
27859
  import {
27851
27860
  createContext,
27852
- useCallback as useCallback30,
27861
+ useCallback as useCallback31,
27853
27862
  useContext,
27854
27863
  useEffect as useEffect49,
27855
27864
  useMemo as useMemo12,
@@ -27876,7 +27885,7 @@ function Provider(props) {
27876
27885
  const callbacksRef = useRef21(callbacks);
27877
27886
  useEffect49(() => notifyNoProjetctId(projectId), [projectId]);
27878
27887
  const config = useRef21(merge3({}, DEFAULT_PROVIDER_CONFIG, { projectId }, initialConfig));
27879
- const updateConfig = useCallback30((updates) => {
27888
+ const updateConfig = useCallback31((updates) => {
27880
27889
  const prev = config.current;
27881
27890
  const next = { ...prev };
27882
27891
  if (updates.projectId !== void 0) next.projectId = updates.projectId;
@@ -27910,7 +27919,7 @@ function Provider(props) {
27910
27919
  if (updates.translations) next.translations = { ...next.translations, ...updates.translations };
27911
27920
  config.current = next;
27912
27921
  }, []);
27913
- const updateCallbacks = useCallback30((updates) => {
27922
+ const updateCallbacks = useCallback31((updates) => {
27914
27923
  const prev = callbacksRef.current;
27915
27924
  const next = updates ? { ...prev, ...updates } : void 0;
27916
27925
  callbacksRef.current = next;
@@ -28325,13 +28334,13 @@ var useHydrated = () => useSession((st) => st.hasHydrated);
28325
28334
  // src/hooks/useOpenPage.ts
28326
28335
  init_SessionContext();
28327
28336
  init_useLayoutDataStore();
28328
- import { useCallback as useCallback31 } from "react";
28337
+ import { useCallback as useCallback32 } from "react";
28329
28338
  function useOpenPage() {
28330
28339
  const page = useLayoutDataStore((st) => st.page);
28331
28340
  const setPage = useLayoutDataStore((st) => st.setPage);
28332
28341
  const setPageParams = useLayoutDataStore((st) => st.setPageParams);
28333
28342
  const address = useSession((st) => st.address);
28334
- const open = useCallback31(
28343
+ const open = useCallback32(
28335
28344
  (passportPage, params) => {
28336
28345
  if (!address) return setPage("auth" /* AUTH */);
28337
28346
  if (!!address && passportPage === "auth" /* AUTH */) return setPage("manage-wallet" /* MANAGE_WALLET */);
@@ -28340,7 +28349,7 @@ function useOpenPage() {
28340
28349
  },
28341
28350
  [setPage, setPageParams, address]
28342
28351
  );
28343
- const close = useCallback31(() => setPage(null), [setPage]);
28352
+ const close = useCallback32(() => setPage(null), [setPage]);
28344
28353
  return { open, close, isOpen: page !== null };
28345
28354
  }
28346
28355
 
@@ -29206,12 +29215,12 @@ init_useErc3643Compliance();
29206
29215
 
29207
29216
  // src/hooks/useWalletMode.ts
29208
29217
  init_useExternalWalletStore();
29209
- import { useCallback as useCallback34 } from "react";
29218
+ import { useCallback as useCallback35 } from "react";
29210
29219
  function useWalletMode() {
29211
29220
  const configMode = useExternalWalletStore((st) => st.configMode);
29212
29221
  const activeMode = useExternalWalletStore((st) => st.activeMode);
29213
29222
  const setActiveMode = useExternalWalletStore((st) => st.setActiveMode);
29214
- const switchMode = useCallback34(
29223
+ const switchMode = useCallback35(
29215
29224
  (mode) => {
29216
29225
  if (configMode !== "both") return;
29217
29226
  setActiveMode(mode);
@@ -29229,25 +29238,25 @@ function useWalletMode() {
29229
29238
  // src/hooks/useDirectWallet.ts
29230
29239
  init_useExternalWalletStore();
29231
29240
  init_useLayoutDataStore();
29232
- import { useCallback as useCallback35 } from "react";
29241
+ import { useCallback as useCallback36 } from "react";
29233
29242
  import { useConnectModal as useConnectModal3 } from "@rainbow-me/rainbowkit";
29234
- import { useDisconnect as useDisconnect2 } from "wagmi";
29243
+ import { useDisconnect as useDisconnect3 } from "wagmi";
29235
29244
  function useDirectWallet() {
29236
29245
  const address = useExternalWalletStore((st) => st.externalAddress);
29237
29246
  const chainId = useExternalWalletStore((st) => st.externalChainId);
29238
29247
  const isConnected = useExternalWalletStore((st) => st.isExternalConnected);
29239
29248
  const connectorName = useExternalWalletStore((st) => st.connectorName);
29240
29249
  const clearExternalWallet = useExternalWalletStore((st) => st.clearExternalWallet);
29241
- const { disconnect: wagmiDisconnect } = useDisconnect2();
29250
+ const { disconnect: wagmiDisconnect } = useDisconnect3();
29242
29251
  const { openConnectModal } = useConnectModal3();
29243
29252
  const setIsWalletLinking = useLayoutDataStore((st) => st.setIsWalletLinking);
29244
- const connect = useCallback35(() => {
29253
+ const connect = useCallback36(() => {
29245
29254
  setIsWalletLinking(true);
29246
29255
  }, [setIsWalletLinking]);
29247
- const reconnect = useCallback35(() => {
29256
+ const reconnect = useCallback36(() => {
29248
29257
  if (openConnectModal) openConnectModal();
29249
29258
  }, [openConnectModal]);
29250
- const disconnect = useCallback35(() => {
29259
+ const disconnect = useCallback36(() => {
29251
29260
  wagmiDisconnect();
29252
29261
  clearExternalWallet();
29253
29262
  }, [wagmiDisconnect, clearExternalWallet]);
@@ -29264,7 +29273,7 @@ function useDirectWallet() {
29264
29273
 
29265
29274
  // src/hooks/useSendDirectTransaction.ts
29266
29275
  init_useExternalWalletStore();
29267
- import { useCallback as useCallback36, useState as useState38 } from "react";
29276
+ import { useCallback as useCallback37, useState as useState38 } from "react";
29268
29277
  import { isAddress as isAddress3, parseEther as parseEther3 } from "viem";
29269
29278
  import { useSendTransaction as useWagmiSendTransaction, useSwitchChain as useSwitchChain3 } from "wagmi";
29270
29279
  function useSendDirectTransaction() {
@@ -29275,7 +29284,7 @@ function useSendDirectTransaction() {
29275
29284
  const [isPending, setIsPending] = useState38(false);
29276
29285
  const [error, setError] = useState38(null);
29277
29286
  const [txHash, setTxHash] = useState38(null);
29278
- const sendTransaction = useCallback36(
29287
+ const sendTransaction = useCallback37(
29279
29288
  async (params) => {
29280
29289
  if (!isConnected) {
29281
29290
  setError("No external wallet connected");
@@ -29309,7 +29318,7 @@ function useSendDirectTransaction() {
29309
29318
  },
29310
29319
  [isConnected, externalChainId, sendTransactionAsync, switchChainAsync]
29311
29320
  );
29312
- const reset = useCallback36(() => {
29321
+ const reset = useCallback37(() => {
29313
29322
  setError(null);
29314
29323
  setTxHash(null);
29315
29324
  setIsPending(false);
@@ -29321,7 +29330,7 @@ function useSendDirectTransaction() {
29321
29330
  init_SessionContext();
29322
29331
  init_account2();
29323
29332
  init_linkedProfiles();
29324
- import { useCallback as useCallback37, useMemo as useMemo14, useState as useState39 } from "react";
29333
+ import { useCallback as useCallback38, useMemo as useMemo14, useState as useState39 } from "react";
29325
29334
  import { encodeFunctionData as encodeFunctionData3, isAddress as isAddress4, parseEther as parseEther4, parseUnits as parseUnits3 } from "viem";
29326
29335
  var ERC20_TRANSFER_ABI2 = [
29327
29336
  {
@@ -29344,7 +29353,7 @@ function useTransferToLinkedWallet() {
29344
29353
  () => (profiles || []).filter((p) => p.provider === "wallet" && p.externalId).map((p) => p.externalId),
29345
29354
  [profiles]
29346
29355
  );
29347
- const transfer = useCallback37(
29356
+ const transfer = useCallback38(
29348
29357
  async (params) => {
29349
29358
  if (!session) {
29350
29359
  setError("No active session");
@@ -29395,7 +29404,7 @@ function useTransferToLinkedWallet() {
29395
29404
  },
29396
29405
  [session, linkedWallets]
29397
29406
  );
29398
- const reset = useCallback37(() => {
29407
+ const reset = useCallback38(() => {
29399
29408
  setError(null);
29400
29409
  setUserOpHash(null);
29401
29410
  setIsPending(false);
@@ -29421,11 +29430,11 @@ function useNativeWalletSignature() {
29421
29430
  init_ProviderContext();
29422
29431
  init_SessionContext();
29423
29432
  import { logout as coreLogout, jwtTokenManager as jwtTokenManager3 } from "@embarkai/core/auth";
29424
- import { useCallback as useCallback38 } from "react";
29433
+ import { useCallback as useCallback39 } from "react";
29425
29434
  function useLogout() {
29426
29435
  const { setSession, setIsLoading, setAddress, setStatus, setError, address } = useSession();
29427
29436
  const { callbacksRef } = useProviderConfig();
29428
- const logout2 = useCallback38(async () => {
29437
+ const logout2 = useCallback39(async () => {
29429
29438
  const prevAddress = address;
29430
29439
  let userId = null;
29431
29440
  setIsLoading(true);