"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const tslib_es6 = require("../../../../../tslib@2.3.0/node_modules/tslib/tslib.es6.js");
const Displayable = require("./Displayable.js");
const text = require("../contain/text.js");
const Path = require("./Path.js");
const util = require("../core/util.js");
const platform = require("../core/platform.js");
var DEFAULT_TSPAN_STYLE = util.defaults({
  strokeFirst: true,
  font: platform.DEFAULT_FONT,
  x: 0,
  y: 0,
  textAlign: "left",
  textBaseline: "top",
  miterLimit: 2
}, Path.DEFAULT_PATH_STYLE);
var TSpan = function(_super) {
  tslib_es6.__extends(TSpan2, _super);
  function TSpan2() {
    return _super !== null && _super.apply(this, arguments) || this;
  }
  TSpan2.prototype.hasStroke = function() {
    var style = this.style;
    var stroke = style.stroke;
    return stroke != null && stroke !== "none" && style.lineWidth > 0;
  };
  TSpan2.prototype.hasFill = function() {
    var style = this.style;
    var fill = style.fill;
    return fill != null && fill !== "none";
  };
  TSpan2.prototype.createStyle = function(obj) {
    return util.createObject(DEFAULT_TSPAN_STYLE, obj);
  };
  TSpan2.prototype.setBoundingRect = function(rect) {
    this._rect = rect;
  };
  TSpan2.prototype.getBoundingRect = function() {
    var style = this.style;
    if (!this._rect) {
      var text$1 = style.text;
      text$1 != null ? text$1 += "" : text$1 = "";
      var rect = text.getBoundingRect(text$1, style.font, style.textAlign, style.textBaseline);
      rect.x += style.x || 0;
      rect.y += style.y || 0;
      if (this.hasStroke()) {
        var w = style.lineWidth;
        rect.x -= w / 2;
        rect.y -= w / 2;
        rect.width += w;
        rect.height += w;
      }
      this._rect = rect;
    }
    return this._rect;
  };
  TSpan2.initDefaultProps = function() {
    var tspanProto = TSpan2.prototype;
    tspanProto.dirtyRectTolerance = 10;
  }();
  return TSpan2;
}(Displayable.default);
TSpan.prototype.type = "tspan";
const TSpan$1 = TSpan;
exports.DEFAULT_TSPAN_STYLE = DEFAULT_TSPAN_STYLE;
exports.default = TSpan$1;
