You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
249 lines
63 KiB
249 lines
63 KiB
import{bd as zt,d as Mt,q as Rt,r as dt,P as Bt,b as w,h as B,s as Ot,gk as At,bu as Nt,B as Tt,Y as nt,aT as Dt}from"./index-f4658ae7.js";import{C as Pt}from"./index-297faa0c.js";import{V as $,n as j,b as R,d as pt,o as ot,A as G,g as P,r as _,P as k,q as gt,k as rt,G as u,B as tt,e as et,l as it,s as Ft,C as It,p as U,R as ht,u as Gt,f as J,j as at,v as $t,w as Lt,x as ft,y as lt,z as jt,D as mt,F as bt}from"./html-a2da55a6.js";import{o as ct,w as _t,h as kt,p as Xt}from"./position-82cfc837.js";import{m as Yt}from"./merge-15067256.js";import"./Checkbox-abf1420e.js";import"./createForOfIteratorHelper-eb4541b9.js";import"./_createCompounder-ed41a610.js";import"./_createAssigner-77c8874c.js";import"./difference-bddb49bc.js";import"./_createAggregator-c692fd07.js";import"./_baseEach-1e26df34.js";import"./_baseFor-37716d03.js";import"./_baseMap-457e4262.js";import"./isNumber-0bc0d001.js";import"./throttle-35369e52.js";var Ht=globalThis&&globalThis.__decorate||function(n,t,e,i){var o=arguments.length,s=o<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,t,e,i);else for(var a=n.length-1;a>=0;a--)(r=n[a])&&(s=(o<3?r(s):o>3?r(t,e,s):r(t,e))||s);return o>3&&s&&Object.defineProperty(t,e,s),s};class xt extends ${get model(){return this.graph.model}get view(){return this.graph.renderer.findViewByCell(this.node)}get containerClassName(){return this.prefixClassName("widget-transform")}get resizeClassName(){return`${this.containerClassName}-resize`}get rotateClassName(){return`${this.containerClassName}-rotate`}constructor(t,e,i){super(),this.node=e,this.graph=i,this.options=Object.assign(Object.assign({},M.defaultOptions),t),this.render(),this.startListening()}startListening(){this.delegateEvents({[`mousedown .${this.resizeClassName}`]:"startResizing",[`touchstart .${this.resizeClassName}`]:"startResizing",[`mousedown .${this.rotateClassName}`]:"startRotating",[`touchstart .${this.rotateClassName}`]:"startRotating"}),this.model.on("*",this.update,this),this.graph.on("scale",this.update,this),this.graph.on("translate",this.update,this),this.node.on("removed",this.remove,this),this.model.on("reseted",this.remove,this),this.view.on("cell:knob:mousedown",this.onKnobMouseDown,this),this.view.on("cell:knob:mouseup",this.onKnobMouseUp,this)}stopListening(){this.undelegateEvents(),this.model.off("*",this.update,this),this.graph.off("scale",this.update,this),this.graph.off("translate",this.update,this),this.node.off("removed",this.remove,this),this.model.off("reseted",this.remove,this),this.view.off("cell:knob:mousedown",this.onKnobMouseDown,this),this.view.off("cell:knob:mouseup",this.onKnobMouseUp,this)}renderHandles(){this.container=document.createElement("div");const t=document.createElement("div");j(t,"draggable","false");const e=t.cloneNode(!0);R(e,this.rotateClassName);const i=M.POSITIONS.map(o=>{const s=t.cloneNode(!0);return R(s,this.resizeClassName),j(s,"data-position",o),s});this.empty(),pt(this.container,[...i,e])}render(){return this.renderHandles(),this.view&&this.view.addClass(M.NODE_CLS),R(this.container,this.containerClassName),ot(this.container,"no-orth-resize",this.options.preserveAspectRatio||!this.options.orthogonalResizing),ot(this.container,"no-resize",!this.options.resizable),ot(this.container,"no-rotate",!this.options.rotatable),this.options.className&&R(this.container,this.options.className),this.graph.container.appendChild(this.container),this.update()}update(){const t=this.graph.matrix(),e=this.node.getBBox();e.x*=t.a,e.x+=t.e,e.y*=t.d,e.y+=t.f,e.width*=t.a,e.height*=t.d;const i=G.normalize(this.node.getAngle()),o=i!==0?`rotate(${i}deg)`:"";return P(this.container,{transform:o,width:e.width,height:e.height,left:e.x,top:e.y}),this.updateResizerDirections(),this}remove(){return this.view&&this.view.removeClass(M.NODE_CLS),super.remove()}onKnobMouseDown(){this.startHandle()}onKnobMouseUp(){this.stopHandle()}updateResizerDirections(){const t=G.normalize(this.node.getAngle()),e=Math.floor(t*(M.DIRECTIONS.length/360));if(e!==this.prevShift){const i=M.DIRECTIONS.slice(e).concat(M.DIRECTIONS.slice(0,e)),o=r=>`${this.containerClassName}-cursor-${r}`;this.container.querySelectorAll(`.${this.resizeClassName}`).forEach((r,a)=>{_(r,M.DIRECTIONS.map(h=>o(h)).join(" ")),R(r,o(i[a]))}),this.prevShift=e}}getTrueDirection(t){const e=G.normalize(this.node.getAngle());let i=M.POSITIONS.indexOf(t);return i+=Math.floor(e*(M.POSITIONS.length/360)),i%=M.POSITIONS.length,M.POSITIONS[i]}toValidResizeDirection(t){return{top:"top-left",bottom:"bottom-right",left:"bottom-left",right:"top-right"}[t]||t}startResizing(t){t.stopPropagation(),this.model.startBatch("resize",{cid:this.cid});const e=j(t.target,"data-position");this.prepareResizing(t,e),this.startAction(t)}prepareResizing(t,e){const i=this.getTrueDirection(e);let o=0,s=0;e.split("-").forEach(p=>{o={left:-1,right:1}[p]||o,s={top:-1,bottom:1}[p]||s});const r=this.toValidResizeDirection(e),a={"top-right":"bottomLeft","top-left":"bottomRight","bottom-left":"topRight","bottom-right":"topLeft"}[r],h=G.normalize(this.node.getAngle());this.setEventData(t,{selector:a,direction:r,trueDirection:i,relativeDirection:e,angle:h,resizeX:o,resizeY:s,action:"resizing"})}startRotating(t){t.stopPropagation(),this.model.startBatch("rotate",{cid:this.cid});const e=this.node.getBBox().getCenter(),i=this.normalizeEvent(t),o=this.graph.snapToGrid(i.clientX,i.clientY);this.setEventData(t,{center:e,action:"rotating",angle:G.normalize(this.node.getAngle()),start:k.create(o).theta(e)}),this.startAction(t)}onMouseMove(t){const e=this.graph.findViewByCell(this.node);let i=this.getEventData(t);if(i.action){const o=this.normalizeEvent(t);let s=o.clientX,r=o.clientY;const a=this.graph.getPlugin("scroller"),h=this.options.restrictedResizing;if(h===!0||typeof h=="number"){const d=h===!0?0:h,y=a?Math.max(d,8):d,l=this.graph.container.getBoundingClientRect();s=gt(s,l.left+y,l.right-y),r=gt(r,l.top+y,l.bottom-y)}else this.options.autoScrollOnResizing&&a&&a.autoScroll(s,r);const p=this.graph.snapToGrid(s,r),b=this.graph.getGridSize(),m=this.node,g=this.options;if(i.action==="resizing"){i=i,i.resized||(e&&(e.addClass("node-resizing"),this.notify("node:resize",t,e)),i.resized=!0);const d=m.getBBox(),y=k.create(p).rotate(i.angle,d.getCenter()).diff(d[i.selector]);let l=i.resizeX?y.x*i.resizeX:d.width,c=i.resizeY?y.y*i.resizeY:d.height;const C=l,v=c;if(l=rt.snapToGrid(l,b),c=rt.snapToGrid(c,b),l=Math.max(l,g.minWidth||b),c=Math.max(c,g.minHeight||b),l=Math.min(l,g.maxWidth||1/0),c=Math.min(c,g.maxHeight||1/0),g.preserveAspectRatio){const f=d.width*c/d.height,E=d.height*l/d.width;l<f?c=E:l=f}const x=i.relativeDirection;if(g.allowReverse&&(C<=-l||v<=-c)){let f;x==="left"?C<=-l&&(f="right"):x==="right"?C<=-l&&(f="left"):x==="top"?v<=-c&&(f="bottom"):x==="bottom"?v<=-c&&(f="top"):x==="top-left"?C<=-l&&v<=-c?f="bottom-right":C<=-l?f="top-right":v<=-c&&(f="bottom-left"):x==="top-right"?C<=-l&&v<=-c?f="bottom-left":C<=-l?f="top-left":v<=-c&&(f="bottom-right"):x==="bottom-left"?C<=-l&&v<=-c?f="top-right":C<=-l?f="bottom-right":v<=-c&&(f="top-left"):x==="bottom-right"&&(C<=-l&&v<=-c?f="top-left":C<=-l?f="bottom-left":v<=-c&&(f="top-right"));const E=f;this.stopHandle();const T=this.container.querySelector(`.${this.resizeClassName}[data-position="${E}"]`);this.startHandle(T),this.prepareResizing(t,E),this.onMouseMove(t)}if(d.width!==l||d.height!==c){const f={ui:!0,direction:i.direction,relativeDirection:i.relativeDirection,trueDirection:i.trueDirection,minWidth:g.minWidth,minHeight:g.minHeight,maxWidth:g.maxWidth,maxHeight:g.maxHeight,preserveAspectRatio:g.preserveAspectRatio===!0};m.resize(l,c,f),this.notify("node:resizing",t,e)}}else if(i.action==="rotating"){i=i,i.rotated||(e&&(e.addClass("node-rotating"),this.notify("node:rotate",t,e)),i.rotated=!0);const d=m.getAngle(),y=i.start-k.create(p).theta(i.center);let l=i.angle+y;g.rotateGrid&&(l=rt.snapToGrid(l,g.rotateGrid)),l=G.normalize(l),d!==l&&(m.rotate(l,{absolute:!0}),this.notify("node:rotating",t,e))}}}onMouseUp(t){const e=this.getEventData(t);e.action&&(this.stopAction(t),this.model.stopBatch(e.action==="resizing"?"resize":"rotate",{cid:this.cid}))}startHandle(t){if(this.handle=t||null,R(this.container,`${this.containerClassName}-active`),t){R(t,`${this.containerClassName}-active-handle`);const e=t.getAttribute("data-position");if(e){const i=M.DIRECTIONS[M.POSITIONS.indexOf(e)];R(this.container,`${this.containerClassName}-cursor-${i}`)}}}stopHandle(){if(_(this.container,`${this.containerClassName}-active`),this.handle){_(this.handle,`${this.containerClassName}-active-handle`);const t=this.handle.getAttribute("data-position");if(t){const e=M.DIRECTIONS[M.POSITIONS.indexOf(t)];_(this.container,`${this.containerClassName}-cursor-${e}`)}this.handle=null}}startAction(t){this.startHandle(t.target),this.graph.view.undelegateEvents(),this.delegateDocumentEvents(M.documentEvents,t.data)}stopAction(t){this.stopHandle(),this.undelegateDocumentEvents(),this.graph.view.delegateEvents();const e=this.graph.findViewByCell(this.node),i=this.getEventData(t);e&&(e.removeClass(`node-${i.action}`),i.action==="resizing"&&i.resized?this.notify("node:resized",t,e):i.action==="rotating"&&i.rotated&&this.notify("node:rotated",t,e))}notify(t,e,i,o={}){if(i){const s=i.graph,r=s.view.normalizeEvent(e),a=s.snapToGrid(r.clientX,r.clientY);this.trigger(t,Object.assign({e:r,view:i,node:i.cell,cell:i.cell,x:a.x,y:a.y},o))}}dispose(){this.stopListening(),this.remove(),this.off()}}Ht([$.dispose()],xt.prototype,"dispose",null);var M;(function(n){n.NODE_CLS="has-widget-transform",n.DIRECTIONS=["nw","n","ne","e","se","s","sw","w"],n.POSITIONS=["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"],n.documentEvents={mousemove:"onMouseMove",touchmove:"onMouseMove",mouseup:"onMouseUp",touchend:"onMouseUp"},n.defaultOptions={minWidth:0,minHeight:0,maxWidth:1/0,maxHeight:1/0,rotateGrid:15,rotatable:!0,preserveAspectRatio:!1,orthogonalResizing:!0,restrictedResizing:!1,autoScrollOnResizing:!0,allowReverse:!0}})(M||(M={}));const Wt=`.x6-widget-transform {
|
|
position: absolute;
|
|
box-sizing: content-box !important;
|
|
margin: -5px 0 0 -5px;
|
|
padding: 4px;
|
|
border: 1px dashed #000;
|
|
border-radius: 5px;
|
|
user-select: none;
|
|
pointer-events: none;
|
|
}
|
|
.x6-widget-transform > div {
|
|
position: absolute;
|
|
box-sizing: border-box;
|
|
background-color: #fff;
|
|
border: 1px solid #000;
|
|
transition: background-color 0.2s;
|
|
pointer-events: auto;
|
|
-webkit-user-drag: none;
|
|
user-drag: none;
|
|
/* stylelint-disable-line */
|
|
}
|
|
.x6-widget-transform > div:hover {
|
|
background-color: #d3d3d3;
|
|
}
|
|
.x6-widget-transform-cursor-n {
|
|
cursor: n-resize;
|
|
}
|
|
.x6-widget-transform-cursor-s {
|
|
cursor: s-resize;
|
|
}
|
|
.x6-widget-transform-cursor-e {
|
|
cursor: e-resize;
|
|
}
|
|
.x6-widget-transform-cursor-w {
|
|
cursor: w-resize;
|
|
}
|
|
.x6-widget-transform-cursor-ne {
|
|
cursor: ne-resize;
|
|
}
|
|
.x6-widget-transform-cursor-nw {
|
|
cursor: nw-resize;
|
|
}
|
|
.x6-widget-transform-cursor-se {
|
|
cursor: se-resize;
|
|
}
|
|
.x6-widget-transform-cursor-sw {
|
|
cursor: sw-resize;
|
|
}
|
|
.x6-widget-transform-resize {
|
|
width: 10px;
|
|
height: 10px;
|
|
border-radius: 6px;
|
|
}
|
|
.x6-widget-transform-resize[data-position='top-left'] {
|
|
top: -5px;
|
|
left: -5px;
|
|
}
|
|
.x6-widget-transform-resize[data-position='top-right'] {
|
|
top: -5px;
|
|
right: -5px;
|
|
}
|
|
.x6-widget-transform-resize[data-position='bottom-left'] {
|
|
bottom: -5px;
|
|
left: -5px;
|
|
}
|
|
.x6-widget-transform-resize[data-position='bottom-right'] {
|
|
right: -5px;
|
|
bottom: -5px;
|
|
}
|
|
.x6-widget-transform-resize[data-position='top'] {
|
|
top: -5px;
|
|
left: 50%;
|
|
margin-left: -5px;
|
|
}
|
|
.x6-widget-transform-resize[data-position='bottom'] {
|
|
bottom: -5px;
|
|
left: 50%;
|
|
margin-left: -5px;
|
|
}
|
|
.x6-widget-transform-resize[data-position='left'] {
|
|
top: 50%;
|
|
left: -5px;
|
|
margin-top: -5px;
|
|
}
|
|
.x6-widget-transform-resize[data-position='right'] {
|
|
top: 50%;
|
|
right: -5px;
|
|
margin-top: -5px;
|
|
}
|
|
.x6-widget-transform.prevent-aspect-ratio .x6-widget-transform-resize[data-position='top'],
|
|
.x6-widget-transform.prevent-aspect-ratio .x6-widget-transform-resize[data-position='bottom'],
|
|
.x6-widget-transform.prevent-aspect-ratio .x6-widget-transform-resize[data-position='left'],
|
|
.x6-widget-transform.prevent-aspect-ratio .x6-widget-transform-resize[data-position='right'] {
|
|
display: none;
|
|
}
|
|
.x6-widget-transform.no-orth-resize .x6-widget-transform-resize[data-position='bottom'],
|
|
.x6-widget-transform.no-orth-resize .x6-widget-transform-resize[data-position='left'],
|
|
.x6-widget-transform.no-orth-resize .x6-widget-transform-resize[data-position='right'],
|
|
.x6-widget-transform.no-orth-resize .x6-widget-transform-resize[data-position='top'] {
|
|
display: none;
|
|
}
|
|
.x6-widget-transform.no-resize .x6-widget-transform-resize {
|
|
display: none;
|
|
}
|
|
.x6-widget-transform-rotate {
|
|
top: -20px;
|
|
left: -20px;
|
|
width: 12px;
|
|
height: 12px;
|
|
border-radius: 6px;
|
|
cursor: crosshair;
|
|
}
|
|
.x6-widget-transform.no-rotate .x6-widget-transform-rotate {
|
|
display: none;
|
|
}
|
|
.x6-widget-transform-active {
|
|
border-color: transparent;
|
|
pointer-events: all;
|
|
}
|
|
.x6-widget-transform-active > div {
|
|
display: none;
|
|
}
|
|
.x6-widget-transform-active > .x6-widget-transform-active-handle {
|
|
display: block;
|
|
background-color: #808080;
|
|
}
|
|
`;u.prototype.createTransformWidget=function(n){const t=this.getPlugin("transform");return t&&t.createWidget(n),this};u.prototype.clearTransformWidgets=function(){const n=this.getPlugin("transform");return n&&n.clearWidgets(),this};var Ut=globalThis&&globalThis.__decorate||function(n,t,e,i){var o=arguments.length,s=o<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,t,e,i);else for(var a=n.length-1;a>=0;a--)(r=n[a])&&(s=(o<3?r(s):o>3?r(t,e,s):r(t,e))||s);return o>3&&s&&Object.defineProperty(t,e,s),s};class X extends tt{constructor(t={}){super(),this.name="transform",this.widgets=new Map,this.disabled=!1,this.options=t,et(this.name,Wt)}init(t){this.graph=t,!this.disabled&&this.startListening()}startListening(){this.graph.on("node:click",this.onNodeClick,this),this.graph.on("blank:mousedown",this.onBlankMouseDown,this)}stopListening(){this.graph.off("node:click",this.onNodeClick,this),this.graph.off("blank:mousedown",this.onBlankMouseDown,this)}enable(){this.disabled&&(this.disabled=!1,this.startListening())}disable(){this.disabled||(this.disabled=!0,this.stopListening())}isEnabled(){return!this.disabled}createWidget(t){this.clearWidgets();const e=this.createTransform(t);e&&(this.widgets.set(t,e),e.on("*",(i,o)=>{this.trigger(i,o),this.graph.trigger(i,o)}))}onNodeClick({node:t}){this.createWidget(t)}onBlankMouseDown(){this.clearWidgets()}createTransform(t){const e=this.getTransformOptions(t);return e.resizable||e.rotatable?new xt(e,t,this.graph):null}getTransformOptions(t){this.options.resizing||(this.options.resizing={enabled:!1}),this.options.rotating||(this.options.rotating={enabled:!1}),typeof this.options.resizing=="boolean"&&(this.options.resizing={enabled:this.options.resizing}),typeof this.options.rotating=="boolean"&&(this.options.rotating={enabled:this.options.rotating});const e=X.parseOptionGroup(this.graph,t,this.options.resizing),i=X.parseOptionGroup(this.graph,t,this.options.rotating);return{resizable:!!e.enabled,minWidth:e.minWidth||0,maxWidth:e.maxWidth||Number.MAX_SAFE_INTEGER,minHeight:e.minHeight||0,maxHeight:e.maxHeight||Number.MAX_SAFE_INTEGER,orthogonalResizing:typeof e.orthogonal=="boolean"?e.orthogonal:!0,restrictedResizing:!!e.restrict,autoScrollOnResizing:typeof e.autoScroll=="boolean"?e.autoScroll:!0,preserveAspectRatio:!!e.preserveAspectRatio,allowReverse:typeof e.allowReverse=="boolean"?e.allowReverse:!0,rotatable:!!i.enabled,rotateGrid:i.grid||15}}clearWidgets(){this.widgets.forEach((t,e)=>{this.graph.getCellById(e.id)&&t.dispose()}),this.widgets.clear()}dispose(){this.clearWidgets(),this.stopListening(),this.off(),it(this.name)}}Ut([tt.dispose()],X.prototype,"dispose",null);(function(n){function t(e,i,o){const s={};return Object.keys(o||{}).forEach(r=>{const a=o[r];s[r]=typeof a=="function"?a.call(e,i):a}),s}n.parseOptionGroup=t})(X||(X={}));var Vt=globalThis&&globalThis.__decorate||function(n,t,e,i){var o=arguments.length,s=o<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,t,e,i);else for(var a=n.length-1;a>=0;a--)(r=n[a])&&(s=(o<3?r(s):o>3?r(t,e,s):r(t,e))||s);return o>3&&s&&Object.defineProperty(t,e,s),s};class yt extends ${get graph(){return this.options.graph}get boxClassName(){return this.prefixClassName(D.classNames.box)}get $boxes(){return Ft(this.container,this.boxClassName)}get handleOptions(){return this.options}constructor(t){super(),this.options=t,this.options.model&&(this.options.collection=this.options.model.collection),this.options.collection?this.collection=this.options.collection:(this.collection=new It([],{comparator:D.depthComparator}),this.options.collection=this.collection),this.boxCount=0,this.createContainer(),this.startListening()}startListening(){const t=this.graph,e=this.collection;this.delegateEvents({[`mousedown .${this.boxClassName}`]:"onSelectionBoxMouseDown",[`touchstart .${this.boxClassName}`]:"onSelectionBoxMouseDown"},!0),t.on("scale",this.onGraphTransformed,this),t.on("translate",this.onGraphTransformed,this),t.model.on("updated",this.onModelUpdated,this),e.on("added",this.onCellAdded,this),e.on("removed",this.onCellRemoved,this),e.on("reseted",this.onReseted,this),e.on("updated",this.onCollectionUpdated,this),e.on("node:change:position",this.onNodePositionChanged,this),e.on("cell:changed",this.onCellChanged,this)}stopListening(){const t=this.graph,e=this.collection;this.undelegateEvents(),t.off("scale",this.onGraphTransformed,this),t.off("translate",this.onGraphTransformed,this),t.model.off("updated",this.onModelUpdated,this),e.off("added",this.onCellAdded,this),e.off("removed",this.onCellRemoved,this),e.off("reseted",this.onReseted,this),e.off("updated",this.onCollectionUpdated,this),e.off("node:change:position",this.onNodePositionChanged,this),e.off("cell:changed",this.onCellChanged,this)}onRemove(){this.stopListening()}onGraphTransformed(){this.updateSelectionBoxes()}onCellChanged(){this.updateSelectionBoxes()}onNodePositionChanged({node:t,options:e}){const{showNodeSelectionBox:i,pointerEvents:o}=this.options,{ui:s,selection:r,translateBy:a,snapped:h}=e,p=(i!==!0||o==="none")&&!this.translating&&!r,b=s&&a&&t.id===a;if(p&&(b||h)){this.translating=!0;const m=t.position(),g=t.previous("position"),d=m.x-g.x,y=m.y-g.y;(d!==0||y!==0)&&this.translateSelectedNodes(d,y,t,e),this.translating=!1}}onModelUpdated({removed:t}){t&&t.length&&this.unselect(t)}isEmpty(){return this.length<=0}isSelected(t){return this.collection.has(t)}get length(){return this.collection.length}get cells(){return this.collection.toArray()}select(t,e={}){e.dryrun=!0;const i=this.filter(Array.isArray(t)?t:[t]);return this.collection.add(i,e),this}unselect(t,e={}){return e.dryrun=!0,this.collection.remove(Array.isArray(t)?t:[t],e),this}reset(t,e={}){if(t){if(e.batch){const p=this.filter(Array.isArray(t)?t:[t]);return this.collection.reset(p,Object.assign(Object.assign({},e),{ui:!0})),this}const i=this.cells,o=this.filter(Array.isArray(t)?t:[t]),s={},r={};i.forEach(p=>s[p.id]=p),o.forEach(p=>r[p.id]=p);const a=[],h=[];return o.forEach(p=>{s[p.id]||a.push(p)}),i.forEach(p=>{r[p.id]||h.push(p)}),h.length&&this.unselect(h,Object.assign(Object.assign({},e),{ui:!0})),a.length&&this.select(a,Object.assign(Object.assign({},e),{ui:!0})),h.length===0&&a.length===0&&this.updateContainer(),this}return this.clean(e)}clean(t={}){return this.length&&(t.batch===!1?this.unselect(this.cells,t):this.collection.reset([],Object.assign(Object.assign({},t),{ui:!0}))),this}setFilter(t){this.options.filter=t}setContent(t){this.options.content=t}startSelecting(t){t=this.normalizeEvent(t),this.clean();let e,i;const o=this.graph.container;if(t.offsetX!=null&&t.offsetY!=null&&o.contains(t.target))e=t.offsetX,i=t.offsetY;else{const s=ct(o),r=o.scrollLeft,a=o.scrollTop;e=t.clientX-s.left+window.pageXOffset+r,i=t.clientY-s.top+window.pageYOffset+a}P(this.container,{top:i,left:e,width:1,height:1}),this.setEventData(t,{action:"selecting",clientX:t.clientX,clientY:t.clientY,offsetX:e,offsetY:i,scrollerX:0,scrollerY:0,moving:!1}),this.delegateDocumentEvents(D.documentEvents,t.data)}filter(t){const e=this.options.filter;return t.filter(i=>Array.isArray(e)?e.some(o=>typeof o=="string"?i.shape===o:i.id===o.id):typeof e=="function"?U(e,this.graph,i):!0)}stopSelecting(t){const e=this.graph,i=this.getEventData(t);switch(i.action){case"selecting":{let s=_t(this.container),r=kt(this.container);const a=ct(this.container),h=e.pageToLocal(a.left,a.top),p=e.transform.getScale();s/=p.sx,r/=p.sy;const b=new ht(h.x,h.y,s,r),m=this.getCellViewsInArea(b).map(g=>g.cell);this.reset(m,{batch:!0}),this.hideRubberband();break}case"translating":{const s=e.snapToGrid(t.clientX,t.clientY);if(!this.options.following){const r=i;this.updateSelectedNodesPosition({dx:r.clientX-r.originX,dy:r.clientY-r.originY})}this.graph.model.stopBatch("move-selection"),this.notifyBoxEvent("box:mouseup",t,s.x,s.y);break}default:{this.clean();break}}}onMouseUp(t){this.getEventData(t).action&&(this.stopSelecting(t),this.undelegateDocumentEvents())}onSelectionBoxMouseDown(t){this.options.following||t.stopPropagation();const e=this.normalizeEvent(t);this.options.movable&&this.startTranslating(e);const i=this.getCellViewFromElem(e.target);this.setEventData(e,{activeView:i});const o=this.graph.snapToGrid(e.clientX,e.clientY);this.notifyBoxEvent("box:mousedown",e,o.x,o.y),this.delegateDocumentEvents(D.documentEvents,e.data)}startTranslating(t){this.graph.model.startBatch("move-selection");const e=this.graph.snapToGrid(t.clientX,t.clientY);this.setEventData(t,{action:"translating",clientX:e.x,clientY:e.y,originX:e.x,originY:e.y})}getRestrictArea(){const t=this.graph.options.translating.restrict,e=typeof t=="function"?U(t,this.graph,null):t;return typeof e=="number"?this.graph.transform.getGraphArea().inflate(e):e===!0?this.graph.transform.getGraphArea():e||null}getSelectionOffset(t,e){let i=t.x-e.clientX,o=t.y-e.clientY;const s=this.getRestrictArea();if(s){const r=this.collection.toArray(),a=Gt.getCellsBBox(r,{deep:!0})||ht.create(),h=s.x-a.x,p=s.y-a.y,b=s.x+s.width-(a.x+a.width),m=s.y+s.height-(a.y+a.height);if(i<h&&(i=h),o<p&&(o=p),b<i&&(i=b),m<o&&(o=m),!this.options.following){const g=t.x-e.originX,d=t.y-e.originY;i=g<=h||g>=b?0:i,o=d<=p||d>=m?0:o}}return{dx:i,dy:o}}updateElementPosition(t,e,i){const o=P(t,"left"),s=P(t,"top"),r=o?parseFloat(o):0,a=s?parseFloat(s):0;P(t,"left",r+e),P(t,"top",a+i)}updateSelectedNodesPosition(t){const{dx:e,dy:i}=t;if(e||i)if(this.translateSelectedNodes(e,i),this.boxesUpdated)this.collection.length>1&&this.updateSelectionBoxes();else{const o=this.graph.transform.getScale();for(let s=0,r=this.$boxes,a=r.length;s<a;s+=1)this.updateElementPosition(r[s],e*o.sx,i*o.sy);this.updateElementPosition(this.selectionContainer,e*o.sx,i*o.sy)}}autoScrollGraph(t,e){const i=this.graph.getPlugin("scroller");return i?i.autoScroll(t,e):{scrollerX:0,scrollerY:0}}adjustSelection(t){const e=this.normalizeEvent(t),i=this.getEventData(e);switch(i.action){case"selecting":{const s=i;s.moving!==!0&&(J(this.container,this.graph.container),this.showRubberband(),s.moving=!0);const{scrollerX:r,scrollerY:a}=this.autoScrollGraph(e.clientX,e.clientY);s.scrollerX+=r,s.scrollerY+=a;const h=e.clientX-s.clientX+s.scrollerX,p=e.clientY-s.clientY+s.scrollerY,b=parseInt(P(this.container,"left")||"0",10),m=parseInt(P(this.container,"top")||"0",10);P(this.container,{left:h<0?s.offsetX+h:b,top:p<0?s.offsetY+p:m,width:Math.abs(h),height:Math.abs(p)});break}case"translating":{const s=this.graph.snapToGrid(e.clientX,e.clientY),r=i,a=this.getSelectionOffset(s,r);this.options.following?this.updateSelectedNodesPosition(a):this.updateContainerPosition(a),a.dx&&(r.clientX=s.x),a.dy&&(r.clientY=s.y),this.notifyBoxEvent("box:mousemove",t,s.x,s.y);break}}this.boxesUpdated=!1}translateSelectedNodes(t,e,i,o){const s={},r=[];if(i&&(s[i.id]=!0),this.collection.toArray().forEach(a=>{a.getDescendants({deep:!0}).forEach(h=>{s[h.id]=!0})}),o&&o.translateBy){const a=this.graph.getCellById(o.translateBy);a&&(s[a.id]=!0,a.getDescendants({deep:!0}).forEach(h=>{s[h.id]=!0}),r.push(a))}this.collection.toArray().forEach(a=>{if(!s[a.id]){const h=Object.assign(Object.assign({},o),{selection:this.cid,exclude:r});a.translate(t,e,h),this.graph.model.getConnectedEdges(a).forEach(p=>{s[p.id]||(p.translate(t,e,h),s[p.id]=!0)})}})}getCellViewsInArea(t){const e=this.graph,i={strict:this.options.strict};let o=[];return this.options.rubberNode&&(o=o.concat(e.model.getNodesInArea(t,i).map(s=>e.renderer.findViewByCell(s)).filter(s=>s!=null))),this.options.rubberEdge&&(o=o.concat(e.model.getEdgesInArea(t,i).map(s=>e.renderer.findViewByCell(s)).filter(s=>s!=null))),o}notifyBoxEvent(t,e,i,o){const r=this.getEventData(e).activeView;this.trigger(t,{e,view:r,x:i,y:o,cell:r.cell})}getSelectedClassName(t){return this.prefixClassName(`${t.isNode()?"node":"edge"}-selected`)}addCellSelectedClassName(t){const e=this.graph.renderer.findViewByCell(t);e&&e.addClass(this.getSelectedClassName(t))}removeCellUnSelectedClassName(t){const e=this.graph.renderer.findViewByCell(t);e&&e.removeClass(this.getSelectedClassName(t))}destroySelectionBox(t){this.removeCellUnSelectedClassName(t),this.canShowSelectionBox(t)&&(at(this.container.querySelector(`[data-cell-id="${t.id}"]`)),this.$boxes.length===0&&this.hide(),this.boxCount=Math.max(0,this.boxCount-1))}destroyAllSelectionBoxes(t){t.forEach(e=>this.removeCellUnSelectedClassName(e)),this.hide(),at(this.$boxes),this.boxCount=0}hide(){_(this.container,this.prefixClassName(D.classNames.rubberband)),_(this.container,this.prefixClassName(D.classNames.selected))}showRubberband(){R(this.container,this.prefixClassName(D.classNames.rubberband))}hideRubberband(){_(this.container,this.prefixClassName(D.classNames.rubberband))}showSelected(){$t(this.container,"style"),R(this.container,this.prefixClassName(D.classNames.selected))}createContainer(){this.container=document.createElement("div"),R(this.container,this.prefixClassName(D.classNames.root)),this.options.className&&R(this.container,this.options.className),this.selectionContainer=document.createElement("div"),R(this.selectionContainer,this.prefixClassName(D.classNames.inner)),this.selectionContent=document.createElement("div"),R(this.selectionContent,this.prefixClassName(D.classNames.content)),pt(this.selectionContainer,this.selectionContent),j(this.selectionContainer,"data-selection-length",this.collection.length),Lt(this.container,this.selectionContainer)}updateContainerPosition(t){(t.dx||t.dy)&&this.updateElementPosition(this.selectionContainer,t.dx,t.dy)}updateContainer(){const t={x:1/0,y:1/0},e={x:0,y:0};this.collection.toArray().filter(s=>this.canShowSelectionBox(s)).forEach(s=>{const r=this.graph.renderer.findViewByCell(s);if(r){const a=r.getBBox({useCellGeometry:!0});t.x=Math.min(t.x,a.x),t.y=Math.min(t.y,a.y),e.x=Math.max(e.x,a.x+a.width),e.y=Math.max(e.y,a.y+a.height)}}),P(this.selectionContainer,{position:"absolute",pointerEvents:"none",left:t.x,top:t.y,width:e.x-t.x,height:e.y-t.y}),j(this.selectionContainer,"data-selection-length",this.collection.length);const o=this.options.content;if(o)if(typeof o=="function"){const s=U(o,this.graph,this,this.selectionContent);s&&(this.selectionContent.innerHTML=s)}else this.selectionContent.innerHTML=o;this.collection.length>0&&!this.container.parentNode?J(this.container,this.graph.container):this.collection.length<=0&&this.container.parentNode&&this.container.parentNode.removeChild(this.container)}canShowSelectionBox(t){return t.isNode()&&this.options.showNodeSelectionBox===!0||t.isEdge()&&this.options.showEdgeSelectionBox===!0}createSelectionBox(t){if(this.addCellSelectedClassName(t),this.canShowSelectionBox(t)){const e=this.graph.renderer.findViewByCell(t);if(e){const i=e.getBBox({useCellGeometry:!0}),o=this.boxClassName,s=document.createElement("div");R(s,o),R(s,`${o}-${t.isNode()?"node":"edge"}`),j(s,"data-cell-id",t.id),P(s,{position:"absolute",left:i.x,top:i.y,width:i.width,height:i.height,pointerEvents:this.options.pointerEvents||"auto"}),J(s,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 t=0,e=this.$boxes,i=e.length;t<i;t+=1){const o=e[t],s=j(o,"data-cell-id");at(o),this.boxCount-=1;const r=this.collection.get(s);r&&this.createSelectionBox(r)}this.updateContainer()}return 0}getCellViewFromElem(t){const e=t.getAttribute("data-cell-id");if(e){const i=this.collection.get(e);if(i)return this.graph.renderer.findViewByCell(i)}return null}onCellRemoved({cell:t}){this.destroySelectionBox(t),this.updateContainer()}onReseted({previous:t,current:e}){this.destroyAllSelectionBoxes(t),e.forEach(i=>{this.listenCellRemoveEvent(i),this.createSelectionBox(i)}),this.updateContainer()}onCellAdded({cell:t}){this.listenCellRemoveEvent(t),this.createSelectionBox(t),this.updateContainer()}listenCellRemoveEvent(t){t.off("removed",this.onCellRemoved,this),t.on("removed",this.onCellRemoved,this)}onCollectionUpdated({added:t,removed:e,options:i}){t.forEach(s=>{this.trigger("cell:selected",{cell:s,options:i}),s.isNode()?this.trigger("node:selected",{cell:s,options:i,node:s}):s.isEdge()&&this.trigger("edge:selected",{cell:s,options:i,edge:s})}),e.forEach(s=>{this.trigger("cell:unselected",{cell:s,options:i}),s.isNode()?this.trigger("node:unselected",{cell:s,options:i,node:s}):s.isEdge()&&this.trigger("edge:unselected",{cell:s,options:i,edge:s})});const o={added:t,removed:e,options:i,selected:this.cells.filter(s=>!!this.graph.getCellById(s.id))};this.trigger("selection:changed",o)}dispose(){this.clean(),this.remove(),this.off()}}Vt([$.dispose()],yt.prototype,"dispose",null);var D;(function(n){const t="widget-selection";n.classNames={root:t,inner:`${t}-inner`,box:`${t}-box`,content:`${t}-content`,rubberband:`${t}-rubberband`,selected:`${t}-selected`},n.documentEvents={mousemove:"adjustSelection",touchmove:"adjustSelection",mouseup:"onMouseUp",touchend:"onMouseUp",touchcancel:"onMouseUp"};function e(i){return i.getAncestors().length}n.depthComparator=e})(D||(D={}));const qt=`.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;
|
|
}
|
|
`;u.prototype.isSelectionEnabled=function(){const n=this.getPlugin("selection");return n?n.isEnabled():!1};u.prototype.enableSelection=function(){const n=this.getPlugin("selection");return n&&n.enable(),this};u.prototype.disableSelection=function(){const n=this.getPlugin("selection");return n&&n.disable(),this};u.prototype.toggleSelection=function(n){const t=this.getPlugin("selection");return t&&t.toggleEnabled(n),this};u.prototype.isMultipleSelection=function(){const n=this.getPlugin("selection");return n?n.isMultipleSelection():!1};u.prototype.enableMultipleSelection=function(){const n=this.getPlugin("selection");return n&&n.enableMultipleSelection(),this};u.prototype.disableMultipleSelection=function(){const n=this.getPlugin("selection");return n&&n.disableMultipleSelection(),this};u.prototype.toggleMultipleSelection=function(n){const t=this.getPlugin("selection");return t&&t.toggleMultipleSelection(n),this};u.prototype.isSelectionMovable=function(){const n=this.getPlugin("selection");return n?n.isSelectionMovable():!1};u.prototype.enableSelectionMovable=function(){const n=this.getPlugin("selection");return n&&n.enableSelectionMovable(),this};u.prototype.disableSelectionMovable=function(){const n=this.getPlugin("selection");return n&&n.disableSelectionMovable(),this};u.prototype.toggleSelectionMovable=function(n){const t=this.getPlugin("selection");return t&&t.toggleSelectionMovable(n),this};u.prototype.isRubberbandEnabled=function(){const n=this.getPlugin("selection");return n?n.isRubberbandEnabled():!1};u.prototype.enableRubberband=function(){const n=this.getPlugin("selection");return n&&n.enableRubberband(),this};u.prototype.disableRubberband=function(){const n=this.getPlugin("selection");return n&&n.disableRubberband(),this};u.prototype.toggleRubberband=function(n){const t=this.getPlugin("selection");return t&&t.toggleRubberband(n),this};u.prototype.isStrictRubberband=function(){const n=this.getPlugin("selection");return n?n.isStrictRubberband():!1};u.prototype.enableStrictRubberband=function(){const n=this.getPlugin("selection");return n&&n.enableStrictRubberband(),this};u.prototype.disableStrictRubberband=function(){const n=this.getPlugin("selection");return n&&n.disableStrictRubberband(),this};u.prototype.toggleStrictRubberband=function(n){const t=this.getPlugin("selection");return t&&t.toggleStrictRubberband(n),this};u.prototype.setRubberbandModifiers=function(n){const t=this.getPlugin("selection");return t&&t.setRubberbandModifiers(n),this};u.prototype.setSelectionFilter=function(n){const t=this.getPlugin("selection");return t&&t.setSelectionFilter(n),this};u.prototype.setSelectionDisplayContent=function(n){const t=this.getPlugin("selection");return t&&t.setSelectionDisplayContent(n),this};u.prototype.isSelectionEmpty=function(){const n=this.getPlugin("selection");return n?n.isEmpty():!0};u.prototype.cleanSelection=function(n){const t=this.getPlugin("selection");return t&&t.clean(n),this};u.prototype.resetSelection=function(n,t){const e=this.getPlugin("selection");return e&&e.reset(n,t),this};u.prototype.getSelectedCells=function(){const n=this.getPlugin("selection");return n?n.getSelectedCells():[]};u.prototype.getSelectedCellCount=function(){const n=this.getPlugin("selection");return n?n.getSelectedCellCount():0};u.prototype.isSelected=function(n){const t=this.getPlugin("selection");return t?t.isSelected(n):!1};u.prototype.select=function(n,t){const e=this.getPlugin("selection");return e&&e.select(n,t),this};u.prototype.unselect=function(n,t){const e=this.getPlugin("selection");return e?e.unselect(n,t):this};var Kt=globalThis&&globalThis.__decorate||function(n,t,e,i){var o=arguments.length,s=o<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,t,e,i);else for(var a=n.length-1;a>=0;a--)(r=n[a])&&(s=(o<3?r(s):o>3?r(t,e,s):r(t,e))||s);return o>3&&s&&Object.defineProperty(t,e,s),s};class H extends tt{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(t={}){super(),this.name="selection",this.movedMap=new WeakMap,this.unselectMap=new WeakMap,this.options=Yt({enabled:!0},H.defaultOptions,t),et(this.name,qt)}init(t){this.graph=t,this.selectionImpl=new yt(Object.assign(Object.assign({},this.options),{graph:t})),this.setup(),this.startListening()}isEnabled(){return!this.disabled}enable(){this.disabled&&(this.options.enabled=!0)}disable(){this.disabled||(this.options.enabled=!1)}toggleEnabled(t){return t!=null?t!==this.isEnabled()&&(t?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(t){return t!=null?t!==this.isMultipleSelection()&&(t?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(t){return t!=null?t!==this.isSelectionMovable()&&(t?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(t){return t!=null?t!==this.isRubberbandEnabled()&&(t?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(t){return t!=null?t!==this.isStrictRubberband()&&(t?this.enableStrictRubberband():this.disableStrictRubberband()):this.isStrictRubberband()?this.disableStrictRubberband():this.enableStrictRubberband(),this}setRubberbandModifiers(t){this.setModifiers(t)}setSelectionFilter(t){return this.setFilter(t),this}setSelectionDisplayContent(t){return this.setContent(t),this}isEmpty(){return this.length<=0}clean(t={}){return this.selectionImpl.clean(t),this}reset(t,e={}){return this.selectionImpl.reset(t?this.getCells(t):[],e),this}getSelectedCells(){return this.cells}getSelectedCellCount(){return this.length}isSelected(t){return this.selectionImpl.isSelected(t)}select(t,e={}){const i=this.getCells(t);return i.length&&(this.isMultiple()?this.selectionImpl.select(i,e):this.reset(i.slice(0,1),e)),this}unselect(t,e={}){return this.selectionImpl.unselect(this.getCells(t),e),this}setup(){this.selectionImpl.on("*",(t,e)=>{this.trigger(t,e),this.graph.trigger(t,e)})}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:t}){const e=this.graph.panning.allowPanning(t,!0),i=this.graph.getPlugin("scroller"),o=i&&i.allowPanning(t,!0);(this.allowRubberband(t,!0)||this.allowRubberband(t)&&!o&&!e)&&this.startRubberband(t)}onBlankClick(){this.clean()}allowRubberband(t,e){return!this.rubberbandDisabled&&ft.isMatch(t,this.options.modifiers,e)}allowMultipleSelection(t){return this.isMultiple()&&ft.isMatch(t,this.options.multipleSelectionModifiers)}onCellMouseMove({cell:t}){this.movedMap.set(t,!0)}onCellMouseUp({e:t,cell:e}){const i=this.options;let o=this.disabled;!o&&this.movedMap.has(e)&&(o=i.selectCellOnMoved===!1,o||(o=i.selectNodeOnMoved===!1&&e.isNode()),o||(o=i.selectEdgeOnMoved===!1&&e.isEdge())),o||(this.allowMultipleSelection(t)?this.unselectMap.has(e)?this.unselectMap.delete(e):this.isSelected(e)?this.unselect(e):this.select(e):this.reset(e)),this.movedMap.delete(e)}onBoxMouseDown({e:t,cell:e}){this.disabled||this.allowMultipleSelection(t)&&(this.unselect(e),this.unselectMap.set(e,!0))}getCells(t){return(Array.isArray(t)?t:[t]).map(e=>typeof e=="string"?this.graph.getCellById(e):e).filter(e=>e!=null)}startRubberband(t){return this.rubberbandDisabled||this.selectionImpl.startSelecting(t),this}isMultiple(){return this.options.multiple!==!1}enableMultiple(){return this.options.multiple=!0,this}disableMultiple(){return this.options.multiple=!1,this}setModifiers(t){return this.options.modifiers=t,this}setContent(t){return this.selectionImpl.setContent(t),this}setFilter(t){return this.selectionImpl.setFilter(t),this}dispose(){this.stopListening(),this.off(),this.selectionImpl.dispose(),it(this.name)}}Kt([tt.dispose()],H.prototype,"dispose",null);(function(n){n.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}})(H||(H={}));var Zt=globalThis&&globalThis.__decorate||function(n,t,e,i){var o=arguments.length,s=o<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,t,e,i);else for(var a=n.length-1;a>=0;a--)(r=n[a])&&(s=(o<3?r(s):o>3?r(t,e,s):r(t,e))||s);return o>3&&s&&Object.defineProperty(t,e,s),s},Jt=globalThis&&globalThis.__rest||function(n,t){var e={};for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&t.indexOf(i)<0&&(e[i]=n[i]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,i=Object.getOwnPropertySymbols(n);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(n,i[o])&&(e[i[o]]=n[i[o]]);return e};class vt extends ${get model(){return this.graph.model}get containerClassName(){return this.prefixClassName("widget-snapline")}get verticalClassName(){return`${this.containerClassName}-vertical`}get horizontalClassName(){return`${this.containerClassName}-horizontal`}constructor(t){super();const{graph:e}=t,i=Jt(t,["graph"]);this.graph=e,this.options=Object.assign({},i),this.offset={x:0,y:0},this.render(),this.disabled||this.startListening()}get disabled(){return this.options.enabled!==!0}enable(){this.disabled&&(this.options.enabled=!0,this.startListening())}disable(){this.disabled||(this.options.enabled=!1,this.stopListening())}setFilter(t){this.options.filter=t}render(){const t=this.containerWrapper=new lt("svg"),e=this.horizontal=new lt("line"),i=this.vertical=new lt("line");t.addClass(this.containerClassName),e.addClass(this.horizontalClassName),i.addClass(this.verticalClassName),t.setAttribute("width","100%"),t.setAttribute("height","100%"),e.setAttribute("display","none"),i.setAttribute("display","none"),t.append([e,i]),this.options.className&&t.addClass(this.options.className),this.container=this.containerWrapper.node}startListening(){this.stopListening(),this.graph.on("node:mousedown",this.captureCursorOffset,this),this.graph.on("node:mousemove",this.snapOnMoving,this),this.model.on("batch:stop",this.onBatchStop,this),this.delegateDocumentEvents({mouseup:"hide",touchend:"hide"})}stopListening(){this.graph.off("node:mousedown",this.captureCursorOffset,this),this.graph.off("node:mousemove",this.snapOnMoving,this),this.model.off("batch:stop",this.onBatchStop,this),this.undelegateDocumentEvents()}onBatchStop({name:t,data:e}){t==="resize"&&this.snapOnResizing(e.cell,e)}captureCursorOffset({view:t,x:e,y:i}){const o=t.getDelegatedView();if(o&&this.isNodeMovable(o)){const s=t.cell.getPosition();this.offset={x:e-s.x,y:i-s.y}}}isNodeMovable(t){return t&&t.cell.isNode()&&t.can("nodeMovable")}getRestrictArea(t){const e=this.graph.options.translating.restrict,i=typeof e=="function"?U(e,this.graph,t):e;return typeof i=="number"?this.graph.transform.getGraphArea().inflate(i):i===!0?this.graph.transform.getGraphArea():i||null}snapOnResizing(t,e){if(this.options.resizing&&!e.snapped&&e.ui&&e.direction&&e.trueDirection){const i=this.graph.renderer.findViewByCell(t);if(i&&i.cell.isNode()){const o=t.getBBox(),s=o.bbox(t.getAngle()),r=s.getTopLeft(),a=s.getBottomRight(),h=G.normalize(t.getAngle()),p=this.options.tolerance||0;let b,m,g,d,y,l;const c={vertical:0,horizontal:0},C=e.direction,v=e.trueDirection,x=e.relativeDirection;v.indexOf("right")!==-1?c.vertical=a.x:c.vertical=r.x,v.indexOf("bottom")!==-1?c.horizontal=a.y:c.horizontal=r.y,this.model.getNodes().some(S=>{if(this.isIgnored(t,S))return!1;const A=S.getBBox().bbox(S.getAngle()),L=A.getTopLeft(),q=A.getBottomRight(),ut={vertical:[L.x,q.x],horizontal:[L.y,q.y]},W={};return Object.keys(ut).forEach(St=>{const st=St,Et=ut[st].map(Y=>({position:Y,distance:Math.abs(Y-c[st])})).filter(Y=>Y.distance<=p);W[st]=jt(Et,Y=>Y.distance)}),b==null&&W.vertical.length>0&&(b=W.vertical[0].position,m=Math.min(s.y,A.y),g=Math.max(a.y,q.y)-m),d==null&&W.horizontal.length>0&&(d=W.horizontal[0].position,y=Math.min(s.x,A.x),l=Math.max(a.x,q.x)-y),b!=null&&d!=null}),this.hide();let f=0,E=0;(d!=null||b!=null)&&(b!=null&&(f=v.indexOf("right")!==-1?b-a.x:r.x-b),d!=null&&(E=v.indexOf("bottom")!==-1?d-a.y:r.y-d));let T=0,F=0;if(h%90===0)h===90||h===270?(T=E,F=f):(T=f,F=E);else{const S=h>=0&&h<90?1:h>=90&&h<180?4:h>=180&&h<270?3:2;d!=null&&b!=null&&(f<E?(E=0,d=void 0):(f=0,b=void 0));const A=G.toRad(h%90);f&&(T=S===3?f/Math.cos(A):f/Math.sin(A)),E&&(F=S===3?E/Math.cos(A):E/Math.sin(A));const L=S===1||S===3;switch(x){case"top":case"bottom":F=E?E/(L?Math.cos(A):Math.sin(A)):f/(L?Math.sin(A):Math.cos(A));break;case"left":case"right":T=f?f/(L?Math.cos(A):Math.sin(A)):E/(L?Math.sin(A):Math.cos(A));break}}switch(x){case"top":case"bottom":T=0;break;case"left":case"right":F=0;break}const I=this.graph.getGridSize();let O=Math.max(o.width+T,I),N=Math.max(o.height+F,I);e.minWidth&&e.minWidth>I&&(O=Math.max(O,e.minWidth)),e.minHeight&&e.minHeight>I&&(N=Math.max(N,e.minHeight)),e.maxWidth&&(O=Math.min(O,e.maxWidth)),e.maxHeight&&(N=Math.min(N,e.maxHeight)),e.preserveAspectRatio&&(F<T?N=O*(o.height/o.width):O=N*(o.width/o.height)),(O!==o.width||N!==o.height)&&(t.resize(O,N,{direction:C,relativeDirection:x,trueDirection:v,snapped:!0,snaplines:this.cid,restrict:this.getRestrictArea(i)}),g&&(g+=N-o.height),l&&(l+=O-o.width));const z=t.getBBox().bbox(h);b&&Math.abs(z.x-b)>1&&Math.abs(z.width+z.x-b)>1&&(b=void 0),d&&Math.abs(z.y-d)>1&&Math.abs(z.height+z.y-d)>1&&(d=void 0),this.update({verticalLeft:b,verticalTop:m,verticalHeight:g,horizontalTop:d,horizontalLeft:y,horizontalWidth:l})}}}snapOnMoving({view:t,e,x:i,y:o}){const s=t.getEventData(e).delegatedView||t;if(!this.isNodeMovable(s))return;const r=s.cell,a=r.getSize(),h=r.getPosition(),p=new ht(i-this.offset.x,o-this.offset.y,a.width,a.height),b=r.getAngle(),m=p.getCenter(),g=p.bbox(b),d=g.getTopLeft(),y=g.getBottomRight(),l=this.options.tolerance||0;let c,C,v,x,f,E,T=0,F=0;if(this.model.getNodes().some(I=>{if(this.isIgnored(r,I))return!1;const O=I.getBBox().bbox(I.getAngle()),N=O.getCenter(),z=O.getTopLeft(),S=O.getBottomRight();return c==null&&(Math.abs(N.x-m.x)<l?(c=N.x,T=.5):Math.abs(z.x-d.x)<l?(c=z.x,T=0):Math.abs(z.x-y.x)<l?(c=z.x,T=1):Math.abs(S.x-y.x)<l?(c=S.x,T=1):Math.abs(S.x-d.x)<l&&(c=S.x),c!=null&&(C=Math.min(g.y,O.y),v=Math.max(y.y,S.y)-C)),x==null&&(Math.abs(N.y-m.y)<l?(x=N.y,F=.5):Math.abs(z.y-d.y)<l?x=z.y:Math.abs(z.y-y.y)<l?(x=z.y,F=1):Math.abs(S.y-y.y)<l?(x=S.y,F=1):Math.abs(S.y-d.y)<l&&(x=S.y),x!=null&&(f=Math.min(g.x,O.x),E=Math.max(y.x,S.x)-f)),c!=null&&x!=null}),this.hide(),x!=null||c!=null){x!=null&&(g.y=x-F*g.height),c!=null&&(g.x=c-T*g.width);const I=g.getCenter(),O=I.x-p.width/2,N=I.y-p.height/2,z=O-h.x,S=N-h.y;(z!==0||S!==0)&&(r.translate(z,S,{snapped:!0,restrict:this.getRestrictArea(s)}),E&&(E+=z),v&&(v+=S)),this.update({verticalLeft:c,verticalTop:C,verticalHeight:v,horizontalTop:x,horizontalLeft:f,horizontalWidth:E})}}isIgnored(t,e){return e.id===t.id||e.isDescendantOf(t)||!this.filter(e)}filter(t){const e=this.options.filter;return Array.isArray(e)?e.some(i=>typeof i=="string"?t.shape===i:t.id===i.id):typeof e=="function"?U(e,this.graph,t):!0}update(t){if(t.horizontalTop){const e=this.graph.localToGraph(new k(t.horizontalLeft,t.horizontalTop)),i=this.graph.localToGraph(new k(t.horizontalLeft+t.horizontalWidth,t.horizontalTop));this.horizontal.setAttributes({x1:this.options.sharp?`${e.x}`:"0",y1:`${e.y}`,x2:this.options.sharp?`${i.x}`:"100%",y2:`${i.y}`,display:"inherit"})}else this.horizontal.setAttribute("display","none");if(t.verticalLeft){const e=this.graph.localToGraph(new k(t.verticalLeft,t.verticalTop)),i=this.graph.localToGraph(new k(t.verticalLeft,t.verticalTop+t.verticalHeight));this.vertical.setAttributes({x1:`${e.x}`,y1:this.options.sharp?`${e.y}`:"0",x2:`${i.x}`,y2:this.options.sharp?`${i.y}`:"100%",display:"inherit"})}else this.vertical.setAttribute("display","none");this.show()}resetTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null)}show(){return this.resetTimer(),this.container.parentNode==null&&this.graph.container.appendChild(this.container),this}hide(){this.resetTimer(),this.vertical.setAttribute("display","none"),this.horizontal.setAttribute("display","none");const t=this.options.clean,e=typeof t=="number"?t:t!==!1?3e3:0;return e>0&&(this.timer=window.setTimeout(()=>{this.container.parentNode!==null&&this.unmount()},e)),this}onRemove(){this.stopListening(),this.hide()}dispose(){this.remove()}}Zt([$.dispose()],vt.prototype,"dispose",null);const Qt=`.x6-widget-snapline {
|
|
position: absolute;
|
|
top: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
left: 0;
|
|
pointer-events: none;
|
|
}
|
|
.x6-widget-snapline-vertical,
|
|
.x6-widget-snapline-horizontal {
|
|
stroke: #2ecc71;
|
|
stroke-width: 1px;
|
|
}
|
|
`;u.prototype.isSnaplineEnabled=function(){const n=this.getPlugin("snapline");return n?n.isEnabled():!1};u.prototype.enableSnapline=function(){const n=this.getPlugin("snapline");return n&&n.enable(),this};u.prototype.disableSnapline=function(){const n=this.getPlugin("snapline");return n&&n.disable(),this};u.prototype.toggleSnapline=function(){const n=this.getPlugin("snapline");return n&&n.toggleEnabled(),this};u.prototype.hideSnapline=function(){const n=this.getPlugin("snapline");return n&&n.hide(),this};u.prototype.setSnaplineFilter=function(n){const t=this.getPlugin("snapline");return t&&t.setFilter(n),this};u.prototype.isSnaplineOnResizingEnabled=function(){const n=this.getPlugin("snapline");return n?n.isOnResizingEnabled():!1};u.prototype.enableSnaplineOnResizing=function(){const n=this.getPlugin("snapline");return n&&n.enableOnResizing(),this};u.prototype.disableSnaplineOnResizing=function(){const n=this.getPlugin("snapline");return n&&n.disableOnResizing(),this};u.prototype.toggleSnaplineOnResizing=function(n){const t=this.getPlugin("snapline");return t&&t.toggleOnResizing(n),this};u.prototype.isSharpSnapline=function(){const n=this.getPlugin("snapline");return n?n.isSharp():!1};u.prototype.enableSharpSnapline=function(){const n=this.getPlugin("snapline");return n&&n.enableSharp(),this};u.prototype.disableSharpSnapline=function(){const n=this.getPlugin("snapline");return n&&n.disableSharp(),this};u.prototype.toggleSharpSnapline=function(n){const t=this.getPlugin("snapline");return t&&t.toggleSharp(n),this};u.prototype.getSnaplineTolerance=function(){const n=this.getPlugin("snapline");if(n)return n.getTolerance()};u.prototype.setSnaplineTolerance=function(n){const t=this.getPlugin("snapline");return t&&t.setTolerance(n),this};var te=globalThis&&globalThis.__decorate||function(n,t,e,i){var o=arguments.length,s=o<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,t,e,i);else for(var a=n.length-1;a>=0;a--)(r=n[a])&&(s=(o<3?r(s):o>3?r(t,e,s):r(t,e))||s);return o>3&&s&&Object.defineProperty(t,e,s),s};class wt extends mt{constructor(t={}){super(),this.name="snapline",this.options=Object.assign({enabled:!0,tolerance:10},t),et(this.name,Qt)}init(t){this.snaplineImpl=new vt(Object.assign(Object.assign({},this.options),{graph:t}))}isEnabled(){return!this.snaplineImpl.disabled}enable(){this.snaplineImpl.enable()}disable(){this.snaplineImpl.disable()}toggleEnabled(t){if(t!=null)t!==this.isEnabled()&&(t?this.enable():this.disable());else return this.isEnabled()?this.disable():this.enable(),this}hide(){return this.snaplineImpl.hide(),this}setFilter(t){return this.snaplineImpl.setFilter(t),this}isOnResizingEnabled(){return this.snaplineImpl.options.resizing===!0}enableOnResizing(){return this.snaplineImpl.options.resizing=!0,this}disableOnResizing(){return this.snaplineImpl.options.resizing=!1,this}toggleOnResizing(t){return t!=null?t!==this.isOnResizingEnabled()&&(t?this.enableOnResizing():this.disableOnResizing()):this.isOnResizingEnabled()?this.disableOnResizing():this.enableOnResizing(),this}isSharp(){return this.snaplineImpl.options.sharp===!0}enableSharp(){return this.snaplineImpl.options.sharp=!0,this}disableSharp(){return this.snaplineImpl.options.sharp=!1,this}toggleSharp(t){return t!=null?t!==this.isSharp()&&(t?this.enableSharp():this.disableSharp()):this.isSharp()?this.disableSharp():this.enableSharp(),this}getTolerance(){return this.snaplineImpl.options.tolerance}setTolerance(t){return this.snaplineImpl.options.tolerance=t,this}captureCursorOffset(t){this.snaplineImpl.captureCursorOffset(t)}snapOnMoving(t){this.snaplineImpl.snapOnMoving(t)}dispose(){this.snaplineImpl.dispose(),it(this.name)}}te([mt.dispose()],wt.prototype,"dispose",null);const ee=`.x6-widget-minimap {
|
|
position: relative;
|
|
display: table-cell;
|
|
box-sizing: border-box;
|
|
overflow: hidden;
|
|
text-align: center;
|
|
vertical-align: middle;
|
|
background-color: #fff;
|
|
user-select: none;
|
|
}
|
|
.x6-widget-minimap .x6-graph {
|
|
display: inline-block;
|
|
box-shadow: 0 0 4px 0 #eee;
|
|
cursor: pointer;
|
|
}
|
|
.x6-widget-minimap .x6-graph > svg {
|
|
pointer-events: none;
|
|
shape-rendering: optimizespeed;
|
|
}
|
|
.x6-widget-minimap .x6-graph .x6-node * {
|
|
/* stylelint-disable-next-line */
|
|
vector-effect: initial;
|
|
}
|
|
.x6-widget-minimap-viewport {
|
|
position: absolute;
|
|
box-sizing: content-box !important;
|
|
margin: -2px 0 0 -2px;
|
|
border: 2px solid #31d0c6;
|
|
cursor: move;
|
|
}
|
|
.x6-widget-minimap-viewport-zoom {
|
|
position: absolute;
|
|
right: 0;
|
|
bottom: 0;
|
|
box-sizing: border-box;
|
|
width: 12px;
|
|
height: 12px;
|
|
margin: 0 -6px -6px 0;
|
|
background-color: #fff;
|
|
border: 2px solid #31d0c6;
|
|
border-radius: 50%;
|
|
cursor: nwse-resize;
|
|
}
|
|
`;var ie=globalThis&&globalThis.__decorate||function(n,t,e,i){var o=arguments.length,s=o<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,t,e,i);else for(var a=n.length-1;a>=0;a--)(r=n[a])&&(s=(o<3?r(s):o>3?r(t,e,s):r(t,e))||s);return o>3&&s&&Object.defineProperty(t,e,s),s};class Ct extends ${get scroller(){return this.graph.getPlugin("scroller")}get graphContainer(){return this.scroller?this.scroller.container:this.graph.container}constructor(t){super(),this.name="minimap",this.options=Object.assign(Object.assign({},Q.defaultOptions),t),et(this.name,ee)}init(t){this.graph=t,this.updateViewport=zt(this.updateViewport.bind(this),0),this.container=document.createElement("div"),R(this.container,this.prefixClassName(V.root));const e=document.createElement("div");this.container.appendChild(e),this.viewport=document.createElement("div"),R(this.viewport,this.prefixClassName(V.viewport)),this.options.scalable&&(this.zoomHandle=document.createElement("div"),R(this.zoomHandle,this.prefixClassName(V.zoom)),J(this.zoomHandle,this.viewport)),pt(this.container,this.viewport),P(this.container,{width:this.options.width,height:this.options.height,padding:this.options.padding}),this.options.container&&this.options.container.appendChild(this.container),this.sourceGraph=this.graph;const i=Object.assign(Object.assign({},this.options.graphOptions),{container:e,model:this.sourceGraph.model,interacting:!1,grid:!1,background:!1,embedding:!1});this.targetGraph=this.options.createGraph?this.options.createGraph(i):new u(i),this.updatePaper(this.sourceGraph.options.width,this.sourceGraph.options.height),this.startListening()}startListening(){this.scroller?bt.on(this.graphContainer,`scroll${this.getEventNamespace()}`,this.updateViewport):(this.sourceGraph.on("translate",this.onTransform,this),this.sourceGraph.on("scale",this.onTransform,this),this.sourceGraph.on("model:updated",this.onModelUpdated,this)),this.sourceGraph.on("resize",this.updatePaper,this),this.delegateEvents({mousedown:"startAction",touchstart:"startAction",[`mousedown .${this.prefixClassName("graph")}`]:"scrollTo",[`touchstart .${this.prefixClassName("graph")}`]:"scrollTo"})}stopListening(){this.scroller?bt.off(this.graphContainer,this.getEventNamespace()):(this.sourceGraph.off("translate",this.onTransform,this),this.sourceGraph.off("scale",this.onTransform,this),this.sourceGraph.off("model:updated",this.onModelUpdated,this)),this.sourceGraph.off("resize",this.updatePaper,this),this.undelegateEvents()}onRemove(){this.stopListening(),this.targetGraph.dispose(!1)}onTransform(t){(t.ui||this.targetGraphTransforming)&&this.updateViewport()}onModelUpdated(){this.targetGraph.zoomToFit()}updatePaper(t,e){let i,o;typeof t=="object"?(i=t.width,o=t.height):(i=t,o=e);const s=this.sourceGraph.options,r=this.sourceGraph.transform.getScale(),a=this.options.width-2*this.options.padding,h=this.options.height-2*this.options.padding;i/=r.sx,o/=r.sy,this.ratio=Math.min(a/i,h/o);const p=this.ratio,b=s.x*p/r.sx,m=s.y*p/r.sy;return i*=p,o*=p,this.targetGraph.resize(i,o),this.targetGraph.translate(b,m),this.scroller?this.targetGraph.scale(p,p):this.targetGraph.zoomToFit(),this.updateViewport(),this}updateViewport(){const t=this.sourceGraph.transform.getScale(),e=this.targetGraph.transform.getScale();let i=null;this.scroller?i=this.scroller.clientToLocalPoint(0,0):i=this.graph.graphToLocal(0,0);const o=Xt(this.targetGraph.container),s=this.targetGraph.translate();s.ty=s.ty||0,this.geometry={top:o.top+i.y*e.sy+s.ty,left:o.left+i.x*e.sx+s.tx,width:this.graphContainer.clientWidth*e.sx/t.sx,height:this.graphContainer.clientHeight*e.sy/t.sy},P(this.viewport,this.geometry)}startAction(t){const e=this.normalizeEvent(t),i=e.target===this.zoomHandle?"zooming":"panning",{tx:o,ty:s}=this.sourceGraph.translate(),r={action:i,clientX:e.clientX,clientY:e.clientY,scrollLeft:this.graphContainer.scrollLeft,scrollTop:this.graphContainer.scrollTop,zoom:this.sourceGraph.zoom(),scale:this.sourceGraph.transform.getScale(),geometry:this.geometry,translateX:o,translateY:s};this.targetGraphTransforming=!0,this.delegateDocumentEvents(Q.documentEvents,r)}doAction(t){const e=this.normalizeEvent(t),i=e.clientX,o=e.clientY,s=e.data;switch(s.action){case"panning":{const r=this.sourceGraph.transform.getScale(),a=(i-s.clientX)*r.sx,h=(o-s.clientY)*r.sy;this.scroller?(this.graphContainer.scrollLeft=s.scrollLeft+a/this.ratio,this.graphContainer.scrollTop=s.scrollTop+h/this.ratio):this.sourceGraph.translate(s.translateX-a/this.ratio,s.translateY-h/this.ratio);break}case"zooming":{const r=s.scale,a=s.geometry,h=1+(s.clientX-i)/a.width/r.sx;s.frameId&&cancelAnimationFrame(s.frameId),s.frameId=requestAnimationFrame(()=>{this.sourceGraph.zoom(h*s.zoom,{absolute:!0,minScale:this.options.minScale,maxScale:this.options.maxScale})});break}}}stopAction(){this.undelegateDocumentEvents(),this.targetGraphTransforming=!1}scrollTo(t){const e=this.normalizeEvent(t);let i,o;const s=this.targetGraph.translate();if(s.ty=s.ty||0,e.offsetX==null){const h=ct(this.targetGraph.container);i=e.pageX-h.left,o=e.pageY-h.top}else i=e.offsetX,o=e.offsetY;const r=(i-s.tx)/this.ratio,a=(o-s.ty)/this.ratio;this.sourceGraph.centerPoint(r,a)}dispose(){this.remove(),it(this.name)}}ie([$.dispose()],Ct.prototype,"dispose",null);var V;(function(n){n.root="widget-minimap",n.viewport=`${n.root}-viewport`,n.zoom=`${n.viewport}-zoom`})(V||(V={}));var Q;(function(n){n.defaultOptions={width:300,height:200,padding:10,scalable:!0,minScale:.01,maxScale:16,graphOptions:{},createGraph:t=>new u(t)},n.documentEvents={mousemove:"doAction",touchmove:"doAction",mouseup:"stopAction",touchend:"stopAction"}})(Q||(Q={}));const K=.2,Z=10,se=Mt({name:"Features",props:{graph:u},setup(n){const t=new X({resizing:!0,rotating:!0}),e=new H({rubberband:!0,showNodeSelectionBox:!0}),i=new wt({tolerance:10}),o=new Ct({container:document.getElementById("mini-map-container"),width:200,height:160,padding:10,minScale:K,maxScale:Z,scalable:!0}),s=Rt([{key:"transform",label:"\u542F\u7528\u8282\u70B9\u8C03\u6574",value:!0,instance:t},{key:"selection",label:"\u542F\u7528\u591A\u9009\u5DE5\u5177",value:!0,instance:e},{key:"snapline",label:"\u542F\u7528\u5BF9\u9F50\u7EBF\u5DE5\u5177",value:!0,instance:i}]),r=l=>{const c=localStorage.getItem(l);return c?c==="1":(localStorage.setItem(l,"1"),!0)},a=(l,c)=>{localStorage.setItem(l,c)},h=l=>{var c,C;l.value=!l.value,a(l.key,l.value?"1":"0"),l.value?(c=n.graph)==null||c.enablePlugins(l.key):(C=n.graph)==null||C.disablePlugins(l.key)},p=dt(!1),b={padding:"30px"},m=dt(1),g=()=>{m.value=parseFloat(n.graph.zoom().toFixed(1))},d=l=>{var c;if(m.value+l<K){nt.error("\u6700\u5C0F\u53EF\u7F29\u653E\u523020%"),m.value=K,n.graph.zoomTo(K);return}if(m.value+l>Z){nt.error("\u6700\u5927\u53EF\u7F29\u653E\u52301000%"),m.value=Z,n.graph.zoomTo(Z);return}(c=n.graph)==null||c.zoom(l),g()},y=l=>{const c=Number(l);if(Number.isNaN(c)){nt.error("\u8BF7\u8F93\u5165\u6570\u5B57");return}d(c-m.value)};return Bt(()=>{var C,v;n.graph.use(i).use(t).use(e).use(o);const l=s.map(x=>x.key);n.graph.disablePlugins(l);const c=[];s.forEach(x=>{x.value=r(x.key),x.value&&c.push(x.key)}),(C=n.graph)==null||C.enablePlugins(c),g(),(v=n.graph)==null||v.on("scale",()=>{g()})}),()=>w("div",{class:"feture-wrapper"},[w("div",{class:"zoom-adjust"},[w("div",null,[B("\u7F29\u653E\uFF1A")]),w("div",{class:"main"},[w("div",{class:"oper",onClick:()=>d(-.2)},[B("-")]),Ot(w("input",{"onUpdate:value":l=>m.value=l,onChange:l=>{y(l.target.value)}},null),[[At,m.value,"value"]]),w("div",{class:"oper",onClick:()=>d(.2)},[B("+")])]),w("div",{class:"reset",onClick:()=>d(1-m.value)},[B("\u91CD\u7F6E")])]),w("div",{class:"features"},[s.map(l=>w(Pt,{checked:l.value,"onUpdate:checked":c=>l.value=c,key:l.key,onClick:()=>h(l)},{default:()=>[l.label]}))]),w("div",{class:"guide",onClick:()=>p.value=!0},[w("i",{class:"icon-support"},[B("\xA0")]),B("\u64CD\u4F5C\u8BF4\u660E")]),w(Nt,{visible:p.value,"onUpdate:visible":l=>p.value=l,title:"\u6D41\u7A0B\u8BBE\u8BA1\u5668\u64CD\u4F5C\u8BF4\u660E",centered:!0,closable:!1,bodyStyle:b},{default:()=>[w("p",null,[B("1. Ctrl + \u9F20\u6807\u6EDA\u8F6E \u53EF\u6574\u4F53\u7F29\u653E\u753B\u5E03 ")]),w("p",null,[B("2. Alt \u6216 Shift + \u9F20\u6807\u5DE6\u952E\u6309\u4F4F\u753B\u5E03\u7A7A\u767D\u5904 \u53EF\u62D6\u52A8\u753B\u5E03")]),w("p",null,[B("3. \u9F20\u6807\u79FB\u52A8\u5230\u8282\u70B9\u4E0A \u53EF\u663E\u793A\u5F53\u524D\u53EF\u7528\u8FDE\u63A5\u70B9")]),w("p",null,[B("4. \u9F20\u6807\u5DE6\u952E\u70B9\u51FB\u8282\u70B9 \u53EF\u4EE5\u89E6\u53D1\u4EE5\u4E0B\u529F\u80FD\uFF1A")]),w("p",null,[B("\xA0\xA0\xA0-\xA0\xA01 \u663E\u793A\u5927\u5C0F/\u65B9\u5411\u8C03\u6574\u5DE5\u5177")]),w("p",null,[B("\xA0\xA0\xA0-\xA0\xA02 \u663E\u793A\u5FEB\u6377\u521B\u5EFA\u4E0B\u4E00\u8282\u70B9\u83DC\u5355")]),w("p",null,[B("\xA0\xA0\xA0-\xA0\xA03 \u663E\u793A\u53F3\u4FA7\u5FEB\u6377\u7F16\u8F91\u83DC\u5355\uFF08\u53EF\u70B9\u51FB\u9501\u56FE\u6807\u963B\u6B62\uFF09")]),w("p",null,[B("5. \u9F20\u6807\u5DE6\u952E\u53CC\u51FB\u8282\u70B9 \u53EF\u4EE5\u5FEB\u6377\u4FEE\u6539\u8282\u70B9\u540D")]),w("p",null,[B("6. \u9F20\u6807\u5DE6\u952E\u70B9\u51FB\u8FDE\u63A5\u7EBF \u53EF\u4EE5\u8C03\u6574\u4F4D\u7F6E / \u53F3\u952E\u8FDE\u63A5\u7EBF\u53EF\u663E\u793A\u7F16\u8F91\u6846")]),w("p",null,[B("7. \u753B\u5E03\u7A7A\u767D\u5904\u53F3\u952E\u53EF\u4EE5\u5FEB\u6377\u521B\u5EFA\u8282\u70B9")]),w("p",null,[B("8. \u5DE6\u4FA7\u8282\u70B9\u9762\u677F\u4E5F\u53EF\u5B9E\u73B0\u5FEB\u901F\u521B\u5EFA")])],footer:()=>w(Tt,{type:"primary",style:{borderRadius:"6px"},onClick:()=>p.value=!1},{default:()=>[B("\u77E5\u9053\u4E86")]})})])}});const ve=Dt(se,[["__scopeId","data-v-f96d8574"]]);export{ve as default};
|