import { ConversationLanguageResolver } from "../language/ConversationLanguageResolver";
import { INTERNAL_LANGUAGE } from "./InteractionInterceptor";
/**
 * Intercepts all messages from convey before they are sent and enrich the attributes with the conversation language
 */
var DefaultInteractionInterceptor = /** @class */ (function () {
    function DefaultInteractionInterceptor() {
        this.languageResolver = new ConversationLanguageResolver();
    }
    /**
     * It goes through all language providers to extract the conversation language and enrich the attributes of the interaction with it.
     * Should the attributes contain the language, this will not be modified.
     *
     * @param interaction ConveyInteraction
     */
    DefaultInteractionInterceptor.prototype.execute = function (interaction) {
        if (interaction["attributes"][INTERNAL_LANGUAGE] !== undefined) {
            console.log("Conversation language already in attributes with value: " + interaction["attributes"][INTERNAL_LANGUAGE]);
            return interaction;
        }
        var conversationLanguage = this.languageResolver.get();
        if (conversationLanguage === undefined) {
            console.error("No conversation language defined!!!!!");
        }
        interaction["attributes"][INTERNAL_LANGUAGE] = conversationLanguage;
        return interaction;
    };
    return DefaultInteractionInterceptor;
}());
export { DefaultInteractionInterceptor };
//# sourceMappingURL=DefaultInteractionInterceptor.js.map