import { getSpeechProvider } from "../voice/tts/speech-registry.js";
//#region src/extensions/speech-provider-contracts.ts
/**
* Speech provider extension contract validation.
*/
function normalizeId(id) {
	return id.trim().toLowerCase();
}
/** Declared speech provider ids from manifest (top-level + contracts). */
function declaredSpeechProviderIds(manifest) {
	const ids = /* @__PURE__ */ new Set();
	for (const id of manifest.speechProviders ?? []) if (typeof id === "string" && id.trim()) ids.add(normalizeId(id));
	for (const id of manifest.contracts?.speechProviders ?? []) if (typeof id === "string" && id.trim()) ids.add(normalizeId(id));
	return [...ids];
}
/** Registered ids normalized for comparison (includes canonical plugin ids). */
function normalizeRegisteredSpeechProviderIds(registeredIds) {
	const normalized = /* @__PURE__ */ new Set();
	for (const id of registeredIds) {
		const trimmed = id.trim();
		if (!trimmed) continue;
		normalized.add(normalizeId(trimmed));
		const canonical = getSpeechProvider(trimmed)?.id;
		if (canonical) normalized.add(normalizeId(canonical));
	}
	return [...normalized];
}
/**
* Warn when a manifest declares speech provider contracts but the extension
* did not register matching providers at load time.
*/
function validateSpeechProviderContracts(params) {
	const declared = declaredSpeechProviderIds(params.manifest);
	if (declared.length === 0) return;
	const registered = new Set(normalizeRegisteredSpeechProviderIds(params.registeredProviderIds));
	for (const id of declared) {
		const plugin = getSpeechProvider(id);
		const canonical = plugin ? normalizeId(plugin.id) : id;
		if (!registered.has(canonical) && !registered.has(id)) params.logger.warn(`Speech provider contract "${id}" declared in manifest but not registered by extension "${params.extensionId}"`);
	}
}
//#endregion
export { declaredSpeechProviderIds, normalizeRegisteredSpeechProviderIds, validateSpeechProviderContracts };

//# sourceMappingURL=speech-provider-contracts.js.map