"use strict";

exports.__esModule = true;
exports.getSpacingValues = exports.formatSpacingValue = void 0;
var _spacingSt = require("../../Foundation/stylable/spacing.st.css.js");
var _Box = require("../Box.constants");
/** In case the value is a number, it's multiplied by the defined spacing unit.
 *  Otherwise - there are three options:
 *   1. A Spacing Token - SP1, SP2, etc. - where the number is multiplied by the spacing unit.
 *   2. A predefined spacing value with semantic name (tiny, small, etc.)
 *   3. Space-separated values that are represented by a string (for example: "3px 3px")
 * */

var formatSpacingValue = value => {
  return value == null ? void 0 : value.toString().split(' ').map(computeSpacingValue).join(' ');
};
exports.formatSpacingValue = formatSpacingValue;
function isSpacingKey(value) {
  return value in _Box.SPACING;
}
var computeSpacingValue = value => {
  if (isFinite(Number(value))) {
    return "calc(".concat(Number(value), " * ").concat(_spacingSt.stVars.Spacing, ")");
  }
  if (typeof value === 'string') {
    if (value in _spacingSt.stVars) {
      return _spacingSt.stVars[value];
    } else if (isSpacingKey(value)) {
      return _Box.SPACING[value];
    }
  }
  return "".concat(value);
};
var getSpacingValues = props => {
  return Object.fromEntries(Object.entries(props).map(_ref => {
    var [key, value] = _ref;
    return [key, formatSpacingValue(value)];
  }));
};
exports.getSpacingValues = getSpacingValues;
//# sourceMappingURL=formatSpacingValues.js.map