// Mock demand-heat data per property.
// In production: aggregated from cross-user pipeline additions, search impressions, and view counts.

export interface PropertyHeat {
  searchCount:  number  // distinct active needs that matched this property
  pipelineCount: number // pipeline entries across all users
  viewCount:    number  // total detail-page opens
}

export const PROPERTY_HEAT: Record<string, PropertyHeat> = {
  'prop-001': { searchCount: 7, pipelineCount: 4, viewCount: 52 },
  'prop-007': { searchCount: 5, pipelineCount: 3, viewCount: 38 },
  'prop-043': { searchCount: 9, pipelineCount: 2, viewCount: 61 },
  'prop-012': { searchCount: 4, pipelineCount: 3, viewCount: 29 },
  'prop-015': { searchCount: 6, pipelineCount: 2, viewCount: 44 },
  'prop-003': { searchCount: 3, pipelineCount: 2, viewCount: 21 },
  'prop-042': { searchCount: 4, pipelineCount: 1, viewCount: 33 },
  'prop-044': { searchCount: 8, pipelineCount: 2, viewCount: 57 },
  'prop-040': { searchCount: 5, pipelineCount: 2, viewCount: 31 },
  'prop-002': { searchCount: 3, pipelineCount: 2, viewCount: 18 },
}

export type HeatLevel = 'HOT' | 'VERY_HOT' | null

export function getHeatLevel(propertyId: string | undefined): HeatLevel {
  if (!propertyId) return null
  const h = PROPERTY_HEAT[propertyId]
  if (!h) return null
  if (h.pipelineCount >= 3 || h.searchCount >= 7) return 'VERY_HOT'
  if (h.pipelineCount >= 2 || h.searchCount >= 4) return 'HOT'
  return null
}

export function heatTooltip(propertyId: string): string {
  const h = PROPERTY_HEAT[propertyId]
  if (!h) return ''
  const parts: string[] = []
  if (h.searchCount > 0) parts.push(`${h.searchCount} aktive Suchen`)
  if (h.pipelineCount > 0) parts.push(`${h.pipelineCount}× in Pipeline`)
  if (h.viewCount > 0) parts.push(`${h.viewCount} Aufrufe`)
  return parts.join(' · ')
}
