import { computed, isRef } from "vue";
import { colorToOnColorHex, isCssColor, propsFactory } from "@veno-ui/utils";
const makeColorProps = propsFactory({
  color: String,
  textColor: String
}, "color");
function useColor(colors) {
  const backgroundIsCssColor = computed(() => isCssColor(colors.value.background));
  const textIsCssColor = computed(() => isCssColor(colors.value.text));
  const colorClasses = computed(() => {
    const classes = [];
    if (colors.value.background && !backgroundIsCssColor.value) {
      classes.push(`bg-${colors.value.background}`);
    }
    if (colors.value.text && !textIsCssColor.value) {
      classes.push(`text-${colors.value.text}`);
    }
    return classes;
  });
  const colorStyles = computed(() => {
    const styles = {};
    if (colors.value.background && backgroundIsCssColor.value) {
      styles.backgroundColor = colors.value.background;
      styles.color = colorToOnColorHex(styles.backgroundColor);
    }
    if (colors.value.text && textIsCssColor.value) {
      styles.color = colors.value.text;
      styles.caretColor = colors.value.text;
    }
    return styles;
  });
  return { colorClasses, colorStyles };
}
function useTextColor(props, name) {
  const colors = computed(() => ({
    text: isRef(props) ? props.value : name ? props[name] : null
  }));
  const {
    colorClasses: textColorClasses,
    colorStyles: textColorStyles
  } = useColor(colors);
  return { textColorClasses, textColorStyles };
}
function useBackgroundColor(props, name) {
  const colors = computed(() => ({
    background: isRef(props) ? props.value : name ? props[name] : null
  }));
  const {
    colorClasses: backgroundColorClasses,
    colorStyles: backgroundColorStyles
  } = useColor(colors);
  return { backgroundColorClasses, backgroundColorStyles };
}
export {
  makeColorProps,
  useBackgroundColor,
  useColor,
  useTextColor
};
//# sourceMappingURL=index.mjs.map
