/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
import { coalesceConfigVariant } from "./coalesceConfigVariant.js";

//#region ../automated-config/dist/utils/getConfigComponentVariant.js
/*! © 2026 Yahoo, Inc. UDS Default Config v0.0.0-development */
function getConfigComponentVariant(config, variantKey, subComponentName) {
	const result = coalesceConfigVariant(config, variantKey);
	switch (result.type) {
		case "no-variants": return null;
		case "no-sub-components": return result.variant;
		case "has-sub-components":
			if (!subComponentName) throw new Error("subComponentName argument name is required for configs with subcomponents");
			return result.variants[subComponentName];
	}
}

//#endregion
export { getConfigComponentVariant };