/**
 * A configuration object for a Markdown parser, to be used by the viewer and editor components.
 * This object maintains the necessary internal values for handling mentions within the Markdown parser.
 */
export class MarkdownParserMentionConfiguration {
    constructor(mentionInternals) {
        this.regexPattern = new RegExp(mentionInternals.pattern ?? '');
        this.mappingConfigs = mentionInternals.mappingConfigs;
        this.viewElement = mentionInternals.viewElement;
    }
    isValidMentionHref(mentionHref) {
        return this.regexPattern.test(mentionHref);
    }
    getDisplayName(mentionHref) {
        const mentionMapping = this.mappingConfigs?.get(mentionHref);
        const mentionId = this.extractMentionId(mentionHref);
        return mentionMapping?.displayName ?? mentionId;
    }
    extractMentionId(mentionHref) {
        const regexpArray = this.regexPattern.exec(mentionHref);
        // Matches and gets the first group specified in the regex pattern
        // that renders as an alternative to the display name if missing.
        return regexpArray?.[1] ?? undefined;
    }
}
//# sourceMappingURL=markdown-parser-mention-configuration.js.map