"use client" import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card" import { Badge } from "@/components/ui/badge" import { Progress } from "@/components/ui/progress" import { BarChart3, TrendingUp, TrendingDown, Users, Play, Star, GitFork, Eye, Clock, Zap } from "lucide-react" interface AnalyticsStat { label: string value: string | number change?: number changeLabel?: string icon: React.ReactNode } interface EnhancedAnalyticsProps { stats: { totalRuns: number totalStars: number totalRemixes: number totalViews: number averageResponseTime: number tokenUsage: number topPrompts: { title: string; runs: number; stars: number }[] runsByDay: { date: string; runs: number }[] modelUsage: { model: string; percentage: number }[] } } export function EnhancedAnalytics({ stats }: EnhancedAnalyticsProps) { const mainStats: AnalyticsStat[] = [ { label: "Total Runs", value: stats.totalRuns.toLocaleString(), change: 12.5, changeLabel: "vs last week", icon: }, { label: "Total Stars", value: stats.totalStars.toLocaleString(), change: 8.3, changeLabel: "vs last week", icon: }, { label: "Remixes", value: stats.totalRemixes.toLocaleString(), change: 25.0, changeLabel: "vs last week", icon: }, { label: "Total Views", value: stats.totalViews.toLocaleString(), change: -2.1, changeLabel: "vs last week", icon: } ] return (
{/* Main Stats Grid */}
{mainStats.map((stat, index) => (
{stat.icon} {stat.change !== undefined && ( = 0 ? "text-green-500" : "text-red-500"} > {stat.change >= 0 ? ( ) : ( )} {Math.abs(stat.change)}% )}

{stat.value}

{stat.label}

))}
{/* Performance Metrics */}
Performance Metrics
Avg Response Time {stats.averageResponseTime}ms

{stats.averageResponseTime < 2000 ? "Excellent" : stats.averageResponseTime < 4000 ? "Good" : "Needs improvement"}

Token Efficiency {(stats.tokenUsage / 1000).toFixed(1)}k tokens

Above average efficiency

Model Usage {stats.modelUsage.map((model, index) => (
{model.model} {model.percentage}%
))}
{/* Top Prompts */} Top Performing Prompts Your most popular prompts by runs
{stats.topPrompts.map((prompt, index) => (
{index + 1}

{prompt.title}

{prompt.runs} runs {prompt.stars} stars
))}
{/* Activity Chart (Simple Bar Representation) */} Weekly Activity Runs per day over the last 7 days
{stats.runsByDay.map((day, index) => { const maxRuns = Math.max(...stats.runsByDay.map(d => d.runs)) const height = (day.runs / maxRuns) * 100 return (
{day.date}
) })}
) }