@naculus/connect-appkit-react 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -2
- package/dist/index.d.ts +31 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var Cs=Object.create;var Ut=Object.defineProperty;var hs=Object.getOwnPropertyDescriptor;var ys=Object.getOwnPropertyNames;var Ss=Object.getPrototypeOf,Es=Object.prototype.hasOwnProperty;var ws=(e,t)=>{for(var r in t)Ut(e,r,{get:t[r],enumerable:!0})},cr=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ys(t))!Es.call(e,n)&&n!==r&&Ut(e,n,{get:()=>t[n],enumerable:!(s=hs(t,n))||s.enumerable});return e};var Me=(e,t,r)=>(r=e!=null?Cs(Ss(e)):{},cr(t||!e||!e.__esModule?Ut(r,"default",{value:e,enumerable:!0}):r,e)),ks=e=>cr(Ut({},"__esModule",{value:!0}),e);var qs={};ws(qs,{AppkitAccordion:()=>Ho,AppkitAccountButton:()=>Ko,AppkitAlertDialog:()=>qo,AppkitAvatar:()=>Vo,AppkitBadge:()=>$o,AppkitButton:()=>Go,AppkitCard:()=>jo,AppkitCardContent:()=>zo,AppkitCardDescription:()=>Qo,AppkitCardFooter:()=>Xo,AppkitCardHeader:()=>Yo,AppkitCardTitle:()=>Jo,AppkitCheckbox:()=>Zo,AppkitCollapsible:()=>es,AppkitConnectButton:()=>ts,AppkitDialog:()=>ns,AppkitDropdownMenu:()=>rs,AppkitInput:()=>os,AppkitPopover:()=>ss,AppkitProgress:()=>as,AppkitScrollArea:()=>is,AppkitSelect:()=>ls,AppkitSeparator:()=>cs,AppkitSkeleton:()=>us,AppkitSwitch:()=>ps,AppkitTabs:()=>ds,AppkitToggleGroup:()=>ms,AppkitTooltip:()=>fs,DEFAULT_EVM_CHAINS:()=>jn,LAMPORTS_PER_SOL:()=>J.LAMPORTS_PER_SOL,PassphraseCancelledError:()=>J.PassphraseCancelledError,PassphraseGate:()=>J.PassphraseGate,SolanaRpcError:()=>J.SolanaRpcError,TokenSelector:()=>ir,TxMonitorContext:()=>Qn,WALLET_ERROR_DESCRIPTIONS:()=>sr,WALLET_ERROR_TITLES:()=>or,Web3ConnectProvider:()=>Sr,Web3Context:()=>Dt,buildDelegationPolicyMessage:()=>zn.buildDelegationPolicyMessage,clearClient:()=>fr,createClient:()=>Wt,formatSol:()=>J.formatSol,getChainById:()=>yr,getClient:()=>Ot,getDefaultChains:()=>_t,getLatestBlockhash:()=>J.getLatestBlockhash,getLocale:()=>Po,getSignatureStatus:()=>J.getSignatureStatus,getSolanaBalance:()=>J.getSolanaBalance,getUserFriendlyError:()=>gt,isRetryableError:()=>mn,parseSol:()=>J.parseSol,resetSessionKeyManager:()=>Or,setLocale:()=>Uo,t:()=>dn,useAccount:()=>H,useBalance:()=>xr,useCapabilities:()=>Mt,useChain:()=>ie,useCompareCosts:()=>qn,useConnect:()=>Ar,useCreateSessionKey:()=>Ur,useDelegate:()=>Rr,useDelegation:()=>nt,useDelegationPolicy:()=>_r,useDisconnect:()=>Dr,useERC20Allowance:()=>Hr,useERC20Approve:()=>Kr,useERC20Transfer:()=>qr,useERC20TransferSimulation:()=>jr,useEmbeddedWallet:()=>Mr,useExecuteCalls:()=>Vt,useExecuteRoute:()=>Vn,useLastTx:()=>Qr,useLookupAddress:()=>Jr,useNotification:()=>eo,usePassphraseGate:()=>no,useResolveName:()=>oo,useRevokeSession:()=>Pr,useRouteQuote:()=>$n,useSIWxLogin:()=>rn,useSIWxSession:()=>io,useSendCalls:()=>Kt,useSendTransaction:()=>it,useSendUserOperation:()=>so,useSendWithSession:()=>Wr,useSession:()=>ao,useSessionKeys:()=>Gt,useSignInWithEthereum:()=>lo,useSignInWithX:()=>pt,useSignMessage:()=>zt,useSimulateTransfer:()=>po,useSiwxAuthSession:()=>mo,useSmartAccount:()=>go,useSolanaAccount:()=>un,useSolanaBalance:()=>yo,useSolanaRoles:()=>wo,useSolanaTransaction:()=>xo,useSwitchChain:()=>Ao,useTokenBalance:()=>bo,useTokenList:()=>Tt,useTokenSearch:()=>It,useTransactionSimulation:()=>Jt,useTxHistory:()=>Ro,useTxMonitor:()=>zr,useUserOpStatus:()=>To,useValidateDestination:()=>No,useViemClient:()=>le,useWallet:()=>_o,useWeb3:()=>U,useWeb3ErrorHandler:()=>Do,validateDestination:()=>rr});module.exports=ks(qs);var J=require("@naculus/connect-core");var ur=require("@naculus/connect-appkit-core"),ue=require("react");function qn(e,t){let{operation:r,chains:s,options:n}=e,[l,i]=(0,ue.useState)([]),[C,u]=(0,ue.useState)(!1),[c,g]=(0,ue.useState)(null),o=(0,ue.useRef)(!0),a=(0,ue.useRef)(0),p=(0,ur.compareCostsKey)(e),f=(0,ue.useCallback)(async()=>{if(!s||s.length===0){i([]);return}if(!t)return;let S=++a.current;u(!0),g(null);try{let h=await t(r,s,n);o.current&&S===a.current&&i(h)}catch(h){o.current&&S===a.current&&(g(h instanceof Error?h:new Error(String(h))),i([]))}finally{o.current&&S===a.current&&u(!1)}},[p,t]);(0,ue.useEffect)(()=>{f()},[f]),(0,ue.useEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]);let d=(0,ue.useCallback)(async()=>{await f()},[f]);return{comparisons:l,loading:C,error:c,refresh:d}}var Pt=require("@naculus/connect-appkit-core"),fe=require("react");function Vn(e){let[t,r]=(0,fe.useState)(!1),[s,n]=(0,fe.useState)(null),[l,i]=(0,fe.useState)(null),C=(0,fe.useRef)(!0),u=(0,fe.useRef)(!1);(0,fe.useEffect)(()=>(C.current=!0,()=>{C.current=!1}),[]);let c=(0,fe.useCallback)(async(o,a,p)=>{if(!e)return i({code:"no_executor",message:"No executeRoute function provided"}),n(null),null;let f=(0,Pt.validateRouteRecipient)(o,a);if(f)return i(f),n(null),null;if(u.current)return i({code:"execution_in_progress",message:"A route execution is already in progress"}),null;u.current=!0,r(!0),i(null),n(null);try{let d=await e(o,a,p);return C.current&&n(d),d}catch(d){return C.current&&i((0,Pt.toExecuteRouteError)(d)),null}finally{u.current=!1,C.current&&r(!1)}},[e]),g=(0,fe.useCallback)(()=>{n(null),i(null),r(!1)},[]);return{execute:c,executing:t,result:s,error:l,reset:g}}var pr=require("@naculus/connect-appkit-core"),ae=require("react");function $n(e,t){let{fromChain:r,toChain:s,fromToken:n,toToken:l,amount:i,options:C}=e,[u,c]=(0,ae.useState)([]),[g,o]=(0,ae.useState)(!1),[a,p]=(0,ae.useState)(null),f=(0,ae.useRef)(null),d=(0,ae.useRef)(!0),S=(0,ae.useCallback)(async()=>{if(!(0,pr.isQuotableInput)({fromChain:r,toChain:s,fromToken:n,amount:i})){c([]);return}if(t){o(!0),p(null);try{let E=await t(r,s,n,i,C,l);d.current&&c(E)}catch(E){d.current&&(p(E instanceof Error?E:new Error(String(E))),c([]))}finally{d.current&&o(!1)}}},[r,s,n,l,i,C,t]);(0,ae.useEffect)(()=>{if(f.current&&clearTimeout(f.current),!r||!s||!n||!i){c([]);return}return f.current=setTimeout(()=>{S()},300),()=>{f.current&&clearTimeout(f.current)}},[S,r,s,n,i]),(0,ae.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let h=(0,ae.useCallback)(async()=>{await S()},[S]),w=(0,ae.useCallback)(()=>{c([]),p(null),o(!1)},[]);return{quotes:u,loading:g,error:a,refresh:h,clear:w}}var X=require("@naculus/connect-core"),ee=require("@naculus/connector-evm-injected"),dr=require("@naculus/connect-core"),mr=require("@naculus/connector-walletconnect"),Gn=null;function Wt(e){let t=null,r=(0,mr.createWalletConnectConnector)({projectId:e.projectId,metadata:e.metadata}),s=null,n=null,l=null,i=null,C=e.passphrasePrompt&&e.enableEmbedded&&!e.embeddedConfig?.encryptionPassphrase?new dr.PassphraseGate:null;e.enableEmbedded&&(n=import("@naculus/connector-embedded").then(o=>{let a={...e.embeddedConfig};C&&(a.encryptionPassphrase=C.request),e.enablePasskeys&&a.encryptionPassphrase&&!a.prfUnlock&&(a.prfUnlock={async derive(f){i&&await i;let d=l;return d?.hasCredential()?d.derivePrfKey(f):null}}),s=o.createPocketConnector(a),t?._setEmbeddedConnector(s)}).catch(o=>{X.logger.warn("react/client","Embedded wallet connector not available:",o),s=null})),e.enablePasskeys&&(i=import("@naculus/connector-passkeys").then(o=>{l=o.createPasskeysConnector(),t?._setPasskeysConnector(l)}).catch(o=>{X.logger.warn("react/client","Passkeys connector not available:",o),l=null}));let u=null,c=null;e.enableSolana&&(c=import("@naculus/connector-solana").then(o=>{let a=o.solanaConnector;e.solanaDefaultChain&&"configure"in a&&a.configure({defaultChain:e.solanaDefaultChain}),u=a,typeof window<"u"&&"startDiscovery"in a&&a.startDiscovery(),t?._setSolanaConnector(u)}).catch(o=>{X.logger.warn("react/client","Solana connector not available:",o),u=null})),typeof window<"u"&&ee.eip6963Connector.startDiscovery();let g={connector:r,get embeddedConnector(){return s},getEmbeddedConnector:async()=>(n&&await n,s),get passkeysConnector(){return l},passphraseGate:C,solanaRpcUrl:e.solanaRpcUrl??null,get solanaConnector(){return u},connect:()=>r.connect(),connectInjected:async o=>ee.eip6963Connector.connect(o),connectEmbedded:async()=>{if(n&&await n,!s)throw new Error("Embedded wallet not enabled. Set enableEmbedded: true in config.");return s.connect()},connectPasskeys:async()=>{if(i&&await i,!l)throw new Error("Passkeys connector not enabled. Set enablePasskeys: true in config.");return l.connect()},startPairing:()=>r.startPairing(),completePairing:()=>r.completePairing(),cancelPairing:()=>r.cancelPairing?.(),signMessage:async(o,a)=>{if(o.id?.startsWith("eip6963-"))return ee.eip6963Connector.signMessage(o,a);if(o.walletType==="passkeys"&&l)return l.signMessage(o,a);if(o.walletType==="embedded"){if(!s)throw new X.WalletError("wallet_unavailable","Embedded wallet connector not available.");return s.signMessage(o,a)}if(o.walletType==="solana"){if(c&&await c,u)return u.signMessage(o,a);throw new X.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return r.signMessage(o,a)},signTransaction:async(o,a)=>{if(o.id?.startsWith("eip6963-"))return ee.eip6963Connector.signTransaction(o,a);if(o.walletType==="embedded"){if(!s)throw new X.WalletError("wallet_unavailable","Embedded wallet connector not available.");return s.signTransaction(o,a)}if(o.walletType==="solana"){if(c&&await c,u)return u.signTransaction(o,a);throw new X.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return r.signTransaction(o,a)},sendTransaction:async(o,a)=>{if(o.id?.startsWith("eip6963-"))return ee.eip6963Connector.sendTransaction(o,a);if(o.walletType==="passkeys"&&l)return l.sendTransaction(o,a);if(o.walletType==="embedded"){if(!s)throw new X.WalletError("wallet_unavailable","Embedded wallet connector not available.");return s.sendTransaction(o,a)}if(o.walletType==="solana"){if(c&&await c,u)return u.sendTransaction(o,a);throw new X.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return r.sendTransaction(o,a)},onAccountsChanged:(o,a)=>{let p=()=>{};return o.id?.startsWith("eip6963-")?ee.eip6963Connector.onAccountsChanged?.(o,a)??p:o.walletType==="embedded"?s?.onAccountsChanged?.(o,a)??p:o.walletType==="passkeys"?p:o.walletType==="solana"?u?.onAccountsChanged?.(o,a)??p:r.onAccountsChanged?.(o,a)??p},onChainChanged:(o,a)=>{let p=()=>{};return o.id?.startsWith("eip6963-")?ee.eip6963Connector.onChainChanged?.(o,a)??p:o.walletType==="passkeys"||o.walletType==="embedded"?p:o.walletType==="solana"?u?.onChainChanged?.(o,a)??p:r.onChainChanged?.(o,a)??p},getCapabilities:o=>o.id?.startsWith("eip6963-")?ee.eip6963Connector.getCapabilities?.(o):o.walletType==="passkeys"?l?.getCapabilities?.(o):o.walletType==="solana"?u?.getCapabilities?.(o):o.walletType==="embedded"?s?.getCapabilities?.(o):r.getCapabilities?.(o),sendCalls:async(o,a,p,f)=>{if(o.id?.startsWith("eip6963-"))return ee.eip6963Connector.sendCalls(o,a,p,f);if(o.walletType==="passkeys"&&l)return l.sendCalls(o,a,p,f);if(o.walletType==="solana"){if(c&&await c,u)return u.sendCalls(o,a,p,f);throw new X.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}if(o.walletType==="embedded"){if(!s?.sendCalls)throw new X.WalletError("method_not_allowed","Embedded wallet does not support sendCalls");return s.sendCalls(o,a,p,f)}if(!r.sendCalls)throw new X.WalletError("method_not_allowed","sendCalls not supported by this connector");return r.sendCalls(o,a,p,f)},showCallsStatus:async(o,a)=>{if(o.id?.startsWith("eip6963-"))return ee.eip6963Connector.showCallsStatus(o,a);if(o.walletType==="passkeys"||o.walletType==="embedded")throw new X.WalletError("method_unsupported",`${o.walletType} wallets have no UI to display a call bundle.`);if(!r.showCallsStatus)throw new X.WalletError("method_unsupported","This connector cannot display call status.");return r.showCallsStatus(o,a)},getCallsStatus:async(o,a)=>{if(o.id?.startsWith("eip6963-")&&ee.eip6963Connector.getCallsStatus)return ee.eip6963Connector.getCallsStatus(o,a);if(o.walletType==="passkeys"&&l?.getCallsStatus)return l.getCallsStatus(o,a);if(o.walletType==="embedded")throw new X.WalletError("method_not_allowed","Embedded wallet does not support getCallsStatus");if(!r.getCallsStatus)throw new X.WalletError("method_not_allowed","getCallsStatus not supported by this connector");return r.getCallsStatus(o,a)},reconnect:async o=>o.walletType==="eip6963"?ee.eip6963Connector.reconnect(o):o.walletType==="embedded"?s?s.reconnect(o):o:o.walletType==="solana"?o:r.reconnect(o),disconnect:async o=>{if(o.id?.startsWith("eip6963-")||o.walletType==="eip6963")return ee.eip6963Connector.disconnect(o);if(o.walletType==="embedded"&&s)return s.disconnect();if(o.walletType==="passkeys"&&l)return l.disconnect(o);if(o.walletType==="solana"){if(c&&await c,u)return u.disconnect(o);throw new X.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return r.disconnect(o)},getAllConnectors:()=>{let o=[r];return s&&o.push(s),l&&o.push(l),u&&o.push(u),o},_setEmbeddedConnector:o=>{s=o},_setPasskeysConnector:o=>{l=o},_setSolanaConnector:o=>{u=o}};return t=g,Gn=g,g}function Ot(){return Gn}function fr(){Gn=null}var yt=require("@naculus/connect-core"),wr=require("react");var Z=require("@naculus/connect-core"),ht=require("@naculus/connector-evm-injected"),O=require("react");var gr=require("@naculus/connect-core"),Nt=require("@naculus/siwx");function Xe(e,t){let r=t.split(":",1)[0],n=(e.namespaces[r]?.accounts??[]).filter(l=>l.startsWith(`${r}:`)).map(l=>({namespace:r,caip10:l}))[0];if(n)return{...n,address:n.caip10.split(":").pop()??n.caip10}}function xs(e){return e.namespaces.eip155?.chains?.[0]??e.namespaces.solana?.chains?.[0]??e.namespaces.xrpl?.chains?.[0]??"eip155:1"}async function Cr(e){let{session:t,siwx:r,signMessage:s}=e;if(!r||!t)return{kind:"skipped"};try{let n=xs(t),l=Xe(t,n);if(!l)throw new Error("No account found in session");let{address:i}=l,C=await r.createMessage({address:i,chainId:n}),u=(0,Nt.parseSiwxMessage)(C);if(!u?.nonce)throw new Error("SIWx message must contain a nonce");await(0,Nt.issueNonce)(u.nonce);let c=await s(t,{message:C,address:i,chainId:n});return await r.handleSignComplete?.({message:C,signature:c}),{kind:"authenticated",address:i,chainId:n}}catch(n){let l=n instanceof Error?n:new Error("Wallet authentication failed");return gr.logger.error("appkit/core","SIWx authentication failed:",n),{kind:"failed",error:l,fatal:r.required!==!1}}}var Ne=require("@naculus/connect-appkit-core");var hr=require("@naculus/connect-appkit-core"),Ee=require("@naculus/connect-core"),vs=[{caip2:"eip155:5",name:"Goerli",rpcUrl:"https://goerli.blockpi.network/v1/rpc/public",explorerUrl:"https://goerli.etherscan.io",token:"ETH"},{caip2:"eip155:80001",name:"Mumbai",rpcUrl:"https://rpc-mumbai.maticvigil.com",explorerUrl:"https://mumbai.polygonscan.com",token:"MATIC"},{caip2:"eip155:421613",name:"Arbitrum Goerli",rpcUrl:"https://goerli-rollup.arbitrum.io/rpc",explorerUrl:"https://goerli.arbiscan.io",token:"ETH"},{caip2:"eip155:420",name:"Optimism Goerli",rpcUrl:"https://goerli.optimism.io",explorerUrl:"https://goerli-optimism.etherscan.io",token:"ETH"}];function As(e){let t=Ee.CHAINS[e];if(!t||!t.explorerUrl)return null;let r=t.caip2Id;return{caip2:r,name:t.name,rpcUrl:(0,Ee.getRpcUrl)(r,Ee.DEFAULT_RPC_URLS[r]??""),explorerUrl:t.explorerUrl,token:t.nativeCurrency.symbol}}function bs(){if(!Ee.CHAINS)return[];let e=[],t=Object.keys(Ee.CHAINS).map(Number).sort((r,s)=>r-s);for(let r of t){let s=As(r);s&&e.push(s)}for(let r of vs){let s=(0,Ee.eip155Reference)(r.caip2);(s===null||!Ee.CHAINS[s])&&e.push(r)}return e}var jn=bs();function yr(e,t){return(0,hr.resolveChain)(e,t)??void 0}function _t(){return[...jn]}var Er=require("react/jsx-runtime"),Dt=(0,O.createContext)(null);function Sr({children:e,config:t,autoConnect:r=!0}){let[s,n]=(0,O.useReducer)(Ne.web3Reducer,Ne.initialWeb3State),l=(0,O.useMemo)(()=>t.chains??_t(),[t.chains]),i=t.connectionTimeout??3e4,C=t.maxRetries??2,u=(0,O.useMemo)(()=>new Z.LocalStorageSessionStorage(t.storageKey??"naculus_web3_session",t.encryptionKey),[t.storageKey,t.encryptionKey]),c=(0,O.useMemo)(()=>Wt({projectId:t.projectId,metadata:t.metadata,enableEmbedded:t.enableEmbedded,embeddedConfig:t.embeddedConfig,enablePasskeys:t.enablePasskeys,enableSolana:t.enableSolana,solanaDefaultChain:t.solanaDefaultChain}),[t.projectId,t.metadata,t.enableEmbedded,t.embeddedConfig,t.enablePasskeys,t.enableSolana,t.solanaDefaultChain]),g=(0,O.useRef)(null),o=(0,O.useRef)(null),a=(0,O.useMemo)(()=>{let m=(0,Z.createConnectorManager)();for(let _ of[ht.eip6963Connector,...c.getAllConnectors()])m.register(_.id,_);let y={},k={};for(let _ of l){let D=_.caip2;_.rpcUrl&&(y[D]=_.rpcUrl),_.token&&(k[D]={name:_.name,symbol:_.token,decimals:18})}let P=(0,Z.createSessionManager)(m,{autoRefreshFeeOnSwitch:t.autoRefreshFeeOnSwitch??!0,defaultRpcUrls:y,defaultCurrencies:k,encryptionKey:t.encryptionKey});return g.current=P,P},[c,l,t.autoRefreshFeeOnSwitch,t.encryptionKey]);(0,O.useEffect)(()=>{let m=D=>{let{walletSession:De}=D.bundle;n({type:"SET_SESSION",payload:De});let lr=[];Object.values(De.namespaces).forEach(gs=>{lr.push(...gs.accounts)}),n({type:"SET_ACCOUNTS",payload:lr}),n({type:"SET_CHAIN",payload:D.bundle.activeChainId}),n({type:"SET_STATUS",payload:"connected"})},y=()=>{n({type:"RESET"})},k=D=>{n({type:"SET_CHAIN",payload:D.newChainId})},P=D=>m(D),_=()=>{u.clear(),n({type:"RESET"})};return a.on("sessionConnected",m),a.on("sessionDisconnected",y),a.on("chainChanged",k),a.on("sessionScopeChanged",P),a.on("sessionRevoked",_),()=>{a.off("sessionConnected",m),a.off("sessionDisconnected",y),a.off("chainChanged",k),a.off("sessionScopeChanged",P),a.off("sessionRevoked",_)}},[a,u]),(0,O.useEffect)(()=>{let m=()=>{u.clear(),n({type:"RESET"})};c.connector.onSessionExpiry(m)},[c,u]);let p=(0,O.useCallback)(()=>{for(let m of[ht.eip6963Connector,...c.getAllConnectors()])a.registerConnector(m)},[c,a]),f=(0,O.useCallback)(async m=>{p();let y=[ht.eip6963Connector,...c.getAllConnectors()].find(P=>P.id===m.walletType||P.kind===m.walletType);y&&!m.connectorId&&(m.connectorId=y.id);let k=m.namespaces.eip155?.chains?.[0]??m.namespaces.solana?.chains?.[0]??m.namespaces.xrpl?.chains?.[0];k&&await a.attach(m,k)},[c,a,p]),d=(0,O.useCallback)(m=>{if(n({type:"SET_SESSION",payload:m}),m){let y=[];Object.values(m.namespaces).forEach(D=>{y.push(...D.accounts)}),n({type:"SET_ACCOUNTS",payload:y});let k=m.namespaces.eip155?.chains?.[0],P=m.namespaces.solana?.chains?.[0],_=m.namespaces.xrpl?.chains?.[0];n({type:"SET_CHAIN",payload:k??P??_??null})}else n({type:"SET_ACCOUNTS",payload:[]}),n({type:"SET_CHAIN",payload:null})},[]);(0,O.useEffect)(()=>{let m=s.session,y=c;return!m||!y?.onAccountsChanged?void 0:y.onAccountsChanged(m,P=>{if(P.length===0){u.clear().finally(()=>n({type:"RESET"}));return}d(m),u.save(m)})},[s.session,c,u,d]),(0,O.useEffect)(()=>{let m=s.session,y=c;if(!(!m||!y?.onChainChanged))return y.onChainChanged(m,k=>{d(m),u.save(m);let P=a.syncExternalChain;if(!P)return;let _=P.call(a,k).catch(D=>{Z.logger.warn("react/provider","External chain sync error:",D)});o.current=_,_.finally(()=>{o.current===_&&(o.current=null)})})},[s.session,c,u,d,a]);let S=(0,O.useCallback)(async m=>{if(!t.siwx||!m)return!0;n({type:"SET_STATUS",payload:"authenticating"});let y=await Cr({session:m,siwx:t.siwx,signMessage:(k,P)=>c.signMessage(k,P)});return y.kind==="failed"&&y.fatal?(await u.clear(),n({type:"RESET"}),n({type:"SET_ERROR",payload:y.error}),!1):!0},[t.siwx,c,u]),h=(0,O.useCallback)(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let m=await(0,Ne.withTimeout)(c.connect(),i,"Wallet connect");await u.save(m),d(m);try{await f(m)}catch(y){Z.logger.warn("react/provider","SessionManager sync error:",y)}if(!await S(m))return;n({type:"SET_STATUS",payload:"connected"})}catch(m){let y=m instanceof Error?m.message:"Connection failed";n({type:"SET_ERROR",payload:m instanceof Error?m:new Error(y)}),n({type:"SET_STATUS",payload:"disconnected"})}},[c,u,d,i,S,f]),w=(0,O.useCallback)(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let m=await c.connectEmbedded();if(await u.save(m),d(m),await f(m),!await S(m))return;n({type:"SET_STATUS",payload:"connected"})}catch(m){let y=m instanceof Error?m.message:"Embedded wallet connection failed";n({type:"SET_ERROR",payload:m instanceof Error?m:new Error(y)}),n({type:"SET_STATUS",payload:"disconnected"})}},[c,u,d,S,f]),E=(0,O.useCallback)(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let m=await c.connectPasskeys();if(await u.save(m),d(m),await f(m),!await S(m))return;n({type:"SET_STATUS",payload:"connected"})}catch(m){let y=m instanceof Error?m.message:"Passkeys connection failed";n({type:"SET_ERROR",payload:m instanceof Error?m:new Error(y)}),n({type:"SET_STATUS",payload:"disconnected"})}},[c,u,d,S,f]),R=(0,O.useCallback)(async()=>{if(!s.session){n({type:"RESET"});return}try{await c.disconnect(s.session)}catch(m){Z.logger.error("react/provider","Disconnect error:",m)}try{let m=g.current;m&&await m.disconnect()}catch(m){Z.logger.warn("react/provider","SessionManager disconnect error:",m)}await u.clear(),n({type:"RESET"})},[c,s.session,u]),A=(0,O.useCallback)(async m=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let y=await(0,Ne.withTimeout)(c.connectInjected(m),i,"Injected wallet connect");await u.save(y),d(y);try{await f(y)}catch(k){Z.logger.warn("react/provider","SessionManager sync error:",k)}if(!await S(y))return;n({type:"SET_STATUS",payload:"connected"})}catch(y){let k=y instanceof Error?y.message:"Connection failed";n({type:"SET_ERROR",payload:y instanceof Error?y:new Error(k)}),n({type:"SET_STATUS",payload:"disconnected"})}},[c,u,d,i,S,f]),T=(0,O.useCallback)(async()=>c.startPairing(),[c]),v=(0,O.useCallback)(()=>{c.cancelPairing?.()},[c]),x=(0,O.useCallback)(async()=>{let m=await c.completePairing();return await u.save(m),d(m),await f(m),await S(m)&&n({type:"SET_STATUS",payload:"connected"}),m},[c,u,d,S,f]),b=(0,O.useCallback)(async m=>{let y=t.siwx;if(!y||y.required===!1)return!0;try{if(await y.hasValidSession?.())return!0}catch(k){Z.logger.warn("react/provider","siwx.hasValidSession failed",k)}return S(m)},[t.siwx,S]),I=(0,O.useCallback)(async()=>{let m=await u.load();if(!m){n({type:"SET_STATUS",payload:"disconnected"});return}n({type:"SET_STATUS",payload:"reconnecting"});try{let y=await(0,Ne.withRetry)(()=>c.reconnect(m),{maxRetries:C,baseDelay:1e3,label:"reconnect"});d(y);try{let k=g.current;k&&(p(),await k.restoreFromPersistence())}catch(k){Z.logger.warn("react/provider","SessionManager restore error:",k)}if(!await b(y))return;n({type:"SET_STATUS",payload:"connected"})}catch(y){Z.logger.error("react/provider","Reconnect error:",y),await u.clear(),n({type:"SET_STATUS",payload:"disconnected"}),n({type:"SET_SESSION",payload:null})}},[c,u,d,C,p,b]),W=(0,O.useCallback)(async m=>{o.current&&await o.current;let y=g.current;if(y?.getActiveBundle()){await y.switchChain(m),d(s.session);return}if(!s.session)throw new Error("No active session");try{s.session.walletType==="eip6963"||s.session.id?.startsWith("eip6963-")?await ht.eip6963Connector.switchChain(s.session,m):s.session.walletType==="embedded"&&c.embeddedConnector?await c.embeddedConnector.switchChain?.(s.session,m):s.session.walletType==="passkeys"&&c.passkeysConnector?await c.passkeysConnector.switchChain?.(s.session,m):s.session.walletType==="solana"&&c.solanaConnector?await c.solanaConnector.switchChain?.(s.session,m):await c.connector.switchChain(s.session,m),d(s.session)}catch(k){throw new Z.WalletError("chain_unsupported","Failed to switch chain",k)}},[c,s.session,d]);(0,O.useEffect)(()=>{r&&I()},[r,I]);let F=(0,O.useCallback)(()=>{n({type:"SET_ERROR",payload:null})},[]),q=(0,O.useMemo)(()=>({...s,connect:h,connectEmbedded:w,connectPasskeys:E,disconnect:R,reconnect:I,switchChain:W,startPairing:T,completePairing:x,cancelPairing:v,connectInjected:A,clearError:F,isConnected:s.status==="connected",chains:l,client:c,sessionManager:a}),[s,h,w,E,R,I,W,T,x,A,F,l,c,a]);return(0,Er.jsx)(Dt.Provider,{value:q,children:e})}function U(){let e=(0,O.useContext)(Dt);if(!e)throw new Error("useWeb3 must be used within a Web3ConnectProvider");return e}function H(){let{accounts:e,isConnected:t}=U(),r=(0,wr.useMemo)(()=>!t||e.length===0?null:e.map(n=>{let l=(0,yt.parseCaip10)(n);return l?{address:n,namespace:l.namespace,isEVM:l.namespace==="eip155"&&(0,yt.isEvmAddress)(l.address)}:{address:n,namespace:null,isEVM:(0,yt.isEvmAddress)(n)}}),[e,t]),s=r?.find(n=>n.isEVM)?.address??null;return{accounts:r,evmAccount:s,primaryAccount:e[0]??null,isConnected:t,count:e.length}}var Ye=require("@naculus/connect-appkit-core"),j=require("react");var Je=require("viem"),kr=require("@naculus/connect-core");function xr(e){let{evmAccount:t,isConnected:r}=H(),{chainId:s,chains:n}=U(),[l,i]=(0,j.useState)(null),[C,u]=(0,j.useState)(!1),[c,g]=(0,j.useState)(null),[o,a]=(0,j.useState)(null),p=e?.refreshInterval,f=(0,j.useRef)(null),d=(0,j.useMemo)(()=>(0,Ye.resolveChain)(n,s),[s,n]),S=d?(0,Ye.chainNumber)(d):null,h=(0,j.useMemo)(()=>d?(0,Ye.toViemChain)(d,S):null,[d,S]),w=(0,j.useMemo)(()=>d?.token??null,[d]),[E,R]=(0,j.useState)(null);(0,j.useEffect)(()=>{if(!h||!d?.rpcUrl){R(null);return}let x=(0,Je.createPublicClient)({transport:(0,Je.http)(d.rpcUrl),chain:h});return R(x),()=>{}},[d]);let A=(0,j.useCallback)(async()=>{if(!t||!E){i(null);return}u(!0),g(null);try{let b=t.includes(":")?t.split(":").pop():t,[I,W]=await Promise.all([E.getBalance({address:b}),s?(0,kr.getNativeTokenPriceUsd)(s,d?.rpcUrl).catch(()=>null):Promise.resolve(null)]);i(I.toString()),a(W)}catch(x){g(x instanceof Error?x:new Error("Failed to fetch balance")),i(null),a(null)}finally{u(!1)}},[t,E,s,d?.rpcUrl]);(0,j.useEffect)(()=>{r&&t&&A()},[r,t,A]),(0,j.useEffect)(()=>(p&&p>0&&r&&t&&(f.current=setInterval(A,p)),()=>{f.current&&(clearInterval(f.current),f.current=null)}),[p,r,t,A]);let T=(0,j.useMemo)(()=>{if(l===null)return null;try{return(0,Je.formatEther)(BigInt(l))}catch{return null}},[l]),v=(0,j.useMemo)(()=>{if(o===null||T===null)return null;let x=parseFloat(T);if(isNaN(x))return null;let b=x*o;return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(b)},[o,T]);return{balance:l,formatted:T,symbol:w,usdPrice:o,usdValue:v,isLoading:C,error:c,refetch:A,chain:d}}var Ze=require("@naculus/connect-appkit-core"),Ae=require("react");function N(e){return e??Ot()}function Mt(){let{client:e,session:t,chainId:r}=U(),[s,n]=(0,Ae.useState)(null),[l,i]=(0,Ae.useState)(!1),[C,u]=(0,Ae.useState)(null),c=(0,Ae.useRef)(0),g=(0,Ae.useCallback)(async()=>{let o=++c.current,a=N(e);if(!a?.getCapabilities||!t){n(null),i(!1),u(null);return}i(!0),u(null);try{let p=await a.getCapabilities(t);if(o!==c.current)return;n((0,Ze.normalizeCapabilities)(p))}catch(p){if(o!==c.current)return;n(null),u(p instanceof Error?p:new Error("Capability query failed"))}finally{o===c.current&&i(!1)}},[e,t]);return(0,Ae.useEffect)(()=>{g()},[g]),{capabilities:s,current:(0,Ze.selectChainCapabilities)(s,r),atomic:(0,Ze.atomicSupportFor)(s,r),isFetching:l,error:C,refetch:g}}var Lt=require("react"),et=require("@naculus/connect-appkit-core");function ie(){let{chainId:e,session:t,switchChain:r,chains:s}=U(),n=(0,Lt.useMemo)(()=>(0,et.resolveChain)(s,e),[s,e]),l=(0,Lt.useMemo)(()=>t?(0,et.describeChain)(s,e):null,[s,e,t]),i=(0,Lt.useMemo)(()=>(0,et.chainsForNamespace)(s,e),[s,e]);return{chainId:e,currentChain:n,chainInfo:l,availableChains:i,chains:i,isEvm:e?.startsWith("eip155:")??!1,switchChain:r}}var St=require("react");var vr=require("@naculus/connect-core");function Ar(){let{connect:e,status:t}=U(),[r,s]=(0,St.useState)(!1),[n,l]=(0,St.useState)(null);return{connect:(0,St.useCallback)(async()=>{s(!0),l(null);try{await e()}catch(C){let u=C instanceof Error?C.message:"Connection failed";l(C instanceof vr.WalletError?C:new Error(u))}finally{s(!1)}},[e]),isConnecting:r||t==="connecting",error:n}}var br=require("@naculus/connect-appkit-core"),_e=require("@naculus/connect-core"),te=require("react");var Ft=require("@naculus/connect-appkit-core"),Bt=require("react"),He=require("viem");function le(){let{evmAccount:e,isConnected:t}=H(),{currentChain:r,chains:s}=ie(),n=r?(0,Ft.chainNumber)(r):null,l=(0,Bt.useMemo)(()=>r?(0,Ft.toViemChain)(r,n):null,[r,n]),i=(0,Bt.useMemo)(()=>l?(0,He.createPublicClient)({transport:(0,He.http)(l.rpcUrls.default.http[0]),chain:l}):null,[r,l]),C=(0,Bt.useMemo)(()=>{if(!t||!e||!l)return null;let u=e.includes(":")?e.split(":").pop():e;return(0,He.createWalletClient)({transport:(0,He.http)(l.rpcUrls.default.http[0]),chain:l,account:u})},[t,e,r,l]);return{publicClient:i,walletClient:C,chains:s}}function Rr(e){let{evmAccount:t}=H(),{session:r,chainId:s,client:n}=U(),{publicClient:l}=le(),[i,C]=(0,te.useState)(null),[u,c]=(0,te.useState)(!1),[g,o]=(0,te.useState)(null),a=(0,te.useRef)(0),p=(0,te.useRef)(!1);(0,te.useEffect)(()=>()=>{a.current+=1},[]),(0,te.useEffect)(()=>{a.current+=1,C(null),c(!1),o(null)},[r,s,t]);let f=(0,te.useCallback)(async(w,E)=>{let R=x=>(o(x),null);if(p.current)return R(new Error("A delegation is already in progress"));let A=(0,br.bareEvmAddress)(t);if(!r||!A||!s)return R(new _e.WalletError("wallet_unavailable","No connected EVM account"));if(!l||l.chain?.id!==(0,_e.eip155Reference)(s))return R(new _e.WalletError("chain_mismatch",`No RPC client for ${s}; refusing to read the nonce elsewhere.`));let T=r.walletType==="embedded"?N(n)?.embeddedConnector??{}:{},v=++a.current;p.current=!0,c(!0),o(null),C(null);try{let x=await(0,_e.delegateAccount)({connector:T,session:r,account:A,chainId:s,delegate:w,allowlist:E,getTransactionCount:(b,I)=>l.getTransactionCount({address:b,blockTag:I})});return v!==a.current?null:(C(x),x)}catch(x){return v!==a.current?null:R(x instanceof Error?x:new Error("Failed to send delegation"))}finally{p.current=!1,v===a.current&&c(!1)}},[s,n,t,l,r]),d=(0,te.useCallback)(w=>f(w,e.allowlist),[f,e.allowlist]),S=(0,te.useCallback)(()=>f(_e.REVOKE_DELEGATE,[]),[f]),h=(0,te.useCallback)(()=>{a.current+=1,C(null),c(!1),o(null)},[]);return{delegate:d,revoke:S,result:i,isPending:u,error:g,reset:h}}var tt=require("@naculus/connect-core"),be=require("react");function nt(){let{publicClient:e}=le(),{evmAccount:t}=H(),[r,s]=(0,be.useState)(tt.UNKNOWN_DELEGATION),[n,l]=(0,be.useState)(!1),[i,C]=(0,be.useState)(null),u=(0,be.useRef)(0),c=t?.includes(":")?t.split(":").pop():t,g=(0,be.useCallback)(async()=>{let o=++u.current;if(!e||!c){s(tt.UNKNOWN_DELEGATION),l(!1),C(null);return}l(!0),C(null);try{let a=await e.getCode({address:c});if(o!==u.current)return;s((0,tt.readDelegation)(a??"0x"))}catch(a){if(o!==u.current)return;s(tt.UNKNOWN_DELEGATION),C(a instanceof Error?a:new Error("Code read failed"))}finally{o===u.current&&l(!1)}},[e,c]);return(0,be.useEffect)(()=>{g()},[g]),{...r,isFetching:n,error:i,refetch:g}}var ot=require("@naculus/connect-appkit-core"),ne=require("react"),Nr=require("viem");var qt=require("@naculus/connect-core");var Ke=require("react");var pe=require("@naculus/connect-core"),we=require("react");var Tr=require("@naculus/connect-core");function Ht(e){let t=typeof e=="string"?e:e&&typeof e=="object"&&"hash"in e?e.hash:void 0;if(typeof t=="string"&&/^0x[0-9a-fA-F]{64}$/.test(t))return t;throw new Tr.WalletError("tx_failed","Wallet did not return a valid 32-byte transaction hash")}function Kt(){let{session:e,chainId:t,client:r}=U(),[s,n]=(0,we.useState)("idle"),[l,i]=(0,we.useState)(null),[C,u]=(0,we.useState)(null),[c,g]=(0,we.useState)(null),[o,a]=(0,we.useState)(null),p=(0,we.useCallback)(async(h,w)=>{if(!e){n("failed");let E=new pe.WalletError("wallet_unavailable","No active session");throw i(E),E}if(h.length===0){n("failed");let E=new pe.WalletError("invalid_input","At least one call is required");throw i(E),E}n("awaiting_approval"),i(null),u(null);try{let E=N(r);if(!E)throw new pe.WalletError("wallet_unavailable","Client not initialized");let R=w?.chainId??t??void 0,A=w?.strategy??(0,pe.chooseExecutionStrategy)(await(0,pe.getAccountCapabilities)(E,e,R),h.length);if(a(A),A==="atomic-batch"){let v=await E.sendCalls(e,h,R,{atomicRequired:!0,...w?.paymasterService?{paymasterService:w.paymasterService}:{}});return n("submitted"),u(v),v}let T="";for(let v=0;v<h.length;v++){let x=h[v];try{T=Ht(await E.sendTransaction(e,{transaction:{to:x.to,data:x.data,value:x.value},chainId:R}))}catch(b){throw new pe.WalletError("tx_failed",`Call ${v+1} of ${h.length} failed after ${v} already landed (sent sequentially \u2014 this wallet cannot batch atomically): ${b instanceof Error?b.message:String(b)}`)}}return n("submitted"),u(T),T}catch(E){n("failed");let R=E instanceof Error?E.message:"sendCalls failed";throw i(E instanceof Error?E:new Error(R)),E}},[e,t,r]),f=(0,we.useCallback)(async h=>{if(!e)throw new pe.WalletError("wallet_unavailable","No active session");let w=h??C;if(!w)throw new pe.WalletError("invalid_input","No bundle hash available");if(!h&&o==="sequential")throw new pe.WalletError("invalid_input","Calls were sent sequentially, so there is no bundle to query. Track the returned transaction hash instead.");let E=N(r);if(!E)throw new pe.WalletError("wallet_unavailable","Client not initialized");let R=await E.getCallsStatus(e,w);return g(R),R},[e,C,r,o]),d=(0,we.useCallback)(async h=>{if(!e)return!1;let w=h??C;if(!w||!h&&o==="sequential")return!1;let E=N(r);if(!E?.showCallsStatus)return!1;try{return await E.showCallsStatus(e,w),!0}catch{return!1}},[e,C,r,o]),S=(0,we.useCallback)(()=>{n("idle"),i(null),u(null),g(null),a(null)},[]);return{sendCalls:p,getCallsStatus:f,showCallsStatus:d,status:s,error:l,batchHash:C,callsStatus:c,execution:o,reset:S,isSending:s==="awaiting_approval"}}function Vt(e={}){let{current:t,atomic:r}=Mt(),{delegated:s,delegate:n}=nt(),{sendCalls:l}=Kt(),[i,C]=(0,Ke.useState)(!1),[u,c]=(0,Ke.useState)(null),[g,o]=(0,Ke.useState)(null),a=e.atomicity??"preferred",p=e.sponsorship??"any",f=e.paymasterService,d=e.userOperation,S=e.userOperationSponsored??!1,h=!!(t?.raw?.paymasterService?.supported&&f),w=(0,Ke.useCallback)((R,A=a)=>{let T=(0,qt.planExecution)({atomicBatch:r==="supported",discovered:r!=="unknown",sponsoredTransactions:!1,...t?.maxBatchSize===void 0?{}:{maxBatchSize:t.maxBatchSize}},R,{atomicity:A,sponsorship:p}),v=p==="required"&&!S;if(T.strategy==="atomic-batch"&&!v)return{...T,reason:T.reason+(h?" A paymaster service will be requested, but the wallet's final fee payer must be checked after execution.":""),route:"wallet-batch"};let x=s&&r!=="supported"?` This account does delegate to ${n} under EIP-7702, so it is capable of batching even though the wallet has not offered to.`:"",b=A!=="any"&&!T.atomic||p==="required";return d&&b&&!v?{strategy:"atomic-batch",atomic:!0,sponsored:S,reason:p==="required"&&!T.sponsored?"The wallet batch is not configured for sponsored gas, so the calls are executed through the configured sponsored UserOperation route.":"This wallet cannot batch, so the calls are executed as a single UserOperation through the smart account, which lands as one transaction.",route:"user-operation"}:v?{strategy:"refuse",atomic:T.atomic,sponsored:!1,reason:"Sponsored gas was required, but there is no executable sponsored route: no paymaster is configured for a wallet batch, and capability advertising alone cannot pay for a sequential transaction.",route:null}:T.strategy==="refuse"?{...T,reason:T.reason+x,route:null}:{...T,reason:T.reason+x,route:"sequential"}},[r,t,f,h,d,S,a,p,s,n]),E=(0,Ke.useCallback)(async(R,A=a)=>{C(!0),c(null);try{let T=w(R.length,A);if(T.route===null)throw new qt.WalletError("method_not_allowed",T.reason);return o(T.route),T.route==="user-operation"?await d(R):await l(R,{strategy:T.route==="wallet-batch"?"atomic-batch":"sequential",...T.route==="wallet-batch"&&h?{paymasterService:f}:{}})}catch(T){let v=T instanceof Error?T:new Error("Execution failed");throw c(v),v}finally{C(!1)}},[w,l,d,a,f,h]);return{preview:w,execute:E,isExecuting:i,error:u,lastRoute:g,reset:()=>{c(null),o(null)}}}var $t=require("@naculus/connect-appkit-core"),Ir=require("@naculus/connect-core"),K=require("react");function rt(e){return(0,$t.getSharedSessionKeyManager)(e)}function Gt(e){let{session:t}=U(),[r,s]=(0,K.useState)([]),[n,l]=(0,K.useState)(!1),[i,C]=(0,K.useState)(null),u=(0,K.useRef)(!0),c=(0,K.useCallback)(()=>C(null),[]),g=rt(e),o=g.isStorageAvailable(),a=(0,K.useCallback)(async()=>{if(!t){s([]);return}l(!0),C(null);try{let f=await g.listSessions();u.current&&s(f)}catch(f){u.current&&C(f instanceof Error?f:new Error("Failed to load session keys"))}finally{u.current&&l(!1)}},[t,g]);(0,K.useEffect)(()=>(u.current=!0,a(),()=>{u.current=!1}),[a]);let p=r.filter(f=>f.status==="active");return{sessions:r,activeSessions:p,loading:n,error:i,refresh:a,clearError:c,storageAvailable:o}}function Ur(e){let{session:t}=U(),[r,s]=(0,K.useState)(null),[n,l]=(0,K.useState)(!1),[i,C]=(0,K.useState)(null),u=(0,K.useCallback)(()=>C(null),[]),c=rt(e);return{createSessionKey:(0,K.useCallback)(async(o,a)=>{if(!t)throw new Ir.WalletError("wallet_unavailable","No active wallet session");l(!0),C(null);try{let p=a??void 0,f=await c.createSessionKey(o,p);return s(f),f}catch(p){let f=p instanceof Error?p:new Error("Failed to create session key");throw C(f),f}finally{l(!1)}},[t,c]),lastCreated:r,isCreating:n,error:i,clearError:u}}function Pr(e){let[t,r]=(0,K.useState)(!1),[s,n]=(0,K.useState)(null),l=(0,K.useCallback)(()=>n(null),[]),i=rt(e);return{revokeSession:(0,K.useCallback)(async u=>{r(!0),n(null);try{await i.revokeSession(u)}catch(c){let g=c instanceof Error?c:new Error("Failed to revoke session key");throw n(g),g}finally{r(!1)}},[i]),isRevoking:t,error:s,clearError:l}}function Wr(e){let[t,r]=(0,K.useState)(!1),[s,n]=(0,K.useState)(null),l=(0,K.useCallback)(()=>n(null),[]),i=rt(e),C=(0,K.useCallback)(async(c,g,o)=>{r(!0),n(null);try{return await i.signWithSessionKey(c,g,o)}catch(a){let p=a instanceof Error?a:new Error("Failed to sign with session key");throw n(p),p}finally{r(!1)}},[i]),u=(0,K.useCallback)(async(c,g)=>{r(!0),n(null);try{return await i.checkSessionScope(c,g)}catch(o){let a=o instanceof Error?o:new Error("Failed to check session scope");throw n(a),a}finally{r(!1)}},[i]);return{signWithSession:C,checkScope:u,isBusy:t,error:s,clearError:l}}function Or(){(0,$t.resetSharedSessionKeyManager)()}var Et=require("react");var jt=require("@naculus/connect-core");function zt(){let{session:e,chainId:t,client:r}=U(),[s,n]=(0,Et.useState)(!1),[l,i]=(0,Et.useState)(null);return{signMessage:(0,Et.useCallback)(async u=>{if(!e){let g=new jt.WalletError("wallet_unavailable","No active session");throw i(g),g}let c=e.namespaces.eip155?.accounts[0]??Object.values(e.namespaces)[0]?.accounts[0];if(!c){let g=new jt.WalletError("wallet_unavailable","No account found");throw i(g),g}n(!0),i(null);try{let g=N(r);if(!g)throw new jt.WalletError("wallet_unavailable","Client not initialized");return await g.signMessage(e,{message:u,address:c,chainId:t??void 0})}catch(g){let o=g instanceof Error?g.message:"Signing failed",a=g instanceof Error?g:new Error(o);throw i(a),a}finally{n(!1)}},[e,t,r]),isSigning:s,error:l}}var zn=require("@naculus/connect-appkit-core");function _r(e={}){let{evmAccount:t}=H(),r=(0,ot.bareEvmAddress)(t),s=nt(),n=Vt(e.execution),{signMessage:l}=zt(),i=Gt(e.managerConfig),C=rt(e.managerConfig),[u,c]=(0,ne.useState)(!1),[g,o]=(0,ne.useState)(null),[a,p]=(0,ne.useState)(()=>new Set),[f,d]=(0,ne.useState)(!1),S=e.origin??(typeof window<"u"?window.location.origin:"unknown"),h=!!e.managerConfig?.encryptionKey,w=e.execution?.sponsorship,{refresh:E,storageAvailable:R}=i,{preview:A}=n,{delegated:T,delegate:v}=s,x=(0,ne.useMemo)(()=>(0,ot.createDelegationPolicyFlow)({manager:C,origin:S,signer:()=>r,signMessage:l,verifySignature:async({message:y,signature:k,signerAddress:P})=>(await(0,Nr.recoverMessageAddress)({message:y,signature:k})).toLowerCase()===P.toLowerCase(),previewExecution:A,sponsorship:w,adapter:e.adapter,delegation:()=>({delegated:T,delegate:v}),encryptionKeyConfigured:h,storageAvailable:()=>R,refresh:E}),[C,S,r,l,A,w,e.adapter,T,v,h,R,E]);(0,ne.useEffect)(()=>{let y=!1,k=i.sessions.filter(ot.isVerifiablePolicy);return k.length===0?(p(new Set),d(!1),()=>{y=!0}):(d(!0),Promise.all(k.map(async P=>[P.id,await x.verifyStoredPolicy(P)])).then(P=>{y||p(new Set(P.filter(([,_])=>_).map(([_])=>_)))}).catch(P=>{y||(p(new Set),o(P instanceof Error?P:new Error("Policy verification failed")))}).finally(()=>{y||d(!1)}),()=>{y=!0})},[i.sessions,x]);let b=(0,ne.useCallback)(()=>{o(null),i.clearError()},[i]),I=(0,ne.useCallback)(async(y,k)=>{c(!0),o(null);try{return await y()}catch(P){let _=P instanceof Error?P:new Error(k);throw o(_),_}finally{c(!1)}},[]),W=(0,ne.useCallback)(y=>I(()=>x.createPolicy(y),"Policy creation failed"),[x,I]),F=(0,ne.useCallback)(y=>I(()=>x.revokePolicy(y),"Policy revocation failed"),[x,I]),q=(0,ne.useCallback)((y,k)=>I(()=>x.executePolicy(y,k),"Policy execution failed"),[x,I]),m=i.activeSessions.filter(y=>a.has(y.id));return{policies:i.sessions,activePolicies:m,storageAvailable:i.storageAvailable,loading:i.loading||f,isBusy:u,error:g??i.error,delegation:s,createPolicy:W,revokePolicy:F,previewPolicyExecution:x.previewPolicyExecution,signPolicyDigest:x.signPolicyDigest,executePolicy:q,refresh:i.refresh,clearError:b}}var qe=require("react");function Dr(){let{disconnect:e,status:t}=U(),[r,s]=(0,qe.useState)(!1),[n,l]=(0,qe.useState)(null),i=(0,qe.useRef)(!0);return{disconnect:(0,qe.useCallback)(async()=>{if(t!=="disconnected"){s(!0),l(null);try{await e()}catch(u){if(!i.current)return;l(u instanceof Error?u:new Error("Disconnect failed"))}finally{i.current&&s(!1)}}},[e,t]),isDisconnecting:r,error:n,cleanup:()=>{i.current=!1}}}var Qt=require("@naculus/connect-core"),$=require("react");function Le(e){let t=e.activeNamespace??"eip155",r=Array.isArray(e.accounts)?e.accounts.map(({namespace:s,address:n,derivationPath:l})=>({namespace:s,address:n,...l?{derivationPath:l}:{}})):e.address?[{namespace:t,address:e.address}]:[];return{accounts:r,activeNamespace:t,createdAt:e.createdAt??0,...e.chainId?{chainId:e.chainId}:{},...e.version?{version:e.version}:{},recoveryAvailable:!!e.mnemonic,address:r.find(s=>s.namespace===t)?.address??e.address}}function Mr(){let{connectEmbedded:e,client:t}=U(),[r,s]=(0,$.useState)(null),n=(0,$.useRef)(null),l=(0,$.useRef)(4),i=(0,$.useRef)(!1),C=(0,$.useRef)(null),[u,c]=(0,$.useState)(!1),[g,o]=(0,$.useState)(!1),[a,p]=(0,$.useState)(null),f=()=>p(null),d=(0,$.useCallback)(()=>{let m=n.current;return n.current=null,m},[]),S=(0,$.useCallback)(()=>{let m=N(t);if(!m?.embeddedConnector)throw new Qt.WalletError("wallet_unavailable","Embedded wallet not enabled.");return m.embeddedConnector},[t]),h=(0,$.useCallback)(()=>{try{return S().getWallet()?.privateKey??null}catch{return null}},[S]),w=(0,$.useCallback)(async()=>{let m=N(t);if(!m)throw new Qt.WalletError("wallet_unavailable","Embedded wallet not enabled.");let y=m.getEmbeddedConnector?await m.getEmbeddedConnector():m.embeddedConnector;if(!y)throw new Qt.WalletError("wallet_unavailable","Embedded wallet not enabled.");return y},[t]),E=(0,$.useCallback)(()=>{try{return N(t)?.passphraseGate??null}catch{return null}},[t]),R=(0,$.useCallback)(m=>{m?.code==="decryption_failed"&&E()?.forget("That passphrase did not open the wallet.")},[E]),A=(0,$.useCallback)(async()=>{i.current=!1,p(null);try{let m=await w();if(!await m.load())return!1;let k=m.getWallet();return k?(n.current=null,c(!1),s(Le(k)),!0):!1}catch(m){return i.current=!0,R(m),p(m instanceof Error?m:new Error("Failed to restore embedded wallet")),!1}},[R,w]);(0,$.useEffect)(()=>{let m=!1,y=null;return A().then(k=>{m||k||i.current||(y=setTimeout(()=>{m||A()},100))}),()=>{m=!0,y&&clearTimeout(y)}},[A]);let T=async()=>{o(!0),p(null);try{let m=await w(),y=await m.load(),k=m.getWallet();y&&k&&(s(Le(k)),n.current=k.mnemonic||null,c(!k.mnemonic)),await e();let P=m.getWallet();P&&(s(Le(P)),P.mnemonic&&!y&&(n.current=P.mnemonic,c(!0)))}catch(m){R(m),p(m instanceof Error?m:new Error("Embedded wallet connection failed"))}finally{o(!1)}},v=async()=>{o(!0),p(null);try{let m=await w();E()?.expect("create");let y=await m.generateWallet();return s(Le(y)),n.current=y.mnemonic,c(!0),y}catch(m){return p(m instanceof Error?m:new Error("Failed to generate wallet")),null}finally{o(!1)}},x=async m=>{o(!0),p(null);try{let y=await w();E()?.expect("create");let k=await y.importFromMnemonic(m);return s(Le(k)),n.current=null,c(!1),k}catch(y){return p(y instanceof Error?y:new Error("Failed to import wallet")),null}finally{o(!1)}},b=async m=>{o(!0),p(null);try{let y=await w();E()?.expect("create");let k=await y.importFromPrivateKey(m);return s(Le(k)),n.current=null,c(!1),k}catch(y){return p(y instanceof Error?y:new Error("Failed to import wallet")),null}finally{o(!1)}},I=async()=>{o(!0),p(null);try{await(await w()).wipe(),s(null),n.current=null,c(!1)}catch(m){p(m instanceof Error?m:new Error("Failed to wipe wallet"))}finally{o(!1)}},W=(0,$.useCallback)(m=>{let y=S();y.setActiveNamespace(m);let k=y.getWallet();s(k?Le(k):null)},[S]),F=(0,$.useCallback)(async()=>{let m=await w(),y=await m.backfillAccounts();if(y.length>0){let k=m.getWallet();s(k?Le(k):null)}return y.map(({namespace:k,address:P,derivationPath:_})=>({namespace:k,address:P,..._?{derivationPath:_}:{}}))},[w]),q=()=>{n.current=null,c(!1)};return{connectEmbedded:T,restoreWallet:A,generateWallet:v,importFromMnemonic:x,importFromPrivateKey:b,wipe:I,wallet:r,hasWallet:r!==null,address:r?.address??null,accounts:r?.accounts??[],activeNamespace:r?.activeNamespace??null,setActiveNamespace:W,backfillAccounts:F,seedPhrase:n.current,getSeedPhrase:d,getPrivateKey:h,backupPending:u,confirmBackup:q,isBusy:g,error:a,clearError:f,storageSecurityLevel:(()=>{try{let m=S(),y=m.getStorageSecurityLevel?.()??4;return m.getWallet()?(l.current=y,y):r?l.current:y}catch{return r?l.current:4}})(),securityReport:(()=>{let m=null;try{m=S().getStorageSecurityReport?.()??null}catch{m=null}if(!m)return C.current=null,null;let y=JSON.stringify(m);return C.current?.json===y?C.current.value:(C.current={json:y,value:m},m)})()}}var Fr=require("@naculus/connect-appkit-core"),Ce=require("react");var Lr=require("@naculus/connect-core"),ge=require("react"),Br=require("@naculus/connect-appkit-core");function Rs(e){return[e.token.address.toLowerCase(),e.token.chainId??"",e.token.decimals??"",e.chainId??"",e.owner??"",e.spender??"",e.connected?"1":"0",e.publicClient?"1":"0",e.walletClient?"1":"0",e.session?.id??""].join("|")}function st(e){let{token:t,chainId:r}=e,s=t.address.toLowerCase(),n=Rs(e),l=(0,ge.useMemo)(()=>({key:n}),[n]),i=(0,ge.useRef)(n),C=(0,ge.useRef)(!0);(0,ge.useLayoutEffect)(()=>{i.current=n},[n]),(0,ge.useEffect)(()=>(C.current=!0,()=>{C.current=!1}),[]);let u=(0,ge.useCallback)(()=>C.current&&i.current===n,[n]),c=(0,ge.useCallback)(()=>{if(!u())throw new Lr.WalletError("session_inactive","Wallet or token context changed. Retry the operation with the current account and chain.");let g=(0,Br.tokenChainMismatch)({address:s,chainId:t.chainId},r);if(g)throw g},[u,s,t.chainId,r]);return{identity:l,isCurrent:u,assertCurrent:c}}var Xt=require("@naculus/connect-core");function Hr(e){let{publicClient:t}=le(),{currentChain:r}=ie(),{identity:s,isCurrent:n,assertCurrent:l}=st({token:e.token,chainId:r?(0,Fr.chainNumber)(r)??void 0:void 0,owner:e.owner,spender:e.spender,publicClient:t}),[i,C]=(0,Ce.useState)(null),u=i?.identity===s?i.raw:null,c=i?.identity===s&&i.fetching,g=i?.identity===s?i.error:null,o=(0,Ce.useRef)(null),a=(0,Ce.useRef)(0),p=(0,Ce.useCallback)(async()=>{if(!n())return;let d=++a.current,S=()=>n()&&d===a.current;if(C({identity:s,raw:null,fetching:!!t,error:null}),!!t)try{l();let h=await t.readContract({address:e.token.address,abi:Xt.ERC20_MIN_ABI,functionName:"allowance",args:[e.owner,e.spender]});if(!S())return;C({identity:s,raw:h,fetching:!1,error:null})}catch(h){if(!S())return;C({identity:s,raw:null,fetching:!1,error:h instanceof Error?h:new Error("Failed to fetch allowance")})}},[t,e.token.address,e.token.chainId,e.owner,e.spender,s,n,l]);return(0,Ce.useEffect)(()=>{p().catch(d=>console.warn("useERC20Allowance: initial fetch failed:",d))},[p]),(0,Ce.useEffect)(()=>(e.refreshInterval&&e.refreshInterval>0&&(o.current=setInterval(p,e.refreshInterval)),()=>{o.current&&(clearInterval(o.current),o.current=null)}),[e.refreshInterval,p]),{allowance:(0,Ce.useMemo)(()=>{if(u===null)return null;let d=e.token.decimals;return d===void 0?null:(0,Xt.formatUnits)(u,d)},[u,e.token.decimals]),allowanceRaw:u,isFetching:c,error:g,refetch:p}}var de=require("@naculus/connect-appkit-core"),re=require("@naculus/connect-core"),he=require("react");var Yt=require("@naculus/connect-core"),at=require("react");function it(){let{session:e,chainId:t,client:r}=U(),[s,n]=(0,at.useState)("idle"),[l,i]=(0,at.useState)(null),C=(0,at.useCallback)(async c=>{if(!e){n("failed");let o=new Yt.WalletError("wallet_unavailable","No active session");throw i(o),o}let g=e.namespaces.eip155?.accounts.find(o=>/^eip155:\d+:0x[0-9a-fA-F]{40}$/.test(o)||/^0x[0-9a-fA-F]{40}$/.test(o));if(!g){n("failed");let o=new Yt.WalletError("wallet_unavailable","No EVM account found");throw i(o),o}n("awaiting_approval"),i(null);try{let o={...c,from:c.from??g.split(":").pop()},a=N(r);if(!a)throw new Yt.WalletError("wallet_unavailable","Client not initialized");let p=await a.sendTransaction(e,{transaction:o,chainId:t??void 0}),f=Ht(p);return n("submitted"),f}catch(o){n("failed");let a=o instanceof Error?o.message:"Transaction failed";throw i(o instanceof Error?o:new Error(a)),o}},[e,t,r]),u=(0,at.useCallback)(()=>{n("idle"),i(null)},[]);return{sendTransaction:C,status:s,error:l,reset:u,isSending:s==="awaiting_approval"}}function Ts(e){return e.includes(":")?e.split(":").pop():e}var Is=2n**256n-1n;function Kr(e){let{publicClient:t,walletClient:r}=le(),{evmAccount:s,isConnected:n}=H(),{currentChain:l}=ie(),{session:i,client:C}=U(),{sendTransaction:u,isSending:c,error:g,reset:o}=it(),[a,p]=(0,he.useState)(null),{identity:f,isCurrent:d,assertCurrent:S}=st({token:e.token,chainId:l?(0,de.chainNumber)(l)??void 0:void 0,owner:s,spender:e.spender,connected:n,publicClient:t,walletClient:r,session:i,client:C}),[h,w]=(0,he.useState)(null),E=h?.identity===f?h.raw:null,R=h?.identity===f&&h.fetching,A=(0,he.useRef)((0,de.createDecimalsCache)(e.token,e.token.decimals)),T=(0,he.useRef)(0),v=a??g,x=s?Ts(s):null,b=(0,he.useCallback)(async()=>{if(!d())return null;let y=++T.current,k=()=>d()&&y===T.current;if(w({identity:f,raw:null,fetching:!!t&&!!x&&n}),p(null),!t||!x||!n)return null;try{S();let P=await t.readContract({address:e.token.address,abi:re.ERC20_MIN_ABI,functionName:"allowance",args:[x,e.spender]});return k()?(w({identity:f,raw:P,fetching:!1}),P):null}catch(P){return k()&&(w({identity:f,raw:null,fetching:!1}),p(P instanceof Error?P:new Error("Failed to fetch allowance"))),null}},[t,x,e.token.address,e.token.chainId,e.spender,f,d,S,n]),I=(()=>{if(E===null)return null;let y=(0,de.readDecimals)(A.current,e.token,e.token.decimals);return y===void 0?null:(0,re.formatUnits)(E,y)})(),W=(0,he.useCallback)(async y=>{if(p(null),o(),!n||!s){let k=new re.WalletError("wallet_unavailable","No connected account");throw p(k),k}if(!t){let k=new re.WalletError("wallet_unavailable","No public client");throw p(k),k}try{S();let k=(0,de.encodeErc20Approve)(e.spender,y),P=N(C);if(i&&P){let D=await u({to:e.token.address,data:k,value:"0"});return b(),D}if(r){let{request:D}=await t.simulateContract({address:e.token.address,abi:re.ERC20_MIN_ABI,functionName:"approve",args:[e.spender,y],account:x});S();let De=await r.writeContract(D);return b(),De}let _=await u({to:e.token.address,data:k,value:"0"});return b(),_}catch(k){let P=k instanceof Error?k:new Error("Approve failed");throw d()&&p(P),P}},[e,t,r,s,n,i,C,x,u,o,b,S,d]),F=(0,he.useCallback)(async y=>{try{if(S(),!t)throw new re.WalletError("wallet_unavailable","No public client");let k=(0,de.readDecimals)(A.current,e.token,e.token.decimals);k===void 0&&(k=await t.readContract({address:e.token.address,abi:re.ERC20_MIN_ABI,functionName:"decimals"}),S(),(0,de.writeDecimals)(A.current,e.token,k));let P=(0,re.parseUnits)(y,k);return await W(P)}catch(k){throw d()&&p(k instanceof Error?k:new Error("Approve failed")),k}},[e.token,t,W,S,d]),q=(0,he.useCallback)(async()=>W(Is),[W]),m=(0,he.useCallback)(async y=>{if(!d()||!n||!x||!t)return!1;try{S()}catch(D){return p(D instanceof Error?D:new Error("Cannot check allowance")),!1}let k=E??await b();if(k===null)return!1;let P=(0,de.readDecimals)(A.current,e.token,e.token.decimals);if(P===void 0){if(!t)throw new re.WalletError("wallet_unavailable","Cannot check allowance: no public client to read token decimals.");if(P=await t.readContract({address:e.token.address,abi:re.ERC20_MIN_ABI,functionName:"decimals"}),!d())return!1;(0,de.writeDecimals)(A.current,e.token,P)}let _=(0,re.parseUnits)(y,P);return d()&&k>=_},[E,b,e.token.address,e.token.chainId,e.token.decimals,t,d,S,n,x]);return{approve:F,approveMax:q,allowance:I,allowanceRaw:E,hasAllowance:m,isApproving:c,isFetchingAllowance:R,error:v,refetchAllowance:b}}var Re=require("@naculus/connect-appkit-core"),Be=require("@naculus/connect-core"),lt=require("react");function Us(e){return e.includes(":")?e.split(":").pop():e}function qr(e){let{publicClient:t,walletClient:r}=le(),{evmAccount:s,isConnected:n}=H(),{currentChain:l}=ie(),{session:i,client:C}=U(),{sendTransaction:u,isSending:c,error:g,reset:o}=it(),[a,p]=(0,lt.useState)(null),{isCurrent:f,assertCurrent:d}=st({token:e.token,chainId:l?(0,Re.chainNumber)(l)??void 0:void 0,owner:s,connected:n,publicClient:t,walletClient:r,session:i,client:C}),S=(0,lt.useRef)((0,Re.createDecimalsCache)(e.token,e.token.decimals)),h=a??g;return{sendTransfer:(0,lt.useCallback)(async(E,R)=>{if(p(null),o(),!n||!s){let A=new Be.WalletError("wallet_unavailable","No connected account");throw p(A),A}if(!t){let A=new Be.WalletError("wallet_unavailable","No public client available");throw p(A),A}try{d();let A=Us(s),T=(0,Re.readDecimals)(S.current,e.token,e.token.decimals);T===void 0&&(T=await t.readContract({address:e.token.address,abi:Be.ERC20_MIN_ABI,functionName:"decimals"}),d(),(0,Re.writeDecimals)(S.current,e.token,T));let v=(0,Be.parseUnits)(R,T),x=(0,Re.encodeErc20Transfer)(E,v),b=N(C);if(i&&b)return await u({to:e.token.address,data:x,value:"0"});if(r){let{request:W}=await t.simulateContract({address:e.token.address,abi:Be.ERC20_MIN_ABI,functionName:"transfer",args:[E,v],account:A});return d(),await r.writeContract(W)}return await u({to:e.token.address,data:x,value:"0"})}catch(A){let T=A instanceof Error?A:new Error("Transfer failed");throw f()&&p(T),T}},[e.token,t,r,s,n,i,C,u,o,d,f]),isSending:c,error:h}}var Zt=require("@naculus/connect-appkit-core"),$r=require("@naculus/connect-core"),Gr=require("react");var Vr=require("@naculus/connect-appkit-core"),ke=require("react");function Jt(e,t){U();let{evmAccount:r}=H(),{currentChain:s}=ie(),{publicClient:n}=le(),[l,i]=(0,ke.useState)(void 0),[C,u]=(0,ke.useState)(!1),[c,g]=(0,ke.useState)(null),o=(0,ke.useRef)(void 0),a=(0,ke.useCallback)(async()=>{e&&(u(!0),g(null));try{let f=await(0,Vr.simulateTransactionPreview)(e,{chainId:t,currentChain:s,publicClient:n,evmAccount:r});return i(f),f}catch(f){let d=f instanceof Error?f:new Error("Simulation failed");throw g(d),d}finally{e&&u(!1)}},[e,t,s,n,r]);(0,ke.useEffect)(()=>{if(e)return o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{a().catch(()=>{})},300),()=>{o.current&&clearTimeout(o.current)}},[e,a]);let p=(0,ke.useCallback)(()=>{i(void 0),g(null),u(!1)},[]);return{result:l,isSimulating:C,error:c,simulate:a,reset:p}}function jr(e){let{evmAccount:t,isConnected:r}=H(),{currentChain:s}=ie(),n=e.token.chainId??(s?(0,Zt.chainNumber)(s)??void 0:void 0),l=(0,Gr.useMemo)(()=>{if(!(!r||!t))try{let C=e.token.decimals;if(C===void 0)return;let u=(0,$r.parseUnits)(e.amount,C),c=(0,Zt.encodeErc20Transfer)(e.to,u);return{to:e.token.address,data:c,value:"0"}}catch{return}},[e.token.address,e.token.decimals,e.to,e.amount,t,r]),i=Jt(l,n);return{result:l?i.result:void 0,isSimulating:!!l&&i.isSimulating,error:l?i.error:null,reSimulate:i.simulate,reset:i.reset}}var Te=require("react");var ye=require("react"),en=require("react"),Qn=(0,en.createContext)(null);function wt(){return(0,en.useContext)(Qn)}function zr(e,t,r){let s=wt(),n=r??s,[l,i]=(0,ye.useState)(null),[C,u]=(0,ye.useState)(!1),[c,g]=(0,ye.useState)(!1),[o,a]=(0,ye.useState)(null),p=(0,ye.useRef)(void 0),f=(0,ye.useCallback)(async()=>{if(!(!n||!e)){u(!0),a(null);try{await n.refreshTx(e,t);let h=n.getTxStatus(e,t);h&&i(h)}catch(h){a(h instanceof Error?h:new Error(String(h)))}finally{u(!1)}}},[n,e,t]),d=(0,ye.useCallback)(()=>{!n||!e||(n.stopWatching(e,t),g(!1))},[n,e,t]);(0,ye.useEffect)(()=>{if(!n||!e||!t){i(null),g(!1);return}p.current&&p.current!==e&&n.stopWatching(p.current),p.current=e;let h=!1;g(!0),u(!0),a(null);let w=n.getTxStatus(e,t);w&&(i(w),u(!1)),n.watchTx(e,t,{}).then(R=>{h||(i(R),u(!1))}).catch(R=>{h||(a(R instanceof Error?R:new Error(String(R))),u(!1))});let E=R=>{h||i({...R})};return n.on("statusChange",E),()=>{h=!0,g(!1),n.off("statusChange",E)}},[n,e,t]);let S=l?.status??"idle";return{entry:l,status:S,isLoading:C,isWatching:c,error:o,refresh:f,stopWatching:d}}function Qr(e){let t=wt(),r=e??t,[s,n]=(0,Te.useState)(null),[l,i]=(0,Te.useState)(null),[C,u]=(0,Te.useState)(null),c=(0,Te.useRef)(null),g=(0,Te.useRef)(null),o=(0,Te.useRef)(null);r&&(g.current||(g.current=p=>{i(p),(!c.current||p.createdAt>=c.current.createdAt)&&(n(p),c.current=p)},r.on("confirmed",g.current)),o.current||(o.current=p=>{u(p),(!c.current||p.createdAt>=c.current.createdAt)&&(n(p),c.current=p)},r.on("failed",o.current)));let a=(0,Te.useCallback)(()=>{n(null),i(null),u(null),c.current=null},[]);return{lastTx:s,lastConfirmedTx:l,lastFailedTx:C,clear:a}}var Yr=require("react");var ce=require("react"),Xr=require("@naculus/connect-appkit-core");function tn({input:e,skip:t=!1,resolverConfig:r,scope:s,query:n}){let[l,i]=(0,ce.useState)(null),[C,u]=(0,ce.useState)(!1),[c,g]=(0,ce.useState)(null),o=(0,ce.useRef)(0),a=(0,ce.useRef)(!0);(0,ce.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let p=(0,ce.useMemo)(()=>(0,Xr.getResolver)(r),[r]),f=(0,ce.useCallback)(()=>{let d=e.trim();if(!d||t){o.current+=1,i(null),u(!1),g(null);return}let S=++o.current;u(!0),g(null),n(p,d,s).then(h=>{!a.current||S!==o.current||(i(h),u(!1))}).catch(h=>{!a.current||S!==o.current||(g(h instanceof Error?h:new Error(String(h))),i(null),u(!1))})},[e,t,s,p,n]);return(0,ce.useEffect)(()=>{f()},[f]),{data:l,isLoading:C,error:c,refetch:f}}function Jr(e,t){let r=(0,Yr.useCallback)((s,n,l)=>s.lookupAddress(n,l),[]);return tn({input:e,skip:t?.skip,resolverConfig:t?.resolverConfig,scope:t?.chainId,query:r})}var z=require("react"),Q=require("@naculus/connect-appkit-core"),Zr=require("@naculus/connect-core");function eo(e){let t=(0,z.useRef)(null);t.current||(t.current=e?.channel??new Zr.InAppChannel);let r=t.current,[s,n]=(0,z.useState)(()=>r.getHistory()),[l,i]=(0,z.useState)(()=>Q.DEFAULT_NOTIFICATION_SETTINGS);(0,z.useEffect)(()=>{let h=e?.storage??(0,Q.createNotificationSettingsStorage)();(0,Q.loadNotificationSettings)(h).then(w=>{w&&i(w)})},[]),(0,z.useEffect)(()=>(r.onNotification=h=>{n(w=>[...w,h])},r.restore().then(()=>{n(r.getHistory())}),()=>{r.onNotification=void 0}),[]);let C=(0,z.useMemo)(()=>s.filter(h=>!h.read).length,[s]),u=(0,z.useCallback)(()=>{r.clear(),n([])},[r]),c=(0,z.useCallback)(h=>{(0,Q.clearOneInAppNotification)(r,h).then(()=>{n(r.getHistory())})},[r]),g=(0,z.useCallback)(h=>{r.markAsRead(h),n(w=>w.map(E=>E.id===h?{...E,read:!0}:E))},[r]),o=(0,z.useCallback)(()=>{r.markAllAsRead(),n(h=>h.map(w=>({...w,read:!0})))},[r]),a=(0,z.useCallback)(h=>{(0,Q.addInAppNotification)(r,h)},[r]),p=(0,z.useCallback)(h=>{i(w=>{let E=(0,Q.updateNotificationSettings)(w,h),R=e?.storage??(0,Q.createNotificationSettingsStorage)();return(0,Q.saveNotificationSettings)(R,E),E})},[e?.storage]),f=(0,z.useCallback)(h=>{p((0,Q.channelsUpdate)(h))},[p]),d=(0,z.useCallback)(h=>{p((0,Q.mutedChainSettings)(l,h,!0))},[l.mutedChains,p]),S=(0,z.useCallback)(h=>{p((0,Q.mutedChainSettings)(l,h,!1))},[l.mutedChains,p]);return{notifications:s,unreadCount:C,addNotification:a,clear:u,clearOne:c,markAsRead:g,markAllAsRead:o,settings:l,updateSettings:p,setChannels:f,muteChain:d,unmuteChain:S}}var ct=require("react");var to=()=>null,Ps=()=>()=>{};function no(){let{client:e}=U(),t=N(e)?.passphraseGate??null,r=(0,ct.useSyncExternalStore)(t?.subscribe??Ps,t?.getSnapshot??to,to),s=(0,ct.useCallback)(i=>t?.submit(i),[t]),n=(0,ct.useCallback)(()=>t?.cancel(),[t]),l=(0,ct.useCallback)(i=>t?.forget(i),[t]);return{request:r,submit:s,cancel:n,forget:l,isUnlocked:t?.isUnlocked??!1,gate:t}}var ro=require("react");function oo(e,t){let r=(0,ro.useCallback)((s,n)=>s.resolveName(n),[]);return tn({input:e,skip:t?.skip,resolverConfig:t?.resolverConfig,query:r})}var Ie=require("@naculus/connect-appkit-core"),Ve=require("@naculus/connect-core"),oe=require("react");async function Ws(e,t,r,s,n){let l=N(t);if(!l)throw new Ve.WalletError("wallet_unavailable","Client not initialized");let i=[r,s];if(e.walletType==="eip6963"||e.id?.startsWith("eip6963-")){let{eip6963Connector:C}=await import("@naculus/connector-evm-injected"),u=C.getDiscoveredWallets().find(g=>g.id===e.walletId),c=u?await u.provider.request({method:"personal_sign",params:i}):await C.request({method:"personal_sign",params:i});return(0,Ie.assertHexSignature)(c)}if(e.walletType==="walletconnect")return(0,Ie.assertHexSignature)(await l.connector.request({method:"personal_sign",params:i}));if(e.walletType==="embedded"){let C=l.embeddedConnector;if(!C?.signHash)throw new Ve.WalletError("method_unsupported","This embedded wallet build cannot sign a raw digest. Upgrade @naculus/connector-embedded or pass an explicit signer.");return(0,Ie.assertHexSignature)(await C.signHash(e,r))}throw e.walletType==="passkeys"?new Ve.WalletError("method_unsupported","Passkeys sign with P-256, which a SimpleAccount cannot verify. Use a smart account with a WebAuthn validator, or pass an explicit signer."):new Ve.WalletError("method_unsupported",`Raw UserOperation signing is not available for ${e.walletType} on ${n}. Pass a signer that signs the raw 32-byte hash.`)}function so(e){let{evmAccount:t}=H(),{session:r,chainId:s,client:n}=U(),[l,i]=(0,oe.useState)(null),[C,u]=(0,oe.useState)(null),[c,g]=(0,oe.useState)(!1),[o,a]=(0,oe.useState)(!1),[p,f]=(0,oe.useState)(null),d=(0,oe.useRef)(0),S=(0,oe.useRef)(!1);(0,oe.useEffect)(()=>()=>{d.current+=1,S.current=!1},[]),(0,oe.useEffect)(()=>{d.current+=1,S.current=!1,i(null),u(null),g(!1),a(!1),f(null)},[n,s,t,e?.accountType,e?.bundlerUrl,e?.chainId,e?.entryPoint,e?.owner,e?.rpcUrl,e?.salt,e?.signerMode,r]);let h=(0,oe.useCallback)(async(E,R)=>{let A=b=>(f(b),null);if(!e?.rpcUrl)return A(new Error("RPC URL not configured"));if(!e.bundlerUrl)return A(new Error("Bundler URL not configured"));if(!E.length)return A(new Error("At least one call is required"));if(S.current)return A(new Error("A UserOperation is already in progress"));let T=(0,Ie.bareEvmAddress)(e.owner??t);if(!T)return A(new Ve.WalletError("wallet_unavailable","No EVM account found"));let v;try{v=(0,Ie.resolveUserOpChain)(e.chainId,s)}catch(b){return A(b)}if(!e.signer&&!r)return A(new Ve.WalletError("wallet_unavailable","No active session"));let x=++d.current;S.current=!0,g(!0),a(!0),f(null),i(null),u(null);try{let{SmartAccountManager:b}=await import("@naculus/connect-core"),I=e.signer??(m=>Ws(r,n,m,T,v)),W=new b({rpcUrl:e.rpcUrl,bundlerClient:{url:e.bundlerUrl},chainId:v,signer:I,signerMode:e.signer?e.signerMode??"eip191":"raw"}),F=(0,Ie.buildSmartAccountConfig)(T,v,e),q=await W.sendUserOperation(F,E,R);return x!==d.current?null:(a(!1),i(q.userOpHash),W.getUserOperationReceipt(q.userOpHash).then(m=>{x===d.current&&u(m)}).catch(()=>{}),q)}catch(b){if(x!==d.current)return null;let I=b instanceof Error?b:new Error("Failed to send UserOperation");return f(I),null}finally{S.current=!1,x===d.current&&(g(!1),a(!1))}},[n,s,t,e,r]),w=(0,oe.useCallback)(()=>{d.current+=1,i(null),u(null),g(!1),a(!1),f(null)},[]);return{sendUserOp:h,userOpHash:l,receipt:C,isPending:c,isEstimating:o,error:p,reset:w}}var kt=require("react");function Os(e,t){if(!e)return()=>{};let r=()=>t();return e.on("sessionConnected",r),e.on("sessionDisconnected",r),e.on("chainChanged",r),e.on("sessionScopeChanged",r),e.on("sessionRevoked",r),()=>{e.off("sessionConnected",r),e.off("sessionDisconnected",r),e.off("chainChanged",r),e.off("sessionScopeChanged",r),e.off("sessionRevoked",r)}}var Xn=Object.freeze({session:null,chainSessions:[],activeChainId:null,isConnected:!1,connectorId:null}),Yn=new WeakMap;function Ns(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function _s(e){if(!e)return Xn;let t=e.getActiveBundle(),r=Yn.get(e);if(!t)return r&&r.session===null?r:(Yn.set(e,Xn),Xn);let s=Array.from(t.chainSessions.values());if(r&&r.session===t.walletSession&&r.activeChainId===t.activeChainId&&Ns(r.chainSessions,s))return r;let n={session:t.walletSession,chainSessions:s,activeChainId:t.activeChainId,isConnected:!0,connectorId:t.walletSession.walletType};return Yn.set(e,n),n}function ao(e){let t=U(),r=e??t.sessionManager??null,s=(0,kt.useCallback)(l=>Os(r,l),[r]),n=(0,kt.useCallback)(()=>_s(r),[r]);return(0,kt.useSyncExternalStore)(s,n)}var nn=require("@naculus/connect-appkit-core"),xt=require("@naculus/connect-core"),Ue=require("@naculus/siwx"),ut=require("react");var Ds=86400;function rn(){let{session:e,chainId:t,client:r}=U(),[s,n]=(0,ut.useState)(!1),[l,i]=(0,ut.useState)(null),C=(0,ut.useCallback)(()=>i(null),[]);return{signIn:(0,ut.useCallback)(async c=>{if(!e)throw new xt.WalletError("wallet_unavailable","No active session");let g=c?.chainId??t;if(!g)throw new xt.WalletError("invalid_chain","No chain to sign for. Connect a wallet or pass options.chainId.");let o=Xe(e,g);if(!o)throw new xt.WalletError("wallet_unavailable","No account found");let a=N(r);if(!a)throw new xt.WalletError("wallet_unavailable","Client not initialized");let{address:p}=o,f=typeof window>"u"?void 0:window.location,d=c?.domain??(0,nn.defaultSiwxDomain)(f),S=c?.uri??(0,nn.defaultSiwxUri)(f);n(!0),i(null);try{let h=(0,Ue.generateNonce)();await(0,Ue.issueNonce)(h);let w=(0,Ue.nowISO)(),E=c?.expirySeconds??Ds,R=new Date(Date.now()+E*1e3).toISOString(),A=(0,Ue.createSiwxMessage)({domain:d,address:p,uri:S,version:1,chainId:g,nonce:h,issuedAt:w,expirationTime:R,statement:c?.statement,resources:c?.resources,requestId:c?.requestId}),T=await a.signMessage(e,{message:A,address:p,chainId:g??void 0}),v={message:{raw:A,domain:d,address:p,statement:c?.statement??null,uri:S,version:1,chainId:g,nonce:h,issuedAt:w,blockchain:(0,Ue.getBlockchainName)(g),expirationTime:R,notBefore:null,resources:c?.resources??[],requestId:c?.requestId??null},signature:T};return n(!1),v}catch(h){let w=h instanceof Error?h:new Error("SIWx sign-in failed");throw i(w),n(!1),w}},[e,t,r]),isSigningIn:s,error:l,clearError:C}}var Jn=require("@naculus/connect-appkit-core"),on=require("@naculus/connect-core"),vt=require("@naculus/siwx"),se=require("react");function io(e){let{storagePrefix:t="naculus_",autoRestore:r=!0,defaultExpirySeconds:s=86400}=e??{},[n,l]=(0,se.useState)(null),[i,C]=(0,se.useState)(r),[u,c]=(0,se.useState)(!1),[g,o]=(0,se.useState)(null),{session:a,chainId:p}=U(),f=rn(),d=(0,se.useRef)((0,vt.createLocalStorageSiwxSessionStorage)(`${t}siwx_session`)),S=(0,se.useCallback)(()=>o(null),[]);(0,se.useEffect)(()=>{if(!r){C(!1);return}let v=!1;return(async()=>{try{let b=await d.current.get();if(v)return;b?(on.logger.info("react/useSIWxSession","Restored persisted SIWx session"),l(b),o(null)):l(null)}catch(x){on.logger.warn("react/useSIWxSession","Failed to restore SIWx session:",x),l(null)}finally{v||C(!1)}})(),()=>{v=!0}},[r]),(0,se.useEffect)(()=>{if(!n?.expiresAt)return;let v=new Date(n.expiresAt).getTime()-Date.now();if(v<=0){l(null);return}let x=setTimeout(()=>{l(b=>b&&b.id===n.id?null:b)},v);return()=>clearTimeout(x)},[n?.id,n?.expiresAt]);let h=(0,se.useCallback)(async v=>{c(!0),o(null);try{let x={expirySeconds:s,chainId:p??void 0,...v},b=await f.signIn(x),I=(0,Jn.siwxResultToSession)(b);return await d.current.set(I),l(I),c(!1),I}catch(x){let b=x instanceof Error?x:new Error("SIWx sign-in failed");throw o(b),c(!1),b}},[f,p,s]),w=(0,se.useCallback)(async()=>{try{await d.current.remove()}catch(v){on.logger.warn("react/useSIWxSession","Failed to clear session:",v)}l(null),o(null)},[]),E=(0,se.useCallback)(async()=>{if(!n)throw new Error("No active session to refresh");c(!0),o(null);try{let v=await f.signIn({domain:n.domain,statement:n.message.statement??void 0,uri:n.message.uri,chainId:n.chainId,expirySeconds:s,resources:n.message.resources.length>0?n.message.resources:void 0,requestId:n.message.requestId??void 0}),x={...(0,Jn.siwxResultToSession)(v),id:n.id,refreshedAt:new Date().toISOString()};return await d.current.set(x),l(x),c(!1),x}catch(v){let x=v instanceof Error?v:new Error("Session refresh failed");throw o(x),c(!1),x}},[n,f,s]),R=n!==null&&!(0,vt.checkSessionExpired)(n),A=(0,vt.checkSessionExpired)(n),T=n?.expiresAt?Math.max(0,new Date(n.expiresAt).getTime()-Date.now()):null;return{session:R?n:null,isAuthenticated:R,isRestoring:i,isSigningIn:u,isExpired:A,timeUntilExpiry:T,signIn:h,signOut:w,refresh:E,error:g,clearError:S}}var sn=require("@naculus/connect-appkit-core"),At=require("@naculus/connect-core"),Pe=require("@naculus/siwx"),$e=require("react");function pt(){let{session:e,chainId:t,client:r}=U(),[s,n]=(0,$e.useState)(!1),[l,i]=(0,$e.useState)(null),[C,u]=(0,$e.useState)(null),c=(0,$e.useCallback)(()=>u(null),[]);return{signIn:(0,$e.useCallback)(async o=>{if(!e)throw new At.WalletError("wallet_unavailable","No active session");let a=o?.chainId??t;if(!a)throw new At.WalletError("invalid_chain","No chain to sign for. Connect a wallet or pass options.chainId.");let p=Xe(e,a);if(!p)throw new At.WalletError("wallet_unavailable","No account found");let f=N(r);if(!f)throw new At.WalletError("wallet_unavailable","Client not initialized");let{address:d}=p,S=typeof window>"u"?void 0:window.location,h=o?.domain??(0,sn.defaultSiwxDomain)(S),w=o?.uri??(0,sn.defaultSiwxUri)(S);n(!0),u(null);try{let E=(0,Pe.generateNonce)();await(0,Pe.issueNonce)(E);let R=(0,Pe.nowISO)(),A=(0,Pe.createSiwxMessage)({domain:h,address:d,uri:w,version:1,chainId:a,nonce:E,issuedAt:R,statement:o?.statement,expirationTime:o?.expirySeconds?new Date(Date.now()+o.expirySeconds*1e3).toISOString():void 0,resources:o?.resources,requestId:o?.requestId}),T=await f.signMessage(e,{message:A,address:d,chainId:a??void 0}),v=o?.expirySeconds?new Date(Date.now()+o.expirySeconds*1e3).toISOString():null,x={message:{raw:A,domain:h,address:d,statement:o?.statement??null,uri:w,version:1,chainId:a,nonce:E,issuedAt:R,blockchain:(0,Pe.getBlockchainName)(a),expirationTime:v,notBefore:null,resources:o?.resources??[],requestId:o?.requestId??null},signature:T};return i(x),x}catch(E){let R=E instanceof Error?E:new Error("SIWx sign-in failed");throw u(R),R}finally{n(!1)}},[e,t,r]),isSigningIn:s,result:l,error:C,clearError:c}}var an=require("@naculus/connect-core");var Zn=require("react");function Ms(){let{session:e,chainId:t}=U();return(0,Zn.useCallback)(r=>{if(!e)throw new an.WalletError("wallet_unavailable","No active session");let s=r??t;if(s&&!s.startsWith("eip155:"))throw new an.WalletError("namespace_mismatch",`Ethereum SIWx requires an eip155 chain, received ${s}`);let n=e.namespaces.eip155;if(!n||n.accounts.length===0)throw new an.WalletError("namespace_mismatch","No EVM (eip155) accounts found in session")},[e,t])}function lo(){let e=Ms(),t=pt();return{signIn:(0,Zn.useCallback)(async s=>(e(s?.chainId),t.signIn(s)),[e,t.signIn]),isSigningIn:t.isSigningIn,result:t.result,error:t.error,clearError:t.clearError}}var co=require("@naculus/connect-appkit-core"),uo=require("@naculus/wallet-engine"),We=require("react");function po(e){let t=e?.rpcUrl,r=e?.chainId,s=(0,We.useRef)(null),n=(0,We.useCallback)(()=>(s.current||(s.current=new uo.SimulationManager({enabled:!0,rpcUrl:t,autoSimulate:!1})),s.current),[t]),[l,i]=(0,We.useState)(null),[C,u]=(0,We.useState)(!1),[c,g]=(0,We.useState)(null),o=(0,We.useCallback)(async(p,f,d,S,h)=>{u(!0),g(null);try{let w=n(),E=(0,co.resolveSimulationEndpoint)(h?.chainId,r,h?.rpcUrl,t),R=await w.simulateERC20Transfer(p,f,d,S,E.chainId,h?.decimals,E.rpcUrl);return i(R),R}catch(w){let E=w instanceof Error?w:new Error(String(w));throw g(E),E}finally{u(!1)}},[t,r,n]),a=(0,We.useCallback)(()=>{i(null),g(null),u(!1)},[]);return{result:l,loading:C,error:c,simulate:o,reset:a}}var cn=require("@naculus/connect-appkit-core"),Ge=require("@naculus/connect-core"),me=require("react");var ln="siwx_auth";function Ls(e){return new Ge.LocalStorageAdapter(e)}function mo(e){let{storagePrefix:t="naculus_",autoRestore:r=!0}=e??{},[s,n]=(0,me.useState)(null),[l,i]=(0,me.useState)(r),[C,u]=(0,me.useState)(!1),[c,g]=(0,me.useState)(null),o=pt(),a=(0,me.useRef)(Ls(t)),p=(0,me.useCallback)(()=>g(null),[]);(0,me.useEffect)(()=>{if(!r){i(!1);return}let S=!1;return(async()=>{try{let h=a.current,w=await h.get(ln);if(S)return;w&&!(0,cn.isSiwxExpired)(w,new Date)&&(0,cn.isSiwxNotBeforeValid)(w,new Date)?(Ge.logger.info("react/useSiwxAuthSession","Restored persisted SIWx auth session"),n(w),g(null)):w&&(Ge.logger.info("react/useSiwxAuthSession","Persisted SIWx auth expired, clearing"),await h.remove(ln))}catch(h){Ge.logger.warn("react/useSiwxAuthSession","Failed to restore SIWx auth:",h)}finally{S||i(!1)}})(),()=>{S=!0}},[r]);let f=(0,me.useCallback)(async S=>{u(!0),g(null);try{let h=await o.signIn(S);return await a.current.set(ln,h),n(h),u(!1),h}catch(h){let w=h instanceof Error?h:new Error("SIWx sign-in failed");throw g(w),u(!1),w}},[o]),d=(0,me.useCallback)(async()=>{try{await a.current.remove(ln)}catch(S){Ge.logger.warn("react/useSiwxAuthSession","Failed to clear SIWx auth:",S)}n(null),g(null)},[]);return{isSignedIn:s!==null,isRestoring:l,siwxResult:s,isSigningIn:C,error:c,signIn:f,signOut:d,clearError:p}}var je=require("@naculus/connect-appkit-core"),er=require("@naculus/connect-core"),G=require("react");function fo(e){return new er.WalletError("wallet_unavailable",e)}function go(e){let{evmAccount:t}=H(),{session:r,chainId:s,client:n}=U(),[l,i]=(0,G.useState)(null),[C,u]=(0,G.useState)(!1),[c,g]=(0,G.useState)(null),[o,a]=(0,G.useState)(!1),[p,f]=(0,G.useState)(null),d=(0,G.useRef)(null),S=(0,G.useRef)(0),h=(0,G.useRef)(!1);(0,G.useEffect)(()=>{if(d.current=null,!e?.rpcUrl)return;let b=!1;return import("@naculus/connect-core").then(({SmartAccountManager:I})=>{if(b)return;let W=(0,je.resolveEvmChainId)(e.chainId,s);W&&(d.current=new I({rpcUrl:e.rpcUrl,chainId:W,bundlerClient:{url:e.bundlerUrl??""}}))}).catch(I=>{b||f(I instanceof Error?I:new Error("Failed to load account-abstraction module"))}),()=>{b=!0}},[s,e?.rpcUrl,e?.bundlerUrl,e?.chainId]),(0,G.useEffect)(()=>{S.current+=1,h.current=!1,i(null),u(!1),g(null),a(!1),f(null)},[t,s,e?.rpcUrl,e?.bundlerUrl,e?.chainId,e?.entryPoint,e?.accountType,e?.salt]);let w=(0,G.useCallback)(()=>{let b=(0,je.bareEvmAddress)(t);if(!b||!d.current)return null;let I=(0,je.resolveEvmChainId)(e?.chainId,s);return I?(0,je.buildSmartAccountConfig)(b,I,{accountType:e?.accountType,entryPoint:e?.entryPoint,salt:e?.salt}):null},[t,s,e?.accountType,e?.chainId,e?.entryPoint,e?.salt]),E=(0,G.useCallback)(b=>(f(b),null),[]),R=(0,G.useCallback)(()=>h.current?null:(h.current=!0,S.current),[]),A=(0,G.useCallback)(b=>{S.current===b&&(h.current=!1)},[]),T=(0,G.useCallback)(async()=>{let b=w();if(!b||!d.current)return E(new Error("Smart account not configured"));let I=R();if(I===null)return E(new Error("Smart account operation already in progress"));a(!0),f(null);try{let F=await d.current.createAccount(b);return S.current!==I?null:(i(F.address),u(F.isDeployed),g(F),F)}catch(W){if(S.current!==I)return null;let F=W instanceof Error?W:new Error("Failed to create smart account");return f(F),null}finally{S.current===I&&a(!1),A(I)}},[R,E,A,w]),v=(0,G.useCallback)(async()=>{let b=w();if(!b||!d.current)return E(new Error("Smart account not configured"));if(!r)return E(fo("No active session"));let I=N(n);if(!I)return E(fo("Client not initialized"));if(s&&s!==b.chainId)return E(new er.WalletError("chain_mismatch",`Connected chain ${s} does not match smart account chain ${b.chainId}.`));let W=R();if(W===null)return E(new Error("Smart account operation already in progress"));a(!0),f(null);try{let F=d.current,q=await F.createAccount(b);if(S.current!==W)return null;if(q.isDeployed)return i(q.address),u(!0),g(q),q.address;let m=await F.getDeployCallData(b),y=await I.sendTransaction(r,{transaction:{to:m.to,data:m.data,value:m.value.toString()},chainId:b.chainId});if(S.current!==W)return null;let k=await F.createAccount(b);return i(k.address),u(k.isDeployed),g(k),y}catch(F){if(S.current!==W)return null;let q=F instanceof Error?F:new Error("Failed to deploy smart account");return f(q),null}finally{S.current===W&&a(!1),A(W)}},[n,s,R,E,A,w,r]),x=(0,G.useCallback)(async()=>{let b=w();if(!b||!d.current)return null;let I=S.current;try{let W=await d.current.getAccountAddress(b);return S.current!==I?null:(i(W),W)}catch(W){return S.current!==I||f(W instanceof Error?W:new Error("Failed to get smart account address")),null}},[w]);return{address:l,isDeployed:C,accountInfo:c,isLoading:o,error:p,createWallet:T,deployWallet:v,getAddress:x}}var Co=require("react");function un(){let{accounts:e,isConnected:t}=U();return(0,Co.useMemo)(()=>{if(!t)return{address:null,caip10:null,chainId:null,isConnected:!1};let r=e.find(i=>i.startsWith("solana:"))??null;if(!r)return{address:null,caip10:null,chainId:null,isConnected:t};let s=r.split(":"),n=s.length>=3?s[s.length-1]:null,l=s.length>=3?s.slice(0,-1).join(":"):null;return{address:n,caip10:r,chainId:l,isConnected:t}},[e,t])}var xe=require("react"),ho=require("@naculus/connect-core");function yo(e={}){let{client:t}=U(),{address:r}=un(),s=e.address??r,n=e.rpcUrl??N(t)?.solanaRpcUrl??null,[l,i]=(0,xe.useState)(null),[C,u]=(0,xe.useState)(!1),[c,g]=(0,xe.useState)(null),o=(0,xe.useRef)(0),a=(0,xe.useCallback)(async()=>{if(!s||!n){i(null);return}let p=++o.current;u(!0),g(null);try{let f=await(0,ho.getSolanaBalance)(n,s);if(p!==o.current)return;i(f)}catch(f){if(p!==o.current)return;i(null),g(f instanceof Error?f:new Error("Balance read failed"))}finally{p===o.current&&u(!1)}},[s,n]);return(0,xe.useEffect)(()=>{a()},[a]),(0,xe.useEffect)(()=>{if(!e.refreshInterval||e.refreshInterval<=0)return;let p=setInterval(()=>{a()},e.refreshInterval);return()=>clearInterval(p)},[e.refreshInterval,a]),{balance:l,isFetching:C,error:c,isConfigured:!!n,refetch:a}}var So=require("@naculus/connect-appkit-core"),Eo=require("react");function wo(){let{client:e,session:t,accounts:r}=U();return(0,Eo.useMemo)(()=>{let s=N(e)?.solanaConnector,{roles:n,absence:l}=(0,So.readSolanaRoles)(s,t);return{roles:n,absence:l,identity:n?.identity??null,signer:n?.signer??null,payer:n?.payer??null}},[e,t,r])}var tr=require("@naculus/connect-core"),Fe=require("react"),ko=require("@naculus/connect-core");function xo(){let{client:e,session:t}=U(),[r,s]=(0,Fe.useState)(!1),[n,l]=(0,Fe.useState)(!1),[i,C]=(0,Fe.useState)(null),u=()=>{let a=N(e);if(!a||!t)throw new tr.WalletError("wallet_unavailable","No connected wallet.");return a},c=(0,Fe.useCallback)(async a=>{s(!0),C(null);try{return await u().signTransaction(t,{transaction:a})}catch(p){let f=p instanceof Error?p:new Error("Signing failed");throw C(f),f}finally{s(!1)}},[e,t]),g=(0,Fe.useCallback)(async a=>{l(!0),C(null);try{return await u().sendTransaction(t,{transaction:a})}catch(p){let f=p instanceof Error?p:new Error("Send failed");throw C(f),f}finally{l(!1)}},[e,t]),o=(0,Fe.useCallback)(async a=>{let p=N(e)?.solanaRpcUrl;if(!p)throw new tr.WalletError("no_rpc","Set solanaRpcUrl on the client to read a signature's status.");return(0,ko.getSignatureStatus)(p,a)},[e]);return{signTransaction:c,sendTransaction:g,getStatus:o,isSigning:r,isSending:n,error:i,reset:()=>C(null)}}var dt=require("react"),vo=require("@naculus/connect-appkit-core");function Ao(){let{switchChain:e,chainId:t}=U(),[r,s]=(0,dt.useState)(!1),[n,l]=(0,dt.useState)(null),i=(0,dt.useCallback)(async u=>{s(!0),l(null);try{await e(u)}catch(c){let g=(0,vo.toChainSwitchError)(c);throw l(g),g}finally{s(!1)}},[e]),C=(0,dt.useCallback)(()=>{l(null)},[]);return{switchChain:i,isSwitching:r,currentChainId:t,error:n,clearError:C}}var mt=require("@naculus/connect-appkit-core"),Y=require("react");var ft=require("viem");function bo(e){let{evmAccount:t,isConnected:r}=H(),{chainId:s,chains:n}=U(),[l,i]=(0,Y.useState)([]),[C,u]=(0,Y.useState)(!1),[c,g]=(0,Y.useState)(null),{tokens:o,refreshInterval:a}=e,p=(0,Y.useRef)(null),f=(0,Y.useMemo)(()=>o.map(v=>v.address.toLowerCase()+"|"+v.decimals+"|"+v.symbol).join(","),[o]),d=(0,Y.useMemo)(()=>(0,mt.resolveChain)(n,s),[s,n]),S=d?(0,mt.chainNumber)(d):null,h=(0,Y.useMemo)(()=>d?(0,mt.toViemChain)(d,S):null,[d,S]),[w,E]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{if(!h||!d?.rpcUrl){E(null);return}let v=(0,ft.createPublicClient)({transport:(0,ft.http)(d.rpcUrl),chain:h});E(v)},[d,h]);let R=[{name:"balanceOf",type:"function",stateMutability:"view",inputs:[{name:"owner",type:"address"}],outputs:[{name:"balance",type:"uint256"}]}],A=(0,Y.useCallback)(async()=>{if(!t||!w||o.length===0){i([]);return}u(!0),g(null);try{let v=t.includes(":")?t.split(":").pop():t,b=(await Promise.allSettled(o.map(async I=>{try{let W=await w.readContract({address:I.address,abi:R,functionName:"balanceOf",args:[v]});return{address:I.address,symbol:I.symbol,decimals:I.decimals,name:I.name,balance:W.toString(),formatted:(0,ft.formatUnits)(W,I.decimals)}}catch{return{address:I.address,symbol:I.symbol,decimals:I.decimals,name:I.name,balance:null,formatted:null}}}))).map(I=>I.status==="fulfilled"?I.value:{address:"",symbol:"?",decimals:0,balance:null,formatted:null});i(b)}catch(v){g(v instanceof Error?v:new Error("Failed to fetch token balances"))}finally{u(!1)}},[t,w,f]);(0,Y.useEffect)(()=>{r&&t&&o.length>0&&A()},[r,t,f,A]),(0,Y.useEffect)(()=>(a&&a>0&&r&&t&&o.length>0&&(p.current=setInterval(A,a)),()=>{p.current&&(clearInterval(p.current),p.current=null)}),[a,r,t,f,A]);let T=(0,Y.useCallback)(v=>l.find(x=>x.address.toLowerCase()===v.toLowerCase()),[l]);return{tokenBalances:l,isLoading:C,error:c,refetch:A,getTokenBalance:T,chain:d}}var ve=require("react");function Ro(e,t,r){let s=wt(),n=r??s,[l,i]=(0,ve.useState)([]),[C,u]=(0,ve.useState)(!1),[c,g]=(0,ve.useState)(null),o=(0,ve.useRef)(0),a=(0,ve.useCallback)(async()=>{if(n){u(!0),g(null),o.current++;try{let f=await n.getTxHistory(e,t);i(f)}catch(f){g(f instanceof Error?f:new Error(String(f)))}finally{u(!1)}}},[n,e,t]);(0,ve.useEffect)(()=>{a().catch(()=>{})},[a]),(0,ve.useEffect)(()=>{if(!n)return;let f=()=>{a().catch(()=>{})};return n.on("statusChange",f),()=>{n.off("statusChange",f)}},[n,a]);let p={pending:l.filter(f=>f.status==="pending").length,confirmed:l.filter(f=>f.status==="confirmed").length,failed:l.filter(f=>f.status==="failed").length};return{entries:l,isLoading:C,error:c,refresh:a,summary:p}}var pn=require("@naculus/connect-appkit-core"),V=require("react");function To(e){let t=e?.bundlerUrl,r=e?.pollInterval??2e3,s=e?.maxRetries??30,[n,l]=(0,V.useState)("idle"),[i,C]=(0,V.useState)(null),[u,c]=(0,V.useState)(e?.userOpHash??null),[g,o]=(0,V.useState)(null),[a,p]=(0,V.useState)(!1),[f,d]=(0,V.useState)(0),S=(0,V.useRef)(0),[h,w]=(0,V.useState)(0),E=(0,V.useRef)(null),R=(0,V.useRef)(null),A=(0,V.useRef)(0),T=(0,V.useRef)(0),v=(0,V.useRef)(null),x=(0,V.useCallback)(()=>{E.current&&(clearInterval(E.current),E.current=null),R.current&&(clearTimeout(R.current),R.current=null)},[]),b=(0,V.useCallback)(async(q,m)=>{if(!t||m!==A.current)return;let y=T.current+1;T.current=y,d(y);let k=new AbortController;v.current=k;let P=D=>{m===A.current&&(l("not_found"),p(!1),x(),o(D))},_=D=>{if(m===A.current){if(y<=s){R.current=setTimeout(()=>{b(q,m)},r);return}P(D)}};try{let D=await(0,pn.fetchUserOperationReceipt)(t,q,k.signal);if(m!==A.current)return;if(D){C(D),l(D.success?"confirmed":"failed"),p(!1),x();return}l("pending"),_(new Error("UserOperation not included after maximum retries"))}catch(D){if(m!==A.current||k.signal.aborted)return;let De=D instanceof Error?D:new Error("Unknown bundler response failure");if(De instanceof pn.InvalidUserOperationReceiptError){P(De);return}_(new Error(`UserOperation status unavailable after ${y} attempt${y===1?"":"s"}: ${De.message}`))}finally{v.current===k&&(v.current=null)}},[t,r,s,x]),I=(0,V.useCallback)(q=>{A.current+=1;let m=A.current;if(v.current?.abort(),v.current=null,x(),c(q),C(null),o(null),T.current=0,d(0),w(0),S.current=Date.now(),!t){l("not_found"),p(!1),o(new Error("Bundler URL not configured"));return}l("pending"),p(!0),E.current=setInterval(()=>{w(Date.now()-S.current)},1e3),b(q,m)},[t,x,b]),W=(0,V.useCallback)(()=>{A.current+=1,v.current?.abort(),v.current=null,x(),p(!1)},[x]),F=(0,V.useCallback)(()=>{A.current+=1,v.current?.abort(),v.current=null,x(),c(null),l("idle"),C(null),o(null),p(!1),T.current=0,d(0),w(0)},[x]);return(0,V.useEffect)(()=>{e?.userOpHash&&e?.autoStart!==!1&&I(e.userOpHash)},[]),(0,V.useEffect)(()=>()=>{A.current+=1,v.current?.abort(),v.current=null,x()},[x]),{status:n,receipt:i,userOpHash:u,error:g,isPolling:a,elapsedMs:h,attempts:f,start:I,stop:W,reset:F}}var Wo=require("@naculus/connect-appkit-core"),Oo=require("react");var Bs={"storage.critical.title":"Insecure Storage Detected","storage.critical.body":"Your browser does not support IndexedDB. Wallet data is stored in plaintext in localStorage and could be exposed to XSS attacks. We strongly recommend switching to a modern browser.","storage.warning.title":"Storage Security Warning","storage.warning.body":"Your browser does not support IndexedDB, but your wallet data is encrypted with AES-256-GCM. Consider switching browsers for better origin isolation.","address.empty":"Address is empty","address.invalid_format":"Invalid address format (expected 0x + 40 hex chars)","address.zero_address":"Address is the zero address \u2014 funds would be permanently lost","address.burn_address":"Address appears to be a burn address \u2014 funds would be permanently lost","wallet.connect":"Connect Wallet","wallet.disconnect":"Disconnect","wallet.connecting":"Connecting...","wallet.copy_address":"Copy address","wallet.copied":"Copied!","wallet.view_on_explorer":"View on Explorer","wallet.retry":"Retry","wallet.connection_failed":"Connection failed","wallet.scan_qr":"Scan with your wallet app","embedded.generate":"Create Wallet","embedded.import":"Import Wallet","embedded.backup_seed":"Back up your seed phrase","embedded.backup_warning":"Anyone with your seed phrase can access your funds. Store it securely.","embedded.backup_done":"I've saved my seed phrase","embedded.wipe":"Remove Wallet","embedded.wipe_confirm":"Are you sure? This cannot be undone."},Fs={"storage.critical.title":"\u5075\u6E2C\u5230\u4E0D\u5B89\u5168\u5132\u5B58","storage.critical.body":"\u60A8\u7684\u700F\u89BD\u5668\u4E0D\u652F\u63F4 IndexedDB\u3002\u9322\u5305\u8CC7\u6599\u4EE5\u660E\u6587\u5132\u5B58\u5728 localStorage \u4E2D\uFF0C\u53EF\u80FD\u66B4\u9732\u65BC XSS \u653B\u64CA\u3002\u5F37\u70C8\u5EFA\u8B70\u66F4\u63DB\u81F3\u73FE\u4EE3\u700F\u89BD\u5668\u3002","storage.warning.title":"\u5132\u5B58\u5B89\u5168\u8B66\u544A","storage.warning.body":"\u60A8\u7684\u700F\u89BD\u5668\u4E0D\u652F\u63F4 IndexedDB\uFF0C\u4F46\u9322\u5305\u8CC7\u6599\u5DF2\u4F7F\u7528 AES-256-GCM \u52A0\u5BC6\u3002\u5EFA\u8B70\u66F4\u63DB\u700F\u89BD\u5668\u4EE5\u7372\u5F97\u66F4\u597D\u7684\u9694\u96E2\u4FDD\u8B77\u3002","address.empty":"\u5730\u5740\u70BA\u7A7A","address.invalid_format":"\u7121\u6548\u7684\u5730\u5740\u683C\u5F0F\uFF08\u61C9\u70BA 0x + 40 \u500B\u5341\u516D\u9032\u4F4D\u5B57\u5143\uFF09","address.zero_address":"\u6B64\u70BA\u96F6\u5730\u5740 \u2014 \u8CC7\u91D1\u5C07\u6C38\u4E45\u4E1F\u5931","address.burn_address":"\u6B64\u5730\u5740\u70BA\u71D2\u6BC0\u5730\u5740 \u2014 \u8CC7\u91D1\u5C07\u6C38\u4E45\u4E1F\u5931","wallet.connect":"\u9023\u63A5\u9322\u5305","wallet.disconnect":"\u65B7\u958B\u9023\u7DDA","wallet.connecting":"\u9023\u7DDA\u4E2D...","wallet.copy_address":"\u8907\u88FD\u5730\u5740","wallet.copied":"\u5DF2\u8907\u88FD\uFF01","wallet.view_on_explorer":"\u5728\u700F\u89BD\u5668\u67E5\u770B","wallet.retry":"\u91CD\u8A66","wallet.connection_failed":"\u9023\u7DDA\u5931\u6557","wallet.scan_qr":"\u4F7F\u7528\u9322\u5305 App \u6383\u63CF","embedded.generate":"\u5EFA\u7ACB\u9322\u5305","embedded.import":"\u532F\u5165\u9322\u5305","embedded.backup_seed":"\u5099\u4EFD\u52A9\u8A18\u8A5E","embedded.backup_warning":"\u4EFB\u4F55\u4EBA\u53D6\u5F97\u60A8\u7684\u52A9\u8A18\u8A5E\u90FD\u53EF\u4EE5\u5B58\u53D6\u60A8\u7684\u8CC7\u91D1\u3002\u8ACB\u5B89\u5168\u5132\u5B58\u3002","embedded.backup_done":"\u6211\u5DF2\u5132\u5B58\u52A9\u8A18\u8A5E","embedded.wipe":"\u79FB\u9664\u9322\u5305","embedded.wipe_confirm":"\u78BA\u5B9A\u8981\u79FB\u9664\u55CE\uFF1F\u6B64\u64CD\u4F5C\u7121\u6CD5\u5FA9\u539F\u3002"},Io={en:Bs,zh:Fs},nr="en";function Uo(e){nr=e}function Po(){return nr}function dn(e){return Io[nr][e]??Io.en[e]??e}function rr(e){let{isValid:t,level:r,issue:s}=(0,Wo.validateDestination)(e);return{isValid:t,level:r,warning:s?dn(`address.${s}`):null}}function No({address:e}){return{validation:(0,Oo.useMemo)(()=>rr(e),[e])}}function _o(){let{status:e,session:t,accounts:r,chainId:s,error:n,connect:l,disconnect:i,reconnect:C,switchChain:u}=U(),c=e==="connected",g=e==="connecting",o=e==="reconnecting",a=r[0]??null;return{status:e,session:t,accounts:r,chainId:s,error:n,isConnected:c,isConnecting:g,isReconnecting:o,isDisconnected:e==="disconnected",currentAccount:a,connect:l,disconnect:i,reconnect:C,switchChain:u}}var ze=require("react");var or={wallet_unavailable:"Wallet Not Detected",user_rejected:"Connection Rejected",deeplink_timeout:"Wallet Connection Timed Out",session_expired:"Session Expired",intent_expired:"Connection Request Expired",namespace_mismatch:"Network Mismatch",chain_unsupported:"Unsupported Network",method_not_allowed:"Action Not Allowed",signature_rejected:"Signature Rejected",tx_failed:"Transaction Failed"},sr={wallet_unavailable:"No wallet found. Please install a compatible wallet (e.g., MetaMask, WalletConnect) and try again.",user_rejected:"The connection request was declined in your wallet. You can try again whenever you're ready.",deeplink_timeout:"The wallet didn't respond in time. This can happen if the wallet app isn't installed or takes too long to open.",session_expired:"Your wallet session has expired. Please reconnect to continue.",intent_expired:"The connection request expired. Please try connecting again.",namespace_mismatch:"This wallet doesn't support the required network. Try using a different wallet or network.",chain_unsupported:"This network isn't supported. Please switch to a supported network in your wallet.",method_not_allowed:"This action isn't supported by your current wallet or network.",signature_rejected:"The signature request was declined in your wallet.",tx_failed:"The transaction couldn't be completed. This could be due to insufficient funds, network congestion, or a contract error."},bt="Something went wrong",Rt="An unexpected error occurred. Please try again. If the problem persists, check your connection and wallet configuration.";function gt(e){if(!e)return{title:bt,description:Rt};let t=e;if(t.name==="WalletError"&&t.code){let r=t.code,s=or[r]??bt,n=sr[r]??t.message??Rt;return{title:s,description:n,code:r}}if(e instanceof Error){let r=e.message;return/user rejected/i.test(r)||/rejected/.test(r)?{title:"Request Rejected",description:"The request was declined.",code:"user_rejected"}:/timeout/i.test(r)||/timed? ?out/i.test(r)?{title:"Request Timed Out",description:"The request took too long. Please try again.",code:"deeplink_timeout"}:/insufficient funds/i.test(r)?{title:"Insufficient Funds",description:"You don't have enough funds to complete this transaction.",code:"tx_failed"}:/network/i.test(r)||/chain/i.test(r)?{title:"Network Error",description:r,code:"chain_unsupported"}:{title:bt,description:r||Rt}}return typeof e=="string"?{title:bt,description:e||Rt}:{title:bt,description:Rt}}function mn(e){if(e===null||typeof e!="object")return!1;let t=e;return t.name!=="WalletError"||!t.code?!1:["deeplink_timeout","session_expired","intent_expired","tx_failed"].includes(t.code)}function Do(){let{error:e,clearError:t}=U(),r=(0,ze.useMemo)(()=>e?gt(e):null,[e]),s=(0,ze.useMemo)(()=>e?mn(e):!1,[e]),n=(0,ze.useCallback)(()=>{t()},[t]),l=(0,ze.useCallback)(C=>gt(C),[]),i=(0,ze.useCallback)(C=>async()=>{try{return await C()}catch(u){let c=gt(u);if(u instanceof Error){let g=u;try{g.title=c.title,g.friendlyMessage=c.description,g.code===void 0&&c.code!==void 0&&(g.code=c.code)}catch{}throw g}throw Object.assign(new Error(c.description,{cause:u}),{title:c.title,code:c.code,friendlyMessage:c.description})}},[]);return{error:e,friendlyError:r,clearError:n,isRetryable:s,formatError:l,wrapAsync:i}}var Se=require("react"),Mo=require("@naculus/connect-core"),ar=require("@naculus/connect-appkit-core");function Tt(e,t){let r=(0,Se.useRef)(null),[s,n]=(0,Se.useState)([]),[l,i]=(0,Se.useState)(t?.autoLoad!==!1),[C,u]=(0,Se.useState)(!1),[c,g]=(0,Se.useState)(null);if(!r.current){let p={};t?.sources&&(p.sources=t.sources),r.current=new Mo.TokenListManager(p)}let o=(0,Se.useCallback)(async()=>{let p=r.current;if(p){i(!0),g(null);try{await p.load();let f=e?(0,ar.eip155ChainIdToNumber)(e):void 0,d=p.getTokens(f!==void 0?{chainId:f}:void 0);n(d),u(!0)}catch(f){g(f instanceof Error?f:new Error(String(f)))}finally{i(!1)}}},[e]),a=(0,Se.useCallback)(async()=>{let p=r.current;if(p){i(!0),g(null);try{await p.refresh();let f=e?(0,ar.eip155ChainIdToNumber)(e):void 0,d=p.getTokens(f!==void 0?{chainId:f}:void 0);n(d),u(!0)}catch(f){g(f instanceof Error?f:new Error(String(f)))}finally{i(!1)}}},[e]);return(0,Se.useEffect)(()=>{t?.autoLoad!==!1&&o()},[o,t?.autoLoad]),{tokens:s,isLoading:l,isLoaded:C,error:c,refetch:a}}var Qe=require("react"),Bo=require("@naculus/connect-core");var Oe=require("@naculus/connect-core");function Lo(){return[{name:"built-in",tokens:[...Oe.ETHEREUM_MAINNET_TOKENS,...Oe.POLYGON_TOKENS,...Oe.OPTIMISM_TOKENS,...Oe.ARBITRUM_TOKENS,...Oe.BASE_TOKENS],enabled:!0},{name:"uniswap-default",url:"https://tokens.uniswap.org",enabled:!0,refreshInterval:1440*60*1e3}]}var Fo=require("@naculus/connect-appkit-core"),Hs=300,fn=null;function Ks(){return fn||(fn=new Bo.TokenListManager({sources:Lo()}),fn.load().catch(()=>{})),fn}function It(e,t){let[r,s]=(0,Qe.useState)({exact:[],fuzzy:[],hasMore:!1}),[n,l]=(0,Qe.useState)(!1),i=(0,Qe.useRef)(null),C=e.trim();return(0,Qe.useEffect)(()=>{if(!C){s({exact:[],fuzzy:[],hasMore:!1}),l(!1);return}return i.current&&clearTimeout(i.current),l(!0),i.current=setTimeout(()=>{let u=Ks(),c=t?(0,Fo.eip155ChainIdToNumber)(t):void 0,g=u.search(C,{chainId:c,limit:20});s(g),l(!1)},Hs),()=>{i.current&&clearTimeout(i.current)}},[C,t]),{results:r,isSearching:n}}var Ct=Me(require("react"),1);var B=require("react/jsx-runtime");function ir({chainId:e,onSelect:t,onClose:r,options:s}){let[n,l]=Ct.default.useState(""),{tokens:i,isLoading:C,error:u}=Tt(e),{results:c,isSearching:g}=It(n,n?e:void 0),o=s?.showRecommendations??!0,a=Ct.default.useMemo(()=>{if(n.trim()){let S=[...c.exact,...c.fuzzy].map(h=>h.token);return s?.filter?S.filter(s.filter):S}let d=i;return s?.filter?d.filter(s.filter):d},[n,c,i,s?.filter]),p=Ct.default.useMemo(()=>!o||n.trim()?[]:i.slice(0,6),[i,o,n]),f=(0,Ct.useCallback)(d=>{t(d),r()},[t,r]);return(0,B.jsxs)("div",{style:{background:"hsl(var(--background))",borderRadius:"12px",padding:"16px",color:"hsl(var(--foreground))",minWidth:"320px",maxWidth:"400px",fontFamily:"system-ui, sans-serif"},children:[(0,B.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[(0,B.jsx)("h3",{style:{margin:0,fontSize:"16px",fontWeight:600},children:"Select Token"}),(0,B.jsx)("button",{onClick:r,style:{background:"none",border:"none",color:"hsl(var(--muted-foreground))",cursor:"pointer",fontSize:"18px",padding:"4px 8px"},children:"\u2715"})]}),(0,B.jsx)("input",{type:"text",placeholder:"Search token name or paste address",value:n,onChange:d=>l(d.target.value),style:{width:"100%",padding:"10px 12px",borderRadius:"8px",border:"1px solid #333",background:"hsl(var(--card))",color:"hsl(var(--foreground))",fontSize:"14px",outline:"none",boxSizing:"border-box",marginBottom:"12px"},autoFocus:!0}),C&&!g&&(0,B.jsx)("div",{style:{textAlign:"center",padding:"20px",color:"hsl(var(--muted-foreground))"},children:"Loading tokens..."}),u&&(0,B.jsxs)("div",{style:{textAlign:"center",padding:"12px",color:"hsl(var(--destructive))",fontSize:"13px"},children:["Error: ",u.message]}),o&&p.length>0&&!n.trim()&&(0,B.jsxs)("div",{style:{marginBottom:"12px"},children:[(0,B.jsx)("div",{style:{fontSize:"11px",color:"hsl(var(--muted-foreground))",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"8px"},children:"Popular"}),(0,B.jsx)("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap"},children:p.map(d=>(0,B.jsxs)("button",{onClick:()=>f(d),style:{background:"hsl(var(--card))",border:"1px solid #333",borderRadius:"20px",padding:"6px 14px",color:"hsl(var(--foreground))",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"4px"},children:[d.logoURI?(0,B.jsx)("img",{src:d.logoURI,alt:"",style:{width:"16px",height:"16px",borderRadius:"50%"},onError:S=>{S.target.style.display="none"}}):null,d.symbol]},`${d.chainId}:${d.address}`))})]}),n.trim()&&!C&&(0,B.jsx)("div",{style:{fontSize:"11px",color:"hsl(var(--muted-foreground))",marginBottom:"8px"},children:a.length>0?(0,B.jsxs)(B.Fragment,{children:[c.exact.length," exact, ",c.fuzzy.length," fuzzy",c.hasMore?" (more available)":""]}):"No results found"}),(0,B.jsx)("div",{style:{maxHeight:"320px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"2px"},children:a.map(d=>(0,B.jsxs)("button",{onClick:()=>f(d),style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 8px",background:"transparent",border:"none",borderRadius:"8px",color:"hsl(var(--foreground))",cursor:"pointer",textAlign:"left",width:"100%",fontSize:"14px"},onMouseEnter:S=>{S.target.style.background="hsl(var(--card))"},onMouseLeave:S=>{S.target.style.background="transparent"},children:[(0,B.jsx)("div",{style:{width:"32px",height:"32px",borderRadius:"50%",background:"hsl(var(--border))",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:600,flexShrink:0,overflow:"hidden"},children:d.logoURI?(0,B.jsx)("img",{src:d.logoURI,alt:d.symbol,style:{width:"100%",height:"100%"},onError:S=>{let h=S.target;h.style.display="none",h.parentElement.textContent=d.symbol.slice(0,2)}}):d.symbol.slice(0,2)}),(0,B.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,B.jsx)("div",{style:{fontWeight:600,fontSize:"14px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.symbol}),(0,B.jsx)("div",{style:{fontSize:"12px",color:"hsl(var(--muted-foreground))",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.name})]}),(0,B.jsxs)("div",{style:{fontSize:"11px",color:"#666",textAlign:"right",flexShrink:0},children:[(0,B.jsxs)("div",{children:[d.decimals," decimals"]}),(0,B.jsxs)("div",{children:["Chain ",d.chainId]})]})]},`${d.chainId}:${d.address}`))})]})}var M=require("@stencil/react-output-target/runtime"),L=Me(require("react"),1),gn=require("@naculus/connect-appkit-wc/dist/components/appkit-accordion.js"),Cn=require("@naculus/connect-appkit-wc/dist/components/appkit-account-button.js"),hn=require("@naculus/connect-appkit-wc/dist/components/appkit-alert-dialog.js"),yn=require("@naculus/connect-appkit-wc/dist/components/appkit-avatar.js"),Sn=require("@naculus/connect-appkit-wc/dist/components/appkit-badge.js"),En=require("@naculus/connect-appkit-wc/dist/components/appkit-button.js"),wn=require("@naculus/connect-appkit-wc/dist/components/appkit-card-content.js"),kn=require("@naculus/connect-appkit-wc/dist/components/appkit-card-description.js"),xn=require("@naculus/connect-appkit-wc/dist/components/appkit-card-footer.js"),vn=require("@naculus/connect-appkit-wc/dist/components/appkit-card-header.js"),An=require("@naculus/connect-appkit-wc/dist/components/appkit-card-title.js"),bn=require("@naculus/connect-appkit-wc/dist/components/appkit-card.js"),Rn=require("@naculus/connect-appkit-wc/dist/components/appkit-checkbox.js"),Tn=require("@naculus/connect-appkit-wc/dist/components/appkit-collapsible.js"),In=require("@naculus/connect-appkit-wc/dist/components/appkit-connect-button.js"),Un=require("@naculus/connect-appkit-wc/dist/components/appkit-dialog.js"),Pn=require("@naculus/connect-appkit-wc/dist/components/appkit-dropdown-menu.js"),Wn=require("@naculus/connect-appkit-wc/dist/components/appkit-input.js"),On=require("@naculus/connect-appkit-wc/dist/components/appkit-popover.js"),Nn=require("@naculus/connect-appkit-wc/dist/components/appkit-progress.js"),_n=require("@naculus/connect-appkit-wc/dist/components/appkit-scroll-area.js"),Dn=require("@naculus/connect-appkit-wc/dist/components/appkit-select.js"),Mn=require("@naculus/connect-appkit-wc/dist/components/appkit-separator.js"),Ln=require("@naculus/connect-appkit-wc/dist/components/appkit-skeleton.js"),Bn=require("@naculus/connect-appkit-wc/dist/components/appkit-switch.js"),Fn=require("@naculus/connect-appkit-wc/dist/components/appkit-tabs.js"),Hn=require("@naculus/connect-appkit-wc/dist/components/appkit-toggle-group.js"),Kn=require("@naculus/connect-appkit-wc/dist/components/appkit-tooltip.js"),Ho=(0,M.createComponent)({tagName:"appkit-accordion",elementClass:gn.AppkitAccordion,react:L.default,events:{onAppkitToggle:"appkitToggle"},defineCustomElement:gn.defineCustomElement}),Ko=(0,M.createComponent)({tagName:"appkit-account-button",elementClass:Cn.AppkitAccountButton,react:L.default,events:{},defineCustomElement:Cn.defineCustomElement}),qo=(0,M.createComponent)({tagName:"appkit-alert-dialog",elementClass:hn.AppkitAlertDialog,react:L.default,events:{onAppkitClose:"appkitClose",onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:hn.defineCustomElement}),Vo=(0,M.createComponent)({tagName:"appkit-avatar",elementClass:yn.AppkitAvatar,react:L.default,events:{},defineCustomElement:yn.defineCustomElement}),$o=(0,M.createComponent)({tagName:"appkit-badge",elementClass:Sn.AppkitBadge,react:L.default,events:{},defineCustomElement:Sn.defineCustomElement}),Go=(0,M.createComponent)({tagName:"appkit-button",elementClass:En.AppkitButton,react:L.default,events:{},defineCustomElement:En.defineCustomElement}),jo=(0,M.createComponent)({tagName:"appkit-card",elementClass:bn.AppkitCard,react:L.default,events:{},defineCustomElement:bn.defineCustomElement}),zo=(0,M.createComponent)({tagName:"appkit-card-content",elementClass:wn.AppkitCardContent,react:L.default,events:{},defineCustomElement:wn.defineCustomElement}),Qo=(0,M.createComponent)({tagName:"appkit-card-description",elementClass:kn.AppkitCardDescription,react:L.default,events:{},defineCustomElement:kn.defineCustomElement}),Xo=(0,M.createComponent)({tagName:"appkit-card-footer",elementClass:xn.AppkitCardFooter,react:L.default,events:{},defineCustomElement:xn.defineCustomElement}),Yo=(0,M.createComponent)({tagName:"appkit-card-header",elementClass:vn.AppkitCardHeader,react:L.default,events:{},defineCustomElement:vn.defineCustomElement}),Jo=(0,M.createComponent)({tagName:"appkit-card-title",elementClass:An.AppkitCardTitle,react:L.default,events:{},defineCustomElement:An.defineCustomElement}),Zo=(0,M.createComponent)({tagName:"appkit-checkbox",elementClass:Rn.AppkitCheckbox,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Rn.defineCustomElement}),es=(0,M.createComponent)({tagName:"appkit-collapsible",elementClass:Tn.AppkitCollapsible,react:L.default,events:{onAppkitToggle:"appkitToggle"},defineCustomElement:Tn.defineCustomElement}),ts=(0,M.createComponent)({tagName:"appkit-connect-button",elementClass:In.AppkitConnectButton,react:L.default,events:{onAppkitConnect:"appkitConnect",onAppkitDisconnect:"appkitDisconnect",onAppkitStartPairing:"appkitStartPairing",onAppkitRetry:"appkitRetry",onAppkitCancelPairing:"appkitCancelPairing",onAppkitMobileDeepLink:"appkitMobileDeepLink",onAppkitCopyAddress:"appkitCopyAddress"},defineCustomElement:In.defineCustomElement}),ns=(0,M.createComponent)({tagName:"appkit-dialog",elementClass:Un.AppkitDialog,react:L.default,events:{onAppkitClose:"appkitClose",onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:Un.defineCustomElement}),rs=(0,M.createComponent)({tagName:"appkit-dropdown-menu",elementClass:Pn.AppkitDropdownMenu,react:L.default,events:{onAppkitSelect:"appkitSelect"},defineCustomElement:Pn.defineCustomElement}),os=(0,M.createComponent)({tagName:"appkit-input",elementClass:Wn.AppkitInput,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Wn.defineCustomElement}),ss=(0,M.createComponent)({tagName:"appkit-popover",elementClass:On.AppkitPopover,react:L.default,events:{onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:On.defineCustomElement}),as=(0,M.createComponent)({tagName:"appkit-progress",elementClass:Nn.AppkitProgress,react:L.default,events:{},defineCustomElement:Nn.defineCustomElement}),is=(0,M.createComponent)({tagName:"appkit-scroll-area",elementClass:_n.AppkitScrollArea,react:L.default,events:{},defineCustomElement:_n.defineCustomElement}),ls=(0,M.createComponent)({tagName:"appkit-select",elementClass:Dn.AppkitSelect,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Dn.defineCustomElement}),cs=(0,M.createComponent)({tagName:"appkit-separator",elementClass:Mn.AppkitSeparator,react:L.default,events:{},defineCustomElement:Mn.defineCustomElement}),us=(0,M.createComponent)({tagName:"appkit-skeleton",elementClass:Ln.AppkitSkeleton,react:L.default,events:{},defineCustomElement:Ln.defineCustomElement}),ps=(0,M.createComponent)({tagName:"appkit-switch",elementClass:Bn.AppkitSwitch,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Bn.defineCustomElement}),ds=(0,M.createComponent)({tagName:"appkit-tabs",elementClass:Fn.AppkitTabs,react:L.default,events:{onAppkitTabChange:"appkitTabChange"},defineCustomElement:Fn.defineCustomElement}),ms=(0,M.createComponent)({tagName:"appkit-toggle-group",elementClass:Hn.AppkitToggleGroup,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Hn.defineCustomElement}),fs=(0,M.createComponent)({tagName:"appkit-tooltip",elementClass:Kn.AppkitTooltip,react:L.default,events:{},defineCustomElement:Kn.defineCustomElement});0&&(module.exports={AppkitAccordion,AppkitAccountButton,AppkitAlertDialog,AppkitAvatar,AppkitBadge,AppkitButton,AppkitCard,AppkitCardContent,AppkitCardDescription,AppkitCardFooter,AppkitCardHeader,AppkitCardTitle,AppkitCheckbox,AppkitCollapsible,AppkitConnectButton,AppkitDialog,AppkitDropdownMenu,AppkitInput,AppkitPopover,AppkitProgress,AppkitScrollArea,AppkitSelect,AppkitSeparator,AppkitSkeleton,AppkitSwitch,AppkitTabs,AppkitToggleGroup,AppkitTooltip,DEFAULT_EVM_CHAINS,LAMPORTS_PER_SOL,PassphraseCancelledError,PassphraseGate,SolanaRpcError,TokenSelector,TxMonitorContext,WALLET_ERROR_DESCRIPTIONS,WALLET_ERROR_TITLES,Web3ConnectProvider,Web3Context,buildDelegationPolicyMessage,clearClient,createClient,formatSol,getChainById,getClient,getDefaultChains,getLatestBlockhash,getLocale,getSignatureStatus,getSolanaBalance,getUserFriendlyError,isRetryableError,parseSol,resetSessionKeyManager,setLocale,t,useAccount,useBalance,useCapabilities,useChain,useCompareCosts,useConnect,useCreateSessionKey,useDelegate,useDelegation,useDelegationPolicy,useDisconnect,useERC20Allowance,useERC20Approve,useERC20Transfer,useERC20TransferSimulation,useEmbeddedWallet,useExecuteCalls,useExecuteRoute,useLastTx,useLookupAddress,useNotification,usePassphraseGate,useResolveName,useRevokeSession,useRouteQuote,useSIWxLogin,useSIWxSession,useSendCalls,useSendTransaction,useSendUserOperation,useSendWithSession,useSession,useSessionKeys,useSignInWithEthereum,useSignInWithX,useSignMessage,useSimulateTransfer,useSiwxAuthSession,useSmartAccount,useSolanaAccount,useSolanaBalance,useSolanaRoles,useSolanaTransaction,useSwitchChain,useTokenBalance,useTokenList,useTokenSearch,useTransactionSimulation,useTxHistory,useTxMonitor,useUserOpStatus,useValidateDestination,useViemClient,useWallet,useWeb3,useWeb3ErrorHandler,validateDestination});
|
|
1
|
+
"use strict";var Ss=Object.create;var Pt=Object.defineProperty;var Es=Object.getOwnPropertyDescriptor;var ws=Object.getOwnPropertyNames;var ks=Object.getPrototypeOf,xs=Object.prototype.hasOwnProperty;var vs=(e,t)=>{for(var r in t)Pt(e,r,{get:t[r],enumerable:!0})},ur=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ws(t))!xs.call(e,n)&&n!==r&&Pt(e,n,{get:()=>t[n],enumerable:!(s=Es(t,n))||s.enumerable});return e};var Le=(e,t,r)=>(r=e!=null?Ss(ks(e)):{},ur(t||!e||!e.__esModule?Pt(r,"default",{value:e,enumerable:!0}):r,e)),As=e=>ur(Pt({},"__esModule",{value:!0}),e);var Gs={};vs(Gs,{AppkitAccordion:()=>Vo,AppkitAccountButton:()=>$o,AppkitAlertDialog:()=>Go,AppkitAvatar:()=>jo,AppkitBadge:()=>zo,AppkitButton:()=>Qo,AppkitCard:()=>Xo,AppkitCardContent:()=>Yo,AppkitCardDescription:()=>Jo,AppkitCardFooter:()=>Zo,AppkitCardHeader:()=>es,AppkitCardTitle:()=>ts,AppkitCheckbox:()=>ns,AppkitCollapsible:()=>rs,AppkitConnectButton:()=>os,AppkitDialog:()=>ss,AppkitDropdownMenu:()=>as,AppkitInput:()=>is,AppkitPopover:()=>ls,AppkitProgress:()=>cs,AppkitScrollArea:()=>us,AppkitSelect:()=>ps,AppkitSeparator:()=>ds,AppkitSkeleton:()=>ms,AppkitSwitch:()=>fs,AppkitTabs:()=>gs,AppkitToggleGroup:()=>hs,AppkitTooltip:()=>Cs,DEFAULT_EVM_CHAINS:()=>zn,LAMPORTS_PER_SOL:()=>J.LAMPORTS_PER_SOL,PassphraseCancelledError:()=>J.PassphraseCancelledError,PassphraseGate:()=>J.PassphraseGate,SolanaRpcError:()=>J.SolanaRpcError,TokenSelector:()=>lr,TxMonitorContext:()=>Xn,WALLET_ERROR_DESCRIPTIONS:()=>ar,WALLET_ERROR_TITLES:()=>sr,Web3ConnectProvider:()=>Er,Web3Context:()=>Mt,buildDelegationPolicyMessage:()=>Qn.buildDelegationPolicyMessage,clearClient:()=>gr,createClient:()=>Ot,formatSol:()=>J.formatSol,getChainById:()=>Sr,getClient:()=>Nt,getDefaultChains:()=>Dt,getLatestBlockhash:()=>J.getLatestBlockhash,getLocale:()=>No,getSignatureStatus:()=>J.getSignatureStatus,getSolanaBalance:()=>J.getSolanaBalance,getUserFriendlyError:()=>ht,isRetryableError:()=>fn,parseSol:()=>J.parseSol,resetSessionKeyManager:()=>Dr,setLocale:()=>Oo,t:()=>mn,useAccount:()=>H,useBalance:()=>vr,useCapabilities:()=>Lt,useChain:()=>ie,useCompareCosts:()=>Vn,useConnect:()=>br,useCreateSessionKey:()=>Or,useDelegate:()=>Tr,useDelegation:()=>rt,useDelegationPolicy:()=>Lr,useDisconnect:()=>Br,useERC20Allowance:()=>Vr,useERC20Approve:()=>$r,useERC20Transfer:()=>Gr,useERC20TransferSimulation:()=>Xr,useEmbeddedWallet:()=>Fr,useExecuteCalls:()=>$t,useExecuteRoute:()=>$n,useLastTx:()=>Jr,useLookupAddress:()=>to,useNotification:()=>ro,usePassphraseGate:()=>so,usePaymentFetch:()=>Ur,useResolveName:()=>io,useRevokeSession:()=>Nr,useRouteQuote:()=>Gn,useSIWxLogin:()=>on,useSIWxSession:()=>uo,useSendCalls:()=>qt,useSendTransaction:()=>lt,useSendUserOperation:()=>lo,useSendWithSession:()=>_r,useSession:()=>co,useSessionKeys:()=>jt,useSignInWithEthereum:()=>po,useSignInWithX:()=>dt,useSignMessage:()=>Qt,useSimulateTransfer:()=>go,useSiwxAuthSession:()=>ho,useSmartAccount:()=>yo,useSolanaAccount:()=>pn,useSolanaBalance:()=>wo,useSolanaRoles:()=>vo,useSolanaTransaction:()=>bo,useSwitchChain:()=>To,useTokenBalance:()=>Io,useTokenList:()=>It,useTokenSearch:()=>Ut,useTransactionSimulation:()=>Zt,useTxHistory:()=>Uo,useTxMonitor:()=>Yr,useUserOpStatus:()=>Po,useValidateDestination:()=>Mo,useViemClient:()=>le,useWallet:()=>Lo,useWeb3:()=>U,useWeb3ErrorHandler:()=>Bo,validateDestination:()=>or});module.exports=As(Gs);var J=require("@naculus/connect-core");var pr=require("@naculus/connect-appkit-core"),ue=require("react");function Vn(e,t){let{operation:r,chains:s,options:n}=e,[l,i]=(0,ue.useState)([]),[g,u]=(0,ue.useState)(!1),[c,h]=(0,ue.useState)(null),o=(0,ue.useRef)(!0),a=(0,ue.useRef)(0),p=(0,pr.compareCostsKey)(e),f=(0,ue.useCallback)(async()=>{if(!s||s.length===0){i([]);return}if(!t)return;let y=++a.current;u(!0),h(null);try{let C=await t(r,s,n);o.current&&y===a.current&&i(C)}catch(C){o.current&&y===a.current&&(h(C instanceof Error?C:new Error(String(C))),i([]))}finally{o.current&&y===a.current&&u(!1)}},[p,t]);(0,ue.useEffect)(()=>{f()},[f]),(0,ue.useEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]);let d=(0,ue.useCallback)(async()=>{await f()},[f]);return{comparisons:l,loading:g,error:c,refresh:d}}var Wt=require("@naculus/connect-appkit-core"),ge=require("react");function $n(e){let[t,r]=(0,ge.useState)(!1),[s,n]=(0,ge.useState)(null),[l,i]=(0,ge.useState)(null),g=(0,ge.useRef)(!0),u=(0,ge.useRef)(!1);(0,ge.useEffect)(()=>(g.current=!0,()=>{g.current=!1}),[]);let c=(0,ge.useCallback)(async(o,a,p)=>{if(!e)return i({code:"no_executor",message:"No executeRoute function provided"}),n(null),null;let f=(0,Wt.validateRouteRecipient)(o,a);if(f)return i(f),n(null),null;if(u.current)return i({code:"execution_in_progress",message:"A route execution is already in progress"}),null;u.current=!0,r(!0),i(null),n(null);try{let d=await e(o,a,p);return g.current&&n(d),d}catch(d){return g.current&&i((0,Wt.toExecuteRouteError)(d)),null}finally{u.current=!1,g.current&&r(!1)}},[e]),h=(0,ge.useCallback)(()=>{n(null),i(null),r(!1)},[]);return{execute:c,executing:t,result:s,error:l,reset:h}}var dr=require("@naculus/connect-appkit-core"),ae=require("react");function Gn(e,t){let{fromChain:r,toChain:s,fromToken:n,toToken:l,amount:i,options:g}=e,[u,c]=(0,ae.useState)([]),[h,o]=(0,ae.useState)(!1),[a,p]=(0,ae.useState)(null),f=(0,ae.useRef)(null),d=(0,ae.useRef)(!0),y=(0,ae.useCallback)(async()=>{if(!(0,dr.isQuotableInput)({fromChain:r,toChain:s,fromToken:n,amount:i})){c([]);return}if(t){o(!0),p(null);try{let E=await t(r,s,n,i,g,l);d.current&&c(E)}catch(E){d.current&&(p(E instanceof Error?E:new Error(String(E))),c([]))}finally{d.current&&o(!1)}}},[r,s,n,l,i,g,t]);(0,ae.useEffect)(()=>{if(f.current&&clearTimeout(f.current),!r||!s||!n||!i){c([]);return}return f.current=setTimeout(()=>{y()},300),()=>{f.current&&clearTimeout(f.current)}},[y,r,s,n,i]),(0,ae.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let C=(0,ae.useCallback)(async()=>{await y()},[y]),w=(0,ae.useCallback)(()=>{c([]),p(null),o(!1)},[]);return{quotes:u,loading:h,error:a,refresh:C,clear:w}}var X=require("@naculus/connect-core"),ee=require("@naculus/connector-evm-injected"),mr=require("@naculus/connect-core"),fr=require("@naculus/connector-walletconnect"),jn=null;function Ot(e){let t=null,r=(0,fr.createWalletConnectConnector)({projectId:e.projectId,metadata:e.metadata}),s=null,n=null,l=null,i=null,g=e.passphrasePrompt&&e.enableEmbedded&&!e.embeddedConfig?.encryptionPassphrase?new mr.PassphraseGate:null;e.enableEmbedded&&(n=import("@naculus/connector-embedded").then(o=>{let a={...e.embeddedConfig};g&&(a.encryptionPassphrase=g.request),e.enablePasskeys&&a.encryptionPassphrase&&!a.prfUnlock&&(a.prfUnlock={async derive(f){i&&await i;let d=l;return d?.hasCredential()?d.derivePrfKey(f):null}}),s=o.createPocketConnector(a),t?._setEmbeddedConnector(s)}).catch(o=>{X.logger.warn("react/client","Embedded wallet connector not available:",o),s=null})),e.enablePasskeys&&(i=import("@naculus/connector-passkeys").then(o=>{l=o.createPasskeysConnector(),t?._setPasskeysConnector(l)}).catch(o=>{X.logger.warn("react/client","Passkeys connector not available:",o),l=null}));let u=null,c=null;e.enableSolana&&(c=import("@naculus/connector-solana").then(o=>{let a=o.solanaConnector;e.solanaDefaultChain&&"configure"in a&&a.configure({defaultChain:e.solanaDefaultChain}),u=a,typeof window<"u"&&"startDiscovery"in a&&a.startDiscovery(),t?._setSolanaConnector(u)}).catch(o=>{X.logger.warn("react/client","Solana connector not available:",o),u=null})),typeof window<"u"&&ee.eip6963Connector.startDiscovery();let h={connector:r,get embeddedConnector(){return s},getEmbeddedConnector:async()=>(n&&await n,s),get passkeysConnector(){return l},passphraseGate:g,solanaRpcUrl:e.solanaRpcUrl??null,get solanaConnector(){return u},connect:()=>r.connect(),connectInjected:async o=>ee.eip6963Connector.connect(o),connectEmbedded:async()=>{if(n&&await n,!s)throw new Error("Embedded wallet not enabled. Set enableEmbedded: true in config.");return s.connect()},connectPasskeys:async()=>{if(i&&await i,!l)throw new Error("Passkeys connector not enabled. Set enablePasskeys: true in config.");return l.connect()},startPairing:()=>r.startPairing(),completePairing:()=>r.completePairing(),cancelPairing:()=>r.cancelPairing?.(),signMessage:async(o,a)=>{if(o.id?.startsWith("eip6963-"))return ee.eip6963Connector.signMessage(o,a);if(o.walletType==="passkeys"&&l)return l.signMessage(o,a);if(o.walletType==="embedded"){if(!s)throw new X.WalletError("wallet_unavailable","Embedded wallet connector not available.");return s.signMessage(o,a)}if(o.walletType==="solana"){if(c&&await c,u)return u.signMessage(o,a);throw new X.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return r.signMessage(o,a)},signTransaction:async(o,a)=>{if(o.id?.startsWith("eip6963-"))return ee.eip6963Connector.signTransaction(o,a);if(o.walletType==="embedded"){if(!s)throw new X.WalletError("wallet_unavailable","Embedded wallet connector not available.");return s.signTransaction(o,a)}if(o.walletType==="solana"){if(c&&await c,u)return u.signTransaction(o,a);throw new X.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return r.signTransaction(o,a)},sendTransaction:async(o,a)=>{if(o.id?.startsWith("eip6963-"))return ee.eip6963Connector.sendTransaction(o,a);if(o.walletType==="passkeys"&&l)return l.sendTransaction(o,a);if(o.walletType==="embedded"){if(!s)throw new X.WalletError("wallet_unavailable","Embedded wallet connector not available.");return s.sendTransaction(o,a)}if(o.walletType==="solana"){if(c&&await c,u)return u.sendTransaction(o,a);throw new X.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return r.sendTransaction(o,a)},onAccountsChanged:(o,a)=>{let p=()=>{};return o.id?.startsWith("eip6963-")?ee.eip6963Connector.onAccountsChanged?.(o,a)??p:o.walletType==="embedded"?s?.onAccountsChanged?.(o,a)??p:o.walletType==="passkeys"?p:o.walletType==="solana"?u?.onAccountsChanged?.(o,a)??p:r.onAccountsChanged?.(o,a)??p},onChainChanged:(o,a)=>{let p=()=>{};return o.id?.startsWith("eip6963-")?ee.eip6963Connector.onChainChanged?.(o,a)??p:o.walletType==="passkeys"||o.walletType==="embedded"?p:o.walletType==="solana"?u?.onChainChanged?.(o,a)??p:r.onChainChanged?.(o,a)??p},getCapabilities:o=>o.id?.startsWith("eip6963-")?ee.eip6963Connector.getCapabilities?.(o):o.walletType==="passkeys"?l?.getCapabilities?.(o):o.walletType==="solana"?u?.getCapabilities?.(o):o.walletType==="embedded"?s?.getCapabilities?.(o):r.getCapabilities?.(o),sendCalls:async(o,a,p,f)=>{if(o.id?.startsWith("eip6963-"))return ee.eip6963Connector.sendCalls(o,a,p,f);if(o.walletType==="passkeys"&&l)return l.sendCalls(o,a,p,f);if(o.walletType==="solana"){if(c&&await c,u)return u.sendCalls(o,a,p,f);throw new X.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}if(o.walletType==="embedded"){if(!s?.sendCalls)throw new X.WalletError("method_not_allowed","Embedded wallet does not support sendCalls");return s.sendCalls(o,a,p,f)}if(!r.sendCalls)throw new X.WalletError("method_not_allowed","sendCalls not supported by this connector");return r.sendCalls(o,a,p,f)},showCallsStatus:async(o,a)=>{if(o.id?.startsWith("eip6963-"))return ee.eip6963Connector.showCallsStatus(o,a);if(o.walletType==="passkeys"||o.walletType==="embedded")throw new X.WalletError("method_unsupported",`${o.walletType} wallets have no UI to display a call bundle.`);if(!r.showCallsStatus)throw new X.WalletError("method_unsupported","This connector cannot display call status.");return r.showCallsStatus(o,a)},getCallsStatus:async(o,a)=>{if(o.id?.startsWith("eip6963-")&&ee.eip6963Connector.getCallsStatus)return ee.eip6963Connector.getCallsStatus(o,a);if(o.walletType==="passkeys"&&l?.getCallsStatus)return l.getCallsStatus(o,a);if(o.walletType==="embedded")throw new X.WalletError("method_not_allowed","Embedded wallet does not support getCallsStatus");if(!r.getCallsStatus)throw new X.WalletError("method_not_allowed","getCallsStatus not supported by this connector");return r.getCallsStatus(o,a)},reconnect:async o=>o.walletType==="eip6963"?ee.eip6963Connector.reconnect(o):o.walletType==="embedded"?s?s.reconnect(o):o:o.walletType==="solana"?o:r.reconnect(o),disconnect:async o=>{if(o.id?.startsWith("eip6963-")||o.walletType==="eip6963")return ee.eip6963Connector.disconnect(o);if(o.walletType==="embedded"&&s)return s.disconnect();if(o.walletType==="passkeys"&&l)return l.disconnect(o);if(o.walletType==="solana"){if(c&&await c,u)return u.disconnect(o);throw new X.WalletError("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return r.disconnect(o)},getAllConnectors:()=>{let o=[r];return s&&o.push(s),l&&o.push(l),u&&o.push(u),o},_setEmbeddedConnector:o=>{s=o},_setPasskeysConnector:o=>{l=o},_setSolanaConnector:o=>{u=o}};return t=h,jn=h,h}function Nt(){return jn}function gr(){jn=null}var St=require("@naculus/connect-core"),kr=require("react");var Z=require("@naculus/connect-core"),yt=require("@naculus/connector-evm-injected"),O=require("react");var hr=require("@naculus/connect-core"),_t=require("@naculus/siwx");function Ye(e,t){let r=t.split(":",1)[0],n=(e.namespaces[r]?.accounts??[]).filter(l=>l.startsWith(`${r}:`)).map(l=>({namespace:r,caip10:l}))[0];if(n)return{...n,address:n.caip10.split(":").pop()??n.caip10}}function bs(e){return e.namespaces.eip155?.chains?.[0]??e.namespaces.solana?.chains?.[0]??e.namespaces.xrpl?.chains?.[0]??"eip155:1"}async function Cr(e){let{session:t,siwx:r,signMessage:s}=e;if(!r||!t)return{kind:"skipped"};try{let n=bs(t),l=Ye(t,n);if(!l)throw new Error("No account found in session");let{address:i}=l,g=await r.createMessage({address:i,chainId:n}),u=(0,_t.parseSiwxMessage)(g);if(!u?.nonce)throw new Error("SIWx message must contain a nonce");await(0,_t.issueNonce)(u.nonce);let c=await s(t,{message:g,address:i,chainId:n});return await r.handleSignComplete?.({message:g,signature:c}),{kind:"authenticated",address:i,chainId:n}}catch(n){let l=n instanceof Error?n:new Error("Wallet authentication failed");return hr.logger.error("appkit/core","SIWx authentication failed:",n),{kind:"failed",error:l,fatal:r.required!==!1}}}var _e=require("@naculus/connect-appkit-core");var yr=require("@naculus/connect-appkit-core"),we=require("@naculus/connect-core"),Rs=[{caip2:"eip155:5",name:"Goerli",rpcUrl:"https://goerli.blockpi.network/v1/rpc/public",explorerUrl:"https://goerli.etherscan.io",token:"ETH"},{caip2:"eip155:80001",name:"Mumbai",rpcUrl:"https://rpc-mumbai.maticvigil.com",explorerUrl:"https://mumbai.polygonscan.com",token:"MATIC"},{caip2:"eip155:421613",name:"Arbitrum Goerli",rpcUrl:"https://goerli-rollup.arbitrum.io/rpc",explorerUrl:"https://goerli.arbiscan.io",token:"ETH"},{caip2:"eip155:420",name:"Optimism Goerli",rpcUrl:"https://goerli.optimism.io",explorerUrl:"https://goerli-optimism.etherscan.io",token:"ETH"}];function Ts(e){let t=we.CHAINS[e];if(!t||!t.explorerUrl)return null;let r=t.caip2Id;return{caip2:r,name:t.name,rpcUrl:(0,we.getRpcUrl)(r,we.DEFAULT_RPC_URLS[r]??""),explorerUrl:t.explorerUrl,token:t.nativeCurrency.symbol}}function Is(){if(!we.CHAINS)return[];let e=[],t=Object.keys(we.CHAINS).map(Number).sort((r,s)=>r-s);for(let r of t){let s=Ts(r);s&&e.push(s)}for(let r of Rs){let s=(0,we.eip155Reference)(r.caip2);(s===null||!we.CHAINS[s])&&e.push(r)}return e}var zn=Is();function Sr(e,t){return(0,yr.resolveChain)(e,t)??void 0}function Dt(){return[...zn]}var wr=require("react/jsx-runtime"),Mt=(0,O.createContext)(null);function Er({children:e,config:t,autoConnect:r=!0}){let[s,n]=(0,O.useReducer)(_e.web3Reducer,_e.initialWeb3State),l=(0,O.useMemo)(()=>t.chains??Dt(),[t.chains]),i=t.connectionTimeout??3e4,g=t.maxRetries??2,u=(0,O.useMemo)(()=>new Z.LocalStorageSessionStorage(t.storageKey??"naculus_web3_session",t.encryptionKey),[t.storageKey,t.encryptionKey]),c=(0,O.useMemo)(()=>Ot({projectId:t.projectId,metadata:t.metadata,enableEmbedded:t.enableEmbedded,embeddedConfig:t.embeddedConfig,enablePasskeys:t.enablePasskeys,enableSolana:t.enableSolana,solanaDefaultChain:t.solanaDefaultChain}),[t.projectId,t.metadata,t.enableEmbedded,t.embeddedConfig,t.enablePasskeys,t.enableSolana,t.solanaDefaultChain]),h=(0,O.useRef)(null),o=(0,O.useRef)(null),a=(0,O.useMemo)(()=>{let m=(0,Z.createConnectorManager)();for(let _ of[yt.eip6963Connector,...c.getAllConnectors()])m.register(_.id,_);let S={},k={};for(let _ of l){let D=_.caip2;_.rpcUrl&&(S[D]=_.rpcUrl),_.token&&(k[D]={name:_.name,symbol:_.token,decimals:18})}let P=(0,Z.createSessionManager)(m,{autoRefreshFeeOnSwitch:t.autoRefreshFeeOnSwitch??!0,defaultRpcUrls:S,defaultCurrencies:k,encryptionKey:t.encryptionKey});return h.current=P,P},[c,l,t.autoRefreshFeeOnSwitch,t.encryptionKey]);(0,O.useEffect)(()=>{let m=D=>{let{walletSession:Me}=D.bundle;n({type:"SET_SESSION",payload:Me});let cr=[];Object.values(Me.namespaces).forEach(ys=>{cr.push(...ys.accounts)}),n({type:"SET_ACCOUNTS",payload:cr}),n({type:"SET_CHAIN",payload:D.bundle.activeChainId}),n({type:"SET_STATUS",payload:"connected"})},S=()=>{n({type:"RESET"})},k=D=>{n({type:"SET_CHAIN",payload:D.newChainId})},P=D=>m(D),_=()=>{u.clear(),n({type:"RESET"})};return a.on("sessionConnected",m),a.on("sessionDisconnected",S),a.on("chainChanged",k),a.on("sessionScopeChanged",P),a.on("sessionRevoked",_),()=>{a.off("sessionConnected",m),a.off("sessionDisconnected",S),a.off("chainChanged",k),a.off("sessionScopeChanged",P),a.off("sessionRevoked",_)}},[a,u]),(0,O.useEffect)(()=>{let m=()=>{u.clear(),n({type:"RESET"})};c.connector.onSessionExpiry(m)},[c,u]);let p=(0,O.useCallback)(()=>{for(let m of[yt.eip6963Connector,...c.getAllConnectors()])a.registerConnector(m)},[c,a]),f=(0,O.useCallback)(async m=>{p();let S=[yt.eip6963Connector,...c.getAllConnectors()].find(P=>P.id===m.walletType||P.kind===m.walletType);S&&!m.connectorId&&(m.connectorId=S.id);let k=m.namespaces.eip155?.chains?.[0]??m.namespaces.solana?.chains?.[0]??m.namespaces.xrpl?.chains?.[0];k&&await a.attach(m,k)},[c,a,p]),d=(0,O.useCallback)(m=>{if(n({type:"SET_SESSION",payload:m}),m){let S=[];Object.values(m.namespaces).forEach(D=>{S.push(...D.accounts)}),n({type:"SET_ACCOUNTS",payload:S});let k=m.namespaces.eip155?.chains?.[0],P=m.namespaces.solana?.chains?.[0],_=m.namespaces.xrpl?.chains?.[0];n({type:"SET_CHAIN",payload:k??P??_??null})}else n({type:"SET_ACCOUNTS",payload:[]}),n({type:"SET_CHAIN",payload:null})},[]);(0,O.useEffect)(()=>{let m=s.session,S=c;return!m||!S?.onAccountsChanged?void 0:S.onAccountsChanged(m,P=>{if(P.length===0){u.clear().finally(()=>n({type:"RESET"}));return}d(m),u.save(m)})},[s.session,c,u,d]),(0,O.useEffect)(()=>{let m=s.session,S=c;if(!(!m||!S?.onChainChanged))return S.onChainChanged(m,k=>{d(m),u.save(m);let P=a.syncExternalChain;if(!P)return;let _=P.call(a,k).catch(D=>{Z.logger.warn("react/provider","External chain sync error:",D)});o.current=_,_.finally(()=>{o.current===_&&(o.current=null)})})},[s.session,c,u,d,a]);let y=(0,O.useCallback)(async m=>{if(!t.siwx||!m)return!0;n({type:"SET_STATUS",payload:"authenticating"});let S=await Cr({session:m,siwx:t.siwx,signMessage:(k,P)=>c.signMessage(k,P)});return S.kind==="failed"&&S.fatal?(await u.clear(),n({type:"RESET"}),n({type:"SET_ERROR",payload:S.error}),!1):!0},[t.siwx,c,u]),C=(0,O.useCallback)(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let m=await(0,_e.withTimeout)(c.connect(),i,"Wallet connect");await u.save(m),d(m);try{await f(m)}catch(S){Z.logger.warn("react/provider","SessionManager sync error:",S)}if(!await y(m))return;n({type:"SET_STATUS",payload:"connected"})}catch(m){let S=m instanceof Error?m.message:"Connection failed";n({type:"SET_ERROR",payload:m instanceof Error?m:new Error(S)}),n({type:"SET_STATUS",payload:"disconnected"})}},[c,u,d,i,y,f]),w=(0,O.useCallback)(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let m=await c.connectEmbedded();if(await u.save(m),d(m),await f(m),!await y(m))return;n({type:"SET_STATUS",payload:"connected"})}catch(m){let S=m instanceof Error?m.message:"Embedded wallet connection failed";n({type:"SET_ERROR",payload:m instanceof Error?m:new Error(S)}),n({type:"SET_STATUS",payload:"disconnected"})}},[c,u,d,y,f]),E=(0,O.useCallback)(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let m=await c.connectPasskeys();if(await u.save(m),d(m),await f(m),!await y(m))return;n({type:"SET_STATUS",payload:"connected"})}catch(m){let S=m instanceof Error?m.message:"Passkeys connection failed";n({type:"SET_ERROR",payload:m instanceof Error?m:new Error(S)}),n({type:"SET_STATUS",payload:"disconnected"})}},[c,u,d,y,f]),R=(0,O.useCallback)(async()=>{if(!s.session){n({type:"RESET"});return}try{await c.disconnect(s.session)}catch(m){Z.logger.error("react/provider","Disconnect error:",m)}try{let m=h.current;m&&await m.disconnect()}catch(m){Z.logger.warn("react/provider","SessionManager disconnect error:",m)}await u.clear(),n({type:"RESET"})},[c,s.session,u]),A=(0,O.useCallback)(async m=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let S=await(0,_e.withTimeout)(c.connectInjected(m),i,"Injected wallet connect");await u.save(S),d(S);try{await f(S)}catch(k){Z.logger.warn("react/provider","SessionManager sync error:",k)}if(!await y(S))return;n({type:"SET_STATUS",payload:"connected"})}catch(S){let k=S instanceof Error?S.message:"Connection failed";n({type:"SET_ERROR",payload:S instanceof Error?S:new Error(k)}),n({type:"SET_STATUS",payload:"disconnected"})}},[c,u,d,i,y,f]),T=(0,O.useCallback)(async()=>c.startPairing(),[c]),v=(0,O.useCallback)(()=>{c.cancelPairing?.()},[c]),x=(0,O.useCallback)(async()=>{let m=await c.completePairing();return await u.save(m),d(m),await f(m),await y(m)&&n({type:"SET_STATUS",payload:"connected"}),m},[c,u,d,y,f]),b=(0,O.useCallback)(async m=>{let S=t.siwx;if(!S||S.required===!1)return!0;try{if(await S.hasValidSession?.())return!0}catch(k){Z.logger.warn("react/provider","siwx.hasValidSession failed",k)}return y(m)},[t.siwx,y]),I=(0,O.useCallback)(async()=>{let m=await u.load();if(!m){n({type:"SET_STATUS",payload:"disconnected"});return}n({type:"SET_STATUS",payload:"reconnecting"});try{let S=await(0,_e.withRetry)(()=>c.reconnect(m),{maxRetries:g,baseDelay:1e3,label:"reconnect"});d(S);try{let k=h.current;k&&(p(),await k.restoreFromPersistence())}catch(k){Z.logger.warn("react/provider","SessionManager restore error:",k)}if(!await b(S))return;n({type:"SET_STATUS",payload:"connected"})}catch(S){Z.logger.error("react/provider","Reconnect error:",S),await u.clear(),n({type:"SET_STATUS",payload:"disconnected"}),n({type:"SET_SESSION",payload:null})}},[c,u,d,g,p,b]),W=(0,O.useCallback)(async m=>{o.current&&await o.current;let S=h.current;if(S?.getActiveBundle()){await S.switchChain(m),d(s.session);return}if(!s.session)throw new Error("No active session");try{s.session.walletType==="eip6963"||s.session.id?.startsWith("eip6963-")?await yt.eip6963Connector.switchChain(s.session,m):s.session.walletType==="embedded"&&c.embeddedConnector?await c.embeddedConnector.switchChain?.(s.session,m):s.session.walletType==="passkeys"&&c.passkeysConnector?await c.passkeysConnector.switchChain?.(s.session,m):s.session.walletType==="solana"&&c.solanaConnector?await c.solanaConnector.switchChain?.(s.session,m):await c.connector.switchChain(s.session,m),d(s.session)}catch(k){throw new Z.WalletError("chain_unsupported","Failed to switch chain",k)}},[c,s.session,d]);(0,O.useEffect)(()=>{r&&I()},[r,I]);let F=(0,O.useCallback)(()=>{n({type:"SET_ERROR",payload:null})},[]),q=(0,O.useMemo)(()=>({...s,connect:C,connectEmbedded:w,connectPasskeys:E,disconnect:R,reconnect:I,switchChain:W,startPairing:T,completePairing:x,cancelPairing:v,connectInjected:A,clearError:F,isConnected:s.status==="connected",chains:l,client:c,sessionManager:a}),[s,C,w,E,R,I,W,T,x,A,F,l,c,a]);return(0,wr.jsx)(Mt.Provider,{value:q,children:e})}function U(){let e=(0,O.useContext)(Mt);if(!e)throw new Error("useWeb3 must be used within a Web3ConnectProvider");return e}function H(){let{accounts:e,isConnected:t}=U(),r=(0,kr.useMemo)(()=>!t||e.length===0?null:e.map(n=>{let l=(0,St.parseCaip10)(n);return l?{address:n,namespace:l.namespace,isEVM:l.namespace==="eip155"&&(0,St.isEvmAddress)(l.address)}:{address:n,namespace:null,isEVM:(0,St.isEvmAddress)(n)}}),[e,t]),s=r?.find(n=>n.isEVM)?.address??null;return{accounts:r,evmAccount:s,primaryAccount:e[0]??null,isConnected:t,count:e.length}}var Je=require("@naculus/connect-appkit-core"),j=require("react");var Ze=require("viem"),xr=require("@naculus/connect-core");function vr(e){let{evmAccount:t,isConnected:r}=H(),{chainId:s,chains:n}=U(),[l,i]=(0,j.useState)(null),[g,u]=(0,j.useState)(!1),[c,h]=(0,j.useState)(null),[o,a]=(0,j.useState)(null),p=e?.refreshInterval,f=(0,j.useRef)(null),d=(0,j.useMemo)(()=>(0,Je.resolveChain)(n,s),[s,n]),y=d?(0,Je.chainNumber)(d):null,C=(0,j.useMemo)(()=>d?(0,Je.toViemChain)(d,y):null,[d,y]),w=(0,j.useMemo)(()=>d?.token??null,[d]),[E,R]=(0,j.useState)(null);(0,j.useEffect)(()=>{if(!C||!d?.rpcUrl){R(null);return}let x=(0,Ze.createPublicClient)({transport:(0,Ze.http)(d.rpcUrl),chain:C});return R(x),()=>{}},[d]);let A=(0,j.useCallback)(async()=>{if(!t||!E){i(null);return}u(!0),h(null);try{let b=t.includes(":")?t.split(":").pop():t,[I,W]=await Promise.all([E.getBalance({address:b}),s?(0,xr.getNativeTokenPriceUsd)(s,d?.rpcUrl).catch(()=>null):Promise.resolve(null)]);i(I.toString()),a(W)}catch(x){h(x instanceof Error?x:new Error("Failed to fetch balance")),i(null),a(null)}finally{u(!1)}},[t,E,s,d?.rpcUrl]);(0,j.useEffect)(()=>{r&&t&&A()},[r,t,A]),(0,j.useEffect)(()=>(p&&p>0&&r&&t&&(f.current=setInterval(A,p)),()=>{f.current&&(clearInterval(f.current),f.current=null)}),[p,r,t,A]);let T=(0,j.useMemo)(()=>{if(l===null)return null;try{return(0,Ze.formatEther)(BigInt(l))}catch{return null}},[l]),v=(0,j.useMemo)(()=>{if(o===null||T===null)return null;let x=parseFloat(T);if(isNaN(x))return null;let b=x*o;return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(b)},[o,T]);return{balance:l,formatted:T,symbol:w,usdPrice:o,usdValue:v,isLoading:g,error:c,refetch:A,chain:d}}var et=require("@naculus/connect-appkit-core"),be=require("react");function N(e){return e??Nt()}function Lt(){let{client:e,session:t,chainId:r}=U(),[s,n]=(0,be.useState)(null),[l,i]=(0,be.useState)(!1),[g,u]=(0,be.useState)(null),c=(0,be.useRef)(0),h=(0,be.useCallback)(async()=>{let o=++c.current,a=N(e);if(!a?.getCapabilities||!t){n(null),i(!1),u(null);return}i(!0),u(null);try{let p=await a.getCapabilities(t);if(o!==c.current)return;n((0,et.normalizeCapabilities)(p))}catch(p){if(o!==c.current)return;n(null),u(p instanceof Error?p:new Error("Capability query failed"))}finally{o===c.current&&i(!1)}},[e,t]);return(0,be.useEffect)(()=>{h()},[h]),{capabilities:s,current:(0,et.selectChainCapabilities)(s,r),atomic:(0,et.atomicSupportFor)(s,r),isFetching:l,error:g,refetch:h}}var Bt=require("react"),tt=require("@naculus/connect-appkit-core");function ie(){let{chainId:e,session:t,switchChain:r,chains:s}=U(),n=(0,Bt.useMemo)(()=>(0,tt.resolveChain)(s,e),[s,e]),l=(0,Bt.useMemo)(()=>t?(0,tt.describeChain)(s,e):null,[s,e,t]),i=(0,Bt.useMemo)(()=>(0,tt.chainsForNamespace)(s,e),[s,e]);return{chainId:e,currentChain:n,chainInfo:l,availableChains:i,chains:i,isEvm:e?.startsWith("eip155:")??!1,switchChain:r}}var Et=require("react");var Ar=require("@naculus/connect-core");function br(){let{connect:e,status:t}=U(),[r,s]=(0,Et.useState)(!1),[n,l]=(0,Et.useState)(null);return{connect:(0,Et.useCallback)(async()=>{s(!0),l(null);try{await e()}catch(g){let u=g instanceof Error?g.message:"Connection failed";l(g instanceof Ar.WalletError?g:new Error(u))}finally{s(!1)}},[e]),isConnecting:r||t==="connecting",error:n}}var Rr=require("@naculus/connect-appkit-core"),De=require("@naculus/connect-core"),te=require("react");var Ht=require("@naculus/connect-appkit-core"),Ft=require("react"),Ke=require("viem");function le(){let{evmAccount:e,isConnected:t}=H(),{currentChain:r,chains:s}=ie(),n=r?(0,Ht.chainNumber)(r):null,l=(0,Ft.useMemo)(()=>r?(0,Ht.toViemChain)(r,n):null,[r,n]),i=(0,Ft.useMemo)(()=>l?(0,Ke.createPublicClient)({transport:(0,Ke.http)(l.rpcUrls.default.http[0]),chain:l}):null,[r,l]),g=(0,Ft.useMemo)(()=>{if(!t||!e||!l)return null;let u=e.includes(":")?e.split(":").pop():e;return(0,Ke.createWalletClient)({transport:(0,Ke.http)(l.rpcUrls.default.http[0]),chain:l,account:u})},[t,e,r,l]);return{publicClient:i,walletClient:g,chains:s}}function Tr(e){let{evmAccount:t}=H(),{session:r,chainId:s,client:n}=U(),{publicClient:l}=le(),[i,g]=(0,te.useState)(null),[u,c]=(0,te.useState)(!1),[h,o]=(0,te.useState)(null),a=(0,te.useRef)(0),p=(0,te.useRef)(!1);(0,te.useEffect)(()=>()=>{a.current+=1},[]),(0,te.useEffect)(()=>{a.current+=1,g(null),c(!1),o(null)},[r,s,t]);let f=(0,te.useCallback)(async(w,E)=>{let R=x=>(o(x),null);if(p.current)return R(new Error("A delegation is already in progress"));let A=(0,Rr.bareEvmAddress)(t);if(!r||!A||!s)return R(new De.WalletError("wallet_unavailable","No connected EVM account"));if(!l||l.chain?.id!==(0,De.eip155Reference)(s))return R(new De.WalletError("chain_mismatch",`No RPC client for ${s}; refusing to read the nonce elsewhere.`));let T=r.walletType==="embedded"?N(n)?.embeddedConnector??{}:{},v=++a.current;p.current=!0,c(!0),o(null),g(null);try{let x=await(0,De.delegateAccount)({connector:T,session:r,account:A,chainId:s,delegate:w,allowlist:E,getTransactionCount:(b,I)=>l.getTransactionCount({address:b,blockTag:I})});return v!==a.current?null:(g(x),x)}catch(x){return v!==a.current?null:R(x instanceof Error?x:new Error("Failed to send delegation"))}finally{p.current=!1,v===a.current&&c(!1)}},[s,n,t,l,r]),d=(0,te.useCallback)(w=>f(w,e.allowlist),[f,e.allowlist]),y=(0,te.useCallback)(()=>f(De.REVOKE_DELEGATE,[]),[f]),C=(0,te.useCallback)(()=>{a.current+=1,g(null),c(!1),o(null)},[]);return{delegate:d,revoke:y,result:i,isPending:u,error:h,reset:C}}var Ir=require("@naculus/connect-appkit-core"),pe=require("react");function Ur(e){let[t,r]=(0,pe.useState)(0),[s,n]=(0,pe.useState)(null),[l,i]=(0,pe.useState)(null),g=(0,pe.useRef)(0),u=(0,pe.useRef)(0),c=(0,pe.useRef)(e);c.current=e,(0,pe.useEffect)(()=>()=>{g.current+=1,u.current+=1},[]);let h=(0,pe.useCallback)(async(a,p)=>{let f=++g.current,d=u.current;r(y=>y+1),i(null);try{let y=await c.current(a,p),C=(0,Ir.describePayment)(a,y);return C&&d===u.current&&n(C),y}catch(y){let C=y instanceof Error?y:new Error("Paid request failed");throw f===g.current&&i(C),C}finally{r(y=>y-1)}},[]),o=(0,pe.useCallback)(()=>{g.current+=1,u.current+=1,n(null),i(null)},[]);return{payFetch:h,isPending:t>0,lastPayment:s,error:l,reset:o}}var nt=require("@naculus/connect-core"),Re=require("react");function rt(){let{publicClient:e}=le(),{evmAccount:t}=H(),[r,s]=(0,Re.useState)(nt.UNKNOWN_DELEGATION),[n,l]=(0,Re.useState)(!1),[i,g]=(0,Re.useState)(null),u=(0,Re.useRef)(0),c=t?.includes(":")?t.split(":").pop():t,h=(0,Re.useCallback)(async()=>{let o=++u.current;if(!e||!c){s(nt.UNKNOWN_DELEGATION),l(!1),g(null);return}l(!0),g(null);try{let a=await e.getCode({address:c});if(o!==u.current)return;s((0,nt.readDelegation)(a??"0x"))}catch(a){if(o!==u.current)return;s(nt.UNKNOWN_DELEGATION),g(a instanceof Error?a:new Error("Code read failed"))}finally{o===u.current&&l(!1)}},[e,c]);return(0,Re.useEffect)(()=>{h()},[h]),{...r,isFetching:n,error:i,refetch:h}}var st=require("@naculus/connect-appkit-core"),ne=require("react"),Mr=require("viem");var Vt=require("@naculus/connect-core");var qe=require("react");var de=require("@naculus/connect-core"),ke=require("react");var Pr=require("@naculus/connect-core");function Kt(e){let t=typeof e=="string"?e:e&&typeof e=="object"&&"hash"in e?e.hash:void 0;if(typeof t=="string"&&/^0x[0-9a-fA-F]{64}$/.test(t))return t;throw new Pr.WalletError("tx_failed","Wallet did not return a valid 32-byte transaction hash")}function qt(){let{session:e,chainId:t,client:r}=U(),[s,n]=(0,ke.useState)("idle"),[l,i]=(0,ke.useState)(null),[g,u]=(0,ke.useState)(null),[c,h]=(0,ke.useState)(null),[o,a]=(0,ke.useState)(null),p=(0,ke.useCallback)(async(C,w)=>{if(!e){n("failed");let E=new de.WalletError("wallet_unavailable","No active session");throw i(E),E}if(C.length===0){n("failed");let E=new de.WalletError("invalid_input","At least one call is required");throw i(E),E}n("awaiting_approval"),i(null),u(null);try{let E=N(r);if(!E)throw new de.WalletError("wallet_unavailable","Client not initialized");let R=w?.chainId??t??void 0,A=w?.strategy??(0,de.chooseExecutionStrategy)(await(0,de.getAccountCapabilities)(E,e,R),C.length);if(a(A),A==="atomic-batch"){let v=await E.sendCalls(e,C,R,{atomicRequired:!0,...w?.paymasterService?{paymasterService:w.paymasterService}:{}});return n("submitted"),u(v),v}let T="";for(let v=0;v<C.length;v++){let x=C[v];try{T=Kt(await E.sendTransaction(e,{transaction:{to:x.to,data:x.data,value:x.value},chainId:R}))}catch(b){throw new de.WalletError("tx_failed",`Call ${v+1} of ${C.length} failed after ${v} already landed (sent sequentially \u2014 this wallet cannot batch atomically): ${b instanceof Error?b.message:String(b)}`)}}return n("submitted"),u(T),T}catch(E){n("failed");let R=E instanceof Error?E.message:"sendCalls failed";throw i(E instanceof Error?E:new Error(R)),E}},[e,t,r]),f=(0,ke.useCallback)(async C=>{if(!e)throw new de.WalletError("wallet_unavailable","No active session");let w=C??g;if(!w)throw new de.WalletError("invalid_input","No bundle hash available");if(!C&&o==="sequential")throw new de.WalletError("invalid_input","Calls were sent sequentially, so there is no bundle to query. Track the returned transaction hash instead.");let E=N(r);if(!E)throw new de.WalletError("wallet_unavailable","Client not initialized");let R=await E.getCallsStatus(e,w);return h(R),R},[e,g,r,o]),d=(0,ke.useCallback)(async C=>{if(!e)return!1;let w=C??g;if(!w||!C&&o==="sequential")return!1;let E=N(r);if(!E?.showCallsStatus)return!1;try{return await E.showCallsStatus(e,w),!0}catch{return!1}},[e,g,r,o]),y=(0,ke.useCallback)(()=>{n("idle"),i(null),u(null),h(null),a(null)},[]);return{sendCalls:p,getCallsStatus:f,showCallsStatus:d,status:s,error:l,batchHash:g,callsStatus:c,execution:o,reset:y,isSending:s==="awaiting_approval"}}function $t(e={}){let{current:t,atomic:r}=Lt(),{delegated:s,delegate:n}=rt(),{sendCalls:l}=qt(),[i,g]=(0,qe.useState)(!1),[u,c]=(0,qe.useState)(null),[h,o]=(0,qe.useState)(null),a=e.atomicity??"preferred",p=e.sponsorship??"any",f=e.paymasterService,d=e.userOperation,y=e.userOperationSponsored??!1,C=!!(t?.raw?.paymasterService?.supported&&f),w=(0,qe.useCallback)((R,A=a)=>{let T=(0,Vt.planExecution)({atomicBatch:r==="supported",discovered:r!=="unknown",sponsoredTransactions:!1,...t?.maxBatchSize===void 0?{}:{maxBatchSize:t.maxBatchSize}},R,{atomicity:A,sponsorship:p}),v=p==="required"&&!y;if(T.strategy==="atomic-batch"&&!v)return{...T,reason:T.reason+(C?" A paymaster service will be requested, but the wallet's final fee payer must be checked after execution.":""),route:"wallet-batch"};let x=s&&r!=="supported"?` This account does delegate to ${n} under EIP-7702, so it is capable of batching even though the wallet has not offered to.`:"",b=A!=="any"&&!T.atomic||p==="required";return d&&b&&!v?{strategy:"atomic-batch",atomic:!0,sponsored:y,reason:p==="required"&&!T.sponsored?"The wallet batch is not configured for sponsored gas, so the calls are executed through the configured sponsored UserOperation route.":"This wallet cannot batch, so the calls are executed as a single UserOperation through the smart account, which lands as one transaction.",route:"user-operation"}:v?{strategy:"refuse",atomic:T.atomic,sponsored:!1,reason:"Sponsored gas was required, but there is no executable sponsored route: no paymaster is configured for a wallet batch, and capability advertising alone cannot pay for a sequential transaction.",route:null}:T.strategy==="refuse"?{...T,reason:T.reason+x,route:null}:{...T,reason:T.reason+x,route:"sequential"}},[r,t,f,C,d,y,a,p,s,n]),E=(0,qe.useCallback)(async(R,A=a)=>{g(!0),c(null);try{let T=w(R.length,A);if(T.route===null)throw new Vt.WalletError("method_not_allowed",T.reason);return o(T.route),T.route==="user-operation"?await d(R):await l(R,{strategy:T.route==="wallet-batch"?"atomic-batch":"sequential",...T.route==="wallet-batch"&&C?{paymasterService:f}:{}})}catch(T){let v=T instanceof Error?T:new Error("Execution failed");throw c(v),v}finally{g(!1)}},[w,l,d,a,f,C]);return{preview:w,execute:E,isExecuting:i,error:u,lastRoute:h,reset:()=>{c(null),o(null)}}}var Gt=require("@naculus/connect-appkit-core"),Wr=require("@naculus/connect-core"),K=require("react");function ot(e){return(0,Gt.getSharedSessionKeyManager)(e)}function jt(e){let{session:t}=U(),[r,s]=(0,K.useState)([]),[n,l]=(0,K.useState)(!1),[i,g]=(0,K.useState)(null),u=(0,K.useRef)(!0),c=(0,K.useCallback)(()=>g(null),[]),h=ot(e),o=h.isStorageAvailable(),a=(0,K.useCallback)(async()=>{if(!t){s([]);return}l(!0),g(null);try{let f=await h.listSessions();u.current&&s(f)}catch(f){u.current&&g(f instanceof Error?f:new Error("Failed to load session keys"))}finally{u.current&&l(!1)}},[t,h]);(0,K.useEffect)(()=>(u.current=!0,a(),()=>{u.current=!1}),[a]);let p=r.filter(f=>f.status==="active");return{sessions:r,activeSessions:p,loading:n,error:i,refresh:a,clearError:c,storageAvailable:o}}function Or(e){let{session:t}=U(),[r,s]=(0,K.useState)(null),[n,l]=(0,K.useState)(!1),[i,g]=(0,K.useState)(null),u=(0,K.useCallback)(()=>g(null),[]),c=ot(e);return{createSessionKey:(0,K.useCallback)(async(o,a)=>{if(!t)throw new Wr.WalletError("wallet_unavailable","No active wallet session");l(!0),g(null);try{let p=a??void 0,f=await c.createSessionKey(o,p);return s(f),f}catch(p){let f=p instanceof Error?p:new Error("Failed to create session key");throw g(f),f}finally{l(!1)}},[t,c]),lastCreated:r,isCreating:n,error:i,clearError:u}}function Nr(e){let[t,r]=(0,K.useState)(!1),[s,n]=(0,K.useState)(null),l=(0,K.useCallback)(()=>n(null),[]),i=ot(e);return{revokeSession:(0,K.useCallback)(async u=>{r(!0),n(null);try{await i.revokeSession(u)}catch(c){let h=c instanceof Error?c:new Error("Failed to revoke session key");throw n(h),h}finally{r(!1)}},[i]),isRevoking:t,error:s,clearError:l}}function _r(e){let[t,r]=(0,K.useState)(!1),[s,n]=(0,K.useState)(null),l=(0,K.useCallback)(()=>n(null),[]),i=ot(e),g=(0,K.useCallback)(async(c,h,o)=>{r(!0),n(null);try{return await i.signWithSessionKey(c,h,o)}catch(a){let p=a instanceof Error?a:new Error("Failed to sign with session key");throw n(p),p}finally{r(!1)}},[i]),u=(0,K.useCallback)(async(c,h)=>{r(!0),n(null);try{return await i.checkSessionScope(c,h)}catch(o){let a=o instanceof Error?o:new Error("Failed to check session scope");throw n(a),a}finally{r(!1)}},[i]);return{signWithSession:g,checkScope:u,isBusy:t,error:s,clearError:l}}function Dr(){(0,Gt.resetSharedSessionKeyManager)()}var wt=require("react");var zt=require("@naculus/connect-core");function Qt(){let{session:e,chainId:t,client:r}=U(),[s,n]=(0,wt.useState)(!1),[l,i]=(0,wt.useState)(null);return{signMessage:(0,wt.useCallback)(async u=>{if(!e){let h=new zt.WalletError("wallet_unavailable","No active session");throw i(h),h}let c=e.namespaces.eip155?.accounts[0]??Object.values(e.namespaces)[0]?.accounts[0];if(!c){let h=new zt.WalletError("wallet_unavailable","No account found");throw i(h),h}n(!0),i(null);try{let h=N(r);if(!h)throw new zt.WalletError("wallet_unavailable","Client not initialized");return await h.signMessage(e,{message:u,address:c,chainId:t??void 0})}catch(h){let o=h instanceof Error?h.message:"Signing failed",a=h instanceof Error?h:new Error(o);throw i(a),a}finally{n(!1)}},[e,t,r]),isSigning:s,error:l}}var Qn=require("@naculus/connect-appkit-core");function Lr(e={}){let{evmAccount:t}=H(),r=(0,st.bareEvmAddress)(t),s=rt(),n=$t(e.execution),{signMessage:l}=Qt(),i=jt(e.managerConfig),g=ot(e.managerConfig),[u,c]=(0,ne.useState)(!1),[h,o]=(0,ne.useState)(null),[a,p]=(0,ne.useState)(()=>new Set),[f,d]=(0,ne.useState)(!1),y=e.origin??(typeof window<"u"?window.location.origin:"unknown"),C=!!e.managerConfig?.encryptionKey,w=e.execution?.sponsorship,{refresh:E,storageAvailable:R}=i,{preview:A}=n,{delegated:T,delegate:v}=s,x=(0,ne.useMemo)(()=>(0,st.createDelegationPolicyFlow)({manager:g,origin:y,signer:()=>r,signMessage:l,verifySignature:async({message:S,signature:k,signerAddress:P})=>(await(0,Mr.recoverMessageAddress)({message:S,signature:k})).toLowerCase()===P.toLowerCase(),previewExecution:A,sponsorship:w,adapter:e.adapter,signTypedData:e.signTypedData,chainId:()=>e.chainId??null,delegation:()=>({delegated:T,delegate:v}),encryptionKeyConfigured:C,storageAvailable:()=>R,refresh:E}),[g,y,r,l,A,w,e.adapter,e.signTypedData,e.chainId,T,v,C,R,E]);(0,ne.useEffect)(()=>{let S=!1,k=i.sessions.filter(st.isVerifiablePolicy);return k.length===0?(p(new Set),d(!1),()=>{S=!0}):(d(!0),Promise.all(k.map(async P=>[P.id,await x.verifyStoredPolicy(P)])).then(P=>{S||p(new Set(P.filter(([,_])=>_).map(([_])=>_)))}).catch(P=>{S||(p(new Set),o(P instanceof Error?P:new Error("Policy verification failed")))}).finally(()=>{S||d(!1)}),()=>{S=!0})},[i.sessions,x]);let b=(0,ne.useCallback)(()=>{o(null),i.clearError()},[i]),I=(0,ne.useCallback)(async(S,k)=>{c(!0),o(null);try{return await S()}catch(P){let _=P instanceof Error?P:new Error(k);throw o(_),_}finally{c(!1)}},[]),W=(0,ne.useCallback)(S=>I(()=>x.createPolicy(S),"Policy creation failed"),[x,I]),F=(0,ne.useCallback)(S=>I(()=>x.revokePolicy(S),"Policy revocation failed"),[x,I]),q=(0,ne.useCallback)((S,k)=>I(()=>x.executePolicy(S,k),"Policy execution failed"),[x,I]),m=i.activeSessions.filter(S=>a.has(S.id));return{policies:i.sessions,activePolicies:m,storageAvailable:i.storageAvailable,loading:i.loading||f,isBusy:u,error:h??i.error,delegation:s,createPolicy:W,revokePolicy:F,previewPolicyExecution:x.previewPolicyExecution,signPolicyDigest:x.signPolicyDigest,executePolicy:q,refresh:i.refresh,clearError:b}}var Ve=require("react");function Br(){let{disconnect:e,status:t}=U(),[r,s]=(0,Ve.useState)(!1),[n,l]=(0,Ve.useState)(null),i=(0,Ve.useRef)(!0);return{disconnect:(0,Ve.useCallback)(async()=>{if(t!=="disconnected"){s(!0),l(null);try{await e()}catch(u){if(!i.current)return;l(u instanceof Error?u:new Error("Disconnect failed"))}finally{i.current&&s(!1)}}},[e,t]),isDisconnecting:r,error:n,cleanup:()=>{i.current=!1}}}var Xt=require("@naculus/connect-core"),$=require("react");function Be(e){let t=e.activeNamespace??"eip155",r=Array.isArray(e.accounts)?e.accounts.map(({namespace:s,address:n,derivationPath:l})=>({namespace:s,address:n,...l?{derivationPath:l}:{}})):e.address?[{namespace:t,address:e.address}]:[];return{accounts:r,activeNamespace:t,createdAt:e.createdAt??0,...e.chainId?{chainId:e.chainId}:{},...e.version?{version:e.version}:{},recoveryAvailable:!!e.mnemonic,address:r.find(s=>s.namespace===t)?.address??e.address}}function Fr(){let{connectEmbedded:e,client:t}=U(),[r,s]=(0,$.useState)(null),n=(0,$.useRef)(null),l=(0,$.useRef)(4),i=(0,$.useRef)(!1),g=(0,$.useRef)(null),[u,c]=(0,$.useState)(!1),[h,o]=(0,$.useState)(!1),[a,p]=(0,$.useState)(null),f=()=>p(null),d=(0,$.useCallback)(()=>{let m=n.current;return n.current=null,m},[]),y=(0,$.useCallback)(()=>{let m=N(t);if(!m?.embeddedConnector)throw new Xt.WalletError("wallet_unavailable","Embedded wallet not enabled.");return m.embeddedConnector},[t]),C=(0,$.useCallback)(()=>{try{return y().getWallet()?.privateKey??null}catch{return null}},[y]),w=(0,$.useCallback)(async()=>{let m=N(t);if(!m)throw new Xt.WalletError("wallet_unavailable","Embedded wallet not enabled.");let S=m.getEmbeddedConnector?await m.getEmbeddedConnector():m.embeddedConnector;if(!S)throw new Xt.WalletError("wallet_unavailable","Embedded wallet not enabled.");return S},[t]),E=(0,$.useCallback)(()=>{try{return N(t)?.passphraseGate??null}catch{return null}},[t]),R=(0,$.useCallback)(m=>{m?.code==="decryption_failed"&&E()?.forget("That passphrase did not open the wallet.")},[E]),A=(0,$.useCallback)(async()=>{i.current=!1,p(null);try{let m=await w();if(!await m.load())return!1;let k=m.getWallet();return k?(n.current=null,c(!1),s(Be(k)),!0):!1}catch(m){return i.current=!0,R(m),p(m instanceof Error?m:new Error("Failed to restore embedded wallet")),!1}},[R,w]);(0,$.useEffect)(()=>{let m=!1,S=null;return A().then(k=>{m||k||i.current||(S=setTimeout(()=>{m||A()},100))}),()=>{m=!0,S&&clearTimeout(S)}},[A]);let T=async()=>{o(!0),p(null);try{let m=await w(),S=await m.load(),k=m.getWallet();S&&k&&(s(Be(k)),n.current=k.mnemonic||null,c(!k.mnemonic)),await e();let P=m.getWallet();P&&(s(Be(P)),P.mnemonic&&!S&&(n.current=P.mnemonic,c(!0)))}catch(m){R(m),p(m instanceof Error?m:new Error("Embedded wallet connection failed"))}finally{o(!1)}},v=async()=>{o(!0),p(null);try{let m=await w();E()?.expect("create");let S=await m.generateWallet();return s(Be(S)),n.current=S.mnemonic,c(!0),S}catch(m){return p(m instanceof Error?m:new Error("Failed to generate wallet")),null}finally{o(!1)}},x=async m=>{o(!0),p(null);try{let S=await w();E()?.expect("create");let k=await S.importFromMnemonic(m);return s(Be(k)),n.current=null,c(!1),k}catch(S){return p(S instanceof Error?S:new Error("Failed to import wallet")),null}finally{o(!1)}},b=async m=>{o(!0),p(null);try{let S=await w();E()?.expect("create");let k=await S.importFromPrivateKey(m);return s(Be(k)),n.current=null,c(!1),k}catch(S){return p(S instanceof Error?S:new Error("Failed to import wallet")),null}finally{o(!1)}},I=async()=>{o(!0),p(null);try{await(await w()).wipe(),s(null),n.current=null,c(!1)}catch(m){p(m instanceof Error?m:new Error("Failed to wipe wallet"))}finally{o(!1)}},W=(0,$.useCallback)(m=>{let S=y();S.setActiveNamespace(m);let k=S.getWallet();s(k?Be(k):null)},[y]),F=(0,$.useCallback)(async()=>{let m=await w(),S=await m.backfillAccounts();if(S.length>0){let k=m.getWallet();s(k?Be(k):null)}return S.map(({namespace:k,address:P,derivationPath:_})=>({namespace:k,address:P,..._?{derivationPath:_}:{}}))},[w]),q=()=>{n.current=null,c(!1)};return{connectEmbedded:T,restoreWallet:A,generateWallet:v,importFromMnemonic:x,importFromPrivateKey:b,wipe:I,wallet:r,hasWallet:r!==null,address:r?.address??null,accounts:r?.accounts??[],activeNamespace:r?.activeNamespace??null,setActiveNamespace:W,backfillAccounts:F,seedPhrase:n.current,getSeedPhrase:d,getPrivateKey:C,backupPending:u,confirmBackup:q,isBusy:h,error:a,clearError:f,storageSecurityLevel:(()=>{try{let m=y(),S=m.getStorageSecurityLevel?.()??4;return m.getWallet()?(l.current=S,S):r?l.current:S}catch{return r?l.current:4}})(),securityReport:(()=>{let m=null;try{m=y().getStorageSecurityReport?.()??null}catch{m=null}if(!m)return g.current=null,null;let S=JSON.stringify(m);return g.current?.json===S?g.current.value:(g.current={json:S,value:m},m)})()}}var qr=require("@naculus/connect-appkit-core"),Ce=require("react");var Hr=require("@naculus/connect-core"),he=require("react"),Kr=require("@naculus/connect-appkit-core");function Us(e){return[e.token.address.toLowerCase(),e.token.chainId??"",e.token.decimals??"",e.chainId??"",e.owner??"",e.spender??"",e.connected?"1":"0",e.publicClient?"1":"0",e.walletClient?"1":"0",e.session?.id??""].join("|")}function at(e){let{token:t,chainId:r}=e,s=t.address.toLowerCase(),n=Us(e),l=(0,he.useMemo)(()=>({key:n}),[n]),i=(0,he.useRef)(n),g=(0,he.useRef)(!0);(0,he.useLayoutEffect)(()=>{i.current=n},[n]),(0,he.useEffect)(()=>(g.current=!0,()=>{g.current=!1}),[]);let u=(0,he.useCallback)(()=>g.current&&i.current===n,[n]),c=(0,he.useCallback)(()=>{if(!u())throw new Hr.WalletError("session_inactive","Wallet or token context changed. Retry the operation with the current account and chain.");let h=(0,Kr.tokenChainMismatch)({address:s,chainId:t.chainId},r);if(h)throw h},[u,s,t.chainId,r]);return{identity:l,isCurrent:u,assertCurrent:c}}var Yt=require("@naculus/connect-core");function Vr(e){let{publicClient:t}=le(),{currentChain:r}=ie(),{identity:s,isCurrent:n,assertCurrent:l}=at({token:e.token,chainId:r?(0,qr.chainNumber)(r)??void 0:void 0,owner:e.owner,spender:e.spender,publicClient:t}),[i,g]=(0,Ce.useState)(null),u=i?.identity===s?i.raw:null,c=i?.identity===s&&i.fetching,h=i?.identity===s?i.error:null,o=(0,Ce.useRef)(null),a=(0,Ce.useRef)(0),p=(0,Ce.useCallback)(async()=>{if(!n())return;let d=++a.current,y=()=>n()&&d===a.current;if(g({identity:s,raw:null,fetching:!!t,error:null}),!!t)try{l();let C=await t.readContract({address:e.token.address,abi:Yt.ERC20_MIN_ABI,functionName:"allowance",args:[e.owner,e.spender]});if(!y())return;g({identity:s,raw:C,fetching:!1,error:null})}catch(C){if(!y())return;g({identity:s,raw:null,fetching:!1,error:C instanceof Error?C:new Error("Failed to fetch allowance")})}},[t,e.token.address,e.token.chainId,e.owner,e.spender,s,n,l]);return(0,Ce.useEffect)(()=>{p().catch(d=>console.warn("useERC20Allowance: initial fetch failed:",d))},[p]),(0,Ce.useEffect)(()=>(e.refreshInterval&&e.refreshInterval>0&&(o.current=setInterval(p,e.refreshInterval)),()=>{o.current&&(clearInterval(o.current),o.current=null)}),[e.refreshInterval,p]),{allowance:(0,Ce.useMemo)(()=>{if(u===null)return null;let d=e.token.decimals;return d===void 0?null:(0,Yt.formatUnits)(u,d)},[u,e.token.decimals]),allowanceRaw:u,isFetching:c,error:h,refetch:p}}var me=require("@naculus/connect-appkit-core"),re=require("@naculus/connect-core"),ye=require("react");var Jt=require("@naculus/connect-core"),it=require("react");function lt(){let{session:e,chainId:t,client:r}=U(),[s,n]=(0,it.useState)("idle"),[l,i]=(0,it.useState)(null),g=(0,it.useCallback)(async c=>{if(!e){n("failed");let o=new Jt.WalletError("wallet_unavailable","No active session");throw i(o),o}let h=e.namespaces.eip155?.accounts.find(o=>/^eip155:\d+:0x[0-9a-fA-F]{40}$/.test(o)||/^0x[0-9a-fA-F]{40}$/.test(o));if(!h){n("failed");let o=new Jt.WalletError("wallet_unavailable","No EVM account found");throw i(o),o}n("awaiting_approval"),i(null);try{let o={...c,from:c.from??h.split(":").pop()},a=N(r);if(!a)throw new Jt.WalletError("wallet_unavailable","Client not initialized");let p=await a.sendTransaction(e,{transaction:o,chainId:t??void 0}),f=Kt(p);return n("submitted"),f}catch(o){n("failed");let a=o instanceof Error?o.message:"Transaction failed";throw i(o instanceof Error?o:new Error(a)),o}},[e,t,r]),u=(0,it.useCallback)(()=>{n("idle"),i(null)},[]);return{sendTransaction:g,status:s,error:l,reset:u,isSending:s==="awaiting_approval"}}function Ps(e){return e.includes(":")?e.split(":").pop():e}var Ws=2n**256n-1n;function $r(e){let{publicClient:t,walletClient:r}=le(),{evmAccount:s,isConnected:n}=H(),{currentChain:l}=ie(),{session:i,client:g}=U(),{sendTransaction:u,isSending:c,error:h,reset:o}=lt(),[a,p]=(0,ye.useState)(null),{identity:f,isCurrent:d,assertCurrent:y}=at({token:e.token,chainId:l?(0,me.chainNumber)(l)??void 0:void 0,owner:s,spender:e.spender,connected:n,publicClient:t,walletClient:r,session:i,client:g}),[C,w]=(0,ye.useState)(null),E=C?.identity===f?C.raw:null,R=C?.identity===f&&C.fetching,A=(0,ye.useRef)((0,me.createDecimalsCache)(e.token,e.token.decimals)),T=(0,ye.useRef)(0),v=a??h,x=s?Ps(s):null,b=(0,ye.useCallback)(async()=>{if(!d())return null;let S=++T.current,k=()=>d()&&S===T.current;if(w({identity:f,raw:null,fetching:!!t&&!!x&&n}),p(null),!t||!x||!n)return null;try{y();let P=await t.readContract({address:e.token.address,abi:re.ERC20_MIN_ABI,functionName:"allowance",args:[x,e.spender]});return k()?(w({identity:f,raw:P,fetching:!1}),P):null}catch(P){return k()&&(w({identity:f,raw:null,fetching:!1}),p(P instanceof Error?P:new Error("Failed to fetch allowance"))),null}},[t,x,e.token.address,e.token.chainId,e.spender,f,d,y,n]),I=(()=>{if(E===null)return null;let S=(0,me.readDecimals)(A.current,e.token,e.token.decimals);return S===void 0?null:(0,re.formatUnits)(E,S)})(),W=(0,ye.useCallback)(async S=>{if(p(null),o(),!n||!s){let k=new re.WalletError("wallet_unavailable","No connected account");throw p(k),k}if(!t){let k=new re.WalletError("wallet_unavailable","No public client");throw p(k),k}try{y();let k=(0,me.encodeErc20Approve)(e.spender,S),P=N(g);if(i&&P){let D=await u({to:e.token.address,data:k,value:"0"});return b(),D}if(r){let{request:D}=await t.simulateContract({address:e.token.address,abi:re.ERC20_MIN_ABI,functionName:"approve",args:[e.spender,S],account:x});y();let Me=await r.writeContract(D);return b(),Me}let _=await u({to:e.token.address,data:k,value:"0"});return b(),_}catch(k){let P=k instanceof Error?k:new Error("Approve failed");throw d()&&p(P),P}},[e,t,r,s,n,i,g,x,u,o,b,y,d]),F=(0,ye.useCallback)(async S=>{try{if(y(),!t)throw new re.WalletError("wallet_unavailable","No public client");let k=(0,me.readDecimals)(A.current,e.token,e.token.decimals);k===void 0&&(k=await t.readContract({address:e.token.address,abi:re.ERC20_MIN_ABI,functionName:"decimals"}),y(),(0,me.writeDecimals)(A.current,e.token,k));let P=(0,re.parseUnits)(S,k);return await W(P)}catch(k){throw d()&&p(k instanceof Error?k:new Error("Approve failed")),k}},[e.token,t,W,y,d]),q=(0,ye.useCallback)(async()=>W(Ws),[W]),m=(0,ye.useCallback)(async S=>{if(!d()||!n||!x||!t)return!1;try{y()}catch(D){return p(D instanceof Error?D:new Error("Cannot check allowance")),!1}let k=E??await b();if(k===null)return!1;let P=(0,me.readDecimals)(A.current,e.token,e.token.decimals);if(P===void 0){if(!t)throw new re.WalletError("wallet_unavailable","Cannot check allowance: no public client to read token decimals.");if(P=await t.readContract({address:e.token.address,abi:re.ERC20_MIN_ABI,functionName:"decimals"}),!d())return!1;(0,me.writeDecimals)(A.current,e.token,P)}let _=(0,re.parseUnits)(S,P);return d()&&k>=_},[E,b,e.token.address,e.token.chainId,e.token.decimals,t,d,y,n,x]);return{approve:F,approveMax:q,allowance:I,allowanceRaw:E,hasAllowance:m,isApproving:c,isFetchingAllowance:R,error:v,refetchAllowance:b}}var Te=require("@naculus/connect-appkit-core"),Fe=require("@naculus/connect-core"),ct=require("react");function Os(e){return e.includes(":")?e.split(":").pop():e}function Gr(e){let{publicClient:t,walletClient:r}=le(),{evmAccount:s,isConnected:n}=H(),{currentChain:l}=ie(),{session:i,client:g}=U(),{sendTransaction:u,isSending:c,error:h,reset:o}=lt(),[a,p]=(0,ct.useState)(null),{isCurrent:f,assertCurrent:d}=at({token:e.token,chainId:l?(0,Te.chainNumber)(l)??void 0:void 0,owner:s,connected:n,publicClient:t,walletClient:r,session:i,client:g}),y=(0,ct.useRef)((0,Te.createDecimalsCache)(e.token,e.token.decimals)),C=a??h;return{sendTransfer:(0,ct.useCallback)(async(E,R)=>{if(p(null),o(),!n||!s){let A=new Fe.WalletError("wallet_unavailable","No connected account");throw p(A),A}if(!t){let A=new Fe.WalletError("wallet_unavailable","No public client available");throw p(A),A}try{d();let A=Os(s),T=(0,Te.readDecimals)(y.current,e.token,e.token.decimals);T===void 0&&(T=await t.readContract({address:e.token.address,abi:Fe.ERC20_MIN_ABI,functionName:"decimals"}),d(),(0,Te.writeDecimals)(y.current,e.token,T));let v=(0,Fe.parseUnits)(R,T),x=(0,Te.encodeErc20Transfer)(E,v),b=N(g);if(i&&b)return await u({to:e.token.address,data:x,value:"0"});if(r){let{request:W}=await t.simulateContract({address:e.token.address,abi:Fe.ERC20_MIN_ABI,functionName:"transfer",args:[E,v],account:A});return d(),await r.writeContract(W)}return await u({to:e.token.address,data:x,value:"0"})}catch(A){let T=A instanceof Error?A:new Error("Transfer failed");throw f()&&p(T),T}},[e.token,t,r,s,n,i,g,u,o,d,f]),isSending:c,error:C}}var en=require("@naculus/connect-appkit-core"),zr=require("@naculus/connect-core"),Qr=require("react");var jr=require("@naculus/connect-appkit-core"),xe=require("react");function Zt(e,t){U();let{evmAccount:r}=H(),{currentChain:s}=ie(),{publicClient:n}=le(),[l,i]=(0,xe.useState)(void 0),[g,u]=(0,xe.useState)(!1),[c,h]=(0,xe.useState)(null),o=(0,xe.useRef)(void 0),a=(0,xe.useCallback)(async()=>{e&&(u(!0),h(null));try{let f=await(0,jr.simulateTransactionPreview)(e,{chainId:t,currentChain:s,publicClient:n,evmAccount:r});return i(f),f}catch(f){let d=f instanceof Error?f:new Error("Simulation failed");throw h(d),d}finally{e&&u(!1)}},[e,t,s,n,r]);(0,xe.useEffect)(()=>{if(e)return o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{a().catch(()=>{})},300),()=>{o.current&&clearTimeout(o.current)}},[e,a]);let p=(0,xe.useCallback)(()=>{i(void 0),h(null),u(!1)},[]);return{result:l,isSimulating:g,error:c,simulate:a,reset:p}}function Xr(e){let{evmAccount:t,isConnected:r}=H(),{currentChain:s}=ie(),n=e.token.chainId??(s?(0,en.chainNumber)(s)??void 0:void 0),l=(0,Qr.useMemo)(()=>{if(!(!r||!t))try{let g=e.token.decimals;if(g===void 0)return;let u=(0,zr.parseUnits)(e.amount,g),c=(0,en.encodeErc20Transfer)(e.to,u);return{to:e.token.address,data:c,value:"0"}}catch{return}},[e.token.address,e.token.decimals,e.to,e.amount,t,r]),i=Zt(l,n);return{result:l?i.result:void 0,isSimulating:!!l&&i.isSimulating,error:l?i.error:null,reSimulate:i.simulate,reset:i.reset}}var Ie=require("react");var Se=require("react"),tn=require("react"),Xn=(0,tn.createContext)(null);function kt(){return(0,tn.useContext)(Xn)}function Yr(e,t,r){let s=kt(),n=r??s,[l,i]=(0,Se.useState)(null),[g,u]=(0,Se.useState)(!1),[c,h]=(0,Se.useState)(!1),[o,a]=(0,Se.useState)(null),p=(0,Se.useRef)(void 0),f=(0,Se.useCallback)(async()=>{if(!(!n||!e)){u(!0),a(null);try{await n.refreshTx(e,t);let C=n.getTxStatus(e,t);C&&i(C)}catch(C){a(C instanceof Error?C:new Error(String(C)))}finally{u(!1)}}},[n,e,t]),d=(0,Se.useCallback)(()=>{!n||!e||(n.stopWatching(e,t),h(!1))},[n,e,t]);(0,Se.useEffect)(()=>{if(!n||!e||!t){i(null),h(!1);return}p.current&&p.current!==e&&n.stopWatching(p.current),p.current=e;let C=!1;h(!0),u(!0),a(null);let w=n.getTxStatus(e,t);w&&(i(w),u(!1)),n.watchTx(e,t,{}).then(R=>{C||(i(R),u(!1))}).catch(R=>{C||(a(R instanceof Error?R:new Error(String(R))),u(!1))});let E=R=>{C||i({...R})};return n.on("statusChange",E),()=>{C=!0,h(!1),n.off("statusChange",E)}},[n,e,t]);let y=l?.status??"idle";return{entry:l,status:y,isLoading:g,isWatching:c,error:o,refresh:f,stopWatching:d}}function Jr(e){let t=kt(),r=e??t,[s,n]=(0,Ie.useState)(null),[l,i]=(0,Ie.useState)(null),[g,u]=(0,Ie.useState)(null),c=(0,Ie.useRef)(null),h=(0,Ie.useRef)(null),o=(0,Ie.useRef)(null);r&&(h.current||(h.current=p=>{i(p),(!c.current||p.createdAt>=c.current.createdAt)&&(n(p),c.current=p)},r.on("confirmed",h.current)),o.current||(o.current=p=>{u(p),(!c.current||p.createdAt>=c.current.createdAt)&&(n(p),c.current=p)},r.on("failed",o.current)));let a=(0,Ie.useCallback)(()=>{n(null),i(null),u(null),c.current=null},[]);return{lastTx:s,lastConfirmedTx:l,lastFailedTx:g,clear:a}}var eo=require("react");var ce=require("react"),Zr=require("@naculus/connect-appkit-core");function nn({input:e,skip:t=!1,resolverConfig:r,scope:s,query:n}){let[l,i]=(0,ce.useState)(null),[g,u]=(0,ce.useState)(!1),[c,h]=(0,ce.useState)(null),o=(0,ce.useRef)(0),a=(0,ce.useRef)(!0);(0,ce.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let p=(0,ce.useMemo)(()=>(0,Zr.getResolver)(r),[r]),f=(0,ce.useCallback)(()=>{let d=e.trim();if(!d||t){o.current+=1,i(null),u(!1),h(null);return}let y=++o.current;u(!0),h(null),n(p,d,s).then(C=>{!a.current||y!==o.current||(i(C),u(!1))}).catch(C=>{!a.current||y!==o.current||(h(C instanceof Error?C:new Error(String(C))),i(null),u(!1))})},[e,t,s,p,n]);return(0,ce.useEffect)(()=>{f()},[f]),{data:l,isLoading:g,error:c,refetch:f}}function to(e,t){let r=(0,eo.useCallback)((s,n,l)=>s.lookupAddress(n,l),[]);return nn({input:e,skip:t?.skip,resolverConfig:t?.resolverConfig,scope:t?.chainId,query:r})}var z=require("react"),Q=require("@naculus/connect-appkit-core"),no=require("@naculus/connect-core");function ro(e){let t=(0,z.useRef)(null);t.current||(t.current=e?.channel??new no.InAppChannel);let r=t.current,[s,n]=(0,z.useState)(()=>r.getHistory()),[l,i]=(0,z.useState)(()=>Q.DEFAULT_NOTIFICATION_SETTINGS);(0,z.useEffect)(()=>{let C=e?.storage??(0,Q.createNotificationSettingsStorage)();(0,Q.loadNotificationSettings)(C).then(w=>{w&&i(w)})},[]),(0,z.useEffect)(()=>(r.onNotification=C=>{n(w=>[...w,C])},r.restore().then(()=>{n(r.getHistory())}),()=>{r.onNotification=void 0}),[]);let g=(0,z.useMemo)(()=>s.filter(C=>!C.read).length,[s]),u=(0,z.useCallback)(()=>{r.clear(),n([])},[r]),c=(0,z.useCallback)(C=>{(0,Q.clearOneInAppNotification)(r,C).then(()=>{n(r.getHistory())})},[r]),h=(0,z.useCallback)(C=>{r.markAsRead(C),n(w=>w.map(E=>E.id===C?{...E,read:!0}:E))},[r]),o=(0,z.useCallback)(()=>{r.markAllAsRead(),n(C=>C.map(w=>({...w,read:!0})))},[r]),a=(0,z.useCallback)(C=>{(0,Q.addInAppNotification)(r,C)},[r]),p=(0,z.useCallback)(C=>{i(w=>{let E=(0,Q.updateNotificationSettings)(w,C),R=e?.storage??(0,Q.createNotificationSettingsStorage)();return(0,Q.saveNotificationSettings)(R,E),E})},[e?.storage]),f=(0,z.useCallback)(C=>{p((0,Q.channelsUpdate)(C))},[p]),d=(0,z.useCallback)(C=>{p((0,Q.mutedChainSettings)(l,C,!0))},[l.mutedChains,p]),y=(0,z.useCallback)(C=>{p((0,Q.mutedChainSettings)(l,C,!1))},[l.mutedChains,p]);return{notifications:s,unreadCount:g,addNotification:a,clear:u,clearOne:c,markAsRead:h,markAllAsRead:o,settings:l,updateSettings:p,setChannels:f,muteChain:d,unmuteChain:y}}var ut=require("react");var oo=()=>null,Ns=()=>()=>{};function so(){let{client:e}=U(),t=N(e)?.passphraseGate??null,r=(0,ut.useSyncExternalStore)(t?.subscribe??Ns,t?.getSnapshot??oo,oo),s=(0,ut.useCallback)(i=>t?.submit(i),[t]),n=(0,ut.useCallback)(()=>t?.cancel(),[t]),l=(0,ut.useCallback)(i=>t?.forget(i),[t]);return{request:r,submit:s,cancel:n,forget:l,isUnlocked:t?.isUnlocked??!1,gate:t}}var ao=require("react");function io(e,t){let r=(0,ao.useCallback)((s,n)=>s.resolveName(n),[]);return nn({input:e,skip:t?.skip,resolverConfig:t?.resolverConfig,query:r})}var Ue=require("@naculus/connect-appkit-core"),$e=require("@naculus/connect-core"),oe=require("react");async function _s(e,t,r,s,n){let l=N(t);if(!l)throw new $e.WalletError("wallet_unavailable","Client not initialized");let i=[r,s];if(e.walletType==="eip6963"||e.id?.startsWith("eip6963-")){let{eip6963Connector:g}=await import("@naculus/connector-evm-injected"),u=g.getDiscoveredWallets().find(h=>h.id===e.walletId),c=u?await u.provider.request({method:"personal_sign",params:i}):await g.request({method:"personal_sign",params:i});return(0,Ue.assertHexSignature)(c)}if(e.walletType==="walletconnect")return(0,Ue.assertHexSignature)(await l.connector.request({method:"personal_sign",params:i}));if(e.walletType==="embedded"){let g=l.embeddedConnector;if(!g?.signHash)throw new $e.WalletError("method_unsupported","This embedded wallet build cannot sign a raw digest. Upgrade @naculus/connector-embedded or pass an explicit signer.");return(0,Ue.assertHexSignature)(await g.signHash(e,r))}throw e.walletType==="passkeys"?new $e.WalletError("method_unsupported","Passkeys sign with P-256, which a SimpleAccount cannot verify. Use a smart account with a WebAuthn validator, or pass an explicit signer."):new $e.WalletError("method_unsupported",`Raw UserOperation signing is not available for ${e.walletType} on ${n}. Pass a signer that signs the raw 32-byte hash.`)}function lo(e){let{evmAccount:t}=H(),{session:r,chainId:s,client:n}=U(),[l,i]=(0,oe.useState)(null),[g,u]=(0,oe.useState)(null),[c,h]=(0,oe.useState)(!1),[o,a]=(0,oe.useState)(!1),[p,f]=(0,oe.useState)(null),d=(0,oe.useRef)(0),y=(0,oe.useRef)(!1);(0,oe.useEffect)(()=>()=>{d.current+=1,y.current=!1},[]),(0,oe.useEffect)(()=>{d.current+=1,y.current=!1,i(null),u(null),h(!1),a(!1),f(null)},[n,s,t,e?.accountType,e?.bundlerUrl,e?.chainId,e?.entryPoint,e?.owner,e?.rpcUrl,e?.salt,e?.signerMode,r]);let C=(0,oe.useCallback)(async(E,R)=>{let A=b=>(f(b),null);if(!e?.rpcUrl)return A(new Error("RPC URL not configured"));if(!e.bundlerUrl)return A(new Error("Bundler URL not configured"));if(!E.length)return A(new Error("At least one call is required"));if(y.current)return A(new Error("A UserOperation is already in progress"));let T=(0,Ue.bareEvmAddress)(e.owner??t);if(!T)return A(new $e.WalletError("wallet_unavailable","No EVM account found"));let v;try{v=(0,Ue.resolveUserOpChain)(e.chainId,s)}catch(b){return A(b)}if(!e.signer&&!r)return A(new $e.WalletError("wallet_unavailable","No active session"));let x=++d.current;y.current=!0,h(!0),a(!0),f(null),i(null),u(null);try{let{SmartAccountManager:b}=await import("@naculus/connect-core"),I=e.signer??(m=>_s(r,n,m,T,v)),W=new b({rpcUrl:e.rpcUrl,bundlerClient:{url:e.bundlerUrl},chainId:v,signer:I,signerMode:e.signer?e.signerMode??"eip191":"raw"}),F=(0,Ue.buildSmartAccountConfig)(T,v,e),q=await W.sendUserOperation(F,E,R);return x!==d.current?null:(a(!1),i(q.userOpHash),W.getUserOperationReceipt(q.userOpHash).then(m=>{x===d.current&&u(m)}).catch(()=>{}),q)}catch(b){if(x!==d.current)return null;let I=b instanceof Error?b:new Error("Failed to send UserOperation");return f(I),null}finally{y.current=!1,x===d.current&&(h(!1),a(!1))}},[n,s,t,e,r]),w=(0,oe.useCallback)(()=>{d.current+=1,i(null),u(null),h(!1),a(!1),f(null)},[]);return{sendUserOp:C,userOpHash:l,receipt:g,isPending:c,isEstimating:o,error:p,reset:w}}var xt=require("react");function Ds(e,t){if(!e)return()=>{};let r=()=>t();return e.on("sessionConnected",r),e.on("sessionDisconnected",r),e.on("chainChanged",r),e.on("sessionScopeChanged",r),e.on("sessionRevoked",r),()=>{e.off("sessionConnected",r),e.off("sessionDisconnected",r),e.off("chainChanged",r),e.off("sessionScopeChanged",r),e.off("sessionRevoked",r)}}var Yn=Object.freeze({session:null,chainSessions:[],activeChainId:null,isConnected:!1,connectorId:null}),Jn=new WeakMap;function Ms(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function Ls(e){if(!e)return Yn;let t=e.getActiveBundle(),r=Jn.get(e);if(!t)return r&&r.session===null?r:(Jn.set(e,Yn),Yn);let s=Array.from(t.chainSessions.values());if(r&&r.session===t.walletSession&&r.activeChainId===t.activeChainId&&Ms(r.chainSessions,s))return r;let n={session:t.walletSession,chainSessions:s,activeChainId:t.activeChainId,isConnected:!0,connectorId:t.walletSession.walletType};return Jn.set(e,n),n}function co(e){let t=U(),r=e??t.sessionManager??null,s=(0,xt.useCallback)(l=>Ds(r,l),[r]),n=(0,xt.useCallback)(()=>Ls(r),[r]);return(0,xt.useSyncExternalStore)(s,n)}var rn=require("@naculus/connect-appkit-core"),vt=require("@naculus/connect-core"),Pe=require("@naculus/siwx"),pt=require("react");var Bs=86400;function on(){let{session:e,chainId:t,client:r}=U(),[s,n]=(0,pt.useState)(!1),[l,i]=(0,pt.useState)(null),g=(0,pt.useCallback)(()=>i(null),[]);return{signIn:(0,pt.useCallback)(async c=>{if(!e)throw new vt.WalletError("wallet_unavailable","No active session");let h=c?.chainId??t;if(!h)throw new vt.WalletError("invalid_chain","No chain to sign for. Connect a wallet or pass options.chainId.");let o=Ye(e,h);if(!o)throw new vt.WalletError("wallet_unavailable","No account found");let a=N(r);if(!a)throw new vt.WalletError("wallet_unavailable","Client not initialized");let{address:p}=o,f=typeof window>"u"?void 0:window.location,d=c?.domain??(0,rn.defaultSiwxDomain)(f),y=c?.uri??(0,rn.defaultSiwxUri)(f);n(!0),i(null);try{let C=(0,Pe.generateNonce)();await(0,Pe.issueNonce)(C);let w=(0,Pe.nowISO)(),E=c?.expirySeconds??Bs,R=new Date(Date.now()+E*1e3).toISOString(),A=(0,Pe.createSiwxMessage)({domain:d,address:p,uri:y,version:1,chainId:h,nonce:C,issuedAt:w,expirationTime:R,statement:c?.statement,resources:c?.resources,requestId:c?.requestId}),T=await a.signMessage(e,{message:A,address:p,chainId:h??void 0}),v={message:{raw:A,domain:d,address:p,statement:c?.statement??null,uri:y,version:1,chainId:h,nonce:C,issuedAt:w,blockchain:(0,Pe.getBlockchainName)(h),expirationTime:R,notBefore:null,resources:c?.resources??[],requestId:c?.requestId??null},signature:T};return n(!1),v}catch(C){let w=C instanceof Error?C:new Error("SIWx sign-in failed");throw i(w),n(!1),w}},[e,t,r]),isSigningIn:s,error:l,clearError:g}}var Zn=require("@naculus/connect-appkit-core"),sn=require("@naculus/connect-core"),At=require("@naculus/siwx"),se=require("react");function uo(e){let{storagePrefix:t="naculus_",autoRestore:r=!0,defaultExpirySeconds:s=86400}=e??{},[n,l]=(0,se.useState)(null),[i,g]=(0,se.useState)(r),[u,c]=(0,se.useState)(!1),[h,o]=(0,se.useState)(null),{session:a,chainId:p}=U(),f=on(),d=(0,se.useRef)((0,At.createLocalStorageSiwxSessionStorage)(`${t}siwx_session`)),y=(0,se.useCallback)(()=>o(null),[]);(0,se.useEffect)(()=>{if(!r){g(!1);return}let v=!1;return(async()=>{try{let b=await d.current.get();if(v)return;b?(sn.logger.info("react/useSIWxSession","Restored persisted SIWx session"),l(b),o(null)):l(null)}catch(x){sn.logger.warn("react/useSIWxSession","Failed to restore SIWx session:",x),l(null)}finally{v||g(!1)}})(),()=>{v=!0}},[r]),(0,se.useEffect)(()=>{if(!n?.expiresAt)return;let v=new Date(n.expiresAt).getTime()-Date.now();if(v<=0){l(null);return}let x=setTimeout(()=>{l(b=>b&&b.id===n.id?null:b)},v);return()=>clearTimeout(x)},[n?.id,n?.expiresAt]);let C=(0,se.useCallback)(async v=>{c(!0),o(null);try{let x={expirySeconds:s,chainId:p??void 0,...v},b=await f.signIn(x),I=(0,Zn.siwxResultToSession)(b);return await d.current.set(I),l(I),c(!1),I}catch(x){let b=x instanceof Error?x:new Error("SIWx sign-in failed");throw o(b),c(!1),b}},[f,p,s]),w=(0,se.useCallback)(async()=>{try{await d.current.remove()}catch(v){sn.logger.warn("react/useSIWxSession","Failed to clear session:",v)}l(null),o(null)},[]),E=(0,se.useCallback)(async()=>{if(!n)throw new Error("No active session to refresh");c(!0),o(null);try{let v=await f.signIn({domain:n.domain,statement:n.message.statement??void 0,uri:n.message.uri,chainId:n.chainId,expirySeconds:s,resources:n.message.resources.length>0?n.message.resources:void 0,requestId:n.message.requestId??void 0}),x={...(0,Zn.siwxResultToSession)(v),id:n.id,refreshedAt:new Date().toISOString()};return await d.current.set(x),l(x),c(!1),x}catch(v){let x=v instanceof Error?v:new Error("Session refresh failed");throw o(x),c(!1),x}},[n,f,s]),R=n!==null&&!(0,At.checkSessionExpired)(n),A=(0,At.checkSessionExpired)(n),T=n?.expiresAt?Math.max(0,new Date(n.expiresAt).getTime()-Date.now()):null;return{session:R?n:null,isAuthenticated:R,isRestoring:i,isSigningIn:u,isExpired:A,timeUntilExpiry:T,signIn:C,signOut:w,refresh:E,error:h,clearError:y}}var an=require("@naculus/connect-appkit-core"),bt=require("@naculus/connect-core"),We=require("@naculus/siwx"),Ge=require("react");function dt(){let{session:e,chainId:t,client:r}=U(),[s,n]=(0,Ge.useState)(!1),[l,i]=(0,Ge.useState)(null),[g,u]=(0,Ge.useState)(null),c=(0,Ge.useCallback)(()=>u(null),[]);return{signIn:(0,Ge.useCallback)(async o=>{if(!e)throw new bt.WalletError("wallet_unavailable","No active session");let a=o?.chainId??t;if(!a)throw new bt.WalletError("invalid_chain","No chain to sign for. Connect a wallet or pass options.chainId.");let p=Ye(e,a);if(!p)throw new bt.WalletError("wallet_unavailable","No account found");let f=N(r);if(!f)throw new bt.WalletError("wallet_unavailable","Client not initialized");let{address:d}=p,y=typeof window>"u"?void 0:window.location,C=o?.domain??(0,an.defaultSiwxDomain)(y),w=o?.uri??(0,an.defaultSiwxUri)(y);n(!0),u(null);try{let E=(0,We.generateNonce)();await(0,We.issueNonce)(E);let R=(0,We.nowISO)(),A=(0,We.createSiwxMessage)({domain:C,address:d,uri:w,version:1,chainId:a,nonce:E,issuedAt:R,statement:o?.statement,expirationTime:o?.expirySeconds?new Date(Date.now()+o.expirySeconds*1e3).toISOString():void 0,resources:o?.resources,requestId:o?.requestId}),T=await f.signMessage(e,{message:A,address:d,chainId:a??void 0}),v=o?.expirySeconds?new Date(Date.now()+o.expirySeconds*1e3).toISOString():null,x={message:{raw:A,domain:C,address:d,statement:o?.statement??null,uri:w,version:1,chainId:a,nonce:E,issuedAt:R,blockchain:(0,We.getBlockchainName)(a),expirationTime:v,notBefore:null,resources:o?.resources??[],requestId:o?.requestId??null},signature:T};return i(x),x}catch(E){let R=E instanceof Error?E:new Error("SIWx sign-in failed");throw u(R),R}finally{n(!1)}},[e,t,r]),isSigningIn:s,result:l,error:g,clearError:c}}var ln=require("@naculus/connect-core");var er=require("react");function Fs(){let{session:e,chainId:t}=U();return(0,er.useCallback)(r=>{if(!e)throw new ln.WalletError("wallet_unavailable","No active session");let s=r??t;if(s&&!s.startsWith("eip155:"))throw new ln.WalletError("namespace_mismatch",`Ethereum SIWx requires an eip155 chain, received ${s}`);let n=e.namespaces.eip155;if(!n||n.accounts.length===0)throw new ln.WalletError("namespace_mismatch","No EVM (eip155) accounts found in session")},[e,t])}function po(){let e=Fs(),t=dt();return{signIn:(0,er.useCallback)(async s=>(e(s?.chainId),t.signIn(s)),[e,t.signIn]),isSigningIn:t.isSigningIn,result:t.result,error:t.error,clearError:t.clearError}}var mo=require("@naculus/connect-appkit-core"),fo=require("@naculus/wallet-engine"),Oe=require("react");function go(e){let t=e?.rpcUrl,r=e?.chainId,s=(0,Oe.useRef)(null),n=(0,Oe.useCallback)(()=>(s.current||(s.current=new fo.SimulationManager({enabled:!0,rpcUrl:t,autoSimulate:!1})),s.current),[t]),[l,i]=(0,Oe.useState)(null),[g,u]=(0,Oe.useState)(!1),[c,h]=(0,Oe.useState)(null),o=(0,Oe.useCallback)(async(p,f,d,y,C)=>{u(!0),h(null);try{let w=n(),E=(0,mo.resolveSimulationEndpoint)(C?.chainId,r,C?.rpcUrl,t),R=await w.simulateERC20Transfer(p,f,d,y,E.chainId,C?.decimals,E.rpcUrl);return i(R),R}catch(w){let E=w instanceof Error?w:new Error(String(w));throw h(E),E}finally{u(!1)}},[t,r,n]),a=(0,Oe.useCallback)(()=>{i(null),h(null),u(!1)},[]);return{result:l,loading:g,error:c,simulate:o,reset:a}}var un=require("@naculus/connect-appkit-core"),je=require("@naculus/connect-core"),fe=require("react");var cn="siwx_auth";function Hs(e){return new je.LocalStorageAdapter(e)}function ho(e){let{storagePrefix:t="naculus_",autoRestore:r=!0}=e??{},[s,n]=(0,fe.useState)(null),[l,i]=(0,fe.useState)(r),[g,u]=(0,fe.useState)(!1),[c,h]=(0,fe.useState)(null),o=dt(),a=(0,fe.useRef)(Hs(t)),p=(0,fe.useCallback)(()=>h(null),[]);(0,fe.useEffect)(()=>{if(!r){i(!1);return}let y=!1;return(async()=>{try{let C=a.current,w=await C.get(cn);if(y)return;w&&!(0,un.isSiwxExpired)(w,new Date)&&(0,un.isSiwxNotBeforeValid)(w,new Date)?(je.logger.info("react/useSiwxAuthSession","Restored persisted SIWx auth session"),n(w),h(null)):w&&(je.logger.info("react/useSiwxAuthSession","Persisted SIWx auth expired, clearing"),await C.remove(cn))}catch(C){je.logger.warn("react/useSiwxAuthSession","Failed to restore SIWx auth:",C)}finally{y||i(!1)}})(),()=>{y=!0}},[r]);let f=(0,fe.useCallback)(async y=>{u(!0),h(null);try{let C=await o.signIn(y);return await a.current.set(cn,C),n(C),u(!1),C}catch(C){let w=C instanceof Error?C:new Error("SIWx sign-in failed");throw h(w),u(!1),w}},[o]),d=(0,fe.useCallback)(async()=>{try{await a.current.remove(cn)}catch(y){je.logger.warn("react/useSiwxAuthSession","Failed to clear SIWx auth:",y)}n(null),h(null)},[]);return{isSignedIn:s!==null,isRestoring:l,siwxResult:s,isSigningIn:g,error:c,signIn:f,signOut:d,clearError:p}}var ze=require("@naculus/connect-appkit-core"),tr=require("@naculus/connect-core"),G=require("react");function Co(e){return new tr.WalletError("wallet_unavailable",e)}function yo(e){let{evmAccount:t}=H(),{session:r,chainId:s,client:n}=U(),[l,i]=(0,G.useState)(null),[g,u]=(0,G.useState)(!1),[c,h]=(0,G.useState)(null),[o,a]=(0,G.useState)(!1),[p,f]=(0,G.useState)(null),d=(0,G.useRef)(null),y=(0,G.useRef)(0),C=(0,G.useRef)(!1);(0,G.useEffect)(()=>{if(d.current=null,!e?.rpcUrl)return;let b=!1;return import("@naculus/connect-core").then(({SmartAccountManager:I})=>{if(b)return;let W=(0,ze.resolveEvmChainId)(e.chainId,s);W&&(d.current=new I({rpcUrl:e.rpcUrl,chainId:W,bundlerClient:{url:e.bundlerUrl??""}}))}).catch(I=>{b||f(I instanceof Error?I:new Error("Failed to load account-abstraction module"))}),()=>{b=!0}},[s,e?.rpcUrl,e?.bundlerUrl,e?.chainId]),(0,G.useEffect)(()=>{y.current+=1,C.current=!1,i(null),u(!1),h(null),a(!1),f(null)},[t,s,e?.rpcUrl,e?.bundlerUrl,e?.chainId,e?.entryPoint,e?.accountType,e?.salt]);let w=(0,G.useCallback)(()=>{let b=(0,ze.bareEvmAddress)(t);if(!b||!d.current)return null;let I=(0,ze.resolveEvmChainId)(e?.chainId,s);return I?(0,ze.buildSmartAccountConfig)(b,I,{accountType:e?.accountType,entryPoint:e?.entryPoint,salt:e?.salt}):null},[t,s,e?.accountType,e?.chainId,e?.entryPoint,e?.salt]),E=(0,G.useCallback)(b=>(f(b),null),[]),R=(0,G.useCallback)(()=>C.current?null:(C.current=!0,y.current),[]),A=(0,G.useCallback)(b=>{y.current===b&&(C.current=!1)},[]),T=(0,G.useCallback)(async()=>{let b=w();if(!b||!d.current)return E(new Error("Smart account not configured"));let I=R();if(I===null)return E(new Error("Smart account operation already in progress"));a(!0),f(null);try{let F=await d.current.createAccount(b);return y.current!==I?null:(i(F.address),u(F.isDeployed),h(F),F)}catch(W){if(y.current!==I)return null;let F=W instanceof Error?W:new Error("Failed to create smart account");return f(F),null}finally{y.current===I&&a(!1),A(I)}},[R,E,A,w]),v=(0,G.useCallback)(async()=>{let b=w();if(!b||!d.current)return E(new Error("Smart account not configured"));if(!r)return E(Co("No active session"));let I=N(n);if(!I)return E(Co("Client not initialized"));if(s&&s!==b.chainId)return E(new tr.WalletError("chain_mismatch",`Connected chain ${s} does not match smart account chain ${b.chainId}.`));let W=R();if(W===null)return E(new Error("Smart account operation already in progress"));a(!0),f(null);try{let F=d.current,q=await F.createAccount(b);if(y.current!==W)return null;if(q.isDeployed)return i(q.address),u(!0),h(q),q.address;let m=await F.getDeployCallData(b),S=await I.sendTransaction(r,{transaction:{to:m.to,data:m.data,value:m.value.toString()},chainId:b.chainId});if(y.current!==W)return null;let k=await F.createAccount(b);return i(k.address),u(k.isDeployed),h(k),S}catch(F){if(y.current!==W)return null;let q=F instanceof Error?F:new Error("Failed to deploy smart account");return f(q),null}finally{y.current===W&&a(!1),A(W)}},[n,s,R,E,A,w,r]),x=(0,G.useCallback)(async()=>{let b=w();if(!b||!d.current)return null;let I=y.current;try{let W=await d.current.getAccountAddress(b);return y.current!==I?null:(i(W),W)}catch(W){return y.current!==I||f(W instanceof Error?W:new Error("Failed to get smart account address")),null}},[w]);return{address:l,isDeployed:g,accountInfo:c,isLoading:o,error:p,createWallet:T,deployWallet:v,getAddress:x}}var So=require("react");function pn(){let{accounts:e,isConnected:t}=U();return(0,So.useMemo)(()=>{if(!t)return{address:null,caip10:null,chainId:null,isConnected:!1};let r=e.find(i=>i.startsWith("solana:"))??null;if(!r)return{address:null,caip10:null,chainId:null,isConnected:t};let s=r.split(":"),n=s.length>=3?s[s.length-1]:null,l=s.length>=3?s.slice(0,-1).join(":"):null;return{address:n,caip10:r,chainId:l,isConnected:t}},[e,t])}var ve=require("react"),Eo=require("@naculus/connect-core");function wo(e={}){let{client:t}=U(),{address:r}=pn(),s=e.address??r,n=e.rpcUrl??N(t)?.solanaRpcUrl??null,[l,i]=(0,ve.useState)(null),[g,u]=(0,ve.useState)(!1),[c,h]=(0,ve.useState)(null),o=(0,ve.useRef)(0),a=(0,ve.useCallback)(async()=>{if(!s||!n){i(null);return}let p=++o.current;u(!0),h(null);try{let f=await(0,Eo.getSolanaBalance)(n,s);if(p!==o.current)return;i(f)}catch(f){if(p!==o.current)return;i(null),h(f instanceof Error?f:new Error("Balance read failed"))}finally{p===o.current&&u(!1)}},[s,n]);return(0,ve.useEffect)(()=>{a()},[a]),(0,ve.useEffect)(()=>{if(!e.refreshInterval||e.refreshInterval<=0)return;let p=setInterval(()=>{a()},e.refreshInterval);return()=>clearInterval(p)},[e.refreshInterval,a]),{balance:l,isFetching:g,error:c,isConfigured:!!n,refetch:a}}var ko=require("@naculus/connect-appkit-core"),xo=require("react");function vo(){let{client:e,session:t,accounts:r}=U();return(0,xo.useMemo)(()=>{let s=N(e)?.solanaConnector,{roles:n,absence:l}=(0,ko.readSolanaRoles)(s,t);return{roles:n,absence:l,identity:n?.identity??null,signer:n?.signer??null,payer:n?.payer??null}},[e,t,r])}var nr=require("@naculus/connect-core"),He=require("react"),Ao=require("@naculus/connect-core");function bo(){let{client:e,session:t}=U(),[r,s]=(0,He.useState)(!1),[n,l]=(0,He.useState)(!1),[i,g]=(0,He.useState)(null),u=()=>{let a=N(e);if(!a||!t)throw new nr.WalletError("wallet_unavailable","No connected wallet.");return a},c=(0,He.useCallback)(async a=>{s(!0),g(null);try{return await u().signTransaction(t,{transaction:a})}catch(p){let f=p instanceof Error?p:new Error("Signing failed");throw g(f),f}finally{s(!1)}},[e,t]),h=(0,He.useCallback)(async a=>{l(!0),g(null);try{return await u().sendTransaction(t,{transaction:a})}catch(p){let f=p instanceof Error?p:new Error("Send failed");throw g(f),f}finally{l(!1)}},[e,t]),o=(0,He.useCallback)(async a=>{let p=N(e)?.solanaRpcUrl;if(!p)throw new nr.WalletError("no_rpc","Set solanaRpcUrl on the client to read a signature's status.");return(0,Ao.getSignatureStatus)(p,a)},[e]);return{signTransaction:c,sendTransaction:h,getStatus:o,isSigning:r,isSending:n,error:i,reset:()=>g(null)}}var mt=require("react"),Ro=require("@naculus/connect-appkit-core");function To(){let{switchChain:e,chainId:t}=U(),[r,s]=(0,mt.useState)(!1),[n,l]=(0,mt.useState)(null),i=(0,mt.useCallback)(async u=>{s(!0),l(null);try{await e(u)}catch(c){let h=(0,Ro.toChainSwitchError)(c);throw l(h),h}finally{s(!1)}},[e]),g=(0,mt.useCallback)(()=>{l(null)},[]);return{switchChain:i,isSwitching:r,currentChainId:t,error:n,clearError:g}}var ft=require("@naculus/connect-appkit-core"),Y=require("react");var gt=require("viem");function Io(e){let{evmAccount:t,isConnected:r}=H(),{chainId:s,chains:n}=U(),[l,i]=(0,Y.useState)([]),[g,u]=(0,Y.useState)(!1),[c,h]=(0,Y.useState)(null),{tokens:o,refreshInterval:a}=e,p=(0,Y.useRef)(null),f=(0,Y.useMemo)(()=>o.map(v=>v.address.toLowerCase()+"|"+v.decimals+"|"+v.symbol).join(","),[o]),d=(0,Y.useMemo)(()=>(0,ft.resolveChain)(n,s),[s,n]),y=d?(0,ft.chainNumber)(d):null,C=(0,Y.useMemo)(()=>d?(0,ft.toViemChain)(d,y):null,[d,y]),[w,E]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{if(!C||!d?.rpcUrl){E(null);return}let v=(0,gt.createPublicClient)({transport:(0,gt.http)(d.rpcUrl),chain:C});E(v)},[d,C]);let R=[{name:"balanceOf",type:"function",stateMutability:"view",inputs:[{name:"owner",type:"address"}],outputs:[{name:"balance",type:"uint256"}]}],A=(0,Y.useCallback)(async()=>{if(!t||!w||o.length===0){i([]);return}u(!0),h(null);try{let v=t.includes(":")?t.split(":").pop():t,b=(await Promise.allSettled(o.map(async I=>{try{let W=await w.readContract({address:I.address,abi:R,functionName:"balanceOf",args:[v]});return{address:I.address,symbol:I.symbol,decimals:I.decimals,name:I.name,balance:W.toString(),formatted:(0,gt.formatUnits)(W,I.decimals)}}catch{return{address:I.address,symbol:I.symbol,decimals:I.decimals,name:I.name,balance:null,formatted:null}}}))).map(I=>I.status==="fulfilled"?I.value:{address:"",symbol:"?",decimals:0,balance:null,formatted:null});i(b)}catch(v){h(v instanceof Error?v:new Error("Failed to fetch token balances"))}finally{u(!1)}},[t,w,f]);(0,Y.useEffect)(()=>{r&&t&&o.length>0&&A()},[r,t,f,A]),(0,Y.useEffect)(()=>(a&&a>0&&r&&t&&o.length>0&&(p.current=setInterval(A,a)),()=>{p.current&&(clearInterval(p.current),p.current=null)}),[a,r,t,f,A]);let T=(0,Y.useCallback)(v=>l.find(x=>x.address.toLowerCase()===v.toLowerCase()),[l]);return{tokenBalances:l,isLoading:g,error:c,refetch:A,getTokenBalance:T,chain:d}}var Ae=require("react");function Uo(e,t,r){let s=kt(),n=r??s,[l,i]=(0,Ae.useState)([]),[g,u]=(0,Ae.useState)(!1),[c,h]=(0,Ae.useState)(null),o=(0,Ae.useRef)(0),a=(0,Ae.useCallback)(async()=>{if(n){u(!0),h(null),o.current++;try{let f=await n.getTxHistory(e,t);i(f)}catch(f){h(f instanceof Error?f:new Error(String(f)))}finally{u(!1)}}},[n,e,t]);(0,Ae.useEffect)(()=>{a().catch(()=>{})},[a]),(0,Ae.useEffect)(()=>{if(!n)return;let f=()=>{a().catch(()=>{})};return n.on("statusChange",f),()=>{n.off("statusChange",f)}},[n,a]);let p={pending:l.filter(f=>f.status==="pending").length,confirmed:l.filter(f=>f.status==="confirmed").length,failed:l.filter(f=>f.status==="failed").length};return{entries:l,isLoading:g,error:c,refresh:a,summary:p}}var dn=require("@naculus/connect-appkit-core"),V=require("react");function Po(e){let t=e?.bundlerUrl,r=e?.pollInterval??2e3,s=e?.maxRetries??30,[n,l]=(0,V.useState)("idle"),[i,g]=(0,V.useState)(null),[u,c]=(0,V.useState)(e?.userOpHash??null),[h,o]=(0,V.useState)(null),[a,p]=(0,V.useState)(!1),[f,d]=(0,V.useState)(0),y=(0,V.useRef)(0),[C,w]=(0,V.useState)(0),E=(0,V.useRef)(null),R=(0,V.useRef)(null),A=(0,V.useRef)(0),T=(0,V.useRef)(0),v=(0,V.useRef)(null),x=(0,V.useCallback)(()=>{E.current&&(clearInterval(E.current),E.current=null),R.current&&(clearTimeout(R.current),R.current=null)},[]),b=(0,V.useCallback)(async(q,m)=>{if(!t||m!==A.current)return;let S=T.current+1;T.current=S,d(S);let k=new AbortController;v.current=k;let P=D=>{m===A.current&&(l("not_found"),p(!1),x(),o(D))},_=D=>{if(m===A.current){if(S<=s){R.current=setTimeout(()=>{b(q,m)},r);return}P(D)}};try{let D=await(0,dn.fetchUserOperationReceipt)(t,q,k.signal);if(m!==A.current)return;if(D){g(D),l(D.success?"confirmed":"failed"),p(!1),x();return}l("pending"),_(new Error("UserOperation not included after maximum retries"))}catch(D){if(m!==A.current||k.signal.aborted)return;let Me=D instanceof Error?D:new Error("Unknown bundler response failure");if(Me instanceof dn.InvalidUserOperationReceiptError){P(Me);return}_(new Error(`UserOperation status unavailable after ${S} attempt${S===1?"":"s"}: ${Me.message}`))}finally{v.current===k&&(v.current=null)}},[t,r,s,x]),I=(0,V.useCallback)(q=>{A.current+=1;let m=A.current;if(v.current?.abort(),v.current=null,x(),c(q),g(null),o(null),T.current=0,d(0),w(0),y.current=Date.now(),!t){l("not_found"),p(!1),o(new Error("Bundler URL not configured"));return}l("pending"),p(!0),E.current=setInterval(()=>{w(Date.now()-y.current)},1e3),b(q,m)},[t,x,b]),W=(0,V.useCallback)(()=>{A.current+=1,v.current?.abort(),v.current=null,x(),p(!1)},[x]),F=(0,V.useCallback)(()=>{A.current+=1,v.current?.abort(),v.current=null,x(),c(null),l("idle"),g(null),o(null),p(!1),T.current=0,d(0),w(0)},[x]);return(0,V.useEffect)(()=>{e?.userOpHash&&e?.autoStart!==!1&&I(e.userOpHash)},[]),(0,V.useEffect)(()=>()=>{A.current+=1,v.current?.abort(),v.current=null,x()},[x]),{status:n,receipt:i,userOpHash:u,error:h,isPolling:a,elapsedMs:C,attempts:f,start:I,stop:W,reset:F}}var _o=require("@naculus/connect-appkit-core"),Do=require("react");var Ks={"storage.critical.title":"Insecure Storage Detected","storage.critical.body":"Your browser does not support IndexedDB. Wallet data is stored in plaintext in localStorage and could be exposed to XSS attacks. We strongly recommend switching to a modern browser.","storage.warning.title":"Storage Security Warning","storage.warning.body":"Your browser does not support IndexedDB, but your wallet data is encrypted with AES-256-GCM. Consider switching browsers for better origin isolation.","address.empty":"Address is empty","address.invalid_format":"Invalid address format (expected 0x + 40 hex chars)","address.zero_address":"Address is the zero address \u2014 funds would be permanently lost","address.burn_address":"Address appears to be a burn address \u2014 funds would be permanently lost","wallet.connect":"Connect Wallet","wallet.disconnect":"Disconnect","wallet.connecting":"Connecting...","wallet.copy_address":"Copy address","wallet.copied":"Copied!","wallet.view_on_explorer":"View on Explorer","wallet.retry":"Retry","wallet.connection_failed":"Connection failed","wallet.scan_qr":"Scan with your wallet app","embedded.generate":"Create Wallet","embedded.import":"Import Wallet","embedded.backup_seed":"Back up your seed phrase","embedded.backup_warning":"Anyone with your seed phrase can access your funds. Store it securely.","embedded.backup_done":"I've saved my seed phrase","embedded.wipe":"Remove Wallet","embedded.wipe_confirm":"Are you sure? This cannot be undone."},qs={"storage.critical.title":"\u5075\u6E2C\u5230\u4E0D\u5B89\u5168\u5132\u5B58","storage.critical.body":"\u60A8\u7684\u700F\u89BD\u5668\u4E0D\u652F\u63F4 IndexedDB\u3002\u9322\u5305\u8CC7\u6599\u4EE5\u660E\u6587\u5132\u5B58\u5728 localStorage \u4E2D\uFF0C\u53EF\u80FD\u66B4\u9732\u65BC XSS \u653B\u64CA\u3002\u5F37\u70C8\u5EFA\u8B70\u66F4\u63DB\u81F3\u73FE\u4EE3\u700F\u89BD\u5668\u3002","storage.warning.title":"\u5132\u5B58\u5B89\u5168\u8B66\u544A","storage.warning.body":"\u60A8\u7684\u700F\u89BD\u5668\u4E0D\u652F\u63F4 IndexedDB\uFF0C\u4F46\u9322\u5305\u8CC7\u6599\u5DF2\u4F7F\u7528 AES-256-GCM \u52A0\u5BC6\u3002\u5EFA\u8B70\u66F4\u63DB\u700F\u89BD\u5668\u4EE5\u7372\u5F97\u66F4\u597D\u7684\u9694\u96E2\u4FDD\u8B77\u3002","address.empty":"\u5730\u5740\u70BA\u7A7A","address.invalid_format":"\u7121\u6548\u7684\u5730\u5740\u683C\u5F0F\uFF08\u61C9\u70BA 0x + 40 \u500B\u5341\u516D\u9032\u4F4D\u5B57\u5143\uFF09","address.zero_address":"\u6B64\u70BA\u96F6\u5730\u5740 \u2014 \u8CC7\u91D1\u5C07\u6C38\u4E45\u4E1F\u5931","address.burn_address":"\u6B64\u5730\u5740\u70BA\u71D2\u6BC0\u5730\u5740 \u2014 \u8CC7\u91D1\u5C07\u6C38\u4E45\u4E1F\u5931","wallet.connect":"\u9023\u63A5\u9322\u5305","wallet.disconnect":"\u65B7\u958B\u9023\u7DDA","wallet.connecting":"\u9023\u7DDA\u4E2D...","wallet.copy_address":"\u8907\u88FD\u5730\u5740","wallet.copied":"\u5DF2\u8907\u88FD\uFF01","wallet.view_on_explorer":"\u5728\u700F\u89BD\u5668\u67E5\u770B","wallet.retry":"\u91CD\u8A66","wallet.connection_failed":"\u9023\u7DDA\u5931\u6557","wallet.scan_qr":"\u4F7F\u7528\u9322\u5305 App \u6383\u63CF","embedded.generate":"\u5EFA\u7ACB\u9322\u5305","embedded.import":"\u532F\u5165\u9322\u5305","embedded.backup_seed":"\u5099\u4EFD\u52A9\u8A18\u8A5E","embedded.backup_warning":"\u4EFB\u4F55\u4EBA\u53D6\u5F97\u60A8\u7684\u52A9\u8A18\u8A5E\u90FD\u53EF\u4EE5\u5B58\u53D6\u60A8\u7684\u8CC7\u91D1\u3002\u8ACB\u5B89\u5168\u5132\u5B58\u3002","embedded.backup_done":"\u6211\u5DF2\u5132\u5B58\u52A9\u8A18\u8A5E","embedded.wipe":"\u79FB\u9664\u9322\u5305","embedded.wipe_confirm":"\u78BA\u5B9A\u8981\u79FB\u9664\u55CE\uFF1F\u6B64\u64CD\u4F5C\u7121\u6CD5\u5FA9\u539F\u3002"},Wo={en:Ks,zh:qs},rr="en";function Oo(e){rr=e}function No(){return rr}function mn(e){return Wo[rr][e]??Wo.en[e]??e}function or(e){let{isValid:t,level:r,issue:s}=(0,_o.validateDestination)(e);return{isValid:t,level:r,warning:s?mn(`address.${s}`):null}}function Mo({address:e}){return{validation:(0,Do.useMemo)(()=>or(e),[e])}}function Lo(){let{status:e,session:t,accounts:r,chainId:s,error:n,connect:l,disconnect:i,reconnect:g,switchChain:u}=U(),c=e==="connected",h=e==="connecting",o=e==="reconnecting",a=r[0]??null;return{status:e,session:t,accounts:r,chainId:s,error:n,isConnected:c,isConnecting:h,isReconnecting:o,isDisconnected:e==="disconnected",currentAccount:a,connect:l,disconnect:i,reconnect:g,switchChain:u}}var Qe=require("react");var sr={wallet_unavailable:"Wallet Not Detected",user_rejected:"Connection Rejected",deeplink_timeout:"Wallet Connection Timed Out",session_expired:"Session Expired",intent_expired:"Connection Request Expired",namespace_mismatch:"Network Mismatch",chain_unsupported:"Unsupported Network",method_not_allowed:"Action Not Allowed",signature_rejected:"Signature Rejected",tx_failed:"Transaction Failed"},ar={wallet_unavailable:"No wallet found. Please install a compatible wallet (e.g., MetaMask, WalletConnect) and try again.",user_rejected:"The connection request was declined in your wallet. You can try again whenever you're ready.",deeplink_timeout:"The wallet didn't respond in time. This can happen if the wallet app isn't installed or takes too long to open.",session_expired:"Your wallet session has expired. Please reconnect to continue.",intent_expired:"The connection request expired. Please try connecting again.",namespace_mismatch:"This wallet doesn't support the required network. Try using a different wallet or network.",chain_unsupported:"This network isn't supported. Please switch to a supported network in your wallet.",method_not_allowed:"This action isn't supported by your current wallet or network.",signature_rejected:"The signature request was declined in your wallet.",tx_failed:"The transaction couldn't be completed. This could be due to insufficient funds, network congestion, or a contract error."},Rt="Something went wrong",Tt="An unexpected error occurred. Please try again. If the problem persists, check your connection and wallet configuration.";function ht(e){if(!e)return{title:Rt,description:Tt};let t=e;if(t.name==="WalletError"&&t.code){let r=t.code,s=sr[r]??Rt,n=ar[r]??t.message??Tt;return{title:s,description:n,code:r}}if(e instanceof Error){let r=e.message;return/user rejected/i.test(r)||/rejected/.test(r)?{title:"Request Rejected",description:"The request was declined.",code:"user_rejected"}:/timeout/i.test(r)||/timed? ?out/i.test(r)?{title:"Request Timed Out",description:"The request took too long. Please try again.",code:"deeplink_timeout"}:/insufficient funds/i.test(r)?{title:"Insufficient Funds",description:"You don't have enough funds to complete this transaction.",code:"tx_failed"}:/network/i.test(r)||/chain/i.test(r)?{title:"Network Error",description:r,code:"chain_unsupported"}:{title:Rt,description:r||Tt}}return typeof e=="string"?{title:Rt,description:e||Tt}:{title:Rt,description:Tt}}function fn(e){if(e===null||typeof e!="object")return!1;let t=e;return t.name!=="WalletError"||!t.code?!1:["deeplink_timeout","session_expired","intent_expired","tx_failed"].includes(t.code)}function Bo(){let{error:e,clearError:t}=U(),r=(0,Qe.useMemo)(()=>e?ht(e):null,[e]),s=(0,Qe.useMemo)(()=>e?fn(e):!1,[e]),n=(0,Qe.useCallback)(()=>{t()},[t]),l=(0,Qe.useCallback)(g=>ht(g),[]),i=(0,Qe.useCallback)(g=>async()=>{try{return await g()}catch(u){let c=ht(u);if(u instanceof Error){let h=u;try{h.title=c.title,h.friendlyMessage=c.description,h.code===void 0&&c.code!==void 0&&(h.code=c.code)}catch{}throw h}throw Object.assign(new Error(c.description,{cause:u}),{title:c.title,code:c.code,friendlyMessage:c.description})}},[]);return{error:e,friendlyError:r,clearError:n,isRetryable:s,formatError:l,wrapAsync:i}}var Ee=require("react"),Fo=require("@naculus/connect-core"),ir=require("@naculus/connect-appkit-core");function It(e,t){let r=(0,Ee.useRef)(null),[s,n]=(0,Ee.useState)([]),[l,i]=(0,Ee.useState)(t?.autoLoad!==!1),[g,u]=(0,Ee.useState)(!1),[c,h]=(0,Ee.useState)(null);if(!r.current){let p={};t?.sources&&(p.sources=t.sources),r.current=new Fo.TokenListManager(p)}let o=(0,Ee.useCallback)(async()=>{let p=r.current;if(p){i(!0),h(null);try{await p.load();let f=e?(0,ir.eip155ChainIdToNumber)(e):void 0,d=p.getTokens(f!==void 0?{chainId:f}:void 0);n(d),u(!0)}catch(f){h(f instanceof Error?f:new Error(String(f)))}finally{i(!1)}}},[e]),a=(0,Ee.useCallback)(async()=>{let p=r.current;if(p){i(!0),h(null);try{await p.refresh();let f=e?(0,ir.eip155ChainIdToNumber)(e):void 0,d=p.getTokens(f!==void 0?{chainId:f}:void 0);n(d),u(!0)}catch(f){h(f instanceof Error?f:new Error(String(f)))}finally{i(!1)}}},[e]);return(0,Ee.useEffect)(()=>{t?.autoLoad!==!1&&o()},[o,t?.autoLoad]),{tokens:s,isLoading:l,isLoaded:g,error:c,refetch:a}}var Xe=require("react"),Ko=require("@naculus/connect-core");var Ne=require("@naculus/connect-core");function Ho(){return[{name:"built-in",tokens:[...Ne.ETHEREUM_MAINNET_TOKENS,...Ne.POLYGON_TOKENS,...Ne.OPTIMISM_TOKENS,...Ne.ARBITRUM_TOKENS,...Ne.BASE_TOKENS],enabled:!0},{name:"uniswap-default",url:"https://tokens.uniswap.org",enabled:!0,refreshInterval:1440*60*1e3}]}var qo=require("@naculus/connect-appkit-core"),Vs=300,gn=null;function $s(){return gn||(gn=new Ko.TokenListManager({sources:Ho()}),gn.load().catch(()=>{})),gn}function Ut(e,t){let[r,s]=(0,Xe.useState)({exact:[],fuzzy:[],hasMore:!1}),[n,l]=(0,Xe.useState)(!1),i=(0,Xe.useRef)(null),g=e.trim();return(0,Xe.useEffect)(()=>{if(!g){s({exact:[],fuzzy:[],hasMore:!1}),l(!1);return}return i.current&&clearTimeout(i.current),l(!0),i.current=setTimeout(()=>{let u=$s(),c=t?(0,qo.eip155ChainIdToNumber)(t):void 0,h=u.search(g,{chainId:c,limit:20});s(h),l(!1)},Vs),()=>{i.current&&clearTimeout(i.current)}},[g,t]),{results:r,isSearching:n}}var Ct=Le(require("react"),1);var B=require("react/jsx-runtime");function lr({chainId:e,onSelect:t,onClose:r,options:s}){let[n,l]=Ct.default.useState(""),{tokens:i,isLoading:g,error:u}=It(e),{results:c,isSearching:h}=Ut(n,n?e:void 0),o=s?.showRecommendations??!0,a=Ct.default.useMemo(()=>{if(n.trim()){let y=[...c.exact,...c.fuzzy].map(C=>C.token);return s?.filter?y.filter(s.filter):y}let d=i;return s?.filter?d.filter(s.filter):d},[n,c,i,s?.filter]),p=Ct.default.useMemo(()=>!o||n.trim()?[]:i.slice(0,6),[i,o,n]),f=(0,Ct.useCallback)(d=>{t(d),r()},[t,r]);return(0,B.jsxs)("div",{style:{background:"hsl(var(--background))",borderRadius:"12px",padding:"16px",color:"hsl(var(--foreground))",minWidth:"320px",maxWidth:"400px",fontFamily:"system-ui, sans-serif"},children:[(0,B.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[(0,B.jsx)("h3",{style:{margin:0,fontSize:"16px",fontWeight:600},children:"Select Token"}),(0,B.jsx)("button",{onClick:r,style:{background:"none",border:"none",color:"hsl(var(--muted-foreground))",cursor:"pointer",fontSize:"18px",padding:"4px 8px"},children:"\u2715"})]}),(0,B.jsx)("input",{type:"text",placeholder:"Search token name or paste address",value:n,onChange:d=>l(d.target.value),style:{width:"100%",padding:"10px 12px",borderRadius:"8px",border:"1px solid #333",background:"hsl(var(--card))",color:"hsl(var(--foreground))",fontSize:"14px",outline:"none",boxSizing:"border-box",marginBottom:"12px"},autoFocus:!0}),g&&!h&&(0,B.jsx)("div",{style:{textAlign:"center",padding:"20px",color:"hsl(var(--muted-foreground))"},children:"Loading tokens..."}),u&&(0,B.jsxs)("div",{style:{textAlign:"center",padding:"12px",color:"hsl(var(--destructive))",fontSize:"13px"},children:["Error: ",u.message]}),o&&p.length>0&&!n.trim()&&(0,B.jsxs)("div",{style:{marginBottom:"12px"},children:[(0,B.jsx)("div",{style:{fontSize:"11px",color:"hsl(var(--muted-foreground))",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"8px"},children:"Popular"}),(0,B.jsx)("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap"},children:p.map(d=>(0,B.jsxs)("button",{onClick:()=>f(d),style:{background:"hsl(var(--card))",border:"1px solid #333",borderRadius:"20px",padding:"6px 14px",color:"hsl(var(--foreground))",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",gap:"4px"},children:[d.logoURI?(0,B.jsx)("img",{src:d.logoURI,alt:"",style:{width:"16px",height:"16px",borderRadius:"50%"},onError:y=>{y.target.style.display="none"}}):null,d.symbol]},`${d.chainId}:${d.address}`))})]}),n.trim()&&!g&&(0,B.jsx)("div",{style:{fontSize:"11px",color:"hsl(var(--muted-foreground))",marginBottom:"8px"},children:a.length>0?(0,B.jsxs)(B.Fragment,{children:[c.exact.length," exact, ",c.fuzzy.length," fuzzy",c.hasMore?" (more available)":""]}):"No results found"}),(0,B.jsx)("div",{style:{maxHeight:"320px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"2px"},children:a.map(d=>(0,B.jsxs)("button",{onClick:()=>f(d),style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 8px",background:"transparent",border:"none",borderRadius:"8px",color:"hsl(var(--foreground))",cursor:"pointer",textAlign:"left",width:"100%",fontSize:"14px"},onMouseEnter:y=>{y.target.style.background="hsl(var(--card))"},onMouseLeave:y=>{y.target.style.background="transparent"},children:[(0,B.jsx)("div",{style:{width:"32px",height:"32px",borderRadius:"50%",background:"hsl(var(--border))",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:600,flexShrink:0,overflow:"hidden"},children:d.logoURI?(0,B.jsx)("img",{src:d.logoURI,alt:d.symbol,style:{width:"100%",height:"100%"},onError:y=>{let C=y.target;C.style.display="none",C.parentElement.textContent=d.symbol.slice(0,2)}}):d.symbol.slice(0,2)}),(0,B.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,B.jsx)("div",{style:{fontWeight:600,fontSize:"14px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.symbol}),(0,B.jsx)("div",{style:{fontSize:"12px",color:"hsl(var(--muted-foreground))",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.name})]}),(0,B.jsxs)("div",{style:{fontSize:"11px",color:"#666",textAlign:"right",flexShrink:0},children:[(0,B.jsxs)("div",{children:[d.decimals," decimals"]}),(0,B.jsxs)("div",{children:["Chain ",d.chainId]})]})]},`${d.chainId}:${d.address}`))})]})}var M=require("@stencil/react-output-target/runtime"),L=Le(require("react"),1),hn=require("@naculus/connect-appkit-wc/dist/components/appkit-accordion.js"),Cn=require("@naculus/connect-appkit-wc/dist/components/appkit-account-button.js"),yn=require("@naculus/connect-appkit-wc/dist/components/appkit-alert-dialog.js"),Sn=require("@naculus/connect-appkit-wc/dist/components/appkit-avatar.js"),En=require("@naculus/connect-appkit-wc/dist/components/appkit-badge.js"),wn=require("@naculus/connect-appkit-wc/dist/components/appkit-button.js"),kn=require("@naculus/connect-appkit-wc/dist/components/appkit-card-content.js"),xn=require("@naculus/connect-appkit-wc/dist/components/appkit-card-description.js"),vn=require("@naculus/connect-appkit-wc/dist/components/appkit-card-footer.js"),An=require("@naculus/connect-appkit-wc/dist/components/appkit-card-header.js"),bn=require("@naculus/connect-appkit-wc/dist/components/appkit-card-title.js"),Rn=require("@naculus/connect-appkit-wc/dist/components/appkit-card.js"),Tn=require("@naculus/connect-appkit-wc/dist/components/appkit-checkbox.js"),In=require("@naculus/connect-appkit-wc/dist/components/appkit-collapsible.js"),Un=require("@naculus/connect-appkit-wc/dist/components/appkit-connect-button.js"),Pn=require("@naculus/connect-appkit-wc/dist/components/appkit-dialog.js"),Wn=require("@naculus/connect-appkit-wc/dist/components/appkit-dropdown-menu.js"),On=require("@naculus/connect-appkit-wc/dist/components/appkit-input.js"),Nn=require("@naculus/connect-appkit-wc/dist/components/appkit-popover.js"),_n=require("@naculus/connect-appkit-wc/dist/components/appkit-progress.js"),Dn=require("@naculus/connect-appkit-wc/dist/components/appkit-scroll-area.js"),Mn=require("@naculus/connect-appkit-wc/dist/components/appkit-select.js"),Ln=require("@naculus/connect-appkit-wc/dist/components/appkit-separator.js"),Bn=require("@naculus/connect-appkit-wc/dist/components/appkit-skeleton.js"),Fn=require("@naculus/connect-appkit-wc/dist/components/appkit-switch.js"),Hn=require("@naculus/connect-appkit-wc/dist/components/appkit-tabs.js"),Kn=require("@naculus/connect-appkit-wc/dist/components/appkit-toggle-group.js"),qn=require("@naculus/connect-appkit-wc/dist/components/appkit-tooltip.js"),Vo=(0,M.createComponent)({tagName:"appkit-accordion",elementClass:hn.AppkitAccordion,react:L.default,events:{onAppkitToggle:"appkitToggle"},defineCustomElement:hn.defineCustomElement}),$o=(0,M.createComponent)({tagName:"appkit-account-button",elementClass:Cn.AppkitAccountButton,react:L.default,events:{},defineCustomElement:Cn.defineCustomElement}),Go=(0,M.createComponent)({tagName:"appkit-alert-dialog",elementClass:yn.AppkitAlertDialog,react:L.default,events:{onAppkitClose:"appkitClose",onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:yn.defineCustomElement}),jo=(0,M.createComponent)({tagName:"appkit-avatar",elementClass:Sn.AppkitAvatar,react:L.default,events:{},defineCustomElement:Sn.defineCustomElement}),zo=(0,M.createComponent)({tagName:"appkit-badge",elementClass:En.AppkitBadge,react:L.default,events:{},defineCustomElement:En.defineCustomElement}),Qo=(0,M.createComponent)({tagName:"appkit-button",elementClass:wn.AppkitButton,react:L.default,events:{},defineCustomElement:wn.defineCustomElement}),Xo=(0,M.createComponent)({tagName:"appkit-card",elementClass:Rn.AppkitCard,react:L.default,events:{},defineCustomElement:Rn.defineCustomElement}),Yo=(0,M.createComponent)({tagName:"appkit-card-content",elementClass:kn.AppkitCardContent,react:L.default,events:{},defineCustomElement:kn.defineCustomElement}),Jo=(0,M.createComponent)({tagName:"appkit-card-description",elementClass:xn.AppkitCardDescription,react:L.default,events:{},defineCustomElement:xn.defineCustomElement}),Zo=(0,M.createComponent)({tagName:"appkit-card-footer",elementClass:vn.AppkitCardFooter,react:L.default,events:{},defineCustomElement:vn.defineCustomElement}),es=(0,M.createComponent)({tagName:"appkit-card-header",elementClass:An.AppkitCardHeader,react:L.default,events:{},defineCustomElement:An.defineCustomElement}),ts=(0,M.createComponent)({tagName:"appkit-card-title",elementClass:bn.AppkitCardTitle,react:L.default,events:{},defineCustomElement:bn.defineCustomElement}),ns=(0,M.createComponent)({tagName:"appkit-checkbox",elementClass:Tn.AppkitCheckbox,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Tn.defineCustomElement}),rs=(0,M.createComponent)({tagName:"appkit-collapsible",elementClass:In.AppkitCollapsible,react:L.default,events:{onAppkitToggle:"appkitToggle"},defineCustomElement:In.defineCustomElement}),os=(0,M.createComponent)({tagName:"appkit-connect-button",elementClass:Un.AppkitConnectButton,react:L.default,events:{onAppkitConnect:"appkitConnect",onAppkitDisconnect:"appkitDisconnect",onAppkitStartPairing:"appkitStartPairing",onAppkitRetry:"appkitRetry",onAppkitCancelPairing:"appkitCancelPairing",onAppkitMobileDeepLink:"appkitMobileDeepLink",onAppkitCopyAddress:"appkitCopyAddress"},defineCustomElement:Un.defineCustomElement}),ss=(0,M.createComponent)({tagName:"appkit-dialog",elementClass:Pn.AppkitDialog,react:L.default,events:{onAppkitClose:"appkitClose",onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:Pn.defineCustomElement}),as=(0,M.createComponent)({tagName:"appkit-dropdown-menu",elementClass:Wn.AppkitDropdownMenu,react:L.default,events:{onAppkitSelect:"appkitSelect"},defineCustomElement:Wn.defineCustomElement}),is=(0,M.createComponent)({tagName:"appkit-input",elementClass:On.AppkitInput,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:On.defineCustomElement}),ls=(0,M.createComponent)({tagName:"appkit-popover",elementClass:Nn.AppkitPopover,react:L.default,events:{onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:Nn.defineCustomElement}),cs=(0,M.createComponent)({tagName:"appkit-progress",elementClass:_n.AppkitProgress,react:L.default,events:{},defineCustomElement:_n.defineCustomElement}),us=(0,M.createComponent)({tagName:"appkit-scroll-area",elementClass:Dn.AppkitScrollArea,react:L.default,events:{},defineCustomElement:Dn.defineCustomElement}),ps=(0,M.createComponent)({tagName:"appkit-select",elementClass:Mn.AppkitSelect,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Mn.defineCustomElement}),ds=(0,M.createComponent)({tagName:"appkit-separator",elementClass:Ln.AppkitSeparator,react:L.default,events:{},defineCustomElement:Ln.defineCustomElement}),ms=(0,M.createComponent)({tagName:"appkit-skeleton",elementClass:Bn.AppkitSkeleton,react:L.default,events:{},defineCustomElement:Bn.defineCustomElement}),fs=(0,M.createComponent)({tagName:"appkit-switch",elementClass:Fn.AppkitSwitch,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Fn.defineCustomElement}),gs=(0,M.createComponent)({tagName:"appkit-tabs",elementClass:Hn.AppkitTabs,react:L.default,events:{onAppkitTabChange:"appkitTabChange"},defineCustomElement:Hn.defineCustomElement}),hs=(0,M.createComponent)({tagName:"appkit-toggle-group",elementClass:Kn.AppkitToggleGroup,react:L.default,events:{onAppkitChange:"appkitChange"},defineCustomElement:Kn.defineCustomElement}),Cs=(0,M.createComponent)({tagName:"appkit-tooltip",elementClass:qn.AppkitTooltip,react:L.default,events:{},defineCustomElement:qn.defineCustomElement});0&&(module.exports={AppkitAccordion,AppkitAccountButton,AppkitAlertDialog,AppkitAvatar,AppkitBadge,AppkitButton,AppkitCard,AppkitCardContent,AppkitCardDescription,AppkitCardFooter,AppkitCardHeader,AppkitCardTitle,AppkitCheckbox,AppkitCollapsible,AppkitConnectButton,AppkitDialog,AppkitDropdownMenu,AppkitInput,AppkitPopover,AppkitProgress,AppkitScrollArea,AppkitSelect,AppkitSeparator,AppkitSkeleton,AppkitSwitch,AppkitTabs,AppkitToggleGroup,AppkitTooltip,DEFAULT_EVM_CHAINS,LAMPORTS_PER_SOL,PassphraseCancelledError,PassphraseGate,SolanaRpcError,TokenSelector,TxMonitorContext,WALLET_ERROR_DESCRIPTIONS,WALLET_ERROR_TITLES,Web3ConnectProvider,Web3Context,buildDelegationPolicyMessage,clearClient,createClient,formatSol,getChainById,getClient,getDefaultChains,getLatestBlockhash,getLocale,getSignatureStatus,getSolanaBalance,getUserFriendlyError,isRetryableError,parseSol,resetSessionKeyManager,setLocale,t,useAccount,useBalance,useCapabilities,useChain,useCompareCosts,useConnect,useCreateSessionKey,useDelegate,useDelegation,useDelegationPolicy,useDisconnect,useERC20Allowance,useERC20Approve,useERC20Transfer,useERC20TransferSimulation,useEmbeddedWallet,useExecuteCalls,useExecuteRoute,useLastTx,useLookupAddress,useNotification,usePassphraseGate,usePaymentFetch,useResolveName,useRevokeSession,useRouteQuote,useSIWxLogin,useSIWxSession,useSendCalls,useSendTransaction,useSendUserOperation,useSendWithSession,useSession,useSessionKeys,useSignInWithEthereum,useSignInWithX,useSignMessage,useSimulateTransfer,useSiwxAuthSession,useSmartAccount,useSolanaAccount,useSolanaBalance,useSolanaRoles,useSolanaTransaction,useSwitchChain,useTokenBalance,useTokenList,useTokenSearch,useTransactionSimulation,useTxHistory,useTxMonitor,useUserOpStatus,useValidateDestination,useViemClient,useWallet,useWeb3,useWeb3ErrorHandler,validateDestination});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|