automatica-draw2d
Version:
JS drag&drop lib
2 lines • 1.28 MB
JavaScript
/*! For license information please see automatica-draw2d.js.LICENSE.txt */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.draw2d=e():t.draw2d=e()}(self,(()=>(()=>{var t={"./src/lib/Class.exec.js":(t,e,n)=>{"use strict";n("./node_modules/script-loader/addScript.js")(n("./node_modules/raw-loader/index.js!./src/lib/Class.exec.js"))},"./src/lib/pathfinding.exec.js":(t,e,n)=>{"use strict";n("./node_modules/script-loader/addScript.js")(n("./node_modules/raw-loader/index.js!./src/lib/pathfinding.exec.js"))},"./src/lib/raphael.exec.js":(t,e,n)=>{"use strict";n("./node_modules/script-loader/addScript.js")(n("./node_modules/raw-loader/index.js!./src/lib/raphael.exec.js"))},"./src/Canvas.js":(t,e,n)=>{"use strict";var r,i=(r=n("./src/packages.js"))&&r.__esModule?r:{default:r};i.default.Canvas=Class.extend({NAME:"draw2d.Canvas",init:function(t,e,n){let r=this;this.setScrollArea(document.body),this.canvasId=t,this.html=$("#"+t),this.html.css({cursor:"default"}),isNaN(parseFloat(e))||isNaN(parseFloat(n))?(this.initialWidth=this.getWidth(),this.initialHeight=this.getHeight()):(this.initialWidth=parseInt(e),this.initialHeight=parseInt(n),this.html.height(this.initialHeight).width(this.initialWidth)),this.html.css({"-webkit-tap-highlight-color":"rgba(0,0,0,0)"}),$(this.html).droppable({accept:".draw2d_droppable",over:function(t,e){r.onDragEnter(e.draggable)},out:function(t,e){r.onDragLeave(e.draggable)},drop:function(t,e){t=r._getEvent(t);let n=$(e.helper).position(),i=r.fromDocumentToCanvasCoordinate(t.clientX,t.clientY);r.onDrop(e.draggable,i.getX()-(t.clientX-n.left)+5,i.getY()-(t.clientY-n.top)+5,t.shiftKey,t.ctrlKey)}}),$(".draw2d_droppable").draggable({appendTo:"body",stack:"body",zIndex:27e3,helper:"clone",drag:function(t,e){t=r._getEvent(t);let n=r.fromDocumentToCanvasCoordinate(t.clientX,t.clientY);r.onDrag(e.draggable,n.getX(),n.getY(),t.shiftKey,t.ctrlKey)},stop:function(t,e){},start:function(t,e){$(e.helper).addClass("shadow")}}),isNaN(parseFloat(n))?this.paper=Raphael(t,this.getWidth(),this.getHeight()):this.paper=Raphael(t,e,n),this.paper.canvas.style.position="absolute",this.zoomPolicy=null,this.zoomFactor=1,this.selection=new i.default.Selection,this.currentDropTarget=null,this.currentHoverFigure=null,this.regionDragDropConstraint=new i.default.policy.figure.RegionEditPolicy(0,0,this.getWidth(),this.getHeight()),this.eventSubscriptions={},this.editPolicy=new i.default.util.ArrayList,this.figures=new i.default.util.ArrayList,this.lines=new i.default.util.ArrayList,this.commonPorts=new i.default.util.ArrayList,this.resizeHandles=new i.default.util.ArrayList,this.commandStack=new i.default.command.CommandStack,this.linesToRepaintAfterDragDrop=new i.default.util.ArrayList,this.lineIntersections=new i.default.util.ArrayList,this.installEditPolicy(new i.default.policy.canvas.WheelZoomPolicy),this.installEditPolicy(new i.default.policy.canvas.DefaultKeyboardPolicy),this.installEditPolicy(new i.default.policy.canvas.BoundingboxSelectionPolicy),this.installEditPolicy(new i.default.policy.canvas.DropInterceptorPolicy),this.installEditPolicy(new i.default.policy.connection.ComposedConnectionCreatePolicy([new i.default.policy.connection.DragConnectionCreatePolicy,new i.default.policy.connection.ClickConnectionCreatePolicy])),this.commandStack.addEventListener((function(t){!0===t.isPostChangeEvent()&&(r.calculateConnectionIntersection(),r.linesToRepaintAfterDragDrop.each(((t,e)=>{e.svgPathString=null,e.repaint()})),r.linesToRepaintAfterDragDrop=new i.default.util.ArrayList)})),this.mouseDown=!1,this.mouseDownX=0,this.mouseDownY=0,this.mouseDragDiffX=0,this.mouseDragDiffY=0,this.html.bind("mouseup touchend",(function(t){if(!1===r.mouseDown)return;t=r._getEvent(t),r.calculateConnectionIntersection(),r.mouseDown=!1;let e=r.fromDocumentToCanvasCoordinate(t.clientX,t.clientY);r.editPolicy.each((function(n,i){i.onMouseUp(r,e.x,e.y,t.shiftKey,t.ctrlKey)})),r.mouseDragDiffX=0,r.mouseDragDiffY=0})),this.html.bind("mousemove touchmove",(function(t){t=r._getEvent(t);let e=r.fromDocumentToCanvasCoordinate(t.clientX,t.clientY);if(!1===r.mouseDown){try{let t=r.getBestFigure(e.x,e.y);t!==r.currentHoverFigure&&null!==r.currentHoverFigure&&(r.currentHoverFigure.onMouseLeave(),r.currentHoverFigure.fireEvent("mouseleave"),r.fireEvent("mouseleave",{figure:r.currentHoverFigure})),t!==r.currentHoverFigure&&null!==t&&(t.onMouseEnter(),t.fireEvent("mouseenter"),r.fireEvent("mouseenter",{figure:t})),r.currentHoverFigure=t}catch(t){console.log(t)}r.editPolicy.each((function(n,i){i.onMouseMove(r,e.x,e.y,t.shiftKey,t.ctrlKey)})),r.fireEvent("mousemove",{x:e.x,y:e.y,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,hoverFigure:r.currentHoverFigure})}else{let n=(t.clientX-r.mouseDownX)*r.zoomFactor,i=(t.clientY-r.mouseDownY)*r.zoomFactor;r.editPolicy.each((function(e,s){s.onMouseDrag(r,n,i,n-r.mouseDragDiffX,i-r.mouseDragDiffY,t.shiftKey,t.ctrlKey)})),r.mouseDragDiffX=n,r.mouseDragDiffY=i,r.fireEvent("mousemove",{x:e.x,y:e.y,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,hoverFigure:r.currentHoverFigure})}})),this.html.bind("mousedown",(function(t){try{let e=null;switch(t.which){case 1:case 0:try{t.preventDefault(),t=r._getEvent(t),r.mouseDownX=t.clientX,r.mouseDownY=t.clientY,r.mouseDragDiffX=0,r.mouseDragDiffY=0,e=r.fromDocumentToCanvasCoordinate(t.clientX,t.clientY),r.mouseDown=!0,r.editPolicy.each((function(n,i){i.onMouseDown(r,e.x,e.y,t.shiftKey,t.ctrlKey)}))}catch(t){console.log(t)}break;case 3:return t.preventDefault(),void 0!==t.stopPropagation&&t.stopPropagation(),t=r._getEvent(t),e=r.fromDocumentToCanvasCoordinate(t.clientX,t.clientY),r.onRightMouseDown(e.x,e.y,t.shiftKey,t.ctrlKey),!1}}catch(t){console.log(t)}})),this.html.on("dblclick",(function(t){t=r._getEvent(t),r.mouseDownX=t.clientX,r.mouseDownY=t.clientY;let e=r.fromDocumentToCanvasCoordinate(t.clientX,t.clientY);r.onDoubleClick(e.x,e.y,t.shiftKey,t.ctrlKey)})),this.html.on("click",(function(t){if(t=r._getEvent(t),r.mouseDownX===t.clientX||r.mouseDownY===t.clientY){let e=r.fromDocumentToCanvasCoordinate(t.clientX,t.clientY);r.onClick(e.x,e.y,t.shiftKey,t.ctrlKey)}})),this.html.on("MozMousePixelScroll DOMMouseScroll mousewheel",(function(t){let e=r._getEvent(t),n=r.fromDocumentToCanvasCoordinate(e.originalEvent.clientX,e.originalEvent.clientY),i=0;"mousewheel"===t.type?i=-1*t.originalEvent.wheelDelta:"DOMMouseScroll"===t.type&&(i=40*t.originalEvent.detail),!1===r.onMouseWheel(i,n.x,n.y,e.shiftKey,e.ctrlKey)&&t.preventDefault()})),this.keyupCallback=function(t){let e=$(t.target);e.is("input")||e.is("textarea")||r.editPolicy.each((function(e,n){n instanceof i.default.policy.canvas.KeyboardPolicy&&n.onKeyUp(r,t.keyCode,t.shiftKey,t.ctrlKey)}))},$(document).bind("keyup",this.keyupCallback),this.keydownCallback=function(t){let e=$(t.target);e.is("input")||e.is("textarea")||r.editPolicy.each((function(e,n){n instanceof i.default.policy.canvas.KeyboardPolicy&&n.onKeyDown(r,t.keyCode,t.shiftKey,t.ctrlKey)}))},$(document).bind("keydown",this.keydownCallback)},destroy:function(){this.clear(),$(document).unbind("keydown",this.keydownCallback),$(document).unbind("keyup",this.keyupCallback),this.eventSubscriptions={};try{this.paper.remove()}catch(t){}},clear:function(){this.fireEvent("clear");let t=this;return this.lines.clone().each((function(e,n){t.remove(n)})),this.figures.clone().each((function(e,n){t.remove(n)})),this.zoomFactor=1,this.selection.clear(),this.currentDropTarget=null,this.figures=new i.default.util.ArrayList,this.lines=new i.default.util.ArrayList,this.commonPorts=new i.default.util.ArrayList,this.commandStack.markSaveLocation(),this.linesToRepaintAfterDragDrop=new i.default.util.ArrayList,this.lineIntersections=new i.default.util.ArrayList,this},hideDecoration:function(){},showDecoration:function(){},calculateConnectionIntersection:function(){this.lineIntersections=new i.default.util.ArrayList;let t=this.getLines().clone();for(;t.getSize()>0;){let e=t.removeElementAt(0);t.each(((t,n)=>{let r=e.intersection(n);r.getSize()>0&&(this.lineIntersections.add({line:e,other:n,intersection:r}),this.lineIntersections.add({line:n,other:e,intersection:r}))}))}return this},installEditPolicy:function(t){return t instanceof i.default.policy.canvas.SelectionPolicy?(this.getSelection().getAll().each(((t,e)=>{e.unselect()})),this.editPolicy.grep((t=>{let e=!(t instanceof i.default.policy.canvas.SelectionPolicy);return!1===e&&t.onUninstall(this),e}))):t instanceof i.default.policy.canvas.ZoomPolicy?(this.editPolicy.grep((t=>{let e=!(t instanceof i.default.policy.canvas.ZoomPolicy);return!1===e&&t.onUninstall(this),e})),this.zoomPolicy=t):t instanceof i.default.policy.connection.ConnectionCreatePolicy?this.editPolicy.grep((t=>{let e=!(t instanceof i.default.policy.connection.ConnectionCreatePolicy);return!1===e&&t.onUninstall(this),e})):i.default.policy.canvas.DropInterceptorPolicy,t.NAME&&this.uninstallEditPolicy(t.NAME),t.onInstall(this),this.editPolicy.add(t),this},uninstallEditPolicy:function(t){if(null===t)return;let e=this.editPolicy.remove(t);if(null!==e)e.onUninstall(this),e instanceof i.default.policy.canvas.ZoomPolicy&&(this.zoomPolicy=null);else{let e=this,n="string"==typeof t?t:t.NAME;this.editPolicy.grep((function(t){return t.NAME!==n||(t.onUninstall(e),t instanceof i.default.policy.canvas.ZoomPolicy&&(e.zoomPolicy=null),!1)}))}return this},getDropInterceptorPolicies:function(){return this.editPolicy.clone().grep((function(t){return t instanceof i.default.policy.canvas.DropInterceptorPolicy}))},setZoom:function(t,e){this.zoomPolicy&&this.zoomPolicy.setZoom(t,e)},getZoom:function(){return this.zoomFactor},getDimension:function(){return new i.default.geo.Rectangle(0,0,this.initialWidth,this.initialHeight)},setDimension:function(t,e){if(void 0===t){let t=this.getFigures().clone().map((function(t){return t.getAbsoluteX()+t.getWidth()})),e=this.getFigures().clone().map((function(t){return t.getAbsoluteY()+t.getHeight()}));this.initialHeight=Math.max(...e.asArray()),this.initialWidth=Math.max(...t.asArray())}else t instanceof i.default.geo.Rectangle?(this.initialWidth=t.w,this.initialHeight=t.h):"number"==typeof t.width&&"number"==typeof t.height?(this.initialWidth=t.width,this.initialHeight=t.height):"number"==typeof t&&"number"==typeof e&&(this.initialWidth=t,this.initialHeight=e);return this.html.css({width:this.initialWidth+"px",height:this.initialHeight+"px"}),this.paper.setSize(this.initialWidth,this.initialHeight),this.setZoom(this.zoomFactor,!1),this},fromDocumentToCanvasCoordinate:function(t,e){return new i.default.geo.Point((t-this.getAbsoluteX()+this.getScrollLeft())*this.zoomFactor,(e-this.getAbsoluteY()+this.getScrollTop())*this.zoomFactor)},fromCanvasToDocumentCoordinate:function(t,e){return new i.default.geo.Point(t*(1/this.zoomFactor)+this.getAbsoluteX()-this.getScrollLeft(),e*(1/this.zoomFactor)+this.getAbsoluteY()-this.getScrollTop())},getHtmlContainer:function(){return this.html},_getEvent:function(t){if(void 0!==t.originalEvent){if(t.originalEvent.touches&&t.originalEvent.touches.length)return t.originalEvent.touches[0];if(t.originalEvent.changedTouches&&t.originalEvent.changedTouches.length)return t.originalEvent.changedTouches[0]}return t},setScrollArea:function(t){return this.scrollArea=$(t),this},getScrollArea:function(){return this.scrollArea},getScrollLeft:function(){return this.getScrollArea().scrollLeft()},getScrollTop:function(){return this.getScrollArea().scrollTop()},setScrollLeft:function(t){return this.getScrollArea().scrollLeft(t),this},setScrollTop:function(t){return this.getScrollArea().scrollTop(t),this},scrollTo:function(t,e){return this.getScrollArea().scrollTop(t).scrollLeft(e),this},getAbsoluteX:function(){return this.html.offset().left},getAbsoluteY:function(){return this.html.offset().top},getWidth:function(){return this.html.width()},getHeight:function(){return this.html.height()},add:function(t,e,n){if(t.getCanvas()!==this)return t instanceof i.default.shape.basic.Line?(this.linesToRepaintAfterDragDrop=this.lines,this.lines.add(t)):this.figures.add(t),void 0!==e&&t.setPosition(e,n),t.setCanvas(this),t.installEditPolicy(this.regionDragDropConstraint),t.getShapeElement(),t.repaint(),this.fireEvent("figure:add",{figure:t,canvas:this}),t.fireEvent("added",{figure:t,canvas:this}),t.fireEvent("move",{figure:t,x:t.getX(),y:t.getY(),dx:0,dy:0}),t instanceof i.default.shape.basic.PolyLine&&(this.calculateConnectionIntersection(),this.linesToRepaintAfterDragDrop.each(((t,e)=>{e.svgPathString=null,e.repaint()})),this.linesToRepaintAfterDragDrop=new i.default.util.ArrayList),this},remove:function(t){return t.getCanvas()!==this||(this.getSelection().contains(t)&&this.editPolicy.each(((e,n)=>{"function"==typeof n.unselect&&n.unselect(this,t)})),t instanceof i.default.shape.basic.Line?this.lines.remove(t):this.figures.remove(t),t.setCanvas(null),t instanceof i.default.Connection&&t.disconnect(),this.fireEvent("figure:remove",{figure:t}),t.fireEvent("removed",{figure:t,canvas:this})),this},getLines:function(){return this.lines},getFigures:function(){return this.figures},getLine:function(t){let e=this.lines.getSize();for(let n=0;n<e;n++){let e=this.lines.get(n);if(e.getId()===t)return e}return null},getFigure:function(t){let e=null;return this.figures.each(((n,r)=>{if(r.id===t)return e=r,!1})),e},getIntersection:function(t){let e=new i.default.util.ArrayList;return this.lineIntersections.each(((n,r)=>{r.line===t&&r.intersection.each(((t,n)=>{e.add({x:n.x,y:n.y,justTouching:n.justTouching,other:r.other})}))})),e},snapToHelper:function(t,e){if(this.getSelection().getSize()>1)return e;let n=e.clone();return this.editPolicy.each(((r,s)=>{s instanceof i.default.policy.canvas.SnapToEditPolicy&&(e=s.snap(this,t,e,n))})),e},registerPort:function(t){return this.commonPorts.contains(t)||this.commonPorts.add(t),this},unregisterPort:function(t){return this.commonPorts.remove(t),this},getAllPorts:function(){return this.commonPorts},getCommandStack:function(){return this.commandStack},getPrimarySelection:function(){return this.selection.getPrimary()},getSelection:function(){return this.selection},setCurrentSelection:function(t){return this.selection.getAll().each(((t,e)=>{this.editPolicy.each(((t,n)=>{"function"==typeof n.unselect&&n.unselect(this,e)}))})),this.addSelection(t),this},addSelection:function(t){let e=(t,e)=>{this.editPolicy.each(((t,n)=>{"function"==typeof n.select&&n.select(this,e)}))};return t instanceof i.default.util.ArrayList||t instanceof i.default.Selection?t.each(e):e(0,t),this},getBestFigure:function(t,e,n,r){Array.isArray(n)||(n=n?[n]:[]),Array.isArray(r)||(r=r?[r]:[]);let i=null,s=null,a=function(t,e){for(let n=0,r=e.length;n<r;n++){let r=e[n];if("function"==typeof r){if(t instanceof r)return!0}else if(r===t||r.contains(t))return!0}return!1},o=function(t){return a(t,n)},c=0===r.length?function(){return!0}:function(t){return a(t,r)},l=function(n){n.each((function(n,r){let s=r.figure;return l(s.children),null===i&&s.isVisible()&&s.hitTest(t,e)&&!o(s)&&c(s)&&(i=s),null===i}))};for(let n=0,r=this.resizeHandles.getSize();n<r;n++)if(s=this.resizeHandles.get(n),s.isVisible()&&s.hitTest(t,e)&&!o(s)&&c(s))return s;for(let n=0,r=this.commonPorts.getSize();n<r;n++){let r=this.commonPorts.get(n);if(l(r.children),null===i&&r.isVisible()&&r.hitTest(t,e)&&!o(r)&&c(r)&&(i=r),null!==i)return i}for(let n=this.figures.getSize()-1;n>=0;n--){let r=this.figures.get(n);if(l(r.children),null===i&&r.isVisible()&&r.hitTest(t,e)&&!o(r)&&c(r)){i=r;break}}let h=i,u=null,d=this.getBestLine(t,e,n,r);i=null;let p=this.lines.getSize();for(let t=0;t<p;t++){let e=this.lines.get(t);if(l(e.children),null!==i){u=i;break}}let f=[{i:null!==h?$(h.shape.node).index():-1,f:h},{i:null!==u?$(u.shape.node).index():-1,f:u},{i:null!==d?$(d.shape.node).index():-1,f:d}];return f=f.filter((t=>-1!==t.i)),f=f.sort(((t,e)=>e.i-t.i)),f.length>0&&(i=f[0].f),i},getBestLine:function(t,e,n){Array.isArray(n)||(n=n instanceof i.default.Figure?[n]:[]);let r=this.lines.getSize();for(let i=0;i<r;i++){let r=this.lines.get(i);if(!0===r.isVisible()&&!0===r.hitTest(t,e)&&-1===$.inArray(r,n))return r}return null},onDragEnter:function(t){},onDrag:function(t,e,n){},onDragLeave:function(t){},onDrop:function(t,e,n,r,i){},onDoubleClick:function(t,e,n,r){let i=this.getBestFigure(t,e);null===i&&(i=this.getBestLine(t,e)),this.fireEvent("dblclick",{figure:i,x:t,y:e,shiftKey:n,ctrlKey:r}),this.editPolicy.each((function(s,a){a.onDoubleClick(i,t,e,n,r)}))},onClick:function(t,e,n,r){let i=this.getBestFigure(t,e);this.fireEvent("click",{figure:i,x:t,y:e,relX:null!==i?t-i.getAbsoluteX():0,relY:null!==i?e-i.getAbsoluteY():0,shiftKey:n,ctrlKey:r}),this.editPolicy.each((function(s,a){a.onClick(i,t,e,n,r)}))},onRightMouseDown:function(t,e,n,r){let i=this.getBestFigure(t,e);this.fireEvent("contextmenu",{figure:i,x:t,y:e,shiftKey:n,ctrlKey:r}),null!==i&&(i.fireEvent("contextmenu",{figure:i,x:t,y:e,shiftKey:n,ctrlKey:r}),i.onContextMenu(t,e),i.editPolicy.each((function(s,a){a.onRightMouseDown(i,t,e,n,r)}))),this.editPolicy.each((function(s,a){a.onRightMouseDown(i,t,e,n,r)}))},onMouseWheel:function(t,e,n,r,i){let s=!0;return this.fireEvent("wheel",{wheelDelta:t,x:e,y:n,shiftKey:r,ctrlKey:i}),this.editPolicy.each((function(a,o){s=o.onMouseWheel(t,e,n,r,i)&&s})),s},fireEvent:function(t,e){if(void 0===this.eventSubscriptions[t])return;let n=this.eventSubscriptions[t];for(let t=0;t<n.length;t++)try{n[t](this,e)}catch(e){console.log(e),console.log(n[t])}},on:function(t,e){let n=t.split(" ");for(let t=0;t<n.length;t++)void 0===this.eventSubscriptions[n[t]]&&(this.eventSubscriptions[n[t]]=[]),this.eventSubscriptions[n[t]].push(e);return this},off:function(t){if(void 0===t)this.eventSubscriptions={};else if("string"==typeof t)this.eventSubscriptions[t]=[];else for(let e in this.eventSubscriptions)this.eventSubscriptions[e]=this.eventSubscriptions[e].filter((function(e){return e!==t}));return this}})},"./src/Configuration.js":(t,e,n)=>{"use strict";var r,i=(r=n("./src/packages.js"))&&r.__esModule?r:{default:r};i.default.Configuration={version:"@VERSION@",i18n:{command:{move:"Move Shape",assignShape:"Add Shapes to Composite",groupShapes:"Group Shapes",ungroupShapes:"Ungroup Shapes",deleteShape:"Delete Shape",moveShape:"Move Shape",moveLine:"Move Line",addShape:"Add Shape",moveVertex:"Move Vertex",moveVertices:"Move Vertices",deleteVertex:"Delete Vertex",resizeShape:"Resize Shape",rotateShape:"Rotate Shape",collection:"Execute Commands",addVertex:"Add Vertex",changeAttributes:"Change Attributes",connectPorts:"Connect Ports"},menu:{deleteSegment:"Delete Segment",addSegment:"Add Segment"},dialog:{filenamePrompt:"Enter Filename:"}},factory:{createResizeHandle:function(t,e,n,r){return console.log("deprecated call factory.createResizeHandle"),new i.default.ResizeHandle({owner:t,type:e,width:n,height:r})},createConnection:function(t,e,n,r){return console.log("deprecated call factory.createConnection"),new i.default.Connection},createInputPort:function(t){return new i.default.InputPort},createOutputPort:function(t){return new i.default.OutputPort},createHybridPort:function(t){return new i.default.HybridPort}}}},"./src/Connection.js":(t,e,n)=>{"use strict";var r,i=(r=n("./src/packages.js"))&&r.__esModule?r:{default:r};i.default.Connection=i.default.shape.basic.PolyLine.extend({NAME:"draw2d.Connection",init:function(t,e,n){this.sourcePort=null,this.targetPort=null,this.oldPoint=null,this.sourceDecorator=null,this.targetDecorator=null,this.sourceDecoratorNode=null,this.targetDecoratorNode=null,this.isMoving=!1,this.moveListener=t=>{t===this.sourcePort?this.setStartPoint(this.sourcePort.getAbsoluteX(),this.sourcePort.getAbsoluteY()):this.setEndPoint(this.targetPort.getAbsoluteX(),this.targetPort.getAbsoluteY())},this._super({color:"#129CE4",stroke:2,radius:3,...t},{sourceDecorator:this.setSourceDecorator,targetDecorator:this.setTargetDecorator,source:this.setSource,target:this.setTarget,...e},{sourceDecorator:this.getSourceDecorator,targetDecorator:this.getTargetDecorator,source:this.getSource,target:this.getTarget,...n})},disconnect:function(){null!==this.sourcePort&&(this.sourcePort.off(this.moveListener),this.sourcePort.connections.remove(this),this.sourcePort.fireEvent("disconnect",{port:this.sourcePort,connection:this}),this.canvas?.fireEvent("disconnect",{port:this.sourcePort,connection:this}),this.sourcePort.onDisconnect(this),this.fireSourcePortRouteEvent()),null!==this.targetPort&&(this.targetPort.off(this.moveListener),this.targetPort.connections.remove(this),this.targetPort.fireEvent("disconnect",{port:this.targetPort,connection:this}),this.canvas?.fireEvent("disconnect",{port:this.targetPort,connection:this}),this.targetPort.onDisconnect(this),this.fireTargetPortRouteEvent())},reconnect:function(){null!==this.sourcePort&&(this.sourcePort.on("move",this.moveListener),this.sourcePort.connections.add(this),this.sourcePort.fireEvent("connect",{port:this.sourcePort,connection:this}),this.canvas?.fireEvent("connect",{port:this.sourcePort,connection:this}),this.sourcePort.onConnect(this),this.fireSourcePortRouteEvent()),null!==this.targetPort&&(this.targetPort.on("move",this.moveListener),this.targetPort.connections.add(this),this.targetPort.fireEvent("connect",{port:this.targetPort,connection:this}),this.canvas?.fireEvent("connect",{port:this.targetPort,connection:this}),this.targetPort.onConnect(this),this.fireTargetPortRouteEvent()),this.routingRequired=!0,this.repaint()},isResizeable:function(){return this.isDraggable()},add:function(t,e,n){if(!(e instanceof i.default.layout.locator.ConnectionLocator))throw"Locator must implement the class draw2d.layout.locator.ConnectionLocator";this._super(t,e,n)},setSourceDecorator:function(t){return this.sourceDecorator?.setParent(null),this.sourceDecorator=t,this.routingRequired=!0,this.sourceDecorator.setParent(this),this.sourceDecoratorNode?.remove(),this.sourceDecoratorNode=null,this.repaint(),this},getSourceDecorator:function(){return this.sourceDecorator},setTargetDecorator:function(t){return this.targetDecorator?.setParent(null),this.targetDecorator=t,this.routingRequired=!0,this.targetDecorator.setParent(this),this.targetDecoratorNode?.remove(),this.targetDecoratorNode=null,this.repaint(),this},getTargetDecorator:function(){return this.targetDecorator},calculatePath:function(t){if(null===this.sourcePort||null===this.targetPort)return this;if(this._super(t),null!==this.shape){let t=this.sourcePort.getZOrder(),e=this.targetPort.getZOrder();this.toBack(t<e?this.sourcePort:this.targetPort)}return this},repaint:function(t){if(!0!==this.repaintBlocked&&null!==this.shape&&null!==this.sourcePort&&null!==this.targetPort){if(this._super(t),null!==this.targetDecorator&&null===this.targetDecoratorNode&&(this.targetDecoratorNode=this.targetDecorator.paint(this.getCanvas().paper)),null!==this.sourceDecorator&&null===this.sourceDecoratorNode&&(this.sourceDecoratorNode=this.sourceDecorator.paint(this.getCanvas().paper)),null!==this.sourceDecoratorNode){let t=this.getVertices().first();this.sourceDecoratorNode.transform("r"+this.getStartAngle()+","+t.x+","+t.y+" t"+t.x+","+t.y),this.sourceDecoratorNode.attr({opacity:this.alpha}),null===this.sourceDecorator.getColor()?this.sourceDecoratorNode.attr({stroke:"#"+this.lineColor.hex()}):this.sourceDecoratorNode.attr({stroke:"#"+this.sourceDecorator.getColor().hex()}),this.sourceDecoratorNode.forEach((t=>{t.node.setAttribute("class",null!==this.cssClass?this.cssClass:"")}))}if(null!==this.targetDecoratorNode){let t=this.getVertices().last();this.targetDecoratorNode.transform("r"+this.getEndAngle()+","+t.x+","+t.y+" t"+t.x+","+t.y),this.targetDecoratorNode.attr({opacity:this.alpha}),null===this.targetDecorator.getColor()?this.targetDecoratorNode.attr({stroke:this.lineColor.hash()}):this.targetDecoratorNode.attr({stroke:this.targetDecorator.getColor().hash()}),this.targetDecoratorNode.forEach((t=>{t.node.setAttribute("class",null!==this.cssClass?this.cssClass:"")}))}}},getAbsoluteX:function(){return 0},getAbsoluteY:function(){return 0},postProcess:function(t){this.router.postProcess(this,this.getCanvas(),t)},onDrag:function(t,e,n,r){null!==this.command&&(this.router.onDrag(this,t,e,n,r),this.command.updateVertices(this.getVertices().clone()),this.editPolicy.each(((t,e)=>{e instanceof i.default.policy.figure.DragDropEditPolicy&&e.onDrag(this.canvas,this)})),this.svgPathString=null,this.repaint(),this.editPolicy.each(((t,e)=>{e instanceof i.default.policy.figure.DragDropEditPolicy&&e.moved(this.canvas,this)})),this.fireEvent("move",{figure:this,dx:t,dy:t}))},toFront:function(t){return this._super(t),null!==this.shape&&(this.targetDecoratorNode?.insertAfter(this.shape),this.sourceDecoratorNode?.insertAfter(this.shape)),this},toBack:function(t){return this._super(t),null!==this.shape&&(this.targetDecoratorNode?.insertAfter(this.shape),this.sourceDecoratorNode?.insertAfter(this.shape)),this},getStartPoint:function(t){return this.getStartPosition(t)},getStartPosition:function(t){return!1===this.isMoving?t?this.sourcePort.getConnectionAnchorLocation(t,this):this.sourcePort.getConnectionAnchorLocation(this.targetPort.getConnectionAnchorReferencePoint(this),this):this._super()},getEndPoint:function(t){return this.getEndPosition(t)},getEndPosition:function(t){return!1===this.isMoving?t?this.targetPort.getConnectionAnchorLocation(t,this):this.targetPort.getConnectionAnchorLocation(this.sourcePort.getConnectionAnchorReferencePoint(this),this):this._super()},setSource:function(t){null!==this.sourcePort&&(this.sourcePort.off(this.moveListener),this.sourcePort.connections.remove(this),this.sourcePort.fireEvent("disconnect",{port:this.sourcePort,connection:this}),this.canvas?.fireEvent("disconnect",{port:this.sourcePort,connection:this}),this.sourcePort.onDisconnect(this)),this.sourcePort=t,null!==this.sourcePort&&(this.routingRequired=!0,this.fireSourcePortRouteEvent(),this.sourcePort.connections.add(this),this.sourcePort.on("move",this.moveListener),this.canvas?.fireEvent("connect",{port:this.sourcePort,connection:this}),this.sourcePort.fireEvent("connect",{port:this.sourcePort,connection:this}),this.sourcePort.onConnect(this),this.setStartPoint(t.getAbsoluteX(),t.getAbsoluteY()),this.fireEvent("connect",{port:this.sourcePort,connection:this}))},getSource:function(){return this.sourcePort},setTarget:function(t){null!==this.targetPort&&(this.targetPort.off(this.moveListener),this.targetPort.connections.remove(this),this.targetPort.fireEvent("disconnect",{port:this.targetPort,connection:this}),this.canvas?.fireEvent("disconnect",{port:this.targetPort,connection:this}),this.targetPort.onDisconnect(this)),this.targetPort=t,null!==this.targetPort&&(this.routingRequired=!0,this.fireTargetPortRouteEvent(),this.targetPort.connections.add(this),this.targetPort.on("move",this.moveListener),this.canvas?.fireEvent("connect",{port:this.targetPort,connection:this}),this.targetPort.fireEvent("connect",{port:this.targetPort,connection:this}),this.targetPort.onConnect(this),this.setEndPoint(t.getAbsoluteX(),t.getAbsoluteY()),this.fireEvent("connect",{port:this.targetPort,connection:this}))},getTarget:function(){return this.targetPort},getPeerPort:function(t){return t===this.sourcePort?this.targetPort:t===this.targetPort?this.sourcePort:null},sharingPorts:function(t){return this.sourcePort==t.sourcePort||this.sourcePort==t.targetPort||this.targetPort==t.sourcePort||this.targetPort==t.targetPort},setCanvas:function(t){if(this.canvas===t)return;let e=null===this.canvas?t:this.canvas;this._super(t),this.sourceDecoratorNode?.remove(),this.sourceDecoratorNode=null,this.targetDecoratorNode?.remove(),this.targetDecoratorNode=null,null===this.canvas?(null!==this.sourcePort&&(this.sourcePort.off(this.moveListener),e.fireEvent("disconnect",{port:this.sourcePort,connection:this}),this.sourcePort.onDisconnect(this)),null!==this.targetPort&&(this.targetPort.off(this.moveListener),e.fireEvent("disconnect",{port:this.targetPort,connection:this}),this.targetPort.onDisconnect(this))):(null!==this.sourcePort&&(this.sourcePort.on("move",this.moveListener),this.canvas.fireEvent("connect",{port:this.sourcePort,connection:this}),this.sourcePort.onConnect(this)),null!==this.targetPort&&(this.targetPort.on("move",this.moveListener),this.canvas.fireEvent("connect",{port:this.targetPort,connection:this}),this.targetPort.onConnect(this)))},getStartAngle:function(){if(0===this.lineSegments.getSize())return 0;let t=this.lineSegments.get(0).start,e=this.lineSegments.get(0).end;this.router instanceof i.default.layout.connection.SplineConnectionRouter&&(e=this.lineSegments.get(5)?.end??e);let n=Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y)),r=-180/Math.PI*Math.asin((t.y-e.y)/n);return r<0?r=e.x<t.x?Math.abs(r)+180:360-Math.abs(r):e.x<t.x&&(r=180-r),r},getEndAngle:function(){if(0===this.lineSegments.getSize())return 90;let t=this.lineSegments.get(this.lineSegments.getSize()-1).end,e=this.lineSegments.get(this.lineSegments.getSize()-1).start;this.router instanceof i.default.layout.connection.SplineConnectionRouter&&(e=this.lineSegments.get(this.lineSegments.getSize()-5)?.end??e);let n=Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y)),r=-180/Math.PI*Math.asin((t.y-e.y)/n);return r<0?r=e.x<t.x?Math.abs(r)+180:360-Math.abs(r):e.x<t.x&&(r=180-r),r},fireSourcePortRouteEvent:function(){this.sourcePort.getConnections().each(((t,e)=>{e.routingRequired=!0,e.repaint()}))},fireTargetPortRouteEvent:function(){this.targetPort.getConnections().each(((t,e)=>{e.routingRequired=!0,e.repaint()}))},createCommand:function(t){return t.getPolicy()===i.default.command.CommandType.MOVE&&this.isDraggable()?new i.default.command.CommandMoveVertices(this):t.getPolicy()===i.default.command.CommandType.MOVE_BASEPOINT?new i.default.command.CommandReconnect(this):this._super(t)},getPersistentAttributes:function(){let t=this._super(),e=this.getSource().getParent();for(;null!==e.getParent();)e=e.getParent();for(t.source={node:e.getId(),port:this.getSource().getName()},e=this.getTarget().getParent();null!==e.getParent();)e=e.getParent();return t.target={node:e.getId(),port:this.getTarget().getName()},null!==this.sourceDecorator&&(t.source.decoration=this.sourceDecorator.NAME),null!==this.targetDecorator&&(t.target.decoration=this.targetDecorator.NAME),t},setPersistentAttributes:function(t){return this._super(t),void 0!==t.target.decoration&&null!=t.target.decoration&&this.setTargetDecorator(Function(`return new ${t.target.decoration}()`)()),void 0!==t.source.decoration&&null!=t.source.decoration&&this.setSourceDecorator(Function(`return new ${t.source.decoration}()`)()),this}})},"./src/Figure.js":(t,e,n)=>{"use strict";var r=o(n("./src/packages.js")),i=o(n("./src/util/JSONUtil.js")),s=o(n("./src/util/UUID.js")),a=o(n("./src/util/extend.js"));function o(t){return t&&t.__esModule?t:{default:t}}r.default.Figure=Class.extend({NAME:"draw2d.Figure",MIN_TIMER_INTERVAL:50,init:function(t,e,n){this.setterWhitelist={id:this.setId,x:this.setX,y:this.setY,width:this.setWidth,height:this.setHeight,boundingBox:this.setBoundingBox,minWidth:this.setMinWidth,minHeight:this.setMinHeight,cssClass:this.setCssClass,userData:this.setUserData,draggable:this.setDraggable,resizeable:this.setResizeable,selectable:this.setSelectable,angle:this.setRotationAngle,alpha:this.setAlpha,opacity:this.setAlpha,glow:this.setGlow,visible:this.setVisible,keepAspectRatio:this.setKeepAspectRatio,...e},this.getterWhitelist={id:this.getId,visible:this.isVisible,angle:this.getRotationAngle,x:this.getX,y:this.getY,userData:this.getUserData,width:this.getWidth,height:this.getHeight,draggable:this.isDraggable,resizeable:this.isResizeable,selectable:this.isSelectable,alpha:this.getAlpha,opacity:this.getAlpha,...n},this.id=s.default.create(),this.cachedZOrder=-1,this.isResizeHandle=!1,this.command=null,this.canvas=null,this.shape=null,this.children=new r.default.util.ArrayList,this.selectable=!0,this.deleteable=!0,this.resizeable=!0,this.draggable=!0,this.visible=!0,this.keepAspectRatio=!1,this.canSnapToHelper=!0,this.snapToGridAnchor=new r.default.geo.Point(0,0),this.editPolicy=new r.default.util.ArrayList,this.timerId=-1,this.timerInterval=0,this.parent=null,this.composite=null,this.userData=null,this.x=0,this.y=0,this.minHeight=5,this.minWidth=5,this.rotationAngle=0,this.cssClass=this.NAME.replace(new RegExp("[.]","g"),"_"),this.width=this.getMinWidth(),this.height=this.getMinHeight(),this.alpha=1,this.isInDragDrop=!1,this.ox=0,this.oy=0,this.repaintBlocked=!1,this.lastAppliedAttributes={},this.selectionHandles=new r.default.util.ArrayList,this.panningDelegate=null,this.eventSubscriptions={},this.relocateChildrenEventCallback=()=>{this.children.each(((t,e)=>{e.locator.relocate(t,e.figure)}))},this.defaultSelectionAdapter=this.selectionAdapter=()=>this,this.installEditPolicy(new r.default.policy.figure.RectangleSelectionFeedbackPolicy),this.attr(t)},attr:function(t,e){let n=this.repaintBlocked;try{if($.isPlainObject(t))for(let e in t)if("userData."===e.substring(0,9))this.userData??={},i.default.set({userData:this.userData},e,t[e]),this.fireEvent("change:"+e,{value:t[e]});else{let n=this.setterWhitelist[e],r=t[e];n&&void 0!==r?n.call(this,r):"function"==typeof t[e]&&(this[e]=r.bind(this))}else if("string"==typeof t){if(void 0===e){let e=this.getterWhitelist[t];if("function"==typeof e)return e.call(this);if("userData."===t.substring(0,9)){let e={userData:this.userData};return i.default.get(e,t)}return}if("function"==typeof e&&(e=e()),"userData."===t.substring(0,9))this.userData??={},i.default.set({userData:this.userData},t,e),this.fireEvent("change:"+t,{value:e});else{let n=this.setterWhitelist[t];n?.call(this,e)}}else{if(Array.isArray(t))return Object.assign({},...Object.keys(t).map((t=>({[t]:this.attr(t)}))));if(void 0===t){let t={};for(let e in this.getterWhitelist)t[e]=this.getterWhitelist[e].call(this);return t}}}finally{this.repaintBlocked=n}return this},pick:function(t,e){let n,r="string"!=typeof arguments[1]?arguments[1]:Array.prototype.slice.call(arguments,1),i={};for(n in r)void 0!==t[n]&&(i[n]=t[n]);return i},select:function(t){return void 0===t&&(t=!0),this.editPolicy.each(((e,n)=>{n instanceof r.default.policy.figure.SelectionPolicy&&n.onSelect(this.canvas,this,t)})),this.canvas?.getSelection().add(this),this.fireEvent("select",{figure:this}),this},unselect:function(){return this.editPolicy.each(((t,e)=>{e instanceof r.default.policy.figure.SelectionPolicy&&e.onUnselect(this.canvas,this)})),this.canvas?.getSelection().remove(this),this.fireEvent("unselect",{figure:this}),this},setSelectionAdapter:function(t){return this.selectionAdapter=t??this.defaultSelectionAdapter,this},getSelectionAdapter:function(){return this.selectionAdapter},isSelected:function(){return this.canvas?.getSelection().contains(this)},setUserData:function(t){return this.userData=t,this.fireEvent("change:userData",{value:t}),this},getUserData:function(){return this.userData},getId:function(){return this.id},setId:function(t){return this.id=t,this},getCssClass:function(){return this.cssClass},setCssClass:function(t){return this.cssClass=null===t?null:t.trim(),null===this.shape||(null===this.cssClass?this.shape.node.removeAttribute("class"):this.shape.node.setAttribute("class",this.cssClass),this.fireEvent("change:cssClass",{value:this.cssClass})),this},hasCssClass:function(t){return null!==this.cssClass&&new RegExp(" "+t.trim()+" ").test(" "+this.cssClass+" ")},addCssClass:function(t){return t=t.trim(),this.hasCssClass(t)||(null===this.cssClass?this.setCssClass(t):this.setCssClass(this.cssClass+" "+t),this.fireEvent("change:cssClass",{value:this.cssClass})),this},removeCssClass:function(t){t=t.trim();let e=" "+this.cssClass.replace(/[\t\r\n]/g," ")+" ";if(this.hasCssClass(t)){for(;e.indexOf(" "+t+" ")>=0;)e=e.replace(" "+t+" "," ");this.setCssClass(e.replace(/^\s+|\s+$/g,"")),this.fireEvent("change:cssClass",{value:this.cssClass})}return this},toggleCssClass:function(t){t=t.trim();let e=" "+this.cssClass.replace(/[\t\r\n]/g," ")+" ";if(this.hasCssClass(t)){for(;e.indexOf(" "+t+" ")>=0;)e=e.replace(" "+t+" "," ");this.setCssClass(e.replace(/^\s+|\s+$/g,""))}else this.setCssClass(this.cssClass+" "+t);return this.fireEvent("change:cssClass",{value:this.cssClass}),this},setCanvas:function(t){return null===t&&null!==this.shape&&(this.isSelected()&&this.unselect(),this.shape.remove(),this.shape=null),this.canvas=t,null!==this.canvas&&this.getShapeElement(),this.lastAppliedAttributes={},null===t?this.stopTimer():this.timerInterval>=this.MIN_TIMER_INTERVAL&&this.startTimer(this.timerInterval),this.children.each(((e,n)=>{n.figure.setCanvas(t)})),this},getCanvas:function(){return this.canvas},startTimer:function(t){return this.stopTimer(),this.timerInterval=Math.max(this.MIN_TIMER_INTERVAL,t),null!==this.canvas&&(this.timerId=window.setInterval((()=>{this.onTimer(),this.fireEvent("timer")}),this.timerInterval)),this},stopTimer:function(){return this.timerId>=0&&(window.clearInterval(this.timerId),this.timerId=-1),this},onTimer:function(){},toFront:function(t){if(this.composite instanceof r.default.shape.composite.StrongComposite&&void 0!==t){t.getZOrder()<this.composite.getZOrder()&&(t=this.composite)}if(void 0===t){if(this.getShapeElement().toFront(),null!==this.canvas){let t=this.canvas.getFigures(),e=this.canvas.getLines();null!==t.remove(this)?t.add(this):null!==e.remove(this)&&e.add(this)}}else if(this.getShapeElement().insertAfter(t.getTopLevelShapeElement()),null!==this.canvas){let e=this.canvas.getFigures(),n=this.canvas.getLines();if(null!==e.remove(this)){let n=e.indexOf(t);e.insertElementAt(this,n+1)}else null!==n.remove(this)&&n.add(this)}return this.children.each(((t,e)=>e.figure.toFront(this))),this.selectionHandles.each(((t,e)=>e.toFront())),this.cachedZOrder=-1,this},toBack:function(t){if(!(this.composite instanceof r.default.shape.composite.StrongComposite)){if(null!==this.canvas){let e=this.canvas.getFigures(),n=this.canvas.getLines();null!==e.remove(this)?e.insertElementAt(this,0):null!==n.remove(this)&&n.insertElementAt(this,0),void 0!==t?this.getShapeElement().insertBefore(t.getShapeElement()):this.getShapeElement().toBack()}return this.children.each(((t,e)=>{e.figure.toFront(this)}),!0),this.cachedZOrder=-1,this}this.toFront(this.composite)},installEditPolicy:function(t){return t instanceof r.default.policy.figure.SelectionFeedbackPolicy&&this.editPolicy.grep((t=>{let e=!(t instanceof r.default.policy.figure.SelectionFeedbackPolicy);return e||t.onUninstall(this),e})),this.editPolicy.grep((e=>{let n=e.__proto__!==t.__proto__;return n||e.onUninstall(this),n})),t.onInstall(this),this.editPolicy.add(t),this},uninstallEditPolicy:function(t){let e=this.editPolicy.remove(t);if(null!==e)return void e.onUninstall(this);let n="string"==typeof t?t:t.NAME;this.editPolicy.grep((t=>t.NAME!==n||(t.onUninstall(this),!1)))},add:function(t,e,n){if(null==e)throw"Second parameter 'locator' is required for method 'Figure#add'";return t.setParent(this),e.bind(this,t),t.on("resize",this.relocateChildrenEventCallback),isNaN(parseInt(n))?this.children.add({figure:t,locator:e}):this.children.insertElementAt({figure:t,locator:e},n),null!==this.canvas&&t.setCanvas(this.canvas),this.repaint(),this},remove:function(t){if(null==t)return debug.warn("The parameter child is required for Figure.remove"),null;let e=null;return this.children.grep((function(n){let r=n.figure!==t;return r||(e=n),r})),null!==e?(t.setParent(null),t.setCanvas(null),e.locator.unbind(this,t),t.off(this.relocateChildrenEventCallback),this.repaint(),e):null},getChildren:function(){return this.children.clone().map((t=>t.figure))},resetChildren:function(){return this.children.each(((t,e)=>{e.figure.setCanvas(null)})),this.children=new r.default.util.ArrayList,this.repaint(),this},getShapeElement:function(){return null!==this.shape||(this.shape=this.createShapeElement(),this.isVisible()||this.shape.hide(),null!==this.cssClass&&this.shape.node.setAttribute("class",this.cssClass)),this.shape},getTopLevelShapeElement:function(){return this.getShapeElement()},createShapeElement:function(){throw"Inherited class ["+this.NAME+"] must override the abstract method createShapeElement"},repaint:function(t){return!0===this.repaintBlocked||null===this.shape?this:(t??={},!0!==this.visible?(!0===this.shape.isVisible()&&(isNaN(parseFloat(t.visibleDuration))?this.shape.hide():$(this.shape.node).fadeOut(t.visibleDuration,(()=>this.shape.hide()))),this):(!1===this.shape.isVisible()&&(isNaN(parseFloat(t.visibleDuration))?this.shape.show():$(this.shape.node).fadeIn(t.visibleDuration,(()=>this.shape.show()))),t.opacity=this.alpha,t=i.default.flatDiff(t,this.lastAppliedAttributes),Object.getOwnPropertyNames(t).length>0&&this.shape.attr(t),this.lastAppliedAttributes=t,this.applyTransformation(),("x"in t||"width"in t||"cx"in t||"path"in t)&&this.children.each(((t,e)=>{e.locator.relocate(t,e.figure)})),this))},applyTransformation:function(){return this},setGlow:function(t){return this},getHandleBBox:function(){return null},onDragStart:function(t,e,n,i){this.isInDragDrop=!1;let s=this.getHandleBBox();if(null!==s&&!1===s.translate(this.getAbsolutePosition().scale(-1)).hitTest(t,e))return this.panningDelegate=this.getBestChild(this.getX()+t,this.getY()+e),null!==this.panningDelegate&&this.panningDelegate.onDragStart(t-this.panningDelegate.x,e-this.panningDelegate.y,n,i),!1;if(this.command=this.createCommand(new r.default.command.CommandType(r.default.command.CommandType.MOVE)),null!==this.command){this.ox=this.getX(),this.oy=this.getY(),this.isInDragDrop=!0;let s=this,a=!0;return this.editPolicy.each((function(o,c){c instanceof r.default.policy.figure.DragDropEditPolicy&&(a=a&&c.onDragStart(s.canvas,s,t,e,n,i))})),a&&this.fireEvent("dragstart",{x:t,y:e,shiftKey:n,ctrlKey:i}),a}return!1},onDrag:function(t,e,n,i,s,a){this.editPolicy.each(((n,i)=>{if(i instanceof r.default.policy.figure.DragDropEditPolicy){let n=i.adjustPosition(this,this.ox+t,this.oy+e);n&&(t=n.x-this.ox,e=n.y-this.oy)}}));let o=new r.default.geo.Point(this.ox+t,this.oy+e);this.getCanSnapToHelper()&&(o=this.getCanvas().snapToHelper(this,o)),this.setPosition(o),this.editPolicy.each(((t,e)=>{e instanceof r.default.policy.figure.DragDropEditPolicy&&e.onDrag(this.canvas,this)})),this.fireEvent("drag",{dx:t,dy:e,dx2:n,dy2:i,shiftKey:s,ctrlKey:a})},onPanning:function(t,e,n,r,i,s){},onPanningEnd:function(){},onDragEnd:function(t,e,n,i){null!==this.command&&(this.command.setPosition(this.x,this.y),this.canvas.getCommandStack().execute(this.command),this.command=null),this.isInDragDrop=!1,this.panningDelegate=null,this.editPolicy.each(((s,a)=>{a instanceof r.default.policy.figure.DragDropEditPolicy&&a.onDragEnd(this.canvas,this,t,e,n,i)})),this.fireEvent("move",{x:this.getX(),y:this.getY(),dx:0,dy:0}),this.fireEvent("change:x",{x:this.getX(),dx:0}),this.fireEvent("change:y",{y:this.getY(),dy:0}),this.fireEvent("dragend",{x:t,y:e,shiftKey:n,ctrlKey:i})},delegateTarget:function(t){let e=t;return this.getCanvas().getDropInterceptorPolicies().each(((n,r)=>{if(e=r.delegateTarget(t,this),null!==e)return!1})),e},onDragEnter:function(t){},onDragLeave:function(t){},onDrop:function(t,e,n,r,i){},onCatch:function(t,e,n,r,i){},onMouseEnter:function(){},onMouseLeave:function(){},onDoubleClick:function(){},onClick:function(){},onContextMenu:function(t,e){},setAlpha:function(t){if((t=Math.min(1,Math.max(0,parseFloat(t))))!==this.alpha)return this.alpha=t,this.repaint(),this.fireEvent("change:opacity",{value:this.alpha}),this},getAlpha:function(){return this.alpha},setRotationAngle:function(t){return this.rotationAngle=t,this.editPolicy.each(((t,e)=>{e instanceof r.default.policy.figure.DragDropEditPolicy&&e.moved(this.canvas,this)})),this.fireEvent("change:angle",{value:this.rotationAngle}),this.repaint(),this},getRotationAngle:function(){return this.rotationAngle},setVisible:function(t,e){if((t=!!t)!==this.visible)return this.visible=t,this.repaint({visibleDuration:e}),this.fireEvent(this.visible?"show":"hide"),this.fireEvent("change:visibility",{value:this.visible}),this},isVisible:function(){return this.visible&&null!==this.shape},setKeepAspectRatio:function(t){return this.keepAspectRatio=t,this},getKeepAspectRatio:function(){return this.keepAspectRatio},getZOrder:function(){let t=this.shape?.node;return!t||this.cachedZOrder>=0||(this.cachedZOrder=Array.from(t.parentNode.children).indexOf(t)),this.cachedZOrder},setCanSnapToHelper:function(t){return this.canSnapToHelper=!!t,this},getCanSnapToHelper:function(){return this.canSnapToHelper},getSnapToGridAnchor:function(){return this.snapToGridAnchor},setSnapToGridAnchor:function(t){return this.snapToGridAnchor=t,this},setWidth:function(t){return this.setDimension(parseFloat(t),this.getHeight()),this.fireEvent("change:width",{value:this.width}),this},getWidth:function(){return this.width},setHeight:function(t){return this.setDimension(this.getWidth(),parseFloat(t)),this.fireEvent("change:height",{value:this.height}),this},getHeight:function(){return this.height},getMinWidth:function(){return this.minWidth},setMinWidth:function(t){return this.minWidth=parseFloat(t),this.fireEvent("change:minWidth",{value:this.minWidth}),this.setWidth(this.getWidth()),this},getMinHeight:function(){return this.minHeight},setMinHeight:function(t){return this.minHeight=parseFloat(t),this.fireEvent("change:minHeight",{value:this.minHeight}),this.setHeight(this.getHeight()),this},setX:function(t){return this.setPosition(parseFloat(t),this.y),this},getX:function(){return this.x},setY:function(t){return this.setPosition(this.x,parseFloat(t)),this},getY:function(){return this.y},getAbsoluteX:function(){return this.parent?this.getX()+this.parent.getAbsoluteX():this.getX()},getAbsoluteY:function(){return this.parent?this.getY()+this.parent.getAbsoluteY():this.getY()},getAbsolutePosition:function(){return new r.default.geo.Point(this.getAbsoluteX(),this.getAbsoluteY())},getAbsoluteBounds:function(){return new r.default.geo.Rectangle(this.getAbsoluteX(),this.getAbsoluteY(),this.getWidth(),this.getHeight())},setPosition:function(t,e){let n=this.x,i=this.y;t instanceof r.default.geo.Point?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e),this.editPolicy.each(((t,e)=>{if(e instanceof r.default.policy.figure.DragDropEditPolicy){let t=e.adjustPosition(this,this.x,this.y);this.x=t.x,this.y=t.y}})),this.repaint(),this.editPolicy.each(((t,e)=>{e instanceof r.default.policy.figure.DragDropEditPolicy&&e.moved(this.canvas,this)}));let s={x:this.x,y:this.y,dx:this.x-n,dy:this.y-i};return this.fireEvent("move",s),this.fireEvent("change:x",s),this.fireEvent("change:y",s),this},getPosition:function(){return new r.default.geo.Point(this.getX(),this.getY())},translate:function(t,e){return this.setPosition(this.getX()+t,this.getY()+e),this},setDimension:function(t,e){let n={width:this.width,height:this.height};return t=Math.max(this.getMinWidth(),t),e=Math.max(this.getMinHeight(),e),this.width===t&&this.height===e?(this.editPolicy.each(((t,e)=>{e instanceof r.default.policy.figure.DragDropEditPolicy&&e.moved(this.canvas,this)})),this):(this.editPolicy.each(((n,i)=>{if(i instanceof r.default.policy.figure.DragDropEditPolicy){let n=i.adjustDimension(this,t,e);t=n.w,e=n.h}})),!0===this.keepAspectRatio?t>=this.getMinWidth()&&(e=this.getHeight()*(t/this.getWidth()))>=this.getMinHeight()&&(this.width=t,this.height=e):(this.width=Math.max(this.getMinWidth(),t),this.height=Math.max(this.getMinHeight(),e)),this.repaint(),this.fireEvent("resize"),this.fireEvent("change:dimension",{height:this.height,width:this.width,old:n}),this.editPolicy.each(((t,e)=>{e instanceof r.default.policy.figure.DragDropEditPolicy&&e.moved(this.canvas,this)})),this)},setBoundingBox:function(t){t=new r.default.geo.Rectangle(t);let e=this.repaintBlocked;return this.repaintBlocked=!0,this.setPosition(t.x,t.y),this.repaintBlocked=e,this.setDimension(t.w,t.h),this},getBoundingBox:function(){return new r.default.geo.Rectangle(this.getAbsoluteX(),this.getAbsoluteY(),this.getWidth(),this.getHeight())},getOuterBoundingBox:function(){let t=new r.default.geo.Rectangle(this.getAbsoluteX(),this.getAbsoluteY(),this.getWidth(),this.getHeight());return this.getChildren().each(((e,n)=>{let r=n.getOuterBoundingBox();t.merge(r)})),t},hitTest:function(t,e,n){return"number"==typeof n?this.getBoundingBox().scale(n,n).hitTest(t,e):this.getBoundingBox().hitTest(t,e)},setDraggable:function(t){return this.draggable=!!t,this},isDraggable:function(){return null!==this.composite?this.composite.isMemberDraggable(this,this.draggable):this.draggable},isResizeable:function(){return this.resizeable},setResizeable:function(t){return this.resizeable=!!t,this.fireEvent("change:resizeable",{value:this.resizeable}),this},isSelectable:function(){return null!==this.composite?this.composite.isMemberSelectable(this,this.selectable):this.selectable},setSelectable:function(t){return this.selectable=!!t,this.fireEvent("change:selectable",{value:this.selectable}),this},isStrechable:function(){return!this.getKeepAspectRatio()},isDeleteable:function(){return this.deleteable},setDeleteable:function(t){return this.deleteable=!!t,this.fireEvent("change:deleteable",{value:this.deleteable}),this},setParent:function(t){return this.parent=t,null!==t?this.setSelectionAdapter(t.getSelectionAdapter()):this.setSelectionAdapter(null),this},getParent:function(){return this.parent},contains:function(t){if(t.getParent()===this)return!0;for(let e=0,n=this.children.getSize();e<n;e++){if(this.children.get(e).figure.contains(t))return!0}return!1},getRoot:function(){let t=this.parent;for(;null!==t&&null!==t.parent;)t=t.parent;return t},setComposite:function(t){if(null!==t&&!(t instanceof r.default.shape.composite.StrongComposite))throw"'composite must inherit from 'draw2d.shape.composite.StrongComposite'";return this.composite=t,this},getComposite:function(){return this.composite},fireEvent:function(t,e){try{if(