var W=Object.create;var d=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var G=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var z=(t,e)=>{for(var o in e)d(t,o,{get:e[o],enumerable:!0})},C=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of L(e))!q.call(t,s)&&s!==o&&d(t,s,{get:()=>e[s],enumerable:!(n=F(e,s))||n.enumerable});return t};var g=(t,e,o)=>(o=t!=null?W(G(t)):{},C(e||!t||!t.__esModule?d(o,"default",{value:t,enumerable:!0}):o,t)),H=t=>C(d({},"__esModule",{value:!0}),t);var ot={};z(ot,{default:()=>et});module.exports=H(ot);var c=require("react");var I=require("@ethersproject/bytes"),v=require("@ethersproject/strings"),S=async(t,e,o)=>{if(t.provider?.wc){let n=(0,I.hexlify)((0,v.toUtf8Bytes)(o));return await t.provider?.wc.signPersonalMessage([n,e])}return t.getSigner(e).signMessage(o)};var b="CONNECTOR_ID",i="SIGNATURE";var _=require("tweetnacl-util"),D=require("@solana/wallet-adapter-react"),K=g(require("bs58"),1);var m=require("react"),J=t=>{let e=(0,m.useRef)();return(0,m.useEffect)(()=>{e.current=t},[t]),e.current},E=J;var T=require("@web3-react/core"),O=require("@chakra-ui/react"),B=require("react-redux");var k=g(require("axios"),1);var f=require("react"),Q=require("react/jsx-runtime"),mt=(0,f.createContext)(void 0),P="production";var h=P==="development"?"https://qa-api-v2.bandit.network/sdk":"https://api-v2.bandit.network/sdk";var w=async(t,e)=>{try{return(await k.default.post(`${h}/users/getNonce`,{walletAddress:t},{headers:{"X-API-KEY":e}})).data}catch(o){throw new Error(o)}};var $=require("react");var l=require("react");var Z=g(require("axios"),1);var A=require("react/jsx-runtime");var j=require("react/jsx-runtime"),N=(0,l.createContext)(void 0);var R=()=>(0,$.useContext)(N);var tt=()=>{let t=(0,D.useWallet)(),e=(0,O.useToast)(),[o,n]=(0,c.useState)(null),[s,M]=(0,c.useState)(null),{account:a,provider:Y}=(0,T.useWeb3React)(),{accessKey:x}=R(),y=(0,B.useSelector)(r=>r.user.selectedWallet),U=E(a);return(0,c.useEffect)(()=>{let r=localStorage.getItem(i);n(r),M(y)},[a,t.connected,y]),(0,c.useEffect)(()=>{let r=localStorage.getItem(b);!a&&!r&&(localStorage.removeItem(i),n(null))},[a]),(0,c.useEffect)(()=>{a&&a!==U&&(localStorage.removeItem(i),n(null))},[a]),[o,s==="Phantom"?async()=>{if(o)return o;try{let{data:r}=await w(t?.publicKey?.toBase58(),x),u=t&&`Verify your account: ${t?.publicKey?.toBase58()}
Nonce: ${r}`,V=(0,_.decodeUTF8)(u),X=t&&await t?.signMessage(V),p=K.encode(X);return localStorage.setItem(i,p),n(p),p}catch(r){throw r}}:async()=>{if(o)return o;try{let{data:r}=await w(a,x),u=await S(Y,a,`Verify your account: ${a}
Nonce: ${r}`);return localStorage.setItem(i,u),n(u),u}catch(r){throw r}}]},et=tt;
