@tuwaio/nova-connect 1.0.0-fix-test-alpha.54.7152f59 → 1.0.0-fix-test-alpha.56.a984de3

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.
@@ -1,8 +1,35 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ToastPosition } from 'react-toastify';
3
- import { ISatelliteConnectStore } from '@tuwaio/satellite-core';
2
+ import { ComponentPropsWithoutRef, ComponentType, ReactNode } from 'react';
3
+ import { ToastContainer, toast, ToastPosition } from 'react-toastify';
4
+ import { OrbitAdapter } from '@tuwaio/orbit-core';
5
+ import { ISatelliteConnectStore, BaseWallet } from '@tuwaio/satellite-core';
4
6
  import { StoreApi } from 'zustand/index';
5
- import { ReactNode } from 'react';
7
+
8
+ /**
9
+ * @description
10
+ * This interface is intentionally left empty.
11
+ * Other packages (@tuwaio/satellite-*) will use module
12
+ * augmentation to add their specific wallet types here.
13
+ */
14
+ interface AllWallets {
15
+ }
16
+ /**
17
+ * @description
18
+ * This interface is intentionally left empty.
19
+ * It will be augmented by satellite packages.
20
+ */
21
+ interface AllConnectors {
22
+ }
23
+ /**
24
+ * Union type for all supported wallet types.
25
+ * It's created from the values of the AllWallets interface.
26
+ * e.g., { evm: EVMWallet, solana: SolanaWallet } -> EVMWallet | SolanaWallet
27
+ */
28
+ type Wallet = AllWallets[keyof AllWallets];
29
+ /**
30
+ * Union type for all supported connector types.
31
+ */
32
+ type Connector = AllConnectors[keyof AllConnectors];
6
33
 
7
34
  /**
8
35
  * Type definitions for NovaConnect component translations
@@ -101,39 +128,217 @@ type NovaConnectLabels = {
101
128
  impersonateAddressConnected: string;
102
129
  };
103
130
 
104
- /**
105
- * @description
106
- * This interface is intentionally left empty.
107
- * Other packages (@tuwaio/satellite-*) will use module
108
- * augmentation to add their specific wallet types here.
109
- */
110
- interface AllWallets {
131
+ type ButtonTxStatus = 'idle' | 'loading' | 'succeed' | 'failed' | 'replaced';
132
+ type ConnectContentType = 'network' | 'connectors' | 'about' | 'getWallet' | 'connecting' | 'impersonate';
133
+ type ConnectedContentType = 'main' | 'transactions' | 'chains';
134
+ interface NovaConnectProviderProps$1 {
135
+ store: StoreApi<ISatelliteConnectStore<Connector, Wallet>>;
136
+ children: React.ReactNode;
137
+ labels?: Partial<NovaConnectLabels>;
111
138
  }
112
- /**
113
- * @description
114
- * This interface is intentionally left empty.
115
- * It will be augmented by satellite packages.
116
- */
117
- interface AllConnectors {
139
+ interface NovaConnectProviderType {
140
+ activeWallet: BaseWallet | undefined;
141
+ walletConnectionError: string | undefined;
142
+ isConnectModalOpen: boolean;
143
+ setIsConnectModalOpen: (value: boolean) => void;
144
+ isConnectedModalOpen: boolean;
145
+ setIsConnectedModalOpen: (value: boolean) => void;
146
+ isChainsListOpen: boolean;
147
+ setIsChainsListOpen: (value: boolean) => void;
148
+ isChainsListOpenMobile: boolean;
149
+ setIsChainsListOpenMobile: (value: boolean) => void;
150
+ connectedButtonStatus: ButtonTxStatus;
151
+ setConnectedButtonStatus: (value: ButtonTxStatus) => void;
152
+ isConnected: boolean;
153
+ setIsConnected: (value: boolean) => void;
154
+ connectedModalContentType: ConnectedContentType;
155
+ setConnectedModalContentType: (value: ConnectedContentType) => void;
156
+ connectModalContentType: ConnectContentType;
157
+ setConnectModalContentType: (value: ConnectContentType) => void;
158
+ selectedAdapter: OrbitAdapter | undefined;
159
+ setSelectedAdapter: (value: OrbitAdapter | undefined) => void;
160
+ activeConnector: string | undefined;
161
+ setActiveConnector: (value: string | undefined) => void;
162
+ impersonatedAddress: string;
163
+ setImpersonatedAddress: (value: string) => void;
118
164
  }
165
+
166
+ type CustomIconProps = {
167
+ isCopied: boolean;
168
+ className?: string;
169
+ style?: React.CSSProperties;
170
+ 'aria-hidden'?: boolean;
171
+ };
172
+ type CustomTitleProps = {
173
+ title: string;
174
+ titleId: string;
175
+ className?: string;
176
+ style?: React.CSSProperties;
177
+ };
178
+ type CustomDescriptionProps = {
179
+ rawError: string;
180
+ descriptionId: string;
181
+ className?: string;
182
+ style?: React.CSSProperties;
183
+ };
184
+ type CustomButtonContentProps = {
185
+ icon: ReactNode;
186
+ isCopied: boolean;
187
+ copyLabel: string;
188
+ copiedLabel: string;
189
+ };
119
190
  /**
120
- * Union type for all supported wallet types.
121
- * It's created from the values of the AllWallets interface.
122
- * e.g., { evm: EVMWallet, solana: SolanaWallet } -> EVMWallet | SolanaWallet
191
+ * Customization options for ToastError component
123
192
  */
124
- type Wallet = AllWallets[keyof AllWallets];
193
+ type ToastErrorCustomization = {
194
+ /** Override container element props */
195
+ containerProps?: Partial<ComponentPropsWithoutRef<'div'>>;
196
+ /** Override button element props */
197
+ buttonProps?: Partial<ComponentPropsWithoutRef<'button'>>;
198
+ /** Custom components */
199
+ components?: {
200
+ /** Custom icon component */
201
+ Icon?: ComponentType<CustomIconProps>;
202
+ /** Custom title component */
203
+ Title?: ComponentType<CustomTitleProps>;
204
+ /** Custom description component */
205
+ Description?: ComponentType<CustomDescriptionProps>;
206
+ /** Custom button content component */
207
+ ButtonContent?: ComponentType<CustomButtonContentProps>;
208
+ };
209
+ /** Custom class name generators */
210
+ classNames?: {
211
+ /** Function to generate container classes */
212
+ container?: (params: {
213
+ hasTitle: boolean;
214
+ hasError: boolean;
215
+ }) => string;
216
+ /** Function to generate title classes */
217
+ title?: (params: {
218
+ title: string;
219
+ }) => string;
220
+ /** Function to generate description classes */
221
+ description?: (params: {
222
+ rawError: string;
223
+ }) => string;
224
+ /** Function to generate button classes */
225
+ button?: (params: {
226
+ isCopied: boolean;
227
+ disabled: boolean;
228
+ }) => string;
229
+ /** Function to generate icon classes */
230
+ icon?: (params: {
231
+ isCopied: boolean;
232
+ }) => string;
233
+ };
234
+ /** Custom style generators */
235
+ styles?: {
236
+ /** Function to generate container styles */
237
+ container?: (params: {
238
+ hasTitle: boolean;
239
+ hasError: boolean;
240
+ }) => React.CSSProperties;
241
+ /** Function to generate title styles */
242
+ title?: (params: {
243
+ title: string;
244
+ }) => React.CSSProperties;
245
+ /** Function to generate description styles */
246
+ description?: (params: {
247
+ rawError: string;
248
+ }) => React.CSSProperties;
249
+ /** Function to generate button styles */
250
+ button?: (params: {
251
+ isCopied: boolean;
252
+ disabled: boolean;
253
+ }) => React.CSSProperties;
254
+ /** Function to generate icon styles */
255
+ icon?: (params: {
256
+ isCopied: boolean;
257
+ }) => React.CSSProperties;
258
+ };
259
+ /** Custom event handlers */
260
+ handlers?: {
261
+ /** Custom click handler wrapper */
262
+ onClick?: (originalHandler: (event: React.MouseEvent<HTMLButtonElement>) => void, event: React.MouseEvent<HTMLButtonElement>) => void;
263
+ /** Custom keydown handler wrapper */
264
+ onKeyDown?: (originalHandler: (event: React.KeyboardEvent<HTMLButtonElement>) => void, event: React.KeyboardEvent<HTMLButtonElement>) => void;
265
+ };
266
+ };
267
+
268
+ type CustomToastErrorProps = {
269
+ title: string;
270
+ rawError: string;
271
+ onCopyComplete?: (success: boolean) => void;
272
+ errorType: 'wallet' | 'switch' | null;
273
+ isConnected: boolean;
274
+ };
275
+ type CustomContainerProps = ComponentPropsWithoutRef<typeof ToastContainer>;
125
276
  /**
126
- * Union type for all supported connector types.
277
+ * Customization options for ErrorsProvider component
127
278
  */
128
- type Connector = AllConnectors[keyof AllConnectors];
129
-
130
- interface NovaConnectProviderProps {
131
- store: StoreApi<ISatelliteConnectStore<Connector, Wallet>>;
132
- children: React.ReactNode;
133
- labels?: Partial<NovaConnectLabels>;
134
- }
135
-
136
- interface ErrorsProviderProps extends Pick<NovaConnectProviderProps, 'store'> {
279
+ type ErrorsProviderCustomization = {
280
+ /** Override ToastContainer element props */
281
+ containerProps?: Partial<ComponentPropsWithoutRef<typeof ToastContainer>>;
282
+ /** Custom components */
283
+ components?: {
284
+ /** Custom ToastError component */
285
+ ToastError?: ComponentType<CustomToastErrorProps>;
286
+ /** Custom ToastContainer component */
287
+ Container?: ComponentType<CustomContainerProps>;
288
+ };
289
+ /** Default ToastError customization (only used with default ToastError component) */
290
+ toastErrorCustomization?: ToastErrorCustomization;
291
+ /** Custom class name generators */
292
+ classNames?: {
293
+ /** Function to generate container classes */
294
+ container?: (params: {
295
+ hasErrors: boolean;
296
+ errorType: 'wallet' | 'switch' | null;
297
+ }) => string;
298
+ };
299
+ /** Custom style generators */
300
+ styles?: {
301
+ /** Function to generate container styles */
302
+ container?: (params: {
303
+ hasErrors: boolean;
304
+ errorType: 'wallet' | 'switch' | null;
305
+ }) => React.CSSProperties;
306
+ };
307
+ /** Custom toast options generators */
308
+ toastOptions?: {
309
+ /** Function to generate toast options */
310
+ error?: (params: {
311
+ title: string;
312
+ rawError: string;
313
+ errorType: 'wallet' | 'switch' | null;
314
+ isConnected: boolean;
315
+ }) => Partial<Parameters<typeof toast.error>[1]>;
316
+ };
317
+ /** Custom logic handlers */
318
+ handlers?: {
319
+ /** Custom error display logic */
320
+ showError?: (originalHandler: (title: string, rawError: string, errorKey: string) => void, params: {
321
+ title: string;
322
+ rawError: string;
323
+ errorKey: string;
324
+ errorType: 'wallet' | 'switch' | null;
325
+ }) => void;
326
+ /** Custom error dismissal logic */
327
+ dismissError?: (originalHandler: () => void) => void;
328
+ /** Custom copy complete handler */
329
+ onCopyComplete?: (success: boolean, rawError: string, errorType: 'wallet' | 'switch' | null) => void;
330
+ };
331
+ /** Custom error title generator - does NOT customize labels, just allows title modification */
332
+ errorTitle?: (defaultTitle: string, params: {
333
+ errorType: 'wallet' | 'switch' | null;
334
+ }) => string;
335
+ /** Custom error hash generator for deduplication */
336
+ errorHash?: (defaultHash: string | null, params: {
337
+ primaryError: string | null;
338
+ errorType: 'wallet' | 'switch' | null;
339
+ }) => string | null;
340
+ };
341
+ interface ErrorsProviderProps extends Pick<NovaConnectProviderProps$1, 'store'> {
137
342
  /** Custom container ID for toast notifications */
138
343
  containerId?: string;
139
344
  /** Custom position for toast notifications */
@@ -142,8 +347,14 @@ interface ErrorsProviderProps extends Pick<NovaConnectProviderProps, 'store'> {
142
347
  autoClose?: number | false;
143
348
  /** Whether to enable drag to dismiss */
144
349
  draggable?: boolean;
350
+ /** Customization options */
351
+ customization?: ErrorsProviderCustomization;
145
352
  }
146
- declare function ErrorsProvider({ store, containerId, position, autoClose, draggable, }: ErrorsProviderProps): react_jsx_runtime.JSX.Element;
353
+ /**
354
+ * A highly customizable error toast provider with extensive styling options and component replacement capabilities.
355
+ * Provides comprehensive customization for appearance, behavior, and error handling logic while maintaining accessibility.
356
+ */
357
+ declare function ErrorsProvider({ store, containerId, position, autoClose, draggable, customization, }: ErrorsProviderProps): react_jsx_runtime.JSX.Element;
147
358
  declare namespace ErrorsProvider {
148
359
  var displayName: string;
149
360
  }
@@ -185,6 +396,149 @@ declare namespace NovaConnectLabelsProvider {
185
396
  var displayName: string;
186
397
  }
187
398
 
188
- declare function NovaConnectProvider({ labels, store, children }: NovaConnectProviderProps): react_jsx_runtime.JSX.Element;
399
+ /**
400
+ * Props for custom NovaConnectLabelsProvider component
401
+ */
402
+ type CustomLabelsProviderProps = {
403
+ labels?: Partial<NovaConnectLabels>;
404
+ children: ReactNode;
405
+ };
406
+ /**
407
+ * Props for custom ErrorsProvider component
408
+ */
409
+ type CustomErrorsProviderProps = Pick<ErrorsProviderProps, 'store'> & {
410
+ customization?: ErrorsProviderCustomization;
411
+ };
412
+ /**
413
+ * Context data passed to custom provider components
414
+ */
415
+ type ProviderContext = {
416
+ /** Current wallet connection state */
417
+ isConnected: boolean;
418
+ /** Active wallet instance */
419
+ activeWallet: BaseWallet | undefined;
420
+ /** Current wallet connection error */
421
+ walletConnectionError: string | undefined;
422
+ /** All modal and UI states */
423
+ modalStates: {
424
+ isConnectModalOpen: boolean;
425
+ isConnectedModalOpen: boolean;
426
+ isChainsListOpen: boolean;
427
+ isChainsListOpenMobile: boolean;
428
+ };
429
+ /** Current content types for modals */
430
+ contentTypes: {
431
+ connectModal: ConnectContentType;
432
+ connectedModal: ConnectedContentType;
433
+ };
434
+ /** Button and transaction statuses */
435
+ statuses: {
436
+ connectedButton: ButtonTxStatus;
437
+ };
438
+ };
439
+ /**
440
+ * Comprehensive customization options for NovaConnectProvider
441
+ */
442
+ type NovaConnectProviderCustomization = {
443
+ /** Custom components */
444
+ components?: {
445
+ /** Custom labels provider component */
446
+ LabelsProvider?: ComponentType<CustomLabelsProviderProps>;
447
+ /** Custom errors provider component */
448
+ ErrorsProvider?: ComponentType<CustomErrorsProviderProps>;
449
+ };
450
+ /** Labels customization and merging strategy */
451
+ labels?: {
452
+ /** Custom labels merging function */
453
+ merge?: (defaultLabels: NovaConnectLabels, userLabels: Partial<NovaConnectLabels>) => NovaConnectLabels;
454
+ /** Transform final merged labels before use */
455
+ transform?: (mergedLabels: NovaConnectLabels, context: ProviderContext) => NovaConnectLabels;
456
+ };
457
+ /** ErrorsProvider customization - passed through to ErrorsProvider */
458
+ errors?: ErrorsProviderCustomization;
459
+ /** Custom initialization logic */
460
+ initialization?: {
461
+ /** Custom logic after store subscription setup */
462
+ onStoreSubscribed?: (context: ProviderContext) => void;
463
+ /** Custom logic when connection state changes */
464
+ onConnectionStateChange?: (isConnected: boolean, activeWallet: BaseWallet | undefined, context: ProviderContext) => void;
465
+ /** Custom logic when error state changes */
466
+ onErrorStateChange?: (error: string | undefined, context: ProviderContext) => void;
467
+ };
468
+ /** Custom context value transformation */
469
+ contextValue?: {
470
+ /** Transform context value before providing to children */
471
+ transform?: (defaultValue: NovaConnectProviderType, context: ProviderContext) => NovaConnectProviderType;
472
+ };
473
+ /** Custom rendering logic */
474
+ rendering?: {
475
+ /** Custom provider tree structure */
476
+ providerTree?: (defaultTree: ReactNode, components: {
477
+ ErrorsProvider: ReactNode;
478
+ LabelsProvider: ReactNode;
479
+ MainContent: ReactNode;
480
+ }, context: ProviderContext) => ReactNode;
481
+ };
482
+ };
483
+ /**
484
+ * Extended props for NovaConnectProvider with full customization capabilities
485
+ */
486
+ interface NovaConnectProviderProps extends NovaConnectProviderProps$1 {
487
+ /** Comprehensive customization options for the provider and its sub-components */
488
+ customization?: NovaConnectProviderCustomization;
489
+ }
490
+ /**
491
+ * Main NovaConnect provider component with comprehensive customization capabilities.
492
+ *
493
+ * This provider manages wallet connection state, error handling, internationalization,
494
+ * and modal states while offering extensive customization options for all sub-components
495
+ * and behaviors.
496
+ *
497
+ * Features:
498
+ * - Complete wallet connection state management
499
+ * - Customizable error handling through ErrorsProvider
500
+ * - Flexible internationalization system
501
+ * - Modal and UI state coordination
502
+ * - Extensive customization API for all aspects
503
+ * - Custom component replacement capabilities
504
+ * - Advanced initialization and lifecycle hooks
505
+ *
506
+ * @example Basic usage
507
+ * ```tsx
508
+ * <NovaConnectProvider store={store}>
509
+ * <App />
510
+ * </NovaConnectProvider>
511
+ * ```
512
+ *
513
+ * @example With customization
514
+ * ```tsx
515
+ * <NovaConnectProvider
516
+ * store={store}
517
+ * labels={customLabels}
518
+ * customization={{
519
+ * errors: {
520
+ * position: 'bottom-right',
521
+ * autoClose: 5000,
522
+ * components: {
523
+ * ToastError: CustomToastError
524
+ * }
525
+ * },
526
+ * initialization: {
527
+ * onConnectionStateChange: (isConnected, wallet) => {
528
+ * console.log('Connection state:', isConnected, wallet);
529
+ * }
530
+ * }
531
+ * }}
532
+ * >
533
+ * <App />
534
+ * </NovaConnectProvider>
535
+ * ```
536
+ *
537
+ * @param props - Provider configuration and customization options
538
+ */
539
+ declare function NovaConnectProvider({ labels, store, children, customization }: NovaConnectProviderProps): react_jsx_runtime.JSX.Element;
540
+ declare namespace NovaConnectProvider {
541
+ var displayName: string;
542
+ }
189
543
 
190
- export { ErrorsProvider, NovaConnectLabelsProvider, NovaConnectProvider };
544
+ export { ErrorsProvider, type ErrorsProviderCustomization, type ErrorsProviderProps, NovaConnectLabelsProvider, NovaConnectProvider, type NovaConnectProviderCustomization, type NovaConnectProviderProps };
@@ -1,6 +1,6 @@
1
- import {cn,ChevronArrowWithAnim,ToastCloseButton,deepMerge,useCopyToClipboard}from'@tuwaio/nova-core';import*as v from'react';import {createContext,forwardRef,useContext,useMemo,useState,useRef,useCallback,lazy,memo,useEffect}from'react';import {toast,Bounce,ToastContainer}from'react-toastify';import {Web3Icon}from'@bgd-labs/react-web3-icons';import'@bgd-labs/react-web3-icons/dist/utils';import*as N from'@radix-ui/react-select';import {jsxs,Fragment,jsx}from'react/jsx-runtime';import {OrbitAdapter,formatWalletName}from'@tuwaio/orbit-core';import {AnimatePresence,motion}from'framer-motion';import {ChevronDownIcon,ChevronUpIcon,DocumentDuplicateIcon}from'@heroicons/react/24/solid';import hn from'ethereum-blockies-base64';import'@heroicons/react/24/outline';import'gill';import'viem';import'@tuwaio/pulsar-core';var F={connectWallet:"Connect Wallet",disconnect:"Disconnect",connecting:"Connecting...",connected:"Connected",tryAgain:"Try again",back:"Back",connect:"Connect",close:"Close",all:"All",connectionError:"Connection error",connectedSuccessfully:"Connected successfully!",connectingTo:"Connecting to",walletConnectionError:"Wallet connection error",errorWhenChainSwitching:"Error when chain switching",cannotConnectWallet:"Cannot connect to the wallet. Please try again or use another connector.",success:"Success",error:"Error",replaced:"Replaced",recent:"Recent",transactionLoading:"Transaction loading",transactionSuccess:"Transaction successful",transactionError:"Transaction failed",transactionReplaced:"Transaction replaced",aboutWallets:"About wallets",getWallet:"Get a wallet",connectImpersonatedWallet:"Connect impersonated wallet",transactionsInApp:"Transactions in app",switchNetwork:"Switch network",switchNetworks:"Switch Networks",connectingEllipsis:"Connecting...",installed:"Installed",popular:"Popular",impersonate:"Impersonate",readOnlyMode:"Read-only mode",whatIsWallet:"What is a wallet?",walletDescription:"Wallets are essential for managing your crypto\u2014they let you send, receive, and securely hold digital assets. Connecting your wallet grants you safe access and interaction with decentralized applications (dApps).",whatIsNetwork:"What is a network?",networkDescription:"A network (or blockchain) is a decentralized digital ledger that records transactions. Selecting a network lets you choose which blockchain you want to connect to.",learnMore:"Learn more",listOfNetworks:"List of networks",viewOnExplorer:"View on explorer",viewTransactions:"View transactions",enterWalletAddress:"Enter wallet address to impersonate",walletAddressPlaceholder:"0x...",noConnectorsFound:"No Connectors Found",noConnectorsDescription:"We couldn't find any wallets or connection methods for the selected network.",somethingWentWrong:"Something went wrong",networkPickingError:"Something went wrong with wallet network selection. Please go back and try again.",pulsarAdapterRequired:"Pulsar Adapter Required",pulsarAdapterDescription:"Additional configuration is needed for viewing transactions in app. Please contact your admin.",selectAvailableNetwork:"Select one of available network",startExploringWeb3:"Start Exploring Web3",walletKeyToDigitalWorld:"Your wallet is the key to the digital world and the technology that makes exploring web3 possible.",iDontHaveWallet:"I don't have a wallet",choseWallet:"Choose a wallet",keyToNewInternet:"The Key to a New Internet",keyToNewInternetDescription:"Your wallet is more than just storage. Think of it as your digital passport that lets you truly own, display, and exchange every digital asset you hold, from crypto tokens to unique NFTs.",logInWithoutHassle:"Log In Without the Hassle",logInWithoutHassleDescription:"Skip the endless sign-up forms! Your wallet is your unique access pass. Just connect it, and the website instantly recognizes you. It saves you time and protects your privacy.",copyRawError:"Copy raw error",copied:"Copied!",chainSelector:"Chain Selector",closeModal:"Close modal",selectChain:"Select chain",chainOption:"Chain option",openChainSelector:"Open chain selector",currentChain:"Current chain",scrollToTop:"Scroll to top",scrollToBottom:"Scroll to bottom",chainListContainer:"Chain list container",walletControls:"Wallet controls",openWalletModal:"Open wallet modal",walletConnected:"Wallet connected",walletNotConnected:"Wallet not connected",walletBalance:"Wallet balance",walletAddress:"Wallet address",transactionStatus:"Transaction status",successIcon:"Success icon",errorIcon:"Error icon",replacedIcon:"Replaced icon",statusIcon:"Status icon",loading:"Loading",idle:"Idle",unknownWallet:"Unknown wallet",walletAvatar:"Wallet avatar",ensAvatar:"ENS avatar",walletIcon:"Wallet icon",impersonateAddressEmpty:"Enter a wallet address to impersonate.",impersonateAddressNotCorrect:"Entered wallet address is not correct. Please try again.",impersonateAddressConnected:"First disconnect the wallet to impersonate another address."};var X=createContext(F),i=()=>useContext(X);var Ho=forwardRef(({children:a,className:o,...n},e)=>{let c=i(),t=n.value===n["aria-label"];return jsxs(N.Item,{ref:e,className:cn("novacon:flex novacon:items-center novacon:w-full novacon:text-left novacon:px-2 novacon:py-2 novacon:rounded-md novacon:transition-colors novacon:space-x-3 novacon:cursor-pointer novacon:outline-none","novacon:text-[var(--tuwa-text-primary)] novacon:hover:bg-[var(--tuwa-bg-muted)] novacon:focus:bg-[var(--tuwa-bg-muted)] novacon:focus:outline-none novacon:focus:ring-2 novacon:focus:ring-[var(--tuwa-border-primary)] novacon:focus:ring-offset-2",{"novacon:bg-[var(--tuwa-bg-muted)]":t},o),role:"option","aria-selected":t,tabIndex:0,...n,children:[a,t&&jsxs(Fragment,{children:[jsx("span",{className:"novacon:ml-auto novacon:text-xs novacon:font-semibold novacon:w-2 novacon:h-2 novacon:rounded-full novacon:bg-[var(--tuwa-success-text)]","aria-label":c.connected,role:"status"}),jsx("span",{className:"novacon:sr-only",children:c.connected})]})]})});Ho.displayName="SelectItemBase";var $=class extends Error{constructor(o="useNovaConnect must be used within NovaConnectProvider"){super(o),this.name="NovaConnectProviderError";}},_=createContext(void 0),I=()=>{let a=useContext(_);if(!a)throw new $;return a};({[OrbitAdapter.EVM]:1,[OrbitAdapter.SOLANA]:"mainnet",[OrbitAdapter.Starknet]:"0x534e5f4d41494e"});function b(a=1200){if(typeof window>"u")return false;let o="ontouchstart"in window,n=navigator.maxTouchPoints>0,e=false;window.matchMedia&&(e=window.matchMedia("(pointer: coarse)").matches);let c=o||n||e,t=window.innerWidth<=a;return c&&t}({[OrbitAdapter.EVM]:{},[OrbitAdapter.SOLANA]:{}});var O=forwardRef(({className:a,"aria-label":o,onClick:n,disabled:e=false,...c},t)=>{let r=i();return jsx("button",{ref:t,type:"button",onClick:s=>{n&&(s.preventDefault(),n(s));},onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&n&&(s.preventDefault(),n(s));},disabled:e,className:cn("novacon:flex novacon:w-full novacon:h-6 novacon:items-center novacon:justify-center","novacon:bg-[var(--tuwa-bg-secondary)] novacon:text-[var(--tuwa-text-primary)]","novacon:transition-colors novacon:duration-200","novacon:hover:bg-[var(--tuwa-bg-tertiary)] novacon:hover:text-[var(--tuwa-text-secondary)]","novacon:focus:outline-none novacon:focus:ring-2 novacon:focus:ring-[var(--tuwa-text-accent)] novacon:focus:ring-inset","novacon:active:bg-[var(--tuwa-bg-quaternary)]","novacon:disabled:opacity-50 novacon:disabled:cursor-not-allowed novacon:disabled:hover:bg-[var(--tuwa-bg-secondary)]",n?"novacon:cursor-pointer":"novacon:cursor-default",a),"aria-label":o||r.scrollToBottom,title:o||r.scrollToBottom,...c,children:jsx(ChevronDownIcon,{className:cn("novacon:w-4 novacon:h-4 novacon:transition-transform novacon:duration-200",e&&"novacon:opacity-50"),"aria-hidden":"true"})})});O.displayName="ToBottomButton";var J=forwardRef(({className:a,"aria-label":o,onClick:n,disabled:e=false,...c},t)=>{let r=i();return jsx("button",{ref:t,type:"button",onClick:s=>{n&&(s.preventDefault(),n(s));},onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&n&&(s.preventDefault(),n(s));},disabled:e,className:cn("novacon:flex novacon:w-full novacon:h-6 novacon:items-center novacon:justify-center","novacon:bg-[var(--tuwa-bg-secondary)] novacon:text-[var(--tuwa-text-primary)]","novacon:transition-colors novacon:duration-200","novacon:hover:bg-[var(--tuwa-bg-tertiary)] novacon:hover:text-[var(--tuwa-text-secondary)]","novacon:focus:outline-none novacon:focus:ring-2 novacon:focus:ring-[var(--tuwa-text-accent)] novacon:focus:ring-inset","novacon:active:bg-[var(--tuwa-bg-quaternary)]","novacon:disabled:opacity-50 novacon:disabled:cursor-not-allowed novacon:disabled:hover:bg-[var(--tuwa-bg-secondary)]",n?"novacon:cursor-pointer":"novacon:cursor-default",a),"aria-label":o||r.scrollToTop,title:o||r.scrollToTop,...c,children:jsx(ChevronUpIcon,{className:cn("novacon:w-4 novacon:h-4 novacon:transition-transform novacon:duration-200",e&&"novacon:opacity-50"),"aria-hidden":"true"})})});J.displayName="ToTopButton";var vo=forwardRef(({className:a,children:o,position:n="popper","aria-label":e,reduceMotion:c=false,...t},r)=>{let m=i(),G=useMemo(()=>c?{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15}}:{initial:{opacity:0,scaleY:.8,y:-5},animate:{opacity:1,scaleY:1,y:0},exit:{opacity:0,scaleY:.8,y:-5},transition:{duration:.2,ease:"easeOut"}},[c]),s=useMemo(()=>c?{}:{duration:.15,ease:"easeOut"},[c]),Q=useMemo(()=>cn("novacon:p-1 novacon:bg-[var(--tuwa-bg-secondary)] novacon:rounded-lg novacon:shadow-xl","novacon:ring-1 novacon:ring-[var(--tuwa-border-primary)] novacon:overflow-hidden",a),[a]),M=useMemo(()=>cn("novacon:max-h-[300px] novacon:w-[--radix-select-trigger-width] novacon:overflow-hidden","novacon:data-[state=open]:animate-in novacon:data-[state=closed]:animate-out","novacon:data-[state=closed]:fade-out-0 novacon:data-[state=open]:novacon:fade-in-0","novacon:data-[state=closed]:zoom-out-95 novacon:data-[state=open]:novacon:zoom-in-95","novacon:data-[side=bottom]:slide-in-from-top-2 novacon:data-[side=left]:slide-in-from-right-2","novacon:data-[side=right]:slide-in-from-left-2 novacon:data-[side=top]:slide-in-from-bottom-2"),[]);return jsx(N.Portal,{children:jsxs(N.Content,{className:M,ref:r,position:n,role:"listbox","aria-label":e||m.chainListContainer,...t,children:[jsx(N.ScrollUpButton,{asChild:true,children:jsx(J,{})}),jsx(N.Viewport,{role:"presentation",children:jsx(AnimatePresence,{mode:"wait",initial:false,children:jsx(motion.div,{...G,className:Q,layout:!c,transition:{layout:s},role:"group","aria-live":"polite",children:o})})}),jsx(N.ScrollDownButton,{asChild:true,children:jsx(O,{})})]})})});vo.displayName="SelectContentAnimated";function Do(a,{strict:o=true}={}){return !a||typeof a!="string"?false:o?/^0x[0-9a-fA-F]*$/.test(a):a.startsWith("0x")}var gn="0x0000000000000000000000000000000000000000",Zn={sm:"novacon:h-4 novacon:w-4",md:"novacon:h-6 novacon:w-6",lg:"novacon:h-8 novacon:w-8",xl:"novacon:h-12 novacon:w-12"},co=forwardRef(({address:a,ensAvatar:o,className:n,altText:e,size:c="md",showLoading:t=true,onImageLoad:r,onImageError:m,disableAnimation:G=false,...s},Q)=>{let M=i(),[l,E]=useState(o??null),[h,p]=useState(!!o),[g,Z]=useState(false),C=useRef(null),z=useMemo(()=>{try{return hn(Do(a)?a:gn)}catch(Y){return console.warn("Failed to generate blockie for address:",a,Y),null}},[a]),d=useMemo(()=>{try{if(!Do(a))return "#6B7280";let Y=a.slice(2,8);return Y.length===6?`#${Y}`:"#6B7280"}catch{return "#6B7280"}},[a]),B=useMemo(()=>a?`${a.slice(0,6)}...${a.slice(-4)}`:M.unknownWallet,[a,M.unknownWallet]),y=useMemo(()=>e||(g||!o?`${M.walletAvatar} ${B}`:`${M.ensAvatar} ${B}`),[e,g,o,B,M.walletAvatar,M.ensAvatar]),D=useMemo(()=>o??null,[o]);useMemo(()=>{E(D),p(!!D),Z(false);},[D]);let w=useCallback(()=>{p(false),Z(false),r?.();},[r]),q=useCallback(Y=>{p(false),Z(true),E(z),m?.(Y.nativeEvent);},[z,m]),H=useMemo(()=>cn(Zn[c],"novacon:flex-shrink-0 novacon:rounded-full novacon:relative novacon:overflow-hidden","novacon:ring-1 novacon:ring-[var(--tuwa-border-primary)]","novacon:focus-within:ring-2 novacon:focus-within:ring-[var(--tuwa-text-accent)]",n),[c,n]),V=useMemo(()=>cn("novacon:absolute novacon:inset-0 novacon:rounded-full novacon:bg-[var(--tuwa-bg-muted)]",!G&&t&&h&&"novacon:animate-pulse",(!h||!t)&&"novacon:opacity-0","novacon:transition-opacity novacon:duration-300"),[G,t,h]),R=l||z||"";return jsxs("div",{ref:Q,className:H,style:{backgroundColor:d},role:"img","aria-label":y,title:y,...s,children:[jsx("div",{className:V,"aria-hidden":"true"}),R&&jsx("img",{ref:C,className:cn("novacon:h-full novacon:w-full novacon:rounded-full novacon:object-cover novacon:relative novacon:z-10","novacon:transition-opacity novacon:duration-300",h?"novacon:opacity-0":"novacon:opacity-100"),src:R,alt:"",onLoad:w,onError:q,loading:"lazy",decoding:"async",draggable:false},`${o||"blockie"}-${a}`),!R&&jsx("div",{className:"novacon:absolute novacon:inset-0 novacon:flex novacon:items-center novacon:justify-center novacon:text-white novacon:text-xs novacon:font-mono","aria-hidden":"true",children:B.slice(0,2)})]})});co.displayName="WalletAvatar";var j=forwardRef(({icon:a,name:o,size:n=32,className:e,altText:c,showLoading:t=false,onImageLoad:r,onImageError:m,lazy:G=false,...s},Q)=>{let M=i(),[l,E]=useState(false),[h,p]=useState(!!a),g=useMemo(()=>formatWalletName(o),[o]),Z=useMemo(()=>c||`${g} ${M.walletIcon}`,[c,g,M.walletIcon]),C=useMemo(()=>{if(!a)return null;try{let w=a.trim();return w&&(w.startsWith("http://")||w.startsWith("https://")||w.startsWith("/")||w.startsWith("data:"))?w:null}catch{return null}},[a]),z=useCallback(()=>{p(false),E(false),r?.();},[r]),d=useCallback(()=>{p(false),E(true),m?.();},[m]),B=useMemo(()=>cn("novacon:relative novacon:inline-flex novacon:items-center novacon:justify-center novacon:flex-shrink-0","novacon:overflow-hidden",t&&h&&"novacon:animate-pulse novacon:bg-[var(--tuwa-bg-muted)]",e),[t,h,e]),y=useMemo(()=>cn("novacon:object-cover novacon:transition-opacity novacon:duration-200","novacon:max-w-full novacon:max-h-full",h&&t?"novacon:opacity-0":"novacon:opacity-100"),[h,t]),D=useMemo(()=>({width:n,height:n}),[n]);return jsxs("div",{ref:Q,className:B,role:"img","aria-label":Z,title:Z,style:{lineHeight:0},...s,children:[t&&h&&jsx("div",{className:"novacon:absolute novacon:inset-0 novacon:bg-[var(--tuwa-bg-muted)] novacon:animate-pulse novacon:rounded-full","aria-hidden":"true"}),C&&!l?jsx("img",{src:C,alt:"",className:y,style:D,onLoad:z,onError:d,loading:G?"lazy":"eager",decoding:"async",crossOrigin:"anonymous",referrerPolicy:"no-referrer"}):jsx(Web3Icon,{walletKey:g,className:cn(y,"novacon:flex-shrink-0"),style:D}),l&&process.env.NODE_ENV==="development"&&jsx("div",{className:"novacon:absolute novacon:top-0 novacon:right-0 novacon:w-2 novacon:h-2 novacon:bg-red-500 novacon:rounded-full",title:`Failed to load icon for ${g}`,"aria-hidden":"true"})]})});j.displayName="WalletIcon";var xo=forwardRef(({walletIcon:a,walletName:o,walletChainId:n,items:e=0,onClick:c,className:t,disabled:r=false,loading:m=false,"aria-label":G,title:s},Q)=>{let M=i(),l=useMemo(()=>!!(c&&!r&&!m&&e>1),[c,r,m,e]),E=useMemo(()=>{if(n)return typeof n=="string"?`${OrbitAdapter.SOLANA}:${n}`:n},[n]),h=useMemo(()=>{if(G)return G;let C=[];return o&&C.push(`${o} wallet`),n&&C.push("network selector"),l&&C.push("button"),m&&C.push("loading"),r&&C.push("disabled"),C.join(", ")||"Wallet controls"},[G,o,n,l,m,r]),p=useMemo(()=>s||(m?"Loading...":r?"Button is disabled":l?`Click to select ${o?o+" ":""}options`:o?`${o} wallet`:"Wallet information"),[s,m,r,l,o]),g=useMemo(()=>cn("novacon:flex novacon:items-center novacon:justify-center novacon:gap-1 novacon:rounded-full","novacon:bg-[var(--tuwa-bg-primary)] novacon:border novacon:border-[var(--tuwa-border-primary)]","novacon:p-1.5 novacon:transition-all novacon:duration-200","novacon:[&_img]:w-6! novacon:[&_img]:h-6! novacon:[&_img]:transition-transform novacon:[&_img]:duration-200",{"novacon:cursor-pointer novacon:hover:[&_img]:scale-95 novacon:active:[&_img]:scale-85 novacon:hover:shadow-sm":l,"novacon:cursor-not-allowed novacon:opacity-50":r&&!m,"novacon:cursor-wait novacon:opacity-75":m,"novacon:cursor-default":!l&&!r&&!m},"novacon:focus-visible:outline-none novacon:focus-visible:ring-2 novacon:focus-visible:ring-[var(--tuwa-border-accent)] novacon:focus-visible:ring-offset-2",t),[l,r,m,t]);return jsxs("button",{ref:Q,type:"button",className:g,onClick:()=>{l&&c&&c();},disabled:r||m,"aria-label":h,title:p,role:"button",tabIndex:r||m?-1:0,children:[o&&jsx(j,{name:o,icon:a,altText:`${o} ${M.walletIcon}`,showLoading:m,className:"novacon:flex-shrink-0"}),E&&jsx(Web3Icon,{chainId:E,className:"novacon:flex-shrink-0",title:`Network: ${n}`}),l&&jsx(ChevronArrowWithAnim,{className:"novacon:flex-shrink-0","aria-hidden":"true"}),m&&jsx("div",{className:"novacon:absolute novacon:inset-0 novacon:bg-[var(--tuwa-bg-primary)]/50 novacon:rounded-full novacon:flex novacon:items-center novacon:justify-center","aria-hidden":"true",children:jsx("div",{className:"novacon:w-3 novacon:h-3 novacon:border-2 novacon:border-[var(--tuwa-text-accent)] novacon:border-t-transparent novacon:rounded-full novacon:animate-spin"})})]})});xo.displayName="IconButton";lazy(()=>{try{return import('@tuwaio/nova-transactions').then(a=>({default:a.TransactionsHistory}))}catch(a){return console.warn("Failed to load @tuwaio/nova-transactions package:",a),new Promise(()=>{})}});var bo=memo(({className:a,children:o="Recent",animated:n=true})=>{let e=useMemo(()=>b(),[]),c=useMemo(()=>`linear-gradient(90deg,
1
+ import {cn,ChevronArrowWithAnim,isTouchDevice,useCopyToClipboard,ToastCloseButton,deepMerge}from'@tuwaio/nova-core';import _n,{createContext,forwardRef,useContext,useCallback,useMemo,useState,lazy,memo,useRef,useEffect}from'react';import {toast,Bounce,ToastContainer}from'react-toastify';import {Web3Icon}from'@bgd-labs/react-web3-icons';import'@bgd-labs/react-web3-icons/dist/utils';import*as F from'@radix-ui/react-select';import {AnimatePresence,motion}from'framer-motion';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {OrbitAdapter,formatWalletName}from'@tuwaio/orbit-core';import {ChevronDownIcon,ChevronUpIcon,DocumentDuplicateIcon}from'@heroicons/react/24/solid';import ae from'ethereum-blockies-base64';import'@heroicons/react/24/outline';import'gill';import'viem';import'@tuwaio/pulsar-core';var Co={connectWallet:"Connect Wallet",disconnect:"Disconnect",connecting:"Connecting...",connected:"Connected",tryAgain:"Try again",back:"Back",connect:"Connect",close:"Close",all:"All",connectionError:"Connection error",connectedSuccessfully:"Connected successfully!",connectingTo:"Connecting to",walletConnectionError:"Wallet connection error",errorWhenChainSwitching:"Error when chain switching",cannotConnectWallet:"Cannot connect to the wallet. Please try again or use another connector.",success:"Success",error:"Error",replaced:"Replaced",recent:"Recent",transactionLoading:"Transaction loading",transactionSuccess:"Transaction successful",transactionError:"Transaction failed",transactionReplaced:"Transaction replaced",aboutWallets:"About wallets",getWallet:"Get a wallet",connectImpersonatedWallet:"Connect impersonated wallet",transactionsInApp:"Transactions in app",switchNetwork:"Switch network",switchNetworks:"Switch Networks",connectingEllipsis:"Connecting...",installed:"Installed",popular:"Popular",impersonate:"Impersonate",readOnlyMode:"Read-only mode",whatIsWallet:"What is a wallet?",walletDescription:"Wallets are essential for managing your crypto\u2014they let you send, receive, and securely hold digital assets. Connecting your wallet grants you safe access and interaction with decentralized applications (dApps).",whatIsNetwork:"What is a network?",networkDescription:"A network (or blockchain) is a decentralized digital ledger that records transactions. Selecting a network lets you choose which blockchain you want to connect to.",learnMore:"Learn more",listOfNetworks:"List of networks",viewOnExplorer:"View on explorer",viewTransactions:"View transactions",enterWalletAddress:"Enter wallet address to impersonate",walletAddressPlaceholder:"0x...",noConnectorsFound:"No Connectors Found",noConnectorsDescription:"We couldn't find any wallets or connection methods for the selected network.",somethingWentWrong:"Something went wrong",networkPickingError:"Something went wrong with wallet network selection. Please go back and try again.",pulsarAdapterRequired:"Pulsar Adapter Required",pulsarAdapterDescription:"Additional configuration is needed for viewing transactions in app. Please contact your admin.",selectAvailableNetwork:"Select one of available network",startExploringWeb3:"Start Exploring Web3",walletKeyToDigitalWorld:"Your wallet is the key to the digital world and the technology that makes exploring web3 possible.",iDontHaveWallet:"I don't have a wallet",choseWallet:"Choose a wallet",keyToNewInternet:"The Key to a New Internet",keyToNewInternetDescription:"Your wallet is more than just storage. Think of it as your digital passport that lets you truly own, display, and exchange every digital asset you hold, from crypto tokens to unique NFTs.",logInWithoutHassle:"Log In Without the Hassle",logInWithoutHassleDescription:"Skip the endless sign-up forms! Your wallet is your unique access pass. Just connect it, and the website instantly recognizes you. It saves you time and protects your privacy.",copyRawError:"Copy raw error",copied:"Copied!",chainSelector:"Chain Selector",closeModal:"Close modal",selectChain:"Select chain",chainOption:"Chain option",openChainSelector:"Open chain selector",currentChain:"Current chain",scrollToTop:"Scroll to top",scrollToBottom:"Scroll to bottom",chainListContainer:"Chain list container",walletControls:"Wallet controls",openWalletModal:"Open wallet modal",walletConnected:"Wallet connected",walletNotConnected:"Wallet not connected",walletBalance:"Wallet balance",walletAddress:"Wallet address",transactionStatus:"Transaction status",successIcon:"Success icon",errorIcon:"Error icon",replacedIcon:"Replaced icon",statusIcon:"Status icon",loading:"Loading",idle:"Idle",unknownWallet:"Unknown wallet",walletAvatar:"Wallet avatar",ensAvatar:"ENS avatar",walletIcon:"Wallet icon",impersonateAddressEmpty:"Enter a wallet address to impersonate.",impersonateAddressNotCorrect:"Entered wallet address is not correct. Please try again.",impersonateAddressConnected:"First disconnect the wallet to impersonate another address."};var uo=createContext(Co),m=()=>useContext(uo);var un=({isActive:n,label:o,className:e,style:t})=>n?jsxs(Fragment,{children:[jsx("span",{className:cn("novacon:ml-auto novacon:text-xs novacon:font-semibold novacon:w-2 novacon:h-2 novacon:rounded-full novacon:bg-[var(--tuwa-success-text)]",e),style:t,"aria-label":o,role:"status"}),jsx("span",{className:"novacon:sr-only",children:o})]}):null,Bn=forwardRef(({children:n,className:o,...e},t)=>{let r=m(),a=e.value===e["aria-selected"];return jsxs(F.Item,{ref:t,className:cn("novacon:flex novacon:items-center novacon:w-full novacon:text-left novacon:px-2 novacon:py-2","novacon:rounded-md novacon:transition-colors novacon:space-x-3 novacon:cursor-pointer novacon:outline-none","novacon:text-[var(--tuwa-text-primary)] novacon:hover:bg-[var(--tuwa-bg-muted)]","novacon:focus:bg-[var(--tuwa-bg-muted)] novacon:focus:outline-none","novacon:focus:ring-2 novacon:focus:ring-[var(--tuwa-border-primary)] novacon:focus:ring-offset-2",{"novacon:bg-[var(--tuwa-bg-muted)]":a},o),role:"option","aria-selected":a,tabIndex:0,...e,children:[n,a&&jsx(un,{isActive:true,label:r.connected,className:"novacon:ml-auto"})]})});Bn.displayName="SelectItemBase";var Do=class extends Error{constructor(o="useNovaConnect must be used within NovaConnectProvider"){super(o),this.name="NovaConnectProviderError";}},po=createContext(void 0),f=()=>{let n=useContext(po);if(!n)throw new Do;return n};({[OrbitAdapter.EVM]:1,[OrbitAdapter.SOLANA]:"mainnet",[OrbitAdapter.Starknet]:"0x534e5f4d41494e"});({[OrbitAdapter.EVM]:{},[OrbitAdapter.SOLANA]:{}});var Rn=({disabled:n,className:o,style:e,...t})=>jsx(ChevronDownIcon,{className:cn("novacon:w-4 novacon:h-4 novacon:transition-transform novacon:duration-200",n&&"novacon:opacity-50",o),style:e,...t}),jn=({icon:n})=>jsx(Fragment,{children:n}),Un=(n,o)=>{n(o);},kn=(n,o)=>{n(o);},go=forwardRef(({className:n,"aria-label":o,onClick:e,disabled:t=false,customization:r,...a},c)=>{let l=m(),{Icon:g=Rn,Content:s=jn}=r?.components??{},{onClick:Q=Un,onKeyDown:z=kn}=r?.handlers??{},M=useCallback(h=>{Q(C=>{e&&(C.preventDefault(),e(C));},h);},[e,Q]),d=useCallback(h=>{z(C=>{if((C.key==="Enter"||C.key===" ")&&e){C.preventDefault();let B={...C,button:0,buttons:1,clientX:0,clientY:0,movementX:0,movementY:0,offsetX:0,offsetY:0,pageX:0,pageY:0,relatedTarget:null,screenX:0,screenY:0,x:0,y:0,getModifierState:()=>false,initMouseEvent:()=>{}};e(B);}},h);},[e,z]),G=useMemo(()=>r?.classNames?.button?r.classNames.button({disabled:t,hasOnClick:!!e}):cn("novacon:flex novacon:w-full novacon:h-6 novacon:items-center novacon:justify-center","novacon:bg-[var(--tuwa-bg-secondary)] novacon:text-[var(--tuwa-text-primary)]","novacon:transition-colors novacon:duration-200","novacon:hover:bg-[var(--tuwa-bg-tertiary)] novacon:hover:text-[var(--tuwa-text-secondary)]","novacon:focus:outline-none novacon:focus:ring-2 novacon:focus:ring-[var(--tuwa-text-accent)] novacon:focus:ring-inset","novacon:active:bg-[var(--tuwa-bg-quaternary)]","novacon:disabled:opacity-50 novacon:disabled:cursor-not-allowed novacon:disabled:hover:bg-[var(--tuwa-bg-secondary)]",e?"novacon:cursor-pointer":"novacon:cursor-default",n),[r,t,e,n]),E=useMemo(()=>{if(r?.classNames?.icon)return r.classNames.icon({disabled:t})},[r,t]),Z=useMemo(()=>{if(r?.styles?.button)return r.styles.button({disabled:t,hasOnClick:!!e})},[r,t,e]),I=useMemo(()=>{if(r?.styles?.icon)return r.styles.icon({disabled:t})},[r,t]),p=useMemo(()=>jsx(g,{disabled:t,className:E,style:I,"aria-hidden":true}),[g,t,E,I]),i=useMemo(()=>({...r?.buttonProps,...a,ref:c,type:"button",onClick:M,onKeyDown:d,disabled:t,className:G,style:{...Z,...r?.buttonProps?.style,...a.style},"aria-label":o||l.scrollToBottom,title:o||l.scrollToBottom}),[r?.buttonProps,a,c,M,d,t,G,Z,o,l.scrollToBottom]);return jsx("button",{...i,children:jsx(s,{icon:p,disabled:t,ariaLabel:o})})});go.displayName="ToBottomButton";var Jn=({disabled:n,className:o,style:e,...t})=>jsx(ChevronUpIcon,{className:cn("novacon:w-4 novacon:h-4 novacon:transition-transform novacon:duration-200",n&&"novacon:opacity-50",o),style:e,...t}),Kn=({icon:n})=>jsx(Fragment,{children:n}),Sn=(n,o)=>{n(o);},Wn=(n,o)=>{n(o);},Go=forwardRef(({className:n,"aria-label":o,onClick:e,disabled:t=false,customization:r,...a},c)=>{let l=m(),{Icon:g=Jn,Content:s=Kn}=r?.components??{},{onClick:Q=Sn,onKeyDown:z=Wn}=r?.handlers??{},M=useCallback(h=>{Q(C=>{e&&(C.preventDefault(),e(C));},h);},[e,Q]),d=useCallback(h=>{z(C=>{if((C.key==="Enter"||C.key===" ")&&e){C.preventDefault();let B={...C,button:0,buttons:1,clientX:0,clientY:0,movementX:0,movementY:0,offsetX:0,offsetY:0,pageX:0,pageY:0,relatedTarget:null,screenX:0,screenY:0,x:0,y:0,getModifierState:()=>false,initMouseEvent:()=>{}};e(B);}},h);},[e,z]),G=useMemo(()=>r?.classNames?.button?r.classNames.button({disabled:t,hasOnClick:!!e}):cn("novacon:flex novacon:w-full novacon:h-6 novacon:items-center novacon:justify-center","novacon:bg-[var(--tuwa-bg-secondary)] novacon:text-[var(--tuwa-text-primary)]","novacon:transition-colors novacon:duration-200","novacon:hover:bg-[var(--tuwa-bg-tertiary)] novacon:hover:text-[var(--tuwa-text-secondary)]","novacon:focus:outline-none novacon:focus:ring-2 novacon:focus:ring-[var(--tuwa-text-accent)] novacon:focus:ring-inset","novacon:active:bg-[var(--tuwa-bg-quaternary)]","novacon:disabled:opacity-50 novacon:disabled:cursor-not-allowed novacon:disabled:hover:bg-[var(--tuwa-bg-secondary)]",e?"novacon:cursor-pointer":"novacon:cursor-default",n),[r,t,e,n]),E=useMemo(()=>{if(r?.classNames?.icon)return r.classNames.icon({disabled:t})},[r,t]),Z=useMemo(()=>{if(r?.styles?.button)return r.styles.button({disabled:t,hasOnClick:!!e})},[r,t,e]),I=useMemo(()=>{if(r?.styles?.icon)return r.styles.icon({disabled:t})},[r,t]),p=useMemo(()=>jsx(g,{disabled:t,className:E,style:I,"aria-hidden":true}),[g,t,E,I]),i=useMemo(()=>({...r?.buttonProps,...a,ref:c,type:"button",onClick:M,onKeyDown:d,disabled:t,className:G,style:{...Z,...r?.buttonProps?.style,...a.style},"aria-label":o||l.scrollToTop,title:o||l.scrollToTop}),[r?.buttonProps,a,c,M,d,t,G,Z,o,l.scrollToTop]);return jsx("button",{...i,children:jsx(s,{icon:p,disabled:t,ariaLabel:o})})});Go.displayName="ToTopButton";var _o=forwardRef(({className:n,contentClassName:o,viewportClassName:e,children:t,position:r="popper","aria-label":a,reduceMotion:c=false,maxHeight:l=300,animationDuration:g=.2,showScrollButtons:s=true,topButtonProps:Q,bottomButtonProps:z,topButtonCustomization:M,bottomButtonCustomization:d,style:G,contentStyle:E,viewportStyle:Z,...I},p)=>{let i=m(),h=useMemo(()=>c?{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15,layout:{duration:0}}}:{initial:{opacity:0,scaleY:.8,y:-5},animate:{opacity:1,scaleY:1,y:0},exit:{opacity:0,scaleY:.8,y:-5},transition:{duration:g,ease:"easeOut",layout:{duration:.15,ease:"easeOut"}}},[c,g]),w=useMemo(()=>cn("novacon:p-1 novacon:bg-[var(--tuwa-bg-secondary)] novacon:rounded-lg novacon:shadow-xl","novacon:ring-1 novacon:ring-[var(--tuwa-border-primary)] novacon:overflow-hidden",o),[o]),C=useMemo(()=>cn("novacon:overflow-hidden","novacon:w-[--radix-select-trigger-width]","novacon:data-[state=open]:animate-in novacon:data-[state=closed]:animate-out","novacon:data-[state=closed]:fade-out-0 novacon:data-[state=open]:fade-in-0","novacon:data-[state=closed]:zoom-out-95 novacon:data-[state=open]:zoom-in-95","novacon:data-[side=bottom]:slide-in-from-top-2 novacon:data-[side=left]:slide-in-from-right-2","novacon:data-[side=right]:slide-in-from-left-2 novacon:data-[side=top]:slide-in-from-bottom-2",n),[n]),B=useMemo(()=>cn("",e),[e]),D=useMemo(()=>({maxHeight:`${l}px`,...G}),[l,G]),x=useMemo(()=>({...E}),[E]),v=useMemo(()=>({...Z}),[Z]),Y=a||i.chainListContainer;return jsx(F.Portal,{children:jsxs(F.Content,{className:C,style:D,ref:p,position:r,role:"listbox","aria-label":Y,...I,children:[s&&jsx(F.ScrollUpButton,{asChild:true,children:jsx(Go,{customization:M,...Q})}),jsx(F.Viewport,{role:"presentation",className:B,style:v,children:jsx(AnimatePresence,{mode:"wait",initial:false,children:jsx(motion.div,{initial:h.initial,animate:h.animate,exit:h.exit,transition:h.transition,className:w,style:x,layout:!c,role:"group","aria-live":"polite",children:t})})}),s&&jsx(F.ScrollDownButton,{asChild:true,children:jsx(go,{customization:d,...z})})]})})});_o.displayName="SelectContentAnimated";var oe=_n.forwardRef(({children:n,className:o,style:e,onKeyDown:t,...r},a)=>jsx("div",{ref:a,className:o,style:e,onKeyDown:t,...r,children:n}));oe.displayName="DefaultScrollContainer";function nn(n,{strict:o=true}={}){return !n||typeof n!="string"?false:o?/^0x[0-9a-fA-F]*$/.test(n):n.startsWith("0x")}var re="0x0000000000000000000000000000000000000000",se={sm:"novacon:h-4 novacon:w-4",md:"novacon:h-6 novacon:w-6",lg:"novacon:h-8 novacon:w-8",xl:"novacon:h-12 novacon:w-12"},ie=({isLoading:n,showLoading:o,disableAnimation:e})=>{let t=cn("novacon:absolute novacon:inset-0 novacon:rounded-full novacon:bg-[var(--tuwa-bg-muted)]",!e&&o&&n&&"novacon:animate-pulse",(!n||!o)&&"novacon:opacity-0","novacon:transition-opacity novacon:duration-300");return jsx("div",{className:t,"aria-hidden":"true"})},ce=({src:n,isLoading:o,onLoad:e,onError:t,address:r,ensAvatar:a})=>jsx("img",{className:cn("novacon:h-full novacon:w-full novacon:rounded-full novacon:object-cover novacon:relative novacon:z-10","novacon:transition-opacity novacon:duration-300",o?"novacon:opacity-0":"novacon:opacity-100"),src:n,alt:"",onLoad:e,onError:t,loading:"lazy",decoding:"async",draggable:false},`${a||"blockie"}-${r}`),le=({formattedAddress:n})=>jsx("div",{className:"novacon:absolute novacon:inset-0 novacon:flex novacon:items-center novacon:justify-center novacon:text-white novacon:text-xs novacon:font-mono","aria-hidden":"true",children:n.slice(0,2)}),me=n=>{try{return ae(nn(n)?n:re)}catch(o){return console.warn("Failed to generate blockie for address:",n,o),null}},Me=n=>{try{if(!nn(n))return "#6B7280";let o=n.slice(2,8);return o.length===6?`#${o}`:"#6B7280"}catch{return "#6B7280"}},he=(n,o)=>n?`${n.slice(0,6)}...${n.slice(-4)}`:o.unknownWallet,fo=forwardRef(({address:n,ensAvatar:o,className:e,altText:t,size:r="md",showLoading:a=true,onImageLoad:c,onImageError:l,disableAnimation:g=false,customization:s,...Q},z)=>{let M=m(),[d,G]=useState(o??null),[E,Z]=useState(!!o),[I,p]=useState(false),{LoadingOverlay:i=ie,AvatarImage:h=ce,FallbackContent:w=le}=s?.components??{},{generateBlockie:C=me,generateBgColor:B=Me,formatAddress:D=he}=s?.utils??{},x=useMemo(()=>C(n),[n,C]),v=useMemo(()=>B(n),[n,B]),Y=useMemo(()=>D(n,M),[n,M,D]),b=useMemo(()=>t||(I||!o?`${M.walletAvatar} ${Y}`:`${M.ensAvatar} ${Y}`),[t,I,o,Y,M.walletAvatar,M.ensAvatar]),j=useMemo(()=>o??null,[o]);useMemo(()=>{G(j),Z(!!j),p(false);},[j]);let T=useCallback(()=>{Z(false),p(false),c?.();},[c]),J=useCallback(A=>{Z(false),p(true),G(x),l?.(A.nativeEvent);},[x,l]),N=useMemo(()=>s?.classNames?.container?s.classNames.container({size:r,bgColor:v,address:n}):cn(se[r],"novacon:flex-shrink-0 novacon:rounded-full novacon:relative novacon:overflow-hidden","novacon:ring-1 novacon:ring-[var(--tuwa-border-primary)]","novacon:focus-within:ring-2 novacon:focus-within:ring-[var(--tuwa-text-accent)]",e),[s?.classNames?.container,r,v,n,e]),u=useMemo(()=>{let A={backgroundColor:v};return s?.styles?.container?{...A,...s.styles.container({bgColor:v,size:r,address:n})}:A},[s?.styles?.container,v,r,n]),y=d||x||"",P=useMemo(()=>({...s?.containerProps,...Q,ref:z,className:N,style:{...u,...s?.containerProps?.style,...Q.style},role:"img","aria-label":b,title:b}),[s?.containerProps,Q,z,N,u,b]);return jsxs("div",{...P,children:[jsx(i,{isLoading:E,showLoading:a,disableAnimation:g,size:r}),y&&jsx(h,{src:y,isLoading:E,onLoad:T,onError:J,address:n,ensAvatar:o,size:r}),!y&&jsx(w,{address:n,formattedAddress:Y,size:r})]})});fo.displayName="WalletAvatar";var Ge=({isLoading:n})=>n?jsx("div",{className:"novacon:absolute novacon:inset-0 novacon:bg-[var(--tuwa-bg-muted)] novacon:animate-pulse novacon:rounded-full","aria-hidden":"true"}):null,Ee=({walletName:n,hasError:o})=>!o||process.env.NODE_ENV!=="development"?null:jsx("div",{className:"novacon:absolute novacon:top-0 novacon:right-0 novacon:w-2 novacon:h-2 novacon:bg-red-500 novacon:rounded-full",title:`Failed to load icon for ${n}`,"aria-hidden":"true"}),Ze=({walletName:n,className:o,style:e})=>jsx(Web3Icon,{walletKey:n,className:cn("novacon:flex-shrink-0",o),style:e}),eo=forwardRef(({icon:n,name:o,size:e=32,className:t,altText:r,showLoading:a=false,onImageLoad:c,onImageError:l,lazy:g=false,customization:s,...Q},z)=>{let M=m(),[d,G]=useState(false),[E,Z]=useState(!!n),{LoadingOverlay:I=Ge,ErrorIndicator:p=Ee,FallbackIcon:i=Ze}=s?.components??{},h=useMemo(()=>formatWalletName(o),[o]),w=useMemo(()=>r||`${h} ${M.walletIcon}`,[r,h,M.walletIcon]),C=useMemo(()=>{if(!n)return null;try{let T=n.trim();return T&&(T.startsWith("http://")||T.startsWith("https://")||T.startsWith("/")||T.startsWith("data:"))?T:null}catch{return null}},[n]),B=useCallback(()=>{Z(false),G(false),c?.();},[c]),D=useCallback(()=>{Z(false),G(true),l?.();},[l]),x=useMemo(()=>s?.classNames?.container?s.classNames.container({isLoading:E,showLoading:a,size:e}):cn("novacon:relative novacon:inline-flex novacon:items-center novacon:justify-center novacon:flex-shrink-0","novacon:overflow-hidden",a&&E&&"novacon:animate-pulse novacon:bg-[var(--tuwa-bg-muted)]",t),[s?.classNames?.container,E,a,e,t]),v=useMemo(()=>s?.classNames?.image?s.classNames.image({isLoading:E,showLoading:a,hasError:d}):cn("novacon:object-cover novacon:transition-opacity novacon:duration-200","novacon:max-w-full novacon:max-h-full",E&&a?"novacon:opacity-0":"novacon:opacity-100"),[s?.classNames?.image,E,a,d]),Y=useMemo(()=>({width:e,height:e}),[e]),b=useMemo(()=>({...s?.containerProps,...Q,ref:z,className:x,role:"img","aria-label":w,title:w,style:{lineHeight:0,...s?.containerProps?.style,...Q.style}}),[s?.containerProps,Q,z,x,w]),j=useMemo(()=>({...s?.imageProps,src:C,alt:"",className:cn(v,s?.imageProps?.className),style:{...Y,...s?.imageProps?.style},onLoad:B,onError:D,loading:g?"lazy":"eager",decoding:"async",crossOrigin:"anonymous",referrerPolicy:"no-referrer"}),[s?.imageProps,C,v,Y,B,D,g]);return jsxs("div",{...b,children:[jsx(I,{size:e,isLoading:a&&E}),C&&!d?jsx("img",{...j}):jsx(i,{walletName:h,size:e,className:v,style:Y}),jsx(p,{walletName:h,hasError:d})]})});eo.displayName="WalletIcon";var tn=forwardRef(({walletIcon:n,walletName:o,walletChainId:e,items:t=0,onClick:r,className:a,disabled:c=false,loading:l=false,"aria-label":g,title:s},Q)=>{let z=m(),M=useMemo(()=>!!(r&&!c&&!l&&t>1),[r,c,l,t]),d=useMemo(()=>{if(e)return typeof e=="string"?`${OrbitAdapter.SOLANA}:${e}`:e},[e]),G=useMemo(()=>{if(g)return g;let p=[];return o&&p.push(`${o} wallet`),e&&p.push("network selector"),M&&p.push("button"),l&&p.push("loading"),c&&p.push("disabled"),p.join(", ")||"Wallet controls"},[g,o,e,M,l,c]),E=useMemo(()=>s||(l?"Loading...":c?"Button is disabled":M?`Click to select ${o?o+" ":""}options`:o?`${o} wallet`:"Wallet information"),[s,l,c,M,o]),Z=useMemo(()=>cn("novacon:flex novacon:items-center novacon:justify-center novacon:gap-1 novacon:rounded-full","novacon:bg-[var(--tuwa-bg-primary)] novacon:border novacon:border-[var(--tuwa-border-primary)]","novacon:p-1.5 novacon:transition-all novacon:duration-200","novacon:[&_img]:w-6! novacon:[&_img]:h-6! novacon:[&_img]:transition-transform novacon:[&_img]:duration-200",{"novacon:cursor-pointer novacon:hover:[&_img]:scale-95 novacon:active:[&_img]:scale-85 novacon:hover:shadow-sm":M,"novacon:cursor-not-allowed novacon:opacity-50":c&&!l,"novacon:cursor-wait novacon:opacity-75":l,"novacon:cursor-default":!M&&!c&&!l},"novacon:focus-visible:outline-none novacon:focus-visible:ring-2 novacon:focus-visible:ring-[var(--tuwa-border-accent)] novacon:focus-visible:ring-offset-2",a),[M,c,l,a]);return jsxs("button",{ref:Q,type:"button",className:Z,onClick:()=>{M&&r&&r();},disabled:c||l,"aria-label":G,title:E,role:"button",tabIndex:c||l?-1:0,children:[o&&jsx(eo,{name:o,icon:n,altText:`${o} ${z.walletIcon}`,showLoading:l,className:"novacon:flex-shrink-0"}),d&&jsx(Web3Icon,{chainId:d,className:"novacon:flex-shrink-0",title:`Network: ${e}`}),M&&jsx(ChevronArrowWithAnim,{className:"novacon:flex-shrink-0","aria-hidden":"true"}),l&&jsx("div",{className:"novacon:absolute novacon:inset-0 novacon:bg-[var(--tuwa-bg-primary)]/50 novacon:rounded-full novacon:flex novacon:items-center novacon:justify-center","aria-hidden":"true",children:jsx("div",{className:"novacon:w-3 novacon:h-3 novacon:border-2 novacon:border-[var(--tuwa-text-accent)] novacon:border-t-transparent novacon:rounded-full novacon:animate-spin"})})]})});tn.displayName="IconButton";lazy(()=>{try{return import('@tuwaio/nova-transactions').then(n=>({default:n.TransactionsHistory}))}catch(n){return console.warn("Failed to load @tuwaio/nova-transactions package:",n),new Promise(()=>{})}});var sn=memo(({className:n,children:o="Recent",animated:e=true})=>{let t=useMemo(()=>isTouchDevice(),[]),r=useMemo(()=>`linear-gradient(90deg,
2
2
  rgba(255, 255, 255, 0) 0%,
3
3
  var(--tuwa-text-secondary) 20%,
4
4
  rgba(255, 255, 255, 0) 40%
5
- )`,[]);return jsxs("span",{className:cn("novacon:inline-flex novacon:items-center novacon:rounded-full novacon:font-medium novacon:relative novacon:overflow-hidden","novacon:text-[var(--tuwa-text-secondary)] novacon:border novacon:border-[var(--tuwa-border-primary)]",e?"novacon:px-1.5 novacon:py-0 novacon:text-[10px]":"novacon:px-2.5 novacon:py-0.5 novacon:text-xs",a),role:"status","aria-label":typeof o=="string"?o:"Recent",children:[jsx(motion.span,{className:"novacon:absolute novacon:inset-0 novacon:z-0 novacon:pointer-events-none novacon:rounded-full",style:{background:c,backgroundSize:"200% 100%"},initial:{backgroundPositionX:"100%"},animate:n?{backgroundPositionX:"-100%"}:{},transition:{duration:4,ease:"linear",repeat:n?1/0:0}}),jsx("span",{className:"novacon:absolute novacon:z-10 novacon:pointer-events-none novacon:rounded-full novacon:bg-[var(--tuwa-bg-primary)] novacon:inset-[1px]"}),jsx("span",{className:"novacon:relative novacon:z-20 novacon:whitespace-nowrap",children:o})]})});bo.displayName="RecentBadge";var Ro=0;function Uo({title:a,rawError:o,className:n,"aria-label":e,onCopyComplete:c}){let t=i(),{isCopied:r,copy:m}=useCopyToClipboard(),[G]=v.useState(()=>(Ro+=1,`${Ro}-${Date.now()}`)),s=`error-title-${G}`,Q=`error-description-${G}`,M=v.useMemo(()=>o,[o]),l=v.useCallback(async g=>{g.stopPropagation(),g.preventDefault();try{await m(M),c?.(!0);}catch(Z){console.error("Failed to copy error:",Z),c?.(false);}},[m,M,c]),E=v.useCallback(g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),l(g));},[l]),h=v.useMemo(()=>cn("novacon:bg-[var(--tuwa-bg-primary)] novacon:p-4 novacon:rounded-md novacon:w-full","novacon:border novacon:border-[var(--tuwa-border-primary)]",n),[n]),p=v.useMemo(()=>cn("novacon:cursor-pointer novacon:mt-2 novacon:text-xs novacon:font-medium novacon:inline-flex novacon:items-center novacon:space-x-1.5","novacon:focus:outline-none novacon:focus:ring-2 novacon:focus:ring-[var(--tuwa-error-text)] novacon:focus:ring-opacity-50","novacon:rounded-md novacon:px-2 novacon:py-1 novacon:transition-all novacon:duration-200","novacon:hover:bg-[var(--tuwa-error-text)] novacon:hover:bg-opacity-10","novacon:active:bg-[var(--tuwa-error-text)] novacon:active:bg-opacity-20","novacon:text-[var(--tuwa-error-text)] novacon:hover:text-[var(--tuwa-error-text)]",r&&"novacon:bg-[var(--tuwa-success-text)] novacon:bg-opacity-10 novacon:text-[var(--tuwa-success-text)]"),[r]);return jsxs("div",{className:h,role:"alert","aria-live":"assertive","aria-labelledby":s,"aria-describedby":Q,"aria-label":e,children:[jsx("p",{id:s,className:"novacon:text-sm novacon:font-semibold novacon:truncate novacon:text-[var(--tuwa-error-text)]",role:"heading","aria-level":3,title:a,children:a}),jsx("p",{id:Q,className:"novacon:mt-1 novacon:text-xs novacon:break-words novacon:text-[var(--tuwa-error-text)] novacon:opacity-80",role:"text",children:o}),jsxs("button",{onClick:l,onKeyDown:E,className:p,type:"button","aria-label":r?`${t.copied} ${t.copyRawError}`:t.copyRawError,"aria-describedby":`${s} ${Q}`,disabled:!M.trim(),children:[jsx(DocumentDuplicateIcon,{className:cn("novacon:w-4 novacon:h-4 novacon:transition-colors",r&&"novacon:text-[var(--tuwa-success-text)]"),"aria-hidden":"true"}),jsx("span",{className:"novacon:select-none novacon:transition-colors","aria-live":"polite",role:"status",children:r?t.copied:t.copyRawError})]})]})}function Mo({store:a,containerId:o="nova-connect-errors",position:n="top-center",autoClose:e=7e3,draggable:c=false}){let t=i(),{activeWallet:r,walletConnectionError:m}=I(),G=a.getState().switchNetworkError,s=useRef(new Set),Q=useRef(null),M=useMemo(()=>{let Z=!!m,C=!!G,z=!!r?.isConnected;return {hasWalletError:Z,hasSwitchError:C,isConnected:z,hasAnyError:Z||C,primaryError:m||G,errorType:Z?"wallet":C?"switch":null}},[m,G,r?.isConnected]),l=useMemo(()=>{switch(M.errorType){case "wallet":return t.walletConnectionError;case "switch":return t.errorWhenChainSwitching;default:return t.somethingWentWrong}},[M.errorType,t]),E=useMemo(()=>M.primaryError?`${M.errorType}-${M.primaryError.substring(0,50)}`:null,[M.primaryError,M.errorType]),h=useCallback(()=>{Q.current&&(toast.dismiss(Q.current),Q.current=null),toast.dismiss({containerId:o});},[o]),p=useCallback((Z,C,z)=>{if(h(),!s.current.has(z))try{toast.error(jsx(Uo,{title:Z,rawError:C,onCopyComplete:d=>{d&&process.env.NODE_ENV==="development"&&console.log("Error copied to clipboard:",C.substring(0,100));}}),{containerId:o,toastId:z,onClose:()=>{s.current.delete(z),Q.current=null;}}),s.current.add(z),Q.current=z;}catch(d){console.error("Failed to show error toast:",d);}},[o,h]);useEffect(()=>{let{hasAnyError:Z,isConnected:C,primaryError:z}=M;if(C&&!Z){h(),s.current.clear();return}if(Z&&z&&E){if(C&&M.errorType!=="switch")return;p(l,z,E);}},[M,l,E,p,h]),useEffect(()=>()=>{h(),s.current.clear();},[h]);let g=useMemo(()=>({containerId:o,position:n,closeOnClick:false,icon:false,closeButton:ToastCloseButton,autoClose:e,hideProgressBar:false,newestOnTop:false,pauseOnFocusLoss:false,draggable:c,pauseOnHover:true,theme:"light",transition:Bounce,className:"novacon:p-0 novacon:bg-transparent"}),[o,n,e,c]);return jsx(ToastContainer,{...g,role:"alert","aria-live":"assertive","aria-label":t.somethingWentWrong})}Mo.displayName="ErrorsProvider";function lo({labels:a,children:o}){let n=useMemo(()=>a,[a]);if(process.env.NODE_ENV==="development"){(!a||typeof a!="object")&&console.warn("NovaConnectLabelsProvider: labels prop should be an object");let c=["connectWallet","disconnect","connecting","connected","error","success"].filter(t=>!(t in a));c.length>0&&console.warn(`NovaConnectLabelsProvider: Missing required labels: ${c.join(", ")}`);}return jsx(X.Provider,{value:n,children:o})}lo.displayName="NovaConnectLabelsProvider";function fn({labels:a,store:o,children:n}){let e=useMemo(()=>deepMerge(F,a||{}),[a]),[c,t]=useState(o.getState().activeWallet),[r,m]=useState(o.getState().walletConnectionError),[G,s]=useState(false),[Q,M]=useState(false),[l,E]=useState(false),[h,p]=useState(false),[g,Z]=useState("idle"),[C,z]=useState("connectors"),[d,B]=useState(void 0),[y,D]=useState(void 0),[w,q]=useState(""),[H,V]=useState(false),[R,Y]=useState("main");useEffect(()=>o.subscribe(ho=>{t(ho.activeWallet),m(ho.walletConnectionError);}),[]);let Po={walletConnectionError:r,activeWallet:c,isConnectModalOpen:G,setIsConnectModalOpen:s,isConnectedModalOpen:Q,setIsConnectedModalOpen:M,isChainsListOpen:l,setIsChainsListOpen:E,isChainsListOpenMobile:h,setIsChainsListOpenMobile:p,connectedButtonStatus:g,setConnectedButtonStatus:Z,connectedModalContentType:R,setConnectedModalContentType:Y,connectModalContentType:C,setConnectModalContentType:z,selectedAdapter:d,setSelectedAdapter:B,activeConnector:y,setActiveConnector:D,impersonatedAddress:w,setImpersonatedAddress:q,isConnected:H,setIsConnected:V};return jsxs(_.Provider,{value:Po,children:[jsx(Mo,{store:o}),jsx(lo,{labels:e,children:n})]})}export{Mo as ErrorsProvider,lo as NovaConnectLabelsProvider,fn as NovaConnectProvider};//# sourceMappingURL=index.js.map
5
+ )`,[]);return jsxs("span",{className:cn("novacon:inline-flex novacon:items-center novacon:rounded-full novacon:font-medium novacon:relative novacon:overflow-hidden","novacon:text-[var(--tuwa-text-secondary)] novacon:border novacon:border-[var(--tuwa-border-primary)]",t?"novacon:px-1.5 novacon:py-0 novacon:text-[10px]":"novacon:px-2.5 novacon:py-0.5 novacon:text-xs",n),role:"status","aria-label":typeof o=="string"?o:"Recent",children:[jsx(motion.span,{className:"novacon:absolute novacon:inset-0 novacon:z-0 novacon:pointer-events-none novacon:rounded-full",style:{background:r,backgroundSize:"200% 100%"},initial:{backgroundPositionX:"100%"},animate:e?{backgroundPositionX:"-100%"}:{},transition:{duration:4,ease:"linear",repeat:e?1/0:0}}),jsx("span",{className:"novacon:absolute novacon:z-10 novacon:pointer-events-none novacon:rounded-full novacon:bg-[var(--tuwa-bg-primary)] novacon:inset-[1px]"}),jsx("span",{className:"novacon:relative novacon:z-20 novacon:whitespace-nowrap",children:o})]})});sn.displayName="RecentBadge";var Oe=({isCopied:n,className:o,style:e,...t})=>jsx(DocumentDuplicateIcon,{className:cn("novacon:w-4 novacon:h-4 novacon:transition-colors",n&&"novacon:text-[var(--tuwa-success-text)]",o),style:e,...t}),Fe=({title:n,titleId:o,className:e,style:t})=>jsx("p",{id:o,className:cn("novacon:text-sm novacon:font-semibold novacon:truncate novacon:text-[var(--tuwa-error-text)]",e),style:t,role:"heading","aria-level":3,title:n,children:n}),Je=({rawError:n,descriptionId:o,className:e,style:t})=>jsx("p",{id:o,className:cn("novacon:mt-1 novacon:text-xs novacon:break-words novacon:text-[var(--tuwa-error-text)] novacon:opacity-80",e),style:t,role:"text",children:n}),Ke=({icon:n,isCopied:o,copyLabel:e,copiedLabel:t})=>jsxs(Fragment,{children:[n,jsx("span",{className:"novacon:select-none novacon:transition-colors","aria-live":"polite",role:"status",children:o?t:e})]}),Se=(n,o)=>{n(o);},We=(n,o)=>{n(o);},hn=0,jo=forwardRef(({title:n,rawError:o,className:e,"aria-label":t,onCopyComplete:r,customization:a,...c},l)=>{let g=m(),{isCopied:s,copy:Q}=useCopyToClipboard(),[z]=useState(()=>(hn+=1,`${hn}-${Date.now()}`)),M=`error-title-${z}`,d=`error-description-${z}`,{Icon:G=Oe,Title:E=Fe,Description:Z=Je,ButtonContent:I=Ke}=a?.components??{},{onClick:p=Se,onKeyDown:i=We}=a?.handlers??{},h=useMemo(()=>o,[o]),w=useCallback(async A=>{A.stopPropagation(),A.preventDefault();try{await Q(h),r?.(!0);}catch(L){console.error("Failed to copy error:",L),r?.(false);}},[Q,h,r]),C=useCallback(A=>{i(k=>{if(k.key==="Enter"||k.key===" "){k.preventDefault();let mo={...k,button:0,buttons:1,clientX:0,clientY:0,movementX:0,movementY:0,offsetX:0,offsetY:0,pageX:0,pageY:0,relatedTarget:null,screenX:0,screenY:0,x:0,y:0,getModifierState:()=>false,initMouseEvent:()=>{}};w(mo);}},A);},[i,w]),B=useMemo(()=>a?.classNames?.container?a.classNames.container({hasTitle:!!n,hasError:!!o}):cn("novacon:bg-[var(--tuwa-bg-primary)] novacon:p-4 novacon:rounded-md novacon:w-full","novacon:border novacon:border-[var(--tuwa-border-primary)]",e),[a,n,o,e]),D=useMemo(()=>{if(a?.classNames?.title)return a.classNames.title({title:n})},[a,n]),x=useMemo(()=>{if(a?.classNames?.description)return a.classNames.description({rawError:o})},[a,o]),v=useMemo(()=>{let A=!h.trim();return a?.classNames?.button?a.classNames.button({isCopied:s,disabled:A}):cn("novacon:cursor-pointer novacon:mt-2 novacon:text-xs novacon:font-medium novacon:inline-flex novacon:items-center novacon:space-x-1.5","novacon:focus:outline-none novacon:focus:ring-2 novacon:focus:ring-[var(--tuwa-error-text)] novacon:focus:ring-opacity-50","novacon:rounded-md novacon:px-2 novacon:py-1 novacon:transition-all novacon:duration-200","novacon:hover:bg-[var(--tuwa-error-text)] novacon:hover:bg-opacity-10","novacon:active:bg-[var(--tuwa-error-text)] novacon:active:bg-opacity-20","novacon:text-[var(--tuwa-error-text)] novacon:hover:text-[var(--tuwa-error-text)]",s&&"novacon:bg-[var(--tuwa-success-text)] novacon:bg-opacity-10 novacon:text-[var(--tuwa-success-text)]")},[a,s,h]),Y=useMemo(()=>{if(a?.classNames?.icon)return a.classNames.icon({isCopied:s})},[a,s]),b=useMemo(()=>{if(a?.styles?.container)return a.styles.container({hasTitle:!!n,hasError:!!o})},[a,n,o]),j=useMemo(()=>{if(a?.styles?.title)return a.styles.title({title:n})},[a,n]),T=useMemo(()=>{if(a?.styles?.description)return a.styles.description({rawError:o})},[a,o]),J=useMemo(()=>{let A=!h.trim();if(a?.styles?.button)return a.styles.button({isCopied:s,disabled:A})},[a,s,h]),N=useMemo(()=>{if(a?.styles?.icon)return a.styles.icon({isCopied:s})},[a,s]),u=useMemo(()=>jsx(G,{isCopied:s,className:Y,style:N,"aria-hidden":true}),[G,s,Y,N]),y=useMemo(()=>({...a?.containerProps,...c,ref:l,className:B,style:{...b,...a?.containerProps?.style,...c.style},role:"alert","aria-live":"assertive","aria-labelledby":M,"aria-describedby":d,"aria-label":t}),[a?.containerProps,c,l,B,b,M,d,t]),P=useMemo(()=>({...a?.buttonProps,onClick:A=>{p(w,A);},onKeyDown:C,className:v,style:{...J,...a?.buttonProps?.style},type:"button","aria-label":s?`${g.copied} ${g.copyRawError}`:g.copyRawError,"aria-describedby":`${M} ${d}`,disabled:!h.trim()}),[a?.buttonProps,p,w,C,v,J,s,g.copied,g.copyRawError,M,d,h]);return jsxs("div",{...y,children:[jsx(E,{title:n,titleId:M,className:D,style:j}),jsx(Z,{rawError:o,descriptionId:d,className:x,style:T}),jsx("button",{...P,children:jsx(I,{icon:u,isCopied:s,copyLabel:g.copyRawError,copiedLabel:g.copied})})]})});jo.displayName="ToastError";var Xe=({title:n,rawError:o,onCopyComplete:e,errorType:t,isConnected:r,...a})=>jsx(jo,{title:n,rawError:o,onCopyComplete:e,customization:a.customization}),$e=n=>{let o=m();return jsx(ToastContainer,{...n,role:"alert","aria-live":"assertive","aria-label":o.somethingWentWrong})},_e=(n,o)=>{n(o.title,o.rawError,o.errorKey);},oa=n=>{n();},na=(n,o)=>{n&&process.env.NODE_ENV==="development"&&console.log("Error copied to clipboard:",o.substring(0,100));},ea=n=>n,aa=n=>n;function ko({store:n,containerId:o="nova-connect-errors",position:e="top-center",autoClose:t=7e3,draggable:r=false,customization:a}){let c=m(),{activeWallet:l,walletConnectionError:g}=f(),s=n.getState().switchNetworkError,{ToastError:Q=Xe,Container:z=$e}=a?.components??{},{showError:M=_e,dismissError:d=oa,onCopyComplete:G=na}=a?.handlers??{},{errorTitle:E=ea,errorHash:Z=aa}=a??{},I=useRef(new Set),p=useRef(null),i=useMemo(()=>{let N=!!g,u=!!s,y=!!l?.isConnected;return {hasWalletError:N,hasSwitchError:u,isConnected:y,hasAnyError:N||u,primaryError:g||s||null,errorType:N?"wallet":u?"switch":null}},[g,s,l?.isConnected]),h=useMemo(()=>{switch(i.errorType){case "wallet":return c.walletConnectionError;case "switch":return c.errorWhenChainSwitching;default:return c.somethingWentWrong}},[i.errorType,c]),w=useMemo(()=>E(h,{errorType:i.errorType}),[E,h,i.errorType]),C=useMemo(()=>i.primaryError?`${i.errorType}-${i.primaryError.substring(0,50)}`:null,[i.primaryError,i.errorType]),B=useMemo(()=>Z(C,{primaryError:i.primaryError,errorType:i.errorType}),[Z,C,i.primaryError,i.errorType]),D=useCallback(()=>{d(()=>{p.current&&(toast.dismiss(p.current),p.current=null),toast.dismiss({containerId:o});});},[o,d]),x=useCallback((N,u)=>{G(N,u,i.errorType);},[G,i.errorType]),v=useCallback((N,u,y)=>{if(D(),!I.current.has(y))try{let P={containerId:o,toastId:y,onClose:()=>{I.current.delete(y),p.current=null;}},A=a?.toastOptions?.error?.({title:N,rawError:u,errorType:i.errorType,isConnected:i.isConnected}),L={...P,...A};toast.error(jsx(Q,{title:N,rawError:u,errorType:i.errorType,isConnected:i.isConnected,onCopyComplete:k=>x(k,u),customization:a?.toastErrorCustomization}),L),I.current.add(y),p.current=y;}catch(P){console.error("Failed to show error toast:",P);}},[D,o,a,Q,i.errorType,i.isConnected,x]),Y=useCallback((N,u,y)=>{M(v,{title:N,rawError:u,errorKey:y,errorType:i.errorType});},[v,M,i.errorType]);useEffect(()=>{let{hasAnyError:N,isConnected:u,primaryError:y}=i;if(u&&!N){D(),I.current.clear();return}if(N&&y&&B){if(u&&i.errorType!=="switch")return;Y(w,y,B);}},[i,w,B,Y,D]),useEffect(()=>()=>{D(),I.current.clear();},[D]);let b=useMemo(()=>a?.classNames?.container?a.classNames.container({hasErrors:i.hasAnyError,errorType:i.errorType}):"novacon:p-0 novacon:bg-transparent",[a,i.hasAnyError,i.errorType]),j=useMemo(()=>{if(a?.styles?.container)return a.styles.container({hasErrors:i.hasAnyError,errorType:i.errorType})},[a,i.hasAnyError,i.errorType]),T=useMemo(()=>({containerId:o,position:e,closeOnClick:false,icon:false,closeButton:ToastCloseButton,autoClose:t,hideProgressBar:false,newestOnTop:false,pauseOnFocusLoss:false,draggable:r,pauseOnHover:true,theme:"light",transition:Bounce}),[o,e,t,r]),J=useMemo(()=>({...T,...a?.containerProps,className:b,style:{...j,...a?.containerProps?.style}}),[T,a?.containerProps,b,j]);return jsx(z,{...J})}ko.displayName="ErrorsProvider";function Po({labels:n,children:o}){let e=useMemo(()=>n,[n]);if(process.env.NODE_ENV==="development"){(!n||typeof n!="object")&&console.warn("NovaConnectLabelsProvider: labels prop should be an object");let r=["connectWallet","disconnect","connecting","connected","error","success"].filter(a=>!(a in n));r.length>0&&console.warn(`NovaConnectLabelsProvider: Missing required labels: ${r.join(", ")}`);}return jsx(uo.Provider,{value:e,children:o})}Po.displayName="NovaConnectLabelsProvider";var ca=({labels:n,children:o})=>jsx(Po,{labels:n,children:o}),la=({store:n,customization:o})=>jsx(ko,{store:n,customization:o}),ma=(n,o)=>deepMerge(n,o||{}),Ma=n=>n,ha=()=>{},Ca=()=>{},pa=()=>{},ga=n=>n,da=(n,o,e)=>n;function mn({labels:n,store:o,children:e,customization:t}){let{LabelsProvider:r=ca,ErrorsProvider:a=la}=t?.components??{},{merge:c=ma,transform:l=Ma}=t?.labels??{},{onStoreSubscribed:g=ha,onConnectionStateChange:s=Ca,onErrorStateChange:Q=pa}=t?.initialization??{},{transform:z=ga}=t?.contextValue??{},{providerTree:M=da}=t?.rendering??{},d=useMemo(()=>c(Co,n||{}),[n,c]),[G,E]=useState(o.getState().activeWallet),[Z,I]=useState(o.getState().walletConnectionError),[p,i]=useState(false),[h,w]=useState(false),[C,B]=useState(false),[D,x]=useState(false),[v,Y]=useState("idle"),[b,j]=useState("connectors"),[T,J]=useState(void 0),[N,u]=useState(void 0),[y,P]=useState(""),[A,L]=useState(false),[k,mo]=useState("main"),O=useMemo(()=>({isConnected:A,activeWallet:G,walletConnectionError:Z,modalStates:{isConnectModalOpen:p,isConnectedModalOpen:h,isChainsListOpen:C,isChainsListOpenMobile:D},contentTypes:{connectModal:b,connectedModal:k},statuses:{connectedButton:v}}),[A,G,Z,p,h,C,D,b,k,v]),En=useMemo(()=>l(d,O),[d,l,O]),Zn=useCallback(($,Mo)=>{s($,Mo,O);},[s,O]),Qn=useCallback($=>{Q($,O);},[Q,O]);useEffect(()=>{let $=o.subscribe(Mo=>{let ho=Mo.activeWallet,wo=Mo.walletConnectionError,vo=!!ho?.isConnected;E(ho),I(wo),(vo!==A||ho!==G)&&(L(vo),Zn(vo,ho)),wo!==Z&&Qn(wo);});return g(O),$},[o]);let Oo=useMemo(()=>z({walletConnectionError:Z,activeWallet:G,isConnectModalOpen:p,setIsConnectModalOpen:i,isConnectedModalOpen:h,setIsConnectedModalOpen:w,isChainsListOpen:C,setIsChainsListOpen:B,isChainsListOpenMobile:D,setIsChainsListOpenMobile:x,connectedButtonStatus:v,setConnectedButtonStatus:Y,connectedModalContentType:k,setConnectedModalContentType:mo,connectModalContentType:b,setConnectModalContentType:j,selectedAdapter:T,setSelectedAdapter:J,activeConnector:N,setActiveConnector:u,impersonatedAddress:y,setImpersonatedAddress:P,isConnected:A,setIsConnected:L},O),[Z,G,p,i,h,w,C,B,D,x,v,Y,k,mo,b,j,T,J,N,u,y,P,A,L,z,O]),No=jsx(a,{store:o,customization:t?.errors}),Ao=jsx(r,{labels:En,children:e}),zn=jsxs(po.Provider,{value:Oo,children:[No,Ao]}),In=jsxs(po.Provider,{value:Oo,children:[No,Ao]}),Nn=M(In,{ErrorsProvider:No,LabelsProvider:Ao,MainContent:zn},O);return jsx(Fragment,{children:Nn})}mn.displayName="NovaConnectProvider";export{ko as ErrorsProvider,Po as NovaConnectLabelsProvider,mn as NovaConnectProvider};//# sourceMappingURL=index.js.map
6
6
  //# sourceMappingURL=index.js.map