import { CorpConfig } from "./types"; export class CorpContext { private current: CorpConfig | null = null; private corps: Map = new Map(); constructor(corps: CorpConfig[]) { for (const corp of corps) { this.corps.set(corp.id, corp); } if (corps.length > 0) { this.current = corps[0]; } } getCurrent(): CorpConfig | null { return this.current; } switchCorp(corpId: string): boolean { const corp = this.corps.get(corpId); if (!corp) return false; this.current = corp; return true; } listCorps(): Array<{ id: string; name: string; current: boolean }> { return Array.from(this.corps.values()).map((corp) => ({ id: corp.id, name: corp.name, current: corp.id === this.current?.id, })); } }