'use client'; import { Button } from '@/components/ui/Button'; import Image from 'next/image'; import { useState, useEffect } from 'react'; import { usePathname } from 'next/navigation'; interface HeroVideoProps { data?: any; title?: string; subtitle?: string; description?: string; videoUrl?: string; posterImage?: any; backgroundImage?: any; ctaLabel?: string; ctaHref?: string; linkText?: string; linkHref?: string; secondaryCtaLabel?: string; secondaryCtaHref?: string; badge?: string; } import placeholders from '@/lib/placeholders.json'; export function HeroVideo(props: HeroVideoProps) { const { data } = props; const title = props.title || data?.title || 'DIE EXPERTEN FÜR KABELNETZBAU'; const subtitle = props.subtitle || props.description || data?.subtitle || 'Wir verbinden Infrastruktur mit Präzision. Von Horizontalbohrungen bis zu komplexen Leitungsnetzen.'; const explicitNoVideo = props.videoUrl === 'none' || props.videoUrl === ''; const videoUrl = explicitNoVideo ? null : (props.videoUrl || data?.videoUrl || '/assets/dummy-hero.mp4'); const pathname = usePathname(); let defaultPoster = "/assets/photos/DJI_0048.JPG"; if (videoUrl && videoUrl.endsWith('.mp4')) { defaultPoster = videoUrl.replace('.mp4', '-poster.webp'); } const posterSrc = props.backgroundImage?.url || props.posterImage?.url || data?.posterImage?.url || defaultPoster; const posterAlt = props.backgroundImage?.alt || data?.posterImage?.alt || "E-TIB Gruppe Baustelle"; const ctaLabel = props.ctaLabel || props.linkText || data?.ctaLabel || 'Unternehmen entdecken'; const ctaHref = props.ctaHref || props.linkHref || data?.ctaHref || '#unternehmen'; const currentLocale = pathname?.startsWith('/en') ? 'en' : 'de'; const secondaryCtaLabel = props.secondaryCtaLabel || data?.secondaryCtaLabel || (currentLocale === 'de' ? 'Projekt anfragen' : 'Inquire Project'); const secondaryCtaHref = props.secondaryCtaHref || data?.secondaryCtaHref || `/${currentLocale}/contact`; const [videoSrcLoaded, setVideoSrcLoaded] = useState(false); useEffect(() => { let interactionTriggered = false; const handleInteraction = () => { if (interactionTriggered) return; interactionTriggered = true; setVideoSrcLoaded(true); // Cleanup listeners ['scroll', 'mousemove', 'touchstart', 'keydown'].forEach((event) => window.removeEventListener(event, handleInteraction) ); }; // Listen for any user interaction ['scroll', 'mousemove', 'touchstart', 'keydown'].forEach((event) => window.addEventListener(event, handleInteraction, { passive: true, once: true }) ); return () => { ['scroll', 'mousemove', 'touchstart', 'keydown'].forEach((event) => window.removeEventListener(event, handleInteraction) ); }; }, []); return (
{/* Fast compositing layer to replace the heavy CSS filters on the image */}
{/* Render video on top if available, but defer src to avoid blocking LCP */}
{videoUrl && (
)}
{/* Cinematic Color Grading Overlay */}
{/* Dramatic Vignette & Fade to content */}
{/* Top Fade for Header Navigation Readability */}
{subtitle}