/* eslint-disable @next/next/no-img-element */
import React, { useState } from 'react';
import { motion, AnimatePresence } from 'framer-motion';
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { ArrowUpRight, Calendar, ChevronLeft, ChevronRight, Clock, Globe, ImageIcon, Newspaper, Search, X } from 'lucide-react';
import { ScrollArea } from '@/components/ui/scroll-area';
type SearchImage = {
url: string;
description: string;
};
type SearchResult = {
url: string;
title: string;
content: string;
raw_content: string;
published_date?: string;
};
type SearchQueryResult = {
query: string;
results: SearchResult[];
images: SearchImage[];
};
type MultiSearchResponse = {
searches: SearchQueryResult[];
};
type MultiSearchArgs = {
queries: string[];
maxResults: number[];
topic: ("general" | "news")[];
searchDepth: ("basic" | "advanced")[];
};
interface ResultCardProps {
result: SearchResult;
index: number;
}
interface GalleryProps {
images: SearchImage[];
onClose: () => void;
}
interface SearchResultsProps {
searchData: SearchQueryResult;
topicType: string;
onImageClick: (index: number) => void;
}
const SearchQueryTab: React.FC<{ query: string; count: number; isActive: boolean }> = ({ query, count, isActive }) => (
{query}
{count}
);
const ResultCard: React.FC = ({ result, index }) => {
return (
{result.published_date && (
)}
);
};
const ImageGrid: React.FC<{ images: SearchImage[]; onImageClick: (index: number) => void }> = ({ images, onImageClick }) => (
{images.slice(0, 4).map((image, index) => (
onImageClick(index)}
whileHover={{ scale: 1.02 }}
>
{index === 3 && images.length > 4 && (
+{images.length - 4}
)}
))}
);
const SearchResults: React.FC = ({ searchData, topicType, onImageClick }) => (
Results for “{searchData.query}“
{topicType}
{searchData.results.length} results
{searchData.results.map((result, index) => (
))}
{searchData.images.length > 0 && (
)}
);
interface ContentDialogProps {
isOpen: boolean;
onClose: () => void;
result: SearchResult;
}
const ContentDialog: React.FC = ({ isOpen, onClose, result }) => (
);
const MultiSearch: React.FC<{ result: MultiSearchResponse | null; args: MultiSearchArgs }> = ({ result, args }) => {
const [activeTab, setActiveTab] = useState("0");
const [galleryOpen, setGalleryOpen] = useState(false);
const [selectedSearch, setSelectedSearch] = useState(0);
const [selectedImage, setSelectedImage] = useState(0);
// Replace the current loading state in MultiSearch component with this:
if (!result) {
return (
Running searches...
Processing {args.queries.length} queries
{[0, 1, 2].map((index) => (
))}
);
}
return (
{result.searches.map((search, index) => (
))}
{result.searches.map((search, index) => (
{
setSelectedSearch(index);
setSelectedImage(imageIndex);
setGalleryOpen(true);
}}
/>
))}
{galleryOpen && result.searches[selectedSearch].images && (
)}
);
};
export default MultiSearch;