'use client'; import React, { useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { MapPin, Factory, Zap, CheckCircle2, ArrowUpRight } from 'lucide-react'; import Image from 'next/image'; import Link from 'next/link'; import { AnimatedGlossyBorder } from '@/components/ui/AnimatedGlossyBorder'; import { Location, defaultLocations, minorLocations, projectLocations } from '@/lib/map-data'; import { standorteLocations } from '@/lib/standorte-data'; import { useLocale, useTranslations } from 'next-intl'; interface Stat { value: string; suffix?: string; label: string; href?: string; } interface InteractiveGermanyMapProps { badge?: string; title?: React.ReactNode; description?: string; stats?: Stat[]; locations?: Location[]; isHero?: boolean; hideStandorte?: boolean; } export function InteractiveGermanyMap({ badge, title, description, stats, locations = projectLocations, isHero = false, hideStandorte = false }: InteractiveGermanyMapProps) { const [activeLocation, setActiveLocation] = useState(null); const [hoverTimeout, setHoverTimeout] = useState(null); const handleMouseEnter = (loc: Location) => { if (hoverTimeout) clearTimeout(hoverTimeout); setActiveLocation(loc); }; const handleMouseLeave = () => { const timeout = setTimeout(() => { setActiveLocation(null); }, 200); setHoverTimeout(timeout); }; const locale = useLocale(); const t = useTranslations('InteractiveGermanyMap'); const tStandard = useTranslations('StandardPage'); const finalStats = stats || [ { value: '100', suffix: '%', label: locale === 'en' ? 'Nationwide Reach' : 'Überregionale Reichweite' }, { value: '3', suffix: '', label: locale === 'en' ? 'Operational Locations' : 'Operative Standorte', href: `/${locale}/standorte` }, ]; const finalBadge = badge || tStandard('badge'); // the map is mostly used with specific props, so we leave title & description to fallbacks if not provided const finalTitle = title || (locale === 'en' ? <>Nationwide
in operation for you. : <>Deutschlandweit
für Sie im Einsatz.); const finalDescription = description || (locale === 'en' ? 'From our strategic locations in Guben, Kirchheilingen and Bülstedt, we control and implement complex infrastructure projects nationwide.' : 'Von unseren strategischen Standorten in Guben, Kirchheilingen und Bülstedt steuern und realisieren wir komplexe Infrastrukturprojekte im gesamten Bundesgebiet.'); const finalLocations = React.useMemo(() => { if (hideStandorte) return locations; // Ensure the 3 standorte are always included, without duplicating if already present by ID const base = [...locations]; standorteLocations.forEach(sl => { if (!base.some(l => l.id === sl.id)) { base.push(sl as Location); } }); return base; }, [locations, hideStandorte]); return (
{/* Animated Border Glow (disabled in hero due to performance lag on 100vw) */} {!isHero && } {/* Background Effects */}
{/* Content Left */}
{finalBadge}
{isHero ? (

{finalTitle}

) : (

{finalTitle}

)}

{finalDescription}

{/* Industrial Stats Grid */}
{finalStats.map((stat, i) => { const StatCard = () => (
{stat.value}{stat.suffix}
{stat.label} {stat.href && }
); return stat.href ? ( ) : (
); })}
{/* Map Right */}
{/* Map Container - Enforce strict aspect ratio matching the SVG (1024x1024) */}
{/* Map SVG */}
{locale
{/* Minor Location Markers (The 100+ generic projects) */} {finalLocations.filter(l => l.type === 'minor_node').map((loc, idx) => (
handleMouseEnter(loc)} onMouseLeave={handleMouseLeave} onClick={() => handleMouseEnter(loc)} >
))} {/* Major Location Markers (HQ, Branch, Project) */} {finalLocations.filter(l => l.type !== 'minor_node').map((loc, idx) => { const isHQ = loc.type === 'hq'; const isBranch = loc.type === 'branch'; const isActive = activeLocation?.id === loc.id; return (
handleMouseEnter(loc)} onMouseLeave={handleMouseLeave} onClick={() => handleMouseEnter(loc)} > {/* Ping Animation for HQ / Branch */} {(isHQ || isBranch) && (
)} {/* Elegant Marker Dot */} {(isHQ || isBranch) && }
); })} {/* Global Tooltip */} {activeLocation && ( handleMouseEnter(activeLocation)} onMouseLeave={handleMouseLeave} >
{activeLocation.featuredImage && (
{activeLocation.name}
)}
{t(`types.${activeLocation.type === 'minor_node' ? 'project' : activeLocation.type}`)}
{activeLocation.name}
{activeLocation.type !== 'minor_node' ? (
{activeLocation.description}
) : (
{t(`descriptions.${['wind','pv','fiber','power','battery'].includes(activeLocation.description || '') ? activeLocation.description : 'default'}`)}
)} {(activeLocation.details || activeLocation.type === 'minor_node') && (
    {activeLocation.type === 'minor_node' ? ( <>
  • {t(`features.${['wind','pv','fiber','power','battery'].includes(activeLocation.description || '') ? activeLocation.description : 'default'}`)}
  • {t('features.method')}
  • ) : ( activeLocation.details?.map((detail, i) => (
  • {detail}
  • )) )}
)} {activeLocation.href && (activeLocation.type === 'hq' || activeLocation.type === 'branch') && ( e.stopPropagation()} > {t('learnMore')} )}
)}
); }