text: function(t,i){"use strict";var e=Number,n=t("../../core/utils/type").isString,s=t("../../core/utils/extend").extend,o=t("./utils").patchFontOptions,h=t("./utils").enumParser(["left","center","right"]),r=t("./utils").enumParser(["top","bottom"]),l=10,u=3;function a(t){return!!(t&&String(t).length>0)}function c(t,i,e){t.attr({text:i}).applyEllipsis(e)&&t.setTitle(i)}function p(t){return t>=0?e(t):l}function _(t){var i;return i=t>=0?{left:e(t),top:e(t),right:e(t),bottom:e(t)}:{left:p((t=t||{}).left),top:p(t.top),right:p(t.right),bottom:p(t.bottom)}}function g(t){this._params=t,this._group=t.renderer.g().attr({class:t.cssClass}).linkOn(t.renderer.root,"title"),this._hasText=!1}function d(t){var i=n(t)?{text:t}:t||{};return i.subtitle=n(i.subtitle)?{text:i.subtitle}:i.subtitle||{},i}s(g.prototype,t("./layout_element").LayoutElement.prototype,{dispose:function(){var t=this;this._group.linkRemove(),this._group.linkOff(),this._titleElement&&(this._clipRect.dispose(),this._titleElement=this._subtitleElement=this._clipRect=null),this._params=this._group=this._options=null},_updateOptions:function(t){this._options=t,this._options.horizontalAlignment=h(t.horizontalAlignment,"center"),this._options.verticalAlignment=r(t.verticalAlignment,"top"),this._options.margin=_(t.margin)},_updateStructure:function(){var t=this,i=this._params.renderer,e=this._group,n={align:this._options.horizontalAlignment};this._titleElement||(this._titleElement=i.text().attr(n).append(e),this._subtitleElement=i.text().attr(n),this._clipRect=i.clipRect(),e.attr({"clip-path":this._clipRect.id})),e.linkAppend(),a(this._options.subtitle.text)?this._subtitleElement.append(e):this._subtitleElement.remove()},_updateTexts:function(){var t,i,e=this,n=this._options,s=n.subtitle,h=this._titleElement,r=this._subtitleElement,l="A";h.attr({text:"A",y:0}).css(o(n.font)),t=h.getBBox(),this._titleTextY=t.height+t.y,h.attr({text:n.text}),i=-(t=h.getBBox()).y,h.attr({y:i}),a(s.text)&&(i+=t.height+t.y,r.attr({text:s.text,y:0}).css(o(s.font)),i+=-r.getBBox().y-this._titleTextY+3,r.attr({y:i}))},_updateBoundingRectAlignment:function(){var t=this._boundingRect,i=this._options;t.verticalAlignment=i.verticalAlignment,t.horizontalAlignment=i.horizontalAlignment,t.cutLayoutSide=i.verticalAlignment,t.cutSide="vertical",t.position={horizontal:i.horizontalAlignment,vertical:i.verticalAlignment}},update:function(t){var i=this,e=a(t.text),n=e||e!==this._hasText;return e?(this._updateOptions(t),this._updateStructure(),this._updateTexts(),this._boundingRect={},this._updateBoundingRect(),this._updateBoundingRectAlignment()):(this._group.linkRemove(),this._boundingRect=null),this._hasText=e,n},draw:function(t,i){var e,n=this;return this._group.linkAppend(),this._correctTitleLength(t),(e=this.getLayoutOptions()).height>i&&this.freeSpace(),this},probeDraw:function(t,i){return this.draw(t,i),this},_correctTitleLength:function(t){var i=this,e=this._options,n=e.margin,s=t-n.left-n.right;c(this._titleElement,e.text,s),this._subtitleElement&&c(this._subtitleElement,e.subtitle.text,s),this._updateBoundingRect()},getLayoutOptions:function(){return this._boundingRect||null},shift:function(t,i){var e=this,n=this.getLayoutOptions();return this._group.move(t-n.x,i-n.y),this._setClipRectSettings(),this},_setClipRectSettings:function(){var t=this.getLayoutOptions();this._clipRect.attr({x:t.x,y:t.y,width:t.width,height:t.height})},_updateBoundingRect:function(){var t,i=this,e=this._options,n=e.margin,s=this._boundingRect;(t=this._group.getBBox()).height+=n.top+n.bottom-this._titleTextY,t.width+=n.left+n.right,t.x-=n.left,t.y+=this._titleTextY-n.top,e.placeholderSize>0&&(t.height=e.placeholderSize),s.height=t.height,s.width=t.width,s.x=t.x,s.y=t.y},layoutOptions:function(){return this._boundingRect&&{horizontalAlignment:this._boundingRect.horizontalAlignment,verticalAlignment:this._boundingRect.verticalAlignment,priority:0}},measure:function(t){return this.draw(t[0],t[1]),[this._boundingRect.width,this._boundingRect.height]},move:function(t){var i=this._boundingRect;(t[2]-t[0]<i.width||t[3]-t[1]<i.height)&&this.draw(t[2]-t[0],t[3]-t[1]),this.shift(Math.round(t[0]),Math.round(t[1]))},freeSpace:function(){var t=this;this._params.incidentOccurred("W2103"),this._group.linkRemove(),this._boundingRect.width=this._boundingRect.height=0}}),i.Title=g,i.plugin={name:"title",init:function(){var t=this;this._title=new i.Title({renderer:this._renderer,cssClass:this._rootClassPrefix+"-title",incidentOccurred:this._incidentOccurred}),this._layout.add(this._title)},dispose:function(){this._title.dispose(),this._title=null},customize:function(t){t.addChange({code:"TITLE",handler:function(){this._title.update(s(!0,{},this._themeManager.theme("title"),d(this.option("title"))))&&this._change(["LAYOUT"])},isThemeDependent:!0,option:"title",isOptionChange:!0})}}}
  
  