import { createLogger } from "../utils/logger/index.js";
import { init_logger } from "../utils/logger.js";
import { syncChannelPluginsFromManager } from "./plugins/registry.js";
//#region src/channels/plugin-registry.ts
init_logger();
const log = createLogger("ChannelPluginRegistry");
var ChannelPluginRegistry = class {
	plugins = /* @__PURE__ */ new Map();
	register(plugin) {
		if (this.plugins.has(plugin.id)) log.warn({ channel: plugin.id }, "Channel plugin already registered, overwriting");
		this.plugins.set(plugin.id, plugin);
		syncChannelPluginsFromManager(this.all());
		log.debug({ channel: plugin.id }, "Registered channel plugin");
	}
	get(id) {
		return this.plugins.get(id);
	}
	has(id) {
		return this.plugins.has(id);
	}
	all() {
		return Array.from(this.plugins.values());
	}
	ids() {
		return [...this.plugins.keys()];
	}
	entries() {
		return this.plugins.entries();
	}
	/** Plugin ids whose runtime currently reports connected (e.g. Telegram polling active). */
	runningChannelIds(cfg, isInitialized) {
		const out = [];
		for (const [id, plugin] of this.plugins) {
			if (!isInitialized(id)) continue;
			if (!plugin.channelIsRunning) continue;
			if (plugin.channelIsRunning(cfg)) out.push(id);
		}
		return out;
	}
};
//#endregion
export { ChannelPluginRegistry };

//# sourceMappingURL=plugin-registry.js.map