-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrappid.js
14 lines (8 loc) · 933 KB
/
rappid.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*! JointJS+ v3.5.0 - HTML5 Diagramming Framework - TRIAL VERSION
Copyright (c) 2022 client IO
2022-10-13
This Source Code Form is subject to the terms of the JointJS+ Trial License
, v. 2.0. If a copy of the JointJS+ License was not distributed with this
file, You can obtain one at http://jointjs.com/license/rappid_v2.txt
or from the JointJS+ archive as was distributed by client IO. See the LICENSE file.*/
var g,V;!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("backbone"),require("lodash"),require("jquery")):"function"==typeof define&&define.amd?define(["exports","backbone","lodash","jquery"],e):e((t=t||self).joint={},t.Backbone,t._,t.$)}(this,function(t,o,i,w){"use strict";o=o&&o.hasOwnProperty("default")?o.default:o,i=i&&i.hasOwnProperty("default")?i.default:i,w=w&&w.hasOwnProperty("default")?w.default:w;var b="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function T(t){this.ok=!1,this.alpha=1,t=(t=(t="#"==t.charAt(0)?t.substr(1,6):t).replace(/ /g,"")).toLowerCase();for(var c={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"},u=(t=c[t]||t,[{re:/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*((?:\d?\.)?\d)\)$/,example:["rgba(123, 234, 45, 0.8)","rgba(255,234,245,1.0)"],process:function(t){return[parseInt(t[1]),parseInt(t[2]),parseInt(t[3]),parseFloat(t[4])]}},{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(t){return[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}}]),e=0;e<u.length;e++){var i=u[e].re,n=u[e].process,i=i.exec(t);i&&(n=n(i),this.r=n[0],this.g=n[1],this.b=n[2],3<n.length&&(this.alpha=n[3]),this.ok=!0)}this.r=this.r<0||isNaN(this.r)?0:255<this.r?255:this.r,this.g=this.g<0||isNaN(this.g)?0:255<this.g?255:this.g,this.b=this.b<0||isNaN(this.b)?0:255<this.b?255:this.b,this.alpha=this.alpha<0?0:1<this.alpha||isNaN(this.alpha)?1:this.alpha,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toRGBA=function(){return"rgba("+this.r+", "+this.g+", "+this.b+", "+this.alpha+")"},this.toHex=function(){var t=this.r.toString(16),e=this.g.toString(16),i=this.b.toString(16);return"#"+(t=1==t.length?"0"+t:t)+(e=1==e.length?"0"+e:e)+(i=1==i.length?"0"+i:i)},this.getHelpXML=function(){for(var t,e=new Array,i=0;i<u.length;i++)for(var n=u[i].example,r=0;r<n.length;r++)e[e.length]=n[r];for(t in c)e[e.length]=t;var o=document.createElement("ul");o.setAttribute("id","rgbcolor-examples");for(i=0;i<e.length;i++)try{var s=document.createElement("li"),a=new RGBColor(e[i]),l=document.createElement("div"),h=(l.style.cssText="margin: 3px; border: 1px solid black; background:"+a.toHex()+"; color:"+a.toHex(),l.appendChild(document.createTextNode("test")),document.createTextNode(" "+e[i]+" -> "+a.toRGB()+" -> "+a.toHex()));s.appendChild(l),s.appendChild(h),o.appendChild(s)}catch(t){}return o}}var j=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],_=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function Z(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}function L(t,e,i,n){if(!(isNaN(n)||n<1)){for(var r,o,s,a,l,h,c,u,d,g,p,f,m,v,y,b,w,A,C,I,x,z=(n|=0)+n+1,S=e-1,O=i-1,P=n+1,M=P*(P+1)/2,k=new Z,N=k,T=1;T<z;T++){var R,N=N.next=new Z;T==P&&(R=N)}N.next=k;for(var L=null,E=null,V=a=0,D=j[n],B=_[n],G=0;G<i;G++){for(m=v=y=b=l=h=c=u=0,d=P*(w=t[a]),g=P*(A=t[a+1]),p=P*(C=t[a+2]),f=P*(I=t[a+3]),l+=M*w,h+=M*A,c+=M*C,u+=M*I,N=k,T=0;T<P;T++)N.r=w,N.g=A,N.b=C,N.a=I,N=N.next;for(T=1;T<P;T++)l+=(N.r=w=t[o=a+((S<T?S:T)<<2)])*(x=P-T),h+=(N.g=A=t[o+1])*x,c+=(N.b=C=t[o+2])*x,u+=(N.a=I=t[o+3])*x,m+=w,v+=A,y+=C,b+=I,N=N.next;for(L=k,E=R,r=0;r<e;r++)t[a+3]=I=u*D>>B,0!=I?(t[a]=(l*D>>B)*(I=255/I),t[a+1]=(h*D>>B)*I,t[a+2]=(c*D>>B)*I):t[a]=t[a+1]=t[a+2]=0,l-=d,h-=g,c-=p,u-=f,d-=L.r,g-=L.g,p-=L.b,f-=L.a,o=V+((o=r+n+1)<S?o:S)<<2,l+=m+=L.r=t[o],h+=v+=L.g=t[o+1],c+=y+=L.b=t[o+2],u+=b+=L.a=t[o+3],L=L.next,d+=w=E.r,g+=A=E.g,p+=C=E.b,f+=I=E.a,m-=w,v-=A,y-=C,b-=I,E=E.next,a+=4;V+=e}for(r=0;r<e;r++){for(v=y=b=m=h=c=u=l=0,d=P*(w=t[a=r<<2]),g=P*(A=t[a+1]),p=P*(C=t[a+2]),f=P*(I=t[a+3]),l+=M*w,h+=M*A,c+=M*C,u+=M*I,N=k,T=0;T<P;T++)N.r=w,N.g=A,N.b=C,N.a=I,N=N.next;for(s=e,T=1;T<=n;T++)l+=(N.r=w=t[a=s+r<<2])*(x=P-T),h+=(N.g=A=t[a+1])*x,c+=(N.b=C=t[a+2])*x,u+=(N.a=I=t[a+3])*x,m+=w,v+=A,y+=C,b+=I,N=N.next,T<O&&(s+=e);for(a=r,L=k,E=R,G=0;G<i;G++)t[(o=a<<2)+3]=I=u*D>>B,0<I?(t[o]=(l*D>>B)*(I=255/I),t[o+1]=(h*D>>B)*I,t[o+2]=(c*D>>B)*I):t[o]=t[o+1]=t[o+2]=0,l-=d,h-=g,c-=p,u-=f,d-=L.r,g-=L.g,p-=L.b,f-=L.a,o=r+((o=G+P)<O?o:O)*e<<2,l+=m+=L.r=t[o],h+=v+=L.g=t[o+1],c+=y+=L.b=t[o+2],u+=b+=L.a=t[o+3],L=L.next,d+=w=E.r,g+=A=E.g,p+=C=E.b,f+=I=E.a,m-=w,v-=A,y-=C,b-=I,E=E.next,a+=e}}}(function(t){var e,i,n,r;e="undefined"!=typeof window?window:b,i=function(l,h){var c,u,A,I,x,S,P,M,k;if("undefined"!=typeof Element)return c=function(t,e,i){if(null==t&&null==e&&null==i)for(var n=document.querySelectorAll("svg"),r=0;r<n.length;r++){var o=n[r],s=document.createElement("canvas"),a=(s.width=o.clientWidth,s.height=o.clientHeight,o.parentNode.insertBefore(s,o),o.parentNode.removeChild(o),document.createElement("div"));a.appendChild(o),c(s,a.innerHTML)}else{null!=(t="string"==typeof t?document.getElementById(t):t).svg&&t.svg.stop();i=function(t){var C={opts:t,FRAMERATE:30,MAX_VIRTUAL_PIXELS:3e4,log:function(t){}};1==C.opts.log&&"undefined"!=typeof console&&(C.log=function(t){console.log(t)});C.init=function(t){var e=0;C.UniqueId=function(){return"canvg"+ ++e},C.Definitions={},C.Styles={},C.StylesSpecificity={},C.Animations=[],C.Images=[],C.ctx=t,C.ViewPort=new function(){this.viewPorts=[],this.Clear=function(){this.viewPorts=[]},this.SetCurrent=function(t,e){this.viewPorts.push({width:t,height:e})},this.RemoveCurrent=function(){this.viewPorts.pop()},this.Current=function(){return this.viewPorts[this.viewPorts.length-1]},this.width=function(){return this.Current().width},this.height=function(){return this.Current().height},this.ComputeSize=function(t){return null!=t&&"number"==typeof t?t:"x"==t?this.width():"y"==t?this.height():Math.sqrt(Math.pow(this.width(),2)+Math.pow(this.height(),2))/Math.sqrt(2)}}},C.init(),C.ImagesLoaded=function(){for(var t=0;t<C.Images.length;t++)if(!C.Images[t].loaded)return!1;return!0},C.trim=function(t){return t.replace(/^\s+|\s+$/g,"")},C.compressSpaces=function(t){return t.replace(/[\s\r\t\n]+/gm," ")},C.ajax=function(t){var e=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");return e?(e.open("GET",t,!1),e.send(null),e.responseText):null},C.parseXml=function(e){var t,i;if("undefined"!=typeof Windows&&void 0!==Windows.Data&&void 0!==Windows.Data.Xml)return i=new Windows.Data.Xml.Dom.XmlDocument,(t=new Windows.Data.Xml.Dom.XmlLoadSettings).prohibitDtd=!1,i.loadXml(e,t),i;if(!window.DOMParser)return e=e.replace(/<!DOCTYPE svg[^>]*>/,""),(i=new ActiveXObject("Microsoft.XMLDOM")).async="false",i.loadXML(e),i;try{var n=new DOMParser;return n.parseFromString(e,"image/svg+xml")}catch(t){return(n=new DOMParser).parseFromString(e,"text/xml")}},C.Property=function(t,e){this.name=t,this.value=e},C.Property.prototype.getValue=function(){return this.value},C.Property.prototype.hasValue=function(){return null!=this.value&&""!==this.value},C.Property.prototype.numValue=function(){if(!this.hasValue())return 0;var t=parseFloat(this.value);return(this.value+"").match(/%$/)&&(t/=100),t},C.Property.prototype.valueOrDefault=function(t){return this.hasValue()?this.value:t},C.Property.prototype.numValueOrDefault=function(t){return this.hasValue()?this.numValue():t},C.Property.prototype.addOpacity=function(t){var e,i=this.value;return null!=t.value&&""!=t.value&&"string"==typeof this.value&&(e=new l(this.value)).ok&&(i="rgba("+e.r+", "+e.g+", "+e.b+", "+t.numValue()+")"),new C.Property(this.name,i)},C.Property.prototype.getDefinition=function(){var t=this.value.match(/#([^\)'"]+)/);return t=(t=t&&t[1])||this.value,C.Definitions[t]},C.Property.prototype.isUrlDefinition=function(){return 0==this.value.indexOf("url(")},C.Property.prototype.getFillStyleDefinition=function(t,e){var i=this.getDefinition();return null!=i&&i.createGradient?i.createGradient(C.ctx,t,e):null!=i&&i.createPattern?(i.getHrefAttribute().hasValue()&&(e=i.attribute("patternTransform"),i=i.getHrefAttribute().getDefinition(),e.hasValue()&&(i.attribute("patternTransform",!0).value=e.value)),i.createPattern(C.ctx,t)):null},C.Property.prototype.getDPI=function(t){return 96},C.Property.prototype.getEM=function(t){var e=12,i=new C.Property("fontSize",C.Font.Parse(C.ctx.font).fontSize);return e=i.hasValue()?i.toPixels(t):e},C.Property.prototype.getUnits=function(){return(this.value+"").replace(/[0-9\.\-]/g,"")},C.Property.prototype.toPixels=function(t,e){if(!this.hasValue())return 0;var i=this.value+"";if(i.match(/em$/))return this.numValue()*this.getEM(t);if(i.match(/ex$/))return this.numValue()*this.getEM(t)/2;if(i.match(/px$/))return this.numValue();if(i.match(/pt$/))return this.numValue()*this.getDPI(t)*(1/72);if(i.match(/pc$/))return 15*this.numValue();if(i.match(/cm$/))return this.numValue()*this.getDPI(t)/2.54;if(i.match(/mm$/))return this.numValue()*this.getDPI(t)/25.4;if(i.match(/in$/))return this.numValue()*this.getDPI(t);if(i.match(/%$/))return this.numValue()*C.ViewPort.ComputeSize(t);i=this.numValue();return e&&i<1?i*C.ViewPort.ComputeSize(t):i},C.Property.prototype.toMilliseconds=function(){if(!this.hasValue())return 0;var t=this.value+"";return t.match(/s$/)?1e3*this.numValue():(t.match(/ms$/),this.numValue())},C.Property.prototype.toRadians=function(){if(!this.hasValue())return 0;var t=this.value+"";return t.match(/deg$/)?this.numValue()*(Math.PI/180):t.match(/grad$/)?this.numValue()*(Math.PI/200):t.match(/rad$/)?this.numValue():this.numValue()*(Math.PI/180)};var e={baseline:"alphabetic","before-edge":"top","text-before-edge":"top",middle:"middle",central:"middle","after-edge":"bottom","text-after-edge":"bottom",ideographic:"ideographic",alphabetic:"alphabetic",hanging:"hanging",mathematical:"alphabetic"};return C.Property.prototype.toTextBaseline=function(){return this.hasValue()?e[this.value]:null},C.Font=new function(){this.Styles="normal|italic|oblique|inherit",this.Variants="normal|small-caps|inherit",this.Weights="normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit",this.CreateFont=function(t,e,i,n,r,o){o=null!=o?this.Parse(o):this.CreateFont("","","","","",C.ctx.font);return{fontFamily:r||o.fontFamily,fontSize:n||o.fontSize,fontStyle:t||o.fontStyle,fontWeight:i||o.fontWeight,fontVariant:e||o.fontVariant,toString:function(){return[this.fontStyle,this.fontVariant,this.fontWeight,this.fontSize,this.fontFamily].join(" ")}}};var s=this;this.Parse=function(t){for(var e={},i=C.trim(C.compressSpaces(t||"")).split(" "),n={fontSize:!1,fontStyle:!1,fontWeight:!1,fontVariant:!1},r="",o=0;o<i.length;o++)n.fontStyle||-1==s.Styles.indexOf(i[o])?n.fontVariant||-1==s.Variants.indexOf(i[o])?n.fontWeight||-1==s.Weights.indexOf(i[o])?n.fontSize?"inherit"!=i[o]&&(r+=i[o]):("inherit"!=i[o]&&(e.fontSize=i[o].split("/")[0]),n.fontStyle=n.fontVariant=n.fontWeight=n.fontSize=!0):("inherit"!=i[o]&&(e.fontWeight=i[o]),n.fontStyle=n.fontVariant=n.fontWeight=!0):("inherit"!=i[o]&&(e.fontVariant=i[o]),n.fontStyle=n.fontVariant=!0):("inherit"!=i[o]&&(e.fontStyle=i[o]),n.fontStyle=!0);return""!=r&&(e.fontFamily=r),e}},C.ToNumberArray=function(t){for(var e=C.trim(C.compressSpaces((t||"").replace(/,/g," "))).split(" "),i=0;i<e.length;i++)e[i]=parseFloat(e[i]);return e},C.Point=function(t,e){this.x=t,this.y=e},C.Point.prototype.angleTo=function(t){return Math.atan2(t.y-this.y,t.x-this.x)},C.Point.prototype.applyTransform=function(t){var e=this.x*t[0]+this.y*t[2]+t[4],t=this.x*t[1]+this.y*t[3]+t[5];this.x=e,this.y=t},C.CreatePoint=function(t){t=C.ToNumberArray(t);return new C.Point(t[0],t[1])},C.CreatePath=function(t){for(var e=C.ToNumberArray(t),i=[],n=0;n<e.length;n+=2)i.push(new C.Point(e[n],e[n+1]));return i},C.BoundingBox=function(t,e,i,n){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN,this.x=function(){return this.x1},this.y=function(){return this.y1},this.width=function(){return this.x2-this.x1},this.height=function(){return this.y2-this.y1},this.addPoint=function(t,e){null!=t&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=t,this.x2=t),t<this.x1&&(this.x1=t),t>this.x2&&(this.x2=t)),null!=e&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),e<this.y1&&(this.y1=e),e>this.y2&&(this.y2=e))},this.addX=function(t){this.addPoint(t,null)},this.addY=function(t){this.addPoint(null,t)},this.addBoundingBox=function(t){this.addPoint(t.x1,t.y1),this.addPoint(t.x2,t.y2)},this.addQuadraticCurve=function(t,e,i,n,r,o){i=t+2/3*(i-t),n=e+2/3*(n-e);this.addBezierCurve(t,e,i,i+1/3*(r-t),n,n+1/3*(o-e),r,o)},this.addBezierCurve=function(t,e,i,n,r,o,s,a){var l=[t,e],h=[i,n],c=[r,o],u=[s,a];this.addPoint(l[0],l[1]),this.addPoint(u[0],u[1]);for(var d=0;d<=1;d++){var g,p=function(t){return Math.pow(1-t,3)*l[d]+3*Math.pow(1-t,2)*t*h[d]+3*(1-t)*Math.pow(t,2)*c[d]+Math.pow(t,3)*u[d]},f=6*l[d]-12*h[d]+6*c[d],m=-3*l[d]+9*h[d]-9*c[d]+3*u[d],v=3*h[d]-3*l[d];0==m?0==f||0<(g=-v/f)&&g<1&&(0==d&&this.addX(p(g)),1==d&&this.addY(p(g))):(g=Math.pow(f,2)-4*v*m)<0||(0<(v=(-f+Math.sqrt(g))/(2*m))&&v<1&&(0==d&&this.addX(p(v)),1==d&&this.addY(p(v))),0<(v=(-f-Math.sqrt(g))/(2*m))&&v<1&&(0==d&&this.addX(p(v)),1==d&&this.addY(p(v))))}},this.isPointInBox=function(t,e){return this.x1<=t&&t<=this.x2&&this.y1<=e&&e<=this.y2},this.addPoint(t,e),this.addPoint(i,n)},C.Transform=function(t){for(var e=this,i=(this.Type={},this.Type.translate=function(t){this.p=C.CreatePoint(t),this.apply=function(t){t.translate(this.p.x||0,this.p.y||0)},this.unapply=function(t){t.translate(-1*this.p.x||0,-1*this.p.y||0)},this.applyToPoint=function(t){t.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0])}},this.Type.rotate=function(t){t=C.ToNumberArray(t);this.angle=new C.Property("angle",t[0]),this.cx=t[1]||0,this.cy=t[2]||0,this.apply=function(t){t.translate(this.cx,this.cy),t.rotate(this.angle.toRadians()),t.translate(-this.cx,-this.cy)},this.unapply=function(t){t.translate(this.cx,this.cy),t.rotate(-1*this.angle.toRadians()),t.translate(-this.cx,-this.cy)},this.applyToPoint=function(t){var e=this.angle.toRadians();t.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0]),t.applyTransform([Math.cos(e),Math.sin(e),-Math.sin(e),Math.cos(e),0,0]),t.applyTransform([1,0,0,1,-this.p.x||0,-this.p.y||0])}},this.Type.scale=function(t){this.p=C.CreatePoint(t),this.apply=function(t){t.scale(this.p.x||1,this.p.y||this.p.x||1)},this.unapply=function(t){t.scale(1/this.p.x||1,1/this.p.y||this.p.x||1)},this.applyToPoint=function(t){t.applyTransform([this.p.x||0,0,0,this.p.y||0,0,0])}},this.Type.matrix=function(t){this.m=C.ToNumberArray(t),this.apply=function(t){t.transform(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5])},this.unapply=function(t){var e=this.m[0],i=this.m[2],n=this.m[4],r=this.m[1],o=this.m[3],s=this.m[5],a=1/(e*(+o-0*s)-i*(+r-0*s)+n*(0*r-0*o));t.transform(a*(+o-0*s),a*(0*s-+r),a*(0*n-+i),a*(+e-0*n),a*(i*s-n*o),a*(n*r-e*s))},this.applyToPoint=function(t){t.applyTransform(this.m)}},this.Type.SkewBase=function(t){this.base=e.Type.matrix,this.base(t),this.angle=new C.Property("angle",t)},this.Type.SkewBase.prototype=new this.Type.matrix,this.Type.skewX=function(t){this.base=e.Type.SkewBase,this.base(t),this.m=[1,0,Math.tan(this.angle.toRadians()),1,0,0]},this.Type.skewX.prototype=new this.Type.SkewBase,this.Type.skewY=function(t){this.base=e.Type.SkewBase,this.base(t),this.m=[1,Math.tan(this.angle.toRadians()),0,1,0,0]},this.Type.skewY.prototype=new this.Type.SkewBase,this.transforms=[],this.apply=function(t){for(var e=0;e<this.transforms.length;e++)this.transforms[e].apply(t)},this.unapply=function(t){for(var e=this.transforms.length-1;0<=e;e--)this.transforms[e].unapply(t)},this.applyToPoint=function(t){for(var e=0;e<this.transforms.length;e++)this.transforms[e].applyToPoint(t)},C.trim(C.compressSpaces(t)).replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/)),n=0;n<i.length;n++){var r=C.trim(i[n].split("(")[0]),o=i[n].split("(")[1].replace(")",""),s=this.Type[r];void 0!==s&&((s=new s(o)).type=r,this.transforms.push(s))}},C.AspectRatio=function(t,e,i,n,r,o,s,a,l,h){var c=(e=(e=C.compressSpaces(e)).replace(/^defer\s/,"")).split(" ")[0]||"xMidYMid",e=e.split(" ")[1]||"meet",u=i/n,d=r/o,g=Math.min(u,d),p=Math.max(u,d);"meet"==e&&(n*=g,o*=g),"slice"==e&&(n*=p,o*=p),l=new C.Property("refX",l),h=new C.Property("refY",h),l.hasValue()&&h.hasValue()?t.translate(-g*l.toPixels("x"),-g*h.toPixels("y")):(c.match(/^xMid/)&&("meet"==e&&g==d||"slice"==e&&p==d)&&t.translate(i/2-n/2,0),c.match(/YMid$/)&&("meet"==e&&g==u||"slice"==e&&p==u)&&t.translate(0,r/2-o/2),c.match(/^xMax/)&&("meet"==e&&g==d||"slice"==e&&p==d)&&t.translate(i-n,0),c.match(/YMax$/)&&("meet"==e&&g==u||"slice"==e&&p==u)&&t.translate(0,r-o)),"none"==c?t.scale(u,d):"meet"==e?t.scale(g,g):"slice"==e&&t.scale(p,p),t.translate(null==s?0:-s,null==a?0:-a)},C.Element={},C.EmptyProperty=new C.Property("EMPTY",""),C.Element.ElementBase=function(o){this.attributes={},this.styles={},this.stylesSpecificity={},this.children=[],this.attribute=function(t,e){var i=this.attributes[t];return null!=i?i:(1==e&&(i=new C.Property(t,""),this.attributes[t]=i),i||C.EmptyProperty)},this.getHrefAttribute=function(){for(var t in this.attributes)if("href"==t||t.match(/:href$/))return this.attributes[t];return C.EmptyProperty},this.style=function(t,e,i){var n=this.styles[t];if(null!=n)return n;var r=this.attribute(t);if(null!=r&&r.hasValue())return this.styles[t]=r;if(1!=i){r=this.parent;if(null!=r){i=r.style(t);if(null!=i&&i.hasValue())return i}}return 1==e&&(n=new C.Property(t,""),this.styles[t]=n),n||C.EmptyProperty},this.render=function(t){var e;"none"!=this.style("display").value&&"hidden"!=this.style("visibility").value&&(t.save(),this.style("mask").hasValue()?null!=(e=this.style("mask").getDefinition())&&e.apply(t,this):this.style("filter").hasValue()?null!=(e=this.style("filter").getDefinition())&&e.apply(t,this):(this.setContext(t),this.renderChildren(t),this.clearContext(t)),t.restore())},this.setContext=function(t){},this.clearContext=function(t){},this.renderChildren=function(t){for(var e=0;e<this.children.length;e++)this.children[e].render(t)},this.addChild=function(t,e){var i=t;(i=e?C.CreateElement(t):i).parent=this,"title"!=i.type&&this.children.push(i)},this.addStylesFromStyleDefinition=function(){for(var t in C.Styles)if("@"!=t[0]&&u(o,t)){var e=C.Styles[t],i=C.StylesSpecificity[t];if(null!=e)for(var n in e){var r=this.stylesSpecificity[n];(r=void 0===r?"000":r)<i&&(this.styles[n]=e[n],this.stylesSpecificity[n]=i)}}};var t=new RegExp("^[A-Z-]+$");if(null!=o&&1==o.nodeType){for(var e=0;e<o.attributes.length;e++){var i=o.attributes[e],n=(n=i.nodeName,t.test(n)?n.toLowerCase():n);this.attributes[n]=new C.Property(n,i.value)}if(this.addStylesFromStyleDefinition(),this.attribute("style").hasValue())for(var r,s,a=this.attribute("style").value.split(";"),e=0;e<a.length;e++)""!=C.trim(a[e])&&(s=a[e].split(":"),r=C.trim(s[0]),s=C.trim(s[1]),this.styles[r]=new C.Property(r,s));this.attribute("id").hasValue()&&null==C.Definitions[this.attribute("id").value]&&(C.Definitions[this.attribute("id").value]=this);for(e=0;e<o.childNodes.length;e++){var l,h=o.childNodes[e];1==h.nodeType&&this.addChild(h,!0),!this.captureTextNodes||3!=h.nodeType&&4!=h.nodeType||(l=h.value||h.text||h.textContent||"",""!=C.compressSpaces(l)&&this.addChild(new C.Element.tspan(h),!1))}}},C.Element.RenderedElementBase=function(t){this.base=C.Element.ElementBase,this.base(t),this.setContext=function(t){var e,i,n;this.style("fill").isUrlDefinition()?null!=(e=this.style("fill").getFillStyleDefinition(this,this.style("fill-opacity")))&&(t.fillStyle=e):this.style("fill").hasValue()&&("currentColor"==(n=this.style("fill")).value&&(n.value=this.style("color").value),"inherit"!=n.value&&(t.fillStyle="none"==n.value?"rgba(0,0,0,0)":n.value)),this.style("fill-opacity").hasValue()&&(n=(n=new C.Property("fill",t.fillStyle)).addOpacity(this.style("fill-opacity")),t.fillStyle=n.value),this.style("stroke").isUrlDefinition()?null!=(e=this.style("stroke").getFillStyleDefinition(this,this.style("stroke-opacity")))&&(t.strokeStyle=e):this.style("stroke").hasValue()&&("currentColor"==(i=this.style("stroke")).value&&(i.value=this.style("color").value),"inherit"!=i.value&&(t.strokeStyle="none"==i.value?"rgba(0,0,0,0)":i.value)),this.style("stroke-opacity").hasValue()&&(i=(i=new C.Property("stroke",t.strokeStyle)).addOpacity(this.style("stroke-opacity")),t.strokeStyle=i.value),this.style("stroke-width").hasValue()&&(n=this.style("stroke-width").toPixels(),t.lineWidth=0==n?.001:n),this.style("stroke-linecap").hasValue()&&(t.lineCap=this.style("stroke-linecap").value),this.style("stroke-linejoin").hasValue()&&(t.lineJoin=this.style("stroke-linejoin").value),this.style("stroke-miterlimit").hasValue()&&(t.miterLimit=this.style("stroke-miterlimit").value),this.style("stroke-dasharray").hasValue()&&"none"!=this.style("stroke-dasharray").value&&(e=C.ToNumberArray(this.style("stroke-dasharray").value),void 0!==t.setLineDash?t.setLineDash(e):void 0!==t.webkitLineDash?t.webkitLineDash=e:void 0===t.mozDash||1==e.length&&0==e[0]||(t.mozDash=e),i=this.style("stroke-dashoffset").numValueOrDefault(1),void 0!==t.lineDashOffset?t.lineDashOffset=i:void 0!==t.webkitLineDashOffset?t.webkitLineDashOffset=i:void 0!==t.mozDashOffset&&(t.mozDashOffset=i)),void 0!==t.font&&(t.font=C.Font.CreateFont(this.style("font-style").value,this.style("font-variant").value,this.style("font-weight").value,this.style("font-size").hasValue()?this.style("font-size").toPixels()+"px":"",this.style("font-family").value).toString()),this.style("transform",!1,!0).hasValue()&&new C.Transform(this.style("transform",!1,!0).value).apply(t),this.style("clip-path",!1,!0).hasValue()&&null!=(n=this.style("clip-path",!1,!0).getDefinition())&&n.apply(t),this.style("opacity").hasValue()&&(t.globalAlpha=this.style("opacity").numValue())}},C.Element.RenderedElementBase.prototype=new C.Element.ElementBase,C.Element.PathElementBase=function(t){this.base=C.Element.RenderedElementBase,this.base(t),this.path=function(t){return null!=t&&t.beginPath(),new C.BoundingBox},this.renderChildren=function(t){this.path(t),C.Mouse.checkPath(this,t),""!=t.fillStyle&&("inherit"!=this.style("fill-rule").valueOrDefault("inherit")?t.fill(this.style("fill-rule").value):t.fill()),""!=t.strokeStyle&&t.stroke();var e=this.getMarkers();if(null!=e){if(this.style("marker-start").isUrlDefinition()&&(i=this.style("marker-start").getDefinition()).render(t,e[0][0],e[0][1]),this.style("marker-mid").isUrlDefinition())for(var i=this.style("marker-mid").getDefinition(),n=1;n<e.length-1;n++)i.render(t,e[n][0],e[n][1]);this.style("marker-end").isUrlDefinition()&&(i=this.style("marker-end").getDefinition()).render(t,e[e.length-1][0],e[e.length-1][1])}},this.getBoundingBox=function(){return this.path()},this.getMarkers=function(){return null}},C.Element.PathElementBase.prototype=new C.Element.RenderedElementBase,C.Element.svg=function(t){this.base=C.Element.RenderedElementBase,this.base(t),this.baseClearContext=this.clearContext,this.clearContext=function(t){this.baseClearContext(t),C.ViewPort.RemoveCurrent()},this.baseSetContext=this.setContext,this.setContext=function(t){t.strokeStyle="rgba(0,0,0,0)",t.lineCap="butt",t.lineJoin="miter",t.miterLimit=4,void 0!==t.font&&void 0!==window.getComputedStyle&&(t.font=window.getComputedStyle(t.canvas).getPropertyValue("font")),this.baseSetContext(t),this.attribute("x").hasValue()||(this.attribute("x",!0).value=0),this.attribute("y").hasValue()||(this.attribute("y",!0).value=0),t.translate(this.attribute("x").toPixels("x"),this.attribute("y").toPixels("y"));var e,i,n,r=C.ViewPort.width(),o=C.ViewPort.height();this.attribute("width").hasValue()||(this.attribute("width",!0).value="100%"),this.attribute("height").hasValue()||(this.attribute("height",!0).value="100%"),void 0===this.root&&(r=this.attribute("width").toPixels("x"),o=this.attribute("height").toPixels("y"),e=i=0,this.attribute("refX").hasValue()&&this.attribute("refY").hasValue()&&(i=-this.attribute("refX").toPixels("x"),e=-this.attribute("refY").toPixels("y")),"visible"!=this.attribute("overflow").valueOrDefault("hidden")&&(t.beginPath(),t.moveTo(i,e),t.lineTo(r,e),t.lineTo(r,o),t.lineTo(i,o),t.closePath(),t.clip())),C.ViewPort.SetCurrent(r,o),this.attribute("viewBox").hasValue()&&(i=(e=C.ToNumberArray(this.attribute("viewBox").value))[0],n=e[1],r=e[2],o=e[3],C.AspectRatio(t,this.attribute("preserveAspectRatio").value,C.ViewPort.width(),r,C.ViewPort.height(),o,i,n,this.attribute("refX").value,this.attribute("refY").value),C.ViewPort.RemoveCurrent(),C.ViewPort.SetCurrent(e[2],e[3]))}},C.Element.svg.prototype=new C.Element.RenderedElementBase,C.Element.rect=function(t){this.base=C.Element.PathElementBase,this.base(t),this.path=function(t){var e=this.attribute("x").toPixels("x"),i=this.attribute("y").toPixels("y"),n=this.attribute("width").toPixels("x"),r=this.attribute("height").toPixels("y"),o=this.attribute("rx").toPixels("x"),s=this.attribute("ry").toPixels("y");return this.attribute("rx").hasValue()&&!this.attribute("ry").hasValue()&&(s=o),this.attribute("ry").hasValue()&&!this.attribute("rx").hasValue()&&(o=s),o=Math.min(o,n/2),s=Math.min(s,r/2),null!=t&&(t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+n-o,i),t.quadraticCurveTo(e+n,i,e+n,i+s),t.lineTo(e+n,i+r-s),t.quadraticCurveTo(e+n,i+r,e+n-o,i+r),t.lineTo(e+o,i+r),t.quadraticCurveTo(e,i+r,e,i+r-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+o,i),t.closePath()),new C.BoundingBox(e,i,e+n,i+r)}},C.Element.rect.prototype=new C.Element.PathElementBase,C.Element.circle=function(t){this.base=C.Element.PathElementBase,this.base(t),this.path=function(t){var e=this.attribute("cx").toPixels("x"),i=this.attribute("cy").toPixels("y"),n=this.attribute("r").toPixels();return null!=t&&(t.beginPath(),t.arc(e,i,n,0,2*Math.PI,!0),t.closePath()),new C.BoundingBox(e-n,i-n,e+n,i+n)}},C.Element.circle.prototype=new C.Element.PathElementBase,C.Element.ellipse=function(t){this.base=C.Element.PathElementBase,this.base(t),this.path=function(t){var e=(Math.sqrt(2)-1)/3*4,i=this.attribute("rx").toPixels("x"),n=this.attribute("ry").toPixels("y"),r=this.attribute("cx").toPixels("x"),o=this.attribute("cy").toPixels("y");return null!=t&&(t.beginPath(),t.moveTo(r,o-n),t.bezierCurveTo(r+e*i,o-n,r+i,o-e*n,r+i,o),t.bezierCurveTo(r+i,o+e*n,r+e*i,o+n,r,o+n),t.bezierCurveTo(r-e*i,o+n,r-i,o+e*n,r-i,o),t.bezierCurveTo(r-i,o-e*n,r-e*i,o-n,r,o-n),t.closePath()),new C.BoundingBox(r-i,o-n,r+i,o+n)}},C.Element.ellipse.prototype=new C.Element.PathElementBase,C.Element.line=function(t){this.base=C.Element.PathElementBase,this.base(t),this.getPoints=function(){return[new C.Point(this.attribute("x1").toPixels("x"),this.attribute("y1").toPixels("y")),new C.Point(this.attribute("x2").toPixels("x"),this.attribute("y2").toPixels("y"))]},this.path=function(t){var e=this.getPoints();return null!=t&&(t.beginPath(),t.moveTo(e[0].x,e[0].y),t.lineTo(e[1].x,e[1].y)),new C.BoundingBox(e[0].x,e[0].y,e[1].x,e[1].y)},this.getMarkers=function(){var t=this.getPoints(),e=t[0].angleTo(t[1]);return[[t[0],e],[t[1],e]]}},C.Element.line.prototype=new C.Element.PathElementBase,C.Element.polyline=function(t){this.base=C.Element.PathElementBase,this.base(t),this.points=C.CreatePath(this.attribute("points").value),this.path=function(t){var e=new C.BoundingBox(this.points[0].x,this.points[0].y);null!=t&&(t.beginPath(),t.moveTo(this.points[0].x,this.points[0].y));for(var i=1;i<this.points.length;i++)e.addPoint(this.points[i].x,this.points[i].y),null!=t&&t.lineTo(this.points[i].x,this.points[i].y);return e},this.getMarkers=function(){for(var t=[],e=0;e<this.points.length-1;e++)t.push([this.points[e],this.points[e].angleTo(this.points[e+1])]);return 0<t.length&&t.push([this.points[this.points.length-1],t[t.length-1][1]]),t}},C.Element.polyline.prototype=new C.Element.PathElementBase,C.Element.polygon=function(t){this.base=C.Element.polyline,this.base(t),this.basePath=this.path,this.path=function(t){var e=this.basePath(t);return null!=t&&(t.lineTo(this.points[0].x,this.points[0].y),t.closePath()),e}},C.Element.polygon.prototype=new C.Element.polyline,C.Element.path=function(t){this.base=C.Element.PathElementBase,this.base(t);for(var e=(e=this.attribute("d").value).replace(/,/gm," "),i=0;i<2;i++)e=e.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm,"$1 $2");e=(e=e.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2")).replace(/([0-9])([+\-])/gm,"$1 $2");for(i=0;i<2;i++)e=e.replace(/(\.[0-9]*)(\.)/gm,"$1 $2");e=e.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm,"$1 $3 $4 "),e=C.compressSpaces(e),e=C.trim(e),this.PathParser=new function(t){this.tokens=t.split(" "),this.reset=function(){this.i=-1,this.command="",this.previousCommand="",this.start=new C.Point(0,0),this.control=new C.Point(0,0),this.current=new C.Point(0,0),this.points=[],this.angles=[]},this.isEnd=function(){return this.i>=this.tokens.length-1},this.isCommandOrEnd=function(){return!!this.isEnd()||null!=this.tokens[this.i+1].match(/^[A-Za-z]$/)},this.isRelativeCommand=function(){switch(this.command){case"m":case"l":case"h":case"v":case"c":case"s":case"q":case"t":case"a":case"z":return!0}return!1},this.getToken=function(){return this.i++,this.tokens[this.i]},this.getScalar=function(){return parseFloat(this.getToken())},this.nextCommand=function(){this.previousCommand=this.command,this.command=this.getToken()},this.getPoint=function(){var t=new C.Point(this.getScalar(),this.getScalar());return this.makeAbsolute(t)},this.getAsControlPoint=function(){var t=this.getPoint();return this.control=t},this.getAsCurrentPoint=function(){var t=this.getPoint();return this.current=t},this.getReflectedControlPoint=function(){return"c"!=this.previousCommand.toLowerCase()&&"s"!=this.previousCommand.toLowerCase()&&"q"!=this.previousCommand.toLowerCase()&&"t"!=this.previousCommand.toLowerCase()?this.current:new C.Point(2*this.current.x-this.control.x,2*this.current.y-this.control.y)},this.makeAbsolute=function(t){return this.isRelativeCommand()&&(t.x+=this.current.x,t.y+=this.current.y),t},this.addMarker=function(t,e,i){null!=i&&0<this.angles.length&&null==this.angles[this.angles.length-1]&&(this.angles[this.angles.length-1]=this.points[this.points.length-1].angleTo(i)),this.addMarkerAngle(t,null==e?null:e.angleTo(t))},this.addMarkerAngle=function(t,e){this.points.push(t),this.angles.push(e)},this.getMarkerPoints=function(){return this.points},this.getMarkerAngles=function(){for(var t=0;t<this.angles.length;t++)if(null==this.angles[t])for(var e=t+1;e<this.angles.length;e++)if(null!=this.angles[e]){this.angles[t]=this.angles[e];break}return this.angles}}(e),this.path=function(t){var e=this.PathParser,i=(e.reset(),new C.BoundingBox);for(null!=t&&t.beginPath();!e.isEnd();)switch(e.nextCommand(),e.command){case"M":case"m":var n=e.getAsCurrentPoint();for(e.addMarker(n),i.addPoint(n.x,n.y),null!=t&&t.moveTo(n.x,n.y),e.start=e.current;!e.isCommandOrEnd();){n=e.getAsCurrentPoint();e.addMarker(n,e.start),i.addPoint(n.x,n.y),null!=t&&t.lineTo(n.x,n.y)}break;case"L":case"l":for(;!e.isCommandOrEnd();){var r=e.current,n=e.getAsCurrentPoint();e.addMarker(n,r),i.addPoint(n.x,n.y),null!=t&&t.lineTo(n.x,n.y)}break;case"H":case"h":for(;!e.isCommandOrEnd();){var o=new C.Point((e.isRelativeCommand()?e.current.x:0)+e.getScalar(),e.current.y);e.addMarker(o,e.current),e.current=o,i.addPoint(e.current.x,e.current.y),null!=t&&t.lineTo(e.current.x,e.current.y)}break;case"V":case"v":for(;!e.isCommandOrEnd();){o=new C.Point(e.current.x,(e.isRelativeCommand()?e.current.y:0)+e.getScalar());e.addMarker(o,e.current),e.current=o,i.addPoint(e.current.x,e.current.y),null!=t&&t.lineTo(e.current.x,e.current.y)}break;case"C":case"c":for(;!e.isCommandOrEnd();){var s=e.current,a=e.getPoint(),l=e.getAsControlPoint(),h=e.getAsCurrentPoint();e.addMarker(h,l,a),i.addBezierCurve(s.x,s.y,a.x,a.y,l.x,l.y,h.x,h.y),null!=t&&t.bezierCurveTo(a.x,a.y,l.x,l.y,h.x,h.y)}break;case"S":case"s":for(;!e.isCommandOrEnd();){s=e.current,a=e.getReflectedControlPoint(),l=e.getAsControlPoint(),h=e.getAsCurrentPoint();e.addMarker(h,l,a),i.addBezierCurve(s.x,s.y,a.x,a.y,l.x,l.y,h.x,h.y),null!=t&&t.bezierCurveTo(a.x,a.y,l.x,l.y,h.x,h.y)}break;case"Q":case"q":for(;!e.isCommandOrEnd();){s=e.current,l=e.getAsControlPoint(),h=e.getAsCurrentPoint();e.addMarker(h,l,l),i.addQuadraticCurve(s.x,s.y,l.x,l.y,h.x,h.y),null!=t&&t.quadraticCurveTo(l.x,l.y,h.x,h.y)}break;case"T":case"t":for(;!e.isCommandOrEnd();){s=e.current,l=e.getReflectedControlPoint(),h=(e.control=l,e.getAsCurrentPoint());e.addMarker(h,l,l),i.addQuadraticCurve(s.x,s.y,l.x,l.y,h.x,h.y),null!=t&&t.quadraticCurveTo(l.x,l.y,h.x,h.y)}break;case"A":case"a":for(;!e.isCommandOrEnd();){var s=e.current,c=e.getScalar(),u=e.getScalar(),d=e.getScalar()*(Math.PI/180),g=e.getScalar(),p=e.getScalar(),h=e.getAsCurrentPoint(),f=new C.Point(Math.cos(d)*(s.x-h.x)/2+Math.sin(d)*(s.y-h.y)/2,-Math.sin(d)*(s.x-h.x)/2+Math.cos(d)*(s.y-h.y)/2),m=Math.pow(f.x,2)/Math.pow(c,2)+Math.pow(f.y,2)/Math.pow(u,2),m=(1<m&&(c*=Math.sqrt(m),u*=Math.sqrt(m)),(g==p?-1:1)*Math.sqrt((Math.pow(c,2)*Math.pow(u,2)-Math.pow(c,2)*Math.pow(f.y,2)-Math.pow(u,2)*Math.pow(f.x,2))/(Math.pow(c,2)*Math.pow(f.y,2)+Math.pow(u,2)*Math.pow(f.x,2)))),g=(isNaN(m)&&(m=0),new C.Point(m*c*f.y/u,m*-u*f.x/c)),m=new C.Point((s.x+h.x)/2+Math.cos(d)*g.x-Math.sin(d)*g.y,(s.y+h.y)/2+Math.sin(d)*g.x+Math.cos(d)*g.y),v=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2))},y=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(v(t)*v(e))},b=function(t,e){return(t[0]*e[1]<t[1]*e[0]?-1:1)*Math.acos(y(t,e))},w=b([1,0],[(f.x-g.x)/c,(f.y-g.y)/u]),A=[(f.x-g.x)/c,(f.y-g.y)/u],f=[(-f.x-g.x)/c,(-f.y-g.y)/u],g=b(A,f),b=(y(A,f)<=-1&&(g=Math.PI),1-p?1:-1),A=w+(g=1<=y(A,f)?0:g)/2*b,f=new C.Point(m.x+c*Math.cos(A),m.y+u*Math.sin(A));e.addMarkerAngle(f,A-b*Math.PI/2),e.addMarkerAngle(h,A-b*Math.PI),i.addPoint(h.x,h.y),null!=t&&(y=u<c?c:u,f=u<c?1:c/u,A=u<c?u/c:1,t.translate(m.x,m.y),t.rotate(d),t.scale(f,A),t.arc(0,0,y,w,w+g,1-p),t.scale(1/f,1/A),t.rotate(-d),t.translate(-m.x,-m.y))}break;case"Z":case"z":null!=t&&t.closePath(),e.current=e.start}return i},this.getMarkers=function(){for(var t=this.PathParser.getMarkerPoints(),e=this.PathParser.getMarkerAngles(),i=[],n=0;n<t.length;n++)i.push([t[n],e[n]]);return i}},C.Element.path.prototype=new C.Element.PathElementBase,C.Element.pattern=function(t){this.base=C.Element.ElementBase,this.base(t),this.createPattern=function(t,e){var i=this.attribute("width").toPixels("x",!0),n=this.attribute("height").toPixels("y",!0),r=new C.Element.svg,o=(r.attributes.viewBox=new C.Property("viewBox",this.attribute("viewBox").value),r.attributes.width=new C.Property("width",i+"px"),r.attributes.height=new C.Property("height",n+"px"),r.attributes.transform=new C.Property("transform",this.attribute("patternTransform").value),r.children=this.children,document.createElement("canvas")),s=(o.width=i,o.height=n,o.getContext("2d"));this.attribute("x").hasValue()&&this.attribute("y").hasValue()&&s.translate(this.attribute("x").toPixels("x",!0),this.attribute("y").toPixels("y",!0));for(var a=-1;a<=1;a++)for(var l=-1;l<=1;l++)s.save(),r.attributes.x=new C.Property("x",a*o.width),r.attributes.y=new C.Property("y",l*o.height),r.render(s),s.restore();return t.createPattern(o,"repeat")}},C.Element.pattern.prototype=new C.Element.ElementBase,C.Element.marker=function(t){this.base=C.Element.ElementBase,this.base(t),this.baseRender=this.render,this.render=function(t,e,i){t.translate(e.x,e.y),"auto"==this.attribute("orient").valueOrDefault("auto")&&t.rotate(i),"strokeWidth"==this.attribute("markerUnits").valueOrDefault("strokeWidth")&&t.scale(t.lineWidth,t.lineWidth),t.save();var n=new C.Element.svg;n.attributes.viewBox=new C.Property("viewBox",this.attribute("viewBox").value),n.attributes.refX=new C.Property("refX",this.attribute("refX").value),n.attributes.refY=new C.Property("refY",this.attribute("refY").value),n.attributes.width=new C.Property("width",this.attribute("markerWidth").value),n.attributes.height=new C.Property("height",this.attribute("markerHeight").value),n.attributes.fill=new C.Property("fill",this.attribute("fill").valueOrDefault("black")),n.attributes.stroke=new C.Property("stroke",this.attribute("stroke").valueOrDefault("none")),n.children=this.children,n.render(t),t.restore(),"strokeWidth"==this.attribute("markerUnits").valueOrDefault("strokeWidth")&&t.scale(1/t.lineWidth,1/t.lineWidth),"auto"==this.attribute("orient").valueOrDefault("auto")&&t.rotate(-i),t.translate(-e.x,-e.y)}},C.Element.marker.prototype=new C.Element.ElementBase,C.Element.defs=function(t){this.base=C.Element.ElementBase,this.base(t),this.render=function(t){}},C.Element.defs.prototype=new C.Element.ElementBase,C.Element.GradientBase=function(t){this.base=C.Element.ElementBase,this.base(t),this.stops=[];for(var e=0;e<this.children.length;e++){var i=this.children[e];"stop"==i.type&&this.stops.push(i)}this.getGradient=function(){},this.gradientUnits=function(){return this.attribute("gradientUnits").valueOrDefault("objectBoundingBox")},this.attributesToInherit=["gradientUnits"],this.inheritStopContainer=function(t){for(var e=0;e<this.attributesToInherit.length;e++){var i=this.attributesToInherit[e];!this.attribute(i).hasValue()&&t.attribute(i).hasValue()&&(this.attribute(i,!0).value=t.attribute(i).value)}},this.createGradient=function(t,e,i){function n(t){return i.hasValue()?new C.Property("color",t).addOpacity(i).value:t}var r=this,o=(this.getHrefAttribute().hasValue()&&(r=this.getHrefAttribute().getDefinition(),this.inheritStopContainer(r)),this.getGradient(t,e));if(null==o)return n(r.stops[r.stops.length-1].color);for(var s,a=0;a<r.stops.length;a++)o.addColorStop(r.stops[a].offset,n(r.stops[a].color));return this.attribute("gradientTransform").hasValue()?(t=C.ViewPort.viewPorts[0],(e=new C.Element.rect).attributes.x=new C.Property("x",-C.MAX_VIRTUAL_PIXELS/3),e.attributes.y=new C.Property("y",-C.MAX_VIRTUAL_PIXELS/3),e.attributes.width=new C.Property("width",C.MAX_VIRTUAL_PIXELS),e.attributes.height=new C.Property("height",C.MAX_VIRTUAL_PIXELS),(s=new C.Element.g).attributes.transform=new C.Property("transform",this.attribute("gradientTransform").value),s.children=[e],(e=new C.Element.svg).attributes.x=new C.Property("x",0),e.attributes.y=new C.Property("y",0),e.attributes.width=new C.Property("width",t.width),e.attributes.height=new C.Property("height",t.height),e.children=[s],(s=document.createElement("canvas")).width=t.width,s.height=t.height,(t=s.getContext("2d")).fillStyle=o,e.render(t),t.createPattern(s,"no-repeat")):o}},C.Element.GradientBase.prototype=new C.Element.ElementBase,C.Element.linearGradient=function(t){this.base=C.Element.GradientBase,this.base(t),this.attributesToInherit.push("x1"),this.attributesToInherit.push("y1"),this.attributesToInherit.push("x2"),this.attributesToInherit.push("y2"),this.getGradient=function(t,e){var e="objectBoundingBox"==this.gradientUnits()?e.getBoundingBox():null,i=(this.attribute("x1").hasValue()||this.attribute("y1").hasValue()||this.attribute("x2").hasValue()||this.attribute("y2").hasValue()||(this.attribute("x1",!0).value=0,this.attribute("y1",!0).value=0,this.attribute("x2",!0).value=1,this.attribute("y2",!0).value=0),"objectBoundingBox"==this.gradientUnits()?e.x()+e.width()*this.attribute("x1").numValue():this.attribute("x1").toPixels("x")),n="objectBoundingBox"==this.gradientUnits()?e.y()+e.height()*this.attribute("y1").numValue():this.attribute("y1").toPixels("y"),r="objectBoundingBox"==this.gradientUnits()?e.x()+e.width()*this.attribute("x2").numValue():this.attribute("x2").toPixels("x"),e="objectBoundingBox"==this.gradientUnits()?e.y()+e.height()*this.attribute("y2").numValue():this.attribute("y2").toPixels("y");return i==r&&n==e?null:t.createLinearGradient(i,n,r,e)}},C.Element.linearGradient.prototype=new C.Element.GradientBase,C.Element.radialGradient=function(t){this.base=C.Element.GradientBase,this.base(t),this.attributesToInherit.push("cx"),this.attributesToInherit.push("cy"),this.attributesToInherit.push("r"),this.attributesToInherit.push("fx"),this.attributesToInherit.push("fy"),this.getGradient=function(t,e){var e=e.getBoundingBox(),i=(this.attribute("cx").hasValue()||(this.attribute("cx",!0).value="50%"),this.attribute("cy").hasValue()||(this.attribute("cy",!0).value="50%"),this.attribute("r").hasValue()||(this.attribute("r",!0).value="50%"),"objectBoundingBox"==this.gradientUnits()?e.x()+e.width()*this.attribute("cx").numValue():this.attribute("cx").toPixels("x")),n="objectBoundingBox"==this.gradientUnits()?e.y()+e.height()*this.attribute("cy").numValue():this.attribute("cy").toPixels("y"),r=i,o=n,e=(this.attribute("fx").hasValue()&&(r="objectBoundingBox"==this.gradientUnits()?e.x()+e.width()*this.attribute("fx").numValue():this.attribute("fx").toPixels("x")),this.attribute("fy").hasValue()&&(o="objectBoundingBox"==this.gradientUnits()?e.y()+e.height()*this.attribute("fy").numValue():this.attribute("fy").toPixels("y")),"objectBoundingBox"==this.gradientUnits()?(e.width()+e.height())/2*this.attribute("r").numValue():this.attribute("r").toPixels());return t.createRadialGradient(r,o,0,i,n,e)}},C.Element.radialGradient.prototype=new C.Element.GradientBase,C.Element.stop=function(t){this.base=C.Element.ElementBase,this.base(t),this.offset=this.attribute("offset").numValue(),this.offset<0&&(this.offset=0),1<this.offset&&(this.offset=1);t=this.style("stop-color",!0);""===t.value&&(t.value="#000"),this.style("stop-opacity").hasValue()&&(t=t.addOpacity(this.style("stop-opacity"))),this.color=t.value},C.Element.stop.prototype=new C.Element.ElementBase,C.Element.AnimateBase=function(t){this.base=C.Element.ElementBase,this.base(t),C.Animations.push(this),this.duration=0,this.begin=this.attribute("begin").toMilliseconds(),this.maxDuration=this.begin+this.attribute("dur").toMilliseconds(),this.getProperty=function(){var t=this.attribute("attributeType").value,e=this.attribute("attributeName").value;return"CSS"==t?this.parent.style(e,!0):this.parent.attribute(e,!0)},this.initialValue=null,this.initialUnits="",this.removed=!1,this.calcValue=function(){return""},this.update=function(t){if(null==this.initialValue&&(this.initialValue=this.getProperty().value,this.initialUnits=this.getProperty().getUnits()),this.duration>this.maxDuration){if("indefinite"==this.attribute("repeatCount").value||"indefinite"==this.attribute("repeatDur").value)this.duration=0;else if("freeze"!=this.attribute("fill").valueOrDefault("remove")||this.frozen){if("remove"==this.attribute("fill").valueOrDefault("remove")&&!this.removed)return this.removed=!0,this.getProperty().value=this.parent.animationFrozen?this.parent.animationFrozenValue:this.initialValue,!0}else this.frozen=!0,this.parent.animationFrozen=!0,this.parent.animationFrozenValue=this.getProperty().value;return!1}this.duration=this.duration+t;var e,t=!1;return this.begin<this.duration&&(e=this.calcValue(),this.attribute("type").hasValue()&&(e=this.attribute("type").value+"("+e+")"),this.getProperty().value=e,t=!0),t},this.from=this.attribute("from"),this.to=this.attribute("to"),this.values=this.attribute("values"),this.values.hasValue()&&(this.values.value=this.values.value.split(";")),this.progress=function(){var t,e,i,n={progress:(this.duration-this.begin)/(this.maxDuration-this.begin)};return this.values.hasValue()?(t=n.progress*(this.values.value.length-1),e=Math.floor(t),i=Math.ceil(t),n.from=new C.Property("from",parseFloat(this.values.value[e])),n.to=new C.Property("to",parseFloat(this.values.value[i])),n.progress=(t-e)/(i-e)):(n.from=this.from,n.to=this.to),n}},C.Element.AnimateBase.prototype=new C.Element.ElementBase,C.Element.animate=function(t){this.base=C.Element.AnimateBase,this.base(t),this.calcValue=function(){var t=this.progress();return t.from.numValue()+(t.to.numValue()-t.from.numValue())*t.progress+this.initialUnits}},C.Element.animate.prototype=new C.Element.AnimateBase,C.Element.animateColor=function(t){this.base=C.Element.AnimateBase,this.base(t),this.calcValue=function(){var t,e,i=this.progress(),n=new l(i.from.value),r=new l(i.to.value);return n.ok&&r.ok?(t=n.r+(r.r-n.r)*i.progress,e=n.g+(r.g-n.g)*i.progress,r=n.b+(r.b-n.b)*i.progress,"rgb("+parseInt(t,10)+","+parseInt(e,10)+","+parseInt(r,10)+")"):this.attribute("from").value}},C.Element.animateColor.prototype=new C.Element.AnimateBase,C.Element.animateTransform=function(t){this.base=C.Element.AnimateBase,this.base(t),this.calcValue=function(){for(var t=this.progress(),e=C.ToNumberArray(t.from.value),i=C.ToNumberArray(t.to.value),n="",r=0;r<e.length;r++)n+=e[r]+(i[r]-e[r])*t.progress+" ";return n}},C.Element.animateTransform.prototype=new C.Element.animate,C.Element.font=function(t){this.base=C.Element.ElementBase,this.base(t),this.horizAdvX=this.attribute("horiz-adv-x").numValue(),this.isRTL=!1,this.isArabic=!1,this.fontFace=null,this.missingGlyph=null,this.glyphs=[];for(var e=0;e<this.children.length;e++){var i=this.children[e];"font-face"==i.type?(this.fontFace=i).style("font-family").hasValue()&&(C.Definitions[i.style("font-family").value]=this):"missing-glyph"==i.type?this.missingGlyph=i:"glyph"==i.type&&(""!=i.arabicForm?(this.isRTL=!0,this.isArabic=!0,void 0===this.glyphs[i.unicode]&&(this.glyphs[i.unicode]=[]),this.glyphs[i.unicode][i.arabicForm]=i):this.glyphs[i.unicode]=i)}},C.Element.font.prototype=new C.Element.ElementBase,C.Element.fontface=function(t){this.base=C.Element.ElementBase,this.base(t),this.ascent=this.attribute("ascent").value,this.descent=this.attribute("descent").value,this.unitsPerEm=this.attribute("units-per-em").numValue()},C.Element.fontface.prototype=new C.Element.ElementBase,C.Element.missingglyph=function(t){this.base=C.Element.path,this.base(t),this.horizAdvX=0},C.Element.missingglyph.prototype=new C.Element.path,C.Element.glyph=function(t){this.base=C.Element.path,this.base(t),this.horizAdvX=this.attribute("horiz-adv-x").numValue(),this.unicode=this.attribute("unicode").value,this.arabicForm=this.attribute("arabic-form").value},C.Element.glyph.prototype=new C.Element.path,C.Element.text=function(t){this.captureTextNodes=!0,this.base=C.Element.RenderedElementBase,this.base(t),this.baseSetContext=this.setContext,this.setContext=function(t){this.baseSetContext(t);var e=this.style("dominant-baseline").toTextBaseline();null!=(e=null==e?this.style("alignment-baseline").toTextBaseline():e)&&(t.textBaseline=e)},this.getBoundingBox=function(){var t=this.attribute("x").toPixels("x"),e=this.attribute("y").toPixels("y"),i=this.parent.style("font-size").numValueOrDefault(C.Font.Parse(C.ctx.font).fontSize);return new C.BoundingBox(t,e-i,t+Math.floor(2*i/3)*this.children[0].getText().length,e)},this.renderChildren=function(t){this.x=this.attribute("x").toPixels("x"),this.y=this.attribute("y").toPixels("y"),this.attribute("dx").hasValue()&&(this.x+=this.attribute("dx").toPixels("x")),this.attribute("dy").hasValue()&&(this.y+=this.attribute("dy").toPixels("y")),this.x+=this.getAnchorDelta(t,this,0);for(var e=0;e<this.children.length;e++)this.renderChild(t,this,this,e)},this.getAnchorDelta=function(t,e,i){var n=this.style("text-anchor").valueOrDefault("start");if("start"==n)return 0;for(var r=0,o=i;o<e.children.length;o++){var s=e.children[o];if(i<o&&s.attribute("x").hasValue())break;r+=s.measureTextRecursive(t)}return-1*("end"==n?r:r/2)},this.renderChild=function(t,e,i,n){var r=i.children[n];r.attribute("x").hasValue()?(r.x=r.attribute("x").toPixels("x")+e.getAnchorDelta(t,i,n),r.attribute("dx").hasValue()&&(r.x+=r.attribute("dx").toPixels("x"))):(r.attribute("dx").hasValue()&&(e.x+=r.attribute("dx").toPixels("x")),r.x=e.x),e.x=r.x+r.measureText(t),r.attribute("y").hasValue()?(r.y=r.attribute("y").toPixels("y"),r.attribute("dy").hasValue()&&(r.y+=r.attribute("dy").toPixels("y"))):(r.attribute("dy").hasValue()&&(e.y+=r.attribute("dy").toPixels("y")),r.y=e.y),e.y=r.y,r.render(t);for(n=0;n<r.children.length;n++)e.renderChild(t,e,r,n)}},C.Element.text.prototype=new C.Element.RenderedElementBase,C.Element.TextElementBase=function(t){this.base=C.Element.RenderedElementBase,this.base(t),this.getGlyph=function(t,e,i){var n,r=e[i],o=null;return t.isArabic?(n="isolated",(0==i||" "==e[i-1])&&i<e.length-2&&" "!=e[i+1]&&(n="terminal"),0<i&&" "!=e[i-1]&&i<e.length-2&&" "!=e[i+1]&&(n="medial"),0<i&&" "!=e[i-1]&&(i==e.length-1||" "==e[i+1])&&(n="initial"),void 0!==t.glyphs[r]&&null==(o=t.glyphs[r][n])&&"glyph"==t.glyphs[r].type&&(o=t.glyphs[r])):o=t.glyphs[r],o=null==o?t.missingGlyph:o},this.renderChildren=function(t){var e=this.parent.style("font-family").getDefinition();if(null!=e)for(var i=this.parent.style("font-size").numValueOrDefault(C.Font.Parse(C.ctx.font).fontSize),n=this.parent.style("font-style").valueOrDefault(C.Font.Parse(C.ctx.font).fontStyle),r=this.getText(),o=(e.isRTL&&(r=r.split("").reverse().join("")),C.ToNumberArray(this.parent.attribute("dx").value)),s=0;s<r.length;s++){var a=this.getGlyph(e,r,s),l=i/e.fontFace.unitsPerEm,h=(t.translate(this.x,this.y),t.scale(l,-l),t.lineWidth);t.lineWidth=t.lineWidth*e.fontFace.unitsPerEm/i,"italic"==n&&t.transform(1,0,.4,1,0,0),a.render(t),"italic"==n&&t.transform(1,0,-.4,1,0,0),t.lineWidth=h,t.scale(1/l,-1/l),t.translate(-this.x,-this.y),this.x+=i*(a.horizAdvX||e.horizAdvX)/e.fontFace.unitsPerEm,void 0===o[s]||isNaN(o[s])||(this.x+=o[s])}else""!=t.fillStyle&&t.fillText(C.compressSpaces(this.getText()),this.x,this.y),""!=t.strokeStyle&&t.strokeText(C.compressSpaces(this.getText()),this.x,this.y)},this.getText=function(){},this.measureTextRecursive=function(t){for(var e=this.measureText(t),i=0;i<this.children.length;i++)e+=this.children[i].measureTextRecursive(t);return e},this.measureText=function(t){var e=this.parent.style("font-family").getDefinition();if(null!=e){for(var i=this.parent.style("font-size").numValueOrDefault(C.Font.Parse(C.ctx.font).fontSize),n=0,r=this.getText(),o=(e.isRTL&&(r=r.split("").reverse().join("")),C.ToNumberArray(this.parent.attribute("dx").value)),s=0;s<r.length;s++)n+=(this.getGlyph(e,r,s).horizAdvX||e.horizAdvX)*i/e.fontFace.unitsPerEm,void 0===o[s]||isNaN(o[s])||(n+=o[s]);return n}var a=C.compressSpaces(this.getText());if(!t.measureText)return 10*a.length;t.save(),this.setContext(t);a=t.measureText(a).width;return t.restore(),a}},C.Element.TextElementBase.prototype=new C.Element.RenderedElementBase,C.Element.tspan=function(t){this.captureTextNodes=!0,this.base=C.Element.TextElementBase,this.base(t),this.text=C.compressSpaces(t.value||t.text||t.textContent||""),this.getText=function(){return 0<this.children.length?"":this.text}},C.Element.tspan.prototype=new C.Element.TextElementBase,C.Element.tref=function(t){this.base=C.Element.TextElementBase,this.base(t),this.getText=function(){var t=this.getHrefAttribute().getDefinition();if(null!=t)return t.children[0].getText()}},C.Element.tref.prototype=new C.Element.TextElementBase,C.Element.a=function(t){this.base=C.Element.TextElementBase,this.base(t),this.hasText=0<t.childNodes.length;for(var e=0;e<t.childNodes.length;e++)3!=t.childNodes[e].nodeType&&(this.hasText=!1);this.text=this.hasText?t.childNodes[0].value:"",this.getText=function(){return this.text},this.baseRenderChildren=this.renderChildren,this.renderChildren=function(t){var e;this.hasText?(this.baseRenderChildren(t),e=new C.Property("fontSize",C.Font.Parse(C.ctx.font).fontSize),C.Mouse.checkBoundingBox(this,new C.BoundingBox(this.x,this.y-e.toPixels("y"),this.x+this.measureText(t),this.y))):0<this.children.length&&((e=new C.Element.g).children=this.children,e.parent=this,e.render(t))},this.onclick=function(){window.open(this.getHrefAttribute().value)},this.onmousemove=function(){C.ctx.canvas.style.cursor="pointer"}},C.Element.a.prototype=new C.Element.TextElementBase,C.Element.image=function(t){this.base=C.Element.RenderedElementBase,this.base(t);var o,e,i=this.getHrefAttribute().value;""!=i&&(o=i.match(/\.svg$/),C.Images.push(this),this.loaded=!1,o?(this.img=C.ajax(i),this.loaded=!0):(this.img=document.createElement("img"),1==C.opts.useCORS&&(this.img.crossOrigin="Anonymous"),(e=this).img.onload=function(){e.loaded=!0},this.img.onerror=function(){C.log('ERROR: image "'+i+'" not found'),e.loaded=!0},this.img.src=i),this.renderChildren=function(t){var e=this.attribute("x").toPixels("x"),i=this.attribute("y").toPixels("y"),n=this.attribute("width").toPixels("x"),r=this.attribute("height").toPixels("y");0!=n&&0!=r&&(t.save(),o?t.drawSvg(this.img,e,i,n,r):(t.translate(e,i),C.AspectRatio(t,this.attribute("preserveAspectRatio").value,n,this.img.width,r,this.img.height,0,0),t.drawImage(this.img,0,0)),t.restore())},this.getBoundingBox=function(){var t=this.attribute("x").toPixels("x"),e=this.attribute("y").toPixels("y"),i=this.attribute("width").toPixels("x"),n=this.attribute("height").toPixels("y");return new C.BoundingBox(t,e,t+i,e+n)})},C.Element.image.prototype=new C.Element.RenderedElementBase,C.Element.g=function(t){this.base=C.Element.RenderedElementBase,this.base(t),this.getBoundingBox=function(){for(var t=new C.BoundingBox,e=0;e<this.children.length;e++)t.addBoundingBox(this.children[e].getBoundingBox());return t}},C.Element.g.prototype=new C.Element.RenderedElementBase,C.Element.symbol=function(t){this.base=C.Element.RenderedElementBase,this.base(t),this.render=function(t){}},C.Element.symbol.prototype=new C.Element.RenderedElementBase,C.Element.style=function(t){this.base=C.Element.ElementBase,this.base(t);for(var e="",i=0;i<t.childNodes.length;i++)e+=t.childNodes[i].data;e=e.replace(/(\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)|(^[\s]*\/\/.*)/gm,"");for(var n=(e=C.compressSpaces(e)).split("}"),i=0;i<n.length;i++)if(""!=C.trim(n[i]))for(var r=n[i].split("{"),o=r[0].split(","),s=r[1].split(";"),a=0;a<o.length;a++){var l=C.trim(o[a]);if(""!=l){for(var h=C.Styles[l]||{},c=0;c<s.length;c++){var u=s[c].indexOf(":"),d=s[c].substr(0,u),u=s[c].substr(u+1,s[c].length-u);null!=d&&null!=u&&(h[C.trim(d)]=new C.Property(C.trim(d),C.trim(u)))}if(C.Styles[l]=h,C.StylesSpecificity[l]=function(n){function t(t,e){var i=n.match(t);null!=i&&(r[e]+=i.length,n=n.replace(t," "))}var r=[0,0,0];return n=(n=n.replace(/:not\(([^\)]*)\)/g," $1 ")).replace(/{[\s\S]*/gm," "),t(A,1),t(I,0),t(x,1),t(S,2),t(P,1),t(M,1),n=(n=n.replace(/[\*\s\+>~]/g," ")).replace(/[#\.]/g," "),t(k,2),r.join("")}(l),"@font-face"==l)for(var g=h["font-family"].value.replace(/"/g,""),p=h.src.value.split(","),f=0;f<p.length;f++)if(0<p[f].indexOf('format("svg")'))for(var m=p[f].indexOf("url"),v=p[f].indexOf(")",m),v=p[f].substr(m+5,v-m-6),y=C.parseXml(C.ajax(v)).getElementsByTagName("font"),b=0;b<y.length;b++){var w=C.CreateElement(y[b]);C.Definitions[g]=w}}}},C.Element.style.prototype=new C.Element.ElementBase,C.Element.use=function(t){this.base=C.Element.RenderedElementBase,this.base(t),this.baseSetContext=this.setContext,this.setContext=function(t){this.baseSetContext(t),this.attribute("x").hasValue()&&t.translate(this.attribute("x").toPixels("x"),0),this.attribute("y").hasValue()&&t.translate(0,this.attribute("y").toPixels("y"))};var n=this.getHrefAttribute().getDefinition();this.path=function(t){null!=n&&n.path(t)},this.getBoundingBox=function(){if(null!=n)return n.getBoundingBox()},this.renderChildren=function(t){var e,i;null!=n&&("symbol"==(e=n).type&&((e=new C.Element.svg).type="svg",e.attributes.viewBox=new C.Property("viewBox",n.attribute("viewBox").value),e.attributes.preserveAspectRatio=new C.Property("preserveAspectRatio",n.attribute("preserveAspectRatio").value),e.attributes.overflow=new C.Property("overflow",n.attribute("overflow").value),e.children=n.children),"svg"==e.type&&(this.attribute("width").hasValue()&&(e.attributes.width=new C.Property("width",this.attribute("width").value)),this.attribute("height").hasValue()&&(e.attributes.height=new C.Property("height",this.attribute("height").value))),i=e.parent,e.parent=null,e.render(t),e.parent=i)}},C.Element.use.prototype=new C.Element.RenderedElementBase,C.Element.mask=function(t){this.base=C.Element.ElementBase,this.base(t),this.apply=function(t,e){var i=this.attribute("x").toPixels("x"),n=this.attribute("y").toPixels("y"),r=this.attribute("width").toPixels("x"),o=this.attribute("height").toPixels("y");if(0==r&&0==o){for(var s=new C.BoundingBox,a=0;a<this.children.length;a++)s.addBoundingBox(this.children[a].getBoundingBox());i=Math.floor(s.x1),n=Math.floor(s.y1),r=Math.floor(s.width()),o=Math.floor(s.height())}var l=e.attribute("mask").value,h=(e.attribute("mask").value="",document.createElement("canvas")),c=(h.width=i+r,h.height=n+o,h.getContext("2d")),u=(this.renderChildren(c),document.createElement("canvas")),d=(u.width=i+r,u.height=n+o,u.getContext("2d"));e.render(d),d.globalCompositeOperation="destination-in",d.fillStyle=c.createPattern(h,"no-repeat"),d.fillRect(0,0,i+r,n+o),t.fillStyle=d.createPattern(u,"no-repeat"),t.fillRect(0,0,i+r,n+o),e.attribute("mask").value=l},this.render=function(t){}},C.Element.mask.prototype=new C.Element.ElementBase,C.Element.clipPath=function(t){this.base=C.Element.ElementBase,this.base(t),this.apply=function(t){var e=CanvasRenderingContext2D.prototype.beginPath,i=(CanvasRenderingContext2D.prototype.beginPath=function(){},CanvasRenderingContext2D.prototype.closePath);CanvasRenderingContext2D.prototype.closePath=function(){},e.call(t);for(var n=0;n<this.children.length;n++){var r,o=this.children[n];void 0!==o.path&&(o.style("transform",!1,!(r=null)).hasValue()&&(r=new C.Transform(o.style("transform",!1,!0).value)).apply(t),o.path(t),CanvasRenderingContext2D.prototype.closePath=i,r&&r.unapply(t))}i.call(t),t.clip(),CanvasRenderingContext2D.prototype.beginPath=e,CanvasRenderingContext2D.prototype.closePath=i},this.render=function(t){}},C.Element.clipPath.prototype=new C.Element.ElementBase,C.Element.filter=function(t){this.base=C.Element.ElementBase,this.base(t),this.apply=function(t,e){for(var i=e.getBoundingBox(),n=Math.floor(i.x1),r=Math.floor(i.y1),o=Math.floor(i.width()),s=Math.floor(i.height()),i=e.style("filter").value,a=(e.style("filter").value="",0),l=0,h=0;h<this.children.length;h++)var c=this.children[h].extraFilterDistance||0,a=Math.max(a,c),l=Math.max(l,c);var u=document.createElement("canvas"),d=(u.width=o+2*a,u.height=s+2*l,u.getContext("2d"));d.translate(-n+a,-r+l),e.render(d);for(h=0;h<this.children.length;h++)"function"==typeof this.children[h].apply&&this.children[h].apply(d,0,0,o+2*a,s+2*l);t.drawImage(u,0,0,o+2*a,s+2*l,n-a,r-l,o+2*a,s+2*l),e.style("filter",!0).value=i},this.render=function(t){}},C.Element.filter.prototype=new C.Element.ElementBase,C.Element.feDropShadow=function(t){this.base=C.Element.ElementBase,this.base(t),this.addStylesFromStyleDefinition(),this.apply=function(t,e,i,n,r){}},C.Element.feDropShadow.prototype=new C.Element.ElementBase,C.Element.feMorphology=function(t){this.base=C.Element.ElementBase,this.base(t),this.apply=function(t,e,i,n,r){}},C.Element.feMorphology.prototype=new C.Element.ElementBase,C.Element.feComposite=function(t){this.base=C.Element.ElementBase,this.base(t),this.apply=function(t,e,i,n,r){}},C.Element.feComposite.prototype=new C.Element.ElementBase,C.Element.feColorMatrix=function(t){this.base=C.Element.ElementBase,this.base(t);var i=C.ToNumberArray(this.attribute("values").value);switch(this.attribute("type").valueOrDefault("matrix")){case"saturate":var e=i[0],i=[.213+.787*e,.715-.715*e,.072-.072*e,0,0,.213-.213*e,.715+.285*e,.072-.072*e,0,0,.213-.213*e,.715-.715*e,.072+.928*e,0,0,0,0,0,1,0,0,0,0,0,1];break;case"hueRotate":var n=i[0]*Math.PI/180,e=function(t,e,i){return t+Math.cos(n)*e+Math.sin(n)*i};i=[e(.213,.787,-.213),e(.715,-.715,-.715),e(.072,-.072,.928),0,0,e(.213,-.213,.143),e(.715,.285,.14),e(.072,-.072,-.283),0,0,e(.213,-.213,-.787),e(.715,-.715,.715),e(.072,.928,.072),0,0,0,0,0,1,0,0,0,0,0,1];break;case"luminanceToAlpha":i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.2125,.7154,.0721,0,0,0,0,0,0,1]}function c(t,e,i,n,r,o){return t[i*n*4+4*e+o]}function u(t,e,i,n,r,o,s){t[i*n*4+4*e+o]=s}function d(t,e){t=i[t];return t*(t<0?e-255:e)}this.apply=function(t,e,i,n,r){for(var o=t.getImageData(0,0,n,r),i=0;i<r;i++)for(e=0;e<n;e++){var s=c(o.data,e,i,n,0,0),a=c(o.data,e,i,n,0,1),l=c(o.data,e,i,n,0,2),h=c(o.data,e,i,n,0,3);u(o.data,e,i,n,0,0,d(0,s)+d(1,a)+d(2,l)+d(3,h)+d(4,1)),u(o.data,e,i,n,0,1,d(5,s)+d(6,a)+d(7,l)+d(8,h)+d(9,1)),u(o.data,e,i,n,0,2,d(10,s)+d(11,a)+d(12,l)+d(13,h)+d(14,1)),u(o.data,e,i,n,0,3,d(15,s)+d(16,a)+d(17,l)+d(18,h)+d(19,1))}t.clearRect(0,0,n,r),t.putImageData(o,0,0)}},C.Element.feColorMatrix.prototype=new C.Element.ElementBase,C.Element.feGaussianBlur=function(t){this.base=C.Element.ElementBase,this.base(t),this.blurRadius=Math.floor(this.attribute("stdDeviation").numValue()),this.extraFilterDistance=this.blurRadius,this.apply=function(t,e,i,n,r){void 0===h.canvasRGBA?C.log("ERROR: StackBlur.js must be included for blur to work"):(t.canvas.id=C.UniqueId(),t.canvas.style.display="none",document.body.appendChild(t.canvas),h.canvasRGBA(t.canvas.id,e,i,n,r,this.blurRadius),document.body.removeChild(t.canvas))}},C.Element.feGaussianBlur.prototype=new C.Element.ElementBase,C.Element.title=function(t){},C.Element.title.prototype=new C.Element.ElementBase,C.Element.desc=function(t){},C.Element.desc.prototype=new C.Element.ElementBase,C.Element.MISSING=function(t){C.log("ERROR: Element '"+t.nodeName+"' not yet implemented.")},C.Element.MISSING.prototype=new C.Element.ElementBase,C.CreateElement=function(t){var e=(e=t.nodeName.replace(/^[^:]+:/,"")).replace(/\-/g,""),i=null;return(i=new(void 0!==C.Element[e]?C.Element[e]:C.Element.MISSING)(t)).type=t.nodeName,i},C.load=function(t,e){C.loadXml(t,C.ajax(e))},C.loadXml=function(t,e){C.loadXmlDoc(t,C.parseXml(e))},C.loadXmlDoc=function(o,s){C.init(o);function e(t){for(var e=o.canvas;e;)t.x-=e.offsetLeft,t.y-=e.offsetTop,e=e.offsetParent;return window.scrollX&&(t.x+=window.scrollX),window.scrollY&&(t.y+=window.scrollY),t}function i(){C.ViewPort.Clear(),o.canvas.parentNode&&C.ViewPort.SetCurrent(o.canvas.parentNode.clientWidth,o.canvas.parentNode.clientHeight),1!=C.opts.ignoreDimensions&&(a.style("width").hasValue()&&(o.canvas.width=a.style("width").toPixels("x"),o.canvas.style.width=o.canvas.width+"px"),a.style("height").hasValue()&&(o.canvas.height=a.style("height").toPixels("y"),o.canvas.style.height=o.canvas.height+"px"));var t,e,i,n=o.canvas.clientWidth||o.canvas.width,r=o.canvas.clientHeight||o.canvas.height;1==C.opts.ignoreDimensions&&a.style("width").hasValue()&&a.style("height").hasValue()&&(n=a.style("width").toPixels("x"),r=a.style("height").toPixels("y")),C.ViewPort.SetCurrent(n,r),null!=C.opts.offsetX&&(a.attribute("x",!0).value=C.opts.offsetX),null!=C.opts.offsetY&&(a.attribute("y",!0).value=C.opts.offsetY),null==C.opts.scaleWidth&&null==C.opts.scaleHeight||(e=t=null,i=C.ToNumberArray(a.attribute("viewBox").value),null!=C.opts.scaleWidth&&(a.attribute("width").hasValue()?t=a.attribute("width").toPixels("x")/C.opts.scaleWidth:isNaN(i[2])||(t=i[2]/C.opts.scaleWidth)),null!=C.opts.scaleHeight&&(a.attribute("height").hasValue()?e=a.attribute("height").toPixels("y")/C.opts.scaleHeight:isNaN(i[3])||(e=i[3]/C.opts.scaleHeight)),null==t&&(t=e),null==e&&(e=t),a.attribute("width",!0).value=C.opts.scaleWidth,a.attribute("height",!0).value=C.opts.scaleHeight,a.style("transform",!0,!0).value+=" scale("+1/t+","+1/e+")"),1!=C.opts.ignoreClear&&o.clearRect(0,0,n,r),a.render(o),l&&(l=!1,"function"==typeof C.opts.renderCallback&&C.opts.renderCallback(s))}1!=C.opts.ignoreMouse&&(o.canvas.onclick=function(t){t=e(new C.Point((null!=t?t:event).clientX,(null!=t?t:event).clientY));C.Mouse.onclick(t.x,t.y)},o.canvas.onmousemove=function(t){t=e(new C.Point((null!=t?t:event).clientX,(null!=t?t:event).clientY));C.Mouse.onmousemove(t.x,t.y)});var a=C.CreateElement(s.documentElement),l=(a.root=!0,a.addStylesFromStyleDefinition(),!0),n=!0;C.ImagesLoaded()&&(n=!1,i()),C.intervalID=setInterval(function(){var t=!1;if(n&&C.ImagesLoaded()&&(t=!(n=!1)),1!=C.opts.ignoreMouse&&(t|=C.Mouse.hasEvents()),1!=C.opts.ignoreAnimation)for(var e=0;e<C.Animations.length;e++)t|=C.Animations[e].update(1e3/C.FRAMERATE);(t="function"==typeof C.opts.forceRedraw&&1==C.opts.forceRedraw()?!0:t)&&(i(),C.Mouse.runEvents())},1e3/C.FRAMERATE)},C.stop=function(){C.intervalID&&clearInterval(C.intervalID)},C.Mouse=new function(){this.events=[],this.hasEvents=function(){return 0!=this.events.length},this.onclick=function(t,e){this.events.push({type:"onclick",x:t,y:e,run:function(t){t.onclick&&t.onclick()}})},this.onmousemove=function(t,e){this.events.push({type:"onmousemove",x:t,y:e,run:function(t){t.onmousemove&&t.onmousemove()}})},this.eventElements=[],this.checkPath=function(t,e){for(var i=0;i<this.events.length;i++){var n=this.events[i];e.isPointInPath&&e.isPointInPath(n.x,n.y)&&(this.eventElements[i]=t)}},this.checkBoundingBox=function(t,e){for(var i=0;i<this.events.length;i++){var n=this.events[i];e.isPointInBox(n.x,n.y)&&(this.eventElements[i]=t)}},this.runEvents=function(){C.ctx.canvas.style.cursor="";for(var t=0;t<this.events.length;t++)for(var e=this.events[t],i=this.eventElements[t];i;)e.run(i),i=i.parent;this.events=[],this.eventElements=[]}},C}(i||{}),t=(1==t.childNodes.length&&"OBJECT"==t.childNodes[0].nodeName||(t.svg=i),t.getContext("2d"));void 0!==e.documentElement?i.loadXmlDoc(t,e):"<"==e.substr(0,1)?i.loadXml(t,e):i.load(t,e)}},void 0!==Element.prototype.matches?u=function(t,e){return t.matches(e)}:void 0!==Element.prototype.webkitMatchesSelector?u=function(t,e){return t.webkitMatchesSelector(e)}:void 0!==Element.prototype.mozMatchesSelector?u=function(t,e){return t.mozMatchesSelector(e)}:void 0!==Element.prototype.msMatchesSelector?u=function(t,e){return t.msMatchesSelector(e)}:void 0!==Element.prototype.oMatchesSelector?u=function(t,e){return t.oMatchesSelector(e)}:void 0===(u="function"!=typeof jQuery&&"function"!=typeof Zepto?u:function(t,e){return $(t).is(e)})&&(u=Sizzle.matchesSelector),A=/(\[[^\]]+\])/g,I=/(#[^\s\+>~\.\[:]+)/g,x=/(\.[^\s\+>~\.\[:]+)/g,S=/(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi,P=/(:[\w-]+\([^\)]*\))/gi,M=/(:[^\s\+>~\.\[:]+)/g,k=/([^\s\+>~\.\[:]+)/g,"undefined"!=typeof CanvasRenderingContext2D&&(CanvasRenderingContext2D.prototype.drawSvg=function(t,e,i,n,r,o){var s,a={ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:e,offsetY:i,scaleWidth:n,scaleHeight:r};for(s in o)o.hasOwnProperty(s)&&(a[s]=o[s]);c(this.canvas,t,a)}),c},t.exports&&(t.exports=i(n=T,r=L)),e.canvg=i(void 0!==n?n:e.RGBColor,"undefined"!=typeof statckblur?r:e.stackBlur)})({exports:{}});function E(t,e){return e*U(t/e)}function V(t){return 180*t/X%360}function D(t,e){var i;return void 0===e?(e=void 0===t?1:t,t=0):e<t&&(i=t,t=e,e=i),H(Math.random()*(e-t+1)+t)}function Y(t,e){var i=K(t.y),n=K(e.y),t=t.x,e=e.x,e=K(e-t),t=it(e)*q(n),i=q(i)*it(n)-it(i)*q(n)*q(e);return(n=V(nt(t,i))-22.5)<0&&(n+=360),["NE","E","SE","S","SW","W","NW","N"][n=parseInt(n/45)]}function W(t,e){var i=t.x,t=t.y;return(i-=e.x)*i+(t-=e.y)*t}function F(t,e){return Math.sqrt(W(t,e))}"undefined"==typeof window||"SVGPathSeg"in window||(window.SVGPathSeg=function(t,e,i){this.pathSegType=t,this.pathSegTypeAsLetter=e,this._owningPathSegList=i},window.SVGPathSeg.prototype.classname="SVGPathSeg",window.SVGPathSeg.PATHSEG_UNKNOWN=0,window.SVGPathSeg.PATHSEG_CLOSEPATH=1,window.SVGPathSeg.PATHSEG_MOVETO_ABS=2,window.SVGPathSeg.PATHSEG_MOVETO_REL=3,window.SVGPathSeg.PATHSEG_LINETO_ABS=4,window.SVGPathSeg.PATHSEG_LINETO_REL=5,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS=6,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL=7,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS=8,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL=9,window.SVGPathSeg.PATHSEG_ARC_ABS=10,window.SVGPathSeg.PATHSEG_ARC_REL=11,window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS=12,window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL=13,window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS=14,window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL=15,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS=16,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL=17,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS=18,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL=19,window.SVGPathSeg.prototype._segmentChanged=function(){this._owningPathSegList&&this._owningPathSegList.segmentChanged(this)},window.SVGPathSegClosePath=function(t){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CLOSEPATH,"z",t)},window.SVGPathSegClosePath.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegClosePath.prototype.toString=function(){return"[object SVGPathSegClosePath]"},window.SVGPathSegClosePath.prototype._asPathString=function(){return this.pathSegTypeAsLetter},window.SVGPathSegClosePath.prototype.clone=function(){return new window.SVGPathSegClosePath(void 0)},window.SVGPathSegMovetoAbs=function(t,e,i){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_MOVETO_ABS,"M",t),this._x=e,this._y=i},window.SVGPathSegMovetoAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegMovetoAbs.prototype.toString=function(){return"[object SVGPathSegMovetoAbs]"},window.SVGPathSegMovetoAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegMovetoAbs.prototype.clone=function(){return new window.SVGPathSegMovetoAbs(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegMovetoAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegMovetoAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegMovetoRel=function(t,e,i){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_MOVETO_REL,"m",t),this._x=e,this._y=i},window.SVGPathSegMovetoRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegMovetoRel.prototype.toString=function(){return"[object SVGPathSegMovetoRel]"},window.SVGPathSegMovetoRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegMovetoRel.prototype.clone=function(){return new window.SVGPathSegMovetoRel(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegMovetoRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegMovetoRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoAbs=function(t,e,i){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_ABS,"L",t),this._x=e,this._y=i},window.SVGPathSegLinetoAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoAbs.prototype.toString=function(){return"[object SVGPathSegLinetoAbs]"},window.SVGPathSegLinetoAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegLinetoAbs.prototype.clone=function(){return new window.SVGPathSegLinetoAbs(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegLinetoAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegLinetoAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoRel=function(t,e,i){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_REL,"l",t),this._x=e,this._y=i},window.SVGPathSegLinetoRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoRel.prototype.toString=function(){return"[object SVGPathSegLinetoRel]"},window.SVGPathSegLinetoRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegLinetoRel.prototype.clone=function(){return new window.SVGPathSegLinetoRel(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegLinetoRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegLinetoRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoCubicAbs=function(t,e,i,n,r,o,s){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS,"C",t),this._x=e,this._y=i,this._x1=n,this._y1=r,this._x2=o,this._y2=s},window.SVGPathSegCurvetoCubicAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoCubicAbs.prototype.toString=function(){return"[object SVGPathSegCurvetoCubicAbs]"},window.SVGPathSegCurvetoCubicAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y},window.SVGPathSegCurvetoCubicAbs.prototype.clone=function(){return new window.SVGPathSegCurvetoCubicAbs(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)},Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"x1",{get:function(){return this._x1},set:function(t){this._x1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"y1",{get:function(){return this._y1},set:function(t){this._y1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"x2",{get:function(){return this._x2},set:function(t){this._x2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"y2",{get:function(){return this._y2},set:function(t){this._y2=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoCubicRel=function(t,e,i,n,r,o,s){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL,"c",t),this._x=e,this._y=i,this._x1=n,this._y1=r,this._x2=o,this._y2=s},window.SVGPathSegCurvetoCubicRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoCubicRel.prototype.toString=function(){return"[object SVGPathSegCurvetoCubicRel]"},window.SVGPathSegCurvetoCubicRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y},window.SVGPathSegCurvetoCubicRel.prototype.clone=function(){return new window.SVGPathSegCurvetoCubicRel(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)},Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"x1",{get:function(){return this._x1},set:function(t){this._x1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"y1",{get:function(){return this._y1},set:function(t){this._y1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"x2",{get:function(){return this._x2},set:function(t){this._x2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"y2",{get:function(){return this._y2},set:function(t){this._y2=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoQuadraticAbs=function(t,e,i,n,r){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS,"Q",t),this._x=e,this._y=i,this._x1=n,this._y1=r},window.SVGPathSegCurvetoQuadraticAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoQuadraticAbs.prototype.toString=function(){return"[object SVGPathSegCurvetoQuadraticAbs]"},window.SVGPathSegCurvetoQuadraticAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x+" "+this._y},window.SVGPathSegCurvetoQuadraticAbs.prototype.clone=function(){return new window.SVGPathSegCurvetoQuadraticAbs(void 0,this._x,this._y,this._x1,this._y1)},Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype,"x1",{get:function(){return this._x1},set:function(t){this._x1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype,"y1",{get:function(){return this._y1},set:function(t){this._y1=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoQuadraticRel=function(t,e,i,n,r){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL,"q",t),this._x=e,this._y=i,this._x1=n,this._y1=r},window.SVGPathSegCurvetoQuadraticRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoQuadraticRel.prototype.toString=function(){return"[object SVGPathSegCurvetoQuadraticRel]"},window.SVGPathSegCurvetoQuadraticRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x+" "+this._y},window.SVGPathSegCurvetoQuadraticRel.prototype.clone=function(){return new window.SVGPathSegCurvetoQuadraticRel(void 0,this._x,this._y,this._x1,this._y1)},Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype,"x1",{get:function(){return this._x1},set:function(t){this._x1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype,"y1",{get:function(){return this._y1},set:function(t){this._y1=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegArcAbs=function(t,e,i,n,r,o,s,a){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_ARC_ABS,"A",t),this._x=e,this._y=i,this._r1=n,this._r2=r,this._angle=o,this._largeArcFlag=s,this._sweepFlag=a},window.SVGPathSegArcAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegArcAbs.prototype.toString=function(){return"[object SVGPathSegArcAbs]"},window.SVGPathSegArcAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._r1+" "+this._r2+" "+this._angle+" "+(this._largeArcFlag?"1":"0")+" "+(this._sweepFlag?"1":"0")+" "+this._x+" "+this._y},window.SVGPathSegArcAbs.prototype.clone=function(){return new window.SVGPathSegArcAbs(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)},Object.defineProperty(window.SVGPathSegArcAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"r1",{get:function(){return this._r1},set:function(t){this._r1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"r2",{get:function(){return this._r2},set:function(t){this._r2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"largeArcFlag",{get:function(){return this._largeArcFlag},set:function(t){this._largeArcFlag=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"sweepFlag",{get:function(){return this._sweepFlag},set:function(t){this._sweepFlag=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegArcRel=function(t,e,i,n,r,o,s,a){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_ARC_REL,"a",t),this._x=e,this._y=i,this._r1=n,this._r2=r,this._angle=o,this._largeArcFlag=s,this._sweepFlag=a},window.SVGPathSegArcRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegArcRel.prototype.toString=function(){return"[object SVGPathSegArcRel]"},window.SVGPathSegArcRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._r1+" "+this._r2+" "+this._angle+" "+(this._largeArcFlag?"1":"0")+" "+(this._sweepFlag?"1":"0")+" "+this._x+" "+this._y},window.SVGPathSegArcRel.prototype.clone=function(){return new window.SVGPathSegArcRel(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)},Object.defineProperty(window.SVGPathSegArcRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"r1",{get:function(){return this._r1},set:function(t){this._r1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"r2",{get:function(){return this._r2},set:function(t){this._r2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"largeArcFlag",{get:function(){return this._largeArcFlag},set:function(t){this._largeArcFlag=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"sweepFlag",{get:function(){return this._sweepFlag},set:function(t){this._sweepFlag=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoHorizontalAbs=function(t,e){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS,"H",t),this._x=e},window.SVGPathSegLinetoHorizontalAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoHorizontalAbs.prototype.toString=function(){return"[object SVGPathSegLinetoHorizontalAbs]"},window.SVGPathSegLinetoHorizontalAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x},window.SVGPathSegLinetoHorizontalAbs.prototype.clone=function(){return new window.SVGPathSegLinetoHorizontalAbs(void 0,this._x)},Object.defineProperty(window.SVGPathSegLinetoHorizontalAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoHorizontalRel=function(t,e){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL,"h",t),this._x=e},window.SVGPathSegLinetoHorizontalRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoHorizontalRel.prototype.toString=function(){return"[object SVGPathSegLinetoHorizontalRel]"},window.SVGPathSegLinetoHorizontalRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x},window.SVGPathSegLinetoHorizontalRel.prototype.clone=function(){return new window.SVGPathSegLinetoHorizontalRel(void 0,this._x)},Object.defineProperty(window.SVGPathSegLinetoHorizontalRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoVerticalAbs=function(t,e){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS,"V",t),this._y=e},window.SVGPathSegLinetoVerticalAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoVerticalAbs.prototype.toString=function(){return"[object SVGPathSegLinetoVerticalAbs]"},window.SVGPathSegLinetoVerticalAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._y},window.SVGPathSegLinetoVerticalAbs.prototype.clone=function(){return new window.SVGPathSegLinetoVerticalAbs(void 0,this._y)},Object.defineProperty(window.SVGPathSegLinetoVerticalAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoVerticalRel=function(t,e){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL,"v",t),this._y=e},window.SVGPathSegLinetoVerticalRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoVerticalRel.prototype.toString=function(){return"[object SVGPathSegLinetoVerticalRel]"},window.SVGPathSegLinetoVerticalRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._y},window.SVGPathSegLinetoVerticalRel.prototype.clone=function(){return new window.SVGPathSegLinetoVerticalRel(void 0,this._y)},Object.defineProperty(window.SVGPathSegLinetoVerticalRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoCubicSmoothAbs=function(t,e,i,n,r){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS,"S",t),this._x=e,this._y=i,this._x2=n,this._y2=r},window.SVGPathSegCurvetoCubicSmoothAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoCubicSmoothAbs.prototype.toString=function(){return"[object SVGPathSegCurvetoCubicSmoothAbs]"},window.SVGPathSegCurvetoCubicSmoothAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y},window.SVGPathSegCurvetoCubicSmoothAbs.prototype.clone=function(){return new window.SVGPathSegCurvetoCubicSmoothAbs(void 0,this._x,this._y,this._x2,this._y2)},Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype,"x2",{get:function(){return this._x2},set:function(t){this._x2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype,"y2",{get:function(){return this._y2},set:function(t){this._y2=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoCubicSmoothRel=function(t,e,i,n,r){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL,"s",t),this._x=e,this._y=i,this._x2=n,this._y2=r},window.SVGPathSegCurvetoCubicSmoothRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoCubicSmoothRel.prototype.toString=function(){return"[object SVGPathSegCurvetoCubicSmoothRel]"},window.SVGPathSegCurvetoCubicSmoothRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y},window.SVGPathSegCurvetoCubicSmoothRel.prototype.clone=function(){return new window.SVGPathSegCurvetoCubicSmoothRel(void 0,this._x,this._y,this._x2,this._y2)},Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype,"x2",{get:function(){return this._x2},set:function(t){this._x2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype,"y2",{get:function(){return this._y2},set:function(t){this._y2=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoQuadraticSmoothAbs=function(t,e,i){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS,"T",t),this._x=e,this._y=i},window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype.toString=function(){return"[object SVGPathSegCurvetoQuadraticSmoothAbs]"},window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype.clone=function(){return new window.SVGPathSegCurvetoQuadraticSmoothAbs(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoQuadraticSmoothRel=function(t,e,i){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL,"t",t),this._x=e,this._y=i},window.SVGPathSegCurvetoQuadraticSmoothRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoQuadraticSmoothRel.prototype.toString=function(){return"[object SVGPathSegCurvetoQuadraticSmoothRel]"},window.SVGPathSegCurvetoQuadraticSmoothRel.prototype._asPathString=function(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y},window.SVGPathSegCurvetoQuadraticSmoothRel.prototype.clone=function(){return new window.SVGPathSegCurvetoQuadraticSmoothRel(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathElement.prototype.createSVGPathSegClosePath=function(){return new window.SVGPathSegClosePath(void 0)},window.SVGPathElement.prototype.createSVGPathSegMovetoAbs=function(t,e){return new window.SVGPathSegMovetoAbs(void 0,t,e)},window.SVGPathElement.prototype.createSVGPathSegMovetoRel=function(t,e){return new window.SVGPathSegMovetoRel(void 0,t,e)},window.SVGPathElement.prototype.createSVGPathSegLinetoAbs=function(t,e){return new window.SVGPathSegLinetoAbs(void 0,t,e)},window.SVGPathElement.prototype.createSVGPathSegLinetoRel=function(t,e){return new window.SVGPathSegLinetoRel(void 0,t,e)},window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs=function(t,e,i,n,r,o){return new window.SVGPathSegCurvetoCubicAbs(void 0,t,e,i,n,r,o)},window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel=function(t,e,i,n,r,o){return new window.SVGPathSegCurvetoCubicRel(void 0,t,e,i,n,r,o)},window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs=function(t,e,i,n){return new window.SVGPathSegCurvetoQuadraticAbs(void 0,t,e,i,n)},window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel=function(t,e,i,n){return new window.SVGPathSegCurvetoQuadraticRel(void 0,t,e,i,n)},window.SVGPathElement.prototype.createSVGPathSegArcAbs=function(t,e,i,n,r,o,s){return new window.SVGPathSegArcAbs(void 0,t,e,i,n,r,o,s)},window.SVGPathElement.prototype.createSVGPathSegArcRel=function(t,e,i,n,r,o,s){return new window.SVGPathSegArcRel(void 0,t,e,i,n,r,o,s)},window.SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs=function(t){return new window.SVGPathSegLinetoHorizontalAbs(void 0,t)},window.SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel=function(t){return new window.SVGPathSegLinetoHorizontalRel(void 0,t)},window.SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs=function(t){return new window.SVGPathSegLinetoVerticalAbs(void 0,t)},window.SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel=function(t){return new window.SVGPathSegLinetoVerticalRel(void 0,t)},window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs=function(t,e,i,n){return new window.SVGPathSegCurvetoCubicSmoothAbs(void 0,t,e,i,n)},window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel=function(t,e,i,n){return new window.SVGPathSegCurvetoCubicSmoothRel(void 0,t,e,i,n)},window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs=function(t,e){return new window.SVGPathSegCurvetoQuadraticSmoothAbs(void 0,t,e)},window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel=function(t,e){return new window.SVGPathSegCurvetoQuadraticSmoothRel(void 0,t,e)},"getPathSegAtLength"in window.SVGPathElement.prototype||(window.SVGPathElement.prototype.getPathSegAtLength=function(t){if(void 0===t||!isFinite(t))throw"Invalid arguments.";var e=document.createElementNS("http://www.w3.org/2000/svg","path"),i=(e.setAttribute("d",this.getAttribute("d")),e.pathSegList.numberOfItems-1);if(i<=0)return 0;for(;e.pathSegList.removeItem(i),!(t>e.getTotalLength())&&0<--i;);return i})),"undefined"==typeof window||"SVGPathSegList"in window&&"appendItem"in window.SVGPathSegList.prototype||(window.SVGPathSegList=function(t){this._pathElement=t,this._list=this._parsePath(this._pathElement.getAttribute("d")),this._mutationObserverConfig={attributes:!0,attributeFilter:["d"]},this._pathElementMutationObserver=new MutationObserver(this._updateListFromPathMutations.bind(this)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)},window.SVGPathSegList.prototype.classname="SVGPathSegList",Object.defineProperty(window.SVGPathSegList.prototype,"numberOfItems",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),Object.defineProperty(window.SVGPathSegList.prototype,"length",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"pathSegList",{get:function(){return this._pathSegList||(this._pathSegList=new window.SVGPathSegList(this)),this._pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"normalizedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"animatedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"animatedNormalizedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),window.SVGPathSegList.prototype._checkPathSynchronizedToList=function(){this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords())},window.SVGPathSegList.prototype._updateListFromPathMutations=function(t){var e;this._pathElement&&(e=!1,t.forEach(function(t){"d"==t.attributeName&&(e=!0)}),e&&(this._list=this._parsePath(this._pathElement.getAttribute("d"))))},window.SVGPathSegList.prototype._writeListToPath=function(){this._pathElementMutationObserver.disconnect(),this._pathElement.setAttribute("d",window.SVGPathSegList._pathSegArrayAsString(this._list)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)},window.SVGPathSegList.prototype.segmentChanged=function(t){this._writeListToPath()},window.SVGPathSegList.prototype.clear=function(){this._checkPathSynchronizedToList(),this._list.forEach(function(t){t._owningPathSegList=null}),this._list=[],this._writeListToPath()},window.SVGPathSegList.prototype.initialize=function(t){return this._checkPathSynchronizedToList(),this._list=[t],(t._owningPathSegList=this)._writeListToPath(),t},window.SVGPathSegList.prototype._checkValidIndex=function(t){if(isNaN(t)||t<0||t>=this.numberOfItems)throw"INDEX_SIZE_ERR"},window.SVGPathSegList.prototype.getItem=function(t){return this._checkPathSynchronizedToList(),this._checkValidIndex(t),this._list[t]},window.SVGPathSegList.prototype.insertItemBefore=function(t,e){return this._checkPathSynchronizedToList(),e>this.numberOfItems&&(e=this.numberOfItems),t._owningPathSegList&&(t=t.clone()),this._list.splice(e,0,t),(t._owningPathSegList=this)._writeListToPath(),t},window.SVGPathSegList.prototype.replaceItem=function(t,e){return this._checkPathSynchronizedToList(),t._owningPathSegList&&(t=t.clone()),this._checkValidIndex(e),((this._list[e]=t)._owningPathSegList=this)._writeListToPath(),t},window.SVGPathSegList.prototype.removeItem=function(t){this._checkPathSynchronizedToList(),this._checkValidIndex(t);var e=this._list[t];return this._list.splice(t,1),this._writeListToPath(),e},window.SVGPathSegList.prototype.appendItem=function(t){return this._checkPathSynchronizedToList(),t._owningPathSegList&&(t=t.clone()),this._list.push(t),(t._owningPathSegList=this)._writeListToPath(),t},window.SVGPathSegList._pathSegArrayAsString=function(t){var e="",i=!0;return t.forEach(function(t){i?(i=!1,e+=t._asPathString()):e+=" "+t._asPathString()}),e},window.SVGPathSegList.prototype._parsePath=function(t){if(!t||0==t.length)return[];function e(){this.pathSegList=[]}function i(t){this._string=t,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=window.SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()}var n=this,r=(e.prototype.appendSegment=function(t){this.pathSegList.push(t)},i.prototype._isCurrentSpace=function(){var t=this._string[this._currentIndex];return t<=" "&&(" "==t||"\n"==t||"\t"==t||"\r"==t||"\f"==t)},i.prototype._skipOptionalSpaces=function(){for(;this._currentIndex<this._endIndex&&this._isCurrentSpace();)this._currentIndex++;return this._currentIndex<this._endIndex},i.prototype._skipOptionalSpacesOrDelimiter=function(){return!(this._currentIndex<this._endIndex&&!this._isCurrentSpace()&&","!=this._string.charAt(this._currentIndex))&&(this._skipOptionalSpaces()&&this._currentIndex<this._endIndex&&","==this._string.charAt(this._currentIndex)&&(this._currentIndex++,this._skipOptionalSpaces()),this._currentIndex<this._endIndex)},i.prototype.hasMoreData=function(){return this._currentIndex<this._endIndex},i.prototype.peekSegmentType=function(){var t=this._string[this._currentIndex];return this._pathSegTypeFromChar(t)},i.prototype._pathSegTypeFromChar=function(t){switch(t){case"Z":case"z":return window.SVGPathSeg.PATHSEG_CLOSEPATH;case"M":return window.SVGPathSeg.PATHSEG_MOVETO_ABS;case"m":return window.SVGPathSeg.PATHSEG_MOVETO_REL;case"L":return window.SVGPathSeg.PATHSEG_LINETO_ABS;case"l":return window.SVGPathSeg.PATHSEG_LINETO_REL;case"C":return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS;case"c":return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL;case"Q":return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS;case"q":return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL;case"A":return window.SVGPathSeg.PATHSEG_ARC_ABS;case"a":return window.SVGPathSeg.PATHSEG_ARC_REL;case"H":return window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS;case"h":return window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL;case"V":return window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS;case"v":return window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL;case"S":return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;case"s":return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;case"T":return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;case"t":return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;default:return window.SVGPathSeg.PATHSEG_UNKNOWN}},i.prototype._nextCommandHelper=function(t,e){return("+"==t||"-"==t||"."==t||"0"<=t&&t<="9")&&e!=window.SVGPathSeg.PATHSEG_CLOSEPATH?e==window.SVGPathSeg.PATHSEG_MOVETO_ABS?window.SVGPathSeg.PATHSEG_LINETO_ABS:e==window.SVGPathSeg.PATHSEG_MOVETO_REL?window.SVGPathSeg.PATHSEG_LINETO_REL:e:window.SVGPathSeg.PATHSEG_UNKNOWN},i.prototype.initialCommandIsMoveTo=function(){if(!this.hasMoreData())return!0;var t=this.peekSegmentType();return t==window.SVGPathSeg.PATHSEG_MOVETO_ABS||t==window.SVGPathSeg.PATHSEG_MOVETO_REL},i.prototype._parseNumber=function(){var t=0,e=0,i=1,n=0,r=1,o=1,s=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex<this._endIndex&&"+"==this._string.charAt(this._currentIndex)?this._currentIndex++:this._currentIndex<this._endIndex&&"-"==this._string.charAt(this._currentIndex)&&(this._currentIndex++,r=-1),!(this._currentIndex==this._endIndex||(this._string.charAt(this._currentIndex)<"0"||"9"<this._string.charAt(this._currentIndex))&&"."!=this._string.charAt(this._currentIndex))){for(var a=this._currentIndex;this._currentIndex<this._endIndex&&"0"<=this._string.charAt(this._currentIndex)&&this._string.charAt(this._currentIndex)<="9";)this._currentIndex++;if(this._currentIndex!=a)for(var l=this._currentIndex-1,h=1;a<=l;)e+=h*(this._string.charAt(l--)-"0"),h*=10;if(this._currentIndex<this._endIndex&&"."==this._string.charAt(this._currentIndex)){if(this._currentIndex++,this._currentIndex>=this._endIndex||this._string.charAt(this._currentIndex)<"0"||"9"<this._string.charAt(this._currentIndex))return;for(;this._currentIndex<this._endIndex&&"0"<=this._string.charAt(this._currentIndex)&&this._string.charAt(this._currentIndex)<="9";)i*=10,n+=(this._string.charAt(this._currentIndex)-"0")/i,this._currentIndex+=1}if(this._currentIndex!=s&&this._currentIndex+1<this._endIndex&&("e"==this._string.charAt(this._currentIndex)||"E"==this._string.charAt(this._currentIndex))&&"x"!=this._string.charAt(this._currentIndex+1)&&"m"!=this._string.charAt(this._currentIndex+1)){if(this._currentIndex++,"+"==this._string.charAt(this._currentIndex)?this._currentIndex++:"-"==this._string.charAt(this._currentIndex)&&(this._currentIndex++,o=-1),this._currentIndex>=this._endIndex||this._string.charAt(this._currentIndex)<"0"||"9"<this._string.charAt(this._currentIndex))return;for(;this._currentIndex<this._endIndex&&"0"<=this._string.charAt(this._currentIndex)&&this._string.charAt(this._currentIndex)<="9";)t=(t*=10)+(this._string.charAt(this._currentIndex)-"0"),this._currentIndex++}var c=e+n;if(c*=r,t&&(c*=Math.pow(10,o*t)),s!=this._currentIndex)return this._skipOptionalSpacesOrDelimiter(),c}},i.prototype._parseArcFlag=function(){if(!(this._currentIndex>=this._endIndex)){var t=!1,e=this._string.charAt(this._currentIndex++);if("0"==e)t=!1;else{if("1"!=e)return;t=!0}return this._skipOptionalSpacesOrDelimiter(),t}},i.prototype.parseSegment=function(){var t,e=this._string[this._currentIndex],i=this._pathSegTypeFromChar(e);if(i==window.SVGPathSeg.PATHSEG_UNKNOWN){if(this._previousCommand==window.SVGPathSeg.PATHSEG_UNKNOWN)return null;if((i=this._nextCommandHelper(e,this._previousCommand))==window.SVGPathSeg.PATHSEG_UNKNOWN)return null}else this._currentIndex++;switch(this._previousCommand=i){case window.SVGPathSeg.PATHSEG_MOVETO_REL:return new window.SVGPathSegMovetoRel(n,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_MOVETO_ABS:return new window.SVGPathSegMovetoAbs(n,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_REL:return new window.SVGPathSegLinetoRel(n,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_ABS:return new window.SVGPathSegLinetoAbs(n,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:return new window.SVGPathSegLinetoHorizontalRel(n,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:return new window.SVGPathSegLinetoHorizontalAbs(n,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:return new window.SVGPathSegLinetoVerticalRel(n,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:return new window.SVGPathSegLinetoVerticalAbs(n,this._parseNumber());case window.SVGPathSeg.PATHSEG_CLOSEPATH:return this._skipOptionalSpaces(),new window.SVGPathSegClosePath(n);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:return t={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoCubicRel(n,t.x,t.y,t.x1,t.y1,t.x2,t.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:return t={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoCubicAbs(n,t.x,t.y,t.x1,t.y1,t.x2,t.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:return t={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoCubicSmoothRel(n,t.x,t.y,t.x2,t.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:return t={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoCubicSmoothAbs(n,t.x,t.y,t.x2,t.y2);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:return t={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoQuadraticRel(n,t.x,t.y,t.x1,t.y1);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:return t={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoQuadraticAbs(n,t.x,t.y,t.x1,t.y1);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:return new window.SVGPathSegCurvetoQuadraticSmoothRel(n,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:return new window.SVGPathSegCurvetoQuadraticSmoothAbs(n,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_ARC_REL:return t={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegArcRel(n,t.x,t.y,t.x1,t.y1,t.arcAngle,t.arcLarge,t.arcSweep);case window.SVGPathSeg.PATHSEG_ARC_ABS:return t={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegArcAbs(n,t.x,t.y,t.x1,t.y1,t.arcAngle,t.arcLarge,t.arcSweep);default:throw"Unknown path seg type."}},new e),o=new i(t);if(!o.initialCommandIsMoveTo())return[];for(;o.hasMoreData();){var s=o.parseSegment();if(!s)return[];r.appendSegment(s)}return r.pathSegList});var U=Math.round,H=Math.floor,X=Math.PI,J={linear:function(t,e,i){var n=t[1]-t[0],r=e[1]-e[0];return(i-t[0])/n*r+e[0]||0}},Q=function(t){return t%360+(t<0?360:0)},K=function(t,e){return(t=(e=e||!1)?t:t%360)*X/180},q=Math.cos,it=Math.sin,nt=Math.atan2,s={Point:1,Line:2,Ellipse:3,Rect:4,Polyline:5,Polygon:6,Curve:7,Path:8},rt=Math.abs,ot=Math.cos,st=Math.sin,at=Math.sqrt,lt=Math.min,ht=Math.max,ct=Math.atan2,ut=Math.round,dt=Math.pow,gt=Math.PI,z=function(t,e){if(!(this instanceof z))return new z(t,e);var i;"string"==typeof t?(i=t.split(-1===t.indexOf("@")?" ":"@"),t=parseFloat(i[0]),e=parseFloat(i[1])):Object(t)===t&&(e=t.y,t=t.x),this.x=void 0===t?0:t,this.y=void 0===e?0:e},A=(z.fromPolar=function(t,e,i){i=new z(i);var n=rt(t*ot(e)),t=rt(t*st(e)),e=Q(V(e));return e<90?t=-t:e<180?(n=-n,t=-t):e<270&&(n=-n),new z(i.x+n,i.y+t)},z.random=function(t,e,i,n){return new z(D(t,e),D(i,n))},z.prototype={type:s.Point,chooseClosest:function(t){var e=t.length;if(1===e)return new z(t[0]);for(var i=null,n=1/0,r=0;r<e;r++){var o=new z(t[r]),s=this.squaredDistance(o);s<n&&(i=o,n=s)}return i},adhereToRect:function(t){return t.containsPoint(this)||(this.x=lt(ht(this.x,t.x),t.x+t.width),this.y=lt(ht(this.y,t.y),t.y+t.height)),this},angleBetween:function(t,e){e=this.equals(t)||this.equals(e)?NaN:this.theta(e)-this.theta(t);return e<0&&(e+=360),e},bearing:function(t){return Y(this,t)},changeInAngle:function(t,e,i){return this.clone().offset(-t,-e).theta(i)-this.theta(i)},clone:function(){return new z(this)},cross:function(t,e){return t&&e?(e.x-this.x)*(t.y-this.y)-(e.y-this.y)*(t.x-this.x):NaN},difference:function(t,e){return Object(t)===t&&(e=t.y,t=t.x),new z(this.x-(t||0),this.y-(e||0))},distance:function(t){return F(this,t)},dot:function(t){return t?this.x*t.x+this.y*t.y:NaN},equals:function(t){return!!t&&this.x===t.x&&this.y===t.y},lerp:function(t,e){var i=this.x,n=this.y;return new z((1-e)*i+e*t.x,(1-e)*n+e*t.y)},magnitude:function(){return at(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(t){return rt(t.x-this.x)+rt(t.y-this.y)},move:function(t,e){t=K(new z(t).theta(this));return this.offset(ot(t)*e,-st(t)*e)},normalize:function(t){t=(t||1)/this.magnitude();return this.scale(t,t)},offset:function(t,e){return Object(t)===t&&(e=t.y,t=t.x),this.x+=t||0,this.y+=e||0,this},reflection:function(t){return new z(t).move(this,this.distance(t))},rotate:function(t,e){if(0===e)return this;t=t||new z(0,0),e=K(Q(-e));var i=ot(e),e=st(e),n=i*(this.x-t.x)-e*(this.y-t.y)+t.x,e=e*(this.x-t.x)+i*(this.y-t.y)+t.y;return this.x=n,this.y=e,this},round:function(t){var e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=dt(10,t)}return this.x=ut(this.x*e)/e,this.y=ut(this.y*e)/e,this},scale:function(t,e,i){return i=i&&new z(i)||new z(0,0),this.x=i.x+t*(this.x-i.x),this.y=i.y+e*(this.y-i.y),this},snapToGrid:function(t,e){return this.x=E(this.x,t),this.y=E(this.y,e||t),this},squaredDistance:function(t){return W(this,t)},theta:function(t){var e=-((t=new z(t)).y-this.y),t=t.x-this.x,e=ct(e,t);return 180*(e=e<0?2*gt+e:e)/gt},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(t){t=t&&new z(t)||new z(0,0);var e=this.x,i=this.y;return this.x=at((e-t.x)*(e-t.x)+(i-t.y)*(i-t.y)),this.y=K(t.theta(new z(e,i))),this},toString:function(){return this.x+"@"+this.y},serialize:function(){return this.x+","+this.y},update:function(t,e){return Object(t)===t&&(e=t.y,t=t.x),this.x=t||0,this.y=e||0,this},vectorAngle:function(t){return new z(0,0).angleBetween(this,t)}},z.prototype.translate=z.prototype.offset,z),pt=Math.max,ft=Math.min,C=function(t,e){return this instanceof C?t instanceof C?new C(t.start,t.end):(this.start=new z(t),void(this.end=new z(e))):new C(t,e)},mt=(C.prototype={type:s.Line,angle:function(){var t=new z(this.start.x+1,this.start.y);return this.start.angleBetween(this.end,t)},bbox:function(){var t=ft(this.start.x,this.end.x),e=ft(this.start.y,this.end.y),i=pt(this.start.x,this.end.x),n=pt(this.start.y,this.end.y);return new tt(t,e,i-t,n-e)},bearing:function(){return Y(this.start,this.end)},clone:function(){return new C(this.start,this.end)},closestPoint:function(t){return this.pointAt(this.closestPointNormalizedLength(t))},closestPointLength:function(t){return this.closestPointNormalizedLength(t)*this.length()},closestPointNormalizedLength:function(t){t=this.vector().dot(new C(this.start,t).vector()),t=ft(1,pt(0,t/this.squaredLength()));return t!=t?0:t},closestPointTangent:function(t){return this.tangentAt(this.closestPointNormalizedLength(t))},containsPoint:function(t){var e=this.start,i=this.end;if(0!==e.cross(t,i))return!1;var n=this.length();return!(new C(e,t).length()>n)&&!(new C(t,i).length()>n)},divideAt:function(t){t=this.pointAt(t);return[new C(this.start,t),new C(t,this.end)]},divideAtLength:function(t){t=this.pointAtLength(t);return[new C(this.start,t),new C(t,this.end)]},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.end.x===t.end.x&&this.end.y===t.end.y},intersect:function(t,e){return t&&t.intersectionWithLine?(e=t.intersectionWithLine(this,e))&&t instanceof C?e[0]:e:null},intersectionWithLine:function(t){var e=new z(this.end.x-this.start.x,this.end.y-this.start.y),i=new z(t.end.x-t.start.x,t.end.y-t.start.y),n=e.x*i.y-e.y*i.x,t=new z(t.start.x-this.start.x,t.start.y-this.start.y),i=t.x*i.y-t.y*i.x,t=t.x*e.y-t.y*e.x;if(0==n||i*n<0||t*n<0)return null;if(0<n){if(n<i||n<t)return null}else if(i<n||t<n)return null;return[new z(this.start.x+i*e.x/n,this.start.y+i*e.y/n)]},isDifferentiable:function(){return!this.start.equals(this.end)},length:function(){return F(this.start,this.end)},midpoint:function(){return new z((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)},parallel:function(t){var e=this.clone();if(!this.isDifferentiable())return e;var i=e.start,n=e.end,r=i.clone().rotate(n,270),o=n.clone().rotate(i,90);return i.move(o,t),n.move(r,t),e},pointAt:function(t){var e=this.start,i=this.end;return t<=0?e.clone():1<=t?i.clone():e.lerp(i,t)},pointAtLength:function(t){var e=this.start,i=this.end,n=!0,r=(t<0&&(n=!1,t=-t),this.length());return r<=t?(n?i:e).clone():this.pointAt((n?t:r-t)/r)},pointOffset:function(t){t=new z(t);var e=this.start,i=this.end;return((i.x-e.x)*(t.y-e.y)-(i.y-e.y)*(t.x-e.x))/this.length()},rotate:function(t,e){return this.start.rotate(t,e),this.end.rotate(t,e),this},round:function(t){return this.start.round(t),this.end.round(t),this},scale:function(t,e,i){return this.start.scale(t,e,i),this.end.scale(t,e,i),this},setLength:function(t){var e=this.length();if(!e)return this;t/=e;return this.scale(t,t,this.start)},squaredLength:function(){return W(this.start,this.end)},tangentAt:function(t){if(!this.isDifferentiable())return null;var e=this.start,i=this.end,t=this.pointAt(t),i=new C(e,i);return i.translate(t.x-e.x,t.y-e.y),i},tangentAtLength:function(t){if(!this.isDifferentiable())return null;var e=this.start,i=this.end,t=this.pointAtLength(t),i=new C(e,i);return i.translate(t.x-e.x,t.y-e.y),i},toString:function(){return this.start.toString()+" "+this.end.toString()},serialize:function(){return this.start.serialize()+" "+this.end.serialize()},translate:function(t,e){return this.start.translate(t,e),this.end.translate(t,e),this},vector:function(){return new z(this.end.x-this.start.x,this.end.y-this.start.y)}},C.prototype.intersection=C.prototype.intersect,C),vt=Math.sqrt,yt=Math.round,bt=Math.pow,wt=function(t,e,i){return this instanceof wt?t instanceof wt?new wt(new z(t.x,t.y),t.a,t.b):(t=new z(t),this.x=t.x,this.y=t.y,this.a=e,void(this.b=i)):new wt(t,e,i)},At=(wt.fromRect=function(t){return t=new tt(t),new wt(t.center(),t.width/2,t.height/2)},wt.prototype={type:s.Ellipse,bbox:function(){return new tt(this.x-this.a,this.y-this.b,2*this.a,2*this.b)},center:function(){return new z(this.x,this.y)},clone:function(){return new wt(this)},containsPoint:function(t){return this.normalizedDistance(t)<=1},equals:function(t){return!!t&&t.x===this.x&&t.y===this.y&&t.a===this.a&&t.b===this.b},inflate:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.a+=2*t,this.b+=2*e,this},intersectionWithLine:function(t){var e=[],i=t.start,n=t.end,r=this.a,o=this.b,t=t.vector(),s=i.difference(new z(this)),a=new z(t.x/(r*r),t.y/(o*o)),r=new z(s.x/(r*r),s.y/(o*o)),o=t.dot(a),a=t.dot(r),t=a*a-o*(s.dot(r)-1);if(t<0)return null;if(0<t){s=vt(t),r=(-a-s)/o,t=(-a+s)/o;if((r<0||1<r)&&(t<0||1<t))return null;0<=r&&r<=1&&e.push(i.lerp(n,r)),0<=t&&t<=1&&e.push(i.lerp(n,t))}else{s=-a/o;if(!(0<=s&&s<=1))return null;e.push(i.lerp(n,s))}return e},intersectionWithLineFromCenterToPoint:function(t,e){t=new z(t),e&&t.rotate(new z(this.x,this.y),e);var i=t.x-this.x,n=t.y-this.y;if(0==i)return o=this.bbox().pointNearestToPoint(t),e?o.rotate(new z(this.x,this.y),-e):o;var t=n/i,n=this.a*this.a,r=this.b*this.b,n=vt(1/(1/n+t*t/r)),n=i<0?-n:n,o=new z(this.x+n,this.y+t*n);return e?o.rotate(new z(this.x,this.y),-e):o},normalizedDistance:function(t){var e=t.x,t=t.y,i=this.a,n=this.b,r=this.x,o=this.y;return(e-r)*(e-r)/(i*i)+(t-o)*(t-o)/(n*n)},round:function(t){var e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=bt(10,t)}return this.x=yt(this.x*e)/e,this.y=yt(this.y*e)/e,this.a=yt(this.a*e)/e,this.b=yt(this.b*e)/e,this},tangentTheta:function(t){var e,i,n=t.x,r=t.y,o=this.a,s=this.b,a=this.bbox().center(),l=a.x,h=a.y,c=n>a.x+o/2,u=n<a.x-o/2;return c||u?i=o*o/(n-l)-o*o*(r-h)*((e=n>a.x?r-30:r+30)-h)/(s*s*(n-l))+l:e=s*s/(r-h)-s*s*(n-l)*((i=r>a.y?n+30:n-30)-l)/(o*o*(r-h))+h,new z(i,e).theta(t)},toString:function(){return new z(this.x,this.y).toString()+" "+this.a+" "+this.b}},wt),Ct=Math.abs,It=Math.cos,xt=Math.sin,St=Math.min,Pt=Math.max,Mt=Math.round,kt=Math.pow,tt=function(t,e,i,n){if(!(this instanceof tt))return new tt(t,e,i,n);Object(t)===t&&(e=t.y,i=t.width,n=t.height,t=t.x),this.x=void 0===t?0:t,this.y=void 0===e?0:e,this.width=void 0===i?0:i,this.height=void 0===n?0:n},Nt=(tt.fromEllipse=function(t){return t=new wt(t),new tt(t.x-t.a,t.y-t.b,2*t.a,2*t.b)},tt.fromPointUnion=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(0===t.length)return null;for(var i,n,r=new z,o=i=1/0,s=n=-1/0,a=0;a<t.length;a++){r.update(t[a]);var l=r.x,h=r.y;l<o&&(o=l),s<l&&(s=l),h<i&&(i=h),n<h&&(n=h)}return new tt(o,i,s-o,n-i)},tt.fromRectUnion=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(0===t.length)return null;for(var i,n,r=new tt,o=i=1/0,s=n=-1/0,a=0;a<t.length;a++){r.update(t[a]);var l=r.x,h=r.y,c=l+r.width,u=h+r.height;l<o&&(o=l),s<c&&(s=c),h<i&&(i=h),n<u&&(n=u)}return new tt(o,i,s-o,n-i)},tt.prototype={type:s.Rect,bbox:function(t){return this.clone().rotateAroundCenter(t)},rotateAroundCenter:function(t){if(!t)return this;var e=this.width,i=this.height,t=K(t),n=Ct(xt(t)),t=Ct(It(t)),r=e*t+i*n,n=e*n+i*t;return this.x+=(e-r)/2,this.y+=(i-n)/2,this.width=r,this.height=n,this},bottomLeft:function(){return new z(this.x,this.y+this.height)},bottomLine:function(){return new C(this.bottomLeft(),this.bottomRight())},bottomMiddle:function(){return new z(this.x+this.width/2,this.y+this.height)},center:function(){return new z(this.x+this.width/2,this.y+this.height/2)},clone:function(){return new tt(this)},containsPoint:function(t){return(t=new z(t)).x>=this.x&&t.x<=this.x+this.width&&t.y>=this.y&&t.y<=this.y+this.height},containsRect:function(t){var e=new tt(this).normalize(),t=new tt(t).normalize(),i=e.width,n=e.height,r=t.width,o=t.height;if(!(i&&n&&r&&o))return!1;var s=e.x,e=e.y,a=t.x,t=t.y;return r+=a,i+=s,o+=t,n+=e,s<=a&&r<=i&&e<=t&&o<=n},corner:function(){return new z(this.x+this.width,this.y+this.height)},equals:function(t){var e=new tt(this).normalize(),t=new tt(t).normalize();return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height},inflate:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e,this},intersect:function(t){var e=this.origin(),i=this.corner(),n=t.origin(),t=t.corner();if(t.x<=e.x||t.y<=e.y||n.x>=i.x||n.y>=i.y)return null;var r=Pt(e.x,n.x),e=Pt(e.y,n.y);return new tt(r,e,St(i.x,t.x)-r,St(i.y,t.y)-e)},intersectionWithLine:function(t){for(var e,i=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],n=[],r=[],o=i.length,s=0;s<o;s++)null!==(e=t.intersect(i[s]))&&r.indexOf(e.toString())<0&&(n.push(e),r.push(e.toString()));return 0<n.length?n:null},intersectionWithLineFromCenterToPoint:function(t,e){t=new z(t);for(var i,n=new z(this.x+this.width/2,this.y+this.height/2),r=(e&&t.rotate(n,e),[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()]),o=new C(n,t),s=r.length-1;0<=s;--s){var a=r[s].intersection(o);if(null!==a){i=a;break}}return i&&e&&i.rotate(n,-e),i},leftLine:function(){return new C(this.topLeft(),this.bottomLeft())},leftMiddle:function(){return new z(this.x,this.y+this.height/2)},maxRectScaleToFit:function(t,e){t=new tt(t);var i,n,r,o,s,a,l,h=(e=e||t.center()).x,e=e.y,c=i=n=r=o=s=a=l=1/0,u=t.topLeft(),u=(u.x<h&&(c=(this.x-h)/(u.x-h)),u.y<e&&(o=(this.y-e)/(u.y-e)),t.bottomRight()),u=(u.x>h&&(i=(this.x+this.width-h)/(u.x-h)),u.y>e&&(s=(this.y+this.height-e)/(u.y-e)),t.topRight()),u=(u.x>h&&(n=(this.x+this.width-h)/(u.x-h)),u.y<e&&(a=(this.y-e)/(u.y-e)),t.bottomLeft());return u.x<h&&(r=(this.x-h)/(u.x-h)),u.y>e&&(l=(this.y+this.height-e)/(u.y-e)),{sx:St(c,i,n,r),sy:St(o,s,a,l)}},maxRectUniformScaleToFit:function(t,e){t=this.maxRectScaleToFit(t,e);return St(t.sx,t.sy)},moveAndExpand:function(t){return this.x+=t.x||0,this.y+=t.y||0,this.width+=t.width||0,this.height+=t.height||0,this},normalize:function(){var t=this.x,e=this.y,i=this.width,n=this.height;return this.width<0&&(t=this.x+this.width,i=-this.width),this.height<0&&(e=this.y+this.height,n=-this.height),this.x=t,this.y=e,this.width=i,this.height=n,this},offset:function(t,e){return z.prototype.offset.call(this,t,e)},origin:function(){return new z(this.x,this.y)},pointNearestToPoint:function(t){if(t=new z(t),this.containsPoint(t))switch(this.sideNearestToPoint(t)){case"right":return new z(this.x+this.width,t.y);case"left":return new z(this.x,t.y);case"bottom":return new z(t.x,this.y+this.height);case"top":return new z(t.x,this.y)}return t.adhereToRect(this)},rightLine:function(){return new C(this.topRight(),this.bottomRight())},rightMiddle:function(){return new z(this.x+this.width,this.y+this.height/2)},round:function(t){var e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=kt(10,t)}return this.x=Mt(this.x*e)/e,this.y=Mt(this.y*e)/e,this.width=Mt(this.width*e)/e,this.height=Mt(this.height*e)/e,this},scale:function(t,e,i){return i=this.origin().scale(t,e,i),this.x=i.x,this.y=i.y,this.width*=t,this.height*=e,this},sideNearestToPoint:function(t){var e=(t=new z(t)).x-this.x,i=this.x+this.width-t.x,n=t.y-this.y,r="left";return i<e&&(e=i,r="right"),n<e&&(e=n,r="top"),r=this.y+this.height-t.y<e?"bottom":r},snapToGrid:function(t,e){var i=this.origin().snapToGrid(t,e),t=this.corner().snapToGrid(t,e);return this.x=i.x,this.y=i.y,this.width=t.x-i.x,this.height=t.y-i.y,this},toJSON:function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},topLine:function(){return new C(this.topLeft(),this.topRight())},topMiddle:function(){return new z(this.x+this.width/2,this.y)},topRight:function(){return new z(this.x+this.width,this.y)},toString:function(){return this.origin().toString()+" "+this.corner().toString()},union:function(t){return tt.fromRectUnion(this,t)},update:function(t,e,i,n){return Object(t)===t&&(e=t.y,i=t.width,n=t.height,t=t.x),this.x=t||0,this.y=e||0,this.width=i||0,this.height=n||0,this}},tt.prototype.bottomRight=tt.prototype.corner,tt.prototype.topLeft=tt.prototype.origin,tt.prototype.translate=tt.prototype.offset,tt);function Tt(t){if(""===(t=t.trim()))return[];for(var e=[],i=t.split(/\s*,\s*|\s+/),n=i.length,r=0;r<n;r+=2)e.push({x:+i[r],y:+i[r+1]});return e}function Lt(t){var e=t.length;if(0===e)return[];for(var i=[],n=0;n<e;n++){var r=t[n].clone();i.push(r)}return i}function Et(t){var e,i=Math.abs,n=t.length;if(0===n)return[];for(o=0;o<n;o++)(void 0===e||t[o].y<e.y||t[o].y===e.y&&t[o].x>e.x)&&(e=t[o]);for(var r=[],o=0;o<n;o++){var s=e.theta(t[o]),s=(0===s&&(s=360),[t[o],o,s]);r.push(s)}r.sort(function(t,e){var i=t[2]-e[2];return i=0===i?e[1]-t[1]:i}),2<r.length&&(A=r[r.length-1],r.unshift(A));for(var a,l,h,c={},u=[];0!==r.length;)if(l=(a=r.pop())[0],!c.hasOwnProperty(a[0]+"@@"+a[1]))for(var d,g,p,f,m,v=!1;!v;)u.length<2?(u.push(a),v=!0):(g=(d=u.pop())[0],(m=(f=(p=u.pop())[0]).cross(g,l))<0?(u.push(p),u.push(d),u.push(a),v=!0):0===m?i((m=g.angleBetween(f,l))-180)<1e-10||g.equals(l)||f.equals(g)?(c[d[0]+"@@"+d[1]]=g,u.push(p)):i((m+1)%360-1)<1e-10&&(u.push(p),r.push(d)):(c[d[0]+"@@"+d[1]]=g,u.push(p)));2<u.length&&u.pop();var y=-1,b=u.length;for(o=0;o<b;o++){var w=u[o][1];(void 0===h||w<h)&&(h=w,y=o)}var A,C,I=[],x=[];for(b=(I=0<y?(A=u.slice(y),C=u.slice(0,y),A.concat(C)):u).length,o=0;o<b;o++)x.push(I[o][0]);return x}function v(t){return this instanceof v?"string"==typeof t?new v.parse(t):void(this.points=Array.isArray(t)?t.map(z):[]):new v(t)}v.parse=function(t){return new v(Tt(t))},v.fromRect=function(t){return new v([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft(),t.topLeft()])},v.prototype={type:s.Polyline,bbox:function(){var t=1/0,e=-1/0,i=1/0,n=-1/0,r=this.points,o=r.length;if(0===o)return null;for(var s=0;s<o;s++){var a=r[s],l=a.x,a=a.y;l<t&&(t=l),e<l&&(e=l),a<i&&(i=a),n<a&&(n=a)}return new tt(t,i,e-t,n-i)},clone:function(){return new v(Lt(this.points))},closestPoint:function(t){t=this.closestPointLength(t);return this.pointAtLength(t)},closestPointLength:function(t){var e,i=this.lengthPoints(),n=i.length;if(0===n)return 0;if(1===n)return 0;for(var r=1/0,o=0,s=n-1,a=0;a<s;a++){var l=new C(i[a],i[a+1]),h=l.length(),c=l.closestPointNormalizedLength(t),l=l.pointAt(c).squaredDistance(t);l<r&&(r=l,e=o+c*h),o+=h}return e},closestPointNormalizedLength:function(t){t=this.closestPointLength(t);if(0===t)return 0;var e=this.length();return 0===e?0:t/e},closestPointTangent:function(t){t=this.closestPointLength(t);return this.tangentAtLength(t)},containsPoint:function(t){var e=this.points,i=e.length;if(0===i)return!1;for(var n=t.x,r=t.y,o=i-1,s=0,a=0,l=new C,h=new C,c=new z;s<i;s++){var u=e[o],d=e[s];if(t.equals(u))return!0;if(l.start=u,l.end=d,l.containsPoint(t))return!0;!(r<=u.y&&r>d.y||r>u.y&&r<=d.y)||0<=(u=u.x-n>d.x-n?u.x-n:d.x-n)&&(c.x=n+u,c.y=r,h.start=t,h.end=c,l.intersect(h)&&a++),o=s}return a%2==1},close:function(){var t=this.start,e=this.end,i=this.points;return t&&e&&!t.equals(e)&&i.push(t.clone()),this},lengthPoints:function(){return this.points},convexHull:function(){return new v(Et(this.points))},equals:function(t){if(!t)return!1;var e=this.points,i=t.points,n=e.length;if(i.length!==n)return!1;for(var r=0;r<n;r++){var o=e[r],s=t.points[r];if(!o.equals(s))return!1}return!0},intersectionWithLine:function(t){for(var e=new C(t),i=[],n=this.lengthPoints(),r=new C,o=0,s=n.length-1;o<s;o++){r.start=n[o],r.end=n[o+1];var a=e.intersectionWithLine(r);a&&i.push(a[0])}return 0<i.length?i:null},isDifferentiable:function(){var t=this.points,e=t.length;if(0===e)return!1;for(var i=new C,n=e-1,r=0;r<n;r++)if(i.start=t[r],i.end=t[r+1],i.isDifferentiable())return!0;return!1},length:function(){var t=this.lengthPoints(),e=t.length;if(0===e)return 0;for(var i=0,n=e-1,r=0;r<n;r++)i+=t[r].distance(t[r+1]);return i},pointAt:function(t){var e=this.lengthPoints(),i=e.length;if(0===i)return null;if(1===i)return e[0].clone();if(t<=0)return e[0].clone();if(1<=t)return e[i-1].clone();e=this.length();return this.pointAtLength(e*t)},pointAtLength:function(t){var e=this.lengthPoints(),i=e.length;if(0===i)return null;if(1===i)return e[0].clone();for(var n=!0,r=(t<0&&(n=!1,t=-t),0),o=i-1,s=0;s<o;s++){var a=n?s:o-1-s,l=e[a],a=e[a+1],h=new C(l,a),l=l.distance(a);if(t<=r+l)return h.pointAtLength((n?1:-1)*(t-r));r+=l}return(n?e[i-1]:e[0]).clone()},round:function(t){for(var e=this.points,i=e.length,n=0;n<i;n++)e[n].round(t);return this},scale:function(t,e,i){for(var n=this.points,r=n.length,o=0;o<r;o++)n[o].scale(t,e,i);return this},simplify:function(t){var e=this.points;if(e.length<3)return this;for(var i=(t=void 0===t?{}:t).threshold||0,n=0;e[n+2];){var r=n+1,o=e[n],s=e[r],a=e[n+2];new C(o,a).closestPoint(s).distance(s)<=i?e.splice(r,1):n+=1}return this},tangentAt:function(t){var e=this.lengthPoints().length;if(0===e)return null;if(1===e)return null;1<(t=t<0?0:t)&&(t=1);e=this.length();return this.tangentAtLength(e*t)},tangentAtLength:function(t){var e=this.lengthPoints(),i=e.length;if(0===i)return null;if(1===i)return null;for(var n,r=!0,o=(t<0&&(r=!1,t=-t),0),s=i-1,a=0;a<s;a++){var l=r?a:s-1-a,h=e[l],l=e[l+1],c=new C(h,l),h=h.distance(l);if(c.isDifferentiable()){if(t<=o+h)return c.tangentAtLength((r?1:-1)*(t-o));n=c}o+=h}return n?n.tangentAt(r?1:0):null},toString:function(){return this.points+""},translate:function(t,e){for(var i=this.points,n=i.length,r=0;r<n;r++)i[r].translate(t,e);return this},serialize:function(){var t=this.points,e=t.length;if(0===e)return"";for(var i="",n=0;n<e;n++){var r=t[n];i+=r.x+","+r.y+" "}return i.trim()}},Object.defineProperty(v.prototype,"start",{configurable:!0,enumerable:!0,get:function(){return 0===this.points.length?null:this.points[0]}}),Object.defineProperty(v.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.points.length;return 0===t?null:this.points[t-1]}});var Dt=Math.abs,Bt=Math.sqrt,Gt=Math.min,zt=Math.max,Ot=Math.pow,d=function(t,e,i,n){return this instanceof d?t instanceof d?new d(t.start,t.controlPoint1,t.controlPoint2,t.end):(this.start=new z(t),this.controlPoint1=new z(e),this.controlPoint2=new z(i),void(this.end=new z(n))):new d(t,e,i,n)};function Rt(t){var e=t.length,i=[],n=[],r=2;i[0]=t[0]/r;for(var o=1;o<e;o++)n[o]=1/r,r=(o<e-1?4:3.5)-n[o],i[o]=(t[o]-i[o-1])/r;for(o=1;o<e;o++)i[e-o-1]-=n[e-o]*i[e-o];return i}function Vt(t){for(var e=arguments,i=[],n=arguments.length,r=1;r<n;r++)i.push(e[r]);if(!t)throw new Error("Missing a parent object.");var o=Object.create(t);for(n=i.length,r=0;r<n;r++){var s,a,l=i[r];for(a in l)l.hasOwnProperty(a)&&(delete o[a],s=Object.getOwnPropertyDescriptor(l,a),Object.defineProperty(o,a,s))}return o}d.throughPoints=function(t){if(!t||Array.isArray(t)&&t.length<2)throw new Error("At least 2 points are required");for(var e=function(t){var e=[],i=[],n=t.length-1;if(1==n)return e[0]=new z((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),i[0]=new z(2*e[0].x-t[0].x,2*e[0].y-t[0].y),[e,i];for(var r=[],o=1;o<n-1;o++)r[o]=4*t[o].x+2*t[o+1].x;r[0]=t[0].x+2*t[1].x,r[n-1]=(8*t[n-1].x+t[n].x)/2;var s=Rt(r);for(o=1;o<n-1;++o)r[o]=4*t[o].y+2*t[o+1].y;r[0]=t[0].y+2*t[1].y,r[n-1]=(8*t[n-1].y+t[n].y)/2;var a=Rt(r);for(o=0;o<n;o++)e.push(new z(s[o],a[o])),o<n-1?i.push(new z(2*t[o+1].x-s[o+1],2*t[o+1].y-a[o+1])):i.push(new z((t[n].x+s[n-1])/2,(t[n].y+a[n-1])/2));return[e,i]}(t),i=[],n=e[0].length,r=0;r<n;r++){var o=new z(e[0][r].x,e[0][r].y),s=new z(e[1][r].x,e[1][r].y);i.push(new d(t[r],o,s,t[r+1]))}return i},d.prototype={type:s.Curve,bbox:function(){for(var t,e,i,n,r,o=this.start,s=this.controlPoint1,a=this.controlPoint2,l=this.end,h=o.x,c=o.y,u=s.x,d=s.y,g=a.x,p=a.y,f=l.x,m=l.y,v=new Array,y=new Array,b=[new Array,new Array],w=0;w<2;++w)n=0===w?(e=6*h-12*u+6*g,t=-3*h+9*u-9*g+3*f,3*u-3*h):(e=6*c-12*d+6*p,t=-3*c+9*d-9*p+3*m,3*d-3*c),Dt(t)<1e-12?Dt(e)<1e-12||0<(i=-n/e)&&i<1&&y.push(i):(r=Bt(n=e*e-4*n*t),n<0||(0<(n=(-e+r)/(2*t))&&n<1&&y.push(n),0<(n=(-e-r)/(2*t))&&n<1&&y.push(n)));for(var A,C,I=y.length,o=I;I--;)i=y[I],b[0][I]=A=(C=1-i)*C*C*h+3*C*C*i*u+3*C*i*i*g+i*i*i*f,b[1][I]=C=C*C*C*c+3*C*C*i*d+3*C*i*i*p+i*i*i*m,v[I]={X:A,Y:C};y[o]=0,y[o+1]=1,v[o]={X:h,Y:c},v[o+1]={X:f,Y:m},b[0][o]=h,b[1][o]=c,b[0][o+1]=f,b[1][o+1]=m,y.length=o+2,b[0].length=o+2,b[1].length=o+2,v.length=o+2;s=Gt.apply(null,b[0]),a=Gt.apply(null,b[1]),l=zt.apply(null,b[0]),o=zt.apply(null,b[1]);return new tt(s,a,l-s,o-a)},clone:function(){return new d(this.start,this.controlPoint1,this.controlPoint2,this.end)},closestPoint:function(t,e){return this.pointAtT(this.closestPointT(t,e))},closestPointLength:function(t,e){var i=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:i,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:i}):e.subdivisions};return this.lengthAtT(this.closestPointT(t,i),i)},closestPointNormalizedLength:function(t,e){var i=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:i,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:i}):e.subdivisions},e=this.closestPointLength(t,i);if(!e)return 0;t=this.length(i);return 0===t?0:e/t},closestPointT:function(t,e){for(var i,n,r,o,s,a,l=void 0===(e=e||{}).precision?this.PRECISION:e.precision,h=void 0===e.subdivisions?this.getSubdivisions({precision:l}):e.subdivisions,c=h.length,u=c?1/c:0,d=0;d<c;d++){var g=h[d],p=g.start.distance(t),f=g.end.distance(t),m=p+f;(!a||m<a)&&(n=d*u,r=(d+1)*u,o=p,x=f,s=(i=g).start.distance(g.end),a=m)}for(var v=Ot(10,-l);;){var y=o?Dt(o-x)/o:0,b=x?Dt(o-x)/x:0;if(y<v||b<v||(!o||o<s*v||(!x||x<s*v)))return o<=x?n:r;var y=i.divide(.5),b=(u/=2,y[0].start.distance(t)),w=y[0].end.distance(t),A=b+w,C=y[1].start.distance(t),I=y[1].end.distance(t),x=A<=C+I?(i=y[0],r-=u,o=b,w):(i=y[1],n+=u,o=C,I)}},closestPointTangent:function(t,e){return this.tangentAtT(this.closestPointT(t,e))},containsPoint:function(t,e){return this.toPolyline(e).containsPoint(t)},divideAt:function(t,e){if(t<=0)return this.divideAtT(0);if(1<=t)return this.divideAtT(1);t=this.tAt(t,e);return this.divideAtT(t)},divideAtLength:function(t,e){t=this.tAtLength(t,e);return this.divideAtT(t)},divideAtT:function(t){var e=this.start,i=this.controlPoint1,n=this.controlPoint2,r=this.end;if(t<=0)return[new d(e,e,e,e),new d(e,i,n,r)];if(1<=t)return[new d(e,i,n,r),new d(r,r,r,r)];var i=this.getSkeletonPoints(t),n=i.startControlPoint1,t=i.startControlPoint2,o=i.divider,s=i.dividerControlPoint1,i=i.dividerControlPoint2;return[new d(e,n,t,o),new d(o,s,i,r)]},endpointDistance:function(){return this.start.distance(this.end)},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.controlPoint1.x===t.controlPoint1.x&&this.controlPoint1.y===t.controlPoint1.y&&this.controlPoint2.x===t.controlPoint2.x&&this.controlPoint2.y===t.controlPoint2.y&&this.end.x===t.end.x&&this.end.y===t.end.y},getSkeletonPoints:function(t){var e=this.start,i=this.controlPoint1,n=this.controlPoint2,r=this.end;if(t<=0)return{startControlPoint1:e.clone(),startControlPoint2:e.clone(),divider:e.clone(),dividerControlPoint1:i.clone(),dividerControlPoint2:n.clone()};if(1<=t)return{startControlPoint1:i.clone(),startControlPoint2:n.clone(),divider:r.clone(),dividerControlPoint1:r.clone(),dividerControlPoint2:r.clone()};e=new C(e,i).pointAt(t),i=new C(i,n).pointAt(t),n=new C(n,r).pointAt(t),r=new C(e,i).pointAt(t),i=new C(i,n).pointAt(t);return{startControlPoint1:e,startControlPoint2:r,divider:new C(r,i).pointAt(t),dividerControlPoint1:i,dividerControlPoint2:n}},getSubdivisions:function(t){var t=void 0===(t=t||{}).precision?this.PRECISION:t.precision,e=[new d(this.start,this.controlPoint1,this.controlPoint2,this.end)];if(0===t)return e;for(var i=this.endpointDistance(),n=Ot(10,-t),r=0;;){r+=1;for(var o=[],s=e.length,a=0;a<s;a++){var l=e[a].divide(.5);o.push(l[0],l[1])}for(var h=0,c=o.length,u=0;u<c;u++)h+=o[u].endpointDistance();if(1<r&&(0!==h?(h-i)/h:0)<n)return o;e=o,i=h}},isDifferentiable:function(){var t=this.start,e=this.controlPoint1,i=this.controlPoint2,n=this.end;return!(t.equals(e)&&e.equals(i)&&i.equals(n))},length:function(t){for(var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,i=void 0===t.subdivisions?this.getSubdivisions({precision:e}):t.subdivisions,n=0,r=i.length,o=0;o<r;o++)n+=i[o].endpointDistance();return n},lengthAtT:function(t,e){if(t<=0)return 0;e=void 0===(e=e||{}).precision?this.PRECISION:e.precision;return this.divide(t)[0].length({precision:e})},pointAt:function(t,e){if(t<=0)return this.start.clone();if(1<=t)return this.end.clone();t=this.tAt(t,e);return this.pointAtT(t)},pointAtLength:function(t,e){t=this.tAtLength(t,e);return this.pointAtT(t)},pointAtT:function(t){return t<=0?this.start.clone():1<=t?this.end.clone():this.getSkeletonPoints(t).divider},PRECISION:3,round:function(t){return this.start.round(t),this.controlPoint1.round(t),this.controlPoint2.round(t),this.end.round(t),this},scale:function(t,e,i){return this.start.scale(t,e,i),this.controlPoint1.scale(t,e,i),this.controlPoint2.scale(t,e,i),this.end.scale(t,e,i),this},tangentAt:function(t,e){if(!this.isDifferentiable())return null;t<0?t=0:1<t&&(t=1);t=this.tAt(t,e);return this.tangentAtT(t)},tangentAtLength:function(t,e){if(!this.isDifferentiable())return null;t=this.tAtLength(t,e);return this.tangentAtT(t)},tangentAtT:function(t){if(!this.isDifferentiable())return null;t<0?t=0:1<t&&(t=1);var t=this.getSkeletonPoints(t),e=t.startControlPoint2,i=t.dividerControlPoint1,t=t.divider,i=new C(e,i);return i.translate(t.x-e.x,t.y-e.y),i},tAt:function(t,e){if(t<=0)return 0;if(1<=t)return 1;var i=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:i,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:i}):e.subdivisions},e=this.length(i);return this.tAtLength(e*t,i)},tAtLength:function(t,e){for(var i,n,r,o=!0,s=(t<0&&(o=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),a=void 0===e.subdivisions?this.getSubdivisions({precision:s}):e.subdivisions,e={precision:s,subdivisions:a},l=0,h=a.length,c=1/h,u=0;u<h;u++){var d=o?u:h-1-u,g=a[u],p=g.endpointDistance();if(t<=l+p){i=g,n=d*c,r=(d+1)*c,A=o?t-l:p+l-t,C=o?p+l-t:t-l;break}l+=p}if(!i)return o?1:0;for(var f=this.length(e),m=Ot(10,-s);;){var v,y=0!==f?A/f:0;if(y<m)return n;if((0!==f?C/f:0)<m)return r;var y=i.divide(.5),b=(c/=2,y[0].endpointDistance()),w=y[1].endpointDistance(),y=A<=b?(i=y[0],r-=c,b-(v=A)):(i=y[1],n+=c,w-(v=A-b)),A=v,C=y}},toPoints:function(t){for(var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,i=void 0===t.subdivisions?this.getSubdivisions({precision:e}):t.subdivisions,n=[i[0].start.clone()],r=i.length,o=0;o<r;o++){var s=i[o];n.push(s.end.clone())}return n},toPolyline:function(t){return new v(this.toPoints(t))},toString:function(){return this.start+" "+this.controlPoint1+" "+this.controlPoint2+" "+this.end},translate:function(t,e){return this.start.translate(t,e),this.controlPoint1.translate(t,e),this.controlPoint2.translate(t,e),this.end.translate(t,e),this}},d.prototype.divide=d.prototype.divideAtT;var O=function(t){if(!(this instanceof O))return new O(t);if("string"==typeof t)return new O.parse(t);var e;if(this.segments=[],t)if(Array.isArray(t)&&0!==t.length)if(e=(t=t.reduce(function(t,e){return t.concat(e)},[])).length,t[0].isSegment)for(r=0;r<e;r++){var i=t[r];this.appendSegment(i)}else for(var n=null,r=0;r<e;r++){var o=t[r];if(!(o instanceof C||o instanceof d))throw new Error("Cannot construct a path segment from the provided object.");0===r&&this.appendSegment(O.createSegment("M",o.start)),n&&!n.end.equals(o.start)&&this.appendSegment(O.createSegment("M",o.start)),o instanceof C?this.appendSegment(O.createSegment("L",o.end)):o instanceof d&&this.appendSegment(O.createSegment("C",o.controlPoint1,o.controlPoint2,o.end)),n=o}else if(t.isSegment)this.appendSegment(t);else if(t instanceof C)this.appendSegment(O.createSegment("M",t.start)),this.appendSegment(O.createSegment("L",t.end));else if(t instanceof d)this.appendSegment(O.createSegment("M",t.start)),this.appendSegment(O.createSegment("C",t.controlPoint1,t.controlPoint2,t.end));else{if(!(t instanceof v))throw new Error("Cannot construct a path from the provided object.");if(t.points&&0!==t.points.length)for(e=t.points.length,r=0;r<e;r++){var s=t.points[r];0===r?this.appendSegment(O.createSegment("M",s)):this.appendSegment(O.createSegment("L",s))}}};function jt(t,e){return e.unshift(null),new(Function.prototype.bind.apply(t,e))}O.parse=function(t){if(!t)return new O;for(var e=new O,i=t.match(/(?:[a-zA-Z] *)(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)? *,? *)|(?:-?\.\d+ *,? *))+|(?:[a-zA-Z] *)(?! |\d|-|\.)/g),n=i.length,r=0;r<n;r++){var o=i[r].match(/(?:[a-zA-Z])|(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)?))|(?:(?:-?\.\d+))/g),o=O.createSegment.apply(this,o);e.appendSegment(o)}return e},O.createSegment=function(t){var e=arguments;if(!t)throw new Error("Type must be provided.");var i=O.segmentTypes[t];if(!i)throw new Error(t+" is not a recognized path segment type.");for(var n=[],r=arguments.length,o=1;o<r;o++)n.push(e[o]);return jt(i,n)},O.prototype={type:s.Path,appendSegment:function(t){var e=this.segments,i=e.length,n=0!==i?e[i-1]:null;if(Array.isArray(t)){if(!(t=t.reduce(function(t,e){return t.concat(e)},[]))[0].isSegment)throw new Error("Segments required.");for(var r=t.length,o=0;o<r;o++){var s=t[o],a=this.prepareSegment(s,n,null);e.push(a),n=a}}else{if(!t||!t.isSegment)throw new Error("Segment required.");a=this.prepareSegment(t,n,null),e.push(a)}},bbox:function(){var t=this.segments,e=t.length;if(0===e)return null;for(var i=0;i<e;i++){var n,r=t[i];r.isVisible&&(r=r.bbox(),n=n?n.union(r):r)}if(n)return n;var o=t[e-1];return new tt(o.end.x,o.end.y,0,0)},clone:function(){for(var t=this.segments,e=t.length,i=new O,n=0;n<e;n++){var r=t[n].clone();i.appendSegment(r)}return i},closestPoint:function(t,e){t=this.closestPointT(t,e);return t?this.pointAtT(t):null},closestPointLength:function(t,e){var i=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:i,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:i}):e.segmentSubdivisions},e=this.closestPointT(t,i);return e?this.lengthAtT(e,i):0},closestPointNormalizedLength:function(t,e){var i=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:i,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:i}):e.segmentSubdivisions},e=this.closestPointLength(t,i);if(0===e)return 0;t=this.length(i);return 0===t?0:e/t},closestPointT:function(t,e){var i=this.segments,n=i.length;if(0===n)return null;for(var r,o=void 0===(e=e||{}).precision?this.PRECISION:e.precision,s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=1/0,l=0;l<n;l++){var h=i[l],c=s[l];h.isVisible&&(c=h.closestPointT(t,{precision:o,subdivisions:c}),h=h.pointAtT(c),(h=new C(h,t).squaredLength())<a&&(r={segmentIndex:l,value:c},a=h))}return r||{segmentIndex:n-1,value:1}},closestPointTangent:function(t,e){var i=this.segments,n=i.length;if(0===n)return null;for(var r,o=void 0===(e=e||{}).precision?this.PRECISION:e.precision,s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=1/0,l=0;l<n;l++){var h,c=i[l],u=s[l];c.isDifferentiable()&&(u=c.closestPointT(t,{precision:o,subdivisions:u}),h=c.pointAtT(u),(h=new C(h,t).squaredLength())<a&&(r=c.tangentAtT(u),a=h))}return r||null},containsPoint:function(t,e){var i=this.toPolylines(e);if(!i)return!1;for(var n=i.length,r=0,o=0;o<n;o++)i[o].containsPoint(t)&&r++;return r%2==1},divideAt:function(t,e){if(0===this.segments.length)return null;1<(t=t<0?0:t)&&(t=1);var i=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:i,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:i}):e.segmentSubdivisions},e=this.length(i);return this.divideAtLength(e*t,i)},divideAtLength:function(t,e){var i=this.segments.length;if(0===i)return null;for(var n,r,o,s,a=!0,l=(t<0&&(a=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),h=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:l}):e.segmentSubdivisions,c=0,u=0;u<i;u++){var d=a?u:i-1-u,g=this.getSegment(d),p=h[d],f=g.length({precision:l,subdivisions:p});if(g.isDifferentiable()&&(o=g,s=d,t<=c+f)){r=d,n=g.divideAtLength((a?1:-1)*(t-c),{precision:l,subdivisions:p});break}c+=f}if(!o)return null;n||(r=s,n=o.divideAtT(a?1:0));var m=this.clone(),e=(m.replaceSegment(r,n),r),v=r+1,y=r+2,b=(n[0].isDifferentiable()||(m.removeSegment(e),--v,--y),m.getSegment(v).start),w=(m.insertSegment(v,O.createSegment("M",b)),y+=1,n[1].isDifferentiable()||(m.removeSegment(y-1),--y),y-e-1);for(u=y;u<m.segments.length;u++){var A=this.getSegment(u-w);"Z"!==(g=m.getSegment(u)).type||A.subpathStartSegment.end.equals(g.subpathStartSegment.end)||(A=O.createSegment("L",A.end),m.replaceSegment(u,A))}return[new O(m.segments.slice(0,v)),new O(m.segments.slice(v))]},equals:function(t){if(!t)return!1;var e=this.segments,i=t.segments,n=e.length;if(i.length!==n)return!1;for(var r=0;r<n;r++){var o=e[r],s=i[r];if(o.type!==s.type||!o.equals(s))return!1}return!0},getSegment:function(t){var e=this.segments,i=e.length;if(0===i)throw new Error("Path has no segments.");if(i<=(t=t<0?i+t:t)||t<0)throw new Error("Index out of range.");return e[t]},getSegmentSubdivisions:function(t){for(var e=this.segments,i=e.length,n=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=[],o=0;o<i;o++){var s=e[o].getSubdivisions({precision:n});r.push(s)}return r},getSubpaths:function(){for(var t=this.clone().validate().segments,e=t.length,i=[],n=0;n<e;n++){var r=t[n];r.isSubpathStart?i.push(new O(r)):i[i.length-1].appendSegment(r)}return i},insertSegment:function(t,e){var i=this.segments,n=i.length;if(n<(t=t<0?n+t+1:t)||t<0)throw new Error("Index out of range.");var r=null,o=null;if(0!==n&&(o=1<=t?(r=i[t-1]).nextSegment:i[0]),Array.isArray(e)){if(!(e=e.reduce(function(t,e){return t.concat(e)},[]))[0].isSegment)throw new Error("Segments required.");for(var s=e.length,a=0;a<s;a++){var l=e[a],h=this.prepareSegment(l,r,o);i.splice(t+a,0,h),r=h}}else{if(!e||!e.isSegment)throw new Error("Segment required.");h=this.prepareSegment(e,r,o),i.splice(t,0,h)}},intersectionWithLine:function(t,e){var i=null,n=this.toPolylines(e);if(!n)return null;for(var r=0,o=n.length;r<o;r++){var s=n[r],s=t.intersect(s);s&&(i=i||[],Array.isArray(s)?Array.prototype.push.apply(i,s):i.push(s))}return i},isDifferentiable:function(){for(var t=this.segments,e=t.length,i=0;i<e;i++)if(t[i].isDifferentiable())return!0;return!1},isValid:function(){var t=this.segments;return 0===t.length||"M"===t[0].type},length:function(t){var e=this.segments,i=e.length;if(0===i)return 0;for(var n=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=void 0===t.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):t.segmentSubdivisions,o=0,s=0;s<i;s++){var a=e[s],l=r[s];o+=a.length({subdivisions:l})}return o},lengthAtT:function(t,e){var i=this.segments,n=i.length;if(0===n)return 0;var r=t.segmentIndex;if(r<0)return 0;for(var t=t.value,o=(n<=r?(r=n-1,t=1):t<0?t=0:1<t&&(t=1),void 0===(e=e||{}).precision?this.PRECISION:e.precision),s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=0,l=0;l<r;l++){var h=i[l],c=s[l];a+=h.length({precisison:o,subdivisions:c})}return h=i[r],c=s[r],a+=h.lengthAtT(t,{precisison:o,subdivisions:c})},pointAt:function(t,e){if(0===this.segments.length)return null;if(t<=0)return this.start.clone();if(1<=t)return this.end.clone();var i=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:i,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:i}):e.segmentSubdivisions},e=this.length(i);return this.pointAtLength(e*t,i)},pointAtLength:function(t,e){var i=this.segments,n=i.length;if(0===n)return null;if(0===t)return this.start.clone();for(var r,o=!0,s=(t<0&&(o=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):e.segmentSubdivisions,l=0,h=0;h<n;h++){var c=o?h:n-1-h,u=i[c],c=a[c],d=u.length({precision:s,subdivisions:c});if(u.isVisible){if(t<=l+d)return u.pointAtLength((o?1:-1)*(t-l),{precision:s,subdivisions:c});r=u}l+=d}return r?o?r.end:r.start:i[n-1].end.clone()},pointAtT:function(t){var e=this.segments,i=e.length;if(0===i)return null;var n=t.segmentIndex;if(n<0)return e[0].pointAtT(0);if(i<=n)return e[i-1].pointAtT(1);i=t.value;return i<0?i=0:1<i&&(i=1),e[n].pointAtT(i)},PRECISION:3,prepareSegment:function(t,e,i){t.previousSegment=e,t.nextSegment=i,e&&(e.nextSegment=t),i&&(i.previousSegment=t);e=t;return t.isSubpathStart&&(t.subpathStartSegment=t,e=i),e&&this.updateSubpathStartSegment(e),t},removeSegment:function(t){var e=this.segments,i=e.length;if(0===i)throw new Error("Path has no segments.");if(i<=(t=t<0?i+t:t)||t<0)throw new Error("Index out of range.");i=e.splice(t,1)[0],e=i.previousSegment,t=i.nextSegment;e&&(e.nextSegment=t),t&&(t.previousSegment=e),i.isSubpathStart&&t&&this.updateSubpathStartSegment(t)},replaceSegment:function(t,e){var i=this.segments,n=i.length;if(0===n)throw new Error("Path has no segments.");if(n<=(t=t<0?n+t:t)||t<0)throw new Error("Index out of range.");var n=i[t],r=n.previousSegment,o=n.nextSegment,s=n.isSubpathStart;if(Array.isArray(e)){if(!(e=e.reduce(function(t,e){return t.concat(e)},[]))[0].isSegment)throw new Error("Segments required.");i.splice(t,1);for(var a=e.length,l=0;l<a;l++){var h=e[l],c=this.prepareSegment(h,r,o);i.splice(t+l,0,c),r=c,s&&c.isSubpathStart&&(s=!1)}}else{if(!e||!e.isSegment)throw new Error("Segment required.");c=this.prepareSegment(e,r,o),i.splice(t,1,c),s&&c.isSubpathStart&&(s=!1)}s&&o&&this.updateSubpathStartSegment(o)},round:function(t){for(var e=this.segments,i=e.length,n=0;n<i;n++)e[n].round(t);return this},scale:function(t,e,i){for(var n=this.segments,r=n.length,o=0;o<r;o++)n[o].scale(t,e,i);return this},segmentAt:function(t,e){t=this.segmentIndexAt(t,e);return t?this.getSegment(t):null},segmentAtLength:function(t,e){t=this.segmentIndexAtLength(t,e);return t?this.getSegment(t):null},segmentIndexAt:function(t,e){if(0===this.segments.length)return null;1<(t=t<0?0:t)&&(t=1);var i=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:i,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:i}):e.segmentSubdivisions},e=this.length(i);return this.segmentIndexAtLength(e*t,i)},segmentIndexAtLength:function(t,e){var i=this.segments,n=i.length;if(0===n)return null;for(var r=!0,o=(t<0&&(r=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=null,l=0,h=0;h<n;h++){var c=r?h:n-1-h,u=i[c],d=s[c],d=u.length({precision:o,subdivisions:d});if(u.isVisible){if(t<=l+d)return c;a=c}l+=d}return a},serialize:function(){if(this.isValid())return this.toString();throw new Error("Invalid path segments.")},tangentAt:function(t,e){if(0===this.segments.length)return null;1<(t=t<0?0:t)&&(t=1);var i=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:i,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:i}):e.segmentSubdivisions},e=this.length(i);return this.tangentAtLength(e*t,i)},tangentAtLength:function(t,e){var i=this.segments,n=i.length;if(0===n)return null;for(var r,o=!0,s=(t<0&&(o=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):e.segmentSubdivisions,l=0,h=0;h<n;h++){var c=o?h:n-1-h,u=i[c],c=a[c],d=u.length({precision:s,subdivisions:c});if(u.isDifferentiable()){if(t<=l+d)return u.tangentAtLength((o?1:-1)*(t-l),{precision:s,subdivisions:c});r=u}l+=d}return r?r.tangentAtT(o?1:0):null},tangentAtT:function(t){var e=this.segments,i=e.length;if(0===i)return null;var n=t.segmentIndex;if(n<0)return e[0].tangentAtT(0);if(i<=n)return e[i-1].tangentAtT(1);i=t.value;return i<0?i=0:1<i&&(i=1),e[n].tangentAtT(i)},toPoints:function(t){var e=this.segments,i=e.length;if(0===i)return null;for(var n=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=void 0===t.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):t.segmentSubdivisions,o=[],s=[],a=0;a<i;a++){var l,h=e[a];h.isVisible?0<(l=r[a]).length?(l=l.map(function(t){return t.start}),Array.prototype.push.apply(s,l)):s.push(h.start):0<s.length&&(s.push(e[a-1].end),o.push(s),s=[])}return 0<s.length&&(s.push(this.end),o.push(s)),o},toPolylines:function(t){var e=[],i=this.toPoints(t);if(!i)return null;for(var n=0,r=i.length;n<r;n++)e.push(new v(i[n]));return e},toString:function(){for(var t=this.segments,e=t.length,i="",n=0;n<e;n++)i+=t[n].serialize()+" ";return i.trim()},translate:function(t,e){for(var i=this.segments,n=i.length,r=0;r<n;r++)i[r].translate(t,e);return this},updateSubpathStartSegment:function(t){for(var e=t.previousSegment;t&&!t.isSubpathStart;)t.subpathStartSegment=e?e.subpathStartSegment:null,t=(e=t).nextSegment},validate:function(){return this.isValid()||this.insertSegment(0,O.createSegment("M",0,0)),this}},Object.defineProperty(O.prototype,"start",{configurable:!0,enumerable:!0,get:function(){var t=this.segments,e=t.length;if(0===e)return null;for(var i=0;i<e;i++){var n=t[i];if(n.isVisible)return n.start}return t[e-1].end}}),Object.defineProperty(O.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.segments,e=t.length;if(0===e)return null;for(var i=e-1;0<=i;i--){var n=t[i];if(n.isVisible)return n.end}return t[e-1].end}});function _t(){for(var t,e=arguments,i=[],n=arguments.length,r=0;r<n;r++)i.push(e[r]);if(!(this instanceof _t))return jt(_t,i);if(0===n)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates (none provided).");if(i[0]instanceof C){if(1===n)return this.end=i[0].end.clone(),this;throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+n+" lines provided).")}if("string"==typeof i[0]||"number"==typeof i[0]){if(2===n)return this.end=new z(+i[0],+i[1]),this;if(n<2)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+n+" coordinates provided).");for(var o,s=[],r=0;r<n;r+=2)o=i.slice(r,r+2),s.push(jt(_t,o));return s}if(1===n)return this.end=new z(i[0]),this;for(s=[],r=0;r<n;r+=1)t=i[r],s.push(new _t(t));return s}function Zt(){for(var t,e=arguments,i=[],n=arguments.length,r=0;r<n;r++)i.push(e[r]);if(!(this instanceof Zt))return jt(Zt,i);if(0===n)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates (none provided).");if(i[0]instanceof d){if(1===n)return this.controlPoint1=i[0].controlPoint1.clone(),this.controlPoint2=i[0].controlPoint2.clone(),this.end=i[0].end.clone(),this;throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+n+" curves provided).")}if("string"==typeof i[0]||"number"==typeof i[0]){if(6===n)return this.controlPoint1=new z(+i[0],+i[1]),this.controlPoint2=new z(+i[2],+i[3]),this.end=new z(+i[4],+i[5]),this;if(n<6)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+n+" coordinates provided).");for(var o,s=[],r=0;r<n;r+=6)o=i.slice(r,r+6),s.push(jt(Zt,o));return s}if(3===n)return this.controlPoint1=new z(i[0]),this.controlPoint2=new z(i[1]),this.end=new z(i[2]),this;if(n<3)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+n+" points provided).");for(s=[],r=0;r<n;r+=3)t=i.slice(r,r+3),s.push(jt(Zt,t));return s}function Yt(){for(var t,e=arguments,i=[],n=arguments.length,r=0;r<n;r++)i.push(e[r]);if(!(this instanceof Yt))return jt(Yt,i);if(0===n)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates (none provided).");if(i[0]instanceof C){if(1===n)return this.end=i[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+n+" lines provided).")}if(i[0]instanceof d){if(1===n)return this.end=i[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+n+" curves provided).")}if("string"==typeof i[0]||"number"==typeof i[0]){if(2===n)return this.end=new z(+i[0],+i[1]),this;if(n<2)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+n+" coordinates provided).");for(var o,s=[],r=0;r<n;r+=2)o=i.slice(r,r+2),0===r?s.push(jt(Yt,o)):s.push(jt(_t,o));return s}if(1===n)return this.end=new z(i[0]),this;for(s=[],r=0;r<n;r+=1)t=i[r],0===r?s.push(new Yt(t)):s.push(new _t(t));return s}function Wt(){for(var t=arguments,e=[],i=arguments.length,n=0;n<i;n++)e.push(t[n]);if(!(this instanceof Wt))return jt(Wt,e);if(0<i)throw new Error("Closepath constructor expects no arguments.");return this}var Ft={bbox:function(){throw new Error("Declaration missing for virtual function.")},clone:function(){throw new Error("Declaration missing for virtual function.")},closestPoint:function(){throw new Error("Declaration missing for virtual function.")},closestPointLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointNormalizedLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointT:function(t){if(this.closestPointNormalizedLength)return this.closestPointNormalizedLength(t);throw new Error("Neither closestPointT() nor closestPointNormalizedLength() function is implemented.")},closestPointTangent:function(){throw new Error("Declaration missing for virtual function.")},divideAt:function(){throw new Error("Declaration missing for virtual function.")},divideAtLength:function(){throw new Error("Declaration missing for virtual function.")},divideAtT:function(t){if(this.divideAt)return this.divideAt(t);throw new Error("Neither divideAtT() nor divideAt() function is implemented.")},equals:function(){throw new Error("Declaration missing for virtual function.")},getSubdivisions:function(){throw new Error("Declaration missing for virtual function.")},isDifferentiable:function(){throw new Error("Declaration missing for virtual function.")},isSegment:!0,isSubpathStart:!1,isVisible:!0,length:function(){throw new Error("Declaration missing for virtual function.")},lengthAtT:function(t){if(t<=0)return 0;var e=this.length();return 1<=t?e:e*t},nextSegment:null,pointAt:function(){throw new Error("Declaration missing for virtual function.")},pointAtLength:function(){throw new Error("Declaration missing for virtual function.")},pointAtT:function(t){if(this.pointAt)return this.pointAt(t);throw new Error("Neither pointAtT() nor pointAt() function is implemented.")},previousSegment:null,round:function(){throw new Error("Declaration missing for virtual function.")},subpathStartSegment:null,scale:function(){throw new Error("Declaration missing for virtual function.")},serialize:function(){throw new Error("Declaration missing for virtual function.")},tangentAt:function(){throw new Error("Declaration missing for virtual function.")},tangentAtLength:function(){throw new Error("Declaration missing for virtual function.")},tangentAtT:function(t){if(this.tangentAt)return this.tangentAt(t);throw new Error("Neither tangentAtT() nor tangentAt() function is implemented.")},toString:function(){throw new Error("Declaration missing for virtual function.")},translate:function(){throw new Error("Declaration missing for virtual function.")}},Ut=(Object.defineProperty(Ft,"end",{configurable:!0,enumerable:!0,writable:!0}),Object.defineProperty(Ft,"start",{configurable:!0,enumerable:!0,get:function(){if(this.previousSegment)return this.previousSegment.end;throw new Error("Missing previous segment. (This segment cannot be the first segment of a path; OR segment has not yet been added to a path.)")}}),Object.defineProperty(Ft,"type",{configurable:!0,enumerable:!0,get:function(){throw new Error("Bad segment declaration. No type specified.")}}),{clone:function(){return new _t(this.end)},divideAt:function(t){t=new C(this.start,this.end).divideAt(t);return[new _t(t[0]),new _t(t[1])]},divideAtLength:function(t){t=new C(this.start,this.end).divideAtLength(t);return[new _t(t[0]),new _t(t[1])]},getSubdivisions:function(){return[]},isDifferentiable:function(){return!!this.previousSegment&&!this.start.equals(this.end)},round:function(t){return this.end.round(t),this},scale:function(t,e,i){return this.end.scale(t,e,i),this},serialize:function(){var t=this.end;return this.type+" "+t.x+" "+t.y},toString:function(){return this.type+" "+this.start+" "+this.end},translate:function(t,e){return this.end.translate(t,e),this}}),Ut=(Object.defineProperty(Ut,"type",{configurable:!0,enumerable:!0,value:"L"}),_t.prototype=Vt(Ft,C.prototype,Ut),{clone:function(){return new Zt(this.controlPoint1,this.controlPoint2,this.end)},divideAt:function(t,e){t=new d(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAt(t,e);return[new Zt(t[0]),new Zt(t[1])]},divideAtLength:function(t,e){t=new d(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtLength(t,e);return[new Zt(t[0]),new Zt(t[1])]},divideAtT:function(t){t=new d(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtT(t);return[new Zt(t[0]),new Zt(t[1])]},isDifferentiable:function(){if(!this.previousSegment)return!1;var t=this.start,e=this.controlPoint1,i=this.controlPoint2,n=this.end;return!(t.equals(e)&&e.equals(i)&&i.equals(n))},round:function(t){return this.controlPoint1.round(t),this.controlPoint2.round(t),this.end.round(t),this},scale:function(t,e,i){return this.controlPoint1.scale(t,e,i),this.controlPoint2.scale(t,e,i),this.end.scale(t,e,i),this},serialize:function(){var t=this.controlPoint1,e=this.controlPoint2,i=this.end;return this.type+" "+t.x+" "+t.y+" "+e.x+" "+e.y+" "+i.x+" "+i.y},toString:function(){return this.type+" "+this.start+" "+this.controlPoint1+" "+this.controlPoint2+" "+this.end},translate:function(t,e){return this.controlPoint1.translate(t,e),this.controlPoint2.translate(t,e),this.end.translate(t,e),this}}),Ut=(Object.defineProperty(Ut,"type",{configurable:!0,enumerable:!0,value:"C"}),Zt.prototype=Vt(Ft,d.prototype,Ut),{bbox:function(){return null},clone:function(){return new Yt(this.end)},closestPoint:function(){return this.end.clone()},closestPointNormalizedLength:function(){return 0},closestPointLength:function(){return 0},closestPointT:function(){return 1},closestPointTangent:function(){return null},divideAt:function(){return[this.clone(),this.clone()]},divideAtLength:function(){return[this.clone(),this.clone()]},equals:function(t){return this.end.equals(t.end)},getSubdivisions:function(){return[]},isDifferentiable:function(){return!1},isSubpathStart:!0,isVisible:!1,length:function(){return 0},lengthAtT:function(){return 0},pointAt:function(){return this.end.clone()},pointAtLength:function(){return this.end.clone()},pointAtT:function(){return this.end.clone()},round:function(t){return this.end.round(t),this},scale:function(t,e,i){return this.end.scale(t,e,i),this},serialize:function(){var t=this.end;return this.type+" "+t.x+" "+t.y},tangentAt:function(){return null},tangentAtLength:function(){return null},tangentAtT:function(){return null},toString:function(){return this.type+" "+this.end},translate:function(t,e){return this.end.translate(t,e),this}}),Ut=(Object.defineProperty(Ut,"start",{configurable:!0,enumerable:!0,get:function(){throw new Error("Illegal access. Moveto segments should not need a start property.")}}),Object.defineProperty(Ut,"type",{configurable:!0,enumerable:!0,value:"M"}),Yt.prototype=Vt(Ft,Ut),{clone:function(){return new Wt},divideAt:function(t){t=new C(this.start,this.end).divideAt(t);return[t[1].isDifferentiable()?new _t(t[0]):this.clone(),new _t(t[1])]},divideAtLength:function(t){t=new C(this.start,this.end).divideAtLength(t);return[t[1].isDifferentiable()?new _t(t[0]):this.clone(),new _t(t[1])]},getSubdivisions:function(){return[]},isDifferentiable:function(){return!(!this.previousSegment||!this.subpathStartSegment)&&!this.start.equals(this.end)},round:function(){return this},scale:function(){return this},serialize:function(){return this.type},toString:function(){return this.type+" "+this.start+" "+this.end},translate:function(){return this}}),Ft=(Object.defineProperty(Ut,"end",{configurable:!0,enumerable:!0,get:function(){if(this.subpathStartSegment)return this.subpathStartSegment.end;throw new Error("Missing subpath start segment. (This segment needs a subpath start segment (e.g. Moveto); OR segment has not yet been added to a path.)")}}),Object.defineProperty(Ut,"type",{configurable:!0,enumerable:!0,value:"Z"}),Wt.prototype=Vt(Ft,C.prototype,Ut),O.segmentTypes={L:_t,C:Zt,M:Yt,Z:Wt,z:Wt}),Ut=(O.regexSupportedData=new RegExp("^[\\s\\d"+Object.keys(Ft).join("")+",.]*$"),O.isDataSupported=function(t){return"string"==typeof t&&this.regexSupportedData.test(t)},{curveThroughPoints:function(t){return console.warn("deprecated"),new O(d.throughPoints(t)).serialize()},getCurveControlPoints:function(t){console.warn("deprecated");var e=[],i=[],n=t.length-1;if(1==n)return e[0]=new z((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),i[0]=new z(2*e[0].x-t[0].x,2*e[0].y-t[0].y),[e,i];for(var r=[],o=1;o<n-1;o++)r[o]=4*t[o].x+2*t[o+1].x;r[0]=t[0].x+2*t[1].x,r[n-1]=(8*t[n-1].x+t[n].x)/2;var s=this.getFirstControlPoints(r);for(o=1;o<n-1;++o)r[o]=4*t[o].y+2*t[o+1].y;r[0]=t[0].y+2*t[1].y,r[n-1]=(8*t[n-1].y+t[n].y)/2;var a=this.getFirstControlPoints(r);for(o=0;o<n;o++)e.push(new z(s[o],a[o])),o<n-1?i.push(new z(2*t[o+1].x-s[o+1],2*t[o+1].y-a[o+1])):i.push(new z((t[n].x+s[n-1])/2,(t[n].y+a[n-1])/2));return[e,i]},getCurveDivider:function(t,e,i,n){console.warn("deprecated");var r=new d(t,e,i,n);return function(t){t=r.divide(t);return[{p0:t[0].start,p1:t[0].controlPoint1,p2:t[0].controlPoint2,p3:t[0].end},{p0:t[1].start,p1:t[1].controlPoint1,p2:t[1].controlPoint2,p3:t[1].end}]}},getFirstControlPoints:function(t){console.warn("deprecated");var e=t.length,i=[],n=[],r=2;i[0]=t[0]/r;for(var o=1;o<e;o++)n[o]=1/r,r=(o<e-1?4:3.5)-n[o],i[o]=(t[o]-i[o-1])/r;for(o=1;o<e;o++)i[e-o-1]-=n[e-o]*i[e-o];return i},getInversionSolver:function(t,e,i,n){console.warn("deprecated");var r=new d(t,e,i,n);return function(t){return r.closestPointT(t)}}}),Ht=function(t){return this instanceof Ht?"string"==typeof t?new Ht.parse(t):void(this.points=Array.isArray(t)?t.map(z):[]):new Ht(t)};function Xt(t,e){var i=t.start.x,n=t.start.y,r=t.end.x,t=t.end.y,o=e.start.x,s=e.start.y,r=r-i,t=t-n,a=e.end.x-o,e=e.end.y-s,i=i-o,o=n-s,n=r*e-a*t,s=(r*o-t*i)/n,r=(a*o-e*i)/n;return 0<=s&&s<=1&&0<=r&&r<=1}function Jt(t,e){var i=t.a,n=t.b,r=t.x,t=t.y,o=e.start.x-r,r=e.end.x-r,s=e.start.y-t,i=i*i,n=n*n,r=r-o,e=e.end.y-t-s,t=r*r/i+e*e/n,r=2*o*r/i+2*s*e/n,e=r*r-4*t*(o*o/i+s*s/n-1);return 0==e?0<=(o=-r/2/t)&&o<=1:0<e&&(s=(-r-(i=Math.sqrt(e)))/2/t,0<=(n=(-r+i)/2/t)&&n<=1||0<=s&&s<=1)}function $t(t,e){var i=0,n=0,r=Math.cos,o=(s=Math.sin)(i),i=r(i),s=s(n),r=r(n),n=o*o,a=i*i,o=o*i,i=s*s,l=r*r,s=s*r,r=t.a*t.a,h=t.b*t.b,c=e.a*e.a,u=e.b*e.b,d=r*n+h*a,g=c*i+u*l,a=r*a+h*n,n=c*l+u*i,l=2*(h-r)*o,i=2*(u-c)*s,o=-2*d*t.x-l*t.y,s=-2*g*e.x-i*e.y,p=-l*t.x-2*a*t.y,f=-i*e.x-2*n*e.y,t=d*t.x*t.x+a*t.y*t.y+l*t.x*t.y-r*h,r=g*e.x*e.x+n*e.y*e.y+i*e.x*e.y-c*u,h=(i/=2,s/=2,f/=2,Ce([[d,l/=2,o/=2],[l,a,p/=2],[o,p,t]])),e=Ce([[g,i,s],[i,n,f],[s,f,r]]),c=.33333333*(Ce([[g,l,o],[i,a,p],[s,p,t]])+Ce([[d,i,o],[l,n,p],[o,f,t]])+Ce([[d,l,s],[l,a,f],[o,p,r]])),u=.33333333*(Ce([[d,i,s],[l,n,f],[o,f,r]])+Ce([[g,l,s],[i,a,f],[s,p,r]])+Ce([[g,i,o],[i,n,p],[s,f,t]])),d=Ae([[h,c],[c,u]]),l=Ae([[h,u],[c,e]]),a=Ae([[c,u],[u,e]]);return!(0<Ae([[2*d,l],[l,2*a]])&&(0<u||0<c))}function Qt(t,e){var i=e.start,n=e.end,r=t.x,o=t.y,s=t.width,a=t.height;return!(i.x>r+s&&n.x>r+s||i.x<r&&n.x<r||i.y>o+a&&n.y>o+a||i.y<o&&n.y<o)&&(!(!t.containsPoint(e.start)&&!t.containsPoint(e.end))||(Xt(t.topLine(),e)||Xt(t.rightLine(),e)||Xt(t.bottomLine(),e)||Xt(t.leftLine(),e)))}function Kt(t,e){return!!qt(t,tt.fromEllipse(e))&&oe(Ht.fromRect(t),e)}function qt(t,e){return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y}function te(t,e){return fe(t,e,{interior:!1})}function ee(t,e){return me(t,e,{interior:!1})}function ie(t,e){return ve(t,e,{interior:!1})}function ne(t,e){return be(t,e,{interior:!1})}function re(t,e){return fe(t,e,{interior:!0})}function oe(t,e){return me(t,e,{interior:!0})}function se(t,e){return ve(t,e,{interior:!0})}function ae(t,e){return be(t,e,{interior:!0})}function le(t,e){return we(t,e,{interior:!0})}function he(t,i,n){return t.getSubpaths().some(function(t){var e=t.toPolylines(n)[0];return("Z"===t.getSegment(-1).type?re:te)(e,i)})}function ce(t,i,n){return t.getSubpaths().some(function(t){var e=t.toPolylines(n)[0];return("Z"===t.getSegment(-1).type?oe:ee)(e,i)})}function ue(t,e,i){return ge(t,Ht.fromRect(e),i)}function de(t,e,i){return ye(t,e,i,{interior:!1})}function ge(t,e,i){return ye(t,e,i,{interior:!0})}function pe(t,i,n,r){return t.getSubpaths().some(function(t){var e=t.toPolylines(n)[0];return("Z"===t.getSegment(-1).type?ge:de)(i,e,r)})}function fe(t,e,i){i=(i=void 0===i?{}:i).interior;if(i=void 0===i?!1:i){if(t.containsPoint(e.start))return!0;var i=t.start,n=t.end,r=t.points,o=n.equals(i)?r:r.concat([i])}else o=t.points;for(var s=o.length,a=new C,l=0;l<s-1;l++)if(a.start=o[l],a.end=o[l+1],Xt(e,a))return!0;return!1}function me(t,e,i){void 0===i&&(i={});var n,r=t.start,o=t.end,s=t.points;if(e.containsPoint(r))return!0;i=i.interior;if(i=void 0===i?!1:i){if(t.containsPoint(e.center()))return!0;n=o.equals(r)?s:s.concat([r])}else n=s;for(var a=n.length,l=new C,h=0;h<a-1;h++)if(l.start=n[h],l.end=n[h+1],Jt(e,l))return!0;return!1}function ve(t,e,i){return we(t,Ht.fromRect(e),i)}function ye(t,i,n,r){return t.getSubpaths().some(function(t){var e=t.toPolylines(n)[0];return("Z"===t.getSegment(-1).type?we:be)(i,e,r)})}function be(t,e,i){var n,i=(i=void 0===i?{}:i).interior;if(i=void 0===i?!1:i){i=e.start;if(t.containsPoint(i))return!0;n=t.clone().close()}else n=t;for(var r=e.points,o=r.length,s=new C,a=0;a<o-1;a++)if(s.start=r[a],s.end=r[a+1],te(n,s))return!0;return!1}function we(t,e,i){return e.containsPoint(t.start)||be(t,e.clone().close(),i)}function Ae(t){return t[0][0]*t[1][1]-t[0][1]*t[1][0]}function Ce(t){return t[0][0]*t[1][1]*t[2][2]-t[0][0]*t[1][2]*t[2][1]-t[0][1]*t[1][0]*t[2][2]+t[0][1]*t[1][2]*t[2][0]+t[0][2]*t[1][0]*t[2][1]-t[0][2]*t[1][1]*t[2][0]}Ht.parse=function(t){return new Ht(Tt(t))},Ht.fromRect=function(t){return new Ht([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft()])},Ht.prototype=Vt(v.prototype,{type:s.Polygon,clone:function(){return new Ht(Lt(this.points))},convexHull:function(){return new Ht(Et(this.points))},lengthPoints:function(){var t=this.start,e=this.end,i=this.points;return i.length<=1||t.equals(e)?i:i.concat([t.clone()])}});function Ie(t){return t&&t.toString().split(" ").map(function(t){return t=t.substr(0,Qe.classNamePrefix.length)!==Qe.classNamePrefix?Qe.classNamePrefix+t:t}).join(" ")}function xe(t){return t&&t.toString().split(" ").map(function(t){return t=t.substr(0,Qe.classNamePrefix.length)===Qe.classNamePrefix?t.substr(Qe.classNamePrefix.length):t}).join(" ")}function Se(t,e){for(var i={},n={},r=B.namespace.svg,o=e||r,e=document.createDocumentFragment(),s=[t,e,o];0<s.length;)for(var o=s.pop(),a=s.pop(),l=s.pop(),h=0,c=l.length;h<c;h++){var u=l[h];if(!u.hasOwnProperty("tagName"))throw new Error("json-dom-parser: missing tagName");var d=u.tagName,g=(u.hasOwnProperty("namespaceURI")&&(o=u.namespaceURI),document.createElementNS(o,d)),d=o===r,p=d?B:w,f=u.attributes,f=(f&&p(g).attr(f),u.style);if(f&&w(g).css(f),u.hasOwnProperty("className")&&(f=u.className,d?g.className.baseVal=f:g.className=f),u.hasOwnProperty("textContent")&&(g.textContent=u.textContent),u.hasOwnProperty("selector")){d=u.selector;if(i[d])throw new Error("json-dom-parser: selector must be unique");p(i[d]=g).attr("joint-selector",d)}if(u.hasOwnProperty("groupSelector"))for(var m=u.groupSelector,v=0,y=(m=Array.isArray(m)?m:[m]).length;v<y;v++){var b=m[v];(n[b]||(n[b]=[])).push(g)}a.appendChild(g);f=u.children;Array.isArray(f)&&s.push(f,g,o)}return{fragment:e,selectors:i,groupSelectors:n}}function Pe(t){var e=0;if(0===t.length)return e;for(var i=0;i<t.length;i++){e=(e<<5)-e+t.charCodeAt(i);e&=e}return e}function Me(t,e,i){for(var n,r=Array.isArray(e)?e:e.split(i||"/"),o=0,s=r.length;o<s;){if(n=r[o++],!(Object(t)===t&&n in t))return;t=t[n]}return t}function ke(t,e){return("constructor"!==(e="string"!=typeof e&&"number"!=typeof e?String(e):e)||"function"!=typeof t[e])&&"__proto__"!==e}function Ne(t,e,i,n){for(var r=Array.isArray(e)?e:e.split(n||"/"),o=r.length-1,s=t,a=0;a<o;a++){var l=r[a];if(!ke(s,l))return t;s=s[l]||(s[l]={})}return s[r[o]]=i,t}function Te(t,e,i){for(var n=Array.isArray(e)?e:e.split(i||"/"),r=n.length-1,o=t,s=0;s<r;s++){var a=n[s];if(!ke(o,a))return t;a=o[a];if(!a)return t;o=a}return delete o[n[r]],t}function Le(t,e,i){e=e||"/";var n,r={};for(n in t)if(t.hasOwnProperty(n)){var o="object"==typeof t[n];if(o=o&&i&&i(t[n])?!1:o){var s,a=Le(t[n],e,i);for(s in a)a.hasOwnProperty(s)&&(r[n+e+s]=a[s])}else r[n]=t[n]}return r}function Ee(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}function De(t){return De.id=De.id||1,t.id=void 0===t.id?"j_"+De.id++:t.id,t.id}function Be(t){return t.replace(/[A-Z]/g,"-$&").toLowerCase()}function I(t){var e=t,i=t.originalEvent&&t.originalEvent.changedTouches&&t.originalEvent.changedTouches[0];if(i){for(var n in t)void 0===i[n]&&(i[n]=t[n]);e=i}var r=e.target;return r&&(r=r.correspondingUseElement)&&(e.target=r),e}function Ge(t,e){var i=parseFloat(t);if(Number.isNaN(i))return null;var n,r={};if(r.value=i,null==e)n="[A-Za-z]*";else if(Array.isArray(e)){if(0===e.length)return null;n=e.join("|")}else N(e)&&(n=e);return i=n,null===(e=(i=new RegExp("(?:\\d+(?:\\.\\d+)*)("+i+")$").exec(t))?i[1]:null)?null:(r.unit=e,r)}function ze(t,e,i,n){void 0===i&&(i={});for(var r,o=e.width,s=e.height,e=(n=void 0===n?{}:n).svgDocument||B("svg").node,a=B("tspan").node,l=B("text").attr(i).append(a).node,h=document.createTextNode(""),c=(l.style.opacity=0,l.style.display="block",a.style.display="block",a.appendChild(h),e.appendChild(l),n.svgDocument||document.body.appendChild(e),n.separator||" "),u=n.eol||"\n",d=n.hyphen?new RegExp(n.hyphen):/[^\w\d]/,g=n.maxLineCount,p=(G(g)||(g=1/0),t.split(c)),f=[],m=[],v=0,y=0,b=p.length;v<b;v++){var w=p[v];if(w){var A=!1;if(u&&0<=w.indexOf(u)){if(1<w.length){for(var C=w.split(u),I=0,x=C.length-1;I<x;I++)C.splice(2*I+1,0,u);p.splice.apply(p,[v,1].concat(C.filter(function(t){return""!==t}))),v--,b=p.length;continue}A=!(m[++y]="")}if(!A)if(h.data=m[y]?m[y]+" "+w:w,a.getComputedTextLength()<=o)m[y]=h.data,(P||r)&&(f[y++]=!0,r=P=0);else{if(!m[y]||P){var S=!!P,P=w.length-1;if(S||!P){if(!P){if(!m[y]){m=[];break}p.splice(v,2,w+p[v+1]),b--,f[y++]=!0,v--;continue}p[v]=w.substring(0,P),p[v+1]=w.substring(P)+(void 0===p[v+1]?"":p[v+1])}else r?(p.splice(v,2,p[v]+p[v+1]),r=0):(-1<(S=w.search(d))&&S!==w.length-1&&0!==S&&(r=S+1,P=0),p.splice(v,1,w.substring(0,r||P),w.substring(r||P)),b++),y&&!f[y-1]&&y--;v--;continue}y++,v--}var M,k=null;if(m.length>g?k=g-1:void 0!==s&&(void 0===M&&(M=(S="auto"===i.lineHeight?{value:1.5,unit:"em"}:Ge(i.lineHeight,["em"])||{value:1,unit:"em"}).value,"em"===S.unit&&(M*=l.getBBox().height)),M*m.length>s&&(k=Math.floor(s/M)-1)),null!==k){m.splice(k+1);var N=n.ellipsis;if(!N||k<0)break;"string"!=typeof N&&(N="\u2026");var T=m[k];if(!T&&!A)break;var L,E,D=T.length;do{if(E=T[D],L=T.substring(0,D),E?E.match(c)&&(L+=E):L+="string"==typeof c?c:" ",L+=N,h.data=L,a.getComputedTextLength()<=o){m[k]=L;break}}while(0<=--D);break}}}return n.svgDocument?e.removeChild(l):document.body.removeChild(e),m.join(u)}function Oe(t){return(t=w(w.parseHTML("<div>"+t+"</div>",null,!1))).find("*").each(function(){var i=this;w.each(i.attributes,function(){var t=this.name,e=this.value;(t.startsWith("on")||e.startsWith("javascript:")||e.startsWith("data:")||e.startsWith("vbscript:"))&&w(i).removeAttr(t)})}),t.html()}function Re(t,e){var i;window.navigator.msSaveBlob?window.navigator.msSaveBlob(t,e):(t=window.URL.createObjectURL(t),(i=document.createElement("a")).href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(t))}function Ve(t,e){t=je(t),Re(t,e)}function je(t){t=t.replace(/\s/g,"");for(var e=(t=decodeURIComponent(t)).indexOf(","),i=t.slice(0,e),n=i.split(":")[1].split(";")[0],t=t.slice(e+1),r=0<=i.indexOf("base64")?atob(t):unescape(encodeURIComponent(t)),o=new Uint8Array(r.length),s=0;s<r.length;s++)o[s]=r.charCodeAt(s);return new Blob([o],{type:n})}function _e(n,r){if(!n||"data:"===n.substr(0,"data:".length))return setTimeout(function(){r(null,n)},0);function o(t,e){var i;200===t.status?(t=new Uint8Array(t.response),e(null,"data:image/"+({svg:"svg+xml"}[i=n.split(".").pop()||"png"]||i)+";base64,"+btoa(function(t){for(var e=[],i=0;i<t.length;i+=32768)e.push(String.fromCharCode.apply(null,t.subarray(i,i+32768)));return e.join("")}(t)))):e(new Error("Failed to load image "+n))}var s=new XMLHttpRequest;s.open("GET",n,!0),s.addEventListener("error",function(){r(new Error("Failed to load image "+n))}),s.responseType=window.FileReader?"blob":"arraybuffer",s.addEventListener("load",function(){var t,e,i;window.FileReader?(e=r,200===(t=s).status?((i=new FileReader).onload=function(t){t=t.target.result;e(null,t)},i.onerror=function(){e(new Error("Failed to load image "+n))},i.readAsDataURL(t.response)):e(new Error("Failed to load image "+n))):o(s,r)}),s.send()}function Ze(t){if(0===(t=w(t)).length)throw new Error("Element not found");var e=(t=t[0]).ownerDocument,i=t.getBoundingClientRect(),n=0,r=0;return t.ownerSVGElement&&(t=(t=B(t)).getBBox({target:t.svg()}),n=i.width-t.width,r=i.height-t.height),{x:i.left+window.pageXOffset-e.documentElement.offsetLeft+n/2,y:i.top+window.pageYOffset-e.documentElement.offsetTop+r/2,width:i.width-n,height:i.height-r}}function Ye(t,e){var i=(t=w(t)).map(function(){var t=this.parentNode,e=t.insertBefore(document.createTextNode(""),this.nextSibling);return function(){if(t===this)throw new Error("You can't sort elements if any one is a descendant of another.");t.insertBefore(this,e),t.removeChild(e)}});return Array.prototype.sort.call(t,e).each(function(t){i[t].call(this)})}function We(t,e){var i=w(t);k(e,function(t,e){e=i.find(e).addBack().filter(e);xi(t,"class")&&(e.addClass(t.class),t=Si(t,"class")),e.attr(t)})}function Fe(t){var e=window.top.document;function i(t,e){for(var i=["webkit","moz","ms","o",""],n=0;n<i.length;n++){var r=i[n],r=r?r+e:e.substr(0,1).toLowerCase()+e.substr(1);if(void 0!==t[r])return P(t[r])?t[r]():t[r]}}t=t||e.body,i(e,"FullscreenElement")||i(e,"FullScreenElement")?i(e,"ExitFullscreen")||i(e,"CancelFullScreen"):i(t,"RequestFullscreen")||i(t,"RequestFullScreen")}function y(){var t,e,n;return i.mergeWith?(e=(t=Array.from(arguments))[t.length-1],n=P(e)?e:He,t.push(function(t,e){var i=n(t,e);return void 0!==i?i:Array.isArray(t)&&!Array.isArray(e)?e:void 0}),i.mergeWith.apply(this,t)):i.merge.apply(this,arguments)}function Ue(t){var e=Object.prototype.toString;return!0===t||!1===t||!!t&&"object"==typeof t&&"[object Boolean]"===e.call(t)}function x(t){return!!t&&("object"==typeof t||"function"==typeof t)}function He(){}var Xe,Je,$e={intersection:{exists:function t(e,i,n,r){switch(e.type){case s.Line:if(i.type===s.Line)return Xt(e,i);break;case s.Ellipse:switch(i.type){case s.Line:return Jt(e,i);case s.Ellipse:return $t(e,i)}break;case s.Rect:switch(i.type){case s.Line:return Qt(e,i);case s.Ellipse:return Kt(e,i);case s.Rect:return qt(e,i)}break;case s.Polyline:switch(i.type){case s.Line:return te(e,i);case s.Ellipse:return ee(e,i);case s.Rect:return ie(e,i);case s.Polyline:return ne(e,i)}break;case s.Polygon:switch(i.type){case s.Line:return re(e,i);case s.Ellipse:return oe(e,i);case s.Rect:return se(e,i);case s.Polyline:return ae(e,i);case s.Polygon:return le(e,i)}break;case s.Path:switch(i.type){case s.Line:return he(e,i,n);case s.Ellipse:return ce(e,i,n);case s.Rect:return ue(e,i,n);case s.Polyline:return de(e,i,n);case s.Polygon:return ge(e,i,n);case s.Path:return pe(e,i,n,r)}}switch(i.type){case s.Ellipse:case s.Rect:case s.Polyline:case s.Polygon:case s.Path:return t(i,e,r,n);default:throw Error("The intersection for "+e+" and "+i+" could not be found.")}},lineWithLine:Xt,ellipseWithLine:Jt,ellipseWithEllipse:$t,rectWithLine:Qt,rectWithEllipse:Kt,rectWithRect:qt,polylineWithLine:te,polylineWithEllipse:ee,polylineWithRect:ie,polylineWithPolyline:ne,polygonWithLine:re,polygonWithEllipse:oe,polygonWithRect:se,polygonWithPolyline:ae,polygonWithPolygon:le,pathWithLine:he,pathWithEllipse:ce,pathWithRect:ue,pathWithPolyline:de,pathWithPolygon:ge,pathWithPath:pe},scale:J,normalizeAngle:Q,snapToGrid:E,toDeg:V,toRad:K,random:D,bezier:Ut,Curve:d,Ellipse:wt,ellipse:At,Line:C,line:mt,Path:O,Point:z,point:A,Polyline:v,Polygon:Ht,Rect:tt,rect:Nt,types:s},B=function(){if(!("object"==typeof window&&!(!window.SVGAngle&&!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1"))))return function(){throw new Error("SVG is required to use Vectorizer.")};function T(t,e,i){if(!(this instanceof T))return T.apply(Object.create(T.prototype),arguments);if(t){if(T.isV(t)&&(t=t.node),e=e||{},T.isString(t)){if("svg"===(t=t.trim()).toLowerCase())t=T.createSvgDocument();else if("<"===t[0]){var n=T.createSvgDocument(t);if(1<n.childNodes.length){for(var r=[],o=0,s=n.childNodes.length;o<s;o++){var a=n.childNodes[o];r.push(new T(document.importNode(a,!0)))}return r}t=document.importNode(n.firstChild,!0)}else t=document.createElementNS(L.svg,t);T.ensureId(t)}return this.node=t,this.setAttributes(e),i&&this.append(i),this}}var L={svg:"http://www.w3.org/2000/svg",xmlns:"http://www.w3.org/2000/xmlns/",xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xhtml:"http://www.w3.org/1999/xhtml"},t=Math,h=t.PI,n=t.atan2,o=t.sqrt,l=t.min,a=t.max,c=t.cos,u=t.sin,t=T.prototype;Object.defineProperty(t,"id",{enumerable:!0,get:function(){return this.node.id},set:function(t){this.node.id=t}}),t.getTransformToElement=function(t){var e=this.node;if(T.isSVGGraphicsElement(t)&&T.isSVGGraphicsElement(e)){t=T.toNode(t).getScreenCTM(),e=e.getScreenCTM();if(t&&e)return t.inverse().multiply(e)}return T.createSVGMatrix()},t.transform=function(t,e){var i=this.node;if(T.isUndefined(t))return T.transformStringToMatrix(this.attr("transform"));if(e&&e.absolute)return this.attr("transform",T.matrixToTransformString(t));e=T.createSVGTransform(t);return i.transform.baseVal.appendItem(e),this},t.translate=function(t,e,i){i=i||{},e=e||0;var n=this.attr("transform")||"",r=T.parseTransformString(n),n=r.value;if(T.isUndefined(t))return r.translate;n=n.replace(/translate\([^)]*\)/g,"").trim();t=i.absolute?t:r.translate.tx+t,i=i.absolute?e:r.translate.ty+e;return this.attr("transform",("translate("+t+","+i+")"+" "+n).trim()),this},t.rotate=function(t,e,i,n){n=n||{};var r=this.attr("transform")||"",o=T.parseTransformString(r),r=o.value;if(T.isUndefined(t))return o.rotate;r=r.replace(/rotate\([^)]*\)/g,"").trim(),t%=360;n=n.absolute?t:o.rotate.angle+t;return this.attr("transform",(r+" "+("rotate("+n+(void 0!==e&&void 0!==i?","+e+","+i:"")+")")).trim()),this},t.scale=function(t,e){e=T.isUndefined(e)?t:e;var i=this.attr("transform")||"",n=T.parseTransformString(i),i=n.value;return T.isUndefined(t)?n.scale:(i=i.replace(/scale\([^)]*\)/g,"").trim(),this.attr("transform",(i+" "+("scale("+t+","+e+")")).trim()),this)},t.bbox=function(t,e){var i,n=this.node,r=n.ownerSVGElement;if(!r)return new tt(0,0,0,0);try{i=n.getBBox()}catch(t){i={x:n.clientLeft,y:n.clientTop,width:n.clientWidth,height:n.clientHeight}}if(t)return new tt(i);n=this.getTransformToElement(e||r);return T.transformRect(i,n)},t.getBBox=function(t){var e={},i=this.node;if(!i.ownerSVGElement||!T.isSVGGraphicsElement(i))return new tt(0,0,0,0);if(t&&(t.target&&(e.target=T.toNode(t.target)),t.recursive&&(e.recursive=t.recursive)),e.recursive){var n=this.children(),r=n.length;if(0===r)return this.getBBox({target:e.target,recursive:!1});e.target||(e.target=this);for(var o=0;o<r;o++)var s=n[o],s=0===s.children().length?s.getBBox({target:e.target,recursive:!1}):s.getBBox({target:e.target,recursive:!0}),a=a?a.union(s):s;return a}try{a=i.getBBox()}catch(t){a={x:i.clientLeft,y:i.clientTop,width:i.clientWidth,height:i.clientHeight}}return e.target?(t=this.getTransformToElement(e.target),T.transformRect(a,t)):new tt(a)};var E=/em$/;function D(t,e){var i=parseFloat(t);return E.test(t)?i*e:i}t.text=function(t,e){if(t&&"string"!=typeof t)throw new Error("Vectorizer: text() expects the first argument to be a string.");t=T.sanitizeText(t);for(var i,n,r,o,s=(e=e||{}).displayEmpty,a=e.eol,l=e.textPath,h=e.textVerticalAnchor,c="middle"===h||"bottom"===h||"top"===h,u=e.x,d=(void 0===u&&(u=this.attr("x")||0),e.includeAnnotationIndices),g=e.annotations,e=(g&&!T.isArray(g)&&(g=[g]),e.lineHeight),p="auto"===e,f=p?"1.5em":e||"1em",m=(this.empty(),this.attr({"xml:space":"preserve",display:t||s?null:"none"}),parseFloat(this.attr("font-size"))),v=(m||(m=16,(c||g)&&this.attr("font-size",m)),document),y=l?(e=this,s=(s=l="string"==typeof l?{d:l}:l)||{},i=T("textPath"),(n=s.d)&&void 0===s["xlink:href"]&&(n=T("path").attr("d",n).appendTo(e.defs()),i.attr("xlink:href","#"+n.id)),T.isObject(s)&&i.attr(s),i.node):v.createDocumentFragment(),b=0,w=t.split("\n"),A=[],C=0,I=w.length-1;C<=I;C++){var x,S,P=f,M="v-line",k=v.createElementNS(L.svg,"tspan"),N=w[C];N?g?((S=(x=function(t,e,i){for(var n=(i=i||{}).includeAnnotationIndices,r=i.eol,o=i.lineHeight,s=i.baseSize,a=0,i={},l=e.length-1,h=0;h<=l;h++){var c,u,d,g,p=e[h],f=null;T.isObject(p)?(c=p.attrs,d=(u=T("tspan",c)).node,g=p.t,r&&h===l&&(g+=r),d.textContent=g,(g=c.class)&&u.addClass(g),n&&u.attr("annotations",p.annotations),f=parseFloat(c["font-size"]),(f=isFinite(f)?f:s)&&a<f&&(a=f)):(r&&h===l&&(p+=r),d=document.createTextNode(p||" "),s&&a<s&&(a=s)),t.appendChild(d)}return a&&(i.maxFontSize=a),o?i.lineHeight=o:a&&(i.lineHeight=1.2*a),i}(k,T.annotateString(N,g,{offset:-b,includeAnnotationIndices:d}),{includeAnnotationIndices:d,eol:C!==I&&a,lineHeight:p?null:f,baseSize:m})).lineHeight)&&p&&0!==C&&(P=S),0===C&&(r=.8*x.maxFontSize)):(a&&C!==I&&(N+=a),k.textContent=N):(k.textContent="-",M+=" v-empty-line",(S=k.style).fillOpacity=0,S.strokeOpacity=0,g&&(x={})),x&&A.push(x),0<C&&k.setAttribute("dy",P),(0<C||l)&&k.setAttribute("x",u),k.className.baseVal=M,y.appendChild(k),b+=N.length+1}if(c)if(g)P=function(t,e,i,n){if(!Array.isArray(e))return 0;var r=e.length;if(!r)return 0;for(var o=e[0],s=D(o.maxFontSize,i)||i,a=0,l=D(n,i),h=1;h<r;h++)a+=D((o=e[h]).lineHeight,i)||l;var c,u=D(o.maxFontSize,i)||i;switch(t){case"middle":c=s/2-.15*u-a/2;break;case"bottom":c=-.25*u-a;break;default:c=.8*s}return c}(h,A,m,f);else if("top"===h)P="0.8em";else switch(0<I?(o=parseFloat(f)||1,o*=I,E.test(f)||(o/=m)):o=0,h){case"middle":P=.3-o/2+"em";break;case"bottom":P=-o-.3+"em"}else 0===h?P="0em":h?P=h:(P=0,null===this.attr("y")&&this.attr("y",r||"0.8em"));return y.firstChild.setAttribute("dy",P),this.append(y),this},t.removeAttr=function(t){var e=T.qualifyAttr(t),i=this.node;return e.ns?i.hasAttributeNS(e.ns,e.local)&&i.removeAttributeNS(e.ns,e.local):i.hasAttribute(t)&&i.removeAttribute(t),this},t.attr=function(t,e){if(T.isUndefined(t)){for(var i=this.node.attributes,n={},r=0;r<i.length;r++)n[i[r].name]=i[r].value;return n}if(T.isString(t)&&T.isUndefined(e))return this.node.getAttribute(t);if("object"==typeof t)for(var o in t)t.hasOwnProperty(o)&&this.setAttribute(o,t[o]);else this.setAttribute(t,e);return this},t.normalizePath=function(){return"PATH"===this.tagName()&&this.attr("d",T.normalizePathData(this.attr("d"))),this},t.remove=function(){return this.node.parentNode&&this.node.parentNode.removeChild(this.node),this},t.empty=function(){for(;this.node.firstChild;)this.node.removeChild(this.node.firstChild);return this},t.setAttributes=function(t){for(var e in t)t.hasOwnProperty(e)&&this.setAttribute(e,t[e]);return this},t.append=function(t){for(var e=0,i=(t=T.isArray(t)?t:[t]).length;e<i;e++)this.node.appendChild(T.toNode(t[e]));return this},t.prepend=function(t){var e=this.node.firstChild;return e?T(e).before(t):this.append(t)},t.before=function(t){var e=this.node,i=e.parentNode;if(i)for(var n=0,r=(t=T.isArray(t)?t:[t]).length;n<r;n++)i.insertBefore(T.toNode(t[n]),e);return this},t.appendTo=function(t){return T.toNode(t).appendChild(this.node),this},t.svg=function(){return this.node instanceof window.SVGSVGElement?this:T(this.node.ownerSVGElement)},t.tagName=function(){return this.node.tagName.toUpperCase()},t.defs=function(){var t=this.svg()||this,e=t.node.getElementsByTagName("defs")[0];return e?T(e):T("defs").appendTo(t)},t.clone=function(){var t=T(this.node.cloneNode(!0));return t.node.id=T.uniqueId(),t},t.findOne=function(t){t=this.node.querySelector(t);return t?T(t):void 0},t.find=function(t){var e=[],i=this.node.querySelectorAll(t);if(i)for(var n=0;n<i.length;n++)e.push(T(i[n]));return e},t.children=function(){for(var t=this.node.childNodes,e=[],i=0;i<t.length;i++)1===t[i].nodeType&&e.push(T(t[i]));return e},t.parent=function(){return T(this.node.parentNode)||null},t.index=function(){for(var t=0,e=this.node.previousSibling;e;)1===e.nodeType&&t++,e=e.previousSibling;return t},t.findParentByClass=function(t,e){for(var i=this.node.ownerSVGElement,n=this.node.parentNode;n&&n!==e&&n!==i;){var r=T(n);if(r.hasClass(t))return r;n=n.parentNode}return null},t.contains=function(t){var e=this.node,t=T.toNode(t),t=t&&t.parentNode;return e===t||!!(t&&1===t.nodeType&&16&e.compareDocumentPosition(t))},t.toLocalPoint=function(t,e){var i=this.svg().node,n=i.createSVGPoint();n.x=t,n.y=e;try{var r=n.matrixTransform(i.getScreenCTM().inverse()),o=this.getTransformToElement(i).inverse()}catch(t){return n}return r.matrixTransform(o)},t.translateCenterToPoint=function(t){var e=this.getBBox({target:this.svg()}).center();return this.translate(t.x-e.x,t.y-e.y),this},t.translateAndAutoOrient=function(t,e,i){t=new z(t),e=new z(e),i=i||this.svg();var n=this.scale(),r=(this.attr("transform",""),this.getBBox({target:i}).scale(n.sx,n.sy)),o=T.createSVGTransform(),s=(o.setTranslate(-r.x-r.width/2,-r.y-r.height/2),T.createSVGTransform()),a=t.angleBetween(e,t.clone().offset(1,0)),a=(a&&s.setRotate(a,0,0),T.createSVGTransform()),e=t.clone().move(e,r.width/2),r=(a.setTranslate(2*t.x-e.x,2*t.y-e.y),this.getTransformToElement(i)),t=T.createSVGTransform();return t.setMatrix(a.matrix.multiply(s.matrix.multiply(o.matrix.multiply(r.scale(n.sx,n.sy))))),this.attr("transform",T.matrixToTransformString(t.matrix)),this},t.animateAlongPath=function(e,i){i=T.toNode(i);i=T.ensureId(i),e=T("animateMotion",e),i=T("mpath",{"xlink:href":"#"+i});e.append(i),this.append(e);try{e.node.beginElement()}catch(t){if("fake"===document.documentElement.getAttribute("smiling"))for(var n=e.node,i=(n.animators=[],n.getAttribute("id")),r=(i&&(id2anim[i]=n),getTargets(n)),o=0,s=r.length;o<s;o++){var a=r[o],a=new Animator(n,a,o);animators.push(a),(n.animators[o]=a).register()}}return this},t.hasClass=function(t){return new RegExp("(\\s|^)"+t+"(\\s|$)").test(this.node.getAttribute("class"))},t.addClass=function(t){var e;return t&&!this.hasClass(t)&&(e=this.node.getAttribute("class")||"",this.node.setAttribute("class",(e+" "+t).trim())),this},t.removeClass=function(t){return t&&this.hasClass(t)&&(t=this.node.getAttribute("class").replace(new RegExp("(\\s|^)"+t+"(\\s|$)","g"),"$2"),this.node.setAttribute("class",t)),this},t.toggleClass=function(t,e){return(T.isUndefined(e)?this.hasClass(t):!e)?this.removeClass(t):this.addClass(t),this},t.sample=function(t){t=t||1;for(var e,i=this.node,n=i.getTotalLength(),r=[],o=0;o<n;)e=i.getPointAtLength(o),r.push({x:e.x,y:e.y,distance:o}),o+=t;return r},t.convertToPath=function(){var t=T("path"),e=(t.attr(this.attr()),this.convertToPathData());return e&&t.attr("d",e),t},t.convertToPathData=function(){var t=this.tagName();switch(t){case"PATH":return this.attr("d");case"LINE":return T.convertLineToPathData(this.node);case"POLYGON":return T.convertPolygonToPathData(this.node);case"POLYLINE":return T.convertPolylineToPathData(this.node);case"ELLIPSE":return T.convertEllipseToPathData(this.node);case"CIRCLE":return T.convertCircleToPathData(this.node);case"RECT":return T.convertRectToPathData(this.node)}throw new Error(t+" cannot be converted to PATH.")},T.prototype.toGeometryShape=function(){var t,e,i,n,r,o,s;switch(this.tagName()){case"RECT":return n=parseFloat(this.attr("x"))||0,s=parseFloat(this.attr("y"))||0,t=parseFloat(this.attr("width"))||0,i=parseFloat(this.attr("height"))||0,new tt(n,s,t,i);case"CIRCLE":return o=parseFloat(this.attr("cx"))||0,r=parseFloat(this.attr("cy"))||0,n=parseFloat(this.attr("r"))||0,new wt({x:o,y:r},n,n);case"ELLIPSE":return o=parseFloat(this.attr("cx"))||0,r=parseFloat(this.attr("cy"))||0,s=parseFloat(this.attr("rx"))||0,t=parseFloat(this.attr("ry"))||0,new wt({x:o,y:r},s,t);case"POLYLINE":return e=T.getPointsFromSvgNode(this),new v(e);case"POLYGON":return 1<(e=T.getPointsFromSvgNode(this)).length&&e.push(e[0]),new v(e);case"PATH":return i=this.attr("d"),O.isDataSupported(i)||(i=T.normalizePathData(i)),new O(i);case"LINE":return n=parseFloat(this.attr("x1"))||0,o=parseFloat(this.attr("y1"))||0,r=parseFloat(this.attr("x2"))||0,s=parseFloat(this.attr("y2"))||0,new C({x:n,y:o},{x:r,y:s})}return this.getBBox()},t.findIntersection=function(t,e){var i=this.svg().node,n=this.getBBox({target:e=e||i}),r=n.center();if(n.intersectionWithLineFromCenterToPoint(t)){n=this.tagName();if("RECT"===n)var o=new tt(parseFloat(this.attr("x")||0),parseFloat(this.attr("y")||0),parseFloat(this.attr("width")),parseFloat(this.attr("height"))),s=this.getTransformToElement(e),a=T.decomposeMatrix(s),i=i.createSVGTransform(),o=(i.setRotate(-a.rotation,r.x,r.y),T.transformRect(o,i.matrix.multiply(s))),s=new tt(o).intersectionWithLineFromCenterToPoint(t,a.rotation);else if("PATH"===n||"POLYGON"===n||"POLYLINE"===n||"CIRCLE"===n||"ELLIPSE"===n){for(var l,h,c,u=("PATH"===n?this:this.convertToPath()).sample(),d=1/0,g=[],p=0;p<u.length;p++)l=u[p],h=(h=T.createSVGPoint(l.x,l.y)).matrixTransform(this.getTransformToElement(e)),(c=(l=new z(h)).distance(r)+(h=1.1*l.distance(t)))<d?(d=c,g=[{sample:l,refDistance:h}]):c<d+1&&g.push({sample:l,refDistance:h});g.sort(function(t,e){return t.refDistance-e.refDistance}),g[0]&&(s=g[0].sample)}return s}},t.setAttribute=function(t,e){var i=this.node;if(null===e)return this.removeAttr(t),this;var n=T.qualifyAttr(t);return n.ns?i.setAttributeNS(n.ns,t,e):"id"===t?i.id=e:i.setAttribute(t,e),this},T.createSvgDocument=function(t){if(t)return T.parseXML('<svg xmlns="'+L.svg+'" xmlns:xlink="'+L.xlink+'" version="1.1">'+t+"</svg>",{async:!1}).documentElement;t=document.createElementNS(L.svg,"svg");return t.setAttributeNS(L.xmlns,"xmlns:xlink",L.xlink),t.setAttribute("version","1.1"),t},T.createSVGStyle=function(t){return T("style",{type:"text/css"},[T.createCDATASection(t)]).node},T.createCDATASection=function(t){return void 0===t&&(t=""),document.implementation.createDocument(null,"xml",null).createCDATASection(t)},T.idCounter=0,T.uniqueId=function(){return"v-"+ ++T.idCounter},T.toNode=function(t){return T.isV(t)?t.node:t.nodeName&&t||t[0]},T.ensureId=function(t){return(t=T.toNode(t)).id||(t.id=T.uniqueId())},T.sanitizeText=function(t){return(t||"").replace(/ /g,"\xa0")},T.isUndefined=function(t){return void 0===t},T.isString=function(t){return"string"==typeof t},T.isObject=function(t){return t&&"object"==typeof t},T.isArray=Array.isArray,T.parseXML=function(t,e){var i;e=e||{};try{var n=new DOMParser;T.isUndefined(e.async)||(n.async=e.async),i=n.parseFromString(t,"text/xml")}catch(t){i=void 0}if(!i||i.getElementsByTagName("parsererror").length)throw new Error("Invalid XML: "+t);return i},T.qualifyAttr=function(t){var e;return-1!==t.indexOf(":")?(e=t.split(":"),{ns:L[e[0]],local:e[1]}):{ns:null,local:t}},T.transformRegex=/(\w+)\(([^,)]+),?([^)]+)?\)/gi,T.transformSeparatorRegex=/[ ,]+/,T.transformationListRegex=/^(\w+)\((.*)\)/,T.transformStringToMatrix=function(t){var e=T.createSVGMatrix(),i=t&&t.match(T.transformRegex);if(!i)return e;for(var n=0,r=i.length;n<r;n++){var o=i[n].match(T.transformationListRegex);if(o){var s,a,l,h,c,u=T.createSVGMatrix(),d=o[2].split(T.transformSeparatorRegex);switch(o[1].toLowerCase()){case"scale":s=parseFloat(d[0]),a=void 0===d[1]?s:parseFloat(d[1]),u=u.scaleNonUniform(s,a);break;case"translate":l=parseFloat(d[0]),h=parseFloat(d[1]),u=u.translate(l,h);break;case"rotate":c=parseFloat(d[0]),l=parseFloat(d[1])||0,h=parseFloat(d[2])||0,u=0!==l||0!==h?u.translate(l,h).rotate(c).translate(-l,-h):u.rotate(c);break;case"skewx":c=parseFloat(d[0]),u=u.skewX(c);break;case"skewy":c=parseFloat(d[0]),u=u.skewY(c);break;case"matrix":u.a=parseFloat(d[0]),u.b=parseFloat(d[1]),u.c=parseFloat(d[2]),u.d=parseFloat(d[3]),u.e=parseFloat(d[4]),u.f=parseFloat(d[5]);break;default:continue}e=e.multiply(u)}}return e},T.matrixToTransformString=function(t){return"matrix("+(void 0!==(t=t||!0).a?t.a:1)+","+(void 0!==t.b?t.b:0)+","+(void 0!==t.c?t.c:0)+","+(void 0!==t.d?t.d:1)+","+(void 0!==t.e?t.e:0)+","+(void 0!==t.f?t.f:0)+")"},T.parseTransformString=function(t){t&&(e=T.transformSeparatorRegex,0<=t.trim().indexOf("matrix")?(r=T.transformStringToMatrix(t),i=[(r=T.decomposeMatrix(r)).translateX,r.translateY],n=[r.scaleX,r.scaleY],r=[r.rotation],o=[],0===i[0]&&0===i[1]||o.push("translate("+i+")"),1===n[0]&&1===n[1]||o.push("scale("+n+")"),0!==r[0]&&o.push("rotate("+r+")"),t=o.join(" ")):((o=t.match(/translate\((.*?)\)/))&&(i=o[1].split(e)),(o=t.match(/rotate\((.*?)\)/))&&(r=o[1].split(e)),(o=t.match(/scale\((.*?)\)/))&&(n=o[1].split(e))));var e,i,n,r,o=n&&n[0]?parseFloat(n[0]):1;return{value:t,translate:{tx:i&&i[0]?parseInt(i[0],10):0,ty:i&&i[1]?parseInt(i[1],10):0},rotate:{angle:r&&r[0]?parseInt(r[0],10):0,cx:r&&r[1]?parseInt(r[1],10):void 0,cy:r&&r[2]?parseInt(r[2],10):void 0},scale:{sx:o,sy:n&&n[1]?parseFloat(n[1]):o}}},T.deltaTransformPoint=function(t,e){return{x:e.x*t.a+e.y*t.c,y:e.x*t.b+e.y*t.d}},T.decomposeMatrix=function(t){var e=T.deltaTransformPoint(t,{x:0,y:1}),i=T.deltaTransformPoint(t,{x:1,y:0}),e=180/h*n(e.y,e.x)-90,i=180/h*n(i.y,i.x);return{translateX:t.e,translateY:t.f,scaleX:o(t.a*t.a+t.b*t.b),scaleY:o(t.c*t.c+t.d*t.d),skewX:e,skewY:i,rotation:e}},T.matrixToScale=function(t){var e,i,n,r;return t?(e=T.isUndefined(t.a)?1:t.a,r=T.isUndefined(t.d)?1:t.d,i=t.b,n=t.c):e=r=1,{sx:i?o(e*e+i*i):e,sy:n?o(n*n+r*r):r}},T.matrixToRotate=function(t){var e={x:0,y:1};return t&&(e=T.deltaTransformPoint(t,e)),{angle:Q(V(n(e.y,e.x))-90)}},T.matrixToTranslate=function(t){return{tx:t&&t.e||0,ty:t&&t.f||0}},T.isVElement=T.isV=function(t){return t instanceof T},T.isSVGGraphicsElement=function(t){return!!t&&((t=T.toNode(t))instanceof SVGElement&&"function"==typeof t.getScreenCTM)};var f,m,I,x,S,P,M,k,N,d=T("svg").node;function g(t,e,i,n,r,o){return[1/3*t+2/3*i,1/3*e+2/3*n,1/3*r+2/3*i,1/3*o+2/3*n,r,o]}function B(t,e,i){return{x:t*S(i)-e*x(i),y:t*x(i)+e*S(i)}}function G(t,e,i,n,r,o,s,a,l,h){var c=120*I/180,u=I/180*(+r||0),d=[],o=(h?(y=h[0],b=h[1],m=h[2],v=h[3]):(t=(f=B(t,e,-u)).x,e=f.y,1<(g=(p=(t-(a=(f=B(a,l,-u)).x))/2)*p/(i*i)+(f=(e-(l=f.y))/2)*f/(n*n))&&(i*=g=k(g),n*=g),m=(g=(o==s?-1:1)*k(N(((g=i*i)*(o=n*n)-g*f*f-o*p*p)/(g*f*f+o*p*p))))*i*f/n+(t+a)/2,y=M(((e-(v=g*-n*p/i+(e+l)/2))/n).toFixed(9)),b=M(((l-v)/n).toFixed(9)),(y=t<m?I-y:y)<0&&(y=2*I+y),(b=a<m?I-b:b)<0&&(b=2*I+b),s&&b<y&&(y-=2*I),!s&&y<b&&(b-=2*I)),b-y),c=(N(o)>c&&(f=b,g=a,p=l,d=G(a=m+i*S(b=y+c*(s&&y<b?1:-1)),l=v+n*x(b),i,n,r,0,s,g,p,[b,f,m,v])),o=b-y,S(y)),r=x(y),s=S(b),g=x(b),p=P(o/4),f=4/3*(i*p),m=4/3*(n*p),v=[t,e],y=[t+f*r,e-m*c],b=[a+f*g,l-m*s],o=[a,l];if(y[0]=2*v[0]-y[0],y[1]=2*v[1]-y[1],h)return[y,b,o].concat(d);for(var w=[],A=(d=[y,b,o].concat(d).join().split(",")).length,C=0;C<A;C++)w[C]=C%2?B(d[C-1],d[C],u).y:B(d[C],d[C+1],u).x;return w}function p(t){if(!(t=Array.isArray(t)&&Array.isArray(t&&t[0])?t:function(t){if(!t)return null;var o={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},s=[];return String(t).replace(f,function(t,e,i){var n=[],r=e.toLowerCase();for(i.replace(m,function(t,e){e&&n.push(+e)}),"m"===r&&2<n.length&&(s.push([e].concat(n.splice(0,2))),r="l",e="m"===e?"l":"L");n.length>=o[r]&&(s.push([e].concat(n.splice(0,o[r]))),o[r]););}),s}(t))||!t.length)return[["M",0,0]];for(var e=[],i=0,n=0,r=0,o=0,s=t.length,a=0;a<s;a++){var l,h,c=[],u=(e.push(c),t[a]),d=u[0];if(d!=d.toUpperCase())switch(c[0]=d.toUpperCase(),c[0]){case"A":c[1]=u[1],c[2]=u[2],c[3]=u[3],c[4]=u[4],c[5]=u[5],c[6]=+u[6]+i,c[7]=+u[7]+n;break;case"V":c[1]=+u[1]+n;break;case"H":c[1]=+u[1]+i;break;case"M":for(r=+u[1]+i,o=+u[2]+n,l=u.length,h=1;h<l;h++)c[h]=+u[h]+(h%2?i:n);break;default:for(l=u.length,h=1;h<l;h++)c[h]=+u[h]+(h%2?i:n)}else for(var g=u.length,p=0;p<g;p++)c[p]=u[p];switch(c[0]){case"Z":i=+r,n=+o;break;case"H":i=c[1];break;case"V":n=c[1];break;case"M":r=c[c.length-2],o=c[c.length-1],i=c[c.length-2],n=c[c.length-1];break;default:i=c[c.length-2],n=c[c.length-1]}}return e}function e(t){var e=p(t),i={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null};for(var n=[],r="",o="",s=e.length,a=0;a<s;a++){"C"!==(r=e[a]?e[a][0]:r)&&(n[a]=r,0<a&&(o=n[a-1])),e[a]=function(t,e,i){var n,r;if(!t)return["C",e.x,e.y,e.x,e.y,e.x,e.y];switch(t[0]in{T:1,Q:1}||(e.qx=null,e.qy=null),t[0]){case"M":e.X=t[1],e.Y=t[2];break;case"A":t=0===parseFloat(t[1])||0===parseFloat(t[2])?["L",t[6],t[7]]:["C"].concat(G.apply(0,[e.x,e.y].concat(t.slice(1))));break;case"S":r="C"===i||"S"===i?(n=2*e.x-e.bx,2*e.y-e.by):(n=e.x,e.y),t=["C",n,r].concat(t.slice(1));break;case"T":"Q"===i||"T"===i?(e.qx=2*e.x-e.qx,e.qy=2*e.y-e.qy):(e.qx=e.x,e.qy=e.y),t=["C"].concat(g(e.x,e.y,e.qx,e.qy,t[1],t[2]));break;case"Q":e.qx=t[1],e.qy=t[2],t=["C"].concat(g(e.x,e.y,t[1],t[2],t[3],t[4]));break;case"H":t=["L"].concat(t[1],e.y);break;case"V":t=["L"].concat(e.x,t[1])}return t}(e[a],i,o),"A"!==n[a]&&"C"===r&&(n[a]="C"),c=h=l=void 0;var l=e,h=a;if(7<l[h].length){l[h].shift();for(var c=l[h];c.length;)n[h]="A",l.splice(h++,0,["C"].concat(c.splice(0,6)));l.splice(h,1),s=e.length}var u=e[a],d=u.length;i.x=u[d-2],i.y=u[d-1],i.bx=parseFloat(u[d-4])||i.x,i.by=parseFloat(u[d-3])||i.y}return e[0][0]&&"M"===e[0][0]||e.unshift(["M",0,0]),e}return T.createSVGMatrix=function(t){var e,i=d.createSVGMatrix();for(e in t)i[e]=t[e];return i},T.createSVGTransform=function(t){return T.isUndefined(t)?d.createSVGTransform():(t instanceof SVGMatrix||(t=T.createSVGMatrix(t)),d.createSVGTransformFromMatrix(t))},T.createSVGPoint=function(t,e){var i=d.createSVGPoint();return i.x=t,i.y=e,i},T.transformRect=function(t,e){var i=d.createSVGPoint(),n=(i.x=t.x,i.y=t.y,i.matrixTransform(e)),r=(i.x=t.x+t.width,i.y=t.y,i.matrixTransform(e)),o=(i.x=t.x+t.width,i.y=t.y+t.height,i.matrixTransform(e)),t=(i.x=t.x,i.y=t.y+t.height,i.matrixTransform(e)),i=l(n.x,r.x,o.x,t.x),e=a(n.x,r.x,o.x,t.x),s=l(n.y,r.y,o.y,t.y),n=a(n.y,r.y,o.y,t.y);return new tt(i,s,e-i,n-s)},T.transformPoint=function(t,e){return new z(T.createSVGPoint(t.x,t.y).matrixTransform(e))},T.transformLine=function(t,e){return new C(T.transformPoint(t.start,e),T.transformPoint(t.end,e))},T.transformPolyline=function(t,e){for(var i=t instanceof v?t.points:t,n=[],r=0,o=(i=T.isArray(i)?i:[]).length;r<o;r++)n[r]=T.transformPoint(i[r],e);return new v(n)},T.styleToObject=function(t){for(var e={},i=t.split(";"),n=0;n<i.length;n++){var r=i[n].split("=");e[r[0].trim()]=r[1].trim()}return e},T.createSlicePathData=function(t,e,i,n){var r=2*h-1e-6,o=(n<i&&(o=i,i=n,n=o),n-i),s=o<h?"0":"1",a=c(i),i=u(i),l=c(n),n=u(n);return r<=o?t?"M0,"+e+"A"+e+","+e+" 0 1,1 0,"+-e+"A"+e+","+e+" 0 1,1 0,"+e+"M0,"+t+"A"+t+","+t+" 0 1,0 0,"+-t+"A"+t+","+t+" 0 1,0 0,"+t+"Z":"M0,"+e+"A"+e+","+e+" 0 1,1 0,"+-e+"A"+e+","+e+" 0 1,1 0,"+e+"Z":t?"M"+e*a+","+e*i+"A"+e+","+e+" 0 "+s+",1 "+e*l+","+e*n+"L"+t*l+","+t*n+"A"+t+","+t+" 0 "+s+",0 "+t*a+","+t*i+"Z":"M"+e*a+","+e*i+"A"+e+","+e+" 0 "+s+",1 "+e*l+","+e*n+"L0,0Z"},T.mergeAttrs=function(t,e){for(var i in e)"class"===i?t[i]=t[i]?t[i]+" "+e[i]:e[i]:"style"===i?T.isObject(t[i])&&T.isObject(e[i])?t[i]=T.mergeAttrs(t[i],e[i]):T.isObject(t[i])?t[i]=T.mergeAttrs(t[i],T.styleToObject(e[i])):T.isObject(e[i])?t[i]=T.mergeAttrs(T.styleToObject(t[i]),e[i]):t[i]=T.mergeAttrs(T.styleToObject(t[i]),T.styleToObject(e[i])):t[i]=e[i];return t},T.annotateString=function(t,e,i){e=e||[];for(var n,r,o=(i=i||{}).offset||0,s=[],a=[],l=0;l<t.length;l++){for(var h=a[l]=t[l],c=0;c<e.length;c++){var u=e[c],d=u.start+o,g=u.end+o;d<=l&&l<g&&(T.isObject(h)?h.attrs=T.mergeAttrs(T.mergeAttrs({},h.attrs),u.attrs):h=a[l]={t:t[l],attrs:u.attrs},i.includeAnnotationIndices&&(h.annotations||(h.annotations=[])).push(c))}(r=a[l-1])?T.isObject(h)&&T.isObject(r)?JSON.stringify(h.attrs)===JSON.stringify(r.attrs)?n.t+=h.t:(s.push(n),n=h):n=T.isObject(h)||T.isObject(r)?(s.push(n),h):(n||"")+h:n=h}return n&&s.push(n),s},T.findAnnotationsAtIndex=function(t,e){var i=[];return t&&t.forEach(function(t){t.start<e&&e<=t.end&&i.push(t)}),i},T.findAnnotationsBetweenIndexes=function(t,e,i){var n=[];return t&&t.forEach(function(t){(e>=t.start&&e<t.end||i>t.start&&i<=t.end||t.start>=e&&t.end<i)&&n.push(t)}),n},T.shiftAnnotations=function(t,e,i){return t&&t.forEach(function(t){t.start<e&&t.end>=e?t.end+=i:t.start>=e&&(t.start+=i,t.end+=i)}),t},T.convertLineToPathData=function(t){return["M",(t=T(t)).attr("x1"),t.attr("y1"),"L",t.attr("x2"),t.attr("y2")].join(" ")},T.convertPolygonToPathData=function(t){t=T.getPointsFromSvgNode(t);return 0===t.length?null:T.svgPointsToPath(t)+" Z"},T.convertPolylineToPathData=function(t){t=T.getPointsFromSvgNode(t);return 0===t.length?null:T.svgPointsToPath(t)},T.svgPointsToPath=function(t){for(var e=0,i=t.length;e<i;e++)t[e]=t[e].x+" "+t[e].y;return"M "+t.join(" L")},T.getPointsFromSvgNode=function(t){var e=[],i=(t=T.toNode(t)).points;if(i)for(var n=0,r=i.numberOfItems;n<r;n++)e.push(i.getItem(n));return e},T.KAPPA=.551784,T.convertCircleToPathData=function(t){t=T(t);var e=parseFloat(t.attr("cx"))||0,i=parseFloat(t.attr("cy"))||0,t=parseFloat(t.attr("r")),n=t*T.KAPPA;return["M",e,i-t,"C",e+n,i-t,e+t,i-n,e+t,i,"C",e+t,i+n,e+n,i+t,e,i+t,"C",e-n,i+t,e-t,i+n,e-t,i,"C",e-t,i-n,e-n,i-t,e,i-t,"Z"].join(" ")},T.convertEllipseToPathData=function(t){t=T(t);var e=parseFloat(t.attr("cx"))||0,i=parseFloat(t.attr("cy"))||0,n=parseFloat(t.attr("rx")),t=parseFloat(t.attr("ry"))||n,r=n*T.KAPPA,o=t*T.KAPPA;return["M",e,i-t,"C",e+r,i-t,e+n,i-o,e+n,i,"C",e+n,i+o,e+r,i+t,e,i+t,"C",e-r,i+t,e-n,i+o,e-n,i,"C",e-n,i-o,e-r,i-t,e,i-t,"Z"].join(" ")},T.convertRectToPathData=function(t){return t=T(t),T.rectToPath({x:parseFloat(t.attr("x"))||0,y:parseFloat(t.attr("y"))||0,width:parseFloat(t.attr("width"))||0,height:parseFloat(t.attr("height"))||0,rx:parseFloat(t.attr("rx"))||0,ry:parseFloat(t.attr("ry"))||0})},T.rectToPath=function(t){var e=t.x,i=t.y,n=t.width,r=t.height,o=l(t.rx||t["top-rx"]||0,n/2),s=l(t.rx||t["bottom-rx"]||0,n/2),a=l(t.ry||t["top-ry"]||0,r/2),t=l(t.ry||t["bottom-ry"]||0,r/2),s=o||s||a||t?["M",e,i+a,"v",r-a-t,"a",s,t,0,0,0,s,t,"h",n-2*s,"a",s,t,0,0,0,s,-t,"v",-(r-t-a),"a",o,a,0,0,0,-o,-a,"h",-(n-2*o),"a",o,a,0,0,0,-o,a,"Z"]:["M",e,i,"H",e+n,"V",i+r,"H",e,"V",i,"Z"];return s.join(" ")},T.normalizePathData=(t="\t\n\v\f\r \xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029",f=new RegExp("([a-z])["+t+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+t+"]*,?["+t+"]*)+)","ig"),m=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+t+"]*,?["+t+"]*","ig"),t=Math,I=t.PI,x=t.sin,S=t.cos,P=t.tan,M=t.asin,k=t.sqrt,N=t.abs,function(t){return e(t).join(",").split(",").join(" ")}),T.namespace=L,T.g=$e,T}(),Qe={useCSSSelectors:!0,classNamePrefix:"joint-",defaultTheme:"default",doubleTapInterval:300},Ke=((Je="undefined"!=typeof window?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame:Je)||(Xe=0,Je=function(t){var e=(new Date).getTime(),i=Math.max(0,16-(e-Xe)),n=setTimeout(function(){t(e+i)},i);return Xe=e+i,n}),function(t,e){for(var i=[],n=arguments.length-2;0<n--;)i[n]=arguments[n+2];return Je(void 0!==e?t.bind.apply(t,[e].concat(i)):t)}),qe=(Ft="undefined"!=typeof window,e=(e=Ft?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.oCancelAnimationFrame||window.oCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.mozCancelRequestAnimationFrame:e)||clearTimeout,Ft?e.bind(window):e),ti=function(t){return N(t)&&"%"===t.slice(-1)},ei=function(t){var e,i,n,r;return Object(t)!==t?(r=0,{top:r=isFinite(t)?+t:r,right:r,bottom:r,left:r}):(e=i=n=r=0,isFinite(t.vertical)&&(e=n=+t.vertical),isFinite(t.horizontal)&&(i=r=+t.horizontal),{top:e=isFinite(t.top)?+t.top:e,right:i=isFinite(t.right)?+t.right:i,bottom:n=isFinite(t.bottom)?+t.bottom:n,left:r=isFinite(t.left)?+t.left:r})},ii={linear:function(t){return t},quad:function(t){return t*t},cubic:function(t){return t*t*t},inout:function(t){if(t<=0)return 0;if(1<=t)return 1;var e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)},exponential:function(t){return Math.pow(2,10*(t-1))},bounce:function(t){for(var e,i=0,n=1;;i+=n,n/=2){1;if((7-4*i)/11<=t)return-(e=(11-6*i-11*t)/4)*e+n*n}},reverse:function(e){return function(t){return 1-e(1-t)}},reflect:function(e){return function(t){return.5*(t<.5?e(2*t):2-e(2-2*t))}},clamp:function(e,i,n){return i=i||0,n=n||1,function(t){t=e(t);return t<i?i:n<t?n:t}},back:function(e){return e=e||1.70158,function(t){return t*t*((e+1)*t-e)}},elastic:function(e){return e=e||1.5,function(t){return Math.pow(2,10*(t-1))*Math.cos(20*Math.PI*e/3*t)}}},ni={number:function(e,t){var i=t-e;return function(t){return e+i*t}},object:function(r,o){var s=Object.keys(r);return function(t){for(var e,i={},n=s.length-1;-1!=n;n--)i[e=s[n]]=r[e]+(o[e]-r[e])*t;return i}},hexColor:function(t,e){var t=parseInt(t.slice(1),16),e=parseInt(e.slice(1),16),i=255&t,n=(255&e)-i,r=65280&t,o=(65280&e)-r,s=16711680&t,a=(16711680&e)-s;return function(t){return"#"+(1<<24|i+n*t&255|r+o*t&65280|s+a*t&16711680).toString(16).slice(1)}},unit:function(e,t){var i=/(-?[0-9]*.[0-9]*)(px|em|cm|mm|in|pt|pc|%)/,n=i.exec(e),i=i.exec(t),t=i[1].indexOf("."),r=0<t?i[1].length-t-1:0,o=(e=+n[1],+i[1]-e),s=n[2];return function(t){return(e+o*t).toFixed(r)+s}}},ri={outline:function(t){var e=Number.isFinite(t.margin)?t.margin:2,i=Number.isFinite(t.width)?t.width:1;return si('<filter><feFlood flood-color="${color}" flood-opacity="${opacity}" result="colored"/><feMorphology in="SourceAlpha" result="morphedOuter" operator="dilate" radius="${outerRadius}" /><feMorphology in="SourceAlpha" result="morphedInner" operator="dilate" radius="${innerRadius}" /><feComposite result="morphedOuterColored" in="colored" in2="morphedOuter" operator="in"/><feComposite operator="xor" in="morphedOuterColored" in2="morphedInner" result="outline"/><feMerge><feMergeNode in="outline"/><feMergeNode in="SourceGraphic"/></feMerge></filter>')({color:t.color||"blue",opacity:Number.isFinite(t.opacity)?t.opacity:1,outerRadius:e+i,innerRadius:e})},highlight:function(t){return si('<filter><feFlood flood-color="${color}" flood-opacity="${opacity}" result="colored"/><feMorphology result="morphed" in="SourceGraphic" operator="dilate" radius="${width}"/><feComposite result="composed" in="colored" in2="morphed" operator="in"/><feGaussianBlur result="blured" in="composed" stdDeviation="${blur}"/><feBlend in="SourceGraphic" in2="blured" mode="normal"/></filter>')({color:t.color||"red",width:Number.isFinite(t.width)?t.width:1,blur:Number.isFinite(t.blur)?t.blur:0,opacity:Number.isFinite(t.opacity)?t.opacity:1})},blur:function(t){var e=Number.isFinite(t.x)?t.x:2;return si('<filter><feGaussianBlur stdDeviation="${stdDeviation}"/></filter>')({stdDeviation:Number.isFinite(t.y)?[e,t.y]:e})},dropShadow:function(t){var e="SVGFEDropShadowElement"in window?'<filter><feDropShadow stdDeviation="${blur}" dx="${dx}" dy="${dy}" flood-color="${color}" flood-opacity="${opacity}"/></filter>':'<filter><feGaussianBlur in="SourceAlpha" stdDeviation="${blur}"/><feOffset dx="${dx}" dy="${dy}" result="offsetblur"/><feFlood flood-color="${color}"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="${opacity}"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge></filter>';return si(e)({dx:t.dx||0,dy:t.dy||0,opacity:Number.isFinite(t.opacity)?t.opacity:1,color:t.color||"black",blur:Number.isFinite(t.blur)?t.blur:4})},grayscale:function(t){t=Number.isFinite(t.amount)?t.amount:1;return si('<filter><feColorMatrix type="matrix" values="${a} ${b} ${c} 0 0 ${d} ${e} ${f} 0 0 ${g} ${b} ${h} 0 0 0 0 0 1 0"/></filter>')({a:.2126+.7874*(1-t),b:.7152-.7152*(1-t),c:.0722-.0722*(1-t),d:.2126-.2126*(1-t),e:.7152+.2848*(1-t),f:.0722-.0722*(1-t),g:.2126-.2126*(1-t),h:.0722+.9278*(1-t)})},sepia:function(t){t=Number.isFinite(t.amount)?t.amount:1;return si('<filter><feColorMatrix type="matrix" values="${a} ${b} ${c} 0 0 ${d} ${e} ${f} 0 0 ${g} ${h} ${i} 0 0 0 0 0 1 0"/></filter>')({a:.393+.607*(1-t),b:.769-.769*(1-t),c:.189-.189*(1-t),d:.349-.349*(1-t),e:.686+.314*(1-t),f:.168-.168*(1-t),g:.272-.272*(1-t),h:.534-.534*(1-t),i:.131+.869*(1-t)})},saturate:function(t){t=Number.isFinite(t.amount)?t.amount:1;return si('<filter><feColorMatrix type="saturate" values="${amount}"/></filter>')({amount:1-t})},hueRotate:function(t){return si('<filter><feColorMatrix type="hueRotate" values="${angle}"/></filter>')({angle:t.angle||0})},invert:function(t){t=Number.isFinite(t.amount)?t.amount:1;return si('<filter><feComponentTransfer><feFuncR type="table" tableValues="${amount} ${amount2}"/><feFuncG type="table" tableValues="${amount} ${amount2}"/><feFuncB type="table" tableValues="${amount} ${amount2}"/></feComponentTransfer></filter>')({amount:t,amount2:1-t})},brightness:function(t){return si('<filter><feComponentTransfer><feFuncR type="linear" slope="${amount}"/><feFuncG type="linear" slope="${amount}"/><feFuncB type="linear" slope="${amount}"/></feComponentTransfer></filter>')({amount:Number.isFinite(t.amount)?t.amount:1})},contrast:function(t){t=Number.isFinite(t.amount)?t.amount:1;return si('<filter><feComponentTransfer><feFuncR type="linear" slope="${amount}" intercept="${amount2}"/><feFuncG type="linear" slope="${amount}" intercept="${amount2}"/><feFuncB type="linear" slope="${amount}" intercept="${amount2}"/></feComponentTransfer></filter>')({amount:t,amount2:.5-t/2})}},oi={number:function(t,e,o){o=o||{currency:["$",""],decimal:".",thousands:",",grouping:[3]};var t=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i.exec(t),i=t[1]||" ",n=t[2]||">",r=t[3]||"",s=t[4]||"",a=t[5],l=+t[6],h=t[7],c=t[8],u=t[9],d=1,g="",p="",f=!1,c=c&&+c.substring(1);switch((a||"0"===i&&"="===n)&&(a=i="0",n="=",h&&(l-=Math.floor((l-1)/4))),u){case"n":h=!0,u="g";break;case"%":d=100,p="%",u="f";break;case"p":d=100,p="%",u="r";break;case"b":case"o":case"x":case"X":"#"===s&&(g="0"+u.toLowerCase());break;case"c":case"d":f=!0,c=0;break;case"s":d=-1,u="r"}"$"===s&&(g=o.currency[0],p=o.currency[1]),"r"!=u||c||(u="g"),null!=c&&("g"==u?c=Math.max(1,Math.min(21,c)):"e"!=u&&"f"!=u||(c=Math.max(0,Math.min(20,c))));t=a&&h;if(f&&e%1)return"";var r=e<0||0===e&&1/e<0?(e=-e,"-"):r,m=p,v=(d<0?(e=(v=this.prefix(e,c)).scale(e),m=v.symbol+p):e*=d,(e=this.convert(u,e,c)).lastIndexOf(".")),y=v<0?e:e.substring(0,v),v=v<0?"":o.decimal+e.substring(v+1);function b(t){for(var e=t.length,i=[],n=0,r=o.grouping[0];0<e&&0<r;)i.push(t.substring(e-=r,e+r)),r=o.grouping[n=(n+1)%o.grouping.length];return i.reverse().join(o.thousands)}!a&&h&&o.grouping&&(y=b(y));a=g.length+y.length+v.length+(t?0:r.length),l=a<l?new Array(a=l-a+1).join(i):"";return r+=g,e=(y=t?b(l+y):y)+v,("<"===n?r+e+l:">"===n?l+r+e:"^"===n?l.substring(0,a>>=1)+r+e+l.substring(a):r+(t?e:l+e))+m},string:function(t,e){for(var i,n="{",r=!1,o=[];-1!==(i=t.indexOf(n));){if(l=t.slice(0,i),r){for(var s,a=(s=l.split(":")).shift().split("."),l=e,h=0;h<a.length;h++)l=l[a[h]];s.length&&(l=this.number(s,l))}o.push(l),t=t.slice(i+1),n=(r=!r)?"}":"{"}return o.push(t),o.join("")},convert:function(t,e,i){switch(t){case"b":return e.toString(2);case"c":return String.fromCharCode(e);case"o":return e.toString(8);case"x":return e.toString(16);case"X":return e.toString(16).toUpperCase();case"g":return e.toPrecision(i);case"e":return e.toExponential(i);case"f":return e.toFixed(i);case"r":return(e=this.round(e,this.precision(e,i))).toFixed(Math.max(0,Math.min(20,this.precision(e*(1+1e-15),i))));default:return e+""}},round:function(t,e){return e?Math.round(t*(e=Math.pow(10,e)))/e:Math.round(t)},precision:function(t,e){return e-(t?Math.ceil(Math.log(t)/Math.LN10):1)},prefix:function(t,e){var i=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(function(t,e){var i=Math.pow(10,3*Math.abs(8-e));return{scale:8<e?function(t){return t/i}:function(t){return t*i},symbol:t}}),n=0;return t&&(t<0&&(t*=-1),e&&(t=this.round(t,this.precision(t,e))),n=1+Math.floor(1e-12+Math.log(t)/Math.LN10),n=Math.max(-24,Math.min(24,3*Math.floor((n<=0?n+1:n-1)/3)))),i[8+n/3]}},si=function(t){var e=/<%= ([^ ]+) %>|\$\{ ?([^{} ]+) ?\}|\{\{([^{} ]+)\}\}/g;return function(n){return n=n||{},t.replace(e,function(t){for(var e=Array.from(arguments).slice(1,4).find(function(t){return!!t}).split("."),i=n[e.shift()];void 0!==i&&e.length;)i=i[e.shift()];return void 0!==i?i:""})}},Ut=i.assign,At=i.defaults,Ft=Ut,e=i.defaultsDeep,R=i.assign,S=i.defaults,ai=i.defaultsDeep,li=i.invokeMap||i.invoke,hi=i.sortedIndexBy||i.sortedIndex,ci=i.uniqBy||i.uniq,ui=i.clone,di=i.cloneDeep,gi=i.isEmpty,pi=i.isEqual,P=i.isFunction,fi=i.isPlainObject,et=i.toArray,mi=i.debounce,vi=i.groupBy,yi=i.sortBy,bi=i.flattenDeep,wi=i.without,Ai=i.difference,Ci=i.intersection,Ii=i.union,xi=i.has,M=i.result,Si=i.omit,Pi=i.pick,Mi=i.bindAll,k=i.forIn,ki=i.camelCase,Ni=i.uniqueId,G=function(t){var e=Object.prototype.toString;return"number"==typeof t||!!t&&"object"==typeof t&&"[object Number]"===e.call(t)},N=function(t){var e=Object.prototype.toString;return"string"==typeof t||!!t&&"object"==typeof t&&"[object String]"===e.call(t)};function Ti(t){t=ci(t);var r=et(t).reduce(function(t,e){return t[e.id]=e.clone(),t},{});return et(t).forEach(function(t){var e=r[t.id],i=(e.isLink()&&(i=e.source(),n=e.target(),i.id&&r[i.id]&&e.prop("source/id",r[i.id].id),n.id&&r[n.id]&&e.prop("target/id",r[n.id].id)),t.get("parent")),n=(i&&r[i]&&e.set("parent",r[i].id),et(t.get("embeds")).reduce(function(t,e){return r[e]&&t.push(r[e].id),t},[]));gi(n)||e.set("embeds",n)}),r}var Li={x:"x",y:"y",width:"w",height:"h",minimum:"s",maximum:"l",diagonal:"d"},Ei=Object.keys(Li).map(function(t){return Li[t]}).join(""),Di="[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?",Bi=/\s/g,Gi=new RegExp("^("+Di+"\\*)?(["+Ei+"])([-+]{1,2}"+Di+")?$","g");function zi(t){throw new Error("Invalid calc() expression: "+t)}function Oi(t,e){var i=Gi.exec(t.replace(Bi,"")),t=(i||zi(t),Gi.lastIndex=0,i[1]),n=(void 0===t&&(t=1),i[2]),i=i[3],r=(void 0===i&&(i=0),e.x),o=e.y,s=e.width,a=e.height,l=0;switch(n){case Li.width:l=s;break;case Li.height:l=a;break;case Li.x:l=r;break;case Li.y:l=o;break;case Li.minimum:l=Math.min(a,s);break;case Li.maximum:l=Math.max(a,s);break;case Li.diagonal:l=Math.sqrt(a*a+s*s)}return parseFloat(t)*l+function(t){if(!t)return 0;switch(t[0]){case"+":return parseFloat(t.substr(1));case"-":return-parseFloat(t.substr(1))}return parseFloat(t)}(i)}function Ri(t){return"string"==typeof t&&t.includes("calc")}var Vi="calc(".length;function ji(t,e){for(var i=t,n=0;;){var r=i.indexOf("calc(",n);if(-1===r)return i;var o=r+Vi,s=1;t:for(;;){switch(i[o]){case"(":s++;break;case")":if(0===--s)break t;break;case void 0:zi(i)}o++}var a=i.slice(r+Vi,o),a=(Ri(a)&&(a=ji(a,e)),String(Oi(a,e))),i=i.slice(0,r)+a+i.slice(o+1),n=r+a.length}}function _i(r,o){return function(t,e){var i=ti(t),n=(t=parseFloat(t),i&&(t/=100),{});return isFinite(t)&&(i=i||0<=t&&t<=1?t*e[o]:Math.max(t+e[o],0),n[r]=i),n}}function Zi(r,o,s){return function(t,e){var i,n=ti(t),n=(t=parseFloat(t),n&&(t/=100),isFinite(t)&&(i=e[s](),i=n||0<t&&t<1?i[r]+e[o]*t:i[r]+t),z());return n[r]=i||0,n}}function Yi(n,r,o){return function(t,e){var t="middle"===t?e[r]/2:t===o?e[r]:isFinite(t)?-1<t&&t<1?-e[r]*t:-t:ti(t)?e[r]*parseFloat(t)/100:0,i=z();return i[n]=-(e[n]+t),i}}function Wi(s,t){var a="joint-shape",l=t&&t.resetOffset;return function(t,e,i){var i=w(i),n=i.data(a),t=(n&&n.value===t||(n={value:t,shape:t=s(t),shapeBBox:t.bbox()},i.data(a,n)),n.shape.clone()),i=n.shapeBBox.clone(),n=i.origin(),r=e.origin(),r=(i.x=r.x,i.y=r.y,e.maxRectScaleToFit(i,r)),o=0===i.width||0===e.width?1:r.sx,i=0===i.height||0===e.height?1:r.sy;return t.scale(o,i,n),l&&t.translate(-n.x,-n.y),t}}function Fi(t){var n=Wi(function(t){return new O(B.normalizePathData(t))},t);return function(t,e,i){return{d:n(t,e,i).serialize()}}}function Ui(t){var n=Wi(v,t);return function(t,e,i){return{points:n(t,e,i).serialize()}}}function Hi(n,r){var o=new z(1,0);return function(t){var e,i,t=this[n](t);return t?(i=r.rotate?t.vector().vectorAngle(o):0,e=t.start):(e=this.path.start,i=0),0===i?{transform:"translate("+e.x+","+e.y+")"}:{transform:"translate("+e.x+","+e.y+") rotate("+i+")"}}}function Xi(n){return function(t,e,i){i=B(i);i.attr(n)!==t&&i.attr(n,t)}}function Ji(t,e,i){return void 0!==i.text}function $i(){return this.model.isLink()}function Qi(t){var e={},i=t.stroke,i=("string"==typeof i&&(e.stroke=i,e.fill=i),t.strokeOpacity);return void 0!==(i=void 0===(i=void 0===i?t["stroke-opacity"]:i)?t.opacity:i)&&(e["stroke-opacity"]=i,e["fill-opacity"]=i),e}function Ki(t){var e=this.paper;return"url(#"+("pattern"===t.type?e.definePattern(t):e.defineGradient(t))+")"}function qi(e,t,i){if(N(i)){if(!on[i])throw new Error('Unknown wrapper: "'+i+'"');i=on[i]}if(!P(i))throw new Error("Wrapper must be a function.");et(t).forEach(function(t){e[t]=i(e[t])})}var tn,en,a={xlinkShow:{set:"xlink:show"},xlinkRole:{set:"xlink:role"},xlinkType:{set:"xlink:type"},xlinkArcrole:{set:"xlink:arcrole"},xlinkTitle:{set:"xlink:title"},xlinkActuate:{set:"xlink:actuate"},xmlSpace:{set:"xml:space"},xmlBase:{set:"xml:base"},xmlLang:{set:"xml:lang"},preserveAspectRatio:{set:"preserveAspectRatio"},requiredExtension:{set:"requiredExtension"},requiredFeatures:{set:"requiredFeatures"},systemLanguage:{set:"systemLanguage"},externalResourcesRequired:{set:"externalResourceRequired"},href:{set:Xi("href")},xlinkHref:{set:Xi("xlink:href")},filter:{qualify:fi,set:function(t){return"url(#"+this.paper.defineFilter(t)+")"}},fill:{qualify:fi,set:Ki},stroke:{qualify:fi,set:Ki},sourceMarker:{qualify:fi,set:function(t,e,i,n){return t=R(Qi(n),t),{"marker-start":"url(#"+this.paper.defineMarker(t)+")"}}},targetMarker:{qualify:fi,set:function(t,e,i,n){return t=R(Qi(n),{transform:"rotate(180)"},t),{"marker-end":"url(#"+this.paper.defineMarker(t)+")"}}},vertexMarker:{qualify:fi,set:function(t,e,i,n){return t=R(Qi(n),t),{"marker-mid":"url(#"+this.paper.defineMarker(t)+")"}}},text:{qualify:function(t,e,i){return!i.textWrap||!fi(i.textWrap)},set:function(t,e,i,n){var r=w(i),o="joint-text",s=r.data(o),a=Pi(n,"lineHeight","annotations","textPath","x","textVerticalAnchor","eol","displayEmpty"),l=a.x,l=(Ri(l)&&(a.x=ji(l,e)),a.fontSize=n["font-size"]||n.fontSize),e=JSON.stringify([t,a]);void 0!==s&&s===e||(l&&i.setAttribute("font-size",l),n=a.textPath,x(n)&&"string"==typeof(s=n.selector)&&(l=this.findBySelector(s)[0])instanceof SVGPathElement&&(a.textPath=R({"xlink:href":"#"+l.id},n)),B(i).text(""+t,a),r.data(o,e))}},textWrap:{qualify:fi,set:function(t,e,i,n){var r=t.width||0,o={},r=(ti(r)?o.width=e.width*parseFloat(r)/100:o.width=r<=0?e.width+r:r,t.height||0),r=(ti(r)?o.height=e.height*parseFloat(r)/100:o.height=r<=0?e.height+r:r,t.text),r=void 0!==(r=void 0===r?n.text:r)?ze(""+r,o,{"font-weight":n["font-weight"]||n.fontWeight,"font-size":n["font-size"]||n.fontSize,"font-family":n["font-family"]||n.fontFamily,lineHeight:n.lineHeight,"letter-spacing":"letter-spacing"in n?n["letter-spacing"]:n.letterSpacing},{svgDocument:this.paper.svg,ellipsis:t.ellipsis,hyphen:t.hyphen,maxLineCount:t.maxLineCount}):"";a.text.set.call(this,r,e,i,n)}},title:{qualify:function(t,e){return e instanceof SVGElement},set:function(t,e,i){var n=w(i),r="joint-title",o=n.data(r);void 0!==o&&o===t||(n.data(r,t),(o=i.firstChild)&&"TITLE"===o.tagName.toUpperCase()?o.textContent=t:((n=document.createElementNS(i.namespaceURI,"title")).textContent=t,i.insertBefore(n,o)))}},lineHeight:{qualify:Ji},textVerticalAnchor:{qualify:Ji},textPath:{qualify:Ji},annotations:{qualify:Ji},eol:{qualify:Ji},displayEmpty:{qualify:Ji},port:{set:function(t){return null===t||void 0===t.id?t:t.id}},style:{qualify:fi,set:function(t,e,i){w(i).css(t)}},html:{set:function(t,e,i){w(i).html(t+"")}},ref:{},refX:{position:Zi("x","width","origin")},refY:{position:Zi("y","height","origin")},refDx:{position:Zi("x","width","corner")},refDy:{position:Zi("y","height","corner")},refWidth:{set:_i("width","width")},refHeight:{set:_i("height","height")},refRx:{set:_i("rx","width")},refRy:{set:_i("ry","height")},refRInscribed:{set:(tn=_i("r","width"),en=_i("r","height"),function(t,e){return(e.height>e.width?tn:en)(t,e)})},refRCircumscribed:{set:function(t,e){var i,n=ti(t),e=(t=parseFloat(t),n&&(t/=100),Math.sqrt(e.height*e.height+e.width*e.width));return{r:i=isFinite(t)?n||0<=t&&t<=1?t*e:Math.max(t+e,0):i}}},refCx:{set:_i("cx","width")},refCy:{set:_i("cy","height")},xAlignment:{offset:Yi("x","width","right")},yAlignment:{offset:Yi("y","height","bottom")},resetOffset:{offset:function(t,e){return t?{x:-e.x,y:-e.y}:{x:0,y:0}}},refDResetOffset:{set:Fi({resetOffset:!0})},refDKeepOffset:{set:Fi({resetOffset:!1})},refPointsResetOffset:{set:Ui({resetOffset:!0})},refPointsKeepOffset:{set:Ui({resetOffset:!1})},connection:{qualify:$i,set:function(t){var e,i,n,t=t.stubs;return void 0===t&&(t=0),isFinite(t)&&0!==t&&(t=t<0?(this.getConnectionLength()+t)/2:t,i=(n=this.getConnection()).divideAtLength(t),n=n.divideAtLength(-t),i&&n&&(e=i[0].serialize()+" "+n[1].serialize())),{d:e||this.getSerializedConnection()}}},atConnectionLengthKeepGradient:{qualify:$i,set:Hi("getTangentAtLength",{rotate:!0})},atConnectionLengthIgnoreGradient:{qualify:$i,set:Hi("getTangentAtLength",{rotate:!1})},atConnectionRatioKeepGradient:{qualify:$i,set:Hi("getTangentAtRatio",{rotate:!0})},atConnectionRatioIgnoreGradient:{qualify:$i,set:Hi("getTangentAtRatio",{rotate:!1})}},nn=(a["xlink:href"]=a.xlinkHref,["transform","d","points","width","height","cx","cy","r","rx","ry","x1","x2","y1","y2","x","y","dx","dy"].forEach(function(n){a[n]={qualify:Ri,set:function(t,e){var i={};return i[n]=ji(t,e),i}}}),a.refR=a.refRInscribed,a.refD=a.refDResetOffset,a.refPoints=a.refPointsResetOffset,a.atConnectionLength=a.atConnectionLengthKeepGradient,a.atConnectionRatio=a.atConnectionRatioKeepGradient,a.refX2=a.refX,a.refY2=a.refY,a.refWidth2=a.refWidth,a.refHeight2=a.refHeight,a["ref-x"]=a.refX,a["ref-y"]=a.refY,a["ref-dy"]=a.refDy,a["ref-dx"]=a.refDx,a["ref-width"]=a.refWidth,a["ref-height"]=a.refHeight,a["x-alignment"]=a.xAlignment,a["y-alignment"]=a.yAlignment,a),rn=o.Model.extend({constructor:function(t,e){var i,t=t||{};"function"==typeof this.preinitialize&&this.preinitialize.apply(this,arguments),this.cid=Ni("c"),this.attributes={},e&&e.collection&&(this.collection=e.collection),e&&e.parse&&(t=this.parse(t,e)||{}),(i=M(this,"defaults"))&&(t=y({},i,t)),this.set(t,e),this.changed={},this.initialize.apply(this,arguments)},translate:function(t,e,i){throw new Error("Must define a translate() method.")},toJSON:function(){var e=M(this.constructor.prototype,"defaults").attrs||{},t=this.attributes.attrs,o={},t=(k(t,function(t,n){var r=e[n];k(t,function(t,i){x(t)&&!Array.isArray(t)?k(t,function(t,e){r&&r[i]&&pi(r[i][e],t)||(o[n]=o[n]||{},(o[n][i]||(o[n][i]={}))[e]=t)}):r&&pi(r[i],t)||(o[n]=o[n]||{},o[n][i]=t)})}),di(Si(this.attributes,"attrs")));return t.attrs=o,t},initialize:function(t){var e=this.getIdAttribute();t&&e in t||this.set(e,this.generateId(),{silent:!0}),this._transitionIds={},this._scheduledTransitionIds={},this.processPorts(),this.on("change:attrs",this.processPorts,this)},getIdAttribute:function(){return this.idAttribute||"id"},generateId:Ee,processPorts:function(){var t=this.ports,i={},n=(k(this.get("attrs"),function(t,e){t&&t.port&&(void 0!==t.port.id?i[t.port.id]=t.port:i[t.port]={id:t.port})}),{});k(t,function(t,e){i[e]||(n[e]=!0)}),this.graph&&!gi(n)&&(this.graph.getConnectedLinks(this,{inbound:!0}).forEach(function(t){n[t.get("target").port]&&t.remove()}),this.graph.getConnectedLinks(this,{outbound:!0}).forEach(function(t){n[t.get("source").port]&&t.remove()})),this.ports=i},remove:function(t){void 0===t&&(t={});var e=this.graph,i=this.collection;if(!e)return i&&i.remove(this,t),this;e.startBatch("remove");for(var i=this.getParentCell(),n=(i&&i.unembed(this,t),this.getEmbeddedCells()),r=0,o=n.length;r<o;r++){var s=n[r];s&&s.remove(t)}return this.trigger("remove",this,e.attributes.cells,t),e.stopBatch("remove"),this},toFront:function(i){var n,t,e=this.graph;return e&&(i=i||{},n=e.maxZIndex(),i.deep?(t=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==i.breadthFirst})).unshift(this):t=[this],n=n-t.length+1,((e=e.get("cells")).indexOf(this)!==e.length-t.length||t.some(function(t,e){return t.get("z")!==n+e}))&&(this.startBatch("to-front"),n+=t.length,t.forEach(function(t,e){t.set("z",n+e,i)}),this.stopBatch("to-front"))),this},toBack:function(i){var n,t,e=this.graph;return e&&(i=i||{},n=e.minZIndex(),i.deep?(t=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==i.breadthFirst})).unshift(this):t=[this],(0!==e.get("cells").indexOf(this)||t.some(function(t,e){return t.get("z")!==n+e}))&&(this.startBatch("to-back"),n-=t.length,t.forEach(function(t,e){t.set("z",n+e,i)}),this.stopBatch("to-back"))),this},parent:function(t,e){return void 0===t?this.get("parent"):this.set("parent",t,e)},embed:function(t,e){t=Array.isArray(t)?t:[t];if(this.canEmbed(t))return this._embedCells(t,e),this;throw new Error("Recursive embedding not allowed.")},unembed:function(t,e){t=Array.isArray(t)?t:[t];return this._unembedCells(t,e),this},canEmbed:function(t){var e=this;return(Array.isArray(t)?t:[t]).every(function(t){return e!==t&&!e.isEmbeddedIn(t)})},_embedCells:function(t,e){var i=this,n=(this.startBatch("embed"),R([],this.get("embeds")));t.forEach(function(t){n[t.isLink()?"unshift":"push"](t.id),t.parent(i.id,e)}),this.set("embeds",ci(n),e),this.stopBatch("embed")},_unembedCells:function(t,e){this.startBatch("unembed"),t.forEach(function(t){return t.unset("parent",e)}),this.set("embeds",wi.apply(void 0,[this.get("embeds")].concat(t.map(function(t){return t.id}))),e),this.stopBatch("unembed")},getParentCell:function(){var t=this.parent(),e=this.graph;return t&&e&&e.getCell(t)||null},getAncestors:function(){var t=[];if(!this.graph)return t;for(var e=this.getParentCell();e;)t.push(e),e=e.getParentCell();return t},getEmbeddedCells:function(e){if(e=e||{},this.graph){if(e.deep)if(e.breadthFirst)for(var i=[],t=this.getEmbeddedCells();0<t.length;){var n=t.shift();i.push(n),t.push.apply(t,n.getEmbeddedCells())}else(i=this.getEmbeddedCells()).forEach(function(t){i.push.apply(i,t.getEmbeddedCells(e))});else i=et(this.get("embeds")).map(this.graph.getCell,this.graph);return i}return[]},isEmbeddedIn:function(t,e){var i=N(t)?t:t.id,n=this.parent();if(e=S({deep:!0},e),this.graph&&e.deep){for(;n;){if(n===i)return!0;n=this.graph.getCell(n).parent()}return!1}return n===i},isEmbedded:function(){return!!this.parent()},clone:function(t){return(t=t||{}).deep?et(Ti([this].concat(this.getEmbeddedCells({deep:!0})))):((t=o.Model.prototype.clone.apply(this,arguments)).set(this.getIdAttribute(),this.generateId()),t.unset("embeds"),t.unset("parent"),t)},prop:function(t,e,i){var n=N(t);if(n||Array.isArray(t)){if(1<arguments.length){var r=n?(p=t).split("/"):(p=t.join("/"),t.slice()),o=r[0],s=r.length;if((i=i||{}).propertyPath=p,i.propertyValue=e,i.propertyPathArray=r,1===s)return this.set(o,e,i);for(var a=d={},l=o,h=1;h<s;h++)var c=r[h],u=Number.isFinite(n?Number(c):c),a=a[l]=u?[]:{},l=c;var d=Ne(d,r,e,"/"),g=y({},this.attributes),p=(i.rewrite&&Te(g,p,"/"),y(g,d));return this.set(o,p[o],i)}return Me(this.attributes,t,"/")}return this.set(y({},this.attributes,t),e)},removeProp:function(t,e){e=e||{};var i=Array.isArray(t)?t:t.split("/"),n=i[0];if("attrs"===n&&(e.dirty=!0),1===i.length)return this.unset(t,e);t=i.slice(1),i=di(this.get(n));return Te(i,t,"/"),this.set(n,i,e)},attr:function(t,e,i){var n=Array.from(arguments);return 0===n.length?this.get("attrs"):(Array.isArray(t)?n[0]=["attrs"].concat(t):N(t)?n[0]="attrs/"+t:n[0]={attrs:t},this.prop.apply(this,n))},removeAttr:function(t,e){return Array.isArray(t)?this.removeProp(["attrs"].concat(t)):this.removeProp("attrs/"+t,e)},transition:function(i,e,n,r){var o=this;r=r||"/";n=R({duration:100,delay:10,timingFunction:ii.linear,valueFunction:ni.number},n);var s,a=0,l=function(t){var e;(t=(t-=a=a||t)/n.duration)<1?this._transitionIds[i]=e=Ke(l):(t=1,delete this._transitionIds[i]),t=s(n.timingFunction(t)),n.transitionId=e,this.prop(i,t,n),e||this.trigger("transition:end",this,i)}.bind(this),h=this._scheduledTransitionIds,c=setTimeout(function(t){h[i]&&(h[i]=wi(h[i],c),0===h[i].length&&delete h[i]),o.stopPendingTransitions(i,r),s=n.valueFunction(Me(o.attributes,i,r),e),o._transitionIds[i]=Ke(t),o.trigger("transition:start",o,i)},n.delay,l);return h[i]||(h[i]=[]),h[i].push(c),c},getTransitions:function(){return Ii(Object.keys(this._transitionIds),Object.keys(this._scheduledTransitionIds))},stopScheduledTransitions:function(t,e){void 0===e&&(e="/");var i,n=this._scheduledTransitionIds,r=(void 0===n&&(n={}),Object.keys(n));return t&&(i=t.split(e),r=r.filter(function(t){return pi(i,t.split(e).slice(0,i.length))})),r.forEach(function(t){n[t].forEach(function(t){return clearTimeout(t)}),delete n[t]}),this},stopPendingTransitions:function(t,e){var i,n=this,r=(void 0===e&&(e="/"),this._transitionIds),o=(void 0===r&&(r={}),Object.keys(r));t&&(i=t.split(e),o=o.filter(function(t){return pi(i,t.split(e).slice(0,i.length))})),o.forEach(function(t){var e=r[t];qe(e),delete r[t],n.trigger("transition:end",n,t)})},stopTransitions:function(t,e){return this.stopScheduledTransitions(t,e=void 0===e?"/":e),this.stopPendingTransitions(t,e),this},addTo:function(t,e){return t.addCell(this,e),this},findView:function(t){return t.findViewByModel(this)},isElement:function(){return!1},isLink:function(){return!1},startBatch:function(t,e){return this.graph&&this.graph.startBatch(t,R({},e,{cell:this})),this},stopBatch:function(t,e){return this.graph&&this.graph.stopBatch(t,R({},e,{cell:this})),this},getChangeFlag:function(t){var e,i=0;if(!t)return i;for(e in t)t.hasOwnProperty(e)&&this.hasChanged(e)&&(i|=t[e]);return i},angle:function(){return 0},position:function(){return new z(0,0)},getPointFromConnectedLink:function(){return new z},getBBox:function(){return new tt(0,0,0,0)},getPointRotatedAroundCenter:function(t,e,i){e=new z(e,i);return t&&e.rotate(this.getBBox().center(),t),e},getAbsolutePointFromRelative:function(t,e){return this.getPointRotatedAroundCenter(-this.angle(),this.position().offset(t,e))},getRelativePointFromAbsolute:function(t,e){return this.getPointRotatedAroundCenter(this.angle(),t,e).difference(this.position())}},{getAttributeDefinition:function(t){var e=this.attributes,i=nn;return e&&e[t]||i[t]},define:function(t,e,i,n){i=R({defaults:ai({type:t},e,this.prototype.defaults)},i);e=this.extend(i,n);return"undefined"!=typeof joint&&xi(joint,"shapes")&&Ne(joint.shapes,t,e,"."),e}}),on={cells:function(n){return function(){var t=Array.from(arguments),e=t.length,i=0<e&&t[0]||[],e=1<e&&t[e-1]||{};return Array.isArray(i)||(e instanceof rn?i=t:i instanceof rn&&(1<t.length&&t.pop(),i=t)),n.call(this,i,e=e instanceof rn?{}:e)}}},Ei={wrapWith:qi,wrappers:on,addClassNamePrefix:Ie,removeClassNamePrefix:xe,parseDOMJSON:Se,hashCode:Pe,getByPath:Me,setByPath:Ne,unsetByPath:Te,flattenObject:Le,uuid:Ee,guid:De,toKebabCase:Be,normalizeEvent:I,nextFrame:Ke,cancelFrame:qe,shapePerimeterConnectionPoint:function(t,e,i,n){var r,o,s,a;return i||(s=e.$(".scalable")[0],a=e.$(".rotatable")[0],s&&s.firstChild?i=s.firstChild:a&&a.firstChild&&(i=a.firstChild)),i?(o=B(i).findIntersection(n,t.paper.cells))||(r=B(i).getBBox({target:t.paper.cells})):o=(r=e.model.getBBox()).intersectionWithLineFromCenterToPoint(n),o||r.center()},isPercentage:ti,parseCssNumeric:Ge,breakText:ze,sanitizeHTML:Oe,downloadBlob:Re,downloadDataUri:Ve,dataUriToBlob:je,imageToDataUri:_e,getElementBBox:Ze,sortElements:Ye,setAttributesBySelector:We,normalizeSides:ei,timing:ii,interpolate:ni,filter:ri,format:oi,template:si,toggleFullScreen:Fe,mixin:Ut,supplement:At,deepMixin:Ft,deepSupplement:e,assign:R,defaults:S,defaultsDeep:ai,invoke:li,sortedIndex:hi,uniq:ci,clone:ui,cloneDeep:di,isEmpty:gi,isEqual:pi,isFunction:P,isPlainObject:fi,toArray:et,debounce:mi,groupBy:vi,sortBy:yi,flattenDeep:bi,without:wi,difference:Ai,intersection:Ci,union:Ii,has:xi,result:M,omit:Si,pick:Pi,bindAll:Mi,forIn:k,camelCase:ki,uniqueId:Ni,merge:y,isBoolean:Ue,isObject:x,isNumber:G,isString:N,noop:He,cloneCells:Ti};function sn(t,e,i){t=t.toJSON();return t.angle=e||0,S({},i,t)}function an(t,e,i){return t.map(function(t,e,i){e=this.pointAt((e+.5)/i.length);return(t.dx||t.dy)&&e.offset(t.dx||0,t.dy||0),sn(e.round(),0,t)},mt(e,i))}function ln(t,e,n,r){var o=e.center(),s=e.width/e.height,a=e.topMiddle(),l=wt.fromRect(e);return t.map(function(t,e,i){e=n+r(e,i.length),i=a.clone().rotate(o,-e).scale(s,1,o),e=t.compensateRotation?-l.tangentTheta(i):0;return(t.dx||t.dy)&&i.offset(t.dx||0,t.dy||0),t.dr&&i.move(o,t.dr),sn(i.round(),e,t)})}function hn(t,e){var i=e.x,e=(N(i)&&(i=parseFloat(i)/100*t.width),e.y);return N(e)&&(e=parseFloat(e)/100*t.height),A(i||0,e||0)}var cn={absolute:function(t,e,i){return t.map(hn.bind(null,e))},fn:function(t,e,i){return i.fn(t,e,i)},line:function(t,e,i){return an(t,hn(e,i.start||e.origin()),hn(e,i.end||e.corner()))},left:function(t,e,i){return an(t,e.origin(),e.bottomLeft())},right:function(t,e,i){return an(t,e.topRight(),e.corner())},top:function(t,e,i){return an(t,e.origin(),e.topRight())},bottom:function(t,e,i){return an(t,e.bottomLeft(),e.corner())},ellipseSpread:function(t,e,i){var n=i.startAngle||0,r=i.step||360/t.length;return ln(t,e,n,function(t){return t*r})},ellipse:function(t,e,i){var n=i.startAngle||0,r=i.step||20;return ln(t,e,n,function(t,e){return(t+.5-e/2)*r})}};function un(t,e){return ai({},t,e,{x:0,y:0,angle:0,attrs:{".":{y:"0","text-anchor":"start"}}})}function dn(t,e,i,n){n=S({},n,{offset:15});var r,o,s,t=e.center().theta(t),e=gn(e),n=n.offset,a=0,t=t<e[1]||t>e[2]?(s=".3em",r=n,o=0,"start"):t<e[0]?(s="0",r=0,o=-n,i?(a=-90,"start"):"middle"):t<e[3]?(s=".3em",r=-n,o=0,"end"):(s=".6em",r=0,o=n,i?(a=90,"start"):"middle"),e=Math.round;return un({x:e(r),y:e(o),angle:a,attrs:{".":{y:s,"text-anchor":t}}})}function gn(t){var e=t.center(),i=e.theta(t.origin()),n=e.theta(t.bottomLeft()),r=e.theta(t.corner());return[i,e.theta(t.topRight()),r,n]}function pn(t,e,i,n){var r,o,s,t=e.center().theta(t),n=(n=S({},n,{offset:15})).offset,a=0,e=gn(e),t=t<e[1]||t>e[2]?(s=".3em",r=-n,o=0,"end"):t<e[0]?(s=".6em",r=0,o=n,i?(a=90,"start"):"middle"):t<e[3]?(s=".3em",r=n,o=0,"start"):(s="0em",r=0,o=-n,i?(a=-90,"start"):"middle"),e=Math.round;return un({x:e(r),y:e(o),angle:a,attrs:{".":{y:s,"text-anchor":t}}})}function fn(t,e,i){i=S({},i,{offset:20});var n,r=A(0,0),o=-t.theta(r),s=o,r=t.clone().move(r,i.offset).difference(t).round(),i=".3em",t=((90+o)%180==0?(n=e?"end":"middle",e||-270!=o||(i="0em")):-270<o&&o<-90?(n="start",s=o-180):n="end",Math.round);return un({x:t(r.x),y:t(r.y),angle:e?s:0,attrs:{".":{y:i,"text-anchor":n}}})}function mn(t){t=di(t)||{},this.ports=[],this.groups={},this.portLayoutNamespace=cn,this.portLabelLayoutNamespace=yn,this._init(t)}var vn,yn={manual:function(t,e,i){return un(i,e)},left:function(t,e,i){return un(i,{x:-15,attrs:{".":{y:".3em","text-anchor":"end"}}})},right:function(t,e,i){return un(i,{x:15,attrs:{".":{y:".3em","text-anchor":"start"}}})},top:function(t,e,i){return un(i,{y:-15,attrs:{".":{"text-anchor":"middle"}}})},bottom:function(t,e,i){return un(i,{y:15,attrs:{".":{y:".6em","text-anchor":"middle"}}})},outsideOriented:function(t,e,i){return dn(t,e,!0,i)},outside:function(t,e,i){return dn(t,e,!1,i)},insideOriented:function(t,e,i){return pn(t,e,!0,i)},inside:function(t,e,i){return pn(t,e,!1,i)},radial:function(t,e,i){return fn(t.difference(e.center()),!1,i)},radialOriented:function(t,e,i){return fn(t.difference(e.center()),!0,i)}},Di=(mn.prototype={getPorts:function(){return this.ports},getGroup:function(t){return this.groups[t]||{}},getPortsByGroup:function(e){return this.ports.filter(function(t){return t.group===e})},getGroupPortsMetrics:function(t,n){var e=this.getGroup(t),t=this.getPortsByGroup(t),e=e.position||{},i=e.name,r=this.portLayoutNamespace,e=(r[i]||(i="left"),e.args||{}),o=t.map(function(t){return t&&t.position&&t.position.args}),r=r[i](o,n,e),i={ports:t,result:[]};return et(r).reduce(function(t,e,i){i=t.ports[i];return t.result.push({portId:i.id,portTransformation:e,labelTransformation:this._getPortLabelLayout(i,z(e),n),portAttrs:i.attrs,portSize:i.size,labelSize:i.label.size}),t}.bind(this),i),i.result},_getPortLabelLayout:function(t,e,i){var n=this.portLabelLayoutNamespace,r=t.label.position.name||"left";return n[r]?n[r](e,i,t.label.position.args):null},_init:function(t){if(x(t.groups))for(var e=Object.keys(t.groups),i=0,n=e.length;i<n;i++){var r=e[i];this.groups[r]=this._evaluateGroup(t.groups[r])}for(var o=et(t.items),s=0,a=o.length;s<a;s++)this.ports.push(this._evaluatePort(o[s]))},_evaluateGroup:function(t){return y(t,{position:this._getPosition(t.position,!0),label:this._getLabel(t,!0)})},_evaluatePort:function(t){var e=R({},t),t=this.getGroup(t.group);return e.markup=e.markup||t.markup,e.attrs=y({},t.attrs,e.attrs),e.position=this._createPositionNode(t,e),e.label=y({},t.label,this._getLabel(e)),e.z=this._getZIndex(t,e),e.size=R({},t.size,e.size),e},_getZIndex:function(t,e){return G(e.z)?e.z:G(t.z)||"auto"===t.z?t.z:"auto"},_createPositionNode:function(t,e){return y({name:"left",args:{}},t.position,{args:e.args})},_getPosition:function(t,e){var i,n={},e=(P(t)?(i="fn",n.fn=t):N(t)?i=t:void 0===t?i=e?"left":null:Array.isArray(t)?(i="absolute",n.x=t[0],n.y=t[1]):x(t)&&(i=t.name,R(n,t.args)),{args:n});return i&&(e.name=i),e},_getLabel:function(t,e){var t=t.label||{},i=t;return i.position=this._getPosition(t.position,e),i}},{_initializePorts:function(){this._createPortData(),this.on("change:ports",function(){this._processRemovedPort(),this._createPortData()},this)},_processRemovedPort:function(){var t=this.get("ports")||{},e={},t=(et(t.items).forEach(function(t){e[t.id]=!0}),this.previous("ports")||{}),i={},t=(et(t.items).forEach(function(t){e[t.id]||(i[t.id]=!0)}),this.graph);t&&!gi(i)&&(t.getConnectedLinks(this,{inbound:!0}).forEach(function(t){i[t.get("target").port]&&t.remove()}),t.getConnectedLinks(this,{outbound:!0}).forEach(function(t){i[t.get("source").port]&&t.remove()}))},hasPorts:function(){var t=this.prop("ports/items");return Array.isArray(t)&&0<t.length},hasPort:function(t){return-1!==this.getPortIndex(t)},getPorts:function(){return di(this.prop("ports/items"))||[]},getGroupPorts:function(e){var t=et(this.prop(["ports","items"])).filter(function(t){return t.group===e});return di(t)},getPort:function(e){return di(et(this.prop("ports/items")).find(function(t){return t.id&&t.id===e}))},getPortsPositions:function(t){return this._portSettingsData.getGroupPortsMetrics(t,tt(this.size())).reduce(function(t,e){var i=e.portTransformation;return t[e.portId]={x:i.x,y:i.y,angle:i.angle},t},{})},getPortIndex:function(t){var e=x(t)?t.id:t;return this._isValidPortId(e)?et(this.prop("ports/items")).findIndex(function(t){return t.id===e}):-1},addPort:function(t,e){if(!x(t)||Array.isArray(t))throw new Error("Element: addPort requires an object.");var i=R([],this.prop("ports/items"));return i.push(t),this.prop("ports/items",i,e),this},insertPort:function(t,e,i){t="number"==typeof t?t:this.getPortIndex(t);if(!x(e)||Array.isArray(e))throw new Error("dia.Element: insertPort requires an object.");var n=R([],this.prop("ports/items"));return n.splice(t,0,e),this.prop("ports/items",n,i),this},portProp:function(t,e,i,n){var r=this.getPortIndex(t);if(-1===r)throw new Error("Element: unable to find port with id "+t);t=Array.prototype.slice.call(arguments,1);return Array.isArray(e)?t[0]=["ports","items",r].concat(e):N(e)?t[0]=["ports/items/",r,"/",e].join(""):(t=["ports/items/"+r],fi(e)&&(t.push(e),t.push(i))),this.prop.apply(this,t)},_validatePorts:function(){var t=this.get("ports")||{},e=[],t=et((t||{}).items);return t.forEach(function(t){"object"!=typeof t&&e.push("Element: invalid port ",t),this._isValidPortId(t.id)||(t.id=this.generatePortId())},this),ci(t,"id").length!==t.length&&e.push("Element: found id duplicities in ports."),e},generatePortId:function(){return this.generateId()},_isValidPortId:function(t){return null!=t&&!x(t)},addPorts:function(t,e){return t.length&&this.prop("ports/items",R([],this.prop("ports/items")).concat(t),e),this},removePort:function(t,e){var i,e=e||{},t=this.getPortIndex(t);return-1!==t&&((i=R([],this.prop(["ports","items"]))).splice(t,1),e.rewrite=!0,this.startBatch("port-remove"),this.prop(["ports","items"],i,e),this.stopBatch("port-remove")),this},removePorts:function(t,e){var i;if(Array.isArray(t)){if(i=e||{},0===t.length)return this.this;var n=R([],this.prop(["ports","items"])).filter(function(e){return!t.some(function(t){t=x(t)?t.id:t;return e.id===t})})}else i=t||{},n=[];return this.startBatch("port-remove"),i.rewrite=!0,this.prop(["ports","items"],n,i),this.stopBatch("port-remove"),this},_createPortData:function(){var t,e=this._validatePorts();if(0<e.length)throw this.set("ports",this.previous("ports")),new Error(e.join(" "));this._portSettingsData&&(t=this._portSettingsData.getPorts()),this._portSettingsData=new mn(this.get("ports"));var i,n=this._portSettingsData.getPorts();t&&(e=n.filter(function(e){if(!t.find(function(t){return t.id===e.id}))return e}),0<(i=t.filter(function(e){if(!n.find(function(t){return t.id===e.id}))return e})).length&&this.trigger("ports:remove",this,i),0<e.length&&this.trigger("ports:add",this,e))}}),Ut={portContainerMarkup:"g",portMarkup:[{tagName:"circle",selector:"circle",attributes:{r:10,fill:"#FFFFFF",stroke:"#000000"}}],portLabelMarkup:[{tagName:"text",selector:"text",attributes:{fill:"#000000"}}],_portElementsCache:null,_initializePorts:function(){this._cleanPortsCache()},_refreshPorts:function(){this._removePorts(),this._cleanPortsCache(),this._renderPorts()},_cleanPortsCache:function(){this._portElementsCache={}},_renderPorts:function(){for(var e=[],i=this._getContainerElement(),t=0,n=i.node.childNodes.length;t<n;t++)e.push(i.node.childNodes[t]);for(var r=vi(this.model._portSettingsData.getPorts(),"z"),o=(et(r.auto).forEach(function(t){t=this._getPortElement(t);i.append(t),e.push(t)},this),Object.keys(r)),s=0;s<o.length;s++){var a,l=o[s];"auto"!==l&&(a=parseInt(l,10),this._appendPorts(r[l],a,e))}this._updatePorts()},_getContainerElement:function(){return this.rotatableNode||this.vel},_appendPorts:function(t,e,i){var n=this._getContainerElement(),t=et(t).map(this._getPortElement,this);i[e]||e<0?B(i[Math.max(e,0)]).before(t):n.append(t)},_getPortElement:function(t){return this._portElementsCache[t.id]?this._portElementsCache[t.id].portElement:this._createPortElement(t)},findPortNode:function(t,e){t=this._portElementsCache[t];if(!t)return null;var i=t.portContentElement.node,t=t.portContentSelectors,e=this.findBySelector(e,i,t)[0];return e=void 0===e?null:e},_updatePorts:function(){this._updatePortGroup(void 0),Object.keys(this.model._portSettingsData.groups).forEach(this._updatePortGroup,this)},_removePorts:function(){li(this._portElementsCache,"portElement.remove")},_createPortElement:function(t){var e,i,n,r,o=B(this.portContainerMarkup).addClass("joint-port"),s=this._getPortMarkup(t);if(Array.isArray(s)?(n=1<(n=(c=this.parseDOMJSON(s,o.node)).fragment).childNodes.length?B("g").append(n):B(n.firstChild),r=c.selectors):(n=B(s),Array.isArray(n)&&(n=B("g").append(n))),!n)throw new Error("ElementView: Invalid port markup.");n.attr({port:t.id,"port-group":t.group});var a,l,h,c=this._getPortLabelMarkup(t.label);if(Array.isArray(c)?(a=(s=this.parseDOMJSON(c,o.node)).fragment,s=s.selectors,0<(l=a.childNodes.length)&&(i=s,e=1===l?B(a.firstChild):B("g").append(a))):(e=B(c),Array.isArray(e)&&(e=B("g").append(e))),r&&i){for(var u in i)if(r[u]&&u!==this.selector)throw new Error("ElementView: selectors within port must be unique.");h=R({},r,i)}else h=r||i;return o.append(n.addClass("joint-port-body")),e&&o.append(e.addClass("joint-port-label")),this._portElementsCache[t.id]={portElement:o,portLabelElement:e,portSelectors:h,portLabelSelectors:i,portContentElement:n,portContentSelectors:r},o},_updatePortGroup:function(t){for(var e=tt(this.model.size()),i=this.model._portSettingsData.getGroupPortsMetrics(t,e),n=0,r=i.length;n<r;n++){var o=i[n],s=o.portId,s=this._portElementsCache[s]||{},a=o.portTransformation,l=(this.applyPortTransform(s.portElement,a),this.updateDOMSubtreeAttributes(s.portElement.node,o.portAttrs,{rootBBox:new tt(o.portSize),selectors:s.portSelectors}),o.labelTransformation);l&&s.portLabelElement&&(this.applyPortTransform(s.portLabelElement,l,-a.angle||0),this.updateDOMSubtreeAttributes(s.portLabelElement.node,l.attrs,{rootBBox:new tt(o.labelSize),selectors:s.portLabelSelectors}))}},applyPortTransform:function(t,e,i){i=B.createSVGMatrix().rotate(i||0).translate(e.x||0,e.y||0).rotate(e.angle||0);t.transform(i,{absolute:!0})},_getPortMarkup:function(t){return t.markup||this.model.get("portMarkup")||this.model.portMarkup||this.portMarkup},_getPortLabelMarkup:function(t){return t.markup||this.model.get("portLabelMarkup")||this.model.portLabelMarkup||this.portLabelMarkup}},r=rn.extend({defaults:{position:{x:0,y:0},size:{width:1,height:1},angle:0},initialize:function(){this._initializePorts(),rn.prototype.initialize.apply(this,arguments)},_initializePorts:function(){},_refreshPorts:function(){},isElement:function(){return!0},position:function(t,e,i){var n,r=G(e),o=(i=(r?i:t)||{}).parentRelative,s=i.deep,a=i.restrictedArea;if(o){if(!this.graph)throw new Error("Element must be part of a graph.");var l=this.getParentCell();l&&!l.isLink()&&(n=l.get("position"))}return r?(n&&(t+=n.x,e+=n.y),s||a?(r=(l=this.get("position")).x,s=l.y,this.translate(t-r,e-s,i)):this.set("position",{x:t,y:e},i),this):(a=z(this.get("position")),o?a.difference(n):a)},translate:function(t,e,i){if(e=e||0,0===(t=t||0)&&0===e)return this;(i=i||{}).translateBy=i.translateBy||this.id;var n,r,o=this.get("position")||{x:0,y:0},s=i.restrictedArea,a=(s&&i.translateBy===this.id&&(e="function"==typeof s?(t=(n=s.call(this,o.x+t,o.y+e,i)).x-o.x,n.y-o.y):(n=this.getBBox({deep:!0}),r=o.x-n.x,a=o.y-n.y,r=Math.max(s.x+r,Math.min(s.x+s.width+r-n.width,o.x+t)),s=Math.max(s.y+a,Math.min(s.y+s.height+a-n.height,o.y+e)),t=r-o.x,s-o.y)),{x:o.x+t,y:o.y+e});return i.tx=t,i.ty=e,i.transition?(x(i.transition)||(i.transition={}),this.transition("position",a,R({},i.transition,{valueFunction:ni.object})),li(this.getEmbeddedCells(),"translate",t,e,i)):(this.startBatch("translate",i),this.set("position",a,i),li(this.getEmbeddedCells(),"translate",t,e,i),this.stopBatch("translate",i)),this},size:function(t,e,i){var n=this.get("size");return void 0===t?{width:n.width,height:n.height}:(x(t)&&(i=e,e=(G(t.height)?t:n).height,t=(G(t.width)?t:n).width),this.resize(t,e,i))},resize:function(t,e,i){if(this.startBatch("resize",i=i||{}),i.direction){var n=this.get("size");switch(i.direction){case"left":case"right":e=n.height;break;case"top":case"bottom":t=n.width}var r=Q(this.get("angle")||0),o=this.getBBox();if(r)var s={"top-right":0,right:0,"top-left":1,top:1,"bottom-left":2,left:2,"bottom-right":3,bottom:3}[i.direction],a=o[["bottomLeft","corner","topRight","origin"][s=i.absolute?(s+Math.floor((r+45)/90))%4:s]](),a=z(a).rotate(o.center(),-r),l=Math.sqrt(t*t+e*e)/2,h=s*Math.PI/2,s=(h=(h+=Math.atan(s%2==0?e/t:t/e))-K(r),z.fromPolar(l,h,a)),c=z(s).offset(t/-2,e/-2);else switch(c=o.topLeft(),i.direction){case"top":case"top-right":c.offset(0,o.height-e);break;case"left":case"bottom-left":c.offset(o.width-t,0);break;case"top-left":c.offset(o.width-t,o.height-e)}this.set("size",{width:t,height:e},i),this.position(c.x,c.y,i)}else this.set("size",{width:t,height:e},i);return this.stopBatch("resize",i),this},scale:function(t,e,i,n){t=this.getBBox().scale(t,e,i);return this.startBatch("scale",n),this.position(t.x,t.y,n),this.resize(t.width,t.height,n),this.stopBatch("scale"),this},fitEmbeds:function(t){void 0===t&&(t={});var e=this.graph;if(!e)throw new Error("Element must be part of a graph.");var i=this.getEmbeddedCells().filter(function(t){return t.isElement()});if(0===i.length)return this;this.startBatch("fit-embeds",t),t.deep&&li(i,"fitEmbeds",t);var n=ei(t.padding),r=n.left,o=n.right,s=n.top,n=n.bottom,e=e.getCellsBBox(i),i=e.x,a=e.y,l=e.width,e=e.height;return this.set({position:{x:i-=r,y:a-=s},size:{width:l+=r+o,height:e+=n+s}},t),this.stopBatch("fit-embeds"),this},rotate:function(t,e,i,n){var r,o,s,a;return i?(a=this.getBBox().center(),r=this.get("size"),o=this.get("position"),a.rotate(i,this.get("angle")-t),s=a.x-r.width/2-o.x,a=a.y-r.height/2-o.y,this.startBatch("rotate",{angle:t,absolute:e,origin:i}),this.position(o.x+s,o.y+a,n),this.rotate(t,e,null,n),this.stopBatch("rotate")):this.set("angle",e?t:(this.get("angle")+t)%360,n),this},angle:function(){return Q(this.get("angle")||0)},getBBox:function(t){var e=this.graph,i=this.attributes,n=(t=void 0===t?{}:t).deep,r=t.rotate;if(n&&e)return(n=this.getEmbeddedCells({deep:!0,breadthFirst:!0})).push(this),e.getCellsBBox(n,t);var e=i.angle,n=(void 0===e&&(e=0),i.position),t=n.x,n=n.y,i=i.size,o=i.width,i=i.height,t=new tt(t,n,o,i);return r&&t.rotateAroundCenter(e),t},getPointFromConnectedLink:function(t,e){var i=this.getBBox(),n=i.center(),t=t.get(e);if(!t)return n;e=t.port;if(!e||!this.hasPort(e))return n;t=this.portProp(e,["group"]),t=this.getPortsPositions(t),t=new z(t[e]).offset(i.origin()),e=this.angle();return e&&t.rotate(n,-e),t}}),bn=(R(r.prototype,Di),{}),n=o.View.extend({options:{},theme:null,themeClassNamePrefix:Ie("theme-"),requireSetThemeOverride:!1,defaultTheme:Qe.defaultTheme,children:null,childNodes:null,DETACHABLE:!0,UPDATE_PRIORITY:2,FLAG_INSERT:1<<30,FLAG_REMOVE:1<<29,constructor:function(t){this.requireSetThemeOverride=t&&!!t.theme,this.options=R({},this.options,t),o.View.call(this,t)},initialize:function(){(bn[this.cid]=this).setTheme(this.options.theme||this.defaultTheme),this.init()},unmount:function(){(this.svgElement?this.vel:this.$el).remove()},renderChildren:function(t){var e,i;return(t=t||M(this,"children"))&&(e=this.svgElement,i=B.namespace[e?"svg":"xhtml"],t=Se(t,i),(e?this.vel:this.$el).empty().append(t.fragment),this.childNodes=t.selectors),this},findAttribute:function(t,e){for(var i=e;i&&1===i.nodeType;){var n=i.getAttribute(t);if(n)return n;if(i===this.el)return null;i=i.parentNode}return null},_ensureElement:function(){var t,e,i;this.el?this.setElement(M(this,"el")):(t=M(this,"tagName"),e=R({},M(this,"attributes")),i=R({},M(this,"style")),this.id&&(e.id=M(this,"id")),this.setElement(this._createElement(t)),this._setAttributes(e),this._setStyle(i)),this._ensureElClassName()},_setAttributes:function(t){(this.svgElement?this.vel:this.$el).attr(t)},_setStyle:function(t){this.$el.css(t)},_createElement:function(t){return this.svgElement?document.createElementNS(B.namespace.svg,t):document.createElement(t)},_setElement:function(t){this.$el=t instanceof o.$?t:o.$(t),this.el=this.$el[0],this.svgElement&&(this.vel=B(this.el))},_ensureElClassName:function(){var t,e=M(this,"className");e&&(t=Ie(e),(this.svgElement?this.vel:this.$el).removeClass(e).addClass(t))},init:function(){},onRender:function(){},confirmUpdate:function(){return 0},setTheme:function(t,e){return e=e||{},this.theme&&this.requireSetThemeOverride&&!e.override||(this.removeThemeClassName(),this.addThemeClassName(t),this.onSetTheme(this.theme,t),this.theme=t),this},addThemeClassName:function(t){if(!(t=t||this.theme))return this;t=this.themeClassNamePrefix+t;return(this.svgElement?this.vel:this.$el).addClass(t),this},removeThemeClassName:function(t){t=t||this.theme;t=this.themeClassNamePrefix+t;return(this.svgElement?this.vel:this.$el).removeClass(t),this},onSetTheme:function(t,e){},remove:function(){return this.onRemove(),this.undelegateDocumentEvents(),bn[this.cid]=null,o.View.prototype.remove.apply(this,arguments),this},onRemove:function(){},getEventNamespace:function(){return".joint-event-ns-"+this.cid},delegateElementEvents:function(t,e,i){if(!e)return this;i=i||{};var n,r=this.getEventNamespace();for(n in e){var o=e[n];(o="function"!=typeof o?this[o]:o)&&w(t).on(n+r,i,o.bind(this))}return this},undelegateElementEvents:function(t){return w(t).off(this.getEventNamespace()),this},delegateDocumentEvents:function(t,e){return t=t||M(this,"documentEvents"),this.delegateElementEvents(document,t,e)},undelegateDocumentEvents:function(){return this.undelegateElementEvents(document)},eventData:function(t,e){if(!t)throw new Error("eventData(): event object required.");var i=t.data,n="__"+this.cid+"__";return void 0===e?i&&i[n]||{}:((i=i||(t.data={}))[n]||(i[n]={}),R(i[n],e),this)},stopPropagation:function(t){return this.eventData(t,{propagationStopped:!0}),this},isPropagationStopped:function(t){return!!this.eventData(t).propagationStopped}},{extend:function(){var t=Array.from(arguments),e=t[0]&&R({},t[0])||{},t=t[1]&&R({},t[1])||{},i=e.render||this.prototype&&this.prototype.render||null;return e.render=function(){return"function"==typeof i&&i.apply(this,arguments),this.render.__render__===i&&this.onRender(),this},e.render.__render__=i,o.View.extend.call(this,e,t)}}),At=(!w.event||"dbltap"in w.event.special||(vn=Qe.doubleTapInterval,w.event.special.dbltap={bindType:"touchend",delegateType:"touchend",handle:function(t){for(var e=[],i=arguments.length-1;0<i--;)e[i]=arguments[i+1];var n=t.handleObj,r=t.target,r=w.data(r),o=(new Date).getTime(),s="lastTouch"in r?o-r.lastTouch:0;s<vn&&30<s?(r.lastTouch=null,t.type=n.origType,(s=n.handler).call.apply(s,[this,t].concat(e))):r.lastTouch=o}}),{views:bn,View:n});function wn(t){return t?Array.isArray(t)?t:[t]:[]}var An=n.extend({tagName:"g",svgElement:!0,className:"highlight",HIGHLIGHT_FLAG:1,UPDATE_PRIORITY:3,DETACHABLE:!1,UPDATABLE:!0,MOUNTABLE:!0,cellView:null,nodeSelector:null,node:null,updateRequested:!1,transformGroup:null,requestUpdate:function(t,e){var i=t.paper;this.cellView=t,this.nodeSelector=e,i&&(this.updateRequested=!0,i.requestViewUpdate(this,this.HIGHLIGHT_FLAG,this.UPDATE_PRIORITY))},confirmUpdate:function(){this.updateRequested=!1;var t=this.cellView,e=this.nodeSelector;return this.update(t,e),this.mount(),this.transform(),0},findNode:function(t,e){var i,n,r,o,s;return"string"==typeof(e=void 0===e?null:e)?s=t.findBySelector(e)[0]:fi(e)?(i=t.model.isLink(),void 0===(n=e.label)&&(n=null),r=e.port,o=e.selector,s=i&&null!==n?t.findLabelNode(n,o):!i&&r?t.findPortNode(r,o):t.findBySelector(o)[0]):!e||(s=B.toNode(e))instanceof SVGElement||(s=null),s||null},mount:function(){var t,e=this.MOUNTABLE,i=this.cellView,n=this.el,r=this.options,o=this.transformGroup;e&&!o&&(e=i.vel,o=i.paper,(i=r.layer)?(t=this.transformGroup=B("g").addClass("highlight-transform").append(n),o.getLayerView(i).insertSortedNode(t.node,r.z)):n.parentNode&&!n.nextSibling||e.append(n))},unmount:function(){var t=this.MOUNTABLE,e=this.transformGroup,i=this.vel;t&&(e?(this.transformGroup=null,e.remove()):i.remove())},transform:function(){var t=this.transformGroup,e=this.cellView,i=this.updateRequested;!t||e.model.isLink()||i||(i=e.getRootTranslateMatrix(),e=e.getRootRotateMatrix(),i=i.multiply(e),t.attr("transform",B.matrixToTransformString(i)))},update:function(){var t=this.node,e=this.cellView,i=this.nodeSelector,n=this.updateRequested,r=this.id;n||(n=this.node=this.findNode(e,i),t&&this.unhighlight(e,t),n?(this.highlight(e,n),this.mount()):(this.unmount(),e.notify("cell:highlight:invalid",r,this)))},onRemove:function(){var t=this.node,e=this.cellView,i=this.id,n=this.constructor;t&&this.unhighlight(e,t),this.unmount(),n._removeRef(e,i)},highlight:function(t,e){},unhighlight:function(t,e){}},{_views:{},highlight:function(t,e,i){var n=this.uniqueId(e,i);this.add(t,e,n,i)},unhighlight:function(t,e,i){e=this.uniqueId(e,i);this.remove(t,e)},get:function(t,e){var t=t.cid,i=this._views[t];if(null===(e=void 0===e?null:e)){var n,r=[];if(!i)return r;for(n in i){var o=i[n];o instanceof this&&r.push(o)}return r}if(!i)return null;if(e in i){t=i[e];if(t instanceof this)return t}return null},add:function(t,e,i,n){if(void 0===n&&(n={}),!i)throw new Error("dia.HighlighterView: An ID required.");var r=An.get(t,i),r=(r&&r.remove(),new this(n));return r.id=i,this._addRef(t,i,r),r.requestUpdate(t,e),r},_addRef:function(t,e,i){var t=t.cid,n=this._views;(n[t]||(n[t]={}))[e]=i},_removeRef:function(t,e){var t=t.cid,i=this._views,n=i[t];if(n){for(var r in e&&delete n[e],n)return;delete i[t]}},remove:function(t,e){wn(this.get(t,e=void 0===e?null:e)).forEach(function(t){t.remove()})},update:function(t,e,i){void 0===i&&(i=!1),wn(this.get(t,e=void 0===e?null:e)).forEach(function(t){(i||t.UPDATABLE)&&t.update()})},transform:function(t,e){wn(this.get(t,e=void 0===e?null:e)).forEach(function(t){t.UPDATABLE&&t.transform()})},uniqueId:function(t,e){return void 0===e&&(e=""),B.ensureId(t)+JSON.stringify(e)}}),Cn={DEFAULT:"default",EMBEDDING:"embedding",CONNECTING:"connecting",MAGNET_AVAILABILITY:"magnetAvailability",ELEMENT_AVAILABILITY:"elementAvailability"},c=n.extend({tagName:"g",svgElement:!0,selector:"root",metrics:null,className:function(){var n=["cell"],t=this.model.get("type");return t&&t.toLowerCase().split(".").forEach(function(t,e,i){n.push("type-"+i.slice(0,e+1).join("-"))}),n.join(" ")},_presentationAttributes:null,_flags:null,setFlags:function(){var t,e={},i={},n=0,r=M(this,"presentationAttributes");for(t in r)if(r.hasOwnProperty(t))for(var o=r[t],s=0,a=(o=Array.isArray(o)?o:[o]).length;s<a;s++){var l,h=(h=e[l=o[s]])||(e[l]=1<<n++);i[t]|=h}var c=M(this,"initFlag");for(s=0,a=(c=Array.isArray(c)?c:[c]).length;s<a;s++)e[l=c[s]]||(e[l]=1<<n++);if(25<n)throw new Error("dia.CellView: Maximum number of flags exceeded.");this._flags=e,this._presentationAttributes=i},hasFlag:function(t,e){return t&this.getFlag(e)},removeFlag:function(t,e){return t^t&this.getFlag(e)},getFlag:function(t){var e=this._flags;if(!e)return 0;var i=0;if(Array.isArray(t))for(var n=0,r=t.length;n<r;n++)i|=e[t[n]];else i|=e[t];return i},attributes:function(){var t=this.model;return{"model-id":t.id,"data-type":t.attributes.type}},constructor:function(t){t.id=t.id||De(this),n.call(this,t)},initialize:function(){this.setFlags(),n.prototype.initialize.apply(this,arguments),this.cleanNodesCache(),this.$el.data("view",this),this.startListening()},onMount:function(){},startListening:function(){this.listenTo(this.model,"change",this.onAttributesChange)},onAttributesChange:function(t,e){t=t.getChangeFlag(this._presentationAttributes);!e.updateHandled&&t&&(e.dirty&&this.hasFlag(t,"UPDATE")&&(t|=this.getFlag("RENDER")),e.tool&&(e.async=!1),this.requestUpdate(t,e))},requestUpdate:function(t,e){var i=this.paper;i&&0<t&&i.requestViewUpdate(this,t,this.UPDATE_PRIORITY,e)},parseDOMJSON:function(t,e){var i,t=Se(t),n=t.selectors,r=t.groupSelectors;for(i in r){if(n[i])throw new Error("dia.CellView: ambiguous group selector");n[i]=r[i]}if(e){var o=this.selector;if(n[o])throw new Error("dia.CellView: ambiguous root selector.");n[o]=e}return{fragment:t.fragment,selectors:n}},can:function(t){var e=P(this.options.interactive)?this.options.interactive(this):this.options.interactive;return x(e)&&!1!==e[t]||Ue(e)&&!1!==e},findBySelector:function(t,e,i){if(e=e||this.el,i=i||this.selectors,!t||"."===t)return[e];if(i){i=i[t];if(i)return Array.isArray(i)?i:[i]}return Qe.useCSSSelectors?w(e).find(t).toArray():[]},notify:function(t){var e;this.paper&&(e=Array.prototype.slice.call(arguments,1),this.trigger.apply(this,[t].concat(e)),this.paper.trigger.apply(this.paper,[t,this].concat(e)))},getBBox:function(t){return t=t&&t.useModelGeometry?(t=this.model).getBBox().bbox(t.angle()):this.getNodeBBox(this.el),this.paper.localToPaperRect(t)},getNodeBBox:function(t){var e=this.getNodeBoundingRect(t),t=this.getNodeMatrix(t),i=this.getRootTranslateMatrix(),n=this.getRootRotateMatrix();return B.transformRect(e,i.multiply(n).multiply(t))},getNodeUnrotatedBBox:function(t){var e=this.getNodeBoundingRect(t),t=this.getNodeMatrix(t),i=this.getRootTranslateMatrix();return B.transformRect(e,i.multiply(t))},getRootTranslateMatrix:function(){var t=this.model.position();return B.createSVGMatrix().translate(t.x,t.y)},getRootRotateMatrix:function(){var t,e=B.createSVGMatrix(),i=this.model,n=i.angle();return n&&(t=(i=i.getBBox()).width/2,i=i.height/2,e=e.translate(t,i).rotate(n).translate(-t,-i)),e},_notifyHighlight:function(t,e,i){void 0===i&&(i={});var n,r=this.el,o="string"==typeof e?void 0===(o=this.findBySelector(e)[0])?r:o:void 0===(o=this.$(e)[0])?r:o;if(i.partial=o!==r,void 0===i.type){switch(!0){case i.embedding:n=Cn.EMBEDDING;break;case i.connecting:n=Cn.CONNECTING;break;case i.magnetAvailability:n=Cn.MAGNET_AVAILABILITY;break;case i.elementAvailability:n=Cn.ELEMENT_AVAILABILITY;break;default:n=Cn.DEFAULT}i.type=n}return this.notify(t,o,i),this},highlight:function(t,e){return this._notifyHighlight("cell:highlight",t,e)},unhighlight:function(t,e){return this._notifyHighlight("cell:unhighlight",t,e=void 0===e?{}:e)},findMagnet:function(t){var e=this.el,i=(i=this.$(t)[0])||e;do{var n=i.getAttribute("magnet"),r=i===e;if((n||r)&&"false"!==n)return i;if(r)return}while(i=i.parentNode)},findProxyNode:function(t,e){e=(t=t||this.el).getAttribute(e+"-selector");if(e){e=this.findBySelector(e)[0];if(e)return e}return t},getSelector:function(t,e){var i,n;return t===this.el?"string"==typeof e?"> "+e:n:(t&&(i=B(t).index()+1,n=t.tagName+":nth-child("+i+")",e&&(n+=" > "+e),n=this.getSelector(t.parentNode,n)),n)},addLinkFromMagnet:function(t,e,i){var n=this.paper,r=n.model,o=n.getDefaultLink(this,t);return o.set({source:this.getLinkEnd(t,e,i,o,"source"),target:{x:e,y:i}}).addTo(r,{async:!1,ui:!0}),o.findView(n)},getLinkEnd:function(t){for(var e=[],i=arguments.length-1;0<i--;)e[i]=arguments[i+1];var n=this.model,r=n.id,o=this.findAttribute("port",t),s=t.getAttribute("joint-selector"),r={id:r};return null!=s&&(r.magnet=s),null!=o?(r.port=o,n.hasPort(o)||s||(r.selector=this.getSelector(t))):null==s&&this.el!==t&&(r.selector=this.getSelector(t)),this.customizeLinkEnd.apply(this,[r,t].concat(e))},customizeLinkEnd:function(t,e,i,n,r,o){var s=this.paper,a=s.options.connectionStrategy;if("function"==typeof a){a=a.call(s,t,this,e,new z(i,n),r,o,s);if(a)return a}return t},getMagnetFromLinkEnd:function(t){var e=this.el,i=t.port,n=t.magnet,r=this.model,r=null!=i&&r.isElement()&&r.hasPort(i)?this.findPortNode(i,n)||e:(n=n||t.selector,this.findBySelector(n=n||null==i?n:'[port="'+i+'"]',e,this.selectors)[0]);return this.findProxyNode(r,"magnet")},dragLinkStart:function(t,e,i,n){this.model.startBatch("add-link");e=this.addLinkFromMagnet(e,i,n);e.notifyPointerdown(t,i,n),e.eventData(t,e.startArrowheadMove("target",{whenNotAllowed:"remove"})),this.eventData(t,{linkView:e})},dragLink:function(t,e,i){var n=this.eventData(t),r=n.linkView;if(r)r.pointermove(t,e,i);else{var r=this.paper,o=r.options.magnetThreshold,s=this.getEventTarget(t),n=n.targetMagnet;if("onleave"===o){if(n===s||B(n).contains(s))return}else if(r.eventData(t).mousemoved<=o)return;this.dragLinkStart(t,n,e,i)}},dragLinkEnd:function(t,e,i){var n=this.eventData(t).linkView;n&&(n.pointerup(t,e,i),this.model.stopBatch("add-link"))},getAttributeDefinition:function(t){return this.model.constructor.getAttributeDefinition(t)},setNodeAttributes:function(t,e){gi(e)||(t instanceof SVGElement?B:w)(t).attr(e)},processNodeAttributes:function(t,e){var i,n,r,o,s,a,l,h,c,u=[];for(i in e)e.hasOwnProperty(i)&&(n=e[i],!(r=this.getAttributeDefinition(i))||P(r.qualify)&&!r.qualify.call(this,n,t,e)?(a=a||{})[Be(i)]=n:(N(r.set)&&((a=a||{})[r.set]=n),null!==n&&u.push(i,r)));for(o=0,s=u.length;o<s;o+=2)i=u[o],r=u[o+1],n=e[i],P(r.set)&&((l=l||{})[i]=n),P(r.position)&&((h=h||{})[i]=n),P(r.offset)&&((c=c||{})[i]=n);return{raw:e,normal:a,set:l,position:h,offset:c}},updateRelativeAttributes:function(t,e,i,n){n=n||{};var r,o=e.raw||{},s=e.normal||{},a=e.set,l=e.position,h=e.offset;for(r in a){var c=a[r],u=this.getAttributeDefinition(r).set.call(this,c,i.clone(),t,o);x(u)?R(s,u):void 0!==u&&(s[r]=u)}if(t instanceof HTMLElement)this.setNodeAttributes(t,s);else{var d,g,p,e=s.transform,f=B.transformStringToMatrix(e),m=z(f.e,f.f),v=(e&&(s=Si(s,"transform"),f.e=f.f=0),(l||h)&&(g=(n=this.getNodeScale(t,n.scalableNode)).sx,p=n.sy),!1);for(r in l)c=l[r],(d=this.getAttributeDefinition(r).position.call(this,c,i.clone(),t,o))&&(m.offset(z(d).scale(g,p)),v=v||!0);this.setNodeAttributes(t,s);var y=!1;if(h){n=this.getNodeBoundingRect(t);if(0<n.width&&0<n.height){var b=B.transformRect(n,f).scale(1/g,1/p);for(r in h)c=h[r],(d=this.getAttributeDefinition(r).offset.call(this,c,b,t,o))&&(m.offset(z(d).scale(g,p)),y=y||!0)}}(void 0!==e||v||y)&&(m.round(1),f.e=m.x,f.f=m.y,t.setAttribute("transform",B.matrixToTransformString(f)))}},getNodeScale:function(t,e){var i;return e=e&&e.contains(t)?(i=1/(t=e.scale()).sx,1/t.sy):i=1,{sx:i,sy:e}},cleanNodesCache:function(){this.metrics={}},nodeCache:function(t){var e=this.metrics;if(!e)return{};t=B.ensureId(t);return e[t]||(e[t]={})},getNodeData:function(t){t=this.nodeCache(t);return t.data||(t.data={}),t.data},getNodeBoundingRect:function(t){var e=this.nodeCache(t);return void 0===e.boundingRect&&(e.boundingRect=B(t).getBBox()),new tt(e.boundingRect)},getNodeMatrix:function(t){var e,i=this.nodeCache(t);return void 0===i.magnetMatrix&&(e=this.rotatableNode||this.el,i.magnetMatrix=B(t).getTransformToElement(e)),B.createSVGMatrix(i.magnetMatrix)},getNodeShape:function(t){var e=this.nodeCache(t);return void 0===e.geometryShape&&(e.geometryShape=B(t).toGeometryShape()),e.geometryShape.clone()},isNodeConnection:function(t){return this.model.isLink()&&(!t||t===this.el)},findNodesAttributes:function(t,e,i,n){var r,o,s={},a=[];for(o in t)if(t.hasOwnProperty(o)&&(r=t[o],fi(r)))for(var l=i[o]=this.findBySelector(o,e,n),h=0,c=l.length;h<c;h++){var u,d,g=l[h],p=B.ensureId(g),f=n&&n[o]===g,m=s[p];m?(m.array||(a.push(p),m.array=!0,m.attributes=[m.attributes],m.selectedLength=[m.selectedLength]),u=m.attributes,m=m.selectedLength,f?(u.unshift(r),m.unshift(-1)):(d=hi(m,c),u.splice(d,0,r),m.splice(d,0,c))):s[p]={attributes:r,selectedLength:f?-1:c,node:g,array:!1}}for(h=0,c=a.length;h<c;h++)(r=s[p=a[h]]).attributes=y.apply(void 0,[{}].concat(r.attributes.reverse()));return s},getEventTarget:function(t,e){var i=t.target,n=t.type,r=t.clientX,t=(void 0===r&&(r=0),t.clientY);return void 0===t&&(t=0),(e=void 0===e?{}:e).fromPoint||"touchmove"===n||"touchend"===n?document.elementFromPoint(r,t):i},updateDOMSubtreeAttributes:function(t,e,i){(i=i||{}).rootBBox||(i.rootBBox=tt()),i.selectors||(i.selectors=this.selectors);var n,r,o,s={},a={},l=[],h=[],c=i.roAttributes,u=this.findNodesAttributes(c||e,t,s,i.selectors),d=c?this.findNodesAttributes(e,t,s,i.selectors):u;for(r in u)if(p=(g=u[r]).attributes,b=g.node,(n=this.processNodeAttributes(b,p)).set||n.position||n.offset){var g=d[r]&&d[r].attributes,p=(g&&void 0===p.ref?g:p).ref;if(p){if(!(w=(s[p]||this.findBySelector(p,t,i.selectors))[0]))throw new Error('dia.CellView: "'+p+'" reference does not exist.')}else w=null;v={node:b,refNode:w,processedAttributes:n,allAttributes:g},w?-1<(p=h.findIndex(function(t){return t.refNode===b}))?h.splice(p,0,v):h.push(v):l.push(v)}else this.setNodeAttributes(b,n.normal);l.push.apply(l,h);for(var f=0,m=l.length;f<m;f++){var v,y,b=(v=l[f]).node,w=v.refNode,A=B(i.rotatableNode),C=w?B.ensureId(w):"",I=!!A&&!!w&&A.contains(w),x=a[C],C=(x||(y=I?A:t,x=a[C]=w?B(w).getBBox({target:y}):i.rootBBox),c?(n=this.processNodeAttributes(b,v.allAttributes),this.mergeProcessedAttributes(n,v.processedAttributes)):n=v.processedAttributes,x);I&&!A.contains(b)&&(o=o||B.transformStringToMatrix(A.attr("transform")),C=B.transformRect(x,o)),this.updateRelativeAttributes(b,n,C,i)}},mergeProcessedAttributes:function(t,e){t.set||(t.set={}),t.position||(t.position={}),t.offset||(t.offset={}),R(t.set,e.set),R(t.position,e.position),R(t.offset,e.offset);var i=t.normal&&t.normal.transform;void 0!==i&&e.normal&&(e.normal.transform=i),t.normal=e.normal},onRemove:function(){this.removeTools(),this.removeHighlighters()},_toolsView:null,hasTools:function(t){var e=this._toolsView;return!!e&&(!t||e.getName()===t)},addTools:function(t){return this.removeTools(),t&&((this._toolsView=t).configure({relatedView:this}),t.listenTo(this.paper,"tools:event",this.onToolEvent.bind(this))),this},updateTools:function(t){var e=this._toolsView;return e&&e.update(t),this},removeTools:function(){var t=this._toolsView;return t&&(t.remove(),this._toolsView=null),this},hideTools:function(){var t=this._toolsView;return t&&t.hide(),this},showTools:function(){var t=this._toolsView;return t&&t.show(),this},onToolEvent:function(t){switch(t){case"remove":this.removeTools();break;case"hide":this.hideTools();break;case"show":this.showTools()}},removeHighlighters:function(){An.remove(this)},updateHighlighters:function(t){An.update(this,null,t=void 0===t?!1:t)},transformHighlighters:function(){An.transform(this)},pointerdblclick:function(t,e,i){this.notify("cell:pointerdblclick",t,e,i)},pointerclick:function(t,e,i){this.notify("cell:pointerclick",t,e,i)},contextmenu:function(t,e,i){this.notify("cell:contextmenu",t,e,i)},pointerdown:function(t,e,i){var n=this.model,r=n.graph;r&&(n.startBatch("pointer"),this.eventData(t,{graph:r})),this.notify("cell:pointerdown",t,e,i)},pointermove:function(t,e,i){this.notify("cell:pointermove",t,e,i)},pointerup:function(t,e,i){var n=this.eventData(t).graph;this.notify("cell:pointerup",t,e,i),n&&n.stopBatch("pointer",{cell:this.model})},mouseover:function(t){this.notify("cell:mouseover",t)},mouseout:function(t){this.notify("cell:mouseout",t)},mouseenter:function(t){this.notify("cell:mouseenter",t)},mouseleave:function(t){this.notify("cell:mouseleave",t)},mousewheel:function(t,e,i,n){this.notify("cell:mousewheel",t,e,i,n)},onevent:function(t,e,i,n){this.notify(e,t,i,n)},onmagnet:function(){},magnetpointerdblclick:function(){},magnetcontextmenu:function(){},checkMouseleave:function(t){var e=this.paper,i=(e.isAsync()&&e.dumpView(this),this.getEventTarget(t,{fromPoint:!0})),e=e.findView(i);e!==this&&(this.mouseleave(t),e&&e.mouseenter(t))},setInteractivity:function(t){this.options.interactive=t}},{Highlighting:Cn,addPresentationAttributes:function(t){return y({},M(this.prototype,"presentationAttributes"),t,function(t,e){if(t&&e)return"string"==typeof t&&(t=[t]),"string"==typeof e&&(e=[e]),Array.isArray(t)&&Array.isArray(e)?ci(t.concat(e)):void 0})}}),l={UPDATE:"UPDATE",TRANSLATE:"TRANSLATE",TOOLS:"TOOLS",RESIZE:"RESIZE",PORTS:"PORTS",ROTATE:"ROTATE",RENDER:"RENDER"},g=c.extend({_removePorts:function(){},_renderPorts:function(){},className:function(){var t=c.prototype.className.apply(this).split(" ");return t.push("element"),t.join(" ")},initialize:function(){c.prototype.initialize.apply(this,arguments),this._initializePorts()},presentationAttributes:{attrs:[l.UPDATE],position:[l.TRANSLATE,l.TOOLS],size:[l.RESIZE,l.PORTS,l.TOOLS],angle:[l.ROTATE,l.TOOLS],markup:[l.RENDER],ports:[l.PORTS]},initFlag:[l.RENDER],UPDATE_PRIORITY:0,confirmUpdate:function(t,e){var i,n=Qe.useCSSSelectors,r=(this.hasFlag(t,l.PORTS)&&(this._removePorts(),this._cleanPortsCache()),!1);return this.hasFlag(t,l.RENDER)?(this.render(),this.updateTools(e),this.updateHighlighters(!0),r=!0,t=this.removeFlag(t,[l.RENDER,l.UPDATE,l.RESIZE,l.TRANSLATE,l.ROTATE,l.PORTS,l.TOOLS])):(i=!1,this.hasFlag(t,l.RESIZE)&&(this.resize(e),i=!0,t=this.removeFlag(t,[l.RESIZE,l.UPDATE])),this.hasFlag(t,l.UPDATE)&&(this.update(this.model,null,e),t=this.removeFlag(t,l.UPDATE),i=!0,n&&(t=this.removeFlag(t,l.PORTS))),this.hasFlag(t,l.TRANSLATE)&&(this.translate(),t=this.removeFlag(t,l.TRANSLATE),r=!0),this.hasFlag(t,l.ROTATE)&&(this.rotate(),t=this.removeFlag(t,l.ROTATE),r=!0),this.hasFlag(t,l.PORTS)&&(this._renderPorts(),i=!0,t=this.removeFlag(t,l.PORTS)),i&&this.updateHighlighters(!1)),r&&this.transformHighlighters(),this.hasFlag(t,l.TOOLS)&&(this.updateTools(e),t=this.removeFlag(t,l.TOOLS)),t},_initializePorts:function(){},update:function(t,e){this.cleanNodesCache();var i=Qe.useCSSSelectors,n=(i&&this._removePorts(),this.model),r=n.attr();this.updateDOMSubtreeAttributes(this.el,r,{rootBBox:new tt(n.size()),selectors:this.selectors,scalableNode:this.scalableNode,rotatableNode:this.rotatableNode,roAttributes:e===r?null:e}),i&&this._renderPorts()},rotatableSelector:"rotatable",scalableSelector:"scalable",scalableNode:null,rotatableNode:null,renderMarkup:function(){var t=this.model,t=t.get("markup")||t.markup;if(!t)throw new Error("dia.ElementView: markup required");if(Array.isArray(t))return this.renderJSONMarkup(t);if("string"==typeof t)return this.renderStringMarkup(t);throw new Error("dia.ElementView: invalid markup")},renderJSONMarkup:function(t){var t=this.parseDOMJSON(t,this.el),e=this.selectors=t.selectors;this.rotatableNode=B(e[this.rotatableSelector])||null,this.scalableNode=B(e[this.scalableSelector])||null,this.vel.append(t.fragment)},renderStringMarkup:function(t){var e=this.vel;e.append(B(t)),this.rotatableNode=e.findOne(".rotatable"),this.scalableNode=e.findOne(".scalable"),(this.selectors={})[this.selector]=this.el},render:function(){return this.vel.empty(),this.renderMarkup(),this.scalableNode&&this.update(),this.resize(),this.rotatableNode?(this.rotate(),this.translate()):this.updateTransformation(),Qe.useCSSSelectors||this._renderPorts(),this},resize:function(t){if(this.scalableNode)return this.sgResize(t);this.model.attributes.angle&&this.rotate(),this.update()},translate:function(){if(this.rotatableNode)return this.rgTranslate();this.updateTransformation()},rotate:function(){if(this.rotatableNode)return this.rgRotate(),void this.update();this.updateTransformation()},updateTransformation:function(){var t=this.getTranslateString(),e=this.getRotateString();e&&(t+=" "+e),this.vel.attr("transform",t)},getTranslateString:function(){var t=this.model.attributes.position;return"translate("+t.x+","+t.y+")"},getRotateString:function(){var t=this.model.attributes,e=t.angle;if(!e)return null;t=t.size;return"rotate("+e+","+t.width/2+","+t.height/2+")"},rgRotate:function(){this.rotatableNode.attr("transform",this.getRotateString())},rgTranslate:function(){this.vel.attr("transform",this.getTranslateString())},sgResize:function(t){var e=this.model,i=e.angle(),n=e.size(),r=this.scalableNode,o=!1,o=(0<r.node.getElementsByTagName("path").length&&(o=!0),r.getBBox({recursive:o})),s=n.width/(o.width||1),o=n.height/(o.height||1),s=(r.attr("transform","scale("+s+","+o+")"),this.rotatableNode),o=s&&s.attr("transform");o&&(s.attr("transform",o+" rotate("+-i+","+n.width/2+","+n.height/2+")"),s=r.getBBox({target:this.paper.cells}),e.set("position",{x:s.x,y:s.y},R({updateHandled:!0},t)),this.translate(),this.rotate()),this.update()},prepareEmbedding:function(t){var e=(t=void 0===t?{}:t).model||this.model,i=(t.paper||this.paper).model,n=t.initialZIndices={},r=e.getEmbeddedCells({deep:!0}),o=i.getConnectedLinks(e,{deep:!0,includeEnclosed:!0}),s=([e].concat(r,o).forEach(function(t){return n[t.id]=t.attributes.z}),e.startBatch("to-front"),e.toFront({deep:!0,ui:!0}),i.getElements().reduce(function(t,e){return Math.max(t,e.attributes.z||0)},0)),r=(o.forEach(function(t){t.attributes.z<=s&&t.set("z",s+1,{ui:!0})}),e.stopBatch("to-front"),e.parent());r?(i.getCell(r).unembed(e,{ui:!0}),t.initialParentId=r):t.initialParentId=null},processEmbedding:function(t,e,i,n){var r=(t=void 0===t?{}:t).model||this.model,o=t.paper||this.paper,s=o.model,a=o.options,l=a.findParentBy,h=a.frontParentOnly,c=a.validateEmbedding,u=P(l)?et(l.call(s,this,e,i,n)):"pointer"===l?et(s.findModelsFromPoint({x:i,y:n})):s.findModelsUnderElement(r,{searchBy:l});u=u.filter(function(t){return t instanceof rn&&r.id!==t.id&&!t.isEmbeddedIn(r)}),h&&(u=u.slice(-1));for(var d=null,g=t.candidateEmbedView,p=u.length-1;0<=p;p--){var f=u[p];if(g&&g.model.id==f.id){d=g;break}f=f.findView(o);if(!P(c)||c.call(o,this,f)){d=f;break}}d&&d!=g&&(this.clearEmbedding(t),t.candidateEmbedView=d.highlight(d.findProxyNode(null,"container"),{embedding:!0})),!d&&g&&this.clearEmbedding(t)},clearEmbedding:function(t){var e=(t=t||{}).candidateEmbedView;e&&(e.unhighlight(e.findProxyNode(null,"container"),{embedding:!0}),t.candidateEmbedView=null)},finalizeEmbedding:function(t){var e=(t=void 0===t?{}:t).candidateEmbedView,i=t.model||this.model,n=t.paper||this.paper;if(e)e.model.embed(i,{ui:!0}),e.unhighlight(e.findProxyNode(null,"container"),{embedding:!0}),t.candidateEmbedView=null;else{e=n.options.validateUnembedding;if(t.initialParentId&&"function"==typeof e&&!e.call(n,this))return void this._disallowUnembed(t)}n.model.getConnectedLinks(i,{deep:!0}).forEach(function(t){t.reparent({ui:!0})})},_disallowUnembed:function(t){var e=t.model,i=t.whenNotAllowed,n=e||this.model,r=(t.paper||this.paper).model;switch(i=void 0===i?"revert":i){case"remove":n.remove({ui:!0});break;case"revert":var o=t.initialParentId,s=t.initialPosition,a=t.initialZIndices,l=(s&&(l=s.x,s=s.y,n.position(l,s,{deep:!0,ui:!0})),a&&Object.keys(a).forEach(function(t){var e=r.getCell(t);e&&e.set("z",a[t],{ui:!0})}),r.getCell(o));l&&l.embed(n,{ui:!0})}},getDelegatedView:function(){for(var t=this,e=t.model,i=t.paper;t&&!e.isLink();){if(!e.isEmbedded()||t.can("stopDelegation"))return t;e=e.getParentCell(),t=i.findViewByModel(e)}return null},findProxyNode:function(t,e){e=(t=t||this.el).getAttribute(e+"-selector");if(e){var i=this.findAttribute("port",t);if(i){i=this.findPortNode(i,e);if(i)return i}else{i=this.findBySelector(e)[0];if(i)return i}}return t},notifyPointerdown:function(t,e,i){c.prototype.pointerdown.call(this,t,e,i),this.notify("element:pointerdown",t,e,i)},notifyPointermove:function(t,e,i){c.prototype.pointermove.call(this,t,e,i),this.notify("element:pointermove",t,e,i)},notifyPointerup:function(t,e,i){this.notify("element:pointerup",t,e,i),c.prototype.pointerup.call(this,t,e,i)},pointerdblclick:function(t,e,i){c.prototype.pointerdblclick.apply(this,arguments),this.notify("element:pointerdblclick",t,e,i)},pointerclick:function(t,e,i){c.prototype.pointerclick.apply(this,arguments),this.notify("element:pointerclick",t,e,i)},contextmenu:function(t,e,i){c.prototype.contextmenu.apply(this,arguments),this.notify("element:contextmenu",t,e,i)},pointerdown:function(t,e,i){this.isPropagationStopped(t)||(this.notifyPointerdown(t,e,i),this.dragStart(t,e,i))},pointermove:function(t,e,i){var n=this.eventData(t);switch(n.action){case"magnet":this.dragMagnet(t,e,i);break;case"move":(n.delegatedView||this).drag(t,e,i);default:this.notifyPointermove(t,e,i)}this.eventData(t,n)},pointerup:function(t,e,i){var n=this.eventData(t);switch(n.action){case"magnet":this.dragMagnetEnd(t,e,i);break;case"move":(n.delegatedView||this).dragEnd(t,e,i);default:this.notifyPointerup(t,e,i)}var r=n.targetMagnet;r&&this.magnetpointerclick(t,r,e,i),this.checkMouseleave(t)},mouseover:function(t){c.prototype.mouseover.apply(this,arguments),this.notify("element:mouseover",t)},mouseout:function(t){c.prototype.mouseout.apply(this,arguments),this.notify("element:mouseout",t)},mouseenter:function(t){c.prototype.mouseenter.apply(this,arguments),this.notify("element:mouseenter",t)},mouseleave:function(t){c.prototype.mouseleave.apply(this,arguments),this.notify("element:mouseleave",t)},mousewheel:function(t,e,i,n){c.prototype.mousewheel.apply(this,arguments),this.notify("element:mousewheel",t,e,i,n)},onmagnet:function(t,e,i){this.dragMagnetStart(t,e,i)},magnetpointerdblclick:function(t,e,i,n){this.notify("element:magnet:pointerdblclick",t,e,i,n)},magnetcontextmenu:function(t,e,i,n){this.notify("element:magnet:contextmenu",t,e,i,n)},dragStart:function(t,e,i){var n,r=this.getDelegatedView();r&&r.can("elementMove")&&(this.eventData(t,{action:"move",delegatedView:r}),n=r.model.position(),r.eventData(t,{initialPosition:n,pointerOffset:n.difference(e,i),restrictedArea:this.paper.getRestrictedArea(r,e,i)}))},dragMagnetStart:function(t,e,i){var n,r;this.can("addLinkFromMagnet")&&(n=t.currentTarget,r=this.paper,this.eventData(t,{targetMagnet:n}),t.stopPropagation(),r.options.validateMagnet(this,n,t)?(r.options.magnetThreshold<=0&&this.dragLinkStart(t,n,e,i),this.eventData(t,{action:"magnet"}),this.stopPropagation(t)):this.pointerdown(t,e,i),r.delegateDragEvents(this,t.data))},drag:function(t,e,i){var n=this.paper,r=n.options.gridSize,o=this.model,s=this.eventData(t),a=s.pointerOffset,l=s.restrictedArea,h=s.embedding,c=E(e+a.x,r),a=E(i+a.y,r);o.position(c,a,{restrictedArea:l,deep:!0,ui:!0}),n.options.embeddingMode&&(h||(this.prepareEmbedding(s),h=!0),this.processEmbedding(s,t,e,i)),this.eventData(t,{embedding:h})},dragMagnet:function(t,e,i){this.dragLink(t,e,i)},dragEnd:function(t,e,i){t=this.eventData(t);t.embedding&&this.finalizeEmbedding(t)},dragMagnetEnd:function(t,e,i){this.dragLinkEnd(t,e,i)},magnetpointerclick:function(t,e,i,n){var r=this.paper;r.eventData(t).mousemoved>r.options.clickThreshold||this.notify("element:magnet:pointerclick",t,e,i,n)}},{Flags:l}),In=(R(g.prototype,Ut),{_results:{},_tests:{svgforeignobject:function(){return!!document.createElementNS&&/SVGForeignObject/.test({}.toString.call(document.createElementNS("http://www.w3.org/2000/svg","foreignObject")))}},addTest:function(t,e){return this._tests[t]=e},test:function(t){var e=this._tests[t];if(!e)throw new Error('Test not defined ("'+t+'"). Use `joint.env.addTest(name, fn) to add a new test.`');var i=this._results[t];if(void 0!==i)return i;try{i=e()}catch(t){i=!1}return this._results[t]=i}}),h=r.define("basic.Generic",{attrs:{".":{fill:"#ffffff",stroke:"none"}}}),Ft=h.define("basic.Rect",{attrs:{rect:{fill:"#ffffff",stroke:"#000000",width:100,height:60},text:{fill:"#000000",text:"","font-size":14,"ref-x":.5,"ref-y":.5,"text-anchor":"middle","y-alignment":"middle","font-family":"Arial, helvetica, sans-serif"}}},{markup:'<g class="rotatable"><g class="scalable"><rect/></g><text/></g>'}),Di=g.extend({presentationAttributes:g.addPresentationAttributes({attrs:["SCALE"]}),confirmUpdate:function(){var t=g.prototype.confirmUpdate.apply(this,arguments);return this.hasFlag(t,"SCALE")&&(this.resize(),t=this.removeFlag(t,"SCALE")),t}}),Ut=h.define("basic.Text",{attrs:{text:{"font-size":18,fill:"#000000"}}},{markup:'<g class="rotatable"><g class="scalable"><text/></g></g>'}),xn=h.define("basic.Circle",{size:{width:60,height:60},attrs:{circle:{fill:"#ffffff",stroke:"#000000",r:30,cx:30,cy:30},text:{"font-size":14,text:"","text-anchor":"middle","ref-x":.5,"ref-y":.5,"y-alignment":"middle",fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:'<g class="rotatable"><g class="scalable"><circle/></g><text/></g>'}),Sn=h.define("basic.Ellipse",{size:{width:60,height:40},attrs:{ellipse:{fill:"#ffffff",stroke:"#000000",rx:30,ry:20,cx:30,cy:20},text:{"font-size":14,text:"","text-anchor":"middle","ref-x":.5,"ref-y":.5,"y-alignment":"middle",fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:'<g class="rotatable"><g class="scalable"><ellipse/></g><text/></g>'}),Pn=h.define("basic.Polygon",{size:{width:60,height:40},attrs:{polygon:{fill:"#ffffff",stroke:"#000000"},text:{"font-size":14,text:"","text-anchor":"middle","ref-x":.5,"ref-dy":20,"y-alignment":"middle",fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:'<g class="rotatable"><g class="scalable"><polygon/></g><text/></g>'}),Mn=h.define("basic.Polyline",{size:{width:60,height:40},attrs:{polyline:{fill:"#ffffff",stroke:"#000000"},text:{"font-size":14,text:"","text-anchor":"middle","ref-x":.5,"ref-dy":20,"y-alignment":"middle",fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:'<g class="rotatable"><g class="scalable"><polyline/></g><text/></g>'}),kn=h.define("basic.Image",{attrs:{text:{"font-size":14,text:"","text-anchor":"middle","ref-x":.5,"ref-dy":20,"y-alignment":"middle",fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:'<g class="rotatable"><g class="scalable"><image/></g><text/></g>'}),Nn=h.define("basic.Path",{size:{width:60,height:60},attrs:{path:{fill:"#ffffff",stroke:"#000000"},text:{"font-size":14,text:"","text-anchor":"middle",ref:"path","ref-x":.5,"ref-dy":10,fill:"#000000","font-family":"Arial, helvetica, sans-serif"}}},{markup:'<g class="rotatable"><g class="scalable"><path/></g><text/></g>'}),Tn=Nn.define("basic.Rhombus",{attrs:{path:{d:"M 30 0 L 60 30 30 60 0 30 z"},text:{"ref-y":.5,"ref-dy":null,"y-alignment":"middle"}}}),Ln=In.test("svgforeignobject"),En=h.define("basic.TextBlock",{attrs:{rect:{fill:"#ffffff",stroke:"#000000",width:80,height:100},text:{fill:"#000000","font-size":14,"font-family":"Arial, helvetica, sans-serif"},".content":{text:"","ref-x":.5,"ref-y":.5,"y-alignment":"middle","x-alignment":"middle"}},content:""},{markup:['<g class="rotatable">','<g class="scalable"><rect/></g>',Ln?'<foreignObject class="fobj"><body xmlns="http://www.w3.org/1999/xhtml"><div class="content"/></body></foreignObject>':'<text class="content"/>',"</g>"].join(""),initialize:function(){this.listenTo(this,"change:size",this.updateSize),this.listenTo(this,"change:content",this.updateContent),this.updateSize(this,this.get("size")),this.updateContent(this,this.get("content")),h.prototype.initialize.apply(this,arguments)},updateSize:function(t,e){this.attr({".fobj":R({},e),div:{style:R({},e)}})},updateContent:function(t,e){Ln?this.attr({".content":{html:Oe(e)}}):this.attr({".content":{text:e}})},setForeignObjectSize:function(){this.updateSize.apply(this,arguments)},setDivContent:function(){this.updateContent.apply(this,arguments)}}),Dn=g.extend({presentationAttributes:Ln?g.prototype.presentationAttributes:g.addPresentationAttributes({content:["CONTENT"],size:["CONTENT"]}),initFlag:["RENDER","CONTENT"],confirmUpdate:function(){var t=g.prototype.confirmUpdate.apply(this,arguments);return this.hasFlag(t,"CONTENT")&&(this.updateContent(this.model),t=this.removeFlag(t,"CONTENT")),t},update:function(t,e){var i,n=this.model;Ln?g.prototype.update.call(this,n,e):(i=Si(e||n.get("attrs"),".content"),g.prototype.update.call(this,n,i),e&&!xi(e,".content")||this.updateContent(n,e))},updateContent:function(t,e){var e=y({},(e||t.get("attrs"))[".content"]),e=Si(e,"text"),i=ze(t.get("content"),t.get("size"),e,{svgDocument:this.paper.svg}),e=Ne({},".content",e,"/");e[".content"].text=i,g.prototype.update.call(this,t,e)}}),Ft={Generic:h,Rect:Ft,TextView:Di,Text:Ut,Circle:xn,Ellipse:Sn,Polygon:Pn,Polyline:Mn,Image:kn,Path:Nn,Rhombus:Tn,TextBlock:En,TextBlockView:Dn},u=rn.extend({markup:['<path class="connection" stroke="black" d="M 0 0 0 0"/>','<path class="marker-source" fill="black" stroke="black" d="M 0 0 0 0"/>','<path class="marker-target" fill="black" stroke="black" d="M 0 0 0 0"/>','<path class="connection-wrap" d="M 0 0 0 0"/>','<g class="labels"/>','<g class="marker-vertices"/>','<g class="marker-arrowheads"/>','<g class="link-tools"/>'].join(""),toolMarkup:['<g class="link-tool">','<g class="tool-remove" event="remove">','<circle r="11" />','<path transform="scale(.8) translate(-16, -16)" d="M24.778,21.419 19.276,15.917 24.777,10.415 21.949,7.585 16.447,13.087 10.945,7.585 8.117,10.415 13.618,15.917 8.116,21.419 10.946,24.248 16.447,18.746 21.948,24.248z" />',"<title>Remove link.</title>","</g>",'<g class="tool-options" event="link:options">','<circle r="11" transform="translate(25)"/>','<path fill="white" transform="scale(.55) translate(29, -16)" d="M31.229,17.736c0.064-0.571,0.104-1.148,0.104-1.736s-0.04-1.166-0.104-1.737l-4.377-1.557c-0.218-0.716-0.504-1.401-0.851-2.05l1.993-4.192c-0.725-0.91-1.549-1.734-2.458-2.459l-4.193,1.994c-0.647-0.347-1.334-0.632-2.049-0.849l-1.558-4.378C17.165,0.708,16.588,0.667,16,0.667s-1.166,0.041-1.737,0.105L12.707,5.15c-0.716,0.217-1.401,0.502-2.05,0.849L6.464,4.005C5.554,4.73,4.73,5.554,4.005,6.464l1.994,4.192c-0.347,0.648-0.632,1.334-0.849,2.05l-4.378,1.557C0.708,14.834,0.667,15.412,0.667,16s0.041,1.165,0.105,1.736l4.378,1.558c0.217,0.715,0.502,1.401,0.849,2.049l-1.994,4.193c0.725,0.909,1.549,1.733,2.459,2.458l4.192-1.993c0.648,0.347,1.334,0.633,2.05,0.851l1.557,4.377c0.571,0.064,1.148,0.104,1.737,0.104c0.588,0,1.165-0.04,1.736-0.104l1.558-4.377c0.715-0.218,1.399-0.504,2.049-0.851l4.193,1.993c0.909-0.725,1.733-1.549,2.458-2.458l-1.993-4.193c0.347-0.647,0.633-1.334,0.851-2.049L31.229,17.736zM16,20.871c-2.69,0-4.872-2.182-4.872-4.871c0-2.69,2.182-4.872,4.872-4.872c2.689,0,4.871,2.182,4.871,4.872C20.871,18.689,18.689,20.871,16,20.871z"/>',"<title>Link options.</title>","</g>","</g>"].join(""),doubleToolMarkup:void 0,vertexMarkup:['<g class="marker-vertex-group" transform="translate(<%= x %>, <%= y %>)">','<circle class="marker-vertex" idx="<%= idx %>" r="10" />','<path class="marker-vertex-remove-area" idx="<%= idx %>" d="M16,5.333c-7.732,0-14,4.701-14,10.5c0,1.982,0.741,3.833,2.016,5.414L2,25.667l5.613-1.441c2.339,1.317,5.237,2.107,8.387,2.107c7.732,0,14-4.701,14-10.5C30,10.034,23.732,5.333,16,5.333z" transform="translate(5, -33)"/>','<path class="marker-vertex-remove" idx="<%= idx %>" transform="scale(.8) translate(9.5, -37)" d="M24.778,21.419 19.276,15.917 24.777,10.415 21.949,7.585 16.447,13.087 10.945,7.585 8.117,10.415 13.618,15.917 8.116,21.419 10.946,24.248 16.447,18.746 21.948,24.248z">',"<title>Remove vertex.</title>","</path>","</g>"].join(""),arrowheadMarkup:['<g class="marker-arrowhead-group marker-arrowhead-group-<%= end %>">','<path class="marker-arrowhead" end="<%= end %>" d="M 26 0 L 0 13 L 26 26 z" />',"</g>"].join(""),defaultLabel:void 0,labelMarkup:void 0,_builtins:{defaultLabel:{markup:[{tagName:"rect",selector:"rect"},{tagName:"text",selector:"text"}],attrs:{text:{fill:"#000000",fontSize:14,textAnchor:"middle",yAlignment:"middle",pointerEvents:"none"},rect:{ref:"text",fill:"#ffffff",rx:3,ry:3,refWidth:1,refHeight:1,refX:0,refY:0}},position:{distance:.5}}},defaults:{type:"link",source:{},target:{}},isLink:function(){return!0},disconnect:function(t){return this.set({source:{x:0,y:0},target:{x:0,y:0}},t)},source:function(t,e,i){return void 0===t?ui(this.get("source")):t instanceof rn?((n=ui(e)||{}).id=t.id,this.set("source",n,i)):fi(t)?this.set("source",n=t,e):((n=ui(e)||{}).x=t.x,n.y=t.y,this.set("source",n,i));var n},target:function(t,e,i){return void 0===t?ui(this.get("target")):t instanceof rn?((n=ui(e)||{}).id=t.id,this.set("target",n,i)):fi(t)?this.set("target",n=t,e):((n=ui(e)||{}).x=t.x,n.y=t.y,this.set("target",n,i));var n},router:function(t,e,i){if(void 0===t)return(n=this.get("router"))?"object"==typeof n?ui(n):n:this.get("manhattan")?{name:"orthogonal"}:null;var n="object"==typeof t||"function"==typeof t;return this.set("router",n?t:{name:t,args:e},n?e:i)},connector:function(t,e,i){if(void 0===t)return(n=this.get("connector"))?"object"==typeof n?ui(n):n:this.get("smooth")?{name:"smooth"}:null;var n="object"==typeof t||"function"==typeof t;return this.set("connector",n?t:{name:t,args:e},n?e:i)},label:function(t,e,i){var n=this.labels();return(t=isFinite(t)&&null!==t?0|t:0)<0&&(t=n.length+t),arguments.length<=1?this.prop(["labels",t]):this.prop(["labels",t],e,i)},labels:function(t,e){return 0===arguments.length?(t=this.get("labels"),Array.isArray(t)?t.slice():[]):(Array.isArray(t)||(t=[]),this.set("labels",t,e))},hasLabels:function(){var t=this.attributes.labels;return Array.isArray(t)&&0<t.length},insertLabel:function(t,e,i){if(!e)throw new Error("dia.Link: no label provided");var n=this.labels(),r=n.length;return t=isFinite(t)&&null!==t?0|t:r,n.splice(t=t<0?r+t+1:t,0,e),this.labels(n,i)},appendLabel:function(t,e){return this.insertLabel(-1,t,e)},removeLabel:function(t,e){var i=this.labels();return t=isFinite(t)&&null!==t?0|t:-1,i.splice(t,1),this.labels(i,e)},vertex:function(t,e,i){var n=this.vertices();if((t=isFinite(t)&&null!==t?0|t:0)<0&&(t=n.length+t),arguments.length<=1)return this.prop(["vertices",t]);n=this._normalizeVertex(e);return this.prop(["vertices",t],n,i)},vertices:function(t,e){if(0===arguments.length)return t=this.get("vertices"),Array.isArray(t)?t.slice():[];Array.isArray(t)||(t=[]);for(var i=[],n=0;n<t.length;n++){var r=t[n],r=this._normalizeVertex(r);i.push(r)}return this.set("vertices",i,e)},insertVertex:function(t,e,i){if(!e)throw new Error("dia.Link: no vertex provided");var n=this.vertices(),r=n.length,r=((t=isFinite(t)&&null!==t?0|t:r)<0&&(t=r+t+1),this._normalizeVertex(e));return n.splice(t,0,r),this.vertices(n,i)},removeVertex:function(t,e){var i=this.vertices();return t=isFinite(t)&&null!==t?0|t:-1,i.splice(t,1),this.vertices(i,e)},_normalizeVertex:function(t){return fi(t)?t:{x:t.x,y:t.y}},translate:function(e,i,t){return(t=t||{}).translateBy=t.translateBy||this.id,t.tx=e,t.ty=i,this.applyToPoints(function(t){return{x:(t.x||0)+e,y:(t.y||0)+i}},t)},scale:function(e,i,n,t){return this.applyToPoints(function(t){return z(t).scale(e,i,n).toJSON()},t)},applyToPoints:function(t,e){if(!P(t))throw new TypeError("dia.Link: applyToPoints expects its first parameter to be a function.");var i={},n=this.attributes,r=n.source,n=n.target,r=(r.id||(i.source=t(r)),n.id||(i.target=t(n)),this.vertices());return 0<r.length&&(i.vertices=r.map(t)),this.set(i,e)},getSourcePoint:function(){var t=this.getSourceCell();return t?t.getPointFromConnectedLink(this,"source"):new z(this.source())},getTargetPoint:function(){var t=this.getTargetCell();return t?t.getPointFromConnectedLink(this,"target"):new z(this.target())},getPointFromConnectedLink:function(){return this.getPolyline().pointAt(.5)},getPolyline:function(){var t=[this.getSourcePoint()].concat(this.vertices().map(z),[this.getTargetPoint()]);return new v(t)},getBBox:function(){return this.getPolyline().bbox()},reparent:function(t){var e,i,n,r;return this.graph&&(i=this.getSourceElement(),n=this.getTargetElement(),r=this.getParentCell(),i&&n&&(e=i===n||i.isEmbeddedIn(n)?n:n.isEmbeddedIn(i)?i:this.graph.getCommonAncestor(i,n)),!r||e&&e.id===r.id||r.unembed(this,t),e&&e.embed(this,t)),e},hasLoop:function(t){t=t||{};var e=this.attributes,i=e.source,e=e.target,i=i.id,e=e.id;if(!i||!e)return!1;i=i===e;return!i&&t.deep&&this.graph&&(e=this.getSourceCell(),t=this.getTargetCell(),i=e.isEmbeddedIn(t)||t.isEmbeddedIn(e)),i},getSourceCell:function(){var t=this.graph,e=this.attributes.source;return e&&e.id&&t&&t.getCell(e.id)||null},getSourceElement:function(){var t=this,e={};do{if(e[t.id])return null}while(e[t.id]=!0,(t=t.getSourceCell())&&t.isLink());return t},getTargetCell:function(){var t=this.graph,e=this.attributes.target;return e&&e.id&&t&&t.getCell(e.id)||null},getTargetElement:function(){var t=this,e={};do{if(e[t.id])return null}while(e[t.id]=!0,(t=t.getTargetCell())&&t.isLink());return t},getRelationshipAncestor:function(){var t;return this.graph&&(t=[this,this.getSourceElement(),this.getTargetElement()].filter(function(t){return!!t}),t=this.graph.getCommonAncestor.apply(this.graph,t)),t||null},isRelationshipEmbeddedIn:function(t){var t=N(t)||G(t)?t:t.id,e=this.getRelationshipAncestor();return!!e&&(e.id===t||e.isEmbeddedIn(t))},_getDefaultLabel:function(){var t=this.get("defaultLabel")||this.defaultLabel||{},e={};return e.markup=t.markup||this.get("labelMarkup")||this.labelMarkup,e.position=t.position,e.attrs=t.attrs,e.size=t.size,e}},{endsEqual:function(t,e){var i=t.port===e.port||!t.port&&!e.port;return t.id===e.id&&i}}),Di=r.define("standard.Rectangle",{attrs:{body:{refWidth:"100%",refHeight:"100%",strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"text",selector:"label"}]}),Ut=r.define("standard.Circle",{attrs:{body:{refCx:"50%",refCy:"50%",refR:"50%",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"circle",selector:"body"},{tagName:"text",selector:"label"}]}),Sn=r.define("standard.Ellipse",{attrs:{body:{refCx:"50%",refCy:"50%",refRx:"50%",refRy:"50%",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"ellipse",selector:"body"},{tagName:"text",selector:"label"}]}),Pn=r.define("standard.Path",{attrs:{body:{refD:"M 0 0 L 10 0 10 10 0 10 Z",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"path",selector:"body"},{tagName:"text",selector:"label"}]}),Mn=r.define("standard.Polygon",{attrs:{body:{refPoints:"0 0 10 0 10 10 0 10",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"polygon",selector:"body"},{tagName:"text",selector:"label"}]}),kn=r.define("standard.Polyline",{attrs:{body:{refPoints:"0 0 10 0 10 10 0 10 0 0",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"polyline",selector:"body"},{tagName:"text",selector:"label"}]}),Nn=r.define("standard.Image",{attrs:{image:{refWidth:"100%",refHeight:"100%"},label:{textVerticalAnchor:"top",textAnchor:"middle",refX:"50%",refY:"100%",refY2:10,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"image",selector:"image"},{tagName:"text",selector:"label"}]}),Tn=r.define("standard.BorderedImage",{attrs:{border:{refWidth:"100%",refHeight:"100%",stroke:"#333333",strokeWidth:2},background:{refWidth:-1,refHeight:-1,x:.5,y:.5,fill:"#FFFFFF"},image:{refWidth:-1,refHeight:-1,x:.5,y:.5},label:{textVerticalAnchor:"top",textAnchor:"middle",refX:"50%",refY:"100%",refY2:10,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"background",attributes:{stroke:"none"}},{tagName:"image",selector:"image"},{tagName:"rect",selector:"border",attributes:{fill:"none"}},{tagName:"text",selector:"label"}]}),Bn=r.define("standard.EmbeddedImage",{attrs:{body:{refWidth:"100%",refHeight:"100%",stroke:"#333333",fill:"#FFFFFF",strokeWidth:2},image:{refWidth:"30%",refHeight:-20,x:10,y:10,preserveAspectRatio:"xMidYMin"},label:{textVerticalAnchor:"top",textAnchor:"left",refX:"30%",refX2:20,refY:10,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"image",selector:"image"},{tagName:"text",selector:"label"}]}),Gn=r.define("standard.InscribedImage",{attrs:{border:{refRx:"50%",refRy:"50%",refCx:"50%",refCy:"50%",stroke:"#333333",strokeWidth:2},background:{refRx:"50%",refRy:"50%",refCx:"50%",refCy:"50%",fill:"#FFFFFF"},image:{refWidth:"68%",refHeight:"68%",refX:"16%",refY:"16%",preserveAspectRatio:"xMidYMid"},label:{textVerticalAnchor:"top",textAnchor:"middle",refX:"50%",refY:"100%",refY2:10,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"ellipse",selector:"background"},{tagName:"image",selector:"image"},{tagName:"ellipse",selector:"border",attributes:{fill:"none"}},{tagName:"text",selector:"label"}]}),zn=r.define("standard.HeaderedRectangle",{attrs:{body:{refWidth:"100%",refHeight:"100%",strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},header:{refWidth:"100%",height:30,strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},headerText:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:15,fontSize:16,fill:"#333333"},bodyText:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"50%",refY2:15,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"rect",selector:"header"},{tagName:"text",selector:"headerText"},{tagName:"text",selector:"bodyText"}]}),On=r.define("standard.Cylinder",{attrs:{body:{lateralArea:10,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},top:{refCx:"50%",cy:10,refRx:"50%",ry:10,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},label:{textVerticalAnchor:"middle",textAnchor:"middle",refX:"50%",refY:"100%",refY2:15,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"path",selector:"body"},{tagName:"ellipse",selector:"top"},{tagName:"text",selector:"label"}],topRy:function(t,e){if(void 0===t)return this.attr("body/lateralArea");var i=ti(t);return this.attr({body:{lateralArea:t},top:i?{refCy:t,refRy:t,cy:null,ry:null}:{refCy:null,refRy:null,cy:t,ry:t}},e)}},{attributes:{lateralArea:{set:function(t,e){var i=ti(t),n=(i&&(t=parseFloat(t)/100),e.x),r=e.y,o=e.width,e=e.height,s=i?e*t:t,a=B.KAPPA,l=a*(o/2),a=a*(i?e*t:t),i=n+o/2,t=n+o,o=r+s,h=o-s,s=r+e-s,r=r+e;return{d:["M",n,o,"L",n,s,"C",n,s+a,i-l,r,i,r,"C",i+l,r,t,s+a,t,s,"L",t,o,"C",t,o-a,i+l,h,i,h,"C",i-l,h,n,o-a,n,o,"Z"].join(" ")}}}}}),Rn=In.test("svgforeignobject")?{tagName:"foreignObject",selector:"foreignObject",attributes:{overflow:"hidden"},children:[{tagName:"div",namespaceURI:"http://www.w3.org/1999/xhtml",selector:"label",style:{width:"100%",height:"100%",position:"static",backgroundColor:"transparent",textAlign:"center",margin:0,padding:"0px 5px",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center"}}]}:{tagName:"text",selector:"label",attributes:{"text-anchor":"middle"}},Di={Rectangle:Di,Circle:Ut,Ellipse:Sn,Path:Pn,Polygon:Mn,Polyline:kn,Image:Nn,BorderedImage:Tn,EmbeddedImage:Bn,InscribedImage:Gn,HeaderedRectangle:zn,Cylinder:On,TextBlock:r.define("standard.TextBlock",{attrs:{body:{refWidth:"100%",refHeight:"100%",stroke:"#333333",fill:"#ffffff",strokeWidth:2},foreignObject:{refWidth:"100%",refHeight:"100%"},label:{style:{fontSize:14}}}},{markup:[{tagName:"rect",selector:"body"},Rn]},{attributes:{text:{set:function(t,e,i,n){var r,o;if(!(i instanceof HTMLElement))return n=n.style||{},r={text:t,width:-5,height:"100%"},o=R({textVerticalAnchor:"middle"},n),nn.textWrap.set.call(this,r,e,i,o),{fill:n.color||null};i.textContent=t},position:function(t,e,i){if(i instanceof SVGElement)return e.center()}}}}),Link:u.define("standard.Link",{attrs:{line:{connection:!0,stroke:"#333333",strokeWidth:2,strokeLinejoin:"round",targetMarker:{type:"path",d:"M 10 -5 0 0 10 5 z"}},wrapper:{connection:!0,strokeWidth:10,strokeLinejoin:"round"}}},{markup:[{tagName:"path",selector:"wrapper",attributes:{fill:"none",cursor:"pointer",stroke:"transparent","stroke-linecap":"round"}},{tagName:"path",selector:"line",attributes:{fill:"none","pointer-events":"none"}}]}),DoubleLink:u.define("standard.DoubleLink",{attrs:{line:{connection:!0,stroke:"#DDDDDD",strokeWidth:4,strokeLinejoin:"round",targetMarker:{type:"path",stroke:"#000000",d:"M 10 -3 10 -10 -2 0 10 10 10 3"}},outline:{connection:!0,stroke:"#000000",strokeWidth:6,strokeLinejoin:"round"}}},{markup:[{tagName:"path",selector:"outline",attributes:{fill:"none"}},{tagName:"path",selector:"line",attributes:{fill:"none"}}]}),ShadowLink:u.define("standard.ShadowLink",{attrs:{line:{connection:!0,stroke:"#FF0000",strokeWidth:20,strokeLinejoin:"round",targetMarker:{type:"path",stroke:"none",d:"M 0 -10 -10 0 0 10 z"},sourceMarker:{type:"path",stroke:"none",d:"M -10 -10 0 0 -10 10 0 10 0 -10 z"}},shadow:{connection:!0,refX:3,refY:6,stroke:"#000000",strokeOpacity:.2,strokeWidth:20,strokeLinejoin:"round",targetMarker:{type:"path",d:"M 0 -10 -10 0 0 10 z",stroke:"none"},sourceMarker:{type:"path",stroke:"none",d:"M -10 -10 0 0 -10 10 0 10 0 -10 z"}}}},{markup:[{tagName:"path",selector:"shadow",attributes:{fill:"none"}},{tagName:"path",selector:"line",attributes:{fill:"none"}}]})},Ut=h.define("devs.Model",{inPorts:[],outPorts:[],size:{width:80,height:80},attrs:{".":{magnet:!1},".label":{text:"Model","ref-x":.5,"ref-y":10,"font-size":18,"text-anchor":"middle",fill:"#000"},".body":{"ref-width":"100%","ref-height":"100%",stroke:"#000"}},ports:{groups:{in:{position:{name:"left"},attrs:{".port-label":{fill:"#000"},".port-body":{fill:"#fff",stroke:"#000",r:10,magnet:!0}},label:{position:{name:"left",args:{y:10}}}},out:{position:{name:"right"},attrs:{".port-label":{fill:"#000"},".port-body":{fill:"#fff",stroke:"#000",r:10,magnet:!0}},label:{position:{name:"right",args:{y:10}}}}}}},{markup:'<g class="rotatable"><rect class="body"/><text class="label"/></g>',portMarkup:'<circle class="port-body"/>',portLabelMarkup:'<text class="port-label"/>',initialize:function(){h.prototype.initialize.apply(this,arguments),this.on("change:inPorts change:outPorts",this.updatePortItems,this),this.updatePortItems()},updatePortItems:function(t,e,i){var n=ci(this.get("inPorts")),r=Ai(ci(this.get("outPorts")),n),n=this.createPortItems("in",n),r=this.createPortItems("out",r);this.prop("ports/items",n.concat(r),R({rewrite:!0},i))},createPortItem:function(t,e){return{id:e,group:t,attrs:{".port-label":{text:e}}}},createPortItems:function(t,e){return et(e).map(this.createPortItem.bind(this,t))},_addGroupPort:function(t,e,i){var n=this.get(e);return this.set(e,Array.isArray(n)?n.concat(t):[t],i)},addOutPort:function(t,e){return this._addGroupPort(t,"outPorts",e)},addInPort:function(t,e){return this._addGroupPort(t,"inPorts",e)},_removeGroupPort:function(t,e,i){return this.set(e,wi(this.get(e),t),i)},removeOutPort:function(t,e){return this._removeGroupPort(t,"outPorts",e)},removeInPort:function(t,e){return this._removeGroupPort(t,"inPorts",e)},_changeGroup:function(t,e,i){return this.prop("ports/groups/"+t,x(e)?e:{},i)},changeInGroup:function(t,e){return this._changeGroup("in",t,e)},changeOutGroup:function(t,e){return this._changeGroup("out",t,e)}}),Sn=Ut.define("devs.Atomic",{size:{width:80,height:80},attrs:{".label":{text:"Atomic"}}}),Pn=Ut.define("devs.Coupled",{size:{width:200,height:300},attrs:{".label":{text:"Coupled"}}}),Mn={Model:Ut,Atomic:Sn,Coupled:Pn,Link:u.define("devs.Link",{attrs:{".connection":{"stroke-width":2}}})},kn=h.define("logic.Gate",{size:{width:80,height:40},attrs:{".":{magnet:!1},".body":{width:100,height:50},circle:{r:7,stroke:"black",fill:"transparent","stroke-width":2}}},{operation:function(){return!0}}),Nn=kn.define("logic.IO",{size:{width:60,height:30},attrs:{".body":{fill:"white",stroke:"black","stroke-width":2},".wire":{ref:".body","ref-y":.5,stroke:"black"},text:{fill:"black",ref:".body","ref-x":.5,"ref-y":.5,"y-alignment":"middle","text-anchor":"middle","font-weight":"bold","font-variant":"small-caps","text-transform":"capitalize","font-size":"14px"}}},{markup:'<g class="rotatable"><g class="scalable"><rect class="body"/></g><path class="wire"/><circle/><text/></g>'}),Tn=Nn.define("logic.Input",{attrs:{".wire":{"ref-dx":0,d:"M 0 0 L 23 0"},circle:{ref:".body","ref-dx":30,"ref-y":.5,magnet:!0,class:"output",port:"out"},text:{text:"input"}}}),Bn=Nn.define("logic.Output",{attrs:{".wire":{"ref-x":0,d:"M 0 0 L -23 0"},circle:{ref:".body","ref-x":-30,"ref-y":.5,magnet:"passive",class:"input",port:"in"},text:{text:"output"}}}),Gn=kn.define("logic.Gate11",{attrs:{".input":{ref:".body","ref-x":-2,"ref-y":.5,magnet:"passive",port:"in"},".output":{ref:".body","ref-dx":2,"ref-y":.5,magnet:!0,port:"out"}}},{markup:'<g class="rotatable"><g class="scalable"><image class="body"/></g><circle class="input"/><circle class="output"/></g>'}),zn=kn.define("logic.Gate21",{attrs:{".input1":{ref:".body","ref-x":-2,"ref-y":.3,magnet:"passive",port:"in1"},".input2":{ref:".body","ref-x":-2,"ref-y":.7,magnet:"passive",port:"in2"},".output":{ref:".body","ref-dx":2,"ref-y":.5,magnet:!0,port:"out"}}},{markup:'<g class="rotatable"><g class="scalable"><image class="body"/></g><circle class="input input1"/><circle class="input input2"/><circle class="output"/></g>'}),On=Gn.define("logic.Repeater",{attrs:{image:{"xlink:href":"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgo8c3ZnCiAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgeG1sbnM6Y2M9Imh0dHA6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL25zIyIKICAgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIgogICB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgogICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zOnNvZGlwb2RpPSJodHRwOi8vc29kaXBvZGkuc291cmNlZm9yZ2UubmV0L0RURC9zb2RpcG9kaS0wLmR0ZCIKICAgeG1sbnM6aW5rc2NhcGU9Imh0dHA6Ly93d3cuaW5rc2NhcGUub3JnL25hbWVzcGFjZXMvaW5rc2NhcGUiCiAgIHdpZHRoPSIxMDAiCiAgIGhlaWdodD0iNTAiCiAgIGlkPSJzdmcyIgogICBzb2RpcG9kaTp2ZXJzaW9uPSIwLjMyIgogICBpbmtzY2FwZTp2ZXJzaW9uPSIwLjQ2IgogICB2ZXJzaW9uPSIxLjAiCiAgIHNvZGlwb2RpOmRvY25hbWU9Ik5PVCBBTlNJLnN2ZyIKICAgaW5rc2NhcGU6b3V0cHV0X2V4dGVuc2lvbj0ib3JnLmlua3NjYXBlLm91dHB1dC5zdmcuaW5rc2NhcGUiPgogIDxkZWZzCiAgICAgaWQ9ImRlZnM0Ij4KICAgIDxpb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yb3VuZDphY2N1bXVsYXRlIgogICAgICAgICBpZD0icGF0aDI2MDQiCiAgICAgICAgIHNvZGlwb2RpOmN4PSI3NSIKICAgICAgICAgc29kaXBvZGk6Y3k9IjI1IgogICAgICAgICBzb2RpcG9kaTpyeD0iNCIKICAgICAgICAgc29kaXBvZGk6cnk9IjQiCiAgICAgICAgIGQ9Ik0gNzksMjUgQSA0LDQgMCAxIDEgNzEsMjUgQSA0LDQgMCAxIDEgNzksMjUgeiIKICAgICAgICAgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTI2LjUsMzkuNSkiIC8+CiAgICA8L2c+CiAgPC9nPgo8L3N2Zz4K"}}},{operation:function(t,e){return!(t||e)}}),Vn=zn.define("logic.Nand",{attrs:{image:{"xlink:href":"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgo8c3ZnCiAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgeG1sbnM6Y2M9Imh0dHA6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL25zIyIKICAgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIgogICB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgogICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zOnNvZGlwb2RpPSJodHRwOi8vc29kaXBvZGkuc291cmNlZm9yZ2UubmV0L0RURC9zb2RpcG9kaS0wLmR0ZCIKICAgeG1sbnM6aW5rc2NhcGU9Imh0dHA6Ly93d3cuaW5rc2NhcGUub3JnL25hbWVzcGFjZXMvaW5rc2NhcGUiC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bmtzY2FwZTpwYWdlc2hhZG93PSIyIgogICAgIGlua3NjYXBlOnpvb209IjUuNjU2ODU0MiIKICAgICBpbmtzY2FwZTpjeD0iMjUuOTM4MTE2IgogICAgIGlua3NjYXBlOmN5PSIxNy4yMzAwNSIKICAgICBpbmtzY2FwZTpkb2N1bWVudC11bml0cz0icHgiCiAgICAgaW5rc2NhcGU6Y3VycmVudC1sYXllcj0ibGF5ZXIxIgogICAgIHNob3dncmlkPSJ0cnVlIgogICAgIGlua3NjYXBlOmdyaWQtYmJveD0idHJ1ZSIKICAgICBpbmtzY2FwZTpncmlkLXBvaW50cz0idHJ1ZSIKICAgICBncmlkdG9sZXJhbmNlPSIxMDAwMCIKICAgICBpbmtzY2FwZTp3aW5kb3ctd2lkdGg9IjEzOTkiCiAgICAgaW5rc2NhcGU6d2luZG93LWhlaWdodD0iODc0IgogICAgIGlua3NjYXBlOndpbmRvdy14PSIzMyIKICAgICBpbmtzY2FwZTp3aW5kb3cteT0iMCIKICAgICBpbmtzY2FwZTpzbmFwLWJib3g9InRydWUiPgogICAgPGlua3NjYXBlOmdyaWQKICAgICAgIGlkPSJHcmlkRnJvbVByZTA0NlNldHRpbmdzIgogICAgICAgdHlwZT0ieHlncmlkIgogICAgICAgb3JpZ2lueD0iMHB4IgogICAgICAgb3JpZ2lueT0iMHB4IgogICAgICAgc3BhY2luZ3g9IjFweCIKICAgICAgIHNwYWNpbmd5PSIxcHgiCiAgICAgICBjb2xvcj0iIzAwMDBmZiIKICAgICAgIGVtcGNvbG9yPSIjMDAwMGZmIgogICAgICAgb3BhY2l0eT0iMC4yIgogICAgICAgZW1wb3BhY2l0eT0iMC40IgogICAgICAgZW1wc3BhY2luZz0iNSIKICAgICAgIHZpc2libGU9InRydWUiCiAgICAgICBlbmFibGVkPSJ0cnVlIiAvPgogIDwvc29kaXBvZGk6bmFtZWR2aWV3PgogIDxtZXRhZGF0YQogICAgIGlkPSJtZXRhZGF0YTciPgogICAgPHJkZjpSREY+CiAgICA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NC43NSw4MS41IEwgMy41LDgxLjUgQyA1LjM3MzU4ODQsNzguMzkxNTY2IDguMjUsNzIuNDUwNjUgOC4yNSw2NC41IEMgOC4yNSw1Ni41MjY2NDYgNS4zNDE0Njg2LDUwLjU5OTgxNSAzLjQ2ODc1LDQ3LjUgeiIKICAgICAgICAgaWQ9InBhdGg0OTczIgogICAgICAgICBzb2RpcG9kaTpub2RldHlwZXM9ImNjc2NjY2NzY2NjY2NjY2Njc2Njc2MiIC8+CiAgICA8L2c+CiAgPC9nPgo8L3N2Zz4K"}}},{operation:function(t,e){return(!t||e)&&(t||!e)}}),_n=zn.define("logic.Xnor",{attrs:{image:{"xlink:href":"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgo8c3ZnCiAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgeG1sbnM6Y2M9Imh0dHA6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL25zIyIKICAgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIgogICB4bWxuczpzdmc9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgogICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zOnNvZGlwb2RpPSJodHRwOi8vc29kaXBvZGkuc291cmNlZm9yZ2UubmV0L0RURC9zb2RpcG9kaS0wLmR0ZCIKICAgeG1sbnM6aW5rc2NhcGU9Imh0dHA6Ly93d3cuaW5rc2NhcGUub3JnL25hbWVzcGFjZXMvaW5rc2NhcGUiCiAgIHdpZHRoPSIxMDAiCiAgIGhlaWdodD0iNTAiCiAgIGlkPS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cm9rZTojMDAwMDAwO3N0cm9rZS13aWR0aDozO3N0cm9rZS1saW5lam9pbjptaXRlcjttYXJrZXI6bm9uZTtzdHJva2Utb3BhY2l0eToxO3Zpc2liaWxpdHk6dmlzaWJsZTtkaXNwbGF5OmlubGluZTtvdmVyZmxvdzp2aXNpYmxlO2VuYWJsZS1iYWNrZ3JvdW5kOmFjY3VtdWxhdGUiCiAgICAgICBpZD0icGF0aDM1NTEiCiAgICAgICBzb2RpcG9kaTpjeD0iNzUiCiAgICAgICBzb2RpcG9kaTpjeT0iMjUiCiAgICAgICBzb2RpcG9kaTpyeD0iNCIKICAgICAgIHNvZGlwb2RpOnJ5PSI0IgogICAgICAgZD0iTSA3OSwyNSBBIDQsNCAwIDEgMSA3MSwyNSBBIDQsNCAwIDEgMSA3OSwyNSB6IiAvPgogIDwvZz4KPC9zdmc+Cg=="}}},{operation:function(t,e){return(!t||!e)&&(t||e)}}),kn={Gate:kn,IO:Nn,Input:Tn,Output:Bn,Gate11:Gn,Gate21:zn,Repeater:On,Not:Rn,Or:Ut,And:Sn,Nor:Pn,Nand:Vn,Xor:jn,Xnor:_n,Wire:u.define("logic.Wire",{attrs:{".connection":{"stroke-width":2},".marker-vertex":{r:7}},router:{name:"orthogonal"},connector:{name:"rounded",args:{radius:10}}},{arrowheadMarkup:['<g class="marker-arrowhead-group marker-arrowhead-group-<%= end %>">','<circle class="marker-arrowhead" end="<%= end %>" r="7"/>',"</g>"].join(""),vertexMarkup:['<g class="marker-vertex-group" transform="translate(<%= x %>, <%= y %>)">','<circle class="marker-vertex" idx="<%= idx %>" r="10" />','<g class="marker-vertex-remove-group">','<path class="marker-vertex-remove-area" idx="<%= idx %>" d="M16,5.333c-7.732,0-14,4.701-14,10.5c0,1.982,0.741,3.833,2.016,5.414L2,25.667l5.613-1.441c2.339,1.317,5.237,2.107,8.387,2.107c7.732,0,14-4.701,14-10.5C30,10.034,23.732,5.333,16,5.333z" transform="translate(5, -33)"/>','<path class="marker-vertex-remove" idx="<%= idx %>" transform="scale(.8) translate(9.5, -37)" d="M24.778,21.419 19.276,15.917 24.777,10.415 21.949,7.585 16.447,13.087 10.945,7.585 8.117,10.415 13.618,15.917 8.116,21.419 10.946,24.248 16.447,18.746 21.948,24.248z">',"<title>Remove vertex.</title>","</path>","</g>","</g>"].join("")})},Nn={KingWhite:h.define("chess.KingWhite",{size:{width:42,height:38}},{markup:'<g class="rotatable"><g class="scalable"><g style="fill:none; fill-opacity:1; fill-rule:evenodd; stroke:#000000; stroke-width:1.5; stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4; stroke-dasharray:none; stroke-opacity:1;"><path d="M 22.5,11.63 L 22.5,6" style="fill:none; stroke:#000000; stroke-linejoin:miter;" /> <path d="M 20,8 L 25,8" style="fill:none; stroke:#000000; stroke-linejoin:miter;" /> <path d="M 22.5,25 C 22.5,25 27,17.5 25.5,14.5 C 25.5,14.5 24.5,12 22.5,12 C 20.5,12 19.5,14.5 19.5,14.5 C 18,17.5 22.5,25 22.5,25" style="fill:#ffffff; stroke:#000000; stroke-linecap:butt; stroke-linejoin:miter;" /> <path d="M 11.5,37 C 17,40.5 27,40.5 32.5,37 L 32.5,30 C 32.5,30 41.5,25.5 38.5,19.5 C 34.5,13 25,16 22.5,23.5 L 22.5,27 L 22.5,23.5 C 19,16 9.5,13 6.5,19.5 C 3.5,25.5 11.5,29.5 11.5,29.5 L 11.5,37 z " style="fill:#ffffff; stroke:#000000;" /> <path d="M 11.5,30 C 17,27 27,27 32.5,30" style="fill:none; stroke:#000000;" /> <path d="M 11.5,33.5 C 17,30.5 27,30.5 32.5,33.5" style="fill:none; stroke:#000000;" /> <path d="M 11.5,37 C 17,34 27,34 32.5,37" style="fill:none; stroke:#000000;" /> </g></g></g>'}),KingBlack:h.define("chess.KingBlack",{size:{width:42,height:38}},{markup:'<g class="rotatable"><g class="scalable"><g style="fill:none; fill-opacity:1; fill-rule:evenodd; stroke:#000000; stroke-width:1.5; stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4; stroke-dasharray:none; stroke-opacity:1;"> <path d="M 22.5,11.63 L 22.5,6" style="fill:none; stroke:#000000; stroke-linejoin:miter;" id="path6570" /> <path d="M 22.5,25 C 22.5,25 27,17.5 25.5,14.5 C 25.5,14.5 24.5,12 22.5,12 C 20.5,12 19.5,14.5 19.5,14.5 C 18,17.5 22.5,25 22.5,25" style="fill:#000000;fill-opacity:1; stroke-linecap:butt; stroke-linejoin:miter;" /> <path d="M 11.5,37 C 17,40.5 27,40.5 32.5,37 L 32.5,30 C 32.5,30 41.5,25.5 38.5,19.5 C 34.5,13 25,16 22.5,23.5 L 22.5,27 L 22.5,23.5 C 19,16 9.5,13 6.5,19.5 C 3.5,25.5 11.5,29.5 11.5,29.5 L 11.5,37 z " style="fill:#000000; stroke:#000000;" /> <path d="M 20,8 L 25,8" style="fill:none; stroke:#000000; stroke-linejoin:miter;" /> <path d="M 32,29.5 C 32,29.5 40.5,25.5 38.03,19.85 C 34.15,14 25,18 22.5,24.5 L 22.51,26.6 L 22.5,24.5 C 20,18 9.906,14 6.997,19.85 C 4.5,25.5 11.85,28.85 11.85,28.85" style="fill:none; stroke:#ffffff;" /> <path d="M 11.5,30 C 17,27 27,27 32.5,30 M 11.5,33.5 C 17,30.5 27,30.5 32.5,33.5 M 11.5,37 C 17,34 27,34 32.5,37" style="fill:none; stroke:#ffffff;" /> </g></g></g>'}),QueenWhite:h.define("chess.QueenWhite",{size:{width:42,height:38}},{markup:'<g class="rotatable"><g class="scalable"><g style="opacity:1; fill:#ffffff; fill-opacity:1; fill-rule:evenodd; stroke:#000000; stroke-width:1.5; stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4; stroke-dasharray:none; stroke-opacity:1;"> <path d="M 9 13 A 2 2 0 1 1 5,13 A 2 2 0 1 1 9 13 z" transform="translate(-1,-1)" /> <path d="M 9 13 A 2 2 0 1 1 5,13 A 2 2 0 1 1 9 13 z" transform="translate(15.5,-5.5)" /> <path d="M 9 13 A 2 2 0 1 1 5,13 A 2 2 0 1 1 9 13 z" transform="translate(32,-1)" /> <path d="M 9 13 A 2 2 0 1 1 5,13 A 2 2 0 1 1 9 13 z" transform="translate(7,-4.5)" /> <path d="M 9 13 A 2 2 0 1 1 5,13 A 2 2 0 1 1 9 13 z" transform="translate(24,-4)" /> <path d="M 9,26 C 17.5,24.5 30,24.5 36,26 L 38,14 L 31,25 L 31,11 L 25.5,24.5 L 22.5,9.5 L 19.5,24.5 L 14,10.5 L 14,25 L 7,14 L 9,26 z " style="stroke-linecap:butt;" /> <path d="M 9,26 C 9,28 10.5,28 11.5,30 C 12.5,31.5 12.5,31 12,33.5 C 10.5,34.5 10.5,36 10.5,36 C 9,37.5 11,38.5 11,38.5 C 17.5,39.5 27.5,39.5 34,38.5 C 34,38.5 35.5,37.5 34,36 C 34,36 34.5,34.5 33,33.5 C 32.5,31 32.5,31.5 33.5,30 C 34.5,28 36,28 36,26 C 27.5,24.5 17.5,24.5 9,26 z " style="stroke-linecap:butt;" /> <path d="M 11.5,30 C 15,29 30,29 33.5,30" style="fill:none;" /> <path d="M 12,33.5 C 18,32.5 27,32.5 33,33.5" style="fill:none;" /> </g></g></g>'}),QueenBlack:h.define("chess.QueenBlack",{size:{width:42,height:38}},{markup:'<g class="rotatable"><g class="scalable"><g style="opacity:1; fill:#000000; fill-opacity:1; fill-rule:evenodd; stroke:#000000; stroke-width:1.5; stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4; stroke-dasharray:none; stroke-opacity:1;"> <g style="fill:#000000; stroke:none;"> <circle cx="6" cy="12" r="2.75" /> <circle cx="14" cy="9" r="2.75" /> <circle cx="22.5" cy="8" r="2.75" /> <circle cx="31" cy="9" r="2.75" /> <circle cx="39" cy="12" r="2.75" /> </g> <path d="M 9,26 C 17.5,24.5 30,24.5 36,26 L 38.5,13.5 L 31,25 L 30.7,10.9 L 25.5,24.5 L 22.5,10 L 19.5,24.5 L 14.3,10.9 L 14,25 L 6.5,13.5 L 9,26 z" style="stroke-linecap:butt; stroke:#000000;" /> <path d="M 9,26 C 9,28 10.5,28 11.5,30 C 12.5,31.5 12.5,31 12,33.5 C 10.5,34.5 10.5,36 10.5,36 C 9,37.5 11,38.5 11,38.5 C 17.5,39.5 27.5,39.5 34,38.5 C 34,38.5 35.5,37.5 34,36 C 34,36 34.5,34.5 33,33.5 C 32.5,31 32.5,31.5 33.5,30 C 34.5,28 36,28 36,26 C 27.5,24.5 17.5,24.5 9,26 z" style="stroke-linecap:butt;" /> <path d="M 11,38.5 A 35,35 1 0 0 34,38.5" style="fill:none; stroke:#000000; stroke-linecap:butt;" /> <path d="M 11,29 A 35,35 1 0 1 34,29" style="fill:none; stroke:#ffffff;" /> <path d="M 12.5,31.5 L 32.5,31.5" style="fill:none; stroke:#ffffff;" /> <path d="M 11.5,34.5 A 35,35 1 0 0 33.5,34.5" style="fill:none; stroke:#ffffff;" /> <path d="M 10.5,37.5 A 35,35 1 0 0 34.5,37.5" style="fill:none; stroke:#ffffff;" /> </g></g></g>'}),RookWhite:h.define("chess.RookWhite",{size:{width:32,height:34}},{markup:'<g class="rotatable"><g class="scalable"><g style="opacity:1; fill:#ffffff; fill-opacity:1; fill-rule:evenodd; stroke:#000000; stroke-width:1.5; stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4; stroke-dasharray:none; stroke-opacity:1;"> <path d="M 9,39 L 36,39 L 36,36 L 9,36 L 9,39 z " style="stroke-linecap:butt;" /> <path d="M 12,36 L 12,32 L 33,32 L 33,36 L 12,36 z " style="stroke-linecap:butt;" /> <path d="M 11,14 L 11,9 L 15,9 L 15,11 L 20,11 L 20,9 L 25,9 L 25,11 L 30,11 L 30,9 L 34,9 L 34,14" style="stroke-linecap:butt;" /> <path d="M 34,14 L 31,17 L 14,17 L 11,14" /> <path d="M 31,17 L 31,29.5 L 14,29.5 L 14,17" style="stroke-linecap:butt; stroke-linejoin:miter;" /> <path d="M 31,29.5 L 32.5,32 L 12.5,32 L 14,29.5" /> <path d="M 11,14 L 34,14" style="fill:none; stroke:#000000; stroke-linejoin:miter;" /> </g></g></g>'}),RookBlack:h.define("chess.RookBlack",{size:{width:32,height:34}},{markup:'<g class="rotatable"><g class="scalable"><g style="opacity:1; fill:#000000; fill-opacity:1; fill-rule:evenodd; stroke:#000000; stroke-width:1.5; stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4; stroke-dasharray:none; stroke-opacity:1;"> <path d="M 9,39 L 36,39 L 36,36 L 9,36 L 9,39 z " style="stroke-linecap:butt;" /> <path d="M 12.5,32 L 14,29.5 L 31,29.5 L 32.5,32 L 12.5,32 z " style="stroke-linecap:butt;" /> <path d="M 12,36 L 12,32 L 33,32 L 33,36 L 12,36 z " style="stroke-linecap:butt;" /> <path d="M 14,29.5 L 14,16.5 L 31,16.5 L 31,29.5 L 14,29.5 z " style="stroke-linecap:butt;stroke-linejoin:miter;" /> <path d="M 14,16.5 L 11,14 L 34,14 L 31,16.5 L 14,16.5 z " style="stroke-linecap:butt;" /> <path d="M 11,14 L 11,9 L 15,9 L 15,11 L 20,11 L 20,9 L 25,9 L 25,11 L 30,11 L 30,9 L 34,9 L 34,14 L 11,14 z " style="stroke-linecap:butt;" /> <path d="M 12,35.5 L 33,35.5 L 33,35.5" style="fill:none; stroke:#ffffff; stroke-width:1; stroke-linejoin:miter;" /> <path d="M 13,31.5 L 32,31.5" style="fill:none; stroke:#ffffff; stroke-width:1; stroke-linejoin:miter;" /> <path d="M 14,29.5 L 31,29.5" style="fill:none; stroke:#ffffff; stroke-width:1; stroke-linejoin:miter;" /> <path d="M 14,16.5 L 31,16.5" style="fill:none; stroke:#ffffff; stroke-width:1; stroke-linejoin:miter;" /> <path d="M 11,14 L 34,14" style="fill:none; stroke:#ffffff; stroke-width:1; stroke-linejoin:miter;" /> </g></g></g>'}),BishopWhite:h.define("chess.BishopWhite",{size:{width:38,height:38}},{markup:'<g class="rotatable"><g class="scalable"><g style="opacity:1; fill:none; fill-rule:evenodd; fill-opacity:1; stroke:#000000; stroke-width:1.5; stroke-linecap:round; stroke-linejoin:round; stroke-miterlimit:4; stroke-dasharray:none; stroke-opacity:1;"> <g style="fill:#ffffff; stroke:#000000; stroke-linecap:butt;"> <path d="M 9,36 C 12.39,35.03 19.11,36.43 22.5,34 C 25.89,36.43 32.61,35.03 36,36 C 36,36 37.65,36.54 39,38 C 38.32,38.97 37.35,38.99 36,38.5 C 32.61,37.53 25.89,38.96 22.5,37.5 C 19.11,38.96 12.39,37.53 9,38.5 C 7.646,38.99 6.677,38.97 6,38 C 7.354,36.06 9,36 9,36 z" /> <path d="M 15,32 C 17.5,34.5 27.5,34.5 30,32 C 30.5,30.5 30,30 30,30 C 30,27.5 27.5,26 27.5,26 C 33,24.5 33.5,14.5 22.5,10.5 C 11.5,14.5 12,24.5 17.5,26 C 17.5,26 15,27.5 15,30 C 15,30 14.5,30.5 15,32 z" /> <path d="M 25 8 A 2.5 2.5 0 1 1 20,8 A 2.5 2.5 0 1 1 25 8 z" /> </g> <path d="M 17.5,26 L 27.5,26 M 15,30 L 30,30 M 22.5,15.5 L 22.5,20.5 M 20,18 L 25,18" style="fill:none; stroke:#000000; stroke-linejoin:miter;" /> </g></g></g>'}),BishopBlack:h.define("chess.BishopBlack",{size:{width:38,height:38}},{markup:'<g class="rotatable"><g class="scalable"><g style="opacity:1; fill:none; fill-rule:evenodd; fill-opacity:1; stroke:#000000; stroke-width:1.5; stroke-linecap:round; stroke-linejoin:round; stroke-miterlimit:4; stroke-dasharray:none; stroke-opacity:1;"> <g style="fill:#000000; stroke:#000000; stroke-linecap:butt;"> <path d="M 9,36 C 12.39,35.03 19.11,36.43 22.5,34 C 25.89,36.43 32.61,35.03 36,36 C 36,36 37.65,36.54 39,38 C 38.32,38.97 37.35,38.99 36,38.5 C 32.61,37.53 25.89,38.96 22.5,37.5 C 19.11,38.96 12.39,37.53 9,38.5 C 7.646,38.99 6.677,38.97 6,38 C 7.354,36.06 9,36 9,36 z" /> <path d="M 15,32 C 17.5,34.5 27.5,34.5 30,32 C 30.5,30.5 30,30 30,30 C 30,27.5 27.5,26 27.5,26 C 33,24.5 33.5,14.5 22.5,10.5 C 11.5,14.5 12,24.5 17.5,26 C 17.5,26 15,27.5 15,30 C 15,30 14.5,30.5 15,32 z" /> <path d="M 25 8 A 2.5 2.5 0 1 1 20,8 A 2.5 2.5 0 1 1 25 8 z" /> </g> <path d="M 17.5,26 L 27.5,26 M 15,30 L 30,30 M 22.5,15.5 L 22.5,20.5 M 20,18 L 25,18" style="fill:none; stroke:#ffffff; stroke-linejoin:miter;" /> </g></g></g>'}),KnightWhite:h.define("chess.KnightWhite",{size:{width:38,height:37}},{markup:'<g class="rotatable"><g class="scalable"><g style="opacity:1; fill:none; fill-opacity:1; fill-rule:evenodd; stroke:#000000; stroke-width:1.5; stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4; stroke-dasharray:none; stroke-opacity:1;"> <path d="M 22,10 C 32.5,11 38.5,18 38,39 L 15,39 C 15,30 25,32.5 23,18" style="fill:#ffffff; stroke:#000000;" /> <path d="M 24,18 C 24.38,20.91 18.45,25.37 16,27 C 13,29 13.18,31.34 11,31 C 9.958,30.06 12.41,27.96 11,28 C 10,28 11.19,29.23 10,30 C 9,30 5.997,31 6,26 C 6,24 12,14 12,14 C 12,14 13.89,12.1 14,10.5 C 13.27,9.506 13.5,8.5 13.5,7.5 C 14.5,6.5 16.5,10 16.5,10 L 18.5,10 C 18.5,10 19.28,8.008 21,7 C 22,7 22,10 22,10" style="fill:#ffffff; stroke:#000000;" /> <path d="M 9.5 25.5 A 0.5 0.5 0 1 1 8.5,25.5 A 0.5 0.5 0 1 1 9.5 25.5 z" style="fill:#000000; stroke:#000000;" /> <path d="M 15 15.5 A 0.5 1.5 0 1 1 14,15.5 A 0.5 1.5 0 1 1 15 15.5 z" transform="matrix(0.866,0.5,-0.5,0.866,9.693,-5.173)" style="fill:#000000; stroke:#000000;" /> </g></g></g>'}),KnightBlack:h.define("chess.KnightBlack",{size:{width:38,height:37}},{markup:'<g class="rotatable"><g class="scalable"><g style="opacity:1; fill:none; fill-opacity:1; fill-rule:evenodd; stroke:#000000; stroke-width:1.5; stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4; stroke-dasharray:none; stroke-opacity:1;"> <path d="M 22,10 C 32.5,11 38.5,18 38,39 L 15,39 C 15,30 25,32.5 23,18" style="fill:#000000; stroke:#000000;" /> <path d="M 24,18 C 24.38,20.91 18.45,25.37 16,27 C 13,29 13.18,31.34 11,31 C 9.958,30.06 12.41,27.96 11,28 C 10,28 11.19,29.23 10,30 C 9,30 5.997,31 6,26 C 6,24 12,14 12,14 C 12,14 13.89,12.1 14,10.5 C 13.27,9.506 13.5,8.5 13.5,7.5 C 14.5,6.5 16.5,10 16.5,10 L 18.5,10 C 18.5,10 19.28,8.008 21,7 C 22,7 22,10 22,10" style="fill:#000000; stroke:#000000;" /> <path d="M 9.5 25.5 A 0.5 0.5 0 1 1 8.5,25.5 A 0.5 0.5 0 1 1 9.5 25.5 z" style="fill:#ffffff; stroke:#ffffff;" /> <path d="M 15 15.5 A 0.5 1.5 0 1 1 14,15.5 A 0.5 1.5 0 1 1 15 15.5 z" transform="matrix(0.866,0.5,-0.5,0.866,9.693,-5.173)" style="fill:#ffffff; stroke:#ffffff;" /> <path d="M 24.55,10.4 L 24.1,11.85 L 24.6,12 C 27.75,13 30.25,14.49 32.5,18.75 C 34.75,23.01 35.75,29.06 35.25,39 L 35.2,39.5 L 37.45,39.5 L 37.5,39 C 38,28.94 36.62,22.15 34.25,17.66 C 31.88,13.17 28.46,11.02 25.06,10.5 L 24.55,10.4 z " style="fill:#ffffff; stroke:none;" /> </g></g></g>'}),PawnWhite:h.define("chess.PawnWhite",{size:{width:28,height:33}},{markup:'<g class="rotatable"><g class="scalable"><path d="M 22,9 C 19.79,9 18,10.79 18,13 C 18,13.89 18.29,14.71 18.78,15.38 C 16.83,16.5 15.5,18.59 15.5,21 C 15.5,23.03 16.44,24.84 17.91,26.03 C 14.91,27.09 10.5,31.58 10.5,39.5 L 33.5,39.5 C 33.5,31.58 29.09,27.09 26.09,26.03 C 27.56,24.84 28.5,23.03 28.5,21 C 28.5,18.59 27.17,16.5 25.22,15.38 C 25.71,14.71 26,13.89 26,13 C 26,10.79 24.21,9 22,9 z " style="opacity:1; fill:#ffffff; fill-opacity:1; fill-rule:nonzero; stroke:#000000; stroke-width:1.5; stroke-linecap:round; stroke-linejoin:miter; stroke-miterlimit:4; stroke-dasharray:none; stroke-opacity:1;" /></g></g>'}),PawnBlack:h.define("chess.PawnBlack",{size:{width:28,height:33}},{markup:'<g class="rotatable"><g class="scalable"><path d="M 22,9 C 19.79,9 18,10.79 18,13 C 18,13.89 18.29,14.71 18.78,15.38 C 16.83,16.5 15.5,18.59 15.5,21 C 15.5,23.03 16.44,24.84 17.91,26.03 C 14.91,27.09 10.5,31.58 10.5,39.5 L 33.5,39.5 C 33.5,31.58 29.09,27.09 26.09,26.03 C 27.56,24.84 28.5,23.03 28.5,21 C 28.5,18.59 27.17,16.5 25.22,15.38 C 25.71,14.71 26,13.89 26,13 C 26,10.79 24.21,9 22,9 z " style="opacity:1; fill:#000000; fill-opacity:1; fill-rule:nonzero; stroke:#000000; stroke-width:1.5; stroke-linecap:round; stroke-linejoin:miter; stroke-miterlimit:4; stroke-dasharray:none; stroke-opacity:1;" /></g></g>'})},Tn=r.define("erd.Entity",{size:{width:150,height:60},attrs:{".outer":{fill:"#2ECC71",stroke:"#27AE60","stroke-width":2,points:"100,0 100,60 0,60 0,0"},".inner":{fill:"#2ECC71",stroke:"#27AE60","stroke-width":2,points:"95,5 95,55 5,55 5,5",display:"none"},text:{text:"Entity","font-family":"Arial","font-size":14,"ref-x":.5,"ref-y":.5,"y-alignment":"middle","text-anchor":"middle"}}},{markup:'<g class="rotatable"><g class="scalable"><polygon class="outer"/><polygon class="inner"/></g><text/></g>'}),Bn=Tn.define("erd.WeakEntity",{attrs:{".inner":{display:"auto"},text:{text:"Weak Entity"}}}),Gn=r.define("erd.Relationship",{size:{width:80,height:80},attrs:{".outer":{fill:"#3498DB",stroke:"#2980B9","stroke-width":2,points:"40,0 80,40 40,80 0,40"},".inner":{fill:"#3498DB",stroke:"#2980B9","stroke-width":2,points:"40,5 75,40 40,75 5,40",display:"none"},text:{text:"Relationship","font-family":"Arial","font-size":12,"ref-x":.5,"ref-y":.5,"y-alignment":"middle","text-anchor":"middle"}}},{markup:'<g class="rotatable"><g class="scalable"><polygon class="outer"/><polygon class="inner"/></g><text/></g>'}),zn=Gn.define("erd.IdentifyingRelationship",{attrs:{".inner":{display:"auto"},text:{text:"Identifying"}}}),On=r.define("erd.Attribute",{size:{width:100,height:50},attrs:{ellipse:{transform:"translate(50, 25)"},".outer":{stroke:"#D35400","stroke-width":2,cx:0,cy:0,rx:50,ry:25,fill:"#E67E22"},".inner":{stroke:"#D35400","stroke-width":2,cx:0,cy:0,rx:45,ry:20,fill:"#E67E22",display:"none"},text:{"font-family":"Arial","font-size":14,"ref-x":.5,"ref-y":.5,"y-alignment":"middle","text-anchor":"middle"}}},{markup:'<g class="rotatable"><g class="scalable"><ellipse class="outer"/><ellipse class="inner"/></g><text/></g>'}),Rn=On.define("erd.Multivalued",{attrs:{".inner":{display:"block"},text:{text:"multivalued"}}}),Ut=On.define("erd.Derived",{attrs:{".outer":{"stroke-dasharray":"3,5"},text:{text:"derived"}}}),Sn=On.define("erd.Key",{attrs:{ellipse:{"stroke-width":4},text:{text:"key","font-weight":"800","text-decoration":"underline"}}}),Pn=On.define("erd.Normal",{attrs:{text:{text:"Normal"}}}),Vn={Entity:Tn,WeakEntity:Bn,Relationship:Gn,IdentifyingRelationship:zn,Attribute:On,Multivalued:Rn,Derived:Ut,Key:Sn,Normal:Pn,ISA:r.define("erd.ISA",{type:"erd.ISA",size:{width:100,height:50},attrs:{polygon:{points:"0,0 50,50 100,0",fill:"#F1C40F",stroke:"#F39C12","stroke-width":2},text:{text:"ISA","font-size":18,"ref-x":.5,"ref-y":.3,"y-alignment":"middle","text-anchor":"middle"}}},{markup:'<g class="rotatable"><g class="scalable"><polygon/></g><text/></g>'}),Line:u.define("erd.Line",{},{cardinality:function(t){this.set("labels",[{position:-20,attrs:{text:{dy:-8,text:t}}}])}})},jn={State:xn.define("fsa.State",{attrs:{circle:{"stroke-width":3},text:{"font-weight":"800"}}}),StartState:r.define("fsa.StartState",{size:{width:20,height:20},attrs:{circle:{transform:"translate(10, 10)",r:10,fill:"#000000"}}},{markup:'<g class="rotatable"><g class="scalable"><circle/></g></g>'}),EndState:r.define("fsa.EndState",{size:{width:20,height:20},attrs:{".outer":{transform:"translate(10, 10)",r:10,fill:"#ffffff",stroke:"#000000"},".inner":{transform:"translate(10, 10)",r:6,fill:"#000000"}}},{markup:'<g class="rotatable"><g class="scalable"><circle class="outer"/><circle class="inner"/></g></g>'}),Arrow:u.define("fsa.Arrow",{attrs:{".marker-target":{d:"M 10 0 L 0 5 L 10 10 z"}},smooth:!0})},_n={Member:r.define("org.Member",{size:{width:180,height:70},attrs:{rect:{width:170,height:60},".card":{fill:"#FFFFFF",stroke:"#000000","stroke-width":2,"pointer-events":"visiblePainted",rx:10,ry:10},image:{width:48,height:48,ref:".card","ref-x":10,"ref-y":5},".rank":{"text-decoration":"underline",ref:".card","ref-x":.9,"ref-y":.2,"font-family":"Courier New","font-size":14,"text-anchor":"end"},".name":{"font-weight":"800",ref:".card","ref-x":.9,"ref-y":.6,"font-family":"Courier New","font-size":14,"text-anchor":"end"}}},{markup:'<g class="rotatable"><g class="scalable"><rect class="card"/><image/></g><text class="rank"/><text class="name"/></g>'}),Arrow:u.define("org.Arrow",{source:{selector:".card"},target:{selector:".card"},attrs:{".connection":{stroke:"#585858","stroke-width":3}},z:-1})},Tn={Place:h.define("pn.Place",{size:{width:50,height:50},attrs:{".root":{r:25,fill:"#ffffff",stroke:"#000000",transform:"translate(25, 25)"},".label":{"text-anchor":"middle","ref-x":.5,"ref-y":-20,ref:".root",fill:"#000000","font-size":12},".tokens > circle":{fill:"#000000",r:5},".tokens.one > circle":{transform:"translate(25, 25)"},".tokens.two > circle:nth-child(1)":{transform:"translate(19, 25)"},".tokens.two > circle:nth-child(2)":{transform:"translate(31, 25)"},".tokens.three > circle:nth-child(1)":{transform:"translate(18, 29)"},".tokens.three > circle:nth-child(2)":{transform:"translate(25, 19)"},".tokens.three > circle:nth-child(3)":{transform:"translate(32, 29)"},".tokens.alot > text":{transform:"translate(25, 18)","text-anchor":"middle",fill:"#000000"}}},{markup:'<g class="rotatable"><g class="scalable"><circle class="root"/><g class="tokens" /></g><text class="label"/></g>'}),PlaceView:g.extend({presentationAttributes:g.addPresentationAttributes({tokens:["TOKENS"]}),initFlag:g.prototype.initFlag.concat(["TOKENS"]),confirmUpdate:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var i=(i=g.prototype.confirmUpdate).call.apply(i,[this].concat(t));return this.hasFlag(i,"TOKENS")&&(this.renderTokens(),this.update(),i=this.removeFlag(i,"TOKENS")),i},renderTokens:function(){var e=this.vel.findOne(".tokens").empty(),t=(["one","two","three","alot"].forEach(function(t){e.removeClass(t)}),this.model.get("tokens"));if(t)switch(t){case 1:e.addClass("one"),e.append(B("circle"));break;case 2:e.addClass("two"),e.append([B("circle"),B("circle")]);break;case 3:e.addClass("three"),e.append([B("circle"),B("circle"),B("circle")]);break;default:e.addClass("alot"),e.append(B("text").text(t+""))}}}),Transition:h.define("pn.Transition",{size:{width:12,height:50},attrs:{rect:{width:12,height:50,fill:"#000000",stroke:"#000000"},".label":{"text-anchor":"middle","ref-x":.5,"ref-y":-20,ref:"rect",fill:"#000000","font-size":12}}},{markup:'<g class="rotatable"><g class="scalable"><rect class="root"/></g></g><text class="label"/>'}),Link:u.define("pn.Link",{attrs:{".marker-target":{d:"M 10 0 L 0 5 L 10 10 z"}}})},Bn=h.define("uml.Class",{attrs:{rect:{width:200},".uml-class-name-rect":{stroke:"black","stroke-width":2,fill:"#3498db"},".uml-class-attrs-rect":{stroke:"black","stroke-width":2,fill:"#2980b9"},".uml-class-methods-rect":{stroke:"black","stroke-width":2,fill:"#2980b9"},".uml-class-name-text":{ref:".uml-class-name-rect","ref-y":.5,"ref-x":.5,"text-anchor":"middle","y-alignment":"middle","font-weight":"bold",fill:"black","font-size":12,"font-family":"Times New Roman"},".uml-class-attrs-text":{ref:".uml-class-attrs-rect","ref-y":5,"ref-x":5,fill:"black","font-size":12,"font-family":"Times New Roman"},".uml-class-methods-text":{ref:".uml-class-methods-rect","ref-y":5,"ref-x":5,fill:"black","font-size":12,"font-family":"Times New Roman"}},name:[],attributes:[],methods:[]},{markup:['<g class="rotatable">','<g class="scalable">','<rect class="uml-class-name-rect"/><rect class="uml-class-attrs-rect"/><rect class="uml-class-methods-rect"/>',"</g>",'<text class="uml-class-name-text"/><text class="uml-class-attrs-text"/><text class="uml-class-methods-text"/>',"</g>"].join(""),initialize:function(){this.on("change:name change:attributes change:methods",function(){this.updateRectangles(),this.trigger("uml-update")},this),this.updateRectangles(),h.prototype.initialize.apply(this,arguments)},getClassName:function(){return this.get("name")},updateRectangles:function(){var n=this.get("attrs"),t=[{type:"name",text:this.getClassName()},{type:"attrs",text:this.get("attributes")},{type:"methods",text:this.get("methods")}],r=0;t.forEach(function(t){var e=Array.isArray(t.text)?t.text:[t.text],i=20*e.length+20;n[".uml-class-"+t.type+"-text"].text=e.join("\n"),n[".uml-class-"+t.type+"-rect"].height=i,n[".uml-class-"+t.type+"-rect"].transform="translate(0,"+r+")",r+=i})}}),Gn=g.extend({initialize:function(){g.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"uml-update",function(){this.update(),this.resize()})}}),zn=Bn.define("uml.Abstract",{attrs:{".uml-class-name-rect":{fill:"#e74c3c"},".uml-class-attrs-rect":{fill:"#c0392b"},".uml-class-methods-rect":{fill:"#c0392b"}}},{getClassName:function(){return["<<Abstract>>",this.get("name")]}}),On=Gn,Rn=Bn.define("uml.Interface",{attrs:{".uml-class-name-rect":{fill:"#f1c40f"},".uml-class-attrs-rect":{fill:"#f39c12"},".uml-class-methods-rect":{fill:"#f39c12"}}},{getClassName:function(){return["<<Interface>>",this.get("name")]}}),Ut={Class:Bn,ClassView:Gn,Abstract:zn,AbstractView:On,Interface:Rn,InterfaceView:Gn,Generalization:u.define("uml.Generalization",{attrs:{".marker-target":{d:"M 20 0 L 0 10 L 20 20 z",fill:"white"}}}),Implementation:u.define("uml.Implementation",{attrs:{".marker-target":{d:"M 20 0 L 0 10 L 20 20 z",fill:"white"},".connection":{"stroke-dasharray":"3,3"}}}),Aggregation:u.define("uml.Aggregation",{attrs:{".marker-target":{d:"M 40 10 L 20 20 L 0 10 L 20 0 z",fill:"white"}}}),Composition:u.define("uml.Composition",{attrs:{".marker-target":{d:"M 40 10 L 20 20 L 0 10 L 20 0 z",fill:"black"}}}),Association:u.define("uml.Association"),State:h.define("uml.State",{attrs:{".uml-state-body":{width:200,height:200,rx:10,ry:10,fill:"#ecf0f1",stroke:"#bdc3c7","stroke-width":3},".uml-state-separator":{stroke:"#bdc3c7","stroke-width":2},".uml-state-name":{ref:".uml-state-body","ref-x":.5,"ref-y":5,"text-anchor":"middle",fill:"#000000","font-family":"Courier New","font-size":14},".uml-state-events":{ref:".uml-state-separator","ref-x":5,"ref-y":5,fill:"#000000","font-family":"Courier New","font-size":14}},name:"State",events:[]},{markup:['<g class="rotatable">','<g class="scalable">','<rect class="uml-state-body"/>',"</g>",'<path class="uml-state-separator"/>','<text class="uml-state-name"/>','<text class="uml-state-events"/>',"</g>"].join(""),initialize:function(){this.on({"change:name":this.updateName,"change:events":this.updateEvents,"change:size":this.updatePath},this),this.updateName(),this.updateEvents(),this.updatePath(),h.prototype.initialize.apply(this,arguments)},updateName:function(){this.attr(".uml-state-name/text",this.get("name"))},updateEvents:function(){this.attr(".uml-state-events/text",this.get("events").join("\n"))},updatePath:function(){var t="M 0 20 L "+this.get("size").width+" 20";this.attr(".uml-state-separator/d",t,{silent:!0})}}),StartState:xn.define("uml.StartState",{type:"uml.StartState",attrs:{circle:{fill:"#34495e",stroke:"#2c3e50","stroke-width":2,rx:1}}}),EndState:h.define("uml.EndState",{size:{width:20,height:20},attrs:{"circle.outer":{transform:"translate(10, 10)",r:10,fill:"#ffffff",stroke:"#2c3e50"},"circle.inner":{transform:"translate(10, 10)",r:6,fill:"#34495e"}}},{markup:'<g class="rotatable"><g class="scalable"><circle class="outer"/><circle class="inner"/></g></g>'}),Transition:u.define("uml.Transition",{attrs:{".marker-target":{d:"M 10 0 L 0 5 L 10 10 z",fill:"#34495e",stroke:"#2c3e50"},".connection":{stroke:"#2c3e50"}}})},Zn=["arc","gap","cubic"],Yn=1,Wn=["smooth"],Fn=1/3,Un=2/3;function Hn(t,e,i){var r=[].concat(t,i,e);return r.reduce(function(t,e,i){var n=r[i+1];return null!=n&&(t[i]=mt(e,n)),t},[])}function Xn(t){var e,r=t.paper,i=r._jumpOverUpdateList;null==i&&(i=r._jumpOverUpdateList=[],(e=r.model).on("batch:stop",function(){if(!this.hasActiveBatch())for(var t=r._jumpOverUpdateList,e=0;e<t.length;e++){var i=t[e],n=i.getFlag(i.constructor.Flags.CONNECTOR);i.requestUpdate(n)}}),e.on("reset",function(){i=r._jumpOverUpdateList=[]})),i.indexOf(t)<0&&(i.push(t),t.listenToOnce(t.model,"change:connector remove",function(){i.splice(i.indexOf(t),1)}))}function Jn(t,e){return mt(t,e).squaredLength()}function $n(h,c,u,d){var g=new O,p=O.createSegment("M",h[0].start);return g.appendSegment(p),et(h).forEach(function(t,e){var i,n,r,o,s,a,l;t.isJump?"arc"===u?(s=-90,n=t.start.difference(t.end),Number(n.x<0||0===n.x&&n.y<0)&&(s+=180),r=t.midpoint(),o=new C(r,t.end).rotate(r,s),a=(i=new C(t.start,r)).pointAt(2/3).rotate(t.start,s),l=o.pointAt(1/3).rotate(o.end,-s),p=O.createSegment("C",a,l,o.end),g.appendSegment(p),i=new C(r,t.end),a=o.pointAt(1/3).rotate(o.end,s),l=i.pointAt(1/3).rotate(t.end,-s),p=O.createSegment("C",a,l,t.end),g.appendSegment(p)):"gap"===u?(p=O.createSegment("M",t.end),g.appendSegment(p)):"cubic"===u&&(s=t.start.theta(t.end),r=.6*c,o=1.35*c,n=t.start.difference(t.end),Number(n.x<0||0===n.x&&n.y<0)&&(o*=-1),a=z(t.start.x+r,t.start.y+o).rotate(t.start,s),l=z(t.end.x-r,t.end.y+o).rotate(t.end,s),p=O.createSegment("C",a,l,t.end),g.appendSegment(p)):(i=h[e+1],0==d||!i||i.isJump?(p=O.createSegment("L",t.end),g.appendSegment(p)):(n=d,r=g,o=t.end,s=t.start,a=i.end,l=o.distance(s)/2,e=o.distance(a)/2,l=-Math.min(n,l),n=-Math.min(n,e),e=o.clone().move(s,l).round(),s=o.clone().move(a,n).round(),l=new z(Fn*e.x+Un*o.x,Un*o.y+Fn*e.y),a=new z(Fn*s.x+Un*o.x,Un*o.y+Fn*s.y),n=O.createSegment("L",e),r.appendSegment(n),n=O.createSegment("C",l,a,s),r.appendSegment(n)))}),g}function Qn(t,e,i,n){var r=(n=n||{}).radius||10,n=n.raw,o=new O,s=O.createSegment("M",t);o.appendSegment(s);for(var a,l,h,c,u,d,g=0,p=i.length;g<p;g++)a=new z(i[g]),h=i[g-1]||t,u=i[g+1]||e,c=l||a.distance(h)/2,l=a.distance(u)/2,c=-Math.min(r,c),d=-Math.min(r,l),h=a.clone().move(h,c).round(),c=a.clone().move(u,d).round(),u=new z(1/3*h.x+2/3*a.x,2/3*a.y+1/3*h.y),d=new z(1/3*c.x+2/3*a.x,2/3*a.y+1/3*c.y),s=O.createSegment("L",h),o.appendSegment(s),s=O.createSegment("C",u,d,c),o.appendSegment(s);return s=O.createSegment("L",e),o.appendSegment(s),n?o:o.serialize()}function Kn(t,e,i,n,r){void 0===i&&(i=[]),void 0===n&&(n={});var o=Boolean(n.raw),s=n.direction,a=(void 0===s&&(s=qn.AUTO),n.precision),l=(void 0===a&&(a=3),{coeff:n.distanceCoefficient||.6,angleTangentCoefficient:n.angleTangentCoefficient||80,tau:n.tension||.5,sourceTangent:n.sourceTangent?new z(n.sourceTangent):null,targetTangent:n.targetTangent?new z(n.targetTangent):null}),n=("string"==typeof n.sourceDirection?l.sourceDirection=n.sourceDirection:"number"==typeof n.sourceDirection?l.sourceDirection=new z(1,0).rotate(null,n.sourceDirection):l.sourceDirection=n.sourceDirection?new z(n.sourceDirection).normalize():null,"string"==typeof n.targetDirection?l.targetDirection=n.targetDirection:"number"==typeof n.targetDirection?l.targetDirection=new z(1,0).rotate(null,n.targetDirection):l.targetDirection=n.targetDirection?new z(n.targetDirection).normalize():null,[t].concat(i.map(function(t){return new z(t)}),[e]));return e=l.sourceTangent||(t=function(t,e,i,n){if(n.sourceDirection)switch(n.sourceDirection){case tr.UP:return new z(0,-1);case tr.DOWN:return new z(0,1);case tr.LEFT:return new z(-1,0);case tr.RIGHT:return new z(0,1);case tr.AUTO:return er(t,e);case tr.CLOSEST_POINT:return nr(0,e);case tr.OUTWARDS:return or(t,e);default:return n.sourceDirection}switch(i){case qn.HORIZONTAL:return function(t,e){var t=t.sourceBBox;t=t.width&&t.height?t.sideNearestToPoint(e[0]):t.x>e[1].x?"right":"left";return new z("left"!==t?1:-1,0)}(t,e);case qn.VERTICAL:return function(t,e){var t=t.sourceBBox;t=t.width&&t.height?t.sideNearestToPoint(e[0]):t.y>e[1].y?"bottom":"top";return new z(0,"top"!==t?1:-1)}(t,e);case qn.CLOSEST_POINT:return nr(0,e);case qn.OUTWARDS:return or(t,e);default:qn.AUTO;return er(t,e)}}(r,n,s,l),i=n[0].distance(n[1])*l.coeff,(e=ar(t,n[1].difference(n[0]).normalize()))>Math.PI/4?(e=i+(e-Math.PI/4)*l.angleTangentCoefficient,t.clone().scale(e,e)):t.clone().scale(i,i)),s=l.targetTangent||(t=function(t,e,i,n){if(n.targetDirection)switch(n.targetDirection){case tr.UP:return new z(0,-1);case tr.DOWN:return new z(0,1);case tr.LEFT:return new z(-1,0);case tr.RIGHT:return new z(0,1);case tr.AUTO:return ir(t,e);case tr.CLOSEST_POINT:return rr(0,e);case tr.OUTWARDS:return sr(t,e);default:return n.targetDirection}switch(i){case qn.HORIZONTAL:return function(t,e){var t=t.targetBBox;t=t.width&&t.height?t.sideNearestToPoint(e[e.length-1]):t.x>e[e.length-2].x?"left":"right";return new z("left"!==t?1:-1,0)}(t,e);case qn.VERTICAL:return function(t,e){var t=t.targetBBox;t=t.width&&t.height?t.sideNearestToPoint(e[e.length-1]):t.y>e[e.length-2].y?"top":"bottom";return new z(0,"top"!==t?1:-1)}(t,e);case qn.CLOSEST_POINT:return rr(0,e);case qn.OUTWARDS:return sr(t,e);default:qn.AUTO;return ir(t,e)}}(r,n,s,l),r=n[(i=n.length-1)-1].distance(n[i])*l.coeff,(s=ar(t,n[i-1].difference(n[i]).normalize()))>Math.PI/4?(i=r+(s-Math.PI/4)*l.angleTangentCoefficient,t.clone().scale(i,i)):t.clone().scale(r,r)),i=function(t,e,i,n){for(var r=n.tau,o=n.coeff,s=[],a=[],l=[],h=t.length-1,c=0;c<h;c++)s[c]=t[c].distance(t[c+1]);a[0]=e,a[h]=i;for(var u=1;u<h;u++){var d=void 0,g=void 0,d=(d=1===u?t[u-1].clone().offset(a[u-1].x,a[u-1].y):t[u-1].clone(),g=u===h-1?t[u+1].clone().offset(a[u+1].x,a[u+1].y):t[u+1].clone(),d.difference(t[u]).normalize()),g=g.difference(t[u]).normalize(),p=ar(d,g),f=(Math.PI-p)/2,m=void 0,d=lr(d,g),v=void 0,d=(v=lr(t[u].difference(t[u+1]),t[u].difference(t[u-1])),d<0&&(f=-f),p<Math.PI/2&&(f<0&&v<0||0<f&&0<v)&&(f-=Math.PI),!function(t,e){var i=Math.cos(e),e=Math.sin(e),n=i*t.x-e*t.y,e=e*t.x+i*t.y;t.x=n,t.y=e}(m=g.clone(),f),m.clone()),p=m.clone(),v=s[u-1]*o,g=s[u]*o;d.scale(v,v),p.scale(g,g),a[u]=[d,p]}for(var y=0;y<h;y++){var b=void 0,w=void 0;b=0===y?t[y+1].difference(a[y].x/r,a[y].y/r):t[y+1].difference(a[y][1].x/r,a[y][1].y/r),w=y===h-1?t[y].clone().offset(a[y+1].x/r,a[y+1].y/r):t[y].difference(a[y+1][0].x/r,a[y+1][0].y/r),l[y]=[b,t[y],t[y+1],w]}return l}(n,e,s,l).map(function(t){return t=t,e=(e=l).tau,(i=new z).x=t[1].x+(t[2].x-t[0].x)/(6*e),i.y=t[1].y+(t[2].y-t[0].y)/(6*e),(n=new z).x=t[2].x+(t[3].x-t[1].x)/(6*e),n.y=t[2].y+(t[3].y-t[1].y)/(6*e),new d(t[1],i,n,t[2]);var e,i,n}),t=new O(i).round(a),o?t:t.serialize()}var qn={AUTO:"auto",HORIZONTAL:"horizontal",VERTICAL:"vertical",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"},tr={UP:"up",DOWN:"down",LEFT:"left",RIGHT:"right",AUTO:"auto",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"};function er(t,e){t=t.sourceBBox,t=t.width&&t.height?t.sideNearestToPoint(e[0]):t.sideNearestToPoint(e[1]);switch(t){case"top":return new z(0,-1);case"bottom":return new z(0,1);case"right":return new z(1,0);case"left":return new z(-1,0)}}function ir(t,e){t=t.targetBBox,t=t.width&&t.height?t.sideNearestToPoint(e[e.length-1]):t.sideNearestToPoint(e[e.length-2]);switch(t){case"top":return new z(0,-1);case"bottom":return new z(0,1);case"right":return new z(1,0);case"left":return new z(-1,0)}}function nr(t,e){return e[1].difference(e[0]).normalize()}function rr(t,e){var i=e.length-1;return e[i-1].difference(e[i]).normalize()}function or(t,e){t=t.sourceBBox.center();return e[0].difference(t).normalize()}function sr(t,e){t=t.targetBBox.center();return e[e.length-1].difference(t).normalize()}function ar(t,e){t=t.dot(e)/(t.magnitude()*e.magnitude());return 1<(t=t<-1?-1:t)&&(t=1),Math.acos(t)}function lr(t,e){return t.x*e.y-t.y*e.x}Kn.Directions=qn,Kn.TangentDirections=tr;var hr={jumpover:function(t,e,i,n){Xn(this);var r=n.raw,o=n.size||5,s=n.jump&&(""+n.jump).toLowerCase(),a=n.radius||0,l=n.ignoreConnectors||Wn,h=(-1===Zn.indexOf(s)&&(s=Zn[0]),this.paper),n=h.model.getLinks();if(1===n.length)return $n(Hn(t,e,i),o,s,a);var c=this.model,u=n.indexOf(c),d=h.options.defaultConnector||{},g=n.filter(function(t,e){t=t.get("connector")||d;return!et(l).includes(t.name)&&(!(u<e)||"jumpover"!==t.name)}),n=g.map(function(t){return h.findViewByModel(t)}),p=Hn(t,e,i),f=n.map(function(t){return null==t?[]:t===this?p:Hn(t.sourcePoint,t.targetPoint,t.route)},this),t=$n(p.reduce(function(t,r){var s,a,l,e=g.reduce(function(t,e,i){var n;return e!==c&&(n=r,e=f[i],i=et(e).reduce(function(t,e){e=n.intersection(e);return e&&t.push(e),t},[]),t.push.apply(t,i)),t},[]).sort(function(t,e){return Jn(r.start,t)-Jn(r.start,e)});return 0<e.length?t.push.apply(t,(s=r,l=o,(a=e).reduce(function(t,e,i){if(!0===e.skip)return t;var n=t.pop()||s,r=A(e).move(n.start,-l),e=A(e).move(n.start,+l),i=a[i+1];if(null!=i){var o=e.distance(i);o<=l&&(e=i.move(n.start,o),i.skip=!0)}else if(r.distance(n.end)<2*l+Yn)return t.push(n),t;if(e.distance(n.start)<2*l+Yn)return t.push(n),t;o=mt(r,e);return o.isJump=!0,t.push(mt(n.start,r),o,mt(e,n.end)),t},[]))):t.push(r),t},[]),o,s,a);return r?t:t.serialize()},normal:function(t,e,i,n){n=n&&n.raw,t=[t].concat(i).concat([e]),i=new v(t),e=new O(i);return n?e:e.serialize()},rounded:Qn,smooth:function(t,e,i,n){var r,o,n=n&&n.raw;return i&&0!==i.length?(i=[t].concat(i).concat([e]),i=d.throughPoints(i),r=new O(i)):(r=new O,i=O.createSegment("M",t),r.appendSegment(i),i=Math.abs(t.x-e.x)>=Math.abs(t.y-e.y)?(o=(t.x+e.x)/2,O.createSegment("C",o,t.y,o,e.y,e.x,e.y)):(o=(t.y+e.y)/2,O.createSegment("C",t.x,o,e.x,o,e.x,e.y)),r.appendSegment(i)),n?r:r.serialize()},curve:Kn},Sn=An.extend({tagName:"path",className:"highlight-stroke",attributes:{"pointer-events":"none","vector-effect":"non-scaling-stroke",fill:"none"},options:{padding:3,rx:0,ry:0,useFirstSubpath:!1,attrs:{"stroke-width":3,stroke:"#FEB663"}},getPathData:function(e,i){var n=this.options,t=n.useFirstSubpath;try{var r,o=B(i);s=o.convertToPathData().trim(),"PATH"!==o.tagName()||!t||0<(r=s.search(/.M/i)+1)&&(s=s.substr(0,r))}catch(t){var o=e.getNodeBoundingRect(i),s=B.rectToPath(R({},n,o.toJSON()))}return s},highlightConnection:function(t){this.vel.attr("d",t.getSerializedConnection())},highlightNode:function(t,e){var i,n,r,o=this.vel,s=this.options,a=s.padding,s=s.layer,l=t.getNodeMatrix(e);a&&(s||e!==t.el||o.remove(),i=(s=t.getNodeBoundingRect(e)).x+s.width/2,n=s.y+s.height/2,s=B.transformRect(s,l),r=Math.max(s.width,1),s=Math.max(s.height,1),s=B.createSVGMatrix({a:r=(r+a)/r,b:0,c:0,d:a=(s+a)/s,e:i-r*i,f:n-a*n}),l=l.multiply(s)),o.attr({d:this.getPathData(t,e),transform:B.matrixToTransformString(l)})},highlight:function(t,e){var i=this.vel,n=this.options;i.attr(n.attrs),t.isNodeConnection(e)?this.highlightConnection(t):this.highlightNode(t,e)}});Pn=An.extend({tagName:"rect",className:"highlight-mask",attributes:{"pointer-events":"none"},options:{padding:3,maskClip:20,deep:!1,attrs:{stroke:"#FEB663","stroke-width":3,"stroke-linecap":"butt","stroke-linejoin":"miter"}},VISIBLE:"white",INVISIBLE:"black",MASK_ROOT_ATTRIBUTE_BLACKLIST:["marker-start","marker-end","marker-mid","transform","stroke-dasharray"],MASK_CHILD_ATTRIBUTE_BLACKLIST:["stroke","fill","stroke-width","stroke-opacity","stroke-dasharray","fill-opacity","marker-start","marker-end","marker-mid"],MASK_REPLACE_TAGS:["FOREIGNOBJECT","IMAGE","USE","TEXT","TSPAN","TEXTPATH"],MASK_REMOVE_TAGS:["TEXT","TSPAN","TEXTPATH"],transformMaskChild:function(t,e){var i,n,r=this.MASK_CHILD_ATTRIBUTE_BLACKLIST,o=this.MASK_REPLACE_TAGS,s=this.MASK_REMOVE_TAGS,a=e.tagName();return!B.isSVGGraphicsElement(e)||s.includes(a)?(e.remove(),!1):o.includes(a)?((s=t.vel.findOne("#"+e.id))&&(o=s.node,a=t.getNodeBoundingRect(o),t.model.isElement()&&(a=B.transformRect(a,t.getNodeMatrix(o))),t=B("rect",a.toJSON()),a=(o=a.center()).x,o=o.y,i=(s=s.rotate()).angle,void 0===(n=s.cx)&&(n=a),void 0===(a=s.cy)&&(a=o),i&&t.rotate(i,n,a),e.parent().append(t)),e.remove(),!1):(r.forEach(function(t){"fill"===t&&"none"===e.attr("fill")||e.removeAttr(t)}),!0)},transformMaskRoot:function(t,e){this.MASK_ROOT_ATTRIBUTE_BLACKLIST.forEach(function(t){e.removeAttr(t)})},getMaskShape:function(e,t){var i=this,n=this.options,r=this.MASK_REPLACE_TAGS,n=n.deep,o=t.tagName();if("G"===o){if(!n)return null;for(var s=t.clone(),a=function(t){return i.transformMaskChild(e,t)},l=s.children();0<l.length;){var h=l.shift();a(h)&&l.push.apply(l,h.children())}}else{if(r.includes(o))return null;s=t.clone()}return this.transformMaskRoot(e,s),s},getMaskId:function(){return"highlight-mask-"+this.cid},getMask:function(t,e){var i=this.VISIBLE,n=this.INVISIBLE,r=this.options,o=r.padding,r=r.attrs,s="stroke-width"in r?r["stroke-width"]:1,a="none"!==e.attr("fill"),l=parseFloat(e.attr("stroke-width")),l=(l=isNaN(l)?1:l)+2*o,o=l+2*s,s=this.getMaskShape(t,e);return s||((t=t.getNodeBoundingRect(e.node)).inflate(t.width?0:.5,t.height?0:.5),s=B("rect",t.toJSON())),s.attr(r),B("mask",{id:this.getMaskId()}).append([s.clone().attr({fill:a?i:"none",stroke:i,"stroke-width":o}),s.clone().attr({fill:a?n:"none",stroke:n,"stroke-width":l})])},removeMask:function(t){var e=t.svg.getElementById(this.getMaskId());e&&t.defs.removeChild(e)},addMask:function(t,e){t.defs.appendChild(e.node)},highlight:function(t,e){var i=this.options,n=this.vel,r=i.padding,o=i.attrs,s=i.maskClip,i=(void 0===s&&(s=20),i.layer),o="stroke"in o?o.stroke:"#000000",i=(i||e!==t.el||n.remove(),t.getNodeBoundingRect(e).inflate(r+s)),r=this.getMask(t,B(e));this.addMask(t.paper,r),n.attr(i.toJSON()),n.attr({transform:B.matrixToTransformString(t.getNodeMatrix(e)),mask:"url(#"+r.id+")",fill:o})},unhighlight:function(t){this.removeMask(t.paper)}}),Bn=An.extend({UPDATABLE:!1,MOUNTABLE:!1,opacityClassName:Ie("highlight-opacity"),highlight:function(t,e){B(e).addClass(this.opacityClassName)},unhighlight:function(t,e){B(e).removeClass(this.opacityClassName)}}),zn=Ie("highlighted"),On={stroke:Sn,mask:Pn,opacity:Bn,addClass:An.extend({UPDATABLE:!1,MOUNTABLE:!1,options:{className:zn},highlight:function(t,e){B(e).addClass(this.options.className)},unhighlight:function(t,e){B(e).removeClass(this.options.className)}},{className:zn})};function cr(t,e,i){var n;if(fi(i)&&(n=i.x,r=i.y,isFinite(r)&&(e=(r=new C(e,t).parallel(r)).start,t=r.end),i=n),!isFinite(i))return t;var r=t.distance(e);return 0===i&&0<r?t:t.move(e,-Math.min(i,r-1))}function ur(t){t=t.getAttribute("stroke-width");return null!==t&&parseFloat(t)||0}function dr(t,e,i,n){e=e.getNodeBBox(i),n.stroke&&e.inflate(ur(i)/2),i=t.intersect(e);return cr(i?t.start.chooseClosest(i):t.end,t.start,n.offset)}var gr="segmentSubdivisons",pr="shapeBBox";Rn={anchor:function(t,e,i,n){var r=n.offset,o=n.alignOffset;return(n=n.align)&&function(t,e,i){void 0===i&&(i=0);var n,r,o,s,a=t.start,l=t.end;switch(e){case"left":n="x",r=l,o=a,s=-1;break;case"right":n="x",r=a,o=l,s=1;break;case"top":n="y",r=l,o=a,s=-1;break;case"bottom":n="y",r=a,o=l,s=1;break;default:return}a[n]<l[n]?r[n]=o[n]:o[n]=r[n],isFinite(i)&&(r[n]+=s*i,o[n]+=s*i)}(t,n,o),cr(t.end,t.start,r)},bbox:dr,rectangle:function(t,e,i,n){var r=e.model.angle();if(0===r)return dr(t,e,i,n);var e=e.getNodeUnrotatedBBox(i),i=(n.stroke&&e.inflate(ur(i)/2),e.center()),o=t.clone().rotate(i,r);return cr((e=o.setLength(1e6).intersect(e))?o.start.chooseClosest(e).rotate(i,-r):t.end,t.start,n.offset)},boundary:function(t,e,i,n){var r=n.selector,o=t.end,r="string"==typeof r?e.findBySelector(r)[0]:Array.isArray(r)?Me(i,r):function(t){if(!t)return null;var e=t;do{var i=e.tagName;if("string"!=typeof i)return null;if("G"===(i=i.toUpperCase()))e=e.firstElementChild;else{if("TITLE"!==i)break;e=e.nextElementSibling}}while(e);return e}(i);if(!B.isSVGGraphicsElement(r)){if(r===i||!B.isSVGGraphicsElement(i))return o;r=i}var s,i=e.getNodeShape(r),a=e.getNodeMatrix(r),l=e.getRootTranslateMatrix(),h=e.getRootRotateMatrix(),h=(l=l.multiply(h).multiply(a)).inverse(),h=(a=B.transformLine(t,h)).start.clone(),e=e.getNodeData(r);return!1===n.insideout&&(e[pr]||(e[pr]=i.bbox()),e[pr].containsPoint(h))?o:(i instanceof O&&(s=n.precision||2,e[gr]||(e[gr]=i.getSegmentSubdivisions({precision:s})),s={precision:s,segmentSubdivisions:e[gr]}),!0===n.extrapolate&&a.setLength(1e6),(e=a.intersect(i,s))?B.isArray(e)&&(e=h.chooseClosest(e)):!0===n.sticky&&(e=i instanceof tt?i.pointNearestToPoint(h):i instanceof wt?i.intersectionWithLineFromCenterToPoint(h):i.closestPoint(h,s)),a=e?B.transformPoint(e,l):o,i=n.offset||0,n.stroke&&(i+=ur(r)/2),cr(a,t.start,i))}};function fr(t,e){if(0===e)return"0%";return Math.round(t/e*100*1e3)/1e3+"%"}function mr(r){return function(t,e,i,n){return(e.isNodeConnection(i)?yr:vr)(r,t,e,i,n)}}function vr(t,e,i,n,r){var o=i.model.angle(),n=i.getNodeUnrotatedBBox(n),i=i.model.getBBox().center(),i=(r.rotate(i,o),r.x-n.x),o=r.y-n.y;return t&&(i=fr(i,n.width),o=fr(o,n.height)),e.anchor={name:"topLeft",args:{dx:i,dy:o,rotate:!0}},e}function yr(t,e,i,n,r){i=i.getConnection();if(!i)return e;r=i.closestPointLength(r);return t?(t=i.length(),e.anchor={name:"connectionRatio",args:{ratio:r/t}}):e.anchor={name:"connectionLength",args:{length:r}},e}var Gn=mr(!1),br=mr(!0),xn={useDefaults:He,pinAbsolute:Gn,pinRelative:br},wr={N:"S",S:"N",E:"W",W:"E"},Ar={N:-Math.PI/2*3,S:-Math.PI/2,E:0,W:Math.PI};function Cr(t,e,i){var n=new z(t.x,e.y);return n=i.containsPoint(n)?new z(e.x,t.y):n}function Ir(t,e){return t["W"===e||"E"===e?"width":"height"]}function xr(t,e){return t.x===e.x?t.y>e.y?"N":"S":t.y===e.y?t.x>e.x?"W":"E":null}function Sr(t){return new tt(t.x,t.y,0,0)}function Pr(t){t=ei(t.padding||t.elementPadding||20);return{x:-t.left,y:-t.top,width:t.left+t.right,height:t.top+t.bottom}}function Mr(t,e){return t.sourceBBox.clone().moveAndExpand(Pr(e))}function kr(t,e){return t.targetBBox.clone().moveAndExpand(Pr(e))}function Nr(t,e,i){var n=new z(t.x,e.y),r=new z(e.x,t.y),o=xr(t,n),t=xr(t,r),s=wr[i],o=o===i||o!==s&&(t===s||t!==i)?n:r;return{points:[o],direction:xr(o,e)}}function Tr(t,e,i){t=Cr(t,e,i);return{points:[t],direction:xr(t,e)}}function Lr(t,e,i,n,r){var o={},i=i.union(n).inflate(1),n=i.center().distance(e)>i.center().distance(t),s=n?e:t,t=n?t:e,a=r?(a=z.fromPolar(i.width+i.height,Ar[r],s),i.pointNearestToPoint(a).move(a,-1)):i.pointNearestToPoint(s).move(s,1),r=Cr(a,t,i);return a.round().equals(r.round())?(r=z.fromPolar(i.width+i.height,K(a.theta(s))+Math.PI/2,t),s=Cr(a,r=i.pointNearestToPoint(r).move(t,1).round(),i),o.points=n?[r,s,a]:[a,s,r]):o.points=n?[r,a]:[a,r],o.direction=xr(n?a:r,e),o}function Er(t,e,i){var n,r,o=Mr(i,e),s=kr(i,e),a=(n=e,(a=i).sourceAnchor||Mr(a,n).center()),i=(n=e,(i=i).targetAnchor||kr(i,n).center()),o=o.union(Sr(a)),s=s.union(Sr(i));(t=et(t).map(z)).unshift(a),t.push(i);for(var l,h,c,u,d,g,p=[],f=0,m=t.length-1;f<m;f++){var v,y=null,b=t[f],w=t[f+1],A=!!xr(b,w);0===f?f+1===m?o.intersect(s.clone().inflate(1))?y=Lr(b,w,o,s):A||(h=o,g=d=u=void 0,d=Tr(v=w,l=b,c=s),g=d.points[0],h.containsPoint(g)&&(u=(d=Tr(l,v,h)).points[0],c.containsPoint(u)&&(u=new z(l).move(u,-Ir(h,xr(l,u))/2),c=new z(v).move(g,-Ir(c,xr(v,g))/2),c=Nr(g=new C(u,c).midpoint(),v,(u=Tr(l,g,h)).direction),d.points=[u.points[0],c.points[0]],d.direction=c.direction)),y=d):o.containsPoint(w)?y=Lr(b,w,o,Sr(w).moveAndExpand(Pr(e))):A||(y=Tr(b,w,o)):f+1===m?(v=A&&xr(w,b)===r,s.containsPoint(b)||v?y=Lr(b,w,Sr(b).moveAndExpand(Pr(e)),s,r):A||(y=function(e,t,i,n){var r,o={},s=[new z(e.x,t.y),new z(t.x,e.y)],a=s.filter(function(t){return!i.containsPoint(t)}),l=a.filter(function(t){return xr(t,e)!==n});return 0<l.length?(r=(r=l.filter(function(t){return xr(e,t)===n}).pop())||l[0],o.points=[r],o.direction=xr(r,t)):(r=Ai(s,a)[0],s=Cr(l=new z(t).move(r,-Ir(i,n)/2),e,i),o.points=[s,l],o.direction=xr(l,t)),o}(b,w,s,r))):A||(y=Nr(b,w,r)),r=y?(Array.prototype.push.apply(p,y.points),y.direction):xr(b,w),f+1<m&&p.push(w)}return p}var Dr={step:10,maximumLoops:2e3,precision:1,maxAllowedDirectionChange:90,perpendicular:!0,excludeEnds:[],excludeTypes:["basic.Text"],startDirections:["top","right","bottom","left"],endDirections:["top","right","bottom","left"],directionMap:{top:{x:0,y:-1},right:{x:1,y:0},bottom:{x:0,y:1},left:{x:-1,y:0}},cost:function(){return this.step},directions:function(){var t=this.step,e=this.cost();return[{offsetX:t,offsetY:0,cost:e},{offsetX:-t,offsetY:0,cost:e},{offsetX:0,offsetY:t,cost:e},{offsetX:0,offsetY:-t,cost:e}]},penalties:function(){return{0:0,45:this.step/2,90:this.step/2}},paddingBox:function(){var t=this.step;return{x:-t,y:-t,width:2*t,height:2*t}},isPointObstacle:null,fallbackRouter:function(t,e,i){if(P(Er))return Er(t,R({},Dr,e),i);throw new Error("Manhattan requires the orthogonal router as default fallback.")},fallbackRoute:function(t,e,i){return null},draggingRoute:null};function Br(t){this.map={},this.options=t,this.mapGridSize=100}function Gr(){this.items=[],this.hash={},this.values={},this.OPEN=1,this.CLOSE=2}function zr(t,e){return e&&e.paddingBox?t.sourceBBox.clone().moveAndExpand(e.paddingBox):t.sourceBBox.clone()}function Or(t,e){return e&&e.paddingBox?t.targetBBox.clone().moveAndExpand(e.paddingBox):t.targetBBox.clone()}function Rr(t,e){return t.sourceAnchor||zr(t,e).center()}function Vr(t,e,i,n,r){var o,s,i=360/i,n=t.theta((e=e,o=n,r=(r=r).step,s=e.x-t.x,e=e.y-t.y,s/=n.x,e/=n.y,o=s*r,s=e*r,new z(t.x+o,t.y+s))),e=Q(n+i/2);return i*Math.floor(e/i)}function jr(t,e){t=Math.abs(t-e);return 180<t?360-t:t}function _r(t,e){if(!t)return e;var t=Math.abs(t),i=Math.round(t/e);return i?e+(t-i*e)/i:t}function Zr(t,e){return t.round(e)}function Yr(t,e,i){return Zr((t=t.clone(),n=(e=e).source,r=E(t.x-n.x,e.x)+n.x,t=E(t.y-n.y,e.y)+n.y,new z(r,t)),i);var n,r}function Wr(t){return t.clone().toString()}function Fr(t){return new z(0===t.x?0:Math.abs(t.x)/t.x,0===t.y?0:Math.abs(t.y)/t.y)}function Ur(t,e){for(var i=1/0,n=0,r=e.length;n<r;n++){var o=t.manhattanDistance(e[n]);o<i&&(i=o)}return i}function Hr(c,u,t,d,e){var g=e.precision,p=e.directionMap,f=c.difference(u.center()),e=x(p)?Object.keys(p):[],m=et(t),t=e.reduce(function(t,e){if(m.includes(e)){for(var i,e=p[e],n=new z(c.x+e.x*(Math.abs(f.x)+u.width),c.y+e.y*(Math.abs(f.y)+u.height)),r=new C(c,n).intersect(u)||[],o=r.length,s=null,a=0;a<o;a++){var l=r[a],h=c.squaredDistance(l);(void 0===i||i<h)&&(i=h,s=l)}s&&(n=Yr(s,d,g),u.containsPoint(n)&&(n=Yr(n.offset(e.x*d.x,e.y*d.y),d,g)),t.push(n))}return t},[]);return u.containsPoint(c)||t.push(Yr(c,d,g)),t}function Xr(t,e,i,n){var r,o,s,a,l,h,c,u=n.precision,d=Zr((t instanceof tt?Rr(this,n):t).clone(),u),g=Zr(e instanceof tt?(r=n,((g=this).targetAnchor||Or(g,r).center()).clone()):e.clone(),u),p=(r=n.step,s=g,{source:(o=d).clone(),x:_r(s.x-o.x,r),y:_r(s.y-o.y,r)}),f=t instanceof tt?Hr(a=d,t,n.startDirections,p,n):[a=d],m=e instanceof tt?Hr(l=g,e,n.endDirections,p,n):[l=g];if(f=f.filter(function(t){return!i(t)}),m=m.filter(function(t){return!i(t)}),0<f.length&&0<m.length){for(var v=new Gr,y={},b={},w={},A=0,z=f.length;A<z;A++){var C=f[A],I=Wr(C);v.add(I,Ur(C,m)),y[I]=C,w[I]=0}for(var O=n.previousDirectionAngle,R=void 0===O,V=n.directions,x=(h=p,c=n.step,et(n.directions).forEach(function(t){t.gridOffsetX=t.offsetX/c*h.x,t.gridOffsetY=t.offsetY/c*h.y}),V.length),j=et(m).reduce(function(t,e){e=Wr(e);return t.push(e),t},[]),_=n.maximumLoops;!v.isEmpty()&&0<_;){var S=v.pop(),P=y[S],M=b[S],Z=w[S],k=void 0===M,Y=P.equals(a),W=k?R?Y?null:Vr(a,P,x,p,n):O:Vr(M,P,x,p,n),F=f.length===m.length;if(F)for(var N=0;N<f.length;N++)if(!f[N].equals(m[N])){F=!1;break}if(!(k&&F)&&0<=j.indexOf(S)){n.previousDirectionAngle=W;for(var U=b,H=y,M=P,k=a,S=l,X=[],J=Fr(S.difference(M)),T=Wr(M),L=U[T];L;){var $,Q=Fr(($=H[T]).difference(L));Q.equals(J)||(X.unshift($),J=Q),L=U[T=Wr(L)]}return Fr((S=H[T]).difference(k)).equals(J)||X.unshift(S),X}for(A=0;A<x;A++){var E,K=(E=V[A]).angle,q=jr(W,K);if(R&&Y||!(q>n.maxAllowedDirectionChange)){var D=Yr(P.clone().offset(E.gridOffsetX,E.gridOffsetY),p,u),B=Wr(D);if(!v.isClose(B)&&!i(D)){if(0<=j.indexOf(B)){var G=D.equals(l);if(!G)if(jr(K,Vr(D,l,x,p,n))>n.maxAllowedDirectionChange)continue}G=Z+E.cost+(Y?0:n.penalties[q]);(!v.isOpen(B)||G<w[B])&&(y[B]=D,b[B]=P,w[B]=G,v.add(B,G+Ur(D,m)))}}}_--}}return n.fallbackRoute.call(this,a,l,n)}function Jr(t,e,i){(n=e).directions=M(n,"directions"),n.penalties=M(n,"penalties"),n.paddingBox=M(n,"paddingBox"),n.padding=M(n,"padding"),n.padding&&(r=ei(n.padding),n.paddingBox={x:-r.left,y:-r.top,width:r.left+r.right,height:r.top+r.bottom}),et(n.directions).forEach(function(t){var e=new z(0,0),i=new z(t.offsetX,t.offsetY);t.angle=Q(e.theta(i))}),i.options.perpendicular=!!e.perpendicular;for(var n,r,o,s=zr(i,e),a=Or(i,e),l=Rr(i,e),h="function"==typeof e.isPointObstacle?e.isPointObstacle:((o=new Br(e)).build(i.paper.model,i.model),function(t){return!o.isPointAccessible(t)}),c=et(t).map(z),u=[],d=l,g=0,p=c.length;g<=p;g++){var f,m,v=null,y=f||s;if((f=c[g])||(f=a,i.model.get("source").id&&i.model.get("target").id||!P(e.draggingRoute)||(b=y===s?l:y,m=f.origin(),v=e.draggingRoute.call(i,b,m,e))),null===(v=v||Xr.call(i,y,f,h,e)))return e.fallbackRouter(t,e,i);var b=v[0];b&&b.equals(d)&&v.shift(),d=v[v.length-1]||d,Array.prototype.push.apply(u,v)}return u}Br.prototype.build=function(i,n){var u=this.options,d=et(u.excludeEnds).reduce(function(t,e){var e=n.get(e);return e&&(e=i.getCell(e.id))&&t.push(e),t},[]),g=[],t=i.getCell(n.get("source").id),t=(t&&(g=Ii(g,t.getAncestors().map(function(t){return t.id}))),i.getCell(n.get("target").id)),p=(t&&(g=Ii(g,t.getAncestors().map(function(t){return t.id}))),this.mapGridSize);return i.getElements().reduce(function(t,e){var i=et(u.excludeTypes).includes(e.get("type")),n=d.find(function(t){return t.id===e.id}),r=g.includes(e.id);if(!(i||n||r))for(var o=e.getBBox().moveAndExpand(u.paddingBox),s=o.origin().snapToGrid(p),a=o.corner().snapToGrid(p),l=s.x;l<=a.x;l+=p)for(var h=s.y;h<=a.y;h+=p){var c=l+"@"+h;t[c]=t[c]||[],t[c].push(o)}return t},this.map),this},Br.prototype.isPointAccessible=function(e){var t=e.clone().snapToGrid(this.mapGridSize).toString();return et(this.map[t]).every(function(t){return!t.containsPoint(e)})},Gr.prototype.add=function(t,e){this.hash[t]?this.items.splice(this.items.indexOf(t),1):this.hash[t]=this.OPEN,this.values[t]=e;e=hi(this.items,t,function(t){return this.values[t]}.bind(this));this.items.splice(e,0,t)},Gr.prototype.remove=function(t){this.hash[t]=this.CLOSE},Gr.prototype.isOpen=function(t){return this.hash[t]===this.OPEN},Gr.prototype.isClose=function(t){return this.hash[t]===this.CLOSE},Gr.prototype.isEmpty=function(){return 0===this.items.length},Gr.prototype.pop=function(){var t=this.items.shift();return this.remove(t),t};function $r(t,e,i){return Jr(t,R({},Dr,e),i)}var Qr={maxAllowedDirectionChange:45,diagonalCost:function(){var t=this.step;return Math.ceil(Math.sqrt(t*t<<1))},directions:function(){var t=this.step,e=this.cost(),i=this.diagonalCost();return[{offsetX:t,offsetY:0,cost:e},{offsetX:t,offsetY:t,cost:i},{offsetX:0,offsetY:t,cost:e},{offsetX:-t,offsetY:t,cost:i},{offsetX:-t,offsetY:0,cost:e},{offsetX:-t,offsetY:-t,cost:i},{offsetX:0,offsetY:-t,cost:e},{offsetX:t,offsetY:-t,cost:i}]},fallbackRoute:function(t,e,i){var n=t.theta(e),r=[],o={x:e.x,y:t.y},s={x:t.x,y:e.y},a=(90<n%180&&(a=o,o=s,s=a),n%90<45?o:s),o=new C(t,a),s=90*Math.ceil(n/90),n=z.fromPolar(o.squaredLength(),K(135+s),a),s=new C(e,n),a=o.intersection(s),n=a||e,o=a?n:t,s=360/i.directions.length,a=o.theta(e),t=Q(a+s/2),o=s*Math.floor(t/s);return i.previousDirectionAngle=o,n&&r.push(n.round()),r.push(e),r}},Kr={normal:function(t,e,i){return t},oneSide:function(t,e,i){var n,r,o,s=e.side||"bottom",e=ei(e.padding||40),a=i.sourceBBox,i=i.targetBBox,l=a.center(),h=i.center();switch(s){case"bottom":o=1,n="y",r="height";break;case"top":o=-1,n="y",r="height";break;case"left":o=-1,n="x",r="width";break;case"right":o=1,n="x",r="width";break;default:throw new Error("Router: invalid side")}return l[n]+=o*(a[r]/2+e[s]),h[n]+=o*(i[r]/2+e[s]),0<o*(l[n]-h[n])?h[n]=l[n]:l[n]=h[n],[l].concat(t,h)},orthogonal:Er,manhattan:$r,metro:function(t,e,i){if(P($r))return $r(t,R({},Qr,e),i);throw new Error("Metro requires the manhattan router.")}};function qr(o){return function(t,e,i,n){var r;return i instanceof Element?(r=(r=this.paper.findView(i))?r.isNodeConnection(i)?to(r,"fixedAt"in n?n.fixedAt:"50%"):r.getNodeBBox(i).center():new z,o.call(this,t,e,r,n)):o.apply(this,arguments)}}function to(t,e){var i=parseFloat(e);return ti(e)?t.getPointAtRatio(i/100):t.getPointAtLength(i)}var Sn=qr(function(t,e,i,n){var r=t.getConnection(),o=t.getConnectionSubdivisions(),s=new C(i.clone().offset(0,1e6),i.clone().offset(0,-1e6)),a=new C(i.clone().offset(1e6,0),i.clone().offset(-1e6,0)),s=s.intersect(r,{segmentSubdivisions:o}),a=a.intersect(r,{segmentSubdivisions:o}),r=[];return s&&Array.prototype.push.apply(r,s),a&&Array.prototype.push.apply(r,a),0<r.length?i.chooseClosest(r):"fallbackAt"in n?to(t,n.fallbackAt):eo(t,e,i,n)}),eo=qr(function(t,e,i,n){return(t=t.getClosestPoint(i))||new z}),Pn={resolveRef:qr,connectionRatio:function(t,e,i,n){return n="ratio"in n?n.ratio:.5,t.getPointAtRatio(n)},connectionLength:function(t,e,i,n){return n="length"in n?n.length:20,t.getPointAtLength(n)},connectionPerpendicular:Sn,connectionClosest:eo};function io(l){return function(t,e,i,n){var r=!!n.rotate,e=r?t.getNodeUnrotatedBBox(e):t.getNodeBBox(e),o=e[l](),s=n.dx,a=(s&&(a=ti(s),s=parseFloat(s),isFinite(s)&&(a&&(s=s/100*e.width),o.x+=s)),n.dy);return a&&(s=ti(a),a=parseFloat(a),isFinite(a)&&(s&&(a=a/100*e.height),o.y+=a)),r?o.rotate(t.model.getBBox().center(),-t.model.angle()):o}}var Bn={center:io("center"),top:io("topMiddle"),bottom:io("bottomMiddle"),left:io("leftMiddle"),right:io("rightMiddle"),topLeft:io("origin"),topRight:io("topRight"),bottomLeft:io("bottomLeft"),bottomRight:io("corner"),perpendicular:qr(function(t,e,i,n){var r,o=t.model.angle(),e=(t=t.getNodeBBox(e)).center(),s=t.origin(),t=t.corner(),n=n.padding;return isFinite(n)||(n=0),s.y+n<=i.y&&i.y<=t.y-n?(r=i.y-e.y,e.x+=0===o||180===o?0:r/Math.tan(K(o)),e.y+=r):s.x+n<=i.x&&i.x<=t.x-n&&(r=i.x-e.x,e.y+=90===o||270===o?0:r*Math.tan(K(o)),e.x+=r),e}),midSide:qr(function(t,e,i,n){var r,o,s,a,l=!!n.rotate,t=(l?(r=t.getNodeUnrotatedBBox(e),s=t.model.getBBox().center(),o=t.model.angle()):r=t.getNodeBBox(e),n.padding);switch(isFinite(t)&&r.inflate(t),l&&i.rotate(s,o),r.sideNearestToPoint(i)){case"left":a=r.leftMiddle();break;case"right":a=r.rightMiddle();break;case"top":a=r.topMiddle();break;case"bottom":a=r.bottomMiddle()}return l?a.rotate(s,-o):a}),modelCenter:function(t,e,i,n,r){return t.model.getPointFromConnectedLink(this.model,r).offset(n.dx,n.dy)}},no=o.Collection.extend({initialize:function(t,e){e.cellNamespace?this.cellNamespace=e.cellNamespace:this.cellNamespace="undefined"!=typeof joint&&xi(joint,"shapes")?joint.shapes:null,this.graph=e.graph},model:function(t,e){var i=e.collection,n=i.cellNamespace,n=new("link"===t.type?u:Me(n,t.type,".")||r)(t,e);return e.dry||(n.graph=i.graph),n},comparator:function(t){return t.get("z")||0}}),ro=o.Model.extend({initialize:function(t,e){e=new no([],{model:(e=e||{}).cellModel,cellNamespace:e.cellNamespace,graph:this});o.Model.prototype.set.call(this,"cells",e),e.on("all",this.trigger,this),this.on("change:z",this._sortOnChangeZ,this),this._out={},this._in={},this._nodes={},this._edges={},this._batches={},e.on("add",this._restructureOnAdd,this),e.on("remove",this._restructureOnRemove,this),e.on("reset",this._restructureOnReset,this),e.on("change:source",this._restructureOnChangeSource,this),e.on("change:target",this._restructureOnChangeTarget,this),e.on("remove",this._removeCell,this)},_sortOnChangeZ:function(){this.get("cells").sort()},_restructureOnAdd:function(t){var e,i;t.isLink()?(this._edges[t.id]=!0,e=(i=t.attributes).source,i=i.target,e.id&&((this._out[e.id]||(this._out[e.id]={}))[t.id]=!0),i.id&&((this._in[i.id]||(this._in[i.id]={}))[t.id]=!0)):this._nodes[t.id]=!0},_restructureOnRemove:function(t){var e,i;t.isLink()?(delete this._edges[t.id],e=(i=t.attributes).source,i=i.target,e.id&&this._out[e.id]&&this._out[e.id][t.id]&&delete this._out[e.id][t.id],i.id&&this._in[i.id]&&this._in[i.id][t.id]&&delete this._in[i.id][t.id]):delete this._nodes[t.id]},_restructureOnReset:function(t){t=t.models,this._out={},this._in={},this._nodes={},this._edges={},t.forEach(this._restructureOnAdd,this)},_restructureOnChangeSource:function(t){var e=t.previous("source"),e=(e.id&&this._out[e.id]&&delete this._out[e.id][t.id],t.attributes.source);e.id&&((this._out[e.id]||(this._out[e.id]={}))[t.id]=!0)},_restructureOnChangeTarget:function(t){var e=t.previous("target"),e=(e.id&&this._in[e.id]&&delete this._in[e.id][t.id],t.get("target"));e.id&&((this._in[e.id]||(this._in[e.id]={}))[t.id]=!0)},getOutboundEdges:function(t){return this._out&&this._out[t]||{}},getInboundEdges:function(t){return this._in&&this._in[t]||{}},toJSON:function(){var t=o.Model.prototype.toJSON.apply(this,arguments);return t.cells=this.get("cells").toJSON(),t},fromJSON:function(t,e){if(t.cells)return this.set(t,e);throw new Error("Graph JSON must contain cells array.")},set:function(t,e,i){var n;return"object"==typeof t?(n=t,i=e):(n={})[t]=e,n.hasOwnProperty("cells")&&(this.resetCells(n.cells,i),n=Si(n,"cells")),o.Model.prototype.set.call(this,n,i)},clear:function(t){t=R({},t,{clear:!0});var e=this.get("cells");if(0===e.length)return this;this.startBatch("clear",t);for(var i=e.sortBy(function(t){return t.isLink()?1:2});i.shift().remove(t),0<i.length;);return this.stopBatch("clear"),this},_prepareCell:function(t,e){var i;if(t instanceof o.Model?(i=t.attributes,t.graph||e&&e.dry||(t.graph=this)):i=t,N(i.type))return t;throw new TypeError("dia.Graph: cell type must be a string.")},minZIndex:function(){var t=this.get("cells").first();return t&&t.get("z")||0},maxZIndex:function(){var t=this.get("cells").last();return t&&t.get("z")||0},addCell:function(t,e){return Array.isArray(t)?this.addCells(t,e):(t instanceof o.Model?t.has("z")||t.set("z",this.maxZIndex()+1):void 0===t.z&&(t.z=this.maxZIndex()+1),this.get("cells").add(this._prepareCell(t,e),e||{}),this)},addCells:function(t,e){return 0===t.length||(t=bi(t),e.maxPosition=e.position=t.length-1,this.startBatch("add",e),t.forEach(function(t){this.addCell(t,e),e.position--},this),this.stopBatch("add",e)),this},resetCells:function(t,e){t=et(t).map(function(t){return this._prepareCell(t,e)},this);return this.get("cells").reset(t,e),this},removeCells:function(t,e){return t.length&&(this.startBatch("remove"),li(t,"remove",e),this.stopBatch("remove")),this},_removeCell:function(t,e,i){(i=i||{}).clear||(i.disconnectLinks?this.disconnectLinks(t,i):this.removeLinks(t,i)),this.get("cells").remove(t,{silent:!0}),t.graph===this&&(t.graph=null)},getCell:function(t){return this.get("cells").get(t)},getCells:function(){return this.get("cells").toArray()},getElements:function(){return this.get("cells").filter(function(t){return t.isElement()})},getLinks:function(){return this.get("cells").filter(function(t){return t.isLink()})},getFirstCell:function(){return this.get("cells").first()},getLastCell:function(){return this.get("cells").last()},getConnectedLinks:function(t,r){var o,s=(r=r||{}).indirect,a=r.inbound,l=r.outbound,h=(void 0===a&&void 0===l&&(a=l=!0),[]),c={};function u(n,t){k(n.getOutboundEdges(t.id),function(t,e){var i;c[e]||(i=n.getCell(e),h.push(i),c[e]=!0,s&&(a&&d(n,i),l&&u(n,i)))}.bind(n)),s&&t.isLink()&&((t=t.getTargetCell())&&t.isLink()&&(c[t.id]||(h.push(t),u(n,t))))}function d(n,t){k(n.getInboundEdges(t.id),function(t,e){var i;c[e]||(i=n.getCell(e),h.push(i),c[e]=!0,s&&(a&&d(n,i),l&&u(n,i)))}.bind(n)),s&&t.isLink()&&((t=t.getSourceCell())&&t.isLink()&&(c[t.id]||(h.push(t),d(n,t))))}return l&&u(this,t),a&&d(this,t),r.deep&&(t=t.getEmbeddedCells({deep:!0}),o={},t.forEach(function(t){t.isElement()&&(o[t.id]=!0)}),t.forEach(function(t){t.isLink()||(l&&k(this.getOutboundEdges(t.id),function(t,e){var i,n;c[e]||(i=(n=this.getCell(e).attributes).source,n=n.target,i=i.id,n=n.id,!r.includeEnclosed&&i&&o[i]&&n&&o[n]||(h.push(this.getCell(e)),c[e]=!0))}.bind(this)),a&&k(this.getInboundEdges(t.id),function(t,e){var i,n;c[e]||(i=(n=this.getCell(e).attributes).source,n=n.target,i=i.id,n=n.id,!r.includeEnclosed&&i&&o[i]&&n&&o[n]||(h.push(this.getCell(e)),c[e]=!0))}.bind(this)))},this)),h},getNeighbors:function(o,s){var t,a=(s=s||{}).inbound,l=s.outbound,e=(void 0===a&&void 0===l&&(a=l=!0),this.getConnectedLinks(o,s).reduce(function(t,e){var i,n=e.attributes,r=n.source,n=n.target,e=e.hasLoop(s);return a&&xi(r,"id")&&!t[r.id]&&(i=this.getCell(r.id)).isElement()&&(e||!(!i||i===o||s.deep&&i.isEmbeddedIn(o)))&&(t[r.id]=i),l&&xi(n,"id")&&!t[n.id]&&(r=this.getCell(n.id)).isElement()&&(e||!(!r||r===o||s.deep&&r.isEmbeddedIn(o)))&&(t[n.id]=r),t}.bind(this),{}));return o.isLink()&&(a&&(t=o.getSourceCell())&&t.isElement()&&!e[t.id]&&(e[t.id]=t),l&&(t=o.getTargetCell())&&t.isElement()&&!e[t.id]&&(e[t.id]=t)),et(e)},getCommonAncestor:function(){var t=(t=Array.from(arguments).map(function(t){for(var e=[],i=t.get("parent");i;)e.push(i),i=this.getCell(i).get("parent");return e},this)).sort(function(t,e){return t.length-e.length}),e=et(t.shift()).find(function(e){return t.every(function(t){return t.includes(e)})});return this.getCell(e)},getSuccessors:function(e,t){var i=[];return this.search(e,function(t){t!==e&&i.push(t)},R({},t=t||{},{outbound:!0})),i},cloneCells:Ti,cloneSubgraph:function(t,e){t=this.getSubgraph(t,e);return this.cloneCells(t)},getSubgraph:function(t,e){e=e||{};var n=[],r={},i=[],o=[];return et(t).forEach(function(t){r[t.id]||(n.push(t),((r[t.id]=t).isLink()?o:i).push(t)),e.deep&&t.getEmbeddedCells({deep:!0}).forEach(function(t){r[t.id]||(n.push(t),((r[t.id]=t).isLink()?o:i).push(t))})}),o.forEach(function(t){var t=t.attributes,e=t.source,t=t.target;e.id&&!r[e.id]&&(e=this.getCell(e.id),n.push(e),r[e.id]=e,i.push(e)),t.id&&!r[t.id]&&(e=this.getCell(t.id),n.push(this.getCell(t.id)),r[e.id]=e,i.push(e))},this),i.forEach(function(t){this.getConnectedLinks(t,e).forEach(function(t){var e=t.attributes,i=e.source,e=e.target;!r[t.id]&&i.id&&r[i.id]&&e.id&&r[e.id]&&(n.push(t),r[t.id]=t)})},this),n},getPredecessors:function(e,t){var i=[];return this.search(e,function(t){t!==e&&i.push(t)},R({},t=t||{},{inbound:!0})),i},search:function(t,e,i){(i=i||{}).breadthFirst?this.bfs(t,e,i):this.dfs(t,e,i)},bfs:function(t,e,i){void 0===i&&(i={});var n={},r={},o=[];for(o.push(t),r[t.id]=0;0<o.length;){var s=o.shift();if(!n[s.id]&&!(n[s.id]=!0)!==e.call(this,s,r[s.id]))for(var a=this.getNeighbors(s,i),l=0,h=a.length;l<h;l++){var c=a[l];r[c.id]=r[s.id]+1,o.push(c)}}},dfs:function(t,e,i){void 0===i&&(i={});var n={},r={},o=[];for(o.push(t),r[t.id]=0;0<o.length;){var s=o.pop();if(!n[s.id]&&!(n[s.id]=!0)!==e.call(this,s,r[s.id]))for(var a=this.getNeighbors(s,i),l=o.length,h=0,c=a.length;h<c;h++){var u=a[h];r[u.id]=r[s.id]+1,o.splice(l,0,u)}}},getSources:function(){var i=[];return k(this._nodes,function(t,e){this._in[e]&&!gi(this._in[e])||i.push(this.getCell(e))}.bind(this)),i},getSinks:function(){var i=[];return k(this._nodes,function(t,e){this._out[e]&&!gi(this._out[e])||i.push(this.getCell(e))}.bind(this)),i},isSource:function(t){return!this._in[t.id]||gi(this._in[t.id])},isSink:function(t){return!this._out[t.id]||gi(this._out[t.id])},isSuccessor:function(e,i){var n=!1;return this.search(e,function(t){if(t===i&&t!==e)return!(n=!0)},{outbound:!0}),n},isPredecessor:function(e,i){var n=!1;return this.search(e,function(t){if(t===i&&t!==e)return!(n=!0)},{inbound:!0}),n},isNeighbor:function(t,i,e){var n=(e=e||{}).inbound,r=e.outbound,o=(void 0===n&&void 0===r&&(n=r=!0),!1);return this.getConnectedLinks(t,e).forEach(function(t){var t=t.attributes,e=t.source,t=t.target;return n&&xi(e,"id")&&e.id===i.id||r&&xi(t,"id")&&t.id===i.id?!(o=!0):void 0}),o},disconnectLinks:function(e,i){this.getConnectedLinks(e).forEach(function(t){t.set(t.attributes.source.id===e.id?"source":"target",{x:0,y:0},i)})},removeLinks:function(t,e){li(this.getConnectedLinks(t),"remove",e)},findModelsFromPoint:function(e){return this.getElements().filter(function(t){return t.getBBox({rotate:!0}).containsPoint(e)})},findModelsInArea:function(t,e){void 0===e&&(e={});var i=new tt(t),t=e.strict,n=(t=void 0===t?!1:t)?"containsRect":"intersect";return this.getElements().filter(function(t){return i[n](t.getBBox({rotate:!0}))})},findModelsUnderElement:function(e,t){var t=(t=void 0===t?{}:t).searchBy,i=(void 0===t&&(t="bbox"),e.getBBox().rotateAroundCenter(e.angle()));return("bbox"===t?this.findModelsInArea(i):this.findModelsFromPoint(i[t]())).filter(function(t){return e.id!==t.id&&!t.isEmbeddedIn(e)})},getBBox:function(){return this.getCellsBBox(this.getCells())},getCellsBBox:function(t,e){var i=(e=void 0===e?{}:e).rotate;return void 0===i&&(i=!0),et(t).reduce(function(t,e){e=e.getBBox({rotate:i});return e?t?t.union(e):e:t},null)},translate:function(t,e,i){var n=this.getCells().filter(function(t){return!t.isEmbedded()});return li(n,"translate",t,e,i),this},resize:function(t,e,i){return this.resizeCells(t,e,this.getCells(),i)},resizeCells:function(t,e,i,n){var r=this.getCellsBBox(i);return r&&(t=Math.max(t/r.width,0),e=Math.max(e/r.height,0),li(i,"scale",t,e,r.origin(),n)),this},startBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)+1,this.trigger("batch:start",R({},e,{batchName:t}))},stopBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)-1,this.trigger("batch:stop",R({},e,{batchName:t}))},hasActiveBatch:function(t){var e=this._batches,t=0===arguments.length?Object.keys(e):Array.isArray(t)?t:[t];return t.some(function(t){return 0<e[t]})}},{validations:{multiLinks:function(t,e){var i=e.attributes,n=i.source,r=i.target;if(n.id&&r.id){i=e.getSourceCell();if(i)if(1<t.getConnectedLinks(i,{outbound:!0}).filter(function(t){var t=t.attributes,e=t.source,t=t.target;return e&&e.id===n.id&&(!e.port||e.port===n.port)&&t&&t.id===r.id&&(!t.port||t.port===r.port)}).length)return!1}return!0},linkPinning:function(t,e){var e=e.attributes,i=e.source,e=e.target;return i.id&&e.id}}}),oo=(qi(ro.prototype,["resetCells","addCells","removeCells"],on.cells),{CELLS:"cells",BACK:"back",FRONT:"front",TOOLS:"tools",LABELS:"labels"}),so=n.extend({tagName:"g",svgElement:!0,pivotNodes:null,defaultTheme:null,options:{name:""},className:function(){return Ie(this.options.name+"-layer")},init:function(){this.pivotNodes={}},insertSortedNode:function(t,e){this.el.insertBefore(t,this.insertPivot(e))},insertNode:function(t){var e=this.el;t.parentNode!==e&&e.appendChild(t)},insertPivot:function(t){var e=this.el,i=this.pivotNodes;if(r=i[t=(t=+t)||0])return r;var n,r=i[t]=document.createComment("z-index:"+(t+1)),o=-1/0;for(n in i)(n=+n)<t&&o<n&&(o=n);return o!==-1/0?(i=i[o],e.insertBefore(r,i.nextSibling)):e.insertBefore(r,e.firstChild),r},removePivots:function(){var t,e=this.el,i=this.pivotNodes;for(t in i)e.removeChild(i[t]);this.pivotNodes={}}}),p={RENDER:"RENDER",UPDATE:"UPDATE",TOOLS:"TOOLS",LEGACY_TOOLS:"LEGACY_TOOLS",LABELS:"LABELS",VERTICES:"VERTICES",SOURCE:"SOURCE",TARGET:"TARGET",CONNECTOR:"CONNECTOR"},ao=c.extend({className:function(){var t=c.prototype.className.apply(this).split(" ");return t.push("link"),t.join(" ")},options:{shortLinkLength:105,doubleLinkTools:!1,longLinkLength:155,linkToolsOffset:40,doubleLinkToolsOffset:65,sampleInterval:50},_labelCache:null,_labelSelectors:null,_markerCache:null,_V:null,_dragData:null,metrics:null,decimalsRounding:2,initialize:function(){c.prototype.initialize.apply(this,arguments),this._labelCache={},this._labelSelectors={},this._markerCache={},this._V={},this.cleanNodesCache()},presentationAttributes:{markup:[p.RENDER],attrs:[p.UPDATE],router:[p.UPDATE],connector:[p.CONNECTOR],smooth:[p.UPDATE],manhattan:[p.UPDATE],toolMarkup:[p.LEGACY_TOOLS],labels:[p.LABELS],labelMarkup:[p.LABELS],vertices:[p.VERTICES,p.UPDATE],vertexMarkup:[p.VERTICES],source:[p.SOURCE,p.UPDATE],target:[p.TARGET,p.UPDATE]},initFlag:[p.RENDER,p.SOURCE,p.TARGET,p.TOOLS],UPDATE_PRIORITY:1,confirmUpdate:function(t,e){if(e=e||{},this.hasFlag(t,p.SOURCE)){if(!this.updateEndProperties("source"))return t;t=this.removeFlag(t,p.SOURCE)}if(this.hasFlag(t,p.TARGET)){if(!this.updateEndProperties("target"))return t;t=this.removeFlag(t,p.TARGET)}var i=this.paper,n=this.sourceView,r=this.targetView;if(i&&(n&&!i.isViewMounted(n)||r&&!i.isViewMounted(r)))return t;if(this.hasFlag(t,p.RENDER))return this.render(),this.updateHighlighters(!0),this.updateTools(e),t=this.removeFlag(t,[p.RENDER,p.UPDATE,p.VERTICES,p.LABELS,p.TOOLS,p.LEGACY_TOOLS,p.CONNECTOR]);var n=!1,i=(this.hasFlag(t,p.VERTICES)&&(this.renderVertexMarkers(),t=this.removeFlag(t,p.VERTICES)),this.model),r=i.attributes,o=this.hasFlag(t,p.LABELS),s=this.hasFlag(t,p.LEGACY_TOOLS),r=(o&&(this.onLabelsChange(i,r.labels,e),t=this.removeFlag(t,p.LABELS),n=!0),s&&(this.renderTools(),t=this.removeFlag(t,p.LEGACY_TOOLS)),this.hasFlag(t,p.UPDATE)),a=this.hasFlag(t,p.CONNECTOR);return(r||a)&&(r?e.translateBy&&i.isRelationshipEmbeddedIn(e.translateBy)?this.translate(e.tx,e.ty):this.update():(this.updatePath(),this.updateDOM()),this.updateTools(e),t=this.removeFlag(t,[p.UPDATE,p.TOOLS,p.CONNECTOR]),n=!(s=o=!1)),o&&this.updateLabelPositions(),s&&this.updateToolsPosition(),n&&this.updateHighlighters(),this.hasFlag(t,p.TOOLS)&&(this.updateTools(e),t=this.removeFlag(t,p.TOOLS)),t},requestConnectionUpdate:function(t){this.requestUpdate(this.getFlag(p.UPDATE),t)},isLabelsRenderRequired:function(t){void 0===t&&(t={});var e=this.model.previous("labels");if(!e)return!0;if("propertyPathArray"in t&&"propertyValue"in t){var i=t.propertyPathArray||[],n=i.length;if(1<n)if(!!e[i[1]]){if(2===n)return"markup"in Object(t.propertyValue);if("markup"!==i[2])return!1}}return!0},onLabelsChange:function(t,e,i){this.isLabelsRenderRequired(i)?this.renderLabels():this.updateLabels()},render:function(){return this.vel.empty(),this.unmountLabels(),this._V={},this.renderMarkup(),this.renderLabels(),this.update(),this},renderMarkup:function(){var t=this.model,t=t.get("markup")||t.markup;if(!t)throw new Error("dia.LinkView: markup required");if(Array.isArray(t))return this.renderJSONMarkup(t);if("string"==typeof t)return this.renderStringMarkup(t);throw new Error("dia.LinkView: invalid markup")},renderJSONMarkup:function(t){t=this.parseDOMJSON(t,this.el);this.selectors=t.selectors,this.vel.append(t.fragment)},renderStringMarkup:function(t){for(var e=B(t),i=(Array.isArray(e)||(e=[e]),this._V),n=0,r=e.length;n<r;n++){var o=e[n],s=o.attr("class");s&&(s=xe(s),i[w.camelCase(s)]=o)}this.renderTools(),this.renderVertexMarkers(),this.renderArrowheadMarkers(),this.vel.append(e)},_getLabelMarkup:function(t){if(t){if(Array.isArray(t))return this.parseDOMJSON(t,null);if("string"==typeof t)return this._getLabelStringMarkup(t);throw new Error("dia.linkView: invalid label markup")}},_getLabelStringMarkup:function(t){var e=B(t),i=document.createDocumentFragment();if(Array.isArray(e))for(var n=0,r=e.length;n<r;n++){var o=e[n].node;i.appendChild(o)}else i.appendChild(e.node);return{fragment:i,selectors:{}}},_normalizeLabelMarkup:function(t){if(t){var e=t.fragment;if(!(t.fragment instanceof DocumentFragment&&t.fragment.hasChildNodes()))throw new Error("dia.LinkView: invalid label markup.");var i=e.childNodes;return(e=1<i.length||"G"!==i[0].nodeName.toUpperCase()?B("g").append(e):B(i[0])).addClass("label"),{node:e.node,selectors:t.selectors}}},renderLabels:function(){var t=this._V,e=t.labels,i=this._labelCache={},n=this._labelSelectors={},r=this.model,o=r.attributes.labels||[],s=o.length;if(0===s)return e&&e.remove(),this;e?e.empty():(e=t.labels=B("g").addClass("labels"),this.options.labelsLayer&&(e.addClass(Ie(M(this,"className"))),e.attr("model-id",r.id)));for(var a=0;a<s;a++){var l,h=o[a],h=this._normalizeLabelMarkup(this._getLabelMarkup(h.markup)),c=(h=h?(l=h.node,h.selectors):(h=r._builtins.defaultLabel,h=this._normalizeLabelMarkup(this._getLabelMarkup(h.markup)),c=r._getDefaultLabel(),l=(c=this._normalizeLabelMarkup(this._getLabelMarkup(c.markup))||h).node,c.selectors),l.setAttribute("label-idx",a),e.append(l),i[a]=l,this.selector);if(h[c])throw new Error("dia.LinkView: ambiguous label root selector.");h[c]=l,n[a]=h}return e.parent()||this.mountLabels(),this.updateLabels(),this},mountLabels:function(){var t=this.el,e=this.paper,i=this.model,n=this._V,r=this.options,n=n.labels;n&&i.hasLabels()&&(n=n.node,r.labelsLayer?e.getLayerView(r.labelsLayer).insertSortedNode(n,i.get("z")):n.parentNode!==t&&t.appendChild(n))},unmountLabels:function(){var t=this.options,e=this._V;!e||(e=e.labels)&&t.labelsLayer&&e.remove()},onMount:function(){this.mountLabels()},unmount:function(){c.prototype.unmount.apply(this,arguments),this.unmountLabels()},findLabelNode:function(t,e){var i=this._labelCache[t];if(!i)return null;t=this._labelSelectors[t],e=this.findBySelector(e,i,t)[0];return e=void 0===e?null:e},_mergeLabelAttrs:function(t,e,i,n){return null===e?null:void 0===e?null===i?null:void 0===i?t?void 0:n:t?i:y({},n,i):t?y({},i,e):y({},n,i,e)},updateLabels:function(){if(!this._V.labels)return this;for(var t=this.model,e=t.get("labels")||[],i=this.can("labelMove"),n=t._builtins.defaultLabel.attrs,t=t._getDefaultLabel(),r=t.markup,o=t.attrs,s=0,a=e.length;s<a;s++){var l=this._labelCache[s],h=(l.setAttribute("cursor",i?"move":"default"),this._labelSelectors[s]),c=e[s],u=c.markup,d=c.attrs,u=this._mergeLabelAttrs(u||r,d,o,n);this.updateDOMSubtreeAttributes(l,u,{rootBBox:new tt(c.size),selectors:h})}return this},renderTools:function(){if(!this._V.linkTools)return this;var t=w(this._V.linkTools.node).empty(),e=si(this.model.get("toolMarkup")||this.model.toolMarkup),i=B(e());return t.append(i.node),this._toolCache=i,this.options.doubleLinkTools&&(e=this.model.get("doubleToolMarkup")||this.model.doubleToolMarkup?(e=si(this.model.get("doubleToolMarkup")||this.model.doubleToolMarkup),B(e())):i.clone(),t.append(e.node),this._tool2Cache=e),this},renderVertexMarkers:function(){if(!this._V.markerVertices)return this;var i=w(this._V.markerVertices.node).empty(),n=si(this.model.get("vertexMarkup")||this.model.vertexMarkup);return this.model.vertices().forEach(function(t,e){i.append(B(n(R({idx:e},t))).node)}),this},renderArrowheadMarkers:function(){if(!this._V.markerArrowheads)return this;var t=w(this._V.markerArrowheads.node),e=(t.empty(),si(this.model.get("arrowheadMarkup")||this.model.arrowheadMarkup));return this._V.sourceArrowhead=B(e({end:"source"})),this._V.targetArrowhead=B(e({end:"target"})),t.append(this._V.sourceArrowhead.node,this._V.targetArrowhead.node),this},removeRedundantLinearVertices:function(t){var e=this.model,i=e.vertices(),i=[this.sourceAnchor].concat(i,[this.targetAnchor]),n=i.length,i=new v(i),i=(i.simplify({threshold:.001}),i.points.map(function(t){return t.toJSON()})),r=i.length;return n===r?0:(e.vertices(i.slice(1,r-1),t),n-r)},updateDefaultConnectionPath:function(){var t=this._V;t.connection&&t.connection.attr("d",this.getSerializedConnection()),t.connectionWrap&&t.connectionWrap.attr("d",this.getSerializedConnection()),t.markerSource&&t.markerTarget&&this._translateAndAutoOrientArrows(t.markerSource,t.markerTarget)},getEndView:function(t){switch(t){case"source":return this.sourceView||null;case"target":return this.targetView||null;default:throw new Error("dia.LinkView: type parameter required.")}},getEndAnchor:function(t){switch(t){case"source":return new z(this.sourceAnchor);case"target":return new z(this.targetAnchor);default:throw new Error("dia.LinkView: type parameter required.")}},getEndConnectionPoint:function(t){switch(t){case"source":return new z(this.sourcePoint);case"target":return new z(this.targetPoint);default:throw new Error("dia.LinkView: type parameter required.")}},getEndMagnet:function(t){switch(t){case"source":var e=this.sourceView;if(e)return this.sourceMagnet||e.el;break;case"target":e=this.targetView;if(e)return this.targetMagnet||e.el;break;default:throw new Error("dia.LinkView: type parameter required.")}return null},update:function(){return this.updateRoute(),this.updatePath(),this.updateDOM(),this},translate:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0);var i=this.route,n=this.path;i&&n&&((i=new v(i)).translate(t,e),this.route=i.points,this._translateConnectionPoints(t,e),n.translate(t,e),this.updateDOM())},updateDOM:function(){var t=this.el,e=this.model,i=this.selectors;this.cleanNodesCache(),this.updateDOMSubtreeAttributes(t,e.attr(),{selectors:i}),this.updateDefaultConnectionPath(),this.updateLabelPositions(),this.updateToolsPosition(),this.updateArrowheadMarkers(),this.options.perpendicular=null},updateRoute:function(){var t=this.model.vertices(),e=this.findAnchors(t),i=this.sourceAnchor=e.source,e=this.targetAnchor=e.target,t=this.findRoute(t),t=(this.route=t,this.findConnectionPoints(t,i,e));this.sourcePoint=t.source,this.targetPoint=t.target},updatePath:function(){var t=this.route,e=this.sourcePoint,i=this.targetPoint,n=this.findMarkerPoints(t,e,i),t=this.findPath(t,n.source||e,n.target||i);this.path=t},findMarkerPoints:function(t,e,i){var n,r,o=t[0],t=t[t.length-1],s=this._markerCache;return this._V.markerSource&&(s.sourceBBox=s.sourceBBox||this._V.markerSource.getBBox(),n=z(e).move(o||i,s.sourceBBox.width*this._V.markerSource.scale().sx*-1).round()),this._V.markerTarget&&(s.targetBBox=s.targetBBox||this._V.markerTarget.getBBox(),r=z(i).move(t||e,s.targetBBox.width*this._V.markerTarget.scale().sx*-1).round()),s.sourcePoint=n||e.clone(),s.targetPoint=r||i.clone(),{source:n,target:r}},findAnchorsOrdered:function(t,e,i,n){var r=this.model,o=r.get(t),r=r.get(i),s=this.getEndView(t),a=this.getEndView(i),l=this.getEndMagnet(t),h=this.getEndMagnet(i),s=s?(e=e?new z(e):a?h:new z(r),this.getAnchor(o.anchor,s,l,e,t)):new z(o),e=a?(l=new z(n||s),this.getAnchor(r.anchor,a,h,l,i)):new z(r),o={};return o[t]=s,o[i]=e,o},findAnchors:function(t){var e=this.model,i=t[0],t=t[t.length-1];return e.target().priority&&!e.source().priority?this.findAnchorsOrdered("target",t,"source",i):this.findAnchorsOrdered("source",i,"target",t)},findConnectionPoints:function(t,e,i){var n,r=t[0],t=t[t.length-1],o=this.model,s=o.get("source"),o=o.get("target"),a=this.sourceView,l=this.targetView,h=this.paper.options;return{source:a&&!a.isNodeConnection(this.sourceMagnet)?(n=this.sourceMagnet||a.el,s=s.connectionPoint||h.defaultConnectionPoint,r=new C(r||i,e),this.getConnectionPoint(s,a,n,r,"source")):e,target:l&&!l.isNodeConnection(this.targetMagnet)?(s=this.targetMagnet||l.el,a=o.connectionPoint||h.defaultConnectionPoint,n=new C(t||e,i),this.getConnectionPoint(a,l,s,n,"target")):i}},getAnchor:function(t,e,i,n,r){var o=e.isNodeConnection(i),s=this.paper.options;if(!(t=t||(o?s.defaultLinkAnchor:s.perpendicularLinks||this.options.perpendicular?{name:"perpendicular"}:s.defaultAnchor)))throw new Error("Anchor required.");if("function"==typeof t)a=t;else{var a,l=t.name;if("function"!=typeof(a=s[o?"linkAnchorNamespace":"anchorNamespace"][l]))throw new Error("Unknown anchor: "+l)}s=a.call(this,e,i,n,t.args||{},r,this);return s?s.round(this.decimalsRounding):new z},getConnectionPoint:function(t,e,i,n,r){var o=n.end,s=this.paper.options;if("function"==typeof s.linkConnectionPoint){var a=i===e.el?void 0:i;if(a=s.linkConnectionPoint(this,e,a,n.start,r))return a}if(!t)return o;if("function"==typeof t)l=t;else{var l,h=t.name;if("function"!=typeof(l=s.connectionPointNamespace[h]))throw new Error("Unknown connection point: "+h)}return(a=l.call(this,n,e,i,t.args||{},r,this))?a.round(this.decimalsRounding):o},_translateConnectionPoints:function(t,e){var i=this._markerCache;i.sourcePoint.offset(t,e),i.targetPoint.offset(t,e),this.sourcePoint.offset(t,e),this.targetPoint.offset(t,e),this.sourceAnchor.offset(t,e),this.targetAnchor.offset(t,e)},_normalizeLabelPosition:function(t){return"number"==typeof t?{distance:t,offset:null,angle:0,args:null}:t},updateLabelPositions:function(){if(!this._V.labels)return this;if(!this.path)return this;var t=this.model,e=t.get("labels")||[];if(!e.length)return this;for(var i=t._builtins.defaultLabel.position,t=t._getDefaultLabel(),t=this._normalizeLabelPosition(t.position),n=y({},i,t),r=0,o=e.length;r<o;r++){var s,a=this._labelCache[r];a&&(s=e[r],s=this._normalizeLabelPosition(s.position),s=y({},n,s),s=this._getLabelTransformationMatrix(s),a.setAttribute("transform",B.matrixToTransformString(s)),this._cleanLabelMatrices(r))}return this},_cleanLabelMatrices:function(t){var e=this.metrics,i=this._labelSelectors[t];if(i)for(var n in i){n=i[n].id;n&&n in e&&delete e[n].magnetMatrix}},updateToolsPosition:function(){if(!this._V.linkTools)return this;var t,e="",i=this.options.linkToolsOffset,n=this.getConnectionLength();return Number.isNaN(n)||(n<this.options.shortLinkLength&&(e="scale(.5)",i/=2),t=this.getPointAtLength(i),this._toolCache.attr("transform","translate("+t.x+", "+t.y+") "+e),this.options.doubleLinkTools&&n>=this.options.longLinkLength?(i=this.options.doubleLinkToolsOffset||i,t=this.getPointAtLength(n-i),this._tool2Cache.attr("transform","translate("+t.x+", "+t.y+") "+e),this._tool2Cache.attr("visibility","visible")):this.options.doubleLinkTools&&this._tool2Cache.attr("visibility","hidden")),this},updateArrowheadMarkers:function(){if(!this._V.markerArrowheads)return this;if("none"===w.css(this._V.markerArrowheads.node,"display"))return this;var t=this.getConnectionLength()<this.options.shortLinkLength?.5:1;return this._V.sourceArrowhead.scale(t),this._V.targetArrowhead.scale(t),this._translateAndAutoOrientArrows(this._V.sourceArrowhead,this._V.targetArrowhead),this},updateEndProperties:function(t){var e=this.model,i=this.paper,n=t+"View",e=e.get(t),e=e&&e.id;if(!e)return this[n]=null,this.updateEndMagnet(t),!0;e=i.getModelById(e);if(!e)throw new Error("LinkView: invalid "+t+" cell.");e=e.findView(i);return!!e&&(this[n]=e,this.updateEndMagnet(t),!0)},updateEndMagnet:function(t){var e=t+"Magnet",i=this.getEndView(t);i?((t=i.getMagnetFromLinkEnd(this.model.get(t)))===i.el&&(t=null),this[e]=t):this[e]=null},_translateAndAutoOrientArrows:function(t,e){var i=et(this.route);t&&t.translateAndAutoOrient(this.sourcePoint,i[0]||this.targetPoint,this.paper.cells),e&&e.translateAndAutoOrient(this.targetPoint,i[i.length-1]||this.sourcePoint,this.paper.cells)},_getLabelPositionAngle:function(t){return(this.model.label(t).position||{}).angle||0},_getLabelPositionArgs:function(t){return(this.model.label(t).position||{}).args},_getDefaultLabelPositionArgs:function(){return(this.model._getDefaultLabel().position||{}).args},_mergeLabelPositionArgs:function(t,e){return null===t?null:void 0===t?null===e?null:e:y({},e,t)},addLabel:function(t,e,i,n){var r,o,s=0,t="number"!=typeof t?(r=t.x,o=t.y,"number"==typeof e?(s=e,i):e):(r=t,o=e,"number"==typeof i?(s=i,n):i),e=this._getDefaultLabelPositionArgs(),n=t,i=this._mergeLabelPositionArgs(n,e),n={position:this.getLabelPosition(r,o,s,i)};return this.model.insertLabel(-1,n,t),-1},addVertex:function(t,e,i){var n="number"!=typeof t,r=n?t.x:t,t=n?t.y:e,n=n?e:i,e={x:r,y:t},i=this.getVertexIndex(r,t);return this.model.insertVertex(i,e,n),i},sendToken:function(t,e,i){var n,r,e=x(e)?(o=e.duration,a="reverse"===e.direction,e.connection):(o=e,a=!1,null),o=o||1e3,s={dur:o+"ms",repeatCount:1,calcMode:"linear",fill:"freeze"},a=(a&&(s.keyPoints="1;0",s.keyTimes="0;1"),B(t));if(!((e="string"==typeof e?this.findBySelector(e,this.el,this.selectors)[0]:(t=this._V).connection?t.connection.node:this.el.querySelector("path"))instanceof SVGPathElement))throw new Error("dia.LinkView: token animation requires a valid connection path.");a.appendTo(this.paper.cells).animateAlongPath(s,e),setTimeout((n=a,r=i,function(){n.remove(),"function"==typeof r&&r()}),o)},findRoute:function(t){t=t||[];var e=this.paper.options.routerNamespace||Kr,i=this.model.router(),n=this.paper.options.defaultRouter;if(!i){if(!n)return t.map(z);i=n}n=P(i)?i:e[i.name];if(!P(n))throw new Error('dia.LinkView: unknown router: "'+i.name+'".');e=i.args||{},i=n.call(this,t,e,this);return i||t.map(z)},findPath:function(t,e,i){var n=this.paper.options.connectorNamespace||hr,r=this.model.connector(),o=this.paper.options.defaultConnector,o=P(r=r||(o||{}))?r:n[r.name];if(!P(o))throw new Error('dia.LinkView: unknown connector: "'+r.name+'".');n=ui(r.args||{}),n.raw=!0,r=o.call(this,e,i,t,n,this);return r="string"==typeof r?new O(B.normalizePathData(r)):r},getConnection:function(){var t=this.path;return t?t.clone():null},getSerializedConnection:function(){var t=this.path;if(!t)return null;var e=this.metrics;if(e.hasOwnProperty("data"))return e.data;t=t.serialize();return e.data=t},getConnectionSubdivisions:function(){var t=this.path;if(!t)return null;var e=this.metrics;if(e.hasOwnProperty("segmentSubdivisions"))return e.segmentSubdivisions;t=t.getSegmentSubdivisions();return e.segmentSubdivisions=t},getConnectionLength:function(){var t=this.path;if(!t)return 0;var e=this.metrics;if(e.hasOwnProperty("length"))return e.length;t=t.length({segmentSubdivisions:this.getConnectionSubdivisions()});return e.length=t},getPointAtLength:function(t){var e=this.path;return e?e.pointAtLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getPointAtRatio:function(t){var e=this.path;return e?(ti(t)&&(t=parseFloat(t)/100),e.pointAt(t,{segmentSubdivisions:this.getConnectionSubdivisions()})):null},getTangentAtLength:function(t){var e=this.path;return e?e.tangentAtLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getTangentAtRatio:function(t){var e=this.path;return e?e.tangentAt(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getClosestPoint:function(t){var e=this.path;return e?e.closestPoint(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getClosestPointLength:function(t){var e=this.path;return e?e.closestPointLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getClosestPointRatio:function(t){var e=this.path;return e?e.closestPointNormalizedLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getLabelPosition:function(t,e,i,n){var r,o={},s=0,n="number"==typeof i?(s=i,n):i,i=(n&&(o.args=n),!(n&&n.absoluteDistance)),a=n&&n.absoluteDistance&&n.reverseDistance,n=n&&n.absoluteOffset,l=this.path,h={segmentSubdivisions:this.getConnectionSubdivisions()},t=new z(t,e),e=l.closestPointT(t,h),h=l.lengthAtT(e,h);return i&&(h=h/this.getConnectionLength()||0),a&&(h=-1*(this.getConnectionLength()-h)||1),o.distance=h,h=(r=n?r:l.tangentAtT(e))?r.pointOffset(t):(i=l.pointAtT(e),{x:(a=t.difference(i)).x,y:a.y}),o.offset=h,o.angle=s,o},_getLabelTransformationMatrix:function(t){var e=0,i={};if("number"==typeof t)c=t;else{if("number"!=typeof t.distance)throw new Error("dia.LinkView: invalid label position distance.");i=t.args||{},c=t.distance,e=t.angle||0}var n,r=0<c&&c<=1,o=0,s={x:0,y:0},t=(t.offset&&("number"==typeof(t=t.offset)&&(o=t),t.x&&(s.x=t.x),t.y&&(s.y=t.y)),0!==s.x||0!==s.y||0===o),a=i.keepGradient,i=i.ensureLegibility,l=this.path,h={segmentSubdivisions:this.getConnectionSubdivisions()},r=r?c*this.getConnectionLength():c,c=l.tangentAtLength(r,h),r=e;return c?(t?(n=c.start).offset(s):((h=c.clone()).rotate(c.start,-90),h.setLength(o),n=h.end),a&&(r=c.angle()+e,i&&(r=Q((r+90)%180-90)))):(n=l.start,t&&n.offset(s)),B.createSVGMatrix().translate(n.x,n.y).rotate(r)},getLabelCoordinates:function(t){t=this._getLabelTransformationMatrix(t);return new z(t.e,t.f)},getVertexIndex:function(t,e){for(var i=this.model.vertices(),n=this.getClosestPointLength(new z(t,e)),r=0,o=i.length;r<o;r++){var s=i[r];if(n<this.getClosestPointLength(s))break}return r},notifyPointerdown:function(t,e,i){c.prototype.pointerdown.call(this,t,e,i),this.notify("link:pointerdown",t,e,i)},notifyPointermove:function(t,e,i){c.prototype.pointermove.call(this,t,e,i),this.notify("link:pointermove",t,e,i)},notifyPointerup:function(t,e,i){this.notify("link:pointerup",t,e,i),c.prototype.pointerup.call(this,t,e,i)},pointerdblclick:function(t,e,i){c.prototype.pointerdblclick.apply(this,arguments),this.notify("link:pointerdblclick",t,e,i)},pointerclick:function(t,e,i){c.prototype.pointerclick.apply(this,arguments),this.notify("link:pointerclick",t,e,i)},contextmenu:function(t,e,i){c.prototype.contextmenu.apply(this,arguments),this.notify("link:contextmenu",t,e,i)},pointerdown:function(t,e,i){switch(this.notifyPointerdown(t,e,i),t.target.getAttribute("class")){case"marker-vertex":return void this.dragVertexStart(t,e,i);case"marker-vertex-remove":case"marker-vertex-remove-area":return void this.dragVertexRemoveStart(t,e,i);case"marker-arrowhead":return void this.dragArrowheadStart(t,e,i);case"connection":case"connection-wrap":return void this.dragConnectionStart(t,e,i);case"marker-source":case"marker-target":return}this.dragStart(t,e,i)},pointermove:function(t,e,i){var n=this._dragData;switch(n&&this.eventData(t,n),this.eventData(t).action){case"vertex-move":this.dragVertex(t,e,i);break;case"label-move":this.dragLabel(t,e,i);break;case"arrowhead-move":this.dragArrowhead(t,e,i);break;case"move":this.drag(t,e,i)}n&&R(n,this.eventData(t)),this.notifyPointermove(t,e,i)},pointerup:function(t,e,i){var n=this._dragData;switch(n&&(this.eventData(t,n),this._dragData=null),this.eventData(t).action){case"vertex-move":this.dragVertexEnd(t,e,i);break;case"label-move":this.dragLabelEnd(t,e,i);break;case"arrowhead-move":this.dragArrowheadEnd(t,e,i);break;case"move":this.dragEnd(t,e,i)}this.notifyPointerup(t,e,i),this.checkMouseleave(t)},mouseover:function(t){c.prototype.mouseover.apply(this,arguments),this.notify("link:mouseover",t)},mouseout:function(t){c.prototype.mouseout.apply(this,arguments),this.notify("link:mouseout",t)},mouseenter:function(t){c.prototype.mouseenter.apply(this,arguments),this.notify("link:mouseenter",t)},mouseleave:function(t){c.prototype.mouseleave.apply(this,arguments),this.notify("link:mouseleave",t)},mousewheel:function(t,e,i,n){c.prototype.mousewheel.apply(this,arguments),this.notify("link:mousewheel",t,e,i,n)},onevent:function(t,e,i,n){if(B(t.target).findParentByClass("link-tool",this.el)){if(t.stopPropagation(),this.can("useLinkTools")){if("remove"===e)return void this.model.remove({ui:!0});this.notify(e,t,i,n)}this.notifyPointerdown(t,i,n),this.paper.delegateDragEvents(this,t.data)}else c.prototype.onevent.apply(this,arguments)},onlabel:function(t,e,i){this.notifyPointerdown(t,e,i),this.dragLabelStart(t,e,i),this.eventData(t).stopPropagation&&t.stopPropagation()},dragConnectionStart:function(t,e,i){this.can("vertexAdd")&&(e=this.addVertex({x:e,y:i},{ui:!0}),this.eventData(t,{action:"vertex-move",vertexIdx:e}))},dragLabelStart:function(t,e,i){var n,r,o,s;this.can("labelMove")?(n=t.currentTarget,n=parseInt(n.getAttribute("label-idx"),10),r=this._getLabelPositionAngle(n),s=this._getLabelPositionArgs(n),o=this._getDefaultLabelPositionArgs(),s=this._mergeLabelPositionArgs(s,o),this.eventData(t,{action:"label-move",labelIdx:n,positionAngle:r,positionArgs:s,stopPropagation:!0})):this.eventData(t,{stopPropagation:!0}),this.paper.delegateDragEvents(this,t.data)},dragVertexStart:function(t,e,i){var n;this.can("vertexMove")&&(n=t.target,n=parseInt(n.getAttribute("idx"),10),this.eventData(t,{action:"vertex-move",vertexIdx:n}))},dragVertexRemoveStart:function(t,e,i){this.can("vertexRemove")&&(t=t.target,t=parseInt(t.getAttribute("idx"),10),this.model.removeVertex(t))},dragArrowheadStart:function(t,e,i){var n;this.can("arrowheadMove")&&(n=t.target.getAttribute("end"),n=this.startArrowheadMove(n,{ignoreBackwardsCompatibility:!0}),this.eventData(t,n))},dragStart:function(t,e,i){this.can("linkMove")&&this.eventData(t,{action:"move",dx:e,dy:i})},dragLabel:function(t,e,i){t=this.eventData(t),e={position:this.getLabelPosition(e,i,t.positionAngle,t.positionArgs)};this.paper.options.snapLabels&&delete e.position.offset,this.model.label(t.labelIdx,e)},dragVertex:function(t,e,i){t=this.eventData(t);this.model.vertex(t.vertexIdx,{x:e,y:i},{ui:!0})},dragArrowhead:function(t,e,i){this.paper.options.snapLinks?this._snapArrowhead(t,e,i):this._connectArrowhead(this.getEventTarget(t),e,i,this.eventData(t))},drag:function(t,e,i){var n=this.eventData(t);this.model.translate(e-n.dx,i-n.dy,{ui:!0}),this.eventData(t,{dx:e,dy:i})},dragLabelEnd:function(){},dragVertexEnd:function(){},dragArrowheadEnd:function(t,e,i){var n=this.eventData(t),r=this.paper;r.options.snapLinks?this._snapArrowheadEnd(n):this._connectArrowheadEnd(n,e,i),r.linkAllowed(this)?(this._finishEmbedding(n),this._notifyConnectEvent(n,t)):this._disallow(n),this._afterArrowheadMove(n)},dragEnd:function(){},_disallow:function(t){"remove"===t.whenNotAllowed?this.model.remove({ui:!0}):this.model.set(t.arrowhead,t.initialEnd,{ui:!0})},_finishEmbedding:function(t){this.paper.options.embeddingMode&&this.model.reparent()&&(t.z=null)},_notifyConnectEvent:function(t,e){var i,n=t.arrowhead,r=t.initialEnd,o=this.model.prop(n);o&&!u.endsEqual(r,o)&&(i=this.paper,r.id&&this.notify("link:disconnect",e,i.findViewByModel(r.id),t.initialMagnet,n),o.id&&this.notify("link:connect",e,i.findViewByModel(o.id),t.magnetUnderPointer,n))},_snapArrowhead:function(t,e,i){var n=this.paper,r=n.options,o=r.snapLinks,r=r.connectionStrategy,s=this.eventData(t),o=o.radius||50,o=n.findViewsInArea({x:e-o,y:i-o,width:2*o,height:2*o}),a=s.closestView||null,l=s.closestMagnet||null,h=s.magnetProxy||null,c=(s.closestView=s.closestMagnet=s.magnetProxy=null,Number.MAX_VALUE),u=new z(e,i),o=(o.forEach(function(i){var e=[];"false"!==i.el.getAttribute("magnet")&&e.push({bbox:i.model.getBBox(),magnet:i.el}),i.$("[magnet]").toArray().forEach(function(t){e.push({bbox:i.getNodeBBox(t),magnet:t})}),e.forEach(function(t){var e=t.magnet,t=t.bbox.center().squaredDistance(u);t<c&&(l===e||n.options.validateConnection.apply(n,s.validateConnectionArgs(i,i.el===e?null:e)))&&(c=t,s.closestView=i,s.closestMagnet=e)})},this),null),d=s.closestView,g=s.closestMagnet,p=(g&&(o=s.magnetProxy=d.findProxyNode(g,"highlighter")),s.arrowhead),f=l!==g;if(a&&f&&a.unhighlight(h,{connecting:!0,snapping:!0}),d){var h=s.prevEnd,m=s.prevX,v=s.prevY;if(s.prevX=e,s.prevY=i,!f&&("function"!=typeof r||m===e&&v===i))return;if(m=d.getLinkEnd(g,e,i,this.model,p),!f&&pi(h,m))return;s.prevEnd=m,f&&d.highlight(o,{connecting:!0,snapping:!0})}else m={x:e,y:i};this.model.set(p,m||{x:e,y:i},{ui:!0}),a&&this.notify("link:snap:disconnect",t,a,l,p),d&&this.notify("link:snap:connect",t,d,g,p)},_snapArrowheadEnd:function(t){var e=t.closestView,i=t.closestMagnet;e&&i&&(e.unhighlight(t.magnetProxy,{connecting:!0,snapping:!0}),t.magnetUnderPointer=e.findMagnet(i)),t.closestView=t.closestMagnet=null},_connectArrowhead:function(t,e,i,n){var r,o,s,a=this.paper,l=this.model;n.eventTarget!==t&&(n.magnetProxy&&n.viewUnderPointer.unhighlight(n.magnetProxy,{connecting:!0}),(r=n.viewUnderPointer=a.findView(t))?(o=n.magnetUnderPointer=r.findMagnet(t),s=n.magnetProxy=r.findProxyNode(o,"highlighter"),o&&this.paper.options.validateConnection.apply(a,n.validateConnectionArgs(r,o))?s&&r.highlight(s,{connecting:!0}):(n.magnetUnderPointer=null,n.magnetProxy=null)):(n.magnetUnderPointer=null,n.magnetProxy=null)),n.eventTarget=t,l.set(n.arrowhead,{x:e,y:i},{ui:!0})},_connectArrowheadEnd:function(t,e,i){var n=this.model,r=(t=void 0===t?{}:t).viewUnderPointer,o=t.magnetUnderPointer,s=t.magnetProxy,t=t.arrowhead;o&&s&&r&&(r.unhighlight(s,{connecting:!0}),s=r.getLinkEnd(o,e,i,n,t),n.set(t,s,{ui:!0}))},_beforeArrowheadMove:function(t){t.z=this.model.get("z"),this.model.toFront();var e=this.el.style;t.pointerEvents=e.pointerEvents,e.pointerEvents="none",this.paper.options.markAvailable&&this._markAvailableMagnets(t)},_afterArrowheadMove:function(t){null!==t.z&&(this.model.set("z",t.z,{ui:!0}),t.z=null),this.el.style.pointerEvents=t.pointerEvents,this.paper.options.markAvailable&&this._unmarkAvailableMagnets(t)},_createValidateConnectionArgs:function(t){var e,i=[],n=(i[4]=t,i[5]=this,0),r=0,t="source"===t?(n=2,"target"):(r=2,"source"),t=this.model.get(t);return t.id&&((t=(e=i[n]=this.paper.findViewByModel(t.id)).getMagnetFromLinkEnd(t))===e.el&&(t=void 0),i[n+1]=t),function(t,e){return i[r]=t,i[r+1]=t.el===e?void 0:e,i}},_markAvailableMagnets:function(t){function e(t,e){var i=t.paper;return i.options.validateConnection.apply(i,this.validateConnectionArgs(t,e))}var i=this.paper,n=i.model.getCells();t.marked={};for(var r=0,o=n.length;r<o;r++){var s=n[r].findView(i);if(s){var a=Array.prototype.slice.call(s.el.querySelectorAll("[magnet]")),l=("false"!==s.el.getAttribute("magnet")&&a.push(s.el),a.filter(e.bind(t,s)));if(0<l.length){for(var h=0,c=l.length;h<c;h++)s.highlight(l[h],{magnetAvailability:!0});s.highlight(null,{elementAvailability:!0}),t.marked[s.model.id]=l}}}},_unmarkAvailableMagnets:function(t){for(var e=Object.keys(t.marked),i=0,n=e.length;i<n;i++){var r=e[i],o=t.marked[r],s=this.paper.findViewByModel(r);if(s){for(var a=0,l=o.length;a<l;a++)s.unhighlight(o[a],{magnetAvailability:!0});s.unhighlight(null,{elementAvailability:!0})}}t.marked=null},startArrowheadMove:function(t,e){t={action:"arrowhead-move",arrowhead:t,whenNotAllowed:(e=e||{}).whenNotAllowed||"revert",initialMagnet:this[t+"Magnet"]||(this[t+"View"]?this[t+"View"].el:null),initialEnd:ui(this.model.get(t)),validateConnectionArgs:this._createValidateConnectionArgs(t)};return this._beforeArrowheadMove(t),!0!==e.ignoreBackwardsCompatibility&&(this._dragData=t),t},onRemove:function(){c.prototype.onRemove.apply(this,arguments),this.unmountLabels()}},{Flags:p}),lo=(Object.defineProperty(ao.prototype,"sourceBBox",{enumerable:!0,get:function(){var t=this.sourceView;if(!t)return e=this.model.source(),new tt(e.x,e.y);var e=this.sourceMagnet;return t.isNodeConnection(e)?new tt(this.sourceAnchor):t.getNodeBBox(e||t.el)}}),Object.defineProperty(ao.prototype,"targetBBox",{enumerable:!0,get:function(){var t=this.targetView;if(!t)return e=this.model.target(),new tt(e.x,e.y);var e=this.targetMagnet;return t.isNodeConnection(e)?new tt(this.targetAnchor):t.getNodeBBox(e||t.el)}}),{NONE:"sorting-none",APPROX:"sorting-approximate",EXACT:"sorting-exact"}),ho=9007199254740991,zn=c.Highlighting,co={},uo=(co[zn.DEFAULT]={name:"stroke",options:{padding:3}},co[zn.MAGNET_AVAILABILITY]={name:"addClass",options:{className:"available-magnet"}},co[zn.ELEMENT_AVAILABILITY]={name:"addClass",options:{className:"available-cell"}},[{name:oo.BACK},{name:oo.CELLS},{name:oo.LABELS},{name:oo.FRONT},{name:oo.TOOLS}]),go=n.extend({className:"paper",options:{width:800,height:600,origin:{x:0,y:0},gridSize:1,drawGrid:!1,background:!1,perpendicularLinks:!1,elementView:g,linkView:ao,snapLabels:!1,snapLinks:!1,labelsLayer:!1,multiLinks:!0,guard:function(t,e){return!1},highlighting:co,preventContextMenu:!0,preventDefaultBlankAction:!0,restrictTranslate:!1,markAvailable:!1,defaultLink:new u,defaultConnector:{name:"normal"},defaultRouter:{name:"normal"},defaultAnchor:{name:"center"},defaultLinkAnchor:{name:"connectionRatio"},defaultConnectionPoint:{name:"bbox"},connectionStrategy:null,validateMagnet:function(t,e,i){return"passive"!==e.getAttribute("magnet")},validateConnection:function(t,e,i,n,r,o){return("target"===r?i:t)instanceof g},embeddingMode:!1,validateEmbedding:function(t,e){return!0},validateUnembedding:function(t){return!0},findParentBy:"bbox",frontParentOnly:!0,interactive:{labelMove:!1},linkPinning:!0,allowLink:null,clickThreshold:0,moveThreshold:0,magnetThreshold:0,sorting:lo.EXACT,frozen:!1,onViewUpdate:function(t,e,i,n,r){e&(t.FLAG_INSERT|t.FLAG_REMOVE)||n.mounting||n.isolate||r.requestConnectedLinksUpdate(t,i,n)},onViewPostponed:function(t,e,i){return i.forcePostponedViewUpdate(t,e)},beforeRender:null,afterRender:null,viewport:null,cellViewNamespace:null,routerNamespace:null,connectorNamespace:null,highlighterNamespace:On,anchorNamespace:Bn,linkAnchorNamespace:Pn,connectionPointNamespace:Rn},events:{dblclick:"pointerdblclick",contextmenu:"contextmenu",mousedown:"pointerdown",touchstart:"pointerdown",mouseover:"mouseover",mouseout:"mouseout",mouseenter:"mouseenter",mouseleave:"mouseleave",wheel:"mousewheel","mouseenter .joint-cell":"mouseenter","mouseleave .joint-cell":"mouseleave","mouseenter .joint-tools":"mouseenter","mouseleave .joint-tools":"mouseleave","mousedown .joint-cell [event]":"onevent","touchstart .joint-cell [event]":"onevent","mousedown .joint-cell [magnet]":"onmagnet","touchstart .joint-cell [magnet]":"onmagnet","dblclick .joint-cell [magnet]":"magnetpointerdblclick","contextmenu .joint-cell [magnet]":"magnetcontextmenu","mousedown .joint-link .label":"onlabel","touchstart .joint-link .label":"onlabel","dragstart .joint-cell image":"onImageDragStart"},documentEvents:{mousemove:"pointermove",touchmove:"pointermove",mouseup:"pointerup",touchend:"pointerup",touchcancel:"pointerup"},svg:null,viewport:null,defs:null,tools:null,$background:null,layers:null,$grid:null,$document:null,_viewportMatrix:null,_viewportTransformString:null,_updates:null,_layers:null,SORT_DELAYING_BATCHES:["add","to-front","to-back"],UPDATE_DELAYING_BATCHES:["translate"],MIN_SCALE:1e-6,init:function(){var t=this.options,e=this.el,i=(t.cellViewNamespace||(t.cellViewNamespace="undefined"!=typeof joint&&xi(joint,"shapes")?joint.shapes:null),this.model=t.model||new ro);this._layers={},this.setGrid(t.drawGrid),this.cloneOptions(),this.render(),this._setDimensions(),this.startListening(),this._views={},this.$document=w(e.ownerDocument),this.resetViews(i.attributes.cells.models),!this.isFrozen()&&this.isAsync()&&this.updateViewsAsync()},_resetUpdates:function(){return this._updates={id:null,priorities:[{},{},{}],unmountedCids:[],mountedCids:[],unmounted:{},mounted:{},count:0,keyFrozen:!1,freezeKey:null,sort:!1}},startListening:function(){var t=this.model;this.listenTo(t,"add",this.onCellAdded).listenTo(t,"remove",this.onCellRemoved).listenTo(t,"change",this.onCellChange).listenTo(t,"reset",this.onGraphReset).listenTo(t,"sort",this.onGraphSort).listenTo(t,"batch:stop",this.onGraphBatchStop),this.on("cell:highlight",this.onCellHighlight).on("cell:unhighlight",this.onCellUnhighlight).on("scale translate",this.update)},onCellAdded:function(t,e,i){var n=i.position;this.isAsync()||!G(n)?this.renderView(t,i):(i.maxPosition===n&&this.freeze({key:"addCells"}),this.renderView(t,i),0===n&&this.unfreeze({key:"addCells"}))},onCellRemoved:function(t,e,i){t=this.findViewByModel(t);t&&this.requestViewUpdate(t,t.FLAG_REMOVE,t.UPDATE_PRIORITY,i)},onCellChange:function(t,e){t!==this.model.attributes.cells&&t.hasChanged("z")&&this.options.sorting===lo.APPROX&&(t=this.findViewByModel(t))&&this.requestViewUpdate(t,t.FLAG_INSERT,t.UPDATE_PRIORITY,e)},onGraphReset:function(t,e){this.resetLayers(),this.resetViews(t.models,e)},onGraphSort:function(){this.model.hasActiveBatch(this.SORT_DELAYING_BATCHES)||this.sortViews()},onGraphBatchStop:function(t){var e,i,n;this.isFrozen()||(e=t&&t.batchName,i=this.model,this.isAsync()||(n=this.UPDATE_DELAYING_BATCHES).includes(e)&&!i.hasActiveBatch(n)&&this.updateViews(t),(n=this.SORT_DELAYING_BATCHES).includes(e)&&!i.hasActiveBatch(n)&&this.sortViews())},cloneOptions:function(){var t=this.options,e=t.defaultConnector,i=t.defaultRouter,n=t.defaultConnectionPoint,r=t.defaultAnchor,o=t.defaultLinkAnchor,s=t.origin,a=t.highlighting,l=t.cellViewNamespace,h=t.interactive;!l&&"undefined"!=typeof joint&&xi(joint,"shapes")&&(t.cellViewNamespace=joint.shapes),P(e)||(t.defaultConnector=di(e)),P(i)||(t.defaultRouter=di(i)),P(n)||(t.defaultConnectionPoint=di(n)),P(r)||(t.defaultAnchor=di(r)),P(o)||(t.defaultLinkAnchor=di(o)),fi(h)&&(t.interactive=R({},h)),fi(a)&&(t.highlighting=ai({},a,co)),t.origin=R({},s)},children:function(){var t=B.namespace;return[{namespaceURI:t.xhtml,tagName:"div",className:Ie("paper-background"),selector:"background"},{namespaceURI:t.xhtml,tagName:"div",className:Ie("paper-grid"),selector:"grid"},{namespaceURI:t.svg,tagName:"svg",attributes:{width:"100%",height:"100%","xmlns:xlink":t.xlink},selector:"svg",children:[{tagName:"defs",selector:"defs"},{tagName:"g",className:Ie("layers"),selector:"layers"}]}]},hasLayerView:function(t){return t in this._layers},getLayerView:function(t){var e=this._layers;if(t in e)return e[t];throw new Error('dia.Paper: Unknown layer "'+t+'"')},getLayerNode:function(t){return this.getLayerView(t).el},render:function(){this.renderChildren();var t=this.childNodes,e=this.options,i=t.svg,n=t.defs,r=t.layers,o=t.background,t=t.grid;return this.svg=i,this.defs=n,this.layers=r,this.$background=w(o),this.$grid=w(t),this.renderLayers(),B.ensureId(i),e.background&&this.drawBackground(e.background),e.drawGrid&&this.drawGrid(),this},renderLayers:function(t){var i=this,t=(void 0===t&&(t=uo),this.removeLayers(),t.forEach(function(t){var e=t.name,t=(t.sorted,new so({name:e}));i.layers.appendChild(t.el),i._layers[e]=t}),this.getLayerView(oo.CELLS)),e=this.getLayerView(oo.TOOLS),n=this.getLayerView(oo.LABELS);this.tools=e.el,this.cells=this.viewport=t.el,t.vel.addClass(Ie("viewport")),n.vel.addClass(Ie("viewport"))},removeLayers:function(){this._layers},resetLayers:function(){this._layers},update:function(){return this.options.drawGrid&&this.drawGrid(),this._background&&this.updateBackgroundImage(this._background),this},matrix:function(t){var e=this.layers;if(void 0===t)return i=e.getAttribute("transform"),(this._viewportTransformString||null)===i?t=this._viewportMatrix:(t=e.getCTM(),this._viewportMatrix=t,this._viewportTransformString=i),B.createSVGMatrix(t);t=B.createSVGMatrix(t);var i=B.matrixToTransformString(t);return e.setAttribute("transform",i),this._viewportMatrix=t,this._viewportTransformString=e.getAttribute("transform"),this},clientMatrix:function(){return B.createSVGMatrix(this.cells.getScreenCTM())},requestConnectedLinksUpdate:function(t,e,i){if(t instanceof c)for(var n=t.model,r=this.model.getConnectedLinks(n),o=0,s=r.length;o<s;o++){var a,l=r[o],h=this.findViewByModel(l);h&&(a=["UPDATE"],l.getTargetCell()===n&&a.push("TARGET"),l.getSourceCell()===n&&a.push("SOURCE"),l=Math.max(e+1,h.UPDATE_PRIORITY),this.scheduleViewUpdate(h,h.getFlag(a),l,i))}},forcePostponedViewUpdate:function(t,e){if(!(t&&t instanceof c))return!1;var i=t.model;if(i.isElement())return!1;if(0==(e&t.getFlag(["SOURCE","TARGET"]))){var e=0,n=this.findViewByModel(i.getSourceCell()),n=(n&&!this.isViewMounted(n)&&(e=this.dumpView(n),t.updateEndMagnet("source")),0),i=this.findViewByModel(i.getTargetCell());if(i&&!this.isViewMounted(i)&&(n=this.dumpView(i),t.updateEndMagnet("target")),0===e&&0===n)return!this.dumpView(t)}return!1},requestViewUpdate:function(t,e,i,n){this.scheduleViewUpdate(t,e,i,n=n||{});t=this.isAsync();this.isFrozen()||t&&!1!==n.async||this.model.hasActiveBatch(this.UPDATE_DELAYING_BATCHES)||(e=this.updateViews(n),t&&this.notifyAfterRender(e,n))},scheduleViewUpdate:function(t,e,i,n){var r=this._updates,o=this.options,s=t.FLAG_REMOVE,a=t.FLAG_INSERT,l=t.UPDATE_PRIORITY,h=t.cid,c=(c=r.priorities[i])||(r.priorities[i]={});if(l<i)for(var u=i-1;l<=u;u--){var d=r.priorities[u];d&&h in d&&(c[h]|=d[h],delete d[h])}var g=c[h]||0;(g&e)!==e&&(g||r.count++,e&s&&g&a?c[h]^=a:e&a&&g&s&&(c[h]^=s),c[h]|=e,"function"==typeof(a=o.onViewUpdate)&&a.call(this,t,e,i,n||{},this))},dumpViewUpdate:function(t){if(!t)return 0;var e=this._updates,i=t.cid,e=e.priorities[t.UPDATE_PRIORITY],t=this.registerMountedView(t)|e[i];return delete e[i],t},dumpView:function(t,e){var i=this.dumpViewUpdate(t);return i?this.updateView(t,i,e):0},updateView:function(t,e,i){if(!t)return 0;var n=t.FLAG_REMOVE,r=t.FLAG_INSERT,o=t.model;if(t instanceof c){if(e&n)return this.removeView(o),0;e&r&&(this.insertView(t),e^=r)}return e?t.confirmUpdate(e,i||{}):0},requireView:function(t,e){t=this.findViewByModel(t);return t?(this.dumpView(t,e),t):null},registerUnmountedView:function(t){var e=t.cid,i=this._updates;if(e in i.unmounted)return 0;t=i.unmounted[e]|=t.FLAG_INSERT;return i.unmountedCids.push(e),delete i.mounted[e],t},registerMountedView:function(t){var t=t.cid,e=this._updates;if(t in e.mounted)return 0;e.mounted[t]=!0,e.mountedCids.push(t);var i=e.unmounted[t]||0;return delete e.unmounted[t],i},isViewMounted:function(t){return!!t&&t.cid in this._updates.mounted},dumpViews:function(t){t=S({},t,{viewport:null});this.checkViewport(t),this.updateViews(t)},updateViews:function(t){this.notifyBeforeRender(t);for(var e,i=0,n=0,r=ho;n++,i+=(e=this.updateViewsBatch(t)).updated,r=Math.min(e.priority,r),!e.empty;);var o={updated:i,batches:n,priority:r};return this.notifyAfterRender(o,t),o},hasScheduledUpdates:function(){for(var t=this._updates.priorities,e=Object.keys(t),i=e.length;0<i&&i--;)for(var n in t[e[i]])return!0;return!1},updateViewsAsync:function(t,e){t=t||{},e=e||{processed:0,priority:ho};var i=this._updates,n=i.id;if(n){qe(n),0===e.processed&&this.hasScheduledUpdates()&&this.notifyBeforeRender(t);var r=this.updateViewsBatch(t),o=S({},t,{mountBatchSize:1e3-r.mounted,unmountBatchSize:1e3-r.unmounted}),o=this.checkViewport(o),s=o.unmounted,o=o.mounted,a=e.processed,l=i.count,s=(0<r.updated&&(a+=r.updated+r.unmounted,r.processed=a,e.priority=Math.min(r.priority,e.priority),r.empty&&0===o?(r.unmounted+=s,r.mounted+=o,r.priority=e.priority,this.notifyAfterRender(r,t),e.processed=0,e.priority=ho,i.count=0):e.processed=a),t.progress);if(l&&"function"==typeof s&&s.call(this,r.empty,a,l,r,this),i.id!==n)return}i.id=Ke(this.updateViewsAsync,this,t,e)},notifyBeforeRender:function(t){var e=(t=void 0===t?{}:t).beforeRender;"function"!=typeof e&&"function"!=typeof(e=this.options.beforeRender)||e.call(this,t,this)},notifyAfterRender:function(t,e){var i=(e=void 0===e?{}:e).afterRender;"function"==typeof(i="function"!=typeof i?this.options.afterRender:i)&&i.call(this,t,e,this),this.trigger("render:done",t,e)},updateViewsBatch:function(t){var e=(t=t||{}).batchSize||1/0,i=this._updates,n=0,r=0,o=0,s=0,a=ho,l=!0,h=this.options,c=i.priorities,u=("viewport"in t?t:h).viewport,d=("function"!=typeof u&&(u=null),h.onViewPostponed),g=("function"!=typeof d&&(d=null),Object.keys(c));t:for(var p=0,f=g.length;p<f;p++){var m,v=+g[p],y=c[v];for(m in y){if(e<=n){l=!1;break t}var b=bn[m];if(b){var w=y[m];if(0==(w&b.FLAG_REMOVE)){var A=m in i.unmounted;if(b.DETACHABLE&&u&&!u.call(this,b,!A,this)){A||(this.registerUnmountedView(b),b.unmount()),i.unmounted[m]|=w,delete y[m],o++;continue}A&&(w|=b.FLAG_INSERT,s++),w|=this.registerMountedView(b)}A=this.updateView(b,w,t);0<A&&(y[m]=A,!d||!d.call(this,b,A,this)||y[m])?(r++,l=!1):(v<a&&(a=v),n++,delete y[m])}else delete y[m]}}return{priority:a,updated:n,postponed:r,unmounted:o,mounted:s,empty:l}},getUnmountedViews:function(){for(var t=this._updates,e=Object.keys(t.unmounted),i=e.length,n=new Array(i),r=0;r<i;r++)n[r]=bn[e[r]];return n},getMountedViews:function(){for(var t=this._updates,e=Object.keys(t.mounted),i=e.length,n=new Array(i),r=0;r<i;r++)n[r]=bn[e[r]];return n},checkUnmountedViews:function(t,e){for(var i=0,e=("function"!=typeof t&&(t=null),"mountBatchSize"in(e=e||{})?e.mountBatchSize:1/0),n=this._updates,r=n.unmountedCids,o=n.unmounted,s=0,a=Math.min(r.length,e);s<a;s++){var l,h=r[s];h in o&&((l=bn[h])&&(l.DETACHABLE&&t&&!t.call(this,l,!1,this)?r.push(h):(i++,(h=this.registerMountedView(l))&&this.scheduleViewUpdate(l,h,l.UPDATE_PRIORITY,{mounting:!0}))))}return r.splice(0,s),i},checkMountedViews:function(t,e){var i=0;if("function"!=typeof t)return i;for(var e=("unmountBatchSize"in(e=e||{})?e.unmountBatchSize:1/0),n=this._updates,r=n.mountedCids,o=n.mounted,s=0,a=Math.min(r.length,e);s<a;s++){var l,h=r[s];h in o&&((l=bn[h])&&(!l.DETACHABLE||t.call(this,l,!0,this)?r.push(h):(i++,this.registerUnmountedView(l)&&l.unmount())))}return r.splice(0,s),i},checkViewport:function(t){var e,t=S({},t,{mountBatchSize:1/0,unmountBatchSize:1/0}),i=("viewport"in t?t:this.options).viewport,n=this.checkMountedViews(i,t);return 0<n&&(e=this._updates.unmountedCids,t.mountBatchSize=Math.min(e.length-n,t.mountBatchSize)),{mounted:this.checkUnmountedViews(i,t),unmounted:n}},freeze:function(t){var e=this._updates,t=(t=t||{}).key,i=this.options.frozen,n=e.freezeKey;if(t&&t!==n){if(i&&n)return;e.freezeKey=t,e.keyFrozen=i}this.options.frozen=!0;n=e.id;e.id=null,this.isAsync()&&n&&qe(n)},unfreeze:function(t){var e=this._updates,i=(t=t||{}).key,n=e.freezeKey;i&&n&&i!==n||(e.freezeKey=null,i&&i===n&&e.keyFrozen||(this.isAsync()?(this.freeze(),this.updateViewsAsync(t)):this.updateViews(t),this.options.frozen=e.keyFrozen=!1,e.sort&&(this.sortViews(),e.sort=!1)))},isAsync:function(){return!!this.options.async},isFrozen:function(){return!!this.options.frozen},isExactSorting:function(){return this.options.sorting===lo.EXACT},onRemove:function(){this.freeze(),this.removeLayers(),this.removeViews()},getComputedSize:function(){var t=this.options,e=t.width,t=t.height;return{width:e=G(e)?e:this.el.clientWidth,height:t=G(t)?t:this.el.clientHeight}},setDimensions:function(t,e){var i=this.options,n=i.width,r=i.height,t=void 0===t?n:t,e=void 0===e?r:e;n===t&&r===e||(i.width=t,i.height=e,this._setDimensions(),n=this.getComputedSize(),this.trigger("resize",n.width,n.height))},_setDimensions:function(){var t=this.options,e=t.width,t=t.height;G(e)&&(e=Math.round(e)),G(t)&&(t=Math.round(t)),this.$el.css({width:null===e?"":e,height:null===t?"":t})},setOrigin:function(t,e){return this.translate(t||0,e||0)},fitToContent:function(t,e,i,n){n=x(t)?t:R({gridWidth:t,gridHeight:e,padding:i},n);var t=this.getFitToContentArea(n),e=t.x,i=t.y,n=t.width,t=t.height,r=this.scale(),o=r.sx,r=r.sy;return this.setOrigin(-e*o,-i*r),this.setDimensions(n*o,t*r),new tt(e,i,n,t)},getFitToContentArea:function(t){var e=(t=void 0===t?{}:t).gridWidth||1,i=t.gridHeight||1,n=ei(t.padding||0),r=Math.max(t.minWidth||0,e),o=Math.max(t.minHeight||0,i),s=t.maxWidth||Number.MAX_VALUE,a=t.maxHeight||Number.MAX_VALUE,l=t.allowNewOrigin,h="contentArea"in t?new tt(t.contentArea):this.getContentArea(t),c=this.scale(),u=c.sx,c=c.sy,d=(h.x*=u,h.y*=c,h.width*=u,h.height*=c,Math.ceil((h.width+h.x)/e)),g=Math.ceil((h.height+h.y)/i),t=(t.allowNegativeBottomRight||(d=Math.max(d,1),g=Math.max(g,1)),d*=e,g*=i,0),e=(("negative"===l&&h.x<0||"positive"===l&&0<=h.x||"any"===l)&&(t=Math.ceil(-h.x/e)*e,d+=t+=n.left),0);return("negative"===l&&h.y<0||"positive"===l&&0<=h.y||"any"===l)&&(e=Math.ceil(-h.y/i)*i,g+=e+=n.top),d+=n.right,g+=n.bottom,d=Math.max(d,r),g=Math.max(g,o),d=Math.min(d,s),g=Math.min(g,a),new tt(-t/u,-e/c,d/u,g/c)},scaleContentToFit:function(t){var e,i,n,r,o,s,a,l,h;e="contentArea"in(t=t||{})?(e=t.contentArea,a=this.localToPaperRect(e),new z(e)):(a=this.getContentBBox(t),this.paperToLocalPoint(a)),a.width&&a.height&&(S(t,{padding:0,preserveAspectRatio:!0,scaleGrid:null,minScale:0,maxScale:Number.MAX_VALUE}),s=ei(t.padding),i=t.minScaleX||t.minScale,h=t.maxScaleX||t.maxScale,n=t.minScaleY||t.minScale,r=t.maxScaleY||t.maxScale,o=t.fittingBBox||(o=this.translate(),l=this.getComputedSize(),{x:o.tx,y:o.ty,width:l.width,height:l.height}),o=new tt(o).moveAndExpand({x:s.left,y:s.top,width:-s.left-s.right,height:-s.top-s.bottom}),l=this.scale(),s=o.width/a.width*l.sx,a=o.height/a.height*l.sy,t.preserveAspectRatio&&(s=a=Math.min(s,a)),t.scaleGrid&&(s=(l=t.scaleGrid)*Math.floor(s/l),a=l*Math.floor(a/l)),s=Math.min(h,Math.max(i,s)),a=Math.min(r,Math.max(n,a)),t=this.options.origin,l=o.x-e.x*s-t.x,h=o.y-e.y*a-t.y,this.scale(s,a),this.translate(l,h))},getContentArea:function(t){return t&&t.useModelGeometry?this.model.getBBox()||new tt:B(this.cells).getBBox()},getContentBBox:function(t){return this.localToPaperRect(this.getContentArea(t))},getArea:function(){return this.paperToLocalRect(this.getComputedSize())},getRestrictedArea:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var i=this.options.restrictTranslate,i=P(i)?i.apply(this,t):!0===i?this.getArea():i?new tt(i):null;return i},createViewForModel:function(t){var e,i=this.options,n=i.cellViewNamespace,r=t.get("type")+"View",n=Me(n,r,"."),r=t.isLink()?(e=i.linkView,ao):(e=i.elementView,g);return new(e.prototype instanceof o.View?n||e:e.call(this,t)||n||r)({model:t,interactive:i.interactive,labelsLayer:!0===i.labelsLayer?oo.LABELS:i.labelsLayer})},removeView:function(t){var e,i,t=t.id,n=this._views,r=this._updates,o=n[t];return o&&(e=o.cid,i=r.mounted,r=r.unmounted,o.remove(),delete n[t],delete i[e],delete r[e]),o},renderView:function(t,e){var i,n,r=t.id,o=this._views,s=!0;return r in o&&((i=o[r]).model===t?(n=i.FLAG_INSERT,s=!1):this.removeView(t)),s&&(n=((i=o[r]=this.createViewForModel(t)).paper=this).registerUnmountedView(i)|i.getFlag(M(i,"initFlag"))),this.requestViewUpdate(i,n,i.UPDATE_PRIORITY,e),i},onImageDragStart:function(){return!1},resetViews:function(t,e){e=e||{},t=t||[],this._resetUpdates(),this.removeViews(),this.freeze({key:"reset"});for(var i=0,n=t.length;i<n;i++)this.renderView(t[i],e);this.unfreeze({key:"reset"}),this.sortViews()},removeViews:function(){li(this._views,"remove"),this._views={}},sortViews:function(){this.isExactSorting()&&(this.isFrozen()?this._updates.sort=!0:this.sortViewsExact())},sortViewsExact:function(){var t=w(this.cells).children("[model-id]"),i=this.model.get("cells");Ye(t,function(t,e){t=i.get(t.getAttribute("model-id")),e=i.get(e.getAttribute("model-id")),t=t.attributes.z||0,e=e.attributes.z||0;return t===e?0:t<e?-1:1})},insertView:function(t){var e=this.getLayerView(oo.CELLS),i=t.el,n=t.model;this.options.sorting===lo.APPROX?e.insertSortedNode(i,n.get("z")):e.insertNode(i),t.onMount()},scale:function(t,e,i,n){if(void 0===t)return B.matrixToScale(this.matrix());void 0===e&&(e=t),void 0===i&&(n=i=0);var r=this.translate(),o=((i||n||r.tx||r.ty)&&(o=r.tx-i*(t-1),r=r.ty-n*(e-1),this.translate(o,r)),t=Math.max(t||0,this.MIN_SCALE),e=Math.max(e||0,this.MIN_SCALE),this.matrix());return o.a=t,o.d=e,this.matrix(o),this.trigger("scale",t,e,i,n),this},rotate:function(t,e,i){if(void 0===t)return B.matrixToRotate(this.matrix());void 0===e&&(e=(n=this.cells.getBBox()).width/2,i=n.height/2);var n=this.matrix().translate(e,i).rotate(t).translate(-e,-i);return this.matrix(n),this},translate:function(t,e){if(void 0===t)return B.matrixToTranslate(this.matrix());var i=this.options,n=i.origin,i=i.drawGrid,r=(t=t||0,e=e||0,this.matrix());if(r.e===t&&r.f===e)return this;r.e=t,r.f=e,this.matrix(r);t=this.translate(),e=t.tx,r=t.ty;return n.x=e,n.y=r,this.trigger("translate",e,r),i&&this.drawGrid(),this},findView:function(t){t=N(t)?this.cells.querySelector(t):t instanceof w?t[0]:t,t=this.findAttribute("model-id",t);if(t)return this._views[t]},findViewByModel:function(t){t=N(t)||G(t)?t:t&&t.id;return this._views[t]},findViewsFromPoint:function(e){return e=new z(e),this.model.getElements().map(this.findViewByModel,this).filter(function(t){return t&&t.vel.getBBox({target:this.cells}).containsPoint(e)},this)},findViewsInArea:function(e,t){t=S(t||{},{strict:!1}),e=new tt(e);var i=this.model.getElements().map(this.findViewByModel,this),n=t.strict?"containsRect":"intersect";return i.filter(function(t){return t&&e[n](t.vel.getBBox({target:this.cells}))},this)},removeTools:function(){return this.dispatchToolsEvent("remove"),this},hideTools:function(){return this.dispatchToolsEvent("hide"),this},showTools:function(){return this.dispatchToolsEvent("show"),this},dispatchToolsEvent:function(t){for(var e=[],i=arguments.length-1;0<i--;)e[i]=arguments[i+1];"string"==typeof t&&this.trigger.apply(this,["tools:event",t].concat(e))},getModelById:function(t){return this.model.getCell(t)},snapToGrid:function(t,e){return this.clientToLocalPoint(t,e).snapToGrid(this.options.gridSize)},localToPaperPoint:function(t,e){t=new z(t,e);return B.transformPoint(t,this.matrix())},localToPaperRect:function(t,e,i,n){t=new tt(t,e,i,n);return B.transformRect(t,this.matrix())},paperToLocalPoint:function(t,e){t=new z(t,e);return B.transformPoint(t,this.matrix().inverse())},paperToLocalRect:function(t,e,i,n){t=new tt(t,e,i,n);return B.transformRect(t,this.matrix().inverse())},localToClientPoint:function(t,e){t=new z(t,e);return B.transformPoint(t,this.clientMatrix())},localToClientRect:function(t,e,i,n){t=new tt(t,e,i,n);return B.transformRect(t,this.clientMatrix())},clientToLocalPoint:function(t,e){t=new z(t,e);return B.transformPoint(t,this.clientMatrix().inverse())},clientToLocalRect:function(t,e,i,n){t=new tt(t,e,i,n);return B.transformRect(t,this.clientMatrix().inverse())},localToPagePoint:function(t,e){return this.localToPaperPoint(t,e).offset(this.pageOffset())},localToPageRect:function(t,e,i,n){return this.localToPaperRect(t,e,i,n).offset(this.pageOffset())},pageToLocalPoint:function(t,e){t=new z(t,e).difference(this.pageOffset());return this.paperToLocalPoint(t)},pageToLocalRect:function(t,e,i,n){var r=this.pageOffset(),t=new tt(t,e,i,n);return t.x-=r.x,t.y-=r.y,this.paperToLocalRect(t)},clientOffset:function(){var t=this.svg.getBoundingClientRect();return new z(t.left,t.top)},pageOffset:function(){return this.clientOffset().offset(window.scrollX,window.scrollY)},linkAllowed:function(t){if(!(t instanceof ao))throw new Error("Must provide a linkView.");var e=t.model,i=this.options,n=this.model,r=n.constructor.validations;return!(!i.multiLinks&&!r.multiLinks.call(this,n,e))&&(!(!i.linkPinning&&!r.linkPinning.call(this,n,e))&&!("function"==typeof i.allowLink&&!i.allowLink.call(this,t,this)))},getDefaultLink:function(t,e){return P(this.options.defaultLink)?this.options.defaultLink.call(this,t,e):this.options.defaultLink.clone()},resolveHighlighter:function(t){var e=(t=void 0===t?{}:t).highlighter,t=t.type,i=this.options,n=i.highlighting,i=i.highlighterNamespace;if(void 0===e){if(!n)return!1;if(t&&!1===(e=n[t]))return!1;e=e||n.default}if(!e)return!1;t=(e=N(e)?{name:e}:e).name,n=i[t];if(!n)throw new Error('Unknown highlighter ("'+t+'")');if("function"!=typeof n.highlight)throw new Error('Highlighter ("'+t+'") is missing required highlight() method');if("function"!=typeof n.unhighlight)throw new Error('Highlighter ("'+t+'") is missing required unhighlight() method');return{highlighter:n,options:e.options||{},name:t}},onCellHighlight:function(t,e,i){var n,i=this.resolveHighlighter(i);i&&(n=i.highlighter,i=i.options,n.highlight(t,e,i))},onCellUnhighlight:function(t,e,i){var n,i=this.resolveHighlighter(i);i&&(n=i.highlighter,i=i.options,n.unhighlight(t,e,i))},pointerdblclick:function(t){t.preventDefault(),t=I(t);var e,i=this.findView(t.target);this.guard(t,i)||(e=this.snapToGrid(t.clientX,t.clientY),i?i.pointerdblclick(t,e.x,e.y):this.trigger("blank:pointerdblclick",t,e.x,e.y))},pointerclick:function(t){var e,i;this.eventData(t).mousemoved<=this.options.clickThreshold&&(t=I(t),e=this.findView(t.target),this.guard(t,e)||(i=this.snapToGrid(t.clientX,t.clientY),e?e.pointerclick(t,i.x,i.y):this.trigger("blank:pointerclick",t,i.x,i.y)))},contextmenu:function(t){this.options.preventContextMenu&&t.preventDefault(),t=I(t);var e,i=this.findView(t.target);this.guard(t,i)||(e=this.snapToGrid(t.clientX,t.clientY),i?i.contextmenu(t,e.x,e.y):this.trigger("blank:contextmenu",t,e.x,e.y))},pointerdown:function(t){t=I(t);var e,i=this.findView(t.target);this.guard(t,i)||(e=this.snapToGrid(t.clientX,t.clientY),i?(t.preventDefault(),i.pointerdown(t,e.x,e.y)):(this.options.preventDefaultBlankAction&&t.preventDefault(),this.trigger("blank:pointerdown",t,e.x,e.y)),this.delegateDragEvents(i,t.data))},pointermove:function(t){var e,i,n=this.eventData(t);n.mousemoved||(n.mousemoved=0),++n.mousemoved<=this.options.moveThreshold||(t=I(t),e=this.snapToGrid(t.clientX,t.clientY),(i=n.sourceView)?i.pointermove(t,e.x,e.y):this.trigger("blank:pointermove",t,e.x,e.y),this.eventData(t,n))},pointerup:function(t){this.undelegateDocumentEvents();var e=I(t),i=this.snapToGrid(e.clientX,e.clientY),n=this.eventData(t).sourceView;n?n.pointerup(e,i.x,i.y):this.trigger("blank:pointerup",e,i.x,i.y),e.isPropagationStopped()||this.pointerclick(w.Event(t,{type:"click",data:t.data})),t.stopImmediatePropagation(),this.delegateEvents()},mouseover:function(t){t=I(t);var e=this.findView(t.target);this.guard(t,e)||(e?e.mouseover(t):this.el!==t.target&&this.trigger("blank:mouseover",t))},mouseout:function(t){t=I(t);var e=this.findView(t.target);this.guard(t,e)||(e?e.mouseout(t):this.el!==t.target&&this.trigger("blank:mouseout",t))},mouseenter:function(t){t=I(t);var e,i=this.findView(t.target);this.guard(t,i)||(e=this.findView(t.relatedTarget),i?e!==i&&i.mouseenter(t):e||this.trigger("paper:mouseenter",t))},mouseleave:function(t){var e=(t=I(t)).target,i=t.relatedTarget,e=this.findView(e);if(!this.guard(t,e)){var n=this.findView(i);if(e){if(n===e)return;if(t.stopPropagation(),e.mouseleave(t),this.el.contains(i))return}n||this.trigger("paper:mouseleave",t)}},mousewheel:function(t){t=I(t);var e,i,n=this.findView(t.target);this.guard(t,n)||(i=t.originalEvent,e=this.snapToGrid(i.clientX,i.clientY),i=Math.max(-1,Math.min(1,i.wheelDelta)),n?n.mousewheel(t,e.x,e.y,i):this.trigger("blank:mousewheel",t,e.x,e.y,i))},onevent:function(t){var e,i=t.currentTarget,n=i.getAttribute("event");n&&(i=this.findView(i))&&(t=I(t),this.guard(t,i)||(e=this.snapToGrid(t.clientX,t.clientY),i.onevent(t,n,e.x,e.y)))},magnetEvent:function(t,e){var i,n,r=t.currentTarget;r.getAttribute("magnet")&&(i=this.findView(r))&&(t=I(t),this.guard(t,i)||(n=this.snapToGrid(t.clientX,t.clientY),e.call(this,i,t,r,n.x,n.y)))},onmagnet:function(t){this.magnetEvent(t,function(t,e,i,n,r){t.onmagnet(e,n,r)})},magnetpointerdblclick:function(t){this.magnetEvent(t,function(t,e,i,n,r){t.magnetpointerdblclick(e,i,n,r)})},magnetcontextmenu:function(t){this.options.preventContextMenu&&t.preventDefault(),this.magnetEvent(t,function(t,e,i,n,r){t.magnetcontextmenu(e,i,n,r)})},onlabel:function(t){var e,i=t.currentTarget,i=this.findView(i);i&&(t=I(t),this.guard(t,i)||(e=this.snapToGrid(t.clientX,t.clientY),i.onlabel(t,e.x,e.y)))},getPointerArgs:function(t){var t=I(t),e=this.snapToGrid(t.clientX,t.clientY);return[t,e.x,e.y]},delegateDragEvents:function(t,e){this.eventData({data:e=e||{}},{sourceView:t||null,mousemoved:0}),this.delegateDocumentEvents(null,e),this.undelegateEvents()},guard:function(t,e){return"mousedown"===t.type&&2===t.button||(!(!this.options.guard||!this.options.guard(t,e))||(t.data&&void 0!==t.data.guarded?t.data.guarded:!(e&&e.model&&e.model instanceof rn)&&(this.svg!==t.target&&this.el!==t.target&&!w.contains(this.svg,t.target))))},setGridSize:function(t){return this.options.gridSize=t,this.options.drawGrid&&this.drawGrid(),this},clearGrid:function(){return this.$grid&&this.$grid.css("backgroundImage","none"),this},_getGridRefs:function(){return this._gridCache||(this._gridCache={root:B("svg",{width:"100%",height:"100%"},B("defs")),patterns:{},add:function(t,e){B(this.root.node.childNodes[0]).append(e),this.patterns[t]=e,this.root.append(B("rect",{width:"100%",height:"100%",fill:"url(#"+t+")"}))},get:function(t){return this.patterns[t]},exist:function(t){return void 0!==this.patterns[t]}}),this._gridCache},setGrid:function(t){return this.clearGrid(),this._gridCache=null,this._gridSettings=[],(Array.isArray(t)?t:[t||{}]).forEach(function(t){this._gridSettings.push.apply(this._gridSettings,this._resolveDrawGridOption(t))},this),this},_resolveDrawGridOption:function(t){var e=this.constructor.gridPatterns;if(N(t)&&Array.isArray(e[t]))return e[t].map(function(t){return R({},t)});var i=t||{args:[{}]},n=Array.isArray(i),r=i.name;if((r=n||r||i.markup?r:"dot")&&Array.isArray(e[r])){var o=e[r].map(function(t){return R({},t)}),s=Array.isArray(i.args)?i.args:[i.args||{}];S(s[0],Si(t,"args"));for(var a=0;a<s.length;a++)o[a]&&R(o[a],s[a]);return o}return n?i:[i]},drawGrid:function(t){var r=this.options.gridSize;if(r<=1)return this.clearGrid();var o=Array.isArray(t)?t:[t],s=this.matrix(),a=this._getGridRefs(),t=(this._gridSettings.forEach(function(t,e){var i="pattern_"+e,t=y(t,o[e],{sx:s.a||1,sy:s.d||1,ox:s.e||0,oy:s.f||0}),e=(t.width=r*(s.a||1)*(t.scaleFactor||1),t.height=r*(s.d||1)*(t.scaleFactor||1),a.exist(i)||a.add(i,B("pattern",{id:i,patternUnits:"userSpaceOnUse"},B(t.markup))),a.get(i)),i=(P(t.update)&&t.update(e.node.childNodes[0],t),t.ox%t.width),n=(i<0&&(i+=t.width),t.oy%t.height);n<0&&(n+=t.height),e.attr({x:i,y:n,width:t.width,height:t.height})}),(new XMLSerializer).serializeToString(a.root.node)),t="url(data:image/svg+xml;base64,"+btoa(t)+")";return this.$grid.css("backgroundImage",t),this},updateBackgroundImage:function(t){var e=(t=t||{}).position||"center",t=t.size||"auto auto",i=this.scale(),n=this.translate();x(e)&&(e=n.tx+i.sx*(e.x||0)+"px "+(n.ty+i.sy*(e.y||0))+"px"),x(t)&&(t=(t=new tt(t).scale(i.sx,i.sy)).width+"px "+t.height+"px"),this.$background.css({backgroundSize:t,backgroundPosition:e})},drawBackgroundImage:function(t,e){if(t instanceof HTMLImageElement){if(this._background&&this._background.id===e.id){var i,n=(e=e||{}).size,r=e.repeat||"no-repeat",o=e.opacity||1,s=Math.abs(e.quality)||1,a=this.constructor.backgroundPatterns[ki(r)];if(P(a)){t.width*=s,t.height*=s;a=a(t,e);if(!(a instanceof HTMLCanvasElement))throw new Error("dia.Paper: background pattern must return an HTML Canvas instance");i=a.toDataURL("image/png"),r="repeat",x(n)?(n.width*=a.width/t.width,n.height*=a.height/t.height):void 0===n&&(e.size={width:a.width/s,height:a.height/s})}else i=t.src,void 0===n&&(e.size={width:t.width,height:t.height});this.$background.css({opacity:o,backgroundRepeat:r,backgroundImage:"url("+i+")"}),this.updateBackgroundImage(e)}}else this.$background.css("backgroundImage","")},updateBackgroundColor:function(t){this.$el.css("backgroundColor",t||"")},drawBackground:function(t){var e;return this.updateBackgroundColor((t=t||{}).color),t.image?(t=this._background=di(t),De(t),(e=document.createElement("img")).onload=this.drawBackgroundImage.bind(this,e,t),e.src=t.image):(this.drawBackgroundImage(null),this._background=null),this},setInteractivity:function(t){this.options.interactive=t,li(this._views,"setInteractivity",t)},isDefined:function(t){return!!this.svg.getElementById(t)},defineFilter:function(t){if(!x(t))throw new TypeError("dia.Paper: defineFilter() requires 1. argument to be an object.");var e=t.id,i=t.name,e=e||i+this.svg.id+Pe(JSON.stringify(t));if(!this.isDefined(e)){var n=ri,n=n[i]&&n[i](t.args||{});if(!n)throw new Error("Non-existing filter "+i);i=R({filterUnits:"objectBoundingBox",x:-1,y:-1,width:3,height:3},t.attrs,{id:e});B(n,i).appendTo(this.defs)}return e},defineGradient:function(t){if(!x(t))throw new TypeError("dia.Paper: defineGradient() requires 1. argument to be an object.");var e=this.svg,i=this.defs,n=t.type,r=t.id,e=(void 0===r&&(r=n+e.id+Pe(JSON.stringify(t))),t.stops),t=t.attrs;if(void 0===t&&(t={}),this.isDefined(r))return r;e=et(e).map(function(t){var e=t.offset,i=t.color,t=t.opacity;return B("stop").attr({offset:e,"stop-color":i,"stop-opacity":Number.isFinite(t)?t:1})}),n=B(n,t,e);return n.id=r,n.appendTo(i),r},definePattern:function(t){if(!x(t))throw new TypeError("dia.Paper: definePattern() requires 1. argument to be an object.");var e=this.svg,i=this.defs,n=t.id,e=(void 0===n&&(n=e.id+Pe(JSON.stringify(t))),t.markup),t=t.attrs;if(void 0===t&&(t={}),!e)throw new TypeError("dia.Paper: definePattern() requires markup.");if(this.isDefined(n))return n;var r=B("pattern",{patternUnits:"userSpaceOnUse"});return r.id=n,r.attr(t),"string"==typeof e?r.append(B(e)):(t=Se(e).fragment,r.append(t)),r.appendTo(i),n},defineMarker:function(t){if(!x(t))throw new TypeError("dia.Paper: defineMarker() requires 1. argument to be an object.");var e=this.svg,i=this.defs,n=t.id,e=(void 0===n&&(n=e.id+Pe(JSON.stringify(t))),t.markup),r=t.attrs,o=(void 0===r&&(r={}),t.markerUnits);if(void 0===o&&(o="userSpaceOnUse"),this.isDefined(n))return n;o=B("marker",{orient:"auto",overflow:"visible",markerUnits:o});return o.id=n,o.attr(r),e?"string"==typeof e?o.append(B(e)):(r=Se(e).fragment,o.append(r)):(e=t.type,r=B(e=void 0===e?"path":e,Si(t,"type","id","markup","attrs","markerUnits")),o.append(r)),o.appendTo(i),n}},{sorting:lo,Layers:oo,backgroundPatterns:{flipXy:function(t){var e=document.createElement("canvas"),i=t.width,n=t.height,r=(e.width=2*i,e.height=2*n,e.getContext("2d"));return r.drawImage(t,0,0,i,n),r.setTransform(-1,0,0,-1,e.width,e.height),r.drawImage(t,0,0,i,n),r.setTransform(-1,0,0,1,e.width,0),r.drawImage(t,0,0,i,n),r.setTransform(1,0,0,-1,0,e.height),r.drawImage(t,0,0,i,n),e},flipX:function(t){var e=document.createElement("canvas"),i=t.width,n=t.height,r=(e.width=2*i,e.height=n,e.getContext("2d"));return r.drawImage(t,0,0,i,n),r.translate(2*i,0),r.scale(-1,1),r.drawImage(t,0,0,i,n),e},flipY:function(t){var e=document.createElement("canvas"),i=t.width,n=t.height,r=(e.width=i,e.height=2*n,e.getContext("2d"));return r.drawImage(t,0,0,i,n),r.translate(0,2*n),r.scale(1,-1),r.drawImage(t,0,0,i,n),e},watermark:function(t,e){e=e||{};for(var i=t.width,n=t.height,r=document.createElement("canvas"),o=(r.width=3*i,r.height=3*n,r.getContext("2d")),e=G(e.watermarkAngle)?-e.watermarkAngle:-20,s=K(e),a=r.width/4,l=r.height/4,h=0;h<4;h++)for(var c=0;c<4;c++)0<(h+c)%2&&(o.setTransform(1,0,0,1,(2*h-1)*a,(2*c-1)*l),o.rotate(s),o.drawImage(t,-i/2,-n/2,i,n));return r}},gridPatterns:{dot:[{color:"#AAAAAA",thickness:1,markup:"rect",update:function(t,e){B(t).attr({width:e.thickness*e.sx,height:e.thickness*e.sy,fill:e.color})}}],fixedDot:[{color:"#AAAAAA",thickness:1,markup:"rect",update:function(t,e){var i=e.sx<=1?e.thickness*e.sx:e.thickness;B(t).attr({width:i,height:i,fill:e.color})}}],mesh:[{color:"#AAAAAA",thickness:1,markup:"path",update:function(t,e){var i=e.width,n=e.height,r=e.thickness,r=0<=i-r&&0<=n-r?["M",i,0,"H0 M0 0 V0",n].join(" "):"M 0 0 0 0";B(t).attr({d:r,stroke:e.color,"stroke-width":e.thickness})}}],doubleMesh:[{color:"#AAAAAA",thickness:1,markup:"path",update:function(t,e){var i=e.width,n=e.height,r=e.thickness,r=0<=i-r&&0<=n-r?["M",i,0,"H0 M0 0 V0",n].join(" "):"M 0 0 0 0";B(t).attr({d:r,stroke:e.color,"stroke-width":e.thickness})}},{color:"#000000",thickness:3,scaleFactor:4,markup:"path",update:function(t,e){var i=e.width,n=e.height,r=e.thickness,r=0<=i-r&&0<=n-r?["M",i,0,"H0 M0 0 V0",n].join(" "):"M 0 0 0 0";B(t).attr({d:r,stroke:e.color,"stroke-width":e.thickness})}}]}}),po=n.extend({name:null,tagName:"g",className:"tool",svgElement:!0,_visible:!0,init:function(){var t=this.name;t&&this.vel.attr("data-tool-name",t)},configure:function(t,e){return this.relatedView=t,this.paper=t.paper,this.parentView=e,this.simulateRelatedView(this.el),this.delegateEvents(),this},simulateRelatedView:function(t){t&&t.setAttribute("model-id",this.relatedView.model.id)},getName:function(){return this.name},show:function(){this.el.style.display="",this._visible=!0},hide:function(){this.el.style.display="none",this._visible=!1},isVisible:function(){return!!this._visible},focus:function(){var t=this.options.focusOpacity;isFinite(t)&&(this.el.style.opacity=t),this.parentView.focusTool(this)},blur:function(){this.el.style.opacity="",this.parentView.blurTool(this)},update:function(){},guard:function(t){var e=this.paper,i=this.relatedView;return!e||!i||e.guard(t,i)}}),Gn=n.extend({tagName:"g",className:"tools",svgElement:!0,tools:null,isRendered:!1,options:{tools:null,relatedView:null,name:null},configure:function(t){var e=(t=R(this.options,t)).tools;if(!Array.isArray(e))return this;var i=t.relatedView;if(!(i instanceof c))return this;for(var n=this.tools=[],r=0,o=e.length;r<o;r++){var s=e[r];s instanceof po&&(s.configure(i,this),this.vel.append(s.el),n.push(s))}return this.isRendered=!1,i.requestUpdate(i.getFlag("TOOLS")),this},getName:function(){return this.options.name},update:function(t){t=t||{};var e=this.tools;if(!e)return this;for(var i=this.isRendered,n=0,r=e.length;n<r;n++){var o=e[n];i?t.tool!==o.cid&&o.isVisible()&&o.update():o.render()}return i||(this.mount(),this.blurTool(),this.isRendered=!0),this},focusTool:function(t){var e=this.tools;if(!e)return this;for(var i=0,n=e.length;i<n;i++){var r=e[i];t===r?r.show():r.hide()}return this},blurTool:function(t){var e=this.tools;if(!e)return this;for(var i=0,n=e.length;i<n;i++){var r=e[i];r===t||r.isVisible()||(r.show(),r.update())}return this},hide:function(){return this.focusTool(null)},show:function(){return this.blurTool(null)},onRemove:function(){var t=this.tools;if(!t)return this;for(var e=0,i=t.length;e<i;e++)t[e].remove();this.tools=null},mount:function(){var t=this.options,e=this.el,i=t.relatedView,n=t.layer,t=(void 0===n&&(n=oo.TOOLS),t.z);return i&&(n?i.paper.getLayerView(n).insertSortedNode(e,t):i.el.appendChild(e)),this}}),Sn={Graph:ro,attributes:nn,LayersNames:oo,PaperLayer:so,Cell:rn,CellView:c,Element:r,ElementView:g,Link:u,LinkView:ao,Paper:go,ToolView:po,ToolsView:Gn,HighlighterView:An};function fo(t,e,i){return br.call(this.paper,{},e,i,t,this.model).anchor}function mo(t,e){var i=t.model;return e?i.getBBox():i.isLink()?t.getConnection().bbox():t.getNodeUnrotatedBBox(t.el)}var zn=n.extend({tagName:"circle",svgElement:!0,className:"marker-vertex",events:{mousedown:"onPointerDown",touchstart:"onPointerDown",dblclick:"onDoubleClick",dbltap:"onDoubleClick"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},attributes:{r:6,fill:"#33334F",stroke:"#FFFFFF","stroke-width":2,cursor:"move"},position:function(t,e){this.vel.attr({cx:t,cy:e})},onPointerDown:function(t){this.options.guard(t)||(t.stopPropagation(),t.preventDefault(),this.options.paper.undelegateEvents(),this.delegateDocumentEvents(null,t.data),this.trigger("will-change",this,t))},onPointerMove:function(t){this.trigger("changing",this,t)},onDoubleClick:function(t){this.trigger("remove",this,t)},onPointerUp:function(t){this.trigger("changed",this,t),this.undelegateDocumentEvents(),this.options.paper.delegateEvents()}}),Gn=po.extend({name:"vertices",options:{handleClass:zn,snapRadius:20,redundancyRemoval:!0,vertexAdding:!0,stopPropagation:!0},children:[{tagName:"path",selector:"connection",className:"joint-vertices-path",attributes:{fill:"none",stroke:"transparent","stroke-width":10,cursor:"cell"}}],handles:null,events:{"mousedown .joint-vertices-path":"onPathPointerDown","touchstart .joint-vertices-path":"onPathPointerDown"},onRender:function(){return this.options.vertexAdding&&(this.renderChildren(),this.updatePath()),this.resetHandles(),this.renderHandles(),this},update:function(){return this.relatedView.model.vertices().length===this.handles.length?this.updateHandles():(this.resetHandles(),this.renderHandles()),this.options.vertexAdding&&this.updatePath(),this},resetHandles:function(){var t=this.handles;if(this.handles=[],this.stopListening(),Array.isArray(t))for(var e=0,i=t.length;e<i;e++)t[e].remove()},renderHandles:function(){for(var e=this,t=this.relatedView.model.vertices(),i=0,n=t.length;i<n;i++){var r=t[i],o=new this.options.handleClass({index:i,paper:this.paper,guard:function(t){return e.guard(t)}});o.render(),o.position(r.x,r.y),this.simulateRelatedView(o.el),o.vel.appendTo(this.el),this.handles.push(o),this.startHandleListening(o)}},updateHandles:function(){for(var t=this.relatedView.model.vertices(),e=0,i=t.length;e<i;e++){var n=t[e],r=this.handles[e];if(!r)return;r.position(n.x,n.y)}},updatePath:function(){var t=this.childNodes.connection;t&&t.setAttribute("d",this.relatedView.getSerializedConnection())},startHandleListening:function(t){var e=this.relatedView;e.can("vertexMove")&&(this.listenTo(t,"will-change",this.onHandleWillChange),this.listenTo(t,"changing",this.onHandleChanging),this.listenTo(t,"changed",this.onHandleChanged)),e.can("vertexRemove")&&this.listenTo(t,"remove",this.onHandleRemove)},getNeighborPoints:function(t){var e=this.relatedView,i=e.model.vertices(),n=0<t?i[t-1]:e.sourceAnchor,i=t<i.length-1?i[t+1]:e.targetAnchor;return{prev:new z(n),next:new z(i)}},onHandleWillChange:function(t,e){this.focus();var i=this.relatedView,n=this.options;i.model.startBatch("vertex-move",{ui:!0,tool:this.cid}),n.stopPropagation||i.notifyPointerdown.apply(i,i.paper.getPointerArgs(e))},onHandleChanging:function(t,e){var i=this.options,n=this.relatedView,r=t.options.index,e=n.paper.getPointerArgs(e),o=e[0],s=e[1],e=e[2],a={x:s,y:e};this.snapVertex(a,r),n.model.vertex(r,a,{ui:!0,tool:this.cid}),t.position(a.x,a.y),i.stopPropagation||n.notifyPointermove(o,s,e)},onHandleChanged:function(t,e){var i,n,r=this.options,o=this.relatedView;r.vertexAdding&&this.updatePath(),r.redundancyRemoval&&(o.removeRedundantLinearVertices({ui:!0,tool:this.cid})&&this.render(),this.blur(),o.model.stopBatch("vertex-move",{ui:!0,tool:this.cid}),this.eventData(e).vertexAdded&&o.model.stopBatch("vertex-add",{ui:!0,tool:this.cid}),i=(e=o.paper.getPointerArgs(e))[0],n=e[1],e=e[2],r.stopPropagation||o.notifyPointerup(i,n,e),o.checkMouseleave(i))},snapVertex:function(t,e){var i,n,r=this.options.snapRadius;0<r&&(i=(e=this.getNeighborPoints(e)).prev,n=e.next,Math.abs(t.x-i.x)<r?t.x=i.x:Math.abs(t.x-n.x)<r&&(t.x=n.x),Math.abs(t.y-i.y)<r?t.y=e.prev.y:Math.abs(t.y-n.y)<r&&(t.y=n.y))},onHandleRemove:function(t,e){var t=t.options.index,i=this.relatedView;i.model.removeVertex(t,{ui:!0}),this.options.vertexAdding&&this.updatePath(),i.checkMouseleave(I(e))},onPathPointerDown:function(t){var e,i,n;this.guard(t)||(t.stopPropagation(),t.preventDefault(),t=I(t),e=this.paper.snapToGrid(t.clientX,t.clientY).toJSON(),(n=this.relatedView).model.startBatch("vertex-add",{ui:!0,tool:this.cid}),i=n.getVertexIndex(e.x,e.y),this.snapVertex(e,i),n.model.insertVertex(i,e,{ui:!0,tool:this.cid}),this.update(),n=this.handles[i],this.eventData(t,{vertexAdded:!0}),n.onPointerDown(t))},onRemove:function(){this.resetHandles()}},{VertexHandle:zn}),zn=n.extend({tagName:"g",svgElement:!0,className:"marker-segment",events:{mousedown:"onPointerDown",touchstart:"onPointerDown"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},children:[{tagName:"line",selector:"line",attributes:{stroke:"#33334F","stroke-width":2,fill:"none","pointer-events":"none"}},{tagName:"rect",selector:"handle",attributes:{width:20,height:8,x:-10,y:-4,rx:4,ry:4,fill:"#33334F",stroke:"#FFFFFF","stroke-width":2}}],onRender:function(){this.renderChildren()},position:function(t,e,i,n){var r=B.createSVGMatrix().translate(t,e).rotate(i),o=this.childNodes.handle,r=(o.setAttribute("transform",B.matrixToTransformString(r)),o.setAttribute("cursor",i%180==0?"row-resize":"col-resize"),n.getClosestPoint(new z(t,e))),o=this.childNodes.line;o.setAttribute("x1",t),o.setAttribute("y1",e),o.setAttribute("x2",r.x),o.setAttribute("y2",r.y)},onPointerDown:function(t){this.options.guard(t)||(this.trigger("change:start",this,t),t.stopPropagation(),t.preventDefault(),this.options.paper.undelegateEvents(),this.delegateDocumentEvents(null,t.data))},onPointerMove:function(t){this.trigger("changing",this,t)},onPointerUp:function(t){this.undelegateDocumentEvents(),this.options.paper.delegateEvents(),this.trigger("change:end",this,t)},show:function(){this.el.style.display=""},hide:function(){this.el.style.display="none"}}),zn=po.extend({name:"segments",precision:.5,options:{handleClass:zn,segmentLengthThreshold:40,redundancyRemoval:!0,anchor:fo,snapRadius:10,snapHandle:!0,stopPropagation:!0},handles:null,onRender:function(){this.resetHandles();var t=this.relatedView,e=t.model.vertices();e.unshift(t.sourcePoint),e.push(t.targetPoint);for(var i=0,n=e.length;i<n-1;i++){var r=e[i],o=e[i+1],r=this.renderHandle(r,o);this.simulateRelatedView(r.el),this.handles.push(r),r.options.index=i}return this},renderHandle:function(t,e){var i=this,n=new this.options.handleClass({paper:this.paper,guard:function(t){return i.guard(t)}});return n.render(),this.updateHandle(n,t,e),n.vel.appendTo(this.el),this.startHandleListening(n),n},update:function(){return this.render(),this},startHandleListening:function(t){this.listenTo(t,"change:start",this.onHandleChangeStart),this.listenTo(t,"changing",this.onHandleChanging),this.listenTo(t,"change:end",this.onHandleChangeEnd)},resetHandles:function(){var t=this.handles;if(this.handles=[],this.stopListening(),Array.isArray(t))for(var e=0,i=t.length;e<i;e++)t[e].remove()},shiftHandleIndexes:function(t){for(var e=this.handles,i=0,n=e.length;i<n;i++)e[i].options.index+=t},resetAnchor:function(t,e){var i=this.relatedView.model;e?i.prop([t,"anchor"],e,{rewrite:!0,ui:!0,tool:this.cid}):i.removeProp([t,"anchor"],{ui:!0,tool:this.cid})},snapHandle:function(t,e,i){var n=t.options.index,r=this.relatedView.model.vertices(),t=t.options.axis,o=r[n-2]||i.sourceAnchor,r=r[n+1]||i.targetAnchor,n=this.options.snapRadius;return Math.abs(e[t]-o[t])<n?e[t]=o[t]:Math.abs(e[t]-r[t])<n&&(e[t]=r[t]),e},onHandleChanging:function(t,e){var i=this.options,n=this.eventData(e),r=this.relatedView,o=r.paper,s=t.options.index-1,e=I(e),o=o.snapToGrid(e.clientX,e.clientY),a=this.snapHandle(t,o.clone(),n),l=t.options.axis,h=this.options.snapHandle?0:o[l]-a[l],c=r.model,u=di(c.vertices()),d=u[s],g=u[1+s],p=this.options.anchor,f=("function"!=typeof p&&(p=null),r.sourceView),m=r.sourceBBox,v=!1,y=!1,m=(d?0==s?m.containsPoint(d)?(u.shift(),this.shiftHandleIndexes(-1),v=!0):(d[l]=a[l],y=!0):d[l]=a[l]:((d=r.sourceAnchor.toJSON())[l]=a[l],m.containsPoint(d)?(d[l]=a[l],v=!0):(u.unshift(d),this.shiftHandleIndexes(1),y=!0)),p&&f&&(v&&((m=n.sourceAnchor.clone())[l]=a[l],v=p.call(r,m,f,r.sourceMagnet||f.el,"source",r),this.resetAnchor("source",v)),y&&this.resetAnchor("source",n.sourceAnchorDef)),r.targetView),f=r.targetBBox,v=!1,y=!1;g?s==u.length-2?f.containsPoint(g)?(u.pop(),v=!0):(g[l]=a[l],y=!0):g[l]=a[l]:((g=r.targetAnchor.toJSON())[l]=a[l],f.containsPoint(g)?v=!0:(u.push(g),y=!0)),p&&m&&(v&&((s=n.targetAnchor.clone())[l]=a[l],f=p.call(r,s,m,r.targetMagnet||m.el,"target",r),this.resetAnchor("target",f)),y&&this.resetAnchor("target",n.targetAnchorDef)),c.vertices(u,{ui:!0,tool:this.cid}),this.updateHandle(t,d,g,h),i.stopPropagation||r.notifyPointermove(e,o.x,o.y)},onHandleChangeStart:function(t,e){var i=this.options,n=this.handles,r=this.relatedView,o=r.model,s=r.paper,a=t.options.index;if(Array.isArray(n)){for(var l=0,h=n.length;l<h;l++)l!==a&&n[l].hide();this.focus(),this.eventData(e,{sourceAnchor:r.sourceAnchor.clone(),targetAnchor:r.targetAnchor.clone(),sourceAnchorDef:ui(o.prop(["source","anchor"])),targetAnchorDef:ui(o.prop(["target","anchor"]))}),o.startBatch("segment-move",{ui:!0,tool:this.cid}),i.stopPropagation||r.notifyPointerdown.apply(r,s.getPointerArgs(e))}},onHandleChangeEnd:function(t,e){var i=this.options,n=this.relatedView,r=n.paper,o=n.model,e=(i.redundancyRemoval&&n.removeRedundantLinearVertices({ui:!0,tool:this.cid}),I(e)),r=r.snapToGrid(e.clientX,e.clientY);this.render(),this.blur(),o.stopBatch("segment-move",{ui:!0,tool:this.cid}),i.stopPropagation||n.notifyPointerup(e,r.x,r.y),n.checkMouseleave(e)},updateHandle:function(t,e,i,n){var r=Math.abs(e.x-i.x)<this.precision,o=Math.abs(e.y-i.y)<this.precision;!r&&!o||(o=new C(e,i)).length()<this.options.segmentLengthThreshold?t.hide():((e=o.midpoint())[i=r?"x":"y"]+=n||0,r=o.vector().vectorAngle(new z(1,0)),t.position(e.x,e.y,r,this.relatedView),t.show(),t.options.axis=i)},onRemove:function(){this.resetHandles()}},{SegmentHandle:zn}),vo=po.extend({tagName:"path",xAxisVector:new z(1,0),events:{mousedown:"onPointerDown",touchstart:"onPointerDown"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},onRender:function(){this.update()},update:function(){var t,e=this.ratio,i=this.relatedView,n=i.getTangentAtRatio(e),n=n?(t=n.start,n.vector().vectorAngle(this.xAxisVector)||0):(t=i.getPointAtRatio(e),0);if(!t)return this;i=B.createSVGMatrix().translate(t.x,t.y).rotate(n);return this.vel.transform(i,{absolute:!0}),this},onPointerDown:function(t){this.guard(t)||(t.stopPropagation(),t.preventDefault(),(t=this.relatedView).model.startBatch("arrowhead-move",{ui:!0,tool:this.cid}),t.can("arrowheadMove")&&(t.startArrowheadMove(this.arrowheadType),this.delegateDocumentEvents(),t.paper.undelegateEvents()),this.focus(),this.el.style.pointerEvents="none")},onPointerMove:function(t){var t=I(t),e=this.paper.snapToGrid(t.clientX,t.clientY);this.relatedView.pointermove(t,e.x,e.y)},onPointerUp:function(t){this.undelegateDocumentEvents();var e=this.relatedView,i=e.paper,t=I(t),n=i.snapToGrid(t.clientX,t.clientY);e.pointerup(t,n.x,n.y),i.delegateEvents(),this.blur(),this.el.style.pointerEvents="",e.model.stopBatch("arrowhead-move",{ui:!0,tool:this.cid})}}),yo=vo.extend({name:"target-arrowhead",ratio:1,arrowheadType:"target",attributes:{d:"M -10 -8 10 0 -10 8 Z",fill:"#33334F",stroke:"#FFFFFF","stroke-width":2,cursor:"move",class:"target-arrowhead"}}),vo=vo.extend({name:"source-arrowhead",ratio:0,arrowheadType:"source",attributes:{d:"M 10 -8 -10 0 10 8 Z",fill:"#33334F",stroke:"#FFFFFF","stroke-width":2,cursor:"move",class:"source-arrowhead"}}),bo=po.extend({name:"button",events:{mousedown:"onPointerDown",touchstart:"onPointerDown"},options:{distance:0,offset:0,rotate:!1},onRender:function(){this.renderChildren(this.options.markup),this.update()},update:function(){return this.position(),this},position:function(){var t=this.relatedView,e=this.vel,t=t.model.isLink()?this.getLinkMatrix():this.getElementMatrix();e.transform(t,{absolute:!0})},getElementMatrix:function(){var t=this.relatedView,e=this.options,i=e.x,n=(void 0===i&&(i=0),e.y),r=(void 0===n&&(n=0),e.offset),o=(void 0===r&&(r={}),e.useModelGeometry),e=e.rotate,o=mo(t,o),t=t.model.angle(),s=(e||(o=o.bbox(t)),r.x),r=(void 0===s&&(s=0),r.y),a=(void 0===r&&(r=0),ti(i)&&(i=parseFloat(i)/100*o.width),ti(n)&&(n=parseFloat(n)/100*o.height),B.createSVGMatrix().translate(o.x+o.width/2,o.y+o.height/2));return a=(a=e?a.rotate(t):a).translate(i+s-o.width/2,n+r-o.height/2)},getLinkMatrix:function(){var t,e=this.relatedView,i=this.options,n=i.offset,r=(void 0===n&&(n=0),i.distance),i=i.rotate,r=ti(r=void 0===r?0:r)?e.getTangentAtRatio(parseFloat(r)/100):e.getTangentAtLength(r),r=r?(t=r.start,r.vector().vectorAngle(new z(1,0))||0):(t=e.getConnection().start,0),e=B.createSVGMatrix().translate(t.x,t.y).rotate(r).translate(0,n);return e=i?e:e.rotate(-r)},onPointerDown:function(t){var e;this.guard(t)||(t.stopPropagation(),t.preventDefault(),"function"==typeof(e=this.options.action)&&e.call(this.relatedView,t,this.relatedView,this))}}),wo=bo.extend({children:[{tagName:"circle",selector:"button",attributes:{r:7,fill:"#FF1D00",cursor:"pointer"}},{tagName:"path",selector:"icon",attributes:{d:"M -3 -3 3 3 M -3 3 3 -3",fill:"none",stroke:"#FFFFFF","stroke-width":2,"pointer-events":"none"}}],options:{distance:60,offset:0,action:function(t,e,i){e.model.remove({ui:!0,tool:i.cid})}}}),Ao=bo.extend({name:"connect",documentEvents:{mousemove:"drag",touchmove:"drag",mouseup:"dragend",touchend:"dragend",touchcancel:"dragend"},children:[{tagName:"circle",selector:"button",attributes:{r:7,fill:"#333333",cursor:"pointer"}},{tagName:"path",selector:"icon",attributes:{d:"M -4 -1 L 0 -1 L 0 -4 L 4 0 L 0 4 0 1 -4 1 z",fill:"#FFFFFF",stroke:"none","stroke-width":2,"pointer-events":"none"}}],options:{distance:80,offset:0,magnet:function(t){return t.el},action:function(t,e,i){return i.dragstart(t)}},getMagnetNode:function(){var t,e=this.options,i=this.relatedView,n=e.magnet;switch(typeof n){case"function":t=n.call(this,i,this);break;case"string":t=i.findBySelector(n)[0];break;default:t=n}if((t=t||i.el)instanceof SVGElement)return t;throw new Error("Connect: magnet must be an SVGElement")},dragstart:function(t){var e=this.paper,i=this.relatedView,n=I(t),r=e.clientToLocalPoint(n.clientX,n.clientY),o=r.x,r=r.y;i.dragLinkStart(n,this.getMagnetNode(),o,r),e.undelegateEvents(),this.delegateDocumentEvents(null,t.data),this.focus()},drag:function(t){var e=this.paper,i=this.relatedView,t=I(t),e=e.snapToGrid(t.clientX,t.clientY),n=e.x,e=e.y;i.dragLink(t,n,e)},dragend:function(t){var e=this.paper,i=this.relatedView,t=I(t),n=e.snapToGrid(t.clientX,t.clientY),r=n.x,n=n.y;i.dragLinkEnd(t,r,n),this.undelegateDocumentEvents(),e.delegateEvents(),this.blur(),i.checkMouseleave(t)}}),Co=po.extend({name:"boundary",tagName:"rect",options:{padding:10,useModelGeometry:!1},attributes:{fill:"none",stroke:"#33334F","stroke-width":.5,"stroke-dasharray":"5, 5","pointer-events":"none"},onRender:function(){this.update()},update:function(){var t=this.relatedView,e=this.options,i=this.vel,n=e.useModelGeometry,r=e.rotate,e=ei(e.padding),n=mo(t,n).moveAndExpand({x:-e.left,y:-e.top,width:e.left+e.right,height:e.top+e.bottom}),e=t.model;return e.isElement()&&(t=e.angle())&&(r?(r=e.getBBox().center(),i.rotate(t,r.x,r.y,{absolute:!0})):n=n.bbox(t)),i.attr(n.toJSON()),this}}),Io=po.extend({tagName:"g",type:null,children:[{tagName:"circle",selector:"anchor",attributes:{cursor:"pointer"}},{tagName:"rect",selector:"area",attributes:{"pointer-events":"none",fill:"none",stroke:"#33334F","stroke-dasharray":"2,4",rx:5,ry:5}}],events:{mousedown:"onPointerDown",touchstart:"onPointerDown",dblclick:"onPointerDblClick",dbltap:"onPointerDblClick"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},options:{snap:function(t,e,i,n,r,o){return o=o.options.snapRadius,n="source"===n,(n=this.model.vertex(n?0:-1)||this.getEndAnchor(n?"target":"source"))&&(Math.abs(n.x-t.x)<o&&(t.x=n.x),Math.abs(n.y-t.y)<o&&(t.y=n.y)),t},anchor:fo,resetAnchor:!0,customAnchorAttributes:{"stroke-width":4,stroke:"#33334F",fill:"#FFFFFF",r:5},defaultAnchorAttributes:{"stroke-width":2,stroke:"#FFFFFF",fill:"#33334F",r:6},areaPadding:6,snapRadius:10,restrictArea:!0,redundancyRemoval:!0},onRender:function(){this.renderChildren(),this.toggleArea(!1),this.update()},update:function(){var t=this.type;return this.relatedView.getEndView(t)?(this.updateAnchor(),this.updateArea(),this.el.style.display=""):this.el.style.display="none",this},updateAnchor:function(){var t=this.childNodes;if(t){var e=t.anchor;if(e){var i,t=this.relatedView,n=this.type,r=t.getEndAnchor(n),o=this.options,t=t.model.prop([n,"anchor"]),s=(e.setAttribute("transform","translate("+r.x+","+r.y+")"),t?o.customAnchorAttributes:o.defaultAnchorAttributes);for(i in s)e.setAttribute(i,s[i])}}},updateArea:function(){var t,e,i,n,r,o,s,a=this.childNodes;!a||(a=a.area)&&(i=this.relatedView,n=this.type,e=(t=i.getEndView(n)).model,i=i.getEndMagnet(n),n=this.options.areaPadding,isFinite(n)||(n=0),t.isNodeConnection(i)?(o=0,s=(r=t.getBBox()).center()):(r=t.getNodeUnrotatedBBox(i),o=e.angle(),s=r.center(),o&&s.rotate(e.getBBox().center(),-o)),r.inflate(n),a.setAttribute("x",-r.width/2),a.setAttribute("y",-r.height/2),a.setAttribute("width",r.width),a.setAttribute("height",r.height),a.setAttribute("transform","translate("+s.x+","+s.y+") rotate("+o+")"))},toggleArea:function(t){this.childNodes.area.style.display=t?"":"none"},onPointerDown:function(t){this.guard(t)||(t.stopPropagation(),t.preventDefault(),this.paper.undelegateEvents(),this.delegateDocumentEvents(),this.focus(),this.toggleArea(this.options.restrictArea),this.relatedView.model.startBatch("anchor-move",{ui:!0,tool:this.cid}))},resetAnchor:function(t){var e=this.type,i=this.relatedView.model;t?i.prop([e,"anchor"],t,{rewrite:!0,ui:!0,tool:this.cid}):i.removeProp([e,"anchor"],{ui:!0,tool:this.cid})},onPointerMove:function(t){var e,i,n,r=this.relatedView,o=this.type,s=r.getEndView(o),a=s.model,l=r.getEndMagnet(o),t=I(t),t=this.paper.clientToLocalPoint(t.clientX,t.clientY),h=this.options.snap,h=("function"==typeof h&&(t=h.call(r,t,s,l,o,r,this),t=new z(t)),this.options.restrictArea&&(s.isNodeConnection(l)?(h=s.getClosestPoint(t))&&(t=h):(h=s.getNodeUnrotatedBBox(l),e=a.angle(),a=a.getBBox().center(),i=t.clone().rotate(a,e),h.containsPoint(i)||(t=h.pointNearestToPoint(i).rotate(a,-e)))),this.options.anchor);"function"==typeof h&&(n=h.call(r,t,s,l,o,r)),this.resetAnchor(n),this.update()},onPointerUp:function(t){this.paper.delegateEvents(),this.undelegateDocumentEvents(),this.blur(),this.toggleArea(!1);var e=this.relatedView;this.options.redundancyRemoval&&e.removeRedundantLinearVertices({ui:!0,tool:this.cid}),e.model.stopBatch("anchor-move",{ui:!0,tool:this.cid})},onPointerDblClick:function(){var t=this.options.resetAnchor;!1!==t&&(this.resetAnchor(di(t=!0===t?null:t)),this.update())}}),Gn={Vertices:Gn,Segments:zn,SourceArrowhead:vo,TargetArrowhead:yo,SourceAnchor:Io.extend({name:"source-anchor",type:"source"}),TargetAnchor:Io.extend({name:"target-anchor",type:"target"}),Button:bo,Remove:wo,Connect:Ao,Boundary:Co},vo={Button:bo,Remove:wo,Connect:Ao,Boundary:Co,Control:po.extend({tagName:"g",children:[{tagName:"circle",selector:"handle",attributes:{cursor:"pointer","stroke-width":2,stroke:"#FFFFFF",fill:"#33334F",r:6}},{tagName:"rect",selector:"extras",attributes:{"pointer-events":"none",fill:"none",stroke:"#33334F","stroke-dasharray":"2,4",rx:5,ry:5}}],events:{mousedown:"onPointerDown",touchstart:"onPointerDown",dblclick:"onPointerDblClick",dbltap:"onPointerDblClick"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},options:{handleAttributes:null,selector:"root",padding:6},getPosition:function(){},setPosition:function(){},resetPosition:function(){},onRender:function(){this.renderChildren(),this.toggleExtras(!1),this.update()},update:function(){var t=this.childNodes,e=t.handle,t=t.extras;if(e)return this.updateHandle(e),t&&this.updateExtras(t),this;throw new Error("Control: markup selector `handle` is required")},updateHandle:function(t){var e=this.relatedView,i=this.options,n=e.model,e=this.getPosition(e,this),n=n.getAbsolutePointFromRelative(e),r=(t.setAttribute("transform","translate("+n.x+","+n.y+")"),i.handleAttributes);if(r)for(var o in r)t.setAttribute(o,r[o])},updateExtras:function(t){var e=this.relatedView,i=this.options,n=this.options.selector;if(n){n=e.findBySelector(n)[0];if(!n)throw new Error("Control: invalid selector.");var i=i.padding,n=(isFinite(i)||(i=0),e.getNodeUnrotatedBBox(n)),e=e.model,r=e.angle(),o=n.center();r&&o.rotate(e.getBBox().center(),-r),n.inflate(i),t.setAttribute("x",-n.width/2),t.setAttribute("y",-n.height/2),t.setAttribute("width",n.width),t.setAttribute("height",n.height),t.setAttribute("transform","translate("+o.x+","+o.y+") rotate("+r+")")}else this.toggleExtras(!1)},toggleExtras:function(t){var e=this.childNodes.extras;e&&(e.style.display=t?"":"none")},onPointerDown:function(t){var e=this.relatedView,i=this.paper;this.guard(t)||(t.stopPropagation(),t.preventDefault(),i.undelegateEvents(),this.delegateDocumentEvents(),this.focus(),this.toggleExtras(!0),e.model.startBatch("control-move",{ui:!0,tool:this.cid}))},onPointerMove:function(t){var e=this.relatedView,i=this.paper,n=e.model,t=I(t),r=t.clientX,t=t.clientY,i=i.clientToLocalPoint(r,t),r=n.getRelativePointFromAbsolute(i);this.setPosition(e,r,this),this.update()},onPointerUp:function(t){var e=this.relatedView;this.paper.delegateEvents(),this.undelegateDocumentEvents(),this.blur(),this.toggleExtras(!1),e.model.stopBatch("control-move",{ui:!0,tool:this.cid})},onPointerDblClick:function(){var t=this.relatedView;this.resetPosition(t,this),this.update()}})},yo=B,Io=r,xo=g.prototype,bo=Io.define("standard.Record",{size:{width:100},padding:0,scrollTop:null,items:[],itemHeight:20,itemOffset:20,itemMinLabelWidth:10,itemButtonSize:10,itemIcon:{width:16,height:16,padding:2},itemOverflow:!1,itemAboveViewSelector:"root",itemBelowViewSelector:"root",attrs:{wrapper:{scrollable:!0},bodiesGroups:{fill:"transparent",stroke:"none"},labelsGroups:{fill:"#333333"},buttonsGroups:{fill:"transparent",stroke:"#333333",strokeWidth:1},forksGroups:{stroke:"#333333"},groups:{groupPosition:!0},itemBodies:{groupWidth:!0,itemHighlight:{fill:"#eeeeee"}},itemLabels:{fontSize:16,textVerticalAnchor:"middle",itemText:{textWrap:!0,ellipsis:!0},itemHighlight:{fill:"red"}}}},{markup:[],metrics:null,markupAttributes:["items","itemHeight","itemOffset","itemIcon","itemMinLabelWidth","itemButtonSize","itemOverflow","padding"],initialize:function(){r.prototype.initialize.apply(this,arguments),this.on("change",this.onChange,this),this.buildMarkup()},anyHasChanged:function(t){return!!Array.isArray(t)&&t.some(function(t){return this.hasChanged(t)},this)},onChange:function(t,e){e.record!==this.id&&this.hasChanged("markup")&&So("Markup can not be modified."),this.anyHasChanged(this.markupAttributes)&&this.buildMarkup(e)},getPadding:function(){return ei(this.attributes.padding)},buildMarkup:function(t){var e=this.metrics={},i=e.items={},n=this.attributes,r=n.itemHeight,o=n.itemOffset,s=!!n.itemOverflow,a=n.items,l=(a=Array.isArray(a)?a:[]).length,h=0,c=di(this.markup),u=(Array.isArray(c)||So("Expects Prototype JSON Markup."),this.getPadding()),d=0,g=[];c.push({tagName:"g",selector:"wrapper",children:g});for(var p=0;p<l;p++){for(var f=[],m=[],v=[],y=[],b=[],w=Array.from(a[p]),A=this.createQueue(w,0,[],null),C=0,I=0;0<A.length;){var x=A.pop(),S=x.path,P=x.level,M=x.item,x=x.parent,k=(0===P&&S.splice(1,0,p),M.id),N=-1!==P,T=M.height||r,L=M.icon,E=M.items,D=!!M.highlighted,B=!!M.collapsed,G=Array.isArray(E)&&0<E.length,x=(k||So("Item id required."),i.hasOwnProperty(k)&&So("Duplicated item id."),i[k]={path:S,visible:N,parent:x,label:M.label,height:T,group:p,hasSubItems:G,highlighted:D,collapsed:B});G&&(x.children=E.map(function(t){return t.id}),Array.prototype.push.apply(A,this.createQueue(E,B||!N?-1:P+1,S,k))),N&&(x.x=(D=o*P)+o,x.y=C,x.cx=D+o/2,x.cy=C+T/2,x.span=M.span||1,k&&(E=this.getItemBodyMarkup(M,D,C,p,s&&0===p?u.left:0),f.push(E),S=this.getItemLabelMarkup(M,D,C,p),m.push(S),G&&(v.push(this.getButtonMarkup(M,D,C,p)),B||b.push(k)),L&&(y.push(this.getIconMarkup(M,D,C,p)),x.x+=n.itemIcon.width+n.itemIcon.padding)),I=Math.max(I,x.x+n.itemMinLabelWidth),C+=T)}d=Math.max(I,d),h=Math.max(h,C),w=[];g.push({tagName:"g",selector:this.getSelector("group",p),groupSelector:"groups",attributes:{"record-group":p},children:w}),w.push({tagName:"g",selector:this.getSelector("bodiesGroup",p),groupSelector:"bodiesGroups",children:f},{tagName:"g",selector:this.getSelector("labelsGroup",p),groupSelector:"labelsGroups",children:m}),0<b.length&&w.push({tagName:"g",selector:this.getSelector("forksGroup",p),groupSelector:"forksGroups",children:b.map(this.getForkMarkup,this)}),0<v.length&&w.push({tagName:"g",selector:this.getSelector("buttonsGroup",p),groupSelector:"buttonsGroups",children:v}),0<y.length&&w.push({tagName:"g",selector:this.getSelector("iconsGroup",p),groupSelector:"iconsGroups",children:y})}e.padding=u,e.groupsCount=l,e.overflow=s,e.minHeight=h+u.top+u.bottom,e.minWidth=d*l+u.left+u.right;e=R({record:this.id,dry:!0},t);this.set("markup",c,e),this.autoresize(e)},autoresize:function(t){var e=this.getMinimalSize(),i=this.attributes.size,n=i.height,i=i.width,n=null===this.getScrollTop()?Math.max(n,e.height):n,i=Math.max(i,e.width);this.resize(i,n,t)},getMinimalSize:function(){var t=this.metrics;return{width:t.minWidth,height:t.minHeight}},removeInvalidLinks:function(e){var t=this.graph;return t?t.getConnectedLinks(this).filter(this.isLinkInvalid,this).map(function(t){return t.remove(e)}):[]},isLinkInvalid:function(t){var e=this.id,i=this.metrics.items,n=t.source();if(n.id===e&&n.hasOwnProperty("port")&&!i[n.port]&&!this.hasPort(n.port))return!0;n=t.target();return!(n.id!==e||!n.hasOwnProperty("port")||i[n.port]||this.hasPort(n.port))},createQueue:function(i,n,r,o){var s=i.length;return Array.from({length:s},function(t,e){e=s-e-1;return{path:r.concat(["items",e]),item:i[e],level:n,parent:o}})},getGroupSelector:function(t){for(var e=Array.prototype.slice.call(arguments,1),i=[t],n=0,r=e.length;n<r;n++){var o=e[n];if(null!=o)for(var s=0,a=(o=Array.isArray(o)?o:[o]).length;s<a;s++)i.push(this.getSelector(t,o[s]))}return i},getItemLabelMarkup:function(t,e,i,n){var r=this.attributes,o=r.itemOffset,s=t.height||r.itemHeight,a=t.id,e=e+o;return t.icon&&(e+=r.itemIcon.width+2*r.itemIcon.padding),{tagName:"text",className:"record-item-label",selector:this.getSelector("itemLabel",a),groupSelector:this.getGroupSelector("itemLabels",n,t.group),attributes:{x:e,y:i+s/2,"item-id":a}}},getItemBodyMarkup:function(t,e,i,n,r){var o=0,r=(r&&(o-=r),{x:o,y:i,height:t.height||this.attributes.itemHeight,"item-id":t.id}),o=t.span;return o&&(r["item-span"]=o),{tagName:"rect",selector:this.getSelector("itemBody",t.id),groupSelector:this.getGroupSelector("itemBodies",n,t.group),className:"record-item-body",attributes:r}},getButtonMarkup:function(t,e,i){var n=this.attributes,r=n.itemButtonSize,o=n.itemOffset,n=t.height||n.itemHeight;return{tagName:"path",className:"record-item-button",attributes:{d:this.getButtonPathData(e+o/2,i+n/2,r/2,t.collapsed),"item-id":t.id,cursor:"pointer","shape-rendering":"geometricprecision"}}},getIconMarkup:function(t,e,i){var n=this.attributes,r=n.itemOffset,o=n.itemIcon,n=t.height||n.itemHeight;return{tagName:"image",className:"record-item-icon",attributes:{x:e+r+o.padding,y:i+(n-o.height)/2,width:o.width,height:o.height,"xlink:href":t.icon}}},getForkMarkup:function(t){return{tagName:"path",attributes:{d:this.getForkPathData(t),fill:"none"}}},getButtonPathData:function(t,e,i,n){var r=["M",t-i,e-i,t+i,e-i,t+i,e+i,t-i,e+i,"Z","M",t-i/2,e,t+i/2,e];return n&&Array.prototype.push.apply(r,["M",t,e-i/2,t,e+i/2]),r.join(" ")},getForkPathData:function(t){var e=this.metrics.items;if(!e)return null;var i=e[t];if(!i)return null;var n=i.children;if(!n||0===n.length)return null;for(var r=this.attributes.itemButtonSize,o=[],s=0,a=n.length;s<a;s++){var l,h=(l=e[n[s]]).cx+(l.hasSubItems?-1:1)*r/2;o.push("M",i.cx,l.cy,h,l.cy)}return o.push("M",i.cx,i.cy+r/2,i.cx,l.cy),o.join(" ")},item:function(t,e,i){t=this.getItemPathArray(t);return t?void 0===e?this.prop(t):this.prop(t,e,i):null},toggleItemCollapse:function(t,e){t=this.getItemPathArray(t);if(!t)return this;t.push("collapsed");var i=!!this.prop(t);return this.prop(t,!i,e),this},toggleItemHighlight:function(t,e){t=this.getItemPathArray(t);if(!t)return this;t.push("highlighted");var i=!!this.prop(t);return this.prop(t,!i,e),this},isItemVisible:function(t){return this.getItemCacheAttribute(t,"visible")},isItemCollapsed:function(t){return this.getItemCacheAttribute(t,"collapsed")},isItemHighlighted:function(t){return this.getItemCacheAttribute(t,"highlighted")},getItemParentId:function(t){return this.getItemCacheAttribute(t,"parent")},getItemGroupIndex:function(t){return this.getItemCacheAttribute(t,"group")},getItemPathArray:function(t){t=this.getItemCacheAttribute(t,"path");return t?t.slice():null},getItemSide:function(t){var e=this.getItemGroupIndex(t);if(null===e)return null;var i=this.metrics,n=i.groupsCount;if(1<n){if(0===e)return"left";if(e+i.items[t].span-1==n-1)return"right"}return"middle"},getItemCacheAttribute:function(t,e){if(!e)return null;t=this.getItemCache(t);return t?t[e]:null},getItemCache:function(t){var e=this.metrics.items;if(!e)return null;e=e[t];return e||null},getItemBBox:function(t){t=this.getItemCache(t);if(!t)return null;var e=t.x,i=t.y,n=t.width,t=t.height;return new tt(e,i,n,t)},getSelector:function(t,e){return t+"_"+e},removeItem:function(t,e){t=this.getItemPathArray(t);if(!t)return this;var i=t.pop(),n=this.prop(t).slice();return 1<n.length?(n.splice(i,1),this.prop(t,n,R({rewrite:!0},e))):2<t.length?this.removeProp(t,e):(i=t.pop(),(n=this.get("items").slice()).splice(i,1,[]),this.prop(t,n,R({rewrite:!0},e))),this},addNextSibling:function(t,e,i){var n=this.getItemPathArray(t);if(!n)return this;t=this.getItemParentId(t)||this.getItemGroupIndex(t),n=n[n.length-1]+1;return this.addItemAtIndex(t,n,e,i)},addPrevSibling:function(t,e,i){var n=this.getItemPathArray(t);if(!n)return this;t=this.getItemParentId(t)||this.getItemGroupIndex(t),n=n[n.length-1];return this.addItemAtIndex(t,n,e,i)},addItemAtIndex:function(t,e,i,n){if(!i)return this;switch(typeof t){case"number":var r=this.prop("items"),o=["items",Math.min(Math.max(t,0),r.length)];break;case"string":if(!(o=this.getItemPathArray(t)))return this;o.push("items");break;default:So("Requires an item id.")}var s=this.prop(o),s=Array.isArray(s)?s.slice():[],e=Math.min(Math.max(e,0),s.length);return s.splice(e,0,i),this.prop(o,s,R({rewrite:!0},n))},toJSON:function(){var t=r.prototype.toJSON.apply(this,arguments);return delete t.markup,t},getItemViewSign:function(t){this.isItemVisible(t)||So('Item "'+t+'" does not exist or is not visible.');var e=this.attributes,i=this.metrics,t=i.items[t],n=t.y,t=t.height,r=this.getScrollTop();if(null===r)return 0;var e=e.size.height,i=i.padding,o=i.top,i=i.bottom;return n-r<0?-1:e-o-i-(n+t-r)<0?1:0},isItemInView:function(t){return 0===this.getItemViewSign(t)},isEveryItemInView:function(){return null===this.getScrollTop()||this.metrics.minHeight<=this.size().height},clampScrollTop:function(t){var e=this.size().height,i=this.metrics.minHeight;return Number.isFinite(t)?Math.min(Math.max(t,0),Math.max(i-e,0)):null},getScrollTop:function(){return this.clampScrollTop(this.get("scrollTop"))},setScrollTop:function(t,e){var i=this.get("scrollTop"),t=this.clampScrollTop(t);i!==t&&this.set("scrollTop",t,e)}},{attributes:{itemText:{set:function(t,e,i,n){if(!fi(t))return null;var r,o,s,a,l=this.model,h=i.getAttribute("item-id"),h=l.metrics.items[h];h&&(r=h.label,s=l.metrics.padding,l=l.metrics.groupsCount,o=h.x,e=(e.width-s.left-s.right)/l*h.span-o,s=new tt(o,h.y,e,h.height),l=t.textWrap?(a="textWrap",R({text:r},t)):(a="text",r),this.getAttributeDefinition(a).set.call(this,l,s,i,n))}},itemHighlight:{set:function(t,e,i,n){if(!fi(t))return null;var r=this.model,o=i.getAttribute("item-id");switch(r.getItemCacheAttribute(o,"highlighted")){case!0:return t;case null:case!1:return Object.keys(t).reduce(function(t,e){return!(n.hasOwnProperty(e)||n.hasOwnProperty(ki(e)))&&i.getAttribute(e)&&(t[e]=null),t},{})}}},groupWidth:{set:function(t,e,i){var n=this.model.metrics,r=n.padding,o=n.groupsCount,e=(e.width-r.left-r.right)/o,s=Number(i.getAttribute("item-span")||1);return e*=s=isFinite(s)?s:1,n.overflow&&(0===(n=Number(this.findAttribute("record-group",i)))&&(e+=r.left),n+s===o&&(e+=r.right)),{width:e}}},groupPosition:{position:function(t,e,i){var i=Number(i.getAttribute("record-group")),n=this.model.metrics,r=n.groupsCount,n=n.padding,e=(e.width-n.left-n.right)/r,r=n.left+i*e,i=n.top;return new z(r,i)}},scrollable:{set:Po(function(t,e){var i,n=this.paper,r=n.svg,n=n.defs,o=this.model,s="scroll-clip-"+this.cid,r=r.getElementById(s),r=(r?i=(r=B(r)).children()[0]:(i=B("rect"),(r=B("clipPath",{id:s},[i])).appendTo(n)),o.metrics),n=r.padding,o=r.overflow,r=n.top,a=n.bottom,l=n.left,n=n.right,h=0,c=e.width;return o||(h+=l,c-=l+n),i.attr({y:t+r,x:h,width:c,height:Math.max(e.height-r-a,0)}),{"clip-path":"url(#"+s+")"}}),position:Po(function(t){return new z(0,-t)})}}}),wo=bo.define("standard.BorderedRecord",{padding:0,attrs:{body:{refWidth:"100%",refHeight:"100%",stroke:"#000000",fill:"#FFFFFF"}}},{markup:[{tagName:"rect",selector:"body"}]}),Ao=bo.define("standard.HeaderedRecord",{padding:{top:30,left:0,right:0,bottom:0},itemAboveViewSelector:"header",itemBelowViewSelector:"header",attrs:{body:{refWidth:"100%",refHeight:"100%",stroke:"#000000",fill:"#FFFFFF"},header:{refWidth:"100%",height:30,stroke:"#000000",fill:"transparent"},headerLabel:{refX:"50%",refY:15,textAnchor:"middle",textVerticalAnchor:"middle",fontSize:20,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"rect",selector:"header"},{tagName:"text",selector:"headerLabel"}]}),Io=bo.prototype.markupAttributes.reduce(function(t,e){return t[e]=["UPDATE"],t},{scrollTop:["UPDATE","TOOLS"]}),Io=g.extend({events:{"mousedown .record-item-button":"onItemButtonClick","touchstart .record-item-button":"onItemButtonClick"},presentationAttributes:g.addPresentationAttributes(Io),getLinkEnd:function(t){for(var e=[],i=arguments.length-1;0<i--;)e[i]=arguments[i+1];var n={id:this.model.id,port:this.findAttribute("item-id",t)||this.findAttribute("port",t)};return this.customizeLinkEnd.apply(this,[n,t].concat(e))},getMagnetFromLinkEnd:function(t){for(var e,i=t.port,n=this.model;i&&!n.isItemVisible(i);)i=n.getItemParentId(i);if(!i)return xo.getMagnetFromLinkEnd.apply(this,arguments);switch(n.getItemViewSign(i)){case-1:e=String(n.get("itemAboveViewSelector"));break;case 1:e=String(n.get("itemBelowViewSelector"));break;default:e=n.getSelector("itemBody",i)}return this.findBySelector(e,this.el,this.selectors)[0]},onItemButtonClick:function(t){2!==t.button&&(t.stopPropagation(),t.preventDefault(),t=t.currentTarget.getAttribute("item-id"),this.model.toggleItemCollapse(t,{ui:!0}))}});function So(t){throw new Error("shapes.standard.Record: "+t)}function Po(n){return function(t){for(var e=[],i=arguments.length-1;0<i--;)e[i]=arguments[i+1];if(t)return t=this.model.getScrollTop(),null!==t?n.call.apply(n,[this,t].concat(e)):void 0}}var bo={Record:bo,BorderedRecord:wo,HeaderedRecord:Ao,RecordView:Io,BorderedRecordView:Io,HeaderedRecordView:Io},wo=h.extend({markup:['<clipPath class="clip"><rect/></clipPath>','<g class="rotatable">','<g class="scalable"></g>','<g class="background"><rect/><text/></g>','<g class="axis">','<g class="y-axis"><path/><g class="ticks"></g></g>','<g class="x-axis"><path/><g class="ticks"></g></g>','<g class="markings"></g>',"</g>",'<g class="data"><g class="series"></g></g>','<g class="foreground">','<rect/><text class="caption"/><text class="subcaption"/>','<g class="legend"><g class="legend-items"></g></g>','<line class="guideline x-guideline" /><line class="guideline y-guideline" />',"</g>","</g>"].join(""),tickMarkup:'<g class="tick"><line/><text/></g>',pointMarkup:'<g class="point"><circle/><text/></g>',barMarkup:'<path class="bar"/>',markingMarkup:'<g class="marking"><rect/><text/></g>',serieMarkup:'<g><clipPath class="serie-clip"><rect/></clipPath><path/><g class="bars"></g><g class="points"></g></g>',legendItemMarkup:'<g class="legend-item"><circle/><text/></g>',defaults:e({type:"chart.Plot",attrs:{".data path":{fill:"none",stroke:"black"},".data .bars rect":{fill:"none",stroke:"black"},".background rect":{fill:"white",stroke:"#e5e5e5",opacity:1},".background text":{fill:"black",text:"No data available.",ref:".","ref-x":.5,"ref-y":.5,"text-anchor":"middle","y-alignment":"middle",display:"none"},".foreground > rect":{fill:"white",stroke:"#e5e5e5",opacity:0,"pointer-events":"none"},".foreground .caption":{fill:"black",text:"",ref:".foreground > rect","ref-x":.5,"ref-y":10,"text-anchor":"middle","y-alignment":"middle","font-size":14},".foreground .subcaption":{fill:"black",text:"",ref:".foreground > rect","ref-x":.5,"ref-y":23,"text-anchor":"middle","y-alignment":"middle","font-size":10},".point":{display:"inline-block"},".point circle":{r:2,stroke:"black",fill:"black",opacity:.3},".point text":{fill:"black","font-size":8,"text-anchor":"middle",display:"none"},".axis path":{fill:"none",stroke:"black"},".axis .tick":{fill:"none",stroke:"black"},".y-axis .tick line":{fill:"none",stroke:"black",x2:2,y2:0,opacity:1},".x-axis .tick line":{fill:"none",stroke:"black",x2:0,y2:-3,opacity:1},".y-axis .tick text":{fill:"black",stroke:"none","font-size":10,"text-anchor":"end"},".x-axis .tick text":{fill:"black",stroke:"none","font-size":10,"text-anchor":"middle"},".y-axis .tick text > tspan":{dy:"-.5em",x:-5},".x-axis .tick text > tspan":{dy:".5em",x:0},".axis .markings":{fill:"black",stroke:"none","fill-opacity":1},".axis .markings text":{fill:"black","text-anchor":"end","font-size":10,dy:-5,dx:-5},".guideline":{"pointer-events":"none",display:"none"},".x-guideline":{stroke:"black",visibility:"hidden"},".y-guideline":{stroke:"black",visibility:"hidden"},".legend":{"ref-x":10,"ref-y":10},".legend-item text":{fill:"black",transform:"translate(14, 0)","font-size":11},".legend-item circle":{r:5,transform:"translate(5,5)"},".legend-item":{cursor:"pointer"},".legend-item.disabled circle":{fill:"gray"},".legend-item.disabled text":{opacity:.5}}},h.prototype.defaults),legendPosition:function(t,e){e=e||{},this.trigger("batch:start"),[".legend/ref-x",".legend/ref-y",".legend/ref-dx",".legend/ref-dy",".legend/x-alignment",".legend/y-alignment"].forEach(function(t){this.removeAttr(t,{silent:!0})},this);e=e.padding||10,e={n:{".legend":{"ref-x":.5,"x-alignment":-.5,"ref-y":e}},ne:{".legend":{"ref-dx":-e,"x-alignment":-.999,"ref-y":e}},e:{".legend":{"ref-dx":-e,"x-alignment":-.999,"ref-y":.5,"y-alignment":-.5}},se:{".legend":{"ref-dx":-e,"ref-dy":-e,"x-alignment":-.999,"y-alignment":-.999}},s:{".legend":{"ref-x":.5,"ref-dy":-e,"x-alignment":-.5,"y-alignment":-.999}},sw:{".legend":{"ref-x":e,"ref-dy":-e,"y-alignment":-.999}},w:{".legend":{"ref-x":e,"ref-y":.5,"y-alignment":-.5}},nw:{".legend":{"ref-x":e,"ref-y":e}},nnw:{".legend":{"ref-x":e,"ref-y":-e,"y-alignment":-.999}},nn:{".legend":{"ref-x":.5,"ref-y":-e,"x-alignment":-.5,"y-alignment":-.999}},nne:{".legend":{"ref-dx":-e,"ref-y":-e,"x-alignment":-.999,"y-alignment":-.999}},nnee:{".legend":{"ref-dx":e,"ref-y":-e,"y-alignment":-.999}},nee:{".legend":{"ref-y":e,"ref-dx":e}},ee:{".legend":{"ref-dx":e,"ref-y":.5,"y-alignment":-.5}},see:{".legend":{"ref-dx":e,"ref-dy":-e,"y-alignment":-.999}},ssee:{".legend":{"ref-dx":e,"ref-dy":e}},sse:{".legend":{"ref-dx":-e,"ref-dy":e,"x-alignment":-.999}},ss:{".legend":{"ref-x":.5,"ref-dy":e,"x-alignment":-.5}},ssw:{".legend":{"ref-x":e,"ref-dy":e}},ssww:{".legend":{"ref-x":-e,"ref-dy":e,"x-alignment":-.999}},sww:{".legend":{"ref-x":-e,"ref-dy":-e,"x-alignment":-.999,"y-alignment":-.999}},ww:{".legend":{"ref-x":-e,"ref-y":.5,"x-alignment":-.999,"y-alignment":-.5}},nww:{".legend":{"ref-x":-e,"ref-y":e,"x-alignment":-.999}},nnww:{".legend":{"ref-x":-e,"ref-y":-e,"x-alignment":-.999,"y-alignment":-.999}}};e[t]&&this.attr(e[t]),this.trigger("batch:stop")},addPoint:function(t,e,i){i=i||{};var n=this.get("series"),r=et(n).findIndex(function(t){return t.name===e});if(-1===r)throw new Error("Serie "+e+" was not found.");var o=di(n[r]);o.data.push(t),Number.isFinite(i.maxLen)&&o.data.length>i.maxLen&&o.data.shift(),(n=n.slice())[r]=o,this.set("series",n,i)},lastPoint:function(e){var t=et(this.get("series")).find(function(t){return t&&t.name===e}).data;return t[t.length-1]},firstPoint:function(e){return et(this.get("series")).find(function(t){return t&&t.name===e}).data[0]}}),Ao=g.extend({events:{mousemove:"onMouseMove",mouseout:"onMouseOut"},presentationAttributes:g.addPresentationAttributes({series:["UPDATE"],interpolate:["UPDATE"],padding:["UPDATE"],canvas:["UPDATE"],markings:["UPDATE"],axis:["UPDATE"]}),initialize:function(){g.prototype.initialize.apply(this,arguments),this.on("cell:pointerdown",this.onPointerDown,this),this._disabledSeries=[]},renderMarkup:function(){g.prototype.renderMarkup.apply(this,arguments),this.elDataClipPath=this.$(".clip")[0],this.elDataClipPathRect=this.elDataClipPath.firstChild,this.elBackgroundRect=this.$(".background rect")[0],this.elBackgroundText=this.$(".background text")[0],this.elForeground=this.$(".foreground")[0],this.elForegroundRect=this.$(".foreground rect")[0],this.elDataSeries=this.$(".data .series")[0],this.elYAxisPath=this.$(".y-axis path")[0],this.elYAxisTicks=this.$(".y-axis .ticks")[0],this.elXAxisPath=this.$(".x-axis path")[0],this.elXAxisTicks=this.$(".x-axis .ticks")[0],this.elMarkings=this.$(".axis .markings")[0],this.elXGuideline=this.$(".x-guideline")[0],this.elYGuideline=this.$(".y-guideline")[0],this.elLegend=this.$(".legend")[0],this.elLegendItems=this.$(".legend-items")[0],this.elTick=B(this.model.tickMarkup),this.elMarking=B(this.model.markingMarkup),this.elLegendItem=B(this.model.legendItemMarkup),this.elPoint=B(this.model.pointMarkup),this.elBar=B(this.model.barMarkup),this.elSerie=B(this.model.serieMarkup),this.elDataClipPath.id="clip_"+this.cid,B(this.$(".data")[0]).attr("clip-path","url(#"+this.elDataClipPath.id+")"),B(this.elMarkings).attr("clip-path","url(#"+this.elDataClipPath.id+")")},update:function(){var t=this.filterSeries(),e=(this.calculateStats(t),this.model.get("size")),i=e.width,e=e.height,n=(this.canvas=R({x:0,y:0,width:i,height:e},this.model.get("canvas")),{top:0,right:0,bottom:0,left:0}),r=this.model.get("padding"),r=x(r)?R({},n,r):void 0!==r?{top:r,right:2*r,bottom:2*r,left:r}:n,n=(this.canvas=Nt(this.canvas).moveAndExpand(Nt(r.left,r.top,-r.right,-r.bottom)),{x:0,y:0,width:i,height:e});B(this.elDataClipPathRect).attr(n),B(this.elBackgroundRect).attr(n),B(this.elForegroundRect).attr(n),this.updateAxis(),this.updateMarkings(),this.isEmpty()?w(this.elBackgroundText).show():w(this.elBackgroundText).hide(),this.updateSeries(t),this.updateLegend(),g.prototype.update.apply(this,arguments)},calculateStats:function(t){t=t||this.model.get("series");var r=[],o=[],s={},a={},l={},t=(et(t).forEach(function(e,t){var i,n=l[e.name||t]||(l[e.name||t]={});n.decreasingX=!0,n.decreasingY=!0,n.nonDecreasingX=!0,n.nonDecreasingY=!0,k(e.data,function(t){n.minX=void 0===n.minX?t.x:Math.min(n.minX,t.x),n.maxX=void 0===n.maxX?t.x:Math.max(n.maxX,t.x),n.minY=void 0===n.minY?t.y:Math.min(n.minY,t.y),n.maxY=void 0===n.maxY?t.y:Math.max(n.maxY,t.y),i&&(n.decreasingX=n.decreasingX&&t.x<i.x,n.decreasingY=n.decreasingY&&t.y<i.y,n.nonDecreasingX=n.nonDecreasingX&&t.x>=i.x,n.nonDecreasingY=n.nonDecreasingY&&t.y>=i.y),r.includes(t.x)||r.push(t.x),o.includes(t.y)||o.push(t.y),(s[t.x]||(s[t.x]=[])).push({serie:e,x:t.x,y:t.y}),(a[t.y]||(a[t.y]=[])).push({serie:e,x:t.x,y:t.y}),i=t})}),this.model.get("axis")||{}),e=t["x-axis"]||{},t=t["y-axis"]||{};this.stats={minX:void 0===e.min?r.reduce(function(t,e){return e<t?e:t},1/0):e.min,maxX:void 0===e.max?r.reduce(function(t,e){return t<e?e:t},-1/0):e.max,minY:void 0===t.min?o.reduce(function(t,e){return e<t?e:t},1/0):t.min,maxY:void 0===t.max?o.reduce(function(t,e){return t<e?e:t},-1/0):t.max,bySerie:l,xValues:r,yValues:o,xMap:s,yMap:a}},isEmpty:function(){return!this.stats.xValues.length},updateSeries:function(t){var l,h,c,u,d;t=t||this.model.get("series"),this.elDataSeries.textContent="",this.isEmpty()||(l=[this.stats.minX,this.stats.maxX],h=[this.stats.minY,this.stats.maxY],c=[this.canvas.x,this.canvas.x+this.canvas.width],u=[this.canvas.y+this.canvas.height,this.canvas.y],d=this.model.get("attrs"),et(t).forEach(function(n,t){var e=n.data,r=[],i=this.elSerie.clone().attr("class",n.name||"serie-"+t),e=(B(this.elDataSeries).append(i),k(e,function(t){var e=J.linear(l,c,t.x),i=J.linear(h,u,t.y);r.push({x:e,y:i}),d[".point"]&&"none"!==d[".point"].display&&this.renderPoint(t,n),n.bars&&this.renderBar(t,n)}.bind(this)),i.findOne(".serie-clip")),o=this.model.get("size"),s=this.stats.bySerie[n.name||t],a=J.linear(l,c,s.minX),s=J.linear(l,c,s.maxX);e.findOne("rect").attr(Nt(a,0,s-a,o.height)),n.bars||i.findOne("path").attr({d:this.seriePathData(r,n,t),"clip-path":"url(#"+e.node.id+")"})},this))},seriePathClipData:function(t,e){var i=this.model.get("size"),t=t[0];return["M",t.x,t.y,"V",i.height+10].join(" ")},renderBar:function(t,e){var i=[this.stats.minX,this.stats.maxX],n=[this.stats.minY,this.stats.maxY],r=[this.canvas.x,this.canvas.x+this.canvas.width],o=[this.canvas.y+this.canvas.height,this.canvas.y],i=J.linear(i,r,t.x),r=J.linear(n,o,t.y),s=e.bars.barWidth||.8,s=1<s?s:this.canvas.width/(this.stats.maxX-this.stats.minX)*s,o=J.linear(n,o,0)-r,n=(n[0]===n[1]&&(r=this.canvas.y+this.canvas.height,o=0),t["top-rx"]||e.bars["top-rx"]),a=t["top-ry"]||e.bars["top-ry"],l=t["bottom-rx"]||e.bars["bottom-rx"],h=t["bottom-ry"]||e.bars["bottom-ry"],i={left:i,middle:i-s/2,right:i-s}[e.bars.align||"middle"],c=this.elBar.clone(),t=(c.attr({"data-serie":e.name,"data-x":t.x,"data-y":t.y,d:B.rectToPath({x:i,y:r,width:s,height:o,"top-rx":n,"top-ry":a,"bottom-rx":l,"bottom-ry":h})}),e.name||"serie-"+this.model.get("series").indexOf(e));return B(this.elDataSeries).findOne("."+t+" .bars").append(c),c.node},renderPoint:function(t,e){var i=[this.stats.minX,this.stats.maxX],n=[this.stats.minY,this.stats.maxY],r=[this.canvas.x,this.canvas.x+this.canvas.width],o=[this.canvas.y+this.canvas.height,this.canvas.y],i=J.linear(i,r,t.x),r=J.linear(n,o,t.y),o=(n[0]===n[1]&&(r=this.canvas.y+this.canvas.height),this.elPoint.clone()),n=(o.attr({"data-serie":e.name,"data-x":t.x,"data-y":t.y}),o.findOne("circle").attr({cx:i,cy:r}),o.findOne("text").attr({x:i,dy:r}).text(this.pointLabel(t,e)),e.name||"serie-"+this.model.get("series").indexOf(e));return B(this.elDataSeries).findOne("."+n+" .points").append(o),o.node},seriePathData:function(t,e,i){var n,r,o=t.length,s=[this.stats.minY,this.stats.maxY];if(s[0]===s[1])for(n=0;n<o;n++)t[n].y=this.canvas.y+this.canvas.height;switch(void 0===e.interpolate?this.model.get("interpolate"):e.interpolate){case"bezier":r=new O(d.throughPoints(t));break;case"step":for((r=new O).appendSegment(O.createSegment("M",t[0].x,t[0].y)),n=1;n<o;n++)r.appendSegment(O.createSegment("L",(t[n-1].x+t[n].x)/2,t[n-1].y)),r.appendSegment(O.createSegment("L",(t[n-1].x+t[n].x)/2,t[n].y));r.appendSegment(O.createSegment("L",t[o-1].x,t[o-1].y));break;case"stepBefore":for((r=new O).appendSegment(O.createSegment("M",t[0].x,t[0].y)),n=1;n<o;n++)r.appendSegment(O.createSegment("L",t[n-1].x,t[n].y)),r.appendSegment(O.createSegment("L",t[n].x,t[n].y));break;case"stepAfter":for((r=new O).appendSegment(O.createSegment("M",t[0].x,t[0].y)),n=1;n<o;n++)r.appendSegment(O.createSegment("L",t[n].x,t[n-1].y)),r.appendSegment(O.createSegment("L",t[n].x,t[n].y));break;default:for((r=new O).appendSegment(O.createSegment("M",t[0].x,t[0].y)),n=1;n<o;n++)r.appendSegment(O.createSegment("L",t[n].x,t[n].y))}return this.fixPathForFill(r,t,e,i).serialize()},fixPathForFill:function(t,e,i,n){if(0===e.length)return t;if(i.hideFillBoundaries)return t;if(!this.stats.bySerie[i.name||n].nonDecreasingX)return t;var n=t.getSegment(0),n=(t.replaceSegment(0,O.createSegment("L",n.end.x,n.end.y)),i.fillPadding&&i.fillPadding.left||0),r=i.fillPadding&&i.fillPadding.right||0,o=i.fillPadding&&i.fillPadding.bottom||10,s=this.model.get("size"),a=e[0],e=e[e.length-1];return t.insertSegment(0,O.createSegment("M",e.x+r,s.height+o)),t.insertSegment(1,O.createSegment("L",a.x-n,s.height+o)),t.insertSegment(2,O.createSegment("L",a.x-n,a.y)),i.showRightFillBoundary&&(t.appendSegment(O.createSegment("L",e.x+r,e.y)),t.appendSegment(O.createSegment("Z"))),t},updateAxis:function(){var t,e,i,n=this.model.get("axis"),r=this.model.get("size"),o=r.height,s=r.width;function l(t,e,i,n,r,o,s,a){for(var l=i[1]-i[0],h=t.ticks||11,c=l/(h=0==l?1:h)/a,u=i[0],d=0;d<h;d++)g.call(this,t,e,i,n,r,o,s,u),u+=c}function g(t,e,i,n,r,o,s,a){var l=this.elTick.clone(),r=r.call(this,i,n,a);r>e.width||(o.call(this,l,r,e),o=s.call(this,a,i,n),l.findOne("text").text(this.tickLabel(o,t)))}B(this.elXAxisPath).attr("d",["M",0,o,"L",s,o].join(" ")),B(this.elYAxisPath).attr("d",["M",0,0,"L",0,o].join(" ")),this.elXAxisTicks.textContent="",this.elYAxisTicks.textContent="",this.isEmpty()||(s=[this.stats.minX,this.stats.maxX],o=[this.stats.minY,this.stats.maxY],t=[this.canvas.x,this.canvas.x+this.canvas.width],e=[0,this.canvas.height],i=n&&n["y-axis"]||{},n=n&&n["x-axis"]||{},function(t,e,i,n){function r(t,e,i){t.translate(e,i.height),B(this.elXAxisTicks).append(t)}function o(t,e,i){return J.linear(t,e,i)}function s(t){return t}var a;t.ticks?(a=this.canvas.width/(e.width-2*this.canvas.x),l.call(this,t,e,i,n,o,r,s,a)):(a=this.stats.xValues,function(i,n,r,o,s,a,l,t){t.forEach(function(t,e){e%(i.tickStep||1)==0&&g.call(this,i,n,r,o,s,a,l,t)},this)}.call(this,t,e,i,n,o,r,s,a))}.call(this,n,r,s,t),function(t,e,i,n){var r=this.canvas.height/e.height;l.call(this,t,e,i,n,function(t,e,i){return t[0]===t[1]?this.canvas.y+this.canvas.height:J.linear(t,e,i)},function(t,e){t.translate(0,e),B(this.elYAxisTicks).append(t)},function(t,e,i){t=e[1]-(t-e[0]);return t+=J.linear(i,e,this.canvas.y)-e[0]},r)}.call(this,i,r,o,e))},tickLabel:function(t,e){if(P(e.tickFormat))return e.tickFormat(t);var i=e.tickFormat||".1f";return oi.number(i,t)+(P(e.tickSuffix)?e.tickSuffix(t):e.tickSuffix||"")},pointLabel:function(t,e){if(P(e.pointFormat))return e.pointFormat(t);var i=e.pointFormat||".1f";return oi.number(i,t.y)+(e.pointSuffix||"")},updateMarkings:function(){this.elMarkings.textContent="";var t,c,u,d,g,p,f,e=this.model.get("markings");function m(t,e){return void 0===t?e:t}e&&0!==e.length&&(t=this.model.get("size"),c=t.width,u=t.height,d=[this.stats.minX,this.stats.maxX],g=[this.stats.minY,this.stats.maxY],p=[this.canvas.x,this.canvas.x+this.canvas.width],f=[this.canvas.y,this.canvas.y+this.canvas.height],et(e).forEach(function(t,e){var i=t.start||t.end,n=t.end||t.start,r=Math.min(m(i.x,this.stats.minX),m(n.x,this.stats.minX)),o=Math.max(m(i.x,this.stats.maxX),m(n.x,this.stats.maxX)),s=Math.min(m(i.y,this.stats.minY),m(n.y,this.stats.minY)),a=Math.max(m(i.y,this.stats.maxY),m(n.y,this.stats.maxY)),l=void 0===i.x||void 0===n.x,i=void 0===i.y||void 0===n.y,n=(l&&(p=[0,c]),i&&(f=[0,u]),J.linear(d,p,r)),l=J.linear(d,p,o),i=J.linear(g,f,s),r=J.linear(g,f,a),o=n,h=f[1]-r+f[0],l=l-n,n=r-i;if(g[0]===g[1]&&s===a){if(g[0]!==s)return;h=this.canvas.y+this.canvas.height,n=1}l=Math.max(l,1),n=Math.max(n,1),r=this.elMarking.clone(),r.findOne("rect").attr({x:o,y:h,width:l,height:n}),r.findOne("text").text(t.label||"").attr({x:o+l,y:h}),i=r.attr("class")+" "+(t.name||"marking-"+e);r.attr(R({class:i},t.attrs)),B(this.elMarkings).append(r)},this))},updateLegend:function(){var t=this.model.get("series");this.elLegendItems.textContent="",et(t).forEach(function(t,e){var i;P(t.showLegend)&&!t.showLegend(t,this.stats.bySerie[t.name||e])||!1!==t.showLegend&&(i=this.elLegendItem.clone(),this._disabledSeries.includes(t.name)&&i.addClass("disabled"),i.attr("data-serie",t.name),i.findOne("circle").attr({fill:this.getSerieColor(t.name)}),i.findOne("text").text(t.label||t.name),i.translate(0,e*(t.legendLabelLineHeight||16)),B(this.elLegendItems).append(i))},this)},getSerieColor:function(e){var t=this.model.get("attrs"),i=Object.keys(t).find(function(t){return t.includes(e)});return i?t[i].stroke||t[i].fill:"black"},hideSerie:function(t){this._disabledSeries.includes(t)||this._disabledSeries.push(t);t=this.filterSeries();this.update(t)},showSerie:function(t){this._disabledSeries=wi(this._disabledSeries,t);t=this.filterSeries();this.update(t)},filterSeries:function(t){return t=t||this.model.get("series"),t=et(t).filter(function(t){return!this._disabledSeries.includes(t.name)},this)},onPointerDown:function(t,e,i){t=w(t.target).closest(".legend-item")[0];t&&(B(t).toggleClass("disabled"),B(t).hasClass("disabled")?this.hideSerie(B(t).attr("data-serie")):this.showSerie(B(t).attr("data-serie")))},onMouseMove:function(t){this.showGuidelines(t.clientX,t.clientY,t)},onMouseOut:function(t){this.hideGuidelines(),this.trigger("mouseout",t)},showGuidelines:function(t,e,i){var n,r,o=this.model.get("angle"),s=this.model.getBBox(),o=new z(B(this.paper.layers).toLocalPoint(t,e)).rotate(s.center(),o);Nt(s).containsPoint(o)&&(r=this.model.get("size"),n=o.x-s.x,o=o.y-s.y,B(this.elXGuideline).attr({x1:n,y1:0,x2:n,y2:r.height,visibility:"visible"}),B(this.elYGuideline).attr({x1:0,y1:o,x2:r.width,y2:o,visibility:"visible"}),s=J.linear([this.canvas.x,this.canvas.x+this.canvas.width],[this.stats.minX,this.stats.maxX],n),r=J.linear([this.canvas.y,this.canvas.y+this.canvas.height],[this.stats.minY,this.stats.maxY],o),n={x:s,y:this.stats.minY+this.stats.maxY-r},o={x:t,y:e},r=this.closestPoints(s),this.trigger("mouseover",n,o,r,i))},closestPoints:function(t){var e=hi(this.stats.xValues,t),i=this.stats.xValues[e],e=this.stats.xValues[e-1],t=void 0===e||Math.abs(t-i)<Math.abs(t-e)?i:e;return this.stats.xMap[t]},hideGuidelines:function(){B(this.elXGuideline).attr("visibility","hidden"),B(this.elYGuideline).attr("visibility","hidden")}}),Mo=h.extend({markup:['<g class="rotatable">','<g class="scalable"></g>','<g class="background"><rect/><text/></g>','<g class="data"></g>','<g class="foreground">','<rect/><text class="caption"/><text class="subcaption"/>','<g class="legend"><g class="legend-items"></g></g>',"</g>","</g>"].join(""),sliceMarkup:'<g class="slice"/>',sliceFillMarkup:'<path class="slice-fill"/>',sliceBorderMarkup:'<path class="slice-border"/>',sliceInnerLabelMarkup:'<text class="slice-inner-label"/>',legendSerieMarkup:'<g class="legend-serie"><text/></g>',legendSliceMarkup:'<g class="legend-slice"><circle/><text/></g>',defaults:e({type:"chart.Pie",size:{width:200,height:200},pieHole:0,serieDefaults:{startAngle:0,degree:360,label:null,showLegend:!0,labelLineHeight:6},sliceDefaults:{innerLabel:"{percentage:.0f}%",innerLabelMargin:6,legendLabel:"{label}: {value}",legendLabelLineHeight:6,legendLabelMargin:14,offset:0,onClickEffect:{type:"offset",offset:20},onHoverEffect:null},series:[],attrs:{".background > rect":{opacity:0},".background > text":{fill:"black",text:"No data available.",ref:".background > rect","ref-x":.5,"ref-y":.5,"text-anchor":"middle","y-alignment":"middle",display:"none"},".foreground > rect":{fill:"white",stroke:"#e5e5e5",opacity:0,"pointer-events":"none"},".foreground .caption":{fill:"black",text:"",ref:".foreground > rect","ref-x":2,"ref-y":6,"text-anchor":"start","y-alignment":"middle","font-size":14},".foreground .subcaption":{fill:"black",text:"",ref:".foreground > rect","ref-x":2,"ref-y":18,"text-anchor":"start","y-alignment":"middle","font-size":10},".data":{ref:".background","ref-x":.5,"ref-y":.5},".slice":{cursor:"pointer"},".slice > .slice-fill":{stroke:"#ffffff","stroke-width":1,"fill-opacity":1},".slice.hover > .slice-fill":{"fill-opacity":.8},".slice > .slice-border":{"stroke-width":6,"stroke-opacity":.4,"fill-opacity":1,fill:"none",display:"none"},".slice.hover > .slice-border":{display:"block"},".slice > .slice-inner-label":{"text-anchor":"middle","font-size":"12",stroke:"none","stroke-width":"0",fill:"#ffffff"},".slice > .slice-inner-label > tspan":{dy:"-.5em"},".legend":{"ref-dx":20,"ref-y":5},".legend-serie text":{fill:"grey",transform:"translate(2, 0)","font-size":13},".legend-slice":{cursor:"pointer"},".legend-slice text":{"font-weight":"normal",fill:"black","font-size":11},".legend-slice.hover text":{"font-weight":"bold"},".legend-slice circle":{r:5,transform:"translate(5,5)"}}},h.prototype.defaults),addSlice:function(t,e,i){i=i||{},e=e||0;var n=this.get("series"),r=(void 0===n[e]&&(n[e]={data:[]}),di(n[e]));r.data.push(t),i=1<((n=n.slice())[e]=r).data.length?R(i,{changedSerieIndex:e}):i,this.set("series",n,i)},editSlice:function(t,e,i,n){n=n||{},i=i||0;var r=this.get("series");if(void 0===r[i]||void 0===r[i].data[e])throw new Error("Slice "+e+" on serie "+i+" was not found.");var o=di(r[i]);o.data[e]=R(o.data[e],t),(r=r.slice())[i]=o,this.set("series",r,R(n,{changedSerieIndex:i}))}}),Io=g.extend({events:{"mouseover .slice":"onMouseOverSlice","mouseout .slice":"onMouseOverSlice","mousemove .slice":"onMouseMoveSlice","mouseover .legend-slice":"onEventLegendItem","mouseout .legend-slice":"onEventLegendItem"},presentationAttributes:g.addPresentationAttributes({series:["UPDATE"],serieDefaults:["UPDATE"],sliceDefaults:["UPDATE"],pieHole:["UPDATE"]}),initialize:function(){g.prototype.initialize.apply(this,arguments),this.on("cell:pointerclick",this.onClickSlice,this),this.on("cell:pointerclick",this.onEventLegendItem,this)},renderMarkup:function(){g.prototype.renderMarkup.apply(this,arguments),this.elBackgroundRect=this.$(".background rect")[0],this.elBackgroundText=this.$(".background text")[0],this.elForegroundRect=this.$(".foreground rect")[0],this.elLegendItems=this.$(".legend-items")[0],this.elPie=this.$(".data")[0],this.elSlice=B(this.model.sliceMarkup),this.elSliceFill=B(this.model.sliceFillMarkup),this.elSliceBorder=B(this.model.sliceBorderMarkup),this.elSliceInnerLabel=B(this.model.sliceInnerLabelMarkup),this.elLegendSerie=B(this.model.legendSerieMarkup),this.elLegendSlice=B(this.model.legendSliceMarkup)},update:function(t,e,i){var n=(i=i||{}).changedSerieIndex,i=this.calculateSeries(n),r=(n in i?w(this.elPie).find(".serie-"+n).remove():w(this.elPie).empty(),this.model.get("size"));B(this.elBackgroundRect).attr(r),B(this.elForegroundRect).attr(r),i.length?w(this.elBackgroundText).hide():w(this.elBackgroundText).show(),et(i).forEach(function(t,e){void 0!==n&&n!==e||k(t.data,this.updateSlice.bind(this))},this),this.updateLegend(),g.prototype.update.apply(this,arguments)},calculateSeries:function(s){var t=di(this.model.get("series")),a=this.model.get("serieDefaults"),l=this.model.get("sliceDefaults"),e=this.model.get("size"),e=Math.min(e.width,e.height)/2,i=this.model.get("pieHole"),h=e,c=(e-(i=1<i?i:e*i))/t.length;return this._series=t.map(function(t,i){if(void 0!==s&&s!==i)return t;var n=(t=S(t,a)).startAngle,e=t.data.reduce(function(t,e){return t+e.value},0),r=t.degree/e||0,o=100/e;return t.data=t.data.map(function(t,e){(t=S(t,Si(l,"offset","onClickEffect","onHoverEffect"))).outerRadius=h,t.innerRadius=h-c,i||((t=S(t,Pi(l,"offset","onClickEffect","onHoverEffect"))).isOuter=!0,t.offset=1<t.offset?t.offset:t.offset*t.outerRadius,t.onClickEffect.offset=1<t.onClickEffect.offset?t.onClickEffect.offset:t.onClickEffect.offset*t.outerRadius),t.serieIndex=i,t.sliceIndex=e,t.innerLabelMargin=t.innerLabelMargin<-1||1<t.innerLabelMargin?t.innerLabelMargin:t.innerLabelMargin*t.outerRadius,t.percentage=t.value*o;e=t.value*r;return t.degree={angle:e,start:n,end:e+n},t.rad={angle:K(t.degree.angle,!0),start:K(t.degree.start,!0),end:K(t.degree.end,!0)},t.middleangle=(t.rad.start+t.rad.end)/2,n=t.degree.end,t}),h-=c,t}),this._series},updateLegend:function(){var t=this._series,o=(this.elLegendItems.textContent="",0),i=parseInt(this.model.attr(".legend-serie text/font-size"),10),s=parseInt(this.model.attr(".legend-slice text/font-size"),10);et(t).forEach(function(t,r){var e;t.showLegend&&(t.label&&(e=this.elLegendSerie.clone(),t.name&&e.addClass(t.name),e.attr({"data-serie":r}),e.findOne("text").text(t.label),e.translate(0,o),B(this.elLegendItems).append(e),o+=i+t.labelLineHeight),k(t.data,function(t,e){var i=this.elLegendSlice.clone(),n=this.getSliceFillColor(e,r);t.name&&i.addClass(t.name),i.attr({"data-serie":r,"data-slice":e}),i.findOne("text").text(oi.string(t.legendLabel,t)),i.findOne("text").translate(t.legendLabelMargin),i.translate(0,o),o+=s+t.legendLabelLineHeight,x(n)?this.applyGradient(i.findOne("circle"),"fill",n):i.findOne("circle").attr({fill:n}),B(this.elLegendItems).append(i)}.bind(this)))},this)},applyGradient:function(t,e,i){var t=N(t)?this.findBySelector(t):w(t).toArray(),n=this.paper.defineGradient(i);t.forEach(function(t){B(t).attr(e,"url(#"+n+")")})},updateSlice:function(t){var e=this.elSlice.clone(),i=(B(this.elPie).append(e),this.elSliceFill.clone()),n=this.getSliceFillColor(t.sliceIndex,t.serieIndex),i=(i.attr({fill:n,d:B.createSlicePathData(t.innerRadius,t.outerRadius,t.rad.start,t.rad.end)}),e.append(i),x(n)&&this.applyGradient("#"+i.attr("id"),"fill",n),this.elSliceBorder.clone()),r=parseInt(this.model.attr(".slice > .slice-border/stroke-width"),10),o=A.fromPolar(t.outerRadius+r/2,-t.rad.start,A(0,0)),s=A.fromPolar(t.outerRadius+r/2,-t.rad.end,A(0,0)),o=(i.attr({stroke:n,d:this.drawArc(o,s,t.outerRadius+r/2,t.rad.start,t.rad.end)}),e.append(i),x(n)&&this.applyGradient("#"+i.attr("id"),"stroke",n),this.elSliceInnerLabel.clone()),s=(o.text(oi.string(t.innerLabel,t)),e.append(o),o.bbox()),r=t.outerRadius-s.width/2-t.innerLabelMargin,i=(o.translate(r*Math.cos(-t.middleangle),-r*Math.sin(-t.middleangle)),e.attr({"data-serie":t.serieIndex,"data-slice":t.sliceIndex,"data-value":t.value}),this._series[t.serieIndex].name);return i&&e.addClass(i),t.name&&e.addClass(t.name),e.addClass("serie-"+t.serieIndex+" slice-"+t.sliceIndex),t.isOuter&&(e.addClass("outer"),t.offset&&(e.addClass("clicked"),this.effectOnSlice(e,t,{type:"offset",offset:t.offset}))),e},getSliceFillColor:function(e,i){i=i||0;var t=this.model.get("attrs"),n=Object.keys(t).find(function(t){return-1<t.indexOf(".serie-"+i+".slice-"+e+" > .slice-fill")});return(n?t[n]:this._series[i].data[e]).fill},onMouseMoveSlice:function(t){var e=B(t.currentTarget),i=e.attr("data-serie"),e=e.attr("data-slice"),i=this._series[i].data[e];this.trigger(t.type,i,t)},mouseOverSlice:function(t,e){var i=B(this.$('.slice[data-serie="'+(e=e||0)+'"][data-slice="'+t+'"]')[0]),n=this._series[e].data[t],n=(i.toggleClass("hover"),n.isOuter&&!gi(n.onHoverEffect)&&this.effectOnSlice(i,n,n.onHoverEffect,!i.hasClass("hover")),B(this.$('.legend-slice[data-serie="'+e+'"][data-slice="'+t+'"]')[0])),i=(n&&n.toggleClass("hover"),Object.keys(this.model.get("attrs")).filter(function(t){return-1<t.indexOf(".slice")||-1<t.indexOf(".legend-slice")}));g.prototype.update.call(this,this.model,Pi(this.model.get("attrs"),i))},onMouseOverSlice:function(t){var e=B(t.currentTarget),i=e.attr("data-serie"),e=e.attr("data-slice"),i=(this.mouseOverSlice(e,i),this._series[i].data[e]);this.trigger(t.type,i,t)},clickSlice:function(t,e){var i=B(this.$('.slice[data-serie="'+(e=e||0)+'"][data-slice="'+t+'"]')[0]),n=this._series[e].data[t];n.isOuter&&(i.hasClass("clicked")?(i.removeClass("clicked"),this.model.get("series")[e].data[t].offset=0,this.effectOnSlice(i,n,n.onClickEffect,!0)):(i.addClass("clicked"),this.model.get("series")[e].data[t].offset=n.onClickEffect.offset,this.effectOnSlice(i,n,n.onClickEffect)))},onClickSlice:function(t){var e,i=B(w(t.target).closest(".slice.outer")[0]);i&&(e=i.attr("data-serie"),i=i.attr("data-slice"),this.clickSlice(i,e),e=this._series[e].data[i],this.trigger(t.type,e,t))},onEventLegendItem:function(t){var e=B(w(t.target).closest(".legend-slice")[0]);if(e){var i=e.attr("data-serie"),n=e.attr("data-slice");switch(t.type){case"click":this.clickSlice(n,i);break;case"mouseover":case"mouseout":this.mouseOverSlice(n,i)}}},effectOnSlice:function(t,e,i,n){switch(n=n||!1,i.type){case"enlarge":n?t.scale(1):t.scale(i.scale||1.05);break;case"offset":n?t.translate(0,0,{absolute:!0}):t.translate(i.offset*Math.cos(-e.middleangle),-i.offset*Math.sin(-e.middleangle))}},svgArcMax:2*Math.PI-1e-6,drawArc:function(t,e,i,n,r){var o=0,s=1,r=r-n;return r>Math.PI&&(o=1,r>=this.svgArcMax&&(s=o=0)),"M"+t.x+","+t.y+" A"+i+","+i+" 0 "+o+","+s+" "+e.x+","+e.y}}),ko=Mo.extend({defaults:e({type:"chart.Knob",sliceDefaults:{legendLabel:"{value:.0f}",outer:{offsetOnClick:0}},pieHole:.7,value:0,attrs:{".legend":{"ref-x":.5,"ref-y":.5,"ref-dx":null,"x-alignment":-.5,"y-alignment":-.5},".legend-slice text":{"font-size":30},".legend-slice circle":{display:"none"},".slice-inner-label":{display:"none"},".slice-fill":{stroke:"none"}}},Mo.prototype.defaults),initialize:function(){this.set("series",this.getKnobSeries(),{silent:!0}),Mo.prototype.initialize.apply(this,arguments),this.on("change:value change:min change:max change:fill",this.updateKnob,this)},getKnobSeries:function(){var t=Array.isArray(this.get("value"))?this.get("value"):[this.get("value")],o=Array.isArray(this.get("fill"))?this.get("fill"):[this.get("fill")],s=Array.isArray(this.get("min"))?this.get("min"):[this.get("min")],a=Array.isArray(this.get("max"))?this.get("max"):[this.get("max")];return t.map(function(t,e){var i=void 0===s[e]?s[0]:s[e],n=void 0===a[e]?a[0]:a[e],r=void 0===o[e]?o[0]:o[e];return{degree:J.linear([i,n],[0,360],t),data:[{value:t,fill:r}],showLegend:!(0<e)}})},updateKnob:function(){this.set("series",this.getKnobSeries())}}),No=Io,To=h.extend({markup:['<g class="rotatable">','<g class="scalable">','<g class="background"><rect/></g>','<g class="cells"/>','<g class="foreground"/>',"</g>",'<g class="labels">','<g class="rows"/>','<g class="columns"/>',"</g>","</g>"].join(""),cellMarkup:'<rect class="cell"/>',labelMarkup:'<text class="label"/>',gridLineMarkup:'<path class="grid-line"/>',defaults:e({type:"chart.Matrix",attrs:{".background rect":{fill:"#eeeeee"},".grid-line":{stroke:"white","stroke-width":2},".label":{fill:"black","alignment-baseline":"middle"},".labels .rows .label":{"text-anchor":"end"},".labels .columns .label":{"text-anchor":"start"}}},h.prototype.defaults)}),Lo=g.extend({presentationAttributes:g.addPresentationAttributes({size:["LABELS"],cells:["MARKUP","LABELS"]}),initFlag:["LABELS"].concat(g.prototype.initFlag),confirmUpdate:function(){var t=g.prototype.confirmUpdate.apply(this,arguments);return this.hasFlag(t,"MARKUP")&&(this.renderMarkup(),t=this.removeFlag(t,"MARKUP")),this.hasFlag(t,"LABELS")&&(this.renderLabels(),t=this.removeFlag(t,"LABELS")),t},renderMarkup:function(){g.prototype.renderMarkup.apply(this,arguments),this.elCells=this.$(".cells")[0],this.elRowLabels=this.$(".labels .rows")[0],this.elColumnLabels=this.$(".labels .columns")[0],this.elForeground=this.$(".foreground")[0],this.elCell=B(this.model.cellMarkup),this.elGridLine=B(this.model.gridLineMarkup);for(var t,e,i,n,r,o=this.model.get("cells")||[],s=this.model.get("size"),a=(this.elBackgroundRect=this.$(".background rect")[0],B(this.elBackgroundRect).attr(s),s.height/o.length),l=s.width/o.length,h=document.createDocumentFragment(),c=(this.elCells.textContent="",this.elForeground.textContent="",document.createDocumentFragment()),u=0;u<o.length;u++)for((i=this.elGridLine.clone()).addClass("horizontal"),i.attr("d","M 0 "+u*a+" "+s.width+" "+u*a),c.appendChild(i.node),t=o[u],e=0;e<t.length;e++)0===u&&((i=this.elGridLine.clone()).addClass("vertical"),i.attr("d","M "+e*l+" 0 "+e*l+" "+s.height),c.appendChild(i.node)),(n=t[e])&&((r=this.elCell.clone()).attr(R({x:e*l,y:u*a,width:l,height:a},n)),h.appendChild(r.node));this.elForeground.appendChild(c),this.elCells.appendChild(h)},renderLabels:function(){this.elLabel=B(this.model.labelMarkup);for(var t,e,i,n,r=this.model.get("cells")||[],o=this.model.get("labels")||{},s=o.rows||[],a=o.columns||[],l=this.model.get("size"),h=l.height/r.length,c=l.width/r.length,u=(this.elRowLabels.textContent="",this.elColumnLabels.textContent="",document.createDocumentFragment()),d=0;d<s.length;d++)t=o.rows[d],(e=this.elLabel.clone()).text(t.text),e.attr(R({x:-(o.padding||5),y:d*h+h/2,"text-anchor":"end","dominant-baseline":"central","font-size":h,"data-row":d},Si(t,"text"))),u.appendChild(e.node);this.elRowLabels.appendChild(u);for(var g=document.createDocumentFragment(),p=0;p<a.length;p++)t=o.columns[p],e=this.elLabel.clone(),n=-(o.padding||5),e.attr("x",i=p*c+c/2),e.text(t.text),e.attr(R({y:n,"text-anchor":"start","dominant-baseline":"central","font-size":c,"data-column":p},Si(t,"text"))),e.rotate(-90,i,n),g.appendChild(e.node);this.elColumnLabels.appendChild(g)}}),wo={Plot:wo,PlotView:Ao,Pie:Mo,PieView:Io,Knob:ko,KnobView:No,Matrix:To,MatrixView:L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Uo++aBSo+ki7vQBGaHTRBjdwJ7TghGENFqtNoAuPTvUEmFkDxN0Z7ZSkBymvlqltUj5DOQpd/Kk4HbG6pct5fuYp9xJQlk8depUK1/8P5EqgDvcydPV4g6gVMcutNmWd5IlgEvuhA8ixJl63LjU64uKinS4g+AW5niauE+wKn0vUwB3uNMcvM+RI0faQcKU0ioHDx60pVWMtmQWvj9jLFtaBXNwWmWXbBvYThiAO8TO8UIMHHAQaOIIPyEQ7d+/v9NRgN27d3exfv/AhG4D9zVgLIzJ7heJrW3SjdgVd7Jr8zsybfZUATyKU4tXVXKt9Txml2pqUdbXdDXuZPf+OySPkX+1CQBixtzmjEqfQL6tJaqtxU/ix3I9n4JaeUEInZmZGSHasVIxNTU1wx9TulTGNNGf35zN67eOFL6X4Hv+/Hkr3aN14PNEPYL5atgvjde4+1HBy3/PaXb49xwwzD/eZyP/EWAAQ3AUnjpOYHIAAAAASUVORK5CYII="},Ao={initialize:function(){this._parent=(this._parent||this).constructor.__super__,this._parent.initialize.apply(this,arguments),this.listenTo(this,"change:icon",this._onIconChange),this._onIconChange(this,this.get("icon")||"none")},_onIconChange:function(t,e){if(!xi(Eo,e))throw"BPMN: Unknown icon: "+e;t.attr({image:{"xlink:href":Eo[e],dataIconType:e}})}},Io={initialize:function(){this._parent=(this._parent||this).constructor.__super__,this._parent.initialize.apply(this,arguments),this.listenTo(this,"change:subProcess",this._onSubProcessChange),this._onSubProcessChange(this,this.get("subProcess")||null)},_onSubProcessChange:function(t,e){t.attr({".sub-process":{visibility:e?"visible":"hidden","data-sub-process":e||""}})}},ko=Dn,No=En.extend({markup:['<g class="rotatable">','<g class="scalable"><rect class="body outer"/><rect class="body inner"/></g>',In.test("svgforeignobject")?'<foreignObject class="fobj"><body xmlns="http://www.w3.org/1999/xhtml"><div class="content"/></body></foreignObject>':'<text class="content"/>','<path class="sub-process"/><image class="icon"/></g>'].join(""),defaults:e({size:{width:100,height:100},type:"bpmn.Activity",attrs:{rect:{rx:8,ry:8,width:100,height:100},".body":{fill:"#ffffff",stroke:"#000000"},".inner":{transform:"scale(0.9,0.9) translate(5,5)"},path:{d:"M 0 0 L 30 0 30 30 0 30 z M 15 4 L 15 26 M 4 15 L 26 15",ref:".inner","ref-x":.5,"ref-dy":-30,"x-alignment":"middle",stroke:"#000000",fill:"transparent"},image:{ref:".inner","ref-x":5,width:20,height:20}},activityType:"task",subProcess:null},En.prototype.defaults),initialize:function(){En.prototype.initialize.apply(this,arguments),this.listenTo(this,"change:activityType",this.onActivityTypeChange),this.listenTo(this,"change:subProcess",this.onSubProcessChange),this.onSubProcessChange(this,this.get("subProcess")),this.onActivityTypeChange(this,this.get("activityType"))},onActivityTypeChange:function(t,e){switch(e){case"task":t.attr({".inner":{visibility:"hidden"},".outer":{"stroke-width":1,"stroke-dasharray":"none"},path:{ref:".outer"},image:{ref:".outer"}});break;case"transaction":t.attr({".inner":{visibility:"visible"},".outer":{"stroke-width":1,"stroke-dasharray":"none"},path:{ref:".inner"},image:{ref:".inner"}});break;case"event-sub-process":t.attr({".inner":{visibility:"hidden"},".outer":{"stroke-width":1,"stroke-dasharray":"1,2"},path:{ref:".outer"},image:{ref:".outer"}});break;case"call-activity":t.attr({".inner":{visibility:"hidden"},".outer":{"stroke-width":5,"stroke-dasharray":"none"},path:{ref:".outer"},image:{ref:".outer"}});break;default:throw"BPMN: Unknown Activity Type: "+e}},onSubProcessChange:function(t,e){e?t.attr({".fobj div":{style:{verticalAlign:"baseline",paddingTop:10}},image:{"ref-dy":-25,"ref-y":""},".content":{"ref-y":10,"y-alignment":null}}):t.attr({".fobj div":{style:{verticalAlign:"middle",paddingTop:0}},image:{"ref-dy":"","ref-y":5},".content":{"ref-y":.5,"y-alignment":"middle"}})}}).extend(Ao).extend(Io),To=Dn,Lo=En.extend({markup:['<g class="rotatable">','<g class="scalable"><rect class="body"/></g>',In.test("svgforeignobject")?'<foreignObject class="fobj"><body xmlns="http://www.w3.org/1999/xhtml"><div class="content"/></body></foreignObject>':'<text class="content"/>','<path class="stroke"/></g>'].join(""),defaults:e({size:{width:100,height:100},type:"bpmn.Annotation",attrs:{rect:{width:100,height:100},".body":{"fill-opacity":.1,fill:"#ffffff",stroke:"none"},".fobj div":{style:{textAlign:"left",paddingLeft:10}},".stroke":{stroke:"#000000",fill:"none","stroke-width":3}},wingLength:20},En.prototype.defaults),initialize:function(){En.prototype.initialize.apply(this,arguments),this.listenTo(this,"change:size",this.onSizeChange),this.onSizeChange(this,this.get("size"))},onSizeChange:function(t,e){t.attr(".stroke",{d:t.getStrokePathData(e.width,e.height,t.get("wingLength"))})},getStrokePathData:function(t,e,i){return["M",i=Math.min(i,t),"0 L 0 0 0",e,i,e].join(" ")}}),Do=r.extend({markup:'<g class="rotatable"><g class="scalable"><polygon class="body"/><image/></g></g><text class="label"/>',defaults:e({type:"bpmn.Gateway",size:{width:80,height:80},attrs:{".body":{points:"40,0 80,40 40,80 0,40",fill:"#ffffff",stroke:"#000000"},".label":{text:"",ref:".body","ref-x":.5,"ref-dy":20,"y-alignment":"middle","x-alignment":"middle","font-size":14,"font-family":"Arial, helvetica, sans-serif",fill:"#000000"},image:{width:40,height:40,"xlink:href":"",transform:"translate(20,20)"}}},r.prototype.defaults)}).extend(Ao),Bo=r.extend({markup:'<g class="rotatable"><g class="scalable"><circle class="body outer"/><circle class="body inner"/><image/></g><text class="label"/></g>',defaults:e({type:"bpmn.Event",size:{width:60,height:60},attrs:{".body":{fill:"#ffffff",stroke:"#000000"},".outer":{"stroke-width":1,r:30,transform:"translate(30,30)"},".inner":{"stroke-width":1,r:26,transform:"translate(30,30)"},image:{width:40,height:40,"xlink:href":"",transform:"translate(10,10)"},".label":{text:"",fill:"#000000","font-family":"Arial","font-size":14,ref:".outer","ref-x":.5,"ref-dy":20,"x-alignment":"middle","y-alignment":"middle"}},eventType:"start"},r.prototype.defaults),initialize:function(){r.prototype.initialize.apply(this,arguments),this.listenTo(this,"change:eventType",this.onEventTypeChange),this.onEventTypeChange(this,this.get("eventType"))},onEventTypeChange:function(t,e){switch(e){case"start":t.attr({".inner":{visibility:"hidden"},".outer":{"stroke-width":1}});break;case"end":t.attr({".inner":{visibility:"hidden"},".outer":{"stroke-width":5}});break;case"intermediate":t.attr({".inner":{visibility:"visible"},".outer":{"stroke-width":1}});break;default:throw"BPMN: Unknown Event Type: "+e}}}).extend(Ao),Go=r.extend({markup:['<g class="rotatable">','<g class="scalable"><rect class="body"/></g>','<svg overflow="hidden" class="blackbox-wrap"><text class="blackbox-label"/></svg>','<rect class="header"/><text class="label"/>','<g class="lanes"/>',"</g>"].join(""),laneMarkup:'<g class="lane"><rect class="lane-body"/><rect class="lane-header"/><text class="lane-label"/></g>',defaults:e({type:"bpmn.Pool",size:{width:600,height:300},attrs:{".body":{fill:"#ffffff",stroke:"#000000",width:500,height:200,"pointer-events":"stroke"},".header":{fill:"#ffffff",stroke:"#000000",width:20,ref:".body","ref-height":1,"pointer-events":"visiblePainted"},".label":{fill:"#000000",transform:"rotate(-90)",ref:".header","ref-x":10,"ref-y":.5,"font-family":"Arial","font-size":14,"x-alignment":"middle","text-anchor":"middle"},".lane-body":{fill:"#ffffff",stroke:"#000000","pointer-events":"stroke"},".lane-header":{fill:"#ffffff",stroke:"#000000","pointer-events":"visiblePainted"},".lane-label":{fill:"#000000",transform:"rotate(-90)","text-anchor":"middle","font-family":"Arial","font-size":13},".blackbox-wrap":{ref:".body","ref-width":1,"ref-height":1},".blackbox-label":{text:"Black Box","text-anchor":"middle",transform:"translate(0,-7)"},".blackbox-label > tspan":{dx:"50%",dy:"50%"}}},r.prototype.defaults)}),zo=g.extend({options:{headerWidth:20},presentationAttributes:g.addPresentationAttributes({lanes:["LANES"]}),confirmUpdate:function(){var t=g.prototype.confirmUpdate.apply(this,arguments);return this.hasFlag(t,"LANES")&&(this.renderLanes(this.model.get("lanes")),t=this.removeFlag(t,["LANES"])),t},update:function(){return void 0===this.lanesAttrs?this.renderLanes(this.model.get("lanes")):g.prototype.update.call(this,this.model,y({},this.model.get("attrs"),this.lanesAttrs||{}))},renderMarkup:function(){g.prototype.renderMarkup.apply(this,arguments),this.$lanes=this.$(".lanes"),this.laneMarkup=B(this.model.laneMarkup)},renderLanes:function(t){t=t||{};var e=(void(this.index=0)===t.headerWidth?this.options:t).headerWidth;this.lanesAttrs={".header":{width:e},".label":{text:t.label||""}},this.$lanes.empty(),t.sublanes&&this.renderSublanes(t.sublanes,e,0,1,"lanes"),this.update(this.model,y({},this.model.get("attrs"),this.lanesAttrs))},calculateRatios:function(t,e){for(var i=0,n=[],r=[],o=0,s=t.length;o<s;o++){var a=t[o].ratio;Number.isFinite(a)?(i+=a/10,r[o]=a/10/e):n.push(o)}for(var l=Math.max(1-i,0)*e/n.length,h=0,c=n.length;h<c;h++)r[n[h]]=l;return r},renderSublanes:function(t,h,c,e,i){var u=this.options.headerWidth,d=i+"/sublanes/",g=this.calculateRatios(t,e);et(t).reduce(function(t,e,i){var n="lane"+this.index,r="."+n+" .lane-body",o="."+n+" .lane-header",s="."+n+" .lane-label",a=(e.name&&(n+=" "+e.name),d+i),n=this.laneMarkup.clone().addClass(n).attr({"data-lane-path":a,"data-lane-index":this.index}),n=(this.$lanes.append(n.node),g[i]),i=void 0===e.headerWidth?u:e.headerWidth,l=c+t;return this.lanesAttrs[r]={ref:".body","ref-height":n,"ref-width":-h,"ref-x":h,"ref-y":l},this.lanesAttrs[o]={width:i,ref:".body","ref-height":n,"ref-x":h,"ref-y":l},this.lanesAttrs[s]={text:e.label,ref:o,"ref-x":10,"ref-y":.5,"x-alignment":"middle"},this.index++,e.sublanes&&this.renderSublanes(e.sublanes,h+i,l,n,a),t+n}.bind(this),0)}}),Oo=r.extend({markup:'<g class="rotatable"><g class="scalable"><rect class="body"/></g><rect class="label-rect"/><g class="label-group"><svg overflow="hidden" class="label-wrap"><text class="label"/></svg></g></g>',defaults:e({type:"bpmn.Group",size:{width:200,height:200},attrs:{".body":{width:200,height:200,stroke:"#000000","stroke-dasharray":"6,6","stroke-width":2,fill:"transparent",rx:15,ry:15,"pointer-events":"stroke"},".label-rect":{ref:".body","ref-width":.6,"ref-x":.4,"ref-y":-30,height:25,fill:"#ffffff",stroke:"#000000"},".label-group":{ref:".label-rect","ref-x":0,"ref-y":0},".label-wrap":{ref:".label-rect","ref-width":1,"ref-height":1},".label":{text:"",x:"50%",y:"1.3em","text-anchor":"middle","font-family":"Arial","font-size":14,fill:"#000000"}}},r.prototype.defaults)}),Ro=r.extend({markup:'<g class="rotatable"><g class="scalable"><polygon class="body"/></g><text class="label"/></g>',defaults:e({type:"bpmn.DataObject",size:{width:60,height:80},attrs:{".body":{points:"20,0 60,0 60,80 0,80 0,20 20,0 20,20 0,20",stroke:"#000000",fill:"#ffffff"},".label":{ref:".body","ref-x":.5,"ref-dy":5,text:"","text-anchor":"middle"}}},r.prototype.defaults)}),Vo=r.extend({markup:'<g class="rotatable"><g class="scalable"><polygon class="body"/></g><text class="label"/><path class="sub-process"/></g>',defaults:e({type:"bpmn.Conversation",size:{width:100,height:100},attrs:{".body":{points:"25,0 75,0 100,50 75,100 25,100 0,50",stroke:"#000000",fill:"#ffffff"},".label":{text:"",ref:".body","ref-x":.5,"ref-dy":5,"text-anchor":"middle"},path:{d:"M 0 0 L 30 0 30 30 0 30 z M 15 4 L 15 26 M 4 15 L 26 15",ref:".body","ref-x":.5,"ref-dy":-30,"x-alignment":"middle",fill:"#ffffff",stroke:"#000000","fill-opacity":0}},conversationType:"conversation"},r.prototype.defaults),initialize:function(){r.prototype.initialize.apply(this,arguments),this.listenTo(this,"change:conversationType",this.onConversationTypeChange),this.onConversationTypeChange(this,this.get("conversationType"))},onConversationTypeChange:function(t,e){switch(e){case"conversation":t.attr("polygon/stroke-width",1);break;case"call-conversation":t.attr("polygon/stroke-width",4);break;default:throw"BPMN: Unknown Conversation Type: "+e}}}).extend(Io),jo=En.extend({markup:['<g class="rotatable">','<g class="scalable"><rect class="body"/></g>',In.test("svgforeignobject")?'<foreignObject class="fobj"><body xmlns="http://www.w3.org/1999/xhtml"><div class="content"/></body></foreignObject>':'<text class="content"/>','<text class="label"/><path class="sub-process"/><g class="participants"/>',"</g>"].join(""),participantMarkup:'<g class="participant"><rect class="participant-rect"/><text class="participant-label"/></g>',defaults:e({type:"bpmn.Choreography",size:{width:60,height:80},attrs:{rect:{},".body":{width:60,height:80,stroke:"#000000",fill:"#ffffff"},".label":{ref:".body","ref-x":.5,"ref-dy":5,text:"","text-anchor":"middle"},".participant-rect":{stroke:"#000000",fill:"#aaaaaa",ref:".body","ref-width":1},".participant-label":{"text-anchor":"middle",ref:".participant_0 .participant-rect","ref-x":.5,"ref-y":.5,"y-alignment":"middle"},".sub-process":{d:"M 0 0 L 30 0 30 30 0 30 z M 15 4 L 15 26 M 4 15 L 26 15",ref:".body","ref-x":.5,"ref-dy":-30,"x-alignment":"middle",fill:"transparent",stroke:"#000000"}},participants:[],initiatingParticipant:0},En.prototype.defaults)}).extend(Io),_o=Dn.extend({options:{participantHeight:20},presentationAttributes:Dn.addPresentationAttributes({participants:"PARTICIPANTS",initiatingParticipant:"INIT_PARTICIPANT"}),initFlag:["PARTICIPANTS"].concat(Dn.prototype.initFlag),confirmUpdate:function(){var t=Dn.prototype.confirmUpdate.apply(this,arguments);return this.hasFlag(t,"PARTICIPANTS")?(this.renderParticipants(this.model.get("participants")),this.removeFlag(t,["PARTICIPANTS","INIT_PARTICIPANT"])):(this.hasFlag(t,"INIT_PARTICIPANT")&&(this.layoutAndUpdate(),t=this.removeFlag(t,"INIT_PARTICIPANT")),t)},update:function(){return void 0===this.participantsAttrs?this.renderParticipants(this.model.get("participants")):(this.layoutAndUpdate(),this)},render:function(){this.participantsAttrs=void 0,g.prototype.render.apply(this,arguments)},renderMarkup:function(){g.prototype.renderMarkup.apply(this,arguments),this.$participants=this.$(".participants"),this.participantMarkup=B(this.model.participantMarkup)},renderParticipants:function(t){this.$participants.empty(),this.participantsAttrs={},et(t).forEach(function(t,e){var e="participant_"+e,i="."+e;this.participantsAttrs[i+" .participant-rect"]={height:this.options.participantHeight},this.participantsAttrs[i+" .participant-label"]={text:t},this.$participants.append(this.participantMarkup.clone().addClass(e).node)},this),this.layoutAndUpdate()},layoutAndUpdate:function(){var t=this.model.get("participants")||[],e=t.length,n=this.options.participantHeight,i=this.model.get("size").height,r=Math.max(0,i-n*e),o=0,s=this.model.get("initiatingParticipant"),a=Math.max(G(s)?Math.abs(s):t.indexOf(s),0),l=Math.min(a,e-2),s=(et(t).forEach(function(t,e){var i=".participant_"+e;this.participantsAttrs[i]={transform:"translate(0,"+o+")"},this.participantsAttrs[i+" .participant-rect"].fill=a==e?this.model.attr(".body/fill"):this.model.attr(".participant-rect/fill"),this.participantsAttrs[i+" .participant-rect"].stroke=a==e?this.model.attr(".body/stroke"):this.model.attr(".participant-rect/stroke"),o+=n+(l==e?r:0)},this),e<2?0:l-e+1),t=(this.participantsAttrs[".sub-process"]={"ref-dy":Math.max(-i,s*n-30)},e<2?0:l+1),i=(this.participantsAttrs[".fobj div"]={style:{height:r,paddingTop:n*t}},this.participantsAttrs[".content"]={"ref-y":n*t+r/2},y({},this.model.get("attrs"),this.participantsAttrs||{}));Te(i,"div/html"),Dn.prototype.update.call(this,this.model,i)}}),e=r.extend({markup:'<g class="rotatable"><g class="scalable"><polygon class="body"/></g><text class="label"/></g>',defaults:e({type:"bpmn.Message",size:{width:60,height:40},attrs:{".body":{points:"0,0 60,0 60,40 0,40 0,0 60,0 30,20 0,0",stroke:"#000000",fill:"#ffffff"},".label":{ref:".body","ref-x":.5,"ref-dy":5,text:"","text-anchor":"middle"}}},r.prototype.defaults)}),Zo=u.extend({defaults:{type:"bpmn.Flow",attrs:{".marker-source":{d:"M 0 0"},".marker-target":{d:"M 10 0 L 0 5 L 10 10 z",fill:"#000000"},".connection":{"stroke-dasharray":" ","stroke-width":1},".connection-wrap":{style:"",onMouseOver:"",onMouseOut:""}},flowType:"normal"},initialize:function(){u.prototype.initialize.apply(this,arguments),this.listenTo(this,"change:flowType",this.onFlowTypeChange),this.onFlowTypeChange(this,this.get("flowType"))},onFlowTypeChange:function(t,e){var i;switch(e){case"default":i={".marker-source":{d:"M 0 5 L 20 5 M 20 0 L 10 10",fill:"none"}};break;case"conditional":i={".marker-source":{d:"M 20 8 L 10 0 L 0 8 L 10 16 z",fill:"#FFF"}};break;case"normal":i={};break;case"message":i={".marker-target":{fill:"#FFF"},".connection":{"stroke-dasharray":"4,4"}};break;case"association":i={".marker-target":{d:"M 0 0"},".connection":{"stroke-dasharray":"4,4"}};break;case"conversation":i={".marker-target":{d:"M 0 0"},".connection":{"stroke-width":"7px"},".connection-wrap":{style:"stroke: #fff; stroke-width: 5px; opacity: 1;",onMouseOver:"var s=this.style;s.stroke='#000';s.strokeWidth=15;s.opacity=.4",onMouseOut:"var s=this.style;s.stroke='#fff';s.strokeWidth=5;s.opacity=1"}};break;default:throw"BPMN: Unknown Flow Type: "+e}i.root={dataFlowType:e},t.attr(y({},this.defaults.attrs,i))}}),Ao={icons:Eo,IconInterface:Ao,SubProcessInterface:Io,ActivityView:ko,Activity:No,AnnotationView:To,Annotation:Lo,Gateway:Do,Event:Bo,Pool:Go,PoolView:zo,Group:Oo,DataObject:Ro,Conversation:Vo,Choreography:jo,ChoreographyView:_o,Message:e,Flow:Zo},Io=u,Yo=nn,Wo=new z(1,0),ko=Io.define("measurement.Distance",{attrs:{line:{connection:!0,stroke:"#333333",strokeWidth:2,strokeLinejoin:"round",targetMarker:{type:"path","stroke-width":2,d:"M 0 10 0 -10 M 10 10 0 0 10 -10",fill:"none"},sourceMarker:{type:"path","stroke-width":2,d:"M 0 10 0 -10 M 10 10 0 0 10 -10",fill:"none"}},wrapper:{connection:!0,strokeWidth:10,strokeLinejoin:"round"},anchorLines:{stroke:"#333333",strokeWidth:1,strokeDasharray:"1,2"},sourceAnchorLine:{dAnchor:"source"},targetAnchorLine:{dAnchor:"target"},distanceLabel:{distanceText:{unit:"px",fixed:0},fontFamily:"sans-serif",fontWeight:"lighter",fontSize:14,labelPosition:{ratio:.5,offset:12},textAnchor:"middle",textVerticalAnchor:"middle"}}},{markup:[{tagName:"path",selector:"sourceAnchorLine",groupSelector:"anchorLines"},{tagName:"path",selector:"targetAnchorLine",groupSelector:"anchorLines"},{tagName:"path",selector:"wrapper",attributes:{fill:"none",cursor:"pointer",stroke:"transparent","stroke-linecap":"round"}},{tagName:"path",selector:"line",attributes:{fill:"none","pointer-events":"none"}},{tagName:"text",selector:"distanceLabel"}],getDistanceText:function(t,e){var i=(e=void 0===e?{}:e).fixed,e=(void 0===i&&(i=0),e.unit),t=(void 0===e&&(e=""),t.getConnectionLength().toFixed(i));return e?t+" "+e:""+t}},{attributes:{distanceText:{set:function(t){for(var e,i=[],n=arguments.length-1;0<n--;)i[n]=arguments[n+1];(e=Yo.text.set).call.apply(e,[this,this.model.getDistanceText(this,t)].concat(i))}},dAnchor:{set:function(t){return{d:"M "+new C(this.getEndAnchor(t),this.getEndConnectionPoint(t)).serialize()}}},labelPosition:{set:function(t){var e,i,n=t.ratio,t=t.offset,n=(void 0===t&&(t=0),this.getTangentAtRatio(n=void 0===n?.5:n)),n=(n?(i=n.vector().vectorAngle(Wo),e=n.start):(e=this.path.start,i=0),t),t=0===i?"translate("+e.x+","+e.y+")":(i!==(i=Q((i+90)%180-90))&&(n=-t),"translate("+e.x+","+e.y+") rotate("+i+")");return{transform:t,y:n}}}}}),Fo={self:"self",source:"source",target:"target"},f={clockwise:"clockwise",anticlockwise:"anticlockwise",small:"small",large:"large"};function Uo(t,e,i){var n="angleData",r=t.nodeCache(t.el);if(n in r){if(e in r[n])return r[n][e]}else r[n]={};var n="number"==typeof i.angle,o=t.getEndView(e);if(!o&&!n)return null;var s,a,l="target"===e,h=t.getTangentAtRatio(l?1:0);return h?(l&&h.scale(-1,-1,h.start),n=n?(l=h,s=(n=i).angle,n=i.angleRadius,a=l.clone().rotate(l.start,-s),Ho(l,a,{angleRadius:n,angleStart:Fo.target,angleDirection:s<0?f.clockwise:f.anticlockwise})):o.model.isLink()?(l=h,a=i,s=(n=o).getClosestPointLength(l.start),n=n.getTangentAtLength(s),Ho(l,n,a)):(l=t.getEndMagnet(e),function(t,e,i,n){var r=n.angleRadius,n=n.angleDirection,o=e.model,s=o.getBBox(),o=o.angle(),s=s.center(),e=e.getNodeUnrotatedBBox(i),i=t.clone().setLength(1).end.rotate(s,o);if(e.containsPoint(i))return null;var a,l=0,h=0,s=t.angle()-o;i.y>e.y+e.height||i.y<e.y?(s+=90,l=r):h=r;s=Q(s);var c=Math.floor(s/90);switch(c){case 0:a=1;break;case 1:a=0;break;case 2:l*=-1,h*=-1,a=1;break;case 3:l*=-1,h*=-1,a=0}var u=!1;switch(n){case f.large:u=!0;break;case f.anticlockwise:u=0===c||2===c;break;case f.clockwise:u=1===c||3===c}u&&(l*=-1,h*=-1,a^=1);i=t.setLength(r),e=i.start,n=i.end,t=e.clone().offset(l,h).rotate(e,-o),r=e.angleBetween(n,t);180<r&&(r=360-r);return{arcAngle:s,angleBetween:r,sweepFlag:a,largeArcFlag:0,otherArcPoint:t,linkArcPoint:n,connectionPoint:e}}(h,o,l,i)),r.angleData[e]=n):null}function Ho(t,e,i){var n=i.angleRadius,r=i.angleStart,o=i.angleDirection,i=t.setLength(n),s=i.start,i=i.end,t=t.angle(),e=e.setLength(n).end,a=s.angleBetween(i,e),l=1,h=0,c=!1,u=!1,d=!0,g=Math.floor(a/90);switch(r){case Fo.target:switch(o===f.small?o=a<180?f.clockwise:f.anticlockwise:o===f.large&&(o=180<a?f.clockwise:f.anticlockwise),o){case f.anticlockwise:0<a&&a<180&&(h^=1),u=!0;break;default:case f.clockwise:180<=a&&(h^=1),l^=1}d=!1;break;case Fo.source:switch(o===f.small?o=180<a?f.clockwise:f.anticlockwise:o===f.large&&(o=a<180?f.clockwise:f.anticlockwise),o){case f.anticlockwise:180<a&&(h^=1),l=1,u=!0;break;default:case f.clockwise:a<180&&(h^=1),l=0}c=!(d=!1),a=Q(a+180);break;default:case Fo.self:switch(o){case f.anticlockwise:c=0===g||1===g,l=1,u=!0;break;case f.clockwise:c=2===g||3===g,l=0,u=!1;break;case f.small:c=1===g||2===g,l=0===g||2===g?0:1,u=1===g||3===g;break;case f.large:c=0===g||3===g,l=1===g||3===g?0:1,u=0===g||2===g}}return c&&(e=e.reflection(s)),d&&180<=a&&(a=Q(a-180)),{angleBetween:a=u?Q((d?180:360)-a):a,connectionPoint:s,linkArcPoint:i,otherArcPoint:e,largeArcFlag:h,sweepFlag:l,arcAngle:t}}var No={Distance:ko,Angle:Io.define("measurement.Angle",{attrs:{line:{connection:!0,stroke:"#333333",strokeWidth:2,strokeLinejoin:"round"},wrapper:{connection:!0,strokeWidth:10,strokeLinejoin:"round"},angles:{stroke:"#333333",fill:"none",strokeWidth:1,angleRadius:40},sourceAngle:{angleD:"source"},targetAngle:{angleD:"target"},angleLabels:{textAnchor:"middle",textVerticalAnchor:"middle",fill:"#333333",fontSize:11,fontFamily:"sans-serif",angleTextDecimalPoints:0,angleTextDistance:23},sourceAngleLabel:{angleText:"source",angleTextPosition:"source"},targetAngleLabel:{angleText:"target",angleTextPosition:"target"}}},{markup:[{tagName:"path",selector:"wrapper",attributes:{fill:"none",cursor:"pointer",stroke:"transparent","stroke-linecap":"round"}},{tagName:"path",selector:"line",attributes:{fill:"none","pointer-events":"none"}},{tagName:"path",selector:"sourceAngle",groupSelector:"angles",attributes:{cursor:"pointer"}},{tagName:"path",selector:"targetAngle",groupSelector:"angles",attributes:{cursor:"pointer"}},{tagName:"text",selector:"sourceAngleLabel",groupSelector:"angleLabels"},{tagName:"text",selector:"targetAngleLabel",groupSelector:"angleLabels"}],getAngleText:function(t){var e=(t=void 0===t?{}:t).angle,t=t.decimalPoints;return(e=void 0===e?0:e).toFixed(t=void 0===t?2:t)+"\xb0"}},{AngleStarts:Fo,AngleDirections:f,attributes:{angleD:{set:function(t,e,i,n){var r=n.angleRadius,o=n.angleStart,s=(void 0===o&&(o=Fo.self),n.anglePie),a=(void 0===s&&(s=!1),n.angleDirection);void 0===a&&(a=f.small);t=Uo(this,t,{angle:n.angle,angleRadius:r=void 0===r?40:r,angleStart:o,angleDirection:a});if(!t)return{d:"M 0 0 0 0"};var n=t.connectionPoint,o=t.linkArcPoint,a=t.otherArcPoint,l=t.arcAngle,h=t.largeArcFlag,t=t.sweepFlag,o=["M "+o.serialize(),"A "+r+" "+r+" "+l+" "+h+" "+t+" "+a.serialize()];return s&&o.push("L "+n.serialize()+" Z"),{d:o.join(" ")}}},angleText:{set:function(t,e,i,n){var r="",t=Uo(this,t,{angleRadius:40});t&&(r=this.model.getAngleText({angle:t.angleBetween,decimalPoints:n.angleTextDecimalPoints})),Yo.text.set.call(this,r,e,i,n)}},angleTextPosition:{set:function(t,e,i,n){n=n.angleTextDistance,t=Uo(this,t,{angleRadius:n=void 0===n?60:n});if(!t)return{};var r,o=t.connectionPoint,s=t.otherArcPoint,a=t.linkArcPoint,l=t.angleBetween,t=t.largeArcFlag,a=(Math.abs(l-180)<1e-6?(l=a.clone().rotate(o,t?90:-90),r=new C(o,l).setLength(n)):(l=new C(a,s).midpoint(),r=new C(o,l).setLength(n),t&&r.scale(-1,-1,r.start)),r.end),s=Q((r.angle()+90)%180-90);return{transform:"translate("+a.serialize()+") rotate("+s+")"}}},angle:{},angleRadius:{},angleTextDistance:{},angleTextDecimalPoints:{},anglePie:{},angleStart:{},angleDirection:{}}})},m='xmlns="http://www.w3.org/2000/svg"';To=function(t){var e=(t=void 0===t?{}:t).color,t=t.svg,i={none:null,message1:"<svg "+m+' viewBox="10 10 20 20"><path fill="none" stroke="'+(e=void 0===e?"#000":e)+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.2" d="M12.5 15.313v9.374h15v-9.375zm0 0l7.5 5.624 7.5-5.625"/></svg>',message2:"<svg "+m+' viewBox="10 10 20 20"><path fill="'+e+'" d="M12.5 14.344l7.5 5.625 7.5-5.625zm0 .937v9.375h15v-9.375L20 20.906z"/></svg>',timer1:"<svg "+m+' viewBox="8 8 24 24"><g fill="none" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"><circle cx="20" cy="20" r="10"/><path d="M20 10v3m5-2l-1.5 3m5.5 1l-3 1.5m4 3.5h-3m2 5l-3-1.5M25 29l-1.5-3M20 30v-3m-5 2l1.5-3M11 25l3-1.5M10 20h3m-2-5l3 1.5m1-5.5l1.5 3m5.5-1l-2 7h4"/></g></svg>',conditional1:"<svg "+m+' viewBox="6 6 28 28"><path fill="none" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M11.563 11.563h16.874v16.874H11.563V11.563m2.813 2.813h11.25m-11.25 3.75h11.25m-11.25 3.75h11.25m-11.25 3.75h11.25z"/></svg>',link1:"<svg "+m+' viewBox="8 8 24 24"><path fill="none" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M14.406 18.125h8.438v-2.813L27.53 20l-4.687 4.688v-2.813h-9.375v-3.75"/></svg>',link2:"<svg "+m+' viewBox="8 8 24 24"><path fill="'+e+'" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M14.406 18.125h8.438v-2.813L27.53 20l-4.687 4.688v-2.813h-9.375v-3.75"/></svg>',signal1:"<svg "+m+' viewBox="8 8 24 24"><path fill="none" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M13.17 24.851h13.706l-6.853-11.879-6.854 11.88z"/></svg>',signal2:"<svg "+m+' viewBox="8 8 24 24"><path fill="'+e+'" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M13.17 24.851h13.706l-6.853-11.879-6.854 11.88z"/></svg>',error1:"<svg "+m+' viewBox="8 8 24 24"><path fill="none" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M26.4 15.455l-3.238 12.58L17.7 18.37 13.76 23.8l3.478-12.412 5.576 8.72 3.586-4.652z"/></svg>',error2:"<svg "+m+' viewBox="8 8 24 24"><path fill="'+e+'" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M26.4 15.455l-3.238 12.58L17.7 18.37 13.76 23.8l3.478-12.412 5.576 8.72 3.586-4.652z"/></svg>',escalation1:"<svg "+m+' viewBox="8 8 24 24"><path fill="none" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M20 13.219l5.625 14.062L20 20.953l-5.625 6.328z"/></svg>',escalation2:"<svg "+m+' viewBox="8 8 24 24"><path fill="'+e+'" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M20 13.219l5.625 14.062L20 20.953l-5.625 6.328z"/></svg>',termination1:"<svg "+m+' viewBox="8 8 24 24"><circle cx="20" cy="20" r="10.5" fill="none" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"/></svg>',termination2:"<svg "+m+' viewBox="8 8 24 24"><circle cx="20" cy="20" r="10.5" fill="'+e+'" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"/></svg>',compensation1:"<svg "+m+' viewBox="8 8 24 24"><path fill="none" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M19 13.438v13.124L12.437 20 19 13.437m6.563 0v13.126L19 20l6.563-6.563z"/></svg>',compensation2:"<svg "+m+' viewBox="8 8 24 24"><path fill="'+e+'" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M19 13.438v13.124L12.437 20 19 13.437m6.563 0v13.126L19 20l6.563-6.563z"/></svg>',cancel1:"<svg "+m+' viewBox="8 8 24 24"><path fill="none" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M11.284 14.274l2.867-2.868 5.735 5.735 5.735-5.735 2.868 2.868-5.735 5.735 5.735 5.735-2.868 2.867-5.735-5.735-5.735 5.735-2.867-2.867 5.735-5.735-5.735-5.735z"/></svg>',cancel2:"<svg "+m+' viewBox="8 8 24 24"><path fill="'+e+'" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M11.284 14.274l2.867-2.868 5.735 5.735 5.735-5.735 2.868 2.868-5.735 5.735 5.735 5.735-2.868 2.867-5.735-5.735-5.735 5.735-2.867-2.867 5.735-5.735-5.735-5.735z"/></svg>',multiple1:"<svg "+m+' viewBox="8 8 24 24"><path fill="none" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M24.52 26.39h-9.443l-2.918-8.982 7.64-5.55 7.64 5.551-2.919 8.98z"/></svg>',multiple2:"<svg "+m+' viewBox="8 8 24 24"><path fill="'+e+'" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M24.52 26.39h-9.443l-2.918-8.982 7.64-5.55 7.64 5.551-2.919 8.98z"/></svg>',parallel1:"<svg "+m+' viewBox="8 8 24 24"><path fill="none" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M11.344 17.203v5.625h5.86v6.328h5.624v-6.328h6.328v-5.625h-6.328v-5.86h-5.625v5.86z"/></svg>',parallel2:"<svg "+m+' viewBox="8 8 24 24"><path fill="'+e+'" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M11.344 17.203v5.625h5.86v6.328h5.624v-6.328h6.328v-5.625h-6.328v-5.86h-5.625v5.86z"/></svg>'};if(t=void 0===t?!1:t)return i;var n={};return Object.keys(i).forEach(function(t){n[t]="data:image/svg+xml,"+encodeURIComponent(i[t])}),n}({color:"${color}",svg:!0}),Lo=function(t){var e=(t=void 0===t?{}:t).color,t=t.svg,i={exclusive_blank:null,exclusive:"<svg "+m+' viewBox="12 12 26 26"><path fill="'+(e=void 0===e?"#000":e)+'" stroke="'+e+'" d="M18.25 17.063L23.5 25.5l-5.25 8.438h4l3.25-5.25 3.25 5.25h3.906L27.438 25.5l5.218-8.438H28.75l-3.25 5.25-3.25-5.25h-4z"/></svg>',inclusive:"<svg "+m+' viewBox="12 12 26 26"><circle cx="25" cy="25" r="9.429" fill="none" stroke="'+e+'" stroke-width="3"/></svg>',parallel:"<svg "+m+' viewBox="12 12 26 26"><path fill="'+e+'" stroke="'+e+'" stroke-width="1.4" d="M16.388 21.821v5.625h5.86v6.328h5.624v-6.328H34.2v-5.625h-6.328v-5.86h-5.625v5.86z"/></svg>',event:"<svg "+m+' viewBox="12 12 26 26"><circle stroke-width="1.4" cx="25" cy="25" r="12.121" fill="none" stroke="'+e+'"/><circle stroke-width="1.4" cx="25" cy="25" r="10.121" fill="none" stroke="'+e+'"/><path fill="none" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.4" d="M29.828 31.845h-9.069l-2.801-8.625 7.337-5.33 7.335 5.33-2.802 8.625z"/></svg>',exclusive_event:"<svg "+m+' viewBox="12 12 26 26"><circle stroke-width="1.4" cx="25" cy="25" r="12.121" fill="none" stroke="'+e+'"/><path fill="none" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.4" d="M29.828 31.845h-9.069l-2.801-8.625 7.337-5.33 7.335 5.33-2.802 8.625z"/></svg>',parallel_event:"<svg "+m+' viewBox="12 12 26 26"><circle stroke-width="1.4" cx="25" cy="25" r="12.121" fill="none" stroke="'+e+'"/><path fill="none" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.4" d="M16.388 21.821v5.625h5.86v6.328h5.624v-6.328H34.2v-5.625h-6.328v-5.86h-5.625v5.86z"/></svg>',complex:"<svg "+m+' viewBox="13 13 25 25"><path fill="none" stroke="'+e+'" stroke-width="4" d="M16.25 25.5h19m-9.75-9.25v19m-6.644-2.96L32.29 18.857m-13.435.353L32.29 32.644"/></svg>'};if(t=void 0===t?!1:t)return i;var n={};return Object.keys(i).forEach(function(t){n[t]="data:image/svg+xml,"+encodeURIComponent(i[t])}),n}({color:"${color}",svg:!0}),Do=function(t){var e=(t=void 0===t?{}:t).color,t=t.svg,i={none:null,parallel:"<svg "+m+' viewBox="-3 -3 16 16"><path fill="none" stroke="'+(e=void 0===e?"#000":e)+'" stroke-width="2" d="M0 0v10M3 0v10M6 0v10"/></svg>',sequential:"<svg "+m+' viewBox="-3 -3 16 16"><path fill="none" stroke="'+e+'" stroke-width="2" d="M0 2h10M0 5h10M0 8h10"/></svg>',"sub-process":"<svg "+m+' viewBox="-2 -2 14 14"><path fill="none" stroke="'+e+'" stroke-width="1" d="M0 0h10v10H0zm5 2v6M2 5h6"/></svg>',compensation:"<svg "+m+' viewBox="8 8 24 24"><path fill="none" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M19 13.438v13.124L12.437 20 19 13.437m6.563 0v13.126L19 20l6.563-6.563z"/></svg>',"ad-hoc":"<svg "+m+' viewBox="0 0 2000 2000"><path fill="'+e+'" d="M300 1039.87c58.332-138.228 134.894-282.23 266.546-360.085c97.784-58.392 218.701-22.42 308.428 34.819c138.188 85.207 246.292 211.842 382.606 299.507c82.335 48.265 184.733 8.718 244.748-58.056c72.401-84.446 155.215-164.023 197.672-269.981v330.038c-61.331 121.67-140.231 248.152-266.392 307.169c-103.228 44.44-223.148 17.789-312.524-46.586c-131.02-87.979-227.486-223.69-369.854-294.78c-69.172-36.004-157.377-27.545-215.331 26.623C431.412 1101.042 371.534 1231.858 300 1350v-310.13z"/></svg>',loop:"<svg "+m+' viewBox="0 0 2000 2000"><path fill="'+e+'" d="M1057.07 410.836C805.11 407.3 563.447 583.065 491.134 824.983c-55.584 173.977-23.105 373.061 85.522 520.027l-269.086-52.09l-22.804 117.814l483.865 93.664l93.687-479.986l-117.779-22.988l-56.861 291.316c-138.733-165.6-136.73-427.773 4.367-591.379c137.417-171.716 399.203-221.007 590.733-114c183.232 94.568 284.888 318.597 234.896 518.746c-44.77 208.91-247.404 367.34-460.604 363.053c-55.485-3.935-83.374 76.196-37.436 107.561c40.104 24.986 90.846 7.364 134.808 4.475c248.181-37.748 457.52-249.452 489.52-498.91c36.994-238.025-91.384-488.935-304.803-600.241c-86.168-46.769-184.068-71.364-282.089-71.21z"/></svg>'};if(t=void 0===t?!1:t)return i;var n={};return Object.keys(i).forEach(function(t){n[t]="data:image/svg+xml,"+encodeURIComponent(i[t])}),n}({color:"${color}",svg:!0}),Bo=function(t){var e=(t=void 0===t?{}:t).color,t=t.svg,i={none:null,"business-rule":"<svg "+m+' viewBox="5 5 25 20"><path fill="'+(e=void 0===e?"#000":e)+'" stroke="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.2" d="m 8,8 0,4 20,0 0,-4 z"/><path stroke="'+e+'" fill="none" d=" m 8,8 0,12 20,0 0,-12 zm 0,8 l 20,0 m -13,-4 l 0,8"/></svg>',manual:"<svg "+m+' viewBox="0 0 2000 2000"><path d="M919.379 382.988c-22.3.007-42.953 8.258-60.567 19.616l-.029.017-.027.02c-94.694 61.32-418.867 286.29-490.127 335.2l-.002.003h-.002c-64.371 44.196-107.733 110.904-132.662 189.935l-.004.016-.004.014c-25.952 82.515-22.622 172.403-22.371 247.685l.002.02v.02c.255 56.685 1.606 106.154 16.309 166.148l.003.015c21.373 87.802 62.768 151.336 121.23 190.285 58.46 38.948 130.615 52.768 211.575 53.018 292.284 1.097 584.741 1.49 877.182 0h.05c32.21-.211 62.96-13.752 82.135-37.678 19.174-23.923 27.017-54.865 27.43-88.81.29-22.768-2.91-44.287-10.307-63.512h32.375c31.532 0 60.434-8.984 81.153-27.916 20.711-18.926 31.304-44.62 36.808-71.68v-.007c7.683-37.64 4.055-74.807-10.916-105.997 32.946-2.661 62.034-15.102 80.74-37.906 21.024-25.627 27.148-58.205 27.256-92.72.115-36.034-8.629-70.421-28.812-97.766s-53.772-45.956-91.567-46.01H1666.21c-13.76-.011-26.16.008-41.781 0 7.516-18.744 10.82-39.826 10.752-62.006v-.113c-.228-35.772-9.251-69.954-29.535-97.127-20.284-27.173-53.809-45.753-91.586-45.754-224.42-.885-446.252 2.157-634.903 1.203 9.83-9.885 19.378-19.525 29.871-29.96 32.482-32.304 63.7-62.743 79.827-83.612 38.555-49.623 44.307-116.852 11.85-166.305-17.114-26.143-42.208-43.832-69.151-47.513a89.543 89.543 0 00-10.012-.8v.003a90.145 90.145 0 00-2.162-.026zm.547 70.028a17.31 17.31 0 012.148.152c5.305.725 10.986 2.62 20.07 16.506l.018.025.016.026c12.691 19.326 12.131 58.305-8.623 84.992l-.035.045-.036.045c-7.546 9.77-41.454 44.616-73.818 76.802-32.364 32.187-63.134 61.896-78.357 80.442-14.557 17.734-9.216 32.647-5.268 41.982 3.948 9.335 8.465 20.237 28.598 25.02 6.028 1.432 6.36 1.02 8.289 1.152 1.929.133 3.923.224 6.267.309 4.689.169 10.688.297 18.094.406 226.465 1.38 450.423-1.24 676.709-.92h.063c17.211 0 26.557 5.657 35.492 17.627 8.929 11.962 15.468 31.813 15.629 55.652.066 24.73-5.857 39.82-13.057 48.133-7.2 8.313-16.845 13.52-37.475 13.588H1030v70h484.791c66.478.006 101.54-.042 151.363 0 17.308.03 26.53 5.662 35.324 17.578 8.8 11.922 15.21 31.827 15.133 55.975v.002c-.08 25.822-5.346 41.196-11.375 48.545-6.029 7.349-14.638 12.732-39.482 12.902-8.43.058-68.808.014-93.863.043-.397-.005-.786-.042-1.184-.043-180.227-.85-360.455-.002-540.682-.002H1030l-.025 70h.025c.043 0 382.517.239 541.33.047 19.7.279 31.511 8.21 40.934 23.601 9.563 15.621 14.323 40.11 8.68 67.756v.028c-3.737 18.38-9.413 28.473-15.436 33.976-6.023 5.504-14.335 9.592-33.934 9.592-180.523-.086-361.044-.452-541.568 0h-.092l.092 70h409.414c14.707.096 21.247 4.008 27.96 12.977 6.715 8.968 12.44 25.642 12.132 49.652v.025c-.284 23.412-5.952 38.272-12.057 45.889-6.105 7.617-12.405 11.357-27.973 11.459-292.123 1.488-584.356 1.097-876.51 0h-.025c-73.053-.223-130.456-12.932-173-41.275-42.55-28.344-73.607-72.869-92.039-148.598l-.008-.03-.005-.029c-12.87-52.492-14.06-94.01-14.311-149.81v-.041c-.256-76.57-1.724-160.05 19.146-226.408 21.392-67.802 55.988-119.253 105.512-153.256l.004-.002c72.125-49.505 398.23-275.66 488.5-334.12l.004-.001c8.476-5.465 15.5-7.79 20.719-8.303.87-.086 1.689-.122 2.457-.113z" fill="'+e+'" /></svg>',receive:"<svg "+m+' viewBox="10 10 20 20"><path fill="none" stroke="'+e+'" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.2" d="M12.5 15.313v9.374h15v-9.375zm0 0l7.5 5.624 7.5-5.625"/></svg>',script:"<svg "+m+' viewBox="0 0 2000 2000"><path d="M759.41 378l-8.262 4.904-2.699 1.604C631.658 453.72 551.284 517.185 498.23 579.16c-53.13 62.06-78.817 124.548-79.547 184.787-1.454 119.88 86.972 209.719 165.425 290.067 78.394 80.286 148.323 156.002 154.905 218.664 3.354 31.938-4.195 64.019-39.02 107.943-34.678 43.74-97.616 96.128-198.24 154.785L353.193 1622h916.854l10.85-6.313.011-.01c106.636-62.16 178.477-119.59 224.254-177.33 45.914-57.91 64.594-118.499 58.62-175.378-11.838-112.702-103.646-194.827-180.829-273.873-77.243-79.108-139.852-153.721-139-224.024.43-35.49 14.072-75.084 57.219-125.484 43.073-50.314 115.696-109.181 227.031-175.158v-.002L1674.045 378H759.41zm25.842 92.918h564.643c-49.73 37.078-89.049 72.898-119.307 108.242-53.13 62.06-78.817 124.548-79.547 184.787-1.453 119.882 86.977 209.72 165.43 290.067 78.393 80.286 148.316 156 154.898 218.664 3.355 31.938-4.193 64.019-39.017 107.943-33.397 42.123-93.456 92.386-187.79 148.461h-566.09c39.27-30.627 70.469-60.635 94.33-90.732 45.914-57.911 64.594-118.5 58.62-175.38-11.838-112.701-103.645-194.826-180.828-273.872-77.243-79.108-139.85-153.721-138.998-224.024.43-35.49 14.07-75.084 57.216-125.484 41.627-48.624 111.275-105.346 216.44-168.672zM653.13 629.393v42.92h441.398v-42.92H653.131zm-16.402 231.175v42.918h456.384v-42.918H636.73zm206.794 231.17v42.918h441.989v-42.918H843.523zm63.198 231.174v42.918h457.986v-42.918H906.721z" fill="'+e+'"/></svg>',send:"<svg "+m+' viewBox="10 10 20 20"><path fill="'+e+'" d="M12.5 14.344l7.5 5.625 7.5-5.625zm0 .937v9.375h15v-9.375L20 20.906z"/></svg>',service:"<svg "+m+' viewBox="0 0 2000 2000"><path d="M825.746 438.174c-.046 36.998.01 73.998.106 110.996-31.554 8.927-60.387 21.384-87.616 36.644l-79.582-78.625-148.806 149.668 79.576 78.612a393.526 393.526 0 00-35.752 87.242l-112.725.205v210.79l113.903-.411c10.416 41.298 33.084 78.425 55.662 111.623V963.094l-99.565.357V892.79l99.069-.18 5.56-28.172c8.11-41.084 24.17-80.249 47.244-115.292l15.785-23.973-69.603-68.762 50.094-50.385 69.73 68.893 23.73-15.836c36.264-23.926 75.929-39.963 115.481-48.316l27.96-5.805-.25-96.785h71.966l-.557 96.281h188.834c-17.713-21.144-91.12-48.658-118.508-56.324l.635-109.957c-78.4-.002-139.865.004-212.37-.002zm199.158 201.658l.287 110.992c-31.554 8.927-60.387 21.383-87.617 36.645l-79.584-78.625-148.806 149.668 79.578 78.611a393.515 393.515 0 00-35.754 87.244l-112.723.203v210.79l113.9-.409c8.966 31.257 21.395 59.8 36.626 86.746l-81.495 81.176 150.465 147.879 81.201-80.824c27.815 15.444 57.38 27.436 88.034 35.781l.052 114.713c72.392.634 149.467.307 211.336.3v-116.07c31.578-8.904 60.501-21.45 87.737-36.705l81.134 79.996 148.905-149.48-81.305-80.123a394.444 394.444 0 0035.799-87.399l110.379-.681v-210.586l-111.618.68c-8.972-31.287-21.22-59.637-36.654-86.762l77.121-77.319-150.38-148.13-77.022 77.285a398.637 398.637 0 00-87.68-35.639l.633-109.957h-212.549zm70.18 70h71.967l-.555 96.283 28.426 5.578c41.272 8.1 80.83 24.14 116.015 47.073l23.825 15.529 67.216-67.445 50.618 49.86-67.31 67.483 16.194 23.907c23.765 35.872 39.529 74.65 48.428 114.58l5.856 28.011 97.28-.591v70.59l-96.737.595-5.557 28.012a324.606 324.606 0 01-47.299 115.398l-15.803 24.006 71.258 70.223-50.086 50.28-71.265-70.266-23.69 15.738c-36.275 23.706-75.624 40.123-115.324 48.21l-28.144 5.622v102.215c-19.241.046-40.231.016-71.37-.028l-.045-101.449-28.271-5.521c-41.33-8.071-80.823-24.038-115.947-47.067l-23.754-15.574-71.541 71.21-50.625-49.757 71.64-71.361-16.347-24.004c-23.787-35.794-39.523-74.612-48.438-114.496l-5.85-27.926-99.564.355v-70.66l99.069-.181 5.56-28.168c8.11-41.085 24.17-80.252 47.244-115.295l15.785-23.975-69.605-68.762 50.094-50.384 69.732 68.892 23.73-15.834c36.31-23.77 74.841-39.541 115.481-48.314l27.96-5.805-.251-96.787zm37.166 257.203c-86.647 0-157.639 70.994-157.639 157.64 0 86.648 70.992 157.638 157.639 157.638s157.639-70.99 157.639-157.637-70.992-157.64-157.639-157.64zm0 70c48.816 0 87.639 38.825 87.639 87.64 0 48.817-38.823 87.638-87.639 87.638-48.816 0-87.637-38.821-87.637-87.637s38.82-87.64 87.637-87.64z" fill="'+e+'"/></svg>',user:"<svg "+m+' viewBox="0 0 2000 2000"><path d="M991.75 365c-177.277 0-304.097 136.28-304.453 291.514v.088c.011 46.944 12.714 96.49 32.56 141.177 14.33 32.267 32.147 61.932 53.858 85.696-129.03 44.143-280.193 116.795-356.598 260.054L413 1151.25V1615h1157.5v-463.75l-4.117-7.72c-75.306-141.2-223.199-213.75-350.98-258.077 62.379-63.433 80.78-145.306 80.8-228.851v-.088C1295.847 501.28 1169.027 365 991.75 365zM870.709 530.299c8.194.02 17.191.294 27.11.879 79.022 4.657 105.618 18.882 126.062 32.373 20.443 13.49 34.855 26.333 88.883 27.908h.034c42.101-1.575 62.349-9.081 76.869-17.584 5.884-3.445 10.824-7.027 15.887-10.447 13.38 28.682 20.567 60.389 20.648 93.203-.028 93.44-16.092 158.876-101.768 212.424l8.381 63.17c17.833 5.415 36.266 11.357 54.975 17.873 2.613 10.9 5.632 25.196 7.662 40.394 2.127 15.923 2.964 32.489 1.652 44.928-1.311 12.439-5.173 19.154-5.851 19.832-43.547 43.547-120.847 68.943-199.252 68.943-78.406 0-155.705-25.396-199.252-68.943-.678-.678-4.54-7.393-5.852-19.832-1.311-12.439-.475-29.005 1.653-44.928 2.041-15.282 5.084-29.662 7.707-40.584 18.522-6.44 36.77-12.32 54.43-17.683l4.995-67.688c-4.068-5.217-8.213-8.673-13.16-12.385-19.121-14.345-42.31-45.903-58.69-82.785-16.373-36.868-26.517-79.01-26.532-112.744.101-40.444 10.985-79.211 30.976-112.697 3.577-1.332 7.349-2.739 11.588-4.133 14.908-4.903 35.337-9.583 70.846-9.494zM719.361 979.855c-.063.46-.133.907-.195 1.368-2.587 19.363-4.107 40.44-1.883 61.537 2.224 21.096 7.79 43.81 25.969 61.988 62.048 62.048 155.95 89.447 248.748 89.447 92.797 0 186.7-27.4 248.748-89.447 18.178-18.178 23.745-40.892 25.969-61.988 2.224-21.097.704-42.174-1.883-61.537-.051-.382-.11-.753-.162-1.133 94.334 41.369 185.515 100.615 235.828 189.074V1545H1333v-265h-70v265H719v-265h-70v265H483v-375.836c50.408-88.626 141.838-147.93 236.361-189.309z" fill="'+e+'" fill-rule="evenodd"/></svg>'};if(t=void 0===t?!1:t)return i;var n={};return Object.keys(i).forEach(function(t){n[t]="data:image/svg+xml,"+encodeURIComponent(i[t])}),n}({color:"${color}",svg:!0});function Xo(s){return function(t,e,i,n){switch(t){case"double":var r=e.clone().inflate(-3),o=n.fill;return void 0===o&&(o="none"),{d:s(e,n,0)+" "+s(r,n,3),fill:o};case"thick":r=e.clone().inflate(-3),o=n.stroke;return void 0===o&&(o="black"),{d:s(e,n,0)+" "+s(r,n,3),fill:o};default:return{d:s(e,n,0),fill:"none"}}}}function Jo(t,e,i,n){switch(t){case"dashed":var r=e.width,o=e.height,r=Math.floor(Math.min(r,o)/20),s=4*r+","+r;break;case"dotted":o=n.strokeWidth||n["stroke-width"];s=o+","+2*o;break;default:s="none"}return{"stroke-dasharray":s}}function $o(t,e,i){var i=(i=void 0===i?{}:i)[t];return{"xlink:href":"string"==typeof i?(e=e.iconColor,i=i.replace(/\${color}/g,e=void 0===e?"black":e),"data:image/svg+xml,"+encodeURIComponent(i)):null,"data-icon-type":t}}function Qo(r){return function(t,e,i,n){return $o(t,n,this.model.constructor[r])}}var Ko="row",qo="column",ts={topLeft:"left-top",bottomLeft:"left-bottom",topRight:"right-top",bottomRight:"right-bottom",topMiddle:"top",bottomMiddle:"bottom",rightMiddle:"right",leftMiddle:"left",center:"center"},es=Object.keys(ts).reduce(function(t,e){return t[ts[e]]=e,t},{});function is(d){return function(t,e,i,r){var o=this,n=w(i),s="joint-icons",a=n.data(s.toString()),l=r.iconColor,h=(void 0===l&&(l="#333333"),r.iconSize),c=(void 0===h&&(h=30),r.iconsFlow),l=(void 0===c&&(c=Ko),t.toString()+" "+l+" "+h+" "+c);if(a!==l){var a=B(i),u=(a.empty(),c===qo);if(!Array.isArray(t))return;i=t.map(function(t,e){var i,n=B("image");return n.attr($o(t,r,o.model.constructor[d])),t=u?(i=0,e*h):(i=e*h,0),n.attr({x:i,y:t,width:h,height:h}),n});a.append(i)}n.data(s,l)}}function ns(t,e,i,n){var r,o=n.iconSize,s=(void 0===o&&(o=30),n.iconsFlow),n=(void 0===s&&(s=Ko),n.iconsOrigin),t=(void 0===n&&(n=ts.topLeft),Array.isArray(t)?t.length:0),s=s===qo?t*(r=o):(r=t*o,o),t=new tt(0,0,-r,-s);return n in es?t[es[n]]():t.center()}function rs(t,e,i,n,r,o,s){var a,l=ui(n),h=ei(n.labelMargin),c=h.left,u=h.right,d=h.top,h=h.bottom,n=ss[n.labelAlignment],r=new tt(c,d,r-c-u,o-d-h);return n&&(l.textAnchor=n["text-anchor"],l.textVerticalAnchor=n["text-vertical-anchor"]),c=e.textWrap?(a="textWrap",{text:s,ellipsis:e.ellipsis}):(a="text",s),t.getAttributeDefinition(a).set.call(t,c,r,i,l),n}var os=ui(ts),ss={"left-top":{"text-anchor":"start","text-vertical-anchor":"top"},"left-bottom":{"text-anchor":"start","text-vertical-anchor":"bottom"},"right-top":{"text-anchor":"end","text-vertical-anchor":"top"},"right-bottom":{"text-anchor":"end","text-vertical-anchor":"bottom"},top:{"text-anchor":"middle","text-vertical-anchor":"top"},bottom:{"text-anchor":"middle","text-vertical-anchor":"bottom"},right:{"text-anchor":"end","text-vertical-anchor":"middle"},left:{"text-anchor":"start","text-vertical-anchor":"middle"},center:{"text-anchor":"middle","text-vertical-anchor":"middle"}},Go=r.define("bpmn2.Event",{size:{width:40,height:40},attrs:{root:{magnetSelector:"background",highlighterSelector:"background"},background:{refCx:"50%",refCy:"50%",refRx:"50%",refRy:"50%",fill:"#FFFFFF"},border:{stroke:"#333333",fillRule:"evenodd",borderType:"single",borderStyle:"solid",strokeWidth:2},icon:{iconColor:"#333333",iconType:"none",refX:"15%",refY:"15%",refWidth:"70%",refHeight:"70%"},label:{refDy:10,refX:"50%",textVerticalAnchor:"top",textAnchor:"middle",fontSize:12,fontFamily:"sans-serif",fontWeight:"bold"}}},{markup:[{tagName:"ellipse",selector:"background"},{tagName:"image",selector:"icon"},{tagName:"path",selector:"border"},{tagName:"text",selector:"label"}]},{attributes:{borderType:{set:Xo(function(t){return e=(t=t).center(),e=B("ellipse",{cx:e.x,cy:e.y,rx:t.width/2,ry:t.height/2}),B.convertEllipseToPathData(e);var e})},borderStyle:{set:Jo},iconType:{set:Qo("EVENT_ICONS")}},EVENT_ICONS:To});var zo=r.define("bpmn2.Gateway",{size:{width:58,height:58},attrs:{root:{magnetSelector:"body",highlighterSelector:"body"},body:{refPoints:"1,0,2,1,1,2,0,1",fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},icon:{iconColor:"#333333",refX:"19%",refY:"19%",refWidth:"62%",refHeight:"62%"},label:{refDy:10,refX:"50%",textVerticalAnchor:"top",textAnchor:"middle",fontSize:12,fontFamily:"sans-serif",fontWeight:"bold"}}},{markup:[{tagName:"polygon",selector:"body"},{tagName:"image",selector:"icon"},{tagName:"text",selector:"label"}]},{attributes:{iconType:{set:Qo("GATEWAY_ICONS")}},GATEWAY_ICONS:Lo}),Oo=r.define("bpmn2.DataStore",{size:{width:63,height:63},attrs:{root:{magnetSelector:"body",highlighterSelector:"body"},body:{lateralArea:10,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},top:{refCx:"50%",cy:10,refRx:"50%",ry:10,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},label:{textVerticalAnchor:"top",textAnchor:"middle",refX:"50%",refY:"100%",refY2:10,fontSize:12,fontFamily:"sans-serif",fontWeight:"bold",fill:"#333333",textWrap:{width:"200%"}}}},{markup:[{tagName:"path",selector:"body"},{tagName:"ellipse",selector:"top"},{tagName:"text",selector:"label"}],topRy:function(t,e){if(void 0===t)return this.attr("body/lateralArea");var i=ti(t);return this.attr({body:{lateralArea:t},top:i?{refCy:t,refRy:t,cy:null,ry:null}:{refCy:null,refRy:null,cy:t,ry:t},label:{refY2:t}},e)}},{attributes:{lateralArea:{set:function(t,e){var i=ti(t),n=(i&&(t=parseFloat(t)/100),e.x),r=e.y,o=e.width,e=e.height,s=i?e*t:t,a=B.KAPPA,l=a*(o/2),a=a*(i?e*t:t),i=n,t=n+o/2,o=n+o,h=r+s,c=h-s,u=r+e-s,r=r+e,e=["M",i,h,"L",i,u,"C",n,u+a,t-l,r,t,r,"C",t+l,r,o,u+a,o,u,"L",o,h,"C",o,h-a,t+l,c,t,c,"C",t-l,c,i,h-a,i,h,"Z"],n=h+7,r=h+s+7;return e.push("M",o,n,"C",o,n+a,t+l,r,t,r,"C",t-l,r,i,n+a,i,n),e.push("L",i,n+=7,"C",i,n+a,t-l,r+=7,t,r,"C",t+l,r,o,n+a,o,n,"Z"),{d:e.join(" ")}}}}}),Ro=r.define("bpmn2.DataObject",{size:{width:48,height:65},attrs:{root:{magnetSelector:"body",highlighterSelector:"body"},body:{objectD:10,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},label:{refY:"100%",refY2:10,refX:"50%",textVerticalAnchor:"top",textAnchor:"middle",fontSize:12,fontFamily:"sans-serif",fontWeight:"bold",textWrap:{width:"200%"}},dataTypeIcon:{iconColor:"#333333",iconType:"none",x:0,y:0,width:25,height:25},collectionIcon:{iconColor:"#333333",collection:!1,refX:"50%",refY:"100%",y:-18,x:-6,width:16,height:16}}},{markup:[{tagName:"path",selector:"body"},{tagName:"text",selector:"label"},{tagName:"image",selector:"dataTypeIcon"},{tagName:"image",selector:"collectionIcon"}]},{attributes:{objectD:{set:function(t,e){var i=e.topLeft(),n=e.bottomLeft(),r=e.bottomRight(),e=e.topRight(),o=e.clone().offset(-t,t),s=e.clone().offset(0,t),e=e.clone().offset(-t,0);return{d:"M "+i.serialize()+" "+n.serialize()+" "+r.serialize()+" "+s.serialize()+" "+e.serialize()+" Z"+" "+("M "+e.serialize()+" "+o.serialize()+" "+s.serialize())}}},iconType:{set:Qo("DATA_OBJECT_TYPE_ICONS")},collection:{set:Qo("DATA_OBJECT_COLLECTION_ICONS")}},DATA_OBJECT_TYPE_ICONS:{none:null,input:To.link1,output:To.link2},DATA_OBJECT_COLLECTION_ICONS:{false:null,true:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="-3 -3 16 16"><path fill="none" stroke="${color}" stroke-width="2" d="M0 0v10M3 0v10M6 0v10"/></svg>'}}),Vo={markup:[{tagName:"rect",selector:"body"},{tagName:"text",selector:"label"}],attrs:{label:{fill:"#333333",fontSize:12,textAnchor:"middle",textVerticalAnchor:"middle",fontFamily:"sans-serif"},body:{ref:"label",fill:"#ffffff",stroke:"none",refX:0,refY:0,refWidth:"100%",refHeight:"100%"}},position:{distance:.5}},jo=u.define("bpmn2.DataAssociation",{attrs:{line:{connection:!0,stroke:"#333333",strokeWidth:2,strokeLinejoin:"round",strokeDasharray:"2,5",targetMarker:{type:"path",d:"M 10 -7 0 0 10 7","stroke-width":2,fill:"none"}},wrapper:{connection:!0,strokeWidth:10,strokeLinejoin:"round"}}},{defaultLabel:Vo,markup:[{tagName:"path",selector:"wrapper",attributes:{fill:"none",cursor:"pointer",stroke:"transparent","stroke-linecap":"round"}},{tagName:"path",selector:"line",attributes:{fill:"none","pointer-events":"none"}}]}),_o=r.define("bpmn2.Activity",{size:{width:120,height:100},attrs:{root:{magnetSelector:"background",highlighterSelector:"background"},background:{refWidth:"100%",refHeight:"100%",fill:"#FFFFFF",rx:10,ry:10},border:{stroke:"#333333",fillRule:"evenodd",borderType:"single",borderStyle:"solid",borderRadius:10,strokeWidth:2},icon:{iconColor:"#333333",iconType:"none",x:5,y:0,width:30,height:30},label:{refY:"50%",refX:"50%",textVerticalAnchor:"middle",textAnchor:"middle",fontSize:12,fontFamily:"sans-serif",fontWeight:"bold",textWrap:{width:-10,height:-50,ellipsis:!0}},markers:{event:"element:marker:pointerdown",iconSize:16,iconColor:"#333333",iconTypes:[""],iconsOrigin:ts.bottomMiddle,iconsFlow:Ko,refX:"50%",refY:"100%",refY2:-5}}},{markup:[{tagName:"rect",selector:"background"},{tagName:"image",selector:"icon"},{tagName:"path",selector:"border"},{tagName:"text",selector:"label"},{tagName:"g",selector:"markers"}]},{attributes:{borderType:{set:Xo(function(t,e,i){e=e.borderRadius,void 0===e&&(e=0),e=Math.max(Math.min(e,2),e-i),i=t.toJSON();return i.rx=i.ry=e,B.rectToPath(i)})},borderStyle:{set:Jo},iconType:{set:Qo("ACTIVITY_TYPE_ICONS")},iconTypes:{set:is("ACTIVITY_MARKER_ICONS"),position:ns},iconSize:{},iconsOrigin:{},iconsFlow:{},iconColor:{},borderRadius:{}},ACTIVITY_TYPE_ICONS:Bo,ACTIVITY_MARKER_ICONS:Si(Do,"none")}),e=r.define("bpmn2.Conversation",{size:{width:58,height:47},attrs:{root:{magnetSelector:"body",highlighterSelector:"body"},body:{fill:"#FFFFFF",stroke:"#333333",refPoints:"1,0 3,0, 4,1 3,2 1,2 0,1, 1,0",strokeLinejoin:"round",strokeWidth:2},markers:{event:"element:marker:pointerdown",iconSize:16,iconColor:"#333333",iconTypes:[],iconsOrigin:ts.bottomMiddle,iconsFlow:Ko,refX:"50%",refY:"100%"},label:{refDy:10,refX:"50%",textVerticalAnchor:"top",textAnchor:"middle",fontSize:12,fontFamily:"sans-serif",fontWeight:"bold"}}},{markup:[{tagName:"polygon",selector:"body"},{tagName:"text",selector:"label"},{tagName:"g",selector:"markers"}]},{attributes:{iconTypes:{set:is("CONVERSATION_MARKER_ICONS"),position:ns},iconSize:{},iconsOrigin:{},iconsFlow:{},iconColor:{}},CONVERSATION_MARKER_ICONS:Si(Do,"none")}),Zo=u.define("bpmn2.ConversationLink",{attrs:{line:{connection:!0,stroke:"#FFFFFF",strokeWidth:2,strokeLinejoin:"round"},outline:{connection:!0,stroke:"#333333",strokeWidth:6,strokeLinejoin:"round"},wrapper:{connection:!0,strokeWidth:10,strokeLinejoin:"round"}}},{defaultLabel:Vo,markup:[{tagName:"path",selector:"wrapper",attributes:{fill:"none",cursor:"pointer",stroke:"transparent","stroke-linecap":"round"}},{tagName:"path",selector:"outline",attributes:{fill:"none","pointer-events":"none"}},{tagName:"path",selector:"line",attributes:{fill:"none","pointer-events":"none"}}]}),as=nn.sourceMarker.set,ls=nn.targetMarker.set,hs={sequence:"sequence",default:"default",conditional:"conditional",message:"message"},ko=u.define("bpmn2.Flow",{attrs:{line:{connection:!0,stroke:"#333333",strokeWidth:2,strokeLinejoin:"round",flowType:"sequence"},wrapper:{connection:!0,strokeWidth:10,strokeLinejoin:"round"}}},{defaultLabel:Vo,markup:[{tagName:"path",selector:"wrapper",attributes:{fill:"none",cursor:"pointer",stroke:"transparent","stroke-linecap":"round"}},{tagName:"path",selector:"line",attributes:{fill:"none","pointer-events":"none"}}]},{attributes:{flowType:{set:function(t,e,i,n){var r,o,s=n.markerFill,a=(void 0===s&&(s="#FFFFFF"),n.strokeWidth),l=(void 0===a&&(a=2),{"stroke-dasharray":"none","marker-start":null,"marker-end":null});switch(t){case hs.default:r={d:"M 5 -5 15 5","stroke-width":a},o={type:"path",d:"M 12 -5 0 0 12 5 z"};break;case hs.conditional:r={d:"M 0 0 9 -5 18 0 9 5 Z","stroke-width":a,fill:s},o={type:"path",d:"M 12 -5 0 0 12 5 z"};break;case hs.message:l["stroke-dasharray"]="5,2",r={type:"circle",cx:5,r:5,"stroke-width":a,fill:s},o={type:"path",d:"M 12 -5 0 0 12 5 z","stroke-width":a,fill:s};break;default:o={type:"path",d:"M 12 -5 0 0 12 5 z"}}return r&&R(l,as.call(this,r,e,i,n)),o&&R(l,ls.call(this,o,e,i,n)),l}},markerFill:{}},FLOW_TYPES:hs}),Io=r.define("bpmn2.Group",{size:{width:120,height:100},attrs:{root:{magnetSelector:"body",highlighterSelector:"body"},body:{refWidth:"100%",refHeight:"100%",fill:"transparent",rx:10,ry:10,stroke:"#333333",borderStyle:"dashed",strokeWidth:2,strokeLinecap:"square",pointerEvents:"none"},wrapper:{refX:5,refY:5,refWidth:-10,refHeight:-10,pointerEvents:"stroke",strokeWidth:10,stroke:"transparent",fill:"none"},label:{refY:6,refX:"50%",textAnchor:"middle",fontSize:12,fontFamily:"sans-serif",fontWeight:"bold",textWrap:{width:-12,height:-12,ellipsis:!0}}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"rect",selector:"wrapper"},{tagName:"text",selector:"label"}]},{attributes:{borderStyle:{set:function(t,e,i,n){n=n.strokeWidth||n["stroke-width"]||1;return{"stroke-dasharray":2*n+","+2*n+","+n/2}}}}}),Lo=r.define("bpmn2.Annotation",{size:{width:80,height:40},attrs:{root:{magnetSelector:"body",highlighterSelector:"body"},body:{refWidth:"100%",refHeight:"100%",fill:"transparent"},border:{annotationD:{size:10},fill:"none",stroke:"#333333",strokeWidth:2},label:{refY:6,refX:4,fontSize:12,fontFamily:"sans-serif",textWrap:{width:-12,height:-12,ellipsis:!0}}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"path",selector:"border"},{tagName:"text",selector:"label"}]},{attributes:{annotationD:{set:function(t,e){var i=t.size||0,t=t.side,n=e.topLeft(),r=e.bottomLeft(),o=e.topRight(),s=e.bottomRight();switch(t){case"top":var a=n.clone().offset(0,i),l=o.clone().offset(0,i);return{d:"M "+a.serialize()+" "+n.serialize()+" "+o.serialize()+" "+l.serialize()};case"right":a=o.clone().offset(-i,0),l=s.clone().offset(-i,0);return{d:"M "+a.serialize()+" "+o.serialize()+" "+s.serialize()+" "+l.serialize()};case"bottom":a=r.clone().offset(0,-i),l=s.clone().offset(0,-i);return{d:"M "+a.serialize()+" "+r.serialize()+" "+s.serialize()+" "+l.serialize()};default:a=n.clone().offset(i,0),l=r.clone().offset(i,0);return{d:"M "+a.serialize()+" "+n.serialize()+" "+r.serialize()+" "+l.serialize()}}}}}}),To=u.define("bpmn2.AnnotationLink",{attrs:{line:{connection:!0,stroke:"#333333",strokeWidth:2,strokeLinejoin:"round",strokeDasharray:"2,5"},wrapper:{connection:!0,strokeWidth:10,strokeLinejoin:"round"}}},{defaultLabel:Vo,markup:[{tagName:"path",selector:"wrapper",attributes:{fill:"none",cursor:"pointer",stroke:"transparent","stroke-linecap":"round"}},{tagName:"path",selector:"line",attributes:{fill:"none","pointer-events":"none"}}]}),Bo=r.define("bpmn2.Pool",{size:{width:600,height:300},lanes:null,milestones:null,milestonesSize:20,padding:0,headerSize:20,attrs:{body:{refWidth:"100%",refHeight:"100%",fill:"transparent"},laneGroups:{laneContainerPosition:!0},laneHeaders:{fill:"#ffffff",stroke:"#333333",strokeWidth:2,headerSize:!0,shapeRendering:"optimizespeed"},laneLabels:{fontSize:14,fill:"#333333",transform:"rotate(-90)",textAnchor:"middle",textVerticalAnchor:"middle",labelAlignment:os.center,labelMargin:{vertical:2,horizontal:10},fontFamily:"sans-serif",labelPosition:!0,laneLabel:{textWrap:!0,ellipsis:!0}},lanes:{stroke:"#333333",strokeWidth:2,fill:"#ffffff",laneSize:!0,shapeRendering:"optimizespeed"},milestoneGroups:{milestoneContainerPosition:!0},milestoneHeaders:{fill:"#ffffff",stroke:"#333333",strokeWidth:2,milestoneHeaderSize:!0,shapeRendering:"optimizespeed"},milestoneLabels:{fontSize:14,fill:"#333333",labelMargin:{vertical:2,horizontal:10},fontFamily:"sans-serif",textAnchor:"end",textVerticalAnchor:"middle",labelAlignment:os.rightMiddle,milestoneLabelPosition:!0,milestoneLabel:{textWrap:!0,ellipsis:!0}},milestoneLines:{stroke:"#333333",strokeWidth:2,milestoneLinePosition:!0,shapeRendering:"optimizespeed"}}},{metrics:null,markup:[{tagName:"rect",selector:"body"}],markupAttributes:["lanes","padding","milestones","headerSize","milestonesSize"],initialize:function(){r.prototype.initialize.apply(this,arguments),this.on("change",this.onChange,this),this.buildMarkup()},anyHasChanged:function(t){return!!Array.isArray(t)&&t.some(function(t){return this.hasChanged(t)},this)},onChange:function(t,e){e.pool!==this.id&&this.hasChanged("markup")&&cs("Markup cannot be modified."),this.anyHasChanged(this.markupAttributes)&&this.buildMarkup(e)},buildMarkup:function(t){var e=di(this.markup),i=(Array.isArray(e)||cs("Expects Prototype JSON Markup."),this.attributes.lanes||[{}]),n=(Array.isArray(i)||cs("Expects lanes to be an array."),this.attributes.milestones||[]),r=(Array.isArray(n)||cs("Expects milestones to be an array."),this.metrics={}),r=(r.lanes={},r.lanesNameCache={},r.milestonesNameCache={},r.milestones={},r.totalTakenHeightSpace=0,r.topLaneGroupsCount=i.length,r.padding=ei(this.attributes.padding),this.buildLanesMarkupRecursively(i,e,"",1,0),this.buildMilestones(n,e),R({pool:this.id,dry:!0},t));this.set("markup",e,r),!1!==r.autoResize&&this.autoresize(r)},buildLanesMarkupRecursively:function(t,d,g,p,f){var m=this,v=(Array.isArray(t)||cs("Expects lanes to be an array."),0);return t.forEach(function(t,e){var i,n=0,r=t.id,o=g?g+"_"+e:""+e,s=m.getLaneGroupMarkup(o,r),a=(d.push(s),Number.isFinite(t.size)?Math.max(t.size,0):void 0),l=m.getLaneMarkup(o,r),l=(s.children.push(l),t.label),h="string"==typeof t.label,c=h?Number.isFinite(t.headerSize)?Math.max(t.headerSize,0):m.attributes.headerSize:0,u=(h&&(u=m.getHeaderMarkup(o,r),i=m.getLabelMarkup(o,r),s.children.push(u),s.children.push(i)),t.sublanes&&!Array.isArray(t.sublanes)&&cs("Expects sublanes to be an array."),t.sublanes||[]),t=(u.length&&(i=s.children,n=m.buildLanesMarkupRecursively(u,i,o,p+1,u.length)),v+=n=a&&n<a?a:n,{nestLevel:p,laneIndexWithinGroup:e,parentId:g?"lanes_"+g:"",parentSublanesCount:f,headerSize:c,label:l,hasLabel:h,size:a,takenUpSpaceByLaneAndSublanes:n,sublanesCount:u.length,name:r});m.addLaneGroupMetrics(o,t)}),v},buildMilestones:function(t,l){var h=this,c=this.metrics,e=this.attributes,i=c.padding;c.milestonesCount=t.length,i.top+=t.length?e.milestonesSize:0,t.forEach(function(t,e){var i=t.id,n="milestone_"+e,r=void 0!==c.milestonesNameCache[n],o=(i&&(o=i!==n&&void 0!==c.milestones[i],void 0===c.milestonesNameCache[i]&&!o||cs("Duplicated milestone group id: "+i),c.milestonesNameCache[i]=n),r&&cs("Duplicated milestone group id: "+n),h.getMilestoneGroupMarkup(e,i)),r=(l.push(o),h.getMilestoneHeaderMarkup(e,i)),s=h.getMilestoneLabelMarkup(e,i),a=h.getMilestoneLineMarkup(e,i);c.milestones[n]={label:"string"==typeof t.label?t.label:"",indexWithin:e,size:Number.isFinite(t.size)?Math.max(t.size,0):void 0,name:i},o.children.push(a),o.children.push(r),o.children.push(s)})},addLaneGroupMetrics:function(t,e){var i,t="lanes_"+t,n=e.laneSize,r=e.name,o=this.metrics;void 0!==o.lanesNameCache[t]&&cs("Duplicated lane group id: "+t),r&&(i=r!==t&&void 0!==o.lanes[r],void 0===o.lanesNameCache[r]&&!i||cs("Duplicated lane group id: "+r),o.lanesNameCache[r]=t),o.lanes[t]=e,Number.isFinite(n)&&(o.totalTakenHeightSpace+=n)},autoresize:function(t){var e=this.getMinimalSize(),i=this.attributes.size;this.resize(Math.max(e.width,i.width),Math.max(e.height,i.height),t)},getMinimalSize:function(){var t,o=this.metrics,e=o.padding,s=0,a=0,i=0,n=this.attributes.milestonesSize,l=o.lanes,r=o.milestones;return Object.keys(l).forEach(function(t){for(var e=l[t],i=t,n=0;i;){var r=o.lanes[i];n+=r.headerSize||0,i=r.parentId}s=s<n?n:s,1===e.nestLevel&&(a+=e.takenUpSpaceByLaneAndSublanes||0)}),Object.keys(r).forEach(function(t){i+=r[t].size||0}),t=i<s?s:i,{height:(o.milestonesCount&&a<n?0:a)+e.top+e.bottom,width:t+e.left+e.right}},getLaneGroupMarkup:function(t,e){var i=["laneGroups"];return e&&i.push("lanes_"+e),{tagName:"g",selector:"lanes_"+t,groupSelector:i,attributes:{laneGroupId:"lanes_"+t},children:[]}},getMilestoneGroupMarkup:function(t,e){var i=["milestoneGroups"];return e&&i.push("milestone_"+e),{tagName:"g",selector:"milestone_"+t,groupSelector:i,attributes:{milestoneGroupId:"milestone_"+t},children:[]}},getLaneMarkup:function(t,e){var i=["lanes"];return e&&i.push("lane_"+e),{tagName:"rect",selector:"lane_"+t,groupSelector:i,children:[],attributes:{laneGroupId:"lanes_"+t}}},getHeaderMarkup:function(t,e){var i=["laneHeaders"];return e&&i.push("header_"+e),{tagName:"rect",selector:"header_"+t,groupSelector:i,attributes:{laneGroupId:"lanes_"+t}}},getLabelMarkup:function(t,e){var i=["laneLabels"];return e&&i.push("label_"+e),{tagName:"text",selector:"label_"+t,groupSelector:i,attributes:{laneGroupId:"lanes_"+t}}},getMilestoneHeaderMarkup:function(t,e){var i=["milestoneHeaders"];return e&&i.push("milestoneHeader_"+e),{tagName:"rect",selector:"milestoneHeader_"+t,groupSelector:i,attributes:{milestoneGroupId:"milestone_"+t}}},getMilestoneLabelMarkup:function(t,e){var i=["milestoneLabels"];return e&&i.push("milestoneLabel_"+e),{tagName:"text",selector:"milestoneLabel_"+t,groupSelector:i,attributes:{milestoneGroupId:"milestone_"+t}}},getMilestoneLineMarkup:function(t,e){var i=["milestoneLines"];return e&&i.push("milestoneLine_"+e),{tagName:"line",selector:"milestoneLine_"+t,groupSelector:i,attributes:{milestoneGroupId:"milestone_"+t}}},getParentIndexesArray:function(t){for(var e=[],i=t;i;){e.push(i);i=this.metrics.lanes[i].parentId}return e.reverse()},getFlexAndFixedLaneSizesWithinGroup:function(t){var e=this.metrics,t=e.lanes[t],i=t.parentId,n=0,r=0,o=t.parentSublanesCount-1;for(i||(i="lanes",o=e.topLaneGroupsCount-1);0<=o;){var s=e.lanes[i+"_"+o];Number.isFinite(s.size)?n+=Math.max(s.size,s.takenUpSpaceByLaneAndSublanes):r++,o--}return{totalFixedSize:n,flexLanesWithinGroupCount:r}},getLaneWidth:function(t){var e=this.metrics,i=e.padding,t=this.getParentIndexesArray(t),i=this.attributes.size.width-i.left-i.right,n=0;return t.forEach(function(t){t=e.lanes[t];n+=t.headerSize}),Math.max(i-n,0)},getLaneHeight:function(c){var u=this,d=this.metrics,t=d.lanes[c],e=d.padding,i=this.getParentIndexesArray(c),n=this.attributes.size.height-e.top-e.bottom,r=t.parentId,g=n;if(r){var n=d.lanes[r].sublanesCount;if(t.laneIndexWithinGroup===n-1)return n=this.getLaneContainerPosition(c).y,o=this.getLaneHeight(r),Math.max(o-n,0)}if(Number.isFinite(t.size))return r||t.laneIndexWithinGroup!==d.topLaneGroupsCount-1?(o=t.takenUpSpaceByLaneAndSublanes,Math.max(o,t.size,0)):(n=this.getLaneContainerPosition(c).y,Math.max(this.attributes.size.height-n-e.bottom,0));var r=i.map(function(t){return t}).reverse().find(function(t){return d.lanes[t].size}),e=(r&&(n=(o=i.map(function(t){return t})).indexOf(r),i=o.slice(n+1),g=d.lanes[r].size),i.forEach(function(t){for(var e=u.getFlexAndFixedLaneSizesWithinGroup(t),i=d.lanes[t].parentId,t=d.lanes[t].parentSublanesCount,n=d.topLaneGroupsCount,r=0,o=0,s=(g-e.totalFixedSize)/(e.flexLanesWithinGroupCount||1),a=i?t-1:n-1;0<=a;){var l,h=(i||"lanes")+"_"+a;h===c?a--:(l=(h=d.lanes[h]).takenUpSpaceByLaneAndSublanes,!h.size&&s<l&&(r+=l,o++),a--)}g=(g-=e.totalFixedSize+r)/Math.max(e.flexLanesWithinGroupCount-o,1)}),t.takenUpSpaceByLaneAndSublanes),o=g<e?e:g;return Math.max(o,0)},getMilestoneWidth:function(t){var e=this.metrics,i=e.padding,i=this.attributes.size.width-i.left-i.right,t=e.milestones[t],n=e.milestonesCount;if(Number.isFinite(t.size))return t.size;for(var r=n-1,o=0,s=0;0<=r;){var a=e.milestones["milestone_"+r];Number.isFinite(a.size)&&(o+=a.size,s++),r--}return Math.max((i-o)/(n-s||1),0)},getLaneContainerPosition:function(t){for(var e=this.metrics,i=e.padding,t=e.lanes[t],n=t.laneIndexWithinGroup,r=t.nestLevel,o=t.parentId,t=o?e.lanes[o].headerSize:0,e=0,s=(1===r&&(t+=i.left,e+=i.top),0),a=n-1;0<=a;)s+=this.getLaneHeight(o?o+"_"+a:"lanes_"+a),a--;return new z(t,e+s)},getMilestoneContainerPosition:function(t){for(var e=this.metrics,t=e.milestones[t].indexWithin,e=e.padding,i=t-1,n=0;0<=i;)n+=this.getMilestoneWidth("milestone_"+i),i--;var t=this.attributes.milestonesSize,r=n+e.left,e=e.top-t;return new z(r,e)},getLaneBBox:function(t){"string"!=typeof t&&cs("Expects id to be a string");var e=this.metrics,i=this.position(),n=e.lanes[t];if(n||(t=e.lanesNameCache[t],n=e.lanes[t]),!n)return null;var e=n.parentId,n=n.headerSize,r={x:0,y:0},e=(e&&(e=this.getLaneBBox(e),r.x+=e.x-i.x,r.y+=e.y-i.y),this.getLaneContainerPosition(t)),o=e.x,e=e.y,s=this.getLaneWidth(t),t=this.getLaneHeight(t);return new tt({x:o+r.x+i.x,y:e+r.y+i.y,width:s+n,height:t})},getMilestoneBBox:function(t){"string"!=typeof t&&cs("Expects id to be a string");var e=this.metrics,i=this.attributes,n=e.padding,r=e.milestones;if(!(r[t]||r[t=e.milestonesNameCache[t]]))return null;var r=this.position(),e=this.getMilestoneWidth(t),o=i.milestonesSize,i=i.size.height-n.bottom-n.top+o,n=this.getMilestoneContainerPosition(t),o=n.x,t=n.y;return new tt(o+r.x,t+r.y,e,i)},getLanesFromPoint:function(t){var r=this,e=(t||cs("A point is required"),this.getBBox()),i=e.center(),n=this.angle(),o=new z(t).rotate(i,n);if(!e.containsPoint(o))return[];var s=this.metrics,a=s.lanes,l=[],h=function(t){for(var e=t?a[t].sublanesCount-1:s.topLaneGroupsCount-1;0<=e;){var i=t?t+"_"+e:"lanes_"+e;if(r.getLaneBBox(i).containsPoint(o)){var n=a[i].name;l.push(n||i),h(i);break}e--}};return h(),l.reverse()},getMilestoneFromPoint:function(t){t||cs("A point is required");var e=this.metrics,i=this.getBBox(),n=this.angle(),r=new z(t).rotate(i.center(),n);if(!i.containsPoint(r))return null;for(var o=e.milestonesCount-1;0<=o;){var s,a="milestone_"+o;if(this.getMilestoneBBox(a).containsPoint(r))return void 0===(s=e.milestones[a].name)?a:s;o--}return null},getLanePath:function(t){var e=this.metrics,i=e.lanes,n=i[t];if(void 0===(n=void 0===n?i[e.lanesNameCache[t]]:n))return[];for(var r=[n.laneIndexWithinGroup],o=n;o.parentId;){var s=i[o.parentId].laneIndexWithinGroup;r.unshift(s,"sublanes"),o=i[o.parentId]}return r.unshift("lanes"),r},toJSON:function(){var t=r.prototype.toJSON.apply(this,arguments);return delete t.markup,t}},{attributes:{laneContainerPosition:{position:function(t,e,i){i=i.getAttribute("laneGroupId");return this.model.getLaneContainerPosition(i)}},laneSize:{set:function(t,e,i){var n=this.model,i=i.getAttribute("laneGroupId"),r=n.getLaneWidth(i),o=n.getLaneHeight(i);return{width:r+n.metrics.lanes[i].headerSize,height:o}}},headerSize:{set:function(t,e,i){i=i.getAttribute("laneGroupId");return{width:this.model.metrics.lanes[i].headerSize,height:Math.max(this.model.getLaneHeight(i),0)}}},labelPosition:{position:function(t,e,i,n){var r=this.model,i=i.getAttribute("laneGroupId"),o=r.metrics.lanes[i].headerSize,s=r.getLaneHeight(i),r=ei(n.labelMargin),a=r.left,l=r.top,h=r.right,c=r.bottom,u=s/2,d=o/2;switch(n.labelAlignment){case os.topMiddle:return{x:l,y:u+a-h};case os.topLeft:return{x:l,y:s-h};case os.topRight:return{x:l,y:a};case os.leftMiddle:return{x:d+l-c,y:s-h};case os.rightMiddle:return{x:d+l-c,y:a};case os.bottomLeft:return{x:o-c,y:s-h};case os.bottomMiddle:return{x:o-c,y:u+a-h};case os.bottomRight:return{x:o-c,y:a};default:os.center;return{x:d+l-c,y:u+a-h}}}},laneLabel:{set:function(t,e,i,n){if(!fi(t))return null;var r=this.model,o=i.getAttribute("laneGroupId"),s=r.metrics.lanes[o],a=s.headerSize;return rs(this,t,i,n,r.getLaneHeight(o),a,s.label)}},milestoneContainerPosition:{position:function(t,e,i){i=i.getAttribute("milestoneGroupId");return this.model.getMilestoneContainerPosition(i)}},milestoneHeaderSize:{set:function(t,e,i){var n=this.model,i=i.getAttribute("milestoneGroupId");return{width:n.getMilestoneWidth(i),height:n.attributes.milestonesSize}}},milestoneLabelPosition:{position:function(t,e,i,n){var r=this.model,i=i.getAttribute("milestoneGroupId"),o=r.getMilestoneWidth(i),s=r.attributes.milestonesSize,i=ei(n.labelMargin),a=i.left,l=i.top,h=i.right,c=i.bottom,u=s/2,d=o/2;switch(n.labelAlignment){case os.topMiddle:return{x:d+a-h,y:l};case os.topLeft:return{x:a,y:l};case os.topRight:return{x:o-h,y:l};case os.leftMiddle:return{x:a,y:u+l-c};case os.bottomLeft:return{x:a,y:s-c};case os.bottomMiddle:return{x:d+a-h,y:s-c};case os.bottomRight:return{x:o-h,y:s-c};case os.rightMiddle:return{x:o-h,y:u+l-c};default:os.center;return{x:d+a-h,y:u+l-c}}}},milestoneLabel:{set:function(t,e,i,n){if(!fi(t))return null;var r=this.model,o=i.getAttribute("milestoneGroupId"),s=r.metrics.milestones[o];return rs(this,t,i,n,r.getMilestoneWidth(o),r.attributes.milestonesSize,s.label)}},milestoneLinePosition:{set:function(t,e,i){var n=this.model,r=n.position(),o=n.metrics.padding,s=n.attributes.milestonesSize,i=i.getAttribute("milestoneGroupId"),n=n.getMilestoneBBox(i),i=n.x,a=n.width,l="block";return{x1:a,x2:a,y1:s,y2:n.height,display:l=e.width-o.right<=Math.ceil(i)-r.x+Math.ceil(a)?"none":l}}},textVertical:{set:function(){return{transform:"rotate(-90)"}}},textWrap:{set:function(t,e,i,n){var r;n.textVertical&&(r=e.width,e.width=e.height,e.height=r),nn.textWrap.set.call(this,t,e,i,n)}},labelMargin:{},labelAlignment:{}}}),Do=Bo.define("bpmn2.HeaderedPool",{padding:{top:0,left:30,right:0,bottom:0},attrs:{header:{width:30,refHeight:"100%",stroke:"#333333",strokeWidth:2,fill:"#ffffff",shapeRendering:"optimizespeed"},headerLabel:{textVertical:!0,textWrap:{width:-10,ellipsis:!0,maxLineCount:1},refX:15,refY:"50%",fontSize:20,fill:"#333333",fontFamily:"sans-serif",textAnchor:"middle",textVerticalAnchor:"middle"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"rect",selector:"header"},{tagName:"text",selector:"headerLabel"}]}),Vo=Bo.prototype.markupAttributes.reduce(function(t,e){return t[e]=["UPDATE","TOOLS"],t},{}),Vo=g.extend({presentationAttributes:g.addPresentationAttributes(Vo)});function cs(t){throw new Error("shapes.bpmn2.Pool: "+t)}var Go={Event:Go,Gateway:zo,DataStore:Oo,DataObject:Ro,DataAssociation:jo,Activity:_o,Conversation:e,ConversationLink:Zo,Flow:ko,Group:Io,Annotation:Lo,AnnotationLink:To,Pool:Bo,HeaderedPool:Do,PoolView:Vo,HeaderedPoolView:Vo},us={exportElement:function(t){return t.size()},exportLink:function(t){var e=t.get("labelSize")||{};return{minLen:t.get("minLen")||1,weight:t.get("weight")||1,labelpos:t.get("labelPosition")||"c",labeloffset:t.get("labelOffset")||0,width:e.width||0,height:e.height||0}},importElement:function(t,e,i){var n=this.getCell(e),i=i.node(e);t.setPosition?t.setPosition(n,i):n.set("position",{x:i.x-i.width/2,y:i.y-i.height/2})},importLink:function(t,e,i){var n,r,o=this.getCell(e.name),i=i.edge(e),e=i.points||[],s=new v(e);(t.setVertices||t.setLinkVertices)&&(P(t.setVertices)?t.setVertices(o,e):(s.simplify({threshold:.001}),r=(n=s.points.map(function(t){return t.toJSON()})).length,o.set("vertices",n.slice(1,r-1)))),t.setLabels&&"x"in i&&"y"in i&&(n={x:i.x,y:i.y},P(t.setLabels)?t.setLabels(o,n,e):(r=s.closestPointLength(n),i=s.pointAtLength(r),t=r/s.length(),e=new z(n).difference(i).toJSON(),o.label(0,{position:{distance:t,offset:e}})))},layout:function(t,e){var i=t instanceof ro?t:(new ro).resetCells(t,{dry:!0,sort:!1}),t=(e=S(e||{},{resizeClusters:!(t=null),clusterPadding:10,exportElement:this.exportElement,exportLink:this.exportLink})).dagre||("undefined"!=typeof dagre?dagre:void 0);if(void 0===t)throw new Error('The the "dagre" utility is a mandatory dependency.');var n=us.toGraphLib(i,{graphlib:e.graphlib,directed:!0,multigraph:!0,compound:!0,setNodeLabel:e.exportElement,setEdgeLabel:e.exportLink,setEdgeName:function(t){return t.id}}),r={},o=e.marginX||0,s=e.marginY||0,t=(e.rankDir&&(r.rankdir=e.rankDir),e.align&&(r.align=e.align),e.nodeSep&&(r.nodesep=e.nodeSep),e.edgeSep&&(r.edgesep=e.edgeSep),e.rankSep&&(r.ranksep=e.rankSep),e.ranker&&(r.ranker=e.ranker),o&&(r.marginx=o),s&&(r.marginy=s),n.setGraph(r),t.layout(n,{debugTiming:!!e.debugTiming}),i.startBatch("layout"),us.fromGraphLib(n,{importNode:this.importElement.bind(i,e),importEdge:this.importLink.bind(i,e)}),e.resizeClusters&&(r=n.nodes().filter(function(t){return 0<n.children(t).length}).map(i.getCell.bind(i)).sort(function(t,e){return e.getAncestors().length-t.getAncestors().length}),li(r,"fitEmbeds",{padding:e.clusterPadding})),i.stopBatch("layout"),n.graph());return new tt(o,s,Math.abs(t.width-2*o),Math.abs(t.height-2*s))},fromGraphLib:function(e,i){var n=(i=i||{}).importNode||He,r=i.importEdge||He,o=this instanceof ro?this:new ro;return e.nodes().forEach(function(t){n.call(o,t,e,o,i)}),e.edges().forEach(function(t){r.call(o,t,e,o,i)}),o},toGraphLib:function(t,e){var i=(e=e||{}).graphlib||("undefined"!=typeof graphlib?graphlib:void 0);if(void 0===i)throw new Error('The the "graphlib" utility is a mandatory dependency.');for(var n=Pi(e,"directed","compound","multigraph"),r=new i.Graph(n),o=e.setNodeLabel||He,s=e.setEdgeLabel||He,a=e.setEdgeName||He,l=t.get("cells"),h=0,c=l.length;h<c;h++){var u=l.at(h);if(u.isLink()){var d=u.get("source"),g=u.get("target");if(!d.id||!g.id)break;r.setEdge(d.id,g.id,s(u),a(u))}else r.setNode(u.id,o(u)),r.isCompound()&&u.has("parent")&&(d=u.get("parent"),l.has(d)&&r.setParent(u.id,d))}return r}},zo=(ro.prototype.toGraphLib=function(t){return us.toGraphLib(this,t)},ro.prototype.fromGraphLib=function(t,e){return us.fromGraphLib.call(this,t,e)},{Port:cn,PortLabel:yn,DirectedGraph:us}),Oo=o.Model.extend({defaults:{linkDistance:10,linkStrength:1,charge:10,x:0,y:0},cacheAttribute:"_fcache",initialize:function(){var t=this.get("graph");if(Array.isArray(t))for(var e=t,i=[],n=[],r=0,o=e.length;r<o;r++){var s=e[r];(s.isLink()?i:n).push(s)}else n=t.getElements(),i=t.getLinks();this.links=i,this.elements=n,this.x=this.get("x"),this.y=this.get("y"),this.width=this.get("width"),this.height=this.get("height"),this.gravityCenter=this.get("gravityCenter"),this.t=1,this.energy=1/0,this.progress=0},start:function(){var r=this.width,o=this.height,s=this.x,a=this.y;this.elements.forEach(function(t){var e=D(s,s+r),i=D(a,a+o),n=(t.position(e,i,{forceDirected:!0}),t[this.cacheAttribute]={});n.charge=t.get("charge")||this.get("charge"),n.weight=t.get("weight")||1,n.x=n.px=e,n.y=n.py=i,n.fx=0,n.fy=0},this),this.links.forEach(function(t){var e=t[this.cacheAttribute]={};e.source=t.getSourceElement(),e.target=t.getTargetElement(),e.strength=t.get("strength")||this.get("linkStrength"),e.distance=t.get("distance")||this.get("linkDistance")},this)},step:function(){if(.99*this.t<.005)return this.notifyEnd();for(var t,e,i,n,r,o,s,a,l,h,c=this.cacheAttribute,u=this.width,d=this.height,g=this.x,p=this.y,f=this.gravityCenter,m=this.energy,v=this.energy=0,y=0,b=0,w=0,A=this.elements.length,C=this.links.length,I=0;I<A-1;I++)for(v+=(e=this.elements[I][c]).x,y+=e.y,t=I+1;t<A;t++)o=(n=(i=this.elements[t][c]).x-e.x)*n+(r=i.y-e.y)*r,s=Math.sqrt(o),h=(a=this.t*e.charge/o)*r,e.fx-=l=a*n,e.fy-=h,i.fx+=l,i.fy+=h,this.energy+=l*l+h*h;var x,S,P,M,k,N=this.elements[A-1][c];for(v+=N.x,y+=N.y,I=0;I<C;I++)e=(x=this.links[I][c]).source[c],o=(n=(i=x.target[c]).x-e.x)*n+(r=i.y-e.y)*r,s=Math.sqrt(o),h=(x=this.t*x.strength*(s-x.distance)/s)*r,S=e.weight/(e.weight+i.weight),e.x+=(l=x*n)*(1-S),e.y+=h*(1-S),i.x-=l*S,i.y-=h*S,this.energy+=l*l+h*h;for(I=0;I<A;I++){k={x:(M=(P=this.elements[I])[c]).x,y:M.y},f&&(k.x+=(f.x-k.x)*this.t*.1,k.y+=(f.y-k.y)*this.t*.1),k.x+=M.fx,k.y+=M.fy,k.x=Math.max(g,Math.min(g+u,k.x)),k.y=Math.max(p,Math.min(g+d,k.y));k.x+=.9*(M.px-k.x),k.y+=.9*(M.py-k.y),M.px=k.x,M.py=k.y,M.fx=M.fy=0,M.x=k.x,M.y=k.y,b+=M.x,w+=M.y,this.notify(P,I,k)}this.t=this.cool(this.t,this.energy,m);N=v-b,m=y-w;Math.sqrt(N*N+m*m)<1&&this.notifyEnd()},cool:function(t,e,i){return e<i?(this.progress+=1,5<=this.progress?(this.progress=0,t/.99):t):(this.progress=0,.99*t)},notify:function(t,e,i){t.set("position",i,{forceDirected:!0})},notifyEnd:function(){this.trigger("end")}});function ds(t,e,i){var n,r=e.size,e=e.position;r&&(n=r.width,r=r.height,t.resize(n,r,i)),e&&(n=e.x,r=e.y,t.position(n,r,i))}var gs={layout:function(t,g){var p=t instanceof ro?t:(new ro).resetCells(t,{dry:!0,sort:!1}),e=(t=null,g=g||{},p.getElements()),f=g.columns||1,i=Math.ceil(e.length/f),m=g.dx||0,v=g.dy||0,t=void 0===g.centre||!1!==g.centre,y=t?"middle":g.verticalAlign,b=t?"middle":g.horizontalAlign,w=!!g.resizeToFit,t=g.marginX||0,n=g.marginY||0,A=g.columnGap||0,C=g.rowGap||0,I=g.setAttributes,x=("function"!=typeof I&&(I=ds),[]),r=g.columnWidth;if("compact"===r)for(var o=0;o<f;o++){var s=this._elementsAtColumn(e,o,f);x.push(this._maxDim(s,"width")+m)}else{r&&!N(r)||(r=this._maxDim(e,"width")+m);for(var a=0;a<f;a++)x.push(r)}var S=this._accumulate(x,t).map(function(t,e){return t+(e-.5)*A}),P=[],l=g.rowHeight;if("compact"===l)for(var h=0;h<i;h++){var c=this._elementsAtRow(e,h,f);P.push(this._maxDim(c,"height")+v)}else{l&&!N(l)||(l=this._maxDim(e,"height")+v);for(var u=0;u<i;u++)P.push(l)}var M=this._accumulate(P,n).map(function(t,e){return t+(e-.5)*C}),t=(p.startBatch("layout"),e.forEach(function(t,e){var i,n,r,o,s=e%f,e=Math.floor(e/f),a=x[s],l=P[e],h=0,c=0,u=t.get("size"),d={};switch(w&&(i=a-2*m,n=l-2*v,r=u.height*(u.width?i/u.width:1),o=u.width*(u.height?n/u.height:1),l<r?i=o:n=r,d.size=u={width:i,height:n}),y){case"top":break;case"bottom":c=l-u.height;break;case"middle":c=(l-u.height)/2}switch(b){case"left":break;case"right":h=a-u.width;break;case"middle":h=(a-u.width)/2}d.position={x:S[s]+m+h+A/2,y:M[e]+v+c+C/2},I.call(p,t,d,g)}),p.stopBatch("layout"),0<f&&(S[0]+=A/2,S[f]-=A/2),0<i?(M[0]+=C/2,M[i]-=C/2):0===M.length&&(M=[n,n]),new tt(t,n,S[f]-S[0],M[i]-M[0]));return{rowHeights:P,columnWidths:x,gridY:M,gridX:S,bbox:t}},_maxDim:function(t,i){return t.reduce(function(t,e){return Math.max(e.get("size")[i],t)},0)},_elementsAtRow:function(t,e,i){for(var n=[],r=i*e,o=Math.min(r+i,t.length);r<o;r++)n.push(t[r]);return n},_elementsAtColumn:function(t,e,i){for(var n=[],r=e,o=t.length;r<o;r+=i)n.push(t[r]);return n},_accumulate:function(t,e){return 0===t.length?[]:t.reduce(function(t,e,i){return t.push(t[i]+e),t},[e||0])}};function ps(t,e,i){i=S(i||{},{siblingGap:0}),this.width=0,this.height=0,this.layoutAreas=this.sortLayoutAreas(t),this.parentArea=e,this.siblingGap=i.siblingGap,this.exists()&&this.computeSize(i)}R(ps.prototype,{sortLayoutAreas:function(t){t=yi(t,"siblingRank");return t.forEach(function(t,e){t.siblingRank=e}),t},move:function(t,e){for(var i=0,n=this.layoutAreas.length;i<n;i++)this.layoutAreas[i].dx+=t,this.layoutAreas[i].dy+=e},exists:function(){return 0<this.layoutAreas.length},sumGaps:function(t){return Math.max(this.layoutAreas.length-1,0)*t},getSiblingRankByPoint:function(t){if(!this.exists())return-1;t=this.findAreaByPoint(t);return t?t.siblingRank-1:this.layoutAreas.length-1},getFirstChildConnectionPoints:function(){return[]},getConnectionPoints:function(t,e){if(!this.exists())return this.getFirstChildConnectionPoints(t);t={dx:t.x-this.parentArea.rootCX,dy:t.y-this.parentArea.rootCY};return this.layoutAreas[0].getRootVertices(t,e)},getParentConnectionPoint:function(){var t=this.parentArea,e=this.proxyLayoutArea("getConnectionPoint",t.rootSize);return A(t.rootCX,t.rootCY).offset(e.x,e.y)},getChildConnectionPoint:function(t,e){e=this.proxyLayoutArea("getConnectionPoint",e);return A(t).difference(e)},proxyLayoutArea:function(t){var e=Array.prototype.slice.call(arguments,1);return Is.fromDirection(this.direction).prototype[t].apply(this.parentArea,e)}}),ps.extend=o.Model.extend;var Ro=ps.extend({getTopDY:function(){return-this.height/2},findAreaByPoint:function(e){return this.layoutAreas.find(function(t){return t.rootCY>e.y})},computeSize:function(i){this.height=this.sumGaps(i.siblingGap);var t=this.layoutAreas;this.height+=t.reduce(function(t,e){return t+e.height+e.prevSiblingGap+e.nextSiblingGap},0),t.reduce(function(t,e){return this.width=Math.max(this.width,e.getExtendedWidth()),e.dy+=t+e.getCY(),t+e.prevSiblingGap+e.height+e.nextSiblingGap+i.siblingGap}.bind(this),this.getTopDY())},getYTowardsParent:function(){return this.parentArea.rootCY},getXTowardsParent:function(){var t=this.parentArea;return t.rootCX+this.LRSign*(t.rootSize.width/2+t.gap)},getNeighborPointFromRank:function(t){var e,i=this.siblingGap;return e=this.exists()?(e=this.layoutAreas[t],t=this.layoutAreas[t+1],e?t?(e.y+e.height+t.y)/2:e.y+e.height+i/2:t.y-i/2):this.getYTowardsParent(),{x:this.getXTowardsParent(),y:e}}}),fs=Ro.extend({direction:"L",LRSign:-1}),ms=Ro.extend({direction:"R",LRSign:1}),jo={getXTowardsParent:function(){var t=this.parentArea;return t.rootCX+this.LRSign*t.gap},getYTowardsParent:function(){var t=this.parentArea,e=t.getLRHeight(t.siblings)/2;return e+=Math.min(t.firstChildGap,this.siblingGap/2),t.rootCY+this.TBSign*e},getFirstChildConnectionPoints:function(t){return[A(this.parentArea.rootCX,t.y)]},getChildConnectionPoint:function(t,e){return A(t).offset(-this.LRSign*e.width/2,0)},getParentConnectionPoint:function(){var t=this.parentArea;return A(t.rootCX,t.rootCY).offset(0,this.TBSign*(t.rootSize.height-t.rootMargin)/2)}},_o={getTopDY:function(){return 0}},e={getTopDY:function(){return-this.height}},vs=Ro.extend({direction:"BR",LRSign:1,TBSign:1}),ys=(R(vs.prototype,jo,_o),Ro.extend({direction:"BL",LRSign:-1,TBSign:1})),bs=(R(ys.prototype,jo,_o),Ro.extend({direction:"TR",LRSign:1,TBSign:-1})),ws=(R(bs.prototype,jo,e),Ro.extend({direction:"TL",LRSign:-1,TBSign:-1})),Zo=(R(ws.prototype,jo,e),ps.extend({getLeftDX:function(){return-this.width/2},findAreaByPoint:function(e){return this.layoutAreas.find(function(t){return t.rootCX>e.x})},computeSize:function(i){this.width=this.sumGaps(i.siblingGap);var t=this.layoutAreas;this.width+=t.reduce(function(t,e){return t+e.width+e.prevSiblingGap+e.nextSiblingGap},0),t.reduce(function(t,e){return this.height=Math.max(this.height,e.getExtendedHeight()),e.dx+=t+e.getCX(),t+e.prevSiblingGap+e.width+e.nextSiblingGap+i.siblingGap}.bind(this),this.getLeftDX())},getNeighborPointFromRank:function(t){var e;return{x:this.exists()?(e=this.layoutAreas[t],t=this.layoutAreas[t+1],e?t?(e.x+e.width+t.x)/2:e.x+e.width+this.siblingGap/2:t.x-this.siblingGap/2):this.parentArea.rootCX,y:this.getYTowardsParent()}}})),As=Zo.extend({direction:"T",getYTowardsParent:function(){var t=this.parentArea;return t.rootCY-t.getLRHeight()/2-t.gap}}),Cs=Zo.extend({direction:"B",getYTowardsParent:function(){var t=this.parentArea;return t.rootCY+t.getLRHeight()/2+t.gap}});function Is(t,e){this.root=t;t=R({},e,this.getRootAttributes(t,e.attributeNames)),e=e.gap||0;S(t,{parentGap:e,siblingGap:e,firstChildGap:e}),this.siblingRank=t.siblingRank,this.rootOffset=t.rootOffset,this.rootMargin=t.rootMargin,this.siblingGap=t.siblingGap,this.gap=this.parentGap=t.parentGap,this.nextSiblingGap=t.nextSiblingGap,this.prevSiblingGap=t.prevSiblingGap,this.firstChildGap=t.firstChildGap,this.dx=0,this.dy=0,this.width=0,this.height=0}R(Is,{create:function(t,e,i){return new(Is.fromDirection(t,i))(e,i)},fromDirection:function(t,e){var i;switch(t){case"L":i=Gs;break;case"T":i=zs;break;case"R":i=Bs;break;case"B":i=Os;break;case"BR":i=Rs;break;case"BL":i=Vs;break;case"TR":i=js;break;case"TL":i=_s;break;default:i=Is}return i}}),R(Is.prototype,{direction:null,compute:function(t){this.childAreas=t,this.computeRelativePosition(this.root,t)},getHeight:function(t,e){return this.getTHeight(t)+this.getBHeight(t)+this.getLRHeight()},getWidth:function(t,e){var i=Math.max(t.T.width,t.B.width)/2;return Math.max(this.getLWidth(t,e)+e.width/2,i)+Math.max(this.getRWidth(t,e)+e.width/2,i)},getLRHeight:function(){return Math.max(this.rootSize.height,this.siblings.L.height,this.siblings.R.height)},getTHeight:function(t){return t.T.height+this.getTXHeight(t)},getBHeight:function(t){return t.B.height+this.getBXHeight(t)},getXLRWidth:function(t,e){return this.getLWidth(t,e)+e.width+this.getRWidth(t,e)},getXRWidth:function(t,e){t=Math.max(t.BR.width,t.TR.width);return 0<t&&(t-=e.width/2),t},getTXHeight:function(t){t=Math.max(t.TR.height,t.TL.height);return 0<t&&(t+=this.firstChildGap),t},getBXHeight:function(t){t=Math.max(t.BR.height,t.BL.height);return 0<t&&(t+=this.firstChildGap),t},getXLWidth:function(t,e){t=Math.max(t.BL.width,t.TL.width);return 0<t&&(t-=e.width/2),t},getRWidth:function(t,e){return Math.max(t.R.width,this.getXRWidth(t,e))},getLWidth:function(t,e){return Math.max(t.L.width,this.getXLWidth(t,e))},getTBOverlap:function(t,e){t=Math.max(t.T.width,t.B.width);return t=0<t?(t-e.width)/2:t},getRootDX:function(t,e){var i=this.getTBOverlap(t,e),n=Math.max(this.getLWidth(t,e),i);return(n-=Math.max(this.getRWidth(t,e),i))/2},getMinimalGap:function(t){return Math.min(t.siblingGap,this.firstChildGap,this.parentGap)},getBBox:function(t){var e=Nt(this),t=t&&t.expandBy;return t&&e.moveAndExpand({x:-t,y:-t,width:2*t,height:2*t}),e},containsPoint:function(t,e){return this.getBBox(e).containsPoint(t)},getLayoutSiblings:function(t){return this.siblings[t]},getExtendedWidth:function(){return this.width+this.gap+this.rootOffset},getExtendedHeight:function(){return this.height+this.gap+this.rootOffset},findMinimalAreaByPoint:function(e,i){return this.containsPoint(e,i)?(this.childAreas.some(function(t){return!!(n=t.findMinimalAreaByPoint(e,i))}),n||this):null;var n},getType:function(){return Object.keys(this.siblings).reduce(function(t,e){return this.siblings[e].exists()?t.concat(e):t}.bind(this),[]).sort().join("-")},getRootAttributes:function(t,e){var i={rootOffset:t.get(e.offset||"offset")||0,rootMargin:t.get(e.margin||"margin")||0,prevSiblingGap:t.get(e.prevSiblingGap||"prevSiblingGap")||0,nextSiblingGap:t.get(e.nextSiblingGap||"nextSiblingGap")||0},n=t.get(e.siblingRank||"siblingRank"),n=(G(n)&&(i.siblingRank=n),t.get(e.firstChildGap||"firstChildGap"));return G(n)&&(i.firstChildGap=n),i},getRootSize:function(t,e){t=t.size();return t[this.marginDimension]+=e,t},createSiblings:function(t,e){t=vi(t,"direction");return{L:new fs(t.L,this,e),T:new As(t.T,this,e),R:new ms(t.R,this,e),B:new Cs(t.B,this,e),BR:new vs(t.BR,this,e),BL:new ys(t.BL,this,e),TR:new bs(t.TR,this,e),TL:new ws(t.TL,this,e)}},computeSize:function(t,e){return{width:this.getWidth(t,e),height:this.getHeight(t,e)}},computeOrigin:function(){var t=this.siblings,e=this.rootSize,e=Math.max(this.getLWidth(t,e)+e.width/2,this.getXLWidth(t,e)+e.width/2,t.T.width/2,t.B.width/2);return{x:this.rootCX-e,y:this.rootCY-this.getTHeight(t)-this.getLRHeight()/2}},moveSiblings:function(t,e){this.hasHorizontalSiblings(t)&&(e=e.width/2,t.L.move(-e,0),t.R.move(e,0)),this.hasVerticalSiblings(t)&&(e=this.getLRHeight()/2,t.T.move(0,-e),t.B.move(0,e),t.BR.move(0,e),t.BL.move(0,e),t.B.move(0,this.getBXHeight(t)),t.TR.move(0,-e),t.TL.move(0,-e),t.T.move(0,-this.getTXHeight(t)))},moveRootToConnectionPoint:function(t){t=this.getConnectionPoint(t);this.dx+=t.x,this.dy+=t.y},computeRelativePosition:function(t,e){e=this.siblings=this.createSiblings(e,{siblingGap:this.siblingGap}),t=this.rootSize=this.getRootSize(t,this.rootMargin);R(this,this.computeSize(e,t)),this.moveSiblings(e,t),this.moveRootToConnectionPoint(t),this.moveRootBehindSiblings(e,t),this.moveRootFromParent()},computeAbsolutePosition:function(){var t;this.parentArea?(this.rootCX=this.parentArea.rootCX+this.dx,this.rootCY=this.parentArea.rootCY+this.dy,this.level=this.parentArea.level+1):(t=this.root.getBBox().center(),this.rootCX=t.x,this.rootCY=t.y,this.level=0),R(this,this.computeOrigin())},hasVerticalSiblings:function(t){return t.T.exists()||t.B.exists()||t.BR.exists()||t.BL.exists()||t.TR.exists()||t.TL.exists()},hasHorizontalSiblings:function(t){return t.L.exists()||t.R.exists()},isSourceArea:function(){return!this.parentArea},isSinkArea:function(){return 0===this.childAreas.length},getRootPosition:function(){var t=this.root.get("size");return{x:this.rootCX-t.width/2,y:this.rootCY-t.height/2}},getRootVertices:function(t,e){if(e=e||{},0===(t=t||this)[this.deltaCoordinate]||!this.parentArea)return[];var i=this.parentArea.getInnerSize();return e=!e.ignoreSiblings&&this.hasSiblingsBetweenParent()?(e=this.siblings[this.oppositeDirection],this.getRelativeVerticesAvoidingSiblings(i,t,e)):this.getRelativeVertices(i,t),li(e,"offset",this.parentArea.rootCX,this.parentArea.rootCY)},getInnerSize:function(){return{width:this.rootSize.width,height:this.getLRHeight()}},getConnectionPoint:function(){return null},getRelativeVertices:function(){return null},moveRootFromParent:function(){},moveRootBehindSiblings:function(){},hasSiblingsBetweenParent:function(){return!this.isSourceArea()&&this.siblings[this.oppositeDirection].exists()},getCY:function(){return this.height/2+this.prevSiblingGap},getCX:function(){return this.width/2+this.prevSiblingGap}}),Is.extend=o.Model.extend;function xs(t,e,i){var n,r=e.size,e=e.position;r&&(n=r.width,r=r.height,t.resize(n,r,i)),e&&(n=e.x,r=e.y,t.position(n,r,i))}function Ss(t,e,i){this.top=t.topLine().rotate(e,-i),this.left=t.leftLine().rotate(e,-i),this.right=t.rightLine().rotate(e,-i),this.bottom=t.bottomLine().rotate(e,-i)}function Ps(){this.options={handles:[{name:"remove",position:"nw",events:{pointerdown:"removeElement"},icon:null},{name:"direction",position:"se",events:{pointerdown:"directionSwap"},icon:null}],bbox:function(t){return t.paper.localToPaperPoint(t.getPointAtRatio(.5))},typeCssName:"type-link",tinyThreshold:-1,smallThreshold:-1,boxContent:!1}}function Ms(){this.options={handles:[{name:"remove",position:"nw",events:{pointerdown:"removeElement"},icon:null},{name:"resize",position:"se",events:{pointerdown:"startResizing",pointermove:"doResize",pointerup:"stopBatch"},icon:null},{name:"clone",position:"n",events:{pointerdown:"startCloning",pointermove:"doClone",pointerup:"stopCloning"},icon:null},{name:"link",position:"e",events:{pointerdown:"startLinking",pointermove:"doLink",pointerup:"stopLinking"},icon:null},{name:"fork",position:"ne",events:{pointerdown:"startForking",pointermove:"doFork",pointerup:"stopForking"},icon:null},{name:"unlink",position:"w",events:{pointerdown:"unlinkElement"},icon:null},{name:"rotate",position:"sw",events:{pointerdown:"startRotating",pointermove:"doRotate",pointerup:"stopBatch"},icon:null}],bbox:function(t,e){return t.getBBox({useModelGeometry:e.options.useModelGeometry})},typeCssName:"type-element",tinyThreshold:40,smallThreshold:80,boxContent:function(t,e){var i=si("x: <%= x %>, y: <%= y %>, width: <%= width %>, height: <%= height %>, angle: <%= angle %>"),t=t.model,n=t.getBBox();return i({x:Math.floor(n.x),y:Math.floor(n.y),width:Math.floor(n.width),height:Math.floor(n.height),angle:Math.floor(t.get("angle")||0)})},magnet:function(t){return t.el},loopLinkPreferredSide:"top",loopLinkWidth:40,rotateAngleGrid:15,rotateEmbeds:!1,linkAttributes:{},smoothLinks:void 0}}function ks(){Mi(this,"handleKey"),this.parser=new ra,this.enable()}function Ns(t,e){this.options=R({friction:.92},e),this._isDragging=!1,this._dragLastX=0,this._dragLastY=0,this._dragDeltaX=0,this._dragDeltaY=0,this._dragLastDeltaX=0,this._dragLastDeltaY=0,this._velocityX=0,this._velocityY=0,this._requestAnimationFrameId=-1,this.onInertiaMove=t}function Ts(t,e){var e=e.model.direction,i=t.targetStack,t=t.invalid,n=B("path",{stroke:t?"#ccc":"#333","stroke-width":2});switch(e){case Ws.Directions.RightLeft:case Ws.Directions.LeftRight:var r=i.bbox.height;n.attr("d","M 0 "+-r/2+" v "+r);break;case Ws.Directions.TopBottom:case Ws.Directions.BottomTop:default:r=i.bbox.width;n.attr("d","M "+-r/2+" 0 h "+r)}return n.node}function Ls(t,e){return!0}function Es(t,e,i){return t.insertElementIndex}function Ds(t,e){return e.model.hasElement(t.model)}var Bs=Is.extend({direction:"R",oppositeDirection:"L",deltaCoordinate:"dx",marginDimension:"height",getConnectionPoint:function(t){return A(t.width/2,0)},moveRootBehindSiblings:function(t,e){this.dx+=Math.max(this.getLWidth(t,e),this.getTBOverlap(t,e)),this.dy+=(this.getTHeight(t)-this.getBHeight(t))/2},moveRootFromParent:function(){this.dx+=this.parentGap+this.rootOffset},getRelativeVertices:function(t,e){var t=this.getConnectionPoint(t),i=this.parentGap/2;return[t.clone().offset(i,0),t.clone().offset(i,e.dy)]},getRelativeVerticesAvoidingSiblings:function(t,e,i){var t=this.getConnectionPoint(t),n=i.siblingGap/2,r=0<this.dx?-1:1,i=e.dy+r*(i.height+n)/2,n=e.dy+r*this.rootSize.height/4,e=this.gap/2,r=1.5*e+Math.max(this.getLWidth(this.siblings,this.rootSize),this.getTBOverlap(this.siblings,this.rootSize));return[t.clone().offset(e,0),t.clone().offset(e,i),t.clone().offset(r,i),t.clone().offset(r,n)]}}),Gs=Is.extend({direction:"L",oppositeDirection:"R",deltaCoordinate:"dx",marginDimension:"height",getConnectionPoint:function(t){return A(-t.width/2,0)},moveRootBehindSiblings:function(t,e){this.dx-=Math.max(this.getRWidth(t,e),this.getTBOverlap(t,e)),this.dy+=(this.getTHeight(t)-this.getBHeight(t))/2},moveRootFromParent:function(){this.dx-=this.parentGap+this.rootOffset},getRelativeVertices:function(t,e){var t=this.getConnectionPoint(t),i=-this.parentGap/2;return[t.clone().offset(i,0),t.clone().offset(i,e.dy)]},getRelativeVerticesAvoidingSiblings:function(t,e,i){var t=this.getConnectionPoint(t),n=0<this.dx?-1:1,i=e.dy+n*(i.height+i.siblingGap/2)/2,e=e.dy+n*this.rootSize.height/4,n=this.gap/2,r=1.5*n+Math.max(this.getRWidth(this.siblings,this.rootSize),this.getTBOverlap(this.siblings,this.rootSize));return[t.clone().offset(-n,0),t.clone().offset(-n,i),t.clone().offset(-r,i),t.clone().offset(-r,e)]}}),zs=Is.extend({direction:"T",oppositeDirection:"B",deltaCoordinate:"dy",marginDimension:"width",getConnectionPoint:function(t){return A(0,-t.height/2)},moveRootBehindSiblings:function(t,e){this.dx+=this.getRootDX(t,e),this.hasHorizontalSiblings(t)&&(this.dy-=(this.getLRHeight()-e.height)/2),this.dy-=this.getBHeight(t)},moveRootFromParent:function(){this.dy-=this.parentGap+this.rootOffset},getRelativeVertices:function(t,e){var t=this.getConnectionPoint(t),i=-this.getTXHeight(this.parentArea.siblings)-this.parentGap/2;return[t.clone().offset(0,i),t.clone().offset(e.dx,i)]},getRelativeVerticesAvoidingSiblings:function(t,e){var t=this.getConnectionPoint(t),i=this.siblings,n=i.B,r=this.getTXHeight(this.parentArea.siblings)+this.parentGap/2,o=r+n.height,s=(o+=this.getBXHeight(this.siblings)+this.parentGap/4,this.dy<0?-1:1),i=i[0<s?"BR":"BL"].width,a=e.dx,i=(a+=s*(Math.max(i,n.width/2)+n.siblingGap/4),e.dx+s*this.rootSize.width/4);return[t.clone().offset(0,-r),t.clone().offset(a,-r),t.clone().offset(a,-o),t.clone().offset(i,-o)]}}),Os=Is.extend({direction:"B",oppositeDirection:"T",deltaCoordinate:"dy",marginDimension:"width",getConnectionPoint:function(t){return A(0,t.height/2)},moveRootBehindSiblings:function(t,e){this.dx+=this.getRootDX(t,e),this.dy+=this.getTHeight(t),this.hasHorizontalSiblings(t)&&(this.dy+=(this.getLRHeight()-e.height)/2)},moveRootFromParent:function(){this.dy+=this.parentGap+this.rootOffset},getRelativeVertices:function(t,e){var t=this.getConnectionPoint(t),i=this.getBXHeight(this.parentArea.siblings)+this.parentGap/2;return[t.clone().offset(0,i),t.clone().offset(e.dx,i)]},getRelativeVerticesAvoidingSiblings:function(t,e){var t=this.getConnectionPoint(t),i=this.siblings,n=i.T,r=this.getBXHeight(this.parentArea.siblings)+this.parentGap/2,o=r+n.height,s=(o+=this.getTXHeight(i)+this.parentGap/4,this.dy<0?-1:1),i=i[0<s?"TR":"TL"].width,a=e.dx,i=(a+=s*(Math.max(i,n.width/2)+n.siblingGap/4),e.dx+s*this.rootSize.width/4);return[t.clone().offset(0,r),t.clone().offset(a,r),t.clone().offset(a,o),t.clone().offset(i,o)]}}),Rs=Is.extend({direction:"BR",oppositeDirection:"L",deltaCoordinate:"dy",marginDimension:"height",getConnectionPoint:function(t){return A(0,t.height/2)},getCY:function(){return this.prevSiblingGap},moveRootBehindSiblings:function(t,e){var i=Math.max(t.T.width,t.B.width);this.dx+=Math.max(this.getLWidth(t,e),(i-e.width)/2),this.dy+=this.getTHeight(t),this.hasHorizontalSiblings(t)&&(this.dy+=(this.getLRHeight()-e.height)/2)},moveRootFromParent:function(){var t=this.parentArea;t&&(this.dy+=t.firstChildGap),this.dx+=this.rootSize.width/2+this.rootOffset+this.parentGap},getRelativeVertices:function(t,e){var i=this.getConnectionPoint(t),n=e.dx,e=e.dy,r=t.width,t=t.height,r=e-t/2<0?(r/2+(n-this.rootSize.width/2))/2:0;return[i.clone().offset(r,e-t/2)]},getRelativeVerticesAvoidingSiblings:function(t,e,i){var n=e.dx-this.rootSize.width/4,e=e.dy,e=(e+=Math.max(i.height,this.rootSize.height)/2)+this.getMinimalGap(i)/2;return[A(0,e),A(n,e)]}}),Vs=Is.extend({direction:"BL",oppositeDirection:"R",deltaCoordinate:"dy",marginDimension:"height",getConnectionPoint:function(t){return A(0,t.height/2)},getCY:function(){return this.prevSiblingGap},moveRootBehindSiblings:function(t,e){var i=Math.max(t.T.width,t.B.width);this.dx-=Math.max(this.getRWidth(t,e),(i-e.width)/2),this.dy+=this.getTHeight(t),this.hasHorizontalSiblings(t)&&(this.dy+=(this.getLRHeight()-e.height)/2)},moveRootFromParent:function(){var t=this.parentArea;t&&(this.dy+=t.firstChildGap),this.dx-=this.rootSize.width/2+this.rootOffset+this.parentGap},getRelativeVertices:function(t,e){var i=this.getConnectionPoint(t),n=e.dx,e=e.dy,r=t.width,t=t.height,r=e-t/2<0?(-r/2+(n+this.rootSize.width/2))/2:0;return[i.clone().offset(r,e-t/2)]},getRelativeVerticesAvoidingSiblings:function(t,e,i){var n=e.dx+this.rootSize.width/4,e=e.dy,e=(e+=Math.max(i.height,this.rootSize.height)/2)+this.getMinimalGap(i)/2;return[A(0,e),A(n,e)]}}),js=Is.extend({direction:"TR",oppositeDirection:"L",deltaCoordinate:"dy",marginDimension:"height",getConnectionPoint:function(t){return A(0,t.height/2)},getCY:function(){return this.height-this.rootSize.height+this.prevSiblingGap},moveRootBehindSiblings:function(t,e){this.dx+=Math.max(this.getLWidth(t,e),this.getTBOverlap(t,e)),this.dy-=this.getBHeight(t),this.hasHorizontalSiblings(t)&&(this.dy-=(this.getLRHeight()-e.height)/2)},moveRootFromParent:function(){var t=this.parentArea;t&&(this.dy-=t.firstChildGap),this.dx+=this.rootSize.width/2+this.rootOffset+this.parentGap},getRelativeVertices:function(t,e){var i=this.getConnectionPoint(t),n=e.dx,e=e.dy,r=t.width,t=t.height,r=0<e+t/2?(r/2+(n-this.rootSize.width/2))/2:0;return[i.clone().offset(r,e-t/2)]},getRelativeVerticesAvoidingSiblings:function(t,e,i){var n=e.dx-this.rootSize.width/4,e=e.dy,e=(e-=Math.max(i.height,this.rootSize.height)/2)-this.getMinimalGap(i)/2;return[A(0,e),A(n,e)]}}),_s=Is.extend({direction:"TL",oppositeDirection:"R",deltaCoordinate:"dy",marginDimension:"height",getConnectionPoint:function(t){return A(0,t.height/2)},getCY:function(){return this.height-this.rootSize.height+this.prevSiblingGap},moveRootBehindSiblings:function(t,e){this.dx-=Math.max(this.getRWidth(t,e),this.getTBOverlap(t,e)),this.dy-=this.getBHeight(t),this.hasHorizontalSiblings(t)&&(this.dy-=(this.getLRHeight()-e.height)/2)},moveRootFromParent:function(){var t=this.parentArea;t&&(this.dy-=t.firstChildGap),this.dx-=this.rootSize.width/2+this.rootOffset+this.parentGap},getRelativeVertices:function(t,e){var i=this.getConnectionPoint(t),n=e.dx,e=e.dy,r=t.width,t=t.height,r=0<e+t/2?(-r/2+(n+this.rootSize.width/2))/2:0;return[i.clone().offset(r,e-t/2)]},getRelativeVerticesAvoidingSiblings:function(t,e,i){var n=e.dx+this.rootSize.width/4,e=e.dy,e=(e-=Math.max(i.height,this.rootSize.height)/2)-this.getMinimalGap(i)/2;return[A(0,e),A(n,e)]}}),ko={rotate:function(t){var i="LRBT",n=i.indexOf(t[0])-i.indexOf(t[1]);return function(t){var e=i.indexOf(t);return 0<=e?i[(4+e-n)%4]:t}},flip:function(t){var e=t[0],i=t[1];return function(t){return t===e?i:t===i?e:t}},straighten:function(t){return function(){return t[1]}}},Io=o.Model.extend({defaults:{graph:void 0,gap:20,parentGap:20,siblingGap:20,firstChildGap:20,direction:"R",directionRule:ko.straighten,updatePosition:function(t,e,i){t.set("position",e,i)},updateVertices:function(t,e,i){t.set("vertices",e,i)},updateAttributes:null,filter:null,attributeNames:{}},initialize:function(){this._cacheOptions(this.attributes),this.layoutAreas={}},layout:function(t){this.layoutAreas={};for(var e=this.getGraphSources(t),i=0,n=e.length;i<n;i++)this.layoutTree(e[i],t);return this.trigger("layout:done",t),this},layoutTree:function(t,e){(e=e||{}).treeLayout=!0;t=this._computeLayoutAreas(t,null,e);return this._computeAbsolutePositions(t),this._updateCells(t,e),this},getLayoutBBox:function(){return this.getRootLayoutAreas().reduce(function(t,e){e=e.getBBox();return t?t.union(e):e},null)},getLayoutArea:function(t){return this.layoutAreas[t.id||t]||null},getRootLayoutAreas:function(){return this.getGraphSources().map(this.getLayoutArea,this)},getGraphSources:function(t){var e=this.graph.getSources();return e=this.filter&&0<e.length?this.filter(e,null,t)||e:e},getMinimalRootAreaByPoint:function(e){var t=this.getRootLayoutAreas().filter(function(t){return t.containsPoint(e)});return gi(t)?null:t.reduce(function(t,e){return e.width*e.height<t.min&&(t.min=e.width*e.height,t.item=e),t},{min:1/0,item:void 0}).item},_computeLayoutAreas:function(t,e,i){for(var n=e?e.direction:this.get("direction"),n=t.get(this.getAttributeName("direction"))||n,r=Is.create(n,t,this.attributes),o=(r.parentArea=e,r.link=this.graph.getConnectedLinks(t,{inbound:!0})[0],this._getChildren(t,i)),s=(this.layoutAreas[t.id]=r,[]),a=0,l=o.length;a<l;a++)s.push(this._computeLayoutAreas(o[a],r,i));return r.compute(s),r},_cacheOptions:function(e){["updateAttributes","updateVertices","updatePosition","filter"].forEach(function(t){this[t]=P(e[t])?e[t]:null},this),this.graph=e.graph},_getChildren:function(t,e){if(this.layoutAreas[t.id])return[];var i=this.graph.getNeighbors(t,{outbound:!0});return i=this.filter&&0<i.length?this.filter(i,t,e)||i:i},_computeAbsolutePositions:function(t){t.computeAbsolutePosition(t);for(var e=0,i=t.childAreas.length;e<i;e++)this._computeAbsolutePositions(t.childAreas[e])},_updateCells:function(t,e){var i=t.root,n=t.link||null;n&&(this.updatePosition&&this.updatePosition(i,t.getRootPosition(),e),this.updateVertices&&this.updateVertices(n,t.getRootVertices(),e)),this.changeSiblingRank(i,t.siblingRank,e),this.updateAttributes&&this.updateAttributes(t,i,n,e);for(var r=0,o=t.childAreas.length;r<o;r++)this._updateCells(t.childAreas[r],e)},updateDirections:function(t,e,i){i=i||{};var n=this.getAttributeName("direction"),r=this.get("directionRule")(e);this.graph.search(t,function(t,e){0!==e&&(e=r(t.get(n)),this.changeDirection(t,e,i))}.bind(this),{outbound:!0})},reconnectElement:function(t,e,i){i=i||{};var n=this.getLayoutArea(t),r=n.link;return!!r&&(r.set("source",{id:e.id||e},i),r=n.direction,e=i.direction||r,n=i.siblingRank||void 0,this.changeSiblingRank(t,n,i),this.changeDirection(t,e,i),r!==e&&this.updateDirections(t,[r,i.direction],i),!0)},changeSiblingRank:function(t,e,i){t.set(this.getAttributeName("siblingRank"),e,i)},changeDirection:function(t,e,i){t.set(this.getAttributeName("direction"),e,i)},getAttributeName:function(t){return this.get("attributeNames")[t]||t},getAttribute:function(t,e){return t.get(this.getAttributeName(e))},prepare:function(){return this}},{directionRules:ko}),Zs={TopBottom:"TB",BottomTop:"BT",LeftRight:"LR",RightLeft:"RL"},Ys={Start:"start",Middle:"middle",End:"end"},Ws={Directions:Zs,Alignments:Ys,layout:function(t,n){for(var i,e,r,o,s,a=(n=void 0===n?{}:n).direction,l=(void 0===a&&(a=Zs.TopBottom),n.topLeft),h=n.bottomLeft,c=n.topRight,u=n.bottomRight,d=n.stackGap,g=(void 0===d&&(d=10),n.stackElementGap),p=(void 0===g&&(g=10),n.stackSize),f=(void 0===p&&(p=100),n.stackCount),m=n.setAttributes,v=(void 0===m&&(m=xs),n.alignment),y=(void 0===v&&(v=Ys.Middle),n.stackIndexAttributeName),b=(void 0===y&&(y="stackIndex"),n.stackElementIndexAttributeName),w=(void 0===b&&(b="stackElementIndex"),t instanceof ro?(e=t.getElements(),r=t):(e=t)[0]&&(r=e[0].graph),i=f?Array(f).fill(null).map(function(){return Array()}):[],e.forEach(function(t){var e=t.get(y)||0;i[e]||(i[e]=[]),i[e].push(t)}),a===Zs.TopBottom||a===Zs.BottomTop),A=a===Zs.LeftRight||a===Zs.RightLeft,t=i.length,f=(w&&(o=i.reduce(function(t,e){return Math.max(t,e.reduce(function(t,e){return t+e.size().height},0)+(e.length-1)*g)},0),s=t*p+(t-1)*d),A&&(s=i.reduce(function(t,e){return Math.max(t,e.reduce(function(t,e){return t+e.size().width},0)+(e.length-1)*g)},0),o=t*p+(t-1)*d),l?new tt(l.x,l.y,s,o):c?new tt(c.x-s,c.y,s,o):h?new tt(h.x,h.y-o,s,o):u?new tt(u.x-s,u.y-o,s,o):new tt(0,0,s,o)),C=f.topLeft(),I=[],x=0;x<i.length;x++)i[x]=yi(i[x],function(t){return t.get(b)||0}),w&&(I.push({bbox:new tt(C.x,C.y,p,o),elements:i[x],index:x}),C.x+=p+d),A&&(I.push({bbox:new tt(C.x,C.y,s,p),elements:i[x],index:x}),C.y+=p+d);r&&r.startBatch("layout");for(var S=0;S<I.length;S++){var P,M=I[S];M.elements.length&&(P=M.bbox.topLeft(),a===Zs.BottomTop&&(P.y+=M.bbox.height),a===Zs.RightLeft&&(P.x+=M.bbox.width),M.elements.forEach(function(t){var e=t.size(),i=(a===Zs.BottomTop&&(P.y-=e.height),a===Zs.RightLeft&&(P.x-=e.width),P.toJSON());switch(v){case Ys.Middle:w?i.x+=(p-e.width)/2:i.y+=(p-e.height)/2;break;case Ys.End:w?i.x+=p-e.width:i.y+=p-e.height}m(t,{position:i},n),a===Zs.BottomTop&&(P.y-=g),a===Zs.TopBottom&&(P.y+=e.height+g),a===Zs.RightLeft&&(P.x-=g),a===Zs.LeftRight&&(P.x+=e.width+g)}))}return r&&r.stopBatch("layout"),{bbox:f,stacks:I}}},Lo={ForceDirected:Oo,GridLayout:gs,TreeLayout:Io,StackLayout:Ws},To=Co.extend({name:"swimlane-boundary",tagName:"rect",options:{padding:10,laneId:""},update:function(){var t=this.vel,e=this.relatedView,i=this.options,e=e.model,n=e.angle(),r=e.getBBox().center(),e=this.getBoundaryBBox(e,i.laneId,i.padding);return null===e?t.attr({width:0,height:0}):(t.attr(e.toJSON()),t.rotate(n,r.x,r.y,{absolute:!0})),this},getBoundaryBBox:function(t,e,i){var i=ei(i),n=i.left,r=i.top,o=i.right,i=i.bottom,t=t.getLaneBBox(e);return null===t?null:(t.moveAndExpand({x:-n,y:-r,width:n+o,height:r+i}),t.width<0&&(t.width=0),t.height<0&&(t.height=0),t)}}),Bo=(Ss.inflatedOnSide=function(t,e,i,n,r){var o=new Ss(t,e,i),s=o.getLine(r);switch(r){case"top":case"right":o[r]=s.parallel(-n);break;case"bottom":case"left":o[r]=s.parallel(n)}return o},Ss.prototype={getLine:function(t){switch(t){case"top":return this.top;case"right":return this.right;case"bottom":return this.bottom;case"left":return this.left}},isPointOnLine:function(t,e){return 0===Math.round(this.getLine(e).closestPoint(t).distance(t))},isPointToTheLeftOfLine:function(t,e){var i=Math.round(this.getLine(e).pointOffset(t));switch(e){case"top":case"right":return 0<i;case"bottom":case"left":return i<0}},isPointToTheRightOfLine:function(t,e){var i=Math.round(this.getLine(e).pointOffset(t));switch(e){case"top":case"right":return i<0;case"bottom":case"left":return 0<i}},isPointInside:function(t){var e=this.isPointToTheLeftOfLine(t,"top"),i=this.isPointToTheLeftOfLine(t,"right"),n=this.isPointToTheLeftOfLine(t,"bottom");return this.isPointToTheLeftOfLine(t,"left")&&e&&i&&n},isPointInsideOrOnLine:function(t){var e=this.isPointInside(t),i=this.isPointOnLine(t,"top"),n=this.isPointOnLine(t,"right"),r=this.isPointOnLine(t,"bottom"),t=this.isPointOnLine(t,"left");return e||i||n||r||t},findClosestPointToLine:function(t,i){var n=this,r=new z,o=1/0;return t.forEach(function(t){var e=n.getDistanceFromLineToPoint(t,i);e<o&&(r.update(t.x,t.y),o=e)}),r},findFurthestPointFromLine:function(t,i){var n=this,r=new z,o=-1/0;return t.forEach(function(t){var e=n.getDistanceFromLineToPoint(t,i);o<e&&(r.update(t.x,t.y),o=e)}),r},getDistanceFromLineToPoint:function(t,e){var i=this.getLine(e),e=this.isPointToTheRightOfLine(t,e)?1:-1,i=Math.abs(i.pointOffset(t))*e;return Math.round(i)}},zn.SegmentHandle.extend({className:"swimlane-transform-handle",children:[{tagName:"rect",selector:"handle",attributes:{width:20,height:8,x:-10,y:-4,rx:4,ry:4,fill:"#3498db",stroke:"#FFFFFF","stroke-width":2}}],position:function(t,e,i){var n=this.childNodes.handle,t=B.createSVGMatrix().translate(t,e).rotate(i);n.setAttribute("transform",B.matrixToTransformString(t)),n.setAttribute("cursor",i%180==0?"row-resize":"col-resize")}})),Fs="top",Us="right",Hs="bottom",Xs="left",Js="x",$s="y",Do={SwimlaneBoundary:To,SwimlaneTransform:po.extend({name:"swimlane-transform",options:{laneId:void 0,minSize:30,padding:10,stopPropagation:!0,constraintsPadding:10,handleClass:Bo,minSizeConstraints:void 0,maxSizeConstraints:void 0},handles:null,minConstraintPoints:null,maxConstraintPoints:null,initialize:function(){var n=this,t=this.options;void 0===t.minSizeConstraints&&(t.minSizeConstraints=function(t,e,i){return n.getMinConstraintsToEmbeds(t,e,i)}),void 0===t.maxSizeConstraints&&(t.maxSizeConstraints=function(t,e,i){return n.getMaxConstraintsToEmbeds(t,e,i)})},update:function(){return this.render(),this},onRender:function(){return this.removeHandles(),this.doesLaneExist()&&this.renderHandles(),this},onRemove:function(){this.removeHandles()},doesLaneExist:function(){return null!==this.relatedView.model.getLaneBBox(this.options.laneId)},removeHandles:function(){var t=this.handles;if(this.handles=[],this.stopListening(),Array.isArray(t))for(var e=0;e<t.length;e++)t[e].remove()},renderHandles:function(){var e=this;this.getHandlesPositionInfo().forEach(function(t){t=e.renderHandle(t);e.simulateRelatedView(t.el),e.handles.push(t)})},getHandlesPositionInfo:function(){var t=this.options,e=this.relatedView,i=t.laneId,e=e.model,n=e.angle(),r=e.getBBox().center(),e=this.getHandlesBoundaryBBox(e,i,t.padding);return[{position:e.topMiddle().rotate(r,-n),axis:$s,side:Fs},{position:e.leftMiddle().rotate(r,-n),axis:Js,side:Xs},{position:e.rightMiddle().rotate(r,-n),axis:Js,side:Us},{position:e.bottomMiddle().rotate(r,-n),axis:$s,side:Hs}]},getHandlesBoundaryBBox:function(t,e,i){var i=ei(i),n=i.left,r=i.top,o=i.right,i=i.bottom,t=t.getLaneBBox(e).moveAndExpand({x:-n,y:-r,width:n+o,height:r+i});return t.width<0&&(t.width=0),t.height<0&&(t.height=0),t},renderHandle:function(t){var e=this,i=new this.options.handleClass({paper:this.paper,axis:t.axis,side:t.side,guard:function(t){return e.guard(t)}});return i.render(),i.vel.appendTo(this.el),this.updateHandlePosition(i,t.position),this.startHandleListening(i),i},updateHandlePosition:function(t,e){var i=this.relatedView.model.angle();t.options.axis===Js&&(i+=90),t.position(e.x,e.y,i)},startHandleListening:function(t){this.listenTo(t,"change:start",this.onHandleChangeStart),this.listenTo(t,"changing",this.onHandleChanging),this.listenTo(t,"change:end",this.onHandleChangeEnd)},onHandleChangeStart:function(t,e){var i=t.options.side,n=this.options,r=this.handles,o=this.relatedView,s=o.model,a=o.paper;Array.isArray(r)&&(this.hideNonSelectedHandles(r,t),this.updateConstraintPoints(i),this.focus(),s.startBatch("lane-resize",{ui:!0,tool:this.cid}),n.stopPropagation||o.notifyPointerdown.apply(o,a.getPointerArgs(e)))},hideNonSelectedHandles:function(t,e){t.forEach(function(t){return t===e?t.show():t.hide()})},updateConstraintPoints:function(t){var e,i,n=this.relatedView,r=this.options,o=r.laneId,n=n.model,s=r.minSizeConstraints,r=r.maxSizeConstraints;P(s)&&(e=s(n,o,t)),P(r)&&(i=r(n,o,t)),this.minConstraintPoints=Array.isArray(e)?e.map(function(t){return new z(t)}):[],this.maxConstraintPoints=Array.isArray(i)?i.map(function(t){return new z(t)}):[]},onHandleChanging:function(t,e){var i=this.options,n=this.relatedView,r=n.model,o=n.paper,s=i.laneId,i=i.stopPropagation,a=r.getBBox(),l=r.angle(),h=a.center(),c=t.options,u=c.axis,d=c.side,c=this.getHandlesPositionInfo().find(function(t){return t.side===d}).position,e=I(e),o=o.snapToGrid(e.clientX,e.clientY),g=o.clone().rotate(h,l).round(),h=c.clone().rotate(h,l).round(),g=g.difference(h),h=0!==g.y,p=0!==g.x;u===$s&&h?(h=d===Fs?-g.y:g.y,this.updateLaneHeight(s,h,d,a,l)):u===Js&&p&&(h=d===Xs?-g.x:g.x,this.updateLaneWidth(s,h,r,d,a,l)),this.updateHandlePosition(t,c),i||n.notifyPointermove(e,o.x,o.y)},onHandleChangeEnd:function(t,e){var i=this.options,n=this.relatedView,r=n.paper,o=n.model,e=I(e),r=r.snapToGrid(e.clientX,e.clientY),s=r.x,r=r.y;this.render(),this.blur(),o.stopBatch("lane-resize",{ui:!0,tool:this.cid}),i.stopPropagation||n.notifyPointerup(e,s,r),n.checkMouseleave(e)},updateLaneHeight:function(t,e,i,n,r){var o=this,s=this.relatedView.model,a=s.metrics.lanes,l=di(s.prop("lanes")),h=this.getNeighbourLanesIds(a,t,i),a=this.getSublanesAndMostEmbeddedLaneId(a,t,i),c=void 0===h.foundNeighbourLaneId,u=[h.foundNeighbourLaneId].concat(h.sublaneIds),d=[t].concat(a.sublaneIds,h.laneIdsPathToNeighbour);e=this.getDiffWithinConstraints(t,e,i,n.center(),r),e=this.getDiffWithinLaneSizeLimits(s,e,a.mostEmbeddedLaneId,h.mostEmbeddedLaneId),d.forEach(function(t){return o.addSizeToLane(s,l,t,e)}),c?this.resizeShape(s,n.width,n.height+e,i):u.forEach(function(t){return o.addSizeToLane(s,l,t,-e)}),s.prop("lanes",l,{ui:!0,tool:this.cid,autoResize:!1})},getSublanesAndMostEmbeddedLaneId:function(t,e,i){t=this.getIdsOfClosestSublanesToTheSide(t,e,i);return{sublaneIds:t,mostEmbeddedLaneId:t[0]||e}},getOppositeHandleSide:function(t){switch(t){case Fs:return Hs;case Us:return Xs;case Hs:return Fs;case Xs:return Us}},getNeighbourLanesIds:function(t,e,i){var n=this.getOppositeHandleSide(i),e=this.findNeighbourLane(t,e,i),i=e.foundNeighbourLaneId,e=e.laneIdsPathToNeighbour,t=this.getIdsOfClosestSublanesToTheSide(t,i,n);return{foundNeighbourLaneId:i,laneIdsPathToNeighbour:e,sublaneIds:t,mostEmbeddedLaneId:t[0]||i}},addSizeToLane:function(t,e,i,n){n=this.getLaneBBoxHeight(t,i)+n,t=t.getLanePath(i);t.push("size"),Ne({lanes:e},t,n)},updateLaneWidth:function(t,e,i,n,r,o){e=this.getDiffWithinConstraints(t,e,n,r.center(),o);t=i.getMinimalSize().width,o=Math.max(r.width+e,t);this.resizeShape(i,o,r.height,n)},resizeShape:function(t,e,i,n){t.resize(e,i,{ui:!0,tool:this.cid,direction:n})},getLaneBBoxHeight:function(t,e){return t.getLaneBBox(e).height},getDiffWithinLaneSizeLimits:function(t,e,i,n){var r=Math.sign(e),o=void 0!==n,i=this.getLaneBBoxHeight(t,i),o=o?this.getLaneBBoxHeight(t,n):1/0,t=i+e,n=o-e,s=this.getMinSize();return t<s?e=(i-s)*r:n<s&&(e=(o-s)*r),Math.round(e)},getMinSize:function(){var t=this.options.minSize,e=2*this.options.constraintsPadding;return t=t<e?e:t},getDiffWithinConstraints:function(t,e,i,n,r){var t=this.relatedView.model.getLaneBBox(t),o=this.getConstraintPaddingRelativeToHandleSide(e),s=Ss.inflatedOnSide(t,n,r,o,i),t=Ss.inflatedOnSide(t,n,r,e+o,i),n=this.getMaxConstraintPointsInsideLane(t),r=this.getMinConstraintPointsOutsideLane(t,i);return 0<n.length?(o=s.findClosestPointToLine(n,i),e=s.getDistanceFromLineToPoint(o,i)):0<r.length&&(t=s.findFurthestPointFromLine(r,i),e=s.getDistanceFromLineToPoint(t,i)),e},getConstraintPaddingRelativeToHandleSide:function(t){return this.options.constraintsPadding*(t<0?-1:1)},getMaxConstraintPointsInsideLane:function(e){return this.maxConstraintPoints.filter(function(t){return e.isPointInside(t)})},getMinConstraintPointsOutsideLane:function(i,n){return this.minConstraintPoints.filter(function(t){var e=i.isPointToTheRightOfLine(t,n),t=i.isPointOnLine(t,n);return e||t})},findNeighbourLane:function(t,e,i){for(var n=[],r=i===Fs,o=void 0,s=e;s;){var a=t[s],l=a.parentId,h=a.laneIndexWithinGroup;if(!(r?0===h:h===a.parentSublanesCount-1)){o=this.getSublaneIdOfParent(t,l,r?h-1:h+1);break}l&&n.push(l),s=l}return{foundNeighbourLaneId:o,laneIdsPathToNeighbour:n.reverse()}},getSublaneIdOfParent:function(i,n,r){return Object.keys(i).find(function(t){var t=i[t],e=t.parentId===n,t=t.laneIndexWithinGroup===r;return e&&t})},getIdsOfClosestSublanesToTheSide:function(t,e,i){for(var n=[],r=e;r;)var o=t[r].sublanesCount,o=r+"_"+(i===Fs?0:o-1),r=void 0!==t[o]?(n.push(o),o):void 0;return n.reverse()},getMinConstraintsToEmbeds:function(t,e,i){var n=[],r=t.getBBox().center(),o=t.angle(),e=t.getLaneBBox(e),e=new Ss(e,r,o),r=t.getEmbeddedCells({deep:!0}),o=i===Xs||i===Us;return this.getEmbedPointsInsideLane(e,r,i).forEach(function(t){return n.push(t)}),o&&0<r.length&&(o=(i=this.findLeftMostAndRightMostEmbedPoints(t,e,r)).leftMostPoint,t=i.rightMostPoint,n.push(o),n.push(t)),n},getMaxConstraintsToEmbeds:function(t,e,i){var n=[],r=t.angle(),o=t.metrics.lanes,s=t.getBBox().center(),a=t.getEmbeddedCells({deep:!0}),l=this.findNeighbourLane(o,e,Fs).foundNeighbourLaneId,o=this.findNeighbourLane(o,e,Hs).foundNeighbourLaneId;return void 0!==l&&(e=t.getLaneBBox(l),l=new Ss(e,s,r),this.getEmbedPointsInsideLane(l,a,i,{addOverflowingEmbedsOnlyOnHandleSide:!0}).forEach(function(t){return n.push(t)})),void 0!==o&&(e=t.getLaneBBox(o),l=new Ss(e,s,r),this.getEmbedPointsInsideLane(l,a,i,{addOverflowingEmbedsOnlyOnHandleSide:!0}).forEach(function(t){return n.push(t)})),n},getEmbedPointsInsideLane:function(r,t,o,s){var a=this,l=[];return t.forEach(function(t){var e=t.angle(),i=t.getBBox(),n=i.center();t.isLink()||(t=a.getBBoxCornerPoints(i,n,e),a.isElementInsideLane(r,t,n,o,s)&&t.forEach(function(t){return l.push(t)}))}),l},isElementInsideLane:function(i,t,e,n,r){var o,r=(r=void 0===r?{}:r).addOverflowingEmbedsOnlyOnHandleSide,e=i.isPointInsideOrOnLine(e);return r?(o=this.getOppositeHandleSide(n),r=t.every(function(t){return i.isPointInsideOrOnLine(t)}),n=t.some(function(t){var e=i.isPointToTheLeftOfLine(t,o),t=i.isPointOnLine(t,o);return e||t}),t=t.some(function(t){return i.isPointToTheRightOfLine(t,o)}),e&&(r||n&&t)):e},getBBoxCornerPoints:function(t,e,i){return[t.topLeft().rotate(e,-i).round(),t.topRight().rotate(e,-i).round(),t.bottomLeft().rotate(e,-i).round(),t.bottomRight().rotate(e,-i).round()]},findLeftMostAndRightMostEmbedPoints:function(t,e,i){var n=this,r=t.angle(),o=t.getBBox(),s=o.center(),o=new Ss(o,s,r),a=[],s=(i.forEach(function(t){var e,i;t.isLink()||(i=(e=t.getBBox()).center(),t=t.angle(),n.getBBoxCornerPoints(e,i,t).forEach(function(t){return a.push(t)}))}),o.findFurthestPointFromLine(a,Xs));return{leftMostPoint:this.getLeftMostPointCorrectedToPoolHeaders(t,s,o.left,e.left),rightMostPoint:o.findFurthestPointFromLine(a,Us)}},getLeftMostPointCorrectedToPoolHeaders:function(t,e,i,n){var r=this.getTotalLaneHeadersWidth(t),t=t.metrics.padding.left,n=n.pointOffset(i.start)-t-r,t=i.closestPoint(e),r=new C(t,e),i=r.length()+n;return r.setLength(i),r.end},getTotalLaneHeadersWidth:function(r){var t=r.metrics.lanes,o=0;return Object.keys(t).forEach(function(t){for(var e=t,i=0;e;){var n=r.metrics.lanes[e];i+=n.headerSize||0,e=n.parentId}o=o<i?i:o}),o}},{TransformHandle:Bo}),RecordScrollbar:po.extend({name:"scroll-bar",tagName:"rect",options:{margin:2,width:8,rightAlign:!1},attributes:{fill:"#333",rx:4,ry:4,"fill-opacity":.4,cursor:"grab"},events:{mousedown:"onPointerDown",touchstart:"onPointerDown"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},onRender:function(){this.update()},update:function(){var t=this.getBBox();return t?(this.enable(),this.vel.attr(t.toJSON())):this.disable(),this},getTrackHeight:function(){var t=this.relatedView,e=this.options,t=t.model,i=t.metrics.padding,e=e.margin,i=i.top+i.bottom+2*Math.abs(e);return t.attributes.size.height-i},getScale:function(){var t=this.relatedView.model,e=t.metrics,t=t.attributes,e=e.minHeight,t=t.size.height,i=this.getTrackHeight();return i/(e-(t-i))},getBBox:function(){var t=this.relatedView,e=this.options,t=t.model;if(t.isEveryItemInView())return null;var i=t.metrics,n=t.attributes,r=n.size.width,o=i.padding,i=i.overflow,s=this.getTrackHeight();if(s<=0)return null;var a=e.margin,l=e.width,h=this.getScale(),s=s*h,n=n.position,c=n.x,n=n.y+Math.abs(a)+o.top;return e.rightAlign?(c+=r-a,0<=a&&(c-=l),i||(c-=o.right)):(c+=a,a<0&&(c-=l),i||(c+=o.left)),new tt({x:c,y:n+h*t.getScrollTop(),width:l,height:s})},disable:function(){this.vel.attr("display","none")},enable:function(){this.vel.attr("display","")},onPointerDown:function(t){var e,i;this.guard(t)||(t.stopPropagation(),t.preventDefault(),(i=(e=this.relatedView).model).startBatch("scroll-record",{ui:!0,tool:this.cid}),this.focus(),this.delegateDocumentEvents(null,{y:t.clientY,scrollTop:i.getScrollTop()}),e.paper.undelegateEvents())},onPointerMove:function(t){var t=I(t),e=t.data,i=e.y,n=e.scrollTop,e=e.lastScrollTop,r=this.relatedView.model,o=this.getScale(),n=n+(t.clientY-i)/o;e!==n&&(t.data.lastScrollTop=n,r.setScrollTop(n))},onPointerUp:function(){this.undelegateDocumentEvents(),this.paper.delegateEvents(),this.blur(),this.el.style.pointerEvents="",this.relatedView.model.stopBatch("scroll-record",{ui:!0,tool:this.cid})}})},Vo=o.Collection.extend({LOCAL_STORAGE_KEY:"joint.ui.Clipboard.cells",defaults:{useLocalStorage:!0},constructor:function(t){o.Collection.prototype.constructor.call(this,[],t),this.defaults=R({},this.defaults,t)},copyElements:function(t,e,i){this.options=R({},this.defaults,i),i=this.options;t=t.toArray(),e=yi(e.cloneSubgraph(t,i),function(t){return t.isLink()?2:1});return this.reset(e),i.useLocalStorage&&window.localStorage&&localStorage.setItem(this.LOCAL_STORAGE_KEY,JSON.stringify(this.toJSON())),t},cutElements:function(t,e,i){t=this.copyElements(t,e,i);return e.trigger("batch:start",{batchName:"cut"}),li(t,"remove"),e.trigger("batch:stop",{batchName:"cut"}),t},pasteCells:function(t,e){(e=S(e||{},this.options)).useLocalStorage&&window.localStorage&&((n=JSON.parse(localStorage.getItem(this.LOCAL_STORAGE_KEY)))&&(n={cells:n},i=t.get("cells").cellNamespace,i=new ro([],{cellNamespace:i}).fromJSON(n,{sort:!1,dry:!0}),this.reset(i.getCells())));var i,n=this.map(function(t){return this.modifyCell(t,e)}.bind(this));return t.trigger("batch:start",{batchName:"paste"}),t.addCells(n),t.trigger("batch:stop",{batchName:"paste"}),this.copyElements(this,t,e),n},clear:function(){this.options={},this.reset([]),window.localStorage&&localStorage.removeItem(this.LOCAL_STORAGE_KEY)},modifyCell:function(t,e){var i;return t.unset("z"),t.isLink()&&e.link&&t.set(e.link),e.translate&&(void 0===(i=(e=e.translate).dx)&&(i=20),void 0===(e=e.dy)&&(e=20),t.translate(isFinite(i)?i:0,isFinite(e)?e:0)),t.collection=null,t}}),Qs=n.extend({className:"select-box",events:{"click .select-box-selection":"onToggle"},options:{options:[],width:void 0,openPolicy:"auto",target:null,keyboardNavigation:!0,selected:void 0,selectBoxOptionsClass:void 0,disabled:!1},init:function(){this.options.target=this.options.target||document.body,Mi(this,"onOutsideClick","onOptionSelect"),w(document).on("click.selectBox",this.onOutsideClick),this.$el.data("view",this),void 0===this.options.selected?this.selection=et(this.options.options).find(function(t){return!0===t.selected})||this.options.options[0]:this.selection=this.options.options[this.options.selected]},render:function(){return this.$el.empty(),this.$selection=null,this.renderSelection(this.selection),this.options.width&&this.$el.css("width",this.options.width),this.options.disabled&&this.disable(),this.$el.append(this.$options),this},renderOptions:function(){this.removeOptions();var t=this.options,e={selectBoxView:this,parentClassName:M(this,"className")||null,extraClassName:M(t,"selectBoxOptionsClass")||null,options:t.options},e=(t.width&&(e.width=t.width),t.theme&&(e.theme=t.theme),this.optionsView=new this.constructor.OptionsView(e));e.render(),this.listenTo(e,"option:select",this.onOptionSelect),this.listenTo(e,"option:hover",this.onOptionHover),this.listenTo(e,"options:mouseout",this.onOptionsMouseOut),this.$options=e.$el,this.$optionsArrow=e.$arrow,this.$target=w(t.target)},onOptionHover:function(t,e){this.trigger("option:hover",t,e)},onOptionsMouseOut:function(t){this.trigger("options:mouseout",t)},onOptionSelect:function(t,e){this.select(t,e)},removeOptions:function(){this.optionsView&&(this.stopListening(this.optionsView),this.optionsView.remove(),this.optionsView=null)},renderSelection:function(t){this.$selection||(this.$selection=w("<div/>",{class:"select-box-selection"}),this.$el.append(this.$selection)),this.$selection.empty(),t?(t=this.constructor.OptionsView.prototype.renderOptionContent.call(void 0,t),this.$selection.append(t)):this.options.placeholder&&(t=w("<div/>",{class:"select-box-placeholder",html:this.options.placeholder}),this.$selection.append(t))},onToggle:function(t){this.toggle()},onOutsideClick:function(t){!this.el.contains(t.target)&&this.$el.hasClass("opened")&&this.close()},getSelection:function(){return this.selection},getSelectionValue:function(t){return(t=t||this.selection)&&(void 0===t.value?t.content:t.value)},getSelectionIndex:function(){return et(this.options.options).findIndex(function(t){return t===this.selection}.bind(this))},select:function(t,e){this.selection=this.options.options[t],this.renderSelection(this.selection),this.trigger("option:select",this.selection,t,e),this.close()},selectByValue:function(t,e){for(var i=this.options.options||[],n=0;n<i.length;n++){var r=i[n];if(void 0===r.value&&r.content===t)return this.select(n,e);if(void 0!==r.value&&pi(r.value,t))return this.select(n,e)}},isOpen:function(){return this.$el.hasClass("opened")},toggle:function(){this.isOpen()?this.close():this.open()},position:function(){var t=this.$(".select-box-selection"),e=t.outerHeight(),t=t.offset(),i=t.left,n=t.top,r=this.$options.outerHeight(),o={left:0,top:0},t=(this.options.target!==document.body?((o=this.$target.offset()).width=this.$target.outerWidth(),o.height=this.$target.outerHeight(),o.left-=this.$target.scrollLeft(),o.top-=this.$target.scrollTop()):(o.width=w(window).width(),o.height=w(window).height()),i),s="auto",i=this.options.openPolicy;switch(i="selected"!==i||this.selection?i:"auto"){case"above":s=n-r;break;case"coverAbove":s=n-r+e;break;case"below":s=n+e;break;case"coverBelow":s=n;break;case"selected":s=n-this.$options.find(".selected").position().top;break;default:s=n-this.$target.scrollTop()+r>o.top+o.height?n-r+e:n}t-=o.left,s-=o.top,this.$options.css({left:t,top:s})},open:function(){this.isDisabled()||(this.renderOptions(),this.$options.appendTo(this.options.target),this.$options.addClass("rendered"),this.position(),this.$el.addClass("opened"),this.respectWindowBoundaries(),this.alignOptionsArrow())},respectWindowBoundaries:function(){var t=this.calculateElOverflow(this.$options,this.$target),e={left:0,top:0};this.$options.outerWidth()<=this.$target.innerWidth()&&(t.left&&t.right||(t.left?e.left=t.left:t.right&&(e.left=-t.right))),this.$options.outerHeight()<=this.$target.innerHeight()&&(t.top&&t.bottom||(t.top?e.top=t.top:t.bottom&&(e.top=-t.bottom))),this.$options.css({left:"+="+e.left,top:"+="+e.top})},alignOptionsArrow:function(){var t=this.$el[0].getBoundingClientRect(),e=this.$options[0].getBoundingClientRect(),t=t.left+t.width/2,t=(t-=e.left)-this.$optionsArrow.outerWidth()/2;this.$optionsArrow.css({left:t})},close:function(){this.removeOptions(),this.$el.removeClass("opened"),this.trigger("close")},onRemove:function(){this.removeOptions(),w(document).off(".selectBox",this.onOutsideClick)},isDisabled:function(){return this.$el.hasClass("disabled")},enable:function(){this.$el.removeClass("disabled")},disable:function(){this.close(),this.$el.addClass("disabled")},onSetTheme:function(t,e){this.$options&&(t&&this.$options.removeClass(this.themeClassNamePrefix+t),this.$options.addClass(this.themeClassNamePrefix+e))},calculateElOverflow:function(t,e){e=e||window,t instanceof w&&(t=t[0]),e instanceof w&&(e=e[0]);var i,n,r={},o=t.getBoundingClientRect();return n=e===window?{width:t=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,height:i=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,left:0,top:0,right:t,bottom:i}:e.getBoundingClientRect(),["left","top"].forEach(function(t){r[t]=Math.min(0,o[t]-n[t])}),["right","bottom"].forEach(function(t){r[t]=Math.min(0,n[t]-o[t])}),k(r,function(t,e){r[e]=Math.abs(Math.round(t))}),r}},{OptionsView:n.extend({events:{"mouseover .select-box-option":"onOptionHover","click .select-box-option":"onOptionClick"},className:function(){var t=["select-box-options"],e=this.options.parentClassName;return e&&t.push(e),t.join(" ")},init:function(){Mi(this,"onMouseout","onKeydown"),w(document).on({"keydown.selectBoxOptions":this.onKeydown,"mouseleave.selectBoxOptions mouseout.selectBoxOptions":this.onMouseout})},render:function(){var t=this.options.extraClassName;return t&&this.$el.addClass(t),this.options.width&&this.$el.css("width",this.options.width),et(this.options.options).forEach(function(t,e){e=this.renderOption(t,e);this.options.selectBoxView.selection===t&&e.addClass("selected hover"),this.$el.append(e)},this),this.$arrow=w("<div/>").addClass("select-box-options-arrow").appendTo(this.$el),this},renderOption:function(t,e){t=this.renderOptionContent(t);return t.addClass("select-box-option"),t.data("index",e),t},renderOptionContent:function(t){var e=w("<div/>",{class:"select-box-option-content",html:t.content});return t.icon&&e.prepend(w("<img/>",{class:"select-box-option-icon",src:t.icon})),e},select:function(t,e){this.trigger("option:select",t,e)},hover:function(t){var e=this.options.options[t];this.markOptionHover(t),this.trigger("option:hover",e,t)},onOptionClick:function(t){t=this.getOptionIndex(t.target);this.select(t,{ui:!0})},onOptionHover:function(t){t=this.getOptionIndex(t.target);this.hover(t)},onMouseout:function(t){this.trigger("options:mouseout",t)},onKeydown:function(t){var e,i=this.options.selectBoxView;if(i.options.keyboardNavigation&&i.isOpen()){switch(t.which){case 39:case 40:e=1;break;case 38:case 37:e=-1;break;case 13:var n=this.getOptionHoverIndex();return void(0<=n&&this.select(n));case 27:return i.close();default:return}t.preventDefault();var t=this.getOptionHoverIndex()+e,r=this.options.options;(t=t<0?r.length-1:t)>=r.length&&(t=0),this.hover(t)}},onRemove:function(){w(document).off(".selectBoxOptions")},markOptionHover:function(t){this.$el.find(".hover").removeClass("hover"),w(this.$el.find(".select-box-option")[t]).addClass("hover")},getOptionHoverIndex:function(){return this.$el.find(".select-box-option.hover").index()},getOptionIndex:function(t){return w(t).closest(".select-box-option").data("index")}})}),Ks=Qs.extend({className:"select-box color-palette",position:function(){var t=this.$(".select-box-selection"),e=t.outerHeight(),t=t.offset(),i=t.left,t=t.top+e;this.options.target!==document.body&&(this.$target=this.$target||w(this.options.target),i-=(e=this.$target.offset()).left-this.$target.scrollLeft(),t-=e.top-this.$target.scrollTop()),this.$options.css({left:i,top:t})}},{OptionsView:Qs.OptionsView.extend({renderOptionContent:function(t){var e=w("<div/>",{class:"select-box-option-content"});return e.css("background-color",t.content),t.icon&&e.prepend(w("<img/>",{class:"select-box-option-icon",src:t.icon})),e}})}),_o=n.extend({className:"context-toolbar",eventNamespace:"context-toolbar",events:{"click .tool":"onToolPointerdown"},options:{padding:20,autoClose:!0,vertical:!1},documentEvents:{mousedown:"onDocumentPointerdown",touchstart:"onDocumentPointerdown"},init:function(){Mi(this,"onDocumentPointerdown")},render:function(){var t=this.options,e=this.constructor;return e.opened&&e.close(),t.autoClose&&setTimeout(this.delegateAutoCloseEvents.bind(this),0),t.type&&this.$el.attr("data-type",t.type),this.$el.toggleClass("joint-vertical",!!t.vertical),this.getRoot().append(this.$el),this.renderContent(),this.position(),e.opened=this},delegateAutoCloseEvents:function(){this.delegateDocumentEvents(),document.addEventListener("mousedown",this.onDocumentPointerdown,!0),document.addEventListener("touchstart",this.onDocumentPointerdown,!0)},undelegateAutoCloseEvents:function(){this.undelegateDocumentEvents(),document.removeEventListener("mousedown",this.onDocumentPointerdown,!0),document.removeEventListener("touchstart",this.onDocumentPointerdown,!0)},renderContent:function(){var i=w("<div/>",{class:"tools"});this.options.tools&&et(this.options.tools).forEach(function(t){var e=t.icon?w("<img/>",{src:t.icon}):t.content,e=w("<button/>",{class:"tool",html:e,"data-action":t.action});t.attrs&&e.attr(t.attrs),i.append(e)}),this.$el.append(i)},getRoot:function(){return w(this.options.root||document.documentElement)},position:function(){var t=Ze(this.options.target),e=Ze(this.getRoot()),i=this.$el.outerWidth(),i=t.x+t.width/2-i/2,t=t.y+t.height+this.options.padding;i-=e.x,t-=e.y,this.$el.css({left:i,top:t})},onRemove:function(){this.undelegateAutoCloseEvents(),this.constructor.opened=void 0},onToolPointerdown:function(t){var e=w(t.currentTarget).attr("data-action");e&&this.trigger("action:"+e,t)},onDocumentPointerdown:function(t){var e=this.el,i=this.options,i=w(i.target)[0],t=t.target;e.contains(t)||e===t||!i||i===t||i.contains(t)||(this.constructor.close(),this.remove())}},{opened:void 0,close:function(){this.opened&&(this.opened.remove(),this.opened=void 0)},update:function(){this.opened&&this.opened.position()}}),qs=n.extend({className:"dialog",events:{"click .bg":"action","click .btn-close":"action","click .controls button":"action","mousedown .titlebar":"onDragStart","touchstart .titlebar":"onDragStart"},options:{draggable:!1,closeButtonContent:"×",closeButton:!0,inlined:!1,modal:!0,width:0,title:"",buttons:null,type:"",content:null},init:function(){Mi(this,"onDrag","onDragEnd"),this.buttons=this.options.buttons},render:function(){var i,n,r,t=w("<div/>",{class:"bg","data-action":"close"}),e=w("<div/>",{class:"fg"}),o=w("<div/>",{class:"titlebar"}),s=w("<div/>",{class:"body"}),a=w("<button/>",{class:"btn-close","data-action":"close",html:this.options.closeButtonContent}),l=w("<div/>",{class:"controls"});return this.$el.toggleClass("draggable",!!this.options.draggable),this.options.type&&this.$el.attr("data-type",this.options.type),this.options.inlined&&this.$el.addClass("inlined"),this.options.modal&&this.$el.addClass("modal"),this.options.width&&e.width(this.options.width),this.options.title?o.append(this.options.title):o.addClass("empty"),this.options.content&&s.append(this.options.content),this.buttons&&(i=[],n=[],r=[],this.buttons.forEach(function(t){var e=w("<button/>",{class:"control-button",html:t.content,"data-action":t.action});t.position?"left"===t.position?(e.addClass(t.position),r.push(e)):"center"===t.position?(e.addClass(t.position),n.push(e)):(e.addClass(t.position),i.push(e)):i.push(e)}),i.reverse().forEach(function(t){l.append(t)}),r.forEach(function(t){l.append(t)}),n.forEach(function(t){l.append(t)})),e.append(o,s,l),this.options.closeButton&&e.append(a),this.$el.empty().append(t,e),this},open:function(t){return this.delegateEvents(),this.on("action:close",this.close,this),w(document.body).on({"mousemove.dialog touchmove.dialog":this.onDrag,"mouseup.dialog touchend.dialog":this.onDragEnd}),w(t||document.body).append(this.render().el),this.$el.addClass("rendered"),this},close:function(){return this.remove(),this},onRemove:function(){w(document.body).off(".dialog",this.onDrag).off(".dialog",this.onDragStart)},action:function(t){t=w(t.target).closest("[data-action]").attr("data-action");t&&this.trigger("action:"+t)},onDragStart:function(t){this.options.draggable&&(t=I(t),this._dx=t.clientX,this._dy=t.clientY,this._dragging=!0)},onDrag:function(t){var e,i;this._dragging&&(t=I(t),i=(e=this.$(".fg")).offset(),e.css({top:i.top+(t.clientY-this._dy),left:i.left+(t.clientX-this._dx),margin:0}),this._dx=t.clientX,this._dy=t.clientY)},onDragEnd:function(){this._dragging=!1}}),ta=qs.extend({className:qs.prototype.className+" flash-message",options:y({},qs.prototype.options,{closeButton:!0,modal:!1,cascade:!0,closeAnimation:{delay:2e3,duration:200,easing:"swing",properties:{opacity:0}},openAnimation:{duration:200,easing:"swing",properties:{opacity:1}}}),init:function(){Mi(this,"startCloseAnimation"),qs.prototype.init.apply(this,arguments),this.on("close:animation:complete",this.close,this)},open:function(){qs.prototype.open.apply(this,arguments);var t=this.$(".fg");return this._foregroundHeight=t.height(),this.addToCascade(),t.css("height",0),this.startOpenAnimation(),this.options.closeAnimation&&this.options.closeAnimation.delay&&setTimeout(this.startCloseAnimation,this.options.closeAnimation.delay),this},close:function(){return qs.prototype.close.apply(this,arguments),this.removeFromCascade(),this},addToCascade:function(){var t;this.options.cascade&&(t=this.constructor.top,this.$(".fg").css("top",t),this.constructor.top+=this._foregroundHeight+this.constructor.padding),this.constructor.opened.push(this)},removeFromCascade:function(){if(this.options.cascade){for(var t=this.constructor.opened,e=!1,i=0;i<t.length;i++){var n,r=t[i];r.options.cascade&&e&&(n=parseInt(r.$(".fg").css("top"),10),r.$(".fg").css("top",n-this._foregroundHeight-this.constructor.padding)),r===this&&(e=!0)}e&&(this.constructor.top-=this._foregroundHeight+this.constructor.padding)}this.constructor.opened=wi(this.constructor.opened,this)},startCloseAnimation:function(){this.$(".fg").animate(this.options.closeAnimation.properties,R({complete:function(){this.trigger("close:animation:complete")}.bind(this)},this.options.closeAnimation))},startOpenAnimation:function(){this.$(".fg").animate(R({},this.options.openAnimation.properties,{height:this._foregroundHeight}),R({complete:function(){this.trigger("open:animation:complete")}.bind(this)},this.options.openAnimation))}},{top:20,padding:15,opened:[],open:function(t,e,i){return new ta(R({title:e,type:"info",content:t},i=i||{})).open(i.target)},close:function(){li(this.opened,"close")}}),ea=n.extend({className:"free-transform",events:{"mousedown .resize":"startResizing","mousedown .rotate":"startRotating","touchstart .resize":"startResizing","touchstart .rotate":"startRotating"},DIRECTIONS:["nw","n","ne","e","se","s","sw","w"],POSITIONS:["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"],options:{cellView:void 0,rotateAngleGrid:15,resizeGrid:void 0,preserveAspectRatio:!1,minWidth:0,minHeight:0,maxWidth:1/0,maxHeight:1/0,allowOrthogonalResize:!0,resizeDirections:null,allowRotation:!0,clearAll:!0,clearOnBlankPointerdown:!0,usePaperScale:!1,padding:3},documentEvents:{mousemove:"pointermove",touchmove:"pointermove",mouseup:"pointerup",touchend:"pointerup"},init:function(){var t=this.options,e=(t.cellView?S(t,{cell:t.cellView.model,paper:t.cellView.paper,graph:t.cellView.paper.model}):t.paper&&t.cell&&S(t,{cellView:t.cell.findView(t.paper),graph:t.paper.model}),t.paper);t.clearAll&&this.constructor.clear(e),this.startListening(),e.$el.append(this.el),this.constructor.registerInstanceToPaper(this,e)},startListening:function(){var t=this,e=this.options,i=e.cell,n=e.paper,r=e.graph,e=e.clearOnBlankPointerdown;this.listenTo(i,"change:size change:position change:angle",this.onCellAttributeChange),this.listenTo(n,"scale translate",function(){return t.requestUpdate()}),this.listenTo(r,"reset",function(){return t.remove()}),this.listenTo(i,"remove",function(){return t.remove()}),e&&this.listenTo(n,"blank:pointerdown",function(){return t.remove()})},onCellAttributeChange:function(t,e,i){i.updateHandled||this.requestUpdate()},renderHandles:function(){var t=this.options,i=this.POSITIONS,e=w("<div/>").prop("draggable",!1),n=e.clone().addClass("rotate"),r=i.map(function(t){return e.clone().addClass("resize").attr("data-position",t)}),o=t.resizeDirections;Array.isArray(o)&&r.forEach(function(t,e){o.includes(i[e])||t.hide()}),this.$el.empty().append(r,n)},render:function(){var t=this.options,e=this.$el,i=t.cell,n=t.preserveAspectRatio,r=t.allowRotation,t=t.allowOrthogonalResize;e.attr("data-type",i.get("type")),e.toggleClass("no-orthogonal-resize",n||!t),e.toggleClass("no-rotation",!r),this.renderHandles(),this.requestUpdate()},requestUpdate:function(t){var e=this.UPDATE_PRIORITY;this.options.paper.requestViewUpdate(this,1,e,t)},confirmUpdate:function(){this.update()},update:function(){this.options.usePaperScale?this.updateFrameScaled():this.updateFrameNoScale(),this.updateHandleDirections()},updateFrameScaled:function(){var t=this.options,e=t.paper,i=t.cell,t=t.padding,t=ei(t),n=t.left,r=t.right,o=t.top,t=t.bottom,n=i.getBBox().moveAndExpand({x:-n,y:-o,width:n+r,height:o+t}),r=n.x,o=n.y,t=n.width,n=n.height,i=i.angle(),e=e.matrix().translate(r,o).translate(t/2,n/2).rotate(i).translate(-t/2,-n/2),r=B.matrixToTransformString(e);this.$el.css({width:t,height:n,left:0,top:0,"transform-origin":"0 0",transform:r,"-webkit-transform":r,"-ms-transform":r})},updateFrameNoScale:function(){var t=this.options,e=t.paper,i=t.cell,t=t.padding,t=ei(t),n=t.left,r=t.right,o=t.top,t=t.bottom,e=e.matrix(),s=e.a,a=e.d,l=e.e,e=e.f,h=i.getBBox(),i=i.angle(),l=(h.x*=s,h.x+=l,h.y*=a,h.y+=e,h.width*=s,h.height*=a,h.moveAndExpand({x:-n,y:-o,width:n+r,height:o+t}),"rotate("+i+"deg)");this.$el.css({width:h.width,height:h.height,left:h.x,top:h.y,"transform-origin":"50% 50%",transform:l,"-webkit-transform":l,"-ms-transform":l})},updateHandleDirections:function(){var i,t=this.options.cell.angle(),t=Math.floor(t*(this.DIRECTIONS.length/360));t!=this._previousDirectionsShift&&(i=this.DIRECTIONS.slice(t).concat(this.DIRECTIONS.slice(0,t)),this.$(".resize").removeClass(this.DIRECTIONS.join(" ")).each(function(t,e){w(e).addClass(i[t])}),this._previousDirectionsShift=t)},calculateTrueDirection:function(t){var e=this.options.cell,e=Q(e.get("angle")),t=this.POSITIONS.indexOf(t),t=(t+=Math.floor(e*(this.POSITIONS.length/360)))%this.POSITIONS.length;return this.POSITIONS[t]},startResizing:function(t){t.stopPropagation();var e=this.options,i=e.cell,n=e.graph,r=e.paper,n=(n.startBatch("free-transform",{freeTransform:this.cid}),w(t.target).data("position")),o=this.calculateTrueDirection(n),s=0,a=0,l=(n.split("-").forEach(function(t){s={left:-1,right:1}[t]||s,a={top:-1,bottom:1}[t]||a}),this.toValidResizeDirection(n)),h={"top-right":"bottomLeft","top-left":"corner","bottom-left":"topRight","bottom-right":"origin"}[l],c=e.minWidth,u=e.minHeight,d=e.maxWidth,e=e.maxHeight,c="function"==typeof c?c.call(this,i,this):c,u="function"==typeof u?u.call(this,i,this):u,d="function"==typeof d?d.call(this,i,this):d,e="function"==typeof e?e.call(this,i,this):e,h={action:"resize",angle:i.angle(),resizeX:s,resizeY:a,selector:h,direction:l,relativeDirection:n,trueDirection:o,maxHeight:e,minHeight:u,maxWidth:d,minWidth:c,cellView:i.findView(r)};this.startOp(t.target),this.delegateDocumentEvents(null,h),this.trigger(h.action+":start",t)},toValidResizeDirection:function(t){return{top:"top-left",bottom:"bottom-right",left:"bottom-left",right:"top-right"}[t]||t},startRotating:function(t){t.stopPropagation(),this.options.graph.startBatch("free-transform",{freeTransform:this.cid});var e=this.options.cell.getBBox().center(),i=this.options.paper.snapToGrid({x:t.clientX,y:t.clientY}),i={action:"rotate",centerRotation:e,modelAngle:Q(this.options.cell.get("angle")||0),startAngle:A(i).theta(e)};this.startOp(t.target),this.delegateDocumentEvents(null,i),this.trigger(i.action+":start",t)},pointermove:function(t){var e=t.data,i=e.action,n=e.maxHeight,r=e.maxWidth,o=e.minHeight,s=e.minWidth,a=e.cellView;if(i){t=I(t);var l=this.options,h=l.cell,c=l.paper.snapToGrid({x:t.clientX,y:t.clientY}),u=l.paper.options.gridSize,d=l.resizeGrid||{},g=d.width||u,p=d.height||u;switch(i){case"resize":var f,m=h.getBBox(),v=A(c).rotate(m.center(),e.angle).difference(m[e.selector]()),y=e.resizeX?v.x*e.resizeX:m.width,v=e.resizeY?v.y*e.resizeY:m.height,y=E(y,g),v=E(v,p);y=Math.max(y,s||g),v=Math.max(v,o||p),y=Math.min(y,r),v=Math.min(v,n),l.preserveAspectRatio&&(b=m.width*v/m.height,f=m.height*y/m.width,y<b?v=f:y=b),m.width==y&&m.height==v||(f={freeTransform:this.cid,direction:e.direction,relativeDirection:e.relativeDirection,trueDirection:e.trueDirection,ui:!0,minWidth:s,minHeight:o,maxWidth:r,maxHeight:n,preserveAspectRatio:l.preserveAspectRatio},a.scalableNode&&(f.async=!1),h.resize(y,v,f));break;case"rotate":var b=e.startAngle-A(c).theta(e.centerRotation);h.rotate(E(e.modelAngle+b,l.rotateAngleGrid),!0,null,{freeTransform:this.cid})}this.trigger(""+i,t)}},pointerup:function(t){this.undelegateDocumentEvents();var e=t.data;e&&e.action&&(this.stopOp(),this.trigger(e.action+":stop",t),this.options.graph.stopBatch("free-transform",{freeTransform:this.cid}))},onRemove:function(){ea.unregisterInstanceFromPaper(this,this.options.paper)},startOp:function(t){t&&(w(t).addClass("in-operation"),this._elementOp=t),this.$el.addClass("in-operation"),this.options.paper.undelegateEvents()},stopOp:function(){this._elementOp&&(w(this._elementOp).removeClass("in-operation"),this._elementOp=null),this.$el.removeClass("in-operation"),this.options.paper.delegateEvents()}},{instancesByPaper:{},clear:function(t){t.trigger("freetransform:create"),this.removeInstancesForPaper(t)},removeInstancesForPaper:function(t){li(this.getInstancesForPaper(t),"remove")},getInstancesForPaper:function(t){return this.instancesByPaper[t.cid]||{}},registerInstanceToPaper:function(t,e){this.instancesByPaper[e.cid]||(this.instancesByPaper[e.cid]={}),this.instancesByPaper[e.cid][t.cid]=t},unregisterInstanceFromPaper:function(t,e){this.instancesByPaper[e.cid]&&(this.instancesByPaper[e.cid][t.cid]=null)}}),Ro=(Ps.prototype.directionSwap=function(){var t=this.options.cellView.model;t.set({source:t.get("target"),target:t.get("source")},{halo:this.cid})},Ms.prototype.startLinking=function(t,e,i){this.startBatch();var n=this.options,r=n.paper,n=n.graph,t=this.createLinkConnectedToSource(t);t.set({target:{x:e,y:i}}).addTo(n,{validation:!1,halo:this.cid,async:!1}),r.undelegateEvents(),(this._linkView=t.findView(r)).startArrowheadMove("target",{whenNotAllowed:"remove"})},Ms.prototype.startForking=function(t,e,i){var n=this.options,r=n.paper,n=n.graph,o=(this.startBatch(),this.cloneCell({fork:!0})),s=(this.centerElementAtCursor(o,e,i),o.addTo(n,{halo:this.cid,async:!1}),this.createLinkConnectedToSource(t)),o=o.findView(r),r=this.getElementMagnet(o,"target",t),r=this.getLinkEnd(o,r,t);s.set("target",r).addTo(n,{halo:this.cid,async:!1}),o.pointerdown(t,e,i),this.eventData(t,{cloneView:o})},Ms.prototype.getElementMagnet=function(t,e,i){var n=this.options.magnet;if(P(n)){n=n.call(this,t,e,i);if(n instanceof SVGElement)return n}throw new Error("ui.Halo: magnet() has to return an SVGElement.")},Ms.prototype.getLinkEnd=function(t,e,i){var n,r={id:t.model.id};return e!==t.el&&((n=t.findAttribute("port",e))?r.port=n:r.selector=t.getSelector(e)),r},Ms.prototype.createLinkConnectedToSource=function(t){var e=this.options,i=e.paper,n=e.cellView,r=this.getElementMagnet(n,"source",t),t=this.getLinkEnd(n,r,t),i=i.getDefaultLink(n,r).set("source",t);return i.attr(e.linkAttributes),Ue(e.smoothLinks)&&i.set("smooth",e.smoothLinks),i},Ms.prototype.startResizing=function(t){this.startBatch(),this._flip=[1,0,0,1,1,0,0,1][Math.floor(Q(this.options.cellView.model.get("angle"))/45)]},Ms.prototype.startRotating=function(t,e,i){this.startBatch();var n=this.options.cellView.model,r=n.getBBox().center(),o=[n];this.options.rotateEmbeds&&n.getEmbeddedCells({deep:!0}).reduce(function(t,e){return e.isElement()&&t.push(e),t},o),this.eventData(t,{center:r,elements:o,rotationStartAngles:o.map(function(t){return t.angle()}),clientStartAngle:new z(e,i).theta(r)})},Ms.prototype.doResize=function(t,e,i,n,r){var o=this.options.cellView.model.get("size"),s=Math.max(o.width+(this._flip?n:r),1),o=Math.max(o.height+(this._flip?r:n),1);this.options.cellView.model.resize(s,o,{absolute:!0})},Ms.prototype.doRotate=function(t,e,i){var n=this.eventData(t),r=n.clientStartAngle-new z(e,i).theta(n.center);n.elements.forEach(function(t,e){e=n.rotationStartAngles[e],e=E(e+r,this.options.rotateAngleGrid);t.rotate(e,!0,n.center,{halo:this.cid})},this)},Ms.prototype.doClone=function(t,e,i){var n=this.eventData(t).cloneView;n&&n.pointermove(t,e,i)},Ms.prototype.startCloning=function(t,e,i){var n=this.options,r=(this.startBatch(),this.cloneCell({clone:!0})),r=(this.centerElementAtCursor(r,e,i),r.addTo(n.graph,{halo:this.cid,async:!1}),r.findView(n.paper));r.pointerdown(t,e,i),this.eventData(t,{cloneView:r})},Ms.prototype.centerElementAtCursor=function(t,e,i){var n=t.getBBox().center(),e=e-n.x,i=i-n.y;t.translate(e,i)},Ms.prototype.doFork=function(t,e,i){var n=this.eventData(t).cloneView;n&&n.pointermove(t,e,i)},Ms.prototype.doLink=function(t,e,i){this._linkView&&this._linkView.pointermove(t,e,i)},Ms.prototype.stopLinking=function(t,e,i){var n=this._linkView;n&&(n.pointerup(t,e,i),(t=n.model).hasLoop()&&this.makeLoopLink(t),this.stopBatch(),this.triggerAction("link","add",t),this._linkView=null),this.options.paper.delegateEvents()},Ms.prototype.stopForking=function(t,e,i){var n=this.eventData(t).cloneView;n&&n.pointerup(t,e,i),this.stopBatch()},Ms.prototype.stopCloning=function(t,e,i){var n=this.eventData(t).cloneView;n&&n.pointerup(t,e,i),this.stopBatch()},Ms.prototype.unlinkElement=function(t){this.startBatch(),this.options.graph.removeLinks(this.options.cellView.model),this.stopBatch()},n.extend({PIE_INNER_RADIUS:20,PIE_OUTER_RADIUS:50,className:"halo",events:{"mousedown .handle":"onHandlePointerDown","touchstart .handle":"onHandlePointerDown","mousedown .pie-toggle":"onPieTogglePointerDown","touchstart .pie-toggle":"onPieTogglePointerDown"},documentEvents:{mousemove:"pointermove",touchmove:"pointermove",mouseup:"pointerup",touchend:"pointerup"},options:{clearAll:!0,clearOnBlankPointerdown:!0,useModelGeometry:!(Ms.prototype.makeLoopLink=function(t){var r,o,s=this.options.loopLinkWidth,e=this.options.paper.options,a=Nt({x:0,y:0,width:e.width,height:e.height}),l=this.options.paper.paperToLocalRect(this.options.cellView.getBBox());ci([this.options.loopLinkPreferredSide,"top","bottom","left","right"]).find(function(t){var e,i=0,n=0;switch(t){case"top":e=A(l.x+l.width/2,l.y-s),i=s/2;break;case"bottom":e=A(l.x+l.width/2,l.y+l.height+s),i=s/2;break;case"left":e=A(l.x-s,l.y+l.height/2),n=s/2;break;case"right":e=A(l.x+l.width+s,l.y+l.height/2),n=s/2}return r=A(e).offset(-i,-n),o=A(e).offset(i,n),a.containsPoint(r)&&a.containsPoint(o)},this)&&t.set("vertices",[r,o])}),clone:function(t,e){return t.clone().unset("z")},type:"surrounding",pieSliceAngle:45,pieStartAngleOffset:0,pieIconSize:14,pieToggles:[{name:"default",position:"e"}]},init:function(){var t=this.options,e=t.cellView,i=e.model,n=new(i.isLink()?Ps:Ms),e=(R(this,Si(n,"options")),e.paper),r=e.model;S(t,n.options,{paper:e,graph:r}),Mi(this,"render","update"),t.clearAll&&this.constructor.clear(e),this.listenTo(r,"reset",this.remove),this.listenTo(i,"remove",this.remove),this.listenTo(e,"halo:create",this.remove),t.clearOnBlankPointerdown&&this.listenTo(e,"blank:pointerdown",this.remove),this.listenTo(r,"all",this.update),this.listenTo(e,"scale translate",this.update),this.handles=[],et(t.handles).forEach(this.addHandle,this)},render:function(){var t=this.options;switch(this.$el.empty(),this.$handles=w("<div/>").addClass("handles").appendTo(this.el),this.$box=w("<label/>").addClass("box").appendTo(this.el),this.$pieToggles={},this.$el.addClass(t.type),this.$el.addClass(this.cellTypeCssClass()),this.$el.attr("data-type",t.cellView.model.get("type")),this.$handles.append(et(this.handles).map(this.renderHandle,this)),t.type){case"toolbar":case"surrounding":this.hasHandle("fork")&&this.toggleFork();break;case"pie":et(this.options.pieToggles).forEach(function(t){var e=w("<div/>");e.addClass("pie-toggle "+(t.position||"e")),e.attr("data-name",t.name),We(e,t.attrs),e.appendTo(this.el),this.$pieToggles[t.name]=e},this);break;default:throw new Error("ui.Halo: unknown type")}return this.update(),this.$el.addClass("animate").appendTo(t.paper.el),this.setPieIcons(),this},setPieIcons:function(){"pie"===this.options.type&&this.$el.find(".handle").each(function(t,e){var i,n=w(e),r=n.attr("data-action"),r=this.getHandle(r);r&&r.icon||((r=window.getComputedStyle(e,":before").getPropertyValue("content"))&&"none"!==r&&0<(i=n.find(".slice-text-icon")).length&&B(i[0]).text(r.replace(/['"]/g,"")),(e=n.css("background-image"))&&(r=e.match(/url\(['"]?([^'"]+)['"]?\)/))&&(e=r[1],0<(i=n.find(".slice-img-icon")).length&&B(i[0]).attr("xlink:href",e)))}.bind(this))},update:function(){var t;this.isRendered()&&(this.updateBoxContent(),t=this.getBBox(),this.$el.toggleClass("tiny",t.width<this.options.tinyThreshold&&t.height<this.options.tinyThreshold),this.$el.toggleClass("small",!this.$el.hasClass("tiny")&&t.width<this.options.smallThreshold&&t.height<this.options.smallThreshold),this.$el.css({width:t.width,height:t.height,left:t.x,top:t.y}),this.hasHandle("unlink")&&this.toggleUnlink())},getBBox:function(){var t=this.options.cellView,e=this.options.bbox,t=P(e)?e(t,this):e,t=S({},t,{x:0,y:0,width:1,height:1});return Nt(t)},cellTypeCssClass:function(){return this.options.typeCssName},updateBoxContent:function(){var t=this.options.boxContent,e=this.options.cellView;P(t)?(e=t.call(this,e,this.$box[0]))&&this.$box.html(e):t?this.$box.html(t):this.$box.remove()},extendHandles:function(t){k(t,function(t){var e=this.getHandle(t.name);e&&R(e,t)}.bind(this))},addHandles:function(t){return et(t).forEach(this.addHandle,this),this},addHandle:function(i){return this.getHandle(i.name)||(this.handles.push(i),k(i.events,function(t,e){N(t)?this.on("action:"+i.name+":"+e,this[t],this):this.on("action:"+i.name+":"+e,t)}.bind(this)),this.$handles&&this.renderHandle(i).appendTo(this.$handles)),this},renderHandle:function(t){var e=this.getHandleIdx(t.name),i=w("<div/>").addClass("handle").addClass(t.name).attr("data-action",t.name).prop("draggable",!1);switch(this.options.type){case"toolbar":case"surrounding":i.addClass(t.position),t.content&&i.html(t.content);break;case"pie":var n=this.PIE_OUTER_RADIUS,r=this.PIE_INNER_RADIUS,o=(n+r)/2,s=A(n,n),a=K(this.options.pieSliceAngle),l=e*a+K(this.options.pieStartAngleOffset),r=B.createSlicePathData(r,n,l,l+a),h=B("svg").addClass("slice-svg"),r=B("path").attr("d",r).translate(n,n).addClass("slice"),n=A.fromPolar(o,-l-a/2,s),o=this.options.pieIconSize,l=B("image").attr(n).addClass("slice-img-icon"),a=(n.y=n.y+o-2,B("text",{"font-size":o}).attr(n).addClass("slice-text-icon"));l.attr({width:o,height:o}),l.translate(-o/2,-o/2),a.translate(-o/2,-o/2),h.append([r,l,a]),i.append(h.node)}return t.icon&&this.setHandleIcon(i,t.icon),We(i,t.attrs),i},setHandleIcon:function(t,e){switch(this.options.type){case"pie":var i=t.find(".slice-img-icon");B(i[0]).attr("xlink:href",e);break;case"toolbar":case"surrounding":t.css("background-image","url("+e+")")}},removeHandles:function(){for(;this.handles.length;)this.removeHandle(this.handles[0].name);return this},removeHandle:function(i){var t=this.getHandleIdx(i),e=this.handles[t];return e&&(k(e.events,function(t,e){this.off("action:"+i+":"+e)}.bind(this)),this.$(".handle."+i).remove(),this.handles.splice(t,1)),this},changeHandle:function(t,e){var i=this.getHandle(t);return i&&(this.removeHandle(t),this.addHandle(y({name:t},i,e))),this},hasHandle:function(t){return-1!==this.getHandleIdx(t)},getHandleIdx:function(e){return et(this.handles).findIndex(function(t){return t.name===e})},getHandle:function(e){return et(this.handles).find(function(t){return t.name===e})},toggleHandle:function(t,e){var i=this.getHandle(t);return i&&(t=this.$(".handle."+t),void 0===e&&(e=!t.hasClass("selected")),t.toggleClass("selected",e),(e=e?i.iconSelected:i.icon)&&this.setHandleIcon(t,e)),this},selectHandle:function(t){return this.toggleHandle(t,!0)},deselectHandle:function(t){return this.toggleHandle(t,!1)},deselectAllHandles:function(){return et(this.handles).forEach(function(t){this.deselectHandle(t.name)},this),this},onHandlePointerDown:function(t){var e,i,n=this._action=w(t.target).closest(".handle").attr("data-action");n&&(t.preventDefault(),t.stopPropagation(),t=I(t),e=(i=this.options.paper.snapToGrid({x:t.clientX,y:t.clientY})).x,i=i.y,this._localX=e,this._localY=i,"mousedown"===(this._evt=t).type&&2===t.button?this.triggerAction(n,"contextmenu",t,e,i):(this.triggerAction(n,"pointerdown",t,e,i),this.delegateDocumentEvents(null,t.data)))},onPieTogglePointerDown:function(t){t.stopPropagation();t=w(t.target).closest(".pie-toggle").attr("data-name");this.isOpen(t)||this.isOpen()&&this.toggleState(),this.toggleState(t)},triggerAction:function(t,e,i){var n=Array.prototype.slice.call(arguments,2);n.unshift("action:"+t+":"+e),this.trigger.apply(this,n)},stopBatch:function(){var t=this.options.graph;t.hasActiveBatch("halo")&&t.stopBatch("halo",{halo:this.cid})},startBatch:function(){this.options.graph.startBatch("halo",{halo:this.cid})},pointermove:function(t){var e,i,n;this._action&&(t.preventDefault(),t.stopPropagation(),t=I(t),i=(e=this.options.paper.snapToGrid({x:t.clientX,y:t.clientY})).x-this._localX,n=e.y-this._localY,this._localX=e.x,this._localY=e.y,this._evt=t,this.triggerAction(this._action,"pointermove",t,e.x,e.y,i,n))},pointerup:function(t){var e,i=this._action;i&&(this._action=null,this._evt=null,e=this.options.paper.snapToGrid({x:t.clientX,y:t.clientY}),this.triggerAction(i,"pointerup",t,e.x,e.y),this.undelegateDocumentEvents())},onRemove:function(){this._action&&this._evt&&this.pointerup(this._evt),this.stopBatch()},onSetTheme:function(){this.setPieIcons()},removeElement:function(){this.options.cellView.model.remove()},toggleUnlink:function(){var t=0<this.options.graph.getConnectedLinks(this.options.cellView.model).length;this.$handles.children(".unlink").toggleClass("hidden",!t)},toggleFork:function(){var t=this.canFork();this.$handles.children(".fork").toggleClass("hidden",!t)},canFork:function(){var t=this.options,e=t.cellView,t=t.paper,i=t.options.validateConnection;if("function"!=typeof i)return!0;var n=this.cloneCell({fork:!0,validation:!0}),n=t.createViewForModel(n);return i.call(t,e,null,n,null,"target")},cloneCell:function(t){var e=this.options,i=e.cellView,e=(0,e.clone)(i.model,t=void 0===t?{}:t);if(e instanceof rn)return e;throw new Error('ui.Halo: option "clone" has to return a cell.')},toggleState:function(e){var t,i;this.isRendered()&&(t=this.$el,k(this.$pieToggles,function(t){t.removeClass("open")}),this.isOpen()?(this.trigger("state:close",e),t.removeClass("open")):(this.trigger("state:open",e),e&&((i=et(this.options.pieToggles).find(function(t){return t.name===e}))&&t.attr({"data-pie-toggle-position":i.position,"data-pie-toggle-name":i.name}),this.$pieToggles[e].addClass("open")),t.addClass("open")))},isOpen:function(t){return!!this.isRendered()&&(t?this.$pieToggles[t]:this.$el).hasClass("open")},isRendered:function(){return void 0!==this.$box}},{clear:function(t){t.trigger("halo:create")},HandlePosition:{N:"n",NW:"nw",W:"w",SW:"sw",S:"s",SE:"se",E:"e",NE:"ne"}})),ia=n.extend({className:"select-button-group",events:{"click .select-button-group-button":"onSelect","mouseover .select-button-group-button":"onOptionHover",mouseleave:"onMouseOut","mousedown .select-button-group-button":"pointerdown","touchstart .select-button-group-button":"pointerdown","mouseup .select-button-group-button":"pointerup","touchend .select-button-group-button":"pointerup"},options:{options:[],disabled:!1,multi:!1,selected:void 0,singleDeselect:!1,noSelectionValue:void 0,width:void 0,buttonWidth:void 0,buttonHeight:void 0,iconWidth:void 0,iconHeight:void 0},init:function(){Mi(this,"onSelect","pointerup"),this.$el.data("view",this);var t,e=this.options.options,i=this.options.multi,n=this.options.selected;void 0===n?(t=et(e).filter(function(t){return t&&!0===t.selected}),this.selection=i?t:t[0]):this.selection=i?Array.isArray(n)?e.filter(function(t,e){return n.includes(e)}):[e[n]]:e[n]},render:function(){return this.renderOptions(this.selection),this.options.width&&this.$el.css("width",this.options.width),this.options.disabled&&this.disable(),this.$el.append(this.$options),this},renderOptions:function(){this.removeOptions(),et(this.options.options).forEach(function(t,e){var i=this.options.multi?this.selection.includes(t):this.selection===t,t=this.renderOption(t,e,i);this.$el.append(t),i&&t.addClass("selected")},this)},removeOptions:function(){this.$el.empty()},renderOption:function(t,e,i){i=this.renderOptionContent(t,i),i.data("index",e),e=t.buttonWidth||this.options.buttonWidth,e&&i.css("width",e),e=t.buttonHeight||this.options.buttonHeight;return e&&i.css("height",e),i},renderOptionContent:function(t,e){var i,n=w("<div/>",{class:"select-button-group-button",html:t.content});return(t.icon||e&&t.iconSelected)&&(e=w("<img/>",{class:"select-button-group-button-icon",src:e&&t.iconSelected?t.iconSelected:t.icon}),(i=t.iconWidth||this.options.iconWidth)&&e.css("width",i),(i=t.iconHeight||this.options.iconHeight)&&e.css("height",i),n.prepend(e)),We(n,t.attrs),n},getOptionIndex:function(t){return w(t).closest(".select-button-group-button").data("index")},onSelect:function(t){this.isDisabled()||(t=this.getOptionIndex(t.target),this.select(t,{ui:!0}))},onOptionHover:function(t){this.isDisabled()||(t=this.getOptionIndex(t.target),this.trigger("option:hover",this.options.options[t],t))},onMouseOut:function(t){this.isDisabled()||this.trigger("mouseout",t)},getSelection:function(){return this.selection},getSelectionValue:function(t){t=t||this.selection;var e=this.options.noSelectionValue;if(this.options.multi)return 0===(i=et(t)).length?void 0!==e?e:[]:i.map(function(t){var e=t.value;return void 0!==e?e:t.content});if(!t)return void 0!==e?e:void 0;var i=t.value;return void 0!==i?i:t.content},select:function(t,e){var i,n,r=w(this.$(".select-button-group-button")[t]),o=this.options.options[t],s=null,a=null,l=null,h=null,c=(this.options.multi?(r.toggleClass("selected"),r.hasClass("selected")?(l=t,-1===this.selection.indexOf(h=o)&&this.selection.push(o),o.iconSelected&&r.find(".select-button-group-button-icon").attr("src",o.iconSelected)):(s=t,this.selection=wi(this.selection,a=o),o.iconSelected&&r.find(".select-button-group-button-icon").attr("src",o.icon))):(c=(i=this.$(".selected")).index(),n=this.options.options[c],r.toggleClass("selected"),r.hasClass("selected")?(n&&(s=c,a=n,i.removeClass("selected"),n.iconSelected&&i.find(".select-button-group-button-icon").attr("src",n.icon)),l=t,(this.selection=h=o).iconSelected&&r.find(".select-button-group-button-icon").attr("src",o.iconSelected)):this.options.singleDeselect?(s=t,a=o,this.selection=void 0,o.iconSelected&&r.find(".select-button-group-button-icon").attr("src",o.icon)):r.addClass("selected")),R({},e));c.deselectedIndex=s,c.deselectedOption=a,c.selectedIndex=l,c.selectedOption=h,this.trigger("option:select",this.selection,t,c)},selectByValue:function(t,e){Array.isArray(t)||(t=[t]);for(var i=this.options.options||[],n=0;n<i.length;n++){var r=i[n];(void 0===r.value&&t.includes(r.content)||void 0!==r.value&&t.find(function(t){return pi(t,r.value)}))&&this.select(n,e)}},deselect:function(){this.$(".selected").removeClass("selected"),this.options.multi?this.selection=[]:this.selection=void 0},isDisabled:function(){return this.$el.hasClass("disabled")},enable:function(){this.$el.removeClass("disabled")},disable:function(){this.$el.addClass("disabled")},pointerdown:function(t){t=this.getOptionIndex(t.target);w(this.$(".select-button-group-button")[t]).addClass("is-in-action"),w(document).on("mouseup.select-button-group touchend.select-button-group",this.pointerup)},pointerup:function(){this.$(".is-in-action").removeClass("is-in-action"),w(document).off("mouseup.select-button-group touchend.select-button-group")}}),na=n.extend({className:"inspector",options:{cellView:void 0,cell:void 0,live:!0,validateInput:function(t,e,i,n){return!t.validity||t.validity.valid},renderFieldContent:void 0,renderLabel:void 0,operators:{},multiOpenGroups:!0,container:null,stateKey:function(t){return t.id}},events:{"change [data-attribute]:not([data-custom-field])":"onChangeInput","click .group-label":"onGroupLabelClick","click .btn-list-add":"addListItem","click .btn-list-del":"deleteListItem","mousedown .field":"pointerdown","touchstart .field":"pointerdown","focusin .field":"pointerfocusin","focusout .field":"pointerfocusout"},HTMLEntities:{lt:"<",gt:">",amp:"&",nbsp:" ",quot:'"',cent:"\xa2",pound:"\xa3",euro:"\u20ac",yen:"\xa5",copy:"\xa9",reg:"\xae"},init:function(){var t,e=this.options.groups=this.options.groups||{},i=(Mi(this,"stopBatchCommand","pointerup","onContentEditableBlur","replaceHTMLEntity"),this.DEFAULT_PATH_WILDCARD="${index}",this.pathWildcard=this.options.pathWildcard,this.widgets={},this._byPath={},this._attributeKeysInUse=[],this.flatAttributes=this.flattenInputs(this.options.inputs),this.expandAttributes=this.expandAttrs(this.options.inputs||{}),this._when={},this._bound={},Object.keys(this.flatAttributes).map(function(t){var e=this.flatAttributes[t];return this._registerDependants.call(this,e,t),e.path=t,e},this));for(t in e){var n=e[t];n&&e.hasOwnProperty(t)&&this.extractExpressionPaths(n.when).forEach(function(t){this._when[t]||(this._when[t]=[])},this)}i=yi(i,"index");this.groupedFlatAttributes=yi(i,function(t){t=this.options.groups[t.group];return t&&t.index||Number.MAX_VALUE}.bind(this)),this.listenTo(this.getModel(),"all",this.onCellChange,this)},_registerDependants:function(t,e){var i,n;t.when&&(i=t.when,n={expression:i,path:e},this.extractExpressionPaths(i).forEach(function(t){(this._when[t]||(this._when[t]=[])).push(n)},this)),this.needsResolving(t)&&(this._bound[e]=t.options),this._registerNestedDependants.call(this,t,e)},_registerNestedDependants:function(i,t){var n,e,r=Array.isArray(t)?t:t.split("/");"object"===i.type&&i.properties?(n=i.properties,Object.keys(n).forEach(function(t){var e=n[t],t=r.concat(t);this._registerDependants(e,t)},this)):"list"===i.type&&i.item?(t=i.item,e=r.concat(null),this._registerDependants(t,e)):"string"!=typeof i.type&&Object.keys(i).forEach(function(t){var e=i[t];"object"==typeof e&&(t=r.concat(t),this._registerDependants(e,t))},this)},cacheInputs:function(){var i={};Array.from(this.$("[data-attribute]")).forEach(function(t){var t=w(t),e=t.attr("data-attribute");i[e]=t},this),this._byPath=i,this._attributeKeysInUse=this.getAttributeKeysInUse()},updateGroupsVisibility:function(){for(var t=this.$groups,e=0,i=t.length;e<i;e++){var n=w(t[e]),r=n.attr("data-name"),r=this.options.groups[r],o=0===n.find("> .field:not(.hidden)").length,o=(n.toggleClass("empty",o),!(!r||!r.when||this.isExpressionValid(r.when)));n.toggleClass("hidden",o)}},expandAttrs:function(t){for(var e={},i=Object.keys(t),n=0;n<i.length;n++){var r=i[n],o=t[r],r=r.split("/");Ne(e,r,fi(o)?this.expandAttrs(o):o)}return e},flattenInputs:function(t){return Le(t,"/",function(t){return"string"==typeof t.type})},getModel:function(){return this.options.cell||this.options.cellView.model},onCellChange:function(t,e,i,n){if((n=n||{}).inspector!=this.cid)switch(t){case"remove":this.remove();break;case"change:position":this.updateInputPosition();break;case"change:size":this.updateInputSize();break;case"change:angle":this.updateInputAngle();break;case"change:source":case"change:target":case"change:vertices":break;default:var r="change:";t.slice(0,r.length)===r&&(r=t.slice(r.length),this._attributeKeysInUse.includes(r)&&this.render({refresh:!0}))}},render:function(t){var i,n,r=t&&t.refresh,o=(r&&this.options.storeGroupsState&&this.storeGroupsState(),this.$el.empty(),this.removeWidgets(),[]);return this.groupedFlatAttributes.forEach(function(t){var e;i!==t.group&&(e=this.options.groups[t.group],n=this.renderGroup({name:t.group,label:e&&e.label}),r||(e&&e.closed?this.closeGroup(n,{init:!0}):this.openGroup(n,{init:!0})),o.push(n)),this.renderTemplate(n,t,t.path),i=t.group},this),this.$document=w(this.el.ownerDocument),this.$groups=w(o),this.$el.append(o),r&&this.options.restoreGroupsState&&this.restoreGroupsState(),this.afterRender(),this},getAttributeKeysInUse:function(){var t=Object.keys(this._byPath).map(function(t){return t.substring(0,t.indexOf("/"))||t}),e=et(this._bound),i=Object.keys(this._when);return ci([].concat(t,e,i))},getCellAttributeValue:function(t,e){var i=this.getModel(),i=Me(i.attributes,t,"/");if(!(e=e||this.flatAttributes[t]))return i;if(void 0===i&&void 0!==e.defaultValue&&(i=e.defaultValue),e.valueRegExp){if(void 0===i)throw new Error("Inspector: defaultValue must be present when valueRegExp is used.");t=i.match(new RegExp(e.valueRegExp)),i=t&&t[2]}return i},resolvableTypes:["select","select-box","color-palette","select-button-group"],needsResolving:function(t){return!!t&&-1<this.resolvableTypes.indexOf(t.type)&&N(t.options)},resolveBindings:function(t){var e;-1<this.resolvableTypes.indexOf(t.type)&&(e=t.options||[],N(e)&&(e=Me(this.getModel().attributes,e,"/")||[]),x(e[0])||(e=et(e).map(function(t){return{value:t,content:t}})),t.items=e)},updateBindings:function(n){var t=Object.keys(this._bound).reduce(function(t,e){var i=this._bound[e];return 0===n.indexOf(i)&&t.push(e),t}.bind(this),[]);gi(t)||(t.forEach(function(t){var e=this.flatAttributes[t];e&&this.renderTemplate(null,e,t,{replace:!0})},this),this.afterPartialRender())},renderFieldContent:function(r,t,o){var e,s;if(P(this.options.renderFieldContent)&&(e=this.options.renderFieldContent(r,t,o,this)))return w(e).attr({"data-attribute":t,"data-type":r.type,"data-custom-field":!0});switch(r.type){case"select-box":var a,l=et(r.items).findIndex(function(t){var e=t.value,i=o;if(void 0===e&&t.content===i)return!0;t=r.key;return t&&(i=Me(i,t,"/"),e=Me(e,t,"/")),pi(e,i)}),i=R({theme:this.options.theme,target:this.options.container},Si(r,"type","group","index","selectBoxOptionsClass","options"),{options:r.items,selected:l,selectBoxOptionsClass:[Ie("inspector-select-box-options"),r.selectBoxOptionsClass].filter(function(t){return!!t}).join(" ")});(a=new Qs(i)).$el.attr({"data-attribute":t,"data-type":r.type,"data-overwrite":r.overwrite}),a.render(),i=this.renderOwnLabel(r,t),e=w("<div/>").append(i,a.el),r.previewMode?(s=a.selection,a.on("options:mouseout close",function(){a.selection=s,this.processInput(a.$el,{previewCancel:!0,dry:!0})},this),a.on("option:hover",function(t,e){a.selection=t,this.processInput(a.$el,{dry:!0})},this),a.on("option:select",function(t,e){var i=void 0===s?void 0:a.getSelectionValue(s),n=a.getSelectionValue(t);this.processInput(a.$el,{previewDone:!0,dry:i===n,originalValue:i}),s=t},this)):a.on("option:select",function(t,e){this.processInput(a.$el)},this),this.widgets[t]=a;break;case"color-palette":l=et(r.items).findIndex(function(t){return t.value===o||void 0===t.value&&t.content===o});var n=R({theme:this.options.theme,target:this.options.container},Si(r,"type","group","index","options"),{options:r.items,selected:l});(a=new Ks(n)).$el.attr({"data-attribute":t,"data-type":r.type}),a.render(),i=this.renderOwnLabel(r,t),e=w("<div/>").append(i,a.el),r.previewMode?(s=a.selection,a.on("options:mouseout close",function(){a.selection=s,this.processInput(a.$el,{previewCancel:!0,dry:!0})},this),a.on("option:hover",function(t,e){a.selection=t,this.processInput(a.$el,{dry:!0})},this),a.on("option:select",function(t,e){var i=void 0===s?void 0:a.getSelectionValue(s),n=a.getSelectionValue(t);this.processInput(a.$el,{previewDone:!0,dry:i===n,originalValue:i}),s=t},this)):a.on("option:select",function(t,e){this.processInput(a.$el)},this),this.widgets[t]=a;break;case"select-button-group":r.multi?(l=[],et(r.items).forEach(function(t,e){var i=void 0===t.value?t.content:t.value,n=r.key;n&&(i=Me(i,n,"/")),et(o).find(function(t){return n&&(t=Me(t,n,"/")),pi(i,t)})&&l.push(e)})):l=et(r.items).findIndex(function(t){var e=t.value,i=o;if(void 0===e&&t.content===i)return!0;t=r.key;return t&&(i=Me(i,t,"/"),e=Me(e,t,"/")),pi(e,i)});n=R({theme:this.options.theme},Si(r,"type","group","index","options"),{options:r.items,selected:l});(a=new ia(n)).$el.attr({"data-attribute":t,"data-type":r.type,"data-overwrite":r.overwrite}),a.render(),i=this.renderOwnLabel(r,t),e=w("<div/>").append(i,a.el),r.previewMode?(s=a.selection,a.on("mouseout",function(){a.selection=s,this.processInput(a.$el,{previewCancel:!0,dry:!0})},this),a.on("option:hover",function(t,e){r.multi?a.selection=ci(a.selection.concat([t])):a.selection=t,this.processInput(a.$el,{dry:!0})},this),a.on("option:select",function(t,e){var i=void 0===s?void 0:a.getSelectionValue(s),n=a.getSelectionValue(t),n=pi(i,n);this.processInput(a.$el,{previewDone:!0,dry:n,originalValue:i}),s=t},this)):a.on("option:select",function(t,e){this.processInput(a.$el)},this),this.widgets[t]=a;break;default:e=this.renderOwnFieldContent({options:r,type:r.type,overwrite:r.overwrite,label:r.label||t,attribute:t,value:o})}return e},renderGroup:function(t){t=t||{};var e=w("<div/>").addClass("group").attr("data-name",t.name),t=w("<h3/>").addClass("group-label").text(t.label||t.name);return e.append(t)},renderOwnLabel:function(t,e){var i,n=this.options.renderLabel;if(void 0!==(i="function"==typeof n?n(t,e,this):i))return w(i);switch(t.type){case"select-box":case"color-palette":case"select-button-group":return w("<label/>").html(t.label||e);default:return w("<label/>").text(t.label||e)}},renderOwnFieldContent:function(n){var t,e,i,r,o=this.renderOwnLabel(n.options,n.attribute);switch(n.type){case"number":h=w("<input/>",{type:"number",min:n.options.min,max:n.options.max,step:n.options.step}).val(n.value),t=[o,w("<div/>").addClass("input-wrapper").append(h)];break;case"range":o.addClass("with-output"),e=w("<output/>").text(n.value),s=w("<span/>").addClass("units").text(n.options.unit),(h=w("<input/>",{type:"range",name:n.type,min:n.options.min,max:n.options.max,step:n.options.step}).val(n.value)).on("change input",function(){e.text(h.val())}),t=[o,e,s,h];break;case"textarea":h=w("<textarea/>").text(n.value),t=[o,w("<div/>").addClass("input-wrapper").append(h)];break;case"content-editable":var s=n.value,a=n.options,l=(a=void 0===a?{}:a).html,a=(void 0===l&&(l=!0),a.readonly);void 0===a&&(a=!1),l=N(s)?(l?Oe(s):this.encodeHTMLEntities(s)).replace(/\n/g,"<br>"):"",h=w("<div/>").prop("contenteditable",!a).toggleClass("content-editable-readonly",Boolean(a)).css("display","inline-block").html(l).on("blur",this.onContentEditableBlur),t=[o,w("<div/>").addClass("input-wrapper").append(h)];break;case"select":var s=n.options.items,h=w("<select/>");n.options.multiple&&h.prop({size:n.options.size||s.length,multiple:!0});et(s).forEach(function(t){var e,i=w("<option/>",{value:t.value}).text(t.content);e=t.value,(n.options.multiple?et(n.value).find(function(t){return pi(e,t)}):pi(e,n.value))&&i.attr("selected","selected"),h.append(i)}),t=[o,h];break;case"toggle":i=w("<span><i/></span>"),h=w("<input/>",{type:"checkbox"}).prop("checked",!!n.value),t=[o,w("<div/>").addClass(n.type).append(h,i)];break;case"color":t=[o,h=w("<input/>",{type:"color"}).val(n.value)];break;case"text":h=w("<input/>",{type:"text"}).val(n.value),t=[o,w("<div/>").addClass("input-wrapper").append(h)];break;case"object":h=w("<div/>"),r=w("<div/>").addClass("object-properties"),t=[o,h.append(r)];break;case"list":i=w("<button/>").addClass("btn-list-add").text(n.options.addButtonLabel||"+"),r=w("<div/>").addClass("list-items"),t=[o,(h=w("<div/>")).append(i,r)]}return h&&h.addClass(n.type).attr({"data-type":n.type,"data-attribute":n.attribute,"data-overwrite":n.overwrite}),w.fn.append.apply(w("<div>"),t).children()},onContentEditableBlur:function(t){var e=w("<input/>",{disabled:!0,tabIndex:-1,style:{width:"1px",height:"1px",border:"none",margin:0,padding:0}}).appendTo(this.$el);e.focus(),e[0].setSelectionRange(0,0),e.blur().remove(),w(t.target).trigger("change")},replaceHTMLEntity:function(t,e){return this.HTMLEntities[e]||""},encodeHTMLEntities:function(t){return t.replace(/[\u00A0-\u9999<>&]/g,function(t){return"&#"+t.charCodeAt(0)+";"})},renderObjectProperty:function(t){return w("<div/>",{"data-property":(t=t||{}).property,class:"object-property"})},renderListItem:function(t){t=t||{};var e=w("<button/>").addClass("btn-list-del").text(t.options.removeButtonLabel||"-");return w("<div/>",{"data-index":t.index,class:"list-item"}).append(e)},renderFieldContainer:function(t){return w("<div/>",{"data-field":(t=t||{}).path,class:"field "+t.type+"-field"})},renderTemplate:function(t,n,r,e){t=t||this.$el,e=e||{},this.resolveBindings(n),"string"!=typeof n.type&&(n={type:"object",properties:n});var i,o,s,a=this.renderFieldContainer({path:r,type:n.type}),l=(e.hidden&&a.addClass("hidden"),this.getCellAttributeValue(r,n)),h=this.renderFieldContent(n,r,l);a.append(h),We(a,n.attrs),"list"===n.type&&n.item?(et(l).forEach(function(t,e){var i=this.renderListItem({index:e,options:n});this.renderTemplate(i,n.item,r+"/"+e),h.children(".list-items").append(i)},this),l=l&&l.length,i=n&&n.min,o=n&&n.max,this.fixListButtons(h,l,i,o)):"object"===n.type&&n.properties&&(s=this.flattenInputs(n.properties),l=Object.keys(s).map(function(t){var e=s[t];return e.path=t,e}),(l=yi(l,function(t){return t.index})).forEach(function(t){var e=this.renderObjectProperty({property:t.path});this.renderTemplate(e,t,r+"/"+t.path),h.children(".object-properties").append(e)},this)),e.replace?t.find('[data-field="'+r+'"]').replaceWith(a):t.append(a)},updateInputPosition:function(){var t=this._byPath["position/x"],e=this._byPath["position/y"],i=this.getModel().get("position");t&&t.val(i.x),e&&e.val(i.y)},updateInputSize:function(){var t=this._byPath["size/width"],e=this._byPath["size/height"],i=this.getModel().get("size");t&&t.val(i.width),e&&e.val(i.height)},updateInputAngle:function(){var t=this._byPath.angle,e=this.getModel().get("angle");t&&t.val(e)},validateInput:function(t,e,i){switch(t){case"select-box":case"color-palette":var n=this.widgets[i];return n?-1!==n.getSelectionIndex():!1;case"select-button-group":return!!this.widgets[i];default:return this.options.validateInput(e,i,t,this)}},onChangeInput:function(t){t.target===t.currentTarget&&this.processInput(w(t.target))},processInput:function(t,e){var i,n=t.attr("data-attribute"),r=t.attr("data-type");this.validateInput(r,t[0],n)&&(this.options.live&&this.updateCell(t,n,e),i=this.getFieldValue(t[0],r),r=this.parse(r,i,t[0]),this.trigger("change:"+n,r,t[0],e))},updateFieldsVisibility:function(){var e=this;this._attributeKeysInUse.forEach(function(t){e.updateBindings(t),e.updateDependants(t)})},updateDependants:function(t){var a=this,e=this._when,i=Object.keys(e),l=this._byPath,n=Object.keys(l),h=this.flatAttributes;function g(t,e){var i,n={};for(i in t){var r,o,s=t[i];if(Array.isArray(s))for(var a=i,l=s,h=(n[a]=[],l.length),c=0;c<h;c++){var u=l[c],u=g.call(this,u,e);n[a].push(u)}else this._isComposite(t)?(o=i,r=g.call(this,s,e),n[o]=r):(o=i,d.call(this,o,s,e,n))}return n;function d(t,e,i,n){for(var r in n[t]={},e){var o=e[r],r=s.call(this,r,i);n[t][r]=o}function s(t,e){for(var i=this.pathWildcard||this.DEFAULT_PATH_WILDCARD,n=[],r=0,o=t.split("/"),s=o.length,a=0;a<s;a++){var l=o[a];l===i&&(l=e[r]||i,r+=1),n.push(l)}return n.join("/")}}}function r(t,e,i){for(var n,r=i.pathWildcard,o=i.comparisonWildcard,s=[],a=e.length,l=t.length,h=0;h<l;h++){var c=t[h],u=(n=c,Array.isArray(n)?n:n.split("/")),d=u.length;if(d===a){for(var g=!0,p=[],f=[],m=0;m<d;m++){var v=u[m],y=e[m],b=v===r,w=y===o;if(v!==y&&!b&&!w){g=!1;break}b?p.push(y):w&&f.push(v)}g&&s.push({path:c,pathWildcardValues:p,comparisonWildcardValues:f})}}return s}(function(t,e){var e=e.split("/"),i=this.pathWildcard||this.DEFAULT_PATH_WILDCARD;return r(t,e,{pathWildcard:i})}).call(this,i,t).forEach(function(t){t=t.path;et(e[t]).forEach(function(t){var e=t.path,t=t.expression,o=a._getBareExpression(t),s=a._getExpressionExtras(t);(function(t,e){if(!Array.isArray(e))return[{path:e,pathWildcardValues:[],comparisonWildcardValues:[]}];return-1!==e.indexOf(null)?r(t,e,{comparisonWildcard:null}):[{path:e.join("/"),pathWildcardValues:[],comparisonWildcardValues:[]}]})(n,e).forEach(function(t){var e=t.path,t=t.comparisonWildcardValues,i=l[e],n=i.closest(".field"),r=n.hasClass("hidden"),t=g.call(a,o,t),t=a.isExpressionValid(t),n=(n.toggleClass("hidden",!t),s.otherwise);n&&n.unset&&a.options.live&&(t?r&&a.updateCell(i,e):(a.unsetProperty(e),(n=function(t,e){var i=t[e];if(null!=i)return i;for(var n=e.split("/"),r=n.length,o=n[0],s=i=t[o],a=1;a<r;a++){var l=n[a];if(void 0===i)i=(void 0===s?t:s)[o+="/"+l];else{if("object"===(s=i).type&&i.properties)i=i.properties[l];else if("list"===i.type&&i.item)i=i.item;else{if("string"==typeof i.type)break;i=i[l]}o=l}}return i}(h,e))&&a.renderTemplate(null,n,e,{replace:!0,hidden:!0}),a.afterPartialRender()))},a)},a)},this)},unsetProperty:function(t,e){var i=this.getModel(),n=t.split("/"),r=n[0],n=n.slice(1).join("/");(e=e||{}).inspector=this.cid,e["inspector_"+this.cid]=!0,"attrs"===t?i.removeAttr(n,e):t===r?i.unset(r,e):(t=void 0!==(t=i.get(r))?Te(t,n,"/"):void 0,i.set(r,t,e))},getOptions:function(t){if(0!==t.length)return t=t.attr("data-attribute"),this.getOptionsFromPath(t)},markForRemoval:function(t,e){var i=this.findParentListByPath(t);i&&(t=t.substr(i.length+1),t=parseInt(t,10),Number.isFinite(t)&&(e.remove[i]=e.remove[i]||[],e.remove[i].includes(t)||e.remove[i].push(t)))},markForUpdate:function(t,e,i,n){t=t.substr(n.length+1);e.update[n]&&Ne(e.update[n].value,t,i,"/")},updateCell:function(t,e,i){var c=this.getModel(),n={},u=(t?n[e]=w(t):n=this._byPath,this.startBatchCommand(),{}),d={update:{},remove:{}};k(n,function(t,e){if(!t.closest(".field").hasClass("hidden")){var i=t.attr("data-type"),n=t.attr("data-overwrite"),r="false"!==n&&void 0!==n,o=t.hasClass("remove");switch(i){case"list":case"object":o&&this.markForRemoval(e,d);break;default:if(!this.validateInput(i,t[0],e))return;var s,a,l=this.getFieldValue(t[0],i),l=this.parse(i,l,t[0]),h=this.getOptionsFromPath(e);h.valueRegExp&&(l=(Me(c.attributes,e,"/")||h.defaultValue).replace(new RegExp(h.valueRegExp),"$1"+l+"$3")),o?this.markForRemoval(e,d):(h=h.parent)&&"object"===h.type&&void 0!==h.overwrite&&!1!==h.overwrite?((s={})[(a=e.split("/"))[a.length-1]]=l,d.update[h.path]={value:s,overwrite:!0}):u[e]={value:l,overwrite:r}}}}.bind(this)),k(u,function(t,e){this.setProperty(e,t.value,R({overwrite:t.overwrite},i))}.bind(this)),yi(Object.keys(d.remove),function(t){return t.split("/").length}).reverse().forEach(function(t){var e=d.remove[t];this.removeProperty(t,e,R({rewrite:!0},i))}.bind(this)),k(d.update,function(t,e){this.setProperty(e,this.compactDeep(t.value),R({rewrite:!0,overwrite:t.overwrite},i))}.bind(this)),this.updateFieldsVisibility(),this.updateGroupsVisibility(),this.stopBatchCommand()},compactDeep:function(t){return Array.isArray(t)?t.reduce(function(t,e){return e&&t.push(this.compactDeep(e)),t}.bind(this),[]):t},findParentListByPath:function(t){for(var e=t.split("/"),i=(e.pop(),e);i.length;){var n=this.getOptionsFromPath(i.join("/"));if(n&&"list"===n.type)return e.slice(0,i.length).join("/");i.pop()}return null},getOptionsFromPath:function(t){for(var e,i=t.split("/"),n=this.expandAttributes,r=[];i.length;){var o=s;n&&"object"===n.type?s="properties":(s=i.shift(),!i.length&&"list"!==n.type||(e=n,r.push(s)));var s=!Number.isNaN(parseInt(s))&&"list"===n.type?"item":s;if(Object(n)!==n||!(s in n||n[t]))return{};n=n[s]||n[t]}return n=R({},n),(e=R({},e)).path=r.join("/"),o&&"properties"===o&&(e.type="object"),n.parent=e,n},getFieldValue:function(t,e){if(P(this.options.getFieldValue)){var i=this.options.getFieldValue(t,e,this);if(i)return i.value}var n=w(t);switch(e){case"select-box":case"color-palette":case"select-button-group":var r=n.attr("data-attribute");return this.widgets[r].getSelectionValue();case"content-editable":return n.html().replace(/((<br\s*\/*>)?<\/div>)|((( )|(<br\s*\/*>))?<\/p>)|(<br\s*\/*>)/gi,"\n").replace(/(<([^>]+)>)/gi,"").replace(/&(\w+);/gi,this.replaceHTMLEntity).replace(/\n$/,"");default:return n.val()}},removeProperty:function(t,n,e){var i,r=this.getModel(),o=rn.prototype.prop,s=o.call(r,t);s&&(s=s.reduce(function(t,e,i){return n.includes(i)||t.push(e),t},[]),i=this.flatAttributes[t],Array.isArray(s)&&0===s.length&&!i&&(s=null),o.call(r,t,s,e))},setProperty:function(t,e,i){(i=i||{}).inspector=this.cid;var n,r,o=rn.prototype.prop,s=this.getModel(),a=i.overwrite||!1;i.previewDone&&o.call(s,t,i.originalValue,{rewrite:!0,silent:!0}),void 0===e?rn.prototype.removeProp.call(s,t,i):(r=x(e)&&!a?(n=o.call(s,t),r=Array.isArray(e)?[]:{},y(r,n,e)):ui(e),a&&(i.rewrite=!0),o.call(s,t,r,i))},parse:function(t,e,i){switch(t){case"number":case"range":e=parseFloat(e);break;case"toggle":e=i.checked}return e},startBatchCommand:function(){var t;this.inBatch||(this.inBatch=!0,(t=this.getModel())instanceof rn&&t.startBatch("inspector",{cid:this.cid}))},stopBatchCommand:function(){var t;this.inBatch&&((t=this.getModel())instanceof rn&&t.stopBatch("inspector",{cid:this.cid}),this.inBatch=!1)},afterRender:function(){this.cacheInputs(),this.updateFieldsVisibility(),this.updateGroupsVisibility(),this.trigger("render")},afterPartialRender:function(){this.cacheInputs(),this.updateGroupsVisibility(),this.trigger("render")},addListItem:function(t){var t=w(t.target).parent("[data-attribute]"),e=this.getOptions(t),i=t.children(".list-items"),n=i.children(".list-item"),r=n.last(),r=(0===r.length?-1:parseInt(r.attr("data-index"),10))+1,o=this.renderListItem({index:r,options:e}),r=t.attr("data-attribute")+"/"+r;this.renderTemplate(o,e.item,r),i.append(o),o.find("input:first").focus();r=(n=i.children(".list-item")).not(".remove").length;this.fixListButtons(t,r,e.min,e.max),this.afterPartialRender(),this.options.live&&this.updateCell()},deleteListItem:function(t){var t=w(t.target),e=t.closest("[data-attribute]"),i=this.getOptions(e),t=t.closest(".list-item");t.hide(),t.addClass("remove"),t.find("[data-field]").each(function(){w(this).hide().addClass("remove")}),t.find("[data-attribute]").each(function(){w(this).hide().addClass("remove")});t=e.children(".list-items").children(".list-item").not(".remove").length;this.fixListButtons(e,t,i.min,i.max),this.afterPartialRender(),this.options.live&&this.updateCell()},fixListButtons:function(t,e,i,n){var r=t.children(".btn-list-add");o=e;"number"!=typeof(n=n)||("number"!=typeof o||o<n)?r.removeClass("hidden"):r.addClass("hidden");var o=t.children(".list-items").children(".list-item").children(".btn-list-del");n=e,"number"!=typeof(r=i)||r<=0||!("number"!=typeof n||n<=0)&&r<n?o.removeClass("hidden"):o.addClass("hidden")},bindDocumentEvents:function(){var t=this.getEventNamespace();this.$document.on("mouseup"+t+" touchend"+t,this.pointerup)},unbindDocumentEvents:function(){this.$document.off(this.getEventNamespace())},pointerdown:function(t){t.stopPropagation(),this.bindDocumentEvents(),this.startBatchCommand(),this._$activeField=w(t.currentTarget).addClass("is-in-action")},pointerup:function(){this.unbindDocumentEvents(),this.stopBatchCommand(),this._$activeField&&(this._$activeField.removeClass("is-in-action"),this._$activeField=null)},pointerfocusin:function(t){t.stopPropagation(),w(t.currentTarget).addClass("is-focused")},pointerfocusout:function(t){t.stopPropagation(),w(t.currentTarget).removeClass("is-focused")},onRemove:function(){this.unbindDocumentEvents(),this.removeWidgets(),this===this.constructor.instance&&(this.constructor.instance=null)},removeWidgets:function(){var t,e=this.widgets;for(t in e)e[t].remove();this.widgets={}},onGroupLabelClick:function(t){t.preventDefault(),this.options.multiOpenGroups||this.closeGroups();t=w(t.target).closest(".group");this.toggleGroup(t)},toggleGroup:function(t){t=N(t)?this.$('.group[data-name="'+t+'"]'):w(t);t.hasClass("closed")?this.openGroup(t):this.closeGroup(t)},closeGroup:function(t,e){e=e||{};t=N(t)?this.$('.group[data-name="'+t+'"]'):w(t);!e.init&&t.hasClass("closed")||(t.addClass("closed"),this.trigger("group:close",t.data("name"),e))},openGroup:function(t,e){e=e||{};t=N(t)?this.$('.group[data-name="'+t+'"]'):w(t);(e.init||t.hasClass("closed"))&&(t.removeClass("closed"),this.trigger("group:open",t.data("name"),e))},closeGroups:function(){for(var t=0,e=this.$groups.length;t<e;t++)this.closeGroup(this.$groups[t])},openGroups:function(){for(var t=0,e=this.$groups.length;t<e;t++)this.openGroup(this.$groups[t])},COMPOSITE_OPERATORS:["not","and","or","nor"],PRIMITIVE_OPERATORS:["eq","ne","regex","text","lt","lte","gt","gte","in","nin","equal"],_isComposite:function(t){return 0<Ci(this.COMPOSITE_OPERATORS,Object.keys(t)).length},_isPrimitive:function(t){var e=Object.keys(this.options.operators).concat(this.PRIMITIVE_OPERATORS);return 0<Ci(e,Object.keys(t)).length},_evalCustomPrimitive:function(t,e,i,n){return!!this.options.operators[t].apply(this,[this.getModel(),e].concat(i).concat([n]))},_evalPrimitive:function(e){return Object.keys(e).reduce(function(t,r){var o=e[r];return Object.keys(o).reduce(function(t,e){var i=o[e],n=this.getCellAttributeValue(e);if(P(this.options.operators[r]))return this._evalCustomPrimitive(r,n,i,e);switch(r){case"eq":return i==n;case"ne":return i!=n;case"regex":return new RegExp(i).test(n);case"text":return!i||N(n)&&-1<n.toLowerCase().indexOf(i);case"lt":return n<i;case"lte":return n<=i;case"gt":return i<n;case"gte":return i<=n;case"in":return Array.isArray(i)&&i.includes(n);case"nin":return Array.isArray(i)&&!i.includes(n);case"equal":return pi(i,n);default:return t}}.bind(this),!1)}.bind(this),!1)},_evalExpression:function(r){return this._isPrimitive(r)?this._evalPrimitive(r):Object.keys(r).reduce(function(t,e){var i=r[e];if("not"==e)return!this._evalExpression(i);var n=et(i).map(this._evalExpression,this);switch(e){case"and":return n.every(function(t){return!!t});case"or":return n.some(function(t){return!!t});case"nor":return!n.some(function(t){return!!t});default:return t}}.bind(this),!1)},_getBareExpression:function(t){return Si(t,"otherwise","dependencies")},_getExpressionExtras:function(t){return{otherwise:ui(t.otherwise),dependencies:ui(t.dependencies)}},_extractVariables:function(t){return Array.isArray(t)||this._isComposite(t)?et(t).reduce(function(t,e){return t.concat(this._extractVariables(e))}.bind(this),[]):et(t).reduce(function(t,e){return Object.keys(e)},[])},isExpressionValid:function(t){t=this._getBareExpression(t);return this._evalExpression(t)},extractExpressionPaths:function(t){var e=t&&t.dependencies||[],t=this._getBareExpression(t);return ci(this._extractVariables(t).concat(e))},getGroupsStateKey:function(){if(P(this.options.stateKey))return this.options.stateKey(this.getModel());throw new Error("Inspector: Option stateKey must be a function")},storeGroupsState:function(){var t=this.getGroupsStateKey(),e=et(this.$(".group.closed"));na.groupStates[t]=e.map(function(t){return w(t).attr("data-name")})},getGroupsState:function(){return na.groupStates[this.getGroupsStateKey()]},restoreGroupsState:function(){function t(i,t){k(t.options.groups,function(t,e){i(t,e)?this.closeGroup(e):this.openGroup(e)}.bind(t))}var i=this.getGroupsStateKey();na.groupStates[i]?t(function(t,e){return na.groupStates[i].includes(e)},this):t(function(t){return t.closed},this)}},{groupStates:{},instance:null,create:function(t,e){S(e=e||{},{updateCellOnClose:!0,restoreGroupsState:!0,storeGroupsState:!0});var i=e.cell||e.cellView.model,n=this.instance;return n&&n.getModel()===i||(n&&n.el.parentNode&&(e.storeGroupsState&&n.storeGroupsState(),e.updateCellOnClose&&n.updateCell(),n.remove()),n=new this(e).render(),this.instance=n,w(t).html(n.el),e.restoreGroupsState&&n.restoreGroupsState()),n},close:function(){var t,e=this.instance;e&&(t=document.activeElement,w.contains(e.el,t)&&t.blur(),e.remove())}}),ra=(R(ks.prototype,o.Events),ks.prototype.on=function(t,e,i){return o.Events.on.call(this,this.normalizeEvent(t),e,i),this},ks.prototype.off=function(t,e,i){t=t?this.normalizeEvent(t):null;return o.Events.off.call(this,t,e,i),this},ks.prototype.normalizeEvent=function(t){if("object"!=typeof t)return this.normalizeShortcut(t);for(var e=Object.keys(t),i={},n=0,r=e.length;n<r;n++){var o=e[n];i[this.normalizeEvent(o)]=t[o]}return i},ks.prototype.normalizeShortcut=function(t){if("all"===t.toLowerCase())return t;for(var e=this.parser.toEventObjectList(t),i=[],n=0;n<e.length;n++)i.push(this.hash(e[n]));return i.join(" ")},ks.prototype.enable=function(){window.addEventListener?(document.addEventListener("keydown",this.handleKey,!1),document.addEventListener("keypress",this.handleKey,!1),document.addEventListener("keyup",this.handleKey,!1)):window.attachEvent&&(document.attachEvent("keydown",this.handleKey,!1),document.attachEvent("keypress",this.handleKey,!1),document.attachEvent("keyup",this.handleKey,!1))},ks.prototype.disable=function(){window.removeEventListener?(document.removeEventListener("keydown",this.handleKey,!1),document.removeEventListener("keypress",this.handleKey,!1),document.removeEventListener("keyup",this.handleKey,!1)):window.detachEvent&&(document.detachEvent("keydown",this.handleKey,!1),document.detachEvent("keypress",this.handleKey,!1),document.detachEvent("keyup",this.handleKey,!1))},ks.prototype.isActive=function(t,e){return this.isModifierActive(t,e)},ks.prototype.isModifierActive=function(t,e){for(var i=this.parser.toEventObjectList(t),n=0;n<i.length;n++)if(i[n].modifiersCompare(e))return!0;return!1},ks.prototype.hash=function(t){function e(t){return t?1:0}return[t.type,":",t.which,e(t.shiftKey),e(t.ctrlKey),e(t.altKey),e(t.metaKey)].join("")},ks.prototype.handleKey=function(t){var e;this.isUnsupportedElement(t)||(e=ua.fromNative(t),o.Events.trigger.call(this,this.hash(e),t))},ks.prototype.isUnsupportedElement=function(t){var e,t=t.target||t.srcElement;return!!t&&("INPUT"===(e=t.tagName.toUpperCase())||"SELECT"===e||"TEXTAREA"===e||t.isContentEditable)},function(){}),oa=(ra.prototype={constructor:ra,parseEventString:function(t){for(var e=(t=t||"").split("+"),i=new ua(0),n=0;n<e.length;n++){var r=e[n],o=this.getModifierPropertyName(r);o&&(i[o]=!0),1!==e.length&&void 0!==o||(i.which=ra.getCode(r))}return i},toEventObjectList:function(t){return t.replace(/\s*\+\s*/gi,"+").split(" ").map(this.composeEventObject,this)},composeEventObject:function(t){var e=t.split(":"),i=ha.KEYDOWN,n=e[0];if(1<e.length&&(n=e[1],i=e[0]),-1===ca.indexOf(i))throw t+": invalid shortcut definition";e=this.parseEventString(n);return i===ha.KEYUP&&sa[e.which]&&(e[sa[e.which]]=!1),e.setType(i)},getModifierPropertyName:function(t){t=oa[t];return sa[t]}},ra.getCode=function(t){return la[t]||t.toUpperCase().charCodeAt(0)},{"\u21e7":16,shift:16,"\u2325":18,alt:18,option:18,"\u2303":17,ctrl:17,control:17,"\u2318":91,command:91,meta:91}),sa={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey"},aa={226:"\\",57392:"ctrl",63289:"num",59:";",61:"=",173:"-"},la={backspace:8,tab:9,shift:16,ctrl:17,alt:18,meta:91,clear:12,enter:13,return:13,esc:27,escape:27,capslock:20,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,home:36,end:35,insert:45,ins:45,pageup:33,pagedown:34,plus:187,minus:189,"-":189,",":188,".":190,"/":191,"`":192,"=":187,";":186,"'":222,"[":219,"]":221,"\\":220,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123},ha=(R(ks,{keyMap:la,modifierMap:sa,modifiers:oa,charCodeAlternatives:aa}),{KEYPRESS:"keypress",KEYDOWN:"keydown",KEYUP:"keyup"}),ca=[ha.KEYPRESS,ha.KEYDOWN,ha.KEYUP],ua=function(t,e,i,n,r,o){this.which=t,this.shiftKey=e||!1,this.ctrlKey=i||!1,this.altKey=n||!1,this.metaKey=r||!1,this.type=o||ha.KEYDOWN},jo=(ua.fromNative=function(t){var e=t.which,i=(t.type===ha.KEYPRESS&&(e=String.fromCharCode(t.which).toUpperCase().charCodeAt(0)),aa[e]&&(e=ra.getCode(aa[e])),new ua(e,t.shiftKey,t.ctrlKey,t.altKey,t.metaKey,t.type));return t.type===ha.KEYUP&&sa[e]&&(i[sa[e]]=!1),i},ua.prototype.modifiersCompare=function(t){return!(this.shiftKey&&this.shiftKey!==t.shiftKey||this.ctrlKey&&this.ctrlKey!==t.ctrlKey||this.altKey&&this.altKey!==t.altKey||this.metaKey&&this.metaKey!==t.metaKey)},ua.prototype.setType=function(t){return this.type=t,this},qs.extend({className:qs.prototype.className+" lightbox",options:y({},qs.prototype.options,{closeButton:!0,modal:!0,downloadable:!1,downloadAction:"download",fileName:"Image",closeAnimation:{delay:2e3,duration:200,easing:"swing",properties:{opacity:0}},top:100,windowArea:.8,openAnimation:!1}),init:function(){var t;Mi(this,"startCloseAnimation","positionAndScale"),qs.prototype.init.apply(this,arguments),this.options.image&&(this.$image=w("<img/>").on("load",this.positionAndScale),this.options.content=this.$image),this.options.downloadable&&(t={action:this.options.downloadAction,content:"Download",position:"center"},this.buttons=Array.isArray(this.buttons)?this.buttons.slice():[],this.buttons.push(t)),this.on("action:"+this.options.downloadAction,this.download),w(window).on("resize",this.positionAndScale),this.on("close:animation:complete",this.remove,this)},open:function(){return qs.prototype.open.apply(this,arguments),this.$image&&this.$image.attr("src",this.options.image),this.positionAndScale(),this.startOpenAnimation(),this},positionAndScale:function(){var t=this.$(".fg"),e=this.$(".body > img"),i=this.$(".titlebar"),n=this.$(".controls"),r=this.options.windowArea,o=window.innerWidth*r,s=(this.$el.css("margin-top",this.options.top),i.css("width",o),i.height()),a=n.height(),r=window.innerHeight*r-this.options.top-s-a,s=(t.css({width:o,height:r}),e.width()),a=e.height();t.css({width:s,height:a}),i.css("width","auto"),i.hasClass("empty")||n.css("top",i.outerHeight())},download:function(){_e(this.options.image,function(t,e){Ve(e,this.options.fileName)}.bind(this))},close:function(){return this.options.closeAnimation?this.startCloseAnimation():qs.prototype.close.apply(this,arguments),this},onRemove:function(){qs.prototype.onRemove.apply(this,arguments),w(window).off("resize",this.positionAndScale),this.$image&&this.$image.off("load",this.positionAndScale)},startCloseAnimation:function(){this.$el.animate(this.options.closeAnimation.properties,R({complete:function(){this.trigger("close:animation:complete")}.bind(this)},this.options.closeAnimation))},startOpenAnimation:function(){this.$el.animate(R({},this.options.openAnimation.properties,{height:this._foregroundHeight}),R({complete:function(){this.trigger("open:animation:complete")}.bind(this)},this.options.openAnimation))}})),e=n.extend({className:"navigator",events:{mousedown:"startAction",touchstart:"startAction","mousedown .joint-paper":"scrollTo","touchstart .joint-paper":"scrollTo"},documentEvents:{mousemove:"doAction",touchmove:"doAction",mouseup:"stopAction",touchend:"stopAction"},options:{paperConstructor:go,paperOptions:{},zoomOptions:null,zoom:{min:.5,max:2},width:300,height:200,padding:10},init:function(){this.options.zoomOptions?this.options.zoom=R({},this.options.zoom,this.options.zoomOptions):this.options.zoom&&(this.options.zoom=S({},this.options.zoom,this.constructor.prototype.options.zoom)),Mi(this,"updateCurrentView","doAction","stopAction","scrollTo"),this.updateCurrentView=mi(this.updateCurrentView,0);var t=this.options.paperScroller,t=(t.$el.on("scroll"+this.getEventNamespace(),this.updateCurrentView),this.sourcePaper=t.options.paper);this.toggleUseContentBBox(this.options.useContentBBox),this.targetPaper=new this.options.paperConstructor(y({model:t.model,interactive:!1,frozen:!0},this.options.paperOptions))},startListening:function(){var t=this,e=this.options,i=this.sourcePaper;e.useContentBBox?this.listenTo(i,"render:done",function(){return t.updatePaper()}):this.listenTo(i,"resize",function(){return t.updatePaper()})},render:function(){var t;return this.targetPaper.$el.appendTo(this.el),this.targetPaper.unfreeze(),this.$currentView=w("<div>").addClass("current-view"),this.options.zoom&&(t=w("<div>").addClass("current-view-control"),this.$currentView.append(t)),this.$el.append(this.$currentView).css({width:this.options.width,height:this.options.height,padding:this.options.padding}),this.updatePaper(),this},freeze:function(t){this.targetPaper.freeze(t)},unfreeze:function(t){this.targetPaper.unfreeze(t)},CONTENT_BBOX_CLASS_NAME:"navigator-use-content-bbox",NO_CONTENT_CLASS_NAME:"navigator-no-content",toggleUseContentBBox:function(t){var e=this.CONTENT_BBOX_CLASS_NAME,i=this.$el,n=this.targetPaper;this.options.useContentBBox=t=void 0===t?!1:t,this.stopListening(),this.startListening(),i.toggleClass(e,Boolean(t)),n&&this.updatePaper()},updatePaper:function(){var t=this.sourcePaper,e=this.targetPaper,i=this.options,n=this.$el,r=this.NO_CONTENT_CLASS_NAME,i=i.useContentBBox,i=i?t.getContentBBox(i):t.getComputedSize(),t=n.hasClass(r);0<i.width&&0<i.height?(t&&(n.removeClass(r),e.unfreeze({key:"navigator"})),this.updatePaperWithBBox(i),this.updateCurrentView()):t||(n.addClass(r),e.freeze({key:"navigator"}))},updatePaperWithBBox:function(t){var e,i,n,r,o,s,a,l,h=t.width,c=t.height,u=t.x,t=(void 0===u&&(u=0),t.y);void 0===t&&(t=0),h&&c&&(r=this.sourcePaper,e=this.targetPaper,s=this.options,i=(r=r.matrix()).a,n=r.d,l=r.e,r=r.f,a=s.padding,o=s.width-2*a,s=s.height-2*a,h/=i,c/=n,l=(l-u)*(a=this.ratio=Math.min(o/h,s/c))/i,u=(r-t)*a/n,e.setDimensions(h*=a,c*=a),e.setOrigin(l,u),e.scale(a,a))},updateCurrentView:function(){var t=this.ratio,e=this.sourcePaper.scale(),i=this.options.paperScroller,n=i.clientToLocalPoint(0,0),r=this.targetPaper.$el.position(),o=this.targetPaper.translate();o.ty=o.ty||0,this.currentViewGeometry={top:r.top+n.y*t+o.ty,left:r.left+n.x*t+o.tx,width:i.$el.innerWidth()*t/e.sx,height:i.$el.innerHeight()*t/e.sy},this.$currentView.css(this.currentViewGeometry)},startAction:function(t){var e=(t=I(t)).clientX,i=t.clientY,n=w(t.target).hasClass("current-view-control")?"zooming":"panning",r=this.options,o=this.currentViewGeometry,s=this.sourcePaper,r=r.paperScroller;switch(this.delegateDocumentEvents(null,{action:n,startClientX:e,startClientY:i,startScrollLeft:r.el.scrollLeft,startScrollTop:r.el.scrollTop,startZoom:r.zoom(),startGeometry:o,startScale:s.scale()}),n){case"panning":this.trigger("pan:start",t);break;case"zooming":this.trigger("zoom:start",t)}},doAction:function(t){var e=(t=I(t)).clientX,i=t.clientY,n=t.data,r=this.sourcePaper,t=this.options,o=this.ratio,s=n.action,a=n.startClientX,l=n.startClientY,h=n.startScrollLeft,c=n.startScrollTop,u=n.startZoom,d=n.startGeometry,g=n.startScale,p=n.frameId,f=t.paperScroller,m=t.zoom;switch(s){case"panning":var v=r.scale(),y=v.sx,v=(i-l)*v.sy;f.el.scrollLeft=h+(e-a)*y/o,f.el.scrollTop=c+v/o;break;case"zooming":var b=1+(a-e)/d.width/g.sx;qe(p),n.frameId=Ke(function(){f.zoom(b*u,S({absolute:!0},m))})}},stopAction:function(t){switch(this.undelegateDocumentEvents(),t.data.action){case"panning":this.trigger("pan:stop",t);break;case"zooming":this.trigger("zoom:stop",t)}},scrollTo:function(t){t=I(t);var e,i=this.targetPaper.translate(),t=(i.ty=i.ty||0,e=void 0===t.offsetX?(e=this.targetPaper.$el.offset(),n=t.pageX-e.left,t.pageY-e.top):(n=t.offsetX,t.offsetY),(n-i.tx)/this.ratio),n=(e-i.ty)/this.ratio;this.options.paperScroller.center(t,n)},onRemove:function(){this.targetPaper.remove(),this.options.paperScroller.$el.off(this.getEventNamespace())}}),da=(Ns.prototype.approxZero=function(t){return Math.abs(t)<.5},Ns.prototype.updateVelocity=function(){var t=this._velocityX,e=this._velocityY,i=this._isDragging,n=this.options,r=this.onInertiaMove;!i&&this.approxZero(t)&&this.approxZero(e)||(this._requestAnimationFrameId=Ke(this.updateVelocity.bind(this)),i?(this._dragLastDeltaX=this._dragDeltaX,this._dragLastDeltaY=this._dragDeltaY,this._dragDeltaX=this._dragLastX,this._dragDeltaY=this._dragLastY,this._velocityX=this._dragDeltaX-this._dragLastDeltaX,this._velocityY=this._dragDeltaY-this._dragLastDeltaY):(i=t,t=e,e=n.friction,this._velocityX*=e,this._velocityY*=e,this._dragLastX+=i,this._dragLastY+=t,"function"==typeof r&&r(i,t)))},Ns.prototype.handleDragStart=function(t){this._isDragging=!0,this._dragLastX=t.clientX,this._dragLastY=t.clientY,this._velocityX=0,this._velocityY=0,qe(this._requestAnimationFrameId),this.updateVelocity()},Ns.prototype.handleDragMove=function(t){this._dragLastX=t.clientX,this._dragLastY=t.clientY},n.extend({className:"paper-scroller",events:{scroll:"onScroll"},options:{paper:void 0,padding:function(){var t=this.getClientSize(),e=Math.max(this.options.minVisiblePaperSize,1)||1,i={};return i.left=i.right=Math.max(t.width-e,0),i.top=i.bottom=Math.max(t.height-e,0),i},scrollWhileDragging:!(Ns.prototype.handleDragEnd=function(t){this._isDragging=!1}),minVisiblePaperSize:50,autoResizePaper:!1,baseWidth:void 0,baseHeight:void 0,contentOptions:void 0,cursor:"default",inertia:!1,borderless:!1},_padding:{left:0,top:0},init:function(){var t=this,e=(Mi(this,"startPanning","stopPanning","pan","onBackgroundEvent"),this.options),i=this.el,n=e.paper,r=e.autoResizePaper,o=e.scrollWhileDragging,s=e.cursor,a=e.inertia,l=n.scale();this._sx=l.sx,this._sy=l.sy,void 0===e.baseWidth&&(e.baseWidth=n.options.width),void 0===e.baseHeight&&(e.baseHeight=n.options.height),this.$background=w("<div/>").addClass("paper-scroller-background").css({width:n.options.width,height:n.options.height}).append(n.el).appendTo(i),this.listenTo(n,"scale",this.onScale).listenTo(n,"resize",this.onResize).listenTo(n,"beforeprint beforeexport",this.storeScrollPosition).listenTo(n,"afterprint afterexport",this.restoreScrollPosition),r&&this.listenTo(n,"render:done",this.onPaperRenderDone),o&&(this.listenTo(n,"cell:pointermove",this.onCellPointermove),this.listenTo(n,"cell:pointerup",this.onCellPointerup)),this.debouncedStoreCenter=mi(function(){return t.storeCenter()}),this.storeCenter(n.options.width/2,n.options.height/2),this.delegateBackgroundEvents(),this.setCursor(s),a&&(this.inertia=new Ns(function(t,e){var i=this.el;i.scrollTop-=e,i.scrollLeft-=t}.bind(this),a))},onCellPointermove:function(t,e,i,n){var r=this.options.scrollWhileDragging;r&&this.scrollWhileDragging(e,i,n,r)},onCellPointerup:function(t,e){this.stopScrollWhileDragging(e)},scrollWhileDragging:function(t,e,i,n){var r=this.el,o=(n=void 0===n?{}:n).interval,s=(void 0===o&&(o=25),n.padding),n=(void 0===s&&(s=-20),n.scrollingFunction);void 0===n&&(n=function(t){return t<20?5:20});var a=this.eventData(t).scrollId,l=new z(e,i),s=ei(s),h=s.top,c=s.left,u=s.right,s=s.bottom,c=this.getVisibleArea().moveAndExpand({x:-h,y:-c,width:c+u,height:h+s});if(c.containsPoint(l))return clearInterval(a),void this.eventData(t,{scrollId:null});u=c.pointNearestToPoint(l).distance(l),h=n.call(this,u,t),s=c.x,l=c.y,n=c.width,u=c.height;this.eventData(t,{scrollX:e<s?-1:s+n<e?1:0,scrollY:i<l?-1:l+u<i?1:0,scrollPerTick:h,container:r}),a||(c=this.eventData(t),a=setInterval(function(t){var e=t.scrollPerTick,i=t.scrollX,n=t.scrollY,t=t.container;t.scrollLeft+=e*i,t.scrollTop+=e*n},o,c),c.scrollId=a)},stopScrollWhileDragging:function(t){t=this.eventData(t).scrollId;t&&clearInterval(t)},onPaperRenderDone:function(t){t.priority<2&&this.adjustPaper()},lock:function(){return this.$el.css("overflow","hidden"),this},unlock:function(){return this.$el.css("overflow","scroll"),this},setCursor:function(t){return"grab"===t?this.$el.css("cursor",""):this.$el.css("cursor",t),this.$el.attr("data-cursor",t),this.options.cursor=t,this},delegateBackgroundEvents:function(n){n=n||M(this.options.paper,"events");var t=this.paperEvents=Object.keys(n||{}).reduce(function(t,e){var i=n[e];-1===e.indexOf(" ")&&(t[e]=P(i)?i:this.options.paper[i]);return t}.bind(this),{});return Object.keys(t).forEach(function(t){this.delegate(t,{guarded:!1},this.onBackgroundEvent)},this),this},onBackgroundEvent:function(t){this.$background.is(t.target)&&(t=this.paperEvents[t.type],P(t)&&t.apply(this.options.paper,arguments))},onScroll:function(t){this.trigger("scroll",t),this.debouncedStoreCenter()},onResize:function(){this.restoreCenter()},onScale:function(t,e,i,n){this.adjustScale(t,e),this._sx=t,this._sy=e,(i||n)&&this.center(i,n);t=this.options,e=t.contentOptions,i=t.borderless;"function"!=typeof e&&!i||this.adjustPaper()},storeScrollPosition:function(){this._scrollLeftBeforePrint=this.el.scrollLeft,this._scrollTopBeforePrint=this.el.scrollTop},restoreScrollPosition:function(){this.el.scrollLeft=this._scrollLeftBeforePrint,this.el.scrollTop=this._scrollTopBeforePrint,this._scrollLeftBeforePrint=null,this._scrollTopBeforePrint=null},beforePaperManipulation:function(){(In.test("msie")||In.test("msedge"))&&this.$el.css("visibility","hidden")},afterPaperManipulation:function(){(In.test("msie")||In.test("msedge"))&&this.$el.css("visibility","visible")},clientToLocalPoint:function(t,e){var i=this.options.paper.matrix();return t=(t+=this.el.scrollLeft-this._padding.left-i.e)/i.a,e=(e+=this.el.scrollTop-this._padding.top-i.f)/i.d,new z(t,e)},localToBackgroundPoint:function(t,e){var t=new z(t,e),e=this.options.paper.matrix(),i=this._padding;return B.transformPoint(t,e).offset(i.left,i.top)},getPadding:function(){var t=this.options.padding;return P(t)&&(t=t.call(this,this)),ei(t)},computeRequiredPadding:function(t){var e=this.options.paper.scale(),i=e.sx,e=e.sy,n=this.getCenter(),r=n.x,n=n.y,i=(r*=i,n*=e,t.x),e=t.y,o=i+t.width,t=e+t.height,s=this.getClientSize(),a=s.width/2,s=s.height/2,l=this.getPadding(),h=l.left,c=l.right,u=l.top,l=l.bottom;return{left:Math.max(a-h-r+i,0)+h,right:Math.max(a-c+r-o,0)+c,top:Math.max(s-u-n+e,0)+u,bottom:Math.max(s-l+n-t,0)+l}},addPadding:function(){var t,e,i,n,r=this.options,o=r.borderless,r=r.paper,s=(o?t=e=i=n=0:(s=(o=r.scale()).sx,o=o.sy,a=r.getArea(),a=this.computeRequiredPadding(a.scale(s,o,{x:0,y:0})),t=Math.round(a.left),e=Math.round(a.right),i=Math.round(a.top),n=Math.round(a.bottom)),this._padding={left:t,top:i,bottom:n,right:e},r.getComputedSize()),o=s.width,a=s.height;return this.$background.css({width:t+o+e,height:i+a+n}),r.$el.css({left:t,top:i}),this},storeCenter:function(t,e){t=G(t)?new z(t,e):this.computeCenter();this._center=t},restoreCenter:function(){var t=this._center;t&&this.center(t.x,t.y)},getCenter:function(){return this._center||(this._center=this.options.paper.getArea().center()),this._center},computeCenter:function(){var t=this.getClientSize(),e=t.width,t=t.height;return this.clientToLocalPoint(e/2,t/2)},adjustPaper:function(){var t,e,i,n,r=this.options,o=r.paper,s=r.borderless,r=r.contentOptions,r=("function"==typeof r&&(r=r.call(this,this)),R({gridWidth:this.options.baseWidth,gridHeight:this.options.baseHeight,allowNewOrigin:"negative"},r));return s?(s=o.getFitToContentArea(this.transformContentOptions(r)),n=(t=o.scale()).sx,t=t.sy,s.x*=n,s.y*=t,s.width*=n,s.height*=t,t=(n=this.computeRequiredPadding(s)).left,e=n.right,i=n.top,n=n.bottom,s.moveAndExpand({x:-t,y:-i,width:t+e,height:i+n}),o.setOrigin(-s.x,-s.y),o.setDimensions(s.width,s.height)):o.fitToContent(this.transformContentOptions(r)),this},adjustScale:function(t,e){var i=this.options.paper,n=i.options,t=t/this._sx,e=e/this._sy;i.setOrigin(n.origin.x*t,n.origin.y*e),i.setDimensions(n.width*t,n.height*e)},transformContentOptions:function(t){var e=this._sx,i=this._sy;return t.gridWidth&&(t.gridWidth*=e),t.gridHeight&&(t.gridHeight*=i),t.minWidth&&(t.minWidth*=e),t.minHeight&&(t.minHeight*=i),x(t.padding)?t.padding={left:(t.padding.left||0)*e,right:(t.padding.right||0)*e,top:(t.padding.top||0)*i,bottom:(t.padding.bottom||0)*i}:G(t.padding)&&(t.padding=t.padding*e),t},center:function(t,e,i){var n,r=this.options.paper,o=r.matrix(),s=o.a,a=o.d,l=o.e,o=o.f,h=G(t),c=G(e);return h||c?(n=i,h||(t=this.getVisibleArea().center().x),c||(e=this.getVisibleArea().center().y),t*=s,e*=a):(n=t,t=(-l+(i=r.getComputedSize()).width)/2,e=(-o+i.height)/2),this.storeCenter(t/s,e/a),this.addPadding(),this.scroll(t,e,n),this},centerContent:function(t){return this.positionContent("center",t)},centerElement:function(t,e){return this.checkElement(t,"centerElement"),this.positionElement(t,"center",e)},positionContent:function(t,e){var i=this.options.paper.getContentArea(e);return this.positionRect(i,t,e)},positionElement:function(t,e,i){this.checkElement(t,"positionElement");t=t.getBBox();return this.positionRect(t,e,i)},positionRect:function(t,e,i){var n;switch(e){case"center":return n=t.center(),this.positionPoint(n,"50%","50%",i);case"top":return n=t.topMiddle(),this.positionPoint(n,"50%",0,i);case"top-right":return n=t.topRight(),this.positionPoint(n,"100%",0,i);case"right":return n=t.rightMiddle(),this.positionPoint(n,"100%","50%",i);case"bottom-right":return n=t.bottomRight(),this.positionPoint(n,"100%","100%",i);case"bottom":return n=t.bottomMiddle(),this.positionPoint(n,"50%","100%",i);case"bottom-left":return n=t.bottomLeft(),this.positionPoint(n,0,"100%",i);case"left":return n=t.leftMiddle(),this.positionPoint(n,0,"50%",i);case"top-left":return n=t.topLeft(),this.positionPoint(n,0,0,i);default:throw new Error("Provided positionName ('"+e+"') was not recognized.")}},positionPoint:function(t,e,i,n){var r=ei((n=n||{}).padding),o=new tt(this.getClientSize()),r=o.clone().moveAndExpand({x:r.left,y:r.top,width:-r.right-r.left,height:-r.top-r.bottom}),s=ti(e),s=(e=parseFloat(e),(e=s?e/100*Math.max(0,r.width):e)<0&&(e=r.width+e),ti(i)),s=(i=parseFloat(i),(i=s?i/100*Math.max(0,r.height):i)<0&&(i=r.height+i),r.origin().offset(e,i)),r=o.center().difference(s),e=this.zoom(),i=r.scale(1/e,1/e),o=t.clone().offset(i);return this.center(o.x,o.y,n)},scroll:function(t,e,i){var n,r=this.options.paper.matrix(),o=this.getClientSize(),s={};G(t)&&(n=o.width/2,s.scrollLeft=t-n+r.e+(this._padding.left||0)),G(e)&&(t=o.height/2,s.scrollTop=e-t+r.f+(this._padding.top||0)),i&&i.animation?this.$el.animate(s,i.animation):this.$el.prop(s)},scrollToContent:function(t){var e=this.options.paper.getContentArea(t).center(),i=this._sx,n=this._sy;return e.x*=i,e.y*=n,this.scroll(e.x,e.y,t)},scrollToElement:function(t,e){this.checkElement(t,"scrollToElement");var t=t.getBBox().center(),i=this._sx,n=this._sy;return t.x*=i,t.y*=n,this.scroll(t.x,t.y,e)},zoom:function(t,e){if(void 0===e&&(e={}),void 0===t)return this._sx;var i,n,r,o=this.computeCenter(),s=t;return e.absolute||(s+=this._sx,t+=this._sy),e.grid&&(s=Math.round(s/e.grid)*e.grid,t=Math.round(t/e.grid)*e.grid),e.max&&(s=Math.min(e.max,s),t=Math.min(e.max,t)),e.min&&(s=Math.max(e.min,s),t=Math.max(e.min,t)),r=void 0===e.ox||void 0===e.oy?(n=o.x,o.y):(r=s/this._sx,i=t/this._sy,n=e.ox-(e.ox-o.x)/r,e.oy-(e.oy-o.y)/i),this.beforePaperManipulation(),this.options.paper.scale(s,t),this.center(n,r),this.afterPaperManipulation(),this},zoomToRect:function(t,e){void 0===e&&(e={}),t=new tt(t);var i=this.options.paper,n=R({},i.options.origin),n=(e.fittingBBox=e.fittingBBox||R({},new z(n),{width:this.$el.width(),height:this.$el.height()}),e.contentArea=t,this.beforePaperManipulation(),i.scaleContentToFit(e),t.center());return this.adjustPaper(),this.center(n.x,n.y),this.afterPaperManipulation(),this},zoomToFit:function(t){var e=this.options.paper.getContentArea(t=void 0===t?{}:t);return this.zoomToRect(e,t),this},transitionClassName:"transition-in-progress",transitionEventName:"transitionend.paper-scroller-transition",transitionToPoint:function(t,e,i){x(t)&&(i=e,e=t.y,t=t.x),i=i||{};var n,r,o=this._sx,s=Math.max(i.scale||o,1e-6),a=new z(t,e),l=this.computeCenter();return o===s?n="translate("+(n=l.difference(a).scale(o,o).round()).x+"px,"+n.y+"px)":(r=s/(o-s)*a.distance(l),l=l.clone().move(a,r),n="scale("+s/o+")",r=(a=this.localToBackgroundPoint(l).round()).x+"px "+a.y+"px"),this.$el.addClass(this.transitionClassName),this.$background.off(this.transitionEventName).on(this.transitionEventName,function(t){var e=this.paperScroller,i=(e.syncTransition(this.scale,{x:this.x,y:this.y}),this.onTransitionEnd);P(i)&&i.call(e,t)}.bind({paperScroller:this,scale:s,x:t,y:e,onTransitionEnd:i.onTransitionEnd})).css({transition:"transform",transitionDuration:i.duration||"1s",transitionDelay:i.delay,transitionTimingFunction:i.timingFunction,transformOrigin:r,transform:n}),this},syncTransition:function(t,e){return this.beforePaperManipulation(),this.options.paper.scale(t),this.removeTransition().center(e.x,e.y),this.afterPaperManipulation(),this},removeTransition:function(){return this.$el.removeClass(this.transitionClassName),this.$background.off(this.transitionEventName).css({transition:"",transitionDuration:"",transitionDelay:"",transitionTimingFunction:"",transform:"",transformOrigin:""}),this},transitionToRect:function(t,e){void 0===e&&(e={}),t=new tt(t);var i=e.maxScale||1/0,n=e.minScale||Number.MIN_VALUE,r=e.scaleGrid||null,o=e.visibility||1,s=e.center?new z(e.center):t.center(),a=this.getClientSize(),l=a.width*o,a=a.height*o,o=new tt({x:s.x-l/2,y:s.y-a/2,width:l,height:a}).maxRectUniformScaleToFit(t,s),o=Math.min(o,i);return r&&(o=Math.floor(o/r)*r),o=Math.max(n,o),this.transitionToPoint(s,S({scale:o},e)),this},startPanning:function(t){t=I(t),this._clientX=t.clientX,this._clientY=t.clientY,this.trigger("pan:start",t),this.delegatePanning(),this.options.inertia&&this.inertia.handleDragStart(t)},pan:function(t){var e=(t=I(t)).clientX-this._clientX,i=t.clientY-this._clientY;this.el.scrollTop-=i,this.el.scrollLeft-=e,this._clientX=t.clientX,this._clientY=t.clientY,this.options.inertia&&this.inertia.handleDragMove(t)},stopPanning:function(t){this.undelegatePanning(),t=t&&I(t),this.trigger("pan:stop",t),this.options.inertia&&this.inertia.handleDragEnd(t)},delegatePanning:function(){this.$el.addClass("is-panning"),w(document.body).on({"mousemove.panning touchmove.panning":this.pan,"mouseup.panning touchend.panning":this.stopPanning}),w(window).on("mouseup.panning",this.stopPanning)},undelegatePanning:function(){this.$el.removeClass("is-panning"),w(document.body).off(".panning"),w(window).off(".panning")},getClientSize:function(){var t=this.el;return{width:t.clientWidth,height:t.clientHeight}},getVisibleArea:function(){var t=this.options.paper.matrix(),e=this.getClientSize(),e={x:this.el.scrollLeft||0,y:this.el.scrollTop||0,width:e.width,height:e.height},e=B.transformRect(e,t.inverse());return e.x-=(this._padding.left||0)/this._sx,e.y-=(this._padding.top||0)/this._sy,new tt(e)},isElementVisible:function(t,e){this.checkElement(t,"isElementVisible");e=(e=e||{}).strict?"containsRect":"intersect";return!!this.getVisibleArea()[e](t.getBBox())},isPointVisible:function(t){return this.getVisibleArea().containsPoint(t)},checkElement:function(t,e){if(!(t&&t instanceof r))throw new TypeError("ui.PaperScroller."+e+"() accepts instance of dia.Element only")},onRemove:function(){this.undelegatePanning()}})),Zo=(In.addTest("msie",function(){var t=window.navigator.userAgent;return-1!==t.indexOf("MSIE")||-1!==t.indexOf("Trident")}),In.addTest("msedge",function(){return/Edge\/\d+/.test(window.navigator.userAgent)}),n.extend({tagName:"g",svgElement:!0,className:"path-drawer",events:{"mousedown .start-point":"onStartPointPointerDown",mousedown:"onPointerDown","touchstart .start-point":"onStartPointPointerDown",touchstart:"onPointerDown",dblclick:"onDoubleClick",contextmenu:"onContextMenu"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},options:{pathAttributes:{class:null,fill:"#ffffff",stroke:"#000000","stroke-width":1,"pointer-events":"none"},startPointMarkup:'<circle r="5"/>',snapRadius:0},init:function(){var t=this.svgTarget=B(this.options.target);this.$document=w(t.node.ownerDocument),this.action="awaiting-input",this.render()},onRemove:function(){var t=this.pathNode;t&&B(t).remove(),this.clear()},clear:function(){var t=this.pathNode;t&&t.pathSegList.numberOfItems<=1&&B(t).remove(),this.svgStart.remove(),this.svgControl.remove(),this.pathNode=null,this.undelegateDocumentEvents(),this.action="awaiting-input",this.trigger("clear")},render:function(){var t=this.options;return this.svgPathTemplate=B("path").attr(t.pathAttributes),this.svgStart=B(t.startPointMarkup).addClass("start-point"),this.svgControl=B("path").addClass("control-path"),this.vel.append(B("rect",{x:0,y:0,width:"100%",height:"100%",fill:"transparent",stroke:"none"})),this.svgTarget.append(this.el),this},createPath:function(t,e){var i=this.svgPathTemplate.clone(),n=this.pathNode=i.node,r=this.svgStart.translate(t,e,{absolute:!0});this.trigger("path:create",n),this.addMoveSegment(t,e),this.vel.before(i),this.vel.append(r)},closePath:function(){var t=this.pathNode,e=t.pathSegList.getItem(0),i=t.pathSegList.getItem(t.pathSegList.numberOfItems-1);i.pathSegType==SVGPathSeg.PATHSEG_LINETO_ABS?t.pathSegList.replaceItem(t.createSVGPathSegClosePath(),t.pathSegList.numberOfItems-1):(i.x=e.x,i.y=e.y,t.pathSegList.appendItem(t.createSVGPathSegClosePath())),this.finishPath("path:close")},finishPath:function(t){var e=this.pathNode;e&&0<this.numberOfVisibleSegments()?(this.trigger("path:finish",e),this.trigger(t,e)):this.trigger("path:abort",e),this.clear()},numberOfVisibleSegments:function(){var t=this.pathNode,e=t.pathSegList.numberOfItems;return--e,t.pathSegList.getItem(t.pathSegList.numberOfItems-1).pathSegType==SVGPathSeg.PATHSEG_CLOSEPATH&&--e,e},addMoveSegment:function(t,e){var i=this.pathNode,t=i.createSVGPathSegMovetoAbs(t,e);i.pathSegList.appendItem(t),this.trigger("path:segment:add",i),this.trigger("path:move-segment:add",i)},addLineSegment:function(t,e){var i=this.pathNode,t=i.createSVGPathSegLinetoAbs(t,e);i.pathSegList.appendItem(t),this.trigger("path:segment:add",i),this.trigger("path:line-segment:add",i)},addCurveSegment:function(t,e,i,n,r,o){var s=this.pathNode,i=s.createSVGPathSegCurvetoCubicAbs(t,e,i,n,r||t,o||e);s.pathSegList.appendItem(i),this.trigger("path:segment:add",s),this.trigger("path:curve-segment:add",s)},adjustLastSegment:function(t,e,i,n,r,o){var s=this.pathNode,a=this.options.snapRadius,a=(a&&(t=(a=this.snapLastSegmentCoordinates(t,e,a)).x,e=a.y),s.pathSegList.getItem(s.pathSegList.numberOfItems-1));null!==t&&(a.x=t),null!==e&&(a.y=e),null!==i&&(a.x1=i),null!==n&&(a.y1=n),null!==r&&(a.x2=r),null!==o&&(a.y2=o),this.trigger("path:edit",s),this.trigger("path:last-segment:adjust",s)},snapLastSegmentCoordinates:function(t,e,i){for(var n=this.pathNode,r=!1,o=!1,s=t,a=e,l=n.pathSegList.numberOfItems-2;0<=l&&(!r||!o);l--){var h=n.pathSegList.getItem(l),c=h.x,h=h.y;!r&&Math.abs(c-t)<i&&(s=c,r=!0),!o&&Math.abs(h-e)<i&&(a=h,o=!0)}return new z(s,a)},removeLastSegment:function(){var t=this.pathNode;t.pathSegList.removeItem(t.pathSegList.numberOfItems-1),this.trigger("path:edit",t),this.trigger("path:last-segment:remove",t)},findControlPoint:function(t,e){var i=this.pathNode,i=i.pathSegList.getItem(i.pathSegList.numberOfItems-1);return A(t,e).reflection(i)},replaceLastSegmentWithCurve:function(){var t=this.pathNode,e=t.pathSegList.getItem(t.pathSegList.numberOfItems-1),i=t.pathSegList.getItem(t.pathSegList.numberOfItems-2),i=t.createSVGPathSegCurvetoCubicAbs(e.x,e.y,i.x,i.y,e.x,e.y);t.pathSegList.replaceItem(i,t.pathSegList.numberOfItems-1),this.trigger("path:edit",t),this.trigger("path:last-segment:replace-with-curve",t)},adjustControlPath:function(t,e,i,n){var r=this.pathNode,o=this.svgControl.node;o.pathSegList.initialize(o.createSVGPathSegMovetoAbs(t,e)),o.pathSegList.appendItem(o.createSVGPathSegLinetoAbs(i,n)),this.vel.append(o),this.trigger("path:interact",r),this.trigger("path:control:adjust",r)},removeControlPath:function(){var t=this.pathNode,e=this.svgControl.node;e.pathSegList.clear(),this.vel.append(e),this.trigger("path:interact",t),this.trigger("path:control:remove",t)},onPointerDown:function(t){t=I(t);if(t.stopPropagation(),!(1<t.which)&&!(1<t.originalEvent.detail)&&this.el.parentNode){var e=this.vel.toLocalPoint(t.clientX,t.clientY);switch(this.action){case"awaiting-input":this.createPath(e.x,e.y),this.action="path-created",this.delegateDocumentEvents();break;case"adjusting-line-end":this.action="awaiting-line-end";break;case"adjusting-curve-end":this.action="awaiting-curve-control-2"}this._timeStamp=t.timeStamp}},MOVEMENT_DETECTION_THRESHOLD:150,onPointerMove:function(t){t=I(t);if(t.stopPropagation(),"awaiting-input"!=this.action){var e,i,n=this.vel.toLocalPoint(t.clientX,t.clientY),r=this._timeStamp;if(r)if(t.timeStamp-r<this.MOVEMENT_DETECTION_THRESHOLD)switch(this.action){case"path-created":e=this.svgStart.translate(),this.adjustControlPath(e.tx,e.ty,n.x,n.y);break;case"awaiting-line-end":case"adjusting-curve-control-1":this.adjustLastSegment(n.x,n.y);break;case"awaiting-curve-control-2":this.adjustLastSegment(n.x,n.y,null,null,n.x,n.y)}else switch(this.action){case"path-created":this.action="adjusting-curve-control-1";break;case"awaiting-line-end":this.replaceLastSegmentWithCurve(),this.action="adjusting-curve-control-2";break;case"awaiting-curve-control-2":this.action="adjusting-curve-control-2";break;case"adjusting-curve-control-1":e=this.svgStart.translate(),this.adjustControlPath(e.tx,e.ty,n.x,n.y);break;case"adjusting-curve-control-2":i=this.findControlPoint(n.x,n.y),this.adjustLastSegment(null,null,null,null,i.x,i.y),this.adjustControlPath(i.x,i.y,n.x,n.y)}else switch(this.action){case"adjusting-line-end":this.adjustLastSegment(n.x,n.y);break;case"adjusting-curve-end":this.adjustLastSegment(n.x,n.y,null,null,n.x,n.y)}}},onPointerUp:function(t){this._timeStamp=null;t=I(t);if(t.stopPropagation(),!(1<t.which||1<t.originalEvent.detail)){var e=this.vel.toLocalPoint(t.clientX,t.clientY);switch(this.action){case"path-created":case"awaiting-line-end":this.addLineSegment(e.x,e.y),this.action="adjusting-line-end";break;case"awaiting-curve-control-2":this.removeControlPath(),this.addLineSegment(e.x,e.y),this.action="adjusting-line-end";break;case"adjusting-curve-control-1":case"adjusting-curve-control-2":this.addCurveSegment(e.x,e.y,e.x,e.y),this.action="adjusting-curve-end"}}},onStartPointPointerDown:function(t){t=I(t);t.stopPropagation(),1<t.which||1<t.originalEvent.detail||this.closePath()},onDoubleClick:function(t){t=I(t);t.preventDefault(),t.stopPropagation(),1<t.which||this.pathNode&&0<this.numberOfVisibleSegments()&&(this.removeLastSegment(),this.finishPath("path:stop"))},onContextMenu:function(t){t=I(t);t.preventDefault(),t.stopPropagation(),1<t.originalEvent.detail||this.pathNode&&0<this.numberOfVisibleSegments()&&(this.removeLastSegment(),this.finishPath("path:stop"))}})),ko=n.extend({tagName:"g",svgElement:!0,className:"path-editor",events:{"mousedown .anchor-point":"onAnchorPointPointerDown","mousedown .control-point":"onControlPointPointerDown","mousedown .segment-path":"onSegmentPathPointerDown","touchstart .anchor-point":"onAnchorPointPointerDown","touchstart .control-point":"onControlPointPointerDown","touchstart .segment-path":"onSegmentPathPointerDown","dblclick .anchor-point":"onAnchorPointDoubleClick","dblclick .control-point":"onControlPointDoubleClick","dblclick .segment-path":"onSegmentPathDoubleClick"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},options:{anchorPointMarkup:'<circle r="2.5"/>',controlPointMarkup:'<circle r="2.5"/>'},init:function(){var t=this.pathNode=B(this.options.pathElement).normalizePath().node;this.segList=t.pathSegList,this.svgRoot=B(t.ownerSVGElement),this.$document=w(t.ownerDocument),this.render()},onRemove:function(){this.undelegateDocumentEvents(),this.clear()},clear:function(){this.vel.empty(),this.directionPaths=[],this.segmentPaths=[],this.controlPoints=[],this.anchorPoints=[],this._subPathIndices=[0],this.trigger("clear",this.pathNode)},_transformPoint:function(t,e,i){return B.transformPoint(new z(t,e),i)},_getPathCTM:function(){return this.pathNode.getCTM()},render:function(){this.clear();for(var t=this.vel,e=this._getPathCTM(),i=B(this.options.anchorPointMarkup).addClass("anchor-point"),n=B(this.options.controlPointMarkup).addClass("control-point"),r=B('<path class="direction-path"/>'),o=B('<path class="segment-path"/>'),s=this.segList,a=this.anchorPoints,l=this.controlPoints,h=this.directionPaths,c=this.segmentPaths,u=this._subPathIndices,d=0,g=0,p=0;d<s.numberOfItems;d++){var f=s.getItem(d),m=this._transformPoint(f.x,f.y,e),v=m.x,y=m.y;if(f.pathSegType!=SVGPathSeg.PATHSEG_CLOSEPATH&&(a[d]=i.clone().attr({index:d,cx:v,cy:y})),f.pathSegType!=SVGPathSeg.PATHSEG_MOVETO_ABS){var b=o.clone().attr("index",d).node;switch(b.pathSegList.initialize(b.createSVGPathSegMovetoAbs(g,p)),f.pathSegType){case SVGPathSeg.PATHSEG_CLOSEPATH:var w=s.getItem(u[0]),w=this._transformPoint(w.x,w.y,e),v=w.x,y=w.y;b.pathSegList.appendItem(b.createSVGPathSegLinetoAbs(v,y)),u.unshift(d+1);break;case SVGPathSeg.PATHSEG_LINETO_ABS:b.pathSegList.appendItem(b.createSVGPathSegLinetoAbs(v,y));break;case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:var w=this._transformPoint(f.x1,f.y1,e),A=n.clone().attr({index:d,"attribute-index":1,cx:w.x,cy:w.y}),C=this._transformPoint(f.x2,f.y2,e),I=n.clone().attr({index:d,"attribute-index":2,cx:C.x,cy:C.y});l[d]=[A,I],b.pathSegList.appendItem(b.createSVGPathSegCurvetoCubicAbs(v,y,w.x,w.y,C.x,C.y)),h[d]=[r.clone().attr("d",["M",g,p,"L",w.x,w.y].join(" ")),r.clone().attr("d",["M",v,y,"L",C.x,C.y].join(" "))]}c[d]=b}g=v,p=y}var x=[];c.forEach(function(t){t&&x.push(t)}),h.forEach(function(t){t&&Array.prototype.push.apply(x,t)}),a.forEach(function(t){t&&x.push(t)}),l.forEach(function(t){t&&Array.prototype.push.apply(x,t)}),t.append(x),this.svgRoot.append(t)},startMoving:function(t){var t=I(t),e=this.$point=w(t.target),i=(this.prevClientX=t.clientX,this.prevClientY=t.clientY,parseInt(this.$point.attr("index"),10));this.trigger("path:interact"),e.hasClass("anchor-point")?this.trigger("path:anchor-point:select",i):e.hasClass("control-point")?(e=parseInt(this.$point.attr("attribute-index"),10),this.trigger("path:control-point:select",i,e)):this.trigger("path:segment:select",i),t.stopPropagation(),t.preventDefault(),this.index=void 0,this.controlPointIndex=void 0,this.segPoint=void 0,this.pathEditedEventType=void 0},move:function(t){var e,i,n,r=this.$point;r&&(e=(t=I(t)).clientX-this.prevClientX,i=t.clientY-this.prevClientY,n=parseInt(r.attr("index"),10),r.hasClass("anchor-point")?this.adjustAnchorPoint(n,e,i,t):r.hasClass("control-point")?(r=parseInt(r.attr("attribute-index"),10),this.adjustControlPoint(n,r,e,i,t)):this.adjustSegment(n,e,i,t),this.prevClientX=t.clientX,this.prevClientY=t.clientY)},adjustSegment:function(t,e,i,n,r){r=(r=void 0===r?{}:r).dry;void 0===r&&(r=void 0),this.adjustAnchorPoint(t-1,e,i,{dry:!0}),this.adjustAnchorPoint(t,e,i,{dry:!0}),r||(this.pathEditedEventType="path:segment:adjust",this.index=t,this.trigger("path:editing",this.pathNode,n),this.trigger("path:segment:adjusting",this.pathNode,n,{index:t}))},adjustControlPoint:function(t,e,i,n,r,o){var s,a,l,h,o=(o=void 0===o?{}:o).dry,c=(void 0===o&&(o=void 0),this._getPathCTM()),u=this.segList,d=u.getItem(t),g=this.controlPoints,p=c.inverse(),i=(p.e=0,p.f=0,this._transformPoint(i,n,p)),n="x"+e,p="y"+e,i=(d[n]+=i.x,d[p]+=i.y,this._transformPoint(d[n],d[p],c)),f=new z(i);g[t][e-1].attr({cx:i.x,cy:i.y}).hasClass("locked")&&(i=this.getBoundIndex(t,e),s=1===e?2:1,u=u.getItem(i),a="x"+s,l="y"+s,h=new z((1===e?u:d).x,(1===e?u:d).y),n=new z(d[n],d[p]),d=h.distance(new z(u[a],u[l])),p=h.move(n,d),u[a]=p.x,u[l]=p.y,h=this._transformPoint(u[a],u[l],c),g[i][s-1].attr({cx:h.x,cy:h.y}),this.updateDirectionPaths(i),this.updateSegmentPath(i)),this.updateDirectionPaths(t),this.updateSegmentPath(t),o||(this.pathEditedEventType="path:control-point:adjust",this.index=t,this.controlPointIndex=e,this.segPoint=f,this.trigger("path:editing",this.pathNode,r),this.trigger("path:control-point:adjusting",this.pathNode,r,{index:t,controlPointIndex:e,segPoint:f}))},findSubpathIndex:function(t){for(var e=this._subPathIndices,i=0,n=e.length;i<n;i++)if(e[i]<t)return e[i]},findReversedSubpathIndex:function(t){for(var e=this._subPathIndices,i=e.length-1;0<=i;i--)if(e[i]>t)return e[i]},adjustAnchorPoint:function(t,e,i,n,r){var r=(r=void 0===r?{}:r).dry,o=(void 0===r&&(r=void 0),this._getPathCTM()),s=this.segList,a=s.getItem(t),l=(a.pathSegType==SVGPathSeg.PATHSEG_CLOSEPATH&&(t=this.findSubpathIndex(t),a=s.getItem(t)),this.anchorPoints),h=this.controlPoints,c=l.length-1,u=((0===t||t===c)&&h[1]&&h[c]&&(u=h[1][0],c=h[c][1],u&&u.hasClass("locked")&&u.removeClass("locked"),c&&c.hasClass("locked")&&c.removeClass("locked")),o.inverse()),c=(u.e=0,u.f=0,this._transformPoint(e,i,u)),e=(a.x+=c.x,a.y+=c.y,this._transformPoint(a.x,a.y,o)),i=new z(e),l=(l[t].attr({cx:e.x,cy:e.y}),a.pathSegType==SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS&&(a.x2+=c.x,a.y2+=c.y,u=this._transformPoint(a.x2,a.y2,o),h[t][1].attr({cx:u.x,cy:u.y})),t+1<s.numberOfItems?s.getItem(t+1):0);l&&(l.pathSegType==SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS&&(l.x1+=c.x,l.y1+=c.y,e=this._transformPoint(l.x1,l.y1,o),h[t+1][0].attr({cx:e.x,cy:e.y}),this.updateDirectionPaths(t+1)),this.updateSegmentPath(t+1)),this.updateDirectionPaths(t),this.updateSegmentPath(t),r||(this.pathEditedEventType="path:anchor-point:adjust",this.index=t,this.segPoint=i,this.trigger("path:editing",this.pathNode,n),this.trigger("path:anchor-point:adjusting",this.pathNode,n,{index:t,segPoint:i}))},updateDirectionPaths:function(t){var n=this._getPathCTM(),e=this.segList,r=e.getItem(t),o=this._transformPoint(r.x,r.y,n),s=0<t?e.getItem(t-1):null,a=s?this._transformPoint(s.x,s.y,n):null,e=this.directionPaths[t];Array.isArray(e)&&e.forEach(function(t,e){var i=this._transformPoint(r["x"+ ++e],r["y"+e],n);t.attr("d",["M",(1<e||!s?o:a).x,(1<e||!s?o:a).y,i.x,i.y].join(" "))},this)},updateSegmentPath:function(t){var e=this.segList;if(this._subPathIndices.includes(t)){var i=this.findReversedSubpathIndex(t)||e.numberOfItems;if(e.getItem(--i).pathSegType!=SVGPathSeg.PATHSEG_CLOSEPATH)return;t=i}var n=this.segmentPaths[t];if(n){var r=this._getPathCTM(),i=e.getItem(t-1),i=this._transformPoint(i.x,i.y,r),o=n.createSVGPathSegMovetoAbs(i.x,i.y),s=(n.pathSegList.initialize(o),e.getItem(t)),a=this._transformPoint(s.x,s.y,r);switch(s.pathSegType){case SVGPathSeg.PATHSEG_CLOSEPATH:var l=e.getItem(this.findSubpathIndex(t)),l=this._transformPoint(l.x,l.y,r),o=n.createSVGPathSegLinetoAbs(l.x,l.y);break;case SVGPathSeg.PATHSEG_LINETO_ABS:o=n.createSVGPathSegLinetoAbs(a.x,a.y);break;case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:var l=this._transformPoint(s.x1,s.y1,r),h=this._transformPoint(s.x2,s.y2,r);o=n.createSVGPathSegCurvetoCubicAbs(a.x,a.y,l.x,l.y,h.x,h.y)}n.pathSegList.appendItem(o)}},stopMoving:function(t){var e,i,n,r,t=I(t);this.$point=void 0,this.pathEditedEventType&&(e=this.pathNode,i=this.index,n=this.controlPointIndex,r=this.segPoint,this.trigger("path:edit",e,t),this.trigger(this.pathEditedEventType,e,t,{index:i,controlPointIndex:n,segPoint:r})),this.index=void 0,this.controlPointIndex=void 0,this.segPoint=void 0,this.pathEditedEventType=void 0},createAnchorPoint:function(t){var t=I(t),e=B(t.target).attr("index"),i=this.pathNode,n=this.segList,r=B(i).toLocalPoint(t.pageX,t.pageY),o=n.getItem(e),s=n.getItem(e-1);switch(o.pathSegType){case SVGPathSeg.PATHSEG_CLOSEPATH:var a=n.getItem(0),l=new z(s.x,s.y),a=new z(a.x,a.y),l=new C(l,a).closestPoint(r);n.insertItemBefore(i.createSVGPathSegLinetoAbs(l.x,l.y),e);break;case SVGPathSeg.PATHSEG_LINETO_ABS:a=new z(s.x,s.y),l=new z(o.x,o.y),a=new C(a,l).closestPoint(r);n.insertItemBefore(i.createSVGPathSegLinetoAbs(a.x,a.y),e);break;case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:var l=new z(s.x,s.y),a=new z(o.x1,o.y1),h=new z(o.x2,o.y2),c=new z(o.x,o.y),l=new d(l,a,h,c),a=l.closestPointT(r),h=l.divideAtT(a);n.insertItemBefore(i.createSVGPathSegCurvetoCubicAbs(h[0].end.x,h[0].end.y,h[0].controlPoint1.x,h[0].controlPoint1.y,h[0].controlPoint2.x,h[0].controlPoint2.y),e),o.x1=h[1].controlPoint1.x,o.y1=h[1].controlPoint1.y,o.x2=h[1].controlPoint2.x,o.y2=h[1].controlPoint2.y}this.render(),this.trigger("path:edit",i,t),this.trigger("path:anchor-point:create",i,t)},removeAnchorPoint:function(t){var e,i,t=I(t),n=parseInt(w(t.target).attr("index"),10),r=this.pathNode,o=this.segList,s=o.getItem(n);switch(s.pathSegType){case SVGPathSeg.PATHSEG_MOVETO_ABS:e=o.getItem(n+1),i=r.createSVGPathSegMovetoAbs(e.x,e.y),o.replaceItem(i,n+1),o.removeItem(n);break;case SVGPathSeg.PATHSEG_LINETO_ABS:o.removeItem(n);break;case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:n+1<=o.numberOfItems-1&&(e=o.getItem(n+1)).pathSegType==SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS&&(e.x1=s.x1,e.y1=s.y1),o.removeItem(n)}this.render(),this.trigger("path:edit",r,t),this.trigger("path:anchor-point:remove",r,t);var a=o.numberOfItems;o.getItem(o.numberOfItems-1).pathSegType==SVGPathSeg.PATHSEG_CLOSEPATH&&--a,a<2&&this.trigger("path:invalid",r,t)},lockControlPoint:function(t){var e,t=I(t),t=w(t.target),i=parseInt(t.attr("index")),n=parseInt(t.attr("attribute-index"),10),r=this.getBoundIndex(i,n),o=1===n?2:1,r=this.controlPoints[r];r&&(e=t.hasClass("locked"),t.toggleClass("locked"),r[o-1].toggleClass("locked"),this.trigger("path:interact"),e?this.trigger("path:control-point:unlock",i,n):(this.trigger("path:control-point:lock",i,n),this.adjustControlPoint(i,n,0,0,{dry:!0})))},getBoundIndex:function(t,e){var i,n,r,o,s,a=this.segList,l=this.anchorPoints,h=l.length-1;return 1===e?0===(i=t-1)&&(n=a.numberOfItems-1,r=a.getItem(n).pathSegType==SVGPathSeg.PATHSEG_CLOSEPATH,o=l[0].attr("cx")===l[h].attr("cx"),s=l[0].attr("cy")===l[h].attr("cy"),r&&o&&s&&(i=h)):(i=t+1)===1+h&&(n=a.numberOfItems-1,r=a.getItem(n).pathSegType==SVGPathSeg.PATHSEG_CLOSEPATH,o=l[0].attr("cx")===l[h].attr("cx"),s=l[0].attr("cy")===l[h].attr("cy"),r&&o&&s&&(i=1)),i},getControlPointLockedStates:function(){for(var t=this.controlPoints,e=[],i=0;i<t.length;i++)if(t[i]){e[i]=[];for(var n,r=0;r<=1;r++)t[i][r]&&(n=r+1,t[i][r].hasClass("locked")?e[i][n]=!0:e[i][n]=!1)}return e},setControlPointLockedStates:function(t){for(var e=this.controlPoints,i=0;i<e.length;i++)if(t[i]&&e[i])for(var n=1;n<=2;n++)t[i][n]&&e[i][n-1]&&(!0===t[i][n]?e[i][n-1].addClass("locked"):e[i][n-1].removeClass("locked"))},convertSegmentPath:function(t){var t=I(t),e=B(t.target).attr("index"),i=this.pathNode,n=this.segList,r=n.getItem(e);switch(r.pathSegType){case SVGPathSeg.PATHSEG_CLOSEPATH:var o=n.getItem(e-1),s=n.getItem(0);n.insertItemBefore(i.createSVGPathSegCurvetoCubicAbs(s.x,s.y,o.x,o.y,s.x,s.y),e);break;case SVGPathSeg.PATHSEG_LINETO_ABS:o=n.getItem(e-1);n.replaceItem(i.createSVGPathSegCurvetoCubicAbs(r.x,r.y,o.x,o.y,r.x,r.y),e);break;case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:n.replaceItem(i.createSVGPathSegLinetoAbs(r.x,r.y),e)}this.render(),this.trigger("path:edit",i,t),this.trigger("path:segment:convert",i,t)},addClosePathSegment:function(t){var t=I(t),e=parseInt(w(t.target).attr("index"),10),i=this.segList;0!==e&&e!==i.numberOfItems-1||i.getItem(i.numberOfItems-1).pathSegType!=SVGPathSeg.PATHSEG_CLOSEPATH&&(e=this.pathNode,i.appendItem(e.createSVGPathSegClosePath()),this.render(),this.trigger("path:edit",e,t),this.trigger("path:closepath-segment:add",e,t))},removeClosePathSegment:function(t){var e,t=I(t),i=B(t.target).attr("index"),n=this.segList;n.getItem(i).pathSegType==SVGPathSeg.PATHSEG_CLOSEPATH&&(e=this.pathNode,n.removeItem(i),this.render(),this.trigger("path:edit",e,t),this.trigger("path:closepath-segment:remove",e,t))},isMoreThanFirstClick:function(){return this.clickCounter=this.clickCounter||0,this.clickCounter+=1,this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout(function(){this.clickCounter=0},400),2<=this.clickCounter&&(this.clickCounter=0,clearTimeout(this.timeout),!0)},onAnchorPointPointerDown:function(t){t=I(t);t.stopPropagation(),1!==t.which||this.isMoreThanFirstClick()||(this.startMoving(t),this.delegateDocumentEvents())},onControlPointPointerDown:function(t){t=I(t);t.stopPropagation(),1!==t.which||this.isMoreThanFirstClick()||(this.startMoving(t),this.delegateDocumentEvents())},onSegmentPathPointerDown:function(t){t=I(t);t.stopPropagation(),1!==t.which||this.isMoreThanFirstClick()||(this.startMoving(t),this.delegateDocumentEvents())},onPointerMove:function(t){t=I(t);t.stopPropagation(),this.move(t)},onPointerUp:function(t){this.undelegateDocumentEvents();t=I(t);t.stopPropagation(),this.stopMoving(t)},onAnchorPointDoubleClick:function(t){t=I(t);t.stopPropagation(),t.preventDefault(),1===t.which&&this.removeAnchorPoint(t)},onControlPointDoubleClick:function(t){t=I(t);t.stopPropagation(),t.preventDefault(),1===t.which&&this.lockControlPoint(t)},onSegmentPathDoubleClick:function(t){t=I(t);t.stopPropagation(),t.preventDefault(),1===t.which&&this.createAnchorPoint(t)}}),Oo=_o.extend({className:"popup",eventNamespace:"popup",events:{},renderContent:function(){var t=P(this.options.content)?this.options.content(this.el):this.options.content;t&&this.$el.html(t)}}),Io=n.extend({options:{paper:void 0,graph:void 0,boxContent:function(t){return si("<%= length %> elements selected.")({length:this.model.length})},handles:[{name:"remove",position:"nw",events:{pointerdown:"removeElements"}},{name:"rotate",position:"sw",events:{pointerdown:"startRotating",pointermove:"doRotate",pointerup:"stopBatch"}},{name:"resize",position:"se",events:{pointerdown:"startResizing",pointermove:"doResize",pointerup:"stopBatch"}}],useModelGeometry:!1,strictSelection:!1,rotateAngleGrid:15,allowTranslate:!0},className:"selection",events:{"mousedown .selection-box":"onSelectionBoxPointerDown","touchstart .selection-box":"onSelectionBoxPointerDown","mousedown .handle":"onHandlePointerDown","touchstart .handle":"onHandlePointerDown"},documentEvents:{mousemove:"adjustSelection",touchmove:"adjustSelection",mouseup:"pointerup",touchend:"pointerup",touchcancel:"pointerup"},_action:null,init:function(){this.options.model&&(this.options.collection=this.options.model);var t=this.collection=this.options.collection||this.collection||new o.Collection;if(t.comparator||(t.comparator=this.constructor.depthComparator,t.sort()),this.model=t,!this.options.paper)throw new Error("Selection: paper required");S(this.options,{graph:this.options.paper.model}),Mi(this,"startSelecting","stopSelecting","adjustSelection","pointerup"),this.options.paper.$el.append(this.$el),this._boxCount=0,this.$selectionWrapper=this.createSelectionWrapper(),this.handles=[],et(this.options.handles).forEach(this.addHandle,this),this.startListening()},startListening:function(){var t=this.options.paper,t=(this.listenTo(t,"scale translate",this.onPaperTransformation),this.options.graph),t=(this.listenTo(t,"reset",this.cancelSelection),this.listenTo(t,"change remove",this.onGraphChange),this.collection);this.listenTo(t,"remove",this.onRemoveElement),this.listenTo(t,"reset",this.onResetElements),this.listenTo(t,"add",this.onAddElement)},onPaperTransformation:function(){this.updateSelectionBoxes({async:!1})},onGraphChange:function(t,e){e.selection!==this.cid&&this.updateSelectionBoxes()},cancelSelection:function(){this.model.reset([],{ui:!0})},addHandle:function(i){this.handles.push(i);var t=w("<div/>",{class:"handle "+(i.position||"")+" "+(i.name||""),"data-action":i.name});return i.icon&&t.css("background-image","url("+i.icon+")"),t.html(i.content||""),We(t,i.attrs),this.$selectionWrapper.append(t),k(i.events,function(t,e){N(t)?this.on("action:"+i.name+":"+e,this[t],this):this.on("action:"+i.name+":"+e,t)}.bind(this)),this},stopSelecting:function(t){var e=this.options.paper,i=this.eventData(t).action;switch(i){case"selecting":var n=this.$el.offset(),r=this.$el.width(),o=this.$el.height(),n=e.pageToLocalPoint(n.left,n.top),s=e.scale(),s=(r/=s.sx,o/=s.sy,Nt(n.x,n.y,r,o)),r=this.getElementsInSelectedArea(s),a=this.options.filter,o=(Array.isArray(a)?r=r.filter(function(t){return!a.includes(t.model)&&!a.includes(t.model.get("type"))}):P(a)&&(r=r.filter(function(t){return!a(t.model)})),r.map(function(t){return t.model}));this.model.reset(o,{ui:!0});break;case"translating":this.options.graph.stopBatch("selection-translate"),n=e.snapToGrid(t.clientX,t.clientY),this.notify("selection-box:pointerup",t,n.x,n.y);break;default:i||this.cancelSelection()}this._action=null},removeHandle:function(i){var t=et(this.handles).findIndex(function(t){return t.name===i}),e=this.handles[t];return e&&(k(e.events,function(t,e){this.off("action:"+i+":"+e)}.bind(this)),this.$(".handle."+i).remove(),this.handles.splice(t,1)),this},startSelecting:function(t){t=I(t),this.cancelSelection();var e,i,n,r=this.options.paper.el;n=null!=t.offsetX&&null!=t.offsetY&&w.contains(r,t.target)?(i=t.offsetX,t.offsetY):(e=w(r).offset(),n=r.scrollLeft,r=r.scrollTop,i=t.clientX-e.left+window.pageXOffset+n,t.clientY-e.top+window.pageYOffset+r),this.$el.css({width:1,height:1,left:i,top:n}),this.showLasso(),this.eventData(t,{action:"selecting",clientX:t.clientX,clientY:t.clientY,offsetX:i,offsetY:n}),this.delegateDocumentEvents(null,t.data),this._action="selecting"},changeHandle:function(e,t){var i=et(this.handles).find(function(t){return t&&t.name===e});return i&&(this.removeHandle(e),this.addHandle(y({name:e},i,t))),this},onSelectionBoxPointerDown:function(t){t.stopPropagation(),t=I(t),this.options.allowTranslate&&this.startTranslatingSelection(t),this.eventData(t,{activeElementView:this.getCellView(t.target)});var e=this.options.paper.snapToGrid(t.clientX,t.clientY);this.notify("selection-box:pointerdown",t,e.x,e.y),this.delegateDocumentEvents(null,t.data)},startTranslatingSelection:function(t){this.options.graph.startBatch("selection-translate");var e=this.options.paper.snapToGrid(t.clientX,t.clientY);this.eventData(t,{action:"translating",snappedClientX:e.x,snappedClientY:e.y}),this._action="translating"},adjustSelection:function(t){t=I(t);var e=this.eventData(t),i=e.action;switch(i){case"selecting":var n=t.clientX-e.clientX,r=t.clientY-e.clientY,o=parseInt(this.$el.css("left"),10),s=parseInt(this.$el.css("top"),10);this.$el.css({left:n<0?e.offsetX+n:o,top:r<0?e.offsetY+r:s,width:Math.abs(n),height:Math.abs(r)});break;case"translating":var a,l,h,c,o=this.options.paper.snapToGrid(t.clientX,t.clientY),s=o.x,o=o.y,u=(n=s-e.snappedClientX,r=o-e.snappedClientY,this.options.paper.getRestrictedArea());u&&(a=this.model.toArray(),a=this.options.graph.getCellsBBox(a),h=u.x-a.x,l=u.y-a.y,(c=u.x+u.width-(a.x+a.width))<(n=n<h?h:n)&&(n=c),(h=u.y+u.height-(a.y+a.height))<(r=r<l?l:r)&&(r=h)),(n||r)&&(this.translateSelectedElements(n,r),this.boxesUpdated?1<this.model.length&&this.updateSelectionBoxes():(c=this.options.paper.scale(),this.$el.children(".selection-box").add(this.$selectionWrapper).css({left:"+="+n*c.sx,top:"+="+r*c.sy})),e.snappedClientX=s,e.snappedClientY=o),this.notify("selection-box:pointermove",t,s,o);break;default:i&&this.pointermove(t)}this.boxesUpdated=!1},translateSelectedElements:function(i,n){var r={};this.model.each(function(t){var e;r[t.id]||(e={selection:this.cid},t.translate(i,n,e),t.getEmbeddedCells({deep:!0}).forEach(function(t){r[t.id]=!0}),this.options.graph.getConnectedLinks(t).forEach(function(t){r[t.id]||(t.translate(i,n,e),r[t.id]=!0)}))}.bind(this))},notify:function(t,e){var e=this.eventData(e),i=Array.prototype.slice.call(arguments,1);this.trigger.apply(this,[t,e.activeElementView].concat(i))},getElementsInSelectedArea:function(t){var e=this.options.paper,i={strict:this.options.strictSelection};return this.options.useModelGeometry?e.model.findModelsInArea(t,i).map(e.findViewByModel,e).filter(function(t){return!!t}):e.findViewsInArea(t,i)},pointerup:function(t){var e=this.eventData(t).action;e&&(this.triggerAction(e,"pointerup",t),this.stopSelecting(t),this.undelegateDocumentEvents(),this._action=null)},destroySelectionBox:function(t){this.$('[data-model="'+t.get("id")+'"]').remove(),0===this.$el.children(".selection-box").length&&this.hide(),this._boxCount=Math.max(0,this._boxCount-1)},hide:function(){this.$el.removeClass("lasso selected")},showSelected:function(){this.$el.addClass("selected")},showLasso:function(){this.$el.addClass("lasso")},destroyAllSelectionBoxes:function(){this.hide(),this.$el.children(".selection-box").remove(),this._boxCount=0},createSelectionBox:function(t){var e=t.findView(this.options.paper);e&&(e=e.getBBox({useModelGeometry:this.options.useModelGeometry}),w("<div/>").addClass("selection-box").attr("data-model",t.get("id")).css({left:e.x,top:e.y,width:e.width,height:e.height}).appendTo(this.el),this.showSelected(),this._boxCount++)},createSelectionWrapper:function(){var t=w("<div/>",{class:"selection-wrapper"}),e=w("<div/>",{class:"box"});return t.append(e),t.attr("data-selection-length",this.model.length),this.$el.prepend(t),t},updateSelectionWrapper:function(){var t,e,i={x:1/0,y:1/0},n={x:0,y:0};this.model.each(function(t){var t=this.options.paper.findViewByModel(t);t&&(t=t.getBBox({useModelGeometry:this.options.useModelGeometry}),i.x=Math.min(i.x,t.x),i.y=Math.min(i.y,t.y),n.x=Math.max(n.x,t.x+t.width),n.y=Math.max(n.y,t.y+t.height))}.bind(this)),this.$selectionWrapper.css({left:i.x,top:i.y,width:n.x-i.x,height:n.y-i.y}).attr("data-selection-length",this.model.length),P(this.options.boxContent)&&(t=this.$(".box"),(e=this.options.boxContent.call(this,t[0]))&&t.html(e))},updateSelectionBoxes:function(t){0!==this.collection.length&&(this.boxesUpdated=!0,this.options.paper.requestViewUpdate(this,1,this.UPDATE_PRIORITY,t))},confirmUpdate:function(){this._updateSelectionBoxes()},_updateSelectionBoxes:function(){if(this._boxCount){this.hide();for(var t=this.$el.children(".selection-box"),e=0,i=t.length;e<i;e++){var n=t[e],n=w(n).remove().attr("data-model"),n=this.model.get(n);n&&this.createSelectionBox(n)}this.updateSelectionWrapper()}},onHandlePointerDown:function(t){var e=w(t.currentTarget).attr("data-action");e&&(t.preventDefault(),t.stopPropagation(),t=I(t),this.triggerAction(e,"pointerdown",t),this.eventData(t,{action:e,clientX:t.clientX,clientY:t.clientY,startClientX:t.clientX,startClientY:t.clientY}),this.delegateDocumentEvents(null,t.data),this._action=e)},getCellView:function(t){t=this.model.get(t.getAttribute("data-model"));return t&&t.findView(this.options.paper)},pointermove:function(t){var e,i,n,r=this.eventData(t),o=r.action;o&&(n=this.options.paper.snapToGrid(t.clientX,t.clientY),e=this.options.paper.snapToGrid(r.clientX,r.clientY),i=n.x-e.x,n=n.y-e.y,this.triggerAction(o,"pointermove",t,i,n,t.clientX-r.startClientX,t.clientY-r.startClientY),r.clientX=t.clientX,r.clientY=t.clientY)},triggerAction:function(t,e,i){var n=Array.prototype.slice.call(arguments,2);n.unshift("action:"+t+":"+e),this.trigger.apply(this,n)},onRemoveElement:function(t){this.destroySelectionBox(t),this.updateSelectionWrapper()},onResetElements:function(t){this.destroyAllSelectionBoxes(),t.each(this.createSelectionBox.bind(this)),this.updateSelectionWrapper()},onAddElement:function(t){this.createSelectionBox(t),this.updateSelectionWrapper()},removeElements:function(t){var e=this.collection.toArray();this.cancelSelection(),this.options.graph.removeCells(e,{selection:this.cid})},startRotating:function(t){this.options.graph.trigger("batch:start");var e=this.options.graph.getCellsBBox(this.model.models).center(),i=this.options.paper.snapToGrid(t.clientX,t.clientY),n=this.model.toArray().reduce(function(t,e){return t[e.id]=Q(e.get("angle")||0),t},{});this.eventData(t,{center:e,clientAngle:A(i).theta(e),initialAngles:n})},startResizing:function(t){var e=this.options,i=this.collection,n=e.paper,e=e.graph,r=n.options.gridSize,i=i.toArray(),o=e.getCellsBBox(i),s=o.width,o=o.height,n=n.snapToGrid(t.clientX,t.clientY),a=n.x,n=n.y,l=i.map(function(t){var e=t.angle(),t=t.getBBox(),i=t.bbox(e),n=e<=90?e/90:e<=270?Math.abs(180-e)/90:Math.abs(e-360)/90;return{angle:e,unrotatedBBox:t,bbox:i,factor:n,center:i.center()}}),h=l.reduce(function(t,e){e=e.unrotatedBBox;return e.width<t?e.width:t},1/0),c=l.reduce(function(t,e){e=e.unrotatedBBox;return e.height<t?e.height:t},1/0),u=e.getSubgraph(i),d=u.filter(function(t){return t.isLink()}),g=d.map(function(t){return{vertices:t.vertices()}}),u=e.getCellsBBox(u);this.eventData(t,{size:{width:s,height:o},rotatedBBox:e.getCellsBBox(i),minWidth:r*s/h,minHeight:r*o/c,x0:a,y0:n,pointerX:a,pointerY:n,elements:i,elementsRecords:l,links:d,linksRecords:g,cellsBBox:u}),e.trigger("batch:start")},doResize:function(t){var e=this.eventData(t),i=e.size,n=e.rotatedBBox,r=e.minWidth,o=e.minHeight,s=e.x0,a=e.y0,l=e.pointerX,h=e.pointerY,c=e.elements,u=e.elementsRecords,d=e.links,g=e.linksRecords,p=e.cellsBBox,t=this.options.paper.snapToGrid(t.clientX,t.clientY),f=t.x,t=t.y;if(f!==l||t!==h){e.lastX=f,e.lastY=t;for(var l=i.width,h=i.height,e=Math.max(l+f-s,r),i=Math.max(h+t-a,o),m=Math.max(e/l,0),v=Math.max(i/h,0),y=0,b=c.length;y<b;y++){var w=c[y],A=u[y],C=A.bbox,I=A.unrotatedBBox,x=A.factor,S=A.center,A=A.angle,x=new z(m,v).lerp(new z(v,m),x),I=I.clone().scale(x.x,x.y,S),x=I.bbox(A),S=x.width-C.width,A=x.height-C.height,x=(Math.abs(S)<.001&&(S=0),Math.abs(A)<.001&&(A=0),new z(n.x,0).distance(new z(C.x,0))),C=new z(0,n.y).distance(new z(0,C.y)),S=S/2+x*m-x,x=A/2+C*v-C;if(Math.abs(S)<.001&&(S=0),Math.abs(x)<.001&&(x=0),I.translate(S,x),0===y&&w.getBBox().equals(I))return;w.set({position:{x:I.x,y:I.y},size:{width:I.width,height:I.height}},{selection:this.cid})}for(var P=0,M=d.length;P<M;P++)!function(t){var e=d[t],i=[];g[t].vertices.forEach(function(t){t=new z(t);t.scale(m,v,p.origin()),i.push({x:t.x,y:t.y})}),e.vertices(i)}(P);this.updateSelectionBoxes()}},doRotate:function(t){var i=this.eventData(t),n=this.options.rotateAngleGrid,t=this.options.paper.snapToGrid(t.clientX,t.clientY),r=i.clientAngle-A(t).theta(i.center);.001<Math.abs(r)&&(this.collection.each(function(t){var e=E(i.initialAngles[t.id]+r,n);t.rotate(e,!0,i.center,{selection:this.cid})}.bind(this)),this.updateSelectionBoxes())},stopBatch:function(){this.options.graph.trigger("batch:stop")},getAction:function(){return this._action}},{depthComparator:function(t){return t.getAncestors().length},HandlePosition:{N:"n",NW:"nw",W:"w",SW:"sw",S:"s",SE:"se",E:"e",NE:"ne"}}),Co=Io,zn=n.extend({options:{paper:void 0,usePaperGrid:!1,distance:10},className:"snaplines",documentEvents:{mouseup:"hide",touchend:"hide"},init:function(){Mi(this,"hide"),this.render(),this.startListening(),this.prepareFilters()},render:function(){var t=this.$el,e=this.options,i=this.$horizontal=w("<div>").addClass("snapline horizontal"),n=this.$vertical=w("<div>").addClass("snapline vertical");t.hide().append([i,n]).appendTo(e.paper.el)},startListening:function(){this.stopListening(),this.listenTo(this.options.paper,"element:pointerdown",this.captureCursorOffset),this.listenTo(this.options.paper,"element:pointermove",this.snapWhileMoving),this.listenTo(this.options.paper.model,"batch:stop",this.onBatchStop),this.delegateDocumentEvents()},prepareFilters:function(){this.filterTypes={},this.filterCells={},this.filterFunction=void 0,Array.isArray(this.options.filter)?this.options.filter.forEach(function(t){N(t)?this.filterTypes[t]=!0:this.filterCells[t.id]=!0},this):P(this.options.filter)&&(this.filterFunction=this.options.filter)},onBatchStop:function(t){"resize"===(t=t||{}).batchName&&this.snapWhileResizing(t.cell,t)},captureCursorOffset:function(t,e,i,n){var t=t.getDelegatedView();t&&this.canElementMove(t)&&(t=t.model.get("position"),this._cursorOffset={x:i-t.x,y:n-t.y})},snapWhileResizing:function(n,t){if(t.ui&&!t.snapped&&t.direction&&t.trueDirection){var r=this.options,e=r.paper,i=e.findViewByModel(n);if(i&&i.model.isElement()){var i=n.getBBox(),o=i.bbox(n.get("angle")),s=o.origin(),a=o.corner(),l=Q(n.get("angle")),h=r.distance,c=null,u=null,d=e.options.gridSize,g={vertical:0,horizontal:0},p=t.direction,f=t.trueDirection,m=t.relativeDirection;if(-1!==f.indexOf("right")?g.vertical=a.x:g.vertical=s.x,-1!==f.indexOf("bottom")?g.horizontal=a.y:g.horizontal=s.y,e.model.getElements().find(function(t){if(t.id===n.id||t.isEmbeddedIn(n)||this.filterTypes[t.get("type")]||this.filterCells[t.id]||this.filterFunction&&this.filterFunction(t))return!1;var t=t.getBBox().bbox(t.get("angle")),e=t.origin(),t=t.corner(),i=(r.usePaperGrid&&(e.snapToGrid(d),t.snapToGrid(d)),{vertical:[e.x,t.x],horizontal:[e.y,t.y]});return k(i,function(t,e){t=(t=t.map(function(t){return{position:t,distance:Math.abs(t-g[e])}})).filter(function(t){return t.distance<h}),t=yi(t,function(t){return t.distance}),i[e]=t}),null===c&&0<i.vertical.length&&(c=i.vertical[0].position),null===u&&0<i.horizontal.length&&(u=i.horizontal[0].position),G(c)&&G(u)},this),this.hide(),G(c)||G(u)){var v=0,y=(G(c)&&(v=-1!==f.indexOf("right")?c-o.corner().x:o.origin().x-c),0),b=(G(u)&&(y=-1!==f.indexOf("bottom")?u-o.corner().y:o.origin().y-u),0),w=0;if(!(l%90))w=90===l||270===l?(b=y,v):(b=v,y);else{var a=0<=l&&l<90?1:90<=l&&l<180?4:180<=l&&l<270?3:2,A=(u&&c&&(v<y?(y=0,u=null):(v=0,c=null)),K(l%90)),C=(v&&(b=3===a?v/Math.cos(A):v/Math.sin(A)),y&&(w=3===a?y/Math.cos(A):y/Math.sin(A)),1===a||3===a);switch(m){case"top":case"bottom":w=y?y/(C?Math.cos(A):Math.sin(A)):v/(C?Math.sin(A):Math.cos(A));break;case"left":case"right":b=v?v/(C?Math.cos(A):Math.sin(A)):y/(C?Math.sin(A):Math.cos(A))}}switch(m){case"top":case"bottom":b=0;break;case"left":case"right":w=0}s=Math.max(i.width+b,d),e=Math.max(i.height+w,d),o=(t.minWidth&&t.minWidth>d&&(s=Math.max(s,t.minWidth)),t.minHeight&&t.minHeight>d&&(e=Math.max(e,t.minHeight)),t.maxWidth&&(s=Math.min(s,t.maxWidth)),t.maxHeight&&(e=Math.min(e,t.maxHeight)),t.preserveAspectRatio&&(w<b?e=s*(i.height/i.width):s=e*(i.width/i.height)),s===i.width&&e===i.height||n.resize(s,e,{snaplines:this.cid,direction:p,relativeDirection:m,trueDirection:f,snapped:!0}),n.getBBox().bbox(l));c&&1<Math.abs(o.x-c)&&1<Math.abs(o.width+o.x-c)&&(c=null),u&&1<Math.abs(o.y-u)&&1<Math.abs(o.height+o.y-u)&&(u=null),this.show({vertical:c,horizontal:u})}}}},canElementMove:function(t){return t&&t.model.isElement()&&t.can("elementMove")},snapWhileMoving:function(t,e,i,n){var r,o,s,a,l,h,c,u,d,g,p,f,m,e=t.eventData(e).delegatedView||t;this.canElementMove(e)&&(t=(r=e.model).get("size"),t=Nt(R({x:i-this._cursorOffset.x,y:n-this._cursorOffset.y},t)),o=t.center(),m=t.bbox(r.get("angle")),s=m.origin(),a=m.corner(),h=(l=this.options).paper,c=l.distance,d=u=null,p=g=0,h.model.getElements().find(function(t){if(t===r||t.isEmbeddedIn(r)||this.filterTypes[t.get("type")]||this.filterCells[t.id]||this.filterFunction&&this.filterFunction(t))return!1;var t=t.getBBox().bbox(t.get("angle")),e=t.center(),i=t.origin(),t=t.corner();return null===u&&(Math.abs(e.x-o.x)<c?(u=e.x,g=.5):Math.abs(i.x-s.x)<c?u=i.x:Math.abs(i.x-a.x)<c?(u=i.x,g=1):Math.abs(t.x-a.x)<c?(u=t.x,g=1):Math.abs(t.x-s.x)<c&&(u=t.x)),null===d&&(Math.abs(e.y-o.y)<c?(d=e.y,p=.5):Math.abs(i.y-s.y)<c?d=i.y:Math.abs(i.y-a.y)<c?(d=i.y,p=1):Math.abs(t.y-a.y)<c?(d=t.y,p=1):Math.abs(t.y-s.y)<c&&(d=t.y)),G(u)&&G(d)},this),this.hide(),(G(u)||G(d))&&(G(u)&&(m.x=u-g*m.width),G(d)&&(m.y=d-p*m.height),f=(m=m.center()).x-t.width/2,m=m.y-t.height/2,t=new z(f,m),l.usePaperGrid&&t.snapToGrid(h.options.gridSize),r.position(t.x,t.y,{restrictedArea:h.getRestrictedArea(e,i,n),deep:!0,snapped:!0}),this.show({vertical:u,horizontal:d})))},show:function(t){var e=(t=void 0===t?{}:t).vertical,t=t.horizontal,i=this.options,n=this.$horizontal,r=this.$vertical,o=this.$el,i=i.paper.matrix(),s=i.a,a=i.d,l=i.e,i=i.f;G(t)?n.css("top",t*a+i).show():n.hide(),G(e)?r.css("left",e*s+l).show():r.hide(),o.show()},hide:function(){this.$el.hide()}},{HandlePosition:{N:"n",NW:"nw",W:"w",SW:"sw",S:"s",SE:"se",E:"e",NE:"ne"}}),ga={options:function(){return{columnWidth:this.options.width/2-10,columns:2,rowHeight:80,resizeToFit:!0,dy:10,dx:10}},layoutGroup:function(t,e){var i=this.options.layout;if(e=e||{},!gs)throw new Error("joint.ui.Stencil: joint.layout.GridLayout is not available.");gs.layout(t,R({},i,e.layout))}},To=n.extend({className:"stencil",events:{"click .btn-expand":"openGroups","click .btn-collapse":"closeGroups","click .groups-toggle > .group-label":"openGroups","click .group > .group-label":"onGroupLabelClick","touchstart .group > .group-label":"onGroupLabelClick","input .search":"onSearch","focusin .search":"pointerFocusIn","focusout .search":"pointerFocusOut"},documentEvents:{mousemove:"onDrag",touchmove:"onDrag",mouseup:"onDragEnd",touchend:"onDragEnd",touchcancel:"onDragEnd"},options:{width:200,height:800,label:"Stencil",groups:null,groupsToggleButtons:!1,dropAnimation:!1,search:null,layout:null,snaplines:null,scaleClones:!1,usePaperGrid:!1,dragStartClone:function(t){return t.clone()},dragEndClone:function(t){return t.clone()},canDrag:null,layoutGroup:null,paperOptions:null,paperDragOptions:null,paperPadding:10,contentOptions:null,container:null},DEFAULT_GROUP:"__default__",init:function(){this.setPaper(this.options.paperScroller||this.options.paper),this.graphs={},this.papers={},this.$groups={},this.onSearch=mi(this.onSearch,200),this.delegateEvents(),this.initializeLayout()},initializeLayout:function(){var t=this.options.layout;t&&(P(t)?this.layoutGroup=t:(this.layoutGroup=ga.layoutGroup.bind(this),this.options.layout=x(t)?t:{},S(this.options.layout,ga.options.call(this))))},setPaper:function(t){var e=this.options;if(t instanceof go)e.paperScroller=null,e.paper=t,e.graph=t.model;else{if(!("function"==typeof da&&t instanceof da))throw new Error("Stencil: paper required");e.paperScroller=t,e.paper=t.options.paper,e.graph=t.options.paper.model}},freeze:function(e){var i=this.papers;Object.keys(i).forEach(function(t){i[t].freeze(e)})},unfreeze:function(e){var i=this.papers;Object.keys(i).forEach(function(t){i[t].unfreeze(e)})},renderContent:function(){return w("<div/>").addClass("content")},renderPaperDrag:function(){return w("<div/>").addClass("stencil-paper-drag")},renderSearch:function(){return w("<div/>").addClass("search-wrap").append(w("<input/>",{type:"search",placeholder:"search"}).addClass("search"))},renderToggleAll:function(){return[w("<div/>").addClass("groups-toggle").append(w("<label/>").addClass("group-label").html(this.options.label)).append(w("<button/>",{text:"+"}).addClass("btn btn-expand")).append(w("<button/>",{text:"-"}).addClass("btn btn-collapse"))]},renderElementsContainer:function(){return w("<div/>").addClass("elements")},renderGroup:function(t){t=t||{};var e=w("<div/>").addClass("group").attr("data-name",t.name).toggleClass("closed",!!t.closed),t=w("<h3/>").addClass("group-label").html(t.label||t.name),i=this.renderElementsContainer();return e.append(t,i)},render:function(){this.dispose();var r,o=this.options,t=(this.$content=this.renderContent(),this.$paperDrag=this.renderPaperDrag(),this.$el.empty().append(this.$paperDrag,this.$content),o.search&&this.$el.addClass("searchable").prepend(this.renderSearch()),o.groupsToggleButtons&&this.$el.addClass("collapsible").prepend(this.renderToggleAll()),this.el.dataset.textNoMatchesFound="No matches found",Object.keys(o.groups||{})),e=0<t.length;if(o.paperOptions&&!P(o.paperOptions)&&o.paperOptions.model)throw new Error("ui.Stencil: the `paperOptions` has to be a function if there is the property `model` defined.");e?yi(t,function(t){return this[t].index}.bind(o.groups)).forEach(function(t){var e=this.options.groups[t],i=this.$groups[t]=this.renderGroup({name:t,label:e.label,closed:e.closed}).appendTo(this.$content);if(e.paperOptions&&e.paperOptions.model)throw new Error("ui.Stencil: the `model` property is not allowed in the `paperOptions` for the groups.");var n=(r=M(o,"paperOptions")||{}).model||new ro,i=(n.set("group",t),R({},r,e.paperOptions,{el:i.find(".elements"),model:n,width:e.width||o.width,height:e.height||o.height,interactive:!1,preventDefaultBlankAction:!1})),n=new go(i);this.graphs[t]=i.model,this.papers[t]=n},this):(e=this.renderElementsContainer().appendTo(this.$content),r=M(o,"paperOptions")||{},t=new go(R({},r,{el:e,model:r.model||new ro,width:o.width,height:o.height,interactive:!1,preventDefaultBlankAction:!1})),this.graphs[this.DEFAULT_GROUP]=t.model,this.papers[this.DEFAULT_GROUP]=t),r=M(o,"paperOptions")||{};e=M(o,"paperDragOptions")||{},t=this._graphDrag=e.model||r.model||new ro;return this._paperDrag=new go(R({},e,{el:this.$paperDrag,width:1,height:1,model:t,sorting:go.sorting.NONE})),this.startListening(),this},paperEvents:{"cell:pointerdown":"onDragStart"},startListening:function(){var t,n=this,r=(this.stopListening(),this.paperEvents),o=this.papers;for(t in r)!function(e){var i=r[e];(i="function"!=typeof i?n[i]:i)&&k(o,function(t){n.listenTo(t,e,i)})}(t)},load:function(i,t){Array.isArray(i)?this.loadGroup(i,t):x(i)&&k(this.options.groups,function(t,e){i[e]&&this.loadGroup(i[e],e)}.bind(this))},loadGroup:function(t,e){var i=this.options,n=this.getGraph(e),t=(n.resetCells(t),i.height);e&&(t=this.getGroup(e).height),this.isLayoutEnabled()&&this.layoutGroup(n,this.getGroup(e)),t||this.fitPaperToContent(this.getPaper(e))},isLayoutEnabled:function(){return Boolean(this.options.layout)},getGraph:function(t){var e=this.graphs[t||this.DEFAULT_GROUP];if(e)return e;throw new Error("Stencil: group "+t+" does not exist.")},getPaper:function(t){return this.papers[t||this.DEFAULT_GROUP]},preparePaperForDragging:function(t,e,i){var n=this._paperDrag,r=this._graphDrag,o=this.options,s=o.snaplines,a=o.usePaperGrid,l=o.scaleClones,h=o.paper,c=o.container,o=(this.stopListening(r),n.$el.stop(!0,!0),n.$el.addClass("dragging").appendTo(c||document.body),o.dragStartClone(t.model).position(0,0)),t=(r.resetCells([o]),5),l=(s&&(t+=s.options.distance),s||a||l?(s=(r=h.scale()).sx,a=r.sy,n.scale(s,a),t*=Math.max(s,a)):n.scale(1,1),n.fitToContent({padding:t,allowNewOrigin:"any"}),o.findView(n)),h=l.getBBox({useModelGeometry:!0}),r=h.origin().difference(l.getBBox().origin()),s=this.setPaperDragOffset(e,i,{cloneGeometryBBox:h,cloneViewDeltaOrigin:r,paperDragPadding:t}),a=w(c).offset();return a&&(s.left-=a.left,s.top-=a.top),{clone:o,cloneView:l,cloneBBox:o.getBBox(),cloneGeometryBBox:h,cloneViewDeltaOrigin:r,paperDragPadding:t,paperDragInitialOffset:s}},removePaperAfterDragging:function(){var t=this._paperDrag;this._graphDrag.resetCells([]),this.$el.append(t.$el).removeClass("dragging"),t.$el.removeClass("dragging")},setPaperDragOffset:function(t,e,i){var n=i.cloneViewDeltaOrigin,r=i.cloneGeometryBBox,i=i.paperDragPadding,o=document.body,s=document.documentElement,o=o.scrollTop||s.scrollTop,s=t-n.x-r.width/2-i,t=e-n.y-r.height/2-i+o;return this._paperDrag.$el.offset({left:s,top:t}),{left:s,top:t}},onCloneSnapped:function(t,e,i){var n,r,o,s=this._dragging;s&&(r=i.snapped,n=i.tx,i=i.ty,r?(r=s.cloneBBox,o=s.cloneView,t.position(r.x+n,r.y+i,{silent:!0}),o.translate(),t.set("position",e,{silent:!0}),s.snapOffset={x:n,y:i}):s.snapOffset=null)},_dragging:null,onDragStart:function(t,e){var i,n,r,o=this.options,s=this._graphDrag,a=o.canDrag,l=o.snaplines,o=(o.usePaperGrid,t.model.graph.attributes.group);void 0===o&&(o=null),"function"==typeof a&&!a.call(this,t,e,o)||(this.$el.addClass("dragging"),a=e.clientX,o=e.clientY,i=(t=this.preparePaperForDragging(t,a,o)).cloneView,n=t.clone,this._dragging=t,r=this.getCloneArea(i,e,!1),R(t,{clientX:a,clientY:o,validDropTarget:!1,cloneArea:r}),n.position(r.x,r.y,{silent:!0}),l&&(l.captureCursorOffset(i,e,r.x,r.y),this.listenTo(s,"change:position",this.onCloneSnapped.bind(this))),this.delegateDocumentEvents(null,e.data),this.trigger("element:dragstart",i,e,r.clone(),!1),i.stopListening(),this.isDragCanceled()&&(this.notifyDragEnd(i,e,r,!1),this._dragging=null))},onDrag:function(t){var e=this._dragging,i=this.options;if(e){t.preventDefault();var n=I(t);if(this.isDragCanceled())return r=e.cloneView,s=e.validDropTarget,o=e.cloneArea,this.notifyDragEnd(r,n,o,s),void(this._dragging=null);var r=e.cloneView,o=r.model,s=i.paper,a=i.snaplines,i=i.usePaperGrid,l=this.insideValidArea({x:n.clientX,y:n.clientY}),i=this.getCloneArea(r,n,l&&i),h=i.center(),c=h.x,h=h.y,u=s.localToClientPoint(c,h),d=u.x,u=u.y;R(e,{clientX:d,clientY:u,validDropTarget:l,cloneArea:i}),this.setPaperDragOffset(d,u,e),o.position(0,0,{silent:!0}),r.translate(),o.position(i.x,i.y,{stencil:this.cid}),a&&(l?a.snapWhileMoving(r,n,i.x,i.y):a.hide()),s.options.embeddingMode&&(r.eventData(n,{paper:s}),d=e.cloneViewEventData=r.eventData(n),l?r.processEmbedding(d,t,c,h):r.clearEmbedding(d)),r.startListening(),this.trigger("element:drag",r,n,i.clone(),l),r.stopListening(),this.isDragCanceled()&&(this.notifyDragEnd(r,n,i,l),this._dragging=null)}},onDragEnd:function(t){var e,i,n,r,o,s,a,l,h=this._dragging,c=this.options;h&&(t=I(t),a=h.clone,e=h.clientX,i=h.clientY,n=h.validDropTarget,r=h.cloneArea,o=h.cloneView,s=h.cloneBBox,h=h.snapOffset,l=s.x,s=s.y,h&&(l+=h.x,s+=h.y),a.position(l,s,{silent:!0}),this.notifyDragEnd(o,t,r,n),this.isDragCanceled()||(a=c.paper.clientToLocalPoint(e,i),l=!h,n?this.onDrop(o,t,a,l):this.onDropInvalid(o,t,a,l)),this._dragging=null)},notifyDragEnd:function(t,e,i,n){t.startListening(),this.trigger("element:dragend",t,e,i.clone(),n),t.stopListening(),this.undelegateDocumentEvents()},onDrop:function(t,e,i,n){var r=this.options,o=r.paper,s=r.graph,a=o.options.embeddingMode,l=t.model,r=(s.startBatch("stencil-drag"),r.dragEndClone(l));this.drop(r,i,n),a&&(t.eventData(e,{model:r,paper:o,initialParentId:Ee(),whenNotAllowed:"remove"}),t.finalizeEmbedding(t.eventData(e))),s.getCell(r)?(this.trigger("element:drop",r.findView(o),e,i.x,i.y),this.removePaperAfterDragging(l)):this.onDropInvalid(t,e,i,n),s.stopBatch("stencil-drag")},onDropInvalid:function(t,e,i,n){t=t.model,t=this.options.dragEndClone(t);this.trigger("drop:invalid",e,t,i.x,i.y),this.cancelDrag()},cancelDrag:function(t){var e,i,n,r,o,t=(t=void 0===t?this.options:t).dropAnimation,s=this._dragging,a=this.options,l=this._paperDrag;s&&(e=s.clone,o=s.cloneView,i=s.cloneViewEventData,n=s.paperDragInitialOffset,r=a.paper,a=a.snaplines,r.options.embeddingMode&&i&&o.clearEmbedding(i),a&&a.hide(),s.canceled=!0,t?(r=t.duration,o=t.easing,l.$el.animate(n,r=void 0===r?150:r,o=void 0===o?"swing":o,this.removePaperAfterDragging.bind(this,e))):this.removePaperAfterDragging(e))},isDragCanceled:function(){var t=this._dragging;return!!t&&Boolean(t.canceled)},drop:function(t,e,i){var n=this.options,r=n.paper,n=n.graph,o=t.getBBox(),e=new z({x:e.x+o.x-o.width/2,y:e.y+o.y-o.height/2});i&&e.snapToGrid(r.options.gridSize),t.unset("z"),t.position(e.x,e.y),n.addCell(t,{stencil:this.cid})},insideValidArea:function(t){var e=this.options,i=e.paper,e=e.paperScroller,n=this.getDropArea(this.$el);return!(!(e=e?e.options.autoResizePaper?this.getDropArea(e.$el):(e=this.getDropArea(e.$el),this.getDropArea(i.$el).intersect(e)):this.getDropArea(i.$el))||!e.containsPoint(t)||n.containsPoint(t))},getDropArea:function(t){var t=w(t),e=t.offset(),i=e.left,e=e.top,n=document.body,r=document.documentElement,o=n.scrollTop||r.scrollTop,n=n.scrollLeft||r.scrollLeft,r=parseInt(t.css("border-left-width"),10),s=parseInt(t.css("border-top-width"),10);return new tt({x:i+r-n,y:e+s-o,width:t.innerWidth(),height:t.innerHeight()})},getCloneArea:function(t,e,i){var n=this.options.paper,t=t.model,r=e.clientX,e=e.clientY,r=n.clientToLocalPoint(r,e),e=r.x,r=r.y,t=t.size(),o=t.width,t=t.height,e=e-o/2,r=r-t/2;return i&&(e=(i=n.snapToGrid(n.localToClientPoint(e,r))).x,r=i.y),new tt(e,r,o,t)},filter:function(a,l){var h=this,t=(void 0===l&&(l=this.options.search),Object.keys(this.papers).reduce(function(t,e){var i=h.papers[e],n=e===h.DEFAULT_GROUP?null:e,r=i.model.getCells().filter(function(t){var e=!1,e=P(l)?l.call(h,t,a,n,h):h.isCellMatched(t,a,l,a.toLowerCase()!==a),t=i.findViewByModel(t);return t&&t.vel.toggleClass("unmatched",!e),e}),o=!gi(r),s=h.options,s=((M(s,"paperOptions")||{}).model||new ro).resetCells(r);return h.trigger("filter",s,e,a),h.isLayoutEnabled()&&h.layoutGroup(s,h.getGroup(e)),h.$groups[e]&&h.$groups[e].toggleClass("unmatched",!o),h.fitPaperToContent(i),t||o},!1));this.$el.toggleClass("not-found",!t)},isCellMatched:function(i,n,r,o){return!n||Object.keys(r).some(function(t){var e=r[t];return("*"==t||i.get("type")==t)&&e.some(function(t){t=Me(i.attributes,t,"/");return null!=t&&(t=t.toString(),0<=(t=o?t:t.toLowerCase()).indexOf(n))})})},fitPaperToContent:function(t){var e=this.options,i=t.getComputedSize().width,i=R({minWidth:i,padding:e.paperPadding},e.contentOptions);t.fitToContent(i)},getGroup:function(t){return this.options.groups&&this.options.groups[t]||{}},onSearch:function(t){t=t.target.value;this.$el.toggleClass("stencil-filtered",0<t.length),this.filter(t,this.options.search)},pointerFocusIn:function(){this.$el.addClass("is-focused")},pointerFocusOut:function(){this.$el.removeClass("is-focused")},onGroupLabelClick:function(t){if("touchstart"===t.type)this._groupLabelClicked=!0;else if(this._groupLabelClicked&&"click"===t.type)return void(this._groupLabelClicked=!1);t=w(t.target).closest(".group");this.toggleGroup(t.data("name"))},toggleGroup:function(t){this.isGroupOpen(t)?this.closeGroup(t):this.openGroup(t)},closeGroup:function(t){var e=this.$groups[t];e&&this.isGroupOpen(t)&&(this.trigger("group:close",t),e.addClass("closed"))},openGroup:function(t){var e=this.$groups[t];e&&!this.isGroupOpen(t)&&(this.trigger("group:open",t),e.removeClass("closed"))},isGroupOpen:function(t){t=this.$groups[t];return!!t&&!t.hasClass("closed")},closeGroups:function(){Object.keys(this.$groups).forEach(function(t){this.closeGroup(t)},this)},openGroups:function(){Object.keys(this.$groups).forEach(function(t){this.openGroup(t)},this)},onRemove:function(){this.dispose()},dispose:function(){li(this.papers,"remove"),this.papers={},this._paperDrag&&(this._paperDrag.remove(),this._paperDrag=null),this.undelegateDocumentEvents()}}),pa=n.extend({options:{text:void 0,newlineCharacterBBoxWidth:10,placeholder:void 0,focus:!0,debug:!1,selectAllThreshold:20,useNativeSelection:!0,annotateUrls:!1,urlAnnotation:{attrs:{class:"url-annotation",fill:"lightblue","text-decoration":"underline"}},textareaAttributes:{autocorrect:"off",autocomplete:"off",autocapitalize:"off",spellcheck:"false",tabindex:"0"}},className:"text-editor",events:{"keyup textarea":"onKeyup","input textarea":"onInput","copy textarea":"onCopy","cut textarea":"onCut","paste textarea":"onPaste","mousedown .char-selection-box":"onMousedown","dblclick .char-selection-box":"onDoubleClick","click .char-selection-box":"onTripleClick"},selection:{start:null,end:null},selecting:!1,init:function(){Mi(this,"onMousedown","onMousemove","onMouseup","onDoubleClick","onTripleClick","onKeydown","onAfterPaste","onAfterKeydown");var t=this.options.text;if(!t)throw new Error("ui.TextEditor: text option is mandatory");this.setTextElement(t),w(document.body).on("mousemove",this.onMousemove),w(document.body).on("mouseup",this.onMouseup),w(document.body).on("keydown",this.onKeydown),this.$viewport=w(t),this.options.annotations&&this.setAnnotations(this.options.annotations)},setTextElement:function(t){this.$elText&&this.unbindTextElement(),this.options.text=t,this.$elText=w(t),this.$elText.on("mousedown",this.onMousedown),this.$elText.on("dblclick",this.onDoubleClick),this.$elText.on("click",this.onTripleClick)},render:function(t){this.$caret=w("<div>",{class:"caret"}),this.$selection=w("<div>"),this.$selectionBox=w("<div>",{class:"char-selection-box"}),this.$el.append(this.$caret,this.$selection),this.$textareaContainer=w("<div>",{class:"textarea-container"}),this.$textarea=w("<textarea>",this.options.textareaAttributes),this.textarea=this.$textarea[0],this._textContent=this.textarea.value=this.getTextContent(),this._textareaValueBeforeInput=this.textarea.value,this.$textareaContainer.append(this.textarea),this.options.focus&&this.$el.append(this.$textareaContainer),w(t||document.body).append(this.$el);t=B(this.options.text).bbox();return this.$textareaContainer.css({left:t.x,top:t.y}),this.focus(),B(this.options.text).attr("cursor","text"),this.selectAll(),this},annotateURLBeforeCaret:function(t){t=this.getURLBoundary(Math.max(t-1,0));return!!t&&(this.annotateURL(this.getAnnotations()||[],t[0],t[1]),!0)},hasSelection:function(){return G(this.selection.start)&&G(this.selection.end)&&this.selection.start!==this.selection.end},textContentHasChanged:function(){return this._textContent!==this.textarea.value},restoreTextAreaSelectionDirection:function(){this._selectionDirection&&(this.textarea.selectionDirection=this._selectionDirection)},storeSelectionDirection:function(){this._selectionDirection=this.textarea.selectionDirection},onKeydown:function(t){this.options.debug&&console.log("onKeydown(): ",t.keyCode),this.isModifierKey(t)||(this.hasSelection()&&(this.deselect(),this.restoreTextAreaSelectionDirection()),setTimeout(this.onAfterKeydown,0),this._copied=!1,this._selectionStartBeforeInput=this.textarea.selectionStart,this._selectionEndBeforeInput=this.textarea.selectionEnd)},onAfterKeydown:function(){this.textarea===document.activeElement&&(this.storeSelectionDirection(),this.updateSelectionFromTextarea())},updateSelectionFromTextarea:function(){var t=this.textarea,e=t.selectionStart,t=t.selectionEnd;e===t?this.setCaret(e):this.select(e,t)},textSelectionHasChanged:function(){var t=this.selection,e=this.textarea;return!(!t||!e)&&(t.start!==e.selectionStart||t.end!==e.selectionEnd)},isModifierKey:function(e){return[16,18,17,91].some(function(t){return e.which===t})},isArrowKey:function(t){return 37<=t.which&&t.which<=40},onKeyup:function(t){this.textContentHasChanged()&&this.onInput(t),this.textSelectionHasChanged()&&!this.isArrowKey(t)&&(t=this.textarea).selectionEnd!==t.selectionStart&&this.updateSelectionFromTextarea()},onCopy:function(t){this._copied||this.copyToClipboard()},onCut:function(t){this._copied||this.copyToClipboard()},copyToClipboard:function(){document.queryCommandSupported&&document.queryCommandSupported("copy")&&(this._copied=!0,document.execCommand("copy"))},onInput:function(t){var e,i,n,r,o,s;this.textContentHasChanged()&&(e=this.textarea.value.length-this._textareaValueBeforeInput.length,i={start:this._selectionStartBeforeInput,end:this._selectionEndBeforeInput},n={start:this.textarea.selectionStart,end:this.textarea.selectionEnd},this.options.debug&&console.log("onInput()",t,"selectionBeforeInput",i,"selectionAfterInput",n,"diffLength",e),t=this.inferTextOperationType(i,n,e),r=!1,o=this.getAnnotations(),this.options.annotateUrls&&"insert"===t&&(s=this.textarea.value.substr(i.start,e),this.options.debug&&console.log("onInput()","inserted text",s),/\s/.test(s)&&(r=this.annotateURLBeforeCaret(i.start))&&(o=this.shiftAnnotations(o,n.end,e))),o&&(r||(o=this.annotate(o,i,n,e)),this.options.debug&&console.log("onInput()","modified annotations",o),this._currentAnnotationAttributes&&"insert"===t&&(s={start:i.start,end:n.end,attrs:this._currentAnnotationAttributes},o.push(s),this._currentAnnotationAttributes=void 0,this.options.debug&&console.log("onInput()","insert annotation",s,"final annotations",o))),this._annotations=o,this.trigger("text:change",this.textarea.value,this._textareaValueBeforeInput,o,i,n),this._selectionBeforeInput=n,this._textareaValueBeforeInput=this.textarea.value,this._textContent=this.textarea.value)},onPaste:function(t){this.options.debug&&console.log("onPaste()"),this._textareaValueBeforeInput=this.textarea.value,setTimeout(this.onAfterPaste,0)},onAfterPaste:function(){this.setCaret(this.textarea.selectionStart)},onMousedown:function(t){var e;3!==t.originalEvent.detail&&(this.options.debug&&console.log("onMousedown()"),e=this.getCharNumFromEvent(t),this.startSelecting(),this.select(e),t.preventDefault(),t.stopPropagation())},onMousemove:function(t){var e;this.selectionInProgress()&&(this.options.debug&&console.log("onMousemove()"),e=this.getCharNumFromEvent(t),this.storeSelectionDirection(),this.select(null,e),t.preventDefault(),t.stopPropagation())},onMouseup:function(t){this.selectionInProgress()&&(this.options.debug&&console.log("onMouseup()"),this.stopSelecting(),this.trigger("select:changed",this.selection.start,this.selection.end))},onDoubleClick:function(t){this.options.debug&&console.log("onDoubleClick()");var e=this.getCharNumFromEvent(t),e=this.getWordBoundary(e);this.select(e[0],e[1]),t.preventDefault(),t.stopPropagation()},onTripleClick:function(t){3===t.originalEvent.detail&&(this.options.debug&&console.log("onTripleClick()"),this.hideCaret(),this.selectAll(),t.preventDefault(),t.stopPropagation())},findAnnotationsUnderCursor:function(t,e){return B.findAnnotationsAtIndex(t,e)},findAnnotationsInSelection:function(t,e,i){return B.findAnnotationsBetweenIndexes(t,e,i)},inferTextOperationType:function(t,e,i){return t.start===t.end&&e.start===e.end&&0<i?"insert":t.start===t.end&&e.start===e.end&&i<=0?"delete-single":t.start!==t.end&&e.start===e.end&&e.start===t.start?"delete":t.start!==t.end&&e.start!==t.start?"delete-insert":void 0},annotate:function(t,r,o,s){var a=[],l=this.inferTextOperationType(r,o,s);return et(t).forEach(function(t){var e,i,n;switch(l){case"insert":t.start<r.start&&r.start<=t.end?t.end+=s:t.start>=r.start&&(t.start+=s,t.end+=s);break;case"delete-single":t.start<r.start&&r.start<=t.end&&r.start!==o.start||t.start<=r.start&&r.start<t.end&&r.start===o.start?t.end+=s:t.start>=r.start&&(t.start+=s,t.end+=s);break;case"delete":t.start<=r.start&&r.start<=t.end?r.end<=t.end?t.end+=s:t.end+=o.start-t.end:t.start>=r.start&&t.start<r.end?(n=t.end-t.start,i=r.end-t.start,t.start=r.start,t.end=t.start+n-i):t.start>=r.end&&(t.start+=s,t.end+=s);break;case"delete-insert":t.start<=r.start&&r.start<=t.end?r.start<t.end&&(r.end>t.end?t.end=o.end:t.end=o.end+(t.end-r.end)):t.start>=r.start&&t.start<=r.end?(e=o.start-r.start,i=r.end-t.start,n=t.end-t.start,t.start=r.start+e,t.end=t.start+n-i):t.start>=r.start&&t.end<=r.end?t.start=t.end=0:t.start>=r.end&&(t.start+=s,t.end+=s);break;default:this.options.debug&&console.log("ui.TextEditor: Unknown text operation.")}t.end>t.start&&a.push(t)},this),a},shiftAnnotations:function(t,e,i){return B.shiftAnnotations(t,e,i)},setCurrentAnnotation:function(t){this._currentAnnotationAttributes=t},setAnnotations:function(t){this._annotations=t},getAnnotations:function(){return this._annotations},getCombinedAnnotationAttrsAtIndex:function(e,t){var i={};return et(t).forEach(function(t){(void 0===t.start&&void 0===t.end||e>=t.start&&e<t.end)&&B.mergeAttrs(i,t.attrs)}),i},getSelectionAttrs:function(t,e){var i=t.start,n=t.end;if(i===n&&0===i)return this.getCombinedAnnotationAttrsAtIndex(i,e);if(i===n)return this.getCombinedAnnotationAttrsAtIndex(i-1,e);for(var r=i;r<n;r++){var o,s,a=this.getCombinedAnnotationAttrsAtIndex(r,e);o=o&&!pi(o,a)?(o=Le(B.mergeAttrs({},o)),a=Le(B.mergeAttrs({},a)),s={},k(a,function(t,e){o[e]===a[e]&&Ne(s,e,t)}),s):a}return o},getTextContent:function(){var t=this.options.text,e=B(t).find(".v-line");return 0===e.length?t.textContent:e.reduce(function(t,e,i,n){var r=e.node.textContent;return e.hasClass("v-empty-line")&&(r=""),i===n.length-1?t+r:t+r+"\n"},"")},startSelecting:function(){this.selecting=!0},stopSelecting:function(){this.selecting=!1},selectionInProgress:function(){return!0===this.selecting},selectAll:function(){return this.select(0,this.getNumberOfChars())},select:function(t,e){return this.options.debug&&console.log("select(",t,e,")"),void 0===e&&(e=t),G(t)&&(this.selection.start=t),G(e)&&(this.selection.end=e),G(this.selection.end)||(this.selection.end=this.selection.start),G(this.selection.start)&&G(this.selection.end)&&(this.selection.start===this.selection.end?(this.clearSelection(),this.focus(),this.setCaret(this.selection.start)):(this.hideCaret(),this.renderSelection(this.selection.start,this.selection.end)),this.trigger("select:change",this.selection.start,this.selection.end)),this},setTextAreaSelection:function(t,e){t=this.normalizeSelectionRange({start:t,end:e});this.textarea.focus(),this.textarea.selectionStart=t.start,this.textarea.selectionEnd=t.end},renderSelection:function(t,e){this.options.debug&&console.log("renderSelection()");t=this.normalizeSelectionRange({start:t,end:e});this.clearSelection(),this.options.useNativeSelection?(this.$viewport&&(this._viewportUserSelectBefore=this.$viewport.css("user-select"),this.$viewport.css({"-webkit-user-select":"all","-moz-user-select":"all","user-select":"all"})),e=t.end-t.start,this.selectTextInElement(this.options.text,t.start,e)):this.renderSelectionBoxes(t.start,t.end)},normalizeSelectionStartAndLength:function(t,e,i){var n=t.substr(0,e),t=t.substr(e,i),n=(e-=this.countLineBreaks(n),i-=this.countLineBreaks(t),this.countEmptyLines(n));return{start:e+=n,length:i=(i+=n)-n+this.countEmptyLines(t)}},selectTextInElement:function(e,i,n){if(P(e.selectSubString)&&this.selectTextInElementUsingSelectSubString(e,i,n),!this.actualSelectionMatchesExpectedSelection(i,n))try{this.selectTextInElementUsingRanges(e,i,n)}catch(t){this.options.debug&&console.log(t),P(e.selectSubString)&&this.selectTextInElementUsingSelectSubString(e,i,n)}},selectTextInElementUsingSelectSubString:function(t,e,i){e=this.normalizeSelectionStartAndLength(this.getTextContent(),e,i);try{t.selectSubString(e.start,e.length)}catch(t){this.options.debug&&console.log(t)}},selectTextInElementUsingRanges:function(t,e,i){for(var n,r,o,s,a=window.getSelection(),l=(a.removeAllRanges(),this.normalizeSelectionStartAndLength(this.getTextContent(),e,i)),h=(e=0+l.start,i=0+l.length,this.getTextNodesFromDomElement(t)),c=0,u=e+i;0<i&&0<h.length;)s=(o=c)+(n=h.shift()).length,(e<=o&&o<u||e<s&&s<=u||o<=e&&e<s||o<u&&u<=s)&&(o=Math.max(e-o,0),s=Math.min(o+Math.min(i,n.length),s),(r=document.createRange()).setStart(n,o),r.setEnd(n,s),a.addRange(r),i-=s-o),c+=n.length},actualSelectionMatchesExpectedSelection:function(t,e){var i=window.getSelection().toString();return this.getExpectedSelectedContent(t,e)===(i=i.replace(/\s/g," "))},getExpectedSelectedContent:function(t,e){t=this.getTextContent().substr(t,e);return t=(t=(t=(t=0===t.search(/(\n\r|\r|\n)/)?"-"+t:t).replace(/(\n\r|\r|\n){2,}/g,function(t){return Array.from({length:t.length-1},function(){return"-"}).join("")})).replace(/\n\r|\r|\n/g,"")).replace(/\s/g," ")},getTextNodesFromDomElement:function(t){for(var e=[],i=0,n=t.childNodes.length;i<n;i++){var r=t.childNodes[i];void 0!==r.tagName?e=e.concat(this.getTextNodesFromDomElement(r)):e.push(r)}return e},renderSelectionBoxes:function(e,i){this.options.debug&&console.log("renderSelectionBoxes()"),this.$selection.empty();for(var t,n,r,o=this.getFontSize(),s=this.getTextTransforms(),a=s.rotation,l=e;l<i;l++){var h=this.$selectionBox.clone();try{r=this.getCharBBox(l)}catch(t){this.trigger("select:out-of-range",e,i);break}n&&0===a&&Math.round(r.y)===Math.round(n.y)&&Math.round(r.height)===Math.round(n.height)&&Math.round(r.x)===Math.round(n.x+n.width)?t.css({width:"+="+r.width}):(h.css({left:r.x,top:r.y-r.height,width:r.width,height:r.height,"-webkit-transform":"rotate("+a+"deg)","-webkit-transform-origin":"0% 100%","-moz-transform":"rotate("+a+"deg)","-moz-transform-origin":"0% 100%"}),this.$selection.append(h),t=h),n=r}r&&this.$textareaContainer.css({left:r.x,top:r.y-o*s.scaleY})},clearSelection:function(){return this.options.debug&&console.log("clearSelection()"),this.$selection.empty(),this.options.text.selectSubString&&(this.$viewport&&this._viewportUserSelectBefore&&this.$viewport.css({"-webkit-user-select":this._viewportUserSelectBefore,"-moz-user-select":this._viewportUserSelectBefore,"user-select":this._viewportUserSelectBefore}),window.getSelection().removeAllRanges()),this},deselect:function(){return this.options.debug&&console.log("deselect()"),this.stopSelecting(),this.clearSelection(),this.setTextAreaSelection(this.selection.start,this.selection.end),this},getSelectionStart:function(){return this.selection.start},getSelectionEnd:function(){return this.selection.end},getSelectionRange:function(){return this.normalizeSelectionRange(this.selection)},normalizeSelectionRange:function(t){return(t=ui(t)).start>t.end&&(t.end=[t.start,t.start=t.end][0]),t},getSelectionLength:function(){var t=this.getSelectionRange();return t.end-t.start},getSelection:function(){var t=this.getSelectionRange();return this.getTextContent().slice(t.start,t.end)},getWordBoundary:function(t){for(var e=this.textarea.value,i=/\W/,n=t;n;){if(i.test(e[n])){n+=1;break}--n}for(var r=this.getNumberOfChars(),o=t;o<r&&!i.test(e[o]);)o+=1;return n<o?[n,o]:[o,n]},getURLBoundary:function(t){for(var e=this.textarea.value,i=/\s/,n=t;n;){if(i.test(e[n])){n+=1;break}--n}for(var r=this.getNumberOfChars(),o=t;o<=r&&!i.test(e[o]);)o+=1;if(/[-a-zA-Z0-9@:%_+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_+.~#?&//=]*)?/.test(e.substring(n,o)))return[n,o]},annotateURL:function(t,e,i){var n=this.textarea.value.substring(e,i),n=R({url:n},this.options.urlAnnotation);return n.start=e,n.end=i,pi(n,t[t.length-1])||t.push(n),t},getCharBBox:function(t){if(this.isLineEnding(t))return(e=this.getCharBBox(t-1)).x=e.x2,e.y=e.y2,e.width=this.options.newlineCharacterBBoxWidth||10,e;this.ensureTextVisibility();var e=this.realToSvgCharNum(t),t=this.options.text,i=t.getStartPositionOfChar(e),n=t.getEndPositionOfChar(e),t=t.getExtentOfChar(e),i=this.localToScreenCoordinates(i),n=this.localToScreenCoordinates(n),e=this.getTextTransforms();return{x:i.x,y:i.y,width:t.width*e.scaleX,height:t.height*e.scaleY,x2:n.x,y2:n.y}},realToSvgCharNum:function(t){for(var e=0,i=0;i<=t;i++)this.isLineEnding(i)&&(e+=1);return t-e},selectionStartToSvgCharNum:function(t){return t-this.nonEmptyLinesBefore(t)},isLineEnding:function(t){var e=this.textarea.value;return"\n"===e[t]&&0<t&&"\n"!==e[t-1]},svgToRealCharNum:function(t){for(var e=0,i=0;i<=t+e;i++)this.isLineEnding(i)&&(e+=1);return t+e},ensureTextVisibility:function(){w(this.options.text).show()},localToScreenCoordinates:function(t){return B.transformPoint(t,this.options.text.getCTM())},getNumberOfChars:function(){return this.getTextContent().length},getCharNumFromEvent:function(t){this.ensureTextVisibility();var e=this.options.text,i=t.clientX,t=t.clientY,i=B(e).toLocalPoint(i,t),t=e.getCharNumAtPosition(i);if(t<0){var n=B(e).getBBox(),r=n.containsPoint(i);if(!r&&this.hasSelection()&&n.clone().inflate(this.options.selectAllThreshold).containsPoint(i))return this.selection.end;var r=r?i:n.pointNearestToPoint(i),o=B.createSVGPoint(r.x,r.y),s=e.getCharNumAtPosition(o);if(-1<s)return this.svgToRealCharNum(s);var a,l=0<i.x,h=n.x,c=n.x+n.width,u=h+c/2;do{o.x=u;var d=e.getCharNumAtPosition(o)}while(-1<d&&(s=d),a=u,l&&-1<d||!l&&-1===d?(u=(u+c)/2,h=a):(u=(h+u)/2,c=a),1<Math.abs(a-u));return-1<s?this.svgToRealCharNum(s)+(l?1:0):i.x<0&&i.y<n.y+n.height?0:this.getNumberOfChars()}r=this.localToScreenCoordinates(i),n=this.getCharBBox(this.svgToRealCharNum(t));return Math.abs(n.x-r.x)<Math.abs(n.x+n.width-r.x)?this.svgToRealCharNum(t):this.svgToRealCharNum(t)+1},lineNumber:function(t){t=this.textarea.value.substr(0,t);return this.countLineBreaks(t)},emptyLinesBefore:function(t){for(var e=this.textarea.value.split(/\n\r|\r|\n/g),i=0,n=this.lineNumber(t)-1;0<=n;n--)e[n]||(i+=1);return i},countLineBreaks:function(t){return(t.match(/\n\r|\r|\n/g)||[]).length},countEmptyLines:function(t){var e=(t.match(/(\n\r|\r|\n){2,}/g)||[]).reduce(function(t,e){return t+(e.length-1)},0);return 0===t.search(/(\n\r|\r|\n)/)&&e++,e},nonEmptyLinesBefore:function(t){return this.lineNumber(t)-this.emptyLinesBefore(t)},isEmptyLine:function(t){return!this.textarea.value.split(/\n\r|\r|\n/g)[t]},isEmptyLineUnderSelection:function(t){t=this.lineNumber(t);return this.isEmptyLine(t)},getTextTransforms:function(){var t=this.options.text.getCTM();return B.decomposeMatrix(t)},getFontSize:function(){return parseInt(B(this.options.text).attr("font-size"),10)},getTextAnchor:function(){return B(this.options.text).attr("text-anchor")||""},setCaret:function(t,e){this.ensureTextVisibility(),x(t)&&(e=t,t=void 0),e=e||{};var i=this.options.text,n=this.getNumberOfChars(),r=this.selection.start,o=this.textarea.value;void 0!==t&&(t=Math.min(Math.max(t,0),n),r=this.selection.start=this.selection.end=t),e.silent||this.trigger("caret:change",r),this.setTextAreaSelection(r,r),this.options.debug&&console.log("setCaret(",t,e,")","selectionStart",r,"isLineEnding",this.isLineEnding(r),"isEmptyLineUnderSelection",this.isEmptyLineUnderSelection(r),"svgCharNum",this.selectionStartToSvgCharNum(r),"nonEmptyLinesBefore",this.nonEmptyLinesBefore(r));try{var s,a=this.isEmptyLineUnderSelection(r)||!this.isLineEnding(r)&&o.length!==r?(s=this.selectionStartToSvgCharNum(r),i.getStartPositionOfChar(s)):(s=this.selectionStartToSvgCharNum(r)-1,i.getEndPositionOfChar(s))}catch(t){this.trigger("caret:out-of-range",r),a={x:0,y:0}}t=this.localToScreenCoordinates(a),e=this.getTextTransforms(),o=e.rotation,i=this.getFontSize()*e.scaleY;return this.options.placeholder&&this.$caret.toggleClass("placeholder",0===n),this.$caret.css({left:t.x,top:t.y-i,height:i,"line-height":i+"px","font-size":i+"px","-webkit-transform":"rotate("+o+"deg)","-webkit-transform-origin":"0% 100%","-moz-transform":"rotate("+o+"deg)","-moz-transform-origin":"0% 100%"}).attr({"text-anchor":this.getTextAnchor()}).show(),this.$textareaContainer.css({left:t.x,top:t.y-i}),this.focus(),this},focus:function(){return this.options.debug&&console.log("focus()"),this.showCaret(),this},blur:function(){return this.options.debug&&console.log("blur()"),this.hideCaret(),this},showCaret:function(){return this.options.debug&&console.log("showCaret()"),this.$caret.show(),this},hideCaret:function(){return this.options.debug&&console.log("hideCaret()"),this.$caret.hide(),this},unbindTextElement:function(){this.$elText.off("mousedown",this.onMousedown),this.$elText.off("dblclick",this.onDoubleClick),this.$elText.off("click",this.onTripleClick)},onRemove:function(){this.deselect(),this.unbindTextElement(),w(document.body).off("mousemove",this.onMousemove),w(document.body).off("mouseup",this.onMouseup),w(document.body).off("keydown",this.onKeydown),B(this.options.text).attr("cursor","")}},R({getTextElement:function(t){var e=t.tagName.toUpperCase();if("TEXT"===e||"TSPAN"===e||"TEXTPATH"===e)return"TEXT"===e?t:this.getTextElement(t.parentNode)},edit:function(t,e){var n,i,r=this,o=!1!==(e=e||{}).update,s=(this.options=R({},e,{update:o}),this.getTextElement(t));{if(s)return this.close(),this.ed=new pa(R({text:s},e)),this.ed.on("all",this.trigger,this),(n=e.cellView)?(i=n.paper.el,this.cellViewUnderEdit=n,this.cellViewUnderEditInteractiveOption=this.cellViewUnderEdit.options.interactive,this.cellViewUnderEdit.options.interactive=!1,e.annotationsProperty&&!this.ed.getAnnotations()&&(t=this.cellViewUnderEdit.model.prop(e.annotationsProperty))&&this.ed.setAnnotations(this.deepCloneAnnotations(t))):i=B(s).svg().parentNode,o&&this.ed.on("text:change",function(t,e,i){n?r.updateCellView(n,t,i):r.updateSVGTextNode(s,t,i)}),this.ed.render(i),this;this.options.debug&&console.log("ui.TextEditor: cannot find a text element.")}},updateCellView:function(t,e,i){var n=this.options,r=n.textProperty,n=n.annotationsProperty,o=this.ed.cid,t=t.model;r&&t.prop(r,e,{textEditor:o,async:!1}),n&&t.prop(n,this.deepCloneAnnotations(i),{rewrite:!0,textEditor:o,async:!1})},updateSVGTextNode:function(t,e,i){B(t).text(e,{annotations:i})},close:function(){var t;this.ed&&(this.ed.options.annotateUrls&&(t=this.ed.getSelectionStart(),this.findAnnotationsUnderCursor().find(function(t){return!!t.url&&t})||this.ed.annotateURLBeforeCaret(t)&&this.applyAnnotations(this.getAnnotations())),this.ed.remove(),this.cellViewUnderEdit&&(this.cellViewUnderEdit.options.interactive=this.cellViewUnderEditInteractiveOption),this.ed=this.cellViewUnderEdit=this.cellViewUnderEditInteractiveOption=void 0)},applyAnnotations:function(t){var e=this.options,i=this.ed;i&&e.update&&(e.cellView&&e.annotationsProperty?(e.cellView.model.prop(e.annotationsProperty,this.deepCloneAnnotations(t),{rewrite:!0,textEditor:i.cid}),i.setAnnotations(t)):B(i.options.text).text(i.getTextContent(),{annotations:t}),e=this.getSelectionRange(),0<this.getSelectionLength()?i.select(e.start,e.end):i.setCaret())},deepCloneAnnotations:function(t){try{return JSON.parse(JSON.stringify(t))}catch(t){return}},proxy:function(t,e){if(this.ed)return this.ed[t].apply(this.ed,e)},setCurrentAnnotation:function(t){return this.proxy("setCurrentAnnotation",arguments)},getAnnotations:function(){return this.proxy("getAnnotations",arguments)},setCaret:function(){return this.proxy("setCaret",arguments)},deselect:function(){return this.proxy("deselect",arguments)},selectAll:function(){return this.proxy("selectAll",arguments)},select:function(){return this.proxy("select",arguments)},getNumberOfChars:function(){return this.proxy("getNumberOfChars",arguments)},getCharNumFromEvent:function(){return this.proxy("getCharNumFromEvent",arguments)},getWordBoundary:function(){return this.proxy("getWordBoundary",arguments)},findAnnotationsUnderCursor:function(){return this.proxy("findAnnotationsUnderCursor",[this.ed.getAnnotations(),this.ed.getSelectionStart()])},findAnnotationsInSelection:function(){var t;if(this.ed)return t=this.ed.getSelectionRange(),this.proxy("findAnnotationsInSelection",[this.ed.getAnnotations(),t.start,t.end])},getSelectionAttrs:function(t){var e;if(this.ed)return e=this.ed.getSelectionRange(),this.proxy("getSelectionAttrs",[e,t])},getSelectionLength:function(){return this.proxy("getSelectionLength",arguments)},getSelectionRange:function(){return this.proxy("getSelectionRange",arguments)}},o.Events)),fa=n.extend({className:"widget",references:[],constructor:function(t,e){this.availableReferences=e||{},n.prototype.constructor.call(this,t)},updateAttrs:function(t){We(this.$el,t)},bindEvents:function(){},validateReferences:function(){var t=this.references||[],e=[];return t.forEach(function(t){void 0===this.availableReferences[t]&&e.push(t)},this),e},getReference:function(t){return this.availableReferences[t]},getReferences:function(){return this.availableReferences},enable:function(){},disable:function(){},isDisabled:function(){return!1}},{create:function(t,e,i){void 0===i&&(i={});var n=ki(N(t)?t:t.type);if(!P(i[n]))throw new Error('Widget: unable to find widget: "'+n+'"');i=new i[n](t,e),e=i.validateReferences(e);if(0<e.length)throw new Error('Widget: "'+n+'" missing dependency: '+e.join(", "));return i.render(),i.updateAttrs(t.attrs),i.bindEvents(),i.$el.attr("data-type",n),t.name&&i.$el.attr("data-name",t.name),i}}),Bo=fa.extend({tagName:"label",events:{"change .input":"onChange",mousedown:"pointerdown",touchstart:"pointerdown",mouseup:"pointerup",touchend:"pointerup",click:"pointerclick"},documentEvents:{mouseup:"pointerup",touchend:"pointerup"},init:function(){Mi(this,"pointerup")},render:function(){var t=this.options,e=w("<span/>").text(t.label||"");return this.$input=w("<input/>",{type:"checkbox",class:"input"}).prop("checked",!!t.value),this.$span=w("<span/>"),this.$el.append([e,this.$input,this.$span]),this},onChange:function(t){this.trigger("change",!!t.target.checked,t)},pointerdown:function(t){t=I(t),this.$el.addClass("is-in-action"),this.trigger("pointerdown",t),this.delegateDocumentEvents()},pointerclick:function(t){t=I(t),this.trigger("pointerclick",t)},pointerup:function(t){t=I(t),this.undelegateDocumentEvents(),this.trigger("pointerup",t),this.$el.removeClass("is-in-action"),"touchend"===t.type&&(this.$input.trigger("click"),t.preventDefault())},isDisabled:function(){return this.$input.prop("disabled")},enable:function(){this.$el.removeClass("disabled"),this.$input.prop("disabled",!1)},disable:function(){this.$el.addClass("disabled"),this.$input.prop("disabled",!0)}}),ma=fa.extend({tagName:"label",events:{"change input.toggle":"onChange","click input.toggle":"pointerclick",mousedown:"pointerdown",touchstart:"pointerdown",mouseup:"pointerup",touchend:"pointerup"},documentEvents:{mouseup:"pointerup",touchend:"pointerup"},init:function(){Mi(this,"pointerup")},render:function(){var t=this.options,e=w("<span/>").text(t.label||""),i=w("<span><i/></span>"),t=(this.$input=w("<input/>",{type:"checkbox",class:"toggle"}).prop("checked",!!t.value),w("<div/>").addClass(t.type));return this.$el.append([e,t.append(this.$input,i)]),this},onChange:function(t){this.trigger("change",!!t.target.checked,t)},pointerclick:function(t){t=I(t),this.trigger("pointerclick",t)},pointerdown:function(t){t=I(t),this.$el.addClass("is-in-action"),this.trigger("pointerdown",t),this.delegateDocumentEvents()},pointerup:function(t){t=I(t),this.undelegateDocumentEvents(),this.$el.removeClass("is-in-action"),this.trigger("pointerup",t),"touchend"===t.type&&(this.$input.trigger("click"),t.preventDefault())},isDisabled:function(){return this.$input.prop("disabled")},enable:function(){this.$el.removeClass("disabled"),this.$input.prop("disabled",!1)},disable:function(){this.$el.addClass("disabled"),this.$input.prop("disabled",!0)}}),va=fa.extend({render:function(){return this.options.width&&this.$el.css({width:this.options.width}),this}}),ya=fa.extend({tagName:"label",render:function(){return this.$el.text(this.options.text),this}}),ba=fa.extend({events:{"change .input":"onChange","input .input":"onChange"},render:function(){var t,e=this.options;return this.$output=w("<output/>").text(e.value),t=w("<span/>").addClass("units").text(e.unit),this.$input=w("<input/>",{type:"range",name:e.type,min:e.min,max:e.max,step:e.step,class:"input"}).val(e.value),this.$el.append([this.$input,this.$output,t]),this},onChange:function(t){var e=this.getValue();e!==this.currentValue&&(this.currentValue=e,this.$output.text(e),this.trigger("change",e,t))},getValue:function(){return parseInt(this.$input.val(),10)},setValue:function(t,e){void 0===e&&(e={}),this.$input.val(t),e.silent?(t=this.getValue(),this.currentValue=t,this.$output.text(t)):this.$input.trigger("change")},isDisabled:function(){return this.$input.prop("disabled")},enable:function(){this.$input.prop("disabled",!1)},disable:function(){this.$input.prop("disabled",!0)}}),wa=fa.extend({render:function(){var t=Si(this.options,"type","group","index");return this.selectBox=new Qs(t),this.selectBox.render().$el.appendTo(this.el),this},bindEvents:function(){this.selectBox.on("all",this.trigger,this)},isDisabled:function(){return this.selectBox.isDisabled()},enable:function(){this.selectBox.enable()},disable:function(){this.selectBox.disable()}}),Aa=fa.extend({events:{mousedown:"pointerdown",mouseup:"pointerup",touchend:"pointerup",touchstart:"pointerdown",click:"pointerclick"},tagName:"button",render:function(){var t=this.options;return this.$el.text(t.text),this},pointerclick:function(t){t=I(t),this.trigger("pointerclick",t)},pointerdown:function(t){t=I(t),this.trigger("pointerdown",t)},pointerup:function(t){t=I(t),this.trigger("pointerup",t),"touchend"===t.type&&(this.$el.trigger("click"),t.preventDefault())},isDisabled:function(){return this.$el.prop("disabled")},enable:function(){this.$el.prop("disabled",!1)},disable:function(){this.$el.prop("disabled",!0)}}),Ca=fa.extend({events:{mousedown:"pointerdown",touchstart:"pointerdown",mouseup:"pointerup",touchend:"pointerup",click:"pointerclick",focusin:"pointerfocusin",focusout:"pointerfocusout"},tagName:"div",render:function(){var t=this.options;return this.$label=w("<label/>").text(t.label),this.$text=w("<input/>",{type:"text",class:"input"}).val(t.value),this.$input=w("<div/>").addClass("input-wrapper").append(this.$text),this.$el.append([this.$label,this.$input]),this},pointerclick:function(t){t=I(t),this.trigger("pointerclick",t)},pointerdown:function(t){t=I(t),this.trigger("pointerdown",t),"touchstart"===t.type&&this.$text.trigger("focus")},pointerup:function(t){t=I(t),this.trigger("pointerup",t),"touchend"===t.type&&(this.$text.trigger("click"),t.preventDefault())},pointerfocusin:function(t){t=I(t),this.$el.addClass("is-focused"),this.trigger("pointerfocusin",t)},pointerfocusout:function(t){t=I(t),this.$el.removeClass("is-focused"),this.trigger("pointerfocusout",t)},isDisabled:function(){return this.$text.prop("disabled")},enable:function(){this.$text.prop("disabled",!1)},disable:function(){this.$text.prop("disabled",!0)}}),Ia=fa.extend({events:{mousedown:"pointerdown",touchstart:"pointerdown",mouseup:"pointerup",touchend:"pointerup",click:"pointerclick",focusin:"pointerfocusin",focusout:"pointerfocusout"},tagName:"div",render:function(){var t=this.options;return this.$label=w("<label/>").text(t.label),this.$number=w("<input/>",{type:"number",class:"number",max:t.max,min:t.min}).val(t.value),this.$input=w("<div/>").addClass("input-wrapper").append(this.$number),this.$el.append([this.$label,this.$input]),this},pointerclick:function(t){t=I(t),this.trigger("pointerclick",t)},pointerdown:function(t){t=I(t),this.trigger("pointerdown",t),"touchstart"===t.type&&this.$number.trigger("focus")},pointerup:function(t){t=I(t),this.trigger("pointerup",t),"touchend"===t.type&&(this.$number.trigger("click"),t.preventDefault())},pointerfocusin:function(t){t=I(t),this.$el.addClass("is-focused"),this.trigger("pointerfocusin",t)},pointerfocusout:function(t){t=I(t),this.$el.removeClass("is-focused"),this.trigger("pointerfocusout",t)},isDisabled:function(){return this.$number.prop("disabled")},enable:function(){this.$number.prop("disabled",!1)},disable:function(){this.$number.prop("disabled",!0)}}),xa=fa.extend({events:{mousedown:"pointerdown",touchstart:"pointerdown",mouseup:"pointerup",touchend:"pointerup",click:"pointerclick",focusin:"pointerfocusin",focusout:"pointerfocusout"},tagName:"div",render:function(){var t=this.options;return this.$label=w("<label/>").text(t.label),this.$textarea=w("<textarea/>",{class:"textarea"}).text(t.value),this.$input=w("<div/>").addClass("input-wrapper").append(this.$textarea),this.$el.append([this.$label,this.$input]),this},pointerclick:function(t){t.preventDefault(),t=I(t),this.trigger("pointerclick",t)},pointerdown:function(t){t=I(t),this.trigger("pointerdown",t),"touchstart"===t.type&&this.$textarea.focus()},pointerup:function(t){t=I(t),this.trigger("pointerup",t),"touchend"===t.type&&(this.$textarea.trigger("click"),t.preventDefault())},pointerfocusin:function(t){t=I(t),this.$el.addClass("is-focused"),this.trigger("pointerfocusin",t)},pointerfocusout:function(t){t=I(t),this.$el.removeClass("is-focused"),this.trigger("pointerfocusout",t)},isDisabled:function(){return this.$textarea.prop("disabled")},enable:function(){this.$textarea.prop("disabled",!1)},disable:function(){this.$textarea.prop("disabled",!0)}}),Sa=fa.extend({render:function(){var t=Si(this.options,"type","group","index");return this.selectButtonGroup=new ia(t),this.selectButtonGroup.render().$el.appendTo(this.el),this},bindEvents:function(){this.selectButtonGroup.on("all",this.trigger,this)},isDisabled:function(){return this.selectButtonGroup.isDisabled()},enable:function(){this.selectButtonGroup.enable()},disable:function(){this.selectButtonGroup.disable()}}),Pa=Aa.extend({references:["paperScroller"],options:{min:.2,max:5,step:.2},bindEvents:function(){var t,e=this;this.options.autoToggle&&(t=this.getReferences().paperScroller,this.updateAvailability(t),this.listenTo(t.options.paper,"scale",function(){return e.updateAvailability(t)}))},pointerdown:function(t){var e=this.options;this.getReferences().paperScroller.zoom(e.step,{max:e.max,grid:e.step}),Aa.prototype.pointerdown.call(this,t)},updateAvailability:function(t){t.zoom()<this.options.max?this.enable():this.disable()}}),Ma=Aa.extend({references:["paperScroller"],options:{min:.2,max:5,step:.2},bindEvents:function(){var t,e=this;this.options.autoToggle&&(t=this.getReferences().paperScroller,this.updateAvailability(t),this.listenTo(t.options.paper,"scale",function(){return e.updateAvailability(t)}))},pointerdown:function(t){var e=this.options;this.getReferences().paperScroller.zoom(-e.step,{min:e.min,grid:e.step}),Aa.prototype.pointerdown.call(this,t)},updateAvailability:function(t){t.zoom()>this.options.min?this.enable():this.disable()}}),ka=Aa.extend({references:["paperScroller"],options:{min:.2,max:5,step:.2,useModelGeometry:!1,padding:20},pointerdown:function(t){var e=this.options;this.getReferences().paperScroller.zoomToFit({padding:e.padding,scaleGrid:e.step,minScale:e.min,maxScale:e.max,useModelGeometry:e.useModelGeometry}),Aa.prototype.pointerdown.call(this,t)}}),Na=ba.extend({references:["paperScroller"],options:{min:20,max:500,step:20,value:100,unit:" %"},bindEvents:function(){var e=this,i=this.getReferences().paperScroller;this.on("change",function(t){i.zoom(t/100,{absolute:!0,grid:this.options.step/100})},this),this.listenTo(i.options.paper,"scale",function(t){e.setValue(Math.floor(100*t),{silent:!0})})}}),Ta=Aa.extend({references:["commandManager"],bindEvents:function(){var t,e=this;this.options.autoToggle&&(t=this.getReferences().commandManager,this.updateAvailability(t),this.listenTo(t,"stack",function(){return e.updateAvailability(t)}))},pointerclick:function(){this.getReferences().commandManager.undo()},updateAvailability:function(t){t.hasUndo()?this.enable():this.disable()}}),La=Aa.extend({references:["commandManager"],bindEvents:function(){var t,e=this;this.options.autoToggle&&(t=this.getReferences().commandManager,this.updateAvailability(t),this.listenTo(t,"stack",function(){return e.updateAvailability(t)}))},pointerclick:function(){this.getReferences().commandManager.redo()},updateAvailability:function(t){t.hasRedo()?this.enable():this.disable()}}),Ea=Aa.extend({onRender:function(){var t=this.target=w(this.options.target)[0];t&&!w.contains(window.top.document,t)&&this.$el.hide()},pointerclick:function(){Fe(this.target)}}),Da={checkbox:Bo,toggle:ma,separator:va,label:ya,range:ba,selectBox:wa,button:Aa,inputText:Ca,inputNumber:Ia,textarea:xa,selectButtonGroup:Sa,zoomIn:Pa,zoomOut:Ma,zoomToFit:ka,zoomSlider:Na,undo:Ta,redo:La,fullscreen:Ea},Bo=n.extend({options:{autoToggle:!1,widgetNamespace:null},align:["left","right"],className:"toolbar",defaultGroup:"default",widgets:[],groupViews:[],init:function(){this.tools=et(this.options.tools),this.groups=this.options.groups||{}},getWidgetByName:function(e){return this.widgets.find(function(t){return t.options.name===e})},getWidgets:function(){return this.widgets},groupsWithItemsPairs:function(){for(var i={},t=(this.tools.forEach(function(t){var e=t.group||this.defaultGroup;i[e]=i[e]||{items:[],group:{}},i[e].items.push(t),i[e].group=this.groups[e]||{}},this),Object.keys(i)),e=[],n=0,r=t.length;n<r;n++){var o=t[n];e.push([o,i[o]])}var s=yi(e,function(t){return t[1].group.index});return yi(s,function(t){return t[1].group.align||"left"})},render:function(){var t=this.groupsWithItemsPairs(),i=!1;return t.forEach(function(t){var e=t[0],t=t[1],e=this.renderGroup(e,t);!i&&t.group.align&&"right"===t.group.align&&(i=!0,e.addClass("group-first")),e.appendTo(this.el)},this),this},renderGroup:function(t,e){var i=this.options,n=i.references,r=i.autoToggle,i=i.widgetNamespace,t=new Ba({name:t,align:e.group.align,items:e.items,references:n,autoToggle:r,widgetNamespace:i});return this.groupViews.push(t),t.on("all",function(){this.trigger.apply(this,arguments)}.bind(this)),t.render(),this.widgets=this.widgets.concat(t.widgets),t.$el},onRemove:function(){li(this.groupViews,"off"),li(this.groupViews,"remove")}},{Align:{Left:"left",Right:"right"}}),Ba=n.extend({className:"toolbar-group",init:function(){this.widgets=[]},onRender:function(){this.$el.attr("data-group",this.options.name),this.$el.addClass(this.options.align),this.renderItems()},renderItems:function(){et(this.options.items).forEach(function(t){t=this.createWidget(t);this.$el.append(t.$el)},this)},createWidget:function(i){var t=this.options,e=t.references,n=t.autoToggle,t=t.widgetNamespace,n=N(i)?{autoToggle:n,type:i}:R({autoToggle:n},i),n=fa.create(n,e,t||Da);return n.on("all",function(t){var e=Array.prototype.slice.call(arguments,1);this.trigger.apply(this,[i.name+":"+t].concat(e))}.bind(this)),this.widgets.push(n),n},onRemove:function(){li(this.widgets,"off"),li(this.widgets,"remove")}}),ma=n.extend({className:"tooltip",options:{left:void 0,right:void 0,top:void 0,bottom:void 0,position:void 0,positionSelector:void 0,direction:"auto",minResizedWidth:100,padding:0,rootTarget:null,target:null,container:null,trigger:"hover",viewport:{selector:null,padding:0},dataAttributePrefix:"tooltip",template:'<div class="tooltip-arrow"></div><div class="tooltip-arrow-mask"></div><div class="tooltip-content"></div>',animation:!1},init:function(){this.eventNamespace=("."+this.className+this.cid).replace(/ /g,"_"),this.settings={};var t,e=this.options,i=e.trigger,n=e.rootTarget,r=e.target,o=e.animation,e=(void 0===o&&(o=!1),e.container),e=(e&&(t=w(e)[0]),e||(t=document.body),this.container=t,i.split(" "));Mi(this,"render","hide","show","toggle","isVisible","position"),n?(this.$rootTarget=w(n),e.forEach(function(t){switch(t){case"click":this.$rootTarget.on("click"+this.eventNamespace,this.options.target,this.toggle);break;case"hover":this.$rootTarget.on("mouseover"+this.eventNamespace,this.options.target,this.render);break;case"focus":this.$rootTarget.on("focusin"+this.eventNamespace,this.options.target,this.render)}},this)):(this.$target=w(r),e.forEach(function(t){switch(t){case"click":this.$target.on("click"+this.eventNamespace,this.toggle);break;case"hover":this.$target.on("mouseover"+this.eventNamespace,this.render);break;case"focus":this.$target.on("focusin"+this.eventNamespace,this.render)}},this)),o&&this.animate(o),this.$el.append(this.options.template)},animate:function(t){var e=(t=void 0===t?{}:t).duration,i=(void 0===e&&(e="500ms"),t.delay),t=(void 0===i&&(i="400ms"),t.timingFunction);void 0===t&&(t="ease"),this.$el.addClass("animated").css({animationDelay:i,animationDuration:e,animationTimingFunction:t})},onRemove:function(){(this.options.rootTarget?this.$rootTarget:this.$target).off(this.eventNamespace)},hide:function(){var t=this.settings;t&&(this.unbindHideActions(t.currentTarget),this.$el.removeClass(t.className),this.$el.remove())},show:function(t){this.render(t||{target:this.options.target})},toggle:function(t){this.isVisible()?this.hide():this.show(t)},isVisible:function(){return document.body.contains(this.el)},render:function(t){var e,i=void 0!==t.x&&void 0!==t.y?t:null,t=w(t.target).closest(this.options.target)[0],n=this.settings=this.getTooltipSettings(t),i=(n.currentTarget=t,this.bindHideActions(t),e=i?{x:i.x,y:i.y,width:1,height:1}:Ze(t),this.$(".tooltip-content").html(n.content),this.$el.hide(),this.$el.removeClass("left right top bottom"),this.$el.addClass(n.className),w(this.container).append(this.$el),this.$("img"));i.length?i.on("load",function(){this.position(e),this.$el.addClass("rendered")}.bind(this)):(this.position(e),this.$el.addClass("rendered"))},getTooltipSettings:function(t){var e=this.loadDefinitionFromElementData(t);return this.evaluateOptions(t,e)},unbindHideActions:function(t){var e=this.eventNamespace+".remove";w(t).off(e),clearInterval(this.interval)},bindHideOnRemoveTarget:function(t){clearInterval(this.interval),this.interval=setInterval(function(){w.contains(document,t)||(clearInterval(this.interval),this.hide())}.bind(this),500)},bindHideActions:function(t){var e=this.settings,i=w(t),n=this.eventNamespace+".remove";this.bindHideOnRemoveTarget(t),this.options.trigger.split(" ").forEach(function(t){t={hover:["mouseout","mousedown"],focus:["focusout"]}[t]||[];(t=e.hideTrigger?e.hideTrigger.split(" ")||[]:t).forEach(function(t){i.on(t+n,this.hide)},this)},this)},evaluateOptions:function(i,n){var r=R({},n=n||{},this.options);return k(r,function(t,e){t=P(t)?t(i):t;r[e]=null==t?n[e]:t}),this.normalizePosition(r),r},loadDefinitionFromElementData:function(t){if(!t)return{};var t=this.getAllAttrs(t,"data-"+this.options.dataAttributePrefix),n={};return k(t,function(t,e){var i;"left"!==(i=e=""===e?"content":e)&&"bottom"!==i&&"top"!==i&&"right"!==i&&(n[e]=t)}),n},getAllAttrs:function(t,e){for(var i=e||"",n=t.attributes,r={},o=0,s=n.length;o<s;o++){var a=n[o];a&&a.name.startsWith(i)&&(r[ki(a.name.slice(i.length))]=a.value)}return r},normalizePosition:function(t){var e=t.left||t.right||t.top||t.bottom;!t.position&&e&&(t.left&&(t.position="left"),t.right&&(t.position="right"),t.top&&(t.position="top"),t.bottom&&(t.position="bottom")),!t.positionSelector&&e&&(t.positionSelector=e)},position:function(t){var e=this.settings,i=(this.$el.show(),this.$el.css("width","auto"),Ze(this.container)),n=this.getTooltipBBox(t,i),r=(this.$el.css({left:n.x,top:n.y,width:n.width||"auto"}),{});"left"!==e.position&&"right"!==e.position&&("top"===e.position||"bottom"===e.position)?r.left=t.x+t.width/2-n.x:r.top=t.y+t.height/2-n.y,r.top-=i.y,r.left-=i.x,this.$(".tooltip-arrow, .tooltip-arrow-mask").removeAttr("style").css(r),e.direction&&"off"!==e.direction&&this.$el.addClass("auto"===e.direction?e.position||"left":e.direction)},getViewportViewBBox:function(){var t=this.settings,e=t.viewport.selector?w(t.currentTarget).closest(t.viewport.selector):"html",e=Ze(e),i=(t.viewport.selector||(i=w(window),e.width=i.width()+i.scrollLeft(),e.height=i.height()+i.scrollTop()),t.viewport.padding||0);return e.x+=i,e.y+=i,e.width-=2*i,e.height-=2*i,e},basePositions:{left:function(t,e){var i={x:e.positionedBBox.x+e.positionedBBox.width+e.padding,y:e.targetBBox.y+e.targetBBox.height/2-e.tooltipBBox.height/2};if(t){t=e.viewport.x+e.viewport.width-i.x;if(t>e.minWidth&&t<e.tooltipBBox.width+e.padding&&(i.width=t),t<e.minWidth)return this.settings.position="right",this.basePositions.right(!1,e)}return i},right:function(t,e){var i={x:e.positionedBBox.x-e.tooltipBBox.width-e.padding,y:e.targetBBox.y+e.targetBBox.height/2-e.tooltipBBox.height/2};if(t){t=e.positionedBBox.x-e.padding-e.viewport.x;if(t>e.minWidth&&t<e.tooltipBBox.width+e.padding&&(i.width=t,i.x=e.viewport.x),t<e.minWidth)return this.settings.position="left",this.basePositions.left(!1,e)}return i},top:function(t,e){var i={x:e.targetBBox.x+e.targetBBox.width/2-e.tooltipBBox.width/2,y:e.positionedBBox.y+e.positionedBBox.height+e.padding};if(t&&e.viewport.y+e.viewport.height-(e.positionedBBox.y+e.positionedBBox.height+e.padding)<e.tooltipBBox.height)return this.settings.position="bottom",this.basePositions.bottom(!1,e);return i},bottom:function(t,e){var i={x:e.targetBBox.x+e.targetBBox.width/2-e.tooltipBBox.width/2,y:e.positionedBBox.y-e.tooltipBBox.height-e.padding};if(t&&e.positionedBBox.y-e.padding-e.viewport.y<e.tooltipBBox.height)return this.settings.position="top",this.basePositions.top(!1,e);return i}},getTooltipBBox:function(t,e){var i=this.settings,n=w(i.positionSelector),n=n[0]?Ze(n[0]):t,r=this.measureTooltipElement(),o=this.getViewportViewBBox(),s=i.position||"left",a=i.padding,i=Math.min(i.minResizedWidth,r.width+a),s=this.basePositions[s].call(this,0<i,{padding:a,targetBBox:t,positionedBBox:n,tooltipBBox:r,viewport:o,minWidth:i});return s.x-=e.x,s.y-=e.y,s.y<o.y?s.y=o.y:s.y+r.height>o.y+o.height&&(s.y=o.y+o.height-r.height),s.x<o.x?s.x=o.x:s.x+r.width>o.x+o.width&&(s.x=o.x+o.width-r.width),s},measureTooltipElement:function(){var t=this.$el.clone().appendTo(w("body")).css({left:-1e3,top:-500}),e={width:t.outerWidth(),height:t.outerHeight()};return t.remove(),e}},{TooltipPosition:{Left:"left",Top:"top",Bottom:"bottom",Right:"right"},TooltipArrowPosition:{Left:"left",Top:"top",Bottom:"bottom",Right:"right",Auto:"auto",Off:"off"}}),va=n.extend({MINIMAL_PREVIEW_SIZE:10,className:"tree-layout",documentEvents:{mousemove:"onPointermove",touchmove:"onPointermove",mouseup:"onPointerup",touchend:"onPointerup"},options:{previewAttrs:{parent:{rx:2,ry:2}},useModelGeometry:!1,clone:function(t){return t.clone()},canInteract:function(){return!0},validateConnection:null,validatePosition:null,paperConstructor:go,paperOptions:null,reconnectElements:null,translateElements:null},init:function(){this.toggleDefaultInteraction(!1),this.startListening(),this.render(),this.onSetTheme(null,this.theme)},startListening:function(){var t=this.options.paper;this.listenTo(t,"element:pointerdown",this.canInteract(this.onPointerdown))},toggleDefaultInteraction:function(t){this.options.paper.setInteractivity(t)},render:function(){var t=this.options.paper,e=(this.$activeBox=w("<div>").addClass("tree-layout-box active hidden").appendTo(this.el),R({},this.options.paperOptions,{interactive:!1,width:"100%",height:"100%"}));return this.draggingPaper=new this.options.paperConstructor(e),this.draggingPaper.undelegateEvents(),this.$translateBox=w("<div>").addClass("tree-layout-box translate hidden").append(this.draggingPaper.render().el).appendTo(this.el),this.$mask=w("<div>").addClass("tree-layout-mask"),this.svgViewport=B(t.cells),this.svgPreviewChild=B(this.renderChildPreview()).attr(this.options.previewAttrs.child||{}).addClass("tree-layout-preview child"),this.svgPreviewConnection=B(this.renderConnectionPreview()).attr(this.options.previewAttrs.link||{}).addClass("tree-layout-preview link"),this.svgPreviewParent=B(this.renderParentPreview()).attr(this.options.previewAttrs.parent||{}).addClass("tree-layout-preview parent"),this.svgPreview=B("g").addClass("tree-layout-preview-group").append([this.svgPreviewConnection,this.svgPreviewParent,this.svgPreviewChild]),this.$el.appendTo(t.el),this},renderChildPreview:function(){return B("circle")},renderParentPreview:function(){return B("rect")},renderConnectionPreview:function(){return B("path")},onSetTheme:function(e,i){[this.svgPreview,this.$mask].forEach(function(t){t&&(e&&t.removeClass(this.themeClassNamePrefix+e),t.addClass(this.themeClassNamePrefix+i))},this)},onRemove:function(){this.svgPreview.remove(),this.$mask.remove()},toggleDropping:function(t){this.$mask.toggleClass("dropping-not-allowed",!t),this.$translateBox.toggleClass("no-drop",!t)},canDrop:function(){return this.isActive()&&!this.$translateBox.hasClass("no-drop")},isActive:function(){return!this.$translateBox.hasClass("hidden")},updateBox:function(t,e){t.css({width:e.width,height:e.height,left:e.x,top:e.y})},positionTranslateBox:function(t){t=B.transformPoint(t,this.ctm);this.$translateBox.css({left:t.x,top:t.y})},prepareDraggingPaper:function(t){t=this.options.clone(t).position(0,0);this.draggingPaper.scale(this.ctm.a,this.ctm.d),this.draggingPaper.model.resetCells([t])},dragstart:function(t,e,i){var n=this.$translateBox,r=this.$activeBox,o=this.options,s=o.paper,o=o.useModelGeometry,t=(this.toggleDropping(!1),this.ctm=s.matrix(),t[0]),s=t.findView(s);s?(s=s.getBBox({useModelGeometry:o}),this.updateBox(n,S({x:e,y:i},s)),this.updateBox(r,s),r.removeClass("external")):(o=B.transformRect(t.getBBox(),this.ctm),this.updateBox(n,S({x:e,y:i},o)),r.addClass("external")),this.show(),this.prepareDraggingPaper(t)},drag:function(t,e,i){var n,r,o,s,a,l=this,h=this.model,c={x:e,y:i};this.candidate&&(this.candidate=null,this.hidePreview()),this.positionTranslateBox(c),(n=(r=h.getMinimalRootAreaByPoint(c))?r.findMinimalAreaByPoint(c,{expandBy:Math.min(h.get("siblingGap"),h.get("gap"))/2}):n)?(r=this.findDirection(n,c),o=n.getLayoutSiblings(r),s=o.getSiblingRankByPoint(c),et(t).every(function(t){return this.isConnectionValid(t,o,s)},this)?(this.candidate={id:n.root.id,direction:r,siblingRank:s},this.updatePreview(o,s),this.showPreview(),this.toggleDropping(!0)):this.toggleDropping(!1)):(h=!0,"function"==typeof(a=this.options.validatePosition)&&(h=et(t).every(function(t){return a.call(l,t,e,i,l)})),this.toggleDropping(h))},dragend:function(t,e,i){var n,r=this.candidate,o=this.options;this.canDrop()&&(r?("function"==typeof(n=o.reconnectElements)?n.apply(this,[t,o.paper.getModelById(r.id),r.siblingRank,r.direction,this]):this.reconnectElements(t,r),this.candidate=null):"function"==typeof(n=o.translateElements)?n.call(this,t,e,i,this):this.translateElements(t,e,i)),this.hide()},show:function(){var t=this.$mask,e=this.$activeBox,i=this.$translateBox,n=this.options.paper.$el;n.is(t.parent())||t.appendTo(n),e.toggleClass("hidden",e.hasClass("external")),i.removeClass("hidden")},hide:function(){this.$mask.remove().removeClass("dropping-not-allowed"),this.$activeBox.addClass("hidden"),this.$translateBox.addClass("hidden"),this.hidePreview()},cancelDrag:function(){this.candidate=null,this.undelegateDocumentEvents(),this.hide()},reconnectElement:function(t,e){var i,n=this.model,r=this.options,o=n.graph,o=(o.getCell(t)||(o.addCell(t),n.layoutTree(t)),e.siblingRank+.5),s={direction:e.direction,siblingRank:o,ui:!0,treeLayoutView:this.cid};n.reconnectElement(t,e.id,s)||((i=(r=r.paper).getDefaultLink(t.findView(r))).set({source:{id:e.id},target:{id:t.id}}),i.addTo(r.model,s),n.changeSiblingRank(t,o,s),n.changeDirection(t,e.direction,s),i=n.getAttribute(t,"direction"),n.updateDirections(t,[i,e.direction],s))},reconnectElements:function(t,e){t.forEach(function(t){this.reconnectElement(t,e)},this),this.layout()},translateElement:function(t,e,i){var n=this.model.graph,r=n.getConnectedLinks(t,{inbound:!0}),r=(li(r,"remove"),t.get("size"));t.set("position",{x:e-r.width/2,y:i-r.height/2},{ui:!0,treeLayoutView:this.cid}),n.getCell(t)||n.addCell(t,{ui:!0,treeLayoutView:this.cid})},translateElements:function(t,e,i){t.forEach(function(t){this.translateElement(t,e,i)},this),this.layout()},layout:function(){this.model.layout({ui:!0,treeLayoutView:this.cid})},updatePreview:function(t,e){var i=t.parentArea.root,n=Math.max(this.model.get("siblingGap")/2,this.MINIMAL_PREVIEW_SIZE),n={width:n,height:n},e=t.getNeighborPointFromRank(e),r=t.getConnectionPoints(e,{ignoreSiblings:!0}),o=t.getParentConnectionPoint(),t=t.getChildConnectionPoint(e,n);this.updateParentPreview(i.position(),i.size(),i),this.updateChildPreview(e,n),this.updateConnectionPreview(o,t,r)},showPreview:function(){this.svgViewport.append(this.svgPreview)},hidePreview:function(){this.svgPreview.remove()},updateParentPreview:function(t,e){this.svgPreviewParent.attr({x:t.x,y:t.y,width:e.width,height:e.height})},updateChildPreview:function(t,e){this.svgPreviewChild.attr({cx:t.x,cy:t.y,r:e.width/2})},updateConnectionPreview:function(t,e,i){this.svgPreviewConnection.attr({d:Qn(t,e,i,{})})},findDirection:function(t,e){var i,n=t.root.get("layout")||t.getType();switch(n){case"BL-BR":case"TL-TR":case"L-R":return i=n.split("-"),e.x>t.rootCX?i[1]:i[0];case"BL-TL":case"BR-TR":case"B-T":return i=n.split("-"),e.y>t.rootCY?i[0]:i[1];case"L":case"R":case"T":case"B":case"TR":case"TL":case"BR":case"BL":return n;default:return t.direction}},isConnectionValid:function(t,e,i){var n=e.parentArea.root;if(t.id==n.id)return!1;if(this.model.graph.isSuccessor(t,e.parentArea.root))return!1;var r=this.model.getLayoutArea(t);if(r&&r.parentArea&&r.parentArea==e.parentArea&&r.direction==e.direction){e=r.siblingRank-i;if(0==e||1==e)return!1}r=this.options.validateConnection;return"function"!=typeof r||r.call(this,t,n,this)},canInteract:function(e){return function(t){this.options.canInteract(t)&&e.apply(this,arguments)}.bind(this)},startDragging:function(t){t=Array.isArray(t)?t:[t];gi(t)||this.delegateDocumentEvents(null,{moveCounter:0,draggedElements:t})},onPointerdown:function(t){this.startDragging(t.model)},onPointermove:function(t){var e=t.data,i=this.options.paper,t=i.clientToLocalPoint({x:t.clientX,y:t.clientY});e.moveCounter===i.options.clickThreshold?this.dragstart(e.draggedElements,t.x,t.y):e.moveCounter>i.options.clickThreshold&&this.drag(e.draggedElements,t.x,t.y),e.moveCounter++},onPointerup:function(t){var e=t.data,i=this.options.paper;e.moveCounter>=i.options.clickThreshold&&(i=i.clientToLocalPoint({x:t.clientX,y:t.clientY}),this.dragend(e.draggedElements,i.x,i.y)),this.undelegateDocumentEvents()}}),Ga=function(e){function t(t){e.call(this,t),this.update()}e&&(t.__proto__=e);var i={elements:{configurable:!0},direction:{configurable:!0},stackIndexAttributeName:{configurable:!0},stackElementIndexAttributeName:{configurable:!0}};return((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.defaults=function(){return{stackGap:10,stackElementGap:10,direction:Ws.Directions.TopBottom,stackIndexAttributeName:"stackIndex",stackElementIndexAttributeName:"stackElementIndex"}},t.prototype.update=function(){var t=Ws.layout(this.elements,this.attributes);this.bbox=t.bbox,this.stacks=t.stacks,this.trigger("update")},t.prototype.getStackFromPoint=function(t){for(var e=0;e<this.stacks.length;e++){var i=this.stacks[e],n=i.bbox;if((this.direction===Ws.Directions.BottomTop||this.direction===Ws.Directions.TopBottom)&&t.x>=n.x&&t.x<n.x+n.width)return i;if((this.direction===Ws.Directions.RightLeft||this.direction===Ws.Directions.LeftRight)&&t.y>=n.y&&t.y<n.y+n.height)return i}return null},t.prototype.getInsertElementIndexFromPoint=function(t,e){var i=t.elements,n=i.length;if(0===n)return 0;switch(this.direction){case Ws.Directions.TopBottom:for(var r=0;r<n;r++){var o=i[r],o=o.position().y+o.size().height/2;if(e.y<o)return r}return n;case Ws.Directions.BottomTop:for(var s=0;s<n;s++){var a=i[s],a=a.position().y+a.size().height/2;if(e.y>a)return s}return n;case Ws.Directions.LeftRight:for(var l=0;l<n;l++){var h=i[l],h=h.position().x+h.size().width/2;if(e.x<h)return l}return n;case Ws.Directions.RightLeft:for(var c=0;c<n;c++){var u=i[c],u=u.position().x+u.size().width/2;if(e.x>u)return c}return n}},t.prototype.getStackFromElement=function(t){return this.stacks[t.get(this.stackIndexAttributeName)]},t.prototype.hasElement=function(t){return t.has(this.stackIndexAttributeName)},t.prototype.insertElement=function(t,e,i,n){var r=this.get("graph"),o=(r.startBatch("stack-layout-insert"),r.getCell(t)||r.addCell(t,n),this.stackIndexAttributeName),s=this.stackElementIndexAttributeName,a=this.stacks[e];if(a){var l=a.elements,a=l[i],h=l.length;if(a)for(var c=a.get(s),u=i;u<h;u++){var d=l[u],g=d.get(s)||0;d.set(s,g+1,n)}else c=0<h?(l[l.length-1].get(s)||0)+1:0}else c=0;t.set(((a={})[o]=e,a[s]=c,a),n),this.update(),r.stopBatch("stack-layout-insert")},i.elements.get=function(){var e=this;return this.get("graph").getElements().filter(function(t){return t.has(e.stackIndexAttributeName)})},i.direction.get=function(){return this.get("direction")},i.stackIndexAttributeName.get=function(){return this.get("stackIndexAttributeName")},i.stackElementIndexAttributeName.get=function(){return this.get("stackElementIndexAttributeName")},Object.defineProperties(t.prototype,i),t}(o.Model),ya={Clipboard:Vo,ColorPalette:Ks,ContextToolbar:_o,Dialog:qs,FlashMessage:ta,FreeTransform:ea,Halo:Ro,Inspector:na,Keyboard:ks,Lightbox:jo,Navigator:e,PaperScroller:da,PathDrawer:Zo,PathEditor:ko,Popup:Oo,SelectBox:Qs,SelectButtonGroup:ia,Selection:Io,SelectionView:Co,Snaplines:zn,Stencil:To,TextEditor:pa,Toolbar:Bo,Tooltip:ma,TreeLayoutView:va,StackLayoutView:function(e){function t(t){e.call(this,t),this.currentEventData={},this.paper=t.paper,this.model||(this.model=new Ga(Object.assign({},t.layoutOptions,{graph:this.paper.model}))),this.previewFunction=t.preview||Ts,this.validateMoving=t.validateMoving||Ls,this.canInteract=t.canInteract||Ds,this.modifyInsertElementIndex=t.modifyInsertElementIndex||Es,this.startListening()}return e&&(t.__proto__=e),((t.prototype=Object.create(e&&e.prototype)).constructor=t).prototype.preinitialize=function(){this.svgElement=!0,this.tagName="g"},t.prototype.startListening=function(){var t=this.paper;this.listenTo(t,"element:pointerdown",this.onPaperPointerdown),this.listenTo(t,"element:pointermove",this.onPaperPointermove),this.listenTo(t,"element:pointerup",this.onPaperPointerup)},t.prototype.getPreviewPosition=function(t,e){var i,n=this.model.get("stackElementGap")/2,r=this.model.direction,o=t.bbox,s=t.elements,a=s.length,l=s[e],h={x:0,y:0};switch(r){case Ws.Directions.TopBottom:h.x=o.x+o.width/2,l?h.y=l.position().y-n:(i=s[a-1],h.y=i?i.position().y+i.size().height+n:o.y-n);break;case Ws.Directions.BottomTop:h.x=o.x+o.width/2,l?h.y=l.position().y+l.size().height+n:(i=s[a-1],h.y=i?i.position().y-n:o.y+o.height+n);break;case Ws.Directions.LeftRight:h.y=o.y+o.height/2,l?h.x=l.position().x-n:(i=s[a-1],h.x=i?i.position().x+i.size().width+n:o.x-n);break;case Ws.Directions.RightLeft:h.y=o.y+o.height/2,l?h.x=l.position().x+l.size().width+n:(i=s[a-1],h.x=i?i.position().x-n:o.x+o.width+n)}return h},t.prototype.createGhost=function(t){t=t.vel.clone();return t.attr("opacity",.4),t.node.style.transform="",t.addClass("stack-layout-ghost"),t},t.prototype.dragstart=function(t,e,i){t=this.model.getStackFromElement(t);this.currentEventData||(this.currentEventData={}),Object.assign(this.currentEventData,{sourceStack:t})},t.prototype.drag=function(e,t,i){if(this.currentEventData){var t={x:t,y:i},i=this.currentEventData.sourceStack,n=this.currentEventData.preview,r=this.model.getStackFromPoint(t);if(r){i&&(o=i.elements.findIndex(function(t){return t.id===e.id}));var o,s=this.model.getInsertElementIndexFromPoint(r,t),s=this.modifyInsertElementIndex({sourceStack:i,sourceElement:e,targetStack:r,insertElementIndex:s},new z(t),this);if(r!==i||s!==o&&s!==o+1)return void(r===this.currentEventData.targetStack&&s===this.currentEventData.insertElementIndex||(t=!this.validateMoving({sourceStack:i,sourceElement:e,targetStack:r,insertElementIndex:s},this),n&&n.remove(),(n=B(this.previewFunction({sourceStack:i,sourceElement:e,targetStack:r,insertElementIndex:s,invalid:t},this))).addClass("stack-layout-preview"),t&&n.addClass("stack-layout-preview-invalid"),n.appendTo(this.paper.getLayerNode(go.Layers.FRONT)),o=this.getPreviewPosition(r,s),B(n).attr("transform","translate("+o.x+","+o.y+")"),Object.assign(this.currentEventData,{invalid:t,preview:n,targetStack:r,insertElementIndex:s})))}n&&n.remove(),delete this.currentEventData.invalid,delete this.currentEventData.preview,delete this.currentEventData.targetStack,delete this.currentEventData.insertElementIndex}},t.prototype.dragend=function(t,e,i){var n,r,o,s;this.currentEventData&&(n=(s=this.currentEventData).preview,r=s.targetStack,o=s.insertElementIndex,s=s.invalid,n&&n.remove(),r&&!s&&(this.model.insertElement(t,r.index,o,{stackLayoutView:this.cid}),delete this.currentEventData))},t.prototype.cancelDrag=function(){var t;this.currentEventData&&((t=this.currentEventData.preview)&&t.remove(),delete this.currentEventData)},t.prototype.canDrop=function(){if(!this.currentEventData)return!1;var t=this.currentEventData,e=t.targetStack,t=t.invalid;return e&&!t},t.prototype.onPaperPointerdown=function(t,e,i,n){if(this.canInteract(t,this)){if(t.can("elementMove"))throw new Error('ui.StackLayoutView: requires the "elementMove" interactivity set to false. e.g. paper.setInteractivity(false)');var r=t.model,r=(this.dragstart(r,i,n),r.position());Object.assign(this.currentEventData,{ghost:this.createGhost(t),dx:i-r.x,dy:n-r.y})}else delete this.currentEventData},t.prototype.onPaperPointermove=function(t,e,i,n){var r,o,s=this.currentEventData;s&&(t=t.model,this.drag(t,i,n),t=s.ghost,r=s.dx,o=s.dy,s=s.invalid,t&&(t.attr("transform","translate("+(i-r)+","+(n-o)+")"),t.parent()||t.appendTo(this.paper.getLayerNode(go.Layers.FRONT)),t.toggleClass("stack-layout-ghost-invalid",Boolean(s))))},t.prototype.onPaperPointerup=function(t,e,i,n){var r=this.currentEventData;r&&((r=r.ghost)&&r.remove(),r=t.model,this.dragend(r,i,n))},t}(n),widgets:Da,Widget:fa};function za(t,n,r,o){void 0===r&&(r=null),void 0===o&&(o=[]);var e=(n=void 0===n?{}:n).children,s=n.makeElement,a=n.makeLink,e=P(e)?e(t):t[e||"children"];return r||(r=s(t,null),o.push(r)),et(e).forEach(function(t){var e=s(t,r),i=a(r,e);o.push(e,i),za(t,n,e,o)}),o}function Oa(t,e,i){i=i||function(t,e){return 1};var n,r,o,s,a,l={},h=(l[e]=0,{}),c=new Ra;for(n in t)n!==e&&(l[n]=1/0),c.insert(l[n],n,n);for(var u={};!c.isEmpty();)for(u[r=c.remove()]=!0,o=t[r]||[],s=0;s<o.length;s++)u[n=o[s]]||(a=l[r]+i(r,n))<l[n]&&(l[n]=a,h[n]=r,c.updatePriority(n,a));return h}var Ra=function(t){this.comparator=(t=t||{}).comparator||function(t,e){return t-e},this.index={},this.data=t.data||[],this.heapify()};Ra.prototype.isEmpty=function(){return 0===this.data.length},Ra.prototype.insert=function(t,e,i){t={priority:t,value:e},this.data.push(t),e=this.data.length-1;i&&(t.id=i,this.index[i]=e),this.bubbleUp(e)},Ra.prototype.peek=function(){return this.data[0]&&this.data[0].value},Ra.prototype.peekPriority=function(){return this.data[0]&&this.data[0].priority},Ra.prototype.updatePriority=function(t,e){var i=this.index[t];if(null==i)throw new Error("Node with id "+t+" was not found in the heap.");var t=this.data,n=t[i].priority,n=this.comparator(e,n);n<0?(t[i].priority=e,this.bubbleUp(i)):0<n&&(t[i].priority=e,this.bubbleDown(i))},Ra.prototype.remove=function(){var t=this.data,e=t[0],i=t.pop();return this.index[t.length]=null,0<t.length&&((t[0]=i).id&&(this.index[i.id]=0),this.bubbleDown(0)),e&&e.value},Ra.prototype.heapify=function(){for(var t=0;t<this.data.length;t++)this.bubbleUp(t)},Ra.prototype.bubbleUp=function(t){for(var e,i,n=this.data;0<t&&this.comparator(n[t].priority,n[e=t-1>>>1].priority)<0;)i=n[e],n[e]=n[t],n[t].id&&(this.index[n[t].id]=e),n[t]=i,n[t].id&&(this.index[n[t].id]=t),t=e},Ra.prototype.bubbleDown=function(t){for(var e=this.data,i=e.length-1;;){var n=1+(t<<1),r=1+n,o=t;if(n<=i&&this.comparator(e[n].priority,e[o].priority)<0&&(o=n),(o=r<=i&&this.comparator(e[r].priority,e[o].priority)<0?r:o)===t)break;n=e[o];e[o]=e[t],e[t].id&&(this.index[e[t].id]=o),e[t]=n,e[t].id&&(this.index[e[t].id]=t),t=o}};function Va(t,e,i,n){void 0===n&&(n={});var r={},o=(t.getLinks().forEach(function(t){var e=t.get("source").id,t=(r[e]||(r[e]=[]),t.get("target").id);r[t]||(r[t]=[]),r[e].push(t),n.directed||r[t].push(e)}),Oa(r,e.id||e,n.weight)),s=[],a=i.id||i;for(o[a]&&s.push(a);a=o[a];)s.unshift(a);return s}ro.prototype.shortestPath=function(t,e,i){return Va(this,t,e,i)},ro.prototype.constructTree=function(t,e){return za(t,e,null,[])};ba={constructTree:za,shortestPath:Va},wa={Local:{prefix:"joint.storage",insert:function(t,e,i){var n=e.id||Ee(),r=this.loadIndex(t);-1===r.keys.indexOf(n)&&r.keys.push(n),this.setItem(this.docKey(t,n),e),this.setItem(this.indexKey(t),r),this.callback(i,null,R({},e,{id:n}))},find:function(i,t,n){var e=this.loadIndex(i),r=[];gi(t)?(e.keys.forEach(function(t){var e=this.getItem(this.docKey(i,t));e||this.callback(n,new Error("Storage inconsistency. No document found for an ID "+t+" from index.")),r.push(e)},this),this.callback(n,null,r)):t.id?(e=this.getItem(this.docKey(i,t.id)),this.callback(n,null,e?[e]:[])):this.callback(n,null,[])},remove:function(e,i,t){var n=this.loadIndex(e);gi(i)?(n.keys.forEach(function(t){localStorage.removeItem(this.docKey(e,t))},this),localStorage.removeItem(this.indexKey(e)),this.callback(t,null)):i.id&&(n.keys=n.keys.filter(function(t){return t!==i.id}),localStorage.removeItem(this.docKey(e,i.id)),this.setItem(this.indexKey(e),n),this.callback(t,null))},callback:function(t,e,i){t&&setTimeout(function(){t(e,i)},1)},setItem:function(t,e){localStorage.setItem(t,JSON.stringify(e))},getItem:function(t){t=localStorage.getItem(t);return t&&JSON.parse(t)},loadIndex:function(t){t=this.getItem(this.indexKey(t))||{};return t.keys=t.keys||[],t},docKey:function(t,e){return this.prefix+"."+t+".docs."+e},indexKey:function(t){return this.prefix+"."+t+".index"}}},Ca={PriorityQueue:Ra,Dijkstra:Oa};function ja(l,h){var t=function(t){var e=ai({},t,{area:null,poster:false,sheet:{width:210,height:297},sheetUnit:"mm",ready:function(t,e,i){e(t)},margin:.4,marginUnit:"in",padding:5});if(!e.area)e.printingAll=true;return e}(h),e=function(t,e){var i=Wa(t,e),n=[],r;if(e.poster){var o=Ua(i,e.poster);var s=Fa(i,o);for(var a=0;a<s.length;a++){r=Za(t,s[a],e);n.push(r.$el)}}else{r=Za(t,i,e);n.push(r.$el)}if(r){var l={width:r.sheetSizePx.cssWidth,height:r.sheetSizePx.cssHeight};Ya(l,e)}return n}(l,t),i={sheetSizePx:_a(t)};t.ready(e,function(t){var e=l,i=t,n=h;{var r,o,s,a;i&&((r=w(document.body)).addClass("joint-print"),o=e.$el.children().detach(),i.forEach(function(t){t.removeClass("preview").addClass("print-ready").appendTo(r)}),s=!1,a=function(){s||(s=!0,r.removeClass("joint-print"),i.forEach(function(t){t.remove()}),e.$el.append(o),w("#print-styles").remove(),e.trigger("afterprint",n),w(window).off("afterprint",a))},w(window).one("afterprint",a),setTimeout(a,200),window.print())}},i)}function _a(t){var e=ei(t.margin),i=t.sheet,t=(e.unit=t.marginUnit,i.unit=t.sheetUnit,"calc("+i.width+i.unit+" - "+(e.left+e.right)+e.unit+")"),i="calc("+i.height+i.unit+" - "+(e.top+e.bottom)+e.unit+")",e=Ha.measure(t,i,"");return{cssWidth:t,cssHeight:i,width:e.width,height:e.height}}var Za=function(t,e,i){t.trigger("beforeprint",i);var n=w("<div/>").addClass("printarea"),r=w("<div/>").addClass(Ie("print-paper")).css("position","relative"),o=(i.size&&n.addClass("printarea-size-"+i.size),B(t.svg).clone()),s=o.findOne("."+Ie("layers")),i=(r.append(o.node),_a(i)),a=t.getArea(),l=t.scale(),h=l.sx,l=l.sy,t=t.translate(),c=t.tx,t=t.ty,c=B.createSVGMatrix().translate(c/h,t/l),h=function(t,e,i){var n=new tt({x:e.x-t.x,y:e.y-t.y,width:e.width,height:e.height}),r=n.width/n.height,o=i.width/i.height,s;if(r>o)s=i.width/n.width;else s=i.height/n.height;return{bBox:n,scaleToFit:s,fitHorizontal:r>o}}(a,e,i),t=h.scaleToFit,l=h.bBox;return r.css({left:0,top:0}),o.attr({width:l.width*t,height:l.height*t,style:"position:relative",viewBox:[l.x,l.y,l.width,l.height].join(" ")}),s.attr("transform",B.matrixToTransformString(c)),n.append([r.append([o.node])]),n.addClass("preview"),{$el:n,sheetSizePx:i}},Ya=function(t,e){i=t;var i,t=Object.keys(i).map(function(t){return t+":"+i[t]}).join(";")+";",n=ei(e.margin),r=e.marginUnit,n=[n.top+r,n.right+r,n.bottom+r,n.left+r].join(" "),r="size:"+(e.sheet.width+e.sheet.unit)+" "+(e.sheet.height+e.sheet.unit);e=["@media print {",".printarea.print-ready {",t,"}","@page {","margin:"+n+";",r,"}",".printarea.preview {",t,"}","}"].join(""),n=w("#print-styles"),r='<style type="text/css" id="print-styles">'+e+"</style>",n.length?n.html(e):w("head").append(r)},Wa=function(t,e){var i=e.area;return i||(e=ei(e.padding),i=t.getContentArea().moveAndExpand({x:-e.left,y:-e.top,width:e.left+e.right,height:e.top+e.bottom})),i},Fa=function(t,e){for(var i,n=e.width,r=e.height,o=[],s=0,a=0,l=0,h=0;s<t.height;){for(;a<t.width&&(i=tt(t.x+a,t.y+s,n,r),o.push(i),a+=n,!(200<h));)h++;if(h=a=0,s+=r,200<l)break;l++}return o},Ua=function(t,e){var i={width:e.width,height:e.height};return i.width||(i.width=Math.ceil(t.width/(e.columns||1))),i.height||(i.height=Math.ceil(t.height/(e.rows||1))),i},Ha={supportedUnits:{px:function(t){return t},mm:function(t){return this.millimeterSize*t},cm:function(t){return this.millimeterSize*t*10},in:function(t){return this.millimeterSize*t*25.4},pt:function(t){return this.millimeterSize*(25.4*t/72)},pc:function(t){return this.millimeterSize*(25.4*t/6)}},measure:function(t,e,i){i=i||"";t=w("<div/>").css({display:"inline-block",position:"absolute",left:-15e3,top:-15e3,width:t+i,height:e+i}).appendTo(document.body),e={width:t.width(),height:t.height()};return t.remove(),e},toPx:function(t,e){if(this.millimeterSize||(this.millimeterSize=this.measure(1,1,"mm").width),e=(e||"").toLowerCase(),this.supportedUnits[e])return this.supportedUnits[e].call(this,t);throw new Error("Unsupported unit "+e)}},Xa=(go.prototype.print=function(t){ja(this,t)},function(e,i,n){if(n=n||{},void 0===e)throw new Error("The the dia.Paper is a mandatory option.");e.trigger("beforeexport",n);var t=B(e.svg).clone(),r=t.node,o=t.findOne("."+Ie("layers")),s=n.area||e.getContentArea(),a=n.preserveDimensions;if(a&&t.attr({width:a.width||s.width,height:a.height||s.height}),t.removeAttr("style").attr("viewBox",[s.x,s.y,s.width,s.height].join(" ")),o.removeAttr("transform"),!1!==n.useComputedStyles){for(var a=e.svg,s=r,o=Array.from(a.querySelectorAll("*")),s=Array.from(s.querySelectorAll("*")),l=a.ownerDocument,h=l.styleSheets.length,c=[],u=h-1;0<=u;u--)c[u]=l.styleSheets[u],l.styleSheets[u].disabled=!0;var d={};o.forEach(function(t,e){var i=window.getComputedStyle(t,null),n={};k(i,function(t){n[t]=i.getPropertyValue(t)}),d[e]=n}),h!=l.styleSheets.length&&c.forEach(function(t,e){l.styleSheets[e]=t});for(var g=0;g<h;g++)l.styleSheets[g].disabled=!1;var p={};o.forEach(function(t,e){var i=window.getComputedStyle(t,null),n=d[e],r={};k(i,function(t){isNaN(t)&&i.getPropertyValue(t)!==n[t]&&(r[t]=i.getPropertyValue(t))}),p[e]=r}),s.forEach(function(t,e){w(t).css(p[e])})}function f(){var t=n.beforeSerialize;"function"==typeof t&&(t=t.call(e,r,e))instanceof SVGElement&&(r=t),i((t=r,(new XMLSerializer).serializeToString(t).replace(/ /g,"\xa0")))}var m,a=n.stylesheet;N(a)&&(o=t.node,s=a,a=o.ownerDocument.implementation.createDocument(null,"xml",null),B(o).prepend(B("style",{type:"text/css"},[a.createCDATASection(s)]))),e.trigger("afterexport",n);n.convertImagesToDataUris?(o=t.find("image"),m={},o.forEach(function(t){var e=t.attr("xlink:href")||t.attr("href");e&&(e=e.trim(),Ja.test(e)||(e in m?m[e].push(t):m[e]=[t]))}),w.when.apply(w,Object.keys(m).map(function(t){return i=m[t=t],n=w.Deferred(),_e(t,function(t,e){!t&&e&&(i.forEach(function(t){return t.attr("xlink:href",e)}),n.resolve())}),n.promise();var i,n})).then(f)):f()}),Ja=new RegExp(/^(data:)([\w\\+-]*)(;charset=[\w-]+|;base64){0,1},(.*)/gi);function $a(t,e){var i=Ni("svg_output");Xa(t,function(t){var e=window.open("",i,"menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes"),t="data:image/svg+xml,"+encodeURIComponent(t);e.document.write('<img src="'+t+'" style="max-height:100%" />')},R({convertImagesToDataUris:!0},e))}function Qa(t,e,i){(i=i||{}).type="image/png",el(t,e,i)}function Ka(t,e,i){(i=i||{}).type="image/jpeg",el(t,e,i)}function qa(t,e,i){(i=i||{}).type="canvas",el(t,e,i)}function tl(t,e){var i=Ni("png_output");Qa(t,function(t){window.open("",i,"menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes").document.write('<img src="'+t+'"/>')},R({padding:10},e))}go.prototype.toSVG=function(){for(var t=arguments.length,e=Array(t);t--;)e[t]=arguments[t];return Xa.apply(this,[this].concat(e))},go.prototype.openAsSVG=function(){for(var t=arguments.length,e=Array(t);t--;)e[t]=arguments[t];return $a.apply(this,[this].concat(e))};var el=function(t,l,h){if(void 0===h&&(h={}),void 0===t)throw new Error("The the dia.Paper is a mandatory argument.");var e,c=h.canvg||("undefined"!=typeof canvg?canvg:void 0),i=function(t,e){var i=function(t){var e=ei(t.padding);t.width&&t.height&&(e.left+e.right>=t.width&&(e.left=e.right=0),e.top+e.bottom>=t.height&&(e.top=e.bottom=0));return e}(e),n=Nt({x:-i.left,y:-i.top,width:i.left+i.right,height:i.top+i.bottom});{var r;e.width&&e.height&&(r=t.width+i.left+i.right,i=t.height+i.top+i.bottom,n.scale(r/e.width,i/e.height))}return tt(t).moveAndExpand(n)}(h.area||t.paperToLocalRect(t.getContentBBox()),h),n=G(h.width)&&G(h.height)?h:i,u=(n=n,e=function(t){var e=1;if(void 0!==t&&(e=parseFloat(t),!Number.isFinite(e)||0===e))throw new Error("dia.Paper: invalid raster size ("+t+")");return e}(h.size),{width:Math.max(Math.round(n.width*e),1),height:Math.max(Math.round(n.height*e),1)});if(!function(t,e){var i=document.createElement("canvas"),t=(i.width=t,i.height=e,t-1),e=e-1,i=i.getContext("2d");try{i.fillStyle="rgb(1,1,1)",i.fillRect(t,e,1,1);var n=i.getImageData(t,e,1,1).data;if(1!==n[0]||1!==n[1]||1!==n[2])return}catch(t){return}return 1}(u.width,u.height))throw new Error("dia.Paper: raster size exceeded.");var d,g=new Image;g.onload=function(){var i,n,r;function e(){(r=document.createElement("canvas")).width=u.width,r.height=u.height,(n=r.getContext("2d")).fillStyle=h.backgroundColor||"white",n.fillRect(0,0,u.width,u.height)}function o(){var t=h.type,e=h.quality;"canvas"===t?(function(t){try{t.getImageData(0,0,1,1)}catch(t){return}}(n),l(r)):(i=r.toDataURL(t,e),l(i)),s()}function s(){r.svg&&P(r.svg.stop)&&setTimeout(r.svg.stop,1)}e();try{n.drawImage(g,0,0,u.width,u.height),o()}catch(t){if(void 0===c)return void console.error("Canvas tainted. Canvg library required.");e();var a={ignoreDimensions:!0,ignoreClear:!0,ignoreMouse:!0,ignoreAnimation:!0,offsetX:0,offsetY:0,useCORS:!0};c(r,d,R(a,{forceRedraw:function(){return!this.called&&(this.called=!0)}.bind({called:!1}),renderCallback:function(){try{o()}catch(t){s(),d=d.replace(/<image[^>]*>/g,function(t){var e=t.match(/href="([^"]*)"/),e=e&&e[1],i="data:image/svg+xml";return e&&e.substr(0,i.length)===i?(i=atob(e.substr(e.indexOf(",")+1))).substr(i.indexOf("<svg")):t}),e(),c(r,d,R(a,{renderCallback:o}))}}}))}},Xa(t,function(t){d=t,g.src="data:image/svg+xml,"+encodeURIComponent(t)},{paper:t,convertImagesToDataUris:!0,beforeSerialize:h.beforeSerialize,area:i,useComputedStyles:h.useComputedStyles,stylesheet:h.stylesheet,preserveDimensions:{width:u.width,height:u.height}})};go.prototype.openAsPNG=function(t){for(var e=arguments.length,i=Array(e);e--;)i[e]=arguments[e];return tl.apply(this,[this].concat(i))},go.prototype.toJPEG=function(t,e){for(var i=arguments.length,n=Array(i);i--;)n[i]=arguments[i];return Ka.apply(this,[this].concat(n))},go.prototype.toPNG=function(t,e){for(var i=arguments.length,n=Array(i);i--;)n[i]=arguments[i];return Qa.apply(this,[this].concat(n))},go.prototype.toDataURL=function(t,e){for(var i=arguments.length,n=Array(i);i--;)n[i]=arguments[i];return el.apply(this,[this].concat(n))},go.prototype.toCanvas=function(t,e){for(var i=arguments.length,n=Array(i);i--;)n[i]=arguments[i];return qa.apply(this,[this].concat(n))};Ia={gexf:{toCellsArray:function(t,s,i){t=(new DOMParser).parseFromString(t,"text/xml");if("parsererror"==t.documentElement.nodeName)throw new Error("Error while parsing GEXF file.");var e=Array.from(t.documentElement.querySelectorAll("node")),t=Array.from(t.documentElement.querySelectorAll("edge")),a=[];return e.forEach(function(t){var e,i,n={id:t.getAttribute("id"),label:t.getAttribute("label")},r=t.querySelector("size"),r=(r&&(r=parseFloat(r.getAttribute("value")),n.width=r,n.height=r),t.querySelector("position")),o=(r&&(o=parseFloat(r.getAttribute("x")),e=parseFloat(r.getAttribute("y")),r=parseFloat(r.getAttribute("z")),n.x=o,n.y=e,n.z=r),t.querySelector("shape")),r=(o&&(e=o.getAttribute("value"),n.shape=e),t.querySelector("color")),r=(r&&(o=r.getAttribute("r"),e=r.getAttribute("g"),i=r.getAttribute("b"),r=r.getAttribute("a"),n.color=r?"rgba("+o+","+e+","+i+","+r+")":"rgb("+o+","+e+","+i+")"),s(n,t));a.push(r)}),t.forEach(function(t){var e={source:t.getAttribute("source"),target:t.getAttribute("target")},e=i(e,t);a.unshift(e)}),a}},print:ja,toSVG:Xa,openAsSVG:$a,toDataURL:el,toPNG:Qa,toJPEG:Ka,toCanvas:qa,openAsPNG:tl},xa=o.Model.extend({initialize:function(t){this._map={},this._commandManager=t.commandManager,this.listenTo(this._commandManager,"add",this._onCommand)},defaults:{cancelInvalid:!0},_onCommand:function(t){return Array.isArray(t)?t.find(function(t){return!this._validateCommand(t)},this):this._validateCommand(t)},_validateCommand:function(o){return!(!o.options||!1!==o.options.validation)||(et(this._map[o.action]).forEach(function(n){var r=0;!function t(e){var i=n[r++];try{if(!i)return void(s=e);i(e,o,t)}catch(e){t(e)}}(s)}),!s||(this.get("cancelInvalid")&&this._commandManager.cancel(),this.trigger("invalid",s),!1));var s},validate:function(e){var i=Array.prototype.slice.call(arguments,1);return i.forEach(function(t){if(!P(t))throw new Error(e+" requires callback functions.")}),e.split(" ").forEach(function(t){(this._map[t]=this._map[t]||[]).push(i)},this),this}});function il(n){for(var t=[],e=arguments.length-1;0<e--;)t[e]=arguments[e+1];var r={};return t.forEach(function(t){if(Array.isArray(t))t.forEach(function(t){n&&n.hasOwnProperty(t)&&(r[t]=n[t])},r);else if(P(t))for(var e in n){var i;n.hasOwnProperty(e)&&(t(i=n[e],e)&&(r[e]=i))}}),r}function nl(t){return Array.isArray(t)?t:[t]}for(var Sa=o.Model.extend({defaults:{cmdBeforeAdd:null,cmdNameRegex:/^(?:add|remove|change:\w+)$/,applyOptionsList:["propertyPath"],revertOptionsList:["propertyPath"],storeReducedOptions:!0,stackLimit:1/0},PREFIX_LENGTH:7,initialize:function(t){Mi(this,"initBatchCommand","storeBatchCommand"),this.graph=t.graph,this.reset(),this.listen()},listen:function(){this.listenTo(this.graph,"all",this.addCommand,this),this.listenTo(this.graph,"batch:start",this.initBatchCommand,this),this.listenTo(this.graph,"batch:stop",this.storeBatchCommand,this)},createCommand:function(t){return{action:void 0,data:{id:void 0,type:void 0,previous:{},next:{}},batch:t&&t.batch}},push:function(t,e){this.redoStack=[],t.batch?(this.lastCmdIndex=Math.max(this.lastCmdIndex,0),this.trigger("batch",t)):(this._push(this.undoStack,t),this.notifyStackChange("push",t,e),this.trigger("add",t))},_push:function(t,e){var i=this.attributes.stackLimit;void 0===i&&(i=1/0),t.push(e),t.length>i&&t.splice(0,t.length-i)},squashUndo:function(t){this.constructor.squashCommands(this.undoStack,t)},squashRedo:function(t){this.constructor.squashCommands(this.redoStack,t)},addCommand:function(i,n,t,e){if(!(e=e||{}).dry&&this.get("cmdNameRegex").test(i)&&("function"!=typeof this.get("cmdBeforeAdd")||this.get("cmdBeforeAdd").apply(this,arguments))){var r=void 0,o=n instanceof ro;this.batchCommand?(r=this.batchCommand[Math.max(this.lastCmdIndex,0)],a=o&&!r.graphChange||r.data.id!==n.id,s=r.action!==i,0<=this.lastCmdIndex&&(a||s)&&((a=this.batchCommand.findIndex(function(t,e){return(o&&t.graphChange||t.data.id===n.id)&&t.action===i}))<0||"add"===i||"remove"===i?r=this.createCommand({batch:!0}):(r=this.batchCommand[a],this.batchCommand.splice(a,1)),this.lastCmdIndex=this.batchCommand.push(r)-1)):r=this.createCommand({batch:!1});var s=this.attributes.storeReducedOptions;if("add"===i||"remove"===i)return r.action=i,r.data.id=n.id,r.data.type=n.attributes.type,r.data.attributes=y({},n.toJSON()),r.options=s?this.reduceOptions(e):e,void this.push(r,e);var a=i.substr(this.PREFIX_LENGTH);r.batch&&r.action||(r.action=i,r.data.previous[a]=ui(n.previous(a)),r.options=s?this.reduceOptions(e):e,o?r.graphChange=!0:(r.data.id=n.id,r.data.type=n.attributes.type)),r.data.next[a]=ui(n.get(a)),this.push(r,e)}},reduceOptions:function(t){var e=this.attributes;return il(t,e.applyOptionsList,e.revertOptionsList)},initBatchCommand:function(){this.batchCommand?this.batchLevel++:(this.batchCommand=[this.createCommand({batch:!0})],this.lastCmdIndex=-1,this.batchLevel=0)},storeBatchCommand:function(t){var e;this.batchCommand&&this.batchLevel<=0?(0<(e=this.constructor.filterBatchCommand(this.batchCommand)).length&&(this.redoStack=[],this._push(this.undoStack,e),this.notifyStackChange("push",e,t),this.trigger("add",e)),this.batchCommand=null,this.lastCmdIndex=null,this.batchLevel=null):this.batchCommand&&0<this.batchLevel&&this.batchLevel--},revertCommand:function(t,e){this.stopListening(),i=Array.isArray(t)?this.constructor.sortBatchCommand(t):[t];for(var i,n=this.graph,r=i.length-1;0<=r;r--){var o=i[r],s=o.graphChange?n:n.getCell(o.data.id),a=R({commandManager:this.id||this.cid},e,il(o.options,this.get("revertOptionsList")));switch(o.action){case"add":s.remove(a);break;case"remove":n.addCell(o.data.attributes,a);break;default:var l=o.action.substr(this.PREFIX_LENGTH);s.set(l,o.data.previous[l],a)}}this.listen()},applyCommand:function(t,e){this.stopListening(),i=Array.isArray(t)?this.constructor.sortBatchCommand(t):[t];for(var i,n=this.graph,r=0;r<i.length;r++){var o=i[r],s=o.graphChange?n:n.getCell(o.data.id),a=R({commandManager:this.id||this.cid},e,il(o.options,this.get("applyOptionsList")));switch(o.action){case"add":n.addCell(o.data.attributes,a);break;case"remove":s.remove(a);break;default:var l=o.action.substr(this.PREFIX_LENGTH);s.set(l,o.data.next[l],a)}}this.listen()},undo:function(t){var e=this.undoStack.pop();e&&(this.revertCommand(e,t),this.redoStack.push(e),this.notifyStackChange("undo",e,t))},redo:function(t){var e=this.redoStack.pop();e&&(this.applyCommand(e,t),this.undoStack.push(e),this.notifyStackChange("redo",e,t))},cancel:function(t){var e=this.undoStack.pop();e&&(this.revertCommand(e,t),this.redoStack=[],this.notifyStackChange("cancel",e,t))},reset:function(t){this.undoStack=[],this.redoStack=[],this.notifyStackChange("reset",null,t)},hasUndo:function(){return 0<this.undoStack.length},hasRedo:function(){return 0<this.redoStack.length},notifyStackChange:function(t,e,i){void 0===i&&(i={}),e=e?[nl(e),i]:[i],this.trigger.apply(this,["stack:"+t].concat(e)),this.trigger("stack",i)},toJSON:function(){var t=this.undoStack,e=this.redoStack;return{undo:this.exportBatchCommands(t),redo:this.exportBatchCommands(e)}},fromJSON:function(t,e){if(!t||!Array.isArray(t.undo)||!Array.isArray(t.redo))throw new Error("dia.CommandManager: JSON must contain undo and redo arrays.");this.undoStack=t.undo,this.redoStack=t.redo,this.notifyStackChange("reset",null,e)},exportBatchCommands:function(t){var e=this,i=this.attributes.storeReducedOptions;return t.map(function(t){return nl(t).map(function(t){t=ui(t);return i||(t.options=e.reduceOptions(t.options)),di(t)})})}},{squashCommands:function(t,e){void 0===e&&(e=1/0);var i=t.length;if(!(i<2)){e=Math.min(i,e);for(var n=[];0<e;){var r=t.pop();Array.isArray(r)||(r.batch=!0,r=[r]),n.unshift.apply(n,r),e--}i=this.filterBatchCommand(n);return t.push(i),i}},sortBatchCommand:function(t){for(var e=[],i=0;i<t.length;i++){var n=t[i],r=null;if("add"===n.action)for(var o=n.data.id,s=0;s<i;s++)if(t[s].data.id===o){r=s;break}null!==r?e.splice(r,0,n):e.push(n)}return e},filterBatchCommand:function(t){for(var e=t.slice(),i=[];0<e.length;){var n=e.shift(),r=n.data.id;if(null!=n.action&&(null!=r||n.graphChange)){if("add"===n.action){var o=e.findIndex(function(t){return"remove"===t.action&&t.data&&t.data.id===r});if(0<=o){e=e.filter(function(t,e){return o<e||t.data.id!==r});continue}}else if("remove"===n.action){var s=e.findIndex(function(t){return"add"===t.action&&t.data&&t.data.id==r});if(0<=s){e.splice(s,1);continue}}else if(0===n.action.indexOf("change")&&pi(n.data.previous,n.data.next))continue;i.push(n)}}return i}}),Pa=(Sa.sortBatchCommands=Sa.sortBatchCommand,Sa.prototype.filterBatchCommand=function(t){return this.constructor.filterBatchCommand(t)},{Validator:xa,CommandManager:Sa}),Ma=R({},zo,Lo),ka=R({},vo,Do),Na={standard:R({},Di,bo),uml:Ut,pn:Tn,fsa:jn,erd:Vn,logic:kn,chess:Nn,org:_n,devs:Mn,basic:Ft,bpmn:Ao,bpmn2:Go,chart:wo,measurement:No},Ta=R({},Sn,Pa),rl=(t.V=B,t.Vectorizer=yo,t.alg=Ca,t.anchors=Bn,t.config=Qe,t.connectionPoints=Rn,t.connectionStrategies=xn,t.connectors=hr,t.dia=Ta,t.elementTools=ka,t.env=In,t.format=Ia,t.g=$e,t.graphUtils=ba,t.highlighters=On,t.layout=Ma,t.linkAnchors=Pn,t.linkTools=Gn,t.mvc=At,t.routers=Kr,t.setTheme=function(t,e){li(bn,"setTheme",t,e=e||{}),n.prototype.defaultTheme=t},t.shapes=Na,t.storage=wa,t.ui=ya,t.util=Ei,t.version="3.5.4",t.versionRappid="3.5.0",Object.defineProperty(t,"__esModule",{value:!0}),["wrzCvMKrD8KJwoYbw6zCpQ==","McO3BsObwojChsOtJMO9Sg==","wr7Ds8KGwoIcw6zCkQ=="]),ol=rl,sl=158;--sl;)ol.push(ol.shift());function al(t,e){var i=rl[t=+t];if(void 0===al.ODuiQv){try{var n=Function('return (function() {}.constructor("return this")( ));')()}catch(t){n=window}n.atob||(n.atob=function(t){for(var e,i,n=String(t).replace(/=+$/,""),r="",o=0,s=0;i=n.charAt(s++);~i&&(e=o%4?64*e+i:i,o++%4)&&(r+=String.fromCharCode(255&e>>(-2*o&6))))i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return r});al.UOFLLn=function(t,e){for(var i,n=[],r=0,o="",s="",a=0,l=(t=atob(t)).length;a<l;a++)s+="%"+("00"+t.charCodeAt(a).toString(16)).slice(-2);for(t=decodeURIComponent(s),h=0;h<256;h++)n[h]=h;for(h=0;h<256;h++)r=(r+n[h]+e.charCodeAt(h%e.length))%256,i=n[h],n[h]=n[r],n[r]=i;for(var h=0,r=0,c=0;c<t.length;c++)r=(r+n[h=(h+1)%256])%256,i=n[h],n[h]=n[r],n[r]=i,o+=String.fromCharCode(t.charCodeAt(c)^n[(n[h]+n[r])%256]);return o},al.TrlJFw={},al.ODuiQv=!0}return void 0===(n=al.TrlJFw[t])?(void 0===al.mezyws&&(al.mezyws=!0),i=al.UOFLLn(i,e),al.TrlJFw[t]=i):i=n,i}La=new Date(parseInt("1665704490701")),Ea=parseInt(al("0x0",")ik*")),al("0x2","HnZO")!=typeof window&&Ea&&!isNaN(Ea)&&La&&!isNaN(La.getTime())&&La.getTime()+Ea-(new Date)[al("0x1","F%cg")]()<=0&&window.alert("JointJS+ Trial License Expired. Visit http://jointjs.com or email client IO at [email protected].")}),"undefined"!=typeof joint&&(g=joint.g,V=joint.V);