'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
var React = require('react');
var index = require('../../utils/index.js');
var base = require('./variations/_view/base.js');
var base$1 = require('./variations/_size/base.js');
var base$2 = require('./variations/_disabled/base.js');
var Slider_tokens = require('./Slider.tokens.js');
var Single = require('./components/Single/Single.js');
var DoubleUncontrolled = require('./components/DoubleUncontrolled/DoubleUncontrolled.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var React__default = /*#__PURE__*/_interopDefault(React);

var _excluded = ["type"];

// TODO: проверить, можно ли обойтись без каста типов

var isSingleValueProps = function isSingleValueProps(props, type) {
  return typeof props.value === 'number' || type === 'single' && _rollupPluginBabelHelpers.typeof(props.value) !== 'object';
};
var isDoubleValueProps = function isDoubleValueProps(props, type) {
  return _rollupPluginBabelHelpers.typeof(props.value) === 'object' || type === 'double';
};
var sliderRoot = function sliderRoot(Root) {
  return /*#__PURE__*/React.forwardRef(function (_ref, ref) {
    var _ref$type = _ref.type,
      type = _ref$type === void 0 ? 'single' : _ref$type,
      props = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
    if (isSingleValueProps(props, type)) {
      return /*#__PURE__*/React__default.default.createElement(Root, _rollupPluginBabelHelpers.extends({}, props, {
        className: index.cx(props.orientation === 'vertical' && Slider_tokens.classes.verticalOrientation, props.className),
        ref: ref
      }), /*#__PURE__*/React__default.default.createElement(Single.SingleSlider, props));
    }
    return /*#__PURE__*/React__default.default.createElement(Root, _rollupPluginBabelHelpers.extends({
      ref: ref
    }, props), isDoubleValueProps(props, type) && /*#__PURE__*/React__default.default.createElement(DoubleUncontrolled.DoubleUncontrolled, props));
  });
};
var sliderConfig = {
  name: 'Slider',
  tag: 'div',
  layout: sliderRoot,
  base: '',
  variations: {
    view: {
      css: base.base
    },
    size: {
      css: base$1.base
    },
    disabled: {
      css: base$2.base,
      attrs: true
    }
  },
  defaults: {
    view: 'default',
    size: 'm'
  }
};

exports.sliderConfig = sliderConfig;
exports.sliderRoot = sliderRoot;
//# sourceMappingURL=Slider.js.map
