import { createClient as createVendoClient } from "db-vendo-client"; import { profile as dbnavProfile } from "db-vendo-client/p/dbnav/index.js"; const clients = {}; let createHafasClient; export let client; export const initHafasClient = async profileName => { client = await getHafasClient(profileName); }; export const getHafasClient = async profileName => { if (!clients[profileName]) { let profile; switch(profileName) { case "db": clients[profileName] = createVendoClient(dbnavProfile, "trainsearch", {enrichStations: false}); console.info("initialized vendo client"); return clients[profileName]; case "bvg": const { profile: bvgProfile } = await import('hafas-client/p/bvg/index.js'); profile = bvgProfile; break; case "nahsh": const { profile: nahshProfile } = await import('hafas-client/p/nahsh/index.js'); profile = nahshProfile; break; case "rmv": const { profile: rmvProfile } = await import('hafas-client/p/rmv/index.js'); profile = rmvProfile; break; case "vrn": const { profile: vrnProfile } = await import('hafas-client/p/vrn/index.js'); profile = vrnProfile; break; case "oebb": const { profile: oebbProfile } = await import('hafas-client/p/oebb/index.js'); profile = oebbProfile; break; default: throw "Unknown profile name: " + profileName; } if (!createHafasClient) createHafasClient = (await import("hafas-client")).createClient; clients[profileName] = createHafasClient(profile, "trainsearch"); } console.info("initialized hafas client with profile " + profileName); return clients[profileName]; }