import { Injectable } from '@angular/core';
import { Observable, of } from 'rxjs';
import { Connector, DeadLetterEntry } from '../models/connector.model';
import { ConnectorGateway } from './connector-gateway.interface';

/**
 * No connector exists in real life yet (Sprint 0.1: no fixed partner list -
 * connectors onboard as partners arrive). Seeded with zero rows, ready to
 * light up as soon as an admin onboards the first real connector via
 * docs/backend/PHASE-4-CONNECTOR-FRAMEWORK-CONTRACT.md §7.
 */
@Injectable({ providedIn: 'root' })
export class ConnectorLocalGateway implements ConnectorGateway {
  private connectors: Connector[] = [];

  loadConnectors(): Observable<Connector[]> {
    return of(this.connectors);
  }

  loadDeadLetter(_connectorId: string): Observable<DeadLetterEntry[]> {
    return of([]);
  }

  replay(_connectorId: string, _deadLetterId: string): Observable<void> {
    return of(void 0);
  }

  pause(connectorId: string): Observable<void> {
    this.connectors = this.connectors.map(c => c.id === connectorId ? { ...c, status: 'paused' } : c);
    return of(void 0);
  }

  resume(connectorId: string): Observable<void> {
    this.connectors = this.connectors.map(c => c.id === connectorId ? { ...c, status: 'active' } : c);
    return of(void 0);
  }
}
