var m=(n,r,e)=>new Promise((o,i)=>{var p=t=>{try{c(e.next(t))}catch(d){i(d)}},u=t=>{try{c(e.throw(t))}catch(d){i(d)}},c=t=>t.done?o(t.value):Promise.resolve(t.value).then(p,u);c((e=e.apply(n,r)).next())});import{useToast as y}from"@chakra-ui/react";import{Metaplex as w,walletAdapterIdentity as x}from"@metaplex-foundation/js";import{useWallet as A}from"@solana/wallet-adapter-react";import{clusterApiUrl as M,Connection as k,PublicKey as h}from"@solana/web3.js";import{useCallback as f,useEffect as _,useState as b}from"react";var v=(n,r,e)=>n==="devnet"||n===9091?{rpc:"https://kora-disz8d-fast-devnet.helius-rpc.com/",bundlrAddress:"https://devnet.bundlr.network",bundlrProviderUrl:"https://kora-disz8d-fast-devnet.helius-rpc.com/",explorer:`https://solscan.io/${e}/${r}?cluster=devnet`}:n==="mainnet-beta"||n===9090?{rpc:"https://still-patient-panorama.solana-mainnet.quiknode.pro/a9222e86a1f5d32291a0bfa0b5fde4f9309e04cf/",bundlrAddress:"https://node1.bundlr.network",bundlrProviderUrl:"https://still-patient-panorama.solana-mainnet.quiknode.pro/a9222e86a1f5d32291a0bfa0b5fde4f9309e04cf/",explorer:`https://solscan.io/${e}/${r}`}:{rpc:"http://127.0.0.1:8899",bundlrAddress:"https://devnet.bundlr.network",bundlrProviderUrl:M("devnet"),explorer:`https://solscan.io/${e}/${r}?cluster=custom`},$=n=>{let r=A(),e=y(),[o,i]=b(null),[p,u]=b();_(()=>{if([9090,9091].includes(n)){let s=n===9091?"devnet":"mainnet-beta",a=new k(v(s).rpc);u(a),i(w.make(a).use(x(r)))}},[r]);let c=f(s=>s==="candyMachine",[]),t=f(s=>m(void 0,null,function*(){let a=new h(s);try{return yield o.candyMachines().findByAddress({address:a})}catch(l){throw console.log(l),e({title:"invalid cm",description:"provided id is neither cm v2 or v3.",status:"error",duration:6e3}),l}}),[o,e]),d=f(s=>m(void 0,null,function*(){let a=new h(s);try{return yield o.candyMachinesV2().findByAddress({address:a})}catch(l){return t(s)}}),[t,o]);return{metaplex:o,getCandyMachine:d,isV3:c,getUrls:v,connection:p}},B=$;export{B as default,v as getUrls};
