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

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