import { Play, Star, Clock, Calendar } from 'lucide-react'; const IMAGE_BASE_URL = 'https://phimimg.com'; const formatImageUrl = (url) => { if (!url) return ''; if (url.startsWith('http')) return url; const cleanUrl = url.startsWith('/') ? url : `/${url}`; return `${IMAGE_BASE_URL}${cleanUrl}`; }; export default function MovieCard({ movie }) { if (!movie) return null; const poster = formatImageUrl(movie.poster_url); const thumb = formatImageUrl(movie.thumb_url || movie.poster_url); const year = movie.year || (movie.modified?.time ? new Date(movie.modified.time).getFullYear() : ''); const quality = movie.quality || 'HD'; const lang = movie.lang?.toLowerCase() || 'vietsub'; const isVietsub = lang.includes('vietsub') || lang.includes('pđ') || lang.includes('phụ đề') || lang === 'vietsub'; const isThuyetMinh = lang.includes('thuyết minh') || lang.includes('tm'); const isSingle = movie.type === 'single' || movie.type === 'movie'; const epNum = movie.episode_current?.match(/\d+/)?.[0]; const isFull = movie.episode_current?.toLowerCase().includes('hoàn tất') || (movie.episode_current === movie.episode_total && movie.episode_total !== '1' && movie.episode_total !== undefined); const statusLabel = isFull ? 'Hoàn tất' : (epNum ? `Tập ${epNum}` : movie.episode_current); // Deterministic rating based on slug to avoid hydration mismatch const getRating = (slug) => { if (!slug) return "8.5"; let hash = 0; for (let i = 0; i < slug.length; i++) hash = slug.charCodeAt(i) + ((hash << 5) - hash); return (8.5 + (Math.abs(hash) % 15) / 10).toFixed(1); }; const rating = movie.tmdb?.vote_average || getRating(movie.slug); return (
${movie.name}
${movie.content?.replace(/<[^>]*>/g, '')}
`} >
{/* Main Background Image */} {movie.name} {/* Overlay Gradients */}
{/* Quality Badge (Top Left) */}
{quality}
{/* Rating Badge (Top Right) */}
{rating}
{year && ( {year} )}
{/* Small Poster Thumbnail Overlay (Bottom Left) */}
mini
{/* Bottom Status Badges (Vietsub | Thuyết Minh | Status) */}
{isVietsub && ( Vietsub )} {isThuyetMinh && ( Thuyết Minh )} {isSingle ? ( FULL ) : ( statusLabel && ( {statusLabel} ) )}

{movie.name}

{movie.origin_name}

{statusLabel && ( {statusLabel} )}
); }