/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

'use strict';

function getIEVersion() {
  var {
    userAgent
  } = navigator;
  var isIE = userAgent.includes("compatible") && userAgent.includes("MSIE");
  var isIE11 = userAgent.includes("Trident") && userAgent.includes("rv:11.0");
  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 [...(str !== null && str !== void 0 ? str : "")].length;
}
function limitUnicodeMaxLength(str, maxLength, oldStr) {
  if ([...(oldStr !== null && oldStr !== void 0 ? oldStr : "")].slice().length === maxLength) return oldStr;
  return [...(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(name => "".concat(name, ":").concat(style.getPropertyValue(name))).join(";");
  return {
    paddingSize,
    borderSize,
    boxSizing,
    sizingStyle
  };
}

exports.calculateNodeSize = calculateNodeSize;
exports.getIEVersion = getIEVersion;
exports.getUnicodeLength = getUnicodeLength;
exports.limitUnicodeMaxLength = limitUnicodeMaxLength;
//# sourceMappingURL=helper2.js.map
