// PRE-GENERATED (design session). Builds the active IAiEqProvider from AppSettings + stored key.
using DansoriEQ.Core.Ai;
using DansoriEQ.Core.Security;

namespace DansoriEQ.App.Ai;

public static class AiProviderFactory
{
    /// <summary>Returns the configured provider, or null if a cloud key is missing.</summary>
    public static IAiEqProvider? Create(ISecretStore store)
    {
        var s = AppSettings.Load();
        var provider = s.AiProvider ?? "claude";
        var model = s.AiModel;

        return provider switch
        {
            "openai" => store.Load(ProviderKeys.OpenAi) is { Length: > 0 } ok ? new OpenAiProvider(ok, model) : null,
            "gemini" => store.Load(ProviderKeys.Gemini) is { Length: > 0 } gk ? new GeminiProvider(gk, model) : null,
            "ollama" => new OllamaProvider(model ?? "phi3.5"),
            _ => store.Load(ProviderKeys.Claude) is { Length: > 0 } ck ? new ClaudeClient(ck, model) : null
        };
    }
}
