(function(){var t="http://www.w3.org/2000/svg";var e={link:"http://www.w3.org/1999/xhtml"};u8.Base.Svg=function(t){if(t instanceof u8.Base.Svg){return t}if(!(this instanceof u8.Base.Svg)){return new u8.Base.Svg(t)}this.element=t};var i=u8.Base.Svg;function r(t){return t instanceof i?t.element:t}$.extend(u8.Base.Svg.prototype,{attr:function(t,e){if(typeof t=="string"){var i=t;if(arguments.length==1){return this.element.getAttributeNS(null,i)}this.element.setAttributeNS(null,i,e);return this}if(typeof t=="object"&&t){var r=this.element;Object.keys(t).forEach(function(e){var i=t[e];if(i){r.setAttributeNS(null,e,i)}})}return this},create:function(r,n){var a=e[r]||t;var s=this.element.ownerDocument.createElementNS(a,r);return i(s).attr(n)},createRadialGradient:function(t,e){return this.create("radialGradient",e).appendStops(t)},createLinearGradient:function(t,e){return this.create("linearGradient",e).appendStops(t)},createShadowFilter:function(t){var e=this.create("feMerge").append("feMergeNode").append("feMergeNode",{in:"SourceGraphic"});return this.create("filter",{id:t.id,width:t.width||"200%",height:t.height||"200%"}).append("feGaussianBlur",{in:"SourceAlpha",stdDeviation:t.stdDeviation||3}).append("feOffset",t.offset).append(e)},append:function(t,e){if(typeof t=="string"){return this.create(t,e).appendTo(this)}this.element.appendChild(r(t));return this},appendRadialGradient:function(t,e){return this.append(this.createRadialGradient(t,e))},appendLinearGradient:function(t,e){return this.append(this.createLinearGradient(t,e))},appendTo:function(t){r(t).appendChild(this.element);return this},remove:function(t){if(arguments.length==0){this.element.parentNode.removeChild(this.element)}else{this.element.removeChild(r(t))}return this},empty:function(){var t=this.element;while(t.lastChild){t.removeChild(t.lastChild)}return this},getById:function(t){var e=this.element.ownerDocument.getElementById(t);return e&&new i(e)},text:function(t){if(arguments.length<1){return this.element.firstChild&&this.element.firstChild.data||""}if(this.element.firstChild){}else{var e=this.element.ownerDocument.createTextNode(t);this.element.appendChild(e)}return this},clipText:function(t){if(this.element.getComputedTextLength()>t){this.attr("title",this.text()).cutText(t)}},splitTextByWord:function(t,e,r){var n=this.element;var a=n.getAttributeNS(null,"x");var s=t.split(" ");n.removeChild(n.firstChild);var h=this.create("tspan").text(s[0]).appendTo(n);var l=n.getBBox().height;if(h.element.getComputedTextLength()>e||l>r){var o=n.firstChild.firstChild;n.removeChild(n.firstChild);n.appendChild(o);if(l>r){while(n.getBBox().height>r){n.removeChild(n.lastChild);if(!n.lastChild){return this}}}return this.cutText(e)}for(var u=1;u<s.length;u++){var d=h.element.firstChild;var f=d.data.length;d.data+=" "+s[u];if(h.element.getComputedTextLength()>e){d.data=d.data.slice(0,f);h=this.create("tspan",{x:a,dy:l}).text(s[u]).appendTo(n);if(n.getBBox().height>r){while(n.getBBox().height>r){n.removeChild(n.lastChild);if(!n.lastChild){return this}}i(n.lastChild).cutText(e);return this}if(n.lastChild.getComputedTextLength()>e){i(n.lastChild).cutText(e);return this}}}return this},cutText:function(t){var e=this.element;var i=e.firstChild.data;var r=e.firstChild;for(var n=i.length;n>0;n--){r.data=i.substring(0,n)+"...";if(e.getComputedTextLength()<t){break}}if(e.getComputedTextLength()>t){e.removeChild(r)}return this},getBBox:function(){return this.element.getBBox()},appendStops:function(t){if(!t){return this}t.forEach(function(t){this.create("stop",t).appendTo(this)},this);return this},addClass:function(){var t=Array.prototype.slice.call(arguments);if(u8.tools.isArray(t[0])){t=t[0]}if(!t.length){return this}var e=" "+this.attr("class")+" ";t.forEach(function(t){if(e.indexOf(" "+t+" ")>=0){return}e+=t+" "});this.attr("class",e.trim())},removeClass:function(){var t=Array.prototype.slice.call(arguments);if(u8.tools.isArray(t[0])){t=t[0]}if(!t.length){return this}var e=" "+this.attr("class")+" ";t.forEach(function(t){e=e.replace(" "+t+" "," ")});this.attr("class",e.trim())}})})();