-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflowchart.js
More file actions
2 lines (2 loc) · 204 KB
/
flowchart.js
File metadata and controls
2 lines (2 loc) · 204 KB
1
/* 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,r,o,a,i,s){return FlowChart.private.animate(t,e,r,o,a,i,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,r){this._.addNodeWithLink(t,e,r)}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,r){this._.alignShapes(t,e,r)}reposition(t,e,r,o){this._.reposition(t,e,r,o)}rippleShape(t,e,r){FlowChart.private.rippleShape(t,e,r)}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,r){return t.call(e,r)})}onChanged(t){return this._.on("changed",function(e,r){return t.call(e,r)})}onUndoRedoChanged(t){return this._.on("undo-redo-changed",function(e,r){return t.call(e,r)})}onSelectedShapeChanging(t){return this._.on("selected-shape-changing",function(e,r){return t.call(e,r)})}onSelectedShapesChanged(t){return this._.on("selected-shapes-changed",function(e,r){return t.call(e,r)})}onSelectedPortChange(t){return this._.on("selected-port-change",function(e,r){return t.call(e,r)})}onShortcut(t){return this._.on("shortcut",function(e,r){return t.call(e,r)})}onMenuItemClick(t){return this._.on("menu-item-click",function(e,r){return t.call(e,r)})}onLinkPoints(t){return this._.on("link-points",function(e,r){return t.call(e,r)})}onLinkClick(t){return this._.on("link-click",function(e,r){return t.call(e,r)})}onShapeDoubleClick(t){return this._.on("shape-db-click",function(e,r){return t.call(e,r)})}onShapeClick(t){return this._.on("shape-click",function(e,r){return t.call(e,r)})}onSvgClick(t){return this._.on("svg-click",function(e,r){return t.call(e,r)})}onFieldChange(t){return this._.on("field-change",function(e,r){return t.call(e,r)})}};void 0===FlowChart&&(FlowChart={}),FlowChart.VERSION="1.01.82","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,r){var o=this,a={templateId:e};(a=this.chart.nodes.add(a)).element.style.opacity=0;var i=this.chart.links.getByShape(t.shape),s=[];for(var h of i){if(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 i=[],s=[],h=[],l=o.chart.scale;for(var n of e){var c=o.chart.nodes.get(n.id),p={x:n.x,y:n.y,opacity:1};if(a==c){var d={x:n.x,y:n.y,opacity:0};switch(t.position){case FlowChart.position.left:d.x+=8/l;break;case FlowChart.position.right:d.x-=8/l;break;case FlowChart.position.top:d.y+=8/l;break;case FlowChart.position.bottom:d.y-=8/l;break;case FlowChart.position.topLeft:d.y+=8/l,d.x+=8/l;break;case FlowChart.position.bottomLeft:d.y-=8/l,d.x+=8/l;break;case FlowChart.position.bottomRight:d.y-=8/l,d.x-=8/l;break;case FlowChart.position.topRight:d.y+=8/l,d.x-=8/l}s.push(d)}else s.push({x:c.x,y:c.y,opacity:0});h.push(p),c.x=-1e4,c.y=-1e4,i.push(c)}for(var f=0;f<i.length;f++)i[f].x=s[f].x,i[f].y=s[f].y;o.animateShapes(i,s,h,function(){r&&r.call(o.chart,a,w),o.makeShapesVisible([i],function(){var t=o.chart.editor.getFieldNames(a);t.length&&o.chart.editor.edit(a,t[0])})});var u=o.chart.ports.getByOpositeOfPosition(a.id,t.position)[0],w={from:t.shape.id,to:u.shape.id,fromPort:t.id,toPort:u.id,templateId:"rounded"};w=o.chart.links.add(w)})}changed(t){if(this.useChangeListener){var e=this;for(var r in t){var o=t[r];(r="property")&&-1==this.changedArgs.properties.indexOf(o)&&this.changedArgs.properties.push(o)}"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 r of t.selectedShapes){var o=this.chart.getShape(r);o&&(o.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,r){if(t.length){this.chart.selectedPortShape=null;t.length;var o=t[t.length-1];r&&(t.length,o=t[0]);for(var a=0;a<t.length;a++){var i=t[a];e==FlowChart.position.top?i.y=o.y-o.height/2+i.height/2:e==FlowChart.align.bottom?i.y=o.y+o.height/2-i.height/2:e==FlowChart.align.left?i.x=o.x-o.width/2+i.width/2:e==FlowChart.align.right?i.x=o.x+o.width/2-i.width/2:e==FlowChart.align.vertically?i.x=o.x:e==FlowChart.align.horizontally&&(i.y=o.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 \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 r=e.getBoundingClientRect(),o=this.chart.scale;return{width:r.width/o+6,height:r.height/o+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,r,o){var a=this,i=this.chart.viewBox,s=i,h=i[2],l=i[3];!0===t?(i[2]=i[2]/FlowChart.SCALE_FACTOR,i[3]=i[3]/FlowChart.SCALE_FACTOR):!1===t?(i[2]=i[2]*FlowChart.SCALE_FACTOR,i[3]=i[3]*FlowChart.SCALE_FACTOR):(i[2]=i[2]/t,i[3]=i[3]/t),e||(e=[50,50]),i[0]=s[0]-(i[2]-h)/(100/e[0]),i[1]=s[1]-(i[3]-l)/(100/e[1]);var n=FlowChart.private.getScale(i,this.svgBCR.width,this.svgBCR.height);i[2]=this.svgBCR.width/n,i[3]=this.svgBCR.height/n;var c=this.chart.options;(!0===t&&n<c.scaleMax||!1===t&&n>c.scaleMin||!1!==t&&!0!==t&&n<c.scaleMax&&n>c.scaleMin)&&(r?(this._zoomTimeout&&(clearTimeout(this._zoomTimeout),this._zoomTimeout=null),this._zoomTimeout=FlowChart.animate(this.chart.svgElement,{viewBox:this.chart.viewBox},{viewBox:i},300,FlowChart.anim.outPow,function(){o&&o.call(a.chart)})):(this.chart.viewBox=i,o&&o.call(a.chart)))}updateMatchedShortcuts(t,e,r){this.matchedShortcuts=[];var o=this.getActiveComponentTypes();for(var a in this.shortcuts)if(!this.matchedShortcuts.includes(a)){var i=!0,s=!0,h=!0,l=this.shortcuts[a];if(l.keysPressed)for(var n=0;n<l.keysPressed.length;n++){var c,p=l.keysPressed[n];c=-1!=p.indexOf("|")?p.split("|"):[p];var d=!1;for(var f of c)0==f.indexOf("!")?(f=f.substring(1),this.keysPressed.includes(f)||(d=!0)):this.keysPressed.includes(f)&&(d=!0);if(!d){i=!1;break}var u=!1;if(l.activeComponentType){var w=l.activeComponentType.split("|");for(var m of w)o.includes(m)&&(u=!0)}else u=!0;if(!u){h=!1;break}}else e&&l.keyDown?l.keyDown!=e&&(i=!1):r&&l.keyUp&&l.keyUp!=r&&(i=!1);if(l.mouseActions)for(n=0;n<l.mouseActions.length;n++)if(!this.mouseActions.includes(l.mouseActions[n])){s=!1;break}if(s&&i&&h){this.matchedShortcuts.includes(a)||this.matchedShortcuts.push(a);var C=this.chart.selectedShapes,g=this.chart.selectedShapes.nodes;if("move_selected_nodes_left"==a)this.chart.selectedPortShape=null,this.chart.nodes._.move(g,FlowChart.move.left);else if("move_selected_nodes_right"==a)this.chart.selectedPortShape=null,this.chart.nodes._.move(g,FlowChart.move.right);else if("move_selected_nodes_up"==a)this.chart.selectedPortShape=null,this.chart.nodes._.move(g,FlowChart.move.up);else if("move_selected_nodes_down"==a)this.chart.selectedPortShape=null,this.chart.nodes._.move(g,FlowChart.move.down);else if("align_tofirst_selected_nodes_bottom"==a)t.preventDefault(),this.chart.alignShapes(C,FlowChart.align.bottom,!0);else if("align_tofirst_selected_nodes_top"==a)t.preventDefault(),this.chart.alignShapes(C,FlowChart.align.top,!0);else if("align_tofirst_selected_nodes_left"==a)t.preventDefault(),this.chart.alignShapes(C,FlowChart.align.left,!0);else if("align_tofirst_selected_nodes_right"==a)t.preventDefault(),this.chart.alignShapes(C,FlowChart.align.right,!0);else if("align_tofirst_selected_nodes_horizontally"==a)t.preventDefault(),this.chart.alignShapes(C,FlowChart.align.horizontally,!0);else if("align_tofirst_selected_nodes_vertically"==a)t.preventDefault(),this.chart.alignShapes(C,FlowChart.align.vertically,!0);else if("align_tolast_selected_nodes_bottom"==a)t.preventDefault(),this.chart.alignShapes(C,FlowChart.align.bottom,!1);else if("align_tolast_selected_nodes_top"==a)t.preventDefault(),this.chart.alignShapes(C,FlowChart.align.top,!1);else if("align_tolast_selected_nodes_left"==a)t.preventDefault(),this.chart.alignShapes(C,FlowChart.align.left,!1);else if("align_tolast_selected_nodes_right"==a)t.preventDefault(),this.chart.alignShapes(C,FlowChart.align.right,!1);else if("align_tolast_selected_nodes_horizontally"==a)t.preventDefault(),this.chart.alignShapes(C,FlowChart.align.horizontally,!1);else if("align_tolast_selected_nodes_vertically"==a)t.preventDefault(),this.chart.alignShapes(C,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 v of(t.preventDefault(),this.chart.nodes))"label"!=v.type&&this.chart.selectedShapes.add(v);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 y=this.chart.selectedShapes.last;t.preventDefault(),this.chart.editor.editFirstFieldIfAny(y)}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 N=parseInt(e)-1;this.changeFill(N),this.chart.colorBar._.simulateMouseClickOnKeydown(`color-${N}`)}}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 b=x.getAttribute("data-shape-id");if(this.chart.selectedShapes.contains(b)){if(13==t.keyCode){t.preventDefault();const e=window.getSelection(),r=e.getRangeAt(0);var F=document.getSelection().anchorNode.parentNode.nodeName.toUpperCase();switch(F){case"P":case"DIV":default:F="BR";break;case"SPAN":F="span";break;case"BR":F=null}const o=document.createElement(F);r.deleteContents(),r.insertNode(o),"BR"===F?(r.setStartAfter(o),r.setEndAfter(o)):(r.setStart(o,0),r.setEnd(o,0));const a=document.createTextNode("");r.insertNode(a),r.setStartBefore(a),r.setEndBefore(a),e.removeAllRanges(),e.addRange(r),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 r="",o=0;o<this.changeFillPressedIndexes.length;o++)r+=this.changeFillPressedIndexes[o].toString();t=parseInt(r)-1;for(var a=this.chart.options.colors[t];!a&&r.length;)r=r.substring(1),t=parseInt(r)-1,a=this.chart.options.colors[t];if(a)for(var i of this.chart.selectedShapes)i.fill!=a&&(i.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",centerShapes:"centerShapes",centerTop:"centerTop",centerBottom:"centerBottom",centerLeft:"centerLeft",centerRight:"centerRight",center:"center"}),FlowChart.private.animate=function(t,e,r,o,a,i,s){var h,l=10,n=1,c=o/l+1;document.getElementsByTagName("g");return Array.isArray(t)||(t=[t]),Array.isArray(e)||(e=[e]),Array.isArray(r)||(r=[r]),h=setInterval(function(){for(var p=0;p<t.length;p++)for(var d in r[p]){var f=["top","left","right","bottom","width","height"].includes(d.toLowerCase())?"px":"";if("node"==t[p].type||"label"==t[p].type){var u=a((n*l-l)/o)*(r[p][d]-e[p][d])+e[p][d];switch(d){case"x":case"y":case"width":case"height":case"opacity":t[p][d]=u;break;default:t[p].element.style[d]=u}}else switch(d){case"d":var w=a((n*l-l)/o)*(r[p][d][0]-e[p][d][0])+e[p][d][0],m=a((n*l-l)/o)*(r[p][d][1]-e[p][d][1])+e[p][d][1];t[p].setAttribute("d",t[p].getAttribute("d")+" L"+w+" "+m);break;case"r":u=a((n*l-l)/o)*(r[p][d]-e[p][d])+e[p][d];t[p].setAttribute("r",u);break;case"x1":u=a((n*l-l)/o)*(r[p][d]-e[p][d])+e[p][d];t[p].setAttribute("x1",u);break;case"x2":u=a((n*l-l)/o)*(r[p][d]-e[p][d])+e[p][d];t[p].setAttribute("x2",u);break;case"y1":u=a((n*l-l)/o)*(r[p][d]-e[p][d])+e[p][d];t[p].setAttribute("y1",u);break;case"y2":u=a((n*l-l)/o)*(r[p][d]-e[p][d])+e[p][d];t[p].setAttribute("y2",u);break;case"rotate3d":if(r[p][d]){var C=e[p][d],g=r[p][d],v=[0,0,0,0];for(var y in C)v[y]=a((n*l-l)/o)*(g[y]-C[y])+C[y];t[p].style.transform="rotate3d("+v.toString()+"deg)"}break;case"transform":if(r[p][d]){C=e[p][d],g=r[p][d],v=[0,0,0,0,0,0];for(var y in C)v[y]=a((n*l-l)/o)*(g[y]-C[y])+C[y];t[p].hasAttribute("transform")?t[p].setAttribute("transform","matrix("+v.toString()+")"):t[p].style.transform="matrix("+v.toString()+")"}break;case"translate":if(r[p][d]){C=e[p][d],g=r[p][d],v=[0,0];for(var y in C)v[y]=a((n*l-l)/o)*(g[y]-C[y])+C[y];t[p].setAttribute("transform","translate("+v.toString()+")")}break;case"viewBox":if(r[p][d]){C=e[p][d],g=r[p][d],v=[0,0,0,0];for(var y in C)v[y]=a((n*l-l)/o)*(g[y]-C[y])+C[y];t[p].setAttribute("viewBox",v.toString())}break;case"margin":if(r[p][d]){C=e[p][d],g=r[p][d],v=[0,0,0,0];for(var y in C)v[y]=a((n*l-l)/o)*(g[y]-C[y])+C[y];var N="";for(y=0;y<v.length;y++)N+=parseInt(v[y])+"px ";t[p]&&t[p].style&&(t[p].style[d]=N)}break;case"scrollY":u=a((n*l-l)/o)*(r[p][d]-e[p][d])+e[p][d];t[p].scrollTo(0,u);break;case"stdDeviation":u=a((n*l-l)/o)*(r[p][d]-e[p][d])+e[p][d];t[p].setAttribute("stdDeviation",u);break;case"baseFrequency":u=a((n*l-l)/o)*(r[p][d]-e[p][d])+e[p][d];t[p].setAttribute("baseFrequency",u);break;default:u=a((n*l-l)/o)*(r[p][d]-e[p][d])+e[p][d];t[p]&&t[p].style&&(t[p].style[d]=u+f)}}s&&s(),(n+=1)>c+1&&(clearInterval(h),i&&i(t))},l)},FlowChart.private.linkFromTo=function(t,e,r,o,a){var i=[];if(r.position==FlowChart.position.right&&o.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;i.push({x:r.x,y:r.y}),i.push({x:s,y:r.y}),i.push({x:s,y:o.y}),i.push({x:o.x,y:o.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;i.push({x:r.x,y:r.y}),i.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:h}),i.push({x:e.left-FlowChart.LINK_DITSNANCE,y:h}),i.push({x:e.left-FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.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;i.push({x:r.x,y:r.y}),i.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:h}),i.push({x:e.left-FlowChart.LINK_DITSNANCE,y:h}),i.push({x:e.left-FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y})}else if(r.y<=o.y&&t.left-FlowChart.LINK_DITSNANCE>e.left+e.width+FlowChart.LINK_DITSNANCE){var l=Math.min(t.top,e.top);i.push({x:r.x,y:r.y}),i.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:l-FlowChart.LINK_DITSNANCE}),i.push({x:e.left-FlowChart.LINK_DITSNANCE,y:l-FlowChart.LINK_DITSNANCE}),i.push({x:e.left-FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y})}else if(r.y>o.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);i.push({x:r.x,y:r.y}),i.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:n+FlowChart.LINK_DITSNANCE}),i.push({x:e.left-FlowChart.LINK_DITSNANCE,y:n+FlowChart.LINK_DITSNANCE}),i.push({x:e.left-FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y})}else i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(r.position==FlowChart.position.left&&o.position==FlowChart.position.right)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;i.push({x:r.x,y:r.y}),i.push({x:s,y:r.y}),i.push({x:s,y:o.y}),i.push({x:o.x,y:o.y})}else if(t.top-FlowChart.LINK_DITSNANCE>e.top+e.height+FlowChart.LINK_DITSNANCE){h=e.top+e.height+(t.top-(e.top+e.height))/2;i.push({x:r.x,y:r.y}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:h}),i.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:h}),i.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y})}else 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;i.push({x:r.x,y:r.y}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:h}),i.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:h}),i.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y})}else if(r.y<=o.y&&t.left+t.width+FlowChart.LINK_DITSNANCE<e.left-FlowChart.LINK_DITSNANCE){l=Math.min(t.top,e.top);i.push({x:r.x,y:r.y}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:l-FlowChart.LINK_DITSNANCE}),i.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:l-FlowChart.LINK_DITSNANCE}),i.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y})}else if(r.y>o.y&&t.left+t.width+FlowChart.LINK_DITSNANCE<e.left-FlowChart.LINK_DITSNANCE){n=Math.max(t.top+t.height,e.top+e.height);i.push({x:r.x,y:r.y}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:n+FlowChart.LINK_DITSNANCE}),i.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:n+FlowChart.LINK_DITSNANCE}),i.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y})}else i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(r.position==FlowChart.position.bottom&&o.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;i.push({x:r.x,y:r.y}),i.push({x:r.x,y:h}),i.push({x:o.x,y:h}),i.push({x:o.x,y:o.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;i.push({x:r.x,y:r.y}),i.push({x:r.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:s,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:s,y:e.top-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:e.top-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.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;i.push({x:r.x,y:r.y}),i.push({x:r.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:s,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:s,y:e.top-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:e.top-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})}else if(r.x<=o.x&&t.top-FlowChart.LINK_DITSNANCE>e.top+e.height+FlowChart.LINK_DITSNANCE){var c=Math.min(t.left,e.left);i.push({x:r.x,y:r.y}),i.push({x:r.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:c-FlowChart.LINK_DITSNANCE,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:c-FlowChart.LINK_DITSNANCE,y:e.top-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:e.top-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})}else if(r.x>o.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);i.push({x:r.x,y:r.y}),i.push({x:r.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:p+FlowChart.LINK_DITSNANCE,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:p+FlowChart.LINK_DITSNANCE,y:e.top-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:e.top-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})}else i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(r.position==FlowChart.position.top&&o.position==FlowChart.position.bottom)if(t.top-FlowChart.LINK_DITSNANCE>e.top+e.height+FlowChart.LINK_DITSNANCE){h=e.top+e.height+(t.top-(e.top+e.height))/2;i.push({x:r.x,y:r.y}),i.push({x:r.x,y:h}),i.push({x:o.x,y:h}),i.push({x:o.x,y:o.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;i.push({x:r.x,y:r.y}),i.push({x:r.x,y:t.top-FlowChart.LINK_DITSNANCE}),i.push({x:s,y:t.top-FlowChart.LINK_DITSNANCE}),i.push({x:s,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.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;i.push({x:r.x,y:r.y}),i.push({x:r.x,y:t.top-FlowChart.LINK_DITSNANCE}),i.push({x:s,y:t.top-FlowChart.LINK_DITSNANCE}),i.push({x:s,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})}else if(r.x<=o.x&&t.top+t.height+FlowChart.LINK_DITSNANCE<e.top-FlowChart.LINK_DITSNANCE){c=Math.min(t.left,e.left);i.push({x:r.x,y:r.y}),i.push({x:r.x,y:t.top-FlowChart.LINK_DITSNANCE}),i.push({x:c-FlowChart.LINK_DITSNANCE,y:t.top-FlowChart.LINK_DITSNANCE}),i.push({x:c-FlowChart.LINK_DITSNANCE,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})}else if(r.x>o.x&&t.top+t.height+FlowChart.LINK_DITSNANCE<e.top-FlowChart.LINK_DITSNANCE){p=Math.max(t.left+t.width,e.left+e.width);i.push({x:r.x,y:r.y}),i.push({x:r.x,y:t.top-FlowChart.LINK_DITSNANCE}),i.push({x:p+FlowChart.LINK_DITSNANCE,y:t.top-FlowChart.LINK_DITSNANCE}),i.push({x:p+FlowChart.LINK_DITSNANCE,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})}else i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(r.position==FlowChart.position.bottom&&o.position==FlowChart.position.left)if(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)i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(r.y+FlowChart.LINK_DITSNANCE<o.y&&r.x<e.left-FlowChart.LINK_DITSNANCE)i.push({x:r.x,y:r.y}),i.push({x:r.x,y:o.y}),i.push({x:o.x,y:o.y});else 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;i.push({x:r.x,y:r.y}),i.push({x:r.x,y:h}),i.push({x:e.left-FlowChart.LINK_DITSNANCE,y:h}),i.push({x:e.left-FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y})}else if(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),c=Math.min(t.left,e.left);i.push({x:r.x,y:r.y}),i.push({x:r.x,y:n+FlowChart.LINK_DITSNANCE}),i.push({x:c-FlowChart.LINK_DITSNANCE,y:n+FlowChart.LINK_DITSNANCE}),i.push({x:c-FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y})}else if(t.top+t.height+FlowChart.LINK_DITSNANCE>e.top){s=t.left+t.width+(e.left-(t.left+t.width))/2;i.push({x:r.x,y:r.y}),i.push({x:r.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:s,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:s,y:o.y}),i.push({x:o.x,y:o.y})}else i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(r.position==FlowChart.position.bottom&&o.position==FlowChart.position.right)if(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)i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(r.y<o.y&&r.x>e.left+e.width+FlowChart.LINK_DITSNANCE)i.push({x:r.x,y:r.y}),i.push({x:r.x,y:o.y}),i.push({x:o.x,y:o.y});else 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;i.push({x:r.x,y:r.y}),i.push({x:r.x,y:h}),i.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:h}),i.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y})}else if(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);i.push({x:r.x,y:r.y}),i.push({x:r.x,y:n+FlowChart.LINK_DITSNANCE}),i.push({x:p+FlowChart.LINK_DITSNANCE,y:n+FlowChart.LINK_DITSNANCE}),i.push({x:p+FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y})}else if(t.top+t.height+FlowChart.LINK_DITSNANCE>e.top){s=e.left+e.width+(t.left-(e.left+e.width))/2;i.push({x:r.x,y:r.y}),i.push({x:r.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:s,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:s,y:o.y}),i.push({x:o.x,y:o.y})}else i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(r.position==FlowChart.position.top&&o.position==FlowChart.position.left)if(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)i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(r.y>o.y&&r.x<e.left-FlowChart.LINK_DITSNANCE)i.push({x:r.x,y:r.y}),i.push({x:r.x,y:o.y}),i.push({x:o.x,y:o.y});else if(t.top-FlowChart.LINK_DITSNANCE>=e.top+e.height+FlowChart.LINK_DITSNANCE){h=t.top+t.height+(e.top-(t.top+t.height))/2;i.push({x:r.x,y:r.y}),i.push({x:r.x,y:h}),i.push({x:e.left-FlowChart.LINK_DITSNANCE,y:h}),i.push({x:e.left-FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y})}else if(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),c=Math.min(t.left,e.left);i.push({x:r.x,y:r.y}),i.push({x:r.x,y:l-FlowChart.LINK_DITSNANCE}),i.push({x:c-FlowChart.LINK_DITSNANCE,y:l-FlowChart.LINK_DITSNANCE}),i.push({x:c-FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y})}else if(t.top+FlowChart.LINK_DITSNANCE<e.top+e.height){s=t.left+t.width+(e.left-(t.left+t.width))/2;i.push({x:r.x,y:r.y}),i.push({x:r.x,y:t.top-FlowChart.LINK_DITSNANCE}),i.push({x:s,y:t.top-FlowChart.LINK_DITSNANCE}),i.push({x:s,y:o.y}),i.push({x:o.x,y:o.y})}else i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(r.position==FlowChart.position.top&&o.position==FlowChart.position.right)if(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)i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(r.y-FlowChart.LINK_DITSNANCE>o.y&&r.x>e.left+e.width+FlowChart.LINK_DITSNANCE)i.push({x:r.x,y:r.y}),i.push({x:r.x,y:o.y}),i.push({x:o.x,y:o.y});else if(t.top-FlowChart.LINK_DITSNANCE>e.top+e.height+FlowChart.LINK_DITSNANCE){h=t.top+t.height+(e.top-(t.top+t.height))/2;i.push({x:r.x,y:r.y}),i.push({x:r.x,y:h}),i.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:h}),i.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y})}else if(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);i.push({x:r.x,y:r.y}),i.push({x:r.x,y:l-FlowChart.LINK_DITSNANCE}),i.push({x:p+FlowChart.LINK_DITSNANCE,y:l-FlowChart.LINK_DITSNANCE}),i.push({x:p+FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y})}else if(t.top+FlowChart.LINK_DITSNANCE<e.top+e.height){s=t.left+t.width+(e.left-(t.left+t.width))/2;i.push({x:r.x,y:r.y}),i.push({x:r.x,y:t.top-FlowChart.LINK_DITSNANCE}),i.push({x:s,y:t.top-FlowChart.LINK_DITSNANCE}),i.push({x:s,y:o.y}),i.push({x:o.x,y:o.y})}else i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(r.position==FlowChart.position.right&&o.position==FlowChart.position.right)if(o.x<r.x)if(t.top-FlowChart.LINK_DITSNANCE>o.y||t.top+t.height+FlowChart.LINK_DITSNANCE<o.y)i.push({x:r.x,y:r.y}),i.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y});else if(e.left+e.width+FlowChart.LINK_DITSNANCE<t.left-FlowChart.LINK_DITSNANCE){s=e.left+e.width+(t.left-(e.left+e.width))/2;i.push({x:r.x,y:r.y}),i.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:s,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:s,y:o.y}),i.push({x:o.x,y:o.y})}else i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(e.top-FlowChart.LINK_DITSNANCE>r.y||e.top+e.height+FlowChart.LINK_DITSNANCE<r.y){p=Math.max(t.left+t.width,e.left+e.width);i.push({x:r.x,y:r.y}),i.push({x:p+FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:p+FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y})}else e.left+e.width-(t.left+t.width)>FlowChart.LINK_DITSNANCE?(i.push({x:r.x,y:r.y}),i.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),i.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),i.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y})):(i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y}));else if(r.position==FlowChart.position.left&&o.position==FlowChart.position.left)if(o.x>r.x)if(t.top-FlowChart.LINK_DITSNANCE>o.y||t.top+t.height+FlowChart.LINK_DITSNANCE<o.y)i.push({x:r.x,y:r.y}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y});else if(e.left-FlowChart.LINK_DITSNANCE>t.left+t.width+FlowChart.LINK_DITSNANCE){s=e.left+e.width+(t.left-(e.left+e.width))/2;i.push({x:r.x,y:r.y}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:s,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:s,y:o.y}),i.push({x:o.x,y:o.y})}else i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(e.top-FlowChart.LINK_DITSNANCE>r.y||e.top+e.height+FlowChart.LINK_DITSNANCE<r.y){c=Math.min(t.left,e.left);i.push({x:r.x,y:r.y}),i.push({x:c-FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:c-FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y})}else t.left-(e.left+e.width)>FlowChart.LINK_DITSNANCE?(i.push({x:r.x,y:r.y}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),i.push({x:e.left-FlowChart.LINK_DITSNANCE,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),i.push({x:e.left-FlowChart.LINK_DITSNANCE,y:o.y}),i.push({x:o.x,y:o.y})):(i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y}));else if(r.position==FlowChart.position.top&&o.position==FlowChart.position.top)if(o.y<r.y)t.left-FlowChart.LINK_DITSNANCE>o.x||t.left+t.width+FlowChart.LINK_DITSNANCE<o.x?(i.push({x:r.x,y:r.y}),i.push({x:r.x,y:e.top-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:e.top-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})):e.top+e.height+FlowChart.LINK_DITSNANCE<t.top-FlowChart.LINK_DITSNANCE?(i.push({x:r.x,y:r.y}),i.push({x:r.x,y:t.top-FlowChart.LINK_DITSNANCE}),i.push({x:e.left-FlowChart.LINK_DITSNANCE,y:t.top-FlowChart.LINK_DITSNANCE}),i.push({x:e.left-FlowChart.LINK_DITSNANCE,y:e.top-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:e.top-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})):(i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y}));else if(e.left-FlowChart.LINK_DITSNANCE>r.x||e.left+e.width+FlowChart.LINK_DITSNANCE<r.x){l=Math.min(t.top,e.top);i.push({x:r.x,y:r.y}),i.push({x:r.x,y:l-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:l-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})}else e.top+e.height-(t.top+t.height)>FlowChart.LINK_DITSNANCE?(i.push({x:r.x,y:r.y}),i.push({x:r.x,y:t.top-FlowChart.LINK_DITSNANCE}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:t.top-FlowChart.LINK_DITSNANCE}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:e.top-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:e.top-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})):(i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y}));else if(r.position==FlowChart.position.bottom&&o.position==FlowChart.position.bottom)o.y<r.y?t.left-FlowChart.LINK_DITSNANCE>o.x||t.left+t.width+FlowChart.LINK_DITSNANCE<o.x?(i.push({x:r.x,y:r.y}),i.push({x:r.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})):e.top+e.height+FlowChart.LINK_DITSNANCE<t.top-FlowChart.LINK_DITSNANCE?(i.push({x:r.x,y:r.y}),i.push({x:r.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:t.top-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:t.top-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})):(i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y})):e.left-FlowChart.LINK_DITSNANCE>r.x||e.left+e.width+FlowChart.LINK_DITSNANCE<r.x?(i.push({x:r.x,y:r.y}),i.push({x:r.x,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})):e.top+e.height-(t.top+t.height)>FlowChart.LINK_DITSNANCE?(i.push({x:r.x,y:r.y}),i.push({x:r.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:e.left-FlowChart.LINK_DITSNANCE,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),i.push({x:e.left-FlowChart.LINK_DITSNANCE,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})):(i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y}));else if(r.position==FlowChart.position.left&&o.position==FlowChart.position.bottom)if(e.left+e.width+FlowChart.LINK_DITSNANCE>t.left-FlowChart.LINK_DITSNANCE&&e.left-FlowChart.LINK_DITSNANCE<t.left+t.width+FlowChart.LINK_DITSNANCE&&e.top+e.height+FlowChart.LINK_DITSNANCE>t.top-FlowChart.LINK_DITSNANCE&&e.top-FlowChart.LINK_DITSNANCE<t.top+t.height+FlowChart.LINK_DITSNANCE)i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(o.y+FlowChart.LINK_DITSNANCE<r.y&&o.x<t.left-FlowChart.LINK_DITSNANCE)i.push({x:r.x,y:r.y}),i.push({x:o.x,y:r.y}),i.push({x:o.x,y:o.y});else if(e.top+e.height+FlowChart.LINK_DITSNANCE<t.top-FlowChart.LINK_DITSNANCE){h=e.top+e.height+(t.top-(e.top+e.height))/2;i.push({x:r.x,y:r.y}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:h}),i.push({x:o.x,y:h}),i.push({x:o.x,y:o.y})}else if(e.top+e.height+FlowChart.LINK_DITSNANCE>t.top-FlowChart.LINK_DITSNANCE&&e.left+e.width+FlowChart.LINK_DITSNANCE>t.left-FlowChart.LINK_DITSNANCE){n=Math.max(e.top+e.height,t.top+t.height),c=Math.min(e.left,t.left);i.push({x:r.x,y:r.y}),i.push({x:c-FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:c-FlowChart.LINK_DITSNANCE,y:n+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:n+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})}else if(e.top+e.height+FlowChart.LINK_DITSNANCE>t.top){s=e.left+e.width+(t.left-(e.left+e.width))/2;i.push({x:r.x,y:r.y}),i.push({x:s,y:r.y}),i.push({x:s,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})}else i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(r.position==FlowChart.position.left&&o.position==FlowChart.position.top)if(e.left+e.width+FlowChart.LINK_DITSNANCE>t.left-FlowChart.LINK_DITSNANCE&&e.left-FlowChart.LINK_DITSNANCE<t.left+t.width+FlowChart.LINK_DITSNANCE&&e.top+e.height+FlowChart.LINK_DITSNANCE>t.top-FlowChart.LINK_DITSNANCE&&e.top-FlowChart.LINK_DITSNANCE<t.top+t.height+FlowChart.LINK_DITSNANCE)i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(o.y>r.y&&o.x<t.left-FlowChart.LINK_DITSNANCE)i.push({x:r.x,y:r.y}),i.push({x:o.x,y:r.y}),i.push({x:o.x,y:o.y});else if(e.top-FlowChart.LINK_DITSNANCE>=t.top+t.height+FlowChart.LINK_DITSNANCE){h=e.top+e.height+(t.top-(e.top+e.height))/2;i.push({x:r.x,y:r.y}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:t.left-FlowChart.LINK_DITSNANCE,y:h}),i.push({x:o.x,y:h}),i.push({x:o.x,y:o.y})}else if(e.top-FlowChart.LINK_DITSNANCE<t.top+t.height+FlowChart.LINK_DITSNANCE&&e.left+e.width+FlowChart.LINK_DITSNANCE>t.left-FlowChart.LINK_DITSNANCE){l=Math.min(e.top,t.top),c=Math.min(e.left,t.left);i.push({x:r.x,y:r.y}),i.push({x:c-FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:c-FlowChart.LINK_DITSNANCE,y:l-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:l-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})}else if(e.top+FlowChart.LINK_DITSNANCE<t.top+t.height){s=e.left+e.width+(t.left-(e.left+e.width))/2;i.push({x:r.x,y:r.y}),i.push({x:s,y:r.y}),i.push({x:s,y:e.top-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:e.top-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})}else i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(r.position==FlowChart.position.right&&o.position==FlowChart.position.bottom)if(e.left+e.width+FlowChart.LINK_DITSNANCE>t.left-FlowChart.LINK_DITSNANCE&&e.left-FlowChart.LINK_DITSNANCE<t.left+t.width+FlowChart.LINK_DITSNANCE&&e.top+e.height+FlowChart.LINK_DITSNANCE>t.top-FlowChart.LINK_DITSNANCE&&e.top-FlowChart.LINK_DITSNANCE<t.top+t.height+FlowChart.LINK_DITSNANCE)i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(o.y<r.y&&o.x>t.left+t.width+FlowChart.LINK_DITSNANCE)i.push({x:r.x,y:r.y}),i.push({x:o.x,y:r.y}),i.push({x:o.x,y:o.y});else if(e.top+e.height+FlowChart.LINK_DITSNANCE<=t.top-FlowChart.LINK_DITSNANCE){h=e.top+e.height+(t.top-(e.top+e.height))/2;i.push({x:r.x,y:r.y}),i.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:h}),i.push({x:o.x,y:h}),i.push({x:o.x,y:o.y})}else if(e.top+e.height+FlowChart.LINK_DITSNANCE>t.top-FlowChart.LINK_DITSNANCE&&e.left-FlowChart.LINK_DITSNANCE<t.left+t.width+FlowChart.LINK_DITSNANCE){n=Math.max(e.top+e.height,t.top+t.height),p=Math.max(e.left+e.width,t.left+t.width);i.push({x:r.x,y:r.y}),i.push({x:p+FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:p+FlowChart.LINK_DITSNANCE,y:n+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:n+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})}else if(e.top+e.height+FlowChart.LINK_DITSNANCE>t.top){s=t.left+t.width+(e.left-(t.left+t.width))/2;i.push({x:r.x,y:r.y}),i.push({x:s,y:r.y}),i.push({x:s,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})}else i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(r.position==FlowChart.position.right&&o.position==FlowChart.position.top)if(e.left+e.width+FlowChart.LINK_DITSNANCE>t.left-FlowChart.LINK_DITSNANCE&&e.left-FlowChart.LINK_DITSNANCE<t.left+t.width+FlowChart.LINK_DITSNANCE&&e.top+e.height+FlowChart.LINK_DITSNANCE>t.top-FlowChart.LINK_DITSNANCE&&e.top-FlowChart.LINK_DITSNANCE<t.top+t.height+FlowChart.LINK_DITSNANCE)i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});else if(o.y-FlowChart.LINK_DITSNANCE>r.y&&o.x>t.left+t.width+FlowChart.LINK_DITSNANCE)i.push({x:r.x,y:r.y}),i.push({x:o.x,y:r.y}),i.push({x:o.x,y:o.y});else if(e.top-FlowChart.LINK_DITSNANCE>t.top+t.height+FlowChart.LINK_DITSNANCE){h=e.top+e.height+(t.top-(e.top+e.height))/2;i.push({x:r.x,y:r.y}),i.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:h}),i.push({x:o.x,y:h}),i.push({x:o.x,y:o.y})}else if(e.top-FlowChart.LINK_DITSNANCE<t.top+t.height+FlowChart.LINK_DITSNANCE&&e.left-FlowChart.LINK_DITSNANCE<t.left+t.width+FlowChart.LINK_DITSNANCE){l=Math.min(e.top,t.top),p=Math.max(e.left+e.width,t.left+t.width);i.push({x:r.x,y:r.y}),i.push({x:p+FlowChart.LINK_DITSNANCE,y:r.y}),i.push({x:p+FlowChart.LINK_DITSNANCE,y:l-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:l-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})}else if(e.top+FlowChart.LINK_DITSNANCE<t.top+t.height){s=e.left+e.width+(t.left-(e.left+e.width))/2;i.push({x:r.x,y:r.y}),i.push({x:s,y:r.y}),i.push({x:s,y:e.top-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:e.top-FlowChart.LINK_DITSNANCE}),i.push({x:o.x,y:o.y})}else i.push({x:r.x,y:r.y}),i.push({x:o.x,y:o.y});var d={points:i,fromShape:t,toShape:e,fromPort:r,toPort:o};return FlowChart.events.publish("link-points",[a,d]),d.points},FlowChart.private.prototype.handlerKeyup=function(t){var e=FlowChart.private.replaceRightLeftKeyCodes(t.code),r=t.key.toLowerCase(),o=this.keysPressed.indexOf(e);-1!=o&&(this.keysPressed.splice(o,1),this.updateMatchedShortcuts(t,void 0,r)),this.matchedShortcuts.includes("move_selected_nodes_left")&&this.matchedShortcuts.includes("move_selected_nodes_right")||this.chart.nodes._.stopMoving(FlowChart.direction.horizontal),this.matchedShortcuts.includes("move_selected_nodes_up")&&this.matchedShortcuts.includes("move_selected_nodes_down")||this.chart.nodes._.stopMoving(FlowChart.direction.vertical)},FlowChart.private.prototype.handlerKeydown=function(t){var e=t.key.toLowerCase();"shift"==e&&(this.chart.selectedShapes._.arrayBeforeShiftPressed=this.chart.selectedShapes.slice());var r=FlowChart.private.replaceRightLeftKeyCodes(t.code);this.keysPressed.includes(r)||(this.keysPressed.push(r),this.updateMatchedShortcuts(t,e,void 0))},FlowChart.private.prototype.handlerInput=function(t){if(this.chart.editor.hasActiveField()){for(var e=t.target;!e.hasAttribute("data-shape-id");)e=e.parentNode;var r=e.getAttribute("data-shape-id"),o=this.chart.getShape(r);if(this.chart.editor.edit(o),o.canWidthFitContent||o.canHeightFitContent){for(var a=t.target;!a.hasAttribute||!a.hasAttribute("data-html-container");)a=a.parentNode;var i=this.chart._.getSizeOfHTML(a.innerHTML);o.canWidthFitContent&&("label"==o.type?this.chart.labels._.setWidth(o,i.width):this.chart.nodes._.setWidth(o,i.width)),o.canHeightFitContent&&("label"==o.type?this.chart.labels._.setHeight(o,i.height):this.chart.nodes._.setHeight(o,i.height))}}},FlowChart.private.prototype.handlerDblclick=function(t){for(var e=t.target;e&&e.hasAttribute&&e!=this.chart.svgElement;){if(e.hasAttribute("data-link-id")){var r=e.getAttribute("data-link-id"),o=this.chart.links.getById(r),a=FlowChart.private.getFirstPointIndexByMousePosition(t,this.chart.svgElement,o);FlowChart.direction.horizontal;o.points[a].x==o.points[a+1].x&&FlowChart.direction.vertical;for(var i=0,s=0;s<a;s++){var h=o.points[s],l=o.points[s+1];i+=Math.hypot(l.x-h.x,l.y-h.y)}var n=this.chart.svgElement.createSVGPoint();n.x=t.clientX,n.y=t.clientY,n=n.matrixTransform(this.chart.svgElement.getScreenCTM().inverse());var c=(i+=Math.hypot(n.x-o.points[a].x,n.y-o.points[a].y))/(o.length/100),p={from:o.from,to:o.to,fromPort:o.fromPort,toPort:o.toPort,position:c,content:c};return p=this.chart.labels.add(p),this.chart.editor.edit(p.id),void(p.selected=!0)}e=e.parentNode}},FlowChart.private.prototype.handlerMousemove=function(t){for(var e=t.target,r=null,o=null;e&&e!=this.element;){if(e&&e.hasAttribute){if(e.hasAttribute("data-link-id")){r=this.chart.links.getById(e.getAttribute("data-link-id")),o="link";break}if(e.hasAttribute("data-shape-id")){r=this.chart.getShape(e.getAttribute("data-shape-id")),o="node";break}if(e.hasAttribute("data-selector-shape-id")){r=this.chart.getShape(e.getAttribute("data-selector-shape-id")),o="node";break}if(e.hasAttribute("data-ports-s-id")){r=this.chart.nodes.get(e.getAttribute("data-ports-s-id")),o="node";break}if(e.hasAttribute("data-port-out-port")){var a=e.getAttribute("data-port-out-port"),i=e.getAttribute("data-port-out-shape");r=this.chart.ports.get(i,a),o="port";break}if(e.hasAttribute("data-portsb-shape")){r=e.getAttribute("data-portsb-shape"),o="portshapebart";break}}e=e.parentNode}null!=this.mouseOverShapeType&&null==r?("node"==this.mouseOverShapeType?this.handlerMouseleaveOnShape(this.mouseOverShape):"port"==this.mouseOverShapeType||"link"==this.mouseOverShapeType||"portshapebart"==this.mouseOverShapeType&&this.handlerMouseleaveOnMiniShapeBar(),this.mouseOverShape=null,this.mouseOverShapeType=null):FlowChart.private.safeStringify(this.mouseOverShape)!==FlowChart.private.safeStringify(r)&&(null!=r?"node"==o?("port"==this.mouseOverShapeType?this.handlerMouseleaveOnMiniShapeBar():"link"==this.mouseOverShapeType||"portshapebart"==this.mouseOverShapeType&&this.handlerMouseleaveOnMiniShapeBar(),this.handlerMouseenterOnShape(t,r)):"port"==o?("node"==this.mouseOverShapeType||"link"==this.mouseOverShapeType||this.mouseOverShapeType,this.handlerMouseenterOnPortOut(t,r)):"link"==o?("port"==this.mouseOverShapeType||"node"==this.mouseOverShapeType||this.mouseOverShapeType,this.handlerMouseenterOnLink(t,r)):"portshapebart"==o&&("port"==this.mouseOverShapeType||"node"==this.mouseOverShapeType||this.mouseOverShapeType):this.mouseOverShape,this.mouseOverShape=r,this.mouseOverShapeType=o)},FlowChart.private.prototype.handlerTouchstartMousedown=function(t,e,r){for(var o=e.target;o&&o!=this.chart.element;){if(o&&o.classList&&o.classList.contains&&o.classList.contains("bfc-bar-move"))return void this.handlerTouchstartMousedownOnBarMove(t,e,r,o);if(o&&o.hasAttribute&&o.hasAttribute("data-selector-dot-2"))return void this.handlerTouchstartMousedownOnResizeDot(t,e,r,o);if(o&&o.hasAttribute&&o.hasAttribute("data-shapebar-item-id"))return void this.handlerDownOnShapeBarItem(e,r,o);if(o&&o.hasAttribute&&o.hasAttribute("data-shape-id")){var a=this.chart.getShape(o.getAttribute("data-shape-id"));return a&&0!=a.movable||this.handlerTouchstartMousedownOnSvg(t,e,r,o),void(a&&a.selectable&&this.chart.options.selectable&&this.handlerTouchstartMousedownOnShape(e,r,a,!0))}if(o&&o.hasAttribute&&o.hasAttribute("data-link-id")){var i=o.getAttribute("data-link-id");return i||this.handlerTouchstartMousedownOnSvg(t,e,r,o),void(i&&this.chart.options.selectable&&this.handlerTouchstartMousedownOnLink(e,r,i))}if(o&&o.hasAttribute&&o.hasAttribute("data-port-out-port"))return void this.handlerTouchstartMousedownOnPortOut(e,o,r);o==this.chart.svgElement&&this.handlerTouchstartMousedownOnSvg(t,e,r,o),o=o.parentNode}},FlowChart.private.prototype.handlerTouchendClick=function(t){var e,r=t.target;if(r.hasAttribute("data-field-selector")&&(e=r.getAttribute("data-field-selector")),this.chart.svgElement!=r)for(;r&&r.hasAttribute;){if(r.hasAttribute("data-shape-id")){var o=r.getAttribute("data-shape-id"),a=this.chart.getShape(o);if(e)this.chart.editor.edit(a,e);else{c={event:t,shapeId:o};if(!1!==FlowChart.events.publish("shape-click",[this.chart,c])){var i=this.chart.editor.getFieldNames(a);i.length?this.chart.editor.edit(a,i[0]):this.chart.editor.edit(a),this.handlerShapeClick(o,t)}}return}if(r.hasAttribute("data-menu-item")){var s=r.getAttribute("data-menu-item");return this.chart.menuBar._.handlerClick(t,s,r),void this.chart.colorBar._.handlerClick(t,s,r)}if(r.hasAttribute("data-portshapebar-item-id")){for(var h=r.getAttribute("data-portshapebar-item-id");!r.hasAttribute("data-portsb-shape");)r=r.parentNode;o=r.getAttribute("data-portsb-shape");var l=r.getAttribute("data-portsb-port"),n=this.chart.ports.get(o,l);return void this.addNodeWithLink(n,h)}r=r.parentNode}else{this.chart.selectedShapes.clear();var c={event:t};FlowChart.events.publish("svg-click",[this.chart,c])}},FlowChart.private.prototype.handlerMouseenterOnLink=function(t,e){var r=e,o=FlowChart.private.getFirstPointIndexByMousePosition(t,this.chart.svgElement,r),a=FlowChart.direction.horizontal;r.points[o].x==r.points[o+1].x&&(a=FlowChart.direction.vertical),t.target.classList.remove("bfc-cursor-row-resize"),t.target.classList.remove("bfc-cursor-col-resize"),a==FlowChart.direction.vertical?t.target.classList.add("bfc-cursor-col-resize"):a==FlowChart.direction.horizontal&&t.target.classList.add("bfc-cursor-row-resize")},FlowChart.private.prototype.handlerMouseenterOnShape=function(t,e){var r=this;this.handlerMouseenterOnShapeTimeOut&&(clearTimeout(this.handlerMouseenterOnShapeTimeOut),this.handlerMouseenterOnShapeTimeOut=null),this.handlerMouseenterOnShapeTimeOut=setTimeout(function(){r.chart.selectedPortShape=e},700)},FlowChart.private.prototype.handlerMouseleaveOnLink=function(t){},FlowChart.private.prototype.handlerMouseleaveOnShape=function(t){this.chart.selectedPortShape=null,this.handlerMouseenterOnShapeTimeOut&&(clearTimeout(this.handlerMouseenterOnShapeTimeOut),this.handlerMouseenterOnShapeTimeOut=null)},FlowChart.private.prototype.handlerMouseenterOnPortOut=function(t,e){this.chart.selectedPort=e},FlowChart.private.prototype.handlerMouseleaveOnPortOut=function(t,e,r){},FlowChart.private.prototype.handlerMouseleaveOnMiniShapeBar=function(){this.chart.selectedPort=null,this.chart.selectedPortShape=null},FlowChart.Menu=class{_;element;constructor(t){this._=new FlowChart.Menu.private(t),this.element=null}init(){}hide(){null!=this.element&&(this.element.parentNode.removeChild(this.element),this.element=null)}show(t,e,r,o){var a=this;this.hide(),o||(o=this.menu);var i="";for(var s in o){var h=o[s].icon,l=o[s].text;void 0===h&&(h=FlowChart.icon[s]?FlowChart.icon[s](24,24,"#7A7A7A",0,0):""),"function"==typeof l&&(l=l()),"function"==typeof h&&(h=h()),i+=`<div data-item="${s}">${h}<span> ${l}</span></div>`}if(""!=i){if(this.element=document.createElement("div"),this.element.className="bfc-chart-menu",this.element.style.left="-99999px",this.element.style.top="-99999px",this.element.innerHTML=i,this._.chart.element.appendChild(this.element),null==e){var n=FlowChart.private.stickPosition(t,this.element,this._.chart.svgElement);t=n.x,e=n.y}var c=t+45;this.element.style.left=c+"px",this.element.style.top=e+"px",this.element.style.left=c-this.element.offsetWidth+"px";var p=t-this.element.offsetWidth;FlowChart.animate(this.element,{opacity:0,left:c-this.element.offsetWidth},{opacity:1,left:p},300,FlowChart.anim.inOutPow);for(var d=this.element.getElementsByTagName("div"),f=0;f<d.length;f++){(s=d[f]).addEventListener("click",function(t){var e,i=this.getAttribute("data-item");void 0===o[i].onClick||(e=o[i].onClick.call(a._.chart,{item:i,nodeId:r})),0!=e&&a.hide()})}}}},FlowChart.Menu.private=class{chart;constructor(t){this.chart=t}},FlowChart.private.prototype.handlerDownOnShapeBarItem=function(t,e,r){var o=this;this.chart.selectedShapes.clear();var a=r.getAttribute("data-shapebar-item-id"),i=this.chart.element.querySelector(`[data-shapebar-item-id="${a}"]`).querySelector("svg"),s=i.getBoundingClientRect(),h=o.chart.shapeBar.element.getBoundingClientRect(),l=FlowChart.private.getClientTouchesXY(t,0),n=s.width/(l.x-s.x),c=s.height/(l.y-s.y),p=function(f){var u=FlowChart.private.getClientTouchesXY(f,0);if(h.x<u.x&&h.x+h.width>u.x&&h.y<u.y&&h.y+h.height>u.y)!function(t){var e=o.chart.element.querySelector(".bfc-drag-inside-shapes-palette"),r=o.chart.svgElement.querySelector('[data-shape-id="drag-inside-canvas"]');e||((e=i.cloneNode(!0)).style.position="absolute",e.style.top=s.y+"px",e.style.left=s.x+"px",e.style.width=s.width+"px",e.style.height=s.height+"px",e.classList.add("bfc-drag-inside-shapes-palette"),o.chart.element.appendChild(e)),e.style.top=s.y+(t.y-l.y)+"px",e.style.left=s.x+(t.x-l.x)+"px",r&&r.parentNode.removeChild(r)}(u);else{var w=o.chart.svgElement.createSVGPoint();w.x=u.x,w.y=u.y,function(i){var s=o.chart.element.querySelector(".bfc-drag-inside-shapes-palette");if(!o.chart.svgElement.querySelector('[data-shape-id="drag-inside-canvas"]')){var h={templateId:a,x:i.x,y:i.y},l=FlowChart.shapeTemplates[h.templateId],f="fit"==l.width?l.minWidth:l.width,u="fit"==l.height?l.minHeight:l.height,w=f/n,m=u/c;isNaN(w)&&(w=r.offsetWidth/2),isNaN(m)&&(m=r.offsetHeight/2),h.x-=w-f/2,h.y-=m-u/2,o.chart.nodes.add(h),h=o.chart.nodes.get(h.id),o.chart.element.removeEventListener(e.move,p),o.chart.element.removeEventListener(e.up,d),e.leave&&o.chart.element.removeEventListener(e.leave,d),o.handlerTouchstartMousedownOnShape(t,e,h)}s&&s.parentNode.removeChild(s)}(w.matrixTransform(o.chart.svgElement.getScreenCTM().inverse()))}},d=function(t){var r=o.chart.element.querySelector(".bfc-drag-inside-shapes-palette");r&&r.parentNode.removeChild(r);var i=o.chart.svgElement.querySelector('[data-shape-id="drag-inside-canvas"]');if(i){var s=FlowChart._getBox(i,o.nodes);i.parentNode.removeChild(i),o.addNode({templateId:a,x:s.x1,y:s.y1})}FlowChart.private.removeAlignmentLineElements(o.chart.svgElement),o.chart.element.removeEventListener(e.move,p),o.chart.element.removeEventListener(e.up,d),e.leave&&o.chart.element.removeEventListener(e.leave,d)};this.chart.element.addEventListener(e.move,p,{passive:!0}),this.chart.element.addEventListener(e.up,d)},FlowChart.private.prototype.handlerTouchstartMousedownOnLink=function(t,e,r){if(!1!==FlowChart.events.publish("link-click",[this.chart,{linkId:r}])){var o=this;this.chart.selectedPortShape=null,this.chart.selectedShapes.clear();var a=this.chart.links.getById(r),i=this.chart.scale,s=JSON.parse(FlowChart.private.safeStringify(a.points)),h=FlowChart.private.getClientTouchesXY(t,0),l=FlowChart.private.getFirstPointIndexByMousePosition(t,this.chart.svgElement,a),n=FlowChart.direction.horizontal;a.points[l].x==a.points[l+1].x&&(n=FlowChart.direction.vertical);var c=function(t){var e=FlowChart.private.getClientTouchesXY(t,0);n==FlowChart.direction.horizontal?(a.points[l].y=(e.y-h.y+s[l].y*i)/i,a.points[l+1].y=(e.y-h.y+s[l+1].y*i)/i):n==FlowChart.direction.vertical&&(a.points[l].x=(e.x-h.x+s[l].x*i)/i,a.points[l+1].x=(e.x-h.x+s[l+1].x*i)/i)},p=function(t){o.chart.element.removeEventListener(e.move,c),o.chart.element.removeEventListener(e.up,p),e.leave&&o.chart.element.removeEventListener(e.leave,p)};this.chart.element.addEventListener(e.move,c,{passive:!0}),this.chart.element.addEventListener(e.up,p)}},FlowChart.private.prototype.handlerTouchstartMousedownOnPortOut=function(t,e,r){var o=e.getAttribute("data-port-out-port"),a=e.getAttribute("data-port-out-shape"),i=FlowChart.private.getClientTouchesXY(t,0),s=this.chart.svgElement.createSVGPoint();s.x=i.x,s.y=i.y,s=s.matrixTransform(this.chart.svgElement.getScreenCTM().inverse());var h={id:`psuedo${this.chart.generateId()}`,templateId:"psuedo",x:s.x,y:s.y};this.chart.nodes.add(h);var l=this.chart.nodes.get(h.id);this.chart.links.add({from:a,fromPort:o,to:h.id,templateId:"psuedo"}),this.handlerTouchstartMousedownOnShape(t,r,l,!0)},FlowChart.private.prototype.handlerTouchstartMousedownOnShape=function(t,e,r,o){var a=this,i=this.chart.scale;if(r.selectable&&this.chart.options.selectable){var s={mouseEvent:t,shape:r,oldValue:r.selected};if(this.matchedShortcuts.includes("select_multiple_nodes")){if(s.newValue=!r.selected,!1===FlowChart.events.publish("selected-shape-changing",[this.chart,s]))return;r.selected=!r.selected}else if(r.selected){if(s.newValue=!0,!1===FlowChart.events.publish("selected-shape-changing",[this.chart,s]))return}else{if(s.newValue=!0,!1===FlowChart.events.publish("selected-shape-changing",[this.chart,s]))return;this.chart.selectedShapes.clear(),r.selected=!0}var h={};for(var l of this.chart.selectedShapes){if(!l.movable)return;h[l.id]={x:l.x*i,y:l.y*i}}var n=FlowChart.private.getClientTouchesXY(t,0),c=0,p=0,d=null,f=function(t){a.chart.selectedPortShape=null,a.chart.selectedShapes._.hideUI();var e=FlowChart.private.getClientTouchesXY(t,0);for(var o of a.chart.selectedShapes)o.x=(e.x-n.x+h[o.id].x)/i,o.y=(e.y-n.y+h[o.id].y)/i;if("label"==r.type)c=(e.x-n.x)/i,p=(e.y-n.y)/i;else if("psuedo-node"==r.type){var s=a.chart.links.getByShape(r)[0],l=a.chart.ports.get(s.from,s.fromPort),f=Number.MAX_VALUE,u=null;for(var w of a.chart.ports)if(w.shape!=r&&w.shape!=l.shape){var m=Math.hypot(w.x-r.x,w.y-r.y);m<f&&(f=m,u=w)}if(FlowChart.MAGNET_PORT>f){if(s.element.style.visibility="hidden",!d){var C=u.shape.id,g=u.id;d=a.chart.links.add({from:s.from,fromPort:l.id,to:C,toPort:g,templateId:"psuedo"})}}else s.element.style.visibility="",d&&(a.chart.links.remove(d),d=null)}"node"==r.type&&FlowChart.private.magnet(a.chart.selectedShapes.nodes,a.chart.nodes,a.chart.svgElement,i)},u=function(t){"label"==r.type?(null==r.movex&&(r.movex=0),r.movex+=c,null==r.movey&&(r.movey=0),r.movey+=p):"psuedo-node"==r.type&&(a.chart.nodes.remove(r),d&&(d.templateId="rounded")),a.chart.selectedShapes._.showUI(),a.chart.selectedPortShape=r,FlowChart.private.removeAlignmentLineElements(a.chart.svgElement),a.chart.element.removeEventListener(e.move,f),a.chart.element.removeEventListener(e.up,u),e.leave&&a.chart.element.removeEventListener(e.leave,u)};this.chart.element.addEventListener(e.move,f,{passive:!0}),this.chart.element.addEventListener(e.up,u)}},FlowChart.private.prototype.handlerTouchstartMousedownOnResizeDot=function(t,e,r,o){var a=this;if(this.mouseActions.includes("resize-shape")||(this.mouseActions.push("resize-shape"),this.updateMatchedShortcuts(e)),this.matchedShortcuts.includes("resize_node")){for(var i=o.parentNode;!i.hasAttribute("data-selector-shape-id");)i=i.parentNode;var s=i.getAttribute("data-selector-shape-id"),h=this.chart.getShape(s),l=h.left,n=h.top,c=h.width,p=h.height,d=this.chart.scale,f=FlowChart.private.getClientTouchesXY(e,0),u=function(t){a.chart.selectedPortShape=null,a.chart.editor.clearFieldBorders();var e=FlowChart.private.getClientTouchesXY(t,0),r=e.x-f.x,i=f.y-e.y;r/=d,i/=d;var s=function(t){var e=h.height,o=h.width,s=h.top,d=h.left;if("top"==t?a.matchedShortcuts.includes("centered_resize_shape")?(e=p+2*i,s=n-i):(e=p+i,s=n-i):"bottom"==t?a.matchedShortcuts.includes("centered_resize_shape")?(e=p-2*i,s=n+i):e=p-i:"left"==t?a.matchedShortcuts.includes("centered_resize_shape")?(o=c-2*r,d=l+r):(o=c-r,d=l+r):"right"==t&&(a.matchedShortcuts.includes("centered_resize_shape")?(o=c+2*r,d=l-r):o=c+r),"top"==t||"bottom"==t)a.matchedShortcuts.includes("maintain_aspect_ratio_resize_shape")&&(o=o/h.height*e,a.matchedShortcuts.includes("centered_resize_shape")&&(d-=(o-h.width)/2));else if("left"==t||"right"==t){if(a.matchedShortcuts.includes("maintain_aspect_ratio_resize_shape"))e=e/h.width*o,a.matchedShortcuts.includes("centered_resize_shape")&&(s-=(e-h.height)/2)}var f=FlowChart.shapeTemplates[h.templateId];o>=f.minWidth&&o>=f.minHeight&&(h.width=o,h.height=e,h.x=d+h.width/2,h.y=s+h.height/2)},u=o.getAttribute("data-selector-dot-2");u==FlowChart.position.left?s("left"):u==FlowChart.position.right?s("right"):u==FlowChart.position.top?s("top"):u==FlowChart.position.bottom?s("bottom"):u==FlowChart.position.topLeft?(s("top"),s("left")):u==FlowChart.position.topRight?(s("top"),s("right")):u==FlowChart.position.bottomLeft?(s("bottom"),s("left")):u==FlowChart.position.bottomRight&&(s("bottom"),s("right")),FlowChart.private.magnetWhenResize(h,a.chart.nodes,a.chart.svgElement,o.getAttribute("data-selector-dot-2"),d)},w=function(t){var e=a.mouseActions.indexOf("resize-shape");-1!=e&&(a.mouseActions.splice(e,1),a.updateMatchedShortcuts(t)),FlowChart.private.removeAlignmentLineElements(a.chart.svgElement),a.chart.element.removeEventListener(r.move,u),a.chart.element.removeEventListener(r.up,w),r.leave&&a.chart.element.removeEventListener(r.leave,w)};this.chart.element.addEventListener(r.move,u,{passive:!0}),this.chart.element.addEventListener(r.up,w)}},FlowChart.private._mousedownOnSvgTimeout=null,FlowChart.private._mousedownOnSvgMovingStarted=!1,FlowChart.private.prototype.handlerTouchstartMousedownOnSvg=function(t,e,r,o){var a=this;FlowChart.private._mousedownOnSvgMovingStarted=!1,this.chart.selectedPortShape=null;var i=this.chart.viewBox,s=this.chart.scale,h=FlowChart.private.getClientTouchesXY(e,0),l=FlowChart.private.getClientTouchesXY(e,1),n={diffX:0,diffY:0,x0:h.x,y0:h.y,type:"pan",viewBoxLeft:i[0],viewBoxTop:i[1],viewBox:JSON.parse(FlowChart.private.safeStringify(i))};e.touches&&e.touches.length>1&&(n.type="pinch",n.dist=Math.sqrt((h.x-l.x)*(h.x-l.x)+(h.y-l.y)*(h.y-l.y))),"pan"==n.type&&a.chart.svgElement.classList.add("bfc-pan-cursor");var c=function(){setTimeout(function(){FlowChart.private._mousedownOnSvgMovingStarted=!1},50),n&&"pan"==n.type&&a.chart.svgElement.classList.remove("bfc-pan-cursor"),n=null};this.chart.svgElement.addEventListener(r.move,function(t){var e=FlowChart.private.getClientTouchesXY(t,0);if(n&&"pan"==n.type){t.preventDefault(),n.diffX=e.x-n.x0,n.diffY=e.y-n.y0;var r=-n.diffY/s+n.viewBoxTop,o=-n.diffX/s+n.viewBoxLeft;(Math.abs(n.diffX)>3||Math.abs(n.diffY)>3)&&(FlowChart.private._mousedownOnSvgMovingStarted=!0),i[0]=o,i[1]=r,FlowChart.private._mousedownOnSvgTimeout&&(clearTimeout(FlowChart.private._mousedownOnSvgTimeout),FlowChart.private._mousedownOnSvgTimeout=null),FlowChart.private._mousedownOnSvgTimeout=setTimeout(function(){a.chart.viewBox=i},3)}else if(n&&"pinch"==n.type){t.preventDefault(),FlowChart.private._mousedownOnSvgMovingStarted=!0,FlowChart.private._mousedownOnSvgTimeout&&(clearTimeout(FlowChart.private._mousedownOnSvgTimeout),FlowChart.private._mousedownOnSvgTimeout=null);var h=FlowChart.private.getClientTouchesXY(t,1),l=Math.sqrt((e.x-h.x)*(e.x-h.x)+(e.y-h.y)*(e.y-h.y)),c=1+(l-n.dist)/(n.dist/100)/100;n.dist=l;var p=FlowChart.private.pinchMiddlePointInPercent(a.element,a.svgBCR.width,a.svgBCR.height,t);a.zoom(c,p)}},{passive:!1}),this.chart.svgElement.addEventListener(r.up,c),this.chart.svgElement.addEventListener(r.leave,c)},FlowChart.private.prototype.handlerTouchstartMousedownOnBarMove=function(t,e,r,o){var a,i,s=this,h=FlowChart.private.getClientTouchesXY(e,0);o.parentNode.hasAttribute("data-shapebar")?(a=s.chart.shapeBar,i="shapebar-position"):o.parentNode.hasAttribute("data-colorbar")?(a=s.chart.colorBar,i="colorbar-position"):o.parentNode.hasAttribute("data-menubar")&&(a=s.chart.menuBar,i="menubar-position");var l=a.element.getBoundingClientRect(),n=function(t){var e=FlowChart.private.getClientTouchesXY(t,0),r=e.x-h.x+l.left,o=e.y-h.y+l.top,n=r-s.svgBCR.left;n<FlowChart.MAGNET_WIN_PIXELS&&n>-FlowChart.MAGNET_WIN_PIXELS&&(r=s.svgBCR.left);var c=s.svgBCR.right-(r+l.width);c<FlowChart.MAGNET_WIN_PIXELS&&c>-FlowChart.MAGNET_WIN_PIXELS&&(r=s.svgBCR.right-l.width);var p=o-s.svgBCR.top;p<FlowChart.MAGNET_WIN_PIXELS&&p>-FlowChart.MAGNET_WIN_PIXELS&&(o=s.svgBCR.top);var d=s.svgBCR.bottom-(o+l.height);d<FlowChart.MAGNET_WIN_PIXELS&&d>-FlowChart.MAGNET_WIN_PIXELS&&(o=s.svgBCR.bottom-l.height),a.element.style.right="unset",a.element.style.bottom="unset",a.element.style.left=r+"px",a.element.style.top=o+"px";var f={left:r,top:o};try{sessionStorage.setItem(i,FlowChart.private.safeStringify(f))}catch(t){t.code==t.QUOTA_EXCEEDED_ERR&&sessionStorage.clear(),console.error(t)}},c=function(t){s.chart.element.removeEventListener(r.move,n),s.chart.element.removeEventListener(r.up,c),r.leave&&s.chart.element.removeEventListener(r.leave,c)};this.chart.element.addEventListener(r.move,n,{passive:!0}),this.chart.element.addEventListener(r.up,c)},FlowChart.private.prototype.handlerMousewheel=function(t){if(this.mouseActions.includes("wheel")||(this.mouseActions.push("wheel"),this.updateMatchedShortcuts(t)),this.matchedShortcuts.includes("zoom")){this.chart.selectedPort=null;var e=this,r=!1,o=this.chart.options.zoom.speed,a=this.chart.options.zoom.smooth,i=0,s=this.chart.scale,h=FlowChart.private.centerPointInPercent(this.chart.svgElement,t.clientX,t.clientY);var l=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){setTimeout(t,20)};t.preventDefault();var n=t.delta||t.wheelDelta;void 0===n&&(n=-t.detail),n=Math.max(-1,Math.min(1,n)),i+=-n*o,r||function t(){r=!0;var o=(i-s)/a;o>0?o++:o--,s+=o,e.zoom(1-o/12/50,h),parseInt(s)==parseInt(i)?r=!1:l(t)}()}},FlowChart.private.prototype.handlerShapeClick=function(t,e){},FlowChart.private.prototype.handlerResizeOnSvgElement=function(){var t=this.chart.viewBox,e=this.chart.svgElement.getBoundingClientRect(),r=FlowChart.private.getScale(this.chart.viewBox,this.svgBCR.width,this.svgBCR.height);t[2]=e.width/r,t[3]=e.height/r,this.setViewBox(t),this.svgBCR=e},FlowChart.private.prototype.addListeners=function(){var t=this;new ResizeObserver(function(e){for(var r of e){if(!r.target.checkVisibility())return}t.handlerResizeOnSvgElement(e)}).observe(t.chart.svgElement),this.chart.options.interactive&&(document.addEventListener("click",function(e){if(e.target.hasAttribute&&e.target.hasAttribute("data-field-selector"))return t.chart.active;for(var r=e.target;r&&r!=t.chart.element;)r=r.parentNode;t.chart.active=r==t.chart.element}),this.chart.element.addEventListener("touchstart",function(e){t.touchendEnabledDevice=!0;t.handlerTouchstartMousedown(this,e,{move:"touchmove",up:"touchend",touchstart:"touchstart"})},{passive:!0}),this.chart.element.addEventListener("touchend",function(e){t.touchendEnabledDevice=!0,FlowChart.private._mousedownOnSvgMovingStarted||t.handlerTouchendClick(e)},{passive:!0}),this.chart.element.addEventListener("mousedown",function(e){if(!t.touchendEnabledDevice){t.handlerTouchstartMousedown(this,e,{move:"mousemove",up:"mouseup",leave:"mouseleave"})}t.touchendEnabledDevice&&setTimeout(function(){t.touchendEnabledDevice=!1},2e3)}),this.chart.element.addEventListener("wheel",function(e){t.handlerMousewheel(e)}),this.chart.element.addEventListener("mousemove",function(e){t.handlerMousemove(e)}),this.chart.element.addEventListener("mouseup",function(e){t.touchendEnabledDevice||FlowChart.private._mousedownOnSvgMovingStarted||t.handlerTouchendClick(e)}),this.chart.element.addEventListener("dragover",function(t){FlowChart.private.getParentElementWithAttribute(t.target,"data-drop-field")&&t.preventDefault()}),this.chart.element.addEventListener("drop",function(e){var r=FlowChart.private.getParentElementWithAttribute(e.target,"data-drop-field");if(r){e.preventDefault();for(var o=e.dataTransfer.items,a=0;a<o.length;a+=1)if("file"===o[a].kind&&o[a].type.match("^image/")){var i=o[a].getAsFile(),s=window.URL.createObjectURL(i);FlowChart.private.createImageElementForUpload(s,function(o){var a=r.getAttribute("data-drop-field"),i=FlowChart.private.getParentElementWithAttribute(e.target,"data-shape-id");i&&(shapeId=i.getAttribute("data-shape-id"),t.chart.getShape(shapeId)[a]=o)})}}}),this.chart.element.addEventListener("dblclick",function(e){t.handlerDblclick(e)}),document.addEventListener("keydown",function(e){!1!==t.chart.active&&t.handlerKeydown(e)}),document.addEventListener("input",function(e){t.handlerInput(e)}),document.addEventListener("keyup",function(e){t.handlerKeyup(e)}),document.addEventListener("contextmenu",function(t){}))},FlowChart.private.magnet=function(t,e,r,o){var a=FlowChart.MAGNET_MOVE_PIXELS/o;if(0!=t.length){var i=!1,s=!1;for(var h of(FlowChart.private.removeAlignmentLineElements(r),e)){var l=!1;for(var n of t)if(h==n){l=!0;break}if(!l)for(var n of t){if(Math.abs(n.left-h.left)<a&&n.left>=h.left-a&&n.left<=h.left+a){if(!i){var c=h.left+n.width/2-n.x;for(var p of t)p.x+=c;i=!0}if(Math.abs(n.left-h.left)<.5)(d=n.top)>(f=h.top)?d+=n.height:f+=h.height,FlowChart.private.addAlignmentLineElement(r,"side",h.left,d,h.left,f,o)}if(Math.abs(n.x-h.x)<a&&n.x>=h.x-a&&n.x<=h.x+a){if(!i){c=h.x-n.x;for(var p of t)p.x+=c;i=!0}if(Math.abs(n.x-h.x)<.5)(d=n.top)>(f=h.top)?d+=n.height:f+=h.height,FlowChart.private.addAlignmentLineElement(r,"center",h.x,d,h.x,f,o)}if(Math.abs(n.right-h.right)<a&&n.right>=h.right-a&&n.right<=h.right+a){if(!i){c=h.right-n.width/2-n.x;for(var p of t)p.x+=c;i=!0}var d,f;if(Math.abs(n.right-h.right)<.5)(d=n.top)>(f=h.top)?d+=n.height:f+=h.height,FlowChart.private.addAlignmentLineElement(r,"side",h.right,d,h.right,f,o)}if(Math.abs(n.top-h.top)<a&&n.top>=h.top-a&&n.top<=h.top+a){if(!s){c=h.top+n.height/2-n.y;for(var p of t)p.y+=c;s=!0}if(Math.abs(n.top-h.top)<.5)(u=n.left)>(w=h.left)?u+=n.width:w+=h.width,FlowChart.private.addAlignmentLineElement(r,"side",u,h.top,w,h.top,o)}if(Math.abs(n.y-h.y)<a&&n.y>=h.y-a&&n.y<=h.y+a){if(!s){c=h.y-n.y;for(var p of t)p.y+=c;s=!0}if(Math.abs(n.y-h.y)<.5)(u=n.left)>(w=h.left)?u+=n.width:w+=h.width,FlowChart.private.addAlignmentLineElement(r,"center",u,h.y,w,h.y,o)}if(Math.abs(n.bottom-h.bottom)<a&&n.bottom>=h.bottom-a&&n.bottom<=h.bottom+a){if(!s){c=h.bottom-n.height/2-n.y;for(var p of t)p.y+=c;s=!0}var u,w;if(Math.abs(n.bottom-h.bottom)<.5)(u=n.left)>(w=h.left)?u+=n.width:w+=h.width,FlowChart.private.addAlignmentLineElement(r,"side",u,h.bottom,w,h.bottom,o)}}}}},FlowChart.private.magnetWhenResize=function(t,e,r,o,a){var i=!1,s=!1,h=FlowChart.MAGNET_RESIZE_PIXELS/a;for(var l of(FlowChart.private.removeAlignmentLineElements(r),e))if(t!=l){if(Math.abs(t.left-l.left)<h&&t.left>=l.left-h&&t.left<=l.left+h)if(i||(t.width=t.right-l.left,t.x=l.left+t.width/2,i=!0),Math.abs(t.left-l.left)<.5)(p=t.top)>(d=l.top)?p+=t.height:d+=l.height,FlowChart.private.addAlignmentLineElement(r,"side",l.left,p,l.left,d,a);if(Math.abs(t.x-l.x)<h&&t.x>=l.x-h&&t.x<=l.x+h){if(o==FlowChart.position.left||o==FlowChart.position.topLeft||o==FlowChart.position.bottomLeft)i||(t.width=2*(t.right-l.x),t.x=l.x-t.width/2+t.width/2,i=!0);else if(!i){var n=2*(l.x-t.left),c=t.width;t.width=n,t.x+=(n-c)/2,i=!0}if(Math.abs(t.x-l.x)<.5)(p=t.top)>(d=l.top)?p+=t.height:d+=l.height,FlowChart.private.addAlignmentLineElement(r,"center",l.x,p,l.x,d,a)}if(Math.abs(t.right-l.right)<h&&t.right>=l.right-h&&t.right<=l.right+h){if(!i){n=l.right-t.left,c=t.width;t.width=n,t.x+=(n-c)/2,i=!0}var p,d;if(Math.abs(t.right-l.right)<.5)(p=t.top)>(d=l.top)?p+=t.height:d+=l.height,FlowChart.private.addAlignmentLineElement(r,"side",l.right,p,l.right,d,a)}if(Math.abs(t.top-l.top)<h&&t.top>=l.top-h&&t.top<=l.top+h)if(s||(t.height=t.bottom-l.top,t.y=l.top+t.height/2,s=!0),Math.abs(t.top-l.top)<.5)(w=t.left)>(m=l.left)?w+=t.width:m+=l.width,FlowChart.private.addAlignmentLineElement(r,"side",w,l.top,m,l.top,a);if(Math.abs(t.y-l.y)<h&&t.y>=l.y-h&&t.y<=l.y+h){if(o==FlowChart.position.top||o==FlowChart.position.topLeft||o==FlowChart.position.topRight)s||(t.height=2*(t.bottom-l.y),t.y=l.y-t.height/2+t.height/2,s=!0);else if(!s){var f=2*(l.y-t.top),u=t.height;t.height=f,t.y+=(f-u)/2,s=!0}if(Math.abs(t.y-l.y)<.5)(w=t.left)>(m=l.left)?w+=t.width:m+=l.width,FlowChart.private.addAlignmentLineElement(r,"center",w,l.y,m,l.y,a)}if(Math.abs(t.bottom-l.bottom)<h&&t.bottom>=l.bottom-h&&t.bottom<=l.bottom+h){if(!s){f=l.bottom-t.top,u=t.height;t.height=f,t.y+=(f-u)/2,s=!0}var w,m;if(Math.abs(t.bottom-l.bottom)<.5)(w=t.left)>(m=l.left)?w+=t.width:m+=l.width,FlowChart.private.addAlignmentLineElement(r,"side",w,l.bottom,m,l.bottom,a)}}},FlowChart.private.addAlignmentLineElement=function(t,e,r,o,a,i,s){var h=document.createElementNS("http://www.w3.org/2000/svg","line");return h.setAttribute("x1",r),h.setAttribute("x2",a),h.setAttribute("y1",o),h.setAttribute("y2",i),h.setAttribute("stroke-width",1/s),h.classList.add("bfc-alignment-line"),"center"==e?h.setAttribute("stroke-dasharray",`${15/s} ${15/s} ${2/s} ${15/s}`):"side"==e&&h.setAttribute("stroke-dasharray",`${10/s} ${20/s}`),t.appendChild(h),h},FlowChart.private.removeAlignmentLineElements=function(t){for(var e=t.querySelectorAll(".bfc-alignment-line"),r=0;r<e.length;r++)e[r].parentNode.removeChild(e[r])},FlowChart.anim=class{static inPow(t){return t<0?0:t>1?1:Math.pow(t,2)}static outPow(t){if(t<0)return 0;if(t>1)return 1;return-1*(Math.pow(t-1,2)+-1)}static inOutPow(t){if(t<0)return 0;if(t>1)return 1;if((t*=2)<1)return FlowChart.anim.inPow(t,2)/2;return-.5*(Math.pow(t-2,2)+-2)}static inSin(t){return t<0?0:t>1?1:1-Math.cos(t*(Math.PI/2))}static outSin(t){return t<0?0:t>1?1:Math.sin(t*(Math.PI/2))}static inOutSin(t){return t<0?0:t>1?1:-.5*(Math.cos(Math.PI*t)-1)}static inExp(t){return t<0?0:t>1?1:Math.pow(2,10*(t-1))}static outExp(t){return t<0?0:t>1?1:1-Math.pow(2,-10*t)}static inOutExp(t){return t<0?0:t>1?1:t<.5?.5*Math.pow(2,10*(2*t-1)):.5*(2-Math.pow(2,10*(-2*t+1)))}static inCirc(t){return t<0?0:t>1?1:-(Math.sqrt(1-t*t)-1)}static outCirc(t){return t<0?0:t>1?1:Math.sqrt(1-(t-1)*(t-1))}static inOutCirc(t){return t<0?0:t>1?1:t<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(2*t-2)*(2*t-2))+1)}static rebound(t){return t<0?0:t>1?1:t<1/2.75?1-7.5625*t*t:t<2/2.75?1-(7.5625*(t-1.5/2.75)*(t-1.5/2.75)+.75):t<2.5/2.75?1-(7.5625*(t-2.25/2.75)*(t-2.25/2.75)+.9375):1-(7.5625*(t-2.625/2.75)*(t-2.625/2.75)+.984375)}static inBack(t){return t<0?0:t>1?1:t*t*(2.70158*t-1.70158)}static outBack(t){return t<0?0:t>1?1:(t-1)*(t-1)*(2.70158*(t-1)+1.70158)+1}static inOutBack(t){return t<0?0:t>1?1:t<.5?4*t*t*(7.1898*t-2.5949)*.5:.5*((2*t-2)*(2*t-2)*(3.5949*(2*t-2)+2.5949)+2)}static impulse(t){var e=2*t;return e*Math.exp(1-e)}static expPulse(t){return Math.exp(-2*Math.pow(t,2))}},FlowChart.LinkCollection=class extends Array{_;constructor(t){super(),this._=new FlowChart.LinkCollection.private(t)}get last(){return this.length?this[this.length-1]:null}get first(){return this.length?this[0]:null}addRange(t){this._.chart._.snap();var e=this._.addRange(t);return this.push(...e),this._.chart._.changed({property:"links"}),e}add(t){return this.addRange([t])[0]}get(t,e,r,o){for(var a of(null==r&&(r=""),null==o&&(o=""),this))if(a.from==t&&a.to==e&&a.fromPort==r&&a.toPort==o)return a;return null}getById(t){for(var e of this)if(e.id==t)return e;return null}getByShape(t){var e=[];for(var r of this)r.from!=t.id&&r.to!=t.id||e.push(r);return e}clear(){this._.remove(this,this)}removeRange(t){this._.remove(t,this)}remove(t){this._.remove(t,this)}contains(t){for(var e of this)if(e==t)return!0;return!1}},FlowChart.LinkCollection.private=class{chart;metadata;constructor(t){this.chart=t,this.metadata={}}getProperty(t,e,r){if(null==t[e]){var o=FlowChart.linkTemplates[t.templateId];if(o[e]&&"function"!=typeof o[e])return o[e]}if("points"==e){if(t[e])return t[e];if(this.metadata[r.id]||(this.metadata[r.id]={}),null==this.metadata[r.id][e]){if("length"==e)return 0;if("points"==e)return[]}return this.metadata[r.id][e]}return Reflect.get(...arguments)}setProperty(t,e,r,o){var a=FlowChart.linkTemplates[t.templateId];if("length"==e&&(this.metadata[o.id]||(this.metadata[o.id]={}),this.metadata[o.id].length=r),"points"==e){for(var i=this,s=r,h=0;h<s.length;h++){var l=s[h],n=new Proxy(l,{set(e,r,a){for(var s of(e[r]=a,null==t.points&&(t.points=c),i.draw(o),i.chart.labels))if(s.from==o.from&&s.to==o.to&&s.fromPort==o.fromPort&&s.toPort==o.toPort){var h=FlowChart.private.getLabelXY(s,o);s.x=h.x,s.y=h.y}return!0}});s[h]=n}var c=new Proxy(s,{set:(t,e,r)=>(console.log(e),t[e]=r,i.draw(o),!0)});this.metadata[o.id]||(this.metadata[o.id]={}),void 0!==t.points&&delete t.points,this.metadata[o.id].points=c}else a[e]&&"function"!=typeof a[e]?(null!=t[e]&&a[e]==r&&delete t[e],a[e]!=r?t[e]=r:a[e]==r||FlowChart.isNEU(t[e])||(t[e]=r)):t[e]=r}addRange(t){var e=this,r=[];t||console.error("links are: "+t);for(var o=0;o<t.length;o++){var a=t[o];FlowChart.isNEU(a.from)&&console.error("link.from not defined!"),FlowChart.isNEU(a.to)&&console.error("link.to not defined!"),a.templateId||(a.templateId=FlowChart.DEFAULT_LINK_SHAPE_ID);var i={get(t,r,o){return"type"==r?"psuedo"==t.templateId?"psuedo-link":"link":"fromPort"==r&&FlowChart.isNEU(t.fromPort)||"toPort"==r&&FlowChart.isNEU(t.toPort)?"":"element"==r?e.chart.svgElement.querySelector(`[data-link-id="${o.id}"]`):"pathElement"==r?e.chart.svgElement.querySelector(`[data-link-id="${o.id}"] path`):"layer"==r&&FlowChart.isNEU(t.layer)?-3:"id"==r?`${o.from}${FlowChart.SEPARATOR}${o.fromPort}${FlowChart.SEPARATOR}${o.to}${FlowChart.SEPARATOR}${o.toPort}`:e.getProperty(...arguments)},set(t,r,o,a){if(t[r]==o)return!0;if("to"==r||"from"==r||"fromPort"==r||"toPort"==r||""==r||"templateId"==r||"points"!=r){var i=a.element;i&&i.parentNode.removeChild(i)}e.chart._.snap();var s=e.beforeIdChange(r,a);for(var h of(e.setProperty(t,r,o,a),e.afterIdChange(s,a),e.draw(a),e.chart.labels))if(h.from==a.from&&h.to==a.to&&h.fromPort==a.fromPort&&h.toPort==a.toPort){var l=FlowChart.private.getLabelXY(h,a);h.x=l.x,h.y=l.y}return e.chart._.changed({property:"links"}),!0}},s=new Proxy(a,i),h=a.points;if(!h){var l=this.chart.ports.getByLink(a);h=FlowChart.private.linkFromTo(l.fromShape,l.toShape,l.fromPort,l.toPort,this.chart)}for(var n=0;n<h.length;n++){var c=h[n],p=new Proxy(c,{set(t,r,o){for(var a of(t[r]=o,e.draw(s),e.chart.labels))if(a.from==s.from&&a.to==s.to&&a.fromPort==s.fromPort&&a.toPort==s.toPort){var i=FlowChart.private.getLabelXY(a,s);a.x=i.x,a.y=i.y}return!0}});h[n]=p}var d=new Proxy(h,{});this.setProperty(a,"points",d,s),this.draw(s),r.push(s)}return r}beforeIdChange(t,e){var r=null;return"to"!=t&&"from"!=t&&"fromPort"!=t&&"toPort"!=t||((r={from:e.from,to:e.to,fromPort:e.fromPort,toPort:e.toPort,metadata:null}).metadata=this.metadata[e.id],delete this.metadata[e.id]),r}afterIdChange(t,e){if(t){this.metadata[e.id]=t.metadata;var r=this.chart.ports.getByLink(e),o=FlowChart.private.linkFromTo(r.fromShape,r.toShape,r.fromPort,r.toPort,this.chart);for(var a of(e.points=o,this.chart.labels))a.from==t.from&&a.to==t.to&&a.fromPort==t.fromPort&&a.toPort==t.toPort&&(a.from=e.from,a.to=e.to,a.fromPort=e.fromPort,a.toPort=e.toPort)}}remove(t,e){var r=!1,o=[];if(Array.isArray(t))o=t;else if(t.type)o=[t];else for(var a of e)a.from!=t&&a.to!=t||o.push(a);for(var a of o)for(var i=e.length-1;i>=0;i--)if(e[i].from==a.from&&e[i].to==a.to){var s=a.element;for(var h of(s&&s.parentNode.removeChild(s),this.chart.labels))h.from==a.from&&h.to==a.to&&this.chart.labels.remove(h);r||(this.chart._.snap(),r=!0),e.splice(i,1);break}r&&this.chart._.changed({property:"links"})}getPathElementByLinkElement(t){var e=null;for(var r of t.children)if("path"==r.nodeName){e=r;break}return e||console.error("Cannot find path Element!"),e}draw(t){var e=this.chart.svgElement.querySelector(`[data-link-id="${t.id}"]`),r=FlowChart.linkTemplates[t.templateId];if(!e){var o=t.stroke.replace(/\W/g,"_"),a=`bfc_mstart_${t.templateId}_${o}`,i=`bfc_mend_${t.templateId}_${o}`;(e=document.createElementNS("http://www.w3.org/2000/svg","g")).setAttribute("data-link-id",t.id),e.classList.add("bfc-link"),e.classList.add(t.templateId),e.innerHTML=r.svg(t,a,i)+'<path d="" class="bfc-link-invisible"></path>',FlowChart.private.getLayer(this.chart.svgElement,t.layer).appendChild(e),this.chart.svgElement.querySelector(`[data-markers="${t.templateId}"]`)||(this.chart.svgElement.querySelector("defs").innerHTML+=`<g data-markers="${t.templateId}">\n ${r.markerStart}\n ${r.markerMid}\n ${r.markerEnd}\n </g>`)}var s=this.getPathElementByLinkElement(e),h=r.path(t);s.setAttribute("d",h),e.querySelector(".bfc-link-invisible").setAttribute("d",h);for(var l=0,n=0;n<t.points.length-1;n++){var c=t.points[n],p=t.points[n+1];l+=Math.hypot(p.x-c.x,p.y-c.y)}this.setProperty(t,"length",l,t)}},FlowChart.PortCollection=class{_;constructor(t){this._=new FlowChart.PortCollection.private(t)}[Symbol.iterator](){var t=this._.chart.nodes,e=this._.chart.labels,r=this,o=0,a=0,i=!1,s=null;return{next(){for(var h;!h&&!i;)if(o>e.length+t.length-1)i=!0;else{var l;l=o<t.length?t[o]:e[o-t.length];var n=FlowChart.shapeTemplates[l.templateId].ports(l);n?(null==s&&(s=Object.keys(n)),h=r.get(l.id,s[a])):s=[],++a>s.length-1&&(s=null,a=0,o++)}return{value:h,done:i}}}}getElement(t){return this._.getElement(t)}getByPosition(t,e){return this._.getByPosition(t,e)}getByOpositeOfPosition(t,e){return this._.getByOpositeOfPosition(t,e)}getByLink(t){return this._.getByLink(t)}get(t,e){return this._.get(t,e)}},FlowChart.PortCollection.private=class{chart;cachedPorts;constructor(t){this.chart=t,this.cachedPorts=[]}getElement(t){return this.chart.svgElement.querySelector(`[data-ports-s-id="${t}"]`)}getByPosition(t,e){var r=FlowChart.shapeTemplates[t.templateId],o=[];for(var a in r.ports(t)){FlowChart.private.getPortPosition(r.ports(t)[a],t)==e&&o.push(this.get(t.id,a))}return o}getByOpositeOfPosition(t,e){var r=null;switch(e){case FlowChart.position.topRight:r=FlowChart.position.bottomLeft;break;case FlowChart.position.bottomRight:r=FlowChart.position.topLeft;break;case FlowChart.position.bottomLeft:r=FlowChart.position.topRight;break;case FlowChart.position.topLeft:r=FlowChart.position.bottomRight;break;case FlowChart.position.left:r=FlowChart.position.right;break;case FlowChart.position.right:r=FlowChart.position.left;break;case FlowChart.position.top:r=FlowChart.position.bottom;break;case FlowChart.position.bottom:r=FlowChart.position.top}var o=this.chart.getShape(t);return this.getByPosition(o,r)}getByLink(t){var e,r,o,a,i;return e=this.chart.getShape(t.from),FlowChart.isNEU(t.fromPort)||(o=this.get(t.from,t.fromPort)),r=this.chart.getShape(t.to),FlowChart.isNEU(t.toPort)||(a=this.get(t.to,t.toPort)),o&&a||(i=FlowChart.private.findClosestPorts(e,r),o||(o=this.get(t.from,i.fromPortName)),a||(a=this.get(t.to,i.toPortName))),{fromShape:e,toShape:r,fromPort:o,toPort:a}}get(t,e){var r=this.chart.getShape(t),o=FlowChart.shapeTemplates[r.templateId],a=FlowChart.private.getPortPosition(o.ports(r)[e],r),i=JSON.parse(FlowChart.private.safeStringify(o.ports(r)[e]));if(!i)return null;for(var s of(i.id=e,i.x+=r.left,i.y+=r.top,i.position=a,i.shape=r,this.cachedPorts))if(s.id==i.id&&s.shape==i.shape)return s.x=i.x,s.y=i.y,s.position=i.position,s;return this.cachedPorts.push(i),i}},FlowChart.css=function(){return'<style data-bfc-styles>.bfc-dark ::-webkit-scrollbar,.bfc-light ::-webkit-scrollbar{width:15px;height:15px}.bfc-dark ::-webkit-scrollbar-corner{background:#1e1e1e}.bfc-dark ::-webkit-scrollbar-track{background:#1e1e1e;border-left:1px solid #333;border-top:1px solid #333}.bfc-dark ::-webkit-scrollbar-thumb{background:#424242}.bfc-dark ::-webkit-scrollbar-thumb:hover{background:#4f4f4f}.bfc-dark ::-webkit-scrollbar-thumb:active{background:#5e5e5e}.bfc-light ::-webkit-scrollbar-corner{background:#fff}.bfc-light ::-webkit-scrollbar-track{background:#fff;border-left:1px solid #ddd;border-top:1px solid #ddd}.bfc-light ::-webkit-scrollbar-thumb{background:#c1c1c1}.bfc-light ::-webkit-scrollbar-thumb:hover{background:#929292}.bfc-light ::-webkit-scrollbar-thumb:active{background:#666}.bfc-controls{display:flex;gap:7px;position:absolute}.bfc-controls-top{left:unset;top:15px;right:50%;bottom:unset;transform:translateX(50%);flex-direction:row}.bfc-controls-bottom{left:unset;top:unset;right:50%;bottom:15px;transform:translateX(50%);flex-direction:row}.bfc-controls-left{left:15px;top:50%;right:unset;bottom:unset;transform:translateY(-50%);flex-direction:column}.bfc-controls-right{left:unset;top:50%;right:15px;bottom:unset;transform:translateY(-50%);flex-direction:column}.bfc-controls-bottom_right,.bfc-controls-right_bottom{left:unset;top:unset;right:15px;bottom:15px;flex-direction:row}.bfc-controls-right_bottom{flex-direction:column}.bfc-controls-right_top,.bfc-controls-top_right{left:unset;top:15px;right:15px;bottom:unset;flex-direction:row}.bfc-controls-right_top{flex-direction:column}.bfc-controls-bottom_left,.bfc-controls-left_bottom{left:15px;top:unset;right:unset;bottom:15px;flex-direction:row}.bfc-controls-left_bottom{flex-direction:column}.bfc-controls-left_top,.bfc-controls-top_left{left:15px;top:15px;right:unset;bottom:unset;flex-direction:row}.bfc-controls-left_top{flex-direction:column}.bfc-controls [data-control-id] svg{display:block;margin:0 auto}.bfc-controls [data-control-id]{display:flex;align-items:center;cursor:pointer;width:60px;height:60px;border-radius:30px;box-shadow:0 4px 30px rgba(0,0,0,.1);backdrop-filter:blur(5px);-webkit-backdrop-filter:blur(5px)}.bfc-light .bfc-controls [data-control-id]{background:rgba(255,255,255,.2);border:1px solid #c7c7c7}.bfc-dark .bfc-controls [data-control-id]{background:rgba(30,30,30,.2);border:1px solid #5b5b5b}.bfc-controls [data-control-id]:hover{background-color:#0074e8}.bfc-controls [data-control-id]:hover svg{filter:brightness(0) invert(1)}.bfc-controls [data-control-id].bfc-control-selected{background-color:#0074e8}.bfc-controls [data-control-id].bfc-control-selected svg{filter:brightness(0) invert(1)}.frame{display:flex;flex-direction:column}.bfc-svg{overflow-y:scroll;flex-grow:1}.bfc-light{background-color:#fff}.bfc-dark{background-color:#1e1e1e}.bfc-light .bfc-statusbar{background-color:#ddd}.bfc-dark .bfc-statusbar{background-color:#3c3c3c}.bfc-statusbar{user-select:none;line-height:32px;padding:0 7px;white-space:nowrap}.bfc-content{overflow:hidden;position:relative;height:100%}.bfc-canvas{overflow:auto;height:100%}.bfc-dark,.bfc-light{font:18px "Segoe UI",Arial,sans-serif}.bfc-light{color:#333}.bfc-dark{color:#cfcfcf}.bfc-menu-item{display:inline-block}.bfc-shapebar{position:absolute;top:64px;left:10px;max-width:60px;user-select:none}.bfc-dark .bfc-shapebar{background-color:#3c3c3c}.bfc-light .bfc-shapebar{background-color:#ddd}.bfc-shapebar-shapes{justify-content:flex-start;flex-wrap:wrap;display:flex;flex-wrap:wrap}.bfc-shapebar-shapes>[data-shapebar-item-id]{padding:7px 0;font-size:13px;text-align:center;user-select:none;cursor:move;flex:1 1 50px;min-height:50px;display:flex;flex-wrap:nowrap;flex-direction:column;justify-content:center}.bfc-colorbar{position:absolute;top:10px;right:10px;width:44px;user-select:none}.bfc-dark .bfc-colorbar{background-color:#3c3c3c}.bfc-light .bfc-colorbar{background-color:#ddd}.bfc-colorbar-colors{justify-content:flex-start;flex-wrap:wrap;display:flex;flex-wrap:wrap}.bfc-colorbar-colors>[data-colorbar-item-id]{padding:7px 0;font-size:13px;text-align:center;user-select:none;cursor:move;flex:1 1 50px;min-height:50px;display:flex;flex-wrap:nowrap;flex-direction:column;justify-content:center}.bfc-menubar{position:absolute;top:10px;left:10px;user-select:none}.bfc-dark .bfc-menubar{background-color:#3c3c3c}.bfc-light .bfc-menubar{background-color:#ddd}.bfc-menubar-colors{justify-content:flex-start;flex-wrap:wrap;display:flex;flex-wrap:wrap}.bfc-menubar-colors>[data-menubar-item-id]{padding:7px 0;font-size:13px;text-align:center;user-select:none;cursor:move;flex:1 1 50px;min-height:50px;display:flex;flex-wrap:nowrap;flex-direction:column;justify-content:center}.bfc-bar-move{cursor:move;height:10px;width:100%}.bfc-dark .bfc-bar-move{background-color:#3c3c3c}.bfc-light .bfc-bar-move{background-color:#ddd}.bfc-bar-move-line{border-top:1px solid #8b8b8b;border-bottom:1px solid #8b8b8b;height:5px;margin-top:3px;margin-left:3px;margin-right:3px}.bfc-dark .bfc-shapebar-shapes>[data-shapebar-item-id]:hover{background-color:#252526}.bfc-light .bfc-shapebar-shapes>[data-shapebar-item-id]:hover{background-color:#f3f3f3}.bfc-alignment-line{stroke:#ffca28}.bfc-selector .bfc-selector-rect{fill:none;stroke:#ffca28}[data-selector-dot-1]{fill:#ffca28;stroke:#ffca28;stroke-width:1;transform-origin:center;transform-box:fill-box}.bfc-c-resizer-dot{stroke:#ffca28;stroke-width:2}.bfc-light .bfc-c-resizer-dot{fill:#fff}.bfc-dark .bfc-c-resizer-dot{fill:#1e1e1e}[data-selector-dot-2=left]{cursor:ew-resize}[data-selector-dot-2=topRight]{cursor:nwse-resize}[data-selector-dot-2=top]{cursor:ns-resize}[data-selector-dot-2=topRight]{cursor:nesw-resize}[data-selector-dot-2=right]{cursor:ew-resize}[data-selector-dot-2=bottomRight]{cursor:nwse-resize}[data-selector-dot-2=bottom]{cursor:ns-resize}[data-selector-dot-2=bottomLeft]{cursor:nesw-resize}[data-selector-dot-2=topLeft]{cursor:nwse-resize}[data-selector-dot-2]{pointer-events:all;visibility:hidden;transform-origin:center;transform-box:fill-box}.bfc-flex-center{display:flex;justify-content:center;align-items:center;height:100%;color:#fff;text-align:center}.bfc-port-dot{cursor:default}.bfc-port-dot circle{stroke:#f57c00;stroke-width:1}.bfc-light .bfc-port-dot{fill:#fff}.bfc-dark .bfc-port-dot{fill:#151515}.bfc-port-dot rect{opacity:0}.bfc-html{user-select:none;overflow:visible}.bfc-pan-cursor{cursor:move}.bfc-shapebar-svg{margin:0 5px;max-width:50px}.bfc-cursor-row-resize{cursor:row-resize}.bfc-cursor-col-resize{cursor:col-resize}.bfc-link-invisible{stroke-width:10;fill:none;stroke:#aeaeae;stroke-miterlimit:10;visibility:hidden;pointer-events:stroke}.bfc-link-resizer{cursor:row-resize}.bfc-s-ports>g{transform-box:fill-box;transform-origin:center}.bfc-port-out{opacity:.3}.bfc-port-out:hover{opacity:1}.bfc-portshapebar{position:absolute;top:500px;left:100px;justify-content:flex-start;flex-wrap:wrap;display:flex;gap:7px;padding:7px;border-radius:7px}.bfc-portshapebar>[data-portshapebar-item-id]{text-align:center;user-select:none;flex:1 1 25px;display:flex;flex-wrap:nowrap;flex-direction:column;justify-content:center;filter:grayscale(1)}.bfc-portshapebar>[data-portshapebar-item-id].bfc-portshapebar-selected,.bfc-portshapebar>[data-portshapebar-item-id]:hover{filter:grayscale(0)}.bfc-portshapebar-svg{width:25px}.bfc-light .bfc-portshapebar{background-color:#ddd}.bfc-dark .bfc-portshapebar{background-color:#3c3c3c}[contenteditable]{outline:0 solid transparent}.bfc-light .bfc-label{fill:#fff}.bfc-dark .bfc-label{fill:#1e1e1e}.bfc-ports-invisible .bfc-port-out{visibility:hidden}.bfc-ports-invisible .bfc-port-out.bfc-ports-visible{visibility:visible;opacity:1}.bfc-color-item{border-radius:3px;color:#fff;display:flex;justify-content:center;align-items:center;user-select:none}.bfc-menu-item{display:inline-block}.bfc-menu-item>*{margin:7px;width:30px;height:30px;vertical-align:middle}.bfc-dark .bfc-menu-item-selected,.bfc-dark :not(.bfc-disabled-grayscale):not(.bfc-disabled-opacity).bfc-menu-item:hover{background-color:#252526}.bfc-light .bfc-menu-item-selected,.bfc-light :not(.bfc-disabled-grayscale):not(.bfc-disabled-opacity).bfc-menu-item:hover{background-color:#fff}.bfc-disabled-opacity{opacity:.3}.bfc-disabled-grayscale{filter:grayscale(1)}[data-shape-id]{user-select:none}.bfc-field-border{fill:transparent;stroke:#ffca28;stroke-width:2px;stroke-dasharray:4;cursor:pointer}.bfc-horizontal-bar{display:flex}.bfc-horizontal-bar .bfc-bar-move{width:10px;height:44px;padding-bottom:0}.bfc-horizontal-bar .bfc-bar-content{flex-grow:1}.bfc-horizontal-bar .bfc-bar-move-line{border-top:none;border-bottom:none;border-left:1px solid #8b8b8b;border-right:1px solid #8b8b8b;height:calc(100% - 6px);margin-right:0;margin-left:3px;margin-top:3px;margin-bottom:3px}.bfc-dark,.bfc-light{position:relative;overflow:hidden}@-moz-keyframes bfc-ripple{to{opacity:0;transform:scale(2)}}@-webkit-keyframes bfc-ripple{to{opacity:0;transform:scale(2)}}@-o-keyframes bfc-ripple{to{opacity:0;transform:scale(2)}}@keyframes bfc-ripple{to{opacity:0;transform:scale(2)}}.bfc-chart-menu{opacity:0;display:inline-block;position:absolute;text-align:left;user-select:none;min-width:270px;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0,rgba(0,0,0,.19) 0 6px 20px 0;font:13px/28px Helvetica,"Segoe UI",Arial,sans-serif;border-radius:10px}.bfc-chart-menu>div:hover img{filter:invert(100%)}.bfc-chart-menu [data-item]{text-align:start;padding:7px 10px}.bfc-dark .bfc-chart-menu [data-item]{background-color:#252526;color:#acacac;border-bottom:1px solid #333}.bfc-dark .bfc-chart-menu [data-item]:hover{background-color:#094771!important;color:#fff!important}.bfc-dark .bfc-chart-menu [data-item]:hover svg{filter:brightness(0) invert(1)}.bfc-light .bfc-chart-menu [data-item]{background-color:#fff;color:#333;border-bottom:1px solid #c7c7c7}.bfc-light .bfc-chart-menu [data-item]:hover{background-color:#0074e8!important;color:#fff!important}.bfc-light .bfc-chart-menu [data-item]:hover svg{filter:brightness(0) invert(1)}.bfc-chart-menu [data-item] svg{vertical-align:middle}.bfc-chart-menu [data-item]:first-child{border-top-left-radius:7px;border-top-right-radius:7px}.bfc-chart-menu [data-item]:last-child{border-bottom-width:0;border-bottom-style:none;border-bottom-left-radius:7px;border-bottom-right-radius:7px}</style>'},FlowChart.private.prototype.json=function(t){return JSON.parse(this.text(t))},FlowChart.private.prototype.text=function(t){t||(t=["shapes","links"]);var e={};for(var r of t)switch(r){case"shapes":e.nodes=this.chart.nodes,e.labels=this.chart.labels;break;case"nodes":e.nodes=this.chart.nodes;break;case"labels":e.labels=this.chart.labels;break;case"links":e.links=this.chart.links;break;case"selectedShapes":for(var o of(e.selectedShapes=[],this.chart.selectedShapes))e.selectedShapes.push(o.id);break;case"viewBox":e.viewBox=this.chart.viewBox}return FlowChart.private.safeStringify(e)},FlowChart.private.prototype.svg=function(){var t=document.createElement("div");t.innerHTML=this.chart.svgElement.outerHTML;for(var e=t.querySelector("svg"),r=this.chart.nodes,o={left:r.left-FlowChart.PADDING,top:r.top-FlowChart.PADDING,right:r.right+FlowChart.PADDING,bottom:r.bottom+FlowChart.PADDING},a=e.querySelectorAll("foreignObject"),i=0;i<a.length;i++)a[i].parentNode.removeChild(a[i]);return e.setAttribute("viewBox",[o.left,o.top,o.right-o.left,o.bottom-o.top]),e.setAttribute("width",o.right-o.left),e.setAttribute("height",o.bottom-o.top),e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),e.querySelector("defs").innerHTML+=FlowChart.css(),t.innerHTML.replaceAll("\n","").replaceAll("\t","")},FlowChart.events=class{static topics={};static on(t,e,r){Array.isArray(FlowChart.events.topics[t])||(FlowChart.events.topics[t]=[]),FlowChart.events.topics[t].push({listener:e,uid:r})}static removeAll(t){Array.isArray(FlowChart.events.topics[t])||(FlowChart.events.topics[t]=[]),FlowChart.events.topics[t]=[]}static has(t,e){if(Array.isArray(FlowChart.events.topics[t])&&FlowChart.events.topics[t].length>0){if(FlowChart.isNEU(e))return!0;for(var r=0;r<FlowChart.events.topics[t].length;r++)if(FlowChart.events.topics[t][r].uid==e)return!0}return!1}static removeForEventId(t){for(var e in FlowChart.events.topics)if(Array.isArray(FlowChart.events.topics[e]))for(var r=FlowChart.events.topics[e].length-1;r>=0;r--)FlowChart.events.topics[e][r].uid==t&&FlowChart.events.topics[e].splice(r,1)}static publish(t,e){if(FlowChart.events.topics[t]){for(var r=[],o=0;o<FlowChart.events.topics[t].length;o++){var a=FlowChart.events.topics[t][o];null!=a&&null!=a.uid&&a.uid!=e[0].uid&&a.uid!=e[0]._.uid||r.push(a.listener)}if(r.length>0){var i=!0;for(o=0;o<r.length&&(1==e.length?i=r[o](e[0])&&i:2==e.length?i=r[o](e[0],e[1])&&i:3==e.length?i=r[o](e[0],e[1],e[2])&&i:4==e.length?i=r[o](e[0],e[1],e[2],e[3])&&i:5==e.length&&(i=r[o](e[0],e[1],e[2],e[3],e[4])&&i),!1!==i);o++);return i}}}},FlowChart.icon=class{static png(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 550.801 550.801">\n <path fill="${r}" d="M146.747,276.708c0-13.998-9.711-22.352-26.887-22.352c-6.99,0-11.726,0.675-14.204,1.355v44.927 c2.932,0.676,6.539,0.896,11.52,0.896C135.449,301.546,146.747,292.28,146.747,276.708z"/>\n <path fill="${r}" d="M488.426,197.019H475.2v-63.816c0-0.398-0.063-0.799-0.116-1.202c-0.021-2.534-0.827-5.023-2.562-6.995L366.325,3.694 c-0.032-0.031-0.063-0.042-0.085-0.076c-0.633-0.707-1.371-1.295-2.151-1.804c-0.231-0.155-0.464-0.285-0.706-0.419 c-0.676-0.369-1.393-0.675-2.131-0.896c-0.2-0.056-0.38-0.138-0.58-0.19C359.87,0.119,359.037,0,358.193,0H97.2 c-11.918,0-21.6,9.693-21.6,21.601v175.413H62.377c-17.049,0-30.873,13.818-30.873,30.873v160.545 c0,17.043,13.824,30.87,30.873,30.87h13.224V529.2c0,11.907,9.682,21.601,21.6,21.601h356.4c11.907,0,21.6-9.693,21.6-21.601 V419.302h13.226c17.044,0,30.871-13.827,30.871-30.87v-160.54C519.297,210.838,505.47,197.019,488.426,197.019z M97.2,21.605 h250.193v110.513c0,5.967,4.841,10.8,10.8,10.8h95.407v54.108H97.2V21.605z M234.344,335.86v45.831h-31.601V229.524h40.184 l31.611,55.759c9.025,16.031,18.064,34.983,24.825,52.154h0.675c-2.257-20.103-2.933-40.643-2.933-63.44v-44.473h31.614v152.167 h-36.117l-32.516-58.703c-9.049-16.253-18.971-35.892-26.438-53.727l-0.665,0.222C233.906,289.58,234.344,311.027,234.344,335.86z M71.556,381.691V231.56c10.613-1.804,25.516-3.159,46.506-3.159c21.215,0,36.353,4.061,46.509,12.192 c9.698,7.673,16.255,20.313,16.255,35.219c0,14.897-4.959,27.549-13.999,36.123c-11.738,11.063-29.123,16.031-49.441,16.031 c-4.522,0-8.593-0.231-11.736-0.675v54.411H71.556V381.691z M453.601,523.353H97.2V419.302h356.4V523.353z M485.652,374.688 c-10.61,3.607-30.713,8.585-50.805,8.585c-27.759,0-47.872-7.003-61.857-20.545c-13.995-13.1-21.684-32.97-21.452-55.318 c0.222-50.569,37.03-79.463,86.917-79.463c19.644,0,34.783,3.829,42.219,7.446l-7.214,27.543c-8.369-3.617-18.752-6.55-35.458-6.55 c-28.656,0-50.341,16.256-50.341,49.22c0,31.382,19.649,49.892,47.872,49.892c7.895,0,14.218-0.901,16.934-2.257v-31.835h-23.493 v-26.869h56.679V374.688z"/>\n </svg>`}static pdf(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 550.801 550.801">\n <path fill="${r}" d="M160.381,282.225c0-14.832-10.299-23.684-28.474-23.684c-7.414,0-12.437,0.715-15.071,1.432V307.6 c3.114,0.707,6.942,0.949,12.192,0.949C148.419,308.549,160.381,298.74,160.381,282.225z"/>\n <path fill="${r}" d="M272.875,259.019c-8.145,0-13.397,0.717-16.519,1.435v105.523c3.116,0.729,8.142,0.729,12.69,0.729 c33.017,0.231,54.554-17.946,54.554-56.474C323.842,276.719,304.215,259.019,272.875,259.019z"/>\n <path fill="${r}" d="M488.426,197.019H475.2v-63.816c0-0.398-0.063-0.799-0.116-1.202c-0.021-2.534-0.827-5.023-2.562-6.995L366.325,3.694 c-0.032-0.031-0.063-0.042-0.085-0.076c-0.633-0.707-1.371-1.295-2.151-1.804c-0.231-0.155-0.464-0.285-0.706-0.419 c-0.676-0.369-1.393-0.675-2.131-0.896c-0.2-0.056-0.38-0.138-0.58-0.19C359.87,0.119,359.037,0,358.193,0H97.2 c-11.918,0-21.6,9.693-21.6,21.601v175.413H62.377c-17.049,0-30.873,13.818-30.873,30.873v160.545 c0,17.043,13.824,30.87,30.873,30.87h13.224V529.2c0,11.907,9.682,21.601,21.6,21.601h356.4c11.907,0,21.6-9.693,21.6-21.601 V419.302h13.226c17.044,0,30.871-13.827,30.871-30.87v-160.54C519.297,210.838,505.47,197.019,488.426,197.019z M97.2,21.605 h250.193v110.513c0,5.967,4.841,10.8,10.8,10.8h95.407v54.108H97.2V21.605z M362.359,309.023c0,30.876-11.243,52.165-26.82,65.333 c-16.971,14.117-42.82,20.814-74.396,20.814c-18.9,0-32.297-1.197-41.401-2.389V234.365c13.399-2.149,30.878-3.346,49.304-3.346 c30.612,0,50.478,5.508,66.039,17.226C351.828,260.69,362.359,280.547,362.359,309.023z M80.7,393.499V234.365 c11.241-1.904,27.042-3.346,49.296-3.346c22.491,0,38.527,4.308,49.291,12.928c10.292,8.131,17.215,21.534,17.215,37.328 c0,15.799-5.25,29.198-14.829,38.285c-12.442,11.728-30.865,16.996-52.407,16.996c-4.778,0-9.1-0.243-12.435-0.723v57.67H80.7 V393.499z M453.601,523.353H97.2V419.302h356.4V523.353z M484.898,262.127h-61.989v36.851h57.913v29.674h-57.913v64.848h-36.593 V232.216h98.582V262.127z"/>\n </svg>`}static svg(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 550.801 550.801">\n <path fill="${r}" d="M488.426,197.019H475.2v-63.816c0-0.398-0.063-0.799-0.116-1.202c-0.021-2.534-0.827-5.023-2.562-6.995L366.325,3.694 c-0.032-0.031-0.063-0.042-0.085-0.076c-0.633-0.707-1.371-1.295-2.151-1.804c-0.231-0.155-0.464-0.285-0.706-0.419 c-0.676-0.369-1.393-0.675-2.131-0.896c-0.2-0.056-0.38-0.138-0.58-0.19C359.87,0.119,359.037,0,358.193,0H97.2 c-11.918,0-21.6,9.693-21.6,21.601v175.413H62.377c-17.049,0-30.873,13.818-30.873,30.873v160.545 c0,17.043,13.824,30.87,30.873,30.87h13.224V529.2c0,11.907,9.682,21.601,21.6,21.601h356.4c11.907,0,21.6-9.693,21.6-21.601 V419.302h13.226c17.044,0,30.871-13.827,30.871-30.87v-160.54C519.297,210.838,505.47,197.019,488.426,197.019z M97.2,21.605 h250.193v110.513c0,5.967,4.841,10.8,10.8,10.8h95.407v54.108H97.2V21.605z M338.871,225.672L284.545,386.96h-42.591 l-51.69-161.288h39.967l19.617,68.196c5.508,19.143,10.531,37.567,14.36,57.67h0.717c4.061-19.385,9.089-38.527,14.592-56.953 l20.585-68.918h38.77V225.672z M68.458,379.54l7.415-30.153c9.811,5.021,24.888,10.051,40.439,10.051 c16.751,0,25.607-6.935,25.607-17.465c0-10.052-7.662-15.795-27.05-22.734c-26.8-9.328-44.263-24.168-44.263-47.611 c0-27.524,22.971-48.579,61.014-48.579c18.188,0,31.591,3.823,41.159,8.131l-8.126,29.437c-6.465-3.116-17.945-7.657-33.745-7.657 c-15.791,0-23.454,7.183-23.454,15.552c0,10.296,9.089,14.842,29.917,22.731c28.468,10.536,41.871,25.365,41.871,48.094 c0,27.042-20.812,50.013-65.09,50.013C95.731,389.349,77.538,384.571,68.458,379.54z M453.601,523.353H97.2V419.302h356.4V523.353z M488.911,379.54c-11.243,3.823-32.537,9.103-53.831,9.103c-29.437,0-50.73-7.426-65.57-21.779 c-14.839-13.875-22.971-34.942-22.738-58.625c0.253-53.604,39.255-84.235,92.137-84.235c20.81,0,36.852,4.073,44.74,7.896 l-7.657,29.202c-8.859-3.829-19.849-6.95-37.567-6.95c-30.396,0-53.357,17.233-53.357,52.173c0,33.265,20.81,52.882,50.73,52.882 c8.375,0,15.072-0.96,17.94-2.395v-33.745h-24.875v-28.471h60.049V379.54L488.911,379.54z" />\n </svg>`}static csv(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 548.29 548.291" >\n <path fill="${r}" d="M486.2,196.121h-13.164V132.59c0-0.399-0.064-0.795-0.116-1.2c-0.021-2.52-0.824-5-2.551-6.96L364.656,3.677 c-0.031-0.034-0.064-0.044-0.085-0.075c-0.629-0.707-1.364-1.292-2.141-1.796c-0.231-0.157-0.462-0.286-0.704-0.419 c-0.672-0.365-1.386-0.672-2.121-0.893c-0.199-0.052-0.377-0.134-0.576-0.188C358.229,0.118,357.4,0,356.562,0H96.757 C84.893,0,75.256,9.649,75.256,21.502v174.613H62.093c-16.972,0-30.733,13.756-30.733,30.73v159.81 c0,16.966,13.761,30.736,30.733,30.736h13.163V526.79c0,11.854,9.637,21.501,21.501,21.501h354.777 c11.853,0,21.502-9.647,21.502-21.501V417.392H486.2c16.966,0,30.729-13.764,30.729-30.731v-159.81 C516.93,209.872,503.166,196.121,486.2,196.121z M96.757,21.502h249.053v110.006c0,5.94,4.818,10.751,10.751,10.751h94.973v53.861 H96.757V21.502z M258.618,313.18c-26.68-9.291-44.063-24.053-44.063-47.389c0-27.404,22.861-48.368,60.733-48.368 c18.107,0,31.447,3.811,40.968,8.107l-8.09,29.3c-6.43-3.107-17.862-7.632-33.59-7.632c-15.717,0-23.339,7.149-23.339,15.485 c0,10.247,9.047,14.769,29.78,22.632c28.341,10.479,41.681,25.239,41.681,47.874c0,26.909-20.721,49.786-64.792,49.786 c-18.338,0-36.449-4.776-45.497-9.77l7.38-30.016c9.772,5.014,24.775,10.006,40.264,10.006c16.671,0,25.488-6.908,25.488-17.396 C285.536,325.789,277.909,320.078,258.618,313.18z M69.474,302.692c0-54.781,39.074-85.269,87.654-85.269 c18.822,0,33.113,3.811,39.549,7.149l-7.392,28.816c-7.38-3.084-17.632-5.939-30.491-5.939c-28.822,0-51.206,17.375-51.206,53.099 c0,32.158,19.051,52.4,51.456,52.4c10.947,0,23.097-2.378,30.241-5.238l5.483,28.346c-6.672,3.34-21.674,6.919-41.208,6.919 C98.06,382.976,69.474,348.424,69.474,302.692z M451.534,520.962H96.757v-103.57h354.777V520.962z M427.518,380.583h-42.399 l-51.45-160.536h39.787l19.526,67.894c5.479,19.046,10.479,37.386,14.299,57.397h0.709c4.048-19.298,9.045-38.352,14.526-56.693 l20.487-68.598h38.599L427.518,380.583z" />\n </svg>`}static json(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 32 32" >\n <polygon fill="${r}" points="31 11 31 21 29 21 27 15 27 21 25 21 25 11 27 11 29 17 29 11 31 11"/><path fill="' + c + '" d="M21.3335,21h-2.667A1.6684,1.6684,0,0,1,17,19.3335v-6.667A1.6684,1.6684,0,0,1,18.6665,11h2.667A1.6684,1.6684,0,0,1,23,12.6665v6.667A1.6684,1.6684,0,0,1,21.3335,21ZM19,19h2V13H19Z"/><path fill="' + c + '" d="M13.3335,21H9V19h4V17H11a2.002,2.002,0,0,1-2-2V12.6665A1.6684,1.6684,0,0,1,10.6665,11H15v2H11v2h2a2.002,2.002,0,0,1,2,2v2.3335A1.6684,1.6684,0,0,1,13.3335,21Z"/><path fill="' + c + '" d="M5.3335,21H2.6665A1.6684,1.6684,0,0,1,1,19.3335V17H3v2H5V11H7v8.3335A1.6684,1.6684,0,0,1,5.3335,21Z"/><rect fill="' + c + '" id="_Transparent_Rectangle_" data-name="<Transparent Rectangle>" style="fill: none;" width="32" height="32"/>\n </svg>`}static excel(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 512 512">'\n <path fill="#ECEFF1" d="M496,432.011H272c-8.832,0-16-7.168-16-16s0-311.168,0-320s7.168-16,16-16h224 c8.832,0,16,7.168,16,16v320C512,424.843,504.832,432.011,496,432.011z" />\n <path fill="${r}" d="M336,176.011h-64c-8.832,0-16-7.168-16-16s7.168-16,16-16h64c8.832,0,16,7.168,16,16 S344.832,176.011,336,176.011z" />\n <path fill="${r}" d="M336,240.011h-64c-8.832,0-16-7.168-16-16s7.168-16,16-16h64c8.832,0,16,7.168,16,16 S344.832,240.011,336,240.011z" />\n <path fill="${r}" d="M336,304.011h-64c-8.832,0-16-7.168-16-16s7.168-16,16-16h64c8.832,0,16,7.168,16,16 S344.832,304.011,336,304.011z" />\n <path fill="${r}" d="M336,368.011h-64c-8.832,0-16-7.168-16-16s7.168-16,16-16h64c8.832,0,16,7.168,16,16 S344.832,368.011,336,368.011z" />\n <path fill="${r}" d="M432,176.011h-32c-8.832,0-16-7.168-16-16s7.168-16,16-16h32c8.832,0,16,7.168,16,16 S440.832,176.011,432,176.011z" />\n <path fill="${r}" d="M432,240.011h-32c-8.832,0-16-7.168-16-16s7.168-16,16-16h32c8.832,0,16,7.168,16,16 S440.832,240.011,432,240.011z" />\n <path fill="${r}" d="M432,304.011h-32c-8.832,0-16-7.168-16-16s7.168-16,16-16h32c8.832,0,16,7.168,16,16 S440.832,304.011,432,304.011z" />\n <path fill="${r}" d="M432,368.011h-32c-8.832,0-16-7.168-16-16s7.168-16,16-16h32c8.832,0,16,7.168,16,16 S440.832,368.011,432,368.011z" />\n <path fill="${r}" d="M282.208,19.691c-3.648-3.04-8.544-4.352-13.152-3.392l-256,48C5.472,65.707,0,72.299,0,80.011v352 c0,7.68,5.472,14.304,13.056,15.712l256,48c0.96,0.192,1.952,0.288,2.944,0.288c3.712,0,7.328-1.28,10.208-3.68 c3.68-3.04,5.792-7.584,5.792-12.32v-448C288,27.243,285.888,22.731,282.208,19.691z" />\n <path fill="#FAFAFA" d="M220.032,309.483l-50.592-57.824l51.168-65.792c5.44-6.976,4.16-17.024-2.784-22.464 c-6.944-5.44-16.992-4.16-22.464,2.784l-47.392,60.928l-39.936-45.632c-5.856-6.72-15.968-7.328-22.56-1.504 c-6.656,5.824-7.328,15.936-1.504,22.56l44,50.304L83.36,310.187c-5.44,6.976-4.16,17.024,2.784,22.464 c2.944,2.272,6.432,3.36,9.856,3.36c4.768,0,9.472-2.112,12.64-6.176l40.8-52.48l46.528,53.152 c3.168,3.648,7.584,5.504,12.032,5.504c3.744,0,7.488-1.312,10.528-3.968C225.184,326.219,225.856,316.107,220.032,309.483z" />\n </svg>`}static fit(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 16 16">\n <path fill="${r}" d="m 4 1 c -1.660156 0 -3 1.339844 -3 3 v 8 c 0 1.660156 1.339844 3 3 3 h 8 c 1.660156 0 3 -1.339844 3 -3 v -8 c 0 -1.660156 -1.339844 -3 -3 -3 z m 0 2 h 3.011719 v 2 h -2 v 2 h -2 l -0.011719 -3 c 0 -0.128906 0.027344 -0.253906 0.074219 -0.375 c 0.003906 -0.003906 0.003906 -0.007812 0.007812 -0.011719 c 0.046875 -0.117187 0.117188 -0.21875 0.203125 -0.308593 c 0.007813 -0.007813 0.011719 -0.011719 0.019532 -0.019532 c 0.089843 -0.085937 0.191406 -0.15625 0.308593 -0.203125 c 0.003907 -0.003906 0.007813 -0.007812 0.015625 -0.007812 c 0.117188 -0.046875 0.242188 -0.074219 0.371094 -0.074219 z m 5 0 h 3.011719 c 0.125 0 0.253906 0.027344 0.371093 0.074219 c 0.003907 0.003906 0.011719 0.003906 0.015626 0.007812 c 0.113281 0.046875 0.21875 0.117188 0.304687 0.203125 c 0.007813 0.007813 0.015625 0.011719 0.019531 0.019532 c 0.089844 0.089843 0.160156 0.191406 0.207032 0.308593 c 0 0.003907 0.003906 0.007813 0.007812 0.015625 c 0.046875 0.117188 0.070312 0.242188 0.074219 0.371094 l -0.011719 3 h -2 v -2 h -2 z m -5.988281 6 h 2 v 2 h 2 v 2 h -3.011719 c -0.128906 0 -0.253906 -0.027344 -0.375 -0.074219 c -0.003906 -0.003906 -0.007812 -0.003906 -0.011719 -0.007812 c -0.117187 -0.046875 -0.21875 -0.117188 -0.308593 -0.203125 c -0.007813 -0.007813 -0.011719 -0.011719 -0.019532 -0.019532 c -0.085937 -0.089843 -0.15625 -0.191406 -0.203125 -0.308593 c -0.003906 -0.003907 -0.007812 -0.007813 -0.007812 -0.015625 c -0.046875 -0.117188 -0.074219 -0.242188 -0.074219 -0.371094 z m 7.988281 0 h 2 l 0.011719 3 c -0.003907 0.128906 -0.027344 0.253906 -0.074219 0.375 c -0.003906 0.003906 -0.003906 0.007812 -0.007812 0.011719 c -0.046876 0.117187 -0.117188 0.21875 -0.203126 0.308593 c -0.007812 0.007813 -0.015624 0.011719 -0.019531 0.019532 c -0.089843 0.085937 -0.195312 0.15625 -0.308593 0.203125 c -0.003907 0.003906 -0.011719 0.007812 -0.015626 0.007812 c -0.117187 0.046875 -0.246093 0.074219 -0.371093 0.074219 h -3.011719 v -2 h 2 z m 0 0" fill="#2e3436"/>\n </svg>`}static undo(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 32 32" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">\n <path fill="${r}" d="M6.507,17.508l20.963,-0.008c0.828,-0 1.5,-0.673 1.5,-1.501c-0.001,-0.827 -0.673,-1.499 -1.501,-1.499l-20.975,0.008c0.088,-0.119 0.188,-0.231 0.298,-0.334c0,0 9.705,-9.079 9.705,-9.079c0.605,-0.565 0.636,-1.515 0.071,-2.12c-0.566,-0.604 -1.516,-0.636 -2.12,-0.07c-0,-0 -5.9,5.519 -9.705,9.078c-1.118,1.045 -1.749,2.509 -1.743,4.038c0.006,1.53 0.649,2.989 1.774,4.025c3.848,3.543 9.829,9.05 9.829,9.05c0.609,0.56 1.559,0.521 2.119,-0.088c0.561,-0.609 0.522,-1.558 -0.087,-2.119c-0,-0 -5.98,-5.507 -9.828,-9.05c-0.111,-0.102 -0.211,-0.213 -0.3,-0.331Z"/>\n </svg>`}static redo(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 32 32" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">\n <path fill="${r}" d="M25.468,14.508l-20.967,-0.008c-0.828,-0 -1.501,0.672 -1.501,1.499c-0,0.828 0.672,1.501 1.499,1.501l21.125,0.009c-0.107,0.159 -0.234,0.306 -0.377,0.439c-3.787,3.502 -9.68,8.951 -9.68,8.951c-0.608,0.562 -0.645,1.511 -0.083,2.119c0.562,0.608 1.512,0.645 2.12,0.083c-0,0 5.892,-5.448 9.68,-8.95c1.112,-1.029 1.751,-2.47 1.766,-3.985c0.014,-1.515 -0.596,-2.968 -1.688,-4.018l-9.591,-9.221c-0.596,-0.574 -1.547,-0.556 -2.121,0.041c-0.573,0.597 -0.555,1.547 0.042,2.121l9.591,9.221c0.065,0.063 0.127,0.129 0.185,0.198Z"/>\n </svg>`}static cut(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 32 32" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">\n <path fill="${r}" d="M16,13.879l-10.939,-10.94c-0.586,-0.585 -1.536,-0.585 -2.122,0c-0.585,0.586 -0.585,1.536 0,2.122l10.94,10.939l-3.567,3.566c-0.692,-0.361 -1.478,-0.566 -2.312,-0.566c-2.76,0 -5,2.24 -5,5c0,2.76 2.24,5 5,5c2.76,0 5,-2.24 5,-5c0,-0.834 -0.205,-1.62 -0.566,-2.312l3.566,-3.567l3.566,3.567c-0.361,0.692 -0.566,1.478 -0.566,2.312c0,2.76 2.24,5 5,5c2.76,0 5,-2.24 5,-5c0,-2.76 -2.24,-5 -5,-5c-0.834,0 -1.62,0.205 -2.312,0.566l-3.567,-3.566l10.94,-10.939c0.585,-0.586 0.585,-1.536 -0,-2.122c-0.586,-0.585 -1.536,-0.585 -2.122,0l-10.939,10.94Z"/>\n </svg>`}static copy(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 32 32" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;" >\n <path fill="${r}" d="M9.101,7l8.899,0c1.857,-0 3.637,0.737 4.95,2.05c1.313,1.313 2.05,3.093 2.05,4.95l0,8.899c0.953,-0.195 1.837,-0.665 2.536,-1.363c0.937,-0.938 1.464,-2.21 1.464,-3.536c0,-2.977 0,-7.023 0,-10c0,-1.326 -0.527,-2.598 -1.464,-3.536c-0.938,-0.937 -2.21,-1.464 -3.536,-1.464c-2.977,0 -7.023,0 -10,0c-1.326,-0 -2.598,0.527 -3.536,1.464c-0.698,0.699 -1.168,1.583 -1.363,2.536Z"/>\n <path fill="${r}" d="M23,14c0,-1.326 -0.527,-2.598 -1.464,-3.536c-0.938,-0.937 -2.21,-1.464 -3.536,-1.464c-2.977,0 -7.023,0 -10,0c-1.326,-0 -2.598,0.527 -3.536,1.464c-0.937,0.938 -1.464,2.21 -1.464,3.536c0,2.977 0,7.023 0,10c-0,1.326 0.527,2.598 1.464,3.536c0.938,0.937 2.21,1.464 3.536,1.464c2.977,-0 7.023,-0 10,-0c1.326,0 2.598,-0.527 3.536,-1.464c0.937,-0.938 1.464,-2.21 1.464,-3.536l0,-10Zm-15,10l10,0c0.552,0 1,-0.448 1,-1c0,-0.552 -0.448,-1 -1,-1l-10,0c-0.552,0 -1,0.448 -1,1c0,0.552 0.448,1 1,1Zm0,-4l10,0c0.552,0 1,-0.448 1,-1c0,-0.552 -0.448,-1 -1,-1l-10,0c-0.552,0 -1,0.448 -1,1c0,0.552 0.448,1 1,1Zm0,-4l10,0c0.552,0 1,-0.448 1,-1c0,-0.552 -0.448,-1 -1,-1l-10,0c-0.552,0 -1,0.448 -1,1c0,0.552 0.448,1 1,1Z"/>\n </svg>`}static paste(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 32 32" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">\n <path fill="${r}" d="M23,14c0,-1.326 -0.527,-2.598 -1.464,-3.536c-0.938,-0.937 -2.21,-1.464 -3.536,-1.464c-2.977,0 -7.023,0 -10,0c-1.326,-0 -2.598,0.527 -3.536,1.464c-0.937,0.938 -1.464,2.21 -1.464,3.536c-0,2.977 -0,7.023 -0,10c-0,1.326 0.527,2.598 1.464,3.536c0.938,0.937 2.21,1.464 3.536,1.464c2.977,-0 7.023,-0 10,-0c1.326,0 2.598,-0.527 3.536,-1.464c0.937,-0.938 1.464,-2.21 1.464,-3.536l-0,-10Z"/>\n <path fill="${r}" d="M9.101,7l8.899,0c1.857,-0 3.637,0.737 4.95,2.05c1.313,1.313 2.05,3.093 2.05,4.95l-0,8.899c0.953,-0.195 1.837,-0.665 2.536,-1.363c0.937,-0.938 1.464,-2.21 1.464,-3.536c0,-2.977 0,-7.023 0,-10c0,-1.326 -0.527,-2.598 -1.464,-3.536c-0.938,-0.937 -2.21,-1.464 -3.536,-1.464c-2.977,0 -7.023,0 -10,0c-1.326,-0 -2.598,0.527 -3.536,1.464c-0.698,0.699 -1.168,1.583 -1.363,2.536Z"/>\n </svg>`}static delete(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 32 32" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">\n <path fill="${r}" d="M11,4.5l10,0c0.828,-0 1.5,-0.672 1.5,-1.5c-0,-0.828 -0.672,-1.5 -1.5,-1.5l-10,0c-0.828,-0 -1.5,0.672 -1.5,1.5c-0,0.828 0.672,1.5 1.5,1.5Z"/>\n <path fill="${r}" d="M5,9.5l0,16.5c0,2.761 2.239,5 5,5l12,0c2.761,0 5,-2.239 5,-5l0,-16.5l1.645,0c0.748,-0 1.355,-0.672 1.355,-1.5c-0,-0.828 -0.607,-1.5 -1.355,-1.5l-25.29,0c-0.748,-0 -1.355,0.672 -1.355,1.5c-0,0.828 0.607,1.5 1.355,1.5l1.645,0Zm7,3.5l0,12c-0,0.552 0.448,1 1,1c0.552,0 1,-0.448 1,-1l0,-12c-0,-0.552 -0.448,-1 -1,-1c-0.552,0 -1,0.448 -1,1Zm6,-0l0,12c0,0.552 0.448,1 1,1c0.552,-0 1,-0.448 1,-1l0,-12c0,-0.552 -0.448,-1 -1,-1c-0.552,-0 -1,0.448 -1,1Z"/>\n </svg>`}static addPlusNew(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 32 32">\n <path fill="${r}" d="M14.5,14.501l-10.502,0c-0.828,0 -1.5,0.673 -1.5,1.5c0,0.828 0.672,1.5 1.5,1.5l10.502,0l-0.001,10.502c0,0.828 0.672,1.5 1.5,1.501c0.828,-0 1.5,-0.673 1.5,-1.5l0.001,-10.503l10.502,0c0.828,0 1.5,-0.672 1.5,-1.5c0,-0.827 -0.672,-1.5 -1.5,-1.5l-10.502,0l0.001,-10.501c-0,-0.828 -0.672,-1.501 -1.5,-1.501c-0.828,0 -1.5,0.672 -1.5,1.5l-0.001,10.502Z"/> \n </svg>`}static minus(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 32 32">\n <line stroke="${r}" stroke-width="3" x1="3" y1="16" x2="29" y2="16"></line>\n </svg>`}static editToolPencil(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 32 32" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">\n <path fill="${r}" d="M12.965,5.462c0,-0 -2.584,0.004 -4.979,0.008c-3.034,0.006 -5.49,2.467 -5.49,5.5l0,13.03c0,1.459 0.579,2.858 1.611,3.889c1.031,1.032 2.43,1.611 3.889,1.611l13.003,0c3.038,-0 5.5,-2.462 5.5,-5.5c0,-2.405 0,-5.004 0,-5.004c0,-0.828 -0.672,-1.5 -1.5,-1.5c-0.827,-0 -1.5,0.672 -1.5,1.5l0,5.004c0,1.381 -1.119,2.5 -2.5,2.5l-13.003,0c-0.663,-0 -1.299,-0.263 -1.768,-0.732c-0.469,-0.469 -0.732,-1.105 -0.732,-1.768l0,-13.03c0,-1.379 1.117,-2.497 2.496,-2.5c2.394,-0.004 4.979,-0.008 4.979,-0.008c0.828,-0.002 1.498,-0.675 1.497,-1.503c-0.001,-0.828 -0.675,-1.499 -1.503,-1.497Z"/>\n <path fill="${r}" d="M20.046,6.411l-6.845,6.846c-0.137,0.137 -0.232,0.311 -0.271,0.501l-1.081,5.152c-0.069,0.329 0.032,0.671 0.268,0.909c0.237,0.239 0.577,0.343 0.907,0.277l5.194,-1.038c0.193,-0.039 0.371,-0.134 0.511,-0.274l6.845,-6.845l-5.528,-5.528Zm1.415,-1.414l5.527,5.528l1.112,-1.111c1.526,-1.527 1.526,-4.001 -0,-5.527c-0.001,-0 -0.001,-0.001 -0.001,-0.001c-1.527,-1.526 -4.001,-1.526 -5.527,-0l-1.111,1.111Z"/>\n </svg>`}static saveStorageFolder(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 32 32" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">\n <path fill="${r}" d="M9,29l0,-8.25c0,-1.518 1.232,-2.75 2.75,-2.75l8.5,0c1.518,0 2.75,1.232 2.75,2.75l0,8.25l-14,-0Zm-2,-0.101c-0.953,-0.195 -1.837,-0.665 -2.536,-1.363c-0.937,-0.938 -1.464,-2.21 -1.464,-3.536c-0,-4.439 -0,-11.561 0,-16c-0,-1.326 0.527,-2.598 1.464,-3.536c0.938,-0.937 2.21,-1.464 3.536,-1.464l2,-0l0,5.083c0,2.201 1.613,3.917 3.5,3.917l5,0c1.887,0 3.5,-1.716 3.5,-3.917l0,-5.083l0.221,0c0.24,0 0.472,0.087 0.654,0.244l5.779,5c0.22,0.19 0.346,0.466 0.346,0.756c0,0 0,9.426 -0,15c0,1.326 -0.527,2.598 -1.464,3.536c-0.699,0.698 -1.583,1.168 -2.536,1.363l0,-8.149c0,-2.622 -2.128,-4.75 -4.75,-4.75c0,0 -8.5,0 -8.5,0c-2.622,0 -4.75,2.128 -4.75,4.75l0,8.149Zm13,-25.899l0,5.083c0,1.02 -0.626,1.917 -1.5,1.917c0,0 -5,0 -5,0c-0.874,0 -1.5,-0.897 -1.5,-1.917l0,-5.083l8,0Z"/>\n </svg>`}static share(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 16 16">\n <path fill="${r}" d="M11 6C12.6569 6 14 4.65685 14 3C14 1.34315 12.6569 0 11 0C9.34315 0 8 1.34315 8 3C8 3.22371 8.02449 3.44169 8.07092 3.65143L4.86861 5.65287C4.35599 5.24423 3.70652 5 3 5C1.34315 5 0 6.34315 0 8C0 9.65685 1.34315 11 3 11C3.70652 11 4.35599 10.7558 4.86861 10.3471L8.07092 12.3486C8.02449 12.5583 8 12.7763 8 13C8 14.6569 9.34315 16 11 16C12.6569 16 14 14.6569 14 13C14 11.3431 12.6569 10 11 10C10.2935 10 9.644 10.2442 9.13139 10.6529L5.92908 8.65143C5.97551 8.44169 6 8.22371 6 8C6 7.77629 5.97551 7.55831 5.92908 7.34857L9.13139 5.34713C9.644 5.75577 10.2935 6 11 6Z" fill="#000000"/>\n </svg>`}static arrow(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 24 24" >\n <path d="M12 6V18M12 6L7 11M12 6L17 11" stroke="${r}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>`}static user(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 24 24">\n <path fill="${r}" d="M12 11.796C14.7189 11.796 16.9231 9.60308 16.9231 6.89801C16.9231 4.19294 14.7189 2.00005 12 2.00005C9.28106 2.00005 7.07692 4.19294 7.07692 6.89801C7.07692 9.60308 9.28106 11.796 12 11.796Z" fill="#030D45"/>\n <path fill="${r}" d="M14.5641 13.8369H9.4359C6.46154 13.8369 4 16.2859 4 19.245C4 19.9593 4.30769 20.5716 4.92308 20.8777C5.84615 21.3879 7.89744 22.0001 12 22.0001C16.1026 22.0001 18.1538 21.3879 19.0769 20.8777C19.5897 20.5716 20 19.9593 20 19.245C20 16.1838 17.5385 13.8369 14.5641 13.8369Z" fill="#030D45"/>\n </svg>`}static zoom_in(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 32 32" >\n <g sketch:type="MSLayerGroup" transform="translate(-362.000000, -1037.000000)" fill="${r}">\n <path d="M390,1049 L382,1049 L382,1041 C382,1038.79 380.209,1037 378,1037 C375.791,1037 374,1038.79 374,1041 L374,1049 L366,1049 C363.791,1049 362,1050.79 362,1053 C362,1055.21 363.791,1057 366,1057 L374,1057 L374,1065 C374,1067.21 375.791,1069 378,1069 C380.209,1069 382,1067.21 382,1065 L382,1057 L390,1057 C392.209,1057 394,1055.21 394,1053 C394,1050.79 392.209,1049 390,1049" id="plus" sketch:type="MSShapeGroup"></path>\n </g>\n </svg>`}static zoom_out(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 -12 32 32" >\n <g id="Icon-Set-Filled" sketch:type="MSLayerGroup" transform="translate(-414.000000, -1049.000000)" fill="${r}">\n <path d="M442,1049 L418,1049 C415.791,1049 414,1050.79 414,1053 C414,1055.21 415.791,1057 418,1057 L442,1057 C444.209,1057 446,1055.21 446,1053 C446,1050.79 444.209,1049 442,1049" id="minus" sketch:type="MSShapeGroup"></path>\n </g>\n </svg>`}static cursor(t,e,r,o,a){return`<svg width="${t}" height="${e}" x="${o}" y="${a}" viewBox="0 0 16 16" >\n <path d="M8 3V0H6V3H8Z" fill="${r}"/>\n <path d="M0.792893 2.20711L3.29289 4.70711L4.70711 3.29289L2.20711 0.792893L0.792893 2.20711Z" fill="${r}"/>\n <path d="M6 5L5 6.00001L8 15H10L10.7172 12.1314L14.2929 15.7071L15.7071 14.2929L12.1314 10.7172L15 10V8L6 5Z" fill="${r}"/>\n <path d="M0 6H3V8H0V6Z" fill="${r}"/>\n </svg>`}},FlowChart.ShapeCollection=class extends Array{_;constructor(t){super(),this._=new FlowChart.ShapeCollection.private(t)}get last(){return this.length?this[this.length-1]:null}get first(){return this.length?this[0]:null}get top(){return this._.minY}get bottom(){return this._.maxY}get left(){return this._.minX}get right(){return this._.maxX}addRange(t){this._.chart._.snap();var e=this._.addRange(t);return this.push(...e),this._.chart._.changed({property:"shapes"}),e}add(t){return this.addRange([t])[0]}get(t){if(!(arguments.length>=3)){for(var e of this)if(e.id==t)return e;return null}var r=arguments[0],o=arguments[1],a=arguments[2],i=arguments[3],s=arguments[4];for(var e of(null==i&&(i=""),null==s&&(s=""),this))if(e.from==r&&e.to==o&&e.position==a&&e.fromPort==i&&e.toPort==s)return e}clear(){this._.remove(this,this)}removeRange(t){this._.remove(t,this)}remove(t){t&&this._.remove([t],this)}contains(t){return null!=this.get(t)}},FlowChart.ShapeCollection.private=class{chart;moveHorizontallyInterval;moveVerticallyInterval;metadata;minX;minY;maxX;maxY;minShapeX;minShapeY;maxShapeX;maxShapeY;constructor(t){this.chart=t,this.moveHorizontallyInterval=null,this.moveVerticallyInterval=null,this.metadata={},this.minX=Number.MAX_SAFE_INTEGER,this.minY=Number.MAX_SAFE_INTEGER,this.maxX=Number.MIN_SAFE_INTEGER,this.maxY=Number.MIN_SAFE_INTEGER,this.minShapeX=null,this.minShapeY=null,this.maxShapeX=null,this.maxShapeY=null}getProperty(t,e,r){if(null==t[e]){var o=FlowChart.shapeTemplates[t.templateId];if(null!=o[e]&&"function"!=typeof o[e])return o[e]}if("x"==e||"y"==e){if("label"==r.type)return this.metadata[r.id][e];if(null==t[e])return 0}return Reflect.get(...arguments)}setProperty(t,e,r,o){var a=FlowChart.shapeTemplates[t.templateId];"label"!=o.type||"x"!=e&&"y"!=e?a[e]&&"function"!=typeof a[e]?(t[e]==a[e]==r&&delete t[e],a[e]!=r?this.setPropertyAndCallFieldChange(t,e,r,o):a[e]!=r||FlowChart.isNEU(t[e])||this.setPropertyAndCallFieldChange(t,e,r,o)):this.setPropertyAndCallFieldChange(t,e,r,o):(this.metadata[o.id]||(this.metadata[o.id]={}),this.metadata[o.id][e]=r)}setPropertyAndCallFieldChange(t,e,r,o){if("width"!=e&&"height"!=e&&"opacity"!=e&&"x"!=e&&"y"!=e){var a={shape:o,newValue:r,fieldName:e};return!1!==FlowChart.events.publish("field-change",[this.chart,a])&&(t[e]=r),!0}t[e]=r}setSelected(t,e){0!=this.chart.options.selectable&&0!=t.selectable||(e=!1);var r=t.selected,o=this.getMetadata(t.id);r!=e&&(o.selected=e,!r&&e?(this.chart.selectedShapes.add(t),this.chart.selectedShapes._.createSelectorElement(t)):r&&!e&&(this.chart.selectedShapes.remove(t),this.chart.selectedShapes._.removeSelectorElement(t)))}clearSelectedMetadata(){for(var t in this.metadata){this.metadata[t].selected=!1;var e=this.chart.svgElement.querySelector(`[data-selector-shape-id="${t}"]`);e&&e.parentNode.removeChild(e)}}setWidth(t,e){if(t.canWidthFitContent){var r=FlowChart.shapeTemplates[t.templateId],o=this.getMetadata(t.id);e<r.minWidth&&(e=r.minWidth),o.width!=e&&(o.width=e,t.SYSTEM_CHANGE_SIZE=!0)}else t.width=e}setHeight(t,e){if(t.canHeightFitContent){var r=FlowChart.shapeTemplates[t.templateId],o=this.getMetadata(t.id);e<r.minHeight&&(e=r.minHeight),o.height!=e&&(o.height=e,t.SYSTEM_CHANGE_SIZE=!0)}else t.height=e}addRange(t){for(var e=[],r=0;r<t.length;r++){var o=t[r];if(FlowChart.private.isLabel(o)){o.templateId||(o.templateId=FlowChart.DEFAULT_LABEL_SHAPE_ID);var a="";FlowChart.isNEU(o.fromPort)||(a=o.fromPort);var i="";FlowChart.isNEU(o.toPort)||(i=o.toPort);var s=this.chart.links.get(o.from,o.to,a,i),h=FlowChart.private.getLabelXY(o,s),l=`${o.from}${FlowChart.SEPARATOR}${a}${FlowChart.SEPARATOR}${o.to}${FlowChart.SEPARATOR}${i}${FlowChart.SEPARATOR}${o.position}`;this.metadata[l]={},this.metadata[l].x=h.x,this.metadata[l].y=h.y}var n=this.set(o);e.push(n)}return this.chart.selectedPortShape=null,e}set(t){var e=this;FlowChart.shapeTemplates[t.templateId]||console.error(`Shape template "${t.templateId}" does not exist!`),!FlowChart.private.isLabel(t)&&FlowChart.isNEU(t.id)&&(t.id=this.chart.generateId());var r=t.id;FlowChart.private.isLabel(t)||"string"==typeof r||(r=r.toString());var o=function(t,r){if(e.chart.skip)return!0;var o=FlowChart.shapeTemplates[t.templateId];if(!(l=t.element)){var a=o.html(t),i=o.svg(t),s=o.svgFront(t),h=o.offset(t),l=document.createElementNS("http://www.w3.org/2000/svg","g"),n=t.strokeWidth/2,c=t.strokeWidth/2,p=t.height-t.strokeWidth,d=t.width-t.strokeWidth;p<0&&(p=0),d<0&&(d=0),l.innerHTML=`<g class="bfc-svg-back">${i}</g>\n <foreignObject pointer-events="all" class="bfc-html" x="${n}" y="${c}" width="${d}" height="${p}"><div data-html-container class="bfc-flex-center">${a}</div></foreignObject>\n <g class="bfc-svg-front">${s}</g>`,l.setAttribute("data-shape-id",t.id),l.setAttribute("transform",`translate(${t.left+h.x},${t.top+h.y})`),l.classList.add(t.templateId),null!=t.opacity&&(l.style.opacity=t.opacity),FlowChart.private.getLayer(e.chart.svgElement,t.layer).appendChild(l)}if(null!=r){var f=l.querySelector("[data-html-container]"),u=l.querySelector(".bfc-html"),w=l.querySelector(".bfc-svg-back"),m=l.querySelector(".bfc-svg-front");if("x"==r||"y"==r){h=o.offset(t);l.setAttribute("transform",`translate(${t.left+h.x},${t.top+h.y})`)}else if("width"==r||"height"==r||"SYSTEM_CHANGE_SIZE"==r){h=o.offset(t);w.innerHTML=o.svg(t),m.innerHTML=o.svgFront(t);var C=t.width-t.strokeWidth,g=t.height-t.strokeWidth;C<0&&(C=0),g<0&&(g=0),u.setAttribute("width",C),u.setAttribute("height",g),l.setAttribute("transform",`translate(${t.left+h.x},${t.top+h.y})`)}if("x"==r||"y"==r||"width"==r||"height"==r||"SYSTEM_CHANGE_SIZE"==r){for(var v of(e.chart.selectedShapes._.update(t,e.chart.scale),e.chart._.updatePortsElement(e.chart.scale),e.chart.links))if(v.from==t.id||v.to==t.id){var y=e.chart.ports.getByLink(v),N=FlowChart.private.linkFromTo(y.fromShape,y.toShape,y.fromPort,y.toPort,e.chart);v.points=N}e.minMax(t)}if("selected"!=r&&"x"!=r&&"y"!=r&&"width"!=r&&"height"!=r&&"SYSTEM_CHANGE_SIZE"!=r){a=(o=FlowChart.shapeTemplates[t.templateId]).html(t);if(f.innerHTML=a,w.innerHTML=o.svg(t),m.innerHTML=o.svgFront(t),t.canWidthFitContent||t.canHeightFitContent){var x=e.chart._.getSizeOfHTML(a);if(t.canWidthFitContent){var b=x.width;b<o.minWidth&&(b=o.minWidth),e.setWidth(t,b)}if(t.canHeightFitContent){var F=x.height;F<o.minHeight&&(F=o.minHeight),e.setHeight(t,F)}}}"opacity"==r&&(l.style.opacity=t[r])}},a=new Proxy(t,{deleteProperty(t,r,a){delete t[r];a=e.chart.getShape(t.id);return o(a,r),!0},get(t,r,o){var a=FlowChart.shapeTemplates[t.templateId];return"top"==r?o.y-o.height/2:"bottom"==r?o.y+o.height/2:"left"==r?o.x-o.width/2:"right"==r?o.x+o.width/2:"fromPort"==r&&FlowChart.isNEU(t.fromPort)||"toPort"==r&&FlowChart.isNEU(t.toPort)?"":"layer"==r&&FlowChart.isNEU(t.layer)?"label"==o.type?-1:-2:"id"==r&&"label"==o.type?`${o.from}${FlowChart.SEPARATOR}${o.fromPort}${FlowChart.SEPARATOR}${o.to}${FlowChart.SEPARATOR}${o.toPort}${FlowChart.SEPARATOR}${o.position}`:"width"==r&&"fit"==a.width&&null==t.width?e.metadata[o.id]&&null!=e.metadata[o.id].width?e.metadata[o.id].width:a.width:"height"==r&&"fit"==a.height&&null==t.height?e.metadata[o.id]&&null!=e.metadata[o.id].height?e.metadata[o.id].height:a.height:"selected"==r?!(!e.metadata[o.id]||1!=e.metadata[o.id].selected):"canWidthFitContent"==r&&"fit"==a.width&&null==t.width||("canHeightFitContent"==r&&"fit"==a.height&&null==t.height||("element"==r?e.getElement(o.id):"link"==r&&"label"==o.type?e.chart.links.get(o.from,o.to,o.fromPort,o.toPort):e.getProperty(...arguments)))},set(t,r,a,i){if(i[r]==a)return!0;var s=FlowChart.shapeTemplates[t.templateId];if("width"==r&&a<s.minWidth&&(a=s.minWidth),"height"==r&&a<s.minHeight&&(a=s.minHeight),"selected"==r&&e.setSelected(i,a),"to"==r||"from"==r||"fromPort"==r||"toPort"==r||"id"==r||"templateId"==r){var h=i.element;h&&h.parentNode.removeChild(h)}if("SYSTEM_CHANGE_SIZE"!=r&&"selected"!=r){e.chart._.snap();var l=e.beforeIdChange(r,i,t);e.setProperty(t,r,a,i),e.afterIdChange(l,i)}return o(i,r),"SYSTEM_CHANGE_SIZE"!=r&&"selected"!=r&&e.chart._.changed({property:"shapes"}),!0}}),i=FlowChart.shapeTemplates[t.templateId];if("fit"==i.width||"fit"==i.height){var s=i.html(a),h=this.chart._.getSizeOfHTML(s);if("fit"==i.width){var l=h.width;l<i.minWidth&&(l=i.minWidth),this.metadata[a.id]||(this.metadata[a.id]={}),this.metadata[a.id].width=l}if("fit"==i.height){var n=h.height;n<i.minHeight&&(n=i.minHeight),this.metadata[a.id]||(this.metadata[a.id]={}),this.metadata[a.id].height=n}}return o(a),this.minMax(a),a}beforeIdChange(t,e){var r=null;return"to"!=t&&"from"!=t&&"fromPort"!=t&&"toPort"!=t&&"id"!=t&&"templateId"!=t||((r={from:e.from,to:e.to,fromPort:e.fromPort,toPort:e.toPort,id:e.id,metadata:null}).metadata=this.metadata[e.id],delete this.metadata[e.id]),r}afterIdChange(t,e){if(t)if(this.metadata[e.id]=t.metadata,"label"==e.type)for(var r of this.chart.links)r.from==t.from&&r.to==t.to&&r.fromPort==t.fromPort&&r.toPort==t.toPort&&(r.from=e.from,r.to=e.to,r.fromPort=e.fromPort,r.toPort=e.toPort);else for(var r of this.chart.links)r.from==t.id&&(r.from=e.id),r.to==t.id&&(r.to=e.id)}getElement(t){return this.chart.svgElement.querySelector(`[data-shape-id="${t}"]`)}remove(t,e){var r=!1;t instanceof FlowChart.SelectedShapeCollection||t instanceof FlowChart.ShapeCollection||Array.isArray(t)||(t=[t]);var o=[];for(var a of t)o.push(a.id);for(var i of o)for(var s=e.length-1;s>=0;s--)if(e[s].id==i){(a=e[s]).selected=!1,this.chart.selectedPortShape=null;var h=this.getElement(i);h&&h.parentNode.removeChild(h),this.chart.links.remove(i),r||(this.chart._.snap(),r=!0),this.metadata[a.id]&&delete this.metadata[a.id],e.splice(s,1);break}r&&(this.minMaxIterateAll(e),this.chart._.changed({property:"shapes"}))}move(t,e,r,o,a){if(t.length)if(e){if((e!=FlowChart.move.left&&e!=FlowChart.move.right||!this.moveHorizontallyInterval)&&(e!=FlowChart.move.up&&e!=FlowChart.move.down||!this.moveVerticallyInterval)){var i=1;FlowChart.isNEU(o)&&(o=FlowChart.anim.inSin),FlowChart.isNEU(a)&&(a=1100),e!=FlowChart.move.left&&e!=FlowChart.move.right||(this.moveHorizontallyInterval=setInterval(s,10)),e!=FlowChart.move.up&&e!=FlowChart.move.down||(this.moveVerticallyInterval=setInterval(s,10))}}else console.error("movePosition parameter not defined");function s(){var s=o((10*i-10)/a);for(var h of t)e==FlowChart.move.left?h.x-=FlowChart.MOVE_NODE_STEP*s:e==FlowChart.move.right?h.x+=FlowChart.MOVE_NODE_STEP*s:e==FlowChart.move.up?h.y-=FlowChart.MOVE_NODE_STEP*s:e==FlowChart.move.down&&(h.y+=FlowChart.MOVE_NODE_STEP*s);r&&r(),i+=1}}stopMoving(t){t==FlowChart.direction.vertical?this.moveVerticallyInterval&&(clearInterval(this.moveVerticallyInterval),this.moveVerticallyInterval=null):(t==FlowChart.direction.horizontal||this.moveVerticallyInterval&&(clearInterval(this.moveVerticallyInterval),this.moveVerticallyInterval=null),this.moveHorizontallyInterval&&(clearInterval(this.moveHorizontallyInterval),this.moveHorizontallyInterval=null))}minMax(t){"node"==t.type&&(t.left<this.minX&&(this.minX=t.left,this.minShapeX=t),t.top<this.minY&&(this.minY=t.top,this.minShapeY=t),t.right>this.maxX&&(this.maxX=t.right,this.maxShapeX=t),t.bottom>this.maxY&&(this.maxY=t.bottom,this.maxShapeY=t))}minMaxIterateAll(t){for(var e of(this.minX=Number.MAX_SAFE_INTEGER,this.minY=Number.MAX_SAFE_INTEGER,this.maxX=Number.MIN_SAFE_INTEGER,this.maxY=Number.MIN_SAFE_INTEGER,this.minShapeX=null,this.minShapeY=null,this.maxShapeX=null,this.maxShapeY=null,t))this.minMax(e)}getMetadata(t){return this.metadata[t]||(this.metadata[t]={width:void 0,height:void 0}),this.metadata[t]}},FlowChart.linkTemplates={rounded:{path:function(t){return FlowChart.private.roundPathCorners(t.points,FlowChart.LINK_ROUNDED_CORENERS,!1)},svg:function(t){return`<path d="" style="fill: none; stroke: ${t.stroke}; stroke-width: ${t.strokeWidth}px;" marker-start="url(#rounded_start)" marker-end="url(#rounded_end)" ></path>`},markerStart:"",markerEnd:'<marker id="rounded_end" markerWidth="5" markerHeight="5" refX="5" refY="2.5" orient="auto">\n <path d="M 0 0 L 5 2.5 L 0 5 z" fill="context-stroke" />\n </marker>',markerMid:"",stroke:"#aeaeae",strokeWidth:4}},FlowChart.linkTemplates.psuedo=Object.assign({},FlowChart.linkTemplates.rounded),FlowChart.linkTemplates.psuedo.stroke="#FFCA28",FlowChart.linkTemplates.psuedo.strokeWidth=4,FlowChart.shapeTemplates={base:{offset:function(t){return{x:0,y:0}},svg:function(t){return`<rect rx="7" ry="7" x="0" y="0" width="${t.width}" height="${t.height}" style="stroke:${t.stroke}; fill:${t.fill}; stroke-width:${t.strokeWidth};" ></rect>`},svgFront:function(t){return""},html:function(t){return`<div style="padding: 10px;">\n <div data-field="text"> ${null==t.text?`[${t.displayName}]`:t.text}</div> \n </div>`},ports:function(t){return{top:{x:t.width/2,y:0},right:{x:t.width,y:t.height/2},bottom:{x:t.width/2,y:t.height},left:{x:0,y:t.height/2}}},type:"node",displayInShapeBar:!1,displayInPortShapeBar:!1,fill:"#039BE5",stroke:"#aeaeae",strokeWidth:4,minWidth:200,minHeight:90,width:"fit",height:"fit",displayName:"Base",resizable:!0,selectable:!0,movable:!0}},FlowChart.shapeTemplates.startEnd=Object.assign({},FlowChart.shapeTemplates.base),FlowChart.shapeTemplates.startEnd.svg=function(t){var e=t.height/100*45;return`<rect rx="${e}" ry="${e}" x="0" y="0" width="${t.width}" height="${t.height}" style="stroke:${t.stroke}; fill:${t.fill}; stroke-width:${t.strokeWidth};" ></rect>`},FlowChart.shapeTemplates.startEnd.displayName="Start/End",FlowChart.shapeTemplates.startEnd.displayInShapeBar=!0,FlowChart.shapeTemplates.startEnd.displayInPortShapeBar=!0,FlowChart.shapeTemplates.process=Object.assign({},FlowChart.shapeTemplates.base),FlowChart.shapeTemplates.process.displayName="Process",FlowChart.shapeTemplates.process.displayInShapeBar=!0,FlowChart.shapeTemplates.process.displayInPortShapeBar=!0,FlowChart.shapeTemplates.document=Object.assign({},FlowChart.shapeTemplates.base),FlowChart.shapeTemplates.document.svg=function(t){var e=t.width/10;return`<path d="M0,0 L0,${t.height} Q ${t.width/4} ${t.height+e}, ${t.width/2} ${t.height} T ${t.width} ${t.height} L${t.width},${t.height} L${t.width},0 Z" style="stroke:${t.stroke}; fill:${t.fill}; stroke-width:${t.strokeWidth};"></path>`},FlowChart.shapeTemplates.document.displayName="Document",FlowChart.shapeTemplates.decision=Object.assign({},FlowChart.shapeTemplates.base),FlowChart.shapeTemplates.decision.displayName="Decision",FlowChart.shapeTemplates.decision.svg=function(t){return`<path d="M${t.width/2},0 L${t.width},${t.height/2} L${t.width/2},${t.height} L0,${t.height/2} Z" style="stroke:${t.stroke}; fill:${t.fill}; stroke-width:${t.strokeWidth};" /></path>`},FlowChart.shapeTemplates.decision.width=200,FlowChart.shapeTemplates.decision.height=180,FlowChart.shapeTemplates.decision.displayInShapeBar=!0,FlowChart.shapeTemplates.decision.displayInPortShapeBar=!0,FlowChart.shapeTemplates.inOut=Object.assign({},FlowChart.shapeTemplates.base),FlowChart.shapeTemplates.inOut.svg=function(t){var e=t.width/10;return`<path d="M${e},0 L0,${t.height} L${t.width-e},${t.height} L${t.width},0 Z" style="stroke:${t.stroke}; fill:${t.fill}; stroke-width:${t.strokeWidth};"></path>`},FlowChart.shapeTemplates.inOut.ports=function(t){var e=t.width/10/2;return{top:{x:t.width/2,y:0},right:{x:t.width-e,y:t.height/2},bottom:{x:t.width/2,y:t.height},left:{x:e,y:t.height/2}}},FlowChart.shapeTemplates.inOut.displayName="In/Out",FlowChart.shapeTemplates.inOut.displayInShapeBar=!0,FlowChart.shapeTemplates.inOut.displayInPortShapeBar=!0,FlowChart.shapeTemplates.inOut.static=!1,FlowChart.shapeTemplates.manualInput=Object.assign({},FlowChart.shapeTemplates.base),FlowChart.shapeTemplates.manualInput.svg=function(t){return`<path d="M0,${t.width/10} L0,${t.height} L${t.width},${t.height} L${t.width},0 Z" style="stroke:${t.stroke}; fill:${t.fill}; stroke-width:${t.strokeWidth};"></path>`},FlowChart.shapeTemplates.manualInput.ports=function(t){var e=t.width/20;return{top:{x:t.width/2,y:e},right:{x:t.width,y:t.height/2},bottom:{x:t.width/2,y:t.height},left:{x:0,y:t.height/2}}},FlowChart.shapeTemplates.manualInput.displayName="Manual Input",FlowChart.shapeTemplates.preparation=Object.assign({},FlowChart.shapeTemplates.base),FlowChart.shapeTemplates.preparation.svg=function(t){var e=t.width/10;return`<path d="M${e},0 L0,${t.height/2} L${e},${t.height} L${t.width-e},${t.height} L${t.width},${t.height/2} L${t.width-e},0 Z" style="stroke:${t.stroke}; fill:${t.fill}; stroke-width:${t.strokeWidth};"></path>`},FlowChart.shapeTemplates.preparation.displayName="Preparation",FlowChart.shapeTemplates.connector=Object.assign({},FlowChart.shapeTemplates.base),FlowChart.shapeTemplates.connector.svg=function(t){var e=Math.max(t.width,t.height)/2;return`<circle cx="${e}" cy="${e}" r="${e}" style="stroke:${t.stroke}; fill:${t.fill}; stroke-width:${t.strokeWidth};"></circle>`},FlowChart.shapeTemplates.connector.minWidth=110,FlowChart.shapeTemplates.connector.minHeight=110,FlowChart.shapeTemplates.connector.width=110,FlowChart.shapeTemplates.connector.height=110,FlowChart.shapeTemplates.connector.displayName="Connector",FlowChart.shapeTemplates.or=Object.assign({},FlowChart.shapeTemplates.connector),FlowChart.shapeTemplates.or.svg=function(t){return FlowChart.shapeTemplates.connector.svg(t)+`<line x1="${t.width/2}" y1="0" x2="${t.width/2}" y2="${t.height}" style="stroke:${t.stroke}; stroke-width:${t.strokeWidth};"></line>\n <line x1="0" y1="${t.height/2}" x2="${t.width}" y2="${t.height/2}" style="stroke:${t.stroke}; stroke-width:${t.strokeWidth};"></line>`},FlowChart.shapeTemplates.or.html=function(t){return""},FlowChart.shapeTemplates.displayName="Or",FlowChart.shapeTemplates.data=Object.assign({},FlowChart.shapeTemplates.connector),FlowChart.shapeTemplates.data.svg=function(t){var e=t.width/10;return`<path d="M0,${t.height} C${-e},${t.height} ${-e},0 0,0 L${t.width},0 C${t.width-e},0 ${t.width-e},${t.height} ${t.width},${t.height} Z" style="stroke:${t.stroke}; fill:${t.fill}; stroke-width:${t.strokeWidth};"/>`},FlowChart.shapeTemplates.data.displayName="Data",FlowChart.shapeTemplates.delay=Object.assign({},FlowChart.shapeTemplates.base),FlowChart.shapeTemplates.delay.svg=function(t){var e=t.width/4,r=t.width/5;return`<path d="M0,${t.height} L0,0 L${t.width-r},0 C${t.width+e-r},0 ${t.width+e-r},${t.height} ${t.width-r},${t.height} Z" style="stroke:${t.stroke}; fill:${t.fill}; stroke-width:${t.strokeWidth};"/>`},FlowChart.shapeTemplates.delay.displayName="Delay",FlowChart.shapeTemplates.display=Object.assign({},FlowChart.shapeTemplates.base),FlowChart.shapeTemplates.display.svg=function(t){var e=t.width/4,r=t.width/5,o=t.width/10;return`<path d="M${o},${t.height} L0,${t.height/2} L${o},0 L${t.width-r},0 C${t.width+e-r},0 ${t.width+e-r},${t.height} ${t.width-r},${t.height} Z" style="stroke:${t.stroke}; fill:${t.fill}; stroke-width:${t.strokeWidth};"/>`},FlowChart.shapeTemplates.display.displayName="Display",FlowChart.shapeTemplates.manualLoop=Object.assign({},FlowChart.shapeTemplates.base),FlowChart.shapeTemplates.manualLoop.svg=function(t){var e=t.width/10;return`<path d="M0,0 L${t.width},0 L${t.width-e},${t.height} L${e},${t.height} Z" style="stroke:${t.stroke}; fill:${t.fill}; stroke-width:${t.strokeWidth};"></path>`},FlowChart.shapeTemplates.manualLoop.displayName="Manual Loop",FlowChart.shapeTemplates.loopLimit=Object.assign({},FlowChart.shapeTemplates.base),FlowChart.shapeTemplates.loopLimit.svg=function(t){var e=t.width/6;return`<path d="M0,${e} L${e},0 L${t.width-e},0 L${t.width},${e} L${t.width},${t.height} L0,${t.height} Z" style="stroke:${t.stroke}; fill:${t.fill}; stroke-width:${t.strokeWidth};"></path>`},FlowChart.shapeTemplates.loopLimit.displayName="Loop Limit",FlowChart.shapeTemplates.label=Object.assign({},FlowChart.shapeTemplates.base),FlowChart.shapeTemplates.label.displayName="Label",FlowChart.shapeTemplates.label.svg=function(t){return`<rect class="bfc-label" x="0" y="0" width="${t.width}" height="${t.height}" style="stroke:${t.stroke}; fill:${t.fill}; stroke-width:${t.strokeWidth};" ></rect>`},FlowChart.shapeTemplates.label.html=function(t){var e=t.text;return null==e&&(e="[text]"),`<div style="padding: 2x;">\n <div data-field="text" style="color: #aeaeae;">${e}</div>\n </div>`},FlowChart.shapeTemplates.label.ports=function(t){return null},FlowChart.shapeTemplates.label.width="fit",FlowChart.shapeTemplates.label.height="fit",FlowChart.shapeTemplates.label.fill="",FlowChart.shapeTemplates.label.stroke="",FlowChart.shapeTemplates.label.strokeWidth=0,FlowChart.shapeTemplates.label.minWidth=0,FlowChart.shapeTemplates.label.minHeight=0,FlowChart.shapeTemplates.label.displayInShapeBar=!1,FlowChart.shapeTemplates.label.displayInPortShapeBar=!1,FlowChart.shapeTemplates.label.resizable=!1,FlowChart.shapeTemplates.label.type="label",FlowChart.shapeTemplates.labelOverLink=Object.assign({},FlowChart.shapeTemplates.label),FlowChart.shapeTemplates.labelOverLink.offset=function(t){var e=0,r=0;return FlowChart.private.getLabelXY(t,t.link).direction==FlowChart.direction.vertical?e=-t.width/2-10:r=-t.height/2-10,{x:e,y:r}},FlowChart.shapeTemplates.psuedo=Object.assign({},FlowChart.shapeTemplates.base),FlowChart.shapeTemplates.psuedo.displayName="Psuedo",FlowChart.shapeTemplates.psuedo.svg=function(t){return`<circle r="${t.width/2}" cx="${t.width/2}" cy="${t.height/2}" style="stroke:${t.stroke}; fill:${t.fill}; stroke-width:1; opacity: 0;" ></circle>`},FlowChart.shapeTemplates.psuedo.html=function(t){return""},FlowChart.shapeTemplates.psuedo.width=10,FlowChart.shapeTemplates.psuedo.height=10,FlowChart.shapeTemplates.psuedo.fill="red",FlowChart.shapeTemplates.psuedo.stroke="blue",FlowChart.shapeTemplates.psuedo.minWidth=0,FlowChart.shapeTemplates.psuedo.minHeight=0,FlowChart.shapeTemplates.psuedo.displayInShapeBar=!1,FlowChart.shapeTemplates.psuedo.displayInPortShapeBar=!1,FlowChart.shapeTemplates.psuedo.resizable=!1,FlowChart.shapeTemplates.psuedo.type="psuedo-node",FlowChart.MenuBar=class{_;get element(){return this._.getElement()}constructor(t){this._=new FlowChart.MenuBar.private(t)}init(){this._.init()}show(){this._.show()}hide(){this._.hide()}addItem(t){return this._.addItem(t),this}removeItem(t){return this._.removeItem(t),this}},FlowChart.MenuBar.private=class{chart;constructor(t){this.chart=t}refresh(){var t=this.chart.element.querySelector('[data-menu-item="undo"]');t&&(this.chart.options.interactive||0!=this.chart._.undoStepsCount()?t.classList.remove("bfc-disabled-opacity"):t.classList.add("bfc-disabled-opacity"));var e=this.chart.element.querySelector('[data-menu-item="redo"]');e&&(0==this.chart._.redoStepsCount()?e.classList.add("bfc-disabled-opacity"):e.classList.remove("bfc-disabled-opacity"))}simulateMouseClickOnKeydown(t){var e=this.getElement().querySelector(`[data-menu-item="${t}"]`);if(e){var r=function(t){e.classList.remove("bfc-menu-item-selected"),document.removeEventListener("keyup",r)};e.classList.add("bfc-menu-item-selected"),document.addEventListener("keyup",r)}}getElement(){return this.chart.element.querySelector("[data-menubar]")}show(){this.getElement().style.display=""}hide(){this.getElement().style.display="none"}handlerClick(t,e,r){var o={event:t,name:e};!1!==FlowChart.events.publish("menu-item-click",[this.chart,o])&&("undo"==e&&this.chart._.undo(),"redo"==e&&this.chart._.redo())}addItem(t){this.getElement().querySelector("[data-menu-items]").innerHTML+=`<div class="bfc-menu-item" title="${t.title}" data-menu-item="${t.name}">${t.icon}</div>`}removeItem(t){var e=this.getElement().querySelector(`[data-menu-item="${t}"]`);e&&e.parentElement.removeChild(e)}init(){var t=this.getElement(),e=sessionStorage.getItem("menubar-position");e&&(e=JSON.parse(e),t.style.left=e.left+"px",t.style.top=e.top+"px"),t.innerHTML='<div class="bfc-bar-move">\n <div class="bfc-bar-move-line"></div>\n </div>\n <div class="bfc-bar-content" data-menu-items>\n \n </div> ',this.addItem({title:"Undo",icon:FlowChart.icon.undo(26,26,"#8B8B8B",0,0),name:"undo"}),this.addItem({title:"Redo",icon:FlowChart.icon.redo(26,26,"#8B8B8B",0,0),name:"redo"})}},FlowChart.ControlsUI=function(t){this.instance=t,this.uid=FlowChart.private.guid(),this.elements={top_right:null,right_top:null,bottom_right:null,right_bottom:null,top_left:null,left_top:null,bottom_left:null,left_bottom:null,top:null,bottom:null,left:null,right:null}},FlowChart.ControlsUI.prototype.show=function(t){t&&(this.options=t);var e=this,r=function(t){for(var r=t.target;r&&r.hasAttribute&&!r.hasAttribute("data-control-id");)r=r.parentNode;if(r.hasAttribute&&r.hasAttribute("data-control-id")){var o=r.getAttribute("data-control-id"),a=e.options[o];if(!FlowChart.isNEU(a.isOn))r.classList.contains("bfc-control-selected")?r.classList.remove("bfc-control-selected"):r.classList.add("bfc-control-selected");FlowChart.events.publish("control-click",[e,{isOn:r.classList.contains("bfc-control-selected"),key:o,control:a}])}};if(this.options){this.hide();var o={top_right:"",right_top:"",bottom_right:"",right_bottom:"",top_left:"",left_top:"",bottom_left:"",left_bottom:"",top:"",bottom:"",left:"",right:""};for(var a in this.options){var i=this.options[a],s=i.icon;void 0===s&&(s=FamilyTree2.icon[a]?FamilyTree2.icon[a](32,32,"#7A7A7A",0,0):FamilyTree2.icon.cursor(32,32,"#7A7A7A",0,0));var h=i.title;h||(h=a);var l="";!0===i.isOn&&(l='class="bfc-control-selected"');var n=`<div ${l} data-control-id="${a}" title="${h}">${s}</div>`;i.anchor||(i.anchor=FamilyTree2.anchor.topLeft),o[i.anchor]+=n}for(var a in o)o[a]&&(this.elements[a]=document.createElement("div"),this.elements[a].className="bfc-controls bfc-controls-"+a,this.elements[a].innerHTML=o[a],this.elements[a].addEventListener("click",r),this.instance.element.appendChild(this.elements[a]))}},FlowChart.ControlsUI.prototype.hide=function(){for(var t in this.elements)if(this.elements[t]){var e=this.elements[t];e.parentNode.removeChild(e)}},FlowChart.ControlsUI.prototype.on=function(t,e){return FlowChart.events.on(t,e,this.uid),this},FlowChart.private.prototype.showPortsUI=function(){this.hidePortsUI();var t=this.chart.ports.getElement(this.selectedPortShape.id),e=this.selectedPortShape.element;!t&&e&&((t=document.createElementNS("http://www.w3.org/2000/svg","g")).classList.add("bfc-s-ports"),t.setAttribute("data-ports-s-id",this.selectedPortShape.id),t.setAttribute("transform",`translate(${this.selectedPortShape.left},${this.selectedPortShape.top})`),t.innerHTML=this.portHTMLUI(this.selectedPortShape,this.chart.scale),e.parentNode.insertBefore(t,e))},FlowChart.private.prototype.hidePortsUI=function(){this.hidePortShapeBarUI();for(var t=this.chart.svgElement.querySelectorAll("[data-ports-s-id]"),e=0;e<t.length;e++)t[e].parentNode.removeChild(t[e])},FlowChart.private.prototype.updatePortsElement=function(t){var e=this.chart.svgElement.querySelector("[data-ports-s-id]");if(e){e.setAttribute("transform",`translate(${this.selectedPortShape.left},${this.selectedPortShape.top})`);var r=e.getAttribute("data-ports-s-id"),o=this.chart.getShape(r);e.innerHTML=this.portHTMLUI(o,t)}},FlowChart.private.prototype.portHTMLUI=function(t,e){var r="",o=FlowChart.shapeTemplates[t.templateId],a=o.ports(t);if(!FlowChart.isNEU(a)){for(var i in a){var s=a[i],h=40,l=40,n=s.x,c=s.y,p=0;switch(FlowChart.private.getPortPosition(s,t)){case FlowChart.position.topRight:c-=l/e,p=45;break;case FlowChart.position.bottomRight:p=135;break;case FlowChart.position.bottomLeft:n-=h/e,p=225;break;case FlowChart.position.topLeft:n-=h/e,c-=l/e,p=-45;break;case FlowChart.position.left:n-=h/e,c-=l/2/e,p=-90;break;case FlowChart.position.right:c-=l/2/e,p=90;break;case FlowChart.position.top:n-=h/2/e,c-=l/e;break;case FlowChart.position.bottom:n-=h/2/e,p=-180}r+=`<g class="bfc-port-out" data-port-out-port="${i}" data-port-out-shape="${t.id}" transform="rotate(${p})"><rect style="opacity: 0" x="${n}" y="${c}" width="${h/e}" height="${l/e}"></rect>${FlowChart.icon.arrow(h/e,l/e,"#ffca28",n,c)}</g>`}r=`<rect style="opacity: 0" x="${-h/e}" y="${-l/e}" width="${t.width+h/e*2}" height="${t.height+l/e*2}"></rect>`+r}return r},FlowChart.private.prototype.hidePortShapeBarUI=function(){for(var t=this.chart.element.querySelectorAll("[data-portsb-shape]"),e=0;e<t.length;e++)t[e].parentNode.removeChild(t[e])},FlowChart.private.prototype.portShapeBarHTMLUI=function(){var t="";for(var e in FlowChart.shapeTemplates){var r=FlowChart.shapeTemplates[e];if(r.displayInPortShapeBar){var o={templateId:e};o.width="fit"==r.width?r.minWidth:r.width,o.height="fit"==r.height?r.minHeight:r.height,o.fill=r.fill,o.stroke=r.stroke,o.strokeWidth=r.strokeWidth,t+=`<div data-portshapebar-item-id="${e}">\n <svg class="bfc-portshapebar-svg ${o.templateId}" viewBox="0 0 ${o.width} ${o.height}" preserveAspectRatio="xMidYMid meet" >\n ${r.svg(o)}\n </svg> \n </div>`}}return t},FlowChart.private.prototype.showPortShapeBarUI=function(t){var e=this.chart.ports.getByPosition(this.chart.selectedShapes.last,t);e&&e.length&&(this.chart.selectedPort=e[0],this.selectPortShapeShapeBarItem(!1,this.lastAddedTemplateIdFormPortShapeBar))},FlowChart.private.prototype.navigatePortShapeBarItems=function(t){var e=this.chart.element.querySelector("[data-portsb-shape]");if(e){var r=e.getAttribute("data-portsb-shape"),o=e.getAttribute("data-portsb-port"),a=this.chart.ports.get(r,o),i=FlowChart.shapeTemplates[a.shape.templateId],s=FlowChart.private.getPortPosition(i.ports(a.shape)[a.id],a.shape);s==FlowChart.position.left&&(t==FlowChart.position.bottom&&this.selectPortShapeShapeBarItem(!0),t==FlowChart.position.top&&this.selectPortShapeShapeBarItem(!1),t==FlowChart.position.right&&this.showPortShapeBarByPosition(t)),s==FlowChart.position.right&&(t==FlowChart.position.bottom&&this.selectPortShapeShapeBarItem(!0),t==FlowChart.position.top&&this.selectPortShapeShapeBarItem(!1),t==FlowChart.position.left&&this.showPortShapeBarByPosition(t)),s==FlowChart.position.top&&(t==FlowChart.position.right&&this.selectPortShapeShapeBarItem(!0),t==FlowChart.position.left&&this.selectPortShapeShapeBarItem(!1),t==FlowChart.position.bottom&&this.showPortShapeBarByPosition(t)),s==FlowChart.position.bottom&&(t==FlowChart.position.right&&this.selectPortShapeShapeBarItem(!0),t==FlowChart.position.left&&this.selectPortShapeShapeBarItem(!1),t==FlowChart.position.top&&this.showPortShapeBarByPosition(t))}else this.showPortShapeBarByPosition(t)},FlowChart.private.prototype.showPortShapeBarByPosition=function(t){var e=this.chart.ports.getByPosition(t);if(e&&e.length){var r=e[0];this.showPortShapeBar(r),this.selectPortShapeShapeBarItem(!1)}},FlowChart.private.prototype.createNodeFromPorsShapeBarItem=function(){this.selectedPort;var t=this,e=this.selectedPort,r=this.chart.element.querySelector(`[data-portsb-shape="${e.shape.id}"][data-portsb-port="${e.id}"]`),o=r.querySelector(".bfc-portshapebar-selected");if(o){this.chart.editor.hasActiveField()&&this.chart.editor.blur();var a=r.getAttribute("data-portsb-shape"),i=r.getAttribute("data-portsb-port"),s=this.chart.ports.get(a,i),h=o.getAttribute("data-portshapebar-item-id");this.lastAddedTemplateIdFormPortShapeBar=h,this.addNodeWithLink(s,h,function(e,r){t.chart.selectedShapes.clear(),t.chart.selectedShapes.add(e)})}},FlowChart.private.prototype.selectPortShapeShapeBarItem=function(t,e){var r=this.chart.element.querySelector("[data-portsb-shape]");if(r){for(var o=r.querySelectorAll("[data-portshapebar-item-id]"),a=-1,i=0;i<o.length;i++){(s=o[i]).classList.contains("bfc-portshapebar-selected")&&(a=i,s.classList.remove("bfc-portshapebar-selected"))}if(e){for(var s of o)if(s.getAttribute("data-portshapebar-item-id")==e){s.classList.add("bfc-portshapebar-selected");break}}else{t?a++:a--,a>=o.length?a=0:a<0&&(a=o.length-1);for(i=0;i<o.length;i++){s=o[i];a==i&&s.classList.add("bfc-portshapebar-selected")}}}},FlowChart.private.prototype.showPortShapeBar=function(){for(var t=this.chart.element.querySelectorAll("[data-portsb-shape]"),e=0;e<t.length;e++)t[e].parentNode.removeChild(t[e]);var r=this.portShapeBarHTMLUI(this.selectedPort),o=document.createElement("div");o.classList.add("bfc-portshapebar"),o.setAttribute("data-portsb-shape",`${this.selectedPort.shape.id}`),o.setAttribute("data-portsb-port",`${this.selectedPort.id}`),o.innerHTML=r,this.chart.element.appendChild(o);var a=this.chart.svgElement.querySelector(`[data-port-out-shape="${this.selectedPort.shape.id}"][data-port-out-port="${this.selectedPort.id}"]`),i=this.chart.svgElement.querySelector(`[data-ports-s-id="${this.selectedPort.shape.id}"]`),s=this.chart.svgElement.querySelectorAll(".bfc-ports-visible");for(var h of s)h.classList.remove("bfc-ports-visible");i.classList.add("bfc-ports-invisible"),a.classList.add("bfc-ports-visible");var l=a.getBoundingClientRect(),n=this.chart.element.getBoundingClientRect(),c=o.getBoundingClientRect(),p=0,d=0,f=parseFloat(window.getComputedStyle(o,null).getPropertyValue("padding-top")),u=parseFloat(window.getComputedStyle(o,null).getPropertyValue("padding-bottom")),w=0;switch(this.selectedPort.position){case FlowChart.position.top:p=l.left+l.width/2-n.left-c.width/2,d=l.top-n.top-c.height+3;break;case FlowChart.position.bottom:p=l.left+l.width/2-n.left-c.width/2,d=l.bottom-n.top-3;break;case FlowChart.position.left:o.style.width=c.height-(f+u)+"px",c=o.getBoundingClientRect(),p=l.left-n.left-c.width+3,d=l.bottom-n.top-l.height/2-c.height/2;break;case FlowChart.position.right:o.style.width=c.height-(f+u)+"px",c=o.getBoundingClientRect(),p=l.right-n.left-3,d=l.bottom-n.top-l.height/2-c.height/2;break;case FlowChart.position.topLeft:w=135,p=l.left-n.left-c.width/2+3,d=l.top-n.top-c.height/2+3;break;case FlowChart.position.topRight:w=45,p=l.right-n.left-c.width/2-3,d=l.top-n.top-c.height/2+3;break;case FlowChart.position.bottomRight:w=135,p=l.right-n.left-c.width/2-3,d=l.bottom-n.top-c.height/2-3;break;case FlowChart.position.bottomLeft:w=45,p=l.left-n.left-c.width/2+3,d=l.bottom-n.top-c.height/2-3}o.style.left=p+"px",o.style.top=d+"px",o.style.transformOrigin="center",o.style.transform=`rotate(${w}deg)`},FlowChart.SelectedShapeCollection=class extends Array{_;constructor(t){super(),this._=new FlowChart.SelectedShapeCollection.private(t)}get first(){return this.length?this[0]:null}get last(){return this.length?this[this.length-1]:null}get nodes(){var t=[];for(var e of this)"label"!=e.type&&t.push(e);return t}get labels(){var t=[];for(var e of this)"label"==e.type&&t.push(e);return t}add(t){t.selected?-1==this.indexOf(t)&&(this._.chart._.snap(),this.push(t),this._.chart._.changed({property:"selectedShapes"})):t.selected=!0}remove(t){if(t.selected)t.selected=!1;else for(var e=this.length-1;e>=0;e--)if(t==this[e])return this._.chart._.snap(),this.splice(e,1),void this._.chart._.changed({property:"selectedShapes"})}clear(){this.length&&(this._.chart._.snap(),this._.chart.nodes._.clearSelectedMetadata(),this._.chart.labels._.clearSelectedMetadata(),this._.removeSelectorElement(),this.splice(0,this.length),this._.chart._.changed({property:"selectedShapes"}))}addRange(t){for(var e of t)this.add(e)}get(t){for(var e of this)if(e.id==t)return e;return null}contains(t){return null!=this.get(t)}selectNodeRight(t){this._.selectRight(this._.chart.nodes,t,this)}selectNodeLeft(t){this._.selectLeft(this._.chart.nodes,t,this)}selectNodeAbove(t){this._.selectAbove(this._.chart.nodes,t,this)}selectNodeBelow(t){this._.selectBelow(this._.chart.nodes,t,this)}},FlowChart.SelectedShapeCollection.private=class{chart;arrayBeforeShiftPressed;constructor(t){this.chart=t,this.arrayBeforeShiftPressed=[]}selectRight(t,e,r){var o=r[r.length-1],a=null;for(var i of t){var s;if(i!=o)if(o.right-i.left<=0)if(null==a)a={shape:i,hypot:s=Math.hypot(i.y-o.y,i.left-o.right)};else(s=Math.hypot(i.y-o.y,i.left-o.right))<a.hypot&&(a={shape:i,hypot:s})}this.hideAndShowNext(a,e,r)}selectLeft(t,e,r){var o=r[r.length-1],a=null;for(var i of t){var s;if(i!=o)if(o.left-i.right>=0)if(null==a)a={shape:i,hypot:s=Math.hypot(i.y-o.y,i.right-o.left)};else(s=Math.hypot(i.y-o.y,i.right-o.left))<a.hypot&&(a={shape:i,hypot:s})}this.hideAndShowNext(a,e,r)}selectAbove(t,e,r){var o=r[r.length-1],a=null;for(var i of t){var s;if(i!=o)if(o.top-i.bottom>=0)if(null==a)a={shape:i,hypot:s=Math.hypot(i.x-o.x,i.bottom-o.top)};else(s=Math.hypot(i.x-o.x,i.bottom-o.top))<a.hypot&&(a={shape:i,hypot:s})}this.hideAndShowNext(a,e,r)}selectBelow(t,e,r){var o=r[r.length-1],a=null;for(var i of t){var s;if(o.bottom-i.top<=0)if(null==a)a={shape:i,hypot:s=Math.hypot(i.x-o.x,i.top-o.bottom)};else(s=Math.hypot(i.x-o.x,i.top-o.bottom))<a.hypot&&(a={shape:i,hypot:s})}this.hideAndShowNext(a,e,r)}hideAndShowNext(t,e,r){if(t){for(var o of(e&&r.clear(),r))-1==this.arrayBeforeShiftPressed.indexOf(o)&&(o.selected=!1);t.shape.selected=!0,this.chart.makeShapesVisible(t.shape)}}update(t,e){var r=this.chart.svgElement.querySelector(`[data-selector-shape-id="${t.id}"]`);if(r){FlowChart.shapeTemplates[t.templateId];var o=r.querySelector(".bfc-selector-rect");o.setAttribute("x",0),o.setAttribute("y",0),o.setAttribute("width",t.width),o.setAttribute("height",t.height),o.setAttribute("stroke-width",t.strokeWidth);for(var a=1;a<=2;a++){var i=r.querySelector(`[data-selector-dot-${a}="topLeft"]`);i&&(i.setAttribute("cx",0),i.setAttribute("cy",0));var s=r.querySelector(`[data-selector-dot-${a}="top"]`);s&&(s.setAttribute("cx",t.width/2),s.setAttribute("cy",0));var h=r.querySelector(`[data-selector-dot-${a}="topRight"]`);h&&(h.setAttribute("cx",t.width),h.setAttribute("cy",0));var l=r.querySelector(`[data-selector-dot-${a}="right"]`);l&&(l.setAttribute("cx",t.width),l.setAttribute("cy",t.height/2));var n=r.querySelector(`[data-selector-dot-${a}="bottomRight"]`);n&&(n.setAttribute("cx",t.width),n.setAttribute("cy",t.height));var c=r.querySelector(`[data-selector-dot-${a}="bottom"]`);c&&(c.setAttribute("cx",t.width/2),c.setAttribute("cy",t.height));var p=r.querySelector(`[data-selector-dot-${a}="bottomLeft"]`);p&&(p.setAttribute("cx",0),p.setAttribute("cy",t.height));var d=r.querySelector(`[data-selector-dot-${a}="left"]`);d&&(d.setAttribute("cx",0),d.setAttribute("cy",t.height/2))}}}hideUI(){var t=this.chart.svgElement.querySelectorAll("[data-selector-shape-id]");for(var e of t)e.style.display="none"}showUI(){var t=this.chart.svgElement.querySelectorAll("[data-selector-shape-id]");for(var e of t)e.style.display=""}removeSelectorElement(t){if(t){(r=this.chart.svgElement.querySelector(`[data-selector-shape-id="${t.id}"]`))&&r.parentNode.removeChild(r)}else{var e=this.chart.svgElement.querySelectorAll("[data-selector-shape-id]");for(var r of e)r.parentNode.removeChild(r)}}createSelectorElement(t){this.removeSelectorElement(t);var e=document.createElementNS("http://www.w3.org/2000/svg","g");e.classList.add("bfc-selector"),e.setAttribute("data-selector-shape-id",t.id),e.innerHTML=this.html(t,this.chart.scale),t.element.querySelector(".bfc-html").after(e)}getBox(){var t={x:void 0,y:void 0,top:Number.MAX_SAFE_INTEGER,bottom:Number.MIN_SAFE_INTEGER,right:Number.MIN_SAFE_INTEGER,left:Number.MAX_SAFE_INTEGER,width:void 0,height:void 0};for(var e of this.chart.selectedShapes){FlowChart.shapeTemplates[e.templateId];e.left<t.left&&(t.left=e.left),e.top<t.top&&(t.top=e.top),e.right>t.right&&(t.right=e.right),e.bottom>t.bottom&&(t.bottom=e.bottom)}return t.width=t.right-t.left,t.height=t.bottom-t.top,t.x=t.left+t.width/2,t.y=t.top+t.height/2,t}html(t,e){var r=1/e,o=(FlowChart.shapeTemplates[t.templateId],`<rect stroke-width="${t.strokeWidth}" class="bfc-selector-rect" x="0" y="0" width="${t.width}" height="${t.height}"></rect>`);return t.resizable&&this.chart.selectedShapes.nodes.length>0&&(o+=`<circle transform="scale(${r})" data-selector-dot-1="topLeft" cx="0" cy="0" r="5"></circle>\n <circle transform="scale(${r})" data-selector-dot-1="top" cx="${t.width/2}" cy="0" r="5"></circle>\n <circle transform="scale(${r})" data-selector-dot-1="topRight" cx="${t.width}" cy="0" r="5"></circle>\n <circle transform="scale(${r})" data-selector-dot-1="right" cx="${t.width}" cy="${t.height/2}" r="5"></circle>\n <circle transform="scale(${r})" data-selector-dot-1="bottomRight" cx="${t.width}" cy="${t.height}" r="5"></circle>\n <circle transform="scale(${r})" data-selector-dot-1="bottom" cx="${t.width/2}" cy="${t.height}" r="5"></circle>\n <circle transform="scale(${r})" data-selector-dot-1="bottomLeft" cx="0" cy="${t.height}" r="5"></circle>\n <circle transform="scale(${r})" data-selector-dot-1="left" cx="0" cy="${t.height/2}" r="5"></circle> \n \n <circle transform="scale(${r})" data-selector-dot-2="topLeft" cx="0" cy="0" r="10"></circle>\n <circle transform="scale(${r})" data-selector-dot-2="top" cx="${t.width/2}" cy="0" r="10"></circle>\n <circle transform="scale(${r})" data-selector-dot-2="topRight" cx="${t.width}" cy="0" r="10"></circle>\n <circle transform="scale(${r})" data-selector-dot-2="right" cx="${t.width}" cy="${t.height/2}" r="10"></circle>\n <circle transform="scale(${r})" data-selector-dot-2="bottomRight" cx="${t.width}" cy="${t.height}" r="10"></circle>\n <circle transform="scale(${r})" data-selector-dot-2="bottom" cx="${t.width/2}" cy="${t.height}" r="10"></circle>\n <circle transform="scale(${r})" data-selector-dot-2="bottomLeft" cx="0" cy="${t.height}" r="10"></circle>\n <circle transform="scale(${r})" data-selector-dot-2="left" cx="0" cy="${t.height/2}"r="10"></circle>`),o}},FlowChart.Editor=class{_;element;constructor(t){this._=new FlowChart.Editor.private(t)}blur(){this._.blur()}clearFieldBorders(){this._.clearFieldBorders()}editFirstFieldIfAny(t){this._.editFirstFieldIfAny(t)}getFieldNames(t){return this._.getFieldNames(t)}hasActiveField(){return this._.hasActiveField()}edit(t,e){this._.edit(t,e)}selectNextField(){this._.selectNextField()}},FlowChart.Editor.private=class{chart;constructor(t){this.chart=t}getFieldNames(t){for(var e=[],r=t.element.querySelectorAll("[data-field]"),o=0;o<r.length;o++){var a=r[o].getAttribute("data-field");e.push(a)}return e}editFirstFieldIfAny(t){var e=this.getFieldNames(t);e.length&&this.edit(t,e[0])}blur(){if(this.chart.options.editable)for(var t=this.chart.svgElement.querySelectorAll("[contenteditable]"),e=0;e<t.length;e++){t[e].blur()}}selectNextField(){for(var t=this.chart.svgElement.querySelector("[contenteditable]"),e=t.parentNode;e&&e.hasAttribute&&!e.hasAttribute("data-shape-id");)e=e.parentNode;if(e&&e.hasAttribute&&e.hasAttribute("data-shape-id")){var r=t.getAttribute("data-field"),o=e.getAttribute("data-shape-id"),a=this.chart.getShape(o),i=this.getFieldNames(a),s=i.indexOf(r);++s>=i.length&&(s=0),this.edit(a,i[s])}}clearFieldBorders(){for(var t=this.chart.svgElement.querySelectorAll(".bfc-field-border"),e=t.length-1;e>=0;e--)t[e].parentNode.removeChild(t[e])}hasActiveField(){return null!=this.chart.svgElement.querySelector("[data-field][contenteditable]")}edit(t,e){if(this.chart.options.editable){t.element;for(var r=t.element.querySelectorAll("[data-field-selector]"),o=0;o<r.length;o++)r[o].parentNode.removeChild(r[o]);var a=t.element.querySelectorAll("[data-field]");for(o=0;o<a.length;o++){var i=(g=a[o]).getAttribute("data-field"),s=i;g.hasAttribute("data-title")&&(s=g.getAttribute("data-title"));var h=g.getBoundingClientRect(),l=h.left,n=h.top,c=h.width,p=h.height,d=l-t.left*this.chart.scale,f=n-t.top*this.chart.scale;const e=new DOMPoint(d,f);var u=this.chart.svgElement.getScreenCTM().inverse();const r=e.matrixTransform(u);var w=document.createElementNS("http://www.w3.org/2000/svg","rect");w.setAttribute("width",c/this.chart.scale),w.setAttribute("height",p/this.chart.scale),w.setAttribute("x",r.x),w.setAttribute("y",r.y),w.setAttribute("data-field-selector",i),w.classList.add("bfc-field-border"),w.innerHTML=`<title>${s}</title>`,t.element.querySelector(".bfc-html").after(w)}if(e){var m=this,C=this.chart.svgElement.querySelectorAll("[contenteditable]");for(o=0;o<C.length;o++){C[o].blur()}var g;(g=this.chart.svgElement.querySelector(`[data-shape-id="${t.id}"] [data-field="${e}"]`)).setAttribute("contenteditable",""),g.addedPasteEventHandler||(g.addEventListener("paste",function(t){t.preventDefault();var e=t.clipboardData.getData("text/plain");document.execCommand("insertText",!1,e)}),g.addedPasteEventHandler=!0);var v=document.createRange();v.selectNodeContents(g);var y=window.getSelection();y.removeAllRanges(),y.addRange(v),setTimeout(function(){g.focus(),g.blurAdded||(g.addEventListener("blur",function(t){var e=m.chart.svgElement.querySelector("[contenteditable]"),r=e.getAttribute("data-field"),o=e.innerHTML.trim();"<br>"==o&&(o="");for(var a=e;!a.hasAttribute("data-shape-id");)a=a.parentNode;var i=a.getAttribute("data-shape-id");m.chart.getShape(i)[r]=o,e.removeAttribute("contenteditable")}),g.blurAdded=!0)},10)}}}},FlowChart.private.prototype.reposition=function(t,e,r,o){if(this.chart.nodes.length){var a=this;t||(t=this.chart.options.startPosition);var i=this.svgBCR.width,s=this.svgBCR.height,h=i/2,l=s/2,n=this.chart.viewBox,c=this.chart.nodes.right-this.chart.nodes.left+2*FlowChart.PADDING,p=this.chart.nodes.bottom-this.chart.nodes.top+2*FlowChart.PADDING,d=!0;switch(t){case FlowChart.startPosition.center:if(e){var f=Number.MAX_SAFE_INTEGER,u=Number.MIN_SAFE_INTEGER,w=Number.MAX_SAFE_INTEGER,m=Number.MIN_SAFE_INTEGER;for(var C of e)C.top<f&&(f=C.top),C.bottom>u&&(u=C.bottom),C.left<w&&(w=C.left),C.right>m&&(m=C.right);var g=m-w,v=u-f,y=FlowChart.private.getFitScale(i,s,t,this.chart.options.scaleMax,this.chart.options.scaleMin,g+2*FlowChart.PADDING,v+2*FlowChart.PADDING);(n=FlowChart.private.getViewBoxByScale(y,this.chart.options,n,this.chart._.svgBCR))[0]=w-(i/y-g)/2,n[1]=f-(s/y-v)/2}else n[0]=this.chart.nodes.left+(this.chart.nodes.right-this.chart.nodes.left)/2-h/this.chart.scale,n[1]=this.chart.nodes.top+(this.chart.nodes.bottom-this.chart.nodes.top)/2-l/this.chart.scale;break;case FlowChart.startPosition.centerTop:C=this.chart.nodes._.minShapeY;n[0]=C.x-h/this.chart.scale,n[1]=C.top-FlowChart.PADDING;break;case FlowChart.startPosition.centerBottom:C=this.chart.nodes._.maxShapeY;n[0]=C.x-h/this.chart.scale,n[1]=C.bottom+FlowChart.PADDING-s/this.chart.scale;break;case FlowChart.startPosition.centerRight:C=this.chart.nodes._.minShapeX;n[0]=C.left-FlowChart.PADDING,n[1]=C.y-l/this.chart.scale;break;case FlowChart.startPosition.centerLeft:C=this.chart.nodes._.maxShapeX;n[0]=C.right+FlowChart.PADDING-i/this.chart.scale,n[1]=C.y-l/this.chart.scale;break;case FlowChart.startPosition.fitHeight:case FlowChart.startPosition.fitWidth:case FlowChart.startPosition.fit:case FlowChart.startPosition.fit1:y=FlowChart.private.getFitScale(i,s,t,this.chart.options.scaleMax,this.chart.options.scaleMin,c,p);c=this.chart.nodes.right-this.chart.nodes.left+2*FlowChart.PADDING/y,p=this.chart.nodes.top-this.chart.nodes.left+2*FlowChart.PADDING/y,(n=FlowChart.private.getViewBoxByScale(y,this.chart.options,n,this.chart._.svgBCR))[0]=this.chart.nodes._.minShapeX.left-(i/y-(this.chart.nodes._.maxShapeX.right-this.chart.nodes._.minShapeX.left))/2,n[1]=this.chart.nodes._.minShapeY.top-(s/y-(this.chart.nodes._.maxShapeY.bottom-this.chart.nodes._.minShapeY.top))/2;break;case FlowChart.startPosition.centerShapes:f=Number.MAX_SAFE_INTEGER,u=Number.MIN_SAFE_INTEGER,w=Number.MAX_SAFE_INTEGER,m=Number.MIN_SAFE_INTEGER;for(var C of e)C.top<f&&(f=C.top),C.bottom>u&&(u=C.bottom),C.left<w&&(w=C.left),C.right>m&&(m=C.right);g=m-w,v=u-f,y=FlowChart.private.getFitScale(i,s,t,this.chart.options.scaleMax,this.chart.options.scaleMin,g+2*FlowChart.PADDING,v+2*FlowChart.PADDING);(n=FlowChart.private.getViewBoxByScale(y,this.chart.options,n,this.chart._.svgBCR))[0]=w-(i/y-g)/2,n[1]=f-(s/y-v)/2;break;default:d=!1}d&&(r?(this._repositionTimeout&&(clearTimeout(this._repositionTimeout),this._repositionTimeout=null),this._repositionTimeout=FlowChart.animate(this.chart.svgElement,{viewBox:this.chart.viewBox},{viewBox:n},300,FlowChart.anim.outPow,function(){o&&o.call(a.chart)})):(this.chart.viewBox=n,o&&o.call(a.chart)))}},FlowChart.private.prototype.makeShapesVisible=function(t,e){var r=this;this.makeShapesVisibleInterval&&(clearInterval(this.makeShapesVisibleInterval),this.makeShapesVisibleInterval=null);var o={top:Number.MAX_SAFE_INTEGER,left:Number.MAX_SAFE_INTEGER,right:Number.MIN_SAFE_INTEGER,bottom:Number.MIN_SAFE_INTEGER},a=this.svgBCR.width,i=this.svgBCR.height;for(var s of t)s.top<o.top&&(o.top=s.top),s.bottom>o.bottom&&(o.bottom=s.bottom),s.left<o.left&&(o.left=s.left),s.right>o.right&&(o.right=s.right);var h=this.chart.viewBox,l=h.slice();h[0]=Math.max(o.right+FlowChart.PADDING-a/this.chart.scale,h[0]),h[1]=Math.max(o.bottom+FlowChart.PADDING-i/this.chart.scale,h[1]),h[0]=Math.min(o.left-FlowChart.PADDING,h[0]),h[1]=Math.min(o.top-FlowChart.PADDING,h[1]),l[0]!=h[0]||l[1]!=h[1]?this.makeShapesVisibleInterval=FlowChart.private.animate(this.chart.svgElement,{viewBox:l},{viewBox:h},300,FlowChart.anim.outPow,function(){e&&e.call(r.chart)}):e&&e.call(r.chart)},FlowChart.private.prototype.animateShapes=function(t,e,r,o){var a=this;FlowChart.private.animate(t,e,r,300,FlowChart.anim.outPow,function(){o&&o.call(a.chart)})},FlowChart.events.on("init",function(t){t.menuBar._.refresh(),t.colorBar._.refresh(),t.statusBar._.refreshHint()}),FlowChart.events.on("changed",function(t,e){t.colorBar._.refresh(),t.menuBar._.refresh(),t.statusBar._.refreshHint()}),FlowChart.events.on("undo-redo-changed",function(t){t.colorBar._.refresh(),t.menuBar._.refresh(),t.statusBar._.refreshHint()}),FlowChart.events.on("selected-shapes-changed",function(t){t.colorBar._.refresh(),t.menuBar._.refresh(),t.statusBar._.refreshHint()}),FlowChart.events.on("selected-port-change",function(t,e){setTimeout(function(){t.colorBar._.refresh(),t.menuBar._.refresh(),t.statusBar._.refreshHint()},10)}),FlowChart.StatusBar=class{_;constructor(t){this._=new FlowChart.StatusBar.private(t)}get element(){return this._.getElement()}get content(){return this._.getContent()}set content(t){this._.setContent(t)}init(){this._.init()}show(){this._.show()}hide(){this._.hide()}isVisible(){return"none"!=this._.getElement().style.display}},FlowChart.StatusBar.private=class{chart;useRefreshHint;constructor(t){this.chart=t,this.useRefreshHint=!0}init(){this.getElement().innerHTML="<div data-status-hint> </div>"}show(){this.getElement().style.display=""}hide(){this.getElement().style.display="none"}getElement(){return this.chart.element.querySelector(".bfc-statusbar")}refreshHint(){if(this.useRefreshHint){var t=this.chart._.getActiveComponentTypes();if(-1!=t.indexOf("shape")&&this.chart.selectedShapes.nodes.length==this.chart.nodes.length)this.setContent("Press F to fit to page and center.");else if(-1!=t.indexOf("node")){for(var e=this.chart.selectedShapes.last,r=[],o=0;o<this.chart.options.colors.length;o++){var a=this.chart.options.colors[o];e.fill!=a&&r.push(o+1)}var i="";for(o=0;o<r.length;o++)0==o?i+=r[o]:o==r.length-1?i+=` or ${r[o]}`:i+=`, ${r[o]}`;this.setContent(`Press CTRL + Arrow to open port; Press Interval or Enter to edit; Press ${i} to change the color;`)}else if(-1!=t.indexOf("label"))this.setContent("Press Interval or Edit to edit the label;");else if(-1!=t.indexOf("field")){this.chart.selectedShapes.last;this.setContent("Press Escape to finish editing; Press CTRL + Arrow to open port;")}else-1!=t.indexOf("port-shape-bar")?this.setContent("Select Shape with Arrows and press eneter to add new node;"):-1!=t.indexOf("canvas")&&this.setContent("Press CTRL + A to select all shapes and then press F to fit to page and center.")}}getContent(){var t=this.getElement().querySelector("[data-status-hint]");return t?t.innerHTML:""}setContent(t){""==t&&(t=" ");var e=this.getElement().querySelector("[data-status-hint]");e&&(e.innerHTML=t)}},FlowChart.ShapeBar=class{_;get element(){return this._.getElement()}constructor(t){this._=new FlowChart.ShapeBar.private(t)}init(){this._.init()}show(){this._.show()}hide(){this._.hide()}},FlowChart.ShapeBar.private=class{chart;constructor(t){this.chart=t}getElement(){return this.chart.element.querySelector("[data-shapebar]")}show(){this.getElement().style.display=""}hide(){this.getElement().style.display="none"}init(){var t="";for(var e in FlowChart.shapeTemplates){var r=FlowChart.shapeTemplates[e];if(r.displayInShapeBar){var o={templateId:e};o.width="fit"==r.width?r.minWidth:r.width,o.height="fit"==r.width?r.minHeight:r.height,o.strokeWidth=r.strokeWidth,o.fill=r.fill;var a=r.displayName;t+=`<div data-shapebar-item-id="${e}">\n <svg class="bfc-shapebar-svg ${o.templateId}" viewBox="0 0 ${o.width} ${o.height}" preserveAspectRatio="xMidYMid meet" >\n ${r.svg(o)}\n </svg>\n <div>${a}</div> \n </div>`}}var i=this.getElement(),s=sessionStorage.getItem("shapebar-position");s&&(s=JSON.parse(s),i.style.left=s.left+"px",i.style.top=s.top+"px"),i.innerHTML=`<div class="bfc-bar-move">\n <div class="bfc-bar-move-line"></div>\n </div>\n <div class="bfc-shapebar-shapes bfc-bar-content">\n ${t} \n </div> `}},FlowChart.ColorBar=class{_;get element(){return this._.getElement()}constructor(t){this._=new FlowChart.ColorBar.private(t)}init(){this._.init()}show(){this._.show()}hide(){this._.hide()}},FlowChart.ColorBar.private=class{chart;constructor(t){this.chart=t}refresh(){var t=this.chart.element.querySelector("[data-color-palette]"),e=this.chart._.getActiveComponentTypes();for(var r of t.children)this.chart.options.interactive&&-1!=e.indexOf("shape")?r.classList.remove("bfc-disabled-grayscale"):r.classList.add("bfc-disabled-grayscale")}simulateMouseClickOnKeydown(t){var e=this.getElement().querySelector(`[data-menu-item="${t}"]`);if(e){var r=function(t){e.classList.remove("bfc-menu-item-selected"),document.removeEventListener("keyup",r)};e.classList.add("bfc-menu-item-selected"),document.addEventListener("keyup",r)}}handlerClick(t,e,r){var o={event:t,name:e};if(!1!==FlowChart.events.publish("menu-item-click",[this.chart,o])&&0==e.indexOf("color-")){var a=e.split("-")[1];this.chart._.changeFill(a)}}getElement(){return this.chart.element.querySelector("[data-colorbar]")}show(){this.getElement().style.display=""}hide(){this.getElement().style.display="none"}init(){for(var t="",e=0;e<this.chart.options.colors.length;e++){t+=`<div class="bfc-menu-item" data-color-item="${e}" data-menu-item="color-${e}"><div class="bfc-color-item" style="background-color: ${this.chart.options.colors[e]}">${e+1}</div></div>`}t&&(t=`<div data-color-palette class="bfc-color-palette">${t}</div>`);var r=this.getElement(),o=sessionStorage.getItem("colorbar-position");o&&(o=JSON.parse(o),r.style.right="unset",r.style.bottom="unset",r.style.left=o.left+"px",r.style.top=o.top+"px"),r.innerHTML=`<div class="bfc-bar-move">\n <div class="bfc-bar-move-line"></div>\n </div>\n <div class="bfc-colorbar-colors bfc-bar-content">\n ${t} \n </div> `}},FlowChart.private.prototype.undo=function(){if(this.chart.options.useSession){var t=this.undoStepsCount();if(0!=t){this.putInRedoStack();var e=`${this.uid}_undo_`+(t-1),r=sessionStorage.getItem(e);sessionStorage.removeItem(e);var o=JSON.parse(r);this.chart.load(o),FlowChart.events.publish("undo-redo-changed",[this.chart])}}},FlowChart.private.prototype.redo=function(){if(this.chart.options.useSession){var t=this.redoStepsCount();if(0!=t){this.putInUndoStack();var e=`${this.uid}_redo_`+(t-1),r=sessionStorage.getItem(e);sessionStorage.removeItem(e);var o=JSON.parse(r);this.chart.load(o),FlowChart.events.publish("undo-redo-changed",[this.chart])}}},FlowChart.private.prototype.undoStepsCount=function(){if(!this.chart.options.useSession)return 0;for(var t=`${this.uid}_undo_`,e=Object.keys(sessionStorage),r=0;-1!=e.indexOf(t+r);)r++;return r},FlowChart.private.prototype.redoStepsCount=function(){if(!this.chart.options.useSession)return 0;for(var t=`${this.uid}_redo_`,e=Object.keys(sessionStorage),r=0;-1!=e.indexOf(t+r);)r++;return r},FlowChart.private.prototype.putInRedoStack=function(){if(this.chart.options.useSession){var t=`${this.uid}_redo_`+this.redoStepsCount(),e=sessionStorage.getItem(`${this.uid}_state`);try{sessionStorage.setItem(t,e)}catch(t){t.code==t.QUOTA_EXCEEDED_ERR&&sessionStorage.clear(),console.error(t)}}},FlowChart.private.prototype.putInUndoStack=function(){if(this.chart.options.useSession){var t=`${this.uid}_undo_`+this.undoStepsCount(),e=sessionStorage.getItem(`${this.uid}_state`);try{sessionStorage.setItem(t,e)}catch(t){t.code==t.QUOTA_EXCEEDED_ERR&&sessionStorage.clear(),console.error(t)}}},FlowChart.private.prototype.clearRedo=function(){if(this.chart.options.useSession){for(var t=`${this.uid}_redo_`,e=Object.keys(sessionStorage),r=0;-1!=e.indexOf(t+r);)sessionStorage.removeItem(t+r),r++;FlowChart.events.publish("undo-redo-changed",[this.chart])}},FlowChart.private.prototype.clearUndo=function(){if(this.chart.options.useSession){for(var t=`${this.uid}_undo_`,e=Object.keys(sessionStorage),r=0;-1!=e.indexOf(t+r);)sessionStorage.removeItem(t+r),r++;FlowChart.events.publish("undo-redo-changed",[this.chart])}},FlowChart.private.isObject=function(t){return t&&"object"==typeof t&&!Array.isArray(t)&&null!==t},FlowChart.private.shadeColor=function(t,e){var r=parseInt(t.substring(1,3),16),o=parseInt(t.substring(3,5),16),a=parseInt(t.substring(5,7),16);return r=(r=parseInt(r*(100+e)/100))<255?r:255,o=(o=parseInt(o*(100+e)/100))<255?o:255,a=(a=parseInt(a*(100+e)/100))<255?a:255,r=Math.round(r),o=Math.round(o),a=Math.round(a),"#"+(1==r.toString(16).length?"0"+r.toString(16):r.toString(16))+(1==o.toString(16).length?"0"+o.toString(16):o.toString(16))+(1==a.toString(16).length?"0"+a.toString(16):a.toString(16))},FlowChart.private.mergeDeep=function(t,e){if(FlowChart.private.isObject(t)&&FlowChart.private.isObject(e))for(var r in e)FlowChart.private.isObject(e[r])?(t[r]||Object.assign(t,{[r]:{}}),FlowChart.private.mergeDeep(t[r],e[r])):Object.assign(t,{[r]:e[r]});return t},FlowChart.private.guid=function(){function t(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()},FlowChart.private.rotate=function(t,e,r){var o=Math.PI/180*r,a=Math.cos(o),i=Math.sin(o);return{x:a*(e.x-t.x)+i*(e.y-t.y)+t.x,y:a*(e.y-t.y)-i*(e.x-t.x)+t.y}},FlowChart.private.getScale=function(t,e,r){var o=e/t[2],a=r/t[3];return o>a?a:o},FlowChart.private.pinchMiddlePointInPercent=function(t,e,r,o){var a=function(t,e){t&&(e.x+=t.offsetLeft,e.y+=t.offsetTop,a(t.offsetParent,e))},i=function(t){var e={x:0,y:0};return a(t,e),e}(t),s=o.touches[0].pageX-i.x,h=o.touches[0].pageY-i.y,l=o.touches[1].pageX-i.x,n=o.touches[1].pageY-i.y;return[((s-l)/2+l)/(e/100),((h-n)/2+n)/(r/100)]},FlowChart.private.trim=function(t){return t.replace(/^\s+|\s+$/g,"")},FlowChart.private.getClientTouchesXY=function(t,e){return-1!=t.type.indexOf("touch")?t.touches.length<e+1?{x:null,y:null}:{x:t.touches[e].clientX,y:t.touches[e].clientY}:{x:t.clientX,y:t.clientY}},FlowChart.private.roundPathCorners=function(t,e,r){if(0==e){for(var o="",a=0;a<t.length;a++){var i=t[a];o+=0==a?`M ${i.x} ${i.y} `:`L ${i.x} ${i.y} `}return o}function s(t,e,r){var o=e.x-t.x,a=e.y-t.y,i=Math.sqrt(o*o+a*a);return h(t,e,Math.min(1,r/i))}function h(t,e,r){return{x:t.x+(e.x-t.x)*r,y:t.y+(e.y-t.y)*r}}function l(t,e){t.length>2&&(t[t.length-2]=e.x,t[t.length-1]=e.y)}function n(t){return{x:parseFloat(t[t.length-2]),y:parseFloat(t[t.length-1])}}if(Array.isArray(t)&&t.length&&!Array.isArray(t[0])){var c=[];for(a=0;a<t.length;a++){var p=t[a];0==a?c.push(["M",p.x,p.y]):c.push(["L",p.x,p.y])}t=c}if(Array.isArray(t)){if(Array.isArray(t)){var d=[];for(a=0;a<t.length;a++)d[a]=t[a].slice(0);t=d}}else t=(t=t.split(/[,\s]/).reduce(function(t,e){var r=e.match("([a-zA-Z])(.+)");return r?(t.push(r[1]),t.push(r[2])):t.push(e),t},[])).reduce(function(t,e){return parseFloat(e)==e&&t.length?t[t.length-1].push(e):t.push([e]),t},[]);var f=[];if(t.length>1){var u=n(t[0]),w=null;"Z"==t[t.length-1][0]&&t[0].length>2&&(w=["L",u.x,u.y],t[t.length-1]=w),f.push(t[0]);for(var m=1;m<t.length;m++){var C=f[f.length-1],g=t[m],v=g==w?t[1]:t[m+1];if(v&&C&&C.length>2&&"L"==g[0]&&v.length>2&&"L"==v[0]){var y,N,x=n(C),b=n(g),F=n(v);r?(y=h(b,C.origPoint||x,e),N=h(b,v.origPoint||F,e)):(y=s(b,x,e),N=s(b,F,e)),l(g,y),g.origPoint=b,f.push(g);var S=h(y,b,.5),I=h(b,N,.5),_=["C",S.x,S.y,I.x,I.y,N.x,N.y];_.origPoint=b,f.push(_)}else f.push(g)}if(w){var A=n(f[f.length-1]);f.push(["Z"]),l(f[0],A)}}else f=t;return f.reduce(function(t,e){return t+e.join(" ")+" "},"")},FlowChart.private.centerPointInPercent=function(t,e,r){var o=t.getBoundingClientRect(),a=e-o.left,i=r-o.top;return[a/(o.width/100),i/(o.height/100)]},FlowChart.private.getPortPosition=function(t,e){return t.x==e.width&&0==t.y?FlowChart.position.topRight:t.x==e.width&&t.y==e.height?FlowChart.position.bottomRight:0==t.x&&t.y==e.height?FlowChart.position.bottomLeft:0==t.x&&0==t.y?FlowChart.position.topLeft:t.x>0&&t.x<e.width&&t.y<e.height/2?FlowChart.position.top:t.x>e.width/2&&t.y>0&&t.y<e.height?FlowChart.position.right:t.x>0&&t.x<e.width&&t.y>e.height/2?FlowChart.position.bottom:t.x<e.width/2&&t.y>0&&t.y<e.height?FlowChart.position.left:null},FlowChart.private.replaceRightLeftKeyCodes=function(t){return t.replace("AltLeft","alt").replace("AltRight","alt").replace("ControlLeft","control").replace("ControlRight","control").replace("ShiftLeft","shift").replace("ShiftRight","shift").toLowerCase()},FlowChart.private.stickPosition=function(t,e,r){var o=t.getBoundingClientRect(),a=r.getBoundingClientRect(),i=e.getBoundingClientRect(),s=o.left-a.left,h=o.top-a.top;return o.top+i.height>a.top+a.height&&(h-=i.height),o.left-i.width<a.left&&(s+=i.width),{x:s,y:h}},FlowChart.private.printableKeyCode=function(t){return t>47&&t<58||32==t||13==t||t>64&&t<91||t>95&&t<112||t>185&&t<193||t>218&&t<223},FlowChart.private.getFirstPointIndexByMousePosition=function(t,e,r){var o=e.createSVGPoint();o.x=t.clientX,o.y=t.clientY,o=o.matrixTransform(e.getScreenCTM().inverse());for(var a=Number.MAX_VALUE,i=0,s=0;s<r.points.length-1;s++){var h=r.points[s],l=r.points[s+1],n=Math.hypot(h.x-l.x,h.y-l.y),c=Math.hypot(o.x-h.x,o.y-h.y),p=Math.hypot(o.x-l.x,o.y-l.y);c+p-n<a&&(a=c+p-n,i=s)}return i},FlowChart.private.safeIndexOf=function(t,e){if(!Array.isArray(t))return-1;for(var r=0;r<t.length;r++)if(t[r]==e)return r;return-1},FlowChart.private.getLabelXY=function(t,e){var r=e.length/100*t.position,o=0,a=0,i=null==t.movex?0:t.movex,s=null==t.movey?0:t.movey;!e||!e.points||e.points.length;for(var h=0;h<e.points.length-1;h++){var l=e.points[h],n=e.points[h+1],c=Math.hypot(n.x-l.x,n.y-l.y);if(o+c>=r){a=h;break}o+=c}l=e.points[a],n=e.points[a+1];var p,d,f=FlowChart.direction.horizontal;return e.points[a].x==e.points[a+1].x&&(f=FlowChart.direction.vertical),f==FlowChart.direction.horizontal?(p=l.x<n.x?l.x+(r-o)+i:l.x-(r-o)+i,d=l.y+s):(d=l.y<n.y?l.y+(r-o)+s:l.y-(r-o)+s,p=l.x+i),{x:p,y:d,direction:f}},FlowChart.private.isLabel=function(t){return!(FlowChart.isNEU(t.from)||FlowChart.isNEU(t.to)||FlowChart.isNEU(t.position))},FlowChart.private.getFitScale=function(t,e,r,o,a,i,s){var h=1;if(r==FlowChart.startPosition.fit||r==FlowChart.startPosition.fit1||r==FlowChart.startPosition.centerShapes){var l=t/i,n=e/s;h=l>n?n:l,r==FlowChart.startPosition.fit1&&h>1?h=1:r==FlowChart.startPosition.centerShapes&&h>1.5&&(h=1.5)}else r==FlowChart.startPosition.fitWidth?h=t/i:r==FlowChart.startPosition.fitHeight&&(h=e/s);return h&&h>o&&(h=o),h&&h<a&&(h=a),h},FlowChart.private.downloadFile=function(t,e,r,o){if(1==r){var a=URL.createObjectURL(t);window.open(a,"_blank").focus()}else if(navigator.msSaveBlob)navigator.msSaveBlob(t,e);else{var i=document.createElement("a");if(void 0!==i.download){a=URL.createObjectURL(t);i.setAttribute("href",a);var s=e;s.toLowerCase().endsWith(o.toLowerCase())||(s=s+"."+o),i.setAttribute("download",s),i.style.visibility="hidden",document.body.appendChild(i),i.click(),document.body.removeChild(i)}}},FlowChart.private.findClosestPorts=function(t,e){var r=Number.MAX_SAFE_INTEGER,o=null,a=FlowChart.shapeTemplates[t.templateId].ports(t),i=FlowChart.shapeTemplates[e.templateId].ports(e);for(var s in a){var h=a[s];for(var l in i){var n=i[l],c=Math.hypot(t.x+h.x-(e.x+n.x),t.y+h.y-(e.y+n.y));c<r&&(r=c,o={fromPortName:s,toPortName:l})}}return o},FlowChart.private.rippleShape=function(t,e,r){var o=t.height>t.width?t.height:t.width;o/=2;var a=document.createElementNS("http://www.w3.org/2000/svg","g"),i=document.createElementNS("http://www.w3.org/2000/svg","clipPath"),s=document.createElementNS("http://www.w3.org/2000/svg","circle"),h=t.id+"_ripple";i.setAttribute("id",h);var l=FlowChart.shapeTemplates[t.templateId].svg(t);i.innerHTML=l,s.setAttribute("clip-path","url(#"+h+")"),s.setAttribute("cx",t.width/2),s.setAttribute("cy",t.height/2),s.setAttribute("r",0),s.setAttribute("fill",e),s.setAttribute("class","bfc-ripple"),a.appendChild(i),a.appendChild(s),t.element.appendChild(a);var n={r:o,opacity:0};FlowChart.private.animate(s,{r:0,opacity:1},n,500,FlowChart.anim.outPow,function(){t.element.removeChild(a),r&&r()})},FlowChart.private.getLayer=function(t,e){if(!(r=t.querySelector(`[data-layer="${e}"]`))){var r;(r=document.createElementNS("http://www.w3.org/2000/svg","g")).setAttribute("data-layer",e);for(var o=t.querySelectorAll("[data-layer]"),a=[],i=0;i<o.length;i++)a.push(parseFloat(o[i].getAttribute("data-layer")));a.push(e),a.sort(function(t,e){return t-e});var s=a.indexOf(e),h=t.querySelector(`[data-layer="${a[s+1]}"]`);null==h?t.appendChild(r):h.parentNode.insertBefore(r,h)}return t.querySelector(`[data-layer="${e}"]`)},FlowChart.private.getParentElementWithAttribute=function(t,e){for(;t&&t.hasAttribute&&!t.hasAttribute(e);)t=t.parentNode;return t&&t.hasAttribute&&t.hasAttribute(e)?t:null},FlowChart.private.createImageElementForUpload=function(t,e){var r=document.createElement("canvas");document.body.appendChild(r);var o=document.createElement("img");document.body.appendChild(o),o.addEventListener("load",function(t){var a=o.offsetWidth,i=o.offsetHeight,s=200,h=200;a<i?h*=i/a:a>i&&(s*=a/i);var l=(h-200)/2,n=(s-200)/2;r.setAttribute("width","200px"),r.setAttribute("height","200px"),r.getContext("2d").drawImage(o,n,l,a,a,0,0,200,200);var c=r.toDataURL("image/jpeg",.7);e(c)}),o.src=t},FlowChart.private.safeStringify=function(t,e){null==e&&(e=2);let r=[];const o=JSON.stringify(t,(t,e)=>"object"==typeof e&&null!==e?r.includes(e)?void 0:r.push(e)&&e:e,e);return r=null,o},FlowChart.private.getViewBoxByScale=function(t,e,r,o){t>e.scaleMax&&(t=e.scaleMax),t<e.scaleMin&&(t=e.scaleMin);var a=[50,50],i=o.width,s=o.height,h=i/r[2],l=s/r[3],n=h>l?l:h,c=r,p=r[2],d=r[3];return r[2]=r[2]/(t/n),r[3]=r[3]/(t/n),r[0]=c[0]-(r[2]-p)/(100/a[0]),r[1]=c[1]-(r[3]-d)/(100/a[1]),r},FlowChart.private.gradientCircleForDefs=function(t,e,r,o){function a(t,e,r,o){var a=(o-90)*Math.PI/180;return{x:t+r*Math.cos(a),y:e+r*Math.sin(a)}}function i(t,e,r,o,i){var s=a(t,e,r,i),h=a(t,e,r,o),l=i-o<=180?"0":"1";return["M",s.x,s.y,"A",r,r,0,l,0,h.x,h.y].join(" ")}return Array.isArray(e)||(e=[e,e,e,e,e,e]),`<linearGradient id="${t}_linearColors1" x1="0" y1="0" x2="1" y2="1">\n <stop offset="0%" stop-color="${e[0]}"></stop>\n <stop offset="100%" stop-color="${e[1]}"></stop>\n </linearGradient>\n <linearGradient id="${t}_linearColors2" x1="0.5" y1="0" x2="0.5" y2="1">\n <stop offset="0%" stop-color="${e[1]}"></stop>\n <stop offset="100%" stop-color="${e[2]}"></stop>\n </linearGradient>\n <linearGradient id="${t}_linearColors3" x1="1" y1="0" x2="0" y2="1">\n <stop offset="0%" stop-color="${e[2]}"></stop>\n <stop offset="100%" stop-color="${e[3]}"></stop>\n </linearGradient>\n <linearGradient id="${t}_linearColors4" x1="1" y1="1" x2="0" y2="0">\n <stop offset="0%" stop-color="${e[3]}"></stop>\n <stop offset="100%" stop-color="${e[4]}"></stop>\n </linearGradient>\n <linearGradient id="${t}_linearColors5" x1="0.5" y1="1" x2="0.5" y2="0">\n <stop offset="0%" stop-color="${e[4]}"></stop>\n <stop offset="100%" stop-color="${e[5]}"></stop>\n </linearGradient>\n <linearGradient id="${t}_linearColors6" x1="0" y1="1" x2="1" y2="0">\n <stop offset="0%" stop-color="${e[5]}"></stop>\n <stop offset="100%" stop-color="${e[0]}"></stop>\n </linearGradient> \n <g id="${t}">\n <path stroke-width="${o}" fill="none" stroke="url(#${t}_linearColors1)" d="${i(r,r,r,1,60)}" />\n <path stroke-width="${o}" fill="none" stroke="url(#${t}_linearColors2)" d="${i(r,r,r,60,120)}"/>\n <path stroke-width="${o}" fill="none" stroke="url(#${t}_linearColors3)" d="${i(r,r,r,120,180)}" />\n <path stroke-width="${o}" fill="none" stroke="url(#${t}_linearColors4)" d="${i(r,r,r,180,240)}" />\n <path stroke-width="${o}" fill="none" stroke="url(#${t}_linearColors5)" d="${i(r,r,r,240,300)}" />\n <path stroke-width="${o}" fill="none" stroke="url(#${t}_linearColors6)" d="${i(r,r,r,300,1)}"/>\n </g>`},FlowChart.remote={},FlowChart.private.devin=function(t,e){t.v="1.00.71",FlowChart.remote.findRegion(function(r){fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:FlowChart.private.safeStringify(t)}).then(t=>t.json()).then(function(t){e(t)}).catch(function(t){console.error(t)})})},FlowChart.remote.findRegion=function(t){var e=localStorage.getItem("func-url-flowchartjs");if(e)t(e);else{var r=[];for(var o of["defunc2","cusfunc2","bsfunc2","acfunc2","kcfunc2","safunc2","wifunc2"]){var a=new AbortController;fetch(`https://${o}.azurewebsites.net/api/FlowChartJS`,{method:"GET",signal:a.signal}).then(function(e){for(var o of r)o.abort("cancel_request");localStorage.setItem("func-url-flowchartjs",e.url),t(e.url)}).catch(function(t){"cancel_request"!=t&&console.error(t)}),r.push(a)}}},FlowChart.private.logo=function(t){return t||'<svg style="position: absolute; bottom: 8px; right: 7px; font-family: Verdana;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="160" height="27"> \n <text fill="#039be5" style="font-size: 14px;font-weight:bold;" x="0" y="24">BALKAN</text>\n <text fill="#f57c00" style="font-size: 14px;" x="70" y="24">FlowChart JS</text>\n </svg>'};