//#region src/agent/models/selection.ts
/**
* Normalize provider ID (handle aliases)
*/
function normalizeProviderId(provider) {
	const normalized = provider.trim().toLowerCase();
	if (normalized === "z.ai" || normalized === "z-ai") return "zai";
	if (normalized === "opencode-zen") return "opencode";
	if (normalized === "kimi-code") return "kimi-coding";
	if (normalized === "bytedance" || normalized === "doubao") return "volcengine";
	return normalized;
}
/**
* Parse a model reference string (e.g., "anthropic/claude-opus-4-6")
* into provider and model parts.
*/
function parseModelRef(ref, defaultProvider) {
	if (!ref || typeof ref !== "string") return null;
	const trimmed = ref.trim();
	if (!trimmed) return null;
	const slashIndex = trimmed.indexOf("/");
	if (slashIndex === -1) return {
		provider: defaultProvider || "openai",
		model: trimmed
	};
	const provider = trimmed.slice(0, slashIndex);
	const model = trimmed.slice(slashIndex + 1);
	if (!provider || !model) return null;
	return {
		provider: normalizeProviderId(provider),
		model
	};
}
/**
* Find provider config by normalized provider ID
*/
function findProviderConfig(providers, provider) {
	if (!providers) return;
	const normalizedProviderId = normalizeProviderId(provider);
	if (providers[normalizedProviderId]) return providers[normalizedProviderId];
	for (const [key, config] of Object.entries(providers)) if (normalizeProviderId(key) === normalizedProviderId) return config;
}
/**
* Find model config within a provider
*/
function findModelConfig(provider, modelId) {
	const normalizedModelId = modelId.toLowerCase();
	return provider.models.find((m) => m.id.toLowerCase() === normalizedModelId);
}
//#endregion
export { findModelConfig, findProviderConfig, normalizeProviderId, parseModelRef };

//# sourceMappingURL=selection.js.map