@fluent.xyz/connect 0.4.0 → 0.4.1

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
@@ -1,12 +1,13 @@
1
1
  import './polyfills/buffer.js';
2
- import { toEventSelector, parseAbiItem, parseEther, defineChain, http, createPublicClient, formatUnits, isAddress, getAddress, parseUnits, BaseError, encodeFunctionData, zeroAddress, numberToHex, hexToBigInt, isHex, toHex, fallback, stringToHex, bytesToHex, HttpRequestError, erc20Abi, padHex, decodeEventLog } from 'viem';
2
+ import { parseAbi, toEventSelector, parseAbiItem, parseEther, defineChain, http, createPublicClient, formatUnits, isAddress, getAddress, parseUnits, BaseError, encodeFunctionData, zeroAddress, numberToHex, hexToBigInt, isHex, toHex, fallback, stringToHex, bytesToHex, HttpRequestError, erc20Abi, padHex, decodeEventLog } from 'viem';
3
3
  import * as React from 'react';
4
- import { createContext, forwardRef, useContext, useMemo, useState, useEffect, useCallback, useLayoutEffect, useRef, Fragment as Fragment$1 } from 'react';
4
+ import { createContext, forwardRef, useContext, useMemo, useState, useEffect, useCallback, useRef, useLayoutEffect, Fragment as Fragment$1 } from 'react';
5
5
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
+ import { estimateUserOperationGas } from 'viem/account-abstraction';
6
7
  import { toCallPolicy, CallPolicyVersion, toTimestampPolicy, CallType, ParamCondition } from '@zerodev/permissions/policies';
7
8
  export { CallType, ParamCondition } from '@zerodev/permissions/policies';
8
9
  import { privateKeyToAccount, toAccount, generatePrivateKey } from 'viem/accounts';
9
- import { usePrivy, useSignMessage, useSignTypedData, useWallets, PrivyProvider, useIdentityToken, useUser, useModalStatus, useCreateWallet, useLoginWithEmail, useLoginWithOAuth, useLoginWithPasskey, Captcha } from '@privy-io/react-auth';
10
+ import { usePrivy, useSignMessage, useSignTypedData, useWallets, PrivyProvider, useIdentityToken, useUser, useLinkAccount, useLoginWithSiwe, useModalStatus, useCreateWallet, useLoginWithEmail, useLoginWithOAuth, useLoginWithPasskey, Captcha } from '@privy-io/react-auth';
10
11
  import { signerToEcdsaValidator } from '@zerodev/ecdsa-validator';
11
12
  import { toPermissionValidator, serializePermissionAccount, deserializePermissionAccount } from '@zerodev/permissions';
12
13
  import { toECDSASigner } from '@zerodev/permissions/signers';
@@ -17,21 +18,22 @@ import { clsx } from 'clsx';
17
18
  import { twMerge } from 'tailwind-merge';
18
19
  import { Button as Button$1 } from '@base-ui/react/button';
19
20
  import { cva } from 'class-variance-authority';
20
- import { XIcon, House, Medal, RefreshCw, ChevronLeft, ExternalLink, Copy, Settings, LogOut, Loader2, ChevronDownIcon, CheckIcon, Layers, AlertTriangle, Trash2, Plus, Loader2Icon, ChevronUpIcon, X, Wallet, Check, CircleHelp, LogIn, Send, RotateCw, KeyRound, Mail, CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon } from 'lucide-react';
21
+ import { XIcon, RefreshCw, ChevronLeft, ExternalLink, Copy, Settings, LogOut, Loader2, ChevronDownIcon, CheckIcon, AlertTriangle, Layers, Trash2, Plus, Loader2Icon, ChevronUpIcon, CircleHelp, X, Wallet, Check, LogIn, Send, RotateCw, KeyRound, Mail, CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon } from 'lucide-react';
21
22
  import { WagmiAdapter } from '@reown/appkit-adapter-wagmi';
22
23
  import { createAppKit, useAppKit } from '@reown/appkit/react';
23
24
  import { QueryClient, QueryClientContext, QueryClientProvider, useInfiniteQuery, useQuery } from '@tanstack/react-query';
24
25
  import { WagmiContext, WagmiProvider, useAccount, useDisconnect, useWalletClient, useSwitchChain, useConnect, usePublicClient, useBalance, useReadContract, useWriteContract, useWaitForTransactionReceipt } from 'wagmi';
26
+ import { hydrate } from '@wagmi/core';
27
+ import { reconnect } from 'wagmi/actions';
25
28
  import { coinbaseWallet, baseAccount } from 'wagmi/connectors';
26
29
  import { Dialog as Dialog$1 } from '@base-ui/react/dialog';
27
30
  import { Select as Select$1 } from '@base-ui/react/select';
28
- import { openSwapperModal } from '@swapper-finance/deposit-sdk';
31
+ import { Tooltip as Tooltip$1 } from '@base-ui/react/tooltip';
29
32
  import { Separator as Separator$1 } from '@base-ui/react/separator';
30
33
  import { Switch as Switch$1 } from '@base-ui/react/switch';
31
34
  import { Tabs as Tabs$1 } from '@base-ui/react/tabs';
32
- import { Tooltip as Tooltip$1 } from '@base-ui/react/tooltip';
33
35
  import { RainbowKitProvider, darkTheme, useConnectModal } from '@rainbow-me/rainbowkit';
34
- import '@rainbow-me/rainbowkit/styles.css';
36
+ import { createPortal } from 'react-dom';
35
37
  import { Drawer as Drawer$1 } from '@base-ui/react/drawer';
36
38
 
37
39
  var __defProp = Object.defineProperty;
@@ -4732,8 +4734,8 @@ var fluentTestnetTokenDefaults = {
4732
4734
  chainId: 20994,
4733
4735
  symbol: "USDnr",
4734
4736
  name: "USDnr",
4735
- decimals: 18,
4736
- address: "0x092AE7564C6611a114C20C6df766B5B35A52334A",
4737
+ decimals: 6,
4738
+ address: "0x279a6DC6354374473f6f3CFB3999e6C2e146f8a1",
4737
4739
  gasPriority: 2
4738
4740
  },
4739
4741
  BLEND: {
@@ -4758,7 +4760,7 @@ var fluentMainnetTokenDefaults = {
4758
4760
  chainId: 25363,
4759
4761
  symbol: "USDnr",
4760
4762
  name: "USDnr",
4761
- // `decimals()` on 0xD48e… returns 6 — the testnet mock is 18, mainnet is not.
4763
+ // `decimals()` on 0xD48e… returns 6, as it does on the testnet USDnr.
4762
4764
  decimals: 6,
4763
4765
  address: "0xD48e565561416dE59DA1050ED70b8d75e8eF28f9",
4764
4766
  gasPriority: 2
@@ -5218,6 +5220,20 @@ function getFluentGasPaymentEthValue(params) {
5218
5220
  tier: getFluentGasPaymentValueTier(ethValueWei)
5219
5221
  };
5220
5222
  }
5223
+ function deriveFluentGasEthRates(params) {
5224
+ const native = params.tokens.find(isFluentNativeToken);
5225
+ const ethPrice = native ? params.usdPrices[native.identity] : void 0;
5226
+ if (!ethPrice || !Number.isFinite(ethPrice)) return { ...params.configured };
5227
+ const derived = {};
5228
+ for (const token of params.tokens) {
5229
+ const price = params.usdPrices[token.identity];
5230
+ if (price === void 0 || !Number.isFinite(price)) continue;
5231
+ const rate = price / ethPrice;
5232
+ if (!Number.isFinite(rate) || rate <= 0) continue;
5233
+ derived[token.symbol] = rate.toFixed(18);
5234
+ }
5235
+ return { ...derived, ...params.configured };
5236
+ }
5221
5237
  function getFluentGasPaymentValueTier(ethValueWei) {
5222
5238
  if (ethValueWei > parseUnits("0.001", 18)) return "green";
5223
5239
  if (ethValueWei > parseUnits("0.0001", 18)) return "yellow";
@@ -5374,8 +5390,30 @@ var FLUENT_CONNECT_PRIVY_CONFIG = {
5374
5390
  landingHeader: "",
5375
5391
  loginMessage: "Connect X to start building your Fluent reputation \u2014 badges, tiers, and perks.",
5376
5392
  showWalletLoginFirst: false,
5377
- walletList: ["detected_wallets", "metamask", "coinbase_wallet", "rainbow", "wallet_connect"]
5393
+ walletList: ["detected_wallets", "metamask", "coinbase_wallet", "rainbow"]
5378
5394
  },
5395
+ /**
5396
+ * WalletConnect in this widget belongs to Reown/AppKit, which builds it once
5397
+ * per page (`appKitByKey` in `widget/reownAppKit.tsx`). Privy builds its own
5398
+ * on every `PrivyProvider` mount and never tears it down, so with Quick sign
5399
+ * keying that provider the count of `new Core()` calls grew with every
5400
+ * toggle. Leaving the one owner that is built once is what bounds it.
5401
+ *
5402
+ * `appearance.walletList` drops `wallet_connect` for the same reason: Privy
5403
+ * filters WalletConnect-backed entries out of its own modal once this is off,
5404
+ * so naming it there would promise a route that no longer exists.
5405
+ */
5406
+ externalWallets: { walletConnect: { enabled: false } },
5407
+ /**
5408
+ * Constant on purpose, not derived from Quick sign.
5409
+ *
5410
+ * Privy resolves this once when `PrivyProvider` mounts and does not pick up a
5411
+ * later change to the `config` prop — which is why Quick sign used to key that
5412
+ * provider and rebuild everything below it. A signer that wants Privy's
5413
+ * confirmation screen asks for it per call instead (`uiOptions.showWalletUIs`,
5414
+ * which wins over this), so the provider never has to be rebuilt to change
5415
+ * its mind.
5416
+ */
5379
5417
  embeddedWallets: {
5380
5418
  createOnLogin: "users-without-wallets",
5381
5419
  showWalletUIs: false
@@ -5387,13 +5425,12 @@ function createFluentConnectPrivyConfig(options) {
5387
5425
  ...FLUENT_CONNECT_PRIVY_CONFIG,
5388
5426
  defaultChain: chain,
5389
5427
  supportedChains: [chain],
5428
+ ...options.customOAuthRedirectUrl && {
5429
+ customOAuthRedirectUrl: options.customOAuthRedirectUrl
5430
+ },
5390
5431
  appearance: {
5391
5432
  ...FLUENT_CONNECT_PRIVY_CONFIG.appearance,
5392
5433
  logo: options.logo ?? FLUENT_CONNECT_PRIVY_CONFIG.appearance?.logo
5393
- },
5394
- embeddedWallets: {
5395
- ...FLUENT_CONNECT_PRIVY_CONFIG.embeddedWallets,
5396
- showWalletUIs: options.showWalletUIs
5397
5434
  }
5398
5435
  };
5399
5436
  }
@@ -5457,8 +5494,38 @@ var FLUENT_FAMILY_TIER_PROGRESS = {
5457
5494
  C: 33,
5458
5495
  D: 0
5459
5496
  };
5497
+ var FLUENT_CONNECT_DEFAULT_AUTH_METHODS = [
5498
+ "google",
5499
+ "email",
5500
+ "passkey"
5501
+ ];
5502
+ function resolveFluentWidgetAuthMethods(enabledAuthMethods) {
5503
+ if (!enabledAuthMethods) return [...FLUENT_CONNECT_DEFAULT_AUTH_METHODS];
5504
+ const enabled = /* @__PURE__ */ new Set();
5505
+ for (const method of enabledAuthMethods) {
5506
+ if (FLUENT_CONNECT_DEFAULT_AUTH_METHODS.includes(method)) enabled.add(method);
5507
+ }
5508
+ return [...enabled];
5509
+ }
5460
5510
  var APP_ID_PATTERN = /^app_[0-9a-f]{32}$/;
5461
5511
  var APP_ID_HINT = "Pass the app_<32 hex> id from the Fluent Dashboard as appId.";
5512
+ function resolveCustomOAuthRedirectUrl(value) {
5513
+ if (value === void 0) return void 0;
5514
+ const hint = "FluentWidgetConfig.customOAuthRedirectUrl must be an absolute HTTPS URL without credentials, query parameters, or a fragment. Register the exact URL in Privy.";
5515
+ if (typeof value !== "string") throw new Error(hint);
5516
+ const redirectUrl = value.trim();
5517
+ if (!redirectUrl) return void 0;
5518
+ let url;
5519
+ try {
5520
+ url = new URL(redirectUrl);
5521
+ } catch {
5522
+ throw new Error(hint);
5523
+ }
5524
+ if (!/^https:\/\//i.test(redirectUrl) || url.protocol !== "https:" || !url.hostname || url.username || url.password || redirectUrl.includes("?") || redirectUrl.includes("#")) {
5525
+ throw new Error(hint);
5526
+ }
5527
+ return redirectUrl;
5528
+ }
5462
5529
  function resolveFluentWidgetConfig(config) {
5463
5530
  if (config.clientId !== void 0) {
5464
5531
  throw new Error(
@@ -5506,6 +5573,8 @@ function resolveFluentWidgetConfig(config) {
5506
5573
  appId,
5507
5574
  privyClientId,
5508
5575
  authMode: config.authMode ?? "hosted",
5576
+ customOAuthRedirectUrl: resolveCustomOAuthRedirectUrl(config.customOAuthRedirectUrl),
5577
+ authMethods: resolveFluentWidgetAuthMethods(config.enabledAuthMethods),
5509
5578
  authorizeUrl: endpoints.authorizeUrl,
5510
5579
  faucetEndpoint: endpoints.faucetEndpoint,
5511
5580
  eventsEndpoint: "",
@@ -5513,7 +5582,7 @@ function resolveFluentWidgetConfig(config) {
5513
5582
  sponsorshipUrl: config.sponsorshipUrl ?? endpoints.sponsorshipUrl,
5514
5583
  authTokenRenewalOffsetSeconds: config.authTokenRenewalOffsetSeconds ?? 30,
5515
5584
  disableAnalytics: config.disableAnalytics ?? false,
5516
- reconnectOnMount: config.reconnectOnMount ?? false,
5585
+ reconnectOnMount: config.reconnectOnMount,
5517
5586
  publicApiUrl: endpoints.publicApiUrl,
5518
5587
  reputationSignupUrl: endpoints.reputationSignupUrl,
5519
5588
  bridgeUrl: endpoints.bridgeUrl,
@@ -6130,6 +6199,392 @@ function createFluentBackendUserTokenStore(params) {
6130
6199
  }
6131
6200
  };
6132
6201
  }
6202
+
6203
+ // src/core/browserStorage.ts
6204
+ function resolveLocalStorage(storage) {
6205
+ if (storage !== void 0) return storage;
6206
+ try {
6207
+ return globalThis.localStorage ?? null;
6208
+ } catch {
6209
+ return null;
6210
+ }
6211
+ }
6212
+ function resolveSessionStorage(storage) {
6213
+ try {
6214
+ return globalThis.sessionStorage ?? null;
6215
+ } catch {
6216
+ return null;
6217
+ }
6218
+ }
6219
+ function readStoredValue(storage, key) {
6220
+ if (!storage) return null;
6221
+ try {
6222
+ return storage.getItem(key);
6223
+ } catch {
6224
+ return null;
6225
+ }
6226
+ }
6227
+ function writeStoredValue(storage, key, value) {
6228
+ if (!storage) return false;
6229
+ try {
6230
+ storage.setItem(key, value);
6231
+ return true;
6232
+ } catch {
6233
+ return false;
6234
+ }
6235
+ }
6236
+ function removeStoredValue(storage, key) {
6237
+ if (!storage) return false;
6238
+ try {
6239
+ storage.removeItem(key);
6240
+ return true;
6241
+ } catch {
6242
+ return false;
6243
+ }
6244
+ }
6245
+ var FLUENT_LINK_X_MARKER_KEY = "fluent:widget:link-x:v1";
6246
+ var X_LINKED_ACCOUNT_TYPE = "twitter_oauth";
6247
+ var WALLET_LINKED_ACCOUNT_TYPE = "wallet";
6248
+ var ETHEREUM_CHAIN_TYPE = "ethereum";
6249
+ var EMBEDDED_WALLET_CLIENT_TYPES = /* @__PURE__ */ new Set(["privy", "privy-v2"]);
6250
+ var EMBEDDED_CONNECTOR_TYPE = "embedded";
6251
+ var SERVICE_IDENTITY_ALREADY_LINKED = "privy_identity_already_linked";
6252
+ function readFluentXAccount(raw) {
6253
+ if (typeof raw !== "object" || raw === null) return null;
6254
+ const { id, handle, avatarUrl } = raw;
6255
+ if (typeof id !== "string" || id.length === 0) return null;
6256
+ if (typeof handle !== "string" || handle.length === 0) return null;
6257
+ if (typeof avatarUrl !== "string" || avatarUrl.length === 0) return null;
6258
+ return { id, handle, avatarUrl };
6259
+ }
6260
+ function readFluentProfile(raw) {
6261
+ if (typeof raw !== "object" || raw === null) return null;
6262
+ const { subject, appId, x } = raw;
6263
+ if (typeof subject !== "string" || subject.length === 0) return null;
6264
+ if (typeof appId !== "string" || appId.length === 0) return null;
6265
+ if (x === null) return { subject, appId, x: null };
6266
+ const account = readFluentXAccount(x);
6267
+ return account ? { subject, appId, x: account } : null;
6268
+ }
6269
+ function identityTokenHasLinkedX(token) {
6270
+ if (typeof token !== "string") return false;
6271
+ try {
6272
+ const [, body = ""] = token.split(".");
6273
+ const claims = JSON.parse(atob(body.replace(/-/g, "+").replace(/_/g, "/")));
6274
+ if (typeof claims.linked_accounts !== "string") return false;
6275
+ const accounts = JSON.parse(claims.linked_accounts);
6276
+ if (!Array.isArray(accounts)) return false;
6277
+ return accounts.some(
6278
+ (entry) => typeof entry === "object" && entry !== null && entry.type === X_LINKED_ACCOUNT_TYPE
6279
+ );
6280
+ } catch {
6281
+ return false;
6282
+ }
6283
+ }
6284
+ function privyUserHasLinkedX(linkedAccounts) {
6285
+ return Boolean(linkedAccounts?.some((account) => account.type === X_LINKED_ACCOUNT_TYPE));
6286
+ }
6287
+ function isEthereumWalletEntry(account) {
6288
+ return account.type === WALLET_LINKED_ACCOUNT_TYPE && account.chainType === ETHEREUM_CHAIN_TYPE;
6289
+ }
6290
+ function isEmbeddedWalletEntry(account) {
6291
+ return typeof account.walletClientType === "string" && EMBEDDED_WALLET_CLIENT_TYPES.has(account.walletClientType) || account.connectorType === EMBEDDED_CONNECTOR_TYPE;
6292
+ }
6293
+ function privyUserOwnsWallet(user, address) {
6294
+ if (!user || !address) return false;
6295
+ if (!Array.isArray(user.linkedAccounts)) return false;
6296
+ const wanted = address.toLowerCase();
6297
+ return user.linkedAccounts.some(
6298
+ (account) => isEthereumWalletEntry(account) && typeof account.address === "string" && account.address.toLowerCase() === wanted
6299
+ );
6300
+ }
6301
+ function privyUserHasExternalWallet(user) {
6302
+ if (!user) return false;
6303
+ if (!Array.isArray(user.linkedAccounts)) return false;
6304
+ return user.linkedAccounts.some(
6305
+ (account) => isEthereumWalletEntry(account) && !isEmbeddedWalletEntry(account)
6306
+ );
6307
+ }
6308
+ function readLinkXMarker(storage) {
6309
+ const raw = readStoredValue(storage, FLUENT_LINK_X_MARKER_KEY);
6310
+ if (raw === null) return { kind: "none" };
6311
+ const marker = parseLinkXMarker(raw);
6312
+ if (!marker) {
6313
+ removeStoredValue(storage, FLUENT_LINK_X_MARKER_KEY);
6314
+ return { kind: "invalid" };
6315
+ }
6316
+ return { kind: "marker", marker };
6317
+ }
6318
+ function parseLinkXMarker(raw) {
6319
+ let parsed;
6320
+ try {
6321
+ parsed = JSON.parse(raw);
6322
+ } catch {
6323
+ return null;
6324
+ }
6325
+ if (typeof parsed !== "object" || parsed === null) return null;
6326
+ const { started, subject } = parsed;
6327
+ if (typeof started !== "number" || !Number.isFinite(started)) return null;
6328
+ if (typeof subject !== "string" || subject.length === 0) return null;
6329
+ return { started, subject };
6330
+ }
6331
+ function writeLinkXMarker(storage, marker) {
6332
+ writeStoredValue(storage, FLUENT_LINK_X_MARKER_KEY, JSON.stringify(marker));
6333
+ }
6334
+ function clearLinkXMarker(storage) {
6335
+ removeStoredValue(storage, FLUENT_LINK_X_MARKER_KEY);
6336
+ }
6337
+ function ownsLinkXMarker(marker, subject) {
6338
+ return Boolean(marker && subject && marker.subject === subject);
6339
+ }
6340
+ function toLinkXPrivyError(code) {
6341
+ switch (code) {
6342
+ case "oauth_user_denied":
6343
+ case "exited_link_flow":
6344
+ return new FluentAuthError("user_rejected", "The user did not finish linking X.");
6345
+ case "linked_to_another_user":
6346
+ return new FluentAuthError(
6347
+ "linked_to_another_user",
6348
+ "That X account is already linked to another Fluent user."
6349
+ );
6350
+ default:
6351
+ return new FluentAuthError("link_failed", `Privy could not link X (${String(code)}).`);
6352
+ }
6353
+ }
6354
+ var LINK_X_ERROR_CODES = /* @__PURE__ */ new Set([
6355
+ "user_rejected",
6356
+ "linked_to_another_user",
6357
+ "not_authenticated",
6358
+ "hosted_not_supported",
6359
+ "bad_request",
6360
+ "link_failed"
6361
+ ]);
6362
+ var LinkXIntentDiscardedError = class extends FluentAuthError {
6363
+ constructor() {
6364
+ super(
6365
+ "link_failed",
6366
+ "A link that another user started in this tab, or a stale record of one, was discarded; nothing was linked. Call linkX() again."
6367
+ );
6368
+ this.name = "FluentAuthError";
6369
+ }
6370
+ };
6371
+ function linkXIntentDiscardedError() {
6372
+ return new LinkXIntentDiscardedError();
6373
+ }
6374
+ function isLinkXIntentDiscarded(err) {
6375
+ return err instanceof LinkXIntentDiscardedError;
6376
+ }
6377
+ function toLinkXError(err) {
6378
+ if (err instanceof FluentAuthError) {
6379
+ if (LINK_X_ERROR_CODES.has(err.code)) return err;
6380
+ return new FluentAuthError("link_failed", err.message, err.status);
6381
+ }
6382
+ if (err instanceof HttpError) {
6383
+ if (err.status === 400) return new FluentAuthError("bad_request", err.message, err.status);
6384
+ if (err.body?.code === SERVICE_IDENTITY_ALREADY_LINKED) {
6385
+ return new FluentAuthError(
6386
+ "linked_to_another_user",
6387
+ "That X account is already linked to another Fluent user.",
6388
+ err.status
6389
+ );
6390
+ }
6391
+ return new FluentAuthError("link_failed", err.message, err.status);
6392
+ }
6393
+ return new FluentAuthError("link_failed", err instanceof Error ? err.message : String(err));
6394
+ }
6395
+ async function requestLinkX(params) {
6396
+ if (params.authMode === "hosted") {
6397
+ throw new FluentAuthError(
6398
+ "hosted_not_supported",
6399
+ `linkX() needs authMode: "direct" \u2014 in hosted mode the user's Privy session lives on the authorize page, not in this page.`
6400
+ );
6401
+ }
6402
+ if (params.accountKind === "eoa") {
6403
+ if (!params.wallet) {
6404
+ throw new FluentAuthError(
6405
+ "not_authenticated",
6406
+ "The connected wallet has no signer yet; wait for the connection to finish and call linkX() again."
6407
+ );
6408
+ }
6409
+ try {
6410
+ return await linkWalletUser(params, params.wallet);
6411
+ } catch (err) {
6412
+ throw toLinkXError(err);
6413
+ }
6414
+ }
6415
+ if (params.accountKind !== "smart" || !params.subject) {
6416
+ throw new FluentAuthError("not_authenticated", "Connect a Fluent ID or an external wallet first.");
6417
+ }
6418
+ try {
6419
+ return await linkOrRedirect(params, params.subject);
6420
+ } catch (err) {
6421
+ throw toLinkXError(err);
6422
+ }
6423
+ }
6424
+ async function linkWalletUser(params, wallet) {
6425
+ const { siwe } = params;
6426
+ let session = siwe.session;
6427
+ if (session && !privyUserOwnsWallet(session, wallet.address)) {
6428
+ if (siwe.fluentSessionUserId !== void 0 && siwe.fluentSessionUserId === session.id) {
6429
+ throw new FluentAuthError(
6430
+ "link_failed",
6431
+ "A Fluent ID is signed in on this page. Linking X for the connected external wallet would sign it out; disconnect the Fluent ID first, or link X as the Fluent ID."
6432
+ );
6433
+ }
6434
+ await siwe.logout();
6435
+ session = null;
6436
+ }
6437
+ let subject;
6438
+ let readIdentityToken = params.readIdentityToken;
6439
+ if (session) {
6440
+ subject = session.id;
6441
+ } else {
6442
+ subject = (await signWalletInWithSiwe(wallet, siwe)).id;
6443
+ readIdentityToken = () => null;
6444
+ }
6445
+ await mintWalletFluentToken(params);
6446
+ return linkOrRedirect({ ...params, readIdentityToken }, subject);
6447
+ }
6448
+ async function signWalletInWithSiwe(wallet, siwe) {
6449
+ const message2 = await siwe.generateSiweMessage({
6450
+ address: getAddress(wallet.address),
6451
+ chainId: `eip155:${wallet.chainId}`
6452
+ });
6453
+ let signature;
6454
+ try {
6455
+ signature = await wallet.signMessage(message2);
6456
+ } catch (err) {
6457
+ if (isSignatureRefusal(err)) {
6458
+ throw new FluentAuthError(
6459
+ "user_rejected",
6460
+ "The user did not sign the message that signs the wallet in to Privy."
6461
+ );
6462
+ }
6463
+ throw err;
6464
+ }
6465
+ const user = await siwe.loginWithSiwe({ message: message2, signature });
6466
+ if (!isPrivyUser(user) || !privyUserOwnsWallet(user, wallet.address)) {
6467
+ let signedOut = true;
6468
+ try {
6469
+ await siwe.logout();
6470
+ } catch {
6471
+ signedOut = false;
6472
+ }
6473
+ throw new FluentAuthError(
6474
+ "link_failed",
6475
+ signedOut ? "Privy signed in a user that does not own the connected wallet; nothing was linked and that session was signed out." : "Privy signed in a user that does not own the connected wallet; nothing was linked, and Privy did not confirm signing that session out."
6476
+ );
6477
+ }
6478
+ return user;
6479
+ }
6480
+ async function mintWalletFluentToken(params) {
6481
+ try {
6482
+ await params.getAuthToken();
6483
+ } catch (err) {
6484
+ if (isSignatureRefusal(err)) {
6485
+ throw new FluentAuthError(
6486
+ "user_rejected",
6487
+ "The user did not sign the challenge that mints the wallet's Fluent token."
6488
+ );
6489
+ }
6490
+ throw err;
6491
+ }
6492
+ }
6493
+ function isPrivyUser(raw) {
6494
+ if (typeof raw !== "object" || raw === null) return false;
6495
+ const { id, linkedAccounts } = raw;
6496
+ return typeof id === "string" && id.length > 0 && Array.isArray(linkedAccounts);
6497
+ }
6498
+ function isSignatureRefusal(err) {
6499
+ for (let current = err; typeof current === "object" && current !== null; ) {
6500
+ if (current.code === 4001) return true;
6501
+ current = current.cause;
6502
+ }
6503
+ const message2 = err instanceof Error ? err.message : String(err);
6504
+ return /user rejected|denied/i.test(message2);
6505
+ }
6506
+ async function linkOrRedirect(params, subject) {
6507
+ let identityToken = params.readIdentityToken();
6508
+ if (!identityTokenHasLinkedX(identityToken)) {
6509
+ identityToken = await params.getIdentityToken();
6510
+ }
6511
+ if (!identityTokenHasLinkedX(identityToken)) {
6512
+ writeLinkXMarker(params.storage, { started: Date.now(), subject });
6513
+ try {
6514
+ await params.linkTwitter(subject);
6515
+ } catch (err) {
6516
+ clearLinkXMarker(params.storage);
6517
+ throw err;
6518
+ }
6519
+ return { status: "redirecting" };
6520
+ }
6521
+ const accessToken = await params.getAccessToken();
6522
+ if (!accessToken) {
6523
+ throw new FluentAuthError("link_failed", "Privy session is not ready; sign in again.");
6524
+ }
6525
+ const authToken = await params.getAuthToken();
6526
+ const body = await requestJson(`${params.publicApiUrl}/me/identity/privy`, {
6527
+ method: "POST",
6528
+ headers: { Authorization: `Bearer ${authToken}` },
6529
+ // Exactly these two fields. The App and the subject come from the bearer, and a browser
6530
+ // sets `Origin` itself — this route takes neither from the caller.
6531
+ body: { accessToken, identityToken },
6532
+ fetch: params.fetch
6533
+ });
6534
+ const x = readFluentProfile(body)?.x;
6535
+ if (!x) {
6536
+ throw new FluentAuthError("link_failed", "The service accepted the link but reported no X account.");
6537
+ }
6538
+ return { status: "linked", x };
6539
+ }
6540
+
6541
+ // src/widget/hooks/useLinkX.ts
6542
+ var IDLE = { status: "idle", x: null, error: null };
6543
+ function useLinkX() {
6544
+ const { linkX: requestLink, session, widget } = useFluentWidget();
6545
+ const [state, setState] = useState(IDLE);
6546
+ const run = useCallback(
6547
+ async (resuming) => {
6548
+ setState({ status: "pending", x: null, error: null });
6549
+ try {
6550
+ const result = await requestLink();
6551
+ if (result.status === "linked") setState({ status: "linked", x: result.x, error: null });
6552
+ else setState({ status: "redirecting", x: null, error: null });
6553
+ return result;
6554
+ } catch (err) {
6555
+ if (resuming && isLinkXIntentDiscarded(err)) {
6556
+ setState(IDLE);
6557
+ throw err;
6558
+ }
6559
+ const error = err instanceof FluentAuthError ? err : new FluentAuthError("link_failed", err instanceof Error ? err.message : String(err));
6560
+ setState({ status: "error", x: null, error });
6561
+ throw error;
6562
+ }
6563
+ },
6564
+ [requestLink]
6565
+ );
6566
+ const linkX = useCallback(() => run(false), [run]);
6567
+ const resumed = useRef(false);
6568
+ const subject = session?.user?.id;
6569
+ const walletConnected = !session && widget.account.type === "eoa";
6570
+ useEffect(() => {
6571
+ if (resumed.current) return;
6572
+ const storage = resolveSessionStorage();
6573
+ const stored = readLinkXMarker(storage);
6574
+ if (stored.kind !== "marker") return;
6575
+ if (subject) {
6576
+ if (!ownsLinkXMarker(stored.marker, subject)) {
6577
+ clearLinkXMarker(storage);
6578
+ return;
6579
+ }
6580
+ } else if (!walletConnected) {
6581
+ return;
6582
+ }
6583
+ resumed.current = true;
6584
+ void run(true).catch(() => void 0);
6585
+ }, [run, subject, walletConnected]);
6586
+ return { ...state, linkX };
6587
+ }
6133
6588
  var FluentSponsorshipFallbackError = class extends Error {
6134
6589
  sponsorshipReason;
6135
6590
  fallbackError;
@@ -6159,6 +6614,106 @@ function getSponsorshipFailure(err) {
6159
6614
  if (httpError.status === 401) return { reason: "unauthorized", disableSponsorship: false };
6160
6615
  return { reason: "unreachable", disableSponsorship: false };
6161
6616
  }
6617
+ var maxCallGasLimit = (1n << 128n) - 1n;
6618
+ function validateUserOperationGas(gas) {
6619
+ if (!gas) return;
6620
+ if (gas.callGasLimit !== void 0) {
6621
+ if (gas.callGasBuffer !== void 0) {
6622
+ throw new Error("Choose callGasLimit or callGasBuffer, not both");
6623
+ }
6624
+ if (typeof gas.callGasLimit !== "bigint" || gas.callGasLimit <= 0n || gas.callGasLimit > maxCallGasLimit) {
6625
+ throw new Error("callGasLimit must be a positive uint128 bigint");
6626
+ }
6627
+ return;
6628
+ }
6629
+ if (!gas.callGasBuffer) throw new Error("UserOperation gas requires callGasLimit or callGasBuffer");
6630
+ const { percentage = 0, fixed = 0n } = gas.callGasBuffer;
6631
+ if (!Number.isSafeInteger(percentage) || percentage < 0) {
6632
+ throw new Error("callGasBuffer.percentage must be a nonnegative safe integer");
6633
+ }
6634
+ if (typeof fixed !== "bigint" || fixed < 0n || fixed > maxCallGasLimit) {
6635
+ throw new Error("callGasBuffer.fixed must be a nonnegative uint128 bigint");
6636
+ }
6637
+ }
6638
+ function withUserOperationGas(client2, args, gas) {
6639
+ validateUserOperationGas(gas);
6640
+ if (!gas) return args;
6641
+ if (gas.callGasBuffer && (gas.callGasBuffer.percentage ?? 0) === 0 && (gas.callGasBuffer.fixed ?? 0n) === 0n) {
6642
+ return args;
6643
+ }
6644
+ const paymaster = args.paymaster ?? client2.paymaster;
6645
+ const policyArgs = {
6646
+ ...args,
6647
+ // viem treats a getPaymasterData-only adapter as a single authorization
6648
+ // before gas estimation. Expose both phases so changed limits are authorized
6649
+ // again before signing, including a stub marked final by the provider.
6650
+ ...typeof paymaster === "object" && paymaster.getPaymasterData ? {
6651
+ paymaster: {
6652
+ async getPaymasterStubData(operation) {
6653
+ const getStub = paymaster.getPaymasterStubData ?? paymaster.getPaymasterData;
6654
+ return { ...await getStub.call(paymaster, operation), isFinal: false };
6655
+ },
6656
+ getPaymasterData: paymaster.getPaymasterData.bind(paymaster)
6657
+ }
6658
+ } : {}
6659
+ };
6660
+ if (gas.callGasLimit !== void 0) {
6661
+ const callGasLimit = gas.callGasLimit;
6662
+ const account2 = args.account;
6663
+ return {
6664
+ ...policyArgs,
6665
+ callGasLimit,
6666
+ account: {
6667
+ ...account2,
6668
+ userOperation: {
6669
+ ...account2.userOperation,
6670
+ async estimateGas(operation) {
6671
+ return { ...await account2.userOperation?.estimateGas?.(operation), callGasLimit };
6672
+ }
6673
+ }
6674
+ }
6675
+ };
6676
+ }
6677
+ const { percentage = 0, fixed = 0n } = gas.callGasBuffer;
6678
+ const account = args.account;
6679
+ return {
6680
+ ...policyArgs,
6681
+ account: {
6682
+ ...account,
6683
+ userOperation: {
6684
+ ...account.userOperation,
6685
+ async estimateGas(operation) {
6686
+ const existing = await account.userOperation?.estimateGas?.(operation);
6687
+ const supplied = { ...operation, ...existing };
6688
+ const complete = supplied.callGasLimit !== void 0 && supplied.preVerificationGas !== void 0 && supplied.verificationGasLimit !== void 0 && (!supplied.paymaster || supplied.paymasterVerificationGasLimit !== void 0 && supplied.paymasterPostOpGasLimit !== void 0);
6689
+ const estimate = complete ? supplied : await estimateUserOperationGas(
6690
+ { ...client2, account: void 0 },
6691
+ {
6692
+ callGasLimit: 0n,
6693
+ preVerificationGas: 0n,
6694
+ verificationGasLimit: 0n,
6695
+ ...operation.paymaster ? {
6696
+ paymasterVerificationGasLimit: 0n,
6697
+ paymasterPostOpGasLimit: 0n
6698
+ } : {},
6699
+ ...operation,
6700
+ ...existing,
6701
+ entryPointAddress: account.entryPoint.address
6702
+ }
6703
+ );
6704
+ const configured = supplied.callGasLimit ?? 0n;
6705
+ const estimated = estimate.callGasLimit ?? 0n;
6706
+ const base = configured > estimated ? configured : estimated;
6707
+ const callGasLimit = (base * (100n + BigInt(percentage)) + 99n) / 100n + fixed;
6708
+ validateUserOperationGas({ callGasLimit });
6709
+ return { ...estimate, ...existing, callGasLimit };
6710
+ }
6711
+ }
6712
+ }
6713
+ };
6714
+ }
6715
+
6716
+ // src/widget/batchOperation.ts
6162
6717
  function createFluentBatchOp(input, executor) {
6163
6718
  if (input.calls.length === 0) {
6164
6719
  throw new Error("A Fluent batch operation requires at least one call");
@@ -6176,6 +6731,7 @@ function createFluentBatchOp(input, executor) {
6176
6731
  const inlineExecutor = optionsOrExecutor && "sendCalls" in optionsOrExecutor ? optionsOrExecutor : void 0;
6177
6732
  const options = optionsOrExecutor && "sendCalls" in optionsOrExecutor ? void 0 : optionsOrExecutor;
6178
6733
  const activeExecutor = overrideExecutor ?? inlineExecutor ?? executor;
6734
+ validateUserOperationGas(options?.userOperationGas);
6179
6735
  if (!activeExecutor) {
6180
6736
  throw new Error("A Fluent batch operation requires a Fluent execution executor");
6181
6737
  }
@@ -6196,15 +6752,16 @@ function createFluentBatchOp(input, executor) {
6196
6752
  });
6197
6753
  }
6198
6754
  const executionReady = activeExecutor.account?.executionReady ?? activeExecutor.smartAccountReady === true;
6755
+ let readyAccount;
6199
6756
  if (!executionReady) {
6200
6757
  if (!activeExecutor.ensureReady) {
6201
6758
  throw new Error(
6202
6759
  activeExecutor.account?.executionError ?? "Fluent smart account execution is not available for this widget session"
6203
6760
  );
6204
6761
  }
6205
- await activeExecutor.ensureReady(executionOptions);
6762
+ readyAccount = await activeExecutor.ensureReady(executionOptions);
6206
6763
  }
6207
- return activeExecutor.sendCalls(encodedCalls, executionOptions);
6764
+ return activeExecutor.sendCalls(encodedCalls, executionOptions, readyAccount);
6208
6765
  }
6209
6766
  };
6210
6767
  }
@@ -6234,6 +6791,102 @@ function encodeBatchCall(call) {
6234
6791
  })
6235
6792
  };
6236
6793
  }
6794
+ var FLUENT_SEND_TOKEN_OP_ID = "fluent-send-token";
6795
+ var AMOUNT_SHAPE = /^\d*(\.\d*)?$/;
6796
+ var ADDRESS_SHAPE = /^0x[0-9a-fA-F]{40}$/;
6797
+ var fluentTransferAbi = parseAbi([
6798
+ "function transfer(address to, uint256 amount) returns (bool)"
6799
+ ]);
6800
+ function parseFluentTransferRecipient(params) {
6801
+ const trimmed = params.input.trim();
6802
+ if (!trimmed) return { status: "empty" };
6803
+ if (!ADDRESS_SHAPE.test(trimmed)) {
6804
+ return { status: "rejected", message: "Enter an address: 0x followed by 40 characters." };
6805
+ }
6806
+ if (!isAddress(trimmed)) {
6807
+ return {
6808
+ status: "rejected",
6809
+ message: "This address fails its checksum. Check it for a typo."
6810
+ };
6811
+ }
6812
+ const lowercased = trimmed.toLowerCase();
6813
+ if (params.self && params.self.toLowerCase() === lowercased) {
6814
+ return { status: "rejected", message: "This is the address you are sending from." };
6815
+ }
6816
+ if (params.contracts?.has(lowercased)) {
6817
+ return {
6818
+ status: "rejected",
6819
+ message: "This is a token's contract address, not a wallet. Tokens sent there are lost."
6820
+ };
6821
+ }
6822
+ return { status: "ok", address: trimmed };
6823
+ }
6824
+ function parseFluentTransferAmount(params) {
6825
+ const trimmed = params.input.trim();
6826
+ if (!trimmed) return { status: "empty" };
6827
+ if (trimmed.includes(",")) {
6828
+ return { status: "rejected", message: "Use a dot for the decimal point." };
6829
+ }
6830
+ if (!AMOUNT_SHAPE.test(trimmed) || !/\d/.test(trimmed)) {
6831
+ return { status: "rejected", message: "Enter the amount as a number, like 12.5." };
6832
+ }
6833
+ const fraction = trimmed.split(".")[1] ?? "";
6834
+ if (fraction.length > params.decimals) {
6835
+ return {
6836
+ status: "rejected",
6837
+ message: params.decimals === 0 ? `${params.symbol} cannot be split \u2014 enter a whole number.` : `${params.symbol} has ${params.decimals} decimals. Use at most that many.`
6838
+ };
6839
+ }
6840
+ const raw = parseUnits(trimmed, params.decimals);
6841
+ if (raw === 0n) {
6842
+ return { status: "rejected", message: "Enter an amount greater than 0." };
6843
+ }
6844
+ if (raw > params.balance) {
6845
+ return { status: "rejected", message: `That is more than your ${params.symbol} balance.` };
6846
+ }
6847
+ return { status: "ok", raw };
6848
+ }
6849
+ function resolveFluentTransferGasContext(params) {
6850
+ return {
6851
+ erc20Gas: Boolean(params.fluentAccountAddress) && !params.walletConnected,
6852
+ sponsorshipAvailable: Boolean(params.sponsorshipUrl && params.appId)
6853
+ };
6854
+ }
6855
+ function checkFluentTransferFee(params) {
6856
+ const { feeToken, feeBalance, feeBalanceEthValue, sponsorshipAvailable } = params;
6857
+ if (feeBalance === null) return { status: "ok" };
6858
+ const symbol = feeToken.symbol;
6859
+ const mustPay = !isFluentNativeToken(feeToken) || !sponsorshipAvailable;
6860
+ const verdict = (message2, sponsorable) => mustPay ? { status: "blocked", message: message2 } : { status: "warning", message: sponsorable };
6861
+ if (feeBalance === 0n) {
6862
+ return verdict(
6863
+ `You have no ${symbol} to pay the fee with. Choose another fee token.`,
6864
+ `You have no ${symbol}. This will only go through if the app covers the fee.`
6865
+ );
6866
+ }
6867
+ if (feeBalanceEthValue !== null && feeBalanceEthValue !== void 0 && getFluentGasPaymentValueTier(feeBalanceEthValue) === "red") {
6868
+ return { status: "warning", message: `Your ${symbol} balance may be too small for the fee.` };
6869
+ }
6870
+ return { status: "ok" };
6871
+ }
6872
+ function buildFluentTransferCall(params) {
6873
+ const { token, to, amount } = params;
6874
+ const label = `Send ${token.symbol}`;
6875
+ if (isFluentNativeToken(token)) {
6876
+ return { id: "fluent-send-token", label, to, value: amount, data: "0x" };
6877
+ }
6878
+ if (!token.address) {
6879
+ throw new Error(`${token.symbol} has no contract address on this network`);
6880
+ }
6881
+ return {
6882
+ id: "fluent-send-token",
6883
+ label,
6884
+ to: token.address,
6885
+ abi: fluentTransferAbi,
6886
+ method: "transfer",
6887
+ args: [to, amount]
6888
+ };
6889
+ }
6237
6890
 
6238
6891
  // src/core/hostedSigner.ts
6239
6892
  var READY_TIMEOUT_MS = 3e4;
@@ -6635,13 +7288,14 @@ function sponsorshipTokenErrorCode(err) {
6635
7288
  }
6636
7289
 
6637
7290
  // src/core/userOperationTiming.ts
6638
- async function sendUserOperationWithTiming(client2, args) {
6639
- if (!isDebugLoggingEnabled()) return client2.sendUserOperation(args);
7291
+ async function sendUserOperationWithTiming(client2, args, gas) {
7292
+ const preparedArgs = withUserOperationGas(client2, args, gas);
7293
+ if (!isDebugLoggingEnabled()) return client2.sendUserOperation(preparedArgs);
6640
7294
  const startedAt = performance.now();
6641
7295
  let signingAt;
6642
7296
  let signedAt;
6643
7297
  let success = false;
6644
- const account = args.account;
7298
+ const account = preparedArgs.account;
6645
7299
  const observedAccount = {
6646
7300
  ...account,
6647
7301
  async signUserOperation(operation) {
@@ -6661,7 +7315,7 @@ async function sendUserOperationWithTiming(client2, args) {
6661
7315
  };
6662
7316
  debugLog("[fluent execution stage]", { stage: "preparing" });
6663
7317
  try {
6664
- const hash = await client2.sendUserOperation({ ...args, account: observedAccount });
7318
+ const hash = await client2.sendUserOperation({ ...preparedArgs, account: observedAccount });
6665
7319
  success = true;
6666
7320
  return hash;
6667
7321
  } finally {
@@ -6725,29 +7379,117 @@ function cn(...inputs) {
6725
7379
  return twMerge(clsx(inputs));
6726
7380
  }
6727
7381
  var WIDGET_STYLE_SCOPE = "fluent-root dark contents text-foreground";
7382
+ var TOP_LAYER_STYLE_SCOPE = "fluent-root dark text-foreground";
6728
7383
  var FluentPortalContainerContext = createContext(null);
7384
+ var FluentTopLayerContext = createContext(null);
7385
+ var FluentToastLayerContext = createContext(null);
6729
7386
  function FluentPortalContainerProvider({ children }) {
6730
7387
  const [container, setContainer] = useState(null);
7388
+ const [topLayer, setTopLayer] = useState(null);
7389
+ const [toastLayer, setToastLayer] = useState(null);
7390
+ const holdsRef = useRef(0);
6731
7391
  useLayoutEffect(() => {
6732
7392
  const element = document.createElement("div");
6733
7393
  element.setAttribute("data-fluent-portal-root", "");
6734
7394
  element.className = WIDGET_STYLE_SCOPE;
6735
7395
  document.body.appendChild(element);
6736
7396
  setContainer(element);
7397
+ const toasts = document.createElement("div");
7398
+ toasts.setAttribute("data-fluent-toast-layer", "");
7399
+ toasts.setAttribute("popover", "manual");
7400
+ toasts.className = TOP_LAYER_STYLE_SCOPE;
7401
+ document.body.appendChild(toasts);
7402
+ try {
7403
+ toasts.showPopover?.();
7404
+ } catch {
7405
+ }
7406
+ setToastLayer(toasts);
7407
+ const dialog = document.createElement("dialog");
7408
+ dialog.setAttribute("data-fluent-top-layer", "");
7409
+ dialog.className = TOP_LAYER_STYLE_SCOPE;
7410
+ const onCancel = (event) => event.preventDefault();
7411
+ const onClose = () => {
7412
+ if (holdsRef.current > 0 && dialog.isConnected && !dialog.open) {
7413
+ try {
7414
+ dialog.showModal();
7415
+ } catch {
7416
+ }
7417
+ }
7418
+ };
7419
+ dialog.addEventListener("cancel", onCancel);
7420
+ dialog.addEventListener("close", onClose);
7421
+ document.body.appendChild(dialog);
7422
+ const acquire = () => {
7423
+ holdsRef.current += 1;
7424
+ if (holdsRef.current === 1 && dialog.isConnected && !dialog.open) {
7425
+ try {
7426
+ dialog.showModal();
7427
+ } catch {
7428
+ }
7429
+ }
7430
+ let released = false;
7431
+ return () => {
7432
+ if (released) return;
7433
+ released = true;
7434
+ holdsRef.current -= 1;
7435
+ if (holdsRef.current === 0 && dialog.open) {
7436
+ try {
7437
+ dialog.close();
7438
+ } catch {
7439
+ }
7440
+ }
7441
+ };
7442
+ };
7443
+ setTopLayer({ element: dialog, acquire });
6737
7444
  return () => {
6738
7445
  element.remove();
6739
7446
  setContainer(null);
7447
+ toasts.remove();
7448
+ setToastLayer(null);
7449
+ dialog.removeEventListener("cancel", onCancel);
7450
+ dialog.removeEventListener("close", onClose);
7451
+ dialog.remove();
7452
+ setTopLayer(null);
6740
7453
  };
6741
7454
  }, []);
6742
- return /* @__PURE__ */ jsx(FluentPortalContainerContext.Provider, { value: container, children });
7455
+ return /* @__PURE__ */ jsx(FluentPortalContainerContext.Provider, { value: container, children: /* @__PURE__ */ jsx(FluentTopLayerContext.Provider, { value: topLayer, children: /* @__PURE__ */ jsx(FluentToastLayerContext.Provider, { value: toastLayer, children }) }) });
6743
7456
  }
6744
7457
  function useFluentPortalContainer(override) {
6745
7458
  const container = useContext(FluentPortalContainerContext);
6746
7459
  return override ?? container ?? void 0;
6747
7460
  }
6748
- var buttonVariants = cva(
6749
- "group/button inline-flex shrink-0 items-center justify-center rounded-xl border border-transparent bg-clip-padding font-medium whitespace-nowrap transition-all duration-75 outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
6750
- {
7461
+ function useFluentModalPortalContainer(override) {
7462
+ const topLayer = useContext(FluentTopLayerContext);
7463
+ const container = useContext(FluentPortalContainerContext);
7464
+ return override ?? topLayer?.element ?? container ?? void 0;
7465
+ }
7466
+ function useFluentTopLayer() {
7467
+ return useContext(FluentTopLayerContext);
7468
+ }
7469
+ function useFluentToastLayer() {
7470
+ return useContext(FluentToastLayerContext);
7471
+ }
7472
+ function useFluentToastPortalContainer(override) {
7473
+ const toastLayer = useContext(FluentToastLayerContext);
7474
+ const container = useContext(FluentPortalContainerContext);
7475
+ return override ?? toastLayer ?? container ?? void 0;
7476
+ }
7477
+ function FluentTopLayerSlot({
7478
+ children,
7479
+ disabled = false
7480
+ }) {
7481
+ const topLayer = useContext(FluentTopLayerContext);
7482
+ const active = !disabled && topLayer !== null;
7483
+ useLayoutEffect(() => {
7484
+ if (!active) return;
7485
+ return topLayer.acquire();
7486
+ }, [active, topLayer]);
7487
+ if (!active) return /* @__PURE__ */ jsx(Fragment, { children });
7488
+ return /* @__PURE__ */ jsx(FluentPortalContainerContext.Provider, { value: topLayer.element, children });
7489
+ }
7490
+ var buttonVariants = cva(
7491
+ "group/button inline-flex shrink-0 items-center justify-center rounded-xl border border-transparent bg-clip-padding font-medium whitespace-nowrap transition-all duration-75 outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
7492
+ {
6751
7493
  variants: {
6752
7494
  variant: {
6753
7495
  default: "bg-primary text-primary-foreground hover:bg-primary/80",
@@ -6797,7 +7539,7 @@ function ToastPortal({ container, ...props }) {
6797
7539
  Toast$1.Portal,
6798
7540
  {
6799
7541
  "data-slot": "toast-portal",
6800
- container: useFluentPortalContainer(container),
7542
+ container: useFluentToastPortalContainer(container),
6801
7543
  ...props
6802
7544
  }
6803
7545
  );
@@ -7423,16 +8165,18 @@ function useFluentZeroDevAccount(hookOptions = {}) {
7423
8165
  []
7424
8166
  );
7425
8167
  const sendCalls = useCallback(
7426
- async (calls, options) => {
8168
+ async (calls, options, readyAccount) => {
7427
8169
  const startedAt = performance.now();
7428
8170
  debugLog("[fluent execution stage]", { stage: "setup" });
8171
+ validateUserOperationGas(options?.userOperationGas);
7429
8172
  const signerMode = confirmationToSignerMode(options?.confirmation ?? "always");
7430
- const cachedKernel = kernels[signerMode];
8173
+ const readyKernel = readyAccount && typeof readyAccount === "object" && readyAccount.signerMode === signerMode ? readyAccount : void 0;
8174
+ const knownKernel = readyKernel ?? kernels[signerMode];
7431
8175
  const hasAuthorizationSession = signerMode === "silent" && Boolean(hookOptions.authorizationSession?.serializedPermissionAccount) && (hookOptions.authorizationSession?.expiresAt ?? 0) > Math.floor(Date.now() / 1e3);
7432
- if (cachedKernel?.signerSource === "hosted" || !cachedKernel && !hasAuthorizationSession && hostedSigner && !(ready && authenticated && embeddedWallet)) {
8176
+ if (knownKernel?.signerSource === "hosted" || !knownKernel && !hasAuthorizationSession && hostedSigner && !(ready && authenticated && embeddedWallet)) {
7433
8177
  hostedSigner?.prepare(options?.confirmation ?? "always");
7434
8178
  }
7435
- const executionKernel = cachedKernel ?? await initialize2({ signerMode, throwOnError: true });
8179
+ const executionKernel = knownKernel ?? await initialize2({ signerMode, throwOnError: true });
7436
8180
  if (!executionKernel) throw new Error(error?.message ?? "ZeroDev smart account is not ready");
7437
8181
  const gasToken = options?.gasPayment?.symbol ? getFluentGasTokenAddress(options.gasPayment.symbol, network) : void 0;
7438
8182
  const preparedCalls = [...calls];
@@ -7505,8 +8249,8 @@ function useFluentZeroDevAccount(hookOptions = {}) {
7505
8249
  log: sponsorshipLog
7506
8250
  }),
7507
8251
  buildClient: createSponsoredClient(executionKernel, sponsorship),
7508
- sendSponsored: (client2) => sendUserOperationWithTiming(client2, callArgs),
7509
- sendOwnGas: () => sendUserOperationWithTiming(executionKernel.client, callArgs),
8252
+ sendSponsored: (client2) => sendUserOperationWithTiming(client2, callArgs, options?.userOperationGas),
8253
+ sendOwnGas: () => sendUserOperationWithTiming(executionKernel.client, callArgs, options?.userOperationGas),
7510
8254
  ownGasClient: executionKernel.client,
7511
8255
  waitFor: ({ client: client2, userOpHash: hash }) => waitForInclusion(client2, hash),
7512
8256
  disableSponsorship: () => {
@@ -7521,7 +8265,7 @@ function useFluentZeroDevAccount(hookOptions = {}) {
7521
8265
  else if (!gasToken && sponsorship && sponsorshipUnavailable.current) {
7522
8266
  sponsorshipReason = "unauthorized";
7523
8267
  }
7524
- userOpHash = await sendUserOperationWithTiming(executionClient, callArgs);
8268
+ userOpHash = await sendUserOperationWithTiming(executionClient, callArgs, options?.userOperationGas);
7525
8269
  debugLog("[fluent zerodev] sendCalls userOp submitted", { userOpHash });
7526
8270
  receipt = await waitForInclusion(settlementClient, userOpHash);
7527
8271
  }
@@ -7821,6 +8565,7 @@ async function withFluentSignaturePrompt(sign) {
7821
8565
  function buildPromptSigningUiOptions() {
7822
8566
  if (promptSigningContext.intent === "signature") {
7823
8567
  return {
8568
+ showWalletUIs: true,
7824
8569
  title: "Sign with Fluent",
7825
8570
  description: "Sign this request with your Fluent account. Nothing is sent on chain.",
7826
8571
  buttonText: "Sign"
@@ -7828,6 +8573,7 @@ function buildPromptSigningUiOptions() {
7828
8573
  }
7829
8574
  const gasTokenSymbol = promptSigningContext.gasTokenSymbol;
7830
8575
  return {
8576
+ showWalletUIs: true,
7831
8577
  title: "Confirm Fluent transaction",
7832
8578
  description: gasTokenSymbol ? `Gas will be paid in ${gasTokenSymbol}. Confirm this Fluent transaction.` : "Confirm this Fluent transaction.",
7833
8579
  buttonText: "Sign"
@@ -8346,7 +9092,7 @@ function useFluentIframeBridge(iframeRef, { allowedOrigin }) {
8346
9092
  }
8347
9093
 
8348
9094
  // package.json
8349
- var version = "0.4.0";
9095
+ var version = "0.4.1";
8350
9096
 
8351
9097
  // src/core/analytics.ts
8352
9098
  var INSTANCE_NAME = "fluent";
@@ -8533,12 +9279,42 @@ function getReownNetworks(chain) {
8533
9279
  )?.source;
8534
9280
  return bridgeSource && bridgeSource.id !== chain.id ? [chain, bridgeSource] : [chain];
8535
9281
  }
9282
+ function canReconnectSilently(connector) {
9283
+ return connector.type === "injected" || connector.type === "walletConnect";
9284
+ }
9285
+ var SilentReconnectAdapter = class extends WagmiAdapter {
9286
+ hydration;
9287
+ reconnection;
9288
+ hydrate() {
9289
+ return this.hydration ??= hydrate(this.wagmiConfig, {
9290
+ reconnectOnMount: false
9291
+ }).onMount();
9292
+ }
9293
+ syncConnections() {
9294
+ return this.reconnection ??= this.restoreConnections();
9295
+ }
9296
+ async restoreConnections() {
9297
+ await this.hydrate();
9298
+ const connectors = this.wagmiConfig.connectors.filter(canReconnectSilently);
9299
+ if (connectors.length) await reconnect(this.wagmiConfig, { connectors });
9300
+ }
9301
+ async syncConnection(params) {
9302
+ await this.hydrate();
9303
+ const connector = this.wagmiConfig.connectors.find(({ id }) => id === params.id);
9304
+ if (!connector || !canReconnectSilently(connector)) {
9305
+ throw new Error("This connector requires an explicit connection.");
9306
+ }
9307
+ await this.syncConnections();
9308
+ return super.syncConnection(params);
9309
+ }
9310
+ };
8536
9311
  function getReownWagmiAdapter(chain, disableAnalytics, reconnectOnMount) {
8537
9312
  const networks = getReownNetworks(chain);
8538
9313
  const key = `${networks.map((n) => n.id).join("-")}:${disableAnalytics ? "no-analytics" : "analytics"}:${reconnectOnMount}`;
8539
9314
  const existing = appKitByKey.get(key);
8540
9315
  if (existing) return existing;
8541
- const adapter = new WagmiAdapter({
9316
+ const Adapter = reconnectOnMount === void 0 ? SilentReconnectAdapter : WagmiAdapter;
9317
+ const adapter = new Adapter({
8542
9318
  // Hydrate in a mount effect. In client-render mode Wagmi reruns hydration
8543
9319
  // on every render and reconnectOnMount=false clears even live connections
8544
9320
  // (for example, when opening the account drawer).
@@ -8557,7 +9333,9 @@ function getReownWagmiAdapter(chain, disableAnalytics, reconnectOnMount) {
8557
9333
  appKitByKey.set(key, adapter);
8558
9334
  if (typeof window !== "undefined") {
8559
9335
  createAppKit({
8560
- enableReconnect: reconnectOnMount,
9336
+ // false triggers AppKit initialDisconnect (and ends WalletConnect sessions).
9337
+ // Keep it enabled for the default policy; the adapter filters its restore calls.
9338
+ enableReconnect: reconnectOnMount !== false,
8561
9339
  adapters: [adapter],
8562
9340
  networks,
8563
9341
  defaultNetwork: chain,
@@ -8594,14 +9372,20 @@ function ReownProvider({
8594
9372
  children,
8595
9373
  network = "testnet",
8596
9374
  disableAnalytics = false,
8597
- reconnectOnMount = false
9375
+ reconnectOnMount
8598
9376
  }) {
8599
9377
  const chain = useMemo(() => getFluentChainForNetwork(network), [network]);
8600
9378
  const wagmiAdapter = useMemo(
8601
9379
  () => getReownWagmiAdapter(chain, disableAnalytics, reconnectOnMount),
8602
9380
  [chain, disableAnalytics, reconnectOnMount]
8603
9381
  );
9382
+ useEffect(() => {
9383
+ if (wagmiAdapter instanceof SilentReconnectAdapter) void wagmiAdapter.hydrate();
9384
+ }, [wagmiAdapter]);
8604
9385
  if (!wagmiAdapter) return /* @__PURE__ */ jsx(Fragment, { children });
9386
+ if (wagmiAdapter instanceof SilentReconnectAdapter) {
9387
+ return /* @__PURE__ */ jsx(WagmiContext.Provider, { value: wagmiAdapter.wagmiConfig, children: /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children }) });
9388
+ }
8605
9389
  return /* @__PURE__ */ jsx(
8606
9390
  WagmiProvider,
8607
9391
  {
@@ -8718,6 +9502,7 @@ var icons = {
8718
9502
  x: (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsx("path", { d: "M10.4883 14.651L15.25 21H22.25L14.3917 10.5223L20.9308 3H18.2808L13.1643 8.88578L8.75 3H1.75L9.26086 13.0145L2.31915 21H4.96917L10.4883 14.651ZM16.25 19L5.75 5H7.75L18.25 19H16.25Z" }) }),
8719
9503
  "arrow-right-s-line": (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsx("path", { d: "M13.1717 12.0007L8.22192 7.05093L9.63614 5.63672L16.0001 12.0007L9.63614 18.3646L8.22192 16.9504L13.1717 12.0007Z" }) }),
8720
9504
  "arrow-left-right-line": (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsx("path", { d: "M16.0503 12.0498L21 16.9996L16.0503 21.9493L14.636 20.5351L17.172 17.9988L4 17.9996V15.9996L17.172 15.9988L14.636 13.464L16.0503 12.0498ZM7.94975 2.0498L9.36396 3.46402L6.828 5.9988L20 5.99955V7.99955L6.828 7.9988L9.36396 10.5351L7.94975 11.9493L3 6.99955L7.94975 2.0498Z" }) }),
9505
+ "arrow-up-line": (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsx("path", { d: "M13 7.82843V20H11V7.82843L5.63604 13.1924L4.22183 11.7782L12 4L19.7782 11.7782L18.364 13.1924L13 7.82843Z" }) }),
8721
9506
  "arrow-up-s-fill": (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsx("path", { d: "M12 8L18 14H6L12 8Z" }) }),
8722
9507
  "arrow-down-s-fill": (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsx("path", { d: "M12 16L6 10H18L12 16Z" }) }),
8723
9508
  plus: (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsx("path", { d: "M11 11V5H13V11H19V13H13V19H11V13H5V11H11Z" }) }),
@@ -8744,6 +9529,8 @@ var icons = {
8744
9529
  /* @__PURE__ */ jsx("path", { d: "M12 8.25 8.5 10.3v3.4L12 15.75l3.5-2.05v-3.4L12 8.25z" })
8745
9530
  ] }),
8746
9531
  fluent: (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 26 24", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsx("path", { d: "M25.973 3.5405V0H0.0274556V3.5405H11.5738C9.39481 4.86942 7.44796 6.53554 5.79813 8.4595H0V12H3.2797C1.21554 15.5331 0.0274556 19.6314 0.0274556 24H3.59169C3.59169 19.5198 5.05433 15.3719 7.52284 11.9975H14.257C10.7975 14.8364 8.58862 19.1306 8.58862 23.9256H12.1529C12.1529 17.3479 17.5392 11.9975 24.1609 11.9975H25.9431V8.45702H10.815C14.4167 5.39504 19.0867 3.53802 24.1884 3.53802H25.9705L25.973 3.5405Z" }) }),
9532
+ fluentLogomark: (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 18 16", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsx("path", { d: "M17.6591 2.36033V0H0.362054V2.36033H8.05961C6.60696 3.24628 5.30906 4.35702 4.20917 5.63967H0.34375V8H2.53022C1.15411 10.3554 0.362054 13.0876 0.362054 16H2.73821C2.73821 13.0132 3.7133 10.2479 5.35898 7.99835H9.84839C7.54212 9.89091 6.0695 12.7537 6.0695 15.9504H8.44565C8.44565 11.5653 12.0365 7.99835 16.451 7.99835H17.6391V5.63802H7.55376C9.95488 3.59669 13.0682 2.35868 16.4694 2.35868H17.6574L17.6591 2.36033Z" }) }),
9533
+ fluentLogotype: (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 63 16", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M0.3125 4.63636V6.75207H2.1878V15.8529H4.85017V6.75207H7.89691V4.63636H4.7653V3.95868C4.7653 3.35207 4.90674 2.89752 5.19128 2.59339C5.47582 2.29091 5.89514 2.13884 6.44925 2.13884C6.71881 2.13884 6.98172 2.17851 7.23797 2.2562C7.49423 2.33388 7.72053 2.44959 7.9202 2.60496L8.64404 0.614876C8.3595 0.403306 8.00839 0.247934 7.58907 0.14876C7.16975 0.0495868 6.72713 0 6.25789 0C4.95 0 3.94663 0.357025 3.24276 1.06942C2.5389 1.78182 2.1878 2.73058 2.1878 3.9157V4.63636H0.3125ZM10.1198 0.148438V15.8526H12.7838V0.148438H10.1198ZM20.1296 15.9991C19.1628 15.9991 18.3109 15.8189 17.5721 15.4586C16.8333 15.0982 16.2575 14.5478 15.8465 13.8073C15.4339 13.0668 15.2292 12.1313 15.2292 11.0024V4.54948H17.8932V10.6454C17.8932 11.6619 18.1245 12.4206 18.5854 12.9197C19.0463 13.4206 19.7036 13.6718 20.5556 13.6718C21.1812 13.6718 21.7237 13.5445 22.1863 13.2916C22.6472 13.0371 23.0099 12.6569 23.2729 12.1478C23.5358 11.6404 23.6672 11.0123 23.6672 10.2635V4.54948H26.3312V15.852H23.7953V14.417C23.4615 14.8264 23.049 15.1596 22.559 15.4173C21.8202 15.8057 21.0098 15.9991 20.1296 15.9991ZM31.0708 15.2467C32.0143 15.7475 33.1192 15.9987 34.3838 15.9987H34.3871C35.3805 15.9987 36.2657 15.8401 37.0395 15.5227C37.8132 15.2053 38.4572 14.7491 38.968 14.1574L37.5403 12.5277C37.1427 12.9508 36.6884 13.2615 36.1775 13.4582C35.6667 13.6549 35.091 13.7541 34.452 13.7541C33.7132 13.7541 33.0593 13.6136 32.4918 13.331C31.9228 13.0483 31.4835 12.6467 31.1706 12.1244C30.9733 11.796 30.8383 11.4361 30.7654 11.045H39.6919C39.7052 10.9177 39.7168 10.7839 39.7235 10.6434C39.7301 10.5029 39.7335 10.3756 39.7335 10.2632C39.7335 9.07642 39.4855 8.04667 38.988 7.17229C38.4905 6.29791 37.8099 5.62022 36.943 5.14088C36.076 4.66154 35.1176 4.42188 33.9811 4.42188C32.8446 4.42188 31.8312 4.66816 30.9443 5.16237C30.0558 5.65659 29.3602 6.33758 28.8561 7.20535C28.3502 8.07311 28.0989 9.08634 28.0989 10.2004C28.0989 11.3144 28.3569 12.3095 28.876 13.1839C29.3952 14.0582 30.1257 14.7458 31.0708 15.2467ZM30.743 9.28799C30.8032 8.86257 30.9283 8.47873 31.1174 8.13592C31.3936 7.6351 31.7763 7.24336 32.2672 6.96072C32.7581 6.67807 33.3438 6.53758 33.9828 6.53758C34.6217 6.53758 35.1858 6.67807 35.6767 6.96072C36.1676 7.24336 36.5536 7.63014 36.8381 8.12435C37.0382 8.47383 37.1642 8.86131 37.2161 9.28799H30.743ZM48.0256 4.42188C48.9341 4.42188 49.7478 4.59873 50.465 4.9508C51.1821 5.30287 51.7462 5.84336 52.1589 6.56898C52.5716 7.29626 52.7762 8.23014 52.7762 9.37394V15.85H50.1122V9.71278C50.1122 8.71113 49.8743 7.96402 49.3984 7.46981C48.9225 6.97559 48.2585 6.72931 47.4066 6.72931C46.7809 6.72931 46.2268 6.85659 45.7443 7.10948C45.2617 7.36402 44.889 7.74088 44.6261 8.24171C44.3632 8.74254 44.2317 9.37394 44.2317 10.1359V15.85H41.5677V4.54915H44.1036V6.01502C44.4512 5.60349 44.8811 5.26694 45.3932 5.00535C46.1536 4.61692 47.0305 4.42353 48.0239 4.42353L48.0256 4.42188ZM53.875 4.63555V6.75125H55.7486V12.1893C55.7486 13.4455 56.0914 14.3926 56.772 15.0355C57.4526 15.6785 58.4193 15.9992 59.669 15.9992H59.6706C60.1532 15.9992 60.6224 15.9364 61.0767 15.8091C61.531 15.6818 61.9137 15.4917 62.2265 15.2372L61.481 13.3529C61.0833 13.6636 60.5858 13.819 59.9901 13.819C59.4926 13.819 59.1065 13.6703 58.8287 13.3744C58.5508 13.0785 58.4127 12.6636 58.4127 12.1265V6.75125H61.4594V4.63555H58.4127V2.05208H55.7486V4.63555H53.875Z" }) }),
8747
9534
  metaMask: (props) => /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 142 136.878", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
8748
9535
  /* @__PURE__ */ jsx("path", { fill: "#FF5C16", d: "M132.682,132.192l-30.583-9.106l-23.063,13.787l-16.092-0.007l-23.077-13.78l-30.569,9.106L0,100.801l9.299-34.839L0,36.507L9.299,0l47.766,28.538h27.85L132.682,0l9.299,36.507l-9.299,29.455l9.299,34.839L132.682,132.192L132.682,132.192z" }),
8749
9536
  /* @__PURE__ */ jsx("path", { fill: "#FF5C16", d: "M9.305,0l47.767,28.558l-1.899,19.599L9.305,0z M39.875,100.814l21.017,16.01l-21.017,6.261C39.875,123.085,39.875,100.814,39.875,100.814z M59.212,74.345l-4.039-26.174L29.317,65.97l-0.014-0.007v0.013l0.08,18.321l10.485-9.951L59.212,74.345L59.212,74.345z M132.682,0L84.915,28.558l1.893,19.599L132.682,0z M102.113,100.814l-21.018,16.01l21.018,6.261V100.814z M112.678,65.975h0.007H112.678v-0.013l-0.006,0.007L86.815,48.171l-4.039,26.174h19.336l10.492,9.95C112.604,84.295,112.678,65.975,112.678,65.975z" }),
@@ -8799,13 +9586,14 @@ function Dialog({ ...props }) {
8799
9586
  function DialogTrigger({ ...props }) {
8800
9587
  return /* @__PURE__ */ jsx(Dialog$1.Trigger, { "data-slot": "dialog-trigger", ...props });
8801
9588
  }
8802
- function DialogPortal({ container, ...props }) {
9589
+ function DialogPortal({ container, children, ...props }) {
8803
9590
  return /* @__PURE__ */ jsx(
8804
9591
  Dialog$1.Portal,
8805
9592
  {
8806
9593
  "data-slot": "dialog-portal",
8807
- container: useFluentPortalContainer(container),
8808
- ...props
9594
+ container: useFluentModalPortalContainer(container),
9595
+ ...props,
9596
+ children: /* @__PURE__ */ jsx(FluentTopLayerSlot, { children })
8809
9597
  }
8810
9598
  );
8811
9599
  }
@@ -8973,8 +9761,15 @@ function InlineConnectModal(props) {
8973
9761
  hostedError,
8974
9762
  wallet,
8975
9763
  track,
8976
- onExternalWalletSelected
9764
+ onExternalWalletSelected,
9765
+ config,
9766
+ walletUserPrivySession = false,
9767
+ signInRefusal = null
8977
9768
  } = props;
9769
+ const authMethods = React.useMemo(
9770
+ () => resolveFluentWidgetAuthMethods(config?.enabledAuthMethods),
9771
+ [config?.enabledAuthMethods]
9772
+ );
8978
9773
  const { ready, authenticated, user } = usePrivy();
8979
9774
  const { isOpen: securityPromptOpen } = useModalStatus();
8980
9775
  const { wallets, ready: walletsReady } = useWallets();
@@ -9005,6 +9800,7 @@ function InlineConnectModal(props) {
9005
9800
  const attemptedWallet = React.useRef(null);
9006
9801
  const walletFailed = React.useRef(false);
9007
9802
  const fluentChosen = React.useRef(false);
9803
+ const fluentGate = React.useRef(void 0);
9008
9804
  const heading = React.useRef(null);
9009
9805
  const input = React.useRef(null);
9010
9806
  const walletList = React.useRef(null);
@@ -9012,7 +9808,7 @@ function InlineConnectModal(props) {
9012
9808
  active.current = open;
9013
9809
  const connecting = step !== "choice" && authenticated;
9014
9810
  const screen = connecting ? "connecting" : step;
9015
- const shownError = error || captchaError || (connecting ? hostedError : "");
9811
+ const shownError = error || captchaError || (connecting ? signInRefusal || hostedError : "");
9016
9812
  React.useEffect(() => {
9017
9813
  if (!open) {
9018
9814
  generation.current++;
@@ -9025,6 +9821,7 @@ function InlineConnectModal(props) {
9025
9821
  setBusy(false);
9026
9822
  setSlow(false);
9027
9823
  fluentChosen.current = false;
9824
+ fluentGate.current = void 0;
9028
9825
  clearInlineOAuth();
9029
9826
  }
9030
9827
  return () => {
@@ -9065,7 +9862,7 @@ function InlineConnectModal(props) {
9065
9862
  return () => clearTimeout(timer);
9066
9863
  }, [open, connecting, step, walletAttempt]);
9067
9864
  React.useEffect(() => {
9068
- if (!open || !connecting || !walletsReady || !user?.id) return;
9865
+ if (!open || !connecting || !walletsReady || !user?.id || walletUserPrivySession) return;
9069
9866
  clearInlineOAuth();
9070
9867
  const embedded = (account) => account.walletClientType === "privy" && (!account.chainType || account.chainType === "ethereum");
9071
9868
  if (wallets.some(embedded) || user.linkedAccounts?.some(
@@ -9088,7 +9885,8 @@ function InlineConnectModal(props) {
9088
9885
  wallets,
9089
9886
  user,
9090
9887
  createWallet,
9091
- walletAttempt
9888
+ walletAttempt,
9889
+ walletUserPrivySession
9092
9890
  ]);
9093
9891
  const run = async (action, needsPrivy = true) => {
9094
9892
  if (operation.current || needsPrivy && !ready) return;
@@ -9118,12 +9916,24 @@ function InlineConnectModal(props) {
9118
9916
  setStep(next);
9119
9917
  };
9120
9918
  const chooseFluent = () => {
9121
- if (fluentChosen.current) return;
9122
- fluentChosen.current = true;
9123
- track("connect_method_selected", {
9124
- method: "fluent"
9919
+ if (fluentGate.current !== void 0) return fluentGate.current;
9920
+ if (!fluentChosen.current) {
9921
+ fluentChosen.current = true;
9922
+ track("connect_method_selected", {
9923
+ method: "fluent"
9924
+ });
9925
+ }
9926
+ const answer = onFluentLogin();
9927
+ if (!answer) {
9928
+ fluentGate.current = null;
9929
+ return null;
9930
+ }
9931
+ const gate = answer.then(void 0, (failure) => {
9932
+ if (fluentGate.current === gate) fluentGate.current = void 0;
9933
+ throw failure;
9125
9934
  });
9126
- onFluentLogin();
9935
+ fluentGate.current = gate;
9936
+ return gate;
9127
9937
  };
9128
9938
  const icon = (name) => {
9129
9939
  if (!name) return null;
@@ -9178,12 +9988,20 @@ function InlineConnectModal(props) {
9178
9988
  }
9179
9989
  });
9180
9990
  const passkey = () => run(async (current) => {
9181
- chooseFluent();
9991
+ const gate = chooseFluent();
9992
+ if (gate) {
9993
+ await gate;
9994
+ if (!current()) return;
9995
+ }
9182
9996
  await loginWithPasskey();
9183
9997
  if (current()) setStep("connecting");
9184
9998
  });
9185
9999
  const oauth = (provider) => run(async (current) => {
9186
- chooseFluent();
10000
+ const gate = chooseFluent();
10001
+ if (gate) {
10002
+ await gate;
10003
+ if (!current()) return;
10004
+ }
9187
10005
  window.sessionStorage.setItem(
9188
10006
  inlineOAuthKey,
9189
10007
  JSON.stringify({ started: Date.now(), provider })
@@ -9217,6 +10035,11 @@ function InlineConnectModal(props) {
9217
10035
  const retry = () => {
9218
10036
  setError("");
9219
10037
  setSlow(false);
10038
+ if (signInRefusal) {
10039
+ clearInlineOAuth();
10040
+ setStep("choice");
10041
+ return;
10042
+ }
9220
10043
  if (walletFailed.current) attemptedWallet.current = null;
9221
10044
  setWalletAttempt((value) => value + 1);
9222
10045
  onRetry?.();
@@ -9225,28 +10048,45 @@ function InlineConnectModal(props) {
9225
10048
  let description = "Use Fluent Connect to access your reputation, positions, and rewards.";
9226
10049
  let content;
9227
10050
  let headerIcon = null;
9228
- if (screen === "choice") {
9229
- content = /* @__PURE__ */ jsxs(React.Fragment, { children: [
9230
- button("Continue with X", () => oauth("twitter"), {
9231
- icon: "x",
9232
- primary: true
9233
- }),
9234
- button("Continue with Google", () => oauth("google"), {
10051
+ const authMethodButton = (method) => {
10052
+ if (method === "google")
10053
+ return button("Continue with Google", () => oauth("google"), {
9235
10054
  icon: "google"
9236
- }),
9237
- button(
10055
+ });
10056
+ if (method === "email")
10057
+ return button(
9238
10058
  "Continue with email",
9239
10059
  () => {
9240
- chooseFluent();
9241
- go("email");
10060
+ const gate = chooseFluent();
10061
+ if (!gate) {
10062
+ go("email");
10063
+ return;
10064
+ }
10065
+ void run(async (current) => {
10066
+ await gate;
10067
+ if (current()) go("email");
10068
+ });
9242
10069
  },
9243
10070
  {
9244
10071
  icon: "email"
9245
10072
  }
9246
- ),
9247
- button(busy ? "Signing in\u2026" : "Continue with passkey", passkey, {
9248
- icon: busy ? "spinner" : "passkey"
10073
+ );
10074
+ return button(busy ? "Signing in\u2026" : "Continue with passkey", passkey, {
10075
+ icon: busy ? "spinner" : "passkey"
10076
+ });
10077
+ };
10078
+ if (screen === "choice") {
10079
+ title = /* @__PURE__ */ jsxs("span", { className: "my-3 flex items-center justify-center gap-1.5", children: [
10080
+ /* @__PURE__ */ jsx(Icon, { name: "fluentLogomark", className: "h-5 w-auto" }),
10081
+ /* @__PURE__ */ jsx(Icon, { name: "fluentLogotype", className: "h-5 w-auto" }),
10082
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Sign in" })
10083
+ ] });
10084
+ content = /* @__PURE__ */ jsxs(React.Fragment, { children: [
10085
+ button("Continue with X", () => oauth("twitter"), {
10086
+ icon: "x",
10087
+ primary: true
9249
10088
  }),
10089
+ authMethods.map((method) => /* @__PURE__ */ jsx(React.Fragment, { children: authMethodButton(method) }, method)),
9250
10090
  showWallets ? /* @__PURE__ */ jsx(
9251
10091
  "div",
9252
10092
  {
@@ -9466,7 +10306,7 @@ function InlineConnectModal(props) {
9466
10306
  /* @__PURE__ */ jsxs(DialogHeader, { className: "items-center px-4 pt-5 pb-3 text-center", children: [
9467
10307
  headerIcon,
9468
10308
  /* @__PURE__ */ jsx("div", { ref: heading, tabIndex: -1, className: "outline-none", children: /* @__PURE__ */ jsx(DialogTitle, { children: title }) }),
9469
- /* @__PURE__ */ jsx(DialogDescription, { className: "break-words", children: description })
10309
+ /* @__PURE__ */ jsx(DialogDescription, { className: "break-words text-balance", children: description })
9470
10310
  ] }),
9471
10311
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 p-2.5", children: [
9472
10312
  content,
@@ -10031,6 +10871,25 @@ var FLUENT_TRANSACTION_DIRECTION_LABELS = {
10031
10871
  sent: "Sent",
10032
10872
  received: "Received"
10033
10873
  };
10874
+ var FLUENT_TRANSACTION_SWAP_LABEL = "Swapped";
10875
+ var FLUENT_TRANSACTION_OPERATION_LABEL = "Operation";
10876
+ function describeFluentTransaction(entry) {
10877
+ if (entry.kind === "movement") {
10878
+ return {
10879
+ title: FLUENT_TRANSACTION_DIRECTION_LABELS[entry.direction],
10880
+ counterparty: entry.counterparty,
10881
+ direction: entry.direction
10882
+ };
10883
+ }
10884
+ const [first, ...rest] = entry.movements;
10885
+ if (!first) return { title: FLUENT_TRANSACTION_OPERATION_LABEL };
10886
+ const direction = rest.every((movement) => movement.direction === first.direction) ? first.direction : void 0;
10887
+ if (!direction) return { title: FLUENT_TRANSACTION_SWAP_LABEL };
10888
+ const counterparty = rest.every(
10889
+ (movement) => movement.counterparty.toLowerCase() === first.counterparty.toLowerCase()
10890
+ ) ? first.counterparty : void 0;
10891
+ return { title: FLUENT_TRANSACTION_DIRECTION_LABELS[direction], counterparty, direction };
10892
+ }
10034
10893
  var FLUENT_TRANSACTION_STATUS_LABELS = {
10035
10894
  // A confirmed transaction is the ordinary case and says nothing worth a badge.
10036
10895
  confirmed: null,
@@ -10044,6 +10903,12 @@ function blockscoutApiUrl(explorerBaseUrl, path, params) {
10044
10903
  }
10045
10904
  return url.toString();
10046
10905
  }
10906
+ var ENTRY_POINT_ADDRESSES = new Set(
10907
+ [
10908
+ "0x0000000071727De22E5E9d8BAf0edAc6f37da032",
10909
+ "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
10910
+ ].map((address) => address.toLowerCase())
10911
+ );
10047
10912
  var EXHAUSTED_PAGE = { items: [], nextPageParams: null };
10048
10913
  async function fetchBlockscoutPage(url, signal) {
10049
10914
  const response = await fetch(url, { headers: { Accept: "application/json" }, signal });
@@ -10116,8 +10981,12 @@ function mapInternalTransaction(internal, params) {
10116
10981
  return null;
10117
10982
  }
10118
10983
  if (value === 0n) return null;
10984
+ if (internal.type === "delegatecall") return null;
10119
10985
  const movement = resolveMovement({ from: internal.from, to: internal.to, account });
10120
10986
  if (!movement?.counterparty) return null;
10987
+ if (movement.direction === "sent" && ENTRY_POINT_ADDRESSES.has(movement.counterparty.toLowerCase())) {
10988
+ return null;
10989
+ }
10121
10990
  return {
10122
10991
  kind: "movement",
10123
10992
  id: `internal:${hash}:${internal.index ?? 0}`,
@@ -10265,7 +11134,8 @@ function FluentActivityDetail({
10265
11134
  const badge = CHAIN_BADGE.l2_to_l1;
10266
11135
  const chainName = getFluentBridgeRoute(network)?.destination.name ?? "Fluent";
10267
11136
  const movement = entry.kind === "movement" ? entry : entry.movements[0];
10268
- const heading = entry.kind === "movement" ? formatFluentTransactionAmount(entry) : entry.movements.length > 0 ? entry.movements.map(formatFluentTransactionAmount).join(", ") : "Operation";
11137
+ const summary = describeFluentTransaction(entry);
11138
+ const heading = entry.kind === "movement" ? formatFluentTransactionAmount(entry) : entry.movements.length > 0 ? entry.movements.map(formatFluentTransactionAmount).join(", ") : FLUENT_TRANSACTION_OPERATION_LABEL;
10269
11139
  const openExplorer = (url, label) => {
10270
11140
  track("outbound_link_clicked", {
10271
11141
  label,
@@ -10290,7 +11160,7 @@ function FluentActivityDetail({
10290
11160
  }
10291
11161
  ),
10292
11162
  /* @__PURE__ */ jsxs("span", { className: "text-sm text-muted-foreground", children: [
10293
- entry.kind === "movement" ? FLUENT_TRANSACTION_DIRECTION_LABELS[entry.direction] : "Operation",
11163
+ summary.title,
10294
11164
  " \xB7 ",
10295
11165
  activityDateTimeFormat.format(new Date(entry.timestamp))
10296
11166
  ] })
@@ -10299,11 +11169,11 @@ function FluentActivityDetail({
10299
11169
  /* @__PURE__ */ jsxs("dl", { className: "flex flex-col gap-5 text-sm bg-neutral-900 p-4 rounded-2xl", children: [
10300
11170
  /* @__PURE__ */ jsx(DetailRow, { label: "Status", children: /* @__PURE__ */ jsx("span", { className: status.className, children: status.label }) }),
10301
11171
  /* @__PURE__ */ jsx(DetailRow, { label: "Account", children: /* @__PURE__ */ jsx("span", { title: account, children: formatAddress(account) }) }),
10302
- entry.kind === "movement" ? /* @__PURE__ */ jsx(DetailRow, { label: entry.direction === "sent" ? "To" : "From", children: /* @__PURE__ */ jsx(
11172
+ summary.counterparty ? /* @__PURE__ */ jsx(DetailRow, { label: summary.direction === "sent" ? "To" : "From", children: /* @__PURE__ */ jsx(
10303
11173
  HashMenu,
10304
11174
  {
10305
- hash: entry.counterparty,
10306
- url: explorerAddress(entry.counterparty, network),
11175
+ hash: summary.counterparty,
11176
+ url: explorerAddress(summary.counterparty, network),
10307
11177
  onOpen: (url) => openExplorer(url, "explorer"),
10308
11178
  label: "Address"
10309
11179
  }
@@ -10337,134 +11207,522 @@ function FluentActivityDetail({
10337
11207
  ] })
10338
11208
  ] });
10339
11209
  }
10340
- function Separator({
10341
- className,
10342
- orientation = "horizontal",
10343
- ...props
10344
- }) {
10345
- return /* @__PURE__ */ jsx(
10346
- Separator$1,
10347
- {
10348
- "data-slot": "separator",
10349
- orientation,
10350
- className: cn(
10351
- "shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",
10352
- className
10353
- ),
10354
- ...props
10355
- }
10356
- );
10357
- }
10358
- function FieldGroup({ className, ...props }) {
11210
+ var TooltipProvider = Tooltip$1.Provider;
11211
+ var Tooltip = Tooltip$1.Root;
11212
+ function TooltipTrigger({ className, ...props }) {
10359
11213
  return /* @__PURE__ */ jsx(
10360
- "div",
11214
+ Tooltip$1.Trigger,
10361
11215
  {
10362
- "data-slot": "field-group",
10363
- className: cn(
10364
- "group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",
10365
- className
10366
- ),
11216
+ "data-slot": "tooltip-trigger",
11217
+ className: cn("outline-none focus-visible:ring-3 focus-visible:ring-ring/50", className),
10367
11218
  ...props
10368
11219
  }
10369
11220
  );
10370
11221
  }
10371
- var fieldVariants = cva(
10372
- "group/field flex w-full gap-2 data-[invalid=true]:text-destructive",
10373
- {
10374
- variants: {
10375
- orientation: {
10376
- vertical: "flex-col *:w-full [&>.sr-only]:w-auto",
10377
- horizontal: "flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
10378
- responsive: "flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"
10379
- }
10380
- },
10381
- defaultVariants: {
10382
- orientation: "vertical"
10383
- }
10384
- }
10385
- );
10386
- function Field({
11222
+ function TooltipContent({
10387
11223
  className,
10388
- orientation = "vertical",
11224
+ children,
11225
+ side = "top",
11226
+ sideOffset = 6,
11227
+ align = "center",
11228
+ alignOffset = 0,
10389
11229
  ...props
10390
11230
  }) {
10391
- return /* @__PURE__ */ jsx(
10392
- "div",
11231
+ return /* @__PURE__ */ jsx(Tooltip$1.Portal, { container: useFluentPortalContainer(), children: /* @__PURE__ */ jsx(
11232
+ Tooltip$1.Positioner,
10393
11233
  {
10394
- role: "group",
10395
- "data-slot": "field",
10396
- "data-orientation": orientation,
10397
- className: cn(fieldVariants({ orientation }), className),
10398
- ...props
11234
+ side,
11235
+ sideOffset,
11236
+ align,
11237
+ alignOffset,
11238
+ className: "isolate z-50",
11239
+ children: /* @__PURE__ */ jsx(
11240
+ Tooltip$1.Popup,
11241
+ {
11242
+ "data-slot": "tooltip-content",
11243
+ className: cn(
11244
+ "dark relative isolate z-50 max-w-64 origin-(--transform-origin) rounded-lg border border-white/15 bg-popover px-2 py-1 text-xs text-popover-foreground shadow-xl duration-100 data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
11245
+ className
11246
+ ),
11247
+ ...props,
11248
+ children
11249
+ }
11250
+ )
10399
11251
  }
10400
- );
11252
+ ) });
10401
11253
  }
10402
- function FieldContent({ className, ...props }) {
10403
- return /* @__PURE__ */ jsx(
10404
- "div",
10405
- {
10406
- "data-slot": "field-content",
10407
- className: cn(
10408
- "group/field-content flex flex-1 flex-col gap-0.5 leading-snug",
10409
- className
10410
- ),
10411
- ...props
10412
- }
10413
- );
11254
+ function formatAmount(value, decimals) {
11255
+ if (value === void 0) return "\u2014";
11256
+ const [whole = "0", fraction = ""] = formatUnits(value, decimals).split(".");
11257
+ const trimmed = fraction.slice(0, 6).replace(/0+$/, "");
11258
+ return trimmed ? `${whole}.${trimmed}` : whole;
10414
11259
  }
10415
- function FieldLabel({
10416
- className,
10417
- ...props
11260
+ function formatUsd(usd) {
11261
+ return `$${formatFluentLocaleAmount(usd, usd >= 1 ? 2 : usd >= 0.01 ? 3 : 4)}`;
11262
+ }
11263
+ function formatAmountUsd(amount, usdPrice) {
11264
+ if (usdPrice === void 0) return void 0;
11265
+ const value = Number(amount);
11266
+ return Number.isFinite(value) && value > 0 ? formatUsd(value * usdPrice) : "$0";
11267
+ }
11268
+ var AMOUNT_MAX_PX = 24;
11269
+ var AMOUNT_MIN_PX = 14;
11270
+ var AMOUNT_CHAR_WIDTH_EM = 0.6;
11271
+ function getAmountFontStyle(value) {
11272
+ const width = (Math.max(value.length, 1) * AMOUNT_CHAR_WIDTH_EM).toFixed(2);
11273
+ return { fontSize: `clamp(${AMOUNT_MIN_PX}px, calc(100cqi / ${width}), ${AMOUNT_MAX_PX}px)` };
11274
+ }
11275
+ var AMOUNT_INPUT_CLASS = "w-full min-w-0 border-none bg-transparent p-0 font-medium leading-[1.2] text-foreground outline-none placeholder:text-foreground/40 disabled:opacity-50";
11276
+ function AmountCard({
11277
+ label,
11278
+ children,
11279
+ footer
11280
+ }) {
11281
+ return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-2.5 rounded-2xl bg-foreground/5 p-5", children: [
11282
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-foreground/60", children: label }),
11283
+ children,
11284
+ footer
11285
+ ] });
11286
+ }
11287
+ function SummaryRow({
11288
+ label,
11289
+ value,
11290
+ secondary,
11291
+ tooltip
10418
11292
  }) {
11293
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-5 text-sm", children: [
11294
+ /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 text-foreground/80", children: [
11295
+ label,
11296
+ tooltip ? /* @__PURE__ */ jsxs(Tooltip, { children: [
11297
+ /* @__PURE__ */ jsx(
11298
+ TooltipTrigger,
11299
+ {
11300
+ tabIndex: 0,
11301
+ "aria-label": `About the ${label.toLowerCase()}`,
11302
+ render: /* @__PURE__ */ jsx("span", { className: "inline-flex cursor-default rounded-sm" }),
11303
+ children: /* @__PURE__ */ jsx(CircleHelp, { className: "size-4 text-foreground/45" })
11304
+ }
11305
+ ),
11306
+ /* @__PURE__ */ jsx(TooltipContent, { children: tooltip })
11307
+ ] }) : null
11308
+ ] }),
11309
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2 text-right", children: [
11310
+ /* @__PURE__ */ jsx("span", { className: "text-foreground", children: value }),
11311
+ secondary ? /* @__PURE__ */ jsx("span", { className: "size-0.5 rounded-full bg-foreground/50" }) : null,
11312
+ secondary ? /* @__PURE__ */ jsx("span", { className: "text-foreground/60", children: secondary }) : null
11313
+ ] })
11314
+ ] });
11315
+ }
11316
+ function Spinner({ className, ...props }) {
10419
11317
  return /* @__PURE__ */ jsx(
10420
- Label,
11318
+ Loader2Icon,
10421
11319
  {
10422
- "data-slot": "field-label",
10423
- className: cn(
10424
- "group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-[>[data-slot=field]]:rounded-xl has-[>[data-slot=field]]:bg-white/10 *:data-[slot=field]:px-3.5 *:data-[slot=field]:py-3",
10425
- "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",
10426
- className
10427
- ),
11320
+ "data-slot": "spinner",
11321
+ role: "status",
11322
+ "aria-label": "Loading",
11323
+ className: cn("size-4 animate-spin", className),
10428
11324
  ...props
10429
11325
  }
10430
11326
  );
10431
11327
  }
10432
- function FieldTitle({ className, ...props }) {
11328
+ function TokenGlyph({ token, className = "size-7" }) {
11329
+ const visual = token && isFluentDefaultToken(token) ? VISUAL_BY_DEFAULT_SYMBOL[token.symbol] : void 0;
10433
11330
  return /* @__PURE__ */ jsx(
10434
- "div",
11331
+ "span",
10435
11332
  {
10436
- "data-slot": "field-label",
10437
- className: cn(
10438
- "flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50",
10439
- className
10440
- ),
10441
- ...props
11333
+ className: `flex shrink-0 items-center justify-center overflow-hidden rounded-full ${visual?.bgClassName ?? "bg-foreground/10"} ${className}`,
11334
+ children: visual ? /* @__PURE__ */ jsx(
11335
+ Icon,
11336
+ {
11337
+ name: visual.icon,
11338
+ className: visual.iconClassName.includes("text-white") ? "size-4 text-white" : "size-4"
11339
+ }
11340
+ ) : token?.logoURI ? (
11341
+ // An <img>, never inlined: the URL is an integrator's or a stranger's.
11342
+ /* @__PURE__ */ jsx("img", { src: token.logoURI, alt: "", "aria-hidden": "true", className: "size-full object-cover" })
11343
+ ) : /* @__PURE__ */ jsx("span", { className: "text-xs font-medium", children: token?.symbol.slice(0, 1) ?? "?" })
10442
11344
  }
10443
11345
  );
10444
11346
  }
10445
- function FieldDescription({ className, ...props }) {
10446
- return /* @__PURE__ */ jsx(
10447
- "p",
10448
- {
10449
- "data-slot": "field-description",
10450
- className: cn(
10451
- "text-left text-xs leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5",
10452
- "last:mt-0 nth-last-2:-mt-1",
10453
- "[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
10454
- className
11347
+ function TokenSelect({
11348
+ tokens,
11349
+ value,
11350
+ disabled,
11351
+ onChange
11352
+ }) {
11353
+ return /* @__PURE__ */ jsxs(
11354
+ Select,
11355
+ {
11356
+ value: value?.identity ?? null,
11357
+ disabled,
11358
+ onValueChange: (next) => {
11359
+ if (next) onChange(next);
11360
+ },
11361
+ children: [
11362
+ /* @__PURE__ */ jsxs(
11363
+ SelectTrigger,
11364
+ {
11365
+ "aria-label": "Token to send",
11366
+ className: "!h-11 shrink-0 gap-2 rounded-full border-0 !bg-foreground/[0.06] py-0 pl-2 pr-3.5 text-sm font-medium shadow-none hover:!bg-foreground/10 [&>svg:last-child]:size-4 [&>svg:last-child]:text-foreground/70",
11367
+ children: [
11368
+ /* @__PURE__ */ jsx(TokenGlyph, { token: value }),
11369
+ /* @__PURE__ */ jsx("span", { className: "whitespace-nowrap", children: value?.symbol ?? "No tokens" })
11370
+ ]
11371
+ }
11372
+ ),
11373
+ /* @__PURE__ */ jsx(SelectContent, { align: "end", alignItemWithTrigger: false, className: "min-w-44", children: tokens.map((candidate) => /* @__PURE__ */ jsxs(SelectItem, { value: candidate.identity, children: [
11374
+ /* @__PURE__ */ jsx(TokenGlyph, { token: candidate, className: "size-5" }),
11375
+ /* @__PURE__ */ jsx("span", { children: candidate.symbol })
11376
+ ] }, candidate.identity)) })
11377
+ ]
11378
+ }
11379
+ );
11380
+ }
11381
+ function SendTokenForm({
11382
+ tokens,
11383
+ balances,
11384
+ balancesBusy,
11385
+ accountAddress,
11386
+ usdPrices = {},
11387
+ gasTokens,
11388
+ defaultGasSymbol,
11389
+ erc20GasAvailable = true,
11390
+ sponsorshipAvailable = false,
11391
+ ethValueByToken,
11392
+ onSend,
11393
+ onSent
11394
+ }) {
11395
+ const { chain } = useFluentWidgetNetwork();
11396
+ const [identity, setIdentity] = useState(null);
11397
+ const [gasIdentity, setGasIdentity] = useState(null);
11398
+ const [recipient, setRecipient] = useState("");
11399
+ const [amount, setAmount] = useState("");
11400
+ const [sending, setSending] = useState(false);
11401
+ const [sendError, setSendError] = useState(null);
11402
+ const token = tokens.find((candidate) => candidate.identity === identity) ?? tokens[0];
11403
+ const balanceByIdentity = useMemo(
11404
+ () => new Map(balances.map((entry) => [fluentTokenIdentity(entry), entry])),
11405
+ [balances]
11406
+ );
11407
+ const balance = token ? balanceByIdentity.get(token.identity) : void 0;
11408
+ const rawBalance = balance?.status === "ready" ? balance.raw : null;
11409
+ const chosenGasToken = gasTokens.find((candidate) => candidate.identity === gasIdentity) ?? gasTokens.find((candidate) => candidate.symbol === defaultGasSymbol) ?? gasTokens[0];
11410
+ const feeToken = erc20GasAvailable ? chosenGasToken : gasTokens.find(isFluentNativeToken) ?? chosenGasToken;
11411
+ const feeBalance = feeToken ? balanceByIdentity.get(feeToken.identity) : void 0;
11412
+ const rawFeeBalance = feeBalance?.status === "ready" ? feeBalance.raw : null;
11413
+ const contracts = useMemo(
11414
+ () => new Set(
11415
+ tokens.map((candidate) => candidate.address?.toLowerCase()).filter((address) => Boolean(address))
11416
+ ),
11417
+ [tokens]
11418
+ );
11419
+ const recipientCheck = parseFluentTransferRecipient({
11420
+ input: recipient,
11421
+ self: accountAddress,
11422
+ contracts
11423
+ });
11424
+ const amountCheck = token && rawBalance !== null ? parseFluentTransferAmount({
11425
+ input: amount,
11426
+ symbol: token.symbol,
11427
+ decimals: token.decimals,
11428
+ balance: rawBalance
11429
+ }) : null;
11430
+ const balanceNote = token && rawBalance !== null ? `${formatAmount(rawBalance, token.decimals)} ${token.symbol}` : balancesBusy ? "Loading balance..." : "Balance unavailable";
11431
+ const amountUsd = token ? formatAmountUsd(amount, usdPrices[token.identity]) : void 0;
11432
+ const fee = feeToken ? checkFluentTransferFee({
11433
+ feeToken,
11434
+ feeBalance: rawFeeBalance,
11435
+ feeBalanceEthValue: getFluentGasPaymentEthValue({
11436
+ balance: feeBalance,
11437
+ ethValueByToken
11438
+ }).ethValueWei,
11439
+ sponsorshipAvailable
11440
+ }) : { status: "ok" };
11441
+ const ready = Boolean(token) && recipientCheck.status === "ok" && amountCheck?.status === "ok" && fee.status !== "blocked" && !sending;
11442
+ const handleSend = async () => {
11443
+ if (!token || !feeToken) return;
11444
+ if (recipientCheck.status !== "ok" || amountCheck?.status !== "ok") return;
11445
+ if (fee.status === "blocked") return;
11446
+ setSendError(null);
11447
+ setSending(true);
11448
+ try {
11449
+ const outcome = await onSend({
11450
+ token,
11451
+ to: recipientCheck.address,
11452
+ amount: amountCheck.raw,
11453
+ gasSymbol: feeToken.symbol
11454
+ });
11455
+ if (outcome.status === "sent") onSent();
11456
+ if (outcome.status === "failed") setSendError(outcome.message);
11457
+ } finally {
11458
+ setSending(false);
11459
+ }
11460
+ };
11461
+ return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-1 flex-col gap-4", "aria-label": "Send tokens", children: [
11462
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
11463
+ /* @__PURE__ */ jsxs(AmountCard, { label: "Send", children: [
11464
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-5", children: [
11465
+ /* @__PURE__ */ jsx("div", { className: "flex min-w-0 flex-1 flex-col [container-type:inline-size]", children: /* @__PURE__ */ jsx(
11466
+ "input",
11467
+ {
11468
+ "aria-label": `Amount of ${token?.symbol ?? "tokens"} to send`,
11469
+ className: AMOUNT_INPUT_CLASS,
11470
+ style: getAmountFontStyle(amount || "0"),
11471
+ placeholder: "0",
11472
+ inputMode: "decimal",
11473
+ autoComplete: "off",
11474
+ autoCorrect: "off",
11475
+ spellCheck: false,
11476
+ disabled: sending,
11477
+ "aria-invalid": amountCheck?.status === "rejected" ? true : void 0,
11478
+ value: amount,
11479
+ onChange: (event) => {
11480
+ setSendError(null);
11481
+ setAmount(event.target.value);
11482
+ }
11483
+ }
11484
+ ) }),
11485
+ /* @__PURE__ */ jsx(
11486
+ TokenSelect,
11487
+ {
11488
+ tokens,
11489
+ value: token,
11490
+ disabled: sending || tokens.length === 0,
11491
+ onChange: (next) => {
11492
+ setSendError(null);
11493
+ setAmount("");
11494
+ setIdentity(next);
11495
+ }
11496
+ }
11497
+ )
11498
+ ] }),
11499
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
11500
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-1 text-sm text-foreground/60", children: [
11501
+ /* @__PURE__ */ jsx("span", { children: amountUsd }),
11502
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
11503
+ /* @__PURE__ */ jsx(
11504
+ "span",
11505
+ {
11506
+ className: "tabular-nums",
11507
+ title: token && rawBalance !== null ? formatUnits(rawBalance, token.decimals) : void 0,
11508
+ children: balanceNote
11509
+ }
11510
+ ),
11511
+ /* @__PURE__ */ jsx(
11512
+ "button",
11513
+ {
11514
+ type: "button",
11515
+ className: "font-medium text-foreground/70 transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",
11516
+ disabled: sending || rawBalance === null || rawBalance === 0n,
11517
+ onClick: () => {
11518
+ if (!token || rawBalance === null) return;
11519
+ setSendError(null);
11520
+ setAmount(formatUnits(rawBalance, token.decimals));
11521
+ },
11522
+ children: "Max"
11523
+ }
11524
+ )
11525
+ ] })
11526
+ ] }),
11527
+ amountCheck?.status === "rejected" ? /* @__PURE__ */ jsx("span", { className: "text-xs text-destructive", children: amountCheck.message }) : null
11528
+ ] })
11529
+ ] }),
11530
+ /* @__PURE__ */ jsxs(AmountCard, { label: "To", children: [
11531
+ /* @__PURE__ */ jsx(
11532
+ "input",
11533
+ {
11534
+ "aria-label": "Recipient address",
11535
+ className: `${AMOUNT_INPUT_CLASS} text-sm`,
11536
+ placeholder: "0x\u2026",
11537
+ spellCheck: false,
11538
+ autoComplete: "off",
11539
+ autoCorrect: "off",
11540
+ disabled: sending,
11541
+ "aria-invalid": recipientCheck.status === "rejected" ? true : void 0,
11542
+ value: recipient,
11543
+ onChange: (event) => {
11544
+ setSendError(null);
11545
+ setRecipient(event.target.value);
11546
+ }
11547
+ }
11548
+ ),
11549
+ recipientCheck.status === "rejected" ? /* @__PURE__ */ jsx("span", { className: "text-xs text-destructive", children: recipientCheck.message }) : null
11550
+ ] })
11551
+ ] }),
11552
+ /* @__PURE__ */ jsx(TooltipProvider, { delay: 200, children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3.5 py-2", children: [
11553
+ /* @__PURE__ */ jsx(SummaryRow, { label: "Network", value: chain.name }),
11554
+ /* @__PURE__ */ jsx(
11555
+ SummaryRow,
11556
+ {
11557
+ label: "Fee paid in",
11558
+ value: erc20GasAvailable ? /* @__PURE__ */ jsxs(
11559
+ Select,
11560
+ {
11561
+ value: feeToken?.identity ?? null,
11562
+ disabled: sending || gasTokens.length === 0,
11563
+ onValueChange: (value) => {
11564
+ if (!value) return;
11565
+ setSendError(null);
11566
+ setGasIdentity(value);
11567
+ },
11568
+ children: [
11569
+ /* @__PURE__ */ jsx(
11570
+ SelectTrigger,
11571
+ {
11572
+ "aria-label": "Token the fee is paid in",
11573
+ size: "sm",
11574
+ className: "!h-auto shrink-0 border-0 bg-transparent p-0 text-sm text-foreground shadow-none dark:bg-transparent dark:hover:bg-transparent",
11575
+ children: /* @__PURE__ */ jsx("span", { children: feeToken?.symbol ?? "No fee token" })
11576
+ }
11577
+ ),
11578
+ /* @__PURE__ */ jsx(SelectContent, { align: "end", alignItemWithTrigger: false, children: gasTokens.map((candidate) => /* @__PURE__ */ jsx(SelectItem, { value: candidate.identity, children: candidate.symbol }, candidate.identity)) })
11579
+ ]
11580
+ }
11581
+ ) : feeToken?.symbol ?? "Native currency",
11582
+ secondary: erc20GasAvailable ? void 0 : "your wallet",
11583
+ tooltip: erc20GasAvailable ? `This transfer only. Your saved choice stays ${defaultGasSymbol}.` : "An external wallet has no paymaster, so it pays the network fee itself."
11584
+ }
11585
+ ),
11586
+ /* @__PURE__ */ jsxs("span", { className: "text-xs text-foreground/60", children: [
11587
+ "Sent to any address on ",
11588
+ chain.name,
11589
+ ". Transfers cannot be undone \u2014 check the address before sending."
11590
+ ] })
11591
+ ] }) }),
11592
+ fee.status !== "ok" ? /* @__PURE__ */ jsxs(
11593
+ "p",
11594
+ {
11595
+ className: `flex gap-2 rounded-xl p-3 text-xs ${fee.status === "blocked" ? "bg-destructive/10 text-destructive" : "bg-amber-400/10 text-amber-300"}`,
11596
+ role: "status",
11597
+ children: [
11598
+ /* @__PURE__ */ jsx(AlertTriangle, { className: "mt-0.5 size-4 shrink-0" }),
11599
+ /* @__PURE__ */ jsx("span", { children: fee.message })
11600
+ ]
11601
+ }
11602
+ ) : null,
11603
+ sendError ? /* @__PURE__ */ jsx("span", { className: "text-xs text-destructive", children: sendError }) : null,
11604
+ /* @__PURE__ */ jsx(Button, { className: "w-full", disabled: !ready, onClick: () => void handleSend(), children: sending ? /* @__PURE__ */ jsxs(Fragment, { children: [
11605
+ /* @__PURE__ */ jsx(Spinner, { className: "size-4" }),
11606
+ "Sending\u2026"
11607
+ ] }) : `Send ${token?.symbol ?? ""}`.trim() })
11608
+ ] });
11609
+ }
11610
+ function Separator({
11611
+ className,
11612
+ orientation = "horizontal",
11613
+ ...props
11614
+ }) {
11615
+ return /* @__PURE__ */ jsx(
11616
+ Separator$1,
11617
+ {
11618
+ "data-slot": "separator",
11619
+ orientation,
11620
+ className: cn(
11621
+ "shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",
11622
+ className
10455
11623
  ),
10456
11624
  ...props
10457
11625
  }
10458
11626
  );
10459
11627
  }
10460
- function Spinner({ className, ...props }) {
11628
+ function FieldGroup({ className, ...props }) {
10461
11629
  return /* @__PURE__ */ jsx(
10462
- Loader2Icon,
11630
+ "div",
10463
11631
  {
10464
- "data-slot": "spinner",
10465
- role: "status",
10466
- "aria-label": "Loading",
10467
- className: cn("size-4 animate-spin", className),
11632
+ "data-slot": "field-group",
11633
+ className: cn(
11634
+ "group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",
11635
+ className
11636
+ ),
11637
+ ...props
11638
+ }
11639
+ );
11640
+ }
11641
+ var fieldVariants = cva(
11642
+ "group/field flex w-full gap-2 data-[invalid=true]:text-destructive",
11643
+ {
11644
+ variants: {
11645
+ orientation: {
11646
+ vertical: "flex-col *:w-full [&>.sr-only]:w-auto",
11647
+ horizontal: "flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
11648
+ responsive: "flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"
11649
+ }
11650
+ },
11651
+ defaultVariants: {
11652
+ orientation: "vertical"
11653
+ }
11654
+ }
11655
+ );
11656
+ function Field({
11657
+ className,
11658
+ orientation = "vertical",
11659
+ ...props
11660
+ }) {
11661
+ return /* @__PURE__ */ jsx(
11662
+ "div",
11663
+ {
11664
+ role: "group",
11665
+ "data-slot": "field",
11666
+ "data-orientation": orientation,
11667
+ className: cn(fieldVariants({ orientation }), className),
11668
+ ...props
11669
+ }
11670
+ );
11671
+ }
11672
+ function FieldContent({ className, ...props }) {
11673
+ return /* @__PURE__ */ jsx(
11674
+ "div",
11675
+ {
11676
+ "data-slot": "field-content",
11677
+ className: cn(
11678
+ "group/field-content flex flex-1 flex-col gap-0.5 leading-snug",
11679
+ className
11680
+ ),
11681
+ ...props
11682
+ }
11683
+ );
11684
+ }
11685
+ function FieldLabel({
11686
+ className,
11687
+ ...props
11688
+ }) {
11689
+ return /* @__PURE__ */ jsx(
11690
+ Label,
11691
+ {
11692
+ "data-slot": "field-label",
11693
+ className: cn(
11694
+ "group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-[>[data-slot=field]]:rounded-xl has-[>[data-slot=field]]:bg-white/10 *:data-[slot=field]:px-3.5 *:data-[slot=field]:py-3",
11695
+ "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",
11696
+ className
11697
+ ),
11698
+ ...props
11699
+ }
11700
+ );
11701
+ }
11702
+ function FieldTitle({ className, ...props }) {
11703
+ return /* @__PURE__ */ jsx(
11704
+ "div",
11705
+ {
11706
+ "data-slot": "field-label",
11707
+ className: cn(
11708
+ "flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50",
11709
+ className
11710
+ ),
11711
+ ...props
11712
+ }
11713
+ );
11714
+ }
11715
+ function FieldDescription({ className, ...props }) {
11716
+ return /* @__PURE__ */ jsx(
11717
+ "p",
11718
+ {
11719
+ "data-slot": "field-description",
11720
+ className: cn(
11721
+ "text-left text-xs leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5",
11722
+ "last:mt-0 nth-last-2:-mt-1",
11723
+ "[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
11724
+ className
11725
+ ),
10468
11726
  ...props
10469
11727
  }
10470
11728
  );
@@ -10877,6 +12135,7 @@ function useFluentTransactionHistory(params) {
10877
12135
  );
10878
12136
  useEffect(() => {
10879
12137
  inFlight.current?.abort();
12138
+ inFlight.current = null;
10880
12139
  setAccumulated(EMPTY);
10881
12140
  setVisibleCount(FLUENT_TRANSACTION_HISTORY_PAGE_SIZE);
10882
12141
  setError(null);
@@ -11134,50 +12393,6 @@ function AddTokenForm({
11134
12393
  }
11135
12394
  );
11136
12395
  }
11137
- var TooltipProvider = Tooltip$1.Provider;
11138
- var Tooltip = Tooltip$1.Root;
11139
- function TooltipTrigger({ className, ...props }) {
11140
- return /* @__PURE__ */ jsx(
11141
- Tooltip$1.Trigger,
11142
- {
11143
- "data-slot": "tooltip-trigger",
11144
- className: cn("outline-none focus-visible:ring-3 focus-visible:ring-ring/50", className),
11145
- ...props
11146
- }
11147
- );
11148
- }
11149
- function TooltipContent({
11150
- className,
11151
- children,
11152
- side = "top",
11153
- sideOffset = 6,
11154
- align = "center",
11155
- alignOffset = 0,
11156
- ...props
11157
- }) {
11158
- return /* @__PURE__ */ jsx(Tooltip$1.Portal, { children: /* @__PURE__ */ jsx(
11159
- Tooltip$1.Positioner,
11160
- {
11161
- side,
11162
- sideOffset,
11163
- align,
11164
- alignOffset,
11165
- className: "isolate z-50",
11166
- children: /* @__PURE__ */ jsx(
11167
- Tooltip$1.Popup,
11168
- {
11169
- "data-slot": "tooltip-content",
11170
- className: cn(
11171
- "dark relative isolate z-50 max-w-64 origin-(--transform-origin) rounded-lg border border-white/15 bg-popover px-2 py-1 text-xs text-popover-foreground shadow-xl duration-100 data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
11172
- className
11173
- ),
11174
- ...props,
11175
- children
11176
- }
11177
- )
11178
- }
11179
- ) });
11180
- }
11181
12396
  function WalletMenuTokenList({
11182
12397
  accountAddress,
11183
12398
  balances,
@@ -11626,15 +12841,52 @@ function Notice({ title, description }) {
11626
12841
  /* @__PURE__ */ jsx("span", { className: "text-xs opacity-50", children: description })
11627
12842
  ] });
11628
12843
  }
12844
+ function PendingActivityRow({ transfer }) {
12845
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center gap-3 rounded-xl p-2.5 text-left", children: [
12846
+ /* @__PURE__ */ jsx(ActivityTokenTile, { tokenSymbol: transfer.symbol, badge: "l2_to_l1" }),
12847
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
12848
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5 text-sm font-medium leading-4", children: [
12849
+ "Sending",
12850
+ /* @__PURE__ */ jsx(Spinner, { className: "size-3 text-muted-foreground" })
12851
+ ] }),
12852
+ /* @__PURE__ */ jsxs("span", { className: "truncate leading-4 text-muted-foreground", children: [
12853
+ "To ",
12854
+ formatAddress(transfer.to)
12855
+ ] })
12856
+ ] }),
12857
+ /* @__PURE__ */ jsxs("span", { className: "shrink-0 text-sm font-medium leading-4 tabular-nums opacity-70", children: [
12858
+ "\u2212",
12859
+ formatFluentLocaleAmount(transfer.amount, 6),
12860
+ " ",
12861
+ transfer.symbol
12862
+ ] })
12863
+ ] }) });
12864
+ }
12865
+ function ActivityAmount({
12866
+ movement,
12867
+ status
12868
+ }) {
12869
+ return /* @__PURE__ */ jsx(
12870
+ "span",
12871
+ {
12872
+ className: cn(
12873
+ "text-sm font-medium leading-4 tabular-nums",
12874
+ status === "failed" ? "opacity-50 line-through" : movement.direction === "received" ? "text-green-400" : void 0
12875
+ ),
12876
+ children: formatFluentTransactionAmount(movement)
12877
+ }
12878
+ );
12879
+ }
11629
12880
  function FluentActivityRow({
11630
12881
  entry,
11631
12882
  tag,
11632
12883
  onOpen
11633
12884
  }) {
11634
12885
  const movement = entry.kind === "movement" ? entry : entry.movements[0];
11635
- const title = entry.kind === "operation" ? "Operation" : FLUENT_TRANSACTION_DIRECTION_LABELS[entry.direction];
12886
+ const movements = entry.kind === "movement" ? [entry] : entry.movements;
12887
+ const summary = describeFluentTransaction(entry);
11636
12888
  const statusLabel = FLUENT_TRANSACTION_STATUS_LABELS[entry.status];
11637
- const detail = entry.kind === "movement" ? `${entry.direction === "sent" ? "To" : "From"} ${formatAddress(entry.counterparty)}` : entry.movements.length > 0 ? entry.movements.map(formatFluentTransactionAmount).join(", ") : `Op ${formatAddress(entry.hash)}`;
12889
+ const detail = summary.counterparty ? `${summary.direction === "sent" ? "To" : "From"} ${formatAddress(summary.counterparty)}` : `Op ${formatAddress(entry.hash)}`;
11638
12890
  return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
11639
12891
  "button",
11640
12892
  {
@@ -11648,7 +12900,7 @@ function FluentActivityRow({
11648
12900
  ) : /* @__PURE__ */ jsx("span", { className: "flex size-10 shrink-0 items-center justify-center rounded-full bg-foreground/10", children: /* @__PURE__ */ jsx(Layers, { className: "size-4" }) }),
11649
12901
  /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
11650
12902
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5 text-sm font-medium leading-4", children: [
11651
- title,
12903
+ summary.title,
11652
12904
  statusLabel ? /* @__PURE__ */ jsx("span", { className: "rounded-md bg-destructive/20 px-1.5 leading-[18px] text-[10px] font-normal text-destructive -my-px", children: statusLabel }) : null,
11653
12905
  tag ? /* @__PURE__ */ jsx(AccountTag, { children: tag }) : null
11654
12906
  ] }),
@@ -11658,16 +12910,7 @@ function FluentActivityRow({
11658
12910
  detail
11659
12911
  ] })
11660
12912
  ] }),
11661
- /* @__PURE__ */ jsx("span", { className: "flex shrink-0 flex-col items-end gap-0.5", children: entry.kind === "movement" ? /* @__PURE__ */ jsx(
11662
- "span",
11663
- {
11664
- className: cn(
11665
- "text-sm font-medium leading-4 tabular-nums",
11666
- entry.status === "failed" ? "opacity-50 line-through" : entry.direction === "received" ? "text-green-400" : void 0
11667
- ),
11668
- children: formatFluentTransactionAmount(entry)
11669
- }
11670
- ) : null })
12913
+ /* @__PURE__ */ jsx("span", { className: "flex shrink-0 flex-col items-end gap-0.5", children: movements.map((item) => /* @__PURE__ */ jsx(ActivityAmount, { movement: item, status: entry.status }, item.id)) })
11671
12914
  ]
11672
12915
  }
11673
12916
  ) });
@@ -11683,8 +12926,21 @@ function WalletMenuActivityList({
11683
12926
  const twoAccounts = Boolean(
11684
12927
  fluent3.address && walletAddress && fluent3.address.toLowerCase() !== walletAddress.toLowerCase()
11685
12928
  );
12929
+ const listedHashes = useMemo(() => {
12930
+ const hashes = /* @__PURE__ */ new Set();
12931
+ for (const entry of fluent3.entries) {
12932
+ hashes.add(entry.hash.toLowerCase());
12933
+ if (entry.kind === "operation") hashes.add(entry.transactionHash.toLowerCase());
12934
+ }
12935
+ return hashes;
12936
+ }, [fluent3.entries]);
11686
12937
  const items = useMemo(() => {
11687
- const list = fluent3.entries.map((entry) => ({
12938
+ const list = (fluent3.pending ?? []).filter((transfer) => !transfer.hash || !listedHashes.has(transfer.hash.toLowerCase())).map((transfer) => ({
12939
+ id: `pending:${transfer.id}`,
12940
+ at: transfer.startedAt,
12941
+ node: /* @__PURE__ */ jsx(PendingActivityRow, { transfer }, transfer.id)
12942
+ }));
12943
+ list.push(...fluent3.entries.map((entry) => ({
11688
12944
  id: `fluent:${entry.id}`,
11689
12945
  at: entry.timestamp,
11690
12946
  node: /* @__PURE__ */ jsx(
@@ -11695,7 +12951,7 @@ function WalletMenuActivityList({
11695
12951
  onOpen: () => onOpenFluentEntry(entry)
11696
12952
  }
11697
12953
  )
11698
- }));
12954
+ })));
11699
12955
  const account = bridge?.address;
11700
12956
  if (account) {
11701
12957
  for (const row of bridge.rows) {
@@ -11714,7 +12970,7 @@ function WalletMenuActivityList({
11714
12970
  }
11715
12971
  }
11716
12972
  return list.sort((a, b) => b.at - a.at);
11717
- }, [bridge?.address, bridge?.rows, fluent3.entries, fluent3.label, onOpenBridgeRow, onOpenFluentEntry, twoAccounts]);
12973
+ }, [bridge?.address, bridge?.rows, fluent3.entries, fluent3.label, fluent3.pending, listedHashes, onOpenBridgeRow, onOpenFluentEntry, twoAccounts]);
11718
12974
  if (!fluent3.address && !walletAddress) {
11719
12975
  return /* @__PURE__ */ jsx(Notice, { title: "Not connected", description: "Connect an account to see its activity." });
11720
12976
  }
@@ -11868,6 +13124,7 @@ function ReputationNotice({
11868
13124
  ] }) : null
11869
13125
  ] });
11870
13126
  }
13127
+ var PREFERENCE_NEEDS_SMART_ACCOUNT = "Available with a Fluent smart account";
11871
13128
  function WalletMenuActionCard({
11872
13129
  track,
11873
13130
  session,
@@ -11884,16 +13141,25 @@ function WalletMenuActionCard({
11884
13141
  onConnectWithX,
11885
13142
  tab,
11886
13143
  onTabChange,
13144
+ panel,
13145
+ onPanelChange,
11887
13146
  connectedAddress,
13147
+ accountKind,
11888
13148
  externalWalletAddress,
11889
13149
  balanceRevisionCounter,
11890
13150
  userTokenStore,
11891
13151
  settingsPending = false,
11892
13152
  settingsError = null,
11893
- tokenListError = null
13153
+ tokenListError = null,
13154
+ onSendToken,
13155
+ pendingTransfers,
13156
+ onRevealAccount,
13157
+ gasContext
11894
13158
  }) {
11895
13159
  const resolvedConfig = resolveFluentWidgetConfig(config);
11896
- const [homePanel, setHomePanel] = useState("tokens");
13160
+ const [ownPanel, setOwnPanel] = useState("tokens");
13161
+ const homePanel = panel ?? ownPanel;
13162
+ const setHomePanel = onPanelChange ?? setOwnPanel;
11897
13163
  const queryClient2 = useContext(QueryClientContext);
11898
13164
  const [historyRevision, setHistoryRevision] = useState(0);
11899
13165
  const [refreshingActivity, setRefreshingActivity] = useState(false);
@@ -11947,9 +13213,11 @@ function WalletMenuActionCard({
11947
13213
  };
11948
13214
  }, [client2, session?.user.id]);
11949
13215
  const actionAddress = smartAccountAddress ?? session?.wallet.smartAccountAddress;
13216
+ const externalWalletAccount = accountKind === "eoa";
11950
13217
  const faucetAvailable = isFaucetNetwork(resolvedConfig.network);
13218
+ const faucetOffered = faucetAvailable && !externalWalletAccount;
11951
13219
  const swapperReady = resolvedConfig.swapper.enabled && Boolean(resolvedConfig.swapper.integratorId) && Boolean(resolvedConfig.swapper.dstChainId) && Boolean(resolvedConfig.swapper.dstTokenAddress);
11952
- const handleSwapper = () => {
13220
+ const handleSwapper = async () => {
11953
13221
  setActionStatus(null);
11954
13222
  if (!actionAddress) {
11955
13223
  setActionStatus("Kernel smart wallet is still preparing");
@@ -11960,6 +13228,7 @@ function WalletMenuActionCard({
11960
13228
  return;
11961
13229
  }
11962
13230
  try {
13231
+ const { openSwapperModal } = await import('@swapper-finance/deposit-sdk');
11963
13232
  openSwapperModal({
11964
13233
  integratorId: resolvedConfig.swapper.integratorId,
11965
13234
  dstChainId: resolvedConfig.swapper.dstChainId,
@@ -11979,15 +13248,27 @@ function WalletMenuActionCard({
11979
13248
  setActionStatus(error instanceof Error ? error.message : "Could not open USDnr on-ramp");
11980
13249
  }
11981
13250
  };
13251
+ const explorerTarget = externalWalletAccount ? connectedAddress : actionAddress;
11982
13252
  const handleExplorer = () => {
11983
13253
  setActionStatus(null);
11984
- if (!actionAddress) {
11985
- setActionStatus("Kernel smart wallet is still preparing");
13254
+ if (!explorerTarget) {
13255
+ setActionStatus(
13256
+ externalWalletAccount ? "Wallet address is still preparing" : "Kernel smart wallet is still preparing"
13257
+ );
11986
13258
  return;
11987
13259
  }
11988
- openExternalUrl(explorerAddress(actionAddress, resolvedConfig.network), "explorer", track);
13260
+ openExternalUrl(explorerAddress(explorerTarget, resolvedConfig.network), "explorer", track);
11989
13261
  };
11990
13262
  const accountAddress = connectedAddress ?? actionAddress;
13263
+ const handleSend = () => {
13264
+ setActionStatus(null);
13265
+ if (!accountAddress) {
13266
+ setActionStatus("Wallet address is still preparing");
13267
+ return;
13268
+ }
13269
+ track("wallet_send_opened");
13270
+ onTabChange("send");
13271
+ };
11991
13272
  const {
11992
13273
  balances,
11993
13274
  busy: balancesBusy,
@@ -12032,6 +13313,18 @@ function WalletMenuActionCard({
12032
13313
  }),
12033
13314
  [portfolioTotal, portfolioTotalYesterday]
12034
13315
  );
13316
+ const gasEthRates = useMemo(
13317
+ () => deriveFluentGasEthRates({
13318
+ tokens: gasTokens,
13319
+ usdPrices: prices,
13320
+ configured: resolvedConfig.gasPayment.ethValueByToken
13321
+ }),
13322
+ [gasTokens, prices, resolvedConfig.gasPayment.ethValueByToken]
13323
+ );
13324
+ const nativeGasToken = useMemo(
13325
+ () => gasTokens.find(isFluentNativeToken)?.symbol ?? FLUENT_WIDGET_DEFAULT_GAS_TOKEN,
13326
+ [gasTokens]
13327
+ );
12035
13328
  const portfolioDisplay = portfolioTotal === null ? null : formatFluentPortfolioTotal(portfolioTotal);
12036
13329
  const portfolioLoading = Boolean(accountAddress) && (balancesBusy || pricesBusy);
12037
13330
  const hasReadyBalances = balances.some(
@@ -12047,14 +13340,14 @@ function WalletMenuActionCard({
12047
13340
  /* @__PURE__ */ jsx(FieldLabel, { htmlFor: "silent-signing", children: /* @__PURE__ */ jsxs(Field, { orientation: "horizontal", children: [
12048
13341
  /* @__PURE__ */ jsxs(FieldContent, { children: [
12049
13342
  /* @__PURE__ */ jsx(FieldTitle, { children: "Quick sign" }),
12050
- /* @__PURE__ */ jsx(FieldDescription, { children: "Sign transactions without a confirmation popup." })
13343
+ /* @__PURE__ */ jsx(FieldDescription, { children: externalWalletAccount ? PREFERENCE_NEEDS_SMART_ACCOUNT : "Sign transactions without a confirmation popup." })
12051
13344
  ] }),
12052
13345
  /* @__PURE__ */ jsx(
12053
13346
  Switch,
12054
13347
  {
12055
13348
  id: "silent-signing",
12056
- checked: silentSigningEnabled,
12057
- disabled: settingsPending,
13349
+ checked: externalWalletAccount ? false : silentSigningEnabled,
13350
+ disabled: settingsPending || externalWalletAccount,
12058
13351
  onCheckedChange: (enabled) => {
12059
13352
  setActionStatus(null);
12060
13353
  track("wallet_silent_signing_toggled", { enabled });
@@ -12066,13 +13359,13 @@ function WalletMenuActionCard({
12066
13359
  /* @__PURE__ */ jsx(FieldLabel, { htmlFor: "gas-payment", children: /* @__PURE__ */ jsxs(Field, { orientation: "horizontal", children: [
12067
13360
  /* @__PURE__ */ jsxs(FieldContent, { children: [
12068
13361
  /* @__PURE__ */ jsx(FieldTitle, { children: "Gas payment" }),
12069
- /* @__PURE__ */ jsx(FieldDescription, { children: "Token used to pay transaction fees." })
13362
+ /* @__PURE__ */ jsx(FieldDescription, { children: externalWalletAccount ? PREFERENCE_NEEDS_SMART_ACCOUNT : "Token used to pay transaction fees." })
12070
13363
  ] }),
12071
13364
  /* @__PURE__ */ jsxs(
12072
13365
  Select,
12073
13366
  {
12074
- value: gasPaymentToken,
12075
- disabled: settingsPending,
13367
+ value: externalWalletAccount ? nativeGasToken : gasPaymentToken,
13368
+ disabled: settingsPending || externalWalletAccount,
12076
13369
  onValueChange: (value) => {
12077
13370
  if (value) {
12078
13371
  setActionStatus(null);
@@ -12101,7 +13394,7 @@ function WalletMenuActionCard({
12101
13394
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
12102
13395
  /* @__PURE__ */ jsx("span", { className: "text-xs font-medium opacity-50 uppercase", children: "Developer" }),
12103
13396
  /* @__PURE__ */ jsxs(FieldGroup, { className: "w-full gap-2", children: [
12104
- faucetAvailable ? /* @__PURE__ */ jsx(
13397
+ faucetOffered ? /* @__PURE__ */ jsx(
12105
13398
  SettingsActionField,
12106
13399
  {
12107
13400
  title: faucetBusy ? "Requesting faucet" : "Faucet",
@@ -12114,8 +13407,8 @@ function WalletMenuActionCard({
12114
13407
  SettingsActionField,
12115
13408
  {
12116
13409
  title: "Explorer",
12117
- description: "View Kernel smart wallet",
12118
- disabled: !actionAddress,
13410
+ description: externalWalletAccount ? "View account on explorer" : "View Kernel smart wallet",
13411
+ disabled: !explorerTarget,
12119
13412
  onClick: handleExplorer
12120
13413
  }
12121
13414
  )
@@ -12123,6 +13416,30 @@ function WalletMenuActionCard({
12123
13416
  ] })
12124
13417
  ] });
12125
13418
  }
13419
+ if (tab === "send") {
13420
+ if (!onSendToken) return null;
13421
+ return /* @__PURE__ */ jsx(
13422
+ SendTokenForm,
13423
+ {
13424
+ tokens: displayTokens,
13425
+ balances,
13426
+ balancesBusy,
13427
+ accountAddress,
13428
+ usdPrices: prices,
13429
+ gasTokens,
13430
+ defaultGasSymbol: gasPaymentToken,
13431
+ erc20GasAvailable: gasContext?.erc20Gas ?? true,
13432
+ sponsorshipAvailable: gasContext?.sponsorshipAvailable ?? false,
13433
+ ethValueByToken: gasEthRates,
13434
+ onSend: onSendToken,
13435
+ onSent: () => {
13436
+ setHomePanel("activity");
13437
+ onTabChange("home");
13438
+ onRevealAccount?.();
13439
+ }
13440
+ }
13441
+ );
13442
+ }
12126
13443
  if (tab === "activity") {
12127
13444
  if (!activity) return null;
12128
13445
  return activity.kind === "bridge" ? /* @__PURE__ */ jsx(
@@ -12152,14 +13469,8 @@ function WalletMenuActionCard({
12152
13469
  className: "w-full flex flex-col",
12153
13470
  children: [
12154
13471
  reputationEnabled ? /* @__PURE__ */ jsxs(TabsList, { className: "w-full", children: [
12155
- /* @__PURE__ */ jsxs(TabsTrigger, { value: "home", children: [
12156
- /* @__PURE__ */ jsx(House, { className: "size-4 shrink-0", "aria-hidden": true }),
12157
- "Home"
12158
- ] }),
12159
- /* @__PURE__ */ jsxs(TabsTrigger, { value: "reputation", children: [
12160
- /* @__PURE__ */ jsx(Medal, { className: "size-4 shrink-0", "aria-hidden": true }),
12161
- "Reputation"
12162
- ] })
13472
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "home", children: "Home" }),
13473
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "reputation", children: "Reputation" })
12163
13474
  ] }) : null,
12164
13475
  /* @__PURE__ */ jsxs(
12165
13476
  TabsContent,
@@ -12264,7 +13575,7 @@ function WalletMenuActionCard({
12264
13575
  ] })
12265
13576
  ] }) })
12266
13577
  ] }) }),
12267
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
13578
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-3 gap-2", children: [
12268
13579
  /* @__PURE__ */ jsx(
12269
13580
  Button,
12270
13581
  {
@@ -12279,6 +13590,19 @@ function WalletMenuActionCard({
12279
13590
  ] })
12280
13591
  }
12281
13592
  ),
13593
+ /* @__PURE__ */ jsx(
13594
+ Button,
13595
+ {
13596
+ variant: "secondary",
13597
+ className: "h-16 w-full",
13598
+ disabled: !accountAddress || !onSendToken,
13599
+ onClick: handleSend,
13600
+ children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-1", children: [
13601
+ /* @__PURE__ */ jsx(Icon, { name: "arrow-up-line", className: "size-4" }),
13602
+ /* @__PURE__ */ jsx("span", { children: "Send" })
13603
+ ] })
13604
+ }
13605
+ ),
12282
13606
  /* @__PURE__ */ jsx(
12283
13607
  Button,
12284
13608
  {
@@ -12342,6 +13666,7 @@ function WalletMenuActionCard({
12342
13666
  address: accountAddress,
12343
13667
  label: actionAddress ? "Fluent account" : "Wallet",
12344
13668
  entries: transactions,
13669
+ pending: pendingTransfers,
12345
13670
  busy: transactionsBusy,
12346
13671
  loadingMore: transactionsLoadingMore,
12347
13672
  hasMore: hasMoreTransactions,
@@ -13226,54 +14551,22 @@ function useBridgeDeposit({
13226
14551
  reset
13227
14552
  };
13228
14553
  }
13229
- function formatAmount(value, decimals) {
13230
- if (value === void 0) return "\u2014";
13231
- const [whole = "0", fraction = ""] = formatUnits(value, decimals).split(".");
13232
- const trimmed = fraction.slice(0, 6).replace(/0+$/, "");
13233
- return trimmed ? `${whole}.${trimmed}` : whole;
13234
- }
13235
14554
  function formatFee(wei, symbol, loading2) {
13236
14555
  if (loading2) return "Estimating\u2026";
13237
14556
  if (wei === void 0) return "\u2014";
13238
14557
  return `${formatAmount(wei, 18)} ${symbol}`;
13239
14558
  }
13240
- function formatUsd(usd) {
13241
- return `$${formatFluentLocaleAmount(usd, usd >= 1 ? 2 : usd >= 0.01 ? 3 : 4)}`;
13242
- }
13243
14559
  function formatFeeUsd(wei, usdPrice) {
13244
14560
  if (wei === void 0 || wei === 0n || usdPrice === void 0) return void 0;
13245
14561
  const usd = Number(formatUnits(wei, 18)) * usdPrice;
13246
14562
  return Number.isFinite(usd) && usd > 0 ? formatUsd(usd) : void 0;
13247
14563
  }
13248
- function formatAmountUsd(amount, usdPrice) {
13249
- if (usdPrice === void 0) return void 0;
13250
- const value = Number(amount);
13251
- return Number.isFinite(value) && value > 0 ? formatUsd(value * usdPrice) : "$0";
13252
- }
13253
- var AMOUNT_MAX_PX = 24;
13254
- var AMOUNT_MIN_PX = 14;
13255
- var AMOUNT_CHAR_WIDTH_EM = 0.6;
13256
- function getAmountFontStyle(value) {
13257
- const width = (Math.max(value.length, 1) * AMOUNT_CHAR_WIDTH_EM).toFixed(2);
13258
- return { fontSize: `clamp(${AMOUNT_MIN_PX}px, calc(100cqi / ${width}), ${AMOUNT_MAX_PX}px)` };
13259
- }
13260
14564
  var TOKEN_ICONS = {
13261
14565
  ETH: "eth",
13262
14566
  BLEND: "blend",
13263
14567
  USDnr: "usdnr",
13264
14568
  USDC: "usdc"
13265
14569
  };
13266
- function AmountCard({
13267
- label,
13268
- children,
13269
- footer
13270
- }) {
13271
- return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-2.5 rounded-2xl bg-foreground/5 p-5", children: [
13272
- /* @__PURE__ */ jsx("span", { className: "text-sm text-foreground/60", children: label }),
13273
- children,
13274
- footer
13275
- ] });
13276
- }
13277
14570
  function TokenChainIcon({ symbol, chain }) {
13278
14571
  const visual = VISUAL_BY_DEFAULT_SYMBOL[symbol];
13279
14572
  const badge = chain === "source" ? CHAIN_BADGE.l1_to_l2 : CHAIN_BADGE.l2_to_l1;
@@ -13300,7 +14593,7 @@ function TokenChip({ token }) {
13300
14593
  /* @__PURE__ */ jsx("span", { className: "text-sm font-medium leading-none whitespace-nowrap", children: token.symbol })
13301
14594
  ] });
13302
14595
  }
13303
- function TokenSelect({
14596
+ function TokenSelect2({
13304
14597
  tokens,
13305
14598
  value,
13306
14599
  onChange
@@ -13338,35 +14631,6 @@ function TokenSelect({
13338
14631
  }
13339
14632
  );
13340
14633
  }
13341
- function SummaryRow({
13342
- label,
13343
- value,
13344
- secondary,
13345
- tooltip
13346
- }) {
13347
- return /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-5 text-sm", children: [
13348
- /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 text-foreground/80", children: [
13349
- label,
13350
- tooltip ? /* @__PURE__ */ jsxs(Tooltip, { children: [
13351
- /* @__PURE__ */ jsx(
13352
- TooltipTrigger,
13353
- {
13354
- tabIndex: 0,
13355
- "aria-label": `About the ${label.toLowerCase()}`,
13356
- render: /* @__PURE__ */ jsx("span", { className: "inline-flex cursor-default rounded-sm" }),
13357
- children: /* @__PURE__ */ jsx(CircleHelp, { className: "size-4 text-foreground/45" })
13358
- }
13359
- ),
13360
- /* @__PURE__ */ jsx(TooltipContent, { children: tooltip })
13361
- ] }) : null
13362
- ] }),
13363
- /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2 text-right", children: [
13364
- /* @__PURE__ */ jsx("span", { className: "text-foreground", children: value }),
13365
- secondary ? /* @__PURE__ */ jsx("span", { className: "size-0.5 rounded-full bg-foreground/50" }) : null,
13366
- secondary ? /* @__PURE__ */ jsx("span", { className: "text-foreground/60", children: secondary }) : null
13367
- ] })
13368
- ] });
13369
- }
13370
14634
  function ApprovalSteps({
13371
14635
  currentStep,
13372
14636
  actionLabel,
@@ -13511,7 +14775,7 @@ function BridgeForm({
13511
14775
  "input",
13512
14776
  {
13513
14777
  "aria-label": `Amount to deposit in ${token.symbol}`,
13514
- className: "w-full min-w-0 border-none bg-transparent p-0 font-medium leading-[1.2] text-foreground outline-none placeholder:text-foreground/40",
14778
+ className: AMOUNT_INPUT_CLASS,
13515
14779
  style: getAmountFontStyle(form.amount || "0"),
13516
14780
  placeholder: "0",
13517
14781
  inputMode: "decimal",
@@ -13523,7 +14787,7 @@ function BridgeForm({
13523
14787
  onChange: (event) => form.setAmount(event.target.value)
13524
14788
  }
13525
14789
  ) }),
13526
- /* @__PURE__ */ jsx(TokenSelect, { tokens, value: symbol, onChange: setSymbol })
14790
+ /* @__PURE__ */ jsx(TokenSelect2, { tokens, value: symbol, onChange: setSymbol })
13527
14791
  ] }),
13528
14792
  bridge.connected || bridge.restoring ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
13529
14793
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-1 text-sm text-foreground/60", children: [
@@ -13733,6 +14997,7 @@ function BridgeScreen({
13733
14997
  // src/widget/walletMenuSubPages.ts
13734
14998
  var WALLET_MENU_SUB_PAGES = {
13735
14999
  settings: { title: "Settings" },
15000
+ send: { title: "Send" },
13736
15001
  bridge: { title: "Bridge" },
13737
15002
  activity: { title: "Transfer" }
13738
15003
  };
@@ -13757,42 +15022,6 @@ function useIsMobile() {
13757
15022
  }, []);
13758
15023
  return !!isMobile;
13759
15024
  }
13760
-
13761
- // src/core/browserStorage.ts
13762
- function resolveLocalStorage(storage) {
13763
- if (storage !== void 0) return storage;
13764
- try {
13765
- return globalThis.localStorage ?? null;
13766
- } catch {
13767
- return null;
13768
- }
13769
- }
13770
- function readStoredValue(storage, key) {
13771
- if (!storage) return null;
13772
- try {
13773
- return storage.getItem(key);
13774
- } catch {
13775
- return null;
13776
- }
13777
- }
13778
- function writeStoredValue(storage, key, value) {
13779
- if (!storage) return false;
13780
- try {
13781
- storage.setItem(key, value);
13782
- return true;
13783
- } catch {
13784
- return false;
13785
- }
13786
- }
13787
- function removeStoredValue(storage, key) {
13788
- if (!storage) return false;
13789
- try {
13790
- storage.removeItem(key);
13791
- return true;
13792
- } catch {
13793
- return false;
13794
- }
13795
- }
13796
15025
  function ReviewDialog({
13797
15026
  eyebrow,
13798
15027
  title,
@@ -13803,7 +15032,8 @@ function ReviewDialog({
13803
15032
  onCancel,
13804
15033
  children
13805
15034
  }) {
13806
- return /* @__PURE__ */ jsx(
15035
+ const topLayer = useFluentTopLayer();
15036
+ const overlay = /* @__PURE__ */ jsx(
13807
15037
  "div",
13808
15038
  {
13809
15039
  className: "fixed inset-0 z-[80] grid place-items-center bg-[#030213]/70 p-6 backdrop-blur-md",
@@ -13847,6 +15077,8 @@ function ReviewDialog({
13847
15077
  )
13848
15078
  }
13849
15079
  );
15080
+ if (!topLayer) return overlay;
15081
+ return createPortal(/* @__PURE__ */ jsx(FluentTopLayerSlot, { children: overlay }), topLayer.element);
13850
15082
  }
13851
15083
  function BatchOperationReviewModal({
13852
15084
  operation,
@@ -13925,10 +15157,193 @@ function SignatureReviewModal({
13925
15157
  ] })
13926
15158
  ] })
13927
15159
  }
13928
- );
15160
+ );
15161
+ }
15162
+ var privyPromptIsClosing = (node) => node.matches("[data-leave]") || node.querySelector(".leaving, [data-leave]") !== null;
15163
+ var TARGETS = [
15164
+ {
15165
+ // Privy mounts the prompt only while it is showing or animating away.
15166
+ find: () => document.getElementById("privy-dialog"),
15167
+ isOpen: (node) => !privyPromptIsClosing(node),
15168
+ watchAttributes: ["class", "data-leave"],
15169
+ watchSubtree: true
15170
+ },
15171
+ {
15172
+ find: () => document.querySelector("w3m-modal"),
15173
+ isOpen: (node) => node.classList.contains("open"),
15174
+ watchAttributes: ["class"]
15175
+ }
15176
+ ];
15177
+ function movePreservingState(parent, node, before) {
15178
+ const moveBefore = parent.moveBefore;
15179
+ if (typeof moveBefore === "function") {
15180
+ try {
15181
+ moveBefore.call(parent, node, before);
15182
+ return;
15183
+ } catch {
15184
+ }
15185
+ }
15186
+ parent.insertBefore(node, before);
15187
+ }
15188
+ function isModalDialog(dialog) {
15189
+ const native = /\[native code\]/.test(
15190
+ String(Object.getPrototypeOf(dialog).showModal ?? "")
15191
+ );
15192
+ if (!native) return true;
15193
+ try {
15194
+ return dialog.matches(":modal");
15195
+ } catch {
15196
+ return true;
15197
+ }
15198
+ }
15199
+ function createTopLayerElevator({
15200
+ topLayerHost,
15201
+ acquire,
15202
+ toastLayer
15203
+ }) {
15204
+ const elevated = /* @__PURE__ */ new Map();
15205
+ const watched = /* @__PURE__ */ new WeakSet();
15206
+ const targetObservers = [];
15207
+ let foreignModalWasOpen = false;
15208
+ const foreignModalDialogOpen = () => Array.from(document.querySelectorAll("dialog[open]")).some(
15209
+ (dialog) => dialog !== topLayerHost && !dialog.hasAttribute("data-fluent-top-layer") && !topLayerHost.contains(dialog) && isModalDialog(dialog)
15210
+ );
15211
+ const hostHasOwnContent = () => Array.from(topLayerHost.children).some(
15212
+ (child) => !elevated.has(child) && !child.hasAttribute("data-fluent-top-layer-anchor")
15213
+ );
15214
+ const patchParent = (parent, node, marker) => {
15215
+ const parentWithMethods = parent;
15216
+ const originalRemoveChild = parent.removeChild;
15217
+ const originalInsertBefore = parent.insertBefore;
15218
+ parentWithMethods.removeChild = function(child) {
15219
+ if (child === node && child.parentNode !== parent) {
15220
+ child.parentNode?.removeChild(child);
15221
+ settle(node);
15222
+ return child;
15223
+ }
15224
+ return originalRemoveChild.call(this, child);
15225
+ };
15226
+ parentWithMethods.insertBefore = function(newNode, ref) {
15227
+ if (ref === node && ref.parentNode !== parent) {
15228
+ return originalInsertBefore.call(this, newNode, marker);
15229
+ }
15230
+ return originalInsertBefore.call(this, newNode, ref);
15231
+ };
15232
+ return () => {
15233
+ delete parentWithMethods.removeChild;
15234
+ delete parentWithMethods.insertBefore;
15235
+ };
15236
+ };
15237
+ const settle = (node) => {
15238
+ const entry = elevated.get(node);
15239
+ if (!entry) return;
15240
+ elevated.delete(node);
15241
+ entry.unpatchParent();
15242
+ entry.placeholder.remove();
15243
+ entry.release();
15244
+ };
15245
+ const restore = (node) => {
15246
+ const entry = elevated.get(node);
15247
+ if (!entry) return;
15248
+ if (topLayerHost.contains(node) && entry.placeholder.parentNode) {
15249
+ movePreservingState(entry.placeholder.parentNode, node, entry.placeholder);
15250
+ }
15251
+ settle(node);
15252
+ };
15253
+ const elevate = (node, target) => {
15254
+ const parent = node.parentElement;
15255
+ if (!parent) return;
15256
+ const placeholder = document.createComment("fluent-top-layer-elevated");
15257
+ parent.insertBefore(placeholder, node);
15258
+ elevated.set(node, {
15259
+ target,
15260
+ placeholder,
15261
+ unpatchParent: patchParent(parent, node, placeholder),
15262
+ release: acquire()
15263
+ });
15264
+ movePreservingState(topLayerHost, node, null);
15265
+ };
15266
+ const ensureWatched = (node, target) => {
15267
+ if (!target.watchAttributes || watched.has(node)) return;
15268
+ watched.add(node);
15269
+ const observer2 = new MutationObserver(sync);
15270
+ observer2.observe(node, {
15271
+ attributes: true,
15272
+ attributeFilter: target.watchAttributes,
15273
+ subtree: target.watchSubtree ?? false
15274
+ });
15275
+ targetObservers.push(observer2);
15276
+ };
15277
+ const promoteToastLayer = (foreignModalOpen) => {
15278
+ if (!toastLayer || foreignModalOpen === foreignModalWasOpen) {
15279
+ foreignModalWasOpen = foreignModalOpen;
15280
+ return;
15281
+ }
15282
+ foreignModalWasOpen = foreignModalOpen;
15283
+ if (!foreignModalOpen) return;
15284
+ try {
15285
+ toastLayer.hidePopover?.();
15286
+ toastLayer.showPopover?.();
15287
+ } catch {
15288
+ }
15289
+ };
15290
+ const sync = () => {
15291
+ const foreignModalOpen = foreignModalDialogOpen();
15292
+ promoteToastLayer(foreignModalOpen);
15293
+ const needsElevation = foreignModalOpen || hostHasOwnContent();
15294
+ for (const [node, entry] of Array.from(elevated)) {
15295
+ if (!node.isConnected || !topLayerHost.contains(node)) {
15296
+ settle(node);
15297
+ } else if (!needsElevation || !entry.target.isOpen(node)) {
15298
+ restore(node);
15299
+ }
15300
+ }
15301
+ for (const target of TARGETS) {
15302
+ const node = target.find();
15303
+ if (!node || !node.isConnected) continue;
15304
+ ensureWatched(node, target);
15305
+ if (!needsElevation || elevated.has(node) || topLayerHost.contains(node)) continue;
15306
+ if (!target.isOpen(node)) continue;
15307
+ elevate(node, target);
15308
+ }
15309
+ };
15310
+ const observer = new MutationObserver(sync);
15311
+ observer.observe(document.documentElement, {
15312
+ childList: true,
15313
+ subtree: true,
15314
+ attributes: true,
15315
+ attributeFilter: ["open"]
15316
+ });
15317
+ sync();
15318
+ return () => {
15319
+ observer.disconnect();
15320
+ for (const targetObserver of targetObservers) targetObserver.disconnect();
15321
+ for (const node of Array.from(elevated.keys())) restore(node);
15322
+ };
15323
+ }
15324
+ function FluentTopLayerBridge() {
15325
+ const topLayer = useFluentTopLayer();
15326
+ const toastLayer = useFluentToastLayer();
15327
+ useEffect(() => {
15328
+ if (!topLayer) return;
15329
+ return createTopLayerElevator({
15330
+ topLayerHost: topLayer.element,
15331
+ acquire: topLayer.acquire,
15332
+ toastLayer
15333
+ });
15334
+ }, [topLayer, toastLayer]);
15335
+ if (!topLayer) return null;
15336
+ return createPortal(/* @__PURE__ */ jsx("span", { hidden: true, "data-fluent-top-layer-anchor": "" }), topLayer.element);
13929
15337
  }
13930
15338
  function deriveWidgetAccount(input) {
13931
- const { smartAccount, wallet, sessionUserId, sessionSmartAccountAddress, directAuth } = input;
15339
+ const {
15340
+ smartAccount,
15341
+ wallet,
15342
+ sessionUserId,
15343
+ sessionSmartAccountAddress,
15344
+ directAuth,
15345
+ walletUserPrivySession = false
15346
+ } = input;
13932
15347
  const fluentAccountAddress = smartAccount.smartAccountAddress ?? sessionSmartAccountAddress;
13933
15348
  const externalAddress = wallet?.connected && wallet.address && isAddress(wallet.address, { strict: false }) ? wallet.address : void 0;
13934
15349
  const externalConnected = Boolean(externalAddress);
@@ -13945,7 +15360,7 @@ function deriveWidgetAccount(input) {
13945
15360
  externalConnected || (directAuth ? fluentAccountReady : sessionUserId || sessionSmartAccountAddress)
13946
15361
  );
13947
15362
  const connecting = Boolean(
13948
- !hasConnectedAccount && directAuth && smartAccount.privyAuthenticated && !smartAccount.error
15363
+ !hasConnectedAccount && directAuth && smartAccount.privyAuthenticated && !walletUserPrivySession && !smartAccount.error
13949
15364
  );
13950
15365
  const restoring = Boolean(
13951
15366
  !hasConnectedAccount && !connecting && !smartAccount.error && (directAuth && !smartAccount.privyReady || wallet?.reconnecting)
@@ -14020,14 +15435,22 @@ function presentWidgetAccount(params) {
14020
15435
  };
14021
15436
  }
14022
15437
  function useWidgetAccount(input) {
14023
- const { smartAccount, wallet, sessionUserId, sessionSmartAccountAddress, directAuth } = input;
15438
+ const {
15439
+ smartAccount,
15440
+ wallet,
15441
+ sessionUserId,
15442
+ sessionSmartAccountAddress,
15443
+ directAuth,
15444
+ walletUserPrivySession = false
15445
+ } = input;
14024
15446
  return useMemo(
14025
15447
  () => deriveWidgetAccount({
14026
15448
  smartAccount,
14027
15449
  wallet,
14028
15450
  sessionUserId,
14029
15451
  sessionSmartAccountAddress,
14030
- directAuth
15452
+ directAuth,
15453
+ walletUserPrivySession
14031
15454
  }),
14032
15455
  [
14033
15456
  smartAccount.smartAccountReady,
@@ -14043,7 +15466,8 @@ function useWidgetAccount(input) {
14043
15466
  wallet?.reconnecting,
14044
15467
  sessionUserId,
14045
15468
  sessionSmartAccountAddress,
14046
- directAuth
15469
+ directAuth,
15470
+ walletUserPrivySession
14047
15471
  ]
14048
15472
  );
14049
15473
  }
@@ -14389,9 +15813,9 @@ function useWidgetExecution(params) {
14389
15813
  [chain]
14390
15814
  );
14391
15815
  const sendCalls = useCallback(
14392
- async (calls, options) => {
14393
- if (fluentAccountReady) {
14394
- const { hash, receipt, userOpHash, sponsored, sponsorshipReason, paymaster } = await smartAccount.sendCalls(calls, options);
15816
+ async (calls, options, readyAccount) => {
15817
+ if (fluentAccountReady || readyAccount) {
15818
+ const { hash, receipt, userOpHash, sponsored, sponsorshipReason, paymaster } = await smartAccount.sendCalls(calls, options, readyAccount);
14395
15819
  track("wallet_gas_sponsored", { sponsored, reason: sponsorshipReason });
14396
15820
  refreshBalances();
14397
15821
  return { hash, receipt, userOpHash, hashes: [hash], atomic: true, sponsored, paymaster };
@@ -14481,6 +15905,55 @@ function useWidgetExecution(params) {
14481
15905
  ]
14482
15906
  );
14483
15907
  }
15908
+ function useTokenTransfer(params) {
15909
+ const { widget, track, beginTransfer, settleTransfer, endTransfer } = params;
15910
+ return useCallback(
15911
+ async (request) => {
15912
+ const { token, to, amount, gasSymbol } = request;
15913
+ const pendingId = beginTransfer({
15914
+ symbol: token.symbol,
15915
+ amount: formatUnits(amount, token.decimals),
15916
+ to,
15917
+ startedAt: Date.now()
15918
+ });
15919
+ let settled = false;
15920
+ try {
15921
+ const operation = widget.createBatchOp({
15922
+ id: FLUENT_SEND_TOKEN_OP_ID,
15923
+ reviewTitle: `Send ${token.symbol}`,
15924
+ calls: [buildFluentTransferCall({ token, to, amount })]
15925
+ });
15926
+ const { hash } = await operation.execute({ gasPayment: { symbol: gasSymbol } });
15927
+ track("wallet_token_sent", {
15928
+ symbol: token.symbol,
15929
+ token_source: token.source,
15930
+ native: isFluentNativeToken(token),
15931
+ gas_symbol: gasSymbol
15932
+ });
15933
+ settleTransfer(pendingId, hash);
15934
+ settled = true;
15935
+ return { status: "sent", hash };
15936
+ } catch (error) {
15937
+ if (error instanceof FluentReviewRejectedError) {
15938
+ track("wallet_token_send_failed", { reason: "rejected" });
15939
+ return { status: "rejected" };
15940
+ }
15941
+ debugError("[FluentWidget] Token transfer failed", error);
15942
+ const message2 = error instanceof Error ? error.message : "The transfer was not sent.";
15943
+ toast.add({
15944
+ type: "error",
15945
+ title: `Could not send ${token.symbol}`,
15946
+ description: message2
15947
+ });
15948
+ track("wallet_token_send_failed", { reason: "execution_failed" });
15949
+ return { status: "failed", message: message2 };
15950
+ } finally {
15951
+ if (!settled) endTransfer(pendingId);
15952
+ }
15953
+ },
15954
+ [beginTransfer, settleTransfer, endTransfer, track, widget]
15955
+ );
15956
+ }
14484
15957
  function useZeroDevInitializer(params) {
14485
15958
  const { smartAccount, directAuth, session, widgetAccount } = params;
14486
15959
  const initRequested = useRef(false);
@@ -14888,6 +16361,9 @@ function isSettingsSubjectReady(params) {
14888
16361
  }
14889
16362
  return false;
14890
16363
  }
16364
+ function keepsSettingsPreferences(params) {
16365
+ return params.accountType !== "eoa";
16366
+ }
14891
16367
  function resolveGasTokenSymbol(params) {
14892
16368
  const { stored, available, fallback: fallback2 } = params;
14893
16369
  if (typeof stored !== "string" || stored.length === 0) return fallback2;
@@ -14907,6 +16383,9 @@ function applyUserSettings(params) {
14907
16383
  function isPendingInputFailure(err) {
14908
16384
  return err instanceof FluentAuthError && (err.code === "not_connected" || err.code === "privy_token_missing");
14909
16385
  }
16386
+ function isUnsupportedByService(err) {
16387
+ return (err instanceof FluentSettingsError || err instanceof FluentAuthError) && err.code === "request_failed" && err.status === 404;
16388
+ }
14910
16389
  function messageOf2(err) {
14911
16390
  if (err instanceof FluentSettingsError || err instanceof FluentAuthError) return err.message;
14912
16391
  if (err instanceof Error && err.message) return err.message;
@@ -14931,6 +16410,7 @@ function createUserSettingsController(options) {
14931
16410
  let client2 = null;
14932
16411
  let ready = false;
14933
16412
  let inputsKey = "";
16413
+ let keepsPreferences = true;
14934
16414
  let attemptedInputsKey = null;
14935
16415
  let phase = "unavailable";
14936
16416
  let backend = null;
@@ -14955,6 +16435,12 @@ function createUserSettingsController(options) {
14955
16435
  handlers.onChange();
14956
16436
  return;
14957
16437
  }
16438
+ if (isUnsupportedByService(err)) {
16439
+ phase = "unavailable";
16440
+ handlers.onPreferenceError(null);
16441
+ handlers.onChange();
16442
+ return;
16443
+ }
14958
16444
  phase = "unavailable";
14959
16445
  handlers.onPreferenceError(messageOf2(err));
14960
16446
  handlers.onChange();
@@ -14973,7 +16459,9 @@ function createUserSettingsController(options) {
14973
16459
  backend = store;
14974
16460
  handlers.onPreferenceError(null);
14975
16461
  handlers.onTokenError(null);
14976
- handlers.apply({ quickSign: answer.quickSign, gasTokenSymbol: answer.gasTokenSymbol });
16462
+ if (keepsPreferences) {
16463
+ handlers.apply({ quickSign: answer.quickSign, gasTokenSymbol: answer.gasTokenSymbol });
16464
+ }
14977
16465
  await importLocalUserTokensOnce({
14978
16466
  storage,
14979
16467
  key: options?.storageKey,
@@ -14990,7 +16478,9 @@ function createUserSettingsController(options) {
14990
16478
  };
14991
16479
  const queuePatch = (patch) => {
14992
16480
  const activeClient = client2;
14993
- if (!activeClient || !subject || phase !== "ready") return Promise.resolve();
16481
+ if (!activeClient || !subject) return Promise.resolve();
16482
+ if (!keepsPreferences) return Promise.resolve();
16483
+ if (phase === "idle" || phase === "loading") return Promise.resolve();
14994
16484
  const gen = generation;
14995
16485
  desired = { ...desired, ...patch };
14996
16486
  handlers.onPreferenceError(null);
@@ -15037,6 +16527,7 @@ function createUserSettingsController(options) {
15037
16527
  setTarget(next) {
15038
16528
  if (settlingHoldsSubject({ next, current: { subject, audience } })) return;
15039
16529
  audience = next.audience;
16530
+ keepsPreferences = next.keepsPreferences ?? true;
15040
16531
  if (next.subject !== subject) {
15041
16532
  invalidate();
15042
16533
  subject = next.subject;
@@ -15072,6 +16563,7 @@ function createUserSettingsController(options) {
15072
16563
  client2 = null;
15073
16564
  ready = false;
15074
16565
  inputsKey = "";
16566
+ keepsPreferences = true;
15075
16567
  phase = "unavailable";
15076
16568
  handlers.onPreferenceError(null);
15077
16569
  handlers.onTokenError(null);
@@ -15106,6 +16598,9 @@ async function revokeRefreshFamily(publicApiUrl, refreshToken) {
15106
16598
  debugWarn("[fluent widget] revoking the refresh family failed", err);
15107
16599
  }
15108
16600
  }
16601
+ function isRefreshRouteMissing(err) {
16602
+ return err.code === "request_failed" && err.status === 404;
16603
+ }
15109
16604
  async function requestAuthToken(params, state, options = {}) {
15110
16605
  const {
15111
16606
  publicApiUrl,
@@ -15183,6 +16678,12 @@ async function requestAuthToken(params, state, options = {}) {
15183
16678
  session.loaded = true;
15184
16679
  forgetRefreshCredential(storage, storageKey);
15185
16680
  };
16681
+ const revokeAbandonedFamily = (refreshToken) => {
16682
+ if (session.generation !== generation) return;
16683
+ const revoking = revokeRefreshFamily(publicApiUrl, refreshToken);
16684
+ session.pending.add(revoking);
16685
+ void revoking.then(() => session.pending.delete(revoking));
16686
+ };
15186
16687
  const exchange = async () => {
15187
16688
  let pair;
15188
16689
  if (subject.startsWith("privy:")) {
@@ -15225,8 +16726,11 @@ async function requestAuthToken(params, state, options = {}) {
15225
16726
  try {
15226
16727
  return commit(await refreshAuthToken({ publicApiUrl, refreshToken: held.refreshToken }));
15227
16728
  } catch (err) {
15228
- if (!(err instanceof FluentAuthError) || err.status !== 401) throw err;
16729
+ if (!(err instanceof FluentAuthError)) throw err;
16730
+ const routeMissing = isRefreshRouteMissing(err);
16731
+ if (err.status !== 401 && !routeMissing) throw err;
15229
16732
  forget();
16733
+ if (routeMissing) revokeAbandonedFamily(held.refreshToken);
15230
16734
  return exchange();
15231
16735
  }
15232
16736
  };
@@ -15392,6 +16896,7 @@ function useUserSettings(params) {
15392
16896
  () => isSettingsSubjectReady({ accountType, identityToken, walletAddress, hasWalletClient }),
15393
16897
  [accountType, hasWalletClient, identityToken, walletAddress]
15394
16898
  );
16899
+ const keepsPreferences = keepsSettingsPreferences({ accountType });
15395
16900
  const inputsKey = `${ready ? "1" : "0"}:${identityToken ? "1" : "0"}:${hasWalletClient ? "1" : "0"}`;
15396
16901
  const client2 = useMemo(() => {
15397
16902
  if (!subject || !publicApiUrl) return null;
@@ -15438,9 +16943,20 @@ function useUserSettings(params) {
15438
16943
  ready,
15439
16944
  inputsKey,
15440
16945
  settling,
15441
- knownSubjects
16946
+ knownSubjects,
16947
+ keepsPreferences
15442
16948
  });
15443
- }, [audience, client2, controller, inputsKey, knownSubjects, ready, settling, subjectKey]);
16949
+ }, [
16950
+ audience,
16951
+ client2,
16952
+ controller,
16953
+ inputsKey,
16954
+ keepsPreferences,
16955
+ knownSubjects,
16956
+ ready,
16957
+ settling,
16958
+ subjectKey
16959
+ ]);
15444
16960
  const held = settlingHoldsSubject({
15445
16961
  next: { subject: subjectKey, settling, knownSubjects, audience },
15446
16962
  current: { subject: controller.getSubject(), audience: controller.getAudience() }
@@ -15523,13 +17039,17 @@ function Drawer({
15523
17039
  }
15524
17040
  ) });
15525
17041
  }
15526
- function DrawerPortal({ container, ...props }) {
17042
+ function DrawerPortal({ container, children, ...props }) {
17043
+ const { modal } = useDrawer();
17044
+ const modalContainer = useFluentModalPortalContainer(container);
17045
+ const plainContainer = useFluentPortalContainer(container);
15527
17046
  return /* @__PURE__ */ jsx(
15528
17047
  Drawer$1.Portal,
15529
17048
  {
15530
17049
  "data-slot": "drawer-portal",
15531
- container: useFluentPortalContainer(container),
15532
- ...props
17050
+ container: modal === true ? modalContainer : plainContainer,
17051
+ ...props,
17052
+ children: /* @__PURE__ */ jsx(FluentTopLayerSlot, { disabled: modal !== true, children })
15533
17053
  }
15534
17054
  );
15535
17055
  }
@@ -15837,6 +17357,50 @@ function DebugPanel(props) {
15837
17357
  ] });
15838
17358
  }
15839
17359
  var FLUENT_WIDGET_DIRECT_LOGIN_INTENT_KEY = "fluent:widget:direct-login-intent:v1";
17360
+ function directLoginDialogMarksPresent() {
17361
+ try {
17362
+ if (window.sessionStorage.getItem(FLUENT_WIDGET_DIRECT_LOGIN_INTENT_KEY) !== "1") return false;
17363
+ } catch {
17364
+ return false;
17365
+ }
17366
+ return getPendingInlineOAuth() !== null;
17367
+ }
17368
+ var LINK_X_IN_PROGRESS_REFUSAL = "Linking X to your wallet is still in progress. Try again when it finishes.";
17369
+ var SETTLED_TRANSFER_GRACE_MS = 9e4;
17370
+ var LINK_X_IDENTITY_TOKEN_TIMEOUT_MS = 1e4;
17371
+ var LINK_X_SIWE_STEP_TIMEOUT_MS = LINK_X_IDENTITY_TOKEN_TIMEOUT_MS;
17372
+ var LINK_X_WALLET_SIGNATURE_TIMEOUT_MS = 5 * 6e4;
17373
+ var SIWE_TIMEOUT_LIKELY_CAUSES = "Likely causes: captcha is enabled on the Privy app, which linkX() cannot solve, or wallet login is disabled there.";
17374
+ function siweStepTimedOut(step) {
17375
+ return `Privy did not ${step} within ${LINK_X_SIWE_STEP_TIMEOUT_MS / 1e3} seconds. ${SIWE_TIMEOUT_LIKELY_CAUSES} Nothing was linked.`;
17376
+ }
17377
+ function walletSignatureTimedOut() {
17378
+ return `The wallet did not answer the signature request within ${LINK_X_WALLET_SIGNATURE_TIMEOUT_MS / 6e4} minutes. ${SIWE_TIMEOUT_LIKELY_CAUSES} Nothing was linked.`;
17379
+ }
17380
+ function privyUserNotPublished() {
17381
+ return `Privy did not publish the user it signed in within ${LINK_X_IDENTITY_TOKEN_TIMEOUT_MS / 1e3} seconds. Nothing was linked.`;
17382
+ }
17383
+ function linkXHopTimedOut() {
17384
+ return `Privy did not start the redirect to X within ${LINK_X_IDENTITY_TOKEN_TIMEOUT_MS / 1e3} seconds. Nothing was linked.`;
17385
+ }
17386
+ function isPromiseLike(value) {
17387
+ return typeof value === "object" && value !== null && typeof value.then === "function";
17388
+ }
17389
+ function bounded(work, ms, message2) {
17390
+ return new Promise((resolve, reject) => {
17391
+ const timer = setTimeout(() => reject(new FluentAuthError("link_failed", message2)), ms);
17392
+ work.then(
17393
+ (value) => {
17394
+ clearTimeout(timer);
17395
+ resolve(value);
17396
+ },
17397
+ (err) => {
17398
+ clearTimeout(timer);
17399
+ reject(err);
17400
+ }
17401
+ );
17402
+ });
17403
+ }
15840
17404
  function FluentWidgetContent({
15841
17405
  track,
15842
17406
  reportAnalyticsSession,
@@ -15910,8 +17474,27 @@ function FluentWidgetContent({
15910
17474
  setError: setHostedError
15911
17475
  } = useConnectStatus();
15912
17476
  const [balanceRevisionCounter, setBalanceRevisionCounter] = useState(0);
17477
+ const [walletMenuPanel, setWalletMenuPanel] = useState("tokens");
15913
17478
  const refreshBalances = useCallback(() => setBalanceRevisionCounter((value) => value + 1), []);
15914
17479
  const [connectOpen, setConnectOpen] = useState(() => directAuth && hasPendingInlineOAuth());
17480
+ const connectedWalletAddress = activeWallet?.connected ? activeWallet.address : void 0;
17481
+ const walletClientReady = Boolean(
17482
+ activeWallet?.address && activeWallet.walletClient?.account?.address?.toLowerCase() === activeWallet.address.toLowerCase()
17483
+ );
17484
+ const privyOwnsConnectedWallet = privyUserOwnsWallet(user, connectedWalletAddress);
17485
+ const fluentSessionNamesPrivyUser = user?.id !== void 0 && session?.user?.id === user.id;
17486
+ const linkXSiweLogins = useRef({ pending: false, userIds: /* @__PURE__ */ new Set() });
17487
+ const siweSignedInOnThisPage = linkXSiweLogins.current.pending || user?.id !== void 0 && linkXSiweLogins.current.userIds.has(user.id);
17488
+ const dialogSignInUserIds = useRef(/* @__PURE__ */ new Set());
17489
+ if (directAuth && user?.id !== void 0 && !dialogSignInUserIds.current.has(user.id) && privyUserHasExternalWallet(user) && directLoginDialogMarksPresent())
17490
+ dialogSignInUserIds.current.add(user.id);
17491
+ const dialogSignedInOnThisPage = user?.id !== void 0 && dialogSignInUserIds.current.has(user.id);
17492
+ const walletUserPrivySession = (privyUserHasExternalWallet(user) || siweSignedInOnThisPage) && !fluentSessionNamesPrivyUser && !(dialogSignedInOnThisPage && !siweSignedInOnThisPage);
17493
+ const directLoginSignInRefusal = dialogSignedInOnThisPage && walletUserPrivySession ? LINK_X_IN_PROGRESS_REFUSAL : null;
17494
+ const privySessionNow = useRef({ authenticated, walletUserPrivySession });
17495
+ privySessionNow.current = { authenticated, walletUserPrivySession };
17496
+ const logoutPrivyForLinkXRef = useRef(() => Promise.resolve());
17497
+ const embeddedWalletCount = walletUserPrivySession ? 0 : smartAccount.embeddedWalletCount;
15915
17498
  const derivedAccount = useWidgetAccount({
15916
17499
  smartAccount: {
15917
17500
  smartAccountReady: smartAccount.smartAccountReady,
@@ -15920,19 +17503,18 @@ function FluentWidgetContent({
15920
17503
  error: smartAccount.error,
15921
17504
  privyReady: smartAccount.privyReady,
15922
17505
  privyAuthenticated: smartAccount.privyAuthenticated,
15923
- embeddedWalletCount: smartAccount.embeddedWalletCount
17506
+ embeddedWalletCount
15924
17507
  },
15925
17508
  wallet: activeWallet ? {
15926
17509
  connected: activeWallet.connected,
15927
17510
  address: activeWallet.address,
15928
- hasWalletClient: Boolean(
15929
- activeWallet.address && activeWallet.walletClient?.account?.address?.toLowerCase() === activeWallet.address.toLowerCase()
15930
- ),
17511
+ hasWalletClient: walletClientReady,
15931
17512
  reconnecting: activeWallet.reconnecting
15932
17513
  } : null,
15933
17514
  sessionUserId: session?.user?.id,
15934
17515
  sessionSmartAccountAddress: session?.wallet?.smartAccountAddress,
15935
- directAuth
17516
+ directAuth,
17517
+ walletUserPrivySession
15936
17518
  });
15937
17519
  const walletConnected = Boolean(activeWallet?.connected);
15938
17520
  const account = presentWidgetAccount({
@@ -15972,7 +17554,8 @@ function FluentWidgetContent({
15972
17554
  silentSigningEnabled
15973
17555
  });
15974
17556
  const { resetInitialization } = useZeroDevInitializer({
15975
- smartAccount,
17557
+ // The same count the account model reads: a wallet's own Privy session initializes nothing.
17558
+ smartAccount: { ...smartAccount, embeddedWalletCount },
15976
17559
  directAuth,
15977
17560
  session,
15978
17561
  widgetAccount
@@ -16097,6 +17680,7 @@ function FluentWidgetContent({
16097
17680
  const completeDirectAuthorization = useCallback(async () => {
16098
17681
  if (!directAuth || !authenticated || !user?.id || directAuthInFlight.current) return;
16099
17682
  if (disconnectingRef.current) return;
17683
+ if (walletUserPrivySession) return;
16100
17684
  if (session && !directAuthRequested.current && session.user?.id === user.id) return;
16101
17685
  if (!identityToken) {
16102
17686
  setWalletStatus("Waiting for Privy identity token");
@@ -16134,9 +17718,11 @@ function FluentWidgetContent({
16134
17718
  setWalletStatus("Wallet connected!");
16135
17719
  setConnectOpen(false);
16136
17720
  setDirectAuthRequested(false);
17721
+ clearInlineOAuth();
16137
17722
  } catch (error) {
16138
17723
  const message2 = error instanceof Error ? error.message : "Could not create Fluent session";
16139
17724
  setDirectAuthRequested(false);
17725
+ clearInlineOAuth();
16140
17726
  track("connect_login_failed", { reason: "direct_auth_failed" });
16141
17727
  debugError("[fluent widget] direct auth failed", error);
16142
17728
  setHostedError(message2);
@@ -16157,22 +17743,23 @@ function FluentWidgetContent({
16157
17743
  smartAccount.kernel,
16158
17744
  smartAccount.refresh,
16159
17745
  smartAccount.signerAddress,
16160
- user
17746
+ user,
17747
+ walletUserPrivySession
16161
17748
  ]);
16162
17749
  useEffect(() => {
16163
17750
  if (!directAuth) return;
16164
17751
  if (disconnectingRef.current) return;
16165
17752
  if (!privyReady || !authenticated) return;
16166
- if (smartAccount.embeddedWalletCount === 0) return;
17753
+ if (embeddedWalletCount === 0) return;
16167
17754
  completeDirectAuthorization();
16168
17755
  }, [
16169
17756
  authenticated,
16170
17757
  completeDirectAuthorization,
16171
17758
  directAuth,
17759
+ embeddedWalletCount,
16172
17760
  identityToken,
16173
17761
  privyReady,
16174
17762
  session,
16175
- smartAccount.embeddedWalletCount,
16176
17763
  smartAccount.smartAccountAddress,
16177
17764
  smartAccount.smartAccountReady
16178
17765
  ]);
@@ -16181,16 +17768,32 @@ function FluentWidgetContent({
16181
17768
  pendingPrivyLoginRef.current = false;
16182
17769
  login();
16183
17770
  }, [authenticated, login, pendingPrivyLoginRef, privyReady]);
16184
- const startDirectFluentLogin = useCallback(() => {
17771
+ const startDirectFluentLogin = useCallback(async () => {
16185
17772
  setHostedError(null);
16186
- setWalletStatus("Opening Fluent Connect ID");
16187
- setDirectAuthRequested(true);
16188
- if (authenticated) {
17773
+ const live = privySessionNow.current;
17774
+ if (live.authenticated && !live.walletUserPrivySession) {
17775
+ setWalletStatus("Opening Fluent Connect ID");
17776
+ setDirectAuthRequested(true);
16189
17777
  completeDirectAuthorization();
16190
17778
  return;
16191
17779
  }
17780
+ if (live.walletUserPrivySession) {
17781
+ setWalletStatus("Signing the wallet's Privy session out");
17782
+ try {
17783
+ await logoutPrivyForLinkXRef.current();
17784
+ } catch (error) {
17785
+ const message2 = error instanceof Error ? error.message : "Privy did not sign the previous session out.";
17786
+ debugWarn("[fluent widget] could not sign the wallet's Privy session out", error);
17787
+ setDirectAuthRequested(false);
17788
+ setHostedError(message2);
17789
+ setWalletStatus(message2);
17790
+ throw error instanceof Error ? error : new Error(message2);
17791
+ }
17792
+ }
17793
+ setWalletStatus("Opening Fluent Connect ID");
17794
+ setDirectAuthRequested(true);
16192
17795
  setConnectOpen(true);
16193
- }, [authenticated, completeDirectAuthorization, setDirectAuthRequested]);
17796
+ }, [completeDirectAuthorization, setDirectAuthRequested]);
16194
17797
  useEffect(() => {
16195
17798
  if (!directAuth || inlineLoginRequest <= handledInlineLoginRequest.current) return;
16196
17799
  handledInlineLoginRequest.current = inlineLoginRequest;
@@ -16201,14 +17804,14 @@ function FluentWidgetContent({
16201
17804
  const handleConnectWithX = useCallback(async () => {
16202
17805
  await handleDisconnect({ awaitAuthSession: false });
16203
17806
  if (directAuth) {
16204
- startDirectFluentLogin();
17807
+ void startDirectFluentLogin().catch(() => void 0);
16205
17808
  return;
16206
17809
  }
16207
17810
  openConnectFlow();
16208
17811
  }, [directAuth, handleDisconnect, openConnectFlow, startDirectFluentLogin]);
16209
17812
  const signInWithFluent = useCallback(() => {
16210
17813
  if (directAuth) {
16211
- startDirectFluentLogin();
17814
+ void startDirectFluentLogin().catch(() => void 0);
16212
17815
  return;
16213
17816
  }
16214
17817
  openConnectFlow();
@@ -16231,6 +17834,45 @@ function FluentWidgetContent({
16231
17834
  refreshBalances,
16232
17835
  track
16233
17836
  });
17837
+ const [pendingTransfers, setPendingTransfers] = useState([]);
17838
+ const pendingTransferCount = useRef(0);
17839
+ const beginTransfer = useCallback(
17840
+ (transfer) => {
17841
+ const id = `pending-${pendingTransferCount.current += 1}`;
17842
+ setPendingTransfers((list) => [...list, { ...transfer, id }]);
17843
+ setWalletMenuPanel("activity");
17844
+ return id;
17845
+ },
17846
+ []
17847
+ );
17848
+ const endTransfer = useCallback((id) => {
17849
+ setPendingTransfers((list) => list.filter((transfer) => transfer.id !== id));
17850
+ }, []);
17851
+ const settleTransfer = useCallback(
17852
+ (id, hash) => {
17853
+ setPendingTransfers(
17854
+ (list) => list.map((transfer) => transfer.id === id ? { ...transfer, hash } : transfer)
17855
+ );
17856
+ setTimeout(() => endTransfer(id), SETTLED_TRANSFER_GRACE_MS);
17857
+ },
17858
+ [endTransfer]
17859
+ );
17860
+ const sendToken = useTokenTransfer({
17861
+ widget: widgetApi,
17862
+ track,
17863
+ beginTransfer,
17864
+ settleTransfer,
17865
+ endTransfer
17866
+ });
17867
+ const gasContext = useMemo(
17868
+ () => resolveFluentTransferGasContext({
17869
+ fluentAccountAddress,
17870
+ walletConnected,
17871
+ sponsorshipUrl: resolvedConfig.sponsorshipUrl,
17872
+ appId: resolvedConfig.appId
17873
+ }),
17874
+ [fluentAccountAddress, walletConnected, resolvedConfig.appId, resolvedConfig.sponsorshipUrl]
17875
+ );
16234
17876
  const { getAuthToken, requestSponsorshipToken, endAuthSession: endAuthSession2 } = useAuthToken(
16235
17877
  {
16236
17878
  publicApiUrl: resolvedConfig.publicApiUrl,
@@ -16246,8 +17888,381 @@ function FluentWidgetContent({
16246
17888
  },
16247
17889
  authTokenState
16248
17890
  );
17891
+ const identityTokenRef = useRef(identityToken);
17892
+ const identityTokenWaiters = useRef([]);
17893
+ useEffect(() => {
17894
+ identityTokenRef.current = identityToken;
17895
+ const waiters = identityTokenWaiters.current;
17896
+ if (waiters.length === 0) return;
17897
+ identityTokenWaiters.current = [];
17898
+ for (const resolve of waiters) resolve(identityToken);
17899
+ }, [identityToken]);
17900
+ const refreshIdentityToken = useCallback(async () => {
17901
+ const before = identityTokenRef.current;
17902
+ await refreshUser();
17903
+ if (identityTokenRef.current !== before) return identityTokenRef.current;
17904
+ return new Promise((resolve, reject) => {
17905
+ const waiter = (token) => {
17906
+ clearTimeout(timer);
17907
+ resolve(token);
17908
+ };
17909
+ const timer = setTimeout(() => {
17910
+ identityTokenWaiters.current = identityTokenWaiters.current.filter(
17911
+ (pending2) => pending2 !== waiter
17912
+ );
17913
+ reject(
17914
+ new FluentAuthError(
17915
+ "link_failed",
17916
+ "Privy did not publish a fresh identity token after the link."
17917
+ )
17918
+ );
17919
+ }, LINK_X_IDENTITY_TOKEN_TIMEOUT_MS);
17920
+ identityTokenWaiters.current = [...identityTokenWaiters.current, waiter];
17921
+ });
17922
+ }, [refreshUser]);
17923
+ const privyHasLinkedX = privyUserHasLinkedX(user?.linkedAccounts);
17924
+ const linkXReturnWaiter = useRef(null);
17925
+ const settleLinkXReturn = useCallback((signal) => {
17926
+ const waiting = linkXReturnWaiter.current;
17927
+ if (!waiting) return false;
17928
+ linkXReturnWaiter.current = null;
17929
+ waiting.settle(signal);
17930
+ return true;
17931
+ }, []);
17932
+ const linkXHopWaiter = useRef(null);
17933
+ const settleLinkXHop = useCallback((error) => {
17934
+ const waiting = linkXHopWaiter.current;
17935
+ if (!waiting) return false;
17936
+ linkXHopWaiter.current = null;
17937
+ waiting.reject(error);
17938
+ return true;
17939
+ }, []);
17940
+ const { linkTwitter } = useLinkAccount({
17941
+ onError: (code) => {
17942
+ const error = toLinkXPrivyError(code);
17943
+ debugWarn("[fluent widget] linking X failed", { code, fluentCode: error.code });
17944
+ if (settleLinkXHop(error)) return;
17945
+ if (!settleLinkXReturn({ status: "error", error })) {
17946
+ clearLinkXMarker(resolveSessionStorage());
17947
+ }
17948
+ }
17949
+ });
17950
+ const connectedWalletClient = activeWallet?.walletClient;
17951
+ const linkXWallet = connectedWalletAddress && walletClientReady && connectedWalletClient ? {
17952
+ address: connectedWalletAddress,
17953
+ chainId: chain.id,
17954
+ signMessage: (message2) => bounded(
17955
+ connectedWalletClient.signMessage({
17956
+ account: connectedWalletAddress,
17957
+ message: message2
17958
+ }),
17959
+ LINK_X_WALLET_SIGNATURE_TIMEOUT_MS,
17960
+ walletSignatureTimedOut()
17961
+ )
17962
+ } : null;
17963
+ const privySignedOut = !authenticated && user === null;
17964
+ const privySignedOutWaiters = useRef([]);
17965
+ useEffect(() => {
17966
+ if (!privySignedOut) return;
17967
+ linkXSiweLogins.current.userIds.clear();
17968
+ dialogSignInUserIds.current.clear();
17969
+ const waiters = privySignedOutWaiters.current;
17970
+ if (waiters.length === 0) return;
17971
+ privySignedOutWaiters.current = [];
17972
+ for (const resolve of waiters) resolve();
17973
+ }, [privySignedOut]);
17974
+ const logoutPrivyForLinkX = useCallback(() => {
17975
+ return new Promise((resolve, reject) => {
17976
+ let settled = false;
17977
+ let timer;
17978
+ let waiter = null;
17979
+ const settle = (answer) => {
17980
+ if (settled) return;
17981
+ settled = true;
17982
+ clearTimeout(timer);
17983
+ privySignedOutWaiters.current = privySignedOutWaiters.current.filter(
17984
+ (pending2) => pending2 !== waiter
17985
+ );
17986
+ answer();
17987
+ };
17988
+ const signedOut = () => {
17989
+ linkXSiweLogins.current.userIds.clear();
17990
+ dialogSignInUserIds.current.clear();
17991
+ resolve();
17992
+ };
17993
+ timer = setTimeout(() => {
17994
+ settle(
17995
+ () => reject(new FluentAuthError("link_failed", "Privy did not sign the previous session out."))
17996
+ );
17997
+ }, LINK_X_IDENTITY_TOKEN_TIMEOUT_MS);
17998
+ linkXInputs.current.logout().then(
17999
+ () => {
18000
+ if (settled) return;
18001
+ if (linkXInputs.current.privySignedOut) {
18002
+ settle(signedOut);
18003
+ return;
18004
+ }
18005
+ waiter = () => settle(signedOut);
18006
+ privySignedOutWaiters.current = [...privySignedOutWaiters.current, waiter];
18007
+ },
18008
+ (err) => settle(() => reject(err))
18009
+ );
18010
+ });
18011
+ }, []);
18012
+ useEffect(() => {
18013
+ logoutPrivyForLinkXRef.current = logoutPrivyForLinkX;
18014
+ }, [logoutPrivyForLinkX]);
18015
+ const privyUserWaiters = useRef([]);
18016
+ useEffect(() => {
18017
+ const waiters = privyUserWaiters.current;
18018
+ if (waiters.length === 0) return;
18019
+ privyUserWaiters.current = [];
18020
+ for (const check of waiters) check();
18021
+ }, [authenticated, user?.id]);
18022
+ const awaitPrivyUserPublished = useCallback((subject) => {
18023
+ const published = () => {
18024
+ const live = linkXInputs.current;
18025
+ return live.authenticated && live.privyUserId === subject;
18026
+ };
18027
+ if (published()) return Promise.resolve();
18028
+ return new Promise((resolve, reject) => {
18029
+ const check = () => {
18030
+ if (!published()) {
18031
+ privyUserWaiters.current = [...privyUserWaiters.current, check];
18032
+ return;
18033
+ }
18034
+ clearTimeout(timer);
18035
+ resolve();
18036
+ };
18037
+ const timer = setTimeout(() => {
18038
+ privyUserWaiters.current = privyUserWaiters.current.filter((pending2) => pending2 !== check);
18039
+ reject(new FluentAuthError("link_failed", privyUserNotPublished()));
18040
+ }, LINK_X_IDENTITY_TOKEN_TIMEOUT_MS);
18041
+ privyUserWaiters.current = [...privyUserWaiters.current, check];
18042
+ });
18043
+ }, []);
18044
+ const linkTwitterForLinkX = useCallback(
18045
+ async (subject) => {
18046
+ await awaitPrivyUserPublished(subject);
18047
+ return new Promise((resolve, reject) => {
18048
+ let settled = false;
18049
+ const settle = (answer) => {
18050
+ if (settled) return;
18051
+ settled = true;
18052
+ clearTimeout(timer);
18053
+ if (linkXHopWaiter.current?.reject === rejectHop) linkXHopWaiter.current = null;
18054
+ answer();
18055
+ };
18056
+ const rejectHop = (error) => settle(() => reject(error));
18057
+ const timer = setTimeout(() => {
18058
+ rejectHop(new FluentAuthError("link_failed", linkXHopTimedOut()));
18059
+ }, LINK_X_IDENTITY_TOKEN_TIMEOUT_MS);
18060
+ linkXHopWaiter.current = { reject: rejectHop };
18061
+ let started;
18062
+ try {
18063
+ started = linkXInputs.current.linkTwitter();
18064
+ } catch (err) {
18065
+ settle(() => reject(err));
18066
+ return;
18067
+ }
18068
+ if (isPromiseLike(started)) {
18069
+ started.then(
18070
+ () => settle(resolve),
18071
+ (err) => settle(() => reject(err))
18072
+ );
18073
+ } else {
18074
+ settle(resolve);
18075
+ }
18076
+ });
18077
+ },
18078
+ [awaitPrivyUserPublished]
18079
+ );
18080
+ const linkXInputs = useRef({
18081
+ accountKind: void 0,
18082
+ privyUserId: void 0,
18083
+ privyUser: null,
18084
+ sessionUserId: void 0,
18085
+ privyReady: false,
18086
+ authenticated: false,
18087
+ privySignedOut: true,
18088
+ privyOwnsWallet: false,
18089
+ hasLinkedX: false,
18090
+ hasWalletClient: false,
18091
+ wallet: null,
18092
+ identityToken: null,
18093
+ getAuthToken,
18094
+ getAccessToken,
18095
+ getIdentityToken: refreshIdentityToken,
18096
+ linkTwitter,
18097
+ logout
18098
+ });
18099
+ linkXInputs.current = {
18100
+ accountKind: widgetAccount.type,
18101
+ privyUserId: user?.id,
18102
+ privyUser: authenticated && user ? user : null,
18103
+ sessionUserId: session?.user?.id,
18104
+ privyReady,
18105
+ authenticated,
18106
+ privySignedOut,
18107
+ privyOwnsWallet: privyOwnsConnectedWallet,
18108
+ hasLinkedX: privyHasLinkedX,
18109
+ hasWalletClient: walletClientReady,
18110
+ wallet: linkXWallet,
18111
+ identityToken,
18112
+ getAuthToken,
18113
+ getAccessToken,
18114
+ getIdentityToken: refreshIdentityToken,
18115
+ linkTwitter,
18116
+ logout
18117
+ };
18118
+ const linkXSiwe = useRef(null);
18119
+ const linkXSiweOrRefuse = () => {
18120
+ const source = linkXSiwe.current;
18121
+ if (source) return source;
18122
+ throw new FluentAuthError(
18123
+ "link_failed",
18124
+ "A Fluent ID is signed in on this page. Linking X for the connected external wallet would sign it out; disconnect the Fluent ID first, or link X as the Fluent ID."
18125
+ );
18126
+ };
18127
+ const linkXReturnState = (subject) => {
18128
+ const live = linkXInputs.current;
18129
+ const privyRestored = live.authenticated && live.privyUserId !== void 0;
18130
+ if (privyRestored && live.privyUserId !== subject) return "foreign";
18131
+ const fluentIdPage = live.sessionUserId !== void 0;
18132
+ if (!privyRestored) {
18133
+ if (live.privyReady && !fluentIdPage && live.accountKind === "eoa") return "foreign";
18134
+ return "waiting";
18135
+ }
18136
+ if (live.accountKind === "smart") {
18137
+ return live.sessionUserId === subject && live.hasLinkedX ? "ready" : "waiting";
18138
+ }
18139
+ if (live.accountKind === "eoa" && !fluentIdPage) {
18140
+ if (!live.privyOwnsWallet) return "foreign";
18141
+ return live.hasLinkedX && live.hasWalletClient ? "ready" : "waiting";
18142
+ }
18143
+ return "waiting";
18144
+ };
18145
+ const settleLinkXReturnFor = (subject) => {
18146
+ switch (linkXReturnState(subject)) {
18147
+ case "ready":
18148
+ return settleLinkXReturn({ status: "linked" });
18149
+ case "foreign":
18150
+ return settleLinkXReturn({ status: "discarded" });
18151
+ case "waiting":
18152
+ return false;
18153
+ }
18154
+ };
18155
+ useEffect(() => {
18156
+ const waiting = linkXReturnWaiter.current;
18157
+ if (!waiting) return;
18158
+ settleLinkXReturnFor(waiting.subject);
18159
+ }, [
18160
+ authenticated,
18161
+ privyHasLinkedX,
18162
+ privyOwnsConnectedWallet,
18163
+ privyReady,
18164
+ session,
18165
+ settleLinkXReturn,
18166
+ user?.id,
18167
+ walletClientReady,
18168
+ widgetAccount.type
18169
+ ]);
18170
+ const awaitLinkXReturn = useCallback(
18171
+ (subject) => new Promise((settle) => {
18172
+ linkXReturnWaiter.current = { subject, settle };
18173
+ settleLinkXReturnFor(subject);
18174
+ }),
18175
+ // Same reason as the effect: the conditions are read from the ref, not captured.
18176
+ // eslint-disable-next-line react-hooks/exhaustive-deps
18177
+ []
18178
+ );
18179
+ const linkX = useCallback(async () => {
18180
+ if (resolvedConfig.authMode !== "direct") {
18181
+ throw new FluentAuthError(
18182
+ "hosted_not_supported",
18183
+ `linkX() needs authMode: "direct" \u2014 in hosted mode the user's Privy session lives on the authorize page, not in this page.`
18184
+ );
18185
+ }
18186
+ const storage = resolveSessionStorage();
18187
+ const stored = readLinkXMarker(storage);
18188
+ if (stored.kind === "invalid") {
18189
+ debugWarn("[fluent widget] dropped a stored value that is not a link-X marker");
18190
+ throw linkXIntentDiscardedError();
18191
+ }
18192
+ if (stored.kind === "marker") {
18193
+ const signal = await awaitLinkXReturn(stored.marker.subject);
18194
+ clearLinkXMarker(storage);
18195
+ if (signal.status === "error") throw signal.error;
18196
+ if (signal.status === "discarded") {
18197
+ debugWarn("[fluent widget] dropped a link-X marker of another subject");
18198
+ throw linkXIntentDiscardedError();
18199
+ }
18200
+ }
18201
+ const live = linkXInputs.current;
18202
+ return requestLinkX({
18203
+ authMode: resolvedConfig.authMode,
18204
+ accountKind: live.accountKind,
18205
+ subject: live.privyUserId,
18206
+ wallet: live.wallet,
18207
+ siwe: {
18208
+ session: live.privyUser,
18209
+ fluentSessionUserId: live.sessionUserId,
18210
+ logout: logoutPrivyForLinkX,
18211
+ // Thunks on purpose: Privy's functions of the render that is current when each is
18212
+ // called, not of the one this `linkX()` started on. See `linkXSiwe`.
18213
+ // Each Privy step bounded (`LINK_X_SIWE_STEP_TIMEOUT_MS`): one that never answers is a
18214
+ // `link_failed` naming the likely cause, not a promise the integrator holds forever.
18215
+ generateSiweMessage: (input) => bounded(
18216
+ linkXSiweOrRefuse().generateSiweMessage(input),
18217
+ LINK_X_SIWE_STEP_TIMEOUT_MS,
18218
+ siweStepTimedOut("generate the sign-in message")
18219
+ ),
18220
+ // Marked in flight before Privy is asked, and the user it signed in remembered, so
18221
+ // the renders Privy makes of that user read as a wallet's session, never a Fluent ID's.
18222
+ // See `walletUserPrivySession`. Both follow Privy's own answer, not the bound: a login
18223
+ // Privy completes after the bound ran out still signs somebody in on this page, and
18224
+ // that somebody is a wallet's session here as much as one signed in on time. Until
18225
+ // Privy answers, the flag stays up.
18226
+ loginWithSiwe: (input) => {
18227
+ const logins = linkXSiweLogins.current;
18228
+ logins.pending = true;
18229
+ let login2;
18230
+ try {
18231
+ login2 = linkXSiweOrRefuse().loginWithSiwe(input);
18232
+ } catch (err) {
18233
+ logins.pending = false;
18234
+ throw err;
18235
+ }
18236
+ void login2.then(
18237
+ (signedIn) => {
18238
+ if (typeof signedIn?.id === "string") logins.userIds.add(signedIn.id);
18239
+ logins.pending = false;
18240
+ },
18241
+ () => {
18242
+ logins.pending = false;
18243
+ }
18244
+ );
18245
+ return bounded(login2, LINK_X_SIWE_STEP_TIMEOUT_MS, siweStepTimedOut("sign the wallet in"));
18246
+ }
18247
+ },
18248
+ publicApiUrl: resolvedConfig.publicApiUrl,
18249
+ readIdentityToken: () => linkXInputs.current.identityToken,
18250
+ getAuthToken: () => linkXInputs.current.getAuthToken(),
18251
+ getAccessToken: () => linkXInputs.current.getAccessToken(),
18252
+ getIdentityToken: () => linkXInputs.current.getIdentityToken(),
18253
+ linkTwitter: linkTwitterForLinkX,
18254
+ storage
18255
+ });
18256
+ }, [
18257
+ awaitLinkXReturn,
18258
+ linkTwitterForLinkX,
18259
+ logoutPrivyForLinkX,
18260
+ resolvedConfig.authMode,
18261
+ resolvedConfig.publicApiUrl
18262
+ ]);
16249
18263
  const sessionPrivyUserId = directAuth ? session?.user?.id : void 0;
16250
18264
  const fluentIdRebuilding = Boolean(sessionPrivyUserId) && smartAccount.smartAccountEnabled && !derivedAccount.fluentAccountReady && !smartAccount.error;
18265
+ const settingsAccountKind = fluentIdRebuilding ? void 0 : widgetAccount.type;
16251
18266
  const {
16252
18267
  userTokenStore,
16253
18268
  settingsPending,
@@ -16261,7 +18276,7 @@ function FluentWidgetContent({
16261
18276
  appId: resolvedConfig.appId,
16262
18277
  authMode: resolvedConfig.authMode,
16263
18278
  network: resolvedConfig.network,
16264
- accountType: fluentIdRebuilding ? void 0 : widgetAccount.type,
18279
+ accountType: settingsAccountKind,
16265
18280
  defaultGasToken: resolvedConfig.gasPayment.defaultToken,
16266
18281
  // The session names the same person through the ticks on which the rebuilt
16267
18282
  // Privy cannot yet, so the held subject stays a known one.
@@ -16317,6 +18332,7 @@ function FluentWidgetContent({
16317
18332
  connecting,
16318
18333
  refreshBalances,
16319
18334
  getAuthToken,
18335
+ linkX,
16320
18336
  authMode: resolvedConfig.authMode
16321
18337
  }),
16322
18338
  [
@@ -16332,142 +18348,173 @@ function FluentWidgetContent({
16332
18348
  connecting,
16333
18349
  refreshBalances,
16334
18350
  getAuthToken,
18351
+ linkX,
16335
18352
  resolvedConfig.authMode
16336
18353
  ]
16337
18354
  );
16338
18355
  const accountAvatarUrl = resolvedConfig.avatar.forceDefault || accountMenuIsExternalWallet ? void 0 : getHighResTwitterAvatar(user?.twitter?.profilePictureUrl);
16339
18356
  const defaultLogoUrl = resolvedConfig.avatar.defaultLogoUrl;
16340
- const widget = /* @__PURE__ */ jsx(FluentPortalContainerProvider, { children: /* @__PURE__ */ jsxs(Toaster, { children: [
16341
- /* @__PURE__ */ jsx("div", { className: WIDGET_STYLE_SCOPE, children: /* @__PURE__ */ jsx(
16342
- FluentAccountDrawer,
16343
- {
16344
- accountOpen,
16345
- setAccountOpen,
16346
- hasConnectedAccount,
16347
- isMobile,
16348
- accountMenuAddress,
16349
- onAccountMenuAction: handleAccountMenuAction,
16350
- subPageTitle: subPage?.title ?? null,
16351
- onCloseSubPage: closeSubPage,
16352
- userLogoUrl: accountAvatarUrl,
16353
- defaultLogoUrl,
16354
- connectButton: /* @__PURE__ */ jsx(
16355
- FluentConnectButtonSlot,
18357
+ const widget = /* @__PURE__ */ jsxs(FluentPortalContainerProvider, { children: [
18358
+ /* @__PURE__ */ jsx(FluentTopLayerBridge, {}),
18359
+ !session && connectedWalletAddress !== void 0 ? /* @__PURE__ */ jsx(LinkXSiweSource, { source: linkXSiwe }) : null,
18360
+ /* @__PURE__ */ jsxs(Toaster, { children: [
18361
+ /* @__PURE__ */ jsx("div", { className: WIDGET_STYLE_SCOPE, children: /* @__PURE__ */ jsx(
18362
+ FluentAccountDrawer,
18363
+ {
18364
+ accountOpen,
18365
+ setAccountOpen,
18366
+ hasConnectedAccount,
18367
+ isMobile,
18368
+ accountMenuAddress,
18369
+ onAccountMenuAction: handleAccountMenuAction,
18370
+ subPageTitle: subPage?.title ?? null,
18371
+ onCloseSubPage: closeSubPage,
18372
+ userLogoUrl: accountAvatarUrl,
18373
+ defaultLogoUrl,
18374
+ connectButton: /* @__PURE__ */ jsx(
18375
+ FluentConnectButtonSlot,
18376
+ {
18377
+ hasConnectedAccount,
18378
+ connecting,
18379
+ externalWalletConnected: account.walletConnected,
18380
+ connectedAddress,
18381
+ fluentAccountAddress,
18382
+ onTopConnectClick: handleTopConnectClick,
18383
+ openConnect,
18384
+ openAccount: openAccountMenu,
18385
+ renderConnectButton,
18386
+ connectButton,
18387
+ userLogoUrl: accountAvatarUrl,
18388
+ defaultLogoUrl
18389
+ }
18390
+ ),
18391
+ children: isWalletMenuCardTab(walletMenuTab) ? /* @__PURE__ */ jsx(
18392
+ WalletMenuActionCard,
18393
+ {
18394
+ track,
18395
+ session,
18396
+ smartAccountAddress: fluentAccountAddress,
18397
+ connectedAddress,
18398
+ accountKind: settingsAccountKind,
18399
+ externalWalletAddress: activeWallet?.connected ? activeWallet.address : void 0,
18400
+ faucetBusy,
18401
+ onFaucet: claimFaucet,
18402
+ config,
18403
+ tokens,
18404
+ gasPaymentToken,
18405
+ onGasPaymentTokenChange: handleGasPaymentTokenChange,
18406
+ silentSigningEnabled: silentSigningChecked,
18407
+ onSilentSigningChange: handleSilentSigningChange,
18408
+ onDisconnect: requestDisconnect,
18409
+ onConnectWithX: handleConnectWithX,
18410
+ tab: walletMenuTab,
18411
+ onTabChange: setWalletMenuTab,
18412
+ balanceRevisionCounter,
18413
+ userTokenStore,
18414
+ settingsPending,
18415
+ settingsError: preferenceError,
18416
+ tokenListError: tokenError,
18417
+ panel: walletMenuPanel,
18418
+ onPanelChange: setWalletMenuPanel,
18419
+ onSendToken: sendToken,
18420
+ pendingTransfers,
18421
+ onRevealAccount: () => setAccountOpen(true),
18422
+ gasContext
18423
+ }
18424
+ ) : /* @__PURE__ */ jsx(
18425
+ BridgeScreen,
18426
+ {
18427
+ config,
18428
+ recipient: fluentAccountAddress,
18429
+ onSignIn: signInWithFluent,
18430
+ track
18431
+ }
18432
+ )
18433
+ }
18434
+ ) }),
18435
+ /* @__PURE__ */ jsx(FluentWidgetProvider, { value: context, children: mode === "page" ? renderPage?.(context) : renderHome?.(context) }),
18436
+ /* @__PURE__ */ jsxs("div", { className: WIDGET_STYLE_SCOPE, children: [
18437
+ showDebugPayload && mode === "home" ? /* @__PURE__ */ jsx(
18438
+ DebugPanel,
16356
18439
  {
16357
- hasConnectedAccount,
16358
- connecting,
16359
- externalWalletConnected: account.walletConnected,
16360
- connectedAddress,
16361
- fluentAccountAddress,
16362
- onTopConnectClick: handleTopConnectClick,
16363
- openConnect,
16364
- openAccount: openAccountMenu,
16365
- renderConnectButton,
16366
- connectButton,
16367
- userLogoUrl: accountAvatarUrl,
16368
- defaultLogoUrl
18440
+ session,
18441
+ wallet: activeWallet,
18442
+ walletStatus,
18443
+ hostedError
16369
18444
  }
16370
- ),
16371
- children: isWalletMenuCardTab(walletMenuTab) ? /* @__PURE__ */ jsx(
16372
- WalletMenuActionCard,
18445
+ ) : null,
18446
+ /* @__PURE__ */ jsx(
18447
+ ConnectChoiceModal,
16373
18448
  {
16374
- track,
16375
- session,
16376
- smartAccountAddress: fluentAccountAddress,
16377
- connectedAddress,
16378
- externalWalletAddress: activeWallet?.connected ? activeWallet.address : void 0,
16379
- faucetBusy,
16380
- onFaucet: claimFaucet,
18449
+ open: connectOpen,
18450
+ onClose: () => {
18451
+ setConnectOpen(false);
18452
+ if (directAuth) setDirectAuthRequested(false);
18453
+ },
18454
+ onRetry: () => {
18455
+ setHostedError(null);
18456
+ void completeDirectAuthorization();
18457
+ },
18458
+ wallet: activeWallet,
18459
+ fluentReady: directAuth ? privyReady : true,
18460
+ authMode: resolvedConfig.authMode,
18461
+ walletUserPrivySession,
18462
+ signInRefusal: directLoginSignInRefusal,
16381
18463
  config,
16382
- tokens,
16383
- gasPaymentToken,
16384
- onGasPaymentTokenChange: handleGasPaymentTokenChange,
16385
- silentSigningEnabled: silentSigningChecked,
16386
- onSilentSigningChange: handleSilentSigningChange,
16387
- onDisconnect: requestDisconnect,
16388
- onConnectWithX: handleConnectWithX,
16389
- tab: walletMenuTab,
16390
- onTabChange: setWalletMenuTab,
16391
- balanceRevisionCounter,
16392
- userTokenStore,
16393
- settingsPending,
16394
- settingsError: preferenceError,
16395
- tokenListError: tokenError
18464
+ fluentAuthorizeUrl: directAuth ? void 0 : hostedAuthorizeUrl,
18465
+ hostedError: hostedError ?? smartAccount.error?.message,
18466
+ track,
18467
+ onExternalWalletSelected: () => {
18468
+ externalWalletAnalytics.current.intent = true;
18469
+ },
18470
+ onFluentLogin: () => {
18471
+ track("connect_login_started");
18472
+ if (directAuth) return startDirectFluentLogin();
18473
+ setWalletStatus("Opening hosted Fluent Connect ID");
18474
+ return void 0;
18475
+ }
16396
18476
  }
16397
- ) : /* @__PURE__ */ jsx(
16398
- BridgeScreen,
18477
+ ),
18478
+ /* @__PURE__ */ jsx(
18479
+ BatchOperationReviewModal,
16399
18480
  {
16400
- config,
16401
- recipient: fluentAccountAddress,
16402
- onSignIn: signInWithFluent,
16403
- track
18481
+ operation: batchReview,
18482
+ onConfirm: () => {
18483
+ const wasSend = batchReview?.id === FLUENT_SEND_TOKEN_OP_ID;
18484
+ acceptBatchReview();
18485
+ if (!wasSend) return;
18486
+ setWalletMenuTab("home");
18487
+ setAccountOpen(true);
18488
+ },
18489
+ onCancel: rejectBatchReview
16404
18490
  }
16405
- )
16406
- }
16407
- ) }),
16408
- /* @__PURE__ */ jsx(FluentWidgetProvider, { value: context, children: mode === "page" ? renderPage?.(context) : renderHome?.(context) }),
16409
- /* @__PURE__ */ jsxs("div", { className: WIDGET_STYLE_SCOPE, children: [
16410
- showDebugPayload && mode === "home" ? /* @__PURE__ */ jsx(
16411
- DebugPanel,
16412
- {
16413
- session,
16414
- wallet: activeWallet,
16415
- walletStatus,
16416
- hostedError
16417
- }
16418
- ) : null,
16419
- /* @__PURE__ */ jsx(
16420
- ConnectChoiceModal,
16421
- {
16422
- open: connectOpen,
16423
- onClose: () => {
16424
- setConnectOpen(false);
16425
- if (directAuth) setDirectAuthRequested(false);
16426
- },
16427
- onRetry: () => {
16428
- setHostedError(null);
16429
- void completeDirectAuthorization();
16430
- },
16431
- wallet: activeWallet,
16432
- fluentReady: directAuth ? privyReady : true,
16433
- authMode: resolvedConfig.authMode,
16434
- config,
16435
- fluentAuthorizeUrl: directAuth ? void 0 : hostedAuthorizeUrl,
16436
- hostedError: hostedError ?? smartAccount.error?.message,
16437
- track,
16438
- onExternalWalletSelected: () => {
16439
- externalWalletAnalytics.current.intent = true;
16440
- },
16441
- onFluentLogin: () => {
16442
- track("connect_login_started");
16443
- if (directAuth) {
16444
- startDirectFluentLogin();
16445
- return;
16446
- }
16447
- setWalletStatus("Opening hosted Fluent Connect ID");
18491
+ ),
18492
+ /* @__PURE__ */ jsx(
18493
+ SignatureReviewModal,
18494
+ {
18495
+ review: signatureReview,
18496
+ onConfirm: acceptSignatureReview,
18497
+ onCancel: rejectSignatureReview
16448
18498
  }
16449
- }
16450
- ),
16451
- /* @__PURE__ */ jsx(
16452
- BatchOperationReviewModal,
16453
- {
16454
- operation: batchReview,
16455
- onConfirm: acceptBatchReview,
16456
- onCancel: rejectBatchReview
16457
- }
16458
- ),
16459
- /* @__PURE__ */ jsx(
16460
- SignatureReviewModal,
16461
- {
16462
- review: signatureReview,
16463
- onConfirm: acceptSignatureReview,
16464
- onCancel: rejectSignatureReview
16465
- }
16466
- )
18499
+ )
18500
+ ] })
16467
18501
  ] })
16468
- ] }) });
18502
+ ] });
16469
18503
  return widget;
16470
18504
  }
18505
+ function LinkXSiweSource({
18506
+ source
18507
+ }) {
18508
+ const { generateSiweMessage, loginWithSiwe } = useLoginWithSiwe();
18509
+ source.current = { generateSiweMessage, loginWithSiwe };
18510
+ useEffect(
18511
+ () => () => {
18512
+ source.current = null;
18513
+ },
18514
+ [source]
18515
+ );
18516
+ return null;
18517
+ }
16471
18518
  var SILENT_SIGNING_REMOUNT_MS = 220;
16472
18519
  function FluentWidget(props) {
16473
18520
  setDebugLogging(props.debugLogging ?? false);
@@ -16496,7 +18543,6 @@ function FluentWidget(props) {
16496
18543
  const connectedPresentation = useRef(
16497
18544
  createConnectedPresentationState()
16498
18545
  );
16499
- const silentSigningEnabledRef = useRef(FLUENT_CONNECT_DEFAULT_SILENT_SIGNING);
16500
18546
  const resolvedNetwork = resolvedConfig.network;
16501
18547
  const privyClientId = resolvedConfig.privyClientId;
16502
18548
  const analyticsContext = useRef({});
@@ -16593,20 +18639,21 @@ function FluentWidget(props) {
16593
18639
  headless: resolvedConfig.authMode === "direct",
16594
18640
  ...createFluentConnectPrivyConfig({
16595
18641
  network: resolvedNetwork,
16596
- showWalletUIs: !silentSigningEnabled,
16597
- logo: props.config?.assets?.fluentLogo ?? FLUENT_CONNECT_DEFAULT_ASSETS.fluentLogo
18642
+ logo: props.config?.assets?.fluentLogo ?? FLUENT_CONNECT_DEFAULT_ASSETS.fluentLogo,
18643
+ customOAuthRedirectUrl: resolvedConfig.customOAuthRedirectUrl
16598
18644
  })
16599
18645
  }),
16600
- [props.config?.assets?.fluentLogo, resolvedConfig.authMode, resolvedNetwork, silentSigningEnabled]
18646
+ [
18647
+ props.config?.assets?.fluentLogo,
18648
+ resolvedConfig.authMode,
18649
+ resolvedConfig.customOAuthRedirectUrl,
18650
+ resolvedNetwork
18651
+ ]
16601
18652
  );
16602
18653
  useLayoutEffect(() => {
16603
18654
  clearPrivyRecentLoginMethod(FLUENT_CONNECT_PRIVY_APP_ID);
16604
- }, [privyEpoch, silentSigningEnabled]);
18655
+ }, [privyEpoch]);
16605
18656
  const applySilentSigningEnabled = useCallback((enabled) => {
16606
- if (silentSigningEnabledRef.current !== enabled) {
16607
- silentSigningEnabledRef.current = enabled;
16608
- connectedPresentation.current.rebuilding = connectedPresentation.current.connected;
16609
- }
16610
18657
  setSilentSigningEnabled(enabled);
16611
18658
  }, []);
16612
18659
  const commitSilentSigningEnabled = useCallback(
@@ -16651,17 +18698,17 @@ function FluentWidget(props) {
16651
18698
  };
16652
18699
  }, []);
16653
18700
  return /* @__PURE__ */ jsx(FluentWidgetNetworkProvider, { network: resolvedNetwork, children: /* @__PURE__ */ jsx(
16654
- PrivyProvider,
18701
+ ReownProvider,
16655
18702
  {
16656
- appId: FLUENT_CONNECT_PRIVY_APP_ID,
16657
- clientId: privyClientId,
16658
- config: privyConfig,
18703
+ network: resolvedNetwork,
18704
+ disableAnalytics: resolvedConfig.disableAnalytics,
18705
+ reconnectOnMount: resolvedConfig.reconnectOnMount,
16659
18706
  children: /* @__PURE__ */ jsx(
16660
- ReownProvider,
18707
+ PrivyProvider,
16661
18708
  {
16662
- network: resolvedNetwork,
16663
- disableAnalytics: resolvedConfig.disableAnalytics,
16664
- reconnectOnMount: resolvedConfig.reconnectOnMount,
18709
+ appId: FLUENT_CONNECT_PRIVY_APP_ID,
18710
+ clientId: privyClientId,
18711
+ config: privyConfig,
16665
18712
  children: /* @__PURE__ */ jsx(
16666
18713
  FluentWidgetContent,
16667
18714
  {
@@ -16688,13 +18735,13 @@ function FluentWidget(props) {
16688
18735
  connectedPresentation
16689
18736
  }
16690
18737
  )
16691
- }
18738
+ },
18739
+ `${resolvedNetwork}-${privyEpoch}`
16692
18740
  )
16693
- },
16694
- `${resolvedNetwork}:${silentSigningEnabled ? "silent-signing" : "prompt-signing"}-${privyEpoch}`
18741
+ }
16695
18742
  ) });
16696
18743
  }
16697
18744
 
16698
- export { AccountAvatar, Button, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, FLUENT_CONNECT_DEFAULT_ASSETS, FLUENT_GAS_PAYMENT_DEFAULT_ETH_RATES, FLUENT_USER_TOKEN_LIMIT, FLUENT_WIDGET_DEFAULT_GAS_TOKEN, FLUENT_WIDGET_SESSION_STORAGE_KEY, FLUENT_WIDGET_USER_TOKENS_IMPORT_MARKER_KEY, FLUENT_WIDGET_USER_TOKENS_STORAGE_KEY, FLUENT_ZERODEV_ERC20_PAYMASTER_QUERY, FLUENT_ZERODEV_PAYMASTER_DEMO_RECIPIENT, FluentAccountDrawer, FluentAuthError, FluentIframeRpcError, FluentPortalContainerProvider, FluentReviewRejectedError, FluentSettingsError, FluentSponsorshipFallbackError, FluentWidget, FluentWidgetConnectButton, FluentWidgetNetworkProvider, Icon, Label, Separator, Switch, WIDGET_STYLE_SCOPE, WalletMenuActionCard, buttonVariants, clearPrivyRecentLoginMethod, createFluentBackendUserTokenStore, createFluentBatchOp, createFluentClient, createFluentFamiliesClient, createFluentIframeBridge, createFluentIframeRpcHandler, createFluentPermissionApi, createFluentPermissionClient, createFluentPermissionPolicyBuilders, createFluentPermissionSession, createFluentSettingsClient, createFluentSponsorshipRpcUrl, createFluentUserTokenStore, createFluentZeroDevErc20Paymaster, createFluentZeroDevErc20PaymasterApprovalCall, createFluentZeroDevErc20PaymasterClient, createFluentZeroDevErc20PaymasterRpcUrl, createFluentZeroDevPermissionSession, createFluentZeroDevRpcUrl, createFluentZeroDevSponsoredPaymaster, findFluentSymbolCollisions, fluent2 as fluent, apps as fluentApps, fluentBridgeAbi, fluent as fluentChain, fluentChains, fluentDefinitionToViemChain, integrations as fluentIntegrations, l1Chains as fluentL1Chains, fluentMainnet, fluentMainnetTokenDefaults, fluentTestnet, fluentTestnetTokenDefaults, fluentTokenIdentity, fluentZeroDevChainIds, getApp, getContractAddressFromChain, getFluentChain, getFluentChainByChainId, getFluentChainForNetwork, getFluentDefaultWidgetDisplayTokens, getFluentDefaultWidgetGasTokens, getFluentExplorerBaseUrl, getFluentGasPaymentEthValue, getFluentGasPaymentTokens, getFluentGasPaymentValueTier, getFluentGasTokenAddress, getFluentTokenDefaults, getFluentTokenDefaultsForNetwork, getFluentZeroDevErc20PaymasterTokens, getL1Chain, getL1ForFluentChain, getZeroDevRpcUrl, getZerodevIntegration, isFaucetNetwork, isFluentDefaultToken, isFluentNativeToken, isFluentZeroDevChain, l1DefinitionToViemChain, mergeFluentDisplayTokens, normalizeFluentWidgetNetwork, readFluentTokenBalances, readFluentTokenMetadata, registryVersion, resolveBridgeAddresses, resolveDefaultGasToken, resolveFluentWidgetNetworkFromEnv, resolveFluentZeroDevErc20PaymasterToken, resolveL1Definition, selectFluentGasPaymentToken, sendFluentZeroDevErc20PaymasterDemo, sortFluentGasTokens, useFluentIframeBridge, useFluentUserTokens, useFluentWidget, useFluentWidgetNetwork, useFluentZeroDevAccount, useWidget, withFluentSignaturePrompt };
18745
+ export { AccountAvatar, Button, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, FLUENT_CONNECT_DEFAULT_ASSETS, FLUENT_GAS_PAYMENT_DEFAULT_ETH_RATES, FLUENT_USER_TOKEN_LIMIT, FLUENT_WIDGET_DEFAULT_GAS_TOKEN, FLUENT_WIDGET_SESSION_STORAGE_KEY, FLUENT_WIDGET_USER_TOKENS_IMPORT_MARKER_KEY, FLUENT_WIDGET_USER_TOKENS_STORAGE_KEY, FLUENT_ZERODEV_ERC20_PAYMASTER_QUERY, FLUENT_ZERODEV_PAYMASTER_DEMO_RECIPIENT, FluentAccountDrawer, FluentAuthError, FluentIframeRpcError, FluentPortalContainerProvider, FluentReviewRejectedError, FluentSettingsError, FluentSponsorshipFallbackError, FluentWidget, FluentWidgetConnectButton, FluentWidgetNetworkProvider, Icon, Label, Separator, Switch, WIDGET_STYLE_SCOPE, WalletMenuActionCard, buildFluentTransferCall, buttonVariants, checkFluentTransferFee, clearPrivyRecentLoginMethod, createFluentBackendUserTokenStore, createFluentBatchOp, createFluentClient, createFluentFamiliesClient, createFluentIframeBridge, createFluentIframeRpcHandler, createFluentPermissionApi, createFluentPermissionClient, createFluentPermissionPolicyBuilders, createFluentPermissionSession, createFluentSettingsClient, createFluentSponsorshipRpcUrl, createFluentUserTokenStore, createFluentZeroDevErc20Paymaster, createFluentZeroDevErc20PaymasterApprovalCall, createFluentZeroDevErc20PaymasterClient, createFluentZeroDevErc20PaymasterRpcUrl, createFluentZeroDevPermissionSession, createFluentZeroDevRpcUrl, createFluentZeroDevSponsoredPaymaster, deriveFluentGasEthRates, findFluentSymbolCollisions, fluent2 as fluent, apps as fluentApps, fluentBridgeAbi, fluent as fluentChain, fluentChains, fluentDefinitionToViemChain, integrations as fluentIntegrations, l1Chains as fluentL1Chains, fluentMainnet, fluentMainnetTokenDefaults, fluentTestnet, fluentTestnetTokenDefaults, fluentTokenIdentity, fluentTransferAbi, fluentZeroDevChainIds, getApp, getContractAddressFromChain, getFluentChain, getFluentChainByChainId, getFluentChainForNetwork, getFluentDefaultWidgetDisplayTokens, getFluentDefaultWidgetGasTokens, getFluentExplorerBaseUrl, getFluentGasPaymentEthValue, getFluentGasPaymentTokens, getFluentGasPaymentValueTier, getFluentGasTokenAddress, getFluentTokenDefaults, getFluentTokenDefaultsForNetwork, getFluentZeroDevErc20PaymasterTokens, getL1Chain, getL1ForFluentChain, getZeroDevRpcUrl, getZerodevIntegration, isFaucetNetwork, isFluentDefaultToken, isFluentNativeToken, isFluentZeroDevChain, l1DefinitionToViemChain, mergeFluentDisplayTokens, normalizeFluentWidgetNetwork, parseFluentTransferAmount, parseFluentTransferRecipient, readFluentTokenBalances, readFluentTokenMetadata, registryVersion, resolveBridgeAddresses, resolveDefaultGasToken, resolveFluentWidgetNetworkFromEnv, resolveFluentZeroDevErc20PaymasterToken, resolveL1Definition, selectFluentGasPaymentToken, sendFluentZeroDevErc20PaymasterDemo, sortFluentGasTokens, useFluentIframeBridge, useFluentUserTokens, useFluentWidget, useFluentWidgetNetwork, useFluentZeroDevAccount, useLinkX, useWidget, withFluentSignaturePrompt };
16699
18746
  //# sourceMappingURL=index.js.map
16700
18747
  //# sourceMappingURL=index.js.map