import { listChannelPlugins } from "../../channels/plugins/index.js";
import { dingtalkConnectorOnboardingAdapter } from "./dingtalk-connector.js";
import { openclawWeixinOnboardingAdapter } from "./openclaw-weixin.js";
import { wecomConnectorOnboardingAdapter } from "./wecom-connector.js";
import { qqbotOnboardingAdapter } from "./qqbot.js";
// Core onboarding adapters for channels whose official plugins do not provide
// their own onboarding adapter (or may not be loaded at configure time).
const CORE_ONBOARDING_ADAPTERS = new Map([
    ["dingtalk-connector", dingtalkConnectorOnboardingAdapter],
    ["wecom", wecomConnectorOnboardingAdapter],
    ["openclaw-weixin", openclawWeixinOnboardingAdapter],
    ["qqbot", qqbotOnboardingAdapter],
]);
const CHANNEL_ONBOARDING_ADAPTERS = () => {
    const pluginAdapters = new Map(listChannelPlugins()
        .map((plugin) => plugin.onboarding ? [plugin.id, plugin.onboarding] : null)
        .filter((entry) => Boolean(entry)));
    // Merge: plugin adapters take precedence over core fallbacks
    const merged = new Map(CORE_ONBOARDING_ADAPTERS);
    for (const [id, adapter] of pluginAdapters) {
        merged.set(id, adapter);
    }
    return merged;
};
export function getChannelOnboardingAdapter(channel) {
    return CHANNEL_ONBOARDING_ADAPTERS().get(channel);
}
export function listChannelOnboardingAdapters() {
    return Array.from(CHANNEL_ONBOARDING_ADAPTERS().values());
}
// Legacy aliases (pre-rename).
export const getProviderOnboardingAdapter = getChannelOnboardingAdapter;
export const listProviderOnboardingAdapters = listChannelOnboardingAdapters;
