Your IP : 3.137.136.16
(function(l){var h=document,g=function(c){this.name="dcmap";this.elem="elem";this.cont=c;this.selectedElems={};this.changedElems={};this.bound={};this.beforeChangeView={};this.toSaveElems={}};g.fn=g.prototype;g.fn.init=function(c){this.mdata=c};g.fn.onSelect=function(c){this.selectCallback=c};g.fn.onDblClick=function(c){this.dblClickCallback=c};g.fn.onChange=function(c){this.changeCallback=c};g.fn.onSave=function(c){this.saveCallback=c};g.fn.renderWorkarea=function(){this.papper=new Svg(this.cont,
this.mdata.width,this.mdata.height,this.mdata.scale);this.papper.master=this;this.papper.append();this.papper.zoomCallback=this.renderScaleRuler;this.renderScaleRuler()};g.fn.getOrder=function(c){c-=0;var e=0;if("number"!==typeof c)return!1;for(;10<c;)c/=10,e++;return e};g.fn.getMagicNumber=function(c){c=this.getOrder(c)-2;return 0>c?1:Math.pow(10,c)};g.fn.renderToolbar=function(c){if(c&&0<c.length){var e=c.length,d,a=this,b=h.createElement("div"),k=this.changeView.bind(this),r=this.saveData.bind(this);
b.className="b-map-toolbar";this.mdata.edit&&(d=h.createElement("a"),d.href="#",d.className="b-map-toolbar__button b-map-toolbar__button_save_yes b-map-toolbar__button_disable_yes",d.setAttribute("data-state","notactive"),d.innerHTML=this.mdata.msg.save,b.appendChild(d),d.addEventListener("click",r));for(r=0;r<e;r++)d=h.createElement("a"),d.href="#",d.className="b-map-toolbar__button",d.setAttribute("data-view",c[r].name),d.innerHTML=c[r].localName,b.appendChild(d),d.addEventListener("click",k);d=
h.createElement("a");d.href="#";d.className="b-map-toolbar__button b-map-toolbar__button_zoomin";d.innerHTML="+";b.appendChild(d);d.addEventListener("click",function(){a.papper.viewBoxZoom({direction:1,preventDefault:function(){}})});d=h.createElement("a");d.href="#";d.className="b-map-toolbar__button b-map-toolbar__button_zoomout";d.innerHTML="-";b.appendChild(d);d.addEventListener("click",function(){a.papper.viewBoxZoom({direction:-1,preventDefault:function(){}})});e=h.getElementById(this.cont);
d=h.createElement("span");d.className="b-map-status";d.innerHTML=this.mdata.msg.unsave;b.appendChild(d);e.insertBefore(b,e.lastChild);this.renderLegend(c)}};g.fn.changeView=function(c){var e=c.target,d=e.getAttribute("data-view"),a,b="b-map-toolbar__button_t_"+this.cont,k=" b-map-toolbar__button_active "+b;if(this.activeView===d){if(a=h.querySelectorAll(".view-"+d),this.hideElements(a),this.activeView=null,e.className=e.className.replace(k,""),a=h.querySelector(".b-rack-legend_name_"+d))a.style.display=
"none"}else{this.activeView&&(a=h.querySelectorAll(".view-"+this.activeView),this.hideElements(a),a=h.querySelector("."+b),a.className=a.className.replace(k,""),a=h.querySelector(".b-rack-legend_name_"+this.activeView))&&(a.style.display="none");a=h.querySelectorAll(".view-"+d);this.beforeChangeView[d]?(b=this.beforeChangeViewGetArgs(d),this.visibleElements(a,b),this.beforeChangeView[d]=!1):this.visibleElements(a);if(a=h.querySelector(".b-rack-legend_name_"+d))a.style.display="block";this.activeView=
d;e.className+=k}c.preventDefault()};g.fn.saveData=function(){"function"===typeof this.saveCallback&&this.saveCallback.apply({},[this.toSaveElems,this.tabId]);this.toSaveElems={};var c=h.querySelector("#"+this.cont+" .b-map-status");c&&c.classList.remove("b-map-status_active")};g.fn.hideElements=function(c){for(var e=c.length;e--;)c[e].setAttribute("visibility","hidden")};g.fn.visibleElements=function(c,e){var d=c.length;if(e&&"function"===typeof this[e.func]){for(var a=[""],b=e.arg.length||0,k=0;k<
b;k++)a.push(e.arg[k]);for(;d--;)c[d].setAttribute("visibility","visible"),a[0]=c[d],this[e.func].apply(this,a)}else for(;d--;)c[d].setAttribute("visibility","visible")};g.fn.renderScaleRuler=function(){if(this){var c=this.papper.width,e=this.papper.height,d=this.papper.scale,a=this.getMagicNumber(c>e?c:e),c=Math.round(c/a),e=Math.round(e/a),b=c>e?c:e,k=this.papper.group("scale-ruler",{id:"scaleruler"}),r=this.papper.elems.scaleruler,q,f;r&&r.elem.parentNode.removeChild(r.elem);for(var s=0;s<b;s++)q=
0===s%10?5*d:0===s%5?3*d:2*d,f=s*a,s<c&&(r=this.papper.line("scaleruler-x-"+s,{x1:f,x2:f,y1:"0",y2:q,stroke:"#000","stroke-width":d}),k.appendChild(r)),s<e&&(r=this.papper.line("scaleruler-y-"+s,{x1:0,x2:q,y1:f,y2:f,stroke:"#000","stroke-width":d}),k.appendChild(r));this.papper.appendChild(k);this.papper.elems.scaleruler=k}};g.fn.renderLayer=function(c,e,d,a){var b=e.elems,k=e.layers,r=d?d.length:0,q,f,s,u,g,n,p,h,m,t,l,w=this.mdata.scale||1,B=this.papper.group(e.name,{id:e.name});if(b){e=b.length;
for(var C=0;C<e;C++)if(f=b[C],s=a[f.oName],u=s.shape,this.papper[u]){g={"class":s.name,width:f.width,height:f.height,y:f.top,x:f.left,"stroke-width":1*w,stroke:"#666"};f.direction&&360!==f.direction?(t="rotate("+f.direction+", "+(f.left-0+f.width/2)+", "+(f.top-0+f.height/2)+")",l={direction:f.direction}):t=null;t&&(g.transform=t);f.elid&&(g.elid=f.elid);s.color&&(g.fill=s.color);"image"===u&&(g.href={ns:"xlink",v:pageInfo.commonDir+"img/"+s.img+".png"});n=this.papper[u](s.name,g,l);delete g.color;
delete g.stroke;g.fill="#FFFFFF";g["fill-opacity"]="0.0";var v=this.papper[u](s.name,g,l);n.children.push(v);v.parent=n;delete g["fill-opacity"];if(s.innerObj||s.edit){p=this.papper.group("g-"+s.name,{id:"g-"+f.elid});p.appendChild(n);h=s.innerObj;for(var x in h)m={y:f.top-0+20*w,x:f.left-0+15*w,"font-size":20*w},t&&(m.transform="text"!==x?t:125<f.direction&&225>f.direction?"rotate(0, "+(f.left-0+f.width/2)+", "+(f.top-0+f.height/2)+")":t),this.papper[x]&&(m=this.papper[x](h[x],f[h[x]],m,l),p.appendChild(m),
n.children.push(m),m.parent=n);var z;for(m=0;m<r;m++)if(f[d[m].name]||f[d[m].name+"_used"])if(q={},q.attr=g,q.shape=u,q.transformProp=l,z=f[d[m].name]?f[d[m].name]:f,q=this.renderViewElem(z,d[m],q),"color"===d[m].type&&"relative"===d[m].gradient&&(this.getBounds(d[m].name,f[d[m].name]),this.beforeChangeView[d[m].name]="relativeGradient"),q)if(z=q.length){p.appendChild(q[0]);for(var D=1;D<z;D++)n.children.push(q[D])}else p.appendChild(q),n.children.push(q),q.parent=n;u={y:f.top,x:f.left,width:f.width,
height:5*w,stroke:"#ccc"};t&&(u.transform=t);u=this.papper.rect("line-"+f.elid,u,l);p.appendChild(u);n.children.push(u);u.parent=n;s.edit&&(n.onDrag(this,this.dragElemHandler,this.moveElemHandler,this.dropElemHandler),n.changeFunc=s.drag,n.draged=!0);s.edit&&(n.rotated=!0,u={y:f.top-8*w+(f.height-0),x:f.left-8*w+(f.width-0),stroke:"#ccc",height:16*w,width:16*w},t&&(u.transform=t),t=this.papper.rect("rotate-"+f.elid,u,l),p.appendChild(t),n.children.push(t),t.parent=n,t.onRotate(this,null,null,this.dropRotateElemHandler),
n.dropRotateCallback=this.dropRotateElemHandler)}p.appendChild(v);if(void 0!==f.elid)n.onSelect(this,this.selectElem);if(void 0!==f.elid&&!s.edit)n.onSelectOnly(v);if(void 0!==f.elid&&(n.onDblclick(this,this.dblClickCallback),v))v.onDblclick(this,this.dblClickCallback);s.edit?(f.msg=this.mdata.msg,f=this.showHint.bind(f),v.elem.addEventListener("mouseover",f),v.elem.addEventListener("mouseout",this.hideHint)):h&&h.hint&&v&&(s=this.showActHint.bind(f),v.elem.addEventListener("mouseover",s),v.elem.addEventListener("mouseout",
this.hideHint),v.elem.setAttribute("data-elid",f.elid),v.elem.setAttribute("data-name",f.oName),v.elem.setAttribute("data-func",h.hint));p&&(n=p);B.appendChild(n)}else console.log("don't have this shape: "+u)}c.appendChild(B);if(k)for(e=k.length,c=0;c<e;c++)this.renderLayer(B,k[c],d,a)};g.fn.renderViewElem=function(c,e,d){if("image"!==d.shape){var a=d.attr,b,k;a.visibility=void 0;a["class"]=void 0;a.fill=void 0;a["font-size"]=void 0;a["data-value"]=void 0;if("color"===e.type){a.visibility="hidden";
a["class"]="view-"+e.name;if("fixed"===e.gradient)return a.fill=this.gradientGreenToRed(c,0,100),this.papper[d.shape]("name",a,d.transformProp);if("relative"===e.gradient)return a["data-value"]=c,this.papper[d.shape]("name",a,d.transformProp)}else if("indicator"===e.type){b=a.x;k=a.y;var r=this.papper.group("name",{"class":"view-"+e.name,visibility:"hidden"}),q=this.papper[d.shape]("name",a,d.transformProp),f=c[e.name+"_used"];c=c[e.name+"_total"];q.attr("fill",this.gradientGreenToRed(f,0,c));a["font-size"]=
20*this.papper.scale;a.x=a.x-0+7*this.papper.scale;a.y=a.y-0+20*this.papper.scale;d.transformProp&&125<d.transformProp.direction&&225>d.transformProp.direction&&(a.transform=a.transform.replace(RegExp(d.transformProp.direction),0));d=this.papper.text("name",f+" / "+c,a,d.transformProp);a.x=b;a.y=k;r.appendChild(q);r.appendChild(d);return[r,q,d]}}};g.fn.getBounds=function(c,e){e-=0;if(this.bound[c]){var d=this.bound[c].min,a=this.bound[c].max;this.bound[c].min=d>e?e:d;this.bound[c].max=a<e?e:a}else this.bound[c]=
{},this.bound[c].min=e,this.bound[c].max=e};g.fn.beforeChangeViewGetArgs=function(c){if("relativeGradient"===this.beforeChangeView[c])return{func:this.beforeChangeView[c],arg:[this.bound[c].min,this.bound[c].max]}};g.fn.renderLegend=function(c){for(var e=c.length,d,a;e--;)if("color"===c[e].type){"fixed"===c[e].gradient?(d=c[e].boundleft-0,a=c[e].boundright-0):(d=this.bound[c[e].name].min,a=this.bound[c[e].name].max);var b=Math.floor((a-d)/10),k='<h3 class="b-rack-legend__title">'+c[e].localName+"</h3>",
r=d,q=b%10,f=10;0!==q&&(0!==r%10&&(r-=r%10),q=10-q,b+=q,f=Math.floor(a/b));for(q=0;q<=f;q++)k+='<div class="b-rack-legend__item"><span class="b-rack-legend__color" style="background-color: '+this.gradientGreenToRed(r,d,a)+';"></span><span class="b-rack-legend__value">'+Math.floor(r)+"</span></div>",r+=b;d=h.createElement("div");d.className="b-rack-legend b-rack-legend_dcmap b-rack-legend_name_"+c[e].name;d.innerHTML=k;this.papper.cont.appendChild(d)}};g.fn.showHint=function(c){var e=h.querySelector("body");
c=new CustomEvent("showHintMap",{detail:{props:this,elem:c.srcElement}});e.dispatchEvent(c)};g.fn.showActHint=function(c){var e=h.querySelector("body");c=new CustomEvent("hintActiveShowHandler",{detail:{elem:c.srcElement}});e.dispatchEvent(c)};g.fn.hideHint=function(){var c=h.querySelector("body"),e=new CustomEvent("hideHint");c.dispatchEvent(e)};g.fn.stopShowHint=function(){!0!==this.runHandler&&setTimeout(function(){var c=h.querySelector("body"),e=new CustomEvent("stopShowHint");c.dispatchEvent(e)},
200)};g.fn.relativeGradient=function(c,e,d){var a=c.getAttribute("data-value");c.setAttribute("fill",this.gradientGreenToRed(a,e,d))};g.fn.gradientGreenToRed=function(c,e,d){var a;a=d-e;d=a/2;c>d?(e=255,a=Math.round(255*(a-c)/d)):(a=255,e=Math.round(255*c/d));return"rgb("+e+","+a+",0)"};g.fn.renderLayers=function(c){var e=c.layers,d=c.objects;c=c.views;1===e.length&&this.renderLayer(this.papper,e[0],c,d);this.renderToolbar(c)};g.fn.resize=function(c){var e=c.width;c=c.height;if(e||c)e&&this.papper.setWidth(e),
c&&this.papper.setHeight(c)};g.fn.selectElem=function(c,e){if(!e)for(var d in this.selectedElems)this.selectedElems[d].removeClass("selected"),this.selectedElems[d].selected=!1,delete this.selectedElems[d];c.selected||c.dblclicked?(c.addClass("selected"),c.selected=!0,this.selectedElems[c.id]=c):(c.removeClass("selected"),delete this.selectedElems[c.id]);"function"===typeof this.selectCallback&&this.selectCallback.apply({},[this.selectedElems,this])};g.fn.dragElemHandler=function(c,e){var d,a;for(a in this.selectedElems)c.elid!==
a&&(d=this.selectedElems[a],d.drag.apply(d,[e,!0]));this.hideHint();this.stopShowHint()};g.fn.moveElemHandler=function(c,e){var d,a;for(a in this.selectedElems)c.id!==a&&(d=this.selectedElems[a],d.move.apply(d,[e,!0]));this.stopShowHint();this.runHandler=!0};g.fn.dropElemHandler=function(c,e){"function"===typeof this.changeCallback&&this.changeCallback.apply({},[this.selectedElems]);this.preSaveData(this.selectedElems);this.runHandler=!1};g.fn.preSaveData=function(c){for(var e in c)this.toSaveElems[e]=
this.selectedElems[e];(c=h.querySelector("#"+this.cont+" .b-map-status"))&&c.classList.add("b-map-status_active")};g.fn.dropRotateElemHandler=function(c,e){"function"===typeof this.changeCallback&&this.changeCallback.apply({},[{t:c}]);var d={};d[c.elid]=c;this.preSaveData(d)};g.fn.forceRotate=function(){var c,e;for(e in this.selectedElems)c=this.selectedElems[e],c.rotated&&c.forceRotate()};g.fn.forceMove=function(c){var e,d;for(d in this.selectedElems)e=this.selectedElems[d],e.draged&&e.forceMove(c)};
l.DCMap=g})(window);"use strict";
(function(l){function h(a,b){for(var f=a.mnLen;f--;)if(a.mnodes[f].offset.top<=b&&a.mnodes[f].offset.top+a.mnodes[f].height>=b)return a.mnodes[f];return!1}function g(a,b,f){var d;d=f-b;f=d/2;a>f?(b=255,d=Math.round(255*(d-a)/f)):(d=255,b=Math.round(255*a/f));return"rgb("+b+","+d+",0)"}var c=l.doT,e=l.document,d=l.hash,a=function(a){this.wrapper=a;this.template=c.template(k);this.nodes={};this.slots={};this.toSaveElems={};this.selectedElems=[];this.mnodes=[]};a.fn=a.prototype;a.fn.setData=function(a){this.data=
a.map;this.edit=!0;this.tabId=a.tabId;this.wrapperSelector="#"+this.tabId+"-map";this.prepareData()};a.fn.prepareData=function(){var a=this.data.views,b=this.data.viewsBound,f=[];if(a&&a.length){for(var d=a.length,e=0;d--;)"relative"===a[d].gradient&&(f[e]={name:a[d].name,min:0,max:0},e++);if((a=this.data.elems)&&a.length){for(var d=a.length,c=e,k,g,e=d;d--;)for(k=c;k--;){if(g=a[d][f[k].name])d===e-1?(f[k].min=g,f[k].max=g):(f[k].max=f[k].max<g?g:f[k].max,f[k].min=f[k].min>g?g:f[k].min);if(a[d].embed)for(var h=
a[d].embed.length;h--;)if(g=a[d].embed[h][f[k].name])d===e-1?(f[k].min=g,f[k].max=g):(f[k].max=f[k].max<g?g:f[k].max,f[k].min=f[k].min>g?g:f[k].min)}for(;c--;)b[f[c].name].boundleft=f[c].min,b[f[c].name].boundright=f[c].max;this.data.viewsBound=b}}};a.fn.legend=function(){var a=this.data.viewsBound,b,f,d=e.querySelector(this.wrapperSelector),c=0,k;for(k in a){b=a[k].boundleft-0;f=a[k].boundright-0;var h=Math.floor((f-b)/10),p='<h3 class="b-rack-legend__title">'+this.data.views[c].localName+"</h3>",
l=b,m=h%10,t=10;0!==m&&(0!==l%10&&(l-=l%10),m=10-m,h+=m,t=Math.floor(f/h));for(m=0;m<=t;m++)p+='<div class="b-rack-legend__item"><span class="b-rack-legend__color" style="background-color: '+g(l,b,f)+';"></span><span class="b-rack-legend__value">'+Math.floor(l)+"</span></div>",l+=h;b=e.createElement("div");b.className="b-rack-legend b-rack-legend_name_"+k;b.innerHTML=p;d.appendChild(b);c++}};a.fn.saveData=function(){"function"===typeof this.saveDataCallback&&this.saveDataCallback.apply({},[this.toSaveElems,
this.tabId]);this.toSaveElems={};this.hideStatus()};a.fn.onSaveData=function(a){this.saveDataCallback=a};a.fn.onSelect=function(a){this.selectCb=a};a.fn.preSaveData=function(a){void 0!==a&&(this.showStatus(),this.toSaveElems[a.id]=a)};a.fn.showStatus=function(){var a=e.querySelector(this.wrapperSelector+" .b-map-status");a&&a.classList.add("b-map-status_active")};a.fn.hideStatus=function(){var a=e.querySelector(this.wrapperSelector+" .b-map-status");a&&a.classList.remove("b-map-status_active")};a.fn.onDblclick=
function(a){this.dblclickCb=a};a.fn.changeView=function(a){if(a.target){var b,f;if(this.activeView&&(b=e.querySelectorAll(this.wrapperSelector+" .b-node__view_name_"+this.activeView+","+this.wrapperSelector+" .b-rack-legend_name_"+this.activeView))){for(f=b.length;f--;)b[f].style.display="none";e.querySelector(this.wrapperSelector+" .b-rack-btn_view_"+this.activeView).classList.remove("b-rack-btn_active")}var d=a.target,k=d.getAttribute("data-view");b=e.querySelectorAll(this.wrapperSelector+" .b-node__view_name_"+
k+","+this.wrapperSelector+" .b-rack-legend_name_"+k);if(this.activeView===k){this.activeView=null;e.querySelector(this.wrapperSelector+" .b-nodes").classList.remove("b-nodes_active-view");return}if(b)for(e.querySelector(this.wrapperSelector+" .b-nodes").classList.add("b-nodes_active-view"),f=b.length;f--;)b[f].style.display="block";d.classList.add("b-rack-btn_active");this.activeView=k}a.preventDefault()};a.fn.render=function(){this.data.gradientGreenToRed=g;this.data.hash=d;this.data.unitBorder=
2;this.data.unitHeight=19;this.data.tabId=this.tabId;var a=this.template(this.data),b=this,f;e.querySelector(this.wrapperSelector).innerHTML=a;setTimeout(function(){b.buildNodes();e.querySelector(b.wrapperSelector+" .b-rack-btn").addEventListener("click",b.saveData.bind(b));var a=e.querySelectorAll(b.wrapperSelector+" .b-rack-btn");if(a)for(f=a.length;f--;)"#save"!==a[f].getAttribute("href")&&a[f].addEventListener("click",b.changeView.bind(b))},300);this.legend()};a.fn.buildNodes=function(){for(var a=
this.data.elems,e=this.data.unplaced,f=this.edit,k=a.length,c,g;k--;){c=a[k];g=c.size-0;for(var h=0;h<g;h++)this.slots[c.position-0-h]=d(c.elid+c.type);g=new b(c.elid,f,this);g.setData(c);g.onChange(this.preSaveData.bind(this));g.onSelect(this.selectNode.bind(this));g.onDblclick(this.dblclickNode.bind(this));this.nodes[c.elid]=g;c.embed&&this.mnodes.push(g)}if(e)for(k=e.length;k--;)c=e[k],g=new b(c.elid,f,this),g.presetData(c)};a.fn.selectNode=function(a,b){if(17!==(a.which||a.keyCode)&&!a.ctrlKey){for(var f=
this.selectedElems.length;f--;)this.selectedElems[f].domElem.classList.remove("b-node__elem_selected");this.selectedElems=[]}this.selectedElems.push(b);"function"===typeof this.selectCb&&this.selectCb.apply(l,[this.selectedElems,this.tabId])};a.fn.dblclickNode=function(a,b){for(var f=this.selectedElems.length;f--;)this.selectedElems[f].domElem.classList.remove("b-node__elem_selected");this.selectedElems=[];this.selectedElems.push(b);"function"===typeof this.dblclickCb&&this.dblclickCb.apply(l,[b,
this.tabId])};var b=function(a,b,f){this.id=a;this.edit=b;this.rack=f;this.wrapper=f.wrapperSelector};b.fn=b.prototype;b.fn.onChange=function(a){this.changeCallback=a};b.fn.onSelect=function(a){this.selectCb=a};b.fn.onDblclick=function(a){this.dblclickCb=a};b.fn.getDomNode=function(){this.domElemMover=e.querySelector(this.wrapper+" .n"+this.id);this.domElem=e.querySelector(this.wrapper+" .b-node__elem_elid_"+this.id);"multinode"===this.type&&(this.offset=$(this.domElem).offset(),this.height=19*this.size,
this.domInner=e.querySelector(this.wrapper+" .b-node__elem_elid_"+this.id+" .b-node-inner"));this.parent&&(this.domText=e.querySelector(this.wrapper+" .b-node__elem_elid_"+this.id+" .b-node__name_multinode"))};b.fn.presetData=function(a){this.elid=a.elid;this.type=a.type;this.id=d(this.elid+this.type);this.unplaced=this.parent=!0;this.getDomNode();this.domElemMover&&this.domElemMover.addEventListener("mousedown",this.hDrag.bind(this))};b.fn.setData=function(a){this.name=a.name;this.elid=a.elid;this.position=
a.position;this.size=a.size;this.type=a.type;this.id=d(this.elid+this.type);this.state=!0;this.edit&&!this.parent&&(this.getDomNode(),this.domElemMover&&this.domElemMover.addEventListener("mousedown",this.drag.bind(this)),this.domElem&&(this.domElem.addEventListener("click",this.select.bind(this)),this.domElem.addEventListener("dblclick",this.dblclick.bind(this))));if(a.embed){this.embed=[];this.slots=[];this.volume=a.volume;for(var c=a.embed.length,f;c--;)f=new b(a.embed[c].elid,this.edit,this.rack),
f.setData(a.embed[c]),f.parent=this,f.position=a.embed[c].position,f.bindChildEvent(),this.slots[f.position-0]=d(f.elid+f.type),this.embed.push(f)}};b.fn.bindChildEvent=function(){this.onChange(this.rack.preSaveData.bind(this.rack));this.onSelect(this.rack.selectNode.bind(this.rack));this.onDblclick(this.rack.dblclickNode.bind(this.rack));this.domElem&&this.getDomNode();this.domElem&&(this.domElem.addEventListener("click",this.select.bind(this)),this.domElem.addEventListener("dblclick",this.dblclick.bind(this)));
this.domElemMover&&this.domElemMover.addEventListener("mousedown",this.hDrag.bind(this))};b.fn.drag=function(a){0!==this.position-0?(e.onmousemove=this.move.bind(this),e.onmouseup=this.drop.bind(this)):(e.onmousemove=this.moveToRack.bind(this),e.onmouseup=this.dropToRack.bind(this),this.defX=a.clientX);this.defY=a.clientY;this.domElem.focus();this.bottom=parseFloat(this.domElem.style.bottom);this.maxBottom=19*(this.rack.data.size-this.size);a.preventDefault()};b.fn.move=function(a){var b=this.defY-
a.clientY,f=b%19,b=this.bottom+(9.5>f?b-f:b+(19-f));0>b?b=0:b>this.maxBottom&&(b=this.maxBottom);this.checkFreePosition(b);this.domElem.style.bottom=b+"px";a.preventDefault()};b.fn.moveToRack=function(a){var b=this.defX-a.clientX,f=350-b;350<f&&(f=350);this.move.apply(this,[a]);this.domElem.style.left=175<b?0:f+"px"};b.fn.drop=function(a){e.onmousemove=null;e.onmouseup=null;var b;if(this.position!==this.currentPosition&&this.state){for(b=0;b<this.size-0;b++)this.rack.slots[this.position-b]=!1,this.rack.slots[this.currentPosition-
b]=this.id;this.position=this.currentPosition;"function"===typeof this.changeCallback&&this.changeCallback.apply(this.rack,[this])}else if(this.position!==this.currentPosition){for(b=0;b<this.size-0;b++)this.rack.slots[this.position-b]=!1;this.position=this.currentPosition}this.offset=$(this.domElem).offset();a.preventDefault()};b.fn.dropToRack=function(a){e.onmousemove=null;e.onmouseup=null;0===parseInt(this.domElem.style.left,10)?(this.domElem.classList.remove("b-node__elem_withoutpos"),this.drop.apply(this,
[a])):(this.domElem.style.left="350px",this.domElem.style.bottom=this.bottom+"px")};b.fn.checkFreePosition=function(a){var b=this.size-0,f;a=a/19+b;for(var d=0;d<b;d++)if((f=this.rack.slots[a-d])&&f!==this.id){this.state=!1;this.domElem.classList.add("b-node__elem_state_error");break}else this.state=!0,this.domElem.classList.remove("b-node__elem_state_error");this.currentPosition=a};b.fn.hDrag=function(a){var b=$(this.domElem).offset();this.unplaced?(e.onmousemove=this.hMoveToNode.bind(this),e.onmouseup=
this.hDropToNode.bind(this),this.left=this.domElem.offsetLeft,this.shiftAX=b.left-this.left):(e.onmousemove=this.hMove.bind(this),e.onmouseup=this.hDrop.bind(this),this.left=parseFloat(this.domElem.style.left),this.lastParent=this.parent);this.top=this.domElem.offsetTop;this.shiftAY=b.top-this.top;this.mnLen=this.rack.mnodes.length;this.mnodes=this.rack.mnodes;this.defX=a.clientX;this.defY=a.clientY;this.defWidth=this.domElem.style.width;this.defHeight=this.domElem.style.height;this.domElem.focus();
this.sWidth=this.width=parseFloat(this.domElem.style.width);this.maxLeft=(this.parent.volume-1)*this.width+50;this.height=parseFloat(this.domElem.style.height);a.preventDefault()};b.fn.hMove=function(a){if(this.lastX!==a.clientX||this.lastY!==a.clientY){var b=this.defX-a.clientX,f=this.defY-a.clientY,d=this.top-f;this.lastX=a.clientX;this.lastY=a.clientY;if(Math.abs(f)>this.height/2){if(f=d+this.shiftAY,f=h(this,f))d=f.offset.top-this.shiftAY,this.parent.id!==f.id&&(this.parent=f,this.pretend())}else d=
0;f=this.left-b;50>f?f=50:f>this.maxLeft&&(f=this.maxLeft);b=(f-50)%this.width;f=b<this.width/2?f-b:f+(this.width-b);this.hCheckFreePosition(f);this.domElem.style.left=f+"px";this.domElem.style.top=d+"px";a.preventDefault()}};b.fn.hMoveToNode=function(a){if(this.lastX!==a.clientX||this.lastY!==a.clientY){var b=this.defX-a.clientX,f=this.left-b,d=this.top-(this.defY-a.clientY),c=!1,k=!1,e;this.lastX=a.clientX;this.lastY=a.clientY;0>d&&(d=0);-720>f&&(f=-720);if(-400>f&&(e=h(this,d+this.shiftAY))){if("boolean"===
typeof this.parent||"boolean"!==typeof this.parent&&this.parent.id!==e.id)k=!0;this.parent=e;c=!0}c?k&&this.pretend(!0):this.pretendState&&(this.unPretend(!0),this.parent=!0);c&&(d=this.parent.offset.top-this.shiftAY,f=(b-this.df)%this.width,b=f<=this.width/2?b-f:b+(this.width-f),f=this.left-b,f<this.minLeft?f=this.minLeft:f>this.maxLeft&&(f=this.maxLeft),this.hCheckFreePosition(250-(this.left-f-this.df)+50-this.width));this.domElem.style.position="absolute";this.domElem.style.left=f+"px";this.domElem.style.top=
d+"px";a.preventDefault()}};b.fn.pretend=function(a){var b=250/(this.parent.volume-0),d=19*this.parent.size-2;this.domElem.style.width=b+"px";this.domElemMover.style.width=b+"px";this.domElem.style.height=d+"px";this.domText.style.height=d-11+"px";this.domText.style.top=d-11+"px";this.width=b;a?(this.maxLeft=(this.parent.volume-1)*this.width+50+(this.parent.offset.left-this.shiftAX),this.minLeft=50+this.parent.offset.left-this.shiftAX,this.df=this.left-this.maxLeft):(this.dfX=this.sWidth-b,this.maxLeft=
(this.parent.volume-1)*this.width+50,this.lastPosition=this.currentPosition);this.pretendState=!0};b.fn.unPretend=function(a){this.domElem.style.width=this.defWidth;this.domElem.style.height=this.defHeight;this.domElemMover.style.width=this.defWidth;var b=parseFloat(this.defHeight);this.domText.style.height=b-11+"px";this.domText.style.top=b-11+"px";this.pretendState=!1;a?(this.state=!1,this.domElem.classList.add("b-node__elem_state_error"),this.parent=!0):(this.domElem.style.top="0px",this.parent=
this.lastParent)};b.fn.hDrop=function(a){e.onmousemove=null;e.onmouseup=null;this.lastParent&&this.parent.id!==this.lastParent.id?(this.lastParent.slots[this.currentPosition]===this.id?this.lastParent.slots[this.currentPosition]=!1:this.lastParent.slots[this.position]===this.id&&(this.lastParent.slots[this.position]=!1),this.adoptionMe()):this.pretendState&&this.unPretend();this.position!==this.currentPosition&&this.state?(this.parent.slots[this.position]=!1,this.parent.slots[this.currentPosition]=
this.id,this.position=this.currentPosition,"function"===typeof this.changeCallback&&this.changeCallback.apply(this.parent,[this])):this.position!==this.currentPosition&&(this.parent.slots[this.position]=!1,this.position=this.currentPosition);this.lastY=this.lastX=this.height=this.maxLeft=this.sWidth=this.defWidth=this.defHeight=this.defY=this.defX=this.mnodes=this.mnLen=this.top=this.left=this.shiftAX=this.lastPosition=this.lastParent=null;a.preventDefault()};b.fn.hDropToNode=function(a){e.onmousemove=
null;e.onmouseup=null;this.domElem.style.position="";this.domElem.style.top="";this.domElem.style.left="";this.pretendState&&(this.state?(this.adoptionMe(!0),this.hDrop.apply(this,[a])):this.unPretend(!0));a.preventDefault()};b.fn.adoptionMe=function(a){this.parent.domInner.appendChild(this.domElem);this.domElem.style.left=this.width*(this.currentPosition-1)+50+"px";a?(this.domElem.classList.remove("b-node__multi_elem_unplaced"),this.pretendState=this.unplaced=!1,this.bindChildEvent()):this.domElem.style.top=
"0px";this.position=0};b.fn.hCheckFreePosition=function(a){a=Math.round((a-50)/this.width)+1;var b;(b=this.parent.slots[a])&&b!==this.id?(this.state=!1,this.domElem.classList.add("b-node__elem_state_error")):(this.state=!0,this.domElem.classList.remove("b-node__elem_state_error"));this.currentPosition=a};b.fn.select=function(a){this.domElem.classList.add("b-node__elem_selected");"function"===typeof this.selectCb&&this.selectCb(a,this);this.domElem.classList.contains("b-node__multi_elem")&&a.stopPropagation()};
b.fn.dblclick=function(a){this.domElem.classList.add("b-node__elem_selected");"function"===typeof this.dblclickCb&&this.dblclickCb(a,this);this.domElem.classList.contains("b-node__multi_elem")&&a.stopPropagation()};var k=' {{##def.mnode:{{ var color = ""; if (mnode.color) { color="background-color:" + mnode.color + ";" } }}<div class="b-node__multi_elem acthint b-node__elem_elid_{{=it.hash(mnode.elid + mnode.type)}} {{=extClass}}" tabindex="0" data-elid="{{=mnode.elid}}" data-name="{{=mnode.type}}" data-hintfunc="{{=mnode.hintfunc}}" style="{{=color}}width:{{=width}}px;left: {{=left}}px;height: {{=height}}px;">{{~mnode.views :valueM:indexM}}<div class="b-node__view b-node__view_name_{{=valueM.n}}" style="width:{{=width}}px;height: {{=height}}px;background-color:{{=it.gradientGreenToRed(valueM.v, it.viewsBound[valueM.n].boundleft, it.viewsBound[valueM .n].boundright)}};"></div>{{~}}<div class="b-node__name_multinode " style="width: {{=height-11}}px;top:{{=height-11}}px" data-elid="{{=mnode.elid}}">{{=mnode.name}}</div><div class="b-node__props_multinode">{{~mnode.props :value1:index1}}{{?(value1["value"])}}{{ var bg = ""; if (value1["color"] && value1["value"] == "on") { bg = "style= \'background-color: " + value1["color"] + ";\'" } }}<div class="b-prop-multinode b-prop_{{=value1["name"]}}_{{=value1["value"]}}" {{=bg}} data-hint="{{=value1["hint"]}}"></div>{{?}}{{~}}</div><div class="b-node-multi__mover n{{=it.hash(mnode.elid + mnode.type)}}" style="width:{{=width}}px"></div></div>#}}<div class="b-rack-toolbar"><a href="#save" class="b-rack-btn b-rack-btn_save" data-id="#">{{=it.msg.save}}</a>{{~it.views :value:index}}<a href="#{{=value.name}}" class="b-rack-btn b-rack-btn_view_{{=value.name}}" data-view="{{=value.name}}" data-id="#">{{=value.localName}}</a>{{~}}<span class="b-map-status">{{=it.msg.unsave}}</span></div><div class="b-rack" id="b-rack-{{=it.tabId}}"><div class="b-rack__name">{{=it.msg.rack_name}}</div><div class="b-rack__numeric"><ul class="b-rack__numeric-list">{{ var l = it.size; while (l--) { }}<li class="b-rack__numeric-item">{{=l+1}}</li>{{ } }}</ul></div> <div class="b-nodes"><div class="b-node__cont">{{ var l = it.elems.length; var windex = 0; while (l--) { }}{{ var height = (it.elems[l].size * it.unitHeight) - it.unitBorder;}}{{ var color = ""; if (it.elems[l].color) { color="background-color:" + it.elems[l].color + ";" } }}{{ var extClass = ""; if (it.elems[l].position === "0") { extClass="b-node__elem_withoutpos b-node__elem_state_error"; } }}{{ var bottom = ""; if (it.elems[l].position === "0") { windex += (it.elems[l].size - 0) ; bottom = (windex - it.elems[l].size) * it.unitHeight; } else { }}{{ bottom = (it.elems[l].position - it.elems[l].size) * it.unitHeight; } }}<div class="b-node__elem b-node__elem_elid_{{=it.hash(it.elems[l].elid + it.elems[l].type)}} {{=extClass}}" data-elid="{{=it.elems[l].elid}}" tabindex="0" data-pos="{{=it.elems[l].position}}" style="{{=color}}height: {{=height}}px; bottom: {{=bottom}}px;">{{~it.elems[l].views :valueV:indexV}}<div class="b-node__view b-node__view_name_{{=valueV.n}}" style="height: {{=height}}px;background-color:{{=it.gradientGreenToRed(valueV.v, it.viewsBound[valueV.n].boundleft, it.viewsBound[valueV.n].boundright)}};"></div>{{~}}<div class="b-node-inner acthint" data-elid="{{=it.elems[l].elid}}" data-name="{{=it.elems[l].type}}" data-hintfunc="{{=it.elems[l].hintfunc}}"><div class="b-node__props" style="height: {{=height}}px;">{{~it.elems[l].props :value:index}}{{ if (value["value"]) { }}{{ var bg = ""; if (value["color"] && value["value"] == "on") { bg = "style= \'background-color: " + value["color"] + ";\'" } }}<div class="b-prop b-prop_{{=value["name"]}}_{{=value["value"]}} " {{=bg}} data-hint="{{=value["hint"]}}"></div>{{ } }}{{~}}</div><div class="b-node__name" data-elid="{{=it.elems[l].elid}}">{{=it.elems[l].name}}</div>{{?(it.elems[l].type === \'multinode\')}}{{~it.elems[l].embed :mnode:index}}{{ var width = (250 / it.elems[l].volume), height = (it.elems[l].size * it.unitHeight) - it.unitBorder; }}{{ var extClass = ""; var left = width * (mnode.position - 1) + 50; }}{{#def.mnode}}{{~}}{{?}}</div><div class="b-node__mover n{{=it.hash(it.elems[l].elid + it.elems[l].type)}}" style="height: {{=(it.elems[l].size * it.unitHeight) - it.unitBorder}}px;"></div></div> {{ } }}</div></div><div class="b-rack-bottom"></div></div><div class="b-rack-unplaced">{{?it.unplaced}}<div>{{ var extClass = "b-node__multi_elem_unplaced b-node__elem_state_error"; }}{{~it.unplaced :mnode:index}}{{ var width = (250 / 8), height = (3 * it.unitHeight) - it.unitBorder; }}{{ var left = 0; }}{{#def.mnode}}{{~}}</div>{{?}}</div>';
l.Rack=a})(window);"use strict";var _typeof="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(l){return typeof l}:function(l){return l&&"function"===typeof Symbol&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l};
(function(l){var h={},g=document,c=window.hash;h.svg="http://www.w3.org/2000/svg";h.xmlns="http://www.w3.org/2000/xmlns/";h.xlink="http://www.w3.org/1999/xlink";var e=function(a,b,d,c){this.id=a;this.cont=document.getElementById(a);this.wrapper=g.createElement("div");this.svg=g.createElementNS(h.svg,"svg");this.width=b;this.height=d;this.svg.setAttribute("viewBox","0 0 "+this.width*c+" "+this.height*c);this.svg.setAttribute("width",this.width);this.svg.setAttribute("height",this.height);this.svg.setAttributeNS(h.xmlns,
"xmlns:xlink","http://www.w3.org/1999/xlink");this.wrapper.className="svg-wrapper";this.wrapper.appendChild(this.svg);this.layers={};this.zoomRate=1.1;this.curZoom=c?-Math.round(Math.log(c)/Math.log(this.zoomRate)):0;this.zoomDelta=c?1/c:1;this.scale=c||1;this.elems={}};e.fn=e.prototype;e.fn.setWidth=function(a){var b=this.svg.getAttribute("width"),d=this.svg.getAttribute("viewBox").split(" "),b=d[2]/b;this.svg.setAttribute("width",a);d[2]=b*a;this.svg.setAttribute("viewBox",d.join(" "))};e.fn.setHeight=
function(a){var b=this.svg.getAttribute("height"),d=this.svg.getAttribute("viewBox").split(" "),b=d[3]/b;this.svg.setAttribute("height",a);d[3]=b*a;this.svg.setAttribute("viewBox",d.join(" "))};e.fn.append=function(){this.cont.appendChild(this.wrapper);this.viewBoxMoveInit();this.setBorder();this.viewBoxZoomInit()};e.fn.setBorder=function(){var a=this.square("def-border",{x:0,y:0,width:this.width,height:this.height,"class":"default-border"});this.svg.appendChild(a.elem)};e.fn.viewBoxMoveInit=function(){this.svg.addEventListener("mousedown",
this.viewBoxDrag.bind(this),!0)};e.fn.viewBoxZoomInit=function(){this.svg.addEventListener("mousewheel",this.viewBoxScrollMove.bind(this),!1);this.svg.addEventListener("DOMMouseScroll",this.viewBoxScrollMove.bind(this),!1)};e.fn.viewBoxZoom=function(a){var b,d=this;a.wheelDelta?b=-a.wheelDelta/2.5:a.detail?b=16*a.detail:a.direction&&(b=a.direction);var c=this.svg.getAttribute("viewBox").split(" ");c[2]-=0;c[3]-=0;0<b?(c[2]/=this.zoomRate,c[3]/=this.zoomRate,this.curZoom+=1):(c[2]*=this.zoomRate,c[3]*=
this.zoomRate,this.curZoom-=1);this.svg.setAttribute("viewBox",c.join(" "));this.zoomDelta=b=Math.pow(this.zoomRate,this.curZoom);0===b?this.zoomDelta=1:(100*b).toFixed(0);a.preventDefault();this.scale=1/this.zoomDelta;"function"===typeof this.zoomCallback&&(clearTimeout(this.zoomCallbackTimeOut),this.zoomCallbackTimeOut=setTimeout(function(){d.zoomCallback.apply(d.master,[])},200))};e.fn.viewBoxScrollMove=function(a){this.wrapperWidth=this.width-(this.svg.offsetWidth||this.svg.parentNode.offsetWidth)*
this.scale;this.wrapperHeight=this.height-(this.svg.offsetHeight||this.svg.parentNode.offsetHeight)*this.scale;var b,d;a.wheelDelta?(b=-a.wheelDeltaX/2.5,d=-a.wheelDeltaY/2.5):a.detail&&(b=a.axis===a.HORIZONTAL_AXIS?16*a.detail:0,d=a.axis===a.VERTICAL_AXIS?16*a.detail:0);b/=this.zoomDelta;d/=this.zoomDelta;var c=this.svg.getAttribute("viewBox").split(" ");c[0]=c[0]-0+b;c[1]=c[1]-0+d;0>c[0]?c[0]=0:this.wrapperWidth<c[0]&&(c[0]=this.wrapperWidth);0>c[1]?c[1]=0:this.wrapperHeight<c[1]&&(c[1]=this.wrapperHeight);
this.svg.setAttribute("viewBox",c.join(" "));a.preventDefault()};e.fn.viewBoxDrag=function(a){document.onmousemove=this.viewBoxMove.bind(this);document.onmouseup=this.viewBoxDrop.bind(this);this.shiftX=a.clientX;this.shiftY=a.clientY;var b=this.svg.getAttribute("viewBox").split(" ");this.defX=b[0]-0;this.defY=b[1]-0;this.svg.style.cursor="move";this.wrapperWidth=this.width-this.svg.offsetWidth*this.scale;this.wrapperHeight=this.height-this.svg.offsetHeight*this.scale;a.preventDefault()};e.fn.viewBoxMove=
function(a){var b=(this.shiftX-a.clientX)/this.zoomDelta,d=(this.shiftY-a.clientY)/this.zoomDelta,c=this.svg.getAttribute("viewBox").split(" ");c[0]=this.defX+b;c[1]=this.defY+d;0>c[0]?c[0]=0:this.wrapperWidth<c[0]&&(c[0]=this.wrapperWidth);0>c[1]?c[1]=0:this.wrapperHeight<c[1]&&(c[1]=this.wrapperHeight);this.svg.setAttribute("viewBox",c.join(" "));a.preventDefault()};e.fn.viewBoxDrop=function(a){document.onmousemove=null;document.onmouseup=null;this.svg.style.cursor=null;a.preventDefault()};e.fn.appendChild=
function(a){a.elem&&(a=a.elem);this.svg.appendChild(a);return this};e.fn.createLayer=function(a){var b=g.createElementNS(h.svg,"g");b.setAttributeNS(null,"id",this.id+"-"+a);this.svg.appendChild(b);this.layers[a]=b};e.fn.circle=function(a,b,c){var e=g.createElementNS(h.svg,"circle");a=new d(e,a,this);b=b||{};c=c||{};a.props(c);a.attrs(b);return a};e.fn.group=function(a,b,c){var e=g.createElementNS(h.svg,"g");a=new d(e,a,this);b=b||{};c=c||{};a.props(c);a.attrs(b);return a};e.fn.square=function(a,
b,c){var e=g.createElementNS(h.svg,"rect");a=new d(e,a,this);b=b||{};c=c||{};a.props(c);a.attrs(b);return a};e.fn.rect=function(a,b,c){var e=g.createElementNS(h.svg,"rect");a=new d(e,a,this);b=b||{};c=c||{};c.shapeType="rect";a.props(c);a.attrs(b);return a};e.fn.text=function(a,b,c,e){var q=g.createElementNS(h.svg,"text");a=new d(q,a,this);a.setContent(b);c=c||{};e=e||{};e.shapeType="text";a.props(e);a.attrs(c);return a};e.fn.image=function(a,b,c){var e=g.createElementNS(h.svg,"image");a=new d(e,
a,this);b=b||{};c=c||{};c.shapeType="image";a.props(c);a.attrs(b);return a};e.fn.line=function(a,b,c){var e=g.createElementNS(h.svg,"line");a=new d(e,a,this);b=b||{};c=c||{};c.shapeType="line";a.props(c);a.attrs(b);return a};e.fn.renderRacks=function(a){var b=g.createElementNS(svgNs,"g"),c=a.length,d,e;for(b.setAttributeNS(null,"id","racks");c--;)e={x1:a[c].left,x2:a[c].left+a[c].width,y1:a[c].top,y2:a[c].top+a[c].height,text:a[c].name},d=this.rect(e,{fill:"#3b6fcc","fill-opacity":1,style:"color: #fff;"}),
e=this.text(e,{stroke:"#fff"}),d.appendChild(e),b.appendChild(d);this.svg.appendChild(b)};e.fn.renderSetka=function(){var a=Math.ceil(this.height/30/2),b=a-1,c=Math.ceil(this.width/30/2),d=c-1,e=this.width,f=this.height,h=g.createDocumentFragment(),l=g.createElementNS(svgNs,"g"),A=g.createElementNS(svgNs,"g"),n,p,y,m,t;for(l.setAttributeNS(null,"id","setka");a--;)for(a===b?(p=f-f%30,y=p+30,f=p+30):(p=f-30,y=f),n=this.rect({x1:0,x2:e,y1:p,y2:y}),A.appendChild(n),f-=60,t=4,m=p,p=(y-p)/5;t--;)m+=p,n=
m+p,n=this.rect({x1:0,x2:e,y1:m,y2:n},{"stroke-width":"0.5",stroke:"rgb(255, 255, 255)"}),h.appendChild(n),m+=p,2===t&&(m+=p);for(f=this.height;c--;)for(c===d?(b=e-e%30,m=b+30,e=b+30):(b=e-30,m=e),n=this.rect({x1:b,x2:m,y1:0,y2:f}),A.appendChild(n),e-=60,t=4,a=b,p=(m-b)/5;t--;)a+=p,n=a+p,n=this.rect({x1:a,x2:n,y1:0,y2:f},{"stroke-width":"0.5",stroke:"rgb(255, 255, 255)"}),h.appendChild(n),a+=p,2===t&&(a+=p);h.appendChild(A);l.appendChild(h);this.svg.appendChild(l)};var d=function(a,b,c){this.elem=
a;this.name=b;this.children=[];this.selected=!1;this.papper=c};d.fn=d.prototype;d.fn.rm=function(){this.elem.parentNode.removeChild(this.elem)};d.fn.attr=function(a,b){var c=null;"object"===("undefined"===typeof b?"undefined":_typeof(b))&&(c=h[b.ns],a=b.ns+":"+a,b=b.v);if(void 0===b&&a)return this.elem.getAttribute(a);this.elem.setAttributeNS(c,a,b);return this};d.fn.props=function(a){a=a||{};for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b])};d.fn.attrs=function(a){for(var b in a)"elid"!==b?this.attr(b,
a[b]):this.elid=a[b];this.elid&&this.name&&(this.id=c(this.elid+this.name));return this};d.fn.addClass=function(a){if("string"!==typeof a)return this;var b=this.elem.getAttribute("class");b.match(a)||this.elem.setAttribute("class",b+(" "+a));return this};d.fn.removeClass=function(a){if("string"!==typeof a)return this;var b=this.elem.getAttribute("class"),b=b.replace(RegExp(a,"g"),"");this.elem.setAttribute("class",b);return this};d.fn.appendChild=function(a){a.elem&&(a=a.elem);this.elem.appendChild(a);
return this};d.fn.setContent=function(a){this.elem.textContent=a;return this};d.fn.onDrag=function(a,b,c,d){this.elem.addEventListener("mousedown",this.drag.bind(this),!0);this.dragCallback=b;this.moveCallback=c;this.dropCallback=d;this.moveSelf=a;for(a=this.children.length;a--;)b=this.children[a],b.elem.addEventListener("mousedown",this.drag.bind(this),!0);return this};d.fn.onSelect=function(a,b){this.onSelectEvent=!0;this.selectedCallback=b;this.selectedSelf=a;return this};d.fn.onSelectOnly=function(a){this.elem.addEventListener("mousedown",
this.select.bind(this),!0);a&&a.elem.addEventListener("mousedown",this.select.bind(this),!0)};d.fn.onDblclick=function(a,b){"function"===typeof b&&this.elem.addEventListener("dblclick",b.bind(this),!0);return this};d.fn.onRotate=function(a,b,c,d){this.elem.addEventListener("mousedown",this.dragRotate.bind(this),!0);this.elem.addEventListener("keydown",this.forceRotate.bind(this),!0);this.dragRotateCallback=b;this.moveRotateCallback=c;this.dropRotateCallback=d;this.moveSelf=a};d.fn.drag=function(a,
b){b||(document.onmousemove=this.move.bind(this),document.onmouseup=this.drop.bind(this));this.dragStartTime=(new Date).getTime();this.prevClientX=a.clientX;this.prevClientY=a.clientY;this.defX=this.attr("x")-0;this.defY=this.attr("y")-0;this.curDirect=this.direction=this.direction||0;this.elem.style.cursor="move";for(var c=this.children.length,d;c--;)d=this.children[c],d.defX=d.attr("x")-0,d.defY=d.attr("y")-0;this.selected||a.ctrlKey?(!this.selected&&a.ctrlKey&&(this.select.apply(this,[a]),this.forceSelect=
!0),"function"!==typeof this.dragCallback||b||this.dragCallback.apply(this.moveSelf,[this,a])):(this.select.apply(this,[a]),this.forceSelect=!0);b||this.createRulesLines();a.stopPropagation();a.preventDefault()};d.fn.createRulesLines=function(){this.width=this.attr("width");this.height=this.attr("height");90>this.direction?(this.dy=this.height/2,this.dx=this.width/2):180>this.direction?(this.dy=this.width/2,this.dx=this.height/2):270>this.direction?(this.dy=this.height/2,this.dx=this.width/2):(this.dy=
this.width/2,this.dx=this.height/2);this.rotateX=this.defX+this.width/2;this.rotateY=this.defY+this.height/2;var a=this.rotateX-this.dx,b=this.rotateY-this.dy;this.group&&this.group.rm();this.group=this.papper.group("scale-ruler-group",{});this.lineX=this.papper.line("scale-ruler-line-x",{x1:a,x2:a,y1:0,y2:b,stroke:"#000","stroke-width":this.papper.scale});this.group.appendChild(this.lineX);this.lineY=this.papper.line("scale-ruler-line-y",{x1:0,x2:a,y1:b,y2:b,stroke:"#000","stroke-width":this.papper.scale});
this.group.appendChild(this.lineY);this.textX=this.papper.text("scale-ruler-text-x",b,{x:a/2,y:b+20*this.papper.scale,stroke:"#000","font-size":11*this.papper.scale+"px"});this.group.appendChild(this.textX);this.textY=this.papper.text("scale-ruler-text-y",a,{x:a+10*this.papper.scale,y:b/2,stroke:"#000","font-size":11*this.papper.scale+"px"});this.group.appendChild(this.textY);this.papper.appendChild(this.group)};d.fn.moveRulesLines=function(){this.rotateX=this.curX+this.width/2;this.rotateY=this.curY+
this.height/2;var a=this.rotateX-this.dx,b=this.rotateY-this.dy;this.lineX.attr("x1",a);this.lineX.attr("x2",a);this.lineX.attr("y2",b);this.lineY.attr("y1",b);this.lineY.attr("y2",b);this.lineY.attr("x2",a);this.textX.setContent(b.toFixed(0));this.textX.attr("x",a/2);this.textX.attr("y",b+20*this.papper.scale);this.textY.setContent(a.toFixed(0));this.textY.attr("x",a+10*this.papper.scale);this.textY.attr("y",b/2)};d.fn.removeRulesLines=function(){this.group.rm();this.textX=this.textY=this.lineY=
this.lineX=this.group=null};d.fn.move=function(a,b){var c=(a.clientX-this.prevClientX)/this.papper.zoomDelta,d=(a.clientY-this.prevClientY)/this.papper.zoomDelta;this.prevClientX=a.clientX;this.prevClientY=a.clientY;this.moveSetAttr(c,d);"function"!==typeof this.moveCallback||b||this.moveCallback.apply(this.moveSelf,[this,a]);a.preventDefault()};d.fn.moveSetAttr=function(a,b,c){var d,e,f,g=a+(this.attr("x")-0),h=b+(this.attr("y")-0);0>g&&(a-=g,g=0);0>h&&(b-=h,h=0);c&&(g-=g%c,h-=h%c);this.attr("x",
g);this.attr("y",h);this.curX=g;this.curY=h;this.direction&&(d=this.attr("width")-0,e=this.attr("height")-0,f="rotate("+this.direction+", "+(this.curX-0+d/2)+", "+(this.curY-0+e/2)+")",this.attr("transform",f));c=this.children.length;for(var l;c--;)l=this.children[c],g=a+(l.attr("x")-0),h=b+(l.attr("y")-0),l.attr("x",g),l.attr("y",h),l.direction&&("text"!==l.shapeType?l.attr("transform",f):125<this.direction&&225>this.direction?l.attr("transform","rotate(0, "+(this.curX-0+d/2)+", "+(this.curY-0+e/
2)+")"):l.attr("transform",f));this.group&&this.moveRulesLines()};d.fn.drop=function(a,b){document.onmousemove=null;document.onmouseup=null;this.elem.style.cursor=null;var c=(new Date).getTime()-this.dragStartTime;"function"===typeof this.dropCallback&&!b&&200<c&&this.dropCallback.apply(this.moveSelf,[this,a]);this.onSelectEvent&&200>c&&!this.forceSelect&&this.select.apply(this,[a]);this.forceSelect=!1;this.group&&this.removeRulesLines();a.preventDefault()};d.fn.forceMove=function(a){this.defX=this.attr("x")-
0;this.defY=this.attr("y")-0;var b=0,c=0,d=this,e=1/this.papper.zoomDelta;switch(a){case "left":b=-1;break;case "right":b=1;break;case "up":c=-1;break;case "down":c=1}1===e?e=1:5>=e?e=5:10>=e?e=10:50>=e?e=50:100>=e&&(e=100);0!==b?b*=e:0!==c&&(c*=e);this.group||this.createRulesLines();this.moveSetAttr(b,c,e);clearTimeout(this.timeid);this.timeid=setTimeout(function(){"function"===typeof d.dropCallback&&(d.dropCallback.apply(d.moveSelf,[d,{}]),d.group&&d.removeRulesLines())},1E3)};d.fn.dragRotate=function(a){var b=
this.parent,c=$(this.parent.papper.wrapper).offset();document.onmousemove=this.moveRotate.bind(b);document.onmouseup=this.dropRotate.bind(this);b.defX=b.attr("x")-0;b.defY=b.attr("y")-0;b.curY=b.defY;b.curX=b.defX;b.rotateX=b.defX-0+b.attr("width")/2;b.rotateY=b.defY-0+b.attr("height")/2;b.direction=b.direction||0;b.curDirect=b.direction;b.offsetLeft=c.left;b.offsetTop=c.top;c=-1*Math.atan2(a.pageX-c.left-b.rotateX/this.papper.scale,a.pageY-c.top-b.rotateY/this.papper.scale)*(180/Math.PI)+180;b.defA=
c;"function"===typeof this.dragRotateCallback&&this.dragRotateCallback.apply(this.moveSelf,[this,a])};d.fn.moveRotate=function(a){var b;b=-1*Math.atan2(a.pageX-this.offsetLeft-this.rotateX/this.papper.scale,a.pageY-this.offsetTop-this.rotateY/this.papper.scale)*(180/Math.PI)+180-this.defA;this.curDirect=this.direction-0+Math.round(b);b="rotate("+this.curDirect+", "+this.rotateX+", "+this.rotateY+")";this.attr("transform",b);for(var c=this.children.length,d;c--;)d=this.children[c],d.direction=!0,"text"!==
this.children[c].shapeType?d.attr("transform",b):125<this.curDirect&&225>this.curDirect?d.attr("transform","rotate(0, "+this.rotateX+", "+this.rotateY+")"):d.attr("transform",b);"function"===typeof this.moveRotateCallback&&this.moveRotateCallback.apply(this.moveSelf,[this,a]);a.preventDefault()};d.fn.forceRotate=function(a){var b=this.direction%90;this.defX=this.attr("x")-0;this.defY=this.attr("y")-0;this.rotateX=this.defX+this.attr("width")/2;this.rotateY=this.defY+this.attr("height")/2;this.curDirect=
this.direction-0+(90-b);this.setAngle(this.curDirect);b="rotate("+this.curDirect+", "+this.rotateX+", "+this.rotateY+")";this.attr("transform",b);for(var c=this.children.length,d;c--;)d=this.children[c],d.direction=!0,"text"!==this.children[c].shapeType?d.attr("transform",b):125<this.curDirect&&225>this.curDirect?d.attr("transform","rotate(0, "+this.rotateX+", "+this.rotateY+")"):d.attr("transform",b);"function"===typeof this.dropRotateCallback&&this.dropRotateCallback.apply(this.moveSelf,[this,a])};
d.fn.setAngle=function(a){this.curDirect=this.direction=a%=360};d.fn.dropRotate=function(a){document.onmousemove=null;document.onmouseup=null;this.parent.setAngle(this.parent.curDirect);"function"===typeof this.dropRotateCallback&&this.dropRotateCallback.apply(this.parent.moveSelf,[this.parent,a]);a.preventDefault()};d.fn.select=function(a){var b=17===(a.which||a.keyCode)||a.ctrlKey,c=(new Date).getTime();this.selected=b?this.selected?!1:!0:!0;this.dblclicked=300>c-this.lastClicked?!0:!1;"function"===
typeof this.selectedCallback&&this.selectedCallback.apply(this.selectedSelf,[this,b]);this.lastClicked=c;a.preventDefault()};l.Svg=e})(window);