open now works

master
Mark MacKay 2012-07-25 22:44:15 -05:00
parent 6fb2e55f48
commit 47af6cf3db
32 changed files with 726 additions and 734 deletions

BIN
.DS_Store vendored

Binary file not shown.

BIN
editor/.DS_Store vendored

Binary file not shown.

View File

@ -51,7 +51,6 @@ svgEditor.addExtension("eyedropper", function(S) {
var getPaint = function(color, opac, type) {
// update the editor's fill paint
var opts = null;
console.log(color);
if (color.indexOf("url(#") === 0) {
var refElem = svgCanvas.getRefElem(color);
if(refElem) {
@ -87,6 +86,7 @@ svgEditor.addExtension("eyedropper", function(S) {
title: "Eye Dropper Tool",
key: "I",
"class": "disabled",
icon: "extensions/eyedropper.png",
events: {
"click": function() {
svgCanvas.setMode("eyedropper");
@ -130,7 +130,6 @@ svgEditor.addExtension("eyedropper", function(S) {
if (currentStyle.strokeLinecap) change(element, "stroke-linecap", currentStyle.strokeLinecap);
if (currentStyle.strokeLinejoin) change(element, "stroke-linejoin", currentStyle.strokeLinejoin);
batchCmd.addSubCommand(new ChangeElementCommand(element, changes));
console.log(changes);
changes = {};
});
var fill = getPaint(currentStyle.fillPaint, currentStyle.fillOpacity*100, "fill")

View File

@ -155,7 +155,7 @@ svgEditor.addExtension("shapes", function() {
type: "mode_flyout", // _flyout
position: 6,
title: "Shape library",
fallback: "extensions/ext-shapes.png",
icon: "extensions/ext-shapes.png",
events: {
"click": function() {
canv.setMode(mode_id);

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 B

After

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 B

After

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 243 B

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

View File

@ -52,6 +52,7 @@
<script type="text/javascript" src="extensions/ext-shapes.js"></script>
<script type="text/javascript" src="requestanimationframe.js"></script>
<script type="text/javascript" src="taphold.js"></script>
<script type="text/javascript" src="extensions/ext-server_opensave.js"></script>
<!--{endif}-->
<!-- you can load extensions here -->
@ -101,6 +102,8 @@ $(function(){
<div class="menu_title" id="logo"></div>
<div class="menu_list">
<div id="tool_about" class="menu_item">About this Editor...</div>
<div class="separator"></div>
<div id="tool_about" class="menu_item">Keyboard Shortcus...</div>
</div>
</a>
@ -108,8 +111,8 @@ $(function(){
<div class="menu_title">File</div>
<div class="menu_list" id="file_menu">
<div id="tool_clear" class="menu_item">New Image</div>
<div id="tool_open" class="menu_item"><div id="fileinputs"></div>Place Image...</div>
<div id="tool_import" class="menu_item"><div id="fileinputs_import"></div>Import SVG...</div>
<div id="tool_open" class="menu_item"><div id="fileinputs"></div>Open SVG...</div>
<div id="tool_import" class="menu_item"><div id="fileinputs_import"></div>Place SVG...</div>
<div id="tool_save" class="menu_item">Save Image... <span class="shortcut">⌘S</span></div>
<div id="tool_export" class="menu_item">Export as PNG</div>
</div>

View File

@ -240,11 +240,11 @@
'spapelib':'shapelib.png',
'node_delete':'node_delete.png',
'align_left':'align-left.png',
'align_center':'align-center',
'align_right':'align-right',
'align_top':'align-top',
'align_middle':'align-middle',
'align_bottom':'align-bottom',
'align_center':'align-center.png',
'align_right':'align-right.png',
'align_top':'align-top.png',
'align_middle':'align-middle.png',
'align_bottom':'align-bottom.png',
'arrow_right':'flyouth.png',
'arrow_down':'dropdown.gif'
},
@ -1005,17 +1005,16 @@
var icon;
var id = btn.id;
var num = i;
// Give button a unique ID
while($('#'+id).length) {
id = btn.id + '_' + (++num);
}
if(!svgicons) {
icon = (btn.type == "menu") ? "" : $('<img src="' + btn.icon + '">');
} else {
fallback_obj[id] = btn.icon;
var svgicon = btn.svgicon ? btn.svgicon : btn.id;
console.log(svgicon);
if(btn.type == 'app_menu') {
placement_obj['#' + id + ' > div'] = svgicon;
} else {
@ -1391,6 +1390,7 @@
//hack to show the proper multialign box
if (multiselected) {
multiselected = multiselected.filter(Boolean)
elem = (svgCanvas.elementsAreSame(multiselected)) ? multiselected[0] : null
if (elem) $("#tools_top").addClass("multiselected")
}
@ -1534,20 +1534,14 @@
});
if(el_name == 'text') {
var font_family = elem.getAttribute("font-family");
var select = document.getElementById("font_family_dropdown");
select.selectedIndex = 3
$('#text_panel').css("display", "inline");
if (svgCanvas.getItalic()) {
$('#tool_italic').addClass('push_button_pressed').removeClass('tool_button');
}
else {
$('#tool_italic').removeClass('push_button_pressed').addClass('tool_button');
}
if (svgCanvas.getBold()) {
$('#tool_bold').addClass('push_button_pressed').removeClass('tool_button');
}
else {
$('#tool_bold').removeClass('push_button_pressed').addClass('tool_button');
}
$('#font_family').val(elem.getAttribute("font-family"));
$('#tool_italic').toggleClass('active', svgCanvas.getItalic())
$('#tool_bold').toggleClass('active', svgCanvas.getBold())
$('#font_family').val(font_family);
$('#font_size').val(elem.getAttribute("font-size"));
$('#text').val(elem.textContent);
if (svgCanvas.addedNew) {
@ -1889,17 +1883,12 @@
top.exports.setEditorFocus();
}
}
if (e.target.nodeName.toLowerCase() === "input") return false;
if (!$(e.target).hasClass("menu_title") && !$(e.target).parent().hasClass("menu_title")) {
if(!$(e.target).hasClass("disabled") && $(e.target).hasClass("menu_item")) {
blinker(e);
return;
}
else {
$('#menu_bar').removeClass('active')
}
if(!$(e.target).hasClass("disabled") && $(e.target).hasClass("menu_item")) blinker(e)
else $('#menu_bar').removeClass('active')
}
}

View File

@ -2216,13 +2216,8 @@ var addToSelection = this.addToSelection = function(elemsToAdd, showGrips) {
}
}
call("selected", selectedElements);
if (showGrips || selectedElements.length == 1) {
selectorManager.requestSelector(selectedElements[0]).showGrips(true);
}
else {
selectorManager.requestSelector(selectedElements[0]).showGrips(false);
}
if (showGrips || selectedElements.length == 1) selectorManager.requestSelector(selectedElements[0]).showGrips(true)
else selectorManager.requestSelector(selectedElements[0]).showGrips(false);
// make sure the elements are in the correct order
// See: http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-compareDocumentPosition
@ -2801,16 +2796,17 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
// alt drag = create a clone and save the reference
if(evt.altKey) {
//clone doesn't exist yet
if (!canvas.addClone) {
canvas.addClone = canvas.cloneSelectedElements(0,0, xform);
canvas.removeClone = function(){
parent = canvas.addClone.parentNode
if (parent) {
parent.removeChild(canvas.addClone)
canvas.addClone = false;
if (!canvas.addClones) {
canvas.addClones = canvas.cloneSelectedElements(0,0, xform);
canvas.removeClones = function(){
if (canvas.addClones) {
canvas.addClones.forEach(function(clone){
if (clone.parentNode) clone.parentNode.removeChild(clone)
canvas.addClones = false;
})
}
}
window.addEventListener("keyup", canvas.removeClone)
window.addEventListener("keyup", canvas.removeClones)
}
}
@ -3209,8 +3205,8 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
// this is done in when we recalculate the selected dimensions()
var mouseUp = function(evt)
{
canvas.addClone = false;
window.removeEventListener("keyup", canvas.removeClone)
canvas.addClones = false;
window.removeEventListener("keyup", canvas.removeClones)
if(evt.button === 2) return;
var tempJustSelected = justSelected;
@ -3887,9 +3883,11 @@ var textActions = canvas.textActions = function() {
},
setCursor: setCursor,
toEditMode: function(x, y) {
selectOnly([curtext], false)
allow_dbl = false;
current_mode = "textedit";
selectorManager.requestSelector(curtext).showGrips(false);
//selectorManager.requestSelector(curtext).showGrips(false);
// Make selector group accept clicks
var sel = selectorManager.requestSelector(curtext).selectorRect;
@ -8582,21 +8580,28 @@ this.cloneSelectedElements = function(x,y, drag) {
// note that we loop in the reverse way because of the way elements are added
// to the selectedElements array (top-first)
var i = copiedElements.length;
clones = []
while (i--) {
// clone each element and replace it within copiedElements
var elem = copiedElements[i]
var clone = copyElem(copiedElements[i]);
if (drag) clone.setAttribute("transform", "");
if (drag) {
//removed the dragged transform until that moment
tlist = getTransformList(clone)
tlist.removeItem(drag)
recalculateDimensions(clone)
}
(current_group || getCurrentDrawing().getCurrentLayer()).appendChild(clone);
clones.push(clone)
batchCmd.addSubCommand(new InsertElementCommand(clone));
}
if (!batchCmd.isEmpty()) {
addToSelection(copiedElements.reverse()); // Need to reverse for correct selection-adding
this.moveSelectedElements(x,y,false);
if (!drag) this.moveSelectedElements(x,y,false);
addCommandToHistory(batchCmd);
}
return clone
return clones
};
// Function: alignSelectedElements

View File

@ -1,18 +1,18 @@
function touchHandler(a){var p=a.changedTouches,g=p[0],c="";switch(a.type){case "touchstart":c="mousedown";break;case "touchmove":c="mousemove";break;case "touchend":c="mouseup";break;default:return}var n=document.createEvent("MouseEvent");n.initMouseEvent(c,true,true,window,1,g.screenX,g.screenY,g.clientX,g.clientY,false,false,false,false,0,null);if(p.length<2){g.target.dispatchEvent(n);a.preventDefault()}};(function(a){function p(g){if(typeof g.data==="string"){var c=g.handler,n=g.data.toLowerCase().split(" ");g.handler=function(s){if(!(this!==s.target&&(/textarea|select/i.test(s.target.nodeName)||s.target.type==="text"))){var b=s.type!=="keypress"&&a.hotkeys.specialKeys[s.which],f=String.fromCharCode(s.which).toLowerCase(),d="",l={};if(s.altKey&&b!=="alt")d+="alt+";if(s.ctrlKey&&b!=="ctrl")d+="ctrl+";if(s.metaKey&&!s.ctrlKey&&b!=="meta")d+="meta+";if(s.shiftKey&&b!=="shift")d+="shift+";if(b)l[d+b]=
true;else{l[d+f]=true;l[d+a.hotkeys.shiftNums[f]]=true;if(d==="shift+")l[a.hotkeys.shiftNums[f]]=true}b=0;for(f=n.length;b<f;b++)if(l[n[b]])return c.apply(this,arguments)}}}}a.hotkeys={version:"0.8",specialKeys:{8:"backspace",9:"tab",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",
106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",191:"/",224:"meta",219:"[",221:"]"},shiftNums:{"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"}};a.each(["keydown","keyup","keypress"],function(){a.event.special[this]={add:p}})})(jQuery);(function(a,p){function g(da){return typeof da==="string"}function c(da){var V=d.call(arguments,1);return function(){return da.apply(this,V.concat(d.call(arguments)))}}function n(da,V,Z,oa,qa){var ma;if(oa!==f){V=Z.match(da?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);Z=V[3]||"";if(qa===2&&g(oa))oa=oa.replace(da?W:ba,"");else{ma=o(V[2]);oa=g(oa)?o[da?ia:O](oa):oa;oa=qa===2?oa:qa===1?a.extend({},oa,ma):a.extend({},ma,oa);oa=q(oa);if(da)oa=oa.replace(sa,l)}da=V[1]+(da?"#":oa||!V[1]?"?":"")+oa+Z}else da=
V(Z!==f?Z:p[pa][fa]);return da}function s(da,V,Z){if(V===f||typeof V==="boolean"){Z=V;V=q[da?ia:O]()}else V=g(V)?V.replace(da?W:ba,""):V;return o(V,Z)}function b(da,V,Z,oa){if(!g(Z)&&typeof Z!=="object"){oa=Z;Z=V;V=f}return this.each(function(){var qa=a(this),ma=V||Q()[(this.nodeName||"").toLowerCase()]||"",na=ma&&qa.attr(ma)||"";qa.attr(ma,q[da](na,Z,oa))})}var f,d=Array.prototype.slice,l=decodeURIComponent,q=a.param,B,o,K,T=a.bbq=a.bbq||{},M,J,Q,Y=a.event.special,O="querystring",ia="fragment",pa=
V(Z!==f?Z:p[pa][fa]);return da}function s(da,V,Z){if(V===f||typeof V==="boolean"){Z=V;V=q[da?ia:O]()}else V=g(V)?V.replace(da?W:ba,""):V;return o(V,Z)}function b(da,V,Z,oa){if(!g(Z)&&typeof Z!=="object"){oa=Z;Z=V;V=f}return this.each(function(){var qa=a(this),ma=V||Q()[(this.nodeName||"").toLowerCase()]||"",na=ma&&qa.attr(ma)||"";qa.attr(ma,q[da](na,Z,oa))})}var f,d=Array.prototype.slice,l=decodeURIComponent,q=a.param,B,o,K,T=a.bbq=a.bbq||{},M,J,Q,X=a.event.special,O="querystring",ia="fragment",pa=
"location",fa="href",ba=/^.*\?|#.*$/g,W=/^.*\#/,sa,ka={};q[O]=c(n,0,function(da){return da.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")});q[ia]=B=c(n,1,function(da){return da.replace(/^[^#]*#?(.*)$/,"$1")});B.noEscape=function(da){da=da||"";da=a.map(da.split(""),encodeURIComponent);sa=RegExp(da.join("|"),"g")};B.noEscape(",/");a.deparam=o=function(da,V){var Z={},oa={"true":true,"false":false,"null":null};a.each(da.replace(/\+/g," ").split("&"),function(qa,ma){var na=ma.split("="),Aa=l(na[0]),Fa=Z,Ia=
0,Ca=Aa.split("]["),Ka=Ca.length-1;if(/\[/.test(Ca[0])&&/\]$/.test(Ca[Ka])){Ca[Ka]=Ca[Ka].replace(/\]$/,"");Ca=Ca.shift().split("[").concat(Ca);Ka=Ca.length-1}else Ka=0;if(na.length===2){na=l(na[1]);if(V)na=na&&!isNaN(na)?+na:na==="undefined"?f:oa[na]!==f?oa[na]:na;if(Ka)for(;Ia<=Ka;Ia++){Aa=Ca[Ia]===""?Fa.length:Ca[Ia];Fa=Fa[Aa]=Ia<Ka?Fa[Aa]||(Ca[Ia+1]&&isNaN(Ca[Ia+1])?{}:[]):na}else if(a.isArray(Z[Aa]))Z[Aa].push(na);else Z[Aa]=Z[Aa]!==f?[Z[Aa],na]:na}else if(Aa)Z[Aa]=V?f:""});return Z};o[O]=c(s,
0);o[ia]=K=c(s,1);a.elemUrlAttr||(a.elemUrlAttr=function(da){return a.extend(ka,da)})({a:fa,base:fa,iframe:"src",img:"src",input:"src",form:"action",link:fa,script:"src"});Q=a.elemUrlAttr;a.fn[O]=c(b,O);a.fn[ia]=c(b,ia);T.pushState=M=function(da,V){if(g(da)&&/^#/.test(da)&&V===f)V=2;var Z=da!==f;Z=B(p[pa][fa],Z?da:{},Z?V:2);p[pa][fa]=Z+(/#/.test(Z)?"":"#")};T.getState=J=function(da,V){return da===f||typeof da==="boolean"?K(da):K(V)[da]};T.removeState=function(da){var V={};if(da!==f){V=J();a.each(a.isArray(da)?
da:arguments,function(Z,oa){delete V[oa]})}M(V,2)};Y.hashchange=a.extend(Y.hashchange,{add:function(da){function V(oa){var qa=oa[ia]=B();oa.getState=function(ma,na){return ma===f||typeof ma==="boolean"?o(qa,ma):o(qa,na)[ma]};Z.apply(this,arguments)}var Z;if(a.isFunction(da)){Z=da;return V}else{Z=da.handler;da.handler=V}}})})(jQuery,this);
da:arguments,function(Z,oa){delete V[oa]})}M(V,2)};X.hashchange=a.extend(X.hashchange,{add:function(da){function V(oa){var qa=oa[ia]=B();oa.getState=function(ma,na){return ma===f||typeof ma==="boolean"?o(qa,ma):o(qa,na)[ma]};Z.apply(this,arguments)}var Z;if(a.isFunction(da)){Z=da;return V}else{Z=da.handler;da.handler=V}}})})(jQuery,this);
(function(a,p,g){function c(B){B=B||p[b][f];return B.replace(/^[^#]*#?(.*)$/,"$1")}var n,s=a.event.special,b="location",f="href",d=document.documentMode,l=a.browser.msie&&(d===g||d<8),q="onhashchange"in p&&!l;a.hashchangeDelay=100;s.hashchange=a.extend(s.hashchange,{setup:function(){if(q)return false;a(n.start)},teardown:function(){if(q)return false;a(n.stop)}});n=function(){function B(){M=J=function(Q){return Q};if(l){T=a('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;
J=function(){return c(T.document[b][f])};M=function(Q,Y){if(Q!==Y){var O=T.document;O.open().close();O[b].hash="#"+Q}};M(c())}}var o={},K,T,M,J;o.start=function(){if(!K){var Q=c();M||B();(function Y(){var O=c(),ia=J(Q);if(O!==Q){M(Q=O,ia);a(p).trigger("hashchange")}else if(ia!==Q)p[b][f]=p[b][f].replace(/#.*/,"")+"#"+ia;K=setTimeout(Y,a.hashchangeDelay)})()}};o.stop=function(){if(!T){K&&clearTimeout(K);K=0}};return o}()})(jQuery,this);(function(a){var p={},g;a.svgIcons=function(c,n){function s(da,V){if(da!=="ajax"){if(Q)return;var Z=(T=fa[0].contentDocument)&&T.getElementById("svg_eof");if(!Z&&!(V&&Z)){Y++;if(Y<50)setTimeout(s,20);else{f();Q=true}return}Q=true}K=a(T.firstChild).children();if(n.no_img)setTimeout(function(){J||b()},500);else{Z=pa+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";M=a(new Image).attr({src:Z,width:0,height:0}).appendTo("body").load(function(){b(true)}).error(function(){b()})}}
J=function(){return c(T.document[b][f])};M=function(Q,X){if(Q!==X){var O=T.document;O.open().close();O[b].hash="#"+Q}};M(c())}}var o={},K,T,M,J;o.start=function(){if(!K){var Q=c();M||B();(function X(){var O=c(),ia=J(Q);if(O!==Q){M(Q=O,ia);a(p).trigger("hashchange")}else if(ia!==Q)p[b][f]=p[b][f].replace(/#.*/,"")+"#"+ia;K=setTimeout(X,a.hashchangeDelay)})()}};o.stop=function(){if(!T){K&&clearTimeout(K);K=0}};return o}()})(jQuery,this);(function(a){var p={},g;a.svgIcons=function(c,n){function s(da,V){if(da!=="ajax"){if(Q)return;var Z=(T=fa[0].contentDocument)&&T.getElementById("svg_eof");if(!Z&&!(V&&Z)){X++;if(X<50)setTimeout(s,20);else{f();Q=true}return}Q=true}K=a(T.firstChild).children();if(n.no_img)setTimeout(function(){J||b()},500);else{Z=pa+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";M=a(new Image).attr({src:Z,width:0,height:0}).appendTo("body").load(function(){b(true)}).error(function(){b()})}}
function b(da,V){if(!J){if(n.no_img)da=false;if(da){var Z=a(document.createElement("div"));Z.hide().appendTo("body")}if(V){var oa=n.fallback_path?n.fallback_path:"";a.each(V,function(Ka,Na){a("#"+Ka);var za=a(new Image).attr({"class":"svg_icon",src:oa+Na,width:B,height:o,alt:"icon"});ka(za,Ka)})}else for(var qa=K.length,ma=0;ma<qa;ma++){var na=K[ma],Aa=na.id;if(Aa==="svg_eof")break;a("#"+Aa);na=na.getElementsByTagNameNS(l,"svg")[0];var Fa=document.createElementNS(l,"svg");Fa.setAttributeNS(l,"viewBox",
[0,0,B,o].join(" "));var Ia=na.getAttribute("width"),Ca=na.getAttribute("height");na.removeAttribute("width");na.removeAttribute("height");na.getAttribute("viewBox")||na.setAttribute("viewBox",[0,0,Ia,Ca].join(" "));Fa.setAttribute("xmlns",l);Fa.setAttribute("width",B);Fa.setAttribute("height",o);Fa.setAttribute("xmlns:xlink",q);Fa.setAttribute("class","svg_icon");ia||(na=na.cloneNode(true));Fa.appendChild(na);if(da){ia||Fa.cloneNode(true);Z.empty().append(Fa);na=pa+d(Z.html());na=a(new Image).attr({"class":"svg_icon",
src:na})}else na=g(a(Fa),ma);ka(na,Aa)}n.placement&&a.each(n.placement,function(Ka,Na){p[Na]&&a(Ka).each(function(za){var ya=p[Na].clone();if(za>0&&!da)ya=g(ya,za,true);sa(a(this),ya,Na)})});if(!V){da&&Z.remove();fa&&fa.remove();M&&M.remove()}n.resize&&a.resizeSvgIcons(n.resize);J=true;n.callback&&n.callback(p)}}function f(){if(c.indexOf(".svgz")!=-1){var da=c.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg");a.svgIcons(da,n)}else n.fallback&&b(false,n.fallback)}
function d(da){if(window.btoa)return window.btoa(da);var V=Array(Math.floor((da.length+2)/3)*4),Z,oa,qa,ma,na,Aa,Fa=0,Ia=0;do{Z=da.charCodeAt(Fa++);oa=da.charCodeAt(Fa++);qa=da.charCodeAt(Fa++);ma=Z>>2;Z=(Z&3)<<4|oa>>4;na=(oa&15)<<2|qa>>6;Aa=qa&63;if(isNaN(oa))na=Aa=64;else if(isNaN(qa))Aa=64;V[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(ma);V[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Z);V[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(na);
V[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Aa)}while(Fa<da.length);return V.join("")}var l="http://www.w3.org/2000/svg",q="http://www.w3.org/1999/xlink",B=n.w?n.w:24,o=n.h?n.h:24,K,T,M,J=false,Q=false,Y=0,O=navigator.userAgent,ia=!!window.opera;O.indexOf("Safari/")>-1&&O.indexOf("Chrome/");var pa="data:image/svg+xml;charset=utf-8;base64,";if(n.svgz){var fa=a('<object data="'+c+'" type=image/svg+xml>').appendTo("body").hide();try{T=fa[0].contentDocument;fa.load(s);
V[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Aa)}while(Fa<da.length);return V.join("")}var l="http://www.w3.org/2000/svg",q="http://www.w3.org/1999/xlink",B=n.w?n.w:24,o=n.h?n.h:24,K,T,M,J=false,Q=false,X=0,O=navigator.userAgent,ia=!!window.opera;O.indexOf("Safari/")>-1&&O.indexOf("Chrome/");var pa="data:image/svg+xml;charset=utf-8;base64,";if(n.svgz){var fa=a('<object data="'+c+'" type=image/svg+xml>').appendTo("body").hide();try{T=fa[0].contentDocument;fa.load(s);
s(0,true)}catch(ba){f()}}else{var W=new DOMParser;a.ajax({url:c,dataType:"string",success:function(da){if(da){T=W.parseFromString(da,"text/xml");a(function(){s("ajax")})}else a(f)},error:function(da){if(window.opera)a(function(){f()});else if(da.responseText){T=W.parseFromString(da.responseText,"text/xml");T.childNodes.length||a(f);a(function(){s("ajax")})}else a(f)}})}var sa=function(da,V,Z,oa){ia&&V.css("visibility","hidden");if(n.replace){oa&&V.attr("id",Z);(Z=da.attr("class"))&&V.attr("class",
"svg_icon "+Z);da.replaceWith(V)}else da.append(V);ia&&setTimeout(function(){V.removeAttr("style")},1)},ka=function(da,V){if(n.id_match===undefined||n.id_match!==false)sa(holder,da,V,true);p[V]=da};g=function(da,V){var Z=da.find("defs");if(!Z.length)return da;Z=ia?Z.find("*").filter(function(){return!!this.id}):Z.find("[id]");var oa=da[0].getElementsByTagName("*"),qa=oa.length;Z.each(function(ma){var na=this.id;a(T).find("#"+na);this.id=ma="x"+na+V+ma;na="url(#"+na+")";var Aa="url(#"+ma+")";for(ma=
0;ma<qa;ma++){var Fa=oa[ma];Fa.getAttribute("fill")===na&&Fa.setAttribute("fill",Aa);Fa.getAttribute("stroke")===na&&Fa.setAttribute("stroke",Aa);Fa.getAttribute("filter")===na&&Fa.setAttribute("filter",Aa)}});return da}};a.getSvgIcon=function(c,n){var s=p[c];if(n&&s)s=g(s,0,true).clone(true);return s};a.resizeSvgIcons=function(c){var n=!a(".svg_icon:first").length;a.each(c,function(s,b){var f=a.isArray(b),d=f?b[0]:b,l=f?b[1]:b;if(n)s=s.replace(/\.svg_icon/g,"svg");a(s).each(function(){this.setAttribute("width",
@ -20,14 +20,14 @@ d);this.setAttribute("height",l);if(window.opera&&window.widget){this.parentNode
c.copy.type;this.alpha=c.copy.alpha;this.radialGradient=this.linearGradient=this.solidColor=null;switch(this.type){case "solidColor":this.solidColor=c.copy.solidColor;break;case "linearGradient":this.linearGradient=c.copy.linearGradient.cloneNode(true);break;case "radialGradient":this.radialGradient=c.copy.radialGradient.cloneNode(true)}}else if(c.linearGradient){this.type="linearGradient";this.radialGradient=this.solidColor=null;this.linearGradient=c.linearGradient.cloneNode(true)}else if(c.radialGradient){this.type=
"radialGradient";this.linearGradient=this.solidColor=null;this.radialGradient=c.radialGradient.cloneNode(true)}else if(c.solidColor){this.type="solidColor";this.solidColor=c.solidColor}else{this.type="none";this.radialGradient=this.linearGradient=this.solidColor=null}}};jQuery.fn.jGraduateDefaults={paint:new $.jGraduate.Paint,window:{pickerTitle:"Drag markers to pick a paint"},images:{clientPath:"images/"},newstop:"inverse"};var g=navigator.userAgent.indexOf("Gecko/")>=0;jQuery.fn.jGraduate=function(c){var n=
arguments;return this.each(function(){function s(la,ca,ja,N,R){var ea=R||a("stop",{"stop-color":ca,"stop-opacity":ja,offset:la},W);if(R){ca=R.getAttribute("stop-color");ja=R.getAttribute("stop-opacity");la=R.getAttribute("offset")}else W.appendChild(ea);if(ja===null)ja=1;R=a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:"url(#jGraduate_trans)",transform:"translate("+(10+la*ia)+", 26)"},qb);var Ga=
a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:ca,"fill-opacity":ja,transform:"translate("+(10+la*ia)+", 26)",stroke:"#000","stroke-width":1.5},qb);$(Ga).mousedown(function(Oa){b(this);Ra=ib;Q.mousemove(l).mouseup(f);va=$a.offset();Oa.preventDefault();return false}).data("stop",ea).data("bg",R).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Oa=this,Ya=+ea.getAttribute("stop-opacity")||
1,db=ea.getAttribute("stop-color")||1,nb=(parseFloat(Ya)*255).toString(16);nb.length<2;)nb="0"+nb;ca=db.substr(1)+nb;$("#"+o+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:B.images.clientPath},color:{active:ca,alphaSupport:true}},function(Xa){db=Xa.val("hex")?"#"+Xa.val("hex"):"none";Ya=Xa.val("a")!==null?Xa.val("a")/256:1;Oa.setAttribute("fill",db);Oa.setAttribute("fill-opacity",Ya);ea.setAttribute("stop-color",
db);ea.setAttribute("stop-opacity",Ya);$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()})});$(W).find("stop").each(function(){var Oa=$(this);if(+this.getAttribute("offset")>la){if(!ca){var Ya=this.getAttribute("stop-color"),db=this.getAttribute("stop-opacity");ea.setAttribute("stop-color",Ya);Ga.setAttribute("fill",Ya);ea.setAttribute("stop-opacity",db===null?1:db);Ga.setAttribute("fill-opacity",
db===null?1:db)}Oa.before(ea);return false}});N&&b(Ga);return ea}function b(la){ib&&ib.setAttribute("stroke","#000");la.setAttribute("stroke","blue");ib=la;ib.parentNode.appendChild(ib)}function f(){Q.unbind("mousemove",l);if(Da.getAttribute("display")!=="none"){Da.setAttribute("display","none");var la=$(ib),ca=la.data("stop");la=la.data("bg");$([ib,ca,la]).remove()}Ra=null}function d(){var la=Ua?"rotate("+Ua+","+Ea+","+kb+") ":"";fb===1&&La===1?W.removeAttribute("gradientTransform"):W.setAttribute("gradientTransform",
la+"translate("+-Ea*(fb-1)+","+-kb*(La-1)+") scale("+fb+","+La+")")}function l(la){var ca=la.pageX-va.left;la=la.pageY-va.top;ca=ca<10?10:ca>ia+10?ia+10:ca;var ja="translate("+ca+", 26)";if(la<-60||la>130){Da.setAttribute("display","block");Da.setAttribute("transform",ja)}else Da.setAttribute("display","none");Ra.setAttribute("transform",ja);$.data(Ra,"bg").setAttribute("transform",ja);$.data(Ra,"stop").setAttribute("offset",(ca-10)/ia);var N=0;$(W).find("stop").each(function(){var R=this.getAttribute("offset"),
a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:ca,"fill-opacity":ja,transform:"translate("+(10+la*ia)+", 26)",stroke:"#000","stroke-width":1.5},qb);$(Ga).mousedown(function(Pa){b(this);Sa=ib;Q.mousemove(l).mouseup(f);va=$a.offset();Pa.preventDefault();return false}).data("stop",ea).data("bg",R).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Pa=this,Ya=+ea.getAttribute("stop-opacity")||
1,db=ea.getAttribute("stop-color")||1,nb=(parseFloat(Ya)*255).toString(16);nb.length<2;)nb="0"+nb;ca=db.substr(1)+nb;$("#"+o+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:B.images.clientPath},color:{active:ca,alphaSupport:true}},function(Ua){db=Ua.val("hex")?"#"+Ua.val("hex"):"none";Ya=Ua.val("a")!==null?Ua.val("a")/256:1;Pa.setAttribute("fill",db);Pa.setAttribute("fill-opacity",Ya);ea.setAttribute("stop-color",
db);ea.setAttribute("stop-opacity",Ya);$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()})});$(W).find("stop").each(function(){var Pa=$(this);if(+this.getAttribute("offset")>la){if(!ca){var Ya=this.getAttribute("stop-color"),db=this.getAttribute("stop-opacity");ea.setAttribute("stop-color",Ya);Ga.setAttribute("fill",Ya);ea.setAttribute("stop-opacity",db===null?1:db);Ga.setAttribute("fill-opacity",
db===null?1:db)}Pa.before(ea);return false}});N&&b(Ga);return ea}function b(la){ib&&ib.setAttribute("stroke","#000");la.setAttribute("stroke","blue");ib=la;ib.parentNode.appendChild(ib)}function f(){Q.unbind("mousemove",l);if(Da.getAttribute("display")!=="none"){Da.setAttribute("display","none");var la=$(ib),ca=la.data("stop");la=la.data("bg");$([ib,ca,la]).remove()}Sa=null}function d(){var la=Va?"rotate("+Va+","+Ea+","+kb+") ":"";fb===1&&La===1?W.removeAttribute("gradientTransform"):W.setAttribute("gradientTransform",
la+"translate("+-Ea*(fb-1)+","+-kb*(La-1)+") scale("+fb+","+La+")")}function l(la){var ca=la.pageX-va.left;la=la.pageY-va.top;ca=ca<10?10:ca>ia+10?ia+10:ca;var ja="translate("+ca+", 26)";if(la<-60||la>130){Da.setAttribute("display","block");Da.setAttribute("transform",ja)}else Da.setAttribute("display","none");Sa.setAttribute("transform",ja);$.data(Sa,"bg").setAttribute("transform",ja);$.data(Sa,"stop").setAttribute("offset",(ca-10)/ia);var N=0;$(W).find("stop").each(function(){var R=this.getAttribute("offset"),
ea=$(this);if(R<N){ea.prev().before(ea);wa=$(W).find("stop")}N=R})}var q=$(this),B=$.extend(true,{},jQuery.fn.jGraduateDefaults,c),o=q.attr("id"),K="#"+q.attr("id")+" ";if(K){var T=function(){switch(q.paint.type){case "radialGradient":q.paint.linearGradient=null;break;case "linearGradient":q.paint.radialGradient=null;break;case "solidColor":q.paint.radialGradient=q.paint.linearGradient=null}$.isFunction(q.okCallback)&&q.okCallback(q.paint);q.hide()},M=function(){$.isFunction(q.cancelCallback)&&q.cancelCallback();
q.hide()};$.extend(true,q,{paint:new $.jGraduate.Paint({copy:B.paint}),okCallback:$.isFunction(n[1])&&n[1]||null,cancelCallback:$.isFunction(n[2])&&n[2]||null});q.position();var J=null,Q=$(window);if(q.paint.type=="none")q.paint=$.jGraduate.Paint({solidColor:"ffffff"});q.addClass("jGraduate_Picker");q.html('<ul class="jGraduate_tabs"><li class="jGraduate_tab_color jGraduate_tab_current" data-type="col">Solid Color</li><li class="jGraduate_tab_lingrad" data-type="lg">Linear Gradient</li><li class="jGraduate_tab_radgrad" data-type="rg">Radial Gradient</li></ul><div class="jGraduate_colPick"></div><div class="jGraduate_gradPick"></div><div class="jGraduate_LightBox"></div><div id="'+
o+'_jGraduate_stopPicker" class="jGraduate_stopPicker"></div>');var Y=$(K+"> .jGraduate_colPick"),O=$(K+"> .jGraduate_gradPick");O.html('<div id="'+o+'_jGraduate_Swatch" class="jGraduate_Swatch"><h2 class="jGraduate_Title">'+B.window.pickerTitle+'</h2><div id="'+o+'_jGraduate_GradContainer" class="jGraduate_GradContainer"></div><div id="'+o+'_jGraduate_StopSlider" class="jGraduate_StopSlider"></div></div><div class="jGraduate_Form jGraduate_Points jGraduate_lg_field"><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">Begin Point</label><div class="jGraduate_Form_Section"><label>x:</label><input type="text" id="'+
o+'_jGraduate_stopPicker" class="jGraduate_stopPicker"></div>');var X=$(K+"> .jGraduate_colPick"),O=$(K+"> .jGraduate_gradPick");O.html('<div id="'+o+'_jGraduate_Swatch" class="jGraduate_Swatch"><h2 class="jGraduate_Title">'+B.window.pickerTitle+'</h2><div id="'+o+'_jGraduate_GradContainer" class="jGraduate_GradContainer"></div><div id="'+o+'_jGraduate_StopSlider" class="jGraduate_StopSlider"></div></div><div class="jGraduate_Form jGraduate_Points jGraduate_lg_field"><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">Begin Point</label><div class="jGraduate_Form_Section"><label>x:</label><input type="text" id="'+
o+'_jGraduate_x1" size="3" title="Enter starting x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+o+'_jGraduate_y1" size="3" title="Enter starting y value between 0.0 and 1.0"/></div></div><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">End Point</label><div class="jGraduate_Form_Section"><label>x:</label><input type="text" id="'+o+'_jGraduate_x2" size="3" title="Enter ending x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+
o+'_jGraduate_y2" size="3" title="Enter ending y value between 0.0 and 1.0"/></div></div></div><div class="jGraduate_Form jGraduate_Points jGraduate_rg_field"><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">Center Point</label><div class="jGraduate_Form_Section"><label>x:</label><input type="text" id="'+o+'_jGraduate_cx" size="3" title="Enter x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+o+'_jGraduate_cy" size="3" title="Enter y value between 0.0 and 1.0"/></div></div><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">Focal Point</label><div class="jGraduate_Form_Section"><label>Match center: <input type="checkbox" checked="checked" id="'+
o+'_jGraduate_match_ctr"/></label><br/><label>x:</label><input type="text" id="'+o+'_jGraduate_fx" size="3" title="Enter x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+o+'_jGraduate_fy" size="3" title="Enter y value between 0.0 and 1.0"/></div></div></div><div class="jGraduate_StopSection jGraduate_SpreadMethod"><label class="jGraduate_Form_Heading">Spread method</label><div class="jGraduate_Form_Section"><select class="jGraduate_spreadMethod"><option value=pad selected>Pad</option><option value=reflect>Reflect</option><option value=repeat>Repeat</option></select></div></div><div class="jGraduate_Form"><div class="jGraduate_Slider jGraduate_RadiusField jGraduate_rg_field"><label class="prelabel">Radius:</label><div id="'+
@ -39,21 +39,21 @@ Z=W=V.appendChild(W)}a("radialGradient",{id:o+"_rg_jgraduate_grad"},V);if(ba==="
if(Aa.length<2)Aa=0+Aa;ma+=Aa}s(1,"#"+ma,1);break;case "white":s(1,"#ffffff",1);break;case "black":s(1,"#000000",1)}else if(ma==="object")s(1,B.newstop.color||"#"+J,"opac"in B.newstop?B.newstop.opac:1)}J=parseFloat(Z.getAttribute("x1")||0);ma=parseFloat(Z.getAttribute("y1")||0);na=parseFloat(Z.getAttribute("x2")||1);Aa=parseFloat(Z.getAttribute("y2")||0);var Fa=parseFloat(Z.getAttribute("cx")||0.5),Ia=parseFloat(Z.getAttribute("cy")||0.5),Ca=parseFloat(Z.getAttribute("fx")||Fa),Ka=parseFloat(Z.getAttribute("fy")||
Ia);sa=a("rect",{id:o+"_jgraduate_rect",x:0,y:0,width:pa,height:fa,fill:"url(#"+o+"_jgraduate_grad)","fill-opacity":oa/100},V);var Na=$("<div/>").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:ma*ia,left:J*ia}).data("coord","start").appendTo(da),za=Na.clone().text(2).css({top:Aa*ia,left:na*ia}).attr("title","End stop").data("coord","end").appendTo(da),ya=$("<div/>").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Ia*ia,left:Fa*
ia}).data("coord","center").appendTo(da),Ha=ya.clone().text("F").css({top:Ka*ia,left:Ca*ia,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(da);Ha[0].id=o+"_jGraduate_focusCoord";$(K+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(la,ca){var ja=W.getAttribute(ca),N=isNaN(ca[1]);ja||(ja=N?"0.5":ca==="x2"?"1.0":"0.0");ka[ca]=$("#"+o+"_jGraduate_"+ca).val(ja).change(function(){if(isNaN(parseFloat(this.value))||this.value<0)this.value=0;else if(this.value>
1)this.value=1;if(!(ca[0]==="f"&&!jb))if(N&&ba==="radialGradient"||!N&&ba==="linearGradient")W.setAttribute(ca,this.value);var R=N?ca[0]==="c"?ya:Ha:ca[1]==="1"?Na:za,ea=ca.indexOf("x")>=0?"left":"top";R.css(ea,this.value*ia)}).change()});var wa,qb,$a=$("#"+o+"_jGraduate_StopSlider"),ib,Va,Ra,Da=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},Va),va,fb=1,La=1,Ua=0,Ea=Fa,kb=Ia;Va=a("svg",{width:"100%",height:45},$a[0]);da=a("pattern",{width:16,
height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},Va);a("image",{width:16,height:16},da).setAttributeNS(p.xlink,"xlink:href",B.images.clientPath+"map-opacity.png");$(Va).on("click touchstart",function(la){va=$a.offset();if(la.target.tagName!=="path"){var ca=la.pageX-va.left-8;ca=ca<10?10:ca>ia+10?ia+10:ca;s(ca/ia,0,0,true);la.stopPropagation()}});$(Va).mouseover(function(){Va.appendChild(Da)});qb=a("g",{},Va);a("line",{x1:10,y1:15,x2:ia+10,y2:15,"stroke-width":2,stroke:"#000"},Va);var sb=
1)this.value=1;if(!(ca[0]==="f"&&!jb))if(N&&ba==="radialGradient"||!N&&ba==="linearGradient")W.setAttribute(ca,this.value);var R=N?ca[0]==="c"?ya:Ha:ca[1]==="1"?Na:za,ea=ca.indexOf("x")>=0?"left":"top";R.css(ea,this.value*ia)}).change()});var wa,qb,$a=$("#"+o+"_jGraduate_StopSlider"),ib,Wa,Sa,Da=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},Wa),va,fb=1,La=1,Va=0,Ea=Fa,kb=Ia;Wa=a("svg",{width:"100%",height:45},$a[0]);da=a("pattern",{width:16,
height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},Wa);a("image",{width:16,height:16},da).setAttributeNS(p.xlink,"xlink:href",B.images.clientPath+"map-opacity.png");$(Wa).on("click touchstart",function(la){va=$a.offset();if(la.target.tagName!=="path"){var ca=la.pageX-va.left-8;ca=ca<10?10:ca>ia+10?ia+10:ca;s(ca/ia,0,0,true);la.stopPropagation()}});$(Wa).mouseover(function(){Wa.appendChild(Da)});qb=a("g",{},Wa);a("line",{x1:10,y1:15,x2:ia+10,y2:15,"stroke-width":2,stroke:"#000"},Wa);var sb=
O.find(".jGraduate_spreadMethod").change(function(){W.setAttribute("spreadMethod",$(this).val())}),Za=null,bb=function(la){var ca=la.pageX-mb.left,ja=la.pageY-mb.top;ca=ca<0?0:ca>ia?ia:ca;ja=ja<0?0:ja>ia?ia:ja;Za.css("left",ca).css("top",ja);ca=ca/pa;ja=ja/fa;var N=Za.data("coord"),R=W;switch(N){case "start":ka.x1.val(ca);ka.y1.val(ja);R.setAttribute("x1",ca);R.setAttribute("y1",ja);break;case "end":ka.x2.val(ca);ka.y2.val(ja);R.setAttribute("x2",ca);R.setAttribute("y2",ja);break;case "center":ka.cx.val(ca);
ka.cy.val(ja);R.setAttribute("cx",ca);R.setAttribute("cy",ja);Ea=ca;kb=ja;d();break;case "focus":ka.fx.val(ca);ka.fy.val(ja);R.setAttribute("fx",ca);R.setAttribute("fy",ja);d()}la.preventDefault()},Cb=function(){Za=null;Q.unbind("mousemove",bb).unbind("mouseup",Cb)};wa=W.getElementsByTagNameNS(p.svg,"stop");if(ta<2){for(;ta<2;){W.appendChild(document.createElementNS(p.svg,"stop"));++ta}wa=W.getElementsByTagNameNS(p.svg,"stop")}var ta=wa.length;for(na=0;na<ta;na++)s(0,0,0,0,wa[na]);sb.val(W.getAttribute("spreadMethod")||
ka.cy.val(ja);R.setAttribute("cx",ca);R.setAttribute("cy",ja);Ea=ca;kb=ja;d();break;case "focus":ka.fx.val(ca);ka.fy.val(ja);R.setAttribute("fx",ca);R.setAttribute("fy",ja);d()}la.preventDefault()},Cb=function(){Za=null;Q.unbind("mousemove",bb).unbind("mouseup",Cb)};wa=W.getElementsByTagNameNS(p.svg,"stop");if(ua<2){for(;ua<2;){W.appendChild(document.createElementNS(p.svg,"stop"));++ua}wa=W.getElementsByTagNameNS(p.svg,"stop")}var ua=wa.length;for(na=0;na<ua;na++)s(0,0,0,0,wa[na]);sb.val(W.getAttribute("spreadMethod")||
"pad");var mb,jb=false;sa.setAttribute("fill-opacity",oa/100);$("#"+o+" div.grad_coord").mousedown(function(la){la.preventDefault();Za=$(this);Za.offset();mb=Za.parent().offset();Q.mousemove(bb).mouseup(Cb)});$("#"+o+"_jGraduate_Ok").bind("click touchstart",function(){q.paint.type=ba;q.paint[ba]=W.cloneNode(true);q.paint.solidColor=null;T()});$("#"+o+"_jGraduate_Cancel").bind("click touchstart",function(){M()});if(ba==="radialGradient")if(jb)Ha.show();else{Ha.hide();ka.fx.val("");ka.fy.val("")}$("#"+
o+"_jGraduate_match_ctr")[0].checked=!jb;var zb,ob;$("#"+o+"_jGraduate_match_ctr").change(function(){jb=!this.checked;Ha.toggle(jb);ka.fx.val("");ka.fy.val("");var la=W;if(jb){var ca=zb||0.5,ja=ob||0.5;la.setAttribute("fx",ca);la.setAttribute("fy",ja);ka.fx.val(ca);ka.fy.val(ja)}else{zb=la.getAttribute("fx");ob=la.getAttribute("fy");la.removeAttribute("fx");la.removeAttribute("fy")}});wa=W.getElementsByTagNameNS(p.svg,"stop");ta=wa.length;if(ta<2){for(;ta<2;){W.appendChild(document.createElementNS(p.svg,
"stop"));++ta}wa=W.getElementsByTagNameNS(p.svg,"stop")}var eb;oa=O=0;if(ba==="radialGradient"){V=W.gradientTransform.baseVal;if(V.numberOfItems===2){ta=V.getItem(0);V=V.getItem(1);if(ta.type===2&&V.type===3){ta=V.matrix;if(ta.a!==1)O=Math.round(-(1-ta.a)*100);else if(ta.d!==1)O=Math.round((1-ta.d)*100)}}else if(V.numberOfItems===3){da=V.getItem(0);ta=V.getItem(1);V=V.getItem(2);if(da.type===4&&ta.type===2&&V.type===3){oa=Math.round(da.angle);ta=V.matrix;if(ta.a!==1)O=Math.round(-(1-ta.a)*100);else if(ta.d!==
1)O=Math.round((1-ta.d)*100)}}}O={radius:{handle:"#"+o+"_jGraduate_RadiusArrows",input:"#"+o+"_jGraduate_RadiusInput",val:(W.getAttribute("r")||0.5)*100},opacity:{handle:"#"+o+"_jGraduate_OpacArrows",input:"#"+o+"_jGraduate_OpacInput",val:q.paint.alpha||100},ellip:{handle:"#"+o+"_jGraduate_EllipArrows",input:"#"+o+"_jGraduate_EllipInput",val:O},angle:{handle:"#"+o+"_jGraduate_AngleArrows",input:"#"+o+"_jGraduate_AngleInput",val:oa}};$.each(O,function(la,ca){var ja=$(ca.handle);ja.mousedown(function(N){var R=
o+"_jGraduate_match_ctr")[0].checked=!jb;var Ab,ob;$("#"+o+"_jGraduate_match_ctr").change(function(){jb=!this.checked;Ha.toggle(jb);ka.fx.val("");ka.fy.val("");var la=W;if(jb){var ca=Ab||0.5,ja=ob||0.5;la.setAttribute("fx",ca);la.setAttribute("fy",ja);ka.fx.val(ca);ka.fy.val(ja)}else{Ab=la.getAttribute("fx");ob=la.getAttribute("fy");la.removeAttribute("fx");la.removeAttribute("fy")}});wa=W.getElementsByTagNameNS(p.svg,"stop");ua=wa.length;if(ua<2){for(;ua<2;){W.appendChild(document.createElementNS(p.svg,
"stop"));++ua}wa=W.getElementsByTagNameNS(p.svg,"stop")}var eb;oa=O=0;if(ba==="radialGradient"){V=W.gradientTransform.baseVal;if(V.numberOfItems===2){ua=V.getItem(0);V=V.getItem(1);if(ua.type===2&&V.type===3){ua=V.matrix;if(ua.a!==1)O=Math.round(-(1-ua.a)*100);else if(ua.d!==1)O=Math.round((1-ua.d)*100)}}else if(V.numberOfItems===3){da=V.getItem(0);ua=V.getItem(1);V=V.getItem(2);if(da.type===4&&ua.type===2&&V.type===3){oa=Math.round(da.angle);ua=V.matrix;if(ua.a!==1)O=Math.round(-(1-ua.a)*100);else if(ua.d!==
1)O=Math.round((1-ua.d)*100)}}}O={radius:{handle:"#"+o+"_jGraduate_RadiusArrows",input:"#"+o+"_jGraduate_RadiusInput",val:(W.getAttribute("r")||0.5)*100},opacity:{handle:"#"+o+"_jGraduate_OpacArrows",input:"#"+o+"_jGraduate_OpacInput",val:q.paint.alpha||100},ellip:{handle:"#"+o+"_jGraduate_EllipArrows",input:"#"+o+"_jGraduate_EllipInput",val:O},angle:{handle:"#"+o+"_jGraduate_AngleArrows",input:"#"+o+"_jGraduate_AngleInput",val:oa}};$.each(O,function(la,ca){var ja=$(ca.handle);ja.mousedown(function(N){var R=
ja.parent();eb={type:la,elem:ja,input:$(ca.input),parent:R,offset:R.offset()};Q.mousemove(tb).mouseup(ub);N.preventDefault()});$(ca.input).val(ca.val).change(function(){var N=+this.value,R=0,ea=ba==="radialGradient";switch(la){case "radius":ea&&W.setAttribute("r",N/100);R=Math.pow(N/100,0.4)/2*145;break;case "opacity":q.paint.alpha=N;sa.setAttribute("fill-opacity",N/100);R=N*1.45;break;case "ellip":fb=La=1;if(N===0){R=72.5;break}if(N>99.5)N=99.5;if(N>0)La=1-N/100;else fb=-(N/100)-1;R=145*((N+100)/
2)/100;ea&&d();break;case "angle":Ua=N;R=Ua/180;R+=0.5;R*=145;ea&&d()}if(R>145)R=145;else if(R<0)R=0;ja.css({"margin-left":R-5})}).change()});var tb=function(la){var ca=la.pageX-eb.offset.left-parseInt(eb.parent.css("border-left-width"));if(ca>145)ca=145;if(ca<=0)ca=0;var ja=ca-5;ca/=145;switch(eb.type){case "radius":ca=Math.pow(ca*2,2.5);if(ca>0.98&&ca<1.02)ca=1;if(ca<=0.01)ca=0.01;W.setAttribute("r",ca);break;case "opacity":q.paint.alpha=parseInt(ca*100);sa.setAttribute("fill-opacity",ca);break;
case "ellip":La=fb=1;if(ca<0.5){ca/=0.5;fb=ca<=0?0.01:ca}else if(ca>0.5){ca/=0.5;ca=2-ca;La=ca<=0?0.01:ca}d();ca-=1;if(La===ca+1)ca=Math.abs(ca);break;case "angle":ca-=0.5;Ua=ca*=180;d();ca/=100}eb.elem.css({"margin-left":ja});ca=Math.round(ca*100);eb.input.val(ca);la.preventDefault()},ub=function(){Q.unbind("mousemove",tb).unbind("mouseup",ub);eb=null};for(O=(q.paint.alpha*255/100).toString(16);O.length<2;)O="0"+O;O=O.split(".")[0];J=q.paint.solidColor=="none"?"":q.paint.solidColor+O;qa||(J=wa[0].getAttribute("stop-color"));
$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});Y.jPicker({window:{title:B.window.pickerTitle},images:{clientPath:B.images.clientPath},color:{active:J,alphaSupport:true}},function(la){q.paint.type="solidColor";q.paint.alpha=la.val("ahex")?Math.round(la.val("a")/255*100):100;q.paint.solidColor=la.val("hex")?la.val("hex"):"none";q.paint.radialGradient=null;T()},null,function(){M()});var wb=$(K+" .jGraduate_tabs li");wb.on("click touchstart",function(){wb.removeClass("jGraduate_tab_current");
2)/100;ea&&d();break;case "angle":Va=N;R=Va/180;R+=0.5;R*=145;ea&&d()}if(R>145)R=145;else if(R<0)R=0;ja.css({"margin-left":R-5})}).change()});var tb=function(la){var ca=la.pageX-eb.offset.left-parseInt(eb.parent.css("border-left-width"));if(ca>145)ca=145;if(ca<=0)ca=0;var ja=ca-5;ca/=145;switch(eb.type){case "radius":ca=Math.pow(ca*2,2.5);if(ca>0.98&&ca<1.02)ca=1;if(ca<=0.01)ca=0.01;W.setAttribute("r",ca);break;case "opacity":q.paint.alpha=parseInt(ca*100);sa.setAttribute("fill-opacity",ca);break;
case "ellip":La=fb=1;if(ca<0.5){ca/=0.5;fb=ca<=0?0.01:ca}else if(ca>0.5){ca/=0.5;ca=2-ca;La=ca<=0?0.01:ca}d();ca-=1;if(La===ca+1)ca=Math.abs(ca);break;case "angle":ca-=0.5;Va=ca*=180;d();ca/=100}eb.elem.css({"margin-left":ja});ca=Math.round(ca*100);eb.input.val(ca);la.preventDefault()},ub=function(){Q.unbind("mousemove",tb).unbind("mouseup",ub);eb=null};for(O=(q.paint.alpha*255/100).toString(16);O.length<2;)O="0"+O;O=O.split(".")[0];J=q.paint.solidColor=="none"?"":q.paint.solidColor+O;qa||(J=wa[0].getAttribute("stop-color"));
$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});X.jPicker({window:{title:B.window.pickerTitle},images:{clientPath:B.images.clientPath},color:{active:J,alphaSupport:true}},function(la){q.paint.type="solidColor";q.paint.alpha=la.val("ahex")?Math.round(la.val("a")/255*100):100;q.paint.solidColor=la.val("hex")?la.val("hex"):"none";q.paint.radialGradient=null;T()},null,function(){M()});var wb=$(K+" .jGraduate_tabs li");wb.on("click touchstart",function(){wb.removeClass("jGraduate_tab_current");
$(this).addClass("jGraduate_tab_current");$(K+" > div").hide();var la=$(this).attr("data-type");$(K+" .jGraduate_gradPick").show();if(la==="rg"||la==="lg"){$(".jGraduate_"+la+"_field").show();$(".jGraduate_"+(la==="lg"?"rg":"lg")+"_field").hide();$("#"+o+"_jgraduate_rect")[0].setAttribute("fill","url(#"+o+"_"+la+"_jgraduate_grad)");ba=la==="lg"?"linearGradient":"radialGradient";$("#"+o+"_jGraduate_OpacInput").val(q.paint.alpha).change();var ca=$("#"+o+"_"+la+"_jgraduate_grad")[0];if(W!==ca){var ja=
$(W).find("stop");$(ca).empty().append(ja);W=ca;ca=sb.val();W.setAttribute("spreadMethod",ca)}jb=la==="rg"&&W.getAttribute("fx")!=null&&!(Fa==Ca&&Ia==Ka);$("#"+o+"_jGraduate_focusCoord").toggle(jb);if(jb)$("#"+o+"_jGraduate_match_ctr")[0].checked=false}else{$(K+" .jGraduate_gradPick").hide();$(K+" .jGraduate_colPick").show()}});$(K+" > div").hide();wb.removeClass("jGraduate_tab_current");var Ab;switch(q.paint.type){case "linearGradient":Ab=$(K+" .jGraduate_tab_lingrad");break;case "radialGradient":Ab=
$(K+" .jGraduate_tab_radgrad");break;default:Ab=$(K+" .jGraduate_tab_color")}q.show();setTimeout(function(){Ab.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.")})}})();jQuery&&function(){var a=$(window),p=$(document);$.extend($.fn,{contextMenu:function(g,c){if(g.menu==undefined)return false;if(g.inSpeed==undefined)g.inSpeed=150;if(g.outSpeed==undefined)g.outSpeed=75;if(g.inSpeed==0)g.inSpeed=-1;if(g.outSpeed==0)g.outSpeed=-1;$(this).each(function(){var n=$(this),s=$(n).offset(),b=$("#"+g.menu);b.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).on("mouseup",function(l){var q=$(this);q.unbind("mouseup");$(".contextMenu").hide();if(d.button===2||
$(W).find("stop");$(ca).empty().append(ja);W=ca;ca=sb.val();W.setAttribute("spreadMethod",ca)}jb=la==="rg"&&W.getAttribute("fx")!=null&&!(Fa==Ca&&Ia==Ka);$("#"+o+"_jGraduate_focusCoord").toggle(jb);if(jb)$("#"+o+"_jGraduate_match_ctr")[0].checked=false}else{$(K+" .jGraduate_gradPick").hide();$(K+" .jGraduate_colPick").show()}});$(K+" > div").hide();wb.removeClass("jGraduate_tab_current");var Bb;switch(q.paint.type){case "linearGradient":Bb=$(K+" .jGraduate_tab_lingrad");break;case "radialGradient":Bb=
$(K+" .jGraduate_tab_radgrad");break;default:Bb=$(K+" .jGraduate_tab_color")}q.show();setTimeout(function(){Bb.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.")})}})();jQuery&&function(){var a=$(window),p=$(document);$.extend($.fn,{contextMenu:function(g,c){if(g.menu==undefined)return false;if(g.inSpeed==undefined)g.inSpeed=150;if(g.outSpeed==undefined)g.outSpeed=75;if(g.inSpeed==0)g.inSpeed=-1;if(g.outSpeed==0)g.outSpeed=-1;$(this).each(function(){var n=$(this),s=$(n).offset(),b=$("#"+g.menu);b.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).on("mouseup",function(l){var q=$(this);q.unbind("mouseup");$(".contextMenu").hide();if(d.button===2||
g.allowLeft||d.ctrlKey&&svgedit.browser.isMac())svgedit.browser.isTouch()||f(l,d,q)})});svgedit.browser.isTouch()&&$(this).bind("taphold",function(d){var l=$(this);l.unbind("mouseup");f(d,d,l)});var f=function(d,l,q){if(typeof l=="undefined")l=d;d.stopPropagation();if(n.hasClass("disabled")||l.altKey)return false;var B=d.pageX,o=d.pageY;if(svgedit.browser.isTouch()){B=d.originalEvent.touches[0].pageX;o=d.originalEvent.touches[0].pageY}d=a.width()-b.width();l=a.height()-b.height();if(B>d-15)B=d-15;
if(o>l-30)o=l-30;if(svgedit.browser.isTouch())o-=b.height()/2;p.unbind("click");b.css({top:o,left:B}).fadeIn(g.inSpeed);b.find("A").mouseover(function(){b.find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){b.find("LI.hover").removeClass("hover")});p.keypress(function(K){switch(K.keyCode){case 38:if(b.find("LI.hover").length){b.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover");b.find("LI.hover").length||b.find("LI:last").addClass("hover")}else b.find("LI:last").addClass("hover");
break;case 40:if(b.find("LI.hover").length==0)b.find("LI:first").addClass("hover");else{b.find("LI.hover").removeClass("hover").nextAll("LI:not(.disabled)").eq(0).addClass("hover");b.find("LI.hover").length||b.find("LI:first").addClass("hover")}break;case 13:b.find("LI.hover A").trigger("click");break;case 27:p.trigger("click")}});b.find("A").unbind("mouseup");b.find("LI:not(.disabled) A").mouseup(function(){p.unbind("click").unbind("keypress");$(".contextMenu").hide();c&&c($(this).attr("href").substr(1),
@ -64,10 +64,10 @@ function(){return false})});return $(this)},disableContextMenuItems:function(g){
0,q="ontouchstart"in window,B=!!g.querySelector,o=!!document.evaluate,K=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","path");pa.setAttribute("d","M0,0 10,10");var fa=pa.pathSegList;pa=pa.createSVGPathSegLinetoAbs(5,5);try{fa.replaceItem(pa,0);return true}catch(ba){}return false}(),T=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","path");pa.setAttribute("d","M0,0 10,10");var fa=pa.pathSegList;pa=pa.createSVGPathSegLinetoAbs(5,5);try{fa.insertItemBefore(pa,
0);return true}catch(ba){}return false}(),M=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","svg"),fa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(pa);fa.setAttribute("x",5);pa.appendChild(fa);var ba=document.createElementNS("http://www.w3.org/2000/svg","text");ba.textContent="a";fa.appendChild(ba);fa=ba.getStartPositionOfChar(0).x;document.documentElement.removeChild(pa);return fa===0}(),J=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg",
"svg");document.documentElement.appendChild(pa);var fa=document.createElementNS("http://www.w3.org/2000/svg","path");fa.setAttribute("d","M0,0 C0,0 10,10 10,0");pa.appendChild(fa);fa=fa.getBBox();document.documentElement.removeChild(pa);return fa.height>4&&fa.height<5}(),Q=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(pa);var fa=document.createElementNS("http://www.w3.org/2000/svg","path");fa.setAttribute("d","M0,0 10,0");var ba=
document.createElementNS("http://www.w3.org/2000/svg","path");ba.setAttribute("d","M5,0 15,0");var W=document.createElementNS("http://www.w3.org/2000/svg","g");W.appendChild(fa);W.appendChild(ba);pa.appendChild(W);fa=W.getBBox();document.documentElement.removeChild(pa);return fa.width==15}(),Y=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","rect");pa.setAttribute("x",0.1);(pa=pa.cloneNode(false).getAttribute("x").indexOf(",")==-1)||$.alert("NOTE: This version of Opera is known to contain bugs in SVG-edit.\n\t\tPlease upgrade to the <a href='http://opera.com'>latest version</a> in which the problems have been fixed.");
document.createElementNS("http://www.w3.org/2000/svg","path");ba.setAttribute("d","M5,0 15,0");var W=document.createElementNS("http://www.w3.org/2000/svg","g");W.appendChild(fa);W.appendChild(ba);pa.appendChild(W);fa=W.getBBox();document.documentElement.removeChild(pa);return fa.width==15}(),X=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","rect");pa.setAttribute("x",0.1);(pa=pa.cloneNode(false).getAttribute("x").indexOf(",")==-1)||$.alert("NOTE: This version of Opera is known to contain bugs in SVG-edit.\n\t\tPlease upgrade to the <a href='http://opera.com'>latest version</a> in which the problems have been fixed.");
return pa}(),O=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","rect");pa.setAttribute("style","vector-effect:non-scaling-stroke");return pa.style.vectorEffect==="non-scaling-stroke"}(),ia=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","rect").transform.baseVal,fa=g.createSVGTransform();pa.appendItem(fa);return pa.getItem(0)==fa}();svgedit.browser.isOpera=function(){return c};svgedit.browser.isWebkit=function(){return n};svgedit.browser.isGecko=function(){return s};
svgedit.browser.isIE=function(){return b};svgedit.browser.isChrome=function(){return f};svgedit.browser.isWindows=function(){return d};svgedit.browser.isMac=function(){return l};svgedit.browser.isTouch=function(){return q};svgedit.browser.supportsSelectors=function(){return B};svgedit.browser.supportsXpath=function(){return o};svgedit.browser.supportsPathReplaceItem=function(){return K};svgedit.browser.supportsPathInsertItemBefore=function(){return T};svgedit.browser.supportsPathBBox=function(){return J};
svgedit.browser.supportsHVLineContainerBBox=function(){return Q};svgedit.browser.supportsGoodTextCharPos=function(){return M};svgedit.browser.supportsEditableText=function(){return c};svgedit.browser.supportsGoodDecimals=function(){return Y};svgedit.browser.supportsNonScalingStroke=function(){return O};svgedit.browser.supportsNativeTransformLists=function(){return ia}}else window.location="browser-not-supported.html"})();svgedit=svgedit||{};
svgedit.browser.supportsHVLineContainerBBox=function(){return Q};svgedit.browser.supportsGoodTextCharPos=function(){return M};svgedit.browser.supportsEditableText=function(){return c};svgedit.browser.supportsGoodDecimals=function(){return X};svgedit.browser.supportsNonScalingStroke=function(){return O};svgedit.browser.supportsNativeTransformLists=function(){return ia}}else window.location="browser-not-supported.html"})();svgedit=svgedit||{};
(function(){if(!svgedit.transformlist)svgedit.transformlist={};var a=document.createElementNS("http://www.w3.org/2000/svg","svg"),p={};svgedit.transformlist.SVGTransformList=function(g){this._elem=g||null;this._xforms=[];this._update=function(){var c="";a.createSVGMatrix();for(var n=0;n<this.numberOfItems;++n){var s=this._list.getItem(n);c=c;s=s;var b=s.matrix,f="";switch(s.type){case 1:f="matrix("+[b.a,b.b,b.c,b.d,b.e,b.f].join(",")+")";break;case 2:f="translate("+b.e+","+b.f+")";break;case 3:f=
b.a==b.d?"scale("+b.a+")":"scale("+b.a+","+b.d+")";break;case 4:var d=0;f=0;if(s.angle!=0){d=1-b.a;f=(d*b.f+b.b*b.e)/(d*d+b.b*b.b);d=(b.e-b.b*f)/d}f="rotate("+s.angle+" "+d+","+f+")"}c=c+(f+" ")}this._elem.setAttribute("transform",c)};this._list=this;this._init=function(){var c=this._elem.getAttribute("transform");if(c)for(var n=/\s*((scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/,s=true;s;){s=c.match(n);c=c.replace(n,"");if(s&&s[1]){var b=s[1].split(/\s*\(/),f=b[0];b=b[1].match(/\s*(.*?)\s*\)/);
b[1]=b[1].replace(/(\d)-/g,"$1 -");var d=b[1].split(/[, ]+/),l="abcdef".split(""),q=a.createSVGMatrix();$.each(d,function(K,T){d[K]=parseFloat(T);if(f=="matrix")q[l[K]]=d[K]});b=a.createSVGTransform();var B="set"+f.charAt(0).toUpperCase()+f.slice(1),o=f=="matrix"?[q]:d;if(f=="scale"&&o.length==1)o.push(o[0]);else if(f=="translate"&&o.length==1)o.push(0);else if(f=="rotate"&&o.length==1){o.push(0);o.push(0)}b[B].apply(b,o);this._list.appendItem(b)}}};this._removeFromOtherLists=function(c){if(c){var n=
@ -93,8 +93,8 @@ d=d<<2|l>>4;l=(l&15)<<4|B>>2;q=(B&3)<<6|o;f+=String.fromCharCode(d);if(B!=64)f+=
new DOMParser:new ActiveXObject("Microsoft.XMLDOM");d.async=false}catch(l){throw Error("XML Parser could not be instantiated");}try{f=d.loadXML?d.loadXML(b)?d:false:d.parseFromString(b,"text/xml")}catch(q){throw Error("Error parsing XML string");}return f};svgedit.utilities.bboxToObj=function(b){return{x:b.x,y:b.y,width:b.width,height:b.height}};svgedit.utilities.walkTree=function(b,f){if(b&&b.nodeType==1){f(b);for(var d=b.childNodes.length;d--;)svgedit.utilities.walkTree(b.childNodes.item(d),f)}};
svgedit.utilities.walkTreePost=function(b,f){if(b&&b.nodeType==1){for(var d=b.childNodes.length;d--;)svgedit.utilities.walkTree(b.childNodes.item(d),f);f(b)}};svgedit.utilities.getUrlFromAttr=function(b){if(b)if(b.indexOf('url("')===0)return b.substring(5,b.indexOf('"',6));else if(b.indexOf("url('")===0)return b.substring(5,b.indexOf("'",6));else if(b.indexOf("url(")===0)return b.substring(4,b.indexOf(")"));return null};svgedit.utilities.getHref=function(b){return b.getAttributeNS("http://www.w3.org/1999/xlink",
"href")};svgedit.utilities.setHref=function(b,f){b.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",f)};svgedit.utilities.findDefs=function(b){b=g.getSVGContent().documentElement;var f=b.getElementsByTagNameNS("http://www.w3.org/2000/svg","defs");return f=f.length>0?f[0]:b.insertBefore(b.ownerDocument.createElementNS("http://www.w3.org/2000/svg","defs"),b.firstChild.nextSibling)};svgedit.utilities.getPathBBox=function(b){var f=b.pathSegList,d=f.numberOfItems;b=[[],[]];var l=f.getItem(0),
q=[l.x,l.y];for(l=0;l<d;l++){var B=f.getItem(l);if(typeof B.x!="undefined"){b[0].push(q[0]);b[1].push(q[1]);if(B.x1){for(var o=[B.x1,B.y1],K=[B.x2,B.y2],T=[B.x,B.y],M=0;M<2;M++){B=function(ia){return Math.pow(1-ia,3)*q[M]+3*Math.pow(1-ia,2)*ia*o[M]+3*(1-ia)*Math.pow(ia,2)*K[M]+Math.pow(ia,3)*T[M]};var J=6*q[M]-12*o[M]+6*K[M],Q=-3*q[M]+9*o[M]-9*K[M]+3*T[M],Y=3*o[M]-3*q[M];if(Q==0){if(J!=0){J=-Y/J;0<J&&J<1&&b[M].push(B(J))}}else{Y=Math.pow(J,2)-4*Y*Q;if(!(Y<0)){var O=(-J+Math.sqrt(Y))/(2*Q);0<O&&O<
1&&b[M].push(B(O));J=(-J-Math.sqrt(Y))/(2*Q);0<J&&J<1&&b[M].push(B(J))}}}q=T}else{b[0].push(B.x);b[1].push(B.y)}}}f=Math.min.apply(null,b[0]);d=Math.max.apply(null,b[0])-f;l=Math.min.apply(null,b[1]);b=Math.max.apply(null,b[1])-l;return{x:f,y:l,width:d,height:b}};svgedit.utilities.getBBox=function(b){var f=b||g.geSelectedElements()[0];if(b.nodeType!=1)return null;b=null;var d=f.nodeName;switch(d){case "text":if(f.textContent===""){f.textContent="a";b=f.getBBox();f.textContent=""}else try{b=f.getBBox()}catch(l){}break;
q=[l.x,l.y];for(l=0;l<d;l++){var B=f.getItem(l);if(typeof B.x!="undefined"){b[0].push(q[0]);b[1].push(q[1]);if(B.x1){for(var o=[B.x1,B.y1],K=[B.x2,B.y2],T=[B.x,B.y],M=0;M<2;M++){B=function(ia){return Math.pow(1-ia,3)*q[M]+3*Math.pow(1-ia,2)*ia*o[M]+3*(1-ia)*Math.pow(ia,2)*K[M]+Math.pow(ia,3)*T[M]};var J=6*q[M]-12*o[M]+6*K[M],Q=-3*q[M]+9*o[M]-9*K[M]+3*T[M],X=3*o[M]-3*q[M];if(Q==0){if(J!=0){J=-X/J;0<J&&J<1&&b[M].push(B(J))}}else{X=Math.pow(J,2)-4*X*Q;if(!(X<0)){var O=(-J+Math.sqrt(X))/(2*Q);0<O&&O<
1&&b[M].push(B(O));J=(-J-Math.sqrt(X))/(2*Q);0<J&&J<1&&b[M].push(B(J))}}}q=T}else{b[0].push(B.x);b[1].push(B.y)}}}f=Math.min.apply(null,b[0]);d=Math.max.apply(null,b[0])-f;l=Math.min.apply(null,b[1]);b=Math.max.apply(null,b[1])-l;return{x:f,y:l,width:d,height:b}};svgedit.utilities.getBBox=function(b){var f=b||g.geSelectedElements()[0];if(b.nodeType!=1)return null;b=null;var d=f.nodeName;switch(d){case "text":if(f.textContent===""){f.textContent="a";b=f.getBBox();f.textContent=""}else try{b=f.getBBox()}catch(l){}break;
case "path":if(svgedit.browser.supportsPathBBox())try{b=f.getBBox()}catch(q){}else b=svgedit.utilities.getPathBBox(f);break;case "g":case "a":b=a(f);break;default:if(d==="use")b=a(f,true);if(d==="use"){b||(b=f.getBBox());if(!svgedit.browser.isWebkit()){d={};d.width=b.width;d.height=b.height;d.x=b.x+parseFloat(f.getAttribute("x")||0);d.y=b.y+parseFloat(f.getAttribute("y")||0);b=d}}else if(~p.indexOf(d))try{b=f.getBBox()}catch(B){f=$(f).closest("foreignObject");if(f.length)try{b=f[0].getBBox()}catch(o){b=
null}else b=null}}if(b)b=svgedit.utilities.bboxToObj(b);return b};svgedit.utilities.getRotationAngle=function(b,f){var d=b||g.getSelectedElements()[0];d=svgedit.transformlist.getTransformList(d);if(!d)return 0;for(var l=d.numberOfItems,q=0;q<l;++q){var B=d.getItem(q);if(B.type==4)return f?B.angle*Math.PI/180:B.angle}return 0};svgedit.utilities.getElem=svgedit.browser.supportsSelectors()?function(b){return s.querySelector("#"+b)}:svgedit.browser.supportsXpath()?function(b){return c.evaluate('svg:svg[@id="svgroot"]//svg:*[@id="'+
b+'"]',n,function(){return"http://www.w3.org/2000/svg"},9,null).singleNodeValue}:function(b){return $(s).find("[id="+b+"]")[0]};svgedit.utilities.assignAttributes=function(b,f,d,l){d||(d=0);svgedit.browser.isOpera()||s.suspendRedraw(d);for(var q in f)if(d=q.substr(0,4)==="xml:"?"http://www.w3.org/XML/1998/namespace":q.substr(0,6)==="xlink:"?"http://www.w3.org/1999/xlink":null)b.setAttributeNS(d,q,f[q]);else l?svgedit.units.setUnitAttr(b,q,f[q]):b.setAttribute(q,f[q]);svgedit.browser.isOpera()||s.unsuspendRedraw(null)};
@ -183,8 +183,8 @@ this.next.index,l)}if(this.mate){l=this.mate.item;l=[l.x+=f,l.y+=d];svgedit.path
svgedit.path.Segment.prototype.moveCtrl=function(f,d,l){var q=this.item;q["x"+f]+=d;q["y"+f]+=l;svgedit.path.replacePathSeg(this.type,this.index,[q.x,q.y,q.x1,q.y1,q.x2,q.y2]);this.update(true)};svgedit.path.Segment.prototype.setType=function(f,d){svgedit.path.replacePathSeg(f,this.index,d);this.type=f;this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.showCtrlPts(f===6);this.ctrlpts=svgedit.path.getControlPoints(this);this.update(true)};svgedit.path.Path=function(f){if(!f||f.tagName!==
"path")throw"svgedit.path.Path constructed without a <path> element";this.elem=f;this.segs=[];this.selected_pts=[];svgedit.path.path=this;this.init()};svgedit.path.Path.prototype.init=function(){$(svgedit.path.getGripContainer()).find("*").attr("display","none");var f=this.elem.pathSegList,d=f.numberOfItems;this.segs=[];this.selected_pts=[];this.first_seg=null;for(var l=0;l<d;l++){var q=f.getItem(l);q=new svgedit.path.Segment(l,q);q.path=this;this.segs.push(q)}f=this.segs;q=null;for(l=0;l<d;l++){var B=
f[l],o=l+1>=d?null:f[l+1],K=l-1<0?null:f[l-1];if(B.type===2){if(K&&K.type!==1){o=f[q];o.next=f[q+1];o.next.prev=o;o.addGrip()}q=l}else if(o&&o.type===1){B.next=f[q+1];B.next.prev=B;B.mate=f[q];B.addGrip();if(this.first_seg==null)this.first_seg=B}else if(o){if(B.type!==1){B.addGrip();if(o&&o.type!==2){B.next=o;B.next.prev=B}}}else if(B.type!==1){o=f[q];o.next=f[q+1];o.next.prev=o;o.addGrip();B.addGrip();if(!this.first_seg)this.first_seg=f[q]}}return this};svgedit.path.Path.prototype.eachSeg=function(f){for(var d=
this.segs.length,l=0;l<d;l++)if(f.call(this.segs[l],l)===false)break};svgedit.path.Path.prototype.addSeg=function(f){var d=this.segs[f];if(d.prev){var l=d.prev,q;switch(d.item.pathSegType){case 4:var B=(d.item.x+l.item.x)/2,o=(d.item.y+l.item.y)/2;q=this.elem.createSVGPathSegLinetoAbs(B,o);break;case 6:q=(l.item.x+d.item.x1)/2;var K=(d.item.x1+d.item.x2)/2,T=(d.item.x2+d.item.x)/2,M=(q+K)/2;K=(K+T)/2;B=(M+K)/2;var J=(l.item.y+d.item.y1)/2,Q=(d.item.y1+d.item.y2)/2;l=(d.item.y2+d.item.y)/2;var Y=(J+
Q)/2;Q=(Q+l)/2;o=(Y+Q)/2;q=this.elem.createSVGPathSegCurvetoCubicAbs(B,o,q,J,M,Y);svgedit.path.replacePathSeg(d.type,f,[d.item.x,d.item.y,K,Q,T,l])}svgedit.path.insertItemBefore(this.elem,q,f)}};svgedit.path.Path.prototype.deleteSeg=function(f){var d=this.segs[f],l=this.elem.pathSegList;d.show(false);var q=d.next;if(d.mate){var B=[q.item.x,q.item.y];svgedit.path.replacePathSeg(2,q.index,B);svgedit.path.replacePathSeg(4,d.index,B);l.removeItem(d.mate.index)}else{if(!d.prev){B=[q.item.x,q.item.y];svgedit.path.replacePathSeg(2,
this.segs.length,l=0;l<d;l++)if(f.call(this.segs[l],l)===false)break};svgedit.path.Path.prototype.addSeg=function(f){var d=this.segs[f];if(d.prev){var l=d.prev,q;switch(d.item.pathSegType){case 4:var B=(d.item.x+l.item.x)/2,o=(d.item.y+l.item.y)/2;q=this.elem.createSVGPathSegLinetoAbs(B,o);break;case 6:q=(l.item.x+d.item.x1)/2;var K=(d.item.x1+d.item.x2)/2,T=(d.item.x2+d.item.x)/2,M=(q+K)/2;K=(K+T)/2;B=(M+K)/2;var J=(l.item.y+d.item.y1)/2,Q=(d.item.y1+d.item.y2)/2;l=(d.item.y2+d.item.y)/2;var X=(J+
Q)/2;Q=(Q+l)/2;o=(X+Q)/2;q=this.elem.createSVGPathSegCurvetoCubicAbs(B,o,q,J,M,X);svgedit.path.replacePathSeg(d.type,f,[d.item.x,d.item.y,K,Q,T,l])}svgedit.path.insertItemBefore(this.elem,q,f)}};svgedit.path.Path.prototype.deleteSeg=function(f){var d=this.segs[f],l=this.elem.pathSegList;d.show(false);var q=d.next;if(d.mate){var B=[q.item.x,q.item.y];svgedit.path.replacePathSeg(2,q.index,B);svgedit.path.replacePathSeg(4,d.index,B);l.removeItem(d.mate.index)}else{if(!d.prev){B=[q.item.x,q.item.y];svgedit.path.replacePathSeg(2,
d.next.index,B)}l.removeItem(f)}};svgedit.path.Path.prototype.subpathIsClosed=function(f){var d=false;svgedit.path.path.eachSeg(function(l){if(l<=f)return true;if(this.type===2)return false;else if(this.type===1){d=true;return false}});return d};svgedit.path.Path.prototype.removePtFromSelection=function(f){var d=this.selected_pts.indexOf(f);if(d!=-1){this.segs[f].select(false);this.selected_pts.splice(d,1)}};svgedit.path.Path.prototype.clearSelection=function(){this.eachSeg(function(){this.select(false)});
this.selected_pts=[]};svgedit.path.Path.prototype.storeD=function(){this.last_d=this.elem.getAttribute("d")};svgedit.path.Path.prototype.show=function(f){this.eachSeg(function(){this.show(f)});f&&this.selectPt(this.first_seg.index);return this};svgedit.path.Path.prototype.movePts=function(f,d){for(var l=this.selected_pts.length;l--;)this.segs[this.selected_pts[l]].move(f,d)};svgedit.path.Path.prototype.moveCtrl=function(f,d){var l=this.segs[this.selected_pts[0]];l.moveCtrl(this.dragctrl,f,d);c&&l.setLinked(this.dragctrl)};
svgedit.path.Path.prototype.setSegType=function(f){this.storeD();for(var d=this.selected_pts.length,l;d--;){var q=this.segs[this.selected_pts[d]],B=q.prev;if(B){if(!f){l="Toggle Path Segment Type";f=q.type==6?4:6}f-=0;var o=q.item.x,K=q.item.y,T=B.item.x;B=B.item.y;var M;switch(f){case 6:if(q.olditem){T=q.olditem;M=[o,K,T.x1,T.y1,T.x2,T.y2]}else{M=o-T;var J=K-B;M=[o,K,T+M/3,B+J/3,o-M/3,K-J/3]}break;case 4:M=[o,K];q.olditem=q.item}q.setType(f,M)}}svgedit.path.path.endChanges(l)};svgedit.path.Path.prototype.selectPt=
@ -199,150 +199,150 @@ H=H.cloneNode(true);$(H).attr(F);H.id=ja();lb().appendChild(H);e.setAttribute(w,
true);a.appendChild(d);var l=f.createElementNS(c,"svg");(b.clearSvgContentElement=function(){for(;l.firstChild;)l.removeChild(l.firstChild);$(l).attr({id:"svgcontent",width:s[0],height:s[1],x:s[0],y:s[1],overflow:n.show_outside_canvas?"visible":"hidden",xmlns:c,"xmlns:se":"http://svg-edit.googlecode.com","xmlns:xlink":"http://www.w3.org/1999/xlink"}).appendTo(d);var e=f.createComment(" Created with Method Draw - http://github.com/duopixel/Method-Draw/ ");l.appendChild(e)})();var q="svg_";b.setIdPrefix=
function(e){q=e};b.current_drawing_=new svgedit.draw.Drawing(l,q);var B=b.getCurrentDrawing=function(){return b.current_drawing_},o=1,K=null,T={shape:{fill:(n.initFill.color=="none"?"":"#")+n.initFill.color,fill_paint:null,fill_opacity:n.initFill.opacity,stroke:"#"+n.initStroke.color,stroke_paint:null,stroke_opacity:n.initStroke.opacity,stroke_width:n.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:n.initOpacity}};T.text=$.extend(true,{},T.shape);$.extend(T.text,
{fill:"#000000",stroke_width:0,font_size:24,font_family:"Helvetica, Arial, sans-serif"});var M=T.shape,J=Array(1),Q=this.addSvgElementFromJson=function(e){var h=svgedit.utilities.getElem(e.attr.id),m=B().getCurrentLayer();if(h&&e.element!=h.tagName){m.removeChild(h);h=null}if(!h){h=f.createElementNS(c,e.element);if(m)(K||m).appendChild(h)}e.curStyles&&svgedit.utilities.assignAttributes(h,{fill:M.fill,stroke:M.stroke,"stroke-width":M.stroke_width,"stroke-dasharray":M.stroke_dasharray,"stroke-linejoin":M.stroke_linejoin,
"stroke-linecap":M.stroke_linecap,"stroke-opacity":M.stroke_opacity,"fill-opacity":M.fill_opacity,opacity:M.opacity/2,style:"pointer-events:inherit"},100);svgedit.utilities.assignAttributes(h,e.attr,100);svgedit.utilities.cleanupElement(h);return h},Y=b.getTransformList=svgedit.transformlist.getTransformList,O=svgedit.math.transformPoint,ia=b.matrixMultiply=svgedit.math.matrixMultiply,pa=b.hasMatrixTransform=svgedit.math.hasMatrixTransform,fa=b.transformListToTransform=svgedit.math.transformListToTransform,
"stroke-linecap":M.stroke_linecap,"stroke-opacity":M.stroke_opacity,"fill-opacity":M.fill_opacity,opacity:M.opacity/2,style:"pointer-events:inherit"},100);svgedit.utilities.assignAttributes(h,e.attr,100);svgedit.utilities.cleanupElement(h);return h},X=b.getTransformList=svgedit.transformlist.getTransformList,O=svgedit.math.transformPoint,ia=b.matrixMultiply=svgedit.math.matrixMultiply,pa=b.hasMatrixTransform=svgedit.math.hasMatrixTransform,fa=b.transformListToTransform=svgedit.math.transformListToTransform,
ba=svgedit.math.snapToAngle,W=svgedit.math.getMatrix;svgedit.units.init({getBaseUnit:function(){return n.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return l.getAttribute("height")/o},getWidth:function(){return l.getAttribute("width")/o},getRoundDigits:function(){return fb.round_digits}});var sa=b.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return f},getDOMContainer:function(){return a},getSVGRoot:function(){return d},getSelectedElements:function(){return J},
getSVGContent:function(){return l}});var ka=b.getUrlFromAttr=svgedit.utilities.getUrlFromAttr,da=b.getHref=svgedit.utilities.getHref,V=b.setHref=svgedit.utilities.setHref,Z=svgedit.utilities.getPathBBox;b.getBBox=svgedit.utilities.getBBox;var oa=b.getRotationAngle=svgedit.utilities.getRotationAngle,qa=b.getElem=svgedit.utilities.getElem,ma=b.assignAttributes=svgedit.utilities.assignAttributes,na=this.cleanupElement=svgedit.utilities.cleanupElement,Aa=svgedit.sanitize.getNSMap(),Fa=b.sanitizeSvg=svgedit.sanitize.sanitizeSvg,
Ia=svgedit.history.MoveElementCommand,Ca=svgedit.history.InsertElementCommand,Ka=svgedit.history.RemoveElementCommand,Na=svgedit.history.ChangeElementCommand,za=svgedit.history.BatchCommand;b.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(e,h){var m=svgedit.history.HistoryEventTypes;if(e==m.BEFORE_UNAPPLY||e==m.BEFORE_APPLY)b.clearSelection();else if(e==m.AFTER_APPLY||e==m.AFTER_UNAPPLY){var z=h.elements();b.pathActions.clear();N("changed",z);z=h.type();m=e==m.AFTER_APPLY;if(z==
Ia.type()){m=m?h.newParent:h.oldParent;m==l&&b.identifyLayers()}else if(z==Ca.type()||z==Ka.type()){h.parent==l&&b.identifyLayers();if(z==Ca.type())m&&Va(h.elem);else m||Va(h.elem);h.elem.tagName==="use"&&Lb(h.elem)}else if(z==Na.type()){h.elem.tagName=="title"&&h.elem.parentNode.parentNode==l&&b.identifyLayers();m=m?h.newValues:h.oldValues;m.stdDeviation&&b.setBlurOffsets(h.elem.parentNode,m.stdDeviation);if(h.elem.tagName==="use"&&svgedit.browser.isWebkit()){z=h.elem;if(!z.getAttribute("x")&&!z.getAttribute("y")){m=
Ia.type()){m=m?h.newParent:h.oldParent;m==l&&b.identifyLayers()}else if(z==Ca.type()||z==Ka.type()){h.parent==l&&b.identifyLayers();if(z==Ca.type())m&&Wa(h.elem);else m||Wa(h.elem);h.elem.tagName==="use"&&Lb(h.elem)}else if(z==Na.type()){h.elem.tagName=="title"&&h.elem.parentNode.parentNode==l&&b.identifyLayers();m=m?h.newValues:h.oldValues;m.stdDeviation&&b.setBlurOffsets(h.elem.parentNode,m.stdDeviation);if(h.elem.tagName==="use"&&svgedit.browser.isWebkit()){z=h.elem;if(!z.getAttribute("x")&&!z.getAttribute("y")){m=
z.parentNode;var w=z.nextSibling;m.removeChild(z);m.insertBefore(z,w)}}}}}});var ya=function(e){b.undoMgr.addCommandToHistory(e)};svgedit.select.init(n,{createSVGElement:function(e){return b.addSvgElementFromJson(e)},svgRoot:function(){return d},svgContent:function(){return l},currentZoom:function(){return o},getStrokedBBox:function(e){return b.getStrokedBBox([e])}});var Ha=this.selectorManager=svgedit.select.getSelectorManager();svgedit.path.init({getCurrentZoom:function(){return o},getSVGRoot:function(){return d}});
svgedit.utilities.snapToGrid=function(e){var h=n.snappingStep,m=n.baseUnit;if(m!=="px")h*=svgedit.units.getTypeMap()[m];return e=Math.round(e/h)*h};var wa=svgedit.utilities.snapToGrid,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"},$a=["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],ib=$.data,
Va=function(e){var h=$(e).attr($a),m;for(m in h){var z=h[m];if(z&&z.indexOf("url(")===0){z=ka(z).substr(1);if(!qa(z)){lb().appendChild(zb[z]);delete zb[z]}}}e=e.getElementsByTagName("*");if(e.length){h=0;for(m=e.length;h<m;h++)Va(e[h])}},Ra={},Da=n.imgPath+"logo.png",va=[],fb={round_digits:5},La=false,Ua=null,Ea="select",kb="none",sb={},Za=T.text,bb=M,Cb=null,ta=null,mb=[],jb={},zb={};b.clipBoard=[];var ob=this.runExtensions=function(e,h,m){var z=false;if(m)z=[];$.each(jb,function(w,H){if(e in H)if(m)z.push(H[e](h));
else z=H[e](h)});return z};this.addExtension=function(e,h){if(e in jb)console.log('Cannot add extension "'+e+'", an extension by that name already exists"');else{var m=$.isFunction(h)?h($.extend(b.getPrivateMethods(),{svgroot:d,svgcontent:l,nonce:B().getNonce(),selectorManager:Ha})):h;jb[e]=m;N("extension_added",m)}};var eb=this.round=function(e){return parseInt(e*o)/o},tb=this.getIntersectionList=function(e){if(ta==null)return null;var h=K||B().getCurrentLayer();mb.length||(mb=wb(h));var m=null;
try{m=h.getIntersectionList(e,null)}catch(z){}if(m==null||typeof m.item!="function"){m=[];if(e)e=e;else{e=ta.getBBox();h={};for(var w in e)h[w]=e[w]/o;e=h}for(w=mb.length;w--;)e.width&&e.width&&svgedit.math.rectsIntersect(e,mb[w].bbox)&&m.push(mb[w].elem)}return m};getStrokedBBox=this.getStrokedBBox=function(e){e||(e=ub());if(!e.length)return false;var h=function(I){try{var D=svgedit.utilities.getBBox(I),G=svgedit.utilities.getRotationAngle(I);if(G&&G%90||svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(I))){G=
false;if(["ellipse","path","line","polyline","polygon"].indexOf(I.tagName)>=0)D=G=b.convertToPath(I,true);else if(I.tagName=="rect"){var L=I.getAttribute("rx"),k=I.getAttribute("ry");if(L||k)D=G=b.convertToPath(I,true)}if(!G){var u=I.cloneNode(true),C=document.createElementNS(c,"g"),E=I.parentNode;E.appendChild(C);C.appendChild(u);D=svgedit.utilities.bboxToObj(C.getBBox());E.removeChild(C)}}return D}catch(P){console.log(I,P);return null}},m;$.each(e,function(){if(!m)if(this.parentNode)m=h(this)});
if(m==null)return null;var z=m.x+m.width,w=m.y+m.height,H=m.x,A=m.y,v=function(I){var D=I.getAttribute("stroke-width"),G=0;if(I.getAttribute("stroke")!="none"&&!isNaN(D))G+=D/2;return G},F=[];$.each(e,function(I,D){var G=h(D);if(G){var L=v(D);H=Math.min(H,G.x-L);A=Math.min(A,G.y-L);F.push(G)}});m.x=H;m.y=A;$.each(e,function(I,D){var G=F[I];if(G&&D.nodeType==1){var L=v(D);z=Math.max(z,G.x+G.width+L);w=Math.max(w,G.y+G.height+L)}});m.width=z-H;m.height=w-A;return m};var ub=this.getVisibleElements=function(e){e||
(e=$(l).children());e.find("#canvas_background").length&&e.splice(0,1);var h=[];$(e).children().each(function(m,z){try{z.getBBox()&&h.push(z)}catch(w){}});return h.reverse()},wb=this.getVisibleElementsAndBBoxes=function(e){e||(e=$(l).children());var h=[];$(e).children().each(function(m,z){try{z.getBBox()&&h.push({elem:z,bbox:getStrokedBBox([z])})}catch(w){}});return h.reverse()},Ab=this.groupSvgElem=function(e){var h=document.createElementNS(c,"g");e.parentNode.replaceChild(h,e);$(h).append(e).data("gsvg",
Wa=function(e){var h=$(e).attr($a),m;for(m in h){var z=h[m];if(z&&z.indexOf("url(")===0){z=ka(z).substr(1);if(!qa(z)){lb().appendChild(Ab[z]);delete Ab[z]}}}e=e.getElementsByTagName("*");if(e.length){h=0;for(m=e.length;h<m;h++)Wa(e[h])}},Sa={},Da=n.imgPath+"logo.png",va=[],fb={round_digits:5},La=false,Va=null,Ea="select",kb="none",sb={},Za=T.text,bb=M,Cb=null,ua=null,mb=[],jb={},Ab={};b.clipBoard=[];var ob=this.runExtensions=function(e,h,m){var z=false;if(m)z=[];$.each(jb,function(w,H){if(e in H)if(m)z.push(H[e](h));
else z=H[e](h)});return z};this.addExtension=function(e,h){if(e in jb)console.log('Cannot add extension "'+e+'", an extension by that name already exists"');else{var m=$.isFunction(h)?h($.extend(b.getPrivateMethods(),{svgroot:d,svgcontent:l,nonce:B().getNonce(),selectorManager:Ha})):h;jb[e]=m;N("extension_added",m)}};var eb=this.round=function(e){return parseInt(e*o)/o},tb=this.getIntersectionList=function(e){if(ua==null)return null;var h=K||B().getCurrentLayer();mb.length||(mb=wb(h));var m=null;
try{m=h.getIntersectionList(e,null)}catch(z){}if(m==null||typeof m.item!="function"){m=[];if(e)e=e;else{e=ua.getBBox();h={};for(var w in e)h[w]=e[w]/o;e=h}for(w=mb.length;w--;)e.width&&e.width&&svgedit.math.rectsIntersect(e,mb[w].bbox)&&m.push(mb[w].elem)}return m};getStrokedBBox=this.getStrokedBBox=function(e){e||(e=ub());if(!e.length)return false;var h=function(I){try{var E=svgedit.utilities.getBBox(I),G=svgedit.utilities.getRotationAngle(I);if(G&&G%90||svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(I))){G=
false;if(["ellipse","path","line","polyline","polygon"].indexOf(I.tagName)>=0)E=G=b.convertToPath(I,true);else if(I.tagName=="rect"){var L=I.getAttribute("rx"),k=I.getAttribute("ry");if(L||k)E=G=b.convertToPath(I,true)}if(!G){var u=I.cloneNode(true),C=document.createElementNS(c,"g"),D=I.parentNode;D.appendChild(C);C.appendChild(u);E=svgedit.utilities.bboxToObj(C.getBBox());D.removeChild(C)}}return E}catch(P){console.log(I,P);return null}},m;$.each(e,function(){if(!m)if(this.parentNode)m=h(this)});
if(m==null)return null;var z=m.x+m.width,w=m.y+m.height,H=m.x,A=m.y,v=function(I){var E=I.getAttribute("stroke-width"),G=0;if(I.getAttribute("stroke")!="none"&&!isNaN(E))G+=E/2;return G},F=[];$.each(e,function(I,E){var G=h(E);if(G){var L=v(E);H=Math.min(H,G.x-L);A=Math.min(A,G.y-L);F.push(G)}});m.x=H;m.y=A;$.each(e,function(I,E){var G=F[I];if(G&&E.nodeType==1){var L=v(E);z=Math.max(z,G.x+G.width+L);w=Math.max(w,G.y+G.height+L)}});m.width=z-H;m.height=w-A;return m};var ub=this.getVisibleElements=function(e){e||
(e=$(l).children());e.find("#canvas_background").length&&e.splice(0,1);var h=[];$(e).children().each(function(m,z){try{z.getBBox()&&h.push(z)}catch(w){}});return h.reverse()},wb=this.getVisibleElementsAndBBoxes=function(e){e||(e=$(l).children());var h=[];$(e).children().each(function(m,z){try{z.getBBox()&&h.push({elem:z,bbox:getStrokedBBox([z])})}catch(w){}});return h.reverse()},Bb=this.groupSvgElem=function(e){var h=document.createElementNS(c,"g");e.parentNode.replaceChild(h,e);$(h).append(e).data("gsvg",
e)[0].id=ja()},la=function(e){var h=document.createElementNS(e.namespaceURI,e.nodeName);h.removeAttribute("id");$.each(e.attributes,function(z,w){w.localName!="-moz-math-font-style"&&h.setAttributeNS(w.namespaceURI,w.nodeName,w.nodeValue)});if(svgedit.browser.isWebkit()&&e.nodeName=="path"){var m=Ja.convertPath(e);h.setAttribute("d",m)}$.each(e.childNodes,function(z,w){switch(w.nodeType){case 1:h.appendChild(la(w));break;case 3:h.textContent=w.nodeValue}});if($(e).data("gsvg"))$(h).data("gsvg",h.firstChild);
else if($(e).data("symbol")){e=$(e).data("symbol");$(h).data("ref",e).data("symbol",e)}else h.tagName=="image"&&pb(h);h.id=ja();return h},ca,ja,N;(function(e){var h={};ca=e.getId=function(){return B().getId()};ja=e.getNextId=function(){return B().getNextId()};N=e.call=function(m,z){if(h[m])return h[m](this,z)};e.bind=function(m,z){var w=h[m];h[m]=z;return w}})(b);this.prepareSvg=function(e){this.sanitizeSvg(e.documentElement);e=e.getElementsByTagNameNS(c,"path");for(var h=0,m=e.length;h<m;++h){var z=
e[h];z.setAttribute("d",Ja.convertPath(z));Ja.fixEnd(z)}};var R=this.getRefElem=function(e){return qa(ka(e).substr(1))},ea=function(e){if(!svgedit.browser.isGecko())return e;var h=e.cloneNode(true);e.parentNode.insertBefore(h,e);e.parentNode.removeChild(e);Ha.releaseSelector(e);J[0]=h;Ha.requestSelector(h).showGrips(true);return h};this.setRotationAngle=function(e,h){e=parseFloat(e);var m=J[0],z=m.getAttribute("transform"),w=svgedit.utilities.getBBox(m),H=w.x+w.width/2,A=w.y+w.height/2;w=Y(m);w.numberOfItems>
e[h];z.setAttribute("d",Ja.convertPath(z));Ja.fixEnd(z)}};var R=this.getRefElem=function(e){return qa(ka(e).substr(1))},ea=function(e){if(!svgedit.browser.isGecko())return e;var h=e.cloneNode(true);e.parentNode.insertBefore(h,e);e.parentNode.removeChild(e);Ha.releaseSelector(e);J[0]=h;Ha.requestSelector(h).showGrips(true);return h};this.setRotationAngle=function(e,h){e=parseFloat(e);var m=J[0],z=m.getAttribute("transform"),w=svgedit.utilities.getBBox(m),H=w.x+w.width/2,A=w.y+w.height/2;w=X(m);w.numberOfItems>
0&&w.getItem(0).type==4&&w.removeItem(0);if(e!=0){H=O(H,A,fa(w).matrix);A=d.createSVGTransform();A.setRotate(e,H.x,H.y);w.numberOfItems?w.insertItemBefore(A,0):w.appendItem(A)}else w.numberOfItems==0&&m.removeAttribute("transform");if(!h){w=m.getAttribute("transform");m.setAttribute("transform",z);gb("transform",w,J);N("changed",J)}qa("pathpointgrip_container");m=Ha.requestSelector(J[0]);m.resize();m.updateGripCursors(e)};var Ga=this.recalculateAllSelectedDimensions=function(){for(var e=new za(kb==
"none"?"position":"size"),h=J.length;h--;){var m=Xa(J[h]);m&&e.addSubCommand(m)}if(!e.isEmpty()){ya(e);N("changed",J)}},Oa=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],Ya=function(e){console.log([e.a,e.b,e.c,e.d,e.e,e.f])},db=this.remapElement=function(e,h,m){var z=n.gridSnapping&&e.parentNode.parentNode.localName==="svg",w=function(){if(z)for(var G in h)h[G]=wa(h[G]);ma(e,h,1E3,true)};box=svgedit.utilities.getBBox(e);for(var H=0;H<2;H++){var A=H===0?"fill":"stroke",
"none"?"position":"size"),h=J.length;h--;){var m=Ua(J[h]);m&&e.addSubCommand(m)}if(!e.isEmpty()){ya(e);N("changed",J)}},Pa=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],Ya=function(e){console.log([e.a,e.b,e.c,e.d,e.e,e.f])},db=this.remapElement=function(e,h,m){var z=n.gridSnapping&&e.parentNode.parentNode.localName==="svg",w=function(){if(z)for(var G in h)h[G]=wa(h[G]);ma(e,h,1E3,true)};box=svgedit.utilities.getBBox(e);for(var H=0;H<2;H++){var A=H===0?"fill":"stroke",
v=e.getAttribute(A);if(v&&v.indexOf("url(")===0)if(m.a<0||m.d<0){v=R(v).cloneNode(true);if(m.a<0){var F=v.getAttribute("x1"),I=v.getAttribute("x2");v.setAttribute("x1",-(F-1));v.setAttribute("x2",-(I-1))}if(m.d<0){F=v.getAttribute("y1");I=v.getAttribute("y2");v.setAttribute("y1",-(F-1));v.setAttribute("y2",-(I-1))}v.id=ja();lb().appendChild(v);e.setAttribute(A,"url(#"+v.id+")")}}H=e.tagName;if(H==="g"||H==="text"||H==="use")if(m.a==1&&m.b==0&&m.c==0&&m.d==1&&(m.e!=0||m.f!=0)){A=fa(e).matrix;A=ia(A.inverse(),
m,A);h.x=parseFloat(h.x)+A.e;h.y=parseFloat(h.y)+A.f}else{A=Y(e);v=d.createSVGTransform();v.setMatrix(ia(fa(A).matrix,m));A.clear();A.appendItem(v)}switch(H){case "foreignObject":case "rect":case "image":if(H==="image"&&(m.a<0||m.d<0)){A=Y(e);v=d.createSVGTransform();v.setMatrix(ia(fa(A).matrix,m));A.clear();A.appendItem(v)}else{A=O(h.x,h.y,m);h.width=m.a*h.width;h.height=m.d*h.height;h.x=A.x+Math.min(0,h.width);h.y=A.y+Math.min(0,h.height);h.width=Math.abs(h.width);h.height=Math.abs(h.height)}w();
m,A);h.x=parseFloat(h.x)+A.e;h.y=parseFloat(h.y)+A.f}else{A=X(e);v=d.createSVGTransform();v.setMatrix(ia(fa(A).matrix,m));A.clear();A.appendItem(v)}switch(H){case "foreignObject":case "rect":case "image":if(H==="image"&&(m.a<0||m.d<0)){A=X(e);v=d.createSVGTransform();v.setMatrix(ia(fa(A).matrix,m));A.clear();A.appendItem(v)}else{A=O(h.x,h.y,m);h.width=m.a*h.width;h.height=m.d*h.height;h.x=A.x+Math.min(0,h.width);h.y=A.y+Math.min(0,h.height);h.width=Math.abs(h.width);h.height=Math.abs(h.height)}w();
break;case "ellipse":H=O(h.cx,h.cy,m);h.cx=H.x;h.cy=H.y;h.rx=m.a*h.rx;h.ry=m.d*h.ry;h.rx=Math.abs(h.rx);h.ry=Math.abs(h.ry);w();break;case "circle":H=O(h.cx,h.cy,m);h.cx=H.x;h.cy=H.y;H=svgedit.math.transformBox(box.x,box.y,box.width,box.height,m);h.r=Math.min((H.tr.x-H.tl.x)/2,(H.bl.y-H.tl.y)/2);if(h.r)h.r=Math.abs(h.r);w();break;case "line":A=O(h.x1,h.y1,m);F=O(h.x2,h.y2,m);h.x1=A.x;h.y1=A.y;h.x2=F.x;h.y2=F.y;case "text":m=e.querySelectorAll("tspan");for(H=m.length;H--;){A=sa("x",e.getAttribute("x"));
v=sa("x",m[H].getAttribute("x"));F=sa("y",e.getAttribute("y"));I=sa("y",m[H].getAttribute("y"));var D={};if(!isNaN(A)&&!isNaN(v)&&A!=0&&v!=0&&h.x)D.x=h.x-(A-v);if(!isNaN(F)&&!isNaN(I)&&F!=0&&I!=0&&h.y)D.y=h.y-(F-I);if(D.x||D.y)ma(m[H],D,1E3,true)}w();break;case "use":w();break;case "g":(w=$(e).data("gsvg"))&&ma(w,h,1E3,true);break;case "polyline":case "polygon":w=h.points.length;for(H=0;H<w;++H){I=h.points[H];I=O(I.x,I.y,m);h.points[H].x=I.x;h.points[H].y=I.y}w=h.points.length;m="";for(H=0;H<w;++H){I=
h.points[H];m+=I.x+","+I.y+" "}e.setAttribute("points",m);break;case "path":A=e.pathSegList;w=A.numberOfItems;h.d=Array(w);for(H=0;H<w;++H){v=A.getItem(H);h.d[H]={type:v.pathSegType,x:v.x,y:v.y,x1:v.x1,y1:v.y1,x2:v.x2,y2:v.y2,r1:v.r1,r2:v.r2,angle:v.angle,largeArcFlag:v.largeArcFlag,sweepFlag:v.sweepFlag}}w=h.d.length;H=h.d[0];D=O(H.x,H.y,m);h.d[0].x=D.x;h.d[0].y=D.y;for(H=1;H<w;++H){v=h.d[H];A=v.type;if(A%2==0){I=O(v.x!=undefined?v.x:D.x,v.y!=undefined?v.y:D.y,m);A=O(v.x1,v.y1,m);F=O(v.x2,v.y2,m);
v.x=I.x;v.y=I.y;v.x1=A.x;v.y1=A.y;v.x2=F.x;v.y2=F.y}else{v.x=m.a*v.x;v.y=m.d*v.y;v.x1=m.a*v.x1;v.y1=m.d*v.y1;v.x2=m.a*v.x2;v.y2=m.d*v.y2}v.r1=m.a*v.r1;v.r2=m.d*v.r2}m="";w=h.d.length;for(H=0;H<w;++H){v=h.d[H];A=v.type;m+=Oa[A];switch(A){case 13:case 12:m+=v.x+" ";break;case 15:case 14:m+=v.y+" ";break;case 3:case 5:case 19:case 2:case 4:case 18:m+=v.x+","+v.y+" ";break;case 7:case 6:m+=v.x1+","+v.y1+" "+v.x2+","+v.y2+" "+v.x+","+v.y+" ";break;case 9:case 8:m+=v.x1+","+v.y1+" "+v.x+","+v.y+" ";break;
case 11:case 10:m+=v.r1+","+v.r2+" "+v.angle+" "+ +v.largeArcFlag+" "+ +v.sweepFlag+" "+v.x+","+v.y+" ";break;case 17:case 16:m+=v.x2+","+v.y2+" "+v.x+","+v.y+" "}}e.setAttribute("d",m)}},nb=function(e,h,m){e=R(e).firstChild;var z=Y(e),w=d.createSVGTransform();w.setTranslate(h,m);z.appendItem(w);Xa(e)},Xa=this.recalculateDimensions=function(e){if(e==null)return null;var h=Y(e);if(h&&h.numberOfItems>0){for(var m=h.numberOfItems;m--;){var z=h.getItem(m);if(z.type===0)h.removeItem(m);else if(z.type===
v=sa("x",m[H].getAttribute("x"));F=sa("y",e.getAttribute("y"));I=sa("y",m[H].getAttribute("y"));var E={};if(!isNaN(A)&&!isNaN(v)&&A!=0&&v!=0&&h.x)E.x=h.x-(A-v);if(!isNaN(F)&&!isNaN(I)&&F!=0&&I!=0&&h.y)E.y=h.y-(F-I);if(E.x||E.y)ma(m[H],E,1E3,true)}w();break;case "use":w();break;case "g":(w=$(e).data("gsvg"))&&ma(w,h,1E3,true);break;case "polyline":case "polygon":w=h.points.length;for(H=0;H<w;++H){I=h.points[H];I=O(I.x,I.y,m);h.points[H].x=I.x;h.points[H].y=I.y}w=h.points.length;m="";for(H=0;H<w;++H){I=
h.points[H];m+=I.x+","+I.y+" "}e.setAttribute("points",m);break;case "path":A=e.pathSegList;w=A.numberOfItems;h.d=Array(w);for(H=0;H<w;++H){v=A.getItem(H);h.d[H]={type:v.pathSegType,x:v.x,y:v.y,x1:v.x1,y1:v.y1,x2:v.x2,y2:v.y2,r1:v.r1,r2:v.r2,angle:v.angle,largeArcFlag:v.largeArcFlag,sweepFlag:v.sweepFlag}}w=h.d.length;H=h.d[0];E=O(H.x,H.y,m);h.d[0].x=E.x;h.d[0].y=E.y;for(H=1;H<w;++H){v=h.d[H];A=v.type;if(A%2==0){I=O(v.x!=undefined?v.x:E.x,v.y!=undefined?v.y:E.y,m);A=O(v.x1,v.y1,m);F=O(v.x2,v.y2,m);
v.x=I.x;v.y=I.y;v.x1=A.x;v.y1=A.y;v.x2=F.x;v.y2=F.y}else{v.x=m.a*v.x;v.y=m.d*v.y;v.x1=m.a*v.x1;v.y1=m.d*v.y1;v.x2=m.a*v.x2;v.y2=m.d*v.y2}v.r1=m.a*v.r1;v.r2=m.d*v.r2}m="";w=h.d.length;for(H=0;H<w;++H){v=h.d[H];A=v.type;m+=Pa[A];switch(A){case 13:case 12:m+=v.x+" ";break;case 15:case 14:m+=v.y+" ";break;case 3:case 5:case 19:case 2:case 4:case 18:m+=v.x+","+v.y+" ";break;case 7:case 6:m+=v.x1+","+v.y1+" "+v.x2+","+v.y2+" "+v.x+","+v.y+" ";break;case 9:case 8:m+=v.x1+","+v.y1+" "+v.x+","+v.y+" ";break;
case 11:case 10:m+=v.r1+","+v.r2+" "+v.angle+" "+ +v.largeArcFlag+" "+ +v.sweepFlag+" "+v.x+","+v.y+" ";break;case 17:case 16:m+=v.x2+","+v.y2+" "+v.x+","+v.y+" "}}e.setAttribute("d",m)}},nb=function(e,h,m){e=R(e).firstChild;var z=X(e),w=d.createSVGTransform();w.setTranslate(h,m);z.appendItem(w);Ua(e)},Ua=this.recalculateDimensions=function(e){if(e==null)return null;var h=X(e);if(h&&h.numberOfItems>0){for(var m=h.numberOfItems;m--;){var z=h.getItem(m);if(z.type===0)h.removeItem(m);else if(z.type===
1)svgedit.math.isIdentity(z.matrix)&&h.removeItem(m);else z.type===4&&z.angle===0&&h.removeItem(m)}if(h.numberOfItems===1&&oa(e))return null}if(!h||h.numberOfItems==0){e.removeAttribute("transform");return null}if(h){m=h.numberOfItems;for(var w=[];m--;){z=h.getItem(m);if(z.type===1)w.push([z.matrix,m]);else if(w.length)w=[]}if(w.length===2){m=d.createSVGTransformFromMatrix(ia(w[1][0],w[0][0]));h.removeItem(w[0][1]);h.removeItem(w[1][1]);h.insertItemBefore(m,w[1][1])}m=h.numberOfItems;if(m>=2&&h.getItem(m-
2).type===1&&h.getItem(m-1).type===2){w=d.createSVGTransform();z=ia(h.getItem(m-2).matrix,h.getItem(m-1).matrix);w.setMatrix(z);h.removeItem(m-2);h.removeItem(m-2);h.appendItem(w)}}switch(e.tagName){case "line":case "polyline":case "polygon":case "path":break;default:if(h.numberOfItems===1&&h.getItem(0).type===1||h.numberOfItems===2&&h.getItem(0).type===1&&h.getItem(0).type===4)return null}var H=$(e).data("gsvg");m=new za("Transform");var A={},v=null;z=[];switch(e.tagName){case "line":z=["x1","y1",
"x2","y2"];break;case "circle":z=["cx","cy","r"];break;case "ellipse":z=["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":z=["width","height","x","y"];break;case "use":case "text":case "tspan":z=["x","y"];break;case "polygon":case "polyline":v={};v.points=e.getAttribute("points");w=e.points;var F=w.numberOfItems;A.points=Array(F);for(var I=0;I<F;++I){var D=w.getItem(I);A.points[I]={x:D.x,y:D.y}}break;case "path":v={};v.d=e.getAttribute("d");A.d=e.getAttribute("d")}if(z.length){A=
$(e).attr(z);$.each(A,function(ha,Sa){A[ha]=sa(ha,Sa)})}else if(H)A={x:$(H).attr("x")||0,y:$(H).attr("y")||0};if(v==null){v=$.extend(true,{},A);$.each(v,function(ha,Sa){v[ha]=sa(ha,Sa)})}v.transform=Ua?Ua:"";if(e.tagName=="g"&&!H||e.tagName=="a"){w=svgedit.utilities.getBBox(e);var G={x:w.x+w.width/2,y:w.y+w.height/2},L=O(w.x+w.width/2,w.y+w.height/2,fa(h).matrix);z=d.createSVGMatrix();if(w=oa(e)){I=w*Math.PI/180;F=Math.abs(I)>1.0E-10?Math.sin(I)/(1-Math.cos(I)):2/I;for(I=0;I<h.numberOfItems;++I){z=
h.getItem(I);if(z.type==4){z=z.matrix;G.y=(F*z.e+z.f)/2;G.x=(z.e-F*z.f)/2;h.removeItem(I);break}}}I=z=H=0;var k=h.numberOfItems;if(k)var u=h.getItem(0).matrix;if(k>=3&&h.getItem(k-2).type==3&&h.getItem(k-3).type==2&&h.getItem(k-1).type==2){I=3;var C=h.getItem(k-3).matrix,E=h.getItem(k-2).matrix,P=h.getItem(k-1).matrix;F=e.childNodes;for(D=F.length;D--;){var U=F.item(D);z=H=0;if(U.nodeType==1){var S=Y(U);if(S){z=fa(S).matrix;H=oa(U);var X=Ua,aa=[];Ua=U.getAttribute("transform");if(H||pa(S)){var ga=
d.createSVGTransform();ga.setMatrix(ia(C,E,P,z));S.clear();S.appendItem(ga);aa.push(ga)}else{H=ia(z.inverse(),P,z);ga=d.createSVGMatrix();ga.e=-H.e;ga.f=-H.f;z=ia(ga.inverse(),z.inverse(),C,E,P,z,H.inverse());var ra=d.createSVGTransform(),Ta=d.createSVGTransform(),Ba=d.createSVGTransform();ra.setTranslate(H.e,H.f);Ta.setScale(z.a,z.d);Ba.setTranslate(ga.e,ga.f);S.appendItem(Ba);S.appendItem(Ta);S.appendItem(ra);aa.push(Ba);aa.push(Ta);aa.push(ra)}m.addSubCommand(Xa(U));Ua=X}}}h.removeItem(k-1);h.removeItem(k-
2);h.removeItem(k-3)}else if(k>=3&&h.getItem(k-1).type==1){I=3;z=fa(h).matrix;ga=d.createSVGTransform();ga.setMatrix(z);h.clear();h.appendItem(ga)}else if((k==1||k>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){I=2;H=fa(h).matrix;h.removeItem(0);z=fa(h).matrix.inverse();z=ia(z,H);H=z.e;z=z.f;if(H!=0||z!=0){F=e.childNodes;D=F.length;for(k=[];D--;){U=F.item(D);if(U.nodeType==1){if(U.getAttribute("clip-path")){X=U.getAttribute("clip-path");if(k.indexOf(X)===-1){nb(X,H,z);k.push(X)}}X=Ua;Ua=U.getAttribute("transform");
if(S=Y(U)){C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,0):S.appendItem(C);m.addSubCommand(Xa(U));S=e.getElementsByTagNameNS(c,"use");U="#"+U.id;for(C=S.length;C--;){E=S.item(C);if(U==da(E)){P=d.createSVGTransform();P.setTranslate(-H,-z);Y(E).insertItemBefore(P,0);m.addSubCommand(Xa(E))}}Ua=X}}}k=[];Ua=X}}else if(k==1&&h.getItem(0).type==1&&!w){I=1;z=h.getItem(0).matrix;F=e.childNodes;for(D=F.length;D--;){U=F.item(D);if(U.nodeType==1){X=Ua;Ua=U.getAttribute("transform");
if(S=Y(U)){H=ia(z,fa(S).matrix);k=d.createSVGTransform();k.setMatrix(H);S.clear();S.appendItem(k,0);m.addSubCommand(Xa(U));Ua=X;X=U.getAttribute("stroke-width");U.getAttribute("stroke")!=="none"&&!isNaN(X)&&U.setAttribute("stroke-width",X*((Math.abs(H.a)+Math.abs(H.d))/2))}}}h.clear()}else{if(w){G=d.createSVGTransform();G.setRotate(w,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}h.numberOfItems==0&&e.removeAttribute("transform");return null}if(I==2){if(w){L={x:G.x+u.e,y:G.y+u.f};
G=d.createSVGTransform();G.setRotate(w,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else if(I==3){z=fa(h).matrix;u=d.createSVGTransform();u.setRotate(w,G.x,G.y);u=u.matrix;G=d.createSVGTransform();G.setRotate(w,L.x,L.y);L=G.matrix.inverse();X=z.inverse();L=ia(X,L,u,z);H=L.e;z=L.f;if(H!=0||z!=0){F=e.childNodes;for(D=F.length;D--;){U=F.item(D);if(U.nodeType==1){X=Ua;Ua=U.getAttribute("transform");S=Y(U);C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,
0):S.appendItem(C);m.addSubCommand(Xa(U));Ua=X}}}if(w)h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else{w=svgedit.utilities.getBBox(e);if(!w&&e.tagName!="path")return null;z=d.createSVGMatrix();if(H=oa(e)){G={x:w.x+w.width/2,y:w.y+w.height/2};L=O(w.x+w.width/2,w.y+w.height/2,fa(h).matrix);I=H*Math.PI/180;F=Math.abs(I)>1.0E-10?Math.sin(I)/(1-Math.cos(I)):2/I;for(I=0;I<h.numberOfItems;++I){z=h.getItem(I);if(z.type==4){z=z.matrix;G.y=(F*z.e+z.f)/2;G.x=(z.e-F*z.f)/2;h.removeItem(I);break}}}I=
0;k=h.numberOfItems;if(!svgedit.browser.isWebkit())if((u=e.getAttribute("fill"))&&u.indexOf("url(")===0){u=R(u);X="pattern";if(u.tagName!==X)X="gradient";if(u.getAttribute(X+"Units")==="userSpaceOnUse"){z=fa(h).matrix;w=Y(u);w=fa(w).matrix;z=ia(z,w);w="matrix("+[z.a,z.b,z.c,z.d,z.e,z.f].join(",")+")";u.setAttribute(X+"Transform",w)}}if(k>=3&&h.getItem(k-2).type==3&&h.getItem(k-3).type==2&&h.getItem(k-1).type==2){I=3;z=fa(h,k-3,k-1).matrix;h.removeItem(k-1);h.removeItem(k-2);h.removeItem(k-3)}else if(k==
4&&h.getItem(k-1).type==1){I=3;z=fa(h).matrix;ga=d.createSVGTransform();ga.setMatrix(z);h.clear();h.appendItem(ga);z=d.createSVGMatrix()}else if((k==1||k>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){I=2;u=h.getItem(0).matrix;X=fa(h,1).matrix;w=X.inverse();z=ia(w,u,X);h.removeItem(0)}else if(k==1&&h.getItem(0).type==1&&!H){z=fa(h).matrix;switch(e.tagName){case "line":A=$(e).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":A.points=e.getAttribute("points");if(A.points){w=e.points;F=w.numberOfItems;
A.points=Array(F);for(I=0;I<F;++I){D=w.getItem(I);A.points[I]={x:D.x,y:D.y}}}case "path":A.d=e.getAttribute("d");I=1;h.clear()}}else{I=4;if(H){G=d.createSVGTransform();G.setRotate(H,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}h.numberOfItems==0&&e.removeAttribute("transform");return null}if(I==1||I==2||I==3)db(e,A,z);if(I==2){if(H){pa(h)||(L={x:G.x+z.e,y:G.y+z.f});G=d.createSVGTransform();G.setRotate(H,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else if(I==
3&&H){z=fa(h).matrix;u=d.createSVGTransform();u.setRotate(H,G.x,G.y);u=u.matrix;G=d.createSVGTransform();G.setRotate(H,L.x,L.y);L=G.matrix.inverse();X=z.inverse();L=ia(X,L,u,z);db(e,A,L);if(H)h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}h.numberOfItems==0&&e.removeAttribute("transform");m.addSubCommand(new Na(e,v));return m},rb=null,Pa=this.clearSelection=function(e){if(J[0]!=null)for(var h=J.length,m=0;m<h;++m){var z=J[m];if(z==null)break;Ha.releaseSelector(z);J[m]=null}e||N("selected",
"x2","y2"];break;case "circle":z=["cx","cy","r"];break;case "ellipse":z=["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":z=["width","height","x","y"];break;case "use":case "text":case "tspan":z=["x","y"];break;case "polygon":case "polyline":v={};v.points=e.getAttribute("points");w=e.points;var F=w.numberOfItems;A.points=Array(F);for(var I=0;I<F;++I){var E=w.getItem(I);A.points[I]={x:E.x,y:E.y}}break;case "path":v={};v.d=e.getAttribute("d");A.d=e.getAttribute("d")}if(z.length){A=
$(e).attr(z);$.each(A,function(ha,Ta){A[ha]=sa(ha,Ta)})}else if(H)A={x:$(H).attr("x")||0,y:$(H).attr("y")||0};if(v==null){v=$.extend(true,{},A);$.each(v,function(ha,Ta){v[ha]=sa(ha,Ta)})}v.transform=Va?Va:"";if(e.tagName=="g"&&!H||e.tagName=="a"){w=svgedit.utilities.getBBox(e);var G={x:w.x+w.width/2,y:w.y+w.height/2},L=O(w.x+w.width/2,w.y+w.height/2,fa(h).matrix);z=d.createSVGMatrix();if(w=oa(e)){I=w*Math.PI/180;F=Math.abs(I)>1.0E-10?Math.sin(I)/(1-Math.cos(I)):2/I;for(I=0;I<h.numberOfItems;++I){z=
h.getItem(I);if(z.type==4){z=z.matrix;G.y=(F*z.e+z.f)/2;G.x=(z.e-F*z.f)/2;h.removeItem(I);break}}}I=z=H=0;var k=h.numberOfItems;if(k)var u=h.getItem(0).matrix;if(k>=3&&h.getItem(k-2).type==3&&h.getItem(k-3).type==2&&h.getItem(k-1).type==2){I=3;var C=h.getItem(k-3).matrix,D=h.getItem(k-2).matrix,P=h.getItem(k-1).matrix;F=e.childNodes;for(E=F.length;E--;){var U=F.item(E);z=H=0;if(U.nodeType==1){var S=X(U);if(S){z=fa(S).matrix;H=oa(U);var Y=Va,aa=[];Va=U.getAttribute("transform");if(H||pa(S)){var ga=
d.createSVGTransform();ga.setMatrix(ia(C,D,P,z));S.clear();S.appendItem(ga);aa.push(ga)}else{H=ia(z.inverse(),P,z);ga=d.createSVGMatrix();ga.e=-H.e;ga.f=-H.f;z=ia(ga.inverse(),z.inverse(),C,D,P,z,H.inverse());var ra=d.createSVGTransform(),Oa=d.createSVGTransform(),Ba=d.createSVGTransform();ra.setTranslate(H.e,H.f);Oa.setScale(z.a,z.d);Ba.setTranslate(ga.e,ga.f);S.appendItem(Ba);S.appendItem(Oa);S.appendItem(ra);aa.push(Ba);aa.push(Oa);aa.push(ra)}m.addSubCommand(Ua(U));Va=Y}}}h.removeItem(k-1);h.removeItem(k-
2);h.removeItem(k-3)}else if(k>=3&&h.getItem(k-1).type==1){I=3;z=fa(h).matrix;ga=d.createSVGTransform();ga.setMatrix(z);h.clear();h.appendItem(ga)}else if((k==1||k>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){I=2;H=fa(h).matrix;h.removeItem(0);z=fa(h).matrix.inverse();z=ia(z,H);H=z.e;z=z.f;if(H!=0||z!=0){F=e.childNodes;E=F.length;for(k=[];E--;){U=F.item(E);if(U.nodeType==1){if(U.getAttribute("clip-path")){Y=U.getAttribute("clip-path");if(k.indexOf(Y)===-1){nb(Y,H,z);k.push(Y)}}Y=Va;Va=U.getAttribute("transform");
if(S=X(U)){C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,0):S.appendItem(C);m.addSubCommand(Ua(U));S=e.getElementsByTagNameNS(c,"use");U="#"+U.id;for(C=S.length;C--;){D=S.item(C);if(U==da(D)){P=d.createSVGTransform();P.setTranslate(-H,-z);X(D).insertItemBefore(P,0);m.addSubCommand(Ua(D))}}Va=Y}}}k=[];Va=Y}}else if(k==1&&h.getItem(0).type==1&&!w){I=1;z=h.getItem(0).matrix;F=e.childNodes;for(E=F.length;E--;){U=F.item(E);if(U.nodeType==1){Y=Va;Va=U.getAttribute("transform");
if(S=X(U)){H=ia(z,fa(S).matrix);k=d.createSVGTransform();k.setMatrix(H);S.clear();S.appendItem(k,0);m.addSubCommand(Ua(U));Va=Y;Y=U.getAttribute("stroke-width");U.getAttribute("stroke")!=="none"&&!isNaN(Y)&&U.setAttribute("stroke-width",Y*((Math.abs(H.a)+Math.abs(H.d))/2))}}}h.clear()}else{if(w){G=d.createSVGTransform();G.setRotate(w,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}h.numberOfItems==0&&e.removeAttribute("transform");return null}if(I==2){if(w){L={x:G.x+u.e,y:G.y+u.f};
G=d.createSVGTransform();G.setRotate(w,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else if(I==3){z=fa(h).matrix;u=d.createSVGTransform();u.setRotate(w,G.x,G.y);u=u.matrix;G=d.createSVGTransform();G.setRotate(w,L.x,L.y);L=G.matrix.inverse();Y=z.inverse();L=ia(Y,L,u,z);H=L.e;z=L.f;if(H!=0||z!=0){F=e.childNodes;for(E=F.length;E--;){U=F.item(E);if(U.nodeType==1){Y=Va;Va=U.getAttribute("transform");S=X(U);C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,
0):S.appendItem(C);m.addSubCommand(Ua(U));Va=Y}}}if(w)h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else{w=svgedit.utilities.getBBox(e);if(!w&&e.tagName!="path")return null;z=d.createSVGMatrix();if(H=oa(e)){G={x:w.x+w.width/2,y:w.y+w.height/2};L=O(w.x+w.width/2,w.y+w.height/2,fa(h).matrix);I=H*Math.PI/180;F=Math.abs(I)>1.0E-10?Math.sin(I)/(1-Math.cos(I)):2/I;for(I=0;I<h.numberOfItems;++I){z=h.getItem(I);if(z.type==4){z=z.matrix;G.y=(F*z.e+z.f)/2;G.x=(z.e-F*z.f)/2;h.removeItem(I);break}}}I=
0;k=h.numberOfItems;if(!svgedit.browser.isWebkit())if((u=e.getAttribute("fill"))&&u.indexOf("url(")===0){u=R(u);Y="pattern";if(u.tagName!==Y)Y="gradient";if(u.getAttribute(Y+"Units")==="userSpaceOnUse"){z=fa(h).matrix;w=X(u);w=fa(w).matrix;z=ia(z,w);w="matrix("+[z.a,z.b,z.c,z.d,z.e,z.f].join(",")+")";u.setAttribute(Y+"Transform",w)}}if(k>=3&&h.getItem(k-2).type==3&&h.getItem(k-3).type==2&&h.getItem(k-1).type==2){I=3;z=fa(h,k-3,k-1).matrix;h.removeItem(k-1);h.removeItem(k-2);h.removeItem(k-3)}else if(k==
4&&h.getItem(k-1).type==1){I=3;z=fa(h).matrix;ga=d.createSVGTransform();ga.setMatrix(z);h.clear();h.appendItem(ga);z=d.createSVGMatrix()}else if((k==1||k>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){I=2;u=h.getItem(0).matrix;Y=fa(h,1).matrix;w=Y.inverse();z=ia(w,u,Y);h.removeItem(0)}else if(k==1&&h.getItem(0).type==1&&!H){z=fa(h).matrix;switch(e.tagName){case "line":A=$(e).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":A.points=e.getAttribute("points");if(A.points){w=e.points;F=w.numberOfItems;
A.points=Array(F);for(I=0;I<F;++I){E=w.getItem(I);A.points[I]={x:E.x,y:E.y}}}case "path":A.d=e.getAttribute("d");I=1;h.clear()}}else{I=4;if(H){G=d.createSVGTransform();G.setRotate(H,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}h.numberOfItems==0&&e.removeAttribute("transform");return null}if(I==1||I==2||I==3)db(e,A,z);if(I==2){if(H){pa(h)||(L={x:G.x+z.e,y:G.y+z.f});G=d.createSVGTransform();G.setRotate(H,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else if(I==
3&&H){z=fa(h).matrix;u=d.createSVGTransform();u.setRotate(H,G.x,G.y);u=u.matrix;G=d.createSVGTransform();G.setRotate(H,L.x,L.y);L=G.matrix.inverse();Y=z.inverse();L=ia(Y,L,u,z);db(e,A,L);if(H)h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}h.numberOfItems==0&&e.removeAttribute("transform");m.addSubCommand(new Na(e,v));return m},rb=null,Qa=this.clearSelection=function(e){if(J[0]!=null)for(var h=J.length,m=0;m<h;++m){var z=J[m];if(z==null)break;Ha.releaseSelector(z);J[m]=null}e||N("selected",
J)},vb=this.addToSelection=function(e,h){if(e.length!=0){for(var m=0;m<J.length;){if(J[m]==null)break;++m}for(var z=e.length;z--;){var w=e[z];if(w&&svgedit.utilities.getBBox(w)){if(w.tagName==="a"&&w.childNodes.length===1)w=w.firstChild;if(J.indexOf(w)==-1){J[m]=w;m++;w=Ha.requestSelector(w);J.length>1&&w.showGrips(false)}}}N("selected",J);h||J.length==1?Ha.requestSelector(J[0]).showGrips(true):Ha.requestSelector(J[0]).showGrips(false);for(J.sort(function(H,A){if(H&&A&&H.compareDocumentPosition)return 3-
(A.compareDocumentPosition(H)&6);else if(H==null)return 1});J[0]==null;)J.shift(0)}},Bb=this.selectOnly=function(e,h){Pa(true);vb(e,h)};this.removeFromSelection=function(e){if(J[0]!=null)if(e.length!=0){var h=Array(J.length);j=0;len=J.length;for(var m=0;m<len;++m){var z=J[m];if(z)if(e.indexOf(z)==-1){h[j]=z;j++}else Ha.releaseSelector(z)}J=h}};this.selectAllInCurrentLayer=function(){var e=B().getCurrentLayer();if(e){Ea="select";Bb($(K||e).children())}};var Ib=this.getMouseTarget=function(e){if(e==
(A.compareDocumentPosition(H)&6);else if(H==null)return 1});J[0]==null;)J.shift(0)}},xb=this.selectOnly=function(e,h){Qa(true);vb(e,h)};this.removeFromSelection=function(e){if(J[0]!=null)if(e.length!=0){var h=Array(J.length);j=0;len=J.length;for(var m=0;m<len;++m){var z=J[m];if(z)if(e.indexOf(z)==-1){h[j]=z;j++}else Ha.releaseSelector(z)}J=h}};this.selectAllInCurrentLayer=function(){var e=B().getCurrentLayer();if(e){Ea="select";xb($(K||e).children())}};var Ib=this.getMouseTarget=function(e){if(e==
null)return null;e=e.target;if(e.correspondingUseElement)e=e.correspondingUseElement;if(["http://www.w3.org/1998/Math/MathML","http://www.w3.org/1999/xhtml"].indexOf(e.namespaceURI)>=0&&e.id!="svgcanvas")for(;e.nodeName!="foreignObject";){e=e.parentNode;if(!e)return d}var h=B().getCurrentLayer();if([d,a,l,h].indexOf(e)>=0)return d;if($(e).closest("#selectorParentGroup").length)return Ha.selectorParentGroup;for(;e.parentNode!==(K||h);)e=e.parentNode;return e};(function(){var e=null,h=null,m=null,z=
null,w=null,H={},A={minx:null,miny:null,maxx:null,maxy:null};$(a).mousedown(function(v){if(!(v.originalEvent.touches&&v.originalEvent.touches>1)){var F=v.button===2;rb=l.getScreenCTM().inverse();var I=O(v.pageX,v.pageY,rb),D=I.x*o;I=I.y*o;v.preventDefault();if(F)Ea="select";D=D/o;I=I/o;var G=Ib(v);if(G.tagName==="a"&&G.childNodes.length===1)G=G.firstChild;var L=z=h=D,k=w=m=I;if(n.gridSnapping){D=wa(D);I=wa(I);h=wa(h);m=wa(m)}if(G==Ha.selectorParentGroup&&J[0]!=null){G=v.target;var u=ib(G,"type");
if(u=="rotate"){Ea="rotate";current_rotate_mode=ib(G,"dir")}else if(u=="resize"){Ea="resize";kb=ib(G,"dir")}G=J[0]}Ua=G.getAttribute("transform");u=Y(G);switch(Ea){case "select":La=true;kb="none";if(F)La=false;if(G!=d){if(J.indexOf(G)==-1){v.shiftKey||Pa(true);vb([G]);Cb=G;Ja.clear()}if(!F)for(F=0;F<J.length;++F)if(J[F]!=null){var C=Y(J[F]);C.numberOfItems?C.insertItemBefore(d.createSVGTransform(),0):C.appendItem(d.createSVGTransform())}}else if(!F){Pa();Ea="multiselect";if(ta==null)ta=Ha.getRubberBandBox();
z*=o;w*=o;ma(ta,{x:z,y:w,width:0,height:0,display:"inline"},100)}break;case "zoom":La=true;if(ta==null)ta=Ha.getRubberBandBox();ma(ta,{x:L*o,y:L*o,width:0,height:0,display:"inline"},100);break;case "resize":La=true;h=D;m=I;H=svgedit.utilities.getBBox($("#selectedBox0")[0]);var E={};$.each(H,function(P,U){E[P]=U/o});H=E;F=oa(G)?1:0;if(pa(u)){u.insertItemBefore(d.createSVGTransform(),F);u.insertItemBefore(d.createSVGTransform(),F);u.insertItemBefore(d.createSVGTransform(),F)}else{u.appendItem(d.createSVGTransform());
u.appendItem(d.createSVGTransform());u.appendItem(d.createSVGTransform());if(svgedit.browser.supportsNonScalingStroke()){if(D=svgedit.browser.isChrome())C=function(P){var U=P.getAttributeNS(null,"stroke");P.removeAttributeNS(null,"stroke");setTimeout(function(){P.setAttributeNS(null,"stroke",U)},1)};G.style.vectorEffect="non-scaling-stroke";D&&C(G);I=G.getElementsByTagName("*");L=I.length;for(F=0;F<L;F++){I[F].style.vectorEffect="non-scaling-stroke";D&&C(I[F])}}}break;case "fhellipse":case "fhrect":case "fhpath":La=
true;e=L+","+k+" ";C=M.stroke_width==0?1:M.stroke_width;Q({element:"polyline",curStyles:true,attr:{points:e,id:ja(),fill:"none",opacity:M.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}});A.minx=L;A.maxx=L;A.miny=k;A.maxy=k;break;case "image":La=true;C=Q({element:"image",attr:{x:D,y:I,width:0,height:0,id:ja(),opacity:M.opacity/2,style:"pointer-events:inherit"}});V(C,Da);pb(C);break;case "square":case "rect":La=true;h=D;m=I;Q({element:"rect",curStyles:true,attr:{x:D,y:I,width:0,height:0,
id:ja(),opacity:M.opacity/2}});break;case "line":La=true;C=M.stroke_width==0?1:M.stroke_width;Q({element:"line",curStyles:true,attr:{x1:D,y1:I,x2:D,y2:I,id:ja(),stroke:M.stroke,"stroke-width":C,"stroke-dasharray":M.stroke_dasharray,"stroke-linejoin":M.stroke_linejoin,"stroke-linecap":M.stroke_linecap,"stroke-opacity":M.stroke_opacity,fill:"none",opacity:M.opacity/2,style:"pointer-events:none"}});break;case "circle":La=true;Q({element:"circle",curStyles:true,attr:{cx:D,cy:I,r:0,id:ja(),opacity:M.opacity/
2}});break;case "ellipse":La=true;Q({element:"ellipse",curStyles:true,attr:{cx:D,cy:I,rx:0,ry:0,id:ja(),opacity:M.opacity/2}});break;case "text":La=true;Q({element:"text",curStyles:true,attr:{x:D,y:I,id:ja(),fill:Za.fill,"stroke-width":Za.stroke_width,"font-size":Za.font_size,"font-family":Za.font_family,"text-anchor":"left","xml:space":"preserve",opacity:M.opacity}});break;case "path":case "pathedit":h*=o;m*=o;Ja.mouseDown(v,G,h,m);La=true;break;case "textedit":h*=o;m*=o;hb.mouseDown(v,G,h,m);La=
null,w=null,H={},A={minx:null,miny:null,maxx:null,maxy:null};$(a).mousedown(function(v){if(!(v.originalEvent.touches&&v.originalEvent.touches>1)){var F=v.button===2;rb=l.getScreenCTM().inverse();var I=O(v.pageX,v.pageY,rb),E=I.x*o;I=I.y*o;v.preventDefault();if(F)Ea="select";E=E/o;I=I/o;var G=Ib(v);if(G.tagName==="a"&&G.childNodes.length===1)G=G.firstChild;var L=z=h=E,k=w=m=I;if(n.gridSnapping){E=wa(E);I=wa(I);h=wa(h);m=wa(m)}if(G==Ha.selectorParentGroup&&J[0]!=null){G=v.target;var u=ib(G,"type");
if(u=="rotate"){Ea="rotate";current_rotate_mode=ib(G,"dir")}else if(u=="resize"){Ea="resize";kb=ib(G,"dir")}G=J[0]}Va=G.getAttribute("transform");u=X(G);switch(Ea){case "select":La=true;kb="none";if(F)La=false;if(G!=d){if(J.indexOf(G)==-1){v.shiftKey||Qa(true);vb([G]);Cb=G;Ja.clear()}if(!F)for(F=0;F<J.length;++F)if(J[F]!=null){var C=X(J[F]);C.numberOfItems?C.insertItemBefore(d.createSVGTransform(),0):C.appendItem(d.createSVGTransform())}}else if(!F){Qa();Ea="multiselect";if(ua==null)ua=Ha.getRubberBandBox();
z*=o;w*=o;ma(ua,{x:z,y:w,width:0,height:0,display:"inline"},100)}break;case "zoom":La=true;if(ua==null)ua=Ha.getRubberBandBox();ma(ua,{x:L*o,y:L*o,width:0,height:0,display:"inline"},100);break;case "resize":La=true;h=E;m=I;H=svgedit.utilities.getBBox($("#selectedBox0")[0]);var D={};$.each(H,function(P,U){D[P]=U/o});H=D;F=oa(G)?1:0;if(pa(u)){u.insertItemBefore(d.createSVGTransform(),F);u.insertItemBefore(d.createSVGTransform(),F);u.insertItemBefore(d.createSVGTransform(),F)}else{u.appendItem(d.createSVGTransform());
u.appendItem(d.createSVGTransform());u.appendItem(d.createSVGTransform());if(svgedit.browser.supportsNonScalingStroke()){if(E=svgedit.browser.isChrome())C=function(P){var U=P.getAttributeNS(null,"stroke");P.removeAttributeNS(null,"stroke");setTimeout(function(){P.setAttributeNS(null,"stroke",U)},1)};G.style.vectorEffect="non-scaling-stroke";E&&C(G);I=G.getElementsByTagName("*");L=I.length;for(F=0;F<L;F++){I[F].style.vectorEffect="non-scaling-stroke";E&&C(I[F])}}}break;case "fhellipse":case "fhrect":case "fhpath":La=
true;e=L+","+k+" ";C=M.stroke_width==0?1:M.stroke_width;Q({element:"polyline",curStyles:true,attr:{points:e,id:ja(),fill:"none",opacity:M.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}});A.minx=L;A.maxx=L;A.miny=k;A.maxy=k;break;case "image":La=true;C=Q({element:"image",attr:{x:E,y:I,width:0,height:0,id:ja(),opacity:M.opacity/2,style:"pointer-events:inherit"}});V(C,Da);pb(C);break;case "square":case "rect":La=true;h=E;m=I;Q({element:"rect",curStyles:true,attr:{x:E,y:I,width:0,height:0,
id:ja(),opacity:M.opacity/2}});break;case "line":La=true;C=M.stroke_width==0?1:M.stroke_width;Q({element:"line",curStyles:true,attr:{x1:E,y1:I,x2:E,y2:I,id:ja(),stroke:M.stroke,"stroke-width":C,"stroke-dasharray":M.stroke_dasharray,"stroke-linejoin":M.stroke_linejoin,"stroke-linecap":M.stroke_linecap,"stroke-opacity":M.stroke_opacity,fill:"none",opacity:M.opacity/2,style:"pointer-events:none"}});break;case "circle":La=true;Q({element:"circle",curStyles:true,attr:{cx:E,cy:I,r:0,id:ja(),opacity:M.opacity/
2}});break;case "ellipse":La=true;Q({element:"ellipse",curStyles:true,attr:{cx:E,cy:I,rx:0,ry:0,id:ja(),opacity:M.opacity/2}});break;case "text":La=true;Q({element:"text",curStyles:true,attr:{x:E,y:I,id:ja(),fill:Za.fill,"stroke-width":Za.stroke_width,"font-size":Za.font_size,"font-family":Za.font_family,"text-anchor":"left","xml:space":"preserve",opacity:M.opacity}});break;case "path":case "pathedit":h*=o;m*=o;Ja.mouseDown(v,G,h,m);La=true;break;case "textedit":h*=o;m*=o;hb.mouseDown(v,G,h,m);La=
true;break;case "rotate":La=true;b.undoMgr.beginUndoableChange("transform",J);document.getElementById("workarea").className="rotate"}C=ob("mouseDown",{event:v,start_x:h,start_y:m,selectedElements:J},true);$.each(C,function(P,U){if(U&&U.started)La=true});if(Ea)document.getElementById("workarea").className=Ea=="resize"?v.target.style.cursor:Ea}}).mousemove(function(v){if(!(v.originalEvent.touches&&v.originalEvent.touches.length>1))if(La)if(!(v.button===1||b.spaceKey)){var F=J[0],I=O(v.pageX,v.pageY,
rb),D=I.x*o;I=I.y*o;var G=qa(ca()),L=x=D/o,k=y=I/o;if(n.gridSnapping){x=wa(x);y=wa(y)}v.preventDefault();switch(Ea){case "select":if(J[0]!==null){L=x-h;var u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u)}if(v.shiftKey){var C=ba(h,m,x,y);x=C.x;y=C.y}if(L!=0||u!=0){C=J.length;for(k=0;k<C;++k){F=J[k];if(F==null)break;var E=d.createSVGTransform();G=Y(F);E.setTranslate(L,u);G.numberOfItems?G.replaceItem(E,0):G.appendItem(E);Ha.requestSelector(F).resize()}if(v.altKey)if(!b.addClone){b.addClone=b.cloneSelectedElements(0,
0,E);b.removeClone=function(){if(parent=b.addClone.parentNode){parent.removeChild(b.addClone);b.addClone=false}};window.addEventListener("keyup",b.removeClone)}N("transition",J)}}break;case "multiselect":L*=o;k*=o;ma(ta,{x:Math.min(z,L),y:Math.min(w,k),width:Math.abs(L-z),height:Math.abs(k-w)},100);G=[];L=[];E=tb();C=J.length;for(k=0;k<C;++k){u=E.indexOf(J[k]);if(u==-1)G.push(J[k]);else E[u]=null}C=E.length;for(k=0;k<C;++k)E[k]&&L.push(E[k]);G.length>0&&b.removeFromSelection(G);L.length>0&&vb(L);
break;case "resize":G=Y(F);L=(E=pa(G))?H:svgedit.utilities.getBBox(F);C=L.x;k=L.y;var P=L.width,U=L.height;L=x-h;u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u);U=wa(U);P=wa(P)}var S=oa(F);if(S){var X=Math.sqrt(L*L+u*u);u=Math.atan2(u,L)-S*Math.PI/180;L=X*Math.cos(u);u=X*Math.sin(u)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)u=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)L=0;var aa=X=0,ga=U?(U+u)/U:1,ra=P?(P+L)/P:1;if(kb.indexOf("n")>=0){ga=U?(U-u)/U:1;aa=U}if(kb.indexOf("w")>=0){ra=P?(P-L)/P:1;X=P}L=
d.createSVGTransform();u=d.createSVGTransform();P=d.createSVGTransform();if(n.gridSnapping){C=wa(C);X=wa(X);k=wa(k);aa=wa(aa)}L.setTranslate(-(C+X),-(k+aa));if(v.shiftKey)if(ra==1)ra=ga;else ga=ra;u.setScale(ra,ga);P.setTranslate(C+X,k+aa);if(E){E=S?1:0;G.replaceItem(L,2+E);G.replaceItem(u,1+E);G.replaceItem(P,0+E)}else{E=G.numberOfItems;G.replaceItem(P,E-3);G.replaceItem(u,E-2);G.replaceItem(L,E-1)}Ha.requestSelector(F).resize();N("transition",J);break;case "zoom":L*=o;k*=o;ma(ta,{x:Math.min(z*o,
L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100);break;case "text":ma(G,{x:x,y:y},1E3);break;case "line":L=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=wa(x);y=wa(y)}E=x;C=y;if(v.shiftKey){C=ba(h,m,E,C);E=C.x;C=C.y}G.setAttributeNS(null,"x2",E);G.setAttributeNS(null,"y2",C);window.opera||d.unsuspendRedraw(L);break;case "foreignObject":case "square":case "rect":case "image":L=Math.abs(x-h);E=Math.abs(y-m);if(Ea=="square"||v.shiftKey){L=E=Math.max(L,E);C=h<x?h:
h-L;k=m<y?m:m-E}else{C=Math.min(h,x);k=Math.min(m,y)}if(v.altKey){L*=2;E*=2;C=h-L/2;k=m-E/2}if(n.gridSnapping){L=wa(L);E=wa(E);C=wa(C);k=wa(k)}ma(G,{width:L,height:E,x:C,y:k},1E3);break;case "circle":L=$(G).attr(["cx","cy"]);E=L.cx;C=L.cy;L=Math.sqrt((x-E)*(x-E)+(y-C)*(y-C));if(n.gridSnapping)L=wa(L);G.setAttributeNS(null,"r",L);break;case "ellipse":L=$(G).attr(["cx","cy"]);E=Math.abs(h+(x-h)/2);C=Math.abs(m+(y-m)/2);L=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=wa(x);E=wa(E);y=wa(y);
C=wa(C)}k=Math.abs(h-E);u=Math.abs(m-C);if(v.shiftKey){u=k;C=y>m?m+k:m-k}if(v.altKey){E=h;C=m;k=Math.abs(x-E);u=v.shiftKey?k:Math.abs(y-C)}G.setAttributeNS(null,"rx",k);G.setAttributeNS(null,"ry",u);G.setAttributeNS(null,"cx",E);G.setAttributeNS(null,"cy",C);window.opera||d.unsuspendRedraw(L);break;case "fhellipse":case "fhrect":A.minx=Math.min(L,A.minx);A.maxx=Math.max(L,A.maxx);A.miny=Math.min(k,A.miny);A.maxy=Math.max(k,A.maxy);case "fhpath":e+=+L+","+k+" ";G.setAttributeNS(null,"points",e);break;
case "path":case "pathedit":x*=o;y*=o;if(n.gridSnapping){x=wa(x);y=wa(y);h=wa(h);m=wa(m)}if(v.shiftKey){if(E=svgedit.path.path){G=E.dragging?E.dragging[0]:h;E=E.dragging?E.dragging[1]:m}else{G=h;E=m}C=ba(G,E,x,y);x=C.x;y=C.y}if(ta&&ta.getAttribute("display")!=="none"){L*=o;k*=o;ma(ta,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100)}Ja.mouseMove(v,x,y);break;case "textedit":x*=o;y*=o;hb.mouseMove(D,I);break;case "rotate":L=svgedit.utilities.getBBox(F);E=L.x+L.width/
2;C=L.y+L.height/2;G=W(F);G=O(E,C,G);E=G.x;C=G.y;G=L.x;k=L.y;if(current_rotate_mode=="nw")G=L.x+L.width;if(current_rotate_mode=="se")k=L.y+L.height;if(current_rotate_mode=="sw"){G=L.x+L.width;k=L.y+L.height}compensation_angle=(Math.atan2(C-k,E-G)*(180/Math.PI)-90)%360;S=(Math.atan2(C-y,E-x)*(180/Math.PI)-90)%360;S+=compensation_angle;if(n.gridSnapping)S=wa(S);if(v.shiftKey)S=Math.round(S/45)*45;b.setRotationAngle(S<-180?360+S:S,true);N("transition",J)}ob("mouseMove",{event:v,mouse_x:D,mouse_y:I,selected:F})}}).click(function(v){v.preventDefault();
return false}).dblclick(function(v){var F=v.target.parentNode;if(F!==K){var I=Ib(v),D=I.tagName;if(D==="text"&&Ea!=="textedit"){v=O(v.pageX,v.pageY,rb);hb.select(I,v.x,v.y)}if((D==="g"||D==="a")&&oa(I)){Mb(I);I=J[0];Pa(true)}K&&Jb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||I===Ha.selectorParentGroup||Rb(I)}}).mouseup(function(v){b.addClone=false;window.removeEventListener("keyup",b.removeClone);if(v.button!==2){var F=Cb;Cb=null;if(La){var I=O(v.pageX,v.pageY,rb),D=I.x*o;I=I.y*
o;var G=D/o,L=I/o,k=qa(ca()),u=false;La=false;switch(Ea){case "resize":case "multiselect":if(ta!=null){ta.setAttribute("display","none");mb=[]}Ea="select";case "select":if(J[0]!=null){if(J[1]==null){D=J[0];switch(D.tagName){case "g":case "use":case "image":case "foreignObject":break;default:bb.fill=D.getAttribute("fill");bb.fill_opacity=D.getAttribute("fill-opacity");bb.stroke=D.getAttribute("stroke");bb.stroke_opacity=D.getAttribute("stroke-opacity");bb.stroke_width=D.getAttribute("stroke-width");
bb.stroke_dasharray=D.getAttribute("stroke-dasharray");bb.stroke_linejoin=D.getAttribute("stroke-linejoin");bb.stroke_linecap=D.getAttribute("stroke-linecap")}if(D.tagName=="text"){Za.font_size=D.getAttribute("font-size");Za.font_family=D.getAttribute("font-family")}Ha.requestSelector(D).showGrips(true)}Ga();if(G!=z||L!=w){v=J.length;for(D=0;D<v;++D){if(J[D]==null)break;J[D].firstChild||Ha.requestSelector(J[D]).resize()}}else{D=v.target;if(J[0].nodeName==="path"&&J[1]==null)Ja.select(J[0]);else v.shiftKey&&
F!=D&&b.removeFromSelection([D])}if(svgedit.browser.supportsNonScalingStroke())if(v=J[0]){v.removeAttribute("style");svgedit.utilities.walkTree(v,function(P){P.removeAttribute("style")})}}return;case "zoom":ta!=null&&ta.setAttribute("display","none");N("zoomed",{x:Math.min(z,G),y:Math.min(w,L),width:Math.abs(G-z),height:Math.abs(L-w),factor:v.altKey?0.5:2});return;case "fhpath":F=k.getAttribute("points");G=F.indexOf(",");if(u=G>=0?F.indexOf(",",G+1)>=0:F.indexOf(" ",F.indexOf(" ")+1)>=0)k=Ja.smoothPolylineIntoPath(k);
break;case "line":F=$(k).attr(["x1","x2","y1","y2"]);u=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(k).attr(["width","height"]);u=F.width!=0||F.height!=0||Ea==="image";break;case "circle":u=k.getAttribute("r")!=0;break;case "ellipse":F=$(k).attr(["rx","ry"]);u=F.rx!=null||F.ry!=null;break;case "fhellipse":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=Q({element:"ellipse",curStyles:true,attr:{cx:(A.minx+A.maxx)/2,cy:(A.miny+A.maxy)/2,rx:(A.maxx-A.minx)/2,ry:(A.maxy-
A.miny)/2,id:ca()}});N("changed",[k]);u=true}break;case "fhrect":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=Q({element:"rect",curStyles:true,attr:{x:A.minx,y:A.miny,width:A.maxx-A.minx,height:A.maxy-A.miny,id:ca()}});N("changed",[k]);u=true}break;case "text":u=true;Bb([k]);hb.start(k);break;case "path":k=null;La=true;F=Ja.mouseUp(v,k,D,I);k=F.element;u=F.keep;break;case "pathedit":u=true;k=null;Ja.mouseUp(v);break;case "textedit":u=false;k=null;hb.mouseUp(v,D,I);break;case "rotate":u=true;k=null;Ea="select";
F=b.undoMgr.finishUndoableChange();F.isEmpty()||ya(F);Ga();N("changed",J)}D=ob("mouseUp",{event:v,mouse_x:D,mouse_y:I},true);$.each(D,function(P,U){if(U){u=U.keep||u;k=U.element;La=U.started||La}});if(!u&&k!=null){B().releaseId(ca());k.parentNode.removeChild(k);k=null;for(D=v.target;D.parentNode.parentNode.tagName=="g";)D=D.parentNode;if((Ea!="path"||!drawn_path)&&D.parentNode.id!="selectorParentGroup"&&D.id!="svgcanvas"&&D.id!="svgroot"){b.setMode("select");Bb([D],true)}}else if(k!=null){b.addedNew=
true;v=0.2;var C;if(false.beginElement&&k.getAttribute("opacity")!=M.opacity){C=$(false).clone().attr({to:M.opacity,dur:v}).appendTo(k);try{C[0].beginElement()}catch(E){}}else v=0;setTimeout(function(){C&&C.remove();k.setAttribute("opacity",M.opacity);k.setAttribute("style","pointer-events:inherit");na(k);if(Ea==="path")Ja.toEditMode(k);else n.selectNew&&Bb([k],true);ya(new Ca(k));N("changed",[k])},v*1E3)}Ua=null}}});$(a).bind("mousewheel DOMMouseScroll",function(v){if(v.shiftKey){v.preventDefault();
rb=l.getScreenCTM().inverse();var F=O(v.pageX,v.pageY,rb);F={x:F.x,y:F.y,width:0,height:0};if(v.wheelDelta)if(v.wheelDelta>=120)F.factor=2;else{if(v.wheelDelta<=-120)F.factor=0.5}else if(v.detail)if(v.detail>0)F.factor=0.5;else if(v.detail<0)F.factor=2;F.factor&&N("zoomed",F)}})})();var pb=function(e){$(e).click(function(h){h.preventDefault()})},hb=b.textActions=function(){function e(S){var X=I.value==="";$(I).focus();if(!arguments.length)if(X)S=0;else{if(I.selectionEnd!==I.selectionStart)return;
S=I.selectionEnd}var aa;aa=k[S];X||I.setSelectionRange(S,S);D=qa("text_cursor");if(!D){D=document.createElementNS(c,"line");ma(D,{id:"text_cursor",stroke:"#333","stroke-width":1});D=qa("selectorParentGroup").appendChild(D)}L||(L=setInterval(function(){var ga=D.getAttribute("display")==="none";D.setAttribute("display",ga?"inline":"none")},600));X=H(aa.x,u.y);aa=H(aa.x,u.y+u.height);ma(D,{x1:X.x,y1:X.y,x2:aa.x,y2:aa.y,visibility:"visible",display:"inline"});G&&G.setAttribute("d","")}function h(S,X,
aa){if(S===X)e(X);else{aa||I.setSelectionRange(S,X);G=qa("text_selectblock");if(!G){G=document.createElementNS(c,"path");ma(G,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});qa("selectorParentGroup").appendChild(G)}S=k[S];var ga=k[X];D.setAttribute("visibility","hidden");X=H(S.x,u.y);aa=H(S.x+(ga.x-S.x),u.y);var ra=H(S.x,u.y+u.height);S=H(S.x+(ga.x-S.x),u.y+u.height);ma(G,{d:"M"+X.x+","+X.y+" L"+aa.x+","+aa.y+" "+S.x+","+S.y+" "+ra.x+","+ra.y+"z",display:"inline"})}}
function m(S,X){var aa=d.createSVGPoint();aa.x=S;aa.y=X;if(k.length==1)return 0;aa=F.getCharNumAtPosition(aa);if(aa<0){aa=k.length-2;if(S<=k[0].x)aa=0}else if(aa>=k.length-2)aa=k.length-2;var ga=k[aa];S>ga.x+ga.width/2&&aa++;return aa}function z(S,X,aa){var ga=I.selectionStart;S=m(S,X);h(Math.min(ga,S),Math.max(ga,S),!aa)}function w(S,X){var aa={x:S,y:X};aa.x/=o;aa.y/=o;if(C){var ga=O(aa.x,aa.y,C.inverse());aa.x=ga.x;aa.y=ga.y}return aa}function H(S,X){var aa={x:S,y:X};if(C){var ga=O(aa.x,aa.y,C);
aa.x=ga.x;aa.y=ga.y}aa.x*=o;aa.y*=o;return aa}function A(S){h(0,F.textContent.length);$(this).unbind(S)}function v(S){if(U&&F){var X=O(S.pageX,S.pageY,rb);X=w(X.x*o,X.y*o);X=m(X.x,X.y);var aa=F.textContent,ga=aa.substr(0,X).replace(/[a-z0-9]+$/i,"").length;aa=aa.substr(X).match(/^[a-z0-9]+/i);h(ga,(aa?aa[0].length:0)+X);$(S.target).click(A);setTimeout(function(){$(S.target).unbind("click",A)},300)}}var F,I,D,G,L,k=[],u,C,E,P,U;return{select:function(S,X,aa){F=S;hb.toEditMode(X,aa)},start:function(S){F=
S;hb.toEditMode()},mouseDown:function(S,X,aa,ga){S=w(aa,ga);I.focus();e(m(S.x,S.y));E=aa;P=ga},mouseMove:function(S,X){var aa=w(S,X);z(aa.x,aa.y)},mouseUp:function(S,X,aa){var ga=w(X,aa);z(ga.x,ga.y,true);S.target!==F&&X<E+2&&X>E-2&&aa<P+2&&aa>P-2&&hb.toSelectMode(true)},setCursor:e,toEditMode:function(S,X){U=false;Ea="textedit";Ha.requestSelector(F).showGrips(false);Ha.requestSelector(F);hb.init();$(F).css("cursor","text");if(arguments.length){var aa=w(S,X);e(m(aa.x,aa.y))}else e();setTimeout(function(){U=
true},300)},toSelectMode:function(S){Ea="select";clearInterval(L);L=null;G&&$(G).attr("display","none");D&&$(D).attr("visibility","hidden");$(F).css("cursor","move");if(S){Pa();$(F).css("cursor","move");N("selected",[F]);vb([F],true)}F&&!F.textContent.length&&b.deleteSelectedElements();$(I).blur();F=false},setInputElem:function(S){I=S},clear:function(){Ea=="textedit"&&hb.toSelectMode()},init:function(){if(F){if(!F.parentNode){F=J[0];Ha.requestSelector(F).showGrips(false)}var S=F.textContent.length,
X=F.getAttribute("transform");u=svgedit.utilities.getBBox(F);C=X?W(F):null;k=Array(S);I.focus();$(F).unbind("dblclick",v).dblclick(v);if(!S)var aa={x:u.x+u.width/2,width:0};for(X=0;X<S;X++){var ga=F.getStartPositionOfChar(X);aa=F.getEndPositionOfChar(X);if(!svgedit.browser.supportsGoodTextCharPos()){var ra=b.contentW*o;ga.x-=ra;aa.x-=ra;ga.x/=o;aa.x/=o}k[X]={x:ga.x,y:u.y,width:aa.x-ga.x,height:u.height}}k.push({x:aa.x,width:0});h(I.selectionStart,I.selectionEnd,true)}}}}(),Ja=b.pathActions=function(){var e=
false,h,m,z;svgedit.path.Path.prototype.endChanges=function(A){if(svgedit.browser.isWebkit()){var v=this.elem;v.setAttribute("d",Ja.convertPath(v))}A=new Na(this.elem,{d:this.last_d},A);ya(A);N("changed",[this.elem])};svgedit.path.Path.prototype.addPtsToSelection=function(A){$.isArray(A)||(A=[A]);for(var v=0;v<A.length;v++){var F=A[v],I=this.segs[F];I.ptgrip&&this.selected_pts.indexOf(F)==-1&&F>=0&&this.selected_pts.push(F)}this.selected_pts.sort();v=this.selected_pts.length;for(A=Array(v);v--;){I=
this.segs[this.selected_pts[v]];I.select(true);A[v]=I.ptgrip}Ja.canDeleteNodes=true;Ja.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);N("selected",A)};var w=h=null,H=false;return{mouseDown:function(A,v,F,I){if(Ea==="path"){mouse_x=F;mouse_y=I;I=mouse_x/o;v=mouse_y/o;F=qa("path_stretch_line");m=[I,v];if(n.gridSnapping){I=wa(I);v=wa(v);mouse_x=wa(mouse_x);mouse_y=wa(mouse_y)}if(!F){F=document.createElementNS(c,"path");ma(F,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});
F=qa("selectorParentGroup").appendChild(F)}F.setAttribute("display","inline");var D=null;if(w){D=w.pathSegList;for(var G=D.numberOfItems,L=6/o,k=false;G;){G--;var u=D.getItem(G),C=u.x;u=u.y;if(I>=C-L&&I<=C+L&&v>=u-L&&v<=u+L){k=true;break}}L=ca();svgedit.path.removePath_(L);L=qa(L);C=D.numberOfItems;if(k){if(G<=1&&C>=2){I=D.getItem(0).x;v=D.getItem(0).y;A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(I,v):w.createSVGPathSegCurvetoCubicAbs(I,v,A.x1/o,A.y1/o,I,v);I=w.createSVGPathSegClosePath();
D.appendItem(A);D.appendItem(I)}else if(C<3)return D=false;$(F).remove();element=L;w=null;La=false;if(e){svgedit.path.path.matrix&&db(L,{},svgedit.path.path.matrix.inverse());F=L.getAttribute("d");A=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",A+F);$(L).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();Ja.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,Ib(A))){console.log("Clicked outside canvas");
return false}D=w.pathSegList.numberOfItems;G=w.pathSegList.getItem(D-1);L=G.x;G=G.y;if(A.shiftKey){A=ba(L,G,I,v);I=A.x;v=A.y}A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(eb(I),eb(v)):w.createSVGPathSegCurvetoCubicAbs(eb(I),eb(v),A.x1/o,A.y1/o,A.x2/o,A.y2/o);w.pathSegList.appendItem(A);I*=o;v*=o;F.setAttribute("d",["M",I,v,I,v].join(" "));F=D;if(e)F+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(F,I,v)}}else{d_attr="M"+I+","+v+" ";w=Q({element:"path",curStyles:true,
attr:{d:d_attr,id:ja(),opacity:M.opacity/2}});F.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));F=e?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(F,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();L=A.target.id;if(L.substr(0,14)=="pathpointgrip_"){v=svgedit.path.path.cur_pt=parseInt(L.substr(14));svgedit.path.path.dragging=[F,I];D=svgedit.path.path.segs[v];if(A.shiftKey)D.selected?svgedit.path.path.removePtFromSelection(v):svgedit.path.path.addPtsToSelection(v);
else{if(svgedit.path.path.selected_pts.length<=1||!D.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(v)}}else if(L.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[F,I];A=L.split("_")[1].split("c");v=A[0]-0;svgedit.path.path.selectPt(v,A[1]-0)}if(!svgedit.path.path.dragging){if(ta==null)ta=Ha.getRubberBandBox();ma(ta,{x:F*o,y:I*o,width:0,height:0,display:"inline"},100)}}},mouseMove:function(A,v,F){H=true;if(Ea==="path"){if(w){var I=w.pathSegList;A=I.numberOfItems-
1;if(m){var D=svgedit.path.addCtrlGrip("1c1"),G=svgedit.path.addCtrlGrip("0c2");G.getAttribute("cx");G.getAttribute("cy");D.setAttribute("cx",v);D.setAttribute("cy",F);D.setAttribute("display","inline");D=m[0];var L=m[1];I.getItem(A);var k=D+(D-v/o),u=L+(L-F/o);G.setAttribute("cx",k*o);G.setAttribute("cy",u*o);G.setAttribute("display","inline");G=svgedit.path.getCtrlLine(1);var C=svgedit.path.getCtrlLine(2);ma(G,{x1:v,y1:F,x2:D*o,y2:L*o,display:"inline"});ma(C,{x1:k*o,y1:u*o,x2:D*o,y2:L*o,display:"inline"});
if(A===0)z=[v,F];else{I=I.getItem(A-1);v=I.x;F=I.y;if(I.pathSegType===6){v+=v-I.x2;F+=F-I.y2}else if(z){v=z[0]/o;F=z[1]/o}svgedit.path.replacePathSeg(6,A,[D,L,v,F,k,u],w)}}else if(D=qa("path_stretch_line")){A=I.getItem(A);if(A.pathSegType===6)svgedit.path.replacePathSeg(6,1,[v,F,(A.x+(A.x-A.x2))*o,(A.y+(A.y-A.y2))*o,v,F],D);else z?svgedit.path.replacePathSeg(6,1,[v,F,z[0],z[1],v,F],D):svgedit.path.replacePathSeg(4,1,[v,F],D)}}}else if(svgedit.path.path.dragging){D=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],
y:svgedit.path.path.dragging[1]},svgedit.path.path);L=svgedit.path.getPointFromGrip({x:v,y:F},svgedit.path.path);A=L.x-D.x;D=L.y-D.y;svgedit.path.path.dragging=[v,F];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(A,D):svgedit.path.path.movePts(A,D)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var E=ta.getBBox(),P=svgedit.path.getGripPt(this);E=svgedit.math.rectsIntersect(E,{x:P.x,y:P.y,width:0,height:0});this.select(E);E&&svgedit.path.path.selected_pts.push(this.index)}})}},
mouseUp:function(A,v){if(Ea==="path"){m=null;if(!w){v=qa(ca());La=false;z=null}return{keep:true,element:v}}if(svgedit.path.path.dragging){var F=svgedit.path.path.cur_pt;svgedit.path.path.dragging=false;svgedit.path.path.dragctrl=false;svgedit.path.path.update();H&&svgedit.path.path.endChanges("Move path point(s)");!A.shiftKey&&!H&&svgedit.path.path.selectPt(F)}else if(ta&&ta.getAttribute("display")!="none"){ta.setAttribute("display","none");ta.getAttribute("width")<=2&&ta.getAttribute("height")<=
2&&Ja.toSelectMode(A.target)}else Ja.toSelectMode(A.target);H=false},toEditMode:function(A){svgedit.path.path=svgedit.path.getPath_(A);Ea="pathedit";Pa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);e=false},toSelectMode:function(A){var v=A==svgedit.path.path.elem;Ea="select";svgedit.path.path.show(false);h=false;Pa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(v){N("selected",[A]);vb([A],true)}},addSubPath:function(A){if(A){Ea=
"path";e=true}else{Ja.clear(true);Ja.toEditMode(svgedit.path.path.elem)}},select:function(A){if(h===A){Ja.toEditMode(A);Ea="pathedit"}else h=A},reorient:function(){var A=J[0];if(A)if(oa(A)!=0){var v=new za("Reorient path"),F={d:A.getAttribute("d"),transform:A.getAttribute("transform")};v.addSubCommand(new Na(A,F));Pa();this.resetOrientation(A);ya(v);svgedit.path.getPath_(A).show(false).matrix=null;this.clear();vb([A],true);N("changed",J)}},clear:function(){h=null;if(w){var A=qa(ca());$(qa("path_stretch_line")).remove();
$(A).remove();$(qa("pathpointgrip_container")).find("*").attr("display","none");w=z=null;La=false}else Ea=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(A){if(A==null||A.nodeName!="path")return false;var v=Y(A),F=fa(v).matrix;v.clear();A.removeAttribute("transform");v=A.pathSegList;for(var I=v.numberOfItems,D=0;D<I;++D){var G=v.getItem(D),L=G.pathSegType;if(L!=1){var k=[];$.each(["",1,2],function(u,C){var E=G["x"+C],P=G["y"+C];if(E!==
undefined&&P!==undefined){E=O(E,P,F);k.splice(k.length,0,E.x,E.y)}});svgedit.path.replacePathSeg(L,D,k,A)}}g(A,F)},zoomChange:function(){Ea=="pathedit"&&svgedit.path.path.update()},getNodePoint:function(){var A=svgedit.path.path.segs[svgedit.path.path.selected_pts.length?svgedit.path.path.selected_pts[0]:1];return{x:A.item.x,y:A.item.y,type:A.type}},linkControlPoints:function(A){svgedit.path.setLinkControlPoints(A)},clonePathNode:function(){svgedit.path.path.storeD();for(var A=svgedit.path.path.selected_pts,
v=A.length,F=[];v--;){var I=A[v];svgedit.path.path.addSeg(I);F.push(I+v);F.push(I+v+1)}svgedit.path.path.init().addPtsToSelection(F);svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var A=svgedit.path.path.selected_pts;if(A.length===1){var v=svgedit.path.path.elem,F=v.pathSegList,I=A[0],D=null,G=null;svgedit.path.path.eachSeg(function(C){if(this.type===2&&C<=I)G=this.item;if(C<=I)return true;if(this.type===2){D=C;return false}else if(this.type===1)return D=false});if(D==
null)D=svgedit.path.path.segs.length-1;if(D!==false){var L=v.createSVGPathSegLinetoAbs(G.x,G.y),k=v.createSVGPathSegClosePath();if(D==svgedit.path.path.segs.length-1){F.appendItem(L);F.appendItem(k)}else{svgedit.path.insertItemBefore(v,k,D);svgedit.path.insertItemBefore(v,L,D)}svgedit.path.path.init().selectPt(D+1)}else if(svgedit.path.path.segs[I].mate){F.removeItem(I);F.removeItem(I);svgedit.path.path.init().selectPt(I-1)}else{for(A=0;A<F.numberOfItems;A++){var u=F.getItem(A);if(u.pathSegType===
2)L=A;else if(A===I)F.removeItem(L);else if(u.pathSegType===1&&I<A){k=A-1;F.removeItem(A);break}}for(A=I-L-1;A--;)svgedit.path.insertItemBefore(v,F.getItem(L),k);v=F.getItem(L);svgedit.path.replacePathSeg(2,L,[v.x,v.y]);A=I;svgedit.path.path.init().selectPt(0)}}},deletePathNode:function(){if(Ja.canDeleteNodes){svgedit.path.path.storeD();for(var A=svgedit.path.path.selected_pts,v=A.length;v--;)svgedit.path.path.deleteSeg(A[v]);var F=function(){var I=svgedit.path.path.elem.pathSegList,D=I.numberOfItems,
G=function(u,C){for(;C--;)I.removeItem(u)};if(D<=1)return true;for(;D--;){var L=I.getItem(D);if(L.pathSegType===1){L=I.getItem(D-1);var k=I.getItem(D-2);if(L.pathSegType===2){G(D-1,2);F();break}else if(k.pathSegType===2){G(D-2,3);F();break}}else if(L.pathSegType===2)if(D>0){L=I.getItem(D-1).pathSegType;if(L===2){G(D-1,1);F();break}else if(L===1&&I.numberOfItems-1===D){G(D,1);F();break}}}return false};F();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){Ja.toSelectMode(svgedit.path.path.elem);
b.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){A=$(svgedit.path.path.elem);A.attr("d",A.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(A){var v=A.points,F=v.numberOfItems;if(F>=4){var I=v.getItem(0),D=null;A=[];A.push(["M",I.x,",",I.y," C"].join(""));for(var G=1;G<=F-4;G+=3){var L=v.getItem(G),k=v.getItem(G+1),u=v.getItem(G+2);if(D)if((I=svgedit.path.smoothControlPoints(D,L,I))&&I.length==
2){L=A[A.length-1].split(",");L[2]=I[0].x;L[3]=I[0].y;A[A.length-1]=L.join(",");L=I[1]}A.push([L.x,L.y,k.x,k.y,u.x,u.y].join(","));I=u;D=k}for(A.push("L");G<F;++G){k=v.getItem(G);A.push([k.x,k.y].join(","))}A=A.join(" ");A=Q({element:"path",curStyles:true,attr:{id:ca(),d:A,fill:"none"}})}return A},setSegType:function(A){svgedit.path.path.setSegType(A)},moveNode:function(A,v){var F=svgedit.path.path.selected_pts;if(F.length){svgedit.path.path.storeD();F=svgedit.path.path.segs[F[0]];var I={x:0,y:0};
I[A]=v-F.item[A];F.move(I.x,I.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(A){for(var v=A.pathSegList,F=v.numberOfItems,I,D=0;D<F;++D){var G=v.getItem(D);if(G.pathSegType===2)I=G;if(G.pathSegType===1){G=v.getItem(D-1);if(G.x!=I.x||G.y!=I.y){v=A.createSVGPathSegLinetoAbs(I.x,I.y);svgedit.path.insertItemBefore(A,v,D);Ja.fixEnd(A);break}}}svgedit.browser.isWebkit()&&A.setAttribute("d",Ja.convertPath(A))},convertPath:function(A,v){for(var F=A.pathSegList,I=F.numberOfItems,D=0,
G=0,L="",k=null,u=0;u<I;++u){var C=F.getItem(u),E=C.x||0,P=C.y||0,U=C.x1||0,S=C.y1||0,X=C.x2||0,aa=C.y2||0,ga=C.pathSegType,ra=Oa[ga]["to"+(v?"Lower":"Upper")+"Case"](),Ta=function(Ba,ha,Sa){ha=ha?" "+ha.join(" "):"";Sa=Sa?" "+svgedit.units.shortFloat(Sa):"";$.each(Ba,function(Qa,ua){Ba[Qa]=svgedit.units.shortFloat(ua)});L+=ra+Ba.join(" ")+ha+Sa};switch(ga){case 1:L+="z";break;case 12:E-=D;case 13:if(v){D+=E;ra="l"}else{E+=D;D=E;ra="L"}Ta([[E,G]]);break;case 14:P-=G;case 15:if(v){G+=P;ra="l"}else{P+=
G;G=P;ra="L"}Ta([[D,P]]);break;case 2:case 4:case 18:E-=D;P-=G;case 5:case 3:if(k&&F.getItem(u-1).pathSegType===1&&!v){D=k[0];G=k[1]}case 19:if(v){D+=E;G+=P}else{E+=D;P+=G;D=E;G=P}if(ga===3)k=[D,G];Ta([[E,P]]);break;case 6:E-=D;U-=D;X-=D;P-=G;S-=G;aa-=G;case 7:if(v){D+=E;G+=P}else{E+=D;U+=D;X+=D;P+=G;S+=G;aa+=G;D=E;G=P}Ta([[U,S],[X,aa],[E,P]]);break;case 8:E-=D;U-=D;P-=G;S-=G;case 9:if(v){D+=E;G+=P}else{E+=D;U+=D;P+=G;S+=G;D=E;G=P}Ta([[U,S],[E,P]]);break;case 10:E-=D;P-=G;case 11:if(v){D+=E;G+=P}else{E+=
D;P+=G;D=E;G=P}Ta([[C.r1,C.r2]],[C.angle,C.largeArcFlag?1:0,C.sweepFlag?1:0],[E,P]);break;case 16:E-=D;X-=D;P-=G;aa-=G;case 17:if(v){D+=E;G+=P}else{E+=D;X+=D;P+=G;aa+=G;D=E;G=P}Ta([[X,aa],[E,P]])}}return L}}}(),Kb=this.removeUnusedDefElems=function(){var e=l.getElementsByTagNameNS(c,"defs");if(!e||!e.length)return 0;for(var h=[],m=0,z=["fill","stroke","filter","marker-start","marker-mid","marker-end"],w=z.length,H=l.getElementsByTagNameNS(c,"*"),A=H.length,v=0;v<A;v++){for(var F=H[v],I=0;I<w;I++){var D=
ka(F.getAttribute(z[I]));D&&h.push(D.substr(1))}(F=da(F))&&F.indexOf("#")===0&&h.push(F.substr(1))}e=$(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(v=e.length;v--;){z=e[v];w=z.id;if(h.indexOf(w)<0){zb[w]=z;z.parentNode.removeChild(z);m++}}return m};this.svgCanvasToString=function(){for(;Kb()>0;);Ja.clear(true);$.each(l.childNodes,function(m,z){m&&z.nodeType===8&&z.data.indexOf("Created with")>=0&&l.insertBefore(z,l.firstChild)});if(K){Jb();Bb([K])}var e=
[];$(l).find("g:data(gsvg)").each(function(){for(var m=this.attributes,z=m.length,w=0;w<z;w++)if(m[w].nodeName=="id"||m[w].nodeName=="style")z--;if(z<=0){m=this.firstChild;e.push(m);$(this).replaceWith(m)}});var h=this.svgToString(l,0);e.length&&$(e).each(function(){Ab(this)});return h};this.svgToString=function(e,h){var m=[],z=svgedit.utilities.toXml,w=n.baseUnit,H=RegExp("^-?[\\d\\.]+"+w+"$");if(e){na(e);var A=e.attributes,v,F,I=e.childNodes;for(F=0;F<h;F++)m.push(" ");m.push("<");m.push(e.nodeName);
if(e.id==="svgcontent"){F=Eb();if(w!=="px"){F.w=svgedit.units.convertUnit(F.w,w)+w;F.h=svgedit.units.convertUnit(F.h,w)+w}m.push(' width="'+F.w+'" height="'+F.h+'" xmlns="'+c+'"');var D={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(u,C){var E=C.namespaceURI;if(E&&!D[E]&&Aa[E]!=="xmlns"&&Aa[E]!=="xml"){D[E]=true;m.push(" xmlns:"+Aa[E]+'="'+E+'"')}})});F=A.length;for(w=["width","height","xmlns","x","y","viewBox","id","overflow"];F--;){v=A.item(F);var G=z(v.nodeValue);if(v.nodeName.indexOf("xmlns:")!==
rb),E=I.x*o;I=I.y*o;var G=qa(ca()),L=x=E/o,k=y=I/o;if(n.gridSnapping){x=wa(x);y=wa(y)}v.preventDefault();switch(Ea){case "select":if(J[0]!==null){L=x-h;var u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u)}if(v.shiftKey){var C=ba(h,m,x,y);x=C.x;y=C.y}if(L!=0||u!=0){C=J.length;for(k=0;k<C;++k){F=J[k];if(F==null)break;var D=d.createSVGTransform();G=X(F);D.setTranslate(L,u);G.numberOfItems?G.replaceItem(D,0):G.appendItem(D);Ha.requestSelector(F).resize()}if(v.altKey)if(!b.addClones){b.addClones=b.cloneSelectedElements(0,
0,D);b.removeClones=function(){b.addClones&&b.addClones.forEach(function(Oa){Oa.parentNode&&Oa.parentNode.removeChild(Oa);b.addClones=false})};window.addEventListener("keyup",b.removeClones)}N("transition",J)}}break;case "multiselect":L*=o;k*=o;ma(ua,{x:Math.min(z,L),y:Math.min(w,k),width:Math.abs(L-z),height:Math.abs(k-w)},100);G=[];L=[];D=tb();C=J.length;for(k=0;k<C;++k){u=D.indexOf(J[k]);if(u==-1)G.push(J[k]);else D[u]=null}C=D.length;for(k=0;k<C;++k)D[k]&&L.push(D[k]);G.length>0&&b.removeFromSelection(G);
L.length>0&&vb(L);break;case "resize":G=X(F);L=(D=pa(G))?H:svgedit.utilities.getBBox(F);C=L.x;k=L.y;var P=L.width,U=L.height;L=x-h;u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u);U=wa(U);P=wa(P)}var S=oa(F);if(S){var Y=Math.sqrt(L*L+u*u);u=Math.atan2(u,L)-S*Math.PI/180;L=Y*Math.cos(u);u=Y*Math.sin(u)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)u=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)L=0;var aa=Y=0,ga=U?(U+u)/U:1,ra=P?(P+L)/P:1;if(kb.indexOf("n")>=0){ga=U?(U-u)/U:1;aa=U}if(kb.indexOf("w")>=0){ra=
P?(P-L)/P:1;Y=P}L=d.createSVGTransform();u=d.createSVGTransform();P=d.createSVGTransform();if(n.gridSnapping){C=wa(C);Y=wa(Y);k=wa(k);aa=wa(aa)}L.setTranslate(-(C+Y),-(k+aa));if(v.shiftKey)if(ra==1)ra=ga;else ga=ra;u.setScale(ra,ga);P.setTranslate(C+Y,k+aa);if(D){D=S?1:0;G.replaceItem(L,2+D);G.replaceItem(u,1+D);G.replaceItem(P,0+D)}else{D=G.numberOfItems;G.replaceItem(P,D-3);G.replaceItem(u,D-2);G.replaceItem(L,D-1)}Ha.requestSelector(F).resize();N("transition",J);break;case "zoom":L*=o;k*=o;ma(ua,
{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100);break;case "text":ma(G,{x:x,y:y},1E3);break;case "line":L=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=wa(x);y=wa(y)}D=x;C=y;if(v.shiftKey){C=ba(h,m,D,C);D=C.x;C=C.y}G.setAttributeNS(null,"x2",D);G.setAttributeNS(null,"y2",C);window.opera||d.unsuspendRedraw(L);break;case "foreignObject":case "square":case "rect":case "image":L=Math.abs(x-h);D=Math.abs(y-m);if(Ea=="square"||v.shiftKey){L=D=Math.max(L,
D);C=h<x?h:h-L;k=m<y?m:m-D}else{C=Math.min(h,x);k=Math.min(m,y)}if(v.altKey){L*=2;D*=2;C=h-L/2;k=m-D/2}if(n.gridSnapping){L=wa(L);D=wa(D);C=wa(C);k=wa(k)}ma(G,{width:L,height:D,x:C,y:k},1E3);break;case "circle":L=$(G).attr(["cx","cy"]);D=L.cx;C=L.cy;L=Math.sqrt((x-D)*(x-D)+(y-C)*(y-C));if(n.gridSnapping)L=wa(L);G.setAttributeNS(null,"r",L);break;case "ellipse":L=$(G).attr(["cx","cy"]);D=Math.abs(h+(x-h)/2);C=Math.abs(m+(y-m)/2);L=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=wa(x);
D=wa(D);y=wa(y);C=wa(C)}k=Math.abs(h-D);u=Math.abs(m-C);if(v.shiftKey){u=k;C=y>m?m+k:m-k}if(v.altKey){D=h;C=m;k=Math.abs(x-D);u=v.shiftKey?k:Math.abs(y-C)}G.setAttributeNS(null,"rx",k);G.setAttributeNS(null,"ry",u);G.setAttributeNS(null,"cx",D);G.setAttributeNS(null,"cy",C);window.opera||d.unsuspendRedraw(L);break;case "fhellipse":case "fhrect":A.minx=Math.min(L,A.minx);A.maxx=Math.max(L,A.maxx);A.miny=Math.min(k,A.miny);A.maxy=Math.max(k,A.maxy);case "fhpath":e+=+L+","+k+" ";G.setAttributeNS(null,
"points",e);break;case "path":case "pathedit":x*=o;y*=o;if(n.gridSnapping){x=wa(x);y=wa(y);h=wa(h);m=wa(m)}if(v.shiftKey){if(D=svgedit.path.path){G=D.dragging?D.dragging[0]:h;D=D.dragging?D.dragging[1]:m}else{G=h;D=m}C=ba(G,D,x,y);x=C.x;y=C.y}if(ua&&ua.getAttribute("display")!=="none"){L*=o;k*=o;ma(ua,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100)}Ja.mouseMove(v,x,y);break;case "textedit":x*=o;y*=o;hb.mouseMove(E,I);break;case "rotate":L=svgedit.utilities.getBBox(F);
D=L.x+L.width/2;C=L.y+L.height/2;G=W(F);G=O(D,C,G);D=G.x;C=G.y;G=L.x;k=L.y;if(current_rotate_mode=="nw")G=L.x+L.width;if(current_rotate_mode=="se")k=L.y+L.height;if(current_rotate_mode=="sw"){G=L.x+L.width;k=L.y+L.height}compensation_angle=(Math.atan2(C-k,D-G)*(180/Math.PI)-90)%360;S=(Math.atan2(C-y,D-x)*(180/Math.PI)-90)%360;S+=compensation_angle;if(n.gridSnapping)S=wa(S);if(v.shiftKey)S=Math.round(S/45)*45;b.setRotationAngle(S<-180?360+S:S,true);N("transition",J)}ob("mouseMove",{event:v,mouse_x:E,
mouse_y:I,selected:F})}}).click(function(v){v.preventDefault();return false}).dblclick(function(v){var F=v.target.parentNode;if(F!==K){var I=Ib(v),E=I.tagName;if(E==="text"&&Ea!=="textedit"){v=O(v.pageX,v.pageY,rb);hb.select(I,v.x,v.y)}if((E==="g"||E==="a")&&oa(I)){Mb(I);I=J[0];Qa(true)}K&&Jb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||I===Ha.selectorParentGroup||Rb(I)}}).mouseup(function(v){b.addClones=false;window.removeEventListener("keyup",b.removeClones);if(v.button!==2){var F=
Cb;Cb=null;if(La){var I=O(v.pageX,v.pageY,rb),E=I.x*o;I=I.y*o;var G=E/o,L=I/o,k=qa(ca()),u=false;La=false;switch(Ea){case "resize":case "multiselect":if(ua!=null){ua.setAttribute("display","none");mb=[]}Ea="select";case "select":if(J[0]!=null){if(J[1]==null){E=J[0];switch(E.tagName){case "g":case "use":case "image":case "foreignObject":break;default:bb.fill=E.getAttribute("fill");bb.fill_opacity=E.getAttribute("fill-opacity");bb.stroke=E.getAttribute("stroke");bb.stroke_opacity=E.getAttribute("stroke-opacity");
bb.stroke_width=E.getAttribute("stroke-width");bb.stroke_dasharray=E.getAttribute("stroke-dasharray");bb.stroke_linejoin=E.getAttribute("stroke-linejoin");bb.stroke_linecap=E.getAttribute("stroke-linecap")}if(E.tagName=="text"){Za.font_size=E.getAttribute("font-size");Za.font_family=E.getAttribute("font-family")}Ha.requestSelector(E).showGrips(true)}Ga();if(G!=z||L!=w){v=J.length;for(E=0;E<v;++E){if(J[E]==null)break;J[E].firstChild||Ha.requestSelector(J[E]).resize()}}else{E=v.target;if(J[0].nodeName===
"path"&&J[1]==null)Ja.select(J[0]);else v.shiftKey&&F!=E&&b.removeFromSelection([E])}if(svgedit.browser.supportsNonScalingStroke())if(v=J[0]){v.removeAttribute("style");svgedit.utilities.walkTree(v,function(P){P.removeAttribute("style")})}}return;case "zoom":ua!=null&&ua.setAttribute("display","none");N("zoomed",{x:Math.min(z,G),y:Math.min(w,L),width:Math.abs(G-z),height:Math.abs(L-w),factor:v.altKey?0.5:2});return;case "fhpath":F=k.getAttribute("points");G=F.indexOf(",");if(u=G>=0?F.indexOf(",",
G+1)>=0:F.indexOf(" ",F.indexOf(" ")+1)>=0)k=Ja.smoothPolylineIntoPath(k);break;case "line":F=$(k).attr(["x1","x2","y1","y2"]);u=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(k).attr(["width","height"]);u=F.width!=0||F.height!=0||Ea==="image";break;case "circle":u=k.getAttribute("r")!=0;break;case "ellipse":F=$(k).attr(["rx","ry"]);u=F.rx!=null||F.ry!=null;break;case "fhellipse":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=Q({element:"ellipse",curStyles:true,
attr:{cx:(A.minx+A.maxx)/2,cy:(A.miny+A.maxy)/2,rx:(A.maxx-A.minx)/2,ry:(A.maxy-A.miny)/2,id:ca()}});N("changed",[k]);u=true}break;case "fhrect":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=Q({element:"rect",curStyles:true,attr:{x:A.minx,y:A.miny,width:A.maxx-A.minx,height:A.maxy-A.miny,id:ca()}});N("changed",[k]);u=true}break;case "text":u=true;xb([k]);hb.start(k);break;case "path":k=null;La=true;F=Ja.mouseUp(v,k,E,I);k=F.element;u=F.keep;break;case "pathedit":u=true;k=null;Ja.mouseUp(v);break;case "textedit":u=
false;k=null;hb.mouseUp(v,E,I);break;case "rotate":u=true;k=null;Ea="select";F=b.undoMgr.finishUndoableChange();F.isEmpty()||ya(F);Ga();N("changed",J)}E=ob("mouseUp",{event:v,mouse_x:E,mouse_y:I},true);$.each(E,function(P,U){if(U){u=U.keep||u;k=U.element;La=U.started||La}});if(!u&&k!=null){B().releaseId(ca());k.parentNode.removeChild(k);k=null;for(E=v.target;E.parentNode.parentNode.tagName=="g";)E=E.parentNode;if((Ea!="path"||!drawn_path)&&E.parentNode.id!="selectorParentGroup"&&E.id!="svgcanvas"&&
E.id!="svgroot"){b.setMode("select");xb([E],true)}}else if(k!=null){b.addedNew=true;v=0.2;var C;if(false.beginElement&&k.getAttribute("opacity")!=M.opacity){C=$(false).clone().attr({to:M.opacity,dur:v}).appendTo(k);try{C[0].beginElement()}catch(D){}}else v=0;setTimeout(function(){C&&C.remove();k.setAttribute("opacity",M.opacity);k.setAttribute("style","pointer-events:inherit");na(k);if(Ea==="path")Ja.toEditMode(k);else n.selectNew&&xb([k],true);ya(new Ca(k));N("changed",[k])},v*1E3)}Va=null}}});$(a).bind("mousewheel DOMMouseScroll",
function(v){if(v.shiftKey){v.preventDefault();rb=l.getScreenCTM().inverse();var F=O(v.pageX,v.pageY,rb);F={x:F.x,y:F.y,width:0,height:0};if(v.wheelDelta)if(v.wheelDelta>=120)F.factor=2;else{if(v.wheelDelta<=-120)F.factor=0.5}else if(v.detail)if(v.detail>0)F.factor=0.5;else if(v.detail<0)F.factor=2;F.factor&&N("zoomed",F)}})})();var pb=function(e){$(e).click(function(h){h.preventDefault()})},hb=b.textActions=function(){function e(S){var Y=I.value==="";$(I).focus();if(!arguments.length)if(Y)S=0;else{if(I.selectionEnd!==
I.selectionStart)return;S=I.selectionEnd}var aa;aa=k[S];Y||I.setSelectionRange(S,S);E=qa("text_cursor");if(!E){E=document.createElementNS(c,"line");ma(E,{id:"text_cursor",stroke:"#333","stroke-width":1});E=qa("selectorParentGroup").appendChild(E)}L||(L=setInterval(function(){var ga=E.getAttribute("display")==="none";E.setAttribute("display",ga?"inline":"none")},600));Y=H(aa.x,u.y);aa=H(aa.x,u.y+u.height);ma(E,{x1:Y.x,y1:Y.y,x2:aa.x,y2:aa.y,visibility:"visible",display:"inline"});G&&G.setAttribute("d",
"")}function h(S,Y,aa){if(S===Y)e(Y);else{aa||I.setSelectionRange(S,Y);G=qa("text_selectblock");if(!G){G=document.createElementNS(c,"path");ma(G,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});qa("selectorParentGroup").appendChild(G)}S=k[S];var ga=k[Y];E.setAttribute("visibility","hidden");Y=H(S.x,u.y);aa=H(S.x+(ga.x-S.x),u.y);var ra=H(S.x,u.y+u.height);S=H(S.x+(ga.x-S.x),u.y+u.height);ma(G,{d:"M"+Y.x+","+Y.y+" L"+aa.x+","+aa.y+" "+S.x+","+S.y+" "+ra.x+","+ra.y+"z",display:"inline"})}}
function m(S,Y){var aa=d.createSVGPoint();aa.x=S;aa.y=Y;if(k.length==1)return 0;aa=F.getCharNumAtPosition(aa);if(aa<0){aa=k.length-2;if(S<=k[0].x)aa=0}else if(aa>=k.length-2)aa=k.length-2;var ga=k[aa];S>ga.x+ga.width/2&&aa++;return aa}function z(S,Y,aa){var ga=I.selectionStart;S=m(S,Y);h(Math.min(ga,S),Math.max(ga,S),!aa)}function w(S,Y){var aa={x:S,y:Y};aa.x/=o;aa.y/=o;if(C){var ga=O(aa.x,aa.y,C.inverse());aa.x=ga.x;aa.y=ga.y}return aa}function H(S,Y){var aa={x:S,y:Y};if(C){var ga=O(aa.x,aa.y,C);
aa.x=ga.x;aa.y=ga.y}aa.x*=o;aa.y*=o;return aa}function A(S){h(0,F.textContent.length);$(this).unbind(S)}function v(S){if(U&&F){var Y=O(S.pageX,S.pageY,rb);Y=w(Y.x*o,Y.y*o);Y=m(Y.x,Y.y);var aa=F.textContent,ga=aa.substr(0,Y).replace(/[a-z0-9]+$/i,"").length;aa=aa.substr(Y).match(/^[a-z0-9]+/i);h(ga,(aa?aa[0].length:0)+Y);$(S.target).click(A);setTimeout(function(){$(S.target).unbind("click",A)},300)}}var F,I,E,G,L,k=[],u,C,D,P,U;return{select:function(S,Y,aa){F=S;hb.toEditMode(Y,aa)},start:function(S){F=
S;hb.toEditMode()},mouseDown:function(S,Y,aa,ga){S=w(aa,ga);I.focus();e(m(S.x,S.y));D=aa;P=ga},mouseMove:function(S,Y){var aa=w(S,Y);z(aa.x,aa.y)},mouseUp:function(S,Y,aa){var ga=w(Y,aa);z(ga.x,ga.y,true);S.target!==F&&Y<D+2&&Y>D-2&&aa<P+2&&aa>P-2&&hb.toSelectMode(true)},setCursor:e,toEditMode:function(S,Y){xb([F],false);U=false;Ea="textedit";Ha.requestSelector(F);hb.init();$(F).css("cursor","text");if(arguments.length){var aa=w(S,Y);e(m(aa.x,aa.y))}else e();setTimeout(function(){U=true},300)},toSelectMode:function(S){Ea=
"select";clearInterval(L);L=null;G&&$(G).attr("display","none");E&&$(E).attr("visibility","hidden");$(F).css("cursor","move");if(S){Qa();$(F).css("cursor","move");N("selected",[F]);vb([F],true)}F&&!F.textContent.length&&b.deleteSelectedElements();$(I).blur();F=false},setInputElem:function(S){I=S},clear:function(){Ea=="textedit"&&hb.toSelectMode()},init:function(){if(F){if(!F.parentNode){F=J[0];Ha.requestSelector(F).showGrips(false)}var S=F.textContent.length,Y=F.getAttribute("transform");u=svgedit.utilities.getBBox(F);
C=Y?W(F):null;k=Array(S);I.focus();$(F).unbind("dblclick",v).dblclick(v);if(!S)var aa={x:u.x+u.width/2,width:0};for(Y=0;Y<S;Y++){var ga=F.getStartPositionOfChar(Y);aa=F.getEndPositionOfChar(Y);if(!svgedit.browser.supportsGoodTextCharPos()){var ra=b.contentW*o;ga.x-=ra;aa.x-=ra;ga.x/=o;aa.x/=o}k[Y]={x:ga.x,y:u.y,width:aa.x-ga.x,height:u.height}}k.push({x:aa.x,width:0});h(I.selectionStart,I.selectionEnd,true)}}}}(),Ja=b.pathActions=function(){var e=false,h,m,z;svgedit.path.Path.prototype.endChanges=
function(A){if(svgedit.browser.isWebkit()){var v=this.elem;v.setAttribute("d",Ja.convertPath(v))}A=new Na(this.elem,{d:this.last_d},A);ya(A);N("changed",[this.elem])};svgedit.path.Path.prototype.addPtsToSelection=function(A){$.isArray(A)||(A=[A]);for(var v=0;v<A.length;v++){var F=A[v],I=this.segs[F];I.ptgrip&&this.selected_pts.indexOf(F)==-1&&F>=0&&this.selected_pts.push(F)}this.selected_pts.sort();v=this.selected_pts.length;for(A=Array(v);v--;){I=this.segs[this.selected_pts[v]];I.select(true);A[v]=
I.ptgrip}Ja.canDeleteNodes=true;Ja.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);N("selected",A)};var w=h=null,H=false;return{mouseDown:function(A,v,F,I){if(Ea==="path"){mouse_x=F;mouse_y=I;I=mouse_x/o;v=mouse_y/o;F=qa("path_stretch_line");m=[I,v];if(n.gridSnapping){I=wa(I);v=wa(v);mouse_x=wa(mouse_x);mouse_y=wa(mouse_y)}if(!F){F=document.createElementNS(c,"path");ma(F,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});F=qa("selectorParentGroup").appendChild(F)}F.setAttribute("display",
"inline");var E=null;if(w){E=w.pathSegList;for(var G=E.numberOfItems,L=6/o,k=false;G;){G--;var u=E.getItem(G),C=u.x;u=u.y;if(I>=C-L&&I<=C+L&&v>=u-L&&v<=u+L){k=true;break}}L=ca();svgedit.path.removePath_(L);L=qa(L);C=E.numberOfItems;if(k){if(G<=1&&C>=2){I=E.getItem(0).x;v=E.getItem(0).y;A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(I,v):w.createSVGPathSegCurvetoCubicAbs(I,v,A.x1/o,A.y1/o,I,v);I=w.createSVGPathSegClosePath();E.appendItem(A);E.appendItem(I)}else if(C<3)return E=
false;$(F).remove();element=L;w=null;La=false;if(e){svgedit.path.path.matrix&&db(L,{},svgedit.path.path.matrix.inverse());F=L.getAttribute("d");A=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",A+F);$(L).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();Ja.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,Ib(A))){console.log("Clicked outside canvas");return false}E=w.pathSegList.numberOfItems;
G=w.pathSegList.getItem(E-1);L=G.x;G=G.y;if(A.shiftKey){A=ba(L,G,I,v);I=A.x;v=A.y}A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(eb(I),eb(v)):w.createSVGPathSegCurvetoCubicAbs(eb(I),eb(v),A.x1/o,A.y1/o,A.x2/o,A.y2/o);w.pathSegList.appendItem(A);I*=o;v*=o;F.setAttribute("d",["M",I,v,I,v].join(" "));F=E;if(e)F+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(F,I,v)}}else{d_attr="M"+I+","+v+" ";w=Q({element:"path",curStyles:true,attr:{d:d_attr,id:ja(),opacity:M.opacity/
2}});F.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));F=e?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(F,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();L=A.target.id;if(L.substr(0,14)=="pathpointgrip_"){v=svgedit.path.path.cur_pt=parseInt(L.substr(14));svgedit.path.path.dragging=[F,I];E=svgedit.path.path.segs[v];if(A.shiftKey)E.selected?svgedit.path.path.removePtFromSelection(v):svgedit.path.path.addPtsToSelection(v);else{if(svgedit.path.path.selected_pts.length<=
1||!E.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(v)}}else if(L.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[F,I];A=L.split("_")[1].split("c");v=A[0]-0;svgedit.path.path.selectPt(v,A[1]-0)}if(!svgedit.path.path.dragging){if(ua==null)ua=Ha.getRubberBandBox();ma(ua,{x:F*o,y:I*o,width:0,height:0,display:"inline"},100)}}},mouseMove:function(A,v,F){H=true;if(Ea==="path"){if(w){var I=w.pathSegList;A=I.numberOfItems-1;if(m){var E=svgedit.path.addCtrlGrip("1c1"),
G=svgedit.path.addCtrlGrip("0c2");G.getAttribute("cx");G.getAttribute("cy");E.setAttribute("cx",v);E.setAttribute("cy",F);E.setAttribute("display","inline");E=m[0];var L=m[1];I.getItem(A);var k=E+(E-v/o),u=L+(L-F/o);G.setAttribute("cx",k*o);G.setAttribute("cy",u*o);G.setAttribute("display","inline");G=svgedit.path.getCtrlLine(1);var C=svgedit.path.getCtrlLine(2);ma(G,{x1:v,y1:F,x2:E*o,y2:L*o,display:"inline"});ma(C,{x1:k*o,y1:u*o,x2:E*o,y2:L*o,display:"inline"});if(A===0)z=[v,F];else{I=I.getItem(A-
1);v=I.x;F=I.y;if(I.pathSegType===6){v+=v-I.x2;F+=F-I.y2}else if(z){v=z[0]/o;F=z[1]/o}svgedit.path.replacePathSeg(6,A,[E,L,v,F,k,u],w)}}else if(E=qa("path_stretch_line")){A=I.getItem(A);if(A.pathSegType===6)svgedit.path.replacePathSeg(6,1,[v,F,(A.x+(A.x-A.x2))*o,(A.y+(A.y-A.y2))*o,v,F],E);else z?svgedit.path.replacePathSeg(6,1,[v,F,z[0],z[1],v,F],E):svgedit.path.replacePathSeg(4,1,[v,F],E)}}}else if(svgedit.path.path.dragging){E=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},
svgedit.path.path);L=svgedit.path.getPointFromGrip({x:v,y:F},svgedit.path.path);A=L.x-E.x;E=L.y-E.y;svgedit.path.path.dragging=[v,F];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(A,E):svgedit.path.path.movePts(A,E)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var D=ua.getBBox(),P=svgedit.path.getGripPt(this);D=svgedit.math.rectsIntersect(D,{x:P.x,y:P.y,width:0,height:0});this.select(D);D&&svgedit.path.path.selected_pts.push(this.index)}})}},
mouseUp:function(A,v){if(Ea==="path"){m=null;if(!w){v=qa(ca());La=false;z=null}return{keep:true,element:v}}if(svgedit.path.path.dragging){var F=svgedit.path.path.cur_pt;svgedit.path.path.dragging=false;svgedit.path.path.dragctrl=false;svgedit.path.path.update();H&&svgedit.path.path.endChanges("Move path point(s)");!A.shiftKey&&!H&&svgedit.path.path.selectPt(F)}else if(ua&&ua.getAttribute("display")!="none"){ua.setAttribute("display","none");ua.getAttribute("width")<=2&&ua.getAttribute("height")<=
2&&Ja.toSelectMode(A.target)}else Ja.toSelectMode(A.target);H=false},toEditMode:function(A){svgedit.path.path=svgedit.path.getPath_(A);Ea="pathedit";Qa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);e=false},toSelectMode:function(A){var v=A==svgedit.path.path.elem;Ea="select";svgedit.path.path.show(false);h=false;Qa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(v){N("selected",[A]);vb([A],true)}},addSubPath:function(A){if(A){Ea=
"path";e=true}else{Ja.clear(true);Ja.toEditMode(svgedit.path.path.elem)}},select:function(A){if(h===A){Ja.toEditMode(A);Ea="pathedit"}else h=A},reorient:function(){var A=J[0];if(A)if(oa(A)!=0){var v=new za("Reorient path"),F={d:A.getAttribute("d"),transform:A.getAttribute("transform")};v.addSubCommand(new Na(A,F));Qa();this.resetOrientation(A);ya(v);svgedit.path.getPath_(A).show(false).matrix=null;this.clear();vb([A],true);N("changed",J)}},clear:function(){h=null;if(w){var A=qa(ca());$(qa("path_stretch_line")).remove();
$(A).remove();$(qa("pathpointgrip_container")).find("*").attr("display","none");w=z=null;La=false}else Ea=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(A){if(A==null||A.nodeName!="path")return false;var v=X(A),F=fa(v).matrix;v.clear();A.removeAttribute("transform");v=A.pathSegList;for(var I=v.numberOfItems,E=0;E<I;++E){var G=v.getItem(E),L=G.pathSegType;if(L!=1){var k=[];$.each(["",1,2],function(u,C){var D=G["x"+C],P=G["y"+C];if(D!==
undefined&&P!==undefined){D=O(D,P,F);k.splice(k.length,0,D.x,D.y)}});svgedit.path.replacePathSeg(L,E,k,A)}}g(A,F)},zoomChange:function(){Ea=="pathedit"&&svgedit.path.path.update()},getNodePoint:function(){var A=svgedit.path.path.segs[svgedit.path.path.selected_pts.length?svgedit.path.path.selected_pts[0]:1];return{x:A.item.x,y:A.item.y,type:A.type}},linkControlPoints:function(A){svgedit.path.setLinkControlPoints(A)},clonePathNode:function(){svgedit.path.path.storeD();for(var A=svgedit.path.path.selected_pts,
v=A.length,F=[];v--;){var I=A[v];svgedit.path.path.addSeg(I);F.push(I+v);F.push(I+v+1)}svgedit.path.path.init().addPtsToSelection(F);svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var A=svgedit.path.path.selected_pts;if(A.length===1){var v=svgedit.path.path.elem,F=v.pathSegList,I=A[0],E=null,G=null;svgedit.path.path.eachSeg(function(C){if(this.type===2&&C<=I)G=this.item;if(C<=I)return true;if(this.type===2){E=C;return false}else if(this.type===1)return E=false});if(E==
null)E=svgedit.path.path.segs.length-1;if(E!==false){var L=v.createSVGPathSegLinetoAbs(G.x,G.y),k=v.createSVGPathSegClosePath();if(E==svgedit.path.path.segs.length-1){F.appendItem(L);F.appendItem(k)}else{svgedit.path.insertItemBefore(v,k,E);svgedit.path.insertItemBefore(v,L,E)}svgedit.path.path.init().selectPt(E+1)}else if(svgedit.path.path.segs[I].mate){F.removeItem(I);F.removeItem(I);svgedit.path.path.init().selectPt(I-1)}else{for(A=0;A<F.numberOfItems;A++){var u=F.getItem(A);if(u.pathSegType===
2)L=A;else if(A===I)F.removeItem(L);else if(u.pathSegType===1&&I<A){k=A-1;F.removeItem(A);break}}for(A=I-L-1;A--;)svgedit.path.insertItemBefore(v,F.getItem(L),k);v=F.getItem(L);svgedit.path.replacePathSeg(2,L,[v.x,v.y]);A=I;svgedit.path.path.init().selectPt(0)}}},deletePathNode:function(){if(Ja.canDeleteNodes){svgedit.path.path.storeD();for(var A=svgedit.path.path.selected_pts,v=A.length;v--;)svgedit.path.path.deleteSeg(A[v]);var F=function(){var I=svgedit.path.path.elem.pathSegList,E=I.numberOfItems,
G=function(u,C){for(;C--;)I.removeItem(u)};if(E<=1)return true;for(;E--;){var L=I.getItem(E);if(L.pathSegType===1){L=I.getItem(E-1);var k=I.getItem(E-2);if(L.pathSegType===2){G(E-1,2);F();break}else if(k.pathSegType===2){G(E-2,3);F();break}}else if(L.pathSegType===2)if(E>0){L=I.getItem(E-1).pathSegType;if(L===2){G(E-1,1);F();break}else if(L===1&&I.numberOfItems-1===E){G(E,1);F();break}}}return false};F();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){Ja.toSelectMode(svgedit.path.path.elem);
b.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){A=$(svgedit.path.path.elem);A.attr("d",A.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(A){var v=A.points,F=v.numberOfItems;if(F>=4){var I=v.getItem(0),E=null;A=[];A.push(["M",I.x,",",I.y," C"].join(""));for(var G=1;G<=F-4;G+=3){var L=v.getItem(G),k=v.getItem(G+1),u=v.getItem(G+2);if(E)if((I=svgedit.path.smoothControlPoints(E,L,I))&&I.length==
2){L=A[A.length-1].split(",");L[2]=I[0].x;L[3]=I[0].y;A[A.length-1]=L.join(",");L=I[1]}A.push([L.x,L.y,k.x,k.y,u.x,u.y].join(","));I=u;E=k}for(A.push("L");G<F;++G){k=v.getItem(G);A.push([k.x,k.y].join(","))}A=A.join(" ");A=Q({element:"path",curStyles:true,attr:{id:ca(),d:A,fill:"none"}})}return A},setSegType:function(A){svgedit.path.path.setSegType(A)},moveNode:function(A,v){var F=svgedit.path.path.selected_pts;if(F.length){svgedit.path.path.storeD();F=svgedit.path.path.segs[F[0]];var I={x:0,y:0};
I[A]=v-F.item[A];F.move(I.x,I.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(A){for(var v=A.pathSegList,F=v.numberOfItems,I,E=0;E<F;++E){var G=v.getItem(E);if(G.pathSegType===2)I=G;if(G.pathSegType===1){G=v.getItem(E-1);if(G.x!=I.x||G.y!=I.y){v=A.createSVGPathSegLinetoAbs(I.x,I.y);svgedit.path.insertItemBefore(A,v,E);Ja.fixEnd(A);break}}}svgedit.browser.isWebkit()&&A.setAttribute("d",Ja.convertPath(A))},convertPath:function(A,v){for(var F=A.pathSegList,I=F.numberOfItems,E=0,
G=0,L="",k=null,u=0;u<I;++u){var C=F.getItem(u),D=C.x||0,P=C.y||0,U=C.x1||0,S=C.y1||0,Y=C.x2||0,aa=C.y2||0,ga=C.pathSegType,ra=Pa[ga]["to"+(v?"Lower":"Upper")+"Case"](),Oa=function(Ba,ha,Ta){ha=ha?" "+ha.join(" "):"";Ta=Ta?" "+svgedit.units.shortFloat(Ta):"";$.each(Ba,function(Ra,ta){Ba[Ra]=svgedit.units.shortFloat(ta)});L+=ra+Ba.join(" ")+ha+Ta};switch(ga){case 1:L+="z";break;case 12:D-=E;case 13:if(v){E+=D;ra="l"}else{D+=E;E=D;ra="L"}Oa([[D,G]]);break;case 14:P-=G;case 15:if(v){G+=P;ra="l"}else{P+=
G;G=P;ra="L"}Oa([[E,P]]);break;case 2:case 4:case 18:D-=E;P-=G;case 5:case 3:if(k&&F.getItem(u-1).pathSegType===1&&!v){E=k[0];G=k[1]}case 19:if(v){E+=D;G+=P}else{D+=E;P+=G;E=D;G=P}if(ga===3)k=[E,G];Oa([[D,P]]);break;case 6:D-=E;U-=E;Y-=E;P-=G;S-=G;aa-=G;case 7:if(v){E+=D;G+=P}else{D+=E;U+=E;Y+=E;P+=G;S+=G;aa+=G;E=D;G=P}Oa([[U,S],[Y,aa],[D,P]]);break;case 8:D-=E;U-=E;P-=G;S-=G;case 9:if(v){E+=D;G+=P}else{D+=E;U+=E;P+=G;S+=G;E=D;G=P}Oa([[U,S],[D,P]]);break;case 10:D-=E;P-=G;case 11:if(v){E+=D;G+=P}else{D+=
E;P+=G;E=D;G=P}Oa([[C.r1,C.r2]],[C.angle,C.largeArcFlag?1:0,C.sweepFlag?1:0],[D,P]);break;case 16:D-=E;Y-=E;P-=G;aa-=G;case 17:if(v){E+=D;G+=P}else{D+=E;Y+=E;P+=G;aa+=G;E=D;G=P}Oa([[Y,aa],[D,P]])}}return L}}}(),Kb=this.removeUnusedDefElems=function(){var e=l.getElementsByTagNameNS(c,"defs");if(!e||!e.length)return 0;for(var h=[],m=0,z=["fill","stroke","filter","marker-start","marker-mid","marker-end"],w=z.length,H=l.getElementsByTagNameNS(c,"*"),A=H.length,v=0;v<A;v++){for(var F=H[v],I=0;I<w;I++){var E=
ka(F.getAttribute(z[I]));E&&h.push(E.substr(1))}(F=da(F))&&F.indexOf("#")===0&&h.push(F.substr(1))}e=$(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(v=e.length;v--;){z=e[v];w=z.id;if(h.indexOf(w)<0){Ab[w]=z;z.parentNode.removeChild(z);m++}}return m};this.svgCanvasToString=function(){for(;Kb()>0;);Ja.clear(true);$.each(l.childNodes,function(m,z){m&&z.nodeType===8&&z.data.indexOf("Created with")>=0&&l.insertBefore(z,l.firstChild)});if(K){Jb();xb([K])}var e=
[];$(l).find("g:data(gsvg)").each(function(){for(var m=this.attributes,z=m.length,w=0;w<z;w++)if(m[w].nodeName=="id"||m[w].nodeName=="style")z--;if(z<=0){m=this.firstChild;e.push(m);$(this).replaceWith(m)}});var h=this.svgToString(l,0);e.length&&$(e).each(function(){Bb(this)});return h};this.svgToString=function(e,h){var m=[],z=svgedit.utilities.toXml,w=n.baseUnit,H=RegExp("^-?[\\d\\.]+"+w+"$");if(e){na(e);var A=e.attributes,v,F,I=e.childNodes;for(F=0;F<h;F++)m.push(" ");m.push("<");m.push(e.nodeName);
if(e.id==="svgcontent"){F=Eb();if(w!=="px"){F.w=svgedit.units.convertUnit(F.w,w)+w;F.h=svgedit.units.convertUnit(F.h,w)+w}m.push(' width="'+F.w+'" height="'+F.h+'" xmlns="'+c+'"');var E={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(u,C){var D=C.namespaceURI;if(D&&!E[D]&&Aa[D]!=="xmlns"&&Aa[D]!=="xml"){E[D]=true;m.push(" xmlns:"+Aa[D]+'="'+D+'"')}})});F=A.length;for(w=["width","height","xmlns","x","y","viewBox","id","overflow"];F--;){v=A.item(F);var G=z(v.nodeValue);if(v.nodeName.indexOf("xmlns:")!==
0)if(G!=""&&w.indexOf(v.localName)==-1)if(!v.namespaceURI||Aa[v.namespaceURI]){m.push(" ");m.push(v.nodeName);m.push('="');m.push(G);m.push('"')}}}else{if(e.nodeName==="defs"&&!e.firstChild)return;var L=["-moz-math-font-style","_moz-math-font-style"];for(F=A.length-1;F>=0;F--){v=A.item(F);G=z(v.nodeValue);if(!(L.indexOf(v.localName)>=0))if(G!="")if(G.indexOf("pointer-events")!==0)if(!(v.localName==="class"&&G.indexOf("se_")===0)){m.push(" ");if(v.localName==="d")G=Ja.convertPath(e,true);if(isNaN(G)){if(H.test(G))G=
svgedit.units.shortFloat(G)+w}else G=svgedit.units.shortFloat(G);if(fb.apply&&e.nodeName==="image"&&v.localName==="href"&&fb.images&&fb.images==="embed"){var k=Ra[G];if(k)G=k}if(!v.namespaceURI||v.namespaceURI==c||Aa[v.namespaceURI]){m.push(v.nodeName);m.push('="');m.push(G);m.push('"')}}}}if(e.hasChildNodes()){m.push(">");h++;A=false;for(F=0;F<I.length;F++){w=I.item(F);switch(w.nodeType){case 1:m.push("\n");m.push(this.svgToString(I.item(F),h));break;case 3:w=w.nodeValue.replace(/^\s+|\s+$/g,"");
svgedit.units.shortFloat(G)+w}else G=svgedit.units.shortFloat(G);if(fb.apply&&e.nodeName==="image"&&v.localName==="href"&&fb.images&&fb.images==="embed"){var k=Sa[G];if(k)G=k}if(!v.namespaceURI||v.namespaceURI==c||Aa[v.namespaceURI]){m.push(v.nodeName);m.push('="');m.push(G);m.push('"')}}}}if(e.hasChildNodes()){m.push(">");h++;A=false;for(F=0;F<I.length;F++){w=I.item(F);switch(w.nodeType){case 1:m.push("\n");m.push(this.svgToString(I.item(F),h));break;case 3:w=w.nodeValue.replace(/^\s+|\s+$/g,"");
if(w!=""){A=true;m.push(z(w)+"")}break;case 4:m.push("\n");m.push(Array(h+1).join(" "));m.push("<![CDATA[");m.push(w.nodeValue);m.push("]]\>");break;case 8:m.push("\n");m.push(Array(h+1).join(" "));m.push("<!--");m.push(w.data);m.push("--\>")}}h--;if(!A){m.push("\n");for(F=0;F<h;F++)m.push(" ")}m.push("</");m.push(e.nodeName);m.push(">")}else m.push("/>")}return m.join("")};this.embedImage=function(e,h){$(new Image).load(function(){var m=document.createElement("canvas");m.width=this.width;m.height=
this.height;m.getContext("2d").drawImage(this,0,0);try{var z=";svgedit_url="+encodeURIComponent(e);z=m.toDataURL().replace(";base64",z+";base64");Ra[e]=z}catch(w){Ra[e]=false}Da=e;h&&h(Ra[e])}).attr("src",e)};this.setGoodImage=function(e){Da=e};this.open=function(){};this.save=function(e){Pa();e&&$.extend(fb,e);fb.apply=true;e=this.svgCanvasToString();N("saved",e)};this.rasterExport=function(){Pa();var e=[],h={feGaussianBlur:qb.exportNoBlur,foreignObject:qb.exportNoforeignObject,"[stroke-dasharray]":qb.exportNoDashArray},
this.height;m.getContext("2d").drawImage(this,0,0);try{var z=";svgedit_url="+encodeURIComponent(e);z=m.toDataURL().replace(";base64",z+";base64");Sa[e]=z}catch(w){Sa[e]=false}Da=e;h&&h(Sa[e])}).attr("src",e)};this.setGoodImage=function(e){Da=e};this.open=function(){};this.save=function(e){Qa();e&&$.extend(fb,e);fb.apply=true;e=this.svgCanvasToString();N("saved",e)};this.rasterExport=function(){Qa();var e=[],h={feGaussianBlur:qb.exportNoBlur,foreignObject:qb.exportNoforeignObject,"[stroke-dasharray]":qb.exportNoDashArray},
m=$(l);if(!("font"in $("<canvas>")[0].getContext("2d")))h.text=qb.exportNoText;$.each(h,function(z,w){m.find(z).length&&e.push(w)});h=this.svgCanvasToString();N("exported",{svg:h,issues:e})};this.getSvgString=function(){fb.apply=false;return this.svgCanvasToString()};this.randomizeIds=function(){arguments.length>0&&arguments[0]==false?svgedit.draw.randomizeIds(false,B()):svgedit.draw.randomizeIds(true,B())};var Nb=this.uniquifyElems=function(e){var h={},m=["filter","linearGradient","pattern","radialGradient",
"symbol","textPath","use"];svgedit.utilities.walkTree(e,function(v){if(v.nodeType==1){if(v.id){v.id in h||(h[v.id]={elem:null,attrs:[],hrefs:[]});h[v.id].elem=v}$.each($a,function(I,D){var G=v.getAttributeNode(D);if(G){var L=svgedit.utilities.getUrlFromAttr(G.value);if(L=L?L.substr(1):null){L in h||(h[L]={elem:null,attrs:[],hrefs:[]});h[L].attrs.push(G)}}});var F=svgedit.utilities.getHref(v);if(F&&m.indexOf(v.nodeName)>=0)if(F=F.substr(1)){F in h||(h[F]={elem:null,attrs:[],hrefs:[]});h[F].hrefs.push(v)}}});
"symbol","textPath","use"];svgedit.utilities.walkTree(e,function(v){if(v.nodeType==1){if(v.id){v.id in h||(h[v.id]={elem:null,attrs:[],hrefs:[]});h[v.id].elem=v}$.each($a,function(I,E){var G=v.getAttributeNode(E);if(G){var L=svgedit.utilities.getUrlFromAttr(G.value);if(L=L?L.substr(1):null){L in h||(h[L]={elem:null,attrs:[],hrefs:[]});h[L].attrs.push(G)}}});var F=svgedit.utilities.getHref(v);if(F&&m.indexOf(v.nodeName)>=0)if(F=F.substr(1)){F in h||(h[F]={elem:null,attrs:[],hrefs:[]});h[F].hrefs.push(v)}}});
for(var z in h)if(z){var w=h[z].elem;if(w){e=ja();w.id=e;w=h[z].attrs;for(var H=w.length;H--;){var A=w[H];A.ownerElement.setAttribute(A.name,"url(#"+e+")")}w=h[z].hrefs;for(H=w.length;H--;)svgedit.utilities.setHref(w[H],"#"+e)}}},Lb=this.setUseData=function(e){var h=$(e);if(e.tagName!=="use")h=h.find("use");h.each(function(){var m=da(this).substr(1);if(m=qa(m)){$(this).data("ref",m);if(m.tagName=="symbol"||m.tagName=="svg")$(this).data("symbol",m).data("ref",m)}})},Ob=this.convertGradients=function(e){var h=
$(e).find("linearGradient, radialGradient");if(!h.length&&svgedit.browser.isWebkit())h=$(e).find("*").filter(function(){return this.tagName.indexOf("Gradient")>=0});h.each(function(){if($(this).attr("gradientUnits")==="userSpaceOnUse"){var m=$(l).find('[fill="url(#'+this.id+')"],[stroke="url(#'+this.id+')"]');if(m.length)if(m=svgedit.utilities.getBBox(m[0]))if(this.tagName==="linearGradient"){var z=$(this).attr(["x1","y1","x2","y2"]),w=this.gradientTransform.baseVal;if(w&&w.numberOfItems>0){var H=
fa(w).matrix;w=O(z.x1,z.y1,H);H=O(z.x2,z.y2,H);z.x1=w.x;z.y1=w.y;z.x2=H.x;z.y2=H.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(z.x1-m.x)/m.width,y1:(z.y1-m.y)/m.height,x2:(z.x2-m.x)/m.width,y2:(z.y2-m.y)/m.height});this.removeAttribute("gradientUnits")}}})},Db=this.convertToGroup=function(e){e||(e=J[0]);var h=$(e),m=new za,z;if(h.data("gsvg")){m=$(e.firstChild).attr(["x","y"]);$(e.firstChild.firstChild).unwrap();$(e).removeData("gsvg");z=Y(e);var w=d.createSVGTransform();w.setTranslate(m.x,
m.y);z.appendItem(w);Xa(e);N("selected",[e])}else if(h.data("symbol")){e=h.data("symbol");z=h.attr("transform");w=h.attr(["x","y"]);var H=e.getAttribute("viewBox");if(H){H=H.split(" ");w.x-=+H[0];w.y-=+H[1]}z+=" translate("+(w.x||0)+","+(w.y||0)+")";w=h.prev();m.addSubCommand(new Ka(h[0],h[0].nextSibling,h[0].parentNode));h.remove();H=$(l).find("use:data(symbol)").length;h=f.createElementNS(c,"g");for(var A=e.childNodes,v=0;v<A.length;v++)h.appendChild(A[v].cloneNode(true));if(svgedit.browser.isGecko()){A=
$(lb()).children("linearGradient,radialGradient,pattern").clone();$(h).append(A)}z&&h.setAttribute("transform",z);z=e.parentNode;Nb(h);svgedit.browser.isGecko()&&$(lb()).append($(h).find("linearGradient,radialGradient,pattern"));h.id=ja();w.after(h);if(z){if(!H){w=e.nextSibling;z.removeChild(e);m.addSubCommand(new Ka(e,w,z))}m.addSubCommand(new Ca(h))}Lb(h);svgedit.browser.isGecko()?Ob(lb()):Ob(h);svgedit.utilities.walkTreePost(h,function(F){try{Xa(F)}catch(I){console.log(I)}});$(h).find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=
ja()});Bb([h]);(e=Mb(h,true))&&m.addSubCommand(e);ya(m)}else console.log("Unexpected element to ungroup:",e)};this.setSvgString=function(e){try{var h=svgedit.utilities.text2xml(e);this.prepareSvg(h);var m=new za("Change Source"),z=l.nextSibling,w=d.removeChild(l);m.addSubCommand(new Ka(w,z,d));l=f.adoptNode?f.adoptNode(h.documentElement):f.importNode(h.documentElement,true);d.appendChild(l);var H=$(l);b.current_drawing_=new svgedit.draw.Drawing(l,q);var A=B().getNonce();A?N("setnonce",A):N("unsetnonce");
H.find("image").each(function(){var k=this;pb(k);var u=da(this);if(u.indexOf("data:")===0){var C=u.match(/svgedit_url=(.*?);/);if(C){var E=decodeURIComponent(C[1]);$(new Image).load(function(){k.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",E)}).attr("src",E)}}b.embedImage(u)});H.find("svg").each(function(){if(!$(this).closest("defs").length){Nb(this);var k=this.parentNode;if(k.childNodes.length===1&&k.nodeName==="g"){$(k).data("gsvg",this);k.id=k.id||ja()}else Ab(this)}});svgedit.browser.isGecko()&&
H.find("linearGradient, radialGradient, pattern").appendTo(lb());Lb(H);Ob(H[0]);svgedit.utilities.walkTreePost(l,function(k){try{Xa(k)}catch(u){console.log(u)}});var v={id:"svgcontent",overflow:n.show_outside_canvas?"visible":"hidden"},F=false;if(H.attr("viewBox")){var I=H.attr("viewBox").split(" ");v.width=I[2];v.height=I[3]}else $.each(["width","height"],function(k,u){var C=H.attr(u);C||(C="100%");if((C+"").substr(-1)==="%")F=true;else v[u]=sa(u,C)});Fb();H.children().find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=
ja()});if(F){var D=getStrokedBBox();v.width=D.width+D.x;v.height=D.height+D.y}if(v.width<=0)v.width=100;if(v.height<=0)v.height=100;H.attr(v);this.contentW=v.width;this.contentH=v.height;m.addSubCommand(new Ca(l));var G=H.attr(["width","height"]);m.addSubCommand(new Na(d,G));o=1;svgedit.transformlist.resetListMap();Pa();svgedit.path.clearData();d.appendChild(Ha.selectorParentGroup);ya(m);N("changed",[l])}catch(L){console.log(L);return false}return true};this.importSvgString=function(e){try{var h=
svgedit.utilities.encode64(e.length+e).substr(0,32),m=false;if(sb[h])if($(sb[h].symbol).parents("#svgroot").length)m=true;var z=new za("Import SVG");if(m)var w=sb[h].symbol,H=sb[h].xform;else{var A=svgedit.utilities.text2xml(e);this.prepareSvg(A);var v;v=f.adoptNode?f.adoptNode(A.documentElement):f.importNode(A.documentElement,true);Nb(v);var F=sa("width",v.getAttribute("width")),I=sa("height",v.getAttribute("height")),D=v.getAttribute("viewBox"),G=D?D.split(" "):[0,0,F,I];for(e=0;e<4;++e)G[e]=+G[e];
l.getAttribute("width");var L=+l.getAttribute("height");H=I>F?"scale("+L/3/G[3]+")":"scale("+L/3/G[2]+")";H="translate(0) "+H+" translate(0)";w=f.createElementNS(c,"symbol");var k=lb();for(svgedit.browser.isGecko()&&$(v).find("linearGradient, radialGradient, pattern").appendTo(k);v.firstChild;)w.appendChild(v.firstChild);var u=v.attributes;for(v=0;v<u.length;v++){var C=u[v];w.setAttribute(C.nodeName,C.nodeValue)}w.id=ja();sb[h]={symbol:w,xform:H};lb().appendChild(w);z.addSubCommand(new Ca(w))}var E=
f.createElementNS(c,"use");E.id=ja();V(E,"#"+w.id);(K||B().getCurrentLayer()).appendChild(E);z.addSubCommand(new Ca(E));Pa();E.setAttribute("transform",H);Xa(E);$(E).data("symbol",w).data("ref",w);vb([E]);ya(z);N("changed",[l])}catch(P){console.log(P);return false}return true};var Fb=b.identifyLayers=function(){Jb();B().identifyLayers()};this.createLayer=function(e){var h=new za("Create Layer");e=B().createLayer(e);h.addSubCommand(new Ca(e));ya(h);Pa();N("changed",[e])};this.cloneLayer=function(e){var h=
new za("Duplicate Layer"),m=f.createElementNS(c,"g"),z=f.createElementNS(c,"title");z.textContent=e;m.appendChild(z);z=B().getCurrentLayer();$(z).after(m);z=z.childNodes;for(var w=0;w<z.length;w++){var H=z[w];H.localName!="title"&&m.appendChild(la(H))}Pa();Fb();h.addSubCommand(new Ca(m));ya(h);b.setCurrentLayer(e);N("changed",[m])};this.deleteCurrentLayer=function(){var e=B().getCurrentLayer(),h=e.nextSibling,m=e.parentNode;if(e=B().deleteCurrentLayer()){var z=new za("Delete Layer");z.addSubCommand(new Ka(e,
h,m));ya(z);Pa();N("changed",[m]);return true}return false};this.setCurrentLayer=function(e){(e=B().setCurrentLayer(svgedit.utilities.toXml(e)))&&Pa();return e};this.renameCurrentLayer=function(e){var h=B();if(h.current_layer){var m=h.current_layer;if(!b.setCurrentLayer(e)){for(var z=new za("Rename Layer"),w=0;w<h.getNumLayers();++w)if(h.all_layers[w][1]==m)break;var H=h.getLayerName(w);h.all_layers[w][0]=svgedit.utilities.toXml(e);var A=m.childNodes.length;for(w=0;w<A;++w){var v=m.childNodes.item(w);
fa(w).matrix;w=O(z.x1,z.y1,H);H=O(z.x2,z.y2,H);z.x1=w.x;z.y1=w.y;z.x2=H.x;z.y2=H.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(z.x1-m.x)/m.width,y1:(z.y1-m.y)/m.height,x2:(z.x2-m.x)/m.width,y2:(z.y2-m.y)/m.height});this.removeAttribute("gradientUnits")}}})},Db=this.convertToGroup=function(e){e||(e=J[0]);var h=$(e),m=new za,z;if(h.data("gsvg")){m=$(e.firstChild).attr(["x","y"]);$(e.firstChild.firstChild).unwrap();$(e).removeData("gsvg");z=X(e);var w=d.createSVGTransform();w.setTranslate(m.x,
m.y);z.appendItem(w);Ua(e);N("selected",[e])}else if(h.data("symbol")){e=h.data("symbol");z=h.attr("transform");w=h.attr(["x","y"]);var H=e.getAttribute("viewBox");if(H){H=H.split(" ");w.x-=+H[0];w.y-=+H[1]}z+=" translate("+(w.x||0)+","+(w.y||0)+")";w=h.prev();m.addSubCommand(new Ka(h[0],h[0].nextSibling,h[0].parentNode));h.remove();H=$(l).find("use:data(symbol)").length;h=f.createElementNS(c,"g");for(var A=e.childNodes,v=0;v<A.length;v++)h.appendChild(A[v].cloneNode(true));if(svgedit.browser.isGecko()){A=
$(lb()).children("linearGradient,radialGradient,pattern").clone();$(h).append(A)}z&&h.setAttribute("transform",z);z=e.parentNode;Nb(h);svgedit.browser.isGecko()&&$(lb()).append($(h).find("linearGradient,radialGradient,pattern"));h.id=ja();w.after(h);if(z){if(!H){w=e.nextSibling;z.removeChild(e);m.addSubCommand(new Ka(e,w,z))}m.addSubCommand(new Ca(h))}Lb(h);svgedit.browser.isGecko()?Ob(lb()):Ob(h);svgedit.utilities.walkTreePost(h,function(F){try{Ua(F)}catch(I){console.log(I)}});$(h).find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=
ja()});xb([h]);(e=Mb(h,true))&&m.addSubCommand(e);ya(m)}else console.log("Unexpected element to ungroup:",e)};this.setSvgString=function(e){try{var h=svgedit.utilities.text2xml(e);this.prepareSvg(h);var m=new za("Change Source"),z=l.nextSibling,w=d.removeChild(l);m.addSubCommand(new Ka(w,z,d));l=f.adoptNode?f.adoptNode(h.documentElement):f.importNode(h.documentElement,true);d.appendChild(l);var H=$(l);b.current_drawing_=new svgedit.draw.Drawing(l,q);var A=B().getNonce();A?N("setnonce",A):N("unsetnonce");
H.find("image").each(function(){var k=this;pb(k);var u=da(this);if(u.indexOf("data:")===0){var C=u.match(/svgedit_url=(.*?);/);if(C){var D=decodeURIComponent(C[1]);$(new Image).load(function(){k.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",D)}).attr("src",D)}}b.embedImage(u)});H.find("svg").each(function(){if(!$(this).closest("defs").length){Nb(this);var k=this.parentNode;if(k.childNodes.length===1&&k.nodeName==="g"){$(k).data("gsvg",this);k.id=k.id||ja()}else Bb(this)}});svgedit.browser.isGecko()&&
H.find("linearGradient, radialGradient, pattern").appendTo(lb());Lb(H);Ob(H[0]);svgedit.utilities.walkTreePost(l,function(k){try{Ua(k)}catch(u){console.log(u)}});var v={id:"svgcontent",overflow:n.show_outside_canvas?"visible":"hidden"},F=false;if(H.attr("viewBox")){var I=H.attr("viewBox").split(" ");v.width=I[2];v.height=I[3]}else $.each(["width","height"],function(k,u){var C=H.attr(u);C||(C="100%");if((C+"").substr(-1)==="%")F=true;else v[u]=sa(u,C)});Fb();H.children().find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=
ja()});if(F){var E=getStrokedBBox();v.width=E.width+E.x;v.height=E.height+E.y}if(v.width<=0)v.width=100;if(v.height<=0)v.height=100;H.attr(v);this.contentW=v.width;this.contentH=v.height;m.addSubCommand(new Ca(l));var G=H.attr(["width","height"]);m.addSubCommand(new Na(d,G));o=1;svgedit.transformlist.resetListMap();Qa();svgedit.path.clearData();d.appendChild(Ha.selectorParentGroup);ya(m);N("changed",[l])}catch(L){console.log(L);return false}return true};this.importSvgString=function(e){try{var h=
svgedit.utilities.encode64(e.length+e).substr(0,32),m=false;if(sb[h])if($(sb[h].symbol).parents("#svgroot").length)m=true;var z=new za("Import SVG");if(m)var w=sb[h].symbol,H=sb[h].xform;else{var A=svgedit.utilities.text2xml(e);this.prepareSvg(A);var v;v=f.adoptNode?f.adoptNode(A.documentElement):f.importNode(A.documentElement,true);Nb(v);var F=sa("width",v.getAttribute("width")),I=sa("height",v.getAttribute("height")),E=v.getAttribute("viewBox"),G=E?E.split(" "):[0,0,F,I];for(e=0;e<4;++e)G[e]=+G[e];
l.getAttribute("width");var L=+l.getAttribute("height");H=I>F?"scale("+L/3/G[3]+")":"scale("+L/3/G[2]+")";H="translate(0) "+H+" translate(0)";w=f.createElementNS(c,"symbol");var k=lb();for(svgedit.browser.isGecko()&&$(v).find("linearGradient, radialGradient, pattern").appendTo(k);v.firstChild;)w.appendChild(v.firstChild);var u=v.attributes;for(v=0;v<u.length;v++){var C=u[v];w.setAttribute(C.nodeName,C.nodeValue)}w.id=ja();sb[h]={symbol:w,xform:H};lb().appendChild(w);z.addSubCommand(new Ca(w))}var D=
f.createElementNS(c,"use");D.id=ja();V(D,"#"+w.id);(K||B().getCurrentLayer()).appendChild(D);z.addSubCommand(new Ca(D));Qa();D.setAttribute("transform",H);Ua(D);$(D).data("symbol",w).data("ref",w);vb([D]);ya(z);N("changed",[l])}catch(P){console.log(P);return false}return true};var Fb=b.identifyLayers=function(){Jb();B().identifyLayers()};this.createLayer=function(e){var h=new za("Create Layer");e=B().createLayer(e);h.addSubCommand(new Ca(e));ya(h);Qa();N("changed",[e])};this.cloneLayer=function(e){var h=
new za("Duplicate Layer"),m=f.createElementNS(c,"g"),z=f.createElementNS(c,"title");z.textContent=e;m.appendChild(z);z=B().getCurrentLayer();$(z).after(m);z=z.childNodes;for(var w=0;w<z.length;w++){var H=z[w];H.localName!="title"&&m.appendChild(la(H))}Qa();Fb();h.addSubCommand(new Ca(m));ya(h);b.setCurrentLayer(e);N("changed",[m])};this.deleteCurrentLayer=function(){var e=B().getCurrentLayer(),h=e.nextSibling,m=e.parentNode;if(e=B().deleteCurrentLayer()){var z=new za("Delete Layer");z.addSubCommand(new Ka(e,
h,m));ya(z);Qa();N("changed",[m]);return true}return false};this.setCurrentLayer=function(e){(e=B().setCurrentLayer(svgedit.utilities.toXml(e)))&&Qa();return e};this.renameCurrentLayer=function(e){var h=B();if(h.current_layer){var m=h.current_layer;if(!b.setCurrentLayer(e)){for(var z=new za("Rename Layer"),w=0;w<h.getNumLayers();++w)if(h.all_layers[w][1]==m)break;var H=h.getLayerName(w);h.all_layers[w][0]=svgedit.utilities.toXml(e);var A=m.childNodes.length;for(w=0;w<A;++w){var v=m.childNodes.item(w);
if(v&&v.tagName=="title"){for(;v.firstChild;)v.removeChild(v.firstChild);v.textContent=e;z.addSubCommand(new Na(v,{"#text":H}));ya(z);N("changed",[m]);return true}}}h.current_layer=m}return false};this.setCurrentLayerPosition=function(e){var h=B();if(h.current_layer&&e>=0&&e<h.getNumLayers()){for(var m=0;m<h.getNumLayers();++m)if(h.all_layers[m][1]==h.current_layer)break;if(m==h.getNumLayers())return false;if(m!=e){var z=null,w=h.current_layer.nextSibling;if(e>m){if(e<h.getNumLayers()-1)z=h.all_layers[e+
1][1]}else z=h.all_layers[e][1];l.insertBefore(h.current_layer,z);ya(new Ia(h.current_layer,w,l));Fb();b.setCurrentLayer(h.getLayerName(e));return true}}return false};this.setLayerVisibility=function(e,h){var m=B(),z=m.getLayerVisibility(e),w=m.setLayerVisibility(e,h);if(w)ya(new Na(w,{display:z?"inline":"none"},"Layer Visibility"));else return false;if(w==m.getCurrentLayer()){Pa();Ja.clear()}return true};this.moveSelectedToLayer=function(e){for(var h=null,m=B(),z=0;z<m.getNumLayers();++z)if(m.getLayerName(z)==
1][1]}else z=h.all_layers[e][1];l.insertBefore(h.current_layer,z);ya(new Ia(h.current_layer,w,l));Fb();b.setCurrentLayer(h.getLayerName(e));return true}}return false};this.setLayerVisibility=function(e,h){var m=B(),z=m.getLayerVisibility(e),w=m.setLayerVisibility(e,h);if(w)ya(new Na(w,{display:z?"inline":"none"},"Layer Visibility"));else return false;if(w==m.getCurrentLayer()){Qa();Ja.clear()}return true};this.moveSelectedToLayer=function(e){for(var h=null,m=B(),z=0;z<m.getNumLayers();++z)if(m.getLayerName(z)==
e){h=m.all_layers[z][1];break}if(!h)return false;e=new za("Move Elements to Layer");m=J;for(z=m.length;z--;){var w=m[z];if(w){var H=w.nextSibling,A=w.parentNode;h.appendChild(w);e.addSubCommand(new Ia(w,H,A))}}ya(e);return true};this.mergeLayer=function(e){var h=new za("Merge Layer"),m=B(),z=$(m.current_layer).prev()[0];if(z){for(h.addSubCommand(new Ka(m.current_layer,m.current_layer.nextSibling,l));m.current_layer.firstChild;){var w=m.current_layer.firstChild;if(w.localName=="title"){h.addSubCommand(new Ka(w,
w.nextSibling,m.current_layer));m.current_layer.removeChild(w)}else{var H=w.nextSibling;z.appendChild(w);h.addSubCommand(new Ia(w,H,m.current_layer))}}l.removeChild(m.current_layer);if(!e){Pa();Fb();N("changed",[l]);ya(h)}m.current_layer=z;return h}};this.mergeAllLayers=function(){var e=new za("Merge all Layers"),h=B();for(h.current_layer=h.all_layers[h.getNumLayers()-1][1];$(l).children("g").length>1;)e.addSubCommand(b.mergeLayer(true));Pa();Fb();N("changed",[l]);ya(e)};var Jb=this.leaveContext=
function(){var e=va.length;if(e){for(var h=0;h<e;h++){var m=va[h],z=ib(m,"orig_opac");z!==1?m.setAttribute("opacity",z):m.removeAttribute("opacity");m.setAttribute("style","pointer-events: inherit")}va=[];Pa(true);N("contextset",null)}K=null},Rb=this.setContext=function(e){Jb();if(typeof e==="string")e=qa(e);K=e;$(e).parentsUntil("#svgcontent").andSelf().siblings().each(function(){var h=this.getAttribute("opacity")||1;ib(this,"orig_opac",h);this.setAttribute("opacity",h*0.33);this.setAttribute("style",
"pointer-events: none");va.push(this)});Pa();N("contextset",K)};this.clear=function(){Ja.clear();Pa();b.clearSvgContentElement();b.current_drawing_=new svgedit.draw.Drawing(l);b.createLayer("Layer 1");b.undoMgr.resetUndoStack();Ha.initGroup();ta=Ha.getRubberBandBox();N("cleared")};this.linkControlPoints=Ja.linkControlPoints;this.getContentElem=function(){return l};this.getRootElem=function(){return d};this.getSelectedElems=function(){return J};var Eb=this.getResolution=function(){var e=l.getAttribute("width")/
w.nextSibling,m.current_layer));m.current_layer.removeChild(w)}else{var H=w.nextSibling;z.appendChild(w);h.addSubCommand(new Ia(w,H,m.current_layer))}}l.removeChild(m.current_layer);if(!e){Qa();Fb();N("changed",[l]);ya(h)}m.current_layer=z;return h}};this.mergeAllLayers=function(){var e=new za("Merge all Layers"),h=B();for(h.current_layer=h.all_layers[h.getNumLayers()-1][1];$(l).children("g").length>1;)e.addSubCommand(b.mergeLayer(true));Qa();Fb();N("changed",[l]);ya(e)};var Jb=this.leaveContext=
function(){var e=va.length;if(e){for(var h=0;h<e;h++){var m=va[h],z=ib(m,"orig_opac");z!==1?m.setAttribute("opacity",z):m.removeAttribute("opacity");m.setAttribute("style","pointer-events: inherit")}va=[];Qa(true);N("contextset",null)}K=null},Rb=this.setContext=function(e){Jb();if(typeof e==="string")e=qa(e);K=e;$(e).parentsUntil("#svgcontent").andSelf().siblings().each(function(){var h=this.getAttribute("opacity")||1;ib(this,"orig_opac",h);this.setAttribute("opacity",h*0.33);this.setAttribute("style",
"pointer-events: none");va.push(this)});Qa();N("contextset",K)};this.clear=function(){Ja.clear();Qa();b.clearSvgContentElement();b.current_drawing_=new svgedit.draw.Drawing(l);b.createLayer("Layer 1");b.undoMgr.resetUndoStack();Ha.initGroup();ua=Ha.getRubberBandBox();N("cleared")};this.linkControlPoints=Ja.linkControlPoints;this.getContentElem=function(){return l};this.getRootElem=function(){return d};this.getSelectedElems=function(){return J};var Eb=this.getResolution=function(){var e=l.getAttribute("width")/
o,h=l.getAttribute("height")/o;return{w:e,h:h,zoom:o}};this.getZoom=function(){return o};this.getVersion=function(){return"svgcanvas.js ($Rev: 2082 $)"};this.setUiStrings=function(e){$.extend(qb,e.notification)};this.setConfig=function(e){$.extend(n,e)};this.getTitle=function(e){if(e=e||J[0]){e=$(e).data("gsvg")||$(e).data("symbol")||e;e=e.childNodes;for(var h=0;h<e.length;h++)if(e[h].nodeName=="title")return e[h].textContent;return""}};this.setGroupTitle=function(e){var h=J[0];h=$(h).data("gsvg")||
h;var m=$(h).children("title"),z=new za("Set Label");if(e.length)if(m.length){m=m[0];z.addSubCommand(new Na(m,{"#text":m.textContent}));m.textContent=e}else{m=f.createElementNS(c,"title");m.textContent=e;$(h).prepend(m);z.addSubCommand(new Ca(m))}else{z.addSubCommand(new Ka(m[0],m.nextSibling,h));m.remove()}ya(z)};this.getDocumentTitle=function(){return b.getTitle(l)};this.setDocumentTitle=function(e){for(var h=l.childNodes,m=false,z="",w=new za("Change Image Title"),H=0;H<h.length;H++)if(h[H].nodeName==
"title"){m=h[H];z=m.textContent;break}if(!m){m=f.createElementNS(c,"title");l.insertBefore(m,l.firstChild)}if(e.length)m.textContent=e;else m.parentNode.removeChild(m);w.addSubCommand(new Na(m,{"#text":z}));ya(w)};this.getEditorNS=function(e){e&&l.setAttribute("xmlns:se","http://svg-edit.googlecode.com");return"http://svg-edit.googlecode.com"};this.setResolution=function(e,h){var m=Eb(),z=m.w;m=m.h;var w;if(e=="fit"){var H=getStrokedBBox();if(H){w=new za("Fit Canvas to Content");var A=ub();vb(A);
var v=[],F=[];$.each(A,function(){v.push(H.x*-1);F.push(H.y*-1)});A=b.moveSelectedElements(v,F,true);w.addSubCommand(A);Pa();e=Math.round(H.width);h=Math.round(H.height)}else return false}if(e!=z||h!=m){A=d.suspendRedraw(1E3);w||(w=new za("Change Image Dimensions"));e=sa("width",e);h=sa("height",h);l.setAttribute("width",e);l.setAttribute("height",h);this.contentW=e;this.contentH=h;w.addSubCommand(new Na(l,{width:z,height:m}));l.setAttribute("viewBox",[0,0,e/o,h/o].join(" "));w.addSubCommand(new Na(l,
var v=[],F=[];$.each(A,function(){v.push(H.x*-1);F.push(H.y*-1)});A=b.moveSelectedElements(v,F,true);w.addSubCommand(A);Qa();e=Math.round(H.width);h=Math.round(H.height)}else return false}if(e!=z||h!=m){A=d.suspendRedraw(1E3);w||(w=new za("Change Image Dimensions"));e=sa("width",e);h=sa("height",h);l.setAttribute("width",e);l.setAttribute("height",h);this.contentW=e;this.contentH=h;w.addSubCommand(new Na(l,{width:z,height:m}));l.setAttribute("viewBox",[0,0,e/o,h/o].join(" "));w.addSubCommand(new Na(l,
{viewBox:["0 0",z,m].join(" ")}));ya(w);d.unsuspendRedraw(A);if(background=document.getElementById("canvas_background")){background.setAttribute("x",-1);background.setAttribute("y",-1);background.setAttribute("width",e+2);background.setAttribute("height",h+2)}N("changed",[l])}return[e,h]};this.getOffset=function(){return $(l).attr(["x","y"])};this.setBBoxZoom=function(e,h,m){var z=0.85,w=function(H){if(!H)return false;var A=Math.min(Math.round(h/H.width*100*z)/100,Math.round(m/H.height*100*z)/100);
b.setZoom(A);return{zoom:A,bbox:H}};if(typeof e=="object"){e=e;if(e.width==0||e.height==0){b.setZoom(e.zoom?e.zoom:o*e.factor);return{zoom:o,bbox:e}}return w(e)}switch(e){case "selection":if(!J[0])return;e=$.map(J,function(H){if(H)return H});e=getStrokedBBox(e);break;case "canvas":e=Eb();z=0.95;e={width:e.w,height:e.h,x:0,y:0};break;case "content":e=getStrokedBBox();break;case "layer":e=getStrokedBBox(ub(B().getCurrentLayer()));break;default:return}return w(e)};this.setZoom=function(e){var h=Eb();
l.setAttribute("viewBox","0 0 "+h.w/e+" "+h.h/e);o=e;$.each(J,function(m,z){z&&Ha.requestSelector(z).resize()});Ja.zoomChange();ob("zoomChanged",e)};this.getMode=function(){return Ea};this.setMode=function(e){Ja.clear(true);hb.clear();$("#workarea").attr("class",e);bb=J[0]&&J[0].nodeName=="text"?Za:M;Ea=e};this.getColor=function(e){return bb[e]};this.setColor=function(e,h,m){M[e]=h;bb[e+"_paint"]={type:"solidColor"};for(var z=[],w=J.length;w--;){var H=J[w];if(H)if(H.tagName=="g")svgedit.utilities.walkTree(H,
function(A){A.nodeName!="g"&&z.push(A)});else if(e=="fill")H.tagName!="polyline"&&H.tagName!="line"&&z.push(H);else z.push(H)}if(z.length>0)if(m)xb(e,h,z);else{gb(e,h,z);N("changed",z)}};var lb=function(){var e=l.getElementsByTagNameNS(c,"defs");if(e.length>0)e=e[0];else{e=f.createElementNS(c,"defs");l.firstChild?l.insertBefore(e,l.firstChild.nextSibling):l.appendChild(e)}return e},Qb=this.setGradient=function(e){if(!(!bb[e+"_paint"]||bb[e+"_paint"].type=="solidColor")){var h=b[e+"Grad"],m=Pb(h),
function(A){A.nodeName!="g"&&z.push(A)});else if(e=="fill")H.tagName!="polyline"&&H.tagName!="line"&&z.push(H);else z.push(H)}if(z.length>0)if(m)yb(e,h,z);else{gb(e,h,z);N("changed",z)}};var lb=function(){var e=l.getElementsByTagNameNS(c,"defs");if(e.length>0)e=e[0];else{e=f.createElementNS(c,"defs");l.firstChild?l.insertBefore(e,l.firstChild.nextSibling):l.appendChild(e)}return e},Qb=this.setGradient=function(e){if(!(!bb[e+"_paint"]||bb[e+"_paint"].type=="solidColor")){var h=b[e+"Grad"],m=Pb(h),
z=lb();if(m)h=m;else{h=z.appendChild(f.importNode(h,true));h.id=ja()}b.setColor(e,"url(#"+h.id+")");if(e=="canvas")(e=document.getElementById("canvas_background"))&&e.setAttribute("fill","url(#"+h.id+")")}},Pb=function(e){var h=lb();h=$(h).find("linearGradient, radialGradient");for(var m=h.length,z=["r","cx","cy","fx","fy"];m--;){var w=h[m];if(e.tagName=="linearGradient"){if(e.getAttribute("x1")!=w.getAttribute("x1")||e.getAttribute("y1")!=w.getAttribute("y1")||e.getAttribute("x2")!=w.getAttribute("x2")||
e.getAttribute("y2")!=w.getAttribute("y2"))continue}else{var H=$(e).attr(z),A=$(w).attr(z),v=false;$.each(z,function(k,u){if(H[u]!=A[u])v=true});if(v)continue}var F=e.getElementsByTagNameNS(c,"stop"),I=w.getElementsByTagNameNS(c,"stop");if(F.length==I.length){for(var D=F.length;D--;){var G=F[D],L=I[D];if(G.getAttribute("offset")!=L.getAttribute("offset")||G.getAttribute("stop-opacity")!=L.getAttribute("stop-opacity")||G.getAttribute("stop-color")!=L.getAttribute("stop-color"))break}if(D==-1)return w}}return null};
e.getAttribute("y2")!=w.getAttribute("y2"))continue}else{var H=$(e).attr(z),A=$(w).attr(z),v=false;$.each(z,function(k,u){if(H[u]!=A[u])v=true});if(v)continue}var F=e.getElementsByTagNameNS(c,"stop"),I=w.getElementsByTagNameNS(c,"stop");if(F.length==I.length){for(var E=F.length;E--;){var G=F[E],L=I[E];if(G.getAttribute("offset")!=L.getAttribute("offset")||G.getAttribute("stop-opacity")!=L.getAttribute("stop-opacity")||G.getAttribute("stop-color")!=L.getAttribute("stop-color"))break}if(E==-1)return w}}return null};
this.setPaint=function(e,h){var m=new $.jGraduate.Paint(h);this.setPaintOpacity(e,m.alpha/100,true);bb[e+"_paint"]=m;switch(m.type){case "solidColor":if(m.solidColor!="none"&&m.solidColor!="#none")this.setColor(e,"#"+m.solidColor);else{this.setColor(e,"none");document.querySelector(e=="fill"?"#fill_color rect":"#stroke_color rect").setAttribute("fill","none")}break;case "linearGradient":case "radialGradient":b[e+"Grad"]=m[m.type];Qb(e)}};this.getStrokeWidth=function(){return bb.stroke_width};this.setStrokeWidth=
function(e){if(e==0&&["line","path"].indexOf(Ea)>=0)b.setStrokeWidth(1);else{bb.stroke_width=e;for(var h=[],m=J.length;m--;){var z=J[m];if(z)z.tagName=="g"?svgedit.utilities.walkTree(z,function(w){w.nodeName!="g"&&h.push(w)}):h.push(z)}if(h.length>0){gb("stroke-width",e,h);N("changed",J)}}};this.setStrokeAttr=function(e,h){M[e.replace("-","_")]=h;for(var m=[],z=J.length;z--;){var w=J[z];if(w)w.tagName=="g"?svgedit.utilities.walkTree(w,function(H){H.nodeName!="g"&&m.push(H)}):m.push(w)}if(m.length>
0){gb(e,h,m);N("changed",J)}};this.getStyle=function(){return M};this.getOpacity=function(){return M.opacity};this.setOpacity=function(e){M.opacity=e;gb("opacity",e)};this.getFillOpacity=function(){return M.fill_opacity};this.getStrokeOpacity=function(){return M.stroke_opacity};this.setPaintOpacity=function(e,h,m){M[e+"_opacity"]=h;m?xb(e+"-opacity",h):gb(e+"-opacity",h)};this.getBlur=function(e){var h=0;if(e)if(e.getAttribute("filter"))if(e=qa(e.id+"_blur"))h=e.firstChild.getAttribute("stdDeviation");
return h};(function(){function e(){var w=b.undoMgr.finishUndoableChange();h.addSubCommand(w);ya(h);m=h=null}var h=null,m=null,z=false;b.setBlurNoUndo=function(w){if(m)if(w===0){xb("filter","");z=true}else{var H=J[0];z&&xb("filter","url(#"+H.id+"_blur)");if(svgedit.browser.isWebkit()){H.removeAttribute("filter");H.setAttribute("filter","url(#"+H.id+"_blur)")}xb("stdDeviation",w,[m.firstChild]);b.setBlurOffsets(m,w)}else b.setBlur(w)};b.setBlurOffsets=function(w,H){if(H>3)ma(w,{x:"-50%",y:"-50%",width:"200%",
0){gb(e,h,m);N("changed",J)}};this.getStyle=function(){return M};this.getOpacity=function(){return M.opacity};this.setOpacity=function(e){M.opacity=e;gb("opacity",e)};this.getFillOpacity=function(){return M.fill_opacity};this.getStrokeOpacity=function(){return M.stroke_opacity};this.setPaintOpacity=function(e,h,m){M[e+"_opacity"]=h;m?yb(e+"-opacity",h):gb(e+"-opacity",h)};this.getBlur=function(e){var h=0;if(e)if(e.getAttribute("filter"))if(e=qa(e.id+"_blur"))h=e.firstChild.getAttribute("stdDeviation");
return h};(function(){function e(){var w=b.undoMgr.finishUndoableChange();h.addSubCommand(w);ya(h);m=h=null}var h=null,m=null,z=false;b.setBlurNoUndo=function(w){if(m)if(w===0){yb("filter","");z=true}else{var H=J[0];z&&yb("filter","url(#"+H.id+"_blur)");if(svgedit.browser.isWebkit()){H.removeAttribute("filter");H.setAttribute("filter","url(#"+H.id+"_blur)")}yb("stdDeviation",w,[m.firstChild]);b.setBlurOffsets(m,w)}else b.setBlur(w)};b.setBlurOffsets=function(w,H){if(H>3)ma(w,{x:"-50%",y:"-50%",width:"200%",
height:"200%"},100);else if(!svgedit.browser.isWebkit()){w.removeAttribute("x");w.removeAttribute("y");w.removeAttribute("width");w.removeAttribute("height")}};b.setBlur=function(w,H){if(h)e();else{var A=J[0],v=A.id;m=qa(v+"_blur");w-=0;var F=new za;if(m){if(w===0)m=null}else{var I=Q({element:"feGaussianBlur",attr:{"in":"SourceGraphic",stdDeviation:w}});m=Q({element:"filter",attr:{id:v+"_blur"}});m.appendChild(I);lb().appendChild(m);F.addSubCommand(new Ca(m))}I={filter:A.getAttribute("filter")};if(w===
0){A.removeAttribute("filter");F.addSubCommand(new Na(A,I))}else{gb("filter","url(#"+v+"_blur)");F.addSubCommand(new Na(A,I));b.setBlurOffsets(m,w);h=F;b.undoMgr.beginUndoableChange("stdDeviation",[m?m.firstChild:null]);if(H){b.setBlurNoUndo(w);e()}}}}})();this.getBold=function(){var e=J[0];if(e!=null&&e.tagName=="text"&&J[1]==null)return e.getAttribute("font-weight")=="bold";return false};this.setBold=function(e){var h=J[0];if(h!=null&&h.tagName=="text"&&J[1]==null)gb("font-weight",e?"bold":"normal");
J[0].textContent||hb.setCursor()};this.getItalic=function(){var e=J[0];if(e!=null&&e.tagName=="text"&&J[1]==null)return e.getAttribute("font-style")=="italic";return false};this.setItalic=function(e){var h=J[0];if(h!=null&&h.tagName=="text"&&J[1]==null)gb("font-style",e?"italic":"normal");J[0].textContent||hb.setCursor()};this.getFontFamily=function(){return Za.font_family};this.setFontFamily=function(e){Za.font_family=e;gb("font-family",e);J[0]&&!J[0].textContent&&hb.setCursor()};this.setFontColor=
@ -350,158 +350,158 @@ function(e){Za.fill=e;gb("fill",e)};this.getFontSize=function(){return Za.fill};
true;else if(!m)return;var w=new za("Change Image URL");V(h,e);w.addSubCommand(new Na(h,{"#href":z}));m?$(new Image).load(function(){var H=$(h).attr(["width","height"]);$(h).attr({width:this.width,height:this.height});Ha.requestSelector(h).resize();w.addSubCommand(new Na(h,H));ya(w);N("changed",[h])}).attr("src",e):ya(w)}};this.setLinkURL=function(e){var h=J[0];if(h){if(h.tagName!=="a"){h=$(h).parents("a");if(h.length)h=h[0];else return}var m=da(h);if(m!==e){var z=new za("Change Link URL");V(h,e);
z.addSubCommand(new Na(h,{"#href":m}));ya(z)}}};this.elementsAreSame=function(e){return!e.length||e[0]==null?null:J.every(function(h){return h&&J[0]?h.nodeName==J[0].nodeName:null})};this.setRectRadius=function(e){b.elementsAreSame(J)&&J[0].tagName=="rect"&&J.forEach(function(h){var m=h.getAttribute("rx");if(m!=e){h.setAttribute("rx",e);h.setAttribute("ry",e);ya(new Na(h,{rx:m,ry:m},"Radius"));N("changed",[h])}})};this.makeHyperlink=function(e){b.groupSelectedElements("a",e)};this.removeHyperlink=
function(){b.ungroupSelectedElement()};this.setSegType=function(e){Ja.setSegType(e)};this.convertToPath=function(e,h){if(e==null)$.each(J,function(U,S){S&&b.convertToPath(S)});else{if(!h)var m=new za("Convert element to Path");var z=h?{}:{fill:M.fill,"fill-opacity":M.fill_opacity,stroke:M.stroke,"stroke-width":M.stroke_width,"stroke-dasharray":M.stroke_dasharray,"stroke-linejoin":M.stroke_linejoin,"stroke-linecap":M.stroke_linecap,"stroke-opacity":M.stroke_opacity,opacity:M.opacity,visibility:"hidden"};
$.each(["marker-start","marker-end","marker-mid","filter","clip-path"],function(){if(e.getAttribute(this))z[this]=e.getAttribute(this)});var w=Q({element:"path",attr:z}),H=e.getAttribute("transform");H&&w.setAttribute("transform",H);var A=e.id,v=e.parentNode;e.nextSibling?v.insertBefore(w,e):v.appendChild(w);var F="",I=function(U){$.each(U,function(S,X){var aa=X[1];F+=X[0];for(var ga=0;ga<aa.length;ga+=2)F+=aa[ga]+","+aa[ga+1]+" "})},D=1.81;switch(e.tagName){case "ellipse":case "circle":var G=$(e).attr(["rx",
"ry","cx","cy"]),L=G.cx,k=G.cy,u=G.rx;G=G.ry;if(e.tagName=="circle")u=G=$(e).attr("r");I([["M",[L-u,k]],["C",[L-u,k-G/D,L-u/D,k-G,L,k-G]],["C",[L+u/D,k-G,L+u,k-G/D,L+u,k]],["C",[L+u,k+G/D,L+u/D,k+G,L,k+G]],["C",[L-u/D,k+G,L-u,k+G/D,L-u,k]],["Z",[]]]);break;case "path":F=e.getAttribute("d");break;case "line":G=$(e).attr(["x1","y1","x2","y2"]);F="M"+G.x1+","+G.y1+"L"+G.x2+","+G.y2;break;case "polyline":case "polygon":F="M"+e.getAttribute("points");break;case "rect":G=$(e).attr(["rx","ry"]);u=G.rx;G=
G.ry;var C=e.getBBox();L=C.x;k=C.y;var E=C.width;C=C.height;D=4-D;!u&&!G?I([["M",[L,k]],["L",[L+E,k]],["L",[L+E,k+C]],["L",[L,k+C]],["L",[L,k]],["Z",[]]]):I([["M",[L,k+G]],["C",[L,k+G/D,L+u/D,k,L+u,k]],["L",[L+E-u,k]],["C",[L+E-u/D,k,L+E,k+G/D,L+E,k+G]],["L",[L+E,k+C-G]],["C",[L+E,k+C-G/D,L+E-u/D,k+C,L+E-u,k+C]],["L",[L+u,k+C]],["C",[L+u/D,k+C,L,k+C-G/D,L,k+C-G]],["L",[L,k+G]],["Z",[]]]);break;default:w.parentNode.removeChild(w)}F&&w.setAttribute("d",F);if(h){Ja.resetOrientation(w);m=false;try{m=
w.getBBox()}catch(P){}w.parentNode.removeChild(w);return m}else{if(H){H=Y(w);pa(H)&&Ja.resetOrientation(w)}m.addSubCommand(new Ka(e,e.nextSibling,v));m.addSubCommand(new Ca(w));Pa();e.parentNode.removeChild(e);w.setAttribute("id",A);w.removeAttribute("visibility");vb([w],true);ya(m)}}};var xb=this.changeSelectedAttributeNoUndo=function(e,h,m){var z=d.suspendRedraw(1E3);Ea=="pathedit"&&Ja.moveNode(e,h);m=m||J;for(var w=m.length,H=["g","polyline","path"];w--;){var A=m[w];if(A!=null){Ea==="textedit"&&
$.each(["marker-start","marker-end","marker-mid","filter","clip-path"],function(){if(e.getAttribute(this))z[this]=e.getAttribute(this)});var w=Q({element:"path",attr:z}),H=e.getAttribute("transform");H&&w.setAttribute("transform",H);var A=e.id,v=e.parentNode;e.nextSibling?v.insertBefore(w,e):v.appendChild(w);var F="",I=function(U){$.each(U,function(S,Y){var aa=Y[1];F+=Y[0];for(var ga=0;ga<aa.length;ga+=2)F+=aa[ga]+","+aa[ga+1]+" "})},E=1.81;switch(e.tagName){case "ellipse":case "circle":var G=$(e).attr(["rx",
"ry","cx","cy"]),L=G.cx,k=G.cy,u=G.rx;G=G.ry;if(e.tagName=="circle")u=G=$(e).attr("r");I([["M",[L-u,k]],["C",[L-u,k-G/E,L-u/E,k-G,L,k-G]],["C",[L+u/E,k-G,L+u,k-G/E,L+u,k]],["C",[L+u,k+G/E,L+u/E,k+G,L,k+G]],["C",[L-u/E,k+G,L-u,k+G/E,L-u,k]],["Z",[]]]);break;case "path":F=e.getAttribute("d");break;case "line":G=$(e).attr(["x1","y1","x2","y2"]);F="M"+G.x1+","+G.y1+"L"+G.x2+","+G.y2;break;case "polyline":case "polygon":F="M"+e.getAttribute("points");break;case "rect":G=$(e).attr(["rx","ry"]);u=G.rx;G=
G.ry;var C=e.getBBox();L=C.x;k=C.y;var D=C.width;C=C.height;E=4-E;!u&&!G?I([["M",[L,k]],["L",[L+D,k]],["L",[L+D,k+C]],["L",[L,k+C]],["L",[L,k]],["Z",[]]]):I([["M",[L,k+G]],["C",[L,k+G/E,L+u/E,k,L+u,k]],["L",[L+D-u,k]],["C",[L+D-u/E,k,L+D,k+G/E,L+D,k+G]],["L",[L+D,k+C-G]],["C",[L+D,k+C-G/E,L+D-u/E,k+C,L+D-u,k+C]],["L",[L+u,k+C]],["C",[L+u/E,k+C,L,k+C-G/E,L,k+C-G]],["L",[L,k+G]],["Z",[]]]);break;default:w.parentNode.removeChild(w)}F&&w.setAttribute("d",F);if(h){Ja.resetOrientation(w);m=false;try{m=
w.getBBox()}catch(P){}w.parentNode.removeChild(w);return m}else{if(H){H=X(w);pa(H)&&Ja.resetOrientation(w)}m.addSubCommand(new Ka(e,e.nextSibling,v));m.addSubCommand(new Ca(w));Qa();e.parentNode.removeChild(e);w.setAttribute("id",A);w.removeAttribute("visibility");vb([w],true);ya(m)}}};var yb=this.changeSelectedAttributeNoUndo=function(e,h,m){var z=d.suspendRedraw(1E3);Ea=="pathedit"&&Ja.moveNode(e,h);m=m||J;for(var w=m.length,H=["g","polyline","path"];w--;){var A=m[w];if(A!=null){Ea==="textedit"&&
e!=="#text"&&A.textContent.length&&hb.toSelectMode(A);if((e==="x"||e==="y")&&H.indexOf(A.tagName)>=0){var v=getStrokedBBox([A]);b.moveSelectedElements((e==="x"?h-v.x:0)*o,(e==="y"?h-v.y:0)*o,true)}else{v=e==="#text"?A.textContent:A.getAttribute(e);if(v==null)v="";if(v!==String(h)){if(e=="#text"){svgedit.utilities.getBBox(A);A.textContent=h}else e=="#href"?V(A,h):A.setAttribute(e,h);J.indexOf(A)>=0&&setTimeout(function(){A.parentNode&&Ha.requestSelector(A).resize()},0);v=oa(A);if(v!=0&&e!="transform")for(var F=
Y(A),I=F.numberOfItems;I--;)if(F.getItem(I).type==4){F.removeItem(I);var D=svgedit.utilities.getBBox(A),G=O(D.x+D.width/2,D.y+D.height/2,fa(F).matrix);D=G.x;G=G.y;var L=d.createSVGTransform();L.setRotate(v,D,G);F.insertItemBefore(L,I);break}}}}}d.unsuspendRedraw(z)},gb=this.changeSelectedAttribute=function(e,h,m){m=m||J;b.undoMgr.beginUndoableChange(e,m);xb(e,h,m);e=b.undoMgr.finishUndoableChange();e.isEmpty()||ya(e)};this.deleteSelectedElements=function(){for(var e=new za("Delete Elements"),h=J.length,
m=[],z=0;z<h;++z){var w=J[z];if(w==null)break;var H=w.parentNode,A=w;Ha.releaseSelector(A);svgedit.path.removePath_(A.id);if(H.tagName==="a"&&H.childNodes.length===1){A=H;H=H.parentNode}var v=A.nextSibling;A=H.removeChild(A);m.push(w);J[z]=null;e.addSubCommand(new Ka(A,v,H))}e.isEmpty()||ya(e);N("changed",m);Pa()};this.cutSelectedElements=function(){for(var e=new za("Cut Elements"),h=J.length,m=[],z=0;z<h;++z){var w=J[z];if(w==null)break;var H=w.parentNode,A=w;Ha.releaseSelector(A);svgedit.path.removePath_(A.id);
var v=A.nextSibling;A=H.removeChild(A);m.push(w);J[z]=null;e.addSubCommand(new Ka(A,v,H))}e.isEmpty()||ya(e);N("changed",m);Pa();b.clipBoard=m};this.copySelectedElements=function(){b.clipBoard=$.merge([],J)};this.pasteElements=function(){var e=b.clipBoard,h=e.length;if(h){for(var m=[],z=new za("Paste elements");h--;){var w=e[h];if(w){var H=la(w);if(!qa(w.id))H.id=w.id;m.push(H);(K||B().getCurrentLayer()).appendChild(H);z.addSubCommand(new Ca(H))}}svgCanvas.clearSelection();setTimeout(function(){Bb(m)},
X(A),I=F.numberOfItems;I--;)if(F.getItem(I).type==4){F.removeItem(I);var E=svgedit.utilities.getBBox(A),G=O(E.x+E.width/2,E.y+E.height/2,fa(F).matrix);E=G.x;G=G.y;var L=d.createSVGTransform();L.setRotate(v,E,G);F.insertItemBefore(L,I);break}}}}}d.unsuspendRedraw(z)},gb=this.changeSelectedAttribute=function(e,h,m){m=m||J;b.undoMgr.beginUndoableChange(e,m);yb(e,h,m);e=b.undoMgr.finishUndoableChange();e.isEmpty()||ya(e)};this.deleteSelectedElements=function(){for(var e=new za("Delete Elements"),h=J.length,
m=[],z=0;z<h;++z){var w=J[z];if(w==null)break;var H=w.parentNode,A=w;Ha.releaseSelector(A);svgedit.path.removePath_(A.id);if(H.tagName==="a"&&H.childNodes.length===1){A=H;H=H.parentNode}var v=A.nextSibling;A=H.removeChild(A);m.push(w);J[z]=null;e.addSubCommand(new Ka(A,v,H))}e.isEmpty()||ya(e);N("changed",m);Qa()};this.cutSelectedElements=function(){for(var e=new za("Cut Elements"),h=J.length,m=[],z=0;z<h;++z){var w=J[z];if(w==null)break;var H=w.parentNode,A=w;Ha.releaseSelector(A);svgedit.path.removePath_(A.id);
var v=A.nextSibling;A=H.removeChild(A);m.push(w);J[z]=null;e.addSubCommand(new Ka(A,v,H))}e.isEmpty()||ya(e);N("changed",m);Qa();b.clipBoard=m};this.copySelectedElements=function(){b.clipBoard=$.merge([],J)};this.pasteElements=function(){var e=b.clipBoard,h=e.length;if(h){for(var m=[],z=new za("Paste elements");h--;){var w=e[h];if(w){var H=la(w);if(!qa(w.id))H.id=w.id;m.push(H);(K||B().getCurrentLayer()).appendChild(H);z.addSubCommand(new Ca(H))}}svgCanvas.clearSelection();setTimeout(function(){xb(m)},
100);ya(z);N("changed",m)}};this.groupSelectedElements=function(e){e||(e="g");var h="";switch(e){case "a":h="Make hyperlink";var m="";if(arguments.length>1)m=arguments[1];break;default:e="g";h="Group Elements"}h=new za(h);var z=Q({element:e,attr:{id:ja()}});e==="a"&&V(z,m);h.addSubCommand(new Ca(z));for(m=J.length;m--;){var w=J[m];if(w!=null){if(w.parentNode.tagName==="a"&&w.parentNode.childNodes.length===1)w=w.parentNode;var H=w.nextSibling,A=w.parentNode;z.appendChild(w);h.addSubCommand(new Ia(w,
H,A))}}h.isEmpty()||ya(h);Bb([z],true)};var Mb=this.pushGroupProperties=function(e,h){var m=e.childNodes,z=m.length,w=e.getAttribute("transform"),H=Y(e),A=fa(H).matrix,v=new za("Push group properties"),F=0,I=oa(e),D=$(e).attr(["filter","opacity"]),G,L;for(F=0;F<z;F++){var k=m[F];if(k.nodeType===1){if(D.opacity!==null&&D.opacity!==1){k.getAttribute("opacity");var u=Math.round((k.getAttribute("opacity")||1)*D.opacity*100)/100;gb("opacity",u,[k])}if(D.filter){var C=u=this.getBlur(k);L||(L=this.getBlur(e));
if(u)u=L-0+(u-0);else if(u===0)u=L;if(C)G=R(k.getAttribute("filter"));else if(G){G=la(G);lb().appendChild(G)}else G=R(D.filter);G.id=k.id+"_"+(G.firstChild.tagName==="feGaussianBlur"?"blur":"filter");gb("filter","url(#"+G.id+")",[k]);if(u){gb("stdDeviation",u,[G.firstChild]);b.setBlurOffsets(G,u)}}u=Y(k);if(~k.tagName.indexOf("Gradient"))u=null;if(u)if(k.tagName!=="defs")if(H.numberOfItems){if(I&&H.numberOfItems==1){var E=H.getItem(0).matrix,P=d.createSVGMatrix();if(C=oa(k))P=u.getItem(0).matrix;
var U=svgedit.utilities.getBBox(k),S=fa(u).matrix,X=O(U.x+U.width/2,U.y+U.height/2,S);U=I+C;S=d.createSVGTransform();S.setRotate(U,X.x,X.y);E=ia(E,P,S.matrix.inverse());C&&u.removeItem(0);if(U)u.numberOfItems?u.insertItemBefore(S,0):u.appendItem(S);if(E.e||E.f){C=d.createSVGTransform();C.setTranslate(E.e,E.f);u.numberOfItems?u.insertItemBefore(C,0):u.appendItem(C)}}else{C=k.getAttribute("transform");E={};E.transform=C?C:"";C=d.createSVGTransform();E=fa(u).matrix;P=E.inverse();E=ia(P,A,E);C.setMatrix(E);
u.appendItem(C)}(k=Xa(k))&&v.addSubCommand(k)}}}if(w){E={};E.transform=w;e.setAttribute("transform","");e.removeAttribute("transform");v.addSubCommand(new Na(e,E))}if(h&&!v.isEmpty())return v};this.ungroupSelectedElement=function(){var e=J[0];if($(e).data("gsvg")||$(e).data("symbol"))Db(e);else if(e.tagName==="use"){var h=qa(da(e).substr(1));$(e).data("symbol",h).data("ref",h);Db(e)}else{h=$(e).parents("a");if(h.length)e=h[0];if(e.tagName==="g"||e.tagName==="a"){h=new za("Ungroup Elements");var m=
Mb(e,true);m&&h.addSubCommand(m);m=e.parentNode;for(var z=e.nextSibling,w=Array(e.childNodes.length),H=0;e.firstChild;){var A=e.firstChild,v=A.nextSibling,F=A.parentNode;if(A.tagName==="title"){h.addSubCommand(new Ka(A,A.nextSibling,F));F.removeChild(A)}else{w[H++]=A=m.insertBefore(A,z);h.addSubCommand(new Ia(A,v,F))}}Pa();z=e.nextSibling;e=m.removeChild(e);h.addSubCommand(new Ka(e,z,m));h.isEmpty()||ya(h);vb(w)}}};this.moveToTopSelectedElement=function(){var e=J[0];if(e!=null){e=e;var h=e.parentNode,
H,A))}}h.isEmpty()||ya(h);xb([z],true)};var Mb=this.pushGroupProperties=function(e,h){var m=e.childNodes,z=m.length,w=e.getAttribute("transform"),H=X(e),A=fa(H).matrix,v=new za("Push group properties"),F=0,I=oa(e),E=$(e).attr(["filter","opacity"]),G,L;for(F=0;F<z;F++){var k=m[F];if(k.nodeType===1){if(E.opacity!==null&&E.opacity!==1){k.getAttribute("opacity");var u=Math.round((k.getAttribute("opacity")||1)*E.opacity*100)/100;gb("opacity",u,[k])}if(E.filter){var C=u=this.getBlur(k);L||(L=this.getBlur(e));
if(u)u=L-0+(u-0);else if(u===0)u=L;if(C)G=R(k.getAttribute("filter"));else if(G){G=la(G);lb().appendChild(G)}else G=R(E.filter);G.id=k.id+"_"+(G.firstChild.tagName==="feGaussianBlur"?"blur":"filter");gb("filter","url(#"+G.id+")",[k]);if(u){gb("stdDeviation",u,[G.firstChild]);b.setBlurOffsets(G,u)}}u=X(k);if(~k.tagName.indexOf("Gradient"))u=null;if(u)if(k.tagName!=="defs")if(H.numberOfItems){if(I&&H.numberOfItems==1){var D=H.getItem(0).matrix,P=d.createSVGMatrix();if(C=oa(k))P=u.getItem(0).matrix;
var U=svgedit.utilities.getBBox(k),S=fa(u).matrix,Y=O(U.x+U.width/2,U.y+U.height/2,S);U=I+C;S=d.createSVGTransform();S.setRotate(U,Y.x,Y.y);D=ia(D,P,S.matrix.inverse());C&&u.removeItem(0);if(U)u.numberOfItems?u.insertItemBefore(S,0):u.appendItem(S);if(D.e||D.f){C=d.createSVGTransform();C.setTranslate(D.e,D.f);u.numberOfItems?u.insertItemBefore(C,0):u.appendItem(C)}}else{C=k.getAttribute("transform");D={};D.transform=C?C:"";C=d.createSVGTransform();D=fa(u).matrix;P=D.inverse();D=ia(P,A,D);C.setMatrix(D);
u.appendItem(C)}(k=Ua(k))&&v.addSubCommand(k)}}}if(w){D={};D.transform=w;e.setAttribute("transform","");e.removeAttribute("transform");v.addSubCommand(new Na(e,D))}if(h&&!v.isEmpty())return v};this.ungroupSelectedElement=function(){var e=J[0];if($(e).data("gsvg")||$(e).data("symbol"))Db(e);else if(e.tagName==="use"){var h=qa(da(e).substr(1));$(e).data("symbol",h).data("ref",h);Db(e)}else{h=$(e).parents("a");if(h.length)e=h[0];if(e.tagName==="g"||e.tagName==="a"){h=new za("Ungroup Elements");var m=
Mb(e,true);m&&h.addSubCommand(m);m=e.parentNode;for(var z=e.nextSibling,w=Array(e.childNodes.length),H=0;e.firstChild;){var A=e.firstChild,v=A.nextSibling,F=A.parentNode;if(A.tagName==="title"){h.addSubCommand(new Ka(A,A.nextSibling,F));F.removeChild(A)}else{w[H++]=A=m.insertBefore(A,z);h.addSubCommand(new Ia(A,v,F))}}Qa();z=e.nextSibling;e=m.removeChild(e);h.addSubCommand(new Ka(e,z,m));h.isEmpty()||ya(h);vb(w)}}};this.moveToTopSelectedElement=function(){var e=J[0];if(e!=null){e=e;var h=e.parentNode,
m=e.nextSibling;e=e.parentNode.appendChild(e);if(m!=e.nextSibling){ya(new Ia(e,m,h,"top"));N("changed",[e])}}};this.moveToBottomSelectedElement=function(){var e=J[0];if(e!=null){e=e;var h=e.parentNode,m=e.nextSibling,z=e.parentNode.firstChild;if(z.tagName=="title")z=z.nextSibling;if(z.tagName=="defs")z=z.nextSibling;e=e.parentNode.insertBefore(e,z);if(m!=e.nextSibling){ya(new Ia(e,m,h,"bottom"));N("changed",[e])}}};this.moveUpDownSelected=function(e){var h=J[0];if(h){mb=[];var m,z,w=$(tb(getStrokedBBox([h]))).toArray();
e=="Down"&&w.reverse();$.each(w,function(){if(z){m=this;return false}else if(this==h)z=true});if(m){w=h.parentNode;var H=h.nextSibling;$(m)[e=="Down"?"before":"after"](h);if(H!=h.nextSibling){ya(new Ia(h,H,w,"Move "+e));N("changed",[h])}}}};this.moveSelectedElements=function(e,h,m){if(e.constructor!=Array){e/=o;h/=o}m=m||true;for(var z=new za("position"),w=J.length;w--;){var H=J[w];if(H!=null){var A=d.createSVGTransform(),v=Y(H);e.constructor==Array?A.setTranslate(e[w],h[w]):A.setTranslate(e,h);v.numberOfItems?
v.insertItemBefore(A,0):v.appendItem(A);(A=Xa(H))&&z.addSubCommand(A);Ha.requestSelector(H).resize()}}if(!z.isEmpty()){m&&ya(z);N("changed",J);return z}};this.cloneSelectedElements=function(e,h,m){for(var z=new za("Clone Elements"),w=J.length,H=0;H<w;++H)if(J[H]==null)break;w=J.slice(0,H);this.clearSelection(true);for(H=w.length;H--;){var A=la(w[H]);m&&A.setAttribute("transform","");(K||B().getCurrentLayer()).appendChild(A);z.addSubCommand(new Ca(A))}if(!z.isEmpty()){vb(w.reverse());this.moveSelectedElements(e,
h,false);ya(z)}return A};this.alignSelectedElements=function(e,h){var m=[],z=Number.MAX_VALUE,w=Number.MIN_VALUE,H=Number.MAX_VALUE,A=Number.MIN_VALUE,v=Number.MIN_VALUE,F=Number.MIN_VALUE,I=J.length;if(I){for(var D=0;D<I;++D){if(J[D]==null)break;m[D]=getStrokedBBox([J[D]]);switch(h){case "smallest":if((e=="l"||e=="c"||e=="r")&&(v==Number.MIN_VALUE||v>m[D].width)||(e=="t"||e=="m"||e=="b")&&(F==Number.MIN_VALUE||F>m[D].height)){z=m[D].x;H=m[D].y;w=m[D].x+m[D].width;A=m[D].y+m[D].height;v=m[D].width;
F=m[D].height}break;case "largest":if((e=="l"||e=="c"||e=="r")&&(v==Number.MIN_VALUE||v<m[D].width)||(e=="t"||e=="m"||e=="b")&&(F==Number.MIN_VALUE||F<m[D].height)){z=m[D].x;H=m[D].y;w=m[D].x+m[D].width;A=m[D].y+m[D].height;v=m[D].width;F=m[D].height}break;default:if(m[D].x<z)z=m[D].x;if(m[D].y<H)H=m[D].y;if(m[D].x+m[D].width>w)w=m[D].x+m[D].width;if(m[D].y+m[D].height>A)A=m[D].y+m[D].height}}if(h=="page"){H=z=0;w=b.contentW;A=b.contentH}v=Array(I);F=Array(I);for(D=0;D<I;++D){if(J[D]==null)break;
var G=m[D];v[D]=0;F[D]=0;switch(e){case "l":v[D]=z-G.x;break;case "c":v[D]=(z+w)/2-(G.x+G.width/2);break;case "r":v[D]=w-(G.x+G.width);break;case "t":F[D]=H-G.y;break;case "m":F[D]=(H+A)/2-(G.y+G.height/2);break;case "b":F[D]=A-(G.y+G.height)}}this.moveSelectedElements(v,F)}};this.contentW=Eb().w;this.contentH=Eb().h;this.updateCanvas=function(e,h){d.setAttribute("width",e);d.setAttribute("height",h);var m=$("#canvasBackground")[0],z=l.getAttribute("x"),w=l.getAttribute("y"),H=e/2-this.contentW*o/
2,A=h/2-this.contentH*o/2;ma(l,{width:this.contentW*o,height:this.contentH*o,x:H,y:A,viewBox:"0 0 "+this.contentW+" "+this.contentH});ma(m,{width:l.getAttribute("width"),height:l.getAttribute("height"),x:H,y:A});(m=qa("background_image"))&&ma(m,{width:"100%",height:"100%"});Ha.selectorParentGroup.setAttribute("transform","translate("+H+","+A+")");return{x:H,y:A,old_x:z,old_y:w,d_x:H-z,d_y:A-w}};this.setBackground=function(e,h){var m=qa("canvasBackground"),z=$(m).find("rect")[0],w=qa("background_image");
z.setAttribute("fill",e);if(h){if(!w){w=f.createElementNS(c,"image");ma(w,{id:"background_image",width:"100%",height:"100%",preserveAspectRatio:"xMinYMin",style:"pointer-events:none"})}V(w,h);m.appendChild(w)}else w&&w.parentNode.removeChild(w)};this.cycleElement=function(e){var h=J[0],m=false,z=ub(K||B().getCurrentLayer());if(z.length){if(h==null){e=e?z.length-1:0;m=z[e]}else for(var w=z.length;w--;)if(z[w]==h){e=e?w-1:w+1;if(e>=z.length)e=0;else if(e<0)e=z.length-1;m=z[e];break}Bb([m],true);N("selected",
J)}};this.clear();this.getPrivateMethods=function(){return{addCommandToHistory:ya,setGradient:Qb,addSvgElementFromJson:Q,assignAttributes:ma,BatchCommand:za,call:N,ChangeElementCommand:Na,copyElem:la,ffClone:ea,findDefs:lb,findDuplicateGradient:Pb,getElem:qa,getId:ca,getIntersectionList:tb,getMouseTarget:Ib,getNextId:ja,getPathBBox:Z,getUrlFromAttr:ka,hasMatrixTransform:pa,identifyLayers:Fb,InsertElementCommand:Ca,isIdentity:svgedit.math.isIdentity,logMatrix:Ya,matrixMultiply:ia,MoveElementCommand:Ia,
preventClickDefault:pb,recalculateAllSelectedDimensions:Ga,recalculateDimensions:Xa,remapElement:db,RemoveElementCommand:Ka,removeUnusedDefElems:Kb,round:eb,runExtensions:ob,sanitizeSvg:Fa,SVGEditTransformList:svgedit.transformlist.SVGTransformList,toString:toString,transformBox:svgedit.math.transformBox,transformListToTransform:fa,transformPoint:O,walkTree:svgedit.utilities.walkTree}}};(function(){document.addEventListener("touchstart",touchHandler,true);document.addEventListener("touchmove",touchHandler,true);document.addEventListener("touchend",touchHandler,true);document.addEventListener("touchcancel",touchHandler,true);if(!window.svgEditor)window.svgEditor=function(a){function p(d,l){var q=g.setSvgString(d)!==false;l=l||a.noop;q?l(true):a.alert(uiStrings.notification.errorLoadingSVG,function(){l(false)})}var g,c={},n=false;curConfig={canvas_expansion:1,dimensions:[580,400],
e=="Down"&&w.reverse();$.each(w,function(){if(z){m=this;return false}else if(this==h)z=true});if(m){w=h.parentNode;var H=h.nextSibling;$(m)[e=="Down"?"before":"after"](h);if(H!=h.nextSibling){ya(new Ia(h,H,w,"Move "+e));N("changed",[h])}}}};this.moveSelectedElements=function(e,h,m){if(e.constructor!=Array){e/=o;h/=o}m=m||true;for(var z=new za("position"),w=J.length;w--;){var H=J[w];if(H!=null){var A=d.createSVGTransform(),v=X(H);e.constructor==Array?A.setTranslate(e[w],h[w]):A.setTranslate(e,h);v.numberOfItems?
v.insertItemBefore(A,0):v.appendItem(A);(A=Ua(H))&&z.addSubCommand(A);Ha.requestSelector(H).resize()}}if(!z.isEmpty()){m&&ya(z);N("changed",J);return z}};this.cloneSelectedElements=function(e,h,m){for(var z=new za("Clone Elements"),w=J.length,H=0;H<w;++H)if(J[H]==null)break;w=J.slice(0,H);this.clearSelection(true);H=w.length;for(clones=[];H--;){var A=la(w[H]);if(m){tlist=X(A);tlist.removeItem(m);Ua(A)}(K||B().getCurrentLayer()).appendChild(A);clones.push(A);z.addSubCommand(new Ca(A))}if(!z.isEmpty()){vb(w.reverse());
m||this.moveSelectedElements(e,h,false);ya(z)}return clones};this.alignSelectedElements=function(e,h){var m=[],z=Number.MAX_VALUE,w=Number.MIN_VALUE,H=Number.MAX_VALUE,A=Number.MIN_VALUE,v=Number.MIN_VALUE,F=Number.MIN_VALUE,I=J.length;if(I){for(var E=0;E<I;++E){if(J[E]==null)break;m[E]=getStrokedBBox([J[E]]);switch(h){case "smallest":if((e=="l"||e=="c"||e=="r")&&(v==Number.MIN_VALUE||v>m[E].width)||(e=="t"||e=="m"||e=="b")&&(F==Number.MIN_VALUE||F>m[E].height)){z=m[E].x;H=m[E].y;w=m[E].x+m[E].width;
A=m[E].y+m[E].height;v=m[E].width;F=m[E].height}break;case "largest":if((e=="l"||e=="c"||e=="r")&&(v==Number.MIN_VALUE||v<m[E].width)||(e=="t"||e=="m"||e=="b")&&(F==Number.MIN_VALUE||F<m[E].height)){z=m[E].x;H=m[E].y;w=m[E].x+m[E].width;A=m[E].y+m[E].height;v=m[E].width;F=m[E].height}break;default:if(m[E].x<z)z=m[E].x;if(m[E].y<H)H=m[E].y;if(m[E].x+m[E].width>w)w=m[E].x+m[E].width;if(m[E].y+m[E].height>A)A=m[E].y+m[E].height}}if(h=="page"){H=z=0;w=b.contentW;A=b.contentH}v=Array(I);F=Array(I);for(E=
0;E<I;++E){if(J[E]==null)break;var G=m[E];v[E]=0;F[E]=0;switch(e){case "l":v[E]=z-G.x;break;case "c":v[E]=(z+w)/2-(G.x+G.width/2);break;case "r":v[E]=w-(G.x+G.width);break;case "t":F[E]=H-G.y;break;case "m":F[E]=(H+A)/2-(G.y+G.height/2);break;case "b":F[E]=A-(G.y+G.height)}}this.moveSelectedElements(v,F)}};this.contentW=Eb().w;this.contentH=Eb().h;this.updateCanvas=function(e,h){d.setAttribute("width",e);d.setAttribute("height",h);var m=$("#canvasBackground")[0],z=l.getAttribute("x"),w=l.getAttribute("y"),
H=e/2-this.contentW*o/2,A=h/2-this.contentH*o/2;ma(l,{width:this.contentW*o,height:this.contentH*o,x:H,y:A,viewBox:"0 0 "+this.contentW+" "+this.contentH});ma(m,{width:l.getAttribute("width"),height:l.getAttribute("height"),x:H,y:A});(m=qa("background_image"))&&ma(m,{width:"100%",height:"100%"});Ha.selectorParentGroup.setAttribute("transform","translate("+H+","+A+")");return{x:H,y:A,old_x:z,old_y:w,d_x:H-z,d_y:A-w}};this.setBackground=function(e,h){var m=qa("canvasBackground"),z=$(m).find("rect")[0],
w=qa("background_image");z.setAttribute("fill",e);if(h){if(!w){w=f.createElementNS(c,"image");ma(w,{id:"background_image",width:"100%",height:"100%",preserveAspectRatio:"xMinYMin",style:"pointer-events:none"})}V(w,h);m.appendChild(w)}else w&&w.parentNode.removeChild(w)};this.cycleElement=function(e){var h=J[0],m=false,z=ub(K||B().getCurrentLayer());if(z.length){if(h==null){e=e?z.length-1:0;m=z[e]}else for(var w=z.length;w--;)if(z[w]==h){e=e?w-1:w+1;if(e>=z.length)e=0;else if(e<0)e=z.length-1;m=z[e];
break}xb([m],true);N("selected",J)}};this.clear();this.getPrivateMethods=function(){return{addCommandToHistory:ya,setGradient:Qb,addSvgElementFromJson:Q,assignAttributes:ma,BatchCommand:za,call:N,ChangeElementCommand:Na,copyElem:la,ffClone:ea,findDefs:lb,findDuplicateGradient:Pb,getElem:qa,getId:ca,getIntersectionList:tb,getMouseTarget:Ib,getNextId:ja,getPathBBox:Z,getUrlFromAttr:ka,hasMatrixTransform:pa,identifyLayers:Fb,InsertElementCommand:Ca,isIdentity:svgedit.math.isIdentity,logMatrix:Ya,matrixMultiply:ia,
MoveElementCommand:Ia,preventClickDefault:pb,recalculateAllSelectedDimensions:Ga,recalculateDimensions:Ua,remapElement:db,RemoveElementCommand:Ka,removeUnusedDefElems:Kb,round:eb,runExtensions:ob,sanitizeSvg:Fa,SVGEditTransformList:svgedit.transformlist.SVGTransformList,toString:toString,transformBox:svgedit.math.transformBox,transformListToTransform:fa,transformPoint:O,walkTree:svgedit.utilities.walkTree}}};(function(){document.addEventListener("touchstart",touchHandler,true);document.addEventListener("touchmove",touchHandler,true);document.addEventListener("touchend",touchHandler,true);document.addEventListener("touchcancel",touchHandler,true);if(!window.svgEditor)window.svgEditor=function(a){function p(d,l){var q=g.setSvgString(d)!==false;l=l||a.noop;q?l(true):a.alert(uiStrings.notification.errorLoadingSVG,function(){l(false)})}var g,c={},n=false;curConfig={canvas_expansion:1,dimensions:[580,400],
initFill:{color:"fff",opacity:1},initStroke:{width:1.5,color:"000",opacity:1},initOpacity:1,imgPath:"images/",extPath:"extensions/",jGraduatePath:"jgraduate/images/",extensions:[],initTool:"select",wireframe:false,colorPickerCSS:false,gridSnapping:false,gridColor:"#000",baseUnit:"px",snappingStep:10,showRulers:svgedit.browser.isTouch()?false:true,show_outside_canvas:false,no_save_warning:true,initFont:"Helvetica, Arial, sans-serif"};uiStrings=c.uiStrings={common:{ok:"OK",cancel:"Cancel",key_up:"Up",
key_down:"Down",key_backspace:"Backspace",key_del:"Del"},layers:{layer:"Layer"},notification:{invalidAttrValGiven:"Invalid value given",noContentToFitTo:"No content to fit to",dupeLayerName:"There is already a layer named that!",enterUniqueLayerName:"Please enter a unique layer name",enterNewLayerName:"Please enter the new layer name",layerHasThatName:"Layer already has that name",QmoveElemsToLayer:'Move selected elements to layer "%s"?',QwantToClear:"Do you want to clear the drawing?\nThis will also erase your undo history!",
QwantToOpen:"Do you want to open a new file?\nThis will also erase your undo history!",QerrorsRevertToSource:"There were parsing errors in your SVG source.\nRevert back to original SVG source?",QignoreSourceChanges:"Ignore changes made to SVG source?",featNotSupported:"Feature not supported",enterNewImgURL:"Enter the new image URL",defsFailOnSave:"NOTE: Due to a bug in your browser, this image may appear wrong (missing gradients or elements). It will however appear correct once actually saved.",loadingImage:"Loading image, please wait...",
saveFromBrowser:'Select "Save As..." in your browser to save this image as a %s file.',noteTheseIssues:"Also note the following issues: ",unsavedChanges:"There are unsaved changes.",enterNewLinkURL:"Enter the new hyperlink URL",errorLoadingSVG:"Error: Unable to load SVG data",URLloadFail:"Unable to load from URL",retrieving:'Retrieving "%s" ...'}};var s={},b={};c.curConfig=curConfig;c.tool_scale=1;c.setConfig=function(d){a.extend(true,curConfig,d);if(d.extensions)curConfig.extensions=d.extensions};
c.setCustomHandlers=function(d){c.ready(function(){if(d.open){a('#tool_open > input[type="file"]').remove();a("#tool_open").show();g.open=d.open}if(d.save){c.show_save_warning=false;g.bind("saved",d.save)}d.pngsave&&g.bind("exported",d.pngsave);b=d})};c.randomizeIds=function(){g.randomizeIds(arguments)};c.init=function(){function d(k,u){var C=k.id,E=C.split("_"),P=E[0];E=E[1];u&&g.setStrokeAttr("stroke-"+P,E);qb();xb("#cur_"+P,C,20);a(k).addClass("current").siblings().removeClass("current")}function l(k,
u){var C=document.getElementById("ruler_x_cursor"),E=document.getElementById("ruler_y_cursor"),P=document.getElementById("workarea");document.getElementById("title_show");svgedit.browser.isTouch()&&a("#workarea").unbind("mousemove.rulers").bind("mousemove.rulers",function(Sb){Sb.stopPropagation();C.style.left=Sb.pageX-66+P.scrollLeft+"px";E.style.top=Sb.pageY-48+P.scrollTop+"px"});u||(u=g.getZoom());k||(k=a("#svgcanvas"));for(var U=g.getContentElem(),S=svgedit.units.getTypeMap()[curConfig.baseUnit],
X=0;X<2;X++){var aa=X===0,ga=aa?"x":"y",ra=aa?"width":"height",Ta=U.getAttribute(ga)-0;ga=a("#ruler_"+ga+" canvas:first");$hcanv=ga.clone();ga.replaceWith($hcanv);var Ba=$hcanv[0];var ha=ga=k[ra]()*2;Ba.parentNode.style[ra]=ha+"px";var Sa=0,Qa,ua=Ba.getContext("2d");ua.fillStyle="rgb(200,0,0)";ua.fillRect(0,0,Ba.width,Ba.height);$hcanv.siblings().remove();if(ga>=3E4){var Ma=parseInt(ga/3E4)+1;Qa=Array(Ma);Qa[0]=ua;for(var xa=1;xa<Ma;xa++){Ba[ra]=3E4;var ab=Ba.cloneNode(true);Ba.parentNode.appendChild(ab);
Qa[xa]=ab.getContext("2d")}ab[ra]=ga%3E4;ga=3E4}Ba[ra]=ga;ra=S*u;var Wa=50/ra;Ba=1;for(xa=0;xa<I.length;xa++){Ba=Ma=I[xa];if(Wa<=Ma)break}Wa=Ba*ra;ua.font="normal 9px 'Lucida Grande', sans-serif";ua.fillStyle="#777";for(var cb=Ta/ra%Ba*ra,Hb=cb-Wa;cb<ha;cb+=Wa){Hb+=Wa;xa=Math.round(cb)+0.5;if(aa){ua.moveTo(xa,15);ua.lineTo(xa,0)}else{ua.moveTo(15,xa);ua.lineTo(0,xa)}Ma=(Hb-Ta)/ra;if(Ba>=1)xa=Math.round(Ma);else{xa=(Ba+"").split(".")[1].length;xa=Ma.toFixed(xa)-0}if(xa!==0&&xa!==1E3&&xa%1E3===0)xa=
xa/1E3+"K";if(aa){ua.fillText(xa,cb+2,8);ua.fillStyle="#777"}else{Ma=(xa+"").split("");for(xa=0;xa<Ma.length;xa++){ua.fillText(Ma[xa],1,cb+9+xa*9);ua.fillStyle="#777"}}Ma=Wa/10;for(xa=1;xa<10;xa++){var yb=Math.round(cb+Ma*xa)+0.5;if(Qa&&yb>ga){Sa++;ua.stroke();if(Sa>=Qa.length){xa=10;cb=ha;continue}ua=Qa[Sa];cb-=3E4;yb=Math.round(cb+Ma*xa)+0.5}var Gb=xa%2?12:10;if(aa){ua.moveTo(yb,15);ua.lineTo(yb,Gb)}else{ua.moveTo(15,yb);ua.lineTo(Gb,yb)}}}ua.strokeStyle="#666";ua.stroke()}}(function(){var k=window.opener;
c.setCustomHandlers=function(d){c.ready(function(){if(d.open){a('#tool_open > input[type="file"]').remove();a("#tool_open").show();g.open=d.open}if(d.save){c.show_save_warning=false;g.bind("saved",d.save)}d.pngsave&&g.bind("exported",d.pngsave);b=d})};c.randomizeIds=function(){g.randomizeIds(arguments)};c.init=function(){function d(k,u){var C=k.id,D=C.split("_"),P=D[0];D=D[1];u&&g.setStrokeAttr("stroke-"+P,D);qb();yb("#cur_"+P,C,20);a(k).addClass("current").siblings().removeClass("current")}function l(k,
u){var C=document.getElementById("ruler_x_cursor"),D=document.getElementById("ruler_y_cursor"),P=document.getElementById("workarea");document.getElementById("title_show");svgedit.browser.isTouch()&&a("#workarea").unbind("mousemove.rulers").bind("mousemove.rulers",function(Sb){Sb.stopPropagation();C.style.left=Sb.pageX-66+P.scrollLeft+"px";D.style.top=Sb.pageY-48+P.scrollTop+"px"});u||(u=g.getZoom());k||(k=a("#svgcanvas"));for(var U=g.getContentElem(),S=svgedit.units.getTypeMap()[curConfig.baseUnit],
Y=0;Y<2;Y++){var aa=Y===0,ga=aa?"x":"y",ra=aa?"width":"height",Oa=U.getAttribute(ga)-0;ga=a("#ruler_"+ga+" canvas:first");$hcanv=ga.clone();ga.replaceWith($hcanv);var Ba=$hcanv[0];var ha=ga=k[ra]()*2;Ba.parentNode.style[ra]=ha+"px";var Ta=0,Ra,ta=Ba.getContext("2d");ta.fillStyle="rgb(200,0,0)";ta.fillRect(0,0,Ba.width,Ba.height);$hcanv.siblings().remove();if(ga>=3E4){var Ma=parseInt(ga/3E4)+1;Ra=Array(Ma);Ra[0]=ta;for(var xa=1;xa<Ma;xa++){Ba[ra]=3E4;var ab=Ba.cloneNode(true);Ba.parentNode.appendChild(ab);
Ra[xa]=ab.getContext("2d")}ab[ra]=ga%3E4;ga=3E4}Ba[ra]=ga;ra=S*u;var Xa=50/ra;Ba=1;for(xa=0;xa<I.length;xa++){Ba=Ma=I[xa];if(Xa<=Ma)break}Xa=Ba*ra;ta.font="normal 9px 'Lucida Grande', sans-serif";ta.fillStyle="#777";for(var cb=Oa/ra%Ba*ra,Hb=cb-Xa;cb<ha;cb+=Xa){Hb+=Xa;xa=Math.round(cb)+0.5;if(aa){ta.moveTo(xa,15);ta.lineTo(xa,0)}else{ta.moveTo(15,xa);ta.lineTo(0,xa)}Ma=(Hb-Oa)/ra;if(Ba>=1)xa=Math.round(Ma);else{xa=(Ba+"").split(".")[1].length;xa=Ma.toFixed(xa)-0}if(xa!==0&&xa!==1E3&&xa%1E3===0)xa=
xa/1E3+"K";if(aa){ta.fillText(xa,cb+2,8);ta.fillStyle="#777"}else{Ma=(xa+"").split("");for(xa=0;xa<Ma.length;xa++){ta.fillText(Ma[xa],1,cb+9+xa*9);ta.fillStyle="#777"}}Ma=Xa/10;for(xa=1;xa<10;xa++){var zb=Math.round(cb+Ma*xa)+0.5;if(Ra&&zb>ga){Ta++;ta.stroke();if(Ta>=Ra.length){xa=10;cb=ha;continue}ta=Ra[Ta];cb-=3E4;zb=Math.round(cb+Ma*xa)+0.5}var Gb=xa%2?12:10;if(aa){ta.moveTo(zb,15);ta.lineTo(zb,Gb)}else{ta.moveTo(15,zb);ta.lineTo(Gb,zb)}}}ta.strokeStyle="#666";ta.stroke()}}(function(){var k=window.opener;
if(k)try{var u=k.document.createEvent("Event");u.initEvent("svgEditorReady",true,true);k.document.documentElement.dispatchEvent(u)}catch(C){}})();(function(){a("#canvas_width").val(curConfig.dimensions[0]);a("#canvas_height").val(curConfig.dimensions[1]);a("body").toggleClass("touch",svgedit.browser.isTouch());var k=a.deparam.querystring(true);if(!a.isEmptyObject(k)){if(k.dimensions)k.dimensions=k.dimensions.split(",");if(k.extensions)k.extensions=k.extensions.split(",");if(k.bkgd_color)k.bkgd_color=
"#"+k.bkgd_color;svgEditor.setConfig(k);var u=k.source,C=a.param.querystring();if(!u)if(C.indexOf("source=data:")>=0)u=C.match(/source=(data:[^&]*)/)[1];if(u)if(u.indexOf("data:")===0){u=u.replace(/ /g,"+");c.loadFromDataURI(u)}else c.loadFromString(u);else if(C.indexOf("paramurl=")!==-1)svgEditor.loadFromURL(C.substr(9));else k.url&&svgEditor.loadFromURL(k.url)}})();var q=function(){a.each(curConfig.extensions,function(){var k=this;a.getScript(curConfig.extPath+k,function(u){if(!u){u=document.createElement("script");
u.src=curConfig.extPath+k;document.querySelector("head").appendChild(u)}})})};document.location.protocol==="file:"?setTimeout(q,100):q();a.svgIcons(curConfig.imgPath+"svg_edit_icons.svg",{w:27,h:27,id_match:false,no_img:!svgedit.browser.isWebkit(),fallback_path:curConfig.imgPath,fallback:{logo:"logo.png",select:"select.png",select_node:"select_node.png",pencil:"pencil.png",pen:"line.png",square:"square.png",rect:"square.png",fh_rect:"freehand-square.png",circle:"circle.png",ellipse:"ellipse.png",
fh_ellipse:"freehand-circle.png",path:"path.png",text:"text.png",image:"image.png",zoom:"zoom.png","delete":"delete.png",spapelib:"shapelib.png",node_delete:"node_delete.png",align_left:"align-left.png",align_center:"align-center",align_right:"align-right",align_top:"align-top",align_middle:"align-middle",align_bottom:"align-bottom",arrow_right:"flyouth.png",arrow_down:"dropdown.gif"},placement:{"#logo":"logo","#tool_select":"select","#tool_fhpath":"pencil","#tool_line":"pen","#tool_rect,#tools_rect_show":"rect",
"#tool_square":"square","#tool_fhrect":"fh_rect","#tool_ellipse,#tools_ellipse_show":"ellipse","#tool_circle":"circle","#tool_fhellipse":"fh_ellipse","#tool_path":"path","#tool_text,#layer_rename":"text","#tool_image":"image","#tool_zoom":"zoom","#tool_node_clone":"node_clone","#tool_node_delete":"node_delete","#tool_add_subpath":"add_subpath","#tool_openclose_path":"open_path","#tool_alignleft, #tool_posleft":"align_left","#tool_aligncenter, #tool_poscenter":"align_center","#tool_alignright, #tool_posright":"align_right",
"#tool_aligntop, #tool_postop":"align_top","#tool_alignmiddle, #tool_posmiddle":"align_middle","#tool_alignbottom, #tool_posbottom":"align_bottom","#cur_position":"align","#zoomLabel":"zoom","#palette .palette_item:first, #fill_bg, #stroke_bg":"no_color"},resize:{"#logo .svg_icon":15,".flyout_arrow_horiz .svg_icon":5,"#fill_bg .svg_icon, #stroke_bg .svg_icon":svgedit.browser.isTouch()?24:24,".palette_item:first .svg_icon":svgedit.browser.isTouch()?30:16,"#zoomLabel .svg_icon":16,"#zoom_dropdown .svg_icon":7},
callback:function(){a(".toolbar_button button > svg, .toolbar_button button > img").each(function(){a(this).parent().prepend(this)});a(".tool_button, .tool_button_current").addClass("loaded");var k=a("#tools_left");if(k.length!=0){k.offset();k.outerHeight()}a(".tools_flyout").each(function(){var u=a("#"+this.id+"_show"),C=u.attr("data-curopt");if(!u.children("svg, img").length){C=a(C).children().clone();if(C.length){C[0].removeAttribute("style");u.append(C)}}});svgEditor.runCallbacks();setTimeout(function(){a(".flyout_arrow_horiz:empty").each(function(){a(this).append(a.getSvgIcon("arrow_right").width(5).height(5))})},
1)}});a("#rulers").on("dblclick",function(k){a("#base_unit_container").css({top:k.pageY-10,left:k.pageX-50,display:"block"})});a("#base_unit_container").on("mouseleave mouseenter",function(){t=setTimeout(function(){a("#base_unit_container").fadeOut(500)},200);event.type=="mouseover"&&clearTimeout(t)});a("#base_unit").on("change",function(){savePreferences()});c.canvas=g=new a.SvgCanvas(document.getElementById("svgcanvas"),curConfig);c.show_save_warning=false;c.paintBox={fill:null,stroke:null,canvas:null};
q=navigator.platform.indexOf("Mac")>=0;var B=navigator.userAgent.indexOf("AppleWebKit")>=0,o=q?"meta+":"ctrl+",K=g.pathActions,T=g.undoMgr,M=svgedit.utilities,J=curConfig.imgPath+"placeholder.svg",Q=a("#workarea"),Y=a("#cmenu_canvas"),O=null,ia=1,pa="toolbars",fa="";q||a(".shortcut").each(function(){var k=a(this).text();a(this).text(k.split("\u2318").join("Ctrl+"))});(function(){a("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"});var k=a("#dialog_box"),
u=a("#dialog_buttons"),C=function(E,P,U,S){a("#dialog_content").html("<p>"+P.replace(/\n/g,"</p><p>")+"</p>").toggleClass("prompt",E=="prompt");u.empty();var X=a('<input type="button" value="'+uiStrings.common.ok+'">').appendTo(u);E!="alert"&&a('<input type="button" value="'+uiStrings.common.cancel+'">').appendTo(u).on("click, touchstart",function(){k.hide();U(false)});if(E=="prompt"){var aa=a('<input type="text">').prependTo(u);aa.val(S||"");aa.bind("keydown","return",function(){X.trigger("click touchstart")})}E==
"process"&&X.hide();k.show();X.on("click touchstart",function(){k.hide();var ga=E=="prompt"?aa.val():true;U&&U(ga)}).focus();E=="prompt"&&aa.focus()};a.alert=function(E,P){C("alert",E,P)};a.confirm=function(E,P){C("confirm",E,P)};a.process_cancel=function(E,P){C("process",E,P)};a.prompt=function(E,P,U){C("prompt",E,U,P)}})();var ba=function(){var k=a(".tool_button_current");if(k.length&&k[0].id!=="tool_select"){k.removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button")}g.setMode("select")},
W=null,sa=false,ka=false,da="",V=function(k,u){var C=g.getResolution();a("#svgcanvas").position();var E=g.setBBoxZoom(u,Q.width()-15,Q.height()-15);if(E){var P=E.zoom;E=E.bbox;if(P<0.0010)wa({value:0.1});else{var U=Date.now(),S=P-C.zoom;a("#zoom");var X=C.zoom,aa=function(ga){ga=(ga-U)/500;ga=Math.pow(ga-1,3)+1;g.setZoom(X+S*ga);F();ga<1?requestAnimationFrame(aa):a("#zoom").val(P*100)};aa(Date.now());g.getMode()=="zoom"&&E.width&&ba();lb()}}};a("#cur_context_panel").delegate("a","click",function(){var k=
a(this);k.attr("data-root")?g.leaveContext():g.setContext(k.text());return false});var Z=function(){c.paintBox.fill.prep();c.paintBox.stroke.prep()},oa={},qa=function(k){a.each(k,function(u,C){var E=a(u).children(),P=u+"_show",U=a(P),S=false;E.addClass("tool_button").unbind("click mousedown mouseup").each(function(ga){var ra=C[ga];oa[ra.sel]=ra.fn;if(ra.isDefault)S=ga;ga=function(Ta){var Ba=ra;if(Ta.type==="keydown"){var ha=a(Ba.parent+"_show").hasClass("tool_button_current"),Sa=a(Ba.parent+"_show").attr("data-curopt");
a.each(k[ra.parent],function(ua,Ma){if(Ma.sel==Sa)Ba=!Ta.shiftKey||!ha?Ma:k[ra.parent][ua+1]||k[ra.parent][0]})}if(a(this).hasClass("disabled"))return false;$a(P)&&Ba.fn();var Qa=Ba.icon?a.getSvgIcon(Ba.icon,true):a(Ba.sel).children().eq(0).clone();Qa[0].setAttribute("width",U.width());Qa[0].setAttribute("height",U.height());U.children(":not(.flyout_arrow_horiz)").remove();U.append(Qa).attr("data-curopt",Ba.sel)};a(this).mouseup(ga);ra.key&&a(document).bind("keydown",ra.key[0]+" shift+"+ra.key[0],
ga)});if(S)U.attr("data-curopt",C[S].sel);else U.attr("data-curopt")||U.attr("data-curopt",C[0].sel);var X,aa=a(P).position();a(u).css({left:aa.left+34,top:aa.top+77});U.mousedown(function(ga){a("#tools_shapelib").is(":visible")&&$a(P,false);if(U.hasClass("disabled"))return false;var ra=a(u),Ta=aa.left+34,Ba=ra.width()*-1,ha=ra.data("shown_popop")?200:0;X=setTimeout(function(){U.data("isLibrary")?ra.css("left",Ta).show():ra.css("left",Ba).show().animate({left:Ta},150);ra.data("shown_popop",true)},
ha);ga.preventDefault()}).mouseup(function(){clearTimeout(X);var ga=a(this).attr("data-curopt");if(U.data("isLibrary")&&a(P.replace("_show","")).is(":visible"))$a(P,true);else $a(P)&&ga in oa&&oa[ga]()})});Aa()},ma=function(k,u){return a("<div>",{"class":"tools_flyout",id:k}).appendTo("#svg_editor").append(u)},na=function(){a(".tools_flyout").each(function(){var k=a("#"+this.id+"_show"),u=k.offset();k=k.outerWidth();a(this).css({left:(u.left+k)*ia,top:u.top})})},Aa=function(){a(".tools_flyout").each(function(){var k=
a("#"+this.id+"_show");if(!k.data("isLibrary")){var u=[];a(this).children().each(function(){u.push(this.title)});k[0].title=u.join(" / ")}})},Fa,Ia=function(k,u,C){var E=null;if(k.indexOf("url(#")===0){k=(k=g.getRefElem(k))?k.cloneNode(true):a("#"+C+"_color defs *")[0];E={alpha:u};E[k.tagName]=k}else E=k.indexOf("#")===0?{alpha:u,solidColor:k.substr(1)}:{alpha:u,solidColor:"none"};return new a.jGraduate.Paint(E)},Ca=g.getResolution();if(curConfig.baseUnit!=="px"){Ca.w=svgedit.units.convertUnit(Ca.w)+
curConfig.baseUnit;Ca.h=svgedit.units.convertUnit(Ca.h)+curConfig.baseUnit}var Ka=function(k){g.createLayer("background");cur_shape=g.addSvgElementFromJson({element:"rect",attr:{x:-1,y:-1,width:Ca.w+2,height:Ca.h+2,stroke:"none",id:"canvas_background",opacity:1,fill:k||"#fff",style:"pointer-events:none"}});g.setCurrentLayer("Layer 1");g.setCurrentLayerPosition("1")};document.getElementById("canvas_background")||Ka();document.getElementById("canvas_background").getAttribute("fill");var Na=c.setImageURL=
function(k){k||(k=J);g.setImageURL(k);a("#image_url").val(k)},za=function(){var k=W;if(k!=null&&!k.parentNode)k=null;if(sa&&sa[0]!=null&&!sa[0].parentNode)sa=false;var u=g.getCurrentDrawing().getCurrentLayerName(),C=g.getMode(),E=curConfig.baseUnit!=="px"?curConfig.baseUnit:null,P=C=="pathedit",U=a("#cmenu_canvas li");a(".context_panel").hide();a(".menu_item","#edit_menu").addClass("disabled");a(".menu_item","#object_menu").addClass("disabled");if(sa)(k=g.elementsAreSame(sa)?sa[0]:null)&&a("#tools_top").addClass("multiselected");
if(!k&&!sa){a("#tools_top").removeClass("multiselected");a("#stroke_panel").hide();a("#canvas_panel").show()}if(k!=null){a("#stroke_panel").show();var S=k.nodeName,X=g.getRotationAngle(k);a("#angle").val(Math.round(X));X=g.getBlur(k);a("#blur").val(X);if(!P&&C!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");var aa,ga;if(["g","polyline","path"].indexOf(S)>=0)if(C=g.getStrokedBBox([k])){aa=C.x;ga=C.y}if(E){aa=svgedit.units.convertUnit(aa);ga=svgedit.units.convertUnit(ga)}a("#"+
S+"_x").val(Math.round(aa));a("#"+S+"_y").val(Math.round(ga));["image","text","path","g","use"].indexOf(S)==-1&&a(".action_path_convert_selected").removeClass("disabled");S==="path"&&a(".action_path_selected").removeClass("disabled")}else{a("#path_node_panel").show();a("#stroke_panel").hide();u=K.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button");a("#tool_node_delete").toggleClass("disabled",!K.canDeleteNodes);xb("#tool_openclose_path",K.closed_subpath?
"open_path":"close_path");if(u){P=a("#seg_type");if(E){u.x=svgedit.units.convertUnit(u.x);u.y=svgedit.units.convertUnit(u.y)}a("#path_node_x").val(Math.round(u.x));a("#path_node_y").val(Math.round(u.y));u.type?P.val(u.type).removeAttr("disabled"):P.val(4).attr("disabled","disabled")}return}E=null;if(ra==="a"){E=g.getHref(k);a("#g_panel").show()}if(k.parentNode.tagName==="a")if(!a(k).siblings().length){a("#a_panel").show();E=g.getHref(k.parentNode)}a("#tool_make_link, #tool_make_link").toggle(!E);
E&&a("#link_url").val(E);E={g:[],a:[],rect:["rx","width","height","x","y"],image:["width","height","x","y"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],text:["x","y"],use:[],path:[]};var ra=k.tagName;a(k).data("gsvg")&&a("#g_panel").show();ra=="path"&&a("#path_panel").show();if(E[ra]){E=E[ra];a("#"+ra+"_panel").show();ra=="rect"?a("#cornerRadiusLabel").show():a("#cornerRadiusLabel").hide();a.each(E,function(Ta,Ba){var ha=k.getAttribute(Ba);if(curConfig.baseUnit!==
"px"&&k[Ba])ha=svgedit.units.convertUnit(k[Ba].baseVal.value);var Sa=document.getElementById(ra+"_"+Ba);Sa.value=Math.round(ha)||0;Sa.getAttribute("data-cursor")==="true"&&a.fn.dragInput.updateCursor(Sa)});if(ra=="text"){a("#text_panel").css("display","inline");g.getItalic()?a("#tool_italic").addClass("push_button_pressed").removeClass("tool_button"):a("#tool_italic").removeClass("push_button_pressed").addClass("tool_button");g.getBold()?a("#tool_bold").addClass("push_button_pressed").removeClass("tool_button"):
a("#tool_bold").removeClass("push_button_pressed").addClass("tool_button");a("#font_family").val(k.getAttribute("font-family"));a("#font_size").val(k.getAttribute("font-size"));a("#text").val(k.textContent);g.addedNew&&setTimeout(function(){a("#text").focus().select()},100)}else if(ra=="image")Na(g.getHref(k));else if(ra==="g"||ra==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");g.getTitle()}}U[(ra==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");U[(ra===
"g"||!sa?"dis":"en")+"ableContextMenuItems"]("#group")}else if(sa){a("#multiselected_panel").show();a(".action_multi_selected").removeClass("disabled");U.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}else U.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");T.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");T.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");
g.addedNew=false;if(k&&!P||sa){a("#selLayerNames").removeAttr("disabled").val(u);Y.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}};a("#text").on("focus",function(){});a("#text").on("blur",function(){});g.bind("selected",function(k,u){var C=g.getMode();C==="select"&&ba();C=C=="pathedit";W=u.length==1||u[1]==null?u[0]:null;sa=u.length>=2&&u[1]!=null?u:false;if(W!=null)if(!C){if(W!=null)switch(W.tagName){case "use":case "image":case "foreignObject":break;case "g":case "a":for(var E=
null,P=W.getElementsByTagName("*"),U=0,S=P.length;U<S;U++){var X=P[U].getAttribute("stroke-width");if(U===0)E=X;else if(E!==X)E=null}a("#stroke_width").val(E===null?"":E);c.paintBox.fill.update(true);c.paintBox.stroke.update(true);break;default:c.paintBox.fill.update(true);c.paintBox.stroke.update(true);a("#stroke_width").val(W.getAttribute("stroke-width")||1);a("#stroke_style").val(W.getAttribute("stroke-dasharray")||"none");E=W.getAttribute("stroke-linejoin")||"miter";a("#linejoin_"+E).length!=
0&&d(a("#linejoin_"+E)[0]);E=W.getAttribute("stroke-linecap")||"butt";a("#linecap_"+E).length!=0&&d(a("#linecap_"+E)[0])}if(W!=null){E=(W.getAttribute("opacity")||1)*100;a("#group_opacity").val(E);a("#opac_slider").slider("option","value",E);a("#elem_id").val(W.id)}}a("#path_node_panel").toggle(C);a("#tools_bottom_2,#tools_bottom_3").toggle(!C);if(C){a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button");
xb("#tool_select","select_node");sa=false;if(u.length)W=u[0]}else{if(u[0]){C=g.selectorManager.requestSelector(u[0]);C.reset(u[0]);C.selectorRect.setAttribute("display","inline")}xb("#tool_select","select")}za();g.runExtensions("selectedChanged",{elems:u,selectedElement:W,multiselected:sa})});g.bind("transition",function(k,u){var C=g.getMode(),E=u[0];if(E){sa=u.length>=2&&u[1]!=null?u:null;if(!sa)switch(C){case "rotate":C=g.getRotationAngle(E);a("#angle").val(Math.round(C));rotateCursor(C);a("#tool_reorient").toggleClass("disabled",
C==0)}g.runExtensions("elementTransition",{elems:u})}});g.bind("changed",function(k,u){var C=g.getMode();C==="select"&&ba();for(var E=0;E<u.length;++E){var P=u[E];if(P&&P.tagName==="svg")F();else if(P&&W&&W.parentNode==null)W=P}c.show_save_warning=true;za();if(W&&C==="select"){c.paintBox.fill.update();c.paintBox.stroke.update()}g.runExtensions("elementChanged",{elems:u})});g.bind("saved",function(k,u){c.show_save_warning=false;u='<?xml version="1.0"?>\n'+u;var C=navigator.userAgent;if(~C.indexOf("Chrome")&&
a.browser.version>=533||~C.indexOf("MSIE"))Qb(0,true);else{var E=k.open("data:image/svg+xml;base64,"+M.encode64(u)),P=a.pref("save_notice_done");if(P!=="all"){var U=uiStrings.notification.saveFromBrowser.replace("%s","SVG");if(C.indexOf("Gecko/")!==-1)if(u.indexOf("<defs")!==-1){U+="\n\n"+uiStrings.notification.defsFailOnSave;a.pref("save_notice_done","all");P="all"}else a.pref("save_notice_done","part");else a.pref("save_notice_done","all");P!=="part"&&E.alert(U)}}});g.bind("exported",function(k,
u){var C=u.issues;a("#export_canvas").length||a("<canvas>",{id:"export_canvas"}).hide().appendTo("body");var E=a("#export_canvas")[0];E.width=g.contentW;E.height=g.contentH;canvg(E,u.svg,{renderCallback:function(){var P=E.toDataURL("image/png");O.location.href=P;if(a.pref("export_notice_done")!=="all"){P=uiStrings.notification.saveFromBrowser.replace("%s","PNG");if(C.length)P+="\n\n"+uiStrings.notification.noteTheseIssues+"\n \u2022 "+C.join("\n \u2022 ");a.pref("export_notice_done","all");O.alert(P)}}})});
g.bind("zoomed",V);g.bind("contextset",function(k,u){var C="";if(u){var E="";C='<a href="#" data-root="y">'+g.getCurrentDrawing().getCurrentLayerName()+"</a>";a(u).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){E+=" > "+this.id;C+=this!==u?' > <a href="#">'+this.id+"</a>":" > "+this.id}});da=E}else da=null;a("#cur_context_panel").toggle(!!u).html(C)});g.bind("extension_added",function(k,u){function C(){if(Fa){clearTimeout(Fa);Fa=null}P||(Fa=setTimeout(function(){P=true;e(s.iconsize)},
50))}var E=false,P=false,U=true,S=function(){if(u.callback&&!E&&U){E=true;u.callback()}},X=[];u.context_tools&&a.each(u.context_tools,function(Ba,ha){var Sa=ha.container_id?' id="'+ha.container_id+'"':"",Qa=a("#"+ha.panel);Qa.length||(Qa=a("<div>",{id:ha.panel}).appendTo("#tools_top").hide());switch(ha.type){case "tool_button":var ua='<div class="tool_button">'+ha.id+"</div>",Ma=a(ua).appendTo(Qa);ha.events&&a.each(ha.events,function(Wa,cb){a(Ma).bind(Wa,cb)});break;case "select":ua="<label"+Sa+'><select id="'+
ha.id+'">';a.each(ha.options,function(Wa,cb){ua+='<option value="'+Wa+'"'+(Wa==ha.defval?" selected":"")+">"+cb+"</option>"});ua+="</select></label>";var xa=a(ua).appendTo(Qa).find("select");a.each(ha.events,function(Wa,cb){a(xa).bind(Wa,cb)});break;case "button-select":ua='<div id="'+ha.id+'" class="dropdown toolset" title="'+ha.title+'"><div id="cur_'+ha.id+'" class="icon_label"></div><button></button></div>';Sa=a('<ul id="'+ha.id+'_opts"></ul>').appendTo("#option_lists");ha.colnum&&Sa.addClass("optcols"+
ha.colnum);a(ua).appendTo(Qa).children();X.push({elem:"#"+ha.id,list:"#"+ha.id+"_opts",title:ha.title,callback:ha.events.change,cur:"#cur_"+ha.id});break;case "input":ua="<label"+Sa+'><span id="'+ha.id+'_label">'+ha.label+':</span><input id="'+ha.id+'" title="'+ha.title+'" size="'+(ha.size||"4")+'" value="'+(ha.defval||"")+'" type="text"/></label>';var ab=a(ua).appendTo(Qa).find("input");ha.spindata&&ab.SpinButton(ha.spindata);ha.events&&a.each(ha.events,function(Wa,cb){ab.bind(Wa,cb)})}});if(u.buttons){var aa=
{},ga={},ra=u.svgicons,Ta={};a.each(u.buttons,function(Ba,ha){for(var Sa,Qa=ha.id,ua=Ba;a("#"+Qa).length;)Qa=ha.id+"_"+ ++ua;if(ra){aa[Qa]=ha.icon;ua=ha.svgicon?ha.svgicon:ha.id;if(ha.type=="app_menu")ga["#"+Qa+" > div"]=ua;else ga["#"+Qa]=ua}else Sa=ha.type=="menu"?"":a('<img src="'+ha.icon+'">');var Ma,xa;switch(ha.type){case "mode_flyout":case "mode":Ma="tool_button";if(ha.cls)Ma+=" "+ha.cls;xa="#tools_left";break;case "context":Ma="tool_button";xa="#"+ha.panel;a(xa).length||a("<div>",{id:ha.panel}).appendTo("#tools_top");
break;case "menu":Ma="menu_item tool_button";xa="#"+(ha.after||ha.panel);break;case "app_menu":Ma="";xa=ha.parent||"#main_menu ul";a(xa).length||a("<div>",{id:ha.panel}).appendTo("#tools_top")}var ab=a(ha.list||ha.type=="app_menu"?"<li/>":"<div/>").attr("id",Qa).attr("title",ha.title).addClass(Ma);if(!ha.includeWith&&!ha.list){if("position"in ha)a(xa).children().eq(ha.position).before(ab);else ha.type!="menu"||!ha.after?ab.appendTo(xa):a(xa).after(ab);if(ha.type=="mode_flyout"){ua=a(ab);Ma=ua.parent();
if(!ua.parent().hasClass("tools_flyout")){var Wa=ua[0].id.replace("tool_","tools_"),cb=ua.clone().attr("id",Wa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));ua.before(cb);Ma=ma(Wa,ua);Ma.data("isLibrary",true);cb.data("isLibrary",true)}ga["#"+Wa+"_show"]=ha.id;Qa=Ta["#"+Ma[0].id]=[{sel:"#"+Qa,fn:ha.events.click,icon:ha.id,isDefault:true},Hb]}else if(ha.type=="app_menu"||ha.type=="menu")ab.append(ha.title)}else if(ha.list){ab.addClass("push_button");a("#"+ha.list+"_opts").append(ab);if(ha.isDefault){a("#cur_"+
ha.list).append(ab.children().clone());ua=ha.svgicon?ha.svgicon:ha.id;ga["#cur_"+ha.list]=ua}}else if(ha.includeWith){xa=ha.includeWith;ua=a(xa.button);Ma=ua.parent();if(!ua.parent().hasClass("tools_flyout")){Wa=ua[0].id.replace("tool_","tools_");cb=ua.clone().attr("id",Wa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));ua.before(cb);Ma=ma(Wa,ua)}var Hb=v.getButtonData(xa.button);if(xa.isDefault)ga["#"+Wa+"_show"]=ha.id;Qa=Ta["#"+Ma[0].id]=[{sel:"#"+Qa,fn:ha.events.click,icon:ha.id,key:ha.key,
isDefault:ha.includeWith?ha.includeWith.isDefault:0},Hb];Wa="position"in xa?xa.position:"last";Hb=Ma.children().length;if(!isNaN(Wa)&&Wa>=0&&Wa<Hb)Ma.children().eq(Wa).before(ab);else{Ma.append(ab);Qa.reverse()}}ra||ab.append(Sa);ha.list||a.each(ha.events,function(yb,Gb){if(yb=="click")if(ha.type=="mode"){ha.includeWith?ab.bind(yb,Gb):ab.bind(yb,function(){$a(ab)&&Gb()});if(ha.key){a(document).bind("keydown",ha.key,Gb);ha.title&&ab.attr("title",ha.title+" ["+ha.key+"]")}}else ab.bind(yb,Gb);else ab.bind(yb,
Gb)});qa(Ta)});a.each(X,function(){Da(this.elem,this.list,this.callback,{seticon:true})});if(ra)U=false;a.svgIcons(ra,{w:27,h:27,id_match:false,no_img:!B,fallback:aa,placement:ga,callback:function(){s.iconsize&&s.iconsize!="m"&&C();U=true;S()}})}S()});g.textActions.setInputElem(a("#text")[0]);var ya='<div class="palette_item" data-rgb="none"></div>';a.each(["#000000","#3f3f3f","#7f7f7f","#bfbfbf","#ffffff","#ff0000","#ff7f00","#ffff00","#7fff00","#00ff00","#00ff7f","#00ffff","#007fff","#0000ff","#7f00ff",
fh_ellipse:"freehand-circle.png",path:"path.png",text:"text.png",image:"image.png",zoom:"zoom.png","delete":"delete.png",spapelib:"shapelib.png",node_delete:"node_delete.png",align_left:"align-left.png",align_center:"align-center.png",align_right:"align-right.png",align_top:"align-top.png",align_middle:"align-middle.png",align_bottom:"align-bottom.png",arrow_right:"flyouth.png",arrow_down:"dropdown.gif"},placement:{"#logo":"logo","#tool_select":"select","#tool_fhpath":"pencil","#tool_line":"pen",
"#tool_rect,#tools_rect_show":"rect","#tool_square":"square","#tool_fhrect":"fh_rect","#tool_ellipse,#tools_ellipse_show":"ellipse","#tool_circle":"circle","#tool_fhellipse":"fh_ellipse","#tool_path":"path","#tool_text,#layer_rename":"text","#tool_image":"image","#tool_zoom":"zoom","#tool_node_clone":"node_clone","#tool_node_delete":"node_delete","#tool_add_subpath":"add_subpath","#tool_openclose_path":"open_path","#tool_alignleft, #tool_posleft":"align_left","#tool_aligncenter, #tool_poscenter":"align_center",
"#tool_alignright, #tool_posright":"align_right","#tool_aligntop, #tool_postop":"align_top","#tool_alignmiddle, #tool_posmiddle":"align_middle","#tool_alignbottom, #tool_posbottom":"align_bottom","#cur_position":"align","#zoomLabel":"zoom","#palette .palette_item:first, #fill_bg, #stroke_bg":"no_color"},resize:{"#logo .svg_icon":15,".flyout_arrow_horiz .svg_icon":5,"#fill_bg .svg_icon, #stroke_bg .svg_icon":svgedit.browser.isTouch()?24:24,".palette_item:first .svg_icon":svgedit.browser.isTouch()?
30:16,"#zoomLabel .svg_icon":16,"#zoom_dropdown .svg_icon":7},callback:function(){a(".toolbar_button button > svg, .toolbar_button button > img").each(function(){a(this).parent().prepend(this)});a(".tool_button, .tool_button_current").addClass("loaded");var k=a("#tools_left");if(k.length!=0){k.offset();k.outerHeight()}a(".tools_flyout").each(function(){var u=a("#"+this.id+"_show"),C=u.attr("data-curopt");if(!u.children("svg, img").length){C=a(C).children().clone();if(C.length){C[0].removeAttribute("style");
u.append(C)}}});svgEditor.runCallbacks();setTimeout(function(){a(".flyout_arrow_horiz:empty").each(function(){a(this).append(a.getSvgIcon("arrow_right").width(5).height(5))})},1)}});a("#rulers").on("dblclick",function(k){a("#base_unit_container").css({top:k.pageY-10,left:k.pageX-50,display:"block"})});a("#base_unit_container").on("mouseleave mouseenter",function(){t=setTimeout(function(){a("#base_unit_container").fadeOut(500)},200);event.type=="mouseover"&&clearTimeout(t)});a("#base_unit").on("change",
function(){savePreferences()});c.canvas=g=new a.SvgCanvas(document.getElementById("svgcanvas"),curConfig);c.show_save_warning=false;c.paintBox={fill:null,stroke:null,canvas:null};q=navigator.platform.indexOf("Mac")>=0;var B=navigator.userAgent.indexOf("AppleWebKit")>=0,o=q?"meta+":"ctrl+",K=g.pathActions,T=g.undoMgr,M=svgedit.utilities,J=curConfig.imgPath+"placeholder.svg",Q=a("#workarea"),X=a("#cmenu_canvas"),O=null,ia=1,pa="toolbars",fa="";q||a(".shortcut").each(function(){var k=a(this).text();
a(this).text(k.split("\u2318").join("Ctrl+"))});(function(){a("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"});var k=a("#dialog_box"),u=a("#dialog_buttons"),C=function(D,P,U,S){a("#dialog_content").html("<p>"+P.replace(/\n/g,"</p><p>")+"</p>").toggleClass("prompt",D=="prompt");u.empty();var Y=a('<input type="button" value="'+uiStrings.common.ok+'">').appendTo(u);D!="alert"&&a('<input type="button" value="'+uiStrings.common.cancel+'">').appendTo(u).on("click, touchstart",
function(){k.hide();U(false)});if(D=="prompt"){var aa=a('<input type="text">').prependTo(u);aa.val(S||"");aa.bind("keydown","return",function(){Y.trigger("click touchstart")})}D=="process"&&Y.hide();k.show();Y.on("click touchstart",function(){k.hide();var ga=D=="prompt"?aa.val():true;U&&U(ga)}).focus();D=="prompt"&&aa.focus()};a.alert=function(D,P){C("alert",D,P)};a.confirm=function(D,P){C("confirm",D,P)};a.process_cancel=function(D,P){C("process",D,P)};a.prompt=function(D,P,U){C("prompt",D,U,P)}})();
var ba=function(){var k=a(".tool_button_current");if(k.length&&k[0].id!=="tool_select"){k.removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button")}g.setMode("select")},W=null,sa=false,ka=false,da="",V=function(k,u){var C=g.getResolution();a("#svgcanvas").position();var D=g.setBBoxZoom(u,Q.width()-15,Q.height()-15);if(D){var P=D.zoom;D=D.bbox;if(P<0.0010)wa({value:0.1});else{var U=Date.now(),S=P-C.zoom;a("#zoom");var Y=
C.zoom,aa=function(ga){ga=(ga-U)/500;ga=Math.pow(ga-1,3)+1;g.setZoom(Y+S*ga);F();ga<1?requestAnimationFrame(aa):a("#zoom").val(P*100)};aa(Date.now());g.getMode()=="zoom"&&D.width&&ba();lb()}}};a("#cur_context_panel").delegate("a","click",function(){var k=a(this);k.attr("data-root")?g.leaveContext():g.setContext(k.text());return false});var Z=function(){c.paintBox.fill.prep();c.paintBox.stroke.prep()},oa={},qa=function(k){a.each(k,function(u,C){var D=a(u).children(),P=u+"_show",U=a(P),S=false;D.addClass("tool_button").unbind("click mousedown mouseup").each(function(ga){var ra=
C[ga];oa[ra.sel]=ra.fn;if(ra.isDefault)S=ga;ga=function(Oa){var Ba=ra;if(Oa.type==="keydown"){var ha=a(Ba.parent+"_show").hasClass("tool_button_current"),Ta=a(Ba.parent+"_show").attr("data-curopt");a.each(k[ra.parent],function(ta,Ma){if(Ma.sel==Ta)Ba=!Oa.shiftKey||!ha?Ma:k[ra.parent][ta+1]||k[ra.parent][0]})}if(a(this).hasClass("disabled"))return false;$a(P)&&Ba.fn();var Ra=Ba.icon?a.getSvgIcon(Ba.icon,true):a(Ba.sel).children().eq(0).clone();Ra[0].setAttribute("width",U.width());Ra[0].setAttribute("height",
U.height());U.children(":not(.flyout_arrow_horiz)").remove();U.append(Ra).attr("data-curopt",Ba.sel)};a(this).mouseup(ga);ra.key&&a(document).bind("keydown",ra.key[0]+" shift+"+ra.key[0],ga)});if(S)U.attr("data-curopt",C[S].sel);else U.attr("data-curopt")||U.attr("data-curopt",C[0].sel);var Y,aa=a(P).position();a(u).css({left:aa.left+34,top:aa.top+77});U.mousedown(function(ga){a("#tools_shapelib").is(":visible")&&$a(P,false);if(U.hasClass("disabled"))return false;var ra=a(u),Oa=aa.left+34,Ba=ra.width()*
-1,ha=ra.data("shown_popop")?200:0;Y=setTimeout(function(){U.data("isLibrary")?ra.css("left",Oa).show():ra.css("left",Ba).show().animate({left:Oa},150);ra.data("shown_popop",true)},ha);ga.preventDefault()}).mouseup(function(){clearTimeout(Y);var ga=a(this).attr("data-curopt");if(U.data("isLibrary")&&a(P.replace("_show","")).is(":visible"))$a(P,true);else $a(P)&&ga in oa&&oa[ga]()})});Aa()},ma=function(k,u){return a("<div>",{"class":"tools_flyout",id:k}).appendTo("#svg_editor").append(u)},na=function(){a(".tools_flyout").each(function(){var k=
a("#"+this.id+"_show"),u=k.offset();k=k.outerWidth();a(this).css({left:(u.left+k)*ia,top:u.top})})},Aa=function(){a(".tools_flyout").each(function(){var k=a("#"+this.id+"_show");if(!k.data("isLibrary")){var u=[];a(this).children().each(function(){u.push(this.title)});k[0].title=u.join(" / ")}})},Fa,Ia=function(k,u,C){var D=null;if(k.indexOf("url(#")===0){k=(k=g.getRefElem(k))?k.cloneNode(true):a("#"+C+"_color defs *")[0];D={alpha:u};D[k.tagName]=k}else D=k.indexOf("#")===0?{alpha:u,solidColor:k.substr(1)}:
{alpha:u,solidColor:"none"};return new a.jGraduate.Paint(D)},Ca=g.getResolution();if(curConfig.baseUnit!=="px"){Ca.w=svgedit.units.convertUnit(Ca.w)+curConfig.baseUnit;Ca.h=svgedit.units.convertUnit(Ca.h)+curConfig.baseUnit}var Ka=function(k){g.createLayer("background");cur_shape=g.addSvgElementFromJson({element:"rect",attr:{x:-1,y:-1,width:Ca.w+2,height:Ca.h+2,stroke:"none",id:"canvas_background",opacity:1,fill:k||"#fff",style:"pointer-events:none"}});g.setCurrentLayer("Layer 1");g.setCurrentLayerPosition("1")};
document.getElementById("canvas_background")||Ka();document.getElementById("canvas_background").getAttribute("fill");var Na=c.setImageURL=function(k){k||(k=J);g.setImageURL(k);a("#image_url").val(k)},za=function(){var k=W;if(k!=null&&!k.parentNode)k=null;if(sa&&sa[0]!=null&&!sa[0].parentNode)sa=false;var u=g.getCurrentDrawing().getCurrentLayerName(),C=g.getMode(),D=curConfig.baseUnit!=="px"?curConfig.baseUnit:null,P=C=="pathedit",U=a("#cmenu_canvas li");a(".context_panel").hide();a(".menu_item","#edit_menu").addClass("disabled");
a(".menu_item","#object_menu").addClass("disabled");if(sa){sa=sa.filter(Boolean);(k=g.elementsAreSame(sa)?sa[0]:null)&&a("#tools_top").addClass("multiselected")}if(!k&&!sa){a("#tools_top").removeClass("multiselected");a("#stroke_panel").hide();a("#canvas_panel").show()}if(k!=null){a("#stroke_panel").show();var S=k.nodeName,Y=g.getRotationAngle(k);a("#angle").val(Math.round(Y));Y=g.getBlur(k);a("#blur").val(Y);if(!P&&C!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");
var aa,ga;if(["g","polyline","path"].indexOf(S)>=0)if(C=g.getStrokedBBox([k])){aa=C.x;ga=C.y}if(D){aa=svgedit.units.convertUnit(aa);ga=svgedit.units.convertUnit(ga)}a("#"+S+"_x").val(Math.round(aa));a("#"+S+"_y").val(Math.round(ga));["image","text","path","g","use"].indexOf(S)==-1&&a(".action_path_convert_selected").removeClass("disabled");S==="path"&&a(".action_path_selected").removeClass("disabled")}else{a("#path_node_panel").show();a("#stroke_panel").hide();u=K.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button");
a("#tool_node_delete").toggleClass("disabled",!K.canDeleteNodes);yb("#tool_openclose_path",K.closed_subpath?"open_path":"close_path");if(u){P=a("#seg_type");if(D){u.x=svgedit.units.convertUnit(u.x);u.y=svgedit.units.convertUnit(u.y)}a("#path_node_x").val(Math.round(u.x));a("#path_node_y").val(Math.round(u.y));u.type?P.val(u.type).removeAttr("disabled"):P.val(4).attr("disabled","disabled")}return}D=null;if(ra==="a"){D=g.getHref(k);a("#g_panel").show()}if(k.parentNode.tagName==="a")if(!a(k).siblings().length){a("#a_panel").show();
D=g.getHref(k.parentNode)}a("#tool_make_link, #tool_make_link").toggle(!D);D&&a("#link_url").val(D);D={g:[],a:[],rect:["rx","width","height","x","y"],image:["width","height","x","y"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],text:["x","y"],use:[],path:[]};var ra=k.tagName;a(k).data("gsvg")&&a("#g_panel").show();ra=="path"&&a("#path_panel").show();if(D[ra]){D=D[ra];a("#"+ra+"_panel").show();ra=="rect"?a("#cornerRadiusLabel").show():a("#cornerRadiusLabel").hide();
a.each(D,function(Oa,Ba){var ha=k.getAttribute(Ba);if(curConfig.baseUnit!=="px"&&k[Ba])ha=svgedit.units.convertUnit(k[Ba].baseVal.value);var Ta=document.getElementById(ra+"_"+Ba);Ta.value=Math.round(ha)||0;Ta.getAttribute("data-cursor")==="true"&&a.fn.dragInput.updateCursor(Ta)});if(ra=="text"){D=k.getAttribute("font-family");document.getElementById("font_family_dropdown").selectedIndex=3;a("#text_panel").css("display","inline");a("#tool_italic").toggleClass("active",g.getItalic());a("#tool_bold").toggleClass("active",
g.getBold());a("#font_family").val(D);a("#font_size").val(k.getAttribute("font-size"));a("#text").val(k.textContent);g.addedNew&&setTimeout(function(){a("#text").focus().select()},100)}else if(ra=="image")Na(g.getHref(k));else if(ra==="g"||ra==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");g.getTitle()}}U[(ra==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");U[(ra==="g"||!sa?"dis":"en")+"ableContextMenuItems"]("#group")}else if(sa){a("#multiselected_panel").show();
a(".action_multi_selected").removeClass("disabled");U.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}else U.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");T.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");T.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");g.addedNew=false;if(k&&!P||sa){a("#selLayerNames").removeAttr("disabled").val(u);
X.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}};a("#text").on("focus",function(){});a("#text").on("blur",function(){});g.bind("selected",function(k,u){var C=g.getMode();C==="select"&&ba();C=C=="pathedit";W=u.length==1||u[1]==null?u[0]:null;sa=u.length>=2&&u[1]!=null?u:false;if(W!=null)if(!C){if(W!=null)switch(W.tagName){case "use":case "image":case "foreignObject":break;case "g":case "a":for(var D=null,P=W.getElementsByTagName("*"),U=0,S=P.length;U<S;U++){var Y=
P[U].getAttribute("stroke-width");if(U===0)D=Y;else if(D!==Y)D=null}a("#stroke_width").val(D===null?"":D);c.paintBox.fill.update(true);c.paintBox.stroke.update(true);break;default:c.paintBox.fill.update(true);c.paintBox.stroke.update(true);a("#stroke_width").val(W.getAttribute("stroke-width")||1);a("#stroke_style").val(W.getAttribute("stroke-dasharray")||"none");D=W.getAttribute("stroke-linejoin")||"miter";a("#linejoin_"+D).length!=0&&d(a("#linejoin_"+D)[0]);D=W.getAttribute("stroke-linecap")||"butt";
a("#linecap_"+D).length!=0&&d(a("#linecap_"+D)[0])}if(W!=null){D=(W.getAttribute("opacity")||1)*100;a("#group_opacity").val(D);a("#opac_slider").slider("option","value",D);a("#elem_id").val(W.id)}}a("#path_node_panel").toggle(C);a("#tools_bottom_2,#tools_bottom_3").toggle(!C);if(C){a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button");yb("#tool_select","select_node");sa=false;if(u.length)W=
u[0]}else{if(u[0]){C=g.selectorManager.requestSelector(u[0]);C.reset(u[0]);C.selectorRect.setAttribute("display","inline")}yb("#tool_select","select")}za();g.runExtensions("selectedChanged",{elems:u,selectedElement:W,multiselected:sa})});g.bind("transition",function(k,u){var C=g.getMode(),D=u[0];if(D){sa=u.length>=2&&u[1]!=null?u:null;if(!sa)switch(C){case "rotate":C=g.getRotationAngle(D);a("#angle").val(Math.round(C));rotateCursor(C);a("#tool_reorient").toggleClass("disabled",C==0)}g.runExtensions("elementTransition",
{elems:u})}});g.bind("changed",function(k,u){var C=g.getMode();C==="select"&&ba();for(var D=0;D<u.length;++D){var P=u[D];if(P&&P.tagName==="svg")F();else if(P&&W&&W.parentNode==null)W=P}c.show_save_warning=true;za();if(W&&C==="select"){c.paintBox.fill.update();c.paintBox.stroke.update()}g.runExtensions("elementChanged",{elems:u})});g.bind("saved",function(k,u){c.show_save_warning=false;u='<?xml version="1.0"?>\n'+u;var C=navigator.userAgent;if(~C.indexOf("Chrome")&&a.browser.version>=533||~C.indexOf("MSIE"))Qb(0,
true);else{var D=k.open("data:image/svg+xml;base64,"+M.encode64(u)),P=a.pref("save_notice_done");if(P!=="all"){var U=uiStrings.notification.saveFromBrowser.replace("%s","SVG");if(C.indexOf("Gecko/")!==-1)if(u.indexOf("<defs")!==-1){U+="\n\n"+uiStrings.notification.defsFailOnSave;a.pref("save_notice_done","all");P="all"}else a.pref("save_notice_done","part");else a.pref("save_notice_done","all");P!=="part"&&D.alert(U)}}});g.bind("exported",function(k,u){var C=u.issues;a("#export_canvas").length||a("<canvas>",
{id:"export_canvas"}).hide().appendTo("body");var D=a("#export_canvas")[0];D.width=g.contentW;D.height=g.contentH;canvg(D,u.svg,{renderCallback:function(){var P=D.toDataURL("image/png");O.location.href=P;if(a.pref("export_notice_done")!=="all"){P=uiStrings.notification.saveFromBrowser.replace("%s","PNG");if(C.length)P+="\n\n"+uiStrings.notification.noteTheseIssues+"\n \u2022 "+C.join("\n \u2022 ");a.pref("export_notice_done","all");O.alert(P)}}})});g.bind("zoomed",V);g.bind("contextset",function(k,
u){var C="";if(u){var D="";C='<a href="#" data-root="y">'+g.getCurrentDrawing().getCurrentLayerName()+"</a>";a(u).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){D+=" > "+this.id;C+=this!==u?' > <a href="#">'+this.id+"</a>":" > "+this.id}});da=D}else da=null;a("#cur_context_panel").toggle(!!u).html(C)});g.bind("extension_added",function(k,u){function C(){if(Fa){clearTimeout(Fa);Fa=null}P||(Fa=setTimeout(function(){P=true;e(s.iconsize)},50))}var D=false,P=false,U=true,S=function(){if(u.callback&&
!D&&U){D=true;u.callback()}},Y=[];u.context_tools&&a.each(u.context_tools,function(Ba,ha){var Ta=ha.container_id?' id="'+ha.container_id+'"':"",Ra=a("#"+ha.panel);Ra.length||(Ra=a("<div>",{id:ha.panel}).appendTo("#tools_top").hide());switch(ha.type){case "tool_button":var ta='<div class="tool_button">'+ha.id+"</div>",Ma=a(ta).appendTo(Ra);ha.events&&a.each(ha.events,function(Xa,cb){a(Ma).bind(Xa,cb)});break;case "select":ta="<label"+Ta+'><select id="'+ha.id+'">';a.each(ha.options,function(Xa,cb){ta+=
'<option value="'+Xa+'"'+(Xa==ha.defval?" selected":"")+">"+cb+"</option>"});ta+="</select></label>";var xa=a(ta).appendTo(Ra).find("select");a.each(ha.events,function(Xa,cb){a(xa).bind(Xa,cb)});break;case "button-select":ta='<div id="'+ha.id+'" class="dropdown toolset" title="'+ha.title+'"><div id="cur_'+ha.id+'" class="icon_label"></div><button></button></div>';Ta=a('<ul id="'+ha.id+'_opts"></ul>').appendTo("#option_lists");ha.colnum&&Ta.addClass("optcols"+ha.colnum);a(ta).appendTo(Ra).children();
Y.push({elem:"#"+ha.id,list:"#"+ha.id+"_opts",title:ha.title,callback:ha.events.change,cur:"#cur_"+ha.id});break;case "input":ta="<label"+Ta+'><span id="'+ha.id+'_label">'+ha.label+':</span><input id="'+ha.id+'" title="'+ha.title+'" size="'+(ha.size||"4")+'" value="'+(ha.defval||"")+'" type="text"/></label>';var ab=a(ta).appendTo(Ra).find("input");ha.spindata&&ab.SpinButton(ha.spindata);ha.events&&a.each(ha.events,function(Xa,cb){ab.bind(Xa,cb)})}});if(u.buttons){var aa={},ga={},ra=u.svgicons,Oa=
{};a.each(u.buttons,function(Ba,ha){for(var Ta,Ra=ha.id,ta=Ba;a("#"+Ra).length;)Ra=ha.id+"_"+ ++ta;if(ra){aa[Ra]=ha.icon;ta=ha.svgicon?ha.svgicon:ha.id;console.log(ta);if(ha.type=="app_menu")ga["#"+Ra+" > div"]=ta;else ga["#"+Ra]=ta}else Ta=ha.type=="menu"?"":a('<img src="'+ha.icon+'">');var Ma,xa;switch(ha.type){case "mode_flyout":case "mode":Ma="tool_button";if(ha.cls)Ma+=" "+ha.cls;xa="#tools_left";break;case "context":Ma="tool_button";xa="#"+ha.panel;a(xa).length||a("<div>",{id:ha.panel}).appendTo("#tools_top");
break;case "menu":Ma="menu_item tool_button";xa="#"+(ha.after||ha.panel);break;case "app_menu":Ma="";xa=ha.parent||"#main_menu ul";a(xa).length||a("<div>",{id:ha.panel}).appendTo("#tools_top")}var ab=a(ha.list||ha.type=="app_menu"?"<li/>":"<div/>").attr("id",Ra).attr("title",ha.title).addClass(Ma);if(!ha.includeWith&&!ha.list){if("position"in ha)a(xa).children().eq(ha.position).before(ab);else ha.type!="menu"||!ha.after?ab.appendTo(xa):a(xa).after(ab);if(ha.type=="mode_flyout"){ta=a(ab);Ma=ta.parent();
if(!ta.parent().hasClass("tools_flyout")){var Xa=ta[0].id.replace("tool_","tools_"),cb=ta.clone().attr("id",Xa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));ta.before(cb);Ma=ma(Xa,ta);Ma.data("isLibrary",true);cb.data("isLibrary",true)}ga["#"+Xa+"_show"]=ha.id;Ra=Oa["#"+Ma[0].id]=[{sel:"#"+Ra,fn:ha.events.click,icon:ha.id,isDefault:true},Hb]}else if(ha.type=="app_menu"||ha.type=="menu")ab.append(ha.title)}else if(ha.list){ab.addClass("push_button");a("#"+ha.list+"_opts").append(ab);if(ha.isDefault){a("#cur_"+
ha.list).append(ab.children().clone());ta=ha.svgicon?ha.svgicon:ha.id;ga["#cur_"+ha.list]=ta}}else if(ha.includeWith){xa=ha.includeWith;ta=a(xa.button);Ma=ta.parent();if(!ta.parent().hasClass("tools_flyout")){Xa=ta[0].id.replace("tool_","tools_");cb=ta.clone().attr("id",Xa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));ta.before(cb);Ma=ma(Xa,ta)}var Hb=v.getButtonData(xa.button);if(xa.isDefault)ga["#"+Xa+"_show"]=ha.id;Ra=Oa["#"+Ma[0].id]=[{sel:"#"+Ra,fn:ha.events.click,icon:ha.id,key:ha.key,
isDefault:ha.includeWith?ha.includeWith.isDefault:0},Hb];Xa="position"in xa?xa.position:"last";Hb=Ma.children().length;if(!isNaN(Xa)&&Xa>=0&&Xa<Hb)Ma.children().eq(Xa).before(ab);else{Ma.append(ab);Ra.reverse()}}ra||ab.append(Ta);ha.list||a.each(ha.events,function(zb,Gb){if(zb=="click")if(ha.type=="mode"){ha.includeWith?ab.bind(zb,Gb):ab.bind(zb,function(){$a(ab)&&Gb()});if(ha.key){a(document).bind("keydown",ha.key,Gb);ha.title&&ab.attr("title",ha.title+" ["+ha.key+"]")}}else ab.bind(zb,Gb);else ab.bind(zb,
Gb)});qa(Oa)});a.each(Y,function(){Da(this.elem,this.list,this.callback,{seticon:true})});if(ra)U=false;a.svgIcons(ra,{w:27,h:27,id_match:false,no_img:!B,fallback:aa,placement:ga,callback:function(){s.iconsize&&s.iconsize!="m"&&C();U=true;S()}})}S()});g.textActions.setInputElem(a("#text")[0]);var ya='<div class="palette_item" data-rgb="none"></div>';a.each(["#000000","#3f3f3f","#7f7f7f","#bfbfbf","#ffffff","#ff0000","#ff7f00","#ffff00","#7fff00","#00ff00","#00ff7f","#00ffff","#007fff","#0000ff","#7f00ff",
"#ff00ff","#ff007f","#7f0000","#7f3f00","#7f7f00","#3f7f00","#007f00","#007f3f","#007f7f","#003f7f","#00007f","#3f007f","#7f007f","#7f003f","#ffaaaa","#ffd4aa","#ffffaa","#d4ffaa","#aaffaa","#aaffd4","#aaffff","#aad4ff"],function(k,u){ya+='<div class="palette_item" style="background-color: '+u+';" data-rgb="'+u+'"></div>'});a("#palette").append(ya);var Ha=a("#tool_angle_indicator");a("#tool_reorient");rotateCursor=function(k){k="rotate("+k+"deg)";Ha.css({"-webkit-transform":k,"-moz-transform":k,"-o-transform":k,
"-ms-transform":k,transform:k})};var wa=function(k){var u=k.value/100;if(u<0.0010)k.value=0.1;else{k=g.getZoom();V(window,{width:0,height:0,x:(Q[0].scrollLeft+Q.width()/2)/k,y:(Q[0].scrollTop+Q.height()/2)/k,zoom:u},true)}},qb=function(){window.opera&&a("<p/>").hide().appendTo("body").remove()};a("#stroke_style").change(function(){g.setStrokeAttr("stroke-dasharray",a(this).val());a("#stroke_style_label").html(this.options[this.selectedIndex].text);qb()});a("#seg_type").change(function(){g.setSegType(a(this).val());
a("#seg_type_label").html(this.options[this.selectedIndex].text)});a("select").change(function(){a(this).blur()});a("#font_family").change(function(){g.setFontFamily(this.value)});a("#text").keyup(function(){g.setTextContent(this.value)});changeAttribute=function(k,u){var C=k.getAttribute("data-attr"),E=k.value;if(!svgedit.units.isValidUnit(C,E,W)){a.alert(uiStrings.notification.invalidAttrValGiven);k.value=W.getAttribute(C);return false}u?g.changeSelectedAttributeNoUndo(C,E):g.changeSelectedAttribute(C,
E)};a("#palette").mouseover(function(){var k=a('<input type="hidden">');a(this).append(k);k.focus().remove()});a(".palette_item").on("mousedown touchstart touchmove",function(){var k=a("#tool_stroke").hasClass("active"),u=k?"stroke":"fill",C=a(this).attr("data-rgb"),E=null;if(C==="transparent"||C==="initial"||C==="#none"){C="none";E=new a.jGraduate.Paint}else E=new a.jGraduate.Paint({alpha:100,solidColor:C.substr(1)});c.paintBox[u].setPaint(E);if(k){g.setColor("stroke",C);C!="none"&&g.getStrokeOpacity()!=
a("#seg_type_label").html(this.options[this.selectedIndex].text)});a("select").change(function(){a(this).blur()});a("#font_family").change(function(){g.setFontFamily(this.value)});a("#text").keyup(function(){g.setTextContent(this.value)});changeAttribute=function(k,u){var C=k.getAttribute("data-attr"),D=k.value;if(!svgedit.units.isValidUnit(C,D,W)){a.alert(uiStrings.notification.invalidAttrValGiven);k.value=W.getAttribute(C);return false}u?g.changeSelectedAttributeNoUndo(C,D):g.changeSelectedAttribute(C,
D)};a("#palette").mouseover(function(){var k=a('<input type="hidden">');a(this).append(k);k.focus().remove()});a(".palette_item").on("mousedown touchstart touchmove",function(){var k=a("#tool_stroke").hasClass("active"),u=k?"stroke":"fill",C=a(this).attr("data-rgb"),D=null;if(C==="transparent"||C==="initial"||C==="#none"){C="none";D=new a.jGraduate.Paint}else D=new a.jGraduate.Paint({alpha:100,solidColor:C.substr(1)});c.paintBox[u].setPaint(D);if(k){g.setColor("stroke",C);C!="none"&&g.getStrokeOpacity()!=
1&&g.setPaintOpacity("stroke",1)}else{g.setColor("fill",C);C!="none"&&g.getFillOpacity()!=1&&g.setPaintOpacity("fill",1)}}).bind("contextmenu",function(k){k.preventDefault()});a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display","table-cell");a(this).addClass("expanded");z()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");z()});var $a=function(k,u){if(a(k).hasClass("disabled"))return false;if(a(k).parent().hasClass("tools_flyout"))return true;
var C=C||"normal";u||a(".tools_flyout").fadeOut(C);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(k).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var k=null,u=null,C=Q[0],E=false,P=false;a("#svgcanvas").bind("mousemove mouseup touchend",function(U){if(E!==false){C.scrollLeft-=U.clientX-k;C.scrollTop-=U.clientY-u;k=U.clientX;u=U.clientY;if(U.type==="mouseup"||U.type==="touchend")E=false;return false}}).on("mousedown touchmove",
function(U){if(U.button===1||P===true||U.originalEvent.touches&&U.originalEvent.touches.length>=2){E=true;k=U.clientX;u=U.clientY;return false}});a(window).mouseup(function(){E=false;a("body").removeClass("dragging")});a(document).bind("keydown","space",function(U){U.preventDefault();g.spaceKey=P=true}).bind("keyup","space",function(U){U.preventDefault();g.spaceKey=P=false}).bind("keydown","alt",function(){g.getMode()==="zoom"&&Q.addClass("out")}).bind("keyup","alt",function(){g.getMode()==="zoom"&&
Q.removeClass("out")})})();var ib=a(".menu"),Va=function(k){k.target.style.background="#fff";setTimeout(function(){k.target.style.background="#ddd"},50);setTimeout(function(){k.target.style.background="#fff"},150);setTimeout(function(){k.target.style.background="#ddd"},200);setTimeout(function(){k.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").on("mousedown touchstart",function(k){Va(k)});a("svg, body").on("mousedown touchstart",
function(k){top!=self&&!k.isTrigger&&typeof top.exports.setEditorFocus=="function"&&top.exports.setEditorFocus();if(!a(k.target).hasClass("menu_title")&&!a(k.target).parent().hasClass("menu_title"))!a(k.target).hasClass("disabled")&&a(k.target).hasClass("menu_item")?Va(k):a("#menu_bar").removeClass("active")});var Ra=[6,12,16,33,50,66,100,150,200,300,400,600,800,1200];a("#workarea").on("mousewheel",function(k,u,C,E){if(k.altKey){k.preventDefault();k=g.getZoom()*100;u=Ra.length;for(D=0;D<u;D++){C=
Math.min(u,D+1);if(E>0)zoom=Ra[D]<=k?Ra[C]:zoom;if(E<0)zoom=Ra[D]<k?Ra[D]:zoom}zoom&&wa({value:zoom})}});a(".menu_title").on("mousedown",function(){a("#tools_shapelib").hide();a("#menu_bar").toggleClass("active");ib.removeClass("open");a(this).parent().addClass("open")}).on("mouseover",function(){ib.removeClass("open");a(this).parent().addClass("open")});c.addDropDown=function(k,u,C){if(a(k).length!=0){var E=a(k).find("button"),P=a(k).find("ul").attr("id",a(k)[0].id+"-list");C||a("#option_lists").append(P);
var U=false;C&&a(k).addClass("dropup");P.find("li").bind("mouseup",u);a(window).mouseup(function(){if(!U){E.removeClass("down");P.hide()}U=false});E.bind("mousedown",function(){if(E.hasClass("down")){E.removeClass("down");P.hide()}else{E.addClass("down");if(!C){var S=a(k).offset();P.css({top:S.top,left:S.left-110})}P.show();U=true}}).hover(function(){U=true}).mouseout(function(){U=false})}};var Da=function(k,u,C,E){var P=a(k);u=a(u);var U=false,S=E.dropUp;S&&a(k).addClass("dropup");u.find("li").bind("mouseup",
function(){if(E.seticon){xb("#cur_"+P[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}C.apply(this,arguments)});a(window).mouseup(function(){if(!U){P.removeClass("down");u.hide();u.css({top:0,left:0})}U=false});u.height();a(k).bind("mousedown",function(){var X=a(k).offset();if(S){X.top-=u.height();X.left+=8}else X.top+=a(k).height();a(u).offset(X);if(P.hasClass("down")){P.removeClass("down");u.hide();u.css({top:0,left:0})}else{P.addClass("down");u.show();U=
true;return false}}).hover(function(){U=true}).mouseout(function(){U=false});E.multiclick&&u.mousedown(function(){U=true})};a("#font_family_dropdown").change(function(){var k=this.options[this.selectedIndex].value,u=this.options[this.selectedIndex].text;a("#preview_font").html(u).css("font-family",k);a("#font_family").val(k).change()});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var k=this.id.replace("tool_pos","").charAt(0);g.alignSelectedElements(k,"page")})});
(function(){var k,u=function(){a(k).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){k=this;pa="toolbars";Q.mousedown(u)}).blur(function(){pa="canvas";Q.unbind("mousedown",u);g.getMode()=="textedit"&&a("#text").focus()})})();var va=function(){$a("#tool_select")&&g.setMode("select")},fb=function(){$a("#tool_fhpath")&&g.setMode("fhpath")},La=function(){$a("#tool_line")&&g.setMode("line")},Ua=function(){$a("#tool_rect")&&g.setMode("rect")},Ea=function(){$a("#tool_ellipse")&&
g.setMode("ellipse")},kb=function(){$a("#tool_image")&&g.setMode("image")},sb=function(){$a("#tool_zoom")&&g.setMode("zoom")},Za=function(){if($a("#tool_zoom")){Db();ba()}},bb=function(){$a("#tool_text")&&g.setMode("text")},Cb=function(){$a("#tool_path")&&g.setMode("path")},ta=function(){if(W!=null||sa)g.deleteSelectedElements()},mb=function(){if(W!=null||sa){window.event.type==="keydown"&&pb(a("#edit_menu"));g.cutSelectedElements()}},jb=function(){if(W!=null||sa){window.event.type==="keydown"&&pb(a("#edit_menu"));
g.copySelectedElements()}},zb=function(){window.event.type==="keydown"&&pb(a("#edit_menu"));var k=g.getZoom(),u=(Q[0].scrollLeft+Q.width()/2)/k-g.contentW;k=(Q[0].scrollTop+Q.height()/2)/k-g.contentH;g.pasteElements("point",u,k)},ob=function(){if(W!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveToTopSelectedElement()}},eb=function(){if(W!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveToBottomSelectedElement()}},tb=function(){if(W!=null){window.event.type==="keydown"&&
pb(a("#object_menu"));g.moveUpDownSelected("Up")}},ub=function(){if(W!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveUpDownSelected("Down")}},wb=function(k){if(W!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveUpDownSelected(k)}},Ab=function(){if(W!=null){g.convertToPath();elems=g.getSelectedElems();g.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");g.setMode("pathedit");K.toEditMode(elems[0]);g.clearSelection()}},la=function(){W!=
null&&K.reorient()},ca=function(){if(W!=null||sa)a.prompt(uiStrings.notification.enterNewLinkURL,"http://",function(k){k&&g.makeHyperlink(k)})},ja=function(k,u){if(W!=null||sa){if(curConfig.gridSnapping){var C=g.getZoom()*curConfig.snappingStep;k*=C;u*=C}a("input").blur();g.moveSelectedElements(k,u)}},N=function(){var k=!a("#tool_node_link").hasClass("checked");k?a("#tool_node_link").addClass("checked").find("input").attr("checked",true):a("#tool_node_link").removeClass("checked").find("input").attr("checked",
false);K.linkControlPoints(k)},R=function(){K.getNodePoint()&&K.clonePathNode()},ea=function(){K.getNodePoint()&&K.deletePathNode()},Ga=function(){var k=a("#tool_add_subpath"),u=!k.hasClass("push_button_pressed");u?k.addClass("push_button_pressed").removeClass("tool_button"):k.removeClass("push_button_pressed").addClass("tool_button");K.addSubPath(u)},Oa=function(){K.opencloseSubPath()},Ya=function(){g.cycleElement(1)},db=function(){g.cycleElement(0)},nb=function(k,u){if(!(W==null||sa)){k||(u*=-1);
var C=a("#angle").val()*1+u;g.setRotationAngle(C);za()}},Xa=function(){var k=curConfig.dimensions;a.confirm(uiStrings.notification.QwantToClear,function(u){if(u){ba();g.clear();g.setResolution(k[0],k[1]);F(true);Db();za();Z();g.runExtensions("onNewDocument")}})},rb=function(){g.setBold(!g.getBold());za();return false},Pa=function(){g.setItalic(!g.getItalic());za();return false},vb=function(){if(!b.pngsave){var k=uiStrings.notification.loadingImage;O=window.open("data:text/html;charset=utf-8,<title>"+
k+"</title><h1>"+k+"</h1>")}window.canvg?g.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){g.rasterExport()})})},Bb=function(){g.open()},Ib=function(){},pb=function(k){var u=k.prev();u.css("background","#09f");setTimeout(function(){u.css("background","")},200)},hb=function(){if(T.getUndoStackSize()>0){window.event.type==="keydown"&&pb(a("#edit_menu"));T.undo()}},Ja=function(){if(T.getRedoStackSize()>0){window.event.type==="keydown"&&pb(a("#edit_menu"));
T.redo()}},Kb=function(){if(sa)g.groupSelectedElements();else W&&g.ungroupSelectedElement()},Nb=function(){window.event.type==="keydown"&&pb(a("#edit_menu"));g.cloneSelectedElements(20,20)},Lb=function(){var k=this.id.replace("tool_align","").charAt(0);g.alignSelectedElements(k,a("#align_relative_to").val())},Ob=function(){var k=document.querySelector("#tool_stroke rect"),u=document.querySelector("#tool_fill rect"),C=u.getAttribute("fill"),E=k.getAttribute("fill");k=parseFloat(k.getAttribute("stroke-opacity"));
if(isNaN(k))k=100;u=parseFloat(u.getAttribute("fill-opacity"));if(isNaN(u))u=100;E=Ia(E,k,"stroke");C=Ia(C,u,"fill");c.paintBox.fill.setPaint(E,true);c.paintBox.stroke.setPaint(C,true)},Db=function(k){var u=g.getResolution();k=k?u.zoom*k:1;a("#zoom").val(k*100);g.setZoom(k);lb();F(true)},Fb=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");Q.toggleClass("wireframe");if(!H){var k=
var C=C||"normal";u||a(".tools_flyout").fadeOut(C);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(k).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var k=null,u=null,C=Q[0],D=false,P=false;a("#svgcanvas").bind("mousemove mouseup touchend",function(U){if(D!==false){C.scrollLeft-=U.clientX-k;C.scrollTop-=U.clientY-u;k=U.clientX;u=U.clientY;if(U.type==="mouseup"||U.type==="touchend")D=false;return false}}).on("mousedown touchmove",
function(U){if(U.button===1||P===true||U.originalEvent.touches&&U.originalEvent.touches.length>=2){D=true;k=U.clientX;u=U.clientY;return false}});a(window).mouseup(function(){D=false;a("body").removeClass("dragging")});a(document).bind("keydown","space",function(U){U.preventDefault();g.spaceKey=P=true}).bind("keyup","space",function(U){U.preventDefault();g.spaceKey=P=false}).bind("keydown","alt",function(){g.getMode()==="zoom"&&Q.addClass("out")}).bind("keyup","alt",function(){g.getMode()==="zoom"&&
Q.removeClass("out")})})();var ib=a(".menu"),Wa=function(k){k.target.style.background="#fff";setTimeout(function(){k.target.style.background="#ddd"},50);setTimeout(function(){k.target.style.background="#fff"},150);setTimeout(function(){k.target.style.background="#ddd"},200);setTimeout(function(){k.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").on("mousedown touchstart",function(k){Wa(k)});a("svg, body").on("mousedown touchstart",
function(k){top!=self&&!k.isTrigger&&typeof top.exports.setEditorFocus=="function"&&top.exports.setEditorFocus();if(k.target.nodeName.toLowerCase()!=="input")if(!a(k.target).hasClass("menu_title")&&!a(k.target).parent().hasClass("menu_title"))!a(k.target).hasClass("disabled")&&a(k.target).hasClass("menu_item")?Wa(k):a("#menu_bar").removeClass("active")});var Sa=[6,12,16,33,50,66,100,150,200,300,400,600,800,1200];a("#workarea").on("mousewheel",function(k,u,C,D){if(k.altKey){k.preventDefault();k=g.getZoom()*
100;u=Sa.length;for(E=0;E<u;E++){C=Math.min(u,E+1);if(D>0)zoom=Sa[E]<=k?Sa[C]:zoom;if(D<0)zoom=Sa[E]<k?Sa[E]:zoom}zoom&&wa({value:zoom})}});a(".menu_title").on("mousedown",function(){a("#tools_shapelib").hide();a("#menu_bar").toggleClass("active");ib.removeClass("open");a(this).parent().addClass("open")}).on("mouseover",function(){ib.removeClass("open");a(this).parent().addClass("open")});c.addDropDown=function(k,u,C){if(a(k).length!=0){var D=a(k).find("button"),P=a(k).find("ul").attr("id",a(k)[0].id+
"-list");C||a("#option_lists").append(P);var U=false;C&&a(k).addClass("dropup");P.find("li").bind("mouseup",u);a(window).mouseup(function(){if(!U){D.removeClass("down");P.hide()}U=false});D.bind("mousedown",function(){if(D.hasClass("down")){D.removeClass("down");P.hide()}else{D.addClass("down");if(!C){var S=a(k).offset();P.css({top:S.top,left:S.left-110})}P.show();U=true}}).hover(function(){U=true}).mouseout(function(){U=false})}};var Da=function(k,u,C,D){var P=a(k);u=a(u);var U=false,S=D.dropUp;
S&&a(k).addClass("dropup");u.find("li").bind("mouseup",function(){if(D.seticon){yb("#cur_"+P[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}C.apply(this,arguments)});a(window).mouseup(function(){if(!U){P.removeClass("down");u.hide();u.css({top:0,left:0})}U=false});u.height();a(k).bind("mousedown",function(){var Y=a(k).offset();if(S){Y.top-=u.height();Y.left+=8}else Y.top+=a(k).height();a(u).offset(Y);if(P.hasClass("down")){P.removeClass("down");u.hide();u.css({top:0,
left:0})}else{P.addClass("down");u.show();U=true;return false}}).hover(function(){U=true}).mouseout(function(){U=false});D.multiclick&&u.mousedown(function(){U=true})};a("#font_family_dropdown").change(function(){var k=this.options[this.selectedIndex].value,u=this.options[this.selectedIndex].text;a("#preview_font").html(u).css("font-family",k);a("#font_family").val(k).change()});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var k=this.id.replace("tool_pos","").charAt(0);
g.alignSelectedElements(k,"page")})});(function(){var k,u=function(){a(k).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){k=this;pa="toolbars";Q.mousedown(u)}).blur(function(){pa="canvas";Q.unbind("mousedown",u);g.getMode()=="textedit"&&a("#text").focus()})})();var va=function(){$a("#tool_select")&&g.setMode("select")},fb=function(){$a("#tool_fhpath")&&g.setMode("fhpath")},La=function(){$a("#tool_line")&&g.setMode("line")},Va=function(){$a("#tool_rect")&&g.setMode("rect")},
Ea=function(){$a("#tool_ellipse")&&g.setMode("ellipse")},kb=function(){$a("#tool_image")&&g.setMode("image")},sb=function(){$a("#tool_zoom")&&g.setMode("zoom")},Za=function(){if($a("#tool_zoom")){Db();ba()}},bb=function(){$a("#tool_text")&&g.setMode("text")},Cb=function(){$a("#tool_path")&&g.setMode("path")},ua=function(){if(W!=null||sa)g.deleteSelectedElements()},mb=function(){if(W!=null||sa){window.event.type==="keydown"&&pb(a("#edit_menu"));g.cutSelectedElements()}},jb=function(){if(W!=null||sa){window.event.type===
"keydown"&&pb(a("#edit_menu"));g.copySelectedElements()}},Ab=function(){window.event.type==="keydown"&&pb(a("#edit_menu"));var k=g.getZoom(),u=(Q[0].scrollLeft+Q.width()/2)/k-g.contentW;k=(Q[0].scrollTop+Q.height()/2)/k-g.contentH;g.pasteElements("point",u,k)},ob=function(){if(W!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveToTopSelectedElement()}},eb=function(){if(W!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveToBottomSelectedElement()}},tb=function(){if(W!=
null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveUpDownSelected("Up")}},ub=function(){if(W!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveUpDownSelected("Down")}},wb=function(k){if(W!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveUpDownSelected(k)}},Bb=function(){if(W!=null){g.convertToPath();elems=g.getSelectedElems();g.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");g.setMode("pathedit");K.toEditMode(elems[0]);
g.clearSelection()}},la=function(){W!=null&&K.reorient()},ca=function(){if(W!=null||sa)a.prompt(uiStrings.notification.enterNewLinkURL,"http://",function(k){k&&g.makeHyperlink(k)})},ja=function(k,u){if(W!=null||sa){if(curConfig.gridSnapping){var C=g.getZoom()*curConfig.snappingStep;k*=C;u*=C}a("input").blur();g.moveSelectedElements(k,u)}},N=function(){var k=!a("#tool_node_link").hasClass("checked");k?a("#tool_node_link").addClass("checked").find("input").attr("checked",true):a("#tool_node_link").removeClass("checked").find("input").attr("checked",
false);K.linkControlPoints(k)},R=function(){K.getNodePoint()&&K.clonePathNode()},ea=function(){K.getNodePoint()&&K.deletePathNode()},Ga=function(){var k=a("#tool_add_subpath"),u=!k.hasClass("push_button_pressed");u?k.addClass("push_button_pressed").removeClass("tool_button"):k.removeClass("push_button_pressed").addClass("tool_button");K.addSubPath(u)},Pa=function(){K.opencloseSubPath()},Ya=function(){g.cycleElement(1)},db=function(){g.cycleElement(0)},nb=function(k,u){if(!(W==null||sa)){k||(u*=-1);
var C=a("#angle").val()*1+u;g.setRotationAngle(C);za()}},Ua=function(){var k=curConfig.dimensions;a.confirm(uiStrings.notification.QwantToClear,function(u){if(u){ba();g.clear();g.setResolution(k[0],k[1]);F(true);Db();za();Z();g.runExtensions("onNewDocument")}})},rb=function(){g.setBold(!g.getBold());za();return false},Qa=function(){g.setItalic(!g.getItalic());za();return false},vb=function(){if(!b.pngsave){var k=uiStrings.notification.loadingImage;O=window.open("data:text/html;charset=utf-8,<title>"+
k+"</title><h1>"+k+"</h1>")}window.canvg?g.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){g.rasterExport()})})},xb=function(){g.open()},Ib=function(){},pb=function(k){var u=k.prev();u.css("background","#09f");setTimeout(function(){u.css("background","")},200)},hb=function(){if(T.getUndoStackSize()>0){window.event.type==="keydown"&&pb(a("#edit_menu"));T.undo()}},Ja=function(){if(T.getRedoStackSize()>0){window.event.type==="keydown"&&pb(a("#edit_menu"));
T.redo()}},Kb=function(){if(sa)g.groupSelectedElements();else W&&g.ungroupSelectedElement()},Nb=function(){window.event.type==="keydown"&&pb(a("#edit_menu"));g.cloneSelectedElements(20,20)},Lb=function(){var k=this.id.replace("tool_align","").charAt(0);g.alignSelectedElements(k,a("#align_relative_to").val())},Ob=function(){var k=document.querySelector("#tool_stroke rect"),u=document.querySelector("#tool_fill rect"),C=u.getAttribute("fill"),D=k.getAttribute("fill");k=parseFloat(k.getAttribute("stroke-opacity"));
if(isNaN(k))k=100;u=parseFloat(u.getAttribute("fill-opacity"));if(isNaN(u))u=100;D=Ia(D,k,"stroke");C=Ia(C,u,"fill");c.paintBox.fill.setPaint(D,true);c.paintBox.stroke.setPaint(C,true)},Db=function(k){var u=g.getResolution();k=k?u.zoom*k:1;a("#zoom").val(k*100);g.setZoom(k);lb();F(true)},Fb=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");Q.toggleClass("wireframe");if(!H){var k=
a("#wireframe_rules");k.length?k.empty():a('<style id="wireframe_rules"></style>').appendTo("head");lb()}},Jb=function(){var k=!a("#tool_snap").hasClass("push_button_pressed");k?a("#tool_snap").addClass("push_button_pressed"):a("#tool_snap").removeClass("push_button_pressed");curConfig.gridSnapping=k},Rb=function(){window.self!=window.top&&top.exports.setEditorFocus(false)},Eb=function(){if(a("#tool_rulers").hasClass("push_button_pressed")){a("#tool_rulers").removeClass("push_button_pressed");a("#show_rulers").attr("checked",
false);curConfig.showRulers=false}else{a("#tool_rulers").addClass("push_button_pressed");a("#show_rulers").attr("checked",true);curConfig.showRulers=true}a("#rulers").toggle(!!curConfig.showRulers)},lb=function(){if(!H){var k="#workarea.wireframe #svgcontent * { stroke-width: "+1/g.getZoom()+"px; }";a("#wireframe_rules").text(Q.hasClass("wireframe")?k:"")}},Qb=function(k,u){if(!ka){ka=true;a("#save_output_btns").toggle(!!u);a("#tool_source_back").toggle(!u);var C=fa=g.getSvgString();a("#svg_source_textarea").val(C);
a("#svg_source_editor").fadeIn();C=a("#svg_source_container").height()-50;a("#svg_source_textarea").css("height",C);a("#svg_source_textarea").focus()}},Pb=function(){if(ka){if(g.setSvgString(a("#svg_source_textarea").val())){g.clearSelection();m();Db();Z()}else a.confirm(uiStrings.notification.QerrorsRevertToSource,function(k){if(!k)return false;g.clearSelection();m();Db();Z()});ba()}},xb=c.setIcon=function(k,u){var C=typeof u==="string"?a.getSvgIcon(u,true):u.clone();C?a(k).find("img").replaceWith(C):
console.log("NOTE: Icon image missing: "+u)},gb;gb=function(){var k=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,u=document.getElementsByTagName("script")[0],C;for(C in u.style)if(k.test(C))return C.match(k)[0];if("WebkitOpacity"in u.style)return"Webkit";if("KhtmlOpacity"in u.style)return"Khtml";return""}();var Mb=function(k,u){gb.toLowerCase();var C=["top","left","bottom","right"];k.each(function(){for(var E=a(this),P=E.outerWidth()*(u-1),U=E.outerHeight()*(u-1),S=0;S<4;S++){var X=C[S],aa=E.data("orig_margin-"+
X);if(aa==null){aa=parseInt(E.css("margin-"+X));E.data("orig_margin-"+X,aa)}aa=aa*u;if(X==="right")aa+=P;else if(X==="bottom")aa+=U;E.css("margin-"+X,aa)}})},e=c.setIconSize=function(k,u){if(!(k==s.size&&!u)){var C=a("#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout"),E=1;E=typeof k=="number"?k:{s:0.75,m:1,l:1.25,xl:1.5}[k];c.tool_scale=ia=E;na();
var P=C.parents(":hidden");P.css("visibility","hidden").show();Mb(C,E);P.css("visibility","visible").hide();C=a("#tool_size_rules");if(C.length)C.empty();else C=a('<style id="tool_size_rules"></style>').appendTo("head");if(k!="m"){var U="";a.each(cssResizeRules,function(S,X){S="#svg_editor "+S.replace(/,/g,", #svg_editor");U+=S+"{";a.each(X,function(aa,ga){if(typeof ga==="number")var ra=ga*E+"px";else if(ga[k]||ga.all)ra=ga[k]||ga.all;U+=aa+":"+ra+";"});U+="}"});P="-"+gb.toLowerCase()+"-";U+="#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout{"+
P+"transform: scale("+E+");} #svg_editor div.toolset .toolset {"+P+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+P+"transform: scale("+1/E+");}";C.text(U)}na()}},h=function(){a("#dialog_box").hide();if(ka){if(ka)fa!==a("#svg_source_textarea").val()?a.confirm(uiStrings.notification.QignoreSourceChanges,function(k){k&&m()}):m();z()}else da&&g.leaveContext()},m=function(){a("#svg_source_editor").hide();ka=false;a("#svg_source_textarea").blur()};a(window).width();a(window).height();
a("#svg_source_editor").fadeIn();C=a("#svg_source_container").height()-50;a("#svg_source_textarea").css("height",C);a("#svg_source_textarea").focus()}},Pb=function(){if(ka){if(g.setSvgString(a("#svg_source_textarea").val())){g.clearSelection();m();Db();Z()}else a.confirm(uiStrings.notification.QerrorsRevertToSource,function(k){if(!k)return false;g.clearSelection();m();Db();Z()});ba()}},yb=c.setIcon=function(k,u){var C=typeof u==="string"?a.getSvgIcon(u,true):u.clone();C?a(k).find("img").replaceWith(C):
console.log("NOTE: Icon image missing: "+u)},gb;gb=function(){var k=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,u=document.getElementsByTagName("script")[0],C;for(C in u.style)if(k.test(C))return C.match(k)[0];if("WebkitOpacity"in u.style)return"Webkit";if("KhtmlOpacity"in u.style)return"Khtml";return""}();var Mb=function(k,u){gb.toLowerCase();var C=["top","left","bottom","right"];k.each(function(){for(var D=a(this),P=D.outerWidth()*(u-1),U=D.outerHeight()*(u-1),S=0;S<4;S++){var Y=C[S],aa=D.data("orig_margin-"+
Y);if(aa==null){aa=parseInt(D.css("margin-"+Y));D.data("orig_margin-"+Y,aa)}aa=aa*u;if(Y==="right")aa+=P;else if(Y==="bottom")aa+=U;D.css("margin-"+Y,aa)}})},e=c.setIconSize=function(k,u){if(!(k==s.size&&!u)){var C=a("#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout"),D=1;D=typeof k=="number"?k:{s:0.75,m:1,l:1.25,xl:1.5}[k];c.tool_scale=ia=D;na();
var P=C.parents(":hidden");P.css("visibility","hidden").show();Mb(C,D);P.css("visibility","visible").hide();C=a("#tool_size_rules");if(C.length)C.empty();else C=a('<style id="tool_size_rules"></style>').appendTo("head");if(k!="m"){var U="";a.each(cssResizeRules,function(S,Y){S="#svg_editor "+S.replace(/,/g,", #svg_editor");U+=S+"{";a.each(Y,function(aa,ga){if(typeof ga==="number")var ra=ga*D+"px";else if(ga[k]||ga.all)ra=ga[k]||ga.all;U+=aa+":"+ra+";"});U+="}"});P="-"+gb.toLowerCase()+"-";U+="#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout{"+
P+"transform: scale("+D+");} #svg_editor div.toolset .toolset {"+P+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+P+"transform: scale("+1/D+");}";C.text(U)}na()}},h=function(){a("#dialog_box").hide();if(ka){if(ka)fa!==a("#svg_source_textarea").val()?a.confirm(uiStrings.notification.QignoreSourceChanges,function(k){k&&m()}):m();z()}else da&&g.leaveContext()},m=function(){a("#svg_source_editor").hide();ka=false;a("#svg_source_textarea").blur()};a(window).width();a(window).height();
var z=a.noop;a(window).resize(function(){F()});(function(){Q.scroll(function(){if(a("#ruler_x").length!=0)a("#ruler_x")[0].scrollLeft=Q[0].scrollLeft;if(a("#ruler_y").length!=0)a("#ruler_y")[0].scrollTop=Q[0].scrollTop})})();a("#url_notice").click(function(){a.alert(this.title)});a("#change_image_url").click(function(){var k=g.getHref(W);k=k.indexOf("data:")===0?"":k;a.prompt(uiStrings.notification.enterNewImgURL,k,function(u){u&&Na(u)})});var w=function(k){var u=k[0].id=="stroke_color"?"stroke":
"fill",C=k[0].id=="canvas_color";if(C)u="canvas";var E=c.paintBox[u].paint;k=u=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity";C=C?{right:200,top:50}:{left:45,bottom:50};a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",containment:"window"}).css(C).jGraduate({paint:E,window:{pickerTitle:k},images:{clientPath:curConfig.jGraduatePath},newstop:"inverse"},function(P){E=new a.jGraduate.Paint(P);c.paintBox[u].setPaint(E);
g.setPaint(u,E);a("#color_picker").hide()},function(){a("#color_picker").hide()})};q=function(k,u){var C=document.getElementById("canvas_background"),E={color:"fff",opacity:1};if(u=="stroke")E=curConfig.initStroke;if(u=="fill")E=curConfig.initFill;if(u=="canvas"&&C)if(C=C.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))E={color:("0"+parseInt(C[1],10).toString(16)).slice(-2)+("0"+parseInt(C[2],10).toString(16)).slice(-2)+("0"+parseInt(C[3],10).toString(16)).slice(-2),opacity:1};C=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+
E.color+'" opacity="'+E.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml").documentElement;C=a(k)[0].appendChild(document.importNode(C,true));u==="canvas"?C.setAttribute("width",60.5):C.setAttribute("width","100%");this.rect=C.firstChild;this.defs=C.getElementsByTagName("defs")[0];this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:E.color});this.type=u;this.setPaint=function(P,U){this.paint=P;var S="none",X=P.type,aa=P.alpha/100;switch(X){case "solidColor":S=
P[X]=="none"||P[X]=="one"?"none":"#"+P[X];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);this.grad=this.defs.appendChild(P[X]);S="url(#"+(this.grad.id="gradbox_"+this.type)+")"}this.rect.setAttribute("fill",S);this.rect.setAttribute("opacity",aa);if(U){g.setColor(this.type,S,true);g.setPaintOpacity(this.type,aa,true)}if(this.type=="canvas")(X=document.getElementById("canvas_background"))?X.setAttribute("fill",S):Ka(S)};this.update=function(P){if(W){var U=this.type;
switch(W.tagName){case "use":case "image":case "foreignObject":return;case "g":case "a":for(var S=null,X=W.getElementsByTagName("*"),aa=0,ga=X.length;aa<ga;aa++){var ra=X[aa].getAttribute(U);if(aa===0)S=ra;else if(S!==ra){S=null;break}}if(S===null){X=null;return}X=S;S=1;break;default:S=parseFloat(W.getAttribute(U+"-opacity"));if(isNaN(S))S=1;X=U==="fill"?"black":"none";X=W.getAttribute(U)||X}if(P){g.setColor(U,X,true);g.setPaintOpacity(U,S,true)}S*=100;this.setPaint(Ia(X,S,U))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var P=
"fill",C=k[0].id=="canvas_color";if(C)u="canvas";var D=c.paintBox[u].paint;k=u=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity";C=C?{right:200,top:50}:{left:45,bottom:50};a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",containment:"window"}).css(C).jGraduate({paint:D,window:{pickerTitle:k},images:{clientPath:curConfig.jGraduatePath},newstop:"inverse"},function(P){D=new a.jGraduate.Paint(P);c.paintBox[u].setPaint(D);
g.setPaint(u,D);a("#color_picker").hide()},function(){a("#color_picker").hide()})};q=function(k,u){var C=document.getElementById("canvas_background"),D={color:"fff",opacity:1};if(u=="stroke")D=curConfig.initStroke;if(u=="fill")D=curConfig.initFill;if(u=="canvas"&&C)if(C=C.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))D={color:("0"+parseInt(C[1],10).toString(16)).slice(-2)+("0"+parseInt(C[2],10).toString(16)).slice(-2)+("0"+parseInt(C[3],10).toString(16)).slice(-2),opacity:1};C=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+
D.color+'" opacity="'+D.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml").documentElement;C=a(k)[0].appendChild(document.importNode(C,true));u==="canvas"?C.setAttribute("width",60.5):C.setAttribute("width","100%");this.rect=C.firstChild;this.defs=C.getElementsByTagName("defs")[0];this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:D.color});this.type=u;this.setPaint=function(P,U){this.paint=P;var S="none",Y=P.type,aa=P.alpha/100;switch(Y){case "solidColor":S=
P[Y]=="none"||P[Y]=="one"?"none":"#"+P[Y];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);this.grad=this.defs.appendChild(P[Y]);S="url(#"+(this.grad.id="gradbox_"+this.type)+")"}this.rect.setAttribute("fill",S);this.rect.setAttribute("opacity",aa);if(U){g.setColor(this.type,S,true);g.setPaintOpacity(this.type,aa,true)}if(this.type=="canvas")(Y=document.getElementById("canvas_background"))?Y.setAttribute("fill",S):Ka(S)};this.update=function(P){if(W){var U=this.type;
switch(W.tagName){case "use":case "image":case "foreignObject":return;case "g":case "a":for(var S=null,Y=W.getElementsByTagName("*"),aa=0,ga=Y.length;aa<ga;aa++){var ra=Y[aa].getAttribute(U);if(aa===0)S=ra;else if(S!==ra){S=null;break}}if(S===null){Y=null;return}Y=S;S=1;break;default:S=parseFloat(W.getAttribute(U+"-opacity"));if(isNaN(S))S=1;Y=U==="fill"?"black":"none";Y=W.getAttribute(U)||Y}if(P){g.setColor(U,Y,true);g.setPaintOpacity(U,S,true)}S*=100;this.setPaint(Ia(Y,S,U))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var P=
new a.jGraduate.Paint({copy:this.paint});g.setPaint(u,P)}}};c.paintBox.fill=new q("#fill_color","fill");c.paintBox.stroke=new q("#stroke_color","stroke");c.paintBox.canvas=new q("#canvas_color","canvas");a("#stroke_width").val(curConfig.initStroke.width);a("#group_opacity").val(curConfig.initOpacity*100);q=c.paintBox.fill.rect.cloneNode(false);q.setAttribute("style","vector-effect:non-scaling-stroke");var H=q.style.vectorEffect==="non-scaling-stroke";q.removeAttribute("style");q=c.paintBox.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg",
"feGaussianBlur");typeof q.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(q).remove();setTimeout(function(){g.embedImage("images/placeholder.svg",function(k){if(!k){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);s.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",uiStrings.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))w(a("#fill_color"));else{a("#tool_fill").addClass("active");
a("#tool_stroke").removeClass("active")}});a("#tool_stroke").on("click",function(){if(a("#tool_stroke").hasClass("active"))w(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#tool_canvas").on("click touchstart",function(){w(a("#canvas_color"))});a("#tool_stroke").on("touchstart",function(){a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active");w(a("#stroke_color"))});a("#tool_fill").on("touchstart",function(){a("#tool_fill").addClass("active");
a("#tool_stroke").removeClass("active");w(a("#fill_color"))});a("#zoom_select").on("change",function(){var k=this.options[this.selectedIndex].text;k=k.split("%")[0];a("#zoom").val(k).trigger("change")});a(".push_button").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("push_button_pressed").removeClass("push_button")}).mouseout(function(){a(this).removeClass("push_button_pressed").addClass("push_button")}).mouseup(function(){a(this).removeClass("push_button_pressed").addClass("push_button")});
a(window).bind("load resize",function(){Q.css("line-height",Q.height()+"px")});var A=function(){var k=a("#canvas_width"),u=a("#canvas_height"),C=k.val(),E=u.val();if(C!="fit"&&!svgedit.units.isValidUnit("width",C)){a.alert(uiStrings.notification.invalidAttrValGiven);k.parent().addClass("error");return false}k.parent().removeClass("error");if(E!="fit"&&!svgedit.units.isValidUnit("height",E)){a.alert(uiStrings.notification.invalidAttrValGiven);u.parent().addClass("error");return false}u.parent().removeClass("error");
if(!g.setResolution(C,E)){a.alert(uiStrings.notification.noContentToFitTo);C=g.getResolution();k.val(C.w);u.val(C.h);return false}F()};a("#resolution").change(function(){var k=a("#canvas_width")[0],u=a("#canvas_height")[0];if(this.selectedIndex)if(this.value=="content"){k.value="fit";u.value="fit";A();var C=g.getResolution();k.value=C.w;u.value=C.h}else{var E=this.value.split("x");E[0]=parseInt(E[0]);E[1]=parseInt(E[1]);var P=E[0]-k.value,U=E[1]-u.value,S=Date.now(),X=function(aa){aa=(aa-S)/1E3;aa=
Math.pow(aa-1,3)+1;k.value=(E[0]-P+aa*P).toFixed(0);u.value=(E[1]-U+aa*U).toFixed(0);A();if(aa>=1){aa=g.getResolution();a("#canvas_width").val(aa.w.toFixed());a("#canvas_height").val(aa.h.toFixed());a("#resolution_label").html("<div class='pull'>"+aa.w+"<span>\u00d7</span></br>"+aa.h+"</div>")}else requestAnimationFrame(X)};X(Date.now())}else{a("#resolution_label").html("Custom");k.removeAttribute("readonly");k.focus();k.select();if(k.value=="fit"){k.value=100;u.value=100}}});a("#zoom").change(function(){wa(this)});
a("input,select").attr("autocomplete","off");var v=function(){var k=[{sel:"#tool_select",fn:va,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:fb,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:La,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:Ua,evt:"click",key:["R",true],icon:"rect"},{sel:"#tool_ellipse",fn:Ea,evt:"mouseup",key:["C",true],icon:"ellipse"},{sel:"#tool_path",fn:Cb,evt:"click",key:["P",true]},{sel:"#tool_text",fn:bb,evt:"click",key:["T",true]},{sel:"#tool_image",fn:kb,evt:"mouseup"},
{sel:"#tool_zoom",fn:sb,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",fn:Xa,evt:"mouseup",key:[o+"N",true]},{sel:"#tool_save",fn:function(){ka?Pb():clickSave()},evt:"mouseup",key:[o+"S",true]},{sel:"#tool_export",fn:vb,evt:"mouseup"},{sel:"#tool_open",fn:Bb,evt:"mouseup"},{sel:"#tool_import",fn:Ib,evt:"mouseup"},{sel:"#tool_source",fn:Qb,evt:"click",key:[o+"U",true]},{sel:"#tool_wireframe",fn:Fb,evt:"click"},{sel:"#tool_snap",fn:Jb,evt:"click"},{sel:"#tool_rulers",fn:Eb,evt:"click"},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",
fn:h,evt:"click",key:["esc",false,false],hidekey:true},{sel:"#tool_source_save",fn:Pb,evt:"click"},{sel:"#tool_delete,#tool_delete_multi",fn:ta,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",fn:la,evt:"click"},{sel:"#tool_node_link",fn:N,evt:"click"},{sel:"#tool_node_clone",fn:R,evt:"click"},{sel:"#tool_node_delete",fn:ea,evt:"click"},{sel:"#tool_openclose_path",fn:Oa,evt:"click"},{sel:"#tool_add_subpath",fn:Ga,evt:"click"},{sel:"#tool_move_top",fn:ob,evt:"click",key:o+"shift+up"},
{sel:"#tool_move_bottom",fn:eb,evt:"click",key:o+"shift+down"},{sel:"#tool_move_up",fn:tb,evt:"click",key:[o+"up",true]},{sel:"#tool_move_down",fn:ub,evt:"click",key:[o+"down",true]},{sel:"#tool_topath",fn:Ab,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:ca,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:Nb,evt:"click",key:[o+"D",true]},{sel:"#tool_group",fn:Kb,evt:"click",key:[o+"G",true]},{sel:"#tool_ungroup",fn:Kb,evt:"click",key:o+"shift+G"},{sel:"#tool_unlink_use",fn:Kb,evt:"click"},
{sel:"[id^=tool_align]",fn:Lb,evt:"click"},{sel:"#tool_undo",fn:hb,evt:"click",key:o+"z"},{sel:"#tool_redo",fn:Ja,evt:"click",key:["y",true]},{sel:"#tool_cut",fn:mb,evt:"click",key:[o+"x",true]},{sel:"#tool_copy",fn:jb,evt:"click",key:o+"c"},{sel:"#tool_paste",fn:zb,evt:"click",key:o+"v"},{sel:"#tool_switch",fn:Ob,evt:"click",key:["x",true]},{sel:"#tool_bold",fn:rb,evt:"mousedown",key:[o+"B",true]},{sel:"#tool_italic",fn:Pa,evt:"mousedown",key:[o+"I",true]},{sel:"#copy_save_done",fn:h,evt:"click"},
a(window).bind("load resize",function(){Q.css("line-height",Q.height()+"px")});var A=function(){var k=a("#canvas_width"),u=a("#canvas_height"),C=k.val(),D=u.val();if(C!="fit"&&!svgedit.units.isValidUnit("width",C)){a.alert(uiStrings.notification.invalidAttrValGiven);k.parent().addClass("error");return false}k.parent().removeClass("error");if(D!="fit"&&!svgedit.units.isValidUnit("height",D)){a.alert(uiStrings.notification.invalidAttrValGiven);u.parent().addClass("error");return false}u.parent().removeClass("error");
if(!g.setResolution(C,D)){a.alert(uiStrings.notification.noContentToFitTo);C=g.getResolution();k.val(C.w);u.val(C.h);return false}F()};a("#resolution").change(function(){var k=a("#canvas_width")[0],u=a("#canvas_height")[0];if(this.selectedIndex)if(this.value=="content"){k.value="fit";u.value="fit";A();var C=g.getResolution();k.value=C.w;u.value=C.h}else{var D=this.value.split("x");D[0]=parseInt(D[0]);D[1]=parseInt(D[1]);var P=D[0]-k.value,U=D[1]-u.value,S=Date.now(),Y=function(aa){aa=(aa-S)/1E3;aa=
Math.pow(aa-1,3)+1;k.value=(D[0]-P+aa*P).toFixed(0);u.value=(D[1]-U+aa*U).toFixed(0);A();if(aa>=1){aa=g.getResolution();a("#canvas_width").val(aa.w.toFixed());a("#canvas_height").val(aa.h.toFixed());a("#resolution_label").html("<div class='pull'>"+aa.w+"<span>\u00d7</span></br>"+aa.h+"</div>")}else requestAnimationFrame(Y)};Y(Date.now())}else{a("#resolution_label").html("Custom");k.removeAttribute("readonly");k.focus();k.select();if(k.value=="fit"){k.value=100;u.value=100}}});a("#zoom").change(function(){wa(this)});
a("input,select").attr("autocomplete","off");var v=function(){var k=[{sel:"#tool_select",fn:va,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:fb,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:La,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:Va,evt:"click",key:["R",true],icon:"rect"},{sel:"#tool_ellipse",fn:Ea,evt:"mouseup",key:["C",true],icon:"ellipse"},{sel:"#tool_path",fn:Cb,evt:"click",key:["P",true]},{sel:"#tool_text",fn:bb,evt:"click",key:["T",true]},{sel:"#tool_image",fn:kb,evt:"mouseup"},
{sel:"#tool_zoom",fn:sb,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",fn:Ua,evt:"mouseup",key:[o+"N",true]},{sel:"#tool_save",fn:function(){ka?Pb():clickSave()},evt:"mouseup",key:[o+"S",true]},{sel:"#tool_export",fn:vb,evt:"mouseup"},{sel:"#tool_open",fn:xb,evt:"mouseup"},{sel:"#tool_import",fn:Ib,evt:"mouseup"},{sel:"#tool_source",fn:Qb,evt:"click",key:[o+"U",true]},{sel:"#tool_wireframe",fn:Fb,evt:"click"},{sel:"#tool_snap",fn:Jb,evt:"click"},{sel:"#tool_rulers",fn:Eb,evt:"click"},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",
fn:h,evt:"click",key:["esc",false,false],hidekey:true},{sel:"#tool_source_save",fn:Pb,evt:"click"},{sel:"#tool_delete,#tool_delete_multi",fn:ua,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",fn:la,evt:"click"},{sel:"#tool_node_link",fn:N,evt:"click"},{sel:"#tool_node_clone",fn:R,evt:"click"},{sel:"#tool_node_delete",fn:ea,evt:"click"},{sel:"#tool_openclose_path",fn:Pa,evt:"click"},{sel:"#tool_add_subpath",fn:Ga,evt:"click"},{sel:"#tool_move_top",fn:ob,evt:"click",key:o+"shift+up"},
{sel:"#tool_move_bottom",fn:eb,evt:"click",key:o+"shift+down"},{sel:"#tool_move_up",fn:tb,evt:"click",key:[o+"up",true]},{sel:"#tool_move_down",fn:ub,evt:"click",key:[o+"down",true]},{sel:"#tool_topath",fn:Bb,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:ca,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:Nb,evt:"click",key:[o+"D",true]},{sel:"#tool_group",fn:Kb,evt:"click",key:[o+"G",true]},{sel:"#tool_ungroup",fn:Kb,evt:"click",key:o+"shift+G"},{sel:"#tool_unlink_use",fn:Kb,evt:"click"},
{sel:"[id^=tool_align]",fn:Lb,evt:"click"},{sel:"#tool_undo",fn:hb,evt:"click",key:o+"z"},{sel:"#tool_redo",fn:Ja,evt:"click",key:["y",true]},{sel:"#tool_cut",fn:mb,evt:"click",key:[o+"x",true]},{sel:"#tool_copy",fn:jb,evt:"click",key:o+"c"},{sel:"#tool_paste",fn:Ab,evt:"click",key:o+"v"},{sel:"#tool_switch",fn:Ob,evt:"click",key:["x",true]},{sel:"#tool_bold",fn:rb,evt:"mousedown",key:[o+"B",true]},{sel:"#tool_italic",fn:Qa,evt:"mousedown",key:[o+"I",true]},{sel:"#copy_save_done",fn:h,evt:"click"},
{key:"ctrl+left",fn:function(){nb(0,1)}},{key:"ctrl+right",fn:function(){nb(1,1)}},{key:"ctrl+shift+left",fn:function(){nb(0,5)}},{key:"ctrl+shift+right",fn:function(){nb(1,5)}},{key:"shift+O",fn:db},{key:"shift+P",fn:Ya},{key:[o+"+",true],fn:function(){Db(2)}},{key:[o+"-",true],fn:function(){Db(0.5)}},{key:["up",true],fn:function(){ja(0,-1)}},{key:["down",true],fn:function(){ja(0,1)}},{key:["left",true],fn:function(){ja(-1,0)}},{key:["right",true],fn:function(){ja(1,0)}},{key:"shift+up",fn:function(){ja(0,
-10)}},{key:"shift+down",fn:function(){ja(0,10)}},{key:"shift+left",fn:function(){ja(-10,0)}},{key:"shift+right",fn:function(){ja(10,0)}},{key:["alt+up",true],fn:function(){g.cloneSelectedElements(0,-1)}},{key:["alt+down",true],fn:function(){g.cloneSelectedElements(0,1)}},{key:["alt+left",true],fn:function(){g.cloneSelectedElements(-1,0)}},{key:["alt+right",true],fn:function(){g.cloneSelectedElements(1,0)}},{key:["alt+shift+up",true],fn:function(){g.cloneSelectedElements(0,-10)}},{key:["alt+shift+down",
true],fn:function(){g.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){g.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",true],fn:function(){g.cloneSelectedElements(10,0)}},{key:o+"A",fn:function(){g.selectAllInCurrentLayer()}},{key:o+"shift+z",fn:Ja},{key:"esc",fn:Rb}],u={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var C={};a.each(k,function(E,P){if(P.sel){var U=a(P.sel);if(U.length==0)return true;if(P.evt){if(svgedit.browser.isTouch()&&
P.evt==="click")P.evt="mousedown";U[P.evt](P.fn)}if(P.parent&&a(P.parent+"_show").length!=0){var S=a(P.parent);S.length||(S=ma(P.parent.substr(1)));S.append(U);a.isArray(C[P.parent])||(C[P.parent]=[]);C[P.parent].push(P)}}if(P.key){var X=P.fn,aa=false;if(a.isArray(P.key)){S=P.key[0];if(P.key.length>1)aa=P.key[1]}else S=P.key;S+="";svgedit.browser.isMac&&S.indexOf("+")!=-1&&S.split("+")[0]=="ctrl"&&S.replace("ctrl","cmd");a.each(S.split("/"),function(ra,Ta){a(document).bind("keydown",Ta,function(Ba){X();
aa&&Ba.preventDefault();return false})});if(P.sel&&!P.hidekey&&U.attr("title")){var ga=U.attr("title").split("[")[0]+" ("+S+")";u[S]=P.sel;U.parents("#main_menu").length||U.attr("title",ga)}}});qa(C);a(window).bind("keydown","tab",function(E){if(pa==="canvas"){E.preventDefault();Ya()}}).bind("keydown","shift+tab",function(E){if(pa==="canvas"){E.preventDefault();db()}});a("#tool_zoom").dblclick(Za)},setTitles:function(){a.each(u,function(C,E){var P=a(E).parents("#main_menu").length;a(E).each(function(){var U=
P?a(this).text().split(" [")[0]:this.title.split(" [")[0],S="";a.each(C.split("/"),function(X,aa){var ga=aa.split("+"),ra="";if(ga.length>1){ra=ga[0]+"+";aa=ga[1]}S+=(X?"/":"")+ra+(uiStrings["key_"+aa]||aa)});if(P)this.lastChild.textContent=U+" ["+S+"]";else this.title=U+" ["+S+"]"})})},getButtonData:function(C){var E;a.each(k,function(P,U){if(U.sel===C)E=U});return E}}}();v.setAll();c.ready(function(){var k=curConfig.initTool,u=a("#tools_left, #svg_editor .tools_flyout"),C=u.find("#tool_"+k);k=u.find("#"+
true],fn:function(){g.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){g.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",true],fn:function(){g.cloneSelectedElements(10,0)}},{key:o+"A",fn:function(){g.selectAllInCurrentLayer()}},{key:o+"shift+z",fn:Ja},{key:"esc",fn:Rb}],u={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var C={};a.each(k,function(D,P){if(P.sel){var U=a(P.sel);if(U.length==0)return true;if(P.evt){if(svgedit.browser.isTouch()&&
P.evt==="click")P.evt="mousedown";U[P.evt](P.fn)}if(P.parent&&a(P.parent+"_show").length!=0){var S=a(P.parent);S.length||(S=ma(P.parent.substr(1)));S.append(U);a.isArray(C[P.parent])||(C[P.parent]=[]);C[P.parent].push(P)}}if(P.key){var Y=P.fn,aa=false;if(a.isArray(P.key)){S=P.key[0];if(P.key.length>1)aa=P.key[1]}else S=P.key;S+="";svgedit.browser.isMac&&S.indexOf("+")!=-1&&S.split("+")[0]=="ctrl"&&S.replace("ctrl","cmd");a.each(S.split("/"),function(ra,Oa){a(document).bind("keydown",Oa,function(Ba){Y();
aa&&Ba.preventDefault();return false})});if(P.sel&&!P.hidekey&&U.attr("title")){var ga=U.attr("title").split("[")[0]+" ("+S+")";u[S]=P.sel;U.parents("#main_menu").length||U.attr("title",ga)}}});qa(C);a(window).bind("keydown","tab",function(D){if(pa==="canvas"){D.preventDefault();Ya()}}).bind("keydown","shift+tab",function(D){if(pa==="canvas"){D.preventDefault();db()}});a("#tool_zoom").dblclick(Za)},setTitles:function(){a.each(u,function(C,D){var P=a(D).parents("#main_menu").length;a(D).each(function(){var U=
P?a(this).text().split(" [")[0]:this.title.split(" [")[0],S="";a.each(C.split("/"),function(Y,aa){var ga=aa.split("+"),ra="";if(ga.length>1){ra=ga[0]+"+";aa=ga[1]}S+=(Y?"/":"")+ra+(uiStrings["key_"+aa]||aa)});if(P)this.lastChild.textContent=U+" ["+S+"]";else this.title=U+" ["+S+"]"})})},getButtonData:function(C){var D;a.each(k,function(P,U){if(U.sel===C)D=U});return D}}}();v.setAll();c.ready(function(){var k=curConfig.initTool,u=a("#tools_left, #svg_editor .tools_flyout"),C=u.find("#tool_"+k);k=u.find("#"+
k);(C.length?C:k.length?k:a("#tool_select")).click().mouseup();curConfig.wireframe&&a("#tool_wireframe").click();curConfig.showlayers&&toggleSidePanel();a("#rulers").toggle(!!curConfig.showRulers)});a("#canvas_height").dragInput({min:10,max:null,step:10,callback:A,cursor:false});a("#canvas_width").dragInput({min:10,max:null,step:10,callback:A,cursor:false});a("#rect_width").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_height").dragInput({min:0,max:null,step:1,
callback:changeAttribute,cursor:false});a("#ellipse_cx").dragInput({min:0,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_cy").dragInput({min:0,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_rx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_ry").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_height").dragInput({min:0,max:null,step:1,callback:changeAttribute,cursor:false});a("#selected_x").dragInput({min:null,
max:null,step:1,callback:changeAttribute,cursor:false});a("#selected_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_node_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_node_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_width").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_x1").dragInput({min:null,max:null,step:1,callback:changeAttribute,
cursor:false});a("#line_x2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y1").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_x").dragInput({min:null,max:null,
step:1,callback:changeAttribute,cursor:false});a("#rect_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#text_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#text_x").dragInput({min:null,
max:null,step:1,callback:changeAttribute,cursor:false});a("#image_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_rx").dragInput({min:0,max:100,step:1,callback:function(k){g.setRectRadius(k.value)},cursor:true});a("#stroke_width").dragInput({min:0,max:99,step:1,callback:function(k){var u=k.value;if(u==0&&W&&["line","polyline"].indexOf(W.nodeName)>=0)u=k.value=1;g.setStrokeWidth(u)},cursor:true,smallStep:0.1,start:1.5});a("#angle").dragInput({min:-180,max:180,
step:1,callback:function(k){g.setRotationAngle(k.value);rotateCursor(k.value);a("#tool_reorient").toggleClass("disabled",k.value==0)},cursor:false});a("#font_size").dragInput({min:1,max:250,step:1,callback:function(k){g.setFontSize(k.value)},cursor:true,stepfunc:function(k,u){var C=k.value-0,E=C+u,P=E>=C;if(u===0)return C;return C>=24?P?Math.round(C*1.1):Math.round(C/1.1):C<=1?P?C*2:C/2:E}});a("#group_opacity").dragInput({min:0,max:100,step:5,callback:function(k,u){if(u==null)u=k.value;a("#group_opacity").val(u);
if(!k||!k.handle)a("#opac_slider").slider("option","value",u);g.setOpacity(u/100)},cursor:true,start:100});a("#blur").dragInput({min:0,max:10,step:0.1,callback:function(k){val=k.value;a("#blur").val(val);window.event.type=="mouseup"?g.setBlur(val,true):g.setBlurNoUndo(val)},cursor:true,start:0});a("#zoom").val(g.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(k){switch(k){case "delete":ta();break;case "cut":mb();break;case "copy":jb();break;case "paste":g.pasteElements();
step:1,callback:function(k){g.setRotationAngle(k.value);rotateCursor(k.value);a("#tool_reorient").toggleClass("disabled",k.value==0)},cursor:false});a("#font_size").dragInput({min:1,max:250,step:1,callback:function(k){g.setFontSize(k.value)},cursor:true,stepfunc:function(k,u){var C=k.value-0,D=C+u,P=D>=C;if(u===0)return C;return C>=24?P?Math.round(C*1.1):Math.round(C/1.1):C<=1?P?C*2:C/2:D}});a("#group_opacity").dragInput({min:0,max:100,step:5,callback:function(k,u){if(u==null)u=k.value;a("#group_opacity").val(u);
if(!k||!k.handle)a("#opac_slider").slider("option","value",u);g.setOpacity(u/100)},cursor:true,start:100});a("#blur").dragInput({min:0,max:10,step:0.1,callback:function(k){val=k.value;a("#blur").val(val);window.event.type=="mouseup"?g.setBlur(val,true):g.setBlurNoUndo(val)},cursor:true,start:0});a("#zoom").val(g.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(k){switch(k){case "delete":ua();break;case "cut":mb();break;case "copy":jb();break;case "paste":g.pasteElements();
break;case "paste_in_place":g.pasteElements("in_place");break;case "group":g.groupSelectedElements();break;case "ungroup":g.ungroupSelectedElement();break;case "move_front":ob();break;case "move_up":wb("Up");break;case "move_down":wb("Down");break;case "move_back":eb();break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(k)&&svgedit.contextmenu.getCustomHandler(k).call()}});a(".contextMenu li").mousedown(function(k){k.preventDefault()});a("#cmenu_canvas li").disableContextMenu();
Y.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=function(){if(T.getUndoStackSize()===0)c.show_save_warning=false;if(!curConfig.no_save_warning&&c.show_save_warning)return uiStrings.notification.unsavedChanges};c.openPrep=function(k){a("#main_menu").hide();T.getUndoStackSize()===0?k(true):a.confirm(uiStrings.notification.QwantToOpen,k)};if(window.FileReader){q=a('<input type="file">').change(function(){var k=this;c.openPrep(function(u){if(u){g.clear();if(k.files.length==1){u=new FileReader;
u.onloadend=function(C){p(C.target.result);F()};u.readAsText(k.files[0])}}})});a("#tool_open").show().prepend(q);q=a('<input type="file">').change(function(){a("#main_menu").hide();if(this.files.length==1){var k=new FileReader;k.onloadend=function(u){g.importSvgString(u.target.result,true);F()};k.readAsText(this.files[0])}});a("#tool_import").show().prepend(q)}for(var F=c.updateCanvas=function(k,u){var C=Q.width(),E=Q.height(),P=C,U=E,S=g.getZoom(),X=a("#svgcanvas"),aa={x:Q[0].scrollLeft+P/2,y:Q[0].scrollTop+
U/2},ga=curConfig.canvas_expansion;C=Math.max(P,g.contentW*S*ga);E=Math.max(U,g.contentH*S*ga);C==P&&E==U?Q.css("overflow","hidden"):Q.css("overflow","scroll");ga=X.height()/2;var ra=X.width()/2;X.width(C).height(E);var Ta=E/2,Ba=C/2,ha=g.updateCanvas(C,E),Sa=Ba/ra;C=C/2-P/2;E=E/2-U/2;if(u){u.x+=ha.x;u.y+=ha.y}else u={x:Ba+(aa.x-ra)*Sa,y:Ta+(aa.y-ga)*Sa};if(k)if(g.contentW>Q.width()){Q[0].scrollLeft=ha.x-10;Q[0].scrollTop=ha.y-10}else{Q[0].scrollLeft=C;Q[0].scrollTop=E}else{Q[0].scrollLeft=u.x-P/
2;Q[0].scrollTop=u.y-U/2}if(curConfig.showRulers){l(X,S);Q.scroll()}},I=[],D=0.1;D<1E5;D*=10){I.push(1*D);I.push(2*D);I.push(5*D)}F(true);try{var G=function(k){if(window.JSON&&JSON.stringify)return JSON.stringify(k);var u=arguments.callee;if(typeof k=="boolean"||typeof k=="number")return k+"";else if(typeof k=="string")return'"'+k.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,function(P){return"\\u"+("0000"+P.charCodeAt(0).toString(16)).slice(-4)})+
'"';else if(k.length){for(var C=0;C<k.length;C++)k[C]=u(k[C]);return"["+k.join(",")+"]"}else{C=[];for(var E in k)C.push(u(E)+":"+u(k[E]));return"{"+C.join(",")+"}"}};window.addEventListener("message",function(k){var u=parseInt(k.data.substr(0,k.data.indexOf(";")));try{k.source.postMessage("SVGe"+u+";"+G(eval(k.data)),"*")}catch(C){k.source.postMessage("SVGe"+u+";error:"+C.message,"*")}},false)}catch(L){window.embed_error=L}a(function(){window.svgCanvas=g;g.ready=svgEditor.ready});c.setLang=function(k,
u){a.pref("lang",k);a("#lang_select").val(k);if(u){g.runExtensions("langChanged",k);Aa();a.each({"#stroke_color":"#tool_stroke .icon_label, #tool_stroke .color_block","#fill_color":"#tool_fill label, #tool_fill .color_block","#linejoin_miter":"#cur_linejoin","#linecap_butt":"#cur_linecap"},function(C,E){a(E).attr("title",a(C)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var f=[];c.ready=function(d){n?d():f.push(d)};
X.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=function(){if(T.getUndoStackSize()===0)c.show_save_warning=false;if(!curConfig.no_save_warning&&c.show_save_warning)return uiStrings.notification.unsavedChanges};c.openPrep=function(k){a("#main_menu").hide();T.getUndoStackSize()===0?k(true):a.confirm(uiStrings.notification.QwantToOpen,k)};if(window.FileReader){q=a('<input type="file">').change(function(){var k=this;c.openPrep(function(u){if(u){g.clear();if(k.files.length==1){u=new FileReader;
u.onloadend=function(C){p(C.target.result);F()};u.readAsText(k.files[0])}}})});a("#tool_open").show().prepend(q);q=a('<input type="file">').change(function(){a("#main_menu").hide();if(this.files.length==1){var k=new FileReader;k.onloadend=function(u){g.importSvgString(u.target.result,true);F()};k.readAsText(this.files[0])}});a("#tool_import").show().prepend(q)}for(var F=c.updateCanvas=function(k,u){var C=Q.width(),D=Q.height(),P=C,U=D,S=g.getZoom(),Y=a("#svgcanvas"),aa={x:Q[0].scrollLeft+P/2,y:Q[0].scrollTop+
U/2},ga=curConfig.canvas_expansion;C=Math.max(P,g.contentW*S*ga);D=Math.max(U,g.contentH*S*ga);C==P&&D==U?Q.css("overflow","hidden"):Q.css("overflow","scroll");ga=Y.height()/2;var ra=Y.width()/2;Y.width(C).height(D);var Oa=D/2,Ba=C/2,ha=g.updateCanvas(C,D),Ta=Ba/ra;C=C/2-P/2;D=D/2-U/2;if(u){u.x+=ha.x;u.y+=ha.y}else u={x:Ba+(aa.x-ra)*Ta,y:Oa+(aa.y-ga)*Ta};if(k)if(g.contentW>Q.width()){Q[0].scrollLeft=ha.x-10;Q[0].scrollTop=ha.y-10}else{Q[0].scrollLeft=C;Q[0].scrollTop=D}else{Q[0].scrollLeft=u.x-P/
2;Q[0].scrollTop=u.y-U/2}if(curConfig.showRulers){l(Y,S);Q.scroll()}},I=[],E=0.1;E<1E5;E*=10){I.push(1*E);I.push(2*E);I.push(5*E)}F(true);try{var G=function(k){if(window.JSON&&JSON.stringify)return JSON.stringify(k);var u=arguments.callee;if(typeof k=="boolean"||typeof k=="number")return k+"";else if(typeof k=="string")return'"'+k.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,function(P){return"\\u"+("0000"+P.charCodeAt(0).toString(16)).slice(-4)})+
'"';else if(k.length){for(var C=0;C<k.length;C++)k[C]=u(k[C]);return"["+k.join(",")+"]"}else{C=[];for(var D in k)C.push(u(D)+":"+u(k[D]));return"{"+C.join(",")+"}"}};window.addEventListener("message",function(k){var u=parseInt(k.data.substr(0,k.data.indexOf(";")));try{k.source.postMessage("SVGe"+u+";"+G(eval(k.data)),"*")}catch(C){k.source.postMessage("SVGe"+u+";error:"+C.message,"*")}},false)}catch(L){window.embed_error=L}a(function(){window.svgCanvas=g;g.ready=svgEditor.ready});c.setLang=function(k,
u){a.pref("lang",k);a("#lang_select").val(k);if(u){g.runExtensions("langChanged",k);Aa();a.each({"#stroke_color":"#tool_stroke .icon_label, #tool_stroke .color_block","#fill_color":"#tool_fill label, #tool_fill .color_block","#linejoin_miter":"#cur_linejoin","#linecap_butt":"#cur_linecap"},function(C,D){a(D).attr("title",a(C)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var f=[];c.ready=function(d){n?d():f.push(d)};
c.runCallbacks=function(){a.each(f,function(){this()});n=true};c.loadFromString=function(d){c.ready(function(){p(d)})};c.loadFromURL=function(d,l){l||(l={});var q=l.cache,B=l.callback;c.ready(function(){a.ajax({url:d,dataType:"text",cache:!!q,success:function(o){p(o,B)},error:function(o,K,T){o.status!=404&&o.responseText?p(o.responseText,B):a.alert(uiStrings.notification.URLloadFail+": \n"+T+"",B)}})})};c.loadFromDataURI=function(d){c.ready(function(){var l=d.substring(26);p(svgedit.utilities.decode64(l))})};
c.addExtension=function(){var d=arguments;a(function(){g&&g.addExtension.apply(this,d)})};return c}(jQuery);$(svgEditor.init)})();$.fn.dragInput=function(a){return this.each(function(){this.repeating=false;this.dragCfg={min:a&&!isNaN(parseFloat(a.min))?Number(a.min):null,max:a&&!isNaN(parseFloat(a.max))?Number(a.max):null,step:a&&Number(a.step)?a.step:1,stepfunc:a&&a.stepfunc?a.stepfunc:false,page:a&&a.page?Number(a.page):10,reset:a&&a.reset?a.reset:this.value,delay:a&&a.delay?Number(a.delay):500,interval:a&&a.interval?Number(a.interval):100,height:70,cursor:a&&a.cursor?Boolean(a.cursor):false,start:a&&a.start?Number(a.start):
0,_btn_width:20,_direction:null,_delay:null,_repeat:null,callback:a&&a.callback?a.callback:null};this.dragCfg.smallStep=a&&a.smallStep?a.smallStep:this.dragCfg.step/2;var p=$(this).parent(),g=$(this),c=this.dragCfg.height,n=this.dragCfg.min,s=this.dragCfg.max,b=this.dragCfg.step,f=s-n>0?(s-n)/b:200,d=f/c*b,l=0,q=this.getAttribute("data-attr"),B=svgEditor.canvas,o=B.getSelectedElems(),K=svgedit.browser.isTouch(),T=f&&this.dragCfg.cursor?$("<div class='draginput_cursor' />").appendTo(p):false;g.attr("readonly",
"readonly");T&&!isNaN(this.dragCfg.start)&&T.css("top",this.dragCfg.start*-1/d+c);this.adjustValue=function(M,J){var Q;Q=isNaN(this.value)?this.dragCfg.reset:$.isFunction(this.dragCfg.stepfunc)?this.dragCfg.stepfunc(this,M):Number((Number(this.value)+Number(M)).toFixed(5));if(s!==null)Q=Math.min(Q,s);if(n!==null)Q=Math.max(Q,n);T&&this.updateCursor(Q);this.value=Q;p.attr("data-value",Q);$.isFunction(this.dragCfg.callback)&&this.dragCfg.callback(this,J)};p.toggleClass("draginput",p.is("label"));this.move=
function(M,J,Q){if(K)M=M.originalEvent.touches[0];if(l===0)l=J;J=(M.pageY-l)*-1;l=M.pageY;Q=J*d;this.adjustValue(Q.toFixed(b<1?1:0))};this.stop=function(){$("body").removeClass("dragging");p.removeClass("active");$(window).unbind("mousemove.draginput touchmove.draginput mouseup.draginput touchend.draginput");l=0;if(o[0]){var M=B.undoMgr.finishUndoableChange();M.isEmpty()||B.undoMgr.addCommandToHistory(M)}this.adjustValue(0)};this.updateCursor=function(){var M=parseFloat(this.value)*-1/d+c;T.css("top",
M)};this.start=function(M){if(K)M=M.originalEvent.touches[0];var J=M.pageY,Q=this.value,Y=this;B.undoMgr.beginUndoableChange(q,o);$("body").addClass("dragging");p.addClass("active");$(window).bind("mousemove.draginput touchmove.draginput",function(O){Y.move(O,J,parseFloat(Q))});$(window).bind("mouseup.draginput touchend.draginput",function(){Y.stop()})};$(this).attr("readonly","readonly").attr("data-scale",d).attr("data-domain",c).attr("data-cursor",T!=false).bind("mousedown touchstart",function(M){this.blur();
this.start(M)}).bind("dblclick taphold",function(){this.removeAttribute("readonly","readonly");this.focus();this.select()}).keydown(function(M){switch(M.keyCode){case 13:this.adjustValue(0);this.blur()}}).focus(function(){this.getAttribute("readonly")==="readonly"&&this.blur()}).blur(function(){this.setAttribute("readonly","readonly")}).bind("mousewheel",function(M,J,Q,Y){if(Y>0)this.adjustValue(this.dragCfg.step);else Y<0&&this.adjustValue(-this.dragCfg.step);M.preventDefault()})})};
M)};this.start=function(M){if(K)M=M.originalEvent.touches[0];var J=M.pageY,Q=this.value,X=this;B.undoMgr.beginUndoableChange(q,o);$("body").addClass("dragging");p.addClass("active");$(window).bind("mousemove.draginput touchmove.draginput",function(O){X.move(O,J,parseFloat(Q))});$(window).bind("mouseup.draginput touchend.draginput",function(){X.stop()})};$(this).attr("readonly","readonly").attr("data-scale",d).attr("data-domain",c).attr("data-cursor",T!=false).bind("mousedown touchstart",function(M){this.blur();
this.start(M)}).bind("dblclick taphold",function(){this.removeAttribute("readonly","readonly");this.focus();this.select()}).keydown(function(M){switch(M.keyCode){case 13:this.adjustValue(0);this.blur()}}).focus(function(){this.getAttribute("readonly")==="readonly"&&this.blur()}).blur(function(){this.setAttribute("readonly","readonly")}).bind("mousewheel",function(M,J,Q,X){if(X>0)this.adjustValue(this.dragCfg.step);else X<0&&this.adjustValue(-this.dragCfg.step);M.preventDefault()})})};
$.fn.dragInput.updateCursor=function(a){var p=parseFloat(a.value),g=parseFloat(a.getAttribute("data-scale")),c=parseFloat(a.getAttribute("data-domain"));p=p*-1/g+c+"px";a=a.parentNode.lastChild;if(a.className=="draginput_cursor")a.style.top=p};svgedit=svgedit||{};
(function(){var a=this;if(!svgedit.contextmenu)svgedit.contextmenu={};a.contextMenuExtensions={};svgEditor.ready(function(){for(menuItem in contextMenuExtensions){var p=contextMenuExtensions[menuItem];Object.keys(a.contextMenuExtensions).length==0&&$("#cmenu_canvas").append("<li class='separator'>");var g=p.shortcut||"";$("#cmenu_canvas").append("<li class='disabled'><a href='#"+p.id+"'>"+p.label+"<span class='shortcut'>"+g+"</span></a></li>")}});svgedit.contextmenu.resetCustomMenus=function(){a.contextMenuExtensions=
{}};svgedit.contextmenu.add=function(p){if(p&&p.id&&p.label&&p.action&&typeof p.action=="function")if(p.id in a.contextMenuExtensions)console.error('Cannot add extension "'+p.id+'", an extension by that name already exists"');else{console.log("Registed contextmenu item: {id:"+p.id+", label:"+p.label+"}");a.contextMenuExtensions[p.id]=p}else console.error("Menu items must be defined and have at least properties: id, label, action, where action must be a function")};svgedit.contextmenu.hasCustomHandler=
@ -557,9 +557,9 @@ c.axis!="x")g.overflowOffset.top+g.scrollParent[0].offsetHeight-p.pageY<c.scroll
(g.scrollParent[0].scrollLeft=n=g.scrollParent[0].scrollLeft-c.scrollSpeed)}else{if(!c.axis||c.axis!="x")p.pageY-a(document).scrollTop()<c.scrollSensitivity?n=a(document).scrollTop(a(document).scrollTop()-c.scrollSpeed):a(window).height()-(p.pageY-a(document).scrollTop())<c.scrollSensitivity&&(n=a(document).scrollTop(a(document).scrollTop()+c.scrollSpeed));if(!c.axis||c.axis!="y")p.pageX-a(document).scrollLeft()<c.scrollSensitivity?n=a(document).scrollLeft(a(document).scrollLeft()-c.scrollSpeed):
a(window).width()-(p.pageX-a(document).scrollLeft())<c.scrollSensitivity&&(n=a(document).scrollLeft(a(document).scrollLeft()+c.scrollSpeed))}n!==false&&a.ui.ddmanager&&!c.dropBehaviour&&a.ui.ddmanager.prepareOffsets(g,p)}});a.ui.plugin.add("draggable","snap",{start:function(){var p=a(this).data("draggable"),g=p.options;p.snapElements=[];a(g.snap.constructor!=String?g.snap.items||":data(draggable)":g.snap).each(function(){var c=a(this),n=c.offset();this!=p.element[0]&&p.snapElements.push({item:this,
width:c.outerWidth(),height:c.outerHeight(),top:n.top,left:n.left})})},drag:function(p,g){for(var c=a(this).data("draggable"),n=c.options,s=n.snapTolerance,b=g.offset.left,f=b+c.helperProportions.width,d=g.offset.top,l=d+c.helperProportions.height,q=c.snapElements.length-1;q>=0;q--){var B=c.snapElements[q].left,o=B+c.snapElements[q].width,K=c.snapElements[q].top,T=K+c.snapElements[q].height;if(B-s<b&&b<o+s&&K-s<d&&d<T+s||B-s<b&&b<o+s&&K-s<l&&l<T+s||B-s<f&&f<o+s&&K-s<d&&d<T+s||B-s<f&&f<o+s&&K-s<l&&
l<T+s){if(n.snapMode!="inner"){var M=Math.abs(K-l)<=s,J=Math.abs(T-d)<=s,Q=Math.abs(B-f)<=s,Y=Math.abs(o-b)<=s;M&&(g.position.top=c._convertPositionTo("relative",{top:K-c.helperProportions.height,left:0}).top-c.margins.top);J&&(g.position.top=c._convertPositionTo("relative",{top:T,left:0}).top-c.margins.top);Q&&(g.position.left=c._convertPositionTo("relative",{top:0,left:B-c.helperProportions.width}).left-c.margins.left);Y&&(g.position.left=c._convertPositionTo("relative",{top:0,left:o}).left-c.margins.left)}var O=
M||J||Q||Y;if(n.snapMode!="outer"){M=Math.abs(K-d)<=s;J=Math.abs(T-l)<=s;Q=Math.abs(B-b)<=s;Y=Math.abs(o-f)<=s;M&&(g.position.top=c._convertPositionTo("relative",{top:K,left:0}).top-c.margins.top);J&&(g.position.top=c._convertPositionTo("relative",{top:T-c.helperProportions.height,left:0}).top-c.margins.top);Q&&(g.position.left=c._convertPositionTo("relative",{top:0,left:B}).left-c.margins.left);Y&&(g.position.left=c._convertPositionTo("relative",{top:0,left:o-c.helperProportions.width}).left-c.margins.left)}!c.snapElements[q].snapping&&
(M||J||Q||Y||O)&&c.options.snap.snap&&c.options.snap.snap.call(c.element,p,a.extend(c._uiHash(),{snapItem:c.snapElements[q].item}));c.snapElements[q].snapping=M||J||Q||Y||O}else{c.snapElements[q].snapping&&c.options.snap.release&&c.options.snap.release.call(c.element,p,a.extend(c._uiHash(),{snapItem:c.snapElements[q].item}));c.snapElements[q].snapping=false}}}});a.ui.plugin.add("draggable","stack",{start:function(){var p=a(this).data("draggable").options;p=a.makeArray(a(p.stack)).sort(function(c,
l<T+s){if(n.snapMode!="inner"){var M=Math.abs(K-l)<=s,J=Math.abs(T-d)<=s,Q=Math.abs(B-f)<=s,X=Math.abs(o-b)<=s;M&&(g.position.top=c._convertPositionTo("relative",{top:K-c.helperProportions.height,left:0}).top-c.margins.top);J&&(g.position.top=c._convertPositionTo("relative",{top:T,left:0}).top-c.margins.top);Q&&(g.position.left=c._convertPositionTo("relative",{top:0,left:B-c.helperProportions.width}).left-c.margins.left);X&&(g.position.left=c._convertPositionTo("relative",{top:0,left:o}).left-c.margins.left)}var O=
M||J||Q||X;if(n.snapMode!="outer"){M=Math.abs(K-d)<=s;J=Math.abs(T-l)<=s;Q=Math.abs(B-b)<=s;X=Math.abs(o-f)<=s;M&&(g.position.top=c._convertPositionTo("relative",{top:K,left:0}).top-c.margins.top);J&&(g.position.top=c._convertPositionTo("relative",{top:T-c.helperProportions.height,left:0}).top-c.margins.top);Q&&(g.position.left=c._convertPositionTo("relative",{top:0,left:B}).left-c.margins.left);X&&(g.position.left=c._convertPositionTo("relative",{top:0,left:o-c.helperProportions.width}).left-c.margins.left)}!c.snapElements[q].snapping&&
(M||J||Q||X||O)&&c.options.snap.snap&&c.options.snap.snap.call(c.element,p,a.extend(c._uiHash(),{snapItem:c.snapElements[q].item}));c.snapElements[q].snapping=M||J||Q||X||O}else{c.snapElements[q].snapping&&c.options.snap.release&&c.options.snap.release.call(c.element,p,a.extend(c._uiHash(),{snapItem:c.snapElements[q].item}));c.snapElements[q].snapping=false}}}});a.ui.plugin.add("draggable","stack",{start:function(){var p=a(this).data("draggable").options;p=a.makeArray(a(p.stack)).sort(function(c,
n){return(parseInt(a(c).css("zIndex"),10)||0)-(parseInt(a(n).css("zIndex"),10)||0)});if(p.length){var g=parseInt(p[0].style.zIndex)||0;a(p).each(function(c){this.style.zIndex=g+c});this[0].style.zIndex=g+p.length}}});a.ui.plugin.add("draggable","zIndex",{start:function(p,g){var c=a(g.helper),n=a(this).data("draggable").options;c.css("zIndex")&&(n._zIndex=c.css("zIndex"));c.css("zIndex",n.zIndex)},stop:function(p,g){var c=a(this).data("draggable").options;c._zIndex&&a(g.helper).css("zIndex",c._zIndex)}})})(jQuery);
(function(a){a.widget("ui.slider",a.ui.mouse,{widgetEventPrefix:"slide",options:{animate:false,distance:0,max:100,min:0,orientation:"horizontal",range:false,step:1,value:0,values:null},_create:function(){var p=this,g=this.options,c=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),n=g.values&&g.values.length||1,s=[];this._mouseSliding=this._keySliding=false;this._animateOff=true;this._handleIndex=null;this._detectOrientation();this._mouseInit();this.element.addClass("ui-slider ui-slider-"+
this.orientation+" ui-widget ui-widget-content ui-corner-all"+(g.disabled?" ui-slider-disabled ui-disabled":""));this.range=a([]);g.range&&(g.range===true&&(g.values||(g.values=[this._valueMin(),this._valueMin()]),g.values.length&&g.values.length!==2&&(g.values=[g.values[0],g.values[0]])),this.range=a("<div></div>").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(g.range==="min"||g.range==="max"?" ui-slider-range-"+g.range:"")));for(var b=c.length;b<n;b+=1)s.push("<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>");
@ -579,55 +579,55 @@ this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui
return g=this._trimAlignValue(g)}g=this.options.values.slice();for(c=0;c<g.length;c+=1)g[c]=this._trimAlignValue(g[c]);return g},_trimAlignValue:function(p){if(p<=this._valueMin())return this._valueMin();if(p>=this._valueMax())return this._valueMax();var g=this.options.step>0?this.options.step:1,c=(p-this._valueMin())%g;p=p-c;Math.abs(c)*2>=g&&(p+=c>0?g:-g);return parseFloat(p.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var p=
this.options.range,g=this.options,c=this,n=this._animateOff?false:g.animate,s,b={},f,d,l,q;this.options.values&&this.options.values.length?this.handles.each(function(B){s=(c.values(B)-c._valueMin())/(c._valueMax()-c._valueMin())*100;b[c.orientation==="horizontal"?"left":"bottom"]=s+"%";a(this).stop(1,1)[n?"animate":"css"](b,g.animate);c.options.range===true&&(c.orientation==="horizontal"?(B===0&&c.range.stop(1,1)[n?"animate":"css"]({left:s+"%"},g.animate),B===1&&c.range[n?"animate":"css"]({width:s-
f+"%"},{queue:false,duration:g.animate})):(B===0&&c.range.stop(1,1)[n?"animate":"css"]({bottom:s+"%"},g.animate),B===1&&c.range[n?"animate":"css"]({height:s-f+"%"},{queue:false,duration:g.animate})));f=s}):(d=this.value(),l=this._valueMin(),q=this._valueMax(),s=q!==l?(d-l)/(q-l)*100:0,b[c.orientation==="horizontal"?"left":"bottom"]=s+"%",this.handle.stop(1,1)[n?"animate":"css"](b,g.animate),p==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[n?"animate":"css"]({width:s+"%"},g.animate),
p==="max"&&this.orientation==="horizontal"&&this.range[n?"animate":"css"]({width:100-s+"%"},{queue:false,duration:g.animate}),p==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[n?"animate":"css"]({height:s+"%"},g.animate),p==="max"&&this.orientation==="vertical"&&this.range[n?"animate":"css"]({height:100-s+"%"},{queue:false,duration:g.animate}))}});a.extend(a.ui.slider,{version:"1.8.17"})})(jQuery);(function(a){Math.precision=function(b,f){if(f===undefined)f=0;return Math.round(b*Math.pow(10,f))/Math.pow(10,f)};var p=function(b,f){var d=this,l=b.find("img:first"),q=0,B=100,o=100,K=0,T=100,M=100,J=0,Q=0,Y,O,ia=[],pa=function(V){for(var Z=0;Z<ia.length;Z++)ia[Z].call(d,d,V)},fa=function(V){var Z=b.offset();Y={l:Z.left|0,t:Z.top|0};clearTimeout(O);O=setTimeout(function(){sa.call(d,V)},0);a(document).bind("mousemove",ba).bind("mouseup",W);V.preventDefault()},ba=function(V){clearTimeout(O);O=setTimeout(function(){sa.call(d,
V)},0);V.stopPropagation();V.preventDefault();return false},W=function(V){a(document).unbind("mouseup",W).unbind("mousemove",ba);V.stopPropagation();V.preventDefault();return false},sa=function(V){var Z=V.pageX-Y.l;V=V.pageY-Y.t;var oa=b.w,qa=b.h;if(Z<0)Z=0;else if(Z>oa)Z=oa;if(V<0)V=0;else if(V>qa)V=qa;ka.call(d,"xy",{x:Z/oa*o+q,y:V/qa*M+K})},ka=function(V,Z,oa){if(Z===undefined){if(V===undefined||V==null)V="xy";switch(V.toLowerCase()){case "x":return J;case "y":return Q;default:return{x:J,y:Q}}}if(!(oa!=
p==="max"&&this.orientation==="horizontal"&&this.range[n?"animate":"css"]({width:100-s+"%"},{queue:false,duration:g.animate}),p==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[n?"animate":"css"]({height:s+"%"},g.animate),p==="max"&&this.orientation==="vertical"&&this.range[n?"animate":"css"]({height:100-s+"%"},{queue:false,duration:g.animate}))}});a.extend(a.ui.slider,{version:"1.8.17"})})(jQuery);(function(a){Math.precision=function(b,f){if(f===undefined)f=0;return Math.round(b*Math.pow(10,f))/Math.pow(10,f)};var p=function(b,f){var d=this,l=b.find("img:first"),q=0,B=100,o=100,K=0,T=100,M=100,J=0,Q=0,X,O,ia=[],pa=function(V){for(var Z=0;Z<ia.length;Z++)ia[Z].call(d,d,V)},fa=function(V){var Z=b.offset();X={l:Z.left|0,t:Z.top|0};clearTimeout(O);O=setTimeout(function(){sa.call(d,V)},0);a(document).bind("mousemove",ba).bind("mouseup",W);V.preventDefault()},ba=function(V){clearTimeout(O);O=setTimeout(function(){sa.call(d,
V)},0);V.stopPropagation();V.preventDefault();return false},W=function(V){a(document).unbind("mouseup",W).unbind("mousemove",ba);V.stopPropagation();V.preventDefault();return false},sa=function(V){var Z=V.pageX-X.l;V=V.pageY-X.t;var oa=b.w,qa=b.h;if(Z<0)Z=0;else if(Z>oa)Z=oa;if(V<0)V=0;else if(V>qa)V=qa;ka.call(d,"xy",{x:Z/oa*o+q,y:V/qa*M+K})},ka=function(V,Z,oa){if(Z===undefined){if(V===undefined||V==null)V="xy";switch(V.toLowerCase()){case "x":return J;case "y":return Q;default:return{x:J,y:Q}}}if(!(oa!=
null&&oa==d)){var qa=false,ma,na;if(V==null)V="xy";switch(V.toLowerCase()){case "x":ma=Z&&(Z.x&&Z.x|0||Z|0)||0;break;case "y":na=Z&&(Z.y&&Z.y|0||Z|0)||0;break;default:ma=Z&&Z.x&&Z.x|0||0;na=Z&&Z.y&&Z.y|0||0}if(ma!=null){if(ma<q)ma=q;else if(ma>B)ma=B;if(J!=ma){J=ma;qa=true}}if(na!=null){if(na<K)na=K;else if(na>T)na=T;if(Q!=na){Q=na;qa=true}}qa&&pa.call(d,oa||d)}},da=function(V){a.isFunction(V)&&ia.push(V)};a.extend(true,d,{val:ka,range:function(V,Z){if(Z===undefined){if(V===undefined||V==null)V="all";
switch(V.toLowerCase()){case "minx":return q;case "maxx":return B;case "rangex":return{minX:q,maxX:B,rangeX:o};case "miny":return K;case "maxy":return T;case "rangey":return{minY:K,maxY:T,rangeY:M};default:return{minX:q,maxX:B,rangeX:o,minY:K,maxY:T,rangeY:M}}}var oa,qa,ma,na;if(V==null)V="all";switch(V.toLowerCase()){case "minx":oa=Z&&(Z.minX&&Z.minX|0||Z|0)||0;break;case "maxx":qa=Z&&(Z.maxX&&Z.maxX|0||Z|0)||0;break;case "rangex":oa=Z&&Z.minX&&Z.minX|0||0;qa=Z&&Z.maxX&&Z.maxX|0||0;break;case "miny":ma=
Z&&(Z.minY&&Z.minY|0||Z|0)||0;break;case "maxy":na=Z&&(Z.maxY&&Z.maxY|0||Z|0)||0;break;case "rangey":ma=Z&&Z.minY&&Z.minY|0||0;na=Z&&Z.maxY&&Z.maxY|0||0;break;default:oa=Z&&Z.minX&&Z.minX|0||0;qa=Z&&Z.maxX&&Z.maxX|0||0;ma=Z&&Z.minY&&Z.minY|0||0;na=Z&&Z.maxY&&Z.maxY|0||0}if(oa!=null&&q!=oa){q=oa;o=B-q}if(qa!=null&&B!=qa){B=qa;o=B-q}if(ma!=null&&K!=ma){K=ma;M=T-K}if(na!=null&&T!=na){T=na;M=T-K}},bind:da,unbind:function(V){if(a.isFunction(V))for(var Z;(Z=a.inArray(V,ia))!=-1;)ia.splice(Z,1)},destroy:function(){a(document).unbind("mouseup",
W).unbind("mousemove",ba);b.unbind("mousedown",fa);ia=l=b=null}});l.src=f.arrow&&f.arrow.image;l.w=f.arrow&&f.arrow.width||l.width();l.h=f.arrow&&f.arrow.height||l.height();b.w=f.map&&f.map.width||b.width();b.h=f.map&&f.map.height||b.height();b.bind("mousedown",fa);da.call(d,function(){var V=0,Z=0,oa=b.w,qa=b.h,ma=l.w,na=l.h;setTimeout(function(){if(o>0)V=J==B?oa:J/o*oa|0;if(M>0)Z=Q==T?qa:Q/M*qa|0;if(ma>=oa)V=(oa>>1)-(ma>>1);else V-=ma>>1;if(na>=qa)Z=(qa>>1)-(na>>1);else Z-=na>>1;l.css({left:V+"px",
top:Z+"px"})},0)})},g=function(b,f,d,l){var q=this;b=b.find("td.Text input");var B=b.eq(3),o=b.eq(4),K=b.eq(5),T=b.length>7?b.eq(6):null,M=b.eq(0),J=b.eq(1),Q=b.eq(2),Y=b.eq(b.length>7?7:6),O=b.length>7?b.eq(8):null,ia=function(ka){if(!(ka.target.value==""&&ka.target!=Y.get(0)&&(d!=null&&ka.target!=d.get(0)||d==null))){if(!ba(ka))return ka;switch(ka.target){case B.get(0):switch(ka.keyCode){case 38:B.val(W.call(q,(B.val()<<0)+1,0,255));f.val("r",B.val(),ka.target);return false;case 40:B.val(W.call(q,
top:Z+"px"})},0)})},g=function(b,f,d,l){var q=this;b=b.find("td.Text input");var B=b.eq(3),o=b.eq(4),K=b.eq(5),T=b.length>7?b.eq(6):null,M=b.eq(0),J=b.eq(1),Q=b.eq(2),X=b.eq(b.length>7?7:6),O=b.length>7?b.eq(8):null,ia=function(ka){if(!(ka.target.value==""&&ka.target!=X.get(0)&&(d!=null&&ka.target!=d.get(0)||d==null))){if(!ba(ka))return ka;switch(ka.target){case B.get(0):switch(ka.keyCode){case 38:B.val(W.call(q,(B.val()<<0)+1,0,255));f.val("r",B.val(),ka.target);return false;case 40:B.val(W.call(q,
(B.val()<<0)-1,0,255));f.val("r",B.val(),ka.target);return false}break;case o.get(0):switch(ka.keyCode){case 38:o.val(W.call(q,(o.val()<<0)+1,0,255));f.val("g",o.val(),ka.target);return false;case 40:o.val(W.call(q,(o.val()<<0)-1,0,255));f.val("g",o.val(),ka.target);return false}break;case K.get(0):switch(ka.keyCode){case 38:K.val(W.call(q,(K.val()<<0)+1,0,255));f.val("b",K.val(),ka.target);return false;case 40:K.val(W.call(q,(K.val()<<0)-1,0,255));f.val("b",K.val(),ka.target);return false}break;
case T&&T.get(0):switch(ka.keyCode){case 38:T.val(W.call(q,parseFloat(T.val())+1,0,100));f.val("a",Math.precision(T.val()*255/100,l),ka.target);return false;case 40:T.val(W.call(q,parseFloat(T.val())-1,0,100));f.val("a",Math.precision(T.val()*255/100,l),ka.target);return false}break;case M.get(0):switch(ka.keyCode){case 38:M.val(W.call(q,(M.val()<<0)+1,0,360));f.val("h",M.val(),ka.target);return false;case 40:M.val(W.call(q,(M.val()<<0)-1,0,360));f.val("h",M.val(),ka.target);return false}break;case J.get(0):switch(ka.keyCode){case 38:J.val(W.call(q,
(J.val()<<0)+1,0,100));f.val("s",J.val(),ka.target);return false;case 40:J.val(W.call(q,(J.val()<<0)-1,0,100));f.val("s",J.val(),ka.target);return false}break;case Q.get(0):switch(ka.keyCode){case 38:Q.val(W.call(q,(Q.val()<<0)+1,0,100));f.val("v",Q.val(),ka.target);return false;case 40:Q.val(W.call(q,(Q.val()<<0)-1,0,100));f.val("v",Q.val(),ka.target);return false}}}},pa=function(ka){if(!(ka.target.value==""&&ka.target!=Y.get(0)&&(d!=null&&ka.target!=d.get(0)||d==null))){if(!ba(ka))return ka;switch(ka.target){case B.get(0):B.val(W.call(q,
(J.val()<<0)+1,0,100));f.val("s",J.val(),ka.target);return false;case 40:J.val(W.call(q,(J.val()<<0)-1,0,100));f.val("s",J.val(),ka.target);return false}break;case Q.get(0):switch(ka.keyCode){case 38:Q.val(W.call(q,(Q.val()<<0)+1,0,100));f.val("v",Q.val(),ka.target);return false;case 40:Q.val(W.call(q,(Q.val()<<0)-1,0,100));f.val("v",Q.val(),ka.target);return false}}}},pa=function(ka){if(!(ka.target.value==""&&ka.target!=X.get(0)&&(d!=null&&ka.target!=d.get(0)||d==null))){if(!ba(ka))return ka;switch(ka.target){case B.get(0):B.val(W.call(q,
B.val(),0,255));f.val("r",B.val(),ka.target);break;case o.get(0):o.val(W.call(q,o.val(),0,255));f.val("g",o.val(),ka.target);break;case K.get(0):K.val(W.call(q,K.val(),0,255));f.val("b",K.val(),ka.target);break;case T&&T.get(0):T.val(W.call(q,T.val(),0,100));f.val("a",Math.precision(T.val()*255/100,l),ka.target);break;case M.get(0):M.val(W.call(q,M.val(),0,360));f.val("h",M.val(),ka.target);break;case J.get(0):J.val(W.call(q,J.val(),0,100));f.val("s",J.val(),ka.target);break;case Q.get(0):Q.val(W.call(q,
Q.val(),0,100));f.val("v",Q.val(),ka.target);break;case Y.get(0):Y.val(Y.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));d&&d.val(Y.val());f.val("hex",Y.val()!=""?Y.val():null,ka.target);break;case d&&d.get(0):d.val(d.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));Y.val(d.val());f.val("hex",d.val()!=""?d.val():null,ka.target);break;case O&&O.get(0):O.val(O.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,2));f.val("a",O.val()!=null?parseInt(O.val(),16):
null,ka.target)}}},fa=function(ka){if(f.val()!=null)switch(ka.target){case B.get(0):B.val(f.val("r"));break;case o.get(0):o.val(f.val("g"));break;case K.get(0):K.val(f.val("b"));break;case T&&T.get(0):T.val(Math.precision(f.val("a")*100/255,l));break;case M.get(0):M.val(f.val("h"));break;case J.get(0):J.val(f.val("s"));break;case Q.get(0):Q.val(f.val("v"));break;case Y.get(0):case d&&d.get(0):Y.val(f.val("hex"));d&&d.val(f.val("hex"));break;case O&&O.get(0):O.val(f.val("ahex").substring(6))}},ba=
Q.val(),0,100));f.val("v",Q.val(),ka.target);break;case X.get(0):X.val(X.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));d&&d.val(X.val());f.val("hex",X.val()!=""?X.val():null,ka.target);break;case d&&d.get(0):d.val(d.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));X.val(d.val());f.val("hex",d.val()!=""?d.val():null,ka.target);break;case O&&O.get(0):O.val(O.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,2));f.val("a",O.val()!=null?parseInt(O.val(),16):
null,ka.target)}}},fa=function(ka){if(f.val()!=null)switch(ka.target){case B.get(0):B.val(f.val("r"));break;case o.get(0):o.val(f.val("g"));break;case K.get(0):K.val(f.val("b"));break;case T&&T.get(0):T.val(Math.precision(f.val("a")*100/255,l));break;case M.get(0):M.val(f.val("h"));break;case J.get(0):J.val(f.val("s"));break;case Q.get(0):Q.val(f.val("v"));break;case X.get(0):case d&&d.get(0):X.val(f.val("hex"));d&&d.val(f.val("hex"));break;case O&&O.get(0):O.val(f.val("ahex").substring(6))}},ba=
function(ka){switch(ka.keyCode){case 9:case 16:case 29:case 37:case 39:return false;case "c".charCodeAt():case "v".charCodeAt():if(ka.ctrlKey)return false}return true},W=function(ka,da,V){if(ka==""||isNaN(ka))return da;if(ka>V)return V;if(ka<da)return da;return ka},sa=function(ka,da){var V=ka.val("all");if(da!=B.get(0))B.val(V!=null?V.r:"");if(da!=o.get(0))o.val(V!=null?V.g:"");if(da!=K.get(0))K.val(V!=null?V.b:"");if(T&&da!=T.get(0))T.val(V!=null?Math.precision(V.a*100/255,l):"");if(da!=M.get(0))M.val(V!=
null?V.h:"");if(da!=J.get(0))J.val(V!=null?V.s:"");if(da!=Q.get(0))Q.val(V!=null?V.v:"");if(da!=Y.get(0)&&(d&&da!=d.get(0)||!d))Y.val(V!=null?V.hex:"");if(d&&da!=d.get(0)&&da!=Y.get(0))d.val(V!=null?V.hex:"");if(O&&da!=O.get(0))O.val(V!=null?V.ahex.substring(6):"")};a.extend(true,q,{destroy:function(){B.add(o).add(K).add(T).add(M).add(J).add(Q).add(Y).add(d).add(O).unbind("keyup",pa).unbind("blur",fa);B.add(o).add(K).add(T).add(M).add(J).add(Q).unbind("keydown",ia);f.unbind(sa);O=Y=Q=J=M=T=K=o=B=
null}});B.add(o).add(K).add(T).add(M).add(J).add(Q).add(Y).add(d).add(O).bind("keyup",pa).bind("blur",fa);B.add(o).add(K).add(T).add(M).add(J).add(Q).bind("keydown",ia);f.bind(sa)};a.jPicker={List:[],Color:function(b){var f=this,d,l,q,B,o,K,T,M=[],J=function(Y){for(var O=0;O<M.length;O++)M[O].call(f,f,Y)},Q=function(Y,O,ia){if(O===undefined){if(Y===undefined||Y==null||Y=="")Y="all";if(d==null)return null;switch(Y.toLowerCase()){case "ahex":return s.rgbaToHex({r:d,g:l,b:q,a:B});case "hex":return Q("ahex").substring(0,
6);case "all":return{r:d,g:l,b:q,a:B,h:o,s:K,v:T,hex:Q.call(f,"hex"),ahex:Q.call(f,"ahex")};default:O={};for(var pa=0;pa<Y.length;pa++)switch(Y.charAt(pa)){case "r":if(Y.length==1)O=d;else O.r=d;break;case "g":if(Y.length==1)O=l;else O.g=l;break;case "b":if(Y.length==1)O=q;else O.b=q;break;case "a":if(Y.length==1)O=B;else O.a=B;break;case "h":if(Y.length==1)O=o;else O.h=o;break;case "s":if(Y.length==1)O=K;else O.s=K;break;case "v":if(Y.length==1)O=T;else O.v=T}return O=={}?Q.call(f,"all"):O}}if(!(ia!=
null&&ia==f)){var fa=false;if(Y==null)Y="";if(O==null){if(d!=null){d=null;fa=true}if(l!=null){l=null;fa=true}if(q!=null){q=null;fa=true}if(B!=null){B=null;fa=true}if(o!=null){o=null;fa=true}if(K!=null){K=null;fa=true}if(T!=null){T=null;fa=true}fa&&J.call(f,ia||f)}else switch(Y.toLowerCase()){case "ahex":case "hex":O=s.hexToRgba(O&&(O.ahex||O.hex)||O||"00000000");Q.call(f,"rgba",{r:O.r,g:O.g,b:O.b,a:Y=="ahex"?O.a:B!=null?B:255},ia);break;default:if(O&&(O.ahex!=null||O.hex!=null)){Q.call(f,"ahex",O.ahex||
O.hex||"00000000",ia);break}var ba={},W=false,sa=false;if(O.r!==undefined&&!Y.indexOf("r")==-1)Y+="r";if(O.g!==undefined&&!Y.indexOf("g")==-1)Y+="g";if(O.b!==undefined&&!Y.indexOf("b")==-1)Y+="b";if(O.a!==undefined&&!Y.indexOf("a")==-1)Y+="a";if(O.h!==undefined&&!Y.indexOf("h")==-1)Y+="h";if(O.s!==undefined&&!Y.indexOf("s")==-1)Y+="s";if(O.v!==undefined&&!Y.indexOf("v")==-1)Y+="v";for(pa=0;pa<Y.length;pa++)switch(Y.charAt(pa)){case "r":if(sa)continue;W=true;ba.r=O&&O.r&&O.r|0||O&&O|0||0;if(ba.r<0)ba.r=
null?V.h:"");if(da!=J.get(0))J.val(V!=null?V.s:"");if(da!=Q.get(0))Q.val(V!=null?V.v:"");if(da!=X.get(0)&&(d&&da!=d.get(0)||!d))X.val(V!=null?V.hex:"");if(d&&da!=d.get(0)&&da!=X.get(0))d.val(V!=null?V.hex:"");if(O&&da!=O.get(0))O.val(V!=null?V.ahex.substring(6):"")};a.extend(true,q,{destroy:function(){B.add(o).add(K).add(T).add(M).add(J).add(Q).add(X).add(d).add(O).unbind("keyup",pa).unbind("blur",fa);B.add(o).add(K).add(T).add(M).add(J).add(Q).unbind("keydown",ia);f.unbind(sa);O=X=Q=J=M=T=K=o=B=
null}});B.add(o).add(K).add(T).add(M).add(J).add(Q).add(X).add(d).add(O).bind("keyup",pa).bind("blur",fa);B.add(o).add(K).add(T).add(M).add(J).add(Q).bind("keydown",ia);f.bind(sa)};a.jPicker={List:[],Color:function(b){var f=this,d,l,q,B,o,K,T,M=[],J=function(X){for(var O=0;O<M.length;O++)M[O].call(f,f,X)},Q=function(X,O,ia){if(O===undefined){if(X===undefined||X==null||X=="")X="all";if(d==null)return null;switch(X.toLowerCase()){case "ahex":return s.rgbaToHex({r:d,g:l,b:q,a:B});case "hex":return Q("ahex").substring(0,
6);case "all":return{r:d,g:l,b:q,a:B,h:o,s:K,v:T,hex:Q.call(f,"hex"),ahex:Q.call(f,"ahex")};default:O={};for(var pa=0;pa<X.length;pa++)switch(X.charAt(pa)){case "r":if(X.length==1)O=d;else O.r=d;break;case "g":if(X.length==1)O=l;else O.g=l;break;case "b":if(X.length==1)O=q;else O.b=q;break;case "a":if(X.length==1)O=B;else O.a=B;break;case "h":if(X.length==1)O=o;else O.h=o;break;case "s":if(X.length==1)O=K;else O.s=K;break;case "v":if(X.length==1)O=T;else O.v=T}return O=={}?Q.call(f,"all"):O}}if(!(ia!=
null&&ia==f)){var fa=false;if(X==null)X="";if(O==null){if(d!=null){d=null;fa=true}if(l!=null){l=null;fa=true}if(q!=null){q=null;fa=true}if(B!=null){B=null;fa=true}if(o!=null){o=null;fa=true}if(K!=null){K=null;fa=true}if(T!=null){T=null;fa=true}fa&&J.call(f,ia||f)}else switch(X.toLowerCase()){case "ahex":case "hex":O=s.hexToRgba(O&&(O.ahex||O.hex)||O||"00000000");Q.call(f,"rgba",{r:O.r,g:O.g,b:O.b,a:X=="ahex"?O.a:B!=null?B:255},ia);break;default:if(O&&(O.ahex!=null||O.hex!=null)){Q.call(f,"ahex",O.ahex||
O.hex||"00000000",ia);break}var ba={},W=false,sa=false;if(O.r!==undefined&&!X.indexOf("r")==-1)X+="r";if(O.g!==undefined&&!X.indexOf("g")==-1)X+="g";if(O.b!==undefined&&!X.indexOf("b")==-1)X+="b";if(O.a!==undefined&&!X.indexOf("a")==-1)X+="a";if(O.h!==undefined&&!X.indexOf("h")==-1)X+="h";if(O.s!==undefined&&!X.indexOf("s")==-1)X+="s";if(O.v!==undefined&&!X.indexOf("v")==-1)X+="v";for(pa=0;pa<X.length;pa++)switch(X.charAt(pa)){case "r":if(sa)continue;W=true;ba.r=O&&O.r&&O.r|0||O&&O|0||0;if(ba.r<0)ba.r=
0;else if(ba.r>255)ba.r=255;if(d!=ba.r){d=ba.r;fa=true}break;case "g":if(sa)continue;W=true;ba.g=O&&O.g&&O.g|0||O&&O|0||0;if(ba.g<0)ba.g=0;else if(ba.g>255)ba.g=255;if(l!=ba.g){l=ba.g;fa=true}break;case "b":if(sa)continue;W=true;ba.b=O&&O.b&&O.b|0||O&&O|0||0;if(ba.b<0)ba.b=0;else if(ba.b>255)ba.b=255;if(q!=ba.b){q=ba.b;fa=true}break;case "a":ba.a=O&&O.a!=null?O.a|0:O!=null?O|0:255;if(ba.a<0)ba.a=0;else if(ba.a>255)ba.a=255;if(B!=ba.a){B=ba.a;fa=true}break;case "h":if(W)continue;sa=true;ba.h=O&&O.h&&
O.h|0||O&&O|0||0;if(ba.h<0)ba.h=0;else if(ba.h>360)ba.h=360;if(o!=ba.h){o=ba.h;fa=true}break;case "s":if(W)continue;sa=true;ba.s=O&&O.s!=null?O.s|0:O!=null?O|0:100;if(ba.s<0)ba.s=0;else if(ba.s>100)ba.s=100;if(K!=ba.s){K=ba.s;fa=true}break;case "v":if(W)continue;sa=true;ba.v=O&&O.v!=null?O.v|0:O!=null?O|0:100;if(ba.v<0)ba.v=0;else if(ba.v>100)ba.v=100;if(T!=ba.v){T=ba.v;fa=true}}if(fa){if(W){d=d||0;l=l||0;q=q||0;O=s.rgbToHsv({r:d,g:l,b:q});o=O.h;K=O.s;T=O.v}else if(sa){o=o||0;K=K!=null?K:100;T=T!=
null?T:100;O=s.hsvToRgb({h:o,s:K,v:T});d=O.r;l=O.g;q=O.b}B=B!=null?B:255;J.call(f,ia||f)}}}};a.extend(true,f,{val:Q,bind:function(Y){a.isFunction(Y)&&M.push(Y)},unbind:function(Y){if(a.isFunction(Y))for(var O;(O=a.inArray(Y,M))!=-1;)M.splice(O,1)},destroy:function(){M=null}});if(b)if(b.ahex!=null)Q("ahex",b);else if(b.hex!=null)Q((b.a!=null?"a":"")+"hex",b.a!=null?{ahex:b.hex+s.intToHex(b.a)}:b);else if(b.r!=null&&b.g!=null&&b.b!=null)Q("rgb"+(b.a!=null?"a":""),b);else if(b.h!=null&&b.s!=null&&b.v!=
null?T:100;O=s.hsvToRgb({h:o,s:K,v:T});d=O.r;l=O.g;q=O.b}B=B!=null?B:255;J.call(f,ia||f)}}}};a.extend(true,f,{val:Q,bind:function(X){a.isFunction(X)&&M.push(X)},unbind:function(X){if(a.isFunction(X))for(var O;(O=a.inArray(X,M))!=-1;)M.splice(O,1)},destroy:function(){M=null}});if(b)if(b.ahex!=null)Q("ahex",b);else if(b.hex!=null)Q((b.a!=null?"a":"")+"hex",b.a!=null?{ahex:b.hex+s.intToHex(b.a)}:b);else if(b.r!=null&&b.g!=null&&b.b!=null)Q("rgb"+(b.a!=null?"a":""),b);else if(b.h!=null&&b.s!=null&&b.v!=
null)Q("hsv"+(b.a!=null?"a":""),b)},ColorMethods:{hexToRgba:function(b){b=this.validateHex(b);if(b=="")return{r:null,g:null,b:null,a:null};var f="00",d="00",l="00",q="255";if(b.length==6)b+="ff";if(b.length>6){f=b.substring(0,2);d=b.substring(2,4);l=b.substring(4,6);q=b.substring(6,b.length)}else{if(b.length>4){f=b.substring(4,b.length);b=b.substring(0,4)}if(b.length>2){d=b.substring(2,b.length);b=b.substring(0,2)}if(b.length>0)l=b.substring(0,b.length)}return{r:this.hexToInt(f),g:this.hexToInt(d),
b:this.hexToInt(l),a:this.hexToInt(q)}},validateHex:function(b){if(typeof b=="object")return"";b=b.toLowerCase().replace(/[^a-f0-9]/g,"");if(b.length>8)b=b.substring(0,8);return b},rgbaToHex:function(b){return this.intToHex(b.r)+this.intToHex(b.g)+this.intToHex(b.b)+this.intToHex(b.a)},intToHex:function(b){b=(b|0).toString(16);if(b.length==1)b="0"+b;return b.toLowerCase()},hexToInt:function(b){return parseInt(b,16)},rgbToHsv:function(b){var f=b.r/255,d=b.g/255;b=b.b/255;var l={h:0,s:0,v:0},q=0,B=
0;if(f>=d&&f>=b){B=f;q=d>b?b:d}else if(d>=b&&d>=f){B=d;q=f>b?b:f}else{B=b;q=d>f?f:d}l.v=B;l.s=B?(B-q)/B:0;if(l.s){q=B-q;l.h=f==B?(d-b)/q:d==B?2+(b-f)/q:4+(f-d)/q;l.h=parseInt(l.h*60);if(l.h<0)l.h+=360}else l.h=0;l.s=l.s*100|0;l.v=l.v*100|0;return l},hsvToRgb:function(b){var f={r:0,g:0,b:0,a:100},d=b.h,l=b.s;b=b.v;if(l==0)f.r=b==0?f.g=f.b=0:f.g=f.b=b*255/100|0;else{if(d==360)d=0;d/=60;l/=100;b/=100;var q=d|0,B=d-q;d=b*(1-l);var o=b*(1-l*B);l=b*(1-l*(1-B));switch(q){case 0:f.r=b;f.g=l;f.b=d;break;case 1:f.r=
o;f.g=b;f.b=d;break;case 2:f.r=d;f.g=b;f.b=l;break;case 3:f.r=d;f.g=o;f.b=b;break;case 4:f.r=l;f.g=d;f.b=b;break;case 5:f.r=b;f.g=d;f.b=o}f.r=f.r*255|0;f.g=f.g*255|0;f.b=f.b*255|0}return f}}};var c=a.jPicker.Color,n=a.jPicker.List,s=a.jPicker.ColorMethods;a.fn.jPicker=function(b){var f=arguments;return this.each(function(){var d=this,l=a.extend(true,{},a.fn.jPicker.defaults,b);if(a(d).get(0).nodeName.toLowerCase()=="input"){a.extend(true,l,{window:{bindToInput:true,expandable:true,input:a(d)}});if(a(d).val()==
""){l.color.active=new c({hex:null});l.color.current=new c({hex:null})}else if(s.validateHex(a(d).val())){l.color.active=new c({hex:a(d).val(),a:l.color.active.val("a")});l.color.current=new c({hex:a(d).val(),a:l.color.active.val("a")})}}if(l.window.expandable)a(d).after('<span class="jPicker"><span class="Icon"><span class="Color">&nbsp;</span><span class="Alpha">&nbsp;</span><span class="Image" title="Click To Open Color Picker">&nbsp;</span><span class="Container">&nbsp;</span></span></span>');
else l.window.liveUpdate=false;var q=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters,B=null,o=null,K=null,T=null,M=null,J=null,Q=null,Y=null,O=null,ia=null,pa=null,fa=null,ba=null,W=null,sa=null,ka=null,da=null,V=null,Z=null,oa=null,qa=null,ma=null,na=null,Aa=null,Fa=null,Ia=null,Ca=null,Ka=null,Na=function(N){var R=ja.active,ea=R.val("hex"),Ga,Oa;l.color.mode=N;switch(N){case "h":setTimeout(function(){Va.call(d,o,"transparent");Da.call(d,T,0);va.call(d,T,100);Da.call(d,
M,260);va.call(d,M,100);Va.call(d,K,"transparent");Da.call(d,Q,0);va.call(d,Q,100);Da.call(d,Y,260);va.call(d,Y,100);Da.call(d,O,260);va.call(d,O,100);Da.call(d,ia,260);va.call(d,ia,100);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:100,minY:0,maxY:100});W.range("rangeY",{minY:0,maxY:360});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("s"),y:100-R.val("v")},ba);W.val("y",360-R.val("h"),W);break;case "s":setTimeout(function(){Va.call(d,o,"transparent");Da.call(d,T,-260);Da.call(d,
M,-520);Da.call(d,Q,-260);Da.call(d,Y,-520);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:360,minY:0,maxY:100});W.range("rangeY",{minY:0,maxY:100});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("v")},ba);W.val("y",100-R.val("s"),W);break;case "v":setTimeout(function(){Va.call(d,o,"000000");Da.call(d,T,-780);Da.call(d,M,260);Va.call(d,K,ea);Da.call(d,Q,-520);Da.call(d,Y,260);va.call(d,Y,100);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:360,
minY:0,maxY:100});W.range("rangeY",{minY:0,maxY:100});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("s")},ba);W.val("y",100-R.val("v"),W);break;case "r":Ga=-1040;Oa=-780;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});W.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("b"),y:255-R.val("g")},ba);W.val("y",255-R.val("r"),W);break;case "g":Ga=-1560;Oa=-1820;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});W.range("rangeY",{minY:0,maxY:255});
if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("b"),y:255-R.val("r")},ba);W.val("y",255-R.val("g"),W);break;case "b":Ga=-2080;Oa=-2860;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});W.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("r"),y:255-R.val("g")},ba);W.val("y",255-R.val("b"),W);break;case "a":setTimeout(function(){Va.call(d,o,"transparent");Da.call(d,T,-260);Da.call(d,M,-520);Da.call(d,Q,260);Da.call(d,Y,260);va.call(d,Y,100);Da.call(d,fa,0);va.call(d,
fa,100)},0);ba.range("all",{minX:0,maxX:360,minY:0,maxY:100});W.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("v")},ba);W.val("y",255-R.val("a"),W);break;default:throw"Invalid Mode";}switch(N){case "s":case "v":case "a":setTimeout(function(){va.call(d,T,100);va.call(d,Q,100);Da.call(d,O,260);va.call(d,O,100);Da.call(d,ia,260);va.call(d,ia,100)},0);break;case "r":case "g":case "b":setTimeout(function(){Va.call(d,o,"transparent");Va.call(d,K,"transparent");
va.call(d,Q,100);va.call(d,T,100);Da.call(d,T,Ga);Da.call(d,M,Ga-260);Da.call(d,Q,Oa-780);Da.call(d,Y,Oa-520);Da.call(d,O,Oa);Da.call(d,ia,Oa-260);Da.call(d,fa,260);va.call(d,fa,100)},0)}R.val("ahex")!=null&&za.call(d,R)},za=function(N,R){if(R==null||R!=W&&R!=ba)wa.call(d,N,R);setTimeout(function(){qb.call(d,N);$a.call(d,N);ib.call(d,N)},0)},ya=function(N,R){var ea=ja.active;if(!(R!=ba&&ea.val()==null)){var Ga=N.val("all");switch(l.color.mode){case "h":ea.val("sv",{s:Ga.x,v:100-Ga.y},R);break;case "s":case "a":ea.val("hv",
else l.window.liveUpdate=false;var q=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters,B=null,o=null,K=null,T=null,M=null,J=null,Q=null,X=null,O=null,ia=null,pa=null,fa=null,ba=null,W=null,sa=null,ka=null,da=null,V=null,Z=null,oa=null,qa=null,ma=null,na=null,Aa=null,Fa=null,Ia=null,Ca=null,Ka=null,Na=function(N){var R=ja.active,ea=R.val("hex"),Ga,Pa;l.color.mode=N;switch(N){case "h":setTimeout(function(){Wa.call(d,o,"transparent");Da.call(d,T,0);va.call(d,T,100);Da.call(d,
M,260);va.call(d,M,100);Wa.call(d,K,"transparent");Da.call(d,Q,0);va.call(d,Q,100);Da.call(d,X,260);va.call(d,X,100);Da.call(d,O,260);va.call(d,O,100);Da.call(d,ia,260);va.call(d,ia,100);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:100,minY:0,maxY:100});W.range("rangeY",{minY:0,maxY:360});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("s"),y:100-R.val("v")},ba);W.val("y",360-R.val("h"),W);break;case "s":setTimeout(function(){Wa.call(d,o,"transparent");Da.call(d,T,-260);Da.call(d,
M,-520);Da.call(d,Q,-260);Da.call(d,X,-520);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:360,minY:0,maxY:100});W.range("rangeY",{minY:0,maxY:100});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("v")},ba);W.val("y",100-R.val("s"),W);break;case "v":setTimeout(function(){Wa.call(d,o,"000000");Da.call(d,T,-780);Da.call(d,M,260);Wa.call(d,K,ea);Da.call(d,Q,-520);Da.call(d,X,260);va.call(d,X,100);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:360,
minY:0,maxY:100});W.range("rangeY",{minY:0,maxY:100});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("s")},ba);W.val("y",100-R.val("v"),W);break;case "r":Ga=-1040;Pa=-780;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});W.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("b"),y:255-R.val("g")},ba);W.val("y",255-R.val("r"),W);break;case "g":Ga=-1560;Pa=-1820;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});W.range("rangeY",{minY:0,maxY:255});
if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("b"),y:255-R.val("r")},ba);W.val("y",255-R.val("g"),W);break;case "b":Ga=-2080;Pa=-2860;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});W.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("r"),y:255-R.val("g")},ba);W.val("y",255-R.val("b"),W);break;case "a":setTimeout(function(){Wa.call(d,o,"transparent");Da.call(d,T,-260);Da.call(d,M,-520);Da.call(d,Q,260);Da.call(d,X,260);va.call(d,X,100);Da.call(d,fa,0);va.call(d,
fa,100)},0);ba.range("all",{minX:0,maxX:360,minY:0,maxY:100});W.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("v")},ba);W.val("y",255-R.val("a"),W);break;default:throw"Invalid Mode";}switch(N){case "s":case "v":case "a":setTimeout(function(){va.call(d,T,100);va.call(d,Q,100);Da.call(d,O,260);va.call(d,O,100);Da.call(d,ia,260);va.call(d,ia,100)},0);break;case "r":case "g":case "b":setTimeout(function(){Wa.call(d,o,"transparent");Wa.call(d,K,"transparent");
va.call(d,Q,100);va.call(d,T,100);Da.call(d,T,Ga);Da.call(d,M,Ga-260);Da.call(d,Q,Pa-780);Da.call(d,X,Pa-520);Da.call(d,O,Pa);Da.call(d,ia,Pa-260);Da.call(d,fa,260);va.call(d,fa,100)},0)}R.val("ahex")!=null&&za.call(d,R)},za=function(N,R){if(R==null||R!=W&&R!=ba)wa.call(d,N,R);setTimeout(function(){qb.call(d,N);$a.call(d,N);ib.call(d,N)},0)},ya=function(N,R){var ea=ja.active;if(!(R!=ba&&ea.val()==null)){var Ga=N.val("all");switch(l.color.mode){case "h":ea.val("sv",{s:Ga.x,v:100-Ga.y},R);break;case "s":case "a":ea.val("hv",
{h:Ga.x,v:100-Ga.y},R);break;case "v":ea.val("hs",{h:Ga.x,s:100-Ga.y},R);break;case "r":ea.val("gb",{g:255-Ga.y,b:Ga.x},R);break;case "g":ea.val("rb",{r:255-Ga.y,b:Ga.x},R);break;case "b":ea.val("rg",{r:Ga.x,g:255-Ga.y},R)}}},Ha=function(N,R){var ea=ja.active;if(!(R!=W&&ea.val()==null))switch(l.color.mode){case "h":ea.val("h",{h:360-N.val("y")},R);break;case "s":ea.val("s",{s:100-N.val("y")},R);break;case "v":ea.val("v",{v:100-N.val("y")},R);break;case "r":ea.val("r",{r:255-N.val("y")},R);break;case "g":ea.val("g",
{g:255-N.val("y")},R);break;case "b":ea.val("b",{b:255-N.val("y")},R);break;case "a":ea.val("a",255-N.val("y"),R)}},wa=function(N,R){if(R!=ba)switch(l.color.mode){case "h":var ea=N.val("sv");ba.val("xy",{x:ea!=null?ea.s:100,y:100-(ea!=null?ea.v:100)},R);break;case "s":case "a":ea=N.val("hv");ba.val("xy",{x:ea&&ea.h||0,y:100-(ea!=null?ea.v:100)},R);break;case "v":ea=N.val("hs");ba.val("xy",{x:ea&&ea.h||0,y:100-(ea!=null?ea.s:100)},R);break;case "r":ea=N.val("bg");ba.val("xy",{x:ea&&ea.b||0,y:255-(ea&&
ea.g||0)},R);break;case "g":ea=N.val("br");ba.val("xy",{x:ea&&ea.b||0,y:255-(ea&&ea.r||0)},R);break;case "b":ea=N.val("rg");ba.val("xy",{x:ea&&ea.r||0,y:255-(ea&&ea.g||0)},R)}if(R!=W)switch(l.color.mode){case "h":W.val("y",360-(N.val("h")||0),R);break;case "s":ea=N.val("s");W.val("y",100-(ea!=null?ea:100),R);break;case "v":ea=N.val("v");W.val("y",100-(ea!=null?ea:100),R);break;case "r":W.val("y",255-(N.val("r")||0),R);break;case "g":W.val("y",255-(N.val("g")||0),R);break;case "b":W.val("y",255-(N.val("b")||
0),R);break;case "a":ea=N.val("a");W.val("y",255-(ea!=null?ea:255),R)}},qb=function(N){try{var R=N.val("all");oa.css({backgroundColor:R&&"#"+R.hex||"transparent"});va.call(d,oa,R&&Math.precision(R.a*100/255,4)||0)}catch(ea){}},$a=function(N){switch(l.color.mode){case "h":Va.call(d,o,(new c({h:N.val("h")||0,s:100,v:100})).val("hex"));break;case "s":case "a":var R=N.val("s");va.call(d,M,100-(R!=null?R:100));break;case "v":R=N.val("v");va.call(d,T,R!=null?R:100);break;case "r":va.call(d,M,Math.precision((N.val("r")||
0)/255*100,4));break;case "g":va.call(d,M,Math.precision((N.val("g")||0)/255*100,4));break;case "b":va.call(d,M,Math.precision((N.val("b")||0)/255*100))}N=N.val("a");va.call(d,J,Math.precision((255-(N||0))*100/255,4))},ib=function(N){switch(l.color.mode){case "h":var R=N.val("a");va.call(d,pa,Math.precision((255-(R||0))*100/255,4));break;case "s":R=N.val("hva");var ea=new c({h:R&&R.h||0,s:100,v:R!=null?R.v:100});Va.call(d,K,ea.val("hex"));va.call(d,Y,100-(R!=null?R.v:100));va.call(d,pa,Math.precision((255-
(R&&R.a||0))*100/255,4));break;case "v":R=N.val("hsa");ea=new c({h:R&&R.h||0,s:R!=null?R.s:100,v:100});Va.call(d,K,ea.val("hex"));va.call(d,pa,Math.precision((255-(R&&R.a||0))*100/255,4));break;case "r":case "g":case "b":ea=R=0;N=N.val("rgba");if(l.color.mode=="r"){R=N&&N.b||0;ea=N&&N.g||0}else if(l.color.mode=="g"){R=N&&N.b||0;ea=N&&N.r||0}else if(l.color.mode=="b"){R=N&&N.r||0;ea=N&&N.g||0}var Ga=ea>R?R:ea;va.call(d,Y,R>ea?Math.precision((R-ea)/(255-ea)*100,4):0);va.call(d,O,ea>R?Math.precision((ea-
R)/(255-R)*100,4):0);va.call(d,ia,Math.precision(Ga/255*100,4));va.call(d,pa,Math.precision((255-(N&&N.a||0))*100/255,4));break;case "a":R=N.val("a");Va.call(d,K,N.val("hex")||"000000");va.call(d,pa,R!=null?0:100);va.call(d,fa,R!=null?100:0)}},Va=function(N,R){N.css({backgroundColor:R&&R.length==6&&"#"+R||"transparent"})},Ra=function(N,R){if(q&&(R.indexOf("AlphaBar.png")!=-1||R.indexOf("Bars.png")!=-1||R.indexOf("Maps.png")!=-1)){N.attr("pngSrc",R);N.css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+
0),R);break;case "a":ea=N.val("a");W.val("y",255-(ea!=null?ea:255),R)}},qb=function(N){try{var R=N.val("all");oa.css({backgroundColor:R&&"#"+R.hex||"transparent"});va.call(d,oa,R&&Math.precision(R.a*100/255,4)||0)}catch(ea){}},$a=function(N){switch(l.color.mode){case "h":Wa.call(d,o,(new c({h:N.val("h")||0,s:100,v:100})).val("hex"));break;case "s":case "a":var R=N.val("s");va.call(d,M,100-(R!=null?R:100));break;case "v":R=N.val("v");va.call(d,T,R!=null?R:100);break;case "r":va.call(d,M,Math.precision((N.val("r")||
0)/255*100,4));break;case "g":va.call(d,M,Math.precision((N.val("g")||0)/255*100,4));break;case "b":va.call(d,M,Math.precision((N.val("b")||0)/255*100))}N=N.val("a");va.call(d,J,Math.precision((255-(N||0))*100/255,4))},ib=function(N){switch(l.color.mode){case "h":var R=N.val("a");va.call(d,pa,Math.precision((255-(R||0))*100/255,4));break;case "s":R=N.val("hva");var ea=new c({h:R&&R.h||0,s:100,v:R!=null?R.v:100});Wa.call(d,K,ea.val("hex"));va.call(d,X,100-(R!=null?R.v:100));va.call(d,pa,Math.precision((255-
(R&&R.a||0))*100/255,4));break;case "v":R=N.val("hsa");ea=new c({h:R&&R.h||0,s:R!=null?R.s:100,v:100});Wa.call(d,K,ea.val("hex"));va.call(d,pa,Math.precision((255-(R&&R.a||0))*100/255,4));break;case "r":case "g":case "b":ea=R=0;N=N.val("rgba");if(l.color.mode=="r"){R=N&&N.b||0;ea=N&&N.g||0}else if(l.color.mode=="g"){R=N&&N.b||0;ea=N&&N.r||0}else if(l.color.mode=="b"){R=N&&N.r||0;ea=N&&N.g||0}var Ga=ea>R?R:ea;va.call(d,X,R>ea?Math.precision((R-ea)/(255-ea)*100,4):0);va.call(d,O,ea>R?Math.precision((ea-
R)/(255-R)*100,4):0);va.call(d,ia,Math.precision(Ga/255*100,4));va.call(d,pa,Math.precision((255-(N&&N.a||0))*100/255,4));break;case "a":R=N.val("a");Wa.call(d,K,N.val("hex")||"000000");va.call(d,pa,R!=null?0:100);va.call(d,fa,R!=null?100:0)}},Wa=function(N,R){N.css({backgroundColor:R&&R.length==6&&"#"+R||"transparent"})},Sa=function(N,R){if(q&&(R.indexOf("AlphaBar.png")!=-1||R.indexOf("Bars.png")!=-1||R.indexOf("Maps.png")!=-1)){N.attr("pngSrc",R);N.css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+
R+"', sizingMethod='scale')"})}else N.css({backgroundImage:"url('"+R+"')"})},Da=function(N,R){N.css({top:R+"px"})},va=function(N,R){N.css({visibility:R>0?"visible":"hidden"});if(R>0&&R<100)if(q){var ea=N.attr("pngSrc");ea!=null&&(ea.indexOf("AlphaBar.png")!=-1||ea.indexOf("Bars.png")!=-1||ea.indexOf("Maps.png")!=-1)?N.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ea+"', sizingMethod='scale') progid:DXImageTransform.Microsoft.Alpha(opacity="+R+")"}):N.css({opacity:Math.precision(R/
100,4)})}else N.css({opacity:Math.precision(R/100,4)});else if(R==0||R==100)if(q){ea=N.attr("pngSrc");ea!=null&&(ea.indexOf("AlphaBar.png")!=-1||ea.indexOf("Bars.png")!=-1||ea.indexOf("Maps.png")!=-1)?N.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ea+"', sizingMethod='scale')"}):N.css({opacity:""})}else N.css({opacity:""})},fb=function(){ja.active.val("ahex",ja.current.val("ahex"))},La=function(){ja.current.val("ahex",ja.active.val("ahex"))},Ua=function(N){a(this).parents("tbody:first").find('input:radio[value!="'+
100,4)})}else N.css({opacity:Math.precision(R/100,4)});else if(R==0||R==100)if(q){ea=N.attr("pngSrc");ea!=null&&(ea.indexOf("AlphaBar.png")!=-1||ea.indexOf("Bars.png")!=-1||ea.indexOf("Maps.png")!=-1)?N.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ea+"', sizingMethod='scale')"}):N.css({opacity:""})}else N.css({opacity:""})},fb=function(){ja.active.val("ahex",ja.current.val("ahex"))},La=function(){ja.current.val("ahex",ja.active.val("ahex"))},Va=function(N){a(this).parents("tbody:first").find('input:radio[value!="'+
N.target.value+'"]').removeAttr("checked");Na.call(d,N.target.value)},Ea=function(){fb.call(d)},kb=function(){fb.call(d);l.window.expandable&&wb.call(d);a.isFunction(tb)&&tb.call(d,ja.active,na)},sb=function(){La.call(d);l.window.expandable&&wb.call(d);a.isFunction(ob)&&ob.call(d,ja.active,ma)},Za=function(){ub.call(d)},bb=function(N){var R=N.val("hex");qa.css({backgroundColor:R&&"#"+R||"transparent"});va.call(d,qa,Math.precision((N.val("a")||0)*100/255,4))},Cb=function(N){var R=N.val("hex");N=N.val("va");
Fa.css({backgroundColor:R&&"#"+R||"transparent"});va.call(d,Ia,Math.precision((255-(N&&N.a||0))*100/255,4));if(l.window.bindToInput&&l.window.updateInputColor)l.window.input.css({backgroundColor:R&&"#"+R||"transparent",color:N==null||N.v>75?"#000000":"#ffffff"})},ta=function(N){ka=parseInt(B.css("left"));da=parseInt(B.css("top"));V=N.pageX;Z=N.pageY;a(document).bind("mousemove",mb).bind("mouseup",jb);N.preventDefault()},mb=function(N){B.css({left:ka-(V-N.pageX)+"px",top:da-(Z-N.pageY)+"px"});l.window.expandable&&
!a.support.boxModel&&B.prev().css({left:B.css("left"),top:B.css("top")});N.stopPropagation();N.preventDefault();return false},jb=function(N){a(document).unbind("mousemove",mb).unbind("mouseup",jb);N.stopPropagation();N.preventDefault();return false},zb=function(N){N.preventDefault();N.stopPropagation();ja.active.val("ahex",a(this).attr("title")||null,N.target);return false},ob=a.isFunction(f[1])&&f[1]||null,eb=a.isFunction(f[2])&&f[2]||null,tb=a.isFunction(f[3])&&f[3]||null,ub=function(){ja.current.val("ahex",
Fa.css({backgroundColor:R&&"#"+R||"transparent"});va.call(d,Ia,Math.precision((255-(N&&N.a||0))*100/255,4));if(l.window.bindToInput&&l.window.updateInputColor)l.window.input.css({backgroundColor:R&&"#"+R||"transparent",color:N==null||N.v>75?"#000000":"#ffffff"})},ua=function(N){ka=parseInt(B.css("left"));da=parseInt(B.css("top"));V=N.pageX;Z=N.pageY;a(document).bind("mousemove",mb).bind("mouseup",jb);N.preventDefault()},mb=function(N){B.css({left:ka-(V-N.pageX)+"px",top:da-(Z-N.pageY)+"px"});l.window.expandable&&
!a.support.boxModel&&B.prev().css({left:B.css("left"),top:B.css("top")});N.stopPropagation();N.preventDefault();return false},jb=function(N){a(document).unbind("mousemove",mb).unbind("mouseup",jb);N.stopPropagation();N.preventDefault();return false},Ab=function(N){N.preventDefault();N.stopPropagation();ja.active.val("ahex",a(this).attr("title")||null,N.target);return false},ob=a.isFunction(f[1])&&f[1]||null,eb=a.isFunction(f[2])&&f[2]||null,tb=a.isFunction(f[3])&&f[3]||null,ub=function(){ja.current.val("ahex",
ja.active.val("ahex"));var N=function(){if(!(!l.window.expandable||a.support.boxModel)){var R=B.find("table:first");B.before("<iframe/>");B.prev().css({width:R.width(),height:B.height(),opacity:0,position:"absolute",left:B.css("left"),top:B.css("top")})}};if(l.window.expandable){a(document.body).children("div.jPicker.Container").css({zIndex:10});B.css({zIndex:20})}switch(l.window.effects.type){case "fade":B.fadeIn(l.window.effects.speed.show,N);break;case "slide":B.slideDown(l.window.effects.speed.show,
N);break;default:B.show(l.window.effects.speed.show,N)}},wb=function(){var N=function(){l.window.expandable&&B.css({zIndex:10});!l.window.expandable||a.support.boxModel||B.prev().remove()};switch(l.window.effects.type){case "fade":B.fadeOut(l.window.effects.speed.hide,N);break;case "slide":B.slideUp(l.window.effects.speed.hide,N);break;default:B.hide(l.window.effects.speed.hide,N)}},Ab=function(){var N=l.window,R=N.expandable?a(d).next().find(".Container:first"):null;B=N.expandable?a("<div/>"):a(d);
B.addClass("jPicker Container");N.expandable&&B.hide();B.get(0).onselectstart=function(Pa){if(Pa.target.nodeName.toLowerCase()!=="input")return false};var ea=ja.active.val("all");if(N.alphaPrecision<0)N.alphaPrecision=0;else if(N.alphaPrecision>2)N.alphaPrecision=2;var Ga='<table class="jPicker" cellpadding="0" cellspacing="0"><tbody>'+(N.expandable?'<tr><td class="Move" colspan="5">&nbsp;</td></tr>':"")+'<tr><td rowspan="9"><h2 class="Title">'+(N.title||ca.text.title)+'</h2><div class="Map"><span class="Map1">&nbsp;</span><span class="Map2">&nbsp;</span><span class="Map3">&nbsp;</span><img src="'+
N);break;default:B.show(l.window.effects.speed.show,N)}},wb=function(){var N=function(){l.window.expandable&&B.css({zIndex:10});!l.window.expandable||a.support.boxModel||B.prev().remove()};switch(l.window.effects.type){case "fade":B.fadeOut(l.window.effects.speed.hide,N);break;case "slide":B.slideUp(l.window.effects.speed.hide,N);break;default:B.hide(l.window.effects.speed.hide,N)}},Bb=function(){var N=l.window,R=N.expandable?a(d).next().find(".Container:first"):null;B=N.expandable?a("<div/>"):a(d);
B.addClass("jPicker Container");N.expandable&&B.hide();B.get(0).onselectstart=function(Qa){if(Qa.target.nodeName.toLowerCase()!=="input")return false};var ea=ja.active.val("all");if(N.alphaPrecision<0)N.alphaPrecision=0;else if(N.alphaPrecision>2)N.alphaPrecision=2;var Ga='<table class="jPicker" cellpadding="0" cellspacing="0"><tbody>'+(N.expandable?'<tr><td class="Move" colspan="5">&nbsp;</td></tr>':"")+'<tr><td rowspan="9"><h2 class="Title">'+(N.title||ca.text.title)+'</h2><div class="Map"><span class="Map1">&nbsp;</span><span class="Map2">&nbsp;</span><span class="Map3">&nbsp;</span><img src="'+
la.clientPath+la.colorMap.arrow.file+'" class="Arrow"/></div></td><td rowspan="9"><div class="Bar"><span class="Map1">&nbsp;</span><span class="Map2">&nbsp;</span><span class="Map3">&nbsp;</span><span class="Map4">&nbsp;</span><span class="Map5">&nbsp;</span><span class="Map6">&nbsp;</span><img src="'+la.clientPath+la.colorBar.arrow.file+'" class="Arrow"/></div></td><td colspan="2" class="Preview"><div class="prev_div">'+ca.text.newColor+'<div class="color_preview"><span class="Active" title="'+ca.tooltips.colors.newColor+
'">&nbsp;</span><span class="Current" title="'+ca.tooltips.colors.currentColor+'">&nbsp;</span></div></div>'+ca.text.currentColor+'</td><td rowspan="9" class="Button"><input type="button" class="Ok" value="'+ca.text.ok+'" title="'+ca.tooltips.buttons.ok+'"/><input type="button" class="Cancel" value="'+ca.text.cancel+'" title="'+ca.tooltips.buttons.cancel+'"/><div class="Grid">&nbsp;</div></td></tr><tr class="Hue"><td class="Radio"><label title="'+ca.tooltips.hue.radio+'"><input type="radio" value="h"'+
(l.color.mode=="h"?' checked="checked"':"")+'/>H:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(ea!=null?ea.h:"")+'" title="'+ca.tooltips.hue.textbox+'"/>&nbsp;\u00ba</td></tr><tr class="Saturation"><td class="Radio"><label title="'+ca.tooltips.saturation.radio+'"><input type="radio" value="s"'+(l.color.mode=="s"?' checked="checked"':"")+'/>S:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(ea!=null?ea.s:"")+'" title="'+ca.tooltips.saturation.textbox+
@ -636,16 +636,16 @@ la.clientPath+la.colorMap.arrow.file+'" class="Arrow"/></div></td><td rowspan="9
"")+'/>B:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(ea!=null?ea.b:"")+'" title="'+ca.tooltips.blue.textbox+'"/></td></tr><tr class="Alpha"><td class="Radio">'+(N.alphaSupport?'<label title="'+ca.tooltips.alpha.radio+'"><input type="radio" value="a"'+(l.color.mode=="a"?' checked="checked"':"")+"/>A:</label>":"&nbsp;")+'</td><td class="Text">'+(N.alphaSupport?'<input type="text" maxlength="'+(3+N.alphaPrecision)+'" value="'+(ea!=null?Math.precision(ea.a*100/255,N.alphaPrecision):
"")+'" title="'+ca.tooltips.alpha.textbox+'"/>&nbsp;%':"&nbsp;")+'</td></tr><tr class="Hex"><td colspan="2" class="Text"><label title="'+ca.tooltips.hex.textbox+'">#:<input type="text" maxlength="6" class="Hex" value="'+(ea!=null?ea.hex:"")+'"/></label>'+(N.alphaSupport?'<input type="text" maxlength="2" class="AHex" value="'+(ea!=null?ea.ahex.substring(6):"")+'" title="'+ca.tooltips.hex.alpha+'"/></td>':"&nbsp;")+"</tr></tbody></table>";if(N.expandable){B.html(Ga);a(document.body).children("div.jPicker.Container").length==
0?a(document.body).prepend(B):a(document.body).children("div.jPicker.Container:last").after(B);B.mousedown(function(){a(document.body).children("div.jPicker.Container").css({zIndex:10});B.css({zIndex:20})});B.css({left:N.position.x=="left"?R.offset().left-530-(N.position.y=="center"?25:0)+"px":N.position.x=="center"?R.offset().left-260+"px":N.position.x=="right"?R.offset().left-10+(N.position.y=="center"?25:0)+"px":N.position.x=="screenCenter"?(a(document).width()>>1)-260+"px":R.offset().left+parseInt(N.position.x)+
"px",position:"absolute",top:N.position.y=="top"?R.offset().top-312+"px":N.position.y=="center"?R.offset().top-156+"px":N.position.y=="bottom"?R.offset().top+25+"px":R.offset().top+parseInt(N.position.y)+"px"})}else{B=a(d);B.html(Ga)}Ga=B.find("tbody:first");o=Ga.find("div.Map:first");K=Ga.find("div.Bar:first");var Oa=o.find("span"),Ya=K.find("span");T=Oa.filter(".Map1:first");M=Oa.filter(".Map2:first");J=Oa.filter(".Map3:first");Q=Ya.filter(".Map1:first");Y=Ya.filter(".Map2:first");O=Ya.filter(".Map3:first");
"px",position:"absolute",top:N.position.y=="top"?R.offset().top-312+"px":N.position.y=="center"?R.offset().top-156+"px":N.position.y=="bottom"?R.offset().top+25+"px":R.offset().top+parseInt(N.position.y)+"px"})}else{B=a(d);B.html(Ga)}Ga=B.find("tbody:first");o=Ga.find("div.Map:first");K=Ga.find("div.Bar:first");var Pa=o.find("span"),Ya=K.find("span");T=Pa.filter(".Map1:first");M=Pa.filter(".Map2:first");J=Pa.filter(".Map3:first");Q=Ya.filter(".Map1:first");X=Ya.filter(".Map2:first");O=Ya.filter(".Map3:first");
ia=Ya.filter(".Map4:first");pa=Ya.filter(".Map5:first");fa=Ya.filter(".Map6:first");ba=new p(o,{map:{width:la.colorMap.width,height:la.colorMap.height},arrow:{image:la.clientPath+la.colorMap.arrow.file,width:la.colorMap.arrow.width,height:la.colorMap.arrow.height}});ba.bind(ya);W=new p(K,{map:{width:la.colorBar.width,height:la.colorBar.height},arrow:{image:la.clientPath+la.colorBar.arrow.file,width:la.colorBar.arrow.width,height:la.colorBar.arrow.height}});W.bind(Ha);sa=new g(Ga,ja.active,N.expandable&&
N.bindToInput?N.input:null,N.alphaPrecision);Oa=ea!=null?ea.hex:null;var db=Ga.find(".Preview");Ya=Ga.find(".Button");oa=db.find(".Active:first").css({backgroundColor:Oa&&"#"+Oa||"transparent"});qa=db.find(".Current:first").css({backgroundColor:Oa&&"#"+Oa||"transparent"}).bind("click",Ea);va.call(d,qa,Math.precision(ja.current.val("a")*100)/255,4);ma=Ya.find(".Ok:first").bind("click touchstart",sb);na=Ya.find(".Cancel:first").bind("click touchstart",kb);Aa=Ya.find(".Grid:first");setTimeout(function(){Ra.call(d,
T,la.clientPath+"Maps.png");Ra.call(d,M,la.clientPath+"Maps.png");Ra.call(d,J,la.clientPath+"map-opacity.png");Ra.call(d,Q,la.clientPath+"Bars.png");Ra.call(d,Y,la.clientPath+"Bars.png");Ra.call(d,O,la.clientPath+"Bars.png");Ra.call(d,ia,la.clientPath+"Bars.png");Ra.call(d,pa,la.clientPath+"bar-opacity.png");Ra.call(d,fa,la.clientPath+"AlphaBar.png");Ra.call(d,db.find("div:last"),la.clientPath+"preview-opacity.png")},0);Ga.find("td.Radio input").bind("click touchstart",Ua);if(ja.quickList&&ja.quickList.length>
0){Ya="";for(i=0;i<ja.quickList.length;i++){if((typeof ja.quickList[i]).toString().toLowerCase()=="string")ja.quickList[i]=new c({hex:ja.quickList[i]});var nb=ja.quickList[i].val("a"),Xa=ja.quickList[i].val("ahex");if(!N.alphaSupport&&Xa)Xa=Xa.substring(0,6)+"ff";var rb=ja.quickList[i].val("hex");Ya+='<span class="QuickColor"'+(Xa&&' title="#'+Xa+'"'||"")+' style="background-color:'+(rb&&"#"+rb||"")+";"+(rb?"":"background-image:url("+la.clientPath+"NoColor.png)")+(N.alphaSupport&&nb&&nb<255?";opacity:"+
Math.precision(nb/255,4)+";filter:Alpha(opacity="+Math.precision(nb/2.55,4)+")":"")+'">&nbsp;</span>'}Ra.call(d,Aa,la.clientPath+"bar-opacity.png");Aa.html(Ya);Aa.find(".QuickColor").click(zb)}Na.call(d,l.color.mode);ja.active.bind(za);a.isFunction(eb)&&ja.active.bind(eb);ja.current.bind(bb);if(N.expandable){d.icon=R.parents(".Icon:first");Fa=d.icon.find(".Color:first").css({backgroundColor:Oa&&"#"+Oa||"transparent"});Ia=d.icon.find(".Alpha:first");Ra.call(d,Ia,la.clientPath+"bar-opacity.png");va.call(d,
Ia,Math.precision((255-(ea!=null?ea.a:0))*100/255,4));Ca=d.icon.find(".Image:first").css({backgroundImage:"url('"+la.clientPath+la.picker.file+"')"}).bind("click",Za);if(N.bindToInput&&N.updateInputColor)N.input.css({backgroundColor:Oa&&"#"+Oa||"transparent",color:ea==null||ea.v>75?"#000000":"#ffffff"});Ka=Ga.find(".Move:first").bind("mousedown",ta);ja.active.bind(Cb)}else ub.call(d)},la=l.images,ca=l.localization,ja={active:(typeof l.color.active).toString().toLowerCase()=="string"?new c({ahex:!l.window.alphaSupport&&
N.bindToInput?N.input:null,N.alphaPrecision);Pa=ea!=null?ea.hex:null;var db=Ga.find(".Preview");Ya=Ga.find(".Button");oa=db.find(".Active:first").css({backgroundColor:Pa&&"#"+Pa||"transparent"});qa=db.find(".Current:first").css({backgroundColor:Pa&&"#"+Pa||"transparent"}).bind("click",Ea);va.call(d,qa,Math.precision(ja.current.val("a")*100)/255,4);ma=Ya.find(".Ok:first").bind("click touchstart",sb);na=Ya.find(".Cancel:first").bind("click touchstart",kb);Aa=Ya.find(".Grid:first");setTimeout(function(){Sa.call(d,
T,la.clientPath+"Maps.png");Sa.call(d,M,la.clientPath+"Maps.png");Sa.call(d,J,la.clientPath+"map-opacity.png");Sa.call(d,Q,la.clientPath+"Bars.png");Sa.call(d,X,la.clientPath+"Bars.png");Sa.call(d,O,la.clientPath+"Bars.png");Sa.call(d,ia,la.clientPath+"Bars.png");Sa.call(d,pa,la.clientPath+"bar-opacity.png");Sa.call(d,fa,la.clientPath+"AlphaBar.png");Sa.call(d,db.find("div:last"),la.clientPath+"preview-opacity.png")},0);Ga.find("td.Radio input").bind("click touchstart",Va);if(ja.quickList&&ja.quickList.length>
0){Ya="";for(i=0;i<ja.quickList.length;i++){if((typeof ja.quickList[i]).toString().toLowerCase()=="string")ja.quickList[i]=new c({hex:ja.quickList[i]});var nb=ja.quickList[i].val("a"),Ua=ja.quickList[i].val("ahex");if(!N.alphaSupport&&Ua)Ua=Ua.substring(0,6)+"ff";var rb=ja.quickList[i].val("hex");Ya+='<span class="QuickColor"'+(Ua&&' title="#'+Ua+'"'||"")+' style="background-color:'+(rb&&"#"+rb||"")+";"+(rb?"":"background-image:url("+la.clientPath+"NoColor.png)")+(N.alphaSupport&&nb&&nb<255?";opacity:"+
Math.precision(nb/255,4)+";filter:Alpha(opacity="+Math.precision(nb/2.55,4)+")":"")+'">&nbsp;</span>'}Sa.call(d,Aa,la.clientPath+"bar-opacity.png");Aa.html(Ya);Aa.find(".QuickColor").click(Ab)}Na.call(d,l.color.mode);ja.active.bind(za);a.isFunction(eb)&&ja.active.bind(eb);ja.current.bind(bb);if(N.expandable){d.icon=R.parents(".Icon:first");Fa=d.icon.find(".Color:first").css({backgroundColor:Pa&&"#"+Pa||"transparent"});Ia=d.icon.find(".Alpha:first");Sa.call(d,Ia,la.clientPath+"bar-opacity.png");va.call(d,
Ia,Math.precision((255-(ea!=null?ea.a:0))*100/255,4));Ca=d.icon.find(".Image:first").css({backgroundImage:"url('"+la.clientPath+la.picker.file+"')"}).bind("click",Za);if(N.bindToInput&&N.updateInputColor)N.input.css({backgroundColor:Pa&&"#"+Pa||"transparent",color:ea==null||ea.v>75?"#000000":"#ffffff"});Ka=Ga.find(".Move:first").bind("mousedown",ua);ja.active.bind(Cb)}else ub.call(d)},la=l.images,ca=l.localization,ja={active:(typeof l.color.active).toString().toLowerCase()=="string"?new c({ahex:!l.window.alphaSupport&&
l.color.active?l.color.active.substring(0,6)+"ff":l.color.active}):new c({ahex:!l.window.alphaSupport&&l.color.active.val("ahex")?l.color.active.val("ahex").substring(0,6)+"ff":l.color.active.val("ahex")}),current:(typeof l.color.active).toString().toLowerCase()=="string"?new c({ahex:!l.window.alphaSupport&&l.color.active?l.color.active.substring(0,6)+"ff":l.color.active}):new c({ahex:!l.window.alphaSupport&&l.color.active.val("ahex")?l.color.active.val("ahex").substring(0,6)+"ff":l.color.active.val("ahex")}),
quickList:l.color.quickList};a.extend(true,d,{commitCallback:ob,liveCallback:eb,cancelCallback:tb,color:ja,show:ub,hide:wb,destroy:function(){B.find("td.Radio input touchstart").unbind("click",Ua);qa.unbind("click touchstart",Ea);na.unbind("click touchstart",kb);ma.unbind("click touchstart",sb);if(l.window.expandable){Ca.unbind("click",Za);Ka.unbind("mousedown",ta);d.icon=null}B.find(".QuickColor").unbind("click",zb);fa=pa=ia=O=Y=Q=J=M=T=K=o=null;ba.destroy();ba=null;W.destroy();W=null;sa.destroy();
eb=tb=ob=Aa=na=ma=qa=oa=sa=null;B.html("");for(i=0;i<n.length;i++)n[i]==d&&n.splice(i,1)}});n.push(d);setTimeout(function(){Ab.call(d)},0)})};a.fn.jPicker.defaults={window:{title:null,effects:{type:"slide",speed:{show:"slow",hide:"fast"}},position:{x:"screenCenter",y:"top"},expandable:false,liveUpdate:true,alphaSupport:false,alphaPrecision:0,updateInputColor:true},color:{mode:"h",active:new c({ahex:"#ffcc00ff"}),quickList:[new c({h:360,s:33,v:100}),new c({h:360,s:66,v:100}),new c({h:360,s:100,v:100}),
quickList:l.color.quickList};a.extend(true,d,{commitCallback:ob,liveCallback:eb,cancelCallback:tb,color:ja,show:ub,hide:wb,destroy:function(){B.find("td.Radio input touchstart").unbind("click",Va);qa.unbind("click touchstart",Ea);na.unbind("click touchstart",kb);ma.unbind("click touchstart",sb);if(l.window.expandable){Ca.unbind("click",Za);Ka.unbind("mousedown",ua);d.icon=null}B.find(".QuickColor").unbind("click",Ab);fa=pa=ia=O=X=Q=J=M=T=K=o=null;ba.destroy();ba=null;W.destroy();W=null;sa.destroy();
eb=tb=ob=Aa=na=ma=qa=oa=sa=null;B.html("");for(i=0;i<n.length;i++)n[i]==d&&n.splice(i,1)}});n.push(d);setTimeout(function(){Bb.call(d)},0)})};a.fn.jPicker.defaults={window:{title:null,effects:{type:"slide",speed:{show:"slow",hide:"fast"}},position:{x:"screenCenter",y:"top"},expandable:false,liveUpdate:true,alphaSupport:false,alphaPrecision:0,updateInputColor:true},color:{mode:"h",active:new c({ahex:"#ffcc00ff"}),quickList:[new c({h:360,s:33,v:100}),new c({h:360,s:66,v:100}),new c({h:360,s:100,v:100}),
new c({h:360,s:100,v:75}),new c({h:360,s:100,v:50}),new c({h:180,s:0,v:100}),new c({h:30,s:33,v:100}),new c({h:30,s:66,v:100}),new c({h:30,s:100,v:100}),new c({h:30,s:100,v:75}),new c({h:30,s:100,v:50}),new c({h:180,s:0,v:90}),new c({h:60,s:33,v:100}),new c({h:60,s:66,v:100}),new c({h:60,s:100,v:100}),new c({h:60,s:100,v:75}),new c({h:60,s:100,v:50}),new c({h:180,s:0,v:80}),new c({h:90,s:33,v:100}),new c({h:90,s:66,v:100}),new c({h:90,s:100,v:100}),new c({h:90,s:100,v:75}),new c({h:90,s:100,v:50}),
new c({h:180,s:0,v:70}),new c({h:120,s:33,v:100}),new c({h:120,s:66,v:100}),new c({h:120,s:100,v:100}),new c({h:120,s:100,v:75}),new c({h:120,s:100,v:50}),new c({h:180,s:0,v:60}),new c({h:150,s:33,v:100}),new c({h:150,s:66,v:100}),new c({h:150,s:100,v:100}),new c({h:150,s:100,v:75}),new c({h:150,s:100,v:50}),new c({h:180,s:0,v:50}),new c({h:180,s:33,v:100}),new c({h:180,s:66,v:100}),new c({h:180,s:100,v:100}),new c({h:180,s:100,v:75}),new c({h:180,s:100,v:50}),new c({h:180,s:0,v:40}),new c({h:210,
s:33,v:100}),new c({h:210,s:66,v:100}),new c({h:210,s:100,v:100}),new c({h:210,s:100,v:75}),new c({h:210,s:100,v:50}),new c({h:180,s:0,v:30}),new c({h:240,s:33,v:100}),new c({h:240,s:66,v:100}),new c({h:240,s:100,v:100}),new c({h:240,s:100,v:75}),new c({h:240,s:100,v:50}),new c({h:180,s:0,v:20}),new c({h:270,s:33,v:100}),new c({h:270,s:66,v:100}),new c({h:270,s:100,v:100}),new c({h:270,s:100,v:75}),new c({h:270,s:100,v:50}),new c({h:180,s:0,v:10}),new c({h:300,s:33,v:100}),new c({h:300,s:66,v:100}),
@ -653,16 +653,16 @@ new c({h:300,s:100,v:100}),new c({h:300,s:100,v:75}),new c({h:300,s:100,v:50}),n
newColor:"new",currentColor:"current",ok:"OK",cancel:"Cancel"},tooltips:{colors:{newColor:"New Color - Press &ldquo;OK&rdquo; To Commit",currentColor:"Click To Revert To Original Color"},buttons:{ok:"Commit To This Color Selection",cancel:"Cancel And Revert To Original Color"},hue:{radio:"Set To &ldquo;Hue&rdquo; Color Mode",textbox:"Enter A &ldquo;Hue&rdquo; Value (0-360&deg;)"},saturation:{radio:"Set To &ldquo;Saturation&rdquo; Color Mode",textbox:"Enter A &ldquo;Saturation&rdquo; Value (0-100%)"},
value:{radio:"Set To &ldquo;Value&rdquo; Color Mode",textbox:"Enter A &ldquo;Value&rdquo; Value (0-100%)"},red:{radio:"Set To &ldquo;Red&rdquo; Color Mode",textbox:"Enter A &ldquo;Red&rdquo; Value (0-255)"},green:{radio:"Set To &ldquo;Green&rdquo; Color Mode",textbox:"Enter A &ldquo;Green&rdquo; Value (0-255)"},blue:{radio:"Set To &ldquo;Blue&rdquo; Color Mode",textbox:"Enter A &ldquo;Blue&rdquo; Value (0-255)"},alpha:{radio:"Set To &ldquo;Alpha&rdquo; Color Mode",textbox:"Enter A &ldquo;Alpha&rdquo; Value (0-100)"},
hex:{textbox:"Enter A &ldquo;Hex&rdquo; Color Value (#000000-#ffffff)",alpha:"Enter A &ldquo;Alpha&rdquo; Value (#00-#ff)"}}}}})(jQuery,"1.1.6");(function(a){function p(n){var s=n||window.event,b=[].slice.call(arguments,1),f=0,d=0,l=0;n=a.event.fix(s);n.type="mousewheel";if(s.wheelDelta)f=s.wheelDelta/120;if(s.detail)f=-s.detail/3;l=f;if(s.axis!==undefined&&s.axis===s.HORIZONTAL_AXIS){l=0;d=-1*f}if(s.wheelDeltaY!==undefined)l=s.wheelDeltaY/120;if(s.wheelDeltaX!==undefined)d=-1*s.wheelDeltaX/120;b.unshift(n,f,d,l);return(a.event.dispatch||a.event.handle).apply(this,b)}var g=["DOMMouseScroll","mousewheel"];if(a.event.fixHooks)for(var c=g.length;c;)a.event.fixHooks[g[--c]]=
a.event.mouseHooks;a.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var n=g.length;n;)this.addEventListener(g[--n],p,false);else this.onmousewheel=p},teardown:function(){if(this.removeEventListener)for(var n=g.length;n;)this.removeEventListener(g[--n],p,false);else this.onmousewheel=null}};a.fn.extend({mousewheel:function(n){return n?this.bind("mousewheel",n):this.trigger("mousewheel")},unmousewheel:function(n){return this.unbind("mousewheel",n)}})})(jQuery);svgEditor.addExtension("eyedropper",function(a){function p(b){if(g.getMode()!="eyedropper"){var f=$("#tool_eyedropper");b.elems[0]&&$.inArray(b.elems[0].nodeName,["svg","g","use"])==-1?f.removeClass("disabled"):f.addClass("disabled")}}var g=svgEditor.canvas,c=svgedit.history.ChangeElementCommand,n={fillPaint:"red",fillOpacity:1,strokePaint:"black",strokeOpacity:1,strokeWidth:5,strokeDashArray:null,opacity:1,strokeLinecap:"butt",strokeLinejoin:"miter"},s=function(b,f,d){var l=null;console.log(b);if(b.indexOf("url(#")===
0){b=(b=g.getRefElem(b))?b.cloneNode(true):$("#"+d+"_color defs *")[0];l={alpha:f};l[b.tagName]=b}else l=b.indexOf("#")===0?{alpha:f,solidColor:b.substr(1)}:{alpha:f,solidColor:"none"};return new $.jGraduate.Paint(l)};return{name:"eyedropper",svgicons:"extensions/eyedropper-icon.xml",buttons:[{id:"tool_eyedropper",type:"mode",title:"Eye Dropper Tool",key:"I","class":"disabled",events:{click:function(){g.setMode("eyedropper")}}}],selectedChanged:p,elementChanged:p,mouseDown:function(b){var f=g.getMode(),
d=b.event;d=d.target.id==="svgroot"?document.getElementById("canvas_background"):d.target;if(f=="eyedropper"&&d){n.fillPaint=d.getAttribute("fill")||"white";n.fillOpacity=d.getAttribute("fill-opacity")||1;n.strokePaint=d.getAttribute("stroke")||"none";n.strokeOpacity=d.getAttribute("stroke-opacity")||1;n.strokeWidth=d.getAttribute("stroke-width");n.strokeDashArray=d.getAttribute("stroke-dasharray");n.strokeLinecap=d.getAttribute("stroke-linecap");n.strokeLinejoin=d.getAttribute("stroke-linejoin");
n.opacity=d.getAttribute("opacity")||1;if($.inArray(b.selectedElements.nodeName,["g","use"])==-1){var l={},q=function(o,K,T){l[K]=o.getAttribute(K);o.setAttribute(K,T)},B=new a.BatchCommand;b.selectedElements.forEach(function(o){n.fillPaint&&q(o,"fill",n.fillPaint);n.fillOpacity&&q(o,"fill-opacity",n.fillOpacity);n.strokePaint&&q(o,"stroke",n.strokePaint);n.strokeOpacity&&q(o,"stroke-opacity",n.strokeOpacity);n.strokeWidth&&q(o,"stroke-width",n.strokeWidth);n.strokeDashArray&&q(o,"stroke-dasharray",
n.strokeDashArray);n.opacity&&q(o,"opacity",n.opacity);n.strokeLinecap&&q(o,"stroke-linecap",n.strokeLinecap);n.strokeLinejoin&&q(o,"stroke-linejoin",n.strokeLinejoin);B.addSubCommand(new c(o,l));console.log(l);l={}});s(n.fillPaint,n.fillOpacity*100,"fill");s(n.strokePaint,n.strokeOpacity*100,"stroke");svgEditor.paintBox.fill.update(true);svgEditor.paintBox.stroke.update(true);g.undoMgr.addCommandToHistory(B)}}}}});svgEditor.addExtension("view_grid",function(a){function p(d){b.attr("width");b.attr("height");var l=svgedit.units.getTypeMap()[svgEditor.curConfig.baseUnit],q=[0.01,0.1,1,10,100,1E3];svgCanvas.getContentElem().getAttribute("x");var B=n;l=l*d;var o=100/l,K=1;for(d=0;d<q.length;d++){var T=q[d];K=T;if(o<=T)break}q=K*l;B.width=q;B.height=q;l=B.getContext("2d");o=q/10;l.globalAlpha=0.2;l.strokeStyle="#000";for(d=1;d<10;d++){K=Math.round(o*d)+0.5;l.moveTo(K,q);l.lineTo(K,0);l.moveTo(q,K);l.lineTo(0,K)}l.stroke();
a.event.mouseHooks;a.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var n=g.length;n;)this.addEventListener(g[--n],p,false);else this.onmousewheel=p},teardown:function(){if(this.removeEventListener)for(var n=g.length;n;)this.removeEventListener(g[--n],p,false);else this.onmousewheel=null}};a.fn.extend({mousewheel:function(n){return n?this.bind("mousewheel",n):this.trigger("mousewheel")},unmousewheel:function(n){return this.unbind("mousewheel",n)}})})(jQuery);svgEditor.addExtension("eyedropper",function(a){function p(b){if(g.getMode()!="eyedropper"){var f=$("#tool_eyedropper");b.elems[0]&&$.inArray(b.elems[0].nodeName,["svg","g","use"])==-1?f.removeClass("disabled"):f.addClass("disabled")}}var g=svgEditor.canvas,c=svgedit.history.ChangeElementCommand,n={fillPaint:"red",fillOpacity:1,strokePaint:"black",strokeOpacity:1,strokeWidth:5,strokeDashArray:null,opacity:1,strokeLinecap:"butt",strokeLinejoin:"miter"},s=function(b,f,d){var l=null;if(b.indexOf("url(#")===
0){b=(b=g.getRefElem(b))?b.cloneNode(true):$("#"+d+"_color defs *")[0];l={alpha:f};l[b.tagName]=b}else l=b.indexOf("#")===0?{alpha:f,solidColor:b.substr(1)}:{alpha:f,solidColor:"none"};return new $.jGraduate.Paint(l)};return{name:"eyedropper",svgicons:"extensions/eyedropper-icon.xml",buttons:[{id:"tool_eyedropper",type:"mode",title:"Eye Dropper Tool",key:"I","class":"disabled",icon:"extensions/eyedropper.png",events:{click:function(){g.setMode("eyedropper")}}}],selectedChanged:p,elementChanged:p,
mouseDown:function(b){var f=g.getMode(),d=b.event;d=d.target.id==="svgroot"?document.getElementById("canvas_background"):d.target;if(f=="eyedropper"&&d){n.fillPaint=d.getAttribute("fill")||"white";n.fillOpacity=d.getAttribute("fill-opacity")||1;n.strokePaint=d.getAttribute("stroke")||"none";n.strokeOpacity=d.getAttribute("stroke-opacity")||1;n.strokeWidth=d.getAttribute("stroke-width");n.strokeDashArray=d.getAttribute("stroke-dasharray");n.strokeLinecap=d.getAttribute("stroke-linecap");n.strokeLinejoin=
d.getAttribute("stroke-linejoin");n.opacity=d.getAttribute("opacity")||1;if($.inArray(b.selectedElements.nodeName,["g","use"])==-1){var l={},q=function(o,K,T){l[K]=o.getAttribute(K);o.setAttribute(K,T)},B=new a.BatchCommand;b.selectedElements.forEach(function(o){n.fillPaint&&q(o,"fill",n.fillPaint);n.fillOpacity&&q(o,"fill-opacity",n.fillOpacity);n.strokePaint&&q(o,"stroke",n.strokePaint);n.strokeOpacity&&q(o,"stroke-opacity",n.strokeOpacity);n.strokeWidth&&q(o,"stroke-width",n.strokeWidth);n.strokeDashArray&&
q(o,"stroke-dasharray",n.strokeDashArray);n.opacity&&q(o,"opacity",n.opacity);n.strokeLinecap&&q(o,"stroke-linecap",n.strokeLinecap);n.strokeLinejoin&&q(o,"stroke-linejoin",n.strokeLinejoin);B.addSubCommand(new c(o,l));l={}});s(n.fillPaint,n.fillOpacity*100,"fill");s(n.strokePaint,n.strokeOpacity*100,"stroke");svgEditor.paintBox.fill.update(true);svgEditor.paintBox.stroke.update(true);g.undoMgr.addCommandToHistory(B)}}}}});svgEditor.addExtension("view_grid",function(a){function p(d){b.attr("width");b.attr("height");var l=svgedit.units.getTypeMap()[svgEditor.curConfig.baseUnit],q=[0.01,0.1,1,10,100,1E3];svgCanvas.getContentElem().getAttribute("x");var B=n;l=l*d;var o=100/l,K=1;for(d=0;d<q.length;d++){var T=q[d];K=T;if(o<=T)break}q=K*l;B.width=q;B.height=q;l=B.getContext("2d");o=q/10;l.globalAlpha=0.2;l.strokeStyle="#000";for(d=1;d<10;d++){K=Math.round(o*d)+0.5;l.moveTo(K,q);l.lineTo(K,0);l.moveTo(q,K);l.lineTo(0,K)}l.stroke();
l.beginPath();l.globalAlpha=0.5;l.moveTo(0.5,q);l.lineTo(0.5,0);l.moveTo(q,0.5);l.lineTo(0,0.5);l.stroke();B=B.toDataURL("image/png");f.setAttribute("width",q);f.setAttribute("height",q);f.parentNode.setAttribute("width",q);f.parentNode.setAttribute("height",q);svgCanvas.setHref(f,B)}if(!document.getElementById("canvasGrid")){var g=document.getElementById("svgcanvas").ownerDocument,c=false;a=a.assignAttributes;var n=document.createElement("canvas");$(n).hide().appendTo("body");var s=g.createElementNS("http://www.w3.org/2000/svg",
"g");a(s,{id:"canvasGrid",width:"100%",height:"100%",x:0,y:0,overflow:"visible",display:"none"});var b=$("#canvas_background");b.after(s);s=g.createElementNS("http://www.w3.org/2000/svg","pattern");a(s,{id:"gridpattern",patternUnits:"userSpaceOnUse",x:0,y:0,width:100,height:100});var f=g.createElementNS("http://www.w3.org/2000/svg","image");a(f,{x:0,y:0,width:100,height:100});s.appendChild(f);$("#svgroot defs").append(s);g=g.createElementNS("http://www.w3.org/2000/svg","rect");a(g,{width:"100%",height:"100%",
x:0,y:0,"stroke-width":0,stroke:"none",fill:"url(#gridpattern)",style:"pointer-events: none; display:visible;"});$("#canvasGrid").append(g)}return{name:"view_grid",zoomChanged:function(d){c&&p(d)},buttons:[{id:"view_grid",type:"menu",after:"tool_wireframe",panel:"view_menu",title:"View Grid",events:{click:function(){if($("#view_grid").hasClass("push_button_pressed")){svgEditor.curConfig.showGrid=c=false;$("#view_grid").removeClass("push_button_pressed");$("#canvasGrid").attr("display","none")}else{svgEditor.curConfig.showGrid=
c=true;$("#view_grid").addClass("push_button_pressed");$("#canvasGrid").attr("display","normal");p(svgCanvas.getZoom())}}}}]}});svgEditor.addExtension("shapes",function(){function a(){$("#shape_buttons").empty();$("#shape_buttons").append(K.buttons)}function p(M){var J=o[M];if(J){K=J;J.buttons.length||g(M,J);a()}else{$("#shape_buttons").html("Loading...");$.getJSON("extensions/shapelib/"+M+".json",function(Q){K=o[M]={data:Q.data,size:Q.size,fill:Q.fill};g(M,Q);a()})}}function g(M,J){var Q=K.size||300,Y=K.fill||false,O=Q*0.05;O=[-O,-O,Q+O*2,Q+O*2].join(" ");Q=Y?0:Q/30;Q=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><svg viewBox="'+
O+'"><path fill="#333" stroke="transparent" stroke-width="'+Q+'" /></svg></svg>',"text/xml");Q.documentElement.setAttribute("width",40);Q.documentElement.setAttribute("height",40);Y=$(document.importNode(Q.documentElement,true));var ia=J.data;K.buttons=[];for(var pa in ia){var fa=ia[pa],ba=Y.clone();if(fa.charAt(fa.length-1)=="x"){Q=32;O=Q*0.05;O=[-O,-O,Q+O*2,Q+O*2].join(" ");ba.find("svg").attr("viewBox",O);fa.replace("x","")}ba.find("path").attr("d",fa);Q=ba.wrap('<div class="tool_button">').parent().attr({id:T+
c=true;$("#view_grid").addClass("push_button_pressed");$("#canvasGrid").attr("display","normal");p(svgCanvas.getZoom())}}}}]}});svgEditor.addExtension("shapes",function(){function a(){$("#shape_buttons").empty();$("#shape_buttons").append(K.buttons)}function p(M){var J=o[M];if(J){K=J;J.buttons.length||g(M,J);a()}else{$("#shape_buttons").html("Loading...");$.getJSON("extensions/shapelib/"+M+".json",function(Q){K=o[M]={data:Q.data,size:Q.size,fill:Q.fill};g(M,Q);a()})}}function g(M,J){var Q=K.size||300,X=K.fill||false,O=Q*0.05;O=[-O,-O,Q+O*2,Q+O*2].join(" ");Q=X?0:Q/30;Q=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><svg viewBox="'+
O+'"><path fill="#333" stroke="transparent" stroke-width="'+Q+'" /></svg></svg>',"text/xml");Q.documentElement.setAttribute("width",40);Q.documentElement.setAttribute("height",40);X=$(document.importNode(Q.documentElement,true));var ia=J.data;K.buttons=[];for(var pa in ia){var fa=ia[pa],ba=X.clone();if(fa.charAt(fa.length-1)=="x"){Q=32;O=Q*0.05;O=[-O,-O,Q+O*2,Q+O*2].join(" ");ba.find("svg").attr("viewBox",O);fa.replace("x","")}ba.find("path").attr("d",fa);Q=ba.wrap('<div class="tool_button">').parent().attr({id:T+
"_"+pa,title:pa});K.buttons.push(Q[0])}}var c,n,s=svgEditor.canvas,b,f,d,l=s.getRootElem(),q={},B={basic:"Basic",object:"Objects",symbol:"Symbols",arrow:"Arrows",flowchart:"Flowchart",nature:"Nature",game:"Cards & Chess",dialog_balloon:"Dialog balloons",music:"Music",weather:"Weather &amp; Time",ui:"User Interface",social:"Social Web"},o={basic:{data:{star_points_5:"m1,116.58409l113.82668,0l35.17332,-108.13487l35.17334,108.13487l113.82666,0l-92.08755,66.83026l35.17514,108.13487l-92.08759,-66.83208l-92.08757,66.83208l35.17515,-108.13487l-92.08758,-66.83026z",
donut:"m1,150l0,0c0,-82.29042 66.70958,-149 149,-149l0,0c39.51724,0 77.41599,15.69816 105.35889,43.64108c27.94293,27.94293 43.64111,65.84165 43.64111,105.35892l0,0c0,82.29041 -66.70958,149 -149,149l0,0c-82.29041,0 -149,-66.70959 -149,-149zm74.5,0l0,0c0,41.1452 33.35481,74.5 74.5,74.5c41.14522,0 74.5,-33.3548 74.5,-74.5c0,-41.1452 -33.3548,-74.5 -74.5,-74.5l0,0c-41.14519,0 -74.5,33.35481 -74.5,74.5z",triangle:"m1,280.375l149,-260.75l149,260.75z",right_triangle:"m1,299l0,-298l298,298z",diamond:"m1,150l149,-149l149,149l-149,149l-149,-149z",
pentagon:"m1.00035,116.97758l148.99963,-108.4053l148.99998,108.4053l-56.91267,175.4042l-184.1741,0l-56.91284,-175.4042z",hexagon:"m1,149.99944l63.85715,-127.71428l170.28572,0l63.85713,127.71428l-63.85713,127.71428l-170.28572,0l-63.85715,-127.71428z",septagon1:"m0.99917,191.06511l29.51249,-127.7108l119.48833,-56.83673l119.48836,56.83673l29.51303,127.7108l-82.69087,102.41679l-132.62103,0l-82.69031,-102.41679z",heptagon:"m1,88.28171l87.28172,-87.28171l123.43653,0l87.28172,87.28171l0,123.43654l-87.28172,87.28172l-123.43653,0l-87.28172,-87.28172l0,-123.43654z",
@ -671,12 +671,12 @@ heart:"m150,73c61,-175 300,0 0,225c-300,-225 -61,-400 0,-225z",cylinder:"m299.00
arrow_u_turn:"m1.00059,299.00055l0,-167.62497l0,0c0,-72.00411 58.37087,-130.37499 130.375,-130.37499l0,0l0,0c34.57759,0 67.73898,13.7359 92.18906,38.18595c24.45006,24.45005 38.18593,57.61144 38.18593,92.18904l0,18.625l37.24997,0l-74.49995,74.50002l-74.50002,-74.50002l37.25,0l0,-18.625c0,-30.8589 -25.0161,-55.87498 -55.87498,-55.87498l0,0l0,0c-30.85892,0 -55.875,25.01608 -55.875,55.87498l0,167.62497z",arrow_left_up:"m0.99865,224.5l74.50004,-74.5l0,37.25l111.74991,0l0,-111.75l-37.25,0l74.5,-74.5l74.5,74.5l-37.25,0l0,186.25l-186.24989,0l0,37.25l-74.50005,-74.5z",
plaque:"m-0.00197,49.94376l0,0c27.5829,0 49.94327,-22.36036 49.94327,-49.94327l199.76709,0l0,0c0,27.5829 22.36037,49.94327 49.94325,49.94327l0,199.7671l0,0c-27.58289,0 -49.94325,22.36034 -49.94325,49.94325l-199.76709,0c0,-27.58292 -22.36037,-49.94325 -49.94327,-49.94325z",page:"m249.3298,298.99744l9.9335,-39.73413l39.73413,-9.93355l-49.66763,49.66768l-248.33237,0l0,-298.00001l298.00001,0l0,248.33234",cross:"m0.99844,99.71339l98.71494,0l0,-98.71495l101.26279,0l0,98.71495l98.71495,0l0,101.2628l-98.71495,0l0,98.71494l-101.26279,0l0,-98.71494l-98.71494,0z",
divide:"m150,0.99785l0,0c25.17819,0 45.58916,20.41097 45.58916,45.58916c0,25.17821 -20.41096,45.58916 -45.58916,45.58916c-25.17822,0 -45.58916,-20.41093 -45.58916,-45.58916c0,-25.1782 20.41093,-45.58916 45.58916,-45.58916zm0,296.25203c-25.17822,0 -45.58916,-20.41095 -45.58916,-45.58917c0,-25.17819 20.41093,-45.58916 45.58916,-45.58916c25.17819,0 45.58916,20.41096 45.58916,45.58916c0,25.17822 -20.41096,45.58917 -45.58916,45.58917zm-134.06754,-193.71518l268.13507,0l0,91.17833l-268.13507,0z",minus:"m0.99887,102.39503l297.49445,0l0,95.2112l-297.49445,0z",
times:"m1.00089,73.36786l72.36697,-72.36697l76.87431,76.87368l76.87431,-76.87368l72.36765,72.36697l-76.87433,76.87431l76.87433,76.87431l-72.36765,72.36765l-76.87431,-76.87433l-76.87431,76.87433l-72.36697,-72.36765l76.87368,-76.87431l-76.87368,-76.87431z"},buttons:[]}},K=o.basic,T="shapelib";return{svgicons:"extensions/ext-shapes.xml",buttons:[{id:"tool_shapelib",type:"mode_flyout",position:6,title:"Shape library",fallback:"extensions/ext-shapes.png",events:{click:function(){s.setMode(T)}}}],callback:function(){var M=
$('<div id="shape_buttons">');$("#tools_shapelib > *").wrapAll(M);var J=$("#tools_shapelib_show");p("basic");$("#shape_buttons").mouseup(function(Y){Y=$(Y.target).closest("div.tool_button");if(Y.length){var O=Y.children().clone().attr({width:24,height:24});J.children(":not(.flyout_arrow_horiz)").remove();J.append(O).attr("data-curopt","#"+Y[0].id).mouseup();s.setMode(T);n=Y[0].id.substr((T+"_").length);c=K.data[n];$(".tools_flyout").fadeOut()}});M=$('<div id="shape_cats">');var Q="";$.each(B,function(Y,
O){Q+="<div data-cat="+Y+">"+O+"</div>"});M.html(Q).children().bind("mouseup",function(){var Y=$(this);Y.siblings().removeClass("current");Y.addClass("current");p(Y.attr("data-cat"));return false});M.children().eq(0).addClass("current");$("#tools_shapelib").prepend(M);J.mouseup(function(){s.setMode(c?T:"select")});$("#tool_shapelib").remove();M=$("#tools_shapelib").height();$("#tools_shapelib").css({"margin-top":-(M/2),"margin-left":3})},mouseDown:function(M){if(s.getMode()===T){var J=f=M.start_x;
times:"m1.00089,73.36786l72.36697,-72.36697l76.87431,76.87368l76.87431,-76.87368l72.36765,72.36697l-76.87433,76.87431l76.87433,76.87431l-72.36765,72.36765l-76.87431,-76.87433l-76.87431,76.87433l-72.36697,-72.36765l76.87368,-76.87431l-76.87368,-76.87431z"},buttons:[]}},K=o.basic,T="shapelib";return{svgicons:"extensions/ext-shapes.xml",buttons:[{id:"tool_shapelib",type:"mode_flyout",position:6,title:"Shape library",icon:"extensions/ext-shapes.png",events:{click:function(){s.setMode(T)}}}],callback:function(){var M=
$('<div id="shape_buttons">');$("#tools_shapelib > *").wrapAll(M);var J=$("#tools_shapelib_show");p("basic");$("#shape_buttons").mouseup(function(X){X=$(X.target).closest("div.tool_button");if(X.length){var O=X.children().clone().attr({width:24,height:24});J.children(":not(.flyout_arrow_horiz)").remove();J.append(O).attr("data-curopt","#"+X[0].id).mouseup();s.setMode(T);n=X[0].id.substr((T+"_").length);c=K.data[n];$(".tools_flyout").fadeOut()}});M=$('<div id="shape_cats">');var Q="";$.each(B,function(X,
O){Q+="<div data-cat="+X+">"+O+"</div>"});M.html(Q).children().bind("mouseup",function(){var X=$(this);X.siblings().removeClass("current");X.addClass("current");p(X.attr("data-cat"));return false});M.children().eq(0).addClass("current");$("#tools_shapelib").prepend(M);J.mouseup(function(){s.setMode(c?T:"select")});$("#tool_shapelib").remove();M=$("#tools_shapelib").height();$("#tools_shapelib").css({"margin-top":-(M/2),"margin-left":3})},mouseDown:function(M){if(s.getMode()===T){var J=f=M.start_x;
M=d=M.start_y;var Q=s.getStyle();b=s.addSvgElementFromJson({element:"path",curStyles:true,attr:{d:c,id:s.getNextId(),opacity:Q.opacity/2,style:"pointer-events:none"}});b.setAttribute("d",c);if(/[a-z]/.test(c)){c=K.data[n]=s.pathActions.convertPath(b);b.setAttribute("d",c);s.pathActions.fixEnd(b)}b.setAttribute("transform","translate("+J+","+M+") scale(0.005) translate("+-J+","+-M+")");s.recalculateDimensions(b);s.getTransformList(b);q=b.getBBox();totalScale={sx:1,sy:1};return{started:true}}},mouseMove:function(M){if(s.getMode()===
T){var J=s.getZoom(),Q=M.event,Y=M.mouse_x/J,O=M.mouse_y/J;M=s.getTransformList(b);var ia=b.getBBox();J=ia.x;var pa=ia.y,fa=ia.width,ba=ia.height,W=Y-f,sa=O-d,ka={x:Math.min(f,Y),y:Math.min(d,O),width:Math.abs(Y-f),height:Math.abs(O-d)},da=ia=0;ba=ba?(ba+sa)/ba:1;fa=fa?(fa+W)/fa:1;fa=ka.width/q.width;ba=ka.height/q.height;fa=fa||1;ba=ba||1;if(Y<f)ia=q.width;if(O<d)da=q.height;Y=l.createSVGTransform();O=l.createSVGTransform();ka=l.createSVGTransform();Y.setTranslate(-(J+ia),-(pa+da));if(Q.shiftKey){replaced=
true;Q=Math.min(Math.abs(fa),Math.abs(ba));fa=Q*(fa<0?-1:1);ba=Q*(ba<0?-1:1);if(totalScale.sx!=totalScale.sy){Q=totalScale.sx>totalScale.sy?1:totalScale.sx/totalScale.sy;fa*=totalScale.sy>totalScale.sx?1:totalScale.sy/totalScale.sx;ba*=Q}}totalScale.sx*=fa;totalScale.sy*=ba;O.setScale(fa,ba);ka.setTranslate(J+ia,pa+da);M.appendItem(ka);M.appendItem(O);M.appendItem(Y);s.recalculateDimensions(b);q=b.getBBox()}},mouseUp:function(M){if(s.getMode()===T){if(M.mouse_x==f&&M.mouse_y==d)return{keep:false,
T){var J=s.getZoom(),Q=M.event,X=M.mouse_x/J,O=M.mouse_y/J;M=s.getTransformList(b);var ia=b.getBBox();J=ia.x;var pa=ia.y,fa=ia.width,ba=ia.height,W=X-f,sa=O-d,ka={x:Math.min(f,X),y:Math.min(d,O),width:Math.abs(X-f),height:Math.abs(O-d)},da=ia=0;ba=ba?(ba+sa)/ba:1;fa=fa?(fa+W)/fa:1;fa=ka.width/q.width;ba=ka.height/q.height;fa=fa||1;ba=ba||1;if(X<f)ia=q.width;if(O<d)da=q.height;X=l.createSVGTransform();O=l.createSVGTransform();ka=l.createSVGTransform();X.setTranslate(-(J+ia),-(pa+da));if(Q.shiftKey){replaced=
true;Q=Math.min(Math.abs(fa),Math.abs(ba));fa=Q*(fa<0?-1:1);ba=Q*(ba<0?-1:1);if(totalScale.sx!=totalScale.sy){Q=totalScale.sx>totalScale.sy?1:totalScale.sx/totalScale.sy;fa*=totalScale.sy>totalScale.sx?1:totalScale.sy/totalScale.sx;ba*=Q}}totalScale.sx*=fa;totalScale.sy*=ba;O.setScale(fa,ba);ka.setTranslate(J+ia,pa+da);M.appendItem(ka);M.appendItem(O);M.appendItem(X);s.recalculateDimensions(b);q=b.getBBox()}},mouseUp:function(M){if(s.getMode()===T){if(M.mouse_x==f&&M.mouse_y==d)return{keep:false,
element:b,started:false};s.setMode("select");return{keep:true,element:b,started:false}}}}});(function(){for(var a=0,p=["ms","moz","webkit","o"],g=0;g<p.length&&!window.requestAnimationFrame;++g){window.requestAnimationFrame=window[p[g]+"RequestAnimationFrame"];window.cancelAnimationFrame=window[p[g]+"CancelAnimationFrame"]||window[p[g]+"CancelRequestAnimationFrame"]}if(!window.requestAnimationFrame)window.requestAnimationFrame=function(c){var n=(new Date).getTime(),s=Math.max(0,16-(n-a)),b=window.setTimeout(function(){c(n+s)},s);a=n+s;return b};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=
function(c){clearTimeout(c)}})();(function(a){function p(o){var K=o.originalEvent;if(!K.touches||K.targetTouches.length===1&&K.touches.length===1){b.call(this,o);o=a(this);o.bind(q,g);o.bind(l,c)}else{clearTimeout(B);s.call(this)}}function g(o){if(B!=null){var K=o.originalEvent;o=K.changedTouches?K.changedTouches[0].pageX:K.pageX;K=K.changedTouches?K.changedTouches[0].pageY:K.pageY;var T=a(this).data("taphold.point");o=o-T.x;K=K-T.y;if(Math.sqrt(o*o+K*K)>d){clearTimeout(B);s.call(this)}}}function c(){clearTimeout(B);s.call(this)}
function n(o){s.call(this);a(this).data("taphold.handler").call(this,o)}function s(){B=null;a(this).unbind(q,g);a(this).unbind(l,c)}function b(o){if(B==null){var K=this;B=setTimeout(function(){n.call(K,o)},f);var T=o.originalEvent,M={};M.x=T.changedTouches?T.changedTouches[0].pageX:T.pageX;M.y=T.changedTouches?T.changedTouches[0].pageY:T.pageY;a(this).data("taphold.point",M)}}var f=1E3,d=5,l="touchend",q="touchmove",B=null;a.event.special.taphold={setup:function(){},add:function(o){a(this).data("taphold.handler",

BIN
method-draw/.DS_Store vendored

Binary file not shown.

View File

@ -51,7 +51,6 @@ svgEditor.addExtension("eyedropper", function(S) {
var getPaint = function(color, opac, type) {
// update the editor's fill paint
var opts = null;
console.log(color);
if (color.indexOf("url(#") === 0) {
var refElem = svgCanvas.getRefElem(color);
if(refElem) {
@ -87,6 +86,7 @@ svgEditor.addExtension("eyedropper", function(S) {
title: "Eye Dropper Tool",
key: "I",
"class": "disabled",
icon: "extensions/eyedropper.png",
events: {
"click": function() {
svgCanvas.setMode("eyedropper");
@ -130,7 +130,6 @@ svgEditor.addExtension("eyedropper", function(S) {
if (currentStyle.strokeLinecap) change(element, "stroke-linecap", currentStyle.strokeLinecap);
if (currentStyle.strokeLinejoin) change(element, "stroke-linejoin", currentStyle.strokeLinejoin);
batchCmd.addSubCommand(new ChangeElementCommand(element, changes));
console.log(changes);
changes = {};
});
var fill = getPaint(currentStyle.fillPaint, currentStyle.fillOpacity*100, "fill")

View File

@ -155,7 +155,7 @@ svgEditor.addExtension("shapes", function() {
type: "mode_flyout", // _flyout
position: 6,
title: "Shape library",
fallback: "extensions/ext-shapes.png",
icon: "extensions/ext-shapes.png",
events: {
"click": function() {
canv.setMode(mode_id);

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 B

After

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 B

After

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 243 B

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

View File

@ -52,6 +52,7 @@
<script type="text/javascript" src="extensions/ext-shapes.js"></script>
<script type="text/javascript" src="requestanimationframe.js"></script>
<script type="text/javascript" src="taphold.js"></script>
<script type="text/javascript" src="extensions/ext-server_opensave.js"></script>
<!{endif}-->
<!-- you can load extensions here -->
@ -101,6 +102,8 @@ $(function(){
<div class="menu_title" id="logo"></div>
<div class="menu_list">
<div id="tool_about" class="menu_item">About this Editor...</div>
<div class="separator"></div>
<div id="tool_about" class="menu_item">Keyboard Shortcus...</div>
</div>
</a>
@ -108,8 +111,8 @@ $(function(){
<div class="menu_title">File</div>
<div class="menu_list" id="file_menu">
<div id="tool_clear" class="menu_item">New Image</div>
<div id="tool_open" class="menu_item"><div id="fileinputs"></div>Place Image...</div>
<div id="tool_import" class="menu_item"><div id="fileinputs_import"></div>Import SVG...</div>
<div id="tool_open" class="menu_item"><div id="fileinputs"></div>Open SVG...</div>
<div id="tool_import" class="menu_item"><div id="fileinputs_import"></div>Place SVG...</div>
<div id="tool_save" class="menu_item">Save Image... <span class="shortcut">⌘S</span></div>
<div id="tool_export" class="menu_item">Export as PNG</div>
</div>

View File

@ -240,11 +240,11 @@
'spapelib':'shapelib.png',
'node_delete':'node_delete.png',
'align_left':'align-left.png',
'align_center':'align-center',
'align_right':'align-right',
'align_top':'align-top',
'align_middle':'align-middle',
'align_bottom':'align-bottom',
'align_center':'align-center.png',
'align_right':'align-right.png',
'align_top':'align-top.png',
'align_middle':'align-middle.png',
'align_bottom':'align-bottom.png',
'arrow_right':'flyouth.png',
'arrow_down':'dropdown.gif'
},
@ -1005,17 +1005,16 @@
var icon;
var id = btn.id;
var num = i;
// Give button a unique ID
while($('#'+id).length) {
id = btn.id + '_' + (++num);
}
if(!svgicons) {
icon = (btn.type == "menu") ? "" : $('<img src="' + btn.icon + '">');
} else {
fallback_obj[id] = btn.icon;
var svgicon = btn.svgicon ? btn.svgicon : btn.id;
console.log(svgicon);
if(btn.type == 'app_menu') {
placement_obj['#' + id + ' > div'] = svgicon;
} else {
@ -1391,6 +1390,7 @@
//hack to show the proper multialign box
if (multiselected) {
multiselected = multiselected.filter(Boolean)
elem = (svgCanvas.elementsAreSame(multiselected)) ? multiselected[0] : null
if (elem) $("#tools_top").addClass("multiselected")
}
@ -1534,20 +1534,14 @@
});
if(el_name == 'text') {
var font_family = elem.getAttribute("font-family");
var select = document.getElementById("font_family_dropdown");
select.selectedIndex = 3
$('#text_panel').css("display", "inline");
if (svgCanvas.getItalic()) {
$('#tool_italic').addClass('push_button_pressed').removeClass('tool_button');
}
else {
$('#tool_italic').removeClass('push_button_pressed').addClass('tool_button');
}
if (svgCanvas.getBold()) {
$('#tool_bold').addClass('push_button_pressed').removeClass('tool_button');
}
else {
$('#tool_bold').removeClass('push_button_pressed').addClass('tool_button');
}
$('#font_family').val(elem.getAttribute("font-family"));
$('#tool_italic').toggleClass('active', svgCanvas.getItalic())
$('#tool_bold').toggleClass('active', svgCanvas.getBold())
$('#font_family').val(font_family);
$('#font_size').val(elem.getAttribute("font-size"));
$('#text').val(elem.textContent);
if (svgCanvas.addedNew) {
@ -1889,17 +1883,12 @@
top.exports.setEditorFocus();
}
}
if (e.target.nodeName.toLowerCase() === "input") return false;
if (!$(e.target).hasClass("menu_title") && !$(e.target).parent().hasClass("menu_title")) {
if(!$(e.target).hasClass("disabled") && $(e.target).hasClass("menu_item")) {
blinker(e);
return;
}
else {
$('#menu_bar').removeClass('active')
}
if(!$(e.target).hasClass("disabled") && $(e.target).hasClass("menu_item")) blinker(e)
else $('#menu_bar').removeClass('active')
}
}

View File

@ -2216,13 +2216,8 @@ var addToSelection = this.addToSelection = function(elemsToAdd, showGrips) {
}
}
call("selected", selectedElements);
if (showGrips || selectedElements.length == 1) {
selectorManager.requestSelector(selectedElements[0]).showGrips(true);
}
else {
selectorManager.requestSelector(selectedElements[0]).showGrips(false);
}
if (showGrips || selectedElements.length == 1) selectorManager.requestSelector(selectedElements[0]).showGrips(true)
else selectorManager.requestSelector(selectedElements[0]).showGrips(false);
// make sure the elements are in the correct order
// See: http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-compareDocumentPosition
@ -2801,16 +2796,17 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
// alt drag = create a clone and save the reference
if(evt.altKey) {
//clone doesn't exist yet
if (!canvas.addClone) {
canvas.addClone = canvas.cloneSelectedElements(0,0, xform);
canvas.removeClone = function(){
parent = canvas.addClone.parentNode
if (parent) {
parent.removeChild(canvas.addClone)
canvas.addClone = false;
if (!canvas.addClones) {
canvas.addClones = canvas.cloneSelectedElements(0,0, xform);
canvas.removeClones = function(){
if (canvas.addClones) {
canvas.addClones.forEach(function(clone){
if (clone.parentNode) clone.parentNode.removeChild(clone)
canvas.addClones = false;
})
}
}
window.addEventListener("keyup", canvas.removeClone)
window.addEventListener("keyup", canvas.removeClones)
}
}
@ -3209,8 +3205,8 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
// this is done in when we recalculate the selected dimensions()
var mouseUp = function(evt)
{
canvas.addClone = false;
window.removeEventListener("keyup", canvas.removeClone)
canvas.addClones = false;
window.removeEventListener("keyup", canvas.removeClones)
if(evt.button === 2) return;
var tempJustSelected = justSelected;
@ -3887,9 +3883,11 @@ var textActions = canvas.textActions = function() {
},
setCursor: setCursor,
toEditMode: function(x, y) {
selectOnly([curtext], false)
allow_dbl = false;
current_mode = "textedit";
selectorManager.requestSelector(curtext).showGrips(false);
//selectorManager.requestSelector(curtext).showGrips(false);
// Make selector group accept clicks
var sel = selectorManager.requestSelector(curtext).selectorRect;
@ -8582,21 +8580,28 @@ this.cloneSelectedElements = function(x,y, drag) {
// note that we loop in the reverse way because of the way elements are added
// to the selectedElements array (top-first)
var i = copiedElements.length;
clones = []
while (i--) {
// clone each element and replace it within copiedElements
var elem = copiedElements[i]
var clone = copyElem(copiedElements[i]);
if (drag) clone.setAttribute("transform", "");
if (drag) {
//removed the dragged transform until that moment
tlist = getTransformList(clone)
tlist.removeItem(drag)
recalculateDimensions(clone)
}
(current_group || getCurrentDrawing().getCurrentLayer()).appendChild(clone);
clones.push(clone)
batchCmd.addSubCommand(new InsertElementCommand(clone));
}
if (!batchCmd.isEmpty()) {
addToSelection(copiedElements.reverse()); // Need to reverse for correct selection-adding
this.moveSelectedElements(x,y,false);
if (!drag) this.moveSelectedElements(x,y,false);
addCommandToHistory(batchCmd);
}
return clone
return clones
};
// Function: alignSelectedElements

View File

@ -1,18 +1,18 @@
function touchHandler(a){var p=a.changedTouches,g=p[0],c="";switch(a.type){case "touchstart":c="mousedown";break;case "touchmove":c="mousemove";break;case "touchend":c="mouseup";break;default:return}var n=document.createEvent("MouseEvent");n.initMouseEvent(c,true,true,window,1,g.screenX,g.screenY,g.clientX,g.clientY,false,false,false,false,0,null);if(p.length<2){g.target.dispatchEvent(n);a.preventDefault()}};(function(a){function p(g){if(typeof g.data==="string"){var c=g.handler,n=g.data.toLowerCase().split(" ");g.handler=function(s){if(!(this!==s.target&&(/textarea|select/i.test(s.target.nodeName)||s.target.type==="text"))){var b=s.type!=="keypress"&&a.hotkeys.specialKeys[s.which],f=String.fromCharCode(s.which).toLowerCase(),d="",l={};if(s.altKey&&b!=="alt")d+="alt+";if(s.ctrlKey&&b!=="ctrl")d+="ctrl+";if(s.metaKey&&!s.ctrlKey&&b!=="meta")d+="meta+";if(s.shiftKey&&b!=="shift")d+="shift+";if(b)l[d+b]=
true;else{l[d+f]=true;l[d+a.hotkeys.shiftNums[f]]=true;if(d==="shift+")l[a.hotkeys.shiftNums[f]]=true}b=0;for(f=n.length;b<f;b++)if(l[n[b]])return c.apply(this,arguments)}}}}a.hotkeys={version:"0.8",specialKeys:{8:"backspace",9:"tab",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",
106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",191:"/",224:"meta",219:"[",221:"]"},shiftNums:{"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"}};a.each(["keydown","keyup","keypress"],function(){a.event.special[this]={add:p}})})(jQuery);(function(a,p){function g(da){return typeof da==="string"}function c(da){var V=d.call(arguments,1);return function(){return da.apply(this,V.concat(d.call(arguments)))}}function n(da,V,Z,oa,qa){var ma;if(oa!==f){V=Z.match(da?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);Z=V[3]||"";if(qa===2&&g(oa))oa=oa.replace(da?W:ba,"");else{ma=o(V[2]);oa=g(oa)?o[da?ia:O](oa):oa;oa=qa===2?oa:qa===1?a.extend({},oa,ma):a.extend({},ma,oa);oa=q(oa);if(da)oa=oa.replace(sa,l)}da=V[1]+(da?"#":oa||!V[1]?"?":"")+oa+Z}else da=
V(Z!==f?Z:p[pa][fa]);return da}function s(da,V,Z){if(V===f||typeof V==="boolean"){Z=V;V=q[da?ia:O]()}else V=g(V)?V.replace(da?W:ba,""):V;return o(V,Z)}function b(da,V,Z,oa){if(!g(Z)&&typeof Z!=="object"){oa=Z;Z=V;V=f}return this.each(function(){var qa=a(this),ma=V||Q()[(this.nodeName||"").toLowerCase()]||"",na=ma&&qa.attr(ma)||"";qa.attr(ma,q[da](na,Z,oa))})}var f,d=Array.prototype.slice,l=decodeURIComponent,q=a.param,B,o,K,T=a.bbq=a.bbq||{},M,J,Q,Y=a.event.special,O="querystring",ia="fragment",pa=
V(Z!==f?Z:p[pa][fa]);return da}function s(da,V,Z){if(V===f||typeof V==="boolean"){Z=V;V=q[da?ia:O]()}else V=g(V)?V.replace(da?W:ba,""):V;return o(V,Z)}function b(da,V,Z,oa){if(!g(Z)&&typeof Z!=="object"){oa=Z;Z=V;V=f}return this.each(function(){var qa=a(this),ma=V||Q()[(this.nodeName||"").toLowerCase()]||"",na=ma&&qa.attr(ma)||"";qa.attr(ma,q[da](na,Z,oa))})}var f,d=Array.prototype.slice,l=decodeURIComponent,q=a.param,B,o,K,T=a.bbq=a.bbq||{},M,J,Q,X=a.event.special,O="querystring",ia="fragment",pa=
"location",fa="href",ba=/^.*\?|#.*$/g,W=/^.*\#/,sa,ka={};q[O]=c(n,0,function(da){return da.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")});q[ia]=B=c(n,1,function(da){return da.replace(/^[^#]*#?(.*)$/,"$1")});B.noEscape=function(da){da=da||"";da=a.map(da.split(""),encodeURIComponent);sa=RegExp(da.join("|"),"g")};B.noEscape(",/");a.deparam=o=function(da,V){var Z={},oa={"true":true,"false":false,"null":null};a.each(da.replace(/\+/g," ").split("&"),function(qa,ma){var na=ma.split("="),Aa=l(na[0]),Fa=Z,Ia=
0,Ca=Aa.split("]["),Ka=Ca.length-1;if(/\[/.test(Ca[0])&&/\]$/.test(Ca[Ka])){Ca[Ka]=Ca[Ka].replace(/\]$/,"");Ca=Ca.shift().split("[").concat(Ca);Ka=Ca.length-1}else Ka=0;if(na.length===2){na=l(na[1]);if(V)na=na&&!isNaN(na)?+na:na==="undefined"?f:oa[na]!==f?oa[na]:na;if(Ka)for(;Ia<=Ka;Ia++){Aa=Ca[Ia]===""?Fa.length:Ca[Ia];Fa=Fa[Aa]=Ia<Ka?Fa[Aa]||(Ca[Ia+1]&&isNaN(Ca[Ia+1])?{}:[]):na}else if(a.isArray(Z[Aa]))Z[Aa].push(na);else Z[Aa]=Z[Aa]!==f?[Z[Aa],na]:na}else if(Aa)Z[Aa]=V?f:""});return Z};o[O]=c(s,
0);o[ia]=K=c(s,1);a.elemUrlAttr||(a.elemUrlAttr=function(da){return a.extend(ka,da)})({a:fa,base:fa,iframe:"src",img:"src",input:"src",form:"action",link:fa,script:"src"});Q=a.elemUrlAttr;a.fn[O]=c(b,O);a.fn[ia]=c(b,ia);T.pushState=M=function(da,V){if(g(da)&&/^#/.test(da)&&V===f)V=2;var Z=da!==f;Z=B(p[pa][fa],Z?da:{},Z?V:2);p[pa][fa]=Z+(/#/.test(Z)?"":"#")};T.getState=J=function(da,V){return da===f||typeof da==="boolean"?K(da):K(V)[da]};T.removeState=function(da){var V={};if(da!==f){V=J();a.each(a.isArray(da)?
da:arguments,function(Z,oa){delete V[oa]})}M(V,2)};Y.hashchange=a.extend(Y.hashchange,{add:function(da){function V(oa){var qa=oa[ia]=B();oa.getState=function(ma,na){return ma===f||typeof ma==="boolean"?o(qa,ma):o(qa,na)[ma]};Z.apply(this,arguments)}var Z;if(a.isFunction(da)){Z=da;return V}else{Z=da.handler;da.handler=V}}})})(jQuery,this);
da:arguments,function(Z,oa){delete V[oa]})}M(V,2)};X.hashchange=a.extend(X.hashchange,{add:function(da){function V(oa){var qa=oa[ia]=B();oa.getState=function(ma,na){return ma===f||typeof ma==="boolean"?o(qa,ma):o(qa,na)[ma]};Z.apply(this,arguments)}var Z;if(a.isFunction(da)){Z=da;return V}else{Z=da.handler;da.handler=V}}})})(jQuery,this);
(function(a,p,g){function c(B){B=B||p[b][f];return B.replace(/^[^#]*#?(.*)$/,"$1")}var n,s=a.event.special,b="location",f="href",d=document.documentMode,l=a.browser.msie&&(d===g||d<8),q="onhashchange"in p&&!l;a.hashchangeDelay=100;s.hashchange=a.extend(s.hashchange,{setup:function(){if(q)return false;a(n.start)},teardown:function(){if(q)return false;a(n.stop)}});n=function(){function B(){M=J=function(Q){return Q};if(l){T=a('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;
J=function(){return c(T.document[b][f])};M=function(Q,Y){if(Q!==Y){var O=T.document;O.open().close();O[b].hash="#"+Q}};M(c())}}var o={},K,T,M,J;o.start=function(){if(!K){var Q=c();M||B();(function Y(){var O=c(),ia=J(Q);if(O!==Q){M(Q=O,ia);a(p).trigger("hashchange")}else if(ia!==Q)p[b][f]=p[b][f].replace(/#.*/,"")+"#"+ia;K=setTimeout(Y,a.hashchangeDelay)})()}};o.stop=function(){if(!T){K&&clearTimeout(K);K=0}};return o}()})(jQuery,this);(function(a){var p={},g;a.svgIcons=function(c,n){function s(da,V){if(da!=="ajax"){if(Q)return;var Z=(T=fa[0].contentDocument)&&T.getElementById("svg_eof");if(!Z&&!(V&&Z)){Y++;if(Y<50)setTimeout(s,20);else{f();Q=true}return}Q=true}K=a(T.firstChild).children();if(n.no_img)setTimeout(function(){J||b()},500);else{Z=pa+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";M=a(new Image).attr({src:Z,width:0,height:0}).appendTo("body").load(function(){b(true)}).error(function(){b()})}}
J=function(){return c(T.document[b][f])};M=function(Q,X){if(Q!==X){var O=T.document;O.open().close();O[b].hash="#"+Q}};M(c())}}var o={},K,T,M,J;o.start=function(){if(!K){var Q=c();M||B();(function X(){var O=c(),ia=J(Q);if(O!==Q){M(Q=O,ia);a(p).trigger("hashchange")}else if(ia!==Q)p[b][f]=p[b][f].replace(/#.*/,"")+"#"+ia;K=setTimeout(X,a.hashchangeDelay)})()}};o.stop=function(){if(!T){K&&clearTimeout(K);K=0}};return o}()})(jQuery,this);(function(a){var p={},g;a.svgIcons=function(c,n){function s(da,V){if(da!=="ajax"){if(Q)return;var Z=(T=fa[0].contentDocument)&&T.getElementById("svg_eof");if(!Z&&!(V&&Z)){X++;if(X<50)setTimeout(s,20);else{f();Q=true}return}Q=true}K=a(T.firstChild).children();if(n.no_img)setTimeout(function(){J||b()},500);else{Z=pa+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";M=a(new Image).attr({src:Z,width:0,height:0}).appendTo("body").load(function(){b(true)}).error(function(){b()})}}
function b(da,V){if(!J){if(n.no_img)da=false;if(da){var Z=a(document.createElement("div"));Z.hide().appendTo("body")}if(V){var oa=n.fallback_path?n.fallback_path:"";a.each(V,function(Ka,Na){a("#"+Ka);var za=a(new Image).attr({"class":"svg_icon",src:oa+Na,width:B,height:o,alt:"icon"});ka(za,Ka)})}else for(var qa=K.length,ma=0;ma<qa;ma++){var na=K[ma],Aa=na.id;if(Aa==="svg_eof")break;a("#"+Aa);na=na.getElementsByTagNameNS(l,"svg")[0];var Fa=document.createElementNS(l,"svg");Fa.setAttributeNS(l,"viewBox",
[0,0,B,o].join(" "));var Ia=na.getAttribute("width"),Ca=na.getAttribute("height");na.removeAttribute("width");na.removeAttribute("height");na.getAttribute("viewBox")||na.setAttribute("viewBox",[0,0,Ia,Ca].join(" "));Fa.setAttribute("xmlns",l);Fa.setAttribute("width",B);Fa.setAttribute("height",o);Fa.setAttribute("xmlns:xlink",q);Fa.setAttribute("class","svg_icon");ia||(na=na.cloneNode(true));Fa.appendChild(na);if(da){ia||Fa.cloneNode(true);Z.empty().append(Fa);na=pa+d(Z.html());na=a(new Image).attr({"class":"svg_icon",
src:na})}else na=g(a(Fa),ma);ka(na,Aa)}n.placement&&a.each(n.placement,function(Ka,Na){p[Na]&&a(Ka).each(function(za){var ya=p[Na].clone();if(za>0&&!da)ya=g(ya,za,true);sa(a(this),ya,Na)})});if(!V){da&&Z.remove();fa&&fa.remove();M&&M.remove()}n.resize&&a.resizeSvgIcons(n.resize);J=true;n.callback&&n.callback(p)}}function f(){if(c.indexOf(".svgz")!=-1){var da=c.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg");a.svgIcons(da,n)}else n.fallback&&b(false,n.fallback)}
function d(da){if(window.btoa)return window.btoa(da);var V=Array(Math.floor((da.length+2)/3)*4),Z,oa,qa,ma,na,Aa,Fa=0,Ia=0;do{Z=da.charCodeAt(Fa++);oa=da.charCodeAt(Fa++);qa=da.charCodeAt(Fa++);ma=Z>>2;Z=(Z&3)<<4|oa>>4;na=(oa&15)<<2|qa>>6;Aa=qa&63;if(isNaN(oa))na=Aa=64;else if(isNaN(qa))Aa=64;V[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(ma);V[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Z);V[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(na);
V[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Aa)}while(Fa<da.length);return V.join("")}var l="http://www.w3.org/2000/svg",q="http://www.w3.org/1999/xlink",B=n.w?n.w:24,o=n.h?n.h:24,K,T,M,J=false,Q=false,Y=0,O=navigator.userAgent,ia=!!window.opera;O.indexOf("Safari/")>-1&&O.indexOf("Chrome/");var pa="data:image/svg+xml;charset=utf-8;base64,";if(n.svgz){var fa=a('<object data="'+c+'" type=image/svg+xml>').appendTo("body").hide();try{T=fa[0].contentDocument;fa.load(s);
V[Ia++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(Aa)}while(Fa<da.length);return V.join("")}var l="http://www.w3.org/2000/svg",q="http://www.w3.org/1999/xlink",B=n.w?n.w:24,o=n.h?n.h:24,K,T,M,J=false,Q=false,X=0,O=navigator.userAgent,ia=!!window.opera;O.indexOf("Safari/")>-1&&O.indexOf("Chrome/");var pa="data:image/svg+xml;charset=utf-8;base64,";if(n.svgz){var fa=a('<object data="'+c+'" type=image/svg+xml>').appendTo("body").hide();try{T=fa[0].contentDocument;fa.load(s);
s(0,true)}catch(ba){f()}}else{var W=new DOMParser;a.ajax({url:c,dataType:"string",success:function(da){if(da){T=W.parseFromString(da,"text/xml");a(function(){s("ajax")})}else a(f)},error:function(da){if(window.opera)a(function(){f()});else if(da.responseText){T=W.parseFromString(da.responseText,"text/xml");T.childNodes.length||a(f);a(function(){s("ajax")})}else a(f)}})}var sa=function(da,V,Z,oa){ia&&V.css("visibility","hidden");if(n.replace){oa&&V.attr("id",Z);(Z=da.attr("class"))&&V.attr("class",
"svg_icon "+Z);da.replaceWith(V)}else da.append(V);ia&&setTimeout(function(){V.removeAttr("style")},1)},ka=function(da,V){if(n.id_match===undefined||n.id_match!==false)sa(holder,da,V,true);p[V]=da};g=function(da,V){var Z=da.find("defs");if(!Z.length)return da;Z=ia?Z.find("*").filter(function(){return!!this.id}):Z.find("[id]");var oa=da[0].getElementsByTagName("*"),qa=oa.length;Z.each(function(ma){var na=this.id;a(T).find("#"+na);this.id=ma="x"+na+V+ma;na="url(#"+na+")";var Aa="url(#"+ma+")";for(ma=
0;ma<qa;ma++){var Fa=oa[ma];Fa.getAttribute("fill")===na&&Fa.setAttribute("fill",Aa);Fa.getAttribute("stroke")===na&&Fa.setAttribute("stroke",Aa);Fa.getAttribute("filter")===na&&Fa.setAttribute("filter",Aa)}});return da}};a.getSvgIcon=function(c,n){var s=p[c];if(n&&s)s=g(s,0,true).clone(true);return s};a.resizeSvgIcons=function(c){var n=!a(".svg_icon:first").length;a.each(c,function(s,b){var f=a.isArray(b),d=f?b[0]:b,l=f?b[1]:b;if(n)s=s.replace(/\.svg_icon/g,"svg");a(s).each(function(){this.setAttribute("width",
@ -20,14 +20,14 @@ d);this.setAttribute("height",l);if(window.opera&&window.widget){this.parentNode
c.copy.type;this.alpha=c.copy.alpha;this.radialGradient=this.linearGradient=this.solidColor=null;switch(this.type){case "solidColor":this.solidColor=c.copy.solidColor;break;case "linearGradient":this.linearGradient=c.copy.linearGradient.cloneNode(true);break;case "radialGradient":this.radialGradient=c.copy.radialGradient.cloneNode(true)}}else if(c.linearGradient){this.type="linearGradient";this.radialGradient=this.solidColor=null;this.linearGradient=c.linearGradient.cloneNode(true)}else if(c.radialGradient){this.type=
"radialGradient";this.linearGradient=this.solidColor=null;this.radialGradient=c.radialGradient.cloneNode(true)}else if(c.solidColor){this.type="solidColor";this.solidColor=c.solidColor}else{this.type="none";this.radialGradient=this.linearGradient=this.solidColor=null}}};jQuery.fn.jGraduateDefaults={paint:new $.jGraduate.Paint,window:{pickerTitle:"Drag markers to pick a paint"},images:{clientPath:"images/"},newstop:"inverse"};var g=navigator.userAgent.indexOf("Gecko/")>=0;jQuery.fn.jGraduate=function(c){var n=
arguments;return this.each(function(){function s(la,ca,ja,N,R){var ea=R||a("stop",{"stop-color":ca,"stop-opacity":ja,offset:la},W);if(R){ca=R.getAttribute("stop-color");ja=R.getAttribute("stop-opacity");la=R.getAttribute("offset")}else W.appendChild(ea);if(ja===null)ja=1;R=a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:"url(#jGraduate_trans)",transform:"translate("+(10+la*ia)+", 26)"},qb);var Ga=
a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:ca,"fill-opacity":ja,transform:"translate("+(10+la*ia)+", 26)",stroke:"#000","stroke-width":1.5},qb);$(Ga).mousedown(function(Oa){b(this);Ra=ib;Q.mousemove(l).mouseup(f);va=$a.offset();Oa.preventDefault();return false}).data("stop",ea).data("bg",R).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Oa=this,Ya=+ea.getAttribute("stop-opacity")||
1,db=ea.getAttribute("stop-color")||1,nb=(parseFloat(Ya)*255).toString(16);nb.length<2;)nb="0"+nb;ca=db.substr(1)+nb;$("#"+o+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:B.images.clientPath},color:{active:ca,alphaSupport:true}},function(Xa){db=Xa.val("hex")?"#"+Xa.val("hex"):"none";Ya=Xa.val("a")!==null?Xa.val("a")/256:1;Oa.setAttribute("fill",db);Oa.setAttribute("fill-opacity",Ya);ea.setAttribute("stop-color",
db);ea.setAttribute("stop-opacity",Ya);$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()})});$(W).find("stop").each(function(){var Oa=$(this);if(+this.getAttribute("offset")>la){if(!ca){var Ya=this.getAttribute("stop-color"),db=this.getAttribute("stop-opacity");ea.setAttribute("stop-color",Ya);Ga.setAttribute("fill",Ya);ea.setAttribute("stop-opacity",db===null?1:db);Ga.setAttribute("fill-opacity",
db===null?1:db)}Oa.before(ea);return false}});N&&b(Ga);return ea}function b(la){ib&&ib.setAttribute("stroke","#000");la.setAttribute("stroke","blue");ib=la;ib.parentNode.appendChild(ib)}function f(){Q.unbind("mousemove",l);if(Da.getAttribute("display")!=="none"){Da.setAttribute("display","none");var la=$(ib),ca=la.data("stop");la=la.data("bg");$([ib,ca,la]).remove()}Ra=null}function d(){var la=Ua?"rotate("+Ua+","+Ea+","+kb+") ":"";fb===1&&La===1?W.removeAttribute("gradientTransform"):W.setAttribute("gradientTransform",
la+"translate("+-Ea*(fb-1)+","+-kb*(La-1)+") scale("+fb+","+La+")")}function l(la){var ca=la.pageX-va.left;la=la.pageY-va.top;ca=ca<10?10:ca>ia+10?ia+10:ca;var ja="translate("+ca+", 26)";if(la<-60||la>130){Da.setAttribute("display","block");Da.setAttribute("transform",ja)}else Da.setAttribute("display","none");Ra.setAttribute("transform",ja);$.data(Ra,"bg").setAttribute("transform",ja);$.data(Ra,"stop").setAttribute("offset",(ca-10)/ia);var N=0;$(W).find("stop").each(function(){var R=this.getAttribute("offset"),
a("path",{d:"M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",fill:ca,"fill-opacity":ja,transform:"translate("+(10+la*ia)+", 26)",stroke:"#000","stroke-width":1.5},qb);$(Ga).mousedown(function(Pa){b(this);Sa=ib;Q.mousemove(l).mouseup(f);va=$a.offset();Pa.preventDefault();return false}).data("stop",ea).data("bg",R).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Pa=this,Ya=+ea.getAttribute("stop-opacity")||
1,db=ea.getAttribute("stop-color")||1,nb=(parseFloat(Ya)*255).toString(16);nb.length<2;)nb="0"+nb;ca=db.substr(1)+nb;$("#"+o+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:B.images.clientPath},color:{active:ca,alphaSupport:true}},function(Ua){db=Ua.val("hex")?"#"+Ua.val("hex"):"none";Ya=Ua.val("a")!==null?Ua.val("a")/256:1;Pa.setAttribute("fill",db);Pa.setAttribute("fill-opacity",Ya);ea.setAttribute("stop-color",
db);ea.setAttribute("stop-opacity",Ya);$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+o+"_jGraduate_stopPicker").hide()})});$(W).find("stop").each(function(){var Pa=$(this);if(+this.getAttribute("offset")>la){if(!ca){var Ya=this.getAttribute("stop-color"),db=this.getAttribute("stop-opacity");ea.setAttribute("stop-color",Ya);Ga.setAttribute("fill",Ya);ea.setAttribute("stop-opacity",db===null?1:db);Ga.setAttribute("fill-opacity",
db===null?1:db)}Pa.before(ea);return false}});N&&b(Ga);return ea}function b(la){ib&&ib.setAttribute("stroke","#000");la.setAttribute("stroke","blue");ib=la;ib.parentNode.appendChild(ib)}function f(){Q.unbind("mousemove",l);if(Da.getAttribute("display")!=="none"){Da.setAttribute("display","none");var la=$(ib),ca=la.data("stop");la=la.data("bg");$([ib,ca,la]).remove()}Sa=null}function d(){var la=Va?"rotate("+Va+","+Ea+","+kb+") ":"";fb===1&&La===1?W.removeAttribute("gradientTransform"):W.setAttribute("gradientTransform",
la+"translate("+-Ea*(fb-1)+","+-kb*(La-1)+") scale("+fb+","+La+")")}function l(la){var ca=la.pageX-va.left;la=la.pageY-va.top;ca=ca<10?10:ca>ia+10?ia+10:ca;var ja="translate("+ca+", 26)";if(la<-60||la>130){Da.setAttribute("display","block");Da.setAttribute("transform",ja)}else Da.setAttribute("display","none");Sa.setAttribute("transform",ja);$.data(Sa,"bg").setAttribute("transform",ja);$.data(Sa,"stop").setAttribute("offset",(ca-10)/ia);var N=0;$(W).find("stop").each(function(){var R=this.getAttribute("offset"),
ea=$(this);if(R<N){ea.prev().before(ea);wa=$(W).find("stop")}N=R})}var q=$(this),B=$.extend(true,{},jQuery.fn.jGraduateDefaults,c),o=q.attr("id"),K="#"+q.attr("id")+" ";if(K){var T=function(){switch(q.paint.type){case "radialGradient":q.paint.linearGradient=null;break;case "linearGradient":q.paint.radialGradient=null;break;case "solidColor":q.paint.radialGradient=q.paint.linearGradient=null}$.isFunction(q.okCallback)&&q.okCallback(q.paint);q.hide()},M=function(){$.isFunction(q.cancelCallback)&&q.cancelCallback();
q.hide()};$.extend(true,q,{paint:new $.jGraduate.Paint({copy:B.paint}),okCallback:$.isFunction(n[1])&&n[1]||null,cancelCallback:$.isFunction(n[2])&&n[2]||null});q.position();var J=null,Q=$(window);if(q.paint.type=="none")q.paint=$.jGraduate.Paint({solidColor:"ffffff"});q.addClass("jGraduate_Picker");q.html('<ul class="jGraduate_tabs"><li class="jGraduate_tab_color jGraduate_tab_current" data-type="col">Solid Color</li><li class="jGraduate_tab_lingrad" data-type="lg">Linear Gradient</li><li class="jGraduate_tab_radgrad" data-type="rg">Radial Gradient</li></ul><div class="jGraduate_colPick"></div><div class="jGraduate_gradPick"></div><div class="jGraduate_LightBox"></div><div id="'+
o+'_jGraduate_stopPicker" class="jGraduate_stopPicker"></div>');var Y=$(K+"> .jGraduate_colPick"),O=$(K+"> .jGraduate_gradPick");O.html('<div id="'+o+'_jGraduate_Swatch" class="jGraduate_Swatch"><h2 class="jGraduate_Title">'+B.window.pickerTitle+'</h2><div id="'+o+'_jGraduate_GradContainer" class="jGraduate_GradContainer"></div><div id="'+o+'_jGraduate_StopSlider" class="jGraduate_StopSlider"></div></div><div class="jGraduate_Form jGraduate_Points jGraduate_lg_field"><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">Begin Point</label><div class="jGraduate_Form_Section"><label>x:</label><input type="text" id="'+
o+'_jGraduate_stopPicker" class="jGraduate_stopPicker"></div>');var X=$(K+"> .jGraduate_colPick"),O=$(K+"> .jGraduate_gradPick");O.html('<div id="'+o+'_jGraduate_Swatch" class="jGraduate_Swatch"><h2 class="jGraduate_Title">'+B.window.pickerTitle+'</h2><div id="'+o+'_jGraduate_GradContainer" class="jGraduate_GradContainer"></div><div id="'+o+'_jGraduate_StopSlider" class="jGraduate_StopSlider"></div></div><div class="jGraduate_Form jGraduate_Points jGraduate_lg_field"><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">Begin Point</label><div class="jGraduate_Form_Section"><label>x:</label><input type="text" id="'+
o+'_jGraduate_x1" size="3" title="Enter starting x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+o+'_jGraduate_y1" size="3" title="Enter starting y value between 0.0 and 1.0"/></div></div><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">End Point</label><div class="jGraduate_Form_Section"><label>x:</label><input type="text" id="'+o+'_jGraduate_x2" size="3" title="Enter ending x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+
o+'_jGraduate_y2" size="3" title="Enter ending y value between 0.0 and 1.0"/></div></div></div><div class="jGraduate_Form jGraduate_Points jGraduate_rg_field"><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">Center Point</label><div class="jGraduate_Form_Section"><label>x:</label><input type="text" id="'+o+'_jGraduate_cx" size="3" title="Enter x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+o+'_jGraduate_cy" size="3" title="Enter y value between 0.0 and 1.0"/></div></div><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">Focal Point</label><div class="jGraduate_Form_Section"><label>Match center: <input type="checkbox" checked="checked" id="'+
o+'_jGraduate_match_ctr"/></label><br/><label>x:</label><input type="text" id="'+o+'_jGraduate_fx" size="3" title="Enter x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+o+'_jGraduate_fy" size="3" title="Enter y value between 0.0 and 1.0"/></div></div></div><div class="jGraduate_StopSection jGraduate_SpreadMethod"><label class="jGraduate_Form_Heading">Spread method</label><div class="jGraduate_Form_Section"><select class="jGraduate_spreadMethod"><option value=pad selected>Pad</option><option value=reflect>Reflect</option><option value=repeat>Repeat</option></select></div></div><div class="jGraduate_Form"><div class="jGraduate_Slider jGraduate_RadiusField jGraduate_rg_field"><label class="prelabel">Radius:</label><div id="'+
@ -39,21 +39,21 @@ Z=W=V.appendChild(W)}a("radialGradient",{id:o+"_rg_jgraduate_grad"},V);if(ba==="
if(Aa.length<2)Aa=0+Aa;ma+=Aa}s(1,"#"+ma,1);break;case "white":s(1,"#ffffff",1);break;case "black":s(1,"#000000",1)}else if(ma==="object")s(1,B.newstop.color||"#"+J,"opac"in B.newstop?B.newstop.opac:1)}J=parseFloat(Z.getAttribute("x1")||0);ma=parseFloat(Z.getAttribute("y1")||0);na=parseFloat(Z.getAttribute("x2")||1);Aa=parseFloat(Z.getAttribute("y2")||0);var Fa=parseFloat(Z.getAttribute("cx")||0.5),Ia=parseFloat(Z.getAttribute("cy")||0.5),Ca=parseFloat(Z.getAttribute("fx")||Fa),Ka=parseFloat(Z.getAttribute("fy")||
Ia);sa=a("rect",{id:o+"_jgraduate_rect",x:0,y:0,width:pa,height:fa,fill:"url(#"+o+"_jgraduate_grad)","fill-opacity":oa/100},V);var Na=$("<div/>").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:ma*ia,left:J*ia}).data("coord","start").appendTo(da),za=Na.clone().text(2).css({top:Aa*ia,left:na*ia}).attr("title","End stop").data("coord","end").appendTo(da),ya=$("<div/>").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Ia*ia,left:Fa*
ia}).data("coord","center").appendTo(da),Ha=ya.clone().text("F").css({top:Ka*ia,left:Ca*ia,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(da);Ha[0].id=o+"_jGraduate_focusCoord";$(K+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(la,ca){var ja=W.getAttribute(ca),N=isNaN(ca[1]);ja||(ja=N?"0.5":ca==="x2"?"1.0":"0.0");ka[ca]=$("#"+o+"_jGraduate_"+ca).val(ja).change(function(){if(isNaN(parseFloat(this.value))||this.value<0)this.value=0;else if(this.value>
1)this.value=1;if(!(ca[0]==="f"&&!jb))if(N&&ba==="radialGradient"||!N&&ba==="linearGradient")W.setAttribute(ca,this.value);var R=N?ca[0]==="c"?ya:Ha:ca[1]==="1"?Na:za,ea=ca.indexOf("x")>=0?"left":"top";R.css(ea,this.value*ia)}).change()});var wa,qb,$a=$("#"+o+"_jGraduate_StopSlider"),ib,Va,Ra,Da=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},Va),va,fb=1,La=1,Ua=0,Ea=Fa,kb=Ia;Va=a("svg",{width:"100%",height:45},$a[0]);da=a("pattern",{width:16,
height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},Va);a("image",{width:16,height:16},da).setAttributeNS(p.xlink,"xlink:href",B.images.clientPath+"map-opacity.png");$(Va).on("click touchstart",function(la){va=$a.offset();if(la.target.tagName!=="path"){var ca=la.pageX-va.left-8;ca=ca<10?10:ca>ia+10?ia+10:ca;s(ca/ia,0,0,true);la.stopPropagation()}});$(Va).mouseover(function(){Va.appendChild(Da)});qb=a("g",{},Va);a("line",{x1:10,y1:15,x2:ia+10,y2:15,"stroke-width":2,stroke:"#000"},Va);var sb=
1)this.value=1;if(!(ca[0]==="f"&&!jb))if(N&&ba==="radialGradient"||!N&&ba==="linearGradient")W.setAttribute(ca,this.value);var R=N?ca[0]==="c"?ya:Ha:ca[1]==="1"?Na:za,ea=ca.indexOf("x")>=0?"left":"top";R.css(ea,this.value*ia)}).change()});var wa,qb,$a=$("#"+o+"_jGraduate_StopSlider"),ib,Wa,Sa,Da=a("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},Wa),va,fb=1,La=1,Va=0,Ea=Fa,kb=Ia;Wa=a("svg",{width:"100%",height:45},$a[0]);da=a("pattern",{width:16,
height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},Wa);a("image",{width:16,height:16},da).setAttributeNS(p.xlink,"xlink:href",B.images.clientPath+"map-opacity.png");$(Wa).on("click touchstart",function(la){va=$a.offset();if(la.target.tagName!=="path"){var ca=la.pageX-va.left-8;ca=ca<10?10:ca>ia+10?ia+10:ca;s(ca/ia,0,0,true);la.stopPropagation()}});$(Wa).mouseover(function(){Wa.appendChild(Da)});qb=a("g",{},Wa);a("line",{x1:10,y1:15,x2:ia+10,y2:15,"stroke-width":2,stroke:"#000"},Wa);var sb=
O.find(".jGraduate_spreadMethod").change(function(){W.setAttribute("spreadMethod",$(this).val())}),Za=null,bb=function(la){var ca=la.pageX-mb.left,ja=la.pageY-mb.top;ca=ca<0?0:ca>ia?ia:ca;ja=ja<0?0:ja>ia?ia:ja;Za.css("left",ca).css("top",ja);ca=ca/pa;ja=ja/fa;var N=Za.data("coord"),R=W;switch(N){case "start":ka.x1.val(ca);ka.y1.val(ja);R.setAttribute("x1",ca);R.setAttribute("y1",ja);break;case "end":ka.x2.val(ca);ka.y2.val(ja);R.setAttribute("x2",ca);R.setAttribute("y2",ja);break;case "center":ka.cx.val(ca);
ka.cy.val(ja);R.setAttribute("cx",ca);R.setAttribute("cy",ja);Ea=ca;kb=ja;d();break;case "focus":ka.fx.val(ca);ka.fy.val(ja);R.setAttribute("fx",ca);R.setAttribute("fy",ja);d()}la.preventDefault()},Cb=function(){Za=null;Q.unbind("mousemove",bb).unbind("mouseup",Cb)};wa=W.getElementsByTagNameNS(p.svg,"stop");if(ta<2){for(;ta<2;){W.appendChild(document.createElementNS(p.svg,"stop"));++ta}wa=W.getElementsByTagNameNS(p.svg,"stop")}var ta=wa.length;for(na=0;na<ta;na++)s(0,0,0,0,wa[na]);sb.val(W.getAttribute("spreadMethod")||
ka.cy.val(ja);R.setAttribute("cx",ca);R.setAttribute("cy",ja);Ea=ca;kb=ja;d();break;case "focus":ka.fx.val(ca);ka.fy.val(ja);R.setAttribute("fx",ca);R.setAttribute("fy",ja);d()}la.preventDefault()},Cb=function(){Za=null;Q.unbind("mousemove",bb).unbind("mouseup",Cb)};wa=W.getElementsByTagNameNS(p.svg,"stop");if(ua<2){for(;ua<2;){W.appendChild(document.createElementNS(p.svg,"stop"));++ua}wa=W.getElementsByTagNameNS(p.svg,"stop")}var ua=wa.length;for(na=0;na<ua;na++)s(0,0,0,0,wa[na]);sb.val(W.getAttribute("spreadMethod")||
"pad");var mb,jb=false;sa.setAttribute("fill-opacity",oa/100);$("#"+o+" div.grad_coord").mousedown(function(la){la.preventDefault();Za=$(this);Za.offset();mb=Za.parent().offset();Q.mousemove(bb).mouseup(Cb)});$("#"+o+"_jGraduate_Ok").bind("click touchstart",function(){q.paint.type=ba;q.paint[ba]=W.cloneNode(true);q.paint.solidColor=null;T()});$("#"+o+"_jGraduate_Cancel").bind("click touchstart",function(){M()});if(ba==="radialGradient")if(jb)Ha.show();else{Ha.hide();ka.fx.val("");ka.fy.val("")}$("#"+
o+"_jGraduate_match_ctr")[0].checked=!jb;var zb,ob;$("#"+o+"_jGraduate_match_ctr").change(function(){jb=!this.checked;Ha.toggle(jb);ka.fx.val("");ka.fy.val("");var la=W;if(jb){var ca=zb||0.5,ja=ob||0.5;la.setAttribute("fx",ca);la.setAttribute("fy",ja);ka.fx.val(ca);ka.fy.val(ja)}else{zb=la.getAttribute("fx");ob=la.getAttribute("fy");la.removeAttribute("fx");la.removeAttribute("fy")}});wa=W.getElementsByTagNameNS(p.svg,"stop");ta=wa.length;if(ta<2){for(;ta<2;){W.appendChild(document.createElementNS(p.svg,
"stop"));++ta}wa=W.getElementsByTagNameNS(p.svg,"stop")}var eb;oa=O=0;if(ba==="radialGradient"){V=W.gradientTransform.baseVal;if(V.numberOfItems===2){ta=V.getItem(0);V=V.getItem(1);if(ta.type===2&&V.type===3){ta=V.matrix;if(ta.a!==1)O=Math.round(-(1-ta.a)*100);else if(ta.d!==1)O=Math.round((1-ta.d)*100)}}else if(V.numberOfItems===3){da=V.getItem(0);ta=V.getItem(1);V=V.getItem(2);if(da.type===4&&ta.type===2&&V.type===3){oa=Math.round(da.angle);ta=V.matrix;if(ta.a!==1)O=Math.round(-(1-ta.a)*100);else if(ta.d!==
1)O=Math.round((1-ta.d)*100)}}}O={radius:{handle:"#"+o+"_jGraduate_RadiusArrows",input:"#"+o+"_jGraduate_RadiusInput",val:(W.getAttribute("r")||0.5)*100},opacity:{handle:"#"+o+"_jGraduate_OpacArrows",input:"#"+o+"_jGraduate_OpacInput",val:q.paint.alpha||100},ellip:{handle:"#"+o+"_jGraduate_EllipArrows",input:"#"+o+"_jGraduate_EllipInput",val:O},angle:{handle:"#"+o+"_jGraduate_AngleArrows",input:"#"+o+"_jGraduate_AngleInput",val:oa}};$.each(O,function(la,ca){var ja=$(ca.handle);ja.mousedown(function(N){var R=
o+"_jGraduate_match_ctr")[0].checked=!jb;var Ab,ob;$("#"+o+"_jGraduate_match_ctr").change(function(){jb=!this.checked;Ha.toggle(jb);ka.fx.val("");ka.fy.val("");var la=W;if(jb){var ca=Ab||0.5,ja=ob||0.5;la.setAttribute("fx",ca);la.setAttribute("fy",ja);ka.fx.val(ca);ka.fy.val(ja)}else{Ab=la.getAttribute("fx");ob=la.getAttribute("fy");la.removeAttribute("fx");la.removeAttribute("fy")}});wa=W.getElementsByTagNameNS(p.svg,"stop");ua=wa.length;if(ua<2){for(;ua<2;){W.appendChild(document.createElementNS(p.svg,
"stop"));++ua}wa=W.getElementsByTagNameNS(p.svg,"stop")}var eb;oa=O=0;if(ba==="radialGradient"){V=W.gradientTransform.baseVal;if(V.numberOfItems===2){ua=V.getItem(0);V=V.getItem(1);if(ua.type===2&&V.type===3){ua=V.matrix;if(ua.a!==1)O=Math.round(-(1-ua.a)*100);else if(ua.d!==1)O=Math.round((1-ua.d)*100)}}else if(V.numberOfItems===3){da=V.getItem(0);ua=V.getItem(1);V=V.getItem(2);if(da.type===4&&ua.type===2&&V.type===3){oa=Math.round(da.angle);ua=V.matrix;if(ua.a!==1)O=Math.round(-(1-ua.a)*100);else if(ua.d!==
1)O=Math.round((1-ua.d)*100)}}}O={radius:{handle:"#"+o+"_jGraduate_RadiusArrows",input:"#"+o+"_jGraduate_RadiusInput",val:(W.getAttribute("r")||0.5)*100},opacity:{handle:"#"+o+"_jGraduate_OpacArrows",input:"#"+o+"_jGraduate_OpacInput",val:q.paint.alpha||100},ellip:{handle:"#"+o+"_jGraduate_EllipArrows",input:"#"+o+"_jGraduate_EllipInput",val:O},angle:{handle:"#"+o+"_jGraduate_AngleArrows",input:"#"+o+"_jGraduate_AngleInput",val:oa}};$.each(O,function(la,ca){var ja=$(ca.handle);ja.mousedown(function(N){var R=
ja.parent();eb={type:la,elem:ja,input:$(ca.input),parent:R,offset:R.offset()};Q.mousemove(tb).mouseup(ub);N.preventDefault()});$(ca.input).val(ca.val).change(function(){var N=+this.value,R=0,ea=ba==="radialGradient";switch(la){case "radius":ea&&W.setAttribute("r",N/100);R=Math.pow(N/100,0.4)/2*145;break;case "opacity":q.paint.alpha=N;sa.setAttribute("fill-opacity",N/100);R=N*1.45;break;case "ellip":fb=La=1;if(N===0){R=72.5;break}if(N>99.5)N=99.5;if(N>0)La=1-N/100;else fb=-(N/100)-1;R=145*((N+100)/
2)/100;ea&&d();break;case "angle":Ua=N;R=Ua/180;R+=0.5;R*=145;ea&&d()}if(R>145)R=145;else if(R<0)R=0;ja.css({"margin-left":R-5})}).change()});var tb=function(la){var ca=la.pageX-eb.offset.left-parseInt(eb.parent.css("border-left-width"));if(ca>145)ca=145;if(ca<=0)ca=0;var ja=ca-5;ca/=145;switch(eb.type){case "radius":ca=Math.pow(ca*2,2.5);if(ca>0.98&&ca<1.02)ca=1;if(ca<=0.01)ca=0.01;W.setAttribute("r",ca);break;case "opacity":q.paint.alpha=parseInt(ca*100);sa.setAttribute("fill-opacity",ca);break;
case "ellip":La=fb=1;if(ca<0.5){ca/=0.5;fb=ca<=0?0.01:ca}else if(ca>0.5){ca/=0.5;ca=2-ca;La=ca<=0?0.01:ca}d();ca-=1;if(La===ca+1)ca=Math.abs(ca);break;case "angle":ca-=0.5;Ua=ca*=180;d();ca/=100}eb.elem.css({"margin-left":ja});ca=Math.round(ca*100);eb.input.val(ca);la.preventDefault()},ub=function(){Q.unbind("mousemove",tb).unbind("mouseup",ub);eb=null};for(O=(q.paint.alpha*255/100).toString(16);O.length<2;)O="0"+O;O=O.split(".")[0];J=q.paint.solidColor=="none"?"":q.paint.solidColor+O;qa||(J=wa[0].getAttribute("stop-color"));
$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});Y.jPicker({window:{title:B.window.pickerTitle},images:{clientPath:B.images.clientPath},color:{active:J,alphaSupport:true}},function(la){q.paint.type="solidColor";q.paint.alpha=la.val("ahex")?Math.round(la.val("a")/255*100):100;q.paint.solidColor=la.val("hex")?la.val("hex"):"none";q.paint.radialGradient=null;T()},null,function(){M()});var wb=$(K+" .jGraduate_tabs li");wb.on("click touchstart",function(){wb.removeClass("jGraduate_tab_current");
2)/100;ea&&d();break;case "angle":Va=N;R=Va/180;R+=0.5;R*=145;ea&&d()}if(R>145)R=145;else if(R<0)R=0;ja.css({"margin-left":R-5})}).change()});var tb=function(la){var ca=la.pageX-eb.offset.left-parseInt(eb.parent.css("border-left-width"));if(ca>145)ca=145;if(ca<=0)ca=0;var ja=ca-5;ca/=145;switch(eb.type){case "radius":ca=Math.pow(ca*2,2.5);if(ca>0.98&&ca<1.02)ca=1;if(ca<=0.01)ca=0.01;W.setAttribute("r",ca);break;case "opacity":q.paint.alpha=parseInt(ca*100);sa.setAttribute("fill-opacity",ca);break;
case "ellip":La=fb=1;if(ca<0.5){ca/=0.5;fb=ca<=0?0.01:ca}else if(ca>0.5){ca/=0.5;ca=2-ca;La=ca<=0?0.01:ca}d();ca-=1;if(La===ca+1)ca=Math.abs(ca);break;case "angle":ca-=0.5;Va=ca*=180;d();ca/=100}eb.elem.css({"margin-left":ja});ca=Math.round(ca*100);eb.input.val(ca);la.preventDefault()},ub=function(){Q.unbind("mousemove",tb).unbind("mouseup",ub);eb=null};for(O=(q.paint.alpha*255/100).toString(16);O.length<2;)O="0"+O;O=O.split(".")[0];J=q.paint.solidColor=="none"?"":q.paint.solidColor+O;qa||(J=wa[0].getAttribute("stop-color"));
$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});X.jPicker({window:{title:B.window.pickerTitle},images:{clientPath:B.images.clientPath},color:{active:J,alphaSupport:true}},function(la){q.paint.type="solidColor";q.paint.alpha=la.val("ahex")?Math.round(la.val("a")/255*100):100;q.paint.solidColor=la.val("hex")?la.val("hex"):"none";q.paint.radialGradient=null;T()},null,function(){M()});var wb=$(K+" .jGraduate_tabs li");wb.on("click touchstart",function(){wb.removeClass("jGraduate_tab_current");
$(this).addClass("jGraduate_tab_current");$(K+" > div").hide();var la=$(this).attr("data-type");$(K+" .jGraduate_gradPick").show();if(la==="rg"||la==="lg"){$(".jGraduate_"+la+"_field").show();$(".jGraduate_"+(la==="lg"?"rg":"lg")+"_field").hide();$("#"+o+"_jgraduate_rect")[0].setAttribute("fill","url(#"+o+"_"+la+"_jgraduate_grad)");ba=la==="lg"?"linearGradient":"radialGradient";$("#"+o+"_jGraduate_OpacInput").val(q.paint.alpha).change();var ca=$("#"+o+"_"+la+"_jgraduate_grad")[0];if(W!==ca){var ja=
$(W).find("stop");$(ca).empty().append(ja);W=ca;ca=sb.val();W.setAttribute("spreadMethod",ca)}jb=la==="rg"&&W.getAttribute("fx")!=null&&!(Fa==Ca&&Ia==Ka);$("#"+o+"_jGraduate_focusCoord").toggle(jb);if(jb)$("#"+o+"_jGraduate_match_ctr")[0].checked=false}else{$(K+" .jGraduate_gradPick").hide();$(K+" .jGraduate_colPick").show()}});$(K+" > div").hide();wb.removeClass("jGraduate_tab_current");var Ab;switch(q.paint.type){case "linearGradient":Ab=$(K+" .jGraduate_tab_lingrad");break;case "radialGradient":Ab=
$(K+" .jGraduate_tab_radgrad");break;default:Ab=$(K+" .jGraduate_tab_color")}q.show();setTimeout(function(){Ab.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.")})}})();jQuery&&function(){var a=$(window),p=$(document);$.extend($.fn,{contextMenu:function(g,c){if(g.menu==undefined)return false;if(g.inSpeed==undefined)g.inSpeed=150;if(g.outSpeed==undefined)g.outSpeed=75;if(g.inSpeed==0)g.inSpeed=-1;if(g.outSpeed==0)g.outSpeed=-1;$(this).each(function(){var n=$(this),s=$(n).offset(),b=$("#"+g.menu);b.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).on("mouseup",function(l){var q=$(this);q.unbind("mouseup");$(".contextMenu").hide();if(d.button===2||
$(W).find("stop");$(ca).empty().append(ja);W=ca;ca=sb.val();W.setAttribute("spreadMethod",ca)}jb=la==="rg"&&W.getAttribute("fx")!=null&&!(Fa==Ca&&Ia==Ka);$("#"+o+"_jGraduate_focusCoord").toggle(jb);if(jb)$("#"+o+"_jGraduate_match_ctr")[0].checked=false}else{$(K+" .jGraduate_gradPick").hide();$(K+" .jGraduate_colPick").show()}});$(K+" > div").hide();wb.removeClass("jGraduate_tab_current");var Bb;switch(q.paint.type){case "linearGradient":Bb=$(K+" .jGraduate_tab_lingrad");break;case "radialGradient":Bb=
$(K+" .jGraduate_tab_radgrad");break;default:Bb=$(K+" .jGraduate_tab_color")}q.show();setTimeout(function(){Bb.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.")})}})();jQuery&&function(){var a=$(window),p=$(document);$.extend($.fn,{contextMenu:function(g,c){if(g.menu==undefined)return false;if(g.inSpeed==undefined)g.inSpeed=150;if(g.outSpeed==undefined)g.outSpeed=75;if(g.inSpeed==0)g.inSpeed=-1;if(g.outSpeed==0)g.outSpeed=-1;$(this).each(function(){var n=$(this),s=$(n).offset(),b=$("#"+g.menu);b.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).on("mouseup",function(l){var q=$(this);q.unbind("mouseup");$(".contextMenu").hide();if(d.button===2||
g.allowLeft||d.ctrlKey&&svgedit.browser.isMac())svgedit.browser.isTouch()||f(l,d,q)})});svgedit.browser.isTouch()&&$(this).bind("taphold",function(d){var l=$(this);l.unbind("mouseup");f(d,d,l)});var f=function(d,l,q){if(typeof l=="undefined")l=d;d.stopPropagation();if(n.hasClass("disabled")||l.altKey)return false;var B=d.pageX,o=d.pageY;if(svgedit.browser.isTouch()){B=d.originalEvent.touches[0].pageX;o=d.originalEvent.touches[0].pageY}d=a.width()-b.width();l=a.height()-b.height();if(B>d-15)B=d-15;
if(o>l-30)o=l-30;if(svgedit.browser.isTouch())o-=b.height()/2;p.unbind("click");b.css({top:o,left:B}).fadeIn(g.inSpeed);b.find("A").mouseover(function(){b.find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){b.find("LI.hover").removeClass("hover")});p.keypress(function(K){switch(K.keyCode){case 38:if(b.find("LI.hover").length){b.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover");b.find("LI.hover").length||b.find("LI:last").addClass("hover")}else b.find("LI:last").addClass("hover");
break;case 40:if(b.find("LI.hover").length==0)b.find("LI:first").addClass("hover");else{b.find("LI.hover").removeClass("hover").nextAll("LI:not(.disabled)").eq(0).addClass("hover");b.find("LI.hover").length||b.find("LI:first").addClass("hover")}break;case 13:b.find("LI.hover A").trigger("click");break;case 27:p.trigger("click")}});b.find("A").unbind("mouseup");b.find("LI:not(.disabled) A").mouseup(function(){p.unbind("click").unbind("keypress");$(".contextMenu").hide();c&&c($(this).attr("href").substr(1),
@ -64,10 +64,10 @@ function(){return false})});return $(this)},disableContextMenuItems:function(g){
0,q="ontouchstart"in window,B=!!g.querySelector,o=!!document.evaluate,K=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","path");pa.setAttribute("d","M0,0 10,10");var fa=pa.pathSegList;pa=pa.createSVGPathSegLinetoAbs(5,5);try{fa.replaceItem(pa,0);return true}catch(ba){}return false}(),T=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","path");pa.setAttribute("d","M0,0 10,10");var fa=pa.pathSegList;pa=pa.createSVGPathSegLinetoAbs(5,5);try{fa.insertItemBefore(pa,
0);return true}catch(ba){}return false}(),M=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","svg"),fa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(pa);fa.setAttribute("x",5);pa.appendChild(fa);var ba=document.createElementNS("http://www.w3.org/2000/svg","text");ba.textContent="a";fa.appendChild(ba);fa=ba.getStartPositionOfChar(0).x;document.documentElement.removeChild(pa);return fa===0}(),J=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg",
"svg");document.documentElement.appendChild(pa);var fa=document.createElementNS("http://www.w3.org/2000/svg","path");fa.setAttribute("d","M0,0 C0,0 10,10 10,0");pa.appendChild(fa);fa=fa.getBBox();document.documentElement.removeChild(pa);return fa.height>4&&fa.height<5}(),Q=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","svg");document.documentElement.appendChild(pa);var fa=document.createElementNS("http://www.w3.org/2000/svg","path");fa.setAttribute("d","M0,0 10,0");var ba=
document.createElementNS("http://www.w3.org/2000/svg","path");ba.setAttribute("d","M5,0 15,0");var W=document.createElementNS("http://www.w3.org/2000/svg","g");W.appendChild(fa);W.appendChild(ba);pa.appendChild(W);fa=W.getBBox();document.documentElement.removeChild(pa);return fa.width==15}(),Y=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","rect");pa.setAttribute("x",0.1);(pa=pa.cloneNode(false).getAttribute("x").indexOf(",")==-1)||$.alert("NOTE: This version of Opera is known to contain bugs in SVG-edit.\n\t\tPlease upgrade to the <a href='http://opera.com'>latest version</a> in which the problems have been fixed.");
document.createElementNS("http://www.w3.org/2000/svg","path");ba.setAttribute("d","M5,0 15,0");var W=document.createElementNS("http://www.w3.org/2000/svg","g");W.appendChild(fa);W.appendChild(ba);pa.appendChild(W);fa=W.getBBox();document.documentElement.removeChild(pa);return fa.width==15}(),X=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","rect");pa.setAttribute("x",0.1);(pa=pa.cloneNode(false).getAttribute("x").indexOf(",")==-1)||$.alert("NOTE: This version of Opera is known to contain bugs in SVG-edit.\n\t\tPlease upgrade to the <a href='http://opera.com'>latest version</a> in which the problems have been fixed.");
return pa}(),O=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","rect");pa.setAttribute("style","vector-effect:non-scaling-stroke");return pa.style.vectorEffect==="non-scaling-stroke"}(),ia=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","rect").transform.baseVal,fa=g.createSVGTransform();pa.appendItem(fa);return pa.getItem(0)==fa}();svgedit.browser.isOpera=function(){return c};svgedit.browser.isWebkit=function(){return n};svgedit.browser.isGecko=function(){return s};
svgedit.browser.isIE=function(){return b};svgedit.browser.isChrome=function(){return f};svgedit.browser.isWindows=function(){return d};svgedit.browser.isMac=function(){return l};svgedit.browser.isTouch=function(){return q};svgedit.browser.supportsSelectors=function(){return B};svgedit.browser.supportsXpath=function(){return o};svgedit.browser.supportsPathReplaceItem=function(){return K};svgedit.browser.supportsPathInsertItemBefore=function(){return T};svgedit.browser.supportsPathBBox=function(){return J};
svgedit.browser.supportsHVLineContainerBBox=function(){return Q};svgedit.browser.supportsGoodTextCharPos=function(){return M};svgedit.browser.supportsEditableText=function(){return c};svgedit.browser.supportsGoodDecimals=function(){return Y};svgedit.browser.supportsNonScalingStroke=function(){return O};svgedit.browser.supportsNativeTransformLists=function(){return ia}}else window.location="browser-not-supported.html"})();svgedit=svgedit||{};
svgedit.browser.supportsHVLineContainerBBox=function(){return Q};svgedit.browser.supportsGoodTextCharPos=function(){return M};svgedit.browser.supportsEditableText=function(){return c};svgedit.browser.supportsGoodDecimals=function(){return X};svgedit.browser.supportsNonScalingStroke=function(){return O};svgedit.browser.supportsNativeTransformLists=function(){return ia}}else window.location="browser-not-supported.html"})();svgedit=svgedit||{};
(function(){if(!svgedit.transformlist)svgedit.transformlist={};var a=document.createElementNS("http://www.w3.org/2000/svg","svg"),p={};svgedit.transformlist.SVGTransformList=function(g){this._elem=g||null;this._xforms=[];this._update=function(){var c="";a.createSVGMatrix();for(var n=0;n<this.numberOfItems;++n){var s=this._list.getItem(n);c=c;s=s;var b=s.matrix,f="";switch(s.type){case 1:f="matrix("+[b.a,b.b,b.c,b.d,b.e,b.f].join(",")+")";break;case 2:f="translate("+b.e+","+b.f+")";break;case 3:f=
b.a==b.d?"scale("+b.a+")":"scale("+b.a+","+b.d+")";break;case 4:var d=0;f=0;if(s.angle!=0){d=1-b.a;f=(d*b.f+b.b*b.e)/(d*d+b.b*b.b);d=(b.e-b.b*f)/d}f="rotate("+s.angle+" "+d+","+f+")"}c=c+(f+" ")}this._elem.setAttribute("transform",c)};this._list=this;this._init=function(){var c=this._elem.getAttribute("transform");if(c)for(var n=/\s*((scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/,s=true;s;){s=c.match(n);c=c.replace(n,"");if(s&&s[1]){var b=s[1].split(/\s*\(/),f=b[0];b=b[1].match(/\s*(.*?)\s*\)/);
b[1]=b[1].replace(/(\d)-/g,"$1 -");var d=b[1].split(/[, ]+/),l="abcdef".split(""),q=a.createSVGMatrix();$.each(d,function(K,T){d[K]=parseFloat(T);if(f=="matrix")q[l[K]]=d[K]});b=a.createSVGTransform();var B="set"+f.charAt(0).toUpperCase()+f.slice(1),o=f=="matrix"?[q]:d;if(f=="scale"&&o.length==1)o.push(o[0]);else if(f=="translate"&&o.length==1)o.push(0);else if(f=="rotate"&&o.length==1){o.push(0);o.push(0)}b[B].apply(b,o);this._list.appendItem(b)}}};this._removeFromOtherLists=function(c){if(c){var n=
@ -93,8 +93,8 @@ d=d<<2|l>>4;l=(l&15)<<4|B>>2;q=(B&3)<<6|o;f+=String.fromCharCode(d);if(B!=64)f+=
new DOMParser:new ActiveXObject("Microsoft.XMLDOM");d.async=false}catch(l){throw Error("XML Parser could not be instantiated");}try{f=d.loadXML?d.loadXML(b)?d:false:d.parseFromString(b,"text/xml")}catch(q){throw Error("Error parsing XML string");}return f};svgedit.utilities.bboxToObj=function(b){return{x:b.x,y:b.y,width:b.width,height:b.height}};svgedit.utilities.walkTree=function(b,f){if(b&&b.nodeType==1){f(b);for(var d=b.childNodes.length;d--;)svgedit.utilities.walkTree(b.childNodes.item(d),f)}};
svgedit.utilities.walkTreePost=function(b,f){if(b&&b.nodeType==1){for(var d=b.childNodes.length;d--;)svgedit.utilities.walkTree(b.childNodes.item(d),f);f(b)}};svgedit.utilities.getUrlFromAttr=function(b){if(b)if(b.indexOf('url("')===0)return b.substring(5,b.indexOf('"',6));else if(b.indexOf("url('")===0)return b.substring(5,b.indexOf("'",6));else if(b.indexOf("url(")===0)return b.substring(4,b.indexOf(")"));return null};svgedit.utilities.getHref=function(b){return b.getAttributeNS("http://www.w3.org/1999/xlink",
"href")};svgedit.utilities.setHref=function(b,f){b.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",f)};svgedit.utilities.findDefs=function(b){b=g.getSVGContent().documentElement;var f=b.getElementsByTagNameNS("http://www.w3.org/2000/svg","defs");return f=f.length>0?f[0]:b.insertBefore(b.ownerDocument.createElementNS("http://www.w3.org/2000/svg","defs"),b.firstChild.nextSibling)};svgedit.utilities.getPathBBox=function(b){var f=b.pathSegList,d=f.numberOfItems;b=[[],[]];var l=f.getItem(0),
q=[l.x,l.y];for(l=0;l<d;l++){var B=f.getItem(l);if(typeof B.x!="undefined"){b[0].push(q[0]);b[1].push(q[1]);if(B.x1){for(var o=[B.x1,B.y1],K=[B.x2,B.y2],T=[B.x,B.y],M=0;M<2;M++){B=function(ia){return Math.pow(1-ia,3)*q[M]+3*Math.pow(1-ia,2)*ia*o[M]+3*(1-ia)*Math.pow(ia,2)*K[M]+Math.pow(ia,3)*T[M]};var J=6*q[M]-12*o[M]+6*K[M],Q=-3*q[M]+9*o[M]-9*K[M]+3*T[M],Y=3*o[M]-3*q[M];if(Q==0){if(J!=0){J=-Y/J;0<J&&J<1&&b[M].push(B(J))}}else{Y=Math.pow(J,2)-4*Y*Q;if(!(Y<0)){var O=(-J+Math.sqrt(Y))/(2*Q);0<O&&O<
1&&b[M].push(B(O));J=(-J-Math.sqrt(Y))/(2*Q);0<J&&J<1&&b[M].push(B(J))}}}q=T}else{b[0].push(B.x);b[1].push(B.y)}}}f=Math.min.apply(null,b[0]);d=Math.max.apply(null,b[0])-f;l=Math.min.apply(null,b[1]);b=Math.max.apply(null,b[1])-l;return{x:f,y:l,width:d,height:b}};svgedit.utilities.getBBox=function(b){var f=b||g.geSelectedElements()[0];if(b.nodeType!=1)return null;b=null;var d=f.nodeName;switch(d){case "text":if(f.textContent===""){f.textContent="a";b=f.getBBox();f.textContent=""}else try{b=f.getBBox()}catch(l){}break;
q=[l.x,l.y];for(l=0;l<d;l++){var B=f.getItem(l);if(typeof B.x!="undefined"){b[0].push(q[0]);b[1].push(q[1]);if(B.x1){for(var o=[B.x1,B.y1],K=[B.x2,B.y2],T=[B.x,B.y],M=0;M<2;M++){B=function(ia){return Math.pow(1-ia,3)*q[M]+3*Math.pow(1-ia,2)*ia*o[M]+3*(1-ia)*Math.pow(ia,2)*K[M]+Math.pow(ia,3)*T[M]};var J=6*q[M]-12*o[M]+6*K[M],Q=-3*q[M]+9*o[M]-9*K[M]+3*T[M],X=3*o[M]-3*q[M];if(Q==0){if(J!=0){J=-X/J;0<J&&J<1&&b[M].push(B(J))}}else{X=Math.pow(J,2)-4*X*Q;if(!(X<0)){var O=(-J+Math.sqrt(X))/(2*Q);0<O&&O<
1&&b[M].push(B(O));J=(-J-Math.sqrt(X))/(2*Q);0<J&&J<1&&b[M].push(B(J))}}}q=T}else{b[0].push(B.x);b[1].push(B.y)}}}f=Math.min.apply(null,b[0]);d=Math.max.apply(null,b[0])-f;l=Math.min.apply(null,b[1]);b=Math.max.apply(null,b[1])-l;return{x:f,y:l,width:d,height:b}};svgedit.utilities.getBBox=function(b){var f=b||g.geSelectedElements()[0];if(b.nodeType!=1)return null;b=null;var d=f.nodeName;switch(d){case "text":if(f.textContent===""){f.textContent="a";b=f.getBBox();f.textContent=""}else try{b=f.getBBox()}catch(l){}break;
case "path":if(svgedit.browser.supportsPathBBox())try{b=f.getBBox()}catch(q){}else b=svgedit.utilities.getPathBBox(f);break;case "g":case "a":b=a(f);break;default:if(d==="use")b=a(f,true);if(d==="use"){b||(b=f.getBBox());if(!svgedit.browser.isWebkit()){d={};d.width=b.width;d.height=b.height;d.x=b.x+parseFloat(f.getAttribute("x")||0);d.y=b.y+parseFloat(f.getAttribute("y")||0);b=d}}else if(~p.indexOf(d))try{b=f.getBBox()}catch(B){f=$(f).closest("foreignObject");if(f.length)try{b=f[0].getBBox()}catch(o){b=
null}else b=null}}if(b)b=svgedit.utilities.bboxToObj(b);return b};svgedit.utilities.getRotationAngle=function(b,f){var d=b||g.getSelectedElements()[0];d=svgedit.transformlist.getTransformList(d);if(!d)return 0;for(var l=d.numberOfItems,q=0;q<l;++q){var B=d.getItem(q);if(B.type==4)return f?B.angle*Math.PI/180:B.angle}return 0};svgedit.utilities.getElem=svgedit.browser.supportsSelectors()?function(b){return s.querySelector("#"+b)}:svgedit.browser.supportsXpath()?function(b){return c.evaluate('svg:svg[@id="svgroot"]//svg:*[@id="'+
b+'"]',n,function(){return"http://www.w3.org/2000/svg"},9,null).singleNodeValue}:function(b){return $(s).find("[id="+b+"]")[0]};svgedit.utilities.assignAttributes=function(b,f,d,l){d||(d=0);svgedit.browser.isOpera()||s.suspendRedraw(d);for(var q in f)if(d=q.substr(0,4)==="xml:"?"http://www.w3.org/XML/1998/namespace":q.substr(0,6)==="xlink:"?"http://www.w3.org/1999/xlink":null)b.setAttributeNS(d,q,f[q]);else l?svgedit.units.setUnitAttr(b,q,f[q]):b.setAttribute(q,f[q]);svgedit.browser.isOpera()||s.unsuspendRedraw(null)};
@ -183,8 +183,8 @@ this.next.index,l)}if(this.mate){l=this.mate.item;l=[l.x+=f,l.y+=d];svgedit.path
svgedit.path.Segment.prototype.moveCtrl=function(f,d,l){var q=this.item;q["x"+f]+=d;q["y"+f]+=l;svgedit.path.replacePathSeg(this.type,this.index,[q.x,q.y,q.x1,q.y1,q.x2,q.y2]);this.update(true)};svgedit.path.Segment.prototype.setType=function(f,d){svgedit.path.replacePathSeg(f,this.index,d);this.type=f;this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.showCtrlPts(f===6);this.ctrlpts=svgedit.path.getControlPoints(this);this.update(true)};svgedit.path.Path=function(f){if(!f||f.tagName!==
"path")throw"svgedit.path.Path constructed without a <path> element";this.elem=f;this.segs=[];this.selected_pts=[];svgedit.path.path=this;this.init()};svgedit.path.Path.prototype.init=function(){$(svgedit.path.getGripContainer()).find("*").attr("display","none");var f=this.elem.pathSegList,d=f.numberOfItems;this.segs=[];this.selected_pts=[];this.first_seg=null;for(var l=0;l<d;l++){var q=f.getItem(l);q=new svgedit.path.Segment(l,q);q.path=this;this.segs.push(q)}f=this.segs;q=null;for(l=0;l<d;l++){var B=
f[l],o=l+1>=d?null:f[l+1],K=l-1<0?null:f[l-1];if(B.type===2){if(K&&K.type!==1){o=f[q];o.next=f[q+1];o.next.prev=o;o.addGrip()}q=l}else if(o&&o.type===1){B.next=f[q+1];B.next.prev=B;B.mate=f[q];B.addGrip();if(this.first_seg==null)this.first_seg=B}else if(o){if(B.type!==1){B.addGrip();if(o&&o.type!==2){B.next=o;B.next.prev=B}}}else if(B.type!==1){o=f[q];o.next=f[q+1];o.next.prev=o;o.addGrip();B.addGrip();if(!this.first_seg)this.first_seg=f[q]}}return this};svgedit.path.Path.prototype.eachSeg=function(f){for(var d=
this.segs.length,l=0;l<d;l++)if(f.call(this.segs[l],l)===false)break};svgedit.path.Path.prototype.addSeg=function(f){var d=this.segs[f];if(d.prev){var l=d.prev,q;switch(d.item.pathSegType){case 4:var B=(d.item.x+l.item.x)/2,o=(d.item.y+l.item.y)/2;q=this.elem.createSVGPathSegLinetoAbs(B,o);break;case 6:q=(l.item.x+d.item.x1)/2;var K=(d.item.x1+d.item.x2)/2,T=(d.item.x2+d.item.x)/2,M=(q+K)/2;K=(K+T)/2;B=(M+K)/2;var J=(l.item.y+d.item.y1)/2,Q=(d.item.y1+d.item.y2)/2;l=(d.item.y2+d.item.y)/2;var Y=(J+
Q)/2;Q=(Q+l)/2;o=(Y+Q)/2;q=this.elem.createSVGPathSegCurvetoCubicAbs(B,o,q,J,M,Y);svgedit.path.replacePathSeg(d.type,f,[d.item.x,d.item.y,K,Q,T,l])}svgedit.path.insertItemBefore(this.elem,q,f)}};svgedit.path.Path.prototype.deleteSeg=function(f){var d=this.segs[f],l=this.elem.pathSegList;d.show(false);var q=d.next;if(d.mate){var B=[q.item.x,q.item.y];svgedit.path.replacePathSeg(2,q.index,B);svgedit.path.replacePathSeg(4,d.index,B);l.removeItem(d.mate.index)}else{if(!d.prev){B=[q.item.x,q.item.y];svgedit.path.replacePathSeg(2,
this.segs.length,l=0;l<d;l++)if(f.call(this.segs[l],l)===false)break};svgedit.path.Path.prototype.addSeg=function(f){var d=this.segs[f];if(d.prev){var l=d.prev,q;switch(d.item.pathSegType){case 4:var B=(d.item.x+l.item.x)/2,o=(d.item.y+l.item.y)/2;q=this.elem.createSVGPathSegLinetoAbs(B,o);break;case 6:q=(l.item.x+d.item.x1)/2;var K=(d.item.x1+d.item.x2)/2,T=(d.item.x2+d.item.x)/2,M=(q+K)/2;K=(K+T)/2;B=(M+K)/2;var J=(l.item.y+d.item.y1)/2,Q=(d.item.y1+d.item.y2)/2;l=(d.item.y2+d.item.y)/2;var X=(J+
Q)/2;Q=(Q+l)/2;o=(X+Q)/2;q=this.elem.createSVGPathSegCurvetoCubicAbs(B,o,q,J,M,X);svgedit.path.replacePathSeg(d.type,f,[d.item.x,d.item.y,K,Q,T,l])}svgedit.path.insertItemBefore(this.elem,q,f)}};svgedit.path.Path.prototype.deleteSeg=function(f){var d=this.segs[f],l=this.elem.pathSegList;d.show(false);var q=d.next;if(d.mate){var B=[q.item.x,q.item.y];svgedit.path.replacePathSeg(2,q.index,B);svgedit.path.replacePathSeg(4,d.index,B);l.removeItem(d.mate.index)}else{if(!d.prev){B=[q.item.x,q.item.y];svgedit.path.replacePathSeg(2,
d.next.index,B)}l.removeItem(f)}};svgedit.path.Path.prototype.subpathIsClosed=function(f){var d=false;svgedit.path.path.eachSeg(function(l){if(l<=f)return true;if(this.type===2)return false;else if(this.type===1){d=true;return false}});return d};svgedit.path.Path.prototype.removePtFromSelection=function(f){var d=this.selected_pts.indexOf(f);if(d!=-1){this.segs[f].select(false);this.selected_pts.splice(d,1)}};svgedit.path.Path.prototype.clearSelection=function(){this.eachSeg(function(){this.select(false)});
this.selected_pts=[]};svgedit.path.Path.prototype.storeD=function(){this.last_d=this.elem.getAttribute("d")};svgedit.path.Path.prototype.show=function(f){this.eachSeg(function(){this.show(f)});f&&this.selectPt(this.first_seg.index);return this};svgedit.path.Path.prototype.movePts=function(f,d){for(var l=this.selected_pts.length;l--;)this.segs[this.selected_pts[l]].move(f,d)};svgedit.path.Path.prototype.moveCtrl=function(f,d){var l=this.segs[this.selected_pts[0]];l.moveCtrl(this.dragctrl,f,d);c&&l.setLinked(this.dragctrl)};
svgedit.path.Path.prototype.setSegType=function(f){this.storeD();for(var d=this.selected_pts.length,l;d--;){var q=this.segs[this.selected_pts[d]],B=q.prev;if(B){if(!f){l="Toggle Path Segment Type";f=q.type==6?4:6}f-=0;var o=q.item.x,K=q.item.y,T=B.item.x;B=B.item.y;var M;switch(f){case 6:if(q.olditem){T=q.olditem;M=[o,K,T.x1,T.y1,T.x2,T.y2]}else{M=o-T;var J=K-B;M=[o,K,T+M/3,B+J/3,o-M/3,K-J/3]}break;case 4:M=[o,K];q.olditem=q.item}q.setType(f,M)}}svgedit.path.path.endChanges(l)};svgedit.path.Path.prototype.selectPt=
@ -199,150 +199,150 @@ H=H.cloneNode(true);$(H).attr(F);H.id=ja();lb().appendChild(H);e.setAttribute(w,
true);a.appendChild(d);var l=f.createElementNS(c,"svg");(b.clearSvgContentElement=function(){for(;l.firstChild;)l.removeChild(l.firstChild);$(l).attr({id:"svgcontent",width:s[0],height:s[1],x:s[0],y:s[1],overflow:n.show_outside_canvas?"visible":"hidden",xmlns:c,"xmlns:se":"http://svg-edit.googlecode.com","xmlns:xlink":"http://www.w3.org/1999/xlink"}).appendTo(d);var e=f.createComment(" Created with Method Draw - http://github.com/duopixel/Method-Draw/ ");l.appendChild(e)})();var q="svg_";b.setIdPrefix=
function(e){q=e};b.current_drawing_=new svgedit.draw.Drawing(l,q);var B=b.getCurrentDrawing=function(){return b.current_drawing_},o=1,K=null,T={shape:{fill:(n.initFill.color=="none"?"":"#")+n.initFill.color,fill_paint:null,fill_opacity:n.initFill.opacity,stroke:"#"+n.initStroke.color,stroke_paint:null,stroke_opacity:n.initStroke.opacity,stroke_width:n.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:n.initOpacity}};T.text=$.extend(true,{},T.shape);$.extend(T.text,
{fill:"#000000",stroke_width:0,font_size:24,font_family:"Helvetica, Arial, sans-serif"});var M=T.shape,J=Array(1),Q=this.addSvgElementFromJson=function(e){var h=svgedit.utilities.getElem(e.attr.id),m=B().getCurrentLayer();if(h&&e.element!=h.tagName){m.removeChild(h);h=null}if(!h){h=f.createElementNS(c,e.element);if(m)(K||m).appendChild(h)}e.curStyles&&svgedit.utilities.assignAttributes(h,{fill:M.fill,stroke:M.stroke,"stroke-width":M.stroke_width,"stroke-dasharray":M.stroke_dasharray,"stroke-linejoin":M.stroke_linejoin,
"stroke-linecap":M.stroke_linecap,"stroke-opacity":M.stroke_opacity,"fill-opacity":M.fill_opacity,opacity:M.opacity/2,style:"pointer-events:inherit"},100);svgedit.utilities.assignAttributes(h,e.attr,100);svgedit.utilities.cleanupElement(h);return h},Y=b.getTransformList=svgedit.transformlist.getTransformList,O=svgedit.math.transformPoint,ia=b.matrixMultiply=svgedit.math.matrixMultiply,pa=b.hasMatrixTransform=svgedit.math.hasMatrixTransform,fa=b.transformListToTransform=svgedit.math.transformListToTransform,
"stroke-linecap":M.stroke_linecap,"stroke-opacity":M.stroke_opacity,"fill-opacity":M.fill_opacity,opacity:M.opacity/2,style:"pointer-events:inherit"},100);svgedit.utilities.assignAttributes(h,e.attr,100);svgedit.utilities.cleanupElement(h);return h},X=b.getTransformList=svgedit.transformlist.getTransformList,O=svgedit.math.transformPoint,ia=b.matrixMultiply=svgedit.math.matrixMultiply,pa=b.hasMatrixTransform=svgedit.math.hasMatrixTransform,fa=b.transformListToTransform=svgedit.math.transformListToTransform,
ba=svgedit.math.snapToAngle,W=svgedit.math.getMatrix;svgedit.units.init({getBaseUnit:function(){return n.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return l.getAttribute("height")/o},getWidth:function(){return l.getAttribute("width")/o},getRoundDigits:function(){return fb.round_digits}});var sa=b.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return f},getDOMContainer:function(){return a},getSVGRoot:function(){return d},getSelectedElements:function(){return J},
getSVGContent:function(){return l}});var ka=b.getUrlFromAttr=svgedit.utilities.getUrlFromAttr,da=b.getHref=svgedit.utilities.getHref,V=b.setHref=svgedit.utilities.setHref,Z=svgedit.utilities.getPathBBox;b.getBBox=svgedit.utilities.getBBox;var oa=b.getRotationAngle=svgedit.utilities.getRotationAngle,qa=b.getElem=svgedit.utilities.getElem,ma=b.assignAttributes=svgedit.utilities.assignAttributes,na=this.cleanupElement=svgedit.utilities.cleanupElement,Aa=svgedit.sanitize.getNSMap(),Fa=b.sanitizeSvg=svgedit.sanitize.sanitizeSvg,
Ia=svgedit.history.MoveElementCommand,Ca=svgedit.history.InsertElementCommand,Ka=svgedit.history.RemoveElementCommand,Na=svgedit.history.ChangeElementCommand,za=svgedit.history.BatchCommand;b.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(e,h){var m=svgedit.history.HistoryEventTypes;if(e==m.BEFORE_UNAPPLY||e==m.BEFORE_APPLY)b.clearSelection();else if(e==m.AFTER_APPLY||e==m.AFTER_UNAPPLY){var z=h.elements();b.pathActions.clear();N("changed",z);z=h.type();m=e==m.AFTER_APPLY;if(z==
Ia.type()){m=m?h.newParent:h.oldParent;m==l&&b.identifyLayers()}else if(z==Ca.type()||z==Ka.type()){h.parent==l&&b.identifyLayers();if(z==Ca.type())m&&Va(h.elem);else m||Va(h.elem);h.elem.tagName==="use"&&Lb(h.elem)}else if(z==Na.type()){h.elem.tagName=="title"&&h.elem.parentNode.parentNode==l&&b.identifyLayers();m=m?h.newValues:h.oldValues;m.stdDeviation&&b.setBlurOffsets(h.elem.parentNode,m.stdDeviation);if(h.elem.tagName==="use"&&svgedit.browser.isWebkit()){z=h.elem;if(!z.getAttribute("x")&&!z.getAttribute("y")){m=
Ia.type()){m=m?h.newParent:h.oldParent;m==l&&b.identifyLayers()}else if(z==Ca.type()||z==Ka.type()){h.parent==l&&b.identifyLayers();if(z==Ca.type())m&&Wa(h.elem);else m||Wa(h.elem);h.elem.tagName==="use"&&Lb(h.elem)}else if(z==Na.type()){h.elem.tagName=="title"&&h.elem.parentNode.parentNode==l&&b.identifyLayers();m=m?h.newValues:h.oldValues;m.stdDeviation&&b.setBlurOffsets(h.elem.parentNode,m.stdDeviation);if(h.elem.tagName==="use"&&svgedit.browser.isWebkit()){z=h.elem;if(!z.getAttribute("x")&&!z.getAttribute("y")){m=
z.parentNode;var w=z.nextSibling;m.removeChild(z);m.insertBefore(z,w)}}}}}});var ya=function(e){b.undoMgr.addCommandToHistory(e)};svgedit.select.init(n,{createSVGElement:function(e){return b.addSvgElementFromJson(e)},svgRoot:function(){return d},svgContent:function(){return l},currentZoom:function(){return o},getStrokedBBox:function(e){return b.getStrokedBBox([e])}});var Ha=this.selectorManager=svgedit.select.getSelectorManager();svgedit.path.init({getCurrentZoom:function(){return o},getSVGRoot:function(){return d}});
svgedit.utilities.snapToGrid=function(e){var h=n.snappingStep,m=n.baseUnit;if(m!=="px")h*=svgedit.units.getTypeMap()[m];return e=Math.round(e/h)*h};var wa=svgedit.utilities.snapToGrid,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"},$a=["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],ib=$.data,
Va=function(e){var h=$(e).attr($a),m;for(m in h){var z=h[m];if(z&&z.indexOf("url(")===0){z=ka(z).substr(1);if(!qa(z)){lb().appendChild(zb[z]);delete zb[z]}}}e=e.getElementsByTagName("*");if(e.length){h=0;for(m=e.length;h<m;h++)Va(e[h])}},Ra={},Da=n.imgPath+"logo.png",va=[],fb={round_digits:5},La=false,Ua=null,Ea="select",kb="none",sb={},Za=T.text,bb=M,Cb=null,ta=null,mb=[],jb={},zb={};b.clipBoard=[];var ob=this.runExtensions=function(e,h,m){var z=false;if(m)z=[];$.each(jb,function(w,H){if(e in H)if(m)z.push(H[e](h));
else z=H[e](h)});return z};this.addExtension=function(e,h){if(e in jb)console.log('Cannot add extension "'+e+'", an extension by that name already exists"');else{var m=$.isFunction(h)?h($.extend(b.getPrivateMethods(),{svgroot:d,svgcontent:l,nonce:B().getNonce(),selectorManager:Ha})):h;jb[e]=m;N("extension_added",m)}};var eb=this.round=function(e){return parseInt(e*o)/o},tb=this.getIntersectionList=function(e){if(ta==null)return null;var h=K||B().getCurrentLayer();mb.length||(mb=wb(h));var m=null;
try{m=h.getIntersectionList(e,null)}catch(z){}if(m==null||typeof m.item!="function"){m=[];if(e)e=e;else{e=ta.getBBox();h={};for(var w in e)h[w]=e[w]/o;e=h}for(w=mb.length;w--;)e.width&&e.width&&svgedit.math.rectsIntersect(e,mb[w].bbox)&&m.push(mb[w].elem)}return m};getStrokedBBox=this.getStrokedBBox=function(e){e||(e=ub());if(!e.length)return false;var h=function(I){try{var D=svgedit.utilities.getBBox(I),G=svgedit.utilities.getRotationAngle(I);if(G&&G%90||svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(I))){G=
false;if(["ellipse","path","line","polyline","polygon"].indexOf(I.tagName)>=0)D=G=b.convertToPath(I,true);else if(I.tagName=="rect"){var L=I.getAttribute("rx"),k=I.getAttribute("ry");if(L||k)D=G=b.convertToPath(I,true)}if(!G){var u=I.cloneNode(true),C=document.createElementNS(c,"g"),E=I.parentNode;E.appendChild(C);C.appendChild(u);D=svgedit.utilities.bboxToObj(C.getBBox());E.removeChild(C)}}return D}catch(P){console.log(I,P);return null}},m;$.each(e,function(){if(!m)if(this.parentNode)m=h(this)});
if(m==null)return null;var z=m.x+m.width,w=m.y+m.height,H=m.x,A=m.y,v=function(I){var D=I.getAttribute("stroke-width"),G=0;if(I.getAttribute("stroke")!="none"&&!isNaN(D))G+=D/2;return G},F=[];$.each(e,function(I,D){var G=h(D);if(G){var L=v(D);H=Math.min(H,G.x-L);A=Math.min(A,G.y-L);F.push(G)}});m.x=H;m.y=A;$.each(e,function(I,D){var G=F[I];if(G&&D.nodeType==1){var L=v(D);z=Math.max(z,G.x+G.width+L);w=Math.max(w,G.y+G.height+L)}});m.width=z-H;m.height=w-A;return m};var ub=this.getVisibleElements=function(e){e||
(e=$(l).children());e.find("#canvas_background").length&&e.splice(0,1);var h=[];$(e).children().each(function(m,z){try{z.getBBox()&&h.push(z)}catch(w){}});return h.reverse()},wb=this.getVisibleElementsAndBBoxes=function(e){e||(e=$(l).children());var h=[];$(e).children().each(function(m,z){try{z.getBBox()&&h.push({elem:z,bbox:getStrokedBBox([z])})}catch(w){}});return h.reverse()},Ab=this.groupSvgElem=function(e){var h=document.createElementNS(c,"g");e.parentNode.replaceChild(h,e);$(h).append(e).data("gsvg",
Wa=function(e){var h=$(e).attr($a),m;for(m in h){var z=h[m];if(z&&z.indexOf("url(")===0){z=ka(z).substr(1);if(!qa(z)){lb().appendChild(Ab[z]);delete Ab[z]}}}e=e.getElementsByTagName("*");if(e.length){h=0;for(m=e.length;h<m;h++)Wa(e[h])}},Sa={},Da=n.imgPath+"logo.png",va=[],fb={round_digits:5},La=false,Va=null,Ea="select",kb="none",sb={},Za=T.text,bb=M,Cb=null,ua=null,mb=[],jb={},Ab={};b.clipBoard=[];var ob=this.runExtensions=function(e,h,m){var z=false;if(m)z=[];$.each(jb,function(w,H){if(e in H)if(m)z.push(H[e](h));
else z=H[e](h)});return z};this.addExtension=function(e,h){if(e in jb)console.log('Cannot add extension "'+e+'", an extension by that name already exists"');else{var m=$.isFunction(h)?h($.extend(b.getPrivateMethods(),{svgroot:d,svgcontent:l,nonce:B().getNonce(),selectorManager:Ha})):h;jb[e]=m;N("extension_added",m)}};var eb=this.round=function(e){return parseInt(e*o)/o},tb=this.getIntersectionList=function(e){if(ua==null)return null;var h=K||B().getCurrentLayer();mb.length||(mb=wb(h));var m=null;
try{m=h.getIntersectionList(e,null)}catch(z){}if(m==null||typeof m.item!="function"){m=[];if(e)e=e;else{e=ua.getBBox();h={};for(var w in e)h[w]=e[w]/o;e=h}for(w=mb.length;w--;)e.width&&e.width&&svgedit.math.rectsIntersect(e,mb[w].bbox)&&m.push(mb[w].elem)}return m};getStrokedBBox=this.getStrokedBBox=function(e){e||(e=ub());if(!e.length)return false;var h=function(I){try{var E=svgedit.utilities.getBBox(I),G=svgedit.utilities.getRotationAngle(I);if(G&&G%90||svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(I))){G=
false;if(["ellipse","path","line","polyline","polygon"].indexOf(I.tagName)>=0)E=G=b.convertToPath(I,true);else if(I.tagName=="rect"){var L=I.getAttribute("rx"),k=I.getAttribute("ry");if(L||k)E=G=b.convertToPath(I,true)}if(!G){var u=I.cloneNode(true),C=document.createElementNS(c,"g"),D=I.parentNode;D.appendChild(C);C.appendChild(u);E=svgedit.utilities.bboxToObj(C.getBBox());D.removeChild(C)}}return E}catch(P){console.log(I,P);return null}},m;$.each(e,function(){if(!m)if(this.parentNode)m=h(this)});
if(m==null)return null;var z=m.x+m.width,w=m.y+m.height,H=m.x,A=m.y,v=function(I){var E=I.getAttribute("stroke-width"),G=0;if(I.getAttribute("stroke")!="none"&&!isNaN(E))G+=E/2;return G},F=[];$.each(e,function(I,E){var G=h(E);if(G){var L=v(E);H=Math.min(H,G.x-L);A=Math.min(A,G.y-L);F.push(G)}});m.x=H;m.y=A;$.each(e,function(I,E){var G=F[I];if(G&&E.nodeType==1){var L=v(E);z=Math.max(z,G.x+G.width+L);w=Math.max(w,G.y+G.height+L)}});m.width=z-H;m.height=w-A;return m};var ub=this.getVisibleElements=function(e){e||
(e=$(l).children());e.find("#canvas_background").length&&e.splice(0,1);var h=[];$(e).children().each(function(m,z){try{z.getBBox()&&h.push(z)}catch(w){}});return h.reverse()},wb=this.getVisibleElementsAndBBoxes=function(e){e||(e=$(l).children());var h=[];$(e).children().each(function(m,z){try{z.getBBox()&&h.push({elem:z,bbox:getStrokedBBox([z])})}catch(w){}});return h.reverse()},Bb=this.groupSvgElem=function(e){var h=document.createElementNS(c,"g");e.parentNode.replaceChild(h,e);$(h).append(e).data("gsvg",
e)[0].id=ja()},la=function(e){var h=document.createElementNS(e.namespaceURI,e.nodeName);h.removeAttribute("id");$.each(e.attributes,function(z,w){w.localName!="-moz-math-font-style"&&h.setAttributeNS(w.namespaceURI,w.nodeName,w.nodeValue)});if(svgedit.browser.isWebkit()&&e.nodeName=="path"){var m=Ja.convertPath(e);h.setAttribute("d",m)}$.each(e.childNodes,function(z,w){switch(w.nodeType){case 1:h.appendChild(la(w));break;case 3:h.textContent=w.nodeValue}});if($(e).data("gsvg"))$(h).data("gsvg",h.firstChild);
else if($(e).data("symbol")){e=$(e).data("symbol");$(h).data("ref",e).data("symbol",e)}else h.tagName=="image"&&pb(h);h.id=ja();return h},ca,ja,N;(function(e){var h={};ca=e.getId=function(){return B().getId()};ja=e.getNextId=function(){return B().getNextId()};N=e.call=function(m,z){if(h[m])return h[m](this,z)};e.bind=function(m,z){var w=h[m];h[m]=z;return w}})(b);this.prepareSvg=function(e){this.sanitizeSvg(e.documentElement);e=e.getElementsByTagNameNS(c,"path");for(var h=0,m=e.length;h<m;++h){var z=
e[h];z.setAttribute("d",Ja.convertPath(z));Ja.fixEnd(z)}};var R=this.getRefElem=function(e){return qa(ka(e).substr(1))},ea=function(e){if(!svgedit.browser.isGecko())return e;var h=e.cloneNode(true);e.parentNode.insertBefore(h,e);e.parentNode.removeChild(e);Ha.releaseSelector(e);J[0]=h;Ha.requestSelector(h).showGrips(true);return h};this.setRotationAngle=function(e,h){e=parseFloat(e);var m=J[0],z=m.getAttribute("transform"),w=svgedit.utilities.getBBox(m),H=w.x+w.width/2,A=w.y+w.height/2;w=Y(m);w.numberOfItems>
e[h];z.setAttribute("d",Ja.convertPath(z));Ja.fixEnd(z)}};var R=this.getRefElem=function(e){return qa(ka(e).substr(1))},ea=function(e){if(!svgedit.browser.isGecko())return e;var h=e.cloneNode(true);e.parentNode.insertBefore(h,e);e.parentNode.removeChild(e);Ha.releaseSelector(e);J[0]=h;Ha.requestSelector(h).showGrips(true);return h};this.setRotationAngle=function(e,h){e=parseFloat(e);var m=J[0],z=m.getAttribute("transform"),w=svgedit.utilities.getBBox(m),H=w.x+w.width/2,A=w.y+w.height/2;w=X(m);w.numberOfItems>
0&&w.getItem(0).type==4&&w.removeItem(0);if(e!=0){H=O(H,A,fa(w).matrix);A=d.createSVGTransform();A.setRotate(e,H.x,H.y);w.numberOfItems?w.insertItemBefore(A,0):w.appendItem(A)}else w.numberOfItems==0&&m.removeAttribute("transform");if(!h){w=m.getAttribute("transform");m.setAttribute("transform",z);gb("transform",w,J);N("changed",J)}qa("pathpointgrip_container");m=Ha.requestSelector(J[0]);m.resize();m.updateGripCursors(e)};var Ga=this.recalculateAllSelectedDimensions=function(){for(var e=new za(kb==
"none"?"position":"size"),h=J.length;h--;){var m=Xa(J[h]);m&&e.addSubCommand(m)}if(!e.isEmpty()){ya(e);N("changed",J)}},Oa=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],Ya=function(e){console.log([e.a,e.b,e.c,e.d,e.e,e.f])},db=this.remapElement=function(e,h,m){var z=n.gridSnapping&&e.parentNode.parentNode.localName==="svg",w=function(){if(z)for(var G in h)h[G]=wa(h[G]);ma(e,h,1E3,true)};box=svgedit.utilities.getBBox(e);for(var H=0;H<2;H++){var A=H===0?"fill":"stroke",
"none"?"position":"size"),h=J.length;h--;){var m=Ua(J[h]);m&&e.addSubCommand(m)}if(!e.isEmpty()){ya(e);N("changed",J)}},Pa=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],Ya=function(e){console.log([e.a,e.b,e.c,e.d,e.e,e.f])},db=this.remapElement=function(e,h,m){var z=n.gridSnapping&&e.parentNode.parentNode.localName==="svg",w=function(){if(z)for(var G in h)h[G]=wa(h[G]);ma(e,h,1E3,true)};box=svgedit.utilities.getBBox(e);for(var H=0;H<2;H++){var A=H===0?"fill":"stroke",
v=e.getAttribute(A);if(v&&v.indexOf("url(")===0)if(m.a<0||m.d<0){v=R(v).cloneNode(true);if(m.a<0){var F=v.getAttribute("x1"),I=v.getAttribute("x2");v.setAttribute("x1",-(F-1));v.setAttribute("x2",-(I-1))}if(m.d<0){F=v.getAttribute("y1");I=v.getAttribute("y2");v.setAttribute("y1",-(F-1));v.setAttribute("y2",-(I-1))}v.id=ja();lb().appendChild(v);e.setAttribute(A,"url(#"+v.id+")")}}H=e.tagName;if(H==="g"||H==="text"||H==="use")if(m.a==1&&m.b==0&&m.c==0&&m.d==1&&(m.e!=0||m.f!=0)){A=fa(e).matrix;A=ia(A.inverse(),
m,A);h.x=parseFloat(h.x)+A.e;h.y=parseFloat(h.y)+A.f}else{A=Y(e);v=d.createSVGTransform();v.setMatrix(ia(fa(A).matrix,m));A.clear();A.appendItem(v)}switch(H){case "foreignObject":case "rect":case "image":if(H==="image"&&(m.a<0||m.d<0)){A=Y(e);v=d.createSVGTransform();v.setMatrix(ia(fa(A).matrix,m));A.clear();A.appendItem(v)}else{A=O(h.x,h.y,m);h.width=m.a*h.width;h.height=m.d*h.height;h.x=A.x+Math.min(0,h.width);h.y=A.y+Math.min(0,h.height);h.width=Math.abs(h.width);h.height=Math.abs(h.height)}w();
m,A);h.x=parseFloat(h.x)+A.e;h.y=parseFloat(h.y)+A.f}else{A=X(e);v=d.createSVGTransform();v.setMatrix(ia(fa(A).matrix,m));A.clear();A.appendItem(v)}switch(H){case "foreignObject":case "rect":case "image":if(H==="image"&&(m.a<0||m.d<0)){A=X(e);v=d.createSVGTransform();v.setMatrix(ia(fa(A).matrix,m));A.clear();A.appendItem(v)}else{A=O(h.x,h.y,m);h.width=m.a*h.width;h.height=m.d*h.height;h.x=A.x+Math.min(0,h.width);h.y=A.y+Math.min(0,h.height);h.width=Math.abs(h.width);h.height=Math.abs(h.height)}w();
break;case "ellipse":H=O(h.cx,h.cy,m);h.cx=H.x;h.cy=H.y;h.rx=m.a*h.rx;h.ry=m.d*h.ry;h.rx=Math.abs(h.rx);h.ry=Math.abs(h.ry);w();break;case "circle":H=O(h.cx,h.cy,m);h.cx=H.x;h.cy=H.y;H=svgedit.math.transformBox(box.x,box.y,box.width,box.height,m);h.r=Math.min((H.tr.x-H.tl.x)/2,(H.bl.y-H.tl.y)/2);if(h.r)h.r=Math.abs(h.r);w();break;case "line":A=O(h.x1,h.y1,m);F=O(h.x2,h.y2,m);h.x1=A.x;h.y1=A.y;h.x2=F.x;h.y2=F.y;case "text":m=e.querySelectorAll("tspan");for(H=m.length;H--;){A=sa("x",e.getAttribute("x"));
v=sa("x",m[H].getAttribute("x"));F=sa("y",e.getAttribute("y"));I=sa("y",m[H].getAttribute("y"));var D={};if(!isNaN(A)&&!isNaN(v)&&A!=0&&v!=0&&h.x)D.x=h.x-(A-v);if(!isNaN(F)&&!isNaN(I)&&F!=0&&I!=0&&h.y)D.y=h.y-(F-I);if(D.x||D.y)ma(m[H],D,1E3,true)}w();break;case "use":w();break;case "g":(w=$(e).data("gsvg"))&&ma(w,h,1E3,true);break;case "polyline":case "polygon":w=h.points.length;for(H=0;H<w;++H){I=h.points[H];I=O(I.x,I.y,m);h.points[H].x=I.x;h.points[H].y=I.y}w=h.points.length;m="";for(H=0;H<w;++H){I=
h.points[H];m+=I.x+","+I.y+" "}e.setAttribute("points",m);break;case "path":A=e.pathSegList;w=A.numberOfItems;h.d=Array(w);for(H=0;H<w;++H){v=A.getItem(H);h.d[H]={type:v.pathSegType,x:v.x,y:v.y,x1:v.x1,y1:v.y1,x2:v.x2,y2:v.y2,r1:v.r1,r2:v.r2,angle:v.angle,largeArcFlag:v.largeArcFlag,sweepFlag:v.sweepFlag}}w=h.d.length;H=h.d[0];D=O(H.x,H.y,m);h.d[0].x=D.x;h.d[0].y=D.y;for(H=1;H<w;++H){v=h.d[H];A=v.type;if(A%2==0){I=O(v.x!=undefined?v.x:D.x,v.y!=undefined?v.y:D.y,m);A=O(v.x1,v.y1,m);F=O(v.x2,v.y2,m);
v.x=I.x;v.y=I.y;v.x1=A.x;v.y1=A.y;v.x2=F.x;v.y2=F.y}else{v.x=m.a*v.x;v.y=m.d*v.y;v.x1=m.a*v.x1;v.y1=m.d*v.y1;v.x2=m.a*v.x2;v.y2=m.d*v.y2}v.r1=m.a*v.r1;v.r2=m.d*v.r2}m="";w=h.d.length;for(H=0;H<w;++H){v=h.d[H];A=v.type;m+=Oa[A];switch(A){case 13:case 12:m+=v.x+" ";break;case 15:case 14:m+=v.y+" ";break;case 3:case 5:case 19:case 2:case 4:case 18:m+=v.x+","+v.y+" ";break;case 7:case 6:m+=v.x1+","+v.y1+" "+v.x2+","+v.y2+" "+v.x+","+v.y+" ";break;case 9:case 8:m+=v.x1+","+v.y1+" "+v.x+","+v.y+" ";break;
case 11:case 10:m+=v.r1+","+v.r2+" "+v.angle+" "+ +v.largeArcFlag+" "+ +v.sweepFlag+" "+v.x+","+v.y+" ";break;case 17:case 16:m+=v.x2+","+v.y2+" "+v.x+","+v.y+" "}}e.setAttribute("d",m)}},nb=function(e,h,m){e=R(e).firstChild;var z=Y(e),w=d.createSVGTransform();w.setTranslate(h,m);z.appendItem(w);Xa(e)},Xa=this.recalculateDimensions=function(e){if(e==null)return null;var h=Y(e);if(h&&h.numberOfItems>0){for(var m=h.numberOfItems;m--;){var z=h.getItem(m);if(z.type===0)h.removeItem(m);else if(z.type===
v=sa("x",m[H].getAttribute("x"));F=sa("y",e.getAttribute("y"));I=sa("y",m[H].getAttribute("y"));var E={};if(!isNaN(A)&&!isNaN(v)&&A!=0&&v!=0&&h.x)E.x=h.x-(A-v);if(!isNaN(F)&&!isNaN(I)&&F!=0&&I!=0&&h.y)E.y=h.y-(F-I);if(E.x||E.y)ma(m[H],E,1E3,true)}w();break;case "use":w();break;case "g":(w=$(e).data("gsvg"))&&ma(w,h,1E3,true);break;case "polyline":case "polygon":w=h.points.length;for(H=0;H<w;++H){I=h.points[H];I=O(I.x,I.y,m);h.points[H].x=I.x;h.points[H].y=I.y}w=h.points.length;m="";for(H=0;H<w;++H){I=
h.points[H];m+=I.x+","+I.y+" "}e.setAttribute("points",m);break;case "path":A=e.pathSegList;w=A.numberOfItems;h.d=Array(w);for(H=0;H<w;++H){v=A.getItem(H);h.d[H]={type:v.pathSegType,x:v.x,y:v.y,x1:v.x1,y1:v.y1,x2:v.x2,y2:v.y2,r1:v.r1,r2:v.r2,angle:v.angle,largeArcFlag:v.largeArcFlag,sweepFlag:v.sweepFlag}}w=h.d.length;H=h.d[0];E=O(H.x,H.y,m);h.d[0].x=E.x;h.d[0].y=E.y;for(H=1;H<w;++H){v=h.d[H];A=v.type;if(A%2==0){I=O(v.x!=undefined?v.x:E.x,v.y!=undefined?v.y:E.y,m);A=O(v.x1,v.y1,m);F=O(v.x2,v.y2,m);
v.x=I.x;v.y=I.y;v.x1=A.x;v.y1=A.y;v.x2=F.x;v.y2=F.y}else{v.x=m.a*v.x;v.y=m.d*v.y;v.x1=m.a*v.x1;v.y1=m.d*v.y1;v.x2=m.a*v.x2;v.y2=m.d*v.y2}v.r1=m.a*v.r1;v.r2=m.d*v.r2}m="";w=h.d.length;for(H=0;H<w;++H){v=h.d[H];A=v.type;m+=Pa[A];switch(A){case 13:case 12:m+=v.x+" ";break;case 15:case 14:m+=v.y+" ";break;case 3:case 5:case 19:case 2:case 4:case 18:m+=v.x+","+v.y+" ";break;case 7:case 6:m+=v.x1+","+v.y1+" "+v.x2+","+v.y2+" "+v.x+","+v.y+" ";break;case 9:case 8:m+=v.x1+","+v.y1+" "+v.x+","+v.y+" ";break;
case 11:case 10:m+=v.r1+","+v.r2+" "+v.angle+" "+ +v.largeArcFlag+" "+ +v.sweepFlag+" "+v.x+","+v.y+" ";break;case 17:case 16:m+=v.x2+","+v.y2+" "+v.x+","+v.y+" "}}e.setAttribute("d",m)}},nb=function(e,h,m){e=R(e).firstChild;var z=X(e),w=d.createSVGTransform();w.setTranslate(h,m);z.appendItem(w);Ua(e)},Ua=this.recalculateDimensions=function(e){if(e==null)return null;var h=X(e);if(h&&h.numberOfItems>0){for(var m=h.numberOfItems;m--;){var z=h.getItem(m);if(z.type===0)h.removeItem(m);else if(z.type===
1)svgedit.math.isIdentity(z.matrix)&&h.removeItem(m);else z.type===4&&z.angle===0&&h.removeItem(m)}if(h.numberOfItems===1&&oa(e))return null}if(!h||h.numberOfItems==0){e.removeAttribute("transform");return null}if(h){m=h.numberOfItems;for(var w=[];m--;){z=h.getItem(m);if(z.type===1)w.push([z.matrix,m]);else if(w.length)w=[]}if(w.length===2){m=d.createSVGTransformFromMatrix(ia(w[1][0],w[0][0]));h.removeItem(w[0][1]);h.removeItem(w[1][1]);h.insertItemBefore(m,w[1][1])}m=h.numberOfItems;if(m>=2&&h.getItem(m-
2).type===1&&h.getItem(m-1).type===2){w=d.createSVGTransform();z=ia(h.getItem(m-2).matrix,h.getItem(m-1).matrix);w.setMatrix(z);h.removeItem(m-2);h.removeItem(m-2);h.appendItem(w)}}switch(e.tagName){case "line":case "polyline":case "polygon":case "path":break;default:if(h.numberOfItems===1&&h.getItem(0).type===1||h.numberOfItems===2&&h.getItem(0).type===1&&h.getItem(0).type===4)return null}var H=$(e).data("gsvg");m=new za("Transform");var A={},v=null;z=[];switch(e.tagName){case "line":z=["x1","y1",
"x2","y2"];break;case "circle":z=["cx","cy","r"];break;case "ellipse":z=["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":z=["width","height","x","y"];break;case "use":case "text":case "tspan":z=["x","y"];break;case "polygon":case "polyline":v={};v.points=e.getAttribute("points");w=e.points;var F=w.numberOfItems;A.points=Array(F);for(var I=0;I<F;++I){var D=w.getItem(I);A.points[I]={x:D.x,y:D.y}}break;case "path":v={};v.d=e.getAttribute("d");A.d=e.getAttribute("d")}if(z.length){A=
$(e).attr(z);$.each(A,function(ha,Sa){A[ha]=sa(ha,Sa)})}else if(H)A={x:$(H).attr("x")||0,y:$(H).attr("y")||0};if(v==null){v=$.extend(true,{},A);$.each(v,function(ha,Sa){v[ha]=sa(ha,Sa)})}v.transform=Ua?Ua:"";if(e.tagName=="g"&&!H||e.tagName=="a"){w=svgedit.utilities.getBBox(e);var G={x:w.x+w.width/2,y:w.y+w.height/2},L=O(w.x+w.width/2,w.y+w.height/2,fa(h).matrix);z=d.createSVGMatrix();if(w=oa(e)){I=w*Math.PI/180;F=Math.abs(I)>1.0E-10?Math.sin(I)/(1-Math.cos(I)):2/I;for(I=0;I<h.numberOfItems;++I){z=
h.getItem(I);if(z.type==4){z=z.matrix;G.y=(F*z.e+z.f)/2;G.x=(z.e-F*z.f)/2;h.removeItem(I);break}}}I=z=H=0;var k=h.numberOfItems;if(k)var u=h.getItem(0).matrix;if(k>=3&&h.getItem(k-2).type==3&&h.getItem(k-3).type==2&&h.getItem(k-1).type==2){I=3;var C=h.getItem(k-3).matrix,E=h.getItem(k-2).matrix,P=h.getItem(k-1).matrix;F=e.childNodes;for(D=F.length;D--;){var U=F.item(D);z=H=0;if(U.nodeType==1){var S=Y(U);if(S){z=fa(S).matrix;H=oa(U);var X=Ua,aa=[];Ua=U.getAttribute("transform");if(H||pa(S)){var ga=
d.createSVGTransform();ga.setMatrix(ia(C,E,P,z));S.clear();S.appendItem(ga);aa.push(ga)}else{H=ia(z.inverse(),P,z);ga=d.createSVGMatrix();ga.e=-H.e;ga.f=-H.f;z=ia(ga.inverse(),z.inverse(),C,E,P,z,H.inverse());var ra=d.createSVGTransform(),Ta=d.createSVGTransform(),Ba=d.createSVGTransform();ra.setTranslate(H.e,H.f);Ta.setScale(z.a,z.d);Ba.setTranslate(ga.e,ga.f);S.appendItem(Ba);S.appendItem(Ta);S.appendItem(ra);aa.push(Ba);aa.push(Ta);aa.push(ra)}m.addSubCommand(Xa(U));Ua=X}}}h.removeItem(k-1);h.removeItem(k-
2);h.removeItem(k-3)}else if(k>=3&&h.getItem(k-1).type==1){I=3;z=fa(h).matrix;ga=d.createSVGTransform();ga.setMatrix(z);h.clear();h.appendItem(ga)}else if((k==1||k>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){I=2;H=fa(h).matrix;h.removeItem(0);z=fa(h).matrix.inverse();z=ia(z,H);H=z.e;z=z.f;if(H!=0||z!=0){F=e.childNodes;D=F.length;for(k=[];D--;){U=F.item(D);if(U.nodeType==1){if(U.getAttribute("clip-path")){X=U.getAttribute("clip-path");if(k.indexOf(X)===-1){nb(X,H,z);k.push(X)}}X=Ua;Ua=U.getAttribute("transform");
if(S=Y(U)){C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,0):S.appendItem(C);m.addSubCommand(Xa(U));S=e.getElementsByTagNameNS(c,"use");U="#"+U.id;for(C=S.length;C--;){E=S.item(C);if(U==da(E)){P=d.createSVGTransform();P.setTranslate(-H,-z);Y(E).insertItemBefore(P,0);m.addSubCommand(Xa(E))}}Ua=X}}}k=[];Ua=X}}else if(k==1&&h.getItem(0).type==1&&!w){I=1;z=h.getItem(0).matrix;F=e.childNodes;for(D=F.length;D--;){U=F.item(D);if(U.nodeType==1){X=Ua;Ua=U.getAttribute("transform");
if(S=Y(U)){H=ia(z,fa(S).matrix);k=d.createSVGTransform();k.setMatrix(H);S.clear();S.appendItem(k,0);m.addSubCommand(Xa(U));Ua=X;X=U.getAttribute("stroke-width");U.getAttribute("stroke")!=="none"&&!isNaN(X)&&U.setAttribute("stroke-width",X*((Math.abs(H.a)+Math.abs(H.d))/2))}}}h.clear()}else{if(w){G=d.createSVGTransform();G.setRotate(w,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}h.numberOfItems==0&&e.removeAttribute("transform");return null}if(I==2){if(w){L={x:G.x+u.e,y:G.y+u.f};
G=d.createSVGTransform();G.setRotate(w,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else if(I==3){z=fa(h).matrix;u=d.createSVGTransform();u.setRotate(w,G.x,G.y);u=u.matrix;G=d.createSVGTransform();G.setRotate(w,L.x,L.y);L=G.matrix.inverse();X=z.inverse();L=ia(X,L,u,z);H=L.e;z=L.f;if(H!=0||z!=0){F=e.childNodes;for(D=F.length;D--;){U=F.item(D);if(U.nodeType==1){X=Ua;Ua=U.getAttribute("transform");S=Y(U);C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,
0):S.appendItem(C);m.addSubCommand(Xa(U));Ua=X}}}if(w)h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else{w=svgedit.utilities.getBBox(e);if(!w&&e.tagName!="path")return null;z=d.createSVGMatrix();if(H=oa(e)){G={x:w.x+w.width/2,y:w.y+w.height/2};L=O(w.x+w.width/2,w.y+w.height/2,fa(h).matrix);I=H*Math.PI/180;F=Math.abs(I)>1.0E-10?Math.sin(I)/(1-Math.cos(I)):2/I;for(I=0;I<h.numberOfItems;++I){z=h.getItem(I);if(z.type==4){z=z.matrix;G.y=(F*z.e+z.f)/2;G.x=(z.e-F*z.f)/2;h.removeItem(I);break}}}I=
0;k=h.numberOfItems;if(!svgedit.browser.isWebkit())if((u=e.getAttribute("fill"))&&u.indexOf("url(")===0){u=R(u);X="pattern";if(u.tagName!==X)X="gradient";if(u.getAttribute(X+"Units")==="userSpaceOnUse"){z=fa(h).matrix;w=Y(u);w=fa(w).matrix;z=ia(z,w);w="matrix("+[z.a,z.b,z.c,z.d,z.e,z.f].join(",")+")";u.setAttribute(X+"Transform",w)}}if(k>=3&&h.getItem(k-2).type==3&&h.getItem(k-3).type==2&&h.getItem(k-1).type==2){I=3;z=fa(h,k-3,k-1).matrix;h.removeItem(k-1);h.removeItem(k-2);h.removeItem(k-3)}else if(k==
4&&h.getItem(k-1).type==1){I=3;z=fa(h).matrix;ga=d.createSVGTransform();ga.setMatrix(z);h.clear();h.appendItem(ga);z=d.createSVGMatrix()}else if((k==1||k>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){I=2;u=h.getItem(0).matrix;X=fa(h,1).matrix;w=X.inverse();z=ia(w,u,X);h.removeItem(0)}else if(k==1&&h.getItem(0).type==1&&!H){z=fa(h).matrix;switch(e.tagName){case "line":A=$(e).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":A.points=e.getAttribute("points");if(A.points){w=e.points;F=w.numberOfItems;
A.points=Array(F);for(I=0;I<F;++I){D=w.getItem(I);A.points[I]={x:D.x,y:D.y}}}case "path":A.d=e.getAttribute("d");I=1;h.clear()}}else{I=4;if(H){G=d.createSVGTransform();G.setRotate(H,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}h.numberOfItems==0&&e.removeAttribute("transform");return null}if(I==1||I==2||I==3)db(e,A,z);if(I==2){if(H){pa(h)||(L={x:G.x+z.e,y:G.y+z.f});G=d.createSVGTransform();G.setRotate(H,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else if(I==
3&&H){z=fa(h).matrix;u=d.createSVGTransform();u.setRotate(H,G.x,G.y);u=u.matrix;G=d.createSVGTransform();G.setRotate(H,L.x,L.y);L=G.matrix.inverse();X=z.inverse();L=ia(X,L,u,z);db(e,A,L);if(H)h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}h.numberOfItems==0&&e.removeAttribute("transform");m.addSubCommand(new Na(e,v));return m},rb=null,Pa=this.clearSelection=function(e){if(J[0]!=null)for(var h=J.length,m=0;m<h;++m){var z=J[m];if(z==null)break;Ha.releaseSelector(z);J[m]=null}e||N("selected",
"x2","y2"];break;case "circle":z=["cx","cy","r"];break;case "ellipse":z=["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":z=["width","height","x","y"];break;case "use":case "text":case "tspan":z=["x","y"];break;case "polygon":case "polyline":v={};v.points=e.getAttribute("points");w=e.points;var F=w.numberOfItems;A.points=Array(F);for(var I=0;I<F;++I){var E=w.getItem(I);A.points[I]={x:E.x,y:E.y}}break;case "path":v={};v.d=e.getAttribute("d");A.d=e.getAttribute("d")}if(z.length){A=
$(e).attr(z);$.each(A,function(ha,Ta){A[ha]=sa(ha,Ta)})}else if(H)A={x:$(H).attr("x")||0,y:$(H).attr("y")||0};if(v==null){v=$.extend(true,{},A);$.each(v,function(ha,Ta){v[ha]=sa(ha,Ta)})}v.transform=Va?Va:"";if(e.tagName=="g"&&!H||e.tagName=="a"){w=svgedit.utilities.getBBox(e);var G={x:w.x+w.width/2,y:w.y+w.height/2},L=O(w.x+w.width/2,w.y+w.height/2,fa(h).matrix);z=d.createSVGMatrix();if(w=oa(e)){I=w*Math.PI/180;F=Math.abs(I)>1.0E-10?Math.sin(I)/(1-Math.cos(I)):2/I;for(I=0;I<h.numberOfItems;++I){z=
h.getItem(I);if(z.type==4){z=z.matrix;G.y=(F*z.e+z.f)/2;G.x=(z.e-F*z.f)/2;h.removeItem(I);break}}}I=z=H=0;var k=h.numberOfItems;if(k)var u=h.getItem(0).matrix;if(k>=3&&h.getItem(k-2).type==3&&h.getItem(k-3).type==2&&h.getItem(k-1).type==2){I=3;var C=h.getItem(k-3).matrix,D=h.getItem(k-2).matrix,P=h.getItem(k-1).matrix;F=e.childNodes;for(E=F.length;E--;){var U=F.item(E);z=H=0;if(U.nodeType==1){var S=X(U);if(S){z=fa(S).matrix;H=oa(U);var Y=Va,aa=[];Va=U.getAttribute("transform");if(H||pa(S)){var ga=
d.createSVGTransform();ga.setMatrix(ia(C,D,P,z));S.clear();S.appendItem(ga);aa.push(ga)}else{H=ia(z.inverse(),P,z);ga=d.createSVGMatrix();ga.e=-H.e;ga.f=-H.f;z=ia(ga.inverse(),z.inverse(),C,D,P,z,H.inverse());var ra=d.createSVGTransform(),Oa=d.createSVGTransform(),Ba=d.createSVGTransform();ra.setTranslate(H.e,H.f);Oa.setScale(z.a,z.d);Ba.setTranslate(ga.e,ga.f);S.appendItem(Ba);S.appendItem(Oa);S.appendItem(ra);aa.push(Ba);aa.push(Oa);aa.push(ra)}m.addSubCommand(Ua(U));Va=Y}}}h.removeItem(k-1);h.removeItem(k-
2);h.removeItem(k-3)}else if(k>=3&&h.getItem(k-1).type==1){I=3;z=fa(h).matrix;ga=d.createSVGTransform();ga.setMatrix(z);h.clear();h.appendItem(ga)}else if((k==1||k>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){I=2;H=fa(h).matrix;h.removeItem(0);z=fa(h).matrix.inverse();z=ia(z,H);H=z.e;z=z.f;if(H!=0||z!=0){F=e.childNodes;E=F.length;for(k=[];E--;){U=F.item(E);if(U.nodeType==1){if(U.getAttribute("clip-path")){Y=U.getAttribute("clip-path");if(k.indexOf(Y)===-1){nb(Y,H,z);k.push(Y)}}Y=Va;Va=U.getAttribute("transform");
if(S=X(U)){C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,0):S.appendItem(C);m.addSubCommand(Ua(U));S=e.getElementsByTagNameNS(c,"use");U="#"+U.id;for(C=S.length;C--;){D=S.item(C);if(U==da(D)){P=d.createSVGTransform();P.setTranslate(-H,-z);X(D).insertItemBefore(P,0);m.addSubCommand(Ua(D))}}Va=Y}}}k=[];Va=Y}}else if(k==1&&h.getItem(0).type==1&&!w){I=1;z=h.getItem(0).matrix;F=e.childNodes;for(E=F.length;E--;){U=F.item(E);if(U.nodeType==1){Y=Va;Va=U.getAttribute("transform");
if(S=X(U)){H=ia(z,fa(S).matrix);k=d.createSVGTransform();k.setMatrix(H);S.clear();S.appendItem(k,0);m.addSubCommand(Ua(U));Va=Y;Y=U.getAttribute("stroke-width");U.getAttribute("stroke")!=="none"&&!isNaN(Y)&&U.setAttribute("stroke-width",Y*((Math.abs(H.a)+Math.abs(H.d))/2))}}}h.clear()}else{if(w){G=d.createSVGTransform();G.setRotate(w,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}h.numberOfItems==0&&e.removeAttribute("transform");return null}if(I==2){if(w){L={x:G.x+u.e,y:G.y+u.f};
G=d.createSVGTransform();G.setRotate(w,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else if(I==3){z=fa(h).matrix;u=d.createSVGTransform();u.setRotate(w,G.x,G.y);u=u.matrix;G=d.createSVGTransform();G.setRotate(w,L.x,L.y);L=G.matrix.inverse();Y=z.inverse();L=ia(Y,L,u,z);H=L.e;z=L.f;if(H!=0||z!=0){F=e.childNodes;for(E=F.length;E--;){U=F.item(E);if(U.nodeType==1){Y=Va;Va=U.getAttribute("transform");S=X(U);C=d.createSVGTransform();C.setTranslate(H,z);S.numberOfItems?S.insertItemBefore(C,
0):S.appendItem(C);m.addSubCommand(Ua(U));Va=Y}}}if(w)h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else{w=svgedit.utilities.getBBox(e);if(!w&&e.tagName!="path")return null;z=d.createSVGMatrix();if(H=oa(e)){G={x:w.x+w.width/2,y:w.y+w.height/2};L=O(w.x+w.width/2,w.y+w.height/2,fa(h).matrix);I=H*Math.PI/180;F=Math.abs(I)>1.0E-10?Math.sin(I)/(1-Math.cos(I)):2/I;for(I=0;I<h.numberOfItems;++I){z=h.getItem(I);if(z.type==4){z=z.matrix;G.y=(F*z.e+z.f)/2;G.x=(z.e-F*z.f)/2;h.removeItem(I);break}}}I=
0;k=h.numberOfItems;if(!svgedit.browser.isWebkit())if((u=e.getAttribute("fill"))&&u.indexOf("url(")===0){u=R(u);Y="pattern";if(u.tagName!==Y)Y="gradient";if(u.getAttribute(Y+"Units")==="userSpaceOnUse"){z=fa(h).matrix;w=X(u);w=fa(w).matrix;z=ia(z,w);w="matrix("+[z.a,z.b,z.c,z.d,z.e,z.f].join(",")+")";u.setAttribute(Y+"Transform",w)}}if(k>=3&&h.getItem(k-2).type==3&&h.getItem(k-3).type==2&&h.getItem(k-1).type==2){I=3;z=fa(h,k-3,k-1).matrix;h.removeItem(k-1);h.removeItem(k-2);h.removeItem(k-3)}else if(k==
4&&h.getItem(k-1).type==1){I=3;z=fa(h).matrix;ga=d.createSVGTransform();ga.setMatrix(z);h.clear();h.appendItem(ga);z=d.createSVGMatrix()}else if((k==1||k>1&&h.getItem(1).type!=3)&&h.getItem(0).type==2){I=2;u=h.getItem(0).matrix;Y=fa(h,1).matrix;w=Y.inverse();z=ia(w,u,Y);h.removeItem(0)}else if(k==1&&h.getItem(0).type==1&&!H){z=fa(h).matrix;switch(e.tagName){case "line":A=$(e).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":A.points=e.getAttribute("points");if(A.points){w=e.points;F=w.numberOfItems;
A.points=Array(F);for(I=0;I<F;++I){E=w.getItem(I);A.points[I]={x:E.x,y:E.y}}}case "path":A.d=e.getAttribute("d");I=1;h.clear()}}else{I=4;if(H){G=d.createSVGTransform();G.setRotate(H,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}h.numberOfItems==0&&e.removeAttribute("transform");return null}if(I==1||I==2||I==3)db(e,A,z);if(I==2){if(H){pa(h)||(L={x:G.x+z.e,y:G.y+z.f});G=d.createSVGTransform();G.setRotate(H,L.x,L.y);h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}else if(I==
3&&H){z=fa(h).matrix;u=d.createSVGTransform();u.setRotate(H,G.x,G.y);u=u.matrix;G=d.createSVGTransform();G.setRotate(H,L.x,L.y);L=G.matrix.inverse();Y=z.inverse();L=ia(Y,L,u,z);db(e,A,L);if(H)h.numberOfItems?h.insertItemBefore(G,0):h.appendItem(G)}}h.numberOfItems==0&&e.removeAttribute("transform");m.addSubCommand(new Na(e,v));return m},rb=null,Qa=this.clearSelection=function(e){if(J[0]!=null)for(var h=J.length,m=0;m<h;++m){var z=J[m];if(z==null)break;Ha.releaseSelector(z);J[m]=null}e||N("selected",
J)},vb=this.addToSelection=function(e,h){if(e.length!=0){for(var m=0;m<J.length;){if(J[m]==null)break;++m}for(var z=e.length;z--;){var w=e[z];if(w&&svgedit.utilities.getBBox(w)){if(w.tagName==="a"&&w.childNodes.length===1)w=w.firstChild;if(J.indexOf(w)==-1){J[m]=w;m++;w=Ha.requestSelector(w);J.length>1&&w.showGrips(false)}}}N("selected",J);h||J.length==1?Ha.requestSelector(J[0]).showGrips(true):Ha.requestSelector(J[0]).showGrips(false);for(J.sort(function(H,A){if(H&&A&&H.compareDocumentPosition)return 3-
(A.compareDocumentPosition(H)&6);else if(H==null)return 1});J[0]==null;)J.shift(0)}},Bb=this.selectOnly=function(e,h){Pa(true);vb(e,h)};this.removeFromSelection=function(e){if(J[0]!=null)if(e.length!=0){var h=Array(J.length);j=0;len=J.length;for(var m=0;m<len;++m){var z=J[m];if(z)if(e.indexOf(z)==-1){h[j]=z;j++}else Ha.releaseSelector(z)}J=h}};this.selectAllInCurrentLayer=function(){var e=B().getCurrentLayer();if(e){Ea="select";Bb($(K||e).children())}};var Ib=this.getMouseTarget=function(e){if(e==
(A.compareDocumentPosition(H)&6);else if(H==null)return 1});J[0]==null;)J.shift(0)}},xb=this.selectOnly=function(e,h){Qa(true);vb(e,h)};this.removeFromSelection=function(e){if(J[0]!=null)if(e.length!=0){var h=Array(J.length);j=0;len=J.length;for(var m=0;m<len;++m){var z=J[m];if(z)if(e.indexOf(z)==-1){h[j]=z;j++}else Ha.releaseSelector(z)}J=h}};this.selectAllInCurrentLayer=function(){var e=B().getCurrentLayer();if(e){Ea="select";xb($(K||e).children())}};var Ib=this.getMouseTarget=function(e){if(e==
null)return null;e=e.target;if(e.correspondingUseElement)e=e.correspondingUseElement;if(["http://www.w3.org/1998/Math/MathML","http://www.w3.org/1999/xhtml"].indexOf(e.namespaceURI)>=0&&e.id!="svgcanvas")for(;e.nodeName!="foreignObject";){e=e.parentNode;if(!e)return d}var h=B().getCurrentLayer();if([d,a,l,h].indexOf(e)>=0)return d;if($(e).closest("#selectorParentGroup").length)return Ha.selectorParentGroup;for(;e.parentNode!==(K||h);)e=e.parentNode;return e};(function(){var e=null,h=null,m=null,z=
null,w=null,H={},A={minx:null,miny:null,maxx:null,maxy:null};$(a).mousedown(function(v){if(!(v.originalEvent.touches&&v.originalEvent.touches>1)){var F=v.button===2;rb=l.getScreenCTM().inverse();var I=O(v.pageX,v.pageY,rb),D=I.x*o;I=I.y*o;v.preventDefault();if(F)Ea="select";D=D/o;I=I/o;var G=Ib(v);if(G.tagName==="a"&&G.childNodes.length===1)G=G.firstChild;var L=z=h=D,k=w=m=I;if(n.gridSnapping){D=wa(D);I=wa(I);h=wa(h);m=wa(m)}if(G==Ha.selectorParentGroup&&J[0]!=null){G=v.target;var u=ib(G,"type");
if(u=="rotate"){Ea="rotate";current_rotate_mode=ib(G,"dir")}else if(u=="resize"){Ea="resize";kb=ib(G,"dir")}G=J[0]}Ua=G.getAttribute("transform");u=Y(G);switch(Ea){case "select":La=true;kb="none";if(F)La=false;if(G!=d){if(J.indexOf(G)==-1){v.shiftKey||Pa(true);vb([G]);Cb=G;Ja.clear()}if(!F)for(F=0;F<J.length;++F)if(J[F]!=null){var C=Y(J[F]);C.numberOfItems?C.insertItemBefore(d.createSVGTransform(),0):C.appendItem(d.createSVGTransform())}}else if(!F){Pa();Ea="multiselect";if(ta==null)ta=Ha.getRubberBandBox();
z*=o;w*=o;ma(ta,{x:z,y:w,width:0,height:0,display:"inline"},100)}break;case "zoom":La=true;if(ta==null)ta=Ha.getRubberBandBox();ma(ta,{x:L*o,y:L*o,width:0,height:0,display:"inline"},100);break;case "resize":La=true;h=D;m=I;H=svgedit.utilities.getBBox($("#selectedBox0")[0]);var E={};$.each(H,function(P,U){E[P]=U/o});H=E;F=oa(G)?1:0;if(pa(u)){u.insertItemBefore(d.createSVGTransform(),F);u.insertItemBefore(d.createSVGTransform(),F);u.insertItemBefore(d.createSVGTransform(),F)}else{u.appendItem(d.createSVGTransform());
u.appendItem(d.createSVGTransform());u.appendItem(d.createSVGTransform());if(svgedit.browser.supportsNonScalingStroke()){if(D=svgedit.browser.isChrome())C=function(P){var U=P.getAttributeNS(null,"stroke");P.removeAttributeNS(null,"stroke");setTimeout(function(){P.setAttributeNS(null,"stroke",U)},1)};G.style.vectorEffect="non-scaling-stroke";D&&C(G);I=G.getElementsByTagName("*");L=I.length;for(F=0;F<L;F++){I[F].style.vectorEffect="non-scaling-stroke";D&&C(I[F])}}}break;case "fhellipse":case "fhrect":case "fhpath":La=
true;e=L+","+k+" ";C=M.stroke_width==0?1:M.stroke_width;Q({element:"polyline",curStyles:true,attr:{points:e,id:ja(),fill:"none",opacity:M.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}});A.minx=L;A.maxx=L;A.miny=k;A.maxy=k;break;case "image":La=true;C=Q({element:"image",attr:{x:D,y:I,width:0,height:0,id:ja(),opacity:M.opacity/2,style:"pointer-events:inherit"}});V(C,Da);pb(C);break;case "square":case "rect":La=true;h=D;m=I;Q({element:"rect",curStyles:true,attr:{x:D,y:I,width:0,height:0,
id:ja(),opacity:M.opacity/2}});break;case "line":La=true;C=M.stroke_width==0?1:M.stroke_width;Q({element:"line",curStyles:true,attr:{x1:D,y1:I,x2:D,y2:I,id:ja(),stroke:M.stroke,"stroke-width":C,"stroke-dasharray":M.stroke_dasharray,"stroke-linejoin":M.stroke_linejoin,"stroke-linecap":M.stroke_linecap,"stroke-opacity":M.stroke_opacity,fill:"none",opacity:M.opacity/2,style:"pointer-events:none"}});break;case "circle":La=true;Q({element:"circle",curStyles:true,attr:{cx:D,cy:I,r:0,id:ja(),opacity:M.opacity/
2}});break;case "ellipse":La=true;Q({element:"ellipse",curStyles:true,attr:{cx:D,cy:I,rx:0,ry:0,id:ja(),opacity:M.opacity/2}});break;case "text":La=true;Q({element:"text",curStyles:true,attr:{x:D,y:I,id:ja(),fill:Za.fill,"stroke-width":Za.stroke_width,"font-size":Za.font_size,"font-family":Za.font_family,"text-anchor":"left","xml:space":"preserve",opacity:M.opacity}});break;case "path":case "pathedit":h*=o;m*=o;Ja.mouseDown(v,G,h,m);La=true;break;case "textedit":h*=o;m*=o;hb.mouseDown(v,G,h,m);La=
null,w=null,H={},A={minx:null,miny:null,maxx:null,maxy:null};$(a).mousedown(function(v){if(!(v.originalEvent.touches&&v.originalEvent.touches>1)){var F=v.button===2;rb=l.getScreenCTM().inverse();var I=O(v.pageX,v.pageY,rb),E=I.x*o;I=I.y*o;v.preventDefault();if(F)Ea="select";E=E/o;I=I/o;var G=Ib(v);if(G.tagName==="a"&&G.childNodes.length===1)G=G.firstChild;var L=z=h=E,k=w=m=I;if(n.gridSnapping){E=wa(E);I=wa(I);h=wa(h);m=wa(m)}if(G==Ha.selectorParentGroup&&J[0]!=null){G=v.target;var u=ib(G,"type");
if(u=="rotate"){Ea="rotate";current_rotate_mode=ib(G,"dir")}else if(u=="resize"){Ea="resize";kb=ib(G,"dir")}G=J[0]}Va=G.getAttribute("transform");u=X(G);switch(Ea){case "select":La=true;kb="none";if(F)La=false;if(G!=d){if(J.indexOf(G)==-1){v.shiftKey||Qa(true);vb([G]);Cb=G;Ja.clear()}if(!F)for(F=0;F<J.length;++F)if(J[F]!=null){var C=X(J[F]);C.numberOfItems?C.insertItemBefore(d.createSVGTransform(),0):C.appendItem(d.createSVGTransform())}}else if(!F){Qa();Ea="multiselect";if(ua==null)ua=Ha.getRubberBandBox();
z*=o;w*=o;ma(ua,{x:z,y:w,width:0,height:0,display:"inline"},100)}break;case "zoom":La=true;if(ua==null)ua=Ha.getRubberBandBox();ma(ua,{x:L*o,y:L*o,width:0,height:0,display:"inline"},100);break;case "resize":La=true;h=E;m=I;H=svgedit.utilities.getBBox($("#selectedBox0")[0]);var D={};$.each(H,function(P,U){D[P]=U/o});H=D;F=oa(G)?1:0;if(pa(u)){u.insertItemBefore(d.createSVGTransform(),F);u.insertItemBefore(d.createSVGTransform(),F);u.insertItemBefore(d.createSVGTransform(),F)}else{u.appendItem(d.createSVGTransform());
u.appendItem(d.createSVGTransform());u.appendItem(d.createSVGTransform());if(svgedit.browser.supportsNonScalingStroke()){if(E=svgedit.browser.isChrome())C=function(P){var U=P.getAttributeNS(null,"stroke");P.removeAttributeNS(null,"stroke");setTimeout(function(){P.setAttributeNS(null,"stroke",U)},1)};G.style.vectorEffect="non-scaling-stroke";E&&C(G);I=G.getElementsByTagName("*");L=I.length;for(F=0;F<L;F++){I[F].style.vectorEffect="non-scaling-stroke";E&&C(I[F])}}}break;case "fhellipse":case "fhrect":case "fhpath":La=
true;e=L+","+k+" ";C=M.stroke_width==0?1:M.stroke_width;Q({element:"polyline",curStyles:true,attr:{points:e,id:ja(),fill:"none",opacity:M.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}});A.minx=L;A.maxx=L;A.miny=k;A.maxy=k;break;case "image":La=true;C=Q({element:"image",attr:{x:E,y:I,width:0,height:0,id:ja(),opacity:M.opacity/2,style:"pointer-events:inherit"}});V(C,Da);pb(C);break;case "square":case "rect":La=true;h=E;m=I;Q({element:"rect",curStyles:true,attr:{x:E,y:I,width:0,height:0,
id:ja(),opacity:M.opacity/2}});break;case "line":La=true;C=M.stroke_width==0?1:M.stroke_width;Q({element:"line",curStyles:true,attr:{x1:E,y1:I,x2:E,y2:I,id:ja(),stroke:M.stroke,"stroke-width":C,"stroke-dasharray":M.stroke_dasharray,"stroke-linejoin":M.stroke_linejoin,"stroke-linecap":M.stroke_linecap,"stroke-opacity":M.stroke_opacity,fill:"none",opacity:M.opacity/2,style:"pointer-events:none"}});break;case "circle":La=true;Q({element:"circle",curStyles:true,attr:{cx:E,cy:I,r:0,id:ja(),opacity:M.opacity/
2}});break;case "ellipse":La=true;Q({element:"ellipse",curStyles:true,attr:{cx:E,cy:I,rx:0,ry:0,id:ja(),opacity:M.opacity/2}});break;case "text":La=true;Q({element:"text",curStyles:true,attr:{x:E,y:I,id:ja(),fill:Za.fill,"stroke-width":Za.stroke_width,"font-size":Za.font_size,"font-family":Za.font_family,"text-anchor":"left","xml:space":"preserve",opacity:M.opacity}});break;case "path":case "pathedit":h*=o;m*=o;Ja.mouseDown(v,G,h,m);La=true;break;case "textedit":h*=o;m*=o;hb.mouseDown(v,G,h,m);La=
true;break;case "rotate":La=true;b.undoMgr.beginUndoableChange("transform",J);document.getElementById("workarea").className="rotate"}C=ob("mouseDown",{event:v,start_x:h,start_y:m,selectedElements:J},true);$.each(C,function(P,U){if(U&&U.started)La=true});if(Ea)document.getElementById("workarea").className=Ea=="resize"?v.target.style.cursor:Ea}}).mousemove(function(v){if(!(v.originalEvent.touches&&v.originalEvent.touches.length>1))if(La)if(!(v.button===1||b.spaceKey)){var F=J[0],I=O(v.pageX,v.pageY,
rb),D=I.x*o;I=I.y*o;var G=qa(ca()),L=x=D/o,k=y=I/o;if(n.gridSnapping){x=wa(x);y=wa(y)}v.preventDefault();switch(Ea){case "select":if(J[0]!==null){L=x-h;var u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u)}if(v.shiftKey){var C=ba(h,m,x,y);x=C.x;y=C.y}if(L!=0||u!=0){C=J.length;for(k=0;k<C;++k){F=J[k];if(F==null)break;var E=d.createSVGTransform();G=Y(F);E.setTranslate(L,u);G.numberOfItems?G.replaceItem(E,0):G.appendItem(E);Ha.requestSelector(F).resize()}if(v.altKey)if(!b.addClone){b.addClone=b.cloneSelectedElements(0,
0,E);b.removeClone=function(){if(parent=b.addClone.parentNode){parent.removeChild(b.addClone);b.addClone=false}};window.addEventListener("keyup",b.removeClone)}N("transition",J)}}break;case "multiselect":L*=o;k*=o;ma(ta,{x:Math.min(z,L),y:Math.min(w,k),width:Math.abs(L-z),height:Math.abs(k-w)},100);G=[];L=[];E=tb();C=J.length;for(k=0;k<C;++k){u=E.indexOf(J[k]);if(u==-1)G.push(J[k]);else E[u]=null}C=E.length;for(k=0;k<C;++k)E[k]&&L.push(E[k]);G.length>0&&b.removeFromSelection(G);L.length>0&&vb(L);
break;case "resize":G=Y(F);L=(E=pa(G))?H:svgedit.utilities.getBBox(F);C=L.x;k=L.y;var P=L.width,U=L.height;L=x-h;u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u);U=wa(U);P=wa(P)}var S=oa(F);if(S){var X=Math.sqrt(L*L+u*u);u=Math.atan2(u,L)-S*Math.PI/180;L=X*Math.cos(u);u=X*Math.sin(u)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)u=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)L=0;var aa=X=0,ga=U?(U+u)/U:1,ra=P?(P+L)/P:1;if(kb.indexOf("n")>=0){ga=U?(U-u)/U:1;aa=U}if(kb.indexOf("w")>=0){ra=P?(P-L)/P:1;X=P}L=
d.createSVGTransform();u=d.createSVGTransform();P=d.createSVGTransform();if(n.gridSnapping){C=wa(C);X=wa(X);k=wa(k);aa=wa(aa)}L.setTranslate(-(C+X),-(k+aa));if(v.shiftKey)if(ra==1)ra=ga;else ga=ra;u.setScale(ra,ga);P.setTranslate(C+X,k+aa);if(E){E=S?1:0;G.replaceItem(L,2+E);G.replaceItem(u,1+E);G.replaceItem(P,0+E)}else{E=G.numberOfItems;G.replaceItem(P,E-3);G.replaceItem(u,E-2);G.replaceItem(L,E-1)}Ha.requestSelector(F).resize();N("transition",J);break;case "zoom":L*=o;k*=o;ma(ta,{x:Math.min(z*o,
L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100);break;case "text":ma(G,{x:x,y:y},1E3);break;case "line":L=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=wa(x);y=wa(y)}E=x;C=y;if(v.shiftKey){C=ba(h,m,E,C);E=C.x;C=C.y}G.setAttributeNS(null,"x2",E);G.setAttributeNS(null,"y2",C);window.opera||d.unsuspendRedraw(L);break;case "foreignObject":case "square":case "rect":case "image":L=Math.abs(x-h);E=Math.abs(y-m);if(Ea=="square"||v.shiftKey){L=E=Math.max(L,E);C=h<x?h:
h-L;k=m<y?m:m-E}else{C=Math.min(h,x);k=Math.min(m,y)}if(v.altKey){L*=2;E*=2;C=h-L/2;k=m-E/2}if(n.gridSnapping){L=wa(L);E=wa(E);C=wa(C);k=wa(k)}ma(G,{width:L,height:E,x:C,y:k},1E3);break;case "circle":L=$(G).attr(["cx","cy"]);E=L.cx;C=L.cy;L=Math.sqrt((x-E)*(x-E)+(y-C)*(y-C));if(n.gridSnapping)L=wa(L);G.setAttributeNS(null,"r",L);break;case "ellipse":L=$(G).attr(["cx","cy"]);E=Math.abs(h+(x-h)/2);C=Math.abs(m+(y-m)/2);L=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=wa(x);E=wa(E);y=wa(y);
C=wa(C)}k=Math.abs(h-E);u=Math.abs(m-C);if(v.shiftKey){u=k;C=y>m?m+k:m-k}if(v.altKey){E=h;C=m;k=Math.abs(x-E);u=v.shiftKey?k:Math.abs(y-C)}G.setAttributeNS(null,"rx",k);G.setAttributeNS(null,"ry",u);G.setAttributeNS(null,"cx",E);G.setAttributeNS(null,"cy",C);window.opera||d.unsuspendRedraw(L);break;case "fhellipse":case "fhrect":A.minx=Math.min(L,A.minx);A.maxx=Math.max(L,A.maxx);A.miny=Math.min(k,A.miny);A.maxy=Math.max(k,A.maxy);case "fhpath":e+=+L+","+k+" ";G.setAttributeNS(null,"points",e);break;
case "path":case "pathedit":x*=o;y*=o;if(n.gridSnapping){x=wa(x);y=wa(y);h=wa(h);m=wa(m)}if(v.shiftKey){if(E=svgedit.path.path){G=E.dragging?E.dragging[0]:h;E=E.dragging?E.dragging[1]:m}else{G=h;E=m}C=ba(G,E,x,y);x=C.x;y=C.y}if(ta&&ta.getAttribute("display")!=="none"){L*=o;k*=o;ma(ta,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100)}Ja.mouseMove(v,x,y);break;case "textedit":x*=o;y*=o;hb.mouseMove(D,I);break;case "rotate":L=svgedit.utilities.getBBox(F);E=L.x+L.width/
2;C=L.y+L.height/2;G=W(F);G=O(E,C,G);E=G.x;C=G.y;G=L.x;k=L.y;if(current_rotate_mode=="nw")G=L.x+L.width;if(current_rotate_mode=="se")k=L.y+L.height;if(current_rotate_mode=="sw"){G=L.x+L.width;k=L.y+L.height}compensation_angle=(Math.atan2(C-k,E-G)*(180/Math.PI)-90)%360;S=(Math.atan2(C-y,E-x)*(180/Math.PI)-90)%360;S+=compensation_angle;if(n.gridSnapping)S=wa(S);if(v.shiftKey)S=Math.round(S/45)*45;b.setRotationAngle(S<-180?360+S:S,true);N("transition",J)}ob("mouseMove",{event:v,mouse_x:D,mouse_y:I,selected:F})}}).click(function(v){v.preventDefault();
return false}).dblclick(function(v){var F=v.target.parentNode;if(F!==K){var I=Ib(v),D=I.tagName;if(D==="text"&&Ea!=="textedit"){v=O(v.pageX,v.pageY,rb);hb.select(I,v.x,v.y)}if((D==="g"||D==="a")&&oa(I)){Mb(I);I=J[0];Pa(true)}K&&Jb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||I===Ha.selectorParentGroup||Rb(I)}}).mouseup(function(v){b.addClone=false;window.removeEventListener("keyup",b.removeClone);if(v.button!==2){var F=Cb;Cb=null;if(La){var I=O(v.pageX,v.pageY,rb),D=I.x*o;I=I.y*
o;var G=D/o,L=I/o,k=qa(ca()),u=false;La=false;switch(Ea){case "resize":case "multiselect":if(ta!=null){ta.setAttribute("display","none");mb=[]}Ea="select";case "select":if(J[0]!=null){if(J[1]==null){D=J[0];switch(D.tagName){case "g":case "use":case "image":case "foreignObject":break;default:bb.fill=D.getAttribute("fill");bb.fill_opacity=D.getAttribute("fill-opacity");bb.stroke=D.getAttribute("stroke");bb.stroke_opacity=D.getAttribute("stroke-opacity");bb.stroke_width=D.getAttribute("stroke-width");
bb.stroke_dasharray=D.getAttribute("stroke-dasharray");bb.stroke_linejoin=D.getAttribute("stroke-linejoin");bb.stroke_linecap=D.getAttribute("stroke-linecap")}if(D.tagName=="text"){Za.font_size=D.getAttribute("font-size");Za.font_family=D.getAttribute("font-family")}Ha.requestSelector(D).showGrips(true)}Ga();if(G!=z||L!=w){v=J.length;for(D=0;D<v;++D){if(J[D]==null)break;J[D].firstChild||Ha.requestSelector(J[D]).resize()}}else{D=v.target;if(J[0].nodeName==="path"&&J[1]==null)Ja.select(J[0]);else v.shiftKey&&
F!=D&&b.removeFromSelection([D])}if(svgedit.browser.supportsNonScalingStroke())if(v=J[0]){v.removeAttribute("style");svgedit.utilities.walkTree(v,function(P){P.removeAttribute("style")})}}return;case "zoom":ta!=null&&ta.setAttribute("display","none");N("zoomed",{x:Math.min(z,G),y:Math.min(w,L),width:Math.abs(G-z),height:Math.abs(L-w),factor:v.altKey?0.5:2});return;case "fhpath":F=k.getAttribute("points");G=F.indexOf(",");if(u=G>=0?F.indexOf(",",G+1)>=0:F.indexOf(" ",F.indexOf(" ")+1)>=0)k=Ja.smoothPolylineIntoPath(k);
break;case "line":F=$(k).attr(["x1","x2","y1","y2"]);u=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(k).attr(["width","height"]);u=F.width!=0||F.height!=0||Ea==="image";break;case "circle":u=k.getAttribute("r")!=0;break;case "ellipse":F=$(k).attr(["rx","ry"]);u=F.rx!=null||F.ry!=null;break;case "fhellipse":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=Q({element:"ellipse",curStyles:true,attr:{cx:(A.minx+A.maxx)/2,cy:(A.miny+A.maxy)/2,rx:(A.maxx-A.minx)/2,ry:(A.maxy-
A.miny)/2,id:ca()}});N("changed",[k]);u=true}break;case "fhrect":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=Q({element:"rect",curStyles:true,attr:{x:A.minx,y:A.miny,width:A.maxx-A.minx,height:A.maxy-A.miny,id:ca()}});N("changed",[k]);u=true}break;case "text":u=true;Bb([k]);hb.start(k);break;case "path":k=null;La=true;F=Ja.mouseUp(v,k,D,I);k=F.element;u=F.keep;break;case "pathedit":u=true;k=null;Ja.mouseUp(v);break;case "textedit":u=false;k=null;hb.mouseUp(v,D,I);break;case "rotate":u=true;k=null;Ea="select";
F=b.undoMgr.finishUndoableChange();F.isEmpty()||ya(F);Ga();N("changed",J)}D=ob("mouseUp",{event:v,mouse_x:D,mouse_y:I},true);$.each(D,function(P,U){if(U){u=U.keep||u;k=U.element;La=U.started||La}});if(!u&&k!=null){B().releaseId(ca());k.parentNode.removeChild(k);k=null;for(D=v.target;D.parentNode.parentNode.tagName=="g";)D=D.parentNode;if((Ea!="path"||!drawn_path)&&D.parentNode.id!="selectorParentGroup"&&D.id!="svgcanvas"&&D.id!="svgroot"){b.setMode("select");Bb([D],true)}}else if(k!=null){b.addedNew=
true;v=0.2;var C;if(false.beginElement&&k.getAttribute("opacity")!=M.opacity){C=$(false).clone().attr({to:M.opacity,dur:v}).appendTo(k);try{C[0].beginElement()}catch(E){}}else v=0;setTimeout(function(){C&&C.remove();k.setAttribute("opacity",M.opacity);k.setAttribute("style","pointer-events:inherit");na(k);if(Ea==="path")Ja.toEditMode(k);else n.selectNew&&Bb([k],true);ya(new Ca(k));N("changed",[k])},v*1E3)}Ua=null}}});$(a).bind("mousewheel DOMMouseScroll",function(v){if(v.shiftKey){v.preventDefault();
rb=l.getScreenCTM().inverse();var F=O(v.pageX,v.pageY,rb);F={x:F.x,y:F.y,width:0,height:0};if(v.wheelDelta)if(v.wheelDelta>=120)F.factor=2;else{if(v.wheelDelta<=-120)F.factor=0.5}else if(v.detail)if(v.detail>0)F.factor=0.5;else if(v.detail<0)F.factor=2;F.factor&&N("zoomed",F)}})})();var pb=function(e){$(e).click(function(h){h.preventDefault()})},hb=b.textActions=function(){function e(S){var X=I.value==="";$(I).focus();if(!arguments.length)if(X)S=0;else{if(I.selectionEnd!==I.selectionStart)return;
S=I.selectionEnd}var aa;aa=k[S];X||I.setSelectionRange(S,S);D=qa("text_cursor");if(!D){D=document.createElementNS(c,"line");ma(D,{id:"text_cursor",stroke:"#333","stroke-width":1});D=qa("selectorParentGroup").appendChild(D)}L||(L=setInterval(function(){var ga=D.getAttribute("display")==="none";D.setAttribute("display",ga?"inline":"none")},600));X=H(aa.x,u.y);aa=H(aa.x,u.y+u.height);ma(D,{x1:X.x,y1:X.y,x2:aa.x,y2:aa.y,visibility:"visible",display:"inline"});G&&G.setAttribute("d","")}function h(S,X,
aa){if(S===X)e(X);else{aa||I.setSelectionRange(S,X);G=qa("text_selectblock");if(!G){G=document.createElementNS(c,"path");ma(G,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});qa("selectorParentGroup").appendChild(G)}S=k[S];var ga=k[X];D.setAttribute("visibility","hidden");X=H(S.x,u.y);aa=H(S.x+(ga.x-S.x),u.y);var ra=H(S.x,u.y+u.height);S=H(S.x+(ga.x-S.x),u.y+u.height);ma(G,{d:"M"+X.x+","+X.y+" L"+aa.x+","+aa.y+" "+S.x+","+S.y+" "+ra.x+","+ra.y+"z",display:"inline"})}}
function m(S,X){var aa=d.createSVGPoint();aa.x=S;aa.y=X;if(k.length==1)return 0;aa=F.getCharNumAtPosition(aa);if(aa<0){aa=k.length-2;if(S<=k[0].x)aa=0}else if(aa>=k.length-2)aa=k.length-2;var ga=k[aa];S>ga.x+ga.width/2&&aa++;return aa}function z(S,X,aa){var ga=I.selectionStart;S=m(S,X);h(Math.min(ga,S),Math.max(ga,S),!aa)}function w(S,X){var aa={x:S,y:X};aa.x/=o;aa.y/=o;if(C){var ga=O(aa.x,aa.y,C.inverse());aa.x=ga.x;aa.y=ga.y}return aa}function H(S,X){var aa={x:S,y:X};if(C){var ga=O(aa.x,aa.y,C);
aa.x=ga.x;aa.y=ga.y}aa.x*=o;aa.y*=o;return aa}function A(S){h(0,F.textContent.length);$(this).unbind(S)}function v(S){if(U&&F){var X=O(S.pageX,S.pageY,rb);X=w(X.x*o,X.y*o);X=m(X.x,X.y);var aa=F.textContent,ga=aa.substr(0,X).replace(/[a-z0-9]+$/i,"").length;aa=aa.substr(X).match(/^[a-z0-9]+/i);h(ga,(aa?aa[0].length:0)+X);$(S.target).click(A);setTimeout(function(){$(S.target).unbind("click",A)},300)}}var F,I,D,G,L,k=[],u,C,E,P,U;return{select:function(S,X,aa){F=S;hb.toEditMode(X,aa)},start:function(S){F=
S;hb.toEditMode()},mouseDown:function(S,X,aa,ga){S=w(aa,ga);I.focus();e(m(S.x,S.y));E=aa;P=ga},mouseMove:function(S,X){var aa=w(S,X);z(aa.x,aa.y)},mouseUp:function(S,X,aa){var ga=w(X,aa);z(ga.x,ga.y,true);S.target!==F&&X<E+2&&X>E-2&&aa<P+2&&aa>P-2&&hb.toSelectMode(true)},setCursor:e,toEditMode:function(S,X){U=false;Ea="textedit";Ha.requestSelector(F).showGrips(false);Ha.requestSelector(F);hb.init();$(F).css("cursor","text");if(arguments.length){var aa=w(S,X);e(m(aa.x,aa.y))}else e();setTimeout(function(){U=
true},300)},toSelectMode:function(S){Ea="select";clearInterval(L);L=null;G&&$(G).attr("display","none");D&&$(D).attr("visibility","hidden");$(F).css("cursor","move");if(S){Pa();$(F).css("cursor","move");N("selected",[F]);vb([F],true)}F&&!F.textContent.length&&b.deleteSelectedElements();$(I).blur();F=false},setInputElem:function(S){I=S},clear:function(){Ea=="textedit"&&hb.toSelectMode()},init:function(){if(F){if(!F.parentNode){F=J[0];Ha.requestSelector(F).showGrips(false)}var S=F.textContent.length,
X=F.getAttribute("transform");u=svgedit.utilities.getBBox(F);C=X?W(F):null;k=Array(S);I.focus();$(F).unbind("dblclick",v).dblclick(v);if(!S)var aa={x:u.x+u.width/2,width:0};for(X=0;X<S;X++){var ga=F.getStartPositionOfChar(X);aa=F.getEndPositionOfChar(X);if(!svgedit.browser.supportsGoodTextCharPos()){var ra=b.contentW*o;ga.x-=ra;aa.x-=ra;ga.x/=o;aa.x/=o}k[X]={x:ga.x,y:u.y,width:aa.x-ga.x,height:u.height}}k.push({x:aa.x,width:0});h(I.selectionStart,I.selectionEnd,true)}}}}(),Ja=b.pathActions=function(){var e=
false,h,m,z;svgedit.path.Path.prototype.endChanges=function(A){if(svgedit.browser.isWebkit()){var v=this.elem;v.setAttribute("d",Ja.convertPath(v))}A=new Na(this.elem,{d:this.last_d},A);ya(A);N("changed",[this.elem])};svgedit.path.Path.prototype.addPtsToSelection=function(A){$.isArray(A)||(A=[A]);for(var v=0;v<A.length;v++){var F=A[v],I=this.segs[F];I.ptgrip&&this.selected_pts.indexOf(F)==-1&&F>=0&&this.selected_pts.push(F)}this.selected_pts.sort();v=this.selected_pts.length;for(A=Array(v);v--;){I=
this.segs[this.selected_pts[v]];I.select(true);A[v]=I.ptgrip}Ja.canDeleteNodes=true;Ja.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);N("selected",A)};var w=h=null,H=false;return{mouseDown:function(A,v,F,I){if(Ea==="path"){mouse_x=F;mouse_y=I;I=mouse_x/o;v=mouse_y/o;F=qa("path_stretch_line");m=[I,v];if(n.gridSnapping){I=wa(I);v=wa(v);mouse_x=wa(mouse_x);mouse_y=wa(mouse_y)}if(!F){F=document.createElementNS(c,"path");ma(F,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});
F=qa("selectorParentGroup").appendChild(F)}F.setAttribute("display","inline");var D=null;if(w){D=w.pathSegList;for(var G=D.numberOfItems,L=6/o,k=false;G;){G--;var u=D.getItem(G),C=u.x;u=u.y;if(I>=C-L&&I<=C+L&&v>=u-L&&v<=u+L){k=true;break}}L=ca();svgedit.path.removePath_(L);L=qa(L);C=D.numberOfItems;if(k){if(G<=1&&C>=2){I=D.getItem(0).x;v=D.getItem(0).y;A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(I,v):w.createSVGPathSegCurvetoCubicAbs(I,v,A.x1/o,A.y1/o,I,v);I=w.createSVGPathSegClosePath();
D.appendItem(A);D.appendItem(I)}else if(C<3)return D=false;$(F).remove();element=L;w=null;La=false;if(e){svgedit.path.path.matrix&&db(L,{},svgedit.path.path.matrix.inverse());F=L.getAttribute("d");A=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",A+F);$(L).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();Ja.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,Ib(A))){console.log("Clicked outside canvas");
return false}D=w.pathSegList.numberOfItems;G=w.pathSegList.getItem(D-1);L=G.x;G=G.y;if(A.shiftKey){A=ba(L,G,I,v);I=A.x;v=A.y}A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(eb(I),eb(v)):w.createSVGPathSegCurvetoCubicAbs(eb(I),eb(v),A.x1/o,A.y1/o,A.x2/o,A.y2/o);w.pathSegList.appendItem(A);I*=o;v*=o;F.setAttribute("d",["M",I,v,I,v].join(" "));F=D;if(e)F+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(F,I,v)}}else{d_attr="M"+I+","+v+" ";w=Q({element:"path",curStyles:true,
attr:{d:d_attr,id:ja(),opacity:M.opacity/2}});F.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));F=e?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(F,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();L=A.target.id;if(L.substr(0,14)=="pathpointgrip_"){v=svgedit.path.path.cur_pt=parseInt(L.substr(14));svgedit.path.path.dragging=[F,I];D=svgedit.path.path.segs[v];if(A.shiftKey)D.selected?svgedit.path.path.removePtFromSelection(v):svgedit.path.path.addPtsToSelection(v);
else{if(svgedit.path.path.selected_pts.length<=1||!D.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(v)}}else if(L.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[F,I];A=L.split("_")[1].split("c");v=A[0]-0;svgedit.path.path.selectPt(v,A[1]-0)}if(!svgedit.path.path.dragging){if(ta==null)ta=Ha.getRubberBandBox();ma(ta,{x:F*o,y:I*o,width:0,height:0,display:"inline"},100)}}},mouseMove:function(A,v,F){H=true;if(Ea==="path"){if(w){var I=w.pathSegList;A=I.numberOfItems-
1;if(m){var D=svgedit.path.addCtrlGrip("1c1"),G=svgedit.path.addCtrlGrip("0c2");G.getAttribute("cx");G.getAttribute("cy");D.setAttribute("cx",v);D.setAttribute("cy",F);D.setAttribute("display","inline");D=m[0];var L=m[1];I.getItem(A);var k=D+(D-v/o),u=L+(L-F/o);G.setAttribute("cx",k*o);G.setAttribute("cy",u*o);G.setAttribute("display","inline");G=svgedit.path.getCtrlLine(1);var C=svgedit.path.getCtrlLine(2);ma(G,{x1:v,y1:F,x2:D*o,y2:L*o,display:"inline"});ma(C,{x1:k*o,y1:u*o,x2:D*o,y2:L*o,display:"inline"});
if(A===0)z=[v,F];else{I=I.getItem(A-1);v=I.x;F=I.y;if(I.pathSegType===6){v+=v-I.x2;F+=F-I.y2}else if(z){v=z[0]/o;F=z[1]/o}svgedit.path.replacePathSeg(6,A,[D,L,v,F,k,u],w)}}else if(D=qa("path_stretch_line")){A=I.getItem(A);if(A.pathSegType===6)svgedit.path.replacePathSeg(6,1,[v,F,(A.x+(A.x-A.x2))*o,(A.y+(A.y-A.y2))*o,v,F],D);else z?svgedit.path.replacePathSeg(6,1,[v,F,z[0],z[1],v,F],D):svgedit.path.replacePathSeg(4,1,[v,F],D)}}}else if(svgedit.path.path.dragging){D=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],
y:svgedit.path.path.dragging[1]},svgedit.path.path);L=svgedit.path.getPointFromGrip({x:v,y:F},svgedit.path.path);A=L.x-D.x;D=L.y-D.y;svgedit.path.path.dragging=[v,F];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(A,D):svgedit.path.path.movePts(A,D)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var E=ta.getBBox(),P=svgedit.path.getGripPt(this);E=svgedit.math.rectsIntersect(E,{x:P.x,y:P.y,width:0,height:0});this.select(E);E&&svgedit.path.path.selected_pts.push(this.index)}})}},
mouseUp:function(A,v){if(Ea==="path"){m=null;if(!w){v=qa(ca());La=false;z=null}return{keep:true,element:v}}if(svgedit.path.path.dragging){var F=svgedit.path.path.cur_pt;svgedit.path.path.dragging=false;svgedit.path.path.dragctrl=false;svgedit.path.path.update();H&&svgedit.path.path.endChanges("Move path point(s)");!A.shiftKey&&!H&&svgedit.path.path.selectPt(F)}else if(ta&&ta.getAttribute("display")!="none"){ta.setAttribute("display","none");ta.getAttribute("width")<=2&&ta.getAttribute("height")<=
2&&Ja.toSelectMode(A.target)}else Ja.toSelectMode(A.target);H=false},toEditMode:function(A){svgedit.path.path=svgedit.path.getPath_(A);Ea="pathedit";Pa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);e=false},toSelectMode:function(A){var v=A==svgedit.path.path.elem;Ea="select";svgedit.path.path.show(false);h=false;Pa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(v){N("selected",[A]);vb([A],true)}},addSubPath:function(A){if(A){Ea=
"path";e=true}else{Ja.clear(true);Ja.toEditMode(svgedit.path.path.elem)}},select:function(A){if(h===A){Ja.toEditMode(A);Ea="pathedit"}else h=A},reorient:function(){var A=J[0];if(A)if(oa(A)!=0){var v=new za("Reorient path"),F={d:A.getAttribute("d"),transform:A.getAttribute("transform")};v.addSubCommand(new Na(A,F));Pa();this.resetOrientation(A);ya(v);svgedit.path.getPath_(A).show(false).matrix=null;this.clear();vb([A],true);N("changed",J)}},clear:function(){h=null;if(w){var A=qa(ca());$(qa("path_stretch_line")).remove();
$(A).remove();$(qa("pathpointgrip_container")).find("*").attr("display","none");w=z=null;La=false}else Ea=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(A){if(A==null||A.nodeName!="path")return false;var v=Y(A),F=fa(v).matrix;v.clear();A.removeAttribute("transform");v=A.pathSegList;for(var I=v.numberOfItems,D=0;D<I;++D){var G=v.getItem(D),L=G.pathSegType;if(L!=1){var k=[];$.each(["",1,2],function(u,C){var E=G["x"+C],P=G["y"+C];if(E!==
undefined&&P!==undefined){E=O(E,P,F);k.splice(k.length,0,E.x,E.y)}});svgedit.path.replacePathSeg(L,D,k,A)}}g(A,F)},zoomChange:function(){Ea=="pathedit"&&svgedit.path.path.update()},getNodePoint:function(){var A=svgedit.path.path.segs[svgedit.path.path.selected_pts.length?svgedit.path.path.selected_pts[0]:1];return{x:A.item.x,y:A.item.y,type:A.type}},linkControlPoints:function(A){svgedit.path.setLinkControlPoints(A)},clonePathNode:function(){svgedit.path.path.storeD();for(var A=svgedit.path.path.selected_pts,
v=A.length,F=[];v--;){var I=A[v];svgedit.path.path.addSeg(I);F.push(I+v);F.push(I+v+1)}svgedit.path.path.init().addPtsToSelection(F);svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var A=svgedit.path.path.selected_pts;if(A.length===1){var v=svgedit.path.path.elem,F=v.pathSegList,I=A[0],D=null,G=null;svgedit.path.path.eachSeg(function(C){if(this.type===2&&C<=I)G=this.item;if(C<=I)return true;if(this.type===2){D=C;return false}else if(this.type===1)return D=false});if(D==
null)D=svgedit.path.path.segs.length-1;if(D!==false){var L=v.createSVGPathSegLinetoAbs(G.x,G.y),k=v.createSVGPathSegClosePath();if(D==svgedit.path.path.segs.length-1){F.appendItem(L);F.appendItem(k)}else{svgedit.path.insertItemBefore(v,k,D);svgedit.path.insertItemBefore(v,L,D)}svgedit.path.path.init().selectPt(D+1)}else if(svgedit.path.path.segs[I].mate){F.removeItem(I);F.removeItem(I);svgedit.path.path.init().selectPt(I-1)}else{for(A=0;A<F.numberOfItems;A++){var u=F.getItem(A);if(u.pathSegType===
2)L=A;else if(A===I)F.removeItem(L);else if(u.pathSegType===1&&I<A){k=A-1;F.removeItem(A);break}}for(A=I-L-1;A--;)svgedit.path.insertItemBefore(v,F.getItem(L),k);v=F.getItem(L);svgedit.path.replacePathSeg(2,L,[v.x,v.y]);A=I;svgedit.path.path.init().selectPt(0)}}},deletePathNode:function(){if(Ja.canDeleteNodes){svgedit.path.path.storeD();for(var A=svgedit.path.path.selected_pts,v=A.length;v--;)svgedit.path.path.deleteSeg(A[v]);var F=function(){var I=svgedit.path.path.elem.pathSegList,D=I.numberOfItems,
G=function(u,C){for(;C--;)I.removeItem(u)};if(D<=1)return true;for(;D--;){var L=I.getItem(D);if(L.pathSegType===1){L=I.getItem(D-1);var k=I.getItem(D-2);if(L.pathSegType===2){G(D-1,2);F();break}else if(k.pathSegType===2){G(D-2,3);F();break}}else if(L.pathSegType===2)if(D>0){L=I.getItem(D-1).pathSegType;if(L===2){G(D-1,1);F();break}else if(L===1&&I.numberOfItems-1===D){G(D,1);F();break}}}return false};F();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){Ja.toSelectMode(svgedit.path.path.elem);
b.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){A=$(svgedit.path.path.elem);A.attr("d",A.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(A){var v=A.points,F=v.numberOfItems;if(F>=4){var I=v.getItem(0),D=null;A=[];A.push(["M",I.x,",",I.y," C"].join(""));for(var G=1;G<=F-4;G+=3){var L=v.getItem(G),k=v.getItem(G+1),u=v.getItem(G+2);if(D)if((I=svgedit.path.smoothControlPoints(D,L,I))&&I.length==
2){L=A[A.length-1].split(",");L[2]=I[0].x;L[3]=I[0].y;A[A.length-1]=L.join(",");L=I[1]}A.push([L.x,L.y,k.x,k.y,u.x,u.y].join(","));I=u;D=k}for(A.push("L");G<F;++G){k=v.getItem(G);A.push([k.x,k.y].join(","))}A=A.join(" ");A=Q({element:"path",curStyles:true,attr:{id:ca(),d:A,fill:"none"}})}return A},setSegType:function(A){svgedit.path.path.setSegType(A)},moveNode:function(A,v){var F=svgedit.path.path.selected_pts;if(F.length){svgedit.path.path.storeD();F=svgedit.path.path.segs[F[0]];var I={x:0,y:0};
I[A]=v-F.item[A];F.move(I.x,I.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(A){for(var v=A.pathSegList,F=v.numberOfItems,I,D=0;D<F;++D){var G=v.getItem(D);if(G.pathSegType===2)I=G;if(G.pathSegType===1){G=v.getItem(D-1);if(G.x!=I.x||G.y!=I.y){v=A.createSVGPathSegLinetoAbs(I.x,I.y);svgedit.path.insertItemBefore(A,v,D);Ja.fixEnd(A);break}}}svgedit.browser.isWebkit()&&A.setAttribute("d",Ja.convertPath(A))},convertPath:function(A,v){for(var F=A.pathSegList,I=F.numberOfItems,D=0,
G=0,L="",k=null,u=0;u<I;++u){var C=F.getItem(u),E=C.x||0,P=C.y||0,U=C.x1||0,S=C.y1||0,X=C.x2||0,aa=C.y2||0,ga=C.pathSegType,ra=Oa[ga]["to"+(v?"Lower":"Upper")+"Case"](),Ta=function(Ba,ha,Sa){ha=ha?" "+ha.join(" "):"";Sa=Sa?" "+svgedit.units.shortFloat(Sa):"";$.each(Ba,function(Qa,ua){Ba[Qa]=svgedit.units.shortFloat(ua)});L+=ra+Ba.join(" ")+ha+Sa};switch(ga){case 1:L+="z";break;case 12:E-=D;case 13:if(v){D+=E;ra="l"}else{E+=D;D=E;ra="L"}Ta([[E,G]]);break;case 14:P-=G;case 15:if(v){G+=P;ra="l"}else{P+=
G;G=P;ra="L"}Ta([[D,P]]);break;case 2:case 4:case 18:E-=D;P-=G;case 5:case 3:if(k&&F.getItem(u-1).pathSegType===1&&!v){D=k[0];G=k[1]}case 19:if(v){D+=E;G+=P}else{E+=D;P+=G;D=E;G=P}if(ga===3)k=[D,G];Ta([[E,P]]);break;case 6:E-=D;U-=D;X-=D;P-=G;S-=G;aa-=G;case 7:if(v){D+=E;G+=P}else{E+=D;U+=D;X+=D;P+=G;S+=G;aa+=G;D=E;G=P}Ta([[U,S],[X,aa],[E,P]]);break;case 8:E-=D;U-=D;P-=G;S-=G;case 9:if(v){D+=E;G+=P}else{E+=D;U+=D;P+=G;S+=G;D=E;G=P}Ta([[U,S],[E,P]]);break;case 10:E-=D;P-=G;case 11:if(v){D+=E;G+=P}else{E+=
D;P+=G;D=E;G=P}Ta([[C.r1,C.r2]],[C.angle,C.largeArcFlag?1:0,C.sweepFlag?1:0],[E,P]);break;case 16:E-=D;X-=D;P-=G;aa-=G;case 17:if(v){D+=E;G+=P}else{E+=D;X+=D;P+=G;aa+=G;D=E;G=P}Ta([[X,aa],[E,P]])}}return L}}}(),Kb=this.removeUnusedDefElems=function(){var e=l.getElementsByTagNameNS(c,"defs");if(!e||!e.length)return 0;for(var h=[],m=0,z=["fill","stroke","filter","marker-start","marker-mid","marker-end"],w=z.length,H=l.getElementsByTagNameNS(c,"*"),A=H.length,v=0;v<A;v++){for(var F=H[v],I=0;I<w;I++){var D=
ka(F.getAttribute(z[I]));D&&h.push(D.substr(1))}(F=da(F))&&F.indexOf("#")===0&&h.push(F.substr(1))}e=$(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(v=e.length;v--;){z=e[v];w=z.id;if(h.indexOf(w)<0){zb[w]=z;z.parentNode.removeChild(z);m++}}return m};this.svgCanvasToString=function(){for(;Kb()>0;);Ja.clear(true);$.each(l.childNodes,function(m,z){m&&z.nodeType===8&&z.data.indexOf("Created with")>=0&&l.insertBefore(z,l.firstChild)});if(K){Jb();Bb([K])}var e=
[];$(l).find("g:data(gsvg)").each(function(){for(var m=this.attributes,z=m.length,w=0;w<z;w++)if(m[w].nodeName=="id"||m[w].nodeName=="style")z--;if(z<=0){m=this.firstChild;e.push(m);$(this).replaceWith(m)}});var h=this.svgToString(l,0);e.length&&$(e).each(function(){Ab(this)});return h};this.svgToString=function(e,h){var m=[],z=svgedit.utilities.toXml,w=n.baseUnit,H=RegExp("^-?[\\d\\.]+"+w+"$");if(e){na(e);var A=e.attributes,v,F,I=e.childNodes;for(F=0;F<h;F++)m.push(" ");m.push("<");m.push(e.nodeName);
if(e.id==="svgcontent"){F=Eb();if(w!=="px"){F.w=svgedit.units.convertUnit(F.w,w)+w;F.h=svgedit.units.convertUnit(F.h,w)+w}m.push(' width="'+F.w+'" height="'+F.h+'" xmlns="'+c+'"');var D={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(u,C){var E=C.namespaceURI;if(E&&!D[E]&&Aa[E]!=="xmlns"&&Aa[E]!=="xml"){D[E]=true;m.push(" xmlns:"+Aa[E]+'="'+E+'"')}})});F=A.length;for(w=["width","height","xmlns","x","y","viewBox","id","overflow"];F--;){v=A.item(F);var G=z(v.nodeValue);if(v.nodeName.indexOf("xmlns:")!==
rb),E=I.x*o;I=I.y*o;var G=qa(ca()),L=x=E/o,k=y=I/o;if(n.gridSnapping){x=wa(x);y=wa(y)}v.preventDefault();switch(Ea){case "select":if(J[0]!==null){L=x-h;var u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u)}if(v.shiftKey){var C=ba(h,m,x,y);x=C.x;y=C.y}if(L!=0||u!=0){C=J.length;for(k=0;k<C;++k){F=J[k];if(F==null)break;var D=d.createSVGTransform();G=X(F);D.setTranslate(L,u);G.numberOfItems?G.replaceItem(D,0):G.appendItem(D);Ha.requestSelector(F).resize()}if(v.altKey)if(!b.addClones){b.addClones=b.cloneSelectedElements(0,
0,D);b.removeClones=function(){b.addClones&&b.addClones.forEach(function(Oa){Oa.parentNode&&Oa.parentNode.removeChild(Oa);b.addClones=false})};window.addEventListener("keyup",b.removeClones)}N("transition",J)}}break;case "multiselect":L*=o;k*=o;ma(ua,{x:Math.min(z,L),y:Math.min(w,k),width:Math.abs(L-z),height:Math.abs(k-w)},100);G=[];L=[];D=tb();C=J.length;for(k=0;k<C;++k){u=D.indexOf(J[k]);if(u==-1)G.push(J[k]);else D[u]=null}C=D.length;for(k=0;k<C;++k)D[k]&&L.push(D[k]);G.length>0&&b.removeFromSelection(G);
L.length>0&&vb(L);break;case "resize":G=X(F);L=(D=pa(G))?H:svgedit.utilities.getBBox(F);C=L.x;k=L.y;var P=L.width,U=L.height;L=x-h;u=y-m;if(n.gridSnapping){L=wa(L);u=wa(u);U=wa(U);P=wa(P)}var S=oa(F);if(S){var Y=Math.sqrt(L*L+u*u);u=Math.atan2(u,L)-S*Math.PI/180;L=Y*Math.cos(u);u=Y*Math.sin(u)}if(kb.indexOf("n")==-1&&kb.indexOf("s")==-1)u=0;if(kb.indexOf("e")==-1&&kb.indexOf("w")==-1)L=0;var aa=Y=0,ga=U?(U+u)/U:1,ra=P?(P+L)/P:1;if(kb.indexOf("n")>=0){ga=U?(U-u)/U:1;aa=U}if(kb.indexOf("w")>=0){ra=
P?(P-L)/P:1;Y=P}L=d.createSVGTransform();u=d.createSVGTransform();P=d.createSVGTransform();if(n.gridSnapping){C=wa(C);Y=wa(Y);k=wa(k);aa=wa(aa)}L.setTranslate(-(C+Y),-(k+aa));if(v.shiftKey)if(ra==1)ra=ga;else ga=ra;u.setScale(ra,ga);P.setTranslate(C+Y,k+aa);if(D){D=S?1:0;G.replaceItem(L,2+D);G.replaceItem(u,1+D);G.replaceItem(P,0+D)}else{D=G.numberOfItems;G.replaceItem(P,D-3);G.replaceItem(u,D-2);G.replaceItem(L,D-1)}Ha.requestSelector(F).resize();N("transition",J);break;case "zoom":L*=o;k*=o;ma(ua,
{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100);break;case "text":ma(G,{x:x,y:y},1E3);break;case "line":L=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=wa(x);y=wa(y)}D=x;C=y;if(v.shiftKey){C=ba(h,m,D,C);D=C.x;C=C.y}G.setAttributeNS(null,"x2",D);G.setAttributeNS(null,"y2",C);window.opera||d.unsuspendRedraw(L);break;case "foreignObject":case "square":case "rect":case "image":L=Math.abs(x-h);D=Math.abs(y-m);if(Ea=="square"||v.shiftKey){L=D=Math.max(L,
D);C=h<x?h:h-L;k=m<y?m:m-D}else{C=Math.min(h,x);k=Math.min(m,y)}if(v.altKey){L*=2;D*=2;C=h-L/2;k=m-D/2}if(n.gridSnapping){L=wa(L);D=wa(D);C=wa(C);k=wa(k)}ma(G,{width:L,height:D,x:C,y:k},1E3);break;case "circle":L=$(G).attr(["cx","cy"]);D=L.cx;C=L.cy;L=Math.sqrt((x-D)*(x-D)+(y-C)*(y-C));if(n.gridSnapping)L=wa(L);G.setAttributeNS(null,"r",L);break;case "ellipse":L=$(G).attr(["cx","cy"]);D=Math.abs(h+(x-h)/2);C=Math.abs(m+(y-m)/2);L=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=wa(x);
D=wa(D);y=wa(y);C=wa(C)}k=Math.abs(h-D);u=Math.abs(m-C);if(v.shiftKey){u=k;C=y>m?m+k:m-k}if(v.altKey){D=h;C=m;k=Math.abs(x-D);u=v.shiftKey?k:Math.abs(y-C)}G.setAttributeNS(null,"rx",k);G.setAttributeNS(null,"ry",u);G.setAttributeNS(null,"cx",D);G.setAttributeNS(null,"cy",C);window.opera||d.unsuspendRedraw(L);break;case "fhellipse":case "fhrect":A.minx=Math.min(L,A.minx);A.maxx=Math.max(L,A.maxx);A.miny=Math.min(k,A.miny);A.maxy=Math.max(k,A.maxy);case "fhpath":e+=+L+","+k+" ";G.setAttributeNS(null,
"points",e);break;case "path":case "pathedit":x*=o;y*=o;if(n.gridSnapping){x=wa(x);y=wa(y);h=wa(h);m=wa(m)}if(v.shiftKey){if(D=svgedit.path.path){G=D.dragging?D.dragging[0]:h;D=D.dragging?D.dragging[1]:m}else{G=h;D=m}C=ba(G,D,x,y);x=C.x;y=C.y}if(ua&&ua.getAttribute("display")!=="none"){L*=o;k*=o;ma(ua,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100)}Ja.mouseMove(v,x,y);break;case "textedit":x*=o;y*=o;hb.mouseMove(E,I);break;case "rotate":L=svgedit.utilities.getBBox(F);
D=L.x+L.width/2;C=L.y+L.height/2;G=W(F);G=O(D,C,G);D=G.x;C=G.y;G=L.x;k=L.y;if(current_rotate_mode=="nw")G=L.x+L.width;if(current_rotate_mode=="se")k=L.y+L.height;if(current_rotate_mode=="sw"){G=L.x+L.width;k=L.y+L.height}compensation_angle=(Math.atan2(C-k,D-G)*(180/Math.PI)-90)%360;S=(Math.atan2(C-y,D-x)*(180/Math.PI)-90)%360;S+=compensation_angle;if(n.gridSnapping)S=wa(S);if(v.shiftKey)S=Math.round(S/45)*45;b.setRotationAngle(S<-180?360+S:S,true);N("transition",J)}ob("mouseMove",{event:v,mouse_x:E,
mouse_y:I,selected:F})}}).click(function(v){v.preventDefault();return false}).dblclick(function(v){var F=v.target.parentNode;if(F!==K){var I=Ib(v),E=I.tagName;if(E==="text"&&Ea!=="textedit"){v=O(v.pageX,v.pageY,rb);hb.select(I,v.x,v.y)}if((E==="g"||E==="a")&&oa(I)){Mb(I);I=J[0];Qa(true)}K&&Jb();F.tagName!=="g"&&F.tagName!=="a"||F===B().getCurrentLayer()||I===Ha.selectorParentGroup||Rb(I)}}).mouseup(function(v){b.addClones=false;window.removeEventListener("keyup",b.removeClones);if(v.button!==2){var F=
Cb;Cb=null;if(La){var I=O(v.pageX,v.pageY,rb),E=I.x*o;I=I.y*o;var G=E/o,L=I/o,k=qa(ca()),u=false;La=false;switch(Ea){case "resize":case "multiselect":if(ua!=null){ua.setAttribute("display","none");mb=[]}Ea="select";case "select":if(J[0]!=null){if(J[1]==null){E=J[0];switch(E.tagName){case "g":case "use":case "image":case "foreignObject":break;default:bb.fill=E.getAttribute("fill");bb.fill_opacity=E.getAttribute("fill-opacity");bb.stroke=E.getAttribute("stroke");bb.stroke_opacity=E.getAttribute("stroke-opacity");
bb.stroke_width=E.getAttribute("stroke-width");bb.stroke_dasharray=E.getAttribute("stroke-dasharray");bb.stroke_linejoin=E.getAttribute("stroke-linejoin");bb.stroke_linecap=E.getAttribute("stroke-linecap")}if(E.tagName=="text"){Za.font_size=E.getAttribute("font-size");Za.font_family=E.getAttribute("font-family")}Ha.requestSelector(E).showGrips(true)}Ga();if(G!=z||L!=w){v=J.length;for(E=0;E<v;++E){if(J[E]==null)break;J[E].firstChild||Ha.requestSelector(J[E]).resize()}}else{E=v.target;if(J[0].nodeName===
"path"&&J[1]==null)Ja.select(J[0]);else v.shiftKey&&F!=E&&b.removeFromSelection([E])}if(svgedit.browser.supportsNonScalingStroke())if(v=J[0]){v.removeAttribute("style");svgedit.utilities.walkTree(v,function(P){P.removeAttribute("style")})}}return;case "zoom":ua!=null&&ua.setAttribute("display","none");N("zoomed",{x:Math.min(z,G),y:Math.min(w,L),width:Math.abs(G-z),height:Math.abs(L-w),factor:v.altKey?0.5:2});return;case "fhpath":F=k.getAttribute("points");G=F.indexOf(",");if(u=G>=0?F.indexOf(",",
G+1)>=0:F.indexOf(" ",F.indexOf(" ")+1)>=0)k=Ja.smoothPolylineIntoPath(k);break;case "line":F=$(k).attr(["x1","x2","y1","y2"]);u=F.x1!=F.x2||F.y1!=F.y2;break;case "foreignObject":case "square":case "rect":case "image":F=$(k).attr(["width","height"]);u=F.width!=0||F.height!=0||Ea==="image";break;case "circle":u=k.getAttribute("r")!=0;break;case "ellipse":F=$(k).attr(["rx","ry"]);u=F.rx!=null||F.ry!=null;break;case "fhellipse":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=Q({element:"ellipse",curStyles:true,
attr:{cx:(A.minx+A.maxx)/2,cy:(A.miny+A.maxy)/2,rx:(A.maxx-A.minx)/2,ry:(A.maxy-A.miny)/2,id:ca()}});N("changed",[k]);u=true}break;case "fhrect":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=Q({element:"rect",curStyles:true,attr:{x:A.minx,y:A.miny,width:A.maxx-A.minx,height:A.maxy-A.miny,id:ca()}});N("changed",[k]);u=true}break;case "text":u=true;xb([k]);hb.start(k);break;case "path":k=null;La=true;F=Ja.mouseUp(v,k,E,I);k=F.element;u=F.keep;break;case "pathedit":u=true;k=null;Ja.mouseUp(v);break;case "textedit":u=
false;k=null;hb.mouseUp(v,E,I);break;case "rotate":u=true;k=null;Ea="select";F=b.undoMgr.finishUndoableChange();F.isEmpty()||ya(F);Ga();N("changed",J)}E=ob("mouseUp",{event:v,mouse_x:E,mouse_y:I},true);$.each(E,function(P,U){if(U){u=U.keep||u;k=U.element;La=U.started||La}});if(!u&&k!=null){B().releaseId(ca());k.parentNode.removeChild(k);k=null;for(E=v.target;E.parentNode.parentNode.tagName=="g";)E=E.parentNode;if((Ea!="path"||!drawn_path)&&E.parentNode.id!="selectorParentGroup"&&E.id!="svgcanvas"&&
E.id!="svgroot"){b.setMode("select");xb([E],true)}}else if(k!=null){b.addedNew=true;v=0.2;var C;if(false.beginElement&&k.getAttribute("opacity")!=M.opacity){C=$(false).clone().attr({to:M.opacity,dur:v}).appendTo(k);try{C[0].beginElement()}catch(D){}}else v=0;setTimeout(function(){C&&C.remove();k.setAttribute("opacity",M.opacity);k.setAttribute("style","pointer-events:inherit");na(k);if(Ea==="path")Ja.toEditMode(k);else n.selectNew&&xb([k],true);ya(new Ca(k));N("changed",[k])},v*1E3)}Va=null}}});$(a).bind("mousewheel DOMMouseScroll",
function(v){if(v.shiftKey){v.preventDefault();rb=l.getScreenCTM().inverse();var F=O(v.pageX,v.pageY,rb);F={x:F.x,y:F.y,width:0,height:0};if(v.wheelDelta)if(v.wheelDelta>=120)F.factor=2;else{if(v.wheelDelta<=-120)F.factor=0.5}else if(v.detail)if(v.detail>0)F.factor=0.5;else if(v.detail<0)F.factor=2;F.factor&&N("zoomed",F)}})})();var pb=function(e){$(e).click(function(h){h.preventDefault()})},hb=b.textActions=function(){function e(S){var Y=I.value==="";$(I).focus();if(!arguments.length)if(Y)S=0;else{if(I.selectionEnd!==
I.selectionStart)return;S=I.selectionEnd}var aa;aa=k[S];Y||I.setSelectionRange(S,S);E=qa("text_cursor");if(!E){E=document.createElementNS(c,"line");ma(E,{id:"text_cursor",stroke:"#333","stroke-width":1});E=qa("selectorParentGroup").appendChild(E)}L||(L=setInterval(function(){var ga=E.getAttribute("display")==="none";E.setAttribute("display",ga?"inline":"none")},600));Y=H(aa.x,u.y);aa=H(aa.x,u.y+u.height);ma(E,{x1:Y.x,y1:Y.y,x2:aa.x,y2:aa.y,visibility:"visible",display:"inline"});G&&G.setAttribute("d",
"")}function h(S,Y,aa){if(S===Y)e(Y);else{aa||I.setSelectionRange(S,Y);G=qa("text_selectblock");if(!G){G=document.createElementNS(c,"path");ma(G,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});qa("selectorParentGroup").appendChild(G)}S=k[S];var ga=k[Y];E.setAttribute("visibility","hidden");Y=H(S.x,u.y);aa=H(S.x+(ga.x-S.x),u.y);var ra=H(S.x,u.y+u.height);S=H(S.x+(ga.x-S.x),u.y+u.height);ma(G,{d:"M"+Y.x+","+Y.y+" L"+aa.x+","+aa.y+" "+S.x+","+S.y+" "+ra.x+","+ra.y+"z",display:"inline"})}}
function m(S,Y){var aa=d.createSVGPoint();aa.x=S;aa.y=Y;if(k.length==1)return 0;aa=F.getCharNumAtPosition(aa);if(aa<0){aa=k.length-2;if(S<=k[0].x)aa=0}else if(aa>=k.length-2)aa=k.length-2;var ga=k[aa];S>ga.x+ga.width/2&&aa++;return aa}function z(S,Y,aa){var ga=I.selectionStart;S=m(S,Y);h(Math.min(ga,S),Math.max(ga,S),!aa)}function w(S,Y){var aa={x:S,y:Y};aa.x/=o;aa.y/=o;if(C){var ga=O(aa.x,aa.y,C.inverse());aa.x=ga.x;aa.y=ga.y}return aa}function H(S,Y){var aa={x:S,y:Y};if(C){var ga=O(aa.x,aa.y,C);
aa.x=ga.x;aa.y=ga.y}aa.x*=o;aa.y*=o;return aa}function A(S){h(0,F.textContent.length);$(this).unbind(S)}function v(S){if(U&&F){var Y=O(S.pageX,S.pageY,rb);Y=w(Y.x*o,Y.y*o);Y=m(Y.x,Y.y);var aa=F.textContent,ga=aa.substr(0,Y).replace(/[a-z0-9]+$/i,"").length;aa=aa.substr(Y).match(/^[a-z0-9]+/i);h(ga,(aa?aa[0].length:0)+Y);$(S.target).click(A);setTimeout(function(){$(S.target).unbind("click",A)},300)}}var F,I,E,G,L,k=[],u,C,D,P,U;return{select:function(S,Y,aa){F=S;hb.toEditMode(Y,aa)},start:function(S){F=
S;hb.toEditMode()},mouseDown:function(S,Y,aa,ga){S=w(aa,ga);I.focus();e(m(S.x,S.y));D=aa;P=ga},mouseMove:function(S,Y){var aa=w(S,Y);z(aa.x,aa.y)},mouseUp:function(S,Y,aa){var ga=w(Y,aa);z(ga.x,ga.y,true);S.target!==F&&Y<D+2&&Y>D-2&&aa<P+2&&aa>P-2&&hb.toSelectMode(true)},setCursor:e,toEditMode:function(S,Y){xb([F],false);U=false;Ea="textedit";Ha.requestSelector(F);hb.init();$(F).css("cursor","text");if(arguments.length){var aa=w(S,Y);e(m(aa.x,aa.y))}else e();setTimeout(function(){U=true},300)},toSelectMode:function(S){Ea=
"select";clearInterval(L);L=null;G&&$(G).attr("display","none");E&&$(E).attr("visibility","hidden");$(F).css("cursor","move");if(S){Qa();$(F).css("cursor","move");N("selected",[F]);vb([F],true)}F&&!F.textContent.length&&b.deleteSelectedElements();$(I).blur();F=false},setInputElem:function(S){I=S},clear:function(){Ea=="textedit"&&hb.toSelectMode()},init:function(){if(F){if(!F.parentNode){F=J[0];Ha.requestSelector(F).showGrips(false)}var S=F.textContent.length,Y=F.getAttribute("transform");u=svgedit.utilities.getBBox(F);
C=Y?W(F):null;k=Array(S);I.focus();$(F).unbind("dblclick",v).dblclick(v);if(!S)var aa={x:u.x+u.width/2,width:0};for(Y=0;Y<S;Y++){var ga=F.getStartPositionOfChar(Y);aa=F.getEndPositionOfChar(Y);if(!svgedit.browser.supportsGoodTextCharPos()){var ra=b.contentW*o;ga.x-=ra;aa.x-=ra;ga.x/=o;aa.x/=o}k[Y]={x:ga.x,y:u.y,width:aa.x-ga.x,height:u.height}}k.push({x:aa.x,width:0});h(I.selectionStart,I.selectionEnd,true)}}}}(),Ja=b.pathActions=function(){var e=false,h,m,z;svgedit.path.Path.prototype.endChanges=
function(A){if(svgedit.browser.isWebkit()){var v=this.elem;v.setAttribute("d",Ja.convertPath(v))}A=new Na(this.elem,{d:this.last_d},A);ya(A);N("changed",[this.elem])};svgedit.path.Path.prototype.addPtsToSelection=function(A){$.isArray(A)||(A=[A]);for(var v=0;v<A.length;v++){var F=A[v],I=this.segs[F];I.ptgrip&&this.selected_pts.indexOf(F)==-1&&F>=0&&this.selected_pts.push(F)}this.selected_pts.sort();v=this.selected_pts.length;for(A=Array(v);v--;){I=this.segs[this.selected_pts[v]];I.select(true);A[v]=
I.ptgrip}Ja.canDeleteNodes=true;Ja.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);N("selected",A)};var w=h=null,H=false;return{mouseDown:function(A,v,F,I){if(Ea==="path"){mouse_x=F;mouse_y=I;I=mouse_x/o;v=mouse_y/o;F=qa("path_stretch_line");m=[I,v];if(n.gridSnapping){I=wa(I);v=wa(v);mouse_x=wa(mouse_x);mouse_y=wa(mouse_y)}if(!F){F=document.createElementNS(c,"path");ma(F,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});F=qa("selectorParentGroup").appendChild(F)}F.setAttribute("display",
"inline");var E=null;if(w){E=w.pathSegList;for(var G=E.numberOfItems,L=6/o,k=false;G;){G--;var u=E.getItem(G),C=u.x;u=u.y;if(I>=C-L&&I<=C+L&&v>=u-L&&v<=u+L){k=true;break}}L=ca();svgedit.path.removePath_(L);L=qa(L);C=E.numberOfItems;if(k){if(G<=1&&C>=2){I=E.getItem(0).x;v=E.getItem(0).y;A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(I,v):w.createSVGPathSegCurvetoCubicAbs(I,v,A.x1/o,A.y1/o,I,v);I=w.createSVGPathSegClosePath();E.appendItem(A);E.appendItem(I)}else if(C<3)return E=
false;$(F).remove();element=L;w=null;La=false;if(e){svgedit.path.path.matrix&&db(L,{},svgedit.path.path.matrix.inverse());F=L.getAttribute("d");A=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",A+F);$(L).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();svgedit.path.path.init();Ja.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,Ib(A))){console.log("Clicked outside canvas");return false}E=w.pathSegList.numberOfItems;
G=w.pathSegList.getItem(E-1);L=G.x;G=G.y;if(A.shiftKey){A=ba(L,G,I,v);I=A.x;v=A.y}A=F.pathSegList.getItem(1);A=A.pathSegType===4?w.createSVGPathSegLinetoAbs(eb(I),eb(v)):w.createSVGPathSegCurvetoCubicAbs(eb(I),eb(v),A.x1/o,A.y1/o,A.x2/o,A.y2/o);w.pathSegList.appendItem(A);I*=o;v*=o;F.setAttribute("d",["M",I,v,I,v].join(" "));F=E;if(e)F+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(F,I,v)}}else{d_attr="M"+I+","+v+" ";w=Q({element:"path",curStyles:true,attr:{d:d_attr,id:ja(),opacity:M.opacity/
2}});F.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));F=e?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(F,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();L=A.target.id;if(L.substr(0,14)=="pathpointgrip_"){v=svgedit.path.path.cur_pt=parseInt(L.substr(14));svgedit.path.path.dragging=[F,I];E=svgedit.path.path.segs[v];if(A.shiftKey)E.selected?svgedit.path.path.removePtFromSelection(v):svgedit.path.path.addPtsToSelection(v);else{if(svgedit.path.path.selected_pts.length<=
1||!E.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(v)}}else if(L.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[F,I];A=L.split("_")[1].split("c");v=A[0]-0;svgedit.path.path.selectPt(v,A[1]-0)}if(!svgedit.path.path.dragging){if(ua==null)ua=Ha.getRubberBandBox();ma(ua,{x:F*o,y:I*o,width:0,height:0,display:"inline"},100)}}},mouseMove:function(A,v,F){H=true;if(Ea==="path"){if(w){var I=w.pathSegList;A=I.numberOfItems-1;if(m){var E=svgedit.path.addCtrlGrip("1c1"),
G=svgedit.path.addCtrlGrip("0c2");G.getAttribute("cx");G.getAttribute("cy");E.setAttribute("cx",v);E.setAttribute("cy",F);E.setAttribute("display","inline");E=m[0];var L=m[1];I.getItem(A);var k=E+(E-v/o),u=L+(L-F/o);G.setAttribute("cx",k*o);G.setAttribute("cy",u*o);G.setAttribute("display","inline");G=svgedit.path.getCtrlLine(1);var C=svgedit.path.getCtrlLine(2);ma(G,{x1:v,y1:F,x2:E*o,y2:L*o,display:"inline"});ma(C,{x1:k*o,y1:u*o,x2:E*o,y2:L*o,display:"inline"});if(A===0)z=[v,F];else{I=I.getItem(A-
1);v=I.x;F=I.y;if(I.pathSegType===6){v+=v-I.x2;F+=F-I.y2}else if(z){v=z[0]/o;F=z[1]/o}svgedit.path.replacePathSeg(6,A,[E,L,v,F,k,u],w)}}else if(E=qa("path_stretch_line")){A=I.getItem(A);if(A.pathSegType===6)svgedit.path.replacePathSeg(6,1,[v,F,(A.x+(A.x-A.x2))*o,(A.y+(A.y-A.y2))*o,v,F],E);else z?svgedit.path.replacePathSeg(6,1,[v,F,z[0],z[1],v,F],E):svgedit.path.replacePathSeg(4,1,[v,F],E)}}}else if(svgedit.path.path.dragging){E=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},
svgedit.path.path);L=svgedit.path.getPointFromGrip({x:v,y:F},svgedit.path.path);A=L.x-E.x;E=L.y-E.y;svgedit.path.path.dragging=[v,F];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(A,E):svgedit.path.path.movePts(A,E)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||this.prev){var D=ua.getBBox(),P=svgedit.path.getGripPt(this);D=svgedit.math.rectsIntersect(D,{x:P.x,y:P.y,width:0,height:0});this.select(D);D&&svgedit.path.path.selected_pts.push(this.index)}})}},
mouseUp:function(A,v){if(Ea==="path"){m=null;if(!w){v=qa(ca());La=false;z=null}return{keep:true,element:v}}if(svgedit.path.path.dragging){var F=svgedit.path.path.cur_pt;svgedit.path.path.dragging=false;svgedit.path.path.dragctrl=false;svgedit.path.path.update();H&&svgedit.path.path.endChanges("Move path point(s)");!A.shiftKey&&!H&&svgedit.path.path.selectPt(F)}else if(ua&&ua.getAttribute("display")!="none"){ua.setAttribute("display","none");ua.getAttribute("width")<=2&&ua.getAttribute("height")<=
2&&Ja.toSelectMode(A.target)}else Ja.toSelectMode(A.target);H=false},toEditMode:function(A){svgedit.path.path=svgedit.path.getPath_(A);Ea="pathedit";Qa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);e=false},toSelectMode:function(A){var v=A==svgedit.path.path.elem;Ea="select";svgedit.path.path.show(false);h=false;Qa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(v){N("selected",[A]);vb([A],true)}},addSubPath:function(A){if(A){Ea=
"path";e=true}else{Ja.clear(true);Ja.toEditMode(svgedit.path.path.elem)}},select:function(A){if(h===A){Ja.toEditMode(A);Ea="pathedit"}else h=A},reorient:function(){var A=J[0];if(A)if(oa(A)!=0){var v=new za("Reorient path"),F={d:A.getAttribute("d"),transform:A.getAttribute("transform")};v.addSubCommand(new Na(A,F));Qa();this.resetOrientation(A);ya(v);svgedit.path.getPath_(A).show(false).matrix=null;this.clear();vb([A],true);N("changed",J)}},clear:function(){h=null;if(w){var A=qa(ca());$(qa("path_stretch_line")).remove();
$(A).remove();$(qa("pathpointgrip_container")).find("*").attr("display","none");w=z=null;La=false}else Ea=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(A){if(A==null||A.nodeName!="path")return false;var v=X(A),F=fa(v).matrix;v.clear();A.removeAttribute("transform");v=A.pathSegList;for(var I=v.numberOfItems,E=0;E<I;++E){var G=v.getItem(E),L=G.pathSegType;if(L!=1){var k=[];$.each(["",1,2],function(u,C){var D=G["x"+C],P=G["y"+C];if(D!==
undefined&&P!==undefined){D=O(D,P,F);k.splice(k.length,0,D.x,D.y)}});svgedit.path.replacePathSeg(L,E,k,A)}}g(A,F)},zoomChange:function(){Ea=="pathedit"&&svgedit.path.path.update()},getNodePoint:function(){var A=svgedit.path.path.segs[svgedit.path.path.selected_pts.length?svgedit.path.path.selected_pts[0]:1];return{x:A.item.x,y:A.item.y,type:A.type}},linkControlPoints:function(A){svgedit.path.setLinkControlPoints(A)},clonePathNode:function(){svgedit.path.path.storeD();for(var A=svgedit.path.path.selected_pts,
v=A.length,F=[];v--;){var I=A[v];svgedit.path.path.addSeg(I);F.push(I+v);F.push(I+v+1)}svgedit.path.path.init().addPtsToSelection(F);svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var A=svgedit.path.path.selected_pts;if(A.length===1){var v=svgedit.path.path.elem,F=v.pathSegList,I=A[0],E=null,G=null;svgedit.path.path.eachSeg(function(C){if(this.type===2&&C<=I)G=this.item;if(C<=I)return true;if(this.type===2){E=C;return false}else if(this.type===1)return E=false});if(E==
null)E=svgedit.path.path.segs.length-1;if(E!==false){var L=v.createSVGPathSegLinetoAbs(G.x,G.y),k=v.createSVGPathSegClosePath();if(E==svgedit.path.path.segs.length-1){F.appendItem(L);F.appendItem(k)}else{svgedit.path.insertItemBefore(v,k,E);svgedit.path.insertItemBefore(v,L,E)}svgedit.path.path.init().selectPt(E+1)}else if(svgedit.path.path.segs[I].mate){F.removeItem(I);F.removeItem(I);svgedit.path.path.init().selectPt(I-1)}else{for(A=0;A<F.numberOfItems;A++){var u=F.getItem(A);if(u.pathSegType===
2)L=A;else if(A===I)F.removeItem(L);else if(u.pathSegType===1&&I<A){k=A-1;F.removeItem(A);break}}for(A=I-L-1;A--;)svgedit.path.insertItemBefore(v,F.getItem(L),k);v=F.getItem(L);svgedit.path.replacePathSeg(2,L,[v.x,v.y]);A=I;svgedit.path.path.init().selectPt(0)}}},deletePathNode:function(){if(Ja.canDeleteNodes){svgedit.path.path.storeD();for(var A=svgedit.path.path.selected_pts,v=A.length;v--;)svgedit.path.path.deleteSeg(A[v]);var F=function(){var I=svgedit.path.path.elem.pathSegList,E=I.numberOfItems,
G=function(u,C){for(;C--;)I.removeItem(u)};if(E<=1)return true;for(;E--;){var L=I.getItem(E);if(L.pathSegType===1){L=I.getItem(E-1);var k=I.getItem(E-2);if(L.pathSegType===2){G(E-1,2);F();break}else if(k.pathSegType===2){G(E-2,3);F();break}}else if(L.pathSegType===2)if(E>0){L=I.getItem(E-1).pathSegType;if(L===2){G(E-1,1);F();break}else if(L===1&&I.numberOfItems-1===E){G(E,1);F();break}}}return false};F();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){Ja.toSelectMode(svgedit.path.path.elem);
b.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){A=$(svgedit.path.path.elem);A.attr("d",A.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(A){var v=A.points,F=v.numberOfItems;if(F>=4){var I=v.getItem(0),E=null;A=[];A.push(["M",I.x,",",I.y," C"].join(""));for(var G=1;G<=F-4;G+=3){var L=v.getItem(G),k=v.getItem(G+1),u=v.getItem(G+2);if(E)if((I=svgedit.path.smoothControlPoints(E,L,I))&&I.length==
2){L=A[A.length-1].split(",");L[2]=I[0].x;L[3]=I[0].y;A[A.length-1]=L.join(",");L=I[1]}A.push([L.x,L.y,k.x,k.y,u.x,u.y].join(","));I=u;E=k}for(A.push("L");G<F;++G){k=v.getItem(G);A.push([k.x,k.y].join(","))}A=A.join(" ");A=Q({element:"path",curStyles:true,attr:{id:ca(),d:A,fill:"none"}})}return A},setSegType:function(A){svgedit.path.path.setSegType(A)},moveNode:function(A,v){var F=svgedit.path.path.selected_pts;if(F.length){svgedit.path.path.storeD();F=svgedit.path.path.segs[F[0]];var I={x:0,y:0};
I[A]=v-F.item[A];F.move(I.x,I.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(A){for(var v=A.pathSegList,F=v.numberOfItems,I,E=0;E<F;++E){var G=v.getItem(E);if(G.pathSegType===2)I=G;if(G.pathSegType===1){G=v.getItem(E-1);if(G.x!=I.x||G.y!=I.y){v=A.createSVGPathSegLinetoAbs(I.x,I.y);svgedit.path.insertItemBefore(A,v,E);Ja.fixEnd(A);break}}}svgedit.browser.isWebkit()&&A.setAttribute("d",Ja.convertPath(A))},convertPath:function(A,v){for(var F=A.pathSegList,I=F.numberOfItems,E=0,
G=0,L="",k=null,u=0;u<I;++u){var C=F.getItem(u),D=C.x||0,P=C.y||0,U=C.x1||0,S=C.y1||0,Y=C.x2||0,aa=C.y2||0,ga=C.pathSegType,ra=Pa[ga]["to"+(v?"Lower":"Upper")+"Case"](),Oa=function(Ba,ha,Ta){ha=ha?" "+ha.join(" "):"";Ta=Ta?" "+svgedit.units.shortFloat(Ta):"";$.each(Ba,function(Ra,ta){Ba[Ra]=svgedit.units.shortFloat(ta)});L+=ra+Ba.join(" ")+ha+Ta};switch(ga){case 1:L+="z";break;case 12:D-=E;case 13:if(v){E+=D;ra="l"}else{D+=E;E=D;ra="L"}Oa([[D,G]]);break;case 14:P-=G;case 15:if(v){G+=P;ra="l"}else{P+=
G;G=P;ra="L"}Oa([[E,P]]);break;case 2:case 4:case 18:D-=E;P-=G;case 5:case 3:if(k&&F.getItem(u-1).pathSegType===1&&!v){E=k[0];G=k[1]}case 19:if(v){E+=D;G+=P}else{D+=E;P+=G;E=D;G=P}if(ga===3)k=[E,G];Oa([[D,P]]);break;case 6:D-=E;U-=E;Y-=E;P-=G;S-=G;aa-=G;case 7:if(v){E+=D;G+=P}else{D+=E;U+=E;Y+=E;P+=G;S+=G;aa+=G;E=D;G=P}Oa([[U,S],[Y,aa],[D,P]]);break;case 8:D-=E;U-=E;P-=G;S-=G;case 9:if(v){E+=D;G+=P}else{D+=E;U+=E;P+=G;S+=G;E=D;G=P}Oa([[U,S],[D,P]]);break;case 10:D-=E;P-=G;case 11:if(v){E+=D;G+=P}else{D+=
E;P+=G;E=D;G=P}Oa([[C.r1,C.r2]],[C.angle,C.largeArcFlag?1:0,C.sweepFlag?1:0],[D,P]);break;case 16:D-=E;Y-=E;P-=G;aa-=G;case 17:if(v){E+=D;G+=P}else{D+=E;Y+=E;P+=G;aa+=G;E=D;G=P}Oa([[Y,aa],[D,P]])}}return L}}}(),Kb=this.removeUnusedDefElems=function(){var e=l.getElementsByTagNameNS(c,"defs");if(!e||!e.length)return 0;for(var h=[],m=0,z=["fill","stroke","filter","marker-start","marker-mid","marker-end"],w=z.length,H=l.getElementsByTagNameNS(c,"*"),A=H.length,v=0;v<A;v++){for(var F=H[v],I=0;I<w;I++){var E=
ka(F.getAttribute(z[I]));E&&h.push(E.substr(1))}(F=da(F))&&F.indexOf("#")===0&&h.push(F.substr(1))}e=$(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(v=e.length;v--;){z=e[v];w=z.id;if(h.indexOf(w)<0){Ab[w]=z;z.parentNode.removeChild(z);m++}}return m};this.svgCanvasToString=function(){for(;Kb()>0;);Ja.clear(true);$.each(l.childNodes,function(m,z){m&&z.nodeType===8&&z.data.indexOf("Created with")>=0&&l.insertBefore(z,l.firstChild)});if(K){Jb();xb([K])}var e=
[];$(l).find("g:data(gsvg)").each(function(){for(var m=this.attributes,z=m.length,w=0;w<z;w++)if(m[w].nodeName=="id"||m[w].nodeName=="style")z--;if(z<=0){m=this.firstChild;e.push(m);$(this).replaceWith(m)}});var h=this.svgToString(l,0);e.length&&$(e).each(function(){Bb(this)});return h};this.svgToString=function(e,h){var m=[],z=svgedit.utilities.toXml,w=n.baseUnit,H=RegExp("^-?[\\d\\.]+"+w+"$");if(e){na(e);var A=e.attributes,v,F,I=e.childNodes;for(F=0;F<h;F++)m.push(" ");m.push("<");m.push(e.nodeName);
if(e.id==="svgcontent"){F=Eb();if(w!=="px"){F.w=svgedit.units.convertUnit(F.w,w)+w;F.h=svgedit.units.convertUnit(F.h,w)+w}m.push(' width="'+F.w+'" height="'+F.h+'" xmlns="'+c+'"');var E={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(u,C){var D=C.namespaceURI;if(D&&!E[D]&&Aa[D]!=="xmlns"&&Aa[D]!=="xml"){E[D]=true;m.push(" xmlns:"+Aa[D]+'="'+D+'"')}})});F=A.length;for(w=["width","height","xmlns","x","y","viewBox","id","overflow"];F--;){v=A.item(F);var G=z(v.nodeValue);if(v.nodeName.indexOf("xmlns:")!==
0)if(G!=""&&w.indexOf(v.localName)==-1)if(!v.namespaceURI||Aa[v.namespaceURI]){m.push(" ");m.push(v.nodeName);m.push('="');m.push(G);m.push('"')}}}else{if(e.nodeName==="defs"&&!e.firstChild)return;var L=["-moz-math-font-style","_moz-math-font-style"];for(F=A.length-1;F>=0;F--){v=A.item(F);G=z(v.nodeValue);if(!(L.indexOf(v.localName)>=0))if(G!="")if(G.indexOf("pointer-events")!==0)if(!(v.localName==="class"&&G.indexOf("se_")===0)){m.push(" ");if(v.localName==="d")G=Ja.convertPath(e,true);if(isNaN(G)){if(H.test(G))G=
svgedit.units.shortFloat(G)+w}else G=svgedit.units.shortFloat(G);if(fb.apply&&e.nodeName==="image"&&v.localName==="href"&&fb.images&&fb.images==="embed"){var k=Ra[G];if(k)G=k}if(!v.namespaceURI||v.namespaceURI==c||Aa[v.namespaceURI]){m.push(v.nodeName);m.push('="');m.push(G);m.push('"')}}}}if(e.hasChildNodes()){m.push(">");h++;A=false;for(F=0;F<I.length;F++){w=I.item(F);switch(w.nodeType){case 1:m.push("\n");m.push(this.svgToString(I.item(F),h));break;case 3:w=w.nodeValue.replace(/^\s+|\s+$/g,"");
svgedit.units.shortFloat(G)+w}else G=svgedit.units.shortFloat(G);if(fb.apply&&e.nodeName==="image"&&v.localName==="href"&&fb.images&&fb.images==="embed"){var k=Sa[G];if(k)G=k}if(!v.namespaceURI||v.namespaceURI==c||Aa[v.namespaceURI]){m.push(v.nodeName);m.push('="');m.push(G);m.push('"')}}}}if(e.hasChildNodes()){m.push(">");h++;A=false;for(F=0;F<I.length;F++){w=I.item(F);switch(w.nodeType){case 1:m.push("\n");m.push(this.svgToString(I.item(F),h));break;case 3:w=w.nodeValue.replace(/^\s+|\s+$/g,"");
if(w!=""){A=true;m.push(z(w)+"")}break;case 4:m.push("\n");m.push(Array(h+1).join(" "));m.push("<![CDATA[");m.push(w.nodeValue);m.push("]]\>");break;case 8:m.push("\n");m.push(Array(h+1).join(" "));m.push("<!--");m.push(w.data);m.push("--\>")}}h--;if(!A){m.push("\n");for(F=0;F<h;F++)m.push(" ")}m.push("</");m.push(e.nodeName);m.push(">")}else m.push("/>")}return m.join("")};this.embedImage=function(e,h){$(new Image).load(function(){var m=document.createElement("canvas");m.width=this.width;m.height=
this.height;m.getContext("2d").drawImage(this,0,0);try{var z=";svgedit_url="+encodeURIComponent(e);z=m.toDataURL().replace(";base64",z+";base64");Ra[e]=z}catch(w){Ra[e]=false}Da=e;h&&h(Ra[e])}).attr("src",e)};this.setGoodImage=function(e){Da=e};this.open=function(){};this.save=function(e){Pa();e&&$.extend(fb,e);fb.apply=true;e=this.svgCanvasToString();N("saved",e)};this.rasterExport=function(){Pa();var e=[],h={feGaussianBlur:qb.exportNoBlur,foreignObject:qb.exportNoforeignObject,"[stroke-dasharray]":qb.exportNoDashArray},
this.height;m.getContext("2d").drawImage(this,0,0);try{var z=";svgedit_url="+encodeURIComponent(e);z=m.toDataURL().replace(";base64",z+";base64");Sa[e]=z}catch(w){Sa[e]=false}Da=e;h&&h(Sa[e])}).attr("src",e)};this.setGoodImage=function(e){Da=e};this.open=function(){};this.save=function(e){Qa();e&&$.extend(fb,e);fb.apply=true;e=this.svgCanvasToString();N("saved",e)};this.rasterExport=function(){Qa();var e=[],h={feGaussianBlur:qb.exportNoBlur,foreignObject:qb.exportNoforeignObject,"[stroke-dasharray]":qb.exportNoDashArray},
m=$(l);if(!("font"in $("<canvas>")[0].getContext("2d")))h.text=qb.exportNoText;$.each(h,function(z,w){m.find(z).length&&e.push(w)});h=this.svgCanvasToString();N("exported",{svg:h,issues:e})};this.getSvgString=function(){fb.apply=false;return this.svgCanvasToString()};this.randomizeIds=function(){arguments.length>0&&arguments[0]==false?svgedit.draw.randomizeIds(false,B()):svgedit.draw.randomizeIds(true,B())};var Nb=this.uniquifyElems=function(e){var h={},m=["filter","linearGradient","pattern","radialGradient",
"symbol","textPath","use"];svgedit.utilities.walkTree(e,function(v){if(v.nodeType==1){if(v.id){v.id in h||(h[v.id]={elem:null,attrs:[],hrefs:[]});h[v.id].elem=v}$.each($a,function(I,D){var G=v.getAttributeNode(D);if(G){var L=svgedit.utilities.getUrlFromAttr(G.value);if(L=L?L.substr(1):null){L in h||(h[L]={elem:null,attrs:[],hrefs:[]});h[L].attrs.push(G)}}});var F=svgedit.utilities.getHref(v);if(F&&m.indexOf(v.nodeName)>=0)if(F=F.substr(1)){F in h||(h[F]={elem:null,attrs:[],hrefs:[]});h[F].hrefs.push(v)}}});
"symbol","textPath","use"];svgedit.utilities.walkTree(e,function(v){if(v.nodeType==1){if(v.id){v.id in h||(h[v.id]={elem:null,attrs:[],hrefs:[]});h[v.id].elem=v}$.each($a,function(I,E){var G=v.getAttributeNode(E);if(G){var L=svgedit.utilities.getUrlFromAttr(G.value);if(L=L?L.substr(1):null){L in h||(h[L]={elem:null,attrs:[],hrefs:[]});h[L].attrs.push(G)}}});var F=svgedit.utilities.getHref(v);if(F&&m.indexOf(v.nodeName)>=0)if(F=F.substr(1)){F in h||(h[F]={elem:null,attrs:[],hrefs:[]});h[F].hrefs.push(v)}}});
for(var z in h)if(z){var w=h[z].elem;if(w){e=ja();w.id=e;w=h[z].attrs;for(var H=w.length;H--;){var A=w[H];A.ownerElement.setAttribute(A.name,"url(#"+e+")")}w=h[z].hrefs;for(H=w.length;H--;)svgedit.utilities.setHref(w[H],"#"+e)}}},Lb=this.setUseData=function(e){var h=$(e);if(e.tagName!=="use")h=h.find("use");h.each(function(){var m=da(this).substr(1);if(m=qa(m)){$(this).data("ref",m);if(m.tagName=="symbol"||m.tagName=="svg")$(this).data("symbol",m).data("ref",m)}})},Ob=this.convertGradients=function(e){var h=
$(e).find("linearGradient, radialGradient");if(!h.length&&svgedit.browser.isWebkit())h=$(e).find("*").filter(function(){return this.tagName.indexOf("Gradient")>=0});h.each(function(){if($(this).attr("gradientUnits")==="userSpaceOnUse"){var m=$(l).find('[fill="url(#'+this.id+')"],[stroke="url(#'+this.id+')"]');if(m.length)if(m=svgedit.utilities.getBBox(m[0]))if(this.tagName==="linearGradient"){var z=$(this).attr(["x1","y1","x2","y2"]),w=this.gradientTransform.baseVal;if(w&&w.numberOfItems>0){var H=
fa(w).matrix;w=O(z.x1,z.y1,H);H=O(z.x2,z.y2,H);z.x1=w.x;z.y1=w.y;z.x2=H.x;z.y2=H.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(z.x1-m.x)/m.width,y1:(z.y1-m.y)/m.height,x2:(z.x2-m.x)/m.width,y2:(z.y2-m.y)/m.height});this.removeAttribute("gradientUnits")}}})},Db=this.convertToGroup=function(e){e||(e=J[0]);var h=$(e),m=new za,z;if(h.data("gsvg")){m=$(e.firstChild).attr(["x","y"]);$(e.firstChild.firstChild).unwrap();$(e).removeData("gsvg");z=Y(e);var w=d.createSVGTransform();w.setTranslate(m.x,
m.y);z.appendItem(w);Xa(e);N("selected",[e])}else if(h.data("symbol")){e=h.data("symbol");z=h.attr("transform");w=h.attr(["x","y"]);var H=e.getAttribute("viewBox");if(H){H=H.split(" ");w.x-=+H[0];w.y-=+H[1]}z+=" translate("+(w.x||0)+","+(w.y||0)+")";w=h.prev();m.addSubCommand(new Ka(h[0],h[0].nextSibling,h[0].parentNode));h.remove();H=$(l).find("use:data(symbol)").length;h=f.createElementNS(c,"g");for(var A=e.childNodes,v=0;v<A.length;v++)h.appendChild(A[v].cloneNode(true));if(svgedit.browser.isGecko()){A=
$(lb()).children("linearGradient,radialGradient,pattern").clone();$(h).append(A)}z&&h.setAttribute("transform",z);z=e.parentNode;Nb(h);svgedit.browser.isGecko()&&$(lb()).append($(h).find("linearGradient,radialGradient,pattern"));h.id=ja();w.after(h);if(z){if(!H){w=e.nextSibling;z.removeChild(e);m.addSubCommand(new Ka(e,w,z))}m.addSubCommand(new Ca(h))}Lb(h);svgedit.browser.isGecko()?Ob(lb()):Ob(h);svgedit.utilities.walkTreePost(h,function(F){try{Xa(F)}catch(I){console.log(I)}});$(h).find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=
ja()});Bb([h]);(e=Mb(h,true))&&m.addSubCommand(e);ya(m)}else console.log("Unexpected element to ungroup:",e)};this.setSvgString=function(e){try{var h=svgedit.utilities.text2xml(e);this.prepareSvg(h);var m=new za("Change Source"),z=l.nextSibling,w=d.removeChild(l);m.addSubCommand(new Ka(w,z,d));l=f.adoptNode?f.adoptNode(h.documentElement):f.importNode(h.documentElement,true);d.appendChild(l);var H=$(l);b.current_drawing_=new svgedit.draw.Drawing(l,q);var A=B().getNonce();A?N("setnonce",A):N("unsetnonce");
H.find("image").each(function(){var k=this;pb(k);var u=da(this);if(u.indexOf("data:")===0){var C=u.match(/svgedit_url=(.*?);/);if(C){var E=decodeURIComponent(C[1]);$(new Image).load(function(){k.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",E)}).attr("src",E)}}b.embedImage(u)});H.find("svg").each(function(){if(!$(this).closest("defs").length){Nb(this);var k=this.parentNode;if(k.childNodes.length===1&&k.nodeName==="g"){$(k).data("gsvg",this);k.id=k.id||ja()}else Ab(this)}});svgedit.browser.isGecko()&&
H.find("linearGradient, radialGradient, pattern").appendTo(lb());Lb(H);Ob(H[0]);svgedit.utilities.walkTreePost(l,function(k){try{Xa(k)}catch(u){console.log(u)}});var v={id:"svgcontent",overflow:n.show_outside_canvas?"visible":"hidden"},F=false;if(H.attr("viewBox")){var I=H.attr("viewBox").split(" ");v.width=I[2];v.height=I[3]}else $.each(["width","height"],function(k,u){var C=H.attr(u);C||(C="100%");if((C+"").substr(-1)==="%")F=true;else v[u]=sa(u,C)});Fb();H.children().find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=
ja()});if(F){var D=getStrokedBBox();v.width=D.width+D.x;v.height=D.height+D.y}if(v.width<=0)v.width=100;if(v.height<=0)v.height=100;H.attr(v);this.contentW=v.width;this.contentH=v.height;m.addSubCommand(new Ca(l));var G=H.attr(["width","height"]);m.addSubCommand(new Na(d,G));o=1;svgedit.transformlist.resetListMap();Pa();svgedit.path.clearData();d.appendChild(Ha.selectorParentGroup);ya(m);N("changed",[l])}catch(L){console.log(L);return false}return true};this.importSvgString=function(e){try{var h=
svgedit.utilities.encode64(e.length+e).substr(0,32),m=false;if(sb[h])if($(sb[h].symbol).parents("#svgroot").length)m=true;var z=new za("Import SVG");if(m)var w=sb[h].symbol,H=sb[h].xform;else{var A=svgedit.utilities.text2xml(e);this.prepareSvg(A);var v;v=f.adoptNode?f.adoptNode(A.documentElement):f.importNode(A.documentElement,true);Nb(v);var F=sa("width",v.getAttribute("width")),I=sa("height",v.getAttribute("height")),D=v.getAttribute("viewBox"),G=D?D.split(" "):[0,0,F,I];for(e=0;e<4;++e)G[e]=+G[e];
l.getAttribute("width");var L=+l.getAttribute("height");H=I>F?"scale("+L/3/G[3]+")":"scale("+L/3/G[2]+")";H="translate(0) "+H+" translate(0)";w=f.createElementNS(c,"symbol");var k=lb();for(svgedit.browser.isGecko()&&$(v).find("linearGradient, radialGradient, pattern").appendTo(k);v.firstChild;)w.appendChild(v.firstChild);var u=v.attributes;for(v=0;v<u.length;v++){var C=u[v];w.setAttribute(C.nodeName,C.nodeValue)}w.id=ja();sb[h]={symbol:w,xform:H};lb().appendChild(w);z.addSubCommand(new Ca(w))}var E=
f.createElementNS(c,"use");E.id=ja();V(E,"#"+w.id);(K||B().getCurrentLayer()).appendChild(E);z.addSubCommand(new Ca(E));Pa();E.setAttribute("transform",H);Xa(E);$(E).data("symbol",w).data("ref",w);vb([E]);ya(z);N("changed",[l])}catch(P){console.log(P);return false}return true};var Fb=b.identifyLayers=function(){Jb();B().identifyLayers()};this.createLayer=function(e){var h=new za("Create Layer");e=B().createLayer(e);h.addSubCommand(new Ca(e));ya(h);Pa();N("changed",[e])};this.cloneLayer=function(e){var h=
new za("Duplicate Layer"),m=f.createElementNS(c,"g"),z=f.createElementNS(c,"title");z.textContent=e;m.appendChild(z);z=B().getCurrentLayer();$(z).after(m);z=z.childNodes;for(var w=0;w<z.length;w++){var H=z[w];H.localName!="title"&&m.appendChild(la(H))}Pa();Fb();h.addSubCommand(new Ca(m));ya(h);b.setCurrentLayer(e);N("changed",[m])};this.deleteCurrentLayer=function(){var e=B().getCurrentLayer(),h=e.nextSibling,m=e.parentNode;if(e=B().deleteCurrentLayer()){var z=new za("Delete Layer");z.addSubCommand(new Ka(e,
h,m));ya(z);Pa();N("changed",[m]);return true}return false};this.setCurrentLayer=function(e){(e=B().setCurrentLayer(svgedit.utilities.toXml(e)))&&Pa();return e};this.renameCurrentLayer=function(e){var h=B();if(h.current_layer){var m=h.current_layer;if(!b.setCurrentLayer(e)){for(var z=new za("Rename Layer"),w=0;w<h.getNumLayers();++w)if(h.all_layers[w][1]==m)break;var H=h.getLayerName(w);h.all_layers[w][0]=svgedit.utilities.toXml(e);var A=m.childNodes.length;for(w=0;w<A;++w){var v=m.childNodes.item(w);
fa(w).matrix;w=O(z.x1,z.y1,H);H=O(z.x2,z.y2,H);z.x1=w.x;z.y1=w.y;z.x2=H.x;z.y2=H.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(z.x1-m.x)/m.width,y1:(z.y1-m.y)/m.height,x2:(z.x2-m.x)/m.width,y2:(z.y2-m.y)/m.height});this.removeAttribute("gradientUnits")}}})},Db=this.convertToGroup=function(e){e||(e=J[0]);var h=$(e),m=new za,z;if(h.data("gsvg")){m=$(e.firstChild).attr(["x","y"]);$(e.firstChild.firstChild).unwrap();$(e).removeData("gsvg");z=X(e);var w=d.createSVGTransform();w.setTranslate(m.x,
m.y);z.appendItem(w);Ua(e);N("selected",[e])}else if(h.data("symbol")){e=h.data("symbol");z=h.attr("transform");w=h.attr(["x","y"]);var H=e.getAttribute("viewBox");if(H){H=H.split(" ");w.x-=+H[0];w.y-=+H[1]}z+=" translate("+(w.x||0)+","+(w.y||0)+")";w=h.prev();m.addSubCommand(new Ka(h[0],h[0].nextSibling,h[0].parentNode));h.remove();H=$(l).find("use:data(symbol)").length;h=f.createElementNS(c,"g");for(var A=e.childNodes,v=0;v<A.length;v++)h.appendChild(A[v].cloneNode(true));if(svgedit.browser.isGecko()){A=
$(lb()).children("linearGradient,radialGradient,pattern").clone();$(h).append(A)}z&&h.setAttribute("transform",z);z=e.parentNode;Nb(h);svgedit.browser.isGecko()&&$(lb()).append($(h).find("linearGradient,radialGradient,pattern"));h.id=ja();w.after(h);if(z){if(!H){w=e.nextSibling;z.removeChild(e);m.addSubCommand(new Ka(e,w,z))}m.addSubCommand(new Ca(h))}Lb(h);svgedit.browser.isGecko()?Ob(lb()):Ob(h);svgedit.utilities.walkTreePost(h,function(F){try{Ua(F)}catch(I){console.log(I)}});$(h).find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=
ja()});xb([h]);(e=Mb(h,true))&&m.addSubCommand(e);ya(m)}else console.log("Unexpected element to ungroup:",e)};this.setSvgString=function(e){try{var h=svgedit.utilities.text2xml(e);this.prepareSvg(h);var m=new za("Change Source"),z=l.nextSibling,w=d.removeChild(l);m.addSubCommand(new Ka(w,z,d));l=f.adoptNode?f.adoptNode(h.documentElement):f.importNode(h.documentElement,true);d.appendChild(l);var H=$(l);b.current_drawing_=new svgedit.draw.Drawing(l,q);var A=B().getNonce();A?N("setnonce",A):N("unsetnonce");
H.find("image").each(function(){var k=this;pb(k);var u=da(this);if(u.indexOf("data:")===0){var C=u.match(/svgedit_url=(.*?);/);if(C){var D=decodeURIComponent(C[1]);$(new Image).load(function(){k.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",D)}).attr("src",D)}}b.embedImage(u)});H.find("svg").each(function(){if(!$(this).closest("defs").length){Nb(this);var k=this.parentNode;if(k.childNodes.length===1&&k.nodeName==="g"){$(k).data("gsvg",this);k.id=k.id||ja()}else Bb(this)}});svgedit.browser.isGecko()&&
H.find("linearGradient, radialGradient, pattern").appendTo(lb());Lb(H);Ob(H[0]);svgedit.utilities.walkTreePost(l,function(k){try{Ua(k)}catch(u){console.log(u)}});var v={id:"svgcontent",overflow:n.show_outside_canvas?"visible":"hidden"},F=false;if(H.attr("viewBox")){var I=H.attr("viewBox").split(" ");v.width=I[2];v.height=I[3]}else $.each(["width","height"],function(k,u){var C=H.attr(u);C||(C="100%");if((C+"").substr(-1)==="%")F=true;else v[u]=sa(u,C)});Fb();H.children().find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=
ja()});if(F){var E=getStrokedBBox();v.width=E.width+E.x;v.height=E.height+E.y}if(v.width<=0)v.width=100;if(v.height<=0)v.height=100;H.attr(v);this.contentW=v.width;this.contentH=v.height;m.addSubCommand(new Ca(l));var G=H.attr(["width","height"]);m.addSubCommand(new Na(d,G));o=1;svgedit.transformlist.resetListMap();Qa();svgedit.path.clearData();d.appendChild(Ha.selectorParentGroup);ya(m);N("changed",[l])}catch(L){console.log(L);return false}return true};this.importSvgString=function(e){try{var h=
svgedit.utilities.encode64(e.length+e).substr(0,32),m=false;if(sb[h])if($(sb[h].symbol).parents("#svgroot").length)m=true;var z=new za("Import SVG");if(m)var w=sb[h].symbol,H=sb[h].xform;else{var A=svgedit.utilities.text2xml(e);this.prepareSvg(A);var v;v=f.adoptNode?f.adoptNode(A.documentElement):f.importNode(A.documentElement,true);Nb(v);var F=sa("width",v.getAttribute("width")),I=sa("height",v.getAttribute("height")),E=v.getAttribute("viewBox"),G=E?E.split(" "):[0,0,F,I];for(e=0;e<4;++e)G[e]=+G[e];
l.getAttribute("width");var L=+l.getAttribute("height");H=I>F?"scale("+L/3/G[3]+")":"scale("+L/3/G[2]+")";H="translate(0) "+H+" translate(0)";w=f.createElementNS(c,"symbol");var k=lb();for(svgedit.browser.isGecko()&&$(v).find("linearGradient, radialGradient, pattern").appendTo(k);v.firstChild;)w.appendChild(v.firstChild);var u=v.attributes;for(v=0;v<u.length;v++){var C=u[v];w.setAttribute(C.nodeName,C.nodeValue)}w.id=ja();sb[h]={symbol:w,xform:H};lb().appendChild(w);z.addSubCommand(new Ca(w))}var D=
f.createElementNS(c,"use");D.id=ja();V(D,"#"+w.id);(K||B().getCurrentLayer()).appendChild(D);z.addSubCommand(new Ca(D));Qa();D.setAttribute("transform",H);Ua(D);$(D).data("symbol",w).data("ref",w);vb([D]);ya(z);N("changed",[l])}catch(P){console.log(P);return false}return true};var Fb=b.identifyLayers=function(){Jb();B().identifyLayers()};this.createLayer=function(e){var h=new za("Create Layer");e=B().createLayer(e);h.addSubCommand(new Ca(e));ya(h);Qa();N("changed",[e])};this.cloneLayer=function(e){var h=
new za("Duplicate Layer"),m=f.createElementNS(c,"g"),z=f.createElementNS(c,"title");z.textContent=e;m.appendChild(z);z=B().getCurrentLayer();$(z).after(m);z=z.childNodes;for(var w=0;w<z.length;w++){var H=z[w];H.localName!="title"&&m.appendChild(la(H))}Qa();Fb();h.addSubCommand(new Ca(m));ya(h);b.setCurrentLayer(e);N("changed",[m])};this.deleteCurrentLayer=function(){var e=B().getCurrentLayer(),h=e.nextSibling,m=e.parentNode;if(e=B().deleteCurrentLayer()){var z=new za("Delete Layer");z.addSubCommand(new Ka(e,
h,m));ya(z);Qa();N("changed",[m]);return true}return false};this.setCurrentLayer=function(e){(e=B().setCurrentLayer(svgedit.utilities.toXml(e)))&&Qa();return e};this.renameCurrentLayer=function(e){var h=B();if(h.current_layer){var m=h.current_layer;if(!b.setCurrentLayer(e)){for(var z=new za("Rename Layer"),w=0;w<h.getNumLayers();++w)if(h.all_layers[w][1]==m)break;var H=h.getLayerName(w);h.all_layers[w][0]=svgedit.utilities.toXml(e);var A=m.childNodes.length;for(w=0;w<A;++w){var v=m.childNodes.item(w);
if(v&&v.tagName=="title"){for(;v.firstChild;)v.removeChild(v.firstChild);v.textContent=e;z.addSubCommand(new Na(v,{"#text":H}));ya(z);N("changed",[m]);return true}}}h.current_layer=m}return false};this.setCurrentLayerPosition=function(e){var h=B();if(h.current_layer&&e>=0&&e<h.getNumLayers()){for(var m=0;m<h.getNumLayers();++m)if(h.all_layers[m][1]==h.current_layer)break;if(m==h.getNumLayers())return false;if(m!=e){var z=null,w=h.current_layer.nextSibling;if(e>m){if(e<h.getNumLayers()-1)z=h.all_layers[e+
1][1]}else z=h.all_layers[e][1];l.insertBefore(h.current_layer,z);ya(new Ia(h.current_layer,w,l));Fb();b.setCurrentLayer(h.getLayerName(e));return true}}return false};this.setLayerVisibility=function(e,h){var m=B(),z=m.getLayerVisibility(e),w=m.setLayerVisibility(e,h);if(w)ya(new Na(w,{display:z?"inline":"none"},"Layer Visibility"));else return false;if(w==m.getCurrentLayer()){Pa();Ja.clear()}return true};this.moveSelectedToLayer=function(e){for(var h=null,m=B(),z=0;z<m.getNumLayers();++z)if(m.getLayerName(z)==
1][1]}else z=h.all_layers[e][1];l.insertBefore(h.current_layer,z);ya(new Ia(h.current_layer,w,l));Fb();b.setCurrentLayer(h.getLayerName(e));return true}}return false};this.setLayerVisibility=function(e,h){var m=B(),z=m.getLayerVisibility(e),w=m.setLayerVisibility(e,h);if(w)ya(new Na(w,{display:z?"inline":"none"},"Layer Visibility"));else return false;if(w==m.getCurrentLayer()){Qa();Ja.clear()}return true};this.moveSelectedToLayer=function(e){for(var h=null,m=B(),z=0;z<m.getNumLayers();++z)if(m.getLayerName(z)==
e){h=m.all_layers[z][1];break}if(!h)return false;e=new za("Move Elements to Layer");m=J;for(z=m.length;z--;){var w=m[z];if(w){var H=w.nextSibling,A=w.parentNode;h.appendChild(w);e.addSubCommand(new Ia(w,H,A))}}ya(e);return true};this.mergeLayer=function(e){var h=new za("Merge Layer"),m=B(),z=$(m.current_layer).prev()[0];if(z){for(h.addSubCommand(new Ka(m.current_layer,m.current_layer.nextSibling,l));m.current_layer.firstChild;){var w=m.current_layer.firstChild;if(w.localName=="title"){h.addSubCommand(new Ka(w,
w.nextSibling,m.current_layer));m.current_layer.removeChild(w)}else{var H=w.nextSibling;z.appendChild(w);h.addSubCommand(new Ia(w,H,m.current_layer))}}l.removeChild(m.current_layer);if(!e){Pa();Fb();N("changed",[l]);ya(h)}m.current_layer=z;return h}};this.mergeAllLayers=function(){var e=new za("Merge all Layers"),h=B();for(h.current_layer=h.all_layers[h.getNumLayers()-1][1];$(l).children("g").length>1;)e.addSubCommand(b.mergeLayer(true));Pa();Fb();N("changed",[l]);ya(e)};var Jb=this.leaveContext=
function(){var e=va.length;if(e){for(var h=0;h<e;h++){var m=va[h],z=ib(m,"orig_opac");z!==1?m.setAttribute("opacity",z):m.removeAttribute("opacity");m.setAttribute("style","pointer-events: inherit")}va=[];Pa(true);N("contextset",null)}K=null},Rb=this.setContext=function(e){Jb();if(typeof e==="string")e=qa(e);K=e;$(e).parentsUntil("#svgcontent").andSelf().siblings().each(function(){var h=this.getAttribute("opacity")||1;ib(this,"orig_opac",h);this.setAttribute("opacity",h*0.33);this.setAttribute("style",
"pointer-events: none");va.push(this)});Pa();N("contextset",K)};this.clear=function(){Ja.clear();Pa();b.clearSvgContentElement();b.current_drawing_=new svgedit.draw.Drawing(l);b.createLayer("Layer 1");b.undoMgr.resetUndoStack();Ha.initGroup();ta=Ha.getRubberBandBox();N("cleared")};this.linkControlPoints=Ja.linkControlPoints;this.getContentElem=function(){return l};this.getRootElem=function(){return d};this.getSelectedElems=function(){return J};var Eb=this.getResolution=function(){var e=l.getAttribute("width")/
w.nextSibling,m.current_layer));m.current_layer.removeChild(w)}else{var H=w.nextSibling;z.appendChild(w);h.addSubCommand(new Ia(w,H,m.current_layer))}}l.removeChild(m.current_layer);if(!e){Qa();Fb();N("changed",[l]);ya(h)}m.current_layer=z;return h}};this.mergeAllLayers=function(){var e=new za("Merge all Layers"),h=B();for(h.current_layer=h.all_layers[h.getNumLayers()-1][1];$(l).children("g").length>1;)e.addSubCommand(b.mergeLayer(true));Qa();Fb();N("changed",[l]);ya(e)};var Jb=this.leaveContext=
function(){var e=va.length;if(e){for(var h=0;h<e;h++){var m=va[h],z=ib(m,"orig_opac");z!==1?m.setAttribute("opacity",z):m.removeAttribute("opacity");m.setAttribute("style","pointer-events: inherit")}va=[];Qa(true);N("contextset",null)}K=null},Rb=this.setContext=function(e){Jb();if(typeof e==="string")e=qa(e);K=e;$(e).parentsUntil("#svgcontent").andSelf().siblings().each(function(){var h=this.getAttribute("opacity")||1;ib(this,"orig_opac",h);this.setAttribute("opacity",h*0.33);this.setAttribute("style",
"pointer-events: none");va.push(this)});Qa();N("contextset",K)};this.clear=function(){Ja.clear();Qa();b.clearSvgContentElement();b.current_drawing_=new svgedit.draw.Drawing(l);b.createLayer("Layer 1");b.undoMgr.resetUndoStack();Ha.initGroup();ua=Ha.getRubberBandBox();N("cleared")};this.linkControlPoints=Ja.linkControlPoints;this.getContentElem=function(){return l};this.getRootElem=function(){return d};this.getSelectedElems=function(){return J};var Eb=this.getResolution=function(){var e=l.getAttribute("width")/
o,h=l.getAttribute("height")/o;return{w:e,h:h,zoom:o}};this.getZoom=function(){return o};this.getVersion=function(){return"svgcanvas.js ($Rev: 2082 $)"};this.setUiStrings=function(e){$.extend(qb,e.notification)};this.setConfig=function(e){$.extend(n,e)};this.getTitle=function(e){if(e=e||J[0]){e=$(e).data("gsvg")||$(e).data("symbol")||e;e=e.childNodes;for(var h=0;h<e.length;h++)if(e[h].nodeName=="title")return e[h].textContent;return""}};this.setGroupTitle=function(e){var h=J[0];h=$(h).data("gsvg")||
h;var m=$(h).children("title"),z=new za("Set Label");if(e.length)if(m.length){m=m[0];z.addSubCommand(new Na(m,{"#text":m.textContent}));m.textContent=e}else{m=f.createElementNS(c,"title");m.textContent=e;$(h).prepend(m);z.addSubCommand(new Ca(m))}else{z.addSubCommand(new Ka(m[0],m.nextSibling,h));m.remove()}ya(z)};this.getDocumentTitle=function(){return b.getTitle(l)};this.setDocumentTitle=function(e){for(var h=l.childNodes,m=false,z="",w=new za("Change Image Title"),H=0;H<h.length;H++)if(h[H].nodeName==
"title"){m=h[H];z=m.textContent;break}if(!m){m=f.createElementNS(c,"title");l.insertBefore(m,l.firstChild)}if(e.length)m.textContent=e;else m.parentNode.removeChild(m);w.addSubCommand(new Na(m,{"#text":z}));ya(w)};this.getEditorNS=function(e){e&&l.setAttribute("xmlns:se","http://svg-edit.googlecode.com");return"http://svg-edit.googlecode.com"};this.setResolution=function(e,h){var m=Eb(),z=m.w;m=m.h;var w;if(e=="fit"){var H=getStrokedBBox();if(H){w=new za("Fit Canvas to Content");var A=ub();vb(A);
var v=[],F=[];$.each(A,function(){v.push(H.x*-1);F.push(H.y*-1)});A=b.moveSelectedElements(v,F,true);w.addSubCommand(A);Pa();e=Math.round(H.width);h=Math.round(H.height)}else return false}if(e!=z||h!=m){A=d.suspendRedraw(1E3);w||(w=new za("Change Image Dimensions"));e=sa("width",e);h=sa("height",h);l.setAttribute("width",e);l.setAttribute("height",h);this.contentW=e;this.contentH=h;w.addSubCommand(new Na(l,{width:z,height:m}));l.setAttribute("viewBox",[0,0,e/o,h/o].join(" "));w.addSubCommand(new Na(l,
var v=[],F=[];$.each(A,function(){v.push(H.x*-1);F.push(H.y*-1)});A=b.moveSelectedElements(v,F,true);w.addSubCommand(A);Qa();e=Math.round(H.width);h=Math.round(H.height)}else return false}if(e!=z||h!=m){A=d.suspendRedraw(1E3);w||(w=new za("Change Image Dimensions"));e=sa("width",e);h=sa("height",h);l.setAttribute("width",e);l.setAttribute("height",h);this.contentW=e;this.contentH=h;w.addSubCommand(new Na(l,{width:z,height:m}));l.setAttribute("viewBox",[0,0,e/o,h/o].join(" "));w.addSubCommand(new Na(l,
{viewBox:["0 0",z,m].join(" ")}));ya(w);d.unsuspendRedraw(A);if(background=document.getElementById("canvas_background")){background.setAttribute("x",-1);background.setAttribute("y",-1);background.setAttribute("width",e+2);background.setAttribute("height",h+2)}N("changed",[l])}return[e,h]};this.getOffset=function(){return $(l).attr(["x","y"])};this.setBBoxZoom=function(e,h,m){var z=0.85,w=function(H){if(!H)return false;var A=Math.min(Math.round(h/H.width*100*z)/100,Math.round(m/H.height*100*z)/100);
b.setZoom(A);return{zoom:A,bbox:H}};if(typeof e=="object"){e=e;if(e.width==0||e.height==0){b.setZoom(e.zoom?e.zoom:o*e.factor);return{zoom:o,bbox:e}}return w(e)}switch(e){case "selection":if(!J[0])return;e=$.map(J,function(H){if(H)return H});e=getStrokedBBox(e);break;case "canvas":e=Eb();z=0.95;e={width:e.w,height:e.h,x:0,y:0};break;case "content":e=getStrokedBBox();break;case "layer":e=getStrokedBBox(ub(B().getCurrentLayer()));break;default:return}return w(e)};this.setZoom=function(e){var h=Eb();
l.setAttribute("viewBox","0 0 "+h.w/e+" "+h.h/e);o=e;$.each(J,function(m,z){z&&Ha.requestSelector(z).resize()});Ja.zoomChange();ob("zoomChanged",e)};this.getMode=function(){return Ea};this.setMode=function(e){Ja.clear(true);hb.clear();$("#workarea").attr("class",e);bb=J[0]&&J[0].nodeName=="text"?Za:M;Ea=e};this.getColor=function(e){return bb[e]};this.setColor=function(e,h,m){M[e]=h;bb[e+"_paint"]={type:"solidColor"};for(var z=[],w=J.length;w--;){var H=J[w];if(H)if(H.tagName=="g")svgedit.utilities.walkTree(H,
function(A){A.nodeName!="g"&&z.push(A)});else if(e=="fill")H.tagName!="polyline"&&H.tagName!="line"&&z.push(H);else z.push(H)}if(z.length>0)if(m)xb(e,h,z);else{gb(e,h,z);N("changed",z)}};var lb=function(){var e=l.getElementsByTagNameNS(c,"defs");if(e.length>0)e=e[0];else{e=f.createElementNS(c,"defs");l.firstChild?l.insertBefore(e,l.firstChild.nextSibling):l.appendChild(e)}return e},Qb=this.setGradient=function(e){if(!(!bb[e+"_paint"]||bb[e+"_paint"].type=="solidColor")){var h=b[e+"Grad"],m=Pb(h),
function(A){A.nodeName!="g"&&z.push(A)});else if(e=="fill")H.tagName!="polyline"&&H.tagName!="line"&&z.push(H);else z.push(H)}if(z.length>0)if(m)yb(e,h,z);else{gb(e,h,z);N("changed",z)}};var lb=function(){var e=l.getElementsByTagNameNS(c,"defs");if(e.length>0)e=e[0];else{e=f.createElementNS(c,"defs");l.firstChild?l.insertBefore(e,l.firstChild.nextSibling):l.appendChild(e)}return e},Qb=this.setGradient=function(e){if(!(!bb[e+"_paint"]||bb[e+"_paint"].type=="solidColor")){var h=b[e+"Grad"],m=Pb(h),
z=lb();if(m)h=m;else{h=z.appendChild(f.importNode(h,true));h.id=ja()}b.setColor(e,"url(#"+h.id+")");if(e=="canvas")(e=document.getElementById("canvas_background"))&&e.setAttribute("fill","url(#"+h.id+")")}},Pb=function(e){var h=lb();h=$(h).find("linearGradient, radialGradient");for(var m=h.length,z=["r","cx","cy","fx","fy"];m--;){var w=h[m];if(e.tagName=="linearGradient"){if(e.getAttribute("x1")!=w.getAttribute("x1")||e.getAttribute("y1")!=w.getAttribute("y1")||e.getAttribute("x2")!=w.getAttribute("x2")||
e.getAttribute("y2")!=w.getAttribute("y2"))continue}else{var H=$(e).attr(z),A=$(w).attr(z),v=false;$.each(z,function(k,u){if(H[u]!=A[u])v=true});if(v)continue}var F=e.getElementsByTagNameNS(c,"stop"),I=w.getElementsByTagNameNS(c,"stop");if(F.length==I.length){for(var D=F.length;D--;){var G=F[D],L=I[D];if(G.getAttribute("offset")!=L.getAttribute("offset")||G.getAttribute("stop-opacity")!=L.getAttribute("stop-opacity")||G.getAttribute("stop-color")!=L.getAttribute("stop-color"))break}if(D==-1)return w}}return null};
e.getAttribute("y2")!=w.getAttribute("y2"))continue}else{var H=$(e).attr(z),A=$(w).attr(z),v=false;$.each(z,function(k,u){if(H[u]!=A[u])v=true});if(v)continue}var F=e.getElementsByTagNameNS(c,"stop"),I=w.getElementsByTagNameNS(c,"stop");if(F.length==I.length){for(var E=F.length;E--;){var G=F[E],L=I[E];if(G.getAttribute("offset")!=L.getAttribute("offset")||G.getAttribute("stop-opacity")!=L.getAttribute("stop-opacity")||G.getAttribute("stop-color")!=L.getAttribute("stop-color"))break}if(E==-1)return w}}return null};
this.setPaint=function(e,h){var m=new $.jGraduate.Paint(h);this.setPaintOpacity(e,m.alpha/100,true);bb[e+"_paint"]=m;switch(m.type){case "solidColor":if(m.solidColor!="none"&&m.solidColor!="#none")this.setColor(e,"#"+m.solidColor);else{this.setColor(e,"none");document.querySelector(e=="fill"?"#fill_color rect":"#stroke_color rect").setAttribute("fill","none")}break;case "linearGradient":case "radialGradient":b[e+"Grad"]=m[m.type];Qb(e)}};this.getStrokeWidth=function(){return bb.stroke_width};this.setStrokeWidth=
function(e){if(e==0&&["line","path"].indexOf(Ea)>=0)b.setStrokeWidth(1);else{bb.stroke_width=e;for(var h=[],m=J.length;m--;){var z=J[m];if(z)z.tagName=="g"?svgedit.utilities.walkTree(z,function(w){w.nodeName!="g"&&h.push(w)}):h.push(z)}if(h.length>0){gb("stroke-width",e,h);N("changed",J)}}};this.setStrokeAttr=function(e,h){M[e.replace("-","_")]=h;for(var m=[],z=J.length;z--;){var w=J[z];if(w)w.tagName=="g"?svgedit.utilities.walkTree(w,function(H){H.nodeName!="g"&&m.push(H)}):m.push(w)}if(m.length>
0){gb(e,h,m);N("changed",J)}};this.getStyle=function(){return M};this.getOpacity=function(){return M.opacity};this.setOpacity=function(e){M.opacity=e;gb("opacity",e)};this.getFillOpacity=function(){return M.fill_opacity};this.getStrokeOpacity=function(){return M.stroke_opacity};this.setPaintOpacity=function(e,h,m){M[e+"_opacity"]=h;m?xb(e+"-opacity",h):gb(e+"-opacity",h)};this.getBlur=function(e){var h=0;if(e)if(e.getAttribute("filter"))if(e=qa(e.id+"_blur"))h=e.firstChild.getAttribute("stdDeviation");
return h};(function(){function e(){var w=b.undoMgr.finishUndoableChange();h.addSubCommand(w);ya(h);m=h=null}var h=null,m=null,z=false;b.setBlurNoUndo=function(w){if(m)if(w===0){xb("filter","");z=true}else{var H=J[0];z&&xb("filter","url(#"+H.id+"_blur)");if(svgedit.browser.isWebkit()){H.removeAttribute("filter");H.setAttribute("filter","url(#"+H.id+"_blur)")}xb("stdDeviation",w,[m.firstChild]);b.setBlurOffsets(m,w)}else b.setBlur(w)};b.setBlurOffsets=function(w,H){if(H>3)ma(w,{x:"-50%",y:"-50%",width:"200%",
0){gb(e,h,m);N("changed",J)}};this.getStyle=function(){return M};this.getOpacity=function(){return M.opacity};this.setOpacity=function(e){M.opacity=e;gb("opacity",e)};this.getFillOpacity=function(){return M.fill_opacity};this.getStrokeOpacity=function(){return M.stroke_opacity};this.setPaintOpacity=function(e,h,m){M[e+"_opacity"]=h;m?yb(e+"-opacity",h):gb(e+"-opacity",h)};this.getBlur=function(e){var h=0;if(e)if(e.getAttribute("filter"))if(e=qa(e.id+"_blur"))h=e.firstChild.getAttribute("stdDeviation");
return h};(function(){function e(){var w=b.undoMgr.finishUndoableChange();h.addSubCommand(w);ya(h);m=h=null}var h=null,m=null,z=false;b.setBlurNoUndo=function(w){if(m)if(w===0){yb("filter","");z=true}else{var H=J[0];z&&yb("filter","url(#"+H.id+"_blur)");if(svgedit.browser.isWebkit()){H.removeAttribute("filter");H.setAttribute("filter","url(#"+H.id+"_blur)")}yb("stdDeviation",w,[m.firstChild]);b.setBlurOffsets(m,w)}else b.setBlur(w)};b.setBlurOffsets=function(w,H){if(H>3)ma(w,{x:"-50%",y:"-50%",width:"200%",
height:"200%"},100);else if(!svgedit.browser.isWebkit()){w.removeAttribute("x");w.removeAttribute("y");w.removeAttribute("width");w.removeAttribute("height")}};b.setBlur=function(w,H){if(h)e();else{var A=J[0],v=A.id;m=qa(v+"_blur");w-=0;var F=new za;if(m){if(w===0)m=null}else{var I=Q({element:"feGaussianBlur",attr:{"in":"SourceGraphic",stdDeviation:w}});m=Q({element:"filter",attr:{id:v+"_blur"}});m.appendChild(I);lb().appendChild(m);F.addSubCommand(new Ca(m))}I={filter:A.getAttribute("filter")};if(w===
0){A.removeAttribute("filter");F.addSubCommand(new Na(A,I))}else{gb("filter","url(#"+v+"_blur)");F.addSubCommand(new Na(A,I));b.setBlurOffsets(m,w);h=F;b.undoMgr.beginUndoableChange("stdDeviation",[m?m.firstChild:null]);if(H){b.setBlurNoUndo(w);e()}}}}})();this.getBold=function(){var e=J[0];if(e!=null&&e.tagName=="text"&&J[1]==null)return e.getAttribute("font-weight")=="bold";return false};this.setBold=function(e){var h=J[0];if(h!=null&&h.tagName=="text"&&J[1]==null)gb("font-weight",e?"bold":"normal");
J[0].textContent||hb.setCursor()};this.getItalic=function(){var e=J[0];if(e!=null&&e.tagName=="text"&&J[1]==null)return e.getAttribute("font-style")=="italic";return false};this.setItalic=function(e){var h=J[0];if(h!=null&&h.tagName=="text"&&J[1]==null)gb("font-style",e?"italic":"normal");J[0].textContent||hb.setCursor()};this.getFontFamily=function(){return Za.font_family};this.setFontFamily=function(e){Za.font_family=e;gb("font-family",e);J[0]&&!J[0].textContent&&hb.setCursor()};this.setFontColor=
@ -350,158 +350,158 @@ function(e){Za.fill=e;gb("fill",e)};this.getFontSize=function(){return Za.fill};
true;else if(!m)return;var w=new za("Change Image URL");V(h,e);w.addSubCommand(new Na(h,{"#href":z}));m?$(new Image).load(function(){var H=$(h).attr(["width","height"]);$(h).attr({width:this.width,height:this.height});Ha.requestSelector(h).resize();w.addSubCommand(new Na(h,H));ya(w);N("changed",[h])}).attr("src",e):ya(w)}};this.setLinkURL=function(e){var h=J[0];if(h){if(h.tagName!=="a"){h=$(h).parents("a");if(h.length)h=h[0];else return}var m=da(h);if(m!==e){var z=new za("Change Link URL");V(h,e);
z.addSubCommand(new Na(h,{"#href":m}));ya(z)}}};this.elementsAreSame=function(e){return!e.length||e[0]==null?null:J.every(function(h){return h&&J[0]?h.nodeName==J[0].nodeName:null})};this.setRectRadius=function(e){b.elementsAreSame(J)&&J[0].tagName=="rect"&&J.forEach(function(h){var m=h.getAttribute("rx");if(m!=e){h.setAttribute("rx",e);h.setAttribute("ry",e);ya(new Na(h,{rx:m,ry:m},"Radius"));N("changed",[h])}})};this.makeHyperlink=function(e){b.groupSelectedElements("a",e)};this.removeHyperlink=
function(){b.ungroupSelectedElement()};this.setSegType=function(e){Ja.setSegType(e)};this.convertToPath=function(e,h){if(e==null)$.each(J,function(U,S){S&&b.convertToPath(S)});else{if(!h)var m=new za("Convert element to Path");var z=h?{}:{fill:M.fill,"fill-opacity":M.fill_opacity,stroke:M.stroke,"stroke-width":M.stroke_width,"stroke-dasharray":M.stroke_dasharray,"stroke-linejoin":M.stroke_linejoin,"stroke-linecap":M.stroke_linecap,"stroke-opacity":M.stroke_opacity,opacity:M.opacity,visibility:"hidden"};
$.each(["marker-start","marker-end","marker-mid","filter","clip-path"],function(){if(e.getAttribute(this))z[this]=e.getAttribute(this)});var w=Q({element:"path",attr:z}),H=e.getAttribute("transform");H&&w.setAttribute("transform",H);var A=e.id,v=e.parentNode;e.nextSibling?v.insertBefore(w,e):v.appendChild(w);var F="",I=function(U){$.each(U,function(S,X){var aa=X[1];F+=X[0];for(var ga=0;ga<aa.length;ga+=2)F+=aa[ga]+","+aa[ga+1]+" "})},D=1.81;switch(e.tagName){case "ellipse":case "circle":var G=$(e).attr(["rx",
"ry","cx","cy"]),L=G.cx,k=G.cy,u=G.rx;G=G.ry;if(e.tagName=="circle")u=G=$(e).attr("r");I([["M",[L-u,k]],["C",[L-u,k-G/D,L-u/D,k-G,L,k-G]],["C",[L+u/D,k-G,L+u,k-G/D,L+u,k]],["C",[L+u,k+G/D,L+u/D,k+G,L,k+G]],["C",[L-u/D,k+G,L-u,k+G/D,L-u,k]],["Z",[]]]);break;case "path":F=e.getAttribute("d");break;case "line":G=$(e).attr(["x1","y1","x2","y2"]);F="M"+G.x1+","+G.y1+"L"+G.x2+","+G.y2;break;case "polyline":case "polygon":F="M"+e.getAttribute("points");break;case "rect":G=$(e).attr(["rx","ry"]);u=G.rx;G=
G.ry;var C=e.getBBox();L=C.x;k=C.y;var E=C.width;C=C.height;D=4-D;!u&&!G?I([["M",[L,k]],["L",[L+E,k]],["L",[L+E,k+C]],["L",[L,k+C]],["L",[L,k]],["Z",[]]]):I([["M",[L,k+G]],["C",[L,k+G/D,L+u/D,k,L+u,k]],["L",[L+E-u,k]],["C",[L+E-u/D,k,L+E,k+G/D,L+E,k+G]],["L",[L+E,k+C-G]],["C",[L+E,k+C-G/D,L+E-u/D,k+C,L+E-u,k+C]],["L",[L+u,k+C]],["C",[L+u/D,k+C,L,k+C-G/D,L,k+C-G]],["L",[L,k+G]],["Z",[]]]);break;default:w.parentNode.removeChild(w)}F&&w.setAttribute("d",F);if(h){Ja.resetOrientation(w);m=false;try{m=
w.getBBox()}catch(P){}w.parentNode.removeChild(w);return m}else{if(H){H=Y(w);pa(H)&&Ja.resetOrientation(w)}m.addSubCommand(new Ka(e,e.nextSibling,v));m.addSubCommand(new Ca(w));Pa();e.parentNode.removeChild(e);w.setAttribute("id",A);w.removeAttribute("visibility");vb([w],true);ya(m)}}};var xb=this.changeSelectedAttributeNoUndo=function(e,h,m){var z=d.suspendRedraw(1E3);Ea=="pathedit"&&Ja.moveNode(e,h);m=m||J;for(var w=m.length,H=["g","polyline","path"];w--;){var A=m[w];if(A!=null){Ea==="textedit"&&
$.each(["marker-start","marker-end","marker-mid","filter","clip-path"],function(){if(e.getAttribute(this))z[this]=e.getAttribute(this)});var w=Q({element:"path",attr:z}),H=e.getAttribute("transform");H&&w.setAttribute("transform",H);var A=e.id,v=e.parentNode;e.nextSibling?v.insertBefore(w,e):v.appendChild(w);var F="",I=function(U){$.each(U,function(S,Y){var aa=Y[1];F+=Y[0];for(var ga=0;ga<aa.length;ga+=2)F+=aa[ga]+","+aa[ga+1]+" "})},E=1.81;switch(e.tagName){case "ellipse":case "circle":var G=$(e).attr(["rx",
"ry","cx","cy"]),L=G.cx,k=G.cy,u=G.rx;G=G.ry;if(e.tagName=="circle")u=G=$(e).attr("r");I([["M",[L-u,k]],["C",[L-u,k-G/E,L-u/E,k-G,L,k-G]],["C",[L+u/E,k-G,L+u,k-G/E,L+u,k]],["C",[L+u,k+G/E,L+u/E,k+G,L,k+G]],["C",[L-u/E,k+G,L-u,k+G/E,L-u,k]],["Z",[]]]);break;case "path":F=e.getAttribute("d");break;case "line":G=$(e).attr(["x1","y1","x2","y2"]);F="M"+G.x1+","+G.y1+"L"+G.x2+","+G.y2;break;case "polyline":case "polygon":F="M"+e.getAttribute("points");break;case "rect":G=$(e).attr(["rx","ry"]);u=G.rx;G=
G.ry;var C=e.getBBox();L=C.x;k=C.y;var D=C.width;C=C.height;E=4-E;!u&&!G?I([["M",[L,k]],["L",[L+D,k]],["L",[L+D,k+C]],["L",[L,k+C]],["L",[L,k]],["Z",[]]]):I([["M",[L,k+G]],["C",[L,k+G/E,L+u/E,k,L+u,k]],["L",[L+D-u,k]],["C",[L+D-u/E,k,L+D,k+G/E,L+D,k+G]],["L",[L+D,k+C-G]],["C",[L+D,k+C-G/E,L+D-u/E,k+C,L+D-u,k+C]],["L",[L+u,k+C]],["C",[L+u/E,k+C,L,k+C-G/E,L,k+C-G]],["L",[L,k+G]],["Z",[]]]);break;default:w.parentNode.removeChild(w)}F&&w.setAttribute("d",F);if(h){Ja.resetOrientation(w);m=false;try{m=
w.getBBox()}catch(P){}w.parentNode.removeChild(w);return m}else{if(H){H=X(w);pa(H)&&Ja.resetOrientation(w)}m.addSubCommand(new Ka(e,e.nextSibling,v));m.addSubCommand(new Ca(w));Qa();e.parentNode.removeChild(e);w.setAttribute("id",A);w.removeAttribute("visibility");vb([w],true);ya(m)}}};var yb=this.changeSelectedAttributeNoUndo=function(e,h,m){var z=d.suspendRedraw(1E3);Ea=="pathedit"&&Ja.moveNode(e,h);m=m||J;for(var w=m.length,H=["g","polyline","path"];w--;){var A=m[w];if(A!=null){Ea==="textedit"&&
e!=="#text"&&A.textContent.length&&hb.toSelectMode(A);if((e==="x"||e==="y")&&H.indexOf(A.tagName)>=0){var v=getStrokedBBox([A]);b.moveSelectedElements((e==="x"?h-v.x:0)*o,(e==="y"?h-v.y:0)*o,true)}else{v=e==="#text"?A.textContent:A.getAttribute(e);if(v==null)v="";if(v!==String(h)){if(e=="#text"){svgedit.utilities.getBBox(A);A.textContent=h}else e=="#href"?V(A,h):A.setAttribute(e,h);J.indexOf(A)>=0&&setTimeout(function(){A.parentNode&&Ha.requestSelector(A).resize()},0);v=oa(A);if(v!=0&&e!="transform")for(var F=
Y(A),I=F.numberOfItems;I--;)if(F.getItem(I).type==4){F.removeItem(I);var D=svgedit.utilities.getBBox(A),G=O(D.x+D.width/2,D.y+D.height/2,fa(F).matrix);D=G.x;G=G.y;var L=d.createSVGTransform();L.setRotate(v,D,G);F.insertItemBefore(L,I);break}}}}}d.unsuspendRedraw(z)},gb=this.changeSelectedAttribute=function(e,h,m){m=m||J;b.undoMgr.beginUndoableChange(e,m);xb(e,h,m);e=b.undoMgr.finishUndoableChange();e.isEmpty()||ya(e)};this.deleteSelectedElements=function(){for(var e=new za("Delete Elements"),h=J.length,
m=[],z=0;z<h;++z){var w=J[z];if(w==null)break;var H=w.parentNode,A=w;Ha.releaseSelector(A);svgedit.path.removePath_(A.id);if(H.tagName==="a"&&H.childNodes.length===1){A=H;H=H.parentNode}var v=A.nextSibling;A=H.removeChild(A);m.push(w);J[z]=null;e.addSubCommand(new Ka(A,v,H))}e.isEmpty()||ya(e);N("changed",m);Pa()};this.cutSelectedElements=function(){for(var e=new za("Cut Elements"),h=J.length,m=[],z=0;z<h;++z){var w=J[z];if(w==null)break;var H=w.parentNode,A=w;Ha.releaseSelector(A);svgedit.path.removePath_(A.id);
var v=A.nextSibling;A=H.removeChild(A);m.push(w);J[z]=null;e.addSubCommand(new Ka(A,v,H))}e.isEmpty()||ya(e);N("changed",m);Pa();b.clipBoard=m};this.copySelectedElements=function(){b.clipBoard=$.merge([],J)};this.pasteElements=function(){var e=b.clipBoard,h=e.length;if(h){for(var m=[],z=new za("Paste elements");h--;){var w=e[h];if(w){var H=la(w);if(!qa(w.id))H.id=w.id;m.push(H);(K||B().getCurrentLayer()).appendChild(H);z.addSubCommand(new Ca(H))}}svgCanvas.clearSelection();setTimeout(function(){Bb(m)},
X(A),I=F.numberOfItems;I--;)if(F.getItem(I).type==4){F.removeItem(I);var E=svgedit.utilities.getBBox(A),G=O(E.x+E.width/2,E.y+E.height/2,fa(F).matrix);E=G.x;G=G.y;var L=d.createSVGTransform();L.setRotate(v,E,G);F.insertItemBefore(L,I);break}}}}}d.unsuspendRedraw(z)},gb=this.changeSelectedAttribute=function(e,h,m){m=m||J;b.undoMgr.beginUndoableChange(e,m);yb(e,h,m);e=b.undoMgr.finishUndoableChange();e.isEmpty()||ya(e)};this.deleteSelectedElements=function(){for(var e=new za("Delete Elements"),h=J.length,
m=[],z=0;z<h;++z){var w=J[z];if(w==null)break;var H=w.parentNode,A=w;Ha.releaseSelector(A);svgedit.path.removePath_(A.id);if(H.tagName==="a"&&H.childNodes.length===1){A=H;H=H.parentNode}var v=A.nextSibling;A=H.removeChild(A);m.push(w);J[z]=null;e.addSubCommand(new Ka(A,v,H))}e.isEmpty()||ya(e);N("changed",m);Qa()};this.cutSelectedElements=function(){for(var e=new za("Cut Elements"),h=J.length,m=[],z=0;z<h;++z){var w=J[z];if(w==null)break;var H=w.parentNode,A=w;Ha.releaseSelector(A);svgedit.path.removePath_(A.id);
var v=A.nextSibling;A=H.removeChild(A);m.push(w);J[z]=null;e.addSubCommand(new Ka(A,v,H))}e.isEmpty()||ya(e);N("changed",m);Qa();b.clipBoard=m};this.copySelectedElements=function(){b.clipBoard=$.merge([],J)};this.pasteElements=function(){var e=b.clipBoard,h=e.length;if(h){for(var m=[],z=new za("Paste elements");h--;){var w=e[h];if(w){var H=la(w);if(!qa(w.id))H.id=w.id;m.push(H);(K||B().getCurrentLayer()).appendChild(H);z.addSubCommand(new Ca(H))}}svgCanvas.clearSelection();setTimeout(function(){xb(m)},
100);ya(z);N("changed",m)}};this.groupSelectedElements=function(e){e||(e="g");var h="";switch(e){case "a":h="Make hyperlink";var m="";if(arguments.length>1)m=arguments[1];break;default:e="g";h="Group Elements"}h=new za(h);var z=Q({element:e,attr:{id:ja()}});e==="a"&&V(z,m);h.addSubCommand(new Ca(z));for(m=J.length;m--;){var w=J[m];if(w!=null){if(w.parentNode.tagName==="a"&&w.parentNode.childNodes.length===1)w=w.parentNode;var H=w.nextSibling,A=w.parentNode;z.appendChild(w);h.addSubCommand(new Ia(w,
H,A))}}h.isEmpty()||ya(h);Bb([z],true)};var Mb=this.pushGroupProperties=function(e,h){var m=e.childNodes,z=m.length,w=e.getAttribute("transform"),H=Y(e),A=fa(H).matrix,v=new za("Push group properties"),F=0,I=oa(e),D=$(e).attr(["filter","opacity"]),G,L;for(F=0;F<z;F++){var k=m[F];if(k.nodeType===1){if(D.opacity!==null&&D.opacity!==1){k.getAttribute("opacity");var u=Math.round((k.getAttribute("opacity")||1)*D.opacity*100)/100;gb("opacity",u,[k])}if(D.filter){var C=u=this.getBlur(k);L||(L=this.getBlur(e));
if(u)u=L-0+(u-0);else if(u===0)u=L;if(C)G=R(k.getAttribute("filter"));else if(G){G=la(G);lb().appendChild(G)}else G=R(D.filter);G.id=k.id+"_"+(G.firstChild.tagName==="feGaussianBlur"?"blur":"filter");gb("filter","url(#"+G.id+")",[k]);if(u){gb("stdDeviation",u,[G.firstChild]);b.setBlurOffsets(G,u)}}u=Y(k);if(~k.tagName.indexOf("Gradient"))u=null;if(u)if(k.tagName!=="defs")if(H.numberOfItems){if(I&&H.numberOfItems==1){var E=H.getItem(0).matrix,P=d.createSVGMatrix();if(C=oa(k))P=u.getItem(0).matrix;
var U=svgedit.utilities.getBBox(k),S=fa(u).matrix,X=O(U.x+U.width/2,U.y+U.height/2,S);U=I+C;S=d.createSVGTransform();S.setRotate(U,X.x,X.y);E=ia(E,P,S.matrix.inverse());C&&u.removeItem(0);if(U)u.numberOfItems?u.insertItemBefore(S,0):u.appendItem(S);if(E.e||E.f){C=d.createSVGTransform();C.setTranslate(E.e,E.f);u.numberOfItems?u.insertItemBefore(C,0):u.appendItem(C)}}else{C=k.getAttribute("transform");E={};E.transform=C?C:"";C=d.createSVGTransform();E=fa(u).matrix;P=E.inverse();E=ia(P,A,E);C.setMatrix(E);
u.appendItem(C)}(k=Xa(k))&&v.addSubCommand(k)}}}if(w){E={};E.transform=w;e.setAttribute("transform","");e.removeAttribute("transform");v.addSubCommand(new Na(e,E))}if(h&&!v.isEmpty())return v};this.ungroupSelectedElement=function(){var e=J[0];if($(e).data("gsvg")||$(e).data("symbol"))Db(e);else if(e.tagName==="use"){var h=qa(da(e).substr(1));$(e).data("symbol",h).data("ref",h);Db(e)}else{h=$(e).parents("a");if(h.length)e=h[0];if(e.tagName==="g"||e.tagName==="a"){h=new za("Ungroup Elements");var m=
Mb(e,true);m&&h.addSubCommand(m);m=e.parentNode;for(var z=e.nextSibling,w=Array(e.childNodes.length),H=0;e.firstChild;){var A=e.firstChild,v=A.nextSibling,F=A.parentNode;if(A.tagName==="title"){h.addSubCommand(new Ka(A,A.nextSibling,F));F.removeChild(A)}else{w[H++]=A=m.insertBefore(A,z);h.addSubCommand(new Ia(A,v,F))}}Pa();z=e.nextSibling;e=m.removeChild(e);h.addSubCommand(new Ka(e,z,m));h.isEmpty()||ya(h);vb(w)}}};this.moveToTopSelectedElement=function(){var e=J[0];if(e!=null){e=e;var h=e.parentNode,
H,A))}}h.isEmpty()||ya(h);xb([z],true)};var Mb=this.pushGroupProperties=function(e,h){var m=e.childNodes,z=m.length,w=e.getAttribute("transform"),H=X(e),A=fa(H).matrix,v=new za("Push group properties"),F=0,I=oa(e),E=$(e).attr(["filter","opacity"]),G,L;for(F=0;F<z;F++){var k=m[F];if(k.nodeType===1){if(E.opacity!==null&&E.opacity!==1){k.getAttribute("opacity");var u=Math.round((k.getAttribute("opacity")||1)*E.opacity*100)/100;gb("opacity",u,[k])}if(E.filter){var C=u=this.getBlur(k);L||(L=this.getBlur(e));
if(u)u=L-0+(u-0);else if(u===0)u=L;if(C)G=R(k.getAttribute("filter"));else if(G){G=la(G);lb().appendChild(G)}else G=R(E.filter);G.id=k.id+"_"+(G.firstChild.tagName==="feGaussianBlur"?"blur":"filter");gb("filter","url(#"+G.id+")",[k]);if(u){gb("stdDeviation",u,[G.firstChild]);b.setBlurOffsets(G,u)}}u=X(k);if(~k.tagName.indexOf("Gradient"))u=null;if(u)if(k.tagName!=="defs")if(H.numberOfItems){if(I&&H.numberOfItems==1){var D=H.getItem(0).matrix,P=d.createSVGMatrix();if(C=oa(k))P=u.getItem(0).matrix;
var U=svgedit.utilities.getBBox(k),S=fa(u).matrix,Y=O(U.x+U.width/2,U.y+U.height/2,S);U=I+C;S=d.createSVGTransform();S.setRotate(U,Y.x,Y.y);D=ia(D,P,S.matrix.inverse());C&&u.removeItem(0);if(U)u.numberOfItems?u.insertItemBefore(S,0):u.appendItem(S);if(D.e||D.f){C=d.createSVGTransform();C.setTranslate(D.e,D.f);u.numberOfItems?u.insertItemBefore(C,0):u.appendItem(C)}}else{C=k.getAttribute("transform");D={};D.transform=C?C:"";C=d.createSVGTransform();D=fa(u).matrix;P=D.inverse();D=ia(P,A,D);C.setMatrix(D);
u.appendItem(C)}(k=Ua(k))&&v.addSubCommand(k)}}}if(w){D={};D.transform=w;e.setAttribute("transform","");e.removeAttribute("transform");v.addSubCommand(new Na(e,D))}if(h&&!v.isEmpty())return v};this.ungroupSelectedElement=function(){var e=J[0];if($(e).data("gsvg")||$(e).data("symbol"))Db(e);else if(e.tagName==="use"){var h=qa(da(e).substr(1));$(e).data("symbol",h).data("ref",h);Db(e)}else{h=$(e).parents("a");if(h.length)e=h[0];if(e.tagName==="g"||e.tagName==="a"){h=new za("Ungroup Elements");var m=
Mb(e,true);m&&h.addSubCommand(m);m=e.parentNode;for(var z=e.nextSibling,w=Array(e.childNodes.length),H=0;e.firstChild;){var A=e.firstChild,v=A.nextSibling,F=A.parentNode;if(A.tagName==="title"){h.addSubCommand(new Ka(A,A.nextSibling,F));F.removeChild(A)}else{w[H++]=A=m.insertBefore(A,z);h.addSubCommand(new Ia(A,v,F))}}Qa();z=e.nextSibling;e=m.removeChild(e);h.addSubCommand(new Ka(e,z,m));h.isEmpty()||ya(h);vb(w)}}};this.moveToTopSelectedElement=function(){var e=J[0];if(e!=null){e=e;var h=e.parentNode,
m=e.nextSibling;e=e.parentNode.appendChild(e);if(m!=e.nextSibling){ya(new Ia(e,m,h,"top"));N("changed",[e])}}};this.moveToBottomSelectedElement=function(){var e=J[0];if(e!=null){e=e;var h=e.parentNode,m=e.nextSibling,z=e.parentNode.firstChild;if(z.tagName=="title")z=z.nextSibling;if(z.tagName=="defs")z=z.nextSibling;e=e.parentNode.insertBefore(e,z);if(m!=e.nextSibling){ya(new Ia(e,m,h,"bottom"));N("changed",[e])}}};this.moveUpDownSelected=function(e){var h=J[0];if(h){mb=[];var m,z,w=$(tb(getStrokedBBox([h]))).toArray();
e=="Down"&&w.reverse();$.each(w,function(){if(z){m=this;return false}else if(this==h)z=true});if(m){w=h.parentNode;var H=h.nextSibling;$(m)[e=="Down"?"before":"after"](h);if(H!=h.nextSibling){ya(new Ia(h,H,w,"Move "+e));N("changed",[h])}}}};this.moveSelectedElements=function(e,h,m){if(e.constructor!=Array){e/=o;h/=o}m=m||true;for(var z=new za("position"),w=J.length;w--;){var H=J[w];if(H!=null){var A=d.createSVGTransform(),v=Y(H);e.constructor==Array?A.setTranslate(e[w],h[w]):A.setTranslate(e,h);v.numberOfItems?
v.insertItemBefore(A,0):v.appendItem(A);(A=Xa(H))&&z.addSubCommand(A);Ha.requestSelector(H).resize()}}if(!z.isEmpty()){m&&ya(z);N("changed",J);return z}};this.cloneSelectedElements=function(e,h,m){for(var z=new za("Clone Elements"),w=J.length,H=0;H<w;++H)if(J[H]==null)break;w=J.slice(0,H);this.clearSelection(true);for(H=w.length;H--;){var A=la(w[H]);m&&A.setAttribute("transform","");(K||B().getCurrentLayer()).appendChild(A);z.addSubCommand(new Ca(A))}if(!z.isEmpty()){vb(w.reverse());this.moveSelectedElements(e,
h,false);ya(z)}return A};this.alignSelectedElements=function(e,h){var m=[],z=Number.MAX_VALUE,w=Number.MIN_VALUE,H=Number.MAX_VALUE,A=Number.MIN_VALUE,v=Number.MIN_VALUE,F=Number.MIN_VALUE,I=J.length;if(I){for(var D=0;D<I;++D){if(J[D]==null)break;m[D]=getStrokedBBox([J[D]]);switch(h){case "smallest":if((e=="l"||e=="c"||e=="r")&&(v==Number.MIN_VALUE||v>m[D].width)||(e=="t"||e=="m"||e=="b")&&(F==Number.MIN_VALUE||F>m[D].height)){z=m[D].x;H=m[D].y;w=m[D].x+m[D].width;A=m[D].y+m[D].height;v=m[D].width;
F=m[D].height}break;case "largest":if((e=="l"||e=="c"||e=="r")&&(v==Number.MIN_VALUE||v<m[D].width)||(e=="t"||e=="m"||e=="b")&&(F==Number.MIN_VALUE||F<m[D].height)){z=m[D].x;H=m[D].y;w=m[D].x+m[D].width;A=m[D].y+m[D].height;v=m[D].width;F=m[D].height}break;default:if(m[D].x<z)z=m[D].x;if(m[D].y<H)H=m[D].y;if(m[D].x+m[D].width>w)w=m[D].x+m[D].width;if(m[D].y+m[D].height>A)A=m[D].y+m[D].height}}if(h=="page"){H=z=0;w=b.contentW;A=b.contentH}v=Array(I);F=Array(I);for(D=0;D<I;++D){if(J[D]==null)break;
var G=m[D];v[D]=0;F[D]=0;switch(e){case "l":v[D]=z-G.x;break;case "c":v[D]=(z+w)/2-(G.x+G.width/2);break;case "r":v[D]=w-(G.x+G.width);break;case "t":F[D]=H-G.y;break;case "m":F[D]=(H+A)/2-(G.y+G.height/2);break;case "b":F[D]=A-(G.y+G.height)}}this.moveSelectedElements(v,F)}};this.contentW=Eb().w;this.contentH=Eb().h;this.updateCanvas=function(e,h){d.setAttribute("width",e);d.setAttribute("height",h);var m=$("#canvasBackground")[0],z=l.getAttribute("x"),w=l.getAttribute("y"),H=e/2-this.contentW*o/
2,A=h/2-this.contentH*o/2;ma(l,{width:this.contentW*o,height:this.contentH*o,x:H,y:A,viewBox:"0 0 "+this.contentW+" "+this.contentH});ma(m,{width:l.getAttribute("width"),height:l.getAttribute("height"),x:H,y:A});(m=qa("background_image"))&&ma(m,{width:"100%",height:"100%"});Ha.selectorParentGroup.setAttribute("transform","translate("+H+","+A+")");return{x:H,y:A,old_x:z,old_y:w,d_x:H-z,d_y:A-w}};this.setBackground=function(e,h){var m=qa("canvasBackground"),z=$(m).find("rect")[0],w=qa("background_image");
z.setAttribute("fill",e);if(h){if(!w){w=f.createElementNS(c,"image");ma(w,{id:"background_image",width:"100%",height:"100%",preserveAspectRatio:"xMinYMin",style:"pointer-events:none"})}V(w,h);m.appendChild(w)}else w&&w.parentNode.removeChild(w)};this.cycleElement=function(e){var h=J[0],m=false,z=ub(K||B().getCurrentLayer());if(z.length){if(h==null){e=e?z.length-1:0;m=z[e]}else for(var w=z.length;w--;)if(z[w]==h){e=e?w-1:w+1;if(e>=z.length)e=0;else if(e<0)e=z.length-1;m=z[e];break}Bb([m],true);N("selected",
J)}};this.clear();this.getPrivateMethods=function(){return{addCommandToHistory:ya,setGradient:Qb,addSvgElementFromJson:Q,assignAttributes:ma,BatchCommand:za,call:N,ChangeElementCommand:Na,copyElem:la,ffClone:ea,findDefs:lb,findDuplicateGradient:Pb,getElem:qa,getId:ca,getIntersectionList:tb,getMouseTarget:Ib,getNextId:ja,getPathBBox:Z,getUrlFromAttr:ka,hasMatrixTransform:pa,identifyLayers:Fb,InsertElementCommand:Ca,isIdentity:svgedit.math.isIdentity,logMatrix:Ya,matrixMultiply:ia,MoveElementCommand:Ia,
preventClickDefault:pb,recalculateAllSelectedDimensions:Ga,recalculateDimensions:Xa,remapElement:db,RemoveElementCommand:Ka,removeUnusedDefElems:Kb,round:eb,runExtensions:ob,sanitizeSvg:Fa,SVGEditTransformList:svgedit.transformlist.SVGTransformList,toString:toString,transformBox:svgedit.math.transformBox,transformListToTransform:fa,transformPoint:O,walkTree:svgedit.utilities.walkTree}}};(function(){document.addEventListener("touchstart",touchHandler,true);document.addEventListener("touchmove",touchHandler,true);document.addEventListener("touchend",touchHandler,true);document.addEventListener("touchcancel",touchHandler,true);if(!window.svgEditor)window.svgEditor=function(a){function p(d,l){var q=g.setSvgString(d)!==false;l=l||a.noop;q?l(true):a.alert(uiStrings.notification.errorLoadingSVG,function(){l(false)})}var g,c={},n=false;curConfig={canvas_expansion:1,dimensions:[580,400],
e=="Down"&&w.reverse();$.each(w,function(){if(z){m=this;return false}else if(this==h)z=true});if(m){w=h.parentNode;var H=h.nextSibling;$(m)[e=="Down"?"before":"after"](h);if(H!=h.nextSibling){ya(new Ia(h,H,w,"Move "+e));N("changed",[h])}}}};this.moveSelectedElements=function(e,h,m){if(e.constructor!=Array){e/=o;h/=o}m=m||true;for(var z=new za("position"),w=J.length;w--;){var H=J[w];if(H!=null){var A=d.createSVGTransform(),v=X(H);e.constructor==Array?A.setTranslate(e[w],h[w]):A.setTranslate(e,h);v.numberOfItems?
v.insertItemBefore(A,0):v.appendItem(A);(A=Ua(H))&&z.addSubCommand(A);Ha.requestSelector(H).resize()}}if(!z.isEmpty()){m&&ya(z);N("changed",J);return z}};this.cloneSelectedElements=function(e,h,m){for(var z=new za("Clone Elements"),w=J.length,H=0;H<w;++H)if(J[H]==null)break;w=J.slice(0,H);this.clearSelection(true);H=w.length;for(clones=[];H--;){var A=la(w[H]);if(m){tlist=X(A);tlist.removeItem(m);Ua(A)}(K||B().getCurrentLayer()).appendChild(A);clones.push(A);z.addSubCommand(new Ca(A))}if(!z.isEmpty()){vb(w.reverse());
m||this.moveSelectedElements(e,h,false);ya(z)}return clones};this.alignSelectedElements=function(e,h){var m=[],z=Number.MAX_VALUE,w=Number.MIN_VALUE,H=Number.MAX_VALUE,A=Number.MIN_VALUE,v=Number.MIN_VALUE,F=Number.MIN_VALUE,I=J.length;if(I){for(var E=0;E<I;++E){if(J[E]==null)break;m[E]=getStrokedBBox([J[E]]);switch(h){case "smallest":if((e=="l"||e=="c"||e=="r")&&(v==Number.MIN_VALUE||v>m[E].width)||(e=="t"||e=="m"||e=="b")&&(F==Number.MIN_VALUE||F>m[E].height)){z=m[E].x;H=m[E].y;w=m[E].x+m[E].width;
A=m[E].y+m[E].height;v=m[E].width;F=m[E].height}break;case "largest":if((e=="l"||e=="c"||e=="r")&&(v==Number.MIN_VALUE||v<m[E].width)||(e=="t"||e=="m"||e=="b")&&(F==Number.MIN_VALUE||F<m[E].height)){z=m[E].x;H=m[E].y;w=m[E].x+m[E].width;A=m[E].y+m[E].height;v=m[E].width;F=m[E].height}break;default:if(m[E].x<z)z=m[E].x;if(m[E].y<H)H=m[E].y;if(m[E].x+m[E].width>w)w=m[E].x+m[E].width;if(m[E].y+m[E].height>A)A=m[E].y+m[E].height}}if(h=="page"){H=z=0;w=b.contentW;A=b.contentH}v=Array(I);F=Array(I);for(E=
0;E<I;++E){if(J[E]==null)break;var G=m[E];v[E]=0;F[E]=0;switch(e){case "l":v[E]=z-G.x;break;case "c":v[E]=(z+w)/2-(G.x+G.width/2);break;case "r":v[E]=w-(G.x+G.width);break;case "t":F[E]=H-G.y;break;case "m":F[E]=(H+A)/2-(G.y+G.height/2);break;case "b":F[E]=A-(G.y+G.height)}}this.moveSelectedElements(v,F)}};this.contentW=Eb().w;this.contentH=Eb().h;this.updateCanvas=function(e,h){d.setAttribute("width",e);d.setAttribute("height",h);var m=$("#canvasBackground")[0],z=l.getAttribute("x"),w=l.getAttribute("y"),
H=e/2-this.contentW*o/2,A=h/2-this.contentH*o/2;ma(l,{width:this.contentW*o,height:this.contentH*o,x:H,y:A,viewBox:"0 0 "+this.contentW+" "+this.contentH});ma(m,{width:l.getAttribute("width"),height:l.getAttribute("height"),x:H,y:A});(m=qa("background_image"))&&ma(m,{width:"100%",height:"100%"});Ha.selectorParentGroup.setAttribute("transform","translate("+H+","+A+")");return{x:H,y:A,old_x:z,old_y:w,d_x:H-z,d_y:A-w}};this.setBackground=function(e,h){var m=qa("canvasBackground"),z=$(m).find("rect")[0],
w=qa("background_image");z.setAttribute("fill",e);if(h){if(!w){w=f.createElementNS(c,"image");ma(w,{id:"background_image",width:"100%",height:"100%",preserveAspectRatio:"xMinYMin",style:"pointer-events:none"})}V(w,h);m.appendChild(w)}else w&&w.parentNode.removeChild(w)};this.cycleElement=function(e){var h=J[0],m=false,z=ub(K||B().getCurrentLayer());if(z.length){if(h==null){e=e?z.length-1:0;m=z[e]}else for(var w=z.length;w--;)if(z[w]==h){e=e?w-1:w+1;if(e>=z.length)e=0;else if(e<0)e=z.length-1;m=z[e];
break}xb([m],true);N("selected",J)}};this.clear();this.getPrivateMethods=function(){return{addCommandToHistory:ya,setGradient:Qb,addSvgElementFromJson:Q,assignAttributes:ma,BatchCommand:za,call:N,ChangeElementCommand:Na,copyElem:la,ffClone:ea,findDefs:lb,findDuplicateGradient:Pb,getElem:qa,getId:ca,getIntersectionList:tb,getMouseTarget:Ib,getNextId:ja,getPathBBox:Z,getUrlFromAttr:ka,hasMatrixTransform:pa,identifyLayers:Fb,InsertElementCommand:Ca,isIdentity:svgedit.math.isIdentity,logMatrix:Ya,matrixMultiply:ia,
MoveElementCommand:Ia,preventClickDefault:pb,recalculateAllSelectedDimensions:Ga,recalculateDimensions:Ua,remapElement:db,RemoveElementCommand:Ka,removeUnusedDefElems:Kb,round:eb,runExtensions:ob,sanitizeSvg:Fa,SVGEditTransformList:svgedit.transformlist.SVGTransformList,toString:toString,transformBox:svgedit.math.transformBox,transformListToTransform:fa,transformPoint:O,walkTree:svgedit.utilities.walkTree}}};(function(){document.addEventListener("touchstart",touchHandler,true);document.addEventListener("touchmove",touchHandler,true);document.addEventListener("touchend",touchHandler,true);document.addEventListener("touchcancel",touchHandler,true);if(!window.svgEditor)window.svgEditor=function(a){function p(d,l){var q=g.setSvgString(d)!==false;l=l||a.noop;q?l(true):a.alert(uiStrings.notification.errorLoadingSVG,function(){l(false)})}var g,c={},n=false;curConfig={canvas_expansion:1,dimensions:[580,400],
initFill:{color:"fff",opacity:1},initStroke:{width:1.5,color:"000",opacity:1},initOpacity:1,imgPath:"images/",extPath:"extensions/",jGraduatePath:"jgraduate/images/",extensions:[],initTool:"select",wireframe:false,colorPickerCSS:false,gridSnapping:false,gridColor:"#000",baseUnit:"px",snappingStep:10,showRulers:svgedit.browser.isTouch()?false:true,show_outside_canvas:false,no_save_warning:true,initFont:"Helvetica, Arial, sans-serif"};uiStrings=c.uiStrings={common:{ok:"OK",cancel:"Cancel",key_up:"Up",
key_down:"Down",key_backspace:"Backspace",key_del:"Del"},layers:{layer:"Layer"},notification:{invalidAttrValGiven:"Invalid value given",noContentToFitTo:"No content to fit to",dupeLayerName:"There is already a layer named that!",enterUniqueLayerName:"Please enter a unique layer name",enterNewLayerName:"Please enter the new layer name",layerHasThatName:"Layer already has that name",QmoveElemsToLayer:'Move selected elements to layer "%s"?',QwantToClear:"Do you want to clear the drawing?\nThis will also erase your undo history!",
QwantToOpen:"Do you want to open a new file?\nThis will also erase your undo history!",QerrorsRevertToSource:"There were parsing errors in your SVG source.\nRevert back to original SVG source?",QignoreSourceChanges:"Ignore changes made to SVG source?",featNotSupported:"Feature not supported",enterNewImgURL:"Enter the new image URL",defsFailOnSave:"NOTE: Due to a bug in your browser, this image may appear wrong (missing gradients or elements). It will however appear correct once actually saved.",loadingImage:"Loading image, please wait...",
saveFromBrowser:'Select "Save As..." in your browser to save this image as a %s file.',noteTheseIssues:"Also note the following issues: ",unsavedChanges:"There are unsaved changes.",enterNewLinkURL:"Enter the new hyperlink URL",errorLoadingSVG:"Error: Unable to load SVG data",URLloadFail:"Unable to load from URL",retrieving:'Retrieving "%s" ...'}};var s={},b={};c.curConfig=curConfig;c.tool_scale=1;c.setConfig=function(d){a.extend(true,curConfig,d);if(d.extensions)curConfig.extensions=d.extensions};
c.setCustomHandlers=function(d){c.ready(function(){if(d.open){a('#tool_open > input[type="file"]').remove();a("#tool_open").show();g.open=d.open}if(d.save){c.show_save_warning=false;g.bind("saved",d.save)}d.pngsave&&g.bind("exported",d.pngsave);b=d})};c.randomizeIds=function(){g.randomizeIds(arguments)};c.init=function(){function d(k,u){var C=k.id,E=C.split("_"),P=E[0];E=E[1];u&&g.setStrokeAttr("stroke-"+P,E);qb();xb("#cur_"+P,C,20);a(k).addClass("current").siblings().removeClass("current")}function l(k,
u){var C=document.getElementById("ruler_x_cursor"),E=document.getElementById("ruler_y_cursor"),P=document.getElementById("workarea");document.getElementById("title_show");svgedit.browser.isTouch()&&a("#workarea").unbind("mousemove.rulers").bind("mousemove.rulers",function(Sb){Sb.stopPropagation();C.style.left=Sb.pageX-66+P.scrollLeft+"px";E.style.top=Sb.pageY-48+P.scrollTop+"px"});u||(u=g.getZoom());k||(k=a("#svgcanvas"));for(var U=g.getContentElem(),S=svgedit.units.getTypeMap()[curConfig.baseUnit],
X=0;X<2;X++){var aa=X===0,ga=aa?"x":"y",ra=aa?"width":"height",Ta=U.getAttribute(ga)-0;ga=a("#ruler_"+ga+" canvas:first");$hcanv=ga.clone();ga.replaceWith($hcanv);var Ba=$hcanv[0];var ha=ga=k[ra]()*2;Ba.parentNode.style[ra]=ha+"px";var Sa=0,Qa,ua=Ba.getContext("2d");ua.fillStyle="rgb(200,0,0)";ua.fillRect(0,0,Ba.width,Ba.height);$hcanv.siblings().remove();if(ga>=3E4){var Ma=parseInt(ga/3E4)+1;Qa=Array(Ma);Qa[0]=ua;for(var xa=1;xa<Ma;xa++){Ba[ra]=3E4;var ab=Ba.cloneNode(true);Ba.parentNode.appendChild(ab);
Qa[xa]=ab.getContext("2d")}ab[ra]=ga%3E4;ga=3E4}Ba[ra]=ga;ra=S*u;var Wa=50/ra;Ba=1;for(xa=0;xa<I.length;xa++){Ba=Ma=I[xa];if(Wa<=Ma)break}Wa=Ba*ra;ua.font="normal 9px 'Lucida Grande', sans-serif";ua.fillStyle="#777";for(var cb=Ta/ra%Ba*ra,Hb=cb-Wa;cb<ha;cb+=Wa){Hb+=Wa;xa=Math.round(cb)+0.5;if(aa){ua.moveTo(xa,15);ua.lineTo(xa,0)}else{ua.moveTo(15,xa);ua.lineTo(0,xa)}Ma=(Hb-Ta)/ra;if(Ba>=1)xa=Math.round(Ma);else{xa=(Ba+"").split(".")[1].length;xa=Ma.toFixed(xa)-0}if(xa!==0&&xa!==1E3&&xa%1E3===0)xa=
xa/1E3+"K";if(aa){ua.fillText(xa,cb+2,8);ua.fillStyle="#777"}else{Ma=(xa+"").split("");for(xa=0;xa<Ma.length;xa++){ua.fillText(Ma[xa],1,cb+9+xa*9);ua.fillStyle="#777"}}Ma=Wa/10;for(xa=1;xa<10;xa++){var yb=Math.round(cb+Ma*xa)+0.5;if(Qa&&yb>ga){Sa++;ua.stroke();if(Sa>=Qa.length){xa=10;cb=ha;continue}ua=Qa[Sa];cb-=3E4;yb=Math.round(cb+Ma*xa)+0.5}var Gb=xa%2?12:10;if(aa){ua.moveTo(yb,15);ua.lineTo(yb,Gb)}else{ua.moveTo(15,yb);ua.lineTo(Gb,yb)}}}ua.strokeStyle="#666";ua.stroke()}}(function(){var k=window.opener;
c.setCustomHandlers=function(d){c.ready(function(){if(d.open){a('#tool_open > input[type="file"]').remove();a("#tool_open").show();g.open=d.open}if(d.save){c.show_save_warning=false;g.bind("saved",d.save)}d.pngsave&&g.bind("exported",d.pngsave);b=d})};c.randomizeIds=function(){g.randomizeIds(arguments)};c.init=function(){function d(k,u){var C=k.id,D=C.split("_"),P=D[0];D=D[1];u&&g.setStrokeAttr("stroke-"+P,D);qb();yb("#cur_"+P,C,20);a(k).addClass("current").siblings().removeClass("current")}function l(k,
u){var C=document.getElementById("ruler_x_cursor"),D=document.getElementById("ruler_y_cursor"),P=document.getElementById("workarea");document.getElementById("title_show");svgedit.browser.isTouch()&&a("#workarea").unbind("mousemove.rulers").bind("mousemove.rulers",function(Sb){Sb.stopPropagation();C.style.left=Sb.pageX-66+P.scrollLeft+"px";D.style.top=Sb.pageY-48+P.scrollTop+"px"});u||(u=g.getZoom());k||(k=a("#svgcanvas"));for(var U=g.getContentElem(),S=svgedit.units.getTypeMap()[curConfig.baseUnit],
Y=0;Y<2;Y++){var aa=Y===0,ga=aa?"x":"y",ra=aa?"width":"height",Oa=U.getAttribute(ga)-0;ga=a("#ruler_"+ga+" canvas:first");$hcanv=ga.clone();ga.replaceWith($hcanv);var Ba=$hcanv[0];var ha=ga=k[ra]()*2;Ba.parentNode.style[ra]=ha+"px";var Ta=0,Ra,ta=Ba.getContext("2d");ta.fillStyle="rgb(200,0,0)";ta.fillRect(0,0,Ba.width,Ba.height);$hcanv.siblings().remove();if(ga>=3E4){var Ma=parseInt(ga/3E4)+1;Ra=Array(Ma);Ra[0]=ta;for(var xa=1;xa<Ma;xa++){Ba[ra]=3E4;var ab=Ba.cloneNode(true);Ba.parentNode.appendChild(ab);
Ra[xa]=ab.getContext("2d")}ab[ra]=ga%3E4;ga=3E4}Ba[ra]=ga;ra=S*u;var Xa=50/ra;Ba=1;for(xa=0;xa<I.length;xa++){Ba=Ma=I[xa];if(Xa<=Ma)break}Xa=Ba*ra;ta.font="normal 9px 'Lucida Grande', sans-serif";ta.fillStyle="#777";for(var cb=Oa/ra%Ba*ra,Hb=cb-Xa;cb<ha;cb+=Xa){Hb+=Xa;xa=Math.round(cb)+0.5;if(aa){ta.moveTo(xa,15);ta.lineTo(xa,0)}else{ta.moveTo(15,xa);ta.lineTo(0,xa)}Ma=(Hb-Oa)/ra;if(Ba>=1)xa=Math.round(Ma);else{xa=(Ba+"").split(".")[1].length;xa=Ma.toFixed(xa)-0}if(xa!==0&&xa!==1E3&&xa%1E3===0)xa=
xa/1E3+"K";if(aa){ta.fillText(xa,cb+2,8);ta.fillStyle="#777"}else{Ma=(xa+"").split("");for(xa=0;xa<Ma.length;xa++){ta.fillText(Ma[xa],1,cb+9+xa*9);ta.fillStyle="#777"}}Ma=Xa/10;for(xa=1;xa<10;xa++){var zb=Math.round(cb+Ma*xa)+0.5;if(Ra&&zb>ga){Ta++;ta.stroke();if(Ta>=Ra.length){xa=10;cb=ha;continue}ta=Ra[Ta];cb-=3E4;zb=Math.round(cb+Ma*xa)+0.5}var Gb=xa%2?12:10;if(aa){ta.moveTo(zb,15);ta.lineTo(zb,Gb)}else{ta.moveTo(15,zb);ta.lineTo(Gb,zb)}}}ta.strokeStyle="#666";ta.stroke()}}(function(){var k=window.opener;
if(k)try{var u=k.document.createEvent("Event");u.initEvent("svgEditorReady",true,true);k.document.documentElement.dispatchEvent(u)}catch(C){}})();(function(){a("#canvas_width").val(curConfig.dimensions[0]);a("#canvas_height").val(curConfig.dimensions[1]);a("body").toggleClass("touch",svgedit.browser.isTouch());var k=a.deparam.querystring(true);if(!a.isEmptyObject(k)){if(k.dimensions)k.dimensions=k.dimensions.split(",");if(k.extensions)k.extensions=k.extensions.split(",");if(k.bkgd_color)k.bkgd_color=
"#"+k.bkgd_color;svgEditor.setConfig(k);var u=k.source,C=a.param.querystring();if(!u)if(C.indexOf("source=data:")>=0)u=C.match(/source=(data:[^&]*)/)[1];if(u)if(u.indexOf("data:")===0){u=u.replace(/ /g,"+");c.loadFromDataURI(u)}else c.loadFromString(u);else if(C.indexOf("paramurl=")!==-1)svgEditor.loadFromURL(C.substr(9));else k.url&&svgEditor.loadFromURL(k.url)}})();var q=function(){a.each(curConfig.extensions,function(){var k=this;a.getScript(curConfig.extPath+k,function(u){if(!u){u=document.createElement("script");
u.src=curConfig.extPath+k;document.querySelector("head").appendChild(u)}})})};document.location.protocol==="file:"?setTimeout(q,100):q();a.svgIcons(curConfig.imgPath+"svg_edit_icons.svg",{w:27,h:27,id_match:false,no_img:!svgedit.browser.isWebkit(),fallback_path:curConfig.imgPath,fallback:{logo:"logo.png",select:"select.png",select_node:"select_node.png",pencil:"pencil.png",pen:"line.png",square:"square.png",rect:"square.png",fh_rect:"freehand-square.png",circle:"circle.png",ellipse:"ellipse.png",
fh_ellipse:"freehand-circle.png",path:"path.png",text:"text.png",image:"image.png",zoom:"zoom.png","delete":"delete.png",spapelib:"shapelib.png",node_delete:"node_delete.png",align_left:"align-left.png",align_center:"align-center",align_right:"align-right",align_top:"align-top",align_middle:"align-middle",align_bottom:"align-bottom",arrow_right:"flyouth.png",arrow_down:"dropdown.gif"},placement:{"#logo":"logo","#tool_select":"select","#tool_fhpath":"pencil","#tool_line":"pen","#tool_rect,#tools_rect_show":"rect",
"#tool_square":"square","#tool_fhrect":"fh_rect","#tool_ellipse,#tools_ellipse_show":"ellipse","#tool_circle":"circle","#tool_fhellipse":"fh_ellipse","#tool_path":"path","#tool_text,#layer_rename":"text","#tool_image":"image","#tool_zoom":"zoom","#tool_node_clone":"node_clone","#tool_node_delete":"node_delete","#tool_add_subpath":"add_subpath","#tool_openclose_path":"open_path","#tool_alignleft, #tool_posleft":"align_left","#tool_aligncenter, #tool_poscenter":"align_center","#tool_alignright, #tool_posright":"align_right",
"#tool_aligntop, #tool_postop":"align_top","#tool_alignmiddle, #tool_posmiddle":"align_middle","#tool_alignbottom, #tool_posbottom":"align_bottom","#cur_position":"align","#zoomLabel":"zoom","#palette .palette_item:first, #fill_bg, #stroke_bg":"no_color"},resize:{"#logo .svg_icon":15,".flyout_arrow_horiz .svg_icon":5,"#fill_bg .svg_icon, #stroke_bg .svg_icon":svgedit.browser.isTouch()?24:24,".palette_item:first .svg_icon":svgedit.browser.isTouch()?30:16,"#zoomLabel .svg_icon":16,"#zoom_dropdown .svg_icon":7},
callback:function(){a(".toolbar_button button > svg, .toolbar_button button > img").each(function(){a(this).parent().prepend(this)});a(".tool_button, .tool_button_current").addClass("loaded");var k=a("#tools_left");if(k.length!=0){k.offset();k.outerHeight()}a(".tools_flyout").each(function(){var u=a("#"+this.id+"_show"),C=u.attr("data-curopt");if(!u.children("svg, img").length){C=a(C).children().clone();if(C.length){C[0].removeAttribute("style");u.append(C)}}});svgEditor.runCallbacks();setTimeout(function(){a(".flyout_arrow_horiz:empty").each(function(){a(this).append(a.getSvgIcon("arrow_right").width(5).height(5))})},
1)}});a("#rulers").on("dblclick",function(k){a("#base_unit_container").css({top:k.pageY-10,left:k.pageX-50,display:"block"})});a("#base_unit_container").on("mouseleave mouseenter",function(){t=setTimeout(function(){a("#base_unit_container").fadeOut(500)},200);event.type=="mouseover"&&clearTimeout(t)});a("#base_unit").on("change",function(){savePreferences()});c.canvas=g=new a.SvgCanvas(document.getElementById("svgcanvas"),curConfig);c.show_save_warning=false;c.paintBox={fill:null,stroke:null,canvas:null};
q=navigator.platform.indexOf("Mac")>=0;var B=navigator.userAgent.indexOf("AppleWebKit")>=0,o=q?"meta+":"ctrl+",K=g.pathActions,T=g.undoMgr,M=svgedit.utilities,J=curConfig.imgPath+"placeholder.svg",Q=a("#workarea"),Y=a("#cmenu_canvas"),O=null,ia=1,pa="toolbars",fa="";q||a(".shortcut").each(function(){var k=a(this).text();a(this).text(k.split("\u2318").join("Ctrl+"))});(function(){a("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"});var k=a("#dialog_box"),
u=a("#dialog_buttons"),C=function(E,P,U,S){a("#dialog_content").html("<p>"+P.replace(/\n/g,"</p><p>")+"</p>").toggleClass("prompt",E=="prompt");u.empty();var X=a('<input type="button" value="'+uiStrings.common.ok+'">').appendTo(u);E!="alert"&&a('<input type="button" value="'+uiStrings.common.cancel+'">').appendTo(u).on("click, touchstart",function(){k.hide();U(false)});if(E=="prompt"){var aa=a('<input type="text">').prependTo(u);aa.val(S||"");aa.bind("keydown","return",function(){X.trigger("click touchstart")})}E==
"process"&&X.hide();k.show();X.on("click touchstart",function(){k.hide();var ga=E=="prompt"?aa.val():true;U&&U(ga)}).focus();E=="prompt"&&aa.focus()};a.alert=function(E,P){C("alert",E,P)};a.confirm=function(E,P){C("confirm",E,P)};a.process_cancel=function(E,P){C("process",E,P)};a.prompt=function(E,P,U){C("prompt",E,U,P)}})();var ba=function(){var k=a(".tool_button_current");if(k.length&&k[0].id!=="tool_select"){k.removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button")}g.setMode("select")},
W=null,sa=false,ka=false,da="",V=function(k,u){var C=g.getResolution();a("#svgcanvas").position();var E=g.setBBoxZoom(u,Q.width()-15,Q.height()-15);if(E){var P=E.zoom;E=E.bbox;if(P<0.0010)wa({value:0.1});else{var U=Date.now(),S=P-C.zoom;a("#zoom");var X=C.zoom,aa=function(ga){ga=(ga-U)/500;ga=Math.pow(ga-1,3)+1;g.setZoom(X+S*ga);F();ga<1?requestAnimationFrame(aa):a("#zoom").val(P*100)};aa(Date.now());g.getMode()=="zoom"&&E.width&&ba();lb()}}};a("#cur_context_panel").delegate("a","click",function(){var k=
a(this);k.attr("data-root")?g.leaveContext():g.setContext(k.text());return false});var Z=function(){c.paintBox.fill.prep();c.paintBox.stroke.prep()},oa={},qa=function(k){a.each(k,function(u,C){var E=a(u).children(),P=u+"_show",U=a(P),S=false;E.addClass("tool_button").unbind("click mousedown mouseup").each(function(ga){var ra=C[ga];oa[ra.sel]=ra.fn;if(ra.isDefault)S=ga;ga=function(Ta){var Ba=ra;if(Ta.type==="keydown"){var ha=a(Ba.parent+"_show").hasClass("tool_button_current"),Sa=a(Ba.parent+"_show").attr("data-curopt");
a.each(k[ra.parent],function(ua,Ma){if(Ma.sel==Sa)Ba=!Ta.shiftKey||!ha?Ma:k[ra.parent][ua+1]||k[ra.parent][0]})}if(a(this).hasClass("disabled"))return false;$a(P)&&Ba.fn();var Qa=Ba.icon?a.getSvgIcon(Ba.icon,true):a(Ba.sel).children().eq(0).clone();Qa[0].setAttribute("width",U.width());Qa[0].setAttribute("height",U.height());U.children(":not(.flyout_arrow_horiz)").remove();U.append(Qa).attr("data-curopt",Ba.sel)};a(this).mouseup(ga);ra.key&&a(document).bind("keydown",ra.key[0]+" shift+"+ra.key[0],
ga)});if(S)U.attr("data-curopt",C[S].sel);else U.attr("data-curopt")||U.attr("data-curopt",C[0].sel);var X,aa=a(P).position();a(u).css({left:aa.left+34,top:aa.top+77});U.mousedown(function(ga){a("#tools_shapelib").is(":visible")&&$a(P,false);if(U.hasClass("disabled"))return false;var ra=a(u),Ta=aa.left+34,Ba=ra.width()*-1,ha=ra.data("shown_popop")?200:0;X=setTimeout(function(){U.data("isLibrary")?ra.css("left",Ta).show():ra.css("left",Ba).show().animate({left:Ta},150);ra.data("shown_popop",true)},
ha);ga.preventDefault()}).mouseup(function(){clearTimeout(X);var ga=a(this).attr("data-curopt");if(U.data("isLibrary")&&a(P.replace("_show","")).is(":visible"))$a(P,true);else $a(P)&&ga in oa&&oa[ga]()})});Aa()},ma=function(k,u){return a("<div>",{"class":"tools_flyout",id:k}).appendTo("#svg_editor").append(u)},na=function(){a(".tools_flyout").each(function(){var k=a("#"+this.id+"_show"),u=k.offset();k=k.outerWidth();a(this).css({left:(u.left+k)*ia,top:u.top})})},Aa=function(){a(".tools_flyout").each(function(){var k=
a("#"+this.id+"_show");if(!k.data("isLibrary")){var u=[];a(this).children().each(function(){u.push(this.title)});k[0].title=u.join(" / ")}})},Fa,Ia=function(k,u,C){var E=null;if(k.indexOf("url(#")===0){k=(k=g.getRefElem(k))?k.cloneNode(true):a("#"+C+"_color defs *")[0];E={alpha:u};E[k.tagName]=k}else E=k.indexOf("#")===0?{alpha:u,solidColor:k.substr(1)}:{alpha:u,solidColor:"none"};return new a.jGraduate.Paint(E)},Ca=g.getResolution();if(curConfig.baseUnit!=="px"){Ca.w=svgedit.units.convertUnit(Ca.w)+
curConfig.baseUnit;Ca.h=svgedit.units.convertUnit(Ca.h)+curConfig.baseUnit}var Ka=function(k){g.createLayer("background");cur_shape=g.addSvgElementFromJson({element:"rect",attr:{x:-1,y:-1,width:Ca.w+2,height:Ca.h+2,stroke:"none",id:"canvas_background",opacity:1,fill:k||"#fff",style:"pointer-events:none"}});g.setCurrentLayer("Layer 1");g.setCurrentLayerPosition("1")};document.getElementById("canvas_background")||Ka();document.getElementById("canvas_background").getAttribute("fill");var Na=c.setImageURL=
function(k){k||(k=J);g.setImageURL(k);a("#image_url").val(k)},za=function(){var k=W;if(k!=null&&!k.parentNode)k=null;if(sa&&sa[0]!=null&&!sa[0].parentNode)sa=false;var u=g.getCurrentDrawing().getCurrentLayerName(),C=g.getMode(),E=curConfig.baseUnit!=="px"?curConfig.baseUnit:null,P=C=="pathedit",U=a("#cmenu_canvas li");a(".context_panel").hide();a(".menu_item","#edit_menu").addClass("disabled");a(".menu_item","#object_menu").addClass("disabled");if(sa)(k=g.elementsAreSame(sa)?sa[0]:null)&&a("#tools_top").addClass("multiselected");
if(!k&&!sa){a("#tools_top").removeClass("multiselected");a("#stroke_panel").hide();a("#canvas_panel").show()}if(k!=null){a("#stroke_panel").show();var S=k.nodeName,X=g.getRotationAngle(k);a("#angle").val(Math.round(X));X=g.getBlur(k);a("#blur").val(X);if(!P&&C!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");var aa,ga;if(["g","polyline","path"].indexOf(S)>=0)if(C=g.getStrokedBBox([k])){aa=C.x;ga=C.y}if(E){aa=svgedit.units.convertUnit(aa);ga=svgedit.units.convertUnit(ga)}a("#"+
S+"_x").val(Math.round(aa));a("#"+S+"_y").val(Math.round(ga));["image","text","path","g","use"].indexOf(S)==-1&&a(".action_path_convert_selected").removeClass("disabled");S==="path"&&a(".action_path_selected").removeClass("disabled")}else{a("#path_node_panel").show();a("#stroke_panel").hide();u=K.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button");a("#tool_node_delete").toggleClass("disabled",!K.canDeleteNodes);xb("#tool_openclose_path",K.closed_subpath?
"open_path":"close_path");if(u){P=a("#seg_type");if(E){u.x=svgedit.units.convertUnit(u.x);u.y=svgedit.units.convertUnit(u.y)}a("#path_node_x").val(Math.round(u.x));a("#path_node_y").val(Math.round(u.y));u.type?P.val(u.type).removeAttr("disabled"):P.val(4).attr("disabled","disabled")}return}E=null;if(ra==="a"){E=g.getHref(k);a("#g_panel").show()}if(k.parentNode.tagName==="a")if(!a(k).siblings().length){a("#a_panel").show();E=g.getHref(k.parentNode)}a("#tool_make_link, #tool_make_link").toggle(!E);
E&&a("#link_url").val(E);E={g:[],a:[],rect:["rx","width","height","x","y"],image:["width","height","x","y"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],text:["x","y"],use:[],path:[]};var ra=k.tagName;a(k).data("gsvg")&&a("#g_panel").show();ra=="path"&&a("#path_panel").show();if(E[ra]){E=E[ra];a("#"+ra+"_panel").show();ra=="rect"?a("#cornerRadiusLabel").show():a("#cornerRadiusLabel").hide();a.each(E,function(Ta,Ba){var ha=k.getAttribute(Ba);if(curConfig.baseUnit!==
"px"&&k[Ba])ha=svgedit.units.convertUnit(k[Ba].baseVal.value);var Sa=document.getElementById(ra+"_"+Ba);Sa.value=Math.round(ha)||0;Sa.getAttribute("data-cursor")==="true"&&a.fn.dragInput.updateCursor(Sa)});if(ra=="text"){a("#text_panel").css("display","inline");g.getItalic()?a("#tool_italic").addClass("push_button_pressed").removeClass("tool_button"):a("#tool_italic").removeClass("push_button_pressed").addClass("tool_button");g.getBold()?a("#tool_bold").addClass("push_button_pressed").removeClass("tool_button"):
a("#tool_bold").removeClass("push_button_pressed").addClass("tool_button");a("#font_family").val(k.getAttribute("font-family"));a("#font_size").val(k.getAttribute("font-size"));a("#text").val(k.textContent);g.addedNew&&setTimeout(function(){a("#text").focus().select()},100)}else if(ra=="image")Na(g.getHref(k));else if(ra==="g"||ra==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");g.getTitle()}}U[(ra==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");U[(ra===
"g"||!sa?"dis":"en")+"ableContextMenuItems"]("#group")}else if(sa){a("#multiselected_panel").show();a(".action_multi_selected").removeClass("disabled");U.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}else U.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");T.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");T.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");
g.addedNew=false;if(k&&!P||sa){a("#selLayerNames").removeAttr("disabled").val(u);Y.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}};a("#text").on("focus",function(){});a("#text").on("blur",function(){});g.bind("selected",function(k,u){var C=g.getMode();C==="select"&&ba();C=C=="pathedit";W=u.length==1||u[1]==null?u[0]:null;sa=u.length>=2&&u[1]!=null?u:false;if(W!=null)if(!C){if(W!=null)switch(W.tagName){case "use":case "image":case "foreignObject":break;case "g":case "a":for(var E=
null,P=W.getElementsByTagName("*"),U=0,S=P.length;U<S;U++){var X=P[U].getAttribute("stroke-width");if(U===0)E=X;else if(E!==X)E=null}a("#stroke_width").val(E===null?"":E);c.paintBox.fill.update(true);c.paintBox.stroke.update(true);break;default:c.paintBox.fill.update(true);c.paintBox.stroke.update(true);a("#stroke_width").val(W.getAttribute("stroke-width")||1);a("#stroke_style").val(W.getAttribute("stroke-dasharray")||"none");E=W.getAttribute("stroke-linejoin")||"miter";a("#linejoin_"+E).length!=
0&&d(a("#linejoin_"+E)[0]);E=W.getAttribute("stroke-linecap")||"butt";a("#linecap_"+E).length!=0&&d(a("#linecap_"+E)[0])}if(W!=null){E=(W.getAttribute("opacity")||1)*100;a("#group_opacity").val(E);a("#opac_slider").slider("option","value",E);a("#elem_id").val(W.id)}}a("#path_node_panel").toggle(C);a("#tools_bottom_2,#tools_bottom_3").toggle(!C);if(C){a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button");
xb("#tool_select","select_node");sa=false;if(u.length)W=u[0]}else{if(u[0]){C=g.selectorManager.requestSelector(u[0]);C.reset(u[0]);C.selectorRect.setAttribute("display","inline")}xb("#tool_select","select")}za();g.runExtensions("selectedChanged",{elems:u,selectedElement:W,multiselected:sa})});g.bind("transition",function(k,u){var C=g.getMode(),E=u[0];if(E){sa=u.length>=2&&u[1]!=null?u:null;if(!sa)switch(C){case "rotate":C=g.getRotationAngle(E);a("#angle").val(Math.round(C));rotateCursor(C);a("#tool_reorient").toggleClass("disabled",
C==0)}g.runExtensions("elementTransition",{elems:u})}});g.bind("changed",function(k,u){var C=g.getMode();C==="select"&&ba();for(var E=0;E<u.length;++E){var P=u[E];if(P&&P.tagName==="svg")F();else if(P&&W&&W.parentNode==null)W=P}c.show_save_warning=true;za();if(W&&C==="select"){c.paintBox.fill.update();c.paintBox.stroke.update()}g.runExtensions("elementChanged",{elems:u})});g.bind("saved",function(k,u){c.show_save_warning=false;u='<?xml version="1.0"?>\n'+u;var C=navigator.userAgent;if(~C.indexOf("Chrome")&&
a.browser.version>=533||~C.indexOf("MSIE"))Qb(0,true);else{var E=k.open("data:image/svg+xml;base64,"+M.encode64(u)),P=a.pref("save_notice_done");if(P!=="all"){var U=uiStrings.notification.saveFromBrowser.replace("%s","SVG");if(C.indexOf("Gecko/")!==-1)if(u.indexOf("<defs")!==-1){U+="\n\n"+uiStrings.notification.defsFailOnSave;a.pref("save_notice_done","all");P="all"}else a.pref("save_notice_done","part");else a.pref("save_notice_done","all");P!=="part"&&E.alert(U)}}});g.bind("exported",function(k,
u){var C=u.issues;a("#export_canvas").length||a("<canvas>",{id:"export_canvas"}).hide().appendTo("body");var E=a("#export_canvas")[0];E.width=g.contentW;E.height=g.contentH;canvg(E,u.svg,{renderCallback:function(){var P=E.toDataURL("image/png");O.location.href=P;if(a.pref("export_notice_done")!=="all"){P=uiStrings.notification.saveFromBrowser.replace("%s","PNG");if(C.length)P+="\n\n"+uiStrings.notification.noteTheseIssues+"\n \u2022 "+C.join("\n \u2022 ");a.pref("export_notice_done","all");O.alert(P)}}})});
g.bind("zoomed",V);g.bind("contextset",function(k,u){var C="";if(u){var E="";C='<a href="#" data-root="y">'+g.getCurrentDrawing().getCurrentLayerName()+"</a>";a(u).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){E+=" > "+this.id;C+=this!==u?' > <a href="#">'+this.id+"</a>":" > "+this.id}});da=E}else da=null;a("#cur_context_panel").toggle(!!u).html(C)});g.bind("extension_added",function(k,u){function C(){if(Fa){clearTimeout(Fa);Fa=null}P||(Fa=setTimeout(function(){P=true;e(s.iconsize)},
50))}var E=false,P=false,U=true,S=function(){if(u.callback&&!E&&U){E=true;u.callback()}},X=[];u.context_tools&&a.each(u.context_tools,function(Ba,ha){var Sa=ha.container_id?' id="'+ha.container_id+'"':"",Qa=a("#"+ha.panel);Qa.length||(Qa=a("<div>",{id:ha.panel}).appendTo("#tools_top").hide());switch(ha.type){case "tool_button":var ua='<div class="tool_button">'+ha.id+"</div>",Ma=a(ua).appendTo(Qa);ha.events&&a.each(ha.events,function(Wa,cb){a(Ma).bind(Wa,cb)});break;case "select":ua="<label"+Sa+'><select id="'+
ha.id+'">';a.each(ha.options,function(Wa,cb){ua+='<option value="'+Wa+'"'+(Wa==ha.defval?" selected":"")+">"+cb+"</option>"});ua+="</select></label>";var xa=a(ua).appendTo(Qa).find("select");a.each(ha.events,function(Wa,cb){a(xa).bind(Wa,cb)});break;case "button-select":ua='<div id="'+ha.id+'" class="dropdown toolset" title="'+ha.title+'"><div id="cur_'+ha.id+'" class="icon_label"></div><button></button></div>';Sa=a('<ul id="'+ha.id+'_opts"></ul>').appendTo("#option_lists");ha.colnum&&Sa.addClass("optcols"+
ha.colnum);a(ua).appendTo(Qa).children();X.push({elem:"#"+ha.id,list:"#"+ha.id+"_opts",title:ha.title,callback:ha.events.change,cur:"#cur_"+ha.id});break;case "input":ua="<label"+Sa+'><span id="'+ha.id+'_label">'+ha.label+':</span><input id="'+ha.id+'" title="'+ha.title+'" size="'+(ha.size||"4")+'" value="'+(ha.defval||"")+'" type="text"/></label>';var ab=a(ua).appendTo(Qa).find("input");ha.spindata&&ab.SpinButton(ha.spindata);ha.events&&a.each(ha.events,function(Wa,cb){ab.bind(Wa,cb)})}});if(u.buttons){var aa=
{},ga={},ra=u.svgicons,Ta={};a.each(u.buttons,function(Ba,ha){for(var Sa,Qa=ha.id,ua=Ba;a("#"+Qa).length;)Qa=ha.id+"_"+ ++ua;if(ra){aa[Qa]=ha.icon;ua=ha.svgicon?ha.svgicon:ha.id;if(ha.type=="app_menu")ga["#"+Qa+" > div"]=ua;else ga["#"+Qa]=ua}else Sa=ha.type=="menu"?"":a('<img src="'+ha.icon+'">');var Ma,xa;switch(ha.type){case "mode_flyout":case "mode":Ma="tool_button";if(ha.cls)Ma+=" "+ha.cls;xa="#tools_left";break;case "context":Ma="tool_button";xa="#"+ha.panel;a(xa).length||a("<div>",{id:ha.panel}).appendTo("#tools_top");
break;case "menu":Ma="menu_item tool_button";xa="#"+(ha.after||ha.panel);break;case "app_menu":Ma="";xa=ha.parent||"#main_menu ul";a(xa).length||a("<div>",{id:ha.panel}).appendTo("#tools_top")}var ab=a(ha.list||ha.type=="app_menu"?"<li/>":"<div/>").attr("id",Qa).attr("title",ha.title).addClass(Ma);if(!ha.includeWith&&!ha.list){if("position"in ha)a(xa).children().eq(ha.position).before(ab);else ha.type!="menu"||!ha.after?ab.appendTo(xa):a(xa).after(ab);if(ha.type=="mode_flyout"){ua=a(ab);Ma=ua.parent();
if(!ua.parent().hasClass("tools_flyout")){var Wa=ua[0].id.replace("tool_","tools_"),cb=ua.clone().attr("id",Wa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));ua.before(cb);Ma=ma(Wa,ua);Ma.data("isLibrary",true);cb.data("isLibrary",true)}ga["#"+Wa+"_show"]=ha.id;Qa=Ta["#"+Ma[0].id]=[{sel:"#"+Qa,fn:ha.events.click,icon:ha.id,isDefault:true},Hb]}else if(ha.type=="app_menu"||ha.type=="menu")ab.append(ha.title)}else if(ha.list){ab.addClass("push_button");a("#"+ha.list+"_opts").append(ab);if(ha.isDefault){a("#cur_"+
ha.list).append(ab.children().clone());ua=ha.svgicon?ha.svgicon:ha.id;ga["#cur_"+ha.list]=ua}}else if(ha.includeWith){xa=ha.includeWith;ua=a(xa.button);Ma=ua.parent();if(!ua.parent().hasClass("tools_flyout")){Wa=ua[0].id.replace("tool_","tools_");cb=ua.clone().attr("id",Wa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));ua.before(cb);Ma=ma(Wa,ua)}var Hb=v.getButtonData(xa.button);if(xa.isDefault)ga["#"+Wa+"_show"]=ha.id;Qa=Ta["#"+Ma[0].id]=[{sel:"#"+Qa,fn:ha.events.click,icon:ha.id,key:ha.key,
isDefault:ha.includeWith?ha.includeWith.isDefault:0},Hb];Wa="position"in xa?xa.position:"last";Hb=Ma.children().length;if(!isNaN(Wa)&&Wa>=0&&Wa<Hb)Ma.children().eq(Wa).before(ab);else{Ma.append(ab);Qa.reverse()}}ra||ab.append(Sa);ha.list||a.each(ha.events,function(yb,Gb){if(yb=="click")if(ha.type=="mode"){ha.includeWith?ab.bind(yb,Gb):ab.bind(yb,function(){$a(ab)&&Gb()});if(ha.key){a(document).bind("keydown",ha.key,Gb);ha.title&&ab.attr("title",ha.title+" ["+ha.key+"]")}}else ab.bind(yb,Gb);else ab.bind(yb,
Gb)});qa(Ta)});a.each(X,function(){Da(this.elem,this.list,this.callback,{seticon:true})});if(ra)U=false;a.svgIcons(ra,{w:27,h:27,id_match:false,no_img:!B,fallback:aa,placement:ga,callback:function(){s.iconsize&&s.iconsize!="m"&&C();U=true;S()}})}S()});g.textActions.setInputElem(a("#text")[0]);var ya='<div class="palette_item" data-rgb="none"></div>';a.each(["#000000","#3f3f3f","#7f7f7f","#bfbfbf","#ffffff","#ff0000","#ff7f00","#ffff00","#7fff00","#00ff00","#00ff7f","#00ffff","#007fff","#0000ff","#7f00ff",
fh_ellipse:"freehand-circle.png",path:"path.png",text:"text.png",image:"image.png",zoom:"zoom.png","delete":"delete.png",spapelib:"shapelib.png",node_delete:"node_delete.png",align_left:"align-left.png",align_center:"align-center.png",align_right:"align-right.png",align_top:"align-top.png",align_middle:"align-middle.png",align_bottom:"align-bottom.png",arrow_right:"flyouth.png",arrow_down:"dropdown.gif"},placement:{"#logo":"logo","#tool_select":"select","#tool_fhpath":"pencil","#tool_line":"pen",
"#tool_rect,#tools_rect_show":"rect","#tool_square":"square","#tool_fhrect":"fh_rect","#tool_ellipse,#tools_ellipse_show":"ellipse","#tool_circle":"circle","#tool_fhellipse":"fh_ellipse","#tool_path":"path","#tool_text,#layer_rename":"text","#tool_image":"image","#tool_zoom":"zoom","#tool_node_clone":"node_clone","#tool_node_delete":"node_delete","#tool_add_subpath":"add_subpath","#tool_openclose_path":"open_path","#tool_alignleft, #tool_posleft":"align_left","#tool_aligncenter, #tool_poscenter":"align_center",
"#tool_alignright, #tool_posright":"align_right","#tool_aligntop, #tool_postop":"align_top","#tool_alignmiddle, #tool_posmiddle":"align_middle","#tool_alignbottom, #tool_posbottom":"align_bottom","#cur_position":"align","#zoomLabel":"zoom","#palette .palette_item:first, #fill_bg, #stroke_bg":"no_color"},resize:{"#logo .svg_icon":15,".flyout_arrow_horiz .svg_icon":5,"#fill_bg .svg_icon, #stroke_bg .svg_icon":svgedit.browser.isTouch()?24:24,".palette_item:first .svg_icon":svgedit.browser.isTouch()?
30:16,"#zoomLabel .svg_icon":16,"#zoom_dropdown .svg_icon":7},callback:function(){a(".toolbar_button button > svg, .toolbar_button button > img").each(function(){a(this).parent().prepend(this)});a(".tool_button, .tool_button_current").addClass("loaded");var k=a("#tools_left");if(k.length!=0){k.offset();k.outerHeight()}a(".tools_flyout").each(function(){var u=a("#"+this.id+"_show"),C=u.attr("data-curopt");if(!u.children("svg, img").length){C=a(C).children().clone();if(C.length){C[0].removeAttribute("style");
u.append(C)}}});svgEditor.runCallbacks();setTimeout(function(){a(".flyout_arrow_horiz:empty").each(function(){a(this).append(a.getSvgIcon("arrow_right").width(5).height(5))})},1)}});a("#rulers").on("dblclick",function(k){a("#base_unit_container").css({top:k.pageY-10,left:k.pageX-50,display:"block"})});a("#base_unit_container").on("mouseleave mouseenter",function(){t=setTimeout(function(){a("#base_unit_container").fadeOut(500)},200);event.type=="mouseover"&&clearTimeout(t)});a("#base_unit").on("change",
function(){savePreferences()});c.canvas=g=new a.SvgCanvas(document.getElementById("svgcanvas"),curConfig);c.show_save_warning=false;c.paintBox={fill:null,stroke:null,canvas:null};q=navigator.platform.indexOf("Mac")>=0;var B=navigator.userAgent.indexOf("AppleWebKit")>=0,o=q?"meta+":"ctrl+",K=g.pathActions,T=g.undoMgr,M=svgedit.utilities,J=curConfig.imgPath+"placeholder.svg",Q=a("#workarea"),X=a("#cmenu_canvas"),O=null,ia=1,pa="toolbars",fa="";q||a(".shortcut").each(function(){var k=a(this).text();
a(this).text(k.split("\u2318").join("Ctrl+"))});(function(){a("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"});var k=a("#dialog_box"),u=a("#dialog_buttons"),C=function(D,P,U,S){a("#dialog_content").html("<p>"+P.replace(/\n/g,"</p><p>")+"</p>").toggleClass("prompt",D=="prompt");u.empty();var Y=a('<input type="button" value="'+uiStrings.common.ok+'">').appendTo(u);D!="alert"&&a('<input type="button" value="'+uiStrings.common.cancel+'">').appendTo(u).on("click, touchstart",
function(){k.hide();U(false)});if(D=="prompt"){var aa=a('<input type="text">').prependTo(u);aa.val(S||"");aa.bind("keydown","return",function(){Y.trigger("click touchstart")})}D=="process"&&Y.hide();k.show();Y.on("click touchstart",function(){k.hide();var ga=D=="prompt"?aa.val():true;U&&U(ga)}).focus();D=="prompt"&&aa.focus()};a.alert=function(D,P){C("alert",D,P)};a.confirm=function(D,P){C("confirm",D,P)};a.process_cancel=function(D,P){C("process",D,P)};a.prompt=function(D,P,U){C("prompt",D,U,P)}})();
var ba=function(){var k=a(".tool_button_current");if(k.length&&k[0].id!=="tool_select"){k.removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button")}g.setMode("select")},W=null,sa=false,ka=false,da="",V=function(k,u){var C=g.getResolution();a("#svgcanvas").position();var D=g.setBBoxZoom(u,Q.width()-15,Q.height()-15);if(D){var P=D.zoom;D=D.bbox;if(P<0.0010)wa({value:0.1});else{var U=Date.now(),S=P-C.zoom;a("#zoom");var Y=
C.zoom,aa=function(ga){ga=(ga-U)/500;ga=Math.pow(ga-1,3)+1;g.setZoom(Y+S*ga);F();ga<1?requestAnimationFrame(aa):a("#zoom").val(P*100)};aa(Date.now());g.getMode()=="zoom"&&D.width&&ba();lb()}}};a("#cur_context_panel").delegate("a","click",function(){var k=a(this);k.attr("data-root")?g.leaveContext():g.setContext(k.text());return false});var Z=function(){c.paintBox.fill.prep();c.paintBox.stroke.prep()},oa={},qa=function(k){a.each(k,function(u,C){var D=a(u).children(),P=u+"_show",U=a(P),S=false;D.addClass("tool_button").unbind("click mousedown mouseup").each(function(ga){var ra=
C[ga];oa[ra.sel]=ra.fn;if(ra.isDefault)S=ga;ga=function(Oa){var Ba=ra;if(Oa.type==="keydown"){var ha=a(Ba.parent+"_show").hasClass("tool_button_current"),Ta=a(Ba.parent+"_show").attr("data-curopt");a.each(k[ra.parent],function(ta,Ma){if(Ma.sel==Ta)Ba=!Oa.shiftKey||!ha?Ma:k[ra.parent][ta+1]||k[ra.parent][0]})}if(a(this).hasClass("disabled"))return false;$a(P)&&Ba.fn();var Ra=Ba.icon?a.getSvgIcon(Ba.icon,true):a(Ba.sel).children().eq(0).clone();Ra[0].setAttribute("width",U.width());Ra[0].setAttribute("height",
U.height());U.children(":not(.flyout_arrow_horiz)").remove();U.append(Ra).attr("data-curopt",Ba.sel)};a(this).mouseup(ga);ra.key&&a(document).bind("keydown",ra.key[0]+" shift+"+ra.key[0],ga)});if(S)U.attr("data-curopt",C[S].sel);else U.attr("data-curopt")||U.attr("data-curopt",C[0].sel);var Y,aa=a(P).position();a(u).css({left:aa.left+34,top:aa.top+77});U.mousedown(function(ga){a("#tools_shapelib").is(":visible")&&$a(P,false);if(U.hasClass("disabled"))return false;var ra=a(u),Oa=aa.left+34,Ba=ra.width()*
-1,ha=ra.data("shown_popop")?200:0;Y=setTimeout(function(){U.data("isLibrary")?ra.css("left",Oa).show():ra.css("left",Ba).show().animate({left:Oa},150);ra.data("shown_popop",true)},ha);ga.preventDefault()}).mouseup(function(){clearTimeout(Y);var ga=a(this).attr("data-curopt");if(U.data("isLibrary")&&a(P.replace("_show","")).is(":visible"))$a(P,true);else $a(P)&&ga in oa&&oa[ga]()})});Aa()},ma=function(k,u){return a("<div>",{"class":"tools_flyout",id:k}).appendTo("#svg_editor").append(u)},na=function(){a(".tools_flyout").each(function(){var k=
a("#"+this.id+"_show"),u=k.offset();k=k.outerWidth();a(this).css({left:(u.left+k)*ia,top:u.top})})},Aa=function(){a(".tools_flyout").each(function(){var k=a("#"+this.id+"_show");if(!k.data("isLibrary")){var u=[];a(this).children().each(function(){u.push(this.title)});k[0].title=u.join(" / ")}})},Fa,Ia=function(k,u,C){var D=null;if(k.indexOf("url(#")===0){k=(k=g.getRefElem(k))?k.cloneNode(true):a("#"+C+"_color defs *")[0];D={alpha:u};D[k.tagName]=k}else D=k.indexOf("#")===0?{alpha:u,solidColor:k.substr(1)}:
{alpha:u,solidColor:"none"};return new a.jGraduate.Paint(D)},Ca=g.getResolution();if(curConfig.baseUnit!=="px"){Ca.w=svgedit.units.convertUnit(Ca.w)+curConfig.baseUnit;Ca.h=svgedit.units.convertUnit(Ca.h)+curConfig.baseUnit}var Ka=function(k){g.createLayer("background");cur_shape=g.addSvgElementFromJson({element:"rect",attr:{x:-1,y:-1,width:Ca.w+2,height:Ca.h+2,stroke:"none",id:"canvas_background",opacity:1,fill:k||"#fff",style:"pointer-events:none"}});g.setCurrentLayer("Layer 1");g.setCurrentLayerPosition("1")};
document.getElementById("canvas_background")||Ka();document.getElementById("canvas_background").getAttribute("fill");var Na=c.setImageURL=function(k){k||(k=J);g.setImageURL(k);a("#image_url").val(k)},za=function(){var k=W;if(k!=null&&!k.parentNode)k=null;if(sa&&sa[0]!=null&&!sa[0].parentNode)sa=false;var u=g.getCurrentDrawing().getCurrentLayerName(),C=g.getMode(),D=curConfig.baseUnit!=="px"?curConfig.baseUnit:null,P=C=="pathedit",U=a("#cmenu_canvas li");a(".context_panel").hide();a(".menu_item","#edit_menu").addClass("disabled");
a(".menu_item","#object_menu").addClass("disabled");if(sa){sa=sa.filter(Boolean);(k=g.elementsAreSame(sa)?sa[0]:null)&&a("#tools_top").addClass("multiselected")}if(!k&&!sa){a("#tools_top").removeClass("multiselected");a("#stroke_panel").hide();a("#canvas_panel").show()}if(k!=null){a("#stroke_panel").show();var S=k.nodeName,Y=g.getRotationAngle(k);a("#angle").val(Math.round(Y));Y=g.getBlur(k);a("#blur").val(Y);if(!P&&C!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");
var aa,ga;if(["g","polyline","path"].indexOf(S)>=0)if(C=g.getStrokedBBox([k])){aa=C.x;ga=C.y}if(D){aa=svgedit.units.convertUnit(aa);ga=svgedit.units.convertUnit(ga)}a("#"+S+"_x").val(Math.round(aa));a("#"+S+"_y").val(Math.round(ga));["image","text","path","g","use"].indexOf(S)==-1&&a(".action_path_convert_selected").removeClass("disabled");S==="path"&&a(".action_path_selected").removeClass("disabled")}else{a("#path_node_panel").show();a("#stroke_panel").hide();u=K.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button");
a("#tool_node_delete").toggleClass("disabled",!K.canDeleteNodes);yb("#tool_openclose_path",K.closed_subpath?"open_path":"close_path");if(u){P=a("#seg_type");if(D){u.x=svgedit.units.convertUnit(u.x);u.y=svgedit.units.convertUnit(u.y)}a("#path_node_x").val(Math.round(u.x));a("#path_node_y").val(Math.round(u.y));u.type?P.val(u.type).removeAttr("disabled"):P.val(4).attr("disabled","disabled")}return}D=null;if(ra==="a"){D=g.getHref(k);a("#g_panel").show()}if(k.parentNode.tagName==="a")if(!a(k).siblings().length){a("#a_panel").show();
D=g.getHref(k.parentNode)}a("#tool_make_link, #tool_make_link").toggle(!D);D&&a("#link_url").val(D);D={g:[],a:[],rect:["rx","width","height","x","y"],image:["width","height","x","y"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],text:["x","y"],use:[],path:[]};var ra=k.tagName;a(k).data("gsvg")&&a("#g_panel").show();ra=="path"&&a("#path_panel").show();if(D[ra]){D=D[ra];a("#"+ra+"_panel").show();ra=="rect"?a("#cornerRadiusLabel").show():a("#cornerRadiusLabel").hide();
a.each(D,function(Oa,Ba){var ha=k.getAttribute(Ba);if(curConfig.baseUnit!=="px"&&k[Ba])ha=svgedit.units.convertUnit(k[Ba].baseVal.value);var Ta=document.getElementById(ra+"_"+Ba);Ta.value=Math.round(ha)||0;Ta.getAttribute("data-cursor")==="true"&&a.fn.dragInput.updateCursor(Ta)});if(ra=="text"){D=k.getAttribute("font-family");document.getElementById("font_family_dropdown").selectedIndex=3;a("#text_panel").css("display","inline");a("#tool_italic").toggleClass("active",g.getItalic());a("#tool_bold").toggleClass("active",
g.getBold());a("#font_family").val(D);a("#font_size").val(k.getAttribute("font-size"));a("#text").val(k.textContent);g.addedNew&&setTimeout(function(){a("#text").focus().select()},100)}else if(ra=="image")Na(g.getHref(k));else if(ra==="g"||ra==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");g.getTitle()}}U[(ra==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");U[(ra==="g"||!sa?"dis":"en")+"ableContextMenuItems"]("#group")}else if(sa){a("#multiselected_panel").show();
a(".action_multi_selected").removeClass("disabled");U.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}else U.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");T.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");T.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");g.addedNew=false;if(k&&!P||sa){a("#selLayerNames").removeAttr("disabled").val(u);
X.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}};a("#text").on("focus",function(){});a("#text").on("blur",function(){});g.bind("selected",function(k,u){var C=g.getMode();C==="select"&&ba();C=C=="pathedit";W=u.length==1||u[1]==null?u[0]:null;sa=u.length>=2&&u[1]!=null?u:false;if(W!=null)if(!C){if(W!=null)switch(W.tagName){case "use":case "image":case "foreignObject":break;case "g":case "a":for(var D=null,P=W.getElementsByTagName("*"),U=0,S=P.length;U<S;U++){var Y=
P[U].getAttribute("stroke-width");if(U===0)D=Y;else if(D!==Y)D=null}a("#stroke_width").val(D===null?"":D);c.paintBox.fill.update(true);c.paintBox.stroke.update(true);break;default:c.paintBox.fill.update(true);c.paintBox.stroke.update(true);a("#stroke_width").val(W.getAttribute("stroke-width")||1);a("#stroke_style").val(W.getAttribute("stroke-dasharray")||"none");D=W.getAttribute("stroke-linejoin")||"miter";a("#linejoin_"+D).length!=0&&d(a("#linejoin_"+D)[0]);D=W.getAttribute("stroke-linecap")||"butt";
a("#linecap_"+D).length!=0&&d(a("#linecap_"+D)[0])}if(W!=null){D=(W.getAttribute("opacity")||1)*100;a("#group_opacity").val(D);a("#opac_slider").slider("option","value",D);a("#elem_id").val(W.id)}}a("#path_node_panel").toggle(C);a("#tools_bottom_2,#tools_bottom_3").toggle(!C);if(C){a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button");yb("#tool_select","select_node");sa=false;if(u.length)W=
u[0]}else{if(u[0]){C=g.selectorManager.requestSelector(u[0]);C.reset(u[0]);C.selectorRect.setAttribute("display","inline")}yb("#tool_select","select")}za();g.runExtensions("selectedChanged",{elems:u,selectedElement:W,multiselected:sa})});g.bind("transition",function(k,u){var C=g.getMode(),D=u[0];if(D){sa=u.length>=2&&u[1]!=null?u:null;if(!sa)switch(C){case "rotate":C=g.getRotationAngle(D);a("#angle").val(Math.round(C));rotateCursor(C);a("#tool_reorient").toggleClass("disabled",C==0)}g.runExtensions("elementTransition",
{elems:u})}});g.bind("changed",function(k,u){var C=g.getMode();C==="select"&&ba();for(var D=0;D<u.length;++D){var P=u[D];if(P&&P.tagName==="svg")F();else if(P&&W&&W.parentNode==null)W=P}c.show_save_warning=true;za();if(W&&C==="select"){c.paintBox.fill.update();c.paintBox.stroke.update()}g.runExtensions("elementChanged",{elems:u})});g.bind("saved",function(k,u){c.show_save_warning=false;u='<?xml version="1.0"?>\n'+u;var C=navigator.userAgent;if(~C.indexOf("Chrome")&&a.browser.version>=533||~C.indexOf("MSIE"))Qb(0,
true);else{var D=k.open("data:image/svg+xml;base64,"+M.encode64(u)),P=a.pref("save_notice_done");if(P!=="all"){var U=uiStrings.notification.saveFromBrowser.replace("%s","SVG");if(C.indexOf("Gecko/")!==-1)if(u.indexOf("<defs")!==-1){U+="\n\n"+uiStrings.notification.defsFailOnSave;a.pref("save_notice_done","all");P="all"}else a.pref("save_notice_done","part");else a.pref("save_notice_done","all");P!=="part"&&D.alert(U)}}});g.bind("exported",function(k,u){var C=u.issues;a("#export_canvas").length||a("<canvas>",
{id:"export_canvas"}).hide().appendTo("body");var D=a("#export_canvas")[0];D.width=g.contentW;D.height=g.contentH;canvg(D,u.svg,{renderCallback:function(){var P=D.toDataURL("image/png");O.location.href=P;if(a.pref("export_notice_done")!=="all"){P=uiStrings.notification.saveFromBrowser.replace("%s","PNG");if(C.length)P+="\n\n"+uiStrings.notification.noteTheseIssues+"\n \u2022 "+C.join("\n \u2022 ");a.pref("export_notice_done","all");O.alert(P)}}})});g.bind("zoomed",V);g.bind("contextset",function(k,
u){var C="";if(u){var D="";C='<a href="#" data-root="y">'+g.getCurrentDrawing().getCurrentLayerName()+"</a>";a(u).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){D+=" > "+this.id;C+=this!==u?' > <a href="#">'+this.id+"</a>":" > "+this.id}});da=D}else da=null;a("#cur_context_panel").toggle(!!u).html(C)});g.bind("extension_added",function(k,u){function C(){if(Fa){clearTimeout(Fa);Fa=null}P||(Fa=setTimeout(function(){P=true;e(s.iconsize)},50))}var D=false,P=false,U=true,S=function(){if(u.callback&&
!D&&U){D=true;u.callback()}},Y=[];u.context_tools&&a.each(u.context_tools,function(Ba,ha){var Ta=ha.container_id?' id="'+ha.container_id+'"':"",Ra=a("#"+ha.panel);Ra.length||(Ra=a("<div>",{id:ha.panel}).appendTo("#tools_top").hide());switch(ha.type){case "tool_button":var ta='<div class="tool_button">'+ha.id+"</div>",Ma=a(ta).appendTo(Ra);ha.events&&a.each(ha.events,function(Xa,cb){a(Ma).bind(Xa,cb)});break;case "select":ta="<label"+Ta+'><select id="'+ha.id+'">';a.each(ha.options,function(Xa,cb){ta+=
'<option value="'+Xa+'"'+(Xa==ha.defval?" selected":"")+">"+cb+"</option>"});ta+="</select></label>";var xa=a(ta).appendTo(Ra).find("select");a.each(ha.events,function(Xa,cb){a(xa).bind(Xa,cb)});break;case "button-select":ta='<div id="'+ha.id+'" class="dropdown toolset" title="'+ha.title+'"><div id="cur_'+ha.id+'" class="icon_label"></div><button></button></div>';Ta=a('<ul id="'+ha.id+'_opts"></ul>').appendTo("#option_lists");ha.colnum&&Ta.addClass("optcols"+ha.colnum);a(ta).appendTo(Ra).children();
Y.push({elem:"#"+ha.id,list:"#"+ha.id+"_opts",title:ha.title,callback:ha.events.change,cur:"#cur_"+ha.id});break;case "input":ta="<label"+Ta+'><span id="'+ha.id+'_label">'+ha.label+':</span><input id="'+ha.id+'" title="'+ha.title+'" size="'+(ha.size||"4")+'" value="'+(ha.defval||"")+'" type="text"/></label>';var ab=a(ta).appendTo(Ra).find("input");ha.spindata&&ab.SpinButton(ha.spindata);ha.events&&a.each(ha.events,function(Xa,cb){ab.bind(Xa,cb)})}});if(u.buttons){var aa={},ga={},ra=u.svgicons,Oa=
{};a.each(u.buttons,function(Ba,ha){for(var Ta,Ra=ha.id,ta=Ba;a("#"+Ra).length;)Ra=ha.id+"_"+ ++ta;if(ra){aa[Ra]=ha.icon;ta=ha.svgicon?ha.svgicon:ha.id;console.log(ta);if(ha.type=="app_menu")ga["#"+Ra+" > div"]=ta;else ga["#"+Ra]=ta}else Ta=ha.type=="menu"?"":a('<img src="'+ha.icon+'">');var Ma,xa;switch(ha.type){case "mode_flyout":case "mode":Ma="tool_button";if(ha.cls)Ma+=" "+ha.cls;xa="#tools_left";break;case "context":Ma="tool_button";xa="#"+ha.panel;a(xa).length||a("<div>",{id:ha.panel}).appendTo("#tools_top");
break;case "menu":Ma="menu_item tool_button";xa="#"+(ha.after||ha.panel);break;case "app_menu":Ma="";xa=ha.parent||"#main_menu ul";a(xa).length||a("<div>",{id:ha.panel}).appendTo("#tools_top")}var ab=a(ha.list||ha.type=="app_menu"?"<li/>":"<div/>").attr("id",Ra).attr("title",ha.title).addClass(Ma);if(!ha.includeWith&&!ha.list){if("position"in ha)a(xa).children().eq(ha.position).before(ab);else ha.type!="menu"||!ha.after?ab.appendTo(xa):a(xa).after(ab);if(ha.type=="mode_flyout"){ta=a(ab);Ma=ta.parent();
if(!ta.parent().hasClass("tools_flyout")){var Xa=ta[0].id.replace("tool_","tools_"),cb=ta.clone().attr("id",Xa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));ta.before(cb);Ma=ma(Xa,ta);Ma.data("isLibrary",true);cb.data("isLibrary",true)}ga["#"+Xa+"_show"]=ha.id;Ra=Oa["#"+Ma[0].id]=[{sel:"#"+Ra,fn:ha.events.click,icon:ha.id,isDefault:true},Hb]}else if(ha.type=="app_menu"||ha.type=="menu")ab.append(ha.title)}else if(ha.list){ab.addClass("push_button");a("#"+ha.list+"_opts").append(ab);if(ha.isDefault){a("#cur_"+
ha.list).append(ab.children().clone());ta=ha.svgicon?ha.svgicon:ha.id;ga["#cur_"+ha.list]=ta}}else if(ha.includeWith){xa=ha.includeWith;ta=a(xa.button);Ma=ta.parent();if(!ta.parent().hasClass("tools_flyout")){Xa=ta[0].id.replace("tool_","tools_");cb=ta.clone().attr("id",Xa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));ta.before(cb);Ma=ma(Xa,ta)}var Hb=v.getButtonData(xa.button);if(xa.isDefault)ga["#"+Xa+"_show"]=ha.id;Ra=Oa["#"+Ma[0].id]=[{sel:"#"+Ra,fn:ha.events.click,icon:ha.id,key:ha.key,
isDefault:ha.includeWith?ha.includeWith.isDefault:0},Hb];Xa="position"in xa?xa.position:"last";Hb=Ma.children().length;if(!isNaN(Xa)&&Xa>=0&&Xa<Hb)Ma.children().eq(Xa).before(ab);else{Ma.append(ab);Ra.reverse()}}ra||ab.append(Ta);ha.list||a.each(ha.events,function(zb,Gb){if(zb=="click")if(ha.type=="mode"){ha.includeWith?ab.bind(zb,Gb):ab.bind(zb,function(){$a(ab)&&Gb()});if(ha.key){a(document).bind("keydown",ha.key,Gb);ha.title&&ab.attr("title",ha.title+" ["+ha.key+"]")}}else ab.bind(zb,Gb);else ab.bind(zb,
Gb)});qa(Oa)});a.each(Y,function(){Da(this.elem,this.list,this.callback,{seticon:true})});if(ra)U=false;a.svgIcons(ra,{w:27,h:27,id_match:false,no_img:!B,fallback:aa,placement:ga,callback:function(){s.iconsize&&s.iconsize!="m"&&C();U=true;S()}})}S()});g.textActions.setInputElem(a("#text")[0]);var ya='<div class="palette_item" data-rgb="none"></div>';a.each(["#000000","#3f3f3f","#7f7f7f","#bfbfbf","#ffffff","#ff0000","#ff7f00","#ffff00","#7fff00","#00ff00","#00ff7f","#00ffff","#007fff","#0000ff","#7f00ff",
"#ff00ff","#ff007f","#7f0000","#7f3f00","#7f7f00","#3f7f00","#007f00","#007f3f","#007f7f","#003f7f","#00007f","#3f007f","#7f007f","#7f003f","#ffaaaa","#ffd4aa","#ffffaa","#d4ffaa","#aaffaa","#aaffd4","#aaffff","#aad4ff"],function(k,u){ya+='<div class="palette_item" style="background-color: '+u+';" data-rgb="'+u+'"></div>'});a("#palette").append(ya);var Ha=a("#tool_angle_indicator");a("#tool_reorient");rotateCursor=function(k){k="rotate("+k+"deg)";Ha.css({"-webkit-transform":k,"-moz-transform":k,"-o-transform":k,
"-ms-transform":k,transform:k})};var wa=function(k){var u=k.value/100;if(u<0.0010)k.value=0.1;else{k=g.getZoom();V(window,{width:0,height:0,x:(Q[0].scrollLeft+Q.width()/2)/k,y:(Q[0].scrollTop+Q.height()/2)/k,zoom:u},true)}},qb=function(){window.opera&&a("<p/>").hide().appendTo("body").remove()};a("#stroke_style").change(function(){g.setStrokeAttr("stroke-dasharray",a(this).val());a("#stroke_style_label").html(this.options[this.selectedIndex].text);qb()});a("#seg_type").change(function(){g.setSegType(a(this).val());
a("#seg_type_label").html(this.options[this.selectedIndex].text)});a("select").change(function(){a(this).blur()});a("#font_family").change(function(){g.setFontFamily(this.value)});a("#text").keyup(function(){g.setTextContent(this.value)});changeAttribute=function(k,u){var C=k.getAttribute("data-attr"),E=k.value;if(!svgedit.units.isValidUnit(C,E,W)){a.alert(uiStrings.notification.invalidAttrValGiven);k.value=W.getAttribute(C);return false}u?g.changeSelectedAttributeNoUndo(C,E):g.changeSelectedAttribute(C,
E)};a("#palette").mouseover(function(){var k=a('<input type="hidden">');a(this).append(k);k.focus().remove()});a(".palette_item").on("mousedown touchstart touchmove",function(){var k=a("#tool_stroke").hasClass("active"),u=k?"stroke":"fill",C=a(this).attr("data-rgb"),E=null;if(C==="transparent"||C==="initial"||C==="#none"){C="none";E=new a.jGraduate.Paint}else E=new a.jGraduate.Paint({alpha:100,solidColor:C.substr(1)});c.paintBox[u].setPaint(E);if(k){g.setColor("stroke",C);C!="none"&&g.getStrokeOpacity()!=
a("#seg_type_label").html(this.options[this.selectedIndex].text)});a("select").change(function(){a(this).blur()});a("#font_family").change(function(){g.setFontFamily(this.value)});a("#text").keyup(function(){g.setTextContent(this.value)});changeAttribute=function(k,u){var C=k.getAttribute("data-attr"),D=k.value;if(!svgedit.units.isValidUnit(C,D,W)){a.alert(uiStrings.notification.invalidAttrValGiven);k.value=W.getAttribute(C);return false}u?g.changeSelectedAttributeNoUndo(C,D):g.changeSelectedAttribute(C,
D)};a("#palette").mouseover(function(){var k=a('<input type="hidden">');a(this).append(k);k.focus().remove()});a(".palette_item").on("mousedown touchstart touchmove",function(){var k=a("#tool_stroke").hasClass("active"),u=k?"stroke":"fill",C=a(this).attr("data-rgb"),D=null;if(C==="transparent"||C==="initial"||C==="#none"){C="none";D=new a.jGraduate.Paint}else D=new a.jGraduate.Paint({alpha:100,solidColor:C.substr(1)});c.paintBox[u].setPaint(D);if(k){g.setColor("stroke",C);C!="none"&&g.getStrokeOpacity()!=
1&&g.setPaintOpacity("stroke",1)}else{g.setColor("fill",C);C!="none"&&g.getFillOpacity()!=1&&g.setPaintOpacity("fill",1)}}).bind("contextmenu",function(k){k.preventDefault()});a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display","table-cell");a(this).addClass("expanded");z()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");z()});var $a=function(k,u){if(a(k).hasClass("disabled"))return false;if(a(k).parent().hasClass("tools_flyout"))return true;
var C=C||"normal";u||a(".tools_flyout").fadeOut(C);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(k).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var k=null,u=null,C=Q[0],E=false,P=false;a("#svgcanvas").bind("mousemove mouseup touchend",function(U){if(E!==false){C.scrollLeft-=U.clientX-k;C.scrollTop-=U.clientY-u;k=U.clientX;u=U.clientY;if(U.type==="mouseup"||U.type==="touchend")E=false;return false}}).on("mousedown touchmove",
function(U){if(U.button===1||P===true||U.originalEvent.touches&&U.originalEvent.touches.length>=2){E=true;k=U.clientX;u=U.clientY;return false}});a(window).mouseup(function(){E=false;a("body").removeClass("dragging")});a(document).bind("keydown","space",function(U){U.preventDefault();g.spaceKey=P=true}).bind("keyup","space",function(U){U.preventDefault();g.spaceKey=P=false}).bind("keydown","alt",function(){g.getMode()==="zoom"&&Q.addClass("out")}).bind("keyup","alt",function(){g.getMode()==="zoom"&&
Q.removeClass("out")})})();var ib=a(".menu"),Va=function(k){k.target.style.background="#fff";setTimeout(function(){k.target.style.background="#ddd"},50);setTimeout(function(){k.target.style.background="#fff"},150);setTimeout(function(){k.target.style.background="#ddd"},200);setTimeout(function(){k.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").on("mousedown touchstart",function(k){Va(k)});a("svg, body").on("mousedown touchstart",
function(k){top!=self&&!k.isTrigger&&typeof top.exports.setEditorFocus=="function"&&top.exports.setEditorFocus();if(!a(k.target).hasClass("menu_title")&&!a(k.target).parent().hasClass("menu_title"))!a(k.target).hasClass("disabled")&&a(k.target).hasClass("menu_item")?Va(k):a("#menu_bar").removeClass("active")});var Ra=[6,12,16,33,50,66,100,150,200,300,400,600,800,1200];a("#workarea").on("mousewheel",function(k,u,C,E){if(k.altKey){k.preventDefault();k=g.getZoom()*100;u=Ra.length;for(D=0;D<u;D++){C=
Math.min(u,D+1);if(E>0)zoom=Ra[D]<=k?Ra[C]:zoom;if(E<0)zoom=Ra[D]<k?Ra[D]:zoom}zoom&&wa({value:zoom})}});a(".menu_title").on("mousedown",function(){a("#tools_shapelib").hide();a("#menu_bar").toggleClass("active");ib.removeClass("open");a(this).parent().addClass("open")}).on("mouseover",function(){ib.removeClass("open");a(this).parent().addClass("open")});c.addDropDown=function(k,u,C){if(a(k).length!=0){var E=a(k).find("button"),P=a(k).find("ul").attr("id",a(k)[0].id+"-list");C||a("#option_lists").append(P);
var U=false;C&&a(k).addClass("dropup");P.find("li").bind("mouseup",u);a(window).mouseup(function(){if(!U){E.removeClass("down");P.hide()}U=false});E.bind("mousedown",function(){if(E.hasClass("down")){E.removeClass("down");P.hide()}else{E.addClass("down");if(!C){var S=a(k).offset();P.css({top:S.top,left:S.left-110})}P.show();U=true}}).hover(function(){U=true}).mouseout(function(){U=false})}};var Da=function(k,u,C,E){var P=a(k);u=a(u);var U=false,S=E.dropUp;S&&a(k).addClass("dropup");u.find("li").bind("mouseup",
function(){if(E.seticon){xb("#cur_"+P[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}C.apply(this,arguments)});a(window).mouseup(function(){if(!U){P.removeClass("down");u.hide();u.css({top:0,left:0})}U=false});u.height();a(k).bind("mousedown",function(){var X=a(k).offset();if(S){X.top-=u.height();X.left+=8}else X.top+=a(k).height();a(u).offset(X);if(P.hasClass("down")){P.removeClass("down");u.hide();u.css({top:0,left:0})}else{P.addClass("down");u.show();U=
true;return false}}).hover(function(){U=true}).mouseout(function(){U=false});E.multiclick&&u.mousedown(function(){U=true})};a("#font_family_dropdown").change(function(){var k=this.options[this.selectedIndex].value,u=this.options[this.selectedIndex].text;a("#preview_font").html(u).css("font-family",k);a("#font_family").val(k).change()});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var k=this.id.replace("tool_pos","").charAt(0);g.alignSelectedElements(k,"page")})});
(function(){var k,u=function(){a(k).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){k=this;pa="toolbars";Q.mousedown(u)}).blur(function(){pa="canvas";Q.unbind("mousedown",u);g.getMode()=="textedit"&&a("#text").focus()})})();var va=function(){$a("#tool_select")&&g.setMode("select")},fb=function(){$a("#tool_fhpath")&&g.setMode("fhpath")},La=function(){$a("#tool_line")&&g.setMode("line")},Ua=function(){$a("#tool_rect")&&g.setMode("rect")},Ea=function(){$a("#tool_ellipse")&&
g.setMode("ellipse")},kb=function(){$a("#tool_image")&&g.setMode("image")},sb=function(){$a("#tool_zoom")&&g.setMode("zoom")},Za=function(){if($a("#tool_zoom")){Db();ba()}},bb=function(){$a("#tool_text")&&g.setMode("text")},Cb=function(){$a("#tool_path")&&g.setMode("path")},ta=function(){if(W!=null||sa)g.deleteSelectedElements()},mb=function(){if(W!=null||sa){window.event.type==="keydown"&&pb(a("#edit_menu"));g.cutSelectedElements()}},jb=function(){if(W!=null||sa){window.event.type==="keydown"&&pb(a("#edit_menu"));
g.copySelectedElements()}},zb=function(){window.event.type==="keydown"&&pb(a("#edit_menu"));var k=g.getZoom(),u=(Q[0].scrollLeft+Q.width()/2)/k-g.contentW;k=(Q[0].scrollTop+Q.height()/2)/k-g.contentH;g.pasteElements("point",u,k)},ob=function(){if(W!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveToTopSelectedElement()}},eb=function(){if(W!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveToBottomSelectedElement()}},tb=function(){if(W!=null){window.event.type==="keydown"&&
pb(a("#object_menu"));g.moveUpDownSelected("Up")}},ub=function(){if(W!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveUpDownSelected("Down")}},wb=function(k){if(W!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveUpDownSelected(k)}},Ab=function(){if(W!=null){g.convertToPath();elems=g.getSelectedElems();g.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");g.setMode("pathedit");K.toEditMode(elems[0]);g.clearSelection()}},la=function(){W!=
null&&K.reorient()},ca=function(){if(W!=null||sa)a.prompt(uiStrings.notification.enterNewLinkURL,"http://",function(k){k&&g.makeHyperlink(k)})},ja=function(k,u){if(W!=null||sa){if(curConfig.gridSnapping){var C=g.getZoom()*curConfig.snappingStep;k*=C;u*=C}a("input").blur();g.moveSelectedElements(k,u)}},N=function(){var k=!a("#tool_node_link").hasClass("checked");k?a("#tool_node_link").addClass("checked").find("input").attr("checked",true):a("#tool_node_link").removeClass("checked").find("input").attr("checked",
false);K.linkControlPoints(k)},R=function(){K.getNodePoint()&&K.clonePathNode()},ea=function(){K.getNodePoint()&&K.deletePathNode()},Ga=function(){var k=a("#tool_add_subpath"),u=!k.hasClass("push_button_pressed");u?k.addClass("push_button_pressed").removeClass("tool_button"):k.removeClass("push_button_pressed").addClass("tool_button");K.addSubPath(u)},Oa=function(){K.opencloseSubPath()},Ya=function(){g.cycleElement(1)},db=function(){g.cycleElement(0)},nb=function(k,u){if(!(W==null||sa)){k||(u*=-1);
var C=a("#angle").val()*1+u;g.setRotationAngle(C);za()}},Xa=function(){var k=curConfig.dimensions;a.confirm(uiStrings.notification.QwantToClear,function(u){if(u){ba();g.clear();g.setResolution(k[0],k[1]);F(true);Db();za();Z();g.runExtensions("onNewDocument")}})},rb=function(){g.setBold(!g.getBold());za();return false},Pa=function(){g.setItalic(!g.getItalic());za();return false},vb=function(){if(!b.pngsave){var k=uiStrings.notification.loadingImage;O=window.open("data:text/html;charset=utf-8,<title>"+
k+"</title><h1>"+k+"</h1>")}window.canvg?g.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){g.rasterExport()})})},Bb=function(){g.open()},Ib=function(){},pb=function(k){var u=k.prev();u.css("background","#09f");setTimeout(function(){u.css("background","")},200)},hb=function(){if(T.getUndoStackSize()>0){window.event.type==="keydown"&&pb(a("#edit_menu"));T.undo()}},Ja=function(){if(T.getRedoStackSize()>0){window.event.type==="keydown"&&pb(a("#edit_menu"));
T.redo()}},Kb=function(){if(sa)g.groupSelectedElements();else W&&g.ungroupSelectedElement()},Nb=function(){window.event.type==="keydown"&&pb(a("#edit_menu"));g.cloneSelectedElements(20,20)},Lb=function(){var k=this.id.replace("tool_align","").charAt(0);g.alignSelectedElements(k,a("#align_relative_to").val())},Ob=function(){var k=document.querySelector("#tool_stroke rect"),u=document.querySelector("#tool_fill rect"),C=u.getAttribute("fill"),E=k.getAttribute("fill");k=parseFloat(k.getAttribute("stroke-opacity"));
if(isNaN(k))k=100;u=parseFloat(u.getAttribute("fill-opacity"));if(isNaN(u))u=100;E=Ia(E,k,"stroke");C=Ia(C,u,"fill");c.paintBox.fill.setPaint(E,true);c.paintBox.stroke.setPaint(C,true)},Db=function(k){var u=g.getResolution();k=k?u.zoom*k:1;a("#zoom").val(k*100);g.setZoom(k);lb();F(true)},Fb=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");Q.toggleClass("wireframe");if(!H){var k=
var C=C||"normal";u||a(".tools_flyout").fadeOut(C);a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(k).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var k=null,u=null,C=Q[0],D=false,P=false;a("#svgcanvas").bind("mousemove mouseup touchend",function(U){if(D!==false){C.scrollLeft-=U.clientX-k;C.scrollTop-=U.clientY-u;k=U.clientX;u=U.clientY;if(U.type==="mouseup"||U.type==="touchend")D=false;return false}}).on("mousedown touchmove",
function(U){if(U.button===1||P===true||U.originalEvent.touches&&U.originalEvent.touches.length>=2){D=true;k=U.clientX;u=U.clientY;return false}});a(window).mouseup(function(){D=false;a("body").removeClass("dragging")});a(document).bind("keydown","space",function(U){U.preventDefault();g.spaceKey=P=true}).bind("keyup","space",function(U){U.preventDefault();g.spaceKey=P=false}).bind("keydown","alt",function(){g.getMode()==="zoom"&&Q.addClass("out")}).bind("keyup","alt",function(){g.getMode()==="zoom"&&
Q.removeClass("out")})})();var ib=a(".menu"),Wa=function(k){k.target.style.background="#fff";setTimeout(function(){k.target.style.background="#ddd"},50);setTimeout(function(){k.target.style.background="#fff"},150);setTimeout(function(){k.target.style.background="#ddd"},200);setTimeout(function(){k.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").on("mousedown touchstart",function(k){Wa(k)});a("svg, body").on("mousedown touchstart",
function(k){top!=self&&!k.isTrigger&&typeof top.exports.setEditorFocus=="function"&&top.exports.setEditorFocus();if(k.target.nodeName.toLowerCase()!=="input")if(!a(k.target).hasClass("menu_title")&&!a(k.target).parent().hasClass("menu_title"))!a(k.target).hasClass("disabled")&&a(k.target).hasClass("menu_item")?Wa(k):a("#menu_bar").removeClass("active")});var Sa=[6,12,16,33,50,66,100,150,200,300,400,600,800,1200];a("#workarea").on("mousewheel",function(k,u,C,D){if(k.altKey){k.preventDefault();k=g.getZoom()*
100;u=Sa.length;for(E=0;E<u;E++){C=Math.min(u,E+1);if(D>0)zoom=Sa[E]<=k?Sa[C]:zoom;if(D<0)zoom=Sa[E]<k?Sa[E]:zoom}zoom&&wa({value:zoom})}});a(".menu_title").on("mousedown",function(){a("#tools_shapelib").hide();a("#menu_bar").toggleClass("active");ib.removeClass("open");a(this).parent().addClass("open")}).on("mouseover",function(){ib.removeClass("open");a(this).parent().addClass("open")});c.addDropDown=function(k,u,C){if(a(k).length!=0){var D=a(k).find("button"),P=a(k).find("ul").attr("id",a(k)[0].id+
"-list");C||a("#option_lists").append(P);var U=false;C&&a(k).addClass("dropup");P.find("li").bind("mouseup",u);a(window).mouseup(function(){if(!U){D.removeClass("down");P.hide()}U=false});D.bind("mousedown",function(){if(D.hasClass("down")){D.removeClass("down");P.hide()}else{D.addClass("down");if(!C){var S=a(k).offset();P.css({top:S.top,left:S.left-110})}P.show();U=true}}).hover(function(){U=true}).mouseout(function(){U=false})}};var Da=function(k,u,C,D){var P=a(k);u=a(u);var U=false,S=D.dropUp;
S&&a(k).addClass("dropup");u.find("li").bind("mouseup",function(){if(D.seticon){yb("#cur_"+P[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}C.apply(this,arguments)});a(window).mouseup(function(){if(!U){P.removeClass("down");u.hide();u.css({top:0,left:0})}U=false});u.height();a(k).bind("mousedown",function(){var Y=a(k).offset();if(S){Y.top-=u.height();Y.left+=8}else Y.top+=a(k).height();a(u).offset(Y);if(P.hasClass("down")){P.removeClass("down");u.hide();u.css({top:0,
left:0})}else{P.addClass("down");u.show();U=true;return false}}).hover(function(){U=true}).mouseout(function(){U=false});D.multiclick&&u.mousedown(function(){U=true})};a("#font_family_dropdown").change(function(){var k=this.options[this.selectedIndex].value,u=this.options[this.selectedIndex].text;a("#preview_font").html(u).css("font-family",k);a("#font_family").val(k).change()});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var k=this.id.replace("tool_pos","").charAt(0);
g.alignSelectedElements(k,"page")})});(function(){var k,u=function(){a(k).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){k=this;pa="toolbars";Q.mousedown(u)}).blur(function(){pa="canvas";Q.unbind("mousedown",u);g.getMode()=="textedit"&&a("#text").focus()})})();var va=function(){$a("#tool_select")&&g.setMode("select")},fb=function(){$a("#tool_fhpath")&&g.setMode("fhpath")},La=function(){$a("#tool_line")&&g.setMode("line")},Va=function(){$a("#tool_rect")&&g.setMode("rect")},
Ea=function(){$a("#tool_ellipse")&&g.setMode("ellipse")},kb=function(){$a("#tool_image")&&g.setMode("image")},sb=function(){$a("#tool_zoom")&&g.setMode("zoom")},Za=function(){if($a("#tool_zoom")){Db();ba()}},bb=function(){$a("#tool_text")&&g.setMode("text")},Cb=function(){$a("#tool_path")&&g.setMode("path")},ua=function(){if(W!=null||sa)g.deleteSelectedElements()},mb=function(){if(W!=null||sa){window.event.type==="keydown"&&pb(a("#edit_menu"));g.cutSelectedElements()}},jb=function(){if(W!=null||sa){window.event.type===
"keydown"&&pb(a("#edit_menu"));g.copySelectedElements()}},Ab=function(){window.event.type==="keydown"&&pb(a("#edit_menu"));var k=g.getZoom(),u=(Q[0].scrollLeft+Q.width()/2)/k-g.contentW;k=(Q[0].scrollTop+Q.height()/2)/k-g.contentH;g.pasteElements("point",u,k)},ob=function(){if(W!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveToTopSelectedElement()}},eb=function(){if(W!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveToBottomSelectedElement()}},tb=function(){if(W!=
null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveUpDownSelected("Up")}},ub=function(){if(W!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveUpDownSelected("Down")}},wb=function(k){if(W!=null){window.event.type==="keydown"&&pb(a("#object_menu"));g.moveUpDownSelected(k)}},Bb=function(){if(W!=null){g.convertToPath();elems=g.getSelectedElems();g.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");g.setMode("pathedit");K.toEditMode(elems[0]);
g.clearSelection()}},la=function(){W!=null&&K.reorient()},ca=function(){if(W!=null||sa)a.prompt(uiStrings.notification.enterNewLinkURL,"http://",function(k){k&&g.makeHyperlink(k)})},ja=function(k,u){if(W!=null||sa){if(curConfig.gridSnapping){var C=g.getZoom()*curConfig.snappingStep;k*=C;u*=C}a("input").blur();g.moveSelectedElements(k,u)}},N=function(){var k=!a("#tool_node_link").hasClass("checked");k?a("#tool_node_link").addClass("checked").find("input").attr("checked",true):a("#tool_node_link").removeClass("checked").find("input").attr("checked",
false);K.linkControlPoints(k)},R=function(){K.getNodePoint()&&K.clonePathNode()},ea=function(){K.getNodePoint()&&K.deletePathNode()},Ga=function(){var k=a("#tool_add_subpath"),u=!k.hasClass("push_button_pressed");u?k.addClass("push_button_pressed").removeClass("tool_button"):k.removeClass("push_button_pressed").addClass("tool_button");K.addSubPath(u)},Pa=function(){K.opencloseSubPath()},Ya=function(){g.cycleElement(1)},db=function(){g.cycleElement(0)},nb=function(k,u){if(!(W==null||sa)){k||(u*=-1);
var C=a("#angle").val()*1+u;g.setRotationAngle(C);za()}},Ua=function(){var k=curConfig.dimensions;a.confirm(uiStrings.notification.QwantToClear,function(u){if(u){ba();g.clear();g.setResolution(k[0],k[1]);F(true);Db();za();Z();g.runExtensions("onNewDocument")}})},rb=function(){g.setBold(!g.getBold());za();return false},Qa=function(){g.setItalic(!g.getItalic());za();return false},vb=function(){if(!b.pngsave){var k=uiStrings.notification.loadingImage;O=window.open("data:text/html;charset=utf-8,<title>"+
k+"</title><h1>"+k+"</h1>")}window.canvg?g.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){g.rasterExport()})})},xb=function(){g.open()},Ib=function(){},pb=function(k){var u=k.prev();u.css("background","#09f");setTimeout(function(){u.css("background","")},200)},hb=function(){if(T.getUndoStackSize()>0){window.event.type==="keydown"&&pb(a("#edit_menu"));T.undo()}},Ja=function(){if(T.getRedoStackSize()>0){window.event.type==="keydown"&&pb(a("#edit_menu"));
T.redo()}},Kb=function(){if(sa)g.groupSelectedElements();else W&&g.ungroupSelectedElement()},Nb=function(){window.event.type==="keydown"&&pb(a("#edit_menu"));g.cloneSelectedElements(20,20)},Lb=function(){var k=this.id.replace("tool_align","").charAt(0);g.alignSelectedElements(k,a("#align_relative_to").val())},Ob=function(){var k=document.querySelector("#tool_stroke rect"),u=document.querySelector("#tool_fill rect"),C=u.getAttribute("fill"),D=k.getAttribute("fill");k=parseFloat(k.getAttribute("stroke-opacity"));
if(isNaN(k))k=100;u=parseFloat(u.getAttribute("fill-opacity"));if(isNaN(u))u=100;D=Ia(D,k,"stroke");C=Ia(C,u,"fill");c.paintBox.fill.setPaint(D,true);c.paintBox.stroke.setPaint(C,true)},Db=function(k){var u=g.getResolution();k=k?u.zoom*k:1;a("#zoom").val(k*100);g.setZoom(k);lb();F(true)},Fb=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");Q.toggleClass("wireframe");if(!H){var k=
a("#wireframe_rules");k.length?k.empty():a('<style id="wireframe_rules"></style>').appendTo("head");lb()}},Jb=function(){var k=!a("#tool_snap").hasClass("push_button_pressed");k?a("#tool_snap").addClass("push_button_pressed"):a("#tool_snap").removeClass("push_button_pressed");curConfig.gridSnapping=k},Rb=function(){window.self!=window.top&&top.exports.setEditorFocus(false)},Eb=function(){if(a("#tool_rulers").hasClass("push_button_pressed")){a("#tool_rulers").removeClass("push_button_pressed");a("#show_rulers").attr("checked",
false);curConfig.showRulers=false}else{a("#tool_rulers").addClass("push_button_pressed");a("#show_rulers").attr("checked",true);curConfig.showRulers=true}a("#rulers").toggle(!!curConfig.showRulers)},lb=function(){if(!H){var k="#workarea.wireframe #svgcontent * { stroke-width: "+1/g.getZoom()+"px; }";a("#wireframe_rules").text(Q.hasClass("wireframe")?k:"")}},Qb=function(k,u){if(!ka){ka=true;a("#save_output_btns").toggle(!!u);a("#tool_source_back").toggle(!u);var C=fa=g.getSvgString();a("#svg_source_textarea").val(C);
a("#svg_source_editor").fadeIn();C=a("#svg_source_container").height()-50;a("#svg_source_textarea").css("height",C);a("#svg_source_textarea").focus()}},Pb=function(){if(ka){if(g.setSvgString(a("#svg_source_textarea").val())){g.clearSelection();m();Db();Z()}else a.confirm(uiStrings.notification.QerrorsRevertToSource,function(k){if(!k)return false;g.clearSelection();m();Db();Z()});ba()}},xb=c.setIcon=function(k,u){var C=typeof u==="string"?a.getSvgIcon(u,true):u.clone();C?a(k).find("img").replaceWith(C):
console.log("NOTE: Icon image missing: "+u)},gb;gb=function(){var k=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,u=document.getElementsByTagName("script")[0],C;for(C in u.style)if(k.test(C))return C.match(k)[0];if("WebkitOpacity"in u.style)return"Webkit";if("KhtmlOpacity"in u.style)return"Khtml";return""}();var Mb=function(k,u){gb.toLowerCase();var C=["top","left","bottom","right"];k.each(function(){for(var E=a(this),P=E.outerWidth()*(u-1),U=E.outerHeight()*(u-1),S=0;S<4;S++){var X=C[S],aa=E.data("orig_margin-"+
X);if(aa==null){aa=parseInt(E.css("margin-"+X));E.data("orig_margin-"+X,aa)}aa=aa*u;if(X==="right")aa+=P;else if(X==="bottom")aa+=U;E.css("margin-"+X,aa)}})},e=c.setIconSize=function(k,u){if(!(k==s.size&&!u)){var C=a("#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout"),E=1;E=typeof k=="number"?k:{s:0.75,m:1,l:1.25,xl:1.5}[k];c.tool_scale=ia=E;na();
var P=C.parents(":hidden");P.css("visibility","hidden").show();Mb(C,E);P.css("visibility","visible").hide();C=a("#tool_size_rules");if(C.length)C.empty();else C=a('<style id="tool_size_rules"></style>').appendTo("head");if(k!="m"){var U="";a.each(cssResizeRules,function(S,X){S="#svg_editor "+S.replace(/,/g,", #svg_editor");U+=S+"{";a.each(X,function(aa,ga){if(typeof ga==="number")var ra=ga*E+"px";else if(ga[k]||ga.all)ra=ga[k]||ga.all;U+=aa+":"+ra+";"});U+="}"});P="-"+gb.toLowerCase()+"-";U+="#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout{"+
P+"transform: scale("+E+");} #svg_editor div.toolset .toolset {"+P+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+P+"transform: scale("+1/E+");}";C.text(U)}na()}},h=function(){a("#dialog_box").hide();if(ka){if(ka)fa!==a("#svg_source_textarea").val()?a.confirm(uiStrings.notification.QignoreSourceChanges,function(k){k&&m()}):m();z()}else da&&g.leaveContext()},m=function(){a("#svg_source_editor").hide();ka=false;a("#svg_source_textarea").blur()};a(window).width();a(window).height();
a("#svg_source_editor").fadeIn();C=a("#svg_source_container").height()-50;a("#svg_source_textarea").css("height",C);a("#svg_source_textarea").focus()}},Pb=function(){if(ka){if(g.setSvgString(a("#svg_source_textarea").val())){g.clearSelection();m();Db();Z()}else a.confirm(uiStrings.notification.QerrorsRevertToSource,function(k){if(!k)return false;g.clearSelection();m();Db();Z()});ba()}},yb=c.setIcon=function(k,u){var C=typeof u==="string"?a.getSvgIcon(u,true):u.clone();C?a(k).find("img").replaceWith(C):
console.log("NOTE: Icon image missing: "+u)},gb;gb=function(){var k=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,u=document.getElementsByTagName("script")[0],C;for(C in u.style)if(k.test(C))return C.match(k)[0];if("WebkitOpacity"in u.style)return"Webkit";if("KhtmlOpacity"in u.style)return"Khtml";return""}();var Mb=function(k,u){gb.toLowerCase();var C=["top","left","bottom","right"];k.each(function(){for(var D=a(this),P=D.outerWidth()*(u-1),U=D.outerHeight()*(u-1),S=0;S<4;S++){var Y=C[S],aa=D.data("orig_margin-"+
Y);if(aa==null){aa=parseInt(D.css("margin-"+Y));D.data("orig_margin-"+Y,aa)}aa=aa*u;if(Y==="right")aa+=P;else if(Y==="bottom")aa+=U;D.css("margin-"+Y,aa)}})},e=c.setIconSize=function(k,u){if(!(k==s.size&&!u)){var C=a("#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout"),D=1;D=typeof k=="number"?k:{s:0.75,m:1,l:1.25,xl:1.5}[k];c.tool_scale=ia=D;na();
var P=C.parents(":hidden");P.css("visibility","hidden").show();Mb(C,D);P.css("visibility","visible").hide();C=a("#tool_size_rules");if(C.length)C.empty();else C=a('<style id="tool_size_rules"></style>').appendTo("head");if(k!="m"){var U="";a.each(cssResizeRules,function(S,Y){S="#svg_editor "+S.replace(/,/g,", #svg_editor");U+=S+"{";a.each(Y,function(aa,ga){if(typeof ga==="number")var ra=ga*D+"px";else if(ga[k]||ga.all)ra=ga[k]||ga.all;U+=aa+":"+ra+";"});U+="}"});P="-"+gb.toLowerCase()+"-";U+="#tools_top .toolset, #editor_panel > *, #history_panel > *,\t\t\t\t#main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *,\t\t\t\t#g_panel > *, #tool_font_size > *, .tools_flyout{"+
P+"transform: scale("+D+");} #svg_editor div.toolset .toolset {"+P+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+P+"transform: scale("+1/D+");}";C.text(U)}na()}},h=function(){a("#dialog_box").hide();if(ka){if(ka)fa!==a("#svg_source_textarea").val()?a.confirm(uiStrings.notification.QignoreSourceChanges,function(k){k&&m()}):m();z()}else da&&g.leaveContext()},m=function(){a("#svg_source_editor").hide();ka=false;a("#svg_source_textarea").blur()};a(window).width();a(window).height();
var z=a.noop;a(window).resize(function(){F()});(function(){Q.scroll(function(){if(a("#ruler_x").length!=0)a("#ruler_x")[0].scrollLeft=Q[0].scrollLeft;if(a("#ruler_y").length!=0)a("#ruler_y")[0].scrollTop=Q[0].scrollTop})})();a("#url_notice").click(function(){a.alert(this.title)});a("#change_image_url").click(function(){var k=g.getHref(W);k=k.indexOf("data:")===0?"":k;a.prompt(uiStrings.notification.enterNewImgURL,k,function(u){u&&Na(u)})});var w=function(k){var u=k[0].id=="stroke_color"?"stroke":
"fill",C=k[0].id=="canvas_color";if(C)u="canvas";var E=c.paintBox[u].paint;k=u=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity";C=C?{right:200,top:50}:{left:45,bottom:50};a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",containment:"window"}).css(C).jGraduate({paint:E,window:{pickerTitle:k},images:{clientPath:curConfig.jGraduatePath},newstop:"inverse"},function(P){E=new a.jGraduate.Paint(P);c.paintBox[u].setPaint(E);
g.setPaint(u,E);a("#color_picker").hide()},function(){a("#color_picker").hide()})};q=function(k,u){var C=document.getElementById("canvas_background"),E={color:"fff",opacity:1};if(u=="stroke")E=curConfig.initStroke;if(u=="fill")E=curConfig.initFill;if(u=="canvas"&&C)if(C=C.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))E={color:("0"+parseInt(C[1],10).toString(16)).slice(-2)+("0"+parseInt(C[2],10).toString(16)).slice(-2)+("0"+parseInt(C[3],10).toString(16)).slice(-2),opacity:1};C=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+
E.color+'" opacity="'+E.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml").documentElement;C=a(k)[0].appendChild(document.importNode(C,true));u==="canvas"?C.setAttribute("width",60.5):C.setAttribute("width","100%");this.rect=C.firstChild;this.defs=C.getElementsByTagName("defs")[0];this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:E.color});this.type=u;this.setPaint=function(P,U){this.paint=P;var S="none",X=P.type,aa=P.alpha/100;switch(X){case "solidColor":S=
P[X]=="none"||P[X]=="one"?"none":"#"+P[X];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);this.grad=this.defs.appendChild(P[X]);S="url(#"+(this.grad.id="gradbox_"+this.type)+")"}this.rect.setAttribute("fill",S);this.rect.setAttribute("opacity",aa);if(U){g.setColor(this.type,S,true);g.setPaintOpacity(this.type,aa,true)}if(this.type=="canvas")(X=document.getElementById("canvas_background"))?X.setAttribute("fill",S):Ka(S)};this.update=function(P){if(W){var U=this.type;
switch(W.tagName){case "use":case "image":case "foreignObject":return;case "g":case "a":for(var S=null,X=W.getElementsByTagName("*"),aa=0,ga=X.length;aa<ga;aa++){var ra=X[aa].getAttribute(U);if(aa===0)S=ra;else if(S!==ra){S=null;break}}if(S===null){X=null;return}X=S;S=1;break;default:S=parseFloat(W.getAttribute(U+"-opacity"));if(isNaN(S))S=1;X=U==="fill"?"black":"none";X=W.getAttribute(U)||X}if(P){g.setColor(U,X,true);g.setPaintOpacity(U,S,true)}S*=100;this.setPaint(Ia(X,S,U))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var P=
"fill",C=k[0].id=="canvas_color";if(C)u="canvas";var D=c.paintBox[u].paint;k=u=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity";C=C?{right:200,top:50}:{left:45,bottom:50};a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",containment:"window"}).css(C).jGraduate({paint:D,window:{pickerTitle:k},images:{clientPath:curConfig.jGraduatePath},newstop:"inverse"},function(P){D=new a.jGraduate.Paint(P);c.paintBox[u].setPaint(D);
g.setPaint(u,D);a("#color_picker").hide()},function(){a("#color_picker").hide()})};q=function(k,u){var C=document.getElementById("canvas_background"),D={color:"fff",opacity:1};if(u=="stroke")D=curConfig.initStroke;if(u=="fill")D=curConfig.initFill;if(u=="canvas"&&C)if(C=C.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))D={color:("0"+parseInt(C[1],10).toString(16)).slice(-2)+("0"+parseInt(C[2],10).toString(16)).slice(-2)+("0"+parseInt(C[3],10).toString(16)).slice(-2),opacity:1};C=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%"\t\t\t\t\tfill="#'+
D.color+'" opacity="'+D.opacity+'"/>\t\t\t\t\t<defs><linearGradient id="gradbox_"/></defs></svg>',"text/xml").documentElement;C=a(k)[0].appendChild(document.importNode(C,true));u==="canvas"?C.setAttribute("width",60.5):C.setAttribute("width","100%");this.rect=C.firstChild;this.defs=C.getElementsByTagName("defs")[0];this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:D.color});this.type=u;this.setPaint=function(P,U){this.paint=P;var S="none",Y=P.type,aa=P.alpha/100;switch(Y){case "solidColor":S=
P[Y]=="none"||P[Y]=="one"?"none":"#"+P[Y];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);this.grad=this.defs.appendChild(P[Y]);S="url(#"+(this.grad.id="gradbox_"+this.type)+")"}this.rect.setAttribute("fill",S);this.rect.setAttribute("opacity",aa);if(U){g.setColor(this.type,S,true);g.setPaintOpacity(this.type,aa,true)}if(this.type=="canvas")(Y=document.getElementById("canvas_background"))?Y.setAttribute("fill",S):Ka(S)};this.update=function(P){if(W){var U=this.type;
switch(W.tagName){case "use":case "image":case "foreignObject":return;case "g":case "a":for(var S=null,Y=W.getElementsByTagName("*"),aa=0,ga=Y.length;aa<ga;aa++){var ra=Y[aa].getAttribute(U);if(aa===0)S=ra;else if(S!==ra){S=null;break}}if(S===null){Y=null;return}Y=S;S=1;break;default:S=parseFloat(W.getAttribute(U+"-opacity"));if(isNaN(S))S=1;Y=U==="fill"?"black":"none";Y=W.getAttribute(U)||Y}if(P){g.setColor(U,Y,true);g.setPaintOpacity(U,S,true)}S*=100;this.setPaint(Ia(Y,S,U))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var P=
new a.jGraduate.Paint({copy:this.paint});g.setPaint(u,P)}}};c.paintBox.fill=new q("#fill_color","fill");c.paintBox.stroke=new q("#stroke_color","stroke");c.paintBox.canvas=new q("#canvas_color","canvas");a("#stroke_width").val(curConfig.initStroke.width);a("#group_opacity").val(curConfig.initOpacity*100);q=c.paintBox.fill.rect.cloneNode(false);q.setAttribute("style","vector-effect:non-scaling-stroke");var H=q.style.vectorEffect==="non-scaling-stroke";q.removeAttribute("style");q=c.paintBox.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg",
"feGaussianBlur");typeof q.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(q).remove();setTimeout(function(){g.embedImage("images/placeholder.svg",function(k){if(!k){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);s.img_save="ref";a("#image_opt_embed").css("color","#666").attr("title",uiStrings.notification.featNotSupported)}})},1E3);a("#tool_fill").click(function(){if(a("#tool_fill").hasClass("active"))w(a("#fill_color"));else{a("#tool_fill").addClass("active");
a("#tool_stroke").removeClass("active")}});a("#tool_stroke").on("click",function(){if(a("#tool_stroke").hasClass("active"))w(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#tool_canvas").on("click touchstart",function(){w(a("#canvas_color"))});a("#tool_stroke").on("touchstart",function(){a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active");w(a("#stroke_color"))});a("#tool_fill").on("touchstart",function(){a("#tool_fill").addClass("active");
a("#tool_stroke").removeClass("active");w(a("#fill_color"))});a("#zoom_select").on("change",function(){var k=this.options[this.selectedIndex].text;k=k.split("%")[0];a("#zoom").val(k).trigger("change")});a(".push_button").mousedown(function(){a(this).hasClass("disabled")||a(this).addClass("push_button_pressed").removeClass("push_button")}).mouseout(function(){a(this).removeClass("push_button_pressed").addClass("push_button")}).mouseup(function(){a(this).removeClass("push_button_pressed").addClass("push_button")});
a(window).bind("load resize",function(){Q.css("line-height",Q.height()+"px")});var A=function(){var k=a("#canvas_width"),u=a("#canvas_height"),C=k.val(),E=u.val();if(C!="fit"&&!svgedit.units.isValidUnit("width",C)){a.alert(uiStrings.notification.invalidAttrValGiven);k.parent().addClass("error");return false}k.parent().removeClass("error");if(E!="fit"&&!svgedit.units.isValidUnit("height",E)){a.alert(uiStrings.notification.invalidAttrValGiven);u.parent().addClass("error");return false}u.parent().removeClass("error");
if(!g.setResolution(C,E)){a.alert(uiStrings.notification.noContentToFitTo);C=g.getResolution();k.val(C.w);u.val(C.h);return false}F()};a("#resolution").change(function(){var k=a("#canvas_width")[0],u=a("#canvas_height")[0];if(this.selectedIndex)if(this.value=="content"){k.value="fit";u.value="fit";A();var C=g.getResolution();k.value=C.w;u.value=C.h}else{var E=this.value.split("x");E[0]=parseInt(E[0]);E[1]=parseInt(E[1]);var P=E[0]-k.value,U=E[1]-u.value,S=Date.now(),X=function(aa){aa=(aa-S)/1E3;aa=
Math.pow(aa-1,3)+1;k.value=(E[0]-P+aa*P).toFixed(0);u.value=(E[1]-U+aa*U).toFixed(0);A();if(aa>=1){aa=g.getResolution();a("#canvas_width").val(aa.w.toFixed());a("#canvas_height").val(aa.h.toFixed());a("#resolution_label").html("<div class='pull'>"+aa.w+"<span>\u00d7</span></br>"+aa.h+"</div>")}else requestAnimationFrame(X)};X(Date.now())}else{a("#resolution_label").html("Custom");k.removeAttribute("readonly");k.focus();k.select();if(k.value=="fit"){k.value=100;u.value=100}}});a("#zoom").change(function(){wa(this)});
a("input,select").attr("autocomplete","off");var v=function(){var k=[{sel:"#tool_select",fn:va,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:fb,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:La,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:Ua,evt:"click",key:["R",true],icon:"rect"},{sel:"#tool_ellipse",fn:Ea,evt:"mouseup",key:["C",true],icon:"ellipse"},{sel:"#tool_path",fn:Cb,evt:"click",key:["P",true]},{sel:"#tool_text",fn:bb,evt:"click",key:["T",true]},{sel:"#tool_image",fn:kb,evt:"mouseup"},
{sel:"#tool_zoom",fn:sb,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",fn:Xa,evt:"mouseup",key:[o+"N",true]},{sel:"#tool_save",fn:function(){ka?Pb():clickSave()},evt:"mouseup",key:[o+"S",true]},{sel:"#tool_export",fn:vb,evt:"mouseup"},{sel:"#tool_open",fn:Bb,evt:"mouseup"},{sel:"#tool_import",fn:Ib,evt:"mouseup"},{sel:"#tool_source",fn:Qb,evt:"click",key:[o+"U",true]},{sel:"#tool_wireframe",fn:Fb,evt:"click"},{sel:"#tool_snap",fn:Jb,evt:"click"},{sel:"#tool_rulers",fn:Eb,evt:"click"},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",
fn:h,evt:"click",key:["esc",false,false],hidekey:true},{sel:"#tool_source_save",fn:Pb,evt:"click"},{sel:"#tool_delete,#tool_delete_multi",fn:ta,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",fn:la,evt:"click"},{sel:"#tool_node_link",fn:N,evt:"click"},{sel:"#tool_node_clone",fn:R,evt:"click"},{sel:"#tool_node_delete",fn:ea,evt:"click"},{sel:"#tool_openclose_path",fn:Oa,evt:"click"},{sel:"#tool_add_subpath",fn:Ga,evt:"click"},{sel:"#tool_move_top",fn:ob,evt:"click",key:o+"shift+up"},
{sel:"#tool_move_bottom",fn:eb,evt:"click",key:o+"shift+down"},{sel:"#tool_move_up",fn:tb,evt:"click",key:[o+"up",true]},{sel:"#tool_move_down",fn:ub,evt:"click",key:[o+"down",true]},{sel:"#tool_topath",fn:Ab,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:ca,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:Nb,evt:"click",key:[o+"D",true]},{sel:"#tool_group",fn:Kb,evt:"click",key:[o+"G",true]},{sel:"#tool_ungroup",fn:Kb,evt:"click",key:o+"shift+G"},{sel:"#tool_unlink_use",fn:Kb,evt:"click"},
{sel:"[id^=tool_align]",fn:Lb,evt:"click"},{sel:"#tool_undo",fn:hb,evt:"click",key:o+"z"},{sel:"#tool_redo",fn:Ja,evt:"click",key:["y",true]},{sel:"#tool_cut",fn:mb,evt:"click",key:[o+"x",true]},{sel:"#tool_copy",fn:jb,evt:"click",key:o+"c"},{sel:"#tool_paste",fn:zb,evt:"click",key:o+"v"},{sel:"#tool_switch",fn:Ob,evt:"click",key:["x",true]},{sel:"#tool_bold",fn:rb,evt:"mousedown",key:[o+"B",true]},{sel:"#tool_italic",fn:Pa,evt:"mousedown",key:[o+"I",true]},{sel:"#copy_save_done",fn:h,evt:"click"},
a(window).bind("load resize",function(){Q.css("line-height",Q.height()+"px")});var A=function(){var k=a("#canvas_width"),u=a("#canvas_height"),C=k.val(),D=u.val();if(C!="fit"&&!svgedit.units.isValidUnit("width",C)){a.alert(uiStrings.notification.invalidAttrValGiven);k.parent().addClass("error");return false}k.parent().removeClass("error");if(D!="fit"&&!svgedit.units.isValidUnit("height",D)){a.alert(uiStrings.notification.invalidAttrValGiven);u.parent().addClass("error");return false}u.parent().removeClass("error");
if(!g.setResolution(C,D)){a.alert(uiStrings.notification.noContentToFitTo);C=g.getResolution();k.val(C.w);u.val(C.h);return false}F()};a("#resolution").change(function(){var k=a("#canvas_width")[0],u=a("#canvas_height")[0];if(this.selectedIndex)if(this.value=="content"){k.value="fit";u.value="fit";A();var C=g.getResolution();k.value=C.w;u.value=C.h}else{var D=this.value.split("x");D[0]=parseInt(D[0]);D[1]=parseInt(D[1]);var P=D[0]-k.value,U=D[1]-u.value,S=Date.now(),Y=function(aa){aa=(aa-S)/1E3;aa=
Math.pow(aa-1,3)+1;k.value=(D[0]-P+aa*P).toFixed(0);u.value=(D[1]-U+aa*U).toFixed(0);A();if(aa>=1){aa=g.getResolution();a("#canvas_width").val(aa.w.toFixed());a("#canvas_height").val(aa.h.toFixed());a("#resolution_label").html("<div class='pull'>"+aa.w+"<span>\u00d7</span></br>"+aa.h+"</div>")}else requestAnimationFrame(Y)};Y(Date.now())}else{a("#resolution_label").html("Custom");k.removeAttribute("readonly");k.focus();k.select();if(k.value=="fit"){k.value=100;u.value=100}}});a("#zoom").change(function(){wa(this)});
a("input,select").attr("autocomplete","off");var v=function(){var k=[{sel:"#tool_select",fn:va,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:fb,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:La,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:Va,evt:"click",key:["R",true],icon:"rect"},{sel:"#tool_ellipse",fn:Ea,evt:"mouseup",key:["C",true],icon:"ellipse"},{sel:"#tool_path",fn:Cb,evt:"click",key:["P",true]},{sel:"#tool_text",fn:bb,evt:"click",key:["T",true]},{sel:"#tool_image",fn:kb,evt:"mouseup"},
{sel:"#tool_zoom",fn:sb,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",fn:Ua,evt:"mouseup",key:[o+"N",true]},{sel:"#tool_save",fn:function(){ka?Pb():clickSave()},evt:"mouseup",key:[o+"S",true]},{sel:"#tool_export",fn:vb,evt:"mouseup"},{sel:"#tool_open",fn:xb,evt:"mouseup"},{sel:"#tool_import",fn:Ib,evt:"mouseup"},{sel:"#tool_source",fn:Qb,evt:"click",key:[o+"U",true]},{sel:"#tool_wireframe",fn:Fb,evt:"click"},{sel:"#tool_snap",fn:Jb,evt:"click"},{sel:"#tool_rulers",fn:Eb,evt:"click"},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",
fn:h,evt:"click",key:["esc",false,false],hidekey:true},{sel:"#tool_source_save",fn:Pb,evt:"click"},{sel:"#tool_delete,#tool_delete_multi",fn:ua,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",fn:la,evt:"click"},{sel:"#tool_node_link",fn:N,evt:"click"},{sel:"#tool_node_clone",fn:R,evt:"click"},{sel:"#tool_node_delete",fn:ea,evt:"click"},{sel:"#tool_openclose_path",fn:Pa,evt:"click"},{sel:"#tool_add_subpath",fn:Ga,evt:"click"},{sel:"#tool_move_top",fn:ob,evt:"click",key:o+"shift+up"},
{sel:"#tool_move_bottom",fn:eb,evt:"click",key:o+"shift+down"},{sel:"#tool_move_up",fn:tb,evt:"click",key:[o+"up",true]},{sel:"#tool_move_down",fn:ub,evt:"click",key:[o+"down",true]},{sel:"#tool_topath",fn:Bb,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:ca,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:Nb,evt:"click",key:[o+"D",true]},{sel:"#tool_group",fn:Kb,evt:"click",key:[o+"G",true]},{sel:"#tool_ungroup",fn:Kb,evt:"click",key:o+"shift+G"},{sel:"#tool_unlink_use",fn:Kb,evt:"click"},
{sel:"[id^=tool_align]",fn:Lb,evt:"click"},{sel:"#tool_undo",fn:hb,evt:"click",key:o+"z"},{sel:"#tool_redo",fn:Ja,evt:"click",key:["y",true]},{sel:"#tool_cut",fn:mb,evt:"click",key:[o+"x",true]},{sel:"#tool_copy",fn:jb,evt:"click",key:o+"c"},{sel:"#tool_paste",fn:Ab,evt:"click",key:o+"v"},{sel:"#tool_switch",fn:Ob,evt:"click",key:["x",true]},{sel:"#tool_bold",fn:rb,evt:"mousedown",key:[o+"B",true]},{sel:"#tool_italic",fn:Qa,evt:"mousedown",key:[o+"I",true]},{sel:"#copy_save_done",fn:h,evt:"click"},
{key:"ctrl+left",fn:function(){nb(0,1)}},{key:"ctrl+right",fn:function(){nb(1,1)}},{key:"ctrl+shift+left",fn:function(){nb(0,5)}},{key:"ctrl+shift+right",fn:function(){nb(1,5)}},{key:"shift+O",fn:db},{key:"shift+P",fn:Ya},{key:[o+"+",true],fn:function(){Db(2)}},{key:[o+"-",true],fn:function(){Db(0.5)}},{key:["up",true],fn:function(){ja(0,-1)}},{key:["down",true],fn:function(){ja(0,1)}},{key:["left",true],fn:function(){ja(-1,0)}},{key:["right",true],fn:function(){ja(1,0)}},{key:"shift+up",fn:function(){ja(0,
-10)}},{key:"shift+down",fn:function(){ja(0,10)}},{key:"shift+left",fn:function(){ja(-10,0)}},{key:"shift+right",fn:function(){ja(10,0)}},{key:["alt+up",true],fn:function(){g.cloneSelectedElements(0,-1)}},{key:["alt+down",true],fn:function(){g.cloneSelectedElements(0,1)}},{key:["alt+left",true],fn:function(){g.cloneSelectedElements(-1,0)}},{key:["alt+right",true],fn:function(){g.cloneSelectedElements(1,0)}},{key:["alt+shift+up",true],fn:function(){g.cloneSelectedElements(0,-10)}},{key:["alt+shift+down",
true],fn:function(){g.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){g.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",true],fn:function(){g.cloneSelectedElements(10,0)}},{key:o+"A",fn:function(){g.selectAllInCurrentLayer()}},{key:o+"shift+z",fn:Ja},{key:"esc",fn:Rb}],u={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var C={};a.each(k,function(E,P){if(P.sel){var U=a(P.sel);if(U.length==0)return true;if(P.evt){if(svgedit.browser.isTouch()&&
P.evt==="click")P.evt="mousedown";U[P.evt](P.fn)}if(P.parent&&a(P.parent+"_show").length!=0){var S=a(P.parent);S.length||(S=ma(P.parent.substr(1)));S.append(U);a.isArray(C[P.parent])||(C[P.parent]=[]);C[P.parent].push(P)}}if(P.key){var X=P.fn,aa=false;if(a.isArray(P.key)){S=P.key[0];if(P.key.length>1)aa=P.key[1]}else S=P.key;S+="";svgedit.browser.isMac&&S.indexOf("+")!=-1&&S.split("+")[0]=="ctrl"&&S.replace("ctrl","cmd");a.each(S.split("/"),function(ra,Ta){a(document).bind("keydown",Ta,function(Ba){X();
aa&&Ba.preventDefault();return false})});if(P.sel&&!P.hidekey&&U.attr("title")){var ga=U.attr("title").split("[")[0]+" ("+S+")";u[S]=P.sel;U.parents("#main_menu").length||U.attr("title",ga)}}});qa(C);a(window).bind("keydown","tab",function(E){if(pa==="canvas"){E.preventDefault();Ya()}}).bind("keydown","shift+tab",function(E){if(pa==="canvas"){E.preventDefault();db()}});a("#tool_zoom").dblclick(Za)},setTitles:function(){a.each(u,function(C,E){var P=a(E).parents("#main_menu").length;a(E).each(function(){var U=
P?a(this).text().split(" [")[0]:this.title.split(" [")[0],S="";a.each(C.split("/"),function(X,aa){var ga=aa.split("+"),ra="";if(ga.length>1){ra=ga[0]+"+";aa=ga[1]}S+=(X?"/":"")+ra+(uiStrings["key_"+aa]||aa)});if(P)this.lastChild.textContent=U+" ["+S+"]";else this.title=U+" ["+S+"]"})})},getButtonData:function(C){var E;a.each(k,function(P,U){if(U.sel===C)E=U});return E}}}();v.setAll();c.ready(function(){var k=curConfig.initTool,u=a("#tools_left, #svg_editor .tools_flyout"),C=u.find("#tool_"+k);k=u.find("#"+
true],fn:function(){g.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){g.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",true],fn:function(){g.cloneSelectedElements(10,0)}},{key:o+"A",fn:function(){g.selectAllInCurrentLayer()}},{key:o+"shift+z",fn:Ja},{key:"esc",fn:Rb}],u={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var C={};a.each(k,function(D,P){if(P.sel){var U=a(P.sel);if(U.length==0)return true;if(P.evt){if(svgedit.browser.isTouch()&&
P.evt==="click")P.evt="mousedown";U[P.evt](P.fn)}if(P.parent&&a(P.parent+"_show").length!=0){var S=a(P.parent);S.length||(S=ma(P.parent.substr(1)));S.append(U);a.isArray(C[P.parent])||(C[P.parent]=[]);C[P.parent].push(P)}}if(P.key){var Y=P.fn,aa=false;if(a.isArray(P.key)){S=P.key[0];if(P.key.length>1)aa=P.key[1]}else S=P.key;S+="";svgedit.browser.isMac&&S.indexOf("+")!=-1&&S.split("+")[0]=="ctrl"&&S.replace("ctrl","cmd");a.each(S.split("/"),function(ra,Oa){a(document).bind("keydown",Oa,function(Ba){Y();
aa&&Ba.preventDefault();return false})});if(P.sel&&!P.hidekey&&U.attr("title")){var ga=U.attr("title").split("[")[0]+" ("+S+")";u[S]=P.sel;U.parents("#main_menu").length||U.attr("title",ga)}}});qa(C);a(window).bind("keydown","tab",function(D){if(pa==="canvas"){D.preventDefault();Ya()}}).bind("keydown","shift+tab",function(D){if(pa==="canvas"){D.preventDefault();db()}});a("#tool_zoom").dblclick(Za)},setTitles:function(){a.each(u,function(C,D){var P=a(D).parents("#main_menu").length;a(D).each(function(){var U=
P?a(this).text().split(" [")[0]:this.title.split(" [")[0],S="";a.each(C.split("/"),function(Y,aa){var ga=aa.split("+"),ra="";if(ga.length>1){ra=ga[0]+"+";aa=ga[1]}S+=(Y?"/":"")+ra+(uiStrings["key_"+aa]||aa)});if(P)this.lastChild.textContent=U+" ["+S+"]";else this.title=U+" ["+S+"]"})})},getButtonData:function(C){var D;a.each(k,function(P,U){if(U.sel===C)D=U});return D}}}();v.setAll();c.ready(function(){var k=curConfig.initTool,u=a("#tools_left, #svg_editor .tools_flyout"),C=u.find("#tool_"+k);k=u.find("#"+
k);(C.length?C:k.length?k:a("#tool_select")).click().mouseup();curConfig.wireframe&&a("#tool_wireframe").click();curConfig.showlayers&&toggleSidePanel();a("#rulers").toggle(!!curConfig.showRulers)});a("#canvas_height").dragInput({min:10,max:null,step:10,callback:A,cursor:false});a("#canvas_width").dragInput({min:10,max:null,step:10,callback:A,cursor:false});a("#rect_width").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_height").dragInput({min:0,max:null,step:1,
callback:changeAttribute,cursor:false});a("#ellipse_cx").dragInput({min:0,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_cy").dragInput({min:0,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_rx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_ry").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_height").dragInput({min:0,max:null,step:1,callback:changeAttribute,cursor:false});a("#selected_x").dragInput({min:null,
max:null,step:1,callback:changeAttribute,cursor:false});a("#selected_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_node_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_node_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_width").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_x1").dragInput({min:null,max:null,step:1,callback:changeAttribute,
cursor:false});a("#line_x2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y1").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#line_y2").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#path_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_x").dragInput({min:null,max:null,
step:1,callback:changeAttribute,cursor:false});a("#rect_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#g_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#image_x").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#text_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#text_x").dragInput({min:null,
max:null,step:1,callback:changeAttribute,cursor:false});a("#image_y").dragInput({min:null,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_rx").dragInput({min:0,max:100,step:1,callback:function(k){g.setRectRadius(k.value)},cursor:true});a("#stroke_width").dragInput({min:0,max:99,step:1,callback:function(k){var u=k.value;if(u==0&&W&&["line","polyline"].indexOf(W.nodeName)>=0)u=k.value=1;g.setStrokeWidth(u)},cursor:true,smallStep:0.1,start:1.5});a("#angle").dragInput({min:-180,max:180,
step:1,callback:function(k){g.setRotationAngle(k.value);rotateCursor(k.value);a("#tool_reorient").toggleClass("disabled",k.value==0)},cursor:false});a("#font_size").dragInput({min:1,max:250,step:1,callback:function(k){g.setFontSize(k.value)},cursor:true,stepfunc:function(k,u){var C=k.value-0,E=C+u,P=E>=C;if(u===0)return C;return C>=24?P?Math.round(C*1.1):Math.round(C/1.1):C<=1?P?C*2:C/2:E}});a("#group_opacity").dragInput({min:0,max:100,step:5,callback:function(k,u){if(u==null)u=k.value;a("#group_opacity").val(u);
if(!k||!k.handle)a("#opac_slider").slider("option","value",u);g.setOpacity(u/100)},cursor:true,start:100});a("#blur").dragInput({min:0,max:10,step:0.1,callback:function(k){val=k.value;a("#blur").val(val);window.event.type=="mouseup"?g.setBlur(val,true):g.setBlurNoUndo(val)},cursor:true,start:0});a("#zoom").val(g.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(k){switch(k){case "delete":ta();break;case "cut":mb();break;case "copy":jb();break;case "paste":g.pasteElements();
step:1,callback:function(k){g.setRotationAngle(k.value);rotateCursor(k.value);a("#tool_reorient").toggleClass("disabled",k.value==0)},cursor:false});a("#font_size").dragInput({min:1,max:250,step:1,callback:function(k){g.setFontSize(k.value)},cursor:true,stepfunc:function(k,u){var C=k.value-0,D=C+u,P=D>=C;if(u===0)return C;return C>=24?P?Math.round(C*1.1):Math.round(C/1.1):C<=1?P?C*2:C/2:D}});a("#group_opacity").dragInput({min:0,max:100,step:5,callback:function(k,u){if(u==null)u=k.value;a("#group_opacity").val(u);
if(!k||!k.handle)a("#opac_slider").slider("option","value",u);g.setOpacity(u/100)},cursor:true,start:100});a("#blur").dragInput({min:0,max:10,step:0.1,callback:function(k){val=k.value;a("#blur").val(val);window.event.type=="mouseup"?g.setBlur(val,true):g.setBlurNoUndo(val)},cursor:true,start:0});a("#zoom").val(g.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(k){switch(k){case "delete":ua();break;case "cut":mb();break;case "copy":jb();break;case "paste":g.pasteElements();
break;case "paste_in_place":g.pasteElements("in_place");break;case "group":g.groupSelectedElements();break;case "ungroup":g.ungroupSelectedElement();break;case "move_front":ob();break;case "move_up":wb("Up");break;case "move_down":wb("Down");break;case "move_back":eb();break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(k)&&svgedit.contextmenu.getCustomHandler(k).call()}});a(".contextMenu li").mousedown(function(k){k.preventDefault()});a("#cmenu_canvas li").disableContextMenu();
Y.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=function(){if(T.getUndoStackSize()===0)c.show_save_warning=false;if(!curConfig.no_save_warning&&c.show_save_warning)return uiStrings.notification.unsavedChanges};c.openPrep=function(k){a("#main_menu").hide();T.getUndoStackSize()===0?k(true):a.confirm(uiStrings.notification.QwantToOpen,k)};if(window.FileReader){q=a('<input type="file">').change(function(){var k=this;c.openPrep(function(u){if(u){g.clear();if(k.files.length==1){u=new FileReader;
u.onloadend=function(C){p(C.target.result);F()};u.readAsText(k.files[0])}}})});a("#tool_open").show().prepend(q);q=a('<input type="file">').change(function(){a("#main_menu").hide();if(this.files.length==1){var k=new FileReader;k.onloadend=function(u){g.importSvgString(u.target.result,true);F()};k.readAsText(this.files[0])}});a("#tool_import").show().prepend(q)}for(var F=c.updateCanvas=function(k,u){var C=Q.width(),E=Q.height(),P=C,U=E,S=g.getZoom(),X=a("#svgcanvas"),aa={x:Q[0].scrollLeft+P/2,y:Q[0].scrollTop+
U/2},ga=curConfig.canvas_expansion;C=Math.max(P,g.contentW*S*ga);E=Math.max(U,g.contentH*S*ga);C==P&&E==U?Q.css("overflow","hidden"):Q.css("overflow","scroll");ga=X.height()/2;var ra=X.width()/2;X.width(C).height(E);var Ta=E/2,Ba=C/2,ha=g.updateCanvas(C,E),Sa=Ba/ra;C=C/2-P/2;E=E/2-U/2;if(u){u.x+=ha.x;u.y+=ha.y}else u={x:Ba+(aa.x-ra)*Sa,y:Ta+(aa.y-ga)*Sa};if(k)if(g.contentW>Q.width()){Q[0].scrollLeft=ha.x-10;Q[0].scrollTop=ha.y-10}else{Q[0].scrollLeft=C;Q[0].scrollTop=E}else{Q[0].scrollLeft=u.x-P/
2;Q[0].scrollTop=u.y-U/2}if(curConfig.showRulers){l(X,S);Q.scroll()}},I=[],D=0.1;D<1E5;D*=10){I.push(1*D);I.push(2*D);I.push(5*D)}F(true);try{var G=function(k){if(window.JSON&&JSON.stringify)return JSON.stringify(k);var u=arguments.callee;if(typeof k=="boolean"||typeof k=="number")return k+"";else if(typeof k=="string")return'"'+k.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,function(P){return"\\u"+("0000"+P.charCodeAt(0).toString(16)).slice(-4)})+
'"';else if(k.length){for(var C=0;C<k.length;C++)k[C]=u(k[C]);return"["+k.join(",")+"]"}else{C=[];for(var E in k)C.push(u(E)+":"+u(k[E]));return"{"+C.join(",")+"}"}};window.addEventListener("message",function(k){var u=parseInt(k.data.substr(0,k.data.indexOf(";")));try{k.source.postMessage("SVGe"+u+";"+G(eval(k.data)),"*")}catch(C){k.source.postMessage("SVGe"+u+";error:"+C.message,"*")}},false)}catch(L){window.embed_error=L}a(function(){window.svgCanvas=g;g.ready=svgEditor.ready});c.setLang=function(k,
u){a.pref("lang",k);a("#lang_select").val(k);if(u){g.runExtensions("langChanged",k);Aa();a.each({"#stroke_color":"#tool_stroke .icon_label, #tool_stroke .color_block","#fill_color":"#tool_fill label, #tool_fill .color_block","#linejoin_miter":"#cur_linejoin","#linecap_butt":"#cur_linecap"},function(C,E){a(E).attr("title",a(C)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var f=[];c.ready=function(d){n?d():f.push(d)};
X.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=function(){if(T.getUndoStackSize()===0)c.show_save_warning=false;if(!curConfig.no_save_warning&&c.show_save_warning)return uiStrings.notification.unsavedChanges};c.openPrep=function(k){a("#main_menu").hide();T.getUndoStackSize()===0?k(true):a.confirm(uiStrings.notification.QwantToOpen,k)};if(window.FileReader){q=a('<input type="file">').change(function(){var k=this;c.openPrep(function(u){if(u){g.clear();if(k.files.length==1){u=new FileReader;
u.onloadend=function(C){p(C.target.result);F()};u.readAsText(k.files[0])}}})});a("#tool_open").show().prepend(q);q=a('<input type="file">').change(function(){a("#main_menu").hide();if(this.files.length==1){var k=new FileReader;k.onloadend=function(u){g.importSvgString(u.target.result,true);F()};k.readAsText(this.files[0])}});a("#tool_import").show().prepend(q)}for(var F=c.updateCanvas=function(k,u){var C=Q.width(),D=Q.height(),P=C,U=D,S=g.getZoom(),Y=a("#svgcanvas"),aa={x:Q[0].scrollLeft+P/2,y:Q[0].scrollTop+
U/2},ga=curConfig.canvas_expansion;C=Math.max(P,g.contentW*S*ga);D=Math.max(U,g.contentH*S*ga);C==P&&D==U?Q.css("overflow","hidden"):Q.css("overflow","scroll");ga=Y.height()/2;var ra=Y.width()/2;Y.width(C).height(D);var Oa=D/2,Ba=C/2,ha=g.updateCanvas(C,D),Ta=Ba/ra;C=C/2-P/2;D=D/2-U/2;if(u){u.x+=ha.x;u.y+=ha.y}else u={x:Ba+(aa.x-ra)*Ta,y:Oa+(aa.y-ga)*Ta};if(k)if(g.contentW>Q.width()){Q[0].scrollLeft=ha.x-10;Q[0].scrollTop=ha.y-10}else{Q[0].scrollLeft=C;Q[0].scrollTop=D}else{Q[0].scrollLeft=u.x-P/
2;Q[0].scrollTop=u.y-U/2}if(curConfig.showRulers){l(Y,S);Q.scroll()}},I=[],E=0.1;E<1E5;E*=10){I.push(1*E);I.push(2*E);I.push(5*E)}F(true);try{var G=function(k){if(window.JSON&&JSON.stringify)return JSON.stringify(k);var u=arguments.callee;if(typeof k=="boolean"||typeof k=="number")return k+"";else if(typeof k=="string")return'"'+k.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,function(P){return"\\u"+("0000"+P.charCodeAt(0).toString(16)).slice(-4)})+
'"';else if(k.length){for(var C=0;C<k.length;C++)k[C]=u(k[C]);return"["+k.join(",")+"]"}else{C=[];for(var D in k)C.push(u(D)+":"+u(k[D]));return"{"+C.join(",")+"}"}};window.addEventListener("message",function(k){var u=parseInt(k.data.substr(0,k.data.indexOf(";")));try{k.source.postMessage("SVGe"+u+";"+G(eval(k.data)),"*")}catch(C){k.source.postMessage("SVGe"+u+";error:"+C.message,"*")}},false)}catch(L){window.embed_error=L}a(function(){window.svgCanvas=g;g.ready=svgEditor.ready});c.setLang=function(k,
u){a.pref("lang",k);a("#lang_select").val(k);if(u){g.runExtensions("langChanged",k);Aa();a.each({"#stroke_color":"#tool_stroke .icon_label, #tool_stroke .color_block","#fill_color":"#tool_fill label, #tool_fill .color_block","#linejoin_miter":"#cur_linejoin","#linecap_butt":"#cur_linecap"},function(C,D){a(D).attr("title",a(C)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var f=[];c.ready=function(d){n?d():f.push(d)};
c.runCallbacks=function(){a.each(f,function(){this()});n=true};c.loadFromString=function(d){c.ready(function(){p(d)})};c.loadFromURL=function(d,l){l||(l={});var q=l.cache,B=l.callback;c.ready(function(){a.ajax({url:d,dataType:"text",cache:!!q,success:function(o){p(o,B)},error:function(o,K,T){o.status!=404&&o.responseText?p(o.responseText,B):a.alert(uiStrings.notification.URLloadFail+": \n"+T+"",B)}})})};c.loadFromDataURI=function(d){c.ready(function(){var l=d.substring(26);p(svgedit.utilities.decode64(l))})};
c.addExtension=function(){var d=arguments;a(function(){g&&g.addExtension.apply(this,d)})};return c}(jQuery);$(svgEditor.init)})();$.fn.dragInput=function(a){return this.each(function(){this.repeating=false;this.dragCfg={min:a&&!isNaN(parseFloat(a.min))?Number(a.min):null,max:a&&!isNaN(parseFloat(a.max))?Number(a.max):null,step:a&&Number(a.step)?a.step:1,stepfunc:a&&a.stepfunc?a.stepfunc:false,page:a&&a.page?Number(a.page):10,reset:a&&a.reset?a.reset:this.value,delay:a&&a.delay?Number(a.delay):500,interval:a&&a.interval?Number(a.interval):100,height:70,cursor:a&&a.cursor?Boolean(a.cursor):false,start:a&&a.start?Number(a.start):
0,_btn_width:20,_direction:null,_delay:null,_repeat:null,callback:a&&a.callback?a.callback:null};this.dragCfg.smallStep=a&&a.smallStep?a.smallStep:this.dragCfg.step/2;var p=$(this).parent(),g=$(this),c=this.dragCfg.height,n=this.dragCfg.min,s=this.dragCfg.max,b=this.dragCfg.step,f=s-n>0?(s-n)/b:200,d=f/c*b,l=0,q=this.getAttribute("data-attr"),B=svgEditor.canvas,o=B.getSelectedElems(),K=svgedit.browser.isTouch(),T=f&&this.dragCfg.cursor?$("<div class='draginput_cursor' />").appendTo(p):false;g.attr("readonly",
"readonly");T&&!isNaN(this.dragCfg.start)&&T.css("top",this.dragCfg.start*-1/d+c);this.adjustValue=function(M,J){var Q;Q=isNaN(this.value)?this.dragCfg.reset:$.isFunction(this.dragCfg.stepfunc)?this.dragCfg.stepfunc(this,M):Number((Number(this.value)+Number(M)).toFixed(5));if(s!==null)Q=Math.min(Q,s);if(n!==null)Q=Math.max(Q,n);T&&this.updateCursor(Q);this.value=Q;p.attr("data-value",Q);$.isFunction(this.dragCfg.callback)&&this.dragCfg.callback(this,J)};p.toggleClass("draginput",p.is("label"));this.move=
function(M,J,Q){if(K)M=M.originalEvent.touches[0];if(l===0)l=J;J=(M.pageY-l)*-1;l=M.pageY;Q=J*d;this.adjustValue(Q.toFixed(b<1?1:0))};this.stop=function(){$("body").removeClass("dragging");p.removeClass("active");$(window).unbind("mousemove.draginput touchmove.draginput mouseup.draginput touchend.draginput");l=0;if(o[0]){var M=B.undoMgr.finishUndoableChange();M.isEmpty()||B.undoMgr.addCommandToHistory(M)}this.adjustValue(0)};this.updateCursor=function(){var M=parseFloat(this.value)*-1/d+c;T.css("top",
M)};this.start=function(M){if(K)M=M.originalEvent.touches[0];var J=M.pageY,Q=this.value,Y=this;B.undoMgr.beginUndoableChange(q,o);$("body").addClass("dragging");p.addClass("active");$(window).bind("mousemove.draginput touchmove.draginput",function(O){Y.move(O,J,parseFloat(Q))});$(window).bind("mouseup.draginput touchend.draginput",function(){Y.stop()})};$(this).attr("readonly","readonly").attr("data-scale",d).attr("data-domain",c).attr("data-cursor",T!=false).bind("mousedown touchstart",function(M){this.blur();
this.start(M)}).bind("dblclick taphold",function(){this.removeAttribute("readonly","readonly");this.focus();this.select()}).keydown(function(M){switch(M.keyCode){case 13:this.adjustValue(0);this.blur()}}).focus(function(){this.getAttribute("readonly")==="readonly"&&this.blur()}).blur(function(){this.setAttribute("readonly","readonly")}).bind("mousewheel",function(M,J,Q,Y){if(Y>0)this.adjustValue(this.dragCfg.step);else Y<0&&this.adjustValue(-this.dragCfg.step);M.preventDefault()})})};
M)};this.start=function(M){if(K)M=M.originalEvent.touches[0];var J=M.pageY,Q=this.value,X=this;B.undoMgr.beginUndoableChange(q,o);$("body").addClass("dragging");p.addClass("active");$(window).bind("mousemove.draginput touchmove.draginput",function(O){X.move(O,J,parseFloat(Q))});$(window).bind("mouseup.draginput touchend.draginput",function(){X.stop()})};$(this).attr("readonly","readonly").attr("data-scale",d).attr("data-domain",c).attr("data-cursor",T!=false).bind("mousedown touchstart",function(M){this.blur();
this.start(M)}).bind("dblclick taphold",function(){this.removeAttribute("readonly","readonly");this.focus();this.select()}).keydown(function(M){switch(M.keyCode){case 13:this.adjustValue(0);this.blur()}}).focus(function(){this.getAttribute("readonly")==="readonly"&&this.blur()}).blur(function(){this.setAttribute("readonly","readonly")}).bind("mousewheel",function(M,J,Q,X){if(X>0)this.adjustValue(this.dragCfg.step);else X<0&&this.adjustValue(-this.dragCfg.step);M.preventDefault()})})};
$.fn.dragInput.updateCursor=function(a){var p=parseFloat(a.value),g=parseFloat(a.getAttribute("data-scale")),c=parseFloat(a.getAttribute("data-domain"));p=p*-1/g+c+"px";a=a.parentNode.lastChild;if(a.className=="draginput_cursor")a.style.top=p};svgedit=svgedit||{};
(function(){var a=this;if(!svgedit.contextmenu)svgedit.contextmenu={};a.contextMenuExtensions={};svgEditor.ready(function(){for(menuItem in contextMenuExtensions){var p=contextMenuExtensions[menuItem];Object.keys(a.contextMenuExtensions).length==0&&$("#cmenu_canvas").append("<li class='separator'>");var g=p.shortcut||"";$("#cmenu_canvas").append("<li class='disabled'><a href='#"+p.id+"'>"+p.label+"<span class='shortcut'>"+g+"</span></a></li>")}});svgedit.contextmenu.resetCustomMenus=function(){a.contextMenuExtensions=
{}};svgedit.contextmenu.add=function(p){if(p&&p.id&&p.label&&p.action&&typeof p.action=="function")if(p.id in a.contextMenuExtensions)console.error('Cannot add extension "'+p.id+'", an extension by that name already exists"');else{console.log("Registed contextmenu item: {id:"+p.id+", label:"+p.label+"}");a.contextMenuExtensions[p.id]=p}else console.error("Menu items must be defined and have at least properties: id, label, action, where action must be a function")};svgedit.contextmenu.hasCustomHandler=
@ -557,9 +557,9 @@ c.axis!="x")g.overflowOffset.top+g.scrollParent[0].offsetHeight-p.pageY<c.scroll
(g.scrollParent[0].scrollLeft=n=g.scrollParent[0].scrollLeft-c.scrollSpeed)}else{if(!c.axis||c.axis!="x")p.pageY-a(document).scrollTop()<c.scrollSensitivity?n=a(document).scrollTop(a(document).scrollTop()-c.scrollSpeed):a(window).height()-(p.pageY-a(document).scrollTop())<c.scrollSensitivity&&(n=a(document).scrollTop(a(document).scrollTop()+c.scrollSpeed));if(!c.axis||c.axis!="y")p.pageX-a(document).scrollLeft()<c.scrollSensitivity?n=a(document).scrollLeft(a(document).scrollLeft()-c.scrollSpeed):
a(window).width()-(p.pageX-a(document).scrollLeft())<c.scrollSensitivity&&(n=a(document).scrollLeft(a(document).scrollLeft()+c.scrollSpeed))}n!==false&&a.ui.ddmanager&&!c.dropBehaviour&&a.ui.ddmanager.prepareOffsets(g,p)}});a.ui.plugin.add("draggable","snap",{start:function(){var p=a(this).data("draggable"),g=p.options;p.snapElements=[];a(g.snap.constructor!=String?g.snap.items||":data(draggable)":g.snap).each(function(){var c=a(this),n=c.offset();this!=p.element[0]&&p.snapElements.push({item:this,
width:c.outerWidth(),height:c.outerHeight(),top:n.top,left:n.left})})},drag:function(p,g){for(var c=a(this).data("draggable"),n=c.options,s=n.snapTolerance,b=g.offset.left,f=b+c.helperProportions.width,d=g.offset.top,l=d+c.helperProportions.height,q=c.snapElements.length-1;q>=0;q--){var B=c.snapElements[q].left,o=B+c.snapElements[q].width,K=c.snapElements[q].top,T=K+c.snapElements[q].height;if(B-s<b&&b<o+s&&K-s<d&&d<T+s||B-s<b&&b<o+s&&K-s<l&&l<T+s||B-s<f&&f<o+s&&K-s<d&&d<T+s||B-s<f&&f<o+s&&K-s<l&&
l<T+s){if(n.snapMode!="inner"){var M=Math.abs(K-l)<=s,J=Math.abs(T-d)<=s,Q=Math.abs(B-f)<=s,Y=Math.abs(o-b)<=s;M&&(g.position.top=c._convertPositionTo("relative",{top:K-c.helperProportions.height,left:0}).top-c.margins.top);J&&(g.position.top=c._convertPositionTo("relative",{top:T,left:0}).top-c.margins.top);Q&&(g.position.left=c._convertPositionTo("relative",{top:0,left:B-c.helperProportions.width}).left-c.margins.left);Y&&(g.position.left=c._convertPositionTo("relative",{top:0,left:o}).left-c.margins.left)}var O=
M||J||Q||Y;if(n.snapMode!="outer"){M=Math.abs(K-d)<=s;J=Math.abs(T-l)<=s;Q=Math.abs(B-b)<=s;Y=Math.abs(o-f)<=s;M&&(g.position.top=c._convertPositionTo("relative",{top:K,left:0}).top-c.margins.top);J&&(g.position.top=c._convertPositionTo("relative",{top:T-c.helperProportions.height,left:0}).top-c.margins.top);Q&&(g.position.left=c._convertPositionTo("relative",{top:0,left:B}).left-c.margins.left);Y&&(g.position.left=c._convertPositionTo("relative",{top:0,left:o-c.helperProportions.width}).left-c.margins.left)}!c.snapElements[q].snapping&&
(M||J||Q||Y||O)&&c.options.snap.snap&&c.options.snap.snap.call(c.element,p,a.extend(c._uiHash(),{snapItem:c.snapElements[q].item}));c.snapElements[q].snapping=M||J||Q||Y||O}else{c.snapElements[q].snapping&&c.options.snap.release&&c.options.snap.release.call(c.element,p,a.extend(c._uiHash(),{snapItem:c.snapElements[q].item}));c.snapElements[q].snapping=false}}}});a.ui.plugin.add("draggable","stack",{start:function(){var p=a(this).data("draggable").options;p=a.makeArray(a(p.stack)).sort(function(c,
l<T+s){if(n.snapMode!="inner"){var M=Math.abs(K-l)<=s,J=Math.abs(T-d)<=s,Q=Math.abs(B-f)<=s,X=Math.abs(o-b)<=s;M&&(g.position.top=c._convertPositionTo("relative",{top:K-c.helperProportions.height,left:0}).top-c.margins.top);J&&(g.position.top=c._convertPositionTo("relative",{top:T,left:0}).top-c.margins.top);Q&&(g.position.left=c._convertPositionTo("relative",{top:0,left:B-c.helperProportions.width}).left-c.margins.left);X&&(g.position.left=c._convertPositionTo("relative",{top:0,left:o}).left-c.margins.left)}var O=
M||J||Q||X;if(n.snapMode!="outer"){M=Math.abs(K-d)<=s;J=Math.abs(T-l)<=s;Q=Math.abs(B-b)<=s;X=Math.abs(o-f)<=s;M&&(g.position.top=c._convertPositionTo("relative",{top:K,left:0}).top-c.margins.top);J&&(g.position.top=c._convertPositionTo("relative",{top:T-c.helperProportions.height,left:0}).top-c.margins.top);Q&&(g.position.left=c._convertPositionTo("relative",{top:0,left:B}).left-c.margins.left);X&&(g.position.left=c._convertPositionTo("relative",{top:0,left:o-c.helperProportions.width}).left-c.margins.left)}!c.snapElements[q].snapping&&
(M||J||Q||X||O)&&c.options.snap.snap&&c.options.snap.snap.call(c.element,p,a.extend(c._uiHash(),{snapItem:c.snapElements[q].item}));c.snapElements[q].snapping=M||J||Q||X||O}else{c.snapElements[q].snapping&&c.options.snap.release&&c.options.snap.release.call(c.element,p,a.extend(c._uiHash(),{snapItem:c.snapElements[q].item}));c.snapElements[q].snapping=false}}}});a.ui.plugin.add("draggable","stack",{start:function(){var p=a(this).data("draggable").options;p=a.makeArray(a(p.stack)).sort(function(c,
n){return(parseInt(a(c).css("zIndex"),10)||0)-(parseInt(a(n).css("zIndex"),10)||0)});if(p.length){var g=parseInt(p[0].style.zIndex)||0;a(p).each(function(c){this.style.zIndex=g+c});this[0].style.zIndex=g+p.length}}});a.ui.plugin.add("draggable","zIndex",{start:function(p,g){var c=a(g.helper),n=a(this).data("draggable").options;c.css("zIndex")&&(n._zIndex=c.css("zIndex"));c.css("zIndex",n.zIndex)},stop:function(p,g){var c=a(this).data("draggable").options;c._zIndex&&a(g.helper).css("zIndex",c._zIndex)}})})(jQuery);
(function(a){a.widget("ui.slider",a.ui.mouse,{widgetEventPrefix:"slide",options:{animate:false,distance:0,max:100,min:0,orientation:"horizontal",range:false,step:1,value:0,values:null},_create:function(){var p=this,g=this.options,c=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),n=g.values&&g.values.length||1,s=[];this._mouseSliding=this._keySliding=false;this._animateOff=true;this._handleIndex=null;this._detectOrientation();this._mouseInit();this.element.addClass("ui-slider ui-slider-"+
this.orientation+" ui-widget ui-widget-content ui-corner-all"+(g.disabled?" ui-slider-disabled ui-disabled":""));this.range=a([]);g.range&&(g.range===true&&(g.values||(g.values=[this._valueMin(),this._valueMin()]),g.values.length&&g.values.length!==2&&(g.values=[g.values[0],g.values[0]])),this.range=a("<div></div>").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(g.range==="min"||g.range==="max"?" ui-slider-range-"+g.range:"")));for(var b=c.length;b<n;b+=1)s.push("<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>");
@ -579,55 +579,55 @@ this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui
return g=this._trimAlignValue(g)}g=this.options.values.slice();for(c=0;c<g.length;c+=1)g[c]=this._trimAlignValue(g[c]);return g},_trimAlignValue:function(p){if(p<=this._valueMin())return this._valueMin();if(p>=this._valueMax())return this._valueMax();var g=this.options.step>0?this.options.step:1,c=(p-this._valueMin())%g;p=p-c;Math.abs(c)*2>=g&&(p+=c>0?g:-g);return parseFloat(p.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var p=
this.options.range,g=this.options,c=this,n=this._animateOff?false:g.animate,s,b={},f,d,l,q;this.options.values&&this.options.values.length?this.handles.each(function(B){s=(c.values(B)-c._valueMin())/(c._valueMax()-c._valueMin())*100;b[c.orientation==="horizontal"?"left":"bottom"]=s+"%";a(this).stop(1,1)[n?"animate":"css"](b,g.animate);c.options.range===true&&(c.orientation==="horizontal"?(B===0&&c.range.stop(1,1)[n?"animate":"css"]({left:s+"%"},g.animate),B===1&&c.range[n?"animate":"css"]({width:s-
f+"%"},{queue:false,duration:g.animate})):(B===0&&c.range.stop(1,1)[n?"animate":"css"]({bottom:s+"%"},g.animate),B===1&&c.range[n?"animate":"css"]({height:s-f+"%"},{queue:false,duration:g.animate})));f=s}):(d=this.value(),l=this._valueMin(),q=this._valueMax(),s=q!==l?(d-l)/(q-l)*100:0,b[c.orientation==="horizontal"?"left":"bottom"]=s+"%",this.handle.stop(1,1)[n?"animate":"css"](b,g.animate),p==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[n?"animate":"css"]({width:s+"%"},g.animate),
p==="max"&&this.orientation==="horizontal"&&this.range[n?"animate":"css"]({width:100-s+"%"},{queue:false,duration:g.animate}),p==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[n?"animate":"css"]({height:s+"%"},g.animate),p==="max"&&this.orientation==="vertical"&&this.range[n?"animate":"css"]({height:100-s+"%"},{queue:false,duration:g.animate}))}});a.extend(a.ui.slider,{version:"1.8.17"})})(jQuery);(function(a){Math.precision=function(b,f){if(f===undefined)f=0;return Math.round(b*Math.pow(10,f))/Math.pow(10,f)};var p=function(b,f){var d=this,l=b.find("img:first"),q=0,B=100,o=100,K=0,T=100,M=100,J=0,Q=0,Y,O,ia=[],pa=function(V){for(var Z=0;Z<ia.length;Z++)ia[Z].call(d,d,V)},fa=function(V){var Z=b.offset();Y={l:Z.left|0,t:Z.top|0};clearTimeout(O);O=setTimeout(function(){sa.call(d,V)},0);a(document).bind("mousemove",ba).bind("mouseup",W);V.preventDefault()},ba=function(V){clearTimeout(O);O=setTimeout(function(){sa.call(d,
V)},0);V.stopPropagation();V.preventDefault();return false},W=function(V){a(document).unbind("mouseup",W).unbind("mousemove",ba);V.stopPropagation();V.preventDefault();return false},sa=function(V){var Z=V.pageX-Y.l;V=V.pageY-Y.t;var oa=b.w,qa=b.h;if(Z<0)Z=0;else if(Z>oa)Z=oa;if(V<0)V=0;else if(V>qa)V=qa;ka.call(d,"xy",{x:Z/oa*o+q,y:V/qa*M+K})},ka=function(V,Z,oa){if(Z===undefined){if(V===undefined||V==null)V="xy";switch(V.toLowerCase()){case "x":return J;case "y":return Q;default:return{x:J,y:Q}}}if(!(oa!=
p==="max"&&this.orientation==="horizontal"&&this.range[n?"animate":"css"]({width:100-s+"%"},{queue:false,duration:g.animate}),p==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[n?"animate":"css"]({height:s+"%"},g.animate),p==="max"&&this.orientation==="vertical"&&this.range[n?"animate":"css"]({height:100-s+"%"},{queue:false,duration:g.animate}))}});a.extend(a.ui.slider,{version:"1.8.17"})})(jQuery);(function(a){Math.precision=function(b,f){if(f===undefined)f=0;return Math.round(b*Math.pow(10,f))/Math.pow(10,f)};var p=function(b,f){var d=this,l=b.find("img:first"),q=0,B=100,o=100,K=0,T=100,M=100,J=0,Q=0,X,O,ia=[],pa=function(V){for(var Z=0;Z<ia.length;Z++)ia[Z].call(d,d,V)},fa=function(V){var Z=b.offset();X={l:Z.left|0,t:Z.top|0};clearTimeout(O);O=setTimeout(function(){sa.call(d,V)},0);a(document).bind("mousemove",ba).bind("mouseup",W);V.preventDefault()},ba=function(V){clearTimeout(O);O=setTimeout(function(){sa.call(d,
V)},0);V.stopPropagation();V.preventDefault();return false},W=function(V){a(document).unbind("mouseup",W).unbind("mousemove",ba);V.stopPropagation();V.preventDefault();return false},sa=function(V){var Z=V.pageX-X.l;V=V.pageY-X.t;var oa=b.w,qa=b.h;if(Z<0)Z=0;else if(Z>oa)Z=oa;if(V<0)V=0;else if(V>qa)V=qa;ka.call(d,"xy",{x:Z/oa*o+q,y:V/qa*M+K})},ka=function(V,Z,oa){if(Z===undefined){if(V===undefined||V==null)V="xy";switch(V.toLowerCase()){case "x":return J;case "y":return Q;default:return{x:J,y:Q}}}if(!(oa!=
null&&oa==d)){var qa=false,ma,na;if(V==null)V="xy";switch(V.toLowerCase()){case "x":ma=Z&&(Z.x&&Z.x|0||Z|0)||0;break;case "y":na=Z&&(Z.y&&Z.y|0||Z|0)||0;break;default:ma=Z&&Z.x&&Z.x|0||0;na=Z&&Z.y&&Z.y|0||0}if(ma!=null){if(ma<q)ma=q;else if(ma>B)ma=B;if(J!=ma){J=ma;qa=true}}if(na!=null){if(na<K)na=K;else if(na>T)na=T;if(Q!=na){Q=na;qa=true}}qa&&pa.call(d,oa||d)}},da=function(V){a.isFunction(V)&&ia.push(V)};a.extend(true,d,{val:ka,range:function(V,Z){if(Z===undefined){if(V===undefined||V==null)V="all";
switch(V.toLowerCase()){case "minx":return q;case "maxx":return B;case "rangex":return{minX:q,maxX:B,rangeX:o};case "miny":return K;case "maxy":return T;case "rangey":return{minY:K,maxY:T,rangeY:M};default:return{minX:q,maxX:B,rangeX:o,minY:K,maxY:T,rangeY:M}}}var oa,qa,ma,na;if(V==null)V="all";switch(V.toLowerCase()){case "minx":oa=Z&&(Z.minX&&Z.minX|0||Z|0)||0;break;case "maxx":qa=Z&&(Z.maxX&&Z.maxX|0||Z|0)||0;break;case "rangex":oa=Z&&Z.minX&&Z.minX|0||0;qa=Z&&Z.maxX&&Z.maxX|0||0;break;case "miny":ma=
Z&&(Z.minY&&Z.minY|0||Z|0)||0;break;case "maxy":na=Z&&(Z.maxY&&Z.maxY|0||Z|0)||0;break;case "rangey":ma=Z&&Z.minY&&Z.minY|0||0;na=Z&&Z.maxY&&Z.maxY|0||0;break;default:oa=Z&&Z.minX&&Z.minX|0||0;qa=Z&&Z.maxX&&Z.maxX|0||0;ma=Z&&Z.minY&&Z.minY|0||0;na=Z&&Z.maxY&&Z.maxY|0||0}if(oa!=null&&q!=oa){q=oa;o=B-q}if(qa!=null&&B!=qa){B=qa;o=B-q}if(ma!=null&&K!=ma){K=ma;M=T-K}if(na!=null&&T!=na){T=na;M=T-K}},bind:da,unbind:function(V){if(a.isFunction(V))for(var Z;(Z=a.inArray(V,ia))!=-1;)ia.splice(Z,1)},destroy:function(){a(document).unbind("mouseup",
W).unbind("mousemove",ba);b.unbind("mousedown",fa);ia=l=b=null}});l.src=f.arrow&&f.arrow.image;l.w=f.arrow&&f.arrow.width||l.width();l.h=f.arrow&&f.arrow.height||l.height();b.w=f.map&&f.map.width||b.width();b.h=f.map&&f.map.height||b.height();b.bind("mousedown",fa);da.call(d,function(){var V=0,Z=0,oa=b.w,qa=b.h,ma=l.w,na=l.h;setTimeout(function(){if(o>0)V=J==B?oa:J/o*oa|0;if(M>0)Z=Q==T?qa:Q/M*qa|0;if(ma>=oa)V=(oa>>1)-(ma>>1);else V-=ma>>1;if(na>=qa)Z=(qa>>1)-(na>>1);else Z-=na>>1;l.css({left:V+"px",
top:Z+"px"})},0)})},g=function(b,f,d,l){var q=this;b=b.find("td.Text input");var B=b.eq(3),o=b.eq(4),K=b.eq(5),T=b.length>7?b.eq(6):null,M=b.eq(0),J=b.eq(1),Q=b.eq(2),Y=b.eq(b.length>7?7:6),O=b.length>7?b.eq(8):null,ia=function(ka){if(!(ka.target.value==""&&ka.target!=Y.get(0)&&(d!=null&&ka.target!=d.get(0)||d==null))){if(!ba(ka))return ka;switch(ka.target){case B.get(0):switch(ka.keyCode){case 38:B.val(W.call(q,(B.val()<<0)+1,0,255));f.val("r",B.val(),ka.target);return false;case 40:B.val(W.call(q,
top:Z+"px"})},0)})},g=function(b,f,d,l){var q=this;b=b.find("td.Text input");var B=b.eq(3),o=b.eq(4),K=b.eq(5),T=b.length>7?b.eq(6):null,M=b.eq(0),J=b.eq(1),Q=b.eq(2),X=b.eq(b.length>7?7:6),O=b.length>7?b.eq(8):null,ia=function(ka){if(!(ka.target.value==""&&ka.target!=X.get(0)&&(d!=null&&ka.target!=d.get(0)||d==null))){if(!ba(ka))return ka;switch(ka.target){case B.get(0):switch(ka.keyCode){case 38:B.val(W.call(q,(B.val()<<0)+1,0,255));f.val("r",B.val(),ka.target);return false;case 40:B.val(W.call(q,
(B.val()<<0)-1,0,255));f.val("r",B.val(),ka.target);return false}break;case o.get(0):switch(ka.keyCode){case 38:o.val(W.call(q,(o.val()<<0)+1,0,255));f.val("g",o.val(),ka.target);return false;case 40:o.val(W.call(q,(o.val()<<0)-1,0,255));f.val("g",o.val(),ka.target);return false}break;case K.get(0):switch(ka.keyCode){case 38:K.val(W.call(q,(K.val()<<0)+1,0,255));f.val("b",K.val(),ka.target);return false;case 40:K.val(W.call(q,(K.val()<<0)-1,0,255));f.val("b",K.val(),ka.target);return false}break;
case T&&T.get(0):switch(ka.keyCode){case 38:T.val(W.call(q,parseFloat(T.val())+1,0,100));f.val("a",Math.precision(T.val()*255/100,l),ka.target);return false;case 40:T.val(W.call(q,parseFloat(T.val())-1,0,100));f.val("a",Math.precision(T.val()*255/100,l),ka.target);return false}break;case M.get(0):switch(ka.keyCode){case 38:M.val(W.call(q,(M.val()<<0)+1,0,360));f.val("h",M.val(),ka.target);return false;case 40:M.val(W.call(q,(M.val()<<0)-1,0,360));f.val("h",M.val(),ka.target);return false}break;case J.get(0):switch(ka.keyCode){case 38:J.val(W.call(q,
(J.val()<<0)+1,0,100));f.val("s",J.val(),ka.target);return false;case 40:J.val(W.call(q,(J.val()<<0)-1,0,100));f.val("s",J.val(),ka.target);return false}break;case Q.get(0):switch(ka.keyCode){case 38:Q.val(W.call(q,(Q.val()<<0)+1,0,100));f.val("v",Q.val(),ka.target);return false;case 40:Q.val(W.call(q,(Q.val()<<0)-1,0,100));f.val("v",Q.val(),ka.target);return false}}}},pa=function(ka){if(!(ka.target.value==""&&ka.target!=Y.get(0)&&(d!=null&&ka.target!=d.get(0)||d==null))){if(!ba(ka))return ka;switch(ka.target){case B.get(0):B.val(W.call(q,
(J.val()<<0)+1,0,100));f.val("s",J.val(),ka.target);return false;case 40:J.val(W.call(q,(J.val()<<0)-1,0,100));f.val("s",J.val(),ka.target);return false}break;case Q.get(0):switch(ka.keyCode){case 38:Q.val(W.call(q,(Q.val()<<0)+1,0,100));f.val("v",Q.val(),ka.target);return false;case 40:Q.val(W.call(q,(Q.val()<<0)-1,0,100));f.val("v",Q.val(),ka.target);return false}}}},pa=function(ka){if(!(ka.target.value==""&&ka.target!=X.get(0)&&(d!=null&&ka.target!=d.get(0)||d==null))){if(!ba(ka))return ka;switch(ka.target){case B.get(0):B.val(W.call(q,
B.val(),0,255));f.val("r",B.val(),ka.target);break;case o.get(0):o.val(W.call(q,o.val(),0,255));f.val("g",o.val(),ka.target);break;case K.get(0):K.val(W.call(q,K.val(),0,255));f.val("b",K.val(),ka.target);break;case T&&T.get(0):T.val(W.call(q,T.val(),0,100));f.val("a",Math.precision(T.val()*255/100,l),ka.target);break;case M.get(0):M.val(W.call(q,M.val(),0,360));f.val("h",M.val(),ka.target);break;case J.get(0):J.val(W.call(q,J.val(),0,100));f.val("s",J.val(),ka.target);break;case Q.get(0):Q.val(W.call(q,
Q.val(),0,100));f.val("v",Q.val(),ka.target);break;case Y.get(0):Y.val(Y.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));d&&d.val(Y.val());f.val("hex",Y.val()!=""?Y.val():null,ka.target);break;case d&&d.get(0):d.val(d.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));Y.val(d.val());f.val("hex",d.val()!=""?d.val():null,ka.target);break;case O&&O.get(0):O.val(O.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,2));f.val("a",O.val()!=null?parseInt(O.val(),16):
null,ka.target)}}},fa=function(ka){if(f.val()!=null)switch(ka.target){case B.get(0):B.val(f.val("r"));break;case o.get(0):o.val(f.val("g"));break;case K.get(0):K.val(f.val("b"));break;case T&&T.get(0):T.val(Math.precision(f.val("a")*100/255,l));break;case M.get(0):M.val(f.val("h"));break;case J.get(0):J.val(f.val("s"));break;case Q.get(0):Q.val(f.val("v"));break;case Y.get(0):case d&&d.get(0):Y.val(f.val("hex"));d&&d.val(f.val("hex"));break;case O&&O.get(0):O.val(f.val("ahex").substring(6))}},ba=
Q.val(),0,100));f.val("v",Q.val(),ka.target);break;case X.get(0):X.val(X.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));d&&d.val(X.val());f.val("hex",X.val()!=""?X.val():null,ka.target);break;case d&&d.get(0):d.val(d.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));X.val(d.val());f.val("hex",d.val()!=""?d.val():null,ka.target);break;case O&&O.get(0):O.val(O.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,2));f.val("a",O.val()!=null?parseInt(O.val(),16):
null,ka.target)}}},fa=function(ka){if(f.val()!=null)switch(ka.target){case B.get(0):B.val(f.val("r"));break;case o.get(0):o.val(f.val("g"));break;case K.get(0):K.val(f.val("b"));break;case T&&T.get(0):T.val(Math.precision(f.val("a")*100/255,l));break;case M.get(0):M.val(f.val("h"));break;case J.get(0):J.val(f.val("s"));break;case Q.get(0):Q.val(f.val("v"));break;case X.get(0):case d&&d.get(0):X.val(f.val("hex"));d&&d.val(f.val("hex"));break;case O&&O.get(0):O.val(f.val("ahex").substring(6))}},ba=
function(ka){switch(ka.keyCode){case 9:case 16:case 29:case 37:case 39:return false;case "c".charCodeAt():case "v".charCodeAt():if(ka.ctrlKey)return false}return true},W=function(ka,da,V){if(ka==""||isNaN(ka))return da;if(ka>V)return V;if(ka<da)return da;return ka},sa=function(ka,da){var V=ka.val("all");if(da!=B.get(0))B.val(V!=null?V.r:"");if(da!=o.get(0))o.val(V!=null?V.g:"");if(da!=K.get(0))K.val(V!=null?V.b:"");if(T&&da!=T.get(0))T.val(V!=null?Math.precision(V.a*100/255,l):"");if(da!=M.get(0))M.val(V!=
null?V.h:"");if(da!=J.get(0))J.val(V!=null?V.s:"");if(da!=Q.get(0))Q.val(V!=null?V.v:"");if(da!=Y.get(0)&&(d&&da!=d.get(0)||!d))Y.val(V!=null?V.hex:"");if(d&&da!=d.get(0)&&da!=Y.get(0))d.val(V!=null?V.hex:"");if(O&&da!=O.get(0))O.val(V!=null?V.ahex.substring(6):"")};a.extend(true,q,{destroy:function(){B.add(o).add(K).add(T).add(M).add(J).add(Q).add(Y).add(d).add(O).unbind("keyup",pa).unbind("blur",fa);B.add(o).add(K).add(T).add(M).add(J).add(Q).unbind("keydown",ia);f.unbind(sa);O=Y=Q=J=M=T=K=o=B=
null}});B.add(o).add(K).add(T).add(M).add(J).add(Q).add(Y).add(d).add(O).bind("keyup",pa).bind("blur",fa);B.add(o).add(K).add(T).add(M).add(J).add(Q).bind("keydown",ia);f.bind(sa)};a.jPicker={List:[],Color:function(b){var f=this,d,l,q,B,o,K,T,M=[],J=function(Y){for(var O=0;O<M.length;O++)M[O].call(f,f,Y)},Q=function(Y,O,ia){if(O===undefined){if(Y===undefined||Y==null||Y=="")Y="all";if(d==null)return null;switch(Y.toLowerCase()){case "ahex":return s.rgbaToHex({r:d,g:l,b:q,a:B});case "hex":return Q("ahex").substring(0,
6);case "all":return{r:d,g:l,b:q,a:B,h:o,s:K,v:T,hex:Q.call(f,"hex"),ahex:Q.call(f,"ahex")};default:O={};for(var pa=0;pa<Y.length;pa++)switch(Y.charAt(pa)){case "r":if(Y.length==1)O=d;else O.r=d;break;case "g":if(Y.length==1)O=l;else O.g=l;break;case "b":if(Y.length==1)O=q;else O.b=q;break;case "a":if(Y.length==1)O=B;else O.a=B;break;case "h":if(Y.length==1)O=o;else O.h=o;break;case "s":if(Y.length==1)O=K;else O.s=K;break;case "v":if(Y.length==1)O=T;else O.v=T}return O=={}?Q.call(f,"all"):O}}if(!(ia!=
null&&ia==f)){var fa=false;if(Y==null)Y="";if(O==null){if(d!=null){d=null;fa=true}if(l!=null){l=null;fa=true}if(q!=null){q=null;fa=true}if(B!=null){B=null;fa=true}if(o!=null){o=null;fa=true}if(K!=null){K=null;fa=true}if(T!=null){T=null;fa=true}fa&&J.call(f,ia||f)}else switch(Y.toLowerCase()){case "ahex":case "hex":O=s.hexToRgba(O&&(O.ahex||O.hex)||O||"00000000");Q.call(f,"rgba",{r:O.r,g:O.g,b:O.b,a:Y=="ahex"?O.a:B!=null?B:255},ia);break;default:if(O&&(O.ahex!=null||O.hex!=null)){Q.call(f,"ahex",O.ahex||
O.hex||"00000000",ia);break}var ba={},W=false,sa=false;if(O.r!==undefined&&!Y.indexOf("r")==-1)Y+="r";if(O.g!==undefined&&!Y.indexOf("g")==-1)Y+="g";if(O.b!==undefined&&!Y.indexOf("b")==-1)Y+="b";if(O.a!==undefined&&!Y.indexOf("a")==-1)Y+="a";if(O.h!==undefined&&!Y.indexOf("h")==-1)Y+="h";if(O.s!==undefined&&!Y.indexOf("s")==-1)Y+="s";if(O.v!==undefined&&!Y.indexOf("v")==-1)Y+="v";for(pa=0;pa<Y.length;pa++)switch(Y.charAt(pa)){case "r":if(sa)continue;W=true;ba.r=O&&O.r&&O.r|0||O&&O|0||0;if(ba.r<0)ba.r=
null?V.h:"");if(da!=J.get(0))J.val(V!=null?V.s:"");if(da!=Q.get(0))Q.val(V!=null?V.v:"");if(da!=X.get(0)&&(d&&da!=d.get(0)||!d))X.val(V!=null?V.hex:"");if(d&&da!=d.get(0)&&da!=X.get(0))d.val(V!=null?V.hex:"");if(O&&da!=O.get(0))O.val(V!=null?V.ahex.substring(6):"")};a.extend(true,q,{destroy:function(){B.add(o).add(K).add(T).add(M).add(J).add(Q).add(X).add(d).add(O).unbind("keyup",pa).unbind("blur",fa);B.add(o).add(K).add(T).add(M).add(J).add(Q).unbind("keydown",ia);f.unbind(sa);O=X=Q=J=M=T=K=o=B=
null}});B.add(o).add(K).add(T).add(M).add(J).add(Q).add(X).add(d).add(O).bind("keyup",pa).bind("blur",fa);B.add(o).add(K).add(T).add(M).add(J).add(Q).bind("keydown",ia);f.bind(sa)};a.jPicker={List:[],Color:function(b){var f=this,d,l,q,B,o,K,T,M=[],J=function(X){for(var O=0;O<M.length;O++)M[O].call(f,f,X)},Q=function(X,O,ia){if(O===undefined){if(X===undefined||X==null||X=="")X="all";if(d==null)return null;switch(X.toLowerCase()){case "ahex":return s.rgbaToHex({r:d,g:l,b:q,a:B});case "hex":return Q("ahex").substring(0,
6);case "all":return{r:d,g:l,b:q,a:B,h:o,s:K,v:T,hex:Q.call(f,"hex"),ahex:Q.call(f,"ahex")};default:O={};for(var pa=0;pa<X.length;pa++)switch(X.charAt(pa)){case "r":if(X.length==1)O=d;else O.r=d;break;case "g":if(X.length==1)O=l;else O.g=l;break;case "b":if(X.length==1)O=q;else O.b=q;break;case "a":if(X.length==1)O=B;else O.a=B;break;case "h":if(X.length==1)O=o;else O.h=o;break;case "s":if(X.length==1)O=K;else O.s=K;break;case "v":if(X.length==1)O=T;else O.v=T}return O=={}?Q.call(f,"all"):O}}if(!(ia!=
null&&ia==f)){var fa=false;if(X==null)X="";if(O==null){if(d!=null){d=null;fa=true}if(l!=null){l=null;fa=true}if(q!=null){q=null;fa=true}if(B!=null){B=null;fa=true}if(o!=null){o=null;fa=true}if(K!=null){K=null;fa=true}if(T!=null){T=null;fa=true}fa&&J.call(f,ia||f)}else switch(X.toLowerCase()){case "ahex":case "hex":O=s.hexToRgba(O&&(O.ahex||O.hex)||O||"00000000");Q.call(f,"rgba",{r:O.r,g:O.g,b:O.b,a:X=="ahex"?O.a:B!=null?B:255},ia);break;default:if(O&&(O.ahex!=null||O.hex!=null)){Q.call(f,"ahex",O.ahex||
O.hex||"00000000",ia);break}var ba={},W=false,sa=false;if(O.r!==undefined&&!X.indexOf("r")==-1)X+="r";if(O.g!==undefined&&!X.indexOf("g")==-1)X+="g";if(O.b!==undefined&&!X.indexOf("b")==-1)X+="b";if(O.a!==undefined&&!X.indexOf("a")==-1)X+="a";if(O.h!==undefined&&!X.indexOf("h")==-1)X+="h";if(O.s!==undefined&&!X.indexOf("s")==-1)X+="s";if(O.v!==undefined&&!X.indexOf("v")==-1)X+="v";for(pa=0;pa<X.length;pa++)switch(X.charAt(pa)){case "r":if(sa)continue;W=true;ba.r=O&&O.r&&O.r|0||O&&O|0||0;if(ba.r<0)ba.r=
0;else if(ba.r>255)ba.r=255;if(d!=ba.r){d=ba.r;fa=true}break;case "g":if(sa)continue;W=true;ba.g=O&&O.g&&O.g|0||O&&O|0||0;if(ba.g<0)ba.g=0;else if(ba.g>255)ba.g=255;if(l!=ba.g){l=ba.g;fa=true}break;case "b":if(sa)continue;W=true;ba.b=O&&O.b&&O.b|0||O&&O|0||0;if(ba.b<0)ba.b=0;else if(ba.b>255)ba.b=255;if(q!=ba.b){q=ba.b;fa=true}break;case "a":ba.a=O&&O.a!=null?O.a|0:O!=null?O|0:255;if(ba.a<0)ba.a=0;else if(ba.a>255)ba.a=255;if(B!=ba.a){B=ba.a;fa=true}break;case "h":if(W)continue;sa=true;ba.h=O&&O.h&&
O.h|0||O&&O|0||0;if(ba.h<0)ba.h=0;else if(ba.h>360)ba.h=360;if(o!=ba.h){o=ba.h;fa=true}break;case "s":if(W)continue;sa=true;ba.s=O&&O.s!=null?O.s|0:O!=null?O|0:100;if(ba.s<0)ba.s=0;else if(ba.s>100)ba.s=100;if(K!=ba.s){K=ba.s;fa=true}break;case "v":if(W)continue;sa=true;ba.v=O&&O.v!=null?O.v|0:O!=null?O|0:100;if(ba.v<0)ba.v=0;else if(ba.v>100)ba.v=100;if(T!=ba.v){T=ba.v;fa=true}}if(fa){if(W){d=d||0;l=l||0;q=q||0;O=s.rgbToHsv({r:d,g:l,b:q});o=O.h;K=O.s;T=O.v}else if(sa){o=o||0;K=K!=null?K:100;T=T!=
null?T:100;O=s.hsvToRgb({h:o,s:K,v:T});d=O.r;l=O.g;q=O.b}B=B!=null?B:255;J.call(f,ia||f)}}}};a.extend(true,f,{val:Q,bind:function(Y){a.isFunction(Y)&&M.push(Y)},unbind:function(Y){if(a.isFunction(Y))for(var O;(O=a.inArray(Y,M))!=-1;)M.splice(O,1)},destroy:function(){M=null}});if(b)if(b.ahex!=null)Q("ahex",b);else if(b.hex!=null)Q((b.a!=null?"a":"")+"hex",b.a!=null?{ahex:b.hex+s.intToHex(b.a)}:b);else if(b.r!=null&&b.g!=null&&b.b!=null)Q("rgb"+(b.a!=null?"a":""),b);else if(b.h!=null&&b.s!=null&&b.v!=
null?T:100;O=s.hsvToRgb({h:o,s:K,v:T});d=O.r;l=O.g;q=O.b}B=B!=null?B:255;J.call(f,ia||f)}}}};a.extend(true,f,{val:Q,bind:function(X){a.isFunction(X)&&M.push(X)},unbind:function(X){if(a.isFunction(X))for(var O;(O=a.inArray(X,M))!=-1;)M.splice(O,1)},destroy:function(){M=null}});if(b)if(b.ahex!=null)Q("ahex",b);else if(b.hex!=null)Q((b.a!=null?"a":"")+"hex",b.a!=null?{ahex:b.hex+s.intToHex(b.a)}:b);else if(b.r!=null&&b.g!=null&&b.b!=null)Q("rgb"+(b.a!=null?"a":""),b);else if(b.h!=null&&b.s!=null&&b.v!=
null)Q("hsv"+(b.a!=null?"a":""),b)},ColorMethods:{hexToRgba:function(b){b=this.validateHex(b);if(b=="")return{r:null,g:null,b:null,a:null};var f="00",d="00",l="00",q="255";if(b.length==6)b+="ff";if(b.length>6){f=b.substring(0,2);d=b.substring(2,4);l=b.substring(4,6);q=b.substring(6,b.length)}else{if(b.length>4){f=b.substring(4,b.length);b=b.substring(0,4)}if(b.length>2){d=b.substring(2,b.length);b=b.substring(0,2)}if(b.length>0)l=b.substring(0,b.length)}return{r:this.hexToInt(f),g:this.hexToInt(d),
b:this.hexToInt(l),a:this.hexToInt(q)}},validateHex:function(b){if(typeof b=="object")return"";b=b.toLowerCase().replace(/[^a-f0-9]/g,"");if(b.length>8)b=b.substring(0,8);return b},rgbaToHex:function(b){return this.intToHex(b.r)+this.intToHex(b.g)+this.intToHex(b.b)+this.intToHex(b.a)},intToHex:function(b){b=(b|0).toString(16);if(b.length==1)b="0"+b;return b.toLowerCase()},hexToInt:function(b){return parseInt(b,16)},rgbToHsv:function(b){var f=b.r/255,d=b.g/255;b=b.b/255;var l={h:0,s:0,v:0},q=0,B=
0;if(f>=d&&f>=b){B=f;q=d>b?b:d}else if(d>=b&&d>=f){B=d;q=f>b?b:f}else{B=b;q=d>f?f:d}l.v=B;l.s=B?(B-q)/B:0;if(l.s){q=B-q;l.h=f==B?(d-b)/q:d==B?2+(b-f)/q:4+(f-d)/q;l.h=parseInt(l.h*60);if(l.h<0)l.h+=360}else l.h=0;l.s=l.s*100|0;l.v=l.v*100|0;return l},hsvToRgb:function(b){var f={r:0,g:0,b:0,a:100},d=b.h,l=b.s;b=b.v;if(l==0)f.r=b==0?f.g=f.b=0:f.g=f.b=b*255/100|0;else{if(d==360)d=0;d/=60;l/=100;b/=100;var q=d|0,B=d-q;d=b*(1-l);var o=b*(1-l*B);l=b*(1-l*(1-B));switch(q){case 0:f.r=b;f.g=l;f.b=d;break;case 1:f.r=
o;f.g=b;f.b=d;break;case 2:f.r=d;f.g=b;f.b=l;break;case 3:f.r=d;f.g=o;f.b=b;break;case 4:f.r=l;f.g=d;f.b=b;break;case 5:f.r=b;f.g=d;f.b=o}f.r=f.r*255|0;f.g=f.g*255|0;f.b=f.b*255|0}return f}}};var c=a.jPicker.Color,n=a.jPicker.List,s=a.jPicker.ColorMethods;a.fn.jPicker=function(b){var f=arguments;return this.each(function(){var d=this,l=a.extend(true,{},a.fn.jPicker.defaults,b);if(a(d).get(0).nodeName.toLowerCase()=="input"){a.extend(true,l,{window:{bindToInput:true,expandable:true,input:a(d)}});if(a(d).val()==
""){l.color.active=new c({hex:null});l.color.current=new c({hex:null})}else if(s.validateHex(a(d).val())){l.color.active=new c({hex:a(d).val(),a:l.color.active.val("a")});l.color.current=new c({hex:a(d).val(),a:l.color.active.val("a")})}}if(l.window.expandable)a(d).after('<span class="jPicker"><span class="Icon"><span class="Color">&nbsp;</span><span class="Alpha">&nbsp;</span><span class="Image" title="Click To Open Color Picker">&nbsp;</span><span class="Container">&nbsp;</span></span></span>');
else l.window.liveUpdate=false;var q=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters,B=null,o=null,K=null,T=null,M=null,J=null,Q=null,Y=null,O=null,ia=null,pa=null,fa=null,ba=null,W=null,sa=null,ka=null,da=null,V=null,Z=null,oa=null,qa=null,ma=null,na=null,Aa=null,Fa=null,Ia=null,Ca=null,Ka=null,Na=function(N){var R=ja.active,ea=R.val("hex"),Ga,Oa;l.color.mode=N;switch(N){case "h":setTimeout(function(){Va.call(d,o,"transparent");Da.call(d,T,0);va.call(d,T,100);Da.call(d,
M,260);va.call(d,M,100);Va.call(d,K,"transparent");Da.call(d,Q,0);va.call(d,Q,100);Da.call(d,Y,260);va.call(d,Y,100);Da.call(d,O,260);va.call(d,O,100);Da.call(d,ia,260);va.call(d,ia,100);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:100,minY:0,maxY:100});W.range("rangeY",{minY:0,maxY:360});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("s"),y:100-R.val("v")},ba);W.val("y",360-R.val("h"),W);break;case "s":setTimeout(function(){Va.call(d,o,"transparent");Da.call(d,T,-260);Da.call(d,
M,-520);Da.call(d,Q,-260);Da.call(d,Y,-520);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:360,minY:0,maxY:100});W.range("rangeY",{minY:0,maxY:100});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("v")},ba);W.val("y",100-R.val("s"),W);break;case "v":setTimeout(function(){Va.call(d,o,"000000");Da.call(d,T,-780);Da.call(d,M,260);Va.call(d,K,ea);Da.call(d,Q,-520);Da.call(d,Y,260);va.call(d,Y,100);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:360,
minY:0,maxY:100});W.range("rangeY",{minY:0,maxY:100});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("s")},ba);W.val("y",100-R.val("v"),W);break;case "r":Ga=-1040;Oa=-780;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});W.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("b"),y:255-R.val("g")},ba);W.val("y",255-R.val("r"),W);break;case "g":Ga=-1560;Oa=-1820;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});W.range("rangeY",{minY:0,maxY:255});
if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("b"),y:255-R.val("r")},ba);W.val("y",255-R.val("g"),W);break;case "b":Ga=-2080;Oa=-2860;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});W.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("r"),y:255-R.val("g")},ba);W.val("y",255-R.val("b"),W);break;case "a":setTimeout(function(){Va.call(d,o,"transparent");Da.call(d,T,-260);Da.call(d,M,-520);Da.call(d,Q,260);Da.call(d,Y,260);va.call(d,Y,100);Da.call(d,fa,0);va.call(d,
fa,100)},0);ba.range("all",{minX:0,maxX:360,minY:0,maxY:100});W.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("v")},ba);W.val("y",255-R.val("a"),W);break;default:throw"Invalid Mode";}switch(N){case "s":case "v":case "a":setTimeout(function(){va.call(d,T,100);va.call(d,Q,100);Da.call(d,O,260);va.call(d,O,100);Da.call(d,ia,260);va.call(d,ia,100)},0);break;case "r":case "g":case "b":setTimeout(function(){Va.call(d,o,"transparent");Va.call(d,K,"transparent");
va.call(d,Q,100);va.call(d,T,100);Da.call(d,T,Ga);Da.call(d,M,Ga-260);Da.call(d,Q,Oa-780);Da.call(d,Y,Oa-520);Da.call(d,O,Oa);Da.call(d,ia,Oa-260);Da.call(d,fa,260);va.call(d,fa,100)},0)}R.val("ahex")!=null&&za.call(d,R)},za=function(N,R){if(R==null||R!=W&&R!=ba)wa.call(d,N,R);setTimeout(function(){qb.call(d,N);$a.call(d,N);ib.call(d,N)},0)},ya=function(N,R){var ea=ja.active;if(!(R!=ba&&ea.val()==null)){var Ga=N.val("all");switch(l.color.mode){case "h":ea.val("sv",{s:Ga.x,v:100-Ga.y},R);break;case "s":case "a":ea.val("hv",
else l.window.liveUpdate=false;var q=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters,B=null,o=null,K=null,T=null,M=null,J=null,Q=null,X=null,O=null,ia=null,pa=null,fa=null,ba=null,W=null,sa=null,ka=null,da=null,V=null,Z=null,oa=null,qa=null,ma=null,na=null,Aa=null,Fa=null,Ia=null,Ca=null,Ka=null,Na=function(N){var R=ja.active,ea=R.val("hex"),Ga,Pa;l.color.mode=N;switch(N){case "h":setTimeout(function(){Wa.call(d,o,"transparent");Da.call(d,T,0);va.call(d,T,100);Da.call(d,
M,260);va.call(d,M,100);Wa.call(d,K,"transparent");Da.call(d,Q,0);va.call(d,Q,100);Da.call(d,X,260);va.call(d,X,100);Da.call(d,O,260);va.call(d,O,100);Da.call(d,ia,260);va.call(d,ia,100);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:100,minY:0,maxY:100});W.range("rangeY",{minY:0,maxY:360});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("s"),y:100-R.val("v")},ba);W.val("y",360-R.val("h"),W);break;case "s":setTimeout(function(){Wa.call(d,o,"transparent");Da.call(d,T,-260);Da.call(d,
M,-520);Da.call(d,Q,-260);Da.call(d,X,-520);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:360,minY:0,maxY:100});W.range("rangeY",{minY:0,maxY:100});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("v")},ba);W.val("y",100-R.val("s"),W);break;case "v":setTimeout(function(){Wa.call(d,o,"000000");Da.call(d,T,-780);Da.call(d,M,260);Wa.call(d,K,ea);Da.call(d,Q,-520);Da.call(d,X,260);va.call(d,X,100);Da.call(d,fa,260);va.call(d,fa,100)},0);ba.range("all",{minX:0,maxX:360,
minY:0,maxY:100});W.range("rangeY",{minY:0,maxY:100});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("s")},ba);W.val("y",100-R.val("v"),W);break;case "r":Ga=-1040;Pa=-780;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});W.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("b"),y:255-R.val("g")},ba);W.val("y",255-R.val("r"),W);break;case "g":Ga=-1560;Pa=-1820;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});W.range("rangeY",{minY:0,maxY:255});
if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("b"),y:255-R.val("r")},ba);W.val("y",255-R.val("g"),W);break;case "b":Ga=-2080;Pa=-2860;ba.range("all",{minX:0,maxX:255,minY:0,maxY:255});W.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("r"),y:255-R.val("g")},ba);W.val("y",255-R.val("b"),W);break;case "a":setTimeout(function(){Wa.call(d,o,"transparent");Da.call(d,T,-260);Da.call(d,M,-520);Da.call(d,Q,260);Da.call(d,X,260);va.call(d,X,100);Da.call(d,fa,0);va.call(d,
fa,100)},0);ba.range("all",{minX:0,maxX:360,minY:0,maxY:100});W.range("rangeY",{minY:0,maxY:255});if(R.val("ahex")==null)break;ba.val("xy",{x:R.val("h"),y:100-R.val("v")},ba);W.val("y",255-R.val("a"),W);break;default:throw"Invalid Mode";}switch(N){case "s":case "v":case "a":setTimeout(function(){va.call(d,T,100);va.call(d,Q,100);Da.call(d,O,260);va.call(d,O,100);Da.call(d,ia,260);va.call(d,ia,100)},0);break;case "r":case "g":case "b":setTimeout(function(){Wa.call(d,o,"transparent");Wa.call(d,K,"transparent");
va.call(d,Q,100);va.call(d,T,100);Da.call(d,T,Ga);Da.call(d,M,Ga-260);Da.call(d,Q,Pa-780);Da.call(d,X,Pa-520);Da.call(d,O,Pa);Da.call(d,ia,Pa-260);Da.call(d,fa,260);va.call(d,fa,100)},0)}R.val("ahex")!=null&&za.call(d,R)},za=function(N,R){if(R==null||R!=W&&R!=ba)wa.call(d,N,R);setTimeout(function(){qb.call(d,N);$a.call(d,N);ib.call(d,N)},0)},ya=function(N,R){var ea=ja.active;if(!(R!=ba&&ea.val()==null)){var Ga=N.val("all");switch(l.color.mode){case "h":ea.val("sv",{s:Ga.x,v:100-Ga.y},R);break;case "s":case "a":ea.val("hv",
{h:Ga.x,v:100-Ga.y},R);break;case "v":ea.val("hs",{h:Ga.x,s:100-Ga.y},R);break;case "r":ea.val("gb",{g:255-Ga.y,b:Ga.x},R);break;case "g":ea.val("rb",{r:255-Ga.y,b:Ga.x},R);break;case "b":ea.val("rg",{r:Ga.x,g:255-Ga.y},R)}}},Ha=function(N,R){var ea=ja.active;if(!(R!=W&&ea.val()==null))switch(l.color.mode){case "h":ea.val("h",{h:360-N.val("y")},R);break;case "s":ea.val("s",{s:100-N.val("y")},R);break;case "v":ea.val("v",{v:100-N.val("y")},R);break;case "r":ea.val("r",{r:255-N.val("y")},R);break;case "g":ea.val("g",
{g:255-N.val("y")},R);break;case "b":ea.val("b",{b:255-N.val("y")},R);break;case "a":ea.val("a",255-N.val("y"),R)}},wa=function(N,R){if(R!=ba)switch(l.color.mode){case "h":var ea=N.val("sv");ba.val("xy",{x:ea!=null?ea.s:100,y:100-(ea!=null?ea.v:100)},R);break;case "s":case "a":ea=N.val("hv");ba.val("xy",{x:ea&&ea.h||0,y:100-(ea!=null?ea.v:100)},R);break;case "v":ea=N.val("hs");ba.val("xy",{x:ea&&ea.h||0,y:100-(ea!=null?ea.s:100)},R);break;case "r":ea=N.val("bg");ba.val("xy",{x:ea&&ea.b||0,y:255-(ea&&
ea.g||0)},R);break;case "g":ea=N.val("br");ba.val("xy",{x:ea&&ea.b||0,y:255-(ea&&ea.r||0)},R);break;case "b":ea=N.val("rg");ba.val("xy",{x:ea&&ea.r||0,y:255-(ea&&ea.g||0)},R)}if(R!=W)switch(l.color.mode){case "h":W.val("y",360-(N.val("h")||0),R);break;case "s":ea=N.val("s");W.val("y",100-(ea!=null?ea:100),R);break;case "v":ea=N.val("v");W.val("y",100-(ea!=null?ea:100),R);break;case "r":W.val("y",255-(N.val("r")||0),R);break;case "g":W.val("y",255-(N.val("g")||0),R);break;case "b":W.val("y",255-(N.val("b")||
0),R);break;case "a":ea=N.val("a");W.val("y",255-(ea!=null?ea:255),R)}},qb=function(N){try{var R=N.val("all");oa.css({backgroundColor:R&&"#"+R.hex||"transparent"});va.call(d,oa,R&&Math.precision(R.a*100/255,4)||0)}catch(ea){}},$a=function(N){switch(l.color.mode){case "h":Va.call(d,o,(new c({h:N.val("h")||0,s:100,v:100})).val("hex"));break;case "s":case "a":var R=N.val("s");va.call(d,M,100-(R!=null?R:100));break;case "v":R=N.val("v");va.call(d,T,R!=null?R:100);break;case "r":va.call(d,M,Math.precision((N.val("r")||
0)/255*100,4));break;case "g":va.call(d,M,Math.precision((N.val("g")||0)/255*100,4));break;case "b":va.call(d,M,Math.precision((N.val("b")||0)/255*100))}N=N.val("a");va.call(d,J,Math.precision((255-(N||0))*100/255,4))},ib=function(N){switch(l.color.mode){case "h":var R=N.val("a");va.call(d,pa,Math.precision((255-(R||0))*100/255,4));break;case "s":R=N.val("hva");var ea=new c({h:R&&R.h||0,s:100,v:R!=null?R.v:100});Va.call(d,K,ea.val("hex"));va.call(d,Y,100-(R!=null?R.v:100));va.call(d,pa,Math.precision((255-
(R&&R.a||0))*100/255,4));break;case "v":R=N.val("hsa");ea=new c({h:R&&R.h||0,s:R!=null?R.s:100,v:100});Va.call(d,K,ea.val("hex"));va.call(d,pa,Math.precision((255-(R&&R.a||0))*100/255,4));break;case "r":case "g":case "b":ea=R=0;N=N.val("rgba");if(l.color.mode=="r"){R=N&&N.b||0;ea=N&&N.g||0}else if(l.color.mode=="g"){R=N&&N.b||0;ea=N&&N.r||0}else if(l.color.mode=="b"){R=N&&N.r||0;ea=N&&N.g||0}var Ga=ea>R?R:ea;va.call(d,Y,R>ea?Math.precision((R-ea)/(255-ea)*100,4):0);va.call(d,O,ea>R?Math.precision((ea-
R)/(255-R)*100,4):0);va.call(d,ia,Math.precision(Ga/255*100,4));va.call(d,pa,Math.precision((255-(N&&N.a||0))*100/255,4));break;case "a":R=N.val("a");Va.call(d,K,N.val("hex")||"000000");va.call(d,pa,R!=null?0:100);va.call(d,fa,R!=null?100:0)}},Va=function(N,R){N.css({backgroundColor:R&&R.length==6&&"#"+R||"transparent"})},Ra=function(N,R){if(q&&(R.indexOf("AlphaBar.png")!=-1||R.indexOf("Bars.png")!=-1||R.indexOf("Maps.png")!=-1)){N.attr("pngSrc",R);N.css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+
0),R);break;case "a":ea=N.val("a");W.val("y",255-(ea!=null?ea:255),R)}},qb=function(N){try{var R=N.val("all");oa.css({backgroundColor:R&&"#"+R.hex||"transparent"});va.call(d,oa,R&&Math.precision(R.a*100/255,4)||0)}catch(ea){}},$a=function(N){switch(l.color.mode){case "h":Wa.call(d,o,(new c({h:N.val("h")||0,s:100,v:100})).val("hex"));break;case "s":case "a":var R=N.val("s");va.call(d,M,100-(R!=null?R:100));break;case "v":R=N.val("v");va.call(d,T,R!=null?R:100);break;case "r":va.call(d,M,Math.precision((N.val("r")||
0)/255*100,4));break;case "g":va.call(d,M,Math.precision((N.val("g")||0)/255*100,4));break;case "b":va.call(d,M,Math.precision((N.val("b")||0)/255*100))}N=N.val("a");va.call(d,J,Math.precision((255-(N||0))*100/255,4))},ib=function(N){switch(l.color.mode){case "h":var R=N.val("a");va.call(d,pa,Math.precision((255-(R||0))*100/255,4));break;case "s":R=N.val("hva");var ea=new c({h:R&&R.h||0,s:100,v:R!=null?R.v:100});Wa.call(d,K,ea.val("hex"));va.call(d,X,100-(R!=null?R.v:100));va.call(d,pa,Math.precision((255-
(R&&R.a||0))*100/255,4));break;case "v":R=N.val("hsa");ea=new c({h:R&&R.h||0,s:R!=null?R.s:100,v:100});Wa.call(d,K,ea.val("hex"));va.call(d,pa,Math.precision((255-(R&&R.a||0))*100/255,4));break;case "r":case "g":case "b":ea=R=0;N=N.val("rgba");if(l.color.mode=="r"){R=N&&N.b||0;ea=N&&N.g||0}else if(l.color.mode=="g"){R=N&&N.b||0;ea=N&&N.r||0}else if(l.color.mode=="b"){R=N&&N.r||0;ea=N&&N.g||0}var Ga=ea>R?R:ea;va.call(d,X,R>ea?Math.precision((R-ea)/(255-ea)*100,4):0);va.call(d,O,ea>R?Math.precision((ea-
R)/(255-R)*100,4):0);va.call(d,ia,Math.precision(Ga/255*100,4));va.call(d,pa,Math.precision((255-(N&&N.a||0))*100/255,4));break;case "a":R=N.val("a");Wa.call(d,K,N.val("hex")||"000000");va.call(d,pa,R!=null?0:100);va.call(d,fa,R!=null?100:0)}},Wa=function(N,R){N.css({backgroundColor:R&&R.length==6&&"#"+R||"transparent"})},Sa=function(N,R){if(q&&(R.indexOf("AlphaBar.png")!=-1||R.indexOf("Bars.png")!=-1||R.indexOf("Maps.png")!=-1)){N.attr("pngSrc",R);N.css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+
R+"', sizingMethod='scale')"})}else N.css({backgroundImage:"url('"+R+"')"})},Da=function(N,R){N.css({top:R+"px"})},va=function(N,R){N.css({visibility:R>0?"visible":"hidden"});if(R>0&&R<100)if(q){var ea=N.attr("pngSrc");ea!=null&&(ea.indexOf("AlphaBar.png")!=-1||ea.indexOf("Bars.png")!=-1||ea.indexOf("Maps.png")!=-1)?N.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ea+"', sizingMethod='scale') progid:DXImageTransform.Microsoft.Alpha(opacity="+R+")"}):N.css({opacity:Math.precision(R/
100,4)})}else N.css({opacity:Math.precision(R/100,4)});else if(R==0||R==100)if(q){ea=N.attr("pngSrc");ea!=null&&(ea.indexOf("AlphaBar.png")!=-1||ea.indexOf("Bars.png")!=-1||ea.indexOf("Maps.png")!=-1)?N.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ea+"', sizingMethod='scale')"}):N.css({opacity:""})}else N.css({opacity:""})},fb=function(){ja.active.val("ahex",ja.current.val("ahex"))},La=function(){ja.current.val("ahex",ja.active.val("ahex"))},Ua=function(N){a(this).parents("tbody:first").find('input:radio[value!="'+
100,4)})}else N.css({opacity:Math.precision(R/100,4)});else if(R==0||R==100)if(q){ea=N.attr("pngSrc");ea!=null&&(ea.indexOf("AlphaBar.png")!=-1||ea.indexOf("Bars.png")!=-1||ea.indexOf("Maps.png")!=-1)?N.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ea+"', sizingMethod='scale')"}):N.css({opacity:""})}else N.css({opacity:""})},fb=function(){ja.active.val("ahex",ja.current.val("ahex"))},La=function(){ja.current.val("ahex",ja.active.val("ahex"))},Va=function(N){a(this).parents("tbody:first").find('input:radio[value!="'+
N.target.value+'"]').removeAttr("checked");Na.call(d,N.target.value)},Ea=function(){fb.call(d)},kb=function(){fb.call(d);l.window.expandable&&wb.call(d);a.isFunction(tb)&&tb.call(d,ja.active,na)},sb=function(){La.call(d);l.window.expandable&&wb.call(d);a.isFunction(ob)&&ob.call(d,ja.active,ma)},Za=function(){ub.call(d)},bb=function(N){var R=N.val("hex");qa.css({backgroundColor:R&&"#"+R||"transparent"});va.call(d,qa,Math.precision((N.val("a")||0)*100/255,4))},Cb=function(N){var R=N.val("hex");N=N.val("va");
Fa.css({backgroundColor:R&&"#"+R||"transparent"});va.call(d,Ia,Math.precision((255-(N&&N.a||0))*100/255,4));if(l.window.bindToInput&&l.window.updateInputColor)l.window.input.css({backgroundColor:R&&"#"+R||"transparent",color:N==null||N.v>75?"#000000":"#ffffff"})},ta=function(N){ka=parseInt(B.css("left"));da=parseInt(B.css("top"));V=N.pageX;Z=N.pageY;a(document).bind("mousemove",mb).bind("mouseup",jb);N.preventDefault()},mb=function(N){B.css({left:ka-(V-N.pageX)+"px",top:da-(Z-N.pageY)+"px"});l.window.expandable&&
!a.support.boxModel&&B.prev().css({left:B.css("left"),top:B.css("top")});N.stopPropagation();N.preventDefault();return false},jb=function(N){a(document).unbind("mousemove",mb).unbind("mouseup",jb);N.stopPropagation();N.preventDefault();return false},zb=function(N){N.preventDefault();N.stopPropagation();ja.active.val("ahex",a(this).attr("title")||null,N.target);return false},ob=a.isFunction(f[1])&&f[1]||null,eb=a.isFunction(f[2])&&f[2]||null,tb=a.isFunction(f[3])&&f[3]||null,ub=function(){ja.current.val("ahex",
Fa.css({backgroundColor:R&&"#"+R||"transparent"});va.call(d,Ia,Math.precision((255-(N&&N.a||0))*100/255,4));if(l.window.bindToInput&&l.window.updateInputColor)l.window.input.css({backgroundColor:R&&"#"+R||"transparent",color:N==null||N.v>75?"#000000":"#ffffff"})},ua=function(N){ka=parseInt(B.css("left"));da=parseInt(B.css("top"));V=N.pageX;Z=N.pageY;a(document).bind("mousemove",mb).bind("mouseup",jb);N.preventDefault()},mb=function(N){B.css({left:ka-(V-N.pageX)+"px",top:da-(Z-N.pageY)+"px"});l.window.expandable&&
!a.support.boxModel&&B.prev().css({left:B.css("left"),top:B.css("top")});N.stopPropagation();N.preventDefault();return false},jb=function(N){a(document).unbind("mousemove",mb).unbind("mouseup",jb);N.stopPropagation();N.preventDefault();return false},Ab=function(N){N.preventDefault();N.stopPropagation();ja.active.val("ahex",a(this).attr("title")||null,N.target);return false},ob=a.isFunction(f[1])&&f[1]||null,eb=a.isFunction(f[2])&&f[2]||null,tb=a.isFunction(f[3])&&f[3]||null,ub=function(){ja.current.val("ahex",
ja.active.val("ahex"));var N=function(){if(!(!l.window.expandable||a.support.boxModel)){var R=B.find("table:first");B.before("<iframe/>");B.prev().css({width:R.width(),height:B.height(),opacity:0,position:"absolute",left:B.css("left"),top:B.css("top")})}};if(l.window.expandable){a(document.body).children("div.jPicker.Container").css({zIndex:10});B.css({zIndex:20})}switch(l.window.effects.type){case "fade":B.fadeIn(l.window.effects.speed.show,N);break;case "slide":B.slideDown(l.window.effects.speed.show,
N);break;default:B.show(l.window.effects.speed.show,N)}},wb=function(){var N=function(){l.window.expandable&&B.css({zIndex:10});!l.window.expandable||a.support.boxModel||B.prev().remove()};switch(l.window.effects.type){case "fade":B.fadeOut(l.window.effects.speed.hide,N);break;case "slide":B.slideUp(l.window.effects.speed.hide,N);break;default:B.hide(l.window.effects.speed.hide,N)}},Ab=function(){var N=l.window,R=N.expandable?a(d).next().find(".Container:first"):null;B=N.expandable?a("<div/>"):a(d);
B.addClass("jPicker Container");N.expandable&&B.hide();B.get(0).onselectstart=function(Pa){if(Pa.target.nodeName.toLowerCase()!=="input")return false};var ea=ja.active.val("all");if(N.alphaPrecision<0)N.alphaPrecision=0;else if(N.alphaPrecision>2)N.alphaPrecision=2;var Ga='<table class="jPicker" cellpadding="0" cellspacing="0"><tbody>'+(N.expandable?'<tr><td class="Move" colspan="5">&nbsp;</td></tr>':"")+'<tr><td rowspan="9"><h2 class="Title">'+(N.title||ca.text.title)+'</h2><div class="Map"><span class="Map1">&nbsp;</span><span class="Map2">&nbsp;</span><span class="Map3">&nbsp;</span><img src="'+
N);break;default:B.show(l.window.effects.speed.show,N)}},wb=function(){var N=function(){l.window.expandable&&B.css({zIndex:10});!l.window.expandable||a.support.boxModel||B.prev().remove()};switch(l.window.effects.type){case "fade":B.fadeOut(l.window.effects.speed.hide,N);break;case "slide":B.slideUp(l.window.effects.speed.hide,N);break;default:B.hide(l.window.effects.speed.hide,N)}},Bb=function(){var N=l.window,R=N.expandable?a(d).next().find(".Container:first"):null;B=N.expandable?a("<div/>"):a(d);
B.addClass("jPicker Container");N.expandable&&B.hide();B.get(0).onselectstart=function(Qa){if(Qa.target.nodeName.toLowerCase()!=="input")return false};var ea=ja.active.val("all");if(N.alphaPrecision<0)N.alphaPrecision=0;else if(N.alphaPrecision>2)N.alphaPrecision=2;var Ga='<table class="jPicker" cellpadding="0" cellspacing="0"><tbody>'+(N.expandable?'<tr><td class="Move" colspan="5">&nbsp;</td></tr>':"")+'<tr><td rowspan="9"><h2 class="Title">'+(N.title||ca.text.title)+'</h2><div class="Map"><span class="Map1">&nbsp;</span><span class="Map2">&nbsp;</span><span class="Map3">&nbsp;</span><img src="'+
la.clientPath+la.colorMap.arrow.file+'" class="Arrow"/></div></td><td rowspan="9"><div class="Bar"><span class="Map1">&nbsp;</span><span class="Map2">&nbsp;</span><span class="Map3">&nbsp;</span><span class="Map4">&nbsp;</span><span class="Map5">&nbsp;</span><span class="Map6">&nbsp;</span><img src="'+la.clientPath+la.colorBar.arrow.file+'" class="Arrow"/></div></td><td colspan="2" class="Preview"><div class="prev_div">'+ca.text.newColor+'<div class="color_preview"><span class="Active" title="'+ca.tooltips.colors.newColor+
'">&nbsp;</span><span class="Current" title="'+ca.tooltips.colors.currentColor+'">&nbsp;</span></div></div>'+ca.text.currentColor+'</td><td rowspan="9" class="Button"><input type="button" class="Ok" value="'+ca.text.ok+'" title="'+ca.tooltips.buttons.ok+'"/><input type="button" class="Cancel" value="'+ca.text.cancel+'" title="'+ca.tooltips.buttons.cancel+'"/><div class="Grid">&nbsp;</div></td></tr><tr class="Hue"><td class="Radio"><label title="'+ca.tooltips.hue.radio+'"><input type="radio" value="h"'+
(l.color.mode=="h"?' checked="checked"':"")+'/>H:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(ea!=null?ea.h:"")+'" title="'+ca.tooltips.hue.textbox+'"/>&nbsp;\u00ba</td></tr><tr class="Saturation"><td class="Radio"><label title="'+ca.tooltips.saturation.radio+'"><input type="radio" value="s"'+(l.color.mode=="s"?' checked="checked"':"")+'/>S:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(ea!=null?ea.s:"")+'" title="'+ca.tooltips.saturation.textbox+
@ -636,16 +636,16 @@ la.clientPath+la.colorMap.arrow.file+'" class="Arrow"/></div></td><td rowspan="9
"")+'/>B:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(ea!=null?ea.b:"")+'" title="'+ca.tooltips.blue.textbox+'"/></td></tr><tr class="Alpha"><td class="Radio">'+(N.alphaSupport?'<label title="'+ca.tooltips.alpha.radio+'"><input type="radio" value="a"'+(l.color.mode=="a"?' checked="checked"':"")+"/>A:</label>":"&nbsp;")+'</td><td class="Text">'+(N.alphaSupport?'<input type="text" maxlength="'+(3+N.alphaPrecision)+'" value="'+(ea!=null?Math.precision(ea.a*100/255,N.alphaPrecision):
"")+'" title="'+ca.tooltips.alpha.textbox+'"/>&nbsp;%':"&nbsp;")+'</td></tr><tr class="Hex"><td colspan="2" class="Text"><label title="'+ca.tooltips.hex.textbox+'">#:<input type="text" maxlength="6" class="Hex" value="'+(ea!=null?ea.hex:"")+'"/></label>'+(N.alphaSupport?'<input type="text" maxlength="2" class="AHex" value="'+(ea!=null?ea.ahex.substring(6):"")+'" title="'+ca.tooltips.hex.alpha+'"/></td>':"&nbsp;")+"</tr></tbody></table>";if(N.expandable){B.html(Ga);a(document.body).children("div.jPicker.Container").length==
0?a(document.body).prepend(B):a(document.body).children("div.jPicker.Container:last").after(B);B.mousedown(function(){a(document.body).children("div.jPicker.Container").css({zIndex:10});B.css({zIndex:20})});B.css({left:N.position.x=="left"?R.offset().left-530-(N.position.y=="center"?25:0)+"px":N.position.x=="center"?R.offset().left-260+"px":N.position.x=="right"?R.offset().left-10+(N.position.y=="center"?25:0)+"px":N.position.x=="screenCenter"?(a(document).width()>>1)-260+"px":R.offset().left+parseInt(N.position.x)+
"px",position:"absolute",top:N.position.y=="top"?R.offset().top-312+"px":N.position.y=="center"?R.offset().top-156+"px":N.position.y=="bottom"?R.offset().top+25+"px":R.offset().top+parseInt(N.position.y)+"px"})}else{B=a(d);B.html(Ga)}Ga=B.find("tbody:first");o=Ga.find("div.Map:first");K=Ga.find("div.Bar:first");var Oa=o.find("span"),Ya=K.find("span");T=Oa.filter(".Map1:first");M=Oa.filter(".Map2:first");J=Oa.filter(".Map3:first");Q=Ya.filter(".Map1:first");Y=Ya.filter(".Map2:first");O=Ya.filter(".Map3:first");
"px",position:"absolute",top:N.position.y=="top"?R.offset().top-312+"px":N.position.y=="center"?R.offset().top-156+"px":N.position.y=="bottom"?R.offset().top+25+"px":R.offset().top+parseInt(N.position.y)+"px"})}else{B=a(d);B.html(Ga)}Ga=B.find("tbody:first");o=Ga.find("div.Map:first");K=Ga.find("div.Bar:first");var Pa=o.find("span"),Ya=K.find("span");T=Pa.filter(".Map1:first");M=Pa.filter(".Map2:first");J=Pa.filter(".Map3:first");Q=Ya.filter(".Map1:first");X=Ya.filter(".Map2:first");O=Ya.filter(".Map3:first");
ia=Ya.filter(".Map4:first");pa=Ya.filter(".Map5:first");fa=Ya.filter(".Map6:first");ba=new p(o,{map:{width:la.colorMap.width,height:la.colorMap.height},arrow:{image:la.clientPath+la.colorMap.arrow.file,width:la.colorMap.arrow.width,height:la.colorMap.arrow.height}});ba.bind(ya);W=new p(K,{map:{width:la.colorBar.width,height:la.colorBar.height},arrow:{image:la.clientPath+la.colorBar.arrow.file,width:la.colorBar.arrow.width,height:la.colorBar.arrow.height}});W.bind(Ha);sa=new g(Ga,ja.active,N.expandable&&
N.bindToInput?N.input:null,N.alphaPrecision);Oa=ea!=null?ea.hex:null;var db=Ga.find(".Preview");Ya=Ga.find(".Button");oa=db.find(".Active:first").css({backgroundColor:Oa&&"#"+Oa||"transparent"});qa=db.find(".Current:first").css({backgroundColor:Oa&&"#"+Oa||"transparent"}).bind("click",Ea);va.call(d,qa,Math.precision(ja.current.val("a")*100)/255,4);ma=Ya.find(".Ok:first").bind("click touchstart",sb);na=Ya.find(".Cancel:first").bind("click touchstart",kb);Aa=Ya.find(".Grid:first");setTimeout(function(){Ra.call(d,
T,la.clientPath+"Maps.png");Ra.call(d,M,la.clientPath+"Maps.png");Ra.call(d,J,la.clientPath+"map-opacity.png");Ra.call(d,Q,la.clientPath+"Bars.png");Ra.call(d,Y,la.clientPath+"Bars.png");Ra.call(d,O,la.clientPath+"Bars.png");Ra.call(d,ia,la.clientPath+"Bars.png");Ra.call(d,pa,la.clientPath+"bar-opacity.png");Ra.call(d,fa,la.clientPath+"AlphaBar.png");Ra.call(d,db.find("div:last"),la.clientPath+"preview-opacity.png")},0);Ga.find("td.Radio input").bind("click touchstart",Ua);if(ja.quickList&&ja.quickList.length>
0){Ya="";for(i=0;i<ja.quickList.length;i++){if((typeof ja.quickList[i]).toString().toLowerCase()=="string")ja.quickList[i]=new c({hex:ja.quickList[i]});var nb=ja.quickList[i].val("a"),Xa=ja.quickList[i].val("ahex");if(!N.alphaSupport&&Xa)Xa=Xa.substring(0,6)+"ff";var rb=ja.quickList[i].val("hex");Ya+='<span class="QuickColor"'+(Xa&&' title="#'+Xa+'"'||"")+' style="background-color:'+(rb&&"#"+rb||"")+";"+(rb?"":"background-image:url("+la.clientPath+"NoColor.png)")+(N.alphaSupport&&nb&&nb<255?";opacity:"+
Math.precision(nb/255,4)+";filter:Alpha(opacity="+Math.precision(nb/2.55,4)+")":"")+'">&nbsp;</span>'}Ra.call(d,Aa,la.clientPath+"bar-opacity.png");Aa.html(Ya);Aa.find(".QuickColor").click(zb)}Na.call(d,l.color.mode);ja.active.bind(za);a.isFunction(eb)&&ja.active.bind(eb);ja.current.bind(bb);if(N.expandable){d.icon=R.parents(".Icon:first");Fa=d.icon.find(".Color:first").css({backgroundColor:Oa&&"#"+Oa||"transparent"});Ia=d.icon.find(".Alpha:first");Ra.call(d,Ia,la.clientPath+"bar-opacity.png");va.call(d,
Ia,Math.precision((255-(ea!=null?ea.a:0))*100/255,4));Ca=d.icon.find(".Image:first").css({backgroundImage:"url('"+la.clientPath+la.picker.file+"')"}).bind("click",Za);if(N.bindToInput&&N.updateInputColor)N.input.css({backgroundColor:Oa&&"#"+Oa||"transparent",color:ea==null||ea.v>75?"#000000":"#ffffff"});Ka=Ga.find(".Move:first").bind("mousedown",ta);ja.active.bind(Cb)}else ub.call(d)},la=l.images,ca=l.localization,ja={active:(typeof l.color.active).toString().toLowerCase()=="string"?new c({ahex:!l.window.alphaSupport&&
N.bindToInput?N.input:null,N.alphaPrecision);Pa=ea!=null?ea.hex:null;var db=Ga.find(".Preview");Ya=Ga.find(".Button");oa=db.find(".Active:first").css({backgroundColor:Pa&&"#"+Pa||"transparent"});qa=db.find(".Current:first").css({backgroundColor:Pa&&"#"+Pa||"transparent"}).bind("click",Ea);va.call(d,qa,Math.precision(ja.current.val("a")*100)/255,4);ma=Ya.find(".Ok:first").bind("click touchstart",sb);na=Ya.find(".Cancel:first").bind("click touchstart",kb);Aa=Ya.find(".Grid:first");setTimeout(function(){Sa.call(d,
T,la.clientPath+"Maps.png");Sa.call(d,M,la.clientPath+"Maps.png");Sa.call(d,J,la.clientPath+"map-opacity.png");Sa.call(d,Q,la.clientPath+"Bars.png");Sa.call(d,X,la.clientPath+"Bars.png");Sa.call(d,O,la.clientPath+"Bars.png");Sa.call(d,ia,la.clientPath+"Bars.png");Sa.call(d,pa,la.clientPath+"bar-opacity.png");Sa.call(d,fa,la.clientPath+"AlphaBar.png");Sa.call(d,db.find("div:last"),la.clientPath+"preview-opacity.png")},0);Ga.find("td.Radio input").bind("click touchstart",Va);if(ja.quickList&&ja.quickList.length>
0){Ya="";for(i=0;i<ja.quickList.length;i++){if((typeof ja.quickList[i]).toString().toLowerCase()=="string")ja.quickList[i]=new c({hex:ja.quickList[i]});var nb=ja.quickList[i].val("a"),Ua=ja.quickList[i].val("ahex");if(!N.alphaSupport&&Ua)Ua=Ua.substring(0,6)+"ff";var rb=ja.quickList[i].val("hex");Ya+='<span class="QuickColor"'+(Ua&&' title="#'+Ua+'"'||"")+' style="background-color:'+(rb&&"#"+rb||"")+";"+(rb?"":"background-image:url("+la.clientPath+"NoColor.png)")+(N.alphaSupport&&nb&&nb<255?";opacity:"+
Math.precision(nb/255,4)+";filter:Alpha(opacity="+Math.precision(nb/2.55,4)+")":"")+'">&nbsp;</span>'}Sa.call(d,Aa,la.clientPath+"bar-opacity.png");Aa.html(Ya);Aa.find(".QuickColor").click(Ab)}Na.call(d,l.color.mode);ja.active.bind(za);a.isFunction(eb)&&ja.active.bind(eb);ja.current.bind(bb);if(N.expandable){d.icon=R.parents(".Icon:first");Fa=d.icon.find(".Color:first").css({backgroundColor:Pa&&"#"+Pa||"transparent"});Ia=d.icon.find(".Alpha:first");Sa.call(d,Ia,la.clientPath+"bar-opacity.png");va.call(d,
Ia,Math.precision((255-(ea!=null?ea.a:0))*100/255,4));Ca=d.icon.find(".Image:first").css({backgroundImage:"url('"+la.clientPath+la.picker.file+"')"}).bind("click",Za);if(N.bindToInput&&N.updateInputColor)N.input.css({backgroundColor:Pa&&"#"+Pa||"transparent",color:ea==null||ea.v>75?"#000000":"#ffffff"});Ka=Ga.find(".Move:first").bind("mousedown",ua);ja.active.bind(Cb)}else ub.call(d)},la=l.images,ca=l.localization,ja={active:(typeof l.color.active).toString().toLowerCase()=="string"?new c({ahex:!l.window.alphaSupport&&
l.color.active?l.color.active.substring(0,6)+"ff":l.color.active}):new c({ahex:!l.window.alphaSupport&&l.color.active.val("ahex")?l.color.active.val("ahex").substring(0,6)+"ff":l.color.active.val("ahex")}),current:(typeof l.color.active).toString().toLowerCase()=="string"?new c({ahex:!l.window.alphaSupport&&l.color.active?l.color.active.substring(0,6)+"ff":l.color.active}):new c({ahex:!l.window.alphaSupport&&l.color.active.val("ahex")?l.color.active.val("ahex").substring(0,6)+"ff":l.color.active.val("ahex")}),
quickList:l.color.quickList};a.extend(true,d,{commitCallback:ob,liveCallback:eb,cancelCallback:tb,color:ja,show:ub,hide:wb,destroy:function(){B.find("td.Radio input touchstart").unbind("click",Ua);qa.unbind("click touchstart",Ea);na.unbind("click touchstart",kb);ma.unbind("click touchstart",sb);if(l.window.expandable){Ca.unbind("click",Za);Ka.unbind("mousedown",ta);d.icon=null}B.find(".QuickColor").unbind("click",zb);fa=pa=ia=O=Y=Q=J=M=T=K=o=null;ba.destroy();ba=null;W.destroy();W=null;sa.destroy();
eb=tb=ob=Aa=na=ma=qa=oa=sa=null;B.html("");for(i=0;i<n.length;i++)n[i]==d&&n.splice(i,1)}});n.push(d);setTimeout(function(){Ab.call(d)},0)})};a.fn.jPicker.defaults={window:{title:null,effects:{type:"slide",speed:{show:"slow",hide:"fast"}},position:{x:"screenCenter",y:"top"},expandable:false,liveUpdate:true,alphaSupport:false,alphaPrecision:0,updateInputColor:true},color:{mode:"h",active:new c({ahex:"#ffcc00ff"}),quickList:[new c({h:360,s:33,v:100}),new c({h:360,s:66,v:100}),new c({h:360,s:100,v:100}),
quickList:l.color.quickList};a.extend(true,d,{commitCallback:ob,liveCallback:eb,cancelCallback:tb,color:ja,show:ub,hide:wb,destroy:function(){B.find("td.Radio input touchstart").unbind("click",Va);qa.unbind("click touchstart",Ea);na.unbind("click touchstart",kb);ma.unbind("click touchstart",sb);if(l.window.expandable){Ca.unbind("click",Za);Ka.unbind("mousedown",ua);d.icon=null}B.find(".QuickColor").unbind("click",Ab);fa=pa=ia=O=X=Q=J=M=T=K=o=null;ba.destroy();ba=null;W.destroy();W=null;sa.destroy();
eb=tb=ob=Aa=na=ma=qa=oa=sa=null;B.html("");for(i=0;i<n.length;i++)n[i]==d&&n.splice(i,1)}});n.push(d);setTimeout(function(){Bb.call(d)},0)})};a.fn.jPicker.defaults={window:{title:null,effects:{type:"slide",speed:{show:"slow",hide:"fast"}},position:{x:"screenCenter",y:"top"},expandable:false,liveUpdate:true,alphaSupport:false,alphaPrecision:0,updateInputColor:true},color:{mode:"h",active:new c({ahex:"#ffcc00ff"}),quickList:[new c({h:360,s:33,v:100}),new c({h:360,s:66,v:100}),new c({h:360,s:100,v:100}),
new c({h:360,s:100,v:75}),new c({h:360,s:100,v:50}),new c({h:180,s:0,v:100}),new c({h:30,s:33,v:100}),new c({h:30,s:66,v:100}),new c({h:30,s:100,v:100}),new c({h:30,s:100,v:75}),new c({h:30,s:100,v:50}),new c({h:180,s:0,v:90}),new c({h:60,s:33,v:100}),new c({h:60,s:66,v:100}),new c({h:60,s:100,v:100}),new c({h:60,s:100,v:75}),new c({h:60,s:100,v:50}),new c({h:180,s:0,v:80}),new c({h:90,s:33,v:100}),new c({h:90,s:66,v:100}),new c({h:90,s:100,v:100}),new c({h:90,s:100,v:75}),new c({h:90,s:100,v:50}),
new c({h:180,s:0,v:70}),new c({h:120,s:33,v:100}),new c({h:120,s:66,v:100}),new c({h:120,s:100,v:100}),new c({h:120,s:100,v:75}),new c({h:120,s:100,v:50}),new c({h:180,s:0,v:60}),new c({h:150,s:33,v:100}),new c({h:150,s:66,v:100}),new c({h:150,s:100,v:100}),new c({h:150,s:100,v:75}),new c({h:150,s:100,v:50}),new c({h:180,s:0,v:50}),new c({h:180,s:33,v:100}),new c({h:180,s:66,v:100}),new c({h:180,s:100,v:100}),new c({h:180,s:100,v:75}),new c({h:180,s:100,v:50}),new c({h:180,s:0,v:40}),new c({h:210,
s:33,v:100}),new c({h:210,s:66,v:100}),new c({h:210,s:100,v:100}),new c({h:210,s:100,v:75}),new c({h:210,s:100,v:50}),new c({h:180,s:0,v:30}),new c({h:240,s:33,v:100}),new c({h:240,s:66,v:100}),new c({h:240,s:100,v:100}),new c({h:240,s:100,v:75}),new c({h:240,s:100,v:50}),new c({h:180,s:0,v:20}),new c({h:270,s:33,v:100}),new c({h:270,s:66,v:100}),new c({h:270,s:100,v:100}),new c({h:270,s:100,v:75}),new c({h:270,s:100,v:50}),new c({h:180,s:0,v:10}),new c({h:300,s:33,v:100}),new c({h:300,s:66,v:100}),
@ -653,16 +653,16 @@ new c({h:300,s:100,v:100}),new c({h:300,s:100,v:75}),new c({h:300,s:100,v:50}),n
newColor:"new",currentColor:"current",ok:"OK",cancel:"Cancel"},tooltips:{colors:{newColor:"New Color - Press &ldquo;OK&rdquo; To Commit",currentColor:"Click To Revert To Original Color"},buttons:{ok:"Commit To This Color Selection",cancel:"Cancel And Revert To Original Color"},hue:{radio:"Set To &ldquo;Hue&rdquo; Color Mode",textbox:"Enter A &ldquo;Hue&rdquo; Value (0-360&deg;)"},saturation:{radio:"Set To &ldquo;Saturation&rdquo; Color Mode",textbox:"Enter A &ldquo;Saturation&rdquo; Value (0-100%)"},
value:{radio:"Set To &ldquo;Value&rdquo; Color Mode",textbox:"Enter A &ldquo;Value&rdquo; Value (0-100%)"},red:{radio:"Set To &ldquo;Red&rdquo; Color Mode",textbox:"Enter A &ldquo;Red&rdquo; Value (0-255)"},green:{radio:"Set To &ldquo;Green&rdquo; Color Mode",textbox:"Enter A &ldquo;Green&rdquo; Value (0-255)"},blue:{radio:"Set To &ldquo;Blue&rdquo; Color Mode",textbox:"Enter A &ldquo;Blue&rdquo; Value (0-255)"},alpha:{radio:"Set To &ldquo;Alpha&rdquo; Color Mode",textbox:"Enter A &ldquo;Alpha&rdquo; Value (0-100)"},
hex:{textbox:"Enter A &ldquo;Hex&rdquo; Color Value (#000000-#ffffff)",alpha:"Enter A &ldquo;Alpha&rdquo; Value (#00-#ff)"}}}}})(jQuery,"1.1.6");(function(a){function p(n){var s=n||window.event,b=[].slice.call(arguments,1),f=0,d=0,l=0;n=a.event.fix(s);n.type="mousewheel";if(s.wheelDelta)f=s.wheelDelta/120;if(s.detail)f=-s.detail/3;l=f;if(s.axis!==undefined&&s.axis===s.HORIZONTAL_AXIS){l=0;d=-1*f}if(s.wheelDeltaY!==undefined)l=s.wheelDeltaY/120;if(s.wheelDeltaX!==undefined)d=-1*s.wheelDeltaX/120;b.unshift(n,f,d,l);return(a.event.dispatch||a.event.handle).apply(this,b)}var g=["DOMMouseScroll","mousewheel"];if(a.event.fixHooks)for(var c=g.length;c;)a.event.fixHooks[g[--c]]=
a.event.mouseHooks;a.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var n=g.length;n;)this.addEventListener(g[--n],p,false);else this.onmousewheel=p},teardown:function(){if(this.removeEventListener)for(var n=g.length;n;)this.removeEventListener(g[--n],p,false);else this.onmousewheel=null}};a.fn.extend({mousewheel:function(n){return n?this.bind("mousewheel",n):this.trigger("mousewheel")},unmousewheel:function(n){return this.unbind("mousewheel",n)}})})(jQuery);svgEditor.addExtension("eyedropper",function(a){function p(b){if(g.getMode()!="eyedropper"){var f=$("#tool_eyedropper");b.elems[0]&&$.inArray(b.elems[0].nodeName,["svg","g","use"])==-1?f.removeClass("disabled"):f.addClass("disabled")}}var g=svgEditor.canvas,c=svgedit.history.ChangeElementCommand,n={fillPaint:"red",fillOpacity:1,strokePaint:"black",strokeOpacity:1,strokeWidth:5,strokeDashArray:null,opacity:1,strokeLinecap:"butt",strokeLinejoin:"miter"},s=function(b,f,d){var l=null;console.log(b);if(b.indexOf("url(#")===
0){b=(b=g.getRefElem(b))?b.cloneNode(true):$("#"+d+"_color defs *")[0];l={alpha:f};l[b.tagName]=b}else l=b.indexOf("#")===0?{alpha:f,solidColor:b.substr(1)}:{alpha:f,solidColor:"none"};return new $.jGraduate.Paint(l)};return{name:"eyedropper",svgicons:"extensions/eyedropper-icon.xml",buttons:[{id:"tool_eyedropper",type:"mode",title:"Eye Dropper Tool",key:"I","class":"disabled",events:{click:function(){g.setMode("eyedropper")}}}],selectedChanged:p,elementChanged:p,mouseDown:function(b){var f=g.getMode(),
d=b.event;d=d.target.id==="svgroot"?document.getElementById("canvas_background"):d.target;if(f=="eyedropper"&&d){n.fillPaint=d.getAttribute("fill")||"white";n.fillOpacity=d.getAttribute("fill-opacity")||1;n.strokePaint=d.getAttribute("stroke")||"none";n.strokeOpacity=d.getAttribute("stroke-opacity")||1;n.strokeWidth=d.getAttribute("stroke-width");n.strokeDashArray=d.getAttribute("stroke-dasharray");n.strokeLinecap=d.getAttribute("stroke-linecap");n.strokeLinejoin=d.getAttribute("stroke-linejoin");
n.opacity=d.getAttribute("opacity")||1;if($.inArray(b.selectedElements.nodeName,["g","use"])==-1){var l={},q=function(o,K,T){l[K]=o.getAttribute(K);o.setAttribute(K,T)},B=new a.BatchCommand;b.selectedElements.forEach(function(o){n.fillPaint&&q(o,"fill",n.fillPaint);n.fillOpacity&&q(o,"fill-opacity",n.fillOpacity);n.strokePaint&&q(o,"stroke",n.strokePaint);n.strokeOpacity&&q(o,"stroke-opacity",n.strokeOpacity);n.strokeWidth&&q(o,"stroke-width",n.strokeWidth);n.strokeDashArray&&q(o,"stroke-dasharray",
n.strokeDashArray);n.opacity&&q(o,"opacity",n.opacity);n.strokeLinecap&&q(o,"stroke-linecap",n.strokeLinecap);n.strokeLinejoin&&q(o,"stroke-linejoin",n.strokeLinejoin);B.addSubCommand(new c(o,l));console.log(l);l={}});s(n.fillPaint,n.fillOpacity*100,"fill");s(n.strokePaint,n.strokeOpacity*100,"stroke");svgEditor.paintBox.fill.update(true);svgEditor.paintBox.stroke.update(true);g.undoMgr.addCommandToHistory(B)}}}}});svgEditor.addExtension("view_grid",function(a){function p(d){b.attr("width");b.attr("height");var l=svgedit.units.getTypeMap()[svgEditor.curConfig.baseUnit],q=[0.01,0.1,1,10,100,1E3];svgCanvas.getContentElem().getAttribute("x");var B=n;l=l*d;var o=100/l,K=1;for(d=0;d<q.length;d++){var T=q[d];K=T;if(o<=T)break}q=K*l;B.width=q;B.height=q;l=B.getContext("2d");o=q/10;l.globalAlpha=0.2;l.strokeStyle="#000";for(d=1;d<10;d++){K=Math.round(o*d)+0.5;l.moveTo(K,q);l.lineTo(K,0);l.moveTo(q,K);l.lineTo(0,K)}l.stroke();
a.event.mouseHooks;a.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var n=g.length;n;)this.addEventListener(g[--n],p,false);else this.onmousewheel=p},teardown:function(){if(this.removeEventListener)for(var n=g.length;n;)this.removeEventListener(g[--n],p,false);else this.onmousewheel=null}};a.fn.extend({mousewheel:function(n){return n?this.bind("mousewheel",n):this.trigger("mousewheel")},unmousewheel:function(n){return this.unbind("mousewheel",n)}})})(jQuery);svgEditor.addExtension("eyedropper",function(a){function p(b){if(g.getMode()!="eyedropper"){var f=$("#tool_eyedropper");b.elems[0]&&$.inArray(b.elems[0].nodeName,["svg","g","use"])==-1?f.removeClass("disabled"):f.addClass("disabled")}}var g=svgEditor.canvas,c=svgedit.history.ChangeElementCommand,n={fillPaint:"red",fillOpacity:1,strokePaint:"black",strokeOpacity:1,strokeWidth:5,strokeDashArray:null,opacity:1,strokeLinecap:"butt",strokeLinejoin:"miter"},s=function(b,f,d){var l=null;if(b.indexOf("url(#")===
0){b=(b=g.getRefElem(b))?b.cloneNode(true):$("#"+d+"_color defs *")[0];l={alpha:f};l[b.tagName]=b}else l=b.indexOf("#")===0?{alpha:f,solidColor:b.substr(1)}:{alpha:f,solidColor:"none"};return new $.jGraduate.Paint(l)};return{name:"eyedropper",svgicons:"extensions/eyedropper-icon.xml",buttons:[{id:"tool_eyedropper",type:"mode",title:"Eye Dropper Tool",key:"I","class":"disabled",icon:"extensions/eyedropper.png",events:{click:function(){g.setMode("eyedropper")}}}],selectedChanged:p,elementChanged:p,
mouseDown:function(b){var f=g.getMode(),d=b.event;d=d.target.id==="svgroot"?document.getElementById("canvas_background"):d.target;if(f=="eyedropper"&&d){n.fillPaint=d.getAttribute("fill")||"white";n.fillOpacity=d.getAttribute("fill-opacity")||1;n.strokePaint=d.getAttribute("stroke")||"none";n.strokeOpacity=d.getAttribute("stroke-opacity")||1;n.strokeWidth=d.getAttribute("stroke-width");n.strokeDashArray=d.getAttribute("stroke-dasharray");n.strokeLinecap=d.getAttribute("stroke-linecap");n.strokeLinejoin=
d.getAttribute("stroke-linejoin");n.opacity=d.getAttribute("opacity")||1;if($.inArray(b.selectedElements.nodeName,["g","use"])==-1){var l={},q=function(o,K,T){l[K]=o.getAttribute(K);o.setAttribute(K,T)},B=new a.BatchCommand;b.selectedElements.forEach(function(o){n.fillPaint&&q(o,"fill",n.fillPaint);n.fillOpacity&&q(o,"fill-opacity",n.fillOpacity);n.strokePaint&&q(o,"stroke",n.strokePaint);n.strokeOpacity&&q(o,"stroke-opacity",n.strokeOpacity);n.strokeWidth&&q(o,"stroke-width",n.strokeWidth);n.strokeDashArray&&
q(o,"stroke-dasharray",n.strokeDashArray);n.opacity&&q(o,"opacity",n.opacity);n.strokeLinecap&&q(o,"stroke-linecap",n.strokeLinecap);n.strokeLinejoin&&q(o,"stroke-linejoin",n.strokeLinejoin);B.addSubCommand(new c(o,l));l={}});s(n.fillPaint,n.fillOpacity*100,"fill");s(n.strokePaint,n.strokeOpacity*100,"stroke");svgEditor.paintBox.fill.update(true);svgEditor.paintBox.stroke.update(true);g.undoMgr.addCommandToHistory(B)}}}}});svgEditor.addExtension("view_grid",function(a){function p(d){b.attr("width");b.attr("height");var l=svgedit.units.getTypeMap()[svgEditor.curConfig.baseUnit],q=[0.01,0.1,1,10,100,1E3];svgCanvas.getContentElem().getAttribute("x");var B=n;l=l*d;var o=100/l,K=1;for(d=0;d<q.length;d++){var T=q[d];K=T;if(o<=T)break}q=K*l;B.width=q;B.height=q;l=B.getContext("2d");o=q/10;l.globalAlpha=0.2;l.strokeStyle="#000";for(d=1;d<10;d++){K=Math.round(o*d)+0.5;l.moveTo(K,q);l.lineTo(K,0);l.moveTo(q,K);l.lineTo(0,K)}l.stroke();
l.beginPath();l.globalAlpha=0.5;l.moveTo(0.5,q);l.lineTo(0.5,0);l.moveTo(q,0.5);l.lineTo(0,0.5);l.stroke();B=B.toDataURL("image/png");f.setAttribute("width",q);f.setAttribute("height",q);f.parentNode.setAttribute("width",q);f.parentNode.setAttribute("height",q);svgCanvas.setHref(f,B)}if(!document.getElementById("canvasGrid")){var g=document.getElementById("svgcanvas").ownerDocument,c=false;a=a.assignAttributes;var n=document.createElement("canvas");$(n).hide().appendTo("body");var s=g.createElementNS("http://www.w3.org/2000/svg",
"g");a(s,{id:"canvasGrid",width:"100%",height:"100%",x:0,y:0,overflow:"visible",display:"none"});var b=$("#canvas_background");b.after(s);s=g.createElementNS("http://www.w3.org/2000/svg","pattern");a(s,{id:"gridpattern",patternUnits:"userSpaceOnUse",x:0,y:0,width:100,height:100});var f=g.createElementNS("http://www.w3.org/2000/svg","image");a(f,{x:0,y:0,width:100,height:100});s.appendChild(f);$("#svgroot defs").append(s);g=g.createElementNS("http://www.w3.org/2000/svg","rect");a(g,{width:"100%",height:"100%",
x:0,y:0,"stroke-width":0,stroke:"none",fill:"url(#gridpattern)",style:"pointer-events: none; display:visible;"});$("#canvasGrid").append(g)}return{name:"view_grid",zoomChanged:function(d){c&&p(d)},buttons:[{id:"view_grid",type:"menu",after:"tool_wireframe",panel:"view_menu",title:"View Grid",events:{click:function(){if($("#view_grid").hasClass("push_button_pressed")){svgEditor.curConfig.showGrid=c=false;$("#view_grid").removeClass("push_button_pressed");$("#canvasGrid").attr("display","none")}else{svgEditor.curConfig.showGrid=
c=true;$("#view_grid").addClass("push_button_pressed");$("#canvasGrid").attr("display","normal");p(svgCanvas.getZoom())}}}}]}});svgEditor.addExtension("shapes",function(){function a(){$("#shape_buttons").empty();$("#shape_buttons").append(K.buttons)}function p(M){var J=o[M];if(J){K=J;J.buttons.length||g(M,J);a()}else{$("#shape_buttons").html("Loading...");$.getJSON("extensions/shapelib/"+M+".json",function(Q){K=o[M]={data:Q.data,size:Q.size,fill:Q.fill};g(M,Q);a()})}}function g(M,J){var Q=K.size||300,Y=K.fill||false,O=Q*0.05;O=[-O,-O,Q+O*2,Q+O*2].join(" ");Q=Y?0:Q/30;Q=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><svg viewBox="'+
O+'"><path fill="#333" stroke="transparent" stroke-width="'+Q+'" /></svg></svg>',"text/xml");Q.documentElement.setAttribute("width",40);Q.documentElement.setAttribute("height",40);Y=$(document.importNode(Q.documentElement,true));var ia=J.data;K.buttons=[];for(var pa in ia){var fa=ia[pa],ba=Y.clone();if(fa.charAt(fa.length-1)=="x"){Q=32;O=Q*0.05;O=[-O,-O,Q+O*2,Q+O*2].join(" ");ba.find("svg").attr("viewBox",O);fa.replace("x","")}ba.find("path").attr("d",fa);Q=ba.wrap('<div class="tool_button">').parent().attr({id:T+
c=true;$("#view_grid").addClass("push_button_pressed");$("#canvasGrid").attr("display","normal");p(svgCanvas.getZoom())}}}}]}});svgEditor.addExtension("shapes",function(){function a(){$("#shape_buttons").empty();$("#shape_buttons").append(K.buttons)}function p(M){var J=o[M];if(J){K=J;J.buttons.length||g(M,J);a()}else{$("#shape_buttons").html("Loading...");$.getJSON("extensions/shapelib/"+M+".json",function(Q){K=o[M]={data:Q.data,size:Q.size,fill:Q.fill};g(M,Q);a()})}}function g(M,J){var Q=K.size||300,X=K.fill||false,O=Q*0.05;O=[-O,-O,Q+O*2,Q+O*2].join(" ");Q=X?0:Q/30;Q=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><svg viewBox="'+
O+'"><path fill="#333" stroke="transparent" stroke-width="'+Q+'" /></svg></svg>',"text/xml");Q.documentElement.setAttribute("width",40);Q.documentElement.setAttribute("height",40);X=$(document.importNode(Q.documentElement,true));var ia=J.data;K.buttons=[];for(var pa in ia){var fa=ia[pa],ba=X.clone();if(fa.charAt(fa.length-1)=="x"){Q=32;O=Q*0.05;O=[-O,-O,Q+O*2,Q+O*2].join(" ");ba.find("svg").attr("viewBox",O);fa.replace("x","")}ba.find("path").attr("d",fa);Q=ba.wrap('<div class="tool_button">').parent().attr({id:T+
"_"+pa,title:pa});K.buttons.push(Q[0])}}var c,n,s=svgEditor.canvas,b,f,d,l=s.getRootElem(),q={},B={basic:"Basic",object:"Objects",symbol:"Symbols",arrow:"Arrows",flowchart:"Flowchart",nature:"Nature",game:"Cards & Chess",dialog_balloon:"Dialog balloons",music:"Music",weather:"Weather &amp; Time",ui:"User Interface",social:"Social Web"},o={basic:{data:{star_points_5:"m1,116.58409l113.82668,0l35.17332,-108.13487l35.17334,108.13487l113.82666,0l-92.08755,66.83026l35.17514,108.13487l-92.08759,-66.83208l-92.08757,66.83208l35.17515,-108.13487l-92.08758,-66.83026z",
donut:"m1,150l0,0c0,-82.29042 66.70958,-149 149,-149l0,0c39.51724,0 77.41599,15.69816 105.35889,43.64108c27.94293,27.94293 43.64111,65.84165 43.64111,105.35892l0,0c0,82.29041 -66.70958,149 -149,149l0,0c-82.29041,0 -149,-66.70959 -149,-149zm74.5,0l0,0c0,41.1452 33.35481,74.5 74.5,74.5c41.14522,0 74.5,-33.3548 74.5,-74.5c0,-41.1452 -33.3548,-74.5 -74.5,-74.5l0,0c-41.14519,0 -74.5,33.35481 -74.5,74.5z",triangle:"m1,280.375l149,-260.75l149,260.75z",right_triangle:"m1,299l0,-298l298,298z",diamond:"m1,150l149,-149l149,149l-149,149l-149,-149z",
pentagon:"m1.00035,116.97758l148.99963,-108.4053l148.99998,108.4053l-56.91267,175.4042l-184.1741,0l-56.91284,-175.4042z",hexagon:"m1,149.99944l63.85715,-127.71428l170.28572,0l63.85713,127.71428l-63.85713,127.71428l-170.28572,0l-63.85715,-127.71428z",septagon1:"m0.99917,191.06511l29.51249,-127.7108l119.48833,-56.83673l119.48836,56.83673l29.51303,127.7108l-82.69087,102.41679l-132.62103,0l-82.69031,-102.41679z",heptagon:"m1,88.28171l87.28172,-87.28171l123.43653,0l87.28172,87.28171l0,123.43654l-87.28172,87.28172l-123.43653,0l-87.28172,-87.28172l0,-123.43654z",
@ -671,12 +671,12 @@ heart:"m150,73c61,-175 300,0 0,225c-300,-225 -61,-400 0,-225z",cylinder:"m299.00
arrow_u_turn:"m1.00059,299.00055l0,-167.62497l0,0c0,-72.00411 58.37087,-130.37499 130.375,-130.37499l0,0l0,0c34.57759,0 67.73898,13.7359 92.18906,38.18595c24.45006,24.45005 38.18593,57.61144 38.18593,92.18904l0,18.625l37.24997,0l-74.49995,74.50002l-74.50002,-74.50002l37.25,0l0,-18.625c0,-30.8589 -25.0161,-55.87498 -55.87498,-55.87498l0,0l0,0c-30.85892,0 -55.875,25.01608 -55.875,55.87498l0,167.62497z",arrow_left_up:"m0.99865,224.5l74.50004,-74.5l0,37.25l111.74991,0l0,-111.75l-37.25,0l74.5,-74.5l74.5,74.5l-37.25,0l0,186.25l-186.24989,0l0,37.25l-74.50005,-74.5z",
plaque:"m-0.00197,49.94376l0,0c27.5829,0 49.94327,-22.36036 49.94327,-49.94327l199.76709,0l0,0c0,27.5829 22.36037,49.94327 49.94325,49.94327l0,199.7671l0,0c-27.58289,0 -49.94325,22.36034 -49.94325,49.94325l-199.76709,0c0,-27.58292 -22.36037,-49.94325 -49.94327,-49.94325z",page:"m249.3298,298.99744l9.9335,-39.73413l39.73413,-9.93355l-49.66763,49.66768l-248.33237,0l0,-298.00001l298.00001,0l0,248.33234",cross:"m0.99844,99.71339l98.71494,0l0,-98.71495l101.26279,0l0,98.71495l98.71495,0l0,101.2628l-98.71495,0l0,98.71494l-101.26279,0l0,-98.71494l-98.71494,0z",
divide:"m150,0.99785l0,0c25.17819,0 45.58916,20.41097 45.58916,45.58916c0,25.17821 -20.41096,45.58916 -45.58916,45.58916c-25.17822,0 -45.58916,-20.41093 -45.58916,-45.58916c0,-25.1782 20.41093,-45.58916 45.58916,-45.58916zm0,296.25203c-25.17822,0 -45.58916,-20.41095 -45.58916,-45.58917c0,-25.17819 20.41093,-45.58916 45.58916,-45.58916c25.17819,0 45.58916,20.41096 45.58916,45.58916c0,25.17822 -20.41096,45.58917 -45.58916,45.58917zm-134.06754,-193.71518l268.13507,0l0,91.17833l-268.13507,0z",minus:"m0.99887,102.39503l297.49445,0l0,95.2112l-297.49445,0z",
times:"m1.00089,73.36786l72.36697,-72.36697l76.87431,76.87368l76.87431,-76.87368l72.36765,72.36697l-76.87433,76.87431l76.87433,76.87431l-72.36765,72.36765l-76.87431,-76.87433l-76.87431,76.87433l-72.36697,-72.36765l76.87368,-76.87431l-76.87368,-76.87431z"},buttons:[]}},K=o.basic,T="shapelib";return{svgicons:"extensions/ext-shapes.xml",buttons:[{id:"tool_shapelib",type:"mode_flyout",position:6,title:"Shape library",fallback:"extensions/ext-shapes.png",events:{click:function(){s.setMode(T)}}}],callback:function(){var M=
$('<div id="shape_buttons">');$("#tools_shapelib > *").wrapAll(M);var J=$("#tools_shapelib_show");p("basic");$("#shape_buttons").mouseup(function(Y){Y=$(Y.target).closest("div.tool_button");if(Y.length){var O=Y.children().clone().attr({width:24,height:24});J.children(":not(.flyout_arrow_horiz)").remove();J.append(O).attr("data-curopt","#"+Y[0].id).mouseup();s.setMode(T);n=Y[0].id.substr((T+"_").length);c=K.data[n];$(".tools_flyout").fadeOut()}});M=$('<div id="shape_cats">');var Q="";$.each(B,function(Y,
O){Q+="<div data-cat="+Y+">"+O+"</div>"});M.html(Q).children().bind("mouseup",function(){var Y=$(this);Y.siblings().removeClass("current");Y.addClass("current");p(Y.attr("data-cat"));return false});M.children().eq(0).addClass("current");$("#tools_shapelib").prepend(M);J.mouseup(function(){s.setMode(c?T:"select")});$("#tool_shapelib").remove();M=$("#tools_shapelib").height();$("#tools_shapelib").css({"margin-top":-(M/2),"margin-left":3})},mouseDown:function(M){if(s.getMode()===T){var J=f=M.start_x;
times:"m1.00089,73.36786l72.36697,-72.36697l76.87431,76.87368l76.87431,-76.87368l72.36765,72.36697l-76.87433,76.87431l76.87433,76.87431l-72.36765,72.36765l-76.87431,-76.87433l-76.87431,76.87433l-72.36697,-72.36765l76.87368,-76.87431l-76.87368,-76.87431z"},buttons:[]}},K=o.basic,T="shapelib";return{svgicons:"extensions/ext-shapes.xml",buttons:[{id:"tool_shapelib",type:"mode_flyout",position:6,title:"Shape library",icon:"extensions/ext-shapes.png",events:{click:function(){s.setMode(T)}}}],callback:function(){var M=
$('<div id="shape_buttons">');$("#tools_shapelib > *").wrapAll(M);var J=$("#tools_shapelib_show");p("basic");$("#shape_buttons").mouseup(function(X){X=$(X.target).closest("div.tool_button");if(X.length){var O=X.children().clone().attr({width:24,height:24});J.children(":not(.flyout_arrow_horiz)").remove();J.append(O).attr("data-curopt","#"+X[0].id).mouseup();s.setMode(T);n=X[0].id.substr((T+"_").length);c=K.data[n];$(".tools_flyout").fadeOut()}});M=$('<div id="shape_cats">');var Q="";$.each(B,function(X,
O){Q+="<div data-cat="+X+">"+O+"</div>"});M.html(Q).children().bind("mouseup",function(){var X=$(this);X.siblings().removeClass("current");X.addClass("current");p(X.attr("data-cat"));return false});M.children().eq(0).addClass("current");$("#tools_shapelib").prepend(M);J.mouseup(function(){s.setMode(c?T:"select")});$("#tool_shapelib").remove();M=$("#tools_shapelib").height();$("#tools_shapelib").css({"margin-top":-(M/2),"margin-left":3})},mouseDown:function(M){if(s.getMode()===T){var J=f=M.start_x;
M=d=M.start_y;var Q=s.getStyle();b=s.addSvgElementFromJson({element:"path",curStyles:true,attr:{d:c,id:s.getNextId(),opacity:Q.opacity/2,style:"pointer-events:none"}});b.setAttribute("d",c);if(/[a-z]/.test(c)){c=K.data[n]=s.pathActions.convertPath(b);b.setAttribute("d",c);s.pathActions.fixEnd(b)}b.setAttribute("transform","translate("+J+","+M+") scale(0.005) translate("+-J+","+-M+")");s.recalculateDimensions(b);s.getTransformList(b);q=b.getBBox();totalScale={sx:1,sy:1};return{started:true}}},mouseMove:function(M){if(s.getMode()===
T){var J=s.getZoom(),Q=M.event,Y=M.mouse_x/J,O=M.mouse_y/J;M=s.getTransformList(b);var ia=b.getBBox();J=ia.x;var pa=ia.y,fa=ia.width,ba=ia.height,W=Y-f,sa=O-d,ka={x:Math.min(f,Y),y:Math.min(d,O),width:Math.abs(Y-f),height:Math.abs(O-d)},da=ia=0;ba=ba?(ba+sa)/ba:1;fa=fa?(fa+W)/fa:1;fa=ka.width/q.width;ba=ka.height/q.height;fa=fa||1;ba=ba||1;if(Y<f)ia=q.width;if(O<d)da=q.height;Y=l.createSVGTransform();O=l.createSVGTransform();ka=l.createSVGTransform();Y.setTranslate(-(J+ia),-(pa+da));if(Q.shiftKey){replaced=
true;Q=Math.min(Math.abs(fa),Math.abs(ba));fa=Q*(fa<0?-1:1);ba=Q*(ba<0?-1:1);if(totalScale.sx!=totalScale.sy){Q=totalScale.sx>totalScale.sy?1:totalScale.sx/totalScale.sy;fa*=totalScale.sy>totalScale.sx?1:totalScale.sy/totalScale.sx;ba*=Q}}totalScale.sx*=fa;totalScale.sy*=ba;O.setScale(fa,ba);ka.setTranslate(J+ia,pa+da);M.appendItem(ka);M.appendItem(O);M.appendItem(Y);s.recalculateDimensions(b);q=b.getBBox()}},mouseUp:function(M){if(s.getMode()===T){if(M.mouse_x==f&&M.mouse_y==d)return{keep:false,
T){var J=s.getZoom(),Q=M.event,X=M.mouse_x/J,O=M.mouse_y/J;M=s.getTransformList(b);var ia=b.getBBox();J=ia.x;var pa=ia.y,fa=ia.width,ba=ia.height,W=X-f,sa=O-d,ka={x:Math.min(f,X),y:Math.min(d,O),width:Math.abs(X-f),height:Math.abs(O-d)},da=ia=0;ba=ba?(ba+sa)/ba:1;fa=fa?(fa+W)/fa:1;fa=ka.width/q.width;ba=ka.height/q.height;fa=fa||1;ba=ba||1;if(X<f)ia=q.width;if(O<d)da=q.height;X=l.createSVGTransform();O=l.createSVGTransform();ka=l.createSVGTransform();X.setTranslate(-(J+ia),-(pa+da));if(Q.shiftKey){replaced=
true;Q=Math.min(Math.abs(fa),Math.abs(ba));fa=Q*(fa<0?-1:1);ba=Q*(ba<0?-1:1);if(totalScale.sx!=totalScale.sy){Q=totalScale.sx>totalScale.sy?1:totalScale.sx/totalScale.sy;fa*=totalScale.sy>totalScale.sx?1:totalScale.sy/totalScale.sx;ba*=Q}}totalScale.sx*=fa;totalScale.sy*=ba;O.setScale(fa,ba);ka.setTranslate(J+ia,pa+da);M.appendItem(ka);M.appendItem(O);M.appendItem(X);s.recalculateDimensions(b);q=b.getBBox()}},mouseUp:function(M){if(s.getMode()===T){if(M.mouse_x==f&&M.mouse_y==d)return{keep:false,
element:b,started:false};s.setMode("select");return{keep:true,element:b,started:false}}}}});(function(){for(var a=0,p=["ms","moz","webkit","o"],g=0;g<p.length&&!window.requestAnimationFrame;++g){window.requestAnimationFrame=window[p[g]+"RequestAnimationFrame"];window.cancelAnimationFrame=window[p[g]+"CancelAnimationFrame"]||window[p[g]+"CancelRequestAnimationFrame"]}if(!window.requestAnimationFrame)window.requestAnimationFrame=function(c){var n=(new Date).getTime(),s=Math.max(0,16-(n-a)),b=window.setTimeout(function(){c(n+s)},s);a=n+s;return b};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=
function(c){clearTimeout(c)}})();(function(a){function p(o){var K=o.originalEvent;if(!K.touches||K.targetTouches.length===1&&K.touches.length===1){b.call(this,o);o=a(this);o.bind(q,g);o.bind(l,c)}else{clearTimeout(B);s.call(this)}}function g(o){if(B!=null){var K=o.originalEvent;o=K.changedTouches?K.changedTouches[0].pageX:K.pageX;K=K.changedTouches?K.changedTouches[0].pageY:K.pageY;var T=a(this).data("taphold.point");o=o-T.x;K=K-T.y;if(Math.sqrt(o*o+K*K)>d){clearTimeout(B);s.call(this)}}}function c(){clearTimeout(B);s.call(this)}
function n(o){s.call(this);a(this).data("taphold.handler").call(this,o)}function s(){B=null;a(this).unbind(q,g);a(this).unbind(l,c)}function b(o){if(B==null){var K=this;B=setTimeout(function(){n.call(K,o)},f);var T=o.originalEvent,M={};M.x=T.changedTouches?T.changedTouches[0].pageX:T.pageX;M.y=T.changedTouches?T.changedTouches[0].pageY:T.pageY;a(this).data("taphold.point",M)}}var f=1E3,d=5,l="touchend",q="touchmove",B=null;a.event.special.taphold={setup:function(){},add:function(o){a(this).data("taphold.handler",