websch/editor/svgedit.compiled.js

688 lines
348 KiB
JavaScript

function touchHandler(a){var q=a.changedTouches,h=q[0],b="";switch(a.type){case "touchstart":b="mousedown";break;case "touchmove":b="mousemove";break;case "touchend":b="mouseup";break;default:return}var n=document.createEvent("MouseEvent");n.initMouseEvent(b,true,true,window,1,h.screenX,h.screenY,h.clientX,h.clientY,false,false,false,false,0,null);if(q.length<2){h.target.dispatchEvent(n);a.preventDefault()}};(function(a){function q(h){if(typeof h.data==="string"){var b=h.handler,n=h.data.toLowerCase().split(" ");h.handler=function(u){if(!(this!==u.target&&(/textarea|select/i.test(u.target.nodeName)||u.target.type==="text"))){var c=u.type!=="keypress"&&a.hotkeys.specialKeys[u.which],g=String.fromCharCode(u.which).toLowerCase(),d="",l={};if(u.altKey&&c!=="alt")d+="alt+";if(u.ctrlKey&&c!=="ctrl")d+="ctrl+";if(u.metaKey&&!u.ctrlKey&&c!=="meta")d+="meta+";if(u.shiftKey&&c!=="shift")d+="shift+";if(c)l[d+c]=
true;else{l[d+g]=true;l[d+a.hotkeys.shiftNums[g]]=true;if(d==="shift+")l[a.hotkeys.shiftNums[g]]=true}c=0;for(g=n.length;c<g;c++)if(l[n[c]])return b.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:q}})})(jQuery);(function(a,q){function h(da){return typeof da==="string"}function b(da){var V=d.call(arguments,1);return function(){return da.apply(this,V.concat(d.call(arguments)))}}function n(da,V,X,oa,qa){var ma;if(oa!==g){V=X.match(da?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);X=V[3]||"";if(qa===2&&h(oa))oa=oa.replace(da?Z:T,"");else{ma=p(V[2]);oa=h(oa)?p[da?ha:N](oa):oa;oa=qa===2?oa:qa===1?a.extend({},oa,ma):a.extend({},ma,oa);oa=v(oa);if(da)oa=oa.replace(ua,l)}da=V[1]+(da?"#":oa||!V[1]?"?":"")+oa+X}else da=
V(X!==g?X:q[pa][fa]);return da}function u(da,V,X){if(V===g||typeof V==="boolean"){X=V;V=v[da?ha:N]()}else V=h(V)?V.replace(da?Z:T,""):V;return p(V,X)}function c(da,V,X,oa){if(!h(X)&&typeof X!=="object"){oa=X;X=V;V=g}return this.each(function(){var qa=a(this),ma=V||Q()[(this.nodeName||"").toLowerCase()]||"",la=ma&&qa.attr(ma)||"";qa.attr(ma,v[da](la,X,oa))})}var g,d=Array.prototype.slice,l=decodeURIComponent,v=a.param,A,p,K,R=a.bbq=a.bbq||{},O,I,Q,U=a.event.special,N="querystring",ha="fragment",pa=
"location",fa="href",T=/^.*\?|#.*$/g,Z=/^.*\#/,ua,ja={};v[N]=b(n,0,function(da){return da.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")});v[ha]=A=b(n,1,function(da){return da.replace(/^[^#]*#?(.*)$/,"$1")});A.noEscape=function(da){da=da||"";da=a.map(da.split(""),encodeURIComponent);ua=RegExp(da.join("|"),"g")};A.noEscape(",/");a.deparam=p=function(da,V){var X={},oa={"true":true,"false":false,"null":null};a.each(da.replace(/\+/g," ").split("&"),function(qa,ma){var la=ma.split("="),wa=l(la[0]),Ha=X,Ba=
0,Ia=wa.split("]["),Ka=Ia.length-1;if(/\[/.test(Ia[0])&&/\]$/.test(Ia[Ka])){Ia[Ka]=Ia[Ka].replace(/\]$/,"");Ia=Ia.shift().split("[").concat(Ia);Ka=Ia.length-1}else Ka=0;if(la.length===2){la=l(la[1]);if(V)la=la&&!isNaN(la)?+la:la==="undefined"?g:oa[la]!==g?oa[la]:la;if(Ka)for(;Ba<=Ka;Ba++){wa=Ia[Ba]===""?Ha.length:Ia[Ba];Ha=Ha[wa]=Ba<Ka?Ha[wa]||(Ia[Ba+1]&&isNaN(Ia[Ba+1])?{}:[]):la}else if(a.isArray(X[wa]))X[wa].push(la);else X[wa]=X[wa]!==g?[X[wa],la]:la}else if(wa)X[wa]=V?g:""});return X};p[N]=b(u,
0);p[ha]=K=b(u,1);a.elemUrlAttr||(a.elemUrlAttr=function(da){return a.extend(ja,da)})({a:fa,base:fa,iframe:"src",img:"src",input:"src",form:"action",link:fa,script:"src"});Q=a.elemUrlAttr;a.fn[N]=b(c,N);a.fn[ha]=b(c,ha);R.pushState=O=function(da,V){if(h(da)&&/^#/.test(da)&&V===g)V=2;var X=da!==g;X=A(q[pa][fa],X?da:{},X?V:2);q[pa][fa]=X+(/#/.test(X)?"":"#")};R.getState=I=function(da,V){return da===g||typeof da==="boolean"?K(da):K(V)[da]};R.removeState=function(da){var V={};if(da!==g){V=I();a.each(a.isArray(da)?
da:arguments,function(X,oa){delete V[oa]})}O(V,2)};U.hashchange=a.extend(U.hashchange,{add:function(da){function V(oa){var qa=oa[ha]=A();oa.getState=function(ma,la){return ma===g||typeof ma==="boolean"?p(qa,ma):p(qa,la)[ma]};X.apply(this,arguments)}var X;if(a.isFunction(da)){X=da;return V}else{X=da.handler;da.handler=V}}})})(jQuery,this);
(function(a,q,h){function b(A){A=A||q[c][g];return A.replace(/^[^#]*#?(.*)$/,"$1")}var n,u=a.event.special,c="location",g="href",d=document.documentMode,l=a.browser.msie&&(d===h||d<8),v="onhashchange"in q&&!l;a.hashchangeDelay=100;u.hashchange=a.extend(u.hashchange,{setup:function(){if(v)return false;a(n.start)},teardown:function(){if(v)return false;a(n.stop)}});n=function(){function A(){O=I=function(Q){return Q};if(l){R=a('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;
I=function(){return b(R.document[c][g])};O=function(Q,U){if(Q!==U){var N=R.document;N.open().close();N[c].hash="#"+Q}};O(b())}}var p={},K,R,O,I;p.start=function(){if(!K){var Q=b();O||A();(function U(){var N=b(),ha=I(Q);if(N!==Q){O(Q=N,ha);a(q).trigger("hashchange")}else if(ha!==Q)q[c][g]=q[c][g].replace(/#.*/,"")+"#"+ha;K=setTimeout(U,a.hashchangeDelay)})()}};p.stop=function(){if(!R){K&&clearTimeout(K);K=0}};return p}()})(jQuery,this);(function(a){var q={},h;a.svgIcons=function(b,n){function u(da,V){if(da!=="ajax"){if(Q)return;var X=(R=fa[0].contentDocument)&&R.getElementById("svg_eof");if(!X&&!(V&&X)){U++;if(U<50)setTimeout(u,20);else{g();Q=true}return}Q=true}K=a(R.firstChild).children();if(n.no_img)setTimeout(function(){I||c()},500);else{X=pa+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";O=a(new Image).attr({src:X,width:0,height:0}).appendTo("body").load(function(){c(true)}).error(function(){c()})}}
function c(da,V){if(!I){if(n.no_img)da=false;if(da){var X=a(document.createElement("div"));X.hide().appendTo("body")}if(V){var oa=n.fallback_path?n.fallback_path:"";a.each(V,function(Ka,Ja){a("#"+Ka);var Ea=a(new Image).attr({"class":"svg_icon",src:oa+Ja,width:A,height:p,alt:"icon"});ja(Ea,Ka)})}else for(var qa=K.length,ma=0;ma<qa;ma++){var la=K[ma],wa=la.id;if(wa==="svg_eof")break;a("#"+wa);la=la.getElementsByTagNameNS(l,"svg")[0];var Ha=document.createElementNS(l,"svg");Ha.setAttributeNS(l,"viewBox",
[0,0,A,p].join(" "));var Ba=la.getAttribute("width"),Ia=la.getAttribute("height");la.removeAttribute("width");la.removeAttribute("height");la.getAttribute("viewBox")||la.setAttribute("viewBox",[0,0,Ba,Ia].join(" "));Ha.setAttribute("xmlns",l);Ha.setAttribute("width",A);Ha.setAttribute("height",p);Ha.setAttribute("xmlns:xlink",v);Ha.setAttribute("class","svg_icon");ha||(la=la.cloneNode(true));Ha.appendChild(la);if(da){ha||Ha.cloneNode(true);X.empty().append(Ha);la=pa+d(X.html());la=a(new Image).attr({"class":"svg_icon",
src:la})}else la=h(a(Ha),ma);ja(la,wa)}n.placement&&a.each(n.placement,function(Ka,Ja){q[Ja]&&a(Ka).each(function(Ea){var va=q[Ja].clone();if(Ea>0&&!da)va=h(va,Ea,true);ua(a(this),va,Ja)})});if(!V){da&&X.remove();fa&&fa.remove();O&&O.remove()}n.resize&&a.resizeSvgIcons(n.resize);I=true;n.callback&&n.callback(q)}}function g(){if(b.indexOf(".svgz")!=-1){var da=b.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg");a.svgIcons(da,n)}else n.fallback&&c(false,n.fallback)}
function d(da){if(window.btoa)return window.btoa(da);var V=Array(Math.floor((da.length+2)/3)*4),X,oa,qa,ma,la,wa,Ha=0,Ba=0;do{X=da.charCodeAt(Ha++);oa=da.charCodeAt(Ha++);qa=da.charCodeAt(Ha++);ma=X>>2;X=(X&3)<<4|oa>>4;la=(oa&15)<<2|qa>>6;wa=qa&63;if(isNaN(oa))la=wa=64;else if(isNaN(qa))wa=64;V[Ba++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(ma);V[Ba++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(X);V[Ba++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(la);
V[Ba++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(wa)}while(Ha<da.length);return V.join("")}var l="http://www.w3.org/2000/svg",v="http://www.w3.org/1999/xlink",A=n.w?n.w:24,p=n.h?n.h:24,K,R,O,I=false,Q=false,U=0,N=navigator.userAgent,ha=!!window.opera;N.indexOf("Safari/")>-1&&N.indexOf("Chrome/");var pa="data:image/svg+xml;charset=utf-8;base64,";if(n.svgz){var fa=a('<object data="'+b+'" type=image/svg+xml>').appendTo("body").hide();try{R=fa[0].contentDocument;fa.load(u);
u(0,true)}catch(T){g()}}else{var Z=new DOMParser;a.ajax({url:b,dataType:"string",success:function(da){if(da){R=Z.parseFromString(da,"text/xml");a(function(){u("ajax")})}else a(g)},error:function(da){if(window.opera)a(function(){g()});else if(da.responseText){R=Z.parseFromString(da.responseText,"text/xml");R.childNodes.length||a(g);a(function(){u("ajax")})}else a(g)}})}var ua=function(da,V,X,oa){ha&&V.css("visibility","hidden");if(n.replace){oa&&V.attr("id",X);(X=da.attr("class"))&&V.attr("class",
"svg_icon "+X);da.replaceWith(V)}else da.append(V);ha&&setTimeout(function(){V.removeAttr("style")},1)},ja=function(da,V){if(n.id_match===undefined||n.id_match!==false)ua(holder,da,V,true);q[V]=da};h=function(da,V){var X=da.find("defs");if(!X.length)return da;X=ha?X.find("*").filter(function(){return!!this.id}):X.find("[id]");var oa=da[0].getElementsByTagName("*"),qa=oa.length;X.each(function(ma){var la=this.id;a(R).find("#"+la);this.id=ma="x"+la+V+ma;la="url(#"+la+")";var wa="url(#"+ma+")";for(ma=
0;ma<qa;ma++){var Ha=oa[ma];Ha.getAttribute("fill")===la&&Ha.setAttribute("fill",wa);Ha.getAttribute("stroke")===la&&Ha.setAttribute("stroke",wa);Ha.getAttribute("filter")===la&&Ha.setAttribute("filter",wa)}});return da}};a.getSvgIcon=function(b,n){var u=q[b];if(n&&u)u=h(u,0,true).clone(true);return u};a.resizeSvgIcons=function(b){var n=!a(".svg_icon:first").length;a.each(b,function(u,c){var g=a.isArray(c),d=g?c[0]:c,l=g?c[1]:c;if(n)u=u.replace(/\.svg_icon/g,"svg");a(u).each(function(){this.setAttribute("width",
d);this.setAttribute("height",l);if(window.opera&&window.widget){this.parentNode.style.width=d+"px";this.parentNode.style.height=l+"px"}})})}})(jQuery);(function(){function a(b,n,u){b=document.createElementNS(q.svg,b);if(h)for(var c in n)b.setAttribute(c,n[c]);else for(c in n){var g=n[c],d=b[c];if(d&&d.constructor==="SVGLength")d.baseVal.value=g;else b.setAttribute(c,g)}u&&u.appendChild(b);return b}var q={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};if(!window.console)window.console=new function(){this.log=function(){};this.dir=function(){}};$.jGraduate={Paint:function(b){b=b||{};this.alpha=isNaN(b.alpha)?100:b.alpha;if(b.copy){this.type=
b.copy.type;this.alpha=b.copy.alpha;this.radialGradient=this.linearGradient=this.solidColor=null;switch(this.type){case "solidColor":this.solidColor=b.copy.solidColor;break;case "linearGradient":this.linearGradient=b.copy.linearGradient.cloneNode(true);break;case "radialGradient":this.radialGradient=b.copy.radialGradient.cloneNode(true)}}else if(b.linearGradient){this.type="linearGradient";this.radialGradient=this.solidColor=null;this.linearGradient=b.linearGradient.cloneNode(true)}else if(b.radialGradient){this.type=
"radialGradient";this.linearGradient=this.solidColor=null;this.radialGradient=b.radialGradient.cloneNode(true)}else if(b.solidColor){this.type="solidColor";this.solidColor=b.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 h=navigator.userAgent.indexOf("Gecko/")>=0;jQuery.fn.jGraduate=function(b){var n=
arguments;return this.each(function(){function u(ia,ca,ka,M,P){var ea=P||a("stop",{"stop-color":ca,"stop-opacity":ka,offset:ia},Z);if(P){ca=P.getAttribute("stop-color");ka=P.getAttribute("stop-opacity");ia=P.getAttribute("offset")}else Z.appendChild(ea);if(ka===null)ka=1;P=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+ia*ha)+", 26)"},Ua);var Fa=
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":ka,transform:"translate("+(10+ia*ha)+", 26)",stroke:"#000","stroke-width":1.5},Ua);$(Fa).mousedown(function(Oa){c(this);Xa=fb;Q.mousemove(l).mouseup(g);sa=ub.offset();Oa.preventDefault();return false}).data("stop",ea).data("bg",P).dblclick(function(){$("div.jGraduate_LightBox").show();for(var Oa=this,Ra=+ea.getAttribute("stop-opacity")||
1,cb=ea.getAttribute("stop-color")||1,pb=(parseFloat(Ra)*255).toString(16);pb.length<2;)pb="0"+pb;ca=cb.substr(1)+pb;$("#"+p+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:A.images.clientPath},color:{active:ca,alphaSupport:true}},function(Sa){cb=Sa.val("hex")?"#"+Sa.val("hex"):"none";Ra=Sa.val("a")!==null?Sa.val("a")/256:1;Oa.setAttribute("fill",cb);Oa.setAttribute("fill-opacity",Ra);ea.setAttribute("stop-color",
cb);ea.setAttribute("stop-opacity",Ra);$("div.jGraduate_LightBox").hide();$("#"+p+"_jGraduate_stopPicker").hide()},null,function(){$("div.jGraduate_LightBox").hide();$("#"+p+"_jGraduate_stopPicker").hide()})});$(Z).find("stop").each(function(){var Oa=$(this);if(+this.getAttribute("offset")>ia){if(!ca){var Ra=this.getAttribute("stop-color"),cb=this.getAttribute("stop-opacity");ea.setAttribute("stop-color",Ra);Fa.setAttribute("fill",Ra);ea.setAttribute("stop-opacity",cb===null?1:cb);Fa.setAttribute("fill-opacity",
cb===null?1:cb)}Oa.before(ea);return false}});M&&c(Fa);return ea}function c(ia){fb&&fb.setAttribute("stroke","#000");ia.setAttribute("stroke","blue");fb=ia;fb.parentNode.appendChild(fb)}function g(){Q.unbind("mousemove",l);if(Ca.getAttribute("display")!=="none"){Ca.setAttribute("display","none");var ia=$(fb),ca=ia.data("stop");ia=ia.data("bg");$([fb,ca,ia]).remove()}Xa=null}function d(){var ia=Ta?"rotate("+Ta+","+Da+","+hb+") ":"";db===1&&La===1?Z.removeAttribute("gradientTransform"):Z.setAttribute("gradientTransform",
ia+"translate("+-Da*(db-1)+","+-hb*(La-1)+") scale("+db+","+La+")")}function l(ia){var ca=ia.pageX-sa.left;ia=ia.pageY-sa.top;ca=ca<10?10:ca>ha+10?ha+10:ca;var ka="translate("+ca+", 26)";if(ia<-60||ia>130){Ca.setAttribute("display","block");Ca.setAttribute("transform",ka)}else Ca.setAttribute("display","none");Xa.setAttribute("transform",ka);$.data(Xa,"bg").setAttribute("transform",ka);$.data(Xa,"stop").setAttribute("offset",(ca-10)/ha);var M=0;$(Z).find("stop").each(function(){var P=this.getAttribute("offset"),
ea=$(this);if(P<M){ea.prev().before(ea);ta=$(Z).find("stop")}M=P})}var v=$(this),A=$.extend(true,{},jQuery.fn.jGraduateDefaults,b),p=v.attr("id"),K="#"+v.attr("id")+" ";if(K){var R=function(){switch(v.paint.type){case "radialGradient":v.paint.linearGradient=null;break;case "linearGradient":v.paint.radialGradient=null;break;case "solidColor":v.paint.radialGradient=v.paint.linearGradient=null}$.isFunction(v.okCallback)&&v.okCallback(v.paint);v.hide()},O=function(){$.isFunction(v.cancelCallback)&&v.cancelCallback();
v.hide()};$.extend(true,v,{paint:new $.jGraduate.Paint({copy:A.paint}),okCallback:$.isFunction(n[1])&&n[1]||null,cancelCallback:$.isFunction(n[2])&&n[2]||null});v.position();var I=null,Q=$(window);if(v.paint.type=="none")v.paint=$.jGraduate.Paint({solidColor:"ffffff"});v.addClass("jGraduate_Picker");v.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="'+
p+'_jGraduate_stopPicker" class="jGraduate_stopPicker"></div>');var U=$(K+"> .jGraduate_colPick"),N=$(K+"> .jGraduate_gradPick");N.html('<div id="'+p+'_jGraduate_Swatch" class="jGraduate_Swatch"><h2 class="jGraduate_Title">'+A.window.pickerTitle+'</h2><div id="'+p+'_jGraduate_GradContainer" class="jGraduate_GradContainer"></div><div id="'+p+'_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="'+
p+'_jGraduate_x1" size="3" title="Enter starting x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+p+'_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="'+p+'_jGraduate_x2" size="3" title="Enter ending x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+
p+'_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="'+p+'_jGraduate_cx" size="3" title="Enter x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+p+'_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="'+
p+'_jGraduate_match_ctr"/></label><br/><label>x:</label><input type="text" id="'+p+'_jGraduate_fx" size="3" title="Enter x value between 0.0 and 1.0"/><label> y:</label><input type="text" id="'+p+'_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="'+
p+'_jGraduate_Radius" class="jGraduate_SliderBar jGraduate_Radius" title="Click to set radius"><img id="'+p+'_jGraduate_RadiusArrows" class="jGraduate_RadiusArrows" src="'+A.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+p+'_jGraduate_RadiusInput" size="3" value="100"/>%</label></div><div class="jGraduate_Slider jGraduate_EllipField jGraduate_rg_field"><label class="prelabel">Ellip:</label><div id="'+p+'_jGraduate_Ellip" class="jGraduate_SliderBar jGraduate_Ellip" title="Click to set Ellip"><img id="'+
p+'_jGraduate_EllipArrows" class="jGraduate_EllipArrows" src="'+A.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+p+'_jGraduate_EllipInput" size="3" value="0"/>%</label></div><div class="jGraduate_Slider jGraduate_AngleField jGraduate_rg_field"><label class="prelabel">Angle:</label><div id="'+p+'_jGraduate_Angle" class="jGraduate_SliderBar jGraduate_Angle" title="Click to set Angle"><img id="'+p+'_jGraduate_AngleArrows" class="jGraduate_AngleArrows" src="'+A.images.clientPath+
'rangearrows2.gif"></div><label><input type="text" id="'+p+'_jGraduate_AngleInput" size="3" value="0"/>\u00ba&nbsp;</label></div><div class="jGraduate_Slider jGraduate_OpacField"><label class="prelabel">Opac:</label><div id="'+p+'_jGraduate_Opac" class="jGraduate_SliderBar jGraduate_Opac" title="Click to set Opac"><img id="'+p+'_jGraduate_OpacArrows" class="jGraduate_OpacArrows" src="'+A.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+p+'_jGraduate_OpacInput" size="3" value="100"/>%</label></div></div><div class="jGraduate_OkCancel"><input type="button" id="'+
p+'_jGraduate_Ok" class="jGraduate_Ok" value="OK"/><input type="button" id="'+p+'_jGraduate_Cancel" class="jGraduate_Cancel" value="Cancel"/></div>');var ha=256,pa=ha-0,fa=ha-0,T,Z,ua,ja={};$(".jGraduate_SliderBar").width(145);var da=$("#"+p+"_jGraduate_GradContainer")[0],V=a("svg",{id:p+"_jgraduate_svg",width:ha,height:ha,xmlns:q.svg},da);T=T||v.paint.type;var X=Z=v.paint[T],oa=v.paint.alpha,qa=T==="solidColor";switch(T){case "solidColor":case "linearGradient":if(!qa){Z.id=p+"_lg_jgraduate_grad";
X=Z=V.appendChild(Z)}a("radialGradient",{id:p+"_rg_jgraduate_grad"},V);if(T==="linearGradient")break;case "radialGradient":if(!qa){Z.id=p+"_rg_jgraduate_grad";X=Z=V.appendChild(Z)}a("linearGradient",{id:p+"_lg_jgraduate_grad"},V)}if(qa){X=Z=$("#"+p+"_lg_jgraduate_grad")[0];I=v.paint[T];u(0,"#"+I,1);var ma=typeof A.newstop;if(ma==="string")switch(A.newstop){case "same":u(1,"#"+I,1);break;case "inverse":ma="";for(var la=0;la<6;la+=2){I.substr(la,2);var wa=(255-parseInt(I.substr(la,2),16)).toString(16);
if(wa.length<2)wa=0+wa;ma+=wa}u(1,"#"+ma,1);break;case "white":u(1,"#ffffff",1);break;case "black":u(1,"#000000",1)}else if(ma==="object")u(1,A.newstop.color||"#"+I,"opac"in A.newstop?A.newstop.opac:1)}I=parseFloat(X.getAttribute("x1")||0);ma=parseFloat(X.getAttribute("y1")||0);la=parseFloat(X.getAttribute("x2")||1);wa=parseFloat(X.getAttribute("y2")||0);var Ha=parseFloat(X.getAttribute("cx")||0.5),Ba=parseFloat(X.getAttribute("cy")||0.5),Ia=parseFloat(X.getAttribute("fx")||Ha),Ka=parseFloat(X.getAttribute("fy")||
Ba);ua=a("rect",{id:p+"_jgraduate_rect",x:0,y:0,width:pa,height:fa,fill:"url(#"+p+"_jgraduate_grad)","fill-opacity":oa/100},V);var Ja=$("<div/>").attr({"class":"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:ma*ha,left:I*ha}).data("coord","start").appendTo(da),Ea=Ja.clone().text(2).css({top:wa*ha,left:la*ha}).attr("title","End stop").data("coord","end").appendTo(da),va=$("<div/>").attr({"class":"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:Ba*ha,left:Ha*
ha}).data("coord","center").appendTo(da),Ga=va.clone().text("F").css({top:Ka*ha,left:Ia*ha,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(da);Ga[0].id=p+"_jGraduate_focusCoord";$(K+" .grad_coord");$.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(ia,ca){var ka=Z.getAttribute(ca),M=isNaN(ca[1]);ka||(ka=M?"0.5":ca==="x2"?"1.0":"0.0");ja[ca]=$("#"+p+"_jGraduate_"+ca).val(ka).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"&&!gb))if(M&&T==="radialGradient"||!M&&T==="linearGradient")Z.setAttribute(ca,this.value);var P=M?ca[0]==="c"?va:Ga:ca[1]==="1"?Ja:Ea,ea=ca.indexOf("x")>=0?"left":"top";P.css(ea,this.value*ha)}).change()});var ta,Ua,ub=$("#"+p+"_jGraduate_StopSlider"),fb,Va,Xa,Ca=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),sa,db=1,La=1,Ta=0,Da=Ha,hb=Ba;Va=a("svg",{width:"100%",height:45},ub[0]);da=a("pattern",{width:16,
height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},Va);a("image",{width:16,height:16},da).setAttributeNS(q.xlink,"xlink:href",A.images.clientPath+"map-opacity.png");$(Va).on("click touchstart",function(ia){sa=ub.offset();if(ia.target.tagName!=="path"){var ca=ia.pageX-sa.left-8;ca=ca<10?10:ca>ha+10?ha+10:ca;u(ca/ha,0,0,true);ia.stopPropagation()}});$(Va).mouseover(function(){Va.appendChild(Ca)});Ua=a("g",{},Va);a("line",{x1:10,y1:15,x2:ha+10,y2:15,"stroke-width":2,stroke:"#000"},Va);var qb=
N.find(".jGraduate_spreadMethod").change(function(){Z.setAttribute("spreadMethod",$(this).val())}),Ya=null,Za=function(ia){var ca=ia.pageX-kb.left,ka=ia.pageY-kb.top;ca=ca<0?0:ca>ha?ha:ca;ka=ka<0?0:ka>ha?ha:ka;Ya.css("left",ca).css("top",ka);ca=ca/pa;ka=ka/fa;var M=Ya.data("coord"),P=Z;switch(M){case "start":ja.x1.val(ca);ja.y1.val(ka);P.setAttribute("x1",ca);P.setAttribute("y1",ka);break;case "end":ja.x2.val(ca);ja.y2.val(ka);P.setAttribute("x2",ca);P.setAttribute("y2",ka);break;case "center":ja.cx.val(ca);
ja.cy.val(ka);P.setAttribute("cx",ca);P.setAttribute("cy",ka);Da=ca;hb=ka;d();break;case "focus":ja.fx.val(ca);ja.fy.val(ka);P.setAttribute("fx",ca);P.setAttribute("fy",ka);d()}ia.preventDefault()},vb=function(){Ya=null;Q.unbind("mousemove",Za).unbind("mouseup",vb)};ta=Z.getElementsByTagNameNS(q.svg,"stop");if(ra<2){for(;ra<2;){Z.appendChild(document.createElementNS(q.svg,"stop"));++ra}ta=Z.getElementsByTagNameNS(q.svg,"stop")}var ra=ta.length;for(la=0;la<ra;la++)u(0,0,0,0,ta[la]);qb.val(Z.getAttribute("spreadMethod")||
"pad");var kb,gb=false;ua.setAttribute("fill-opacity",oa/100);$("#"+p+" div.grad_coord").mousedown(function(ia){ia.preventDefault();Ya=$(this);Ya.offset();kb=Ya.parent().offset();Q.mousemove(Za).mouseup(vb)});$("#"+p+"_jGraduate_Ok").bind("click touchstart",function(){v.paint.type=T;v.paint[T]=Z.cloneNode(true);v.paint.solidColor=null;R()});$("#"+p+"_jGraduate_Cancel").bind("click touchstart",function(){O()});if(T==="radialGradient")if(gb)Ga.show();else{Ga.hide();ja.fx.val("");ja.fy.val("")}$("#"+
p+"_jGraduate_match_ctr")[0].checked=!gb;var tb,lb;$("#"+p+"_jGraduate_match_ctr").change(function(){gb=!this.checked;Ga.toggle(gb);ja.fx.val("");ja.fy.val("");var ia=Z;if(gb){var ca=tb||0.5,ka=lb||0.5;ia.setAttribute("fx",ca);ia.setAttribute("fy",ka);ja.fx.val(ca);ja.fy.val(ka)}else{tb=ia.getAttribute("fx");lb=ia.getAttribute("fy");ia.removeAttribute("fx");ia.removeAttribute("fy")}});ta=Z.getElementsByTagNameNS(q.svg,"stop");ra=ta.length;if(ra<2){for(;ra<2;){Z.appendChild(document.createElementNS(q.svg,
"stop"));++ra}ta=Z.getElementsByTagNameNS(q.svg,"stop")}var eb;oa=N=0;if(T==="radialGradient"){V=Z.gradientTransform.baseVal;if(V.numberOfItems===2){ra=V.getItem(0);V=V.getItem(1);if(ra.type===2&&V.type===3){ra=V.matrix;if(ra.a!==1)N=Math.round(-(1-ra.a)*100);else if(ra.d!==1)N=Math.round((1-ra.d)*100)}}else if(V.numberOfItems===3){da=V.getItem(0);ra=V.getItem(1);V=V.getItem(2);if(da.type===4&&ra.type===2&&V.type===3){oa=Math.round(da.angle);ra=V.matrix;if(ra.a!==1)N=Math.round(-(1-ra.a)*100);else if(ra.d!==
1)N=Math.round((1-ra.d)*100)}}}N={radius:{handle:"#"+p+"_jGraduate_RadiusArrows",input:"#"+p+"_jGraduate_RadiusInput",val:(Z.getAttribute("r")||0.5)*100},opacity:{handle:"#"+p+"_jGraduate_OpacArrows",input:"#"+p+"_jGraduate_OpacInput",val:v.paint.alpha||100},ellip:{handle:"#"+p+"_jGraduate_EllipArrows",input:"#"+p+"_jGraduate_EllipInput",val:N},angle:{handle:"#"+p+"_jGraduate_AngleArrows",input:"#"+p+"_jGraduate_AngleInput",val:oa}};$.each(N,function(ia,ca){var ka=$(ca.handle);ka.mousedown(function(M){var P=
ka.parent();eb={type:ia,elem:ka,input:$(ca.input),parent:P,offset:P.offset()};Q.mousemove(nb).mouseup(rb);M.preventDefault()});$(ca.input).val(ca.val).change(function(){var M=+this.value,P=0,ea=T==="radialGradient";switch(ia){case "radius":ea&&Z.setAttribute("r",M/100);P=Math.pow(M/100,0.4)/2*145;break;case "opacity":v.paint.alpha=M;ua.setAttribute("fill-opacity",M/100);P=M*1.45;break;case "ellip":db=La=1;if(M===0){P=72.5;break}if(M>99.5)M=99.5;if(M>0)La=1-M/100;else db=-(M/100)-1;P=145*((M+100)/
2)/100;ea&&d();break;case "angle":Ta=M;P=Ta/180;P+=0.5;P*=145;ea&&d()}if(P>145)P=145;else if(P<0)P=0;ka.css({"margin-left":P-5})}).change()});var nb=function(ia){var ca=ia.pageX-eb.offset.left-parseInt(eb.parent.css("border-left-width"));if(ca>145)ca=145;if(ca<=0)ca=0;var ka=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;Z.setAttribute("r",ca);break;case "opacity":v.paint.alpha=parseInt(ca*100);ua.setAttribute("fill-opacity",ca);break;
case "ellip":La=db=1;if(ca<0.5){ca/=0.5;db=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;Ta=ca*=180;d();ca/=100}eb.elem.css({"margin-left":ka});ca=Math.round(ca*100);eb.input.val(ca);ia.preventDefault()},rb=function(){Q.unbind("mousemove",nb).unbind("mouseup",rb);eb=null};for(N=(v.paint.alpha*255/100).toString(16);N.length<2;)N="0"+N;N=N.split(".")[0];I=v.paint.solidColor=="none"?"":v.paint.solidColor+N;qa||(I=ta[0].getAttribute("stop-color"));
$.extend($.fn.jPicker.defaults.window,{alphaSupport:true,effects:{type:"show",speed:0}});U.jPicker({window:{title:A.window.pickerTitle},images:{clientPath:A.images.clientPath},color:{active:I,alphaSupport:true}},function(ia){v.paint.type="solidColor";v.paint.alpha=ia.val("ahex")?Math.round(ia.val("a")/255*100):100;v.paint.solidColor=ia.val("hex")?ia.val("hex"):"none";v.paint.radialGradient=null;R()},null,function(){O()});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 ia=$(this).attr("data-type");$(K+" .jGraduate_gradPick").show();if(ia==="rg"||ia==="lg"){$(".jGraduate_"+ia+"_field").show();$(".jGraduate_"+(ia==="lg"?"rg":"lg")+"_field").hide();$("#"+p+"_jgraduate_rect")[0].setAttribute("fill","url(#"+p+"_"+ia+"_jgraduate_grad)");T=ia==="lg"?"linearGradient":"radialGradient";$("#"+p+"_jGraduate_OpacInput").val(v.paint.alpha).change();var ca=$("#"+p+"_"+ia+"_jgraduate_grad")[0];if(Z!==ca){var ka=
$(Z).find("stop");$(ca).empty().append(ka);Z=ca;ca=qb.val();Z.setAttribute("spreadMethod",ca)}gb=ia==="rg"&&Z.getAttribute("fx")!=null&&!(Ha==Ia&&Ba==Ka);$("#"+p+"_jGraduate_focusCoord").toggle(gb);if(gb)$("#"+p+"_jGraduate_match_ctr")[0].checked=false}else{$(K+" .jGraduate_gradPick").hide();$(K+" .jGraduate_colPick").show()}});$(K+" > div").hide();wb.removeClass("jGraduate_tab_current");var xb;switch(v.paint.type){case "linearGradient":xb=$(K+" .jGraduate_tab_lingrad");break;case "radialGradient":xb=
$(K+" .jGraduate_tab_radgrad");break;default:xb=$(K+" .jGraduate_tab_color")}v.show();setTimeout(function(){xb.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),q=$(document);$.extend($.fn,{contextMenu:function(h,b){if(h.menu==undefined)return false;if(h.inSpeed==undefined)h.inSpeed=150;if(h.outSpeed==undefined)h.outSpeed=75;if(h.inSpeed==0)h.inSpeed=-1;if(h.outSpeed==0)h.outSpeed=-1;$(this).each(function(){var n=$(this),u=$(n).offset(),c=$("#"+h.menu);c.addClass("contextMenu");$(this).bind("mousedown",function(d){$(this).on("mouseup",function(l){var v=$(this);v.unbind("mouseup");$(".contextMenu").hide();if(d.button===2||
h.allowLeft||d.ctrlKey&&svgedit.browser.isMac())svgedit.browser.isTouch()||g(l,d,v)})});svgedit.browser.isTouch()&&$(this).bind("taphold",function(d){var l=$(this);l.unbind("mouseup");g(d,d,l)});var g=function(d,l,v){if(typeof l=="undefined")l=d;d.stopPropagation();if(n.hasClass("disabled")||l.altKey)return false;var A=d.pageX,p=d.pageY;if(svgedit.browser.isTouch()){A=d.originalEvent.touches[0].pageX;p=d.originalEvent.touches[0].pageY}d=a.width()-c.width();l=a.height()-c.height();if(A>d-15)A=d-15;
if(p>l-30)p=l-30;if(svgedit.browser.isTouch())p-=c.height()/2;q.unbind("click");c.css({top:p,left:A}).fadeIn(h.inSpeed);c.find("A").mouseover(function(){c.find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){c.find("LI.hover").removeClass("hover")});q.keypress(function(K){switch(K.keyCode){case 38:if(c.find("LI.hover").length){c.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover");c.find("LI.hover").length||c.find("LI:last").addClass("hover")}else c.find("LI:last").addClass("hover");
break;case 40:if(c.find("LI.hover").length==0)c.find("LI:first").addClass("hover");else{c.find("LI.hover").removeClass("hover").nextAll("LI:not(.disabled)").eq(0).addClass("hover");c.find("LI.hover").length||c.find("LI:first").addClass("hover")}break;case 13:c.find("LI.hover A").trigger("click");break;case 27:q.trigger("click")}});c.find("A").unbind("mouseup");c.find("LI:not(.disabled) A").mouseup(function(){q.unbind("click").unbind("keypress");$(".contextMenu").hide();b&&b($(this).attr("href").substr(1),
$(v),{x:A-u.left,y:p-u.top,docX:A,docY:p});return false});setTimeout(function(){q.click(function(){q.unbind("click").unbind("keypress");c.fadeOut(h.outSpeed);return false})},0)};if($.browser.mozilla)$("#"+h.menu).each(function(){$(this).css({MozUserSelect:"none"})});else $.browser.msie?$("#"+h.menu).each(function(){$(this).bind("selectstart.disableTextSelect",function(){return false})}):$("#"+h.menu).each(function(){$(this).bind("mousedown.disableTextSelect",function(){return false})});$(n).add($("UL.contextMenu")).bind("contextmenu",
function(){return false})});return $(this)},disableContextMenuItems:function(h){if(h==undefined){$(this).find("LI").addClass("disabled");return $(this)}$(this).each(function(){if(h!=undefined)for(var b=h.split(","),n=0;n<b.length;n++)$(this).find('A[href="'+b[n]+'"]').parent().addClass("disabled")});return $(this)},enableContextMenuItems:function(h){if(h==undefined){$(this).find("LI.disabled").removeClass("disabled");return $(this)}$(this).each(function(){if(h!=undefined)for(var b=h.split(","),n=
0;n<b.length;n++)$(this).find('A[href="'+b[n]+'"]').parent().removeClass("disabled")});return $(this)},disableContextMenu:function(){$(this).each(function(){$(this).addClass("disabled")});return $(this)},enableContextMenu:function(){$(this).each(function(){$(this).removeClass("disabled")});return $(this)},destroyContextMenu:function(){$(this).each(function(){$(this).unbind("mousedown").unbind("mouseup")});return $(this)}})}(jQuery);var svgedit=svgedit||{};
(function(){if(!svgedit.browser)svgedit.browser={};var a=!!document.createElementNS&&!!document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect;svgedit.browser.supportsSvg=function(){return a};if(svgedit.browser.supportsSvg()){var q=navigator.userAgent,h=document.createElementNS("http://www.w3.org/2000/svg","svg"),b=!!window.opera,n=q.indexOf("AppleWebKit")>=0,u=q.indexOf("Gecko/")>=0,c=q.indexOf("MSIE")>=0,g=q.indexOf("Chrome/")>=0,d=q.indexOf("Windows")>=0,l=q.indexOf("Macintosh")>=
0,v="ontouchstart"in window,A=!!h.querySelector,p=!!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(T){}return false}(),R=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(T){}return false}(),O=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 T=document.createElementNS("http://www.w3.org/2000/svg","text");T.textContent="a";fa.appendChild(T);fa=T.getStartPositionOfChar(0);fa=fa.x;document.documentElement.removeChild(pa);return fa===0}(),I=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 T=
document.createElementNS("http://www.w3.org/2000/svg","path");T.setAttribute("d","M5,0 15,0");var Z=document.createElementNS("http://www.w3.org/2000/svg","g");Z.appendChild(fa);Z.appendChild(T);pa.appendChild(Z);fa=Z.getBBox();document.documentElement.removeChild(pa);return fa.width==15}(),U=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}(),N=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"}(),ha=function(){var pa=document.createElementNS("http://www.w3.org/2000/svg","rect").transform.baseVal,fa=h.createSVGTransform();pa.appendItem(fa);return pa.getItem(0)==fa}();svgedit.browser.isOpera=function(){return b};svgedit.browser.isWebkit=function(){return n};svgedit.browser.isGecko=function(){return u};
svgedit.browser.isIE=function(){return c};svgedit.browser.isChrome=function(){return g};svgedit.browser.isWindows=function(){return d};svgedit.browser.isMac=function(){return l};svgedit.browser.isTouch=function(){return v};svgedit.browser.supportsSelectors=function(){return A};svgedit.browser.supportsXpath=function(){return p};svgedit.browser.supportsPathReplaceItem=function(){return K};svgedit.browser.supportsPathInsertItemBefore=function(){return R};svgedit.browser.supportsPathBBox=function(){return I};
svgedit.browser.supportsHVLineContainerBBox=function(){return Q};svgedit.browser.supportsGoodTextCharPos=function(){return O};svgedit.browser.supportsEditableText=function(){return b};svgedit.browser.supportsGoodDecimals=function(){return U};svgedit.browser.supportsNonScalingStroke=function(){return N};svgedit.browser.supportsNativeTransformLists=function(){return ha}}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"),q={};svgedit.transformlist.SVGTransformList=function(h){this._elem=h||null;this._xforms=[];this._update=function(){var b="";a.createSVGMatrix();for(var n=0;n<this.numberOfItems;++n){var u=this._list.getItem(n);b=b;u=u;var c=u.matrix,g="";switch(u.type){case 1:g="matrix("+[c.a,c.b,c.c,c.d,c.e,c.f].join(",")+")";break;case 2:g="translate("+c.e+","+c.f+")";break;case 3:g=
c.a==c.d?"scale("+c.a+")":"scale("+c.a+","+c.d+")";break;case 4:var d=0;g=0;if(u.angle!=0){d=1-c.a;g=(d*c.f+c.b*c.e)/(d*d+c.b*c.b);d=(c.e-c.b*g)/d}g="rotate("+u.angle+" "+d+","+g+")"}b=b+(g+" ")}this._elem.setAttribute("transform",b)};this._list=this;this._init=function(){var b=this._elem.getAttribute("transform");if(b)for(var n=/\s*((scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/,u=true;u;){u=b.match(n);b=b.replace(n,"");if(u&&u[1]){var c=u[1].split(/\s*\(/),g=c[0];c=c[1].match(/\s*(.*?)\s*\)/);
c[1]=c[1].replace(/(\d)-/g,"$1 -");var d=c[1].split(/[, ]+/),l="abcdef".split(""),v=a.createSVGMatrix();$.each(d,function(K,R){d[K]=parseFloat(R);if(g=="matrix")v[l[K]]=d[K]});c=a.createSVGTransform();var A="set"+g.charAt(0).toUpperCase()+g.slice(1),p=g=="matrix"?[v]:d;if(g=="scale"&&p.length==1)p.push(p[0]);else if(g=="translate"&&p.length==1)p.push(0);else if(g=="rotate"&&p.length==1){p.push(0);p.push(0)}c[A].apply(c,p);this._list.appendItem(c)}}};this._removeFromOtherLists=function(b){if(b){var n=
false,u;for(u in q){for(var c=q[u],g=0,d=c._xforms.length;g<d;++g)if(c._xforms[g]==b){n=true;c.removeItem(g);break}if(n)break}}};this.numberOfItems=0;this.clear=function(){this.numberOfItems=0;this._xforms=[]};this.initialize=function(b){this.numberOfItems=1;this._removeFromOtherLists(b);this._xforms=[b]};this.getItem=function(b){if(b<this.numberOfItems&&b>=0)return this._xforms[b];throw{code:1};};this.insertItemBefore=function(b,n){var u=null;if(n>=0)if(n<this.numberOfItems){this._removeFromOtherLists(b);
u=Array(this.numberOfItems+1);for(var c=0;c<n;++c)u[c]=this._xforms[c];u[c]=b;for(var g=c+1;c<this.numberOfItems;++g,++c)u[g]=this._xforms[c];this.numberOfItems++;this._xforms=u;u=b;this._list._update()}else u=this._list.appendItem(b);return u};this.replaceItem=function(b,n){var u=null;if(n<this.numberOfItems&&n>=0){this._removeFromOtherLists(b);u=this._xforms[n]=b;this._list._update()}return u};this.removeItem=function(b){if(b<this.numberOfItems&&b>=0){for(var n=this._xforms[b],u=Array(this.numberOfItems-
1),c=0;c<b;++c)u[c]=this._xforms[c];for(b=c;b<this.numberOfItems-1;++b,++c)u[b]=this._xforms[c+1];this.numberOfItems--;this._xforms=u;this._list._update();return n}else throw{code:1};};this.appendItem=function(b){this._removeFromOtherLists(b);this._xforms.push(b);this.numberOfItems++;this._list._update();return b}};svgedit.transformlist.resetListMap=function(){q={}};svgedit.transformlist.removeElementFromListMap=function(h){h.id&&q[h.id]&&delete q[h.id]};svgedit.transformlist.getTransformList=function(h){if(svgedit.browser.supportsNativeTransformLists())if(h.transform)return h.transform.baseVal;
else if(h.gradientTransform)return h.gradientTransform.baseVal;else{if(h.patternTransform)return h.patternTransform.baseVal}else{var b=h.id;b||(b="temp");var n=q[b];if(!n||b=="temp"){q[b]=new svgedit.transformlist.SVGTransformList(h);q[b]._init();n=q[b]}return n}return null}})();svgedit=svgedit||{};
(function(){if(!svgedit.math)svgedit.math={};var a=document.createElementNS("http://www.w3.org/2000/svg","svg");svgedit.math.transformPoint=function(q,h,b){return{x:b.a*q+b.c*h+b.e,y:b.b*q+b.d*h+b.f}};svgedit.math.isIdentity=function(q){return q.a===1&&q.b===0&&q.c===0&&q.d===1&&q.e===0&&q.f===0};svgedit.math.matrixMultiply=function(){for(var q=arguments,h=q.length,b=q[h-1];h-- >1;)b=q[h-1].multiply(b);if(Math.abs(b.a)<1.0E-14)b.a=0;if(Math.abs(b.b)<1.0E-14)b.b=0;if(Math.abs(b.c)<1.0E-14)b.c=0;if(Math.abs(b.d)<
1.0E-14)b.d=0;if(Math.abs(b.e)<1.0E-14)b.e=0;if(Math.abs(b.f)<1.0E-14)b.f=0;return b};svgedit.math.hasMatrixTransform=function(q){if(!q)return false;for(var h=q.numberOfItems;h--;){var b=q.getItem(h);if(b.type==1&&!svgedit.math.isIdentity(b.matrix))return true}return false};svgedit.math.transformBox=function(q,h,b,n,u){var c={x:q,y:h},g={x:q+b,y:h};b={x:q+b,y:h+n};q={x:q,y:h+n};h=svgedit.math.transformPoint;c=h(c.x,c.y,u);var d=n=c.x,l=c.y,v=c.y;g=h(g.x,g.y,u);n=Math.min(n,g.x);d=Math.max(d,g.x);
l=Math.min(l,g.y);v=Math.max(v,g.y);q=h(q.x,q.y,u);n=Math.min(n,q.x);d=Math.max(d,q.x);l=Math.min(l,q.y);v=Math.max(v,q.y);b=h(b.x,b.y,u);n=Math.min(n,b.x);d=Math.max(d,b.x);l=Math.min(l,b.y);v=Math.max(v,b.y);return{tl:c,tr:g,bl:q,br:b,aabox:{x:n,y:l,width:d-n,height:v-l}}};svgedit.math.transformListToTransform=function(q,h,b){if(q==null)return a.createSVGTransformFromMatrix(a.createSVGMatrix());h=h==undefined?0:h;b=b==undefined?q.numberOfItems-1:b;h=parseInt(h);b=parseInt(b);if(h>b){var n=b;b=h;
h=n}n=a.createSVGMatrix();for(h=h;h<=b;++h){var u=h>=0&&h<q.numberOfItems?q.getItem(h).matrix:a.createSVGMatrix();n=svgedit.math.matrixMultiply(n,u)}return a.createSVGTransformFromMatrix(n)};svgedit.math.getMatrix=function(q){q=svgedit.transformlist.getTransformList(q);return svgedit.math.transformListToTransform(q).matrix};svgedit.math.snapToAngle=function(q,h,b,n){var u=Math.PI/4;b=b-q;var c=n-h;n=Math.sqrt(b*b+c*c);u=Math.round(Math.atan2(c,b)/u)*u;return{x:q+n*Math.cos(u),y:h+n*Math.sin(u),a:u}};
svgedit.math.rectsIntersect=function(q,h){if(typeof q=="undefined"||typeof h=="undefined")return false;return h.x<q.x+q.width&&h.x+h.width>q.x&&h.y<q.y+q.height&&h.y+h.height>q.y}})();svgedit=svgedit||{};
(function(){if(!svgedit.units)svgedit.units={};var a=["x","x1","cx","rx","width"],q=["y","y1","cy","ry","height"],h=$.merge(["r","radius"],a);$.merge(h,q);var b,n={px:1};svgedit.units.init=function(c){b=c;c=document.createElementNS("http://www.w3.org/2000/svg","svg");document.body.appendChild(c);var g=document.createElementNS("http://www.w3.org/2000/svg","rect");g.setAttribute("width","1em");g.setAttribute("height","1ex");g.setAttribute("x","1in");c.appendChild(g);g=g.getBBox();document.body.removeChild(c);
c=g.x;n.em=g.width;n.ex=g.height;n["in"]=c;n.cm=c/2.54;n.mm=c/25.4;n.pt=c/72;n.pc=c/6;n["%"]=0};svgedit.units.getTypeMap=function(){return n};svgedit.units.shortFloat=function(c){var g=b.getRoundDigits();if(isNaN(c)){if($.isArray(c))return svgedit.units.shortFloat(c[0])+","+svgedit.units.shortFloat(c[1])}else return+(+c).toFixed(g);return parseFloat(c).toFixed(g)-0};svgedit.units.convertUnit=function(c,g){g=g||b.getBaseUnit();return svgedit.unit.shortFloat(c/n[g])};svgedit.units.setUnitAttr=function(c,
g,d){isNaN(d)||c.getAttribute(g);c.setAttribute(g,d)};var u={line:["x1","x2","y1","y2"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],foreignObject:["x","y","width","height"],rect:["x","y","width","height"],image:["x","y","width","height"],use:["x","y","width","height"],text:["x","y"]};svgedit.units.convertAttrs=function(c){var g=c.tagName,d=b.getBaseUnit();if(g=u[g])for(var l=g.length,v=0;v<l;v++){var A=g[v],p=c.getAttribute(A);if(p)isNaN(p)||c.setAttribute(A,p/n[d]+d)}};svgedit.units.convertToNum=
function(c,g){if(!isNaN(g))return g-0;if(g.substr(-1)==="%"){var d=g.substr(0,g.length-1)/100,l=b.getWidth(),v=b.getHeight();return a.indexOf(c)>=0?d*l:q.indexOf(c)>=0?d*v:d*Math.sqrt(l*l+v*v)/Math.sqrt(2)}else{l=g.substr(-2);d=g.substr(0,g.length-2);return d*n[l]}};svgedit.units.isValidUnit=function(c,g,d){var l=false;if(h.indexOf(c)>=0)if(isNaN(g)){g=g.toLowerCase();$.each(n,function(p){if(!l)if(RegExp("^-?[\\d\\.]+"+p+"$").test(g))l=true})}else l=true;else if(c=="id"){c=false;try{var v=b.getElement(g);
c=v==null||v===d}catch(A){}return c}else l=true;return l}})();svgedit=svgedit||{};
(function(){function a(c){if(svgedit.browser.supportsHVLineContainerBBox())try{return c.getBBox()}catch(g){}var d=$.data(c,"ref"),l=null;if(d){var v=$(d).children().clone().attr("visibility","hidden");$(u).append(v);l=v.filter("line, path")}else l=$(c).find("line, path");var A=false;if(l.length){l.each(function(){var p=this.getBBox();if(!p.width||!p.height)A=true});if(A){c=d?v:$(c).children();ret=getStrokedBBox(c)}else ret=c.getBBox()}else ret=c.getBBox();d&&v.remove();return ret}if(!svgedit.utilities)svgedit.utilities=
{};var q="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),h=null,b=null,n=null,u=null;svgedit.utilities.init=function(c){h=c;b=c.getDOMDocument();n=c.getDOMContainer();u=c.getSVGRoot()};svgedit.utilities.toXml=function(c){return $("<p/>").text(c).html()};svgedit.utilities.fromXml=function(c){return $("<p/>").html(c).text()};svgedit.utilities.encode64=function(c){c=svgedit.utilities.convertToXMLReferences(c);if(window.btoa)return window.btoa(c);
var g=Array(Math.floor((c.length+2)/3)*4),d,l,v,A,p,K,R=0,O=0;do{d=c.charCodeAt(R++);l=c.charCodeAt(R++);v=c.charCodeAt(R++);A=d>>2;d=(d&3)<<4|l>>4;p=(l&15)<<2|v>>6;K=v&63;if(isNaN(l))p=K=64;else if(isNaN(v))K=64;g[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(A);g[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(d);g[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(p);g[O++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(K)}while(R<
c.length);return g.join("")};svgedit.utilities.decode64=function(c){if(window.atob)return window.atob(c);var g="",d,l,v="",A,p="",K=0;c=c.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(c.charAt(K++));
d=d<<2|l>>4;l=(l&15)<<4|A>>2;v=(A&3)<<6|p;g+=String.fromCharCode(d);if(A!=64)g+=String.fromCharCode(l);if(p!=64)g+=String.fromCharCode(v)}while(K<c.length);return unescape(g)};svgedit.utilities.convertToXMLReferences=function(c){for(var g="",d=0;d<c.length;d++){var l=c.charCodeAt(d);if(l<128)g+=c[d];else if(l>127)g+="&#"+l+";"}return g};svgedit.utilities.text2xml=function(c){if(c.indexOf("<svg:svg")>=0)c=c.replace(/<(\/?)svg:/g,"<$1").replace("xmlns:svg","xmlns");var g;try{var d=window.DOMParser?
new DOMParser:new ActiveXObject("Microsoft.XMLDOM");d.async=false}catch(l){throw Error("XML Parser could not be instantiated");}try{g=d.loadXML?d.loadXML(c)?d:false:d.parseFromString(c,"text/xml")}catch(v){throw Error("Error parsing XML string");}return g};svgedit.utilities.bboxToObj=function(c){return{x:c.x,y:c.y,width:c.width,height:c.height}};svgedit.utilities.walkTree=function(c,g){if(c&&c.nodeType==1){g(c);for(var d=c.childNodes.length;d--;)svgedit.utilities.walkTree(c.childNodes.item(d),g)}};
svgedit.utilities.walkTreePost=function(c,g){if(c&&c.nodeType==1){for(var d=c.childNodes.length;d--;)svgedit.utilities.walkTree(c.childNodes.item(d),g);g(c)}};svgedit.utilities.getUrlFromAttr=function(c){if(c)if(c.indexOf('url("')===0)return c.substring(5,c.indexOf('"',6));else if(c.indexOf("url('")===0)return c.substring(5,c.indexOf("'",6));else if(c.indexOf("url(")===0)return c.substring(4,c.indexOf(")"));return null};svgedit.utilities.getHref=function(c){return c.getAttributeNS("http://www.w3.org/1999/xlink",
"href")};svgedit.utilities.setHref=function(c,g){c.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",g)};svgedit.utilities.findDefs=function(c){c=h.getSVGContent().documentElement;var g=c.getElementsByTagNameNS("http://www.w3.org/2000/svg","defs");return g=g.length>0?g[0]:c.insertBefore(c.ownerDocument.createElementNS("http://www.w3.org/2000/svg","defs"),c.firstChild.nextSibling)};svgedit.utilities.getPathBBox=function(c){var g=c.pathSegList,d=g.numberOfItems;c=[[],[]];var l=g.getItem(0),
v=[l.x,l.y];for(l=0;l<d;l++){var A=g.getItem(l);if(typeof A.x!="undefined"){c[0].push(v[0]);c[1].push(v[1]);if(A.x1){for(var p=[A.x1,A.y1],K=[A.x2,A.y2],R=[A.x,A.y],O=0;O<2;O++){A=function(ha){return Math.pow(1-ha,3)*v[O]+3*Math.pow(1-ha,2)*ha*p[O]+3*(1-ha)*Math.pow(ha,2)*K[O]+Math.pow(ha,3)*R[O]};var I=6*v[O]-12*p[O]+6*K[O],Q=-3*v[O]+9*p[O]-9*K[O]+3*R[O],U=3*p[O]-3*v[O];if(Q==0){if(I!=0){I=-U/I;0<I&&I<1&&c[O].push(A(I))}}else{U=Math.pow(I,2)-4*U*Q;if(!(U<0)){var N=(-I+Math.sqrt(U))/(2*Q);0<N&&N<
1&&c[O].push(A(N));I=(-I-Math.sqrt(U))/(2*Q);0<I&&I<1&&c[O].push(A(I))}}}v=R}else{c[0].push(A.x);c[1].push(A.y)}}}g=Math.min.apply(null,c[0]);d=Math.max.apply(null,c[0])-g;l=Math.min.apply(null,c[1]);c=Math.max.apply(null,c[1])-l;return{x:g,y:l,width:d,height:c}};svgedit.utilities.getBBox=function(c){var g=c||h.getSelectedElements()[0];if(c.nodeType!=1)return null;c=null;var d=g.nodeName;switch(d){case "text":if(g.textContent===""){g.textContent="a";c=g.getBBox();g.textContent=""}else try{c=g.getBBox()}catch(l){}break;
case "path":if(svgedit.browser.supportsPathBBox())try{c=g.getBBox()}catch(v){}else c=svgedit.utilities.getPathBBox(g);break;case "g":case "a":c=a(g);break;default:if(d==="use")c=a(g,true);if(d==="use"){c||(c=g.getBBox());if(!svgedit.browser.isWebkit()){d={};d.width=c.width;d.height=c.height;d.x=c.x+parseFloat(g.getAttribute("x")||0);d.y=c.y+parseFloat(g.getAttribute("y")||0);c=d}}else if(~q.indexOf(d))try{c=g.getBBox()}catch(A){g=$(g).closest("foreignObject");if(g.length)try{c=g[0].getBBox()}catch(p){c=
null}else c=null}}if(c)c=svgedit.utilities.bboxToObj(c);return c};svgedit.utilities.getRotationAngle=function(c,g){var d=c||h.getSelectedElements()[0];d=svgedit.transformlist.getTransformList(d);if(!d)return 0;for(var l=d.numberOfItems,v=0;v<l;++v){var A=d.getItem(v);if(A.type==4)return g?A.angle*Math.PI/180:A.angle}return 0};svgedit.utilities.getElem=svgedit.browser.supportsSelectors()?function(c){return u.querySelector("#"+c)}:svgedit.browser.supportsXpath()?function(c){return b.evaluate('svg:svg[@id="svgroot"]//svg:*[@id="'+
c+'"]',n,function(){return"http://www.w3.org/2000/svg"},9,null).singleNodeValue}:function(c){return $(u).find("[id="+c+"]")[0]};svgedit.utilities.assignAttributes=function(c,g,d,l){d||(d=0);svgedit.browser.isOpera()||u.suspendRedraw(d);for(var v in g)if(d=v.substr(0,4)==="xml:"?"http://www.w3.org/XML/1998/namespace":v.substr(0,6)==="xlink:"?"http://www.w3.org/1999/xlink":null)c.setAttributeNS(d,v,g[v]);else l?svgedit.units.setUnitAttr(c,v,g[v]):c.setAttribute(v,g[v]);svgedit.browser.isOpera()||u.unsuspendRedraw(null)};
svgedit.utilities.cleanupElement=function(c){var g=u.suspendRedraw(60),d={"fill-opacity":1,"stop-opacity":1,opacity:1,stroke:"none","stroke-dasharray":"none","stroke-linejoin":"miter","stroke-linecap":"butt","stroke-opacity":1,"stroke-width":1,rx:0,ry:0},l;for(l in d){var v=d[l];c.getAttribute(l)==v&&c.removeAttribute(l)}u.unsuspendRedraw(g)}})();svgedit=svgedit||{};
(function(){if(!svgedit.sanitize)svgedit.sanitize={};var a={};a["http://www.w3.org/1999/xlink"]="xlink";a["http://www.w3.org/XML/1998/namespace"]="xml";a["http://www.w3.org/2000/xmlns/"]="xmlns";a["http://svg-edit.googlecode.com"]="se";a["http://www.w3.org/1999/xhtml"]="xhtml";a["http://www.w3.org/1998/Math/MathML"]="mathml";var q={};$.each(a,function(n,u){q[u]=n});var h={a:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","mask","opacity","stroke","stroke-dasharray",
"stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","xlink:href","xlink:title"],circle:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","r","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],clipPath:["class",
"clipPathUnits","id"],defs:[],style:["type"],desc:[],ellipse:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],feGaussianBlur:["class","color-interpolation-filters","id","requiredFeatures","stdDeviation"],filter:["class","color-interpolation-filters",
"filterRes","filterUnits","height","id","primitiveUnits","requiredFeatures","width","x","xlink:href","y"],foreignObject:["class","font-size","height","id","opacity","requiredFeatures","style","transform","width","x","y"],g:["class","clip-path","clip-rule","id","display","fill","fill-opacity","fill-rule","filter","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage",
"transform","font-family","font-size","font-style","font-weight","text-anchor"],image:["class","clip-path","clip-rule","filter","height","id","mask","opacity","requiredFeatures","style","systemLanguage","transform","width","x","xlink:href","xlink:title","y"],line:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin",
"stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","x1","x2","y1","y2"],linearGradient:["class","id","gradientTransform","gradientUnits","requiredFeatures","spreadMethod","systemLanguage","x1","x2","xlink:href","y1","y2"],marker:["id","class","markerHeight","markerUnits","markerWidth","orient","preserveAspectRatio","refX","refY","systemLanguage","viewBox"],mask:["class","height","id","maskContentUnits","maskUnits","width","x","y"],metadata:["class","id"],path:["class",
"clip-path","clip-rule","d","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],pattern:["class","height","id","patternContentUnits","patternTransform","patternUnits","requiredFeatures","style","systemLanguage","viewBox","width","x","xlink:href","y"],polygon:["class",
"clip-path","clip-rule","id","fill","fill-opacity","fill-rule","filter","id","class","marker-end","marker-mid","marker-start","mask","opacity","points","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],polyline:["class","clip-path","clip-rule","id","fill","fill-opacity","fill-rule","filter","marker-end","marker-mid","marker-start","mask","opacity","points",
"requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],radialGradient:["class","cx","cy","fx","fy","gradientTransform","gradientUnits","id","r","requiredFeatures","spreadMethod","systemLanguage","xlink:href"],rect:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","height","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray",
"stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","width","x","y"],stop:["class","id","offset","requiredFeatures","stop-color","stop-opacity","style","systemLanguage"],svg:["class","clip-path","clip-rule","filter","id","height","mask","preserveAspectRatio","requiredFeatures","style","systemLanguage","viewBox","width","x","xmlns","xmlns:se","xmlns:xlink","y"],"switch":["class","id","requiredFeatures","systemLanguage"],
symbol:["class","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","opacity","preserveAspectRatio","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","viewBox"],text:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","mask","opacity",
"requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","text-anchor","transform","x","xml:space","y"],textPath:["class","id","method","requiredFeatures","spacing","startOffset","style","systemLanguage","transform","xlink:href"],title:[],tspan:["class","clip-path","clip-rule","dx","dy","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight",
"id","mask","opacity","requiredFeatures","rotate","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","text-anchor","textLength","transform","x","xml:space","y"],use:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","height","id","mask","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width",
"style","transform","width","x","xlink:href","y"],annotation:["encoding"],"annotation-xml":["encoding"],maction:["actiontype","other","selection"],math:["class","id","display","xmlns"],menclose:["notation"],merror:[],mfrac:["linethickness"],mi:["mathvariant"],mmultiscripts:[],mn:[],mo:["fence","lspace","maxsize","minsize","rspace","stretchy"],mover:[],mpadded:["lspace","width","height","depth","voffset"],mphantom:[],mprescripts:[],mroot:[],mrow:["xlink:href","xlink:type","xmlns:xlink"],mspace:["depth",
"height","width"],msqrt:[],mstyle:["displaystyle","mathbackground","mathcolor","mathvariant","scriptlevel"],msub:[],msubsup:[],msup:[],mtable:["align","columnalign","columnlines","columnspacing","displaystyle","equalcolumns","equalrows","frame","rowalign","rowlines","rowspacing","width"],mtd:["columnalign","columnspan","rowalign","rowspan"],mtext:[],mtr:["columnalign","rowalign"],munder:[],munderover:[],none:[],semantics:[]},b={};$.each(h,function(n,u){var c={};$.each(u,function(g,d){if(d.indexOf(":")>=
0){var l=d.split(":");c[l[1]]=q[l[0]]}else c[d]=d=="xmlns"?"http://www.w3.org/2000/xmlns/":null});b[n]=c});svgedit.sanitize.getNSMap=function(){return a};svgedit.sanitize.sanitizeSvg=function(n){if(n.nodeType==3){n.nodeValue=n.nodeValue.replace(/^\s+|\s+$/g,"");n.nodeValue.length||n.parentNode.removeChild(n)}if(n.nodeType==1){var u=n.parentNode;if(n.ownerDocument&&u){var c=h[n.nodeName],g=b[n.nodeName];if(c!=undefined){for(var d=[],l=n.attributes.length;l--;){var v=n.attributes.item(l),A=v.nodeName,
p=v.localName,K=v.namespaceURI;if(!(g.hasOwnProperty(p)&&K==g[p]&&K!="http://www.w3.org/2000/xmlns/")&&!(K=="http://www.w3.org/2000/xmlns/"&&a[v.nodeValue])){A.indexOf("se:")==0&&d.push([A,v.nodeValue]);n.removeAttributeNS(K,p)}if(svgedit.browser.isGecko())switch(A){case "transform":case "gradientTransform":case "patternTransform":p=v.nodeValue.replace(/(\d)-/g,"$1 -");n.setAttribute(A,p)}if(A=="style"){v=v.nodeValue.split(";");for(A=v.length;A--;){p=v[A].split(":");c.indexOf(p[0])>=0&&n.setAttribute(p[0],
p[1])}n.removeAttribute("style")}}$.each(d,function(R,O){n.setAttributeNS("http://svg-edit.googlecode.com",O[0],O[1])});if((l=svgedit.utilities.getHref(n))&&["filter","linearGradient","pattern","radialGradient","textPath","use"].indexOf(n.nodeName)>=0)if(l[0]!="#"){svgedit.utilities.setHref(n,"");n.removeAttributeNS("http://www.w3.org/1999/xlink","href")}if(n.nodeName=="use"&&!svgedit.utilities.getHref(n))u.removeChild(n);else{$.each(["clip-path","fill","filter","marker-end","marker-mid","marker-start",
"mask","stroke"],function(R,O){var I=n.getAttribute(O);if(I)if((I=svgedit.utilities.getUrlFromAttr(I))&&I[0]!=="#"){n.setAttribute(O,"");n.removeAttribute(O)}});for(l=n.childNodes.length;l--;)svgedit.sanitize.sanitizeSvg(n.childNodes.item(l))}}else{for(c=[];n.hasChildNodes();)c.push(u.insertBefore(n.firstChild,n));u.removeChild(n);for(l=c.length;l--;)svgedit.sanitize.sanitizeSvg(c[l])}}}}})();svgedit=svgedit||{};
(function(){if(!svgedit.history)svgedit.history={};svgedit.history.HistoryEventTypes={BEFORE_APPLY:"before_apply",AFTER_APPLY:"after_apply",BEFORE_UNAPPLY:"before_unapply",AFTER_UNAPPLY:"after_unapply"};svgedit.history.MoveElementCommand=function(a,q,h,b){this.elem=a;this.text=b?"Move "+a.tagName+" to "+b:"Move "+a.tagName;this.oldNextSibling=q;this.oldParent=h;this.newNextSibling=a.nextSibling;this.newParent=a.parentNode};svgedit.history.MoveElementCommand.type=function(){return"svgedit.history.MoveElementCommand"};svgedit.history.MoveElementCommand.prototype.type=
svgedit.history.MoveElementCommand.type;svgedit.history.MoveElementCommand.prototype.getText=function(){return this.text};svgedit.history.MoveElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);this.elem=this.newParent.insertBefore(this.elem,this.newNextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)};svgedit.history.MoveElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,
this);this.elem=this.oldParent.insertBefore(this.elem,this.oldNextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.MoveElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.InsertElementCommand=function(a,q){this.elem=a;this.text=q||"Create "+a.tagName;this.parent=a.parentNode;this.nextSibling=this.elem.nextSibling};svgedit.history.InsertElementCommand.type=function(){return"svgedit.history.InsertElementCommand"};svgedit.history.InsertElementCommand.prototype.type=
svgedit.history.InsertElementCommand.type;svgedit.history.InsertElementCommand.prototype.getText=function(){return this.text};svgedit.history.InsertElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);this.elem=this.parent.insertBefore(this.elem,this.nextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)};svgedit.history.InsertElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,
this);this.parent=this.elem.parentNode;this.elem=this.elem.parentNode.removeChild(this.elem);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.InsertElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.RemoveElementCommand=function(a,q,h,b){this.elem=a;this.text=b||"Delete "+a.tagName;this.nextSibling=q;this.parent=h;svgedit.transformlist.removeElementFromListMap(a)};svgedit.history.RemoveElementCommand.type=function(){return"svgedit.history.RemoveElementCommand"};
svgedit.history.RemoveElementCommand.prototype.type=svgedit.history.RemoveElementCommand.type;svgedit.history.RemoveElementCommand.prototype.getText=function(){return this.text};svgedit.history.RemoveElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);svgedit.transformlist.removeElementFromListMap(this.elem);this.parent=this.elem.parentNode;this.elem=this.parent.removeChild(this.elem);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,
this)};svgedit.history.RemoveElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);svgedit.transformlist.removeElementFromListMap(this.elem);this.nextSibling==null&&window.console&&console.log("Error: reference element was lost");this.parent.insertBefore(this.elem,this.nextSibling);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this)};svgedit.history.RemoveElementCommand.prototype.elements=function(){return[this.elem]};
svgedit.history.ChangeElementCommand=function(a,q,h){this.elem=a;this.text=h?"Change "+a.tagName+" "+h:"Change "+a.tagName;this.newValues={};this.oldValues=q;for(var b in q)this.newValues[b]=b=="#text"?a.textContent:b=="#href"?svgedit.utilities.getHref(a):a.getAttribute(b)};svgedit.history.ChangeElementCommand.type=function(){return"svgedit.history.ChangeElementCommand"};svgedit.history.ChangeElementCommand.prototype.type=svgedit.history.ChangeElementCommand.type;svgedit.history.ChangeElementCommand.prototype.getText=
function(){return this.text};svgedit.history.ChangeElementCommand.prototype.apply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);var q=false,h;for(h in this.newValues){if(this.newValues[h])if(h=="#text")this.elem.textContent=this.newValues[h];else h=="#href"?svgedit.utilities.setHref(this.elem,this.newValues[h]):this.elem.setAttribute(h,this.newValues[h]);else if(h=="#text")this.elem.textContent="";else{this.elem.setAttribute(h,"");this.elem.removeAttribute(h)}if(h==
"transform")q=true}if(!q)if(q=svgedit.utilities.getRotationAngle(this.elem)){h=elem.getBBox();q=["rotate(",q," ",h.x+h.width/2,",",h.y+h.height/2,")"].join("");q!=elem.getAttribute("transform")&&elem.setAttribute("transform",q)}a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this);return true};svgedit.history.ChangeElementCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);var q=false,h;for(h in this.oldValues){if(this.oldValues[h])if(h==
"#text")this.elem.textContent=this.oldValues[h];else h=="#href"?svgedit.utilities.setHref(this.elem,this.oldValues[h]):this.elem.setAttribute(h,this.oldValues[h]);else if(h=="#text")this.elem.textContent="";else this.elem.removeAttribute(h);if(h=="transform")q=true}if(!q)if(q=svgedit.utilities.getRotationAngle(this.elem)){h=this.elem.getBBox();q=["rotate(",q," ",h.x+h.width/2,",",h.y+h.height/2,")"].join("");q!=this.elem.getAttribute("transform")&&this.elem.setAttribute("transform",q)}svgedit.transformlist.removeElementFromListMap(this.elem);
a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,this);return true};svgedit.history.ChangeElementCommand.prototype.elements=function(){return[this.elem]};svgedit.history.BatchCommand=function(a){this.text=a||"Batch Command";this.stack=[]};svgedit.history.BatchCommand.type=function(){return"svgedit.history.BatchCommand"};svgedit.history.BatchCommand.prototype.type=svgedit.history.BatchCommand.type;svgedit.history.BatchCommand.prototype.getText=function(){return this.text};svgedit.history.BatchCommand.prototype.apply=
function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY,this);for(var q=this.stack.length,h=0;h<q;++h)this.stack[h].apply(a);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY,this)};svgedit.history.BatchCommand.prototype.unapply=function(a){a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY,this);for(var q=this.stack.length-1;q>=0;q--)this.stack[q].unapply(a);a&&a.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY,
this)};svgedit.history.BatchCommand.prototype.elements=function(){for(var a=[],q=this.stack.length;q--;)for(var h=this.stack[q].elements(),b=h.length;b--;)a.indexOf(h[b])==-1&&a.push(h[b]);return a};svgedit.history.BatchCommand.prototype.addSubCommand=function(a){this.stack.push(a)};svgedit.history.BatchCommand.prototype.isEmpty=function(){return this.stack.length==0};svgedit.history.UndoManager=function(a){this.handler_=a||null;this.undoStackPointer=0;this.undoStack=[];this.undoChangeStackPointer=
-1;this.undoableChangeStack=[]};svgedit.history.UndoManager.prototype.resetUndoStack=function(){this.undoStack=[];this.undoStackPointer=0};svgedit.history.UndoManager.prototype.getUndoStackSize=function(){return this.undoStackPointer};svgedit.history.UndoManager.prototype.getRedoStackSize=function(){return this.undoStack.length-this.undoStackPointer};svgedit.history.UndoManager.prototype.getNextUndoCommandText=function(){return this.undoStackPointer>0?this.undoStack[this.undoStackPointer-1].getText():
""};svgedit.history.UndoManager.prototype.getNextRedoCommandText=function(){return this.undoStackPointer<this.undoStack.length?this.undoStack[this.undoStackPointer].getText():""};svgedit.history.UndoManager.prototype.undo=function(){this.undoStackPointer>0&&this.undoStack[--this.undoStackPointer].unapply(this.handler_)};svgedit.history.UndoManager.prototype.redo=function(){this.undoStackPointer<this.undoStack.length&&this.undoStack.length>0&&this.undoStack[this.undoStackPointer++].apply(this.handler_)};
svgedit.history.UndoManager.prototype.addCommandToHistory=function(a){if(this.undoStackPointer<this.undoStack.length&&this.undoStack.length>0)this.undoStack=this.undoStack.splice(0,this.undoStackPointer);this.undoStack.push(a);this.undoStackPointer=this.undoStack.length};svgedit.history.UndoManager.prototype.beginUndoableChange=function(a,q){for(var h=++this.undoChangeStackPointer,b=q.length,n=Array(b),u=Array(b);b--;){var c=q[b];if(c!=null){u[b]=c;n[b]=c.getAttribute(a)}}this.undoableChangeStack[h]=
{attrName:a,oldValues:n,elements:u}};svgedit.history.UndoManager.prototype.finishUndoableChange=function(){for(var a=this.undoChangeStackPointer--,q=this.undoableChangeStack[a],h=q.elements.length,b=q.attrName,n=new svgedit.history.BatchCommand("Change "+b);h--;){var u=q.elements[h];if(u!=null){var c={};c[b]=q.oldValues[h];c[b]!=u.getAttribute(b)&&n.addSubCommand(new svgedit.history.ChangeElementCommand(u,c,b))}}this.undoableChangeStack[a]=null;return n}})();svgedit=svgedit||{};
(function(){if(!svgedit.select)svgedit.select={};var a,q,h;svgedit.select.Selector=function(b,n){this.id=b;this.selectedElement=n;this.locked=true;this.selectorGroup=a.createSVGElement({element:"g",attr:{id:"selectorGroup"+this.id}});this.selectorRect=this.selectorGroup.appendChild(a.createSVGElement({element:"path",attr:{id:"selectedBox"+this.id,fill:"none",stroke:"#4F80FF","stroke-width":"1","shape-rendering":"crispEdges",style:"pointer-events:none"}}));svgedit.browser.isTouch()&&this.selectorRect.setAttribute("stroke-opacity",
0.3);this.gripCoords={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null};this.reset(this.selectedElement)};svgedit.select.Selector.prototype.reset=function(b){this.locked=true;this.selectedElement=b;this.resize();this.selectorGroup.setAttribute("display","inline")};svgedit.select.Selector.prototype.updateGripCursors=function(b){var n=[];b=Math.round(b/45);if(b<0)b+=8;for(var u in h.selectorGrips)n.push(u);for(;b>0;){n.push(n.shift());b--}b=0;for(u in h.selectorGrips){h.selectorGrips[u].setAttribute("style",
"cursor:"+n[b]+"-resize");b++}};svgedit.select.Selector.prototype.showGrips=function(b){h.selectorGripsGroup.setAttribute("display",b?"inline":"none");var n=this.selectedElement;this.hasGrips=b;if(n&&b){this.selectorGroup.appendChild(h.selectorGripsGroup);this.updateGripCursors(svgedit.utilities.getRotationAngle(n))}};svgedit.select.Selector.prototype.resize=function(){var b=this.selectorRect,n=h,u=n.selectorGrips,c=this.selectedElement,g=c.getAttribute("stroke-width"),d=a.currentZoom(),l=1/d;if(c.getAttribute("stroke")!==
"none"&&!isNaN(g))l+=g/2;var v=c.tagName;if(v==="text")l+=2/d;g=svgedit.transformlist.getTransformList(c);g=svgedit.math.transformListToTransform(g).matrix;g.e*=d;g.f*=d;var A=svgedit.utilities.getBBox(c);if(v==="g"&&!$.data(c,"gsvg"))if(v=a.getStrokedBBox(c.childNodes))A=v;v=A.x;var p=A.y,K=A.width;A=A.height;l*=d;d=svgedit.math.transformBox(v*d,p*d,K*d,A*d,g);g=d.aabox;v=g.x-l;p=g.y-l;K=g.width+l*2;var R=g.height+l*2;g=v+K/2;A=p+R/2;if(c=svgedit.utilities.getRotationAngle(c)){v=a.svgRoot().createSVGTransform();
v.setRotate(-c,g,A);v=v.matrix;d.tl=svgedit.math.transformPoint(d.tl.x,d.tl.y,v);d.tr=svgedit.math.transformPoint(d.tr.x,d.tr.y,v);d.bl=svgedit.math.transformPoint(d.bl.x,d.bl.y,v);d.br=svgedit.math.transformPoint(d.br.x,d.br.y,v);v=d.tl;K=v.x;R=v.y;var O=v.x,I=v.y;v=Math.min;p=Math.max;K=v(K,v(d.tr.x,v(d.bl.x,d.br.x)))-l;R=v(R,v(d.tr.y,v(d.bl.y,d.br.y)))-l;O=p(O,p(d.tr.x,p(d.bl.x,d.br.x)))+l;I=p(I,p(d.tr.y,p(d.bl.y,d.br.y)))+l;v=K;p=R;K=O-K;R=I-R}l=a.svgRoot().suspendRedraw(100);b.setAttribute("d",
"M"+v+","+p+" L"+(v+K)+","+p+" "+(v+K)+","+(p+R)+" "+v+","+(p+R)+"z");this.selectorGroup.setAttribute("transform",c?"rotate("+[c,g,A].join(",")+")":"");if(svgedit.browser.isTouch()){v-=15.75;p-=15.75}else{v-=4;p-=4}this.gripCoords={nw:[v,p].map(Math.round),ne:[v+K,p].map(Math.round),sw:[v,p+R].map(Math.round),se:[v+K,p+R].map(Math.round),n:[v+K/2,p].map(Math.round),w:[v,p+R/2].map(Math.round),e:[v+K,p+R/2].map(Math.round),s:[v+K/2,p+R].map(Math.round)};for(var Q in this.gripCoords){b=this.gripCoords[Q];
u[Q].setAttribute("x",b[0]);u[Q].setAttribute("y",b[1])}this.rotateCoords={nw:[v,p],ne:[v+K+8,p],sw:[v,p+R+8],se:[v+K+8,p+R+8]};for(Q in this.rotateCoords){b=this.rotateCoords[Q];n.rotateGrips[Q].setAttribute("cx",b[0]);n.rotateGrips[Q].setAttribute("cy",b[1])}a.svgRoot().unsuspendRedraw(l)};svgedit.select.SelectorManager=function(){this.rubberBandBox=this.selectorParentGroup=null;this.selectors=[];this.selectorMap={};this.selectorGrips={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null};
this.selectorGripsGroup=null;this.rotateGrips={nw:null,ne:null,se:null,sw:null};this.initGroup()};svgedit.select.SelectorManager.prototype.initGroup=function(){this.selectorParentGroup&&this.selectorParentGroup.parentNode&&this.selectorParentGroup.parentNode.removeChild(this.selectorParentGroup);this.selectorParentGroup=a.createSVGElement({element:"g",attr:{id:"selectorParentGroup"}});this.selectorGripsGroup=a.createSVGElement({element:"g",attr:{display:"none"}});this.selectorParentGroup.appendChild(this.selectorGripsGroup);
a.svgRoot().appendChild(this.selectorParentGroup);this.selectorMap={};this.selectors=[];this.rubberBandBox=null;for(var b in this.rotateGrips){var n=a.createSVGElement({element:"circle",attr:{id:"selectorGrip_rotate_"+b,fill:"#000",r:8,stroke:"#000","fill-opacity":0,"stroke-opacity":0,"stroke-width":0,style:"cursor:url("+q.imgPath+"rotate.png) 12 12, auto;"}});$.data(n,"dir",b);$.data(n,"type","rotate");this.rotateGrips[b]=this.selectorGripsGroup.appendChild(n)}for(b in this.selectorGrips){n=a.createSVGElement({element:"rect",
attr:{id:"selectorGrip_resize_"+b,width:8,height:8,fill:"#4F80FF",stroke:"rgba(0,0,0,0)","stroke-width":1,style:"cursor:"+b+"-resize","pointer-events":"all"}});if(svgedit.browser.isTouch()){n.setAttribute("width",30.5);n.setAttribute("height",30.5);n.setAttribute("fill-opacity",0.3)}$.data(n,"dir",b);$.data(n,"type","resize");this.selectorGrips[b]=this.selectorGripsGroup.appendChild(n)}if(!$("#canvasBackground").length){b=q.dimensions;b=a.createSVGElement({element:"svg",attr:{id:"canvasBackground",
width:b[0],height:b[1],x:0,y:0,overflow:svgedit.browser.isWebkit()?"none":"visible",style:"pointer-events:none"}});n=a.createSVGElement({element:"defs",attr:{id:"placeholder_defs"}});var u=a.createSVGElement({element:"pattern",attr:{id:"checkerPattern",patternUnits:"userSpaceOnUse",x:0,y:0,width:20,height:20,viewBox:"0 0 10 10"}}),c=a.createSVGElement({element:"rect",attr:{x:0,y:0,width:10,height:10,fill:"#fff"}}),g=a.createSVGElement({element:"rect",attr:{x:0,y:0,width:5,height:5,fill:"#eee"}}),
d=a.createSVGElement({element:"rect",attr:{x:5,y:5,width:5,height:5,fill:"#eee"}}),l=a.createSVGElement({element:"rect",attr:{width:"100%",height:"100%",x:0,y:0,"stroke-width":1,stroke:"#000",fill:"url(#checkerPattern)",style:"pointer-events:none"}});b.appendChild(n);n.appendChild(u);u.appendChild(c);u.appendChild(g);u.appendChild(d);b.appendChild(l);a.svgRoot().insertBefore(b,a.svgContent())}};svgedit.select.SelectorManager.prototype.requestSelector=function(b){if(b==null)return null;var n=this.selectors.length;
if(typeof this.selectorMap[b.id]=="object"){this.selectorMap[b.id].locked=true;return this.selectorMap[b.id]}for(var u=0;u<n;++u)if(this.selectors[u]&&!this.selectors[u].locked){this.selectors[u].locked=true;this.selectors[u].reset(b);this.selectorMap[b.id]=this.selectors[u];return this.selectors[u]}this.selectors[n]=new svgedit.select.Selector(n,b);this.selectorParentGroup.appendChild(this.selectors[n].selectorGroup);this.selectorMap[b.id]=this.selectors[n];return this.selectors[n]};svgedit.select.SelectorManager.prototype.releaseSelector=
function(b){if(b!=null)for(var n=this.selectors.length,u=this.selectorMap[b.id],c=0;c<n;++c)if(this.selectors[c]&&this.selectors[c]==u){u.locked==false&&console.log("WARNING! selector was released but was already unlocked");delete this.selectorMap[b.id];u.locked=false;u.selectedElement=null;u.showGrips(false);try{u.selectorGroup.setAttribute("display","none")}catch(g){}break}};svgedit.select.SelectorManager.prototype.getRubberBandBox=function(){if(!this.rubberBandBox)this.rubberBandBox=this.selectorParentGroup.appendChild(a.createSVGElement({element:"rect",
attr:{id:"selectorRubberBand",fill:"none",stroke:"#666","stroke-width":1,"stroke-dasharray":"3,2",display:"none",style:"pointer-events:none"}}));return this.rubberBandBox};svgedit.select.init=function(b,n){q=b;a=n;h=new svgedit.select.SelectorManager;a.createSVGElement({element:"g",attr:{id:"hover_group"}})};svgedit.select.getSelectorManager=function(){return h}})();svgedit=svgedit||{};
(function(){if(!svgedit.draw)svgedit.draw={};var a="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),q={LET_DOCUMENT_DECIDE:0,ALWAYS_RANDOMIZE:1,NEVER_RANDOMIZE:2},h=q.LET_DOCUMENT_DECIDE;svgedit.draw.Layer=function(b,n){this.name_=b;this.group_=n};svgedit.draw.Layer.prototype.getName=function(){return this.name_};svgedit.draw.Layer.prototype.getGroup=function(){return this.group_};svgedit.draw.randomizeIds=function(b,n){h=b==false?q.NEVER_RANDOMIZE:
q.ALWAYS_RANDOMIZE;if(h==q.ALWAYS_RANDOMIZE&&!n.getNonce())n.setNonce(Math.floor(Math.random()*100001));else h==q.NEVER_RANDOMIZE&&n.getNonce()&&n.clearNonce()};svgedit.draw.Drawing=function(b,n){if(!b||!b.tagName||!b.namespaceURI||b.tagName!="svg"||b.namespaceURI!="http://www.w3.org/2000/svg")throw"Error: svgedit.draw.Drawing instance initialized without a <svg> element";this.svgElem_=b;this.obj_num=0;this.idPrefix=n||"svg_";this.releasedNums=[];this.all_layers=[];this.current_layer=null;this.nonce_=
"";var u=this.svgElem_.getAttributeNS("http://svg-edit.googlecode.com","nonce");if(u&&h!=q.NEVER_RANDOMIZE)this.nonce_=u;else h==q.ALWAYS_RANDOMIZE&&this.setNonce(Math.floor(Math.random()*100001))};svgedit.draw.Drawing.prototype.getElem_=function(b){return this.svgElem_.querySelector?this.svgElem_.querySelector("#"+b):$(this.svgElem_).find("[id="+b+"]")[0]};svgedit.draw.Drawing.prototype.getSvgElem=function(){return this.svgElem_};svgedit.draw.Drawing.prototype.getNonce=function(){return this.nonce_};
svgedit.draw.Drawing.prototype.setNonce=function(b){this.svgElem_.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:se","http://svg-edit.googlecode.com");this.svgElem_.setAttributeNS("http://svg-edit.googlecode.com","se:nonce",b);this.nonce_=b};svgedit.draw.Drawing.prototype.clearNonce=function(){this.nonce_=""};svgedit.draw.Drawing.prototype.getId=function(){return this.nonce_?this.idPrefix+this.nonce_+"_"+this.obj_num:this.idPrefix+this.obj_num};svgedit.draw.Drawing.prototype.getNextId=function(){var b=
this.obj_num,n=false;if(this.releasedNums.length>0){this.obj_num=this.releasedNums.pop();n=true}else this.obj_num++;for(var u=this.getId();this.getElem_(u);){if(n){this.obj_num=b;n=false}this.obj_num++;u=this.getId()}if(n)this.obj_num=b;return u};svgedit.draw.Drawing.prototype.releaseId=function(b){var n=this.idPrefix+(this.nonce_?this.nonce_+"_":"");if(typeof b!="string"||b.indexOf(n)!=0)return false;b=parseInt(b.substr(n.length));if(typeof b!="number"||b<=0||this.releasedNums.indexOf(b)!=-1)return false;
this.releasedNums.push(b);return true};svgedit.draw.Drawing.prototype.getNumLayers=function(){return this.all_layers.length};svgedit.draw.Drawing.prototype.hasLayer=function(b){for(var n=0;n<this.getNumLayers();n++)if(this.all_layers[n][0]==b)return true;return false};svgedit.draw.Drawing.prototype.getLayerName=function(b){if(b>=0&&b<this.getNumLayers())return this.all_layers[b][0];return""};svgedit.draw.Drawing.prototype.getCurrentLayer=function(){return this.current_layer};svgedit.draw.Drawing.prototype.getCurrentLayerName=
function(){for(var b=0;b<this.getNumLayers();++b)if(this.all_layers[b][1]==this.current_layer)return this.getLayerName(b);return""};svgedit.draw.Drawing.prototype.setCurrentLayer=function(b){for(var n=0;n<this.getNumLayers();++n)if(b==this.getLayerName(n)){if(this.current_layer!=this.all_layers[n][1]){this.current_layer.setAttribute("style","pointer-events:none");this.current_layer=this.all_layers[n][1];this.current_layer.setAttribute("style","pointer-events:all")}return true}return false};svgedit.draw.Drawing.prototype.deleteCurrentLayer=
function(){if(this.current_layer&&this.getNumLayers()>1){var b=this.current_layer.parentNode.removeChild(this.current_layer);this.identifyLayers();return b}return null};svgedit.draw.Drawing.prototype.identifyLayers=function(){this.all_layers=[];for(var b=this.svgElem_.childNodes.length,n=[],u=[],c=null,g=false,d=0;d<b;++d){var l=this.svgElem_.childNodes.item(d);if(l&&l.nodeType==1)if(l.tagName=="g"){g=true;var v=$("title",l).text();if(!v&&svgedit.browser.isOpera()&&l.querySelectorAll)v=$(l.querySelectorAll("title")).text();
if(v){u.push(v);this.all_layers.push([v,l]);c=l;svgedit.utilities.walkTree(l,function(A){A.setAttribute("style","pointer-events:inherit")});c.setAttribute("style","pointer-events:none")}else n.push(l)}else if(~a.indexOf(l.nodeName)){svgedit.utilities.getBBox(l);n.push(l)}}b=this.svgElem_.ownerDocument;if(n.length>0||!g){for(d=1;u.indexOf("Layer "+d)>=0;)d++;u="Layer "+d;c=b.createElementNS("http://www.w3.org/2000/svg","g");g=b.createElementNS("http://www.w3.org/2000/svg","title");g.textContent=u;
c.appendChild(g);for(g=0;g<n.length;++g)c.appendChild(n[g]);this.svgElem_.appendChild(c);this.all_layers.push([u,c])}svgedit.utilities.walkTree(c,function(A){A.setAttribute("style","pointer-events:inherit")});this.current_layer=c;this.current_layer.setAttribute("style","pointer-events:all")};svgedit.draw.Drawing.prototype.createLayer=function(b){var n=this.svgElem_.ownerDocument,u=n.createElementNS("http://www.w3.org/2000/svg","g");n=n.createElementNS("http://www.w3.org/2000/svg","title");n.textContent=
b;u.appendChild(n);this.svgElem_.appendChild(u);this.identifyLayers();return u};svgedit.draw.Drawing.prototype.getLayerVisibility=function(b){for(var n=null,u=0;u<this.getNumLayers();++u)if(this.getLayerName(u)==b){n=this.all_layers[u][1];break}if(!n)return false;return n.getAttribute("display")!="none"};svgedit.draw.Drawing.prototype.setLayerVisibility=function(b,n){if(typeof n!="boolean")return null;for(var u=null,c=0;c<this.getNumLayers();++c)if(this.getLayerName(c)==b){u=this.all_layers[c][1];
break}if(!u)return null;u.getAttribute("display");u.setAttribute("display",n?"inline":"none");return u};svgedit.draw.Drawing.prototype.getLayerOpacity=function(b){for(var n=0;n<this.getNumLayers();++n)if(this.getLayerName(n)==b){(b=this.all_layers[n][1].getAttribute("opacity"))||(b="1.0");return parseFloat(b)}return null};svgedit.draw.Drawing.prototype.setLayerOpacity=function(b,n){if(!(typeof n!="number"||n<0||n>1))for(var u=0;u<this.getNumLayers();++u)if(this.getLayerName(u)==b){this.all_layers[u][1].setAttribute("opacity",
n);break}}})();svgedit=svgedit||{};
(function(){if(!svgedit.path)svgedit.path={};var a={pathNodeTooltip:"Drag node to move it. Double-click node to change segment type",pathCtrlPtTooltip:"Drag control point to adjust curve properties"},q={2:["x","y"],4:["x","y"],6:["x","y","x1","y1","x2","y2"],8:["x","y","x1","y1"],10:["x","y","r1","r2","angle","largeArcFlag","sweepFlag"],12:["x"],14:["y"],16:["x","y","x2","y2"],18:["x","y"]},h=[],b=true,n={};svgedit.path.setLinkControlPoints=function(g){b=g};var u=svgedit.path.path=null;svgedit.path.init=
function(g){u=g;h=[0,"ClosePath"];$.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],function(d,l){h.push(l+"Abs");h.push(l+"Rel")})};svgedit.path.insertItemBefore=function(g,d,l){g=g.pathSegList;if(svgedit.browser.supportsPathInsertItemBefore())g.insertItemBefore(d,l);else{for(var v=g.numberOfItems,A=[],p=0;p<v;p++){var K=g.getItem(p);A.push(K)}g.clear();for(p=0;p<v;p++){p==l&&g.appendItem(d);g.appendItem(A[p])}}};
svgedit.path.ptObjToArr=function(g,d){for(var l=q[g],v=l.length,A=Array(v),p=0;p<v;p++)A[p]=d[l[p]];return A};svgedit.path.getGripPt=function(g,d){var l={x:d?d.x:g.item.x,y:d?d.y:g.item.y},v=g.path;if(v.matrix)l=svgedit.math.transformPoint(l.x,l.y,v.matrix);l.x*=u.getCurrentZoom();l.y*=u.getCurrentZoom();return l};svgedit.path.getPointFromGrip=function(g,d){var l={x:g.x,y:g.y};if(d.matrix){g=svgedit.math.transformPoint(l.x,l.y,d.imatrix);l.x=g.x;l.y=g.y}l.x/=u.getCurrentZoom();l.y/=u.getCurrentZoom();
return l};svgedit.path.addPointGrip=function(g,d,l){var v=svgedit.path.getGripContainer(),A=svgedit.utilities.getElem("pathpointgrip_"+g);if(!A){A=document.createElementNS("http://www.w3.org/2000/svg","rect");svgedit.utilities.assignAttributes(A,{id:"pathpointgrip_"+g,display:"none",width:svgedit.browser.isTouch()?30:5,height:svgedit.browser.isTouch()?30:5,fill:"#fff",stroke:"#4F80FF","shape-rendering":"crispEdges","stroke-width":1,cursor:"move",style:"pointer-events:all","xlink:title":a.pathNodeTooltip});
A=v.appendChild(A);$("#pathpointgrip_"+g).dblclick(function(){svgedit.path.path&&svgedit.path.path.setSegType()})}if(d&&l)svgedit.utilities.assignAttributes(A,{x:d-(svgedit.browser.isTouch()?15:2.5),y:l-(svgedit.browser.isTouch()?15:2.5),display:"inline"});return A};svgedit.path.getGripContainer=function(){var g=svgedit.utilities.getElem("pathpointgrip_container");if(!g){g=svgedit.utilities.getElem("selectorParentGroup").appendChild(document.createElementNS("http://www.w3.org/2000/svg","g"));g.id=
"pathpointgrip_container"}return g};svgedit.path.addCtrlGrip=function(g){var d=svgedit.utilities.getElem("ctrlpointgrip_"+g);if(d)return d;d=document.createElementNS("http://www.w3.org/2000/svg","circle");svgedit.utilities.assignAttributes(d,{id:"ctrlpointgrip_"+g,display:"none",r:svgedit.browser.isTouch()?15:3,fill:"#4F80FF",cursor:"move",style:"pointer-events:all","xlink:title":a.pathCtrlPtTooltip});svgedit.path.getGripContainer().appendChild(d);return d};svgedit.path.getCtrlLine=function(g){var d=
svgedit.utilities.getElem("ctrlLine_"+g);if(d)return d;d=document.createElementNS("http://www.w3.org/2000/svg","line");svgedit.utilities.assignAttributes(d,{id:"ctrlLine_"+g,stroke:"#4F80FF","stroke-width":1,style:"pointer-events:none"});svgedit.path.getGripContainer().appendChild(d);return d};svgedit.path.getPointGrip=function(g,d){var l=svgedit.path.addPointGrip(g.index);if(d){var v=svgedit.path.getGripPt(g);svgedit.utilities.assignAttributes(l,{x:v.x-(svgedit.browser.isTouch()?15:2.5),y:v.y-(svgedit.browser.isTouch()?
15:2.5),display:"inline"})}return l};svgedit.path.getControlPoints=function(g){var d=g.item,l=g.index;if(!("x1"in d)||!("x2"in d))return null;var v={};svgedit.path.getGripContainer();for(var A=[svgedit.path.path.segs[l-1].item,d],p=1;p<3;p++){var K=l+"c"+p,R=v["c"+p+"_line"]=svgedit.path.getCtrlLine(K),O=svgedit.path.getGripPt(g,{x:d["x"+p],y:d["y"+p]}),I=svgedit.path.getGripPt(g,{x:A[p-1].x,y:A[p-1].y});svgedit.utilities.assignAttributes(R,{x1:O.x,y1:O.y,x2:I.x,y2:I.y,display:"inline"});v["c"+p+
"_line"]=R;pointGrip=v["c"+p]=svgedit.path.addCtrlGrip(K);svgedit.utilities.assignAttributes(pointGrip,{cx:O.x,cy:O.y,display:"inline"});v["c"+p]=pointGrip}return v};svgedit.path.replacePathSeg=function(g,d,l,v){v=v||svgedit.path.path.elem;g=v["createSVGPathSeg"+h[g]].apply(v,l);if(svgedit.browser.supportsPathReplaceItem())v.pathSegList.replaceItem(g,d);else{l=v.pathSegList;v=l.numberOfItems;for(var A=[],p=0;p<v;p++){var K=l.getItem(p);A.push(K)}l.clear();for(p=0;p<v;p++)p==d?l.appendItem(g):l.appendItem(A[p])}};
svgedit.path.getSegSelector=function(g,d){var l=g.index,v=svgedit.utilities.getElem("segline_"+l);if(!v){var A=svgedit.path.getGripContainer();v=document.createElementNS("http://www.w3.org/2000/svg","path");svgedit.utilities.assignAttributes(v,{id:"segline_"+l,display:"none",fill:"none",stroke:"#0ff","shape-rendering":"crispEdges","stroke-width":2,style:"pointer-events:none",d:"M0,0 0,0"});A.appendChild(v)}if(d){l=g.prev;if(!l){v.setAttribute("display","none");return v}l=svgedit.path.getGripPt(l);
svgedit.path.replacePathSeg(2,0,[l.x,l.y],v);A=svgedit.path.ptObjToArr(g.type,g.item,true);for(var p=0;p<A.length;p+=2){l=svgedit.path.getGripPt(g,{x:A[p],y:A[p+1]});A[p]=l.x;A[p+1]=l.y}svgedit.path.replacePathSeg(g.type,1,A,v)}return v};svgedit.path.smoothControlPoints=this.smoothControlPoints=function(g,d,l){var v=g.x-l.x,A=g.y-l.y,p=d.x-l.x,K=d.y-l.y;if((v!=0||A!=0)&&(p!=0||K!=0)){g=Math.atan2(A,v);d=Math.atan2(K,p);v=Math.sqrt(v*v+A*A);p=Math.sqrt(p*p+K*K);A=u.getSVGRoot().createSVGPoint();K=
u.getSVGRoot().createSVGPoint();if(g<0)g+=2*Math.PI;if(d<0)d+=2*Math.PI;var R=Math.abs(g-d),O=Math.abs(Math.PI-R)/2;if(g-d>0){g=R<Math.PI?g+O:g-O;d=R<Math.PI?d-O:d+O}else{g=R<Math.PI?g-O:g+O;d=R<Math.PI?d+O:d-O}A.x=v*Math.cos(g)+l.x;A.y=v*Math.sin(g)+l.y;K.x=p*Math.cos(d)+l.x;K.y=p*Math.sin(d)+l.y;return[A,K]}};svgedit.path.Segment=function(g,d){this.selected=false;this.index=g;this.item=d;this.type=d.pathSegType;this.ctrlpts=[];this.segsel=this.ptgrip=null};svgedit.path.Segment.prototype.showCtrlPts=
function(g){for(var d in this.ctrlpts)this.ctrlpts[d].setAttribute("display",g?"inline":"none")};svgedit.path.Segment.prototype.selectCtrls=function(){$("#ctrlpointgrip_"+this.index+"c1, #ctrlpointgrip_"+this.index+"c2").attr("fill","#4F80FF")};svgedit.path.Segment.prototype.show=function(g){if(this.ptgrip){this.ptgrip.setAttribute("display",g?"inline":"none");this.segsel.setAttribute("display",g?"inline":"none");this.showCtrlPts(g)}};svgedit.path.Segment.prototype.select=function(g){if(this.ptgrip){this.ptgrip.setAttribute("stroke",
g?"#0FF":"#00F");this.segsel.setAttribute("display",g?"inline":"none");this.ctrlpts&&this.selectCtrls(g);this.selected=g}};svgedit.path.Segment.prototype.addGrip=function(){this.ptgrip=svgedit.path.getPointGrip(this,true);this.ctrlpts=svgedit.path.getControlPoints(this,true);this.segsel=svgedit.path.getSegSelector(this,true)};svgedit.path.Segment.prototype.update=function(g){if(this.ptgrip){var d=svgedit.path.getGripPt(this),l=svgedit.browser.isTouch()?15:2.5;svgedit.utilities.assignAttributes(this.ptgrip,
this.ptgrip.nodeName=="rect"?{x:d.x-l,y:d.y-l}:{cx:d.x,cy:d.y});svgedit.path.getSegSelector(this,true);if(this.ctrlpts){if(g){this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.type=this.item.pathSegType}svgedit.path.getControlPoints(this)}}};svgedit.path.Segment.prototype.move=function(g,d){var l=this.item;l=this.ctrlpts?[l.x+=g,l.y+=d,l.x1,l.y1,l.x2+=g,l.y2+=d]:[l.x+=g,l.y+=d];svgedit.path.replacePathSeg(this.type,this.index,l);if(this.next&&this.next.ctrlpts){l=this.next.item;
l=[l.x,l.y,l.x1+=g,l.y1+=d,l.x2,l.y2];svgedit.path.replacePathSeg(this.next.type,this.next.index,l)}if(this.mate){l=this.mate.item;l=[l.x+=g,l.y+=d];svgedit.path.replacePathSeg(this.mate.type,this.mate.index,l)}this.update(true);this.next&&this.next.update(true)};svgedit.path.Segment.prototype.setLinked=function(g){var d,l,v;if(g==2){l=1;d=this.next;if(!d)return;v=this.item}else{l=2;d=this.prev;if(!d)return;v=d.item}var A=d.item;A["x"+l]=v.x+(v.x-this.item["x"+g]);A["y"+l]=v.y+(v.y-this.item["y"+
g]);svgedit.path.replacePathSeg(d.type,d.index,[A.x,A.y,A.x1,A.y1,A.x2,A.y2]);d.update(true)};svgedit.path.Segment.prototype.moveCtrl=function(g,d,l){var v=this.item;v["x"+g]+=d;v["y"+g]+=l;svgedit.path.replacePathSeg(this.type,this.index,[v.x,v.y,v.x1,v.y1,v.x2,v.y2]);this.update(true)};svgedit.path.Segment.prototype.setType=function(g,d){svgedit.path.replacePathSeg(g,this.index,d);this.type=g;this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.showCtrlPts(g===6);this.ctrlpts=svgedit.path.getControlPoints(this);
this.update(true)};svgedit.path.Path=function(g){if(!g||g.tagName!=="path")throw"svgedit.path.Path constructed without a <path> element";this.elem=g;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 g=this.elem.pathSegList,d=g.numberOfItems;this.segs=[];this.selected_pts=[];this.first_seg=null;for(var l=0;l<d;l++){var v=g.getItem(l);v=new svgedit.path.Segment(l,v);
v.path=this;this.segs.push(v)}g=this.segs;v=null;for(l=0;l<d;l++){var A=g[l],p=l+1>=d?null:g[l+1],K=l-1<0?null:g[l-1];if(A.type===2){if(K&&K.type!==1){p=g[v];p.next=g[v+1];p.next.prev=p;p.addGrip()}v=l}else if(p&&p.type===1){A.next=g[v+1];A.next.prev=A;A.mate=g[v];A.addGrip();if(this.first_seg==null)this.first_seg=A}else if(p){if(A.type!==1){A.addGrip();if(p&&p.type!==2){A.next=p;A.next.prev=A}}}else if(A.type!==1){p=g[v];p.next=g[v+1];p.next.prev=p;p.addGrip();A.addGrip();if(!this.first_seg)this.first_seg=
g[v]}}return this};svgedit.path.Path.prototype.eachSeg=function(g){for(var d=this.segs.length,l=0;l<d;l++)if(g.call(this.segs[l],l)===false)break};svgedit.path.Path.prototype.addSeg=function(g){var d=this.segs[g];if(d.prev){var l=d.prev,v;switch(d.item.pathSegType){case 4:var A=(d.item.x+l.item.x)/2,p=(d.item.y+l.item.y)/2;v=this.elem.createSVGPathSegLinetoAbs(A,p);break;case 6:v=(l.item.x+d.item.x1)/2;var K=(d.item.x1+d.item.x2)/2,R=(d.item.x2+d.item.x)/2,O=(v+K)/2;K=(K+R)/2;A=(O+K)/2;var I=(l.item.y+
d.item.y1)/2,Q=(d.item.y1+d.item.y2)/2;l=(d.item.y2+d.item.y)/2;var U=(I+Q)/2;Q=(Q+l)/2;p=(U+Q)/2;v=this.elem.createSVGPathSegCurvetoCubicAbs(A,p,v,I,O,U);svgedit.path.replacePathSeg(d.type,g,[d.item.x,d.item.y,K,Q,R,l])}svgedit.path.insertItemBefore(this.elem,v,g)}};svgedit.path.Path.prototype.deleteSeg=function(g){var d=this.segs[g],l=this.elem.pathSegList;d.show(false);var v=d.next;if(d.mate){var A=[v.item.x,v.item.y];svgedit.path.replacePathSeg(2,v.index,A);svgedit.path.replacePathSeg(4,d.index,
A);l.removeItem(d.mate.index)}else{if(!d.prev){A=[v.item.x,v.item.y];svgedit.path.replacePathSeg(2,d.next.index,A)}l.removeItem(g)}};svgedit.path.Path.prototype.subpathIsClosed=function(g){var d=false;svgedit.path.path.eachSeg(function(l){if(l<=g)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(g){var d=this.selected_pts.indexOf(g);if(d!=-1){this.segs[g].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(g){this.eachSeg(function(){this.show(g)});g&&this.selectPt(this.first_seg.index);return this};svgedit.path.Path.prototype.movePts=function(g,d){for(var l=this.selected_pts.length;l--;)this.segs[this.selected_pts[l]].move(g,d)};svgedit.path.Path.prototype.moveCtrl=
function(g,d){var l=this.segs[this.selected_pts[0]];l.moveCtrl(this.dragctrl,g,d);b&&l.setLinked(this.dragctrl)};svgedit.path.Path.prototype.setSegType=function(g){this.storeD();for(var d=this.selected_pts.length,l;d--;){var v=this.segs[this.selected_pts[d]],A=v.prev;if(A){if(!g){l="Toggle Path Segment Type";g=v.type==6?4:6}g-=0;var p=v.item.x,K=v.item.y,R=A.item.x;A=A.item.y;var O;switch(g){case 6:if(v.olditem){R=v.olditem;O=[p,K,R.x1,R.y1,R.x2,R.y2]}else{O=p-R;var I=K-A;O=[p,K,R+O/3,A+I/3,p-O/3,
K-I/3]}break;case 4:O=[p,K];v.olditem=v.item}v.setType(g,O)}}svgedit.path.path.endChanges(l)};svgedit.path.Path.prototype.selectPt=function(g,d){this.clearSelection();g==null&&this.eachSeg(function(l){if(this.prev)g=l});this.addPtsToSelection(g);if(d){this.dragctrl=d;b&&this.segs[g].setLinked(d)}};svgedit.path.Path.prototype.update=function(){var g=this.elem;if(svgedit.utilities.getRotationAngle(g)){this.matrix=svgedit.math.getMatrix(g);this.imatrix=this.matrix.inverse()}else this.imatrix=this.matrix=
null;this.eachSeg(function(d){this.item=g.pathSegList.getItem(d);this.update()});return this};svgedit.path.getPath_=function(g){var d=n[g.id];d||(d=n[g.id]=new svgedit.path.Path(g));return d};svgedit.path.removePath_=function(g){g in n&&delete n[g]};var c=function(g,d,l,v,A,p,K){dx=g-l;dy=d-v;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)+K;dx=r*Math.cos(theta)+l;dy=r*Math.sin(theta)+v;dx-=A;dy-=p;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)-K;return{x:(r*Math.cos(theta)+A)/1,y:(r*Math.sin(theta)+
p)/1}};svgedit.path.recalcRotatedPath=function(){var g=svgedit.path.path.elem,d=svgedit.utilities.getRotationAngle(g,true);if(d){var l=svgedit.utilities.getBBox(g),v=svgedit.path.path.oldbbox,A=v.x+v.width/2;v=v.y+v.height/2;var p=l.x+l.width/2;l=l.y+l.height/2;p=p-A;var K=l-v;l=Math.sqrt(p*p+K*K);K=Math.atan2(K,p)+d;p=l*Math.cos(K)+A;l=l*Math.sin(K)+v;K=g.pathSegList;for(var R=K.numberOfItems;R;){R-=1;var O=K.getItem(R),I=O.pathSegType;if(I!=1){var Q=c(O.x,O.y,A,v,p,l,d);Q=[Q.x,Q.y];if(O.x1!=null&&
O.x2!=null){c_vals1=c(O.x1,O.y1,A,v,p,l,d);c_vals2=c(O.x2,O.y2,A,v,p,l,d);Q.splice(Q.length,0,c_vals1.x,c_vals1.y,c_vals2.x,c_vals2.y)}svgedit.path.replacePathSeg(I,R,Q)}}svgedit.utilities.getBBox(g);A=svgroot.createSVGTransform();g=svgedit.transformlist.getTransformList(g);A.setRotate(d*180/Math.PI,p,l);g.replaceItem(A,0)}};svgedit.path.clearData=function(){n={}}})();if(!window.console){window.console={};window.console.log=function(){};window.console.dir=function(){}}if(window.opera){window.console.log=function(a){opera.postError(a)};window.console.dir=function(){}}
(function(){var a=jQuery.fn.attr;jQuery.fn.attr=function(q,h){var b=this.length;if(!b)return a.apply(this,arguments);for(var n=0;n<b;n++){var u=this[n];if(u.namespaceURI==="http://www.w3.org/2000/svg")if(h!==undefined)u.setAttribute(q,h);else if($.isArray(q)){b=q.length;for(n={};b--;){var c=q[b],g=u.getAttribute(c);if(g||g==="0")g=isNaN(g)?g:g-0;n[c]=g}return n}else if(typeof q==="object")for(c in q)u.setAttribute(c,q[c]);else{if((g=u.getAttribute(q))||g==="0")g=isNaN(g)?g:g-0;return g}else return a.apply(this,
arguments)}return this}})();
$.SvgCanvas=function(a,q){function h(e,k){for(var m=svgedit.utilities.getBBox(e),B=0;B<2;B++){var z=B===0?"fill":"stroke",H=e.getAttribute(z);if(H&&H.indexOf("url(")===0){H=P(H);if(H.tagName==="linearGradient"){var C=H.getAttribute("x1")||0,w=H.getAttribute("y1")||0,E=H.getAttribute("x2")||1,J=H.getAttribute("y2")||0;C=m.width*C+m.x;w=m.height*w+m.y;E=m.width*E+m.x;J=m.height*J+m.y;C=N(C,w,k);J=N(E,J,k);E={};E.x1=(C.x-m.x)/m.width;E.y1=(C.y-m.y)/m.height;E.x2=(J.x-m.x)/m.width;E.y2=(J.y-m.y)/m.height;
H=H.cloneNode(true);$(H).attr(E);H.id=ka();jb().appendChild(H);e.setAttribute(z,"url(#"+H.id+")")}}}}var b="http://www.w3.org/2000/svg",n={show_outside_canvas:true,selectNew:true,dimensions:[640,480]};q&&$.extend(n,q);var u=n.dimensions,c=this,g=a.ownerDocument,d=g.importNode(svgedit.utilities.text2xml('<svg id="svgroot" xmlns="'+b+'" xlinkns="http://www.w3.org/1999/xlink" width="'+u[0]+'" height="'+u[1]+'" x="'+u[0]+'" y="'+u[1]+'" overflow="visible"><defs><filter id="canvashadow" filterUnits="objectBoundingBox"><feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/><feOffset in="blur" dx="5" dy="5" result="offsetBlur"/><feMerge><feMergeNode in="offsetBlur"/><feMergeNode in="SourceGraphic"/></feMerge></filter></defs></svg>').documentElement,
true);a.appendChild(d);var l=g.createElementNS(b,"svg");(c.clearSvgContentElement=function(){for(;l.firstChild;)l.removeChild(l.firstChild);$(l).attr({id:"svgcontent",width:u[0],height:u[1],x:u[0],y:u[1],overflow:n.show_outside_canvas?"visible":"hidden",xmlns:b,"xmlns:se":"http://svg-edit.googlecode.com","xmlns:xlink":"http://www.w3.org/1999/xlink"}).appendTo(d);var e=g.createComment(" Created with Method Draw - http://github.com/duopixel/Method-Draw/ ");l.appendChild(e)})();var v="svg_";c.setIdPrefix=
function(e){v=e};c.current_drawing_=new svgedit.draw.Drawing(l,v);var A=c.getCurrentDrawing=function(){return c.current_drawing_},p=1,K=null,R={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}};R.text=$.extend(true,{},R.shape);$.extend(R.text,
{fill:"#000000",stroke_width:0,font_size:24,font_family:"Helvetica, Arial, sans-serif"});var O=R.shape,I=Array(1),Q=this.addSvgElementFromJson=function(e){var k=svgedit.utilities.getElem(e.attr.id),m=A().getCurrentLayer();if(k&&e.element!=k.tagName){m.removeChild(k);k=null}if(!k){k=g.createElementNS(b,e.element);if(m)(K||m).appendChild(k)}e.curStyles&&svgedit.utilities.assignAttributes(k,{fill:O.fill,stroke:O.stroke,"stroke-width":O.stroke_width,"stroke-dasharray":O.stroke_dasharray,"stroke-linejoin":O.stroke_linejoin,
"stroke-linecap":O.stroke_linecap,"stroke-opacity":O.stroke_opacity,"fill-opacity":O.fill_opacity,opacity:O.opacity/2,style:"pointer-events:inherit"},100);svgedit.utilities.assignAttributes(k,e.attr,100);svgedit.utilities.cleanupElement(k);return k},U=c.getTransformList=svgedit.transformlist.getTransformList,N=svgedit.math.transformPoint,ha=c.matrixMultiply=svgedit.math.matrixMultiply,pa=c.hasMatrixTransform=svgedit.math.hasMatrixTransform,fa=c.transformListToTransform=svgedit.math.transformListToTransform,
T=svgedit.math.snapToAngle,Z=svgedit.math.getMatrix;svgedit.units.init({getBaseUnit:function(){return n.baseUnit},getElement:svgedit.utilities.getElem,getHeight:function(){return l.getAttribute("height")/p},getWidth:function(){return l.getAttribute("width")/p},getRoundDigits:function(){return db.round_digits}});var ua=c.convertToNum=svgedit.units.convertToNum;svgedit.utilities.init({getDOMDocument:function(){return g},getDOMContainer:function(){return a},getSVGRoot:function(){return d},getSelectedElements:function(){return I},
getSVGContent:function(){return l}});var ja=c.getUrlFromAttr=svgedit.utilities.getUrlFromAttr,da=c.getHref=svgedit.utilities.getHref,V=c.setHref=svgedit.utilities.setHref,X=svgedit.utilities.getPathBBox;c.getBBox=svgedit.utilities.getBBox;var oa=c.getRotationAngle=svgedit.utilities.getRotationAngle,qa=c.getElem=svgedit.utilities.getElem,ma=c.assignAttributes=svgedit.utilities.assignAttributes,la=this.cleanupElement=svgedit.utilities.cleanupElement,wa=svgedit.sanitize.getNSMap(),Ha=c.sanitizeSvg=svgedit.sanitize.sanitizeSvg,
Ba=svgedit.history.MoveElementCommand,Ia=svgedit.history.InsertElementCommand,Ka=svgedit.history.RemoveElementCommand,Ja=svgedit.history.ChangeElementCommand,Ea=svgedit.history.BatchCommand;c.undoMgr=new svgedit.history.UndoManager({handleHistoryEvent:function(e,k){var m=svgedit.history.HistoryEventTypes;if(e==m.BEFORE_UNAPPLY||e==m.BEFORE_APPLY)c.clearSelection();else if(e==m.AFTER_APPLY||e==m.AFTER_UNAPPLY){var B=k.elements();c.pathActions.clear();M("changed",B);B=k.type();m=e==m.AFTER_APPLY;if(B==
Ba.type()){m=m?k.newParent:k.oldParent;m==l&&c.identifyLayers()}else if(B==Ia.type()||B==Ka.type()){k.parent==l&&c.identifyLayers();if(B==Ia.type())m&&Va(k.elem);else m||Va(k.elem);k.elem.tagName==="use"&&zb(k.elem)}else if(B==Ja.type()){k.elem.tagName=="title"&&k.elem.parentNode.parentNode==l&&c.identifyLayers();m=m?k.newValues:k.oldValues;m.stdDeviation&&c.setBlurOffsets(k.elem.parentNode,m.stdDeviation);if(k.elem.tagName==="use"&&svgedit.browser.isWebkit()){B=k.elem;if(!B.getAttribute("x")&&!B.getAttribute("y")){m=
B.parentNode;var z=B.nextSibling;m.removeChild(B);m.insertBefore(B,z)}}}}}});var va=function(e){c.undoMgr.addCommandToHistory(e)};svgedit.select.init(n,{createSVGElement:function(e){return c.addSvgElementFromJson(e)},svgRoot:function(){return d},svgContent:function(){return l},currentZoom:function(){return p},getStrokedBBox:function(e){return c.getStrokedBBox([e])}});var Ga=this.selectorManager=svgedit.select.getSelectorManager();svgedit.path.init({getCurrentZoom:function(){return p},getSVGRoot:function(){return d}});
svgedit.utilities.snapToGrid=function(e){var k=n.snappingStep,m=n.baseUnit;if(m!=="px")k*=svgedit.units.getTypeMap()[m];return e=Math.round(e/k)*k};var ta=svgedit.utilities.snapToGrid,Ua={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"},ub=["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],fb=$.data,
Va=function(e){var k=$(e).attr(ub),m;for(m in k){var B=k[m];if(B&&B.indexOf("url(")===0){B=ja(B).substr(1);if(!qa(B)){jb().appendChild(tb[B]);delete tb[B]}}}e=e.getElementsByTagName("*");if(e.length){k=0;for(m=e.length;k<m;k++)Va(e[k])}},Xa={},Ca=n.imgPath+"logo.png",sa=[],db={round_digits:5},La=false,Ta=null,Da="select",hb="none",qb={},Ya=R.text,Za=O,vb=null,ra=null,kb=[],gb={},tb={};c.clipBoard=[];var lb=this.runExtensions=function(e,k,m){var B=false;if(m)B=[];$.each(gb,function(z,H){if(e in H)if(m)B.push(H[e](k));
else B=H[e](k)});return B};this.addExtension=function(e,k){if(e in gb)console.log('Cannot add extension "'+e+'", an extension by that name already exists"');else{var m=$.isFunction(k)?k($.extend(c.getPrivateMethods(),{svgroot:d,svgcontent:l,nonce:A().getNonce(),selectorManager:Ga})):k;gb[e]=m;M("extension_added",m)}};var eb=this.round=function(e){return parseInt(e*p)/p},nb=this.getIntersectionList=function(e){if(ra==null)return null;var k=K||A().getCurrentLayer();kb.length||(kb=wb(k));var m=null;
try{m=k.getIntersectionList(e,null)}catch(B){}if(m==null||typeof m.item!="function"){m=[];if(e)e=e;else{e=ra.getBBox();k={};for(var z in e)k[z]=e[z]/p;e=k}for(z=kb.length;z--;)e.width&&e.width&&svgedit.math.rectsIntersect(e,kb[z].bbox)&&m.push(kb[z].elem)}return m};getStrokedBBox=this.getStrokedBBox=function(e){e||(e=rb());if(!e.length)return false;var k=function(J){try{var F=svgedit.utilities.getBBox(J),f=svgedit.utilities.getRotationAngle(J);if(f&&f%90||svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(J))){f=
false;if(["ellipse","path","line","polyline","polygon"].indexOf(J.tagName)>=0)F=f=c.convertToPath(J,true);else if(J.tagName=="rect"){var o=J.getAttribute("rx"),s=J.getAttribute("ry");if(o||s)F=f=c.convertToPath(J,true)}if(!f){var D=J.cloneNode(true),G=document.createElementNS(b,"g"),L=J.parentNode;L.appendChild(G);G.appendChild(D);F=svgedit.utilities.bboxToObj(G.getBBox());L.removeChild(G)}}return F}catch(W){console.log(J,W);return null}},m;$.each(e,function(){if(!m)if(this.parentNode)m=k(this)});
if(m==null)return null;var B=m.x+m.width,z=m.y+m.height,H=m.x,C=m.y,w=function(J){var F=J.getAttribute("stroke-width"),f=0;if(J.getAttribute("stroke")!="none"&&!isNaN(F))f+=F/2;return f},E=[];$.each(e,function(J,F){var f=k(F);if(f){var o=w(F);H=Math.min(H,f.x-o);C=Math.min(C,f.y-o);E.push(f)}});m.x=H;m.y=C;$.each(e,function(J,F){var f=E[J];if(f&&F.nodeType==1){var o=w(F);B=Math.max(B,f.x+f.width+o);z=Math.max(z,f.y+f.height+o)}});m.width=B-H;m.height=z-C;return m};var rb=this.getVisibleElements=function(e){e||
(e=$(l).children());e.find("#canvas_background").length&&e.splice(0,1);var k=[];$(e).children().each(function(m,B){try{B.getBBox()&&k.push(B)}catch(z){}});return k.reverse()},wb=this.getVisibleElementsAndBBoxes=function(e){e||(e=$(l).children());var k=[];$(e).children().each(function(m,B){try{B.getBBox()&&k.push({elem:B,bbox:getStrokedBBox([B])})}catch(z){}});return k.reverse()},xb=this.groupSvgElem=function(e){var k=document.createElementNS(b,"g");e.parentNode.replaceChild(k,e);$(k).append(e).data("gsvg",
e)[0].id=ka()},ia=function(e){var k=document.createElementNS(e.namespaceURI,e.nodeName);k.removeAttribute("id");$.each(e.attributes,function(B,z){z.localName!="-moz-math-font-style"&&k.setAttributeNS(z.namespaceURI,z.nodeName,z.nodeValue)});if(svgedit.browser.isWebkit()&&e.nodeName=="path"){var m=Ma.convertPath(e);k.setAttribute("d",m)}$.each(e.childNodes,function(B,z){switch(z.nodeType){case 1:k.appendChild(ia(z));break;case 3:k.textContent=z.nodeValue}});if($(e).data("gsvg"))$(k).data("gsvg",k.firstChild);
else if($(e).data("symbol")){e=$(e).data("symbol");$(k).data("ref",e).data("symbol",e)}else k.tagName=="image"&&Eb(k);k.id=ka();return k},ca,ka,M;(function(e){var k={};ca=e.getId=function(){return A().getId()};ka=e.getNextId=function(){return A().getNextId()};M=e.call=function(m,B){if(k[m])return k[m](this,B)};e.bind=function(m,B){var z=k[m];k[m]=B;return z}})(c);this.prepareSvg=function(e){this.sanitizeSvg(e.documentElement);e=e.getElementsByTagNameNS(b,"path");for(var k=0,m=e.length;k<m;++k){var B=
e[k];B.setAttribute("d",Ma.convertPath(B));Ma.fixEnd(B)}};var P=this.getRefElem=function(e){return qa(ja(e).substr(1))},ea=function(e){if(!svgedit.browser.isGecko())return e;var k=e.cloneNode(true);e.parentNode.insertBefore(k,e);e.parentNode.removeChild(e);Ga.releaseSelector(e);I[0]=k;Ga.requestSelector(k).showGrips(true);return k};this.setRotationAngle=function(e,k){e=parseFloat(e);var m=I[0];if(m){var B=m.getAttribute("transform"),z=svgedit.utilities.getBBox(m),H=z.x+z.width/2,C=z.y+z.height/2;
z=U(m);z.numberOfItems>0&&z.getItem(0).type==4&&z.removeItem(0);if(e!=0){H=N(H,C,fa(z).matrix);C=d.createSVGTransform();C.setRotate(e,H.x,H.y);z.numberOfItems?z.insertItemBefore(C,0):z.appendItem(C)}else z.numberOfItems==0&&m.removeAttribute("transform");if(!k){z=m.getAttribute("transform");m.setAttribute("transform",B);ib("transform",z,I);M("changed",I)}qa("pathpointgrip_container");m=Ga.requestSelector(I[0]);m.resize();m.updateGripCursors(e)}};var Fa=this.recalculateAllSelectedDimensions=function(){for(var e=
new Ea(hb=="none"?"position":"size"),k=I.length;k--;){var m=Sa(I[k]);m&&e.addSubCommand(m)}if(!e.isEmpty()){va(e);M("changed",I)}},Oa=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],Ra=function(e){console.log([e.a,e.b,e.c,e.d,e.e,e.f])},cb=this.remapElement=function(e,k,m){var B=n.gridSnapping&&e.parentNode.parentNode.localName==="svg",z=function(){if(B)for(var f in k)k[f]=ta(k[f]);ma(e,k,1E3,true)};box=svgedit.utilities.getBBox(e);for(var H=0;H<2;H++){var C=H===0?
"fill":"stroke",w=e.getAttribute(C);if(w&&w.indexOf("url(")===0)if(m.a<0||m.d<0){w=P(w).cloneNode(true);if(m.a<0){var E=w.getAttribute("x1"),J=w.getAttribute("x2");w.setAttribute("x1",-(E-1));w.setAttribute("x2",-(J-1))}if(m.d<0){E=w.getAttribute("y1");J=w.getAttribute("y2");w.setAttribute("y1",-(E-1));w.setAttribute("y2",-(J-1))}w.id=ka();jb().appendChild(w);e.setAttribute(C,"url(#"+w.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)){C=fa(e).matrix;
C=ha(C.inverse(),m,C);k.x=parseFloat(k.x)+C.e;k.y=parseFloat(k.y)+C.f}else{C=U(e);w=d.createSVGTransform();w.setMatrix(ha(fa(C).matrix,m));C.clear();C.appendItem(w)}switch(H){case "foreignObject":case "rect":case "image":if(H==="image"&&(m.a<0||m.d<0)){C=U(e);w=d.createSVGTransform();w.setMatrix(ha(fa(C).matrix,m));C.clear();C.appendItem(w)}else{C=N(k.x,k.y,m);k.width=m.a*k.width;k.height=m.d*k.height;k.x=C.x+Math.min(0,k.width);k.y=C.y+Math.min(0,k.height);k.width=Math.abs(k.width);k.height=Math.abs(k.height)}z();
break;case "ellipse":H=N(k.cx,k.cy,m);k.cx=H.x;k.cy=H.y;k.rx=m.a*k.rx;k.ry=m.d*k.ry;k.rx=Math.abs(k.rx);k.ry=Math.abs(k.ry);z();break;case "circle":H=N(k.cx,k.cy,m);k.cx=H.x;k.cy=H.y;H=svgedit.math.transformBox(box.x,box.y,box.width,box.height,m);k.r=Math.min((H.tr.x-H.tl.x)/2,(H.bl.y-H.tl.y)/2);if(k.r)k.r=Math.abs(k.r);z();break;case "line":C=N(k.x1,k.y1,m);E=N(k.x2,k.y2,m);k.x1=C.x;k.y1=C.y;k.x2=E.x;k.y2=E.y;case "text":m=e.querySelectorAll("tspan");for(H=m.length;H--;){C=ua("x",e.getAttribute("x"));
w=ua("x",m[H].getAttribute("x"));E=ua("y",e.getAttribute("y"));J=ua("y",m[H].getAttribute("y"));var F={};if(!isNaN(C)&&!isNaN(w)&&C!=0&&w!=0&&k.x)F.x=k.x-(C-w);if(!isNaN(E)&&!isNaN(J)&&E!=0&&J!=0&&k.y)F.y=k.y-(E-J);if(F.x||F.y)ma(m[H],F,1E3,true)}z();break;case "use":z();break;case "g":(z=$(e).data("gsvg"))&&ma(z,k,1E3,true);break;case "polyline":case "polygon":z=k.points.length;for(H=0;H<z;++H){J=k.points[H];J=N(J.x,J.y,m);k.points[H].x=J.x;k.points[H].y=J.y}z=k.points.length;m="";for(H=0;H<z;++H){J=
k.points[H];m+=J.x+","+J.y+" "}e.setAttribute("points",m);break;case "path":C=e.pathSegList;z=C.numberOfItems;k.d=Array(z);for(H=0;H<z;++H){w=C.getItem(H);k.d[H]={type:w.pathSegType,x:w.x,y:w.y,x1:w.x1,y1:w.y1,x2:w.x2,y2:w.y2,r1:w.r1,r2:w.r2,angle:w.angle,largeArcFlag:w.largeArcFlag,sweepFlag:w.sweepFlag}}z=k.d.length;H=k.d[0];F=N(H.x,H.y,m);k.d[0].x=F.x;k.d[0].y=F.y;for(H=1;H<z;++H){w=k.d[H];C=w.type;if(C%2==0){J=N(w.x!=undefined?w.x:F.x,w.y!=undefined?w.y:F.y,m);C=N(w.x1,w.y1,m);E=N(w.x2,w.y2,m);
w.x=J.x;w.y=J.y;w.x1=C.x;w.y1=C.y;w.x2=E.x;w.y2=E.y}else{w.x=m.a*w.x;w.y=m.d*w.y;w.x1=m.a*w.x1;w.y1=m.d*w.y1;w.x2=m.a*w.x2;w.y2=m.d*w.y2}w.r1=m.a*w.r1;w.r2=m.d*w.r2}m="";z=k.d.length;for(H=0;H<z;++H){w=k.d[H];C=w.type;m+=Oa[C];switch(C){case 13:case 12:m+=w.x+" ";break;case 15:case 14:m+=w.y+" ";break;case 3:case 5:case 19:case 2:case 4:case 18:m+=w.x+","+w.y+" ";break;case 7:case 6:m+=w.x1+","+w.y1+" "+w.x2+","+w.y2+" "+w.x+","+w.y+" ";break;case 9:case 8:m+=w.x1+","+w.y1+" "+w.x+","+w.y+" ";break;
case 11:case 10:m+=w.r1+","+w.r2+" "+w.angle+" "+ +w.largeArcFlag+" "+ +w.sweepFlag+" "+w.x+","+w.y+" ";break;case 17:case 16:m+=w.x2+","+w.y2+" "+w.x+","+w.y+" "}}e.setAttribute("d",m)}},pb=function(e,k,m){e=P(e).firstChild;var B=U(e),z=d.createSVGTransform();z.setTranslate(k,m);B.appendItem(z);Sa(e)},Sa=this.recalculateDimensions=function(e){if(e==null)return null;var k=U(e);if(k&&k.numberOfItems>0){for(var m=k.numberOfItems;m--;){var B=k.getItem(m);if(B.type===0)k.removeItem(m);else if(B.type===
1)svgedit.math.isIdentity(B.matrix)&&k.removeItem(m);else B.type===4&&B.angle===0&&k.removeItem(m)}if(k.numberOfItems===1&&oa(e))return null}if(!k||k.numberOfItems==0){e.removeAttribute("transform");return null}if(k){m=k.numberOfItems;for(var z=[];m--;){B=k.getItem(m);if(B.type===1)z.push([B.matrix,m]);else if(z.length)z=[]}if(z.length===2){m=d.createSVGTransformFromMatrix(ha(z[1][0],z[0][0]));k.removeItem(z[0][1]);k.removeItem(z[1][1]);k.insertItemBefore(m,z[1][1])}m=k.numberOfItems;if(m>=2&&k.getItem(m-
2).type===1&&k.getItem(m-1).type===2){z=d.createSVGTransform();B=ha(k.getItem(m-2).matrix,k.getItem(m-1).matrix);z.setMatrix(B);k.removeItem(m-2);k.removeItem(m-2);k.appendItem(z)}}switch(e.tagName){case "line":case "polyline":case "polygon":case "path":break;default:if(k.numberOfItems===1&&k.getItem(0).type===1||k.numberOfItems===2&&k.getItem(0).type===1&&k.getItem(0).type===4)return null}var H=$(e).data("gsvg");m=new Ea("Transform");var C={},w=null;B=[];switch(e.tagName){case "line":B=["x1","y1",
"x2","y2"];break;case "circle":B=["cx","cy","r"];break;case "ellipse":B=["cx","cy","rx","ry"];break;case "foreignObject":case "rect":case "image":B=["width","height","x","y"];break;case "use":case "text":case "tspan":B=["x","y"];break;case "polygon":case "polyline":w={};w.points=e.getAttribute("points");z=e.points;var E=z.numberOfItems;C.points=Array(E);for(var J=0;J<E;++J){var F=z.getItem(J);C.points[J]={x:F.x,y:F.y}}break;case "path":w={};w.d=e.getAttribute("d");C.d=e.getAttribute("d")}if(B.length){C=
$(e).attr(B);$.each(C,function(xa,ya){C[xa]=ua(xa,ya)})}else if(H)C={x:$(H).attr("x")||0,y:$(H).attr("y")||0};if(w==null){w=$.extend(true,{},C);$.each(w,function(xa,ya){w[xa]=ua(xa,ya)})}w.transform=Ta?Ta:"";if(e.tagName=="g"&&!H||e.tagName=="a"){z=svgedit.utilities.getBBox(e);var f={x:z.x+z.width/2,y:z.y+z.height/2},o=N(z.x+z.width/2,z.y+z.height/2,fa(k).matrix);B=d.createSVGMatrix();if(z=oa(e)){J=z*Math.PI/180;E=Math.abs(J)>1.0E-10?Math.sin(J)/(1-Math.cos(J)):2/J;for(J=0;J<k.numberOfItems;++J){B=
k.getItem(J);if(B.type==4){B=B.matrix;f.y=(E*B.e+B.f)/2;f.x=(B.e-E*B.f)/2;k.removeItem(J);break}}}J=B=H=0;var s=k.numberOfItems;if(s)var D=k.getItem(0).matrix;if(s>=3&&k.getItem(s-2).type==3&&k.getItem(s-3).type==2&&k.getItem(s-1).type==2){J=3;var G=k.getItem(s-3).matrix,L=k.getItem(s-2).matrix,W=k.getItem(s-1).matrix;E=e.childNodes;for(F=E.length;F--;){var ba=E.item(F);B=H=0;if(ba.nodeType==1){var S=U(ba);if(S){B=fa(S).matrix;H=oa(ba);var Y=Ta,aa=[];Ta=ba.getAttribute("transform");if(H||pa(S)){var na=
d.createSVGTransform();na.setMatrix(ha(G,L,W,B));S.clear();S.appendItem(na);aa.push(na)}else{H=ha(B.inverse(),W,B);na=d.createSVGMatrix();na.e=-H.e;na.f=-H.f;B=ha(na.inverse(),B.inverse(),G,L,W,B,H.inverse());var za=d.createSVGTransform(),ga=d.createSVGTransform(),Aa=d.createSVGTransform();za.setTranslate(H.e,H.f);ga.setScale(B.a,B.d);Aa.setTranslate(na.e,na.f);S.appendItem(Aa);S.appendItem(ga);S.appendItem(za);aa.push(Aa);aa.push(ga);aa.push(za)}m.addSubCommand(Sa(ba));Ta=Y}}}k.removeItem(s-1);k.removeItem(s-
2);k.removeItem(s-3)}else if(s>=3&&k.getItem(s-1).type==1){J=3;B=fa(k).matrix;na=d.createSVGTransform();na.setMatrix(B);k.clear();k.appendItem(na)}else if((s==1||s>1&&k.getItem(1).type!=3)&&k.getItem(0).type==2){J=2;H=fa(k).matrix;k.removeItem(0);B=fa(k).matrix.inverse();B=ha(B,H);H=B.e;B=B.f;if(H!=0||B!=0){E=e.childNodes;F=E.length;for(s=[];F--;){ba=E.item(F);if(ba.nodeType==1){if(ba.getAttribute("clip-path")){Y=ba.getAttribute("clip-path");if(s.indexOf(Y)===-1){pb(Y,H,B);s.push(Y)}}Y=Ta;Ta=ba.getAttribute("transform");
if(S=U(ba)){G=d.createSVGTransform();G.setTranslate(H,B);S.numberOfItems?S.insertItemBefore(G,0):S.appendItem(G);m.addSubCommand(Sa(ba));S=e.getElementsByTagNameNS(b,"use");ba="#"+ba.id;for(G=S.length;G--;){L=S.item(G);if(ba==da(L)){W=d.createSVGTransform();W.setTranslate(-H,-B);U(L).insertItemBefore(W,0);m.addSubCommand(Sa(L))}}Ta=Y}}}s=[];Ta=Y}}else if(s==1&&k.getItem(0).type==1&&!z){J=1;B=k.getItem(0).matrix;E=e.childNodes;for(F=E.length;F--;){ba=E.item(F);if(ba.nodeType==1){Y=Ta;Ta=ba.getAttribute("transform");
if(S=U(ba)){H=ha(B,fa(S).matrix);s=d.createSVGTransform();s.setMatrix(H);S.clear();S.appendItem(s,0);m.addSubCommand(Sa(ba));Ta=Y;Y=ba.getAttribute("stroke-width");ba.getAttribute("stroke")!=="none"&&!isNaN(Y)&&ba.setAttribute("stroke-width",Y*((Math.abs(H.a)+Math.abs(H.d))/2))}}}k.clear()}else{if(z){f=d.createSVGTransform();f.setRotate(z,o.x,o.y);k.numberOfItems?k.insertItemBefore(f,0):k.appendItem(f)}k.numberOfItems==0&&e.removeAttribute("transform");return null}if(J==2){if(z){o={x:f.x+D.e,y:f.y+
D.f};f=d.createSVGTransform();f.setRotate(z,o.x,o.y);k.numberOfItems?k.insertItemBefore(f,0):k.appendItem(f)}}else if(J==3){B=fa(k).matrix;D=d.createSVGTransform();D.setRotate(z,f.x,f.y);D=D.matrix;f=d.createSVGTransform();f.setRotate(z,o.x,o.y);o=f.matrix.inverse();Y=B.inverse();o=ha(Y,o,D,B);H=o.e;B=o.f;if(H!=0||B!=0){E=e.childNodes;for(F=E.length;F--;){ba=E.item(F);if(ba.nodeType==1){Y=Ta;Ta=ba.getAttribute("transform");S=U(ba);G=d.createSVGTransform();G.setTranslate(H,B);S.numberOfItems?S.insertItemBefore(G,
0):S.appendItem(G);m.addSubCommand(Sa(ba));Ta=Y}}}if(z)k.numberOfItems?k.insertItemBefore(f,0):k.appendItem(f)}}else{z=svgedit.utilities.getBBox(e);if(!z&&e.tagName!="path")return null;B=d.createSVGMatrix();if(H=oa(e)){f={x:z.x+z.width/2,y:z.y+z.height/2};o=N(z.x+z.width/2,z.y+z.height/2,fa(k).matrix);J=H*Math.PI/180;E=Math.abs(J)>1.0E-10?Math.sin(J)/(1-Math.cos(J)):2/J;for(J=0;J<k.numberOfItems;++J){B=k.getItem(J);if(B.type==4){B=B.matrix;f.y=(E*B.e+B.f)/2;f.x=(B.e-E*B.f)/2;k.removeItem(J);break}}}J=
0;s=k.numberOfItems;if(!svgedit.browser.isWebkit())if((D=e.getAttribute("fill"))&&D.indexOf("url(")===0){D=P(D);Y="pattern";if(D.tagName!==Y)Y="gradient";if(D.getAttribute(Y+"Units")==="userSpaceOnUse"){B=fa(k).matrix;z=U(D);z=fa(z).matrix;B=ha(B,z);z="matrix("+[B.a,B.b,B.c,B.d,B.e,B.f].join(",")+")";D.setAttribute(Y+"Transform",z)}}if(s>=3&&k.getItem(s-2).type==3&&k.getItem(s-3).type==2&&k.getItem(s-1).type==2){J=3;B=fa(k,s-3,s-1).matrix;k.removeItem(s-1);k.removeItem(s-2);k.removeItem(s-3)}else if(s==
4&&k.getItem(s-1).type==1){J=3;B=fa(k).matrix;na=d.createSVGTransform();na.setMatrix(B);k.clear();k.appendItem(na);B=d.createSVGMatrix()}else if((s==1||s>1&&k.getItem(1).type!=3)&&k.getItem(0).type==2){J=2;D=k.getItem(0).matrix;Y=fa(k,1).matrix;z=Y.inverse();B=ha(z,D,Y);k.removeItem(0)}else if(s==1&&k.getItem(0).type==1&&!H){B=fa(k).matrix;switch(e.tagName){case "line":C=$(e).attr(["x1","y1","x2","y2"]);case "polyline":case "polygon":C.points=e.getAttribute("points");if(C.points){z=e.points;E=z.numberOfItems;
C.points=Array(E);for(J=0;J<E;++J){F=z.getItem(J);C.points[J]={x:F.x,y:F.y}}}case "path":C.d=e.getAttribute("d");J=1;k.clear()}}else{J=4;if(H){f=d.createSVGTransform();f.setRotate(H,o.x,o.y);k.numberOfItems?k.insertItemBefore(f,0):k.appendItem(f)}k.numberOfItems==0&&e.removeAttribute("transform");return null}if(J==1||J==2||J==3)cb(e,C,B);if(J==2){if(H){pa(k)||(o={x:f.x+B.e,y:f.y+B.f});f=d.createSVGTransform();f.setRotate(H,o.x,o.y);k.numberOfItems?k.insertItemBefore(f,0):k.appendItem(f)}}else if(J==
3&&H){B=fa(k).matrix;D=d.createSVGTransform();D.setRotate(H,f.x,f.y);D=D.matrix;f=d.createSVGTransform();f.setRotate(H,o.x,o.y);o=f.matrix.inverse();Y=B.inverse();o=ha(Y,o,D,B);cb(e,C,o);if(H)k.numberOfItems?k.insertItemBefore(f,0):k.appendItem(f)}}k.numberOfItems==0&&e.removeAttribute("transform");m.addSubCommand(new Ja(e,w));return m},ob=null,Qa=this.clearSelection=function(e){if(I[0]!=null)for(var k=I.length,m=0;m<k;++m){var B=I[m];if(B==null)break;Ga.releaseSelector(B);I[m]=null}e||M("selected",
I)},sb=this.addToSelection=function(e,k){if(e.length!=0){for(var m=0;m<I.length;){if(I[m]==null)break;++m}for(var B=e.length;B--;){var z=e[B];if(z&&svgedit.utilities.getBBox(z)){if(z.tagName==="a"&&z.childNodes.length===1)z=z.firstChild;if(I.indexOf(z)==-1){I[m]=z;m++;z=Ga.requestSelector(z);I.length>1&&z.showGrips(false)}}}M("selected",I);k||I.length==1?Ga.requestSelector(I[0]).showGrips(true):Ga.requestSelector(I[0]).showGrips(false);for(I.sort(function(H,C){if(H&&C&&H.compareDocumentPosition)return 3-
(C.compareDocumentPosition(H)&6);else if(H==null)return 1});I[0]==null;)I.shift(0)}},ab=this.selectOnly=function(e,k){Qa(true);sb(e,k)};this.removeFromSelection=function(e){if(I[0]!=null)if(e.length!=0){var k=Array(I.length);j=0;len=I.length;for(var m=0;m<len;++m){var B=I[m];if(B)if(e.indexOf(B)==-1){k[j]=B;j++}else Ga.releaseSelector(B)}I=k}};this.selectAllInCurrentLayer=function(){var e=A().getCurrentLayer();if(e){Da="select";ab($(K||e).children())}};var Fb=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 k=A().getCurrentLayer();if([d,a,l,k].indexOf(e)>=0)return d;if($(e).closest("#selectorParentGroup").length)return Ga.selectorParentGroup;for(;e.parentNode!==(K||k);)e=e.parentNode;return e};(function(){var e=null,k=null,m=null,B=
null,z=null,H={},C={minx:null,miny:null,maxx:null,maxy:null};$(a).mousedown(function(w){if(!(w.originalEvent.touches&&w.originalEvent.touches>1)){var E=w.button===2;ob=l.getScreenCTM().inverse();isBotchedZoom=svgedit.browser.isGecko();var J=N(w.pageX,w.pageY,ob),F=J.x*(isBotchedZoom?1:p);J=J.y*(isBotchedZoom?1:p);w.preventDefault();if(E)Da="select";F=F/p;J=J/p;var f=Fb(w);if(f.tagName==="a"&&f.childNodes.length===1)f=f.firstChild;var o=B=k=F,s=z=m=J;if(n.gridSnapping){F=ta(F);J=ta(J);k=ta(k);m=ta(m)}if(f==
Ga.selectorParentGroup&&I[0]!=null){f=w.target;var D=fb(f,"type");if(D=="rotate"){Da="rotate";current_rotate_mode=fb(f,"dir")}else if(D=="resize"){Da="resize";hb=fb(f,"dir")}f=I[0]}Ta=f.getAttribute("transform");D=U(f);switch(Da){case "select":La=true;hb="none";if(E)La=false;if(f!=d){if(I.indexOf(f)==-1){w.shiftKey||Qa(true);sb([f]);vb=f;Ma.clear()}if(!E)for(E=0;E<I.length;++E)if(I[E]!=null){var G=U(I[E]);G.numberOfItems?G.insertItemBefore(d.createSVGTransform(),0):G.appendItem(d.createSVGTransform())}}else if(!E){Qa();
Da="multiselect";if(ra==null)ra=Ga.getRubberBandBox();B*=p;z*=p;ma(ra,{x:B,y:z,width:0,height:0,display:"inline"},100)}break;case "zoom":La=true;if(ra==null)ra=Ga.getRubberBandBox();ma(ra,{x:o*p,y:o*p,width:0,height:0,display:"inline"},100);break;case "resize":La=true;k=F;m=J;H=svgedit.utilities.getBBox($("#selectedBox0")[0]);var L={};$.each(H,function(W,ba){L[W]=ba/p});H=L;E=oa(f)?1:0;if(pa(D)){D.insertItemBefore(d.createSVGTransform(),E);D.insertItemBefore(d.createSVGTransform(),E);D.insertItemBefore(d.createSVGTransform(),
E)}else{D.appendItem(d.createSVGTransform());D.appendItem(d.createSVGTransform());D.appendItem(d.createSVGTransform());if(svgedit.browser.supportsNonScalingStroke()){if(F=svgedit.browser.isChrome())G=function(W){var ba=W.getAttributeNS(null,"stroke");W.removeAttributeNS(null,"stroke");setTimeout(function(){W.setAttributeNS(null,"stroke",ba)},1)};f.style.vectorEffect="non-scaling-stroke";F&&G(f);J=f.getElementsByTagName("*");o=J.length;for(E=0;E<o;E++){J[E].style.vectorEffect="non-scaling-stroke";
F&&G(J[E])}}}break;case "fhellipse":case "fhrect":case "fhpath":La=true;e=o+","+s+" ";G=O.stroke_width==0?1:O.stroke_width;Q({element:"polyline",curStyles:true,attr:{points:e,id:ka(),fill:"none",opacity:O.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}});C.minx=o;C.maxx=o;C.miny=s;C.maxy=s;break;case "image":La=true;G=Q({element:"image",attr:{x:F,y:J,width:0,height:0,id:ka(),opacity:O.opacity/2,style:"pointer-events:inherit"}});V(G,Ca);Eb(G);break;case "square":case "rect":La=true;
k=F;m=J;Q({element:"rect",curStyles:true,attr:{x:F,y:J,width:0,height:0,id:ka(),opacity:O.opacity/2}});break;case "line":La=true;G=O.stroke_width==0?1:O.stroke_width;Q({element:"line",curStyles:true,attr:{x1:F,y1:J,x2:F,y2:J,id:ka(),stroke:O.stroke,"stroke-width":G,"stroke-dasharray":O.stroke_dasharray,"stroke-linejoin":O.stroke_linejoin,"stroke-linecap":O.stroke_linecap,"stroke-opacity":O.stroke_opacity,fill:"none",opacity:O.opacity/2,style:"pointer-events:none"}});break;case "circle":La=true;Q({element:"circle",
curStyles:true,attr:{cx:F,cy:J,r:0,id:ka(),opacity:O.opacity/2}});break;case "ellipse":La=true;Q({element:"ellipse",curStyles:true,attr:{cx:F,cy:J,rx:0,ry:0,id:ka(),opacity:O.opacity/2}});break;case "text":La=true;Q({element:"text",curStyles:true,attr:{x:F,y:J,id:ka(),fill:Ya.fill,"stroke-width":Ya.stroke_width,"font-size":Ya.font_size,"font-family":Ya.font_family,"text-anchor":"left","xml:space":"preserve",opacity:O.opacity}});break;case "path":case "pathedit":k*=p;m*=p;Ma.mouseDown(w,f,k,m);La=
true;break;case "textedit":k*=p;m*=p;bb.mouseDown(w,f,k,m);La=true;break;case "rotate":La=true;c.undoMgr.beginUndoableChange("transform",I);document.getElementById("workarea").className="rotate"}G=lb("mouseDown",{event:w,start_x:k,start_y:m,selectedElements:I},true);$.each(G,function(W,ba){if(ba&&ba.started)La=true});if(Da)document.getElementById("workarea").className=Da=="resize"?w.target.style.cursor:Da}}).mousemove(function(w){if(!(w.originalEvent.touches&&w.originalEvent.touches.length>1))if(La)if(!(w.button===
1||c.spaceKey)){var E=I[0],J=N(w.pageX,w.pageY,ob),F=J.x*(isBotchedZoom?1:p);J=J.y*(isBotchedZoom?1:p);var f=qa(ca()),o=x=F/p,s=y=J/p;if(n.gridSnapping){x=ta(x);y=ta(y)}w.preventDefault();switch(Da){case "select":if(I[0]!==null){o=x-k;var D=y-m;if(n.gridSnapping){o=ta(o);D=ta(D)}if(w.shiftKey){var G=T(k,m,x,y);x=G.x;y=G.y}if(o!=0||D!=0){s=I.length;for(var L=0;L<s;++L){E=I[L];if(E==null)break;var W=d.createSVGTransform();f=U(E);if(G){o=G.x-k;D=G.y-m}W.setTranslate(o,D);f.numberOfItems?f.replaceItem(W,
0):f.appendItem(W);Ga.requestSelector(E).resize()}if(w.altKey)if(!c.addClones){c.addClones=c.cloneSelectedElements(0,0,W);c.removeClones=function(){c.addClones&&c.addClones.forEach(function(ga){ga.parentNode&&ga.parentNode.removeChild(ga);c.addClones=false})};window.addEventListener("keyup",c.removeClones)}M("transition",I)}}break;case "multiselect":o*=p;s*=p;ma(ra,{x:Math.min(B,o),y:Math.min(z,s),width:Math.abs(o-B),height:Math.abs(s-z)},100);f=[];o=[];G=nb();s=I.length;for(L=0;L<s;++L){D=G.indexOf(I[L]);
if(D==-1)f.push(I[L]);else G[D]=null}s=G.length;for(L=0;L<s;++L)G[L]&&o.push(G[L]);f.length>0&&c.removeFromSelection(f);o.length>0&&sb(o);break;case "resize":f=U(E);o=(G=pa(f))?H:svgedit.utilities.getBBox(E);s=o.x;L=o.y;var ba=o.width,S=o.height;o=x-k;D=y-m;if(n.gridSnapping){o=ta(o);D=ta(D);S=ta(S);ba=ta(ba)}if(W=oa(E)){var Y=Math.sqrt(o*o+D*D);D=Math.atan2(D,o)-W*Math.PI/180;o=Y*Math.cos(D);D=Y*Math.sin(D)}if(hb.indexOf("n")==-1&&hb.indexOf("s")==-1)D=0;if(hb.indexOf("e")==-1&&hb.indexOf("w")==
-1)o=0;var aa=Y=0,na=S?(S+D)/S:1,za=ba?(ba+o)/ba:1;if(hb.indexOf("n")>=0){na=S?(S-D)/S:1;aa=S}if(hb.indexOf("w")>=0){za=ba?(ba-o)/ba:1;Y=ba}o=d.createSVGTransform();D=d.createSVGTransform();ba=d.createSVGTransform();if(n.gridSnapping){s=ta(s);Y=ta(Y);L=ta(L);aa=ta(aa)}o.setTranslate(-(s+Y),-(L+aa));if(w.shiftKey)if(za==1)za=na;else na=za;D.setScale(za,na);ba.setTranslate(s+Y,L+aa);if(G){G=W?1:0;f.replaceItem(o,2+G);f.replaceItem(D,1+G);f.replaceItem(ba,0+G)}else{G=f.numberOfItems;f.replaceItem(ba,
G-3);f.replaceItem(D,G-2);f.replaceItem(o,G-1)}Ga.requestSelector(E).resize();M("transition",I);break;case "zoom":o*=p;s*=p;ma(ra,{x:Math.min(B*p,o),y:Math.min(z*p,s),width:Math.abs(o-B*p),height:Math.abs(s-z*p)},100);break;case "text":ma(f,{x:x,y:y},1E3);break;case "line":o=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=ta(x);y=ta(y)}s=x;G=y;if(w.shiftKey){G=T(k,m,s,G);s=G.x;G=G.y}f.setAttributeNS(null,"x2",s);f.setAttributeNS(null,"y2",G);window.opera||d.unsuspendRedraw(o);break;case "foreignObject":case "square":case "rect":case "image":o=
Math.abs(x-k);G=Math.abs(y-m);if(Da=="square"||w.shiftKey){o=G=Math.max(o,G);s=k<x?k:k-o;L=m<y?m:m-G}else{s=Math.min(k,x);L=Math.min(m,y)}if(w.altKey){o*=2;G*=2;s=k-o/2;L=m-G/2}if(n.gridSnapping){o=ta(o);G=ta(G);s=ta(s);L=ta(L)}ma(f,{width:o,height:G,x:s,y:L},1E3);break;case "circle":o=$(f).attr(["cx","cy"]);G=o.cx;s=o.cy;o=Math.sqrt((x-G)*(x-G)+(y-s)*(y-s));if(n.gridSnapping)o=ta(o);f.setAttributeNS(null,"r",o);break;case "ellipse":o=$(f).attr(["cx","cy"]);G=Math.abs(k+(x-k)/2);s=Math.abs(m+(y-m)/
2);o=null;window.opera||d.suspendRedraw(1E3);if(n.gridSnapping){x=ta(x);G=ta(G);y=ta(y);s=ta(s)}L=Math.abs(k-G);D=Math.abs(m-s);if(w.shiftKey){D=L;s=y>m?m+L:m-L}if(w.altKey){G=k;s=m;L=Math.abs(x-G);D=w.shiftKey?L:Math.abs(y-s)}f.setAttributeNS(null,"rx",L);f.setAttributeNS(null,"ry",D);f.setAttributeNS(null,"cx",G);f.setAttributeNS(null,"cy",s);window.opera||d.unsuspendRedraw(o);break;case "fhellipse":case "fhrect":C.minx=Math.min(o,C.minx);C.maxx=Math.max(o,C.maxx);C.miny=Math.min(s,C.miny);C.maxy=
Math.max(s,C.maxy);case "fhpath":e+=+o+","+s+" ";f.setAttributeNS(null,"points",e);break;case "path":case "pathedit":x*=p;y*=p;if(n.gridSnapping){x=ta(x);y=ta(y);k=ta(k);m=ta(m)}if(w.shiftKey){if(G=svgedit.path.path){f=G.dragging?G.dragging[0]:k;G=G.dragging?G.dragging[1]:m}else{f=k;G=m}G=T(f,G,x,y);x=G.x;y=G.y}if(ra&&ra.getAttribute("display")!=="none"){o*=p;s*=p;ma(ra,{x:Math.min(B*p,o),y:Math.min(z*p,s),width:Math.abs(o-B*p),height:Math.abs(s-z*p)},100)}Ma.mouseMove(w,x,y);break;case "textedit":x*=
p;y*=p;bb.mouseMove(F,J);break;case "rotate":o=svgedit.utilities.getBBox(E);G=o.x+o.width/2;s=o.y+o.height/2;f=Z(E);f=N(G,s,f);G=f.x;s=f.y;f=o.x;L=o.y;if(current_rotate_mode=="nw")f=o.x+o.width;if(current_rotate_mode=="se")L=o.y+o.height;if(current_rotate_mode=="sw"){f=o.x+o.width;L=o.y+o.height}compensation_angle=(Math.atan2(s-L,G-f)*(180/Math.PI)-90)%360;W=(Math.atan2(s-y,G-x)*(180/Math.PI)-90)%360;W+=compensation_angle;if(n.gridSnapping)W=ta(W);if(w.shiftKey)W=Math.round(W/45)*45;c.setRotationAngle(W<
-180?360+W:W,true);M("transition",I)}lb("mouseMove",{event:w,mouse_x:F,mouse_y:J,selected:E})}}).click(function(w){w.preventDefault();return false}).dblclick(function(w){var E=w.target.parentNode;if(E!==K){var J=Fb(w),F=J.tagName;if(F==="text"&&Da!=="textedit"){w=N(w.pageX,w.pageY,ob);bb.select(J,w.x,w.y)}if((F==="g"||F==="a")&&oa(J)){Gb(J);J=I[0];Qa(true)}K&&Hb();E.tagName!=="g"&&E.tagName!=="a"||E===A().getCurrentLayer()||J===Ga.selectorParentGroup||Kb(J)}}).mouseup(function(w){c.addClones=false;
window.removeEventListener("keyup",c.removeClones);I=I.filter(Boolean);if(w.button!==2){var E=vb;vb=null;if(La){var J=N(w.pageX,w.pageY,ob),F=J.x*p;J=J.y*p;var f=F/p,o=J/p,s=qa(ca()),D=false;La=false;switch(Da){case "resize":case "multiselect":if(ra!=null){ra.setAttribute("display","none");kb=[]}Da="select";case "select":if(I[0]!=null){if(I.length==1){F=I[0];switch(F.tagName){case "g":case "use":case "image":case "foreignObject":break;default:Za.fill=F.getAttribute("fill");Za.fill_opacity=F.getAttribute("fill-opacity");
Za.stroke=F.getAttribute("stroke");Za.stroke_opacity=F.getAttribute("stroke-opacity");Za.stroke_width=F.getAttribute("stroke-width");Za.stroke_dasharray=F.getAttribute("stroke-dasharray");Za.stroke_linejoin=F.getAttribute("stroke-linejoin");Za.stroke_linecap=F.getAttribute("stroke-linecap")}if(F.tagName=="text"){Ya.font_size=F.getAttribute("font-size");Ya.font_family=F.getAttribute("font-family")}Ga.requestSelector(F).showGrips(true)}Fa();if(f!=B||o!=z){w=I.length;for(F=0;F<w;++F){if(I[F]==null)break;
I[F].firstChild||Ga.requestSelector(I[F]).resize()}}else{F=w.target;if(I[0].nodeName==="path"&&I[1]==null)Ma.select(I[0]);else w.shiftKey&&E!=F&&c.removeFromSelection([F])}if(svgedit.browser.supportsNonScalingStroke())if(w=I[0]){w.removeAttribute("style");svgedit.utilities.walkTree(w,function(W){W.removeAttribute("style")})}}return;case "zoom":ra!=null&&ra.setAttribute("display","none");M("zoomed",{x:Math.min(B,f),y:Math.min(z,o),width:Math.abs(f-B),height:Math.abs(o-z),factor:w.altKey?0.5:2});return;
case "fhpath":E=s.getAttribute("points");f=E.indexOf(",");if(D=f>=0?E.indexOf(",",f+1)>=0:E.indexOf(" ",E.indexOf(" ")+1)>=0)s=Ma.smoothPolylineIntoPath(s);break;case "line":E=$(s).attr(["x1","x2","y1","y2"]);D=E.x1!=E.x2||E.y1!=E.y2;break;case "foreignObject":case "square":case "rect":case "image":E=$(s).attr(["width","height"]);D=E.width!=0||E.height!=0||Da==="image";break;case "circle":D=s.getAttribute("r")!=0;break;case "ellipse":E=$(s).attr(["rx","ry"]);D=E.rx!=null||E.ry!=null;break;case "fhellipse":if(C.maxx-
C.minx>0&&C.maxy-C.miny>0){s=Q({element:"ellipse",curStyles:true,attr:{cx:(C.minx+C.maxx)/2,cy:(C.miny+C.maxy)/2,rx:(C.maxx-C.minx)/2,ry:(C.maxy-C.miny)/2,id:ca()}});M("changed",[s]);D=true}break;case "fhrect":if(C.maxx-C.minx>0&&C.maxy-C.miny>0){s=Q({element:"rect",curStyles:true,attr:{x:C.minx,y:C.miny,width:C.maxx-C.minx,height:C.maxy-C.miny,id:ca()}});M("changed",[s]);D=true}break;case "text":D=true;ab([s]);bb.start(s);break;case "path":s=null;La=true;E=Ma.mouseUp(w,s,F,J);s=E.element;D=E.keep;
break;case "pathedit":D=true;s=null;Ma.mouseUp(w);break;case "textedit":D=false;s=null;bb.mouseUp(w,F,J);break;case "rotate":D=true;s=null;Da="select";E=c.undoMgr.finishUndoableChange();E.isEmpty()||va(E);Fa();M("changed",I)}F=lb("mouseUp",{event:w,mouse_x:F,mouse_y:J},true);$.each(F,function(W,ba){if(ba){D=ba.keep||D;s=ba.element;La=ba.started||La}});if(!D&&s!=null){A().releaseId(ca());s.parentNode.removeChild(s);s=null;for(F=w.target;F.parentNode.parentNode.tagName=="g";)F=F.parentNode;if((Da!=
"path"||!drawn_path)&&F.parentNode.id!="selectorParentGroup"&&F.id!="svgcanvas"&&F.id!="svgroot"){c.setMode("select");ab([F],true)}}else if(s!=null){c.addedNew=true;w=0.2;var G;if(false.beginElement&&s.getAttribute("opacity")!=O.opacity){G=$(false).clone().attr({to:O.opacity,dur:w}).appendTo(s);try{G[0].beginElement()}catch(L){}}else w=0;setTimeout(function(){G&&G.remove();s.setAttribute("opacity",O.opacity);s.setAttribute("style","pointer-events:inherit");la(s);if(Da==="path")Ma.toEditMode(s);else n.selectNew&&
ab([s],true);va(new Ia(s));M("changed",[s])},w*1E3)}Ta=null}}});$(a).bind("mousewheel DOMMouseScroll",function(w){if(w.shiftKey){w.preventDefault();ob=l.getScreenCTM().inverse();var E=N(w.pageX,w.pageY,ob);E={x:E.x,y:E.y,width:0,height:0};if(w.wheelDelta)if(w.wheelDelta>=120)E.factor=2;else{if(w.wheelDelta<=-120)E.factor=0.5}else if(w.detail)if(w.detail>0)E.factor=0.5;else if(w.detail<0)E.factor=2;E.factor&&M("zoomed",E)}})})();var Eb=function(e){$(e).click(function(k){k.preventDefault()})},bb=c.textActions=
function(){function e(S){var Y=J.value==="";$(J).focus();if(!arguments.length)if(Y)S=0;else{if(J.selectionEnd!==J.selectionStart)return;S=J.selectionEnd}var aa;aa=s[S];Y||J.setSelectionRange(S,S);F=qa("text_cursor");if(!F){F=document.createElementNS(b,"line");ma(F,{id:"text_cursor",stroke:"#333","stroke-width":1});F=qa("selectorParentGroup").appendChild(F)}o||(o=setInterval(function(){var na=F.getAttribute("display")==="none";F.setAttribute("display",na?"inline":"none")},600));Y=H(aa.x,D.y);aa=H(aa.x,
D.y+D.height);ma(F,{x1:Y.x,y1:Y.y,x2:aa.x,y2:aa.y,visibility:"visible",display:"inline"});f&&f.setAttribute("d","M 0 0")}function k(S,Y,aa){if(S===Y)e(Y);else{aa||J.setSelectionRange(S,Y);f=qa("text_selectblock");if(!f){f=document.createElementNS(b,"path");ma(f,{id:"text_selectblock",fill:"green",opacity:0.5,style:"pointer-events:none"});qa("selectorParentGroup").appendChild(f)}S=s[S];var na=s[Y];F.setAttribute("visibility","hidden");Y=H(S.x,D.y);aa=H(S.x+(na.x-S.x),D.y);var za=H(S.x,D.y+D.height);
S=H(S.x+(na.x-S.x),D.y+D.height);ma(f,{d:"M"+Y.x+","+Y.y+" L"+aa.x+","+aa.y+" "+S.x+","+S.y+" "+za.x+","+za.y+"z",display:"inline"})}}function m(S,Y){var aa=d.createSVGPoint();aa.x=S;aa.y=Y;if(s.length==1)return 0;aa=E.getCharNumAtPosition(aa);if(aa<0){aa=s.length-2;if(S<=s[0].x)aa=0}else if(aa>=s.length-2)aa=s.length-2;var na=s[aa];S>na.x+na.width/2&&aa++;return aa}function B(S,Y,aa){var na=J.selectionStart;S=m(S,Y);k(Math.min(na,S),Math.max(na,S),!aa)}function z(S,Y){var aa={x:S,y:Y};aa.x/=p;aa.y/=
p;if(G){var na=N(aa.x,aa.y,G.inverse());aa.x=na.x;aa.y=na.y}return aa}function H(S,Y){var aa={x:S,y:Y};if(G){var na=N(aa.x,aa.y,G);aa.x=na.x;aa.y=na.y}aa.x*=p;aa.y*=p;return aa}function C(S){k(0,E.textContent.length);$(this).unbind(S)}function w(S){if(ba&&E){var Y=N(S.pageX,S.pageY,ob);Y=z(Y.x*p,Y.y*p);Y=m(Y.x,Y.y);var aa=E.textContent,na=aa.substr(0,Y).replace(/[a-z0-9]+$/i,"").length;aa=aa.substr(Y).match(/^[a-z0-9]+/i);k(na,(aa?aa[0].length:0)+Y);$(S.target).click(C);setTimeout(function(){$(S.target).unbind("click",
C)},300)}}var E,J,F,f,o,s=[],D,G,L,W,ba;return{select:function(S,Y,aa){E=S;bb.toEditMode(Y,aa)},start:function(S){E=S;bb.toEditMode()},mouseDown:function(S,Y,aa,na){S=z(aa,na);J.focus();e(m(S.x,S.y));L=aa;W=na},mouseMove:function(S,Y){var aa=z(S,Y);B(aa.x,aa.y)},mouseUp:function(S,Y,aa){var na=z(Y,aa);B(na.x,na.y,true);S.target!==E&&Y<L+2&&Y>L-2&&aa<W+2&&aa>W-2&&bb.toSelectMode(true)},setCursor:e,toEditMode:function(S,Y){ab([E],false);ba=false;Da="textedit";Ga.requestSelector(E).showGrips(false);
Ga.requestSelector(E);bb.init();$(E).css("cursor","text");if(arguments.length){var aa=z(S,Y);e(m(aa.x,aa.y))}else e();setTimeout(function(){ba=true},300)},toSelectMode:function(S){Da="select";clearInterval(o);o=null;f&&$(f).attr("display","none");F&&$(F).attr("visibility","hidden");$(E).css("cursor","move");if(S){Qa();$(E).css("cursor","move");M("selected",[E]);sb([E],true)}E&&!E.textContent.length&&c.deleteSelectedElements();$(J).blur();E=false},setInputElem:function(S){J=S},clear:function(){Da==
"textedit"&&bb.toSelectMode()},init:function(){if(E){if(!E.parentNode){E=I[0];Ga.requestSelector(E).showGrips(false)}var S=E.textContent.length,Y=E.getAttribute("transform");D=svgedit.utilities.getBBox(E);G=Y?Z(E):null;s=Array(S);J.focus();$(E).unbind("dblclick",w).dblclick(w);if(!S)var aa={x:D.x+D.width/2,width:0};for(Y=0;Y<S;Y++){var na=E.getStartPositionOfChar(Y);aa=E.getEndPositionOfChar(Y);if(!svgedit.browser.supportsGoodTextCharPos()){var za=c.contentW*p;na.x-=za;aa.x-=za;na.x/=p;aa.x/=p}s[Y]=
{x:na.x,y:D.y,width:aa.x-na.x,height:D.height}}s.push({x:aa.x,width:0});k(J.selectionStart,J.selectionEnd,true)}}}}(),Ma=c.pathActions=function(){var e=false,k,m,B;svgedit.path.Path.prototype.endChanges=function(C){if(svgedit.browser.isWebkit()){var w=this.elem;w.setAttribute("d",Ma.convertPath(w))}C=new Ja(this.elem,{d:this.last_d},C);va(C);M("changed",[this.elem])};svgedit.path.Path.prototype.addPtsToSelection=function(C){$.isArray(C)||(C=[C]);for(var w=0;w<C.length;w++){var E=C[w],J=this.segs[E];
J.ptgrip&&this.selected_pts.indexOf(E)==-1&&E>=0&&this.selected_pts.push(E)}this.selected_pts.sort();w=this.selected_pts.length;for(C=Array(w);w--;){J=this.segs[this.selected_pts[w]];J.select(true);C[w]=J.ptgrip}Ma.canDeleteNodes=true;Ma.closed_subpath=this.subpathIsClosed(this.selected_pts[0]);M("selected",C)};var z=k=null,H=false;return{mouseDown:function(C,w,E,J){if(Da==="path"){mouse_x=E;mouse_y=J;J=mouse_x/p;w=mouse_y/p;E=qa("path_stretch_line");m=[J,w];if(n.gridSnapping){J=ta(J);w=ta(w);mouse_x=
ta(mouse_x);mouse_y=ta(mouse_y)}if(!E){E=document.createElementNS(b,"path");ma(E,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"});E=qa("selectorParentGroup").appendChild(E)}E.setAttribute("display","inline");var F=null;if(z){F=z.pathSegList;for(var f=F.numberOfItems,o=6/p,s=false;f;){f--;var D=F.getItem(f),G=D.x;D=D.y;if(J>=G-o&&J<=G+o&&w>=D-o&&w<=D+o){s=true;break}}o=ca();svgedit.path.removePath_(o);o=qa(o);G=F.numberOfItems;if(s){if(f<=1&&G>=2){J=F.getItem(0).x;w=F.getItem(0).y;
C=E.pathSegList.getItem(1);C=C.pathSegType===4?z.createSVGPathSegLinetoAbs(J,w):z.createSVGPathSegCurvetoCubicAbs(J,w,C.x1/p,C.y1/p,J,w);J=z.createSVGPathSegClosePath();F.appendItem(C);F.appendItem(J)}else if(G<3)return F=false;$(E).remove();element=o;z=null;La=false;if(e){svgedit.path.path.matrix&&cb(o,{},svgedit.path.path.matrix.inverse());E=o.getAttribute("d");C=$(svgedit.path.path.elem).attr("d");$(svgedit.path.path.elem).attr("d",C+E);$(o).remove();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();
svgedit.path.path.init();Ma.toEditMode(svgedit.path.path.elem);svgedit.path.path.selectPt();return false}}else{if(!$.contains(a,Fb(C))){console.log("Clicked outside canvas");return false}F=z.pathSegList.numberOfItems;f=z.pathSegList.getItem(F-1);o=f.x;f=f.y;if(C.shiftKey){C=T(o,f,J,w);J=C.x;w=C.y}C=E.pathSegList.getItem(1);C=C.pathSegType===4?z.createSVGPathSegLinetoAbs(eb(J),eb(w)):z.createSVGPathSegCurvetoCubicAbs(eb(J),eb(w),C.x1/p,C.y1/p,C.x2/p,C.y2/p);z.pathSegList.appendItem(C);J*=p;w*=p;E.setAttribute("d",
["M",J,w,J,w].join(" "));E=F;if(e)E+=svgedit.path.path.segs.length;svgedit.path.addPointGrip(E,J,w)}}else{d_attr="M"+J+","+w+" ";z=Q({element:"path",curStyles:true,attr:{d:d_attr,id:ka(),opacity:O.opacity/2}});E.setAttribute("d",["M",mouse_x,mouse_y,mouse_x,mouse_y].join(" "));E=e?svgedit.path.path.segs.length:0;svgedit.path.addPointGrip(E,mouse_x,mouse_y)}}else if(svgedit.path.path){svgedit.path.path.storeD();o=C.target.id;if(o.substr(0,14)=="pathpointgrip_"){w=svgedit.path.path.cur_pt=parseInt(o.substr(14));
svgedit.path.path.dragging=[E,J];F=svgedit.path.path.segs[w];if(C.shiftKey)F.selected?svgedit.path.path.removePtFromSelection(w):svgedit.path.path.addPtsToSelection(w);else{if(svgedit.path.path.selected_pts.length<=1||!F.selected)svgedit.path.path.clearSelection();svgedit.path.path.addPtsToSelection(w)}}else if(o.indexOf("ctrlpointgrip_")==0){svgedit.path.path.dragging=[E,J];C=o.split("_")[1].split("c");w=C[0]-0;svgedit.path.path.selectPt(w,C[1]-0)}if(!svgedit.path.path.dragging){if(ra==null)ra=Ga.getRubberBandBox();
ma(ra,{x:E*p,y:J*p,width:0,height:0,display:"inline"},100)}}},mouseMove:function(C,w,E){H=true;if(Da==="path"){if(z){var J=z.pathSegList;C=J.numberOfItems-1;if(m){var F=svgedit.path.addCtrlGrip("1c1"),f=svgedit.path.addCtrlGrip("0c2");f.getAttribute("cx");f.getAttribute("cy");F.setAttribute("cx",w);F.setAttribute("cy",E);F.setAttribute("display","inline");F=m[0];var o=m[1];J.getItem(C);var s=F+(F-w/p),D=o+(o-E/p);f.setAttribute("cx",s*p);f.setAttribute("cy",D*p);f.setAttribute("display","inline");
f=svgedit.path.getCtrlLine(1);var G=svgedit.path.getCtrlLine(2);ma(f,{x1:w,y1:E,x2:F*p,y2:o*p,display:"inline"});ma(G,{x1:s*p,y1:D*p,x2:F*p,y2:o*p,display:"inline"});if(C===0)B=[w,E];else{J=J.getItem(C-1);w=J.x;E=J.y;if(J.pathSegType===6){w+=w-J.x2;E+=E-J.y2}else if(B){w=B[0]/p;E=B[1]/p}svgedit.path.replacePathSeg(6,C,[F,o,w,E,s,D],z)}}else if(F=qa("path_stretch_line")){C=J.getItem(C);if(C.pathSegType===6)svgedit.path.replacePathSeg(6,1,[w,E,(C.x+(C.x-C.x2))*p,(C.y+(C.y-C.y2))*p,w,E],F);else B?svgedit.path.replacePathSeg(6,
1,[w,E,B[0],B[1],w,E],F):svgedit.path.replacePathSeg(4,1,[w,E],F)}}}else if(svgedit.path.path.dragging){F=svgedit.path.getPointFromGrip({x:svgedit.path.path.dragging[0],y:svgedit.path.path.dragging[1]},svgedit.path.path);o=svgedit.path.getPointFromGrip({x:w,y:E},svgedit.path.path);C=o.x-F.x;F=o.y-F.y;svgedit.path.path.dragging=[w,E];svgedit.path.path.dragctrl?svgedit.path.path.moveCtrl(C,F):svgedit.path.path.movePts(C,F)}else{svgedit.path.path.selected_pts=[];svgedit.path.path.eachSeg(function(){if(this.next||
this.prev){var L=ra.getBBox(),W=svgedit.path.getGripPt(this);L=svgedit.math.rectsIntersect(L,{x:W.x,y:W.y,width:0,height:0});this.select(L);L&&svgedit.path.path.selected_pts.push(this.index)}})}},mouseUp:function(C,w){if(Da==="path"){m=null;if(!z){w=qa(ca());La=false;B=null}return{keep:true,element:w}}if(svgedit.path.path.dragging){var E=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)");
!C.shiftKey&&!H&&svgedit.path.path.selectPt(E)}else if(ra&&ra.getAttribute("display")!="none"){ra.setAttribute("display","none");ra.getAttribute("width")<=2&&ra.getAttribute("height")<=2&&Ma.toSelectMode(C.target)}else Ma.toSelectMode(C.target);H=false},toEditMode:function(C){svgedit.path.path=svgedit.path.getPath_(C);Da="pathedit";Qa();svgedit.path.path.show(true).update();svgedit.path.path.oldbbox=svgedit.utilities.getBBox(svgedit.path.path.elem);e=false},toSelectMode:function(C){var w=C==svgedit.path.path.elem;
Da="select";svgedit.path.path.show(false);k=false;Qa();svgedit.path.path.matrix&&svgedit.path.recalcRotatedPath();if(w){M("selected",[C]);sb([C],true)}},addSubPath:function(C){if(C){Da="path";e=true}else{Ma.clear(true);Ma.toEditMode(svgedit.path.path.elem)}},select:function(C){if(k===C){Ma.toEditMode(C);Da="pathedit"}else k=C},reorient:function(){var C=I[0];if(C)if(oa(C)!=0){var w=new Ea("Reorient path"),E={d:C.getAttribute("d"),transform:C.getAttribute("transform")};w.addSubCommand(new Ja(C,E));
Qa();this.resetOrientation(C);va(w);svgedit.path.getPath_(C).show(false).matrix=null;this.clear();sb([C],true);M("changed",I)}},clear:function(){k=null;if(z){var C=qa(ca());$(qa("path_stretch_line")).remove();$(C).remove();$(qa("pathpointgrip_container")).find("*").attr("display","none");z=B=null;La=false}else Da=="pathedit"&&this.toSelectMode();svgedit.path.path&&svgedit.path.path.init().show(false)},resetOrientation:function(C){if(C==null||C.nodeName!="path")return false;var w=U(C),E=fa(w).matrix;
w.clear();C.removeAttribute("transform");w=C.pathSegList;for(var J=w.numberOfItems,F=0;F<J;++F){var f=w.getItem(F),o=f.pathSegType;if(o!=1){var s=[];$.each(["",1,2],function(D,G){var L=f["x"+G],W=f["y"+G];if(L!==undefined&&W!==undefined){L=N(L,W,E);s.splice(s.length,0,L.x,L.y)}});svgedit.path.replacePathSeg(o,F,s,C)}}h(C,E)},zoomChange:function(){Da=="pathedit"&&svgedit.path.path.update()},getNodePoint:function(){var C=svgedit.path.path.segs[svgedit.path.path.selected_pts.length?svgedit.path.path.selected_pts[0]:
1];return{x:C.item.x,y:C.item.y,type:C.type}},linkControlPoints:function(C){svgedit.path.setLinkControlPoints(C)},clonePathNode:function(){svgedit.path.path.storeD();for(var C=svgedit.path.path.selected_pts,w=C.length,E=[];w--;){var J=C[w];svgedit.path.path.addSeg(J);E.push(J+w);E.push(J+w+1)}svgedit.path.path.init().addPtsToSelection(E);svgedit.path.path.endChanges("Clone path node(s)")},opencloseSubPath:function(){var C=svgedit.path.path.selected_pts;if(C.length===1){var w=svgedit.path.path.elem,
E=w.pathSegList,J=C[0],F=null,f=null;svgedit.path.path.eachSeg(function(G){if(this.type===2&&G<=J)f=this.item;if(G<=J)return true;if(this.type===2){F=G;return false}else if(this.type===1)return F=false});if(F==null)F=svgedit.path.path.segs.length-1;if(F!==false){var o=w.createSVGPathSegLinetoAbs(f.x,f.y),s=w.createSVGPathSegClosePath();if(F==svgedit.path.path.segs.length){E.appendItem(o);E.appendItem(s)}else{svgedit.path.insertItemBefore(w,s,F);svgedit.path.insertItemBefore(w,o,F)}svgedit.path.path.init().selectPt(F+
1)}else if(svgedit.path.path.segs[J].mate){E.removeItem(J);E.removeItem(J);svgedit.path.path.init().selectPt(J-1)}else{for(C=0;C<E.numberOfItems;C++){var D=E.getItem(C);if(D.pathSegType===2)o=C;else if(C===J)E.removeItem(o);else if(D.pathSegType===1&&J<C){s=C-1;E.removeItem(C);break}}for(C=J-o-1;C--;)svgedit.path.insertItemBefore(w,E.getItem(o),s);w=E.getItem(o);svgedit.path.replacePathSeg(2,o,[w.x,w.y]);C=J;svgedit.path.path.init().selectPt(0)}}},deletePathNode:function(){if(Ma.canDeleteNodes){svgedit.path.path.storeD();
for(var C=svgedit.path.path.selected_pts,w=C.length;w--;)svgedit.path.path.deleteSeg(C[w]);var E=function(){var J=svgedit.path.path.elem.pathSegList,F=J.numberOfItems,f=function(D,G){for(;G--;)J.removeItem(D)};if(F<=1)return true;for(;F--;){var o=J.getItem(F);if(o.pathSegType===1){o=J.getItem(F-1);var s=J.getItem(F-2);if(o.pathSegType===2){f(F-1,2);E();break}else if(s.pathSegType===2){f(F-2,3);E();break}}else if(o.pathSegType===2)if(F>0){o=J.getItem(F-1).pathSegType;if(o===2){f(F-1,1);E();break}else if(o===
1&&J.numberOfItems-1===F){f(F,1);E();break}}}return false};E();if(svgedit.path.path.elem.pathSegList.numberOfItems<=1){Ma.toSelectMode(svgedit.path.path.elem);c.deleteSelectedElements()}else{svgedit.path.path.init();svgedit.path.path.clearSelection();if(window.opera){C=$(svgedit.path.path.elem);C.attr("d",C.attr("d"))}svgedit.path.path.endChanges("Delete path node(s)")}}},smoothPolylineIntoPath:function(C){var w=C.points,E=w.numberOfItems;if(E>=4){var J=w.getItem(0),F=null;C=[];C.push(["M",J.x,",",
J.y," C"].join(""));for(var f=1;f<=E-4;f+=3){var o=w.getItem(f),s=w.getItem(f+1),D=w.getItem(f+2);if(F)if((J=svgedit.path.smoothControlPoints(F,o,J))&&J.length==2){o=C[C.length-1].split(",");o[2]=J[0].x;o[3]=J[0].y;C[C.length-1]=o.join(",");o=J[1]}C.push([o.x,o.y,s.x,s.y,D.x,D.y].join(","));J=D;F=s}for(C.push("L");f<E;++f){s=w.getItem(f);C.push([s.x,s.y].join(","))}C=C.join(" ");C=Q({element:"path",curStyles:true,attr:{id:ca(),d:C,fill:"none"}})}return C},setSegType:function(C){svgedit.path.path.setSegType(C)},
moveNode:function(C,w){var E=svgedit.path.path.selected_pts;if(E.length){svgedit.path.path.storeD();E=svgedit.path.path.segs[E[0]];var J={x:0,y:0};J[C]=w-E.item[C];E.move(J.x,J.y);svgedit.path.path.endChanges("Move path point")}},fixEnd:function(C){for(var w=C.pathSegList,E=w.numberOfItems,J,F=0;F<E;++F){var f=w.getItem(F);if(f.pathSegType===2)J=f;if(f.pathSegType===1){f=w.getItem(F-1);if(f.x!=J.x||f.y!=J.y){w=C.createSVGPathSegLinetoAbs(J.x,J.y);svgedit.path.insertItemBefore(C,w,F);Ma.fixEnd(C);
break}}}svgedit.browser.isWebkit()&&C.setAttribute("d",Ma.convertPath(C))},convertPath:function(C,w){for(var E=C.pathSegList,J=E.numberOfItems,F=0,f=0,o="",s=null,D=0;D<J;++D){var G=E.getItem(D),L=G.x||0,W=G.y||0,ba=G.x1||0,S=G.y1||0,Y=G.x2||0,aa=G.y2||0,na=G.pathSegType,za=Oa[na]["to"+(w?"Lower":"Upper")+"Case"](),ga=function(Aa,xa,ya){xa=xa?" "+xa.join(" "):"";ya=ya?" "+svgedit.units.shortFloat(ya):"";$.each(Aa,function(Na,$a){Aa[Na]=svgedit.units.shortFloat($a)});o+=za+Aa.join(" ")+xa+ya};switch(na){case 1:o+=
"z";break;case 12:L-=F;case 13:if(w){F+=L;za="l"}else{L+=F;F=L;za="L"}ga([[L,f]]);break;case 14:W-=f;case 15:if(w){f+=W;za="l"}else{W+=f;f=W;za="L"}ga([[F,W]]);break;case 2:case 4:case 18:L-=F;W-=f;case 5:case 3:if(s&&E.getItem(D-1).pathSegType===1&&!w){F=s[0];f=s[1]}case 19:if(w){F+=L;f+=W}else{L+=F;W+=f;F=L;f=W}if(na===3)s=[F,f];ga([[L,W]]);break;case 6:L-=F;ba-=F;Y-=F;W-=f;S-=f;aa-=f;case 7:if(w){F+=L;f+=W}else{L+=F;ba+=F;Y+=F;W+=f;S+=f;aa+=f;F=L;f=W}ga([[ba,S],[Y,aa],[L,W]]);break;case 8:L-=F;
ba-=F;W-=f;S-=f;case 9:if(w){F+=L;f+=W}else{L+=F;ba+=F;W+=f;S+=f;F=L;f=W}ga([[ba,S],[L,W]]);break;case 10:L-=F;W-=f;case 11:if(w){F+=L;f+=W}else{L+=F;W+=f;F=L;f=W}ga([[G.r1,G.r2]],[G.angle,G.largeArcFlag?1:0,G.sweepFlag?1:0],[L,W]);break;case 16:L-=F;Y-=F;W-=f;aa-=f;case 17:if(w){F+=L;f+=W}else{L+=F;Y+=F;W+=f;aa+=f;F=L;f=W}ga([[Y,aa],[L,W]])}}return o}}}(),Ob=this.removeUnusedDefElems=function(){var e=l.getElementsByTagNameNS(b,"defs");if(!e||!e.length)return 0;for(var k=[],m=0,B=["fill","stroke",
"filter","marker-start","marker-mid","marker-end"],z=B.length,H=l.getElementsByTagNameNS(b,"*"),C=H.length,w=0;w<C;w++){for(var E=H[w],J=0;J<z;J++){var F=ja(E.getAttribute(B[J]));F&&k.push(F.substr(1))}(E=da(E))&&E.indexOf("#")===0&&k.push(E.substr(1))}e=$(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");defelem_ids=[];for(w=e.length;w--;){B=e[w];z=B.id;if(k.indexOf(z)<0){tb[z]=B;B.parentNode.removeChild(B);m++}}return m};this.svgCanvasToString=function(){for(;Ob()>0;);Ma.clear(true);
$.each(l.childNodes,function(m,B){m&&B.nodeType===8&&B.data.indexOf("Created with")>=0&&l.insertBefore(B,l.firstChild)});if(K){Hb();ab([K])}$("#canvasGrid").attr("display","none");var e=[];$(l).find("g:data(gsvg)").each(function(){for(var m=this.attributes,B=m.length,z=0;z<B;z++)if(m[z].nodeName=="id"||m[z].nodeName=="style")B--;if(B<=0){m=this.firstChild;e.push(m);$(this).replaceWith(m)}});var k=this.svgToString(l,0);e.length&&$(e).each(function(){xb(this)});return k};this.svgToString=function(e,
k){var m=[],B=svgedit.utilities.toXml,z=n.baseUnit,H=RegExp("^-?[\\d\\.]+"+z+"$");if(e){la(e);var C=e.attributes,w,E,J=e.childNodes;for(E=0;E<k;E++)m.push(" ");m.push("<");m.push(e.nodeName);if(e.id==="svgcontent"){E=Ab();if(z!=="px"){E.w=svgedit.units.convertUnit(E.w,z)+z;E.h=svgedit.units.convertUnit(E.h,z)+z}m.push(' width="'+E.w+'" height="'+E.h+'" xmlns="'+b+'"');var F={};$(e).find("*").andSelf().each(function(){$.each(this.attributes,function(D,G){var L=G.namespaceURI;if(L&&!F[L]&&wa[L]!=="xmlns"&&
wa[L]!=="xml"){F[L]=true;m.push(" xmlns:"+wa[L]+'="'+L+'"')}})});E=C.length;for(z=["width","height","xmlns","x","y","viewBox","id","overflow"];E--;){w=C.item(E);var f=B(w.nodeValue);if(w.nodeName.indexOf("xmlns:")!==0)if(f!=""&&z.indexOf(w.localName)==-1)if(!w.namespaceURI||wa[w.namespaceURI]){m.push(" ");m.push(w.nodeName);m.push('="');m.push(f);m.push('"')}}}else{if(e.nodeName==="defs"&&!e.firstChild)return;var o=["-moz-math-font-style","_moz-math-font-style"];for(E=C.length-1;E>=0;E--){w=C.item(E);
f=B(w.nodeValue);if(!(o.indexOf(w.localName)>=0))if(f!="")if(f.indexOf("pointer-events")!==0)if(!(w.localName==="class"&&f.indexOf("se_")===0)){m.push(" ");if(w.localName==="d")f=Ma.convertPath(e,true);if(isNaN(f)){if(H.test(f))f=svgedit.units.shortFloat(f)+z}else f=svgedit.units.shortFloat(f);if(db.apply&&e.nodeName==="image"&&w.localName==="href"&&db.images&&db.images==="embed"){var s=Xa[f];if(s)f=s}if(!w.namespaceURI||w.namespaceURI==b||wa[w.namespaceURI]){m.push(w.nodeName);m.push('="');m.push(f);
m.push('"')}}}}if(e.hasChildNodes()){m.push(">");k++;C=false;for(E=0;E<J.length;E++){z=J.item(E);switch(z.nodeType){case 1:m.push("\n");m.push(this.svgToString(J.item(E),k));break;case 3:z=z.nodeValue.replace(/^\s+|\s+$/g,"");if(z!=""){C=true;m.push(B(z)+"")}break;case 4:m.push("\n");m.push(Array(k+1).join(" "));m.push("<![CDATA[");m.push(z.nodeValue);m.push("]]\>");break;case 8:m.push("\n");m.push(Array(k+1).join(" "));m.push("<!--");m.push(z.data);m.push("--\>")}}k--;if(!C){m.push("\n");for(E=0;E<
k;E++)m.push(" ")}m.push("</");m.push(e.nodeName);m.push(">")}else m.push("/>")}return m.join("")};this.embedImage=function(e,k){$(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 B=";svgedit_url="+encodeURIComponent(e);B=m.toDataURL().replace(";base64",B+";base64");Xa[e]=B}catch(z){Xa[e]=false}Ca=e;k&&k(Xa[e])}).attr("src",e)};this.setGoodImage=function(e){Ca=e};this.open=function(){};this.save=
function(e){Qa();e&&$.extend(db,e);db.apply=true;e=this.svgCanvasToString();M("saved",e)};this.rasterExport=function(){Qa();var e=[],k={feGaussianBlur:Ua.exportNoBlur,foreignObject:Ua.exportNoforeignObject,"[stroke-dasharray]":Ua.exportNoDashArray},m=$(l);if(!("font"in $("<canvas>")[0].getContext("2d")))k.text=Ua.exportNoText;$.each(k,function(B,z){m.find(B).length&&e.push(z)});k=this.svgCanvasToString();M("exported",{svg:k,issues:e})};this.getSvgString=function(){db.apply=false;return this.svgCanvasToString()};
this.randomizeIds=function(){arguments.length>0&&arguments[0]==false?svgedit.draw.randomizeIds(false,A()):svgedit.draw.randomizeIds(true,A())};var Lb=this.uniquifyElems=function(e){var k={},m=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];svgedit.utilities.walkTree(e,function(w){if(w.nodeType==1){if(w.id){w.id in k||(k[w.id]={elem:null,attrs:[],hrefs:[]});k[w.id].elem=w}$.each(ub,function(J,F){var f=w.getAttributeNode(F);if(f){var o=svgedit.utilities.getUrlFromAttr(f.value);
if(o=o?o.substr(1):null){o in k||(k[o]={elem:null,attrs:[],hrefs:[]});k[o].attrs.push(f)}}});var E=svgedit.utilities.getHref(w);if(E&&m.indexOf(w.nodeName)>=0)if(E=E.substr(1)){E in k||(k[E]={elem:null,attrs:[],hrefs:[]});k[E].hrefs.push(w)}}});for(var B in k)if(B){var z=k[B].elem;if(z){e=ka();z.id=e;z=k[B].attrs;for(var H=z.length;H--;){var C=z[H];C.ownerElement.setAttribute(C.name,"url(#"+e+")")}z=k[B].hrefs;for(H=z.length;H--;)svgedit.utilities.setHref(z[H],"#"+e)}}},zb=this.setUseData=function(e){var k=
$(e);if(e.tagName!=="use")k=k.find("use");k.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)}})},Mb=this.convertGradients=function(e){var k=$(e).find("linearGradient, radialGradient");if(!k.length&&svgedit.browser.isWebkit())k=$(e).find("*").filter(function(){return this.tagName.indexOf("Gradient")>=0});k.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 B=$(this).attr(["x1","y1","x2","y2"]),z=this.gradientTransform.baseVal;if(z&&z.numberOfItems>0){var H=fa(z).matrix;z=N(B.x1,B.y1,H);H=N(B.x2,B.y2,H);B.x1=z.x;B.y1=z.y;B.x2=H.x;B.y2=H.y;this.removeAttribute("gradientTransform")}$(this).attr({x1:(B.x1-m.x)/m.width,y1:(B.y1-m.y)/m.height,x2:(B.x2-m.x)/m.width,y2:(B.y2-m.y)/m.height});this.removeAttribute("gradientUnits")}}})},
Pb=this.convertToGroup=function(e){e||(e=I[0]);var k=$(e),m=new Ea,B;if(k.data("gsvg")){m=$(e.firstChild).attr(["x","y"]);$(e.firstChild.firstChild).unwrap();$(e).removeData("gsvg");B=U(e);var z=d.createSVGTransform();z.setTranslate(m.x,m.y);B.appendItem(z);Sa(e);M("selected",[e])}else if(k.data("symbol")){e=k.data("symbol");B=k.attr("transform");z=k.attr(["x","y"]);var H=e.getAttribute("viewBox");if(H){H=H.split(" ");z.x-=+H[0];z.y-=+H[1]}B+=" translate("+(z.x||0)+","+(z.y||0)+")";z=k.prev();m.addSubCommand(new Ka(k[0],
k[0].nextSibling,k[0].parentNode));k.remove();H=$(l).find("use:data(symbol)").length;k=g.createElementNS(b,"g");for(var C=e.childNodes,w=0;w<C.length;w++)k.appendChild(C[w].cloneNode(true));if(svgedit.browser.isGecko()){C=$(jb()).children("linearGradient,radialGradient,pattern").clone();$(k).append(C)}B&&k.setAttribute("transform",B);B=e.parentNode;Lb(k);svgedit.browser.isGecko()&&$(jb()).append($(k).find("linearGradient,radialGradient,pattern"));k.id=ka();z.after(k);if(B){if(!H){z=e.nextSibling;
B.removeChild(e);m.addSubCommand(new Ka(e,z,B))}m.addSubCommand(new Ia(k))}zb(k);svgedit.browser.isGecko()?Mb(jb()):Mb(k);svgedit.utilities.walkTreePost(k,function(E){try{Sa(E)}catch(J){console.log(J)}});$(k).find("a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use").each(function(){if(!this.id)this.id=ka()});ab([k]);(e=Gb(k,true))&&m.addSubCommand(e);va(m)}else console.log("Unexpected element to ungroup:",e)};this.setSvgString=function(e){try{var k=svgedit.utilities.text2xml(e);
this.prepareSvg(k);var m=new Ea("Change Source"),B=l.nextSibling,z=d.removeChild(l);m.addSubCommand(new Ka(z,B,d));l=g.adoptNode?g.adoptNode(k.documentElement):g.importNode(k.documentElement,true);d.appendChild(l);var H=$(l);c.current_drawing_=new svgedit.draw.Drawing(l,v);var C=A().getNonce();C?M("setnonce",C):M("unsetnonce");H.find("image").each(function(){var s=this;Eb(s);var D=da(this);if(D.indexOf("data:")===0){var G=D.match(/svgedit_url=(.*?);/);if(G){var L=decodeURIComponent(G[1]);$(new Image).load(function(){s.setAttributeNS("http://www.w3.org/1999/xlink",
"xlink:href",L)}).attr("src",L)}}c.embedImage(D)});H.find("svg").each(function(){if(!$(this).closest("defs").length){Lb(this);var s=this.parentNode;if(s.childNodes.length===1&&s.nodeName==="g"){$(s).data("gsvg",this);s.id=s.id||ka()}else xb(this)}});svgedit.browser.isGecko()&&H.find("linearGradient, radialGradient, pattern").appendTo(jb());zb(H);Mb(H[0]);svgedit.utilities.walkTreePost(l,function(s){try{Sa(s)}catch(D){console.log(D)}});var w={id:"svgcontent",overflow:n.show_outside_canvas?"visible":
"hidden"},E=false;if(H.attr("viewBox")){var J=H.attr("viewBox").split(" ");w.width=J[2];w.height=J[3]}else $.each(["width","height"],function(s,D){var G=H.attr(D);G||(G="100%");if((G+"").substr(-1)==="%")E=true;else w[D]=ua(D,G)});Bb();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=ka()});if(E){var F=getStrokedBBox();w.width=F.width+F.x;w.height=F.height+F.y}if(w.width<=0)w.width=100;if(w.height<=0)w.height=
100;H.attr(w);this.contentW=w.width;this.contentH=w.height;m.addSubCommand(new Ia(l));var f=H.attr(["width","height"]);m.addSubCommand(new Ja(d,f));p=1;svgedit.transformlist.resetListMap();Qa();svgedit.path.clearData();d.appendChild(Ga.selectorParentGroup);va(m);M("changed",[l])}catch(o){console.log(o);return false}return true};this.importSvgString=function(e){try{var k=svgedit.utilities.encode64(e.length+e).substr(0,32),m=false;if(qb[k])if($(qb[k].symbol).parents("#svgroot").length)m=true;var B=
new Ea("Import SVG");if(m)var z=qb[k].symbol,H=qb[k].xform;else{var C=svgedit.utilities.text2xml(e);this.prepareSvg(C);var w;w=g.adoptNode?g.adoptNode(C.documentElement):g.importNode(C.documentElement,true);Lb(w);var E=ua("width",w.getAttribute("width")),J=ua("height",w.getAttribute("height")),F=w.getAttribute("viewBox"),f=F?F.split(" "):[0,0,E,J];for(e=0;e<4;++e)f[e]=+f[e];l.getAttribute("width");var o=+l.getAttribute("height");H=J>E?"scale("+o/3/f[3]+")":"scale("+o/3/f[2]+")";H="translate(0) "+
H+" translate(0)";z=g.createElementNS(b,"symbol");var s=jb();for(svgedit.browser.isGecko()&&$(w).find("linearGradient, radialGradient, pattern").appendTo(s);w.firstChild;)z.appendChild(w.firstChild);var D=w.attributes;for(w=0;w<D.length;w++){var G=D[w];z.setAttribute(G.nodeName,G.nodeValue)}z.id=ka();qb[k]={symbol:z,xform:H};jb().appendChild(z);B.addSubCommand(new Ia(z))}var L=g.createElementNS(b,"use");L.id=ka();V(L,"#"+z.id);(K||A().getCurrentLayer()).appendChild(L);B.addSubCommand(new Ia(L));Qa();
L.setAttribute("transform",H);Sa(L);$(L).data("symbol",z).data("ref",z);sb([L]);va(B);M("changed",[l])}catch(W){console.log(W);return false}return true};var Bb=c.identifyLayers=function(){Hb();A().identifyLayers()};this.createLayer=function(e){var k=new Ea("Create Layer");e=A().createLayer(e);k.addSubCommand(new Ia(e));va(k);Qa();M("changed",[e])};this.cloneLayer=function(e){var k=new Ea("Duplicate Layer"),m=g.createElementNS(b,"g"),B=g.createElementNS(b,"title");B.textContent=e;m.appendChild(B);
B=A().getCurrentLayer();$(B).after(m);B=B.childNodes;for(var z=0;z<B.length;z++){var H=B[z];H.localName!="title"&&m.appendChild(ia(H))}Qa();Bb();k.addSubCommand(new Ia(m));va(k);c.setCurrentLayer(e);M("changed",[m])};this.deleteCurrentLayer=function(){var e=A().getCurrentLayer(),k=e.nextSibling,m=e.parentNode;if(e=A().deleteCurrentLayer()){var B=new Ea("Delete Layer");B.addSubCommand(new Ka(e,k,m));va(B);Qa();M("changed",[m]);return true}return false};this.setCurrentLayer=function(e){(e=A().setCurrentLayer(svgedit.utilities.toXml(e)))&&
Qa();return e};this.renameCurrentLayer=function(e){var k=A();if(k.current_layer){var m=k.current_layer;if(!c.setCurrentLayer(e)){for(var B=new Ea("Rename Layer"),z=0;z<k.getNumLayers();++z)if(k.all_layers[z][1]==m)break;var H=k.getLayerName(z);k.all_layers[z][0]=svgedit.utilities.toXml(e);var C=m.childNodes.length;for(z=0;z<C;++z){var w=m.childNodes.item(z);if(w&&w.tagName=="title"){for(;w.firstChild;)w.removeChild(w.firstChild);w.textContent=e;B.addSubCommand(new Ja(w,{"#text":H}));va(B);M("changed",
[m]);return true}}}k.current_layer=m}return false};this.setCurrentLayerPosition=function(e){var k=A();if(k.current_layer&&e>=0&&e<k.getNumLayers()){for(var m=0;m<k.getNumLayers();++m)if(k.all_layers[m][1]==k.current_layer)break;if(m==k.getNumLayers())return false;if(m!=e){var B=null,z=k.current_layer.nextSibling;if(e>m){if(e<k.getNumLayers()-1)B=k.all_layers[e+1][1]}else B=k.all_layers[e][1];l.insertBefore(k.current_layer,B);va(new Ba(k.current_layer,z,l));Bb();c.setCurrentLayer(k.getLayerName(e));
return true}}return false};this.setLayerVisibility=function(e,k){var m=A(),B=m.getLayerVisibility(e),z=m.setLayerVisibility(e,k);if(z)va(new Ja(z,{display:B?"inline":"none"},"Layer Visibility"));else return false;if(z==m.getCurrentLayer()){Qa();Ma.clear()}return true};this.moveSelectedToLayer=function(e){for(var k=null,m=A(),B=0;B<m.getNumLayers();++B)if(m.getLayerName(B)==e){k=m.all_layers[B][1];break}if(!k)return false;e=new Ea("Move Elements to Layer");m=I;for(B=m.length;B--;){var z=m[B];if(z){var H=
z.nextSibling,C=z.parentNode;k.appendChild(z);e.addSubCommand(new Ba(z,H,C))}}va(e);return true};this.mergeLayer=function(e){var k=new Ea("Merge Layer"),m=A(),B=$(m.current_layer).prev()[0];if(B){for(k.addSubCommand(new Ka(m.current_layer,m.current_layer.nextSibling,l));m.current_layer.firstChild;){var z=m.current_layer.firstChild;if(z.localName=="title"){k.addSubCommand(new Ka(z,z.nextSibling,m.current_layer));m.current_layer.removeChild(z)}else{var H=z.nextSibling;B.appendChild(z);k.addSubCommand(new Ba(z,
H,m.current_layer))}}l.removeChild(m.current_layer);if(!e){Qa();Bb();M("changed",[l]);va(k)}m.current_layer=B;return k}};this.mergeAllLayers=function(){var e=new Ea("Merge all Layers"),k=A();for(k.current_layer=k.all_layers[k.getNumLayers()-1][1];$(l).children("g").length>1;)e.addSubCommand(c.mergeLayer(true));Qa();Bb();M("changed",[l]);va(e)};var Hb=this.leaveContext=function(){var e=sa.length;if(e){for(var k=0;k<e;k++){var m=sa[k],B=fb(m,"orig_opac");B!==1?m.setAttribute("opacity",B):m.removeAttribute("opacity");
m.setAttribute("style","pointer-events: inherit")}sa=[];Qa(true);M("contextset",null)}K=null},Kb=this.setContext=function(e){Hb();if(typeof e==="string")e=qa(e);K=e;$(e).parentsUntil("#svgcontent").andSelf().siblings().each(function(){var k=this.getAttribute("opacity")||1;fb(this,"orig_opac",k);this.setAttribute("opacity",k*0.33);this.setAttribute("style","pointer-events: none");sa.push(this)});Qa();M("contextset",K)};this.clear=function(){Ma.clear();Qa();c.clearSvgContentElement();c.current_drawing_=
new svgedit.draw.Drawing(l);c.createLayer("Layer 1");c.undoMgr.resetUndoStack();Ga.initGroup();ra=Ga.getRubberBandBox();M("cleared")};this.linkControlPoints=Ma.linkControlPoints;this.getContentElem=function(){return l};this.getRootElem=function(){return d};this.getSelectedElems=function(){return I};var Ab=this.getResolution=function(){var e=l.getAttribute("width")/p,k=l.getAttribute("height")/p;return{w:e,h:k,zoom:p}};this.getZoom=function(){return p};this.getVersion=function(){return"svgcanvas.js ($Rev: 2082 $)"};
this.setUiStrings=function(e){$.extend(Ua,e.notification)};this.setConfig=function(e){$.extend(n,e)};this.getTitle=function(e){if(e=e||I[0]){e=$(e).data("gsvg")||$(e).data("symbol")||e;e=e.childNodes;for(var k=0;k<e.length;k++)if(e[k].nodeName=="title")return e[k].textContent;return""}};this.setGroupTitle=function(e){var k=I[0];k=$(k).data("gsvg")||k;var m=$(k).children("title"),B=new Ea("Set Label");if(e.length)if(m.length){m=m[0];B.addSubCommand(new Ja(m,{"#text":m.textContent}));m.textContent=
e}else{m=g.createElementNS(b,"title");m.textContent=e;$(k).prepend(m);B.addSubCommand(new Ia(m))}else{B.addSubCommand(new Ka(m[0],m.nextSibling,k));m.remove()}va(B)};this.getDocumentTitle=function(){return c.getTitle(l)};this.setDocumentTitle=function(e){for(var k=l.childNodes,m=false,B="",z=new Ea("Change Image Title"),H=0;H<k.length;H++)if(k[H].nodeName=="title"){m=k[H];B=m.textContent;break}if(!m){m=g.createElementNS(b,"title");l.insertBefore(m,l.firstChild)}if(e.length)m.textContent=e;else m.parentNode.removeChild(m);
z.addSubCommand(new Ja(m,{"#text":B}));va(z)};this.getEditorNS=function(e){e&&l.setAttribute("xmlns:se","http://svg-edit.googlecode.com");return"http://svg-edit.googlecode.com"};this.setResolution=function(e,k){var m=Ab(),B=m.w;m=m.h;var z;if(e=="fit"){var H=getStrokedBBox();if(H){z=new Ea("Fit Canvas to Content");var C=rb();sb(C);var w=[],E=[];$.each(C,function(){w.push(H.x*-1);E.push(H.y*-1)});C=c.moveSelectedElements(w,E,true);z.addSubCommand(C);Qa();e=Math.round(H.width);k=Math.round(H.height)}else return false}if(e!=
B||k!=m){C=d.suspendRedraw(1E3);z||(z=new Ea("Change Image Dimensions"));e=ua("width",e);k=ua("height",k);l.setAttribute("width",e);l.setAttribute("height",k);this.contentW=e;this.contentH=k;z.addSubCommand(new Ja(l,{width:B,height:m}));l.setAttribute("viewBox",[0,0,e/p,k/p].join(" "));z.addSubCommand(new Ja(l,{viewBox:["0 0",B,m].join(" ")}));va(z);d.unsuspendRedraw(C);if(background=document.getElementById("canvas_background")){background.setAttribute("x",-1);background.setAttribute("y",-1);background.setAttribute("width",
e+2);background.setAttribute("height",k+2)}M("changed",[l])}return[e,k]};this.getOffset=function(){return $(l).attr(["x","y"])};this.setBBoxZoom=function(e,k,m){var B=0.85,z=function(H){if(!H)return false;var C=Math.min(Math.round(k/H.width*100*B)/100,Math.round(m/H.height*100*B)/100);c.setZoom(C);return{zoom:C,bbox:H}};if(typeof e=="object"){e=e;if(e.width==0||e.height==0){c.setZoom(e.zoom?e.zoom:p*e.factor);return{zoom:p,bbox:e}}return z(e)}switch(e){case "selection":if(!I[0])return;e=$.map(I,function(H){if(H)return H});
e=getStrokedBBox(e);break;case "canvas":e=Ab();B=0.95;e={width:e.w,height:e.h,x:0,y:0};break;case "content":e=getStrokedBBox();break;case "layer":e=getStrokedBBox(rb(A().getCurrentLayer()));break;default:return}return z(e)};this.setZoom=function(e){var k=Ab();l.setAttribute("viewBox","0 0 "+k.w/e+" "+k.h/e);p=e;$.each(I,function(m,B){B&&Ga.requestSelector(B).resize()});Ma.zoomChange();lb("zoomChanged",e)};this.getMode=function(){return Da};this.setMode=function(e){Ma.clear(true);bb.clear();$("#workarea").attr("class",
e);Za=I[0]&&I[0].nodeName=="text"?Ya:O;Da=e};this.getColor=function(e){return Za[e]};this.setColor=function(e,k,m){O[e]=k;Za[e+"_paint"]={type:"solidColor"};for(var B=[],z=I.length;z--;){var H=I[z];if(H)if(H.tagName=="g")svgedit.utilities.walkTree(H,function(C){C.nodeName!="g"&&B.push(C)});else if(e=="fill")H.tagName!="polyline"&&H.tagName!="line"&&B.push(H);else B.push(H)}if(B.length>0)if(m)Cb(e,k,B);else{ib(e,k,B);M("changed",B)}};var jb=function(){var e=l.getElementsByTagNameNS(b,"defs");if(e.length>
0)e=e[0];else{e=g.createElementNS(b,"defs");l.firstChild?l.insertBefore(e,l.firstChild.nextSibling):l.appendChild(e)}return e},Jb=this.setGradient=function(e){if(!(!Za[e+"_paint"]||Za[e+"_paint"].type=="solidColor")){var k=c[e+"Grad"],m=Ib(k),B=jb();if(m)k=m;else{k=B.appendChild(g.importNode(k,true));k.id=ka()}c.setColor(e,"url(#"+k.id+")");if(e=="canvas")(e=document.getElementById("canvas_background"))&&e.setAttribute("fill","url(#"+k.id+")")}},Ib=function(e){var k=jb();k=$(k).find("linearGradient, radialGradient");
for(var m=k.length,B=["r","cx","cy","fx","fy"];m--;){var z=k[m];if(e.tagName=="linearGradient"){if(e.getAttribute("x1")!=z.getAttribute("x1")||e.getAttribute("y1")!=z.getAttribute("y1")||e.getAttribute("x2")!=z.getAttribute("x2")||e.getAttribute("y2")!=z.getAttribute("y2"))continue}else{var H=$(e).attr(B),C=$(z).attr(B),w=false;$.each(B,function(s,D){if(H[D]!=C[D])w=true});if(w)continue}var E=e.getElementsByTagNameNS(b,"stop"),J=z.getElementsByTagNameNS(b,"stop");if(E.length==J.length){for(var F=
E.length;F--;){var f=E[F],o=J[F];if(f.getAttribute("offset")!=o.getAttribute("offset")||f.getAttribute("stop-opacity")!=o.getAttribute("stop-opacity")||f.getAttribute("stop-color")!=o.getAttribute("stop-color"))break}if(F==-1)return z}}return null};this.setPaint=function(e,k){var m=new $.jGraduate.Paint(k);this.setPaintOpacity(e,m.alpha/100,true);Za[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":c[e+"Grad"]=m[m.type];Jb(e)}};this.getStrokeWidth=function(){return Za.stroke_width};this.setStrokeWidth=function(e){if(e==0&&["line","path"].indexOf(Da)>=0)c.setStrokeWidth(1);else{Za.stroke_width=e;for(var k=[],m=I.length;m--;){var B=I[m];if(B)B.tagName=="g"?svgedit.utilities.walkTree(B,function(z){z.nodeName!="g"&&k.push(z)}):k.push(B)}if(k.length>
0){ib("stroke-width",e,k);M("changed",I)}}};this.setStrokeAttr=function(e,k){O[e.replace("-","_")]=k;for(var m=[],B=I.length;B--;){var z=I[B];if(z)z.tagName=="g"?svgedit.utilities.walkTree(z,function(H){H.nodeName!="g"&&m.push(H)}):m.push(z)}if(m.length>0){ib(e,k,m);M("changed",I)}};this.getStyle=function(){return O};this.getOpacity=function(){return O.opacity};this.setOpacity=function(e){O.opacity=e;ib("opacity",e)};this.getFillOpacity=function(){return O.fill_opacity};this.getStrokeOpacity=function(){return O.stroke_opacity};
this.setPaintOpacity=function(e,k,m){O[e+"_opacity"]=k;m?Cb(e+"-opacity",k):ib(e+"-opacity",k)};this.getBlur=function(e){var k=0;if(e)if(e.getAttribute("filter"))if(e=qa(e.id+"_blur"))k=e.firstChild.getAttribute("stdDeviation");return k};(function(){function e(){var z=c.undoMgr.finishUndoableChange();k.addSubCommand(z);va(k);m=k=null}var k=null,m=null,B=false;c.setBlurNoUndo=function(z){if(m)if(z===0){Cb("filter","");B=true}else{var H=I[0];B&&Cb("filter","url(#"+H.id+"_blur)");if(svgedit.browser.isWebkit()){H.removeAttribute("filter");
H.setAttribute("filter","url(#"+H.id+"_blur)")}Cb("stdDeviation",z,[m.firstChild]);c.setBlurOffsets(m,z)}else c.setBlur(z)};c.setBlurOffsets=function(z,H){if(H>3)ma(z,{x:"-50%",y:"-50%",width:"200%",height:"200%"},100);else if(!svgedit.browser.isWebkit()){z.removeAttribute("x");z.removeAttribute("y");z.removeAttribute("width");z.removeAttribute("height")}};c.setBlur=function(z,H){if(k)e();else{var C=I[0],w=C.id;m=qa(w+"_blur");z-=0;var E=new Ea;if(m){if(z===0)m=null}else{var J=Q({element:"feGaussianBlur",
attr:{"in":"SourceGraphic",stdDeviation:z}});m=Q({element:"filter",attr:{id:w+"_blur"}});m.appendChild(J);jb().appendChild(m);E.addSubCommand(new Ia(m))}J={filter:C.getAttribute("filter")};if(z===0){C.removeAttribute("filter");E.addSubCommand(new Ja(C,J))}else{ib("filter","url(#"+w+"_blur)");E.addSubCommand(new Ja(C,J));c.setBlurOffsets(m,z);k=E;c.undoMgr.beginUndoableChange("stdDeviation",[m?m.firstChild:null]);if(H){c.setBlurNoUndo(z);e()}}}}})();this.getBold=function(){var e=I[0];if(e!=null&&e.tagName==
"text"&&I[1]==null)return e.getAttribute("font-weight")=="bold";return false};this.setBold=function(e){var k=I[0];if(k!=null&&k.tagName=="text"&&I[1]==null)ib("font-weight",e?"bold":"normal");I[0].textContent||bb.setCursor()};this.getItalic=function(){var e=I[0];if(e!=null&&e.tagName=="text"&&I[1]==null)return e.getAttribute("font-style")=="italic";return false};this.setItalic=function(e){var k=I[0];if(k!=null&&k.tagName=="text"&&I[1]==null)ib("font-style",e?"italic":"normal");I[0].textContent||bb.setCursor()};
this.getFontFamily=function(){return Ya.font_family};this.setFontFamily=function(e){Ya.font_family=e;ib("font-family",e);I[0]&&!I[0].textContent&&bb.setCursor()};this.setFontColor=function(e){Ya.fill=e;ib("fill",e)};this.getFontSize=function(){return Ya.fill};this.getFontSize=function(){return Ya.font_size};this.setFontSize=function(e){Ya.font_size=e;ib("font-size",e);I[0].textContent||bb.setCursor()};this.getText=function(){var e=I[0];if(e==null)return"";return e.textContent};this.setTextContent=
function(e){ib("#text",e);bb.init(e);bb.setCursor()};this.setImageURL=function(e){var k=I[0];if(k){var m=$(k).attr(["width","height"]);m=!m.width||!m.height;var B=da(k);if(B!==e)m=true;else if(!m)return;var z=new Ea("Change Image URL");V(k,e);z.addSubCommand(new Ja(k,{"#href":B}));m?$(new Image).load(function(){var H=$(k).attr(["width","height"]);$(k).attr({width:this.width,height:this.height});Ga.requestSelector(k).resize();z.addSubCommand(new Ja(k,H));va(z);M("changed",[k])}).attr("src",e):va(z)}};
this.setLinkURL=function(e){var k=I[0];if(k){if(k.tagName!=="a"){k=$(k).parents("a");if(k.length)k=k[0];else return}var m=da(k);if(m!==e){var B=new Ea("Change Link URL");V(k,e);B.addSubCommand(new Ja(k,{"#href":m}));va(B)}}};this.elementsAreSame=function(e){return!e.length||e[0]==null?null:I.every(function(k){return k&&I[0]?k.nodeName==I[0].nodeName:null})};this.setRectRadius=function(e){c.elementsAreSame(I)&&I[0].tagName=="rect"&&I.forEach(function(k){var m=k.getAttribute("rx");if(m!=e){k.setAttribute("rx",
e);k.setAttribute("ry",e);va(new Ja(k,{rx:m,ry:m},"Radius"));M("changed",[k])}})};this.makeHyperlink=function(e){c.groupSelectedElements("a",e)};this.removeHyperlink=function(){c.ungroupSelectedElement()};this.setSegType=function(e){Ma.setSegType(e)};this.convertToPath=function(e,k){if(e==null)$.each(I,function(ba,S){S&&c.convertToPath(S)});else{if(!k)var m=new Ea("Convert element to Path");var B=k?{}:{fill:O.fill,"fill-opacity":O.fill_opacity,stroke:O.stroke,"stroke-width":O.stroke_width,"stroke-dasharray":O.stroke_dasharray,
"stroke-linejoin":O.stroke_linejoin,"stroke-linecap":O.stroke_linecap,"stroke-opacity":O.stroke_opacity,opacity:O.opacity,visibility:"hidden"};$.each(["marker-start","marker-end","marker-mid","filter","clip-path"],function(){if(e.getAttribute(this))B[this]=e.getAttribute(this)});var z=Q({element:"path",attr:B}),H=e.getAttribute("transform");H&&z.setAttribute("transform",H);var C=e.id,w=e.parentNode;e.nextSibling?w.insertBefore(z,e):w.appendChild(z);var E="",J=function(ba){$.each(ba,function(S,Y){var aa=
Y[1];E+=Y[0];for(var na=0;na<aa.length;na+=2)E+=aa[na]+","+aa[na+1]+" "})},F=1.81;switch(e.tagName){case "ellipse":case "circle":var f=$(e).attr(["rx","ry","cx","cy"]),o=f.cx,s=f.cy,D=f.rx;f=f.ry;if(e.tagName=="circle")D=f=$(e).attr("r");J([["M",[o-D,s]],["C",[o-D,s-f/F,o-D/F,s-f,o,s-f]],["C",[o+D/F,s-f,o+D,s-f/F,o+D,s]],["C",[o+D,s+f/F,o+D/F,s+f,o,s+f]],["C",[o-D/F,s+f,o-D,s+f/F,o-D,s]],["Z",[]]]);break;case "path":E=e.getAttribute("d");break;case "line":f=$(e).attr(["x1","y1","x2","y2"]);E="M"+
f.x1+","+f.y1+"L"+f.x2+","+f.y2;break;case "polyline":case "polygon":E="M"+e.getAttribute("points");break;case "rect":f=$(e).attr(["rx","ry"]);D=f.rx;f=f.ry;var G=e.getBBox();o=G.x;s=G.y;var L=G.width;G=G.height;F=4-F;if(!D&&!f)J([["M",[o,s]],["L",[o+L,s]],["L",[o+L,s+G]],["L",[o,s+G]],["L",[o,s]],["Z",[]]]);else{f||(f=D);J([["M",[o,s+f]],["C",[o,s+f/F,o+D/F,s,o+D,s]],["L",[o+L-D,s]],["C",[o+L-D/F,s,o+L,s+f/F,o+L,s+f]],["L",[o+L,s+G-f]],["C",[o+L,s+G-f/F,o+L-D/F,s+G,o+L-D,s+G]],["L",[o+D,s+G]],["C",
[o+D/F,s+G,o,s+G-f/F,o,s+G-f]],["L",[o,s+f]],["Z",[]]])}break;default:z.parentNode.removeChild(z)}E&&z.setAttribute("d",E);if(k){Ma.resetOrientation(z);m=false;try{m=z.getBBox()}catch(W){}z.parentNode.removeChild(z);return m}else{if(H){H=U(z);pa(H)&&Ma.resetOrientation(z)}m.addSubCommand(new Ka(e,e.nextSibling,w));m.addSubCommand(new Ia(z));Qa();e.parentNode.removeChild(e);z.setAttribute("id",C);z.removeAttribute("visibility");sb([z],true);va(m)}}};var Cb=this.changeSelectedAttributeNoUndo=function(e,
k,m){var B=d.suspendRedraw(1E3);Da=="pathedit"&&Ma.moveNode(e,k);m=m||I;for(var z=m.length,H=["g","polyline","path"];z--;){var C=m[z];if(C!=null){Da==="textedit"&&e!=="#text"&&C.textContent.length&&bb.toSelectMode(C);if((e==="x"||e==="y")&&H.indexOf(C.tagName)>=0){var w=getStrokedBBox([C]);c.moveSelectedElements((e==="x"?k-w.x:0)*p,(e==="y"?k-w.y:0)*p,true)}else{w=e==="#text"?C.textContent:C.getAttribute(e);if(w==null)w="";if(w!==String(k)){if(e=="#text"){svgedit.utilities.getBBox(C);C.textContent=
k}else e=="#href"?V(C,k):C.setAttribute(e,k);I.indexOf(C)>=0&&setTimeout(function(){C.parentNode&&Ga.requestSelector(C).resize()},0);w=oa(C);if(w!=0&&e!="transform")for(var E=U(C),J=E.numberOfItems;J--;)if(E.getItem(J).type==4){E.removeItem(J);var F=svgedit.utilities.getBBox(C),f=N(F.x+F.width/2,F.y+F.height/2,fa(E).matrix);F=f.x;f=f.y;var o=d.createSVGTransform();o.setRotate(w,F,f);E.insertItemBefore(o,J);break}}}}}d.unsuspendRedraw(B)},ib=this.changeSelectedAttribute=function(e,k,m){m=m||I;c.undoMgr.beginUndoableChange(e,
m);Cb(e,k,m);e=c.undoMgr.finishUndoableChange();e.isEmpty()||va(e)};this.deleteSelectedElements=function(){for(var e=new Ea("Delete Elements"),k=I.length,m=[],B=0;B<k;++B){var z=I[B];if(z==null)break;var H=z.parentNode,C=z;Ga.releaseSelector(C);svgedit.path.removePath_(C.id);if(H.tagName==="a"&&H.childNodes.length===1){C=H;H=H.parentNode}var w=C.nextSibling;C=H.removeChild(C);m.push(z);I[B]=null;e.addSubCommand(new Ka(C,w,H))}e.isEmpty()||va(e);M("changed",m);Qa()};this.cutSelectedElements=function(){for(var e=
new Ea("Cut Elements"),k=I.length,m=[],B=0;B<k;++B){var z=I[B];if(z==null)break;var H=z.parentNode,C=z;Ga.releaseSelector(C);svgedit.path.removePath_(C.id);var w=C.nextSibling;C=H.removeChild(C);m.push(z);I[B]=null;e.addSubCommand(new Ka(C,w,H))}e.isEmpty()||va(e);M("changed",m);Qa();c.clipBoard=m};this.copySelectedElements=function(){c.clipBoard=$.merge([],I)};this.pasteElements=function(){var e=c.clipBoard,k=e.length;if(k){for(var m=[],B=new Ea("Paste elements");k--;){var z=e[k];if(z){var H=ia(z);
if(!qa(z.id))H.id=z.id;m.push(H);(K||A().getCurrentLayer()).appendChild(H);B.addSubCommand(new Ia(H))}}svgCanvas.clearSelection();setTimeout(function(){ab(m)},100);va(B);M("changed",m)}};this.groupSelectedElements=function(e){e||(e="g");var k="";switch(e){case "a":k="Make hyperlink";var m="";if(arguments.length>1)m=arguments[1];break;default:e="g";k="Group Elements"}k=new Ea(k);var B=Q({element:e,attr:{id:ka()}});e==="a"&&V(B,m);k.addSubCommand(new Ia(B));for(m=I.length;m--;){var z=I[m];if(z!=null){if(z.parentNode.tagName===
"a"&&z.parentNode.childNodes.length===1)z=z.parentNode;var H=z.nextSibling,C=z.parentNode;B.appendChild(z);k.addSubCommand(new Ba(z,H,C))}}k.isEmpty()||va(k);ab([B],true)};var Gb=this.pushGroupProperties=function(e,k){var m=e.childNodes,B=m.length,z=e.getAttribute("transform"),H=U(e),C=fa(H).matrix,w=new Ea("Push group properties"),E=0,J=oa(e),F=$(e).attr(["filter","opacity"]),f,o;for(E=0;E<B;E++){var s=m[E];if(s.nodeType===1){if(F.opacity!==null&&F.opacity!==1){s.getAttribute("opacity");var D=Math.round((s.getAttribute("opacity")||
1)*F.opacity*100)/100;ib("opacity",D,[s])}if(F.filter){var G=D=this.getBlur(s);o||(o=this.getBlur(e));if(D)D=o-0+(D-0);else if(D===0)D=o;if(G)f=P(s.getAttribute("filter"));else if(f){f=ia(f);jb().appendChild(f)}else f=P(F.filter);f.id=s.id+"_"+(f.firstChild.tagName==="feGaussianBlur"?"blur":"filter");ib("filter","url(#"+f.id+")",[s]);if(D){ib("stdDeviation",D,[f.firstChild]);c.setBlurOffsets(f,D)}}D=U(s);if(~s.tagName.indexOf("Gradient"))D=null;if(D)if(s.tagName!=="defs")if(H.numberOfItems){if(J&&
H.numberOfItems==1){var L=H.getItem(0).matrix,W=d.createSVGMatrix();if(G=oa(s))W=D.getItem(0).matrix;var ba=svgedit.utilities.getBBox(s),S=fa(D).matrix,Y=N(ba.x+ba.width/2,ba.y+ba.height/2,S);ba=J+G;S=d.createSVGTransform();S.setRotate(ba,Y.x,Y.y);L=ha(L,W,S.matrix.inverse());G&&D.removeItem(0);if(ba)D.numberOfItems?D.insertItemBefore(S,0):D.appendItem(S);if(L.e||L.f){G=d.createSVGTransform();G.setTranslate(L.e,L.f);D.numberOfItems?D.insertItemBefore(G,0):D.appendItem(G)}}else{G=s.getAttribute("transform");
L={};L.transform=G?G:"";G=d.createSVGTransform();L=fa(D).matrix;W=L.inverse();L=ha(W,C,L);G.setMatrix(L);D.appendItem(G)}(s=Sa(s))&&w.addSubCommand(s)}}}if(z){L={};L.transform=z;e.setAttribute("transform","");e.removeAttribute("transform");w.addSubCommand(new Ja(e,L))}if(k&&!w.isEmpty())return w};this.ungroupSelectedElement=function(){var e=I[0];if($(e).data("gsvg")||$(e).data("symbol"))Pb(e);else if(e.tagName==="use"){var k=qa(da(e).substr(1));$(e).data("symbol",k).data("ref",k);Pb(e)}else{k=$(e).parents("a");
if(k.length)e=k[0];if(e.tagName==="g"||e.tagName==="a"){k=new Ea("Ungroup Elements");var m=Gb(e,true);m&&k.addSubCommand(m);m=e.parentNode;for(var B=e.nextSibling,z=Array(e.childNodes.length),H=0;e.firstChild;){var C=e.firstChild,w=C.nextSibling,E=C.parentNode;if(C.tagName==="title"){k.addSubCommand(new Ka(C,C.nextSibling,E));E.removeChild(C)}else{z[H++]=C=m.insertBefore(C,B);k.addSubCommand(new Ba(C,w,E))}}Qa();B=e.nextSibling;e=m.removeChild(e);k.addSubCommand(new Ka(e,B,m));k.isEmpty()||va(k);
sb(z)}}};this.moveToTopSelectedElement=function(){var e=I[0];if(e!=null){e=e;var k=e.parentNode,m=e.nextSibling;e=e.parentNode.appendChild(e);if(m!=e.nextSibling){va(new Ba(e,m,k,"top"));M("changed",[e])}}};this.moveToBottomSelectedElement=function(){var e=I[0];if(e!=null){e=e;var k=e.parentNode,m=e.nextSibling,B=e.parentNode.firstChild;if(B.tagName=="title")B=B.nextSibling;if(B.tagName=="defs")B=B.nextSibling;e=e.parentNode.insertBefore(e,B);if(m!=e.nextSibling){va(new Ba(e,m,k,"bottom"));M("changed",
[e])}}};this.moveUpDownSelected=function(e){var k=I[0];if(k){kb=[];var m,B,z=$(nb(getStrokedBBox([k]))).toArray();e=="Down"&&z.reverse();$.each(z,function(){if(B){m=this;return false}else if(this==k)B=true});if(m){z=k.parentNode;var H=k.nextSibling;$(m)[e=="Down"?"before":"after"](k);if(H!=k.nextSibling){va(new Ba(k,H,z,"Move "+e));M("changed",[k])}}}};this.moveSelectedElements=function(e,k,m){if(e.constructor!=Array){e/=p;k/=p}m=m||true;for(var B=new Ea("position"),z=I.length;z--;){var H=I[z];if(H!=
null){var C=d.createSVGTransform(),w=U(H);e.constructor==Array?C.setTranslate(e[z],k[z]):C.setTranslate(e,k);w.numberOfItems?w.insertItemBefore(C,0):w.appendItem(C);(C=Sa(H))&&B.addSubCommand(C);Ga.requestSelector(H).resize()}}if(!B.isEmpty()){m&&va(B);M("changed",I);return B}};this.cloneSelectedElements=function(e,k,m){for(var B=new Ea("Clone Elements"),z=I.length,H=0;H<z;++H)if(I[H]==null)break;z=I.slice(0,H);this.clearSelection(true);H=z.length;for(clones=[];H--;){var C=ia(z[H]);if(m){tlist=U(C);
tlist.removeItem(m);Sa(C)}(K||A().getCurrentLayer()).appendChild(C);clones.push(C);B.addSubCommand(new Ia(C))}if(!B.isEmpty()){sb(z.reverse());m||this.moveSelectedElements(e,k,false);va(B)}return clones};this.alignSelectedElements=function(e,k){var m=[],B=Number.MAX_VALUE,z=Number.MIN_VALUE,H=Number.MAX_VALUE,C=Number.MIN_VALUE,w=Number.MIN_VALUE,E=Number.MIN_VALUE,J=I.length;if(J){for(var F=0;F<J;++F){if(I[F]==null)break;m[F]=getStrokedBBox([I[F]]);switch(k){case "smallest":if((e=="l"||e=="c"||e==
"r")&&(w==Number.MIN_VALUE||w>m[F].width)||(e=="t"||e=="m"||e=="b")&&(E==Number.MIN_VALUE||E>m[F].height)){B=m[F].x;H=m[F].y;z=m[F].x+m[F].width;C=m[F].y+m[F].height;w=m[F].width;E=m[F].height}break;case "largest":if((e=="l"||e=="c"||e=="r")&&(w==Number.MIN_VALUE||w<m[F].width)||(e=="t"||e=="m"||e=="b")&&(E==Number.MIN_VALUE||E<m[F].height)){B=m[F].x;H=m[F].y;z=m[F].x+m[F].width;C=m[F].y+m[F].height;w=m[F].width;E=m[F].height}break;default:if(m[F].x<B)B=m[F].x;if(m[F].y<H)H=m[F].y;if(m[F].x+m[F].width>
z)z=m[F].x+m[F].width;if(m[F].y+m[F].height>C)C=m[F].y+m[F].height}}if(k=="page"){H=B=0;z=c.contentW;C=c.contentH}w=Array(J);E=Array(J);for(F=0;F<J;++F){if(I[F]==null)break;var f=m[F];w[F]=0;E[F]=0;switch(e){case "l":w[F]=B-f.x;break;case "c":w[F]=(B+z)/2-(f.x+f.width/2);break;case "r":w[F]=z-(f.x+f.width);break;case "t":E[F]=H-f.y;break;case "m":E[F]=(H+C)/2-(f.y+f.height/2);break;case "b":E[F]=C-(f.y+f.height)}}this.moveSelectedElements(w,E)}};this.contentW=Ab().w;this.contentH=Ab().h;this.updateCanvas=
function(e,k){d.setAttribute("width",e);d.setAttribute("height",k);var m=$("#canvasBackground")[0],B=l.getAttribute("x"),z=l.getAttribute("y"),H=e/2-this.contentW*p/2,C=k/2-this.contentH*p/2;ma(l,{width:this.contentW*p,height:this.contentH*p,x:H,y:C,viewBox:"0 0 "+this.contentW+" "+this.contentH});ma(m,{width:l.getAttribute("width"),height:l.getAttribute("height"),x:H,y:C});(m=qa("background_image"))&&ma(m,{width:"100%",height:"100%"});Ga.selectorParentGroup.setAttribute("transform","translate("+
H+","+C+")");return{x:H,y:C,old_x:B,old_y:z,d_x:H-B,d_y:C-z}};this.setBackground=function(e,k){var m=qa("canvasBackground"),B=$(m).find("rect")[0],z=qa("background_image");B.setAttribute("fill",e);if(k){if(!z){z=g.createElementNS(b,"image");ma(z,{id:"background_image",width:"100%",height:"100%",preserveAspectRatio:"xMinYMin",style:"pointer-events:none"})}V(z,k);m.appendChild(z)}else z&&z.parentNode.removeChild(z)};this.cycleElement=function(e){var k=I[0],m=false,B=rb(K||A().getCurrentLayer());if(B.length){if(k==
null){e=e?B.length-1:0;m=B[e]}else for(var z=B.length;z--;)if(B[z]==k){e=e?z-1:z+1;if(e>=B.length)e=0;else if(e<0)e=B.length-1;m=B[e];break}ab([m],true);M("selected",I)}};this.clear();this.getPrivateMethods=function(){return{addCommandToHistory:va,setGradient:Jb,addSvgElementFromJson:Q,assignAttributes:ma,BatchCommand:Ea,call:M,ChangeElementCommand:Ja,copyElem:ia,ffClone:ea,findDefs:jb,findDuplicateGradient:Ib,getElem:qa,getId:ca,getIntersectionList:nb,getMouseTarget:Fb,getNextId:ka,getPathBBox:X,
getUrlFromAttr:ja,hasMatrixTransform:pa,identifyLayers:Bb,InsertElementCommand:Ia,isIdentity:svgedit.math.isIdentity,logMatrix:Ra,matrixMultiply:ha,MoveElementCommand:Ba,preventClickDefault:Eb,recalculateAllSelectedDimensions:Fa,recalculateDimensions:Sa,remapElement:cb,RemoveElementCommand:Ka,removeUnusedDefElems:Ob,round:eb,runExtensions:lb,sanitizeSvg:Ha,SVGEditTransformList:svgedit.transformlist.SVGTransformList,toString:toString,transformBox:svgedit.math.transformBox,transformListToTransform:fa,
transformPoint:N,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 q(d,l){var v=h.setSvgString(d)!==false;l=l||a.noop;v?l(true):a.alert(uiStrings.notification.errorLoadingSVG,function(){l(false)})}var h,b={},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=b.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:"<strong>Do you want to clear the drawing?</strong>\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 u={},c={};b.curConfig=curConfig;b.tool_scale=1;b.setConfig=function(d){a.extend(true,curConfig,d);if(d.extensions)curConfig.extensions=d.extensions};
b.setCustomHandlers=function(d){b.ready(function(){if(d.open){a('#tool_open > input[type="file"]').remove();a("#tool_open").show();h.open=d.open}if(d.save){b.show_save_warning=false;h.bind("saved",d.save)}d.pngsave&&h.bind("exported",d.pngsave);c=d})};b.randomizeIds=function(){h.randomizeIds(arguments)};b.init=function(){function d(f,o){var s=f.id,D=s.split("_"),G=D[0];D=D[1];o&&h.setStrokeAttr("stroke-"+G,D);ta();Jb("#cur_"+G,s,20);a(f).addClass("current").siblings().removeClass("current")}(function(){var f=
window.opener;if(f)try{var o=f.document.createEvent("Event");o.initEvent("svgEditorReady",true,true);f.document.documentElement.dispatchEvent(o)}catch(s){}})();(function(){a("body").toggleClass("touch",svgedit.browser.isTouch());var f=a.deparam.querystring(true);if(!a.isEmptyObject(f)){if(f.dimensions)f.dimensions=f.dimensions.split(",");if(f.extensions)f.extensions=f.extensions.split(",");if(f.bkgd_color)f.bkgd_color="#"+f.bkgd_color;svgEditor.setConfig(f);var o=f.source,s=a.param.querystring();
if(!o)if(s.indexOf("source=data:")>=0)o=s.match(/source=(data:[^&]*)/)[1];if(o)if(o.indexOf("data:")===0){o=o.replace(/ /g,"+");b.loadFromDataURI(o)}else b.loadFromString(o);else if(s.indexOf("paramurl=")!==-1)svgEditor.loadFromURL(s.substr(9));else f.url&&svgEditor.loadFromURL(f.url)}})();a("#canvas_width").val(curConfig.dimensions[0]);a("#canvas_height").val(curConfig.dimensions[1]);var l=function(){a.each(curConfig.extensions,function(){var f=this;a.getScript(curConfig.extPath+f,function(o){if(!o){o=
document.createElement("script");o.src=curConfig.extPath+f;document.querySelector("head").appendChild(o)}})})};document.location.protocol==="file:"?setTimeout(l,100):l();a.svgIcons(curConfig.imgPath+"svg_edit_icons.svg",{w:27,h:27,id_match:false,no_img:true,fallback_path:curConfig.imgPath,fallback:{logo:"logo.png",select:"select.png",select_node:"select_node.png",pencil:"pencil.png",pen:"line.png",rect:"square.png",ellipse:"ellipse.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_ellipse,#tools_ellipse_show":"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 f=a("#tools_left");if(f.length!=0){f.offset();f.outerHeight()}a(".tools_flyout").each(function(){var o=a("#"+this.id+"_show"),s=o.attr("data-curopt");if(!o.children("svg, img").length){s=a(s).children().clone();if(s.length){s[0].removeAttribute("style");o.append(s)}}});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(f){a("#base_unit_container").css({top:f.pageY-
10,left:f.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()});b.canvas=h=new a.SvgCanvas(document.getElementById("svgcanvas"),curConfig);b.show_save_warning=false;b.paintBox={fill:null,stroke:null,canvas:null};l=navigator.platform.indexOf("Mac")>=0;var v=navigator.userAgent.indexOf("AppleWebKit")>=
0,A=l?"meta+":"ctrl+",p=h.pathActions,K=h.undoMgr,R=svgedit.utilities,O=curConfig.imgPath+"placeholder.svg",I=a("#workarea"),Q=a("#cmenu_canvas"),U=null,N=1,ha="toolbars",pa="";l||a(".shortcut").each(function(){var f=a(this).text();a(this).text(f.split("\u2318").join("Ctrl+"))});(function(){a("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"});var f=a("#dialog_box"),o=a("#dialog_buttons"),s=function(D,G,L,W){a("#dialog_content").html("<p>"+G.replace(/\n/g,
"</p><p>")+"</p>").toggleClass("prompt",D=="prompt");o.empty();var ba=a('<input type="button" value="'+uiStrings.common.ok+'">').appendTo(o);D!="alert"&&a('<input type="button" value="'+uiStrings.common.cancel+'">').appendTo(o).on("click touchstart",function(){f.hide();L(false)});if(D=="prompt"){var S=a('<input type="text">').prependTo(o);S.val(W||"");S.bind("keydown","return",function(){ba.trigger("click touchstart")})}D=="process"&&ba.hide();f.show();ba.on("click touchstart",function(){f.hide();
var Y=D=="prompt"?S.val():true;L&&L(Y)}).focus();D=="prompt"&&S.focus()};a.alert=function(D,G){s("alert",D,G)};a.confirm=function(D,G){s("confirm",D,G)};a.process_cancel=function(D,G){s("process",D,G)};a.prompt=function(D,G,L){s("prompt",D,L,G)}})();var fa=function(){var f=a(".tool_button_current");if(f.length&&f[0].id!=="tool_select"){f.removeClass("tool_button_current").addClass("tool_button");a("#tool_select").addClass("tool_button_current").removeClass("tool_button")}h.setMode("select")},T=null,
Z=false,ua=false,ja="",da=function(f,o){var s=h.getResolution(),D=I;a("#svgcanvas").position();if(D=h.setBBoxZoom(o,D.width()-15,D.height()-15)){var G=D.zoom;D=D.bbox;if(G<0.0010)Ga({value:0.1});else{typeof animatedZoom!="undefined"&&f.cancelAnimationFrame(animatedZoom);var L=Date.now(),W=G-s.zoom;a("#zoom");var ba=s.zoom,S=function(Y){Y=(Y-L)/500;Y=Math.pow(Y-1,3)+1;h.setZoom(ba+W*Y);w();if(Y<1)f.animatedZoom=requestAnimationFrame(S);else{a("#zoom").val(parseInt(G*100));a("option","#zoom_select").removeAttr("selected");
a("option[value="+parseInt(G*100)+"]","#zoom_select").attr("selected","selected")}};S(Date.now());h.getMode()=="zoom"&&D.width&&fa();Kb()}}};a("#cur_context_panel").delegate("a","click",function(){var f=a(this);f.attr("data-root")?h.leaveContext():h.setContext(f.text());return false});var V=function(){b.paintBox.fill.prep();b.paintBox.stroke.prep()},X={},oa=function(f){a.each(f,function(o,s){var D=a(o).children(),G=o+"_show",L=a(G),W=false;D.addClass("tool_button").unbind("click mousedown mouseup").each(function(Y){var aa=
s[Y];X[aa.sel]=aa.fn;if(aa.isDefault)W=Y;Y=function(na){var za=aa;if(na.type==="keydown"){var ga=a(za.parent+"_show").hasClass("tool_button_current"),Aa=a(za.parent+"_show").attr("data-curopt");a.each(f[aa.parent],function(ya,Na){if(Na.sel==Aa)za=!na.shiftKey||!ga?Na:f[aa.parent][ya+1]||f[aa.parent][0]})}if(a(this).hasClass("disabled"))return false;Ua(G)&&za.fn();var xa=za.icon?a.getSvgIcon(za.icon,true):a(za.sel).children().eq(0).clone();xa[0].setAttribute("width",L.width());xa[0].setAttribute("height",
L.height());L.children(":not(.flyout_arrow_horiz)").remove();L.append(xa).attr("data-curopt",za.sel)};a(this).mouseup(Y);aa.key&&a(document).bind("keydown",aa.key[0]+" shift+"+aa.key[0],Y)});if(W)L.attr("data-curopt",s[W].sel);else L.attr("data-curopt")||L.attr("data-curopt",s[0].sel);var ba,S=a(G).position();a(o).css({left:S.left+34,top:S.top+77});L.mousedown(function(Y){a("#workarea").one("mousedown",function(){a("#tools_shapelib").hide()});a("#tools_shapelib").is(":visible")&&Ua(G,false);if(L.hasClass("disabled"))return false;
var aa=a(o),na=S.left+34,za=aa.width()*-1,ga=aa.data("shown_popop")?200:0;ba=setTimeout(function(){L.data("isLibrary")?aa.css("left",na).show():aa.css("left",za).show().animate({left:na},50);aa.data("shown_popop",true)},ga);Y.preventDefault()}).mouseup(function(){clearTimeout(ba);var Y=a(this).attr("data-curopt");if(L.data("isLibrary")&&a(G.replace("_show","")).is(":visible"))Ua(G,true);else Ua(G)&&Y in X&&X[Y]()})});la()},qa=function(f,o){return a("<div>",{"class":"tools_flyout",id:f}).appendTo("#svg_editor").append(o)},
ma=function(){a(".tools_flyout").each(function(){var f=a("#"+this.id+"_show"),o=f.offset();f=f.outerWidth();a(this).css({left:(o.left+f)*N,top:o.top})})},la=function(){a(".tools_flyout").each(function(){var f=a("#"+this.id+"_show");if(!f.data("isLibrary")){var o=[];a(this).children().each(function(){o.push(this.title)});f[0].title=o.join(" / ")}})},wa,Ha=function(f,o,s){var D=null;if(f.indexOf("url(#")===0){f=(f=h.getRefElem(f))?f.cloneNode(true):a("#"+s+"_color defs *")[0];D={alpha:o};D[f.tagName]=
f}else D=f.indexOf("#")===0?{alpha:o,solidColor:f.substr(1)}:{alpha:o,solidColor:"none"};return new a.jGraduate.Paint(D)},Ba=h.getResolution();if(curConfig.baseUnit!=="px"){Ba.w=svgedit.units.convertUnit(Ba.w)+curConfig.baseUnit;Ba.h=svgedit.units.convertUnit(Ba.h)+curConfig.baseUnit}var Ia=function(f){h.createLayer("background");cur_shape=h.addSvgElementFromJson({element:"rect",attr:{x:-1,y:-1,width:Ba.w+2,height:Ba.h+2,stroke:"none",id:"canvas_background",opacity:1,fill:f||"#fff",style:"pointer-events:none"}});
h.setCurrentLayer("Layer 1");h.setCurrentLayerPosition("1")};document.getElementById("canvas_background")||Ia();document.getElementById("canvas_background").getAttribute("fill");var Ka=b.setImageURL=function(f){f||(f=O);h.setImageURL(f);a("#image_url").val(f)},Ja=function(){var f=T;if(f!=null&&!f.parentNode)f=null;if(Z&&Z[0]!=null&&!Z[0].parentNode)Z=false;var o=h.getCurrentDrawing().getCurrentLayerName(),s=h.getMode(),D=curConfig.baseUnit!=="px"?curConfig.baseUnit:null,G=s=="pathedit";if(G){a(".context_panel").hide();
a("#path_node_panel").show();a("#stroke_panel").hide();o=p.getNodePoint();a("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button");a("#tool_node_delete").toggleClass("disabled",!p.canDeleteNodes);Jb("#tool_openclose_path",p.closed_subpath?"open_path":"close_path");if(o){G=a("#seg_type");if(D){o.x=svgedit.units.convertUnit(o.x);o.y=svgedit.units.convertUnit(o.y)}a("#path_node_x").val(Math.round(o.x));a("#path_node_y").val(Math.round(o.y));if(o.type){G.val(o.type).removeAttr("disabled");
a("#seg_type_label").html(o.type==4?"Straight":"Curve")}else G.val(4).attr("disabled","disabled")}a("#tools_top").removeClass("multiselected");a("#stroke_panel").hide();a("#canvas_panel").hide()}else{var L=a("#cmenu_canvas li");a(".context_panel").hide();a(".menu_item","#edit_menu").addClass("disabled");a(".menu_item","#object_menu").addClass("disabled");if(Z){Z=Z.filter(Boolean);(f=h.elementsAreSame(Z)?Z[0]:null)&&a("#tools_top").addClass("multiselected")}if(!f&&!Z){a("#tools_top").removeClass("multiselected");
a("#stroke_panel").hide();a("#canvas_panel").show()}if(f!=null){a("#stroke_panel").show();var W=f.nodeName,ba=h.getRotationAngle(f);a("#angle").val(Math.round(ba));ba=h.getBlur(f);a("#blur").val(ba);if(!G&&s!="pathedit"){a("#selected_panel").show();a(".action_selected").removeClass("disabled");var S,Y;if(["g","polyline","path"].indexOf(W)>=0)if(s=h.getStrokedBBox([f])){S=s.x;Y=s.y}if(D){S=svgedit.units.convertUnit(S);Y=svgedit.units.convertUnit(Y)}a("#"+W+"_x").val(Math.round(S));a("#"+W+"_y").val(Math.round(Y));
if(W==="polyline"){a("#path_x").val(Math.round(S));a("#path_y").val(Math.round(Y))}["image","text","path","g","use"].indexOf(W)==-1&&a(".action_path_convert_selected").removeClass("disabled");W==="path"&&a(".action_path_selected").removeClass("disabled")}D=null;if(aa==="a"){D=h.getHref(f);a("#g_panel").show()}if(f.parentNode.tagName==="a")if(!a(f).siblings().length){a("#a_panel").show();D=h.getHref(f.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 aa=f.tagName;a(f).data("gsvg")&&a("#g_panel").show();if(aa=="path"||aa=="polyline")a("#path_panel").show();if(D[aa]){D=D[aa];a("#"+aa+"_panel").show();aa=="rect"?a("#cornerRadiusLabel").show():a("#cornerRadiusLabel").hide();a.each(D,function(na,za){var ga=f.getAttribute(za);if(curConfig.baseUnit!=="px"&&f[za])ga=svgedit.units.convertUnit(f[za].baseVal.value);
var Aa=document.getElementById(aa+"_"+za);Aa.value=Math.round(ga)||0;Aa.getAttribute("data-cursor")==="true"&&a.fn.dragInput.updateCursor(Aa)});if(aa=="text"){D=f.getAttribute("font-family");document.getElementById("font_family_dropdown").selectedIndex=3;a("#text_panel").css("display","inline");a("#tool_italic").toggleClass("active",h.getItalic());a("#tool_bold").toggleClass("active",h.getBold());a("#font_family").val(D);a("#font_size").val(f.getAttribute("font-size"));a("#text").val(f.textContent);
a("#preview_font").text(D.split(",")[0].replace(/'/g,"")).css("font-family",D);h.addedNew&&setTimeout(function(){a("#text").focus().select()},100)}else if(aa=="image")Ka(h.getHref(f));else if(aa==="g"||aa==="use"){a("#container_panel").show();a(".action_group_selected").removeClass("disabled");h.getTitle()}}L[(aa==="g"?"en":"dis")+"ableContextMenuItems"]("#ungroup");L[(aa==="g"||!Z?"dis":"en")+"ableContextMenuItems"]("#group")}if(Z){a("#multiselected_panel").show();a(".action_multi_selected").removeClass("disabled");
L.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")}f||L.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");K.getUndoStackSize()>0?a("#tool_undo").removeClass("disabled"):a("#tool_undo").addClass("disabled");K.getRedoStackSize()>0?a("#tool_redo").removeClass("disabled"):a("#tool_redo").addClass("disabled");h.addedNew=false;if(f&&!G||Z){a("#selLayerNames").removeAttr("disabled").val(o);Q.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}}};
a("#text").on("focus",function(){});a("#text").on("blur",function(){});h.bind("selected",function(f,o){var s=h.getMode();s==="select"&&fa();if(s==="pathedit")return Ja();T=o.length==1||o[1]==null?o[0]:null;o=o.filter(Boolean);Z=o.length>=2?o:false;if(h.elementsAreSame(Z))T=Z[0];if(T!=null){a("#multiselected_panel").hide();if(T!=null)switch(T.tagName){case "use":a(".context_panel").hide();a("#use_panel").show();break;case "image":a(".context_panel").hide();a("#image_panel").show();break;case "foreignObject":a(".context_panel").hide();
break;case "g":case "a":s=null;for(var D=T.getElementsByTagName("*"),G=0,L=D.length;G<L;G++){var W=D[G].getAttribute("stroke-width");if(G===0)s=W;else if(s!==W)s=null}a("#stroke_width").val(s===null?"0":s);Ja();break;default:a("#stroke_width").val(T.getAttribute("stroke-width")||0);s=T.getAttribute("stroke-dasharray")||"none";a("option","#stroke_style").removeAttr("selected");a('#stroke_style option[value="'+s+'"]').attr("selected","selected");a("#stroke_style").trigger("change");a.fn.dragInput.updateCursor(a("#stroke_width")[0]);
s=T.getAttribute("stroke-linejoin")||"miter";a("#linejoin_"+s).length!=0&&d(a("#linejoin_"+s)[0]);s=T.getAttribute("stroke-linecap")||"butt";a("#linecap_"+s).length!=0&&d(a("#linecap_"+s)[0])}if(T!=null){s=(T.getAttribute("opacity")||1)*100;a("#group_opacity").val(s);a.fn.dragInput.updateCursor(a("#group_opacity")[0])}Z.length&&a("#tools_top").addClass("multiselected")}else if(Z.length){a(".context_panel").hide();a("#tools_top").removeClass("multiselected");a("#multiselected_panel").show()}else{a(".context_panel").hide();
a("#canvas_panel").show();a("#tools_top").removeClass("multiselected")}h.runExtensions("selectedChanged",{elems:o,selectedElement:T,multiselected:Z})});h.bind("transition",function(f,o){var s=h.getMode(),D=o[0];if(D){Z=o.length>=2&&o[1]!=null?o:null;if(!Z)switch(s){case "rotate":s=h.getRotationAngle(D);a("#angle").val(Math.round(s));rotateCursor(s);a("#tool_reorient").toggleClass("disabled",s==0)}h.runExtensions("elementTransition",{elems:o})}});h.bind("changed",function(f,o){var s=h.getMode();s===
"select"&&fa();for(var D=0;D<o.length;++D){var G=o[D];if(G&&G.tagName==="svg")w();else if(G&&T&&T.parentNode==null)T=G}b.show_save_warning=true;Ja();if(T&&s==="select"){b.paintBox.fill.update();b.paintBox.stroke.update()}h.runExtensions("elementChanged",{elems:o})});h.bind("saved",function(f,o){b.show_save_warning=false;o='<?xml version="1.0"?>\n'+o;var s=navigator.userAgent;if(~s.indexOf("MSIE"))Ab(0,true);else{var D=f.open("data:image/svg+xml;base64,"+R.encode64(o)),G=a.pref("save_notice_done");
if(G!=="all"){var L=uiStrings.notification.saveFromBrowser.replace("%s","SVG");if(s.indexOf("Gecko/")!==-1)if(o.indexOf("<defs")!==-1){L+="\n\n"+uiStrings.notification.defsFailOnSave;a.pref("save_notice_done","all");G="all"}else a.pref("save_notice_done","part");else a.pref("save_notice_done","all");G!=="part"&&D.alert(L)}}});h.bind("exported",function(f,o){var s=o.issues;a("#export_canvas").length||a("<canvas>",{id:"export_canvas"}).hide().appendTo("body");var D=a("#export_canvas")[0];D.width=h.contentW;
D.height=h.contentH;canvg(D,o.svg,{renderCallback:function(){var G=D.toDataURL("image/png");U.location.href=G;if(a.pref("export_notice_done")!=="all"){G=uiStrings.notification.saveFromBrowser.replace("%s","PNG");if(s.length)G+="\n\n"+uiStrings.notification.noteTheseIssues+"\n \u2022 "+s.join("\n \u2022 ");a.pref("export_notice_done","all");U.alert(G)}}})});h.bind("zoomed",da);h.bind("contextset",function(f,o){var s="";if(o){var D="";s='<a href="#" data-root="y">'+h.getCurrentDrawing().getCurrentLayerName()+
"</a>";a(o).parentsUntil("#svgcontent > g").andSelf().each(function(){if(this.id){D+=" > "+this.id;s+=this!==o?' > <a href="#">'+this.id+"</a>":" > "+this.id}});ja=D}else ja=null;a("#cur_context_panel").toggle(!!o).html(s)});h.bind("extension_added",function(f,o){function s(){if(wa){clearTimeout(wa);wa=null}G||(wa=setTimeout(function(){G=true;ib(u.iconsize)},50))}var D=false,G=false,L=true,W=function(){if(o.callback&&!D&&L){D=true;o.callback()}},ba=[];o.context_tools&&a.each(o.context_tools,function(za,
ga){var Aa=ga.container_id?' id="'+ga.container_id+'"':"",xa=a("#"+ga.panel);xa.length||(xa=a("<div>",{id:ga.panel}).appendTo("#tools_top").hide());switch(ga.type){case "tool_button":var ya='<div class="tool_button">'+ga.id+"</div>",Na=a(ya).appendTo(xa);ga.events&&a.each(ga.events,function(Pa,mb){a(Na).bind(Pa,mb)});break;case "select":ya="<label"+Aa+'><select id="'+ga.id+'">';a.each(ga.options,function(Pa,mb){ya+='<option value="'+Pa+'"'+(Pa==ga.defval?" selected":"")+">"+mb+"</option>"});ya+="</select></label>";
var $a=a(ya).appendTo(xa).find("select");a.each(ga.events,function(Pa,mb){a($a).bind(Pa,mb)});break;case "button-select":ya='<div id="'+ga.id+'" class="dropdown toolset" title="'+ga.title+'"><div id="cur_'+ga.id+'" class="icon_label"></div><button></button></div>';Aa=a('<ul id="'+ga.id+'_opts"></ul>').appendTo("#option_lists");ga.colnum&&Aa.addClass("optcols"+ga.colnum);a(ya).appendTo(xa).children();ba.push({elem:"#"+ga.id,list:"#"+ga.id+"_opts",title:ga.title,callback:ga.events.change,cur:"#cur_"+
ga.id});break;case "input":ya="<label"+Aa+'><span id="'+ga.id+'_label">'+ga.label+':</span><input id="'+ga.id+'" title="'+ga.title+'" size="'+(ga.size||"4")+'" value="'+(ga.defval||"")+'" type="text"/></label>';var Wa=a(ya).appendTo(xa).find("input");ga.spindata&&Wa.SpinButton(ga.spindata);ga.events&&a.each(ga.events,function(Pa,mb){Wa.bind(Pa,mb)})}});if(o.buttons){var S={},Y={},aa=o.svgicons,na={};a.each(o.buttons,function(za,ga){for(var Aa,xa=ga.id,ya=za;a("#"+xa).length;)xa=ga.id+"_"+ ++ya;if(aa){S[xa]=
ga.icon;ya=ga.svgicon?ga.svgicon:ga.id;if(ga.type=="app_menu")Y["#"+xa+" > div"]=ya;else Y["#"+xa]=ya}else Aa=ga.type=="menu"?"":a('<img src="'+ga.icon+'">');var Na,$a;switch(ga.type){case "mode_flyout":case "mode":Na="tool_button";if(ga.cls)Na+=" "+ga.cls;$a="#tools_left";break;case "context":Na="tool_button";$a="#"+ga.panel;a($a).length||a("<div>",{id:ga.panel}).appendTo("#tools_top");break;case "menu":Na="menu_item tool_button";$a="#"+(ga.after||ga.panel);break;case "app_menu":Na="";$a=ga.parent||
"#main_menu ul";a($a).length||a("<div>",{id:ga.panel}).appendTo("#tools_top")}var Wa=a(ga.list||ga.type=="app_menu"?"<li/>":"<div/>").attr("id",xa).attr("title",ga.title).addClass(Na);if(!ga.includeWith&&!ga.list){if("position"in ga)a($a).children().eq(ga.position).before(Wa);else ga.type!="menu"||!ga.after?Wa.appendTo($a):a($a).after(Wa);if(ga.type=="mode_flyout"){ya=a(Wa);Na=ya.parent();if(!ya.parent().hasClass("tools_flyout")){var Pa=ya[0].id.replace("tool_","tools_"),mb=ya.clone().attr("id",Pa+
"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));ya.before(mb);Na=qa(Pa,ya);Na.data("isLibrary",true);mb.data("isLibrary",true)}Y["#"+Pa+"_show"]=ga.id;xa=na["#"+Na[0].id]=[{sel:"#"+xa,fn:ga.events.click,icon:ga.id,isDefault:true},yb]}else if(ga.type=="app_menu"||ga.type=="menu")Wa.append(ga.title)}else if(ga.list){Wa.addClass("push_button");a("#"+ga.list+"_opts").append(Wa);if(ga.isDefault){a("#cur_"+ga.list).append(Wa.children().clone());ya=ga.svgicon?ga.svgicon:ga.id;Y["#cur_"+ga.list]=
ya}}else if(ga.includeWith){$a=ga.includeWith;ya=a($a.button);Na=ya.parent();if(!ya.parent().hasClass("tools_flyout")){Pa=ya[0].id.replace("tool_","tools_");mb=ya.clone().attr("id",Pa+"_show").append(a("<div>",{"class":"flyout_arrow_horiz"}));ya.before(mb);Na=qa(Pa,ya)}var yb=H.getButtonData($a.button);if($a.isDefault)Y["#"+Pa+"_show"]=ga.id;xa=na["#"+Na[0].id]=[{sel:"#"+xa,fn:ga.events.click,icon:ga.id,key:ga.key,isDefault:ga.includeWith?ga.includeWith.isDefault:0},yb];Pa="position"in $a?$a.position:
"last";yb=Na.children().length;if(!isNaN(Pa)&&Pa>=0&&Pa<yb)Na.children().eq(Pa).before(Wa);else{Na.append(Wa);xa.reverse()}}aa||Wa.append(Aa);ga.list||a.each(ga.events,function(Db,Nb){if(Db=="click")if(ga.type=="mode"){ga.includeWith?Wa.bind(Db,Nb):Wa.bind(Db,function(){Ua(Wa)&&Nb()});if(ga.key){a(document).bind("keydown",ga.key,Nb);ga.title&&Wa.attr("title",ga.title+" ["+ga.key+"]")}}else Wa.bind(Db,Nb);else Wa.bind(Db,Nb)});oa(na)});a.each(ba,function(){Va(this.elem,this.list,this.callback,{seticon:true})});
if(aa)L=false;a.svgIcons(aa,{w:27,h:27,id_match:false,no_img:!v,fallback:S,placement:Y,callback:function(){u.iconsize&&u.iconsize!="m"&&s();L=true;W()}})}W()});h.textActions.setInputElem(a("#text")[0]);var Ea='<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(f,o){Ea+='<div class="palette_item" style="background-color: '+o+';" data-rgb="'+o+'"></div>'});a("#palette").append(Ea);var va=a("#tool_angle_indicator");a("#tool_reorient");rotateCursor=function(f){f="rotate("+f+"deg)";va.css({"-webkit-transform":f,"-moz-transform":f,"-o-transform":f,"-ms-transform":f,transform:f})};var Ga=function(f){var o=f.value/100;if(o<
0.0010)f.value=0.1;else{f=h.getZoom();var s=I;da(window,{width:0,height:0,x:(s[0].scrollLeft+s.width()/2)/f,y:(s[0].scrollTop+s.height()/2)/f,zoom:o},true)}},ta=function(){window.opera&&a("<p/>").hide().appendTo("body").remove()};a("#stroke_style").change(function(){h.setStrokeAttr("stroke-dasharray",a(this).val());a("#stroke_style_label").html(this.options[this.selectedIndex].text);ta()});a("#seg_type").change(function(){h.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(){h.setFontFamily(this.value)});a("#text").keyup(function(){h.setTextContent(this.value)});changeAttribute=function(f){var o=f.getAttribute("data-attr"),s=f.getAttribute("data-multiplier")||1;s=parseFloat(s);s=f.value*s;if(!svgedit.units.isValidUnit(o,s,T)){a.alert(uiStrings.notification.invalidAttrValGiven);f.value=T.getAttribute(o);return false}h.changeSelectedAttributeNoUndo(o,s)};a("#palette").mouseover(function(){var f=
a('<input type="hidden">');a(this).append(f);f.focus().remove()});a(".palette_item").on("mousedown touchstart touchmove",function(){var f=a("#tool_stroke").hasClass("active"),o=f?"stroke":"fill",s=a(this).attr("data-rgb"),D=null;if(s==="transparent"||s==="initial"||s==="#none"){s="none";D=new a.jGraduate.Paint}else D=new a.jGraduate.Paint({alpha:100,solidColor:s.substr(1)});b.paintBox[o].setPaint(D);if(f){h.setColor("stroke",s);s!="none"&&h.getStrokeOpacity()!=1&&h.setPaintOpacity("stroke",1)}else{h.setColor("fill",
s);s!="none"&&h.getFillOpacity()!=1&&h.setPaintOpacity("fill",1)}}).bind("contextmenu",function(f){f.preventDefault()});a("#toggle_stroke_tools").toggle(function(){a(".stroke_tool").css("display","table-cell");a(this).addClass("expanded");k()},function(){a(".stroke_tool").css("display","none");a(this).removeClass("expanded");k()});var Ua=function(f,o){if(a(f).hasClass("disabled"))return false;if(a(f).parent().hasClass("tools_flyout"))return true;var s=s||"normal";o||a(".tools_flyout").fadeOut(s);
a("#styleoverrides").text("");a(".tool_button_current").removeClass("tool_button_current").addClass("tool_button");a(f).addClass("tool_button_current").removeClass("tool_button");return true};(function(){var f=null,o=null,s=I[0],D=false,G=false;a("#svgcanvas").on("mousemove mouseup touchend",function(L){if(D!==false){s.scrollLeft-=L.clientX-f;s.scrollTop-=L.clientY-o;f=L.clientX;o=L.clientY;if(L.type==="mouseup"||L.type==="touchend")D=false;return false}}).on("mousedown touchmove",function(L){if(L.button===
1||G===true||L.originalEvent.touches&&L.originalEvent.touches.length>=2){D=true;f=L.clientX;o=L.clientY;return false}});a(window).mouseup(function(){D=false});a(document).bind("keydown","space",function(L){L.preventDefault();h.spaceKey=G=true}).bind("keyup","space",function(L){L.preventDefault();h.spaceKey=G=false}).bind("keydown","alt",function(){h.getMode()==="zoom"&&I.addClass("out")}).bind("keyup","alt",function(){h.getMode()==="zoom"&&I.removeClass("out")})})();var ub=a(".menu"),fb=function(f){f.target.style.background=
"#fff";setTimeout(function(){f.target.style.background="#ddd"},50);setTimeout(function(){f.target.style.background="#fff"},150);setTimeout(function(){f.target.style.background="#ddd"},200);setTimeout(function(){f.target.style.background=""},200);setTimeout(function(){a("#menu_bar").removeClass("active")},220);return false};a(".menu_item").on("mousedown touchstart",function(f){fb(f)});a("svg, body").on("mousedown touchstart",function(f){if(!(f.target.nodeName&&f.target.nodeName.toLowerCase()==="input"))if(!a(f.target).hasClass("menu_title")&&
!a(f.target).parent().hasClass("menu_title"))!a(f.target).hasClass("disabled")&&a(f.target).hasClass("menu_item")?fb(f):a("#menu_bar").removeClass("active")});a("#workarea").on("mousewheel",function(f,o,s,D){if(f.altKey){f.preventDefault();zoom=parseInt(a("#zoom").val());a("#zoom").val(parseInt(zoom+D*10)).change()}});a(".menu_title").on("mousedown",function(){a("#tools_shapelib").hide();a("#menu_bar").toggleClass("active");ub.removeClass("open");a(this).parent().addClass("open")}).on("mouseover",
function(){ub.removeClass("open");a(this).parent().addClass("open")});b.addDropDown=function(f,o,s){if(a(f).length!=0){var D=a(f).find("button"),G=a(f).find("ul").attr("id",a(f)[0].id+"-list");s||a("#option_lists").append(G);var L=false;s&&a(f).addClass("dropup");G.find("li").bind("mouseup",o);a(window).mouseup(function(){if(!L){D.removeClass("down");G.hide()}L=false});D.bind("mousedown",function(){if(D.hasClass("down")){D.removeClass("down");G.hide()}else{D.addClass("down");if(!s){var W=a(f).offset();
G.css({top:W.top,left:W.left-110})}G.show();L=true}}).hover(function(){L=true}).mouseout(function(){L=false})}};var Va=function(f,o,s,D){var G=a(f);o=a(o);var L=false,W=D.dropUp;W&&a(f).addClass("dropup");o.find("li").bind("mouseup",function(){if(D.seticon){Jb("#cur_"+G[0].id,a(this).children());a(this).addClass("current").siblings().removeClass("current")}s.apply(this,arguments)});a(window).mouseup(function(){if(!L){G.removeClass("down");o.hide();o.css({top:0,left:0})}L=false});o.height();a(f).bind("mousedown",
function(){var ba=a(f).offset();if(W){ba.top-=o.height();ba.left+=8}else ba.top+=a(f).height();a(o).offset(ba);if(G.hasClass("down")){G.removeClass("down");o.hide();o.css({top:0,left:0})}else{G.addClass("down");o.show();L=true;return false}}).hover(function(){L=true}).mouseout(function(){L=false});D.multiclick&&o.mousedown(function(){L=true})};a("#font_family_dropdown").change(function(){var f=this.options[this.selectedIndex].value,o=this.options[this.selectedIndex].text;a("#preview_font").html(o).css("font-family",
f);a("#font_family").val(f).change()});a("div","#position_opts").each(function(){this.addEventListener("mouseup",function(){var f=this.id.replace("tool_pos","").charAt(0);h.alignSelectedElements(f,"page")})});(function(){var f,o=function(){a(f).blur()};a("#svg_editor").find("button, select, input:not(#text)").focus(function(){f=this;ha="toolbars";I.mousedown(o)}).blur(function(){ha="canvas";I.unbind("mousedown",o);h.getMode()=="textedit"&&a("#text").focus()})})();var Xa=function(){Ua("#tool_select")&&
h.setMode("select")},Ca=function(){Ua("#tool_fhpath")&&h.setMode("fhpath")},sa=function(){Ua("#tool_line")&&h.setMode("line")},db=function(){Ua("#tool_rect")&&h.setMode("rect")},La=function(){Ua("#tool_ellipse")&&h.setMode("ellipse")},Ta=function(){Ua("#tool_image")&&h.setMode("image")},Da=function(){Ua("#tool_zoom")&&h.setMode("zoom")},hb=function(){if(Ua("#tool_zoom")){zb();fa()}},qb=function(){Ua("#tool_text")&&h.setMode("text")},Ya=function(){Ua("#tool_path")&&h.setMode("path")},Za=function(){if(T!=
null||Z)h.deleteSelectedElements()},vb=function(){if(T!=null||Z){window.event&&window.event.type==="keydown"&&ab(a("#edit_menu"));h.cutSelectedElements()}},ra=function(){if(T!=null||Z){window.event&&window.event.type==="keydown"&&ab(a("#edit_menu"));h.copySelectedElements()}},kb=function(){window.event&&window.event.type==="keydown"&&ab(a("#edit_menu"));var f=h.getZoom(),o=(I[0].scrollLeft+I.width()/2)/f-h.contentW;f=(I[0].scrollTop+I.height()/2)/f-h.contentH;h.pasteElements("point",o,f)},gb=function(){if(T!=
null){window.event&&window.event.type==="keydown"&&ab(a("#object_menu"));h.moveToTopSelectedElement()}},tb=function(){if(T!=null){window.event&&window.event.type==="keydown"&&ab(a("#object_menu"));h.moveToBottomSelectedElement()}},lb=function(){if(T!=null){window.event&&window.event.type==="keydown"&&ab(a("#object_menu"));h.moveUpDownSelected("Up")}},eb=function(){if(T!=null){window.event&&window.event.type==="keydown"&&ab(a("#object_menu"));h.moveUpDownSelected("Down")}},nb=function(f){if(T!=null){window.event&&
window.event.type==="keydown"&&ab(a("#object_menu"));h.moveUpDownSelected(f)}},rb=function(){if(T!=null){h.convertToPath();elems=h.getSelectedElems();h.selectorManager.requestSelector(elems[0]).reset(elems[0]);h.selectorManager.requestSelector(elems[0]).selectorRect.setAttribute("display","none");h.setMode("pathedit");p.toEditMode(elems[0]);h.clearSelection();Ja()}},wb=function(){T!=null&&p.reorient()},xb=function(){if(T!=null||Z)a.prompt(uiStrings.notification.enterNewLinkURL,"http://",function(f){f&&
h.makeHyperlink(f)})},ia=function(f,o){if(T!=null||Z){if(curConfig.gridSnapping){var s=h.getZoom()*curConfig.snappingStep;f*=s;o*=s}a("input").blur();h.moveSelectedElements(f,o)}},ca=function(){var f=!a("#tool_node_link").hasClass("checked");f?a("#tool_node_link").addClass("checked").find("input").attr("checked",true):a("#tool_node_link").removeClass("checked").find("input").attr("checked",false);p.linkControlPoints(f)},ka=function(){p.getNodePoint()&&p.clonePathNode()},M=function(){p.getNodePoint()&&
p.deletePathNode()},P=function(){var f=a("#tool_add_subpath"),o=!f.hasClass("push_button_pressed");o?f.addClass("push_button_pressed").removeClass("tool_button"):f.removeClass("push_button_pressed").addClass("tool_button");p.addSubPath(o)},ea=function(){p.opencloseSubPath()},Fa=function(){h.cycleElement(1)},Oa=function(){h.cycleElement(0)},Ra=function(f,o){if(!(T==null||Z)){f||(o*=-1);var s=a("#angle").val()*1+o;h.setRotationAngle(s);Ja()}},cb=function(){var f=curConfig.dimensions;a.confirm(uiStrings.notification.QwantToClear,
function(o){if(o){fa();h.clear();h.setResolution(f[0],f[1]);w(true);zb();Ja();V();h.runExtensions("onNewDocument")}})},pb=function(){h.setBold(!h.getBold());Ja()},Sa=function(){h.setItalic(!h.getItalic());Ja()},ob=function(){if(!c.pngsave){var f=uiStrings.notification.loadingImage;U=window.open("data:text/html;charset=utf-8,<title>"+f+"</title><h1>"+f+"</h1>")}window.canvg?h.rasterExport():a.getScript("canvg/rgbcolor.js",function(){a.getScript("canvg/canvg.js",function(){h.rasterExport()})})},Qa=
function(){h.open()},sb=function(){},ab=function(f){var o=f.prev();o.css("background","#09f");setTimeout(function(){o.css("background","")},200)},Fb=function(){if(K.getUndoStackSize()>0){window.event&&window.event.type==="keydown"&&ab(a("#edit_menu"));K.undo()}},Eb=function(){if(K.getRedoStackSize()>0){window.event&&window.event.type==="keydown"&&ab(a("#edit_menu"));K.redo()}},bb=function(){if(Z)h.groupSelectedElements();else T&&h.ungroupSelectedElement()},Ma=function(){window.event&&window.event.type===
"keydown"&&ab(a("#edit_menu"));h.cloneSelectedElements(20,20)},Ob=function(){var f=this.id.replace("tool_align","").charAt(0);h.alignSelectedElements(f,a("#align_relative_to").val())},Lb=function(){var f=document.querySelector("#tool_stroke rect"),o=document.querySelector("#tool_fill rect"),s=o.getAttribute("fill"),D=f.getAttribute("fill");f=parseFloat(f.getAttribute("stroke-opacity"));if(isNaN(f))f=100;o=parseFloat(o.getAttribute("fill-opacity"));if(isNaN(o))o=100;D=Ha(D,f,"stroke");s=Ha(s,o,"fill");
b.paintBox.fill.setPaint(D,true);b.paintBox.stroke.setPaint(s,true)},zb=function(f){var o=h.getResolution();f=f?o.zoom*f:1;a("#zoom").val(f*100);h.setZoom(f);Kb();w(true)},Mb=function(){!a("#tool_wireframe").hasClass("push_button_pressed")?a("#tool_wireframe").addClass("push_button_pressed"):a("#tool_wireframe").removeClass("push_button_pressed");I.toggleClass("wireframe");if(!B){var f=a("#wireframe_rules");f.length?f.empty():a('<style id="wireframe_rules"></style>').appendTo("head");Kb()}},Pb=function(){var f=
!a("#tool_snap").hasClass("push_button_pressed");f?a("#tool_snap").addClass("push_button_pressed"):a("#tool_snap").removeClass("push_button_pressed");curConfig.gridSnapping=f},Bb=function(){window.self!=window.top&&top.exit_fullscreen()},Hb=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)},Kb=function(){if(!B){var f="#workarea.wireframe #svgcontent * { stroke-width: "+1/h.getZoom()+"px; }";a("#wireframe_rules").text(I.hasClass("wireframe")?f:"")}},Ab=function(f,o){if(!ua){ua=true;a("#save_output_btns").toggle(!!o);a("#tool_source_back").toggle(!o);var s=pa=h.getSvgString();a("#svg_source_textarea").val(s);a("#svg_source_editor").fadeIn();a("#svg_source_textarea").focus().select()}},jb=function(){if(ua){if(h.setSvgString(a("#svg_source_textarea").val())){h.clearSelection();
e();zb();V()}else a.confirm(uiStrings.notification.QerrorsRevertToSource,function(f){if(!f)return false;h.clearSelection();e();zb();V()});fa()}},Jb=b.setIcon=function(f,o){var s=typeof o==="string"?a.getSvgIcon(o,true):o.clone();s?a(f).find("img").replaceWith(s):console.log("NOTE: Icon image missing: "+o)},Ib;Ib=function(){var f=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,o=document.getElementsByTagName("script")[0],s;for(s in o.style)if(f.test(s))return s.match(f)[0];if("WebkitOpacity"in o.style)return"Webkit";
if("KhtmlOpacity"in o.style)return"Khtml";return""}();var Cb=function(f,o){Ib.toLowerCase();var s=["top","left","bottom","right"];f.each(function(){for(var D=a(this),G=D.outerWidth()*(o-1),L=D.outerHeight()*(o-1),W=0;W<4;W++){var ba=s[W],S=D.data("orig_margin-"+ba);if(S==null){S=parseInt(D.css("margin-"+ba));D.data("orig_margin-"+ba,S)}S=S*o;if(ba==="right")S+=G;else if(ba==="bottom")S+=L;D.css("margin-"+ba,S)}})},ib=b.setIconSize=function(f,o){if(!(f==u.size&&!o)){var s=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 f=="number"?f:{s:0.75,m:1,l:1.25,xl:1.5}[f];b.tool_scale=N=D;ma();var G=s.parents(":hidden");G.css("visibility","hidden").show();Cb(s,D);G.css("visibility","visible").hide();s=a("#tool_size_rules");if(s.length)s.empty();else s=a('<style id="tool_size_rules"></style>').appendTo("head");if(f!="m"){var L="";a.each(cssResizeRules,function(W,ba){W="#svg_editor "+W.replace(/,/g,", #svg_editor");L+=W+"{";a.each(ba,function(S,Y){if(typeof Y==="number")var aa=Y*D+"px";else if(Y[f]||Y.all)aa=Y[f]||
Y.all;L+=S+":"+aa+";"});L+="}"});G="-"+Ib.toLowerCase()+"-";L+="#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{"+G+"transform: scale("+D+");} #svg_editor div.toolset .toolset {"+G+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+G+"transform: scale("+1/D+");}";s.text(L)}ma()}},Gb=function(){a("#dialog_box").hide();if(ua){if(ua)pa!==
a("#svg_source_textarea").val()?a.confirm(uiStrings.notification.QignoreSourceChanges,function(f){f&&e()}):e();k()}else ja&&h.leaveContext()},e=function(){a("#svg_source_editor").hide();ua=false;a("#svg_source_textarea").blur()};a(window).width();a(window).height();var k=a.noop;a(window).resize(function(){w()});(function(){I.scroll(function(){if(a("#ruler_x").length!=0)a("#ruler_x")[0].scrollLeft=I[0].scrollLeft;if(a("#ruler_y").length!=0)a("#ruler_y")[0].scrollTop=I[0].scrollTop})})();a("#url_notice").click(function(){a.alert(this.title)});
a("#change_image_url").click(function(){var f=h.getHref(T);f=f.indexOf("data:")===0?"":f;a.prompt(uiStrings.notification.enterNewImgURL,f,function(o){o&&Ka(o)})});var m=function(f){var o=f[0].id=="stroke_color"?"stroke":"fill",s=f[0].id=="canvas_color";if(s)o="canvas";var D=b.paintBox[o].paint;f=o=="stroke"?"Pick a Stroke Paint and Opacity":"Pick a Fill Paint and Opacity";s=s?{right:175,top:50}:{left:50,bottom:50};a("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",
containment:"window"}).removeAttr("style").css(s).jGraduate({paint:D,window:{pickerTitle:f},images:{clientPath:curConfig.jGraduatePath},newstop:"inverse"},function(G){D=new a.jGraduate.Paint(G);b.paintBox[o].setPaint(D);h.setPaint(o,D);a("#color_picker").hide()},function(){a("#color_picker").hide()})};l=function(f,o){var s=document.getElementById("canvas_background"),D={color:"fff",opacity:1};if(o=="stroke")D=curConfig.initStroke;if(o=="fill")D=curConfig.initFill;if(o=="canvas"&&s)if(s=s.getAttribute("fill").match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))D=
{color:("0"+parseInt(s[1],10).toString(16)).slice(-2)+("0"+parseInt(s[2],10).toString(16)).slice(-2)+("0"+parseInt(s[3],10).toString(16)).slice(-2),opacity:1};s=(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;s=a(f)[0].appendChild(document.importNode(s,true));o==="canvas"?s.setAttribute("width",60.5):
s.setAttribute("width","100%");this.rect=s.firstChild;this.defs=s.getElementsByTagName("defs")[0];this.grad=this.defs.firstChild;this.paint=new a.jGraduate.Paint({solidColor:D.color});this.type=o;this.setPaint=function(G,L){this.paint=G;var W="none",ba=G.type,S=G.alpha/100;switch(ba){case "solidColor":W=G[ba]=="none"||G[ba]=="one"?"none":"#"+G[ba];break;case "linearGradient":case "radialGradient":this.defs.removeChild(this.grad);this.grad=this.defs.appendChild(G[ba]);W="url(#"+(this.grad.id="gradbox_"+
this.type)+")"}this.rect.setAttribute("fill",W);this.rect.setAttribute("opacity",S);if(L){h.setColor(this.type,W,true);h.setPaintOpacity(this.type,S,true)}if(this.type=="canvas")if(ba=document.getElementById("canvas_background")){Ba=h.getResolution();ba.setAttribute("x",-1);ba.setAttribute("y",-1);ba.setAttribute("width",Ba.w+2);ba.setAttribute("height",Ba.h+2);ba.setAttribute("fill",W)}else Ia(W)};this.update=function(G){if(T){var L=this.type;switch(T.tagName){case "use":case "image":case "foreignObject":return;
case "g":case "a":for(var W=null,ba=T.getElementsByTagName("*"),S=0,Y=ba.length;S<Y;S++){var aa=ba[S].getAttribute(L);if(S===0)W=aa;else if(W!==aa){W=null;break}}if(W===null){ba=null;return}ba=W;W=1;break;default:W=parseFloat(T.getAttribute(L+"-opacity"));if(isNaN(W))W=1;ba=L==="fill"?"black":"none";ba=T.getAttribute(L)||ba}if(G){h.setColor(L,ba,true);h.setPaintOpacity(L,W,true)}W*=100;this.setPaint(Ha(ba,W,L))}};this.prep=function(){switch(this.paint.type){case "linearGradient":case "radialGradient":var G=
new a.jGraduate.Paint({copy:this.paint});h.setPaint(o,G)}}};b.paintBox.fill=new l("#fill_color","fill");b.paintBox.stroke=new l("#stroke_color","stroke");b.paintBox.canvas=new l("#canvas_color","canvas");a("#stroke_width").val(curConfig.initStroke.width);a("#group_opacity").val(curConfig.initOpacity*100);l=b.paintBox.fill.rect.cloneNode(false);l.setAttribute("style","vector-effect:non-scaling-stroke");var B=l.style.vectorEffect==="non-scaling-stroke";l.removeAttribute("style");l=b.paintBox.fill.rect.ownerDocument.createElementNS("http://www.w3.org/2000/svg",
"feGaussianBlur");typeof l.stdDeviationX==="undefined"&&a("#tool_blur").hide();a(l).remove();setTimeout(function(){h.embedImage("images/placeholder.svg",function(f){if(!f){a("#image_save_opts [value=embed]").attr("disabled","disabled");a("#image_save_opts input").val(["ref"]);u.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"))m(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"))m(a("#stroke_color"));else{a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active")}});a("#tool_canvas").on("click touchstart",function(){m(a("#canvas_color"))});a("#tool_stroke").on("touchstart",function(){a("#tool_stroke").addClass("active");a("#tool_fill").removeClass("active");m(a("#stroke_color"))});a("#tool_fill").on("touchstart",function(){a("#tool_fill").addClass("active");
a("#tool_stroke").removeClass("active");m(a("#fill_color"))});a("#zoom_select").on("change",function(){var f=this.options[this.selectedIndex].text;f=f.split("%")[0];a("#zoom").val(f).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(){I.css("line-height",I.height()+"px")});var z=function(){var f=a("#canvas_width"),o=a("#canvas_height"),s=f.val(),D=o.val();if(s!="fit"&&!svgedit.units.isValidUnit("width",s)){a.alert(uiStrings.notification.invalidAttrValGiven);f.parent().addClass("error");return false}f.parent().removeClass("error");if(D!="fit"&&!svgedit.units.isValidUnit("height",D)){a.alert(uiStrings.notification.invalidAttrValGiven);o.parent().addClass("error");return false}o.parent().removeClass("error");
if(!h.setResolution(s,D)){a.alert(uiStrings.notification.noContentToFitTo);s=h.getResolution();f.val(s.w);o.val(s.h);return false}w()};a("#resolution").change(function(){var f=a("#canvas_width")[0],o=a("#canvas_height")[0];if(this.selectedIndex)if(this.value=="content"){f.value="fit";o.value="fit";z();var s=h.getResolution();f.value=s.w;o.value=s.h}else{var D=this.value.split("x");D[0]=parseInt(D[0]);D[1]=parseInt(D[1]);var G=D[0]-f.value,L=D[1]-o.value,W=Date.now(),ba=function(S){S=(S-W)/1E3;S=Math.pow(S-
1,3)+1;f.value=(D[0]-G+S*G).toFixed(0);o.value=(D[1]-L+S*L).toFixed(0);z();if(S>=1){S=h.getResolution();a("#canvas_width").val(S.w.toFixed());a("#canvas_height").val(S.h.toFixed());a("#resolution_label").html("<div class='pull'>"+S.w+"<span>\u00d7</span></br>"+S.h+"</div>")}else requestAnimationFrame(ba)};ba(Date.now())}else{a("#resolution_label").html("Custom");f.removeAttribute("readonly");f.focus();f.select();if(f.value=="fit"){f.value=100;o.value=100}}});a("#zoom").change(function(){Ga(this)});
a("input,select").attr("autocomplete","off");var H=function(){var f=[{sel:"#tool_select",fn:Xa,evt:"click",key:["V",true]},{sel:"#tool_fhpath",fn:Ca,evt:"click",key:["Q",true]},{sel:"#tool_line",fn:sa,evt:"click",key:["L",true]},{sel:"#tool_rect",fn:db,evt:"click",key:["R",true],icon:"rect"},{sel:"#tool_ellipse",fn:La,evt:"mouseup",key:["C",true],icon:"ellipse"},{sel:"#tool_path",fn:Ya,evt:"click",key:["P",true]},{sel:"#tool_text",fn:qb,evt:"click",key:["T",true]},{sel:"#tool_image",fn:Ta,evt:"mouseup"},
{sel:"#tool_zoom",fn:Da,evt:"mouseup",key:["Z",true]},{sel:"#tool_clear",fn:cb,evt:"mouseup",key:[A+"N",true]},{sel:"#tool_save",fn:function(){ua?jb():h.save({images:u.img_save,round_digits:6})},evt:"mouseup",key:[A+"S",true]},{sel:"#tool_export",fn:ob,evt:"mouseup"},{sel:"#tool_open",fn:Qa,evt:"mouseup"},{sel:"#tool_import",fn:sb,evt:"mouseup"},{sel:"#tool_source",fn:Ab,evt:"click",key:[A+"U",true]},{sel:"#tool_wireframe",fn:Mb,evt:"click"},{sel:"#tool_snap",fn:Pb,evt:"click"},{sel:"#tool_rulers",
fn:Hb,evt:"click"},{sel:"#tool_source_cancel,#svg_source_overlay,#tool_docprops_cancel,#tool_prefs_cancel",fn:Gb,evt:"click",key:["esc",false,false],hidekey:true},{sel:"#tool_source_save",fn:jb,evt:"click"},{sel:"#tool_delete,#tool_delete_multi",fn:Za,evt:"click",key:["del/backspace",true]},{sel:"#tool_reorient",fn:wb,evt:"click"},{sel:"#tool_node_link",fn:ca,evt:"click"},{sel:"#tool_node_clone",fn:ka,evt:"click"},{sel:"#tool_node_delete",fn:M,evt:"click"},{sel:"#tool_openclose_path",fn:ea,evt:"click"},
{sel:"#tool_add_subpath",fn:P,evt:"click"},{sel:"#tool_move_top",fn:gb,evt:"click",key:A+"shift+up"},{sel:"#tool_move_bottom",fn:tb,evt:"click",key:A+"shift+down"},{sel:"#tool_move_up",fn:lb,evt:"click",key:[A+"up",true]},{sel:"#tool_move_down",fn:eb,evt:"click",key:[A+"down",true]},{sel:"#tool_topath",fn:rb,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:xb,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:Ma,evt:"click",key:[A+"D",true]},{sel:"#tool_group",fn:bb,evt:"click",key:[A+
"G",true]},{sel:"#tool_ungroup",fn:bb,evt:"click",key:A+"shift+G"},{sel:"#tool_unlink_use",fn:bb,evt:"click"},{sel:"[id^=tool_align]",fn:Ob,evt:"click"},{sel:"#tool_undo",fn:Fb,evt:"click",key:A+"z"},{sel:"#tool_redo",fn:Eb,evt:"click",key:["y",true]},{sel:"#tool_cut",fn:vb,evt:"click",key:[A+"x",true]},{sel:"#tool_copy",fn:ra,evt:"click",key:A+"c"},{sel:"#tool_paste",fn:kb,evt:"click",key:A+"v"},{sel:"#tool_switch",fn:Lb,evt:"click",key:["x",true]},{sel:"#tool_bold",fn:pb,evt:"mousedown",key:[A+
"B",true]},{sel:"#tool_italic",fn:Sa,evt:"mousedown",key:[A+"I",true]},{sel:"#copy_save_done",fn:Gb,evt:"click"},{key:"ctrl+left",fn:function(){Ra(0,1)}},{key:"ctrl+right",fn:function(){Ra(1,1)}},{key:"ctrl+shift+left",fn:function(){Ra(0,5)}},{key:"ctrl+shift+right",fn:function(){Ra(1,5)}},{key:"shift+O",fn:Oa},{key:"shift+P",fn:Fa},{key:[A+"+",true],fn:function(){zb(2)}},{key:[A+"-",true],fn:function(){zb(0.5)}},{key:["up",true],fn:function(){ia(0,-1)}},{key:["down",true],fn:function(){ia(0,1)}},
{key:["left",true],fn:function(){ia(-1,0)}},{key:["right",true],fn:function(){ia(1,0)}},{key:"shift+up",fn:function(){ia(0,-10)}},{key:"shift+down",fn:function(){ia(0,10)}},{key:"shift+left",fn:function(){ia(-10,0)}},{key:"shift+right",fn:function(){ia(10,0)}},{key:["alt+up",true],fn:function(){h.cloneSelectedElements(0,-1)}},{key:["alt+down",true],fn:function(){h.cloneSelectedElements(0,1)}},{key:["alt+left",true],fn:function(){h.cloneSelectedElements(-1,0)}},{key:["alt+right",true],fn:function(){h.cloneSelectedElements(1,
0)}},{key:["alt+shift+up",true],fn:function(){h.cloneSelectedElements(0,-10)}},{key:["alt+shift+down",true],fn:function(){h.cloneSelectedElements(0,10)}},{key:["alt+shift+left",true],fn:function(){h.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",true],fn:function(){h.cloneSelectedElements(10,0)}},{key:A+"A",fn:function(){h.selectAllInCurrentLayer()}},{key:"I",fn:function(){var s=a(".tool_button_current");if(s.length&&s[0].id!=="tool_eyedropper"){s.removeClass("tool_button_current").addClass("tool_button");
a("#tool_eyedropper").addClass("tool_button_current").removeClass("tool_button")}h.setMode("eyedropper")}},{key:A+"shift+z",fn:Eb},{key:"esc",fn:Bb}],o={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll:function(){var s={};a.each(f,function(D,G){if(G.sel){var L=a(G.sel);if(L.length==0)return true;if(G.evt){if(svgedit.browser.isTouch()&&G.evt==="click")G.evt="mousedown";L[G.evt](G.fn)}if(G.parent&&a(G.parent+"_show").length!=0){var W=a(G.parent);W.length||(W=qa(G.parent.substr(1)));
W.append(L);a.isArray(s[G.parent])||(s[G.parent]=[]);s[G.parent].push(G)}}if(G.key){var ba=G.fn,S=false;if(a.isArray(G.key)){W=G.key[0];if(G.key.length>1)S=G.key[1]}else W=G.key;W+="";svgedit.browser.isMac&&W.indexOf("+")!=-1&&W.split("+")[0]=="ctrl"&&W.replace("ctrl","cmd");a.each(W.split("/"),function(aa,na){a(document).bind("keydown",na,function(za){ba();S&&za.preventDefault();return false})});if(G.sel&&!G.hidekey&&L.attr("title")){var Y=L.attr("title").split("[")[0]+" ("+W+")";o[W]=G.sel;L.parents("#main_menu").length||
L.attr("title",Y)}}});oa(s);a(window).bind("keydown","tab",function(D){if(ha==="canvas"){D.preventDefault();Fa()}}).bind("keydown","shift+tab",function(D){if(ha==="canvas"){D.preventDefault();Oa()}});a("#tool_zoom").dblclick(hb)},setTitles:function(){a.each(o,function(s,D){var G=a(D).parents("#main_menu").length;a(D).each(function(){var L=G?a(this).text().split(" [")[0]:this.title.split(" [")[0],W="";a.each(s.split("/"),function(ba,S){var Y=S.split("+"),aa="";if(Y.length>1){aa=Y[0]+"+";S=Y[1]}W+=
(ba?"/":"")+aa+(uiStrings["key_"+S]||S)});if(G)this.lastChild.textContent=L+" ["+W+"]";else this.title=L+" ["+W+"]"})})},getButtonData:function(s){var D;a.each(f,function(G,L){if(L.sel===s)D=L});return D}}}();H.setAll();b.ready(function(){var f=curConfig.initTool,o=a("#tools_left, #svg_editor .tools_flyout"),s=o.find("#tool_"+f);f=o.find("#"+f);(s.length?s:f.length?f: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:z,cursor:false,dragAdjust:0.1});a("#canvas_width").dragInput({min:10,max:null,step:10,callback:z,cursor:false,dragAdjust:0.1});a("#rect_width").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#rect_height").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_cx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#ellipse_cy").dragInput({min:1,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:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_cx").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_cy").dragInput({min:1,max:null,step:1,callback:changeAttribute,cursor:false});a("#circle_r").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:changeAttribute,cursor:true});a("#stroke_width").dragInput({min:0,max:99,step:1,callback:function(f){var o=f.value;if(o==0&&
T&&["line","polyline"].indexOf(T.nodeName)>=0)o=f.value=1;h.setStrokeWidth(o)},cursor:true,smallStep:0.1,start:1.5});a("#angle").dragInput({min:-180,max:180,step:1,callback:function(f){h.setRotationAngle(f.value);rotateCursor(f.value);a("#tool_reorient").toggleClass("disabled",f.value==0)},cursor:false,dragAdjust:0.5});a("#font_size").dragInput({min:1,max:250,step:1,callback:function(f){h.setFontSize(f.value)},cursor:true,stepfunc:function(f,o){var s=f.value-0,D=s+o,G=D>=s;if(o===0)return s;return s>=
24?G?Math.round(s*1.1):Math.round(s/1.1):s<=1?G?s*2:s/2:D},dragAdjust:0.15});a("#group_opacity").dragInput({min:0,max:100,step:5,callback:changeAttribute,cursor:true,start:100});a("#blur").dragInput({min:0,max:10,step:0.1,callback:function(f){val=f.value;a("#blur").val(val);h.setBlur(val,true)},cursor:true,start:0});a("#zoom").val(h.getZoom()*100);a("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},function(f){switch(f){case "delete":Za();break;case "cut":vb();break;case "copy":ra();break;
case "paste":h.pasteElements();break;case "paste_in_place":h.pasteElements("in_place");break;case "group":h.groupSelectedElements();break;case "ungroup":h.ungroupSelectedElement();break;case "move_front":gb();break;case "move_up":nb("Up");break;case "move_down":nb("Down");break;case "move_back":tb();break;default:svgedit.contextmenu&&svgedit.contextmenu.hasCustomHandler(f)&&svgedit.contextmenu.getCustomHandler(f).call()}});a(".contextMenu li").mousedown(function(f){f.preventDefault()});a("#cmenu_canvas li").disableContextMenu();
Q.enableContextMenuItems("#delete,#cut,#copy");window.onbeforeunload=function(){if(K.getUndoStackSize()===0)b.show_save_warning=false;if(!curConfig.no_save_warning&&b.show_save_warning)return uiStrings.notification.unsavedChanges};b.openPrep=function(f){a("#main_menu").hide();K.getUndoStackSize()===0?f(true):a.confirm(uiStrings.notification.QwantToOpen,f)};if(window.FileReader){l=function(f){f.stopPropagation();f.preventDefault();a("#workarea").removeAttr("style");a("#main_menu").hide();var o=null;
if(o=f.type=="drop"?f.dataTransfer.files[0]:this.files[0])if(o.type.indexOf("image")!=-1)if(o.type.indexOf("svg")!=-1){f=new FileReader;f.onloadend=function(s){h.importSvgString(s.target.result,true);h.ungroupSelectedElement();h.ungroupSelectedElement();h.groupSelectedElements();h.alignSelectedElements("m","page");h.alignSelectedElements("c","page")};f.readAsText(o)}else alert("sorry, bitmap import is temporalily disabled")};I=a("#workarea");I[0].addEventListener("dragenter",function(f){f.stopPropagation();
f.preventDefault();I.css({"-webkit-transform":"scale3d(1.1,1.1,1)","-moz-transform":"scale3d(1.1,1.1,1)","-o-transform":"scale(1.1)","-ms-transform":"scale3d(1.1,1.1,1)",transform:"scale3d(1.1,1.1,1)"})},false);I[0].addEventListener("dragover",function(f){f.stopPropagation();f.preventDefault()},false);I[0].addEventListener("dragleave",function(f){I.removeAttr("style");f.stopPropagation();f.preventDefault()},false);I[0].addEventListener("drop",l,false);var C=a('<input type="file">').change(function(){var f=
this;b.openPrep(function(o){if(o){h.clear();if(f.files.length==1){o=new FileReader;o.onloadend=function(s){q(s.target.result);w()};o.readAsText(f.files[0])}}})});a("#tool_open").show().prepend(C);l=a('<input type="file">').change(l);a("#tool_import").show().prepend(l)}var w=b.updateCanvas=function(f,o){var s=I.width(),D=I.height(),G=s,L=D,W=h.getZoom(),ba=I,S=a("#svgcanvas"),Y={x:ba[0].scrollLeft+G/2,y:ba[0].scrollTop+L/2},aa=curConfig.canvas_expansion;s=Math.max(G,h.contentW*W*aa);D=Math.max(L,h.contentH*
W*aa);s==G&&D==L?I.css("overflow","hidden"):I.css("overflow","scroll");aa=S.height()/2;var na=S.width()/2;S.width(s).height(D);var za=D/2,ga=s/2,Aa=h.updateCanvas(s,D),xa=ga/na;s=s/2-G/2;D=D/2-L/2;if(o){o.x+=Aa.x;o.y+=Aa.y}else o={x:ga+(Y.x-na)*xa,y:za+(Y.y-aa)*xa};if(f)if(h.contentW>ba.width()){I[0].scrollLeft=Aa.x-10;I[0].scrollTop=Aa.y-10}else{ba[0].scrollLeft=s;ba[0].scrollTop=D}else{ba[0].scrollLeft=o.x-G/2;ba[0].scrollTop=o.y-L/2}if(curConfig.showRulers){G=S;W=W;document.getElementById("workarea");
document.getElementById("title_show");W||(W=h.getZoom());G||(G=a("#svgcanvas"));L=h.getContentElem();ba=svgedit.units.getTypeMap()[curConfig.baseUnit];for(S=0;S<2;S++){na=(Y=S===0)?"x":"y";xa=Y?"width":"height";aa=L.getAttribute(na)-0;na=a("#ruler_"+na+" canvas:first");$hcanv=na.clone();na.replaceWith($hcanv);s=$hcanv[0];za=na=G[xa]()*2;s.parentNode.style[xa]=za+"px";ga=0;var ya;Aa=s.getContext("2d");Aa.fillStyle="rgb(200,0,0)";Aa.fillRect(0,0,s.width,s.height);$hcanv.siblings().remove();if(na>=3E4){var Na=
parseInt(na/3E4)+1;ya=Array(Na);ya[0]=Aa;for(D=1;D<Na;D++){s[xa]=3E4;var $a=s.cloneNode(true);s.parentNode.appendChild($a);ya[D]=$a.getContext("2d")}$a[xa]=na%3E4;na=3E4}s[xa]=na;xa=ba*W;var Wa=50/xa;s=1;for(D=0;D<E.length;D++){s=Na=E[D];if(Wa<=Na)break}Wa=s*xa;Aa.font="normal 9px 'Lucida Grande', sans-serif";Aa.fillStyle="#777";for(var Pa=aa/xa%s*xa,mb=Pa-Wa;Pa<za;Pa+=Wa){mb+=Wa;D=Math.round(Pa)+0.5;if(Y){Aa.moveTo(D,15);Aa.lineTo(D,0)}else{Aa.moveTo(15,D);Aa.lineTo(0,D)}Na=(mb-aa)/xa;if(s>=1)D=
Math.round(Na);else{D=(s+"").split(".")[1].length;D=Na.toFixed(D)-0}if(D!==0&&D!==1E3&&D%1E3===0)D=D/1E3+"K";if(Y){Aa.fillText(D,Pa+2,8);Aa.fillStyle="#777"}else{Na=(D+"").split("");for(D=0;D<Na.length;D++){Aa.fillText(Na[D],1,Pa+9+D*9);Aa.fillStyle="#777"}}Na=Wa/10;for(D=1;D<10;D++){var yb=Math.round(Pa+Na*D)+0.5;if(ya&&yb>na){ga++;Aa.stroke();if(ga>=ya.length){D=10;Pa=za;continue}Aa=ya[ga];Pa-=3E4;yb=Math.round(Pa+Na*D)+0.5}var Db=D%2?12:10;if(Y){Aa.moveTo(yb,15);Aa.lineTo(yb,Db)}else{Aa.moveTo(15,
yb);Aa.lineTo(Db,yb)}}}Aa.strokeStyle="#666";Aa.stroke()}I.scroll()}},E=[];for(l=0.1;l<1E5;l*=10){E.push(1*l);E.push(2*l);E.push(5*l)}w(true);try{var J=function(f){if(window.JSON&&JSON.stringify)return JSON.stringify(f);var o=arguments.callee;if(typeof f=="boolean"||typeof f=="number")return f+"";else if(typeof f=="string")return'"'+f.replace(/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,function(G){return"\\u"+("0000"+G.charCodeAt(0).toString(16)).slice(-4)})+
'"';else if(f.length){for(var s=0;s<f.length;s++)f[s]=o(f[s]);return"["+f.join(",")+"]"}else{s=[];for(var D in f)s.push(o(D)+":"+o(f[D]));return"{"+s.join(",")+"}"}};window.addEventListener("message",function(f){var o=parseInt(f.data.substr(0,f.data.indexOf(";")));try{f.source.postMessage("SVGe"+o+";"+J(eval(f.data)),"*")}catch(s){f.source.postMessage("SVGe"+o+";error:"+s.message,"*")}},false)}catch(F){window.embed_error=F}a(function(){window.svgCanvas=h;h.ready=svgEditor.ready});b.setLang=function(f,
o){a.pref("lang",f);a("#lang_select").val(f);if(o){h.runExtensions("langChanged",f);la();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(s,D){a(D).attr("title",a(s)[0].title)});a("#multiselected_panel div[id^=tool_align]").each(function(){a("#tool_pos"+this.id.substr(10))[0].title=this.title})}}};var g=[];b.ready=function(d){n?d():g.push(d)};
b.runCallbacks=function(){a.each(g,function(){this()});n=true};b.loadFromString=function(d){b.ready(function(){q(d)})};b.loadFromURL=function(d,l){l||(l={});var v=l.cache,A=l.callback;b.ready(function(){a.ajax({url:d,dataType:"text",cache:!!v,success:function(p){q(p,A)},error:function(p,K,R){p.status!=404&&p.responseText?q(p.responseText,A):a.alert(uiStrings.notification.URLloadFail+": \n"+R+"",A)}})})};b.loadFromDataURI=function(d){b.ready(function(){var l=d.substring(26);q(svgedit.utilities.decode64(l))})};
b.addExtension=function(){var d=arguments;a(function(){h&&h.addExtension.apply(this,d)})};return b}(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,dragAdjust:a&&a.dragAdjust?a.dragAdjust:1,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 q=this.dragCfg.dragAdjust,h=$(this).parent(),b=$(this),n=this.dragCfg.height,u=this.dragCfg.min,c=this.dragCfg.max,g=this.dragCfg.step,d=c-u>0?(c-u)/g:200,l=d/n*g,v=0,A=this.getAttribute("data-attr"),p=svgEditor.canvas,K=p.getSelectedElems(),R=svgedit.browser.isTouch(),O=true,I=d&&this.dragCfg.cursor?$("<div class='draginput_cursor' />").appendTo(h):false;b.attr("readonly","readonly");I&&!isNaN(this.dragCfg.start)&&I.css("top",this.dragCfg.start*
-1/l+n);this.adjustValue=function(Q,U){var N;Q=parseFloat(Q);if(isNaN(this.value))N=this.dragCfg.reset;else if($.isFunction(this.dragCfg.stepfunc)){N=this.dragCfg.stepfunc(this,Q);console.log(N)}else N=Number((Number(this.value)+Number(Q)).toFixed(5));if(c!==null)N=Math.min(N,c);if(u!==null)N=Math.max(N,u);I&&this.updateCursor(N);this.value=N;h.attr("data-value",N);$.isFunction(this.dragCfg.callback)&&this.dragCfg.callback(this,U)};h.toggleClass("draginput",h.is("label"));this.move=function(Q,U,N){if(R)Q=
Q.originalEvent.touches[0];if(v===0)v=U;U=(Q.pageY-v)*-1;v=Q.pageY;N=U*l*q;this.adjustValue(N.toFixed(g<1?1:0))};this.stop=function(){$("body").removeClass("dragging");h.removeClass("active");O=true;$(window).unbind("mousemove.draginput touchmove.draginput mouseup.draginput touchend.draginput");v=0;if(K[0]){var Q=p.undoMgr.finishUndoableChange();Q.isEmpty()||p.undoMgr.addCommandToHistory(Q)}this.adjustValue(0,O)};this.updateCursor=function(){var Q=parseFloat(this.value)*-1/l+n;I.css("top",Q)};this.start=
function(Q){if(R)Q=Q.originalEvent.touches[0];var U=Q.pageY,N=this.value,ha=this;p.undoMgr.beginUndoableChange(A,K);$("body").addClass("dragging");h.addClass("active");$(window).bind("mousemove.draginput touchmove.draginput",function(pa){ha.move(pa,U,parseFloat(N))});$(window).bind("mouseup.draginput touchend.draginput",function(){ha.stop()})};$(this).attr("readonly","readonly").attr("data-scale",l).attr("data-domain",n).attr("data-cursor",I!=false).bind("mousedown touchstart",function(Q){this.blur();
this.start(Q)}).bind("dblclick taphold",function(){this.removeAttribute("readonly","readonly");this.focus();this.select()}).keydown(function(Q){switch(Q.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(Q,U,N,ha){O&&p.undoMgr.beginUndoableChange(A,K);O=false;clearTimeout(window.undoTimeout);window.undoTimeout=setTimeout(function(){pa.stop()},
1E3);var pa=this;if(ha>0)this.adjustValue(this.dragCfg.step);else ha<0&&this.adjustValue(-this.dragCfg.step);Q.preventDefault()})})};$.fn.dragInput.updateCursor=function(a){var q=parseFloat(a.value),h=parseFloat(a.getAttribute("data-scale")),b=parseFloat(a.getAttribute("data-domain"));q=q*-1/h+b+"px";a=a.parentNode.lastChild;if(a.className=="draginput_cursor")a.style.top=q};svgedit=svgedit||{};
(function(){var a=this;if(!svgedit.contextmenu)svgedit.contextmenu={};a.contextMenuExtensions={};svgEditor.ready(function(){for(menuItem in contextMenuExtensions){var q=contextMenuExtensions[menuItem];Object.keys(a.contextMenuExtensions).length==0&&$("#cmenu_canvas").append("<li class='separator'>");var h=q.shortcut||"";$("#cmenu_canvas").append("<li class='disabled'><a href='#"+q.id+"'>"+q.label+"<span class='shortcut'>"+h+"</span></a></li>")}});svgedit.contextmenu.resetCustomMenus=function(){a.contextMenuExtensions=
{}};svgedit.contextmenu.add=function(q){if(q&&q.id&&q.label&&q.action&&typeof q.action=="function")if(q.id in a.contextMenuExtensions)console.error('Cannot add extension "'+q.id+'", an extension by that name already exists"');else{console.log("Registed contextmenu item: {id:"+q.id+", label:"+q.label+"}");a.contextMenuExtensions[q.id]=q}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=
function(q){return a.contextMenuExtensions[q]&&true};svgedit.contextmenu.getCustomHandler=function(q){return a.contextMenuExtensions[q].action}})();(function(a,q){function h(n){return!a(n).parents().andSelf().filter(function(){return a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}function b(n,u){var c=n.nodeName.toLowerCase();if("area"===c){c=n.parentNode;var g=c.name;if(!n.href||!g||c.nodeName.toLowerCase()!=="map")return false;c=a("img[usemap=#"+g+"]")[0];return!!c&&h(c)}return(/input|select|textarea|button|object/.test(c)?!n.disabled:"a"==c?n.href||u:u)&&h(n)}a.ui=a.ui||{};a.ui.version||(a.extend(a.ui,{version:"1.8.17",
keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}}),a.fn.extend({propAttr:a.fn.prop||a.fn.attr,_focus:a.fn.focus,focus:function(n,u){return typeof n=="number"?this.each(function(){var c=
this;setTimeout(function(){a(c).focus();u&&u.call(c)},n)}):this._focus.apply(this,arguments)},scrollParent:function(){var n;a.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?n=this.parents().filter(function(){return/(relative|absolute|fixed)/.test(a.curCSS(this,"position",1))&&/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0):n=this.parents().filter(function(){return/(auto|scroll)/.test(a.curCSS(this,
"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!n.length?a(document):n},zIndex:function(n){if(n!==q)return this.css("zIndex",n);if(this.length){n=a(this[0]);for(var u;n.length&&n[0]!==document;){u=n.css("position");if(u==="absolute"||u==="relative"||u==="fixed"){u=parseInt(n.css("zIndex"),10);if(!isNaN(u)&&u!==0)return u}n=n.parent()}}return 0},disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":
"mousedown")+".ui-disableSelection",function(n){n.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),a.each(["Width","Height"],function(n,u){function c(v,A,p,K){a.each(g,function(){A-=parseFloat(a.curCSS(v,"padding"+this,true))||0;p&&(A-=parseFloat(a.curCSS(v,"border"+this+"Width",true))||0);K&&(A-=parseFloat(a.curCSS(v,"margin"+this,true))||0)});return A}var g=u==="Width"?["Left","Right"]:["Top","Bottom"],d=u.toLowerCase(),l={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,
outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};a.fn["inner"+u]=function(v){if(v===q)return l["inner"+u].call(this);return this.each(function(){a(this).css(d,c(this,v)+"px")})};a.fn["outer"+u]=function(v,A){if(typeof v!="number")return l["outer"+u].call(this,v);return this.each(function(){a(this).css(d,c(this,v,true,A)+"px")})}}),a.extend(a.expr[":"],{data:function(n,u,c){return!!a.data(n,c[3])},focusable:function(n){return b(n,!isNaN(a.attr(n,"tabindex")))},tabbable:function(n){var u=a.attr(n,
"tabindex"),c=isNaN(u);return(c||u>=0)&&b(n,!c)}}),a(function(){var n=document.body,u=n.appendChild(u=document.createElement("div"));a.extend(u.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});a.support.minHeight=u.offsetHeight===100;a.support.selectstart="onselectstart"in u;n.removeChild(u).style.display="none"}),a.extend(a.ui,{plugin:{add:function(n,u,c){n=a.ui[n].prototype;for(var g in c){n.plugins[g]=n.plugins[g]||[];n.plugins[g].push([u,c[g]])}},call:function(n,u,c){if((u=n.plugins[u])&&
n.element[0].parentNode)for(var g=0;g<u.length;g++)n.options[u[g][0]]&&u[g][1].apply(n.element,c)}},contains:function(n,u){return document.compareDocumentPosition?n.compareDocumentPosition(u)&16:n!==u&&n.contains(u)},hasScroll:function(n,u){if(a(n).css("overflow")==="hidden")return false;var c=u&&u==="left"?"scrollLeft":"scrollTop",g=false;if(n[c]>0)return true;n[c]=1;g=n[c]>0;n[c]=0;return g},isOverAxis:function(n,u,c){return n>u&&n<u+c},isOver:function(n,u,c,g,d,l){return a.ui.isOverAxis(n,c,d)&&
a.ui.isOverAxis(u,g,l)}}))})(jQuery);
(function(a,q){if(a.cleanData){var h=a.cleanData;a.cleanData=function(n){for(var u=0,c;(c=n[u])!=null;u++)try{a(c).triggerHandler("remove")}catch(g){}h(n)}}else{var b=a.fn.remove;a.fn.remove=function(n,u){return this.each(function(){u||(!n||a.filter(n,[this]).length)&&a("*",this).add([this]).each(function(){try{a(this).triggerHandler("remove")}catch(c){}});return b.call(a(this),n,u)})}}a.widget=function(n,u,c){var g=n.split(".")[0],d;n=n.split(".")[1];d=g+"-"+n;c||(c=u,u=a.Widget);a.expr[":"][d]=
function(l){return!!a.data(l,n)};a[g]=a[g]||{};a[g][n]=function(l,v){arguments.length&&this._createWidget(l,v)};u=new u;u.options=a.extend(true,{},u.options);a[g][n].prototype=a.extend(true,u,{namespace:g,widgetName:n,widgetEventPrefix:a[g][n].prototype.widgetEventPrefix||n,widgetBaseClass:d},c);a.widget.bridge(n,a[g][n])};a.widget.bridge=function(n,u){a.fn[n]=function(c){var g=typeof c=="string",d=Array.prototype.slice.call(arguments,1),l=this;c=!g&&d.length?a.extend.apply(null,[true,c].concat(d)):
c;if(g&&c.charAt(0)==="_")return l;g?this.each(function(){var v=a.data(this,n),A=v&&a.isFunction(v[c])?v[c].apply(v,d):v;if(A!==v&&A!==q){l=A;return false}}):this.each(function(){var v=a.data(this,n);v?v.option(c||{})._init():a.data(this,n,new u(c,this))});return l}};a.Widget=function(n,u){arguments.length&&this._createWidget(n,u)};a.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(n,u){a.data(u,this.widgetName,this);this.element=a(u);this.options=
a.extend(true,{},this.options,this._getCreateOptions(),n);var c=this;this.element.bind("remove."+this.widgetName,function(){c.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return a.metadata&&a.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+
"-disabled ui-state-disabled")},widget:function(){return this.element},option:function(n,u){var c=n;if(arguments.length===0)return a.extend({},this.options);if(typeof n=="string"){if(u===q)return this.options[n];c={};c[n]=u}this._setOptions(c);return this},_setOptions:function(n){var u=this;a.each(n,function(c,g){u._setOption(c,g)});return this},_setOption:function(n,u){this.options[n]=u;n==="disabled"&&this.widget()[u?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",
u);return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(n,u,c){var g,d=this.options[n];c=c||{};u=a.Event(u);u.type=(n===this.widgetEventPrefix?n:this.widgetEventPrefix+n).toLowerCase();u.target=this.element[0];if(n=u.originalEvent)for(g in n)g in u||(u[g]=n[g]);this.element.trigger(u,c);return!(a.isFunction(d)&&d.call(this.element[0],u,c)===false||u.isDefaultPrevented())}}})(jQuery);
(function(a){var q=false;a(document).mouseup(function(){q=false});a.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var h=this;this.element.bind("mousedown."+this.widgetName,function(b){return h._mouseDown(b)}).bind("click."+this.widgetName,function(b){if(true===a.data(b.target,h.widgetName+".preventClickEvent")){a.removeData(b.target,h.widgetName+".preventClickEvent");b.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+
this.widgetName)},_mouseDown:function(h){if(!q){this._mouseStarted&&this._mouseUp(h);this._mouseDownEvent=h;var b=this,n=h.which==1,u=typeof this.options.cancel=="string"&&h.target.nodeName?a(h.target).closest(this.options.cancel).length:false;if(!n||u||!this._mouseCapture(h))return true;(this.mouseDelayMet=!this.options.delay)||(this._mouseDelayTimer=setTimeout(function(){b.mouseDelayMet=true},this.options.delay));if(this._mouseDistanceMet(h)&&this._mouseDelayMet(h)){this._mouseStarted=this._mouseStart(h)!==
false;if(!this._mouseStarted){h.preventDefault();return true}}true===a.data(h.target,this.widgetName+".preventClickEvent")&&a.removeData(h.target,this.widgetName+".preventClickEvent");this._mouseMoveDelegate=function(c){return b._mouseMove(c)};this._mouseUpDelegate=function(c){return b._mouseUp(c)};a(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);h.preventDefault();return q=true}},_mouseMove:function(h){if(a.browser.msie&&
!(document.documentMode>=9)&&!h.button)return this._mouseUp(h);if(this._mouseStarted){this._mouseDrag(h);return h.preventDefault()}this._mouseDistanceMet(h)&&this._mouseDelayMet(h)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,h)!==false,this._mouseStarted?this._mouseDrag(h):this._mouseUp(h));return!this._mouseStarted},_mouseUp:function(h){a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);this._mouseStarted&&
(this._mouseStarted=false,h.target==this._mouseDownEvent.target&&a.data(h.target,this.widgetName+".preventClickEvent",true),this._mouseStop(h));return false},_mouseDistanceMet:function(h){return Math.max(Math.abs(this._mouseDownEvent.pageX-h.pageX),Math.abs(this._mouseDownEvent.pageY-h.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery);
(function(a){a.widget("ui.draggable",a.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false},_create:function(){this.options.helper=="original"&&
!/^(?:r|a|f)/.test(this.element.css("position"))&&(this.element[0].style.position="relative");this.options.addClasses&&this.element.addClass("ui-draggable");this.options.disabled&&this.element.addClass("ui-draggable-disabled");this._mouseInit()},destroy:function(){if(this.element.data("draggable")){this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();return this}},_mouseCapture:function(q){var h=this.options;
if(this.helper||h.disabled||a(q.target).is(".ui-resizable-handle"))return false;this.handle=this._getHandle(q);if(!this.handle)return false;h.iframeFix&&a(h.iframeFix===true?"iframe":h.iframeFix).each(function(){a('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1E3}).css(a(this).offset()).appendTo("body")});return true},_mouseStart:function(q){var h=this.options;this.helper=
this._createHelper(q);this._cacheHelperProportions();a.ui.ddmanager&&(a.ui.ddmanager.current=this);this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.positionAbs=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};a.extend(this.offset,{click:{left:q.pageX-this.offset.left,top:q.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});
this.originalPosition=this.position=this._generatePosition(q);this.originalPageX=q.pageX;this.originalPageY=q.pageY;h.cursorAt&&this._adjustOffsetFromHelper(h.cursorAt);h.containment&&this._setContainment();if(this._trigger("start",q)===false){this._clear();return false}this._cacheHelperProportions();a.ui.ddmanager&&!h.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,q);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(q,true);a.ui.ddmanager&&a.ui.ddmanager.dragStart(this,q);return true},
_mouseDrag:function(q,h){this.position=this._generatePosition(q);this.positionAbs=this._convertPositionTo("absolute");if(!h){var b=this._uiHash();if(this._trigger("drag",q,b)===false){this._mouseUp({});return false}this.position=b.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";a.ui.ddmanager&&a.ui.ddmanager.drag(this,q);return false},_mouseStop:function(q){var h=
false;a.ui.ddmanager&&!this.options.dropBehaviour&&(h=a.ui.ddmanager.drop(this,q));this.dropped&&(h=this.dropped,this.dropped=false);if((!this.element[0]||!this.element[0].parentNode)&&this.options.helper=="original")return false;if(this.options.revert=="invalid"&&!h||this.options.revert=="valid"&&h||this.options.revert===true||a.isFunction(this.options.revert)&&this.options.revert.call(this.element,h)){var b=this;a(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),
function(){b._trigger("stop",q)!==false&&b._clear()})}else this._trigger("stop",q)!==false&&this._clear();return false},_mouseUp:function(q){this.options.iframeFix===true&&a("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)});a.ui.ddmanager&&a.ui.ddmanager.dragStop(this,q);return a.ui.mouse.prototype._mouseUp.call(this,q)},cancel:function(){this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear();return this},_getHandle:function(q){var h=!this.options.handle||
!a(this.options.handle,this.element).length?true:false;a(this.options.handle,this.element).find("*").andSelf().each(function(){this==q.target&&(h=true)});return h},_createHelper:function(q){var h=this.options;q=a.isFunction(h.helper)?a(h.helper.apply(this.element[0],[q])):h.helper=="clone"?this.element.clone().removeAttr("id"):this.element;q.parents("body").length||q.appendTo(h.appendTo=="parent"?this.element[0].parentNode:h.appendTo);q[0]!=this.element[0]&&!/(fixed|absolute)/.test(q.css("position"))&&
q.css("position","absolute");return q},_adjustOffsetFromHelper:function(q){typeof q=="string"&&(q=q.split(" "));a.isArray(q)&&(q={left:+q[0],top:+q[1]||0});"left"in q&&(this.offset.click.left=q.left+this.margins.left);"right"in q&&(this.offset.click.left=this.helperProportions.width-q.right+this.margins.left);"top"in q&&(this.offset.click.top=q.top+this.margins.top);"bottom"in q&&(this.offset.click.top=this.helperProportions.height-q.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=
this.helper.offsetParent();var q=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0])&&(q.left+=this.scrollParent.scrollLeft(),q.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&a.browser.msie)q={top:0,left:0};return{top:q.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:q.left+(parseInt(this.offsetParent.css("borderLeftWidth"),
10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var q=this.element.position();return{top:q.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:q.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),
10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var q=this.options;q.containment=="parent"&&(q.containment=this.helper[0].parentNode);if(q.containment=="document"||q.containment=="window")this.containment=[q.containment=="document"?0:a(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,q.containment=="document"?0:a(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,
(q.containment=="document"?0:a(window).scrollLeft())+a(q.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(q.containment=="document"?0:a(window).scrollTop())+(a(q.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(q.containment)&&q.containment.constructor!=Array){q=a(q.containment);var h=q[0];if(h){q.offset();var b=a(h).css("overflow")!=
"hidden";this.containment=[(parseInt(a(h).css("borderLeftWidth"),10)||0)+(parseInt(a(h).css("paddingLeft"),10)||0),(parseInt(a(h).css("borderTopWidth"),10)||0)+(parseInt(a(h).css("paddingTop"),10)||0),(b?Math.max(h.scrollWidth,h.offsetWidth):h.offsetWidth)-(parseInt(a(h).css("borderLeftWidth"),10)||0)-(parseInt(a(h).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(b?Math.max(h.scrollHeight,h.offsetHeight):h.offsetHeight)-(parseInt(a(h).css("borderTopWidth"),
10)||0)-(parseInt(a(h).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom];this.relative_container=q}}else q.containment.constructor==Array&&(this.containment=q.containment)},_convertPositionTo:function(q,h){h||(h=this.position);var b=q=="absolute"?1:-1,n=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,u=/(html|body)/i.test(n[0].tagName);return{top:h.top+
this.offset.relative.top*b+this.offset.parent.top*b-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():u?0:n.scrollTop())*b),left:h.left+this.offset.relative.left*b+this.offset.parent.left*b-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():u?0:n.scrollLeft())*b)}},_generatePosition:function(q){var h=this.options,b=this.cssPosition=="absolute"&&
(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,n=/(html|body)/i.test(b[0].tagName),u=q.pageX,c=q.pageY;if(this.originalPosition){var g;if(this.containment){if(this.relative_container){g=this.relative_container.offset();g=[this.containment[0]+g.left,this.containment[1]+g.top,this.containment[2]+g.left,this.containment[3]+g.top]}else g=this.containment;q.pageX-this.offset.click.left<g[0]&&(u=g[0]+this.offset.click.left);
q.pageY-this.offset.click.top<g[1]&&(c=g[1]+this.offset.click.top);q.pageX-this.offset.click.left>g[2]&&(u=g[2]+this.offset.click.left);q.pageY-this.offset.click.top>g[3]&&(c=g[3]+this.offset.click.top)}if(h.grid){c=h.grid[1]?this.originalPageY+Math.round((c-this.originalPageY)/h.grid[1])*h.grid[1]:this.originalPageY;c=g?c-this.offset.click.top<g[1]||c-this.offset.click.top>g[3]?c-this.offset.click.top<g[1]?c+h.grid[1]:c-h.grid[1]:c:c;u=h.grid[0]?this.originalPageX+Math.round((u-this.originalPageX)/
h.grid[0])*h.grid[0]:this.originalPageX;u=g?u-this.offset.click.left<g[0]||u-this.offset.click.left>g[2]?u-this.offset.click.left<g[0]?u+h.grid[0]:u-h.grid[0]:u:u}}return{top:c-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():n?0:b.scrollTop()),left:u-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(a.browser.safari&&a.browser.version<
526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():n?0:b.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging");this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove();this.helper=null;this.cancelHelperRemoval=false},_trigger:function(q,h,b){b=b||this._uiHash();a.ui.plugin.call(this,q,[h,b]);q=="drag"&&(this.positionAbs=this._convertPositionTo("absolute"));return a.Widget.prototype._trigger.call(this,q,h,
b)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}});a.extend(a.ui.draggable,{version:"1.8.17"});a.ui.plugin.add("draggable","connectToSortable",{start:function(q,h){var b=a(this).data("draggable"),n=b.options,u=a.extend({},h,{item:b.element});b.sortables=[];a(n.connectToSortable).each(function(){var c=a.data(this,"sortable");c&&!c.options.disabled&&(b.sortables.push({instance:c,shouldRevert:c.options.revert}),
c.refreshPositions(),c._trigger("activate",q,u))})},stop:function(q,h){var b=a(this).data("draggable"),n=a.extend({},h,{item:b.element});a.each(b.sortables,function(){this.instance.isOver?(this.instance.isOver=0,b.cancelHelperRemoval=true,this.instance.cancelHelperRemoval=false,this.shouldRevert&&(this.instance.options.revert=true),this.instance._mouseStop(q),this.instance.options.helper=this.instance.options._helper,b.options.helper=="original"&&this.instance.currentItem.css({top:"auto",left:"auto"})):
(this.instance.cancelHelperRemoval=false,this.instance._trigger("deactivate",q,n))})},drag:function(q,h){var b=a(this).data("draggable"),n=this;a.each(b.sortables,function(){this.instance.positionAbs=b.positionAbs;this.instance.helperProportions=b.helperProportions;this.instance.offset.click=b.offset.click;this.instance._intersectsWith(this.instance.containerCache)?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=a(n).clone().removeAttr("id").appendTo(this.instance.element).data("sortable-item",
true),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return h.helper[0]},q.target=this.instance.currentItem[0],this.instance._mouseCapture(q,true),this.instance._mouseStart(q,true,true),this.instance.offset.click.top=b.offset.click.top,this.instance.offset.click.left=b.offset.click.left,this.instance.offset.parent.left-=b.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=b.offset.parent.top-this.instance.offset.parent.top,
b._trigger("toSortable",q),b.dropped=this.instance.element,b.currentItem=b.element,this.instance.fromOutside=b),this.instance.currentItem&&this.instance._mouseDrag(q)):this.instance.isOver&&(this.instance.isOver=0,this.instance.cancelHelperRemoval=true,this.instance.options.revert=false,this.instance._trigger("out",q,this.instance._uiHash(this.instance)),this.instance._mouseStop(q,true),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&
this.instance.placeholder.remove(),b._trigger("fromSortable",q),b.dropped=false)})}});a.ui.plugin.add("draggable","cursor",{start:function(){var q=a("body"),h=a(this).data("draggable").options;q.css("cursor")&&(h._cursor=q.css("cursor"));q.css("cursor",h.cursor)},stop:function(){var q=a(this).data("draggable").options;q._cursor&&a("body").css("cursor",q._cursor)}});a.ui.plugin.add("draggable","opacity",{start:function(q,h){var b=a(h.helper),n=a(this).data("draggable").options;b.css("opacity")&&(n._opacity=
b.css("opacity"));b.css("opacity",n.opacity)},stop:function(q,h){var b=a(this).data("draggable").options;b._opacity&&a(h.helper).css("opacity",b._opacity)}});a.ui.plugin.add("draggable","scroll",{start:function(){var q=a(this).data("draggable");q.scrollParent[0]!=document&&q.scrollParent[0].tagName!="HTML"&&(q.overflowOffset=q.scrollParent.offset())},drag:function(q){var h=a(this).data("draggable"),b=h.options,n=false;if(h.scrollParent[0]!=document&&h.scrollParent[0].tagName!="HTML"){if(!b.axis||
b.axis!="x")h.overflowOffset.top+h.scrollParent[0].offsetHeight-q.pageY<b.scrollSensitivity?h.scrollParent[0].scrollTop=n=h.scrollParent[0].scrollTop+b.scrollSpeed:q.pageY-h.overflowOffset.top<b.scrollSensitivity&&(h.scrollParent[0].scrollTop=n=h.scrollParent[0].scrollTop-b.scrollSpeed);if(!b.axis||b.axis!="y")h.overflowOffset.left+h.scrollParent[0].offsetWidth-q.pageX<b.scrollSensitivity?h.scrollParent[0].scrollLeft=n=h.scrollParent[0].scrollLeft+b.scrollSpeed:q.pageX-h.overflowOffset.left<b.scrollSensitivity&&
(h.scrollParent[0].scrollLeft=n=h.scrollParent[0].scrollLeft-b.scrollSpeed)}else{if(!b.axis||b.axis!="x")q.pageY-a(document).scrollTop()<b.scrollSensitivity?n=a(document).scrollTop(a(document).scrollTop()-b.scrollSpeed):a(window).height()-(q.pageY-a(document).scrollTop())<b.scrollSensitivity&&(n=a(document).scrollTop(a(document).scrollTop()+b.scrollSpeed));if(!b.axis||b.axis!="y")q.pageX-a(document).scrollLeft()<b.scrollSensitivity?n=a(document).scrollLeft(a(document).scrollLeft()-b.scrollSpeed):
a(window).width()-(q.pageX-a(document).scrollLeft())<b.scrollSensitivity&&(n=a(document).scrollLeft(a(document).scrollLeft()+b.scrollSpeed))}n!==false&&a.ui.ddmanager&&!b.dropBehaviour&&a.ui.ddmanager.prepareOffsets(h,q)}});a.ui.plugin.add("draggable","snap",{start:function(){var q=a(this).data("draggable"),h=q.options;q.snapElements=[];a(h.snap.constructor!=String?h.snap.items||":data(draggable)":h.snap).each(function(){var b=a(this),n=b.offset();this!=q.element[0]&&q.snapElements.push({item:this,
width:b.outerWidth(),height:b.outerHeight(),top:n.top,left:n.left})})},drag:function(q,h){for(var b=a(this).data("draggable"),n=b.options,u=n.snapTolerance,c=h.offset.left,g=c+b.helperProportions.width,d=h.offset.top,l=d+b.helperProportions.height,v=b.snapElements.length-1;v>=0;v--){var A=b.snapElements[v].left,p=A+b.snapElements[v].width,K=b.snapElements[v].top,R=K+b.snapElements[v].height;if(A-u<c&&c<p+u&&K-u<d&&d<R+u||A-u<c&&c<p+u&&K-u<l&&l<R+u||A-u<g&&g<p+u&&K-u<d&&d<R+u||A-u<g&&g<p+u&&K-u<l&&
l<R+u){if(n.snapMode!="inner"){var O=Math.abs(K-l)<=u,I=Math.abs(R-d)<=u,Q=Math.abs(A-g)<=u,U=Math.abs(p-c)<=u;O&&(h.position.top=b._convertPositionTo("relative",{top:K-b.helperProportions.height,left:0}).top-b.margins.top);I&&(h.position.top=b._convertPositionTo("relative",{top:R,left:0}).top-b.margins.top);Q&&(h.position.left=b._convertPositionTo("relative",{top:0,left:A-b.helperProportions.width}).left-b.margins.left);U&&(h.position.left=b._convertPositionTo("relative",{top:0,left:p}).left-b.margins.left)}var N=
O||I||Q||U;if(n.snapMode!="outer"){O=Math.abs(K-d)<=u;I=Math.abs(R-l)<=u;Q=Math.abs(A-c)<=u;U=Math.abs(p-g)<=u;O&&(h.position.top=b._convertPositionTo("relative",{top:K,left:0}).top-b.margins.top);I&&(h.position.top=b._convertPositionTo("relative",{top:R-b.helperProportions.height,left:0}).top-b.margins.top);Q&&(h.position.left=b._convertPositionTo("relative",{top:0,left:A}).left-b.margins.left);U&&(h.position.left=b._convertPositionTo("relative",{top:0,left:p-b.helperProportions.width}).left-b.margins.left)}!b.snapElements[v].snapping&&
(O||I||Q||U||N)&&b.options.snap.snap&&b.options.snap.snap.call(b.element,q,a.extend(b._uiHash(),{snapItem:b.snapElements[v].item}));b.snapElements[v].snapping=O||I||Q||U||N}else{b.snapElements[v].snapping&&b.options.snap.release&&b.options.snap.release.call(b.element,q,a.extend(b._uiHash(),{snapItem:b.snapElements[v].item}));b.snapElements[v].snapping=false}}}});a.ui.plugin.add("draggable","stack",{start:function(){var q=a(this).data("draggable").options;q=a.makeArray(a(q.stack)).sort(function(b,
n){return(parseInt(a(b).css("zIndex"),10)||0)-(parseInt(a(n).css("zIndex"),10)||0)});if(q.length){var h=parseInt(q[0].style.zIndex)||0;a(q).each(function(b){this.style.zIndex=h+b});this[0].style.zIndex=h+q.length}}});a.ui.plugin.add("draggable","zIndex",{start:function(q,h){var b=a(h.helper),n=a(this).data("draggable").options;b.css("zIndex")&&(n._zIndex=b.css("zIndex"));b.css("zIndex",n.zIndex)},stop:function(q,h){var b=a(this).data("draggable").options;b._zIndex&&a(h.helper).css("zIndex",b._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 q=this,h=this.options,b=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),n=h.values&&h.values.length||1,u=[];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"+(h.disabled?" ui-slider-disabled ui-disabled":""));this.range=a([]);h.range&&(h.range===true&&(h.values||(h.values=[this._valueMin(),this._valueMin()]),h.values.length&&h.values.length!==2&&(h.values=[h.values[0],h.values[0]])),this.range=a("<div></div>").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(h.range==="min"||h.range==="max"?" ui-slider-range-"+h.range:"")));for(var c=b.length;c<n;c+=1)u.push("<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>");
this.handles=b.add(a(u.join("")).appendTo(q.element));this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(g){g.preventDefault()}).hover(function(){h.disabled||a(this).addClass("ui-state-hover")},function(){a(this).removeClass("ui-state-hover")}).focus(function(){h.disabled?a(this).blur():(a(".ui-slider .ui-state-focus").removeClass("ui-state-focus"),a(this).addClass("ui-state-focus"))}).blur(function(){a(this).removeClass("ui-state-focus")});this.handles.each(function(g){a(this).data("index.ui-slider-handle",
g)});this.handles.keydown(function(g){var d=true,l=a(this).data("index.ui-slider-handle"),v,A,p;if(!q.options.disabled){switch(g.keyCode){case a.ui.keyCode.HOME:case a.ui.keyCode.END:case a.ui.keyCode.PAGE_UP:case a.ui.keyCode.PAGE_DOWN:case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:d=false;if(!q._keySliding){q._keySliding=true;a(this).addClass("ui-state-active");v=q._start(g,l);if(v===false)return}}v=q.options.step;q.options.values&&q.options.values.length?
A=p=q.values(l):A=p=q.value();switch(g.keyCode){case a.ui.keyCode.HOME:p=q._valueMin();break;case a.ui.keyCode.END:p=q._valueMax();break;case a.ui.keyCode.PAGE_UP:p=q._trimAlignValue(A+(q._valueMax()-q._valueMin())/5);break;case a.ui.keyCode.PAGE_DOWN:p=q._trimAlignValue(A-(q._valueMax()-q._valueMin())/5);break;case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:if(A===q._valueMax())return;p=q._trimAlignValue(A+v);break;case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:if(A===q._valueMin())return;p=q._trimAlignValue(A-
v)}q._slide(g,l,p);return d}}).keyup(function(g){var d=a(this).data("index.ui-slider-handle");q._keySliding&&(q._keySliding=false,q._stop(g,d),q._change(g,d),a(this).removeClass("ui-state-active"))});this._refreshValue();this._animateOff=false},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");this._mouseDestroy();
return this},_mouseCapture:function(q){var h=this.options,b,n,u,c,g;if(h.disabled)return false;this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();b=this._normValueFromMouse({x:q.pageX,y:q.pageY});n=this._valueMax()-this._valueMin()+1;c=this;this.handles.each(function(d){var l=Math.abs(b-c.values(d));n>l&&(n=l,u=a(this),g=d)});h.range===true&&this.values(1)===h.min&&(g+=1,u=a(this.handles[g]));if(this._start(q,g)===false)return false;
this._mouseSliding=true;c._handleIndex=g;u.addClass("ui-state-active").focus();h=u.offset();this._clickOffset=!a(q.target).parents().andSelf().is(".ui-slider-handle")?{left:0,top:0}:{left:q.pageX-h.left-u.width()/2,top:q.pageY-h.top-u.height()/2-(parseInt(u.css("borderTopWidth"),10)||0)-(parseInt(u.css("borderBottomWidth"),10)||0)+(parseInt(u.css("marginTop"),10)||0)};this.handles.hasClass("ui-state-hover")||this._slide(q,g,b);return this._animateOff=true},_mouseStart:function(){return true},_mouseDrag:function(q){var h=
this._normValueFromMouse({x:q.pageX,y:q.pageY});this._slide(q,this._handleIndex,h);return false},_mouseStop:function(q){this.handles.removeClass("ui-state-active");this._mouseSliding=false;this._stop(q,this._handleIndex);this._change(q,this._handleIndex);this._clickOffset=this._handleIndex=null;return this._animateOff=false},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(q){var h,b;this.orientation==="horizontal"?
(h=this.elementSize.width,b=q.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(h=this.elementSize.height,b=q.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0));q=b/h;q>1&&(q=1);q<0&&(q=0);this.orientation==="vertical"&&(q=1-q);h=this._valueMax()-this._valueMin();return this._trimAlignValue(this._valueMin()+q*h)},_start:function(q,h){var b={handle:this.handles[h],value:this.value()};this.options.values&&this.options.values.length&&(b.value=this.values(h),
b.values=this.values());return this._trigger("start",q,b)},_slide:function(q,h,b){var n,u,c;this.options.values&&this.options.values.length?(n=this.values(h?0:1),this.options.values.length===2&&this.options.range===true&&(h===0&&b>n||h===1&&b<n)&&(b=n),b!==this.values(h)&&(u=this.values(),u[h]=b,c=this._trigger("slide",q,{handle:this.handles[h],value:b,values:u}),this.values(h?0:1),c!==false&&this.values(h,b,true))):b!==this.value()&&(c=this._trigger("slide",q,{handle:this.handles[h],value:b}),c!==
false&&this.value(b))},_stop:function(q,h){var b={handle:this.handles[h],value:this.value()};this.options.values&&this.options.values.length&&(b.value=this.values(h),b.values=this.values());this._trigger("stop",q,b)},_change:function(q,h){if(!this._keySliding&&!this._mouseSliding){var b={handle:this.handles[h],value:this.value()};this.options.values&&this.options.values.length&&(b.value=this.values(h),b.values=this.values());this._trigger("change",q,b)}},value:function(q){if(arguments.length){this.options.value=
this._trimAlignValue(q);this._refreshValue();this._change(null,0)}else return this._value()},values:function(q,h){var b,n,u;if(arguments.length>1){this.options.values[q]=this._trimAlignValue(h);this._refreshValue();this._change(null,q)}else{if(!arguments.length)return this._values();if(!a.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(q):this.value();b=this.options.values;n=arguments[0];for(u=0;u<b.length;u+=1){b[u]=this._trimAlignValue(n[u]);this._change(null,
u)}this._refreshValue()}},_setOption:function(q,h){var b,n=0;a.isArray(this.options.values)&&(n=this.options.values.length);a.Widget.prototype._setOption.apply(this,arguments);switch(q){case "disabled":h?(this.handles.filter(".ui-state-focus").blur(),this.handles.removeClass("ui-state-hover"),this.handles.propAttr("disabled",true),this.element.addClass("ui-disabled")):(this.handles.propAttr("disabled",false),this.element.removeClass("ui-disabled"));break;case "orientation":this._detectOrientation();
this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation);this._refreshValue();break;case "value":this._animateOff=true;this._refreshValue();this._change(null,0);this._animateOff=false;break;case "values":this._animateOff=true;this._refreshValue();for(b=0;b<n;b+=1)this._change(null,b);this._animateOff=false}},_value:function(){var q=this.options.value;return q=this._trimAlignValue(q)},_values:function(q){var h,b;if(arguments.length){h=this.options.values[q];
return h=this._trimAlignValue(h)}h=this.options.values.slice();for(b=0;b<h.length;b+=1)h[b]=this._trimAlignValue(h[b]);return h},_trimAlignValue:function(q){if(q<=this._valueMin())return this._valueMin();if(q>=this._valueMax())return this._valueMax();var h=this.options.step>0?this.options.step:1,b=(q-this._valueMin())%h;q=q-b;Math.abs(b)*2>=h&&(q+=b>0?h:-h);return parseFloat(q.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var q=
this.options.range,h=this.options,b=this,n=this._animateOff?false:h.animate,u,c={},g,d,l,v;this.options.values&&this.options.values.length?this.handles.each(function(A){u=(b.values(A)-b._valueMin())/(b._valueMax()-b._valueMin())*100;c[b.orientation==="horizontal"?"left":"bottom"]=u+"%";a(this).stop(1,1)[n?"animate":"css"](c,h.animate);b.options.range===true&&(b.orientation==="horizontal"?(A===0&&b.range.stop(1,1)[n?"animate":"css"]({left:u+"%"},h.animate),A===1&&b.range[n?"animate":"css"]({width:u-
g+"%"},{queue:false,duration:h.animate})):(A===0&&b.range.stop(1,1)[n?"animate":"css"]({bottom:u+"%"},h.animate),A===1&&b.range[n?"animate":"css"]({height:u-g+"%"},{queue:false,duration:h.animate})));g=u}):(d=this.value(),l=this._valueMin(),v=this._valueMax(),u=v!==l?(d-l)/(v-l)*100:0,c[b.orientation==="horizontal"?"left":"bottom"]=u+"%",this.handle.stop(1,1)[n?"animate":"css"](c,h.animate),q==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[n?"animate":"css"]({width:u+"%"},h.animate),
q==="max"&&this.orientation==="horizontal"&&this.range[n?"animate":"css"]({width:100-u+"%"},{queue:false,duration:h.animate}),q==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[n?"animate":"css"]({height:u+"%"},h.animate),q==="max"&&this.orientation==="vertical"&&this.range[n?"animate":"css"]({height:100-u+"%"},{queue:false,duration:h.animate}))}});a.extend(a.ui.slider,{version:"1.8.17"})})(jQuery);(function(a){Math.precision=function(c,g){if(g===undefined)g=0;return Math.round(c*Math.pow(10,g))/Math.pow(10,g)};var q=function(c,g){var d=this,l=c.find("img:first"),v=0,A=100,p=100,K=0,R=100,O=100,I=0,Q=0,U,N,ha=[],pa=function(V){for(var X=0;X<ha.length;X++)ha[X].call(d,d,V)},fa=function(V){var X=c.offset();U={l:X.left|0,t:X.top|0};clearTimeout(N);N=setTimeout(function(){ua.call(d,V)},0);a(document).bind("mousemove",T).bind("mouseup",Z);V.preventDefault()},T=function(V){clearTimeout(N);N=setTimeout(function(){ua.call(d,
V)},0);V.stopPropagation();V.preventDefault();return false},Z=function(V){a(document).unbind("mouseup",Z).unbind("mousemove",T);V.stopPropagation();V.preventDefault();return false},ua=function(V){var X=V.pageX-U.l;V=V.pageY-U.t;var oa=c.w,qa=c.h;if(X<0)X=0;else if(X>oa)X=oa;if(V<0)V=0;else if(V>qa)V=qa;ja.call(d,"xy",{x:X/oa*p+v,y:V/qa*O+K})},ja=function(V,X,oa){if(X===undefined){if(V===undefined||V==null)V="xy";switch(V.toLowerCase()){case "x":return I;case "y":return Q;default:return{x:I,y:Q}}}if(!(oa!=
null&&oa==d)){var qa=false,ma,la;if(V==null)V="xy";switch(V.toLowerCase()){case "x":ma=X&&(X.x&&X.x|0||X|0)||0;break;case "y":la=X&&(X.y&&X.y|0||X|0)||0;break;default:ma=X&&X.x&&X.x|0||0;la=X&&X.y&&X.y|0||0}if(ma!=null){if(ma<v)ma=v;else if(ma>A)ma=A;if(I!=ma){I=ma;qa=true}}if(la!=null){if(la<K)la=K;else if(la>R)la=R;if(Q!=la){Q=la;qa=true}}qa&&pa.call(d,oa||d)}},da=function(V){a.isFunction(V)&&ha.push(V)};a.extend(true,d,{val:ja,range:function(V,X){if(X===undefined){if(V===undefined||V==null)V="all";
switch(V.toLowerCase()){case "minx":return v;case "maxx":return A;case "rangex":return{minX:v,maxX:A,rangeX:p};case "miny":return K;case "maxy":return R;case "rangey":return{minY:K,maxY:R,rangeY:O};default:return{minX:v,maxX:A,rangeX:p,minY:K,maxY:R,rangeY:O}}}var oa,qa,ma,la;if(V==null)V="all";switch(V.toLowerCase()){case "minx":oa=X&&(X.minX&&X.minX|0||X|0)||0;break;case "maxx":qa=X&&(X.maxX&&X.maxX|0||X|0)||0;break;case "rangex":oa=X&&X.minX&&X.minX|0||0;qa=X&&X.maxX&&X.maxX|0||0;break;case "miny":ma=
X&&(X.minY&&X.minY|0||X|0)||0;break;case "maxy":la=X&&(X.maxY&&X.maxY|0||X|0)||0;break;case "rangey":ma=X&&X.minY&&X.minY|0||0;la=X&&X.maxY&&X.maxY|0||0;break;default:oa=X&&X.minX&&X.minX|0||0;qa=X&&X.maxX&&X.maxX|0||0;ma=X&&X.minY&&X.minY|0||0;la=X&&X.maxY&&X.maxY|0||0}if(oa!=null&&v!=oa){v=oa;p=A-v}if(qa!=null&&A!=qa){A=qa;p=A-v}if(ma!=null&&K!=ma){K=ma;O=R-K}if(la!=null&&R!=la){R=la;O=R-K}},bind:da,unbind:function(V){if(a.isFunction(V))for(var X;(X=a.inArray(V,ha))!=-1;)ha.splice(X,1)},destroy:function(){a(document).unbind("mouseup",
Z).unbind("mousemove",T);c.unbind("mousedown",fa);ha=l=c=null}});l.src=g.arrow&&g.arrow.image;l.w=g.arrow&&g.arrow.width||l.width();l.h=g.arrow&&g.arrow.height||l.height();c.w=g.map&&g.map.width||c.width();c.h=g.map&&g.map.height||c.height();c.bind("mousedown",fa);da.call(d,function(){var V=0,X=0,oa=c.w,qa=c.h,ma=l.w,la=l.h;setTimeout(function(){if(p>0)V=I==A?oa:I/p*oa|0;if(O>0)X=Q==R?qa:Q/O*qa|0;if(ma>=oa)V=(oa>>1)-(ma>>1);else V-=ma>>1;if(la>=qa)X=(qa>>1)-(la>>1);else X-=la>>1;l.css({left:V+"px",
top:X+"px"})},0)})},h=function(c,g,d,l){var v=this;c=c.find("td.Text input");var A=c.eq(3),p=c.eq(4),K=c.eq(5),R=c.length>7?c.eq(6):null,O=c.eq(0),I=c.eq(1),Q=c.eq(2),U=c.eq(c.length>7?7:6),N=c.length>7?c.eq(8):null,ha=function(ja){if(!(ja.target.value==""&&ja.target!=U.get(0)&&(d!=null&&ja.target!=d.get(0)||d==null))){if(!T(ja))return ja;switch(ja.target){case A.get(0):switch(ja.keyCode){case 38:A.val(Z.call(v,(A.val()<<0)+1,0,255));g.val("r",A.val(),ja.target);return false;case 40:A.val(Z.call(v,
(A.val()<<0)-1,0,255));g.val("r",A.val(),ja.target);return false}break;case p.get(0):switch(ja.keyCode){case 38:p.val(Z.call(v,(p.val()<<0)+1,0,255));g.val("g",p.val(),ja.target);return false;case 40:p.val(Z.call(v,(p.val()<<0)-1,0,255));g.val("g",p.val(),ja.target);return false}break;case K.get(0):switch(ja.keyCode){case 38:K.val(Z.call(v,(K.val()<<0)+1,0,255));g.val("b",K.val(),ja.target);return false;case 40:K.val(Z.call(v,(K.val()<<0)-1,0,255));g.val("b",K.val(),ja.target);return false}break;
case R&&R.get(0):switch(ja.keyCode){case 38:R.val(Z.call(v,parseFloat(R.val())+1,0,100));g.val("a",Math.precision(R.val()*255/100,l),ja.target);return false;case 40:R.val(Z.call(v,parseFloat(R.val())-1,0,100));g.val("a",Math.precision(R.val()*255/100,l),ja.target);return false}break;case O.get(0):switch(ja.keyCode){case 38:O.val(Z.call(v,(O.val()<<0)+1,0,360));g.val("h",O.val(),ja.target);return false;case 40:O.val(Z.call(v,(O.val()<<0)-1,0,360));g.val("h",O.val(),ja.target);return false}break;case I.get(0):switch(ja.keyCode){case 38:I.val(Z.call(v,
(I.val()<<0)+1,0,100));g.val("s",I.val(),ja.target);return false;case 40:I.val(Z.call(v,(I.val()<<0)-1,0,100));g.val("s",I.val(),ja.target);return false}break;case Q.get(0):switch(ja.keyCode){case 38:Q.val(Z.call(v,(Q.val()<<0)+1,0,100));g.val("v",Q.val(),ja.target);return false;case 40:Q.val(Z.call(v,(Q.val()<<0)-1,0,100));g.val("v",Q.val(),ja.target);return false}}}},pa=function(ja){if(!(ja.target.value==""&&ja.target!=U.get(0)&&(d!=null&&ja.target!=d.get(0)||d==null))){if(!T(ja))return ja;switch(ja.target){case A.get(0):A.val(Z.call(v,
A.val(),0,255));g.val("r",A.val(),ja.target);break;case p.get(0):p.val(Z.call(v,p.val(),0,255));g.val("g",p.val(),ja.target);break;case K.get(0):K.val(Z.call(v,K.val(),0,255));g.val("b",K.val(),ja.target);break;case R&&R.get(0):R.val(Z.call(v,R.val(),0,100));g.val("a",Math.precision(R.val()*255/100,l),ja.target);break;case O.get(0):O.val(Z.call(v,O.val(),0,360));g.val("h",O.val(),ja.target);break;case I.get(0):I.val(Z.call(v,I.val(),0,100));g.val("s",I.val(),ja.target);break;case Q.get(0):Q.val(Z.call(v,
Q.val(),0,100));g.val("v",Q.val(),ja.target);break;case U.get(0):U.val(U.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));d&&d.val(U.val());g.val("hex",U.val()!=""?U.val():null,ja.target);break;case d&&d.get(0):d.val(d.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,6));U.val(d.val());g.val("hex",d.val()!=""?d.val():null,ja.target);break;case N&&N.get(0):N.val(N.val().replace(/[^a-fA-F0-9]/g,"").toLowerCase().substring(0,2));g.val("a",N.val()!=null?parseInt(N.val(),16):
null,ja.target)}}},fa=function(ja){if(g.val()!=null)switch(ja.target){case A.get(0):A.val(g.val("r"));break;case p.get(0):p.val(g.val("g"));break;case K.get(0):K.val(g.val("b"));break;case R&&R.get(0):R.val(Math.precision(g.val("a")*100/255,l));break;case O.get(0):O.val(g.val("h"));break;case I.get(0):I.val(g.val("s"));break;case Q.get(0):Q.val(g.val("v"));break;case U.get(0):case d&&d.get(0):U.val(g.val("hex"));d&&d.val(g.val("hex"));break;case N&&N.get(0):N.val(g.val("ahex").substring(6))}},T=function(ja){switch(ja.keyCode){case 9:case 16:case 29:case 37:case 39:return false;
case "c".charCodeAt():case "v".charCodeAt():if(ja.ctrlKey)return false}return true},Z=function(ja,da,V){if(ja==""||isNaN(ja))return da;if(ja>V)return V;if(ja<da)return da;return ja},ua=function(ja,da){var V=ja.val("all");if(da!=A.get(0))A.val(V!=null?V.r:"");if(da!=p.get(0))p.val(V!=null?V.g:"");if(da!=K.get(0))K.val(V!=null?V.b:"");if(R&&da!=R.get(0))R.val(V!=null?Math.precision(V.a*100/255,l):"");if(da!=O.get(0))O.val(V!=null?V.h:"");if(da!=I.get(0))I.val(V!=null?V.s:"");if(da!=Q.get(0))Q.val(V!=
null?V.v:"");if(da!=U.get(0)&&(d&&da!=d.get(0)||!d))U.val(V!=null?V.hex:"");if(d&&da!=d.get(0)&&da!=U.get(0))d.val(V!=null?V.hex:"");if(N&&da!=N.get(0))N.val(V!=null?V.ahex.substring(6):"")};a.extend(true,v,{destroy:function(){A.add(p).add(K).add(R).add(O).add(I).add(Q).add(U).add(d).add(N).unbind("keyup",pa).unbind("blur",fa);A.add(p).add(K).add(R).add(O).add(I).add(Q).unbind("keydown",ha);g.unbind(ua);N=U=Q=I=O=R=K=p=A=null}});A.add(p).add(K).add(R).add(O).add(I).add(Q).add(U).add(d).add(N).bind("keyup",
pa).bind("blur",fa);A.add(p).add(K).add(R).add(O).add(I).add(Q).bind("keydown",ha);g.bind(ua)};a.jPicker={List:[],Color:function(c){var g=this,d,l,v,A,p,K,R,O=[],I=function(U){for(var N=0;N<O.length;N++)O[N].call(g,g,U)},Q=function(U,N,ha){if(N===undefined){if(U===undefined||U==null||U=="")U="all";if(d==null)return null;switch(U.toLowerCase()){case "ahex":return u.rgbaToHex({r:d,g:l,b:v,a:A});case "hex":return Q("ahex").substring(0,6);case "all":return{r:d,g:l,b:v,a:A,h:p,s:K,v:R,hex:Q.call(g,"hex"),
ahex:Q.call(g,"ahex")};default:N={};for(var pa=0;pa<U.length;pa++)switch(U.charAt(pa)){case "r":if(U.length==1)N=d;else N.r=d;break;case "g":if(U.length==1)N=l;else N.g=l;break;case "b":if(U.length==1)N=v;else N.b=v;break;case "a":if(U.length==1)N=A;else N.a=A;break;case "h":if(U.length==1)N=p;else N.h=p;break;case "s":if(U.length==1)N=K;else N.s=K;break;case "v":if(U.length==1)N=R;else N.v=R}return N=={}?Q.call(g,"all"):N}}if(!(ha!=null&&ha==g)){var fa=false;if(U==null)U="";if(N==null){if(d!=null){d=
null;fa=true}if(l!=null){l=null;fa=true}if(v!=null){v=null;fa=true}if(A!=null){A=null;fa=true}if(p!=null){p=null;fa=true}if(K!=null){K=null;fa=true}if(R!=null){R=null;fa=true}fa&&I.call(g,ha||g)}else switch(U.toLowerCase()){case "ahex":case "hex":N=u.hexToRgba(N&&(N.ahex||N.hex)||N||"00000000");Q.call(g,"rgba",{r:N.r,g:N.g,b:N.b,a:U=="ahex"?N.a:A!=null?A:255},ha);break;default:if(N&&(N.ahex!=null||N.hex!=null)){Q.call(g,"ahex",N.ahex||N.hex||"00000000",ha);break}var T={},Z=false,ua=false;if(N.r!==
undefined&&!U.indexOf("r")==-1)U+="r";if(N.g!==undefined&&!U.indexOf("g")==-1)U+="g";if(N.b!==undefined&&!U.indexOf("b")==-1)U+="b";if(N.a!==undefined&&!U.indexOf("a")==-1)U+="a";if(N.h!==undefined&&!U.indexOf("h")==-1)U+="h";if(N.s!==undefined&&!U.indexOf("s")==-1)U+="s";if(N.v!==undefined&&!U.indexOf("v")==-1)U+="v";for(pa=0;pa<U.length;pa++)switch(U.charAt(pa)){case "r":if(ua)continue;Z=true;T.r=N&&N.r&&N.r|0||N&&N|0||0;if(T.r<0)T.r=0;else if(T.r>255)T.r=255;if(d!=T.r){d=T.r;fa=true}break;case "g":if(ua)continue;
Z=true;T.g=N&&N.g&&N.g|0||N&&N|0||0;if(T.g<0)T.g=0;else if(T.g>255)T.g=255;if(l!=T.g){l=T.g;fa=true}break;case "b":if(ua)continue;Z=true;T.b=N&&N.b&&N.b|0||N&&N|0||0;if(T.b<0)T.b=0;else if(T.b>255)T.b=255;if(v!=T.b){v=T.b;fa=true}break;case "a":T.a=N&&N.a!=null?N.a|0:N!=null?N|0:255;if(T.a<0)T.a=0;else if(T.a>255)T.a=255;if(A!=T.a){A=T.a;fa=true}break;case "h":if(Z)continue;ua=true;T.h=N&&N.h&&N.h|0||N&&N|0||0;if(T.h<0)T.h=0;else if(T.h>360)T.h=360;if(p!=T.h){p=T.h;fa=true}break;case "s":if(Z)continue;
ua=true;T.s=N&&N.s!=null?N.s|0:N!=null?N|0:100;if(T.s<0)T.s=0;else if(T.s>100)T.s=100;if(K!=T.s){K=T.s;fa=true}break;case "v":if(Z)continue;ua=true;T.v=N&&N.v!=null?N.v|0:N!=null?N|0:100;if(T.v<0)T.v=0;else if(T.v>100)T.v=100;if(R!=T.v){R=T.v;fa=true}}if(fa){if(Z){d=d||0;l=l||0;v=v||0;N=u.rgbToHsv({r:d,g:l,b:v});p=N.h;K=N.s;R=N.v}else if(ua){p=p||0;K=K!=null?K:100;R=R!=null?R:100;N=u.hsvToRgb({h:p,s:K,v:R});d=N.r;l=N.g;v=N.b}A=A!=null?A:255;I.call(g,ha||g)}}}};a.extend(true,g,{val:Q,bind:function(U){a.isFunction(U)&&
O.push(U)},unbind:function(U){if(a.isFunction(U))for(var N;(N=a.inArray(U,O))!=-1;)O.splice(N,1)},destroy:function(){O=null}});if(c)if(c.ahex!=null)Q("ahex",c);else if(c.hex!=null)Q((c.a!=null?"a":"")+"hex",c.a!=null?{ahex:c.hex+u.intToHex(c.a)}:c);else if(c.r!=null&&c.g!=null&&c.b!=null)Q("rgb"+(c.a!=null?"a":""),c);else if(c.h!=null&&c.s!=null&&c.v!=null)Q("hsv"+(c.a!=null?"a":""),c)},ColorMethods:{hexToRgba:function(c){c=this.validateHex(c);if(c=="")return{r:null,g:null,b:null,a:null};var g="00",
d="00",l="00",v="255";if(c.length==6)c+="ff";if(c.length>6){g=c.substring(0,2);d=c.substring(2,4);l=c.substring(4,6);v=c.substring(6,c.length)}else{if(c.length>4){g=c.substring(4,c.length);c=c.substring(0,4)}if(c.length>2){d=c.substring(2,c.length);c=c.substring(0,2)}if(c.length>0)l=c.substring(0,c.length)}return{r:this.hexToInt(g),g:this.hexToInt(d),b:this.hexToInt(l),a:this.hexToInt(v)}},validateHex:function(c){if(typeof c=="object")return"";c=c.toLowerCase().replace(/[^a-f0-9]/g,"");if(c.length>
8)c=c.substring(0,8);return c},rgbaToHex:function(c){return this.intToHex(c.r)+this.intToHex(c.g)+this.intToHex(c.b)+this.intToHex(c.a)},intToHex:function(c){c=(c|0).toString(16);if(c.length==1)c="0"+c;return c.toLowerCase()},hexToInt:function(c){return parseInt(c,16)},rgbToHsv:function(c){var g=c.r/255,d=c.g/255;c=c.b/255;var l={h:0,s:0,v:0},v=0,A=0;if(g>=d&&g>=c){A=g;v=d>c?c:d}else if(d>=c&&d>=g){A=d;v=g>c?c:g}else{A=c;v=d>g?g:d}l.v=A;l.s=A?(A-v)/A:0;if(l.s){v=A-v;l.h=g==A?(d-c)/v:d==A?2+(c-g)/
v:4+(g-d)/v;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(c){var g={r:0,g:0,b:0,a:100},d=c.h,l=c.s;c=c.v;if(l==0)g.r=c==0?g.g=g.b=0:g.g=g.b=c*255/100|0;else{if(d==360)d=0;d/=60;l/=100;c/=100;var v=d|0,A=d-v;d=c*(1-l);var p=c*(1-l*A);l=c*(1-l*(1-A));switch(v){case 0:g.r=c;g.g=l;g.b=d;break;case 1:g.r=p;g.g=c;g.b=d;break;case 2:g.r=d;g.g=c;g.b=l;break;case 3:g.r=d;g.g=p;g.b=c;break;case 4:g.r=l;g.g=d;g.b=c;break;case 5:g.r=c;g.g=d;g.b=p}g.r=
g.r*255|0;g.g=g.g*255|0;g.b=g.b*255|0}return g}}};var b=a.jPicker.Color,n=a.jPicker.List,u=a.jPicker.ColorMethods;a.fn.jPicker=function(c){var g=arguments;return this.each(function(){var d=this,l=a.extend(true,{},a.fn.jPicker.defaults,c);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 b({hex:null});l.color.current=new b({hex:null})}else if(u.validateHex(a(d).val())){l.color.active=new b({hex:a(d).val(),
a:l.color.active.val("a")});l.color.current=new b({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 v=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters,A=null,p=null,K=null,R=null,O=
null,I=null,Q=null,U=null,N=null,ha=null,pa=null,fa=null,T=null,Z=null,ua=null,ja=null,da=null,V=null,X=null,oa=null,qa=null,ma=null,la=null,wa=null,Ha=null,Ba=null,Ia=null,Ka=null,Ja=function(M){var P=ka.active,ea=P.val("hex"),Fa,Oa;l.color.mode=M;switch(M){case "h":setTimeout(function(){Va.call(d,p,"transparent");Ca.call(d,R,0);sa.call(d,R,100);Ca.call(d,O,260);sa.call(d,O,100);Va.call(d,K,"transparent");Ca.call(d,Q,0);sa.call(d,Q,100);Ca.call(d,U,260);sa.call(d,U,100);Ca.call(d,N,260);sa.call(d,
N,100);Ca.call(d,ha,260);sa.call(d,ha,100);Ca.call(d,fa,260);sa.call(d,fa,100)},0);T.range("all",{minX:0,maxX:100,minY:0,maxY:100});Z.range("rangeY",{minY:0,maxY:360});if(P.val("ahex")==null)break;T.val("xy",{x:P.val("s"),y:100-P.val("v")},T);Z.val("y",360-P.val("h"),Z);break;case "s":setTimeout(function(){Va.call(d,p,"transparent");Ca.call(d,R,-260);Ca.call(d,O,-520);Ca.call(d,Q,-260);Ca.call(d,U,-520);Ca.call(d,fa,260);sa.call(d,fa,100)},0);T.range("all",{minX:0,maxX:360,minY:0,maxY:100});Z.range("rangeY",
{minY:0,maxY:100});if(P.val("ahex")==null)break;T.val("xy",{x:P.val("h"),y:100-P.val("v")},T);Z.val("y",100-P.val("s"),Z);break;case "v":setTimeout(function(){Va.call(d,p,"000000");Ca.call(d,R,-780);Ca.call(d,O,260);Va.call(d,K,ea);Ca.call(d,Q,-520);Ca.call(d,U,260);sa.call(d,U,100);Ca.call(d,fa,260);sa.call(d,fa,100)},0);T.range("all",{minX:0,maxX:360,minY:0,maxY:100});Z.range("rangeY",{minY:0,maxY:100});if(P.val("ahex")==null)break;T.val("xy",{x:P.val("h"),y:100-P.val("s")},T);Z.val("y",100-P.val("v"),
Z);break;case "r":Fa=-1040;Oa=-780;T.range("all",{minX:0,maxX:255,minY:0,maxY:255});Z.range("rangeY",{minY:0,maxY:255});if(P.val("ahex")==null)break;T.val("xy",{x:P.val("b"),y:255-P.val("g")},T);Z.val("y",255-P.val("r"),Z);break;case "g":Fa=-1560;Oa=-1820;T.range("all",{minX:0,maxX:255,minY:0,maxY:255});Z.range("rangeY",{minY:0,maxY:255});if(P.val("ahex")==null)break;T.val("xy",{x:P.val("b"),y:255-P.val("r")},T);Z.val("y",255-P.val("g"),Z);break;case "b":Fa=-2080;Oa=-2860;T.range("all",{minX:0,maxX:255,
minY:0,maxY:255});Z.range("rangeY",{minY:0,maxY:255});if(P.val("ahex")==null)break;T.val("xy",{x:P.val("r"),y:255-P.val("g")},T);Z.val("y",255-P.val("b"),Z);break;case "a":setTimeout(function(){Va.call(d,p,"transparent");Ca.call(d,R,-260);Ca.call(d,O,-520);Ca.call(d,Q,260);Ca.call(d,U,260);sa.call(d,U,100);Ca.call(d,fa,0);sa.call(d,fa,100)},0);T.range("all",{minX:0,maxX:360,minY:0,maxY:100});Z.range("rangeY",{minY:0,maxY:255});if(P.val("ahex")==null)break;T.val("xy",{x:P.val("h"),y:100-P.val("v")},
T);Z.val("y",255-P.val("a"),Z);break;default:throw"Invalid Mode";}switch(M){case "s":case "v":case "a":setTimeout(function(){sa.call(d,R,100);sa.call(d,Q,100);Ca.call(d,N,260);sa.call(d,N,100);Ca.call(d,ha,260);sa.call(d,ha,100)},0);break;case "r":case "g":case "b":setTimeout(function(){Va.call(d,p,"transparent");Va.call(d,K,"transparent");sa.call(d,Q,100);sa.call(d,R,100);Ca.call(d,R,Fa);Ca.call(d,O,Fa-260);Ca.call(d,Q,Oa-780);Ca.call(d,U,Oa-520);Ca.call(d,N,Oa);Ca.call(d,ha,Oa-260);Ca.call(d,fa,
260);sa.call(d,fa,100)},0)}P.val("ahex")!=null&&Ea.call(d,P)},Ea=function(M,P){if(P==null||P!=Z&&P!=T)ta.call(d,M,P);setTimeout(function(){Ua.call(d,M);ub.call(d,M);fb.call(d,M)},0)},va=function(M,P){var ea=ka.active;if(!(P!=T&&ea.val()==null)){var Fa=M.val("all");switch(l.color.mode){case "h":ea.val("sv",{s:Fa.x,v:100-Fa.y},P);break;case "s":case "a":ea.val("hv",{h:Fa.x,v:100-Fa.y},P);break;case "v":ea.val("hs",{h:Fa.x,s:100-Fa.y},P);break;case "r":ea.val("gb",{g:255-Fa.y,b:Fa.x},P);break;case "g":ea.val("rb",
{r:255-Fa.y,b:Fa.x},P);break;case "b":ea.val("rg",{r:Fa.x,g:255-Fa.y},P)}}},Ga=function(M,P){var ea=ka.active;if(!(P!=Z&&ea.val()==null))switch(l.color.mode){case "h":ea.val("h",{h:360-M.val("y")},P);break;case "s":ea.val("s",{s:100-M.val("y")},P);break;case "v":ea.val("v",{v:100-M.val("y")},P);break;case "r":ea.val("r",{r:255-M.val("y")},P);break;case "g":ea.val("g",{g:255-M.val("y")},P);break;case "b":ea.val("b",{b:255-M.val("y")},P);break;case "a":ea.val("a",255-M.val("y"),P)}},ta=function(M,P){if(P!=
T)switch(l.color.mode){case "h":var ea=M.val("sv");T.val("xy",{x:ea!=null?ea.s:100,y:100-(ea!=null?ea.v:100)},P);break;case "s":case "a":ea=M.val("hv");T.val("xy",{x:ea&&ea.h||0,y:100-(ea!=null?ea.v:100)},P);break;case "v":ea=M.val("hs");T.val("xy",{x:ea&&ea.h||0,y:100-(ea!=null?ea.s:100)},P);break;case "r":ea=M.val("bg");T.val("xy",{x:ea&&ea.b||0,y:255-(ea&&ea.g||0)},P);break;case "g":ea=M.val("br");T.val("xy",{x:ea&&ea.b||0,y:255-(ea&&ea.r||0)},P);break;case "b":ea=M.val("rg");T.val("xy",{x:ea&&
ea.r||0,y:255-(ea&&ea.g||0)},P)}if(P!=Z)switch(l.color.mode){case "h":Z.val("y",360-(M.val("h")||0),P);break;case "s":ea=M.val("s");Z.val("y",100-(ea!=null?ea:100),P);break;case "v":ea=M.val("v");Z.val("y",100-(ea!=null?ea:100),P);break;case "r":Z.val("y",255-(M.val("r")||0),P);break;case "g":Z.val("y",255-(M.val("g")||0),P);break;case "b":Z.val("y",255-(M.val("b")||0),P);break;case "a":ea=M.val("a");Z.val("y",255-(ea!=null?ea:255),P)}},Ua=function(M){try{var P=M.val("all");oa.css({backgroundColor:P&&
"#"+P.hex||"transparent"});sa.call(d,oa,P&&Math.precision(P.a*100/255,4)||0)}catch(ea){}},ub=function(M){switch(l.color.mode){case "h":Va.call(d,p,(new b({h:M.val("h")||0,s:100,v:100})).val("hex"));break;case "s":case "a":var P=M.val("s");sa.call(d,O,100-(P!=null?P:100));break;case "v":P=M.val("v");sa.call(d,R,P!=null?P:100);break;case "r":sa.call(d,O,Math.precision((M.val("r")||0)/255*100,4));break;case "g":sa.call(d,O,Math.precision((M.val("g")||0)/255*100,4));break;case "b":sa.call(d,O,Math.precision((M.val("b")||
0)/255*100))}M=M.val("a");sa.call(d,I,Math.precision((255-(M||0))*100/255,4))},fb=function(M){switch(l.color.mode){case "h":var P=M.val("a");sa.call(d,pa,Math.precision((255-(P||0))*100/255,4));break;case "s":P=M.val("hva");var ea=new b({h:P&&P.h||0,s:100,v:P!=null?P.v:100});Va.call(d,K,ea.val("hex"));sa.call(d,U,100-(P!=null?P.v:100));sa.call(d,pa,Math.precision((255-(P&&P.a||0))*100/255,4));break;case "v":P=M.val("hsa");ea=new b({h:P&&P.h||0,s:P!=null?P.s:100,v:100});Va.call(d,K,ea.val("hex"));
sa.call(d,pa,Math.precision((255-(P&&P.a||0))*100/255,4));break;case "r":case "g":case "b":ea=P=0;M=M.val("rgba");if(l.color.mode=="r"){P=M&&M.b||0;ea=M&&M.g||0}else if(l.color.mode=="g"){P=M&&M.b||0;ea=M&&M.r||0}else if(l.color.mode=="b"){P=M&&M.r||0;ea=M&&M.g||0}var Fa=ea>P?P:ea;sa.call(d,U,P>ea?Math.precision((P-ea)/(255-ea)*100,4):0);sa.call(d,N,ea>P?Math.precision((ea-P)/(255-P)*100,4):0);sa.call(d,ha,Math.precision(Fa/255*100,4));sa.call(d,pa,Math.precision((255-(M&&M.a||0))*100/255,4));break;
case "a":P=M.val("a");Va.call(d,K,M.val("hex")||"000000");sa.call(d,pa,P!=null?0:100);sa.call(d,fa,P!=null?100:0)}},Va=function(M,P){M.css({backgroundColor:P&&P.length==6&&"#"+P||"transparent"})},Xa=function(M,P){if(v&&(P.indexOf("AlphaBar.png")!=-1||P.indexOf("Bars.png")!=-1||P.indexOf("Maps.png")!=-1)){M.attr("pngSrc",P);M.css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+P+"', sizingMethod='scale')"})}else M.css({backgroundImage:"url('"+P+"')"})},Ca=
function(M,P){M.css({top:P+"px"})},sa=function(M,P){M.css({visibility:P>0?"visible":"hidden"});if(P>0&&P<100)if(v){var ea=M.attr("pngSrc");ea!=null&&(ea.indexOf("AlphaBar.png")!=-1||ea.indexOf("Bars.png")!=-1||ea.indexOf("Maps.png")!=-1)?M.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ea+"', sizingMethod='scale') progid:DXImageTransform.Microsoft.Alpha(opacity="+P+")"}):M.css({opacity:Math.precision(P/100,4)})}else M.css({opacity:Math.precision(P/100,4)});else if(P==0||P==
100)if(v){ea=M.attr("pngSrc");ea!=null&&(ea.indexOf("AlphaBar.png")!=-1||ea.indexOf("Bars.png")!=-1||ea.indexOf("Maps.png")!=-1)?M.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ea+"', sizingMethod='scale')"}):M.css({opacity:""})}else M.css({opacity:""})},db=function(){ka.active.val("ahex",ka.current.val("ahex"))},La=function(){ka.current.val("ahex",ka.active.val("ahex"))},Ta=function(M){a(this).parents("tbody:first").find('input:radio[value!="'+M.target.value+'"]').removeAttr("checked");
Ja.call(d,M.target.value)},Da=function(){db.call(d)},hb=function(){db.call(d);l.window.expandable&&wb.call(d);a.isFunction(nb)&&nb.call(d,ka.active,la)},qb=function(){La.call(d);l.window.expandable&&wb.call(d);a.isFunction(lb)&&lb.call(d,ka.active,ma)},Ya=function(){rb.call(d)},Za=function(M){var P=M.val("hex");qa.css({backgroundColor:P&&"#"+P||"transparent"});sa.call(d,qa,Math.precision((M.val("a")||0)*100/255,4))},vb=function(M){var P=M.val("hex");M=M.val("va");Ha.css({backgroundColor:P&&"#"+P||
"transparent"});sa.call(d,Ba,Math.precision((255-(M&&M.a||0))*100/255,4));if(l.window.bindToInput&&l.window.updateInputColor)l.window.input.css({backgroundColor:P&&"#"+P||"transparent",color:M==null||M.v>75?"#000000":"#ffffff"})},ra=function(M){ja=parseInt(A.css("left"));da=parseInt(A.css("top"));V=M.pageX;X=M.pageY;a(document).bind("mousemove",kb).bind("mouseup",gb);M.preventDefault()},kb=function(M){A.css({left:ja-(V-M.pageX)+"px",top:da-(X-M.pageY)+"px"});l.window.expandable&&!a.support.boxModel&&
A.prev().css({left:A.css("left"),top:A.css("top")});M.stopPropagation();M.preventDefault();return false},gb=function(M){a(document).unbind("mousemove",kb).unbind("mouseup",gb);M.stopPropagation();M.preventDefault();return false},tb=function(M){M.preventDefault();M.stopPropagation();ka.active.val("ahex",a(this).attr("title")||null,M.target);return false},lb=a.isFunction(g[1])&&g[1]||null,eb=a.isFunction(g[2])&&g[2]||null,nb=a.isFunction(g[3])&&g[3]||null,rb=function(){ka.current.val("ahex",ka.active.val("ahex"));
var M=function(){if(!(!l.window.expandable||a.support.boxModel)){var P=A.find("table:first");A.before("<iframe/>");A.prev().css({width:P.width(),height:A.height(),opacity:0,position:"absolute",left:A.css("left"),top:A.css("top")})}};if(l.window.expandable){a(document.body).children("div.jPicker.Container").css({zIndex:10});A.css({zIndex:20})}switch(l.window.effects.type){case "fade":A.fadeIn(l.window.effects.speed.show,M);break;case "slide":A.slideDown(l.window.effects.speed.show,M);break;default:A.show(l.window.effects.speed.show,
M)}},wb=function(){var M=function(){l.window.expandable&&A.css({zIndex:10});!l.window.expandable||a.support.boxModel||A.prev().remove()};switch(l.window.effects.type){case "fade":A.fadeOut(l.window.effects.speed.hide,M);break;case "slide":A.slideUp(l.window.effects.speed.hide,M);break;default:A.hide(l.window.effects.speed.hide,M)}},xb=function(){var M=l.window,P=M.expandable?a(d).next().find(".Container:first"):null;A=M.expandable?a("<div/>"):a(d);A.addClass("jPicker Container");M.expandable&&A.hide();
A.get(0).onselectstart=function(Qa){if(Qa.target.nodeName.toLowerCase()!=="input")return false};var ea=ka.active.val("all");if(M.alphaPrecision<0)M.alphaPrecision=0;else if(M.alphaPrecision>2)M.alphaPrecision=2;var Fa='<table class="jPicker" cellpadding="0" cellspacing="0"><tbody>'+(M.expandable?'<tr><td class="Move" colspan="5">&nbsp;</td></tr>':"")+'<tr><td rowspan="9"><h2 class="Title">'+(M.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="'+
ia.clientPath+ia.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="'+ia.clientPath+ia.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+
'"/>&nbsp;%</td></tr><tr class="Value"><td class="Radio"><label title="'+ca.tooltips.value.radio+'"><input type="radio" value="v"'+(l.color.mode=="v"?' checked="checked"':"")+'/>V:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(ea!=null?ea.v:"")+'" title="'+ca.tooltips.value.textbox+'"/>&nbsp;%<br/><br/></td></tr><tr class="Red"><td class="Radio"><label title="'+ca.tooltips.red.radio+'"><input type="radio" value="r"'+(l.color.mode=="r"?' checked="checked"':"")+'/>R:</label></td><td class="Text"><input type="text" maxlength="3" value="'+
(ea!=null?ea.r:"")+'" title="'+ca.tooltips.red.textbox+'"/></td></tr><tr class="Green"><td class="Radio"><label title="'+ca.tooltips.green.radio+'"><input type="radio" value="g"'+(l.color.mode=="g"?' checked="checked"':"")+'/>G:</label></td><td class="Text"><input type="text" maxlength="3" value="'+(ea!=null?ea.g:"")+'" title="'+ca.tooltips.green.textbox+'"/></td></tr><tr class="Blue"><td class="Radio"><label title="'+ca.tooltips.blue.radio+'"><input type="radio" value="b"'+(l.color.mode=="b"?' checked="checked"':
"")+'/>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">'+(M.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">'+(M.alphaSupport?'<input type="text" maxlength="'+(3+M.alphaPrecision)+'" value="'+(ea!=null?Math.precision(ea.a*100/255,M.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>'+(M.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(M.expandable){A.html(Fa);a(document.body).children("div.jPicker.Container").length==
0?a(document.body).prepend(A):a(document.body).children("div.jPicker.Container:last").after(A);A.mousedown(function(){a(document.body).children("div.jPicker.Container").css({zIndex:10});A.css({zIndex:20})});A.css({left:M.position.x=="left"?P.offset().left-530-(M.position.y=="center"?25:0)+"px":M.position.x=="center"?P.offset().left-260+"px":M.position.x=="right"?P.offset().left-10+(M.position.y=="center"?25:0)+"px":M.position.x=="screenCenter"?(a(document).width()>>1)-260+"px":P.offset().left+parseInt(M.position.x)+
"px",position:"absolute",top:M.position.y=="top"?P.offset().top-312+"px":M.position.y=="center"?P.offset().top-156+"px":M.position.y=="bottom"?P.offset().top+25+"px":P.offset().top+parseInt(M.position.y)+"px"})}else{A=a(d);A.html(Fa)}Fa=A.find("tbody:first");p=Fa.find("div.Map:first");K=Fa.find("div.Bar:first");var Oa=p.find("span"),Ra=K.find("span");R=Oa.filter(".Map1:first");O=Oa.filter(".Map2:first");I=Oa.filter(".Map3:first");Q=Ra.filter(".Map1:first");U=Ra.filter(".Map2:first");N=Ra.filter(".Map3:first");
ha=Ra.filter(".Map4:first");pa=Ra.filter(".Map5:first");fa=Ra.filter(".Map6:first");T=new q(p,{map:{width:ia.colorMap.width,height:ia.colorMap.height},arrow:{image:ia.clientPath+ia.colorMap.arrow.file,width:ia.colorMap.arrow.width,height:ia.colorMap.arrow.height}});T.bind(va);Z=new q(K,{map:{width:ia.colorBar.width,height:ia.colorBar.height},arrow:{image:ia.clientPath+ia.colorBar.arrow.file,width:ia.colorBar.arrow.width,height:ia.colorBar.arrow.height}});Z.bind(Ga);ua=new h(Fa,ka.active,M.expandable&&
M.bindToInput?M.input:null,M.alphaPrecision);Oa=ea!=null?ea.hex:null;var cb=Fa.find(".Preview");Ra=Fa.find(".Button");oa=cb.find(".Active:first").css({backgroundColor:Oa&&"#"+Oa||"transparent"});qa=cb.find(".Current:first").css({backgroundColor:Oa&&"#"+Oa||"transparent"}).bind("click",Da);sa.call(d,qa,Math.precision(ka.current.val("a")*100)/255,4);ma=Ra.find(".Ok:first").bind("click touchstart",qb);la=Ra.find(".Cancel:first").bind("click touchstart",hb);wa=Ra.find(".Grid:first");setTimeout(function(){Xa.call(d,
R,ia.clientPath+"Maps.png");Xa.call(d,O,ia.clientPath+"Maps.png");Xa.call(d,I,ia.clientPath+"map-opacity.png");Xa.call(d,Q,ia.clientPath+"Bars.png");Xa.call(d,U,ia.clientPath+"Bars.png");Xa.call(d,N,ia.clientPath+"Bars.png");Xa.call(d,ha,ia.clientPath+"Bars.png");Xa.call(d,pa,ia.clientPath+"bar-opacity.png");Xa.call(d,fa,ia.clientPath+"AlphaBar.png");Xa.call(d,cb.find("div:last"),ia.clientPath+"preview-opacity.png")},0);Fa.find("td.Radio input").bind("click touchstart",Ta);if(ka.quickList&&ka.quickList.length>
0){Ra="";for(i=0;i<ka.quickList.length;i++){if((typeof ka.quickList[i]).toString().toLowerCase()=="string")ka.quickList[i]=new b({hex:ka.quickList[i]});var pb=ka.quickList[i].val("a"),Sa=ka.quickList[i].val("ahex");if(!M.alphaSupport&&Sa)Sa=Sa.substring(0,6)+"ff";var ob=ka.quickList[i].val("hex");Ra+='<span class="QuickColor"'+(Sa&&' title="#'+Sa+'"'||"")+' style="background-color:'+(ob&&"#"+ob||"")+";"+(ob?"":"background-image:url("+ia.clientPath+"NoColor.png)")+(M.alphaSupport&&pb&&pb<255?";opacity:"+
Math.precision(pb/255,4)+";filter:Alpha(opacity="+Math.precision(pb/2.55,4)+")":"")+'">&nbsp;</span>'}Xa.call(d,wa,ia.clientPath+"bar-opacity.png");wa.html(Ra);wa.find(".QuickColor").click(tb)}Ja.call(d,l.color.mode);ka.active.bind(Ea);a.isFunction(eb)&&ka.active.bind(eb);ka.current.bind(Za);if(M.expandable){d.icon=P.parents(".Icon:first");Ha=d.icon.find(".Color:first").css({backgroundColor:Oa&&"#"+Oa||"transparent"});Ba=d.icon.find(".Alpha:first");Xa.call(d,Ba,ia.clientPath+"bar-opacity.png");sa.call(d,
Ba,Math.precision((255-(ea!=null?ea.a:0))*100/255,4));Ia=d.icon.find(".Image:first").css({backgroundImage:"url('"+ia.clientPath+ia.picker.file+"')"}).bind("click",Ya);if(M.bindToInput&&M.updateInputColor)M.input.css({backgroundColor:Oa&&"#"+Oa||"transparent",color:ea==null||ea.v>75?"#000000":"#ffffff"});Ka=Fa.find(".Move:first").bind("mousedown",ra);ka.active.bind(vb)}else rb.call(d)},ia=l.images,ca=l.localization,ka={active:(typeof l.color.active).toString().toLowerCase()=="string"?new b({ahex:!l.window.alphaSupport&&
l.color.active?l.color.active.substring(0,6)+"ff":l.color.active}):new b({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 b({ahex:!l.window.alphaSupport&&l.color.active?l.color.active.substring(0,6)+"ff":l.color.active}):new b({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:lb,liveCallback:eb,cancelCallback:nb,color:ka,show:rb,hide:wb,destroy:function(){A.find("td.Radio input touchstart").unbind("click",Ta);qa.unbind("click touchstart",Da);la.unbind("click touchstart",hb);ma.unbind("click touchstart",qb);if(l.window.expandable){Ia.unbind("click",Ya);Ka.unbind("mousedown",ra);d.icon=null}A.find(".QuickColor").unbind("click",tb);fa=pa=ha=N=U=Q=I=O=R=K=p=null;T.destroy();T=null;Z.destroy();Z=null;ua.destroy();
eb=nb=lb=wa=la=ma=qa=oa=ua=null;A.html("");for(i=0;i<n.length;i++)n[i]==d&&n.splice(i,1)}});n.push(d);setTimeout(function(){xb.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 b({ahex:"#ffcc00ff"}),quickList:[new b({h:360,s:33,v:100}),new b({h:360,s:66,v:100}),new b({h:360,s:100,v:100}),
new b({h:360,s:100,v:75}),new b({h:360,s:100,v:50}),new b({h:180,s:0,v:100}),new b({h:30,s:33,v:100}),new b({h:30,s:66,v:100}),new b({h:30,s:100,v:100}),new b({h:30,s:100,v:75}),new b({h:30,s:100,v:50}),new b({h:180,s:0,v:90}),new b({h:60,s:33,v:100}),new b({h:60,s:66,v:100}),new b({h:60,s:100,v:100}),new b({h:60,s:100,v:75}),new b({h:60,s:100,v:50}),new b({h:180,s:0,v:80}),new b({h:90,s:33,v:100}),new b({h:90,s:66,v:100}),new b({h:90,s:100,v:100}),new b({h:90,s:100,v:75}),new b({h:90,s:100,v:50}),
new b({h:180,s:0,v:70}),new b({h:120,s:33,v:100}),new b({h:120,s:66,v:100}),new b({h:120,s:100,v:100}),new b({h:120,s:100,v:75}),new b({h:120,s:100,v:50}),new b({h:180,s:0,v:60}),new b({h:150,s:33,v:100}),new b({h:150,s:66,v:100}),new b({h:150,s:100,v:100}),new b({h:150,s:100,v:75}),new b({h:150,s:100,v:50}),new b({h:180,s:0,v:50}),new b({h:180,s:33,v:100}),new b({h:180,s:66,v:100}),new b({h:180,s:100,v:100}),new b({h:180,s:100,v:75}),new b({h:180,s:100,v:50}),new b({h:180,s:0,v:40}),new b({h:210,
s:33,v:100}),new b({h:210,s:66,v:100}),new b({h:210,s:100,v:100}),new b({h:210,s:100,v:75}),new b({h:210,s:100,v:50}),new b({h:180,s:0,v:30}),new b({h:240,s:33,v:100}),new b({h:240,s:66,v:100}),new b({h:240,s:100,v:100}),new b({h:240,s:100,v:75}),new b({h:240,s:100,v:50}),new b({h:180,s:0,v:20}),new b({h:270,s:33,v:100}),new b({h:270,s:66,v:100}),new b({h:270,s:100,v:100}),new b({h:270,s:100,v:75}),new b({h:270,s:100,v:50}),new b({h:180,s:0,v:10}),new b({h:300,s:33,v:100}),new b({h:300,s:66,v:100}),
new b({h:300,s:100,v:100}),new b({h:300,s:100,v:75}),new b({h:300,s:100,v:50}),new b({h:180,s:0,v:0}),new b({h:330,s:33,v:100}),new b({h:330,s:66,v:100}),new b({h:330,s:100,v:100}),new b({h:330,s:100,v:75}),new b({h:330,s:100,v:50}),new b]},images:{clientPath:"/jPicker/images/",colorMap:{width:256,height:256,arrow:{file:"mappoint.gif",width:15,height:15}},colorBar:{width:20,height:256,arrow:{file:"rangearrows.gif",width:20,height:7}},picker:{file:"picker.gif",width:25,height:24}},localization:{text:{title:"Drag Markers To Pick A Color",
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 q(n){var u=n||window.event,c=[].slice.call(arguments,1),g=0,d=0,l=0;n=a.event.fix(u);n.type="mousewheel";if(u.wheelDelta)g=u.wheelDelta/120;if(u.detail)g=-u.detail/3;l=g;if(u.axis!==undefined&&u.axis===u.HORIZONTAL_AXIS){l=0;d=-1*g}if(u.wheelDeltaY!==undefined)l=u.wheelDeltaY/120;if(u.wheelDeltaX!==undefined)d=-1*u.wheelDeltaX/120;c.unshift(n,g,d,l);return(a.event.dispatch||a.event.handle).apply(this,c)}var h=["DOMMouseScroll","mousewheel"];if(a.event.fixHooks)for(var b=h.length;b;)a.event.fixHooks[h[--b]]=
a.event.mouseHooks;a.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var n=h.length;n;)this.addEventListener(h[--n],q,false);else this.onmousewheel=q},teardown:function(){if(this.removeEventListener)for(var n=h.length;n;)this.removeEventListener(h[--n],q,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){var q=svgEditor.canvas,h=svgedit.history.ChangeElementCommand,b={fillPaint:"red",fillOpacity:1,strokePaint:"black",strokeOpacity:1,strokeWidth:5,strokeDashArray:null,opacity:1,strokeLinecap:"butt",strokeLinejoin:"miter"},n=function(u,c,g){var d=null;if(u.indexOf("url(#")===0){u=(u=q.getRefElem(u))?u.cloneNode(true):$("#"+g+"_color defs *")[0];d={alpha:c};d[u.tagName]=u}else d=u.indexOf("#")===0?{alpha:c,solidColor:u.substr(1)}:{alpha:c,solidColor:"none"};
return new $.jGraduate.Paint(d)};return{name:"eyedropper",svgicons:"extensions/eyedropper-icon.xml",buttons:[{id:"tool_eyedropper",type:"mode",title:"Eye Dropper Tool",position:8,key:"I",icon:"extensions/eyedropper.png",events:{click:function(){q.setMode("eyedropper")}}}],mouseDown:function(u){var c=q.getMode(),g=u.event;g=g.target.id==="svgroot"?document.getElementById("canvas_background"):g.target;if(c=="eyedropper"&&g){b.fillPaint=g.getAttribute("fill")||"white";b.fillOpacity=g.getAttribute("fill-opacity")||
1;b.strokePaint=g.getAttribute("stroke")||"none";b.strokeOpacity=g.getAttribute("stroke-opacity")||1;b.strokeWidth=g.getAttribute("stroke-width");b.strokeDashArray=g.getAttribute("stroke-dasharray");b.strokeLinecap=g.getAttribute("stroke-linecap");b.strokeLinejoin=g.getAttribute("stroke-linejoin");b.opacity=g.getAttribute("opacity")||1;u.selectedElements=u.selectedElements.filter(Boolean);if(u.selectedElements.length){if($.inArray(u.selectedElements.nodeName,["g","use"])==-1){var d={},l=function(A,
p,K){d[p]=A.getAttribute(p);A.setAttribute(p,K)},v=new a.BatchCommand;u.selectedElements.forEach(function(A){b.fillPaint&&l(A,"fill",b.fillPaint);b.fillOpacity&&l(A,"fill-opacity",b.fillOpacity);b.strokePaint&&l(A,"stroke",b.strokePaint);b.strokeOpacity&&l(A,"stroke-opacity",b.strokeOpacity);b.strokeWidth&&l(A,"stroke-width",b.strokeWidth);b.strokeDashArray&&l(A,"stroke-dasharray",b.strokeDashArray);b.opacity&&l(A,"opacity",b.opacity);b.strokeLinecap&&l(A,"stroke-linecap",b.strokeLinecap);b.strokeLinejoin&&
l(A,"stroke-linejoin",b.strokeLinejoin);v.addSubCommand(new h(A,d));d={}});u=n(b.fillPaint,b.fillOpacity*100,"fill");c=n(b.strokePaint,b.strokeOpacity*100,"stroke");svgEditor.paintBox.fill.update(true);svgEditor.paintBox.stroke.update(true);q.undoMgr.addCommandToHistory(v)}}else{u=n(b.fillPaint,b.fillOpacity*100,"fill");c=n(b.strokePaint,b.strokeOpacity*100,"stroke");svgEditor.paintBox.fill.setPaint(u);svgEditor.paintBox.stroke.setPaint(c)}}}}});svgEditor.addExtension("view_grid",function(a){function q(d){c.attr("width");c.attr("height");var l=svgedit.units.getTypeMap()[svgEditor.curConfig.baseUnit],v=[0.01,0.1,1,10,100,1E3];svgCanvas.getContentElem().getAttribute("x");var A=n;l=l*d;var p=100/l,K=1;for(d=0;d<v.length;d++){var R=v[d];K=R;if(p<=R)break}v=K*l;A.width=v;A.height=v;l=A.getContext("2d");p=v/10;l.globalAlpha=0.2;l.strokeStyle="#000";for(d=1;d<10;d++){K=Math.round(p*d)+0.5;l.moveTo(K,v);l.lineTo(K,0);l.moveTo(v,K);l.lineTo(0,K)}l.stroke();
l.beginPath();l.globalAlpha=0.5;l.moveTo(0.5,v);l.lineTo(0.5,0);l.moveTo(v,0.5);l.lineTo(0,0.5);l.stroke();A=A.toDataURL("image/png");g.setAttribute("width",v);g.setAttribute("height",v);g.parentNode.setAttribute("width",v);g.parentNode.setAttribute("height",v);svgCanvas.setHref(g,A)}if(!document.getElementById("canvasGrid")){var h=document.getElementById("svgcanvas").ownerDocument,b=false;a=a.assignAttributes;var n=document.createElement("canvas");$(n).hide().appendTo("body");var u=h.createElementNS("http://www.w3.org/2000/svg",
"g");a(u,{id:"canvasGrid",width:"100%",height:"100%",x:0,y:0,overflow:"visible",display:"none"});var c=$("#canvas_background");c.after(u);u=h.createElementNS("http://www.w3.org/2000/svg","pattern");a(u,{id:"gridpattern",patternUnits:"userSpaceOnUse",x:0,y:0,width:100,height:100});var g=h.createElementNS("http://www.w3.org/2000/svg","image");a(g,{x:0,y:0,width:100,height:100});u.appendChild(g);$("#svgroot defs").append(u);h=h.createElementNS("http://www.w3.org/2000/svg","rect");a(h,{width:"100%",height:"100%",
x:0,y:0,"stroke-width":0,stroke:"none",fill:"url(#gridpattern)",style:"pointer-events: none; display:visible;"});$("#canvasGrid").append(h)}return{name:"view_grid",zoomChanged:function(d){b&&q(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=b=false;$("#view_grid").removeClass("push_button_pressed");$("#canvasGrid").attr("display","none")}else{svgEditor.curConfig.showGrid=
b=true;$("#view_grid").addClass("push_button_pressed");$("#canvasGrid").attr("display","inline");q(svgCanvas.getZoom())}}}}]}});svgEditor.addExtension("shapes",function(){function a(){$("#shape_buttons").empty();$("#shape_buttons").append(K.buttons)}function q(O){var I=p[O];if(I){K=I;I.buttons.length||h(O,I);a()}else{$("#shape_buttons").html("Loading...");$.getJSON("extensions/shapelib/"+O+".json",function(Q){K=p[O]={data:Q.data,size:Q.size,fill:Q.fill};h(O,Q);a()})}}function h(O,I){var Q=K.size||300,U=K.fill||false,N=Q*0.05;N=[-N,-N,Q+N*2,Q+N*2].join(" ");Q=U?0:Q/30;Q=(new DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg"><svg viewBox="'+
N+'"><path fill="#333" stroke="transparent" stroke-width="'+Q+'" /></svg></svg>',"text/xml");Q.documentElement.setAttribute("width",40);Q.documentElement.setAttribute("height",40);Q=$(document.importNode(Q.documentElement,true));U=I.data;K.buttons=[];for(var ha in U){N=U[ha];var pa=Q.clone();pa.find("path").attr("d",N);N=pa.wrap('<div class="tool_button">').parent().attr({id:R+"_"+ha,title:ha});K.buttons.push(N[0])}}var b,n,u=svgEditor.canvas,c,g,d,l=u.getRootElem(),v={},A={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"},p={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",decagon:"m1,150.00093l28.45646,-88.40318l74.49956,-54.63682l92.08794,0l74.50002,54.63682l28.45599,88.40318l-28.45599,88.40318l-74.50002,54.63681l-92.08794,0l-74.49956,-54.63681l-28.45646,-88.40318z",dodecagon:"m1,110.07421l39.92579,-69.14842l69.14842,-39.92579l79.85159,0l69.14842,39.92579l39.92578,69.14842l0,79.85159l-39.92578,69.14842l-69.14842,39.92578l-79.85159,0l-69.14842,-39.92578l-39.92579,-69.14842l0,-79.85159z",
trapezoid:"m1,299l55.875,-298l186.25001,0l55.87498,298z",dialog_balloon_1:"m0.99786,35.96579l0,0c0,-19.31077 15.28761,-34.96524 34.14583,-34.96524l15.52084,0l0,0l74.50001,0l139.68748,0c9.05606,0 17.74118,3.68382 24.14478,10.24108c6.40356,6.55726 10.00107,15.45081 10.00107,24.72416l0,87.41311l0,0l0,52.44785l0,0c0,19.31078 -15.2876,34.96524 -34.14584,34.96524l-139.68748,0l-97.32507,88.90848l22.82506,-88.90848l-15.52084,0c-18.85822,0 -34.14583,-15.65446 -34.14583,-34.96524l0,0l0,-52.44785l0,0z",heart:"m150,73c61,-175 300,0 0,225c-300,-225 -61,-400 0,-225z",
cylinder:"m299.0007,83.77844c0,18.28676 -66.70958,33.11111 -149.00002,33.11111m149.00002,-33.11111l0,0c0,18.28676 -66.70958,33.11111 -149.00002,33.11111c-82.29041,0 -148.99997,-14.82432 -148.99997,-33.11111m0,0l0,0c0,-18.28674 66.70956,-33.1111 148.99997,-33.1111c82.29044,0 149.00002,14.82436 149.00002,33.1111l0,132.44449c0,18.28674 -66.70958,33.11105 -149.00002,33.11105c-82.29041,0 -148.99997,-14.82431 -148.99997,-33.11105z",arrow_up:"m1.49805,149.64304l148.50121,-148.00241l148.50121,148.00241l-74.25061,0l0,148.71457l-148.5012,0l0,-148.71457z",
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=p.basic,R="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(){u.setMode(R)}}}],callback:function(){var O=
$('<div id="shape_buttons">');$("#tools_shapelib > *").wrapAll(O);var I=$("#tools_shapelib_show");q("basic");$("#shape_buttons").mouseup(function(U){U=$(U.target).closest("div.tool_button");if(U.length){var N=U.children().clone().attr({width:24,height:24});I.children(":not(.flyout_arrow_horiz)").remove();I.append(N).attr("data-curopt","#"+U[0].id).mouseup();u.setMode(R);n=U[0].id.substr((R+"_").length);b=K.data[n];$(".tools_flyout").fadeOut()}});O=$('<div id="shape_cats">');var Q="";$.each(A,function(U,
N){Q+="<div data-cat="+U+">"+N+"</div>"});O.html(Q).children().bind("mouseup",function(){var U=$(this);U.siblings().removeClass("current");U.addClass("current");q(U.attr("data-cat"));return false});O.children().eq(0).addClass("current");$("#tools_shapelib").prepend(O);I.mouseup(function(){u.setMode(b?R:"select")});$("#tool_shapelib").remove();O=$("#tools_shapelib").height();$("#tools_shapelib").css({"margin-top":-(O/2),"margin-left":3})},mouseDown:function(O){if(u.getMode()===R){var I=g=O.start_x;
O=d=O.start_y;var Q=u.getStyle();c=u.addSvgElementFromJson({element:"path",curStyles:true,attr:{d:b,id:u.getNextId(),opacity:Q.opacity/2,style:"pointer-events:none"}});c.setAttribute("d",b);if(/[a-z]/.test(b)){b=K.data[n]=u.pathActions.convertPath(c);c.setAttribute("d",b);u.pathActions.fixEnd(c)}c.setAttribute("transform","translate("+I+","+O+") scale(0.005) translate("+-I+","+-O+")");u.recalculateDimensions(c);u.getTransformList(c);v=c.getBBox();totalScale={sx:1,sy:1};return{started:true}}},mouseMove:function(O){if(u.getMode()===
R){var I=u.getZoom(),Q=O.event,U=O.mouse_x/I,N=O.mouse_y/I;O=u.getTransformList(c);var ha=c.getBBox();I=ha.x;var pa=ha.y,fa=ha.width,T=ha.height,Z=U-g,ua=N-d,ja={x:Math.min(g,U),y:Math.min(d,N),width:Math.abs(U-g),height:Math.abs(N-d)},da=ha=0;T=T?(T+ua)/T:1;fa=fa?(fa+Z)/fa:1;fa=ja.width/v.width;T=ja.height/v.height;fa=fa||1;T=T||1;if(U<g)ha=v.width;if(N<d)da=v.height;U=l.createSVGTransform();N=l.createSVGTransform();ja=l.createSVGTransform();U.setTranslate(-(I+ha),-(pa+da));if(Q.shiftKey){replaced=
true;Q=Math.min(Math.abs(fa),Math.abs(T));fa=Q*(fa<0?-1:1);T=Q*(T<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;T*=Q}}totalScale.sx*=fa;totalScale.sy*=T;N.setScale(fa,T);ja.setTranslate(I+ha,pa+da);O.appendItem(ja);O.appendItem(N);O.appendItem(U);u.recalculateDimensions(c);v=c.getBBox()}},mouseUp:function(O){if(u.getMode()===R){if(O.mouse_x==g&&O.mouse_y==d)return{keep:false,element:c,
started:false};u.setMode("select");return{keep:true,element:c,started:false}}}}});(function(){for(var a=0,q=["ms","moz","webkit","o"],h=0;h<q.length&&!window.requestAnimationFrame;++h){window.requestAnimationFrame=window[q[h]+"RequestAnimationFrame"];window.cancelAnimationFrame=window[q[h]+"CancelAnimationFrame"]||window[q[h]+"CancelRequestAnimationFrame"]}if(!window.requestAnimationFrame)window.requestAnimationFrame=function(b){var n=(new Date).getTime(),u=Math.max(0,16-(n-a)),c=window.setTimeout(function(){b(n+u)},u);a=n+u;return c};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=
function(b){clearTimeout(b)}})();(function(a){function q(p){var K=p.originalEvent;if(!K.touches||K.targetTouches.length===1&&K.touches.length===1){c.call(this,p);p=a(this);p.bind(v,h);p.bind(l,b)}else{clearTimeout(A);u.call(this)}}function h(p){if(A!=null){var K=p.originalEvent;p=K.changedTouches?K.changedTouches[0].pageX:K.pageX;K=K.changedTouches?K.changedTouches[0].pageY:K.pageY;var R=a(this).data("taphold.point");p=p-R.x;K=K-R.y;if(Math.sqrt(p*p+K*K)>d){clearTimeout(A);u.call(this)}}}function b(){clearTimeout(A);u.call(this)}
function n(p){u.call(this);a(this).data("taphold.handler").call(this,p)}function u(){A=null;a(this).unbind(v,h);a(this).unbind(l,b)}function c(p){if(A==null){var K=this;A=setTimeout(function(){n.call(K,p)},g);var R=p.originalEvent,O={};O.x=R.changedTouches?R.changedTouches[0].pageX:R.pageX;O.y=R.changedTouches?R.changedTouches[0].pageY:R.pageY;a(this).data("taphold.point",O)}}var g=1E3,d=5,l="touchend",v="touchmove",A=null;a.event.special.taphold={setup:function(){},add:function(p){a(this).data("taphold.handler",
p.handler);p.data?a(this).bind("touchstart",p.data,q):a(this).bind("touchstart",q)},remove:function(p){clearTimeout(A);u.call(this);p.data?a(this).unbind("touchstart",p.data,q):a(this).unbind("touchstart",q)},teardown:function(){}}})(jQuery);