const PROVIDER_ID_FAMILIES = [
    [/^(anthropic|claude)$/i, 'claude'],
    [/^(openai|codex)$/i, 'openai'],
    [/^(xai|x-ai|grok)$/i, 'xai'],
    [/^composer$/i, 'composer'],
    [/^(glm|zai|zhipu)$/i, 'glm'],
];
const VALUE_FAMILIES = [
    [/\b(claude|sonnet|opus|haiku|fable)\b/i, 'claude'],
    [/\b(gpt|openai|codex|o[1-9])[-\w.]*\b/i, 'openai'],
    [/\b(grok|xai|x-ai)\b/i, 'xai'],
    [/\bcomposer\b/i, 'composer'],
    [/\bglm\b/i, 'glm'],
];
function normalize(value) {
    return typeof value === 'string' ? value.trim() : '';
}
function firstMatchingFamily(value, patterns) {
    for (const [pattern, family] of patterns) {
        if (pattern.test(value)) {
            return family;
        }
    }
    return undefined;
}
export function classifyModelFamily(input) {
    const providerId = normalize(input?.providerId);
    const providerFamily = firstMatchingFamily(providerId, PROVIDER_ID_FAMILIES);
    if (providerFamily) {
        return providerFamily;
    }
    const value = normalize(input?.value);
    return firstMatchingFamily(value, VALUE_FAMILIES) ?? 'unknown';
}
