1import{d5 as e,d3 as t,dA as s,dB as r,dx as n,e6 as a,da as o,e7 as l,e8 as u}from"./index-Cq7_ZeC-.js";import{a as i,F as d,T as c}from"./ProbePage-D0gEiin0.js";import{l as x,c as m}from"./settlerMaps-D-RtOSVl.js";import{u as g}from"./onDisplayAuctionV2-BUS_H8hB.js";import{C as b}from"./chevron-down-DxsvzvH9.js";import"./index-BpYdy5vv.js";import"./Noun-BlXYzE4I.js";import"./lock-QhQhJ4zT.js";import"./external-link-CuIBDBmF.js";import"./ensLookup-CAqjl33O.js";import"./button-C3nSoWpC.js";import"./box-BD6Ql-Kx.js";const p={head:[],body:[],accessory:[],glasses:[],background:[]},h=[{label:"Latest",value:"id-desc"},{label:"Oldest",value:"id-asc"}];function f(e){return""===e||e.length<10?e:`${e.slice(0,6)}...${e.slice(-4)}`}function y({label:e,counts:s,value:r,onChange:n}){const[a,u]=t.useState(!1),[i,d]=t.useState(""),c=t.useRef(null);t.useEffect(()=>{const e=e=>{null===c.current||c.current.contains(e.target)||u(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const x=t.useMemo(()=>{if(""===i)return s.slice(0,50);const e=i.toLowerCase();return s.filter(([t])=>t.toLowerCase().includes(e)).slice(0,50)},[s,i]);return o.jsxs("div",{ref:c,className:"relative",children:[o.jsxs("button",{type:"button",onClick:()=>u(!a),className:"flex h-8 items-center gap-1 rounded-lg border px-2 text-xs "+(""!==r?"border-black bg-black text-white":"border-gray-200 bg-white text-gray-600"),children:[""!==r?f(r):e,""!==r?o.jsx(l,{size:12,onClick:e=>{e.stopPropagation(),n("")},className:"ml-1 cursor-pointer"}):o.jsx(b,{size:12})]}),a&&o.jsxs("div",{className:"absolute left-0 top-9 z-50 max-h-64 w-64 overflow-y-auto rounded-lg border border-gray-200 bg-white shadow-lg",children:[o.jsx("input",{type:"text",placeholder:"Search address...",value:i,onChange:e=>d(e.target.value),className:"w-full border-b px-3 py-2 text-xs outline-none",autoFocus:!0}),0===x.length?o.jsx("p",{className:"px-3 py-2 text-xs text-gray-400",children:"None yet"}):x.map(([e,t])=>o.jsxs("button",{type:"button",onClick:()=>{n(e),u(!1)},className:"flex w-full items-center justify-between px-3 py-1.5 text-xs hover:bg-gray-50",children:[o.jsx("span",{className:"font-mono",children:f(e)}),o.jsx("span",{className:"text-gray-400",children:t})]},e))]})]})}const j=()=>{const j=e(),v=g(),w=v?Number(v.nounId):void 0,N=void 0!==w?w+1:0,C=t.useMemo(()=>i(0,N),[N]),k=t.useMemo(()=>C.map(e=>({address:r,abi:s,functionName:"seeds",args:[BigInt(e)]})),[C]),I=t.useMemo(()=>C.map(e=>({address:r,abi:s,functionName:"ownerOf",args:[BigInt(e)]})),[C]),{data:S,isLoading:L}=n({contracts:k,query:{enabled:N>0,staleTime:3e5,gcTime:18e5}}),{data:M}=n({contracts:I,query:{enabled:N>0,staleTime:6e4,gcTime:18e5}}),z=t.useMemo(()=>{if(!S)return[];const e=[];for(let t=0;t<C.length;t++){const s=S[t];if("success"!==(null==s?void 0:s.status)||null==s.result)continue;const r=s.result,n={background:Number(r[0]),body:Number(r[1]),accessory:Number(r[2]),head:Number(r[3]),glasses:Number(r[4])},o=null==M?void 0:M[t],l="failure"===(null==o?void 0:o.status),u="success"===(null==o?void 0:o.status)?String(o.result).toLowerCase():"";let i="";try{i=a(BigInt(C[t]),n,!0).image}catch{i=""}e.push({nounId:C[t],seed:n,image:i,owner:u,burned:l})}return e},[S,M,C]),[T,E]=t.useState("id-desc"),[$,O]=t.useState(""),[P,B]=t.useState(""),[F,q]=t.useState(!1),[V,A]=t.useState(""),D=t.useRef(null);t.useEffect(()=>{const e=e=>{null===D.current||D.current.contains(e.target)||q(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const R=t.useMemo(()=>{const e=new Map;for(const t of z)""!==t.owner&&"0x0000000000000000000000000000000000000000"!==t.owner&&e.set(t.owner,(e.get(t.owner)??0)+1);return[...e.entries()].sort((e,t)=>t[1]-e[1])},[z]),J=t.useMemo(()=>{if(""===V)return R.slice(0,50);const e=V.toLowerCase();return R.filter(([t])=>t.toLowerCase().includes(e)).slice(0,50)},[R,V]),[K,G]=t.useState({}),[H,Q]=t.useState({}),[U,W]=t.useState(""),[X,Y]=t.useState(""),[Z,_]=t.useState(!1),[ee,te]=t.useState({...p}),se=Object.values(ee).reduce((e,t)=>
1e+t.length,0),re=""!==$||""!==P||""!==U||""!==X||se>0;t.useEffect(()=>{let e=!1;return x("v2").then(({settlers:t,curated:s})=>{e||(G(t),Q(s))}).catch(()=>{}),()=>{e=!0}},[]);const ne=t.useMemo(()=>m(K),[K]),ae=t.useMemo(()=>m(H),[H]),oe=t.useMemo(()=>{let e=[...z];if(""!==$){const t=parseInt($,10);isNaN(t)||(e=e.filter(e=>e.nounId===t))}return""!==P&&(e=e.filter(e=>e.owner===P.toLowerCase())),""!==U&&(e=e.filter(e=>(K[String(e.nounId)]??"").toLowerCase()===U)),""!==X&&(e=e.filter(e=>(H[String(e.nounId)]??"").toLowerCase()===X)),se>0&&(e=e.filter(e=>Object.entries(ee).every(([t,s])=>0===s.length||s.includes(e.seed[t])))),e.sort((e,t)=>"id-desc"===T?t.nounId-e.nounId:e.nounId-t.nounId),e},[z,$,P,U,X,K,H,ee,se,T]);return L&&0===z.length?o.jsx("div",{className:"flex items-center justify-center py-20 text-sm text-gray-400",children:"Loading NounV2 tokens from chainâ¦"}):o.jsxs("div",{children:[o.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 py-1",children:[o.jsx("input",{type:"number",placeholder:"Search ID...",value:$,onChange:e=>O(e.target.value),className:"h-8 w-24 rounded-lg border border-gray-200 bg-white px-2 text-xs outline-none focus:border-gray-400"}),o.jsxs("div",{ref:D,className:"relative",children:[o.jsxs("button",{type:"button",onClick:()=>q(!F),className:"flex h-8 items-center gap-1 rounded-lg border px-2 text-xs "+(""!==P?"border-black bg-black text-white":"border-gray-200 bg-white text-gray-600"),children:[""!==P?f(P):"Owner",""!==P?o.jsx(l,{size:12,onClick:e=>{e.stopPropagation(),B("")},className:"ml-1 cursor-pointer"}):o.jsx(b,{size:12})]}),F&&o.jsxs("div",{className:"absolute left-0 top-9 z-50 max-h-64 w-64 overflow-y-auto rounded-lg border border-gray-200 bg-white shadow-lg",children:[o.jsx("input",{type:"text",placeholder:"Search address...",value:V,onChange:e=>A(e.target.value),className:"w-full border-b px-3 py-2 text-xs outline-none",autoFocus:!0}),0===J.length?o.jsx("p",{className:"px-3 py-2 text-xs text-gray-400",children:"No holders yet"}):J.map(([e,t])=>o.jsxs("button",{type:"button",onClick:()=>{B(e),q(!1)},className:"flex w-full items-center justify-between px-3 py-1.5 text-xs hover:bg-gray-50",children:[o.jsx("span",{className:"font-mono",children:f(e)}),o.jsx("span",{className:"text-gray-400",children:t})]},e))]})]}),o.jsx(y,{label:"Settler",counts:ne,value:U,onChange:W}),o.jsx(y,{label:"Curated",counts:ae,value:X,onChange:Y}),o.jsxs("button",{type:"button",onClick:()=>_(!Z),className:"flex h-8 items-center gap-1 rounded-lg border px-2 text-xs "+(Z?"border-black bg-black text-white":"border-gray-200 bg-white text-gray-600"),children:[o.jsx(d,{size:12}),"Traits",se>0&&o.jsx("span",{className:"ml-1 rounded-full bg-red-500 px-1.5 py-0.5 text-xs text-white",children:se})]}),re&&o.jsxs("button",{type:"button",onClick:()=>{O(""),B(""),W(""),Y(""),te({...p})},className:"flex h-8 items-center gap-1 rounded-lg px-2 text-xs text-red-500 hover:bg-red-50",children:[o.jsx(l,{size:12})," Clear"]}),o.jsx("select",{value:T,onChange:e=>E(e.target.value),className:"h-8 rounded-lg border border-gray-200 bg-white px-2 text-xs outline-none",children:h.map(e=>o.jsx("option",{value:e.value,children:e.label},e.value))}),o.jsxs("span",{className:"ml-auto text-xs text-gray-400",children:[re?`${oe.length} / ${z.length}`:z.length," Nouns"]})]}),Z&&o.jsx(c,{traitFilters:ee,onToggle:(e,t)=>{te(s=>{const r=s[e],n=r.includes(t)?r.filter(e=>e!==t):[...r,t];return{...s,[e]:n}})},isV2:!0}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(72px, 1fr))",gap:6},children:oe.map(e=>o.jsxs("button",{type:"button",onClick:()=>j(u(e.nounId)),title:`Noun ${e.nounId}${e.burned?" (burned)":""}`,className:"group relative aspect-square overflow-hidden rounded-lg border border-gray-100 transition-all hover:scale-105 hover:shadow-md "+(e.burned?"grayscale":""),children:[""!==e.image&&o.jsx("img",{src:e.image,alt:`Noun ${e.nounId}`,loading:"lazy",className:"h-full w-full object-cover",style:{background:"var(--theme-bg-tertiary)"}}),o.jsx("span",{className:"absolute bottom-0.5 left-1/2 hidden -translate-x-1/2 roun
1ded bg-white/90 px-1 text-xs font-bold shadow-sm group-hover:block",children:e.nounId})]},e.nounId))})]})};export{j as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.