/**
 * Parallel fetch of the four dictionary endpoints.
 *
 * Paths match the Angular `NetworkService.getDictionary` pattern:
 * `/dictionary/1/{name}`. Locale is not part of the path; the server
 * returns all titles as a `Record<lang, string>` and the consumer picks.
 */

import type { ApiClient } from "@/shared/api/client.js";
import type {
  IRawDictionaries,
  IRawRegion,
  IRawCountry,
  IRawCity,
  IRawAirport,
} from "./types.js";

export async function fetchDictionaries(
  client: ApiClient,
): Promise<IRawDictionaries> {
  const [regions, countries, cities, airports] = await Promise.all([
    client.get<IRawRegion[]>("dictionary/1/world_regions"),
    client.get<IRawCountry[]>("dictionary/1/countries"),
    client.get<IRawCity[]>("dictionary/1/cities"),
    client.get<IRawAirport[]>("dictionary/1/airports"),
  ]);

  return { regions, countries, cities, airports };
}
