import { _ as modelKey, r as buildConfiguredModelCatalog } from "./model-selection-shared-CWuhAIsC.js";
import { t as buildAllowedModelSet } from "./model-selection-DVRX-V8s.js";
//#region src/agents/model-catalog-visibility.ts
function sortModelCatalogEntries(entries) {
	return entries.toSorted((a, b) => a.provider.localeCompare(b.provider) || a.id.localeCompare(b.id));
}
function dedupeModelCatalogEntries(entries) {
	const seen = /* @__PURE__ */ new Set();
	const next = [];
	for (const entry of entries) {
		const key = modelKey(entry.provider, entry.id);
		if (seen.has(key)) continue;
		seen.add(key);
		next.push(entry);
	}
	return next;
}
function resolveVisibleModelCatalog(params) {
	if (params.view === "all") return params.catalog;
	const allowed = buildAllowedModelSet({
		cfg: params.cfg,
		catalog: params.catalog,
		defaultProvider: params.defaultProvider,
		defaultModel: params.defaultModel,
		agentId: params.agentId
	});
	if (!allowed.allowAny && allowed.allowedCatalog.length > 0) return sortModelCatalogEntries(allowed.allowedCatalog);
	return sortModelCatalogEntries(dedupeModelCatalogEntries(sortModelCatalogEntries(buildConfiguredModelCatalog({ cfg: params.cfg }))));
}
//#endregion
export { resolveVisibleModelCatalog as t };
