import _NumberPicker from "@alifd/next/es/number-picker";
import _Range from "@alifd/next/es/range";
import _extends from "@babel/runtime/helpers/extends";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import _Radio from "@alifd/next/es/radio";
import * as React from 'react';
import { PureComponent } from 'react';
import "./index.scss";
var RadioGroup = _Radio.Group;
var ResizeSetter = /*#__PURE__*/function (_PureComponent) {
  _inheritsLoose(ResizeSetter, _PureComponent);
  function ResizeSetter() {
    return _PureComponent.apply(this, arguments) || this;
  }
  var _proto = ResizeSetter.prototype;
  _proto.render = function render() {
    var options = this.props.options;
    if (options) {
      var _this$props = this.props,
        value = _this$props.value,
        _onChange = _this$props.onChange,
        disabled = _this$props.disabled,
        _this$props$options = _this$props.options,
        size = _this$props$options.size,
        sizeList = _this$props$options.sizeList;
      var dataSource = sizeList.map(function (item) {
        if (typeof item === 'string') {
          return item;
        } else {
          return {
            label: item.title || item.label,
            value: item.value
          };
        }
      });
      var otherProps = {};
      var isRangeSelect = sizeList.find(function (res) {
        return res.value === value;
      });
      return /*#__PURE__*/React.createElement("div", {
        className: "resize-img-setter"
      }, /*#__PURE__*/React.createElement(RadioGroup, _extends({
        size: "small",
        dataSource: dataSource,
        shape: "button",
        value: value,
        disabled: disabled,
        onChange: function onChange(val) {
          return _onChange(val);
        }
      }, otherProps)), /*#__PURE__*/React.createElement("div", {
        style: {
          display: 'flex',
          marginTop: '4px'
        }
      }, /*#__PURE__*/React.createElement(_Range, {
        value: value,
        min: size.min || 0,
        max: size.max || 100,
        step: size.step || 1,
        onChange: function onChange(val) {
          return _onChange(val);
        },
        style: {
          marginRight: 15
        },
        className: isRangeSelect ? 'next-range-static' : ''
      }), !isRangeSelect ? /*#__PURE__*/React.createElement(_NumberPicker, {
        onChange: function onChange(val) {
          return _onChange(val);
        },
        value: value,
        size: "small",
        min: size.min || 0,
        max: size.max || 100,
        hasTrigger: false,
        innerAfter: "%"
      }) : ''));
    }
  };
  return ResizeSetter;
}(PureComponent);
ResizeSetter.displayName = 'ResizeSetter';
export { ResizeSetter as default };