var F=Object.create;var f=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var D=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var X=(e,n)=>{for(var a in n)f(e,a,{get:n[a],enumerable:!0})},y=(e,n,a,B)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of j(n))!H.call(e,t)&&t!==a&&f(e,t,{get:()=>n[t],enumerable:!(B=W(n,t))||B.enumerable});return e};var _=(e,n,a)=>(a=e!=null?F(D(e)):{},y(n||!e||!e.__esModule?f(a,"default",{value:e,enumerable:!0}):a,e)),G=e=>y(f({},"__esModule",{value:!0}),e);var E=(e,n,a)=>new Promise((B,t)=>{var m=c=>{try{u(a.next(c))}catch(i){t(i)}},r=c=>{try{u(a.throw(c))}catch(i){t(i)}},u=c=>c.done?B(c.value):Promise.resolve(c.value).then(m,r);u((a=a.apply(e,n)).next())});var Z={};X(Z,{default:()=>Y});module.exports=G(Z);var N=require("@solana/spl-token"),p=require("@solana/wallet-adapter-react"),b=require("@solana/web3.js"),T=require("@web3-react/core"),v=_(require("bignumber.js"),1),o=require("react");var J={BONK:new b.PublicKey("DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263")},V=({connectedChainId:e,chainId:n,isSwapPaySupported:a,externalCurrencyEnabled:B,mintPrice:t,mintPriceUnit:m,payUsing:r,requiredCustomAmount:u})=>{let[c,i]=(0,o.useState)(0),[O,R]=(0,o.useState)(0),[h,x]=(0,o.useState)(0),{account:A,provider:S}=(0,T.useWeb3React)(),{connected:w,publicKey:s}=(0,p.useWallet)(),{connection:g}=(0,p.useConnection)(),C=(0,o.useCallback)(()=>E(void 0,null,function*(){if(A)try{let l=yield S.getBalance(A);i(l)}catch(l){console.log(l)}}),[A,t,S]),d=(0,o.useCallback)(()=>E(void 0,null,function*(){if(w&&s){let l=yield g.getBalance(s);R(l)}}),[w,s,g]),k=(0,o.useCallback)(()=>E(void 0,null,function*(){if(r==="BONK"&&s){let l=J[r.toUpperCase()],P=yield(0,N.getAssociatedTokenAddress)(l,s),z=(yield g.getTokenAccountBalance(P)).value.uiAmount;x(z)}}),[g,r,s]);(0,o.useEffect)(()=>{Number(n)===Number(e)&&C()},[n,e,C]),(0,o.useEffect)(()=>{d(),a&&k()},[s,w,a,d,k]);let K=new v.default(c.toString()).gte(t),L=O>=t*b.LAMPORTS_PER_SOL,M=parseFloat(h.toString())>=parseFloat(u);return{isEnoughBalance:a&&r.toUpperCase()!=="DEFAULT"?M:m==="SOL"?L:["ETH","MATIC","SHM","BNB"].includes(m)?K:!0}},Y=V;
