@naculus/connect-appkit-react 0.13.0 → 0.15.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.js CHANGED
@@ -1,2 +1,2 @@
1
- import{formatSol as Ay,getLatestBlockhash as by,getSignatureStatus as Ry,getSolanaBalance as Ty,LAMPORTS_PER_SOL as Iy,PassphraseCancelledError as Uy,PassphraseGate as Py,parseSol as Wy,SolanaRpcError as Oy}from"@naculus/connect-core";import{compareCostsKey as jr}from"@naculus/connect-appkit-core";import{useCallback as pn,useEffect as dn,useRef as mn,useState as ot}from"react";function fn(e,t){let{operation:o,chains:s,options:n}=e,[c,i]=ot([]),[h,u]=ot(!1),[l,g]=ot(null),r=mn(!0),a=mn(0),p=jr(e),d=pn(async()=>{if(!s||s.length===0){i([]);return}if(!t)return;let C=++a.current;u(!0),g(null);try{let E=await t(o,s,n);r.current&&C===a.current&&i(E)}catch(E){r.current&&C===a.current&&(g(E instanceof Error?E:new Error(String(E))),i([]))}finally{r.current&&C===a.current&&u(!1)}},[p,t]);dn(()=>{d()},[d]),dn(()=>(r.current=!0,()=>{r.current=!1}),[]);let m=pn(async()=>{await d()},[d]);return{comparisons:c,loading:h,error:l,refresh:m}}import{toExecuteRouteError as $r,validateRouteRecipient as Gr}from"@naculus/connect-appkit-core";import{useCallback as gn,useEffect as Xr,useRef as hn,useState as st}from"react";function yn(e){let[t,o]=st(!1),[s,n]=st(null),[c,i]=st(null),h=hn(!0),u=hn(!1);Xr(()=>(h.current=!0,()=>{h.current=!1}),[]);let l=gn(async(r,a,p)=>{if(!e)return i({code:"no_executor",message:"No executeRoute function provided"}),n(null),null;let d=Gr(r,a);if(d)return i(d),n(null),null;if(u.current)return i({code:"execution_in_progress",message:"A route execution is already in progress"}),null;u.current=!0,o(!0),i(null),n(null);try{let m=await e(r,a,p);return h.current&&n(m),m}catch(m){return h.current&&i($r(m)),null}finally{u.current=!1,h.current&&o(!1)}},[e]),g=gn(()=>{n(null),i(null),o(!1)},[]);return{execute:l,executing:t,result:s,error:c,reset:g}}import{isQuotableInput as Qr}from"@naculus/connect-appkit-core";import{useCallback as at,useEffect as Cn,useRef as Sn,useState as it}from"react";function En(e,t){let{fromChain:o,toChain:s,fromToken:n,toToken:c,amount:i,options:h}=e,[u,l]=it([]),[g,r]=it(!1),[a,p]=it(null),d=Sn(null),m=Sn(!0),C=at(async()=>{if(!Qr({fromChain:o,toChain:s,fromToken:n,amount:i})){l([]);return}if(t){r(!0),p(null);try{let y=await t(o,s,n,i,h,c);m.current&&l(y)}catch(y){m.current&&(p(y instanceof Error?y:new Error(String(y))),l([]))}finally{m.current&&r(!1)}}},[o,s,n,c,i,h,t]);Cn(()=>{if(d.current&&clearTimeout(d.current),!o||!s||!n||!i){l([]);return}return d.current=setTimeout(()=>{C()},300),()=>{d.current&&clearTimeout(d.current)}},[C,o,s,n,i]),Cn(()=>(m.current=!0,()=>{m.current=!1}),[]);let E=at(async()=>{await C()},[C]),A=at(()=>{l([]),p(null),r(!1)},[]);return{quotes:u,loading:g,error:a,refresh:E,clear:A}}import{logger as lt,WalletError as q}from"@naculus/connect-core";import{eip6963Connector as H}from"@naculus/connector-evm-injected";import{PassphraseGate as Yr}from"@naculus/connect-core";import{createWalletConnectConnector as Jr}from"@naculus/connector-walletconnect";var ct=null;function ut(e){let t=null,o=Jr({projectId:e.projectId,metadata:e.metadata,...e.walletConnect?.client?{client:e.walletConnect.client}:{},...e.walletConnect?.openUrl?{openUrl:e.walletConnect.openUrl}:{}}),s=null,n=null,c=null,i=null,h=e.passphrasePrompt&&e.enableEmbedded&&!e.embeddedConfig?.encryptionPassphrase?new Yr:null;e.enableEmbedded&&(n=import("@naculus/connector-embedded").then(r=>{let a={...e.embeddedConfig};h&&(a.encryptionPassphrase=h.request),e.enablePasskeys&&a.encryptionPassphrase&&!a.prfUnlock&&(a.prfUnlock={async derive(d){i&&await i;let m=c;return m?.hasCredential()?m.derivePrfKey(d):null}}),s=r.createPocketConnector(a),t?._setEmbeddedConnector(s)}).catch(r=>{lt.warn("react/client","Embedded wallet connector not available:",r),s=null})),e.enablePasskeys&&(i=import("@naculus/connector-passkeys").then(r=>{c=r.createPasskeysConnector(),t?._setPasskeysConnector(c)}).catch(r=>{lt.warn("react/client","Passkeys connector not available:",r),c=null}));let u=null,l=null;e.enableSolana&&(l=import("@naculus/connector-solana").then(r=>{let a=r.solanaConnector;e.solanaDefaultChain&&"configure"in a&&a.configure({defaultChain:e.solanaDefaultChain}),u=a,typeof window<"u"&&"startDiscovery"in a&&a.startDiscovery();for(let p of e.solanaWallets??[])a.registerWallet?.(p);t?._setSolanaConnector(u)}).catch(r=>{lt.warn("react/client","Solana connector not available:",r),u=null})),typeof window<"u"&&H.startDiscovery();for(let{info:r,provider:a}of e.injectedProviders??[])H.registerProvider(r,a);let g={connector:o,get embeddedConnector(){return s},getEmbeddedConnector:async()=>(n&&await n,s),get passkeysConnector(){return c},passphraseGate:h,solanaRpcUrl:e.solanaRpcUrl??null,get solanaConnector(){return u},connect:()=>o.connect(),connectInjected:async r=>H.connect(r),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,!c)throw new Error("Passkeys connector not enabled. Set enablePasskeys: true in config.");return c.connect()},startPairing:()=>o.startPairing(),completePairing:()=>o.completePairing(),cancelPairing:()=>o.cancelPairing?.(),signMessage:async(r,a)=>{if(r.id?.startsWith("eip6963-"))return H.signMessage(r,a);if(r.walletType==="passkeys"&&c)return c.signMessage(r,a);if(r.walletType==="embedded"){if(!s)throw new q("wallet_unavailable","Embedded wallet connector not available.");return s.signMessage(r,a)}if(r.walletType==="solana"){if(l&&await l,u)return u.signMessage(r,a);throw new q("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return o.signMessage(r,a)},signTransaction:async(r,a)=>{if(r.id?.startsWith("eip6963-"))return H.signTransaction(r,a);if(r.walletType==="embedded"){if(!s)throw new q("wallet_unavailable","Embedded wallet connector not available.");return s.signTransaction(r,a)}if(r.walletType==="solana"){if(l&&await l,u)return u.signTransaction(r,a);throw new q("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return o.signTransaction(r,a)},sendTransaction:async(r,a)=>{if(r.id?.startsWith("eip6963-"))return H.sendTransaction(r,a);if(r.walletType==="passkeys"&&c)return c.sendTransaction(r,a);if(r.walletType==="embedded"){if(!s)throw new q("wallet_unavailable","Embedded wallet connector not available.");return s.sendTransaction(r,a)}if(r.walletType==="solana"){if(l&&await l,u)return u.sendTransaction(r,a);throw new q("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return o.sendTransaction(r,a)},onAccountsChanged:(r,a)=>{let p=()=>{};return r.id?.startsWith("eip6963-")?H.onAccountsChanged?.(r,a)??p:r.walletType==="embedded"?s?.onAccountsChanged?.(r,a)??p:r.walletType==="passkeys"?p:r.walletType==="solana"?u?.onAccountsChanged?.(r,a)??p:o.onAccountsChanged?.(r,a)??p},onChainChanged:(r,a)=>{let p=()=>{};return r.id?.startsWith("eip6963-")?H.onChainChanged?.(r,a)??p:r.walletType==="passkeys"||r.walletType==="embedded"?p:r.walletType==="solana"?u?.onChainChanged?.(r,a)??p:o.onChainChanged?.(r,a)??p},getCapabilities:r=>r.id?.startsWith("eip6963-")?H.getCapabilities?.(r):r.walletType==="passkeys"?c?.getCapabilities?.(r):r.walletType==="solana"?u?.getCapabilities?.(r):r.walletType==="embedded"?s?.getCapabilities?.(r):o.getCapabilities?.(r),sendCalls:async(r,a,p,d)=>{if(r.id?.startsWith("eip6963-"))return H.sendCalls(r,a,p,d);if(r.walletType==="passkeys"&&c)return c.sendCalls(r,a,p,d);if(r.walletType==="solana"){if(l&&await l,u)return u.sendCalls(r,a,p,d);throw new q("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}if(r.walletType==="embedded"){if(!s?.sendCalls)throw new q("method_not_allowed","Embedded wallet does not support sendCalls");return s.sendCalls(r,a,p,d)}if(!o.sendCalls)throw new q("method_not_allowed","sendCalls not supported by this connector");return o.sendCalls(r,a,p,d)},showCallsStatus:async(r,a)=>{if(r.id?.startsWith("eip6963-"))return H.showCallsStatus(r,a);if(r.walletType==="passkeys"||r.walletType==="embedded")throw new q("method_unsupported",`${r.walletType} wallets have no UI to display a call bundle.`);if(!o.showCallsStatus)throw new q("method_unsupported","This connector cannot display call status.");return o.showCallsStatus(r,a)},getCallsStatus:async(r,a)=>{if(r.id?.startsWith("eip6963-")&&H.getCallsStatus)return H.getCallsStatus(r,a);if(r.walletType==="passkeys"&&c?.getCallsStatus)return c.getCallsStatus(r,a);if(r.walletType==="embedded")throw new q("method_not_allowed","Embedded wallet does not support getCallsStatus");if(!o.getCallsStatus)throw new q("method_not_allowed","getCallsStatus not supported by this connector");return o.getCallsStatus(r,a)},reconnect:async r=>r.walletType==="eip6963"?H.reconnect(r):r.walletType==="embedded"?s?s.reconnect(r):r:r.walletType==="solana"?r:o.reconnect(r),disconnect:async r=>{if(r.id?.startsWith("eip6963-")||r.walletType==="eip6963")return H.disconnect(r);if(r.walletType==="embedded"&&s)return s.disconnect();if(r.walletType==="passkeys"&&c)return c.disconnect(r);if(r.walletType==="solana"){if(l&&await l,u)return u.disconnect(r);throw new q("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return o.disconnect(r)},getAllConnectors:()=>{let r=[o];return s&&r.push(s),c&&r.push(c),u&&r.push(u),r},_setEmbeddedConnector:r=>{s=r},_setPasskeysConnector:r=>{c=r},_setSolanaConnector:r=>{u=r}};return t=g,ct=g,g}function pt(){return ct}function Zr(){ct=null}import{isEvmAddress as An,parseCaip10 as Ao}from"@naculus/connect-core";import{useMemo as bo}from"react";import{createConnectorManager as mo,createSessionManager as fo,LocalStorageSessionStorage as go,logger as Z,WalletError as ho}from"@naculus/connect-core";import{eip6963Connector as Oe}from"@naculus/connector-evm-injected";import{createContext as yo,useCallback as K,useContext as Co,useEffect as me,useMemo as fe,useReducer as So,useRef as vn}from"react";import{logger as eo}from"@naculus/connect-core";import{issueNonce as to,parseSiwxMessage as no}from"@naculus/siwx";function se(e,t){let o=t.split(":",1)[0],n=(e.namespaces[o]?.accounts??[]).filter(c=>c.startsWith(`${o}:`)).map(c=>({namespace:o,caip10:c}))[0];if(n)return{...n,address:n.caip10.split(":").pop()??n.caip10}}function ro(e){return e.namespaces.eip155?.chains?.[0]??e.namespaces.solana?.chains?.[0]??e.namespaces.xrpl?.chains?.[0]??"eip155:1"}async function wn(e){let{session:t,siwx:o,signMessage:s}=e;if(!o||!t)return{kind:"skipped"};try{let n=ro(t),c=se(t,n);if(!c)throw new Error("No account found in session");let{address:i}=c,h=await o.createMessage({address:i,chainId:n}),u=no(h);if(!u?.nonce)throw new Error("SIWx message must contain a nonce");await to(u.nonce);let l=await s(t,{message:h,address:i,chainId:n});return await o.handleSignComplete?.({message:h,signature:l}),{kind:"authenticated",address:i,chainId:n}}catch(n){let c=n instanceof Error?n:new Error("Wallet authentication failed");return eo.error("appkit/core","SIWx authentication failed:",n),{kind:"failed",error:c,fatal:o.required!==!1}}}import{initialWeb3State as Eo,web3Reducer as wo,withRetry as ko,withTimeout as xn}from"@naculus/connect-appkit-core";import{resolveChain as oo}from"@naculus/connect-appkit-core";import{CHAINS as We,DEFAULT_RPC_URLS as so,eip155Reference as ao,getRpcUrl as io}from"@naculus/connect-core";var lo=[{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 co(e){let t=We[e];if(!t||!t.explorerUrl)return null;let o=t.caip2Id;return{caip2:o,name:t.name,rpcUrl:io(o,so[o]??""),explorerUrl:t.explorerUrl,token:t.nativeCurrency.symbol}}function uo(){if(!We)return[];let e=[],t=Object.keys(We).map(Number).sort((o,s)=>o-s);for(let o of t){let s=co(o);s&&e.push(s)}for(let o of lo){let s=ao(o.caip2);(s===null||!We[s])&&e.push(o)}return e}var kn=uo();function po(e,t){return oo(e,t)??void 0}function dt(){return[...kn]}import{jsx as xo}from"react/jsx-runtime";var mt=yo(null);function vo({children:e,config:t,autoConnect:o=!0}){let[s,n]=So(wo,Eo),c=fe(()=>t.chains??dt(),[t.chains]),i=t.connectionTimeout??3e4,h=t.maxRetries??2,u=fe(()=>t.sessionStorage??new go(t.storageKey??"naculus_web3_session",t.encryptionKey),[t.sessionStorage,t.storageKey,t.encryptionKey]),l=fe(()=>ut({projectId:t.projectId,metadata:t.metadata,enableEmbedded:t.enableEmbedded,embeddedConfig:t.embeddedConfig,enablePasskeys:t.enablePasskeys,enableSolana:t.enableSolana,solanaDefaultChain:t.solanaDefaultChain,walletConnect:t.walletConnect,solanaWallets:t.solanaWallets,injectedProviders:t.injectedProviders}),[t.projectId,t.metadata,t.enableEmbedded,t.embeddedConfig,t.enablePasskeys,t.enableSolana,t.solanaDefaultChain,t.walletConnect,t.solanaWallets,t.injectedProviders]),g=vn(null),r=vn(null),a=fe(()=>{let f=mo();for(let O of[Oe,...l.getAllConnectors()])f.register(O.id,O);let S={},x={};for(let O of c){let F=O.caip2;O.rpcUrl&&(S[F]=O.rpcUrl),O.token&&(x[F]={name:O.name,symbol:O.token,decimals:18})}let P=fo(f,{autoRefreshFeeOnSwitch:t.autoRefreshFeeOnSwitch??!0,defaultRpcUrls:S,defaultCurrencies:x,encryptionKey:t.encryptionKey});return g.current=P,P},[l,c,t.autoRefreshFeeOnSwitch,t.encryptionKey]);me(()=>{let f=F=>{let{walletSession:ne}=F.bundle;n({type:"SET_SESSION",payload:ne});let V=[];Object.values(ne.namespaces).forEach(de=>{V.push(...de.accounts)}),n({type:"SET_ACCOUNTS",payload:V}),n({type:"SET_CHAIN",payload:F.bundle.activeChainId}),n({type:"SET_STATUS",payload:"connected"})},S=()=>{n({type:"RESET"})},x=F=>{n({type:"SET_CHAIN",payload:F.newChainId})},P=F=>f(F),O=()=>{u.clear(),n({type:"RESET"})};return a.on("sessionConnected",f),a.on("sessionDisconnected",S),a.on("chainChanged",x),a.on("sessionScopeChanged",P),a.on("sessionRevoked",O),()=>{a.off("sessionConnected",f),a.off("sessionDisconnected",S),a.off("chainChanged",x),a.off("sessionScopeChanged",P),a.off("sessionRevoked",O)}},[a,u]),me(()=>{let f=()=>{u.clear(),n({type:"RESET"})};l.connector.onSessionExpiry(f)},[l,u]);let p=K(()=>{for(let f of[Oe,...l.getAllConnectors()])a.registerConnector(f)},[l,a]),d=K(async f=>{p();let S=[Oe,...l.getAllConnectors()].find(P=>P.id===f.walletType||P.kind===f.walletType);S&&!f.connectorId&&(f.connectorId=S.id);let x=f.namespaces.eip155?.chains?.[0]??f.namespaces.solana?.chains?.[0]??f.namespaces.xrpl?.chains?.[0];x&&await a.attach(f,x)},[l,a,p]),m=K(f=>{if(n({type:"SET_SESSION",payload:f}),f){let S=[];Object.values(f.namespaces).forEach(F=>{S.push(...F.accounts)}),n({type:"SET_ACCOUNTS",payload:S});let x=f.namespaces.eip155?.chains?.[0],P=f.namespaces.solana?.chains?.[0],O=f.namespaces.xrpl?.chains?.[0];n({type:"SET_CHAIN",payload:x??P??O??null})}else n({type:"SET_ACCOUNTS",payload:[]}),n({type:"SET_CHAIN",payload:null})},[]);me(()=>{let f=s.session,S=l;return!f||!S?.onAccountsChanged?void 0:S.onAccountsChanged(f,P=>{if(P.length===0){u.clear().finally(()=>n({type:"RESET"}));return}m(f),u.save(f)})},[s.session,l,u,m]),me(()=>{let f=s.session,S=l;if(!(!f||!S?.onChainChanged))return S.onChainChanged(f,x=>{m(f),u.save(f);let P=a.syncExternalChain;if(!P)return;let O=P.call(a,x).catch(F=>{Z.warn("react/provider","External chain sync error:",F)});r.current=O,O.finally(()=>{r.current===O&&(r.current=null)})})},[s.session,l,u,m,a]);let C=K(async f=>{if(!t.siwx||!f)return!0;n({type:"SET_STATUS",payload:"authenticating"});let S=await wn({session:f,siwx:t.siwx,signMessage:(x,P)=>l.signMessage(x,P)});return S.kind==="failed"&&S.fatal?(await u.clear(),n({type:"RESET"}),n({type:"SET_ERROR",payload:S.error}),!1):!0},[t.siwx,l,u]),E=K(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let f=await xn(l.connect(),i,"Wallet connect");await u.save(f),m(f);try{await d(f)}catch(S){Z.warn("react/provider","SessionManager sync error:",S)}if(!await C(f))return;n({type:"SET_STATUS",payload:"connected"})}catch(f){let S=f instanceof Error?f.message:"Connection failed";n({type:"SET_ERROR",payload:f instanceof Error?f:new Error(S)}),n({type:"SET_STATUS",payload:"disconnected"})}},[l,u,m,i,C,d]),A=K(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let f=await l.connectEmbedded();if(await u.save(f),m(f),await d(f),!await C(f))return;n({type:"SET_STATUS",payload:"connected"})}catch(f){let S=f instanceof Error?f.message:"Embedded wallet connection failed";n({type:"SET_ERROR",payload:f instanceof Error?f:new Error(S)}),n({type:"SET_STATUS",payload:"disconnected"})}},[l,u,m,C,d]),y=K(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let f=await l.connectPasskeys();if(await u.save(f),m(f),await d(f),!await C(f))return;n({type:"SET_STATUS",payload:"connected"})}catch(f){let S=f instanceof Error?f.message:"Passkeys connection failed";n({type:"SET_ERROR",payload:f instanceof Error?f:new Error(S)}),n({type:"SET_STATUS",payload:"disconnected"})}},[l,u,m,C,d]),v=K(async()=>{if(!s.session){n({type:"RESET"});return}try{await l.disconnect(s.session)}catch(f){Z.error("react/provider","Disconnect error:",f)}try{let f=g.current;f&&await f.disconnect()}catch(f){Z.warn("react/provider","SessionManager disconnect error:",f)}await u.clear(),n({type:"RESET"})},[l,s.session,u]),R=K(async f=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let S=await xn(l.connectInjected(f),i,"Injected wallet connect");await u.save(S),m(S);try{await d(S)}catch(x){Z.warn("react/provider","SessionManager sync error:",x)}if(!await C(S))return;n({type:"SET_STATUS",payload:"connected"})}catch(S){let x=S instanceof Error?S.message:"Connection failed";n({type:"SET_ERROR",payload:S instanceof Error?S:new Error(x)}),n({type:"SET_STATUS",payload:"disconnected"})}},[l,u,m,i,C,d]),w=K(async()=>l.startPairing(),[l]),T=K(()=>{l.cancelPairing?.()},[l]),k=K(async()=>{let f=await l.completePairing();return await u.save(f),m(f),await d(f),await C(f)&&n({type:"SET_STATUS",payload:"connected"}),f},[l,u,m,C,d]),b=K(async f=>{let S=t.siwx;if(!S||S.required===!1)return!0;try{if(await S.hasValidSession?.())return!0}catch(x){Z.warn("react/provider","siwx.hasValidSession failed",x)}return C(f)},[t.siwx,C]),I=K(async()=>{let f=await u.load();if(!f){n({type:"SET_STATUS",payload:"disconnected"});return}n({type:"SET_STATUS",payload:"reconnecting"});try{let S=await ko(()=>l.reconnect(f),{maxRetries:h,baseDelay:1e3,label:"reconnect"});m(S);try{let x=g.current;x&&(p(),await x.restoreFromPersistence())}catch(x){Z.warn("react/provider","SessionManager restore error:",x)}if(!await b(S))return;n({type:"SET_STATUS",payload:"connected"})}catch(S){Z.error("react/provider","Reconnect error:",S),await u.clear(),n({type:"SET_STATUS",payload:"disconnected"}),n({type:"SET_SESSION",payload:null})}},[l,u,m,h,p,b]),W=K(async f=>{r.current&&await r.current;let S=g.current;if(S?.getActiveBundle()){await S.switchChain(f),m(s.session);return}if(!s.session)throw new Error("No active session");try{s.session.walletType==="eip6963"||s.session.id?.startsWith("eip6963-")?await Oe.switchChain(s.session,f):s.session.walletType==="embedded"&&l.embeddedConnector?await l.embeddedConnector.switchChain?.(s.session,f):s.session.walletType==="passkeys"&&l.passkeysConnector?await l.passkeysConnector.switchChain?.(s.session,f):s.session.walletType==="solana"&&l.solanaConnector?await l.solanaConnector.switchChain?.(s.session,f):await l.connector.switchChain(s.session,f),m(s.session)}catch(x){throw new ho("chain_unsupported","Failed to switch chain",x)}},[l,s.session,m]);me(()=>{o&&I()},[o,I]);let _=K(()=>{n({type:"SET_ERROR",payload:null})},[]),D=fe(()=>({...s,connect:E,connectEmbedded:A,connectPasskeys:y,disconnect:v,reconnect:I,switchChain:W,startPairing:w,completePairing:k,cancelPairing:T,connectInjected:R,clearError:_,isConnected:s.status==="connected",chains:c,client:l,sessionManager:a}),[s,E,A,y,v,I,W,w,k,T,R,_,c,l,a]);return xo(mt.Provider,{value:D,children:e})}function U(){let e=Co(mt);if(!e)throw new Error("useWeb3 must be used within a Web3ConnectProvider");return e}function B(){let{accounts:e,isConnected:t}=U(),o=bo(()=>!t||e.length===0?null:e.map(n=>{let c=Ao(n);return c?{address:n,namespace:c.namespace,isEVM:c.namespace==="eip155"&&An(c.address)}:{address:n,namespace:null,isEVM:An(n)}}),[e,t]),s=o?.find(n=>n.isEVM)?.address??null;return{accounts:o,evmAccount:s,primaryAccount:e[0]??null,isConnected:t,count:e.length}}import{listAuthorizations as Ro,revokeListedAuthorization as To}from"@naculus/connect-core";import{useCallback as bn,useEffect as Rn,useRef as ft,useState as gt}from"react";function Io({managers:e}){let t=ft(e);t.current=e;let o=ft(0),s=ft(!0),[n,c]=gt([]),[i,h]=gt(!1),[u,l]=gt(null);Rn(()=>()=>{s.current=!1,o.current+=1},[]);let g=bn(async()=>{let a=++o.current;h(!0),l(null);try{let p=await Ro(t.current);s.current&&a===o.current&&c(p)}catch(p){s.current&&a===o.current&&l(p instanceof Error?p:new Error("Failed to list authorizations"))}finally{s.current&&a===o.current&&h(!1)}},[]);Rn(()=>{g()},[g]);let r=bn(async a=>{try{let p=await To(t.current,a);return await g(),p}catch(p){let d=p instanceof Error?p:new Error("Failed to revoke authorization");throw s.current&&l(d),d}},[g]);return{entries:n,loading:i,error:u,refresh:g,revoke:r}}import{chainNumber as Uo,resolveChain as Po,toViemChain as Wo}from"@naculus/connect-appkit-core";import{useState as ge,useEffect as ht,useCallback as Oo,useMemo as he,useRef as No}from"react";import{createPublicClient as _o,http as Do,formatEther as Mo}from"viem";import{getNativeTokenPriceUsd as Lo}from"@naculus/connect-core";function Bo(e){let{evmAccount:t,isConnected:o}=B(),{chainId:s,chains:n}=U(),[c,i]=ge(null),[h,u]=ge(!1),[l,g]=ge(null),[r,a]=ge(null),p=e?.refreshInterval,d=No(null),m=he(()=>Po(n,s),[s,n]),C=m?Uo(m):null,E=he(()=>m?Wo(m,C):null,[m,C]),A=he(()=>m?.token??null,[m]),[y,v]=ge(null);ht(()=>{if(!E||!m?.rpcUrl){v(null);return}let k=_o({transport:Do(m.rpcUrl),chain:E});return v(k),()=>{}},[m,E]);let R=Oo(async()=>{if(!t||!y){i(null);return}u(!0),g(null);try{let b=t.includes(":")?t.split(":").pop():t,[I,W]=await Promise.all([y.getBalance({address:b}),s?Lo(s,m?.rpcUrl).catch(()=>null):Promise.resolve(null)]);i(I.toString()),a(W)}catch(k){g(k instanceof Error?k:new Error("Failed to fetch balance")),i(null),a(null)}finally{u(!1)}},[t,y,s,m?.rpcUrl]);ht(()=>{o&&t&&R()},[o,t,R]),ht(()=>(p&&p>0&&o&&t&&(d.current=setInterval(R,p)),()=>{d.current&&(clearInterval(d.current),d.current=null)}),[p,o,t,R]);let w=he(()=>{if(c===null)return null;try{return Mo(BigInt(c))}catch{return null}},[c]),T=he(()=>{if(r===null||w===null)return null;let k=parseFloat(w);if(Number.isNaN(k))return null;let b=k*r;return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(b)},[r,w]);return{balance:c,formatted:w,symbol:A,usdPrice:r,usdValue:T,isLoading:h,error:l,refetch:R,chain:m}}import{atomicSupportFor as Fo,normalizeCapabilities as Ko,selectChainCapabilities as Ho}from"@naculus/connect-appkit-core";import{useCallback as qo,useEffect as Vo,useRef as zo,useState as yt}from"react";function N(e){return e??pt()}function Ct(){let{client:e,session:t,chainId:o}=U(),[s,n]=yt(null),[c,i]=yt(!1),[h,u]=yt(null),l=zo(0),g=qo(async()=>{let r=++l.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(r!==l.current)return;n(Ko(p))}catch(p){if(r!==l.current)return;n(null),u(p instanceof Error?p:new Error("Capability query failed"))}finally{r===l.current&&i(!1)}},[e,t]);return Vo(()=>{g()},[g]),{capabilities:s,current:Ho(s,o),atomic:Fo(s,o),isFetching:c,error:h,refetch:g}}import{useMemo as St}from"react";import{chainsForNamespace as jo,describeChain as $o,resolveChain as Go}from"@naculus/connect-appkit-core";function z(){let{chainId:e,session:t,switchChain:o,chains:s}=U(),n=St(()=>Go(s,e),[s,e]),c=St(()=>t?$o(s,e):null,[s,e,t]),i=St(()=>jo(s,e),[s,e]);return{chainId:e,currentChain:n,chainInfo:c,availableChains:i,chains:i,isEvm:e?.startsWith("eip155:")??!1,switchChain:o}}import{useCallback as Xo,useState as Tn}from"react";import{WalletError as Qo}from"@naculus/connect-core";function Yo(){let{connect:e,status:t}=U(),[o,s]=Tn(!1),[n,c]=Tn(null);return{connect:Xo(async()=>{s(!0),c(null);try{await e()}catch(h){let u=h instanceof Error?h.message:"Connection failed";c(h instanceof Qo?h:new Error(u))}finally{s(!1)}},[e]),isConnecting:o||t==="connecting",error:n}}import{bareEvmAddress as ns}from"@naculus/connect-appkit-core";import{delegateAccount as rs,eip155Reference as os,REVOKE_DELEGATE as ss,WalletError as Un}from"@naculus/connect-core";import{useCallback as Ne,useEffect as Pn,useRef as Wn,useState as wt}from"react";import{chainNumber as Jo,toViemChain as Zo}from"@naculus/connect-appkit-core";import{useMemo as Et}from"react";import{createPublicClient as es,http as In,createWalletClient as ts}from"viem";function j(){let{evmAccount:e,isConnected:t}=B(),{currentChain:o,chains:s}=z(),n=o?Jo(o):null,c=Et(()=>o?Zo(o,n):null,[o,n]),i=Et(()=>c?es({transport:In(c.rpcUrls.default.http[0]),chain:c}):null,[c]),h=Et(()=>{if(!t||!e||!c)return null;let u=e.includes(":")?e.split(":").pop():e;return ts({transport:In(c.rpcUrls.default.http[0]),chain:c,account:u})},[t,e,c]);return{publicClient:i,walletClient:h,chains:s}}function as(e){let{evmAccount:t}=B(),{session:o,chainId:s,client:n}=U(),{publicClient:c}=j(),[i,h]=wt(null),[u,l]=wt(!1),[g,r]=wt(null),a=Wn(0),p=Wn(!1);Pn(()=>()=>{a.current+=1},[]),Pn(()=>{a.current+=1,h(null),l(!1),r(null)},[o,s,t]);let d=Ne(async(A,y)=>{let v=k=>(r(k),null);if(p.current)return v(new Error("A delegation is already in progress"));let R=ns(t);if(!o||!R||!s)return v(new Un("wallet_unavailable","No connected EVM account"));if(!c||c.chain?.id!==os(s))return v(new Un("chain_mismatch",`No RPC client for ${s}; refusing to read the nonce elsewhere.`));let w=o.walletType==="embedded"?N(n)?.embeddedConnector??{}:{},T=++a.current;p.current=!0,l(!0),r(null),h(null);try{let k=await rs({connector:w,session:o,account:R,chainId:s,delegate:A,allowlist:y,getTransactionCount:(b,I)=>c.getTransactionCount({address:b,blockTag:I})});return T!==a.current?null:(h(k),k)}catch(k){return T!==a.current?null:v(k instanceof Error?k:new Error("Failed to send delegation"))}finally{p.current=!1,T===a.current&&l(!1)}},[s,n,t,c,o]),m=Ne(A=>d(A,e.allowlist),[d,e.allowlist]),C=Ne(()=>d(ss,[]),[d]),E=Ne(()=>{a.current+=1,h(null),l(!1),r(null)},[]);return{delegate:m,revoke:C,result:i,isPending:u,error:g,reset:E}}import{applySettlementVerification as On,DEFAULT_VERIFY_RETRY as is,describePayment as ls}from"@naculus/connect-appkit-core";import{useCallback as Nn,useEffect as cs,useRef as ye,useState as kt}from"react";function us(e,t={}){let[o,s]=kt(0),[n,c]=kt(null),[i,h]=kt(null),u=ye(0),l=ye(0),g=ye(e);g.current=e;let r=ye(t);r.current=t;let a=ye(0);cs(()=>()=>{u.current+=1,l.current+=1,a.current+=1},[]);let p=Nn(async(m,C)=>{let E=++u.current,A=l.current;s(y=>y+1),h(null);try{let y=await g.current(m,C),v=ls(m,y);if(v&&A===l.current){let R=r.current.verify;if(!R)c(v);else{v=On(v,{status:"pending"}),c(v);let w=++a.current,T=r.current.verifyRetry??is;Promise.resolve().then(async()=>{let k={status:"pending"};for(let b=0;b<T.attempts;b+=1){if(b>0&&await new Promise(I=>setTimeout(I,T.delayMs)),A!==l.current||w!==a.current)return;try{k=await R(y)}catch(I){k={status:"unavailable",reason:I instanceof Error?I.message:"Settlement verification failed"}}if(k.status!=="pending")break}A===l.current&&w===a.current&&c(b=>b&&On(b,k))})}}return y}catch(y){let v=y instanceof Error?y:new Error("Paid request failed");throw E===u.current&&h(v),v}finally{s(y=>y-1)}},[]),d=Nn(()=>{u.current+=1,l.current+=1,a.current+=1,c(null),h(null)},[]);return{payFetch:p,isPending:o>0,lastPayment:n,error:i,reset:d}}import{createX402WalletSigner as ps,findX402Provider as ds}from"@naculus/connect-appkit-core";import{eip6963Connector as ms}from"@naculus/connector-evm-injected";import{useMemo as fs}from"react";function gs(){let{session:e,accounts:t,chainId:o,client:s,switchChain:n}=U(),c=t.join("\0");return fs(()=>{let i=ds(e,{injected:ms.getDiscoveredWallets(),walletConnect:s.connector});return ps(e,i,n)},[e,c,o,s.connector,n])}import{readCurrentMppSessionChannel as Ce,readMppRecoveryChannelId as _n,readMppSessionReceipt as Dn}from"@naculus/connect-appkit-core";import{useCallback as ae,useEffect as Mn,useMemo as hs,useRef as _e,useState as ie}from"react";function Ln(e){return e instanceof Error?e:new Error("MPP session operation failed")}function ys(e){let[t,o]=ie(0),[s,n]=ie(()=>e.meter.pending),[c,i]=ie(()=>Ce(e)),[h,u]=ie(null),[l,g]=ie(null),[r,a]=ie(null),p=_e(0),d=_e(0),m=_e(!0),C=_e(e);C.current=e,Mn(()=>{p.current+=1,d.current+=1,o(0),n(e.meter.pending),i(Ce(e)),u(null),g(null),a(null)},[e]),Mn(()=>()=>{m.current=!1,p.current+=1,d.current+=1},[]);let E=ae(async(k,b,I=!1)=>{let W=++p.current,_=d.current,D=C.current;o(f=>f+1),a(null);try{let f=await k(D);if(m.current&&_===d.current){b?.(f);let S=Ce(D);i(S),n(D.meter.pending),(I||!S)&&g(null)}return f}catch(f){let S=Ln(f);if(m.current&&_===d.current){let x=Ce(D);i(x),n(D.meter.pending);let P=_n(f);P?g(P):x||g(null),W===p.current&&a(S)}throw S}finally{m.current&&_===d.current&&o(f=>f-1)}},[]),A=ae((k,b)=>E(I=>I(k,b),I=>{let W=Dn(I.receipt);W&&u(W)}),[E]),y=ae(()=>E(k=>k.close(),k=>{let b=Dn(k.receipt);b&&u(b)},!0),[E]),v=ae(()=>E(k=>k.forceClose(),void 0,!0),[E]),R=ae(k=>{try{C.current.meter.add(k),n(C.current.meter.pending),a(null)}catch(b){let I=Ln(b);throw a(I),g(_n(b)),I}},[]),w=ae(()=>{p.current+=1,d.current+=1,o(0),n(C.current.meter.pending),i(Ce(C.current)),u(null),g(null),a(null)},[]),T=hs(()=>({add:R}),[R]);return{fetch:A,meter:T,pending:s,channel:c,lastReceipt:h,recoveryChannelId:l,isPending:t>0,error:r,close:y,forceClose:v,reset:w}}import{createSolanaSessionKeyFlow as Cs}from"@naculus/connect-appkit-core";import{useCallback as De,useEffect as Ss,useMemo as Es,useRef as ws,useState as vt}from"react";function Bn(){return Promise.reject(new Error("No Solana session key manager is connected"))}function ks(e){let[t,o]=vt([]),[s,n]=vt(0),[c,i]=vt(null),h=ws(0),u=e?.manager,l=e?.rpc,g=e?.owner,r=Es(()=>u&&l&&g?Cs({manager:u,rpc:l,owner:g}):null,[u,l,g]),a=De(async(C,E)=>{let A=++h.current;n(y=>y+1),i(null);try{return await C()}catch(y){let v=y instanceof Error?y:new Error(E);throw A===h.current&&i(v),v}finally{if(r&&A===h.current){let y=await r.list().catch(()=>null);y&&A===h.current&&o(y)}n(y=>y-1)}},[r]),p=De(async()=>{if(!r){o([]);return}let C=h.current,E=await r.list();C===h.current&&o(E)},[r]);Ss(()=>(h.current+=1,p().catch(()=>{}),()=>{h.current+=1}),[p]);let d=De(C=>r?a(()=>r.create(C),"Could not create the key"):Bn(),[r,a]),m=De(C=>r?a(()=>r.revoke(C),"Could not revoke the key"):Bn(),[r,a]);return{keys:t,create:d,revoke:m,refresh:p,isPending:s>0,error:c}}import{readDelegation as vs,UNKNOWN_DELEGATION as xt}from"@naculus/connect-core";import{useCallback as xs,useEffect as As,useRef as bs,useState as At}from"react";function Se(){let{publicClient:e}=j(),{evmAccount:t}=B(),[o,s]=At(xt),[n,c]=At(!1),[i,h]=At(null),u=bs(0),l=t?.includes(":")?t.split(":").pop():t,g=xs(async()=>{let r=++u.current;if(!e||!l){s(xt),c(!1),h(null);return}c(!0),h(null);try{let a=await e.getCode({address:l});if(r!==u.current)return;s(vs(a??"0x"))}catch(a){if(r!==u.current)return;s(xt),h(a instanceof Error?a:new Error("Code read failed"))}finally{r===u.current&&c(!1)}},[e,l]);return As(()=>{g()},[g]),{...o,isFetching:n,error:i,refetch:g}}import{bareEvmAddress as Hs,createDelegationPolicyFlow as qs,isVerifiablePolicy as Vs}from"@naculus/connect-appkit-core";import{useCallback as we,useEffect as zs,useMemo as js,useState as Be}from"react";import{recoverMessageAddress as $s}from"viem";import{planExecution as Us,WalletError as Ps}from"@naculus/connect-core";import{useCallback as Kn,useState as Rt}from"react";import{errorMessage as Fn}from"@naculus/connect-appkit-core";import{chooseExecutionStrategy as Ts,getAccountCapabilities as Is,WalletError as ee}from"@naculus/connect-core";import{useCallback as Le,useState as Ee}from"react";import{WalletError as Rs}from"@naculus/connect-core";function Me(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 Rs("tx_failed","Wallet did not return a valid 32-byte transaction hash")}function bt(){let{session:e,chainId:t,client:o}=U(),[s,n]=Ee("idle"),[c,i]=Ee(null),[h,u]=Ee(null),[l,g]=Ee(null),[r,a]=Ee(null),p=Le(async(E,A)=>{if(!e){n("failed");let y=new ee("wallet_unavailable","No active session");throw i(y),y}if(E.length===0){n("failed");let y=new ee("invalid_input","At least one call is required");throw i(y),y}n("awaiting_approval"),i(null),u(null);try{let y=N(o);if(!y)throw new ee("wallet_unavailable","Client not initialized");let v=A?.chainId??t??void 0,R=A?.strategy??Ts(await Is(y,e,v),E.length);if(a(R),R==="atomic-batch"){let T=await y.sendCalls(e,E,v,{atomicRequired:!0,...A?.paymasterService?{paymasterService:A.paymasterService}:{}});return n("submitted"),u(T),T}let w="";for(let T=0;T<E.length;T++){let k=E[T];try{w=Me(await y.sendTransaction(e,{transaction:{to:k.to,data:k.data,value:k.value},chainId:v}))}catch(b){throw new ee("tx_failed",`Call ${T+1} of ${E.length} failed after ${T} already landed (sent sequentially \u2014 this wallet cannot batch atomically): ${Fn(b)}`)}}return n("submitted"),u(w),w}catch(y){throw n("failed"),i(y instanceof Error?y:new Error(Fn(y))),y}},[e,t,o]),d=Le(async E=>{if(!e)throw new ee("wallet_unavailable","No active session");let A=E??h;if(!A)throw new ee("invalid_input","No bundle hash available");if(!E&&r==="sequential")throw new ee("invalid_input","Calls were sent sequentially, so there is no bundle to query. Track the returned transaction hash instead.");let y=N(o);if(!y)throw new ee("wallet_unavailable","Client not initialized");let v=await y.getCallsStatus(e,A);return g(v),v},[e,h,o,r]),m=Le(async E=>{if(!e)return!1;let A=E??h;if(!A||!E&&r==="sequential")return!1;let y=N(o);if(!y?.showCallsStatus)return!1;try{return await y.showCallsStatus(e,A),!0}catch{return!1}},[e,h,o,r]),C=Le(()=>{n("idle"),i(null),u(null),g(null),a(null)},[]);return{sendCalls:p,getCallsStatus:d,showCallsStatus:m,status:s,error:c,batchHash:h,callsStatus:l,execution:r,reset:C,isSending:s==="awaiting_approval"}}function Tt(e={}){let{current:t,atomic:o}=Ct(),{delegated:s,delegate:n}=Se(),{sendCalls:c}=bt(),[i,h]=Rt(!1),[u,l]=Rt(null),[g,r]=Rt(null),a=e.atomicity??"preferred",p=e.sponsorship??"any",d=e.paymasterService,m=e.userOperation,C=e.userOperationSponsored??!1,E=!!(t?.raw?.paymasterService?.supported&&d),A=Kn((v,R=a)=>{let w=Us({atomicBatch:o==="supported",discovered:o!=="unknown",sponsoredTransactions:!1,...t?.maxBatchSize===void 0?{}:{maxBatchSize:t.maxBatchSize}},v,{atomicity:R,sponsorship:p}),T=p==="required"&&!C;if(w.strategy==="atomic-batch"&&!T)return{...w,reason:w.reason+(E?" A paymaster service will be requested, but the wallet's final fee payer must be checked after execution.":""),route:"wallet-batch"};let k=s&&o!=="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=R!=="any"&&!w.atomic||p==="required";return m&&b&&!T?{strategy:"atomic-batch",atomic:!0,sponsored:C,reason:p==="required"&&!w.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"}:T?{strategy:"refuse",atomic:w.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}:w.strategy==="refuse"?{...w,reason:w.reason+k,route:null}:{...w,reason:w.reason+k,route:"sequential"}},[o,t,E,m,C,a,p,s,n]),y=Kn(async(v,R=a)=>{h(!0),l(null);try{let w=A(v.length,R);if(w.route===null)throw new Ps("method_not_allowed",w.reason);return r(w.route),w.route==="user-operation"?await m(v):await c(v,{strategy:w.route==="wallet-batch"?"atomic-batch":"sequential",...w.route==="wallet-batch"&&E?{paymasterService:d}:{}})}catch(w){let T=w instanceof Error?w:new Error("Execution failed");throw l(T),T}finally{h(!1)}},[A,c,m,a,d,E]);return{preview:A,execute:y,isExecuting:i,error:u,lastRoute:g,reset:()=>{l(null),r(null)}}}import{getSharedSessionKeyManager as Ws,resetSharedSessionKeyManager as Os}from"@naculus/connect-appkit-core";import{WalletError as Ns}from"@naculus/connect-core";import{useCallback as Y,useEffect as _s,useRef as Ds,useState as X}from"react";function le(e){return Ws(e)}function It(e){let{session:t}=U(),[o,s]=X([]),[n,c]=X(!1),[i,h]=X(null),u=Ds(!0),l=Y(()=>h(null),[]),g=le(e),r=g.isStorageAvailable(),a=Y(async()=>{if(!t){s([]);return}c(!0),h(null);try{let d=await g.listSessions();u.current&&s(d)}catch(d){u.current&&h(d instanceof Error?d:new Error("Failed to load session keys"))}finally{u.current&&c(!1)}},[t,g]);_s(()=>(u.current=!0,a(),()=>{u.current=!1}),[a]);let p=o.filter(d=>d.status==="active");return{sessions:o,activeSessions:p,loading:n,error:i,refresh:a,clearError:l,storageAvailable:r}}function Ms(e){let{session:t}=U(),[o,s]=X(null),[n,c]=X(!1),[i,h]=X(null),u=Y(()=>h(null),[]),l=le(e);return{createSessionKey:Y(async(r,a)=>{if(!t)throw new Ns("wallet_unavailable","No active wallet session");c(!0),h(null);try{let p=a??void 0,d=await l.createSessionKey(r,p);return s(d),d}catch(p){let d=p instanceof Error?p:new Error("Failed to create session key");throw h(d),d}finally{c(!1)}},[t,l]),lastCreated:o,isCreating:n,error:i,clearError:u}}function Ls(e){let[t,o]=X(!1),[s,n]=X(null),c=Y(()=>n(null),[]),i=le(e);return{revokeSession:Y(async u=>{o(!0),n(null);try{await i.revokeSession(u)}catch(l){let g=l instanceof Error?l:new Error("Failed to revoke session key");throw n(g),g}finally{o(!1)}},[i]),isRevoking:t,error:s,clearError:c}}function Bs(e){let[t,o]=X(!1),[s,n]=X(null),c=Y(()=>n(null),[]),i=le(e),h=Y(async(l,g,r)=>{o(!0),n(null);try{return await i.signWithSessionKey(l,g,r)}catch(a){let p=a instanceof Error?a:new Error("Failed to sign with session key");throw n(p),p}finally{o(!1)}},[i]),u=Y(async(l,g)=>{o(!0),n(null);try{return await i.checkSessionScope(l,g)}catch(r){let a=r instanceof Error?r:new Error("Failed to check session scope");throw n(a),a}finally{o(!1)}},[i]);return{signWithSession:h,checkScope:u,isBusy:t,error:s,clearError:c}}function Fs(){Os()}import{useState as Hn,useCallback as Ks}from"react";import{WalletError as Ut}from"@naculus/connect-core";function Pt(){let{session:e,chainId:t,client:o}=U(),[s,n]=Hn(!1),[c,i]=Hn(null);return{signMessage:Ks(async u=>{if(!e){let g=new Ut("wallet_unavailable","No active session");throw i(g),g}let l=e.namespaces.eip155?.accounts[0]??Object.values(e.namespaces)[0]?.accounts[0];if(!l){let g=new Ut("wallet_unavailable","No account found");throw i(g),g}n(!0),i(null);try{let g=N(o);if(!g)throw new Ut("wallet_unavailable","Client not initialized");return await g.signMessage(e,{message:u,address:l,chainId:t??void 0})}catch(g){let r=g instanceof Error?g.message:"Signing failed",a=g instanceof Error?g:new Error(r);throw i(a),a}finally{n(!1)}},[e,t,o]),isSigning:s,error:c}}import{buildDelegationPolicyMessage as Xs}from"@naculus/connect-appkit-core";function Gs(e={}){let{evmAccount:t}=B(),o=Hs(t),s=Se(),n=Tt(e.execution),{signMessage:c}=Pt(),i=It(e.managerConfig),h=le(e.managerConfig),[u,l]=Be(!1),[g,r]=Be(null),[a,p]=Be(()=>new Set),[d,m]=Be(!1),C=e.origin??(typeof window<"u"?window.location.origin:"unknown"),E=!!e.managerConfig?.encryptionKey,A=e.execution?.sponsorship,{refresh:y,storageAvailable:v}=i,{preview:R}=n,{delegated:w,delegate:T}=s,k=js(()=>qs({manager:h,origin:C,signer:()=>o,signMessage:c,verifySignature:async({message:S,signature:x,signerAddress:P})=>(await $s({message:S,signature:x})).toLowerCase()===P.toLowerCase(),previewExecution:R,sponsorship:A,adapter:e.adapter,signTypedData:e.signTypedData,chainId:()=>e.chainId??null,delegation:()=>({delegated:w,delegate:T}),encryptionKeyConfigured:E,storageAvailable:()=>v,refresh:y}),[h,C,o,c,R,A,e.adapter,e.signTypedData,e.chainId,w,T,E,v,y]);zs(()=>{let S=!1,x=i.sessions.filter(Vs);return x.length===0?(p(new Set),m(!1),()=>{S=!0}):(m(!0),Promise.all(x.map(async P=>[P.id,await k.verifyStoredPolicy(P)])).then(P=>{S||p(new Set(P.filter(([,O])=>O).map(([O])=>O)))}).catch(P=>{S||(p(new Set),r(P instanceof Error?P:new Error("Policy verification failed")))}).finally(()=>{S||m(!1)}),()=>{S=!0})},[i.sessions,k]);let b=we(()=>{r(null),i.clearError()},[i]),I=we(async(S,x)=>{l(!0),r(null);try{return await S()}catch(P){let O=P instanceof Error?P:new Error(x);throw r(O),O}finally{l(!1)}},[]),W=we(S=>I(()=>k.createPolicy(S),"Policy creation failed"),[k,I]),_=we(S=>I(()=>k.revokePolicy(S),"Policy revocation failed"),[k,I]),D=we((S,x)=>I(()=>k.executePolicy(S,x),"Policy execution failed"),[k,I]),f=i.activeSessions.filter(S=>a.has(S.id));return{policies:i.sessions,activePolicies:f,storageAvailable:i.storageAvailable,loading:i.loading||d,isBusy:u,error:g??i.error,delegation:s,createPolicy:W,revokePolicy:_,previewPolicyExecution:k.previewPolicyExecution,signPolicyDigest:k.signPolicyDigest,executePolicy:D,refresh:i.refresh,clearError:b}}import{useCallback as Qs,useRef as Ys,useState as qn}from"react";function Js(){let{disconnect:e,status:t}=U(),[o,s]=qn(!1),[n,c]=qn(null),i=Ys(!0);return{disconnect:Qs(async()=>{if(t!=="disconnected"){s(!0),c(null);try{await e()}catch(u){if(!i.current)return;c(u instanceof Error?u:new Error("Disconnect failed"))}finally{i.current&&s(!1)}}},[e,t]),isDisconnecting:o,error:n,cleanup:()=>{i.current=!1}}}import{WalletError as Wt}from"@naculus/connect-core";import{useCallback as J,useEffect as Zs,useRef as Fe,useState as Ke}from"react";function te(e){let t=e.activeNamespace??"eip155",o=Array.isArray(e.accounts)?e.accounts.map(({namespace:s,address:n,derivationPath:c})=>({namespace:s,address:n,...c?{derivationPath:c}:{}})):e.address?[{namespace:t,address:e.address}]:[];return{accounts:o,activeNamespace:t,createdAt:e.createdAt??0,...e.chainId?{chainId:e.chainId}:{},...e.version?{version:e.version}:{},recoveryAvailable:!!e.mnemonic,address:o.find(s=>s.namespace===t)?.address??e.address}}function ea(){let{connectEmbedded:e,client:t}=U(),[o,s]=Ke(null),n=Fe(null),c=Fe(4),i=Fe(!1),h=Fe(null),[u,l]=Ke(!1),[g,r]=Ke(!1),[a,p]=Ke(null),d=()=>p(null),m=J(()=>{let f=n.current;return n.current=null,f},[]),C=J(()=>{let f=N(t);if(!f?.embeddedConnector)throw new Wt("wallet_unavailable","Embedded wallet not enabled.");return f.embeddedConnector},[t]),E=J(()=>{try{return C().getWallet()?.privateKey??null}catch{return null}},[C]),A=J(async()=>{let f=N(t);if(!f)throw new Wt("wallet_unavailable","Embedded wallet not enabled.");let S=f.getEmbeddedConnector?await f.getEmbeddedConnector():f.embeddedConnector;if(!S)throw new Wt("wallet_unavailable","Embedded wallet not enabled.");return S},[t]),y=J(()=>{try{return N(t)?.passphraseGate??null}catch{return null}},[t]),v=J(f=>{f?.code==="decryption_failed"&&y()?.forget("That passphrase did not open the wallet.")},[y]),R=J(async()=>{i.current=!1,p(null);try{let f=await A();if(!await f.load())return!1;let x=f.getWallet();return x?(n.current=null,l(!1),s(te(x)),!0):!1}catch(f){return i.current=!0,v(f),p(f instanceof Error?f:new Error("Failed to restore embedded wallet")),!1}},[v,A]);Zs(()=>{let f=!1,S=null;return R().then(x=>{f||x||i.current||(S=setTimeout(()=>{f||R()},100))}),()=>{f=!0,S&&clearTimeout(S)}},[R]);let w=async()=>{r(!0),p(null);try{let f=await A(),S=await f.load(),x=f.getWallet();S&&x&&(s(te(x)),n.current=x.mnemonic||null,l(!x.mnemonic)),await e();let P=f.getWallet();P&&(s(te(P)),P.mnemonic&&!S&&(n.current=P.mnemonic,l(!0)))}catch(f){v(f),p(f instanceof Error?f:new Error("Embedded wallet connection failed"))}finally{r(!1)}},T=async()=>{r(!0),p(null);try{let f=await A();y()?.expect("create");let S=await f.generateWallet();return s(te(S)),n.current=S.mnemonic,l(!0),S}catch(f){return p(f instanceof Error?f:new Error("Failed to generate wallet")),null}finally{r(!1)}},k=async f=>{r(!0),p(null);try{let S=await A();y()?.expect("create");let x=await S.importFromMnemonic(f);return s(te(x)),n.current=null,l(!1),x}catch(S){return p(S instanceof Error?S:new Error("Failed to import wallet")),null}finally{r(!1)}},b=async f=>{r(!0),p(null);try{let S=await A();y()?.expect("create");let x=await S.importFromPrivateKey(f);return s(te(x)),n.current=null,l(!1),x}catch(S){return p(S instanceof Error?S:new Error("Failed to import wallet")),null}finally{r(!1)}},I=async()=>{r(!0),p(null);try{await(await A()).wipe(),s(null),n.current=null,l(!1)}catch(f){p(f instanceof Error?f:new Error("Failed to wipe wallet"))}finally{r(!1)}},W=J(f=>{let S=C();S.setActiveNamespace(f);let x=S.getWallet();s(x?te(x):null)},[C]),_=J(async()=>{let f=await A(),S=await f.backfillAccounts();if(S.length>0){let x=f.getWallet();s(x?te(x):null)}return S.map(({namespace:x,address:P,derivationPath:O})=>({namespace:x,address:P,...O?{derivationPath:O}:{}}))},[A]),D=()=>{n.current=null,l(!1)};return{connectEmbedded:w,restoreWallet:R,generateWallet:T,importFromMnemonic:k,importFromPrivateKey:b,wipe:I,wallet:o,hasWallet:o!==null,address:o?.address??null,accounts:o?.accounts??[],activeNamespace:o?.activeNamespace??null,setActiveNamespace:W,backfillAccounts:_,seedPhrase:n.current,getSeedPhrase:m,getPrivateKey:E,backupPending:u,confirmBackup:D,isBusy:g,error:a,clearError:d,storageSecurityLevel:(()=>{try{let f=C(),S=f.getStorageSecurityLevel?.()??4;return f.getWallet()?(c.current=S,S):o?c.current:S}catch{return o?c.current:4}})(),securityReport:(()=>{let f=null;try{f=C().getStorageSecurityReport?.()??null}catch{f=null}if(!f)return h.current=null,null;let S=JSON.stringify(f);return h.current?.json===S?h.current.value:(h.current={json:S,value:f},f)})()}}import{chainNumber as ia}from"@naculus/connect-appkit-core";import{useState as la,useCallback as ca,useEffect as jn,useRef as $n,useMemo as ua}from"react";import{WalletError as ta}from"@naculus/connect-core";import{useCallback as Vn,useEffect as na,useLayoutEffect as ra,useMemo as oa,useRef as zn}from"react";import{tokenChainMismatch as sa}from"@naculus/connect-appkit-core";function aa(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 ce(e){let{token:t,chainId:o}=e,s=t.address.toLowerCase(),n=aa(e),c=oa(()=>({key:n}),[n]),i=zn(n),h=zn(!0);ra(()=>{i.current=n},[n]),na(()=>(h.current=!0,()=>{h.current=!1}),[]);let u=Vn(()=>h.current&&i.current===n,[n]),l=Vn(()=>{if(!u())throw new ta("session_inactive","Wallet or token context changed. Retry the operation with the current account and chain.");let g=sa({address:s,chainId:t.chainId},o);if(g)throw g},[u,s,t.chainId,o]);return{identity:c,isCurrent:u,assertCurrent:l}}import{ERC20_MIN_ABI as pa,formatUnits as da}from"@naculus/connect-core";function ma(e){let{publicClient:t}=j(),{currentChain:o}=z(),{identity:s,isCurrent:n,assertCurrent:c}=ce({token:e.token,chainId:o?ia(o)??void 0:void 0,owner:e.owner,spender:e.spender,publicClient:t}),[i,h]=la(null),u=i?.identity===s?i.raw:null,l=i?.identity===s&&i.fetching,g=i?.identity===s?i.error:null,r=$n(null),a=$n(0),p=ca(async()=>{if(!n())return;let m=++a.current,C=()=>n()&&m===a.current;if(h({identity:s,raw:null,fetching:!!t,error:null}),!!t)try{c();let E=await t.readContract({address:e.token.address,abi:pa,functionName:"allowance",args:[e.owner,e.spender]});if(!C())return;h({identity:s,raw:E,fetching:!1,error:null})}catch(E){if(!C())return;h({identity:s,raw:null,fetching:!1,error:E instanceof Error?E:new Error("Failed to fetch allowance")})}},[t,e.token.address,e.token.chainId,e.owner,e.spender,s,n,c]);return jn(()=>{p().catch(m=>console.warn("useERC20Allowance: initial fetch failed:",m))},[p]),jn(()=>(e.refreshInterval&&e.refreshInterval>0&&(r.current=setInterval(p,e.refreshInterval)),()=>{r.current&&(clearInterval(r.current),r.current=null)}),[e.refreshInterval,p]),{allowance:ua(()=>{if(u===null)return null;let m=e.token.decimals;return m===void 0?null:da(u,m)},[u,e.token.decimals]),allowanceRaw:u,isFetching:l,error:g,refetch:p}}import{chainNumber as fa,createDecimalsCache as ga,encodeErc20Approve as ha,readDecimals as Nt,writeDecimals as Qn}from"@naculus/connect-appkit-core";import{ERC20_MIN_ABI as He,formatUnits as ya,parseUnits as Yn,WalletError as qe}from"@naculus/connect-core";import{useCallback as ve,useRef as Jn,useState as Zn}from"react";import{WalletError as Ot}from"@naculus/connect-core";import{useCallback as Gn,useState as Xn}from"react";function ke(){let{session:e,chainId:t,client:o}=U(),[s,n]=Xn("idle"),[c,i]=Xn(null),h=Gn(async l=>{if(!e){n("failed");let r=new Ot("wallet_unavailable","No active session");throw i(r),r}let g=e.namespaces.eip155?.accounts.find(r=>/^eip155:\d+:0x[0-9a-fA-F]{40}$/.test(r)||/^0x[0-9a-fA-F]{40}$/.test(r));if(!g){n("failed");let r=new Ot("wallet_unavailable","No EVM account found");throw i(r),r}n("awaiting_approval"),i(null);try{let r={...l,from:l.from??g.split(":").pop()},a=N(o);if(!a)throw new Ot("wallet_unavailable","Client not initialized");let p=await a.sendTransaction(e,{transaction:r,chainId:t??void 0}),d=Me(p);return n("submitted"),d}catch(r){n("failed");let a=r instanceof Error?r.message:"Transaction failed";throw i(r instanceof Error?r:new Error(a)),r}},[e,t,o]),u=Gn(()=>{n("idle"),i(null)},[]);return{sendTransaction:h,status:s,error:c,reset:u,isSending:s==="awaiting_approval"}}function Ca(e){return e.includes(":")?e.split(":").pop():e}var Sa=2n**256n-1n;function Ea(e){let{publicClient:t,walletClient:o}=j(),{evmAccount:s,isConnected:n}=B(),{currentChain:c}=z(),{session:i,client:h}=U(),{sendTransaction:u,isSending:l,error:g,reset:r}=ke(),[a,p]=Zn(null),{identity:d,isCurrent:m,assertCurrent:C}=ce({token:e.token,chainId:c?fa(c)??void 0:void 0,owner:s,spender:e.spender,connected:n,publicClient:t,walletClient:o,session:i,client:h}),[E,A]=Zn(null),y=E?.identity===d?E.raw:null,v=E?.identity===d&&E.fetching,R=Jn(ga(e.token,e.token.decimals)),w=Jn(0),T=a??g,k=s?Ca(s):null,b=ve(async()=>{if(!m())return null;let S=++w.current,x=()=>m()&&S===w.current;if(A({identity:d,raw:null,fetching:!!t&&!!k&&n}),p(null),!t||!k||!n)return null;try{C();let P=await t.readContract({address:e.token.address,abi:He,functionName:"allowance",args:[k,e.spender]});return x()?(A({identity:d,raw:P,fetching:!1}),P):null}catch(P){return x()&&(A({identity:d,raw:null,fetching:!1}),p(P instanceof Error?P:new Error("Failed to fetch allowance"))),null}},[t,k,e.token.address,e.token.chainId,e.spender,d,m,C,n]),I=(()=>{if(y===null)return null;let S=Nt(R.current,e.token,e.token.decimals);return S===void 0?null:ya(y,S)})(),W=ve(async S=>{if(p(null),r(),!n||!s){let x=new qe("wallet_unavailable","No connected account");throw p(x),x}if(!t){let x=new qe("wallet_unavailable","No public client");throw p(x),x}try{C();let x=ha(e.spender,S),P=N(h);if(i&&P){let F=await u({to:e.token.address,data:x,value:"0"});return b(),F}if(o){let{request:F}=await t.simulateContract({address:e.token.address,abi:He,functionName:"approve",args:[e.spender,S],account:k});C();let ne=await o.writeContract(F);return b(),ne}let O=await u({to:e.token.address,data:x,value:"0"});return b(),O}catch(x){let P=x instanceof Error?x:new Error("Approve failed");throw m()&&p(P),P}},[e,t,o,s,n,i,h,k,u,r,b,C,m]),_=ve(async S=>{try{if(C(),!t)throw new qe("wallet_unavailable","No public client");let x=Nt(R.current,e.token,e.token.decimals);x===void 0&&(x=await t.readContract({address:e.token.address,abi:He,functionName:"decimals"}),C(),Qn(R.current,e.token,x));let P=Yn(S,x);return await W(P)}catch(x){throw m()&&p(x instanceof Error?x:new Error("Approve failed")),x}},[e.token,t,W,C,m]),D=ve(async()=>W(Sa),[W]),f=ve(async S=>{if(!m()||!n||!k||!t)return!1;try{C()}catch(F){return p(F instanceof Error?F:new Error("Cannot check allowance")),!1}let x=y??await b();if(x===null)return!1;let P=Nt(R.current,e.token,e.token.decimals);if(P===void 0){if(!t)throw new qe("wallet_unavailable","Cannot check allowance: no public client to read token decimals.");if(P=await t.readContract({address:e.token.address,abi:He,functionName:"decimals"}),!m())return!1;Qn(R.current,e.token,P)}let O=Yn(S,P);return m()&&x>=O},[y,b,e.token.address,e.token.chainId,e.token.decimals,t,m,C,n,k]);return{approve:_,approveMax:D,allowance:I,allowanceRaw:y,hasAllowance:f,isApproving:l,isFetchingAllowance:v,error:T,refetchAllowance:b}}import{chainNumber as wa,createDecimalsCache as ka,encodeErc20Transfer as va,readDecimals as xa,writeDecimals as Aa}from"@naculus/connect-appkit-core";import{ERC20_MIN_ABI as er,parseUnits as ba,WalletError as tr}from"@naculus/connect-core";import{useCallback as Ra,useRef as Ta,useState as Ia}from"react";function Ua(e){return e.includes(":")?e.split(":").pop():e}function Pa(e){let{publicClient:t,walletClient:o}=j(),{evmAccount:s,isConnected:n}=B(),{currentChain:c}=z(),{session:i,client:h}=U(),{sendTransaction:u,isSending:l,error:g,reset:r}=ke(),[a,p]=Ia(null),{isCurrent:d,assertCurrent:m}=ce({token:e.token,chainId:c?wa(c)??void 0:void 0,owner:s,connected:n,publicClient:t,walletClient:o,session:i,client:h}),C=Ta(ka(e.token,e.token.decimals)),E=a??g;return{sendTransfer:Ra(async(y,v)=>{if(p(null),r(),!n||!s){let R=new tr("wallet_unavailable","No connected account");throw p(R),R}if(!t){let R=new tr("wallet_unavailable","No public client available");throw p(R),R}try{m();let R=Ua(s),w=xa(C.current,e.token,e.token.decimals);w===void 0&&(w=await t.readContract({address:e.token.address,abi:er,functionName:"decimals"}),m(),Aa(C.current,e.token,w));let T=ba(v,w),k=va(y,T),b=N(h);if(i&&b)return await u({to:e.token.address,data:k,value:"0"});if(o){let{request:W}=await t.simulateContract({address:e.token.address,abi:er,functionName:"transfer",args:[y,T],account:R});return m(),await o.writeContract(W)}return await u({to:e.token.address,data:k,value:"0"})}catch(R){let w=R instanceof Error?R:new Error("Transfer failed");throw d()&&p(w),w}},[e.token,t,o,s,n,i,h,u,r,m,d]),isSending:l,error:E}}import{chainNumber as _a,encodeErc20Transfer as Da}from"@naculus/connect-appkit-core";import{parseUnits as Ma}from"@naculus/connect-core";import{useMemo as La}from"react";import{simulateTransactionPreview as Wa}from"@naculus/connect-appkit-core";import{useCallback as nr,useEffect as Oa,useRef as Na,useState as _t}from"react";function Dt(e,t){U();let{evmAccount:o}=B(),{currentChain:s}=z(),{publicClient:n}=j(),[c,i]=_t(void 0),[h,u]=_t(!1),[l,g]=_t(null),r=Na(void 0),a=nr(async()=>{e&&(u(!0),g(null));try{let d=await Wa(e,{chainId:t,currentChain:s,publicClient:n,evmAccount:o});return i(d),d}catch(d){let m=d instanceof Error?d:new Error("Simulation failed");throw g(m),m}finally{e&&u(!1)}},[e,t,s,n,o]);Oa(()=>{if(e)return r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{a().catch(()=>{})},300),()=>{r.current&&clearTimeout(r.current)}},[e,a]);let p=nr(()=>{i(void 0),g(null),u(!1)},[]);return{result:c,isSimulating:h,error:l,simulate:a,reset:p}}function Ba(e){let{evmAccount:t,isConnected:o}=B(),{currentChain:s}=z(),n=e.token.chainId??(s?_a(s)??void 0:void 0),c=La(()=>{if(!(!o||!t))try{let h=e.token.decimals;if(h===void 0)return;let u=Ma(e.amount,h),l=Da(e.to,u);return{to:e.token.address,data:l,value:"0"}}catch{return}},[e.token.address,e.token.decimals,e.to,e.amount,t,o]),i=Dt(c,n);return{result:c?i.result:void 0,isSimulating:!!c&&i.isSimulating,error:c?i.error:null,reSimulate:i.simulate,reset:i.reset}}import{useState as Mt,useCallback as za,useRef as Lt}from"react";import{useState as Ve,useEffect as Fa,useCallback as rr,useRef as Ka}from"react";import{createContext as Ha,useContext as qa}from"react";var or=Ha(null);function xe(){return qa(or)}function Va(e,t,o){let s=xe(),n=o??s,[c,i]=Ve(null),[h,u]=Ve(!1),[l,g]=Ve(!1),[r,a]=Ve(null),p=Ka(void 0),d=rr(async()=>{if(!(!n||!e)){u(!0),a(null);try{await n.refreshTx(e,t);let E=n.getTxStatus(e,t);E&&i(E)}catch(E){a(E instanceof Error?E:new Error(String(E)))}finally{u(!1)}}},[n,e,t]),m=rr(()=>{!n||!e||(n.stopWatching(e,t),g(!1))},[n,e,t]);Fa(()=>{if(!n||!e||!t){i(null),g(!1);return}p.current&&p.current!==e&&n.stopWatching(p.current),p.current=e;let E=!1;g(!0),u(!0),a(null);let A=n.getTxStatus(e,t);A&&(i(A),u(!1)),n.watchTx(e,t,{}).then(v=>{E||(i(v),u(!1))}).catch(v=>{E||(a(v instanceof Error?v:new Error(String(v))),u(!1))});let y=v=>{E||i({...v})};return n.on("statusChange",y),()=>{E=!0,g(!1),n.off("statusChange",y)}},[n,e,t]);let C=c?.status??"idle";return{entry:c,status:C,isLoading:h,isWatching:l,error:r,refresh:d,stopWatching:m}}function ja(e){let t=xe(),o=e??t,[s,n]=Mt(null),[c,i]=Mt(null),[h,u]=Mt(null),l=Lt(null),g=Lt(null),r=Lt(null);o&&(g.current||(g.current=p=>{i(p),(!l.current||p.createdAt>=l.current.createdAt)&&(n(p),l.current=p)},o.on("confirmed",g.current)),r.current||(r.current=p=>{u(p),(!l.current||p.createdAt>=l.current.createdAt)&&(n(p),l.current=p)},o.on("failed",r.current)));let a=za(()=>{n(null),i(null),u(null),l.current=null},[]);return{lastTx:s,lastConfirmedTx:c,lastFailedTx:h,clear:a}}import{useCallback as Qa}from"react";import{useCallback as $a,useEffect as sr,useMemo as Ga,useRef as ar,useState as Bt}from"react";import{getResolver as Xa}from"@naculus/connect-appkit-core";function ze({input:e,skip:t=!1,resolverConfig:o,scope:s,query:n}){let[c,i]=Bt(null),[h,u]=Bt(!1),[l,g]=Bt(null),r=ar(0),a=ar(!0);sr(()=>(a.current=!0,()=>{a.current=!1}),[]);let p=Ga(()=>Xa(o),[o]),d=$a(()=>{let m=e.trim();if(!m||t){r.current+=1,i(null),u(!1),g(null);return}let C=++r.current;u(!0),g(null),n(p,m,s).then(E=>{!a.current||C!==r.current||(i(E),u(!1))}).catch(E=>{!a.current||C!==r.current||(g(E instanceof Error?E:new Error(String(E))),i(null),u(!1))})},[e,t,s,p,n]);return sr(()=>{d()},[d]),{data:c,isLoading:h,error:l,refetch:d}}function Ya(e,t){let o=Qa((s,n,c)=>s.lookupAddress(n,c),[]);return ze({input:e,skip:t?.skip,resolverConfig:t?.resolverConfig,scope:t?.chainId,query:o})}import{useState as ir,useCallback as Q,useMemo as Ja,useEffect as lr,useRef as cr}from"react";import{addInAppNotification as Za,channelsUpdate as ei,clearOneInAppNotification as ti,createNotificationSettingsStorage as ur,DEFAULT_NOTIFICATION_SETTINGS as ni,loadNotificationSettings as ri,mutedChainSettings as pr,saveNotificationSettings as dr,replayNotificationSettings as oi,updateNotificationSettings as si}from"@naculus/connect-appkit-core";import{InAppChannel as ai}from"@naculus/connect-core";function ii(e){let t=cr(null);t.current||(t.current=e?.channel??new ai);let o=t.current,[s,n]=ir(()=>o.getHistory()),[c,i]=ir(()=>ni),h=cr([]);lr(()=>{let y=e?.storage??ur(),v=R=>{let w=h.current??[];if(h.current=null,w.length===0){R&&i(R);return}i(()=>{let T=oi(R,w);return dr(y,T),T})};ri(y).then(v,()=>v(null))},[]),lr(()=>(o.onNotification=y=>{n(v=>[...v,y])},o.restore().then(()=>{n(o.getHistory())}),()=>{o.onNotification=void 0}),[]);let u=Ja(()=>s.filter(y=>!y.read).length,[s]),l=Q(()=>{o.clear(),n([])},[o]),g=Q(y=>{ti(o,y).then(()=>{n(o.getHistory())})},[o]),r=Q(y=>{o.markAsRead(y),n(v=>v.map(R=>R.id===y?{...R,read:!0}:R))},[o]),a=Q(()=>{o.markAllAsRead(),n(y=>y.map(v=>({...v,read:!0})))},[o]),p=Q(y=>{Za(o,y)},[o]),d=Q(y=>{h.current?.push(y),i(v=>{let R=si(v,y(v)),w=e?.storage??ur();return dr(w,R),R})},[e?.storage]),m=Q(y=>d(()=>y),[d]),C=Q(y=>{m(ei(y))},[m]),E=Q(y=>{d(v=>pr(v,y,!0))},[d]),A=Q(y=>{d(v=>pr(v,y,!1))},[d]);return{notifications:s,unreadCount:u,addNotification:p,clear:l,clearOne:g,markAsRead:r,markAllAsRead:a,settings:c,updateSettings:m,setChannels:C,muteChain:E,unmuteChain:A}}import{useCallback as Ft,useSyncExternalStore as li}from"react";var mr=()=>null,ci=()=>()=>{};function ui(){let{client:e}=U(),t=N(e)?.passphraseGate??null,o=li(t?.subscribe??ci,t?.getSnapshot??mr,mr),s=Ft(i=>t?.submit(i),[t]),n=Ft(()=>t?.cancel(),[t]),c=Ft(i=>t?.forget(i),[t]);return{request:o,submit:s,cancel:n,forget:c,isUnlocked:t?.isUnlocked??!1,gate:t}}import{useCallback as pi}from"react";function di(e,t){let o=pi((s,n)=>s.resolveName(n),[]);return ze({input:e,skip:t?.skip,resolverConfig:t?.resolverConfig,query:o})}import{assertHexSignature as Kt,bareEvmAddress as mi,buildSmartAccountConfig as fi,resolveUserOpChain as gi}from"@naculus/connect-appkit-core";import{WalletError as ue}from"@naculus/connect-core";import{useCallback as fr,useEffect as gr,useRef as hr,useState as Ae}from"react";async function hi(e,t,o,s,n){let c=N(t);if(!c)throw new ue("wallet_unavailable","Client not initialized");let i=[o,s];if(e.walletType==="eip6963"||e.id?.startsWith("eip6963-")){let{eip6963Connector:h}=await import("@naculus/connector-evm-injected"),u=h.getDiscoveredWallets().find(g=>g.id===e.walletId),l=u?await u.provider.request({method:"personal_sign",params:i}):await h.request({method:"personal_sign",params:i});return Kt(l)}if(e.walletType==="walletconnect")return Kt(await c.connector.request({method:"personal_sign",params:i}));if(e.walletType==="embedded"){let h=c.embeddedConnector;if(!h?.signHash)throw new ue("method_unsupported","This embedded wallet build cannot sign a raw digest. Upgrade @naculus/connector-embedded or pass an explicit signer.");return Kt(await h.signHash(e,o))}throw e.walletType==="passkeys"?new ue("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 ue("method_unsupported",`Raw UserOperation signing is not available for ${e.walletType} on ${n}. Pass a signer that signs the raw 32-byte hash.`)}function yi(e){let{evmAccount:t}=B(),{session:o,chainId:s,client:n}=U(),[c,i]=Ae(null),[h,u]=Ae(null),[l,g]=Ae(!1),[r,a]=Ae(!1),[p,d]=Ae(null),m=hr(0),C=hr(!1);gr(()=>()=>{m.current+=1,C.current=!1},[]),gr(()=>{m.current+=1,C.current=!1,i(null),u(null),g(!1),a(!1),d(null)},[n,s,t,e?.accountType,e?.bundlerUrl,e?.chainId,e?.entryPoint,e?.owner,e?.rpcUrl,e?.salt,e?.signerMode,o]);let E=fr(async(y,v)=>{let R=b=>(d(b),null);if(!e?.rpcUrl)return R(new Error("RPC URL not configured"));if(!e.bundlerUrl)return R(new Error("Bundler URL not configured"));if(!y.length)return R(new Error("At least one call is required"));if(C.current)return R(new Error("A UserOperation is already in progress"));let w=mi(e.owner??t);if(!w)return R(new ue("wallet_unavailable","No EVM account found"));let T;try{T=gi(e.chainId,s)}catch(b){return R(b)}if(!e.signer&&!o)return R(new ue("wallet_unavailable","No active session"));let k=++m.current;C.current=!0,g(!0),a(!0),d(null),i(null),u(null);try{let{SmartAccountManager:b}=await import("@naculus/connect-core"),I=e.signer??(f=>hi(o,n,f,w,T)),W=new b({rpcUrl:e.rpcUrl,bundlerClient:{url:e.bundlerUrl},chainId:T,signer:I,signerMode:e.signer?e.signerMode??"eip191":"raw"}),_=fi(w,T,e),D=await W.sendUserOperation(_,y,v);return k!==m.current?null:(a(!1),i(D.userOpHash),W.getUserOperationReceipt(D.userOpHash).then(f=>{k===m.current&&u(f)}).catch(()=>{}),D)}catch(b){if(k!==m.current)return null;let I=b instanceof Error?b:new Error("Failed to send UserOperation");return d(I),null}finally{C.current=!1,k===m.current&&(g(!1),a(!1))}},[n,s,t,e,o]),A=fr(()=>{m.current+=1,i(null),u(null),g(!1),a(!1),d(null)},[]);return{sendUserOp:E,userOpHash:c,receipt:h,isPending:l,isEstimating:r,error:p,reset:A}}import{useSyncExternalStore as Ci,useCallback as yr}from"react";function Si(e,t){if(!e)return()=>{};let o=()=>t();return e.on("sessionConnected",o),e.on("sessionDisconnected",o),e.on("chainChanged",o),e.on("sessionScopeChanged",o),e.on("sessionRevoked",o),()=>{e.off("sessionConnected",o),e.off("sessionDisconnected",o),e.off("chainChanged",o),e.off("sessionScopeChanged",o),e.off("sessionRevoked",o)}}var Ht=Object.freeze({session:null,chainSessions:[],activeChainId:null,isConnected:!1,connectorId:null}),qt=new WeakMap;function Ei(e,t){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(e[o]!==t[o])return!1;return!0}function wi(e){if(!e)return Ht;let t=e.getActiveBundle(),o=qt.get(e);if(!t)return o&&o.session===null?o:(qt.set(e,Ht),Ht);let s=Array.from(t.chainSessions.values());if(o&&o.session===t.walletSession&&o.activeChainId===t.activeChainId&&Ei(o.chainSessions,s))return o;let n={session:t.walletSession,chainSessions:s,activeChainId:t.activeChainId,isConnected:!0,connectorId:t.walletSession.walletType};return qt.set(e,n),n}function ki(e){let t=U(),o=e??t.sessionManager??null,s=yr(c=>Si(o,c),[o]),n=yr(()=>wi(o),[o]);return Ci(s,n)}import{defaultSiwxDomain as vi,defaultSiwxUri as xi}from"@naculus/connect-appkit-core";import{WalletError as je}from"@naculus/connect-core";import{createSiwxMessage as Ai,generateNonce as bi,getBlockchainName as Ri,issueNonce as Ti,nowISO as Ii}from"@naculus/siwx";import{useCallback as Cr,useState as Sr}from"react";var Ui=86400;function Vt(){let{session:e,chainId:t,client:o}=U(),[s,n]=Sr(!1),[c,i]=Sr(null),h=Cr(()=>i(null),[]);return{signIn:Cr(async l=>{if(!e)throw new je("wallet_unavailable","No active session");let g=l?.chainId??t;if(!g)throw new je("invalid_chain","No chain to sign for. Connect a wallet or pass options.chainId.");let r=se(e,g);if(!r)throw new je("wallet_unavailable","No account found");let a=N(o);if(!a)throw new je("wallet_unavailable","Client not initialized");let{address:p}=r,d=typeof window>"u"?void 0:window.location,m=l?.domain??vi(d),C=l?.uri??xi(d);n(!0),i(null);try{let E=bi();await Ti(E);let A=Ii(),y=l?.expirySeconds??Ui,v=new Date(Date.now()+y*1e3).toISOString(),R=Ai({domain:m,address:p,uri:C,version:1,chainId:g,nonce:E,issuedAt:A,expirationTime:v,statement:l?.statement,resources:l?.resources,requestId:l?.requestId}),w=await a.signMessage(e,{message:R,address:p,chainId:g??void 0}),T={message:{raw:R,domain:m,address:p,statement:l?.statement??null,uri:C,version:1,chainId:g,nonce:E,issuedAt:A,blockchain:Ri(g),expirationTime:v,notBefore:null,resources:l?.resources??[],requestId:l?.requestId??null},signature:w};return n(!1),T}catch(E){let A=E instanceof Error?E:new Error("SIWx sign-in failed");throw i(A),n(!1),A}},[e,t,o]),isSigningIn:s,error:c,clearError:h}}import{siwxResultToSession as Er}from"@naculus/connect-appkit-core";import{logger as zt}from"@naculus/connect-core";import{checkSessionExpired as wr,createLocalStorageSiwxSessionStorage as Pi}from"@naculus/siwx";import{useCallback as $e,useEffect as kr,useRef as Wi,useState as Ge}from"react";function Oi(e){let{storagePrefix:t="naculus_",autoRestore:o=!0,defaultExpirySeconds:s=86400}=e??{},[n,c]=Ge(null),[i,h]=Ge(o),[u,l]=Ge(!1),[g,r]=Ge(null),{chainId:a}=U(),p=Vt(),d=Wi(Pi(`${t}siwx_session`)),m=$e(()=>r(null),[]);kr(()=>{if(!o){h(!1);return}let w=!1;return(async()=>{try{let k=await d.current.get();if(w)return;k?(zt.info("react/useSIWxSession","Restored persisted SIWx session"),c(k),r(null)):c(null)}catch(T){zt.warn("react/useSIWxSession","Failed to restore SIWx session:",T),c(null)}finally{w||h(!1)}})(),()=>{w=!0}},[o]),kr(()=>{if(!n?.expiresAt)return;let w=new Date(n.expiresAt).getTime()-Date.now();if(w<=0){c(null);return}let T=setTimeout(()=>{c(k=>k&&k.id===n.id?null:k)},w);return()=>clearTimeout(T)},[n?.id,n?.expiresAt]);let C=$e(async w=>{l(!0),r(null);try{let T={expirySeconds:s,chainId:a??void 0,...w},k=await p.signIn(T),b=Er(k);return await d.current.set(b),c(b),l(!1),b}catch(T){let k=T instanceof Error?T:new Error("SIWx sign-in failed");throw r(k),l(!1),k}},[p,a,s]),E=$e(async()=>{try{await d.current.remove()}catch(w){zt.warn("react/useSIWxSession","Failed to clear session:",w)}c(null),r(null)},[]),A=$e(async()=>{if(!n)throw new Error("No active session to refresh");l(!0),r(null);try{let w=await p.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}),T={...Er(w),id:n.id,refreshedAt:new Date().toISOString()};return await d.current.set(T),c(T),l(!1),T}catch(w){let T=w instanceof Error?w:new Error("Session refresh failed");throw r(T),l(!1),T}},[n,p,s]),y=n!==null&&!wr(n),v=wr(n),R=n?.expiresAt?Math.max(0,new Date(n.expiresAt).getTime()-Date.now()):null;return{session:y?n:null,isAuthenticated:y,isRestoring:i,isSigningIn:u,isExpired:v,timeUntilExpiry:R,signIn:C,signOut:E,refresh:A,error:g,clearError:m}}import{defaultSiwxDomain as Ni,defaultSiwxUri as _i}from"@naculus/connect-appkit-core";import{WalletError as Xe}from"@naculus/connect-core";import{createSiwxMessage as Di,generateNonce as Mi,getBlockchainName as Li,issueNonce as Bi,nowISO as Fi}from"@naculus/siwx";import{useCallback as vr,useState as jt}from"react";function be(){let{session:e,chainId:t,client:o}=U(),[s,n]=jt(!1),[c,i]=jt(null),[h,u]=jt(null),l=vr(()=>u(null),[]);return{signIn:vr(async r=>{if(!e)throw new Xe("wallet_unavailable","No active session");let a=r?.chainId??t;if(!a)throw new Xe("invalid_chain","No chain to sign for. Connect a wallet or pass options.chainId.");let p=se(e,a);if(!p)throw new Xe("wallet_unavailable","No account found");let d=N(o);if(!d)throw new Xe("wallet_unavailable","Client not initialized");let{address:m}=p,C=typeof window>"u"?void 0:window.location,E=r?.domain??Ni(C),A=r?.uri??_i(C);n(!0),u(null);try{let y=Mi();await Bi(y);let v=Fi(),R=Di({domain:E,address:m,uri:A,version:1,chainId:a,nonce:y,issuedAt:v,statement:r?.statement,expirationTime:r?.expirySeconds?new Date(Date.now()+r.expirySeconds*1e3).toISOString():void 0,resources:r?.resources,requestId:r?.requestId}),w=await d.signMessage(e,{message:R,address:m,chainId:a??void 0}),T=r?.expirySeconds?new Date(Date.now()+r.expirySeconds*1e3).toISOString():null,k={message:{raw:R,domain:E,address:m,statement:r?.statement??null,uri:A,version:1,chainId:a,nonce:y,issuedAt:v,blockchain:Li(a),expirationTime:T,notBefore:null,resources:r?.resources??[],requestId:r?.requestId??null},signature:w};return i(k),k}catch(y){let v=y instanceof Error?y:new Error("SIWx sign-in failed");throw u(v),v}finally{n(!1)}},[e,t,o]),isSigningIn:s,result:c,error:h,clearError:l}}import{WalletError as $t}from"@naculus/connect-core";import{useCallback as xr}from"react";function Ki(){let{session:e,chainId:t}=U();return xr(o=>{if(!e)throw new $t("wallet_unavailable","No active session");let s=o??t;if(s&&!s.startsWith("eip155:"))throw new $t("namespace_mismatch",`Ethereum SIWx requires an eip155 chain, received ${s}`);let n=e.namespaces.eip155;if(!n||n.accounts.length===0)throw new $t("namespace_mismatch","No EVM (eip155) accounts found in session")},[e,t])}function Hi(){let e=Ki(),t=be();return{signIn:xr(async s=>(e(s?.chainId),t.signIn(s)),[e,t.signIn]),isSigningIn:t.isSigningIn,result:t.result,error:t.error,clearError:t.clearError}}import{resolveSimulationEndpoint as qi}from"@naculus/connect-appkit-core";import{SimulationManager as Vi}from"@naculus/wallet-engine";import{useCallback as Gt,useRef as zi,useState as Xt}from"react";function ji(e){let t=e?.rpcUrl,o=e?.chainId,s=zi(null),n=Gt(()=>(s.current||(s.current=new Vi({enabled:!0,rpcUrl:t,autoSimulate:!1})),s.current),[t]),[c,i]=Xt(null),[h,u]=Xt(!1),[l,g]=Xt(null),r=Gt(async(p,d,m,C,E)=>{u(!0),g(null);try{let A=n(),y=qi(E?.chainId,o,E?.rpcUrl,t),v=await A.simulateERC20Transfer(p,d,m,C,y.chainId,E?.decimals,y.rpcUrl);return i(v),v}catch(A){let y=A instanceof Error?A:new Error(String(A));throw g(y),y}finally{u(!1)}},[t,o,n]),a=Gt(()=>{i(null),g(null),u(!1)},[]);return{result:c,loading:h,error:l,simulate:r,reset:a}}import{isSiwxExpired as $i,isSiwxNotBeforeValid as Gi}from"@naculus/connect-appkit-core";import{LocalStorageAdapter as Xi,logger as Qe}from"@naculus/connect-core";import{useCallback as Qt,useEffect as Qi,useRef as Yi,useState as Ye}from"react";var Je="siwx_auth";function Ji(e){return new Xi(e)}function Zi(e){let{storagePrefix:t="naculus_",autoRestore:o=!0}=e??{},[s,n]=Ye(null),[c,i]=Ye(o),[h,u]=Ye(!1),[l,g]=Ye(null),r=be(),a=Yi(Ji(t)),p=Qt(()=>g(null),[]);Qi(()=>{if(!o){i(!1);return}let C=!1;return(async()=>{try{let E=a.current,A=await E.get(Je);if(C)return;A&&!$i(A,new Date)&&Gi(A,new Date)?(Qe.info("react/useSiwxAuthSession","Restored persisted SIWx auth session"),n(A),g(null)):A&&(Qe.info("react/useSiwxAuthSession","Persisted SIWx auth expired, clearing"),await E.remove(Je))}catch(E){Qe.warn("react/useSiwxAuthSession","Failed to restore SIWx auth:",E)}finally{C||i(!1)}})(),()=>{C=!0}},[o]);let d=Qt(async C=>{u(!0),g(null);try{let E=await r.signIn(C);return await a.current.set(Je,E),n(E),u(!1),E}catch(E){let A=E instanceof Error?E:new Error("SIWx sign-in failed");throw g(A),u(!1),A}},[r]),m=Qt(async()=>{try{await a.current.remove(Je)}catch(C){Qe.warn("react/useSiwxAuthSession","Failed to clear SIWx auth:",C)}n(null),g(null)},[]);return{isSignedIn:s!==null,isRestoring:c,siwxResult:s,isSigningIn:h,error:l,signIn:d,signOut:m,clearError:p}}import{bareEvmAddress as el,buildSmartAccountConfig as tl,resolveEvmChainId as Ar}from"@naculus/connect-appkit-core";import{WalletError as Tr}from"@naculus/connect-core";import{useCallback as re,useEffect as br,useRef as Yt,useState as Re}from"react";function Rr(e){return new Tr("wallet_unavailable",e)}function nl(e){let{evmAccount:t}=B(),{session:o,chainId:s,client:n}=U(),[c,i]=Re(null),[h,u]=Re(!1),[l,g]=Re(null),[r,a]=Re(!1),[p,d]=Re(null),m=Yt(null),C=Yt(0),E=Yt(!1);br(()=>{if(m.current=null,!e?.rpcUrl)return;let b=!1;return import("@naculus/connect-core").then(({SmartAccountManager:I})=>{if(b)return;let W=Ar(e.chainId,s);W&&(m.current=new I({rpcUrl:e.rpcUrl,chainId:W,bundlerClient:{url:e.bundlerUrl??""}}))}).catch(I=>{b||d(I instanceof Error?I:new Error("Failed to load account-abstraction module"))}),()=>{b=!0}},[s,e?.rpcUrl,e?.bundlerUrl,e?.chainId]),br(()=>{C.current+=1,E.current=!1,i(null),u(!1),g(null),a(!1),d(null)},[t,s,e?.rpcUrl,e?.bundlerUrl,e?.chainId,e?.entryPoint,e?.accountType,e?.salt]);let A=re(()=>{let b=el(t);if(!b||!m.current)return null;let I=Ar(e?.chainId,s);return I?tl(b,I,{accountType:e?.accountType,entryPoint:e?.entryPoint,salt:e?.salt}):null},[t,s,e?.accountType,e?.chainId,e?.entryPoint,e?.salt]),y=re(b=>(d(b),null),[]),v=re(()=>E.current?null:(E.current=!0,C.current),[]),R=re(b=>{C.current===b&&(E.current=!1)},[]),w=re(async()=>{let b=A();if(!b||!m.current)return y(new Error("Smart account not configured"));let I=v();if(I===null)return y(new Error("Smart account operation already in progress"));a(!0),d(null);try{let _=await m.current.createAccount(b);return C.current!==I?null:(i(_.address),u(_.isDeployed),g(_),_)}catch(W){if(C.current!==I)return null;let _=W instanceof Error?W:new Error("Failed to create smart account");return d(_),null}finally{C.current===I&&a(!1),R(I)}},[v,y,R,A]),T=re(async()=>{let b=A();if(!b||!m.current)return y(new Error("Smart account not configured"));if(!o)return y(Rr("No active session"));let I=N(n);if(!I)return y(Rr("Client not initialized"));if(s&&s!==b.chainId)return y(new Tr("chain_mismatch",`Connected chain ${s} does not match smart account chain ${b.chainId}.`));let W=v();if(W===null)return y(new Error("Smart account operation already in progress"));a(!0),d(null);try{let _=m.current,D=await _.createAccount(b);if(C.current!==W)return null;if(D.isDeployed)return i(D.address),u(!0),g(D),D.address;let f=await _.getDeployCallData(b),S=await I.sendTransaction(o,{transaction:{to:f.to,data:f.data,value:f.value.toString()},chainId:b.chainId});if(C.current!==W)return null;let x=await _.createAccount(b);return i(x.address),u(x.isDeployed),g(x),S}catch(_){if(C.current!==W)return null;let D=_ instanceof Error?_:new Error("Failed to deploy smart account");return d(D),null}finally{C.current===W&&a(!1),R(W)}},[n,s,v,y,R,A,o]),k=re(async()=>{let b=A();if(!b||!m.current)return null;let I=C.current;try{let W=await m.current.getAccountAddress(b);return C.current!==I?null:(i(W),W)}catch(W){return C.current!==I||d(W instanceof Error?W:new Error("Failed to get smart account address")),null}},[A]);return{address:c,isDeployed:h,accountInfo:l,isLoading:r,error:p,createWallet:w,deployWallet:T,getAddress:k}}import{useMemo as rl}from"react";function Jt(){let{accounts:e,isConnected:t}=U();return rl(()=>{if(!t)return{address:null,caip10:null,chainId:null,isConnected:!1};let o=e.find(i=>i.startsWith("solana:"))??null;if(!o)return{address:null,caip10:null,chainId:null,isConnected:t};let s=o.split(":"),n=s.length>=3?s[s.length-1]:null,c=s.length>=3?s.slice(0,-1).join(":"):null;return{address:n,caip10:o,chainId:c,isConnected:t}},[e,t])}import{useCallback as ol,useEffect as Ir,useRef as sl,useState as Zt}from"react";import{getSolanaBalance as al}from"@naculus/connect-core";function il(e={}){let{client:t}=U(),{address:o}=Jt(),s=e.address??o,n=e.rpcUrl??N(t)?.solanaRpcUrl??null,[c,i]=Zt(null),[h,u]=Zt(!1),[l,g]=Zt(null),r=sl(0),a=ol(async()=>{if(!s||!n){i(null);return}let p=++r.current;u(!0),g(null);try{let d=await al(n,s);if(p!==r.current)return;i(d)}catch(d){if(p!==r.current)return;i(null),g(d instanceof Error?d:new Error("Balance read failed"))}finally{p===r.current&&u(!1)}},[s,n]);return Ir(()=>{a()},[a]),Ir(()=>{if(!e.refreshInterval||e.refreshInterval<=0)return;let p=setInterval(()=>{a()},e.refreshInterval);return()=>clearInterval(p)},[e.refreshInterval,a]),{balance:c,isFetching:h,error:l,isConfigured:!!n,refetch:a}}import{readSolanaRoles as ll}from"@naculus/connect-appkit-core";import{useMemo as cl}from"react";function ul(){let{client:e,session:t,accounts:o}=U();return cl(()=>{let s=N(e)?.solanaConnector,{roles:n,absence:c}=ll(s,t);return{roles:n,absence:c,identity:n?.identity??null,signer:n?.signer??null,payer:n?.payer??null}},[e,t,o])}import{WalletError as Ur}from"@naculus/connect-core";import{useCallback as en,useState as tn}from"react";import{getSignatureStatus as pl}from"@naculus/connect-core";function dl(){let{client:e,session:t}=U(),[o,s]=tn(!1),[n,c]=tn(!1),[i,h]=tn(null),u=()=>{let a=N(e);if(!a||!t)throw new Ur("wallet_unavailable","No connected wallet.");return a},l=en(async a=>{s(!0),h(null);try{return await u().signTransaction(t,{transaction:a})}catch(p){let d=p instanceof Error?p:new Error("Signing failed");throw h(d),d}finally{s(!1)}},[e,t]),g=en(async a=>{c(!0),h(null);try{return await u().sendTransaction(t,{transaction:a})}catch(p){let d=p instanceof Error?p:new Error("Send failed");throw h(d),d}finally{c(!1)}},[e,t]),r=en(async a=>{let p=N(e)?.solanaRpcUrl;if(!p)throw new Ur("no_rpc","Set solanaRpcUrl on the client to read a signature's status.");return pl(p,a)},[e]);return{signTransaction:l,sendTransaction:g,getStatus:r,isSigning:o,isSending:n,error:i,reset:()=>h(null)}}import{useCallback as Pr,useState as Wr}from"react";import{toChainSwitchError as ml}from"@naculus/connect-appkit-core";function fl(){let{switchChain:e,chainId:t}=U(),[o,s]=Wr(!1),[n,c]=Wr(null),i=Pr(async u=>{s(!0),c(null);try{await e(u)}catch(l){let g=ml(l);throw c(g),g}finally{s(!1)}},[e]),h=Pr(()=>{c(null)},[]);return{switchChain:i,isSwitching:o,currentChainId:t,error:n,clearError:h}}import{chainNumber as gl,resolveChain as hl,toViemChain as yl}from"@naculus/connect-appkit-core";import{useState as Ze,useEffect as nn,useCallback as Or,useMemo as rn,useRef as Cl}from"react";import{createPublicClient as Sl,http as El,formatUnits as wl}from"viem";var kl=[{name:"balanceOf",type:"function",stateMutability:"view",inputs:[{name:"owner",type:"address"}],outputs:[{name:"balance",type:"uint256"}]}];function vl(e){let{evmAccount:t,isConnected:o}=B(),{chainId:s,chains:n}=U(),[c,i]=Ze([]),[h,u]=Ze(!1),[l,g]=Ze(null),{tokens:r,refreshInterval:a}=e,p=Cl(null),d=rn(()=>r.map(w=>w.address.toLowerCase()+"|"+w.decimals+"|"+w.symbol).join(","),[r]),m=rn(()=>hl(n,s),[s,n]),C=m?gl(m):null,E=rn(()=>m?yl(m,C):null,[m,C]),[A,y]=Ze(null);nn(()=>{if(!E||!m?.rpcUrl){y(null);return}let w=Sl({transport:El(m.rpcUrl),chain:E});y(w)},[m,E]);let v=Or(async()=>{if(!t||!A||r.length===0){i([]);return}u(!0),g(null);try{let w=t.includes(":")?t.split(":").pop():t,k=(await Promise.allSettled(r.map(async b=>{try{let I=await A.readContract({address:b.address,abi:kl,functionName:"balanceOf",args:[w]});return{address:b.address,symbol:b.symbol,decimals:b.decimals,name:b.name,balance:I.toString(),formatted:wl(I,b.decimals)}}catch{return{address:b.address,symbol:b.symbol,decimals:b.decimals,name:b.name,balance:null,formatted:null}}}))).map(b=>b.status==="fulfilled"?b.value:{address:"",symbol:"?",decimals:0,balance:null,formatted:null});i(k)}catch(w){g(w instanceof Error?w:new Error("Failed to fetch token balances"))}finally{u(!1)}},[t,A,d]);nn(()=>{o&&t&&r.length>0&&v()},[o,t,d,v]),nn(()=>(a&&a>0&&o&&t&&r.length>0&&(p.current=setInterval(v,a)),()=>{p.current&&(clearInterval(p.current),p.current=null)}),[a,o,t,d,v]);let R=Or(w=>c.find(T=>T.address.toLowerCase()===w.toLowerCase()),[c]);return{tokenBalances:c,isLoading:h,error:l,refetch:v,getTokenBalance:R,chain:m}}import{useState as on,useEffect as Nr,useCallback as xl,useRef as Al}from"react";function bl(e,t,o){let s=xe(),n=o??s,[c,i]=on([]),[h,u]=on(!1),[l,g]=on(null),r=Al(0),a=xl(async()=>{if(n){u(!0),g(null),r.current++;try{let d=await n.getTxHistory(e,t);i(d)}catch(d){g(d instanceof Error?d:new Error(String(d)))}finally{u(!1)}}},[n,e,t]);Nr(()=>{a().catch(()=>{})},[a]),Nr(()=>{if(!n)return;let d=()=>{a().catch(()=>{})};return n.on("statusChange",d),()=>{n.off("statusChange",d)}},[n,a]);let p={pending:c.filter(d=>d.status==="pending").length,confirmed:c.filter(d=>d.status==="confirmed").length,failed:c.filter(d=>d.status==="failed").length};return{entries:c,isLoading:h,error:l,refresh:a,summary:p}}import{fetchUserOperationReceipt as Rl,InvalidUserOperationReceiptError as Tl}from"@naculus/connect-appkit-core";import{useCallback as Te,useEffect as _r,useRef as pe,useState as oe}from"react";function Il(e){let t=e?.bundlerUrl,o=e?.pollInterval??2e3,s=e?.maxRetries??30,[n,c]=oe("idle"),[i,h]=oe(null),[u,l]=oe(e?.userOpHash??null),[g,r]=oe(null),[a,p]=oe(!1),[d,m]=oe(0),C=pe(0),[E,A]=oe(0),y=pe(null),v=pe(null),R=pe(0),w=pe(0),T=pe(null),k=Te(()=>{y.current&&(clearInterval(y.current),y.current=null),v.current&&(clearTimeout(v.current),v.current=null)},[]),b=Te(async(S,x)=>{if(!t||x!==R.current)return;let P=w.current+1;w.current=P,m(P);let O=new AbortController;T.current=O;let F=V=>{x===R.current&&(c("not_found"),p(!1),k(),r(V))},ne=V=>{if(x===R.current){if(P<=s){v.current=setTimeout(()=>{b(S,x)},o);return}F(V)}};try{let V=await Rl(t,S,O.signal);if(x!==R.current)return;if(V){h(V),c(V.success?"confirmed":"failed"),p(!1),k();return}c("pending"),ne(new Error("UserOperation not included after maximum retries"))}catch(V){if(x!==R.current||O.signal.aborted)return;let de=V instanceof Error?V:new Error("Unknown bundler response failure");if(de instanceof Tl){F(de);return}ne(new Error(`UserOperation status unavailable after ${P} attempt${P===1?"":"s"}: ${de.message}`))}finally{T.current===O&&(T.current=null)}},[t,o,s,k]),I=Te(S=>{R.current+=1;let x=R.current;if(T.current?.abort(),T.current=null,k(),l(S),h(null),r(null),w.current=0,m(0),A(0),C.current=Date.now(),!t){c("not_found"),p(!1),r(new Error("Bundler URL not configured"));return}c("pending"),p(!0),y.current=setInterval(()=>{A(Date.now()-C.current)},1e3),b(S,x)},[t,k,b]),W=Te(()=>{R.current+=1,T.current?.abort(),T.current=null,k(),p(!1)},[k]),_=Te(()=>{R.current+=1,T.current?.abort(),T.current=null,k(),l(null),c("idle"),h(null),r(null),p(!1),w.current=0,m(0),A(0)},[k]),D=e?.userOpHash??null,f=e?.autoStart!==!1;return _r(()=>{D&&f&&I(D)},[D,f,I]),_r(()=>()=>{R.current+=1,T.current?.abort(),T.current=null,k()},[k]),{status:n,receipt:i,userOpHash:u,error:g,isPolling:a,elapsedMs:E,attempts:d,start:I,stop:W,reset:_}}import{validateDestination as Nl}from"@naculus/connect-appkit-core";import{useMemo as _l}from"react";var Ul={"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."},Pl={"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"},Dr={en:Ul,zh:Pl},sn="en";function Wl(e){sn=e}function Ol(){return sn}function an(e){return Dr[sn][e]??Dr.en[e]??e}function Mr(e){let{isValid:t,level:o,issue:s}=Nl(e);return{isValid:t,level:o,warning:s?an(`address.${s}`):null}}function Dl({address:e}){return{validation:_l(()=>Mr(e),[e])}}function Ml(){let{status:e,session:t,accounts:o,chainId:s,error:n,connect:c,disconnect:i,reconnect:h,switchChain:u}=U(),l=e==="connected",g=e==="connecting",r=e==="reconnecting",a=o[0]??null;return{status:e,session:t,accounts:o,chainId:s,error:n,isConnected:l,isConnecting:g,isReconnecting:r,isDisconnected:e==="disconnected",currentAccount:a,connect:c,disconnect:i,reconnect:h,switchChain:u}}import{useCallback as cn,useMemo as Fr}from"react";var Lr={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"},Br={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."},Ie="Something went wrong",Ue="An unexpected error occurred. Please try again. If the problem persists, check your connection and wallet configuration.";function Pe(e){if(!e)return{title:Ie,description:Ue};let t=e;if(t.name==="WalletError"&&t.code){let o=t.code,s=Lr[o]??Ie,n=Br[o]??t.message??Ue;return{title:s,description:n,code:o}}if(e instanceof Error){let o=e.message;return/user rejected/i.test(o)||/rejected/.test(o)?{title:"Request Rejected",description:"The request was declined.",code:"user_rejected"}:/timeout/i.test(o)||/timed? ?out/i.test(o)?{title:"Request Timed Out",description:"The request took too long. Please try again.",code:"deeplink_timeout"}:/insufficient funds/i.test(o)?{title:"Insufficient Funds",description:"You don't have enough funds to complete this transaction.",code:"tx_failed"}:/network/i.test(o)||/chain/i.test(o)?{title:"Network Error",description:o,code:"chain_unsupported"}:{title:Ie,description:o||Ue}}return typeof e=="string"?{title:Ie,description:e||Ue}:{title:Ie,description:Ue}}function ln(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 Ll(){let{error:e,clearError:t}=U(),o=Fr(()=>e?Pe(e):null,[e]),s=Fr(()=>e?ln(e):!1,[e]),n=cn(()=>{t()},[t]),c=cn(h=>Pe(h),[]),i=cn(h=>async()=>{try{return await h()}catch(u){let l=Pe(u);if(u instanceof Error){let g=u;try{g.title=l.title,g.friendlyMessage=l.description,g.code===void 0&&l.code!==void 0&&(g.code=l.code)}catch{}throw g}throw Object.assign(new Error(l.description,{cause:u}),{title:l.title,code:l.code,friendlyMessage:l.description})}},[]);return{error:e,friendlyError:o,clearError:n,isRetryable:s,formatError:c,wrapAsync:i}}import{useState as et,useEffect as Bl,useCallback as Kr,useRef as Fl}from"react";import{TokenListManager as Kl}from"@naculus/connect-core";import{eip155ChainIdToNumber as Hr}from"@naculus/connect-appkit-core";function tt(e,t){let o=Fl(null),[s,n]=et([]),[c,i]=et(t?.autoLoad!==!1),[h,u]=et(!1),[l,g]=et(null);if(!o.current){let p={};t?.sources&&(p.sources=t.sources),o.current=new Kl(p)}let r=Kr(async()=>{let p=o.current;if(p){i(!0),g(null);try{await p.load();let d=e?Hr(e):void 0,m=p.getTokens(d!==void 0?{chainId:d}:void 0);n(m),u(!0)}catch(d){g(d instanceof Error?d:new Error(String(d)))}finally{i(!1)}}},[e]),a=Kr(async()=>{let p=o.current;if(p){i(!0),g(null);try{await p.refresh();let d=e?Hr(e):void 0,m=p.getTokens(d!==void 0?{chainId:d}:void 0);n(m),u(!0)}catch(d){g(d instanceof Error?d:new Error(String(d)))}finally{i(!1)}}},[e]);return Bl(()=>{t?.autoLoad!==!1&&r()},[r,t?.autoLoad]),{tokens:s,isLoading:c,isLoaded:h,error:l,refetch:a}}import{useState as Vr,useEffect as $l,useRef as Gl}from"react";import{TokenListManager as Xl}from"@naculus/connect-core";import{ETHEREUM_MAINNET_TOKENS as Hl,POLYGON_TOKENS as ql,OPTIMISM_TOKENS as Vl,ARBITRUM_TOKENS as zl,BASE_TOKENS as jl}from"@naculus/connect-core";function qr(){return[{name:"built-in",tokens:[...Hl,...ql,...Vl,...zl,...jl],enabled:!0},{name:"uniswap-default",url:"https://tokens.uniswap.org",enabled:!0,refreshInterval:1440*60*1e3}]}import{eip155ChainIdToNumber as Ql}from"@naculus/connect-appkit-core";var Yl=300,nt=null;function Jl(){return nt||(nt=new Xl({sources:qr()}),nt.load().catch(()=>{})),nt}function rt(e,t){let[o,s]=Vr({exact:[],fuzzy:[],hasMore:!1}),[n,c]=Vr(!1),i=Gl(null),h=e.trim();return $l(()=>{if(!h){s({exact:[],fuzzy:[],hasMore:!1}),c(!1);return}return i.current&&clearTimeout(i.current),c(!0),i.current=setTimeout(()=>{let u=Jl(),l=t?Ql(t):void 0,g=u.search(h,{chainId:l,limit:20});s(g),c(!1)},Yl),()=>{i.current&&clearTimeout(i.current)}},[h,t]),{results:o,isSearching:n}}import un,{useCallback as Zl}from"react";import{Fragment as ec,jsx as $,jsxs as G}from"react/jsx-runtime";function zr({chainId:e,onSelect:t,onClose:o,options:s}){let[n,c]=un.useState(""),{tokens:i,isLoading:h,error:u}=tt(e),{results:l,isSearching:g}=rt(n,n?e:void 0),r=s?.showRecommendations??!0,a=un.useMemo(()=>{if(n.trim()){let C=[...l.exact,...l.fuzzy].map(E=>E.token);return s?.filter?C.filter(s.filter):C}let m=i;return s?.filter?m.filter(s.filter):m},[n,l,i,s?.filter]),p=un.useMemo(()=>!r||n.trim()?[]:i.slice(0,6),[i,r,n]),d=Zl(m=>{t(m),o()},[t,o]);return G("div",{style:{background:"hsl(var(--background))",borderRadius:"12px",padding:"16px",color:"hsl(var(--foreground))",minWidth:"320px",maxWidth:"400px",fontFamily:"system-ui, sans-serif"},children:[G("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[$("h3",{style:{margin:0,fontSize:"16px",fontWeight:600},children:"Select Token"}),$("button",{type:"button",onClick:o,style:{background:"none",border:"none",color:"hsl(var(--muted-foreground))",cursor:"pointer",fontSize:"18px",padding:"4px 8px"},children:"\u2715"})]}),$("input",{type:"text",placeholder:"Search token name or paste address",value:n,onChange:m=>c(m.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}),h&&!g&&$("div",{style:{textAlign:"center",padding:"20px",color:"hsl(var(--muted-foreground))"},children:"Loading tokens..."}),u&&G("div",{style:{textAlign:"center",padding:"12px",color:"hsl(var(--destructive))",fontSize:"13px"},children:["Error: ",u.message]}),r&&p.length>0&&!n.trim()&&G("div",{style:{marginBottom:"12px"},children:[$("div",{style:{fontSize:"11px",color:"hsl(var(--muted-foreground))",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"8px"},children:"Popular"}),$("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap"},children:p.map(m=>G("button",{type:"button",onClick:()=>d(m),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:[m.logoURI?$("img",{src:m.logoURI,alt:"",style:{width:"16px",height:"16px",borderRadius:"50%"},onError:C=>{C.target.style.display="none"}}):null,m.symbol]},`${m.chainId}:${m.address}`))})]}),n.trim()&&!h&&$("div",{style:{fontSize:"11px",color:"hsl(var(--muted-foreground))",marginBottom:"8px"},children:a.length>0?G(ec,{children:[l.exact.length," exact, ",l.fuzzy.length," fuzzy",l.hasMore?" (more available)":""]}):"No results found"}),$("div",{style:{maxHeight:"320px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"2px"},children:a.map(m=>G("button",{type:"button",onClick:()=>d(m),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:C=>{C.target.style.background="hsl(var(--card))"},onMouseLeave:C=>{C.target.style.background="transparent"},children:[$("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:m.logoURI?$("img",{src:m.logoURI,alt:m.symbol,style:{width:"100%",height:"100%"},onError:C=>{let E=C.target;E.style.display="none",E.parentElement.textContent=m.symbol.slice(0,2)}}):m.symbol.slice(0,2)}),G("div",{style:{flex:1,minWidth:0},children:[$("div",{style:{fontWeight:600,fontSize:"14px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m.symbol}),$("div",{style:{fontSize:"12px",color:"hsl(var(--muted-foreground))",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m.name})]}),G("div",{style:{fontSize:"11px",color:"#666",textAlign:"right",flexShrink:0},children:[G("div",{children:[m.decimals," decimals"]}),G("div",{children:["Chain ",m.chainId]})]})]},`${m.chainId}:${m.address}`))})]})}import{createComponent as M}from"@stencil/react-output-target/runtime";import L from"react";import{AppkitAccordion as tc,defineCustomElement as nc}from"@naculus/connect-appkit-wc/dist/components/appkit-accordion.js";import{AppkitAccountButton as rc,defineCustomElement as oc}from"@naculus/connect-appkit-wc/dist/components/appkit-account-button.js";import{AppkitAlertDialog as sc,defineCustomElement as ac}from"@naculus/connect-appkit-wc/dist/components/appkit-alert-dialog.js";import{AppkitAvatar as ic,defineCustomElement as lc}from"@naculus/connect-appkit-wc/dist/components/appkit-avatar.js";import{AppkitBadge as cc,defineCustomElement as uc}from"@naculus/connect-appkit-wc/dist/components/appkit-badge.js";import{AppkitButton as pc,defineCustomElement as dc}from"@naculus/connect-appkit-wc/dist/components/appkit-button.js";import{AppkitCardContent as mc,defineCustomElement as fc}from"@naculus/connect-appkit-wc/dist/components/appkit-card-content.js";import{AppkitCardDescription as gc,defineCustomElement as hc}from"@naculus/connect-appkit-wc/dist/components/appkit-card-description.js";import{AppkitCardFooter as yc,defineCustomElement as Cc}from"@naculus/connect-appkit-wc/dist/components/appkit-card-footer.js";import{AppkitCardHeader as Sc,defineCustomElement as Ec}from"@naculus/connect-appkit-wc/dist/components/appkit-card-header.js";import{AppkitCardTitle as wc,defineCustomElement as kc}from"@naculus/connect-appkit-wc/dist/components/appkit-card-title.js";import{AppkitCard as vc,defineCustomElement as xc}from"@naculus/connect-appkit-wc/dist/components/appkit-card.js";import{AppkitCheckbox as Ac,defineCustomElement as bc}from"@naculus/connect-appkit-wc/dist/components/appkit-checkbox.js";import{AppkitCollapsible as Rc,defineCustomElement as Tc}from"@naculus/connect-appkit-wc/dist/components/appkit-collapsible.js";import{AppkitConnectButton as Ic,defineCustomElement as Uc}from"@naculus/connect-appkit-wc/dist/components/appkit-connect-button.js";import{AppkitDialog as Pc,defineCustomElement as Wc}from"@naculus/connect-appkit-wc/dist/components/appkit-dialog.js";import{AppkitDropdownMenu as Oc,defineCustomElement as Nc}from"@naculus/connect-appkit-wc/dist/components/appkit-dropdown-menu.js";import{AppkitInput as _c,defineCustomElement as Dc}from"@naculus/connect-appkit-wc/dist/components/appkit-input.js";import{AppkitPopover as Mc,defineCustomElement as Lc}from"@naculus/connect-appkit-wc/dist/components/appkit-popover.js";import{AppkitProgress as Bc,defineCustomElement as Fc}from"@naculus/connect-appkit-wc/dist/components/appkit-progress.js";import{AppkitScrollArea as Kc,defineCustomElement as Hc}from"@naculus/connect-appkit-wc/dist/components/appkit-scroll-area.js";import{AppkitSelect as qc,defineCustomElement as Vc}from"@naculus/connect-appkit-wc/dist/components/appkit-select.js";import{AppkitSeparator as zc,defineCustomElement as jc}from"@naculus/connect-appkit-wc/dist/components/appkit-separator.js";import{AppkitSkeleton as $c,defineCustomElement as Gc}from"@naculus/connect-appkit-wc/dist/components/appkit-skeleton.js";import{AppkitSwitch as Xc,defineCustomElement as Qc}from"@naculus/connect-appkit-wc/dist/components/appkit-switch.js";import{AppkitTabs as Yc,defineCustomElement as Jc}from"@naculus/connect-appkit-wc/dist/components/appkit-tabs.js";import{AppkitToggleGroup as Zc,defineCustomElement as eu}from"@naculus/connect-appkit-wc/dist/components/appkit-toggle-group.js";import{AppkitTooltip as tu,defineCustomElement as nu}from"@naculus/connect-appkit-wc/dist/components/appkit-tooltip.js";var ru=M({tagName:"appkit-accordion",elementClass:tc,react:L,events:{onAppkitToggle:"appkitToggle"},defineCustomElement:nc}),ou=M({tagName:"appkit-account-button",elementClass:rc,react:L,events:{},defineCustomElement:oc}),su=M({tagName:"appkit-alert-dialog",elementClass:sc,react:L,events:{onAppkitClose:"appkitClose",onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:ac}),au=M({tagName:"appkit-avatar",elementClass:ic,react:L,events:{},defineCustomElement:lc}),iu=M({tagName:"appkit-badge",elementClass:cc,react:L,events:{},defineCustomElement:uc}),lu=M({tagName:"appkit-button",elementClass:pc,react:L,events:{},defineCustomElement:dc}),cu=M({tagName:"appkit-card",elementClass:vc,react:L,events:{},defineCustomElement:xc}),uu=M({tagName:"appkit-card-content",elementClass:mc,react:L,events:{},defineCustomElement:fc}),pu=M({tagName:"appkit-card-description",elementClass:gc,react:L,events:{},defineCustomElement:hc}),du=M({tagName:"appkit-card-footer",elementClass:yc,react:L,events:{},defineCustomElement:Cc}),mu=M({tagName:"appkit-card-header",elementClass:Sc,react:L,events:{},defineCustomElement:Ec}),fu=M({tagName:"appkit-card-title",elementClass:wc,react:L,events:{},defineCustomElement:kc}),gu=M({tagName:"appkit-checkbox",elementClass:Ac,react:L,events:{onAppkitChange:"appkitChange"},defineCustomElement:bc}),hu=M({tagName:"appkit-collapsible",elementClass:Rc,react:L,events:{onAppkitToggle:"appkitToggle"},defineCustomElement:Tc}),yu=M({tagName:"appkit-connect-button",elementClass:Ic,react:L,events:{onAppkitConnect:"appkitConnect",onAppkitDisconnect:"appkitDisconnect",onAppkitStartPairing:"appkitStartPairing",onAppkitRetry:"appkitRetry",onAppkitCancelPairing:"appkitCancelPairing",onAppkitMobileDeepLink:"appkitMobileDeepLink",onAppkitCopyAddress:"appkitCopyAddress"},defineCustomElement:Uc}),Cu=M({tagName:"appkit-dialog",elementClass:Pc,react:L,events:{onAppkitClose:"appkitClose",onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:Wc}),Su=M({tagName:"appkit-dropdown-menu",elementClass:Oc,react:L,events:{onAppkitSelect:"appkitSelect"},defineCustomElement:Nc}),Eu=M({tagName:"appkit-input",elementClass:_c,react:L,events:{onAppkitChange:"appkitChange"},defineCustomElement:Dc}),wu=M({tagName:"appkit-popover",elementClass:Mc,react:L,events:{onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:Lc}),ku=M({tagName:"appkit-progress",elementClass:Bc,react:L,events:{},defineCustomElement:Fc}),vu=M({tagName:"appkit-scroll-area",elementClass:Kc,react:L,events:{},defineCustomElement:Hc}),xu=M({tagName:"appkit-select",elementClass:qc,react:L,events:{onAppkitChange:"appkitChange"},defineCustomElement:Vc}),Au=M({tagName:"appkit-separator",elementClass:zc,react:L,events:{},defineCustomElement:jc}),bu=M({tagName:"appkit-skeleton",elementClass:$c,react:L,events:{},defineCustomElement:Gc}),Ru=M({tagName:"appkit-switch",elementClass:Xc,react:L,events:{onAppkitChange:"appkitChange"},defineCustomElement:Qc}),Tu=M({tagName:"appkit-tabs",elementClass:Yc,react:L,events:{onAppkitTabChange:"appkitTabChange"},defineCustomElement:Jc}),Iu=M({tagName:"appkit-toggle-group",elementClass:Zc,react:L,events:{onAppkitChange:"appkitChange"},defineCustomElement:eu}),Uu=M({tagName:"appkit-tooltip",elementClass:tu,react:L,events:{},defineCustomElement:nu});export{ru as AppkitAccordion,ou as AppkitAccountButton,su as AppkitAlertDialog,au as AppkitAvatar,iu as AppkitBadge,lu as AppkitButton,cu as AppkitCard,uu as AppkitCardContent,pu as AppkitCardDescription,du as AppkitCardFooter,mu as AppkitCardHeader,fu as AppkitCardTitle,gu as AppkitCheckbox,hu as AppkitCollapsible,yu as AppkitConnectButton,Cu as AppkitDialog,Su as AppkitDropdownMenu,Eu as AppkitInput,wu as AppkitPopover,ku as AppkitProgress,vu as AppkitScrollArea,xu as AppkitSelect,Au as AppkitSeparator,bu as AppkitSkeleton,Ru as AppkitSwitch,Tu as AppkitTabs,Iu as AppkitToggleGroup,Uu as AppkitTooltip,kn as DEFAULT_EVM_CHAINS,Iy as LAMPORTS_PER_SOL,Uy as PassphraseCancelledError,Py as PassphraseGate,Oy as SolanaRpcError,zr as TokenSelector,or as TxMonitorContext,Br as WALLET_ERROR_DESCRIPTIONS,Lr as WALLET_ERROR_TITLES,vo as Web3ConnectProvider,mt as Web3Context,Xs as buildDelegationPolicyMessage,Zr as clearClient,ut as createClient,Ay as formatSol,po as getChainById,pt as getClient,dt as getDefaultChains,by as getLatestBlockhash,Ol as getLocale,Ry as getSignatureStatus,Ty as getSolanaBalance,Pe as getUserFriendlyError,ln as isRetryableError,Wy as parseSol,Fs as resetSessionKeyManager,Wl as setLocale,an as t,B as useAccount,Io as useAuthorizations,Bo as useBalance,Ct as useCapabilities,z as useChain,fn as useCompareCosts,Yo as useConnect,Ms as useCreateSessionKey,as as useDelegate,Se as useDelegation,Gs as useDelegationPolicy,Js as useDisconnect,ma as useERC20Allowance,Ea as useERC20Approve,Pa as useERC20Transfer,Ba as useERC20TransferSimulation,ea as useEmbeddedWallet,Tt as useExecuteCalls,yn as useExecuteRoute,ja as useLastTx,Ya as useLookupAddress,ys as useMppSession,ii as useNotification,ui as usePassphraseGate,us as usePaymentFetch,di as useResolveName,Ls as useRevokeSession,En as useRouteQuote,Vt as useSIWxLogin,Oi as useSIWxSession,bt as useSendCalls,ke as useSendTransaction,yi as useSendUserOperation,Bs as useSendWithSession,ki as useSession,It as useSessionKeys,Hi as useSignInWithEthereum,be as useSignInWithX,Pt as useSignMessage,ji as useSimulateTransfer,Zi as useSiwxAuthSession,nl as useSmartAccount,Jt as useSolanaAccount,il as useSolanaBalance,ul as useSolanaRoles,ks as useSolanaSessionKey,dl as useSolanaTransaction,fl as useSwitchChain,vl as useTokenBalance,tt as useTokenList,rt as useTokenSearch,Dt as useTransactionSimulation,bl as useTxHistory,Va as useTxMonitor,Il as useUserOpStatus,Dl as useValidateDestination,j as useViemClient,Ml as useWallet,U as useWeb3,Ll as useWeb3ErrorHandler,gs as useX402Signer,Mr as validateDestination};
1
+ import{formatSol as by,getLatestBlockhash as Ry,getSignatureStatus as Ty,getSolanaBalance as Iy,LAMPORTS_PER_SOL as Uy,PassphraseCancelledError as Py,PassphraseGate as Wy,parseSol as Oy,SolanaRpcError as Ny}from"@naculus/connect-core";import{compareCostsKey as jr}from"@naculus/connect-appkit-core";import{useCallback as pn,useEffect as dn,useRef as mn,useState as ot}from"react";function fn(e,t){let{operation:o,chains:s,options:n}=e,[c,i]=ot([]),[h,u]=ot(!1),[l,g]=ot(null),r=mn(!0),a=mn(0),p=jr(e),d=pn(async()=>{if(!s||s.length===0){i([]);return}if(!t)return;let C=++a.current;u(!0),g(null);try{let E=await t(o,s,n);r.current&&C===a.current&&i(E)}catch(E){r.current&&C===a.current&&(g(E instanceof Error?E:new Error(String(E))),i([]))}finally{r.current&&C===a.current&&u(!1)}},[p,t]);dn(()=>{d()},[d]),dn(()=>(r.current=!0,()=>{r.current=!1}),[]);let m=pn(async()=>{await d()},[d]);return{comparisons:c,loading:h,error:l,refresh:m}}import{toExecuteRouteError as Gr,validateRouteRecipient as $r}from"@naculus/connect-appkit-core";import{useCallback as gn,useEffect as Xr,useRef as hn,useState as st}from"react";function yn(e){let[t,o]=st(!1),[s,n]=st(null),[c,i]=st(null),h=hn(!0),u=hn(!1);Xr(()=>(h.current=!0,()=>{h.current=!1}),[]);let l=gn(async(r,a,p)=>{if(!e)return i({code:"no_executor",message:"No executeRoute function provided"}),n(null),null;let d=$r(r,a);if(d)return i(d),n(null),null;if(u.current)return i({code:"execution_in_progress",message:"A route execution is already in progress"}),null;u.current=!0,o(!0),i(null),n(null);try{let m=await e(r,a,p);return h.current&&n(m),m}catch(m){return h.current&&i(Gr(m)),null}finally{u.current=!1,h.current&&o(!1)}},[e]),g=gn(()=>{n(null),i(null),o(!1)},[]);return{execute:l,executing:t,result:s,error:c,reset:g}}import{isQuotableInput as Qr}from"@naculus/connect-appkit-core";import{useCallback as at,useEffect as Cn,useRef as Sn,useState as it}from"react";function En(e,t){let{fromChain:o,toChain:s,fromToken:n,toToken:c,amount:i,options:h}=e,[u,l]=it([]),[g,r]=it(!1),[a,p]=it(null),d=Sn(null),m=Sn(!0),C=at(async()=>{if(!Qr({fromChain:o,toChain:s,fromToken:n,amount:i})){l([]);return}if(t){r(!0),p(null);try{let y=await t(o,s,n,i,h,c);m.current&&l(y)}catch(y){m.current&&(p(y instanceof Error?y:new Error(String(y))),l([]))}finally{m.current&&r(!1)}}},[o,s,n,c,i,h,t]);Cn(()=>{if(d.current&&clearTimeout(d.current),!o||!s||!n||!i){l([]);return}return d.current=setTimeout(()=>{C()},300),()=>{d.current&&clearTimeout(d.current)}},[C,o,s,n,i]),Cn(()=>(m.current=!0,()=>{m.current=!1}),[]);let E=at(async()=>{await C()},[C]),A=at(()=>{l([]),p(null),r(!1)},[]);return{quotes:u,loading:g,error:a,refresh:E,clear:A}}import{logger as lt,WalletError as q}from"@naculus/connect-core";import{eip6963Connector as H}from"@naculus/connector-evm-injected";import{PassphraseGate as Yr}from"@naculus/connect-core";import{createWalletConnectConnector as Jr}from"@naculus/connector-walletconnect";var ct=null;function ut(e){let t=null,o=Jr({projectId:e.projectId,metadata:e.metadata,...e.walletConnect?.client?{client:e.walletConnect.client}:{},...e.walletConnect?.openUrl?{openUrl:e.walletConnect.openUrl}:{}}),s=null,n=null,c=null,i=null,h=e.passphrasePrompt&&e.enableEmbedded&&!e.embeddedConfig?.encryptionPassphrase?new Yr:null;e.enableEmbedded&&(n=import("@naculus/connector-embedded").then(r=>{let a={...e.embeddedConfig};h&&(a.encryptionPassphrase=h.request),e.enablePasskeys&&a.encryptionPassphrase&&!a.prfUnlock&&(a.prfUnlock={async derive(d){i&&await i;let m=c;return m?.hasCredential()?m.derivePrfKey(d):null}}),s=r.createPocketConnector(a),t?._setEmbeddedConnector(s)}).catch(r=>{lt.warn("react/client","Embedded wallet connector not available:",r),s=null})),e.enablePasskeys&&(i=import("@naculus/connector-passkeys").then(r=>{c=r.createPasskeysConnector(),t?._setPasskeysConnector(c)}).catch(r=>{lt.warn("react/client","Passkeys connector not available:",r),c=null}));let u=null,l=null;e.enableSolana&&(l=import("@naculus/connector-solana").then(r=>{let a=r.solanaConnector;e.solanaDefaultChain&&"configure"in a&&a.configure({defaultChain:e.solanaDefaultChain}),u=a,typeof window<"u"&&"startDiscovery"in a&&a.startDiscovery();for(let p of e.solanaWallets??[])a.registerWallet?.(p);t?._setSolanaConnector(u)}).catch(r=>{lt.warn("react/client","Solana connector not available:",r),u=null})),typeof window<"u"&&H.startDiscovery();for(let{info:r,provider:a}of e.injectedProviders??[])H.registerProvider(r,a);let g={connector:o,get embeddedConnector(){return s},getEmbeddedConnector:async()=>(n&&await n,s),get passkeysConnector(){return c},passphraseGate:h,solanaRpcUrl:e.solanaRpcUrl??null,get solanaConnector(){return u},connect:()=>o.connect(),connectInjected:async r=>H.connect(r),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,!c)throw new Error("Passkeys connector not enabled. Set enablePasskeys: true in config.");return c.connect()},startPairing:()=>o.startPairing(),completePairing:()=>o.completePairing(),cancelPairing:()=>o.cancelPairing?.(),signMessage:async(r,a)=>{if(r.id?.startsWith("eip6963-"))return H.signMessage(r,a);if(r.walletType==="passkeys"&&c)return c.signMessage(r,a);if(r.walletType==="embedded"){if(!s)throw new q("wallet_unavailable","Embedded wallet connector not available.");return s.signMessage(r,a)}if(r.walletType==="solana"){if(l&&await l,u)return u.signMessage(r,a);throw new q("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return o.signMessage(r,a)},signTransaction:async(r,a)=>{if(r.id?.startsWith("eip6963-"))return H.signTransaction(r,a);if(r.walletType==="embedded"){if(!s)throw new q("wallet_unavailable","Embedded wallet connector not available.");return s.signTransaction(r,a)}if(r.walletType==="solana"){if(l&&await l,u)return u.signTransaction(r,a);throw new q("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return o.signTransaction(r,a)},sendTransaction:async(r,a)=>{if(r.id?.startsWith("eip6963-"))return H.sendTransaction(r,a);if(r.walletType==="passkeys"&&c)return c.sendTransaction(r,a);if(r.walletType==="embedded"){if(!s)throw new q("wallet_unavailable","Embedded wallet connector not available.");return s.sendTransaction(r,a)}if(r.walletType==="solana"){if(l&&await l,u)return u.sendTransaction(r,a);throw new q("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return o.sendTransaction(r,a)},onAccountsChanged:(r,a)=>{let p=()=>{};return r.id?.startsWith("eip6963-")?H.onAccountsChanged?.(r,a)??p:r.walletType==="embedded"?s?.onAccountsChanged?.(r,a)??p:r.walletType==="passkeys"?p:r.walletType==="solana"?u?.onAccountsChanged?.(r,a)??p:o.onAccountsChanged?.(r,a)??p},onChainChanged:(r,a)=>{let p=()=>{};return r.id?.startsWith("eip6963-")?H.onChainChanged?.(r,a)??p:r.walletType==="passkeys"||r.walletType==="embedded"?p:r.walletType==="solana"?u?.onChainChanged?.(r,a)??p:o.onChainChanged?.(r,a)??p},getCapabilities:r=>r.id?.startsWith("eip6963-")?H.getCapabilities?.(r):r.walletType==="passkeys"?c?.getCapabilities?.(r):r.walletType==="solana"?u?.getCapabilities?.(r):r.walletType==="embedded"?s?.getCapabilities?.(r):o.getCapabilities?.(r),sendCalls:async(r,a,p,d)=>{if(r.id?.startsWith("eip6963-"))return H.sendCalls(r,a,p,d);if(r.walletType==="passkeys"&&c)return c.sendCalls(r,a,p,d);if(r.walletType==="solana"){if(l&&await l,u)return u.sendCalls(r,a,p,d);throw new q("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}if(r.walletType==="embedded"){if(!s?.sendCalls)throw new q("method_not_allowed","Embedded wallet does not support sendCalls");return s.sendCalls(r,a,p,d)}if(!o.sendCalls)throw new q("method_not_allowed","sendCalls not supported by this connector");return o.sendCalls(r,a,p,d)},showCallsStatus:async(r,a)=>{if(r.id?.startsWith("eip6963-"))return H.showCallsStatus(r,a);if(r.walletType==="passkeys"||r.walletType==="embedded")throw new q("method_unsupported",`${r.walletType} wallets have no UI to display a call bundle.`);if(!o.showCallsStatus)throw new q("method_unsupported","This connector cannot display call status.");return o.showCallsStatus(r,a)},getCallsStatus:async(r,a)=>{if(r.id?.startsWith("eip6963-")&&H.getCallsStatus)return H.getCallsStatus(r,a);if(r.walletType==="passkeys"&&c?.getCallsStatus)return c.getCallsStatus(r,a);if(r.walletType==="embedded")throw new q("method_not_allowed","Embedded wallet does not support getCallsStatus");if(!o.getCallsStatus)throw new q("method_not_allowed","getCallsStatus not supported by this connector");return o.getCallsStatus(r,a)},reconnect:async r=>r.walletType==="eip6963"?H.reconnect(r):r.walletType==="embedded"?s?s.reconnect(r):r:r.walletType==="solana"?r:o.reconnect(r),disconnect:async r=>{if(r.id?.startsWith("eip6963-")||r.walletType==="eip6963")return H.disconnect(r);if(r.walletType==="embedded"&&s)return s.disconnect();if(r.walletType==="passkeys"&&c)return c.disconnect(r);if(r.walletType==="solana"){if(l&&await l,u)return u.disconnect(r);throw new q("wallet_unavailable","Solana connector not available. Ensure enableSolana is true and @naculus/connector-solana is installed.")}return o.disconnect(r)},getAllConnectors:()=>{let r=[o];return s&&r.push(s),c&&r.push(c),u&&r.push(u),r},_setEmbeddedConnector:r=>{s=r},_setPasskeysConnector:r=>{c=r},_setSolanaConnector:r=>{u=r}};return t=g,ct=g,g}function pt(){return ct}function Zr(){ct=null}import{isEvmAddress as An,parseCaip10 as Ao}from"@naculus/connect-core";import{useMemo as bo}from"react";import{createConnectorManager as mo,createSessionManager as fo,LocalStorageSessionStorage as go,logger as J,WalletError as ho}from"@naculus/connect-core";import{eip6963Connector as Oe}from"@naculus/connector-evm-injected";import{createContext as yo,useCallback as K,useContext as Co,useEffect as me,useMemo as fe,useReducer as So,useRef as vn}from"react";import{logger as eo}from"@naculus/connect-core";import{issueNonce as to,parseSiwxMessage as no}from"@naculus/siwx";function se(e,t){let o=t.split(":",1)[0],n=(e.namespaces[o]?.accounts??[]).filter(c=>c.startsWith(`${o}:`)).map(c=>({namespace:o,caip10:c}))[0];if(n)return{...n,address:n.caip10.split(":").pop()??n.caip10}}function ro(e){return e.namespaces.eip155?.chains?.[0]??e.namespaces.solana?.chains?.[0]??e.namespaces.xrpl?.chains?.[0]??"eip155:1"}async function wn(e){let{session:t,siwx:o,signMessage:s}=e;if(!o||!t)return{kind:"skipped"};try{let n=ro(t),c=se(t,n);if(!c)throw new Error("No account found in session");let{address:i}=c,h=await o.createMessage({address:i,chainId:n}),u=no(h);if(!u?.nonce)throw new Error("SIWx message must contain a nonce");await to(u.nonce);let l=await s(t,{message:h,address:i,chainId:n});return await o.handleSignComplete?.({message:h,signature:l}),{kind:"authenticated",address:i,chainId:n}}catch(n){let c=n instanceof Error?n:new Error("Wallet authentication failed");return eo.error("appkit/core","SIWx authentication failed:",n),{kind:"failed",error:c,fatal:o.required!==!1}}}import{initialWeb3State as Eo,web3Reducer as wo,withRetry as ko,withTimeout as xn}from"@naculus/connect-appkit-core";import{resolveChain as oo}from"@naculus/connect-appkit-core";import{CHAINS as We,DEFAULT_RPC_URLS as so,eip155Reference as ao,getRpcUrl as io}from"@naculus/connect-core";var lo=[{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 co(e){let t=We[e];if(!t||!t.explorerUrl)return null;let o=t.caip2Id;return{caip2:o,name:t.name,rpcUrl:io(o,so[o]??""),explorerUrl:t.explorerUrl,token:t.nativeCurrency.symbol}}function uo(){if(!We)return[];let e=[],t=Object.keys(We).map(Number).sort((o,s)=>o-s);for(let o of t){let s=co(o);s&&e.push(s)}for(let o of lo){let s=ao(o.caip2);(s===null||!We[s])&&e.push(o)}return e}var kn=uo();function po(e,t){return oo(e,t)??void 0}function dt(){return[...kn]}import{jsx as xo}from"react/jsx-runtime";var mt=yo(null);function vo({children:e,config:t,autoConnect:o=!0}){let[s,n]=So(wo,Eo),c=fe(()=>t.chains??dt(),[t.chains]),i=t.connectionTimeout??3e4,h=t.maxRetries??2,u=fe(()=>t.sessionStorage??new go(t.storageKey??"naculus_web3_session",t.encryptionKey),[t.sessionStorage,t.storageKey,t.encryptionKey]),l=fe(()=>ut({projectId:t.projectId,metadata:t.metadata,enableEmbedded:t.enableEmbedded,embeddedConfig:t.embeddedConfig,enablePasskeys:t.enablePasskeys,enableSolana:t.enableSolana,solanaDefaultChain:t.solanaDefaultChain,walletConnect:t.walletConnect,solanaWallets:t.solanaWallets,injectedProviders:t.injectedProviders}),[t.projectId,t.metadata,t.enableEmbedded,t.embeddedConfig,t.enablePasskeys,t.enableSolana,t.solanaDefaultChain,t.walletConnect,t.solanaWallets,t.injectedProviders]),g=vn(null),r=vn(null),a=fe(()=>{let f=mo();for(let O of[Oe,...l.getAllConnectors()])f.register(O.id,O);let S={},x={};for(let O of c){let F=O.caip2;O.rpcUrl&&(S[F]=O.rpcUrl),O.token&&(x[F]={name:O.name,symbol:O.token,decimals:18})}let P=fo(f,{autoRefreshFeeOnSwitch:t.autoRefreshFeeOnSwitch??!0,defaultRpcUrls:S,defaultCurrencies:x,encryptionKey:t.encryptionKey});return g.current=P,P},[l,c,t.autoRefreshFeeOnSwitch,t.encryptionKey]);me(()=>{let f=F=>{let{walletSession:ne}=F.bundle;n({type:"SET_SESSION",payload:ne});let V=[];Object.values(ne.namespaces).forEach(de=>{V.push(...de.accounts)}),n({type:"SET_ACCOUNTS",payload:V}),n({type:"SET_CHAIN",payload:F.bundle.activeChainId}),n({type:"SET_STATUS",payload:"connected"})},S=()=>{n({type:"RESET"})},x=F=>{n({type:"SET_CHAIN",payload:F.newChainId})},P=F=>f(F),O=()=>{u.clear(),n({type:"RESET"})};return a.on("sessionConnected",f),a.on("sessionDisconnected",S),a.on("chainChanged",x),a.on("sessionScopeChanged",P),a.on("sessionRevoked",O),()=>{a.off("sessionConnected",f),a.off("sessionDisconnected",S),a.off("chainChanged",x),a.off("sessionScopeChanged",P),a.off("sessionRevoked",O)}},[a,u]),me(()=>{let f=()=>{u.clear(),n({type:"RESET"})};l.connector.onSessionExpiry(f)},[l,u]);let p=K(()=>{for(let f of[Oe,...l.getAllConnectors()])a.registerConnector(f)},[l,a]),d=K(async f=>{p();let S=[Oe,...l.getAllConnectors()].find(P=>P.id===f.walletType||P.kind===f.walletType);S&&!f.connectorId&&(f.connectorId=S.id);let x=f.namespaces.eip155?.chains?.[0]??f.namespaces.solana?.chains?.[0]??f.namespaces.xrpl?.chains?.[0];x&&await a.attach(f,x)},[l,a,p]),m=K(f=>{if(n({type:"SET_SESSION",payload:f}),f){let S=[];Object.values(f.namespaces).forEach(F=>{S.push(...F.accounts)}),n({type:"SET_ACCOUNTS",payload:S});let x=f.namespaces.eip155?.chains?.[0],P=f.namespaces.solana?.chains?.[0],O=f.namespaces.xrpl?.chains?.[0];n({type:"SET_CHAIN",payload:x??P??O??null})}else n({type:"SET_ACCOUNTS",payload:[]}),n({type:"SET_CHAIN",payload:null})},[]);me(()=>{let f=s.session,S=l;return!f||!S?.onAccountsChanged?void 0:S.onAccountsChanged(f,P=>{if(P.length===0){u.clear().finally(()=>n({type:"RESET"}));return}m(f),u.save(f)})},[s.session,l,u,m]),me(()=>{let f=s.session,S=l;if(!(!f||!S?.onChainChanged))return S.onChainChanged(f,x=>{m(f),u.save(f);let P=a.syncExternalChain;if(!P)return;let O=P.call(a,x).catch(F=>{J.warn("react/provider","External chain sync error:",F)});r.current=O,O.finally(()=>{r.current===O&&(r.current=null)})})},[s.session,l,u,m,a]);let C=K(async f=>{if(!t.siwx||!f)return!0;n({type:"SET_STATUS",payload:"authenticating"});let S=await wn({session:f,siwx:t.siwx,signMessage:(x,P)=>l.signMessage(x,P)});return S.kind==="failed"&&S.fatal?(await u.clear(),n({type:"RESET"}),n({type:"SET_ERROR",payload:S.error}),!1):!0},[t.siwx,l,u]),E=K(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let f=await xn(l.connect(),i,"Wallet connect");await u.save(f),m(f);try{await d(f)}catch(S){J.warn("react/provider","SessionManager sync error:",S)}if(!await C(f))return;n({type:"SET_STATUS",payload:"connected"})}catch(f){let S=f instanceof Error?f.message:"Connection failed";n({type:"SET_ERROR",payload:f instanceof Error?f:new Error(S)}),n({type:"SET_STATUS",payload:"disconnected"})}},[l,u,m,i,C,d]),A=K(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let f=await l.connectEmbedded();if(await u.save(f),m(f),await d(f),!await C(f))return;n({type:"SET_STATUS",payload:"connected"})}catch(f){let S=f instanceof Error?f.message:"Embedded wallet connection failed";n({type:"SET_ERROR",payload:f instanceof Error?f:new Error(S)}),n({type:"SET_STATUS",payload:"disconnected"})}},[l,u,m,C,d]),y=K(async()=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let f=await l.connectPasskeys();if(await u.save(f),m(f),await d(f),!await C(f))return;n({type:"SET_STATUS",payload:"connected"})}catch(f){let S=f instanceof Error?f.message:"Passkeys connection failed";n({type:"SET_ERROR",payload:f instanceof Error?f:new Error(S)}),n({type:"SET_STATUS",payload:"disconnected"})}},[l,u,m,C,d]),v=K(async()=>{if(!s.session){n({type:"RESET"});return}try{await l.disconnect(s.session)}catch(f){J.error("react/provider","Disconnect error:",f)}try{let f=g.current;f&&await f.disconnect()}catch(f){J.warn("react/provider","SessionManager disconnect error:",f)}await u.clear(),n({type:"RESET"})},[l,s.session,u]),R=K(async f=>{n({type:"SET_STATUS",payload:"connecting"}),n({type:"SET_ERROR",payload:null});try{let S=await xn(l.connectInjected(f),i,"Injected wallet connect");await u.save(S),m(S);try{await d(S)}catch(x){J.warn("react/provider","SessionManager sync error:",x)}if(!await C(S))return;n({type:"SET_STATUS",payload:"connected"})}catch(S){let x=S instanceof Error?S.message:"Connection failed";n({type:"SET_ERROR",payload:S instanceof Error?S:new Error(x)}),n({type:"SET_STATUS",payload:"disconnected"})}},[l,u,m,i,C,d]),w=K(async()=>l.startPairing(),[l]),T=K(()=>{l.cancelPairing?.()},[l]),k=K(async()=>{let f=await l.completePairing();return await u.save(f),m(f),await d(f),await C(f)&&n({type:"SET_STATUS",payload:"connected"}),f},[l,u,m,C,d]),b=K(async f=>{let S=t.siwx;if(!S||S.required===!1)return!0;try{if(await S.hasValidSession?.())return!0}catch(x){J.warn("react/provider","siwx.hasValidSession failed",x)}return C(f)},[t.siwx,C]),I=K(async()=>{let f=await u.load();if(!f){n({type:"SET_STATUS",payload:"disconnected"});return}n({type:"SET_STATUS",payload:"reconnecting"});try{let S=await ko(()=>l.reconnect(f),{maxRetries:h,baseDelay:1e3,label:"reconnect"});m(S);try{let x=g.current;x&&(p(),await x.restoreFromPersistence())}catch(x){J.warn("react/provider","SessionManager restore error:",x)}if(!await b(S))return;n({type:"SET_STATUS",payload:"connected"})}catch(S){J.error("react/provider","Reconnect error:",S),await u.clear(),n({type:"SET_STATUS",payload:"disconnected"}),n({type:"SET_SESSION",payload:null})}},[l,u,m,h,p,b]),W=K(async f=>{r.current&&await r.current;let S=g.current;if(S?.getActiveBundle()){await S.switchChain(f),m(s.session);return}if(!s.session)throw new Error("No active session");try{s.session.walletType==="eip6963"||s.session.id?.startsWith("eip6963-")?await Oe.switchChain(s.session,f):s.session.walletType==="embedded"&&l.embeddedConnector?await l.embeddedConnector.switchChain?.(s.session,f):s.session.walletType==="passkeys"&&l.passkeysConnector?await l.passkeysConnector.switchChain?.(s.session,f):s.session.walletType==="solana"&&l.solanaConnector?await l.solanaConnector.switchChain?.(s.session,f):await l.connector.switchChain(s.session,f),m(s.session)}catch(x){throw new ho("chain_unsupported","Failed to switch chain",x)}},[l,s.session,m]);me(()=>{o&&I()},[o,I]);let _=K(()=>{n({type:"SET_ERROR",payload:null})},[]),D=fe(()=>({...s,connect:E,connectEmbedded:A,connectPasskeys:y,disconnect:v,reconnect:I,switchChain:W,startPairing:w,completePairing:k,cancelPairing:T,connectInjected:R,clearError:_,isConnected:s.status==="connected",chains:c,client:l,sessionManager:a}),[s,E,A,y,v,I,W,w,k,T,R,_,c,l,a]);return xo(mt.Provider,{value:D,children:e})}function U(){let e=Co(mt);if(!e)throw new Error("useWeb3 must be used within a Web3ConnectProvider");return e}function B(){let{accounts:e,isConnected:t}=U(),o=bo(()=>!t||e.length===0?null:e.map(n=>{let c=Ao(n);return c?{address:n,namespace:c.namespace,isEVM:c.namespace==="eip155"&&An(c.address)}:{address:n,namespace:null,isEVM:An(n)}}),[e,t]),s=o?.find(n=>n.isEVM)?.address??null;return{accounts:o,evmAccount:s,primaryAccount:e[0]??null,isConnected:t,count:e.length}}import{listAuthorizations as Ro,revokeListedAuthorization as To}from"@naculus/connect-core";import{useCallback as bn,useEffect as Rn,useRef as ft,useState as gt}from"react";function Io({managers:e}){let t=ft(e);t.current=e;let o=ft(0),s=ft(!0),[n,c]=gt([]),[i,h]=gt(!1),[u,l]=gt(null);Rn(()=>()=>{s.current=!1,o.current+=1},[]);let g=bn(async()=>{let a=++o.current;h(!0),l(null);try{let p=await Ro(t.current);s.current&&a===o.current&&c(p)}catch(p){s.current&&a===o.current&&l(p instanceof Error?p:new Error("Failed to list authorizations"))}finally{s.current&&a===o.current&&h(!1)}},[]);Rn(()=>{g()},[g]);let r=bn(async a=>{try{let p=await To(t.current,a);return await g(),p}catch(p){let d=p instanceof Error?p:new Error("Failed to revoke authorization");throw s.current&&l(d),d}},[g]);return{entries:n,loading:i,error:u,refresh:g,revoke:r}}import{chainNumber as Uo,resolveChain as Po,toViemChain as Wo}from"@naculus/connect-appkit-core";import{useState as ge,useEffect as ht,useCallback as Oo,useMemo as he,useRef as No}from"react";import{createPublicClient as _o,http as Do,formatEther as Mo}from"viem";import{getNativeTokenPriceUsd as Lo}from"@naculus/connect-core";function Bo(e){let{evmAccount:t,isConnected:o}=B(),{chainId:s,chains:n}=U(),[c,i]=ge(null),[h,u]=ge(!1),[l,g]=ge(null),[r,a]=ge(null),p=e?.refreshInterval,d=No(null),m=he(()=>Po(n,s),[s,n]),C=m?Uo(m):null,E=he(()=>m?Wo(m,C):null,[m,C]),A=he(()=>m?.token??null,[m]),[y,v]=ge(null);ht(()=>{if(!E||!m?.rpcUrl){v(null);return}let k=_o({transport:Do(m.rpcUrl),chain:E});return v(k),()=>{}},[m,E]);let R=Oo(async()=>{if(!t||!y){i(null);return}u(!0),g(null);try{let b=t.includes(":")?t.split(":").pop():t,[I,W]=await Promise.all([y.getBalance({address:b}),s?Lo(s,m?.rpcUrl).catch(()=>null):Promise.resolve(null)]);i(I.toString()),a(W)}catch(k){g(k instanceof Error?k:new Error("Failed to fetch balance")),i(null),a(null)}finally{u(!1)}},[t,y,s,m?.rpcUrl]);ht(()=>{o&&t&&R()},[o,t,R]),ht(()=>(p&&p>0&&o&&t&&(d.current=setInterval(R,p)),()=>{d.current&&(clearInterval(d.current),d.current=null)}),[p,o,t,R]);let w=he(()=>{if(c===null)return null;try{return Mo(BigInt(c))}catch{return null}},[c]),T=he(()=>{if(r===null||w===null)return null;let k=parseFloat(w);if(Number.isNaN(k))return null;let b=k*r;return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(b)},[r,w]);return{balance:c,formatted:w,symbol:A,usdPrice:r,usdValue:T,isLoading:h,error:l,refetch:R,chain:m}}import{atomicSupportFor as Fo,normalizeCapabilities as Ko,selectChainCapabilities as Ho}from"@naculus/connect-appkit-core";import{useCallback as qo,useEffect as Vo,useRef as zo,useState as yt}from"react";function N(e){return e??pt()}function Ct(){let{client:e,session:t,chainId:o}=U(),[s,n]=yt(null),[c,i]=yt(!1),[h,u]=yt(null),l=zo(0),g=qo(async()=>{let r=++l.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(r!==l.current)return;n(Ko(p))}catch(p){if(r!==l.current)return;n(null),u(p instanceof Error?p:new Error("Capability query failed"))}finally{r===l.current&&i(!1)}},[e,t]);return Vo(()=>{g()},[g]),{capabilities:s,current:Ho(s,o),atomic:Fo(s,o),isFetching:c,error:h,refetch:g}}import{useMemo as St}from"react";import{chainsForNamespace as jo,describeChain as Go,resolveChain as $o}from"@naculus/connect-appkit-core";function z(){let{chainId:e,session:t,switchChain:o,chains:s}=U(),n=St(()=>$o(s,e),[s,e]),c=St(()=>t?Go(s,e):null,[s,e,t]),i=St(()=>jo(s,e),[s,e]);return{chainId:e,currentChain:n,chainInfo:c,availableChains:i,chains:i,isEvm:e?.startsWith("eip155:")??!1,switchChain:o}}import{useCallback as Xo,useState as Tn}from"react";import{WalletError as Qo}from"@naculus/connect-core";function Yo(){let{connect:e,status:t}=U(),[o,s]=Tn(!1),[n,c]=Tn(null);return{connect:Xo(async()=>{s(!0),c(null);try{await e()}catch(h){let u=h instanceof Error?h.message:"Connection failed";c(h instanceof Qo?h:new Error(u))}finally{s(!1)}},[e]),isConnecting:o||t==="connecting",error:n}}import{bareEvmAddress as ns}from"@naculus/connect-appkit-core";import{delegateAccount as rs,eip155Reference as os,REVOKE_DELEGATE as ss,WalletError as Un}from"@naculus/connect-core";import{useCallback as Ne,useEffect as Pn,useRef as Wn,useState as wt}from"react";import{chainNumber as Jo,toViemChain as Zo}from"@naculus/connect-appkit-core";import{useMemo as Et}from"react";import{createPublicClient as es,http as In,createWalletClient as ts}from"viem";function j(){let{evmAccount:e,isConnected:t}=B(),{currentChain:o,chains:s}=z(),n=o?Jo(o):null,c=Et(()=>o?Zo(o,n):null,[o,n]),i=Et(()=>c?es({transport:In(c.rpcUrls.default.http[0]),chain:c}):null,[c]),h=Et(()=>{if(!t||!e||!c)return null;let u=e.includes(":")?e.split(":").pop():e;return ts({transport:In(c.rpcUrls.default.http[0]),chain:c,account:u})},[t,e,c]);return{publicClient:i,walletClient:h,chains:s}}function as(e){let{evmAccount:t}=B(),{session:o,chainId:s,client:n}=U(),{publicClient:c}=j(),[i,h]=wt(null),[u,l]=wt(!1),[g,r]=wt(null),a=Wn(0),p=Wn(!1);Pn(()=>()=>{a.current+=1},[]),Pn(()=>{a.current+=1,h(null),l(!1),r(null)},[o,s,t]);let d=Ne(async(A,y)=>{let v=k=>(r(k),null);if(p.current)return v(new Error("A delegation is already in progress"));let R=ns(t);if(!o||!R||!s)return v(new Un("wallet_unavailable","No connected EVM account"));if(!c||c.chain?.id!==os(s))return v(new Un("chain_mismatch",`No RPC client for ${s}; refusing to read the nonce elsewhere.`));let w=o.walletType==="embedded"?N(n)?.embeddedConnector??{}:{},T=++a.current;p.current=!0,l(!0),r(null),h(null);try{let k=await rs({connector:w,session:o,account:R,chainId:s,delegate:A,allowlist:y,getTransactionCount:(b,I)=>c.getTransactionCount({address:b,blockTag:I})});return T!==a.current?null:(h(k),k)}catch(k){return T!==a.current?null:v(k instanceof Error?k:new Error("Failed to send delegation"))}finally{p.current=!1,T===a.current&&l(!1)}},[s,n,t,c,o]),m=Ne(A=>d(A,e.allowlist),[d,e.allowlist]),C=Ne(()=>d(ss,[]),[d]),E=Ne(()=>{a.current+=1,h(null),l(!1),r(null)},[]);return{delegate:m,revoke:C,result:i,isPending:u,error:g,reset:E}}import{applySettlementVerification as On,DEFAULT_VERIFY_RETRY as is,describePayment as ls}from"@naculus/connect-appkit-core";import{useCallback as Nn,useEffect as cs,useRef as ye,useState as kt}from"react";function us(e,t={}){let[o,s]=kt(0),[n,c]=kt(null),[i,h]=kt(null),u=ye(0),l=ye(0),g=ye(e);g.current=e;let r=ye(t);r.current=t;let a=ye(0);cs(()=>()=>{u.current+=1,l.current+=1,a.current+=1},[]);let p=Nn(async(m,C)=>{let E=++u.current,A=l.current;s(y=>y+1),h(null);try{let y=await g.current(m,C),v=ls(m,y);if(v&&A===l.current){let R=r.current.verify;if(!R)c(v);else{v=On(v,{status:"pending"}),c(v);let w=++a.current,T=r.current.verifyRetry??is;Promise.resolve().then(async()=>{let k={status:"pending"};for(let b=0;b<T.attempts;b+=1){if(b>0&&await new Promise(I=>setTimeout(I,T.delayMs)),A!==l.current||w!==a.current)return;try{k=await R(y)}catch(I){k={status:"unavailable",reason:I instanceof Error?I.message:"Settlement verification failed"}}if(k.status!=="pending")break}A===l.current&&w===a.current&&c(b=>b&&On(b,k))})}}return y}catch(y){let v=y instanceof Error?y:new Error("Paid request failed");throw E===u.current&&h(v),v}finally{s(y=>y-1)}},[]),d=Nn(()=>{u.current+=1,l.current+=1,a.current+=1,c(null),h(null)},[]);return{payFetch:p,isPending:o>0,lastPayment:n,error:i,reset:d}}import{createX402WalletSigner as ps,findX402Provider as ds}from"@naculus/connect-appkit-core";import{eip6963Connector as ms}from"@naculus/connector-evm-injected";import{useMemo as fs}from"react";function gs(){let{session:e,accounts:t,chainId:o,client:s,switchChain:n}=U(),c=t.join("\0");return fs(()=>{let i=ds(e,{injected:ms.getDiscoveredWallets(),walletConnect:s.connector});return ps(e,i,n)},[e,c,o,s.connector,n])}import{readCurrentMppSessionChannel as Ce,readMppRecoveryChannelId as _n,readMppSessionReceipt as Dn}from"@naculus/connect-appkit-core";import{useCallback as ae,useEffect as Mn,useMemo as hs,useRef as _e,useState as ie}from"react";function Ln(e){return e instanceof Error?e:new Error("MPP session operation failed")}function ys(e){let[t,o]=ie(0),[s,n]=ie(()=>e.meter.pending),[c,i]=ie(()=>Ce(e)),[h,u]=ie(null),[l,g]=ie(null),[r,a]=ie(null),p=_e(0),d=_e(0),m=_e(!0),C=_e(e);C.current=e,Mn(()=>{p.current+=1,d.current+=1,o(0),n(e.meter.pending),i(Ce(e)),u(null),g(null),a(null)},[e]),Mn(()=>()=>{m.current=!1,p.current+=1,d.current+=1},[]);let E=ae(async(k,b,I=!1)=>{let W=++p.current,_=d.current,D=C.current;o(f=>f+1),a(null);try{let f=await k(D);if(m.current&&_===d.current){b?.(f);let S=Ce(D);i(S),n(D.meter.pending),(I||!S)&&g(null)}return f}catch(f){let S=Ln(f);if(m.current&&_===d.current){let x=Ce(D);i(x),n(D.meter.pending);let P=_n(f);P?g(P):x||g(null),W===p.current&&a(S)}throw S}finally{m.current&&_===d.current&&o(f=>f-1)}},[]),A=ae((k,b)=>E(I=>I(k,b),I=>{let W=Dn(I.receipt);W&&u(W)}),[E]),y=ae(()=>E(k=>k.close(),k=>{let b=Dn(k.receipt);b&&u(b)},!0),[E]),v=ae(()=>E(k=>k.forceClose(),void 0,!0),[E]),R=ae(k=>{try{C.current.meter.add(k),n(C.current.meter.pending),a(null)}catch(b){let I=Ln(b);throw a(I),g(_n(b)),I}},[]),w=ae(()=>{p.current+=1,d.current+=1,o(0),n(C.current.meter.pending),i(Ce(C.current)),u(null),g(null),a(null)},[]),T=hs(()=>({add:R}),[R]);return{fetch:A,meter:T,pending:s,channel:c,lastReceipt:h,recoveryChannelId:l,isPending:t>0,error:r,close:y,forceClose:v,reset:w}}import{createSolanaSessionKeyFlow as Cs}from"@naculus/connect-appkit-core";import{useCallback as De,useEffect as Ss,useMemo as Es,useRef as ws,useState as vt}from"react";function Bn(){return Promise.reject(new Error("No Solana session key manager is connected"))}function ks(e){let[t,o]=vt([]),[s,n]=vt(0),[c,i]=vt(null),h=ws(0),u=e?.manager,l=e?.rpc,g=e?.owner,r=Es(()=>u&&l&&g?Cs({manager:u,rpc:l,owner:g}):null,[u,l,g]),a=De(async(C,E)=>{let A=++h.current;n(y=>y+1),i(null);try{return await C()}catch(y){let v=y instanceof Error?y:new Error(E);throw A===h.current&&i(v),v}finally{if(r&&A===h.current){let y=await r.list().catch(()=>null);y&&A===h.current&&o(y)}n(y=>y-1)}},[r]),p=De(async()=>{if(!r){o([]);return}let C=h.current,E=await r.list();C===h.current&&o(E)},[r]);Ss(()=>(h.current+=1,p().catch(()=>{}),()=>{h.current+=1}),[p]);let d=De(C=>r?a(()=>r.create(C),"Could not create the key"):Bn(),[r,a]),m=De(C=>r?a(()=>r.revoke(C),"Could not revoke the key"):Bn(),[r,a]);return{keys:t,create:d,revoke:m,refresh:p,isPending:s>0,error:c}}import{readDelegation as vs,UNKNOWN_DELEGATION as xt}from"@naculus/connect-core";import{useCallback as xs,useEffect as As,useRef as bs,useState as At}from"react";function Se(){let{publicClient:e}=j(),{evmAccount:t}=B(),[o,s]=At(xt),[n,c]=At(!1),[i,h]=At(null),u=bs(0),l=t?.includes(":")?t.split(":").pop():t,g=xs(async()=>{let r=++u.current;if(!e||!l){s(xt),c(!1),h(null);return}c(!0),h(null);try{let a=await e.getCode({address:l});if(r!==u.current)return;s(vs(a??"0x"))}catch(a){if(r!==u.current)return;s(xt),h(a instanceof Error?a:new Error("Code read failed"))}finally{r===u.current&&c(!1)}},[e,l]);return As(()=>{g()},[g]),{...o,isFetching:n,error:i,refetch:g}}import{bareEvmAddress as qs,createDelegationPolicyFlow as Vs,isVerifiablePolicy as zs}from"@naculus/connect-appkit-core";import{useCallback as we,useEffect as js,useMemo as Gs,useState as Be}from"react";import{recoverMessageAddress as $s}from"viem";import{planExecution as Us,WalletError as Ps}from"@naculus/connect-core";import{useCallback as Kn,useState as Rt}from"react";import{errorMessage as Fn}from"@naculus/connect-appkit-core";import{chooseExecutionStrategy as Ts,getAccountCapabilities as Is,WalletError as Z}from"@naculus/connect-core";import{useCallback as Le,useState as Ee}from"react";import{WalletError as Rs}from"@naculus/connect-core";function Me(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 Rs("tx_failed","Wallet did not return a valid 32-byte transaction hash")}function bt(){let{session:e,chainId:t,client:o}=U(),[s,n]=Ee("idle"),[c,i]=Ee(null),[h,u]=Ee(null),[l,g]=Ee(null),[r,a]=Ee(null),p=Le(async(E,A)=>{if(!e){n("failed");let y=new Z("wallet_unavailable","No active session");throw i(y),y}if(E.length===0){n("failed");let y=new Z("invalid_input","At least one call is required");throw i(y),y}n("awaiting_approval"),i(null),u(null);try{let y=N(o);if(!y)throw new Z("wallet_unavailable","Client not initialized");let v=A?.chainId??t??void 0,R=A?.strategy??Ts(await Is(y,e,v),E.length);if(a(R),R==="atomic-batch"){let T=await y.sendCalls(e,E,v,{atomicRequired:!0,...A?.paymasterService?{paymasterService:A.paymasterService}:{}});return n("submitted"),u(T),T}let w="";for(let T=0;T<E.length;T++){let k=E[T];try{w=Me(await y.sendTransaction(e,{transaction:{to:k.to,data:k.data,value:k.value},chainId:v}))}catch(b){throw new Z("tx_failed",`Call ${T+1} of ${E.length} failed after ${T} already landed (sent sequentially \u2014 this wallet cannot batch atomically): ${Fn(b)}`)}}return n("submitted"),u(w),w}catch(y){throw n("failed"),i(y instanceof Error?y:new Error(Fn(y))),y}},[e,t,o]),d=Le(async E=>{if(!e)throw new Z("wallet_unavailable","No active session");let A=E??h;if(!A)throw new Z("invalid_input","No bundle hash available");if(!E&&r==="sequential")throw new Z("invalid_input","Calls were sent sequentially, so there is no bundle to query. Track the returned transaction hash instead.");let y=N(o);if(!y)throw new Z("wallet_unavailable","Client not initialized");let v=await y.getCallsStatus(e,A);return g(v),v},[e,h,o,r]),m=Le(async E=>{if(!e)return!1;let A=E??h;if(!A||!E&&r==="sequential")return!1;let y=N(o);if(!y?.showCallsStatus)return!1;try{return await y.showCallsStatus(e,A),!0}catch{return!1}},[e,h,o,r]),C=Le(()=>{n("idle"),i(null),u(null),g(null),a(null)},[]);return{sendCalls:p,getCallsStatus:d,showCallsStatus:m,status:s,error:c,batchHash:h,callsStatus:l,execution:r,reset:C,isSending:s==="awaiting_approval"}}function Tt(e={}){let{current:t,atomic:o}=Ct(),{delegated:s,delegate:n}=Se(),{sendCalls:c}=bt(),[i,h]=Rt(!1),[u,l]=Rt(null),[g,r]=Rt(null),a=e.atomicity??"preferred",p=e.sponsorship??"any",d=e.paymasterService,m=e.userOperation,C=e.userOperationSponsored??!1,E=!!(t?.raw?.paymasterService?.supported&&d),A=Kn((v,R=a)=>{let w=Us({atomicBatch:o==="supported",discovered:o!=="unknown",sponsoredTransactions:!1,...t?.maxBatchSize===void 0?{}:{maxBatchSize:t.maxBatchSize}},v,{atomicity:R,sponsorship:p}),T=p==="required"&&!C;if(w.strategy==="atomic-batch"&&!T)return{...w,reason:w.reason+(E?" A paymaster service will be requested, but the wallet's final fee payer must be checked after execution.":""),route:"wallet-batch"};let k=s&&o!=="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=R!=="any"&&!w.atomic||p==="required";return m&&b&&!T?{strategy:"atomic-batch",atomic:!0,sponsored:C,reason:p==="required"&&!w.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"}:T?{strategy:"refuse",atomic:w.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}:w.strategy==="refuse"?{...w,reason:w.reason+k,route:null}:{...w,reason:w.reason+k,route:"sequential"}},[o,t,E,m,C,a,p,s,n]),y=Kn(async(v,R=a)=>{h(!0),l(null);try{let w=A(v.length,R);if(w.route===null)throw new Ps("method_not_allowed",w.reason);return r(w.route),w.route==="user-operation"?await m(v):await c(v,{strategy:w.route==="wallet-batch"?"atomic-batch":"sequential",...w.route==="wallet-batch"&&E?{paymasterService:d}:{}})}catch(w){let T=w instanceof Error?w:new Error("Execution failed");throw l(T),T}finally{h(!1)}},[A,c,m,a,d,E]);return{preview:A,execute:y,isExecuting:i,error:u,lastRoute:g,reset:()=>{l(null),r(null)}}}import{checkSessionKeyRailGrant as Ws,getSharedSessionKeyManager as Os,resetSharedSessionKeyManager as Ns}from"@naculus/connect-appkit-core";import{WalletError as _s}from"@naculus/connect-core";import{useCallback as ee,useEffect as Ds,useRef as Ms,useState as X}from"react";function le(e){return Os(e)}function It(e){let{session:t}=U(),[o,s]=X([]),[n,c]=X(!1),[i,h]=X(null),u=Ms(!0),l=ee(()=>h(null),[]),g=le(e),r=g.isStorageAvailable(),a=ee(async()=>{if(!t){s([]);return}c(!0),h(null);try{let d=await g.listSessions();u.current&&s(d)}catch(d){u.current&&h(d instanceof Error?d:new Error("Failed to load session keys"))}finally{u.current&&c(!1)}},[t,g]);Ds(()=>(u.current=!0,a(),()=>{u.current=!1}),[a]);let p=o.filter(d=>d.status==="active");return{sessions:o,activeSessions:p,loading:n,error:i,refresh:a,clearError:l,storageAvailable:r,checkRailGrant:Ws}}function Ls(e){let{session:t}=U(),[o,s]=X(null),[n,c]=X(!1),[i,h]=X(null),u=ee(()=>h(null),[]),l=le(e);return{createSessionKey:ee(async(r,a)=>{if(!t)throw new _s("wallet_unavailable","No active wallet session");c(!0),h(null);try{let p=a??void 0,d=await l.createSessionKey(r,p);return s(d),d}catch(p){let d=p instanceof Error?p:new Error("Failed to create session key");throw h(d),d}finally{c(!1)}},[t,l]),lastCreated:o,isCreating:n,error:i,clearError:u}}function Bs(e){let[t,o]=X(!1),[s,n]=X(null),c=ee(()=>n(null),[]),i=le(e);return{revokeSession:ee(async u=>{o(!0),n(null);try{await i.revokeSession(u)}catch(l){let g=l instanceof Error?l:new Error("Failed to revoke session key");throw n(g),g}finally{o(!1)}},[i]),isRevoking:t,error:s,clearError:c}}function Fs(e){let[t,o]=X(!1),[s,n]=X(null),c=ee(()=>n(null),[]),i=le(e);return{checkScope:ee(async(u,l)=>{o(!0),n(null);try{return await i.checkSessionScope(u,l)}catch(g){let r=g instanceof Error?g:new Error("Failed to check session scope");throw n(r),r}finally{o(!1)}},[i]),isBusy:t,error:s,clearError:c}}function Ks(){Ns()}import{useState as Hn,useCallback as Hs}from"react";import{WalletError as Ut}from"@naculus/connect-core";function Pt(){let{session:e,chainId:t,client:o}=U(),[s,n]=Hn(!1),[c,i]=Hn(null);return{signMessage:Hs(async u=>{if(!e){let g=new Ut("wallet_unavailable","No active session");throw i(g),g}let l=e.namespaces.eip155?.accounts[0]??Object.values(e.namespaces)[0]?.accounts[0];if(!l){let g=new Ut("wallet_unavailable","No account found");throw i(g),g}n(!0),i(null);try{let g=N(o);if(!g)throw new Ut("wallet_unavailable","Client not initialized");return await g.signMessage(e,{message:u,address:l,chainId:t??void 0})}catch(g){let r=g instanceof Error?g.message:"Signing failed",a=g instanceof Error?g:new Error(r);throw i(a),a}finally{n(!1)}},[e,t,o]),isSigning:s,error:c}}import{buildDelegationPolicyMessage as Qs}from"@naculus/connect-appkit-core";function Xs(e={}){let{evmAccount:t}=B(),o=qs(t),s=Se(),n=Tt(e.execution),{signMessage:c}=Pt(),i=It(e.managerConfig),h=le(e.managerConfig),[u,l]=Be(!1),[g,r]=Be(null),[a,p]=Be(()=>new Set),[d,m]=Be(!1),C=e.origin??(typeof window<"u"?window.location.origin:"unknown"),E=!!e.managerConfig?.encryptionKey,A=e.execution?.sponsorship,{refresh:y,storageAvailable:v}=i,{preview:R}=n,{delegated:w,delegate:T}=s,k=Gs(()=>Vs({manager:h,origin:C,signer:()=>o,signMessage:c,verifySignature:async({message:S,signature:x,signerAddress:P})=>(await $s({message:S,signature:x})).toLowerCase()===P.toLowerCase(),previewExecution:R,sponsorship:A,adapter:e.adapter,signTypedData:e.signTypedData,chainId:()=>e.chainId??null,delegation:()=>({delegated:w,delegate:T}),encryptionKeyConfigured:E,storageAvailable:()=>v,refresh:y}),[h,C,o,c,R,A,e.adapter,e.signTypedData,e.chainId,w,T,E,v,y]);js(()=>{let S=!1,x=i.sessions.filter(zs);return x.length===0?(p(new Set),m(!1),()=>{S=!0}):(m(!0),Promise.all(x.map(async P=>[P.id,await k.verifyStoredPolicy(P)])).then(P=>{S||p(new Set(P.filter(([,O])=>O).map(([O])=>O)))}).catch(P=>{S||(p(new Set),r(P instanceof Error?P:new Error("Policy verification failed")))}).finally(()=>{S||m(!1)}),()=>{S=!0})},[i.sessions,k]);let b=we(()=>{r(null),i.clearError()},[i]),I=we(async(S,x)=>{l(!0),r(null);try{return await S()}catch(P){let O=P instanceof Error?P:new Error(x);throw r(O),O}finally{l(!1)}},[]),W=we(S=>I(()=>k.createPolicy(S),"Policy creation failed"),[k,I]),_=we(S=>I(()=>k.revokePolicy(S),"Policy revocation failed"),[k,I]),D=we((S,x)=>I(()=>k.executePolicy(S,x),"Policy execution failed"),[k,I]),f=i.activeSessions.filter(S=>a.has(S.id));return{policies:i.sessions,activePolicies:f,storageAvailable:i.storageAvailable,loading:i.loading||d,isBusy:u,error:g??i.error,delegation:s,createPolicy:W,revokePolicy:_,previewPolicyExecution:k.previewPolicyExecution,signPolicyDigest:k.signPolicyDigest,executePolicy:D,refresh:i.refresh,clearError:b}}import{useCallback as Ys,useRef as Js,useState as qn}from"react";function Zs(){let{disconnect:e,status:t}=U(),[o,s]=qn(!1),[n,c]=qn(null),i=Js(!0);return{disconnect:Ys(async()=>{if(t!=="disconnected"){s(!0),c(null);try{await e()}catch(u){if(!i.current)return;c(u instanceof Error?u:new Error("Disconnect failed"))}finally{i.current&&s(!1)}}},[e,t]),isDisconnecting:o,error:n,cleanup:()=>{i.current=!1}}}import{WalletError as Wt}from"@naculus/connect-core";import{useCallback as Y,useEffect as ea,useRef as Fe,useState as Ke}from"react";function te(e){let t=e.activeNamespace??"eip155",o=Array.isArray(e.accounts)?e.accounts.map(({namespace:s,address:n,derivationPath:c})=>({namespace:s,address:n,...c?{derivationPath:c}:{}})):e.address?[{namespace:t,address:e.address}]:[];return{accounts:o,activeNamespace:t,createdAt:e.createdAt??0,...e.chainId?{chainId:e.chainId}:{},...e.version?{version:e.version}:{},recoveryAvailable:!!e.mnemonic,address:o.find(s=>s.namespace===t)?.address??e.address}}function ta(){let{connectEmbedded:e,client:t}=U(),[o,s]=Ke(null),n=Fe(null),c=Fe(4),i=Fe(!1),h=Fe(null),[u,l]=Ke(!1),[g,r]=Ke(!1),[a,p]=Ke(null),d=()=>p(null),m=Y(()=>{let f=n.current;return n.current=null,f},[]),C=Y(()=>{let f=N(t);if(!f?.embeddedConnector)throw new Wt("wallet_unavailable","Embedded wallet not enabled.");return f.embeddedConnector},[t]),E=Y(()=>{try{return C().getWallet()?.privateKey??null}catch{return null}},[C]),A=Y(async()=>{let f=N(t);if(!f)throw new Wt("wallet_unavailable","Embedded wallet not enabled.");let S=f.getEmbeddedConnector?await f.getEmbeddedConnector():f.embeddedConnector;if(!S)throw new Wt("wallet_unavailable","Embedded wallet not enabled.");return S},[t]),y=Y(()=>{try{return N(t)?.passphraseGate??null}catch{return null}},[t]),v=Y(f=>{f?.code==="decryption_failed"&&y()?.forget("That passphrase did not open the wallet.")},[y]),R=Y(async()=>{i.current=!1,p(null);try{let f=await A();if(!await f.load())return!1;let x=f.getWallet();return x?(n.current=null,l(!1),s(te(x)),!0):!1}catch(f){return i.current=!0,v(f),p(f instanceof Error?f:new Error("Failed to restore embedded wallet")),!1}},[v,A]);ea(()=>{let f=!1,S=null;return R().then(x=>{f||x||i.current||(S=setTimeout(()=>{f||R()},100))}),()=>{f=!0,S&&clearTimeout(S)}},[R]);let w=async()=>{r(!0),p(null);try{let f=await A(),S=await f.load(),x=f.getWallet();S&&x&&(s(te(x)),n.current=x.mnemonic||null,l(!x.mnemonic)),await e();let P=f.getWallet();P&&(s(te(P)),P.mnemonic&&!S&&(n.current=P.mnemonic,l(!0)))}catch(f){v(f),p(f instanceof Error?f:new Error("Embedded wallet connection failed"))}finally{r(!1)}},T=async()=>{r(!0),p(null);try{let f=await A();y()?.expect("create");let S=await f.generateWallet();return s(te(S)),n.current=S.mnemonic,l(!0),S}catch(f){return p(f instanceof Error?f:new Error("Failed to generate wallet")),null}finally{r(!1)}},k=async f=>{r(!0),p(null);try{let S=await A();y()?.expect("create");let x=await S.importFromMnemonic(f);return s(te(x)),n.current=null,l(!1),x}catch(S){return p(S instanceof Error?S:new Error("Failed to import wallet")),null}finally{r(!1)}},b=async f=>{r(!0),p(null);try{let S=await A();y()?.expect("create");let x=await S.importFromPrivateKey(f);return s(te(x)),n.current=null,l(!1),x}catch(S){return p(S instanceof Error?S:new Error("Failed to import wallet")),null}finally{r(!1)}},I=async()=>{r(!0),p(null);try{await(await A()).wipe(),s(null),n.current=null,l(!1)}catch(f){p(f instanceof Error?f:new Error("Failed to wipe wallet"))}finally{r(!1)}},W=Y(f=>{let S=C();S.setActiveNamespace(f);let x=S.getWallet();s(x?te(x):null)},[C]),_=Y(async()=>{let f=await A(),S=await f.backfillAccounts();if(S.length>0){let x=f.getWallet();s(x?te(x):null)}return S.map(({namespace:x,address:P,derivationPath:O})=>({namespace:x,address:P,...O?{derivationPath:O}:{}}))},[A]),D=()=>{n.current=null,l(!1)};return{connectEmbedded:w,restoreWallet:R,generateWallet:T,importFromMnemonic:k,importFromPrivateKey:b,wipe:I,wallet:o,hasWallet:o!==null,address:o?.address??null,accounts:o?.accounts??[],activeNamespace:o?.activeNamespace??null,setActiveNamespace:W,backfillAccounts:_,seedPhrase:n.current,getSeedPhrase:m,getPrivateKey:E,backupPending:u,confirmBackup:D,isBusy:g,error:a,clearError:d,storageSecurityLevel:(()=>{try{let f=C(),S=f.getStorageSecurityLevel?.()??4;return f.getWallet()?(c.current=S,S):o?c.current:S}catch{return o?c.current:4}})(),securityReport:(()=>{let f=null;try{f=C().getStorageSecurityReport?.()??null}catch{f=null}if(!f)return h.current=null,null;let S=JSON.stringify(f);return h.current?.json===S?h.current.value:(h.current={json:S,value:f},f)})()}}import{chainNumber as la}from"@naculus/connect-appkit-core";import{useState as ca,useCallback as ua,useEffect as jn,useRef as Gn,useMemo as pa}from"react";import{WalletError as na}from"@naculus/connect-core";import{useCallback as Vn,useEffect as ra,useLayoutEffect as oa,useMemo as sa,useRef as zn}from"react";import{tokenChainMismatch as aa}from"@naculus/connect-appkit-core";function ia(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 ce(e){let{token:t,chainId:o}=e,s=t.address.toLowerCase(),n=ia(e),c=sa(()=>({key:n}),[n]),i=zn(n),h=zn(!0);oa(()=>{i.current=n},[n]),ra(()=>(h.current=!0,()=>{h.current=!1}),[]);let u=Vn(()=>h.current&&i.current===n,[n]),l=Vn(()=>{if(!u())throw new na("session_inactive","Wallet or token context changed. Retry the operation with the current account and chain.");let g=aa({address:s,chainId:t.chainId},o);if(g)throw g},[u,s,t.chainId,o]);return{identity:c,isCurrent:u,assertCurrent:l}}import{ERC20_MIN_ABI as da,formatUnits as ma}from"@naculus/connect-core";function fa(e){let{publicClient:t}=j(),{currentChain:o}=z(),{identity:s,isCurrent:n,assertCurrent:c}=ce({token:e.token,chainId:o?la(o)??void 0:void 0,owner:e.owner,spender:e.spender,publicClient:t}),[i,h]=ca(null),u=i?.identity===s?i.raw:null,l=i?.identity===s&&i.fetching,g=i?.identity===s?i.error:null,r=Gn(null),a=Gn(0),p=ua(async()=>{if(!n())return;let m=++a.current,C=()=>n()&&m===a.current;if(h({identity:s,raw:null,fetching:!!t,error:null}),!!t)try{c();let E=await t.readContract({address:e.token.address,abi:da,functionName:"allowance",args:[e.owner,e.spender]});if(!C())return;h({identity:s,raw:E,fetching:!1,error:null})}catch(E){if(!C())return;h({identity:s,raw:null,fetching:!1,error:E instanceof Error?E:new Error("Failed to fetch allowance")})}},[t,e.token.address,e.token.chainId,e.owner,e.spender,s,n,c]);return jn(()=>{p().catch(m=>console.warn("useERC20Allowance: initial fetch failed:",m))},[p]),jn(()=>(e.refreshInterval&&e.refreshInterval>0&&(r.current=setInterval(p,e.refreshInterval)),()=>{r.current&&(clearInterval(r.current),r.current=null)}),[e.refreshInterval,p]),{allowance:pa(()=>{if(u===null)return null;let m=e.token.decimals;return m===void 0?null:ma(u,m)},[u,e.token.decimals]),allowanceRaw:u,isFetching:l,error:g,refetch:p}}import{chainNumber as ga,createDecimalsCache as ha,encodeErc20Approve as ya,readDecimals as Nt,writeDecimals as Qn}from"@naculus/connect-appkit-core";import{ERC20_MIN_ABI as He,formatUnits as Ca,parseUnits as Yn,WalletError as qe}from"@naculus/connect-core";import{useCallback as ve,useRef as Jn,useState as Zn}from"react";import{WalletError as Ot}from"@naculus/connect-core";import{useCallback as $n,useState as Xn}from"react";function ke(){let{session:e,chainId:t,client:o}=U(),[s,n]=Xn("idle"),[c,i]=Xn(null),h=$n(async l=>{if(!e){n("failed");let r=new Ot("wallet_unavailable","No active session");throw i(r),r}let g=e.namespaces.eip155?.accounts.find(r=>/^eip155:\d+:0x[0-9a-fA-F]{40}$/.test(r)||/^0x[0-9a-fA-F]{40}$/.test(r));if(!g){n("failed");let r=new Ot("wallet_unavailable","No EVM account found");throw i(r),r}n("awaiting_approval"),i(null);try{let r={...l,from:l.from??g.split(":").pop()},a=N(o);if(!a)throw new Ot("wallet_unavailable","Client not initialized");let p=await a.sendTransaction(e,{transaction:r,chainId:t??void 0}),d=Me(p);return n("submitted"),d}catch(r){n("failed");let a=r instanceof Error?r.message:"Transaction failed";throw i(r instanceof Error?r:new Error(a)),r}},[e,t,o]),u=$n(()=>{n("idle"),i(null)},[]);return{sendTransaction:h,status:s,error:c,reset:u,isSending:s==="awaiting_approval"}}function Sa(e){return e.includes(":")?e.split(":").pop():e}var Ea=2n**256n-1n;function wa(e){let{publicClient:t,walletClient:o}=j(),{evmAccount:s,isConnected:n}=B(),{currentChain:c}=z(),{session:i,client:h}=U(),{sendTransaction:u,isSending:l,error:g,reset:r}=ke(),[a,p]=Zn(null),{identity:d,isCurrent:m,assertCurrent:C}=ce({token:e.token,chainId:c?ga(c)??void 0:void 0,owner:s,spender:e.spender,connected:n,publicClient:t,walletClient:o,session:i,client:h}),[E,A]=Zn(null),y=E?.identity===d?E.raw:null,v=E?.identity===d&&E.fetching,R=Jn(ha(e.token,e.token.decimals)),w=Jn(0),T=a??g,k=s?Sa(s):null,b=ve(async()=>{if(!m())return null;let S=++w.current,x=()=>m()&&S===w.current;if(A({identity:d,raw:null,fetching:!!t&&!!k&&n}),p(null),!t||!k||!n)return null;try{C();let P=await t.readContract({address:e.token.address,abi:He,functionName:"allowance",args:[k,e.spender]});return x()?(A({identity:d,raw:P,fetching:!1}),P):null}catch(P){return x()&&(A({identity:d,raw:null,fetching:!1}),p(P instanceof Error?P:new Error("Failed to fetch allowance"))),null}},[t,k,e.token.address,e.token.chainId,e.spender,d,m,C,n]),I=(()=>{if(y===null)return null;let S=Nt(R.current,e.token,e.token.decimals);return S===void 0?null:Ca(y,S)})(),W=ve(async S=>{if(p(null),r(),!n||!s){let x=new qe("wallet_unavailable","No connected account");throw p(x),x}if(!t){let x=new qe("wallet_unavailable","No public client");throw p(x),x}try{C();let x=ya(e.spender,S),P=N(h);if(i&&P){let F=await u({to:e.token.address,data:x,value:"0"});return b(),F}if(o){let{request:F}=await t.simulateContract({address:e.token.address,abi:He,functionName:"approve",args:[e.spender,S],account:k});C();let ne=await o.writeContract(F);return b(),ne}let O=await u({to:e.token.address,data:x,value:"0"});return b(),O}catch(x){let P=x instanceof Error?x:new Error("Approve failed");throw m()&&p(P),P}},[e,t,o,s,n,i,h,k,u,r,b,C,m]),_=ve(async S=>{try{if(C(),!t)throw new qe("wallet_unavailable","No public client");let x=Nt(R.current,e.token,e.token.decimals);x===void 0&&(x=await t.readContract({address:e.token.address,abi:He,functionName:"decimals"}),C(),Qn(R.current,e.token,x));let P=Yn(S,x);return await W(P)}catch(x){throw m()&&p(x instanceof Error?x:new Error("Approve failed")),x}},[e.token,t,W,C,m]),D=ve(async()=>W(Ea),[W]),f=ve(async S=>{if(!m()||!n||!k||!t)return!1;try{C()}catch(F){return p(F instanceof Error?F:new Error("Cannot check allowance")),!1}let x=y??await b();if(x===null)return!1;let P=Nt(R.current,e.token,e.token.decimals);if(P===void 0){if(!t)throw new qe("wallet_unavailable","Cannot check allowance: no public client to read token decimals.");if(P=await t.readContract({address:e.token.address,abi:He,functionName:"decimals"}),!m())return!1;Qn(R.current,e.token,P)}let O=Yn(S,P);return m()&&x>=O},[y,b,e.token.address,e.token.chainId,e.token.decimals,t,m,C,n,k]);return{approve:_,approveMax:D,allowance:I,allowanceRaw:y,hasAllowance:f,isApproving:l,isFetchingAllowance:v,error:T,refetchAllowance:b}}import{chainNumber as ka,createDecimalsCache as va,encodeErc20Transfer as xa,readDecimals as Aa,writeDecimals as ba}from"@naculus/connect-appkit-core";import{ERC20_MIN_ABI as er,parseUnits as Ra,WalletError as tr}from"@naculus/connect-core";import{useCallback as Ta,useRef as Ia,useState as Ua}from"react";function Pa(e){return e.includes(":")?e.split(":").pop():e}function Wa(e){let{publicClient:t,walletClient:o}=j(),{evmAccount:s,isConnected:n}=B(),{currentChain:c}=z(),{session:i,client:h}=U(),{sendTransaction:u,isSending:l,error:g,reset:r}=ke(),[a,p]=Ua(null),{isCurrent:d,assertCurrent:m}=ce({token:e.token,chainId:c?ka(c)??void 0:void 0,owner:s,connected:n,publicClient:t,walletClient:o,session:i,client:h}),C=Ia(va(e.token,e.token.decimals)),E=a??g;return{sendTransfer:Ta(async(y,v)=>{if(p(null),r(),!n||!s){let R=new tr("wallet_unavailable","No connected account");throw p(R),R}if(!t){let R=new tr("wallet_unavailable","No public client available");throw p(R),R}try{m();let R=Pa(s),w=Aa(C.current,e.token,e.token.decimals);w===void 0&&(w=await t.readContract({address:e.token.address,abi:er,functionName:"decimals"}),m(),ba(C.current,e.token,w));let T=Ra(v,w),k=xa(y,T),b=N(h);if(i&&b)return await u({to:e.token.address,data:k,value:"0"});if(o){let{request:W}=await t.simulateContract({address:e.token.address,abi:er,functionName:"transfer",args:[y,T],account:R});return m(),await o.writeContract(W)}return await u({to:e.token.address,data:k,value:"0"})}catch(R){let w=R instanceof Error?R:new Error("Transfer failed");throw d()&&p(w),w}},[e.token,t,o,s,n,i,h,u,r,m,d]),isSending:l,error:E}}import{chainNumber as Da,encodeErc20Transfer as Ma}from"@naculus/connect-appkit-core";import{parseUnits as La}from"@naculus/connect-core";import{useMemo as Ba}from"react";import{simulateTransactionPreview as Oa}from"@naculus/connect-appkit-core";import{useCallback as nr,useEffect as Na,useRef as _a,useState as _t}from"react";function Dt(e,t){U();let{evmAccount:o}=B(),{currentChain:s}=z(),{publicClient:n}=j(),[c,i]=_t(void 0),[h,u]=_t(!1),[l,g]=_t(null),r=_a(void 0),a=nr(async()=>{e&&(u(!0),g(null));try{let d=await Oa(e,{chainId:t,currentChain:s,publicClient:n,evmAccount:o});return i(d),d}catch(d){let m=d instanceof Error?d:new Error("Simulation failed");throw g(m),m}finally{e&&u(!1)}},[e,t,s,n,o]);Na(()=>{if(e)return r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{a().catch(()=>{})},300),()=>{r.current&&clearTimeout(r.current)}},[e,a]);let p=nr(()=>{i(void 0),g(null),u(!1)},[]);return{result:c,isSimulating:h,error:l,simulate:a,reset:p}}function Fa(e){let{evmAccount:t,isConnected:o}=B(),{currentChain:s}=z(),n=e.token.chainId??(s?Da(s)??void 0:void 0),c=Ba(()=>{if(!(!o||!t))try{let h=e.token.decimals;if(h===void 0)return;let u=La(e.amount,h),l=Ma(e.to,u);return{to:e.token.address,data:l,value:"0"}}catch{return}},[e.token.address,e.token.decimals,e.to,e.amount,t,o]),i=Dt(c,n);return{result:c?i.result:void 0,isSimulating:!!c&&i.isSimulating,error:c?i.error:null,reSimulate:i.simulate,reset:i.reset}}import{useState as Mt,useCallback as ja,useRef as Lt}from"react";import{useState as Ve,useEffect as Ka,useCallback as rr,useRef as Ha}from"react";import{createContext as qa,useContext as Va}from"react";var or=qa(null);function xe(){return Va(or)}function za(e,t,o){let s=xe(),n=o??s,[c,i]=Ve(null),[h,u]=Ve(!1),[l,g]=Ve(!1),[r,a]=Ve(null),p=Ha(void 0),d=rr(async()=>{if(!(!n||!e)){u(!0),a(null);try{await n.refreshTx(e,t);let E=n.getTxStatus(e,t);E&&i(E)}catch(E){a(E instanceof Error?E:new Error(String(E)))}finally{u(!1)}}},[n,e,t]),m=rr(()=>{!n||!e||(n.stopWatching(e,t),g(!1))},[n,e,t]);Ka(()=>{if(!n||!e||!t){i(null),g(!1);return}p.current&&p.current!==e&&n.stopWatching(p.current),p.current=e;let E=!1;g(!0),u(!0),a(null);let A=n.getTxStatus(e,t);A&&(i(A),u(!1)),n.watchTx(e,t,{}).then(v=>{E||(i(v),u(!1))}).catch(v=>{E||(a(v instanceof Error?v:new Error(String(v))),u(!1))});let y=v=>{E||i({...v})};return n.on("statusChange",y),()=>{E=!0,g(!1),n.off("statusChange",y)}},[n,e,t]);let C=c?.status??"idle";return{entry:c,status:C,isLoading:h,isWatching:l,error:r,refresh:d,stopWatching:m}}function Ga(e){let t=xe(),o=e??t,[s,n]=Mt(null),[c,i]=Mt(null),[h,u]=Mt(null),l=Lt(null),g=Lt(null),r=Lt(null);o&&(g.current||(g.current=p=>{i(p),(!l.current||p.createdAt>=l.current.createdAt)&&(n(p),l.current=p)},o.on("confirmed",g.current)),r.current||(r.current=p=>{u(p),(!l.current||p.createdAt>=l.current.createdAt)&&(n(p),l.current=p)},o.on("failed",r.current)));let a=ja(()=>{n(null),i(null),u(null),l.current=null},[]);return{lastTx:s,lastConfirmedTx:c,lastFailedTx:h,clear:a}}import{useCallback as Ya}from"react";import{useCallback as $a,useEffect as sr,useMemo as Xa,useRef as ar,useState as Bt}from"react";import{getResolver as Qa}from"@naculus/connect-appkit-core";function ze({input:e,skip:t=!1,resolverConfig:o,scope:s,query:n}){let[c,i]=Bt(null),[h,u]=Bt(!1),[l,g]=Bt(null),r=ar(0),a=ar(!0);sr(()=>(a.current=!0,()=>{a.current=!1}),[]);let p=Xa(()=>Qa(o),[o]),d=$a(()=>{let m=e.trim();if(!m||t){r.current+=1,i(null),u(!1),g(null);return}let C=++r.current;u(!0),g(null),n(p,m,s).then(E=>{!a.current||C!==r.current||(i(E),u(!1))}).catch(E=>{!a.current||C!==r.current||(g(E instanceof Error?E:new Error(String(E))),i(null),u(!1))})},[e,t,s,p,n]);return sr(()=>{d()},[d]),{data:c,isLoading:h,error:l,refetch:d}}function Ja(e,t){let o=Ya((s,n,c)=>s.lookupAddress(n,c),[]);return ze({input:e,skip:t?.skip,resolverConfig:t?.resolverConfig,scope:t?.chainId,query:o})}import{useState as ir,useCallback as Q,useMemo as Za,useEffect as lr,useRef as cr}from"react";import{addInAppNotification as ei,channelsUpdate as ti,clearOneInAppNotification as ni,createNotificationSettingsStorage as ur,DEFAULT_NOTIFICATION_SETTINGS as ri,loadNotificationSettings as oi,mutedChainSettings as pr,saveNotificationSettings as dr,replayNotificationSettings as si,updateNotificationSettings as ai}from"@naculus/connect-appkit-core";import{InAppChannel as ii}from"@naculus/connect-core";function li(e){let t=cr(null);t.current||(t.current=e?.channel??new ii);let o=t.current,[s,n]=ir(()=>o.getHistory()),[c,i]=ir(()=>ri),h=cr([]);lr(()=>{let y=e?.storage??ur(),v=R=>{let w=h.current??[];if(h.current=null,w.length===0){R&&i(R);return}i(()=>{let T=si(R,w);return dr(y,T),T})};oi(y).then(v,()=>v(null))},[]),lr(()=>(o.onNotification=y=>{n(v=>[...v,y])},o.restore().then(()=>{n(o.getHistory())}),()=>{o.onNotification=void 0}),[]);let u=Za(()=>s.filter(y=>!y.read).length,[s]),l=Q(()=>{o.clear(),n([])},[o]),g=Q(y=>{ni(o,y).then(()=>{n(o.getHistory())})},[o]),r=Q(y=>{o.markAsRead(y),n(v=>v.map(R=>R.id===y?{...R,read:!0}:R))},[o]),a=Q(()=>{o.markAllAsRead(),n(y=>y.map(v=>({...v,read:!0})))},[o]),p=Q(y=>{ei(o,y)},[o]),d=Q(y=>{h.current?.push(y),i(v=>{let R=ai(v,y(v)),w=e?.storage??ur();return dr(w,R),R})},[e?.storage]),m=Q(y=>d(()=>y),[d]),C=Q(y=>{m(ti(y))},[m]),E=Q(y=>{d(v=>pr(v,y,!0))},[d]),A=Q(y=>{d(v=>pr(v,y,!1))},[d]);return{notifications:s,unreadCount:u,addNotification:p,clear:l,clearOne:g,markAsRead:r,markAllAsRead:a,settings:c,updateSettings:m,setChannels:C,muteChain:E,unmuteChain:A}}import{useCallback as Ft,useSyncExternalStore as ci}from"react";var mr=()=>null,ui=()=>()=>{};function pi(){let{client:e}=U(),t=N(e)?.passphraseGate??null,o=ci(t?.subscribe??ui,t?.getSnapshot??mr,mr),s=Ft(i=>t?.submit(i),[t]),n=Ft(()=>t?.cancel(),[t]),c=Ft(i=>t?.forget(i),[t]);return{request:o,submit:s,cancel:n,forget:c,isUnlocked:t?.isUnlocked??!1,gate:t}}import{useCallback as di}from"react";function mi(e,t){let o=di((s,n)=>s.resolveName(n),[]);return ze({input:e,skip:t?.skip,resolverConfig:t?.resolverConfig,query:o})}import{assertHexSignature as Kt,bareEvmAddress as fi,buildSmartAccountConfig as gi,resolveUserOpChain as hi}from"@naculus/connect-appkit-core";import{WalletError as ue}from"@naculus/connect-core";import{useCallback as fr,useEffect as gr,useRef as hr,useState as Ae}from"react";async function yi(e,t,o,s,n){let c=N(t);if(!c)throw new ue("wallet_unavailable","Client not initialized");let i=[o,s];if(e.walletType==="eip6963"||e.id?.startsWith("eip6963-")){let{eip6963Connector:h}=await import("@naculus/connector-evm-injected"),u=h.getDiscoveredWallets().find(g=>g.id===e.walletId),l=u?await u.provider.request({method:"personal_sign",params:i}):await h.request({method:"personal_sign",params:i});return Kt(l)}if(e.walletType==="walletconnect")return Kt(await c.connector.request({method:"personal_sign",params:i}));if(e.walletType==="embedded"){let h=c.embeddedConnector;if(!h?.signHash)throw new ue("method_unsupported","This embedded wallet build cannot sign a raw digest. Upgrade @naculus/connector-embedded or pass an explicit signer.");return Kt(await h.signHash(e,o))}throw e.walletType==="passkeys"?new ue("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 ue("method_unsupported",`Raw UserOperation signing is not available for ${e.walletType} on ${n}. Pass a signer that signs the raw 32-byte hash.`)}function Ci(e){let{evmAccount:t}=B(),{session:o,chainId:s,client:n}=U(),[c,i]=Ae(null),[h,u]=Ae(null),[l,g]=Ae(!1),[r,a]=Ae(!1),[p,d]=Ae(null),m=hr(0),C=hr(!1);gr(()=>()=>{m.current+=1,C.current=!1},[]),gr(()=>{m.current+=1,C.current=!1,i(null),u(null),g(!1),a(!1),d(null)},[n,s,t,e?.accountType,e?.bundlerUrl,e?.chainId,e?.entryPoint,e?.owner,e?.rpcUrl,e?.salt,e?.signerMode,o]);let E=fr(async(y,v)=>{let R=b=>(d(b),null);if(!e?.rpcUrl)return R(new Error("RPC URL not configured"));if(!e.bundlerUrl)return R(new Error("Bundler URL not configured"));if(!y.length)return R(new Error("At least one call is required"));if(C.current)return R(new Error("A UserOperation is already in progress"));let w=fi(e.owner??t);if(!w)return R(new ue("wallet_unavailable","No EVM account found"));let T;try{T=hi(e.chainId,s)}catch(b){return R(b)}if(!e.signer&&!o)return R(new ue("wallet_unavailable","No active session"));let k=++m.current;C.current=!0,g(!0),a(!0),d(null),i(null),u(null);try{let{SmartAccountManager:b}=await import("@naculus/connect-core"),I=e.signer??(f=>yi(o,n,f,w,T)),W=new b({rpcUrl:e.rpcUrl,bundlerClient:{url:e.bundlerUrl},chainId:T,signer:I,signerMode:e.signer?e.signerMode??"eip191":"raw"}),_=gi(w,T,e),D=await W.sendUserOperation(_,y,v);return k!==m.current?null:(a(!1),i(D.userOpHash),W.getUserOperationReceipt(D.userOpHash).then(f=>{k===m.current&&u(f)}).catch(()=>{}),D)}catch(b){if(k!==m.current)return null;let I=b instanceof Error?b:new Error("Failed to send UserOperation");return d(I),null}finally{C.current=!1,k===m.current&&(g(!1),a(!1))}},[n,s,t,e,o]),A=fr(()=>{m.current+=1,i(null),u(null),g(!1),a(!1),d(null)},[]);return{sendUserOp:E,userOpHash:c,receipt:h,isPending:l,isEstimating:r,error:p,reset:A}}import{useSyncExternalStore as Si,useCallback as yr}from"react";function Ei(e,t){if(!e)return()=>{};let o=()=>t();return e.on("sessionConnected",o),e.on("sessionDisconnected",o),e.on("chainChanged",o),e.on("sessionScopeChanged",o),e.on("sessionRevoked",o),()=>{e.off("sessionConnected",o),e.off("sessionDisconnected",o),e.off("chainChanged",o),e.off("sessionScopeChanged",o),e.off("sessionRevoked",o)}}var Ht=Object.freeze({session:null,chainSessions:[],activeChainId:null,isConnected:!1,connectorId:null}),qt=new WeakMap;function wi(e,t){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(e[o]!==t[o])return!1;return!0}function ki(e){if(!e)return Ht;let t=e.getActiveBundle(),o=qt.get(e);if(!t)return o&&o.session===null?o:(qt.set(e,Ht),Ht);let s=Array.from(t.chainSessions.values());if(o&&o.session===t.walletSession&&o.activeChainId===t.activeChainId&&wi(o.chainSessions,s))return o;let n={session:t.walletSession,chainSessions:s,activeChainId:t.activeChainId,isConnected:!0,connectorId:t.walletSession.walletType};return qt.set(e,n),n}function vi(e){let t=U(),o=e??t.sessionManager??null,s=yr(c=>Ei(o,c),[o]),n=yr(()=>ki(o),[o]);return Si(s,n)}import{defaultSiwxDomain as xi,defaultSiwxUri as Ai}from"@naculus/connect-appkit-core";import{WalletError as je}from"@naculus/connect-core";import{createSiwxMessage as bi,generateNonce as Ri,getBlockchainName as Ti,issueNonce as Ii,nowISO as Ui}from"@naculus/siwx";import{useCallback as Cr,useState as Sr}from"react";var Pi=86400;function Vt(){let{session:e,chainId:t,client:o}=U(),[s,n]=Sr(!1),[c,i]=Sr(null),h=Cr(()=>i(null),[]);return{signIn:Cr(async l=>{if(!e)throw new je("wallet_unavailable","No active session");let g=l?.chainId??t;if(!g)throw new je("invalid_chain","No chain to sign for. Connect a wallet or pass options.chainId.");let r=se(e,g);if(!r)throw new je("wallet_unavailable","No account found");let a=N(o);if(!a)throw new je("wallet_unavailable","Client not initialized");let{address:p}=r,d=typeof window>"u"?void 0:window.location,m=l?.domain??xi(d),C=l?.uri??Ai(d);n(!0),i(null);try{let E=Ri();await Ii(E);let A=Ui(),y=l?.expirySeconds??Pi,v=new Date(Date.now()+y*1e3).toISOString(),R=bi({domain:m,address:p,uri:C,version:1,chainId:g,nonce:E,issuedAt:A,expirationTime:v,statement:l?.statement,resources:l?.resources,requestId:l?.requestId}),w=await a.signMessage(e,{message:R,address:p,chainId:g??void 0}),T={message:{raw:R,domain:m,address:p,statement:l?.statement??null,uri:C,version:1,chainId:g,nonce:E,issuedAt:A,blockchain:Ti(g),expirationTime:v,notBefore:null,resources:l?.resources??[],requestId:l?.requestId??null},signature:w};return n(!1),T}catch(E){let A=E instanceof Error?E:new Error("SIWx sign-in failed");throw i(A),n(!1),A}},[e,t,o]),isSigningIn:s,error:c,clearError:h}}import{siwxResultToSession as Er}from"@naculus/connect-appkit-core";import{logger as zt}from"@naculus/connect-core";import{checkSessionExpired as wr,createLocalStorageSiwxSessionStorage as Wi}from"@naculus/siwx";import{useCallback as Ge,useEffect as kr,useRef as Oi,useState as $e}from"react";function Ni(e){let{storagePrefix:t="naculus_",autoRestore:o=!0,defaultExpirySeconds:s=86400}=e??{},[n,c]=$e(null),[i,h]=$e(o),[u,l]=$e(!1),[g,r]=$e(null),{chainId:a}=U(),p=Vt(),d=Oi(Wi(`${t}siwx_session`)),m=Ge(()=>r(null),[]);kr(()=>{if(!o){h(!1);return}let w=!1;return(async()=>{try{let k=await d.current.get();if(w)return;k?(zt.info("react/useSIWxSession","Restored persisted SIWx session"),c(k),r(null)):c(null)}catch(T){zt.warn("react/useSIWxSession","Failed to restore SIWx session:",T),c(null)}finally{w||h(!1)}})(),()=>{w=!0}},[o]),kr(()=>{if(!n?.expiresAt)return;let w=new Date(n.expiresAt).getTime()-Date.now();if(w<=0){c(null);return}let T=setTimeout(()=>{c(k=>k&&k.id===n.id?null:k)},w);return()=>clearTimeout(T)},[n?.id,n?.expiresAt]);let C=Ge(async w=>{l(!0),r(null);try{let T={expirySeconds:s,chainId:a??void 0,...w},k=await p.signIn(T),b=Er(k);return await d.current.set(b),c(b),l(!1),b}catch(T){let k=T instanceof Error?T:new Error("SIWx sign-in failed");throw r(k),l(!1),k}},[p,a,s]),E=Ge(async()=>{try{await d.current.remove()}catch(w){zt.warn("react/useSIWxSession","Failed to clear session:",w)}c(null),r(null)},[]),A=Ge(async()=>{if(!n)throw new Error("No active session to refresh");l(!0),r(null);try{let w=await p.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}),T={...Er(w),id:n.id,refreshedAt:new Date().toISOString()};return await d.current.set(T),c(T),l(!1),T}catch(w){let T=w instanceof Error?w:new Error("Session refresh failed");throw r(T),l(!1),T}},[n,p,s]),y=n!==null&&!wr(n),v=wr(n),R=n?.expiresAt?Math.max(0,new Date(n.expiresAt).getTime()-Date.now()):null;return{session:y?n:null,isAuthenticated:y,isRestoring:i,isSigningIn:u,isExpired:v,timeUntilExpiry:R,signIn:C,signOut:E,refresh:A,error:g,clearError:m}}import{defaultSiwxDomain as _i,defaultSiwxUri as Di}from"@naculus/connect-appkit-core";import{WalletError as Xe}from"@naculus/connect-core";import{createSiwxMessage as Mi,generateNonce as Li,getBlockchainName as Bi,issueNonce as Fi,nowISO as Ki}from"@naculus/siwx";import{useCallback as vr,useState as jt}from"react";function be(){let{session:e,chainId:t,client:o}=U(),[s,n]=jt(!1),[c,i]=jt(null),[h,u]=jt(null),l=vr(()=>u(null),[]);return{signIn:vr(async r=>{if(!e)throw new Xe("wallet_unavailable","No active session");let a=r?.chainId??t;if(!a)throw new Xe("invalid_chain","No chain to sign for. Connect a wallet or pass options.chainId.");let p=se(e,a);if(!p)throw new Xe("wallet_unavailable","No account found");let d=N(o);if(!d)throw new Xe("wallet_unavailable","Client not initialized");let{address:m}=p,C=typeof window>"u"?void 0:window.location,E=r?.domain??_i(C),A=r?.uri??Di(C);n(!0),u(null);try{let y=Li();await Fi(y);let v=Ki(),R=Mi({domain:E,address:m,uri:A,version:1,chainId:a,nonce:y,issuedAt:v,statement:r?.statement,expirationTime:r?.expirySeconds?new Date(Date.now()+r.expirySeconds*1e3).toISOString():void 0,resources:r?.resources,requestId:r?.requestId}),w=await d.signMessage(e,{message:R,address:m,chainId:a??void 0}),T=r?.expirySeconds?new Date(Date.now()+r.expirySeconds*1e3).toISOString():null,k={message:{raw:R,domain:E,address:m,statement:r?.statement??null,uri:A,version:1,chainId:a,nonce:y,issuedAt:v,blockchain:Bi(a),expirationTime:T,notBefore:null,resources:r?.resources??[],requestId:r?.requestId??null},signature:w};return i(k),k}catch(y){let v=y instanceof Error?y:new Error("SIWx sign-in failed");throw u(v),v}finally{n(!1)}},[e,t,o]),isSigningIn:s,result:c,error:h,clearError:l}}import{WalletError as Gt}from"@naculus/connect-core";import{useCallback as xr}from"react";function Hi(){let{session:e,chainId:t}=U();return xr(o=>{if(!e)throw new Gt("wallet_unavailable","No active session");let s=o??t;if(s&&!s.startsWith("eip155:"))throw new Gt("namespace_mismatch",`Ethereum SIWx requires an eip155 chain, received ${s}`);let n=e.namespaces.eip155;if(!n||n.accounts.length===0)throw new Gt("namespace_mismatch","No EVM (eip155) accounts found in session")},[e,t])}function qi(){let e=Hi(),t=be();return{signIn:xr(async s=>(e(s?.chainId),t.signIn(s)),[e,t.signIn]),isSigningIn:t.isSigningIn,result:t.result,error:t.error,clearError:t.clearError}}import{resolveSimulationEndpoint as Vi}from"@naculus/connect-appkit-core";import{SimulationManager as zi}from"@naculus/wallet-engine";import{useCallback as $t,useRef as ji,useState as Xt}from"react";function Gi(e){let t=e?.rpcUrl,o=e?.chainId,s=ji(null),n=$t(()=>(s.current||(s.current=new zi({enabled:!0,rpcUrl:t,autoSimulate:!1})),s.current),[t]),[c,i]=Xt(null),[h,u]=Xt(!1),[l,g]=Xt(null),r=$t(async(p,d,m,C,E)=>{u(!0),g(null);try{let A=n(),y=Vi(E?.chainId,o,E?.rpcUrl,t),v=await A.simulateERC20Transfer(p,d,m,C,y.chainId,E?.decimals,y.rpcUrl);return i(v),v}catch(A){let y=A instanceof Error?A:new Error(String(A));throw g(y),y}finally{u(!1)}},[t,o,n]),a=$t(()=>{i(null),g(null),u(!1)},[]);return{result:c,loading:h,error:l,simulate:r,reset:a}}import{isSiwxExpired as $i,isSiwxNotBeforeValid as Xi}from"@naculus/connect-appkit-core";import{LocalStorageAdapter as Qi,logger as Qe}from"@naculus/connect-core";import{useCallback as Qt,useEffect as Yi,useRef as Ji,useState as Ye}from"react";var Je="siwx_auth";function Zi(e){return new Qi(e)}function el(e){let{storagePrefix:t="naculus_",autoRestore:o=!0}=e??{},[s,n]=Ye(null),[c,i]=Ye(o),[h,u]=Ye(!1),[l,g]=Ye(null),r=be(),a=Ji(Zi(t)),p=Qt(()=>g(null),[]);Yi(()=>{if(!o){i(!1);return}let C=!1;return(async()=>{try{let E=a.current,A=await E.get(Je);if(C)return;A&&!$i(A,new Date)&&Xi(A,new Date)?(Qe.info("react/useSiwxAuthSession","Restored persisted SIWx auth session"),n(A),g(null)):A&&(Qe.info("react/useSiwxAuthSession","Persisted SIWx auth expired, clearing"),await E.remove(Je))}catch(E){Qe.warn("react/useSiwxAuthSession","Failed to restore SIWx auth:",E)}finally{C||i(!1)}})(),()=>{C=!0}},[o]);let d=Qt(async C=>{u(!0),g(null);try{let E=await r.signIn(C);return await a.current.set(Je,E),n(E),u(!1),E}catch(E){let A=E instanceof Error?E:new Error("SIWx sign-in failed");throw g(A),u(!1),A}},[r]),m=Qt(async()=>{try{await a.current.remove(Je)}catch(C){Qe.warn("react/useSiwxAuthSession","Failed to clear SIWx auth:",C)}n(null),g(null)},[]);return{isSignedIn:s!==null,isRestoring:c,siwxResult:s,isSigningIn:h,error:l,signIn:d,signOut:m,clearError:p}}import{bareEvmAddress as tl,buildSmartAccountConfig as nl,resolveEvmChainId as Ar}from"@naculus/connect-appkit-core";import{WalletError as Tr}from"@naculus/connect-core";import{useCallback as re,useEffect as br,useRef as Yt,useState as Re}from"react";function Rr(e){return new Tr("wallet_unavailable",e)}function rl(e){let{evmAccount:t}=B(),{session:o,chainId:s,client:n}=U(),[c,i]=Re(null),[h,u]=Re(!1),[l,g]=Re(null),[r,a]=Re(!1),[p,d]=Re(null),m=Yt(null),C=Yt(0),E=Yt(!1);br(()=>{if(m.current=null,!e?.rpcUrl)return;let b=!1;return import("@naculus/connect-core").then(({SmartAccountManager:I})=>{if(b)return;let W=Ar(e.chainId,s);W&&(m.current=new I({rpcUrl:e.rpcUrl,chainId:W,bundlerClient:{url:e.bundlerUrl??""}}))}).catch(I=>{b||d(I instanceof Error?I:new Error("Failed to load account-abstraction module"))}),()=>{b=!0}},[s,e?.rpcUrl,e?.bundlerUrl,e?.chainId]),br(()=>{C.current+=1,E.current=!1,i(null),u(!1),g(null),a(!1),d(null)},[t,s,e?.rpcUrl,e?.bundlerUrl,e?.chainId,e?.entryPoint,e?.accountType,e?.salt]);let A=re(()=>{let b=tl(t);if(!b||!m.current)return null;let I=Ar(e?.chainId,s);return I?nl(b,I,{accountType:e?.accountType,entryPoint:e?.entryPoint,salt:e?.salt}):null},[t,s,e?.accountType,e?.chainId,e?.entryPoint,e?.salt]),y=re(b=>(d(b),null),[]),v=re(()=>E.current?null:(E.current=!0,C.current),[]),R=re(b=>{C.current===b&&(E.current=!1)},[]),w=re(async()=>{let b=A();if(!b||!m.current)return y(new Error("Smart account not configured"));let I=v();if(I===null)return y(new Error("Smart account operation already in progress"));a(!0),d(null);try{let _=await m.current.createAccount(b);return C.current!==I?null:(i(_.address),u(_.isDeployed),g(_),_)}catch(W){if(C.current!==I)return null;let _=W instanceof Error?W:new Error("Failed to create smart account");return d(_),null}finally{C.current===I&&a(!1),R(I)}},[v,y,R,A]),T=re(async()=>{let b=A();if(!b||!m.current)return y(new Error("Smart account not configured"));if(!o)return y(Rr("No active session"));let I=N(n);if(!I)return y(Rr("Client not initialized"));if(s&&s!==b.chainId)return y(new Tr("chain_mismatch",`Connected chain ${s} does not match smart account chain ${b.chainId}.`));let W=v();if(W===null)return y(new Error("Smart account operation already in progress"));a(!0),d(null);try{let _=m.current,D=await _.createAccount(b);if(C.current!==W)return null;if(D.isDeployed)return i(D.address),u(!0),g(D),D.address;let f=await _.getDeployCallData(b),S=await I.sendTransaction(o,{transaction:{to:f.to,data:f.data,value:f.value.toString()},chainId:b.chainId});if(C.current!==W)return null;let x=await _.createAccount(b);return i(x.address),u(x.isDeployed),g(x),S}catch(_){if(C.current!==W)return null;let D=_ instanceof Error?_:new Error("Failed to deploy smart account");return d(D),null}finally{C.current===W&&a(!1),R(W)}},[n,s,v,y,R,A,o]),k=re(async()=>{let b=A();if(!b||!m.current)return null;let I=C.current;try{let W=await m.current.getAccountAddress(b);return C.current!==I?null:(i(W),W)}catch(W){return C.current!==I||d(W instanceof Error?W:new Error("Failed to get smart account address")),null}},[A]);return{address:c,isDeployed:h,accountInfo:l,isLoading:r,error:p,createWallet:w,deployWallet:T,getAddress:k}}import{useMemo as ol}from"react";function Jt(){let{accounts:e,isConnected:t}=U();return ol(()=>{if(!t)return{address:null,caip10:null,chainId:null,isConnected:!1};let o=e.find(i=>i.startsWith("solana:"))??null;if(!o)return{address:null,caip10:null,chainId:null,isConnected:t};let s=o.split(":"),n=s.length>=3?s[s.length-1]:null,c=s.length>=3?s.slice(0,-1).join(":"):null;return{address:n,caip10:o,chainId:c,isConnected:t}},[e,t])}import{useCallback as sl,useEffect as Ir,useRef as al,useState as Zt}from"react";import{getSolanaBalance as il}from"@naculus/connect-core";function ll(e={}){let{client:t}=U(),{address:o}=Jt(),s=e.address??o,n=e.rpcUrl??N(t)?.solanaRpcUrl??null,[c,i]=Zt(null),[h,u]=Zt(!1),[l,g]=Zt(null),r=al(0),a=sl(async()=>{if(!s||!n){i(null);return}let p=++r.current;u(!0),g(null);try{let d=await il(n,s);if(p!==r.current)return;i(d)}catch(d){if(p!==r.current)return;i(null),g(d instanceof Error?d:new Error("Balance read failed"))}finally{p===r.current&&u(!1)}},[s,n]);return Ir(()=>{a()},[a]),Ir(()=>{if(!e.refreshInterval||e.refreshInterval<=0)return;let p=setInterval(()=>{a()},e.refreshInterval);return()=>clearInterval(p)},[e.refreshInterval,a]),{balance:c,isFetching:h,error:l,isConfigured:!!n,refetch:a}}import{readSolanaRoles as cl}from"@naculus/connect-appkit-core";import{useMemo as ul}from"react";function pl(){let{client:e,session:t,accounts:o}=U();return ul(()=>{let s=N(e)?.solanaConnector,{roles:n,absence:c}=cl(s,t);return{roles:n,absence:c,identity:n?.identity??null,signer:n?.signer??null,payer:n?.payer??null}},[e,t,o])}import{WalletError as Ur}from"@naculus/connect-core";import{useCallback as en,useState as tn}from"react";import{getSignatureStatus as dl}from"@naculus/connect-core";function ml(){let{client:e,session:t}=U(),[o,s]=tn(!1),[n,c]=tn(!1),[i,h]=tn(null),u=()=>{let a=N(e);if(!a||!t)throw new Ur("wallet_unavailable","No connected wallet.");return a},l=en(async a=>{s(!0),h(null);try{return await u().signTransaction(t,{transaction:a})}catch(p){let d=p instanceof Error?p:new Error("Signing failed");throw h(d),d}finally{s(!1)}},[e,t]),g=en(async a=>{c(!0),h(null);try{return await u().sendTransaction(t,{transaction:a})}catch(p){let d=p instanceof Error?p:new Error("Send failed");throw h(d),d}finally{c(!1)}},[e,t]),r=en(async a=>{let p=N(e)?.solanaRpcUrl;if(!p)throw new Ur("no_rpc","Set solanaRpcUrl on the client to read a signature's status.");return dl(p,a)},[e]);return{signTransaction:l,sendTransaction:g,getStatus:r,isSigning:o,isSending:n,error:i,reset:()=>h(null)}}import{useCallback as Pr,useState as Wr}from"react";import{toChainSwitchError as fl}from"@naculus/connect-appkit-core";function gl(){let{switchChain:e,chainId:t}=U(),[o,s]=Wr(!1),[n,c]=Wr(null),i=Pr(async u=>{s(!0),c(null);try{await e(u)}catch(l){let g=fl(l);throw c(g),g}finally{s(!1)}},[e]),h=Pr(()=>{c(null)},[]);return{switchChain:i,isSwitching:o,currentChainId:t,error:n,clearError:h}}import{chainNumber as hl,resolveChain as yl,toViemChain as Cl}from"@naculus/connect-appkit-core";import{useState as Ze,useEffect as nn,useCallback as Or,useMemo as rn,useRef as Sl}from"react";import{createPublicClient as El,http as wl,formatUnits as kl}from"viem";var vl=[{name:"balanceOf",type:"function",stateMutability:"view",inputs:[{name:"owner",type:"address"}],outputs:[{name:"balance",type:"uint256"}]}];function xl(e){let{evmAccount:t,isConnected:o}=B(),{chainId:s,chains:n}=U(),[c,i]=Ze([]),[h,u]=Ze(!1),[l,g]=Ze(null),{tokens:r,refreshInterval:a}=e,p=Sl(null),d=rn(()=>r.map(w=>w.address.toLowerCase()+"|"+w.decimals+"|"+w.symbol).join(","),[r]),m=rn(()=>yl(n,s),[s,n]),C=m?hl(m):null,E=rn(()=>m?Cl(m,C):null,[m,C]),[A,y]=Ze(null);nn(()=>{if(!E||!m?.rpcUrl){y(null);return}let w=El({transport:wl(m.rpcUrl),chain:E});y(w)},[m,E]);let v=Or(async()=>{if(!t||!A||r.length===0){i([]);return}u(!0),g(null);try{let w=t.includes(":")?t.split(":").pop():t,k=(await Promise.allSettled(r.map(async b=>{try{let I=await A.readContract({address:b.address,abi:vl,functionName:"balanceOf",args:[w]});return{address:b.address,symbol:b.symbol,decimals:b.decimals,name:b.name,balance:I.toString(),formatted:kl(I,b.decimals)}}catch{return{address:b.address,symbol:b.symbol,decimals:b.decimals,name:b.name,balance:null,formatted:null}}}))).map(b=>b.status==="fulfilled"?b.value:{address:"",symbol:"?",decimals:0,balance:null,formatted:null});i(k)}catch(w){g(w instanceof Error?w:new Error("Failed to fetch token balances"))}finally{u(!1)}},[t,A,d]);nn(()=>{o&&t&&r.length>0&&v()},[o,t,d,v]),nn(()=>(a&&a>0&&o&&t&&r.length>0&&(p.current=setInterval(v,a)),()=>{p.current&&(clearInterval(p.current),p.current=null)}),[a,o,t,d,v]);let R=Or(w=>c.find(T=>T.address.toLowerCase()===w.toLowerCase()),[c]);return{tokenBalances:c,isLoading:h,error:l,refetch:v,getTokenBalance:R,chain:m}}import{useState as on,useEffect as Nr,useCallback as Al,useRef as bl}from"react";function Rl(e,t,o){let s=xe(),n=o??s,[c,i]=on([]),[h,u]=on(!1),[l,g]=on(null),r=bl(0),a=Al(async()=>{if(n){u(!0),g(null),r.current++;try{let d=await n.getTxHistory(e,t);i(d)}catch(d){g(d instanceof Error?d:new Error(String(d)))}finally{u(!1)}}},[n,e,t]);Nr(()=>{a().catch(()=>{})},[a]),Nr(()=>{if(!n)return;let d=()=>{a().catch(()=>{})};return n.on("statusChange",d),()=>{n.off("statusChange",d)}},[n,a]);let p={pending:c.filter(d=>d.status==="pending").length,confirmed:c.filter(d=>d.status==="confirmed").length,failed:c.filter(d=>d.status==="failed").length};return{entries:c,isLoading:h,error:l,refresh:a,summary:p}}import{fetchUserOperationReceipt as Tl,InvalidUserOperationReceiptError as Il}from"@naculus/connect-appkit-core";import{useCallback as Te,useEffect as _r,useRef as pe,useState as oe}from"react";function Ul(e){let t=e?.bundlerUrl,o=e?.pollInterval??2e3,s=e?.maxRetries??30,[n,c]=oe("idle"),[i,h]=oe(null),[u,l]=oe(e?.userOpHash??null),[g,r]=oe(null),[a,p]=oe(!1),[d,m]=oe(0),C=pe(0),[E,A]=oe(0),y=pe(null),v=pe(null),R=pe(0),w=pe(0),T=pe(null),k=Te(()=>{y.current&&(clearInterval(y.current),y.current=null),v.current&&(clearTimeout(v.current),v.current=null)},[]),b=Te(async(S,x)=>{if(!t||x!==R.current)return;let P=w.current+1;w.current=P,m(P);let O=new AbortController;T.current=O;let F=V=>{x===R.current&&(c("not_found"),p(!1),k(),r(V))},ne=V=>{if(x===R.current){if(P<=s){v.current=setTimeout(()=>{b(S,x)},o);return}F(V)}};try{let V=await Tl(t,S,O.signal);if(x!==R.current)return;if(V){h(V),c(V.success?"confirmed":"failed"),p(!1),k();return}c("pending"),ne(new Error("UserOperation not included after maximum retries"))}catch(V){if(x!==R.current||O.signal.aborted)return;let de=V instanceof Error?V:new Error("Unknown bundler response failure");if(de instanceof Il){F(de);return}ne(new Error(`UserOperation status unavailable after ${P} attempt${P===1?"":"s"}: ${de.message}`))}finally{T.current===O&&(T.current=null)}},[t,o,s,k]),I=Te(S=>{R.current+=1;let x=R.current;if(T.current?.abort(),T.current=null,k(),l(S),h(null),r(null),w.current=0,m(0),A(0),C.current=Date.now(),!t){c("not_found"),p(!1),r(new Error("Bundler URL not configured"));return}c("pending"),p(!0),y.current=setInterval(()=>{A(Date.now()-C.current)},1e3),b(S,x)},[t,k,b]),W=Te(()=>{R.current+=1,T.current?.abort(),T.current=null,k(),p(!1)},[k]),_=Te(()=>{R.current+=1,T.current?.abort(),T.current=null,k(),l(null),c("idle"),h(null),r(null),p(!1),w.current=0,m(0),A(0)},[k]),D=e?.userOpHash??null,f=e?.autoStart!==!1;return _r(()=>{D&&f&&I(D)},[D,f,I]),_r(()=>()=>{R.current+=1,T.current?.abort(),T.current=null,k()},[k]),{status:n,receipt:i,userOpHash:u,error:g,isPolling:a,elapsedMs:E,attempts:d,start:I,stop:W,reset:_}}import{validateDestination as _l}from"@naculus/connect-appkit-core";import{useMemo as Dl}from"react";var Pl={"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."},Wl={"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"},Dr={en:Pl,zh:Wl},sn="en";function Ol(e){sn=e}function Nl(){return sn}function an(e){return Dr[sn][e]??Dr.en[e]??e}function Mr(e){let{isValid:t,level:o,issue:s}=_l(e);return{isValid:t,level:o,warning:s?an(`address.${s}`):null}}function Ml({address:e}){return{validation:Dl(()=>Mr(e),[e])}}function Ll(){let{status:e,session:t,accounts:o,chainId:s,error:n,connect:c,disconnect:i,reconnect:h,switchChain:u}=U(),l=e==="connected",g=e==="connecting",r=e==="reconnecting",a=o[0]??null;return{status:e,session:t,accounts:o,chainId:s,error:n,isConnected:l,isConnecting:g,isReconnecting:r,isDisconnected:e==="disconnected",currentAccount:a,connect:c,disconnect:i,reconnect:h,switchChain:u}}import{useCallback as cn,useMemo as Fr}from"react";var Lr={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"},Br={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."},Ie="Something went wrong",Ue="An unexpected error occurred. Please try again. If the problem persists, check your connection and wallet configuration.";function Pe(e){if(!e)return{title:Ie,description:Ue};let t=e;if(t.name==="WalletError"&&t.code){let o=t.code,s=Lr[o]??Ie,n=Br[o]??t.message??Ue;return{title:s,description:n,code:o}}if(e instanceof Error){let o=e.message;return/user rejected/i.test(o)||/rejected/.test(o)?{title:"Request Rejected",description:"The request was declined.",code:"user_rejected"}:/timeout/i.test(o)||/timed? ?out/i.test(o)?{title:"Request Timed Out",description:"The request took too long. Please try again.",code:"deeplink_timeout"}:/insufficient funds/i.test(o)?{title:"Insufficient Funds",description:"You don't have enough funds to complete this transaction.",code:"tx_failed"}:/network/i.test(o)||/chain/i.test(o)?{title:"Network Error",description:o,code:"chain_unsupported"}:{title:Ie,description:o||Ue}}return typeof e=="string"?{title:Ie,description:e||Ue}:{title:Ie,description:Ue}}function ln(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 Bl(){let{error:e,clearError:t}=U(),o=Fr(()=>e?Pe(e):null,[e]),s=Fr(()=>e?ln(e):!1,[e]),n=cn(()=>{t()},[t]),c=cn(h=>Pe(h),[]),i=cn(h=>async()=>{try{return await h()}catch(u){let l=Pe(u);if(u instanceof Error){let g=u;try{g.title=l.title,g.friendlyMessage=l.description,g.code===void 0&&l.code!==void 0&&(g.code=l.code)}catch{}throw g}throw Object.assign(new Error(l.description,{cause:u}),{title:l.title,code:l.code,friendlyMessage:l.description})}},[]);return{error:e,friendlyError:o,clearError:n,isRetryable:s,formatError:c,wrapAsync:i}}import{useState as et,useEffect as Fl,useCallback as Kr,useRef as Kl}from"react";import{TokenListManager as Hl}from"@naculus/connect-core";import{eip155ChainIdToNumber as Hr}from"@naculus/connect-appkit-core";function tt(e,t){let o=Kl(null),[s,n]=et([]),[c,i]=et(t?.autoLoad!==!1),[h,u]=et(!1),[l,g]=et(null);if(!o.current){let p={};t?.sources&&(p.sources=t.sources),o.current=new Hl(p)}let r=Kr(async()=>{let p=o.current;if(p){i(!0),g(null);try{await p.load();let d=e?Hr(e):void 0,m=p.getTokens(d!==void 0?{chainId:d}:void 0);n(m),u(!0)}catch(d){g(d instanceof Error?d:new Error(String(d)))}finally{i(!1)}}},[e]),a=Kr(async()=>{let p=o.current;if(p){i(!0),g(null);try{await p.refresh();let d=e?Hr(e):void 0,m=p.getTokens(d!==void 0?{chainId:d}:void 0);n(m),u(!0)}catch(d){g(d instanceof Error?d:new Error(String(d)))}finally{i(!1)}}},[e]);return Fl(()=>{t?.autoLoad!==!1&&r()},[r,t?.autoLoad]),{tokens:s,isLoading:c,isLoaded:h,error:l,refetch:a}}import{useState as Vr,useEffect as $l,useRef as Xl}from"react";import{TokenListManager as Ql}from"@naculus/connect-core";import{ETHEREUM_MAINNET_TOKENS as ql,POLYGON_TOKENS as Vl,OPTIMISM_TOKENS as zl,ARBITRUM_TOKENS as jl,BASE_TOKENS as Gl}from"@naculus/connect-core";function qr(){return[{name:"built-in",tokens:[...ql,...Vl,...zl,...jl,...Gl],enabled:!0},{name:"uniswap-default",url:"https://tokens.uniswap.org",enabled:!0,refreshInterval:1440*60*1e3}]}import{eip155ChainIdToNumber as Yl}from"@naculus/connect-appkit-core";var Jl=300,nt=null;function Zl(){return nt||(nt=new Ql({sources:qr()}),nt.load().catch(()=>{})),nt}function rt(e,t){let[o,s]=Vr({exact:[],fuzzy:[],hasMore:!1}),[n,c]=Vr(!1),i=Xl(null),h=e.trim();return $l(()=>{if(!h){s({exact:[],fuzzy:[],hasMore:!1}),c(!1);return}return i.current&&clearTimeout(i.current),c(!0),i.current=setTimeout(()=>{let u=Zl(),l=t?Yl(t):void 0,g=u.search(h,{chainId:l,limit:20});s(g),c(!1)},Jl),()=>{i.current&&clearTimeout(i.current)}},[h,t]),{results:o,isSearching:n}}import un,{useCallback as ec}from"react";import{Fragment as tc,jsx as G,jsxs as $}from"react/jsx-runtime";function zr({chainId:e,onSelect:t,onClose:o,options:s}){let[n,c]=un.useState(""),{tokens:i,isLoading:h,error:u}=tt(e),{results:l,isSearching:g}=rt(n,n?e:void 0),r=s?.showRecommendations??!0,a=un.useMemo(()=>{if(n.trim()){let C=[...l.exact,...l.fuzzy].map(E=>E.token);return s?.filter?C.filter(s.filter):C}let m=i;return s?.filter?m.filter(s.filter):m},[n,l,i,s?.filter]),p=un.useMemo(()=>!r||n.trim()?[]:i.slice(0,6),[i,r,n]),d=ec(m=>{t(m),o()},[t,o]);return $("div",{style:{background:"hsl(var(--background))",borderRadius:"12px",padding:"16px",color:"hsl(var(--foreground))",minWidth:"320px",maxWidth:"400px",fontFamily:"system-ui, sans-serif"},children:[$("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[G("h3",{style:{margin:0,fontSize:"16px",fontWeight:600},children:"Select Token"}),G("button",{type:"button",onClick:o,style:{background:"none",border:"none",color:"hsl(var(--muted-foreground))",cursor:"pointer",fontSize:"18px",padding:"4px 8px"},children:"\u2715"})]}),G("input",{type:"text",placeholder:"Search token name or paste address",value:n,onChange:m=>c(m.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}),h&&!g&&G("div",{style:{textAlign:"center",padding:"20px",color:"hsl(var(--muted-foreground))"},children:"Loading tokens..."}),u&&$("div",{style:{textAlign:"center",padding:"12px",color:"hsl(var(--destructive))",fontSize:"13px"},children:["Error: ",u.message]}),r&&p.length>0&&!n.trim()&&$("div",{style:{marginBottom:"12px"},children:[G("div",{style:{fontSize:"11px",color:"hsl(var(--muted-foreground))",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"8px"},children:"Popular"}),G("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap"},children:p.map(m=>$("button",{type:"button",onClick:()=>d(m),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:[m.logoURI?G("img",{src:m.logoURI,alt:"",style:{width:"16px",height:"16px",borderRadius:"50%"},onError:C=>{C.target.style.display="none"}}):null,m.symbol]},`${m.chainId}:${m.address}`))})]}),n.trim()&&!h&&G("div",{style:{fontSize:"11px",color:"hsl(var(--muted-foreground))",marginBottom:"8px"},children:a.length>0?$(tc,{children:[l.exact.length," exact, ",l.fuzzy.length," fuzzy",l.hasMore?" (more available)":""]}):"No results found"}),G("div",{style:{maxHeight:"320px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"2px"},children:a.map(m=>$("button",{type:"button",onClick:()=>d(m),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:C=>{C.target.style.background="hsl(var(--card))"},onMouseLeave:C=>{C.target.style.background="transparent"},children:[G("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:m.logoURI?G("img",{src:m.logoURI,alt:m.symbol,style:{width:"100%",height:"100%"},onError:C=>{let E=C.target;E.style.display="none",E.parentElement.textContent=m.symbol.slice(0,2)}}):m.symbol.slice(0,2)}),$("div",{style:{flex:1,minWidth:0},children:[G("div",{style:{fontWeight:600,fontSize:"14px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m.symbol}),G("div",{style:{fontSize:"12px",color:"hsl(var(--muted-foreground))",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m.name})]}),$("div",{style:{fontSize:"11px",color:"#666",textAlign:"right",flexShrink:0},children:[$("div",{children:[m.decimals," decimals"]}),$("div",{children:["Chain ",m.chainId]})]})]},`${m.chainId}:${m.address}`))})]})}import{createComponent as M}from"@stencil/react-output-target/runtime";import L from"react";import{AppkitAccordion as nc,defineCustomElement as rc}from"@naculus/connect-appkit-wc/dist/components/appkit-accordion.js";import{AppkitAccountButton as oc,defineCustomElement as sc}from"@naculus/connect-appkit-wc/dist/components/appkit-account-button.js";import{AppkitAlertDialog as ac,defineCustomElement as ic}from"@naculus/connect-appkit-wc/dist/components/appkit-alert-dialog.js";import{AppkitAvatar as lc,defineCustomElement as cc}from"@naculus/connect-appkit-wc/dist/components/appkit-avatar.js";import{AppkitBadge as uc,defineCustomElement as pc}from"@naculus/connect-appkit-wc/dist/components/appkit-badge.js";import{AppkitButton as dc,defineCustomElement as mc}from"@naculus/connect-appkit-wc/dist/components/appkit-button.js";import{AppkitCardContent as fc,defineCustomElement as gc}from"@naculus/connect-appkit-wc/dist/components/appkit-card-content.js";import{AppkitCardDescription as hc,defineCustomElement as yc}from"@naculus/connect-appkit-wc/dist/components/appkit-card-description.js";import{AppkitCardFooter as Cc,defineCustomElement as Sc}from"@naculus/connect-appkit-wc/dist/components/appkit-card-footer.js";import{AppkitCardHeader as Ec,defineCustomElement as wc}from"@naculus/connect-appkit-wc/dist/components/appkit-card-header.js";import{AppkitCardTitle as kc,defineCustomElement as vc}from"@naculus/connect-appkit-wc/dist/components/appkit-card-title.js";import{AppkitCard as xc,defineCustomElement as Ac}from"@naculus/connect-appkit-wc/dist/components/appkit-card.js";import{AppkitCheckbox as bc,defineCustomElement as Rc}from"@naculus/connect-appkit-wc/dist/components/appkit-checkbox.js";import{AppkitCollapsible as Tc,defineCustomElement as Ic}from"@naculus/connect-appkit-wc/dist/components/appkit-collapsible.js";import{AppkitConnectButton as Uc,defineCustomElement as Pc}from"@naculus/connect-appkit-wc/dist/components/appkit-connect-button.js";import{AppkitDialog as Wc,defineCustomElement as Oc}from"@naculus/connect-appkit-wc/dist/components/appkit-dialog.js";import{AppkitDropdownMenu as Nc,defineCustomElement as _c}from"@naculus/connect-appkit-wc/dist/components/appkit-dropdown-menu.js";import{AppkitInput as Dc,defineCustomElement as Mc}from"@naculus/connect-appkit-wc/dist/components/appkit-input.js";import{AppkitPopover as Lc,defineCustomElement as Bc}from"@naculus/connect-appkit-wc/dist/components/appkit-popover.js";import{AppkitProgress as Fc,defineCustomElement as Kc}from"@naculus/connect-appkit-wc/dist/components/appkit-progress.js";import{AppkitScrollArea as Hc,defineCustomElement as qc}from"@naculus/connect-appkit-wc/dist/components/appkit-scroll-area.js";import{AppkitSelect as Vc,defineCustomElement as zc}from"@naculus/connect-appkit-wc/dist/components/appkit-select.js";import{AppkitSeparator as jc,defineCustomElement as Gc}from"@naculus/connect-appkit-wc/dist/components/appkit-separator.js";import{AppkitSkeleton as $c,defineCustomElement as Xc}from"@naculus/connect-appkit-wc/dist/components/appkit-skeleton.js";import{AppkitSwitch as Qc,defineCustomElement as Yc}from"@naculus/connect-appkit-wc/dist/components/appkit-switch.js";import{AppkitTabs as Jc,defineCustomElement as Zc}from"@naculus/connect-appkit-wc/dist/components/appkit-tabs.js";import{AppkitToggleGroup as eu,defineCustomElement as tu}from"@naculus/connect-appkit-wc/dist/components/appkit-toggle-group.js";import{AppkitTooltip as nu,defineCustomElement as ru}from"@naculus/connect-appkit-wc/dist/components/appkit-tooltip.js";var ou=M({tagName:"appkit-accordion",elementClass:nc,react:L,events:{onAppkitToggle:"appkitToggle"},defineCustomElement:rc}),su=M({tagName:"appkit-account-button",elementClass:oc,react:L,events:{},defineCustomElement:sc}),au=M({tagName:"appkit-alert-dialog",elementClass:ac,react:L,events:{onAppkitClose:"appkitClose",onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:ic}),iu=M({tagName:"appkit-avatar",elementClass:lc,react:L,events:{},defineCustomElement:cc}),lu=M({tagName:"appkit-badge",elementClass:uc,react:L,events:{},defineCustomElement:pc}),cu=M({tagName:"appkit-button",elementClass:dc,react:L,events:{},defineCustomElement:mc}),uu=M({tagName:"appkit-card",elementClass:xc,react:L,events:{},defineCustomElement:Ac}),pu=M({tagName:"appkit-card-content",elementClass:fc,react:L,events:{},defineCustomElement:gc}),du=M({tagName:"appkit-card-description",elementClass:hc,react:L,events:{},defineCustomElement:yc}),mu=M({tagName:"appkit-card-footer",elementClass:Cc,react:L,events:{},defineCustomElement:Sc}),fu=M({tagName:"appkit-card-header",elementClass:Ec,react:L,events:{},defineCustomElement:wc}),gu=M({tagName:"appkit-card-title",elementClass:kc,react:L,events:{},defineCustomElement:vc}),hu=M({tagName:"appkit-checkbox",elementClass:bc,react:L,events:{onAppkitChange:"appkitChange"},defineCustomElement:Rc}),yu=M({tagName:"appkit-collapsible",elementClass:Tc,react:L,events:{onAppkitToggle:"appkitToggle"},defineCustomElement:Ic}),Cu=M({tagName:"appkit-connect-button",elementClass:Uc,react:L,events:{onAppkitConnect:"appkitConnect",onAppkitDisconnect:"appkitDisconnect",onAppkitStartPairing:"appkitStartPairing",onAppkitRetry:"appkitRetry",onAppkitCancelPairing:"appkitCancelPairing",onAppkitMobileDeepLink:"appkitMobileDeepLink",onAppkitCopyAddress:"appkitCopyAddress"},defineCustomElement:Pc}),Su=M({tagName:"appkit-dialog",elementClass:Wc,react:L,events:{onAppkitClose:"appkitClose",onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:Oc}),Eu=M({tagName:"appkit-dropdown-menu",elementClass:Nc,react:L,events:{onAppkitSelect:"appkitSelect"},defineCustomElement:_c}),wu=M({tagName:"appkit-input",elementClass:Dc,react:L,events:{onAppkitChange:"appkitChange"},defineCustomElement:Mc}),ku=M({tagName:"appkit-popover",elementClass:Lc,react:L,events:{onAppkitOpenChange:"appkitOpenChange"},defineCustomElement:Bc}),vu=M({tagName:"appkit-progress",elementClass:Fc,react:L,events:{},defineCustomElement:Kc}),xu=M({tagName:"appkit-scroll-area",elementClass:Hc,react:L,events:{},defineCustomElement:qc}),Au=M({tagName:"appkit-select",elementClass:Vc,react:L,events:{onAppkitChange:"appkitChange"},defineCustomElement:zc}),bu=M({tagName:"appkit-separator",elementClass:jc,react:L,events:{},defineCustomElement:Gc}),Ru=M({tagName:"appkit-skeleton",elementClass:$c,react:L,events:{},defineCustomElement:Xc}),Tu=M({tagName:"appkit-switch",elementClass:Qc,react:L,events:{onAppkitChange:"appkitChange"},defineCustomElement:Yc}),Iu=M({tagName:"appkit-tabs",elementClass:Jc,react:L,events:{onAppkitTabChange:"appkitTabChange"},defineCustomElement:Zc}),Uu=M({tagName:"appkit-toggle-group",elementClass:eu,react:L,events:{onAppkitChange:"appkitChange"},defineCustomElement:tu}),Pu=M({tagName:"appkit-tooltip",elementClass:nu,react:L,events:{},defineCustomElement:ru});export{ou as AppkitAccordion,su as AppkitAccountButton,au as AppkitAlertDialog,iu as AppkitAvatar,lu as AppkitBadge,cu as AppkitButton,uu as AppkitCard,pu as AppkitCardContent,du as AppkitCardDescription,mu as AppkitCardFooter,fu as AppkitCardHeader,gu as AppkitCardTitle,hu as AppkitCheckbox,yu as AppkitCollapsible,Cu as AppkitConnectButton,Su as AppkitDialog,Eu as AppkitDropdownMenu,wu as AppkitInput,ku as AppkitPopover,vu as AppkitProgress,xu as AppkitScrollArea,Au as AppkitSelect,bu as AppkitSeparator,Ru as AppkitSkeleton,Tu as AppkitSwitch,Iu as AppkitTabs,Uu as AppkitToggleGroup,Pu as AppkitTooltip,kn as DEFAULT_EVM_CHAINS,Uy as LAMPORTS_PER_SOL,Py as PassphraseCancelledError,Wy as PassphraseGate,Ny as SolanaRpcError,zr as TokenSelector,or as TxMonitorContext,Br as WALLET_ERROR_DESCRIPTIONS,Lr as WALLET_ERROR_TITLES,vo as Web3ConnectProvider,mt as Web3Context,Qs as buildDelegationPolicyMessage,Zr as clearClient,ut as createClient,by as formatSol,po as getChainById,pt as getClient,dt as getDefaultChains,Ry as getLatestBlockhash,Nl as getLocale,Ty as getSignatureStatus,Iy as getSolanaBalance,Pe as getUserFriendlyError,ln as isRetryableError,Oy as parseSol,Ks as resetSessionKeyManager,Ol as setLocale,an as t,B as useAccount,Io as useAuthorizations,Bo as useBalance,Ct as useCapabilities,z as useChain,fn as useCompareCosts,Yo as useConnect,Ls as useCreateSessionKey,as as useDelegate,Se as useDelegation,Xs as useDelegationPolicy,Zs as useDisconnect,fa as useERC20Allowance,wa as useERC20Approve,Wa as useERC20Transfer,Fa as useERC20TransferSimulation,ta as useEmbeddedWallet,Tt as useExecuteCalls,yn as useExecuteRoute,Ga as useLastTx,Ja as useLookupAddress,ys as useMppSession,li as useNotification,pi as usePassphraseGate,us as usePaymentFetch,mi as useResolveName,Bs as useRevokeSession,En as useRouteQuote,Vt as useSIWxLogin,Ni as useSIWxSession,bt as useSendCalls,ke as useSendTransaction,Ci as useSendUserOperation,Fs as useSendWithSession,vi as useSession,It as useSessionKeys,qi as useSignInWithEthereum,be as useSignInWithX,Pt as useSignMessage,Gi as useSimulateTransfer,el as useSiwxAuthSession,rl as useSmartAccount,Jt as useSolanaAccount,ll as useSolanaBalance,pl as useSolanaRoles,ks as useSolanaSessionKey,ml as useSolanaTransaction,gl as useSwitchChain,xl as useTokenBalance,tt as useTokenList,rt as useTokenSearch,Dt as useTransactionSimulation,Rl as useTxHistory,za as useTxMonitor,Ul as useUserOpStatus,Ml as useValidateDestination,j as useViemClient,Ll as useWallet,U as useWeb3,Bl as useWeb3ErrorHandler,gs as useX402Signer,Mr as validateDestination};
2
2
  //# sourceMappingURL=index.js.map