import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
import React from 'react';
import { getDOMRect } from "../../../lib/dom/getDOMRect";
import { jsStyles } from "../TextWidthHelper.styles";
var THIN_SPACE = "\u2009";

/**
 * Херпер позволяет вычислить размеры блока с текстом
 */
export var TextWidthHelper = /*#__PURE__*/function (_React$Component) {
  function TextWidthHelper() {
    var _this;
    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }
    _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
    _this.element = null;
    _this.elementRef = function (node) {
      return _this.element = node;
    };
    return _this;
  }
  _inheritsLoose(TextWidthHelper, _React$Component);
  var _proto = TextWidthHelper.prototype;
  _proto.render = function render() {
    return /*#__PURE__*/React.createElement("div", {
      className: jsStyles.root()
    }, /*#__PURE__*/React.createElement("div", {
      className: jsStyles.textContainer(),
      ref: this.elementRef
    }, this.props.text || THIN_SPACE));
  };
  _proto.getTextWidth = function getTextWidth() {
    return getDOMRect(this.element).width;
  };
  _proto.getTextHeight = function getTextHeight() {
    return getDOMRect(this.element).height;
  };
  return TextWidthHelper;
}(React.Component);