var v=Object.defineProperty;var y=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var f=(o,a,e)=>a in o?v(o,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[a]=e,x=(o,a)=>{for(var e in a||(a={}))A.call(a,e)&&f(o,e,a[e]);if(y)for(var e of y(a))C.call(a,e)&&f(o,e,a[e]);return o};var i=(o,a,e)=>new Promise((d,s)=>{var p=r=>{try{n(e.next(r))}catch(c){s(c)}},l=r=>{try{n(e.throw(r))}catch(c){s(c)}},n=r=>r.done?d(r.value):Promise.resolve(r.value).then(p,l);n((e=e.apply(o,a)).next())});import{useEffect as b,useState as h}from"react";import{createContext as $,useMemo as B}from"react";import{jsx as X}from"react/jsx-runtime";var M=$(void 0),w="production";var I=w==="development"?"https://qa-api-v2.bandit.network/sdk":"https://api-v2.bandit.network/sdk";import g from"axios";var P=(o,a)=>i(void 0,null,function*(){try{return(yield g.get(`${I}/collection/${a}`,{headers:{"X-API-KEY":o}})).data}catch(e){throw new Error(e)}});var E=(o,a)=>{let[e,d]=h({}),[s,p]=h(null),[l,n]=h(!0);return b(()=>{function r(){return i(this,null,function*(){var c,m,u;try{n(!0);let t=yield P(a,o);d(x({collectionId:o,contractAddress:(c=t==null?void 0:t.contract)==null?void 0:c.contractAddress,chainId:(m=t==null?void 0:t.contract)==null?void 0:m.chainId,mintPrice:t.stats.price.value,mintPriceUnit:t.stats.price.unit,mintFunction:t.contract.mintFunction,abi:t.contract.abi,profile:t.profile,contract:t==null?void 0:t.contract,stats:t==null?void 0:t.stats},t)),p((u=t==null?void 0:t.contract)==null?void 0:u.candyMachineId)}catch(t){console.log(`Failed to fetch collection details from collection ID: ${o}`)}finally{n(!1)}})}o&&r()},[o,a]),{collectionState:e,isLoading:l,candyMachineId:s}},H=E;export{H as default};
