/**
 * ldesign v0.4.2
 * (c) 2023 ldesign
 * @license MIT
 */

import { i as isString_1 } from '../../_chunks/dep-1cf2b129.mjs';
import '../../_chunks/dep-a0b4a044.mjs';
import '../../_chunks/dep-c959a6fb.mjs';
import '../../_chunks/dep-b4041200.mjs';
import '../../_chunks/dep-e3b14d70.mjs';
import '../../_chunks/dep-66d6733b.mjs';
import '../../_chunks/dep-c31e1d9e.mjs';

var getStopStyle = function getStopStyle(position, isVertical) {
  return isVertical ? {
    top: "calc(".concat(100 - position, "% - 1px)")
  } : {
    left: "".concat(position, "%")
  };
};
var formatSliderValue = function formatSliderValue(val, type) {
  if (type === "first") {
    if (Array.isArray(val)) return val[0];
    return val;
  }
  if (Array.isArray(val)) return val[1];
  return 0;
};
var formatLabel = function formatLabel(label, val) {
  if (Boolean(label) === false) return String(val);
  if (isString_1(label)) {
    var text = String(val);
    try {
      var rule = /\${value}%/g;
      var enableToReplace = rule.test(label);
      if (enableToReplace) {
        text = label.replace(rule, String(val));
      } else {
        text = label;
        throw new Error();
      }
    } catch (e) {
      console.warn("fail to parse label prop, please pass string such as '${value}%'");
    }
    return text;
  }
  return label;
};

export { formatLabel, formatSliderValue, getStopStyle };
//# sourceMappingURL=common.mjs.map
