var U=Object.create;var c=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var C=(t,e)=>{for(var o in e)c(t,o,{get:e[o],enumerable:!0})},f=(t,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of v(e))!$.call(t,a)&&a!==o&&c(t,a,{get:()=>e[a],enumerable:!(s=b(e,a))||s.enumerable});return t};var D=(t,e,o)=>(o=t!=null?U(E(t)):{},f(e||!t||!t.__esModule?c(o,"default",{value:t,enumerable:!0}):o,t)),W=t=>f(c({},"__esModule",{value:!0}),t);var R={};C(R,{default:()=>O});module.exports=W(R);var ct=require("react");var A=D(require("axios"),1);var p=require("react"),Y=require("react/jsx-runtime"),z=(0,p.createContext)(void 0),y="production";var x=y==="development"?"https://qa-api-v2.bandit.network/sdk":"https://api-v2.bandit.network/sdk";var u=async(t,e)=>{try{return(await A.default.get(`${x}/users/${t}`,{headers:{"X-API-KEY":e}})).data}catch(o){throw new Error(o)}};var l=require("react-redux");var d=require("react"),i=require("@stacks/connect"),_=()=>{let[t,e]=(0,d.useState)(""),o=new i.AppConfig(["store_write","publish_data"]),s=new i.UserSession({appConfig:o}),a=()=>{s.signUserOut(),e("")};return(0,d.useEffect)(()=>{if(s)try{let n=s.loadUserData();e(n.profile.stxAddress.testnet)}catch{}},[s]),{stacksAddress:t,userSession:s,disconnectStacks:a}},S=_;var k=require("@web3-react/core"),K=require("@solana/wallet-adapter-react");var g=require("@reduxjs/toolkit"),X={selectedWallet:void 0,selectedSolanaWallet:void 0,accessKey:null,details:{}},P=(0,g.createSlice)({name:"user",initialState:X,reducers:{updateSelectedWallet(t,{payload:{wallet:e}}){t.selectedWallet=e},updateSolanaSelectedWallet(t,{payload:{wallet:e}}){t.selectedSolanaWallet=e},updateAccessKey(t,{payload:{accessKey:e}}){t.accessKey=e},updateUserDetails(t,{payload:{details:e}}){t.details=e}}}),{updateSelectedWallet:ot,updateSolanaSelectedWallet:st,updateAccessKey:at,updateUserDetails:h}=P.actions,rt=P.reducer;var N=()=>{let{selectedWallet:t,accessKey:e,details:o={}}=(0,l.useSelector)(r=>r.user),{stacksAddress:s}=S(),{account:a}=(0,k.useWeb3React)(),{publicKey:n,disconnect:B}=(0,K.useWallet)(),w=(0,l.useDispatch)();return{user:o,fetchUser:async()=>{try{let r=n?n.toBase58():"",m=t==="stacks"?s:t==="Phantom"?r:a;if(o?.walletAddress?.toLowerCase()===m?.toLowerCase())return;let I=await u(m,e);w(h({details:I}))}catch(r){console.log(r)}},refreshUser:async()=>{try{if(!o.walletAddress)return;let r=await u(o.walletAddress,e);w(h({details:r}))}catch(r){console.log(r)}}}},O=N;
