import{useEffect as f,useState as r}from"react";import{createContext as u,useMemo as g}from"react";import{jsx as C}from"react/jsx-runtime";var v=u(void 0),c="production";var s=c==="development"?"https://qa-api-v2.bandit.network/sdk":"https://api-v2.bandit.network/sdk";import y from"axios";var i=async(e,o)=>{try{return(await y.get(`${s}/collection/${o}`,{headers:{"X-API-KEY":e}})).data}catch(n){throw new Error(n)}};var x=(e,o)=>{let[n,d]=r({}),[l,p]=r(null),[h,a]=r(!0);return f(()=>{async function m(){try{a(!0);let t=await i(o,e);d({collectionId:e,contractAddress:t?.contract?.contractAddress,chainId:t?.contract?.chainId,mintPrice:t.stats.price.value,mintPriceUnit:t.stats.price.unit,mintFunction:t.contract.mintFunction,abi:t.contract.abi,profile:t.profile,contract:t?.contract,stats:t?.stats,...t}),p(t?.contract?.candyMachineId)}catch{console.log(`Failed to fetch collection details from collection ID: ${e}`)}finally{a(!1)}}e&&m()},[e,o]),{collectionState:n,isLoading:h,candyMachineId:l}},D=x;export{D as default};
