import { init_resolve_config_value, resolveConfigValue } from "../../../config/resolve-config-value.js";
import { resolveWebSearchRegion } from "./region.js";
//#region src/agent/tools/search/resolve-config.ts
init_resolve_config_value();
function resolveKey(raw) {
	if (raw === void 0 || raw === "") return void 0;
	return resolveConfigValue(raw) ?? raw;
}
/** Build registry input from config (keys resolved via resolveConfigValue when set). */
function resolveWebSearchConfig(web) {
	const search = web?.search;
	const region = resolveWebSearchRegion(web);
	const providers = (search?.providers ?? []).map((p) => {
		const resolvedKey = p.apiKey !== void 0 && p.apiKey !== "" ? resolveKey(p.apiKey) : void 0;
		const url = p.url?.replace(/\/+$/, "");
		return {
			type: p.type,
			apiKey: resolvedKey,
			url,
			disabled: p.disabled
		};
	});
	return {
		region,
		maxResults: search?.maxResults ?? 5,
		providers
	};
}
//#endregion
export { resolveWebSearchConfig };

//# sourceMappingURL=resolve-config.js.map