// Copyright: © 2026 TWWIM UG. All rights reserved. (www.twwim.com)
/**
* Right-hand visitor context pane — Intercom / Zendesk / Gorgias convention.
* Holds everything the operator needs without leaving the transcript:
* identity, session timeline, device, geo, cart value, page trail.
*/
import { Globe, Monitor, Smartphone, Tablet, MapPin, ShoppingCart, Repeat, Sparkles, Link as LinkIcon } from 'lucide-react';
import { useTranslation } from '@/i18n/TranslationProvider';
import type { ConversationDetail as ConvDetail } from '../lib/types';
import { VisitorAvatar } from './VisitorAvatar';
import { CapturedContactBlock } from './CapturedContactBlock';
interface VisitorContextPanelProps {
conversation: ConvDetail;
}
function DeviceIcon({ device }: { device: ConvDetail['device'] }) {
if (device === 'mobile') return ;
if (device === 'tablet') return ;
return ;
}
function relativeDate(date: Date | string, locale: string): string {
const d = typeof date === 'string' ? new Date(date) : date;
const diffMs = Date.now() - d.getTime();
const minutes = Math.floor(diffMs / 60_000);
if (minutes < 60) return locale === 'de' ? `vor ${minutes} Min.` : `${minutes} min ago`;
const hours = Math.floor(minutes / 60);
if (hours < 24) return locale === 'de' ? `vor ${hours} Std.` : `${hours} h ago`;
const days = Math.floor(hours / 24);
if (days < 30) return locale === 'de' ? `vor ${days} Tagen` : `${days} d ago`;
const months = Math.floor(days / 30);
return locale === 'de' ? `vor ${months} Mon.` : `${months} mo ago`;
}
function formatMoney(cents: number, currency: string, locale: string): string {
return new Intl.NumberFormat(locale === 'de' ? 'de-DE' : 'en-GB', { style: 'currency', currency }).format(cents / 100);
}
export function VisitorContextPanel({ conversation }: VisitorContextPanelProps) {
const { t, locale } = useTranslation();
const pages = conversation.pageTrail.map((v) => v.url);
return (
);
}
function Section({ title, children }: { title: string; children: React.ReactNode }) {
return (
);
}
function Row({ label, value }: { label: string; value: React.ReactNode }) {
return (
{label}
{value}
);
}