var me=Object.defineProperty,he=Object.defineProperties;var ge=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var xe=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable;var D=(e,t,o)=>t in e?me(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,m=(e,t)=>{for(var o in t||(t={}))xe.call(t,o)&&D(e,o,t[o]);if(F)for(var o of F(t))Ce.call(t,o)&&D(e,o,t[o]);return e},C=(e,t)=>he(e,ge(t));var y=(e,t,o)=>new Promise((a,r)=>{var s=c=>{try{l(o.next(c))}catch(d){r(d)}},h=c=>{try{l(o.throw(c))}catch(d){r(d)}},l=c=>c.done?a(c.value):Promise.resolve(c.value).then(s,h);l((o=o.apply(e,t)).next())});import"react";import{Modal as ot,ModalBody as rt,ModalCloseButton as nt,ModalContent as it,ModalHeader as at,ModalOverlay as st}from"@chakra-ui/react";import{createContext as ye,useContext as we,useRef as ft}from"react";import{jsx as ht}from"react/jsx-runtime";var be=ye(void 0);var O=()=>we(be);import{Flex as se}from"@chakra-ui/layout";import{Box as Je,Skeleton as v,Table as He,TableContainer as Ke,Tbody as Qe,Td as k,Text as le,Th as Ye,Thead as Ze,Tr as B}from"@chakra-ui/react";import je from"@emotion/styled";import{useCallback as ce,useEffect as Ge,useState as A}from"react";import{Flex as K,Text as Ae}from"@chakra-ui/react";import Z from"@emotion/styled";import{useEffect as Le,useState as Q}from"react";var N=(e,t)=>e?e.length>t?e.substr(0,t-1)+"..."+e.substr(e.length-(t-1),e.length-1):e:"";var V=(e,t)=>{if(navigator.clipboard&&navigator.permissions)navigator.clipboard.writeText(e).then(t);else if(document.queryCommandSupported("copy")){let o=document.createElement("textarea");o.value=e,document.body.appendChild(o),o.select(),document.execCommand("copy"),document.body.removeChild(o),t==null||t()}};import _,{jsNumberForAddress as ve}from"react-jazzicon";import{default as ke}from"react-shadow/emotion";import{jsx as Pe}from"react/jsx-runtime";var Se=({address:e})=>{let t=Object.keys(ke).length?_.default:_;return Pe(t,{diameter:"24",seed:ve(e),svgStyles:{display:"block",verticalAlign:"middle"},paperStyles:{border:"1px solid #ffffff"}})},U=Se;import"react";import{jsx as W,jsxs as Ie}from"react/jsx-runtime";var Re=e=>{var t,o;return Ie("svg",C(m({width:"32",height:"32",viewBox:"0 0 32 32",fill:"none"},e),{children:[W("path",{d:"M21.5 13L14.1625 20L10.5 16.5",stroke:(t=e.iconcolor)!=null?t:"#49536E",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),W("path",{d:"M16 28C22.6274 28 28 22.6274 28 16C28 9.37258 22.6274 4 16 4C9.37258 4 4 9.37258 4 16C4 22.6274 9.37258 28 16 28Z",stroke:(o=e.iconcolor)!=null?o:"#49536E",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}))},q=Re;import"react";import{jsx as J,jsxs as Me}from"react/jsx-runtime";var Te=e=>{var t,o;return Me("svg",C(m({width:"32",height:"32",viewBox:"0 0 32 32",fill:"none"},e),{children:[J("path",{d:"M27 23V5H9",stroke:(t=e.iconcolor)!=null?t:"#49536E",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),J("path",{d:"M23 9H5V27H23V9Z",stroke:(o=e.iconcolor)!=null?o:"#49536E",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}))},H=Te;import{jsx as T,jsxs as Y}from"react/jsx-runtime";var ze=Z(H)`
  cursor: pointer;
`,Be=Z(q)`
  cursor: pointer;
`,Ee=({address:e,domain:t})=>{let[o,a]=Q(!1),[r,s]=Q(e),h=()=>{a(!0),V(e),setTimeout(()=>{a(!1)},1e3)};return Le(()=>{s(t||N(e,6))},[t,e]),Y(K,{alignItems:"center",children:[T(U,{address:e}),Y(K,{alignItems:"center",children:[T(Ae,{mx:"1",children:r}),o?T(Be,{width:24,height:24,iconcolor:o&&"green"}):T(ze,{width:24,height:24,onClick:h})]})]})},j=Ee;import{useContext as De}from"react";import{createContext as Fe,useCallback as ho,useEffect as go,useState as xo}from"react";import oo from"axios";import{createContext as $e,useMemo as Ht}from"react";import{jsx as Yt}from"react/jsx-runtime";var Kt=$e(void 0),G="production";var L=G==="development"?"https://qa-api-v2.bandit.network/sdk":"https://api-v2.bandit.network/sdk";import{jsx as so,jsxs as lo}from"react/jsx-runtime";import{jsx as bo}from"react/jsx-runtime";var X=Fe(void 0);var ee=()=>De(X);import Oe from"axios";var te=(e,t,o,a)=>y(void 0,null,function*(){try{return(yield Oe.get(`${L}/spaces/leaderboard?space_ids=${e}&offset=${t}&limit=${o}`,{headers:{"X-API-KEY":a}})).data}catch(r){throw r}});import"react";import{useMemo as Ne}from"react";var b="...",M=(e,t)=>{let o=t-e+1;return Array.from({length:o},(a,r)=>r+e)},oe=({totalCount:e,pageSize:t,siblingCount:o=1,currentPage:a})=>Ne(()=>{let s=Math.ceil(e/t);if(o+5>=s)return M(1,s);let l=Math.max(a-o,1),c=Math.min(a+o,s),d=l>2,p=c<s-2,u=1,g=s;if(!d&&p){let n=3+2*o;return[...M(1,n),b,s]}if(d&&!p){let n=3+2*o,f=M(s-n+1,s);return[u,b,...f]}if(d&&p){let n=M(l,c);return[u,b,...n,b,g]}},[e,t,o,a]);import re from"@emotion/styled";var ne=re.ul`
  display: flex;
  align-items: center;
  justify-content: center;
  list-style-type: none;
`,z=re.li`
  padding: 0 12px;
  height: 32px;
  min-width: 32px;
  text-align: center;
  margin: auto 4px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;

  ${({disabled:e})=>e&&`
    pointer-events: none;

    &:hover {
      background-color: transparent;
      cursor: default;
    }
  `}

  &.dots:hover {
    background-color: transparent;
    cursor: default;
  }
  &:hover {
    background-color: var(--bad-colors-muted);
    cursor: pointer;
  }

  &.selected {
    background-color: var(--bad-colors-muted);
  }

  &.disabled {
  }
`;import{ChevronLeftIcon as Ve,ChevronRightIcon as _e}from"@chakra-ui/icons";import{Box as ie,Flex as Ue}from"@chakra-ui/react";import{jsx as w,jsxs as qe}from"react/jsx-runtime";var We=e=>{let{onPageChange:t,totalCount:o,siblingCount:a=1,currentPage:r,pageSize:s,className:h}=e,l=oe({currentPage:r,totalCount:o,siblingCount:a,pageSize:s});if(r===0||l.length<2)return null;let c=()=>{t(r+1)},d=()=>{t(r-1)},p=l[l.length-1];return qe(Ue,{align:"center",children:[w(ie,{children:w(Ve,{boxSize:6,onClick:r===1?()=>{}:d,opacity:r===1?.1:1,cursor:r===1?"not-allowed":"pointer"})}),w(ne,{children:l.map((u,g)=>u===b?w(z,{className:"dots",children:"\u2026"},g):w(z,{className:u===r?"selected":"",onClick:u===r?()=>{}:()=>t(u),children:u},g))}),w(ie,{children:w(_e,{boxSize:6,onClick:r===p?()=>{}:c,opacity:r===p?.1:1,cursor:r===p?"not-allowed":"pointer"})})]})},ae=We;import{jsx as i,jsxs as P}from"react/jsx-runtime";var E=je(Ye)`
  padding-left: 0;
  text-transform: unset;
  /* color: ${({theme:e})=>e.colors.text}; */
  font-size: 14px;
`,$=10,Xe=({selectedSpaceId:e})=>{var g;let[t,o]=A(1),[a,r]=A(!1),[s,h]=A(0),[l,c]=A({}),{accessKey:d}=ee(),p=ce(()=>y(void 0,null,function*(){try{r(!0);let{data:n,totalResults:f}=yield te(e,(t-1)*$,$,d);c(I=>C(m({},I),{[t]:n.map(x=>{var S;return m({collectionId:(S=x==null?void 0:x.User)==null?void 0:S.username},x)})})),h(f)}catch(n){}finally{r(!1)}}),[e,t,c]);Ge(()=>{e&&p()},[e,p]);let u=ce(n=>{r(!0),o(n)},[]);return P(se,{flexDir:"column",w:"full",children:[i(Ke,{pt:"20px",children:P(He,{size:"sm",children:[i(Ze,{width:"100",children:P(B,{pb:"2",children:[i(E,{color:"mutedForeground",borderColor:"input",children:"Ranking"}),i(E,{color:"mutedForeground",borderColor:"input",textAlign:"left",px:"0",children:"User"}),i(E,{color:"mutedForeground",borderColor:"input",textAlign:"right",px:"0",children:"Quest completed"})]})}),i(Qe,{children:l!=null&&l[t]?(g=l==null?void 0:l[t])==null?void 0:g.map((n,f)=>{var I,x,S;return P(B,{children:[i(k,{"data-title":"Raking",borderColor:"input",px:"0",w:"24",children:a?i(v,{borderRadius:"4",w:"6",h:"6",startColor:"muted",endColor:"input"}):i(Je,{children:i(le,{children:n==null?void 0:n.rank})})}),i(k,{"data-title":"User",borderColor:"input",px:"0",children:a?i(v,{borderRadius:"4",w:"32",h:"6",startColor:"muted",endColor:"input"}):i(j,{domain:(I=n==null?void 0:n.user)==null?void 0:I.domainName,address:(x=n==null?void 0:n.user)==null?void 0:x.username})}),i(k,{"data-title":"Quest completed",borderColor:"input",px:"0",children:a?i(v,{borderRadius:"4",ml:"auto",w:"8",h:"6",startColor:"muted",endColor:"input"}):i(le,{textAlign:"right",fontWeight:600,fontSize:14,children:(S=n==null?void 0:n.stats)==null?void 0:S.questCompleted})})]},f)}):[1,2,3,4,5,6,7,8,9,10].map((n,f)=>P(B,{children:[i(k,{"data-title":"Raking",borderColor:"input",px:"0",w:"24",children:i(v,{borderRadius:"4",w:"6",h:"6",startColor:"muted",endColor:"input"})}),i(k,{"data-title":"User",borderColor:"input",px:"0",children:i(v,{borderRadius:"4",w:"32",h:"6",startColor:"muted",endColor:"input"})}),i(k,{"data-title":"Quest completed",borderColor:"input",px:"0",children:i(v,{borderRadius:"4",ml:"auto",w:"8",h:"6",startColor:"muted",endColor:"input"})})]},f))})]})}),i(se,{justify:"center",marginY:3,children:i(ae,{currentPage:t,totalCount:s,pageSize:$,onPageChange:u})})]})},de=Xe;import{useDispatch as lt,useSelector as ct}from"react-redux";import{createSlice as et}from"@reduxjs/toolkit";var tt={selectedCollectionId:null,showMint:!1,collectionViewOpen:!1,selectedSpaceId:!1},pe=et({name:"collection",initialState:tt,reducers:{updateSelectedCollectionId(e,{payload:{id:t}}){e.selectedCollectionId=t},updateShowMint(e,{payload:{showMint:t}}){e.showMint=t},updateCollectionViewOpen(e,{payload:{collectionViewOpen:t}}){e.collectionViewOpen=t},updateSelectedSpaceId(e,{payload:{id:t}}){e.selectedSpaceId=t}}}),{updateSelectedCollectionId:rr,updateShowMint:nr,updateCollectionViewOpen:ir,updateSelectedSpaceId:ue}=pe.actions,ar=pe.reducer;import{jsx as R,jsxs as fe}from"react/jsx-runtime";var hr=({isOpen:e=!0})=>{let{rootRef:t}=O(),o=ct(s=>s.collection.selectedSpaceId),a=lt(),r=()=>{a(ue({id:null}))};return o?fe(ot,{blockScrollOnMount:!1,portalProps:{containerRef:t},isOpen:!!o,onClose:r,isCentered:!0,size:"4xl",children:[R(st,{}),fe(it,{children:[R(at,{children:" Leaderboard"}),R(nt,{}),R(rt,{children:R(de,{selectedSpaceId:o})})]})]}):null};export{hr as Leaderboard};
