1(self.webpackChunkzkcodex=self.webpackChunkzkcodex||[]).push([[9441],{15576:(e,o,n)=>{"use strict";n.r(o),n.d(o,{default:()=>l});var t=n(9950),r=n(55271),s=n(34691),a=n(47465),d=n(44414);const l=()=>{var e,o,n,l,i,c,g,p;const[u,b]=(0,t.useState)(null),[m,x]=(0,t.useState)([]),[h,y]=(0,t.useState)(0),[j,D]=(0,t.useState)("single"),[v,N]=(0,t.useState)([]),[w,k]=(0,t.useState)(""),[f,A]=(0,t.useState)(""),[C,I]=(0,t.useState)(""),[U,S]=(0,t.useState)("amountDesc"),[$,q]=(0,t.useState)("all"),{theme:_}=(0,t.useContext)(a.D);(0,t.useEffect)(()=>{(async()=>{try{var e,o;const n=await fetch("https://grants-stack-indexer-v2.gitcoin.co/graphql",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"\n query GetProject($projectIds: [String!]) {\n projects(filter: {id: {in: $projectIds}}) {\n name\n metadata\n applications(filter: {status: {equalTo: APPROVED}}) {\n id\n totalAmountDonatedInUsd\n totalDonationsCount\n uniqueDonorsCount\n donations {\n id\n donorAddress\n amountInUsd\n transactionHash\n timestamp\n }\n }\n }\n }\n ",variables:{projectIds:["0x15524d92e001464560374928cc41ddc573d4c1975b234d880a99441ddaa76dbd"]}})}),t=null===(e=(await n.json()).data)||void 0===e||null===(o=e.projects)||void 0===o?void 0:o[0];t&&t.applications?(b(t),x(t.applications),F(t.applications,0,"single")):console.error("Project data is not available")}catch(n){console.error("Error fetching project data:",n)}})()},[]);const F=(e,o,n)=>{if("single"===n){var t;const n=(null===(t=e[o])||void 0===t?void 0:t.donations)||[];N(n)}else if("combined"===n){const o=e.reduce((e,o)=>[...e,...o.donations||[]],[]);N(o)}else if("comparison"===n){const o=e.reduce((e,o,n)=>[...e,...(o.donations||[]).map(e=>({...e,appIndex:n,applicationId:o.id}))],[]);N(o)}},T=e=>{D(e),F(m,h,e)},W=(()=>{if(!m||m.length<2)return null;const e=m.map(e=>new Set((e.donations||[]).map(e=>e.donorAddress))),o=new Set;e.length>0&&e[0].forEach(n=>{let t=!0;for(let o=1;o<e.length;o++)if(!e[o].has(n)){t=!1;break}t&&o.add(n)});const n=e.map(e=>e.size),t=new Set;return e.forEach(e=>{e.forEach(e=>t.add(e))}),{commonDonors:o,commonDonorsCount:o.size,donorCounts:n,allUniqueDonorsCount:t.size}})(),O=(()=>{if(!v.length)return{};const e=v.reduce((e,o)=>e+o.amountInUsd,0)/v.length,o=Math.max(...v.map(e=>e.amountInUsd)),n=Math.min(...v.map(e=>e.amountInUsd)),t=v.reduce((e,o)=>(e[o.donorAddress]=(e[o.donorAddress]||0)+o.amountInUsd,e),{});return{avgAmount:e,maxDonation:o,minDonation:n,mostGenerousDonor:Object.entries(t).sort((e,o)=>o[1]-e[1])[0]}})(),E=(()=>{if(!m.length)return{};return{totalDonationsUsd:m.reduce((e,o)=>e+(o.totalAmountDonatedInUsd||0),0),totalDonorsCount:m.reduce((e,o)=>e+(o.uniqueDonorsCount||0),0),totalDonationsCount:m.reduce((e,o)=>e+(o.totalDonationsCount||0),0)}})(),H=e=>{const o={};return e.forEach(e=>{o[e.donorAddress]||(o[e.donorAddress]=0),o[e.donorAddress]+=e.amountInUsd}),Object.entries(o).map(e=>{let[o,n]=e;return{address:o,totalAmount:n}})},L=()=>{let e=[...v];return"comparison"===j&&W&&"all"!==$&&(e=e.filter(e=>{const o=W.commonDonors.has(e.donorAddress);return"common"===$?o:"unique"!==$||!o})),e=e.filter(e=>{const o=e.donorAddress.toLowerCase().includes(w.toLowerCase()),n=!f||e.amountInUsd>=parseFloat(f),t=!C||e.amountInUsd<=parseFloat(C);return o&&n&&t}),"amountDesc"===U?e.sort((e,o)=>o.amountInUsd-e.amountInUsd):"amountAsc"===U?e.sort((e,o)=>e.amountInUsd-o.amountInUsd):"dateDesc"===U?e.sort((e,o)=>new Date(o.timestamp)-new Date(e.timestamp)):"dateAsc"===U&&e.sort((e,o)=>new Date(e.timestamp)-new Date(o.timestamp)),e};if(!u||!m.length)return(0,d.jsx)("div",{children:"Loading..."});const M=u.metadata,z=m[h]||{},B=L(),P=H(B).length;return(0,d.jsxs)("div",{className:"p-4",children:[(0,d.jsxs)("div",{className:"mb-6 p-4 rounded-lg flex items-center space-x-4 backdrop-blur-md "+("dark"===_?"bg-gray-900/20 border-gray-800":"bg-white border-gray-200"),children:[M.logoImg&&(0,d.jsx)("img",{src:`https://ipfs.io/ipfs/${M.logoImg}`,alt:M.title||u.name,className:"w-16 h-16 rounded-full"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("h1",{className:"text-3xl font-bold",children:u.name}),M.website&&(0,d.jsx)("a",{href:M.website,target:"_blank",rel:"noopener noreferrer",className:"text-blue-500 underline mt-2",children:"Visit Website"})]})]}),(0,d.jsxs)("div",{className:"mb-4 flex space-x-2",children:[(0,d.jsx)("button",{onClick:()=>T("single"),className:"p-2 rounded-lg transition-colors "+("single"===j?"dark"===_?"bg-blue-600 text-white":"bg-blue-500 text-white":"dark"===_?"bg-gray-800 text-gray-300":"bg-gray-200 text-gray-700"),children:"Single Application View"}),(0,d.jsx)("button",{onClick:()=>T("combined"),className:"p-2 rounded-lg transition-colors "+("combined"===j?"dark"===_?"bg-blue-600 text-white":"bg-blue-500 text-white":"dark"===_?"bg-gray-800 text-gray-300":"bg-gray-200 text-gray-700"),children:"Combined Applications View"}),(0,d.jsx)("button",{onClick:()=>{T("comparison"),q("all")},className:"p-2 rounded-lg transition-colors "+("comparison"===j?"dark"===_?"bg-blue-600 text-white":"bg-blue-500 text-white":"dark"===_?"bg-gray-800 text-gray-300":"bg-gray-200 text-gray-700"),children:"Donor Comparison View"})]}),"single"===j&&m.length>1&&(0,d.jsx)("div",{className:"mb-4 flex space-x-2",children:m.map((e,o)=>(0,d.jsxs)("button",{onClick:()=>(e=>{y(e),F(m,e,j)})(o),className:"p-2 rounded-lg transition-colors "+(h===o?"dark"===_?"bg-green-600 text-white":"bg-green-500 text-white":"dark"===_?"bg-gray-800 text-gray-300":"bg-gray-200 text-gray-700"),children:["Application ",o+1," (ID: ",e.id,")"]},e.id))}),"comparison"===j&&m.length>1&&(0,d.jsxs)("div",{className:"mb-4 flex space-x-2",children:[(0,d.jsx)("button",{onClick:()=>q("all"),className:"p-2 rounded-lg transition-colors "+("all"===$?"dark"===_?"bg-purple-600 text-white":"bg-purple-500 text-white":"dark"===_?"bg-gray-800 text-gray-300":"bg-gray-200 text-gray-700"),children:"All Donors"}),(0,d.jsx)("button",{onClick:()=>q("common"),className:"p-2 rounded-lg transition-colors "+("common"===$?"dark"===_?"bg-purple-600 text-white":"bg-purple-500 text-white":"dark"===_?"bg-gray-800 text-gray-300":"bg-gray-200 text-gray-700"),children:"Common Donors Only"}),(0,d.jsx)("button",{onClick:()=>q("unique"),className:"p-2 rounded-lg transition-colors "+("unique"===$?"dark"===_?"bg-purple-600 text-white":"bg-purple-500 text-white":"dark"===_?"bg-gray-800 text-gray-300":"bg-gray-200 text-gray-700"),children:"Unique Donors Only"})]}),"comparison"===j&&m.length>1&&W&&(0,d.jsxs)("div",{className:"mb-6 p-4 rounded-lg backdrop-blur-md "+("dark"===_?"bg-gray-900/20 border-gray-800":"bg-white border-gray-200"),children:[(0,d.jsx)("h2",{className:"text-xl font-bold mb-2",children:"Donor Analysis"}),(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-4 mb-2",children:[(0,d.jsxs)("div",{children:[(0,d.jsxs)("p",{children:[(0,d.jsx)("span",{className:"font-semibold",children:"Total Unique Donors:"})," ",W.allUniqueDonorsCount]}),(0,d.jsxs)("p",{children:[(0,d.jsx)("span",{className:"font-semibold",children:"Common Donors (donated to all applications):"})," ",W.commonDonorsCount]})]}),(0,d.jsx)("div",{children:m.map((e,o)=>(0,d.jsxs)("p",{children:[(0,d.jsxs)("span",{className:"font-semibold",children:["App ",o+1," (ID: ",e.id,") Donors:"]})," ",W.donorCounts[o]||0]},e.id))})]})]}),(0,d.jsxs)("div",{className:"mb-6 grid grid-cols-3 gap-4",children:[(0,d.jsxs)("div",{className:"p-4 rounded-lg text-center backdrop-blur-md "+("dark"===_?"bg-gray-900/20 border-gray-800":"bg-white border-gray-200"),children:[(0,d.jsx)("h2",{className:"text-xl font-bold",children:"Total Donations"}),(0,d.jsxs)("p",{className:"text-2xl",children:["$","single"===j?(null===(e=z.totalAmountDonatedInUsd)||void 0===e?void 0:e.toFixed(2))||"0.00":(null===(o=E.totalDonationsUsd)||void 0===o?void 0:o.toFixed(2))||"0.00"]})]}),(0,d.jsxs)("div",{className:"p-4 rounded-lg text-center backdrop-blur-md "+("dark"===_?"bg-gray-900/20 border-gray-800":"bg-white border-gray-200"),children:[(0,d.jsx)("h2",{className:"text-xl font-bold",children:"Total Donors"}),(0,d.jsx)("p",{className:"text-2xl",children:"single"===j?z.uniqueDonorsCount||0:("combined"===j?P:null===W||void 0===W?void 0:W.allUniqueDonorsCount)||0})]}),(0,d.jsxs)("div",{className:"p-4 rounded-lg text-center backdrop-blur-md "+("dark"===_?"bg-gray-900/20 border-gray-800":"bg-white border-gray-200"),children:[(0,d.jsx)("h2",{className:"text-xl font-bold",children:"Total Donations Count"}),(0,d.jsx)("p",{className:"text-2xl",children:"single"===j?z.totalDonationsCount||0:B.length||0})]}),(0,d.jsxs)("div",{className:"p-4 rounded-lg text-center backdrop-blur-md "+("dark"===_?"bg-gray-900/20 border-gray-800":"bg-white border-gray-200"),children:[(0,d.jsx)("h2",{className:"text-xl font-bold",children:"Average Donation"}),(0,d.jsxs)("p",{className:"text-2xl",children:["$",(null===(n=O.avgAmount)||void 0===n?void 0:n.toFixed(2))||"0.00"]})]}),(0,d.jsxs)("div",{className:"p-4 rounded-lg text-center backdrop-blur-md "+("dark"===_?"bg-gray-900/20 border-gray-800":"bg-white border-gray-200"),children:[(0,d.jsx)("h2",{className:"text-xl font-bold",children:"Highe
1st Donation"}),(0,d.jsxs)("p",{className:"text-2xl",children:["$",(null===(l=O.maxDonation)||void 0===l?void 0:l.toFixed(2))||"0.00"]})]}),(0,d.jsxs)("div",{className:"p-4 rounded-lg text-center backdrop-blur-md "+("dark"===_?"bg-gray-900/20 border-gray-800":"bg-white border-gray-200"),children:[(0,d.jsx)("h2",{className:"text-xl font-bold",children:"Lowest Donation"}),(0,d.jsxs)("p",{className:"text-2xl",children:["$",(null===(i=O.minDonation)||void 0===i?void 0:i.toFixed(2))||"0.00"]})]}),(0,d.jsxs)("div",{className:"p-4 rounded-lg text-center backdrop-blur-md "+("dark"===_?"bg-gray-900/20 border-gray-800":"bg-white border-gray-200"),children:[(0,d.jsx)("h2",{className:"text-xl font-bold",children:"Top Donor"}),(0,d.jsx)("p",{className:"text-sm",children:(null===(c=O.mostGenerousDonor)||void 0===c?void 0:c[0])||"N/A"}),(0,d.jsxs)("p",{className:"text-lg",children:["$",(null===(g=O.mostGenerousDonor)||void 0===g||null===(p=g[1])||void 0===p?void 0:p.toFixed(2))||"0.00"]})]})]}),(0,d.jsxs)("div",{className:"mb-4 flex space-x-2",children:[(0,d.jsx)("button",{onClick:()=>{const e=L().map(e=>{var o;return{"Donor Address":e.donorAddress,"Amount (USD)":e.amountInUsd,"Transaction Hash":e.transactionHash,Date:new Date(e.timestamp).toLocaleDateString(),"Application ID":e.applicationId||(null===(o=m[h])||void 0===o?void 0:o.id)||"N/A"}}),o=r.Wp.json_to_sheet(e),n=r.Wp.book_new();r.Wp.book_append_sheet(n,o,"Donations");const t=(0,r.M9)(n,{bookType:"csv",type:"array"}),a=new Blob([t],{type:"text/csv"});(0,s.saveAs)(a,"donations.csv")},className:"p-2 rounded-lg text-white "+("dark"===_?"bg-blue-600":"bg-blue-500"),children:"Download Full Donation Data"}),(0,d.jsxs)("button",{onClick:()=>{const e=L(),o=H(e),n=o.map(e=>({"Wallet Address":e.address}));console.log(`UI shows ${e.length} donations from ${o.length} unique addresses`);const t=r.Wp.json_to_sheet(n),a=r.Wp.book_new();r.Wp.book_append_sheet(a,t,"Wallet Addresses");const d=(0,r.M9)(a,{bookType:"csv",type:"array"}),l=new Blob([d],{type:"text/csv"});(0,s.saveAs)(l,"wallet_addresses.csv")},className:"p-2 rounded-lg text-white "+("dark"===_?"bg-green-600":"bg-green-500"),children:["Download Wallet Addresses Only (",P,")"]}),m.length>1&&(0,d.jsx)("button",{onClick:()=>{if(!m||0===m.length)return;const e=L(),o=new Set(e.map(e=>e.donorAddress)),n=new Map;m.forEach((e,t)=>{(e.donations||[]).forEach(e=>{if(!o.has(e.donorAddress))return;n.has(e.donorAddress)||n.set(e.donorAddress,{appFlags:Array(m.length).fill(!1),totalAmount:0}),n.get(e.donorAddress).appFlags[t]=!0;n.get(e.donorAddress).totalAmount+=e.amountInUsd})});const t=Array.from(n.entries()).map(e=>{let[o,n]=e;const t={"Donor Address":o};return m.forEach((e,o)=>{t[`Donated to App ${o+1} (ID: ${e.id})`]=n.appFlags[o]?"Yes":"No"}),t["Donated to All Apps"]=n.appFlags.every(e=>e)?"Yes":"No",t});console.log(`Exporting ${t.length} unique donors by application`);const a=r.Wp.json_to_sheet(t),d=r.Wp.book_new();r.Wp.book_append_sheet(d,a,"Donors By Application");const l=(0,r.M9)(d,{bookType:"csv",type:"array"}),i=new Blob([l],{type:"text/csv"});(0,s.saveAs)(i,"donors_by_application.csv")},className:"p-2 rounded-lg text-white "+("dark"===_?"bg-purple-600":"bg-purple-500"),children:"Download Donors By Application"})]}),(0,d.jsxs)("div",{className:"mb-4 flex space-x-4",children:[(0,d.jsx)("input",{type:"text",placeholder:"Search by donor address",value:w,onChange:e=>k(e.target.value),className:"bg-transparent border p-2 rounded-lg focus:ring-blue-500 focus:border-blue-500 "+("dark"===_?"bg-gray-900/20 border-gray-800":"bg-white border-gray-200")}),(0,d.jsx)("input",{type:"number",placeholder:"Min amount in USD",value:f,onChange:e=>A(e.target.value),className:"bg-transparent border p-2 rounded-lg focus:ring-blue-500 focus:border-blue-500 "+("dark"===_?"bg-gray-900/20 border-gray-800":"bg-white border-gray-200")}),(0,d.jsx)("input",{type:"number",placeholder:"Max amount in USD",value:C,onChange:e=>I(e.target.value),className:"bg-transparent border p-2 rounded-lg focus:ring-blue-500 focus:border-blue-500 "+("dark"===_?"bg-gray-900/20 border-gray-800":"bg-white border-gray-200")}),(0,d.jsxs)("select",{value:U,onChange:e=>S(e.target.value),className:"bg-transparent border p-2 rounded-lg focus:ring-blue-500 focus:border-blue-500 "+("dark"===_?"bg-gray-900/20 border-gray-800":"bg-white border-gray-200"),children:[(0,d.jsx)("option",{value:"amountDesc",children:"Amount: High to Low"}),(0,d.jsx)("option",{value:"amountAsc",children:"Amount: Low to High"}),(0,d.jsx)("option",{value:"dateDesc",children:"Date: New to Old"}),(0,d.jsx)("option",{value:"dateAsc",children:"Date: Old to New"})]})]}),(0,d.jsx)("p",{className:"mb-4 "+("dark"===_?"text-gray-300":"text-gray-700"),children:"single"===j?`Showing Application ID: ${z.id} (${B.length} donations from ${"single"===j?z.uniqueDonorsCount:P} unique donors)`:"combined"===j?`Showing Combined Applications (${B.length} donations from ${P} unique donors)`:`Showing Donor Comparison (${B.length} donations from ${P} unique donors) - ${"all"===$?"All Donors":"common"===$?"Common Donors Only":"Unique Donors Only"}`}),(0,d.jsx)("div",{className:"rounded-lg border shadow-sm overflow-hidden backdrop-blur-sm "+("dark"===_?"bg-gray-900/20 border-gray-800":"bg-white border-gray-200"),children:(0,d.jsxs)("table",{className:"min-w-full",children:[(0,d.jsx)("thead",{children:(0,d.jsxs)("tr",{className:"dark"===_?"border-gray-800":"border-gray-200",children:[(0,d.jsx)("th",{className:"py-2 px-4 border-b",children:"ID"}),(0,d.jsx)("th",{className:"py-2 px-4 border-b",children:"Donor Address"}),(0,d.jsx)("th",{className:"py-2 px-4 border-b",children:"Amount (USD)"}),"comparison"===j&&m.length>1&&(0,d.jsx)("th",{className:"py-2 px-4 border-b",children:"Applications"}),(0,d.jsx)("th",{className:"py-2 px-4 border-b",children:"Transaction ID"}),(0,d.jsx)("th",{className:"py-2 px-4 border-b",children:"Date"})]})}),(0,d.jsx)("tbody",{className:"dark"===_?"text-gray-400 divide-gray-800":"text-gray-700 divide-gray-200",children:B.map((e,o)=>(0,d.jsxs)("tr",{children:[(0,d.jsx)("td",{className:"py-2 px-4 border-b",children:o+1}),(0,d.jsxs)("td",{className:"py-2 px-4 border-b",children:[e.donorAddress,"comparison"===j&&(null===W||void 0===W?void 0:W.commonDonors.has(e.donorAddress))&&(0,d.jsx)("span",{className:"ml-2 px-1 text-xs rounded-md bg-green-500 text-white",children:"Common"})]}),(0,d.jsxs)("td",{className:"py-2 px-4 border-b",children:["$",e.amountInUsd.toFixed(2)]}),"comparison"===j&&m.length>1&&(0,d.jsx)("td",{className:"py-2 px-4 border-b",children:(0,d.jsx)("div",{className:"flex space-x-1",children:m.map((o,n)=>{return(0,d.jsxs)("span",{className:"inline-block px-2 py-0.5 text-xs rounded-full "+(t=e.donorAddress,r=n,m[r]&&m[r].donations&&m[r].donations.some(e=>e.donorAddress===t)?"dark"===_?"bg-green-600 text-white":"bg-green-500 text-white":"dark"===_?"bg-gray-700 text-gray-400":"bg-gray-300 text-gray-700"),children:["App ",n+1]},o.id);var t,r})})}),(0,d.jsx)("td",{className:"py-2 px-4 border-b",children:(0,d.jsxs)("a",{href:`https://explorer-url/${e.transactionHash}`,className:"text-blue-500 underline",children:[e.transactionHash.slice(0,10),"..."]})}),(0,d.jsx)("td",{className:"py-2 px-4 border-b",children:new Date(e.timestamp).toLocaleDateString()})]},e.id))})]})})]})}},83686:()=>{}}]);
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.