"use client"; import { useState, useMemo } from "react"; import { Search, Swords, Pickaxe, Hammer, TrendingUp, ClipboardList, GraduationCap, Zap, } from "lucide-react"; import { Card, CardContent } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Badge } from "@/components/ui/badge"; import { cn } from "@/lib/utils"; import { GALLERY_TEMPLATES, GALLERY_CATEGORIES, type GalleryTemplate, type GalleryCategoryKey, } from "./gallery-templates"; import { GalleryActivateDialog } from "./gallery-activate-dialog"; const STRATEGY_ICONS: Record = { combat: Swords, gathering: Pickaxe, crafting: Hammer, trading: TrendingUp, task: ClipboardList, leveling: GraduationCap, }; const STRATEGY_COLORS: Record< string, { text: string; bg: string; border: string } > = { combat: { text: "text-red-400", bg: "bg-red-500/10", border: "border-red-500/20", }, gathering: { text: "text-green-400", bg: "bg-green-500/10", border: "border-green-500/20", }, crafting: { text: "text-blue-400", bg: "bg-blue-500/10", border: "border-blue-500/20", }, trading: { text: "text-yellow-400", bg: "bg-yellow-500/10", border: "border-yellow-500/20", }, task: { text: "text-purple-400", bg: "bg-purple-500/10", border: "border-purple-500/20", }, leveling: { text: "text-cyan-400", bg: "bg-cyan-500/10", border: "border-cyan-500/20", }, }; const DIFFICULTY_COLORS: Record = { beginner: "bg-green-500/10 text-green-400 border-green-500/30", intermediate: "bg-yellow-500/10 text-yellow-400 border-yellow-500/30", advanced: "bg-red-500/10 text-red-400 border-red-500/30", }; const CATEGORY_ICONS: Record = { all: Zap, combat: Swords, gathering: Pickaxe, crafting: Hammer, trading: TrendingUp, utility: ClipboardList, }; export function AutomationGallery() { const [search, setSearch] = useState(""); const [category, setCategory] = useState("all"); const [selectedTemplate, setSelectedTemplate] = useState(null); const filtered = useMemo(() => { let result = GALLERY_TEMPLATES; if (category !== "all") { result = result.filter((t) => t.category === category); } if (search.trim()) { const q = search.toLowerCase().trim(); result = result.filter( (t) => t.name.toLowerCase().includes(q) || t.description.toLowerCase().includes(q) || t.tags.some((tag) => tag.includes(q)) ); } return result; }, [search, category]); return (
{/* Search & Category Filter */}
setSearch(e.target.value)} className="pl-9" />
{/* Category Tabs */}
{GALLERY_CATEGORIES.map((cat) => { const Icon = CATEGORY_ICONS[cat.key]; const isActive = category === cat.key; const count = cat.key === "all" ? GALLERY_TEMPLATES.length : GALLERY_TEMPLATES.filter((t) => t.category === cat.key).length; return ( ); })}
{/* Template Grid */} {filtered.length === 0 ? (

No automations match your search.

) : (
{filtered.map((template) => { const Icon = STRATEGY_ICONS[template.strategy_type] ?? Zap; const colors = STRATEGY_COLORS[template.strategy_type] ?? { text: "text-muted-foreground", bg: "bg-muted", border: "border-muted", }; return ( setSelectedTemplate(template)} > {/* Colored top bar */}

{template.name}

{template.description}

{template.difficulty} {template.min_level > 1 && ( Lv. {template.min_level}+ )} {template.skill_requirement && ( {template.skill_requirement.skill} {template.skill_requirement.level}+ )}
); })}
)} {/* Activation Dialog */} setSelectedTemplate(null)} />
); }