@solana/connector 0.1.3 → 0.1.4

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 (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +460 -1082
  3. package/dist/{chunk-TIW3EQPC.js → chunk-CLXM6UEE.js} +120 -103
  4. package/dist/chunk-CLXM6UEE.js.map +1 -0
  5. package/dist/{chunk-7CKCRY25.js → chunk-D6PZY5G6.js} +69 -77
  6. package/dist/chunk-D6PZY5G6.js.map +1 -0
  7. package/dist/chunk-LUZWUZ5N.js +2012 -0
  8. package/dist/chunk-LUZWUZ5N.js.map +1 -0
  9. package/dist/{chunk-HPENTIPE.mjs → chunk-N3Q2J2FG.mjs} +51 -55
  10. package/dist/chunk-N3Q2J2FG.mjs.map +1 -0
  11. package/dist/chunk-P5MWBDFG.mjs +298 -0
  12. package/dist/chunk-P5MWBDFG.mjs.map +1 -0
  13. package/dist/chunk-RIQH5W7D.js +311 -0
  14. package/dist/chunk-RIQH5W7D.js.map +1 -0
  15. package/dist/chunk-U64YZRJL.mjs +1984 -0
  16. package/dist/chunk-U64YZRJL.mjs.map +1 -0
  17. package/dist/{chunk-TKJSKXSA.mjs → chunk-YTCSTE3Q.mjs} +35 -19
  18. package/dist/chunk-YTCSTE3Q.mjs.map +1 -0
  19. package/dist/compat.d.mts +4 -2
  20. package/dist/compat.d.ts +4 -2
  21. package/dist/compat.js +3 -3
  22. package/dist/compat.mjs +1 -1
  23. package/dist/headless.d.mts +146 -18
  24. package/dist/headless.d.ts +146 -18
  25. package/dist/headless.js +144 -111
  26. package/dist/headless.mjs +3 -2
  27. package/dist/index.d.mts +6 -5
  28. package/dist/index.d.ts +6 -5
  29. package/dist/index.js +207 -126
  30. package/dist/index.mjs +4 -3
  31. package/dist/react.d.mts +707 -67
  32. package/dist/react.d.ts +707 -67
  33. package/dist/react.js +64 -16
  34. package/dist/react.mjs +2 -2
  35. package/dist/{transaction-signer-D3csM_Mf.d.mts → transaction-signer-D9d8nxwb.d.mts} +3 -1
  36. package/dist/{transaction-signer-D3csM_Mf.d.ts → transaction-signer-D9d8nxwb.d.ts} +3 -1
  37. package/dist/{wallet-standard-shim-C1tisl9S.d.ts → wallet-standard-shim-Cp4vF4oo.d.mts} +133 -6
  38. package/dist/{wallet-standard-shim-Cg0GVGwu.d.mts → wallet-standard-shim-DC_Z7DS-.d.ts} +133 -6
  39. package/package.json +16 -12
  40. package/dist/chunk-5ZUVZZWU.mjs +0 -180
  41. package/dist/chunk-5ZUVZZWU.mjs.map +0 -1
  42. package/dist/chunk-7CKCRY25.js.map +0 -1
  43. package/dist/chunk-FTD7F7CS.js +0 -314
  44. package/dist/chunk-FTD7F7CS.js.map +0 -1
  45. package/dist/chunk-HPENTIPE.mjs.map +0 -1
  46. package/dist/chunk-MPZFJEJK.mjs +0 -298
  47. package/dist/chunk-MPZFJEJK.mjs.map +0 -1
  48. package/dist/chunk-SMUUAKC3.js +0 -186
  49. package/dist/chunk-SMUUAKC3.js.map +0 -1
  50. package/dist/chunk-TIW3EQPC.js.map +0 -1
  51. package/dist/chunk-TKJSKXSA.mjs.map +0 -1
@@ -0,0 +1,1984 @@
1
+ import { installPolyfills, ConnectorErrorBoundary, isMainnetCluster, isDevnetCluster, isTestnetCluster, isLocalCluster, getClusterExplorerUrl, getClusterType, formatAddress, copyAddressToClipboard, createTransactionSigner, createKitTransactionSigner, NetworkError, getTransactionUrl, ConnectorClient } from './chunk-YTCSTE3Q.mjs';
2
+ import { createLogger, createSolanaClient, prepareTransaction } from './chunk-P5MWBDFG.mjs';
3
+ import React, { createContext, useContext, useSyncExternalStore, useMemo, useState, useCallback, useEffect, useRef } from 'react';
4
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
5
+ import { address } from '@solana/addresses';
6
+ import { signature } from '@solana/keys';
7
+
8
+ var logger = createLogger("ConnectorProvider");
9
+ installPolyfills();
10
+ var ConnectorContext = createContext(null);
11
+ ConnectorContext.displayName = "ConnectorContext";
12
+ function ConnectorProviderInternal({
13
+ children,
14
+ config,
15
+ mobile
16
+ }) {
17
+ let clientRef = useRef(null), client = React.useCallback(() => {
18
+ if (!clientRef.current)
19
+ try {
20
+ clientRef.current = new ConnectorClient(config), typeof window < "u" && (window.__connectorClient = clientRef.current), config?.debug && logger.info("Client initialized successfully");
21
+ } catch (error) {
22
+ let err = error;
23
+ logger.error("Failed to initialize client", { error: err });
24
+ let extendedConfig = config;
25
+ return extendedConfig?.errorBoundary?.onError && extendedConfig.errorBoundary.onError(err, {
26
+ componentStack: "client-initialization",
27
+ digest: `constructor-${(/* @__PURE__ */ new Date()).toISOString()}`
28
+ }), null;
29
+ }
30
+ return clientRef.current;
31
+ }, [config])();
32
+ return React.useEffect(() => {
33
+ let currentClient = clientRef.current;
34
+ if (currentClient) {
35
+ let privateClient = currentClient;
36
+ privateClient.initialize && typeof privateClient.initialize == "function" && privateClient.initialize();
37
+ }
38
+ return () => {
39
+ typeof window < "u" && (window.__connectorClient = void 0), currentClient && typeof currentClient.destroy == "function" && currentClient.destroy();
40
+ };
41
+ }, []), React.useEffect(() => {
42
+ if (!mobile) return;
43
+ let cancelled = false;
44
+ return (async () => {
45
+ try {
46
+ let mod = await import('@solana-mobile/wallet-standard-mobile');
47
+ if (cancelled) return;
48
+ let {
49
+ registerMwa,
50
+ createDefaultAuthorizationCache,
51
+ createDefaultChainSelector,
52
+ createDefaultWalletNotFoundHandler
53
+ } = mod, defaultChains = [
54
+ "solana:mainnet",
55
+ "solana:devnet",
56
+ "solana:testnet"
57
+ ];
58
+ registerMwa({
59
+ appIdentity: mobile.appIdentity,
60
+ authorizationCache: mobile.authorizationCache ?? createDefaultAuthorizationCache(),
61
+ chains: mobile.chains ?? defaultChains,
62
+ chainSelector: mobile.chainSelector ?? createDefaultChainSelector(),
63
+ remoteHostAuthority: mobile.remoteHostAuthority,
64
+ onWalletNotFound: mobile.onWalletNotFound ?? createDefaultWalletNotFoundHandler()
65
+ });
66
+ } catch {
67
+ }
68
+ })(), () => {
69
+ cancelled = true;
70
+ };
71
+ }, [mobile]), /* @__PURE__ */ jsx(ConnectorContext.Provider, { value: client, children });
72
+ }
73
+ function ConnectorProvider({
74
+ children,
75
+ config,
76
+ mobile
77
+ }) {
78
+ let errorBoundaryConfig = config?.errorBoundary;
79
+ return errorBoundaryConfig?.enabled ? /* @__PURE__ */ jsx(
80
+ ConnectorErrorBoundary,
81
+ {
82
+ maxRetries: errorBoundaryConfig.maxRetries ?? 3,
83
+ onError: errorBoundaryConfig.onError,
84
+ fallback: errorBoundaryConfig.fallback,
85
+ children: /* @__PURE__ */ jsx(ConnectorProviderInternal, { config, mobile, children })
86
+ }
87
+ ) : /* @__PURE__ */ jsx(ConnectorProviderInternal, { config, mobile, children });
88
+ }
89
+ function useConnector() {
90
+ let client = useContext(ConnectorContext);
91
+ if (!client)
92
+ throw new Error(
93
+ "useConnector must be used within ConnectorProvider. Wrap your app with <ConnectorProvider> or <UnifiedProvider> to use connector hooks."
94
+ );
95
+ let state = useSyncExternalStore(
96
+ React.useCallback((cb) => client.subscribe(cb), [client]),
97
+ React.useCallback(() => client.getSnapshot(), [client]),
98
+ React.useCallback(() => client.getSnapshot(), [client])
99
+ ), methods = useMemo(
100
+ () => ({
101
+ select: client.select.bind(client),
102
+ disconnect: client.disconnect.bind(client),
103
+ selectAccount: client.selectAccount.bind(client)
104
+ }),
105
+ [client]
106
+ );
107
+ return useMemo(
108
+ () => ({
109
+ ...state,
110
+ ...methods
111
+ }),
112
+ [state, methods]
113
+ );
114
+ }
115
+ function useConnectorClient() {
116
+ return useContext(ConnectorContext);
117
+ }
118
+ function UnifiedProvider({ children, config, connectorConfig, mobile, providers = [] }) {
119
+ let actualConnectorConfig = config?.connectorConfig ?? connectorConfig, actualMobile = config?.mobile ?? mobile, content = /* @__PURE__ */ jsx(ConnectorProvider, { config: actualConnectorConfig, mobile: actualMobile, children });
120
+ for (let i = providers.length - 1; i >= 0; i--) {
121
+ let { component: Provider, props = {} } = providers[i];
122
+ content = /* @__PURE__ */ jsx(Provider, { ...props, children: content });
123
+ }
124
+ return content;
125
+ }
126
+ function useCluster() {
127
+ let { cluster, clusters } = useConnector(), client = useConnectorClient();
128
+ if (!client)
129
+ throw new Error("useCluster must be used within ConnectorProvider");
130
+ let setCluster = useMemo(
131
+ () => async (id) => {
132
+ await client.setCluster(id);
133
+ },
134
+ [client]
135
+ );
136
+ return useMemo(() => {
137
+ let isMainnet = cluster ? isMainnetCluster(cluster) : false, isDevnet = cluster ? isDevnetCluster(cluster) : false, isTestnet = cluster ? isTestnetCluster(cluster) : false, isLocal = cluster ? isLocalCluster(cluster) : false, explorerUrl = cluster ? getClusterExplorerUrl(cluster) : "", type = cluster ? getClusterType(cluster) : null;
138
+ return {
139
+ cluster,
140
+ clusters,
141
+ setCluster,
142
+ isMainnet,
143
+ isDevnet,
144
+ isTestnet,
145
+ isLocal,
146
+ explorerUrl,
147
+ type
148
+ };
149
+ }, [cluster, clusters, setCluster]);
150
+ }
151
+ function useAccount() {
152
+ let { selectedAccount, accounts, connected, selectAccount } = useConnector(), [copied, setCopied] = useState(false), copyTimeoutRef = React.useRef(void 0), account = useMemo(
153
+ () => accounts.find((a) => a.address === selectedAccount) ?? null,
154
+ [accounts, selectedAccount]
155
+ ), formatted = useMemo(() => selectedAccount ? formatAddress(selectedAccount) : "", [selectedAccount]), copy = useCallback(async () => selectedAccount ? (copyTimeoutRef.current && clearTimeout(copyTimeoutRef.current), await copyAddressToClipboard(selectedAccount, {
156
+ onSuccess: () => {
157
+ setCopied(true), copyTimeoutRef.current = setTimeout(() => setCopied(false), 2e3);
158
+ }
159
+ })) : {
160
+ success: false,
161
+ error: "empty_value" /* EMPTY_VALUE */,
162
+ errorMessage: "No account selected"
163
+ }, [selectedAccount]);
164
+ return React.useEffect(() => () => {
165
+ copyTimeoutRef.current && clearTimeout(copyTimeoutRef.current);
166
+ }, []), useMemo(
167
+ () => ({
168
+ address: selectedAccount,
169
+ account,
170
+ connected,
171
+ formatted,
172
+ copy,
173
+ copied,
174
+ accounts,
175
+ selectAccount
176
+ }),
177
+ [selectedAccount, account, connected, formatted, copy, copied, accounts, selectAccount]
178
+ );
179
+ }
180
+ function useWalletInfo() {
181
+ let { selectedWallet, wallets, connected, connecting } = useConnector(), mappedWallets = useMemo(
182
+ () => wallets.map(
183
+ (walletInfo) => ({
184
+ name: walletInfo.wallet.name,
185
+ icon: walletInfo.wallet.icon,
186
+ installed: walletInfo.installed,
187
+ connectable: walletInfo.connectable
188
+ })
189
+ ),
190
+ [wallets]
191
+ ), selectedWalletInfo = useMemo(() => {
192
+ if (!selectedWallet)
193
+ return {
194
+ name: null,
195
+ icon: null,
196
+ installed: false,
197
+ connectable: false
198
+ };
199
+ let walletInfo = wallets.find((w) => w.wallet.name === selectedWallet.name);
200
+ return {
201
+ name: selectedWallet.name,
202
+ icon: selectedWallet.icon ?? null,
203
+ installed: walletInfo?.installed ?? false,
204
+ connectable: walletInfo?.connectable ?? false
205
+ };
206
+ }, [selectedWallet, wallets]);
207
+ return useMemo(
208
+ () => ({
209
+ ...selectedWalletInfo,
210
+ connected,
211
+ connecting,
212
+ wallets: mappedWallets
213
+ }),
214
+ [selectedWalletInfo, connected, connecting, mappedWallets]
215
+ );
216
+ }
217
+ function useTransactionSigner() {
218
+ let { selectedWallet, selectedAccount, accounts, cluster, connected } = useConnector(), client = useConnectorClient(), account = useMemo(
219
+ () => accounts.find((a) => a.address === selectedAccount)?.raw ?? null,
220
+ [accounts, selectedAccount]
221
+ ), signer = useMemo(() => !connected || !selectedWallet || !account ? null : createTransactionSigner({
222
+ wallet: selectedWallet,
223
+ account,
224
+ cluster: cluster ?? void 0,
225
+ eventEmitter: client ? {
226
+ emit: (event) => {
227
+ client.emitEvent(event);
228
+ }
229
+ } : void 0
230
+ }), [connected, selectedWallet, account, cluster, client]), capabilities = useMemo(
231
+ () => signer?.getCapabilities() ?? {
232
+ canSign: false,
233
+ canSend: false,
234
+ canSignMessage: false,
235
+ supportsBatchSigning: false
236
+ },
237
+ [signer]
238
+ );
239
+ return {
240
+ signer,
241
+ ready: !!signer,
242
+ address: selectedAccount,
243
+ capabilities
244
+ };
245
+ }
246
+ function useKitTransactionSigner() {
247
+ let { signer: connectorSigner, ready } = useTransactionSigner();
248
+ return {
249
+ signer: useMemo(() => connectorSigner ? createKitTransactionSigner(connectorSigner) : null, [connectorSigner]),
250
+ ready
251
+ };
252
+ }
253
+ var useGillTransactionSigner = useKitTransactionSigner;
254
+ var logger2 = createLogger("useSolanaClient");
255
+ function useSolanaClient() {
256
+ let { type } = useCluster(), connectorClient = useConnectorClient(), client = useMemo(() => {
257
+ if (!type || !connectorClient) return null;
258
+ try {
259
+ let rpcUrl = connectorClient.getRpcUrl();
260
+ return rpcUrl ? createSolanaClient({
261
+ urlOrMoniker: rpcUrl
262
+ }) : type !== "custom" ? createSolanaClient({
263
+ urlOrMoniker: type
264
+ }) : null;
265
+ } catch (error) {
266
+ return logger2.error("Failed to create Solana client", { error }), null;
267
+ }
268
+ }, [type, connectorClient]);
269
+ return useMemo(
270
+ () => ({
271
+ client,
272
+ ready: !!client,
273
+ clusterType: type
274
+ }),
275
+ [client, type]
276
+ );
277
+ }
278
+ var useGillSolanaClient = useSolanaClient;
279
+ function useTransactionPreparer() {
280
+ let { client, ready } = useSolanaClient(), prepare = useCallback(
281
+ async (transaction, options = {}) => {
282
+ if (!client)
283
+ throw new NetworkError("RPC_ERROR", "Solana client not available. Cannot prepare transaction.");
284
+ return prepareTransaction({
285
+ transaction,
286
+ rpc: client.rpc,
287
+ computeUnitLimitMultiplier: options.computeUnitLimitMultiplier,
288
+ computeUnitLimitReset: options.computeUnitLimitReset,
289
+ blockhashReset: options.blockhashReset
290
+ });
291
+ },
292
+ [client]
293
+ );
294
+ return useMemo(
295
+ () => ({
296
+ prepare,
297
+ ready
298
+ }),
299
+ [prepare, ready]
300
+ );
301
+ }
302
+ var LAMPORTS_PER_SOL2 = 1000000000n;
303
+ function formatSol(lamports, decimals = 4) {
304
+ return (Number(lamports) / Number(LAMPORTS_PER_SOL2)).toLocaleString(void 0, {
305
+ minimumFractionDigits: 0,
306
+ maximumFractionDigits: decimals
307
+ }) + " SOL";
308
+ }
309
+ function useBalance() {
310
+ let { address: address$1, connected } = useAccount(); useCluster(); let client = useSolanaClient(), [lamports, setLamports] = useState(0n), [tokens, setTokens] = useState([]), [isLoading, setIsLoading] = useState(false), [error, setError] = useState(null), [lastUpdated, setLastUpdated] = useState(null), rpcClient = client?.client ?? null, fetchBalance = useCallback(async () => {
311
+ if (!connected || !address$1 || !rpcClient) {
312
+ setLamports(0n), setTokens([]);
313
+ return;
314
+ }
315
+ setIsLoading(true), setError(null);
316
+ try {
317
+ let rpc = rpcClient.rpc, walletAddress = address(address$1), balanceResult = await rpc.getBalance(walletAddress).send();
318
+ setLamports(balanceResult.value);
319
+ try {
320
+ let tokenProgramId = address("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"), tokenAccountsResult = await rpc.getTokenAccountsByOwner(walletAddress, { programId: tokenProgramId }, { encoding: "jsonParsed" }).send(), tokenBalances = [];
321
+ for (let account of tokenAccountsResult.value) {
322
+ let parsed = account.account.data;
323
+ if (parsed?.parsed?.info) {
324
+ let info = parsed.parsed.info, amount = BigInt(info.tokenAmount?.amount || "0"), decimals = info.tokenAmount?.decimals || 0, formatted = (Number(amount) / Math.pow(10, decimals)).toLocaleString(void 0, {
325
+ minimumFractionDigits: 0,
326
+ maximumFractionDigits: Math.min(decimals, 6)
327
+ });
328
+ amount > 0n && tokenBalances.push({
329
+ mint: info.mint,
330
+ amount,
331
+ decimals,
332
+ formatted
333
+ });
334
+ }
335
+ }
336
+ setTokens(tokenBalances);
337
+ } catch (tokenError) {
338
+ console.warn("Failed to fetch token balances:", tokenError), setTokens([]);
339
+ }
340
+ setLastUpdated(/* @__PURE__ */ new Date());
341
+ } catch (err) {
342
+ setError(err), console.error("Failed to fetch balance:", err);
343
+ } finally {
344
+ setIsLoading(false);
345
+ }
346
+ }, [connected, address$1, rpcClient]);
347
+ useEffect(() => {
348
+ fetchBalance();
349
+ }, [fetchBalance]), useEffect(() => {
350
+ if (!connected) return;
351
+ let interval = setInterval(fetchBalance, 3e4);
352
+ return () => clearInterval(interval);
353
+ }, [connected, fetchBalance]);
354
+ let solBalance = useMemo(() => Number(lamports) / Number(LAMPORTS_PER_SOL2), [lamports]), formattedSol = useMemo(() => formatSol(lamports), [lamports]);
355
+ return useMemo(
356
+ () => ({
357
+ solBalance,
358
+ lamports,
359
+ formattedSol,
360
+ tokens,
361
+ isLoading,
362
+ error,
363
+ refetch: fetchBalance,
364
+ lastUpdated
365
+ }),
366
+ [solBalance, lamports, formattedSol, tokens, isLoading, error, fetchBalance, lastUpdated]
367
+ );
368
+ }
369
+ function formatDate(timestamp) {
370
+ if (!timestamp)
371
+ return { date: "Unknown", time: "" };
372
+ let date = new Date(timestamp * 1e3), diffDays = Math.floor(((/* @__PURE__ */ new Date()).getTime() - date.getTime()) / (1e3 * 60 * 60 * 24)), formattedDate;
373
+ diffDays === 0 ? formattedDate = "Today" : diffDays === 1 ? formattedDate = "Yesterday" : diffDays < 7 ? formattedDate = `${diffDays} days ago` : formattedDate = date.toLocaleDateString();
374
+ let formattedTime = date.toLocaleTimeString(void 0, {
375
+ hour: "2-digit",
376
+ minute: "2-digit"
377
+ });
378
+ return { date: formattedDate, time: formattedTime };
379
+ }
380
+ function isAccountKey(value) {
381
+ return typeof value == "object" && value !== null && "pubkey" in value && typeof value.pubkey == "string";
382
+ }
383
+ function isTransactionMeta(value) {
384
+ if (typeof value != "object" || value === null || !("preBalances" in value) || !("postBalances" in value))
385
+ return false;
386
+ let meta = value;
387
+ if (!Array.isArray(meta.preBalances) || !Array.isArray(meta.postBalances))
388
+ return false;
389
+ let isValidBalance = (b) => typeof b == "number" || typeof b == "bigint";
390
+ return meta.preBalances.every(isValidBalance) && meta.postBalances.every(isValidBalance);
391
+ }
392
+ function isTokenBalance(value) {
393
+ return typeof value == "object" && value !== null && "accountIndex" in value && "mint" in value && "uiTokenAmount" in value && typeof value.accountIndex == "number" && typeof value.mint == "string" && typeof value.uiTokenAmount == "object" && value.uiTokenAmount !== null;
394
+ }
395
+ function isUiTokenAmount(value) {
396
+ return typeof value == "object" && value !== null && "amount" in value && "decimals" in value && typeof value.amount == "string" && typeof value.decimals == "number";
397
+ }
398
+ function isTransactionWithMeta(value) {
399
+ return typeof value == "object" && value !== null && "meta" in value && "transaction" in value && value.meta !== null && typeof value.transaction == "object" && value.transaction !== null && "message" in value.transaction;
400
+ }
401
+ function isTransactionMessage(value) {
402
+ return typeof value == "object" && value !== null && "accountKeys" in value && Array.isArray(value.accountKeys);
403
+ }
404
+ function getAccountKeys(message) {
405
+ return Array.isArray(message.accountKeys) ? message.accountKeys.map((key) => typeof key == "string" ? key : isAccountKey(key) ? key.pubkey : "").filter(Boolean) : [];
406
+ }
407
+ function detectProgramIds(message, accountKeys) {
408
+ let programIds = /* @__PURE__ */ new Set();
409
+ if (!Array.isArray(message.instructions))
410
+ return programIds;
411
+ for (let instruction of message.instructions)
412
+ if (typeof instruction == "object" && instruction !== null) {
413
+ if (typeof instruction.programIdIndex == "number" && accountKeys[instruction.programIdIndex])
414
+ programIds.add(accountKeys[instruction.programIdIndex]);
415
+ else if (typeof instruction.programId == "string")
416
+ programIds.add(instruction.programId);
417
+ else if (instruction.programId && typeof instruction.programId == "object") {
418
+ let programIdStr = String(instruction.programId);
419
+ programIdStr && programIdStr !== "[object Object]" && programIds.add(programIdStr);
420
+ }
421
+ }
422
+ return programIds;
423
+ }
424
+ function parseSolChange(meta, walletIndex) {
425
+ if (!isTransactionMeta(meta) || !Array.isArray(meta.preBalances) || !Array.isArray(meta.postBalances))
426
+ return { balanceChange: 0, solChange: 0 };
427
+ let preBalanceRaw = meta.preBalances[walletIndex], postBalanceRaw = meta.postBalances[walletIndex], preBalance = typeof preBalanceRaw == "number" ? preBalanceRaw : typeof preBalanceRaw == "bigint" ? Number(preBalanceRaw) : 0, balanceChange = (typeof postBalanceRaw == "number" ? postBalanceRaw : typeof postBalanceRaw == "bigint" ? Number(postBalanceRaw) : 0) - preBalance, solChange = balanceChange / 1e9;
428
+ return { balanceChange, solChange };
429
+ }
430
+ function parseTokenTransfers(meta, accountKeys, walletAddress) {
431
+ if (!isTransactionMeta(meta))
432
+ return null;
433
+ let preTokenBalances = Array.isArray(meta.preTokenBalances) ? meta.preTokenBalances : [], postTokenBalances = Array.isArray(meta.postTokenBalances) ? meta.postTokenBalances : [], ourPreTokens = preTokenBalances.filter((balance) => {
434
+ if (!isTokenBalance(balance)) return false;
435
+ let accountKey = accountKeys[balance.accountIndex];
436
+ return accountKey && accountKey.trim() === walletAddress.trim() || balance.owner && balance.owner.trim() === walletAddress.trim();
437
+ }), ourPostTokens = postTokenBalances.filter((balance) => {
438
+ if (!isTokenBalance(balance)) return false;
439
+ let accountKey = accountKeys[balance.accountIndex];
440
+ return accountKey && accountKey.trim() === walletAddress.trim() || balance.owner && balance.owner.trim() === walletAddress.trim();
441
+ }), allMints = /* @__PURE__ */ new Set();
442
+ for (let token of ourPreTokens)
443
+ isTokenBalance(token) && allMints.add(token.mint);
444
+ for (let token of ourPostTokens)
445
+ isTokenBalance(token) && allMints.add(token.mint);
446
+ for (let mint of allMints) {
447
+ let preBal = ourPreTokens.find((b) => isTokenBalance(b) && b.mint === mint), postBal = ourPostTokens.find((b) => isTokenBalance(b) && b.mint === mint);
448
+ if (!isTokenBalance(preBal) && !isTokenBalance(postBal))
449
+ continue;
450
+ let preAmount = isTokenBalance(preBal) && isUiTokenAmount(preBal.uiTokenAmount) ? Number(preBal.uiTokenAmount.amount) : 0, change = (isTokenBalance(postBal) && isUiTokenAmount(postBal.uiTokenAmount) ? Number(postBal.uiTokenAmount.amount) : 0) - preAmount;
451
+ if (change !== 0) {
452
+ let decimals = isTokenBalance(postBal) && isUiTokenAmount(postBal.uiTokenAmount) ? postBal.uiTokenAmount.decimals : isTokenBalance(preBal) && isUiTokenAmount(preBal.uiTokenAmount) ? preBal.uiTokenAmount.decimals : 0;
453
+ if (typeof decimals != "number" || decimals < 0)
454
+ continue;
455
+ return {
456
+ tokenMint: mint,
457
+ tokenAmount: Math.abs(change) / Math.pow(10, decimals),
458
+ tokenDecimals: decimals,
459
+ direction: change > 0 ? "in" : "out",
460
+ type: change > 0 ? "received" : "sent"
461
+ };
462
+ }
463
+ }
464
+ if (ourPostTokens.length > ourPreTokens.length) {
465
+ let newToken = ourPostTokens.find(
466
+ (b) => isTokenBalance(b) && !ourPreTokens.some((p) => isTokenBalance(p) && p.mint === b.mint)
467
+ );
468
+ if (isTokenBalance(newToken) && isUiTokenAmount(newToken.uiTokenAmount)) {
469
+ let decimals = newToken.uiTokenAmount.decimals;
470
+ if (typeof decimals == "number" && decimals >= 0) {
471
+ let amount = Number(newToken.uiTokenAmount.amount) / Math.pow(10, decimals);
472
+ return {
473
+ tokenMint: newToken.mint,
474
+ tokenAmount: amount,
475
+ tokenDecimals: decimals,
476
+ direction: "in",
477
+ type: "received"
478
+ };
479
+ }
480
+ }
481
+ }
482
+ return null;
483
+ }
484
+ function formatAmount(tokenAmount, tokenDecimals, direction, solChange) {
485
+ if (tokenAmount !== void 0 && tokenDecimals !== void 0 && direction !== void 0) {
486
+ let sign = direction === "in" ? "+" : "-", maxDecimals = Math.min(tokenDecimals, 6);
487
+ return `${sign}${tokenAmount.toLocaleString(void 0, { maximumFractionDigits: maxDecimals })}`;
488
+ }
489
+ if (solChange !== 0)
490
+ return `${solChange > 0 ? "+" : ""}${solChange.toFixed(4)} SOL`;
491
+ }
492
+ var tokenMetadataCache = /* @__PURE__ */ new Map();
493
+ async function fetchTokenMetadata(mints) {
494
+ let results = /* @__PURE__ */ new Map();
495
+ if (mints.length === 0) return results;
496
+ let uncachedMints = [];
497
+ for (let mint of mints) {
498
+ let cached = tokenMetadataCache.get(mint);
499
+ cached ? results.set(mint, cached) : uncachedMints.push(mint);
500
+ }
501
+ if (uncachedMints.length === 0) return results;
502
+ try {
503
+ let url = new URL("https://lite-api.jup.ag/tokens/v2/search");
504
+ url.searchParams.append("query", uncachedMints.join(","));
505
+ let response = await fetch(url.toString(), {
506
+ signal: AbortSignal.timeout(5e3)
507
+ });
508
+ if (!response.ok) return results;
509
+ let items = await response.json();
510
+ for (let item of items) {
511
+ let metadata = { symbol: item.symbol, icon: item.icon };
512
+ results.set(item.id, metadata), tokenMetadataCache.set(item.id, metadata);
513
+ }
514
+ } catch (error) {
515
+ console.warn("[useTransactions] Failed to fetch token metadata:", error);
516
+ }
517
+ return results;
518
+ }
519
+ function useTransactions(options = {}) {
520
+ let { limit = 10, autoRefresh = false, refreshInterval = 6e4, fetchDetails = true } = options, { address: address$1, connected } = useAccount(), { cluster } = useCluster(), client = useSolanaClient(), [transactions, setTransactions] = useState([]), [isLoading, setIsLoading] = useState(false), [error, setError] = useState(null), [hasMore, setHasMore] = useState(true), [lastUpdated, setLastUpdated] = useState(null), beforeSignatureRef = useRef(void 0), prevDepsRef = useRef(
521
+ null
522
+ ), rpcClient = client?.client ?? null, parseTransaction = useCallback(
523
+ (tx, walletAddress, sig, blockTime, slot, err, explorerUrl) => {
524
+ let { date, time } = formatDate(blockTime), baseInfo = {
525
+ signature: sig,
526
+ blockTime,
527
+ slot,
528
+ status: err ? "failed" : "success",
529
+ error: err ? JSON.stringify(err) : void 0,
530
+ type: "unknown",
531
+ formattedDate: date,
532
+ formattedTime: time,
533
+ explorerUrl
534
+ };
535
+ if (!isTransactionWithMeta(tx))
536
+ return baseInfo;
537
+ try {
538
+ let { meta, transaction } = tx;
539
+ if (!isTransactionMeta(meta))
540
+ return baseInfo;
541
+ let { message } = transaction;
542
+ if (!isTransactionMessage(message))
543
+ return baseInfo;
544
+ let accountKeys = getAccountKeys(message), walletIndex = accountKeys.findIndex((key) => key.trim() === walletAddress.trim());
545
+ if (walletIndex === -1)
546
+ return baseInfo;
547
+ let { balanceChange, solChange } = parseSolChange(meta, walletIndex), programIds = detectProgramIds(message, accountKeys), hasJupiter = programIds.has("JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"), hasOrca = programIds.has("whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc"), hasRaydium = programIds.has("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"), hasStake = programIds.has("Stake11111111111111111111111111111111111111"), hasMetaplex = programIds.has("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"), hasSystemProgram = programIds.has("11111111111111111111111111111111"), hasTokenProgram = programIds.has("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"), type = "unknown", direction, counterparty, tokenMint, tokenAmount, tokenDecimals;
548
+ if (hasJupiter || hasOrca || hasRaydium)
549
+ type = "swap";
550
+ else if (hasStake)
551
+ type = "stake";
552
+ else if (hasMetaplex)
553
+ type = "nft";
554
+ else if (hasSystemProgram && Math.abs(balanceChange) > 0)
555
+ type = balanceChange > 0 ? "received" : "sent", direction = balanceChange > 0 ? "in" : "out", tokenMint = "So11111111111111111111111111111111111111112", accountKeys.length >= 2 && (counterparty = accountKeys.find(
556
+ (key, idx) => idx !== walletIndex && key !== "11111111111111111111111111111111"
557
+ ));
558
+ else if (hasTokenProgram) {
559
+ let tokenTransfer = parseTokenTransfers(meta, accountKeys, walletAddress);
560
+ tokenTransfer && (type = tokenTransfer.type, direction = tokenTransfer.direction, tokenMint = tokenTransfer.tokenMint, tokenAmount = tokenTransfer.tokenAmount, tokenDecimals = tokenTransfer.tokenDecimals);
561
+ } else programIds.size > 0 && (type = "program");
562
+ let formattedAmount = formatAmount(tokenAmount, tokenDecimals, direction, solChange);
563
+ return {
564
+ ...baseInfo,
565
+ type,
566
+ direction,
567
+ amount: tokenAmount ?? Math.abs(solChange),
568
+ formattedAmount,
569
+ tokenMint,
570
+ counterparty: counterparty ? `${counterparty.slice(0, 4)}...${counterparty.slice(-4)}` : void 0
571
+ };
572
+ } catch (parseError) {
573
+ return console.warn("Failed to parse transaction:", parseError), baseInfo;
574
+ }
575
+ },
576
+ []
577
+ ), fetchTransactions = useCallback(
578
+ async (loadMore = false) => {
579
+ if (!connected || !address$1 || !rpcClient || !cluster) {
580
+ setTransactions([]);
581
+ return;
582
+ }
583
+ setIsLoading(true), setError(null);
584
+ try {
585
+ let rpc = rpcClient.rpc, walletAddress = address(address$1), signaturesResult = await rpc.getSignaturesForAddress(walletAddress, {
586
+ limit,
587
+ ...loadMore && beforeSignatureRef.current ? { before: signature(beforeSignatureRef.current) } : {}
588
+ }).send(), newTransactions;
589
+ if (fetchDetails && signaturesResult.length > 0) {
590
+ let txPromises = signaturesResult.map(
591
+ (s) => rpc.getTransaction(signature(String(s.signature)), {
592
+ encoding: "jsonParsed",
593
+ maxSupportedTransactionVersion: 0
594
+ }).send().catch(() => null)
595
+ ), txDetails = await Promise.all(txPromises);
596
+ newTransactions = signaturesResult.map((sig, idx) => {
597
+ let blockTimeNum = sig.blockTime ? Number(sig.blockTime) : null, tx = txDetails[idx];
598
+ return parseTransaction(
599
+ tx,
600
+ address$1,
601
+ String(sig.signature),
602
+ blockTimeNum,
603
+ Number(sig.slot),
604
+ sig.err,
605
+ getTransactionUrl(String(sig.signature), cluster)
606
+ );
607
+ });
608
+ } else
609
+ newTransactions = signaturesResult.map((sig) => {
610
+ let blockTimeNum = sig.blockTime ? Number(sig.blockTime) : null, { date, time } = formatDate(blockTimeNum);
611
+ return {
612
+ signature: String(sig.signature),
613
+ blockTime: blockTimeNum,
614
+ slot: Number(sig.slot),
615
+ status: sig.err ? "failed" : "success",
616
+ error: sig.err ? JSON.stringify(sig.err) : void 0,
617
+ type: "unknown",
618
+ formattedDate: date,
619
+ formattedTime: time,
620
+ explorerUrl: getTransactionUrl(String(sig.signature), cluster)
621
+ };
622
+ });
623
+ setTransactions(loadMore ? (prev) => [...prev, ...newTransactions] : newTransactions);
624
+ let mintsToFetch = [...new Set(newTransactions.filter((tx) => tx.tokenMint).map((tx) => tx.tokenMint))];
625
+ if (mintsToFetch.length > 0) {
626
+ let tokenMetadata = await fetchTokenMetadata(mintsToFetch);
627
+ if (tokenMetadata.size > 0) {
628
+ let enrichedTransactions = newTransactions.map((tx) => {
629
+ if (tx.tokenMint && tokenMetadata.has(tx.tokenMint)) {
630
+ let meta = tokenMetadata.get(tx.tokenMint);
631
+ return {
632
+ ...tx,
633
+ tokenSymbol: meta.symbol,
634
+ tokenIcon: meta.icon,
635
+ // Update formatted amount with symbol
636
+ formattedAmount: tx.formattedAmount ? `${tx.formattedAmount} ${meta.symbol}` : tx.formattedAmount
637
+ };
638
+ }
639
+ return tx;
640
+ });
641
+ setTransactions(loadMore ? (prev) => [...prev.slice(0, -newTransactions.length), ...enrichedTransactions] : enrichedTransactions);
642
+ }
643
+ }
644
+ if (typeof newTransactions < "u" && Array.isArray(newTransactions)) {
645
+ if (newTransactions.length > 0) {
646
+ let newBeforeSignature = newTransactions[newTransactions.length - 1].signature;
647
+ beforeSignatureRef.current = newBeforeSignature;
648
+ }
649
+ setHasMore(newTransactions.length === limit);
650
+ }
651
+ setLastUpdated(/* @__PURE__ */ new Date());
652
+ } catch (err) {
653
+ setError(err), console.error("Failed to fetch transactions:", err);
654
+ } finally {
655
+ setIsLoading(false);
656
+ }
657
+ },
658
+ [connected, address$1, rpcClient, cluster, limit, fetchDetails, parseTransaction]
659
+ ), refetch = useCallback(async () => {
660
+ beforeSignatureRef.current = void 0, await fetchTransactions(false);
661
+ }, [fetchTransactions]), loadMoreFn = useCallback(async () => {
662
+ hasMore && !isLoading && await fetchTransactions(true);
663
+ }, [hasMore, isLoading, fetchTransactions]);
664
+ return useEffect(() => {
665
+ let prevDeps = prevDepsRef.current, currentDeps = { connected, address: address$1, cluster };
666
+ (!prevDeps || prevDeps.connected !== connected || prevDeps.address !== address$1 || prevDeps.cluster !== cluster) && (prevDepsRef.current = currentDeps, beforeSignatureRef.current = void 0, fetchTransactions(false));
667
+ }, [connected, address$1, cluster, fetchTransactions]), useEffect(() => {
668
+ if (!connected || !autoRefresh) return;
669
+ let interval = setInterval(refetch, refreshInterval);
670
+ return () => clearInterval(interval);
671
+ }, [connected, autoRefresh, refreshInterval, refetch]), useMemo(
672
+ () => ({
673
+ transactions,
674
+ isLoading,
675
+ error,
676
+ hasMore,
677
+ loadMore: loadMoreFn,
678
+ refetch,
679
+ lastUpdated
680
+ }),
681
+ [transactions, isLoading, error, hasMore, loadMoreFn, refetch, lastUpdated]
682
+ );
683
+ }
684
+ var NATIVE_MINT = "So11111111111111111111111111111111111111112", metadataCache = /* @__PURE__ */ new Map();
685
+ async function fetchJupiterMetadata(mints) {
686
+ let results = /* @__PURE__ */ new Map();
687
+ if (mints.length === 0) return results;
688
+ let uncachedMints = [];
689
+ for (let mint of mints) {
690
+ let cached = metadataCache.get(mint);
691
+ cached ? results.set(mint, cached) : uncachedMints.push(mint);
692
+ }
693
+ if (uncachedMints.length === 0) return results;
694
+ try {
695
+ let url = new URL("https://lite-api.jup.ag/tokens/v2/search");
696
+ url.searchParams.append("query", uncachedMints.join(","));
697
+ let response = await fetch(url.toString(), {
698
+ signal: AbortSignal.timeout(1e4)
699
+ });
700
+ if (!response.ok)
701
+ throw new Error(`Jupiter API error: ${response.status}`);
702
+ let items = await response.json();
703
+ for (let item of items) {
704
+ let metadata = {
705
+ id: item.id,
706
+ name: item.id === NATIVE_MINT ? "Solana" : item.name,
707
+ symbol: item.symbol,
708
+ decimals: item.decimals,
709
+ icon: item.icon,
710
+ usdPrice: item.usdPrice
711
+ };
712
+ results.set(item.id, metadata), metadataCache.set(item.id, metadata);
713
+ }
714
+ } catch (error) {
715
+ console.warn("[useTokens] Jupiter API failed:", error);
716
+ }
717
+ return results;
718
+ }
719
+ function formatBalance(amount, decimals) {
720
+ return (Number(amount) / Math.pow(10, decimals)).toLocaleString(void 0, {
721
+ minimumFractionDigits: 0,
722
+ maximumFractionDigits: Math.min(decimals, 6)
723
+ });
724
+ }
725
+ function formatUsd(amount, decimals, usdPrice) {
726
+ return (Number(amount) / Math.pow(10, decimals) * usdPrice).toLocaleString(void 0, {
727
+ style: "currency",
728
+ currency: "USD",
729
+ minimumFractionDigits: 2,
730
+ maximumFractionDigits: 2
731
+ });
732
+ }
733
+ function useTokens(options = {}) {
734
+ let {
735
+ includeZeroBalance = false,
736
+ autoRefresh = false,
737
+ refreshInterval = 6e4,
738
+ fetchMetadata = true,
739
+ includeNativeSol = true
740
+ } = options, { address: address$1, connected } = useAccount(), client = useSolanaClient(), [tokens, setTokens] = useState([]), [isLoading, setIsLoading] = useState(false), [error, setError] = useState(null), [lastUpdated, setLastUpdated] = useState(null), [totalAccounts, setTotalAccounts] = useState(0), rpcClient = client?.client ?? null, fetchTokens = useCallback(async () => {
741
+ if (!connected || !address$1 || !rpcClient) {
742
+ setTokens([]), setTotalAccounts(0);
743
+ return;
744
+ }
745
+ setIsLoading(true), setError(null);
746
+ try {
747
+ let rpc = rpcClient.rpc, walletAddress = address(address$1), tokenProgramId = address("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"), [balanceResult, tokenAccountsResult] = await Promise.all([
748
+ includeNativeSol ? rpc.getBalance(walletAddress).send() : Promise.resolve(null),
749
+ rpc.getTokenAccountsByOwner(walletAddress, { programId: tokenProgramId }, { encoding: "jsonParsed" }).send()
750
+ ]), tokenList = [], mints = [];
751
+ if (includeNativeSol && balanceResult !== null) {
752
+ let solBalance = balanceResult.value;
753
+ (includeZeroBalance || solBalance > 0n) && (tokenList.push({
754
+ mint: NATIVE_MINT,
755
+ tokenAccount: address$1,
756
+ // SOL uses wallet address
757
+ amount: solBalance,
758
+ decimals: 9,
759
+ formatted: formatBalance(solBalance, 9),
760
+ isFrozen: false,
761
+ owner: address$1
762
+ }), mints.push(NATIVE_MINT));
763
+ }
764
+ for (let account of tokenAccountsResult.value) {
765
+ let parsed = account.account.data;
766
+ if (parsed?.parsed?.info) {
767
+ let info = parsed.parsed.info, amount = BigInt(info.tokenAmount?.amount || "0"), decimals = info.tokenAmount?.decimals || 0;
768
+ if (!includeZeroBalance && amount === 0n)
769
+ continue;
770
+ tokenList.push({
771
+ mint: info.mint,
772
+ tokenAccount: account.pubkey,
773
+ amount,
774
+ decimals,
775
+ formatted: formatBalance(amount, decimals),
776
+ isFrozen: info.state === "frozen",
777
+ owner: info.owner
778
+ }), mints.push(info.mint);
779
+ }
780
+ }
781
+ if (setTokens([...tokenList]), setTotalAccounts(tokenAccountsResult.value.length + (includeNativeSol ? 1 : 0)), setLastUpdated(/* @__PURE__ */ new Date()), fetchMetadata && mints.length > 0) {
782
+ let metadata = await fetchJupiterMetadata(mints);
783
+ for (let i = 0; i < tokenList.length; i++) {
784
+ let meta = metadata.get(tokenList[i].mint);
785
+ meta && (tokenList[i] = {
786
+ ...tokenList[i],
787
+ name: meta.name,
788
+ symbol: meta.symbol,
789
+ logo: meta.icon,
790
+ usdPrice: meta.usdPrice,
791
+ formattedUsd: formatUsd(tokenList[i].amount, tokenList[i].decimals, meta.usdPrice)
792
+ });
793
+ }
794
+ tokenList.sort((a, b) => {
795
+ let metadataSort = (b.logo ? 1 : 0) - (a.logo ? 1 : 0);
796
+ if (metadataSort !== 0) return metadataSort;
797
+ let aValue = Number(a.amount) / Math.pow(10, a.decimals) * (a.usdPrice ?? 0);
798
+ return Number(b.amount) / Math.pow(10, b.decimals) * (b.usdPrice ?? 0) - aValue;
799
+ }), setTokens([...tokenList]);
800
+ }
801
+ } catch (err) {
802
+ setError(err), console.error("[useTokens] Failed to fetch tokens:", err);
803
+ } finally {
804
+ setIsLoading(false);
805
+ }
806
+ }, [connected, address$1, rpcClient, includeZeroBalance, fetchMetadata, includeNativeSol]);
807
+ return useEffect(() => {
808
+ fetchTokens();
809
+ }, [fetchTokens]), useEffect(() => {
810
+ if (!connected || !autoRefresh) return;
811
+ let interval = setInterval(fetchTokens, refreshInterval);
812
+ return () => clearInterval(interval);
813
+ }, [connected, autoRefresh, refreshInterval, fetchTokens]), useMemo(
814
+ () => ({
815
+ tokens,
816
+ isLoading,
817
+ error,
818
+ refetch: fetchTokens,
819
+ lastUpdated,
820
+ totalAccounts
821
+ }),
822
+ [tokens, isLoading, error, fetchTokens, lastUpdated, totalAccounts]
823
+ );
824
+ }
825
+ function DisconnectElement({
826
+ variant = "menuitem",
827
+ className,
828
+ label = "Disconnect",
829
+ icon,
830
+ showIcon = true,
831
+ onDisconnect,
832
+ render
833
+ }) {
834
+ let { disconnect, connecting } = useConnector(), [disconnecting, setDisconnecting] = React.useState(false), handleDisconnect = async () => {
835
+ setDisconnecting(true);
836
+ try {
837
+ await disconnect(), onDisconnect?.();
838
+ } finally {
839
+ setDisconnecting(false);
840
+ }
841
+ };
842
+ if (render)
843
+ return /* @__PURE__ */ jsx(Fragment, { children: render({ disconnect: handleDisconnect, disconnecting }) });
844
+ let isDisabled = connecting || disconnecting, content = /* @__PURE__ */ jsxs(Fragment, { children: [
845
+ showIcon && (icon || showIcon && !icon && /* @__PURE__ */ jsxs(
846
+ "svg",
847
+ {
848
+ width: "16",
849
+ height: "16",
850
+ viewBox: "0 0 24 24",
851
+ fill: "none",
852
+ stroke: "currentColor",
853
+ strokeWidth: "2",
854
+ strokeLinecap: "round",
855
+ strokeLinejoin: "round",
856
+ className: "ck-block-icon",
857
+ "data-slot": "disconnect-element-icon",
858
+ children: [
859
+ /* @__PURE__ */ jsx("path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }),
860
+ /* @__PURE__ */ jsx("polyline", { points: "16 17 21 12 16 7" }),
861
+ /* @__PURE__ */ jsx("line", { x1: "21", y1: "12", x2: "9", y2: "12" })
862
+ ]
863
+ }
864
+ )),
865
+ /* @__PURE__ */ jsx("span", { "data-slot": "disconnect-element-label", children: label })
866
+ ] });
867
+ return variant === "button" ? /* @__PURE__ */ jsx(
868
+ "button",
869
+ {
870
+ type: "button",
871
+ className: `ck-disconnect-block ck-disconnect-block--button ${className || ""}`,
872
+ onClick: handleDisconnect,
873
+ disabled: isDisabled,
874
+ "data-slot": "disconnect-element",
875
+ "data-variant": "button",
876
+ "data-disconnecting": disconnecting,
877
+ children: content
878
+ }
879
+ ) : variant === "link" ? /* @__PURE__ */ jsx(
880
+ "button",
881
+ {
882
+ type: "button",
883
+ className: `ck-disconnect-block ck-disconnect-block--link ${className || ""}`,
884
+ onClick: handleDisconnect,
885
+ disabled: isDisabled,
886
+ "data-slot": "disconnect-element",
887
+ "data-variant": "link",
888
+ "data-disconnecting": disconnecting,
889
+ children: content
890
+ }
891
+ ) : /* @__PURE__ */ jsx(
892
+ "button",
893
+ {
894
+ type: "button",
895
+ role: "menuitem",
896
+ className: `ck-disconnect-block ck-disconnect-block--menuitem ${className || ""}`,
897
+ onClick: handleDisconnect,
898
+ disabled: isDisabled,
899
+ "data-slot": "disconnect-element",
900
+ "data-variant": "menuitem",
901
+ "data-disconnecting": disconnecting,
902
+ children: content
903
+ }
904
+ );
905
+ }
906
+ DisconnectElement.displayName = "DisconnectElement";
907
+ function AccountElement({
908
+ showAvatar = true,
909
+ showCopy = true,
910
+ showFullAddress = false,
911
+ className,
912
+ avatarSize = 32,
913
+ variant = "compact",
914
+ render
915
+ }) {
916
+ let { address, formatted, copy, copied } = useAccount(), { name: walletName, icon: walletIcon } = useWalletInfo();
917
+ if (render)
918
+ return /* @__PURE__ */ jsx(Fragment, { children: render({ address, formatted, walletName, walletIcon, copy, copied }) });
919
+ if (!address) return null;
920
+ let displayAddress = showFullAddress ? address : formatted, handleCopy = async (e) => {
921
+ e.stopPropagation(), await copy();
922
+ }, copyIcon = /* @__PURE__ */ jsx(
923
+ "svg",
924
+ {
925
+ width: "14",
926
+ height: "14",
927
+ viewBox: "0 0 24 24",
928
+ fill: "none",
929
+ stroke: "currentColor",
930
+ strokeWidth: "2",
931
+ strokeLinecap: "round",
932
+ strokeLinejoin: "round",
933
+ className: "ck-block-icon",
934
+ "data-slot": "account-element-copy-icon",
935
+ children: copied ? /* @__PURE__ */ jsx("polyline", { points: "20 6 9 17 4 12" }) : /* @__PURE__ */ jsxs(Fragment, { children: [
936
+ /* @__PURE__ */ jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
937
+ /* @__PURE__ */ jsx("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
938
+ ] })
939
+ }
940
+ );
941
+ return variant === "inline" ? /* @__PURE__ */ jsxs(
942
+ "div",
943
+ {
944
+ className: `ck-account-block ck-account-block--inline ${className || ""}`,
945
+ "data-slot": "account-element",
946
+ "data-variant": "inline",
947
+ children: [
948
+ showAvatar && walletIcon && /* @__PURE__ */ jsx(
949
+ "img",
950
+ {
951
+ src: walletIcon,
952
+ alt: walletName || "Wallet",
953
+ className: "ck-account-block-avatar",
954
+ style: { width: avatarSize, height: avatarSize },
955
+ "data-slot": "account-element-avatar"
956
+ }
957
+ ),
958
+ /* @__PURE__ */ jsx("span", { className: "ck-account-block-address", "data-slot": "account-element-address", children: displayAddress }),
959
+ showCopy && /* @__PURE__ */ jsx(
960
+ "button",
961
+ {
962
+ type: "button",
963
+ className: "ck-account-block-copy",
964
+ onClick: handleCopy,
965
+ title: copied ? "Copied!" : "Copy address",
966
+ "data-slot": "account-element-copy",
967
+ "data-copied": copied,
968
+ children: copyIcon
969
+ }
970
+ )
971
+ ]
972
+ }
973
+ ) : variant === "expanded" ? /* @__PURE__ */ jsxs(
974
+ "div",
975
+ {
976
+ className: `ck-account-block ck-account-block--expanded ${className || ""}`,
977
+ "data-slot": "account-element",
978
+ "data-variant": "expanded",
979
+ children: [
980
+ /* @__PURE__ */ jsxs("div", { className: "ck-account-block-header", "data-slot": "account-element-header", children: [
981
+ showAvatar && walletIcon && /* @__PURE__ */ jsx(
982
+ "img",
983
+ {
984
+ src: walletIcon,
985
+ alt: walletName || "Wallet",
986
+ className: "ck-account-block-avatar",
987
+ style: { width: avatarSize, height: avatarSize },
988
+ "data-slot": "account-element-avatar"
989
+ }
990
+ ),
991
+ /* @__PURE__ */ jsxs("div", { className: "ck-account-block-info", "data-slot": "account-element-info", children: [
992
+ walletName && /* @__PURE__ */ jsx("span", { className: "ck-account-block-wallet-name", "data-slot": "account-element-wallet-name", children: walletName }),
993
+ /* @__PURE__ */ jsx("span", { className: "ck-account-block-address", "data-slot": "account-element-address", children: displayAddress })
994
+ ] })
995
+ ] }),
996
+ showCopy && /* @__PURE__ */ jsxs(
997
+ "button",
998
+ {
999
+ type: "button",
1000
+ className: "ck-account-block-copy",
1001
+ onClick: handleCopy,
1002
+ "data-slot": "account-element-copy",
1003
+ "data-copied": copied,
1004
+ children: [
1005
+ copyIcon,
1006
+ /* @__PURE__ */ jsx("span", { children: copied ? "Copied!" : "Copy" })
1007
+ ]
1008
+ }
1009
+ )
1010
+ ]
1011
+ }
1012
+ ) : /* @__PURE__ */ jsxs(
1013
+ "div",
1014
+ {
1015
+ className: `ck-account-block ck-account-block--compact ${className || ""}`,
1016
+ "data-slot": "account-element",
1017
+ "data-variant": "compact",
1018
+ children: [
1019
+ showAvatar && walletIcon && /* @__PURE__ */ jsx(
1020
+ "img",
1021
+ {
1022
+ src: walletIcon,
1023
+ alt: walletName || "Wallet",
1024
+ className: "ck-account-block-avatar",
1025
+ style: { width: avatarSize, height: avatarSize },
1026
+ "data-slot": "account-element-avatar"
1027
+ }
1028
+ ),
1029
+ /* @__PURE__ */ jsxs("div", { className: "ck-account-block-content", "data-slot": "account-element-content", children: [
1030
+ walletName && /* @__PURE__ */ jsx("span", { className: "ck-account-block-wallet-name", "data-slot": "account-element-wallet-name", children: walletName }),
1031
+ /* @__PURE__ */ jsx("span", { className: "ck-account-block-address", "data-slot": "account-element-address", children: displayAddress })
1032
+ ] }),
1033
+ showCopy && /* @__PURE__ */ jsx(
1034
+ "button",
1035
+ {
1036
+ type: "button",
1037
+ className: "ck-account-block-copy",
1038
+ onClick: handleCopy,
1039
+ title: copied ? "Copied!" : "Copy address",
1040
+ "data-slot": "account-element-copy",
1041
+ "data-copied": copied,
1042
+ children: copyIcon
1043
+ }
1044
+ )
1045
+ ]
1046
+ }
1047
+ );
1048
+ }
1049
+ AccountElement.displayName = "AccountElement";
1050
+ var DEFAULT_LABELS = {
1051
+ "mainnet-beta": "Mainnet",
1052
+ devnet: "Devnet",
1053
+ testnet: "Testnet",
1054
+ localnet: "Localnet"
1055
+ };
1056
+ function getClusterColor(clusterId) {
1057
+ switch (clusterId) {
1058
+ case "mainnet-beta":
1059
+ return "var(--ck-cluster-mainnet, #22c55e)";
1060
+ case "devnet":
1061
+ return "var(--ck-cluster-devnet, #3b82f6)";
1062
+ case "testnet":
1063
+ return "var(--ck-cluster-testnet, #eab308)";
1064
+ case "localnet":
1065
+ return "var(--ck-cluster-localnet, #ef4444)";
1066
+ default:
1067
+ return "var(--ck-cluster-custom, #8b5cf6)";
1068
+ }
1069
+ }
1070
+ function ClusterElement({
1071
+ variant = "badge",
1072
+ className,
1073
+ allowChange = false,
1074
+ showIndicator = true,
1075
+ labels = {},
1076
+ render
1077
+ }) {
1078
+ let { cluster, clusters, setCluster, isMainnet, isDevnet, isTestnet, isLocal } = useCluster(), [isOpen, setIsOpen] = React.useState(false);
1079
+ if (render)
1080
+ return /* @__PURE__ */ jsx(Fragment, { children: render({ cluster, clusters, setCluster, isMainnet, isDevnet, isTestnet, isLocal }) });
1081
+ if (!cluster) return null;
1082
+ let allLabels = { ...DEFAULT_LABELS, ...labels }, displayLabel = allLabels[cluster.id] || cluster.label || cluster.id, color = getClusterColor(cluster.id), indicator = showIndicator && /* @__PURE__ */ jsx(
1083
+ "span",
1084
+ {
1085
+ className: "ck-cluster-indicator",
1086
+ style: { backgroundColor: color },
1087
+ "data-slot": "cluster-element-indicator",
1088
+ "aria-hidden": "true"
1089
+ }
1090
+ );
1091
+ return variant === "badge" ? /* @__PURE__ */ jsxs(
1092
+ "span",
1093
+ {
1094
+ className: `ck-cluster-block ck-cluster-block--badge ${className || ""}`,
1095
+ "data-slot": "cluster-element",
1096
+ "data-variant": "badge",
1097
+ "data-cluster": cluster.id,
1098
+ children: [
1099
+ indicator,
1100
+ /* @__PURE__ */ jsx("span", { "data-slot": "cluster-element-label", children: displayLabel })
1101
+ ]
1102
+ }
1103
+ ) : variant === "menuitem" ? allowChange ? /* @__PURE__ */ jsxs(
1104
+ "div",
1105
+ {
1106
+ className: `ck-cluster-block ck-cluster-block--menuitem ${className || ""}`,
1107
+ "data-slot": "cluster-element",
1108
+ "data-variant": "menuitem",
1109
+ "data-cluster": cluster.id,
1110
+ children: [
1111
+ /* @__PURE__ */ jsxs(
1112
+ "button",
1113
+ {
1114
+ type: "button",
1115
+ className: "ck-cluster-block-trigger",
1116
+ onClick: () => setIsOpen(!isOpen),
1117
+ "data-slot": "cluster-element-trigger",
1118
+ children: [
1119
+ indicator,
1120
+ /* @__PURE__ */ jsx("span", { "data-slot": "cluster-element-label", children: displayLabel }),
1121
+ /* @__PURE__ */ jsx(
1122
+ "svg",
1123
+ {
1124
+ width: "12",
1125
+ height: "12",
1126
+ viewBox: "0 0 24 24",
1127
+ fill: "none",
1128
+ stroke: "currentColor",
1129
+ strokeWidth: "2",
1130
+ className: `ck-cluster-block-chevron ${isOpen ? "ck-cluster-block-chevron--open" : ""}`,
1131
+ "data-slot": "cluster-element-chevron",
1132
+ children: /* @__PURE__ */ jsx("polyline", { points: "6 9 12 15 18 9" })
1133
+ }
1134
+ )
1135
+ ]
1136
+ }
1137
+ ),
1138
+ isOpen && /* @__PURE__ */ jsx("div", { className: "ck-cluster-block-options", "data-slot": "cluster-element-options", children: clusters.map((c) => {
1139
+ let cLabel = allLabels[c.id] || c.label || c.id, cColor = getClusterColor(c.id), isSelected = c.id === cluster.id;
1140
+ return /* @__PURE__ */ jsxs(
1141
+ "button",
1142
+ {
1143
+ type: "button",
1144
+ className: `ck-cluster-block-option ${isSelected ? "ck-cluster-block-option--selected" : ""}`,
1145
+ onClick: () => {
1146
+ setCluster(c.id), setIsOpen(false);
1147
+ },
1148
+ "data-slot": "cluster-element-option",
1149
+ "data-selected": isSelected,
1150
+ children: [
1151
+ /* @__PURE__ */ jsx(
1152
+ "span",
1153
+ {
1154
+ className: "ck-cluster-indicator",
1155
+ style: { backgroundColor: cColor },
1156
+ "data-slot": "cluster-element-indicator"
1157
+ }
1158
+ ),
1159
+ /* @__PURE__ */ jsx("span", { children: cLabel }),
1160
+ isSelected && /* @__PURE__ */ jsx(
1161
+ "svg",
1162
+ {
1163
+ width: "12",
1164
+ height: "12",
1165
+ viewBox: "0 0 24 24",
1166
+ fill: "none",
1167
+ stroke: "currentColor",
1168
+ strokeWidth: "3",
1169
+ className: "ck-cluster-block-check",
1170
+ "data-slot": "cluster-element-check",
1171
+ children: /* @__PURE__ */ jsx("polyline", { points: "20 6 9 17 4 12" })
1172
+ }
1173
+ )
1174
+ ]
1175
+ },
1176
+ c.id
1177
+ );
1178
+ }) })
1179
+ ]
1180
+ }
1181
+ ) : /* @__PURE__ */ jsxs(
1182
+ "div",
1183
+ {
1184
+ className: `ck-cluster-block ck-cluster-block--menuitem ${className || ""}`,
1185
+ role: "menuitem",
1186
+ "data-slot": "cluster-element",
1187
+ "data-variant": "menuitem",
1188
+ "data-cluster": cluster.id,
1189
+ children: [
1190
+ indicator,
1191
+ /* @__PURE__ */ jsx("span", { "data-slot": "cluster-element-label", children: displayLabel })
1192
+ ]
1193
+ }
1194
+ ) : /* @__PURE__ */ jsxs(
1195
+ "div",
1196
+ {
1197
+ className: `ck-cluster-block ck-cluster-block--select ${className || ""}`,
1198
+ "data-slot": "cluster-element",
1199
+ "data-variant": "select",
1200
+ "data-cluster": cluster.id,
1201
+ children: [
1202
+ /* @__PURE__ */ jsxs(
1203
+ "button",
1204
+ {
1205
+ type: "button",
1206
+ className: "ck-cluster-block-trigger",
1207
+ onClick: () => setIsOpen(!isOpen),
1208
+ disabled: !allowChange,
1209
+ "data-slot": "cluster-element-trigger",
1210
+ children: [
1211
+ indicator,
1212
+ /* @__PURE__ */ jsx("span", { "data-slot": "cluster-element-label", children: displayLabel }),
1213
+ allowChange && /* @__PURE__ */ jsx(
1214
+ "svg",
1215
+ {
1216
+ width: "12",
1217
+ height: "12",
1218
+ viewBox: "0 0 24 24",
1219
+ fill: "none",
1220
+ stroke: "currentColor",
1221
+ strokeWidth: "2",
1222
+ className: `ck-cluster-block-chevron ${isOpen ? "ck-cluster-block-chevron--open" : ""}`,
1223
+ "data-slot": "cluster-element-chevron",
1224
+ children: /* @__PURE__ */ jsx("polyline", { points: "6 9 12 15 18 9" })
1225
+ }
1226
+ )
1227
+ ]
1228
+ }
1229
+ ),
1230
+ isOpen && allowChange && /* @__PURE__ */ jsxs(Fragment, { children: [
1231
+ /* @__PURE__ */ jsx("div", { className: "ck-cluster-block-backdrop", onClick: () => setIsOpen(false), "aria-hidden": "true" }),
1232
+ /* @__PURE__ */ jsx("div", { className: "ck-cluster-block-options", "data-slot": "cluster-element-options", children: clusters.map((c) => {
1233
+ let cLabel = allLabels[c.id] || c.label || c.id, cColor = getClusterColor(c.id), isSelected = c.id === cluster.id;
1234
+ return /* @__PURE__ */ jsxs(
1235
+ "button",
1236
+ {
1237
+ type: "button",
1238
+ className: `ck-cluster-block-option ${isSelected ? "ck-cluster-block-option--selected" : ""}`,
1239
+ onClick: () => {
1240
+ setCluster(c.id), setIsOpen(false);
1241
+ },
1242
+ "data-slot": "cluster-element-option",
1243
+ "data-selected": isSelected,
1244
+ children: [
1245
+ /* @__PURE__ */ jsx(
1246
+ "span",
1247
+ {
1248
+ className: "ck-cluster-indicator",
1249
+ style: { backgroundColor: cColor },
1250
+ "data-slot": "cluster-element-indicator"
1251
+ }
1252
+ ),
1253
+ /* @__PURE__ */ jsx("span", { children: cLabel }),
1254
+ isSelected && /* @__PURE__ */ jsx(
1255
+ "svg",
1256
+ {
1257
+ width: "12",
1258
+ height: "12",
1259
+ viewBox: "0 0 24 24",
1260
+ fill: "none",
1261
+ stroke: "currentColor",
1262
+ strokeWidth: "3",
1263
+ className: "ck-cluster-block-check",
1264
+ "data-slot": "cluster-element-check",
1265
+ children: /* @__PURE__ */ jsx("polyline", { points: "20 6 9 17 4 12" })
1266
+ }
1267
+ )
1268
+ ]
1269
+ },
1270
+ c.id
1271
+ );
1272
+ }) })
1273
+ ] })
1274
+ ]
1275
+ }
1276
+ );
1277
+ }
1278
+ ClusterElement.displayName = "ClusterElement";
1279
+ function WalletListElement({
1280
+ installedOnly = false,
1281
+ className,
1282
+ variant = "list",
1283
+ showStatus = true,
1284
+ onSelect,
1285
+ render,
1286
+ renderWallet
1287
+ }) {
1288
+ let { wallets, connecting } = useWalletInfo(), { select } = useConnector(), installedWallets = wallets.filter((w) => w.installed), displayWallets = installedOnly ? installedWallets : wallets, handleSelect = async (walletName) => {
1289
+ await select(walletName), onSelect?.(walletName);
1290
+ };
1291
+ if (render)
1292
+ return /* @__PURE__ */ jsx(Fragment, { children: render({ wallets, installedWallets, select: handleSelect, connecting }) });
1293
+ if (displayWallets.length === 0)
1294
+ return /* @__PURE__ */ jsx(
1295
+ "div",
1296
+ {
1297
+ className: `ck-wallet-list-block ck-wallet-list-block--empty ${className || ""}`,
1298
+ "data-slot": "wallet-list-element",
1299
+ "data-empty": "true",
1300
+ children: /* @__PURE__ */ jsxs("div", { className: "ck-wallet-list-empty", "data-slot": "wallet-list-empty", children: [
1301
+ /* @__PURE__ */ jsxs(
1302
+ "svg",
1303
+ {
1304
+ width: "48",
1305
+ height: "48",
1306
+ viewBox: "0 0 24 24",
1307
+ fill: "none",
1308
+ stroke: "currentColor",
1309
+ strokeWidth: "1.5",
1310
+ strokeLinecap: "round",
1311
+ strokeLinejoin: "round",
1312
+ className: "ck-wallet-list-empty-icon",
1313
+ "data-slot": "wallet-list-empty-icon",
1314
+ children: [
1315
+ /* @__PURE__ */ jsx("path", { d: "M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1" }),
1316
+ /* @__PURE__ */ jsx("path", { d: "M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4" })
1317
+ ]
1318
+ }
1319
+ ),
1320
+ /* @__PURE__ */ jsx("p", { className: "ck-wallet-list-empty-text", "data-slot": "wallet-list-empty-text", children: installedOnly ? "No wallets detected" : "No wallets available" }),
1321
+ /* @__PURE__ */ jsx("p", { className: "ck-wallet-list-empty-hint", "data-slot": "wallet-list-empty-hint", children: "Install a Solana wallet extension to continue" })
1322
+ ] })
1323
+ }
1324
+ );
1325
+ let walletIcon = /* @__PURE__ */ jsxs(
1326
+ "svg",
1327
+ {
1328
+ width: "20",
1329
+ height: "20",
1330
+ viewBox: "0 0 24 24",
1331
+ fill: "none",
1332
+ stroke: "currentColor",
1333
+ strokeWidth: "2",
1334
+ strokeLinecap: "round",
1335
+ strokeLinejoin: "round",
1336
+ className: "ck-wallet-list-item-fallback-icon",
1337
+ "data-slot": "wallet-list-item-fallback-icon",
1338
+ children: [
1339
+ /* @__PURE__ */ jsx("path", { d: "M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1" }),
1340
+ /* @__PURE__ */ jsx("path", { d: "M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4" })
1341
+ ]
1342
+ }
1343
+ );
1344
+ return variant === "grid" ? /* @__PURE__ */ jsx(
1345
+ "div",
1346
+ {
1347
+ className: `ck-wallet-list-block ck-wallet-list-block--grid ${className || ""}`,
1348
+ "data-slot": "wallet-list-element",
1349
+ "data-variant": "grid",
1350
+ children: displayWallets.map((wallet) => renderWallet ? /* @__PURE__ */ jsx(React.Fragment, { children: renderWallet({
1351
+ wallet,
1352
+ select: () => handleSelect(wallet.name),
1353
+ connecting
1354
+ }) }, wallet.name) : /* @__PURE__ */ jsxs(
1355
+ "button",
1356
+ {
1357
+ type: "button",
1358
+ className: "ck-wallet-list-item ck-wallet-list-item--grid",
1359
+ onClick: () => handleSelect(wallet.name),
1360
+ disabled: connecting || !wallet.installed && installedOnly,
1361
+ "data-slot": "wallet-list-item",
1362
+ "data-wallet": wallet.name,
1363
+ "data-installed": wallet.installed,
1364
+ children: [
1365
+ /* @__PURE__ */ jsx("div", { className: "ck-wallet-list-item-icon", "data-slot": "wallet-list-item-icon", children: wallet.icon ? /* @__PURE__ */ jsx("img", { src: wallet.icon, alt: wallet.name }) : walletIcon }),
1366
+ /* @__PURE__ */ jsx("span", { className: "ck-wallet-list-item-name", "data-slot": "wallet-list-item-name", children: wallet.name }),
1367
+ showStatus && !wallet.installed && /* @__PURE__ */ jsx("span", { className: "ck-wallet-list-item-status", "data-slot": "wallet-list-item-status", children: "Not installed" })
1368
+ ]
1369
+ },
1370
+ wallet.name
1371
+ ))
1372
+ }
1373
+ ) : variant === "compact" ? /* @__PURE__ */ jsx(
1374
+ "div",
1375
+ {
1376
+ className: `ck-wallet-list-block ck-wallet-list-block--compact ${className || ""}`,
1377
+ "data-slot": "wallet-list-element",
1378
+ "data-variant": "compact",
1379
+ children: displayWallets.map((wallet) => renderWallet ? /* @__PURE__ */ jsx(React.Fragment, { children: renderWallet({
1380
+ wallet,
1381
+ select: () => handleSelect(wallet.name),
1382
+ connecting
1383
+ }) }, wallet.name) : /* @__PURE__ */ jsxs(
1384
+ "button",
1385
+ {
1386
+ type: "button",
1387
+ className: "ck-wallet-list-item ck-wallet-list-item--compact",
1388
+ onClick: () => handleSelect(wallet.name),
1389
+ disabled: connecting || !wallet.installed && installedOnly,
1390
+ "data-slot": "wallet-list-item",
1391
+ "data-wallet": wallet.name,
1392
+ "data-installed": wallet.installed,
1393
+ children: [
1394
+ /* @__PURE__ */ jsx("div", { className: "ck-wallet-list-item-icon", "data-slot": "wallet-list-item-icon", children: wallet.icon ? /* @__PURE__ */ jsx("img", { src: wallet.icon, alt: wallet.name }) : walletIcon }),
1395
+ /* @__PURE__ */ jsx("span", { className: "ck-wallet-list-item-name", "data-slot": "wallet-list-item-name", children: wallet.name })
1396
+ ]
1397
+ },
1398
+ wallet.name
1399
+ ))
1400
+ }
1401
+ ) : /* @__PURE__ */ jsx(
1402
+ "div",
1403
+ {
1404
+ className: `ck-wallet-list-block ck-wallet-list-block--list ${className || ""}`,
1405
+ "data-slot": "wallet-list-element",
1406
+ "data-variant": "list",
1407
+ children: displayWallets.map((wallet) => renderWallet ? /* @__PURE__ */ jsx(React.Fragment, { children: renderWallet({
1408
+ wallet,
1409
+ select: () => handleSelect(wallet.name),
1410
+ connecting
1411
+ }) }, wallet.name) : /* @__PURE__ */ jsxs(
1412
+ "button",
1413
+ {
1414
+ type: "button",
1415
+ className: "ck-wallet-list-item ck-wallet-list-item--list",
1416
+ onClick: () => handleSelect(wallet.name),
1417
+ disabled: connecting || !wallet.installed && installedOnly,
1418
+ "data-slot": "wallet-list-item",
1419
+ "data-wallet": wallet.name,
1420
+ "data-installed": wallet.installed,
1421
+ children: [
1422
+ /* @__PURE__ */ jsx("div", { className: "ck-wallet-list-item-icon", "data-slot": "wallet-list-item-icon", children: wallet.icon ? /* @__PURE__ */ jsx("img", { src: wallet.icon, alt: wallet.name }) : walletIcon }),
1423
+ /* @__PURE__ */ jsxs("div", { className: "ck-wallet-list-item-info", "data-slot": "wallet-list-item-info", children: [
1424
+ /* @__PURE__ */ jsx("span", { className: "ck-wallet-list-item-name", "data-slot": "wallet-list-item-name", children: wallet.name }),
1425
+ showStatus && /* @__PURE__ */ jsx(
1426
+ "span",
1427
+ {
1428
+ className: "ck-wallet-list-item-status",
1429
+ "data-slot": "wallet-list-item-status",
1430
+ "data-installed": wallet.installed,
1431
+ children: wallet.installed ? "Detected" : "Not installed"
1432
+ }
1433
+ )
1434
+ ] }),
1435
+ /* @__PURE__ */ jsx(
1436
+ "svg",
1437
+ {
1438
+ width: "16",
1439
+ height: "16",
1440
+ viewBox: "0 0 24 24",
1441
+ fill: "none",
1442
+ stroke: "currentColor",
1443
+ strokeWidth: "2",
1444
+ strokeLinecap: "round",
1445
+ strokeLinejoin: "round",
1446
+ className: "ck-wallet-list-item-arrow",
1447
+ "data-slot": "wallet-list-item-arrow",
1448
+ children: /* @__PURE__ */ jsx("polyline", { points: "9 18 15 12 9 6" })
1449
+ }
1450
+ )
1451
+ ]
1452
+ },
1453
+ wallet.name
1454
+ ))
1455
+ }
1456
+ );
1457
+ }
1458
+ WalletListElement.displayName = "WalletListElement";
1459
+ function BalanceElement({
1460
+ showSol = true,
1461
+ showTokens = false,
1462
+ tokenCount = 3,
1463
+ className,
1464
+ variant = "compact",
1465
+ showRefresh = false,
1466
+ showSkeleton = true,
1467
+ render
1468
+ }) {
1469
+ let { solBalance, formattedSol, tokens, isLoading, error, refetch } = useBalance();
1470
+ if (render)
1471
+ return /* @__PURE__ */ jsx(Fragment, { children: render({ solBalance, formattedSol, tokens, isLoading, error, refetch }) });
1472
+ let displayTokens = tokens.slice(0, tokenCount), refreshIcon = /* @__PURE__ */ jsxs(
1473
+ "svg",
1474
+ {
1475
+ width: "14",
1476
+ height: "14",
1477
+ viewBox: "0 0 24 24",
1478
+ fill: "none",
1479
+ stroke: "currentColor",
1480
+ strokeWidth: "2",
1481
+ strokeLinecap: "round",
1482
+ strokeLinejoin: "round",
1483
+ className: `ck-block-icon ${isLoading ? "ck-block-icon--spinning" : ""}`,
1484
+ "data-slot": "balance-element-refresh-icon",
1485
+ children: [
1486
+ /* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }),
1487
+ /* @__PURE__ */ jsx("path", { d: "M3 3v5h5" }),
1488
+ /* @__PURE__ */ jsx("path", { d: "M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16" }),
1489
+ /* @__PURE__ */ jsx("path", { d: "M16 16h5v5" })
1490
+ ]
1491
+ }
1492
+ );
1493
+ return isLoading && showSkeleton && solBalance === 0 ? /* @__PURE__ */ jsx(
1494
+ "div",
1495
+ {
1496
+ className: `ck-balance-block ck-balance-block--${variant} ck-balance-block--loading ${className || ""}`,
1497
+ "data-slot": "balance-element",
1498
+ "data-variant": variant,
1499
+ "data-loading": "true",
1500
+ children: /* @__PURE__ */ jsxs("div", { className: "ck-balance-block-skeleton", "data-slot": "balance-element-skeleton", children: [
1501
+ /* @__PURE__ */ jsx("div", { className: "ck-skeleton ck-skeleton--text" }),
1502
+ showTokens && /* @__PURE__ */ jsxs(Fragment, { children: [
1503
+ /* @__PURE__ */ jsx("div", { className: "ck-skeleton ck-skeleton--text ck-skeleton--short" }),
1504
+ /* @__PURE__ */ jsx("div", { className: "ck-skeleton ck-skeleton--text ck-skeleton--short" })
1505
+ ] })
1506
+ ] })
1507
+ }
1508
+ ) : error ? /* @__PURE__ */ jsxs(
1509
+ "div",
1510
+ {
1511
+ className: `ck-balance-block ck-balance-block--${variant} ck-balance-block--error ${className || ""}`,
1512
+ "data-slot": "balance-element",
1513
+ "data-variant": variant,
1514
+ "data-error": "true",
1515
+ children: [
1516
+ /* @__PURE__ */ jsx("span", { className: "ck-balance-block-error", "data-slot": "balance-element-error", children: "Failed to load balance" }),
1517
+ showRefresh && /* @__PURE__ */ jsx(
1518
+ "button",
1519
+ {
1520
+ type: "button",
1521
+ className: "ck-balance-block-refresh",
1522
+ onClick: () => refetch(),
1523
+ "data-slot": "balance-element-refresh",
1524
+ children: refreshIcon
1525
+ }
1526
+ )
1527
+ ]
1528
+ }
1529
+ ) : variant === "inline" ? /* @__PURE__ */ jsxs(
1530
+ "div",
1531
+ {
1532
+ className: `ck-balance-block ck-balance-block--inline ${className || ""}`,
1533
+ "data-slot": "balance-element",
1534
+ "data-variant": "inline",
1535
+ children: [
1536
+ showSol && /* @__PURE__ */ jsx("span", { className: "ck-balance-block-sol", "data-slot": "balance-element-sol", children: formattedSol }),
1537
+ showRefresh && /* @__PURE__ */ jsx(
1538
+ "button",
1539
+ {
1540
+ type: "button",
1541
+ className: "ck-balance-block-refresh",
1542
+ onClick: () => refetch(),
1543
+ disabled: isLoading,
1544
+ "data-slot": "balance-element-refresh",
1545
+ children: refreshIcon
1546
+ }
1547
+ )
1548
+ ]
1549
+ }
1550
+ ) : variant === "expanded" ? /* @__PURE__ */ jsxs(
1551
+ "div",
1552
+ {
1553
+ className: `ck-balance-block ck-balance-block--expanded ${className || ""}`,
1554
+ "data-slot": "balance-element",
1555
+ "data-variant": "expanded",
1556
+ children: [
1557
+ showSol && /* @__PURE__ */ jsxs("div", { className: "ck-balance-block-sol-section", "data-slot": "balance-element-sol-section", children: [
1558
+ /* @__PURE__ */ jsx("span", { className: "ck-balance-block-label", "data-slot": "balance-element-label", children: "SOL Balance" }),
1559
+ /* @__PURE__ */ jsx("span", { className: "ck-balance-block-sol", "data-slot": "balance-element-sol", children: formattedSol })
1560
+ ] }),
1561
+ showTokens && displayTokens.length > 0 && /* @__PURE__ */ jsxs("div", { className: "ck-balance-block-tokens-section", "data-slot": "balance-element-tokens-section", children: [
1562
+ /* @__PURE__ */ jsxs("span", { className: "ck-balance-block-label", "data-slot": "balance-element-label", children: [
1563
+ "Tokens (",
1564
+ tokens.length,
1565
+ ")"
1566
+ ] }),
1567
+ /* @__PURE__ */ jsxs("div", { className: "ck-balance-block-tokens", "data-slot": "balance-element-tokens", children: [
1568
+ displayTokens.map((token) => /* @__PURE__ */ jsxs(
1569
+ "div",
1570
+ {
1571
+ className: "ck-balance-block-token",
1572
+ "data-slot": "balance-element-token",
1573
+ children: [
1574
+ token.logo && /* @__PURE__ */ jsx(
1575
+ "img",
1576
+ {
1577
+ src: token.logo,
1578
+ alt: token.symbol || "Token",
1579
+ className: "ck-balance-block-token-logo",
1580
+ "data-slot": "balance-element-token-logo"
1581
+ }
1582
+ ),
1583
+ /* @__PURE__ */ jsxs(
1584
+ "span",
1585
+ {
1586
+ className: "ck-balance-block-token-info",
1587
+ "data-slot": "balance-element-token-info",
1588
+ children: [
1589
+ /* @__PURE__ */ jsx(
1590
+ "span",
1591
+ {
1592
+ className: "ck-balance-block-token-symbol",
1593
+ "data-slot": "balance-element-token-symbol",
1594
+ children: token.symbol || token.mint.slice(0, 4) + "..." + token.mint.slice(-4)
1595
+ }
1596
+ ),
1597
+ /* @__PURE__ */ jsx(
1598
+ "span",
1599
+ {
1600
+ className: "ck-balance-block-token-amount",
1601
+ "data-slot": "balance-element-token-amount",
1602
+ children: token.formatted
1603
+ }
1604
+ )
1605
+ ]
1606
+ }
1607
+ )
1608
+ ]
1609
+ },
1610
+ token.mint
1611
+ )),
1612
+ tokens.length > tokenCount && /* @__PURE__ */ jsxs("div", { className: "ck-balance-block-more", "data-slot": "balance-element-more", children: [
1613
+ "+",
1614
+ tokens.length - tokenCount,
1615
+ " more"
1616
+ ] })
1617
+ ] })
1618
+ ] }),
1619
+ showRefresh && /* @__PURE__ */ jsxs(
1620
+ "button",
1621
+ {
1622
+ type: "button",
1623
+ className: "ck-balance-block-refresh",
1624
+ onClick: () => refetch(),
1625
+ disabled: isLoading,
1626
+ "data-slot": "balance-element-refresh",
1627
+ children: [
1628
+ refreshIcon,
1629
+ /* @__PURE__ */ jsx("span", { children: "Refresh" })
1630
+ ]
1631
+ }
1632
+ )
1633
+ ]
1634
+ }
1635
+ ) : /* @__PURE__ */ jsxs(
1636
+ "div",
1637
+ {
1638
+ className: `ck-balance-block ck-balance-block--compact ${className || ""}`,
1639
+ "data-slot": "balance-element",
1640
+ "data-variant": "compact",
1641
+ children: [
1642
+ showSol && /* @__PURE__ */ jsx("span", { className: "ck-balance-block-sol", "data-slot": "balance-element-sol", children: formattedSol }),
1643
+ showTokens && displayTokens.length > 0 && /* @__PURE__ */ jsxs("span", { className: "ck-balance-block-token-count", "data-slot": "balance-element-token-count", children: [
1644
+ "+",
1645
+ tokens.length,
1646
+ " tokens"
1647
+ ] }),
1648
+ showRefresh && /* @__PURE__ */ jsx(
1649
+ "button",
1650
+ {
1651
+ type: "button",
1652
+ className: "ck-balance-block-refresh",
1653
+ onClick: () => refetch(),
1654
+ disabled: isLoading,
1655
+ "data-slot": "balance-element-refresh",
1656
+ children: refreshIcon
1657
+ }
1658
+ )
1659
+ ]
1660
+ }
1661
+ );
1662
+ }
1663
+ BalanceElement.displayName = "BalanceElement";
1664
+ function TransactionHistoryElement({
1665
+ limit = 5,
1666
+ showStatus = true,
1667
+ showTime = true,
1668
+ className,
1669
+ variant = "list",
1670
+ showLoadMore = false,
1671
+ showSkeleton = true,
1672
+ render,
1673
+ renderItem
1674
+ }) {
1675
+ let { transactions, isLoading, error, hasMore, loadMore, refetch } = useTransactions({ limit });
1676
+ if (render)
1677
+ return /* @__PURE__ */ jsx(Fragment, { children: render({ transactions, isLoading, error, hasMore, loadMore, refetch }) });
1678
+ let statusIcon = (status) => /* @__PURE__ */ jsx(
1679
+ "svg",
1680
+ {
1681
+ width: "12",
1682
+ height: "12",
1683
+ viewBox: "0 0 24 24",
1684
+ fill: "none",
1685
+ stroke: "currentColor",
1686
+ strokeWidth: "2",
1687
+ strokeLinecap: "round",
1688
+ strokeLinejoin: "round",
1689
+ className: `ck-tx-status-icon ck-tx-status-icon--${status}`,
1690
+ "data-slot": "tx-status-icon",
1691
+ "data-status": status,
1692
+ children: status === "success" ? /* @__PURE__ */ jsx("polyline", { points: "20 6 9 17 4 12" }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1693
+ /* @__PURE__ */ jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1694
+ /* @__PURE__ */ jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1695
+ ] })
1696
+ }
1697
+ ), externalLinkIcon = /* @__PURE__ */ jsxs(
1698
+ "svg",
1699
+ {
1700
+ width: "12",
1701
+ height: "12",
1702
+ viewBox: "0 0 24 24",
1703
+ fill: "none",
1704
+ stroke: "currentColor",
1705
+ strokeWidth: "2",
1706
+ strokeLinecap: "round",
1707
+ strokeLinejoin: "round",
1708
+ className: "ck-block-icon",
1709
+ "data-slot": "tx-external-link-icon",
1710
+ children: [
1711
+ /* @__PURE__ */ jsx("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }),
1712
+ /* @__PURE__ */ jsx("polyline", { points: "15 3 21 3 21 9" }),
1713
+ /* @__PURE__ */ jsx("line", { x1: "10", y1: "14", x2: "21", y2: "3" })
1714
+ ]
1715
+ }
1716
+ );
1717
+ if (isLoading && showSkeleton && transactions.length === 0)
1718
+ return /* @__PURE__ */ jsx(
1719
+ "div",
1720
+ {
1721
+ className: `ck-tx-history-block ck-tx-history-block--${variant} ck-tx-history-block--loading ${className || ""}`,
1722
+ "data-slot": "tx-history-element",
1723
+ "data-variant": variant,
1724
+ "data-loading": "true",
1725
+ children: /* @__PURE__ */ jsx("div", { className: "ck-tx-history-skeleton", "data-slot": "tx-history-skeleton", children: Array.from({ length: Math.min(limit, 3) }).map((_, i) => /* @__PURE__ */ jsx("div", { className: "ck-skeleton ck-skeleton--tx" }, i)) })
1726
+ }
1727
+ );
1728
+ if (error)
1729
+ return /* @__PURE__ */ jsxs(
1730
+ "div",
1731
+ {
1732
+ className: `ck-tx-history-block ck-tx-history-block--${variant} ck-tx-history-block--error ${className || ""}`,
1733
+ "data-slot": "tx-history-element",
1734
+ "data-variant": variant,
1735
+ "data-error": "true",
1736
+ children: [
1737
+ /* @__PURE__ */ jsx("span", { className: "ck-tx-history-error", "data-slot": "tx-history-error", children: "Failed to load transactions" }),
1738
+ /* @__PURE__ */ jsx(
1739
+ "button",
1740
+ {
1741
+ type: "button",
1742
+ className: "ck-tx-history-retry",
1743
+ onClick: () => refetch(),
1744
+ "data-slot": "tx-history-retry",
1745
+ children: "Retry"
1746
+ }
1747
+ )
1748
+ ]
1749
+ }
1750
+ );
1751
+ if (transactions.length === 0)
1752
+ return /* @__PURE__ */ jsx(
1753
+ "div",
1754
+ {
1755
+ className: `ck-tx-history-block ck-tx-history-block--${variant} ck-tx-history-block--empty ${className || ""}`,
1756
+ "data-slot": "tx-history-element",
1757
+ "data-variant": variant,
1758
+ "data-empty": "true",
1759
+ children: /* @__PURE__ */ jsx("span", { className: "ck-tx-history-empty", "data-slot": "tx-history-empty", children: "No transactions yet" })
1760
+ }
1761
+ );
1762
+ let itemRenderer = renderItem || ((tx) => /* @__PURE__ */ jsxs(
1763
+ "a",
1764
+ {
1765
+ href: tx.explorerUrl,
1766
+ target: "_blank",
1767
+ rel: "noopener noreferrer",
1768
+ className: "ck-tx-item",
1769
+ "data-slot": "tx-item",
1770
+ "data-status": tx.status,
1771
+ children: [
1772
+ /* @__PURE__ */ jsxs("div", { className: "ck-tx-item-main", "data-slot": "tx-item-main", children: [
1773
+ showStatus && /* @__PURE__ */ jsx(
1774
+ "span",
1775
+ {
1776
+ className: `ck-tx-status ck-tx-status--${tx.status}`,
1777
+ "data-slot": "tx-status",
1778
+ "data-status": tx.status,
1779
+ children: statusIcon(tx.status)
1780
+ }
1781
+ ),
1782
+ /* @__PURE__ */ jsxs("span", { className: "ck-tx-signature", "data-slot": "tx-signature", children: [
1783
+ tx.signature.slice(0, 8),
1784
+ "...",
1785
+ tx.signature.slice(-8)
1786
+ ] })
1787
+ ] }),
1788
+ /* @__PURE__ */ jsxs("div", { className: "ck-tx-item-meta", "data-slot": "tx-item-meta", children: [
1789
+ showTime && /* @__PURE__ */ jsxs("span", { className: "ck-tx-time", "data-slot": "tx-time", children: [
1790
+ tx.formattedDate,
1791
+ " ",
1792
+ tx.formattedTime
1793
+ ] }),
1794
+ externalLinkIcon
1795
+ ] })
1796
+ ]
1797
+ },
1798
+ tx.signature
1799
+ ));
1800
+ return /* @__PURE__ */ jsxs(
1801
+ "div",
1802
+ {
1803
+ className: `ck-tx-history-block ck-tx-history-block--${variant} ${className || ""}`,
1804
+ "data-slot": "tx-history-element",
1805
+ "data-variant": variant,
1806
+ children: [
1807
+ variant === "expanded" && /* @__PURE__ */ jsxs("div", { className: "ck-tx-history-header", "data-slot": "tx-history-header", children: [
1808
+ /* @__PURE__ */ jsx("span", { className: "ck-tx-history-title", "data-slot": "tx-history-title", children: "Recent Transactions" }),
1809
+ /* @__PURE__ */ jsx("span", { className: "ck-tx-history-count", "data-slot": "tx-history-count", children: transactions.length })
1810
+ ] }),
1811
+ /* @__PURE__ */ jsx("div", { className: "ck-tx-history-list", "data-slot": "tx-history-list", children: transactions.map(itemRenderer) }),
1812
+ showLoadMore && hasMore && /* @__PURE__ */ jsx(
1813
+ "button",
1814
+ {
1815
+ type: "button",
1816
+ className: "ck-tx-history-load-more",
1817
+ onClick: () => loadMore(),
1818
+ disabled: isLoading,
1819
+ "data-slot": "tx-history-load-more",
1820
+ children: isLoading ? "Loading..." : "Load more"
1821
+ }
1822
+ )
1823
+ ]
1824
+ }
1825
+ );
1826
+ }
1827
+ TransactionHistoryElement.displayName = "TransactionHistoryElement";
1828
+ function TokenListElement({
1829
+ limit = 10,
1830
+ showValue = false,
1831
+ className,
1832
+ variant = "compact",
1833
+ showRefresh = false,
1834
+ showSkeleton = true,
1835
+ render,
1836
+ renderItem
1837
+ }) {
1838
+ let { tokens, isLoading, error, refetch, totalAccounts } = useTokens();
1839
+ if (render)
1840
+ return /* @__PURE__ */ jsx(Fragment, { children: render({ tokens, isLoading, error, refetch, totalAccounts }) });
1841
+ let displayTokens = tokens.slice(0, limit), refreshIcon = /* @__PURE__ */ jsxs(
1842
+ "svg",
1843
+ {
1844
+ width: "14",
1845
+ height: "14",
1846
+ viewBox: "0 0 24 24",
1847
+ fill: "none",
1848
+ stroke: "currentColor",
1849
+ strokeWidth: "2",
1850
+ strokeLinecap: "round",
1851
+ strokeLinejoin: "round",
1852
+ className: `ck-block-icon ${isLoading ? "ck-block-icon--spinning" : ""}`,
1853
+ "data-slot": "token-list-refresh-icon",
1854
+ children: [
1855
+ /* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }),
1856
+ /* @__PURE__ */ jsx("path", { d: "M3 3v5h5" }),
1857
+ /* @__PURE__ */ jsx("path", { d: "M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16" }),
1858
+ /* @__PURE__ */ jsx("path", { d: "M16 16h5v5" })
1859
+ ]
1860
+ }
1861
+ ), tokenIcon = /* @__PURE__ */ jsxs(
1862
+ "svg",
1863
+ {
1864
+ width: "20",
1865
+ height: "20",
1866
+ viewBox: "0 0 24 24",
1867
+ fill: "none",
1868
+ stroke: "currentColor",
1869
+ strokeWidth: "2",
1870
+ strokeLinecap: "round",
1871
+ strokeLinejoin: "round",
1872
+ className: "ck-token-placeholder-icon",
1873
+ "data-slot": "token-placeholder-icon",
1874
+ children: [
1875
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
1876
+ /* @__PURE__ */ jsx("path", { d: "M12 6v12" }),
1877
+ /* @__PURE__ */ jsx("path", { d: "M6 12h12" })
1878
+ ]
1879
+ }
1880
+ );
1881
+ if (isLoading && showSkeleton && tokens.length === 0)
1882
+ return /* @__PURE__ */ jsx(
1883
+ "div",
1884
+ {
1885
+ className: `ck-token-list-block ck-token-list-block--${variant} ck-token-list-block--loading ${className || ""}`,
1886
+ "data-slot": "token-list-element",
1887
+ "data-variant": variant,
1888
+ "data-loading": "true",
1889
+ children: /* @__PURE__ */ jsx("div", { className: "ck-token-list-skeleton", "data-slot": "token-list-skeleton", children: Array.from({ length: Math.min(limit, 3) }).map((_, i) => /* @__PURE__ */ jsx("div", { className: "ck-skeleton ck-skeleton--token" }, i)) })
1890
+ }
1891
+ );
1892
+ if (error)
1893
+ return /* @__PURE__ */ jsxs(
1894
+ "div",
1895
+ {
1896
+ className: `ck-token-list-block ck-token-list-block--${variant} ck-token-list-block--error ${className || ""}`,
1897
+ "data-slot": "token-list-element",
1898
+ "data-variant": variant,
1899
+ "data-error": "true",
1900
+ children: [
1901
+ /* @__PURE__ */ jsx("span", { className: "ck-token-list-error", "data-slot": "token-list-error", children: "Failed to load tokens" }),
1902
+ /* @__PURE__ */ jsx(
1903
+ "button",
1904
+ {
1905
+ type: "button",
1906
+ className: "ck-token-list-retry",
1907
+ onClick: () => refetch(),
1908
+ "data-slot": "token-list-retry",
1909
+ children: "Retry"
1910
+ }
1911
+ )
1912
+ ]
1913
+ }
1914
+ );
1915
+ if (tokens.length === 0)
1916
+ return /* @__PURE__ */ jsx(
1917
+ "div",
1918
+ {
1919
+ className: `ck-token-list-block ck-token-list-block--${variant} ck-token-list-block--empty ${className || ""}`,
1920
+ "data-slot": "token-list-element",
1921
+ "data-variant": variant,
1922
+ "data-empty": "true",
1923
+ children: /* @__PURE__ */ jsx("span", { className: "ck-token-list-empty", "data-slot": "token-list-empty", children: "No tokens found" })
1924
+ }
1925
+ );
1926
+ let itemRenderer = renderItem || ((token) => /* @__PURE__ */ jsxs("div", { className: "ck-token-item", "data-slot": "token-item", children: [
1927
+ /* @__PURE__ */ jsx("div", { className: "ck-token-item-icon", "data-slot": "token-item-icon", children: token.logo ? /* @__PURE__ */ jsx(
1928
+ "img",
1929
+ {
1930
+ src: token.logo,
1931
+ alt: token.symbol || "Token",
1932
+ className: "ck-token-logo",
1933
+ "data-slot": "token-logo",
1934
+ onError: (e) => {
1935
+ e.currentTarget.style.display = "none";
1936
+ }
1937
+ }
1938
+ ) : tokenIcon }),
1939
+ /* @__PURE__ */ jsxs("div", { className: "ck-token-item-info", "data-slot": "token-item-info", children: [
1940
+ /* @__PURE__ */ jsx("span", { className: "ck-token-symbol", "data-slot": "token-symbol", children: token.symbol || token.mint.slice(0, 4) + "..." + token.mint.slice(-4) }),
1941
+ token.name && /* @__PURE__ */ jsx("span", { className: "ck-token-name", "data-slot": "token-name", children: token.name })
1942
+ ] }),
1943
+ /* @__PURE__ */ jsxs("div", { className: "ck-token-item-balance", "data-slot": "token-item-balance", children: [
1944
+ /* @__PURE__ */ jsx("span", { className: "ck-token-amount", "data-slot": "token-amount", children: token.formatted }),
1945
+ showValue && /* @__PURE__ */ jsx("span", { className: "ck-token-value", "data-slot": "token-value", children: "-" })
1946
+ ] })
1947
+ ] }, token.mint));
1948
+ return /* @__PURE__ */ jsxs(
1949
+ "div",
1950
+ {
1951
+ className: `ck-token-list-block ck-token-list-block--${variant} ${className || ""}`,
1952
+ "data-slot": "token-list-element",
1953
+ "data-variant": variant,
1954
+ children: [
1955
+ variant === "expanded" && /* @__PURE__ */ jsxs("div", { className: "ck-token-list-header", "data-slot": "token-list-header", children: [
1956
+ /* @__PURE__ */ jsx("span", { className: "ck-token-list-title", "data-slot": "token-list-title", children: "Tokens" }),
1957
+ /* @__PURE__ */ jsx("span", { className: "ck-token-list-count", "data-slot": "token-list-count", children: totalAccounts }),
1958
+ showRefresh && /* @__PURE__ */ jsx(
1959
+ "button",
1960
+ {
1961
+ type: "button",
1962
+ className: "ck-token-list-refresh",
1963
+ onClick: () => refetch(),
1964
+ disabled: isLoading,
1965
+ "data-slot": "token-list-refresh",
1966
+ children: refreshIcon
1967
+ }
1968
+ )
1969
+ ] }),
1970
+ /* @__PURE__ */ jsx("div", { className: `ck-token-list ${variant === "grid" ? "ck-token-list--grid" : ""}`, "data-slot": "token-list", children: displayTokens.map(itemRenderer) }),
1971
+ tokens.length > limit && /* @__PURE__ */ jsxs("div", { className: "ck-token-list-more", "data-slot": "token-list-more", children: [
1972
+ "+",
1973
+ tokens.length - limit,
1974
+ " more tokens"
1975
+ ] })
1976
+ ]
1977
+ }
1978
+ );
1979
+ }
1980
+ TokenListElement.displayName = "TokenListElement";
1981
+
1982
+ export { AccountElement, BalanceElement, ClusterElement, ConnectorProvider, DisconnectElement, TokenListElement, TransactionHistoryElement, UnifiedProvider, WalletListElement, useAccount, useBalance, useCluster, useConnector, useConnectorClient, useGillSolanaClient, useGillTransactionSigner, useKitTransactionSigner, useSolanaClient, useTokens, useTransactionPreparer, useTransactionSigner, useTransactions, useWalletInfo };
1983
+ //# sourceMappingURL=chunk-U64YZRJL.mjs.map
1984
+ //# sourceMappingURL=chunk-U64YZRJL.mjs.map