var h=(t,o,n)=>new Promise((p,a)=>{var g=i=>{try{f(n.next(i))}catch(d){a(d)}},c=i=>{try{f(n.throw(i))}catch(d){a(d)}},f=i=>i.done?p(i.value):Promise.resolve(i.value).then(g,c);f((n=n.apply(t,o)).next())});import{ChevronLeftIcon as Y,ChevronRightIcon as D}from"@chakra-ui/icons";import{Box as I,Flex as y,Grid as L,GridItem as X,Modal as _,ModalBody as q,ModalCloseButton as J,ModalContent as U,ModalHeader as j,ModalOverlay as H,Skeleton as V,Text as k,useDisclosure as W}from"@chakra-ui/react";import{useCallback as Q,useEffect as Z,useState as l}from"react";import P,{jsNumberForAddress as R}from"react-jazzicon";import{default as N}from"react-shadow/emotion";import{jsx as F}from"react/jsx-runtime";var O=({address:t})=>{let o=Object.keys(N).length?P.default:P;return F(o,{diameter:"24",seed:R(t),svgStyles:{display:"block",verticalAlign:"middle"},paperStyles:{border:"1px solid #ffffff"}})},x=O;import K from"axios";import{createContext as G,useMemo as ft}from"react";import{jsx as ut}from"react/jsx-runtime";var dt=G(void 0),b="production";var S=b==="development"?"https://qa-api-v2.bandit.network/sdk":"https://api-v2.bandit.network/sdk";var $=(t,o,n,p)=>h(void 0,null,function*(){try{return(yield K.get(`${S}/collection/contest/${t}/participants?offset=${o}&limit=${n}`,{headers:{"X-API-KEY":p}})).data}catch(a){throw a}});var A=(t,o)=>t?t.length>o?t.substr(0,o-1)+"..."+t.substr(t.length-(o-1),t.length-1):t:"";import{Fragment as et,jsx as e,jsxs as s}from"react/jsx-runtime";var tt=({collectionId:t,accessKey:o})=>{let[n,p]=l(0),[a,g]=l(1),[c,f]=l(0),[i,d]=l([]),[M,E]=l(!0),[ot,w]=l(!0),{isOpen:z,onOpen:T,onClose:B}=W(),m=12,v=Q(()=>h(void 0,null,function*(){try{if(!t||!o)return;w(!0);let{data:r,totalResult:u}=yield $(t,n,m,o);d(r),f(u)}catch(r){console.log(r)}finally{w(!1),E(!1)}}),[t,o,n,a]);Z(()=>{v()},[v]);let C=r=>{g(r),p((r-1)*m)};return M?e(V,{mt:2,ml:"2",isLoaded:!1,fadeDuration:.1,minW:"40",minH:8,startColor:"muted",endColor:"input",borderRadius:"8"}):i.length?s(et,{children:[s(y,{onClick:T,alignItems:"flex-end",cursor:"pointer",children:[i.slice(0,11).map((r,u)=>e(I,{h:"24px",ml:u>0?"-15px":"0",children:e(x,{address:r},r)},r)),s(k,{fontWeight:"medium",fontSize:14,ml:2,children:[c," Participants"]})]}),s(_,{isOpen:z,onClose:B,size:"2xl",isCentered:!0,blockScrollOnMount:!1,children:[e(H,{}),s(U,{children:[e(j,{pb:"0",children:`Participants (${c})`}),e(J,{}),e(q,{children:s(I,{mr:3,mt:2,children:[e(L,{templateColumns:["repeat(2, 1fr)","repeat(2, 1fr)","repeat(3, 1fr)"],gap:4,mt:4,children:i.map((r,u)=>e(X,{children:s(y,{align:"center",children:[e(x,{address:r}),e(k,{ml:2,fontSize:14,children:A(r,6)})]})},u))}),e(y,{alignItems:"center",mt:"2",justifyContent:"center",children:s(y,{children:[e(Y,{w:"7",h:"7",color:a===1?"brand.400":"mutedForeground",cursor:a===1?"not-allowed":"pointer",mx:"1",onClick:a===1?()=>{}:()=>C(a-1)}),e(D,{w:"7",h:"7",color:n+m>=c?"brand.400":"mutedForeground",cursor:n+m>=c?"not-allowed":"pointer",mx:"1",onClick:n+m>=c?()=>{}:()=>C(a+1)})]})})]})})]})]})]}):null},Tt=tt;export{Tt as default};
