/**
 * Shared helpers for scoring copy against the configured brand voice profile.
 * Used by co-author, SEO generation, and the fix endpoint.
 */
import { ensureBrandVoiceDocument } from './brand-voice-document.js';
import { parseStructuredProfile, scoreBrandAlignment, } from './brand-voice-structured.js';
const SCORE_CONTENT_MAX = 10_000;
/** Map SEO field slugs to structured channel ids when scoring generated meta copy. */
export function seoFieldToBrandChannel(field) {
    if (field === 'metaDescription' || field === 'ogDescription')
        return 'meta_description';
    return undefined;
}
/** Default channel for long-form editor copy (co-author). */
export const COAUTHOR_BRAND_CHANNEL = 'blog';
export function hasBrandVoiceForScoring(profile) {
    if (!profile)
        return false;
    if (profile.document?.trim())
        return true;
    if (profile.tone?.trim())
        return true;
    if (profile.guidelines?.trim())
        return true;
    return false;
}
/**
 * Score content against the stored profile. Returns null when no profile is
 * configured or the requested channel is unknown.
 */
export function alignContentWithBrandVoice(content, profile, channel) {
    if (!hasBrandVoiceForScoring(profile))
        return null;
    const document = ensureBrandVoiceDocument(profile);
    const structured = parseStructuredProfile(document);
    const allowedChannels = new Set(structured.channels.map((c) => c.id));
    const safeChannel = channel && allowedChannels.has(channel) ? channel : undefined;
    return scoreBrandAlignment(content.slice(0, SCORE_CONTENT_MAX), structured, safeChannel);
}
//# sourceMappingURL=brand-voice-alignment.js.map