import { a as prepareTransportAwareSimpleModel, n as registerProviderStreamForModel, o as ensureCustomApiRegistered, r as buildTransportAwareSimpleStreamFn, t as createAnthropicVertexStreamFnForModel } from "./anthropic-vertex-stream-BsMRghOh.js";
import { getApiProvider } from "@earendil-works/pi-ai";
//#region src/agents/simple-completion-transport.ts
function resolveAnthropicVertexSimpleApi(baseUrl) {
	return `kaijibot-anthropic-vertex-simple:${baseUrl?.trim() ? encodeURIComponent(baseUrl.trim()) : "default"}`;
}
function prepareModelForSimpleCompletion(params) {
	const { model, cfg } = params;
	if (!getApiProvider(model.api) && registerProviderStreamForModel({
		model,
		cfg
	})) return model;
	const transportAwareModel = prepareTransportAwareSimpleModel(model);
	if (transportAwareModel !== model) {
		const streamFn = buildTransportAwareSimpleStreamFn(model);
		if (streamFn) {
			ensureCustomApiRegistered(transportAwareModel.api, streamFn);
			return transportAwareModel;
		}
	}
	if (model.provider === "anthropic-vertex") {
		const api = resolveAnthropicVertexSimpleApi(model.baseUrl);
		ensureCustomApiRegistered(api, createAnthropicVertexStreamFnForModel(model));
		return {
			...model,
			api
		};
	}
	return model;
}
//#endregion
export { prepareModelForSimpleCompletion as t };
