import type { LeadIngestionSource } from '@/types/entities';
import { daysAgo } from './factories';

function minutesAgo(m: number): string {
    const d = new Date();
    d.setMinutes(d.getMinutes() - m);
    return d.toISOString();
}

function hoursAgo(h: number): string {
    const d = new Date();
    d.setHours(d.getHours() - h);
    return d.toISOString();
}

export const mockIngestionSources: LeadIngestionSource[] = [
    {
        id: 'source-1',
        createdAt: daysAgo(90),
        sourceName: 'Facebook Lead Ads',
        platform: 'FACEBOOK',
        integrationStatus: 'ACTIVE',
        lastSuccessfulSyncAt: minutesAgo(10),
        lastFailureAt: null,
        leadsReceivedLast24h: 24,
        consecutiveFailures: 0,
        authStatus: 'VALID',
        webhookUrl: 'https://api.helixengage.in/webhooks/facebook-leads',
        lastErrorMessage: null,
    },
    {
        id: 'source-2',
        createdAt: daysAgo(75),
        sourceName: 'Instagram Lead Ads',
        platform: 'INSTAGRAM',
        integrationStatus: 'ACTIVE',
        lastSuccessfulSyncAt: minutesAgo(15),
        lastFailureAt: null,
        leadsReceivedLast24h: 9,
        consecutiveFailures: 0,
        authStatus: 'VALID',
        webhookUrl: 'https://api.helixengage.in/webhooks/instagram-leads',
        lastErrorMessage: null,
    },
    {
        id: 'source-3',
        createdAt: daysAgo(60),
        sourceName: 'Google Search Ads',
        platform: 'GOOGLE_ADS',
        integrationStatus: 'WARNING',
        lastSuccessfulSyncAt: hoursAgo(2),
        lastFailureAt: hoursAgo(1.5),
        leadsReceivedLast24h: 18,
        consecutiveFailures: 3,
        authStatus: 'VALID',
        webhookUrl: 'https://api.helixengage.in/webhooks/google-ads',
        lastErrorMessage: 'API rate limit exceeded — retry scheduled in 45 minutes',
    },
    {
        id: 'source-4',
        createdAt: daysAgo(45),
        sourceName: 'Google My Business',
        platform: 'GOOGLE_MY_BUSINESS',
        integrationStatus: 'ACTIVE',
        lastSuccessfulSyncAt: minutesAgo(30),
        lastFailureAt: null,
        leadsReceivedLast24h: 3,
        consecutiveFailures: 0,
        authStatus: 'EXPIRING_SOON',
        webhookUrl: null,
        lastErrorMessage: null,
    },
    {
        id: 'source-5',
        createdAt: daysAgo(120),
        sourceName: 'Website Forms',
        platform: 'WEBSITE',
        integrationStatus: 'ACTIVE',
        lastSuccessfulSyncAt: minutesAgo(5),
        lastFailureAt: null,
        leadsReceivedLast24h: 5,
        consecutiveFailures: 0,
        authStatus: 'VALID',
        webhookUrl: 'https://api.helixengage.in/webhooks/website-forms',
        lastErrorMessage: null,
    },
    {
        id: 'source-6',
        createdAt: daysAgo(30),
        sourceName: 'WhatsApp Business API',
        platform: 'WHATSAPP',
        integrationStatus: 'ERROR',
        lastSuccessfulSyncAt: hoursAgo(18),
        lastFailureAt: hoursAgo(0.5),
        leadsReceivedLast24h: 0,
        consecutiveFailures: 8,
        authStatus: 'EXPIRED',
        webhookUrl: 'https://api.helixengage.in/webhooks/whatsapp',
        lastErrorMessage: 'Authentication token expired — re-authorization required in Meta Business Manager',
    },
];
