/**
 * SystemStore — plantilla base.
 * En Anexo76 manejaba sistemas SCAF/SCAII. En la plantilla es un stub.
 * Implementa tu propia lógica de sistemas/módulos si la necesitas.
 */

export type SystemType = string;

class SystemStore {
	_activeSystem = $state<SystemType | null>(null);
	_allowedSystems = $state<SystemType[]>([]);

	get activeSystem() { return this._activeSystem; }
	get allowedSystems() { return this._allowedSystems; }
	get canSwitch() { return this._allowedSystems.length > 1; }
	get activeLabel() { return null; }

	initialize(allowedSystems: SystemType[], cookieValue: string | null) {
		this._allowedSystems = allowedSystems;
		this._activeSystem = cookieValue ?? allowedSystems[0] ?? null;
	}

	async setActiveSystem(system: SystemType): Promise<boolean> {
		this._activeSystem = system;
		return true;
	}

	clear() {
		this._activeSystem = null;
		this._allowedSystems = [];
	}
}

export const systemStore = new SystemStore();
