import { createGoogleGenerativeAI } from "@ai-sdk/google";
const DEFAULT_MODEL = "gemini-3-flash";
const DEFAULT_MODELS = [
  {
    id: "gemini-3-flash",
    name: "Gemini 3 Flash",
    contextWindow: 1048576,
    tags: ["budget"]
  },
  {
    id: "gemini-3-pro",
    name: "Gemini 3 Pro",
    contextWindow: 1048576,
    tags: ["flagship"]
  }
];
function createGoogleAdapter() {
  const envKeys = ["GOOGLE_GENERATIVE_AI_API_KEY", "OPENCODE_GOOGLE_API_KEY"];
  function resolveApiKey(env) {
    const lookup = env ?? process.env;
    for (const key of envKeys) {
      const value = lookup[key];
      if (typeof value === "string") {
        const trimmed = value.trim();
        if (trimmed.length > 0) return trimmed;
      }
    }
    return null;
  }
  return {
    id: "google",
    name: "Google",
    envKeys,
    defaultModel: DEFAULT_MODEL,
    defaultModels: DEFAULT_MODELS,
    isConfigured(env) {
      return resolveApiKey(env) !== null;
    },
    resolveApiKey,
    getConfiguredEnvKey(env) {
      const lookup = env ?? process.env;
      for (const key of envKeys) {
        const value = lookup[key];
        if (typeof value === "string" && value.trim().length > 0) {
          return key;
        }
      }
      return envKeys[0];
    },
    createModel(options) {
      const google = createGoogleGenerativeAI({
        apiKey: options.apiKey,
        ...options.baseURL ? { baseURL: options.baseURL } : {}
      });
      return google(options.modelId);
    }
  };
}
export {
  createGoogleAdapter
};
//# sourceMappingURL=google.js.map
