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