import type { Need } from '../../../domain/need'
import type { Property } from '../../../domain/property'
import { AssetType, ResultType, AvailabilityStatus, FreshnessStatus } from '../../../domain/enums'
import { DEFAULT_SCORING_PROFILES } from '../../../domain/scoring'

// ── Minimal valid Need ────────────────────────────────────────────────────────
// earliestMoveIn is set to a past date so timing calculations are stable
// regardless of when tests run.

export function makeNeed(overrides: Partial<Need> = {}): Need {
  return {
    id: 'need-1',
    companyName: 'TestCo AG',
    assetType: AssetType.OFFICE,
    requiredArea: { min: 200, max: 400 },
    preferredLocations: ['Zürich'],
    budgetRange: { maxPerSqm: 50, currency: 'CHF' },
    timing: {
      earliestMoveIn: '2024-01-01',  // always in the past
      latestMoveIn: '2027-12-31',
      flexibleTiming: false,
    },
    weightingProfile: { ...DEFAULT_SCORING_PROFILES.OFFICE },
    confidenceInCriteria: 0.9,
    createdAt: '2025-01-01T00:00:00Z',
    updatedAt: '2025-01-01T00:00:00Z',
    ...overrides,
  } as Need
}

// ── Minimal valid Property ────────────────────────────────────────────────────
// All softFactor fields are filled so scoreSoftFactor never calls the
// enrichment service — keeping tests hermetic and fast.

export function makeProperty(overrides: Partial<Property> = {}): Property {
  return {
    id: 'prop-1',
    title: 'Testbüro Zürich',
    assetType: AssetType.OFFICE,
    resultType: ResultType.VERIFIED_PORTFOLIO,
    location: { city: 'Zürich', district: 'Kreis 1', country: 'CH' },
    address: {
      street: 'Bahnhofstrasse',
      houseNumber: '1',
      postalCode: '8001',
      city: 'Zürich',
      country: 'CH',
    },
    areaSqm: 300,
    rentPricePerSqm: 40,
    availabilityDate: '2025-03-01',
    availabilityStatus: AvailabilityStatus.AVAILABLE_NOW,
    sourceType: 'ERP_IMPORT',
    confidenceScore: 0.85,
    dataQuality: {
      score: 0.85,
      freshness: FreshnessStatus.FRESH,
      missingCriticalFields: [],
      missingOptionalFields: [],
      warnings: [],
    },
    // All 9 soft factors provided → enrichment service is never called
    softFactors: {
      prestige: 75,
      accessibility: 80,
      expansionPotentialScore: 60,
      flexibilityScore: 70,
      visibilityScore: 65,
      footfallScore: 50,
      talentAccess: 80,
      esgScore: 60,
      taxEnvironmentScore: 70,
    },
    createdAt: '2025-01-01T00:00:00Z',
    updatedAt: '2025-01-01T00:00:00Z',
    ...overrides,
  } as Property
}
