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