import { BookOpen, Eye, Globe2, Tags, TrendingUp } from 'lucide-react'; import { useEnrichment } from './useEnrichment.ts'; import type { MintStatsSnapshot, PageEnrichment } from '../shared/enrichment.ts'; import './enrichment.css'; const compact=new Intl.NumberFormat('en',{notation:'compact',maximumFractionDigits:1}); const full=new Intl.NumberFormat('en',{maximumFractionDigits:0}); const month=(value:string)=>new Date(`${value}-01T00:00:00Z`).toLocaleDateString('en',{month:'short',year:'numeric',timeZone:'UTC'}); const score=(value:number|null)=>value===null?'—':`${value}`; function ScoreStrip({stats,label}: {stats:PageEnrichment['stats'];label:string}){ return
{score(stats.attention)}Attention {score(stats.depth)}Depth {score(stats.reach)}Reach
; } export function EnrichmentScores({data}: {data:PageEnrichment}){ return ; } export function MintStatsScores({snapshot,compactView=false}: {snapshot:MintStatsSnapshot;compactView?:boolean}){ const latest=snapshot.pageviews.months.at(-1); if(compactView)return
AT MINT{latest?`${compact.format(latest.views)} views · ${snapshot.pageBytes.toLocaleString()} bytes`:'Page views unavailable'} · {new Date(snapshot.capturedAt).toLocaleDateString()}
; return

Statistics at mint

{new Date(snapshot.capturedAt).toLocaleString()}
Monthly views
{latest?full.format(latest.views):'Unavailable'}{month(snapshot.pageviews.latestMonth)} · complete month
6-month views
{snapshot.pageviews.total===null?'Unavailable':full.format(snapshot.pageviews.total)}
Monthly change
{snapshot.pageviews.trendPercent===null?'Unavailable':`${snapshot.pageviews.trendPercent>=0?'+':''}${snapshot.pageviews.trendPercent.toFixed(1)}%`}
Daily average
{snapshot.pageviews.dailyAverage===null?'Unavailable':full.format(snapshot.pageviews.dailyAverage)}latest complete month
Article size
{full.format(snapshot.pageBytes)} bytes
Languages
{snapshot.languagesTruncated?'≥ ':''}{full.format(snapshot.languageCount)}other-language links
Revision at capture
{snapshot.revisionId}
{snapshot.pageviews.status==='available'?
{snapshot.pageviews.months.map(item=>{month(item.month)}: {full.format(item.views)})}
:

Page views were unavailable when this NFT was minted. Missing counts were not recorded as zero.

}
; } export function CardInsights({pageId,snapshot}:{pageId:number;snapshot?:MintStatsSnapshot}){ const {data,error,retry}=useEnrichment(pageId); if(!data)return

Current Wikipedia statistics

{error?'Current metadata is unavailable. The mint-time statistics remain on the NFT.':'Loading current Wikipedia metadata and readership…'}

{error&&}{snapshot&&}
; const views=data.pageviews; const latest=views.months.at(-1); const maximum=Math.max(1,...views.months.map(m=>m.views)); const trend=views.trendPercent; return

Current Wikipedia statistics

LIVE · OFF-CHAIN
{data.description&&

{data.description}

}
Monthly views
{latest?full.format(latest.views):'Unavailable'}{month(views.latestMonth)} · human traffic
Monthly change
{trend===null?'Unavailable':`${trend>=0?'+':''}${trend.toFixed(1)}%`}vs. preceding month
6-month views
{views.total===null?'Unavailable':full.format(views.total)}
Daily average
{views.dailyAverage===null?'Unavailable':full.format(views.dailyAverage)}latest complete month
Article size
{full.format(data.pageBytes)} bytes
Languages
{data.languagesTruncated?'≥ ':''}{full.format(data.languageCount)}other-language links
Live revision
{data.revisionId}
Wikidata
{data.wikidataId?{data.wikidataId}:'Not linked'}
{views.status==='available'?
Monthly readership · six complete UTC months
{views.months.map(item=>
{compact.format(item.views)}
{month(item.month)}
)}
{views.months.map(item=>)}
Monthly human page views
{month(item.month)}{item.views}
:

Page views are unavailable or incomplete. Unknown counts are not treated as zero.

} {snapshot&&}

Wikipedia categories{data.categoriesTruncated?' · first 50':''}

{data.categories.length?data.categories.map(category=>{category}):No visible categories returned}
How are these scores calculated?

Scores range from 0–100, capped and rounded: Attention = log₁₀(monthly views + 1) ÷ 6 × 100; Depth = log₁₀(article bytes + 1) ÷ 6 × 100; Reach = log₁₀(language links + 1) ÷ 3 × 100. Depth measures size, not accuracy or quality. Scores can change and do not affect proof-derived rarity, NFT ownership, or consensus.

Retrieved {new Date(data.fetchedAt).toLocaleString()}. Live revision may differ from the minted snapshot. Sources: Wikipedia contributors (CC BY-SA 4.0) and Wikimedia Analytics (CC0). Views use all-access, user traffic and exclude classified bots. Article moves may affect title-based view history.

; }