"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _vue = require("vue");
require("../color");
var _util = require("../util");
require("../../vc-color-picker");
var _ColorSteppers = _interopRequireDefault(require("./ColorSteppers"));
const colorRgbInputProps = () => ({
  prefixCls: String,
  value: Object,
  onChange: Function
});
const ColorRgbInput = (0, _vue.defineComponent)({
  name: 'ColorRgbInput',
  inheritAttrs: false,
  props: colorRgbInputProps(),
  setup(props) {
    const colorRgbInputPrefixCls = (0, _vue.computed)(() => `${props.prefixCls}-rgb-input`);
    const internalValue = (0, _vue.ref)((0, _util.generateColor)(props.value || '#000'));
    const rgbValue = (0, _vue.computed)(() => props.value || internalValue.value);
    const handleRgbChange = (step, type) => {
      var _a;
      const rgb = rgbValue.value.toRgb();
      rgb[type] = step || 0;
      const genColor = (0, _util.generateColor)(rgb);
      internalValue.value = genColor;
      (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, genColor);
    };
    return () => {
      return (0, _vue.createVNode)("div", {
        "class": colorRgbInputPrefixCls.value
      }, [(0, _vue.createVNode)(_ColorSteppers.default, {
        "max": 255,
        "min": 0,
        "value": Number(rgbValue.value.toRgb().r),
        "prefixCls": props.prefixCls,
        "className": colorRgbInputPrefixCls.value,
        "onChange": step => handleRgbChange(Number(step), 'r')
      }, null), (0, _vue.createVNode)(_ColorSteppers.default, {
        "max": 255,
        "min": 0,
        "value": Number(rgbValue.value.toRgb().g),
        "prefixCls": props.prefixCls,
        "className": colorRgbInputPrefixCls.value,
        "onChange": step => handleRgbChange(Number(step), 'g')
      }, null), (0, _vue.createVNode)(_ColorSteppers.default, {
        "max": 255,
        "min": 0,
        "value": Number(rgbValue.value.toRgb().b),
        "prefixCls": props.prefixCls,
        "className": colorRgbInputPrefixCls.value,
        "onChange": step => handleRgbChange(Number(step), 'b')
      }, null)]);
    };
  }
});
var _default = exports.default = ColorRgbInput;