import { l as normalizeOptionalString } from "./string-coerce-CIXf7egm.js";
import { n as normalizeMediaProviderId } from "./provider-id-DSbuCFIb.js";
//#region packages/media-understanding-common/src/provider-supports.ts
/** Return true when a provider exposes the method for a media capability. */
function providerSupportsCapability(provider, capability) {
	if (!provider) return false;
	if (capability === "audio") return Boolean(provider.transcribeAudio);
	if (capability === "image") return Boolean(provider.describeImage);
	return Boolean(provider.describeVideo);
}
//#endregion
//#region src/media-understanding/provider-registry-metadata.ts
function resolveDefaultMediaModelFromRegistry(params) {
	return normalizeOptionalString(params.providerRegistry.get(normalizeMediaProviderId(params.providerId))?.defaultModels?.[params.capability]);
}
function resolveAutoMediaKeyProvidersFromRegistry(params) {
	return [...params.providerRegistry.values()].filter((provider) => provider.capabilities?.includes(params.capability) ?? providerSupportsCapability(provider, params.capability)).map((provider) => {
		const priority = provider.autoPriority?.[params.capability];
		return typeof priority === "number" && Number.isFinite(priority) ? {
			provider,
			priority
		} : null;
	}).filter((entry) => entry !== null).toSorted((left, right) => {
		if (left.priority !== right.priority) return left.priority - right.priority;
		return left.provider.id.localeCompare(right.provider.id);
	}).map((entry) => normalizeMediaProviderId(entry.provider.id)).filter(Boolean);
}
//#endregion
export { resolveDefaultMediaModelFromRegistry as n, providerSupportsCapability as r, resolveAutoMediaKeyProvidersFromRegistry as t };
