/**
 * Publisher registry ; maps channel string to PublisherPort instance.
 *
 * The orchestrator dispatches by `payload.platform` (X), `payload.channel`,
 * or the action_type (publish_article → rempart, send_cold_mail → email).
 * The registry centralizes that mapping.
 *
 * Registry stays in publishers/ since it is an orchestration concept,
 * not a port or adapter.
 *
 * @public
 */
const ACTION_TYPE_DEFAULT_CHANNEL = {
    publish_article: "rempart",
    send_cold_mail: "email",
    send_follow_up_mail: "email",
};
export function createPublisherRegistry(input) {
    const map = new Map();
    for (const [channel, pub] of Object.entries({
        x: input.x,
        email: input.email,
        discord: input.discord,
        github: input.github,
        rempart: input.rempart,
        linkedin: input.linkedin,
    })) {
        if (pub)
            map.set(channel, pub);
    }
    if (input.extras) {
        for (const [channel, pub] of Object.entries(input.extras)) {
            if (pub)
                map.set(channel, pub);
        }
    }
    return {
        get(channel) {
            return map.get(channel) ?? null;
        },
        pick(actionType, payload) {
            const explicit = payload && typeof payload["platform"] === "string"
                ? payload["platform"]
                : undefined;
            if (explicit) {
                return map.get(explicit) ?? null;
            }
            const channelFromAction = ACTION_TYPE_DEFAULT_CHANNEL[actionType];
            if (channelFromAction) {
                return map.get(channelFromAction) ?? null;
            }
            return null;
        },
        channels() {
            return Array.from(map.keys());
        },
    };
}
//# sourceMappingURL=registry.js.map