import { o as resolveProviderHttpRequestConfig } from "./shared-B2wd19X6.js";
import { n as applyAgentDefaultModelPrimary } from "./provider-onboard-SzQNFxTR.js";
import "./provider-http-CL2_VUDN.js";
import { n as parseGoogleOauthApiKey } from "./oauth-token-shared-BlqRwW-Z.js";
import { r as normalizeGoogleApiBaseUrl, t as DEFAULT_GOOGLE_API_BASE_URL } from "./provider-policy-3GZyzLOg.js";
//#region extensions/google/api.ts
function parseGeminiAuth(apiKey) {
	const parsed = apiKey.startsWith("{") ? parseGoogleOauthApiKey(apiKey) : null;
	if (parsed?.token) return { headers: {
		Authorization: `Bearer ${parsed.token}`,
		"Content-Type": "application/json"
	} };
	return { headers: {
		"x-goog-api-key": apiKey,
		"Content-Type": "application/json"
	} };
}
function resolveGoogleGenerativeAiHttpRequestConfig(params) {
	return resolveProviderHttpRequestConfig({
		baseUrl: normalizeGoogleApiBaseUrl(params.baseUrl ?? "https://generativelanguage.googleapis.com/v1beta"),
		defaultBaseUrl: DEFAULT_GOOGLE_API_BASE_URL,
		allowPrivateNetwork: Boolean(params.baseUrl?.trim()),
		headers: params.headers,
		request: params.request,
		defaultHeaders: parseGeminiAuth(params.apiKey).headers,
		provider: "google",
		api: "google-generative-ai",
		capability: params.capability,
		transport: params.transport
	});
}
const GOOGLE_GEMINI_DEFAULT_MODEL = "google/gemini-3.1-pro-preview";
function applyGoogleGeminiModelDefault(cfg) {
	const current = cfg.agents?.defaults?.model;
	if ((typeof current === "string" ? current.trim() || void 0 : current && typeof current === "object" && typeof current.primary === "string" ? (current.primary || "").trim() || void 0 : void 0) === "google/gemini-3.1-pro-preview") return {
		next: cfg,
		changed: false
	};
	return {
		next: applyAgentDefaultModelPrimary(cfg, GOOGLE_GEMINI_DEFAULT_MODEL),
		changed: true
	};
}
//#endregion
export { resolveGoogleGenerativeAiHttpRequestConfig as i, applyGoogleGeminiModelDefault as n, parseGeminiAuth as r, GOOGLE_GEMINI_DEFAULT_MODEL as t };
