/**
 * Helper class for the nimble rich text components to validate that the configuration
 * is valid and report which aspects of the configuration are valid or invalid.
 */
export class RichTextValidator {
    constructor() {
        this.invalidMentionConfiguration = false;
        this.duplicateMentionConfiguration = false;
    }
    getValidity() {
        return {
            invalidMentionConfiguration: this.invalidMentionConfiguration,
            duplicateMentionConfiguration: this.duplicateMentionConfiguration
        };
    }
    isValid() {
        return Object.values(this.getValidity()).every(x => !x);
    }
    validate(mentions) {
        this.validateDuplicateMentionConfigurations(mentions);
        this.validateMentionConfigurations(mentions);
    }
    validateMentionConfigurations(mentions) {
        this.invalidMentionConfiguration = mentions.some(x => !x.mentionInternals.validator.isValid());
        return !this.invalidMentionConfiguration;
    }
    validateDuplicateMentionConfigurations(mentions) {
        const mentionChars = mentions.map(mention => mention.mentionInternals.character);
        this.duplicateMentionConfiguration = mentionChars.length !== new Set(mentionChars).size;
        return !this.duplicateMentionConfiguration;
    }
}
//# sourceMappingURL=rich-text-validator.js.map