/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
import { mapValues } from "../../../utils/dist/mapValues.js";
import { getConfigSubcomponents } from "./subcomponents.js";
//#region ../automated-config/dist/utils/coalesceConfigVariant.js
/*! © 2026 Yahoo, Inc. UDS Default Config v0.0.0-development */
function coalesceConfigVariant(config, variantKey) {
	const rootVariantDef = config.variants?.[variantKey];
	if (rootVariantDef) return {
		type: "no-sub-components",
		variant: rootVariantDef
	};
	const subComponents = getConfigSubcomponents(config);
	if (!subComponents) return { type: "no-variants" };
	return {
		type: "has-sub-components",
		variants: mapValues(subComponents, (subComponent) => subComponent.variants[variantKey])
	};
}
//#endregion
export { coalesceConfigVariant };
