function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
/**
 * 百分比范围转换工具函数
 */

/**
 * 将值转换为百分比（0-100）
 * 
 * @param value 原始值
 * @param range 值的范围
 * @returns 转换后的百分比值（0-100）
 * 
 * @example
 * // [0, 100] 范围 - 直接返回
 * convertToPercent(85.5, [0, 100])  // 返回: 85.5
 * 
 * @example
 * // [0, 1] 范围 - 乘以 100
 * convertToPercent(0.855, [0, 1])  // 返回: 85.5
 * 
 * @example
 * // 自定义范围 - 按比例计算
 * convertToPercent(855, [0, 1000])  // 返回: 85.5
 */
export function convertToPercent(value, range) {
  if (value === null || value === undefined) {
    return null;
  }
  var _range = _slicedToArray(range, 2),
    min = _range[0],
    max = _range[1];

  // 范围 [0, 100] - 直接返回
  if (min === 0 && max === 100) {
    return value;
  }

  // 范围 [0, 1] - 乘以 100
  if (min === 0 && max === 1) {
    return value * 100;
  }

  // 自定义范围 - 按比例计算
  if (max !== 0) {
    return value / max * 100;
  }
  return value;
}

/**
 * 将百分比值转换回原始范围
 * 
 * @param percent 百分比值（0-100）
 * @param range 目标范围
 * @returns 转换后的值
 * 
 * @example
 * convertFromPercent(85.5, [0, 100])  // 返回: 85.5
 * convertFromPercent(85.5, [0, 1])    // 返回: 0.855
 * convertFromPercent(85.5, [0, 1000]) // 返回: 855
 */
export function convertFromPercent(percent, range) {
  if (percent === null || percent === undefined) {
    return null;
  }
  var _range2 = _slicedToArray(range, 2),
    min = _range2[0],
    max = _range2[1];

  // 范围 [0, 100] - 直接返回
  if (min === 0 && max === 100) {
    return percent;
  }

  // 范围 [0, 1] - 除以 100
  if (min === 0 && max === 1) {
    return percent / 100;
  }

  // 自定义范围 - 按比例计算
  return percent / 100 * max;
}