irr-gh 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +144 -1
- package/dist/irr-gh.js +44 -32
- package/dist/irr-gh.umd.cjs +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -44,6 +44,8 @@ bun add irr-gh
|
|
|
44
44
|
|
|
45
45
|
## 快速开始
|
|
46
46
|
|
|
47
|
+
### 组件导入方式
|
|
48
|
+
|
|
47
49
|
```vue
|
|
48
50
|
<script setup lang="ts">
|
|
49
51
|
import { ref } from 'vue'
|
|
@@ -82,6 +84,63 @@ function handleReady(graph: unknown) {
|
|
|
82
84
|
</template>
|
|
83
85
|
```
|
|
84
86
|
|
|
87
|
+
### 全局注册方式
|
|
88
|
+
|
|
89
|
+
您也可以在 main.js/main.ts 中全局注册组件:
|
|
90
|
+
|
|
91
|
+
```javascript
|
|
92
|
+
// main.js
|
|
93
|
+
import { createApp } from 'vue'
|
|
94
|
+
import App from './App.vue'
|
|
95
|
+
import IrrGh from 'irr-gh'
|
|
96
|
+
import 'irr-gh/style.css'
|
|
97
|
+
|
|
98
|
+
const app = createApp(App)
|
|
99
|
+
|
|
100
|
+
// 全局注册组件
|
|
101
|
+
app.use(IrrGh)
|
|
102
|
+
|
|
103
|
+
app.mount('#app')
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
之后就可以在任何组件中直接使用 `<IrrigationGraph>` 组件,无需单独导入:
|
|
107
|
+
|
|
108
|
+
```vue
|
|
109
|
+
<script setup lang="ts">
|
|
110
|
+
import { ref } from 'vue'
|
|
111
|
+
import type { IrrigationData } from 'irr-gh'
|
|
112
|
+
|
|
113
|
+
const graphRef = ref()
|
|
114
|
+
|
|
115
|
+
// 示例数据
|
|
116
|
+
const data: IrrigationData = {
|
|
117
|
+
canals: [
|
|
118
|
+
{ id: 'main', name: '主干渠', type: 'canal', level: 1 },
|
|
119
|
+
{ id: 'branch-1', name: '支渠1', type: 'canal', parentId: 'main', bankSide: 'left' }
|
|
120
|
+
],
|
|
121
|
+
points: [
|
|
122
|
+
{ id: 'sluice-1', name: '闸门1', type: 'sluice', canalId: 'main', chainage: 0 },
|
|
123
|
+
{ id: 'sluice-2', name: '闸门2', type: 'sluice', canalId: 'main', chainage: 100 }
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function handleReady(graph: unknown) {
|
|
128
|
+
console.log('图渲染完成', graph)
|
|
129
|
+
}
|
|
130
|
+
</script>
|
|
131
|
+
|
|
132
|
+
<template>
|
|
133
|
+
<IrrigationGraph
|
|
134
|
+
ref="graphRef"
|
|
135
|
+
:data="data"
|
|
136
|
+
:enable-minimap="true"
|
|
137
|
+
:fit-view="true"
|
|
138
|
+
:show-toolbar="true"
|
|
139
|
+
@ready="handleReady"
|
|
140
|
+
/>
|
|
141
|
+
</template>
|
|
142
|
+
```
|
|
143
|
+
|
|
85
144
|
---
|
|
86
145
|
|
|
87
146
|
## 布局系统
|
|
@@ -340,6 +399,90 @@ interface PointEntity {
|
|
|
340
399
|
chainage: number // 桩号位置
|
|
341
400
|
bankSide?: 'left' | 'right' | 'center' // 岸别
|
|
342
401
|
properties?: Record<string, unknown> // 扩展属性
|
|
402
|
+
/** 节点显示配置(可选,用于自定义节点的G6渲染样式) */
|
|
403
|
+
nodeConfig?: PointNodeConfig
|
|
404
|
+
}
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
#### 节点显示配置 (PointNodeConfig)
|
|
408
|
+
|
|
409
|
+
您可以使用 `nodeConfig` 属性来自定义节点的显示样式:
|
|
410
|
+
|
|
411
|
+
```typescript
|
|
412
|
+
interface PointNodeConfig {
|
|
413
|
+
/** 节点形状: rect(矩形), circle(圆形), diamond(菱形), image(图片) */
|
|
414
|
+
shape?: 'rect' | 'circle' | 'diamond' | 'ellipse' | 'image'
|
|
415
|
+
/** 图片地址(shape为image时使用) */
|
|
416
|
+
img?: string
|
|
417
|
+
/** 节点宽度 */
|
|
418
|
+
width?: number
|
|
419
|
+
/** 节点高度 */
|
|
420
|
+
height?: number
|
|
421
|
+
/** 填充色 */
|
|
422
|
+
fill?: string
|
|
423
|
+
/** 边框色 */
|
|
424
|
+
stroke?: string
|
|
425
|
+
/** 边框宽度 */
|
|
426
|
+
lineWidth?: number
|
|
427
|
+
/** 圆角半径 */
|
|
428
|
+
radius?: number
|
|
429
|
+
}
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
**使用示例:**
|
|
433
|
+
|
|
434
|
+
```typescript
|
|
435
|
+
// 使用图片节点
|
|
436
|
+
const sluiceWithImage: SluiceEntity = {
|
|
437
|
+
id: 'slu-1',
|
|
438
|
+
name: '进水闸1',
|
|
439
|
+
type: 'sluice',
|
|
440
|
+
canalId: 'canal-A',
|
|
441
|
+
chainage: 0,
|
|
442
|
+
sluiceType: 'inlet',
|
|
443
|
+
designFlow: 50,
|
|
444
|
+
nodeConfig: {
|
|
445
|
+
shape: 'image',
|
|
446
|
+
img: '/head.png',
|
|
447
|
+
width: 48,
|
|
448
|
+
height: 48
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// 使用矩形节点并自定义样式
|
|
453
|
+
const pumpWithCustomStyle: PumpStationEntity = {
|
|
454
|
+
id: 'pump-1',
|
|
455
|
+
name: '提水泵站1',
|
|
456
|
+
type: 'pumpStation',
|
|
457
|
+
canalId: 'canal-B',
|
|
458
|
+
chainage: 100,
|
|
459
|
+
capacity: 500,
|
|
460
|
+
pumpType: 'lift',
|
|
461
|
+
nodeConfig: {
|
|
462
|
+
shape: 'rect',
|
|
463
|
+
width: 60,
|
|
464
|
+
height: 40,
|
|
465
|
+
fill: '#ffccc7',
|
|
466
|
+
stroke: '#ff4d4f',
|
|
467
|
+
radius: 8
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// 使用圆形节点
|
|
472
|
+
const reservoirWithCircle: ReservoirEntity = {
|
|
473
|
+
id: 'reservoir-1',
|
|
474
|
+
name: '调节水库1',
|
|
475
|
+
type: 'reservoir',
|
|
476
|
+
canalId: 'canal-C',
|
|
477
|
+
chainage: 500,
|
|
478
|
+
storageCapacity: 10000,
|
|
479
|
+
normalLevel: 85,
|
|
480
|
+
nodeConfig: {
|
|
481
|
+
shape: 'circle',
|
|
482
|
+
r: 24, // 圆形使用 r 属性表示半径
|
|
483
|
+
fill: '#e6f7ff',
|
|
484
|
+
stroke: '#1890ff'
|
|
485
|
+
}
|
|
343
486
|
}
|
|
344
487
|
```
|
|
345
488
|
|
|
@@ -468,7 +611,7 @@ export const CANAL_COLOR = '#1890ff'
|
|
|
468
611
|
|
|
469
612
|
### 图片类型节点
|
|
470
613
|
|
|
471
|
-
|
|
614
|
+
点位节点支持使用图片,通过业务数据中的 `nodeConfig` 配置(推荐方式),或通过 G6 图数据中的 `styleConfig.img` 配置:
|
|
472
615
|
|
|
473
616
|
```typescript
|
|
474
617
|
// 业务数据中的节点配置(推荐方式)
|
package/dist/irr-gh.js
CHANGED
|
@@ -54915,60 +54915,68 @@ class sP {
|
|
|
54915
54915
|
const e = typeof this.options.container == "string" ? document.getElementById(this.options.container) : this.options.container;
|
|
54916
54916
|
if (!e)
|
|
54917
54917
|
throw new Error("Container not found");
|
|
54918
|
-
this.container = e
|
|
54919
|
-
const t = zse(this.options);
|
|
54918
|
+
this.container = e;
|
|
54919
|
+
const t = Kse(this.options.theme), n = zse(this.options);
|
|
54920
54920
|
return this.graph = new kf({
|
|
54921
54921
|
container: e,
|
|
54922
54922
|
width: this.options.width || e.clientWidth,
|
|
54923
54923
|
height: this.options.height || e.clientHeight,
|
|
54924
54924
|
autoFit: this.options.fitView ? "view" : void 0,
|
|
54925
54925
|
padding: this.options.fitViewPadding,
|
|
54926
|
+
// 设置背景色
|
|
54927
|
+
background: t.backgroundColor || "#fafafa",
|
|
54926
54928
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54927
54929
|
layout: this.buildLayoutConfig(this.options.layout),
|
|
54928
|
-
behaviors:
|
|
54930
|
+
behaviors: n,
|
|
54929
54931
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54930
54932
|
plugins: this.buildPlugins(),
|
|
54931
54933
|
node: {
|
|
54932
|
-
type: (
|
|
54933
|
-
style: (
|
|
54934
|
-
const
|
|
54935
|
-
return
|
|
54936
|
-
src:
|
|
54937
|
-
size: [
|
|
54934
|
+
type: (i) => i.nodeShape || "circle",
|
|
54935
|
+
style: (i) => {
|
|
54936
|
+
const a = i, s = a.styleConfig || {};
|
|
54937
|
+
return a.nodeShape === "image" && s.img ? {
|
|
54938
|
+
src: s.img,
|
|
54939
|
+
size: [
|
|
54940
|
+
s.width || 48,
|
|
54941
|
+
s.height || 48
|
|
54942
|
+
],
|
|
54938
54943
|
// 标签
|
|
54939
|
-
labelText:
|
|
54944
|
+
labelText: a.data?.label || "",
|
|
54940
54945
|
labelPlacement: "bottom",
|
|
54941
54946
|
labelOffsetY: 8
|
|
54942
54947
|
} : {
|
|
54943
54948
|
// 基础样式
|
|
54944
|
-
fill:
|
|
54945
|
-
stroke:
|
|
54946
|
-
lineWidth:
|
|
54947
|
-
radius:
|
|
54949
|
+
fill: s.fill || "#fff",
|
|
54950
|
+
stroke: s.stroke || "#1890ff",
|
|
54951
|
+
lineWidth: s.lineWidth ?? 2,
|
|
54952
|
+
radius: s.radius ?? 4,
|
|
54948
54953
|
// 尺寸
|
|
54949
|
-
size:
|
|
54954
|
+
size: s.width ? [
|
|
54955
|
+
s.width,
|
|
54956
|
+
s.height || s.width
|
|
54957
|
+
] : void 0,
|
|
54950
54958
|
// 标签
|
|
54951
|
-
labelText:
|
|
54959
|
+
labelText: a.data?.label || "",
|
|
54952
54960
|
labelPlacement: "bottom"
|
|
54953
54961
|
};
|
|
54954
54962
|
}
|
|
54955
54963
|
},
|
|
54956
54964
|
edge: {
|
|
54957
|
-
type: (
|
|
54958
|
-
const
|
|
54959
|
-
return
|
|
54965
|
+
type: (i) => {
|
|
54966
|
+
const a = i;
|
|
54967
|
+
return a.styleConfig?.router ? "polyline" : a.edgeShape || "line";
|
|
54960
54968
|
},
|
|
54961
|
-
style: (
|
|
54962
|
-
const
|
|
54963
|
-
stroke:
|
|
54964
|
-
lineWidth:
|
|
54965
|
-
endArrow:
|
|
54969
|
+
style: (i) => {
|
|
54970
|
+
const a = i, s = {
|
|
54971
|
+
stroke: a.styleConfig?.stroke || "#1890ff",
|
|
54972
|
+
lineWidth: a.styleConfig?.lineWidth || 2,
|
|
54973
|
+
endArrow: a.styleConfig?.endArrow ?? !0
|
|
54966
54974
|
};
|
|
54967
|
-
return
|
|
54975
|
+
return a.styleConfig?.router && (s.router = {
|
|
54968
54976
|
type: "orth",
|
|
54969
54977
|
// 正交路由,确保垂直相交
|
|
54970
54978
|
offset: 20
|
|
54971
|
-
}),
|
|
54979
|
+
}), s;
|
|
54972
54980
|
}
|
|
54973
54981
|
}
|
|
54974
54982
|
}), this.bindEvents(), this.state.rendered = !0, this.graph;
|
|
@@ -55020,7 +55028,10 @@ class sP {
|
|
|
55020
55028
|
rankSep: 100,
|
|
55021
55029
|
...e.options
|
|
55022
55030
|
}
|
|
55023
|
-
}[e.type] || {
|
|
55031
|
+
}[e.type] || {
|
|
55032
|
+
type: e.type,
|
|
55033
|
+
...e.options
|
|
55034
|
+
};
|
|
55024
55035
|
}
|
|
55025
55036
|
/**
|
|
55026
55037
|
* 构建插件配置
|
|
@@ -55031,7 +55042,9 @@ class sP {
|
|
|
55031
55042
|
type: "tooltip",
|
|
55032
55043
|
getContent: (t, n) => {
|
|
55033
55044
|
if (this.options.tooltip?.formatter && n.length > 0)
|
|
55034
|
-
return this.options.tooltip.formatter(
|
|
55045
|
+
return this.options.tooltip.formatter(
|
|
55046
|
+
n[0]
|
|
55047
|
+
);
|
|
55035
55048
|
const i = n[0];
|
|
55036
55049
|
return `<div style="padding: 8px 12px;">
|
|
55037
55050
|
<div style="font-weight: bold;">${i?.data?.label || ""}</div>
|
|
@@ -55266,7 +55279,9 @@ class sP {
|
|
|
55266
55279
|
async setLayout(e) {
|
|
55267
55280
|
if (!this.graph) return;
|
|
55268
55281
|
const t = this.buildLayoutConfig(e);
|
|
55269
|
-
this.graph.setLayout(
|
|
55282
|
+
this.graph.setLayout(
|
|
55283
|
+
t
|
|
55284
|
+
), await this.graph.layout();
|
|
55270
55285
|
}
|
|
55271
55286
|
/**
|
|
55272
55287
|
* 获取图实例
|
|
@@ -55274,9 +55289,6 @@ class sP {
|
|
|
55274
55289
|
getGraph() {
|
|
55275
55290
|
return this.graph;
|
|
55276
55291
|
}
|
|
55277
|
-
/**
|
|
55278
|
-
* 销毁
|
|
55279
|
-
*/
|
|
55280
55292
|
destroy() {
|
|
55281
55293
|
this.graph && (this.graph.destroy(), this.graph = null), this.eventHandlers.clear(), this.state.rendered = !1;
|
|
55282
55294
|
}
|
package/dist/irr-gh.umd.cjs
CHANGED
|
@@ -130,7 +130,7 @@ YYYY`):Ir(t,"MM月");case"year":return Ir(t,"YYYY");default:return Ir(t,"YYYY-MM
|
|
|
130
130
|
<svg aria-hidden="true" focusable="false">
|
|
131
131
|
<use xlink:href="#${t.id}"></use>
|
|
132
132
|
</svg>
|
|
133
|
-
</div>`}).join("")})}};FU.defaultOptions={position:"top-left"};var TU=function(r,e,t,n){function i(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(c){try{l(n.next(c))}catch(u){s(u)}}function A(c){try{l(n.throw(c))}catch(u){s(u)}}function l(c){c.done?a(c.value):i(c.value).then(o,A)}l((n=n.apply(r,e||[])).next())})};class vf extends Qn{constructor(e,t){super(e,Object.assign({},vf.defaultOptions,t)),this.currentTarget=null,this.tooltipElement=null,this.container=null,this.isEnable=(n,i)=>{const{enable:a}=this.options;return typeof a=="function"?a(n,i):a},this.onClick=n=>{const{target:{id:i}}=n;this.currentTarget===i?this.hide(n):this.show(n)},this.onPointerMove=n=>{const{target:i}=n;!this.currentTarget||i.id===this.currentTarget||this.show(n)},this.onPointerLeave=n=>{this.hide(n)},this.onCanvasMove=n=>{this.hide(n)},this.onPointerOver=n=>{this.show(n)},this.showById=n=>TU(this,void 0,void 0,function*(){const i={target:{id:n}};yield this.show(i)}),this.getElementData=(n,i)=>{const{model:a}=this.context;switch(i){case"node":return a.getNodeData([n]);case"edge":return a.getEdgeData([n]);case"combo":return a.getComboData([n]);default:return[]}},this.show=n=>TU(this,void 0,void 0,function*(){var i,a;const{client:s,target:{id:o}}=n;if(Cl(n.target))return;const A=this.context.graph.getElementType(o),{getContent:l,title:c}=this.options,u=this.getElementData(o,A);if(!this.tooltipElement)return;if(!this.isEnable(n,u)){this.hide(n);return}let h={};if(l){if(h.content=yield l(n,u),!h.content)return}else{const g=this.context.graph.getElementRenderStyle(o),p=A==="node"?g.fill:g.stroke;h={title:c||A,data:u.map(v=>({name:"ID",value:v.id||`${v.source} -> ${v.target}`,color:p}))}}this.currentTarget=o;let d,f;if(s)d=s.x,f=s.y;else{const g=Rn(u,"0.style",{x:0,y:0});d=g.x,f=g.y}(a=(i=this.options).onOpenChange)===null||a===void 0||a.call(i,!0),this.tooltipElement.update(Object.assign(Object.assign(Object.assign({},this.tooltipStyleProps),{x:d,y:f,style:{".tooltip":{visibility:"visible"}}}),h))}),this.hide=n=>{var i,a,s,o,A;if(!n){(a=(i=this.options).onOpenChange)===null||a===void 0||a.call(i,!1),(s=this.tooltipElement)===null||s===void 0||s.hide(),this.currentTarget=null;return}if(!this.tooltipElement||!this.currentTarget)return;const{client:{x:l,y:c}}=n;(A=(o=this.options).onOpenChange)===null||A===void 0||A.call(o,!1),this.tooltipElement.hide(l,c),this.currentTarget=null},this.initTooltip=()=>{var n;const i=new tae({className:"tooltip",style:this.tooltipStyleProps});return(n=this.container)===null||n===void 0||n.appendChild(i.HTMLTooltipElement),i},this.render(),this.bindEvents()}getEvents(){return this.options.trigger==="click"?{"node:click":this.onClick,"edge:click":this.onClick,"combo:click":this.onClick,"canvas:click":this.onPointerLeave,contextmenu:this.onPointerLeave,drag:this.onPointerLeave}:{"node:pointerover":this.onPointerOver,"node:pointermove":this.onPointerMove,"canvas:pointermove":this.onCanvasMove,"edge:pointerover":this.onPointerOver,"edge:pointermove":this.onPointerMove,"combo:pointerover":this.onPointerOver,"combo:pointermove":this.onPointerMove,contextmenu:this.onPointerLeave,"node:drag":this.onPointerLeave}}update(e){var t;this.unbindEvents(),super.update(e),this.tooltipElement&&((t=this.container)===null||t===void 0||t.removeChild(this.tooltipElement.HTMLTooltipElement)),this.tooltipElement=this.initTooltip(),this.bindEvents()}render(){const{canvas:e}=this.context,t=e.getContainer();t&&(this.container=t,this.tooltipElement=this.initTooltip())}unbindEvents(){const{graph:e}=this.context,t=this.getEvents();Object.keys(t).forEach(n=>{e.off(n,t[n])})}bindEvents(){const{graph:e}=this.context,t=this.getEvents();Object.keys(t).forEach(n=>{e.on(n,t[n])})}get tooltipStyleProps(){const{canvas:e}=this.context,{center:t}=e.getBounds(),n=e.getContainer(),{top:i,left:a}=n.getBoundingClientRect(),{style:s,position:o,enterable:A,container:l={x:-a,y:-i},title:c,offset:u}=this.options,[h,d]=t,[f,g]=e.getSize();return{x:h,y:d,container:l,title:c,bounding:{x:0,y:0,width:f,height:g},position:o,enterable:A,offset:u,style:s}}destroy(){var e;this.unbindEvents(),this.tooltipElement&&((e=this.container)===null||e===void 0||e.removeChild(this.tooltipElement.HTMLTooltipElement)),super.destroy()}}vf.defaultOptions={trigger:"hover",position:"top-right",enterable:!1,enable:!0,offset:[10,10],style:{".tooltip":{visibility:"hidden"}}};var MU=function(r,e,t,n){function i(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(c){try{l(n.next(c))}catch(u){s(u)}}function A(c){try{l(n.throw(c))}catch(u){s(u)}}function l(c){c.done?a(c.value):i(c.value).then(o,A)}l((n=n.apply(r,e||[])).next())})};let hA;function OU(r,e){return hA||(hA=document.createElement("canvas")),hA.width=r,hA.height=e,hA.getContext("2d").clearRect(0,0,r,e),hA}function Uae(r,e,t,n){return MU(this,void 0,void 0,function*(){const i=OU(r,e),a=i.getContext("2d"),{rotate:s,opacity:o,textFill:A,textFontSize:l,textFontFamily:c,textFontVariant:u,textFontWeight:h,textAlign:d,textBaseline:f}=n;return a.textAlign=d,a.textBaseline=f,a.translate(r/2,e/2),a.font=`${l}px ${c} ${u} ${h}`,s&&a.rotate(s),o&&(a.globalAlpha=o),A&&(a.fillStyle=A,a.fillText(`${t}`,0,0)),i.toDataURL()})}function Pae(r,e,t,n){return MU(this,void 0,void 0,function*(){const i=OU(r,e),a=i.getContext("2d"),{rotate:s,opacity:o}=n;s&&a.rotate(s),o&&(a.globalAlpha=o);const A=new Image;return A.crossOrigin="anonymous",A.src=t,new Promise(l=>{A.onload=function(){const c=r>A.width?(r-A.width)/2:0,u=e>A.height?(e-A.height)/2:0;a.drawImage(A,0,0,A.width,A.height,c,u,r-c*2,e-u*2),l(i.toDataURL())}})})}var Dae=function(r,e,t,n){function i(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(c){try{l(n.next(c))}catch(u){s(u)}}function A(c){try{l(n.throw(c))}catch(u){s(u)}}function l(c){c.done?a(c.value):i(c.value).then(o,A)}l((n=n.apply(r,e||[])).next())})},Rae=function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t};class yf extends Qn{constructor(e,t){super(e,Object.assign({},yf.defaultOptions,t)),this.$element=aA("watermark"),this.context.canvas.getContainer().appendChild(this.$element),this.update(t)}update(e){const t=Object.create(null,{update:{get:()=>super.update}});return Dae(this,void 0,void 0,function*(){t.update.call(this,e);const n=this.options,{width:i,height:a,text:s,imageURL:o}=n,A=Rae(n,["width","height","text","imageURL"]);Object.keys(A).forEach(c=>{c.startsWith("background")&&(this.$element.style[c]=e[c])});const l=o?yield Pae(i,a,o,A):yield Uae(i,a,s,A);this.$element.style.backgroundImage=`url(${l})`})}destroy(){super.destroy(),this.$element.remove()}}yf.defaultOptions={width:200,height:100,opacity:.2,rotate:Math.PI/12,text:"",textFill:"#000",textFontSize:16,textAlign:"center",textBaseline:"middle",backgroundRepeat:"repeat"};const Hae=["#7E92B5","#F4664A","#FFBE3A"],Gae={type:"group",color:["#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]},Kae={type:"group",color:["#99ADD1","#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]};function IU(r){const{bgColor:e,textColor:t,nodeColor:n,nodeColorDisabled:i,nodeStroke:a,nodeHaloStrokeOpacityActive:s=.15,nodeHaloStrokeOpacitySelected:o=.25,nodeOpacityDisabled:A=.06,nodeIconOpacityInactive:l=.85,nodeOpacityInactive:c=.25,nodeBadgePalette:u=Hae,nodePaletteOptions:h=Gae,edgeColor:d,edgeColorDisabled:f,edgePaletteOptions:g=Kae,comboColor:p,comboColorDisabled:v,comboStroke:y,comboStrokeDisabled:m,edgeColorInactive:b}=r;return{background:e,node:{palette:h,style:{donutOpacity:1,badgeBackgroundOpacity:1,badgeFill:"#fff",badgeFontSize:8,badgePadding:[0,4],badgePalette:u,fill:n,fillOpacity:1,halo:!1,iconFill:"#fff",iconOpacity:1,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelFill:t,labelFillOpacity:.85,labelLineHeight:16,labelPadding:[0,2],labelFontSize:12,labelFontWeight:400,labelOpacity:1,labelOffsetY:2,lineWidth:0,portFill:n,portLineWidth:1,portStroke:a,portStrokeOpacity:.65,size:32,stroke:a,strokeOpacity:1,zIndex:2},state:{selected:{halo:!0,haloLineWidth:24,haloStrokeOpacity:o,labelFontSize:12,labelFontWeight:"bold",lineWidth:4,stroke:a},active:{halo:!0,haloLineWidth:12,haloStrokeOpacity:s},highlight:{labelFontWeight:"bold",lineWidth:4,stroke:a,strokeOpacity:.85},inactive:{badgeBackgroundOpacity:c,donutOpacity:c,fillOpacity:c,iconOpacity:l,labelFill:t,labelFillOpacity:c,strokeOpacity:c},disabled:{badgeBackgroundOpacity:.25,donutOpacity:A,fill:i,fillOpacity:A,iconFill:i,iconOpacity:.25,labelFill:t,labelFillOpacity:.25,strokeOpacity:A}},animation:{enter:"fade",exit:"fade",show:"fade",hide:"fade",expand:"node-expand",collapse:"node-collapse",update:[{fields:["x","y","fill","stroke"]}],translate:[{fields:["x","y"]}]}},edge:{palette:g,style:{badgeBackgroundFill:d,badgeFill:"#fff",badgeFontSize:8,badgeOffsetX:10,badgeBackgroundOpacity:1,fillOpacity:1,halo:!1,haloLineWidth:12,haloStrokeOpacity:1,increasedLineWidthForHitTesting:2,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[4,4,4,4],labelFill:t,labelFontSize:12,labelFontWeight:400,labelOpacity:1,labelPlacement:"center",labelTextBaseline:"middle",lineWidth:1,stroke:d,strokeOpacity:1,zIndex:1},state:{selected:{halo:!0,haloStrokeOpacity:.25,labelFontSize:14,labelFontWeight:"bold",lineWidth:3},active:{halo:!0,haloStrokeOpacity:.15},highlight:{labelFontWeight:"bold",lineWidth:3},inactive:{stroke:b,fillOpacity:.08,labelOpacity:.25,strokeOpacity:.08,badgeBackgroundOpacity:.25},disabled:{stroke:f,fillOpacity:.45,strokeOpacity:.45,labelOpacity:.25,badgeBackgroundOpacity:.45}},animation:{enter:"fade",exit:"fade",expand:"path-in",collapse:"path-out",show:"fade",hide:"fade",update:[{fields:["sourceNode","targetNode"]},{fields:["stroke"],shape:"key"}],translate:[{fields:["sourceNode","targetNode"]}]}},combo:{style:{collapsedMarkerFill:e,collapsedMarkerFontSize:12,collapsedMarkerFillOpacity:1,collapsedSize:32,collapsedFillOpacity:1,fill:p,halo:!1,haloLineWidth:12,haloStroke:y,haloStrokeOpacity:.25,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[2,4,2,4],labelFill:t,labelFontSize:12,labelFontWeight:400,labelOpacity:1,lineDash:0,lineWidth:1,fillOpacity:.04,strokeOpacity:1,padding:10,stroke:y},state:{selected:{halo:!0,labelFontSize:14,labelFontWeight:700,lineWidth:4},active:{halo:!0},highlight:{labelFontWeight:700,lineWidth:4},inactive:{fillOpacity:.65,labelOpacity:.25,strokeOpacity:.65},disabled:{fill:v,fillOpacity:.25,labelOpacity:.25,stroke:m,strokeOpacity:.25}},animation:{enter:"fade",exit:"fade",show:"fade",hide:"fade",expand:"combo-expand",collapse:"combo-collapse",update:[{fields:["x","y"]},{fields:["fill","stroke","lineWidth"],shape:"key"}],translate:[{fields:["x","y"]}]}}}}const zae=IU({bgColor:"#000000",comboColor:"#fdfdfd",comboColorDisabled:"#d0e4ff",comboStroke:"#99add1",comboStrokeDisabled:"#969696",edgeColor:"#637088",edgeColorDisabled:"#637088",edgeColorInactive:"#D0E4FF",edgePaletteOptions:{type:"group",color:["#637088","#0F55A6","#008383","#9C5D38","#8B53A6","#4E40A6","#8F6608","#3E801D","#A65383","#175E75","#0F8248"]},nodeColor:"#1783ff",nodeColorDisabled:"#D0E4FF",nodeHaloStrokeOpacityActive:.25,nodeHaloStrokeOpacitySelected:.45,nodeIconOpacityInactive:.45,nodeOpacityDisabled:.25,nodeOpacityInactive:.45,nodeStroke:"#d0e4ff",textColor:"#ffffff"}),Vae=IU({bgColor:"#ffffff",comboColor:"#99ADD1",comboColorDisabled:"#f0f0f0",comboStroke:"#99add1",comboStrokeDisabled:"#d9d9d9",edgeColor:"#99add1",edgeColorDisabled:"#d9d9d9",edgeColorInactive:"#1B324F",nodeColor:"#1783ff",nodeColorDisabled:"#1B324F",nodeHaloStrokeOpacityActive:.15,nodeHaloStrokeOpacitySelected:.25,nodeIconOpacityInactive:.85,nodeOpacityDisabled:.06,nodeOpacityInactive:.25,nodeStroke:"#000000",textColor:"#000000"});class fs extends Jp{beforeDraw(e,t){return e}afterLayout(e,t){}}class jae extends fs{beforeDraw(e){const{model:t}=this.context,n=e.add.combos,i=a=>{const s=[];return a.forEach((o,A)=>{const c=t.getAncestorsData(A,"combo").map(u=>Y(u)).reverse();s.push([A,o,c.length])}),new Map(s.sort(([,,o],[,,A])=>A-o).map(([o,A])=>[o,A]))};return e.add.combos=i(n),e.update.combos=i(e.update.combos),e}}function Vr(r,e,t,n,i){const a=Y(n),s=`${t}s`,o=i?n:r.add[s].get(a)||r.update[s].get(a)||r.remove[s].get(a)||n;Object.entries(r).forEach(([A,l])=>{e===A?l[s].set(a,o):l[s].delete(a)})}function mf(r,e){return Object.keys(r).every(t=>r[t]===e[t])}class Wae extends fs{beforeDraw(e,t){if(t.stage==="visibility"||!this.context.model.model.hasTreeStructure(Ft))return e;const{model:n}=this.context,{add:i,update:a}=e,s=[...e.update.combos.entries(),...e.add.combos.entries()];for(;s.length;){const[o,A]=s.pop();if(Fr(A)){const l=n.getDescendantsData(o),c=l.map(Y),{internal:u,external:h}=mv(c,d=>n.getRelatedEdgesData(d));l.forEach(d=>{const f=Y(d),g=s.findIndex(([v])=>v===f);g!==-1&&s.splice(g,1);const p=n.getElementType(f);Vr(e,"remove",p,d)}),u.forEach(d=>Vr(e,"remove","edge",d)),h.forEach(d=>{var f;const g=Y(d);((f=this.context.element)===null||f===void 0?void 0:f.getElement(g))?a.edges.set(g,d):i.edges.set(g,d)})}else{const l=n.getChildrenData(o),c=l.map(Y),{edges:u}=mv(c,h=>n.getRelatedEdgesData(h));[...l,...u].forEach(h=>{var d;const f=Y(h),g=n.getElementType(f);((d=this.context.element)===null||d===void 0?void 0:d.getElement(f))?Vr(e,"update",g,h):Vr(e,"add",g,h),g==="combo"&&s.push([f,h])})}}return e}}const _U=(r,e,t,n)=>{const i=`${t}s`,a=Y(n);!r.add[i].has(a)&&!r.update[i].has(a)&&r[e][i].set(Y(n),n)};class qae extends fs{getElement(e){return this.context.element.getElement(e)}handleExpand(e,t){if(_U(t,"add","node",e),Fr(e))return;const n=Y(e);_U(t,"add","node",e),this.context.model.getRelatedEdgesData(n).forEach(s=>{Vr(t,"add","edge",s)}),this.context.model.getChildrenData(n).forEach(s=>{this.handleExpand(s,t)})}beforeDraw(e){const{graph:t,model:n}=this.context;if(!n.model.hasTreeStructure(Rr))return e;const{add:{nodes:i,edges:a},update:{nodes:s}}=e,o=new Map,A=new Map;i.forEach((c,u)=>{Fr(c)&&o.set(u,c)}),a.forEach(c=>{if(t.getElementType(c.source)!=="node")return;const u=t.getNodeData(c.source);Fr(u)&&o.set(c.source,u)}),s.forEach((c,u)=>{const h=this.getElement(u);if(!h)return;const d=h.attributes.collapsed;Fr(c)?d||o.set(u,c):d&&A.set(u,c)});const l=new Set;return o.forEach((c,u)=>{n.getDescendantsData(u).forEach(d=>{const f=Y(d);if(l.has(f))return;Vr(e,"remove","node",d),n.getRelatedEdgesData(f).forEach(p=>{Vr(e,"remove","edge",p)}),l.add(f)})}),A.forEach((c,u)=>{if(n.getAncestorsData(u,Rr).some(Fr)){Vr(e,"remove","node",c);return}this.handleExpand(c,e)}),e}}function $ae(r,e,t){Wp[r][e]&&$i.warn(`The extension ${e} of ${r} has been registered before, and will be overridden.`),Object.assign(Wp[r],{[e]:t})}var kU=(function(){function r(e){ce(this,r),this.dragndropPluginOptions=e}return ue(r,[{key:"apply",value:function(t){var n=this,i=t.renderingService,a=t.renderingContext,s=a.root.ownerDocument,o=s.defaultView,A=function(c){var u=c.target,h=u===s,d=h&&n.dragndropPluginOptions.isDocumentDraggable?s:u.closest&&u.closest("[draggable=true]");if(d){var f=!1,g=c.timeStamp,p=[c.clientX,c.clientY],v=null,y=[c.clientX,c.clientY],m=(function(){var C=La(kn().mark(function S(F){var T,O,I,k,N,U;return kn().wrap(function(H){for(;;)switch(H.prev=H.next){case 0:if(f){H.next=2;break}if(T=F.timeStamp-g,O=wr([F.clientX,F.clientY],p),!(T<=n.dragndropPluginOptions.dragstartTimeThreshold||O<=n.dragndropPluginOptions.dragstartDistanceThreshold)){H.next=1;break}return H.abrupt("return");case 1:F.type="dragstart",d.dispatchEvent(F),f=!0;case 2:if(F.type="drag",F.dx=F.clientX-y[0],F.dy=F.clientY-y[1],d.dispatchEvent(F),y=[F.clientX,F.clientY],h){H.next=4;break}return I=n.dragndropPluginOptions.overlap==="pointer"?[F.canvasX,F.canvasY]:u.getBounds().center,H.next=3,s.elementsFromPoint(I[0],I[1]);case 3:k=H.sent,N=k[k.indexOf(u)+1],U=N?.closest("[droppable=true]")||(n.dragndropPluginOptions.isDocumentDroppable?s:null),v!==U&&(v&&(F.type="dragleave",F.target=v,v.dispatchEvent(F)),U&&(F.type="dragenter",F.target=U,U.dispatchEvent(F)),v=U,v&&(F.type="dragover",F.target=v,v.dispatchEvent(F)));case 4:case"end":return H.stop()}},S)}));return function(F){return C.apply(this,arguments)}})();o.addEventListener("pointermove",m);var b=function(S){if(f){S.detail={preventClick:!0};var F=S.clone();v&&(F.type="drop",F.target=v,v.dispatchEvent(F)),F.type="dragend",d.dispatchEvent(F),f=!1}o.removeEventListener("pointermove",m)};u.addEventListener("pointerup",b,{once:!0}),u.addEventListener("pointerupoutside",b,{once:!0})}};i.hooks.init.tap(r.tag,function(){o.addEventListener("pointerdown",A)}),i.hooks.destroy.tap(r.tag,function(){o.removeEventListener("pointerdown",A)})}}])})();kU.tag="Dragndrop";var Yae=(function(r){function e(){var t,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return ce(this,e),t=qe(this,e),t.name="dragndrop",t.options=n,t}return $e(e,r),ue(e,[{key:"init",value:function(){this.addRenderingPlugin(new kU(He({overlap:"pointer",isDocumentDraggable:!1,isDocumentDroppable:!1,dragstartDistanceThreshold:0,dragstartTimeThreshold:0},this.options)))}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}},{key:"setOptions",value:function(n){Object.assign(this.plugins[0].dragndropPluginOptions,n)}}])})(Ua),NU=function(r,e,t,n){function i(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(c){try{l(n.next(c))}catch(u){s(u)}}function A(c){try{l(n.throw(c))}catch(u){s(u)}}function l(c){c.done?a(c.value):i(c.value).then(o,A)}l((n=n.apply(r,e||[])).next())})},LU=function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t};const QU=["main"],UU=["background","main","label","transient"];function Xae(r){return r.main}class PU{getConfig(){return this.config}getLayer(e="main"){return this.extends.layers[e]||Xae(this.getLayers())}getLayers(){return this.extends.layers}getRenderer(e){return this.extends.renderers[e]}getCamera(e="main"){return this.getLayer(e).getCamera()}getRoot(e="main"){return this.getLayer(e).getRoot()}getContextService(e="main"){return this.getLayer(e).getContextService()}setCursor(e){this.config.cursor=e,this.getLayer().setCursor(e)}get document(){return this.getLayer().document}get context(){return this.getLayer().context}constructor(e){this.config={enableMultiLayer:!0},Object.assign(this.config,e);const t=this.config,{renderer:n,background:i,cursor:a,enableMultiLayer:s}=t,o=LU(t,["renderer","background","cursor","enableMultiLayer"]),A=s?UU:QU,l=DU(n,A),c=Object.fromEntries(A.map(u=>{const h=new Wg(Object.assign(Object.assign({},o),{supportsMutipleCanvasesInOneContainer:s,renderer:l[u],background:s?u==="background"?i:void 0:i}));return[u,h]}));RU(c),this.extends={config:this.config,renderer:n,renderers:l,layers:c}}get ready(){return Promise.all(Object.entries(this.getLayers()).map(([,e])=>e.ready))}resize(e,t){Object.assign(this.extends.config,{width:e,height:t}),Object.values(this.getLayers()).forEach(n=>{const i=n.getCamera(),a=i.getPosition(),s=i.getFocalPoint();n.resize(e,t),i.setPosition(a),i.setFocalPoint(s)})}getBounds(e){return dl(Object.values(this.getLayers()).map(t=>e?t.getRoot().childNodes.find(i=>i.classList.includes(e)):t.getRoot()).filter(t=>t?.childNodes.length>0).map(t=>t.getBounds()))}getContainer(){const e=this.extends.config.container;return typeof e=="string"?document.getElementById(e):e}getSize(){return[this.extends.config.width||0,this.extends.config.height||0]}appendChild(e,t){var n;const i=((n=e.style)===null||n===void 0?void 0:n.$layer)||"main";return this.getLayer(i).appendChild(e,t)}setRenderer(e){if(e===this.extends.renderer)return;const t=DU(e,this.config.enableMultiLayer?UU:QU);this.extends.renderers=t,Object.entries(t).forEach(([n,i])=>this.getLayer(n).setRenderer(i)),RU(this.getLayers())}getCanvasByViewport(e){return zn(this.getLayer().viewport2Canvas(Ei(e)))}getViewportByCanvas(e){return zn(this.getLayer().canvas2Viewport(Ei(e)))}getViewportByClient(e){return zn(this.getLayer().client2Viewport(Ei(e)))}getClientByViewport(e){return zn(this.getLayer().viewport2Client(Ei(e)))}getClientByCanvas(e){return this.getClientByViewport(this.getViewportByCanvas(e))}getCanvasByClient(e){const t=this.getLayer(),n=t.client2Viewport(Ei(e));return zn(t.viewport2Canvas(n))}toDataURL(){return NU(this,arguments,void 0,function*(e={}){const t=globalThis.devicePixelRatio||1,{mode:n="viewport"}=e,i=LU(e,["mode"]);let[a,s,o,A]=[0,0,0,0];if(n==="viewport")[o,A]=this.getSize();else if(n==="overall"){const v=this.getBounds(),y=qa(v);[a,s]=v.min,[o,A]=y}const l=og('<div id="virtual-image"></div>'),c=new Wg({width:o,height:A,renderer:new bl,devicePixelRatio:t,container:l,background:this.extends.config.background});yield c.ready,c.appendChild(this.getLayer("background").getRoot().cloneNode(!0)),c.appendChild(this.getRoot().cloneNode(!0));const u=this.getLayer("label").getRoot().cloneNode(!0),h=c.viewport2Canvas({x:0,y:0}),d=this.getCanvasByViewport([0,0]);u.translate([d[0]-h.x,d[1]-h.y]),u.scale(1/this.getCamera().getZoom()),c.appendChild(u),c.appendChild(this.getLayer("transient").getRoot().cloneNode(!0));const f=this.getCamera(),g=c.getCamera();if(n==="viewport")g.setZoom(f.getZoom()),g.setPosition(f.getPosition()),g.setFocalPoint(f.getFocalPoint());else if(n==="overall"){const[v,y,m]=g.getPosition(),[b,C,S]=g.getFocalPoint();g.setPosition([v+a,y+s,m]),g.setFocalPoint([b+a,C+s,S])}const p=c.getContextService();return new Promise(v=>{c.addEventListener(Lr.RERENDER,()=>NU(this,void 0,void 0,function*(){yield new Promise(m=>setTimeout(m,300));const y=yield p.toDataURL(i);v(y)}))})})}destroy(){Object.values(this.getLayers()).forEach(e=>{e.getCamera().cancelLandmarkAnimation(),e.destroy()})}}function DU(r,e){return Object.fromEntries(e.map(t=>{const n=r?.(t)||new bl;return n instanceof bl&&n.setConfig({enableDirtyRectangleRendering:!1}),t==="main"?n.registerPlugin(new Yae({isDocumentDraggable:!0,isDocumentDroppable:!0,dragstartDistanceThreshold:10,dragstartTimeThreshold:100})):n.unregisterPlugin(n.getPlugin("dom-interaction")),[t,n]}))}function RU(r){Object.entries(r).forEach(([e,t])=>{const n=t.getContextService().getDomElement();n?.style&&(n.style.gridArea="1 / 1 / 2 / 2",n.style.outline="none",n.tabIndex=1,e!=="main"&&(n.style.pointerEvents="none")),n?.parentElement&&(n.parentElement.style.display="grid",n.parentElement.style.isolation="isolate")})}const dA=r=>r?parseInt(r):0;function Zae(r){const e=getComputedStyle(r),t=r.clientWidth||dA(e.width),n=r.clientHeight||dA(e.height),i=dA(e.paddingLeft)+dA(e.paddingRight),a=dA(e.paddingTop)+dA(e.paddingBottom);return[t-i,n-a]}function HU(r){if(!r)return[0,0];let e=640,t=480;const[n,i]=Zae(r);e=n||e,t=i||t;const a=1,s=1;return[Math.max(Ee(e)?e:a,a),Math.max(Ee(t)?t:s,s)]}class wf{constructor(e){this.type=e}}class xn extends wf{constructor(e,t){super(e),this.data=t}}class ci extends wf{constructor(e,t,n,i){super(e),this.animationType=t,this.animation=n,this.data=i}}class fA extends wf{constructor(e,t,n){super(e),this.elementType=t,this.data=n}}class bf extends wf{constructor(e,t){super(e),this.data=t}}function On(r,e){r.emit(e.type,e)}function Jae(r){if(!r)return null;if(r instanceof Jx)return{type:"canvas",element:r};let e=r;for(;e;){if(El(e))return{type:"node",element:e};if(MF(e))return{type:"edge",element:e};if(wv(e))return{type:"combo",element:e};e=e.parentElement}return null}function GU(r){var e;return((e=r?.style)===null||e===void 0?void 0:e.zIndex)||0}const tc="cachedStyle",SB=r=>`__${r}__`;function ese(r,e){const t=Array.isArray(e)?e:[e];Rn(r,tc)||xA(r,tc,{}),t.forEach(n=>{xA(Rn(r,tc),SB(n),r.attributes[n])})}function KU(r,e){return Rn(r,[tc,SB(e)])}function tse(r,e){return SB(e)in(Rn(r,tc)||{})}class nse{constructor(e){this.tasks=[],this.animations=new Set,this.context=e}getTasks(){const e=[...this.tasks];return this.tasks=[],e}add(e,t){this.tasks.push([e,t])}animate(e,t,n){var i,a,s;(i=t?.before)===null||i===void 0||i.call(t);const o=this.getTasks().map(([l,c])=>{var u,h,d;const{element:f,elementType:g,stage:p}=l,v=EV(this.context.options,g,p,e);(u=c?.before)===null||u===void 0||u.call(c);const y=v.length?CV(f,this.inferStyle(l,n),v):null;return y?((h=c?.beforeAnimate)===null||h===void 0||h.call(c,y),y.finished.then(()=>{var m,b;(m=c?.afterAnimate)===null||m===void 0||m.call(c,y),(b=c?.after)===null||b===void 0||b.call(c),this.animations.delete(y)})):(d=c?.after)===null||d===void 0||d.call(c),y}).filter(Boolean);o.forEach(l=>this.animations.add(l));const A=qp(o);return A?((a=t?.beforeAnimate)===null||a===void 0||a.call(t,A),A.finished.then(()=>{var l,c;(l=t?.afterAnimate)===null||l===void 0||l.call(t,A),(c=t?.after)===null||c===void 0||c.call(t),this.release()})):(s=t?.after)===null||s===void 0||s.call(t),A}inferStyle(e,t){var n,i;const{element:a,elementType:s,stage:o,originalStyle:A,updatedStyle:l={}}=e;e.modifiedStyle||(e.modifiedStyle=Object.assign(Object.assign({},A),l));const{modifiedStyle:c}=e,u={},h={};if(o==="enter")Object.assign(u,{opacity:0});else if(o==="exit")Object.assign(h,{opacity:0});else if(o==="show")Object.assign(u,{opacity:0}),Object.assign(h,{opacity:(n=KU(a,"opacity"))!==null&&n!==void 0?n:hl("opacity")});else if(o==="hide")Object.assign(u,{opacity:(i=KU(a,"opacity"))!==null&&i!==void 0?i:hl("opacity")}),Object.assign(h,{opacity:0});else if(o==="collapse"){const{collapse:d}=t||{},{target:f,descendants:g,position:p}=d;if(s==="node"){if(g.includes(a.id)){const[v,y,m]=p;Object.assign(h,{x:v,y,z:m})}}else if(s==="combo"){if(a.id===f||g.includes(a.id)){const[v,y]=p;Object.assign(h,{x:v,y,childrenNode:A.childrenNode})}}else s==="edge"&&Object.assign(h,{sourceNode:c.sourceNode,targetNode:c.targetNode})}else if(o==="expand"){const{expand:d}=t||{},{target:f,descendants:g,position:p}=d;if(s==="node"){if(a.id===f||g.includes(a.id)){const[v,y,m]=p;Object.assign(u,{x:v,y,z:m})}}else if(s==="combo"){if(a.id===f||g.includes(a.id)){const[v,y,m]=p;Object.assign(u,{x:v,y,z:m,childrenNode:c.childrenNode})}}else s==="edge"&&Object.assign(u,{sourceNode:c.sourceNode,targetNode:c.targetNode})}return[Object.keys(u).length>0?Object.assign({},A,u):A,Object.keys(h).length>0?Object.assign({},c,h):c]}stop(){this.animations.forEach(e=>e.cancel())}clear(){this.tasks=[]}release(){var e,t;const{canvas:n}=this.context,i=(t=(e=n.document)===null||e===void 0?void 0:e.timeline)===null||t===void 0?void 0:t.animationsWithPromises;i&&(n.document.timeline.animationsWithPromises=i.filter(a=>a.playState!=="finished"))}destroy(){this.stop(),this.animations.clear(),this.tasks=[]}}class rse{constructor(e){this.batchCount=0,this.context=e}emit(e){const{graph:t}=this.context;t.emit(e.type,e)}startBatch(e=!0){this.batchCount++,this.batchCount===1&&this.emit(new xn(fe.BATCH_START,{initiate:e}))}endBatch(){this.batchCount--,this.batchCount===0&&this.emit(new xn(fe.BATCH_END))}get isBatching(){return this.batchCount>0}destroy(){this.context=null}}class ise extends Zp{constructor(e){super(e),this.currentTarget=null,this.currentTargetType=null,this.category="behavior",this.forwardCanvasEvents=t=>{const{target:n}=t,i=Jae(n);if(!i)return;const{graph:a,canvas:s}=this.context,{type:o,element:A}=i;if("destroyed"in A&&(Cl(A)||A.destroyed))return;const{type:l,detail:c,button:u}=t,h=Object.assign(Object.assign({},t),{target:A,targetType:o,originalTarget:n});l===re.POINTER_MOVE&&(this.currentTarget!==A&&(this.currentTarget&&a.emit(`${this.currentTargetType}:${re.POINTER_LEAVE}`,Object.assign(Object.assign({},h),{type:re.POINTER_LEAVE,target:this.currentTarget,targetType:this.currentTargetType})),A&&(Object.assign(h,{type:re.POINTER_ENTER}),a.emit(`${o}:${re.POINTER_ENTER}`,h))),this.currentTarget=A,this.currentTargetType=o),l===re.CLICK&&u===2||(a.emit(`${o}:${l}`,h),a.emit(l,h)),l===re.CLICK&&c===2&&(Object.assign(h,{type:re.DBLCLICK}),a.emit(`${o}:${re.DBLCLICK}`,h),a.emit(re.DBLCLICK,h)),l===re.POINTER_DOWN&&u===2&&(Object.assign(h,{type:re.CONTEXT_MENU,preventDefault:()=>{var d;(d=s.getContainer())===null||d===void 0||d.addEventListener(re.CONTEXT_MENU,f=>f.preventDefault(),{once:!0})}}),a.emit(`${o}:${re.CONTEXT_MENU}`,h),a.emit(re.CONTEXT_MENU,h))},this.forwardContainerEvents=t=>{this.context.graph.emit(t.type,t)},this.forwardEvents(),this.setBehaviors(this.context.options.behaviors||[])}setBehaviors(e){this.setExtensions(e)}forwardEvents(){const e=this.context.canvas.getContainer();e&&[Ho.KEY_DOWN,Ho.KEY_UP].forEach(n=>{e.addEventListener(n,this.forwardContainerEvents)});const t=this.context.canvas.document;t&&[re.CLICK,re.DBLCLICK,re.POINTER_OVER,re.POINTER_LEAVE,re.POINTER_ENTER,re.POINTER_MOVE,re.POINTER_OUT,re.POINTER_DOWN,re.POINTER_UP,re.CONTEXT_MENU,re.DRAG_START,re.DRAG,re.DRAG_END,re.DRAG_ENTER,re.DRAG_OVER,re.DRAG_LEAVE,re.DROP,re.WHEEL].forEach(n=>{t.addEventListener(n,this.forwardCanvasEvents)})}destroy(){const e=this.context.canvas.getContainer();e&&[Ho.KEY_DOWN,Ho.KEY_UP].forEach(t=>{e.removeEventListener(t,this.forwardContainerEvents)}),this.context.canvas.document.removeAllEventListeners(),super.destroy()}}var ase=function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t};function FB(r){const{id:e=Y(r),style:t,data:n}=r,i=ase(r,["id","style","data"]),a=Object.assign(Object.assign({},r),{style:Object.assign({},t),data:Object.assign({},n)});return IV(r)?Object.assign({id:e,data:a},i):{id:e,data:a}}function Pn(r){return r.data}function sse(r){if(r.hasTreeStructure(Rr))return;r.attachTreeStructure(Rr);const e=r.getAllEdges();for(const t of e){const{source:n,target:i}=t;r.setParent(i,n,Rr)}}class ose{constructor(){this.latestRemovedComboIds=new Set,this.comboIds=new Set,this.changes=[],this.batchCount=0,this.isTraceless=!1,this.enableUpdateNodeLikeHierarchy=!0,this.model=new Tn}pushChange(e){if(this.isTraceless)return;const{type:t}=e;if(t===Rt.NodeUpdated||t===Rt.EdgeUpdated||t===Rt.ComboUpdated){const{value:n,original:i}=e;this.changes.push({value:Cv(n),original:Cv(i),type:t})}else this.changes.push({value:Cv(e.value),type:t})}getChanges(){return this.changes}clearChanges(){this.changes=[]}batch(e){this.batchCount++,this.model.batch(e),this.batchCount--}isBatching(){return this.batchCount>0}silence(e){this.isTraceless=!0,e(),this.isTraceless=!1}isCombo(e){return this.comboIds.has(e)||this.latestRemovedComboIds.has(e)}getData(){return{nodes:this.getNodeData(),edges:this.getEdgeData(),combos:this.getComboData()}}getNodeData(e){return this.model.getAllNodes().reduce((t,n)=>{const i=Pn(n);return this.isCombo(Y(i))||(e===void 0||e.includes(Y(i)))&&t.push(i),t},[])}getEdgeDatum(e){return Pn(this.model.getEdge(e))}getEdgeData(e){return this.model.getAllEdges().reduce((t,n)=>{const i=Pn(n);return(e===void 0||e.includes(Y(i)))&&t.push(i),t},[])}getComboData(e){return this.model.getAllNodes().reduce((t,n)=>{const i=Pn(n);return this.isCombo(Y(i))&&(e===void 0||e.includes(Y(i)))&&t.push(i),t},[])}getRootsData(e=Rr){return this.model.getRoots(e).map(Pn)}getAncestorsData(e,t){const{model:n}=this;return!n.hasNode(e)||!n.hasTreeStructure(t)?[]:n.getAncestors(e,t).map(Pn)}getDescendantsData(e){const t=this.getElementDataById(e),n=[];return Ko(t,i=>{i!==t&&n.push(i)},i=>this.getChildrenData(Y(i)),"TB"),n}getParentData(e,t){const{model:n}=this;if(!t){$i.warn("The hierarchy structure key is not specified");return}if(!n.hasNode(e)||!n.hasTreeStructure(t))return;const i=n.getParent(e,t);return i?Pn(i):void 0}getChildrenData(e){const t=this.getElementType(e)==="node"?Rr:Ft,{model:n}=this;return!n.hasNode(e)||!n.hasTreeStructure(t)?[]:n.getChildren(e,t).map(Pn)}getElementsDataByType(e){return e==="node"?this.getNodeData():e==="edge"?this.getEdgeData():e==="combo"?this.getComboData():[]}getElementDataById(e){return this.getElementType(e)==="edge"?this.getEdgeDatum(e):this.getNodeLikeDatum(e)}getNodeLikeDatum(e){const t=this.model.getNode(e);return Pn(t)}getNodeLikeData(e){return this.model.getAllNodes().reduce((t,n)=>{const i=Pn(n);return e?e.includes(Y(i))&&t.push(i):t.push(i),t},[])}getElementDataByState(e,t){return this.getElementsDataByType(e).filter(i=>{var a;return(a=i.states)===null||a===void 0?void 0:a.includes(t)})}getElementState(e){var t;return((t=this.getElementDataById(e))===null||t===void 0?void 0:t.states)||[]}hasNode(e){return this.model.hasNode(e)&&!this.isCombo(e)}hasEdge(e){return this.model.hasEdge(e)}hasCombo(e){return this.model.hasNode(e)&&this.isCombo(e)}getRelatedEdgesData(e,t="both"){return this.model.getRelatedEdges(e,t).map(Pn)}getNeighborNodesData(e){return this.model.getNeighbors(e).map(Pn)}setData(e){const{nodes:t=[],edges:n=[],combos:i=[]}=e,{nodes:a,edges:s,combos:o}=this.getData(),A=Xa(a,t,u=>Y(u),Wo),l=Xa(s,n,u=>Y(u),Wo),c=Xa(o,i,u=>Y(u),Wo);this.batch(()=>{const u={nodes:A.enter,edges:l.enter,combos:c.enter};this.addData(u),this.computeZIndex(u,"add",!0);const h={nodes:A.update,edges:l.update,combos:c.update};this.updateData(h),this.computeZIndex(h,"update",!0);const d={nodes:A.exit.map(Y),edges:l.exit.map(Y),combos:c.exit.map(Y)};this.removeData(d)})}addData(e){const{nodes:t,edges:n,combos:i}=e;this.batch(()=>{this.addComboData(i),this.addNodeData(t),this.addEdgeData(n)}),this.computeZIndex(e,"add")}addNodeData(e=[]){e.length&&(this.model.addNodes(e.map(t=>(this.pushChange({value:t,type:Rt.NodeAdded}),FB(t)))),this.updateNodeLikeHierarchy(e),this.computeZIndex({nodes:e},"add"))}addEdgeData(e=[]){e.length&&(this.model.addEdges(e.map(t=>(this.pushChange({value:t,type:Rt.EdgeAdded}),FB(t)))),this.computeZIndex({edges:e},"add"))}addComboData(e=[]){if(!e.length)return;const{model:t}=this;t.hasTreeStructure(Ft)||t.attachTreeStructure(Ft),t.addNodes(e.map(n=>(this.comboIds.add(Y(n)),this.pushChange({value:n,type:Rt.ComboAdded}),FB(n)))),this.updateNodeLikeHierarchy(e),this.computeZIndex({combos:e},"add")}addChildrenData(e,t){const n=this.getNodeLikeDatum(e),i=t.map(Y);this.addNodeData(t),this.updateNodeData([{id:e,children:[...n.children||[],...i]}]),this.addEdgeData(i.map(a=>({source:e,target:a})))}computeZIndex(e,t,n=!1){!n&&this.isBatching()||this.batch(()=>{const{nodes:i=[],edges:a=[],combos:s=[]}=e;s.forEach(o=>{var A,l,c;const u=Y(o);if(t==="add"&&Ee((A=o.style)===null||A===void 0?void 0:A.zIndex)||t==="update"&&!("combo"in o))return;const h=this.getParentData(u,Ft),d=h?((c=(l=h.style)===null||l===void 0?void 0:l.zIndex)!==null&&c!==void 0?c:0)+1:0;this.preventUpdateNodeLikeHierarchy(()=>{this.updateComboData([{id:u,style:{zIndex:d}}])})}),i.forEach(o=>{var A,l,c;const u=Y(o);if(t==="add"&&Ee((A=o.style)===null||A===void 0?void 0:A.zIndex)||t==="update"&&!("combo"in o)&&!("children"in o))return;let h=0;const d=this.getParentData(u,Ft);if(d)h=(((l=d.style)===null||l===void 0?void 0:l.zIndex)||0)+1;else{const f=this.getParentData(u,Rr);f&&(h=((c=f?.style)===null||c===void 0?void 0:c.zIndex)||0)}this.preventUpdateNodeLikeHierarchy(()=>{this.updateNodeData([{id:u,style:{zIndex:h}}])})}),a.forEach(o=>{var A,l,c,u,h;if(Ee((A=o.style)===null||A===void 0?void 0:A.zIndex))return;let{id:d,source:f,target:g}=o;if(!d)d=Y(o);else{const y=this.getEdgeDatum(d);f=y.source,g=y.target}if(!f||!g)return;const p=((c=(l=this.getNodeLikeDatum(f))===null||l===void 0?void 0:l.style)===null||c===void 0?void 0:c.zIndex)||0,v=((h=(u=this.getNodeLikeDatum(g))===null||u===void 0?void 0:u.style)===null||h===void 0?void 0:h.zIndex)||0;this.updateEdgeData([{id:Y(o),style:{zIndex:Math.max(p,v)-1}}])})})}getFrontZIndex(e){var t;const n=this.getElementType(e),i=this.getElementDataById(e),a=this.getData();if(Object.assign(a,{[`${n}s`]:a[`${n}s`].filter(s=>Y(s)!==e)}),n==="combo"&&!Fr(i)){const s=new Set(this.getAncestorsData(e,Ft).map(Y));a.nodes=a.nodes.filter(o=>!s.has(Y(o))),a.combos=a.combos.filter(o=>!s.has(Y(o))),a.edges=a.edges.filter(({source:o,target:A})=>!s.has(o)&&!s.has(A))}return Math.max(((t=i.style)===null||t===void 0?void 0:t.zIndex)||0,0,...Object.values(a).flat().map(s=>{var o;return(((o=s?.style)===null||o===void 0?void 0:o.zIndex)||0)+1}))}updateNodeLikeHierarchy(e){if(!this.enableUpdateNodeLikeHierarchy)return;const{model:t}=this;e.forEach(n=>{const i=Y(n),a=ih(n);a!==void 0&&(t.hasTreeStructure(Ft)||t.attachTreeStructure(Ft),a===null&&this.refreshComboData(i),this.setParent(i,ih(n),Ft));const s=n.children||[];if(s.length){t.hasTreeStructure(Rr)||t.attachTreeStructure(Rr);const o=s.filter(A=>t.hasNode(A));o.forEach(A=>this.setParent(A,i,Rr)),o.length!==s.length&&this.updateNodeData([{id:i,children:o}])}})}preventUpdateNodeLikeHierarchy(e){this.enableUpdateNodeLikeHierarchy=!1,e(),this.enableUpdateNodeLikeHierarchy=!0}updateData(e){const{nodes:t,edges:n,combos:i}=e;this.batch(()=>{this.updateNodeData(t),this.updateComboData(i),this.updateEdgeData(n)}),this.computeZIndex(e,"update")}updateNodeData(e=[]){if(!e.length)return;const{model:t}=this;this.batch(()=>{const n=[];e.forEach(i=>{const a=Y(i),s=Pn(t.getNode(a));if(Wo(s,i))return;const o=is(s,i);this.pushChange({value:o,original:s,type:Rt.NodeUpdated}),t.mergeNodeData(a,o),n.push(o)}),this.updateNodeLikeHierarchy(n)}),this.computeZIndex({nodes:e},"update")}refreshData(){const{nodes:e,edges:t,combos:n}=this.getData();e.forEach(i=>{this.pushChange({value:i,original:i,type:Rt.NodeUpdated})}),t.forEach(i=>{this.pushChange({value:i,original:i,type:Rt.EdgeUpdated})}),n.forEach(i=>{this.pushChange({value:i,original:i,type:Rt.ComboUpdated})})}syncNodeLikeDatum(e){const{model:t}=this,n=Y(e);if(!t.hasNode(n))return;const i=Pn(t.getNode(n)),a=is(i,e);t.mergeNodeData(n,a)}syncEdgeDatum(e){const{model:t}=this,n=Y(e);if(!t.hasEdge(n))return;const i=Pn(t.getEdge(n)),a=is(i,e);t.mergeEdgeData(n,a)}updateEdgeData(e=[]){if(!e.length)return;const{model:t}=this;this.batch(()=>{e.forEach(n=>{const i=Y(n),a=Pn(t.getEdge(i));if(Wo(a,n))return;n.source&&a.source!==n.source&&t.updateEdgeSource(i,n.source),n.target&&a.target!==n.target&&t.updateEdgeTarget(i,n.target);const s=is(a,n);this.pushChange({value:s,original:a,type:Rt.EdgeUpdated}),t.mergeEdgeData(i,s)})}),this.computeZIndex({edges:e},"update")}updateComboData(e=[]){if(!e.length)return;const{model:t}=this;t.batch(()=>{const n=[];e.forEach(i=>{const a=Y(i),s=Pn(t.getNode(a));if(Wo(s,i))return;const o=is(s,i);this.pushChange({value:o,original:s,type:Rt.ComboUpdated}),t.mergeNodeData(a,o),n.push(o)}),this.updateNodeLikeHierarchy(n)}),this.computeZIndex({combos:e},"update")}setParent(e,t,n,i=!0){if(e===t)return;const a=this.getNodeLikeDatum(e),s=ih(a);if(s!==t&&n===Ft){const o={id:e,combo:t};this.isCombo(e)?this.syncNodeLikeDatum(o):this.syncNodeLikeDatum(o)}this.model.setParent(e,t,n),i&&n===Ft&&bD([s,t]).forEach(o=>{o!==void 0&&this.refreshComboData(o)})}refreshComboData(e){const t=this.getComboData([e])[0],n=this.getAncestorsData(e,Ft);t&&this.pushChange({value:t,original:t,type:Rt.ComboUpdated}),n.forEach(i=>{this.pushChange({value:i,original:i,type:Rt.ComboUpdated})})}getElementPosition(e){const t=this.getElementDataById(e);return Fn(t)}translateNodeLikeBy(e,t){this.isCombo(e)?this.translateComboBy(e,t):this.translateNodeBy(e,t)}translateNodeLikeTo(e,t){this.isCombo(e)?this.translateComboTo(e,t):this.translateNodeTo(e,t)}translateNodeBy(e,t){const n=this.getElementPosition(e),i=je(n,[...t,0].slice(0,3));this.translateNodeTo(e,i)}translateNodeTo(e,t){const[n=0,i=0,a=0]=t;this.preventUpdateNodeLikeHierarchy(()=>{this.updateNodeData([{id:e,style:{x:n,y:i,z:a}}])})}translateComboBy(e,t){const[n=0,i=0,a=0]=t;if([n,i,a].some(isNaN)||[n,i,a].every(A=>A===0))return;const s=this.getComboData([e])[0];if(!s)return;const o=new Set;Ko(s,A=>{const l=Y(A);if(o.has(l))return;o.add(l);const[c,u,h]=Fn(A),d=is(A,{style:{x:c+n,y:u+i,z:h+a}});this.pushChange({value:d,original:A,type:this.isCombo(l)?Rt.ComboUpdated:Rt.NodeUpdated}),this.model.mergeNodeData(l,d)},A=>this.getChildrenData(Y(A)),"BT")}translateComboTo(e,t){var n;if(t.some(isNaN))return;const[i=0,a=0,s=0]=t,o=(n=this.getComboData([e]))===null||n===void 0?void 0:n[0];if(!o)return;const[A,l,c]=Fn(o),u=i-A,h=a-l,d=s-c;Ko(o,f=>{const g=Y(f),[p,v,y]=Fn(f),m=is(f,{style:{x:p+u,y:v+h,z:y+d}});this.pushChange({value:m,original:f,type:this.isCombo(g)?Rt.ComboUpdated:Rt.NodeUpdated}),this.model.mergeNodeData(g,m)},f=>this.getChildrenData(Y(f)),"BT")}removeData(e){const{nodes:t,edges:n,combos:i}=e;this.batch(()=>{this.removeEdgeData(n),this.removeNodeData(t),this.removeComboData(i),this.latestRemovedComboIds=new Set(i)})}removeNodeData(e=[]){e.length&&this.batch(()=>{e.forEach(t=>{this.removeEdgeData(this.getRelatedEdgesData(t).map(Y)),this.pushChange({value:this.getNodeData([t])[0],type:Rt.NodeRemoved}),this.removeNodeLikeHierarchy(t)}),this.model.removeNodes(e)})}removeEdgeData(e=[]){e.length&&(e.forEach(t=>this.pushChange({value:this.getEdgeData([t])[0],type:Rt.EdgeRemoved})),this.model.removeEdges(e))}removeComboData(e=[]){e.length&&this.batch(()=>{e.forEach(t=>{this.pushChange({value:this.getComboData([t])[0],type:Rt.ComboRemoved}),this.removeNodeLikeHierarchy(t),this.comboIds.delete(t)}),this.model.removeNodes(e)})}removeNodeLikeHierarchy(e){if(this.model.hasTreeStructure(Ft)){const t=ih(this.getNodeLikeDatum(e));this.setParent(e,void 0,Ft,!1),this.model.getChildren(e,Ft).forEach(n=>{const i=Pn(n),a=Y(i);this.setParent(Y(i),t,Ft,!1);const s=is(i,{id:Y(i),combo:t});this.pushChange({value:s,original:i,type:this.isCombo(a)?Rt.ComboUpdated:Rt.NodeUpdated}),this.model.mergeNodeData(Y(i),s)}),Ne(t)||this.refreshComboData(t)}}getElementType(e){if(this.model.hasNode(e))return this.isCombo(e)?"combo":"node";if(this.model.hasEdge(e))return"edge";throw new Error(da(`Unknown element type of id: ${e}`))}destroy(){const{model:e}=this,t=e.getAllNodes(),n=e.getAllEdges();e.removeEdges(n.map(i=>i.id)),e.removeNodes(t.map(i=>i.id)),this.context={}}}var gA=function(r,e,t,n){function i(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(c){try{l(n.next(c))}catch(u){s(u)}}function A(c){try{l(n.throw(c))}catch(u){s(u)}}function l(c){c.done?a(c.value):i(c.value).then(o,A)}l((n=n.apply(r,e||[])).next())})};class Ase{constructor(e){this.elementMap={},this.shapeTypeMap={},this.paletteStyle={},this.defaultStyle={},this.stateStyle={},this.visibilityCache=new WeakMap,this.context=e}init(){this.initContainer()}initContainer(){if(!this.container||this.container.destroyed){const{canvas:e}=this.context;this.container=e.appendChild(new Cn({className:"elements"}))}}emit(e,t){t.silence||On(this.context.graph,e)}forEachElementData(e){Vs.forEach(t=>{const n=this.context.model.getElementsDataByType(t);e(t,n)})}getElementType(e,t){var n;const{options:i,graph:a}=this.context,s=QF(t)&&((n=i[e])===null||n===void 0?void 0:n.type)||t.type;return s?typeof s=="string"?s:s.call(a,t):e==="edge"?"line":"circle"}getTheme(e){return vS(this.context.options)[e]||{}}getThemeStyle(e){return this.getTheme(e).style||{}}getThemeStateStyle(e,t){const{state:n={}}=this.getTheme(e);return Object.assign({},...t.map(i=>n[i]||{}))}computePaletteStyle(){const{options:e}=this.context;this.paletteStyle={},this.forEachElementData((t,n)=>{var i,a;const s=Object.assign({},qS((i=this.getTheme(t))===null||i===void 0?void 0:i.palette),qS((a=e[t])===null||a===void 0?void 0:a.palette));s?.field&&Object.assign(this.paletteStyle,Cj(n,s))})}getPaletteStyle(e,t){const n=this.paletteStyle[t];return n?e==="edge"?{stroke:n}:{fill:n}:{}}computeElementDefaultStyle(e,t){var n;const{options:i}=this.context,a=((n=i[e])===null||n===void 0?void 0:n.style)||{};"transform"in a&&Array.isArray(a.transform)&&(a.transform=[...a.transform]),this.defaultStyle[Y(t.datum)]=WS(a,t)}computeElementsDefaultStyle(e){const{graph:t}=this.context;this.forEachElementData((n,i)=>{const a=i.length;for(let s=0;s<a;s++){const o=i[s];(e===void 0||e.includes(Y(o)))&&this.computeElementDefaultStyle(n,{datum:o,graph:t})}})}getDefaultStyle(e){return this.defaultStyle[e]||{}}getElementState(e){try{const{model:t}=this.context;return t.getElementState(e)}catch{return[]}}getElementStateStyle(e,t,n){var i,a;const{options:s}=this.context,o=((a=(i=s[e])===null||i===void 0?void 0:i.state)===null||a===void 0?void 0:a[t])||{};return WS(o,n)}computeElementStatesStyle(e,t,n){this.stateStyle[Y(n.datum)]=Object.assign({},...t.map(i=>this.getElementStateStyle(e,i,n)))}computeElementsStatesStyle(e){const{graph:t}=this.context;this.forEachElementData((n,i)=>{const a=i.length;for(let s=0;s<a;s++){const o=i[s];if(e===void 0||e.includes(Y(o))){const A=this.getElementState(Y(o));this.computeElementStatesStyle(n,A,{datum:o,graph:t})}}})}getStateStyle(e){return this.stateStyle[e]||{}}computeStyle(e,t){e&&["translate","zIndex"].includes(e)||(this.computePaletteStyle(),this.computeElementsDefaultStyle(t),this.computeElementsStatesStyle(t))}getElement(e){return this.elementMap[e]}getNodes(){return this.context.model.getNodeData().map(({id:e})=>this.elementMap[e])}getEdges(){return this.context.model.getEdgeData().map(e=>this.elementMap[Y(e)])}getCombos(){return this.context.model.getComboData().map(({id:e})=>this.elementMap[e])}getElementComputedStyle(e,t){const n=Y(t),i=this.getThemeStyle(e),a=this.getPaletteStyle(e,n),s=t.style||{},o=this.getDefaultStyle(n),A=this.getThemeStateStyle(e,this.getElementState(n)),l=this.getStateStyle(n),c=QF(t)?Object.assign({},i,a,s,o,A,l):Object.assign({},s);if(e==="combo"){const u=this.context.model.getChildrenData(n),d=!!c.collapsed?[]:u.map(Y).filter(f=>this.getElement(f));Object.assign(c,{childrenNode:d,childrenData:u})}return c}getDrawData(e){this.init();const t=this.computeChangesAndDrawData(e);if(!t)return null;const{type:n="draw",stage:i=n}=e;return this.markDestroyElement(t.drawData),this.computeStyle(i),{type:n,stage:i,data:t}}draw(e={animation:!0}){const t=this.getDrawData(e);if(!t)return;const{data:{drawData:{add:n,update:i,remove:a}}}=t;return this.destroyElements(a,e),this.createElements(n,e),this.updateElements(i,e),this.setAnimationTask(e,t)}preLayoutDraw(){return gA(this,arguments,void 0,function*(e={animation:!0}){var t,n;const i=this.getDrawData(e);if(!i)return;const{data:{drawData:a}}=i;yield(n=(t=this.context.layout)===null||t===void 0?void 0:t.preLayout)===null||n===void 0?void 0:n.call(t,a);const{add:s,update:o,remove:A}=a;return this.destroyElements(A,e),this.createElements(s,e),this.updateElements(o,e),this.setAnimationTask(e,i)})}setAnimationTask(e,t){const{animation:n,silence:i}=e,{data:{dataChanges:a,drawData:s},stage:o,type:A}=t;return this.context.animation.animate(n,i?{}:{before:()=>this.emit(new xn(fe.BEFORE_DRAW,{dataChanges:a,animation:n,stage:o,render:A==="render"}),e),beforeAnimate:l=>this.emit(new ci(fe.BEFORE_ANIMATE,Sr.DRAW,l,s),e),afterAnimate:l=>this.emit(new ci(fe.AFTER_ANIMATE,Sr.DRAW,l,s),e),after:()=>this.emit(new xn(fe.AFTER_DRAW,{dataChanges:a,animation:n,stage:o,render:A==="render",firstRender:this.context.graph.rendered===!1}),e)})}computeChangesAndDrawData(e){const{model:t}=this.context,n=t.getChanges(),i=Db(n);if(i.length===0)return null;const{NodeAdded:a=[],NodeUpdated:s=[],NodeRemoved:o=[],EdgeAdded:A=[],EdgeUpdated:l=[],EdgeRemoved:c=[],ComboAdded:u=[],ComboUpdated:h=[],ComboRemoved:d=[]}=pc(i,C=>C.type),f=(C,S)=>{const F=[];return C.forEach(T=>{const O=Y(T.value);this.getElement(O)?F.push(T):S.push(T)}),F},g=f(s,a),p=f(l,A),v=f(h,u),y=C=>new Map(C.map(S=>{const F=S.value;return[Y(F),F]})),m={add:{nodes:y(a),edges:y(A),combos:y(u)},update:{nodes:y(g),edges:y(p),combos:y(v)},remove:{nodes:y(o),edges:y(c),combos:y(d)}},b=this.transformData(m,e);return t.clearChanges(),{dataChanges:n,drawData:b}}transformData(e,t){const n=this.context.transform.getTransformInstance();return Object.values(n).reduce((i,a)=>a.beforeDraw(i,t),e)}createElement(e,t,n){var i;const a=Y(t);if(this.getElement(a))return;const o=this.getElementType(e,t),A=this.getElementComputedStyle(e,t),l=ha(e,o);if(!l)return $i.warn(`The element ${o} of ${e} is not registered.`);this.emit(new fA(fe.BEFORE_ELEMENT_CREATE,e,t),n);const c=this.container.appendChild(new l({id:a,context:this.context,style:A}));this.shapeTypeMap[a]=o,this.elementMap[a]=c;const{stage:u="enter"}=n;(i=this.context.animation)===null||i===void 0||i.add({element:c,elementType:e,stage:u,originalStyle:Object.assign({},c.attributes),updatedStyle:A},{after:()=>{var h;this.emit(new fA(fe.AFTER_ELEMENT_CREATE,e,t),n),(h=c.onCreate)===null||h===void 0||h.call(c)}})}createElements(e,t){const{nodes:n,edges:i,combos:a}=e;[["node",n],["combo",a],["edge",i]].forEach(([o,A])=>{A.forEach(l=>this.createElement(o,l,t))})}getUpdateStageStyle(e,t,n){const{stage:i="update"}=n;if(i==="translate")if(e==="node"||e==="combo"){const{style:{x:a=0,y:s=0,z:o=0}={}}=t;return{x:a,y:s,z:o}}else return{};return this.getElementComputedStyle(e,t)}updateElement(e,t,n){var i;const a=Y(t),{stage:s="update"}=n,o=this.getElement(a);if(!o)return()=>null;this.emit(new fA(fe.BEFORE_ELEMENT_UPDATE,e,t),n);const A=this.getElementType(e,t),l=this.getUpdateStageStyle(e,t,n);this.shapeTypeMap[a]!==A&&(o.destroy(),delete this.shapeTypeMap[a],delete this.elementMap[a],this.createElement(e,t,{animation:!1,silence:!0}));const c=s!=="visibility"?s:l.visibility==="hidden"?"hide":"show";c==="hide"&&delete l.visibility,(i=this.context.animation)===null||i===void 0||i.add({element:o,elementType:e,stage:c,originalStyle:Object.assign({},o.attributes),updatedStyle:l},{before:()=>{const u=this.elementMap[a];s!=="collapse"&&xv(u,l),s==="visibility"&&(tse(u,"opacity")||ese(u,"opacity"),this.visibilityCache.set(u,c==="show"?"visible":"hidden"),c==="show"&&Ks(u,"visible"))},after:()=>{var u;const h=this.elementMap[a];s==="collapse"&&xv(h,l),c==="hide"&&Ks(h,this.visibilityCache.get(h)),this.emit(new fA(fe.AFTER_ELEMENT_UPDATE,e,t),n),(u=h.onUpdate)===null||u===void 0||u.call(h)}})}updateElements(e,t){const{nodes:n,edges:i,combos:a}=e;[["node",n],["combo",a],["edge",i]].forEach(([o,A])=>{A.forEach(l=>this.updateElement(o,l,t))})}markDestroyElement(e){Object.values(e.remove).forEach(t=>{t.forEach(n=>{const i=Y(n),a=this.getElement(i);a&&hW(a)})})}destroyElement(e,t,n){var i;const{stage:a="exit"}=n,s=Y(t),o=this.elementMap[s];if(!o)return()=>null;this.emit(new fA(fe.BEFORE_ELEMENT_DESTROY,e,t),n),(i=this.context.animation)===null||i===void 0||i.add({element:o,elementType:e,stage:a,originalStyle:Object.assign({},o.attributes),updatedStyle:{}},{after:()=>{var A;this.clearElement(s),o.destroy(),(A=o.onDestroy)===null||A===void 0||A.call(o),this.emit(new fA(fe.AFTER_ELEMENT_DESTROY,e,t),n)}})}destroyElements(e,t){const{nodes:n,edges:i,combos:a}=e;[["combo",a],["edge",i],["node",n]].forEach(([o,A])=>{A.forEach(l=>this.destroyElement(o,l,t))})}clearElement(e){delete this.paletteStyle[e],delete this.defaultStyle[e],delete this.stateStyle[e],delete this.elementMap[e],delete this.shapeTypeMap[e]}alignLayoutResultToElement(e,t){var n,i;const a=(n=e.nodes)===null||n===void 0?void 0:n.find(s=>Y(s)===t);if(a){const s=Fn(this.context.model.getNodeLikeDatum(t)),o=Fn(a),A=Bt(s,o);(i=e.nodes)===null||i===void 0||i.forEach(l=>{var c,u,h;!((c=l.style)===null||c===void 0)&&c.x&&(l.style.x+=A[0]),!((u=l.style)===null||u===void 0)&&u.y&&(l.style.y+=A[1]),!((h=l.style)===null||h===void 0)&&h.z&&(l.style.z+=A[2]||0)})}}syncLayoutResult(e,t){return gA(this,void 0,void 0,function*(){const{layout:n,model:i}=this.context;if(!n)return;const a=this.context.options.layout,s=A=>Array.isArray(A)?A.map(l=>Object.assign(Object.assign({},l),{preLayout:!0})):Object.assign(Object.assign({},A),{preLayout:!0}),o=yield n.simulate(a?s(a):void 0);t&&this.alignLayoutResultToElement(o,e),i.updateData(o)})}collapseNode(e,t){return gA(this,void 0,void 0,function*(){var n;const{animation:i,align:a}=t;yield this.syncLayoutResult(e,a);const s=this.computeChangesAndDrawData({stage:"collapse",animation:i});if(!s)return;const{drawData:o}=s,{add:A,remove:l,update:c}=o;this.markDestroyElement(o);const u={animation:i,stage:"collapse",data:o};this.destroyElements(l,u),this.createElements(A,u),this.updateElements(c,u),yield(n=this.context.animation.animate(i,{beforeAnimate:h=>this.emit(new ci(fe.BEFORE_ANIMATE,Sr.COLLAPSE,h,o),u),afterAnimate:h=>this.emit(new ci(fe.AFTER_ANIMATE,Sr.COLLAPSE,h,o),u)},{collapse:{target:e,descendants:Array.from(l.nodes).map(([,h])=>Y(h)),position:Fn(c.nodes.get(e))}}))===null||n===void 0?void 0:n.finished})}expandNode(e,t){return gA(this,void 0,void 0,function*(){var n;const{model:i}=this.context,{animation:a,align:s}=t,o=Fn(i.getNodeData([e])[0]);yield this.syncLayoutResult(e,s);const A=this.computeChangesAndDrawData({stage:"expand",animation:a});if(this.createElements(A.drawData.add,{animation:!1,stage:"expand",target:e}),this.context.animation.clear(),this.computeStyle("expand"),!A)return;const{drawData:l}=A,{update:c,add:u}=l,h={animation:a,stage:"expand",data:l};u.edges.forEach(d=>c.edges.set(Y(d),d)),u.nodes.forEach(d=>c.nodes.set(Y(d),d)),this.updateElements(c,h),yield(n=this.context.animation.animate(a,{beforeAnimate:d=>this.emit(new ci(fe.BEFORE_ANIMATE,Sr.EXPAND,d,l),h),afterAnimate:d=>this.emit(new ci(fe.AFTER_ANIMATE,Sr.EXPAND,d,l),h)},{expand:{target:e,descendants:Array.from(u.nodes).map(([,d])=>Y(d)),position:o}}))===null||n===void 0?void 0:n.finished})}collapseCombo(e,t){return gA(this,void 0,void 0,function*(){var n;const{model:i,element:a}=this.context;if(i.getAncestorsData(e,Ft).some(g=>Fr(g)))return;const s=a.getElement(e),o=s.getComboPosition(Object.assign(Object.assign({},s.attributes),{collapsed:!0})),A=this.computeChangesAndDrawData({stage:"collapse",animation:t});if(!A)return;const{dataChanges:l,drawData:c}=A;this.markDestroyElement(c);const{update:u,remove:h}=c,d={animation:t,stage:"collapse",data:c};this.destroyElements(h,d),this.updateElements(u,d);const f=g=>Array.from(g).map(([,p])=>Y(p));yield(n=this.context.animation.animate(t,{before:()=>this.emit(new xn(fe.BEFORE_DRAW,{dataChanges:l,animation:t}),d),beforeAnimate:g=>this.emit(new ci(fe.BEFORE_ANIMATE,Sr.COLLAPSE,g,c),d),afterAnimate:g=>this.emit(new ci(fe.AFTER_ANIMATE,Sr.COLLAPSE,g,c),d),after:()=>this.emit(new xn(fe.AFTER_DRAW,{dataChanges:l,animation:t}),d)},{collapse:{target:e,descendants:[...f(h.nodes),...f(h.combos)],position:o}}))===null||n===void 0?void 0:n.finished})}expandCombo(e,t){return gA(this,void 0,void 0,function*(){var n;const{model:i}=this.context,a=Fn(i.getComboData([e])[0]);this.computeStyle("expand");const s=this.computeChangesAndDrawData({stage:"expand",animation:t});if(!s)return;const{dataChanges:o,drawData:A}=s,{add:l,update:c}=A,u={animation:t,stage:"expand",data:A,target:e};this.createElements(l,u),this.updateElements(c,u);const h=d=>Array.from(d).map(([,f])=>Y(f));yield(n=this.context.animation.animate(t,{before:()=>this.emit(new xn(fe.BEFORE_DRAW,{dataChanges:o,animation:t}),u),beforeAnimate:d=>this.emit(new ci(fe.BEFORE_ANIMATE,Sr.EXPAND,d,A),u),afterAnimate:d=>this.emit(new ci(fe.AFTER_ANIMATE,Sr.EXPAND,d,A),u),after:()=>this.emit(new xn(fe.AFTER_DRAW,{dataChanges:o,animation:t}),u)},{expand:{target:e,descendants:[...h(l.nodes),...h(l.combos)],position:a}}))===null||n===void 0?void 0:n.finished})}clear(){this.container.destroy(),this.initContainer(),this.elementMap={},this.shapeTypeMap={},this.defaultStyle={},this.stateStyle={},this.paletteStyle={}}destroy(){this.clear(),this.container.destroy(),this.context={}}}var pA=function(r,e,t,n){function i(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(c){try{l(n.next(c))}catch(u){s(u)}}function A(c){try{l(n.throw(c))}catch(u){s(u)}}function l(c){c.done?a(c.value):i(c.value).then(o,A)}l((n=n.apply(r,e||[])).next())})},lse=function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t};class cse{get presetOptions(){return{animation:!!yS(this.context.options,!0)}}get options(){const{options:e}=this.context;return e.layout}constructor(e){this.instances=[],this.context=e}getLayoutInstance(){return this.instances}preLayout(e){return pA(this,void 0,void 0,function*(){var t,n,i,a;const{graph:s,model:o}=this.context,{add:A}=e;On(s,new xn(fe.BEFORE_LAYOUT,{type:"pre"}));const l=yield(t=this.context.layout)===null||t===void 0?void 0:t.simulate();(n=l?.nodes)===null||n===void 0||n.forEach(c=>{const u=Y(c),h=A.nodes.get(u);o.syncNodeLikeDatum(c),h&&Object.assign(h.style,c.style)}),(i=l?.edges)===null||i===void 0||i.forEach(c=>{const u=Y(c),h=A.edges.get(u);o.syncEdgeDatum(c),h&&Object.assign(h.style,c.style)}),(a=l?.combos)===null||a===void 0||a.forEach(c=>{const u=Y(c),h=A.combos.get(u);o.syncNodeLikeDatum(c),h&&Object.assign(h.style,c.style)}),On(s,new xn(fe.AFTER_LAYOUT,{type:"pre"})),this.transformDataAfterLayout("pre",e)})}postLayout(){return pA(this,arguments,void 0,function*(e=this.options){if(!e)return;const t=Array.isArray(e)?e:[e],{graph:n}=this.context;On(n,new xn(fe.BEFORE_LAYOUT,{type:"post"}));for(let i=0;i<t.length;i++){const a=t[i],s=this.getLayoutData(a),o=Object.assign(Object.assign({},this.presetOptions),a);On(n,new xn(fe.BEFORE_STAGE_LAYOUT,{options:o,index:i}));const A=yield this.stepLayout(s,o,i);On(n,new xn(fe.AFTER_STAGE_LAYOUT,{options:o,index:i})),a.animation||this.updateElementPosition(A,!1)}On(n,new xn(fe.AFTER_LAYOUT,{type:"post"})),this.transformDataAfterLayout("post")})}transformDataAfterLayout(e,t){const n=this.context.transform.getTransformInstance();Object.values(n).forEach(i=>i.afterLayout(e,t))}simulate(){return pA(this,arguments,void 0,function*(e=this.options){if(!e)return{};const t=Array.isArray(e)?e:[e];let n={};for(let i=0;i<t.length;i++){const a=t[i],s=this.getLayoutData(a);n=yield this.stepLayout(s,Object.assign(Object.assign(Object.assign({},this.presetOptions),a),{animation:!1}),i)}return n})}stepLayout(e,t,n){return pA(this,void 0,void 0,function*(){return mW(t)?yield this.treeLayout(e,t,n):yield this.graphLayout(e,t,n)})}graphLayout(e,t,n){return pA(this,void 0,void 0,function*(){const{animation:i,enableWorker:a,iterations:s=300}=t,o=this.initGraphLayout(t);if(!o)return{};if(this.instances[n]=o,this.instance=o,a){const l=o;return this.supervisor=new wee(l.graphData2LayoutModel(e),l.instance,{iterations:s}),Hh(yield this.supervisor.execute())}if(jv(o))return i?yield o.execute(e,{onTick:l=>{this.updateElementPosition(l,!1)}}):(o.execute(e),o.stop(),o.tick(s));const A=yield o.execute(e);if(i){const l=this.updateElementPosition(A,i);yield l?.finished}return A})}treeLayout(e,t,n){return pA(this,void 0,void 0,function*(){const{type:i,animation:a}=t,s=ha("layout",i);if(!s)return{};const{nodes:o=[],edges:A=[]}=e,l=new Tn({nodes:o.map(f=>({id:Y(f),data:f.data||{}})),edges:A.map(f=>({id:Y(f),source:f.source,target:f.target,data:f.data||{}}))});sse(l);const c={nodes:[],edges:[]},u={nodes:[],edges:[]};l.getRoots(Rr).forEach(f=>{Ko(f,m=>{m.children=l.getSuccessors(m.id)},m=>l.getSuccessors(m.id),"TB");const g=s(f,t),{x:p,y:v,z:y=0}=g;Ko(g,m=>{const{id:b,x:C,y:S,z:F=0}=m;c.nodes.push({id:b,style:{x:p,y:v,z:y}}),u.nodes.push({id:b,style:{x:C,y:S,z:F}})},m=>m.children,"TB")});const d=this.inferTreeLayoutOffset(u);if(zU(u,d),a){zU(c,d),this.updateElementPosition(c,!1);const f=this.updateElementPosition(u,a);yield f?.finished}return u})}inferTreeLayoutOffset(e){var t;let[n,i]=[1/0,-1/0],[a,s]=[1/0,-1/0];(t=e.nodes)===null||t===void 0||t.forEach(g=>{const{x:p=0,y:v=0}=g.style||{};n=Math.min(n,p),i=Math.max(i,p),a=Math.min(a,v),s=Math.max(s,v)});const{canvas:o}=this.context,A=o.getSize(),[l,c]=o.getCanvasByViewport([0,0]),[u,h]=o.getCanvasByViewport(A);if(n>=l&&i<=u&&a>=c&&s<=h)return[0,0];const d=(l+u)/2,f=(c+h)/2;return[d-(n+i)/2,f-(a+s)/2]}stopLayout(){this.instance&&jv(this.instance)&&(this.instance.stop(),this.instance=void 0),this.supervisor&&(this.supervisor.stop(),this.supervisor=void 0),this.animationResult&&(this.animationResult.finish(),this.animationResult=void 0)}getLayoutData(e){const{nodeFilter:t=()=>!0,comboFilter:n=()=>!0,preLayout:i=!1,isLayoutInvisibleNodes:a=!1}=e,{nodes:s,edges:o,combos:A}=this.context.model.getData(),{element:l,model:c}=this.context,u=v=>l.getElement(v),h=i?v=>{var y;return!a&&(((y=v.style)===null||y===void 0?void 0:y.visibility)==="hidden"||c.getAncestorsData(v.id,Rr).some(Fr)||c.getAncestorsData(v.id,Ft).some(Fr))?!1:t(v)}:v=>{const y=Y(v),m=u(y);return!m||Cl(m)?!1:t(v)},d=s.filter(h),f=A.filter(n),g=new Map(d.map(v=>[Y(v),v]));f.forEach(v=>g.set(Y(v),v));const p=o.filter(({source:v,target:y})=>g.has(v)&&g.has(y));return{nodes:d,edges:p,combos:f}}initGraphLayout(e){var t;const{element:n,viewport:i}=this.context,{type:a,enableWorker:s,animation:o,iterations:A}=e,l=lse(e,["type","enableWorker","animation","iterations"]),[c,u]=i.getCanvasSize(),h=[c/2,u/2],d=(t=e?.nodeSize)!==null&&t!==void 0?t:(y=>{const m=n?.getElement(y.id);return m?m.attributes.size:n?.getElementComputedStyle("node",y).size}),f=ha("layout",a);if(!f)return $i.warn(`The layout of ${a} is not registered.`);const g=Object.getPrototypeOf(f.prototype)===Rh.prototype?f:bW(f,this.context),p=new g(this.context),v={nodeSize:d,width:c,height:u,center:h};switch(p.id){case"d3-force":case"d3-force-3d":Object.assign(v,{center:{x:c/2,y:u/2,z:0}});break}return Dn(p.options,v,l),p}updateElementPosition(e,t){const{model:n,element:i}=this.context;return i?(n.updateData(e),i.draw({animation:t,silence:!0})):null}destroy(){var e;this.stopLayout(),this.context={},(e=this.supervisor)===null||e===void 0||e.kill(),this.supervisor=void 0,this.instance=void 0,this.instances=[],this.animationResult=void 0}}const zU=(r,e)=>{var t;const[n,i]=e;(t=r.nodes)===null||t===void 0||t.forEach(a=>{if(a.style){const{x:s=0,y:o=0}=a.style;a.style.x=s+n,a.style.y=o+i}else a.style={x:n,y:i}})};function use(r){return[hse].reduce((t,n)=>n(t),r)}function hse(r){return!r.layout||Array.isArray(r.layout)||"preLayout"in r.layout||["antv-dagre","combo-combined","compact-box","circular","concentric","dagre","fishbone","grid","indented","mds","radial","random","snake","dendrogram","mindmap"].includes(r.layout.type)&&(r.layout.preLayout=!0),r}class dse extends Zp{constructor(e){super(e),this.category="plugin",this.setPlugins(this.context.options.plugins||[])}setPlugins(e){this.setExtensions(e)}getPluginInstance(e){const t=this.extensionMap[e];if(t)return t;$i.warn(`Cannot find the plugin ${e}, will try to find it by type.`);const n=this.extensions.find(i=>i.type===e);if(n)return this.extensionMap[n.key]}}const Bf=["update-related-edges","collapse-expand-node","collapse-expand-combo","get-edge-actual-ends","arrange-draw-order"];class fse extends Zp{constructor(e){super(e),this.category="transform",this.setTransforms(this.context.options.transforms||[])}getTransforms(){}setTransforms(e){this.setExtensions([...Bf.slice(0,Bf.length-1),...e,Bf[Bf.length-1]])}getTransformInstance(e){return e?this.extensionMap[e]:this.extensionMap}}var nc=function(r,e,t,n){function i(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(c){try{l(n.next(c))}catch(u){s(u)}}function A(c){try{l(n.throw(c))}catch(u){s(u)}}function l(c){c.done?a(c.value):i(c.value).then(o,A)}l((n=n.apply(r,e||[])).next())})};class gse{get padding(){return si(this.context.options.padding)}get paddingOffset(){const[e,t,n,i]=this.padding,[a,s,o]=[(i-t)/2,(e-n)/2,0];return[a,s,o]}constructor(e){this.landmarkCounter=0,this.context=e;const[t,n]=this.paddingOffset,{zoom:i,rotation:a,x:s=t,y:o=n}=e.options;this.transform({mode:"absolute",scale:i,translate:[s,o],rotate:a},!1)}get camera(){const{canvas:e}=this.context;return new Proxy(e.getCamera(),{get:(t,n)=>{const a=Object.entries(e.getLayers()).filter(([o])=>!["main"].includes(o)).map(([,o])=>o.getCamera()),s=t[n];if(typeof s=="function")return(...o)=>{const A=s.apply(t,o);return a.forEach(l=>{l[n].apply(l,o)}),A}}})}createLandmark(e){return this.camera.createLandmark(`landmark-${this.landmarkCounter++}`,e)}getAnimation(e){const t=yS(this.context.options,e);return t?ws(Object.assign({},t),["easing","duration"]):!1}getCanvasSize(){const{canvas:e}=this.context,{width:t=0,height:n=0}=e.getConfig();return[t,n]}getCanvasCenter(){const{canvas:e}=this.context,{width:t=0,height:n=0}=e.getConfig();return[t/2,n/2,0]}getViewportCenter(){const[e,t]=this.camera.getPosition();return[e,t,0]}getGraphCenter(){return this.context.graph.getViewportByCanvas(this.getCanvasCenter())}getZoom(){return this.camera.getZoom()}getRotation(){return this.camera.getRoll()}getTranslateOptions(e){const{camera:t}=this,{mode:n,translate:i=[]}=e,a=this.getZoom(),s=t.getPosition(),o=t.getFocalPoint(),[A,l]=this.getCanvasCenter(),[c=0,u=0,h=0]=i,d=Bi([-c,-u,-h],a);return n==="relative"?{position:je(s,d),focalPoint:je(o,d)}:{position:je([A,l,s[2]],d),focalPoint:je([A,l,o[2]],d)}}getRotateOptions(e){const{mode:t,rotate:n=0}=e;return{roll:t==="relative"?this.camera.getRoll()+n:n}}getZoomOptions(e){const{zoomRange:t}=this.context.options,n=this.camera.getZoom(),{mode:i,scale:a=1}=e;return Yt(i==="relative"?n*a:a,...t)}transform(e,t){return nc(this,void 0,void 0,function*(){const{graph:n}=this.context,{translate:i,rotate:a,scale:s,origin:o}=e;this.cancelAnimation();const A=this.getAnimation(t);if(On(n,new bf(fe.BEFORE_TRANSFORM,e)),!a&&s&&!i&&o&&!A){this.camera.setZoomByViewportPoint(this.getZoomOptions(e),o),On(n,new bf(fe.AFTER_TRANSFORM,e));return}const l={};if(i&&Object.assign(l,this.getTranslateOptions(e)),Ee(a)&&Object.assign(l,this.getRotateOptions(e)),Ee(s)&&Object.assign(l,{zoom:this.getZoomOptions(e)}),A)return On(n,new ci(fe.BEFORE_ANIMATE,Sr.TRANSFORM,null,e)),new Promise(c=>{this.transformResolver=c,this.camera.gotoLandmark(this.createLandmark(l),Object.assign(Object.assign({},A),{onfinish:()=>{On(n,new ci(fe.AFTER_ANIMATE,Sr.TRANSFORM,null,e)),On(n,new bf(fe.AFTER_TRANSFORM,e)),this.transformResolver=void 0,c()}}))});this.camera.gotoLandmark(this.createLandmark(l),{duration:0}),On(n,new bf(fe.AFTER_TRANSFORM,e))})}fitView(e,t){return nc(this,void 0,void 0,function*(){const[n,i,a,s]=this.padding,{when:o="always",direction:A="both"}=e||{},[l,c]=this.context.canvas.getSize(),u=l-s-i,h=c-n-a,d=this.context.canvas.getBounds(),f=this.getBBoxInViewport(d),[g,p]=qa(f),v=A==="x"&&g>=u||A==="y"&&p>=h||A==="both"&&g>=u&&p>=h;if(o==="overflow"&&!v)return yield this.fitCenter({animation:t});const y=u/g,m=h/p,b=A==="x"?y:A==="y"?m:Math.min(y,m),C=this.getAnimation(t);Number.isFinite(b)&&(yield this.transform({mode:"relative",scale:b,translate:je(Bt(this.getCanvasCenter(),this.getBBoxInViewport(d).center),Bi(this.paddingOffset,b))},C))})}fitCenter(e){return nc(this,void 0,void 0,function*(){const t=this.context.canvas.getBounds();yield this.focus(t,e)})}focusElements(e){return nc(this,arguments,void 0,function*(t,n={}){const{element:i}=this.context;if(!i)return;const a=o=>n.shapes?o.getShape(n.shapes).getRenderBounds():o.getRenderBounds(),s=dl(t.map(o=>a(i.getElement(o))));yield this.focus(s,n)})}focus(e,t){return nc(this,void 0,void 0,function*(){const n=this.context.graph.getViewportByCanvas(e.center),i=t.position||this.getCanvasCenter(),a=Bt(i,n);yield this.transform({mode:"relative",translate:je(a,this.paddingOffset)},t.animation)})}getBBoxInViewport(e){const{min:t,max:n}=e,{graph:i}=this.context,[a,s]=i.getViewportByCanvas(t),[o,A]=i.getViewportByCanvas(n),l=new kt;return l.setMinMax([a,s,0],[o,A,0]),l}isInViewport(e,t=!1,n=0){const{graph:i}=this.context,a=this.getCanvasSize(),[s,o]=i.getCanvasByViewport([0,0]),[A,l]=i.getCanvasByViewport(a);let c=new kt;return c.setMinMax([s,o,0],[A,l,0]),n&&(c=Ya(c,n)),Go(e)?wi(e,c):t?NV(e,c):c.intersects(e)}cancelAnimation(){var e,t;!((e=this.camera.landmarks)===null||e===void 0)&&e.length&&this.camera.cancelLandmarkAnimation(),(t=this.transformResolver)===null||t===void 0||t.call(this)}}var Ot=function(r,e,t,n){function i(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(c){try{l(n.next(c))}catch(u){s(u)}}function A(c){try{l(n.throw(c))}catch(u){s(u)}}function l(c){c.done?a(c.value):i(c.value).then(o,A)}l((n=n.apply(r,e||[])).next())})};class Ef extends Ph{constructor(e){var t;super(),this.options={},this.rendered=!1,this.destroyed=!1,this.context={model:new ose},this.isCollapsingExpanding=!1,this.onResize=EA(()=>{this.resize()},300),this._setOptions(Object.assign({},Ef.defaultOptions,e),!0),this.context.graph=this,this.options.autoResize&&((t=globalThis.addEventListener)===null||t===void 0||t.call(globalThis,"resize",this.onResize))}getOptions(){return this.options}setOptions(e){this._setOptions(e,!1)}_setOptions(e,t){if(this.updateCanvas(e),Object.assign(this.options,use(e)),t){const{data:h}=e;h&&this.addData(h);return}const{behaviors:n,combo:i,data:a,edge:s,layout:o,node:A,plugins:l,theme:c,transforms:u}=e;n&&this.setBehaviors(n),a&&this.setData(a),A&&this.setNode(A),s&&this.setEdge(s),i&&this.setCombo(i),o&&this.setLayout(o),c&&this.setTheme(c),l&&this.setPlugins(l),u&&this.setTransforms(u)}getSize(){return this.context.canvas?this.context.canvas.getSize():[this.options.width||0,this.options.height||0]}setSize(e,t){e&&(this.options.width=e),t&&(this.options.height=t),this.resize(e,t)}setZoomRange(e){this.options.zoomRange=e}getZoomRange(){return this.options.zoomRange}setNode(e){this.options.node=e,this.context.model.refreshData()}setEdge(e){this.options.edge=e,this.context.model.refreshData()}setCombo(e){this.options.combo=e,this.context.model.refreshData()}getTheme(){return this.options.theme}setTheme(e){this.options.theme=Te(e)?e(this.getTheme()):e}setLayout(e){this.options.layout=Te(e)?e(this.getLayout()):e}getLayout(){return this.options.layout}setBehaviors(e){var t;this.options.behaviors=Te(e)?e(this.getBehaviors()):e,(t=this.context.behavior)===null||t===void 0||t.setBehaviors(this.options.behaviors)}updateBehavior(e){this.setBehaviors(t=>t.map(n=>typeof n=="object"&&n.key===e.key?Object.assign(Object.assign({},n),e):n))}getBehaviors(){return this.options.behaviors||[]}setPlugins(e){var t;this.options.plugins=Te(e)?e(this.getPlugins()):e,(t=this.context.plugin)===null||t===void 0||t.setPlugins(this.options.plugins)}updatePlugin(e){this.setPlugins(t=>t.map(n=>typeof n=="object"&&n.key===e.key?Object.assign(Object.assign({},n),e):n))}getPlugins(){return this.options.plugins||[]}getPluginInstance(e){return this.context.plugin.getPluginInstance(e)}setTransforms(e){var t;this.options.transforms=Te(e)?e(this.getTransforms()):e,(t=this.context.transform)===null||t===void 0||t.setTransforms(this.options.transforms)}updateTransform(e){this.setTransforms(t=>t.map(n=>typeof n=="object"&&n.key===e.key?Object.assign(Object.assign({},n),e):n)),this.context.model.refreshData()}getTransforms(){return this.options.transforms||[]}getData(){return this.context.model.getData()}hasNode(e){return this.context.model.hasNode(e)}hasEdge(e){return this.context.model.hasEdge(e)}hasCombo(e){return this.context.model.hasCombo(e)}getElementData(e){return Array.isArray(e)?e.map(t=>this.context.model.getElementDataById(t)):this.context.model.getElementDataById(e)}getNodeData(e){return e===void 0?this.context.model.getNodeData():Array.isArray(e)?this.context.model.getNodeData(e):this.context.model.getNodeLikeDatum(e)}getEdgeData(e){return e===void 0?this.context.model.getEdgeData():Array.isArray(e)?this.context.model.getEdgeData(e):this.context.model.getEdgeDatum(e)}getComboData(e){return e===void 0?this.context.model.getComboData():Array.isArray(e)?this.context.model.getComboData(e):this.context.model.getNodeLikeDatum(e)}setData(e){this.context.model.setData(Te(e)?e(this.getData()):e)}addData(e){this.context.model.addData(Te(e)?e(this.getData()):e)}addNodeData(e){this.context.model.addNodeData(Te(e)?e(this.getNodeData()):e)}addEdgeData(e){this.context.model.addEdgeData(Te(e)?e(this.getEdgeData()):e)}addComboData(e){this.context.model.addComboData(Te(e)?e(this.getComboData()):e)}addChildrenData(e,t){this.context.model.addChildrenData(e,t)}updateData(e){this.context.model.updateData(Te(e)?e(this.getData()):e)}updateNodeData(e){this.context.model.updateNodeData(Te(e)?e(this.getNodeData()):e)}updateEdgeData(e){this.context.model.updateEdgeData(Te(e)?e(this.getEdgeData()):e)}updateComboData(e){this.context.model.updateComboData(Te(e)?e(this.getComboData()):e)}removeData(e){this.context.model.removeData(Te(e)?e(this.getData()):e)}removeNodeData(e){this.context.model.removeNodeData(Te(e)?e(this.getNodeData()):e)}removeEdgeData(e){this.context.model.removeEdgeData(Te(e)?e(this.getEdgeData()):e)}removeComboData(e){this.context.model.removeComboData(Te(e)?e(this.getComboData()):e)}getElementType(e){return this.context.model.getElementType(e)}getRelatedEdgesData(e,t="both"){return this.context.model.getRelatedEdgesData(e,t)}getNeighborNodesData(e){return this.context.model.getNeighborNodesData(e)}getAncestorsData(e,t){return this.context.model.getAncestorsData(e,t)}getParentData(e,t){return this.context.model.getParentData(e,t)}getChildrenData(e){return this.context.model.getChildrenData(e)}getDescendantsData(e){return this.context.model.getDescendantsData(e)}getElementDataByState(e,t){return this.context.model.getElementDataByState(e,t)}initCanvas(){return Ot(this,void 0,void 0,function*(){var e;if(this.context.canvas)return yield this.context.canvas.ready;const{container:t="container",width:n,height:i,renderer:a,cursor:s,background:o,canvas:A,devicePixelRatio:l=(e=globalThis.devicePixelRatio)!==null&&e!==void 0?e:1}=this.options;if(t instanceof PU)this.context.canvas=t,s&&t.setCursor(s),a&&t.setRenderer(a),yield t.ready;else{const c=At(t)?document.getElementById(t):t,u=HU(c);this.emit(fe.BEFORE_CANVAS_INIT,{container:c,width:n,height:i});const h=Object.assign(Object.assign({},A),{container:c,width:n||u[0],height:i||u[1],background:o,renderer:a,cursor:s,devicePixelRatio:l}),d=new PU(h);this.context.canvas=d,yield d.ready,this.emit(fe.AFTER_CANVAS_INIT,{canvas:d})}})}updateCanvas(e){var t,n;const{renderer:i,cursor:a,height:s,width:o}=e,A=this.context.canvas;A&&(i&&(this.emit(fe.BEFORE_RENDERER_CHANGE,{renderer:this.options.renderer}),A.setRenderer(i),this.emit(fe.AFTER_RENDERER_CHANGE,{renderer:i})),a&&A.setCursor(a),(Ee(o)||Ee(s))&&this.setSize((t=o??this.options.width)!==null&&t!==void 0?t:0,(n=s??this.options.height)!==null&&n!==void 0?n:0))}initRuntime(){this.context.options=this.options,this.context.batch||(this.context.batch=new rse(this.context)),this.context.plugin||(this.context.plugin=new dse(this.context)),this.context.viewport||(this.context.viewport=new gse(this.context)),this.context.transform||(this.context.transform=new fse(this.context)),this.context.element||(this.context.element=new Ase(this.context)),this.context.animation||(this.context.animation=new nse(this.context)),this.context.layout||(this.context.layout=new cse(this.context)),this.context.behavior||(this.context.behavior=new ise(this.context))}prepare(){return Ot(this,void 0,void 0,function*(){if(yield Promise.resolve(),this.destroyed){console.error(da("The graph instance has been destroyed"));return}yield this.initCanvas(),this.initRuntime()})}render(){return Ot(this,void 0,void 0,function*(){if(yield this.prepare(),On(this,new xn(fe.BEFORE_RENDER)),this.options.layout)if(!this.rendered&&wW(this.options.layout)){const e=yield this.context.element.preLayoutDraw({type:"render"});yield Promise.all([e?.finished,this.autoFit()])}else{const e=this.context.element.draw({type:"render"});yield Promise.all([e?.finished,this.context.layout.postLayout()]),yield this.autoFit()}else{const e=this.context.element.draw({type:"render"});yield Promise.all([e?.finished,this.autoFit()])}this.rendered=!0,On(this,new xn(fe.AFTER_RENDER))})}draw(){return Ot(this,void 0,void 0,function*(){var e;yield this.prepare(),yield(e=this.context.element.draw())===null||e===void 0?void 0:e.finished})}layout(e){return Ot(this,void 0,void 0,function*(){yield this.context.layout.postLayout(e)})}stopLayout(){this.context.layout.stopLayout()}clear(){return Ot(this,void 0,void 0,function*(){const{model:e,element:t}=this.context;e.setData({}),e.clearChanges(),t?.clear()})}destroy(){var e;On(this,new xn(fe.BEFORE_DESTROY));const{layout:t,animation:n,element:i,model:a,canvas:s,behavior:o,plugin:A}=this.context;A?.destroy(),o?.destroy(),t?.destroy(),n?.destroy(),i?.destroy(),a.destroy(),s?.destroy(),this.options={},this.context={},this.off(),(e=globalThis.removeEventListener)===null||e===void 0||e.call(globalThis,"resize",this.onResize),this.destroyed=!0,On(this,new xn(fe.AFTER_DESTROY))}getCanvas(){return this.context.canvas}resize(e,t){var n;const i=HU((n=this.context.canvas)===null||n===void 0?void 0:n.getContainer()),a=[e||i[0],t||i[1]];if(!this.context.canvas)return;const s=this.context.canvas.getSize();Xt(a,s)||(On(this,new xn(fe.BEFORE_SIZE_CHANGE,{size:a})),this.context.canvas.resize(...a),On(this,new xn(fe.AFTER_SIZE_CHANGE,{size:a})))}fitView(e,t){return Ot(this,void 0,void 0,function*(){var n;yield(n=this.context.viewport)===null||n===void 0?void 0:n.fitView(e,t)})}fitCenter(e){return Ot(this,void 0,void 0,function*(){var t;yield(t=this.context.viewport)===null||t===void 0?void 0:t.fitCenter({animation:e})})}autoFit(){return Ot(this,void 0,void 0,function*(){const{autoFit:e}=this.context.options;if(e)if(At(e))e==="view"?yield this.fitView():e==="center"&&(yield this.fitCenter());else{const{type:t,animation:n}=e;t==="view"?yield this.fitView(e.options,n):t==="center"&&(yield this.fitCenter(n))}})}focusElement(e,t){return Ot(this,void 0,void 0,function*(){var n;yield(n=this.context.viewport)===null||n===void 0?void 0:n.focusElements(Array.isArray(e)?e:[e],{animation:t})})}zoomBy(e,t,n){return Ot(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",scale:e,origin:n},t)})}zoomTo(e,t,n){return Ot(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",scale:e,origin:n},t)})}getZoom(){return this.context.viewport.getZoom()}rotateBy(e,t,n){return Ot(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",rotate:e,origin:n},t)})}rotateTo(e,t,n){return Ot(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",rotate:e,origin:n},t)})}getRotation(){return this.context.viewport.getRotation()}translateBy(e,t){return Ot(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",translate:e},t)})}translateTo(e,t){return Ot(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",translate:e},t)})}getPosition(){return Bt([0,0],this.getCanvasByViewport([0,0]))}translateElementBy(e,t){return Ot(this,arguments,void 0,function*(n,i,a=!0){var s,o;const[A,l]=on(n)?[n,(s=i)!==null&&s!==void 0?s:!0]:[{[n]:i},a];Object.entries(A).forEach(([c,u])=>this.context.model.translateNodeLikeBy(c,u)),yield(o=this.context.element.draw({animation:l,stage:"translate"}))===null||o===void 0?void 0:o.finished})}translateElementTo(e,t){return Ot(this,arguments,void 0,function*(n,i,a=!0){var s,o;const[A,l]=on(n)?[n,(s=i)!==null&&s!==void 0?s:!0]:[{[n]:i},a];Object.entries(A).forEach(([c,u])=>this.context.model.translateNodeLikeTo(c,u)),yield(o=this.context.element.draw({animation:l,stage:"translate"}))===null||o===void 0?void 0:o.finished})}getElementPosition(e){return this.context.model.getElementPosition(e)}getElementRenderStyle(e){return Jf(this.context.element.getElement(e).attributes,["context"])}setElementVisibility(e,t){return Ot(this,arguments,void 0,function*(n,i,a=!0){var s,o;const[A,l]=on(n)?[n,(s=i)!==null&&s!==void 0?s:!0]:[{[n]:i},a],c={nodes:[],edges:[],combos:[]};Object.entries(A).forEach(([d,f])=>{const g=this.getElementType(d);c[`${g}s`].push({id:d,style:{visibility:f}})});const{model:u,element:h}=this.context;u.preventUpdateNodeLikeHierarchy(()=>{u.updateData(c)}),yield(o=h.draw({animation:l,stage:"visibility"}))===null||o===void 0?void 0:o.finished})}showElement(e,t){return Ot(this,void 0,void 0,function*(){const n=Array.isArray(e)?e:[e];yield this.setElementVisibility(Object.fromEntries(n.map(i=>[i,"visible"])),t)})}hideElement(e,t){return Ot(this,void 0,void 0,function*(){const n=Array.isArray(e)?e:[e];yield this.setElementVisibility(Object.fromEntries(n.map(i=>[i,"hidden"])),t)})}getElementVisibility(e){var t,n;const i=this.context.element.getElement(e);return(n=(t=i?.style)===null||t===void 0?void 0:t.visibility)!==null&&n!==void 0?n:"visible"}setElementZIndex(e,t){return Ot(this,void 0,void 0,function*(){var n;const i={nodes:[],edges:[],combos:[]},a=on(e)?e:{[e]:t};Object.entries(a).forEach(([A,l])=>{const c=this.getElementType(A);i[`${c}s`].push({id:A,style:{zIndex:l}})});const{model:s,element:o}=this.context;s.preventUpdateNodeLikeHierarchy(()=>s.updateData(i)),yield(n=o.draw({animation:!1,stage:"zIndex"}))===null||n===void 0?void 0:n.finished})}frontElement(e){return Ot(this,void 0,void 0,function*(){const t=Array.isArray(e)?e:[e],{model:n}=this.context,i={};t.map(a=>{const s=n.getFrontZIndex(a);if(n.getElementType(a)==="combo"){const A=n.getAncestorsData(a,Ft).at(-1)||this.getComboData(a),l=[A,...n.getDescendantsData(Y(A))],c=s-GU(A);l.forEach(h=>{i[Y(h)]=this.getElementZIndex(Y(h))+c});const{internal:u}=mv(l.map(Y),h=>n.getRelatedEdgesData(h));u.forEach(h=>{const d=Y(h);i[d]=this.getElementZIndex(d)+c})}else i[a]=s}),yield this.setElementZIndex(i)})}getElementZIndex(e){return GU(this.context.model.getElementDataById(e))}setElementState(e,t){return Ot(this,arguments,void 0,function*(n,i,a=!0){var s,o;const[A,l]=on(n)?[n,(s=i)!==null&&s!==void 0?s:!0]:[{[n]:i},a],c=h=>h?Array.isArray(h)?h:[h]:[],u={nodes:[],edges:[],combos:[]};Object.entries(A).forEach(([h,d])=>{const f=this.getElementType(h);u[`${f}s`].push({id:h,states:c(d)})}),this.updateData(u),yield(o=this.context.element.draw({animation:l,stage:"state"}))===null||o===void 0?void 0:o.finished})}getElementState(e){return this.context.model.getElementState(e)}getElementRenderBounds(e){return this.context.element.getElement(e).getRenderBounds()}collapseElement(e){return Ot(this,arguments,void 0,function*(t,n=!0){const{model:i,element:a}=this.context;if(Fr(i.getNodeLikeData([t])[0])||this.isCollapsingExpanding)return;typeof n=="boolean"&&(n={animation:n,align:!1});const s=i.getElementType(t);yield this.frontElement(t),this.isCollapsingExpanding=!0,i.updateData(s==="node"?{nodes:[{id:t,style:{collapsed:!0}}]}:{combos:[{id:t,style:{collapsed:!0}}]}),s==="node"?yield a.collapseNode(t,n):s==="combo"&&(yield a.collapseCombo(t,!!n.animation)),this.isCollapsingExpanding=!1})}expandElement(e){return Ot(this,arguments,void 0,function*(t,n=!0){const{model:i,element:a}=this.context;if(!Fr(i.getNodeLikeData([t])[0])||this.isCollapsingExpanding)return;typeof n=="boolean"&&(n={animation:n,align:!1});const s=i.getElementType(t);this.isCollapsingExpanding=!0,i.updateData(s==="node"?{nodes:[{id:t,style:{collapsed:!1}}]}:{combos:[{id:t,style:{collapsed:!1}}]}),s==="node"?yield a.expandNode(t,n):s==="combo"&&(yield a.expandCombo(t,!!n.animation)),this.isCollapsingExpanding=!1})}setElementCollapsibility(e,t){const n=this.getElementType(e);n==="node"?this.updateNodeData([{id:e,style:{collapsed:t}}]):n==="combo"&&this.updateComboData([{id:e,style:{collapsed:t}}])}toDataURL(){return Ot(this,arguments,void 0,function*(e={}){return this.context.canvas.toDataURL(e)})}getCanvasByViewport(e){return this.context.canvas.getCanvasByViewport(e)}getViewportByCanvas(e){return this.context.canvas.getViewportByCanvas(e)}getClientByCanvas(e){return this.context.canvas.getClientByCanvas(e)}getCanvasByClient(e){return this.context.canvas.getCanvasByClient(e)}getViewportCenter(){return this.context.viewport.getViewportCenter()}getCanvasCenter(){return this.context.viewport.getCanvasCenter()}on(e,t,n){return super.on(e,t,n)}once(e,t){return super.once(e,t)}off(e,t){return super.off(e,t)}}Ef.defaultOptions={autoResize:!1,theme:"light",rotation:0,zoom:1,zoomRange:[.01,10]};class pse extends fs{beforeDraw(e){const{add:t,update:n}=e,{model:i}=this.context;return[...t.edges.entries(),...n.edges.entries()].forEach(([,a])=>{VU(i,a)}),e}}const VU=(r,e)=>{const{source:t,target:n}=e,i=r.getElementDataById(t),a=r.getElementDataById(n),s=BF(i,u=>r.getParentData(u,Ft)),o=BF(a,u=>r.getParentData(u,Ft)),A=Y(s),l=Y(o),c={sourceNode:A,targetNode:l};return e.style?Object.assign(e.style,c):e.style=c,e},vse=(r,e,t)=>{const[n,i]=e,[a,s]=t;if(i===n)return a;const o=(r-n)/(i-n);return a+o*(s-a)},yse=(r,e,t)=>{const[n,i]=e,[a,s]=t,o=Math.log(r-n+1)/Math.log(i-n+1);return a+o*(s-a)},mse=(r,e,t,n=2)=>{const[i,a]=e,[s,o]=t,A=Math.pow((r-i)/(a-i),n);return s+A*(o-s)},wse=(r,e,t)=>{const[n,i]=e,[a,s]=t,o=Math.sqrt((r-n)/(i-n));return a+o*(s-a)};class xf extends fs{constructor(e,t){super(e,Dn({},xf.defaultOptions,t)),this.assignSizeByCentrality=(n,i,a,s,o,A)=>{const l=[i,a],c=[s[0],o[0]],u=[s[1],o[1]],h=[s[2],o[2]],d=(f,g)=>{if(typeof A=="function")return A(f,l,g);switch(A){case"linear":return vse(f,l,g);case"log":return yse(f,l,g);case"pow":return mse(f,l,g,2);case"sqrt":return wse(f,l,g);default:return g[0]}};return[d(n,c),d(n,u),d(n,h)]}}beforeDraw(e){const{model:t}=this.context,n=t.getNodeData(),i=Gr(this.options.maxSize),a=Gr(this.options.minSize),s=this.getCentralities(this.options.centrality),o=s.size>0?Math.max(...s.values()):0,A=s.size>0?Math.min(...s.values()):0;return n.forEach(l=>{var c;const u=this.assignSizeByCentrality(s.get(Y(l))||0,A,o,a,i,this.options.scale),h=(c=this.context.element)===null||c===void 0?void 0:c.getElement(Y(l)),d={size:u};this.assignLabelStyle(d,u,l,h),(!h||!mf(d,h.attributes))&&Vr(e,h?"update":"add","node",Dn(l,{style:d}),!0)}),e}assignLabelStyle(e,t,n,i){var a;const s=i?i.config.style:(a=this.context.element)===null||a===void 0?void 0:a.getElementComputedStyle("node",n);if(Object.assign(e,ws(s,["labelFontSize","labelLineHeight"])),this.options.mapLabelSize){const o=this.getLabelSizeByNodeSize(t,1/0,Number(e.labelFontSize));Object.assign(e,{labelFontSize:o,labelLineHeight:o+kV(e.labelPadding)})}return e}getLabelSizeByNodeSize(e,t,n){const i=Math.min(...e)/2,[a,s]=Array.isArray(this.options.mapLabelSize)?this.options.mapLabelSize:[n,t];return Math.min(s,Math.max(i,a))}getCentralities(e){const{model:t}=this.context,n=t.getData();if(typeof e=="function")return e(n);const i=t.getRelatedEdgesData.bind(t);return IS(n,i,e)}}xf.defaultOptions={centrality:{type:"degree"},maxSize:80,minSize:20,scale:"linear",mapLabelSize:!1};class Cf extends fs{constructor(e,t){super(e,Object.assign({},Cf.defaultOptions,t))}get ref(){return this.context.model.getRootsData()[0]}afterLayout(){var e;const t=Fn(this.ref),{graph:n,model:i}=this.context;(e=i.getData().nodes)===null||e===void 0||e.forEach(s=>{var o;if(Y(s)===Y(this.ref))return;const A=NS(Bt(Fn(s),t)),l=Math.abs(A)>Math.PI/2,c=!s.children||s.children.length===0,u=Y(s),h=(o=this.context.element)===null||o===void 0?void 0:o.getElement(u);if(!h||!h.isVisible())return;const d=Gr(n.getElementRenderStyle(u).size)[0]/2,f=(c?1:-1)*(d+this.options.offset),g=[["translate",f*Math.cos(A),f*Math.sin(A)],["rotate",l?br(A)+180:br(A)]];i.updateNodeData([{id:Y(s),style:{labelTextAlign:l===c?"right":"left",labelTextBaseline:"middle",labelTransform:g}}])}),n.draw()}}Cf.defaultOptions={offset:5};const bse="quadratic",jU=["top","top-right","right","right-bottom","bottom","bottom-left","left","left-top"];class Sf extends fs{constructor(e,t){super(e,Object.assign({},Sf.defaultOptions,t)),this.cacheMergeStyle=new Map,this.getAffectedParallelEdges=n=>{const{add:{edges:i},update:{nodes:a,edges:s,combos:o},remove:{edges:A}}=n,{model:l}=this.context,c=new Map,u=(f,g)=>{l.getRelatedEdgesData(g).forEach(v=>!c.has(Y(v))&&c.set(Y(v),v))};a.forEach(u),o.forEach(u);const h=f=>{const g=new Set(n.remove.edges.keys()),p=l.getEdgeData().filter(v=>!g.has(Y(v))).map(v=>VU(l,v));Bse(f,p).forEach(v=>{const y=Y(v);c.has(y)||c.set(y,v)})};if(A.size&&A.forEach(h),i.size&&i.forEach(h),s.size){const f=YL(Db(l.getChanges())).update.edges;s.forEach(g=>{var p;h(g);const v=(p=f.find(y=>Y(y.value)===Y(g)))===null||p===void 0?void 0:p.original;v&&!TB(g,v)&&h(v)})}Ui(this.options.edges)||c.forEach((f,g)=>!this.options.edges.includes(g)&&c.delete(g));const d=l.getEdgeData().map(Y);return new Map([...c].sort((f,g)=>d.indexOf(f[0])-d.indexOf(g[0])))},this.applyBundlingStyle=(n,i,a)=>{const{edgeMap:s,reverses:o}=WU(i);s.forEach(A=>{A.forEach((l,c,u)=>{var h;const d=u.length,f=l.style||{};if(l.source===l.target){const v=jU.length;f.loopPlacement=jU[c%v],f.loopDist=Math.floor(c/v)*a+50}else if(d===1)f.curveOffset=0;else{const v=(c%2===0?1:-1)*(o[`${l.source}|${l.target}|${c}`]?-1:1);f.curveOffset=d%2===1?v*Math.ceil(c/2)*a*2:v*(Math.floor(c/2)*a*2+a)}const g=Object.assign(l,{type:bse,style:f}),p=(h=this.context.element)===null||h===void 0?void 0:h.getElement(Y(l));(!p||!mf(g.style,p.attributes))&&Vr(n,p?"update":"add","edge",g,!0)})})},this.resetEdgeStyle=n=>{const i=n.style||{},a=this.cacheMergeStyle.get(Y(n))||{};return Object.keys(a).forEach(s=>{Xt(i[s],a[s])&&(n[s]?i[s]=n[s]:delete i[s])}),Object.assign(n,{style:i})},this.applyMergingStyle=(n,i)=>{const{edgeMap:a,reverses:s}=WU(i);a.forEach(o=>{var A;if(o.length===1){const c=o[0],u=(A=this.context.element)===null||A===void 0?void 0:A.getElement(Y(c)),h=this.resetEdgeStyle(c);(!u||!mf(h,u.attributes))&&Vr(n,u?"update":"add","edge",h);return}const l=o.map(({source:c,target:u,style:h={}},d)=>{const{startArrow:f,endArrow:g}=h,p={},[v,y]=s[`${c}|${u}|${d}`]?["endArrow","startArrow"]:["startArrow","endArrow"];return BA(f)&&(p[v]=f),BA(g)&&(p[y]=g),p}).reduce((c,u)=>Object.assign(Object.assign({},c),u),{});o.forEach((c,u,h)=>{var d;if(u!==0){Vr(n,"remove","edge",c);return}const f=Object.assign({},Te(this.options.style)?this.options.style(h):this.options.style,{childrenData:h});this.cacheMergeStyle.set(Y(c),f);const g=Object.assign(Object.assign({},c),{type:"line",style:Object.assign(Object.assign(Object.assign({},c.style),l),f)}),p=(d=this.context.element)===null||d===void 0?void 0:d.getElement(Y(c));(!p||!mf(g.style,p.attributes))&&Vr(n,p?"update":"add","edge",g,!0)})})}}beforeDraw(e){const t=this.getAffectedParallelEdges(e);return t.size===0||(this.options.mode==="bundle"?this.applyBundlingStyle(e,t,this.options.distance):this.applyMergingStyle(e,t)),e}}Sf.defaultOptions={mode:"bundle",distance:15};const WU=r=>{const e=new Map,t=new Set,n={},i=new Map;for(const[a,s]of r){if(t.has(a))continue;const{source:o,target:A}=s,l=`${o}-${A}`;e.has(l)||(e.set(l,[]),i.set(l,new Set));const c=e.get(l),u=i.get(l);c&&u&&!u.has(a)&&(c.push(s),u.add(a),t.add(a));for(const[h,d]of r)if(!(t.has(h)||h===a)&&TB(s,d)){const f=e.get(l),g=i.get(l);f&&g&&!g.has(h)&&(f.push(d),g.add(h),o===d.target&&A===d.source&&(n[`${d.source}|${d.target}|${f.length-1}`]=!0),t.add(h))}}return{edgeMap:e,reverses:n}},Bse=(r,e,t)=>e.filter(n=>TB(n,r)),TB=(r,e)=>{const{sourceNode:t,targetNode:n}=r.style||{},{sourceNode:i,targetNode:a}=e.style||{};return t===i&&n===a||t===a&&n===i};class Ese extends fs{beforeDraw(e,t){const{stage:n}=t;if(n==="visibility")return e;const{model:i}=this.context,{update:{nodes:a,edges:s,combos:o}}=e,A=(l,c)=>{i.getRelatedEdgesData(c).forEach(h=>!s.has(Y(h))&&s.set(Y(h),h))};return a.forEach(A),o.forEach(A),e}}const xse={animation:{"combo-collapse":BS,"combo-expand":OV,"node-collapse":wS,"node-expand":TV,"path-in":bS,"path-out":MV,fade:SV,translate:FV},behavior:{"brush-select":vl,"click-select":uh,"collapse-expand":kh,"create-edge":Qh,"drag-canvas":Uh,"drag-element-force":EW,"drag-element":Fl,"fix-element-size":Gh,"focus-element":Kh,"hover-activate":zh,"lasso-select":CW,"auto-adapt-label":ah,"optimize-viewport-transform":Vh,"scroll-canvas":jh,"zoom-canvas":Wh},combo:{circle:T9,rect:M9},edge:{cubic:Ws,line:xF,polyline:Ih,quadratic:_h,"cubic-horizontal":Th,"cubic-radial":Mh,"cubic-vertical":Oh},layout:{"antv-dagre":G$,"combo-combined":X7,"compact-box":NW,"d3-force":EY,"force-atlas2":HJ,circular:V$,concentric:Hv,dagre:bd,dendrogram:RW,fishbone:Md,force:UT,fruchterman:zJ,grid:jJ,indented:zW,mds:KT,mindmap:$W,radial:tee,random:Aee,snake:Od},node:{circle:wl,diamond:Qj,ellipse:vh,hexagon:Hj,html:xh,image:hF,rect:S9,star:F9,donut:gh,triangle:Ch},palette:{spectral:xee,tableau:Cee,oranges:See,greens:Fee,blues:Tee},theme:{dark:zae,light:Vae},plugin:{"bubble-sets":Rd,"edge-bundling":Gd,"edge-filter-lens":Kd,"grid-line":jd,background:Id,contextmenu:Hd,fisheye:zd,fullscreen:Vd,history:Wd,hull:Xd,legend:df,minimap:ff,snapline:gf,timebar:pf,title:_ae,toolbar:FU,tooltip:vf,watermark:yf},transform:{"arrange-draw-order":jae,"collapse-expand-combo":Wae,"collapse-expand-node":qae,"get-edge-actual-ends":pse,"map-node-size":xf,"place-radial-labels":Cf,"process-parallel-edges":Sf,"update-related-edges":Ese},shape:{circle:zi,ellipse:RA,group:Cn,html:Is,image:Av,line:_s,path:tr,polygon:ks,polyline:zc,rect:Gn,text:Ns,label:Ji,badge:zo}};function Cse(){Object.entries(xse).forEach(([r,e])=>{Object.entries(e).forEach(([t,n])=>{$ae(r,t,n)})})}Cse();const vA=10,gs="#1890ff",ps={canal:gs,pumpStation:"#52c41a",reservoir:"#13c2c2",sluice:"#faad14",dispatchUnit:"#722ed1",dispatchNode:"#eb2f96",auxiliary:gs},xa={canal:{fill:"#e6f7ff",stroke:"#1890ff",lineWidth:2,radius:4,width:200,height:40},pumpStation:{fill:"#f6ffed",stroke:"#52c41a",lineWidth:2,width:48,height:48,img:""},reservoir:{fill:"#e6fffb",stroke:"#13c2c2",lineWidth:2,radius:24,width:48,height:48},sluice:{fill:"#fffbe6",stroke:"#faad14",lineWidth:2,radius:4,width:48,height:36},dispatchUnit:{fill:"#f9f0ff",stroke:"#722ed1",lineWidth:2,radius:20,width:40,height:40},dispatchNode:{fill:"#fff0f6",stroke:"#eb2f96",lineWidth:2,radius:16,width:32,height:32},auxiliary:{fill:gs,stroke:gs,lineWidth:0,radius:0,width:vA,height:vA}},MB={stroke:gs,lineWidth:vA,endArrow:!1},qU={flow:{stroke:gs,lineWidth:vA},control:{stroke:"#faad14",lineWidth:3,lineDash:[8,4]},supply:{stroke:"#52c41a",lineWidth:3,lineDash:[6,4]}};function $U(r){return{...xa[r]}}function YU(r){const e={...MB};return r&&qU[r]?{...e,...qU[r]}:e}const OB={light:{name:"light",backgroundColor:"#ffffff",nodeStyle:xa,edgeStyle:MB},dark:{name:"dark",backgroundColor:"#141414",nodeStyle:{canal:{...xa.canal,fill:"#1d3557",stroke:"#4dabf7"},pumpStation:{...xa.pumpStation,fill:"#2d4a22",stroke:"#69db7c"},reservoir:{...xa.reservoir,fill:"#1d4a4a",stroke:"#38d9a9"},sluice:{...xa.sluice,fill:"#4a3e1d",stroke:"#ffd43b"},dispatchUnit:{...xa.dispatchUnit,fill:"#2d1d4a",stroke:"#b197fc"},dispatchNode:{...xa.dispatchNode,fill:"#4a1d3e",stroke:"#f783ac"},auxiliary:{...xa.auxiliary,fill:"#4dabf7",stroke:"#4dabf7"}},edgeStyle:{...MB,stroke:"#4dabf7"}}};function XU(r){const e=r?.name||"light",t=OB[e]??OB.light;return{...t,...r,nodeStyle:{...t.nodeStyle||{},...r?.nodeStyle||{}},edgeStyle:{...t.edgeStyle||{},...r?.edgeStyle||{}}}}function Sse(r,e){return{...r,...e}}function Fse(r,e){return{...r,...e}}const Ff={canal:{type:"rect",style:{fill:"#e6f7ff",stroke:ps.canal,lineWidth:2,radius:4,width:200,height:40}},pumpStation:{type:"circle",style:{fill:"#f6ffed",stroke:ps.pumpStation,lineWidth:2,width:48,height:48}},reservoir:{type:"circle",style:{fill:"#e6fffb",stroke:ps.reservoir,lineWidth:2,width:48,height:48}},sluice:{type:"rect",style:{fill:"#fffbe6",stroke:ps.sluice,lineWidth:2,radius:4,width:48,height:36}},dispatchUnit:{type:"circle",style:{fill:"#f9f0ff",stroke:ps.dispatchUnit,lineWidth:2,width:40,height:40}},dispatchNode:{type:"circle",style:{fill:"#fff0f6",stroke:ps.dispatchNode,lineWidth:2,width:32,height:32}},auxiliary:{type:"rect",style:{fill:"#f0f0f0",stroke:ps.auxiliary,lineWidth:1,width:16,height:16}}};function Tse(){}function Mse(r){return Ff[r]?.type||"circle"}function Ose(r){return{...Ff[r]?.style}}function Ise(r,e){const t=Ff[r]||Ff.dispatchNode;return{type:t.type,style:{...t.style,...e}}}const Tf={flow:{type:"polyline",style:{stroke:"#1890ff",lineWidth:2,endArrow:!0}},control:{type:"line",style:{stroke:"#faad14",lineWidth:1.5,lineDash:[6,3],endArrow:!0}},supply:{type:"line",style:{stroke:"#52c41a",lineWidth:1.5,lineDash:[4,4],endArrow:!0}},curve:{type:"quadratic",style:{stroke:"#91d5ff",lineWidth:2,endArrow:!0,curveOffset:30}}};function _se(){}function kse(r){return Tf[r||"flow"]?.type||"line"}function Nse(r){return{...Tf[r||"flow"]?.style}}function Lse(r,e){const t=Tf[r||"flow"]??Tf.flow;return{type:t.type,style:{...t.style,...e}}}function ZU(r){const e=[];return r.enableZoom!==!1&&e.push({type:"zoom-canvas",sensitivity:1,minZoom:.1,maxZoom:5}),r.enableDrag!==!1&&e.push({type:"drag-element",key:"drag-element",enable:t=>["node","combo"].includes(t.targetType),shadow:!1,dropEffect:"move",hideEdge:"none"}),e.push({type:"drag-canvas",key:"drag-canvas",enable:t=>t.targetType==="canvas"}),e.push({type:"click-select",multiple:!0}),r.enableBrush&&e.push({type:"brush-select",trigger:"shift"}),e.push({type:"hover-activate"}),e}function Qse(r){const e=[];return r.enableZoom!==!1&&e.push({type:"zoom-canvas",sensitivity:1,minZoom:.1,maxZoom:5}),e.push({type:"drag-canvas",enable:!0}),e.push({type:"hover-activate"}),e}const Use={ZOOM_CANVAS:"zoom-canvas",DRAG_CANVAS:"drag-canvas",DRAG_ELEMENT:"drag-element",CLICK_SELECT:"click-select",BRUSH_SELECT:"brush-select",HOVER_ACTIVATE:"hover-activate"};class IB{graph=null;container=null;options;state={loading:!1,rendered:!1,zoom:1,selectedNodes:[],selectedEdges:[]};eventHandlers=new Map;constructor(e){this.options=e}async init(){const e=typeof this.options.container=="string"?document.getElementById(this.options.container):this.options.container;if(!e)throw new Error("Container not found");this.container=e,XU(this.options.theme);const t=ZU(this.options);return this.graph=new Ef({container:e,width:this.options.width||e.clientWidth,height:this.options.height||e.clientHeight,autoFit:this.options.fitView?"view":void 0,padding:this.options.fitViewPadding,layout:this.buildLayoutConfig(this.options.layout),behaviors:t,plugins:this.buildPlugins(),node:{type:n=>n.nodeShape||"circle",style:n=>{const i=n,a=i.styleConfig||{};return i.nodeShape==="image"&&a.img?{src:a.img,size:[a.width||48,a.height||48],labelText:i.data?.label||"",labelPlacement:"bottom",labelOffsetY:8}:{fill:a.fill||"#fff",stroke:a.stroke||"#1890ff",lineWidth:a.lineWidth??2,radius:a.radius??4,size:a.width?[a.width,a.height||a.width]:void 0,labelText:i.data?.label||"",labelPlacement:"bottom"}}},edge:{type:n=>{const i=n;return i.styleConfig?.router?"polyline":i.edgeShape||"line"},style:n=>{const i=n,a={stroke:i.styleConfig?.stroke||"#1890ff",lineWidth:i.styleConfig?.lineWidth||2,endArrow:i.styleConfig?.endArrow??!0};return i.styleConfig?.router&&(a.router={type:"orth",offset:20}),a}}}),this.bindEvents(),this.state.rendered=!0,this.graph}buildLayoutConfig(e){return!e||e.type==="custom"?void 0:{force:{type:"force",preventOverlap:!0,nodeSize:50,...e.options},grid:{type:"grid",rows:4,cols:4,...e.options},dagre:{type:"dagre",rankdir:"TB",nodesep:60,ranksep:80,...e.options},circular:{type:"circular",radius:200,...e.options},radial:{type:"radial",unitRadius:100,...e.options},concentric:{type:"concentric",minNodeSpacing:60,...e.options},tree:{type:"dendrogram",direction:"TB",nodeSep:40,rankSep:100,...e.options}}[e.type]||{type:e.type,...e.options}}buildPlugins(){const e=[];return this.options.tooltip?.enabled!==!1&&e.push({type:"tooltip",getContent:(t,n)=>{if(this.options.tooltip?.formatter&&n.length>0)return this.options.tooltip.formatter(n[0]);const i=n[0];return`<div style="padding: 8px 12px;">
|
|
133
|
+
</div>`}).join("")})}};FU.defaultOptions={position:"top-left"};var TU=function(r,e,t,n){function i(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(c){try{l(n.next(c))}catch(u){s(u)}}function A(c){try{l(n.throw(c))}catch(u){s(u)}}function l(c){c.done?a(c.value):i(c.value).then(o,A)}l((n=n.apply(r,e||[])).next())})};class vf extends Qn{constructor(e,t){super(e,Object.assign({},vf.defaultOptions,t)),this.currentTarget=null,this.tooltipElement=null,this.container=null,this.isEnable=(n,i)=>{const{enable:a}=this.options;return typeof a=="function"?a(n,i):a},this.onClick=n=>{const{target:{id:i}}=n;this.currentTarget===i?this.hide(n):this.show(n)},this.onPointerMove=n=>{const{target:i}=n;!this.currentTarget||i.id===this.currentTarget||this.show(n)},this.onPointerLeave=n=>{this.hide(n)},this.onCanvasMove=n=>{this.hide(n)},this.onPointerOver=n=>{this.show(n)},this.showById=n=>TU(this,void 0,void 0,function*(){const i={target:{id:n}};yield this.show(i)}),this.getElementData=(n,i)=>{const{model:a}=this.context;switch(i){case"node":return a.getNodeData([n]);case"edge":return a.getEdgeData([n]);case"combo":return a.getComboData([n]);default:return[]}},this.show=n=>TU(this,void 0,void 0,function*(){var i,a;const{client:s,target:{id:o}}=n;if(Cl(n.target))return;const A=this.context.graph.getElementType(o),{getContent:l,title:c}=this.options,u=this.getElementData(o,A);if(!this.tooltipElement)return;if(!this.isEnable(n,u)){this.hide(n);return}let h={};if(l){if(h.content=yield l(n,u),!h.content)return}else{const g=this.context.graph.getElementRenderStyle(o),p=A==="node"?g.fill:g.stroke;h={title:c||A,data:u.map(v=>({name:"ID",value:v.id||`${v.source} -> ${v.target}`,color:p}))}}this.currentTarget=o;let d,f;if(s)d=s.x,f=s.y;else{const g=Rn(u,"0.style",{x:0,y:0});d=g.x,f=g.y}(a=(i=this.options).onOpenChange)===null||a===void 0||a.call(i,!0),this.tooltipElement.update(Object.assign(Object.assign(Object.assign({},this.tooltipStyleProps),{x:d,y:f,style:{".tooltip":{visibility:"visible"}}}),h))}),this.hide=n=>{var i,a,s,o,A;if(!n){(a=(i=this.options).onOpenChange)===null||a===void 0||a.call(i,!1),(s=this.tooltipElement)===null||s===void 0||s.hide(),this.currentTarget=null;return}if(!this.tooltipElement||!this.currentTarget)return;const{client:{x:l,y:c}}=n;(A=(o=this.options).onOpenChange)===null||A===void 0||A.call(o,!1),this.tooltipElement.hide(l,c),this.currentTarget=null},this.initTooltip=()=>{var n;const i=new tae({className:"tooltip",style:this.tooltipStyleProps});return(n=this.container)===null||n===void 0||n.appendChild(i.HTMLTooltipElement),i},this.render(),this.bindEvents()}getEvents(){return this.options.trigger==="click"?{"node:click":this.onClick,"edge:click":this.onClick,"combo:click":this.onClick,"canvas:click":this.onPointerLeave,contextmenu:this.onPointerLeave,drag:this.onPointerLeave}:{"node:pointerover":this.onPointerOver,"node:pointermove":this.onPointerMove,"canvas:pointermove":this.onCanvasMove,"edge:pointerover":this.onPointerOver,"edge:pointermove":this.onPointerMove,"combo:pointerover":this.onPointerOver,"combo:pointermove":this.onPointerMove,contextmenu:this.onPointerLeave,"node:drag":this.onPointerLeave}}update(e){var t;this.unbindEvents(),super.update(e),this.tooltipElement&&((t=this.container)===null||t===void 0||t.removeChild(this.tooltipElement.HTMLTooltipElement)),this.tooltipElement=this.initTooltip(),this.bindEvents()}render(){const{canvas:e}=this.context,t=e.getContainer();t&&(this.container=t,this.tooltipElement=this.initTooltip())}unbindEvents(){const{graph:e}=this.context,t=this.getEvents();Object.keys(t).forEach(n=>{e.off(n,t[n])})}bindEvents(){const{graph:e}=this.context,t=this.getEvents();Object.keys(t).forEach(n=>{e.on(n,t[n])})}get tooltipStyleProps(){const{canvas:e}=this.context,{center:t}=e.getBounds(),n=e.getContainer(),{top:i,left:a}=n.getBoundingClientRect(),{style:s,position:o,enterable:A,container:l={x:-a,y:-i},title:c,offset:u}=this.options,[h,d]=t,[f,g]=e.getSize();return{x:h,y:d,container:l,title:c,bounding:{x:0,y:0,width:f,height:g},position:o,enterable:A,offset:u,style:s}}destroy(){var e;this.unbindEvents(),this.tooltipElement&&((e=this.container)===null||e===void 0||e.removeChild(this.tooltipElement.HTMLTooltipElement)),super.destroy()}}vf.defaultOptions={trigger:"hover",position:"top-right",enterable:!1,enable:!0,offset:[10,10],style:{".tooltip":{visibility:"hidden"}}};var MU=function(r,e,t,n){function i(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(c){try{l(n.next(c))}catch(u){s(u)}}function A(c){try{l(n.throw(c))}catch(u){s(u)}}function l(c){c.done?a(c.value):i(c.value).then(o,A)}l((n=n.apply(r,e||[])).next())})};let hA;function OU(r,e){return hA||(hA=document.createElement("canvas")),hA.width=r,hA.height=e,hA.getContext("2d").clearRect(0,0,r,e),hA}function Uae(r,e,t,n){return MU(this,void 0,void 0,function*(){const i=OU(r,e),a=i.getContext("2d"),{rotate:s,opacity:o,textFill:A,textFontSize:l,textFontFamily:c,textFontVariant:u,textFontWeight:h,textAlign:d,textBaseline:f}=n;return a.textAlign=d,a.textBaseline=f,a.translate(r/2,e/2),a.font=`${l}px ${c} ${u} ${h}`,s&&a.rotate(s),o&&(a.globalAlpha=o),A&&(a.fillStyle=A,a.fillText(`${t}`,0,0)),i.toDataURL()})}function Pae(r,e,t,n){return MU(this,void 0,void 0,function*(){const i=OU(r,e),a=i.getContext("2d"),{rotate:s,opacity:o}=n;s&&a.rotate(s),o&&(a.globalAlpha=o);const A=new Image;return A.crossOrigin="anonymous",A.src=t,new Promise(l=>{A.onload=function(){const c=r>A.width?(r-A.width)/2:0,u=e>A.height?(e-A.height)/2:0;a.drawImage(A,0,0,A.width,A.height,c,u,r-c*2,e-u*2),l(i.toDataURL())}})})}var Dae=function(r,e,t,n){function i(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(c){try{l(n.next(c))}catch(u){s(u)}}function A(c){try{l(n.throw(c))}catch(u){s(u)}}function l(c){c.done?a(c.value):i(c.value).then(o,A)}l((n=n.apply(r,e||[])).next())})},Rae=function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t};class yf extends Qn{constructor(e,t){super(e,Object.assign({},yf.defaultOptions,t)),this.$element=aA("watermark"),this.context.canvas.getContainer().appendChild(this.$element),this.update(t)}update(e){const t=Object.create(null,{update:{get:()=>super.update}});return Dae(this,void 0,void 0,function*(){t.update.call(this,e);const n=this.options,{width:i,height:a,text:s,imageURL:o}=n,A=Rae(n,["width","height","text","imageURL"]);Object.keys(A).forEach(c=>{c.startsWith("background")&&(this.$element.style[c]=e[c])});const l=o?yield Pae(i,a,o,A):yield Uae(i,a,s,A);this.$element.style.backgroundImage=`url(${l})`})}destroy(){super.destroy(),this.$element.remove()}}yf.defaultOptions={width:200,height:100,opacity:.2,rotate:Math.PI/12,text:"",textFill:"#000",textFontSize:16,textAlign:"center",textBaseline:"middle",backgroundRepeat:"repeat"};const Hae=["#7E92B5","#F4664A","#FFBE3A"],Gae={type:"group",color:["#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]},Kae={type:"group",color:["#99ADD1","#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]};function IU(r){const{bgColor:e,textColor:t,nodeColor:n,nodeColorDisabled:i,nodeStroke:a,nodeHaloStrokeOpacityActive:s=.15,nodeHaloStrokeOpacitySelected:o=.25,nodeOpacityDisabled:A=.06,nodeIconOpacityInactive:l=.85,nodeOpacityInactive:c=.25,nodeBadgePalette:u=Hae,nodePaletteOptions:h=Gae,edgeColor:d,edgeColorDisabled:f,edgePaletteOptions:g=Kae,comboColor:p,comboColorDisabled:v,comboStroke:y,comboStrokeDisabled:m,edgeColorInactive:b}=r;return{background:e,node:{palette:h,style:{donutOpacity:1,badgeBackgroundOpacity:1,badgeFill:"#fff",badgeFontSize:8,badgePadding:[0,4],badgePalette:u,fill:n,fillOpacity:1,halo:!1,iconFill:"#fff",iconOpacity:1,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelFill:t,labelFillOpacity:.85,labelLineHeight:16,labelPadding:[0,2],labelFontSize:12,labelFontWeight:400,labelOpacity:1,labelOffsetY:2,lineWidth:0,portFill:n,portLineWidth:1,portStroke:a,portStrokeOpacity:.65,size:32,stroke:a,strokeOpacity:1,zIndex:2},state:{selected:{halo:!0,haloLineWidth:24,haloStrokeOpacity:o,labelFontSize:12,labelFontWeight:"bold",lineWidth:4,stroke:a},active:{halo:!0,haloLineWidth:12,haloStrokeOpacity:s},highlight:{labelFontWeight:"bold",lineWidth:4,stroke:a,strokeOpacity:.85},inactive:{badgeBackgroundOpacity:c,donutOpacity:c,fillOpacity:c,iconOpacity:l,labelFill:t,labelFillOpacity:c,strokeOpacity:c},disabled:{badgeBackgroundOpacity:.25,donutOpacity:A,fill:i,fillOpacity:A,iconFill:i,iconOpacity:.25,labelFill:t,labelFillOpacity:.25,strokeOpacity:A}},animation:{enter:"fade",exit:"fade",show:"fade",hide:"fade",expand:"node-expand",collapse:"node-collapse",update:[{fields:["x","y","fill","stroke"]}],translate:[{fields:["x","y"]}]}},edge:{palette:g,style:{badgeBackgroundFill:d,badgeFill:"#fff",badgeFontSize:8,badgeOffsetX:10,badgeBackgroundOpacity:1,fillOpacity:1,halo:!1,haloLineWidth:12,haloStrokeOpacity:1,increasedLineWidthForHitTesting:2,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[4,4,4,4],labelFill:t,labelFontSize:12,labelFontWeight:400,labelOpacity:1,labelPlacement:"center",labelTextBaseline:"middle",lineWidth:1,stroke:d,strokeOpacity:1,zIndex:1},state:{selected:{halo:!0,haloStrokeOpacity:.25,labelFontSize:14,labelFontWeight:"bold",lineWidth:3},active:{halo:!0,haloStrokeOpacity:.15},highlight:{labelFontWeight:"bold",lineWidth:3},inactive:{stroke:b,fillOpacity:.08,labelOpacity:.25,strokeOpacity:.08,badgeBackgroundOpacity:.25},disabled:{stroke:f,fillOpacity:.45,strokeOpacity:.45,labelOpacity:.25,badgeBackgroundOpacity:.45}},animation:{enter:"fade",exit:"fade",expand:"path-in",collapse:"path-out",show:"fade",hide:"fade",update:[{fields:["sourceNode","targetNode"]},{fields:["stroke"],shape:"key"}],translate:[{fields:["sourceNode","targetNode"]}]}},combo:{style:{collapsedMarkerFill:e,collapsedMarkerFontSize:12,collapsedMarkerFillOpacity:1,collapsedSize:32,collapsedFillOpacity:1,fill:p,halo:!1,haloLineWidth:12,haloStroke:y,haloStrokeOpacity:.25,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[2,4,2,4],labelFill:t,labelFontSize:12,labelFontWeight:400,labelOpacity:1,lineDash:0,lineWidth:1,fillOpacity:.04,strokeOpacity:1,padding:10,stroke:y},state:{selected:{halo:!0,labelFontSize:14,labelFontWeight:700,lineWidth:4},active:{halo:!0},highlight:{labelFontWeight:700,lineWidth:4},inactive:{fillOpacity:.65,labelOpacity:.25,strokeOpacity:.65},disabled:{fill:v,fillOpacity:.25,labelOpacity:.25,stroke:m,strokeOpacity:.25}},animation:{enter:"fade",exit:"fade",show:"fade",hide:"fade",expand:"combo-expand",collapse:"combo-collapse",update:[{fields:["x","y"]},{fields:["fill","stroke","lineWidth"],shape:"key"}],translate:[{fields:["x","y"]}]}}}}const zae=IU({bgColor:"#000000",comboColor:"#fdfdfd",comboColorDisabled:"#d0e4ff",comboStroke:"#99add1",comboStrokeDisabled:"#969696",edgeColor:"#637088",edgeColorDisabled:"#637088",edgeColorInactive:"#D0E4FF",edgePaletteOptions:{type:"group",color:["#637088","#0F55A6","#008383","#9C5D38","#8B53A6","#4E40A6","#8F6608","#3E801D","#A65383","#175E75","#0F8248"]},nodeColor:"#1783ff",nodeColorDisabled:"#D0E4FF",nodeHaloStrokeOpacityActive:.25,nodeHaloStrokeOpacitySelected:.45,nodeIconOpacityInactive:.45,nodeOpacityDisabled:.25,nodeOpacityInactive:.45,nodeStroke:"#d0e4ff",textColor:"#ffffff"}),Vae=IU({bgColor:"#ffffff",comboColor:"#99ADD1",comboColorDisabled:"#f0f0f0",comboStroke:"#99add1",comboStrokeDisabled:"#d9d9d9",edgeColor:"#99add1",edgeColorDisabled:"#d9d9d9",edgeColorInactive:"#1B324F",nodeColor:"#1783ff",nodeColorDisabled:"#1B324F",nodeHaloStrokeOpacityActive:.15,nodeHaloStrokeOpacitySelected:.25,nodeIconOpacityInactive:.85,nodeOpacityDisabled:.06,nodeOpacityInactive:.25,nodeStroke:"#000000",textColor:"#000000"});class fs extends Jp{beforeDraw(e,t){return e}afterLayout(e,t){}}class jae extends fs{beforeDraw(e){const{model:t}=this.context,n=e.add.combos,i=a=>{const s=[];return a.forEach((o,A)=>{const c=t.getAncestorsData(A,"combo").map(u=>Y(u)).reverse();s.push([A,o,c.length])}),new Map(s.sort(([,,o],[,,A])=>A-o).map(([o,A])=>[o,A]))};return e.add.combos=i(n),e.update.combos=i(e.update.combos),e}}function Vr(r,e,t,n,i){const a=Y(n),s=`${t}s`,o=i?n:r.add[s].get(a)||r.update[s].get(a)||r.remove[s].get(a)||n;Object.entries(r).forEach(([A,l])=>{e===A?l[s].set(a,o):l[s].delete(a)})}function mf(r,e){return Object.keys(r).every(t=>r[t]===e[t])}class Wae extends fs{beforeDraw(e,t){if(t.stage==="visibility"||!this.context.model.model.hasTreeStructure(Ft))return e;const{model:n}=this.context,{add:i,update:a}=e,s=[...e.update.combos.entries(),...e.add.combos.entries()];for(;s.length;){const[o,A]=s.pop();if(Fr(A)){const l=n.getDescendantsData(o),c=l.map(Y),{internal:u,external:h}=mv(c,d=>n.getRelatedEdgesData(d));l.forEach(d=>{const f=Y(d),g=s.findIndex(([v])=>v===f);g!==-1&&s.splice(g,1);const p=n.getElementType(f);Vr(e,"remove",p,d)}),u.forEach(d=>Vr(e,"remove","edge",d)),h.forEach(d=>{var f;const g=Y(d);((f=this.context.element)===null||f===void 0?void 0:f.getElement(g))?a.edges.set(g,d):i.edges.set(g,d)})}else{const l=n.getChildrenData(o),c=l.map(Y),{edges:u}=mv(c,h=>n.getRelatedEdgesData(h));[...l,...u].forEach(h=>{var d;const f=Y(h),g=n.getElementType(f);((d=this.context.element)===null||d===void 0?void 0:d.getElement(f))?Vr(e,"update",g,h):Vr(e,"add",g,h),g==="combo"&&s.push([f,h])})}}return e}}const _U=(r,e,t,n)=>{const i=`${t}s`,a=Y(n);!r.add[i].has(a)&&!r.update[i].has(a)&&r[e][i].set(Y(n),n)};class qae extends fs{getElement(e){return this.context.element.getElement(e)}handleExpand(e,t){if(_U(t,"add","node",e),Fr(e))return;const n=Y(e);_U(t,"add","node",e),this.context.model.getRelatedEdgesData(n).forEach(s=>{Vr(t,"add","edge",s)}),this.context.model.getChildrenData(n).forEach(s=>{this.handleExpand(s,t)})}beforeDraw(e){const{graph:t,model:n}=this.context;if(!n.model.hasTreeStructure(Rr))return e;const{add:{nodes:i,edges:a},update:{nodes:s}}=e,o=new Map,A=new Map;i.forEach((c,u)=>{Fr(c)&&o.set(u,c)}),a.forEach(c=>{if(t.getElementType(c.source)!=="node")return;const u=t.getNodeData(c.source);Fr(u)&&o.set(c.source,u)}),s.forEach((c,u)=>{const h=this.getElement(u);if(!h)return;const d=h.attributes.collapsed;Fr(c)?d||o.set(u,c):d&&A.set(u,c)});const l=new Set;return o.forEach((c,u)=>{n.getDescendantsData(u).forEach(d=>{const f=Y(d);if(l.has(f))return;Vr(e,"remove","node",d),n.getRelatedEdgesData(f).forEach(p=>{Vr(e,"remove","edge",p)}),l.add(f)})}),A.forEach((c,u)=>{if(n.getAncestorsData(u,Rr).some(Fr)){Vr(e,"remove","node",c);return}this.handleExpand(c,e)}),e}}function $ae(r,e,t){Wp[r][e]&&$i.warn(`The extension ${e} of ${r} has been registered before, and will be overridden.`),Object.assign(Wp[r],{[e]:t})}var kU=(function(){function r(e){ce(this,r),this.dragndropPluginOptions=e}return ue(r,[{key:"apply",value:function(t){var n=this,i=t.renderingService,a=t.renderingContext,s=a.root.ownerDocument,o=s.defaultView,A=function(c){var u=c.target,h=u===s,d=h&&n.dragndropPluginOptions.isDocumentDraggable?s:u.closest&&u.closest("[draggable=true]");if(d){var f=!1,g=c.timeStamp,p=[c.clientX,c.clientY],v=null,y=[c.clientX,c.clientY],m=(function(){var C=La(kn().mark(function S(F){var T,O,I,k,N,U;return kn().wrap(function(H){for(;;)switch(H.prev=H.next){case 0:if(f){H.next=2;break}if(T=F.timeStamp-g,O=wr([F.clientX,F.clientY],p),!(T<=n.dragndropPluginOptions.dragstartTimeThreshold||O<=n.dragndropPluginOptions.dragstartDistanceThreshold)){H.next=1;break}return H.abrupt("return");case 1:F.type="dragstart",d.dispatchEvent(F),f=!0;case 2:if(F.type="drag",F.dx=F.clientX-y[0],F.dy=F.clientY-y[1],d.dispatchEvent(F),y=[F.clientX,F.clientY],h){H.next=4;break}return I=n.dragndropPluginOptions.overlap==="pointer"?[F.canvasX,F.canvasY]:u.getBounds().center,H.next=3,s.elementsFromPoint(I[0],I[1]);case 3:k=H.sent,N=k[k.indexOf(u)+1],U=N?.closest("[droppable=true]")||(n.dragndropPluginOptions.isDocumentDroppable?s:null),v!==U&&(v&&(F.type="dragleave",F.target=v,v.dispatchEvent(F)),U&&(F.type="dragenter",F.target=U,U.dispatchEvent(F)),v=U,v&&(F.type="dragover",F.target=v,v.dispatchEvent(F)));case 4:case"end":return H.stop()}},S)}));return function(F){return C.apply(this,arguments)}})();o.addEventListener("pointermove",m);var b=function(S){if(f){S.detail={preventClick:!0};var F=S.clone();v&&(F.type="drop",F.target=v,v.dispatchEvent(F)),F.type="dragend",d.dispatchEvent(F),f=!1}o.removeEventListener("pointermove",m)};u.addEventListener("pointerup",b,{once:!0}),u.addEventListener("pointerupoutside",b,{once:!0})}};i.hooks.init.tap(r.tag,function(){o.addEventListener("pointerdown",A)}),i.hooks.destroy.tap(r.tag,function(){o.removeEventListener("pointerdown",A)})}}])})();kU.tag="Dragndrop";var Yae=(function(r){function e(){var t,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return ce(this,e),t=qe(this,e),t.name="dragndrop",t.options=n,t}return $e(e,r),ue(e,[{key:"init",value:function(){this.addRenderingPlugin(new kU(He({overlap:"pointer",isDocumentDraggable:!1,isDocumentDroppable:!1,dragstartDistanceThreshold:0,dragstartTimeThreshold:0},this.options)))}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}},{key:"setOptions",value:function(n){Object.assign(this.plugins[0].dragndropPluginOptions,n)}}])})(Ua),NU=function(r,e,t,n){function i(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(c){try{l(n.next(c))}catch(u){s(u)}}function A(c){try{l(n.throw(c))}catch(u){s(u)}}function l(c){c.done?a(c.value):i(c.value).then(o,A)}l((n=n.apply(r,e||[])).next())})},LU=function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t};const QU=["main"],UU=["background","main","label","transient"];function Xae(r){return r.main}class PU{getConfig(){return this.config}getLayer(e="main"){return this.extends.layers[e]||Xae(this.getLayers())}getLayers(){return this.extends.layers}getRenderer(e){return this.extends.renderers[e]}getCamera(e="main"){return this.getLayer(e).getCamera()}getRoot(e="main"){return this.getLayer(e).getRoot()}getContextService(e="main"){return this.getLayer(e).getContextService()}setCursor(e){this.config.cursor=e,this.getLayer().setCursor(e)}get document(){return this.getLayer().document}get context(){return this.getLayer().context}constructor(e){this.config={enableMultiLayer:!0},Object.assign(this.config,e);const t=this.config,{renderer:n,background:i,cursor:a,enableMultiLayer:s}=t,o=LU(t,["renderer","background","cursor","enableMultiLayer"]),A=s?UU:QU,l=DU(n,A),c=Object.fromEntries(A.map(u=>{const h=new Wg(Object.assign(Object.assign({},o),{supportsMutipleCanvasesInOneContainer:s,renderer:l[u],background:s?u==="background"?i:void 0:i}));return[u,h]}));RU(c),this.extends={config:this.config,renderer:n,renderers:l,layers:c}}get ready(){return Promise.all(Object.entries(this.getLayers()).map(([,e])=>e.ready))}resize(e,t){Object.assign(this.extends.config,{width:e,height:t}),Object.values(this.getLayers()).forEach(n=>{const i=n.getCamera(),a=i.getPosition(),s=i.getFocalPoint();n.resize(e,t),i.setPosition(a),i.setFocalPoint(s)})}getBounds(e){return dl(Object.values(this.getLayers()).map(t=>e?t.getRoot().childNodes.find(i=>i.classList.includes(e)):t.getRoot()).filter(t=>t?.childNodes.length>0).map(t=>t.getBounds()))}getContainer(){const e=this.extends.config.container;return typeof e=="string"?document.getElementById(e):e}getSize(){return[this.extends.config.width||0,this.extends.config.height||0]}appendChild(e,t){var n;const i=((n=e.style)===null||n===void 0?void 0:n.$layer)||"main";return this.getLayer(i).appendChild(e,t)}setRenderer(e){if(e===this.extends.renderer)return;const t=DU(e,this.config.enableMultiLayer?UU:QU);this.extends.renderers=t,Object.entries(t).forEach(([n,i])=>this.getLayer(n).setRenderer(i)),RU(this.getLayers())}getCanvasByViewport(e){return zn(this.getLayer().viewport2Canvas(Ei(e)))}getViewportByCanvas(e){return zn(this.getLayer().canvas2Viewport(Ei(e)))}getViewportByClient(e){return zn(this.getLayer().client2Viewport(Ei(e)))}getClientByViewport(e){return zn(this.getLayer().viewport2Client(Ei(e)))}getClientByCanvas(e){return this.getClientByViewport(this.getViewportByCanvas(e))}getCanvasByClient(e){const t=this.getLayer(),n=t.client2Viewport(Ei(e));return zn(t.viewport2Canvas(n))}toDataURL(){return NU(this,arguments,void 0,function*(e={}){const t=globalThis.devicePixelRatio||1,{mode:n="viewport"}=e,i=LU(e,["mode"]);let[a,s,o,A]=[0,0,0,0];if(n==="viewport")[o,A]=this.getSize();else if(n==="overall"){const v=this.getBounds(),y=qa(v);[a,s]=v.min,[o,A]=y}const l=og('<div id="virtual-image"></div>'),c=new Wg({width:o,height:A,renderer:new bl,devicePixelRatio:t,container:l,background:this.extends.config.background});yield c.ready,c.appendChild(this.getLayer("background").getRoot().cloneNode(!0)),c.appendChild(this.getRoot().cloneNode(!0));const u=this.getLayer("label").getRoot().cloneNode(!0),h=c.viewport2Canvas({x:0,y:0}),d=this.getCanvasByViewport([0,0]);u.translate([d[0]-h.x,d[1]-h.y]),u.scale(1/this.getCamera().getZoom()),c.appendChild(u),c.appendChild(this.getLayer("transient").getRoot().cloneNode(!0));const f=this.getCamera(),g=c.getCamera();if(n==="viewport")g.setZoom(f.getZoom()),g.setPosition(f.getPosition()),g.setFocalPoint(f.getFocalPoint());else if(n==="overall"){const[v,y,m]=g.getPosition(),[b,C,S]=g.getFocalPoint();g.setPosition([v+a,y+s,m]),g.setFocalPoint([b+a,C+s,S])}const p=c.getContextService();return new Promise(v=>{c.addEventListener(Lr.RERENDER,()=>NU(this,void 0,void 0,function*(){yield new Promise(m=>setTimeout(m,300));const y=yield p.toDataURL(i);v(y)}))})})}destroy(){Object.values(this.getLayers()).forEach(e=>{e.getCamera().cancelLandmarkAnimation(),e.destroy()})}}function DU(r,e){return Object.fromEntries(e.map(t=>{const n=r?.(t)||new bl;return n instanceof bl&&n.setConfig({enableDirtyRectangleRendering:!1}),t==="main"?n.registerPlugin(new Yae({isDocumentDraggable:!0,isDocumentDroppable:!0,dragstartDistanceThreshold:10,dragstartTimeThreshold:100})):n.unregisterPlugin(n.getPlugin("dom-interaction")),[t,n]}))}function RU(r){Object.entries(r).forEach(([e,t])=>{const n=t.getContextService().getDomElement();n?.style&&(n.style.gridArea="1 / 1 / 2 / 2",n.style.outline="none",n.tabIndex=1,e!=="main"&&(n.style.pointerEvents="none")),n?.parentElement&&(n.parentElement.style.display="grid",n.parentElement.style.isolation="isolate")})}const dA=r=>r?parseInt(r):0;function Zae(r){const e=getComputedStyle(r),t=r.clientWidth||dA(e.width),n=r.clientHeight||dA(e.height),i=dA(e.paddingLeft)+dA(e.paddingRight),a=dA(e.paddingTop)+dA(e.paddingBottom);return[t-i,n-a]}function HU(r){if(!r)return[0,0];let e=640,t=480;const[n,i]=Zae(r);e=n||e,t=i||t;const a=1,s=1;return[Math.max(Ee(e)?e:a,a),Math.max(Ee(t)?t:s,s)]}class wf{constructor(e){this.type=e}}class xn extends wf{constructor(e,t){super(e),this.data=t}}class ci extends wf{constructor(e,t,n,i){super(e),this.animationType=t,this.animation=n,this.data=i}}class fA extends wf{constructor(e,t,n){super(e),this.elementType=t,this.data=n}}class bf extends wf{constructor(e,t){super(e),this.data=t}}function On(r,e){r.emit(e.type,e)}function Jae(r){if(!r)return null;if(r instanceof Jx)return{type:"canvas",element:r};let e=r;for(;e;){if(El(e))return{type:"node",element:e};if(MF(e))return{type:"edge",element:e};if(wv(e))return{type:"combo",element:e};e=e.parentElement}return null}function GU(r){var e;return((e=r?.style)===null||e===void 0?void 0:e.zIndex)||0}const tc="cachedStyle",SB=r=>`__${r}__`;function ese(r,e){const t=Array.isArray(e)?e:[e];Rn(r,tc)||xA(r,tc,{}),t.forEach(n=>{xA(Rn(r,tc),SB(n),r.attributes[n])})}function KU(r,e){return Rn(r,[tc,SB(e)])}function tse(r,e){return SB(e)in(Rn(r,tc)||{})}class nse{constructor(e){this.tasks=[],this.animations=new Set,this.context=e}getTasks(){const e=[...this.tasks];return this.tasks=[],e}add(e,t){this.tasks.push([e,t])}animate(e,t,n){var i,a,s;(i=t?.before)===null||i===void 0||i.call(t);const o=this.getTasks().map(([l,c])=>{var u,h,d;const{element:f,elementType:g,stage:p}=l,v=EV(this.context.options,g,p,e);(u=c?.before)===null||u===void 0||u.call(c);const y=v.length?CV(f,this.inferStyle(l,n),v):null;return y?((h=c?.beforeAnimate)===null||h===void 0||h.call(c,y),y.finished.then(()=>{var m,b;(m=c?.afterAnimate)===null||m===void 0||m.call(c,y),(b=c?.after)===null||b===void 0||b.call(c),this.animations.delete(y)})):(d=c?.after)===null||d===void 0||d.call(c),y}).filter(Boolean);o.forEach(l=>this.animations.add(l));const A=qp(o);return A?((a=t?.beforeAnimate)===null||a===void 0||a.call(t,A),A.finished.then(()=>{var l,c;(l=t?.afterAnimate)===null||l===void 0||l.call(t,A),(c=t?.after)===null||c===void 0||c.call(t),this.release()})):(s=t?.after)===null||s===void 0||s.call(t),A}inferStyle(e,t){var n,i;const{element:a,elementType:s,stage:o,originalStyle:A,updatedStyle:l={}}=e;e.modifiedStyle||(e.modifiedStyle=Object.assign(Object.assign({},A),l));const{modifiedStyle:c}=e,u={},h={};if(o==="enter")Object.assign(u,{opacity:0});else if(o==="exit")Object.assign(h,{opacity:0});else if(o==="show")Object.assign(u,{opacity:0}),Object.assign(h,{opacity:(n=KU(a,"opacity"))!==null&&n!==void 0?n:hl("opacity")});else if(o==="hide")Object.assign(u,{opacity:(i=KU(a,"opacity"))!==null&&i!==void 0?i:hl("opacity")}),Object.assign(h,{opacity:0});else if(o==="collapse"){const{collapse:d}=t||{},{target:f,descendants:g,position:p}=d;if(s==="node"){if(g.includes(a.id)){const[v,y,m]=p;Object.assign(h,{x:v,y,z:m})}}else if(s==="combo"){if(a.id===f||g.includes(a.id)){const[v,y]=p;Object.assign(h,{x:v,y,childrenNode:A.childrenNode})}}else s==="edge"&&Object.assign(h,{sourceNode:c.sourceNode,targetNode:c.targetNode})}else if(o==="expand"){const{expand:d}=t||{},{target:f,descendants:g,position:p}=d;if(s==="node"){if(a.id===f||g.includes(a.id)){const[v,y,m]=p;Object.assign(u,{x:v,y,z:m})}}else if(s==="combo"){if(a.id===f||g.includes(a.id)){const[v,y,m]=p;Object.assign(u,{x:v,y,z:m,childrenNode:c.childrenNode})}}else s==="edge"&&Object.assign(u,{sourceNode:c.sourceNode,targetNode:c.targetNode})}return[Object.keys(u).length>0?Object.assign({},A,u):A,Object.keys(h).length>0?Object.assign({},c,h):c]}stop(){this.animations.forEach(e=>e.cancel())}clear(){this.tasks=[]}release(){var e,t;const{canvas:n}=this.context,i=(t=(e=n.document)===null||e===void 0?void 0:e.timeline)===null||t===void 0?void 0:t.animationsWithPromises;i&&(n.document.timeline.animationsWithPromises=i.filter(a=>a.playState!=="finished"))}destroy(){this.stop(),this.animations.clear(),this.tasks=[]}}class rse{constructor(e){this.batchCount=0,this.context=e}emit(e){const{graph:t}=this.context;t.emit(e.type,e)}startBatch(e=!0){this.batchCount++,this.batchCount===1&&this.emit(new xn(fe.BATCH_START,{initiate:e}))}endBatch(){this.batchCount--,this.batchCount===0&&this.emit(new xn(fe.BATCH_END))}get isBatching(){return this.batchCount>0}destroy(){this.context=null}}class ise extends Zp{constructor(e){super(e),this.currentTarget=null,this.currentTargetType=null,this.category="behavior",this.forwardCanvasEvents=t=>{const{target:n}=t,i=Jae(n);if(!i)return;const{graph:a,canvas:s}=this.context,{type:o,element:A}=i;if("destroyed"in A&&(Cl(A)||A.destroyed))return;const{type:l,detail:c,button:u}=t,h=Object.assign(Object.assign({},t),{target:A,targetType:o,originalTarget:n});l===re.POINTER_MOVE&&(this.currentTarget!==A&&(this.currentTarget&&a.emit(`${this.currentTargetType}:${re.POINTER_LEAVE}`,Object.assign(Object.assign({},h),{type:re.POINTER_LEAVE,target:this.currentTarget,targetType:this.currentTargetType})),A&&(Object.assign(h,{type:re.POINTER_ENTER}),a.emit(`${o}:${re.POINTER_ENTER}`,h))),this.currentTarget=A,this.currentTargetType=o),l===re.CLICK&&u===2||(a.emit(`${o}:${l}`,h),a.emit(l,h)),l===re.CLICK&&c===2&&(Object.assign(h,{type:re.DBLCLICK}),a.emit(`${o}:${re.DBLCLICK}`,h),a.emit(re.DBLCLICK,h)),l===re.POINTER_DOWN&&u===2&&(Object.assign(h,{type:re.CONTEXT_MENU,preventDefault:()=>{var d;(d=s.getContainer())===null||d===void 0||d.addEventListener(re.CONTEXT_MENU,f=>f.preventDefault(),{once:!0})}}),a.emit(`${o}:${re.CONTEXT_MENU}`,h),a.emit(re.CONTEXT_MENU,h))},this.forwardContainerEvents=t=>{this.context.graph.emit(t.type,t)},this.forwardEvents(),this.setBehaviors(this.context.options.behaviors||[])}setBehaviors(e){this.setExtensions(e)}forwardEvents(){const e=this.context.canvas.getContainer();e&&[Ho.KEY_DOWN,Ho.KEY_UP].forEach(n=>{e.addEventListener(n,this.forwardContainerEvents)});const t=this.context.canvas.document;t&&[re.CLICK,re.DBLCLICK,re.POINTER_OVER,re.POINTER_LEAVE,re.POINTER_ENTER,re.POINTER_MOVE,re.POINTER_OUT,re.POINTER_DOWN,re.POINTER_UP,re.CONTEXT_MENU,re.DRAG_START,re.DRAG,re.DRAG_END,re.DRAG_ENTER,re.DRAG_OVER,re.DRAG_LEAVE,re.DROP,re.WHEEL].forEach(n=>{t.addEventListener(n,this.forwardCanvasEvents)})}destroy(){const e=this.context.canvas.getContainer();e&&[Ho.KEY_DOWN,Ho.KEY_UP].forEach(t=>{e.removeEventListener(t,this.forwardContainerEvents)}),this.context.canvas.document.removeAllEventListeners(),super.destroy()}}var ase=function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t};function FB(r){const{id:e=Y(r),style:t,data:n}=r,i=ase(r,["id","style","data"]),a=Object.assign(Object.assign({},r),{style:Object.assign({},t),data:Object.assign({},n)});return IV(r)?Object.assign({id:e,data:a},i):{id:e,data:a}}function Pn(r){return r.data}function sse(r){if(r.hasTreeStructure(Rr))return;r.attachTreeStructure(Rr);const e=r.getAllEdges();for(const t of e){const{source:n,target:i}=t;r.setParent(i,n,Rr)}}class ose{constructor(){this.latestRemovedComboIds=new Set,this.comboIds=new Set,this.changes=[],this.batchCount=0,this.isTraceless=!1,this.enableUpdateNodeLikeHierarchy=!0,this.model=new Tn}pushChange(e){if(this.isTraceless)return;const{type:t}=e;if(t===Rt.NodeUpdated||t===Rt.EdgeUpdated||t===Rt.ComboUpdated){const{value:n,original:i}=e;this.changes.push({value:Cv(n),original:Cv(i),type:t})}else this.changes.push({value:Cv(e.value),type:t})}getChanges(){return this.changes}clearChanges(){this.changes=[]}batch(e){this.batchCount++,this.model.batch(e),this.batchCount--}isBatching(){return this.batchCount>0}silence(e){this.isTraceless=!0,e(),this.isTraceless=!1}isCombo(e){return this.comboIds.has(e)||this.latestRemovedComboIds.has(e)}getData(){return{nodes:this.getNodeData(),edges:this.getEdgeData(),combos:this.getComboData()}}getNodeData(e){return this.model.getAllNodes().reduce((t,n)=>{const i=Pn(n);return this.isCombo(Y(i))||(e===void 0||e.includes(Y(i)))&&t.push(i),t},[])}getEdgeDatum(e){return Pn(this.model.getEdge(e))}getEdgeData(e){return this.model.getAllEdges().reduce((t,n)=>{const i=Pn(n);return(e===void 0||e.includes(Y(i)))&&t.push(i),t},[])}getComboData(e){return this.model.getAllNodes().reduce((t,n)=>{const i=Pn(n);return this.isCombo(Y(i))&&(e===void 0||e.includes(Y(i)))&&t.push(i),t},[])}getRootsData(e=Rr){return this.model.getRoots(e).map(Pn)}getAncestorsData(e,t){const{model:n}=this;return!n.hasNode(e)||!n.hasTreeStructure(t)?[]:n.getAncestors(e,t).map(Pn)}getDescendantsData(e){const t=this.getElementDataById(e),n=[];return Ko(t,i=>{i!==t&&n.push(i)},i=>this.getChildrenData(Y(i)),"TB"),n}getParentData(e,t){const{model:n}=this;if(!t){$i.warn("The hierarchy structure key is not specified");return}if(!n.hasNode(e)||!n.hasTreeStructure(t))return;const i=n.getParent(e,t);return i?Pn(i):void 0}getChildrenData(e){const t=this.getElementType(e)==="node"?Rr:Ft,{model:n}=this;return!n.hasNode(e)||!n.hasTreeStructure(t)?[]:n.getChildren(e,t).map(Pn)}getElementsDataByType(e){return e==="node"?this.getNodeData():e==="edge"?this.getEdgeData():e==="combo"?this.getComboData():[]}getElementDataById(e){return this.getElementType(e)==="edge"?this.getEdgeDatum(e):this.getNodeLikeDatum(e)}getNodeLikeDatum(e){const t=this.model.getNode(e);return Pn(t)}getNodeLikeData(e){return this.model.getAllNodes().reduce((t,n)=>{const i=Pn(n);return e?e.includes(Y(i))&&t.push(i):t.push(i),t},[])}getElementDataByState(e,t){return this.getElementsDataByType(e).filter(i=>{var a;return(a=i.states)===null||a===void 0?void 0:a.includes(t)})}getElementState(e){var t;return((t=this.getElementDataById(e))===null||t===void 0?void 0:t.states)||[]}hasNode(e){return this.model.hasNode(e)&&!this.isCombo(e)}hasEdge(e){return this.model.hasEdge(e)}hasCombo(e){return this.model.hasNode(e)&&this.isCombo(e)}getRelatedEdgesData(e,t="both"){return this.model.getRelatedEdges(e,t).map(Pn)}getNeighborNodesData(e){return this.model.getNeighbors(e).map(Pn)}setData(e){const{nodes:t=[],edges:n=[],combos:i=[]}=e,{nodes:a,edges:s,combos:o}=this.getData(),A=Xa(a,t,u=>Y(u),Wo),l=Xa(s,n,u=>Y(u),Wo),c=Xa(o,i,u=>Y(u),Wo);this.batch(()=>{const u={nodes:A.enter,edges:l.enter,combos:c.enter};this.addData(u),this.computeZIndex(u,"add",!0);const h={nodes:A.update,edges:l.update,combos:c.update};this.updateData(h),this.computeZIndex(h,"update",!0);const d={nodes:A.exit.map(Y),edges:l.exit.map(Y),combos:c.exit.map(Y)};this.removeData(d)})}addData(e){const{nodes:t,edges:n,combos:i}=e;this.batch(()=>{this.addComboData(i),this.addNodeData(t),this.addEdgeData(n)}),this.computeZIndex(e,"add")}addNodeData(e=[]){e.length&&(this.model.addNodes(e.map(t=>(this.pushChange({value:t,type:Rt.NodeAdded}),FB(t)))),this.updateNodeLikeHierarchy(e),this.computeZIndex({nodes:e},"add"))}addEdgeData(e=[]){e.length&&(this.model.addEdges(e.map(t=>(this.pushChange({value:t,type:Rt.EdgeAdded}),FB(t)))),this.computeZIndex({edges:e},"add"))}addComboData(e=[]){if(!e.length)return;const{model:t}=this;t.hasTreeStructure(Ft)||t.attachTreeStructure(Ft),t.addNodes(e.map(n=>(this.comboIds.add(Y(n)),this.pushChange({value:n,type:Rt.ComboAdded}),FB(n)))),this.updateNodeLikeHierarchy(e),this.computeZIndex({combos:e},"add")}addChildrenData(e,t){const n=this.getNodeLikeDatum(e),i=t.map(Y);this.addNodeData(t),this.updateNodeData([{id:e,children:[...n.children||[],...i]}]),this.addEdgeData(i.map(a=>({source:e,target:a})))}computeZIndex(e,t,n=!1){!n&&this.isBatching()||this.batch(()=>{const{nodes:i=[],edges:a=[],combos:s=[]}=e;s.forEach(o=>{var A,l,c;const u=Y(o);if(t==="add"&&Ee((A=o.style)===null||A===void 0?void 0:A.zIndex)||t==="update"&&!("combo"in o))return;const h=this.getParentData(u,Ft),d=h?((c=(l=h.style)===null||l===void 0?void 0:l.zIndex)!==null&&c!==void 0?c:0)+1:0;this.preventUpdateNodeLikeHierarchy(()=>{this.updateComboData([{id:u,style:{zIndex:d}}])})}),i.forEach(o=>{var A,l,c;const u=Y(o);if(t==="add"&&Ee((A=o.style)===null||A===void 0?void 0:A.zIndex)||t==="update"&&!("combo"in o)&&!("children"in o))return;let h=0;const d=this.getParentData(u,Ft);if(d)h=(((l=d.style)===null||l===void 0?void 0:l.zIndex)||0)+1;else{const f=this.getParentData(u,Rr);f&&(h=((c=f?.style)===null||c===void 0?void 0:c.zIndex)||0)}this.preventUpdateNodeLikeHierarchy(()=>{this.updateNodeData([{id:u,style:{zIndex:h}}])})}),a.forEach(o=>{var A,l,c,u,h;if(Ee((A=o.style)===null||A===void 0?void 0:A.zIndex))return;let{id:d,source:f,target:g}=o;if(!d)d=Y(o);else{const y=this.getEdgeDatum(d);f=y.source,g=y.target}if(!f||!g)return;const p=((c=(l=this.getNodeLikeDatum(f))===null||l===void 0?void 0:l.style)===null||c===void 0?void 0:c.zIndex)||0,v=((h=(u=this.getNodeLikeDatum(g))===null||u===void 0?void 0:u.style)===null||h===void 0?void 0:h.zIndex)||0;this.updateEdgeData([{id:Y(o),style:{zIndex:Math.max(p,v)-1}}])})})}getFrontZIndex(e){var t;const n=this.getElementType(e),i=this.getElementDataById(e),a=this.getData();if(Object.assign(a,{[`${n}s`]:a[`${n}s`].filter(s=>Y(s)!==e)}),n==="combo"&&!Fr(i)){const s=new Set(this.getAncestorsData(e,Ft).map(Y));a.nodes=a.nodes.filter(o=>!s.has(Y(o))),a.combos=a.combos.filter(o=>!s.has(Y(o))),a.edges=a.edges.filter(({source:o,target:A})=>!s.has(o)&&!s.has(A))}return Math.max(((t=i.style)===null||t===void 0?void 0:t.zIndex)||0,0,...Object.values(a).flat().map(s=>{var o;return(((o=s?.style)===null||o===void 0?void 0:o.zIndex)||0)+1}))}updateNodeLikeHierarchy(e){if(!this.enableUpdateNodeLikeHierarchy)return;const{model:t}=this;e.forEach(n=>{const i=Y(n),a=ih(n);a!==void 0&&(t.hasTreeStructure(Ft)||t.attachTreeStructure(Ft),a===null&&this.refreshComboData(i),this.setParent(i,ih(n),Ft));const s=n.children||[];if(s.length){t.hasTreeStructure(Rr)||t.attachTreeStructure(Rr);const o=s.filter(A=>t.hasNode(A));o.forEach(A=>this.setParent(A,i,Rr)),o.length!==s.length&&this.updateNodeData([{id:i,children:o}])}})}preventUpdateNodeLikeHierarchy(e){this.enableUpdateNodeLikeHierarchy=!1,e(),this.enableUpdateNodeLikeHierarchy=!0}updateData(e){const{nodes:t,edges:n,combos:i}=e;this.batch(()=>{this.updateNodeData(t),this.updateComboData(i),this.updateEdgeData(n)}),this.computeZIndex(e,"update")}updateNodeData(e=[]){if(!e.length)return;const{model:t}=this;this.batch(()=>{const n=[];e.forEach(i=>{const a=Y(i),s=Pn(t.getNode(a));if(Wo(s,i))return;const o=is(s,i);this.pushChange({value:o,original:s,type:Rt.NodeUpdated}),t.mergeNodeData(a,o),n.push(o)}),this.updateNodeLikeHierarchy(n)}),this.computeZIndex({nodes:e},"update")}refreshData(){const{nodes:e,edges:t,combos:n}=this.getData();e.forEach(i=>{this.pushChange({value:i,original:i,type:Rt.NodeUpdated})}),t.forEach(i=>{this.pushChange({value:i,original:i,type:Rt.EdgeUpdated})}),n.forEach(i=>{this.pushChange({value:i,original:i,type:Rt.ComboUpdated})})}syncNodeLikeDatum(e){const{model:t}=this,n=Y(e);if(!t.hasNode(n))return;const i=Pn(t.getNode(n)),a=is(i,e);t.mergeNodeData(n,a)}syncEdgeDatum(e){const{model:t}=this,n=Y(e);if(!t.hasEdge(n))return;const i=Pn(t.getEdge(n)),a=is(i,e);t.mergeEdgeData(n,a)}updateEdgeData(e=[]){if(!e.length)return;const{model:t}=this;this.batch(()=>{e.forEach(n=>{const i=Y(n),a=Pn(t.getEdge(i));if(Wo(a,n))return;n.source&&a.source!==n.source&&t.updateEdgeSource(i,n.source),n.target&&a.target!==n.target&&t.updateEdgeTarget(i,n.target);const s=is(a,n);this.pushChange({value:s,original:a,type:Rt.EdgeUpdated}),t.mergeEdgeData(i,s)})}),this.computeZIndex({edges:e},"update")}updateComboData(e=[]){if(!e.length)return;const{model:t}=this;t.batch(()=>{const n=[];e.forEach(i=>{const a=Y(i),s=Pn(t.getNode(a));if(Wo(s,i))return;const o=is(s,i);this.pushChange({value:o,original:s,type:Rt.ComboUpdated}),t.mergeNodeData(a,o),n.push(o)}),this.updateNodeLikeHierarchy(n)}),this.computeZIndex({combos:e},"update")}setParent(e,t,n,i=!0){if(e===t)return;const a=this.getNodeLikeDatum(e),s=ih(a);if(s!==t&&n===Ft){const o={id:e,combo:t};this.isCombo(e)?this.syncNodeLikeDatum(o):this.syncNodeLikeDatum(o)}this.model.setParent(e,t,n),i&&n===Ft&&bD([s,t]).forEach(o=>{o!==void 0&&this.refreshComboData(o)})}refreshComboData(e){const t=this.getComboData([e])[0],n=this.getAncestorsData(e,Ft);t&&this.pushChange({value:t,original:t,type:Rt.ComboUpdated}),n.forEach(i=>{this.pushChange({value:i,original:i,type:Rt.ComboUpdated})})}getElementPosition(e){const t=this.getElementDataById(e);return Fn(t)}translateNodeLikeBy(e,t){this.isCombo(e)?this.translateComboBy(e,t):this.translateNodeBy(e,t)}translateNodeLikeTo(e,t){this.isCombo(e)?this.translateComboTo(e,t):this.translateNodeTo(e,t)}translateNodeBy(e,t){const n=this.getElementPosition(e),i=je(n,[...t,0].slice(0,3));this.translateNodeTo(e,i)}translateNodeTo(e,t){const[n=0,i=0,a=0]=t;this.preventUpdateNodeLikeHierarchy(()=>{this.updateNodeData([{id:e,style:{x:n,y:i,z:a}}])})}translateComboBy(e,t){const[n=0,i=0,a=0]=t;if([n,i,a].some(isNaN)||[n,i,a].every(A=>A===0))return;const s=this.getComboData([e])[0];if(!s)return;const o=new Set;Ko(s,A=>{const l=Y(A);if(o.has(l))return;o.add(l);const[c,u,h]=Fn(A),d=is(A,{style:{x:c+n,y:u+i,z:h+a}});this.pushChange({value:d,original:A,type:this.isCombo(l)?Rt.ComboUpdated:Rt.NodeUpdated}),this.model.mergeNodeData(l,d)},A=>this.getChildrenData(Y(A)),"BT")}translateComboTo(e,t){var n;if(t.some(isNaN))return;const[i=0,a=0,s=0]=t,o=(n=this.getComboData([e]))===null||n===void 0?void 0:n[0];if(!o)return;const[A,l,c]=Fn(o),u=i-A,h=a-l,d=s-c;Ko(o,f=>{const g=Y(f),[p,v,y]=Fn(f),m=is(f,{style:{x:p+u,y:v+h,z:y+d}});this.pushChange({value:m,original:f,type:this.isCombo(g)?Rt.ComboUpdated:Rt.NodeUpdated}),this.model.mergeNodeData(g,m)},f=>this.getChildrenData(Y(f)),"BT")}removeData(e){const{nodes:t,edges:n,combos:i}=e;this.batch(()=>{this.removeEdgeData(n),this.removeNodeData(t),this.removeComboData(i),this.latestRemovedComboIds=new Set(i)})}removeNodeData(e=[]){e.length&&this.batch(()=>{e.forEach(t=>{this.removeEdgeData(this.getRelatedEdgesData(t).map(Y)),this.pushChange({value:this.getNodeData([t])[0],type:Rt.NodeRemoved}),this.removeNodeLikeHierarchy(t)}),this.model.removeNodes(e)})}removeEdgeData(e=[]){e.length&&(e.forEach(t=>this.pushChange({value:this.getEdgeData([t])[0],type:Rt.EdgeRemoved})),this.model.removeEdges(e))}removeComboData(e=[]){e.length&&this.batch(()=>{e.forEach(t=>{this.pushChange({value:this.getComboData([t])[0],type:Rt.ComboRemoved}),this.removeNodeLikeHierarchy(t),this.comboIds.delete(t)}),this.model.removeNodes(e)})}removeNodeLikeHierarchy(e){if(this.model.hasTreeStructure(Ft)){const t=ih(this.getNodeLikeDatum(e));this.setParent(e,void 0,Ft,!1),this.model.getChildren(e,Ft).forEach(n=>{const i=Pn(n),a=Y(i);this.setParent(Y(i),t,Ft,!1);const s=is(i,{id:Y(i),combo:t});this.pushChange({value:s,original:i,type:this.isCombo(a)?Rt.ComboUpdated:Rt.NodeUpdated}),this.model.mergeNodeData(Y(i),s)}),Ne(t)||this.refreshComboData(t)}}getElementType(e){if(this.model.hasNode(e))return this.isCombo(e)?"combo":"node";if(this.model.hasEdge(e))return"edge";throw new Error(da(`Unknown element type of id: ${e}`))}destroy(){const{model:e}=this,t=e.getAllNodes(),n=e.getAllEdges();e.removeEdges(n.map(i=>i.id)),e.removeNodes(t.map(i=>i.id)),this.context={}}}var gA=function(r,e,t,n){function i(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(c){try{l(n.next(c))}catch(u){s(u)}}function A(c){try{l(n.throw(c))}catch(u){s(u)}}function l(c){c.done?a(c.value):i(c.value).then(o,A)}l((n=n.apply(r,e||[])).next())})};class Ase{constructor(e){this.elementMap={},this.shapeTypeMap={},this.paletteStyle={},this.defaultStyle={},this.stateStyle={},this.visibilityCache=new WeakMap,this.context=e}init(){this.initContainer()}initContainer(){if(!this.container||this.container.destroyed){const{canvas:e}=this.context;this.container=e.appendChild(new Cn({className:"elements"}))}}emit(e,t){t.silence||On(this.context.graph,e)}forEachElementData(e){Vs.forEach(t=>{const n=this.context.model.getElementsDataByType(t);e(t,n)})}getElementType(e,t){var n;const{options:i,graph:a}=this.context,s=QF(t)&&((n=i[e])===null||n===void 0?void 0:n.type)||t.type;return s?typeof s=="string"?s:s.call(a,t):e==="edge"?"line":"circle"}getTheme(e){return vS(this.context.options)[e]||{}}getThemeStyle(e){return this.getTheme(e).style||{}}getThemeStateStyle(e,t){const{state:n={}}=this.getTheme(e);return Object.assign({},...t.map(i=>n[i]||{}))}computePaletteStyle(){const{options:e}=this.context;this.paletteStyle={},this.forEachElementData((t,n)=>{var i,a;const s=Object.assign({},qS((i=this.getTheme(t))===null||i===void 0?void 0:i.palette),qS((a=e[t])===null||a===void 0?void 0:a.palette));s?.field&&Object.assign(this.paletteStyle,Cj(n,s))})}getPaletteStyle(e,t){const n=this.paletteStyle[t];return n?e==="edge"?{stroke:n}:{fill:n}:{}}computeElementDefaultStyle(e,t){var n;const{options:i}=this.context,a=((n=i[e])===null||n===void 0?void 0:n.style)||{};"transform"in a&&Array.isArray(a.transform)&&(a.transform=[...a.transform]),this.defaultStyle[Y(t.datum)]=WS(a,t)}computeElementsDefaultStyle(e){const{graph:t}=this.context;this.forEachElementData((n,i)=>{const a=i.length;for(let s=0;s<a;s++){const o=i[s];(e===void 0||e.includes(Y(o)))&&this.computeElementDefaultStyle(n,{datum:o,graph:t})}})}getDefaultStyle(e){return this.defaultStyle[e]||{}}getElementState(e){try{const{model:t}=this.context;return t.getElementState(e)}catch{return[]}}getElementStateStyle(e,t,n){var i,a;const{options:s}=this.context,o=((a=(i=s[e])===null||i===void 0?void 0:i.state)===null||a===void 0?void 0:a[t])||{};return WS(o,n)}computeElementStatesStyle(e,t,n){this.stateStyle[Y(n.datum)]=Object.assign({},...t.map(i=>this.getElementStateStyle(e,i,n)))}computeElementsStatesStyle(e){const{graph:t}=this.context;this.forEachElementData((n,i)=>{const a=i.length;for(let s=0;s<a;s++){const o=i[s];if(e===void 0||e.includes(Y(o))){const A=this.getElementState(Y(o));this.computeElementStatesStyle(n,A,{datum:o,graph:t})}}})}getStateStyle(e){return this.stateStyle[e]||{}}computeStyle(e,t){e&&["translate","zIndex"].includes(e)||(this.computePaletteStyle(),this.computeElementsDefaultStyle(t),this.computeElementsStatesStyle(t))}getElement(e){return this.elementMap[e]}getNodes(){return this.context.model.getNodeData().map(({id:e})=>this.elementMap[e])}getEdges(){return this.context.model.getEdgeData().map(e=>this.elementMap[Y(e)])}getCombos(){return this.context.model.getComboData().map(({id:e})=>this.elementMap[e])}getElementComputedStyle(e,t){const n=Y(t),i=this.getThemeStyle(e),a=this.getPaletteStyle(e,n),s=t.style||{},o=this.getDefaultStyle(n),A=this.getThemeStateStyle(e,this.getElementState(n)),l=this.getStateStyle(n),c=QF(t)?Object.assign({},i,a,s,o,A,l):Object.assign({},s);if(e==="combo"){const u=this.context.model.getChildrenData(n),d=!!c.collapsed?[]:u.map(Y).filter(f=>this.getElement(f));Object.assign(c,{childrenNode:d,childrenData:u})}return c}getDrawData(e){this.init();const t=this.computeChangesAndDrawData(e);if(!t)return null;const{type:n="draw",stage:i=n}=e;return this.markDestroyElement(t.drawData),this.computeStyle(i),{type:n,stage:i,data:t}}draw(e={animation:!0}){const t=this.getDrawData(e);if(!t)return;const{data:{drawData:{add:n,update:i,remove:a}}}=t;return this.destroyElements(a,e),this.createElements(n,e),this.updateElements(i,e),this.setAnimationTask(e,t)}preLayoutDraw(){return gA(this,arguments,void 0,function*(e={animation:!0}){var t,n;const i=this.getDrawData(e);if(!i)return;const{data:{drawData:a}}=i;yield(n=(t=this.context.layout)===null||t===void 0?void 0:t.preLayout)===null||n===void 0?void 0:n.call(t,a);const{add:s,update:o,remove:A}=a;return this.destroyElements(A,e),this.createElements(s,e),this.updateElements(o,e),this.setAnimationTask(e,i)})}setAnimationTask(e,t){const{animation:n,silence:i}=e,{data:{dataChanges:a,drawData:s},stage:o,type:A}=t;return this.context.animation.animate(n,i?{}:{before:()=>this.emit(new xn(fe.BEFORE_DRAW,{dataChanges:a,animation:n,stage:o,render:A==="render"}),e),beforeAnimate:l=>this.emit(new ci(fe.BEFORE_ANIMATE,Sr.DRAW,l,s),e),afterAnimate:l=>this.emit(new ci(fe.AFTER_ANIMATE,Sr.DRAW,l,s),e),after:()=>this.emit(new xn(fe.AFTER_DRAW,{dataChanges:a,animation:n,stage:o,render:A==="render",firstRender:this.context.graph.rendered===!1}),e)})}computeChangesAndDrawData(e){const{model:t}=this.context,n=t.getChanges(),i=Db(n);if(i.length===0)return null;const{NodeAdded:a=[],NodeUpdated:s=[],NodeRemoved:o=[],EdgeAdded:A=[],EdgeUpdated:l=[],EdgeRemoved:c=[],ComboAdded:u=[],ComboUpdated:h=[],ComboRemoved:d=[]}=pc(i,C=>C.type),f=(C,S)=>{const F=[];return C.forEach(T=>{const O=Y(T.value);this.getElement(O)?F.push(T):S.push(T)}),F},g=f(s,a),p=f(l,A),v=f(h,u),y=C=>new Map(C.map(S=>{const F=S.value;return[Y(F),F]})),m={add:{nodes:y(a),edges:y(A),combos:y(u)},update:{nodes:y(g),edges:y(p),combos:y(v)},remove:{nodes:y(o),edges:y(c),combos:y(d)}},b=this.transformData(m,e);return t.clearChanges(),{dataChanges:n,drawData:b}}transformData(e,t){const n=this.context.transform.getTransformInstance();return Object.values(n).reduce((i,a)=>a.beforeDraw(i,t),e)}createElement(e,t,n){var i;const a=Y(t);if(this.getElement(a))return;const o=this.getElementType(e,t),A=this.getElementComputedStyle(e,t),l=ha(e,o);if(!l)return $i.warn(`The element ${o} of ${e} is not registered.`);this.emit(new fA(fe.BEFORE_ELEMENT_CREATE,e,t),n);const c=this.container.appendChild(new l({id:a,context:this.context,style:A}));this.shapeTypeMap[a]=o,this.elementMap[a]=c;const{stage:u="enter"}=n;(i=this.context.animation)===null||i===void 0||i.add({element:c,elementType:e,stage:u,originalStyle:Object.assign({},c.attributes),updatedStyle:A},{after:()=>{var h;this.emit(new fA(fe.AFTER_ELEMENT_CREATE,e,t),n),(h=c.onCreate)===null||h===void 0||h.call(c)}})}createElements(e,t){const{nodes:n,edges:i,combos:a}=e;[["node",n],["combo",a],["edge",i]].forEach(([o,A])=>{A.forEach(l=>this.createElement(o,l,t))})}getUpdateStageStyle(e,t,n){const{stage:i="update"}=n;if(i==="translate")if(e==="node"||e==="combo"){const{style:{x:a=0,y:s=0,z:o=0}={}}=t;return{x:a,y:s,z:o}}else return{};return this.getElementComputedStyle(e,t)}updateElement(e,t,n){var i;const a=Y(t),{stage:s="update"}=n,o=this.getElement(a);if(!o)return()=>null;this.emit(new fA(fe.BEFORE_ELEMENT_UPDATE,e,t),n);const A=this.getElementType(e,t),l=this.getUpdateStageStyle(e,t,n);this.shapeTypeMap[a]!==A&&(o.destroy(),delete this.shapeTypeMap[a],delete this.elementMap[a],this.createElement(e,t,{animation:!1,silence:!0}));const c=s!=="visibility"?s:l.visibility==="hidden"?"hide":"show";c==="hide"&&delete l.visibility,(i=this.context.animation)===null||i===void 0||i.add({element:o,elementType:e,stage:c,originalStyle:Object.assign({},o.attributes),updatedStyle:l},{before:()=>{const u=this.elementMap[a];s!=="collapse"&&xv(u,l),s==="visibility"&&(tse(u,"opacity")||ese(u,"opacity"),this.visibilityCache.set(u,c==="show"?"visible":"hidden"),c==="show"&&Ks(u,"visible"))},after:()=>{var u;const h=this.elementMap[a];s==="collapse"&&xv(h,l),c==="hide"&&Ks(h,this.visibilityCache.get(h)),this.emit(new fA(fe.AFTER_ELEMENT_UPDATE,e,t),n),(u=h.onUpdate)===null||u===void 0||u.call(h)}})}updateElements(e,t){const{nodes:n,edges:i,combos:a}=e;[["node",n],["combo",a],["edge",i]].forEach(([o,A])=>{A.forEach(l=>this.updateElement(o,l,t))})}markDestroyElement(e){Object.values(e.remove).forEach(t=>{t.forEach(n=>{const i=Y(n),a=this.getElement(i);a&&hW(a)})})}destroyElement(e,t,n){var i;const{stage:a="exit"}=n,s=Y(t),o=this.elementMap[s];if(!o)return()=>null;this.emit(new fA(fe.BEFORE_ELEMENT_DESTROY,e,t),n),(i=this.context.animation)===null||i===void 0||i.add({element:o,elementType:e,stage:a,originalStyle:Object.assign({},o.attributes),updatedStyle:{}},{after:()=>{var A;this.clearElement(s),o.destroy(),(A=o.onDestroy)===null||A===void 0||A.call(o),this.emit(new fA(fe.AFTER_ELEMENT_DESTROY,e,t),n)}})}destroyElements(e,t){const{nodes:n,edges:i,combos:a}=e;[["combo",a],["edge",i],["node",n]].forEach(([o,A])=>{A.forEach(l=>this.destroyElement(o,l,t))})}clearElement(e){delete this.paletteStyle[e],delete this.defaultStyle[e],delete this.stateStyle[e],delete this.elementMap[e],delete this.shapeTypeMap[e]}alignLayoutResultToElement(e,t){var n,i;const a=(n=e.nodes)===null||n===void 0?void 0:n.find(s=>Y(s)===t);if(a){const s=Fn(this.context.model.getNodeLikeDatum(t)),o=Fn(a),A=Bt(s,o);(i=e.nodes)===null||i===void 0||i.forEach(l=>{var c,u,h;!((c=l.style)===null||c===void 0)&&c.x&&(l.style.x+=A[0]),!((u=l.style)===null||u===void 0)&&u.y&&(l.style.y+=A[1]),!((h=l.style)===null||h===void 0)&&h.z&&(l.style.z+=A[2]||0)})}}syncLayoutResult(e,t){return gA(this,void 0,void 0,function*(){const{layout:n,model:i}=this.context;if(!n)return;const a=this.context.options.layout,s=A=>Array.isArray(A)?A.map(l=>Object.assign(Object.assign({},l),{preLayout:!0})):Object.assign(Object.assign({},A),{preLayout:!0}),o=yield n.simulate(a?s(a):void 0);t&&this.alignLayoutResultToElement(o,e),i.updateData(o)})}collapseNode(e,t){return gA(this,void 0,void 0,function*(){var n;const{animation:i,align:a}=t;yield this.syncLayoutResult(e,a);const s=this.computeChangesAndDrawData({stage:"collapse",animation:i});if(!s)return;const{drawData:o}=s,{add:A,remove:l,update:c}=o;this.markDestroyElement(o);const u={animation:i,stage:"collapse",data:o};this.destroyElements(l,u),this.createElements(A,u),this.updateElements(c,u),yield(n=this.context.animation.animate(i,{beforeAnimate:h=>this.emit(new ci(fe.BEFORE_ANIMATE,Sr.COLLAPSE,h,o),u),afterAnimate:h=>this.emit(new ci(fe.AFTER_ANIMATE,Sr.COLLAPSE,h,o),u)},{collapse:{target:e,descendants:Array.from(l.nodes).map(([,h])=>Y(h)),position:Fn(c.nodes.get(e))}}))===null||n===void 0?void 0:n.finished})}expandNode(e,t){return gA(this,void 0,void 0,function*(){var n;const{model:i}=this.context,{animation:a,align:s}=t,o=Fn(i.getNodeData([e])[0]);yield this.syncLayoutResult(e,s);const A=this.computeChangesAndDrawData({stage:"expand",animation:a});if(this.createElements(A.drawData.add,{animation:!1,stage:"expand",target:e}),this.context.animation.clear(),this.computeStyle("expand"),!A)return;const{drawData:l}=A,{update:c,add:u}=l,h={animation:a,stage:"expand",data:l};u.edges.forEach(d=>c.edges.set(Y(d),d)),u.nodes.forEach(d=>c.nodes.set(Y(d),d)),this.updateElements(c,h),yield(n=this.context.animation.animate(a,{beforeAnimate:d=>this.emit(new ci(fe.BEFORE_ANIMATE,Sr.EXPAND,d,l),h),afterAnimate:d=>this.emit(new ci(fe.AFTER_ANIMATE,Sr.EXPAND,d,l),h)},{expand:{target:e,descendants:Array.from(u.nodes).map(([,d])=>Y(d)),position:o}}))===null||n===void 0?void 0:n.finished})}collapseCombo(e,t){return gA(this,void 0,void 0,function*(){var n;const{model:i,element:a}=this.context;if(i.getAncestorsData(e,Ft).some(g=>Fr(g)))return;const s=a.getElement(e),o=s.getComboPosition(Object.assign(Object.assign({},s.attributes),{collapsed:!0})),A=this.computeChangesAndDrawData({stage:"collapse",animation:t});if(!A)return;const{dataChanges:l,drawData:c}=A;this.markDestroyElement(c);const{update:u,remove:h}=c,d={animation:t,stage:"collapse",data:c};this.destroyElements(h,d),this.updateElements(u,d);const f=g=>Array.from(g).map(([,p])=>Y(p));yield(n=this.context.animation.animate(t,{before:()=>this.emit(new xn(fe.BEFORE_DRAW,{dataChanges:l,animation:t}),d),beforeAnimate:g=>this.emit(new ci(fe.BEFORE_ANIMATE,Sr.COLLAPSE,g,c),d),afterAnimate:g=>this.emit(new ci(fe.AFTER_ANIMATE,Sr.COLLAPSE,g,c),d),after:()=>this.emit(new xn(fe.AFTER_DRAW,{dataChanges:l,animation:t}),d)},{collapse:{target:e,descendants:[...f(h.nodes),...f(h.combos)],position:o}}))===null||n===void 0?void 0:n.finished})}expandCombo(e,t){return gA(this,void 0,void 0,function*(){var n;const{model:i}=this.context,a=Fn(i.getComboData([e])[0]);this.computeStyle("expand");const s=this.computeChangesAndDrawData({stage:"expand",animation:t});if(!s)return;const{dataChanges:o,drawData:A}=s,{add:l,update:c}=A,u={animation:t,stage:"expand",data:A,target:e};this.createElements(l,u),this.updateElements(c,u);const h=d=>Array.from(d).map(([,f])=>Y(f));yield(n=this.context.animation.animate(t,{before:()=>this.emit(new xn(fe.BEFORE_DRAW,{dataChanges:o,animation:t}),u),beforeAnimate:d=>this.emit(new ci(fe.BEFORE_ANIMATE,Sr.EXPAND,d,A),u),afterAnimate:d=>this.emit(new ci(fe.AFTER_ANIMATE,Sr.EXPAND,d,A),u),after:()=>this.emit(new xn(fe.AFTER_DRAW,{dataChanges:o,animation:t}),u)},{expand:{target:e,descendants:[...h(l.nodes),...h(l.combos)],position:a}}))===null||n===void 0?void 0:n.finished})}clear(){this.container.destroy(),this.initContainer(),this.elementMap={},this.shapeTypeMap={},this.defaultStyle={},this.stateStyle={},this.paletteStyle={}}destroy(){this.clear(),this.container.destroy(),this.context={}}}var pA=function(r,e,t,n){function i(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(c){try{l(n.next(c))}catch(u){s(u)}}function A(c){try{l(n.throw(c))}catch(u){s(u)}}function l(c){c.done?a(c.value):i(c.value).then(o,A)}l((n=n.apply(r,e||[])).next())})},lse=function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(t[n[i]]=r[n[i]]);return t};class cse{get presetOptions(){return{animation:!!yS(this.context.options,!0)}}get options(){const{options:e}=this.context;return e.layout}constructor(e){this.instances=[],this.context=e}getLayoutInstance(){return this.instances}preLayout(e){return pA(this,void 0,void 0,function*(){var t,n,i,a;const{graph:s,model:o}=this.context,{add:A}=e;On(s,new xn(fe.BEFORE_LAYOUT,{type:"pre"}));const l=yield(t=this.context.layout)===null||t===void 0?void 0:t.simulate();(n=l?.nodes)===null||n===void 0||n.forEach(c=>{const u=Y(c),h=A.nodes.get(u);o.syncNodeLikeDatum(c),h&&Object.assign(h.style,c.style)}),(i=l?.edges)===null||i===void 0||i.forEach(c=>{const u=Y(c),h=A.edges.get(u);o.syncEdgeDatum(c),h&&Object.assign(h.style,c.style)}),(a=l?.combos)===null||a===void 0||a.forEach(c=>{const u=Y(c),h=A.combos.get(u);o.syncNodeLikeDatum(c),h&&Object.assign(h.style,c.style)}),On(s,new xn(fe.AFTER_LAYOUT,{type:"pre"})),this.transformDataAfterLayout("pre",e)})}postLayout(){return pA(this,arguments,void 0,function*(e=this.options){if(!e)return;const t=Array.isArray(e)?e:[e],{graph:n}=this.context;On(n,new xn(fe.BEFORE_LAYOUT,{type:"post"}));for(let i=0;i<t.length;i++){const a=t[i],s=this.getLayoutData(a),o=Object.assign(Object.assign({},this.presetOptions),a);On(n,new xn(fe.BEFORE_STAGE_LAYOUT,{options:o,index:i}));const A=yield this.stepLayout(s,o,i);On(n,new xn(fe.AFTER_STAGE_LAYOUT,{options:o,index:i})),a.animation||this.updateElementPosition(A,!1)}On(n,new xn(fe.AFTER_LAYOUT,{type:"post"})),this.transformDataAfterLayout("post")})}transformDataAfterLayout(e,t){const n=this.context.transform.getTransformInstance();Object.values(n).forEach(i=>i.afterLayout(e,t))}simulate(){return pA(this,arguments,void 0,function*(e=this.options){if(!e)return{};const t=Array.isArray(e)?e:[e];let n={};for(let i=0;i<t.length;i++){const a=t[i],s=this.getLayoutData(a);n=yield this.stepLayout(s,Object.assign(Object.assign(Object.assign({},this.presetOptions),a),{animation:!1}),i)}return n})}stepLayout(e,t,n){return pA(this,void 0,void 0,function*(){return mW(t)?yield this.treeLayout(e,t,n):yield this.graphLayout(e,t,n)})}graphLayout(e,t,n){return pA(this,void 0,void 0,function*(){const{animation:i,enableWorker:a,iterations:s=300}=t,o=this.initGraphLayout(t);if(!o)return{};if(this.instances[n]=o,this.instance=o,a){const l=o;return this.supervisor=new wee(l.graphData2LayoutModel(e),l.instance,{iterations:s}),Hh(yield this.supervisor.execute())}if(jv(o))return i?yield o.execute(e,{onTick:l=>{this.updateElementPosition(l,!1)}}):(o.execute(e),o.stop(),o.tick(s));const A=yield o.execute(e);if(i){const l=this.updateElementPosition(A,i);yield l?.finished}return A})}treeLayout(e,t,n){return pA(this,void 0,void 0,function*(){const{type:i,animation:a}=t,s=ha("layout",i);if(!s)return{};const{nodes:o=[],edges:A=[]}=e,l=new Tn({nodes:o.map(f=>({id:Y(f),data:f.data||{}})),edges:A.map(f=>({id:Y(f),source:f.source,target:f.target,data:f.data||{}}))});sse(l);const c={nodes:[],edges:[]},u={nodes:[],edges:[]};l.getRoots(Rr).forEach(f=>{Ko(f,m=>{m.children=l.getSuccessors(m.id)},m=>l.getSuccessors(m.id),"TB");const g=s(f,t),{x:p,y:v,z:y=0}=g;Ko(g,m=>{const{id:b,x:C,y:S,z:F=0}=m;c.nodes.push({id:b,style:{x:p,y:v,z:y}}),u.nodes.push({id:b,style:{x:C,y:S,z:F}})},m=>m.children,"TB")});const d=this.inferTreeLayoutOffset(u);if(zU(u,d),a){zU(c,d),this.updateElementPosition(c,!1);const f=this.updateElementPosition(u,a);yield f?.finished}return u})}inferTreeLayoutOffset(e){var t;let[n,i]=[1/0,-1/0],[a,s]=[1/0,-1/0];(t=e.nodes)===null||t===void 0||t.forEach(g=>{const{x:p=0,y:v=0}=g.style||{};n=Math.min(n,p),i=Math.max(i,p),a=Math.min(a,v),s=Math.max(s,v)});const{canvas:o}=this.context,A=o.getSize(),[l,c]=o.getCanvasByViewport([0,0]),[u,h]=o.getCanvasByViewport(A);if(n>=l&&i<=u&&a>=c&&s<=h)return[0,0];const d=(l+u)/2,f=(c+h)/2;return[d-(n+i)/2,f-(a+s)/2]}stopLayout(){this.instance&&jv(this.instance)&&(this.instance.stop(),this.instance=void 0),this.supervisor&&(this.supervisor.stop(),this.supervisor=void 0),this.animationResult&&(this.animationResult.finish(),this.animationResult=void 0)}getLayoutData(e){const{nodeFilter:t=()=>!0,comboFilter:n=()=>!0,preLayout:i=!1,isLayoutInvisibleNodes:a=!1}=e,{nodes:s,edges:o,combos:A}=this.context.model.getData(),{element:l,model:c}=this.context,u=v=>l.getElement(v),h=i?v=>{var y;return!a&&(((y=v.style)===null||y===void 0?void 0:y.visibility)==="hidden"||c.getAncestorsData(v.id,Rr).some(Fr)||c.getAncestorsData(v.id,Ft).some(Fr))?!1:t(v)}:v=>{const y=Y(v),m=u(y);return!m||Cl(m)?!1:t(v)},d=s.filter(h),f=A.filter(n),g=new Map(d.map(v=>[Y(v),v]));f.forEach(v=>g.set(Y(v),v));const p=o.filter(({source:v,target:y})=>g.has(v)&&g.has(y));return{nodes:d,edges:p,combos:f}}initGraphLayout(e){var t;const{element:n,viewport:i}=this.context,{type:a,enableWorker:s,animation:o,iterations:A}=e,l=lse(e,["type","enableWorker","animation","iterations"]),[c,u]=i.getCanvasSize(),h=[c/2,u/2],d=(t=e?.nodeSize)!==null&&t!==void 0?t:(y=>{const m=n?.getElement(y.id);return m?m.attributes.size:n?.getElementComputedStyle("node",y).size}),f=ha("layout",a);if(!f)return $i.warn(`The layout of ${a} is not registered.`);const g=Object.getPrototypeOf(f.prototype)===Rh.prototype?f:bW(f,this.context),p=new g(this.context),v={nodeSize:d,width:c,height:u,center:h};switch(p.id){case"d3-force":case"d3-force-3d":Object.assign(v,{center:{x:c/2,y:u/2,z:0}});break}return Dn(p.options,v,l),p}updateElementPosition(e,t){const{model:n,element:i}=this.context;return i?(n.updateData(e),i.draw({animation:t,silence:!0})):null}destroy(){var e;this.stopLayout(),this.context={},(e=this.supervisor)===null||e===void 0||e.kill(),this.supervisor=void 0,this.instance=void 0,this.instances=[],this.animationResult=void 0}}const zU=(r,e)=>{var t;const[n,i]=e;(t=r.nodes)===null||t===void 0||t.forEach(a=>{if(a.style){const{x:s=0,y:o=0}=a.style;a.style.x=s+n,a.style.y=o+i}else a.style={x:n,y:i}})};function use(r){return[hse].reduce((t,n)=>n(t),r)}function hse(r){return!r.layout||Array.isArray(r.layout)||"preLayout"in r.layout||["antv-dagre","combo-combined","compact-box","circular","concentric","dagre","fishbone","grid","indented","mds","radial","random","snake","dendrogram","mindmap"].includes(r.layout.type)&&(r.layout.preLayout=!0),r}class dse extends Zp{constructor(e){super(e),this.category="plugin",this.setPlugins(this.context.options.plugins||[])}setPlugins(e){this.setExtensions(e)}getPluginInstance(e){const t=this.extensionMap[e];if(t)return t;$i.warn(`Cannot find the plugin ${e}, will try to find it by type.`);const n=this.extensions.find(i=>i.type===e);if(n)return this.extensionMap[n.key]}}const Bf=["update-related-edges","collapse-expand-node","collapse-expand-combo","get-edge-actual-ends","arrange-draw-order"];class fse extends Zp{constructor(e){super(e),this.category="transform",this.setTransforms(this.context.options.transforms||[])}getTransforms(){}setTransforms(e){this.setExtensions([...Bf.slice(0,Bf.length-1),...e,Bf[Bf.length-1]])}getTransformInstance(e){return e?this.extensionMap[e]:this.extensionMap}}var nc=function(r,e,t,n){function i(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(c){try{l(n.next(c))}catch(u){s(u)}}function A(c){try{l(n.throw(c))}catch(u){s(u)}}function l(c){c.done?a(c.value):i(c.value).then(o,A)}l((n=n.apply(r,e||[])).next())})};class gse{get padding(){return si(this.context.options.padding)}get paddingOffset(){const[e,t,n,i]=this.padding,[a,s,o]=[(i-t)/2,(e-n)/2,0];return[a,s,o]}constructor(e){this.landmarkCounter=0,this.context=e;const[t,n]=this.paddingOffset,{zoom:i,rotation:a,x:s=t,y:o=n}=e.options;this.transform({mode:"absolute",scale:i,translate:[s,o],rotate:a},!1)}get camera(){const{canvas:e}=this.context;return new Proxy(e.getCamera(),{get:(t,n)=>{const a=Object.entries(e.getLayers()).filter(([o])=>!["main"].includes(o)).map(([,o])=>o.getCamera()),s=t[n];if(typeof s=="function")return(...o)=>{const A=s.apply(t,o);return a.forEach(l=>{l[n].apply(l,o)}),A}}})}createLandmark(e){return this.camera.createLandmark(`landmark-${this.landmarkCounter++}`,e)}getAnimation(e){const t=yS(this.context.options,e);return t?ws(Object.assign({},t),["easing","duration"]):!1}getCanvasSize(){const{canvas:e}=this.context,{width:t=0,height:n=0}=e.getConfig();return[t,n]}getCanvasCenter(){const{canvas:e}=this.context,{width:t=0,height:n=0}=e.getConfig();return[t/2,n/2,0]}getViewportCenter(){const[e,t]=this.camera.getPosition();return[e,t,0]}getGraphCenter(){return this.context.graph.getViewportByCanvas(this.getCanvasCenter())}getZoom(){return this.camera.getZoom()}getRotation(){return this.camera.getRoll()}getTranslateOptions(e){const{camera:t}=this,{mode:n,translate:i=[]}=e,a=this.getZoom(),s=t.getPosition(),o=t.getFocalPoint(),[A,l]=this.getCanvasCenter(),[c=0,u=0,h=0]=i,d=Bi([-c,-u,-h],a);return n==="relative"?{position:je(s,d),focalPoint:je(o,d)}:{position:je([A,l,s[2]],d),focalPoint:je([A,l,o[2]],d)}}getRotateOptions(e){const{mode:t,rotate:n=0}=e;return{roll:t==="relative"?this.camera.getRoll()+n:n}}getZoomOptions(e){const{zoomRange:t}=this.context.options,n=this.camera.getZoom(),{mode:i,scale:a=1}=e;return Yt(i==="relative"?n*a:a,...t)}transform(e,t){return nc(this,void 0,void 0,function*(){const{graph:n}=this.context,{translate:i,rotate:a,scale:s,origin:o}=e;this.cancelAnimation();const A=this.getAnimation(t);if(On(n,new bf(fe.BEFORE_TRANSFORM,e)),!a&&s&&!i&&o&&!A){this.camera.setZoomByViewportPoint(this.getZoomOptions(e),o),On(n,new bf(fe.AFTER_TRANSFORM,e));return}const l={};if(i&&Object.assign(l,this.getTranslateOptions(e)),Ee(a)&&Object.assign(l,this.getRotateOptions(e)),Ee(s)&&Object.assign(l,{zoom:this.getZoomOptions(e)}),A)return On(n,new ci(fe.BEFORE_ANIMATE,Sr.TRANSFORM,null,e)),new Promise(c=>{this.transformResolver=c,this.camera.gotoLandmark(this.createLandmark(l),Object.assign(Object.assign({},A),{onfinish:()=>{On(n,new ci(fe.AFTER_ANIMATE,Sr.TRANSFORM,null,e)),On(n,new bf(fe.AFTER_TRANSFORM,e)),this.transformResolver=void 0,c()}}))});this.camera.gotoLandmark(this.createLandmark(l),{duration:0}),On(n,new bf(fe.AFTER_TRANSFORM,e))})}fitView(e,t){return nc(this,void 0,void 0,function*(){const[n,i,a,s]=this.padding,{when:o="always",direction:A="both"}=e||{},[l,c]=this.context.canvas.getSize(),u=l-s-i,h=c-n-a,d=this.context.canvas.getBounds(),f=this.getBBoxInViewport(d),[g,p]=qa(f),v=A==="x"&&g>=u||A==="y"&&p>=h||A==="both"&&g>=u&&p>=h;if(o==="overflow"&&!v)return yield this.fitCenter({animation:t});const y=u/g,m=h/p,b=A==="x"?y:A==="y"?m:Math.min(y,m),C=this.getAnimation(t);Number.isFinite(b)&&(yield this.transform({mode:"relative",scale:b,translate:je(Bt(this.getCanvasCenter(),this.getBBoxInViewport(d).center),Bi(this.paddingOffset,b))},C))})}fitCenter(e){return nc(this,void 0,void 0,function*(){const t=this.context.canvas.getBounds();yield this.focus(t,e)})}focusElements(e){return nc(this,arguments,void 0,function*(t,n={}){const{element:i}=this.context;if(!i)return;const a=o=>n.shapes?o.getShape(n.shapes).getRenderBounds():o.getRenderBounds(),s=dl(t.map(o=>a(i.getElement(o))));yield this.focus(s,n)})}focus(e,t){return nc(this,void 0,void 0,function*(){const n=this.context.graph.getViewportByCanvas(e.center),i=t.position||this.getCanvasCenter(),a=Bt(i,n);yield this.transform({mode:"relative",translate:je(a,this.paddingOffset)},t.animation)})}getBBoxInViewport(e){const{min:t,max:n}=e,{graph:i}=this.context,[a,s]=i.getViewportByCanvas(t),[o,A]=i.getViewportByCanvas(n),l=new kt;return l.setMinMax([a,s,0],[o,A,0]),l}isInViewport(e,t=!1,n=0){const{graph:i}=this.context,a=this.getCanvasSize(),[s,o]=i.getCanvasByViewport([0,0]),[A,l]=i.getCanvasByViewport(a);let c=new kt;return c.setMinMax([s,o,0],[A,l,0]),n&&(c=Ya(c,n)),Go(e)?wi(e,c):t?NV(e,c):c.intersects(e)}cancelAnimation(){var e,t;!((e=this.camera.landmarks)===null||e===void 0)&&e.length&&this.camera.cancelLandmarkAnimation(),(t=this.transformResolver)===null||t===void 0||t.call(this)}}var Ot=function(r,e,t,n){function i(a){return a instanceof t?a:new t(function(s){s(a)})}return new(t||(t=Promise))(function(a,s){function o(c){try{l(n.next(c))}catch(u){s(u)}}function A(c){try{l(n.throw(c))}catch(u){s(u)}}function l(c){c.done?a(c.value):i(c.value).then(o,A)}l((n=n.apply(r,e||[])).next())})};class Ef extends Ph{constructor(e){var t;super(),this.options={},this.rendered=!1,this.destroyed=!1,this.context={model:new ose},this.isCollapsingExpanding=!1,this.onResize=EA(()=>{this.resize()},300),this._setOptions(Object.assign({},Ef.defaultOptions,e),!0),this.context.graph=this,this.options.autoResize&&((t=globalThis.addEventListener)===null||t===void 0||t.call(globalThis,"resize",this.onResize))}getOptions(){return this.options}setOptions(e){this._setOptions(e,!1)}_setOptions(e,t){if(this.updateCanvas(e),Object.assign(this.options,use(e)),t){const{data:h}=e;h&&this.addData(h);return}const{behaviors:n,combo:i,data:a,edge:s,layout:o,node:A,plugins:l,theme:c,transforms:u}=e;n&&this.setBehaviors(n),a&&this.setData(a),A&&this.setNode(A),s&&this.setEdge(s),i&&this.setCombo(i),o&&this.setLayout(o),c&&this.setTheme(c),l&&this.setPlugins(l),u&&this.setTransforms(u)}getSize(){return this.context.canvas?this.context.canvas.getSize():[this.options.width||0,this.options.height||0]}setSize(e,t){e&&(this.options.width=e),t&&(this.options.height=t),this.resize(e,t)}setZoomRange(e){this.options.zoomRange=e}getZoomRange(){return this.options.zoomRange}setNode(e){this.options.node=e,this.context.model.refreshData()}setEdge(e){this.options.edge=e,this.context.model.refreshData()}setCombo(e){this.options.combo=e,this.context.model.refreshData()}getTheme(){return this.options.theme}setTheme(e){this.options.theme=Te(e)?e(this.getTheme()):e}setLayout(e){this.options.layout=Te(e)?e(this.getLayout()):e}getLayout(){return this.options.layout}setBehaviors(e){var t;this.options.behaviors=Te(e)?e(this.getBehaviors()):e,(t=this.context.behavior)===null||t===void 0||t.setBehaviors(this.options.behaviors)}updateBehavior(e){this.setBehaviors(t=>t.map(n=>typeof n=="object"&&n.key===e.key?Object.assign(Object.assign({},n),e):n))}getBehaviors(){return this.options.behaviors||[]}setPlugins(e){var t;this.options.plugins=Te(e)?e(this.getPlugins()):e,(t=this.context.plugin)===null||t===void 0||t.setPlugins(this.options.plugins)}updatePlugin(e){this.setPlugins(t=>t.map(n=>typeof n=="object"&&n.key===e.key?Object.assign(Object.assign({},n),e):n))}getPlugins(){return this.options.plugins||[]}getPluginInstance(e){return this.context.plugin.getPluginInstance(e)}setTransforms(e){var t;this.options.transforms=Te(e)?e(this.getTransforms()):e,(t=this.context.transform)===null||t===void 0||t.setTransforms(this.options.transforms)}updateTransform(e){this.setTransforms(t=>t.map(n=>typeof n=="object"&&n.key===e.key?Object.assign(Object.assign({},n),e):n)),this.context.model.refreshData()}getTransforms(){return this.options.transforms||[]}getData(){return this.context.model.getData()}hasNode(e){return this.context.model.hasNode(e)}hasEdge(e){return this.context.model.hasEdge(e)}hasCombo(e){return this.context.model.hasCombo(e)}getElementData(e){return Array.isArray(e)?e.map(t=>this.context.model.getElementDataById(t)):this.context.model.getElementDataById(e)}getNodeData(e){return e===void 0?this.context.model.getNodeData():Array.isArray(e)?this.context.model.getNodeData(e):this.context.model.getNodeLikeDatum(e)}getEdgeData(e){return e===void 0?this.context.model.getEdgeData():Array.isArray(e)?this.context.model.getEdgeData(e):this.context.model.getEdgeDatum(e)}getComboData(e){return e===void 0?this.context.model.getComboData():Array.isArray(e)?this.context.model.getComboData(e):this.context.model.getNodeLikeDatum(e)}setData(e){this.context.model.setData(Te(e)?e(this.getData()):e)}addData(e){this.context.model.addData(Te(e)?e(this.getData()):e)}addNodeData(e){this.context.model.addNodeData(Te(e)?e(this.getNodeData()):e)}addEdgeData(e){this.context.model.addEdgeData(Te(e)?e(this.getEdgeData()):e)}addComboData(e){this.context.model.addComboData(Te(e)?e(this.getComboData()):e)}addChildrenData(e,t){this.context.model.addChildrenData(e,t)}updateData(e){this.context.model.updateData(Te(e)?e(this.getData()):e)}updateNodeData(e){this.context.model.updateNodeData(Te(e)?e(this.getNodeData()):e)}updateEdgeData(e){this.context.model.updateEdgeData(Te(e)?e(this.getEdgeData()):e)}updateComboData(e){this.context.model.updateComboData(Te(e)?e(this.getComboData()):e)}removeData(e){this.context.model.removeData(Te(e)?e(this.getData()):e)}removeNodeData(e){this.context.model.removeNodeData(Te(e)?e(this.getNodeData()):e)}removeEdgeData(e){this.context.model.removeEdgeData(Te(e)?e(this.getEdgeData()):e)}removeComboData(e){this.context.model.removeComboData(Te(e)?e(this.getComboData()):e)}getElementType(e){return this.context.model.getElementType(e)}getRelatedEdgesData(e,t="both"){return this.context.model.getRelatedEdgesData(e,t)}getNeighborNodesData(e){return this.context.model.getNeighborNodesData(e)}getAncestorsData(e,t){return this.context.model.getAncestorsData(e,t)}getParentData(e,t){return this.context.model.getParentData(e,t)}getChildrenData(e){return this.context.model.getChildrenData(e)}getDescendantsData(e){return this.context.model.getDescendantsData(e)}getElementDataByState(e,t){return this.context.model.getElementDataByState(e,t)}initCanvas(){return Ot(this,void 0,void 0,function*(){var e;if(this.context.canvas)return yield this.context.canvas.ready;const{container:t="container",width:n,height:i,renderer:a,cursor:s,background:o,canvas:A,devicePixelRatio:l=(e=globalThis.devicePixelRatio)!==null&&e!==void 0?e:1}=this.options;if(t instanceof PU)this.context.canvas=t,s&&t.setCursor(s),a&&t.setRenderer(a),yield t.ready;else{const c=At(t)?document.getElementById(t):t,u=HU(c);this.emit(fe.BEFORE_CANVAS_INIT,{container:c,width:n,height:i});const h=Object.assign(Object.assign({},A),{container:c,width:n||u[0],height:i||u[1],background:o,renderer:a,cursor:s,devicePixelRatio:l}),d=new PU(h);this.context.canvas=d,yield d.ready,this.emit(fe.AFTER_CANVAS_INIT,{canvas:d})}})}updateCanvas(e){var t,n;const{renderer:i,cursor:a,height:s,width:o}=e,A=this.context.canvas;A&&(i&&(this.emit(fe.BEFORE_RENDERER_CHANGE,{renderer:this.options.renderer}),A.setRenderer(i),this.emit(fe.AFTER_RENDERER_CHANGE,{renderer:i})),a&&A.setCursor(a),(Ee(o)||Ee(s))&&this.setSize((t=o??this.options.width)!==null&&t!==void 0?t:0,(n=s??this.options.height)!==null&&n!==void 0?n:0))}initRuntime(){this.context.options=this.options,this.context.batch||(this.context.batch=new rse(this.context)),this.context.plugin||(this.context.plugin=new dse(this.context)),this.context.viewport||(this.context.viewport=new gse(this.context)),this.context.transform||(this.context.transform=new fse(this.context)),this.context.element||(this.context.element=new Ase(this.context)),this.context.animation||(this.context.animation=new nse(this.context)),this.context.layout||(this.context.layout=new cse(this.context)),this.context.behavior||(this.context.behavior=new ise(this.context))}prepare(){return Ot(this,void 0,void 0,function*(){if(yield Promise.resolve(),this.destroyed){console.error(da("The graph instance has been destroyed"));return}yield this.initCanvas(),this.initRuntime()})}render(){return Ot(this,void 0,void 0,function*(){if(yield this.prepare(),On(this,new xn(fe.BEFORE_RENDER)),this.options.layout)if(!this.rendered&&wW(this.options.layout)){const e=yield this.context.element.preLayoutDraw({type:"render"});yield Promise.all([e?.finished,this.autoFit()])}else{const e=this.context.element.draw({type:"render"});yield Promise.all([e?.finished,this.context.layout.postLayout()]),yield this.autoFit()}else{const e=this.context.element.draw({type:"render"});yield Promise.all([e?.finished,this.autoFit()])}this.rendered=!0,On(this,new xn(fe.AFTER_RENDER))})}draw(){return Ot(this,void 0,void 0,function*(){var e;yield this.prepare(),yield(e=this.context.element.draw())===null||e===void 0?void 0:e.finished})}layout(e){return Ot(this,void 0,void 0,function*(){yield this.context.layout.postLayout(e)})}stopLayout(){this.context.layout.stopLayout()}clear(){return Ot(this,void 0,void 0,function*(){const{model:e,element:t}=this.context;e.setData({}),e.clearChanges(),t?.clear()})}destroy(){var e;On(this,new xn(fe.BEFORE_DESTROY));const{layout:t,animation:n,element:i,model:a,canvas:s,behavior:o,plugin:A}=this.context;A?.destroy(),o?.destroy(),t?.destroy(),n?.destroy(),i?.destroy(),a.destroy(),s?.destroy(),this.options={},this.context={},this.off(),(e=globalThis.removeEventListener)===null||e===void 0||e.call(globalThis,"resize",this.onResize),this.destroyed=!0,On(this,new xn(fe.AFTER_DESTROY))}getCanvas(){return this.context.canvas}resize(e,t){var n;const i=HU((n=this.context.canvas)===null||n===void 0?void 0:n.getContainer()),a=[e||i[0],t||i[1]];if(!this.context.canvas)return;const s=this.context.canvas.getSize();Xt(a,s)||(On(this,new xn(fe.BEFORE_SIZE_CHANGE,{size:a})),this.context.canvas.resize(...a),On(this,new xn(fe.AFTER_SIZE_CHANGE,{size:a})))}fitView(e,t){return Ot(this,void 0,void 0,function*(){var n;yield(n=this.context.viewport)===null||n===void 0?void 0:n.fitView(e,t)})}fitCenter(e){return Ot(this,void 0,void 0,function*(){var t;yield(t=this.context.viewport)===null||t===void 0?void 0:t.fitCenter({animation:e})})}autoFit(){return Ot(this,void 0,void 0,function*(){const{autoFit:e}=this.context.options;if(e)if(At(e))e==="view"?yield this.fitView():e==="center"&&(yield this.fitCenter());else{const{type:t,animation:n}=e;t==="view"?yield this.fitView(e.options,n):t==="center"&&(yield this.fitCenter(n))}})}focusElement(e,t){return Ot(this,void 0,void 0,function*(){var n;yield(n=this.context.viewport)===null||n===void 0?void 0:n.focusElements(Array.isArray(e)?e:[e],{animation:t})})}zoomBy(e,t,n){return Ot(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",scale:e,origin:n},t)})}zoomTo(e,t,n){return Ot(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",scale:e,origin:n},t)})}getZoom(){return this.context.viewport.getZoom()}rotateBy(e,t,n){return Ot(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",rotate:e,origin:n},t)})}rotateTo(e,t,n){return Ot(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",rotate:e,origin:n},t)})}getRotation(){return this.context.viewport.getRotation()}translateBy(e,t){return Ot(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",translate:e},t)})}translateTo(e,t){return Ot(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",translate:e},t)})}getPosition(){return Bt([0,0],this.getCanvasByViewport([0,0]))}translateElementBy(e,t){return Ot(this,arguments,void 0,function*(n,i,a=!0){var s,o;const[A,l]=on(n)?[n,(s=i)!==null&&s!==void 0?s:!0]:[{[n]:i},a];Object.entries(A).forEach(([c,u])=>this.context.model.translateNodeLikeBy(c,u)),yield(o=this.context.element.draw({animation:l,stage:"translate"}))===null||o===void 0?void 0:o.finished})}translateElementTo(e,t){return Ot(this,arguments,void 0,function*(n,i,a=!0){var s,o;const[A,l]=on(n)?[n,(s=i)!==null&&s!==void 0?s:!0]:[{[n]:i},a];Object.entries(A).forEach(([c,u])=>this.context.model.translateNodeLikeTo(c,u)),yield(o=this.context.element.draw({animation:l,stage:"translate"}))===null||o===void 0?void 0:o.finished})}getElementPosition(e){return this.context.model.getElementPosition(e)}getElementRenderStyle(e){return Jf(this.context.element.getElement(e).attributes,["context"])}setElementVisibility(e,t){return Ot(this,arguments,void 0,function*(n,i,a=!0){var s,o;const[A,l]=on(n)?[n,(s=i)!==null&&s!==void 0?s:!0]:[{[n]:i},a],c={nodes:[],edges:[],combos:[]};Object.entries(A).forEach(([d,f])=>{const g=this.getElementType(d);c[`${g}s`].push({id:d,style:{visibility:f}})});const{model:u,element:h}=this.context;u.preventUpdateNodeLikeHierarchy(()=>{u.updateData(c)}),yield(o=h.draw({animation:l,stage:"visibility"}))===null||o===void 0?void 0:o.finished})}showElement(e,t){return Ot(this,void 0,void 0,function*(){const n=Array.isArray(e)?e:[e];yield this.setElementVisibility(Object.fromEntries(n.map(i=>[i,"visible"])),t)})}hideElement(e,t){return Ot(this,void 0,void 0,function*(){const n=Array.isArray(e)?e:[e];yield this.setElementVisibility(Object.fromEntries(n.map(i=>[i,"hidden"])),t)})}getElementVisibility(e){var t,n;const i=this.context.element.getElement(e);return(n=(t=i?.style)===null||t===void 0?void 0:t.visibility)!==null&&n!==void 0?n:"visible"}setElementZIndex(e,t){return Ot(this,void 0,void 0,function*(){var n;const i={nodes:[],edges:[],combos:[]},a=on(e)?e:{[e]:t};Object.entries(a).forEach(([A,l])=>{const c=this.getElementType(A);i[`${c}s`].push({id:A,style:{zIndex:l}})});const{model:s,element:o}=this.context;s.preventUpdateNodeLikeHierarchy(()=>s.updateData(i)),yield(n=o.draw({animation:!1,stage:"zIndex"}))===null||n===void 0?void 0:n.finished})}frontElement(e){return Ot(this,void 0,void 0,function*(){const t=Array.isArray(e)?e:[e],{model:n}=this.context,i={};t.map(a=>{const s=n.getFrontZIndex(a);if(n.getElementType(a)==="combo"){const A=n.getAncestorsData(a,Ft).at(-1)||this.getComboData(a),l=[A,...n.getDescendantsData(Y(A))],c=s-GU(A);l.forEach(h=>{i[Y(h)]=this.getElementZIndex(Y(h))+c});const{internal:u}=mv(l.map(Y),h=>n.getRelatedEdgesData(h));u.forEach(h=>{const d=Y(h);i[d]=this.getElementZIndex(d)+c})}else i[a]=s}),yield this.setElementZIndex(i)})}getElementZIndex(e){return GU(this.context.model.getElementDataById(e))}setElementState(e,t){return Ot(this,arguments,void 0,function*(n,i,a=!0){var s,o;const[A,l]=on(n)?[n,(s=i)!==null&&s!==void 0?s:!0]:[{[n]:i},a],c=h=>h?Array.isArray(h)?h:[h]:[],u={nodes:[],edges:[],combos:[]};Object.entries(A).forEach(([h,d])=>{const f=this.getElementType(h);u[`${f}s`].push({id:h,states:c(d)})}),this.updateData(u),yield(o=this.context.element.draw({animation:l,stage:"state"}))===null||o===void 0?void 0:o.finished})}getElementState(e){return this.context.model.getElementState(e)}getElementRenderBounds(e){return this.context.element.getElement(e).getRenderBounds()}collapseElement(e){return Ot(this,arguments,void 0,function*(t,n=!0){const{model:i,element:a}=this.context;if(Fr(i.getNodeLikeData([t])[0])||this.isCollapsingExpanding)return;typeof n=="boolean"&&(n={animation:n,align:!1});const s=i.getElementType(t);yield this.frontElement(t),this.isCollapsingExpanding=!0,i.updateData(s==="node"?{nodes:[{id:t,style:{collapsed:!0}}]}:{combos:[{id:t,style:{collapsed:!0}}]}),s==="node"?yield a.collapseNode(t,n):s==="combo"&&(yield a.collapseCombo(t,!!n.animation)),this.isCollapsingExpanding=!1})}expandElement(e){return Ot(this,arguments,void 0,function*(t,n=!0){const{model:i,element:a}=this.context;if(!Fr(i.getNodeLikeData([t])[0])||this.isCollapsingExpanding)return;typeof n=="boolean"&&(n={animation:n,align:!1});const s=i.getElementType(t);this.isCollapsingExpanding=!0,i.updateData(s==="node"?{nodes:[{id:t,style:{collapsed:!1}}]}:{combos:[{id:t,style:{collapsed:!1}}]}),s==="node"?yield a.expandNode(t,n):s==="combo"&&(yield a.expandCombo(t,!!n.animation)),this.isCollapsingExpanding=!1})}setElementCollapsibility(e,t){const n=this.getElementType(e);n==="node"?this.updateNodeData([{id:e,style:{collapsed:t}}]):n==="combo"&&this.updateComboData([{id:e,style:{collapsed:t}}])}toDataURL(){return Ot(this,arguments,void 0,function*(e={}){return this.context.canvas.toDataURL(e)})}getCanvasByViewport(e){return this.context.canvas.getCanvasByViewport(e)}getViewportByCanvas(e){return this.context.canvas.getViewportByCanvas(e)}getClientByCanvas(e){return this.context.canvas.getClientByCanvas(e)}getCanvasByClient(e){return this.context.canvas.getCanvasByClient(e)}getViewportCenter(){return this.context.viewport.getViewportCenter()}getCanvasCenter(){return this.context.viewport.getCanvasCenter()}on(e,t,n){return super.on(e,t,n)}once(e,t){return super.once(e,t)}off(e,t){return super.off(e,t)}}Ef.defaultOptions={autoResize:!1,theme:"light",rotation:0,zoom:1,zoomRange:[.01,10]};class pse extends fs{beforeDraw(e){const{add:t,update:n}=e,{model:i}=this.context;return[...t.edges.entries(),...n.edges.entries()].forEach(([,a])=>{VU(i,a)}),e}}const VU=(r,e)=>{const{source:t,target:n}=e,i=r.getElementDataById(t),a=r.getElementDataById(n),s=BF(i,u=>r.getParentData(u,Ft)),o=BF(a,u=>r.getParentData(u,Ft)),A=Y(s),l=Y(o),c={sourceNode:A,targetNode:l};return e.style?Object.assign(e.style,c):e.style=c,e},vse=(r,e,t)=>{const[n,i]=e,[a,s]=t;if(i===n)return a;const o=(r-n)/(i-n);return a+o*(s-a)},yse=(r,e,t)=>{const[n,i]=e,[a,s]=t,o=Math.log(r-n+1)/Math.log(i-n+1);return a+o*(s-a)},mse=(r,e,t,n=2)=>{const[i,a]=e,[s,o]=t,A=Math.pow((r-i)/(a-i),n);return s+A*(o-s)},wse=(r,e,t)=>{const[n,i]=e,[a,s]=t,o=Math.sqrt((r-n)/(i-n));return a+o*(s-a)};class xf extends fs{constructor(e,t){super(e,Dn({},xf.defaultOptions,t)),this.assignSizeByCentrality=(n,i,a,s,o,A)=>{const l=[i,a],c=[s[0],o[0]],u=[s[1],o[1]],h=[s[2],o[2]],d=(f,g)=>{if(typeof A=="function")return A(f,l,g);switch(A){case"linear":return vse(f,l,g);case"log":return yse(f,l,g);case"pow":return mse(f,l,g,2);case"sqrt":return wse(f,l,g);default:return g[0]}};return[d(n,c),d(n,u),d(n,h)]}}beforeDraw(e){const{model:t}=this.context,n=t.getNodeData(),i=Gr(this.options.maxSize),a=Gr(this.options.minSize),s=this.getCentralities(this.options.centrality),o=s.size>0?Math.max(...s.values()):0,A=s.size>0?Math.min(...s.values()):0;return n.forEach(l=>{var c;const u=this.assignSizeByCentrality(s.get(Y(l))||0,A,o,a,i,this.options.scale),h=(c=this.context.element)===null||c===void 0?void 0:c.getElement(Y(l)),d={size:u};this.assignLabelStyle(d,u,l,h),(!h||!mf(d,h.attributes))&&Vr(e,h?"update":"add","node",Dn(l,{style:d}),!0)}),e}assignLabelStyle(e,t,n,i){var a;const s=i?i.config.style:(a=this.context.element)===null||a===void 0?void 0:a.getElementComputedStyle("node",n);if(Object.assign(e,ws(s,["labelFontSize","labelLineHeight"])),this.options.mapLabelSize){const o=this.getLabelSizeByNodeSize(t,1/0,Number(e.labelFontSize));Object.assign(e,{labelFontSize:o,labelLineHeight:o+kV(e.labelPadding)})}return e}getLabelSizeByNodeSize(e,t,n){const i=Math.min(...e)/2,[a,s]=Array.isArray(this.options.mapLabelSize)?this.options.mapLabelSize:[n,t];return Math.min(s,Math.max(i,a))}getCentralities(e){const{model:t}=this.context,n=t.getData();if(typeof e=="function")return e(n);const i=t.getRelatedEdgesData.bind(t);return IS(n,i,e)}}xf.defaultOptions={centrality:{type:"degree"},maxSize:80,minSize:20,scale:"linear",mapLabelSize:!1};class Cf extends fs{constructor(e,t){super(e,Object.assign({},Cf.defaultOptions,t))}get ref(){return this.context.model.getRootsData()[0]}afterLayout(){var e;const t=Fn(this.ref),{graph:n,model:i}=this.context;(e=i.getData().nodes)===null||e===void 0||e.forEach(s=>{var o;if(Y(s)===Y(this.ref))return;const A=NS(Bt(Fn(s),t)),l=Math.abs(A)>Math.PI/2,c=!s.children||s.children.length===0,u=Y(s),h=(o=this.context.element)===null||o===void 0?void 0:o.getElement(u);if(!h||!h.isVisible())return;const d=Gr(n.getElementRenderStyle(u).size)[0]/2,f=(c?1:-1)*(d+this.options.offset),g=[["translate",f*Math.cos(A),f*Math.sin(A)],["rotate",l?br(A)+180:br(A)]];i.updateNodeData([{id:Y(s),style:{labelTextAlign:l===c?"right":"left",labelTextBaseline:"middle",labelTransform:g}}])}),n.draw()}}Cf.defaultOptions={offset:5};const bse="quadratic",jU=["top","top-right","right","right-bottom","bottom","bottom-left","left","left-top"];class Sf extends fs{constructor(e,t){super(e,Object.assign({},Sf.defaultOptions,t)),this.cacheMergeStyle=new Map,this.getAffectedParallelEdges=n=>{const{add:{edges:i},update:{nodes:a,edges:s,combos:o},remove:{edges:A}}=n,{model:l}=this.context,c=new Map,u=(f,g)=>{l.getRelatedEdgesData(g).forEach(v=>!c.has(Y(v))&&c.set(Y(v),v))};a.forEach(u),o.forEach(u);const h=f=>{const g=new Set(n.remove.edges.keys()),p=l.getEdgeData().filter(v=>!g.has(Y(v))).map(v=>VU(l,v));Bse(f,p).forEach(v=>{const y=Y(v);c.has(y)||c.set(y,v)})};if(A.size&&A.forEach(h),i.size&&i.forEach(h),s.size){const f=YL(Db(l.getChanges())).update.edges;s.forEach(g=>{var p;h(g);const v=(p=f.find(y=>Y(y.value)===Y(g)))===null||p===void 0?void 0:p.original;v&&!TB(g,v)&&h(v)})}Ui(this.options.edges)||c.forEach((f,g)=>!this.options.edges.includes(g)&&c.delete(g));const d=l.getEdgeData().map(Y);return new Map([...c].sort((f,g)=>d.indexOf(f[0])-d.indexOf(g[0])))},this.applyBundlingStyle=(n,i,a)=>{const{edgeMap:s,reverses:o}=WU(i);s.forEach(A=>{A.forEach((l,c,u)=>{var h;const d=u.length,f=l.style||{};if(l.source===l.target){const v=jU.length;f.loopPlacement=jU[c%v],f.loopDist=Math.floor(c/v)*a+50}else if(d===1)f.curveOffset=0;else{const v=(c%2===0?1:-1)*(o[`${l.source}|${l.target}|${c}`]?-1:1);f.curveOffset=d%2===1?v*Math.ceil(c/2)*a*2:v*(Math.floor(c/2)*a*2+a)}const g=Object.assign(l,{type:bse,style:f}),p=(h=this.context.element)===null||h===void 0?void 0:h.getElement(Y(l));(!p||!mf(g.style,p.attributes))&&Vr(n,p?"update":"add","edge",g,!0)})})},this.resetEdgeStyle=n=>{const i=n.style||{},a=this.cacheMergeStyle.get(Y(n))||{};return Object.keys(a).forEach(s=>{Xt(i[s],a[s])&&(n[s]?i[s]=n[s]:delete i[s])}),Object.assign(n,{style:i})},this.applyMergingStyle=(n,i)=>{const{edgeMap:a,reverses:s}=WU(i);a.forEach(o=>{var A;if(o.length===1){const c=o[0],u=(A=this.context.element)===null||A===void 0?void 0:A.getElement(Y(c)),h=this.resetEdgeStyle(c);(!u||!mf(h,u.attributes))&&Vr(n,u?"update":"add","edge",h);return}const l=o.map(({source:c,target:u,style:h={}},d)=>{const{startArrow:f,endArrow:g}=h,p={},[v,y]=s[`${c}|${u}|${d}`]?["endArrow","startArrow"]:["startArrow","endArrow"];return BA(f)&&(p[v]=f),BA(g)&&(p[y]=g),p}).reduce((c,u)=>Object.assign(Object.assign({},c),u),{});o.forEach((c,u,h)=>{var d;if(u!==0){Vr(n,"remove","edge",c);return}const f=Object.assign({},Te(this.options.style)?this.options.style(h):this.options.style,{childrenData:h});this.cacheMergeStyle.set(Y(c),f);const g=Object.assign(Object.assign({},c),{type:"line",style:Object.assign(Object.assign(Object.assign({},c.style),l),f)}),p=(d=this.context.element)===null||d===void 0?void 0:d.getElement(Y(c));(!p||!mf(g.style,p.attributes))&&Vr(n,p?"update":"add","edge",g,!0)})})}}beforeDraw(e){const t=this.getAffectedParallelEdges(e);return t.size===0||(this.options.mode==="bundle"?this.applyBundlingStyle(e,t,this.options.distance):this.applyMergingStyle(e,t)),e}}Sf.defaultOptions={mode:"bundle",distance:15};const WU=r=>{const e=new Map,t=new Set,n={},i=new Map;for(const[a,s]of r){if(t.has(a))continue;const{source:o,target:A}=s,l=`${o}-${A}`;e.has(l)||(e.set(l,[]),i.set(l,new Set));const c=e.get(l),u=i.get(l);c&&u&&!u.has(a)&&(c.push(s),u.add(a),t.add(a));for(const[h,d]of r)if(!(t.has(h)||h===a)&&TB(s,d)){const f=e.get(l),g=i.get(l);f&&g&&!g.has(h)&&(f.push(d),g.add(h),o===d.target&&A===d.source&&(n[`${d.source}|${d.target}|${f.length-1}`]=!0),t.add(h))}}return{edgeMap:e,reverses:n}},Bse=(r,e,t)=>e.filter(n=>TB(n,r)),TB=(r,e)=>{const{sourceNode:t,targetNode:n}=r.style||{},{sourceNode:i,targetNode:a}=e.style||{};return t===i&&n===a||t===a&&n===i};class Ese extends fs{beforeDraw(e,t){const{stage:n}=t;if(n==="visibility")return e;const{model:i}=this.context,{update:{nodes:a,edges:s,combos:o}}=e,A=(l,c)=>{i.getRelatedEdgesData(c).forEach(h=>!s.has(Y(h))&&s.set(Y(h),h))};return a.forEach(A),o.forEach(A),e}}const xse={animation:{"combo-collapse":BS,"combo-expand":OV,"node-collapse":wS,"node-expand":TV,"path-in":bS,"path-out":MV,fade:SV,translate:FV},behavior:{"brush-select":vl,"click-select":uh,"collapse-expand":kh,"create-edge":Qh,"drag-canvas":Uh,"drag-element-force":EW,"drag-element":Fl,"fix-element-size":Gh,"focus-element":Kh,"hover-activate":zh,"lasso-select":CW,"auto-adapt-label":ah,"optimize-viewport-transform":Vh,"scroll-canvas":jh,"zoom-canvas":Wh},combo:{circle:T9,rect:M9},edge:{cubic:Ws,line:xF,polyline:Ih,quadratic:_h,"cubic-horizontal":Th,"cubic-radial":Mh,"cubic-vertical":Oh},layout:{"antv-dagre":G$,"combo-combined":X7,"compact-box":NW,"d3-force":EY,"force-atlas2":HJ,circular:V$,concentric:Hv,dagre:bd,dendrogram:RW,fishbone:Md,force:UT,fruchterman:zJ,grid:jJ,indented:zW,mds:KT,mindmap:$W,radial:tee,random:Aee,snake:Od},node:{circle:wl,diamond:Qj,ellipse:vh,hexagon:Hj,html:xh,image:hF,rect:S9,star:F9,donut:gh,triangle:Ch},palette:{spectral:xee,tableau:Cee,oranges:See,greens:Fee,blues:Tee},theme:{dark:zae,light:Vae},plugin:{"bubble-sets":Rd,"edge-bundling":Gd,"edge-filter-lens":Kd,"grid-line":jd,background:Id,contextmenu:Hd,fisheye:zd,fullscreen:Vd,history:Wd,hull:Xd,legend:df,minimap:ff,snapline:gf,timebar:pf,title:_ae,toolbar:FU,tooltip:vf,watermark:yf},transform:{"arrange-draw-order":jae,"collapse-expand-combo":Wae,"collapse-expand-node":qae,"get-edge-actual-ends":pse,"map-node-size":xf,"place-radial-labels":Cf,"process-parallel-edges":Sf,"update-related-edges":Ese},shape:{circle:zi,ellipse:RA,group:Cn,html:Is,image:Av,line:_s,path:tr,polygon:ks,polyline:zc,rect:Gn,text:Ns,label:Ji,badge:zo}};function Cse(){Object.entries(xse).forEach(([r,e])=>{Object.entries(e).forEach(([t,n])=>{$ae(r,t,n)})})}Cse();const vA=10,gs="#1890ff",ps={canal:gs,pumpStation:"#52c41a",reservoir:"#13c2c2",sluice:"#faad14",dispatchUnit:"#722ed1",dispatchNode:"#eb2f96",auxiliary:gs},xa={canal:{fill:"#e6f7ff",stroke:"#1890ff",lineWidth:2,radius:4,width:200,height:40},pumpStation:{fill:"#f6ffed",stroke:"#52c41a",lineWidth:2,width:48,height:48,img:""},reservoir:{fill:"#e6fffb",stroke:"#13c2c2",lineWidth:2,radius:24,width:48,height:48},sluice:{fill:"#fffbe6",stroke:"#faad14",lineWidth:2,radius:4,width:48,height:36},dispatchUnit:{fill:"#f9f0ff",stroke:"#722ed1",lineWidth:2,radius:20,width:40,height:40},dispatchNode:{fill:"#fff0f6",stroke:"#eb2f96",lineWidth:2,radius:16,width:32,height:32},auxiliary:{fill:gs,stroke:gs,lineWidth:0,radius:0,width:vA,height:vA}},MB={stroke:gs,lineWidth:vA,endArrow:!1},qU={flow:{stroke:gs,lineWidth:vA},control:{stroke:"#faad14",lineWidth:3,lineDash:[8,4]},supply:{stroke:"#52c41a",lineWidth:3,lineDash:[6,4]}};function $U(r){return{...xa[r]}}function YU(r){const e={...MB};return r&&qU[r]?{...e,...qU[r]}:e}const OB={light:{name:"light",backgroundColor:"#ffffff",nodeStyle:xa,edgeStyle:MB},dark:{name:"dark",backgroundColor:"#141414",nodeStyle:{canal:{...xa.canal,fill:"#1d3557",stroke:"#4dabf7"},pumpStation:{...xa.pumpStation,fill:"#2d4a22",stroke:"#69db7c"},reservoir:{...xa.reservoir,fill:"#1d4a4a",stroke:"#38d9a9"},sluice:{...xa.sluice,fill:"#4a3e1d",stroke:"#ffd43b"},dispatchUnit:{...xa.dispatchUnit,fill:"#2d1d4a",stroke:"#b197fc"},dispatchNode:{...xa.dispatchNode,fill:"#4a1d3e",stroke:"#f783ac"},auxiliary:{...xa.auxiliary,fill:"#4dabf7",stroke:"#4dabf7"}},edgeStyle:{...MB,stroke:"#4dabf7"}}};function XU(r){const e=r?.name||"light",t=OB[e]??OB.light;return{...t,...r,nodeStyle:{...t.nodeStyle||{},...r?.nodeStyle||{}},edgeStyle:{...t.edgeStyle||{},...r?.edgeStyle||{}}}}function Sse(r,e){return{...r,...e}}function Fse(r,e){return{...r,...e}}const Ff={canal:{type:"rect",style:{fill:"#e6f7ff",stroke:ps.canal,lineWidth:2,radius:4,width:200,height:40}},pumpStation:{type:"circle",style:{fill:"#f6ffed",stroke:ps.pumpStation,lineWidth:2,width:48,height:48}},reservoir:{type:"circle",style:{fill:"#e6fffb",stroke:ps.reservoir,lineWidth:2,width:48,height:48}},sluice:{type:"rect",style:{fill:"#fffbe6",stroke:ps.sluice,lineWidth:2,radius:4,width:48,height:36}},dispatchUnit:{type:"circle",style:{fill:"#f9f0ff",stroke:ps.dispatchUnit,lineWidth:2,width:40,height:40}},dispatchNode:{type:"circle",style:{fill:"#fff0f6",stroke:ps.dispatchNode,lineWidth:2,width:32,height:32}},auxiliary:{type:"rect",style:{fill:"#f0f0f0",stroke:ps.auxiliary,lineWidth:1,width:16,height:16}}};function Tse(){}function Mse(r){return Ff[r]?.type||"circle"}function Ose(r){return{...Ff[r]?.style}}function Ise(r,e){const t=Ff[r]||Ff.dispatchNode;return{type:t.type,style:{...t.style,...e}}}const Tf={flow:{type:"polyline",style:{stroke:"#1890ff",lineWidth:2,endArrow:!0}},control:{type:"line",style:{stroke:"#faad14",lineWidth:1.5,lineDash:[6,3],endArrow:!0}},supply:{type:"line",style:{stroke:"#52c41a",lineWidth:1.5,lineDash:[4,4],endArrow:!0}},curve:{type:"quadratic",style:{stroke:"#91d5ff",lineWidth:2,endArrow:!0,curveOffset:30}}};function _se(){}function kse(r){return Tf[r||"flow"]?.type||"line"}function Nse(r){return{...Tf[r||"flow"]?.style}}function Lse(r,e){const t=Tf[r||"flow"]??Tf.flow;return{type:t.type,style:{...t.style,...e}}}function ZU(r){const e=[];return r.enableZoom!==!1&&e.push({type:"zoom-canvas",sensitivity:1,minZoom:.1,maxZoom:5}),r.enableDrag!==!1&&e.push({type:"drag-element",key:"drag-element",enable:t=>["node","combo"].includes(t.targetType),shadow:!1,dropEffect:"move",hideEdge:"none"}),e.push({type:"drag-canvas",key:"drag-canvas",enable:t=>t.targetType==="canvas"}),e.push({type:"click-select",multiple:!0}),r.enableBrush&&e.push({type:"brush-select",trigger:"shift"}),e.push({type:"hover-activate"}),e}function Qse(r){const e=[];return r.enableZoom!==!1&&e.push({type:"zoom-canvas",sensitivity:1,minZoom:.1,maxZoom:5}),e.push({type:"drag-canvas",enable:!0}),e.push({type:"hover-activate"}),e}const Use={ZOOM_CANVAS:"zoom-canvas",DRAG_CANVAS:"drag-canvas",DRAG_ELEMENT:"drag-element",CLICK_SELECT:"click-select",BRUSH_SELECT:"brush-select",HOVER_ACTIVATE:"hover-activate"};class IB{graph=null;container=null;options;state={loading:!1,rendered:!1,zoom:1,selectedNodes:[],selectedEdges:[]};eventHandlers=new Map;constructor(e){this.options=e}async init(){const e=typeof this.options.container=="string"?document.getElementById(this.options.container):this.options.container;if(!e)throw new Error("Container not found");this.container=e;const t=XU(this.options.theme),n=ZU(this.options);return this.graph=new Ef({container:e,width:this.options.width||e.clientWidth,height:this.options.height||e.clientHeight,autoFit:this.options.fitView?"view":void 0,padding:this.options.fitViewPadding,background:t.backgroundColor||"#fafafa",layout:this.buildLayoutConfig(this.options.layout),behaviors:n,plugins:this.buildPlugins(),node:{type:i=>i.nodeShape||"circle",style:i=>{const a=i,s=a.styleConfig||{};return a.nodeShape==="image"&&s.img?{src:s.img,size:[s.width||48,s.height||48],labelText:a.data?.label||"",labelPlacement:"bottom",labelOffsetY:8}:{fill:s.fill||"#fff",stroke:s.stroke||"#1890ff",lineWidth:s.lineWidth??2,radius:s.radius??4,size:s.width?[s.width,s.height||s.width]:void 0,labelText:a.data?.label||"",labelPlacement:"bottom"}}},edge:{type:i=>{const a=i;return a.styleConfig?.router?"polyline":a.edgeShape||"line"},style:i=>{const a=i,s={stroke:a.styleConfig?.stroke||"#1890ff",lineWidth:a.styleConfig?.lineWidth||2,endArrow:a.styleConfig?.endArrow??!0};return a.styleConfig?.router&&(s.router={type:"orth",offset:20}),s}}}),this.bindEvents(),this.state.rendered=!0,this.graph}buildLayoutConfig(e){return!e||e.type==="custom"?void 0:{force:{type:"force",preventOverlap:!0,nodeSize:50,...e.options},grid:{type:"grid",rows:4,cols:4,...e.options},dagre:{type:"dagre",rankdir:"TB",nodesep:60,ranksep:80,...e.options},circular:{type:"circular",radius:200,...e.options},radial:{type:"radial",unitRadius:100,...e.options},concentric:{type:"concentric",minNodeSpacing:60,...e.options},tree:{type:"dendrogram",direction:"TB",nodeSep:40,rankSep:100,...e.options}}[e.type]||{type:e.type,...e.options}}buildPlugins(){const e=[];return this.options.tooltip?.enabled!==!1&&e.push({type:"tooltip",getContent:(t,n)=>{if(this.options.tooltip?.formatter&&n.length>0)return this.options.tooltip.formatter(n[0]);const i=n[0];return`<div style="padding: 8px 12px;">
|
|
134
134
|
<div style="font-weight: bold;">${i?.data?.label||""}</div>
|
|
135
135
|
<div style="color: #666; font-size: 12px;">${i?.entityType||""}</div>
|
|
136
136
|
</div>`}}),this.options.enableMinimap&&e.push({type:"minimap",size:[150,100]}),e}bindEvents(){if(!this.graph)return;const e=["node:click","node:dblclick","node:contextmenu","node:mouseenter","node:mouseleave","node:dragstart","node:drag","node:dragend","edge:click","edge:dblclick","edge:contextmenu","edge:mouseenter","edge:mouseleave","canvas:click","canvas:dragstart","canvas:drag","canvas:dragend","combo:click","combo:dblclick"];for(const t of e)this.graph.on(t,n=>{this.emitEvent(t,n)})}emitEvent(e,t){const n=this.eventHandlers.get(e);if(n)for(const i of n)i({type:e,itemData:t?.target,originalEvent:t,graph:this.graph})}on(e,t){this.eventHandlers.has(e)||this.eventHandlers.set(e,new Set),this.eventHandlers.get(e).add(t)}off(e,t){t?this.eventHandlers.get(e)?.delete(t):this.eventHandlers.delete(e)}async render(e){this.graph||await this.init(),this.state.loading=!0;try{await this.graph.setData(e),await this.graph.render()}finally{this.state.loading=!1}}async updateData(e){if(!this.graph)return;const t=this.graph.getData(),n={nodes:e.nodes??t.nodes,edges:e.edges??t.edges,combos:e.combos??t.combos};await this.graph.setData(n),await this.graph.render()}async addNode(e){this.graph&&(await this.graph.addNodeData([e]),await this.graph.draw())}async addEdge(e){this.graph&&(await this.graph.addEdgeData([e]),await this.graph.draw())}async removeNode(e){this.graph&&(await this.graph.removeNodeData([e]),await this.graph.draw())}async removeEdge(e){this.graph&&(await this.graph.removeEdgeData([e]),await this.graph.draw())}async updateNode(e,t){this.graph&&(await this.graph.updateNodeData([{id:e,...t}]),await this.graph.draw())}async updateEdge(e,t){this.graph&&(await this.graph.updateEdgeData([{id:e,...t}]),await this.graph.draw())}zoomTo(e){this.graph&&(this.graph.zoomTo(e),this.state.zoom=e)}zoomIn(){const e=Math.min(this.state.zoom*1.2,5);this.zoomTo(e)}zoomOut(){const e=Math.max(this.state.zoom/1.2,.1);this.zoomTo(e)}fitView(){this.graph&&this.graph.fitView()}focusNode(e){this.graph&&this.graph.focusElement(e)}getData(){return this.graph?this.graph.getData():{nodes:[],edges:[],combos:[]}}save(){const e=this.getData();return JSON.stringify(e,null,2)}async load(e){const t=JSON.parse(e);await this.render(t)}async toImage(e){return this.graph?await this.graph.toDataURL({mode:"overall",type:e?.format==="jpg"?"image/jpeg":"image/png"}):""}async downloadImage(e){const t=await this.toImage(e);if(!t)return;const n=document.createElement("a");n.download=e?.fileName||"irrigation-graph",n.href=t,n.click()}print(){if(!this.container)return;const e=window.open("","_blank");e&&(e.document.write(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "irr-gh",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "灌溉系统概化图组件",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/irr-gh.umd.cjs",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"import": "./dist/irr-gh.js",
|
|
13
13
|
"require": "./dist/irr-gh.umd.cjs"
|
|
14
14
|
},
|
|
15
|
-
"./style.css": "./dist/
|
|
15
|
+
"./style.css": "./dist/irr-gh.css"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"dist"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"灌溉",
|
|
52
52
|
"概化图"
|
|
53
53
|
],
|
|
54
|
-
"author": "
|
|
54
|
+
"author": "eRiver",
|
|
55
55
|
"license": "MIT",
|
|
56
56
|
"repository": {
|
|
57
57
|
"type": "git",
|