import { PlayCircle, PlayIcon, PlusIcon, VideoIcon } from "lucide-react"; import { useState } from "react"; import Lightbox, { GenericSlide, VideoSlide } from "yet-another-react-lightbox"; import "yet-another-react-lightbox/styles.css"; import { Message } from "./ChatWindow"; type Video = { url: string; img_src: string; title: string; iframe_src: string; }; declare module "yet-another-react-lightbox" { export interface VideoSlide extends GenericSlide { type: "video-slide"; src: string; iframe_src: string; } interface SlideTypes { "video-slide": VideoSlide; } } const Searchvideos = ({ query, chat_history }: { query: string; chat_history: Message[] }) => { const [videos, setVideos] = useState(null); const [loading, setLoading] = useState(false); const [open, setOpen] = useState(false); const [slides, setSlides] = useState([]); return ( <> {!loading && videos === null && ( )} {loading && (
{Array.from({ length: 4 }).map((_, index) => (
))}
)} {videos !== null && videos.length > 0 && ( <>
{videos.length > 4 ? videos.slice(0, 3).map((video, index) => (
{ setOpen(true); setSlides([slides[index], ...slides.slice(0, index), ...slides.slice(index + 1)]); }} className="relative transition duration-200 active:scale-95 hover:scale-[1.02] cursor-pointer" key={index} > {video.title}

Video

)) : videos.map((video, index) => (
{ setOpen(true); setSlides([slides[index], ...slides.slice(0, index), ...slides.slice(index + 1)]); }} className="relative transition duration-200 active:scale-95 hover:scale-[1.02] cursor-pointer" key={index} > {video.title}

Video

))} {videos.length > 4 && ( )}
setOpen(false)} slides={slides} render={{ slide: ({ slide }) => slide.type === "video-slide" ? (