import{o as e}from"./rolldown-runtime.js";import{n as t}from"./jsx-runtime.js";import{Vt as n,dt as r}from"./useActiveWallet-CEs8euQ3.js";import{i,n as a}from"./_esm.js";var o=e(t(),1);function s({rpcConfig:e,appId:t,address:s,chain:c}){let{chains:l}=n(),[u,d]=(0,o.useState)(0n),[f,p]=(0,o.useState)(!1),m=(0,o.useMemo)((()=>{let n=c||l[0];if(n)return i({chain:c,transport:a(r(n,e,t))})}),[c,e,t]),h=(0,o.useCallback)((async()=>{if(!s||!m)return;p(!0);let e=await m.getBalance({address:s}).catch(console.error);return e?(d(e),p(!1),e):void 0}),[m,s,d]);return(0,o.useEffect)((()=>{h().catch(console.error)}),[]),{balance:u,isLoading:f,reloadBalance:h}}export{s as t};