/**
 * ldesign v0.2.2
 * (c) 2022年9月20日 swimly
 * @license MIT
 */

import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/slicedToArray';

function getIEVersion() {
  var _navigator = navigator,
      userAgent = _navigator.userAgent;
  var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1;
  var isIE11 = userAgent.indexOf("Trident") > -1 && userAgent.indexOf("rv:11.0") > -1;

  if (isIE) {
    var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
    var match = userAgent.match(reIE);
    if (!match) return -1;
    var fIEVersion = parseFloat(match[1]);
    return fIEVersion < 7 ? 6 : fIEVersion;
  }

  if (isIE11) {
    return 11;
  }

  return Number.MAX_SAFE_INTEGER;
}

function getUnicodeLength(str) {
  return _toConsumableArray(str !== null && str !== void 0 ? str : "").length;
}

function limitUnicodeMaxLength(str, maxLength) {
  return _toConsumableArray(str !== null && str !== void 0 ? str : "").slice(0, maxLength).join("");
}

var DOM_STYLE_PROPS = ["padding-top", "padding-bottom", "padding-left", "padding-right", "font-family", "font-weight", "font-size", "font-variant", "text-rendering", "text-transform", "width", "text-indent", "border-width", "box-sizing", "line-height", "letter-spacing"];

function calculateNodeSize(targetElement) {
  var style = window.getComputedStyle(targetElement);
  var boxSizing = style.getPropertyValue("box-sizing") || style.getPropertyValue("-moz-box-sizing") || style.getPropertyValue("-webkit-box-sizing");
  var paddingSize = parseFloat(style.getPropertyValue("padding-bottom")) + parseFloat(style.getPropertyValue("padding-top"));
  var borderSize = parseFloat(style.getPropertyValue("border-bottom-width")) + parseFloat(style.getPropertyValue("border-top-width"));
  var sizingStyle = DOM_STYLE_PROPS.map(function (name) {
    return "".concat(name, ":").concat(style.getPropertyValue(name));
  }).join(";");
  return {
    paddingSize: paddingSize,
    borderSize: borderSize,
    boxSizing: boxSizing,
    sizingStyle: sizingStyle
  };
}

export { getUnicodeLength as a, calculateNodeSize as c, getIEVersion as g, limitUnicodeMaxLength as l };
//# sourceMappingURL=dep-fc383775.js.map
