import { computed, ref } from 'vue';
import { useConfigContextInject, Variants } from '../../config-provider/context';
import { useInjectFormVariant } from '../context';
const useVariants = (component, variant, legacyBordered = ref(undefined)) => {
  const {
    variant: configVariant,
    [component]: componentConfig
  } = useConfigContextInject();
  const ctxVariant = useInjectFormVariant();
  return computed(() => {
    var _a, _b, _c, _d;
    const configComponentVariant = (_a = componentConfig === null || componentConfig === void 0 ? void 0 : componentConfig.value) === null || _a === void 0 ? void 0 : _a.variant;
    let mergedVariant;
    if (typeof variant.value !== 'undefined') {
      mergedVariant = variant.value;
    } else if (legacyBordered.value === false) {
      mergedVariant = 'borderless';
    } else {
      // form variant > component global variant > global variant
      mergedVariant = (_d = (_c = (_b = ctxVariant === null || ctxVariant === void 0 ? void 0 : ctxVariant.value) !== null && _b !== void 0 ? _b : configComponentVariant) !== null && _c !== void 0 ? _c : configVariant === null || configVariant === void 0 ? void 0 : configVariant.value) !== null && _d !== void 0 ? _d : 'outlined';
    }
    const enableVariantCls = Variants.includes(mergedVariant);
    return [mergedVariant, enableVariantCls];
  });
};
export default useVariants;