import { DEFAULT_COMPOSIO_STORE_ID, DEFAULT_NANGO_STORE_ID } from "./default-constants.js";
import { ComposioCredentialStore } from "./composio-store.js";
import { createKeyChainStore } from "./keychain-store.js";
import { InMemoryCredentialStore } from "./memory-store.js";
import { createNangoCredentialStore } from "./nango-store.js";

//#region src/credential-stores/defaults.ts
/**
* Create default credential stores based on environment variables
*/
function createDefaultCredentialStores() {
	const stores = [];
	stores.push(new InMemoryCredentialStore("memory-default"));
	if (process.env.NANGO_SECRET_KEY) stores.push(createNangoCredentialStore(DEFAULT_NANGO_STORE_ID, {
		apiUrl: process.env.NANGO_SERVER_URL || "https://api.nango.dev",
		secretKey: process.env.NANGO_SECRET_KEY
	}));
	if (process.env.COMPOSIO_API_KEY) stores.push(new ComposioCredentialStore(DEFAULT_COMPOSIO_STORE_ID));
	try {
		stores.push(createKeyChainStore("keychain-default"));
	} catch (error) {
		console.warn("Failed to create keychain store:", error instanceof Error ? error.message : error);
	}
	return stores;
}

//#endregion
export { createDefaultCredentialStores };