package llm

import "strings"

// Route maps a model string to its provider. Pure function.
func Route(model string) ProviderID {
	switch {
	case model == "claude-code" || strings.HasPrefix(model, "claude-code/"):
		return ProviderClaudeCode
	case strings.HasPrefix(model, "claude"):
		return ProviderAnthropic
	case strings.HasPrefix(model, "gpt"), strings.HasPrefix(model, "o1"), strings.HasPrefix(model, "o3"):
		return ProviderOpenAI
	case strings.HasPrefix(model, "ollama/"):
		return ProviderOllama
	default:
		return ProviderOpenAI
	}
}

// ModelName strips the provider prefix from a model string.
func ModelName(model string) string {
	if after, ok := strings.CutPrefix(model, "ollama/"); ok {
		return after
	}
	return model
}
