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