import{o as e}from"./rolldown-runtime.js";import{n as t}from"./jsx-runtime.js";import{Tt as n,Vt as r,jt as i,xt as a}from"./useActiveWallet-CEs8euQ3.js";var o=e(t(),1),s=n((()=>({user:null,authenticated:!1,hasResolvedInitialUser:!1}))),c=e=>s.setState({user:e}),l=e=>s.setState({authenticated:e}),u=e=>s.setState({hasResolvedInitialUser:e}),d=(e,{chainType:t,walletIndex:n}={})=>e?.linkedAccounts.filter((e=>!(e.type!==`wallet`||e.walletClientType!==`privy`||n!==void 0&&e.walletIndex!==n||t!==void 0&&e.chainType!==t)))??[],f=n((()=>({ethereumExternal:[],areExternalConnectorsReady:!1,ethereumEmbedded:[]}))),p=e=>f.setState({areExternalConnectorsReady:e}),m=(0,o.createContext)(!1),h=()=>{if((0,o.useContext)(m))throw new a(`Multiple PrivyProvider instances found`,`Found multiple instances of PrivyProvider, ensure there is only one mounted in your application tree.`)};function g(){let e=(0,o.useContext)(m),t=r(),n=f((e=>e.ethereumEmbedded)),i=f((e=>e.ethereumExternal)),a=f((e=>e.areExternalConnectorsReady)),c=s((e=>e.user)),l=s((e=>e.hasResolvedInitialUser)),u=(0,o.useMemo)((()=>[...n,...i].sort(((e,t)=>t.connectedAt-e.connectedAt))),[n,i]),p=d(c,{chainType:`ethereum`}).length>0,h=n.length>0,g=!!a&&!!l&&!!t.walletProxy&&(!p||h);return e?(0,o.useMemo)((()=>({wallets:u,ready:g})),[u,g]):(console.warn("`useWallets` was called outside the PrivyProvider component"),{wallets:[],ready:!1})}var _=e=>{if(e.chainType===`ethereum`)return{entropyId:e.address,entropyIdVerifier:`ethereum-address-verifier`};if(e.chainType===`solana`)return{entropyId:e.address,entropyIdVerifier:`solana-address-verifier`};throw Error(`Failed to get account entropy details`)},v=(e,t)=>{if(t?.imported)return _(t);let n=i(e);if(!n)throw Error(`Failed to find primary wallet`);return _(n)};export{p as a,_ as c,u as d,c as f,d as i,l,f as n,g as o,v as r,m as s,h as t,s as u};