import { MockupMarketIntelligenceProvider } from '../provider/MockupMarketIntelligenceProvider'
import type { MarketSignal, MarketSignalFilters, SignalProcessingStatus } from '../domain/marketSignal'
import type { ListResponse, ItemResponse } from './types'

const provider = MockupMarketIntelligenceProvider

export const marketIntelligenceService = {
  async getSignals(filters?: MarketSignalFilters): Promise<ListResponse<MarketSignal>> {
    const data = await provider.getSignals(filters)
    return { data, meta: { total: data.length, page: 1, pageSize: data.length, hasMore: false } }
  },

  async getSignalDetail(id: string): Promise<ItemResponse<MarketSignal | null>> {
    const data = await provider.getSignalById(id)
    return { data }
  },

  async updateSignalStatus(
    id: string,
    status: SignalProcessingStatus,
  ): Promise<ItemResponse<MarketSignal>> {
    const data = await provider.updateSignalStatus(id, status)
    return { data }
  },

  async convertToFutureSignal(
    id: string,
  ): Promise<ItemResponse<{ futureSignalId: string }>> {
    const data = await provider.convertToFutureSignal(id)
    return { data }
  },

  async linkSignalToEntity(
    id: string,
    entityType: 'property' | 'need',
    entityId: string,
  ): Promise<ItemResponse<MarketSignal>> {
    const data = await provider.linkSignalToEntity(id, entityType, entityId)
    return { data }
  },
}
