/* eslint-disable @next/next/no-img-element */ 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(4)].map((_, i) => (
))}
)} {videos !== null && videos.length > 0 && ( <>
{videos.length > 4 ? videos.slice(0, 3).map((video, i) => (
{ setOpen(true); setSlides([ slides[i], ...slides.slice(0, i), ...slides.slice(i + 1), ]); }} className="relative transition duration-200 active:scale-95 hover:scale-[1.02] cursor-pointer" key={i} > {video.title}

Video

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

Video

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