"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = useColor;
var _vue = require("vue");
require("..");
var _colors = require("../../_util/colors");
var _fastColor = require("@ant-design/fast-color");
function useColor(props) {
  return (0, _vue.computed)(() => {
    const {
      color,
      variant,
      bordered
    } = props;
    const isInverseColor = color === null || color === void 0 ? void 0 : color.endsWith('-inverse');
    // =================== Variant ===================
    let nextVariant;
    if (variant) {
      nextVariant = variant;
    } else if (isInverseColor) {
      nextVariant = 'solid';
    } else if (bordered === false) {
      nextVariant = 'filled';
    } else {
      nextVariant = 'filled';
    }
    // ==================== Color ====================
    const nextColor = isInverseColor ? color === null || color === void 0 ? void 0 : color.replace('-inverse', '') : color;
    // =============== Preset & Status ===============
    const nextIsPreset = (0, _colors.isPresetColor)(color);
    const nextIsStatus = (0, _colors.isPresetStatusColor)(color);
    // ================== Customize ==================
    // When `color` is not preset color,
    // dynamic calculate the color pair.
    const tagStyle = {};
    if (!nextIsPreset && !nextIsStatus && nextColor) {
      if (nextVariant === 'solid') {
        tagStyle.backgroundColor = color;
      } else {
        const hsl = new _fastColor.FastColor(nextColor).toHsl();
        hsl.l = 0.95;
        tagStyle.backgroundColor = new _fastColor.FastColor(hsl).toHexString();
        tagStyle.color = color;
        if (nextVariant === 'outlined') {
          tagStyle.borderColor = color;
        }
      }
    }
    return {
      mergedVariant: nextVariant,
      mergedColor: nextColor,
      isPreset: nextIsPreset,
      isStatus: nextIsStatus,
      customTagStyle: tagStyle
    };
  });
}