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