svgedit={NS:{HTML:"http://www.w3.org/1999/xhtml",MATH:"http://www.w3.org/1998/Math/MathML",SE:"http://svg-edit.googlecode.com",SVG:"http://www.w3.org/2000/svg",XLINK:"http://www.w3.org/1999/xlink",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"}};svgedit.getReverseNS=function(){var a={};$.each(this.NS,function(t,j){a[j]=t.toLowerCase()});return a};(function(){var a=jQuery.fn.attr;jQuery.fn.attr=function(t,j){var c,d=this.length;if(!d)return a.apply(this,arguments);for(c=0;cm-15)s=m-15;if(F>A-30)F=A-30;t.unbind("click");h.css({top:F,left:s}).fadeIn(j.inSpeed);h.find("A").mouseover(function(){h.find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){h.find("LI.hover").removeClass("hover")});t.keypress(function(i){switch(i.keyCode){case 38:if(h.find("LI.hover").length){h.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover");
h.find("LI.hover").length||h.find("LI:last").addClass("hover")}else h.find("LI:last").addClass("hover");break;case 40:if(h.find("LI.hover").length==0)h.find("LI:first").addClass("hover");else{h.find("LI.hover").removeClass("hover").nextAll("LI:not(.disabled)").eq(0).addClass("hover");h.find("LI.hover").length||h.find("LI:first").addClass("hover")}break;case 13:h.find("LI.hover A").trigger("click");break;case 27:t.trigger("click")}});h.find("A").unbind("mouseup");h.find("LI:not(.disabled) A").mouseup(function(){t.unbind("click").unbind("keypress");
$(".contextMenu").hide();c&&c($(this).attr("href").substr(1),$(z),{x:s-l.left,y:F-l.top,docX:s,docY:F});return false});setTimeout(function(){t.click(function(){t.unbind("click").unbind("keypress");h.fadeOut(j.outSpeed);return false})},0)}})});if($.browser.mozilla)$("#"+j.menu).each(function(){$(this).css({MozUserSelect:"none"})});else $.browser.msie?$("#"+j.menu).each(function(){$(this).bind("selectstart.disableTextSelect",function(){return false})}):$("#"+j.menu).each(function(){$(this).bind("mousedown.disableTextSelect",
function(){return false})});$(d).add($("UL.contextMenu")).bind("contextmenu",function(){return false})});return $(this)},disableContextMenuItems:function(j){if(j==undefined){$(this).find("LI").addClass("disabled");return $(this)}$(this).each(function(){if(j!=undefined)for(var c=j.split(","),d=0;d=this.numberOfItems)throw"INDEX_SIZE_ERR";
};SVGPathSegList.prototype.getItem=function(a){this._checkPathSynchronizedToList();this._checkValidIndex(a);return this._list[a]};SVGPathSegList.prototype.insertItemBefore=function(a,t){this._checkPathSynchronizedToList();if(t>this.numberOfItems)t=this.numberOfItems;if(a._owningPathSegList)a=a.clone();this._list.splice(t,0,a);a._owningPathSegList=this;this._writeListToPath();return a};SVGPathSegList.prototype.replaceItem=function(a,t){this._checkPathSynchronizedToList();if(a._owningPathSegList)a=
a.clone();this._checkValidIndex(t);this._list[t]=a;a._owningPathSegList=this;this._writeListToPath();return a};SVGPathSegList.prototype.removeItem=function(a){this._checkPathSynchronizedToList();this._checkValidIndex(a);var t=this._list[a];this._list.splice(a,1);this._writeListToPath();return t};SVGPathSegList.prototype.appendItem=function(a){this._checkPathSynchronizedToList();if(a._owningPathSegList)a=a.clone();this._list.push(a);a._owningPathSegList=this;this._writeListToPath();return a};SVGPathSegList._pathSegArrayAsString=
function(a){var t="",j=true;a.forEach(function(c){if(j){j=false;t+=c._asPathString()}else t+=" "+c._asPathString()});return t};SVGPathSegList.prototype._parsePath=function(a){if(!a||a.length==0)return[];var t=this,j=function(){this.pathSegList=[]};j.prototype.appendSegment=function(d){this.pathSegList.push(d)};var c=function(d){this._string=d;this._currentIndex=0;this._endIndex=this._string.length;this._previousCommand=SVGPathSeg.PATHSEG_UNKNOWN;this._skipOptionalSpaces()};c.prototype._isCurrentSpace=
function(){var d=this._string[this._currentIndex];return d<=" "&&(d==" "||d=="\n"||d=="\t"||d=="\r"||d=="\u000c")};c.prototype._skipOptionalSpaces=function(){for(;this._currentIndex="0"&&d<="9")&&l!=SVGPathSeg.PATHSEG_CLOSEPATH){if(l==
SVGPathSeg.PATHSEG_MOVETO_ABS)return SVGPathSeg.PATHSEG_LINETO_ABS;if(l==SVGPathSeg.PATHSEG_MOVETO_REL)return SVGPathSeg.PATHSEG_LINETO_REL;return l}return SVGPathSeg.PATHSEG_UNKNOWN};c.prototype.initialCommandIsMoveTo=function(){if(!this.hasMoreData())return true;var d=this.peekSegmentType();return d==SVGPathSeg.PATHSEG_MOVETO_ABS||d==SVGPathSeg.PATHSEG_MOVETO_REL};c.prototype._parseNumber=function(){var d=0,l=0,h=1,o=0,m=1,z=1,s=this._currentIndex;this._skipOptionalSpaces();if(this._currentIndex<
this._endIndex&&this._string.charAt(this._currentIndex)=="+")this._currentIndex++;else if(this._currentIndex"9")&&this._string.charAt(this._currentIndex)!=".")){for(var F=this._currentIndex;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<=
"9";)this._currentIndex++;if(this._currentIndex!=F)for(var A=this._currentIndex-1,i=1;A>=F;){l+=i*(this._string.charAt(A--)-"0");i*=10}if(this._currentIndex=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<=
"9";)o+=(this._string.charAt(this._currentIndex++)-"0")*(h*=0.1)}if(this._currentIndex!=s&&this._currentIndex+1=
this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";){d*=10;d+=this._string.charAt(this._currentIndex)-"0";this._currentIndex++}}l=l+o;l*=m;if(d)l*=Math.pow(10,z*d);if(s!=this._currentIndex){this._skipOptionalSpacesOrDelimiter();return l}}};c.prototype._parseArcFlag=function(){if(!(this._currentIndex>=this._endIndex)){var d=
false;d=this._string.charAt(this._currentIndex++);if(d=="0")d=false;else if(d=="1")d=true;else return;this._skipOptionalSpacesOrDelimiter();return d}};c.prototype.parseSegment=function(){var d=this._string[this._currentIndex],l=this._pathSegTypeFromChar(d);if(l==SVGPathSeg.PATHSEG_UNKNOWN){if(this._previousCommand==SVGPathSeg.PATHSEG_UNKNOWN)return null;l=this._nextCommandHelper(d,this._previousCommand);if(l==SVGPathSeg.PATHSEG_UNKNOWN)return null}else this._currentIndex++;this._previousCommand=l;
switch(l){case SVGPathSeg.PATHSEG_MOVETO_REL:return new SVGPathSegMovetoRel(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_MOVETO_ABS:return new SVGPathSegMovetoAbs(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_REL:return new SVGPathSegLinetoRel(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_ABS:return new SVGPathSegLinetoAbs(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:return new SVGPathSegLinetoHorizontalRel(t,
this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:return new SVGPathSegLinetoHorizontalAbs(t,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:return new SVGPathSegLinetoVerticalRel(t,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:return new SVGPathSegLinetoVerticalAbs(t,this._parseNumber());case SVGPathSeg.PATHSEG_CLOSEPATH:this._skipOptionalSpaces();return new SVGPathSegClosePath(t);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:d={x1:this._parseNumber(),
y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicRel(t,d.x,d.y,d.x1,d.y1,d.x2,d.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:d={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicAbs(t,d.x,d.y,d.x1,d.y1,d.x2,d.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:d={x2:this._parseNumber(),
y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothRel(t,d.x,d.y,d.x2,d.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:d={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothAbs(t,d.x,d.y,d.x2,d.y2);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:d={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticRel(t,
d.x,d.y,d.x1,d.y1);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:d={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticAbs(t,d.x,d.y,d.x1,d.y1);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:return new SVGPathSegCurvetoQuadraticSmoothRel(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:return new SVGPathSegCurvetoQuadraticSmoothAbs(t,this._parseNumber(),this._parseNumber());
case SVGPathSeg.PATHSEG_ARC_REL:d={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegArcRel(t,d.x,d.y,d.x1,d.y1,d.arcAngle,d.arcLarge,d.arcSweep);case SVGPathSeg.PATHSEG_ARC_ABS:d={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};
return new SVGPathSegArcAbs(t,d.x,d.y,d.x1,d.y1,d.arcAngle,d.arcLarge,d.arcSweep);default:throw"Unknown path seg type.";}};j=new j;a=new c(a);if(!a.initialCommandIsMoveTo())return[];for(;a.hasMoreData();){c=a.parseSegment();if(!c)return[];j.appendSegment(c)}return j.pathSegList};Object.defineProperty(SVGPathElement.prototype,"pathSegList",{get:function(){if(!this._pathSegList)this._pathSegList=new SVGPathSegList(this);return this._pathSegList},enumerable:true});Object.defineProperty(SVGPathElement.prototype,
"normalizedPathSegList",{get:function(){return this.pathSegList},enumerable:true});Object.defineProperty(SVGPathElement.prototype,"animatedPathSegList",{get:function(){return this.pathSegList},enumerable:true});Object.defineProperty(SVGPathElement.prototype,"animatedNormalizedPathSegList",{get:function(){return this.pathSegList},enumerable:true})}})();(function(){if(!svgedit.browser)svgedit.browser={};var a=svgedit.NS,t=!!document.createElementNS&&!!document.createElementNS(a.SVG,"svg").createSVGRect;svgedit.browser.supportsSvg=function(){return t};if(svgedit.browser.supportsSvg()){var j=navigator.userAgent,c=document.createElementNS(a.SVG,"svg"),d=!!window.opera,l=j.indexOf("AppleWebKit")>=0,h=j.indexOf("Gecko/")>=0,o=j.indexOf("MSIE")>=0,m=j.indexOf("Chrome/")>=0,z=j.indexOf("Windows")>=0,s=j.indexOf("Macintosh")>=0,F="ontouchstart"in window,
A=!!c.querySelector,i=!!document.evaluate,B=function(){var ba=document.createElementNS(a.SVG,"path");ba.setAttribute("d","M0,0 10,10");var ia=ba.pathSegList;ba=ba.createSVGPathSegLinetoAbs(5,5);try{ia.replaceItem(ba,0);return true}catch(Pa){}return false}(),u=function(){var ba=document.createElementNS(a.SVG,"path");ba.setAttribute("d","M0,0 10,10");var ia=ba.pathSegList;ba=ba.createSVGPathSegLinetoAbs(5,5);try{ia.insertItemBefore(ba,0);return true}catch(Pa){}return false}(),v=function(){var ba=document.createElementNS(a.SVG,
"svg"),ia=document.createElementNS(a.SVG,"svg");document.documentElement.appendChild(ba);ia.setAttribute("x",5);ba.appendChild(ia);var Pa=document.createElementNS(a.SVG,"text");Pa.textContent="a";ia.appendChild(Pa);ia=Pa.getStartPositionOfChar(0).x;document.documentElement.removeChild(ba);return ia===0}(),r=function(){var ba=document.createElementNS(a.SVG,"svg");document.documentElement.appendChild(ba);var ia=document.createElementNS(a.SVG,"path");ia.setAttribute("d","M0,0 C0,0 10,10 10,0");ba.appendChild(ia);
ia=ia.getBBox();document.documentElement.removeChild(ba);return ia.height>4&&ia.height<5}(),O=function(){var ba=document.createElementNS(a.SVG,"svg");document.documentElement.appendChild(ba);var ia=document.createElementNS(a.SVG,"path");ia.setAttribute("d","M0,0 10,0");var Pa=document.createElementNS(a.SVG,"path");Pa.setAttribute("d","M5,0 15,0");var Ca=document.createElementNS(a.SVG,"g");Ca.appendChild(ia);Ca.appendChild(Pa);ba.appendChild(Ca);ia=Ca.getBBox();document.documentElement.removeChild(ba);
return ia.width==15}(),Z=function(){var ba=document.createElementNS(a.SVG,"rect");ba.setAttribute("x",0.1);(ba=ba.cloneNode(false).getAttribute("x").indexOf(",")==-1)||$.alert('NOTE: This version of Opera is known to contain bugs in SVG-edit.\nPlease upgrade to the latest version in which the problems have been fixed.');return ba}(),ka=function(){var ba=document.createElementNS(a.SVG,"rect");ba.setAttribute("style","vector-effect:non-scaling-stroke");return ba.style.vectorEffect===
"non-scaling-stroke"}(),ea=function(){var ba=document.createElementNS(a.SVG,"rect").transform.baseVal,ia=c.createSVGTransform();ba.appendItem(ia);return ba.getItem(0)==ia}();svgedit.browser.isOpera=function(){return d};svgedit.browser.isWebkit=function(){return l};svgedit.browser.isGecko=function(){return h};svgedit.browser.isIE=function(){return o};svgedit.browser.isChrome=function(){return m};svgedit.browser.isWindows=function(){return z};svgedit.browser.isMac=function(){return s};svgedit.browser.isTouch=
function(){return F};svgedit.browser.supportsSelectors=function(){return A};svgedit.browser.supportsXpath=function(){return i};svgedit.browser.supportsPathReplaceItem=function(){return B};svgedit.browser.supportsPathInsertItemBefore=function(){return u};svgedit.browser.supportsPathBBox=function(){return r};svgedit.browser.supportsHVLineContainerBBox=function(){return O};svgedit.browser.supportsGoodTextCharPos=function(){return v};svgedit.browser.supportsEditableText=function(){return d};svgedit.browser.supportsGoodDecimals=
function(){return Z};svgedit.browser.supportsNonScalingStroke=function(){return ka};svgedit.browser.supportsNativeTransformLists=function(){return ea}}else window.location="browser-not-supported.html"})();(function(){if(!svgedit.transformlist)svgedit.transformlist={};var a=document.createElementNS(svgedit.NS.SVG,"svg"),t={};svgedit.transformlist.SVGTransformList=function(j){this._elem=j||null;this._xforms=[];this._update=function(){var c="";a.createSVGMatrix();var d;for(d=0;d=0)return this._xforms[c];throw{code:1};};this.insertItemBefore=function(c,d){var l=null;if(d>=0)if(d=0){this._removeFromOtherLists(c);l=this._xforms[d]=c;this._list._update()}return l};this.removeItem=function(c){if(c=0){var d=this._xforms[c],l=Array(this.numberOfItems-1),h;for(h=0;h1;)c=t[j-1].multiply(c);if(Math.abs(c.a)<1.0E-14)c.a=0;if(Math.abs(c.b)<1.0E-14)c.b=0;if(Math.abs(c.c)<1.0E-14)c.c=0;if(Math.abs(c.d)<
1.0E-14)c.d=0;if(Math.abs(c.e)<1.0E-14)c.e=0;if(Math.abs(c.f)<1.0E-14)c.f=0;return c};svgedit.math.hasMatrixTransform=function(t){if(!t)return false;for(var j=t.numberOfItems;j--;){var c=t.getItem(j);if(c.type==1&&!svgedit.math.isIdentity(c.matrix))return true}return false};svgedit.math.transformBox=function(t,j,c,d,l){var h=svgedit.math.transformPoint,o=h(t,j,l),m=h(t+c,j,l),z=h(t,j+d,l);t=h(t+c,j+d,l);j=Math.min(o.x,m.x,z.x,t.x);c=Math.min(o.y,m.y,z.y,t.y);return{tl:o,tr:m,bl:z,br:t,aabox:{x:j,
y:c,width:Math.max(o.x,m.x,z.x,t.x)-j,height:Math.max(o.y,m.y,z.y,t.y)-c}}};svgedit.math.transformListToTransform=function(t,j,c){if(t==null)return a.createSVGTransformFromMatrix(a.createSVGMatrix());j=j||0;c=c||t.numberOfItems-1;j=parseInt(j,10);c=parseInt(c,10);if(j>c){var d=c;c=j;j=d}d=a.createSVGMatrix();for(j=j;j<=c;++j){var l=j>=0&&jt.x&&j.yt.y}})();(function(){if(!svgedit.units)svgedit.units={};var a=svgedit.NS,t=["x","x1","cx","rx","width"],j=["y","y1","cy","ry","height"],c=["r","radius"].concat(t,j),d,l={};svgedit.units.init=function(o){d=o;o=document.createElementNS(a.SVG,"svg");document.body.appendChild(o);var m=document.createElementNS(a.SVG,"rect");m.setAttribute("width","1em");m.setAttribute("height","1ex");m.setAttribute("x","1in");o.appendChild(m);m=m.getBBox();document.body.removeChild(o);o=m.x;l={em:m.width,ex:m.height,"in":o,cm:o/
2.54,mm:o/25.4,pt:o/72,pc:o/6,px:1,"%":0}};svgedit.units.getTypeMap=function(){return l};svgedit.units.shortFloat=function(o){var m=d.getRoundDigits();if(!isNaN(o))return+(+o).toFixed(m);if($.isArray(o))return svgedit.units.shortFloat(o[0])+","+svgedit.units.shortFloat(o[1]);return parseFloat(o).toFixed(m)-0};svgedit.units.convertUnit=function(o,m){m=m||d.getBaseUnit();return svgedit.units.shortFloat(o/l[m])};svgedit.units.setUnitAttr=function(o,m,z){o.setAttribute(m,z)};var h={line:["x1","x2","y1",
"y2"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],foreignObject:["x","y","width","height"],rect:["x","y","width","height"],image:["x","y","width","height"],use:["x","y","width","height"],text:["x","y"]};svgedit.units.convertAttrs=function(o){var m=o.tagName,z=d.getBaseUnit();if(m=h[m]){var s=m.length,F;for(F=0;F=0)return z*s;if(j.indexOf(o)>=0)return z*F;return z*Math.sqrt(s*s+F*F)/Math.sqrt(2)}s=m.substr(-2);z=m.substr(0,m.length-2);return z*l[s]};svgedit.units.isValidUnit=function(o,m,z){var s=false;if(c.indexOf(o)>=0)if(isNaN(m)){m=m.toLowerCase();$.each(l,function(i){if(!s)if(RegExp("^-?[\\d\\.]+"+i+"$").test(m))s=true})}else s=true;else if(o=="id"){o=false;try{var F=d.getElement(m);o=F==null||F===z}catch(A){}return o}return s=
true}})();(function(a){function t(m){if(svgedit.browser.supportsHVLineContainerBBox())try{return m.getBBox()}catch(z){}var s=$.data(m,"ref"),F=null,A;if(s){A=$(s).children().clone().attr("visibility","hidden");$(o).append(A);F=A.filter("line, path")}else F=$(m).find("line, path");var i=false;if(F.length){F.each(function(){var B=this.getBBox();if(!B.width||!B.height)i=true});if(i){m=s?A:$(m).children();m=getStrokedBBox(m)}else m=m.getBBox()}else m=m.getBBox();s&&A.remove();return m}if(!svgedit.utilities)svgedit.utilities=
{};var j=svgedit.NS,c="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),d=null,l=null,h=null,o=null;svgedit.utilities.init=function(m){d=m;l=m.getDOMDocument();h=m.getDOMContainer();o=m.getSVGRoot()};svgedit.utilities.toXml=function(m){return m.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/,"'")};svgedit.utilities.fromXml=function(m){return $("").html(m).text()};svgedit.utilities.encode64=
function(m){m=svgedit.utilities.encodeUTF8(m);if(window.btoa)return window.btoa(m);var z=[];z.length=Math.floor((m.length+2)/3)*4;var s,F,A,i,B,u,v=0,r=0;do{s=m.charCodeAt(v++);F=m.charCodeAt(v++);A=m.charCodeAt(v++);i=s>>2;s=(s&3)<<4|F>>4;B=(F&15)<<2|A>>6;u=A&63;if(isNaN(F))B=u=64;else if(isNaN(A))u=64;z[r++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(i);z[r++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(s);z[r++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(B);
z[r++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(u)}while(v>4;F=(F&15)<<4|i>>2;A=(i&3)<<6|B;z+=String.fromCharCode(s);if(i!=64)z+=String.fromCharCode(F);if(B!=64)z+=String.fromCharCode(A)}while(u127)s+=""+F+";"}return s};svgedit.utilities.text2xml=function(m){if(m.indexOf("=0)m=m.replace(/<(\/?)svg:/g,"<$1").replace("xmlns:svg","xmlns");var z,s;try{s=window.DOMParser?new DOMParser:new ActiveXObject("Microsoft.XMLDOM");s.async=false}catch(F){throw Error("XML Parser could not be instantiated");}try{z=s.loadXML?s.loadXML(m)?s:false:s.parseFromString(m,"text/xml")}catch(A){throw Error("Error parsing XML string");
}return z};svgedit.utilities.bboxToObj=function(m){return{x:m.x,y:m.y,width:m.width,height:m.height}};svgedit.utilities.walkTree=function(m,z){if(m&&m.nodeType==1){z(m);for(var s=m.childNodes.length;s--;)svgedit.utilities.walkTree(m.childNodes.item(s),z)}};svgedit.utilities.walkTreePost=function(m,z){if(m&&m.nodeType==1){for(var s=m.childNodes.length;s--;)svgedit.utilities.walkTree(m.childNodes.item(s),z);z(m)}};svgedit.utilities.getUrlFromAttr=function(m){if(m){if(m.indexOf('url("')===0)return m.substring(5,
m.indexOf('"',6));if(m.indexOf("url('")===0)return m.substring(5,m.indexOf("'",6));if(m.indexOf("url(")===0)return m.substring(4,m.indexOf(")"))}return null};svgedit.utilities.getHref=function(m){return m.getAttributeNS(j.XLINK,"href")};svgedit.utilities.setHref=function(m,z){m.setAttributeNS(j.XLINK,"xlink:href",z)};svgedit.utilities.findDefs=function(){var m=d.getSVGContent(),z=m.getElementsByTagNameNS(j.SVG,"defs");if(z.length>0)z=z[0];else{z=m.ownerDocument.createElementNS(j.SVG,"defs");m.firstChild?
m.insertBefore(z,m.firstChild.nextSibling):m.appendChild(z)}return z};svgedit.utilities.getPathBBox=function(m){var z=m.pathSegList,s=z.numberOfItems;m=[[],[]];var F=z.getItem(0),A=[F.x,F.y];for(F=0;F|:\\"+(z||"")+"-]","g"),"\\$&")};svgedit.utilities.executeAfterLoads=function(m,z,s){return function(){function F(){s.apply(null,
A)}var A=arguments;window[m]?F():z.reduceRight(function(i,B){return function(){$.getScript(B,i)}},F)()}};svgedit.utilities.buildCanvgCallback=function(m){return svgedit.utilities.executeAfterLoads("canvg",["canvg/rgbcolor.js","canvg/canvg.js"],m)};svgedit.utilities.buildJSPDFCallback=function(m){return svgedit.utilities.executeAfterLoads("RGBColor",["canvg/rgbcolor.js"],function(){var z=[];if(!RGBColor||RGBColor.ok===a)z.push("canvg/rgbcolor.js");svgedit.utilities.executeAfterLoads("jsPDF",z.concat("jspdf/underscore-min.js",
"jspdf/jspdf.min.js","jspdf/jspdf.plugin.svgToPdf.js"),m)()})}})();(function(){if(!svgedit.sanitize)svgedit.sanitize={};var a=svgedit.NS,t=svgedit.getReverseNS(),j={a:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","mask","opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","xlink:href","xlink:title"],circle:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask",
"opacity","r","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],clipPath:["class","clipPathUnits","id"],defs:[],style:["type"],desc:[],ellipse:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin",
"stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],feGaussianBlur:["class","color-interpolation-filters","id","requiredFeatures","stdDeviation"],filter:["class","color-interpolation-filters","filterRes","filterUnits","height","id","primitiveUnits","requiredFeatures","width","x","xlink:href","y"],foreignObject:["class","font-size","height","id","opacity","requiredFeatures","style","transform","width","x","y"],g:["class","clip-path","clip-rule","id","display",
"fill","fill-opacity","fill-rule","filter","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","font-family","font-size","font-style","font-weight","text-anchor"],image:["class","clip-path","clip-rule","filter","height","id","mask","opacity","requiredFeatures","style","systemLanguage","transform","width","x","xlink:href","xlink:title","y"],line:["class",
"clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","x1","x2","y1","y2"],linearGradient:["class","id","gradientTransform","gradientUnits","requiredFeatures","spreadMethod","systemLanguage","x1","x2","xlink:href","y1","y2"],marker:["id",
"class","markerHeight","markerUnits","markerWidth","orient","preserveAspectRatio","refX","refY","systemLanguage","viewBox"],mask:["class","height","id","maskContentUnits","maskUnits","width","x","y"],metadata:["class","id"],path:["class","clip-path","clip-rule","d","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity",
"stroke-width","style","systemLanguage","transform"],pattern:["class","height","id","patternContentUnits","patternTransform","patternUnits","requiredFeatures","style","systemLanguage","viewBox","width","x","xlink:href","y"],polygon:["class","clip-path","clip-rule","id","fill","fill-opacity","fill-rule","filter","id","class","marker-end","marker-mid","marker-start","mask","opacity","points","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit",
"stroke-opacity","stroke-width","style","systemLanguage","transform"],polyline:["class","clip-path","clip-rule","id","fill","fill-opacity","fill-rule","filter","marker-end","marker-mid","marker-start","mask","opacity","points","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],radialGradient:["class","cx","cy","fx","fy","gradientTransform","gradientUnits","id",
"r","requiredFeatures","spreadMethod","systemLanguage","xlink:href"],rect:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","height","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","width","x","y"],stop:["class","id","offset","requiredFeatures","stop-color","stop-opacity","style","systemLanguage"],svg:["class",
"clip-path","clip-rule","filter","id","height","mask","preserveAspectRatio","requiredFeatures","style","systemLanguage","viewBox","width","x","xmlns","xmlns:se","xmlns:xlink","y"],"switch":["class","id","requiredFeatures","systemLanguage"],symbol:["class","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","opacity","preserveAspectRatio","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit",
"stroke-opacity","stroke-width","style","systemLanguage","transform","viewBox"],text:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","text-anchor","transform","x","xml:space","y"],textPath:["class","id","method","requiredFeatures",
"spacing","startOffset","style","systemLanguage","transform","xlink:href"],title:[],tspan:["class","clip-path","clip-rule","dx","dy","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","mask","opacity","requiredFeatures","rotate","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","text-anchor","textLength","transform","x","xml:space","y"],use:["class",
"clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","height","id","mask","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","transform","width","x","xlink:href","y"],annotation:["encoding"],"annotation-xml":["encoding"],maction:["actiontype","other","selection"],math:["class","id","display","xmlns"],menclose:["notation"],merror:[],mfrac:["linethickness"],mi:["mathvariant"],mmultiscripts:[],mn:[],
mo:["fence","lspace","maxsize","minsize","rspace","stretchy"],mover:[],mpadded:["lspace","width","height","depth","voffset"],mphantom:[],mprescripts:[],mroot:[],mrow:["xlink:href","xlink:type","xmlns:xlink"],mspace:["depth","height","width"],msqrt:[],mstyle:["displaystyle","mathbackground","mathcolor","mathvariant","scriptlevel"],msub:[],msubsup:[],msup:[],mtable:["align","columnalign","columnlines","columnspacing","displaystyle","equalcolumns","equalrows","frame","rowalign","rowlines","rowspacing",
"width"],mtd:["columnalign","columnspan","rowalign","rowspan"],mtext:[],mtr:["columnalign","rowalign"],munder:[],munderover:[],none:[],semantics:[]},c={};$.each(j,function(d,l){var h={};$.each(l,function(o,m){if(m.indexOf(":")>=0){var z=m.split(":");h[z[1]]=a[z[0].toUpperCase()]}else h[m]=m=="xmlns"?a.XMLNS:null});c[d]=h});svgedit.sanitize.sanitizeSvg=function(d){if(d.nodeType==3){d.nodeValue=d.nodeValue.replace(/^\s+|\s+$/g,"");d.nodeValue.length===0&&d.parentNode.removeChild(d)}if(d.nodeType==1){var l=
d.parentNode;if(d.ownerDocument&&l){var h=j[d.nodeName],o=c[d.nodeName],m;if(typeof h!=="undefined"){var z=[];for(m=d.attributes.length;m--;){var s=d.attributes.item(m),F=s.nodeName,A=s.localName,i=s.namespaceURI;if(!(o.hasOwnProperty(A)&&i==o[A]&&i!=a.XMLNS)&&!(i==a.XMLNS&&t[s.value])){F.indexOf("se:")===0&&z.push([F,s.value]);d.removeAttributeNS(i,A)}if(svgedit.browser.isGecko())switch(F){case "transform":case "gradientTransform":case "patternTransform":A=s.value.replace(/(\d)-/g,"$1 -");d.setAttribute(F,
A)}if(F=="style"){s=s.value.split(";");for(F=s.length;F--;){i=s[F].split(":");A=$.trim(i[0]);i=$.trim(i[1]);h.indexOf(A)>=0&&d.setAttribute(A,i)}d.removeAttribute("style")}}$.each(z,function(B,u){d.setAttributeNS(a.SE,u[0],u[1])});if((m=svgedit.utilities.getHref(d))&&["filter","linearGradient","pattern","radialGradient","textPath","use"].indexOf(d.nodeName)>=0)if(m[0]!="#"){svgedit.utilities.setHref(d,"");d.removeAttributeNS(a.XLINK,"href")}if(d.nodeName=="use"&&!svgedit.utilities.getHref(d))l.removeChild(d);
else{$.each(["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],function(B,u){var v=d.getAttribute(u);if(v)if((v=svgedit.utilities.getUrlFromAttr(v))&&v[0]!=="#"){d.setAttribute(u,"");d.removeAttribute(u)}});for(m=d.childNodes.length;m--;)svgedit.sanitize.sanitizeSvg(d.childNodes.item(m))}}else{for(h=[];d.hasChildNodes();)h.push(l.insertBefore(d.firstChild,d));l.removeChild(d);for(m=h.length;m--;)svgedit.sanitize.sanitizeSvg(h[m])}}}}})();(function(){if(!svgedit.history)svgedit.history={};svgedit.history.HistoryEventTypes={BEFORE_APPLY:"before_apply",AFTER_APPLY:"after_apply",BEFORE_UNAPPLY:"before_unapply",AFTER_UNAPPLY:"after_unapply"};svgedit.history.MoveElementCommand=function(a,t,j,c){this.elem=a;this.text=c?"Move "+a.tagName+" to "+c:"Move "+a.tagName;this.oldNextSibling=t;this.oldParent=j;this.newNextSibling=a.nextSibling;this.newParent=a.parentNode};svgedit.history.MoveElementCommand.type=function(){return"svgedit.history.MoveElementCommand"};
svgedit.history.MoveElementCommand.prototype.type=svgedit.history.MoveElementCommand.type;svgedit.history.MoveElementCommand.prototype.getText=function(){return this.text};svgedit.history.MoveElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);this.elem=this.newParent.insertBefore(this.elem,this.newNextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)};svgedit.history.MoveElementCommand.prototype.unapply=
function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);this.elem=this.oldParent.insertBefore(this.elem,this.oldNextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.MoveElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.InsertElementCommand=function(a,t){this.elem=a;this.text=t||"Create "+a.tagName;this.parent=a.parentNode;this.nextSibling=this.elem.nextSibling};svgedit.history.InsertElementCommand.type=
function(){return"svgedit.history.InsertElementCommand"};svgedit.history.InsertElementCommand.prototype.type=svgedit.history.InsertElementCommand.type;svgedit.history.InsertElementCommand.prototype.getText=function(){return this.text};svgedit.history.InsertElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);this.elem=this.parent.insertBefore(this.elem,this.nextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,
this)};svgedit.history.InsertElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);this.parent=this.elem.parentNode;this.elem=this.elem.parentNode.removeChild(this.elem);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.InsertElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.RemoveElementCommand=function(a,t,j,c){this.elem=a;this.text=c||"Delete "+a.tagName;
this.nextSibling=t;this.parent=j;svgedit.transformlist.removeElementFromListMap(a)};svgedit.history.RemoveElementCommand.type=function(){return"svgedit.history.RemoveElementCommand"};svgedit.history.RemoveElementCommand.prototype.type=svgedit.history.RemoveElementCommand.type;svgedit.history.RemoveElementCommand.prototype.getText=function(){return this.text};svgedit.history.RemoveElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);
svgedit.transformlist.removeElementFromListMap(this.elem);this.parent=this.elem.parentNode;this.elem=this.parent.removeChild(this.elem);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)};svgedit.history.RemoveElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);svgedit.transformlist.removeElementFromListMap(this.elem);this.nextSibling==null&&window.console&&console.log("Error: reference element was lost");
this.parent.insertBefore(this.elem,this.nextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.RemoveElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.ChangeElementCommand=function(a,t,j){this.elem=a;this.text=j?"Change "+a.tagName+" "+j:"Change "+a.tagName;this.newValues={};this.oldValues=t;for(var c in t)this.newValues[c]=c=="#text"?a.textContent:c=="#href"?svgedit.utilities.getHref(a):a.getAttribute(c)};svgedit.history.ChangeElementCommand.type=
function(){return"svgedit.history.ChangeElementCommand"};svgedit.history.ChangeElementCommand.prototype.type=svgedit.history.ChangeElementCommand.type;svgedit.history.ChangeElementCommand.prototype.getText=function(){return this.text};svgedit.history.ChangeElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);var t=false,j;for(j in this.newValues){if(this.newValues[j])if(j=="#text")this.elem.textContent=this.newValues[j];else j=="#href"?
svgedit.utilities.setHref(this.elem,this.newValues[j]):this.elem.setAttribute(j,this.newValues[j]);else if(j=="#text")this.elem.textContent="";else{this.elem.setAttribute(j,"");this.elem.removeAttribute(j)}if(j=="transform")t=true}if(!t)if(t=svgedit.utilities.getRotationAngle(this.elem)){j=elem.getBBox();t=["rotate(",t," ",j.x+j.width/2,",",j.y+j.height/2,")"].join("");t!=elem.getAttribute("transform")&&elem.setAttribute("transform",t)}a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,
this);return true};svgedit.history.ChangeElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);var t=false,j;for(j in this.oldValues){if(this.oldValues[j])if(j=="#text")this.elem.textContent=this.oldValues[j];else j=="#href"?svgedit.utilities.setHref(this.elem,this.oldValues[j]):this.elem.setAttribute(j,this.oldValues[j]);else if(j=="#text")this.elem.textContent="";else this.elem.removeAttribute(j);if(j=="transform")t=true}if(!t)if(t=
svgedit.utilities.getRotationAngle(this.elem)){j=elem.getBBox();t=["rotate(",t," ",j.x+j.width/2,",",j.y+j.height/2,")"].join("");t!=elem.getAttribute("transform")&&elem.setAttribute("transform",t)}svgedit.transformlist.removeElementFromListMap(this.elem);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this);return true};svgedit.history.ChangeElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.BatchCommand=function(a){this.text=a||"Batch Command";
this.stack=[]};svgedit.history.BatchCommand.type=function(){return"svgedit.history.BatchCommand"};svgedit.history.BatchCommand.prototype.type=svgedit.history.BatchCommand.type;svgedit.history.BatchCommand.prototype.getText=function(){return this.text};svgedit.history.BatchCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);var t,j=this.stack.length;for(t=0;t=0;t--)this.stack[t].unapply(a);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.BatchCommand.prototype.elements=function(){for(var a=[],t=this.stack.length;t--;)for(var j=this.stack[t].elements(),c=j.length;c--;)a.indexOf(j[c])==-1&&a.push(j[c]);return a};svgedit.history.BatchCommand.prototype.addSubCommand=
function(a){this.stack.push(a)};svgedit.history.BatchCommand.prototype.isEmpty=function(){return this.stack.length===0};svgedit.history.UndoManager=function(a){this.handler_=a||null;this.undoStackPointer=0;this.undoStack=[];this.undoChangeStackPointer=-1;this.undoableChangeStack=[]};svgedit.history.UndoManager.prototype.resetUndoStack=function(){this.undoStack=[];this.undoStackPointer=0};svgedit.history.UndoManager.prototype.getUndoStackSize=function(){return this.undoStackPointer};svgedit.history.UndoManager.prototype.getRedoStackSize=
function(){return this.undoStack.length-this.undoStackPointer};svgedit.history.UndoManager.prototype.getNextUndoCommandText=function(){return this.undoStackPointer>0?this.undoStack[this.undoStackPointer-1].getText():""};svgedit.history.UndoManager.prototype.getNextRedoCommandText=function(){return this.undoStackPointer0&&this.undoStack[--this.undoStackPointer].unapply(this.handler_)};
svgedit.history.UndoManager.prototype.redo=function(){this.undoStackPointer0&&this.undoStack[this.undoStackPointer++].apply(this.handler_)};svgedit.history.UndoManager.prototype.addCommandToHistory=function(a){if(this.undoStackPointer0)this.undoStack=this.undoStack.splice(0,this.undoStackPointer);this.undoStack.push(a);this.undoStackPointer=this.undoStack.length};svgedit.history.UndoManager.prototype.beginUndoableChange=
function(a,t){for(var j=++this.undoChangeStackPointer,c=t.length,d=Array(c),l=Array(c);c--;){var h=t[c];if(h!=null){l[c]=h;d[c]=h.getAttribute(a)}}this.undoableChangeStack[j]={attrName:a,oldValues:d,elements:l}};svgedit.history.UndoManager.prototype.finishUndoableChange=function(){for(var a=this.undoChangeStackPointer--,t=this.undoableChangeStack[a],j=t.elements.length,c=t.attrName,d=new svgedit.history.BatchCommand("Change "+c);j--;){var l=t.elements[j];if(l!=null){var h={};h[c]=t.oldValues[j];h[c]!=
l.getAttribute(c)&&d.addSubCommand(new svgedit.history.ChangeElementCommand(l,h,c))}}this.undoableChangeStack[a]=null;return d}})();var svgedit=svgedit||{};
(function(){if(!svgedit.coords)svgedit.coords={};var a=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],t=null;svgedit.coords.init=function(j){t=j};svgedit.coords.remapElement=function(j,c,d){var l,h,o=function(B,u){return svgedit.math.transformPoint(B,u,d)},m=t.getGridSnapping()&&j.parentNode.parentNode.localName==="svg",z=function(){var B;if(m)for(B in c)c[B]=svgedit.utilities.snapToGrid(c[B]);svgedit.utilities.assignAttributes(j,c,1E3,true)},s=svgedit.utilities.getBBox(j);
for(l=0;l<2;l++){h=l===0?"fill":"stroke";var F=j.getAttribute(h);if(F&&F.indexOf("url(")===0)if(d.a<0||d.d<0){F=svgedit.utilities.getRefElem(F).cloneNode(true);if(d.a<0){var A=F.getAttribute("x1"),i=F.getAttribute("x2");F.setAttribute("x1",-(A-1));F.setAttribute("x2",-(i-1))}if(d.d<0){A=F.getAttribute("y1");i=F.getAttribute("y2");F.setAttribute("y1",-(A-1));F.setAttribute("y2",-(i-1))}F.id=t.getDrawing().getNextId();svgedit.utilities.findDefs().appendChild(F);j.setAttribute(h,"url(#"+F.id+")")}}l=
j.tagName;if(l==="g"||l==="text"||l=="tspan"||l==="use")if(d.a==1&&d.b==0&&d.c==0&&d.d==1&&(d.e!=0||d.f!=0)){h=svgedit.math.transformListToTransform(j).matrix;h=svgedit.math.matrixMultiply(h.inverse(),d,h);c.x=parseFloat(c.x)+h.e;c.y=parseFloat(c.y)+h.f}else{h=svgedit.transformlist.getTransformList(j);F=svgroot.createSVGTransform();F.setMatrix(svgedit.math.matrixMultiply(svgedit.math.transformListToTransform(h).matrix,d));h.clear();h.appendItem(F)}switch(l){case "foreignObject":case "rect":case "image":if(l===
"image"&&(d.a<0||d.d<0)){h=svgedit.transformlist.getTransformList(j);F=svgroot.createSVGTransform();F.setMatrix(svgedit.math.matrixMultiply(svgedit.math.transformListToTransform(h).matrix,d));h.clear();h.appendItem(F)}else{F=o(c.x,c.y);c.width=d.a*c.width;c.height=d.d*c.height;c.x=F.x+Math.min(0,c.width);c.y=F.y+Math.min(0,c.height);c.width=Math.abs(c.width);c.height=Math.abs(c.height)}z();break;case "ellipse":o=o(c.cx,c.cy);c.cx=o.x;c.cy=o.y;c.rx=d.a*c.rx;c.ry=d.d*c.ry;c.rx=Math.abs(c.rx);c.ry=Math.abs(c.ry);
z();break;case "circle":o=o(c.cx,c.cy);c.cx=o.x;c.cy=o.y;o=svgedit.math.transformBox(s.x,s.y,s.width,s.height,d);c.r=Math.min((o.tr.x-o.tl.x)/2,(o.bl.y-o.tl.y)/2);if(c.r)c.r=Math.abs(c.r);z();break;case "line":F=o(c.x1,c.y1);A=o(c.x2,c.y2);c.x1=F.x;c.y1=F.y;c.x2=A.x;c.y2=A.y;case "text":case "tspan":case "use":z();break;case "g":(o=$(j).data("gsvg"))&&svgedit.utilities.assignAttributes(o,c,1E3,true);break;case "polyline":case "polygon":z=c.points.length;for(l=0;l=0)return null;
var c=t.getSVGRoot(),d=svgedit.transformlist.getTransformList(j),l;if(d&&d.numberOfItems>0){for(l=d.numberOfItems;l--;){var h=d.getItem(l);if(h.type===0)d.removeItem(l);else if(h.type===1)svgedit.math.isIdentity(h.matrix)&&d.removeItem(l);else h.type===4&&h.angle===0&&d.removeItem(l)}if(d.numberOfItems===1&&svgedit.utilities.getRotationAngle(j))return null}if(!d||d.numberOfItems==0){j.setAttribute("transform","");j.removeAttribute("transform");return null}if(d){l=d.numberOfItems;for(var o=[];l--;){h=
d.getItem(l);if(h.type===1)o.push([h.matrix,l]);else if(o.length)o=[]}if(o.length===2){l=c.createSVGTransformFromMatrix(svgedit.math.matrixMultiply(o[1][0],o[0][0]));d.removeItem(o[0][1]);d.removeItem(o[1][1]);d.insertItemBefore(l,o[1][1])}l=d.numberOfItems;if(l>=2&&d.getItem(l-2).type===1&&d.getItem(l-1).type===2){o=c.createSVGTransform();h=svgedit.math.matrixMultiply(d.getItem(l-2).matrix,d.getItem(l-1).matrix);o.setMatrix(h);d.removeItem(l-2);d.removeItem(l-2);d.appendItem(o)}}switch(j.tagName){case "line":case "polyline":case "polygon":case "path":break;
default:if(d.numberOfItems===1&&d.getItem(0).type===1||d.numberOfItems===2&&d.getItem(0).type===1&&d.getItem(0).type===4)return null}var m=$(j).data("gsvg");l=new svgedit.history.BatchCommand("Transform");var z={},s=null;h=[];switch(j.tagName){case "line":h=["x1","y1","x2","y2"];break;case "circle":h=["cx","cy","r"];break;case "ellipse":h=["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":h=["width","height","x","y"];break;case "use":case "text":case "tspan":h=["x","y"];break;
case "polygon":case "polyline":s={};s.points=j.getAttribute("points");o=j.points;var F=o.numberOfItems;z.points=Array(F);var A;for(A=0;A1.0E-10?Math.sin(A)/(1-Math.cos(A)):2/A;for(A=0;A=3&&d.getItem(v-2).type==3&&d.getItem(v-3).type==2&&d.getItem(v-1).type==2){A=3;var O=d.getItem(v-3).matrix,Z=d.getItem(v-2).matrix,ka=d.getItem(v-1).matrix;F=j.childNodes;for(i=F.length;i--;){var ea=F.item(i);h=m=0;if(ea.nodeType==1){var ba=svgedit.transformlist.getTransformList(ea);if(ba){h=svgedit.math.transformListToTransform(ba).matrix;m=svgedit.utilities.getRotationAngle(ea);var ia=t.getStartTransform(),
Pa=[];t.setStartTransform(ea.getAttribute("transform"));if(m||svgedit.math.hasMatrixTransform(ba)){var Ca=c.createSVGTransform();Ca.setMatrix(svgedit.math.matrixMultiply(O,Z,ka,h));ba.clear();ba.appendItem(Ca);Pa.push(Ca)}else{m=svgedit.math.matrixMultiply(h.inverse(),ka,h);Ca=c.createSVGMatrix();Ca.e=-m.e;Ca.f=-m.f;h=svgedit.math.matrixMultiply(Ca.inverse(),h.inverse(),O,Z,ka,h,m.inverse());var eb=c.createSVGTransform(),Hb=c.createSVGTransform(),mb=c.createSVGTransform();eb.setTranslate(m.e,m.f);
Hb.setScale(h.a,h.d);mb.setTranslate(Ca.e,Ca.f);ba.appendItem(mb);ba.appendItem(Hb);ba.appendItem(eb);Pa.push(mb);Pa.push(Hb);Pa.push(eb)}l.addSubCommand(svgedit.recalculate.recalculateDimensions(ea));t.setStartTransform(ia)}}}d.removeItem(v-1);d.removeItem(v-2);d.removeItem(v-3)}else if(v>=3&&d.getItem(v-1).type==1){A=3;h=svgedit.math.transformListToTransform(d).matrix;Ca=c.createSVGTransform();Ca.setMatrix(h);d.clear();d.appendItem(Ca)}else if((v==1||v>1&&d.getItem(1).type!=3)&&d.getItem(0).type==
2){A=2;m=svgedit.math.transformListToTransform(d).matrix;d.removeItem(0);h=svgedit.math.transformListToTransform(d).matrix.inverse();h=svgedit.math.matrixMultiply(h,m);m=h.e;h=h.f;if(m!=0||h!=0){F=j.childNodes;i=F.length;for(v=[];i--;){ea=F.item(i);if(ea.nodeType==1){if(ea.getAttribute("clip-path")){ia=ea.getAttribute("clip-path");if(v.indexOf(ia)===-1){svgedit.recalculate.updateClipPath(ia,m,h);v.push(ia)}}ia=t.getStartTransform();t.setStartTransform(ea.getAttribute("transform"));if(ba=svgedit.transformlist.getTransformList(ea)){O=
c.createSVGTransform();O.setTranslate(m,h);ba.numberOfItems?ba.insertItemBefore(O,0):ba.appendItem(O);l.addSubCommand(svgedit.recalculate.recalculateDimensions(ea));ba=j.getElementsByTagNameNS(a.SVG,"use");ea="#"+ea.id;for(O=ba.length;O--;){Z=ba.item(O);if(ea==svgedit.utilities.getHref(Z)){ka=c.createSVGTransform();ka.setTranslate(-m,-h);svgedit.transformlist.getTransformList(Z).insertItemBefore(ka,0);l.addSubCommand(svgedit.recalculate.recalculateDimensions(Z))}}t.setStartTransform(ia)}}}v=[];t.setStartTransform(ia)}}else if(v==
1&&d.getItem(0).type==1&&!o){A=1;h=d.getItem(0).matrix;F=j.childNodes;for(i=F.length;i--;){ea=F.item(i);if(ea.nodeType==1){ia=t.getStartTransform();t.setStartTransform(ea.getAttribute("transform"));if(ba=svgedit.transformlist.getTransformList(ea)){m=svgedit.math.matrixMultiply(h,svgedit.math.transformListToTransform(ba).matrix);v=c.createSVGTransform();v.setMatrix(m);ba.clear();ba.appendItem(v,0);l.addSubCommand(svgedit.recalculate.recalculateDimensions(ea));t.setStartTransform(ia);ia=ea.getAttribute("stroke-width");
ea.getAttribute("stroke")!=="none"&&!isNaN(ia)&&ea.setAttribute("stroke-width",ia*((Math.abs(m.a)+Math.abs(m.d))/2))}}}d.clear()}else{if(o){c=c.createSVGTransform();c.setRotate(o,u.x,u.y);d.numberOfItems?d.insertItemBefore(c,0):d.appendItem(c)}d.numberOfItems==0&&j.removeAttribute("transform");return null}if(A==2){if(o){u={x:B.x+r.e,y:B.y+r.f};c=c.createSVGTransform();c.setRotate(o,u.x,u.y);d.numberOfItems?d.insertItemBefore(c,0):d.appendItem(c)}}else if(A==3){h=svgedit.math.transformListToTransform(d).matrix;
r=c.createSVGTransform();r.setRotate(o,B.x,B.y);r=r.matrix;B=c.createSVGTransform();B.setRotate(o,u.x,u.y);u=B.matrix.inverse();ia=h.inverse();u=svgedit.math.matrixMultiply(ia,u,r,h);m=u.e;h=u.f;if(m!=0||h!=0){F=j.childNodes;for(i=F.length;i--;){ea=F.item(i);if(ea.nodeType==1){ia=t.getStartTransform();t.setStartTransform(ea.getAttribute("transform"));ba=svgedit.transformlist.getTransformList(ea);O=c.createSVGTransform();O.setTranslate(m,h);ba.numberOfItems?ba.insertItemBefore(O,0):ba.appendItem(O);
l.addSubCommand(svgedit.recalculate.recalculateDimensions(ea));t.setStartTransform(ia)}}}if(o)d.numberOfItems?d.insertItemBefore(B,0):d.appendItem(B)}}else{o=svgedit.utilities.getBBox(j);if(!o&&j.tagName!="path")return null;h=c.createSVGMatrix();if(m=svgedit.utilities.getRotationAngle(j)){B={x:o.x+o.width/2,y:o.y+o.height/2};u=svgedit.math.transformPoint(o.x+o.width/2,o.y+o.height/2,svgedit.math.transformListToTransform(d).matrix);A=m*Math.PI/180;F=Math.abs(A)>1.0E-10?Math.sin(A)/(1-Math.cos(A)):
2/A;for(A=0;A=3&&d.getItem(v-2).type==3&&d.getItem(v-3).type==2&&d.getItem(v-1).type==2){A=3;h=svgedit.math.transformListToTransform(d,v-3,v-1).matrix;d.removeItem(v-1);d.removeItem(v-2);d.removeItem(v-3)}else if(v==4&&d.getItem(v-1).type==1){A=3;h=svgedit.math.transformListToTransform(d).matrix;Ca=c.createSVGTransform();Ca.setMatrix(h);d.clear();d.appendItem(Ca);h=c.createSVGMatrix()}else if((v==1||v>1&&d.getItem(1).type!=
3)&&d.getItem(0).type==2){A=2;r=d.getItem(0).matrix;ia=svgedit.math.transformListToTransform(d,1).matrix;o=ia.inverse();h=svgedit.math.matrixMultiply(o,r,ia);d.removeItem(0)}else if(v==1&&d.getItem(0).type==1&&!m){h=svgedit.math.transformListToTransform(d).matrix;switch(j.tagName){case "line":z=$(j).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":z.points=j.getAttribute("points");if(z.points){o=j.points;F=o.numberOfItems;z.points=Array(F);for(A=0;A0;){h.push(h.shift());d--}d=0;for(l in j.selectorGrips){j.selectorGrips[l].setAttribute("style","cursor:"+h[d]+
"-resize");d++}};svgedit.select.Selector.prototype.showGrips=function(d){j.selectorGripsGroup.setAttribute("display",d?"inline":"none");var l=this.selectedElement;this.hasGrips=d;if(l&&d){this.selectorGroup.appendChild(j.selectorGripsGroup);this.updateGripCursors(svgedit.utilities.getRotationAngle(l))}};svgedit.select.Selector.prototype.resize=function(){var d=this.selectorRect,l=j,h=l.selectorGrips,o=this.selectedElement,m=o.getAttribute("stroke-width"),z=a.currentZoom(),s=1/z;if(o.getAttribute("stroke")!==
"none"&&!isNaN(m))s+=m/2;var F=o.tagName;if(F==="text")s+=2/z;m=svgedit.transformlist.getTransformList(o);m=svgedit.math.transformListToTransform(m).matrix;m.e*=z;m.f*=z;var A=svgedit.utilities.getBBox(o);if(F==="g"&&!$.data(o,"gsvg"))if(F=a.getStrokedBBox(o.childNodes))A=F;F=A.x;var i=A.y,B=A.width;A=A.height;s*=z;z=svgedit.math.transformBox(F*z,i*z,B*z,A*z,m);m=z.aabox;F=m.x-s;i=m.y-s;B=m.width+s*2;var u=m.height+s*2;m=F+B/2;A=i+u/2;if(o=svgedit.utilities.getRotationAngle(o)){F=a.svgRoot().createSVGTransform();
F.setRotate(-o,m,A);F=F.matrix;z.tl=svgedit.math.transformPoint(z.tl.x,z.tl.y,F);z.tr=svgedit.math.transformPoint(z.tr.x,z.tr.y,F);z.bl=svgedit.math.transformPoint(z.bl.x,z.bl.y,F);z.br=svgedit.math.transformPoint(z.br.x,z.br.y,F);F=z.tl;B=F.x;u=F.y;var v=F.x,r=F.y;F=Math.min;i=Math.max;B=F(B,F(z.tr.x,F(z.bl.x,z.br.x)))-s;u=F(u,F(z.tr.y,F(z.bl.y,z.br.y)))-s;v=i(v,i(z.tr.x,i(z.bl.x,z.br.x)))+s;r=i(r,i(z.tr.y,i(z.bl.y,z.br.y)))+s;F=B;i=u;B=v-B;u=r-u}s=a.svgRoot().suspendRedraw(100);d.setAttribute("d",
"M"+F+","+i+" L"+(F+B)+","+i+" "+(F+B)+","+(i+u)+" "+F+","+(i+u)+"z");this.selectorGroup.setAttribute("transform",o?"rotate("+[o,m,A].join(",")+")":"");this.gripCoords={nw:[F,i],ne:[F+B,i],sw:[F,i+u],se:[F+B,i+u],n:[F+B/2,i],w:[F,i+u/2],e:[F+B,i+u/2],s:[F+B/2,i+u]};for(var O in this.gripCoords){d=this.gripCoords[O];h[O].setAttribute("cx",d[0]);h[O].setAttribute("cy",d[1])}l.rotateGripConnector.setAttribute("x1",F+B/2);l.rotateGripConnector.setAttribute("y1",i);l.rotateGripConnector.setAttribute("x2",
F+B/2);l.rotateGripConnector.setAttribute("y2",i-c*5);l.rotateGrip.setAttribute("cx",F+B/2);l.rotateGrip.setAttribute("cy",i-c*5);a.svgRoot().unsuspendRedraw(s)};svgedit.select.SelectorManager=function(){this.rubberBandBox=this.selectorParentGroup=null;this.selectors=[];this.selectorMap={};this.selectorGrips={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null};this.rotateGrip=this.rotateGripConnector=this.selectorGripsGroup=null;this.initGroup()};svgedit.select.SelectorManager.prototype.initGroup=
function(){this.selectorParentGroup&&this.selectorParentGroup.parentNode&&this.selectorParentGroup.parentNode.removeChild(this.selectorParentGroup);this.selectorParentGroup=a.createSVGElement({element:"g",attr:{id:"selectorParentGroup"}});this.selectorGripsGroup=a.createSVGElement({element:"g",attr:{display:"none"}});this.selectorParentGroup.appendChild(this.selectorGripsGroup);a.svgRoot().appendChild(this.selectorParentGroup);this.selectorMap={};this.selectors=[];this.rubberBandBox=null;for(var d in this.selectorGrips){var l=
a.createSVGElement({element:"circle",attr:{id:"selectorGrip_resize_"+d,fill:"#22C",r:c,style:"cursor:"+d+"-resize","stroke-width":2,"pointer-events":"all"}});$.data(l,"dir",d);$.data(l,"type","resize");this.selectorGrips[d]=this.selectorGripsGroup.appendChild(l)}this.rotateGripConnector=this.selectorGripsGroup.appendChild(a.createSVGElement({element:"line",attr:{id:"selectorGrip_rotateconnector",stroke:"#22C","stroke-width":"1"}}));this.rotateGrip=this.selectorGripsGroup.appendChild(a.createSVGElement({element:"circle",
attr:{id:"selectorGrip_rotate",fill:"lime",r:c,stroke:"#22C","stroke-width":2,style:"cursor:url("+t.imgPath+"rotate.png) 12 12, auto;"}}));$.data(this.rotateGrip,"type","rotate");if(!$("#canvasBackground").length){d=t.dimensions;d=a.createSVGElement({element:"svg",attr:{id:"canvasBackground",width:d[0],height:d[1],x:0,y:0,overflow:svgedit.browser.isWebkit()?"none":"visible",style:"pointer-events:none"}});l=a.createSVGElement({element:"rect",attr:{width:"100%",height:"100%",x:0,y:0,"stroke-width":1,
stroke:"#000",fill:"#FFF",style:"pointer-events:none"}});d.appendChild(l);a.svgRoot().insertBefore(d,a.svgContent())}};svgedit.select.SelectorManager.prototype.requestSelector=function(d){if(d==null)return null;var l,h=this.selectors.length;if(typeof this.selectorMap[d.id]=="object"){this.selectorMap[d.id].locked=true;return this.selectorMap[d.id]}for(l=0;l element";this.svgElem_=d;this.obj_num=0;this.idPrefix=l||"svg_";this.releasedNums=[];this.all_layers=[];this.current_layer=null;this.nonce_=
"";var h=this.svgElem_.getAttributeNS(a.SE,"nonce");if(h&&c!=j.NEVER_RANDOMIZE)this.nonce_=h;else c==j.ALWAYS_RANDOMIZE&&this.setNonce(Math.floor(Math.random()*100001))};svgedit.draw.Drawing.prototype.getElem_=function(d){if(this.svgElem_.querySelector)return this.svgElem_.querySelector("#"+d);return $(this.svgElem_).find("[id="+d+"]")[0]};svgedit.draw.Drawing.prototype.getSvgElem=function(){return this.svgElem_};svgedit.draw.Drawing.prototype.getNonce=function(){return this.nonce_};svgedit.draw.Drawing.prototype.setNonce=
function(d){this.svgElem_.setAttributeNS(a.XMLNS,"xmlns:se",a.SE);this.svgElem_.setAttributeNS(a.SE,"se:nonce",d);this.nonce_=d};svgedit.draw.Drawing.prototype.clearNonce=function(){this.nonce_=""};svgedit.draw.Drawing.prototype.getId=function(){return this.nonce_?this.idPrefix+this.nonce_+"_"+this.obj_num:this.idPrefix+this.obj_num};svgedit.draw.Drawing.prototype.getNextId=function(){var d=this.obj_num,l=false;if(this.releasedNums.length>0){this.obj_num=this.releasedNums.pop();l=true}else this.obj_num++;
for(var h=this.getId();this.getElem_(h);){if(l){this.obj_num=d;l=false}this.obj_num++;h=this.getId()}if(l)this.obj_num=d;return h};svgedit.draw.Drawing.prototype.releaseId=function(d){var l=this.idPrefix+(this.nonce_?this.nonce_+"_":"");if(typeof d!=="string"||d.indexOf(l)!==0)return false;d=parseInt(d.substr(l.length),10);if(typeof d!=="number"||d<=0||this.releasedNums.indexOf(d)!=-1)return false;this.releasedNums.push(d);return true};svgedit.draw.Drawing.prototype.getNumLayers=function(){return this.all_layers.length};
svgedit.draw.Drawing.prototype.hasLayer=function(d){var l;for(l=0;l=0&&d1){var d=this.current_layer.parentNode.removeChild(this.current_layer);
this.identifyLayers();return d}return null};svgedit.draw.Drawing.prototype.identifyLayers=function(){this.all_layers=[];var d=this.svgElem_.childNodes.length,l=[],h=[],o=null,m=false,z;for(z=0;z0||!m){for(z=1;h.indexOf("Layer "+z)>=0;)z++;h="Layer "+z;o=d.createElementNS(a.SVG,"g");m=d.createElementNS(a.SVG,"title");m.textContent=h;o.appendChild(m);for(m=0;m1)){var h;for(h=0;h0){i=ka element";this.elem=i;this.segs=[];this.selected_pts=[];svgedit.path.path=this;this.init()};svgedit.path.Path.prototype.init=function(){$(svgedit.path.getGripContainer()).find("*").each(function(){$(this).attr("display","none")});var i=this.elem.pathSegList,B=i.numberOfItems;this.segs=[];this.selected_pts=
[];this.first_seg=null;var u;for(u=0;u=B?null:i[u+1],Z=u-1<0?null:i[u-1];if(r.type===2){if(Z&&Z.type!==1){O=i[v];O.next=i[v+1];O.next.prev=O;O.addGrip()}v=u}else if(O&&O.type===1){r.next=i[v+1];r.next.prev=r;r.mate=i[v];r.addGrip();if(this.first_seg==null)this.first_seg=r}else if(O){if(r.type!==1){r.addGrip();if(O&&O.type!==2){r.next=O;r.next.prev=r}}}else if(r.type!==
1){O=i[v];O.next=i[v+1];O.next.prev=O;O.addGrip();r.addGrip();if(!this.first_seg)this.first_seg=i[v]}}return this};svgedit.path.Path.prototype.eachSeg=function(i){var B,u=this.segs.length;for(B=0;B")[0].getContext("2d")))f.text=qb.exportNoText;$.each(f,function(q,k){e.find(q).length&&b.push(k)});return b}function c(b,f){var e,q=svgedit.utilities.getBBox(b);for(e=0;e<2;e++){var k=e===0?"fill":"stroke",D=b.getAttribute(k);if(D&&D.indexOf("url(")===0){D=svgedit.utilities.getRefElem(D);if(D.tagName===
"linearGradient"){var p=D.getAttribute("x1")||0,w=D.getAttribute("y1")||0,C=D.getAttribute("x2")||1,I=D.getAttribute("y2")||0;p=q.width*p+q.x;w=q.height*w+q.y;C=q.width*C+q.x;I=q.height*I+q.y;p=svgedit.math.transformPoint(p,w,f);I=svgedit.math.transformPoint(C,I,f);C={};C.x1=(p.x-q.x)/q.width;C.y1=(p.y-q.y)/q.height;C.x2=(I.x-q.x)/q.width;C.y2=(I.y-q.y)/q.height;D=D.cloneNode(true);$(D).attr(C);D.id=Ha();svgedit.utilities.findDefs().appendChild(D);b.setAttribute(k,"url(#"+D.id+")")}}}}var d=svgedit.NS,
l={show_outside_canvas:true,selectNew:true,dimensions:[640,480]};t&&$.extend(l,t);var h=l.dimensions,o=this,m=a.ownerDocument,z=m.importNode(svgedit.utilities.text2xml('').documentElement,
true);a.appendChild(z);var s=m.createElementNS(d.SVG,"svg");(o.clearSvgContentElement=function(){for(;s.firstChild;)s.removeChild(s.firstChild);$(s).attr({id:"svgcontent",width:h[0],height:h[1],x:h[0],y:h[1],overflow:l.show_outside_canvas?"visible":"hidden",xmlns:d.SVG,"xmlns:se":d.SE,"xmlns:xlink":d.XLINK}).appendTo(z);var b=m.createComment(" Created with SVG-edit - http://svg-edit.googlecode.com/ ");s.appendChild(b)})();var F="svg_";o.setIdPrefix=function(b){F=b};o.current_drawing_=new svgedit.draw.Drawing(s,
F);var A=o.getCurrentDrawing=function(){return o.current_drawing_},i=1,B=null,u={shape:{fill:(l.initFill.color=="none"?"":"#")+l.initFill.color,fill_paint:null,fill_opacity:l.initFill.opacity,stroke:"#"+l.initStroke.color,stroke_paint:null,stroke_opacity:l.initStroke.opacity,stroke_width:l.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:l.initOpacity}};u.text=$.extend(true,{},u.shape);$.extend(u.text,{fill:"#000000",stroke_width:0,font_size:24,font_family:"serif"});
var v=u.shape,r=Array(1),O=this.addSvgElementFromJson=function(b){var f=svgedit.utilities.getElem(b.attr.id),e=A().getCurrentLayer();if(f&&b.element!=f.tagName){e.removeChild(f);f=null}if(!f){f=m.createElementNS(d.SVG,b.element);if(e)(B||e).appendChild(f)}b.curStyles&&svgedit.utilities.assignAttributes(f,{fill:v.fill,stroke:v.stroke,"stroke-width":v.stroke_width,"stroke-dasharray":v.stroke_dasharray,"stroke-linejoin":v.stroke_linejoin,"stroke-linecap":v.stroke_linecap,"stroke-opacity":v.stroke_opacity,
"fill-opacity":v.fill_opacity,opacity:v.opacity/2,style:"pointer-events:inherit"},100);svgedit.utilities.assignAttributes(f,b.attr,100);svgedit.utilities.cleanupElement(f);return f};o.getTransformList=svgedit.transformlist.getTransformList;var Z=svgedit.math.transformPoint,ka=o.matrixMultiply=svgedit.math.matrixMultiply,ea=o.hasMatrixTransform=svgedit.math.hasMatrixTransform,ba=o.transformListToTransform=svgedit.math.transformListToTransform;svgedit.units.init({getBaseUnit:function(){return l.baseUnit},
getElement:svgedit.utilities.getElem,getHeight:function(){return s.getAttribute("height")/i},getWidth:function(){return s.getAttribute("width")/i},getRoundDigits:function(){return Xa.round_digits}});o.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return m},getDOMContainer:function(){return a},getSVGRoot:function(){return z},getSelectedElements:function(){return r},getSVGContent:function(){return s},getBaseUnit:function(){return l.baseUnit},getSnappingStep:function(){return l.snappingStep}});
var ia=o.findDefs=svgedit.utilities.findDefs,Pa=o.getUrlFromAttr=svgedit.utilities.getUrlFromAttr,Ca=o.getHref=svgedit.utilities.getHref,eb=o.setHref=svgedit.utilities.setHref,Hb=svgedit.utilities.getPathBBox;o.getBBox=svgedit.utilities.getBBox;o.getRotationAngle=svgedit.utilities.getRotationAngle;var mb=o.getElem=svgedit.utilities.getElem;o.getRefElem=svgedit.utilities.getRefElem;var db=o.assignAttributes=svgedit.utilities.assignAttributes,ua=this.cleanupElement=svgedit.utilities.cleanupElement;
svgedit.coords.init({getDrawing:function(){return A()},getGridSnapping:function(){return l.gridSnapping}});var Sb=this.remapElement=svgedit.coords.remapElement;svgedit.recalculate.init({getSVGRoot:function(){return z},getStartTransform:function(){return nb},setStartTransform:function(b){nb=b}});var Ib=this.recalculateDimensions=svgedit.recalculate.recalculateDimensions,bb=svgedit.getReverseNS(),Jb=o.sanitizeSvg=svgedit.sanitize.sanitizeSvg,yb=svgedit.history.MoveElementCommand,cb=svgedit.history.InsertElementCommand,
Ua=svgedit.history.RemoveElementCommand,ib=svgedit.history.ChangeElementCommand,Xb=svgedit.history.BatchCommand,W;o.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(b,f){var e=svgedit.history.HistoryEventTypes;if(b==e.BEFORE_UNAPPLY||b==e.BEFORE_APPLY)o.clearSelection();else if(b==e.AFTER_APPLY||b==e.AFTER_UNAPPLY){var q=f.elements();o.pathActions.clear();W("changed",q);q=f.type();e=b==e.AFTER_APPLY;if(q==yb.type())(e?f.newParent:f.oldParent)==s&&o.identifyLayers();else if(q==
cb.type()||q==Ua.type()){f.parent==s&&o.identifyLayers();if(q==cb.type())e&&Na(f.elem);else e||Na(f.elem);f.elem.tagName==="use"&&zb(f.elem)}else if(q==ib.type()){f.elem.tagName=="title"&&f.elem.parentNode.parentNode==s&&o.identifyLayers();e=e?f.newValues:f.oldValues;e.stdDeviation&&o.setBlurOffsets(f.elem.parentNode,e.stdDeviation)}}}});var pa=function(b){o.undoMgr.addCommandToHistory(b)};svgedit.select.init(l,{createSVGElement:function(b){return o.addSvgElementFromJson(b)},svgRoot:function(){return z},
svgContent:function(){return s},currentZoom:function(){return i},getStrokedBBox:function(b){return o.getStrokedBBox([b])}});var qa=this.selectorManager=svgedit.select.getSelectorManager();svgedit.path.init({getCurrentZoom:function(){return i},getSVGRoot:function(){return z}});var qb={exportNoBlur:"Blurred elements will appear as un-blurred",exportNoforeignObject:"foreignObject elements will not appear",exportNoDashArray:"Strokes will appear filled",exportNoText:"Text may not appear as expected"},
Tb=["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],rb=$.data,Ab=document.createElementNS(d.SVG,"animate");$(Ab).attr({attributeName:"opacity",begin:"indefinite",dur:1,fill:"freeze"}).appendTo(z);var Na=function(b){var f,e=$(b).attr(Tb);for(f in e){var q=e[f];if(q&&q.indexOf("url(")===0){q=svgedit.utilities.getUrlFromAttr(q).substr(1);if(!mb(q)){svgedit.utilities.findDefs().appendChild(Bb[q]);delete Bb[q]}}}e=b.getElementsByTagName("*");if(e.length){b=0;for(f=
e.length;b=0)K=E=o.convertToPath(I,true);else if(I.tagName=="rect"){var N=I.getAttribute("rx"),
S=I.getAttribute("ry");if(N||S)K=E=o.convertToPath(I,true)}if(!E){var U=I.cloneNode(true),X=document.createElementNS(d.SVG,"g"),da=I.parentNode;da.appendChild(X);X.appendChild(U);K=svgedit.utilities.bboxToObj(X.getBBox());da.removeChild(X)}}return K}catch(R){console.log(I,R);return null}},e;$.each(b,function(){if(!e)if(this.parentNode)e=f(this)});if(e==null)return null;var q=e.x+e.width,k=e.y+e.height,D=e.x,p=e.y,w=function(I){var K=I.getAttribute("stroke-width"),E=0;if(I.getAttribute("stroke")!=
"none"&&!isNaN(K))E+=K/2;return E},C=[];$.each(b,function(I,K){var E=f(K);if(E){var N=w(K);D=Math.min(D,E.x-N);p=Math.min(p,E.y-N);C.push(E)}});e.x=D;e.y=p;$.each(b,function(I,K){var E=C[I];if(E&&K.nodeType==1){var N=w(K);q=Math.max(q,E.x+E.width+N);k=Math.max(k,E.y+E.height+N)}});e.width=q-D;e.height=k-p;return e};var Ta=this.getVisibleElements=function(b){b||(b=$(s).children());var f=[];$(b).children().each(function(e,q){try{q.getBBox()&&f.push(q)}catch(k){}});return f.reverse()},Ub=this.getVisibleElementsAndBBoxes=
function(b){b||(b=$(s).children());var f=[];$(b).children().each(function(e,q){try{q.getBBox()&&f.push({elem:q,bbox:getStrokedBBox([q])})}catch(k){}});return f.reverse()},Lb=this.groupSvgElem=function(b){var f=document.createElementNS(d.SVG,"g");b.parentNode.replaceChild(f,b);$(f).append(b).data("gsvg",b)[0].id=Ha()},ob=function(b){var f=document.createElementNS(b.namespaceURI,b.nodeName);$.each(b.attributes,function(q,k){k.localName!="-moz-math-font-style"&&f.setAttributeNS(k.namespaceURI,k.nodeName,
k.value)});f.removeAttribute("id");f.id=Ha();if(svgedit.browser.isWebkit()&&b.nodeName=="path"){var e=ra.convertPath(b);f.setAttribute("d",e)}$.each(b.childNodes,function(q,k){switch(k.nodeType){case 1:f.appendChild(ob(k));break;case 3:f.textContent=k.nodeValue}});if($(b).data("gsvg"))$(f).data("gsvg",f.firstChild);else if($(b).data("symbol")){b=$(b).data("symbol");$(f).data("ref",b).data("symbol",b)}else f.tagName=="image"&&vb(f);return f},Za,Ha,Ka,ra;(function(b){var f={};Za=b.getId=function(){return A().getId()};
Ha=b.getNextId=function(){return A().getNextId()};W=b.call=function(e,q){if(f[e])return f[e](this,q)};b.bind=function(e,q){var k=f[e];f[e]=q;return k}})(o);this.prepareSvg=function(b){this.sanitizeSvg(b.documentElement);var f,e,q=b.getElementsByTagNameNS(d.SVG,"path");b=0;for(e=q.length;b0&&k.getItem(0).type==4&&k.removeItem(0);if(b!=0){D=svgedit.math.transformPoint(D,p,svgedit.math.transformListToTransform(k).matrix);p=z.createSVGTransform();p.setRotate(b,D.x,D.y);k.numberOfItems?k.insertItemBefore(p,0):k.appendItem(p)}else k.numberOfItems==
0&&e.removeAttribute("transform");if(!f){k=e.getAttribute("transform");e.setAttribute("transform",q);Ma("transform",k,r);W("changed",r)}svgedit.utilities.getElem("pathpointgrip_container");e=qa.requestSelector(r[0]);e.resize();e.updateGripCursors(b)};var Mb=this.recalculateAllSelectedDimensions=function(){for(var b=new svgedit.history.BatchCommand(kb=="none"?"position":"size"),f=r.length;f--;){var e=svgedit.recalculate.recalculateDimensions(r[f]);e&&b.addSubCommand(e)}if(!b.isEmpty()){pa(b);W("changed",
r)}},gc=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],Yb=function(b){console.log([b.a,b.b,b.c,b.d,b.e,b.f])},fb=null,xa=this.clearSelection=function(b){if(r[0]!=null){var f,e,q=r.length;for(f=0;f1&&k.showGrips(false)}}}W("selected",r);f||r.length==1?qa.requestSelector(r[0]).showGrips(true):qa.requestSelector(r[0]).showGrips(false);for(r.sort(function(D,p){if(D&&p&&D.compareDocumentPosition)return 3-(p.compareDocumentPosition(D)&6);if(D==null)return 1});r[0]==null;)r.shift(0)}},$a=this.selectOnly=function(b,f){xa(true);gb(b,f)};this.removeFromSelection=function(b){if(r[0]!=null)if(b.length!=
0){var f,e=0,q=[],k=r.length;q.length=k;for(f=0;f=0&&b.id!="svgcanvas")for(;b.nodeName!="foreignObject";){b=b.parentNode;if(!b)return z}var f=
A().getCurrentLayer();if([z,a,s,f].indexOf(b)>=0)return z;if($(b).closest("#selectorParentGroup").length)return qa.selectorParentGroup;for(;b.parentNode!==(B||f);)b=b.parentNode;return b};(function(){var b=null,f=null,e=null,q=null,k=null,D={},p={minx:null,miny:null,maxx:null,maxy:null},w=0,C={x:0,y:0},I={x:0,y:0},K={x:0,y:0},E={x:0,y:0},N,S,U={x:0,y:0},X={x:0,y:0},da=function(R){var L={x:0,y:0},J=C,M=I,Q=K,aa=E,ga=1/6,oa=R*R,za=oa*R,ca=[[-1,3,-3,1],[3,-6,3,0],[-3,0,3,0],[1,4,1,0]];L.x=ga*((J.x*ca[0][0]+
M.x*ca[0][1]+Q.x*ca[0][2]+aa.x*ca[0][3])*za+(J.x*ca[1][0]+M.x*ca[1][1]+Q.x*ca[1][2]+aa.x*ca[1][3])*oa+(J.x*ca[2][0]+M.x*ca[2][1]+Q.x*ca[2][2]+aa.x*ca[2][3])*R+(J.x*ca[3][0]+M.x*ca[3][1]+Q.x*ca[3][2]+aa.x*ca[3][3]));L.y=ga*((J.y*ca[0][0]+M.y*ca[0][1]+Q.y*ca[0][2]+aa.y*ca[0][3])*za+(J.y*ca[1][0]+M.y*ca[1][1]+Q.y*ca[1][2]+aa.y*ca[1][3])*oa+(J.y*ca[2][0]+M.y*ca[2][1]+Q.y*ca[2][2]+aa.y*ca[2][3])*R+(J.y*ca[3][0]+M.y*ca[3][1]+Q.y*ca[3][2]+aa.y*ca[3][3]));return{x:L.x,y:L.y}};$(a).mousedown(function(R){if(!(o.spaceKey||
R.button===1)){var L=R.button===2;R.altKey&&svgCanvas.cloneSelectedElements(0,0);fb=$("#svgcontent g")[0].getScreenCTM().inverse();var J=svgedit.math.transformPoint(R.pageX,R.pageY,fb),M=J.x*i,Q=J.y*i;R.preventDefault();if(L){va="select";Cb=J}J=M/i;Q=Q/i;var aa=Eb(R);if(aa.tagName==="a"&&aa.childNodes.length===1)aa=aa.firstChild;q=f=M=J;var ga=Q;k=e=Q;if(l.gridSnapping){J=svgedit.utilities.snapToGrid(J);Q=svgedit.utilities.snapToGrid(Q);f=svgedit.utilities.snapToGrid(f);e=svgedit.utilities.snapToGrid(e)}if(aa==
qa.selectorParentGroup&&r[0]!=null){aa=R.target;var oa=rb(aa,"type");if(oa=="rotate")va="rotate";else if(oa=="resize"){va="resize";kb=rb(aa,"dir")}aa=r[0]}nb=aa.getAttribute("transform");var za;oa=svgedit.transformlist.getTransformList(aa);switch(va){case "select":Ba=true;kb="none";if(L)Ba=false;if(aa!=z){if(r.indexOf(aa)==-1){R.shiftKey||xa(true);gb([aa]);Kb=aa;ra.clear()}if(!L)for(L=0;L0&&o.removeFromSelection(ca);J.length>0&&gb(J);break;case "resize":ca=svgedit.transformlist.getTransformList(ga);M=(L=svgedit.math.hasMatrixTransform(ca))?D:svgedit.utilities.getBBox(ga);Q=M.x;ta=M.y;var Aa=M.width,ab=M.height;J=x-f;M=y-e;if(l.gridSnapping){J=svgedit.utilities.snapToGrid(J);M=svgedit.utilities.snapToGrid(M);ab=svgedit.utilities.snapToGrid(ab);Aa=svgedit.utilities.snapToGrid(Aa)}if(aa=
svgedit.utilities.getRotationAngle(ga)){var pb=Math.sqrt(J*J+M*M);M=Math.atan2(M,J)-aa*Math.PI/180;J=pb*Math.cos(M);M=pb*Math.sin(M)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)M=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)J=0;var Fb=pb=0,Nb=ab?(ab+M)/ab:1,Gb=Aa?(Aa+J)/Aa:1;if(kb.indexOf("n")>=0){Nb=ab?(ab-M)/ab:1;Fb=ab}if(kb.indexOf("w")>=0){Gb=Aa?(Aa-J)/Aa:1;pb=Aa}J=z.createSVGTransform();M=z.createSVGTransform();Aa=z.createSVGTransform();if(l.gridSnapping){Q=svgedit.utilities.snapToGrid(Q);pb=
svgedit.utilities.snapToGrid(pb);ta=svgedit.utilities.snapToGrid(ta);Fb=svgedit.utilities.snapToGrid(Fb)}J.setTranslate(-(Q+pb),-(ta+Fb));if(R.shiftKey)if(Gb==1)Gb=Nb;else Nb=Gb;M.setScale(Gb,Nb);Aa.setTranslate(Q+pb,ta+Fb);if(L){L=aa?1:0;ca.replaceItem(J,2+L);ca.replaceItem(M,1+L);ca.replaceItem(Aa,Number(L))}else{L=ca.numberOfItems;ca.replaceItem(Aa,L-3);ca.replaceItem(M,L-2);ca.replaceItem(J,L-1)}qa.requestSelector(ga).resize();W("transition",r);break;case "zoom":J*=i;Q*=i;svgedit.utilities.assignAttributes(Da,
{x:Math.min(q*i,J),y:Math.min(k*i,Q),width:Math.abs(J-q*i),height:Math.abs(Q-k*i)},100);break;case "text":svgedit.utilities.assignAttributes(ca,{x:x,y:y},1E3);break;case "line":Q=null;window.opera||z.suspendRedraw(1E3);if(l.gridSnapping){x=svgedit.utilities.snapToGrid(x);y=svgedit.utilities.snapToGrid(y)}J=x;L=y;if(R.shiftKey){L=svgedit.math.snapToAngle(f,e,J,L);J=L.x;L=L.y}ca.setAttributeNS(null,"x2",J);ca.setAttributeNS(null,"y2",L);window.opera||z.unsuspendRedraw(Q);break;case "foreignObject":case "square":case "rect":case "image":J=
Math.abs(x-f);L=Math.abs(y-e);if(va=="square"||R.shiftKey){J=L=Math.max(J,L);Q=f0.8){b+=+U.x+","+U.y+" ";ca.setAttributeNS(null,"points",b);w-=0.8}}C={x:I.x,y:I.y};I={x:K.x,y:K.y};K={x:E.x,y:E.y};break;case "path":case "pathedit":x*=i;y*=i;if(l.gridSnapping){x=svgedit.utilities.snapToGrid(x);y=svgedit.utilities.snapToGrid(y);f=svgedit.utilities.snapToGrid(f);e=svgedit.utilities.snapToGrid(e)}if(R.shiftKey){if(L=
svgedit.path.path){ca=L.dragging?L.dragging[0]:f;L=L.dragging?L.dragging[1]:e}else{ca=f;L=e}L=svgedit.math.snapToAngle(ca,L,x,y);x=L.x;y=L.y}if(Da&&Da.getAttribute("display")!=="none"){J*=i;Q*=i;svgedit.utilities.assignAttributes(Da,{x:Math.min(q*i,J),y:Math.min(k*i,Q),width:Math.abs(J-q*i),height:Math.abs(Q-k*i)},100)}ra.mouseMove(x,y);break;case "textedit":x*=i;y*=i;Ka.mouseMove(za,oa);break;case "rotate":M=svgedit.utilities.getBBox(ga);J=M.x+M.width/2;L=M.y+M.height/2;ca=svgedit.math.getMatrix(ga);
ca=svgedit.math.transformPoint(J,L,ca);J=ca.x;L=ca.y;aa=(Math.atan2(L-y,J-x)*(180/Math.PI)-90)%360;if(l.gridSnapping)aa=svgedit.utilities.snapToGrid(aa);if(R.shiftKey)aa=Math.round(aa/45)*45;o.setRotationAngle(aa<-180?360+aa:aa,true);W("transition",r)}tb("mouseMove",{event:R,mouse_x:za,mouse_y:oa,selected:ga})}}).click(function(R){R.preventDefault();return false}).dblclick(function(R){var L=R.target.parentNode;if(L!==B){var J=Eb(R),M=J.tagName;if(M==="text"&&va!=="textedit"){R=svgedit.math.transformPoint(R.pageX,
R.pageY,fb);Ka.select(J,R.x,R.y)}if((M==="g"||M==="a")&&svgedit.utilities.getRotationAngle(J)){Vb(J);J=r[0];xa(true)}B&&Ob();L.tagName!=="g"&&L.tagName!=="a"||L===A().getCurrentLayer()||J===qa.selectorParentGroup||hc(J)}}).mouseup(function(R){if(R.button!==2){var L=Kb;Kb=null;if(Ba){var J=svgedit.math.transformPoint(R.pageX,R.pageY,fb),M=J.x*i;J=J.y*i;var Q=M/i,aa=J/i,ga=svgedit.utilities.getElem(Za()),oa=false;Ba=false;switch(va){case "resize":case "multiselect":if(Da!=null){Da.setAttribute("display",
"none");hb=[]}va="select";case "select":if(r[0]!=null){if(r[1]==null){M=r[0];switch(M.tagName){case "g":case "use":case "image":case "foreignObject":break;default:ya.fill=M.getAttribute("fill");ya.fill_opacity=M.getAttribute("fill-opacity");ya.stroke=M.getAttribute("stroke");ya.stroke_opacity=M.getAttribute("stroke-opacity");ya.stroke_width=M.getAttribute("stroke-width");ya.stroke_dasharray=M.getAttribute("stroke-dasharray");ya.stroke_linejoin=M.getAttribute("stroke-linejoin");ya.stroke_linecap=M.getAttribute("stroke-linecap")}if(M.tagName==
"text"){Va.font_size=M.getAttribute("font-size");Va.font_family=M.getAttribute("font-family")}qa.requestSelector(M).showGrips(true)}Mb();if(Q!=q||aa!=k){M=r.length;for(R=0;R=0?L.indexOf(",",Q+1)>=0:L.indexOf(" ",L.indexOf(" ")+1)>=0)ga=ra.smoothPolylineIntoPath(ga);break;case "line":L=$(ga).attr(["x1","x2","y1","y2"]);oa=L.x1!=L.x2||L.y1!=L.y2;break;case "foreignObject":case "square":case "rect":case "image":L=
$(ga).attr(["width","height"]);oa=L.width!=0||L.height!=0||va==="image";break;case "circle":oa=ga.getAttribute("r")!=0;break;case "ellipse":L=$(ga).attr(["rx","ry"]);oa=L.rx!=null||L.ry!=null;break;case "fhellipse":if(p.maxx-p.minx>0&&p.maxy-p.miny>0){ga=O({element:"ellipse",curStyles:true,attr:{cx:(p.minx+p.maxx)/2,cy:(p.miny+p.maxy)/2,rx:(p.maxx-p.minx)/2,ry:(p.maxy-p.miny)/2,id:Za()}});W("changed",[ga]);oa=true}break;case "fhrect":if(p.maxx-p.minx>0&&p.maxy-p.miny>0){ga=O({element:"rect",curStyles:true,
attr:{x:p.minx,y:p.miny,width:p.maxx-p.minx,height:p.maxy-p.miny,id:Za()}});W("changed",[ga]);oa=true}break;case "text":oa=true;$a([ga]);Ka.start(ga);break;case "path":ga=null;Ba=true;L=ra.mouseUp(R,ga,M,J);ga=L.element;oa=L.keep;break;case "pathedit":oa=true;ga=null;ra.mouseUp(R);break;case "textedit":oa=false;ga=null;Ka.mouseUp(R,M,J);break;case "rotate":oa=true;ga=null;va="select";L=o.undoMgr.finishUndoableChange();L.isEmpty()||pa(L);Mb();W("changed",r)}M=tb("mouseUp",{event:R,mouse_x:M,mouse_y:J},
true);$.each(M,function(ta,Aa){if(Aa){oa=Aa.keep||oa;ga=Aa.element;Ba=Aa.started||Ba}});if(!oa&&ga!=null){A().releaseId(Za());ga.parentNode.removeChild(ga);ga=null;for(M=R.target;M.parentNode.parentNode.tagName=="g";)M=M.parentNode;if((va!="path"||!drawn_path)&&M.parentNode.id!="selectorParentGroup"&&M.id!="svgcanvas"&&M.id!="svgroot"){o.setMode("select");$a([M],true)}}else if(ga!=null){o.addedNew=true;R=0.2;var za;if(Ab.beginElement&&ga.getAttribute("opacity")!=v.opacity){za=$(Ab).clone().attr({to:v.opacity,
dur:R}).appendTo(ga);try{za[0].beginElement()}catch(ca){}}else R=0;setTimeout(function(){za&&za.remove();ga.setAttribute("opacity",v.opacity);ga.setAttribute("style","pointer-events:inherit");ua(ga);if(va==="path")ra.toEditMode(ga);else l.selectNew&&$a([ga],true);pa(new svgedit.history.InsertElementCommand(ga));W("changed",[ga])},R*1E3)}nb=null}}});$(a).bind("mousewheel DOMMouseScroll",function(R){R.preventDefault();R=R.originalEvent;fb=$("#svgcontent g")[0].getScreenCTM().inverse();var L=svgedit.math.transformPoint(R.pageX,
R.pageY,fb);L={x:L.x,y:L.y,width:0,height:0};if(R=R.wheelDelta?R.wheelDelta:R.detail?-R.detail:0){L.factor=Math.max(0.75,Math.min(4/3,R));W("zoomed",L)}})})();var vb=function(b){$(b).click(function(f){f.preventDefault()})};Ka=o.textActions=function(){function b(J){var M=I.value==="";$(I).focus();if(!arguments.length)if(M)J=0;else{if(I.selectionEnd!==I.selectionStart)return;J=I.selectionEnd}var Q;Q=S[J];M||I.setSelectionRange(J,J);K=svgedit.utilities.getElem("text_cursor");if(!K){K=document.createElementNS(d.SVG,
"line");svgedit.utilities.assignAttributes(K,{id:"text_cursor",stroke:"#333","stroke-width":1});K=svgedit.utilities.getElem("selectorParentGroup").appendChild(K)}N||(N=setInterval(function(){var aa=K.getAttribute("display")==="none";K.setAttribute("display",aa?"inline":"none")},600));M=D(Q.x,U.y);Q=D(Q.x,U.y+U.height);svgedit.utilities.assignAttributes(K,{x1:M.x,y1:M.y,x2:Q.x,y2:Q.y,visibility:"visible",display:"inline"});E&&E.setAttribute("d","")}function f(J,M,Q){if(J===M)b(M);else{Q||I.setSelectionRange(J,
M);E=svgedit.utilities.getElem("text_selectblock");if(!E){E=document.createElementNS(d.SVG,"path");svgedit.utilities.assignAttributes(E,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});svgedit.utilities.getElem("selectorParentGroup").appendChild(E)}J=S[J];var aa=S[M];K.setAttribute("visibility","hidden");M=D(J.x,U.y);Q=D(J.x+(aa.x-J.x),U.y);var ga=D(J.x,U.y+U.height);J=D(J.x+(aa.x-J.x),U.y+U.height);svgedit.utilities.assignAttributes(E,{d:"M"+M.x+","+M.y+" L"+Q.x+","+
Q.y+" "+J.x+","+J.y+" "+ga.x+","+ga.y+"z",display:"inline"})}}function e(J,M){var Q=z.createSVGPoint();Q.x=J;Q.y=M;if(S.length==1)return 0;Q=C.getCharNumAtPosition(Q);if(Q<0){Q=S.length-2;if(J<=S[0].x)Q=0}else if(Q>=S.length-2)Q=S.length-2;var aa=S[Q];J>aa.x+aa.width/2&&Q++;return Q}function q(J,M,Q){var aa=I.selectionStart;J=e(J,M);f(Math.min(aa,J),Math.max(aa,J),!Q)}function k(J,M){var Q={x:J,y:M};Q.x/=i;Q.y/=i;if(X){var aa=svgedit.math.transformPoint(Q.x,Q.y,X.inverse());Q.x=aa.x;Q.y=aa.y}return Q}
function D(J,M){var Q={x:J,y:M};if(X){var aa=svgedit.math.transformPoint(Q.x,Q.y,X);Q.x=aa.x;Q.y=aa.y}Q.x*=i;Q.y*=i;return Q}function p(J){f(0,C.textContent.length);$(this).unbind(J)}function w(J){if(L&&C){var M=svgedit.math.transformPoint(J.pageX,J.pageY,fb);M=k(M.x*i,M.y*i);M=e(M.x,M.y);var Q=C.textContent,aa=Q.substr(0,M).replace(/[a-z0-9]+$/i,"").length;Q=Q.substr(M).match(/^[a-z0-9]+/i);f(aa,(Q?Q[0].length:0)+M);$(J.target).click(p);setTimeout(function(){$(J.target).unbind("click",p)},300)}}
var C,I,K,E,N,S=[],U,X,da,R,L;return{select:function(J,M,Q){C=J;Ka.toEditMode(M,Q)},start:function(J){C=J;Ka.toEditMode()},mouseDown:function(J,M,Q,aa){J=k(Q,aa);I.focus();b(e(J.x,J.y));da=Q;R=aa},mouseMove:function(J,M){var Q=k(J,M);q(Q.x,Q.y)},mouseUp:function(J,M,Q){var aa=k(M,Q);q(aa.x,aa.y,true);J.target!==C&&Mda-2&&QR-2&&Ka.toSelectMode(true)},setCursor:b,toEditMode:function(J,M){L=false;va="textedit";qa.requestSelector(C).showGrips(false);qa.requestSelector(C);Ka.init();$(C).css("cursor",
"text");if(arguments.length){var Q=k(J,M);b(e(Q.x,Q.y))}else b();setTimeout(function(){L=true},300)},toSelectMode:function(J){va="select";clearInterval(N);N=null;E&&$(E).attr("display","none");K&&$(K).attr("visibility","hidden");$(C).css("cursor","move");if(J){xa();$(C).css("cursor","move");W("selected",[C]);gb([C],true)}C&&!C.textContent.length&&o.deleteSelectedElements();$(I).blur();C=false},setInputElem:function(J){I=J},clear:function(){va=="textedit"&&Ka.toSelectMode()},init:function(){if(C){var J,
M;if(!C.parentNode){C=r[0];qa.requestSelector(C).showGrips(false)}var Q=C.textContent.length;J=C.getAttribute("transform");U=svgedit.utilities.getBBox(C);X=J?svgedit.math.getMatrix(C):null;S=[];S.length=Q;I.focus();$(C).unbind("dblclick",w).dblclick(w);Q||(M={x:U.x+U.width/2,width:0});for(J=0;J=0&&this.selected_pts.push(I)}this.selected_pts.sort();w=this.selected_pts.length;p=[];for(p.length=w;w--;){C=this.segs[this.selected_pts[w]];C.select(true);p[w]=C.ptgrip}ra.canDeleteNodes=true;ra.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);W("selected",p)};var k=f=null,D=false;return{mouseDown:function(p,w,C,I){var K;if(va==="path"){mouse_x=C;mouse_y=I;I=mouse_x/i;w=mouse_y/i;C=svgedit.utilities.getElem("path_stretch_line");e=[I,w];if(l.gridSnapping){I=svgedit.utilities.snapToGrid(I);
w=svgedit.utilities.snapToGrid(w);mouse_x=svgedit.utilities.snapToGrid(mouse_x);mouse_y=svgedit.utilities.snapToGrid(mouse_y)}if(!C){C=document.createElementNS(d.SVG,"path");svgedit.utilities.assignAttributes(C,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});C=svgedit.utilities.getElem("selectorParentGroup").appendChild(C)}C.setAttribute("display","inline");var E=null;if(k){E=k.pathSegList;var N=E.numberOfItems;K=6/i;for(var S=false;N;){N--;var U=E.getItem(N),X=U.x;U=U.y;
if(I>=X-K&&I<=X+K&&w>=U-K&&w<=U+K){S=true;break}}K=Za();svgedit.path.removePath_(K);K=svgedit.utilities.getElem(K);X=E.numberOfItems;if(S){if(N<=1&&X>=2){I=E.getItem(0).x;w=E.getItem(0).y;p=C.pathSegList.getItem(1);p=p.pathSegType===4?k.createSVGPathSegLinetoAbs(I,w):k.createSVGPathSegCurvetoCubicAbs(I,w,p.x1/i,p.y1/i,I,w);I=k.createSVGPathSegClosePath();E.appendItem(p);E.appendItem(I)}else if(X<3)return E=false;$(C).remove();element=K;k=null;Ba=false;if(b){svgedit.path.path.matrix&&svgedit.coords.remapElement(K,
{},svgedit.path.path.matrix.inverse());C=K.getAttribute("d");p=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",p+C);$(K).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();ra.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,Eb(p))){console.log("Clicked outside canvas");return false}E=k.pathSegList.numberOfItems;N=k.pathSegList.getItem(E-1);K=N.x;N=N.y;if(p.shiftKey){p=svgedit.math.snapToAngle(K,
N,I,w);I=p.x;w=p.y}p=C.pathSegList.getItem(1);p=p.pathSegType===4?k.createSVGPathSegLinetoAbs(Ya(I),Ya(w)):k.createSVGPathSegCurvetoCubicAbs(Ya(I),Ya(w),p.x1/i,p.y1/i,p.x2/i,p.y2/i);k.pathSegList.appendItem(p);I*=i;w*=i;C.setAttribute("d",["M",I,w,I,w].join(" "));C=E;if(b)C+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(C,I,w)}}else{d_attr="M"+I+","+w+" ";k=O({element:"path",curStyles:true,attr:{d:d_attr,id:Ha(),opacity:v.opacity/2}});C.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));
C=b?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(C,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();K=p.target.id;if(K.substr(0,14)=="pathpointgrip_"){w=svgedit.path.path.cur_pt=parseInt(K.substr(14));svgedit.path.path.dragging=[C,I];E=svgedit.path.path.segs[w];if(p.shiftKey)E.selected?svgedit.path.path.removePtFromSelection(w):svgedit.path.path.addPtsToSelection(w);else{if(svgedit.path.path.selected_pts.length<=1||!E.selected)svgedit.path.path.clearSelection();
svgedit.path.path.addPtsToSelection(w)}}else if(K.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[C,I];p=K.split("_")[1].split("c");w=Number(p[0]);svgedit.path.path.selectPt(w,Number(p[1]))}if(!svgedit.path.path.dragging){if(Da==null)Da=qa.getRubberBandBox();svgedit.utilities.assignAttributes(Da,{x:C*i,y:I*i,width:0,height:0,display:"inline"},100)}}},mouseMove:function(p,w){D=true;if(va==="path"){if(k){var C=k.pathSegList,I=C.numberOfItems-1;if(e){var K=svgedit.path.addCtrlGrip("1c1"),E=
svgedit.path.addCtrlGrip("0c2");K.setAttribute("cx",p);K.setAttribute("cy",w);K.setAttribute("display","inline");K=e[0];var N=e[1];C.getItem(I);var S=K+(K-p/i),U=N+(N-w/i);E.setAttribute("cx",S*i);E.setAttribute("cy",U*i);E.setAttribute("display","inline");E=svgedit.path.getCtrlLine(1);svgedit.utilities.assignAttributes(E,{x1:p,y1:w,x2:S*i,y2:U*i,display:"inline"});if(I===0)q=[p,w];else{C=C.getItem(I-1);E=C.x;var X=C.y;if(C.pathSegType===6){E+=E-C.x2;X+=X-C.y2}else if(q){E=q[0]/i;X=q[1]/i}svgedit.path.replacePathSeg(6,
I,[K,N,E,X,S,U],k)}}else if(K=svgedit.utilities.getElem("path_stretch_line")){I=C.getItem(I);if(I.pathSegType===6)svgedit.path.replacePathSeg(6,1,[p,w,(I.x+(I.x-I.x2))*i,(I.y+(I.y-I.y2))*i,p,w],K);else q?svgedit.path.replacePathSeg(6,1,[p,w,q[0],q[1],p,w],K):svgedit.path.replacePathSeg(4,1,[p,w],K)}}}else if(svgedit.path.path.dragging){K=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},svgedit.path.path);N=svgedit.path.getPointFromGrip({x:p,y:w},svgedit.path.path);
I=N.x-K.x;K=N.y-K.y;svgedit.path.path.dragging=[p,w];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(I,K):svgedit.path.path.movePts(I,K)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var da=Da.getBBox(),R=svgedit.path.getGripPt(this);da=svgedit.math.rectsIntersect(da,{x:R.x,y:R.y,width:0,height:0});this.select(da);da&&svgedit.path.path.selected_pts.push(this.index)}})}},mouseUp:function(p,w){if(va==="path"){e=null;if(!k){w=svgedit.utilities.getElem(Za());
Ba=false;q=null}return{keep:true,element:w}}if(svgedit.path.path.dragging){var C=svgedit.path.path.cur_pt;svgedit.path.path.dragging=false;svgedit.path.path.dragctrl=false;svgedit.path.path.update();D&&svgedit.path.path.endChanges("Move path point(s)");!p.shiftKey&&!D&&svgedit.path.path.selectPt(C)}else if(Da&&Da.getAttribute("display")!="none"){Da.setAttribute("display","none");Da.getAttribute("width")<=2&&Da.getAttribute("height")<=2&&ra.toSelectMode(p.target)}else ra.toSelectMode(p.target);D=false},
toEditMode:function(p){svgedit.path.path=svgedit.path.getPath_(p);va="pathedit";xa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);b=false},toSelectMode:function(p){var w=p==svgedit.path.path.elem;va="select";svgedit.path.path.show(false);f=false;xa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(w){W("selected",[p]);gb([p],true)}},addSubPath:function(p){if(p){va="path";b=true}else{ra.clear(true);ra.toEditMode(svgedit.path.path.elem)}},
select:function(p){if(f===p){ra.toEditMode(p);va="pathedit"}else f=p},reorient:function(){var p=r[0];if(p)if(svgedit.utilities.getRotationAngle(p)!=0){var w=new svgedit.history.BatchCommand("Reorient path"),C={d:p.getAttribute("d"),transform:p.getAttribute("transform")};w.addSubCommand(new svgedit.history.ChangeElementCommand(p,C));xa();this.resetOrientation(p);pa(w);svgedit.path.getPath_(p).show(false).matrix=null;this.clear();gb([p],true);W("changed",r)}},clear:function(){f=null;if(k){var p=svgedit.utilities.getElem(Za());
$(svgedit.utilities.getElem("path_stretch_line")).remove();$(p).remove();$(svgedit.utilities.getElem("pathpointgrip_container")).find("*").attr("display","none");k=q=null;Ba=false}else va=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(p){if(p==null||p.nodeName!="path")return false;var w=svgedit.transformlist.getTransformList(p),C=svgedit.math.transformListToTransform(w).matrix;w.clear();p.removeAttribute("transform");w=p.pathSegList;
var I=w.numberOfItems,K;for(K=0;K0){N=I.getItem(K-1).pathSegType;if(N===2){E(K-1,1);C();break}else if(N===1&&I.numberOfItems-1===K){E(K,
1);C();break}}}return false};C();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){ra.toSelectMode(svgedit.path.path.elem);o.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){p=$(svgedit.path.path.elem);p.attr("d",p.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(p){var w=p.points,C=w.numberOfItems;if(C>=4){var I=w.getItem(0),K=null,E=[];E.push(["M",I.x,",",I.y," C"].join(""));for(p=1;p<=
C-4;p+=3){var N=w.getItem(p),S=w.getItem(p+1),U=w.getItem(p+2);if(K)if((I=svgedit.path.smoothControlPoints(K,N,I))&&I.length==2){N=E[E.length-1].split(",");N[2]=I[0].x;N[3]=I[0].y;E[E.length-1]=N.join(",");N=I[1]}E.push([N.x,N.y,S.x,S.y,U.x,U.y].join(","));I=U;K=S}for(E.push("L");p
0;);ra.clear(true);$.each(s.childNodes,function(e,q){e&&q.nodeType===8&&q.data.indexOf("Created with")>=0&&s.insertBefore(q,s.firstChild)});if(B){Ob();$a([B])}var b=[];$(s).find("g:data(gsvg)").each(function(){var e=this.attributes,q=e.length,k;for(k=0;k=0;C--){w=p.item(C);E=q(w.value);if(!(N.indexOf(w.localName)>=0))if(E!="")if(E.indexOf("pointer-events")!==0)if(!(w.localName==="class"&&E.indexOf("se_")===0)){e.push(" ");if(w.localName==="d")E=ra.convertPath(b,true);if(isNaN(E)){if(D.test(E))E=svgedit.units.shortFloat(E)+k}else E=svgedit.units.shortFloat(E);if(Xa.apply&&b.nodeName==="image"&&w.localName==="href"&&Xa.images&&Xa.images==="embed"){var S=jb[E];if(S)E=S}if(!w.namespaceURI||
w.namespaceURI==d.SVG||bb[w.namespaceURI]){e.push(w.nodeName);e.push('="');e.push(E);e.push('"')}}}}if(b.hasChildNodes()){e.push(">");f++;p=false;for(C=0;C");break;case 8:e.push("\n");e.push(Array(f+1).join(" "));
e.push("