"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 colorHsbInputProps = () => ({
  prefixCls: String,
  value: Object,
  onChange: Function
});
const ColorHsbInput = (0, _vue.defineComponent)({
  name: 'ColorHsbInput',
  inheritAttrs: false,
  props: colorHsbInputProps(),
  setup(props) {
    const colorHsbInputPrefixCls = (0, _vue.computed)(() => `${props.prefixCls}-hsb-input`);
    const internalValue = (0, _vue.ref)((0, _util.generateColor)(props.value || '#000'));
    const hsbValue = (0, _vue.computed)(() => props.value || internalValue.value);
    const handleHsbChange = (step, type) => {
      var _a;
      const hsb = hsbValue.value.toHsb();
      hsb[type] = type === 'h' ? step : (step || 0) / 100;
      const genColor = (0, _util.generateColor)(hsb);
      internalValue.value = genColor;
      (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, genColor);
    };
    return () => {
      return (0, _vue.createVNode)("div", {
        "class": colorHsbInputPrefixCls.value
      }, [(0, _vue.createVNode)(_ColorSteppers.default, {
        "max": 360,
        "min": 0,
        "value": Number(hsbValue.value.toHsb().h),
        "prefixCls": props.prefixCls,
        "className": colorHsbInputPrefixCls.value,
        "formatter": step => (0, _util.getRoundNumber)(Number(step) || 0).toString(),
        "onChange": step => handleHsbChange(Number(step), 'h')
      }, null), (0, _vue.createVNode)(_ColorSteppers.default, {
        "max": 100,
        "min": 0,
        "value": Number(hsbValue.value.toHsb().s * 100),
        "prefixCls": props.prefixCls,
        "className": colorHsbInputPrefixCls.value,
        "formatter": step => `${(0, _util.getRoundNumber)(Number(step) || 0)}%`,
        "onChange": step => handleHsbChange(Number(step), 's')
      }, null), (0, _vue.createVNode)(_ColorSteppers.default, {
        "max": 100,
        "min": 0,
        "value": Number(hsbValue.value.toHsb().b * 100),
        "prefixCls": props.prefixCls,
        "className": colorHsbInputPrefixCls.value,
        "formatter": step => `${(0, _util.getRoundNumber)(Number(step) || 0)}%`,
        "onChange": step => handleHsbChange(Number(step), 'b')
      }, null)]);
    };
  }
});
var _default = exports.default = ColorHsbInput;