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