import type { Client as TypesenseClient } from 'typesense';

export interface PropertySearchDeps {
  typesenseClient: TypesenseClient;
  collectionName?: string;
}

export interface MarketAnalyticsDeps {
  typesenseClient: TypesenseClient;
  collectionName?: string;
}

export interface ValuationDeps {
  aiServiceBaseUrl: string;
}

export interface IndustrialParksDeps {
  typesenseClient: TypesenseClient;
  collectionName?: string;
  aiServiceBaseUrl: string;
}

export interface ReportsDeps {
  apiBaseUrl: string;
}

export interface McpServerConfig {
  name: string;
  version: string;
}

export interface PropertyComparisonResult {
  properties: PropertySummary[];
  comparison: {
    priceRange: { min: number; max: number; avg: number };
    areaRange: { min: number; max: number; avg: number };
    pricePerM2Range: { min: number; max: number; avg: number };
  };
}

export interface PropertySummary {
  listingId: string;
  title: string;
  propertyType: string;
  transactionType: string;
  priceVND: number;
  pricePerM2: number | null;
  areaM2: number;
  bedrooms: number | null;
  bathrooms: number | null;
  address: string;
  district: string;
  city: string;
}

export interface MarketReport {
  district: string;
  city: string;
  propertyType: string | null;
  totalListings: number;
  averagePriceVND: number;
  medianPriceVND: number;
  averagePricePerM2: number;
  averageArea: number;
  priceDistribution: { range: string; count: number }[];
}

export interface PriceTrend {
  district: string;
  city: string;
  period: string;
  dataPoints: { label: string; avgPrice: number; count: number }[];
}

export interface ValuationEstimate {
  estimatedPriceVND: number;
  confidence: number;
  pricePerM2: number;
  priceRangeLow: number;
  priceRangeHigh: number;
}

export interface IndustrialParkSummary {
  parkId: string;
  name: string;
  nameEn: string | null;
  developer: string;
  province: string;
  region: string;
  status: string;
  totalAreaHa: number;
  remainingAreaHa: number;
  occupancyRate: number;
  landRentUsdM2Year: number | null;
  rbfRentUsdM2Month: number | null;
  rbwRentUsdM2Month: number | null;
  targetIndustries: string[];
  tenantCount: number;
}

export interface FeatureExtractionResult {
  features: {
    area: number | null;
    district: string | null;
    city: string | null;
    propertyType: string | null;
    bedrooms: number | null;
    bathrooms: number | null;
    floors: number | null;
    frontage: number | null;
    roadWidth: number | null;
    priceMentioned: number | null;
    hasLegalPaper: boolean | null;
  };
  tokens: string[];
  entities: { text: string; label: string }[];
}
