import React, { useState } from "react"; import { Store, Sparkles, Plus, Search, Star, Users, BookOpen, Code, FileText, Image as ImageIcon, Database, Lock, Globe, ArrowRight, Check, Upload, X, Sliders, Share2, LogIn, Zap, ShieldCheck, Cpu, Layers, ExternalLink } from "lucide-react"; export interface CustomGpt { id: string; name: string; author: string; description: string; category: "coding" | "oxford" | "creative" | "productivity" | "analytics"; avatar: string; rating: number; useCount: number; systemPrompt: string; knowledgeFiles?: string[]; capabilities: { webSearch: boolean; codeExecution: boolean; artifacts: boolean; computerUse: boolean; }; customApiActions?: { endpointUrl: string; method: "GET" | "POST"; headers: string; }[]; isCustomCreated?: boolean; } interface CustomGptStoreModalProps { isOpen: boolean; onClose: () => void; currentUser: { email?: string; isGuest?: boolean } | null; onOpenAuthModal: () => void; onSelectGpt: (gpt: CustomGpt) => void; } export default function CustomGptStoreModal({ isOpen, onClose, currentUser, onOpenAuthModal, onSelectGpt }: CustomGptStoreModalProps) { const [activeTab, setActiveTab] = useState<"marketplace" | "create" | "myGpts">("marketplace"); const [selectedCategory, setSelectedCategory] = useState("all"); const [searchQuery, setSearchQuery] = useState(""); // New GPT Form State const [name, setName] = useState(""); const [description, setDescription] = useState(""); const [category, setCategory] = useState("coding"); const [avatar, setAvatar] = useState("🤖"); const [systemPrompt, setSystemPrompt] = useState(""); const [knowledgeFiles, setKnowledgeFiles] = useState([]); const [webSearch, setWebSearch] = useState(true); const [codeExecution, setCodeExecution] = useState(true); const [artifacts, setArtifacts] = useState(true); const [computerUse, setComputerUse] = useState(false); const [apiEndpoint, setApiEndpoint] = useState(""); const [apiMethod, setApiMethod] = useState<"GET" | "POST">("POST"); // Default Featured Custom GPT Marketplace Items const [customGpts, setCustomGpts] = useState([ { id: "gpt-oxford", name: "Oxford Textbook Master", author: "Oxford Education AI", description: "Expert tutor for Grade 6-8 Oxford English lessons, literature summaries, and Q&A analysis.", category: "oxford", avatar: "📚", rating: 4.9, useCount: 14200, systemPrompt: "You are an expert Oxford English literature & language tutor with full indexed knowledge of Grade 6, Grade 7, and Grade 8 textbooks.", capabilities: { webSearch: true, codeExecution: false, artifacts: true, computerUse: false } }, { id: "gpt-code-architect", name: "React & Vite Code Architect", author: "Aura Dev Labs", description: "Senior full-stack code architect creating production-ready React 19, TypeScript, and Express components with side-by-side Artifacts execution.", category: "coding", avatar: "⚡", rating: 4.95, useCount: 28900, systemPrompt: "You are a master React 19 & TypeScript software architect specializing in clean, modern UI components with Tailwind CSS.", capabilities: { webSearch: true, codeExecution: true, artifacts: true, computerUse: true } }, { id: "gpt-image-prompt", name: "FLUX & Gemini Visual Designer", author: "Aura Creative", description: "Crafts ultra-detailed image prompts, vector SVG graphic layouts, and typography palettes for AI Image Studio.", category: "creative", avatar: "🎨", rating: 4.88, useCount: 9800, systemPrompt: "You are a master creative director generating photorealistic FLUX image prompts and custom SVG vector art.", capabilities: { webSearch: false, codeExecution: false, artifacts: true, computerUse: false } }, { id: "gpt-data-analyst", name: "Spreadsheet & SQL Data Analyst", author: "Analytics Core", description: "Parses CSV, Excel, and JSON data to generate interactive charts, SQL queries, and financial trend breakdowns.", category: "analytics", avatar: "📊", rating: 4.85, useCount: 11200, systemPrompt: "You are an expert data analyst who transforms raw data files into clear visualizations, Recharts charts, and SQL queries.", capabilities: { webSearch: true, codeExecution: true, artifacts: true, computerUse: false } } ]); if (!isOpen) return null; const isSignedIn = currentUser && !currentUser.isGuest && Boolean(currentUser.email); const filteredGpts = customGpts.filter(gpt => { const matchesCategory = selectedCategory === "all" || gpt.category === selectedCategory; const matchesSearch = gpt.name.toLowerCase().includes(searchQuery.toLowerCase()) || gpt.description.toLowerCase().includes(searchQuery.toLowerCase()); return matchesCategory && matchesSearch; }); const handleCreateGpt = (e: React.FormEvent) => { e.preventDefault(); if (!isSignedIn) { onOpenAuthModal(); return; } if (!name.trim() || !systemPrompt.trim()) return; const newGpt: CustomGpt = { id: `custom-gpt-${Date.now()}`, name, author: currentUser?.email || "Signed-in Creator", description: description || "Custom user-built specialized AI micro-app.", category, avatar, rating: 5.0, useCount: 1, systemPrompt, knowledgeFiles, capabilities: { webSearch, codeExecution, artifacts, computerUse }, customApiActions: apiEndpoint ? [{ endpointUrl: apiEndpoint, method: apiMethod, headers: "Content-Type: application/json" }] : [], isCustomCreated: true }; setCustomGpts([newGpt, ...customGpts]); setActiveTab("marketplace"); onSelectGpt(newGpt); }; return (
e.stopPropagation()} > {/* Header Bar */}

Custom GPT Store & Studio

Micro-App Marketplace

Package tailored system prompts, knowledge files, and custom API connections into shareable micro-apps

{/* Tab Navigation */}
{/* User Sign-In Badge */}
{isSignedIn ? (
Signed In ({currentUser?.email})
) : ( )}
{/* TAB 1: Marketplace View */} {activeTab === "marketplace" && (
{/* Search & Categories Bar */}
setSearchQuery(e.target.value)} placeholder="Search Custom GPTs by name or skill..." className="w-full pl-9 pr-4 py-2 rounded-xl bg-slate-900 border border-slate-800 text-xs text-white placeholder-slate-500 focus:outline-none focus:ring-1 focus:ring-indigo-500" />
{/* Category Pills */}
{[ { id: "all", label: "All GPTs" }, { id: "coding", label: "Coding & Dev" }, { id: "oxford", label: "Oxford Education" }, { id: "creative", label: "Creative & Design" }, { id: "analytics", label: "Data & Charts" } ].map(cat => ( ))}
{/* Custom GPT Cards Grid */}
{filteredGpts.map(gpt => (
{gpt.avatar}

{gpt.name}

{gpt.rating}
By {gpt.author}

{gpt.description}

{/* Capabilities Badges */}
{gpt.capabilities.artifacts && Artifacts} {gpt.capabilities.codeExecution && Code Run} {gpt.capabilities.computerUse && Computer Use}
))}
)} {/* TAB 2: Create Custom GPT Form */} {activeTab === "create" && (
{!isSignedIn && (
Sign In Required to publish Custom GPT micro-apps to the marketplace.
)}
setName(e.target.value)} placeholder="e.g. Oxford Grade 7 Math Tutor" className="w-full px-3.5 py-2.5 rounded-xl bg-slate-900 border border-slate-800 text-xs text-white focus:outline-none focus:border-indigo-500" />
setAvatar(e.target.value)} maxLength={2} className="w-14 text-center px-2 py-2.5 rounded-xl bg-slate-900 border border-slate-800 text-lg font-bold" />
setDescription(e.target.value)} placeholder="What does this specialized micro-app do?" className="w-full px-3.5 py-2.5 rounded-xl bg-slate-900 border border-slate-800 text-xs text-white focus:outline-none focus:border-indigo-500" />