import { s as normalizeOptionalString } from "./string-coerce-CIT1-v_a.js";
import "./provider-model-shared-DkmyZ3nD.js";
import "./text-runtime-Drz6LusC.js";
import "./provider-catalog-shared-DhtJrocV.js";
//#region extensions/openai/shared.ts
const OPENAI_API_BASE_URL = "https://api.openai.com/v1";
function toOpenAIDataUrl(buffer, mimeType) {
	return `data:${mimeType};base64,${buffer.toString("base64")}`;
}
function resolveConfiguredOpenAIBaseUrl(cfg) {
	return normalizeOptionalString(cfg?.models?.providers?.openai?.baseUrl) ?? "https://api.openai.com/v1";
}
function isOpenAIApiBaseUrl(baseUrl) {
	const trimmed = normalizeOptionalString(baseUrl);
	if (!trimmed) return false;
	return /^https?:\/\/api\.openai\.com(?:\/v1)?\/?$/i.test(trimmed);
}
function isOpenAICodexBaseUrl(baseUrl) {
	const trimmed = normalizeOptionalString(baseUrl);
	if (!trimmed) return false;
	return /^https?:\/\/chatgpt\.com\/backend-api\/?$/i.test(trimmed);
}
function buildOpenAISyntheticCatalogEntry(template, entry) {
	if (!template) return;
	return {
		...template,
		id: entry.id,
		name: entry.id,
		reasoning: entry.reasoning,
		input: [...entry.input],
		contextWindow: entry.contextWindow,
		...entry.contextTokens === void 0 ? {} : { contextTokens: entry.contextTokens }
	};
}
//#endregion
export { resolveConfiguredOpenAIBaseUrl as a, isOpenAICodexBaseUrl as i, buildOpenAISyntheticCatalogEntry as n, toOpenAIDataUrl as o, isOpenAIApiBaseUrl as r, OPENAI_API_BASE_URL as t };
