/**
 * route-state.impl.ts
 * Implementación en memoria de RouteStateRepository.
 */

import type {
  RouteState,
  RouteStateRepository,
} from "../../domain/repositories/route-state.repository.js";

export class InMemoryRouteStateRepository implements RouteStateRepository {
  private readonly states = new Map<string, RouteState>();

  async get(routeId: string): Promise<RouteState | null> {
    return this.states.get(routeId) ?? null;
  }

  async set(state: RouteState): Promise<void> {
    this.states.set(state.routeId, state);
  }

  async getAll(): Promise<RouteState[]> {
    return Array.from(this.states.values());
  }

  /** Helper para reset de demo. */
  async clearAll(): Promise<void> {
    this.states.clear();
  }
}
