var Pe=Object.create;var M=Object.defineProperty,Re=Object.defineProperties,Ie=Object.getOwnPropertyDescriptor,Te=Object.getOwnPropertyDescriptors,Me=Object.getOwnPropertyNames,Z=Object.getOwnPropertySymbols,Ae=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable;var j=(e,t,o)=>t in e?M(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,y=(e,t)=>{for(var o in t||(t={}))G.call(t,o)&&j(e,o,t[o]);if(Z)for(var o of Z(t))Le.call(t,o)&&j(e,o,t[o]);return e},S=(e,t)=>Re(e,Te(t));var ze=(e,t)=>{for(var o in t)M(e,o,{get:t[o],enumerable:!0})},X=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Me(t))!G.call(e,r)&&r!==o&&M(e,r,{get:()=>t[r],enumerable:!(s=Ie(t,r))||s.enumerable});return e};var P=(e,t,o)=>(o=e!=null?Pe(Ae(e)):{},X(t||!e||!e.__esModule?M(o,"default",{value:e,enumerable:!0}):o,e)),Be=e=>X(M({},"__esModule",{value:!0}),e);var R=(e,t,o)=>new Promise((s,r)=>{var l=d=>{try{c(o.next(d))}catch(u){r(u)}},b=d=>{try{c(o.throw(d))}catch(u){r(u)}},c=d=>d.done?s(d.value):Promise.resolve(d.value).then(l,b);c((o=o.apply(e,t)).next())});var Ye={};ze(Ye,{Leaderboard:()=>Qe});module.exports=Be(Ye);var ao=require("react"),p=require("@chakra-ui/react");var A=require("react"),$e=require("react/jsx-runtime"),Ee=(0,A.createContext)(void 0);var ee=()=>(0,A.useContext)(Ee);var Y=require("@chakra-ui/layout"),n=require("@chakra-ui/react"),we=P(require("@emotion/styled"),1),g=require("react");var E=require("@chakra-ui/react"),U=P(require("@emotion/styled"),1),$=require("react");var te=(e,t)=>e?e.length>t?e.substr(0,t-1)+"..."+e.substr(e.length-(t-1),e.length-1):e:"";var oe=(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()}};var L=P(require("react-jazzicon"),1),re=P(require("react-shadow/emotion"),1),ie=require("react/jsx-runtime"),Fe=({address:e})=>{let t=Object.keys(re.default).length?L.default.default:L.default;return(0,ie.jsx)(t,{diameter:"24",seed:(0,L.jsNumberForAddress)(e),svgStyles:{display:"block",verticalAlign:"middle"},paperStyles:{border:"1px solid #ffffff"}})},ne=Fe;var ot=require("react");var z=require("react/jsx-runtime"),De=e=>{var t,o;return(0,z.jsxs)("svg",S(y({width:"32",height:"32",viewBox:"0 0 32 32",fill:"none"},e),{children:[(0,z.jsx)("path",{d:"M21.5 13L14.1625 20L10.5 16.5",stroke:(t=e.iconcolor)!=null?t:"#49536E",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,z.jsx)("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"})]}))},ae=De;var at=require("react");var B=require("react/jsx-runtime"),Oe=e=>{var t,o;return(0,B.jsxs)("svg",S(y({width:"32",height:"32",viewBox:"0 0 32 32",fill:"none"},e),{children:[(0,B.jsx)("path",{d:"M27 23V5H9",stroke:(t=e.iconcolor)!=null?t:"#49536E",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,B.jsx)("path",{d:"M23 9H5V27H23V9Z",stroke:(o=e.iconcolor)!=null?o:"#49536E",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}))},se=Oe;var w=require("react/jsx-runtime"),Ne=(0,U.default)(se)`
  cursor: pointer;
`,Ve=(0,U.default)(ae)`
  cursor: pointer;
`,_e=({address:e,domain:t})=>{let[o,s]=(0,$.useState)(!1),[r,l]=(0,$.useState)(e),b=()=>{s(!0),oe(e),setTimeout(()=>{s(!1)},1e3)};return(0,$.useEffect)(()=>{l(t||te(e,6))},[t,e]),(0,w.jsxs)(E.Flex,{alignItems:"center",children:[(0,w.jsx)(ne,{address:e}),(0,w.jsxs)(E.Flex,{alignItems:"center",children:[(0,w.jsx)(E.Text,{mx:"1",children:r}),o?(0,w.jsx)(Ve,{width:24,height:24,iconcolor:o&&"green"}):(0,w.jsx)(Ne,{width:24,height:24,onClick:b})]})]})},le=_e;var ue=require("react");var F=require("react");var We=P(require("axios"),1);var W=require("react"),Ue=require("react/jsx-runtime"),Ct=(0,W.createContext)(void 0),ce="production";var q=ce==="development"?"https://qa-api-v2.bandit.network/sdk":"https://api-v2.bandit.network/sdk";var de=require("react/jsx-runtime");var qe=require("react/jsx-runtime"),pe=(0,F.createContext)(void 0);var fe=()=>(0,ue.useContext)(pe);var me=P(require("axios"),1);var he=(e,t,o,s)=>R(void 0,null,function*(){try{return(yield me.default.get(`${q}/spaces/leaderboard?space_ids=${e}&offset=${t}&limit=${o}`,{headers:{"X-API-KEY":s}})).data}catch(r){throw r}});var qt=require("react");var ge=require("react"),I="...",N=(e,t)=>{let o=t-e+1;return Array.from({length:o},(s,r)=>r+e)},xe=({totalCount:e,pageSize:t,siblingCount:o=1,currentPage:s})=>(0,ge.useMemo)(()=>{let l=Math.ceil(e/t);if(o+5>=l)return N(1,l);let c=Math.max(s-o,1),d=Math.min(s+o,l),u=c>2,f=d<l-2,m=1,v=l;if(!u&&f){let a=3+2*o;return[...N(1,a),I,l]}if(u&&!f){let a=3+2*o,C=N(l-a+1,l);return[m,I,...C]}if(u&&f){let a=N(c,d);return[m,I,...a,I,v]}},[e,t,o,s]);var J=P(require("@emotion/styled"),1),Ce=J.default.ul`
  display: flex;
  align-items: center;
  justify-content: center;
  list-style-type: none;
`,H=J.default.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 {
  }
`;var V=require("@chakra-ui/icons"),D=require("@chakra-ui/react"),h=require("react/jsx-runtime");var Je=e=>{let{onPageChange:t,totalCount:o,siblingCount:s=1,currentPage:r,pageSize:l,className:b}=e,c=xe({currentPage:r,totalCount:o,siblingCount:s,pageSize:l});if(r===0||c.length<2)return null;let d=()=>{t(r+1)},u=()=>{t(r-1)},f=c[c.length-1];return(0,h.jsxs)(D.Flex,{align:"center",children:[(0,h.jsx)(D.Box,{children:(0,h.jsx)(V.ChevronLeftIcon,{boxSize:6,onClick:r===1?()=>{}:u,opacity:r===1?.1:1,cursor:r===1?"not-allowed":"pointer"})}),(0,h.jsx)(Ce,{children:c.map((m,v)=>m===I?(0,h.jsx)(H,{className:"dots",children:"\u2026"},v):(0,h.jsx)(H,{className:m===r?"selected":"",onClick:m===r?()=>{}:()=>t(m),children:m},v))}),(0,h.jsx)(D.Box,{children:(0,h.jsx)(V.ChevronRightIcon,{boxSize:6,onClick:r===f?()=>{}:d,opacity:r===f?.1:1,cursor:r===f?"not-allowed":"pointer"})})]})},ye=Je;var i=require("react/jsx-runtime"),K=(0,we.default)(n.Th)`
  padding-left: 0;
  text-transform: unset;
  /* color: ${({theme:e})=>e.colors.text}; */
  font-size: 14px;
`,Q=10,He=({selectedSpaceId:e})=>{var v;let[t,o]=(0,g.useState)(1),[s,r]=(0,g.useState)(!1),[l,b]=(0,g.useState)(0),[c,d]=(0,g.useState)({}),{accessKey:u}=fe(),f=(0,g.useCallback)(()=>R(void 0,null,function*(){try{r(!0);let{data:a,totalResults:C}=yield he(e,(t-1)*Q,Q,u);d(O=>S(y({},O),{[t]:a.map(k=>{var T;return y({collectionId:(T=k==null?void 0:k.User)==null?void 0:T.username},k)})})),b(C)}catch(a){}finally{r(!1)}}),[e,t,d]);(0,g.useEffect)(()=>{e&&f()},[e,f]);let m=(0,g.useCallback)(a=>{r(!0),o(a)},[]);return(0,i.jsxs)(Y.Flex,{flexDir:"column",w:"full",children:[(0,i.jsx)(n.TableContainer,{pt:"20px",children:(0,i.jsxs)(n.Table,{size:"sm",children:[(0,i.jsx)(n.Thead,{width:"100",children:(0,i.jsxs)(n.Tr,{pb:"2",children:[(0,i.jsx)(K,{color:"mutedForeground",borderColor:"input",children:"Ranking"}),(0,i.jsx)(K,{color:"mutedForeground",borderColor:"input",textAlign:"left",px:"0",children:"User"}),(0,i.jsx)(K,{color:"mutedForeground",borderColor:"input",textAlign:"right",px:"0",children:"Quest completed"})]})}),(0,i.jsx)(n.Tbody,{children:c!=null&&c[t]?(v=c==null?void 0:c[t])==null?void 0:v.map((a,C)=>{var O,k,T;return(0,i.jsxs)(n.Tr,{children:[(0,i.jsx)(n.Td,{"data-title":"Raking",borderColor:"input",px:"0",w:"24",children:s?(0,i.jsx)(n.Skeleton,{borderRadius:"4",w:"6",h:"6",startColor:"muted",endColor:"input"}):(0,i.jsx)(n.Box,{children:(0,i.jsx)(n.Text,{children:a==null?void 0:a.rank})})}),(0,i.jsx)(n.Td,{"data-title":"User",borderColor:"input",px:"0",children:s?(0,i.jsx)(n.Skeleton,{borderRadius:"4",w:"32",h:"6",startColor:"muted",endColor:"input"}):(0,i.jsx)(le,{domain:(O=a==null?void 0:a.user)==null?void 0:O.domainName,address:(k=a==null?void 0:a.user)==null?void 0:k.username})}),(0,i.jsx)(n.Td,{"data-title":"Quest completed",borderColor:"input",px:"0",children:s?(0,i.jsx)(n.Skeleton,{borderRadius:"4",ml:"auto",w:"8",h:"6",startColor:"muted",endColor:"input"}):(0,i.jsx)(n.Text,{textAlign:"right",fontWeight:600,fontSize:14,children:(T=a==null?void 0:a.stats)==null?void 0:T.questCompleted})})]},C)}):[1,2,3,4,5,6,7,8,9,10].map((a,C)=>(0,i.jsxs)(n.Tr,{children:[(0,i.jsx)(n.Td,{"data-title":"Raking",borderColor:"input",px:"0",w:"24",children:(0,i.jsx)(n.Skeleton,{borderRadius:"4",w:"6",h:"6",startColor:"muted",endColor:"input"})}),(0,i.jsx)(n.Td,{"data-title":"User",borderColor:"input",px:"0",children:(0,i.jsx)(n.Skeleton,{borderRadius:"4",w:"32",h:"6",startColor:"muted",endColor:"input"})}),(0,i.jsx)(n.Td,{"data-title":"Quest completed",borderColor:"input",px:"0",children:(0,i.jsx)(n.Skeleton,{borderRadius:"4",ml:"auto",w:"8",h:"6",startColor:"muted",endColor:"input"})})]},C))})]})}),(0,i.jsx)(Y.Flex,{justify:"center",marginY:3,children:(0,i.jsx)(ye,{currentPage:t,totalCount:l,pageSize:Q,onPageChange:m})})]})},be=He;var _=require("react-redux");var ve=require("@reduxjs/toolkit"),Ke={selectedCollectionId:null,showMint:!1,collectionViewOpen:!1,selectedSpaceId:!1},ke=(0,ve.createSlice)({name:"collection",initialState:Ke,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:to,updateShowMint:oo,updateCollectionViewOpen:ro,updateSelectedSpaceId:Se}=ke.actions,no=ke.reducer;var x=require("react/jsx-runtime"),Qe=({isOpen:e=!0})=>{let{rootRef:t}=ee(),o=(0,_.useSelector)(l=>l.collection.selectedSpaceId),s=(0,_.useDispatch)(),r=()=>{s(Se({id:null}))};return o?(0,x.jsxs)(p.Modal,{blockScrollOnMount:!1,portalProps:{containerRef:t},isOpen:!!o,onClose:r,isCentered:!0,size:"4xl",children:[(0,x.jsx)(p.ModalOverlay,{}),(0,x.jsxs)(p.ModalContent,{children:[(0,x.jsx)(p.ModalHeader,{children:" Leaderboard"}),(0,x.jsx)(p.ModalCloseButton,{}),(0,x.jsx)(p.ModalBody,{children:(0,x.jsx)(be,{selectedSpaceId:o})})]})]}):null};0&&(module.exports={Leaderboard});
