import { memo } from 'react' import { Box, Button, Divider, Typography } from '@mui/material' import { AlertCircle, CheckCircle2, ShieldCheck } from 'lucide-react' import { useNavigate } from 'react-router' import { getScoreTier, SCORE_THEME } from '../shared/scoreTheme' import { floorLabel, SOURCE_META, ASSET_TYPE_LABELS, getOpportunityHeadline } from './futureAvailabilityCardHelpers' import { SignalQualityDots } from './SignalQualityDots' import { DS_COLORS, DS_TEXT, DS_SURFACE, DS_BORDER } from '../../lib/ds' import type { MatchCardViewModel } from './MatchCardViewModel' // ── Future Availability Card ────────────────────────────────────────────────── export const FutureAvailabilityCard = memo(function FutureAvailabilityCard({ vm }: { vm: MatchCardViewModel }) { const isControlled = vm.signalIsControlled ?? false const navigate = useNavigate() const cardColors = isControlled ? DS_COLORS.futureCard.controlled : DS_COLORS.futureCard.signal const accentColor = cardColors.accent const headerBg = cardColors.headerBg const borderColor = cardColors.border const badgeBg = cardColors.badgeBg const badgeColor = cardColors.badgeText const assetLabel = vm.assetType ? (ASSET_TYPE_LABELS[vm.assetType] ?? vm.assetType) : 'Fläche' const headline = getOpportunityHeadline(vm.signalType, assetLabel) const sourceMeta = vm.signalSourceType ? (SOURCE_META[vm.signalSourceType] ?? null) : null const tier = getScoreTier(vm.matchScore) const theme = SCORE_THEME[tier] return ( {/* ── Data header ─────────────────────────────────────────────────────── */} {/* Asset type · location + badge */} {assetLabel.toUpperCase()} · {vm.locationLabel?.split(',')[0]?.toUpperCase() ?? ''} {isControlled && } {isControlled ? 'PRE-MARKET VERIFIED' : 'MARKET SIGNAL'} {/* Opportunity headline */} {headline} {/* Key facts */} {vm.signalAreaSqmEstimate ? ( {isControlled ? '' : '~'}{vm.signalAreaSqmEstimate.toLocaleString('de-CH')} m² ) : null} {vm.availabilityLabel && ( {vm.availabilityLabel} )} {/* Source attribution */} {isControlled ? ( Direkte Verwaltungsquelle ) : sourceMeta ? ( {sourceMeta.icon} {sourceMeta.label} ) : null} {/* ── Score + signal quality strip ────────────────────────────────────── */} {vm.matchScore}% {!isControlled && vm.signalProbability !== undefined && ( {Math.round(vm.signalProbability * 100)}% Signalw. )} {/* ── Card body ───────────────────────────────────────────────────────── */} {/* MARKET SIGNAL: probabilistic notice */} {!isControlled && ( Probabilistischer Marktindikator — kein bestätigtes Objekt. Dient als strategischer Frühindikator. )} {/* PRE-MARKET VERIFIED: confirmed facts */} {isControlled && (vm.signalConfirmedFacts?.length ?? 0) > 0 && ( {(vm.signalConfirmedFacts ?? []).slice(0, 3).map((fact, i) => ( {fact} ))} )} {/* PRE-MARKET VERIFIED: specific unit info */} {isControlled && vm.preMarketUnit && ( Freigegebene Einheit {floorLabel(vm.preMarketUnit.floorLevel)}{vm.preMarketUnit.unitLabel ? ` · ${vm.preMarketUnit.unitLabel}` : ''} {vm.preMarketUnit.areaSqm.toLocaleString('de-CH')} m² {vm.preMarketUnit.schattenmarktRelease?.availableFrom && ( ab {new Date(vm.preMarketUnit.schattenmarktRelease.availableFrom).toLocaleDateString('de-CH', { month: 'short', year: 'numeric' })} )} )} {/* MARKET SIGNAL: market indicators */} {!isControlled && (vm.signalMarketIndicators?.length ?? 0) > 0 && ( Erkannte Marktindikatoren {(vm.signalMarketIndicators ?? []).slice(0, 3).map((ind, i) => ( {ind} ))} )} {/* Why relevant — match reasons */} {vm.reasons.length > 0 && ( <> Warum relevant für Ihre Suche? {vm.reasons.slice(0, 3).map((r, i) => ( {r.label} {r.explanation} ))} )} {/* Actions */} {vm.actions.map(a => ( ))} {isControlled && vm.propertyId && ( )} {/* Disclaimer footnote */} {vm.disclaimer && ( {vm.disclaimer} )} ) })