//#region src/extensions/onboard-helpers.ts
function listOnboardProviders(registry, env = process.env) {
	const results = [];
	for (const entry of registry.listProviderExtensions()) {
		const manifest = entry.manifest;
		const providers = manifest.providers || [];
		for (const providerId of providers) {
			const configuredEnvVar = (manifest.providerAuthEnvVars?.[providerId] || []).find((v) => !!env[v]);
			const authChoices = (manifest.providerAuthChoices || []).filter((c) => c.provider === providerId);
			results.push({
				extensionId: entry.id,
				providerId,
				extensionName: manifest.name || entry.id,
				envConfigured: !!configuredEnvVar,
				configuredEnvVar,
				authChoices,
				modelPrefixes: manifest.modelSupport?.modelPrefixes || []
			});
		}
	}
	results.sort((a, b) => {
		if (a.envConfigured && !b.envConfigured) return -1;
		if (!a.envConfigured && b.envConfigured) return 1;
		return a.extensionName.localeCompare(b.extensionName);
	});
	return results;
}
function listOnboardChannels(registry, env = process.env) {
	const results = [];
	for (const entry of registry.listChannelExtensions()) {
		const manifest = entry.manifest;
		const channels = manifest.channels || [];
		for (const channelId of channels) {
			const configuredEnvVar = (manifest.channelEnvVars?.[channelId] || []).find((v) => !!env[v]);
			results.push({
				extensionId: entry.id,
				channelId,
				extensionName: manifest.name || entry.id,
				envConfigured: !!configuredEnvVar,
				configuredEnvVar
			});
		}
	}
	results.sort((a, b) => {
		if (a.envConfigured && !b.envConfigured) return -1;
		if (!a.envConfigured && b.envConfigured) return 1;
		return a.extensionName.localeCompare(b.extensionName);
	});
	return results;
}
function resolveProviderForModel(registry, modelId) {
	const entry = registry.findByModelId(modelId);
	if (!entry) return void 0;
	const providers = entry.manifest.providers;
	if (!providers || providers.length === 0) return void 0;
	return {
		extensionId: entry.id,
		providerId: providers[0]
	};
}
//#endregion
export { listOnboardChannels, listOnboardProviders, resolveProviderForModel };

//# sourceMappingURL=onboard-helpers.js.map