var b=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var _=(t,e)=>{for(var r in e)b(t,r,{get:e[r],enumerable:!0})},$=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of M(e))!k.call(t,s)&&s!==r&&b(t,s,{get:()=>e[s],enumerable:!(n=A(e,s))||n.enumerable});return t};var C=t=>$(b({},"__esModule",{value:!0}),t);var v=(t,e,r)=>new Promise((n,s)=>{var h=o=>{try{i(r.next(o))}catch(u){s(u)}},f=o=>{try{i(r.throw(o))}catch(u){s(u)}},i=o=>o.done?n(o.value):Promise.resolve(o.value).then(h,f);i((r=r.apply(t,e)).next())});var V={};_(V,{default:()=>P,getUrls:()=>y});module.exports=C(V);var w=require("@chakra-ui/react"),m=require("@metaplex-foundation/js"),x=require("@solana/wallet-adapter-react"),d=require("@solana/web3.js"),c=require("react");var y=(t,e,r)=>t==="devnet"||t===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/${r}/${e}?cluster=devnet`}:t==="mainnet-beta"||t===9090?{rpc:"https://mainnet.helius-rpc.com/?api-key=68e9930e-3fe1-4025-ae8b-e9aa39550aa8/",bundlrAddress:"https://node1.bundlr.network",bundlrProviderUrl:"https://mainnet.helius-rpc.com/?api-key=68e9930e-3fe1-4025-ae8b-e9aa39550aa8/",explorer:`https://solscan.io/${r}/${e}`}:{rpc:"http://127.0.0.1:8899",bundlrAddress:"https://devnet.bundlr.network",bundlrProviderUrl:(0,d.clusterApiUrl)("devnet"),explorer:`https://solscan.io/${r}/${e}?cluster=custom`},U=t=>{let e=(0,x.useWallet)(),r=(0,w.useToast)(),[n,s]=(0,c.useState)(null),[h,f]=(0,c.useState)();(0,c.useEffect)(()=>{if([9090,9091].includes(t)){let a=t===9091?"devnet":"mainnet-beta",l=new d.Connection(y(a).rpc);f(l),s(m.Metaplex.make(l).use((0,m.walletAdapterIdentity)(e)))}},[e]);let i=(0,c.useCallback)(a=>a==="candyMachine",[]),o=(0,c.useCallback)(a=>v(void 0,null,function*(){let l=new d.PublicKey(a);try{return yield n.candyMachines().findByAddress({address:l})}catch(p){throw console.log(p),r({title:"invalid cm",description:"provided id is neither cm v2 or v3.",status:"error",duration:6e3}),p}}),[n,r]),u=(0,c.useCallback)(a=>v(void 0,null,function*(){let l=new d.PublicKey(a);try{return yield n.candyMachinesV2().findByAddress({address:l})}catch(p){return o(a)}}),[o,n]);return{metaplex:n,getCandyMachine:u,isV3:i,getUrls:y,connection:h}},P=U;0&&(module.exports={getUrls});
