UNPKG

jbxl-workflow

Version:

流程图

66 lines 793 kB
(function(Oe,z){typeof exports=="object"&&typeof module<"u"?z(exports,require("@antv/x6"),require("vue"),require("element-plus"),require("dayjs")):typeof define=="function"&&define.amd?define(["exports","@antv/x6","vue","element-plus","dayjs"],z):(Oe=typeof globalThis<"u"?globalThis:Oe||self,z(Oe.workflow={},Oe.X6,Oe.Vue,Oe.ElementPlus,Oe.dayjs))})(this,function(Oe,z,e,ce,we){"use strict";var tP=Object.defineProperty;var vm=Oe=>{throw TypeError(Oe)};var nP=(Oe,z,e)=>z in Oe?tP(Oe,z,{enumerable:!0,configurable:!0,writable:!0,value:e}):Oe[z]=e;var Tr=(Oe,z,e)=>nP(Oe,typeof z!="symbol"?z+"":z,e),Nm=(Oe,z,e)=>z.has(Oe)||vm("Cannot "+e);var _m=(Oe,z,e)=>(Nm(Oe,z,"read from private field"),e?e.call(Oe):z.get(Oe)),xm=(Oe,z,e)=>z.has(Oe)?vm("Cannot add the same private member more than once"):z instanceof WeakSet?z.add(Oe):z.set(Oe,e),Tm=(Oe,z,e,ce)=>(Nm(Oe,z,"write to private field"),ce?ce.call(Oe,e):z.set(Oe,e),e);var _r;z.Graph.prototype.isHistoryEnabled=function(){const t=this.getPlugin("history");return t?t.isEnabled():!1},z.Graph.prototype.enableHistory=function(){const t=this.getPlugin("history");return t&&t.enable(),this},z.Graph.prototype.disableHistory=function(){const t=this.getPlugin("history");return t&&t.disable(),this},z.Graph.prototype.toggleHistory=function(t){const n=this.getPlugin("history");return n&&n.toggleEnabled(t),this},z.Graph.prototype.undo=function(t){const n=this.getPlugin("history");return n&&n.undo(t),this},z.Graph.prototype.redo=function(t){const n=this.getPlugin("history");return n&&n.redo(t),this},z.Graph.prototype.undoAndCancel=function(t){const n=this.getPlugin("history");return n&&n.cancel(t),this},z.Graph.prototype.canUndo=function(){const t=this.getPlugin("history");return t?t.canUndo():!1},z.Graph.prototype.canRedo=function(){const t=this.getPlugin("history");return t?t.canRedo():!1},z.Graph.prototype.cleanHistory=function(t){const n=this.getPlugin("history");return n&&n.clean(t),this},z.Graph.prototype.getHistoryStackSize=function(){return this.getPlugin("history").getSize()},z.Graph.prototype.getUndoStackSize=function(){return this.getPlugin("history").getUndoSize()},z.Graph.prototype.getRedoStackSize=function(){return this.getPlugin("history").getRedoSize()},z.Graph.prototype.getUndoRemainSize=function(){return this.getPlugin("history").getUndoRemainSize()};var Oc=function(t,n,o,a){var r=arguments.length,l=r<3?n:a===null?a=Object.getOwnPropertyDescriptor(n,o):a,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(t,n,o,a);else for(var i=t.length-1;i>=0;i--)(s=t[i])&&(l=(r<3?s(l):r>3?s(n,o,l):s(n,o))||l);return r>3&&l&&Object.defineProperty(n,o,l),l};class Ho extends z.Basecoat{constructor(n={}){super(),this.name="history",this.batchCommands=null,this.batchLevel=0,this.lastBatchIndex=-1,this.freezed=!1,this.stackSize=0,this.handlers=[];const{stackSize:o=0}=n;this.stackSize=o,this.options=rt.getOptions(n),this.validator=new Ho.Validator({history:this,cancelInvalid:this.options.cancelInvalid})}init(n){this.graph=n,this.model=this.graph.model,this.clean(),this.startListening()}isEnabled(){return!this.disabled}enable(){this.disabled&&(this.options.enabled=!0)}disable(){this.disabled||(this.options.enabled=!1)}toggleEnabled(n){return n!=null?n!==this.isEnabled()&&(n?this.enable():this.disable()):this.isEnabled()?this.disable():this.enable(),this}undo(n={}){if(!this.disabled){const o=this.undoStack.pop();o&&(this.revertCommand(o,n),this.redoStack.push(o),this.notify("undo",o,n))}return this}redo(n={}){if(!this.disabled){const o=this.redoStack.pop();o&&(this.applyCommand(o,n),this.undoStackPush(o),this.notify("redo",o,n))}return this}cancel(n={}){if(!this.disabled){const o=this.undoStack.pop();o&&(this.revertCommand(o,n),this.redoStack=[],this.notify("cancel",o,n))}return this}getSize(){return this.stackSize}getUndoRemainSize(){const n=this.undoStack.length;return this.stackSize-n}getUndoSize(){return this.undoStack.length}getRedoSize(){return this.redoStack.length}canUndo(){return!this.disabled&&this.undoStack.length>0}canRedo(){return!this.disabled&&this.redoStack.length>0}clean(n={}){return this.undoStack=[],this.redoStack=[],this.notify("clean",null,n),this}get disabled(){return this.options.enabled!==!0}validate(n,...o){return this.validator.validate(n,...o),this}startListening(){this.model.on("batch:start",this.initBatchCommand,this),this.model.on("batch:stop",this.storeBatchCommand,this),this.options.eventNames&&this.options.eventNames.forEach((n,o)=>{this.handlers[o]=this.addCommand.bind(this,n),this.model.on(n,this.handlers[o])}),this.validator.on("invalid",n=>this.trigger("invalid",n))}stopListening(){this.model.off("batch:start",this.initBatchCommand,this),this.model.off("batch:stop",this.storeBatchCommand,this),this.options.eventNames&&(this.options.eventNames.forEach((n,o)=>{this.model.off(n,this.handlers[o])}),this.handlers.length=0),this.validator.off("invalid")}createCommand(n){return{batch:n?n.batch:!1,data:{}}}revertCommand(n,o){this.freezed=!0;const a=Array.isArray(n)?rt.sortBatchCommands(n):[n];for(let r=a.length-1;r>=0;r-=1){const l=a[r],s=Object.assign(Object.assign({},o),z.ObjectExt.pick(l.options,this.options.revertOptionsList||[]));this.executeCommand(l,!0,s)}this.freezed=!1}applyCommand(n,o){this.freezed=!0;const a=Array.isArray(n)?rt.sortBatchCommands(n):[n];for(let r=0;r<a.length;r+=1){const l=a[r],s=Object.assign(Object.assign({},o),z.ObjectExt.pick(l.options,this.options.applyOptionsList||[]));this.executeCommand(l,!1,s)}this.freezed=!1}executeCommand(n,o,a){const r=this.model,l=r.getCell(n.data.id),s=n.event;if(rt.isAddEvent(s)&&o||rt.isRemoveEvent(s)&&!o)l&&l.remove(a);else if(rt.isAddEvent(s)&&!o||rt.isRemoveEvent(s)&&o){const i=n.data;i.node?r.addNode(i.props,a):i.edge&&r.addEdge(i.props,a)}else if(rt.isChangeEvent(s)){const i=n.data,c=i.key;if(c&&l){const d=o?i.prev[c]:i.next[c];i.key==="attrs"&&this.ensureUndefinedAttrs(d,o?i.next[c]:i.prev[c])&&(a.dirty=!0),l.prop(c,d,a)}}else{const i=this.options.executeCommand;i&&z.FunctionExt.call(i,this,n,o,a)}}addCommand(n,o){if(this.freezed||this.disabled)return;const a=o,r=a.options||{};if(r.dryrun||rt.isAddEvent(n)&&this.options.ignoreAdd||rt.isRemoveEvent(n)&&this.options.ignoreRemove||rt.isChangeEvent(n)&&this.options.ignoreChange)return;const l=this.options.beforeAddCommand;if(l!=null&&z.FunctionExt.call(l,this,n,o)===!1)return;n==="cell:change:*"&&(n=`cell:change:${a.key}`);const s=a.cell,i=z.Model.isModel(s);let c;if(this.batchCommands){c=this.batchCommands[Math.max(this.lastBatchIndex,0)];const u=i&&!c.modelChange||c.data.id!==s.id,f=c.event!==n;if(this.lastBatchIndex>=0&&(u||f)){const p=this.batchCommands.findIndex(m=>(i&&m.modelChange||m.data.id===s.id)&&m.event===n);p<0||rt.isAddEvent(n)||rt.isRemoveEvent(n)?c=this.createCommand({batch:!0}):(c=this.batchCommands[p],this.batchCommands.splice(p,1)),this.batchCommands.push(c),this.lastBatchIndex=this.batchCommands.length-1}}else c=this.createCommand({batch:!1});if(rt.isAddEvent(n)||rt.isRemoveEvent(n)){const u=c.data;return c.event=n,c.options=r,u.id=s.id,u.props=z.ObjectExt.cloneDeep(s.toJSON()),s.isEdge()?u.edge=!0:s.isNode()&&(u.node=!0),this.push(c,r)}if(rt.isChangeEvent(n)){const u=o.key,f=c.data;return(!c.batch||!c.event)&&(c.event=n,c.options=r,f.key=u,f.prev==null&&(f.prev={}),f.prev[u]=z.ObjectExt.cloneDeep(s.previous(u)),i?c.modelChange=!0:f.id=s.id),f.next==null&&(f.next={}),f.next[u]=z.ObjectExt.cloneDeep(s.prop(u)),this.push(c,r)}const d=this.options.afterAddCommand;d&&z.FunctionExt.call(d,this,n,o,c),this.push(c,r)}initBatchCommand(n){this.freezed||(this.batchCommands?this.batchLevel+=1:(this.batchCommands=[this.createCommand({batch:!0})],this.batchLevel=0,this.lastBatchIndex=-1))}storeBatchCommand(n){if(!this.freezed)if(this.batchCommands&&this.batchLevel<=0){const o=this.filterBatchCommand(this.batchCommands);o.length>0&&(this.redoStack=[],this.undoStackPush(o),this.consolidateCommands(),this.notify("add",o,n)),this.batchCommands=null,this.lastBatchIndex=-1,this.batchLevel=0}else this.batchCommands&&this.batchLevel>0&&(this.batchLevel-=1)}filterBatchCommand(n){let o=n.slice();const a=[];for(;o.length>0;){const r=o.shift(),l=r.event,s=r.data.id;if(l!=null&&(s!=null||r.modelChange)){if(rt.isAddEvent(l)){const i=o.findIndex(c=>rt.isRemoveEvent(c.event)&&c.data.id===s);if(i>=0){o=o.filter((c,d)=>i<d||c.data.id!==s);continue}}else if(rt.isRemoveEvent(l)){const i=o.findIndex(c=>rt.isAddEvent(c.event)&&c.data.id===s);if(i>=0){o.splice(i,1);continue}}else if(rt.isChangeEvent(l)){const i=r.data;if(z.ObjectExt.isEqual(i.prev,i.next))continue}a.push(r)}}return a}notify(n,o,a){const r=o==null?null:Array.isArray(o)?o:[o];this.emit(n,{cmds:r,options:a}),this.graph.trigger(`history:${n}`,{cmds:r,options:a}),this.emit("change",{cmds:r,options:a}),this.graph.trigger("history:change",{cmds:r,options:a})}push(n,o){this.redoStack=[],n.batch?(this.lastBatchIndex=Math.max(this.lastBatchIndex,0),this.emit("batch",{cmd:n,options:o})):(this.undoStackPush(n),this.consolidateCommands(),this.notify("add",n,o))}consolidateCommands(){var n;const o=this.undoStack[this.undoStack.length-1],a=this.undoStack[this.undoStack.length-2];if(!Array.isArray(o))return;const r=new Set(o.map(s=>s.event));if(r.size!==2||!r.has("cell:change:parent")||!r.has("cell:change:children")||!o.every(s=>{var i;return s.batch&&((i=s.options)===null||i===void 0?void 0:i.ui)})||!Array.isArray(a)||a.length!==1)return;const l=a[0];l.event!=="cell:change:position"||!(!((n=l.options)===null||n===void 0)&&n.ui)||(a.push(...o),this.undoStack.pop())}undoStackPush(n){if(this.stackSize===0){this.undoStack.push(n);return}this.undoStack.length>=this.stackSize&&this.undoStack.shift(),this.undoStack.push(n)}ensureUndefinedAttrs(n,o){let a=!1;return n!==null&&o!==null&&typeof n=="object"&&typeof o=="object"&&Object.keys(o).forEach(r=>{n[r]===void 0&&o[r]!==void 0?(n[r]=void 0,a=!0):typeof n[r]=="object"&&typeof o[r]=="object"&&(a=this.ensureUndefinedAttrs(n[r],o[r]))}),a}dispose(){this.validator.dispose(),this.clean(),this.stopListening(),this.off()}}Oc([z.Basecoat.dispose()],Ho.prototype,"dispose",null),function(t){class n extends z.Basecoat{constructor(a){super(),this.map={},this.command=a.history,this.cancelInvalid=a.cancelInvalid!==!1,this.command.on("add",this.onCommandAdded,this)}onCommandAdded({cmds:a}){return Array.isArray(a)?a.every(r=>this.isValidCommand(r)):this.isValidCommand(a)}isValidCommand(a){if(a.options&&a.options.validation===!1)return!0;const r=a.event&&this.map[a.event]||[];let l=null;return r.forEach(s=>{let i=0;const c=d=>{const u=s[i];i+=1;try{if(u)u(d,a,c);else{l=d;return}}catch(f){c(f)}};c(l)}),l?(this.cancelInvalid&&this.command.cancel(),this.emit("invalid",{err:l}),!1):!0}validate(a,...r){const l=Array.isArray(a)?a:a.split(/\s+/);return r.forEach(s=>{if(typeof s!="function")throw new Error(`${l.join(" ")} requires callback functions.`)}),l.forEach(s=>{this.map[s]==null&&(this.map[s]=[]),this.map[s].push(r)}),this}dispose(){this.command.off("add",this.onCommandAdded,this)}}Oc([z.Basecoat.dispose()],n.prototype,"dispose",null),t.Validator=n}(Ho||(Ho={}));var rt;(function(t){function n(s){return s==="cell:added"}t.isAddEvent=n;function o(s){return s==="cell:removed"}t.isRemoveEvent=o;function a(s){return s!=null&&s.startsWith("cell:change:")}t.isChangeEvent=a;function r(s){const i=["cell:added","cell:removed","cell:change:*"],c=["batch:start","batch:stop"],d=s.eventNames?s.eventNames.filter(u=>!(t.isChangeEvent(u)||i.includes(u)||c.includes(u))):i;return Object.assign(Object.assign({enabled:!0},s),{eventNames:d,applyOptionsList:s.applyOptionsList||["propertyPath"],revertOptionsList:s.revertOptionsList||["propertyPath"]})}t.getOptions=r;function l(s){const i=[];for(let c=0,d=s.length;c<d;c+=1){const u=s[c];let f=null;if(t.isAddEvent(u.event)){const p=u.data.id;for(let m=0;m<c;m+=1)if(s[m].data.id===p){f=m;break}}f!==null?i.splice(f,0,u):i.push(u)}return i}t.sortBatchCommands=l})(rt||(rt={}));var Dm=function(t,n,o,a){var r=arguments.length,l=r<3?n:a===null?a=Object.getOwnPropertyDescriptor(n,o):a,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(t,n,o,a);else for(var i=t.length-1;i>=0;i--)(s=t[i])&&(l=(r<3?s(l):r>3?s(n,o,l):s(n,o))||l);return r>3&&l&&Object.defineProperty(n,o,l),l};class Rc extends z.View{get graph(){return this.options.graph}get boxClassName(){return this.prefixClassName($t.classNames.box)}get $boxes(){return z.Dom.children(this.container,this.boxClassName)}get handleOptions(){return this.options}constructor(n){super(),this.options=n,this.options.model&&(this.options.collection=this.options.model.collection),this.options.collection?this.collection=this.options.collection:(this.collection=new z.Collection([],{comparator:$t.depthComparator}),this.options.collection=this.collection),this.boxCount=0,this.createContainer(),this.startListening()}startListening(){const n=this.graph,o=this.collection;this.delegateEvents({[`mousedown .${this.boxClassName}`]:"onSelectionBoxMouseDown",[`touchstart .${this.boxClassName}`]:"onSelectionBoxMouseDown"},!0),n.on("scale",this.onGraphTransformed,this),n.on("translate",this.onGraphTransformed,this),n.model.on("updated",this.onModelUpdated,this),o.on("added",this.onCellAdded,this),o.on("removed",this.onCellRemoved,this),o.on("reseted",this.onReseted,this),o.on("updated",this.onCollectionUpdated,this),o.on("node:change:position",this.onNodePositionChanged,this),o.on("cell:changed",this.onCellChanged,this)}stopListening(){const n=this.graph,o=this.collection;this.undelegateEvents(),n.off("scale",this.onGraphTransformed,this),n.off("translate",this.onGraphTransformed,this),n.model.off("updated",this.onModelUpdated,this),o.off("added",this.onCellAdded,this),o.off("removed",this.onCellRemoved,this),o.off("reseted",this.onReseted,this),o.off("updated",this.onCollectionUpdated,this),o.off("node:change:position",this.onNodePositionChanged,this),o.off("cell:changed",this.onCellChanged,this)}onRemove(){this.stopListening()}onGraphTransformed(){this.updateSelectionBoxes()}onCellChanged(){this.updateSelectionBoxes()}onNodePositionChanged({node:n,options:o}){const{showNodeSelectionBox:a,pointerEvents:r}=this.options,{ui:l,selection:s,translateBy:i,snapped:c}=o,d=(a!==!0||r&&this.getPointerEventsValue(r)==="none")&&!this.translating&&!s,u=l&&i&&n.id===i;if(d&&(u||c)){this.translating=!0;const f=n.position(),p=n.previous("position"),m=f.x-p.x,h=f.y-p.y;(m!==0||h!==0)&&this.translateSelectedNodes(m,h,n,o),this.translating=!1}}onModelUpdated({removed:n}){n&&n.length&&this.unselect(n)}isEmpty(){return this.length<=0}isSelected(n){return this.collection.has(n)}get length(){return this.collection.length}get cells(){return this.collection.toArray()}select(n,o={}){o.dryrun=!0;const a=this.filter(Array.isArray(n)?n:[n]);return this.collection.add(a,o),this}unselect(n,o={}){return o.dryrun=!0,this.collection.remove(Array.isArray(n)?n:[n],o),this}reset(n,o={}){if(n){if(o.batch){const d=this.filter(Array.isArray(n)?n:[n]);return this.collection.reset(d,Object.assign(Object.assign({},o),{ui:!0})),this}const a=this.cells,r=this.filter(Array.isArray(n)?n:[n]),l={},s={};a.forEach(d=>l[d.id]=d),r.forEach(d=>s[d.id]=d);const i=[],c=[];return r.forEach(d=>{l[d.id]||i.push(d)}),a.forEach(d=>{s[d.id]||c.push(d)}),c.length&&this.unselect(c,Object.assign(Object.assign({},o),{ui:!0})),i.length&&this.select(i,Object.assign(Object.assign({},o),{ui:!0})),c.length===0&&i.length===0&&this.updateContainer(),this}return this.clean(o)}clean(n={}){return this.length&&(n.batch===!1?this.unselect(this.cells,n):this.collection.reset([],Object.assign(Object.assign({},n),{ui:!0}))),this}setFilter(n){this.options.filter=n}setContent(n){this.options.content=n}startSelecting(n){n=this.normalizeEvent(n),this.clean();let o,a;const r=this.graph.container;if(n.offsetX!=null&&n.offsetY!=null&&r.contains(n.target))o=n.offsetX,a=n.offsetY;else{const l=z.Dom.offset(r),s=r.scrollLeft,i=r.scrollTop;o=n.clientX-l.left+window.pageXOffset+s,a=n.clientY-l.top+window.pageYOffset+i}z.Dom.css(this.container,{top:a,left:o,width:1,height:1}),this.setEventData(n,{action:"selecting",clientX:n.clientX,clientY:n.clientY,offsetX:o,offsetY:a,scrollerX:0,scrollerY:0,moving:!1}),this.delegateDocumentEvents($t.documentEvents,n.data)}filter(n){const o=this.options.filter;return n.filter(a=>Array.isArray(o)?o.some(r=>typeof r=="string"?a.shape===r:a.id===r.id):typeof o=="function"?z.FunctionExt.call(o,this.graph,a):!0)}stopSelecting(n){const o=this.graph,a=this.getEventData(n);switch(a.action){case"selecting":{let l=z.Dom.width(this.container),s=z.Dom.height(this.container);const i=z.Dom.offset(this.container),c=o.pageToLocal(i.left,i.top),d=o.transform.getScale();l/=d.sx,s/=d.sy;const u=new z.Rectangle(c.x,c.y,l,s),f=this.getCellViewsInArea(u).map(p=>p.cell);this.reset(f,{batch:!0}),this.hideRubberband();break}case"translating":{const l=o.snapToGrid(n.clientX,n.clientY);if(!this.options.following){const s=a;this.updateSelectedNodesPosition({dx:s.clientX-s.originX,dy:s.clientY-s.originY})}this.graph.model.stopBatch("move-selection"),this.notifyBoxEvent("box:mouseup",n,l.x,l.y);break}default:{this.clean();break}}}onMouseUp(n){this.getEventData(n).action&&(this.stopSelecting(n),this.undelegateDocumentEvents())}onSelectionBoxMouseDown(n){this.options.following||n.stopPropagation();const o=this.normalizeEvent(n);this.options.movable&&this.startTranslating(o);const a=this.getCellViewFromElem(o.target);this.setEventData(o,{activeView:a});const r=this.graph.snapToGrid(o.clientX,o.clientY);this.notifyBoxEvent("box:mousedown",o,r.x,r.y),this.delegateDocumentEvents($t.documentEvents,o.data)}startTranslating(n){this.graph.model.startBatch("move-selection");const o=this.graph.snapToGrid(n.clientX,n.clientY);this.setEventData(n,{action:"translating",clientX:o.x,clientY:o.y,originX:o.x,originY:o.y})}getRestrictArea(){const n=this.graph.options.translating.restrict,o=typeof n=="function"?z.FunctionExt.call(n,this.graph,null):n;return typeof o=="number"?this.graph.transform.getGraphArea().inflate(o):o===!0?this.graph.transform.getGraphArea():o||null}getSelectionOffset(n,o){let a=n.x-o.clientX,r=n.y-o.clientY;const l=this.getRestrictArea();if(l){const s=this.collection.toArray(),i=z.Cell.getCellsBBox(s,{deep:!0})||z.Rectangle.create(),c=l.x-i.x,d=l.y-i.y,u=l.x+l.width-(i.x+i.width),f=l.y+l.height-(i.y+i.height);if(a<c&&(a=c),r<d&&(r=d),u<a&&(a=u),f<r&&(r=f),!this.options.following){const p=n.x-o.originX,m=n.y-o.originY;a=p<=c||p>=u?0:a,r=m<=d||m>=f?0:r}}return{dx:a,dy:r}}updateElementPosition(n,o,a){const r=z.Dom.css(n,"left"),l=z.Dom.css(n,"top"),s=r?parseFloat(r):0,i=l?parseFloat(l):0;z.Dom.css(n,"left",s+o),z.Dom.css(n,"top",i+a)}updateSelectedNodesPosition(n){const{dx:o,dy:a}=n;if(o||a)if(this.translateSelectedNodes(o,a),this.boxesUpdated)this.collection.length>1&&this.updateSelectionBoxes();else{const r=this.graph.transform.getScale();for(let l=0,s=this.$boxes,i=s.length;l<i;l+=1)this.updateElementPosition(s[l],o*r.sx,a*r.sy);this.updateElementPosition(this.selectionContainer,o*r.sx,a*r.sy)}}autoScrollGraph(n,o){const a=this.graph.getPlugin("scroller");return a?a.autoScroll(n,o):{scrollerX:0,scrollerY:0}}adjustSelection(n){const o=this.normalizeEvent(n),a=this.getEventData(o);switch(a.action){case"selecting":{const l=a;l.moving!==!0&&(z.Dom.appendTo(this.container,this.graph.container),this.showRubberband(),l.moving=!0);const{scrollerX:s,scrollerY:i}=this.autoScrollGraph(o.clientX,o.clientY);l.scrollerX+=s,l.scrollerY+=i;const c=o.clientX-l.clientX+l.scrollerX,d=o.clientY-l.clientY+l.scrollerY,u=parseInt(z.Dom.css(this.container,"left")||"0",10),f=parseInt(z.Dom.css(this.container,"top")||"0",10);z.Dom.css(this.container,{left:c<0?l.offsetX+c:u,top:d<0?l.offsetY+d:f,width:Math.abs(c),height:Math.abs(d)});break}case"translating":{const l=this.graph.snapToGrid(o.clientX,o.clientY),s=a,i=this.getSelectionOffset(l,s);this.options.following?this.updateSelectedNodesPosition(i):this.updateContainerPosition(i),i.dx&&(s.clientX=l.x),i.dy&&(s.clientY=l.y),this.notifyBoxEvent("box:mousemove",n,l.x,l.y);break}}this.boxesUpdated=!1}translateSelectedNodes(n,o,a,r){const l={},s=[];if(a&&(l[a.id]=!0),this.collection.toArray().forEach(i=>{i.getDescendants({deep:!0}).forEach(c=>{l[c.id]=!0})}),r&&r.translateBy){const i=this.graph.getCellById(r.translateBy);i&&(l[i.id]=!0,i.getDescendants({deep:!0}).forEach(c=>{l[c.id]=!0}),s.push(i))}this.collection.toArray().forEach(i=>{if(!l[i.id]){const c=Object.assign(Object.assign({},r),{selection:this.cid,exclude:s});i.translate(n,o,c),this.graph.model.getConnectedEdges(i).forEach(d=>{l[d.id]||(d.translate(n,o,c),l[d.id]=!0)})}})}getCellViewsInArea(n){const o=this.graph,a={strict:this.options.strict};let r=[];return this.options.rubberNode&&(r=r.concat(o.model.getNodesInArea(n,a).map(l=>o.renderer.findViewByCell(l)).filter(l=>l!=null))),this.options.rubberEdge&&(r=r.concat(o.model.getEdgesInArea(n,a).map(l=>o.renderer.findViewByCell(l)).filter(l=>l!=null))),r}notifyBoxEvent(n,o,a,r){const s=this.getEventData(o).activeView;this.trigger(n,{e:o,view:s,x:a,y:r,cell:s.cell})}getSelectedClassName(n){return this.prefixClassName(`${n.isNode()?"node":"edge"}-selected`)}addCellSelectedClassName(n){const o=this.graph.renderer.findViewByCell(n);o&&o.addClass(this.getSelectedClassName(n))}removeCellUnSelectedClassName(n){const o=this.graph.renderer.findViewByCell(n);o&&o.removeClass(this.getSelectedClassName(n))}destroySelectionBox(n){this.removeCellUnSelectedClassName(n),this.canShowSelectionBox(n)&&(z.Dom.remove(this.container.querySelector(`[data-cell-id="${n.id}"]`)),this.$boxes.length===0&&this.hide(),this.boxCount=Math.max(0,this.boxCount-1))}destroyAllSelectionBoxes(n){n.forEach(o=>this.removeCellUnSelectedClassName(o)),this.hide(),z.Dom.remove(this.$boxes),this.boxCount=0}hide(){z.Dom.removeClass(this.container,this.prefixClassName($t.classNames.rubberband)),z.Dom.removeClass(this.container,this.prefixClassName($t.classNames.selected))}showRubberband(){z.Dom.addClass(this.container,this.prefixClassName($t.classNames.rubberband))}hideRubberband(){z.Dom.removeClass(this.container,this.prefixClassName($t.classNames.rubberband))}showSelected(){z.Dom.removeAttribute(this.container,"style"),z.Dom.addClass(this.container,this.prefixClassName($t.classNames.selected))}createContainer(){this.container=document.createElement("div"),z.Dom.addClass(this.container,this.prefixClassName($t.classNames.root)),this.options.className&&z.Dom.addClass(this.container,this.options.className),this.selectionContainer=document.createElement("div"),z.Dom.addClass(this.selectionContainer,this.prefixClassName($t.classNames.inner)),this.selectionContent=document.createElement("div"),z.Dom.addClass(this.selectionContent,this.prefixClassName($t.classNames.content)),z.Dom.append(this.selectionContainer,this.selectionContent),z.Dom.attr(this.selectionContainer,"data-selection-length",this.collection.length),z.Dom.prepend(this.container,this.selectionContainer)}updateContainerPosition(n){(n.dx||n.dy)&&this.updateElementPosition(this.selectionContainer,n.dx,n.dy)}updateContainer(){const n={x:1/0,y:1/0},o={x:0,y:0};this.collection.toArray().filter(l=>this.canShowSelectionBox(l)).forEach(l=>{const s=this.graph.renderer.findViewByCell(l);if(s){const i=s.getBBox({useCellGeometry:!0});n.x=Math.min(n.x,i.x),n.y=Math.min(n.y,i.y),o.x=Math.max(o.x,i.x+i.width),o.y=Math.max(o.y,i.y+i.height)}}),z.Dom.css(this.selectionContainer,{position:"absolute",pointerEvents:"none",left:n.x,top:n.y,width:o.x-n.x,height:o.y-n.y}),z.Dom.attr(this.selectionContainer,"data-selection-length",this.collection.length);const r=this.options.content;if(r)if(typeof r=="function"){const l=z.FunctionExt.call(r,this.graph,this,this.selectionContent);l&&(this.selectionContent.innerHTML=l)}else this.selectionContent.innerHTML=r;this.collection.length>0&&!this.container.parentNode?z.Dom.appendTo(this.container,this.graph.container):this.collection.length<=0&&this.container.parentNode&&this.container.parentNode.removeChild(this.container)}canShowSelectionBox(n){return n.isNode()&&this.options.showNodeSelectionBox===!0||n.isEdge()&&this.options.showEdgeSelectionBox===!0}getPointerEventsValue(n){return typeof n=="string"?n:n(this.cells)}createSelectionBox(n){if(this.addCellSelectedClassName(n),this.canShowSelectionBox(n)){const o=this.graph.renderer.findViewByCell(n);if(o){const a=o.getBBox({useCellGeometry:!0}),r=this.boxClassName,l=document.createElement("div"),s=this.options.pointerEvents;z.Dom.addClass(l,r),z.Dom.addClass(l,`${r}-${n.isNode()?"node":"edge"}`),z.Dom.attr(l,"data-cell-id",n.id),z.Dom.css(l,{position:"absolute",left:a.x,top:a.y,width:a.width,height:a.height,pointerEvents:s?this.getPointerEventsValue(s):"auto"}),z.Dom.appendTo(l,this.container),this.showSelected(),this.boxCount+=1}}}updateSelectionBoxes(){this.collection.length>0&&(this.boxesUpdated=!0,this.confirmUpdate())}confirmUpdate(){if(this.boxCount){this.hide();for(let n=0,o=this.$boxes,a=o.length;n<a;n+=1){const r=o[n],l=z.Dom.attr(r,"data-cell-id");z.Dom.remove(r),this.boxCount-=1;const s=this.collection.get(l);s&&this.createSelectionBox(s)}this.updateContainer()}return 0}getCellViewFromElem(n){const o=n.getAttribute("data-cell-id");if(o){const a=this.collection.get(o);if(a)return this.graph.renderer.findViewByCell(a)}return null}onCellRemoved({cell:n}){this.destroySelectionBox(n),this.updateContainer()}onReseted({previous:n,current:o}){this.destroyAllSelectionBoxes(n),o.forEach(a=>{this.listenCellRemoveEvent(a),this.createSelectionBox(a)}),this.updateContainer()}onCellAdded({cell:n}){this.listenCellRemoveEvent(n),this.createSelectionBox(n),this.updateContainer()}listenCellRemoveEvent(n){n.off("removed",this.onCellRemoved,this),n.on("removed",this.onCellRemoved,this)}onCollectionUpdated({added:n,removed:o,options:a}){n.forEach(l=>{this.trigger("cell:selected",{cell:l,options:a}),l.isNode()?this.trigger("node:selected",{cell:l,options:a,node:l}):l.isEdge()&&this.trigger("edge:selected",{cell:l,options:a,edge:l})}),o.forEach(l=>{this.trigger("cell:unselected",{cell:l,options:a}),l.isNode()?this.trigger("node:unselected",{cell:l,options:a,node:l}):l.isEdge()&&this.trigger("edge:unselected",{cell:l,options:a,edge:l})});const r={added:n,removed:o,options:a,selected:this.cells.filter(l=>!!this.graph.getCellById(l.id))};this.trigger("selection:changed",r)}dispose(){this.clean(),this.remove(),this.off()}}Dm([z.View.dispose()],Rc.prototype,"dispose",null);var $t;(function(t){const n="widget-selection";t.classNames={root:n,inner:`${n}-inner`,box:`${n}-box`,content:`${n}-content`,rubberband:`${n}-rubberband`,selected:`${n}-selected`},t.documentEvents={mousemove:"adjustSelection",touchmove:"adjustSelection",mouseup:"onMouseUp",touchend:"onMouseUp",touchcancel:"onMouseUp"};function o(a){return a.getAncestors().length}t.depthComparator=o})($t||($t={}));const Pm=`.x6-widget-selection { position: absolute; top: 0; left: 0; display: none; width: 0; height: 0; touch-action: none; } .x6-widget-selection-rubberband { display: block; overflow: visible; opacity: 0.3; } .x6-widget-selection-selected { display: block; } .x6-widget-selection-box { cursor: move; } .x6-widget-selection-inner[data-selection-length='0'], .x6-widget-selection-inner[data-selection-length='1'] { display: none; } .x6-widget-selection-content { position: absolute; top: 100%; right: -20px; left: -20px; margin-top: 30px; padding: 6px; line-height: 14px; text-align: center; border-radius: 6px; } .x6-widget-selection-content:empty { display: none; } .x6-widget-selection-rubberband { background-color: #3498db; border: 2px solid #2980b9; } .x6-widget-selection-box { box-sizing: content-box !important; margin-top: -4px; margin-left: -4px; padding-right: 4px; padding-bottom: 4px; border: 2px dashed #feb663; box-shadow: 2px 2px 5px #d3d3d3; } .x6-widget-selection-inner { box-sizing: content-box !important; margin-top: -8px; margin-left: -8px; padding-right: 12px; padding-bottom: 12px; border: 2px solid #feb663; box-shadow: 2px 2px 5px #d3d3d3; } .x6-widget-selection-content { color: #fff; font-size: 10px; background-color: #6a6b8a; } `;z.Graph.prototype.isSelectionEnabled=function(){const t=this.getPlugin("selection");return t?t.isEnabled():!1},z.Graph.prototype.enableSelection=function(){const t=this.getPlugin("selection");return t&&t.enable(),this},z.Graph.prototype.disableSelection=function(){const t=this.getPlugin("selection");return t&&t.disable(),this},z.Graph.prototype.toggleSelection=function(t){const n=this.getPlugin("selection");return n&&n.toggleEnabled(t),this},z.Graph.prototype.isMultipleSelection=function(){const t=this.getPlugin("selection");return t?t.isMultipleSelection():!1},z.Graph.prototype.enableMultipleSelection=function(){const t=this.getPlugin("selection");return t&&t.enableMultipleSelection(),this},z.Graph.prototype.disableMultipleSelection=function(){const t=this.getPlugin("selection");return t&&t.disableMultipleSelection(),this},z.Graph.prototype.toggleMultipleSelection=function(t){const n=this.getPlugin("selection");return n&&n.toggleMultipleSelection(t),this},z.Graph.prototype.isSelectionMovable=function(){const t=this.getPlugin("selection");return t?t.isSelectionMovable():!1},z.Graph.prototype.enableSelectionMovable=function(){const t=this.getPlugin("selection");return t&&t.enableSelectionMovable(),this},z.Graph.prototype.disableSelectionMovable=function(){const t=this.getPlugin("selection");return t&&t.disableSelectionMovable(),this},z.Graph.prototype.toggleSelectionMovable=function(t){const n=this.getPlugin("selection");return n&&n.toggleSelectionMovable(t),this},z.Graph.prototype.isRubberbandEnabled=function(){const t=this.getPlugin("selection");return t?t.isRubberbandEnabled():!1},z.Graph.prototype.enableRubberband=function(){const t=this.getPlugin("selection");return t&&t.enableRubberband(),this},z.Graph.prototype.disableRubberband=function(){const t=this.getPlugin("selection");return t&&t.disableRubberband(),this},z.Graph.prototype.toggleRubberband=function(t){const n=this.getPlugin("selection");return n&&n.toggleRubberband(t),this},z.Graph.prototype.isStrictRubberband=function(){const t=this.getPlugin("selection");return t?t.isStrictRubberband():!1},z.Graph.prototype.enableStrictRubberband=function(){const t=this.getPlugin("selection");return t&&t.enableStrictRubberband(),this},z.Graph.prototype.disableStrictRubberband=function(){const t=this.getPlugin("selection");return t&&t.disableStrictRubberband(),this},z.Graph.prototype.toggleStrictRubberband=function(t){const n=this.getPlugin("selection");return n&&n.toggleStrictRubberband(t),this},z.Graph.prototype.setRubberbandModifiers=function(t){const n=this.getPlugin("selection");return n&&n.setRubberbandModifiers(t),this},z.Graph.prototype.setSelectionFilter=function(t){const n=this.getPlugin("selection");return n&&n.setSelectionFilter(t),this},z.Graph.prototype.setSelectionDisplayContent=function(t){const n=this.getPlugin("selection");return n&&n.setSelectionDisplayContent(t),this},z.Graph.prototype.isSelectionEmpty=function(){const t=this.getPlugin("selection");return t?t.isEmpty():!0},z.Graph.prototype.cleanSelection=function(t){const n=this.getPlugin("selection");return n&&n.clean(t),this},z.Graph.prototype.resetSelection=function(t,n){const o=this.getPlugin("selection");return o&&o.reset(t,n),this},z.Graph.prototype.getSelectedCells=function(){const t=this.getPlugin("selection");return t?t.getSelectedCells():[]},z.Graph.prototype.getSelectedCellCount=function(){const t=this.getPlugin("selection");return t?t.getSelectedCellCount():0},z.Graph.prototype.isSelected=function(t){const n=this.getPlugin("selection");return n?n.isSelected(t):!1},z.Graph.prototype.select=function(t,n){const o=this.getPlugin("selection");return o&&o.select(t,n),this},z.Graph.prototype.unselect=function(t,n){const o=this.getPlugin("selection");return o&&o.unselect(t,n),this};var Bm=function(t,n,o,a){var r=arguments.length,l=r<3?n:a===null?a=Object.getOwnPropertyDescriptor(n,o):a,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(t,n,o,a);else for(var i=t.length-1;i>=0;i--)(s=t[i])&&(l=(r<3?s(l):r>3?s(n,o,l):s(n,o))||l);return r>3&&l&&Object.defineProperty(n,o,l),l};class jo extends z.Basecoat{get rubberbandDisabled(){return this.options.enabled!==!0||this.options.rubberband!==!0}get disabled(){return this.options.enabled!==!0}get length(){return this.selectionImpl.length}get cells(){return this.selectionImpl.cells}constructor(n={}){super(),this.name="selection",this.movedMap=new WeakMap,this.unselectMap=new WeakMap,this.options=Object.assign(Object.assign({enabled:!0},jo.defaultOptions),n),z.CssLoader.ensure(this.name,Pm)}init(n){this.graph=n,this.selectionImpl=new Rc(Object.assign(Object.assign({},this.options),{graph:n})),this.setup(),this.startListening()}isEnabled(){return!this.disabled}enable(){this.disabled&&(this.options.enabled=!0)}disable(){this.disabled||(this.options.enabled=!1)}toggleEnabled(n){return n!=null?n!==this.isEnabled()&&(n?this.enable():this.disable()):this.isEnabled()?this.disable():this.enable(),this}isMultipleSelection(){return this.isMultiple()}enableMultipleSelection(){return this.enableMultiple(),this}disableMultipleSelection(){return this.disableMultiple(),this}toggleMultipleSelection(n){return n!=null?n!==this.isMultipleSelection()&&(n?this.enableMultipleSelection():this.disableMultipleSelection()):this.isMultipleSelection()?this.disableMultipleSelection():this.enableMultipleSelection(),this}isSelectionMovable(){return this.options.movable!==!1}enableSelectionMovable(){return this.selectionImpl.options.movable=!0,this}disableSelectionMovable(){return this.selectionImpl.options.movable=!1,this}toggleSelectionMovable(n){return n!=null?n!==this.isSelectionMovable()&&(n?this.enableSelectionMovable():this.disableSelectionMovable()):this.isSelectionMovable()?this.disableSelectionMovable():this.enableSelectionMovable(),this}isRubberbandEnabled(){return!this.rubberbandDisabled}enableRubberband(){return this.rubberbandDisabled&&(this.options.rubberband=!0),this}disableRubberband(){return this.rubberbandDisabled||(this.options.rubberband=!1),this}toggleRubberband(n){return n!=null?n!==this.isRubberbandEnabled()&&(n?this.enableRubberband():this.disableRubberband()):this.isRubberbandEnabled()?this.disableRubberband():this.enableRubberband(),this}isStrictRubberband(){return this.selectionImpl.options.strict===!0}enableStrictRubberband(){return this.selectionImpl.options.strict=!0,this}disableStrictRubberband(){return this.selectionImpl.options.strict=!1,this}toggleStrictRubberband(n){return n!=null?n!==this.isStrictRubberband()&&(n?this.enableStrictRubberband():this.disableStrictRubberband()):this.isStrictRubberband()?this.disableStrictRubberband():this.enableStrictRubberband(),this}setRubberbandModifiers(n){this.setModifiers(n)}setSelectionFilter(n){return this.setFilter(n),this}setSelectionDisplayContent(n){return this.setContent(n),this}isEmpty(){return this.length<=0}clean(n={}){return this.selectionImpl.clean(n),this}reset(n,o={}){return this.selectionImpl.reset(n?this.getCells(n):[],o),this}getSelectedCells(){return this.cells}getSelectedCellCount(){return this.length}isSelected(n){return this.selectionImpl.isSelected(n)}select(n,o={}){const a=this.getCells(n);return a.length&&(this.isMultiple()?this.selectionImpl.select(a,o):this.reset(a.slice(0,1),o)),this}unselect(n,o={}){return this.selectionImpl.unselect(this.getCells(n),o),this}setup(){this.selectionImpl.on("*",(n,o)=>{this.trigger(n,o),this.graph.trigger(n,o)})}startListening(){this.graph.on("blank:mousedown",this.onBlankMouseDown,this),this.graph.on("blank:click",this.onBlankClick,this),this.graph.on("cell:mousemove",this.onCellMouseMove,this),this.graph.on("cell:mouseup",this.onCellMouseUp,this),this.selectionImpl.on("box:mousedown",this.onBoxMouseDown,this)}stopListening(){this.graph.off("blank:mousedown",this.onBlankMouseDown,this),this.graph.off("blank:click",this.onBlankClick,this),this.graph.off("cell:mousemove",this.onCellMouseMove,this),this.graph.off("cell:mouseup",this.onCellMouseUp,this),this.selectionImpl.off("box:mousedown",this.onBoxMouseDown,this)}onBlankMouseDown({e:n}){if(!this.allowBlankMouseDown(n))return;const o=this.graph.panning.allowPanning(n,!0),a=this.graph.getPlugin("scroller"),r=a&&a.allowPanning(n,!0);(this.allowRubberband(n,!0)||this.allowRubberband(n)&&!r&&!o)&&this.startRubberband(n)}allowBlankMouseDown(n){const o=this.options.eventTypes;return(o==null?void 0:o.includes("leftMouseDown"))&&n.button===0||(o==null?void 0:o.includes("mouseWheelDown"))&&n.button===1}onBlankClick(){this.clean()}allowRubberband(n,o){return!this.rubberbandDisabled&&z.ModifierKey.isMatch(n,this.options.modifiers,o)}allowMultipleSelection(n){return this.isMultiple()&&z.ModifierKey.isMatch(n,this.options.multipleSelectionModifiers)}onCellMouseMove({cell:n}){this.movedMap.set(n,!0)}onCellMouseUp({e:n,cell:o}){const a=this.options;let r=this.disabled;!r&&this.movedMap.has(o)&&(r=a.selectCellOnMoved===!1,r||(r=a.selectNodeOnMoved===!1&&o.isNode()),r||(r=a.selectEdgeOnMoved===!1&&o.isEdge())),r||(this.allowMultipleSelection(n)?this.unselectMap.has(o)?this.unselectMap.delete(o):this.isSelected(o)?this.unselect(o):this.select(o):this.reset(o)),this.movedMap.delete(o)}onBoxMouseDown({e:n,cell:o}){this.disabled||this.allowMultipleSelection(n)&&(this.unselect(o),this.unselectMap.set(o,!0))}getCells(n){return(Array.isArray(n)?n:[n]).map(o=>typeof o=="string"?this.graph.getCellById(o):o).filter(o=>o!=null)}startRubberband(n){return this.rubberbandDisabled||this.selectionImpl.startSelecting(n),this}isMultiple(){return this.options.multiple!==!1}enableMultiple(){return this.options.multiple=!0,this}disableMultiple(){return this.options.multiple=!1,this}setModifiers(n){return this.options.modifiers=n,this}setContent(n){return this.selectionImpl.setContent(n),this}setFilter(n){return this.selectionImpl.setFilter(n),this}dispose(){this.stopListening(),this.off(),this.selectionImpl.dispose(),z.CssLoader.clean(this.name)}}Bm([z.Basecoat.dispose()],jo.prototype,"dispose",null),function(t){t.defaultOptions={rubberband:!1,rubberNode:!0,rubberEdge:!1,pointerEvents:"auto",multiple:!0,multipleSelectionModifiers:["ctrl","meta"],movable:!0,strict:!1,selectCellOnMoved:!1,selectNodeOnMoved:!1,selectEdgeOnMoved:!1,following:!0,content:null,eventTypes:["leftMouseDown","mouseWheelDown"]}}(jo||(jo={}));function vn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var us={exports:{}},Ac;function Vm(){return Ac||(Ac=1,function(t){(function(n,o,a){if(!n)return;for(var r={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"ins",46:"del",91:"meta",93:"meta",224:"meta"},l={106:"*",107:"+",109:"-",110:".",111:"/",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},s={"~":"`","!":"1","@":"2","#":"3",$:"4","%":"5","^":"6","&":"7","*":"8","(":"9",")":"0",_:"-","+":"=",":":";",'"':"'","<":",",">":".","?":"/","|":"\\"},i={option:"alt",command:"meta",return:"enter",escape:"esc",plus:"+",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},c,d=1;d<20;++d)r[111+d]="f"+d;for(d=0;d<=9;++d)r[d+96]=d.toString();function u(S,k,v){if(S.addEventListener){S.addEventListener(k,v,!1);return}S.attachEvent("on"+k,v)}function f(S){if(S.type=="keypress"){var k=String.fromCharCode(S.which);return S.shiftKey||(k=k.toLowerCase()),k}return r[S.which]?r[S.which]:l[S.which]?l[S.which]:String.fromCharCode(S.which).toLowerCase()}function p(S,k){return S.sort().join(",")===k.sort().join(",")}function m(S){var k=[];return S.shiftKey&&k.push("shift"),S.altKey&&k.push("alt"),S.ctrlKey&&k.push("ctrl"),S.metaKey&&k.push("meta"),k}function h(S){if(S.preventDefault){S.preventDefault();return}S.returnValue=!1}function b(S){if(S.stopPropagation){S.stopPropagation();return}S.cancelBubble=!0}function C(S){return S=="shift"||S=="ctrl"||S=="alt"||S=="meta"}function w(){if(!c){c={};for(var S in r)S>95&&S<112||r.hasOwnProperty(S)&&(c[r[S]]=S)}return c}function _(S,k,v){return v||(v=w()[S]?"keydown":"keypress"),v=="keypress"&&k.length&&(v="keydown"),v}function N(S){return S==="+"?["+"]:(S=S.replace(/\+{2}/g,"+plus"),S.split("+"))}function g(S,k){var v,T,V,I=[];for(v=N(S),V=0;V<v.length;++V)T=v[V],i[T]&&(T=i[T]),k&&k!="keypress"&&s[T]&&(T=s[T],I.push("shift")),C(T)&&I.push(T);return k=_(T,I,k),{key:T,modifiers:I,action:k}}function y(S,k){return S===null||S===o?!1:S===k?!0:y(S.parentNode,k)}function E(S){var k=this;if(S=S||o,!(k instanceof E))return new E(S);k.target=S,k._callbacks={},k._directMap={};var v={},T,V=!1,I=!1,M=!1;function q(D){D=D||{};var F=!1,B;for(B in v){if(D[B]){F=!0;continue}v[B]=0}F||(M=!1)}function j(D,F,B,L,U,R){var H,W,oe=[],Z=B.type;if(!k._callbacks[D])return[];for(Z=="keyup"&&C(D)&&(F=[D]),H=0;H<k._callbacks[D].length;++H)if(W=k._callbacks[D][H],!(!L&&W.seq&&v[W.seq]!=W.level)&&Z==W.action&&(Z=="keypress"&&!B.metaKey&&!B.ctrlKey||p(F,W.modifiers))){var J=!L&&W.combo==U,ne=L&&W.seq==L&&W.level==R;(J||ne)&&k._callbacks[D].splice(H,1),oe.push(W)}return oe}function K(D,F,B,L){k.stopCallback(F,F.target||F.srcElement,B,L)||D(F,B)===!1&&(h(F),b(F))}k._handleKey=function(D,F,B){var L=j(D,F,B),U,R={},H=0,W=!1;for(U=0;U<L.length;++U)L[U].seq&&(H=Math.max(H,L[U].level));for(U=0;U<L.length;++U){if(L[U].seq){if(L[U].level!=H)continue;W=!0,R[L[U].seq]=1,K(L[U].callback,B,L[U].combo,L[U].seq);continue}W||K(L[U].callback,B,L[U].combo)}var oe=B.type=="keypress"&&I;B.type==M&&!C(D)&&!oe&&q(R),I=W&&B.type=="keydown"};function O(D){typeof D.which!="number"&&(D.which=D.keyCode);var F=f(D);if(F){if(D.type=="keyup"&&V===F){V=!1;return}k.handleKey(F,m(D),D)}}function $(){clearTimeout(T),T=setTimeout(q,1e3)}function x(D,F,B,L){v[D]=0;function U(Z){return function(){M=Z,++v[D],$()}}function R(Z){K(B,Z,D),L!=="keyup"&&(V=f(Z)),setTimeout(q,10)}for(var H=0;H<F.length;++H){var W=H+1===F.length,oe=W?R:U(L||g(F[H+1]).action);P(F[H],oe,L,D,H)}}function P(D,F,B,L,U){k._directMap[D+":"+B]=F,D=D.replace(/\s+/g," ");var R=D.split(" "),H;if(R.length>1){x(D,R,F,B);return}H=g(D,B),k._callbacks[H.key]=k._callbacks[H.key]||[],j(H.key,H.modifiers,{type:H.action},L,D,U),k._callbacks[H.key][L?"unshift":"push"]({callback:F,modifiers:H.modifiers,action:H.action,seq:L,level:U,combo:D})}k._bindMultiple=function(D,F,B){for(var L=0;L<D.length;++L)P(D[L],F,B)},u(S,"keypress",O),u(S,"keydown",O),u(S,"keyup",O)}E.prototype.bind=function(S,k,v){var T=this;return S=S instanceof Array?S:[S],T._bindMultiple.call(T,S,k,v),T},E.prototype.unbind=function(S,k){var v=this;return v.bind.call(v,S,function(){},k)},E.prototype.trigger=function(S,k){var v=this;return v._directMap[S+":"+k]&&v._directMap[S+":"+k]({},S),v},E.prototype.reset=function(){var S=this;return S._callbacks={},S._directMap={},S},E.prototype.stopCallback=function(S,k){var v=this;if((" "+k.className+" ").indexOf(" mousetrap ")>-1||y(k,v.target))return!1;if("composedPath"in S&&typeof S.composedPath=="function"){var T=S.composedPath()[0];T!==S.target&&(k=T)}return k.tagName=="INPUT"||k.tagName=="SELECT"||k.tagName=="TEXTAREA"||k.isContentEditable},E.prototype.handleKey=function(){var S=this;return S._handleKey.apply(S,arguments)},E.addKeycodes=function(S){for(var k in S)S.hasOwnProperty(k)&&(r[k]=S[k]);c=null},E.init=function(){var S=E(o);for(var k in S)k.charAt(0)!=="_"&&(E[k]=function(v){return function(){return S[v].apply(S,arguments)}}(k))},E.init(),n.Mousetrap=E,t.exports&&(t.exports=E)})(typeof window<"u"?window:null,typeof window<"u"?document:null)}(us)),us.exports}var Mm=Vm();const Om=vn(Mm);var Rm=function(t,n,o,a){var r=arguments.length,l=r<3?n:a===null?a=Object.getOwnPropertyDescriptor(n,o):a,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(t,n,o,a);else for(var i=t.length-1;i>=0;i--)(s=t[i])&&(l=(r<3?s(l):r>3?s(n,o,l):s(n,o))||l);return r>3&&l&&Object.defineProperty(n,o,l),l};class Wo extends z.Disposable{get graph(){return this.options.graph}constructor(n){super(),this.options=n;const o=this.graph.getPlugin("scroller");this.container=o?o.container:this.graph.container,n.global?this.target=document:(this.target=this.container,this.disabled||this.target.setAttribute("tabindex","-1"),this.graph.on("cell:mouseup",this.focus,this),this.graph.on("blank:mouseup",this.focus,this)),this.mousetrap=Wo.createMousetrap(this)}get disabled(){return this.options.enabled!==!0}enable(){this.disabled&&(this.options.enabled=!0,this.target instanceof HTMLElement&&this.target.setAttribute("tabindex","-1"))}disable(){this.disabled||(this.options.enabled=!1,this.target instanceof HTMLElement&&this.target.removeAttribute("tabindex"))}on(n,o,a){this.mousetrap.bind(this.getKeys(n),o,a)}off(n,o){this.mousetrap.unbind(this.getKeys(n),o)}clear(){this.mousetrap.reset()}trigger(n,o){this.mousetrap.trigger(n,o)}focus(n){if(this.isInputEvent(n.e))return;this.target.focus({preventScroll:!0})}getKeys(n){return(Array.isArray(n)?n:[n]).map(o=>this.formatkey(o))}formatkey(n){const o=n.toLocaleLowerCase().replace(/\s/g,"").replace("delete","del").replace("cmd","command").replace("arrowup","up").replace("arrowright","right").replace("arrowdown","down").replace("arrowleft","left"),a=this.options.format;return a?z.FunctionExt.call(a,this.graph,o):o}isGraphEvent(n){const o=n.target,a=n.currentTarget;return o?o===this.target||a===this.target||o===document.body?!0:z.Dom.contains(this.container,o):!1}isInputEvent(n){var o;const a=n.target,r=(o=a==null?void 0:a.tagName)===null||o===void 0?void 0:o.toLowerCase();let l=["input","textarea"].includes(r);return z.Dom.attr(a,"contenteditable")==="true"&&(l=!0),l}isEnabledForEvent(n){const o=!this.disabled&&this.isGraphEvent(n),a=this.isInputEvent(n);if(o){if(a&&(n.key==="Backspace"||n.key==="Delete"))return!1;if(this.options.guard)return z.FunctionExt.call(this.options.guard,this.graph,n)}return o}dispose(){this.mousetrap.reset()}}Rm([z.Disposable.dispose()],Wo.prototype,"dispose",null),function(t){function n(o){const a=new Om(o.target),r=a.stopCallback;return a.stopCallback=(l,s,i)=>o.isEnabledForEvent(l)?r?r.call(a,l,s,i):!1:!0,a}t.createMousetrap=n}(Wo||(Wo={})),z.Graph.prototype.isKeyboardEnabled=function(){const t=this.getPlugin("keyboard");return t?t.isEnabled():!1},z.Graph.prototype.enableKeyboard=function(){const t=this.getPlugin("keyboard");return t&&t.enable(),this},z.Graph.prototype.disableKeyboard=function(){const t=this.getPlugin("keyboard");return t&&t.disable(),this},z.Graph.prototype.toggleKeyboard=function(t){const n=this.getPlugin("keyboard");return n&&n.toggleEnabled(t),this},z.Graph.prototype.bindKey=function(t,n,o){const a=this.getPlugin("keyboard");return a&&a.bindKey(t,n,o),this},z.Graph.prototype.unbindKey=function(t,n){const o=this.getPlugin("keyboard");return o&&o.unbindKey(t,n),this},z.Graph.prototype.clearKeys=function(){const t=this.getPlugin("keyboard");return t&&t.clear(),this},z.Graph.prototype.triggerKey=function(t,n){const o=this.getPlugin("keyboard");return o&&o.trigger(t,n),this};var Am=function(t,n,o,a){var r=arguments.length,l=r<3?n:a===null?a=Object.getOwnPropertyDescriptor(n,o):a,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(t,n,o,a);else for(var i=t.length-1;i>=0;i--)(s=t[i])&&(l=(r<3?s(l):r>3?s(n,o,l):s(n,o))||l);return r>3&&l&&Object.defineProperty(n,o,l),l};class Ic extends z.Disposable{constructor(n={}){super(),this.name="keyboard",this.options=Object.assign({enabled:!0},n)}init(n){this.keyboardImpl=new Wo(Object.assign(Object.assign({},this.options),{graph:n}))}isEnabled(){return!this.keyboardImpl.disabled}enable(){this.keyboardImpl.enable()}disable(){this.keyboardImpl.disable()}toggleEnabled(n){return n!=null?n!==this.isEnabled()&&(n?this.enable():this.disable()):this.isEnabled()?this.disable():this.enable(),this}bindKey(n,o,a){return this.keyboardImpl.on(n,o,a),this}trigger(n,o){return this.keyboardImpl.trigger(n,o),this}clear(){return this.keyboardImpl.clear(),this}unbindKey(n,o){return this.keyboardImpl.off(n,o),this}dispose(){this.keyboardImpl.dispose()}}Am([z.Disposable.dispose()],Ic.prototype,"dispose",null);var Dr={exports:{}},Im=Dr.exports,Lc;function Lm(){return Lc||(Lc=1,function(t,n){(function(o,a){t.exports=a()})(Im,function(){return function(o,a,r){r.updateLocale=function(l,s){var i=r.Ls[l];if(i)return(s?Object.keys(s):[]).forEach(function(c){i[c]=s[c]}),i}}})}(Dr)),Dr.exports}var $m=Lm();const Fm=vn($m);var Pr={exports:{}},zm=Pr.exports,$c;function Um(){return $c||($c=1,function(t,n){(function(o,a){t.exports=a()})(zm,function(){var o={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},a=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,r=/\d/,l=/\d\d/,s=/\d\d?/,i=/\d*[^-_:/,()\s\d]+/,c={},d=function(C){return(C=+C)+(C>68?1900:2e3)},u=function(C){return function(w){this[C]=+w}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(C){(this.zone||(this.zone={})).offset=function(w){if(!w||w==="Z")return 0;var _=w.match(/([+-]|\d\d)/g),N=60*_[1]+(+_[2]||0);return N===0?0:_[0]==="+"?-N:N}(C)}],p=function(C){var w=c[C];return w&&(w.indexOf?w:w.s.concat(w.f))},m=function(C,w){var _,N=c.meridiem;if(N){for(var g=1;g<=24;g+=1)if(C.indexOf(N(g,0,w))>-1){_=g>12;break}}else _=C===(w?"pm":"PM");return _},h={A:[i,function(C){this.afternoon=m(C,!1)}],a:[i,function(C){this.afternoon=m(C,!0)}],Q:[r,function(C){this.month=3*(C-1)+1}],S:[r,function(C){this.milliseconds=100*+C}],SS:[l,function(C){this.milliseconds=10*+C}],SSS:[/\d{3}/,function(C){this.milliseconds=+C}],s:[s,u("seconds")],ss:[s,u("seconds")],m:[s,u("minutes")],mm:[s,u("minutes")],H:[s,u("hours")],h:[s,u("hours")],HH:[s,