'use client' import { memo } from 'react' import { toast } from 'sonner' import { type VideoData } from '@/types/playground' import Icon from '@/components/ui/icon' const VideoItem = memo(({ video }: { video: VideoData }) => { const videoUrl = video.url const handleDownload = async () => { try { toast.loading('Downloading video...') const response = await fetch(videoUrl) if (!response.ok) throw new Error('Network response was not ok') const blob = await response.blob() const fileExtension = videoUrl.split('.').pop() ?? 'mp4' const fileName = `video-${Date.now()}.${fileExtension}` const url = window.URL.createObjectURL(blob) const a = document.createElement('a') a.href = url a.download = fileName document.body.appendChild(a) a.click() window.URL.revokeObjectURL(url) document.body.removeChild(a) toast.dismiss() toast.success('Video downloaded successfully') } catch { toast.dismiss() toast.error('Failed to download video') } } return (