"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.valueToPercent = valueToPercent;
exports.percentToValue = percentToValue;
exports.roundValueToStep = roundValueToStep;
exports.clampValue = clampValue;

function valueToPercent(value, min, max) {
  return (value - min) * 100 / (max - min);
}

function percentToValue(percent, min, max) {
  return (max - min) * percent + min;
}

function makeValuePrecise(value, step) {
  var stepDecimalPart = step.toString().split('.')[1];
  var stepPrecision = stepDecimalPart ? stepDecimalPart.length : 0;
  return Number(value.toFixed(stepPrecision));
}

function roundValueToStep(value, step) {
  return makeValuePrecise(Math.round(value / step) * step, step);
}

function clampValue(val, min, max) {
  if (val > max) {
    return max;
  }

  if (val < min) {
    return min;
  }

  return val;
}
//# sourceMappingURL=utils.js.map