"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _vue = require("vue");
require("../interface");
var _color = require("../color");
var _util = require("../util");
var _propsUtil = require("../../_util/props-util");
const gradientProps = () => ({
  colors: Array,
  direction: String,
  type: String,
  prefixCls: String
});
const Gradient = (0, _vue.defineComponent)({
  name: 'Gradient',
  inheritAttrs: false,
  props: (0, _propsUtil.initDefaultProps)(gradientProps(), {
    direction: 'to right'
  }),
  setup(props, {
    slots
  }) {
    const gradientColors = (0, _vue.computed)(() => props.colors.map((color, idx) => {
      let result = (0, _util.generateColor)(color);
      if (props.type === 'alpha' && idx === props.colors.length - 1) {
        result = new _color.Color(result.setA(1));
      }
      return result.toRgbString();
    }).join(','));
    return () => {
      var _a;
      const {
        direction,
        prefixCls
      } = props;
      return (0, _vue.createVNode)("div", {
        "class": `${prefixCls}-gradient`,
        "style": {
          position: 'absolute',
          inset: 0,
          background: `linear-gradient(${direction}, ${gradientColors.value})`
        }
      }, [(_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)]);
    };
  }
});
var _default = exports.default = Gradient;