import { getLogger } from "../utils/logger.js";

//#region src/credential-stores/CredentialStoreRegistry.ts
/**
* Registry for managing credential stores in the application context
* Provides methods to register, retrieve, and manage credential stores
*/
var CredentialStoreRegistry = class {
	stores = /* @__PURE__ */ new Map();
	logger = getLogger("credential-store-registry");
	constructor(initialStores = []) {
		for (const store of initialStores) this.add(store);
	}
	/**
	* Add a credential store to the registry
	*/
	add(store) {
		if (this.stores.has(store.id)) this.logger.warn({ storeId: store.id }, `Credential store ${store.id} already registered, replacing`);
		this.stores.set(store.id, store);
		this.logger.info({
			storeId: store.id,
			storeType: store.type
		}, `Registered credential store: ${store.id} (type: ${store.type})`);
	}
	/**
	* Get a credential store by ID
	*/
	get(id) {
		return this.stores.get(id);
	}
	/**
	* Get all registered credential stores
	*/
	getAll() {
		return Array.from(this.stores.values());
	}
	/**
	* Get all credential store IDs
	*/
	getIds() {
		return Array.from(this.stores.keys());
	}
	/**
	* Check if a credential store is registered
	*/
	has(id) {
		return this.stores.has(id);
	}
	/**
	* Remove a credential store
	*/
	remove(id) {
		const removed = this.stores.delete(id);
		if (removed) this.logger.info({ id }, `Removed credential store: ${id}`);
		return removed;
	}
	/**
	* Get the number of registered stores
	*/
	size() {
		return this.stores.size;
	}
};

//#endregion
export { CredentialStoreRegistry };