UNPKG

@balkangraph/familytree2.js

Version:

Build family tree app with BALKAN FamilyTree JS library. Family Tree also called a genealogy or a pedigree chart, is a chart representing family relationships in a conventional tree structure.

1 lines 284 kB
/* eslint-disable */ var FlowChart=class{_;options;element;svgElement;shapeBar;colorBar;menuBar;statusBar;editor;nodes;labels;links;ports;selectedShapes;active;get useChangeListener(){return this._.useChangeListener}set useChangeListener(t){this._.useChangeListener=t}get defs(){return this.svgElement.querySelector("defs").innerHTML}set defs(t){this.svgElement.querySelector("defs").innerHTML=t}get mode(){return this.options.mode}set mode(t){this.options.mode=t,this.element.classList.remove("bfc-dark"),this.element.classList.remove("bfc-light"),this.element.classList.add("bfc-"+this.options.mode),this.svgElement.classList.remove("bfc-dark"),this.svgElement.classList.remove("bfc-light"),this.svgElement.classList.add("bfc-"+this.options.mode)}get viewBox(){return this._.getViewBox()}set viewBox(t){this._.snap(),this._.setViewBox(t),this._.changed({property:"viewBox"})}get selectedPortShape(){return this._.selectedPortShape}set selectedPortShape(t){null==t?(this._.selectedPortShape=null,null!=this.selectedPort&&(this.selectedPort=null),this._.hidePortsUI()):t!=this._.selectedPortShape&&(this._.selectedPortShape=t,this._.showPortsUI())}get selectedPort(){return this._.selectedPort}set selectedPort(t){if(this._.selectedPort!=t){var e={oldPort:this._.selectedPort,newPort:t};!1!==FlowChart.events.publish("selected-port-change",[this._.chart,e])&&(null==t?(this._.selectedPort=null,this._.hidePortShapeBarUI()):this._.selectedPort!=t&&(this.selectedPortShape!=t.shape&&(this.selectedPortShape=t.shape),this._.selectedPort=t,this._.showPortShapeBar()))}}get scale(){return this._.getScale()}set scale(t){if(this.scale!=t){var e=FlowChart.private.getViewBoxByScale(t,this.options,this.viewBox,this._.svgBCR);this.viewBox=e}}static MAGNET_MOVE_PIXELS=10;static MAGNET_RESIZE_PIXELS=7;static MAGNET_WIN_PIXELS=10;static MAGNET_PORT=20;static LINK_DITSNANCE=20;static LINK_ROUNDED_CORENERS=7;static MOVE_NODE_STEP=3;static SCALE_FACTOR=1.44;static DEFAULT_LINK_SHAPE_ID="rounded";static DEFAULT_LABEL_SHAPE_ID="label";static CHANGED_TIMEOUT=700;static PADDING=30;static SEPARATOR=":";static PORTSEPARATOR="~";static shortcuts={open_up_port:{keysPressed:["control","!shift","arrowup"],activeComponentType:"node|port-shape-bar|field",desc:"Open port above the shape"},open_down_port:{keysPressed:["control","!shift","arrowdown"],activeComponentType:"node|port-shape-bar|field",desc:"Open port below the shape"},open_left_port:{keysPressed:["control","!shift","arrowleft"],activeComponentType:"node|port-shape-bar|field",desc:"Open left port"},open_right_port:{keysPressed:["control","!shift","arrowright"],activeComponentType:"node|port-shape-bar|field",desc:"Open right port"},navigate_port_down:{keysPressed:["!control","!shift","arrowdown"],activeComponentType:"port-shape-bar",desc:"Select shape from the opened port shape bar"},navigate_port_left:{keysPressed:["!control","!shift","arrowleft"],activeComponentType:"port-shape-bar",desc:"Select shape from the opened port shape bar"},navigate_port_right:{keysPressed:["!control","!shift","arrowright"],activeComponentType:"port-shape-bar",desc:"Select shape from the opened port shape bar"},navigate_port_up:{keysPressed:["!control","!shift","arrowup"],activeComponentType:"port-shape-bar",desc:"Select shape from the opened port shape bar"},undo:{keysPressed:["control","keyz"],desc:"Undo"},redo:{keysPressed:["control","keyy"],desc:"Redo"},select_all_nodes:{keysPressed:["control","keya"],desc:"Selectd all nodes"},select_multiple_nodes:{keysPressed:["shift"],desc:"Selectd multiple nodes or shapes"},resize_node:{mouseActions:["resize-shape"],desc:"Resize shape"},centered_resize_shape:{keysPressed:["control"],mouseActions:["resize-shape"],desc:"Centered resize"},maintain_aspect_ratio_resize_shape:{keysPressed:["shift"],mouseActions:["resize-shape"],activeComponentType:"shape",desc:"Resize and maintain proportions"},remove_selected_shapes:{keysPressed:["delete|backspace"],activeComponentType:"shape",desc:"Remove selected shapes"},zoom:{keysPressed:["control"],mouseActions:["wheel"],desc:"Zoom In/Out"},move_selected_nodes_left:{keysPressed:["arrowleft","control","shift"],desc:"Move selected nodes with arrow keys"},move_selected_nodes_right:{keysPressed:["arrowright","control","shift"],desc:"Move selected nodes with arrow keys"},move_selected_nodes_up:{keysPressed:["arrowup","control","shift"],desc:"Move selected nodes with arrow keys"},move_selected_nodes_down:{keysPressed:["arrowdown","control","shift"],desc:"Move selected nodes with arrow keys"},select_node_left:{keysPressed:["arrowleft","!control","!shift"],activeComponentType:"node",desc:"Select the closest node on the left"},select_node_right:{keysPressed:["arrowright","!control","!shift"],activeComponentType:"node",desc:"Select the closest node on the right"},select_node_above:{keysPressed:["arrowup","!control","!shift"],activeComponentType:"node",desc:"Select the closest node on the top"},select_node_below:{keysPressed:["arrowdown","!control","!shift"],activeComponentType:"node",desc:"Select the closest node on the bottom"},select_nodes_left:{keysPressed:["arrowleft","!control","shift"],activeComponentType:"node",desc:"Select multiple nodes"},select_nodes_right:{keysPressed:["arrowright","!control","shift"],activeComponentType:"node",desc:"Select multiple nodes"},select_nodes_above:{keysPressed:["arrowup","!control","shift"],activeComponentType:"node",desc:"Select multiple nodes"},select_nodes_below:{keysPressed:["arrowdown","!control","shift"],activeComponentType:"node",desc:"Select multiple nodes"},align_tofirst_selected_nodes_top:{keysPressed:["keyt","!shift"],activeComponentType:"node",desc:"Align top to the first selected node"},align_tofirst_selected_nodes_bottom:{keysPressed:["keyb","!shift"],activeComponentType:"node",desc:"Align bottom to the first selected node"},align_tofirst_selected_nodes_left:{keysPressed:["keyl","!shift"],activeComponentType:"node",desc:"Align left to the first selected node"},align_tofirst_selected_nodes_right:{keysPressed:["keyr","!shift"],activeComponentType:"node",desc:"Align right to the first selected node"},align_tofirst_selected_nodes_horizontally:{keysPressed:["keye","!shift"],activeComponentType:"node",desc:"Align center horizontally to the first selected node"},align_tofirst_selected_nodes_vertically:{keysPressed:["keyc","!shift"],activeComponentType:"node",desc:"Align center vertically to the first selected node"},align_tolast_selected_nodes_top:{keysPressed:["keyt","shift"],activeComponentType:"node",desc:"Align top to the last selected node"},align_tolast_selected_nodes_bottom:{keysPressed:["keyb","shift"],activeComponentType:"node",desc:"Align bottom to the last selected node"},align_tolast_selected_nodes_left:{keysPressed:["keyl","shift"],activeComponentType:"node",desc:"Align left to the last selected node"},align_tolast_selected_nodes_right:{keysPressed:["keyr","shift"],activeComponentType:"node",desc:"Align right to the last selected node"},align_tolast_selected_nodes_horizontally:{keysPressed:["keye","shift"],activeComponentType:"node",desc:"Align center horizontally to the last selected node"},align_tolast_selected_nodes_vertically:{keysPressed:["keyc","shift"],activeComponentType:"node",desc:"Align center vertically to the last selected node"},paint_node:{keysPressed:["digit1|digit2|digit3|digit4|digit5|digit6|digit7|digit8|digit9|numpad1|numpad2|numpad3|numpad4|numpad5|numpad6|numpad7|numpad8|numpad9"],activeComponentType:"node",desc:"Change color"},add_shape:{keysPressed:["enter"],activeComponentType:"port-shape-bar",desc:"Add node"},edit_next_field:{keysPressed:["tab"],activeComponentType:"field",desc:"Focus next field"},exit_edit_field:{keysPressed:["escape"],activeComponentType:"field",desc:"Finish editing"},close_port_shape_bar:{keysPressed:["escape"],activeComponentType:"port-shape-bar",desc:"Hide port shape bar"},deleselect_shapes:{keysPressed:["escape"],activeComponentType:"shape",desc:"Unselect shapes"},edit_shape:{keysPressed:["enter|numpadenter|space"],activeComponentType:"shape",desc:"Edit shape"},fit_to_page:{keysPressed:["keyf"],activeComponentType:"all-nodes",desc:"Fit to page"},replace_div_with_br_on_enter:{keysPressed:["enter|numpadenter"],activeComponentType:"field",desc:""}};static isNEU(t){return null==t||""===t}static isMobile=function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)};static animate=function(t,e,i,r,a,o,s){return FlowChart.private.animate(t,e,i,r,a,o,s)};constructor(t,e){("string"==typeof t||t instanceof String)&&(t=document.querySelector(t)),this.options=FlowChart.private.mergeDeep(FlowChart.private.defaultOptions(),e),this.element=t,this.svgElement=null,this.shapeBar=new FlowChart.ShapeBar(this),this.colorBar=new FlowChart.ColorBar(this),this.menuBar=new FlowChart.MenuBar(this),this.statusBar=new FlowChart.StatusBar(this),this.selectedShapes=new FlowChart.SelectedShapeCollection(this),this.editor=new FlowChart.Editor(this),this.ports=new FlowChart.PortCollection(this),this.nodes=new FlowChart.ShapeCollection(this),this.links=new FlowChart.LinkCollection(this),this.labels=new FlowChart.ShapeCollection(this),this.active=null,this._=new FlowChart.private(this),FlowChart.events.publish("init",[this])}addNodeWithLink(t,e,i){this._.addNodeWithLink(t,e,i)}load(t){this._.load(t)}json(t){return this._.json(t)}text(t){return this._.text(t)}svg(){return this._.svg()}exportSVG(){var t=new Blob([this.svg()],{type:"image/svg+xml"});FlowChart.private.downloadFile(t,"flowchart.svg",!1,"svg")}getShape(t){return this._.getShape(t)}generateId(){return this._.generateId()}undo(){this._.undo()}redo(){this._.redo()}undoStepsCount(){return this._.undoStepsCount()}redoStepsCount(){return this._.redoStepsCount()}clearRedo(){this._.clearRedo()}clearUndo(){this._.clearUndo()}alignShapes(t,e,i){this._.alignShapes(t,e,i)}reposition(t,e,i,r){this._.reposition(t,e,i,r)}rippleShape(t,e,i){FlowChart.private.rippleShape(t,e,i)}makeShapesVisible(t,e){this._.makeShapesVisible(t,e)}destroy(){if(FlowChart.events.topics={},this.element){this.element.innerHTML="";var t=this.element.cloneNode(!0);this.element.parentNode.replaceChild(t,this.element),this.element=t}}onInit(t){return this._.on("init",(function(e,i){return t.call(e,i)}))}onChanged(t){return this._.on("changed",(function(e,i){return t.call(e,i)}))}onUndoRedoChanged(t){return this._.on("undo-redo-changed",(function(e,i){return t.call(e,i)}))}onSelectedShapeChanging(t){return this._.on("selected-shape-changing",(function(e,i){return t.call(e,i)}))}onSelectedShapesChanged(t){return this._.on("selected-shapes-changed",(function(e,i){return t.call(e,i)}))}onSelectedPortChange(t){return this._.on("selected-port-change",(function(e,i){return t.call(e,i)}))}onShortcut(t){return this._.on("shortcut",(function(e,i){return t.call(e,i)}))}onMenuItemClick(t){return this._.on("menu-item-click",(function(e,i){return t.call(e,i)}))}onLinkPoints(t){return this._.on("link-points",(function(e,i){return t.call(e,i)}))}onLinkClick(t){return this._.on("link-click",(function(e,i){return t.call(e,i)}))}onShapeDoubleClick(t){return this._.on("shape-db-click",(function(e,i){return t.call(e,i)}))}onShapeClick(t){return this._.on("shape-click",(function(e,i){return t.call(e,i)}))}onSvgClick(t){return this._.on("svg-click",(function(e,i){return t.call(e,i)}))}onFieldChange(t){return this._.on("field-change",(function(e,i){return t.call(e,i)}))}};void 0===FlowChart&&(FlowChart={}),FlowChart.VERSION="1.01.74","undefined"!=typeof module&&(module.exports=FlowChart),FlowChart.private=class{chart;mouseActions;keysPressed;mouseOverShape;mouseOverShapeType;touchendEnabledDevice;uid;useChangeListener;initialized;changedTimeout;changedArgs;selectedPortShape;selectedPort;lastAddedTemplateIdFormPortShapeBar;changeFillPressedIndexes;changeFillPressedTimeout;makeShapesVisibleInterval;svgBCR;shortcuts;static defaultOptions(){return{mode:"light",startPosition:FlowChart.startPosition.center,startScale:1,interactive:!0,loadFromSession:!1,useSession:!0,statusBar:!0,colors:["#039BE5","#F57C00","#FFCA28"],scaleMax:4,scaleMin:.5,selectable:!0,editable:!0,nodeSeparation:100,zoom:{speed:120,smooth:12}}}static countFlowCharts=0;constructor(t){this.chart=t,this.shortcuts=JSON.parse(FlowChart.private.safeStringify(FlowChart.shortcuts)),this.mouseActions=[],this.keysPressed=[],this.matchedShortcuts=[],this.mouseOverShape=null,this.mouseOverShapeType=null,this.touchendEnabledDevice=!1,this.useChangeListener=!0,this.initialized=!1,this.changedTimeout=null,this.changedArgs={properties:[]},this.selectedPortShape=null,this.selectedPort=null,this.uid=window.location.pathname+"/flow-chart/"+FlowChart.private.countFlowCharts,FlowChart.private.countFlowCharts++,this.changeFillPressedIndexes=[],this.changeFillPressedTimeout=null,this.makeShapesVisibleInterval=null,this.init()}snap(){this.useChangeListener&&(this.changedTimeout||(this.putInUndoStack(),this.clearRedo()))}addNodeWithLink(t,e,i){var r=this,a={templateId:e};(a=this.chart.nodes.add(a)).element.style.opacity=0;var o=this.chart.links.getByShape(t.shape),s=[];for(var h of o)this.chart.ports.getByLink(h).fromPort==t&&(n=this.chart.nodes.get(h.to))&&s.push(n.id);var l=[];for(var n of this.chart.nodes)l.push({x:n.x,y:n.y,w:n.width,h:n.height,id:n.id});FlowChart.private.devin({nodeDiscriptors:l,neighborNodeIds:s,newNodeId:a.id,parentNodeId:t.shape.id,position:t.position,options:this.chart.options},(function(e){var o=[],s=[],h=[],l=r.chart.scale;for(var n of e){var d=r.chart.nodes.get(n.id),p={x:n.x,y:n.y,opacity:1};if(a==d){var c={x:n.x,y:n.y,opacity:0};switch(t.position){case FlowChart.position.left:c.x+=8/l;break;case FlowChart.position.right:c.x-=8/l;break;case FlowChart.position.top:c.y+=8/l;break;case FlowChart.position.bottom:c.y-=8/l;break;case FlowChart.position.topLeft:c.y+=8/l,c.x+=8/l;break;case FlowChart.position.bottomLeft:c.y-=8/l,c.x+=8/l;break;case FlowChart.position.bottomRight:c.y-=8/l,c.x-=8/l;break;case FlowChart.position.topRight:c.y+=8/l,c.x-=8/l}s.push(c)}else s.push({x:d.x,y:d.y,opacity:0});h.push(p),d.x=-1e4,d.y=-1e4,o.push(d)}for(var f=0;f<o.length;f++)o[f].x=s[f].x,o[f].y=s[f].y;r.animateShapes(o,s,h,(function(){i&&i.call(r.chart,a,m),r.makeShapesVisible([o],(function(){var t=r.chart.editor.getFieldNames(a);t.length&&r.chart.editor.edit(a,t[0])}))}));var u=r.chart.ports.getByOpositeOfPosition(a.id,t.position)[0],m={from:t.shape.id,to:u.shape.id,fromPort:t.id,toPort:u.id,templateId:"rounded"};m=r.chart.links.add(m)}))}changed(t){if(this.useChangeListener){var e=this;for(var i in t){var r=t[i];(i="property")&&-1==this.changedArgs.properties.indexOf(r)&&this.changedArgs.properties.push(r)}"selectedShapes"==t.property&&(FlowChart.events.publish("selected-shapes-changed",[e.chart]),this.chart.editor.clearFieldBorders()),this.changedTimeout&&(clearTimeout(this.changedTimeout),this.changedTimeout=null),this.changedTimeout=setTimeout((function(){e.changedTimeout=null;var t=e.chart.text(["shapes","links","viewBox","selectedShapes"]);if(e.chart.options.useSession)try{sessionStorage.setItem(`${e.uid}_state`,t)}catch(t){t.code==t.QUOTA_EXCEEDED_ERR&&sessionStorage.clear(),console.error(t)}FlowChart.events.publish("changed",[e.chart,e.changedArgs]),e.changedArgs={properties:[]}}),FlowChart.CHANGED_TIMEOUT)}}load(t){if(this.useChangeListener=!1,this.chart.nodes.clear(),this.chart.labels.clear(),this.chart.links.clear(),!this.initialized&&this.chart.options.loadFromSession){var e=sessionStorage.getItem(`${this.uid}_state`);e&&(t=JSON.parse(e))}if(t){if(t.nodes&&this.chart.nodes.addRange(t.nodes),t.links&&this.chart.links.addRange(t.links),t.labels&&this.chart.labels.addRange(t.labels),t.selectedShapes)for(var i of t.selectedShapes){var r=this.chart.getShape(i);r&&(r.selected=!0)}t.viewBox&&(this.setViewBox(t.viewBox),this.initialized=!0)}this.initialized||(this.chart.scale=this.chart.options.startScale,this.chart.reposition(),this.initialized=!0),this.useChangeListener=!0;var a=this.chart.text(["shapes","links","viewBox","selectedShapes"]);if(this.chart.options.useSession)try{sessionStorage.setItem(`${this.uid}_state`,a)}catch(t){t.code==t.QUOTA_EXCEEDED_ERR&&sessionStorage.clear(),console.error(t)}}alignShapes(t,e,i){if(t.length){this.chart.selectedPortShape=null,t.length;var r=t[t.length-1];i&&(t.length,r=t[0]);for(var a=0;a<t.length;a++){var o=t[a];e==FlowChart.position.top?o.y=r.y-r.height/2+o.height/2:e==FlowChart.align.bottom?o.y=r.y+r.height/2-o.height/2:e==FlowChart.align.left?o.x=r.x-r.width/2+o.width/2:e==FlowChart.align.right?o.x=r.x+r.width/2-o.width/2:e==FlowChart.align.vertically?o.x=r.x:e==FlowChart.align.horizontally&&(o.y=r.y)}}}getShape(t){var e=this.chart.nodes.get(t);return e||(e=this.chart.labels.get(t)),e}generateId(){for(var t=this.chart.nodes.length+this.chart.labels.length;;){if(!this.chart.nodes.contains(t)&&!this.chart.labels.contains(t))return t;t++}}init(){this.chart.element.classList.add("bfc-"+this.chart.mode),this.chart.element.classList.add("frame"),this.chart.element.innerHTML=` ${FlowChart.css()}\n <svg class="bfc-svg bfc-${this.chart.options.mode}"> \n <defs></defs> \n <g data-layer="-3"></g>\n <g data-layer="-2"></g>\n <g data-layer="-1"></g>\n <foreignObject class="bfc-html" x="90000" y="90000" width="10000" height="10000"><div data-test-elastic-size style="height: initial; display: inline-block;" class="bfc-flex-center"></div></foreignObject>\n </svg>\n <div data-statusbar class="bfc-statusbar">\n &nbsp;\n </div>\n <div data-shapebar class="bfc-shapebar" style="display: none;"></div>\n <div data-colorbar class="bfc-colorbar" style="display: none;"></div>\n <div data-menubar class="bfc-menubar bfc-horizontal-bar" style="display: none;"></div>${FlowChart.private.logo(this.chart.options.logoSvg)}`,this.chart.svgElement=this.chart.element.querySelector(".bfc-svg"),this.svgBCR=this.chart.svgElement.getBoundingClientRect();var t=[0,0,this.svgBCR.width,this.svgBCR.height];this.chart.svgElement.setAttribute("viewBox",t.join(",")),this.chart.menuBar.init(),this.chart.shapeBar.init(),this.chart.colorBar.init(),this.chart.statusBar.init(),this.addListeners()}getViewBox=function(){var t=null;return this.chart.svgElement?(t=(t="["+(t=this.chart.svgElement.getAttribute("viewBox"))+"]").replace(/\ /g,","),t=JSON.parse(t)):null};setViewBox(t){isNaN(t[2])&&console.log("not ok"),this.chart.svgElement.setAttribute("viewBox",t.toString());var e=FlowChart.private.getScale(t,this.svgBCR.width,this.svgBCR.height);this.updatePortsElement(e)}getScale(){if(this.svgBCR.width>0&&this.svgBCR.height>0){var t=FlowChart.private.getScale(this.chart.viewBox,this.svgBCR.width,this.svgBCR.height);return isNaN(t),t}return console.log(`setViewBox -> this.svgBCR.width: ${this.svgBCR.width}; this.svgBCR.height: ${this.svgBCR.height};`),0}on(t,e){return FlowChart.events.on(t,e,this.uid),this.chart}getSizeOfHTML(t){t&&(t=t.replaceAll("contenteditable"," "));var e=this.chart.svgElement.querySelector("[data-test-elastic-size]");e.innerHTML=t;var i=e.getBoundingClientRect(),r=this.chart.scale;return{width:i.width/r+6,height:i.height/r+6}}getActiveComponentTypes(){if(null!=this.chart.selectedPort)return["port-shape-bar"];if(this.chart.editor.hasActiveField())return["field"];var t=[];return this.chart.selectedShapes.nodes.length&&t.push("node"),this.chart.selectedShapes.labels.length&&t.push("label"),t.length?(t.push("shape"),this.chart.selectedShapes.nodes.length==this.chart.nodes.length&&t.push("all-nodes"),t):"canvas"}zoom(t,e,i,r){var a=this,o=this.chart.viewBox,s=o,h=o[2],l=o[3];!0===t?(o[2]=o[2]/FlowChart.SCALE_FACTOR,o[3]=o[3]/FlowChart.SCALE_FACTOR):!1===t?(o[2]=o[2]*FlowChart.SCALE_FACTOR,o[3]=o[3]*FlowChart.SCALE_FACTOR):(o[2]=o[2]/t,o[3]=o[3]/t),e||(e=[50,50]),o[0]=s[0]-(o[2]-h)/(100/e[0]),o[1]=s[1]-(o[3]-l)/(100/e[1]);var n=FlowChart.private.getScale(o,this.svgBCR.width,this.svgBCR.height);o[2]=this.svgBCR.width/n,o[3]=this.svgBCR.height/n;var d=this.chart.options;(!0===t&&n<d.scaleMax||!1===t&&n>d.scaleMin||!1!==t&&!0!==t&&n<d.scaleMax&&n>d.scaleMin)&&(i?(this._zoomTimeout&&(clearTimeout(this._zoomTimeout),this._zoomTimeout=null),this._zoomTimeout=FlowChart.animate(this.chart.svgElement,{viewBox:this.chart.viewBox},{viewBox:o},300,FlowChart.anim.outPow,(function(){r&&r.call(a.chart)}))):(this.chart.viewBox=o,r&&r.call(a.chart)))}updateMatchedShortcuts(t,e,i){this.matchedShortcuts=[];var r=this.getActiveComponentTypes();for(var a in this.shortcuts)if(!this.matchedShortcuts.includes(a)){var o=!0,s=!0,h=!0,l=this.shortcuts[a];if(l.keysPressed)for(var n=0;n<l.keysPressed.length;n++){var d,p=l.keysPressed[n];d=-1!=p.indexOf("|")?p.split("|"):[p];var c=!1;for(var f of d)0==f.indexOf("!")?(f=f.substring(1),this.keysPressed.includes(f)||(c=!0)):this.keysPressed.includes(f)&&(c=!0);if(!c){o=!1;break}var u=!1;if(l.activeComponentType){var m=l.activeComponentType.split("|");for(var y of m)r.includes(y)&&(u=!0)}else u=!0;if(!u){h=!1;break}}else e&&l.keyDown?l.keyDown!=e&&(o=!1):i&&l.keyUp&&l.keyUp!=i&&(o=!1);if(l.mouseActions)for(n=0;n<l.mouseActions.length;n++)if(!this.mouseActions.includes(l.mouseActions[n])){s=!1;break}if(s&&o&&h){this.matchedShortcuts.includes(a)||this.matchedShortcuts.push(a);var g=this.chart.selectedShapes,v=this.chart.selectedShapes.nodes;if("move_selected_nodes_left"==a)this.chart.selectedPortShape=null,this.chart.nodes._.move(v,FlowChart.move.left);else if("move_selected_nodes_right"==a)this.chart.selectedPortShape=null,this.chart.nodes._.move(v,FlowChart.move.right);else if("move_selected_nodes_up"==a)this.chart.selectedPortShape=null,this.chart.nodes._.move(v,FlowChart.move.up);else if("move_selected_nodes_down"==a)this.chart.selectedPortShape=null,this.chart.nodes._.move(v,FlowChart.move.down);else if("align_tofirst_selected_nodes_bottom"==a)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.bottom,!0);else if("align_tofirst_selected_nodes_top"==a)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.top,!0);else if("align_tofirst_selected_nodes_left"==a)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.left,!0);else if("align_tofirst_selected_nodes_right"==a)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.right,!0);else if("align_tofirst_selected_nodes_horizontally"==a)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.horizontally,!0);else if("align_tofirst_selected_nodes_vertically"==a)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.vertically,!0);else if("align_tolast_selected_nodes_bottom"==a)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.bottom,!1);else if("align_tolast_selected_nodes_top"==a)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.top,!1);else if("align_tolast_selected_nodes_left"==a)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.left,!1);else if("align_tolast_selected_nodes_right"==a)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.right,!1);else if("align_tolast_selected_nodes_horizontally"==a)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.horizontally,!1);else if("align_tolast_selected_nodes_vertically"==a)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.vertically,!1);else if("remove_selected_shapes"==a)this.chart.nodes.removeRange(this.chart.selectedShapes.nodes),this.chart.labels.removeRange(this.chart.selectedShapes.labels);else if("select_all_nodes"==a)for(var w of(t.preventDefault(),this.chart.nodes))"label"!=w.type&&this.chart.selectedShapes.add(w);else if("undo"==a)this.chart._.undo(),this.chart.menuBar._.simulateMouseClickOnKeydown("undo");else if("redo"==a)this.chart._.redo(),this.chart.menuBar._.simulateMouseClickOnKeydown("redo");else if("open_up_port"==a)this.showPortShapeBarUI(FlowChart.position.top);else if("open_down_port"==a)this.showPortShapeBarUI(FlowChart.position.bottom);else if("open_left_port"==a)this.showPortShapeBarUI(FlowChart.position.left);else if("open_right_port"==a)this.showPortShapeBarUI(FlowChart.position.right);else if("navigate_port_down"==a)t.preventDefault(),this.navigatePortShapeBarItems(FlowChart.position.bottom);else if("navigate_port_left"==a)t.preventDefault(),this.navigatePortShapeBarItems(FlowChart.position.left);else if("navigate_port_right"==a)t.preventDefault(),this.navigatePortShapeBarItems(FlowChart.position.right);else if("navigate_port_up"==a)t.preventDefault(),this.navigatePortShapeBarItems(FlowChart.position.top);else if("add_shape"==a)this.chart.editor.blur(),t.preventDefault(),this.chart._.createNodeFromPorsShapeBarItem();else if("edit_next_field"==a)t.preventDefault(),this.chart.editor.selectNextField();else if("exit_edit_field"==a)this.chart.editor.blur();else if("close_port_shape_bar"==a)this.chart.selectedPort=null;else if("deleselect_shapes"==a)this.chart.selectedShapes.clear();else if("edit_shape"==a){var C=this.chart.selectedShapes.last;t.preventDefault(),this.chart.editor.editFirstFieldIfAny(C)}else if("select_node_above"==a)t.preventDefault(),this.chart.editor.blur(),this.chart.selectedShapes.selectNodeAbove(!0);else if("select_node_below"==a)t.preventDefault(),this.chart.editor.blur(),this.chart.selectedShapes.selectNodeBelow(!0);else if("select_node_left"==a)t.preventDefault(),this.chart.editor.blur(),this.chart.selectedShapes.selectNodeLeft(!0);else if("select_node_right"==a)t.preventDefault(),this.chart.editor.blur(),this.chart.selectedShapes.selectNodeRight(!0);else if("select_nodes_above"==a)t.preventDefault(),this.chart.editor.blur(),this.chart.selectedShapes.selectNodeAbove(!1);else if("select_nodes_below"==a)t.preventDefault(),this.chart.editor.blur(),this.chart.selectedShapes.selectNodeBelow(!1);else if("select_nodes_left"==a)t.preventDefault(),this.chart.editor.blur(),this.chart.selectedShapes.selectNodeLeft(!1);else if("select_nodes_right"==a)t.preventDefault(),this.chart.editor.blur(),this.chart.selectedShapes.selectNodeRight(!1);else if("paint_node"==a){if(null!=e){var b=parseInt(e)-1;this.changeFill(b),this.chart.colorBar._.simulateMouseClickOnKeydown(`color-${b}`)}}else if("fit_to_page"==a)this.chart.reposition(FlowChart.startPosition.fit);else if("replace_div_with_br_on_enter"==a){for(var x=t.target;x&&x.hasAttribute&&!x.hasAttribute("data-shape-id");)x=x.parentNode;if(x){var F=x.getAttribute("data-shape-id");if(this.chart.selectedShapes.contains(F)){if(13==t.keyCode){t.preventDefault();const e=window.getSelection(),i=e.getRangeAt(0);var N=document.getSelection().anchorNode.parentNode.nodeName.toUpperCase();switch(N){case"P":case"DIV":default:N="BR";break;case"SPAN":N="span";break;case"BR":N=null}const r=document.createElement(N);i.deleteContents(),i.insertNode(r),"BR"===N?(i.setStartAfter(r),i.setEndAfter(r)):(i.setStart(r,0),i.setEnd(r,0));const a=document.createTextNode("​");i.insertNode(a),i.setStartBefore(a),i.setEndBefore(a),e.removeAllRanges(),e.addRange(i),t.stopPropagation()}t.target.value=t.target.innerHTML}}}FlowChart.events.publish("shortcut",[this.chart,{name:a,event:t}])}}}changeFill(t){t=parseInt(t)+1;var e=this;-1==this.changeFillPressedIndexes.indexOf(t)&&this.changeFillPressedIndexes.push(t),this.changeFillPressedTimeout&&(clearTimeout(this.changeFillPressedTimeout),this.changeFillPressedTimeout=null),this.changeFillPressedTimeout=setTimeout((function(){e.changeFillPressedIndexes=[]}),500);for(var i="",r=0;r<this.changeFillPressedIndexes.length;r++)i+=this.changeFillPressedIndexes[r].toString();t=parseInt(i)-1;for(var a=this.chart.options.colors[t];!a&&i.length;)i=i.substring(1),t=parseInt(i)-1,a=this.chart.options.colors[t];if(a)for(var o of this.chart.selectedShapes)o.fill!=a&&(o.fill=a)}},void 0===FlowChart&&(FlowChart={}),FlowChart.position=Object.freeze({top:"top",bottom:"bottom",left:"left",right:"right",topLeft:"topLeft",topRight:"topRight",bottomLeft:"bottomLeft",bottomRight:"bottomRight"}),FlowChart.align=Object.freeze({top:"top",bottom:"bottom",left:"left",right:"right",horizontally:"horizontally",vertically:"vertically"}),FlowChart.move=Object.freeze({up:"up",down:"down",left:"left",right:"right"}),FlowChart.direction=Object.freeze({vertical:"vertical",horizontal:"horizontal"}),FlowChart.startPosition=Object.freeze({none:"none",fitHeight:"fitHeight",fitWidth:"fitWidth",fit:"fit",fit1:"fit1",center2In:"center2In",center2Out:"center2Out",centerTop:"centerTop",centerBottom:"centerBottom",centerLeft:"centerLeft",centerRight:"centerRight",center:"center"}),FlowChart.private.animate=function(t,e,i,r,a,o,s){var h,l=10,n=1,d=r/l+1;return document.getElementsByTagName("g"),Array.isArray(t)||(t=[t]),Array.isArray(e)||(e=[e]),Array.isArray(i)||(i=[i]),h=setInterval((function(){for(var p=0;p<t.length;p++)for(var c in i[p]){var f=["top","left","right","bottom","width","height"].includes(c.toLowerCase())?"px":"";if("node"==t[p].type||"label"==t[p].type){var u=a((n*l-l)/r)*(i[p][c]-e[p][c])+e[p][c];switch(c){case"x":case"y":case"width":case"height":case"opacity":t[p][c]=u;break;default:t[p].element.style[c]=u}}else switch(c){case"d":var m=a((n*l-l)/r)*(i[p][c][0]-e[p][c][0])+e[p][c][0],y=a((n*l-l)/r)*(i[p][c][1]-e[p][c][1])+e[p][c][1];t[p].setAttribute("d",t[p].getAttribute("d")+" L"+m+" "+y);break;case"r":u=a((n*l-l)/r)*(i[p][c]-e[p][c])+e[p][c],t[p].setAttribute("r",u);break;case"x1":u=a((n*l-l)/r)*(i[p][c]-e[p][c])+e[p][c],t[p].setAttribute("x1",u);break;case"x2":u=a((n*l-l)/r)*(i[p][c]-e[p][c])+e[p][c],t[p].setAttribute("x2",u);break;case"y1":u=a((n*l-l)/r)*(i[p][c]-e[p][c])+e[p][c],t[p].setAttribute("y1",u);break;case"y2":u=a((n*l-l)/r)*(i[p][c]-e[p][c])+e[p][c],t[p].setAttribute("y2",u);break;case"rotate3d":if(i[p][c]){var g=e[p][c],v=i[p][c],w=[0,0,0,0];for(var C in g)w[C]=a((n*l-l)/r)*(v[C]-g[C])+g[C];t[p].style.transform="rotate3d("+w.toString()+"deg)"}break;case"transform":if(i[p][c]){for(var C in g=e[p][c],v=i[p][c],w=[0,0,0,0,0,0],g)w[C]=a((n*l-l)/r)*(v[C]-g[C])+g[C];t[p].hasAttribute("transform")?t[p].setAttribute("transform","matrix("+w.toString()+")"):t[p].style.transform="matrix("+w.toString()+")"}break;case"translate":if(i[p][c]){for(var C in g=e[p][c],v=i[p][c],w=[0,0],g)w[C]=a((n*l-l)/r)*(v[C]-g[C])+g[C];t[p].setAttribute("transform","translate("+w.toString()+")")}break;case"viewBox":if(i[p][c]){for(var C in g=e[p][c],v=i[p][c],w=[0,0,0,0],g)w[C]=a((n*l-l)/r)*(v[C]-g[C])+g[C];t[p].setAttribute("viewBox",w.toString())}break;case"margin":if(i[p][c]){for(var C in g=e[p][c],v=i[p][c],w=[0,0,0,0],g)w[C]=a((n*l-l)/r)*(v[C]-g[C])+g[C];var b="";for(C=0;C<w.length;C++)b+=parseInt(w[C])+"px ";t[p]&&t[p].style&&(t[p].style[c]=b)}break;case"scrollY":u=a((n*l-l)/r)*(i[p][c]-e[p][c])+e[p][c],t[p].scrollTo(0,u);break;case"stdDeviation":u=a((n*l-l)/r)*(i[p][c]-e[p][c])+e[p][c],t[p].setAttribute("stdDeviation",u);break;case"baseFrequency":u=a((n*l-l)/r)*(i[p][c]-e[p][c])+e[p][c],t[p].setAttribute("baseFrequency",u);break;default:u=a((n*l-l)/r)*(i[p][c]-e[p][c])+e[p][c],t[p]&&t[p].style&&(t[p].style[c]=u+f)}}s&&s(),(n+=1)>d+1&&(clearInterval(h),o&&o(t))}),l)},FlowChart.private.linkFromTo=function(t,e,i,r,a){var o=[];if(i.position==FlowChart.position.right&&r.position==FlowChart.position.left)if(t.left+t.width+FlowChart.LINK_DITSNANCE<e.left-FlowChart.LINK_DITSNANCE){var s=t.left+t.width+(e.left-(t.left+t.width))/2;o.push({x:i.x,y:i.y}),o.push({x:s,y:i.y}),o.push({x:s,y:r.y}),o.push({x:r.x,y:r.y})}else if(t.top-FlowChart.LINK_DITSNANCE>e.top+e.height+FlowChart.LINK_DITSNANCE){var h=t.top+t.height+(e.top-(t.top+t.height))/2;o.push({x:i.x,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:h}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:h}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})}else if(t.top+t.height+FlowChart.LINK_DITSNANCE<e.top-FlowChart.LINK_DITSNANCE)h=e.top+e.height+(t.top-(e.top+e.height))/2,o.push({x:i.x,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:h}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:h}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y});else if(i.y<=r.y&&t.left-FlowChart.LINK_DITSNANCE>e.left+e.width+FlowChart.LINK_DITSNANCE){var l=Math.min(t.top,e.top);o.push({x:i.x,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:l-FlowChart.LINK_DITSNANCE}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:l-FlowChart.LINK_DITSNANCE}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})}else if(i.y>r.y&&t.left+FlowChart.LINK_DITSNANCE>e.left+e.width+FlowChart.LINK_DITSNANCE){var n=Math.max(t.top+t.height,e.top+e.height);o.push({x:i.x,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:n+FlowChart.LINK_DITSNANCE}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:n+FlowChart.LINK_DITSNANCE}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})}else o.push({x:i.x,y:i.y}),o.push({x:r.x,y:r.y});else if(i.position==FlowChart.position.left&&r.position==FlowChart.position.right)t.left-FlowChart.LINK_DITSNANCE>e.left+e.width+FlowChart.LINK_DITSNANCE?(s=e.left+e.width+(t.left-(e.left+e.width))/2,o.push({x:i.x,y:i.y}),o.push({x:s,y:i.y}),o.push({x:s,y:r.y}),o.push({x:r.x,y:r.y})):t.top-FlowChart.LINK_DITSNANCE>e.top+e.height+FlowChart.LINK_DITSNANCE?(h=e.top+e.height+(t.top-(e.top+e.height))/2,o.push({x:i.x,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:h}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:h}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})):t.top+t.height+FlowChart.LINK_DITSNANCE<e.top-FlowChart.LINK_DITSNANCE?(h=t.top+t.height+(e.top-(t.top+t.height))/2,o.push({x:i.x,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:h}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:h}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})):i.y<=r.y&&t.left+t.width+FlowChart.LINK_DITSNANCE<e.left-FlowChart.LINK_DITSNANCE?(l=Math.min(t.top,e.top),o.push({x:i.x,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:l-FlowChart.LINK_DITSNANCE}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:l-FlowChart.LINK_DITSNANCE}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})):i.y>r.y&&t.left+t.width+FlowChart.LINK_DITSNANCE<e.left-FlowChart.LINK_DITSNANCE?(n=Math.max(t.top+t.height,e.top+e.height),o.push({x:i.x,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:n+FlowChart.LINK_DITSNANCE}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:n+FlowChart.LINK_DITSNANCE}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})):(o.push({x:i.x,y:i.y}),o.push({x:r.x,y:r.y}));else if(i.position==FlowChart.position.bottom&&r.position==FlowChart.position.top)if(t.top+t.height+FlowChart.LINK_DITSNANCE<e.top-FlowChart.LINK_DITSNANCE)h=t.top+t.height+(e.top-(t.top+t.height))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:h}),o.push({x:r.x,y:h}),o.push({x:r.x,y:r.y});else if(t.left+t.width+FlowChart.LINK_DITSNANCE<e.left-FlowChart.LINK_DITSNANCE)s=t.left+t.width+(e.left-(t.left+t.width))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:r.y});else if(t.left-FlowChart.LINK_DITSNANCE>e.left+e.width+FlowChart.LINK_DITSNANCE)s=e.left+e.width+(t.left-(e.left+e.width))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:r.y});else if(i.x<=r.x&&t.top-FlowChart.LINK_DITSNANCE>e.top+e.height+FlowChart.LINK_DITSNANCE){var d=Math.min(t.left,e.left);o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:d-FlowChart.LINK_DITSNANCE,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:d-FlowChart.LINK_DITSNANCE,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:r.y})}else if(i.x>r.x&&t.top-FlowChart.LINK_DITSNANCE>e.top+e.height+FlowChart.LINK_DITSNANCE){var p=Math.max(t.left+t.width,e.left+e.width);o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:p+FlowChart.LINK_DITSNANCE,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:p+FlowChart.LINK_DITSNANCE,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:r.y})}else o.push({x:i.x,y:i.y}),o.push({x:r.x,y:r.y});else i.position==FlowChart.position.top&&r.position==FlowChart.position.bottom?t.top-FlowChart.LINK_DITSNANCE>e.top+e.height+FlowChart.LINK_DITSNANCE?(h=e.top+e.height+(t.top-(e.top+e.height))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:h}),o.push({x:r.x,y:h}),o.push({x:r.x,y:r.y})):t.left+t.width+FlowChart.LINK_DITSNANCE<e.left-FlowChart.LINK_DITSNANCE?(s=t.left+t.width+(e.left-(t.left+t.width))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:s,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:s,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:r.y})):t.left-FlowChart.LINK_DITSNANCE>e.left+e.width+FlowChart.LINK_DITSNANCE?(s=e.left+e.width+(t.left-(e.left+e.width))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:s,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:s,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:r.y})):i.x<=r.x&&t.top+t.height+FlowChart.LINK_DITSNANCE<e.top-FlowChart.LINK_DITSNANCE?(d=Math.min(t.left,e.left),o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:d-FlowChart.LINK_DITSNANCE,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:d-FlowChart.LINK_DITSNANCE,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:r.y})):i.x>r.x&&t.top+t.height+FlowChart.LINK_DITSNANCE<e.top-FlowChart.LINK_DITSNANCE?(p=Math.max(t.left+t.width,e.left+e.width),o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:p+FlowChart.LINK_DITSNANCE,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:p+FlowChart.LINK_DITSNANCE,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:r.y})):(o.push({x:i.x,y:i.y}),o.push({x:r.x,y:r.y})):i.position==FlowChart.position.bottom&&r.position==FlowChart.position.left?t.left+t.width+FlowChart.LINK_DITSNANCE>e.left-FlowChart.LINK_DITSNANCE&&t.left-FlowChart.LINK_DITSNANCE<e.left+e.width+FlowChart.LINK_DITSNANCE&&t.top+t.height+FlowChart.LINK_DITSNANCE>e.top-FlowChart.LINK_DITSNANCE&&t.top-FlowChart.LINK_DITSNANCE<e.top+e.height+FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:r.x,y:r.y})):i.y+FlowChart.LINK_DITSNANCE<r.y&&i.x<e.left-FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:i.x,y:r.y}),o.push({x:r.x,y:r.y})):t.top+t.height+FlowChart.LINK_DITSNANCE<e.top-FlowChart.LINK_DITSNANCE?(h=t.top+t.height+(e.top-(t.top+t.height))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:h}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:h}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})):t.top+t.height+FlowChart.LINK_DITSNANCE>e.top-FlowChart.LINK_DITSNANCE&&t.left+t.width+FlowChart.LINK_DITSNANCE>e.left-FlowChart.LINK_DITSNANCE?(n=Math.max(t.top+t.height,e.top+e.height),d=Math.min(t.left,e.left),o.push({x:i.x,y:i.y}),o.push({x:i.x,y:n+FlowChart.LINK_DITSNANCE}),o.push({x:d-FlowChart.LINK_DITSNANCE,y:n+FlowChart.LINK_DITSNANCE}),o.push({x:d-FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})):t.top+t.height+FlowChart.LINK_DITSNANCE>e.top?(s=t.left+t.width+(e.left-(t.left+t.width))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:r.y}),o.push({x:r.x,y:r.y})):(o.push({x:i.x,y:i.y}),o.push({x:r.x,y:r.y})):i.position==FlowChart.position.bottom&&r.position==FlowChart.position.right?t.left+t.width+FlowChart.LINK_DITSNANCE>e.left-FlowChart.LINK_DITSNANCE&&t.left-FlowChart.LINK_DITSNANCE<e.left+e.width+FlowChart.LINK_DITSNANCE&&t.top+t.height+FlowChart.LINK_DITSNANCE>e.top-FlowChart.LINK_DITSNANCE&&t.top-FlowChart.LINK_DITSNANCE<e.top+e.height+FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:r.x,y:r.y})):i.y<r.y&&i.x>e.left+e.width+FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:i.x,y:r.y}),o.push({x:r.x,y:r.y})):t.top+t.height+FlowChart.LINK_DITSNANCE<=e.top-FlowChart.LINK_DITSNANCE?(h=t.top+t.height+(e.top-(t.top+t.height))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:h}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:h}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})):t.top+t.height+FlowChart.LINK_DITSNANCE>e.top-FlowChart.LINK_DITSNANCE&&t.left-FlowChart.LINK_DITSNANCE<e.left+e.width+FlowChart.LINK_DITSNANCE?(n=Math.max(t.top+t.height,e.top+e.height),p=Math.max(t.left+t.width,e.left+e.width),o.push({x:i.x,y:i.y}),o.push({x:i.x,y:n+FlowChart.LINK_DITSNANCE}),o.push({x:p+FlowChart.LINK_DITSNANCE,y:n+FlowChart.LINK_DITSNANCE}),o.push({x:p+FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})):t.top+t.height+FlowChart.LINK_DITSNANCE>e.top?(s=e.left+e.width+(t.left-(e.left+e.width))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:r.y}),o.push({x:r.x,y:r.y})):(o.push({x:i.x,y:i.y}),o.push({x:r.x,y:r.y})):i.position==FlowChart.position.top&&r.position==FlowChart.position.left?t.left+t.width+FlowChart.LINK_DITSNANCE>e.left-FlowChart.LINK_DITSNANCE&&t.left-FlowChart.LINK_DITSNANCE<e.left+e.width+FlowChart.LINK_DITSNANCE&&t.top+t.height+FlowChart.LINK_DITSNANCE>e.top-FlowChart.LINK_DITSNANCE&&t.top-FlowChart.LINK_DITSNANCE<e.top+e.height+FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:r.x,y:r.y})):i.y>r.y&&i.x<e.left-FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:i.x,y:r.y}),o.push({x:r.x,y:r.y})):t.top-FlowChart.LINK_DITSNANCE>=e.top+e.height+FlowChart.LINK_DITSNANCE?(h=t.top+t.height+(e.top-(t.top+t.height))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:h}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:h}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})):t.top-FlowChart.LINK_DITSNANCE<e.top+e.height+FlowChart.LINK_DITSNANCE&&t.left+t.width+FlowChart.LINK_DITSNANCE>e.left-FlowChart.LINK_DITSNANCE?(l=Math.min(t.top,e.top),d=Math.min(t.left,e.left),o.push({x:i.x,y:i.y}),o.push({x:i.x,y:l-FlowChart.LINK_DITSNANCE}),o.push({x:d-FlowChart.LINK_DITSNANCE,y:l-FlowChart.LINK_DITSNANCE}),o.push({x:d-FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})):t.top+FlowChart.LINK_DITSNANCE<e.top+e.height?(s=t.left+t.width+(e.left-(t.left+t.width))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:s,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:s,y:r.y}),o.push({x:r.x,y:r.y})):(o.push({x:i.x,y:i.y}),o.push({x:r.x,y:r.y})):i.position==FlowChart.position.top&&r.position==FlowChart.position.right?t.left+t.width+FlowChart.LINK_DITSNANCE>e.left-FlowChart.LINK_DITSNANCE&&t.left-FlowChart.LINK_DITSNANCE<e.left+e.width+FlowChart.LINK_DITSNANCE&&t.top+t.height+FlowChart.LINK_DITSNANCE>e.top-FlowChart.LINK_DITSNANCE&&t.top-FlowChart.LINK_DITSNANCE<e.top+e.height+FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:r.x,y:r.y})):i.y-FlowChart.LINK_DITSNANCE>r.y&&i.x>e.left+e.width+FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:i.x,y:r.y}),o.push({x:r.x,y:r.y})):t.top-FlowChart.LINK_DITSNANCE>e.top+e.height+FlowChart.LINK_DITSNANCE?(h=t.top+t.height+(e.top-(t.top+t.height))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:h}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:h}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})):t.top-FlowChart.LINK_DITSNANCE<e.top+e.height+FlowChart.LINK_DITSNANCE&&t.left-FlowChart.LINK_DITSNANCE<e.left+e.width+FlowChart.LINK_DITSNANCE?(l=Math.min(t.top,e.top),p=Math.max(t.left+t.width,e.left+e.width),o.push({x:i.x,y:i.y}),o.push({x:i.x,y:l-FlowChart.LINK_DITSNANCE}),o.push({x:p+FlowChart.LINK_DITSNANCE,y:l-FlowChart.LINK_DITSNANCE}),o.push({x:p+FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})):t.top+FlowChart.LINK_DITSNANCE<e.top+e.height?(s=t.left+t.width+(e.left-(t.left+t.width))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:s,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:s,y:r.y}),o.push({x:r.x,y:r.y})):(o.push({x:i.x,y:i.y}),o.push({x:r.x,y:r.y})):i.position==FlowChart.position.right&&r.position==FlowChart.position.right?r.x<i.x?t.top-FlowChart.LINK_DITSNANCE>r.y||t.top+t.height+FlowChart.LINK_DITSNANCE<r.y?(o.push({x:i.x,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})):e.left+e.width+FlowChart.LINK_DITSNANCE<t.left-FlowChart.LINK_DITSNANCE?(s=e.left+e.width+(t.left-(e.left+e.width))/2,o.push({x:i.x,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:r.y}),o.push({x:r.x,y:r.y})):(o.push({x:i.x,y:i.y}),o.push({x:r.x,y:r.y})):e.top-FlowChart.LINK_DITSNANCE>i.y||e.top+e.height+FlowChart.LINK_DITSNANCE<i.y?(p=Math.max(t.left+t.width,e.left+e.width),o.push({x:i.x,y:i.y}),o.push({x:p+FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:p+FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})):e.left+e.width-(t.left+t.width)>FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})):(o.push({x:i.x,y:i.y}),o.push({x:r.x,y:r.y})):i.position==FlowChart.position.left&&r.position==FlowChart.position.left?r.x>i.x?t.top-FlowChart.LINK_DITSNANCE>r.y||t.top+t.height+FlowChart.LINK_DITSNANCE<r.y?(o.push({x:i.x,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})):e.left-FlowChart.LINK_DITSNANCE>t.left+t.width+FlowChart.LINK_DITSNANCE?(s=e.left+e.width+(t.left-(e.left+e.width))/2,o.push({x:i.x,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:r.y}),o.push({x:r.x,y:r.y})):(o.push({x:i.x,y:i.y}),o.push({x:r.x,y:r.y})):e.top-FlowChart.LINK_DITSNANCE>i.y||e.top+e.height+FlowChart.LINK_DITSNANCE<i.y?(d=Math.min(t.left,e.left),o.push({x:i.x,y:i.y}),o.push({x:d-FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:d-FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})):t.left-(e.left+e.width)>FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:r.y}),o.push({x:r.x,y:r.y})):(o.push({x:i.x,y:i.y}),o.push({x:r.x,y:r.y})):i.position==FlowChart.position.top&&r.position==FlowChart.position.top?r.y<i.y?t.left-FlowChart.LINK_DITSNANCE>r.x||t.left+t.width+FlowChart.LINK_DITSNANCE<r.x?(o.push({x:i.x,y:i.y}),o.push({x:i.x,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:r.y})):e.top+e.height+FlowChart.LINK_DITSNANCE<t.top-FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:r.y})):(o.push({x:i.x,y:i.y}),o.push({x:r.x,y:r.y})):e.left-FlowChart.LINK_DITSNANCE>i.x||e.left+e.width+FlowChart.LINK_DITSNANCE<i.x?(l=Math.min(t.top,e.top),o.push({x:i.x,y:i.y}),o.push({x:i.x,y:l-FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:l-FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:r.y})):e.top+e.height-(t.top+t.height)>FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:r.y})):(o.push({x:i.x,y:i.y}),o.push({x:r.x,y:r.y})):i.position==FlowChart.position.bottom&&r.position==FlowChart.position.bottom?r.y<i.y?t.left-FlowChart.LINK_DITSNANCE>r.x||t.left+t.width+FlowChart.LINK_DITSNANCE<r.x?(o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:r.x,y:r.y})):e.top+e.height+Flow