"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.getHexOrEmpty = getHexOrEmpty;
exports.getHsbOrEmpty = getHsbOrEmpty;
exports.getRgbOrEmpty = getRgbOrEmpty;
exports.isTransparent = isTransparent;
exports.safeColor = safeColor;
exports.stopPropagation = stopPropagation;
var _color2 = _interopRequireDefault(require("color"));
var _mapValue = _interopRequireDefault(require("../utils/operators/mapValue"));
function safeColor(input) {
  var allowEmpty = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  try {
    if (allowEmpty) {
      return input ? (0, _color2.default)(input) : (0, _color2.default)().alpha(0);
    }
    return (0, _color2.default)(input);
  } catch (error) {
    return null;
  }
}
function getHexOrEmpty(_color) {
  return isTransparent(_color) ? '' : _color.hex();
}
function getRgbOrEmpty(_color) {
  return isTransparent(_color) ? {
    r: '',
    g: '',
    b: ''
  } : (0, _mapValue.default)(_color.rgb().object(), Math.round);
}
function getHsbOrEmpty(_color) {
  return isTransparent(_color) ? {
    h: '',
    s: '',
    l: ''
  } : _color.hsl().round().object();
}
function isTransparent(_color) {
  return _color.alpha() === 0;
}
function stopPropagation(event) {
  event.stopPropagation();
}
//# sourceMappingURL=utils.js.map