@gientech/modual 2.3.8 → 2.3.9

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.
Binary file
@@ -1,4 +1,4 @@
1
- import{jsx as _,jsxs as Y,Fragment as Vr}from"react/jsx-runtime";import*as ce from"react";import Le,{createElement as ai,PureComponent as Ds,useState as J,useMemo as Ce,createContext as Aa,Children as _s,cloneElement as Ss,Component as ks,useRef as tt,useEffect as Ve,useCallback as Dt,useContext as Rs}from"react";import yt from"axios";import{AiChat as Is,validateFileUpload as Ns,showValidationErrors as Ps}from"@mxmweb/aichat";import{mergeLiveChunkToNodes as Ts,ChatMessageAdapter as a0}from"@mxmweb/rtext";import{Dropdown as qs,Input as Da,Popover as zs,message as Je,Skeleton as nn,Button as Ht,ConfigProvider as Zn,Modal as jn,Form as s0,Table as Os,Pagination as Ls,Empty as Ms,Tooltip as Mr,Drawer as _a,Select as Sa,DatePicker as $s}from"antd";import{u as sr}from"./index-CpW6Dhpp.js";import{Icon as ka,defaultTheme as Ur,useTheme as Mi,deepMergeTheme as Rr,DashboardContainer as Ra,DeptUserSelector as Vs}from"@mxmweb/zui";import{E as $i,m as Vi,y as De,w as or,d as Us,e as Hs,_ as Ft,k as ve,l as Ee,x as Ia,b as Hr,c as j,a as Wr,B as jr,C as Wt,z as Ui,h as $r,G as Ws,H as si,g as js}from"./AntdIcon-C8lLl5Jn.js";import Ut from"dayjs";import{c as hr}from"./createLucideIcon-Bj5DlX2s.js";import{P as Ks}from"./plus-B679mjyt.js";import{S as Kn}from"./search-CEuIa9-_.js";import{X as Hi}from"./x-CdZQbi--.js";import{i as Gs,_ as Na,m as zr,g as pr,s as ir,a as o0,b as Xs,c as Ys,t as Qs}from"./index-djXskign.js";import{f as Zs,r as Js,a as eo,c as to,d as Pa,g as Ta,b as qa,e as Ci,h as Wi,i as Ei,D as ro,j as no,T as Gn,k as io,l as ao,m as so,n as oo,G as uo,o as lo,W as co,p as fo,u as po,F as xo,q as u0,s as oi,t as ho,v as go,w as vo,x as mo,y as yo}from"./index-CqAhjlSN.js";import{a as Fo,C as Co,G as za}from"./GientechStreamReader-_ih9ja1B.js";import{R as Eo,k as bo,g as ui,r as Oa,a as wo,b as li}from"./index-CIPEixYE.js";/* empty css *//* empty css */import"@mxmweb/fviewer";import"../database.js";import"../databaseId.js";import"../databaseTable.js";import"../modelManage.js";import"../sensitive.js";import"../oprecords.js";import Me from"styled-components";import{Xviwer as bi}from"@mxmweb/xviewer";import"./index-C4Mch_6h.js";/**
1
+ import{jsx as _,jsxs as Y,Fragment as Vr}from"react/jsx-runtime";import*as ce from"react";import Le,{createElement as ai,PureComponent as Ds,useState as J,useMemo as Ce,createContext as Aa,Children as _s,cloneElement as Ss,Component as ks,useRef as tt,useEffect as Ve,useCallback as Dt,useContext as Rs}from"react";import yt from"axios";import{AiChat as Is,validateFileUpload as Ns,showValidationErrors as Ps}from"@mxmweb/aichat";import{mergeLiveChunkToNodes as Ts,ChatMessageAdapter as a0}from"@mxmweb/rtext";import{Dropdown as qs,Input as Da,Popover as zs,message as Je,Skeleton as nn,Button as Ht,ConfigProvider as Zn,Modal as jn,Form as s0,Table as Os,Pagination as Ls,Empty as Ms,Tooltip as Mr,Drawer as _a,Select as Sa,DatePicker as $s}from"antd";import{u as sr}from"./index-CpW6Dhpp.js";import{Icon as ka,defaultTheme as Ur,useTheme as Mi,deepMergeTheme as Rr,DashboardContainer as Ra,DeptUserSelector as Vs}from"@mxmweb/zui";import{G as $i,m as Vi,y as De,w as or,d as Us,e as Hs,_ as Ft,k as ve,l as Ee,x as Ia,b as Hr,c as j,a as Wr,B as jr,C as Wt,z as Ui,h as $r,H as Ws,J as si,g as js}from"./lodash-Damzdmsp.js";import Ut from"dayjs";import{c as hr}from"./createLucideIcon-Bj5DlX2s.js";import{P as Ks}from"./plus-B679mjyt.js";import{S as Kn}from"./search-CEuIa9-_.js";import{X as Hi}from"./x-CdZQbi--.js";import{i as Gs,_ as Na,m as zr,g as pr,s as ir,a as o0,b as Xs,c as Ys,t as Qs}from"./index-C_ZueMV3.js";import{f as Zs,r as Js,a as eo,c as to,d as Pa,g as Ta,b as qa,e as Ci,h as Wi,i as Ei,D as ro,j as no,T as Gn,k as io,l as ao,m as so,n as oo,G as uo,o as lo,W as co,p as fo,u as po,F as xo,q as u0,s as oi,t as ho,v as go,w as vo,x as mo,y as yo}from"./index-BIl0ZvFZ.js";import{a as Fo,C as Co,G as za}from"./GientechStreamReader-_ih9ja1B.js";import{R as Eo,k as bo,g as ui,r as Oa,a as wo,b as li}from"./index-BIS6Xs7b.js";/* empty css *//* empty css */import"@mxmweb/fviewer";import"../database.js";import"../databaseId.js";import"../databaseTable.js";import"../modelManage.js";import"../sensitive.js";import"../oprecords.js";import Me from"styled-components";import{Xviwer as bi}from"@mxmweb/xviewer";import"./index-C5OVrHqf.js";/**
2
2
  * @license lucide-react v0.456.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1 @@
1
+ import{g as l}from"./lodash-Damzdmsp.js";import u from"react-dom";function s(e,i){for(var n=0;n<i.length;n++){const t=i[n];if(typeof t!="string"&&!Array.isArray(t)){for(const r in t)if(r!=="default"&&!(r in e)){const a=Object.getOwnPropertyDescriptor(t,r);a&&Object.defineProperty(e,r,a.get?a:{enumerable:!0,get:()=>t[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var o={},c;function p(){if(c)return o;c=1;var e=u;return o.createRoot=e.createRoot,o.hydrateRoot=e.hydrateRoot,o}var f=p();const d=l(f),y=s({__proto__:null,default:d},[f]);export{y as c};
@@ -207,12 +207,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
207
207
  * @date 7/30/2025, 1:35:41 PM
208
208
  * @author AntVis
209
209
  * @docs https://g.antv.antgroup.com/
210
- */var a6=(function(){function n(t){et(this,n),this.dragndropPluginOptions=t}return nt(n,[{key:"apply",value:function(t){var e=this,r=t.renderingService,i=t.renderingContext,a=i.root.ownerDocument,o=a.defaultView,s=function(u){var c=u.target,l=c===a,d=l&&e.dragndropPluginOptions.isDocumentDraggable?a:c.closest&&c.closest("[draggable=true]");if(d){var p=!1,g=u.timeStamp,m=[u.clientX,u.clientY],y=null,v=[u.clientX,u.clientY],x=(function(){var w=ya(fn().mark(function S(k){var A,N,T,O,M,P;return fn().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(p){L.next=2;break}if(A=k.timeStamp-g,N=Hn([k.clientX,k.clientY],m),!(A<=e.dragndropPluginOptions.dragstartTimeThreshold||N<=e.dragndropPluginOptions.dragstartDistanceThreshold)){L.next=1;break}return L.abrupt("return");case 1:k.type="dragstart",d.dispatchEvent(k),p=!0;case 2:if(k.type="drag",k.dx=k.clientX-v[0],k.dy=k.clientY-v[1],d.dispatchEvent(k),v=[k.clientX,k.clientY],l){L.next=4;break}return T=e.dragndropPluginOptions.overlap==="pointer"?[k.canvasX,k.canvasY]:c.getBounds().center,L.next=3,a.elementsFromPoint(T[0],T[1]);case 3:O=L.sent,M=O[O.indexOf(c)+1],P=(M==null?void 0:M.closest("[droppable=true]"))||(e.dragndropPluginOptions.isDocumentDroppable?a:null),y!==P&&(y&&(k.type="dragleave",k.target=y,y.dispatchEvent(k)),P&&(k.type="dragenter",k.target=P,P.dispatchEvent(k)),y=P,y&&(k.type="dragover",k.target=y,y.dispatchEvent(k)));case 4:case"end":return L.stop()}},S)}));return function(S){return w.apply(this,arguments)}})();o.addEventListener("pointermove",x);var E=function(w){if(p){w.detail={preventClick:!0};var S=w.clone();y&&(S.type="drop",S.target=y,y.dispatchEvent(S)),S.type="dragend",d.dispatchEvent(S),p=!1}o.removeEventListener("pointermove",x)};c.addEventListener("pointerup",E,{once:!0}),c.addEventListener("pointerupoutside",E,{once:!0})}};r.hooks.init.tap(n.tag,function(){o.addEventListener("pointerdown",s)}),r.hooks.destroy.tap(n.tag,function(){o.removeEventListener("pointerdown",s)})}}])})();a6.tag="Dragndrop";var tJ=(function(n){function t(){var e,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return et(this,t),e=Bt(this,t),e.name="dragndrop",e.options=r,e}return zt(t,n),nt(t,[{key:"init",value:function(){this.addRenderingPlugin(new a6(Lt({overlap:"pointer",isDocumentDraggable:!1,isDocumentDroppable:!1,dragstartDistanceThreshold:0,dragstartTimeThreshold:0},this.options)))}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}},{key:"setOptions",value:function(e){Object.assign(this.plugins[0].dragndropPluginOptions,e)}}])})(wa),kT=function(n,t,e,r){function i(a){return a instanceof e?a:new e(function(o){o(a)})}return new(e||(e=Promise))(function(a,o){function s(l){try{c(r.next(l))}catch(d){o(d)}}function u(l){try{c(r.throw(l))}catch(d){o(d)}}function c(l){l.done?a(l.value):i(l.value).then(s,u)}c((r=r.apply(n,t||[])).next())})},AT=function(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(e[r[i]]=n[r[i]]);return e};const ST=["main"],CT=["background","main","label","transient"];function eJ(n){return n.main}class NT{getConfig(){return this.config}getLayer(t="main"){return this.extends.layers[t]||eJ(this.getLayers())}getLayers(){return this.extends.layers}getRenderer(t){return this.extends.renderers[t]}getCamera(t="main"){return this.getLayer(t).getCamera()}getRoot(t="main"){return this.getLayer(t).getRoot()}getContextService(t="main"){return this.getLayer(t).getContextService()}setCursor(t){this.config.cursor=t,this.getLayer().setCursor(t)}get document(){return this.getLayer().document}get context(){return this.getLayer().context}constructor(t){this.config={enableMultiLayer:!0},Object.assign(this.config,t);const e=this.config,{renderer:r,background:i,enableMultiLayer:a}=e,o=AT(e,["renderer","background","cursor","enableMultiLayer"]),s=a?CT:ST,u=TT(r,s),c=Object.fromEntries(s.map(l=>{const d=new I1(Object.assign(Object.assign({},o),{supportsMutipleCanvasesInOneContainer:a,renderer:u[l],background:a?l==="background"?i:void 0:i}));return[l,d]}));MT(c),this.extends={config:this.config,renderer:r,renderers:u,layers:c}}get ready(){return Promise.all(Object.entries(this.getLayers()).map(([,t])=>t.ready))}resize(t,e){Object.assign(this.extends.config,{width:t,height:e}),Object.values(this.getLayers()).forEach(r=>{const i=r.getCamera(),a=i.getPosition(),o=i.getFocalPoint();r.resize(t,e),i.setPosition(a),i.setFocalPoint(o)})}getBounds(t){return Fu(Object.values(this.getLayers()).map(e=>t?e.getRoot().childNodes.find(r=>r.classList.includes(t)):e.getRoot()).filter(e=>(e==null?void 0:e.childNodes.length)>0).map(e=>e.getBounds()))}getContainer(){const t=this.extends.config.container;return typeof t=="string"?document.getElementById(t):t}getSize(){return[this.extends.config.width||0,this.extends.config.height||0]}appendChild(t,e){var r;const i=((r=t.style)===null||r===void 0?void 0:r.$layer)||"main";return this.getLayer(i).appendChild(t,e)}setRenderer(t){if(t===this.extends.renderer)return;const e=TT(t,this.config.enableMultiLayer?CT:ST);this.extends.renderers=e,Object.entries(e).forEach(([r,i])=>this.getLayer(r).setRenderer(i)),MT(this.getLayers())}getCanvasByViewport(t){return oi(this.getLayer().viewport2Canvas(Js(t)))}getViewportByCanvas(t){return oi(this.getLayer().canvas2Viewport(Js(t)))}getViewportByClient(t){return oi(this.getLayer().client2Viewport(Js(t)))}getClientByViewport(t){return oi(this.getLayer().viewport2Client(Js(t)))}getClientByCanvas(t){return this.getClientByViewport(this.getViewportByCanvas(t))}getCanvasByClient(t){const e=this.getLayer(),r=e.client2Viewport(Js(t));return oi(e.viewport2Canvas(r))}toDataURL(){return kT(this,arguments,void 0,function*(t={}){const e=globalThis.devicePixelRatio||1,{mode:r="viewport"}=t,i=AT(t,["mode"]);let[a,o,s,u]=[0,0,0,0];if(r==="viewport")[s,u]=this.getSize();else if(r==="overall"){const x=this.getBounds(),E=zu(x);[a,o]=x.min,[s,u]=E}const c=b1('<div id="virtual-image"></div>'),l=new I1({width:s,height:u,renderer:new gh,devicePixelRatio:e,container:c,background:this.extends.config.background});yield l.ready,l.appendChild(this.getLayer("background").getRoot().cloneNode(!0)),l.appendChild(this.getRoot().cloneNode(!0));const d=this.getLayer("label").getRoot().cloneNode(!0),p=l.viewport2Canvas({x:0,y:0}),g=this.getCanvasByViewport([0,0]);d.translate([g[0]-p.x,g[1]-p.y]),d.scale(1/this.getCamera().getZoom()),l.appendChild(d),l.appendChild(this.getLayer("transient").getRoot().cloneNode(!0));const m=this.getCamera(),y=l.getCamera();if(r==="viewport")y.setZoom(m.getZoom()),y.setPosition(m.getPosition()),y.setFocalPoint(m.getFocalPoint());else if(r==="overall"){const[x,E,w]=y.getPosition(),[S,k,A]=y.getFocalPoint();y.setPosition([x+a,E+o,w]),y.setFocalPoint([S+a,k+o,A])}const v=l.getContextService();return new Promise(x=>{l.addEventListener(cr.RERENDER,()=>kT(this,void 0,void 0,function*(){yield new Promise(w=>setTimeout(w,300));const E=yield v.toDataURL(i);x(E)}))})})}destroy(){Object.values(this.getLayers()).forEach(t=>{t.getCamera().cancelLandmarkAnimation(),t.destroy()})}}function TT(n,t){return Object.fromEntries(t.map(e=>{const r=(n==null?void 0:n(e))||new gh;return r instanceof gh&&r.setConfig({enableDirtyRectangleRendering:!1}),e==="main"?r.registerPlugin(new tJ({isDocumentDraggable:!0,isDocumentDroppable:!0,dragstartDistanceThreshold:10,dragstartTimeThreshold:100})):r.unregisterPlugin(r.getPlugin("dom-interaction")),[e,r]}))}function MT(n){Object.entries(n).forEach(([t,e])=>{const r=e.getContextService().getDomElement();r!=null&&r.style&&(r.style.gridArea="1 / 1 / 2 / 2",r.style.outline="none",r.tabIndex=1,t!=="main"&&(r.style.pointerEvents="none")),r!=null&&r.parentElement&&(r.parentElement.style.display="grid",r.parentElement.style.isolation="isolate")})}const zo=n=>n?parseInt(n):0;function nJ(n){const t=getComputedStyle(n),e=n.clientWidth||zo(t.width),r=n.clientHeight||zo(t.height),i=zo(t.paddingLeft)+zo(t.paddingRight),a=zo(t.paddingTop)+zo(t.paddingBottom);return[e-i,r-a]}function _T(n){if(!n)return[0,0];let t=640,e=480;const[r,i]=nJ(n);t=r||t,e=i||e;const a=1,o=1;return[Math.max(Xt(t)?t:a,a),Math.max(Xt(e)?e:o,o)]}class Td{constructor(t){this.type=t}}class Xe extends Td{constructor(t,e){super(t),this.data=e}}class Tr extends Td{constructor(t,e,r,i){super(t),this.animationType=e,this.animation=r,this.data=i}}class Fo extends Td{constructor(t,e,r){super(t),this.elementType=e,this.data=r}}class kl extends Td{constructor(t,e){super(t),this.data=e}}function an(n,t){n.emit(t.type,t)}function rJ(n){if(!n)return null;if(n instanceof S_)return{type:"canvas",element:n};let t=n;for(;t;){if(Vu(t))return{type:"node",element:t};if(EO(t))return{type:"edge",element:t};if(Bb(t))return{type:"combo",element:t};t=t.parentElement}return null}function OT(n){var t;return((t=n==null?void 0:n.style)===null||t===void 0?void 0:t.zIndex)||0}const yu="cachedStyle",lx=n=>`__${n}__`;function iJ(n,t){const e=Array.isArray(t)?t:[t];lr(n,yu)||Xl(n,yu,{}),e.forEach(r=>{Xl(lr(n,yu),lx(r),n.attributes[r])})}function PT(n,t){return lr(n,[yu,lx(t)])}function aJ(n,t){return lx(t)in(lr(n,yu)||{})}class oJ{constructor(t){this.tasks=[],this.animations=new Set,this.context=t}getTasks(){const t=[...this.tasks];return this.tasks=[],t}add(t,e){this.tasks.push([t,e])}animate(t,e,r){var i,a,o;(i=e==null?void 0:e.before)===null||i===void 0||i.call(e);const s=this.getTasks().map(([c,l])=>{var d,p,g;const{element:m,elementType:y,stage:v}=c,x=eU(this.context.options,y,v,t);(d=l==null?void 0:l.before)===null||d===void 0||d.call(l);const E=x.length?rU(m,this.inferStyle(c,r),x):null;return E?((p=l==null?void 0:l.beforeAnimate)===null||p===void 0||p.call(l,E),E.finished.then(()=>{var w,S;(w=l==null?void 0:l.afterAnimate)===null||w===void 0||w.call(l,E),(S=l==null?void 0:l.after)===null||S===void 0||S.call(l),this.animations.delete(E)})):(g=l==null?void 0:l.after)===null||g===void 0||g.call(l),E}).filter(Boolean);s.forEach(c=>this.animations.add(c));const u=Pb(s);return u?((a=e==null?void 0:e.beforeAnimate)===null||a===void 0||a.call(e,u),u.finished.then(()=>{var c,l;(c=e==null?void 0:e.afterAnimate)===null||c===void 0||c.call(e,u),(l=e==null?void 0:e.after)===null||l===void 0||l.call(e),this.release()})):(o=e==null?void 0:e.after)===null||o===void 0||o.call(e),u}inferStyle(t,e){var r,i;const{element:a,elementType:o,stage:s,originalStyle:u,updatedStyle:c={}}=t;t.modifiedStyle||(t.modifiedStyle=Object.assign(Object.assign({},u),c));const{modifiedStyle:l}=t,d={},p={};if(s==="enter")Object.assign(d,{opacity:0});else if(s==="exit")Object.assign(p,{opacity:0});else if(s==="show")Object.assign(d,{opacity:0}),Object.assign(p,{opacity:(r=PT(a,"opacity"))!==null&&r!==void 0?r:ah("opacity")});else if(s==="hide")Object.assign(d,{opacity:(i=PT(a,"opacity"))!==null&&i!==void 0?i:ah("opacity")}),Object.assign(p,{opacity:0});else if(s==="collapse"){const{collapse:g}=e||{},{target:m,descendants:y,position:v}=g;if(o==="node"){if(y.includes(a.id)){const[x,E,w]=v;Object.assign(p,{x,y:E,z:w})}}else if(o==="combo"){if(a.id===m||y.includes(a.id)){const[x,E]=v;Object.assign(p,{x,y:E,childrenNode:u.childrenNode})}}else o==="edge"&&Object.assign(p,{sourceNode:l.sourceNode,targetNode:l.targetNode})}else if(s==="expand"){const{expand:g}=e||{},{target:m,descendants:y,position:v}=g;if(o==="node"){if(a.id===m||y.includes(a.id)){const[x,E,w]=v;Object.assign(d,{x,y:E,z:w})}}else if(o==="combo"){if(a.id===m||y.includes(a.id)){const[x,E,w]=v;Object.assign(d,{x,y:E,z:w,childrenNode:l.childrenNode})}}else o==="edge"&&Object.assign(d,{sourceNode:l.sourceNode,targetNode:l.targetNode})}return[Object.keys(d).length>0?Object.assign({},u,d):u,Object.keys(p).length>0?Object.assign({},l,p):l]}stop(){this.animations.forEach(t=>t.cancel())}clear(){this.tasks=[]}release(){var t,e;const{canvas:r}=this.context,i=(e=(t=r.document)===null||t===void 0?void 0:t.timeline)===null||e===void 0?void 0:e.animationsWithPromises;i&&(r.document.timeline.animationsWithPromises=i.filter(a=>a.playState!=="finished"))}destroy(){this.stop(),this.animations.clear(),this.tasks=[]}}class sJ{constructor(t){this.batchCount=0,this.context=t}emit(t){const{graph:e}=this.context;e.emit(t.type,t)}startBatch(t=!0){this.batchCount++,this.batchCount===1&&this.emit(new Xe(gt.BATCH_START,{initiate:t}))}endBatch(){this.batchCount--,this.batchCount===0&&this.emit(new Xe(gt.BATCH_END))}get isBatching(){return this.batchCount>0}destroy(){this.context=null}}class uJ extends Db{constructor(t){super(t),this.currentTarget=null,this.currentTargetType=null,this.category="behavior",this.forwardCanvasEvents=e=>{const{target:r}=e,i=rJ(r);if(!i)return;const{graph:a,canvas:o}=this.context,{type:s,element:u}=i;if("destroyed"in u&&(Uu(u)||u.destroyed))return;const{type:c,detail:l,button:d}=e,p=Object.assign(Object.assign({},e),{target:u,targetType:s,originalTarget:r});c===st.POINTER_MOVE&&(this.currentTarget!==u&&(this.currentTarget&&a.emit(`${this.currentTargetType}:${st.POINTER_LEAVE}`,Object.assign(Object.assign({},p),{type:st.POINTER_LEAVE,target:this.currentTarget,targetType:this.currentTargetType})),u&&(Object.assign(p,{type:st.POINTER_ENTER}),a.emit(`${s}:${st.POINTER_ENTER}`,p))),this.currentTarget=u,this.currentTargetType=s),c===st.CLICK&&d===2||(a.emit(`${s}:${c}`,p),a.emit(c,p)),c===st.CLICK&&l===2&&(Object.assign(p,{type:st.DBLCLICK}),a.emit(`${s}:${st.DBLCLICK}`,p),a.emit(st.DBLCLICK,p)),c===st.POINTER_DOWN&&d===2&&(Object.assign(p,{type:st.CONTEXT_MENU,preventDefault:()=>{var g;(g=o.getContainer())===null||g===void 0||g.addEventListener(st.CONTEXT_MENU,m=>m.preventDefault(),{once:!0})}}),a.emit(`${s}:${st.CONTEXT_MENU}`,p),a.emit(st.CONTEXT_MENU,p))},this.forwardContainerEvents=e=>{this.context.graph.emit(e.type,e)},this.forwardEvents(),this.setBehaviors(this.context.options.behaviors||[])}setBehaviors(t){this.setExtensions(t)}forwardEvents(){const t=this.context.canvas.getContainer();t&&[$o.KEY_DOWN,$o.KEY_UP].forEach(r=>{t.addEventListener(r,this.forwardContainerEvents)});const e=this.context.canvas.document;e&&[st.CLICK,st.DBLCLICK,st.POINTER_OVER,st.POINTER_LEAVE,st.POINTER_ENTER,st.POINTER_MOVE,st.POINTER_OUT,st.POINTER_DOWN,st.POINTER_UP,st.CONTEXT_MENU,st.DRAG_START,st.DRAG,st.DRAG_END,st.DRAG_ENTER,st.DRAG_OVER,st.DRAG_LEAVE,st.DROP,st.WHEEL].forEach(r=>{e.addEventListener(r,this.forwardCanvasEvents)})}destroy(){const t=this.context.canvas.getContainer();t&&[$o.KEY_DOWN,$o.KEY_UP].forEach(e=>{t.removeEventListener(e,this.forwardContainerEvents)}),this.context.canvas.document.removeAllEventListeners(),super.destroy()}}var Pu=function(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(e[r[i]]=n[r[i]]);return e};function ea(n,t){const{data:e,style:r}=n,i=Pu(n,["data","style"]),{data:a,style:o}=t,s=Pu(t,["data","style"]),u=Object.assign(Object.assign({},i),s);return(e||a)&&Object.assign(u,{data:Object.assign(Object.assign({},e),a)}),(r||o)&&Object.assign(u,{style:Object.assign(Object.assign({},r),o)}),u}function qy(n){const{data:t,style:e}=n,r=Pu(n,["data","style"]);return t&&(r.data=Object.assign({},t)),e&&(r.style=Object.assign({},e)),r}function Go(n={},t={}){const{states:e=[],data:r={},style:i={},children:a=[]}=n,o=Pu(n,["states","data","style","children"]),{states:s=[],data:u={},style:c={},children:l=[]}=t,d=Pu(t,["states","data","style","children"]),p=(m,y)=>m.length!==y.length?!1:m.every((v,x)=>v===y[x]),g=(m,y)=>{const v=Object.keys(m),x=Object.keys(y);return v.length!==x.length?!1:v.every(E=>m[E]===y[E])};return!(!g(o,d)||!p(a,l)||!p(e,s)||!g(r,u)||!g(i,c))}var cJ=function(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(e[r[i]]=n[r[i]]);return e};function Ky(n){const{id:t=Z(n),style:e,data:r}=n,i=cJ(n,["id","style","data"]),a=Object.assign(Object.assign({},n),{style:Object.assign({},e),data:Object.assign({},r)});return iU(n)?Object.assign({id:t,data:a},i):{id:t,data:a}}function cn(n){return n.data}function lJ(n){if(n.hasTreeStructure(Yr))return;n.attachTreeStructure(Yr);const t=n.getAllEdges();for(const e of t){const{source:r,target:i}=e;n.setParent(i,r,Yr)}}class hJ{constructor(){this.latestRemovedComboIds=new Set,this.comboIds=new Set,this.changes=[],this.batchCount=0,this.isTraceless=!1,this.enableUpdateNodeLikeHierarchy=!0,this.model=new qh}pushChange(t){if(this.isTraceless)return;const{type:e}=t;if(e===Se.NodeUpdated||e===Se.EdgeUpdated||e===Se.ComboUpdated){const{value:r,original:i}=t;this.changes.push({value:qy(r),original:qy(i),type:e})}else this.changes.push({value:qy(t.value),type:e})}getChanges(){return this.changes}clearChanges(){this.changes=[]}batch(t){this.batchCount++,this.model.batch(t),this.batchCount--}isBatching(){return this.batchCount>0}silence(t){this.isTraceless=!0,t(),this.isTraceless=!1}isCombo(t){return this.comboIds.has(t)||this.latestRemovedComboIds.has(t)}getData(){return{nodes:this.getNodeData(),edges:this.getEdgeData(),combos:this.getComboData()}}getNodeData(t){return this.model.getAllNodes().reduce((e,r)=>{const i=cn(r);return this.isCombo(Z(i))||(t===void 0||t.includes(Z(i)))&&e.push(i),e},[])}getEdgeDatum(t){return cn(this.model.getEdge(t))}getEdgeData(t){return this.model.getAllEdges().reduce((e,r)=>{const i=cn(r);return(t===void 0||t.includes(Z(i)))&&e.push(i),e},[])}getComboData(t){return this.model.getAllNodes().reduce((e,r)=>{const i=cn(r);return this.isCombo(Z(i))&&(t===void 0||t.includes(Z(i)))&&e.push(i),e},[])}getRootsData(t=Yr){return this.model.getRoots(t).map(cn)}getAncestorsData(t,e){const{model:r}=this;return!r.hasNode(t)||!r.hasTreeStructure(e)?[]:r.getAncestors(t,e).map(cn)}getDescendantsData(t){const e=this.getElementDataById(t),r=[];return Qo(e,i=>{i!==e&&r.push(i)},i=>this.getChildrenData(Z(i)),"TB"),r}getParentData(t,e){const{model:r}=this;if(!e){ka.warn("The hierarchy structure key is not specified");return}if(!r.hasNode(t)||!r.hasTreeStructure(e))return;const i=r.getParent(t,e);return i?cn(i):void 0}getChildrenData(t){const e=this.getElementType(t)==="node"?Yr:me,{model:r}=this;return!r.hasNode(t)||!r.hasTreeStructure(e)?[]:r.getChildren(t,e).map(cn)}getElementsDataByType(t){return t==="node"?this.getNodeData():t==="edge"?this.getEdgeData():t==="combo"?this.getComboData():[]}getElementDataById(t){return this.getElementType(t)==="edge"?this.getEdgeDatum(t):this.getNodeLikeDatum(t)}getNodeLikeDatum(t){const e=this.model.getNode(t);return cn(e)}getNodeLikeData(t){return this.model.getAllNodes().reduce((e,r)=>{const i=cn(r);return t?t.includes(Z(i))&&e.push(i):e.push(i),e},[])}getElementDataByState(t,e){return this.getElementsDataByType(t).filter(r=>{var i;return(i=r.states)===null||i===void 0?void 0:i.includes(e)})}getElementState(t){var e;return((e=this.getElementDataById(t))===null||e===void 0?void 0:e.states)||[]}hasNode(t){return this.model.hasNode(t)&&!this.isCombo(t)}hasEdge(t){return this.model.hasEdge(t)}hasCombo(t){return this.model.hasNode(t)&&this.isCombo(t)}getRelatedEdgesData(t,e="both"){return this.model.getRelatedEdges(t,e).map(cn)}getNeighborNodesData(t){return this.model.getNeighbors(t).map(cn)}setData(t){const{nodes:e=[],edges:r=[],combos:i=[]}=t,{nodes:a,edges:o,combos:s}=this.getData(),u=mu(a,e,d=>Z(d),Go),c=mu(o,r,d=>Z(d),Go),l=mu(s,i,d=>Z(d),Go);this.batch(()=>{const d={nodes:u.enter,edges:c.enter,combos:l.enter};this.addData(d),this.computeZIndex(d,"add",!0);const p={nodes:u.update,edges:c.update,combos:l.update};this.updateData(p),this.computeZIndex(p,"update",!0);const g={nodes:u.exit.map(Z),edges:c.exit.map(Z),combos:l.exit.map(Z)};this.removeData(g)})}addData(t){const{nodes:e,edges:r,combos:i}=t;this.batch(()=>{this.addComboData(i),this.addNodeData(e),this.addEdgeData(r)}),this.computeZIndex(t,"add")}addNodeData(t=[]){t.length&&(this.model.addNodes(t.map(e=>(this.pushChange({value:e,type:Se.NodeAdded}),Ky(e)))),this.updateNodeLikeHierarchy(t),this.computeZIndex({nodes:t},"add"))}addEdgeData(t=[]){t.length&&(this.model.addEdges(t.map(e=>(this.pushChange({value:e,type:Se.EdgeAdded}),Ky(e)))),this.computeZIndex({edges:t},"add"))}addComboData(t=[]){if(!t.length)return;const{model:e}=this;e.hasTreeStructure(me)||e.attachTreeStructure(me),e.addNodes(t.map(r=>(this.comboIds.add(Z(r)),this.pushChange({value:r,type:Se.ComboAdded}),Ky(r)))),this.updateNodeLikeHierarchy(t),this.computeZIndex({combos:t},"add")}addChildrenData(t,e){const r=this.getNodeLikeDatum(t),i=e.map(Z);this.addNodeData(e),this.updateNodeData([{id:t,children:[...r.children||[],...i]}]),this.addEdgeData(i.map(a=>({source:t,target:a})))}computeZIndex(t,e,r=!1){!r&&this.isBatching()||this.batch(()=>{const{nodes:i=[],edges:a=[],combos:o=[]}=t;o.forEach(s=>{var u,c,l;const d=Z(s);if(e==="add"&&Xt((u=s.style)===null||u===void 0?void 0:u.zIndex)||e==="update"&&!("combo"in s))return;const p=this.getParentData(d,me),g=p?((l=(c=p.style)===null||c===void 0?void 0:c.zIndex)!==null&&l!==void 0?l:0)+1:0;this.preventUpdateNodeLikeHierarchy(()=>{this.updateComboData([{id:d,style:{zIndex:g}}])})}),i.forEach(s=>{var u,c,l;const d=Z(s);if(e==="add"&&Xt((u=s.style)===null||u===void 0?void 0:u.zIndex)||e==="update"&&!("combo"in s)&&!("children"in s))return;let p=0;const g=this.getParentData(d,me);if(g)p=(((c=g.style)===null||c===void 0?void 0:c.zIndex)||0)+1;else{const m=this.getParentData(d,Yr);m&&(p=((l=m==null?void 0:m.style)===null||l===void 0?void 0:l.zIndex)||0)}this.preventUpdateNodeLikeHierarchy(()=>{this.updateNodeData([{id:d,style:{zIndex:p}}])})}),a.forEach(s=>{var u,c,l,d,p;if(Xt((u=s.style)===null||u===void 0?void 0:u.zIndex))return;let{id:g,source:m,target:y}=s;if(!g)g=Z(s);else{const E=this.getEdgeDatum(g);m=E.source,y=E.target}if(!m||!y)return;const v=((l=(c=this.getNodeLikeDatum(m))===null||c===void 0?void 0:c.style)===null||l===void 0?void 0:l.zIndex)||0,x=((p=(d=this.getNodeLikeDatum(y))===null||d===void 0?void 0:d.style)===null||p===void 0?void 0:p.zIndex)||0;this.updateEdgeData([{id:Z(s),style:{zIndex:Math.max(v,x)-1}}])})})}getFrontZIndex(t){var e;const r=this.getElementType(t),i=this.getElementDataById(t),a=this.getData();if(Object.assign(a,{[`${r}s`]:a[`${r}s`].filter(o=>Z(o)!==t)}),r==="combo"&&!ba(i)){const o=new Set(this.getAncestorsData(t,me).map(Z));a.nodes=a.nodes.filter(s=>!o.has(Z(s))),a.combos=a.combos.filter(s=>!o.has(Z(s))),a.edges=a.edges.filter(({source:s,target:u})=>!o.has(s)&&!o.has(u))}return Math.max(((e=i.style)===null||e===void 0?void 0:e.zIndex)||0,0,...Object.values(a).flat().map(o=>{var s;return(((s=o==null?void 0:o.style)===null||s===void 0?void 0:s.zIndex)||0)+1}))}updateNodeLikeHierarchy(t){if(!this.enableUpdateNodeLikeHierarchy)return;const{model:e}=this;t.forEach(r=>{const i=Z(r),a=fl(r);a!==void 0&&(e.hasTreeStructure(me)||e.attachTreeStructure(me),a===null&&this.refreshComboData(i),this.setParent(i,fl(r),me));const o=r.children||[];if(o.length){e.hasTreeStructure(Yr)||e.attachTreeStructure(Yr);const s=o.filter(u=>e.hasNode(u));s.forEach(u=>this.setParent(u,i,Yr)),s.length!==o.length&&this.updateNodeData([{id:i,children:s}])}})}preventUpdateNodeLikeHierarchy(t){this.enableUpdateNodeLikeHierarchy=!1,t(),this.enableUpdateNodeLikeHierarchy=!0}updateData(t){const{nodes:e,edges:r,combos:i}=t;this.batch(()=>{this.updateNodeData(e),this.updateComboData(i),this.updateEdgeData(r)}),this.computeZIndex(t,"update")}updateNodeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch(()=>{const r=[];t.forEach(i=>{const a=Z(i),o=cn(e.getNode(a));if(Go(o,i))return;const s=ea(o,i);this.pushChange({value:s,original:o,type:Se.NodeUpdated}),e.mergeNodeData(a,s),r.push(s)}),this.updateNodeLikeHierarchy(r)}),this.computeZIndex({nodes:t},"update")}refreshData(){const{nodes:t,edges:e,combos:r}=this.getData();t.forEach(i=>{this.pushChange({value:i,original:i,type:Se.NodeUpdated})}),e.forEach(i=>{this.pushChange({value:i,original:i,type:Se.EdgeUpdated})}),r.forEach(i=>{this.pushChange({value:i,original:i,type:Se.ComboUpdated})})}syncNodeLikeDatum(t){const{model:e}=this,r=Z(t);if(!e.hasNode(r))return;const i=cn(e.getNode(r)),a=ea(i,t);e.mergeNodeData(r,a)}syncEdgeDatum(t){const{model:e}=this,r=Z(t);if(!e.hasEdge(r))return;const i=cn(e.getEdge(r)),a=ea(i,t);e.mergeEdgeData(r,a)}updateEdgeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch(()=>{t.forEach(r=>{const i=Z(r),a=cn(e.getEdge(i));if(Go(a,r))return;r.source&&a.source!==r.source&&e.updateEdgeSource(i,r.source),r.target&&a.target!==r.target&&e.updateEdgeTarget(i,r.target);const o=ea(a,r);this.pushChange({value:o,original:a,type:Se.EdgeUpdated}),e.mergeEdgeData(i,o)})}),this.computeZIndex({edges:t},"update")}updateComboData(t=[]){if(!t.length)return;const{model:e}=this;e.batch(()=>{const r=[];t.forEach(i=>{const a=Z(i),o=cn(e.getNode(a));if(Go(o,i))return;const s=ea(o,i);this.pushChange({value:s,original:o,type:Se.ComboUpdated}),e.mergeNodeData(a,s),r.push(s)}),this.updateNodeLikeHierarchy(r)}),this.computeZIndex({combos:t},"update")}setParent(t,e,r,i=!0){if(t===e)return;const a=this.getNodeLikeDatum(t),o=fl(a);if(o!==e&&r===me){const s={id:t,combo:e};this.isCombo(t)?this.syncNodeLikeDatum(s):this.syncNodeLikeDatum(s)}this.model.setParent(t,e,r),i&&r===me&&EB([o,e]).forEach(s=>{s!==void 0&&this.refreshComboData(s)})}refreshComboData(t){const e=this.getComboData([t])[0],r=this.getAncestorsData(t,me);e&&this.pushChange({value:e,original:e,type:Se.ComboUpdated}),r.forEach(i=>{this.pushChange({value:i,original:i,type:Se.ComboUpdated})})}getElementPosition(t){const e=this.getElementDataById(t);return _r(e)}translateNodeLikeBy(t,e){this.isCombo(t)?this.translateComboBy(t,e):this.translateNodeBy(t,e)}translateNodeLikeTo(t,e){this.isCombo(t)?this.translateComboTo(t,e):this.translateNodeTo(t,e)}translateNodeBy(t,e){const r=this.getElementPosition(t),i=rn(r,[...e,0].slice(0,3));this.translateNodeTo(t,i)}translateNodeTo(t,e){const[r=0,i=0,a=0]=e;this.preventUpdateNodeLikeHierarchy(()=>{this.updateNodeData([{id:t,style:{x:r,y:i,z:a}}])})}translateComboBy(t,e){const[r=0,i=0,a=0]=e;if([r,i,a].some(isNaN)||[r,i,a].every(u=>u===0))return;const o=this.getComboData([t])[0];if(!o)return;const s=new Set;Qo(o,u=>{const c=Z(u);if(s.has(c))return;s.add(c);const[l,d,p]=_r(u),g=ea(u,{style:{x:l+r,y:d+i,z:p+a}});this.pushChange({value:g,original:u,type:this.isCombo(c)?Se.ComboUpdated:Se.NodeUpdated}),this.model.mergeNodeData(c,g)},u=>this.getChildrenData(Z(u)),"BT")}translateComboTo(t,e){var r;if(e.some(isNaN))return;const[i=0,a=0,o=0]=e,s=(r=this.getComboData([t]))===null||r===void 0?void 0:r[0];if(!s)return;const[u,c,l]=_r(s),d=i-u,p=a-c,g=o-l;Qo(s,m=>{const y=Z(m),[v,x,E]=_r(m),w=ea(m,{style:{x:v+d,y:x+p,z:E+g}});this.pushChange({value:w,original:m,type:this.isCombo(y)?Se.ComboUpdated:Se.NodeUpdated}),this.model.mergeNodeData(y,w)},m=>this.getChildrenData(Z(m)),"BT")}removeData(t){const{nodes:e,edges:r,combos:i}=t;this.batch(()=>{this.removeEdgeData(r),this.removeNodeData(e),this.removeComboData(i),this.latestRemovedComboIds=new Set(i)})}removeNodeData(t=[]){t.length&&this.batch(()=>{t.forEach(e=>{this.removeEdgeData(this.getRelatedEdgesData(e).map(Z)),this.pushChange({value:this.getNodeData([e])[0],type:Se.NodeRemoved}),this.removeNodeLikeHierarchy(e)}),this.model.removeNodes(t)})}removeEdgeData(t=[]){t.length&&(t.forEach(e=>this.pushChange({value:this.getEdgeData([e])[0],type:Se.EdgeRemoved})),this.model.removeEdges(t))}removeComboData(t=[]){t.length&&this.batch(()=>{t.forEach(e=>{this.pushChange({value:this.getComboData([e])[0],type:Se.ComboRemoved}),this.removeNodeLikeHierarchy(e),this.comboIds.delete(e)}),this.model.removeNodes(t)})}removeNodeLikeHierarchy(t){if(this.model.hasTreeStructure(me)){const e=fl(this.getNodeLikeDatum(t));this.setParent(t,void 0,me,!1),this.model.getChildren(t,me).forEach(r=>{const i=cn(r),a=Z(i);this.setParent(Z(i),e,me,!1);const o=ea(i,{id:Z(i),combo:e});this.pushChange({value:o,original:i,type:this.isCombo(a)?Se.ComboUpdated:Se.NodeUpdated}),this.model.mergeNodeData(Z(i),o)}),Tt(e)||this.refreshComboData(e)}}getElementType(t){if(this.model.hasNode(t))return this.isCombo(t)?"combo":"node";if(this.model.hasEdge(t))return"edge";throw new Error(Li(`Unknown element type of id: ${t}`))}destroy(){const{model:t}=this,e=t.getAllNodes(),r=t.getAllEdges();t.removeEdges(r.map(i=>i.id)),t.removeNodes(e.map(i=>i.id)),this.context={}}}var ru=function(n,t,e,r){function i(a){return a instanceof e?a:new e(function(o){o(a)})}return new(e||(e=Promise))(function(a,o){function s(l){try{c(r.next(l))}catch(d){o(d)}}function u(l){try{c(r.throw(l))}catch(d){o(d)}}function c(l){l.done?a(l.value):i(l.value).then(s,u)}c((r=r.apply(n,t||[])).next())})};class dJ{constructor(t){this.elementMap={},this.shapeTypeMap={},this.paletteStyle={},this.defaultStyle={},this.stateStyle={},this.visibilityCache=new WeakMap,this.context=t}init(){this.initContainer()}initContainer(){if(!this.container||this.container.destroyed){const{canvas:t}=this.context;this.container=t.appendChild(new vi({className:"elements"}))}}emit(t,e){e.silence||an(this.context.graph,t)}forEachElementData(t){so.forEach(e=>{const r=this.context.model.getElementsDataByType(e);t(e,r)})}getElementType(t,e){var r;const{options:i,graph:a}=this.context,o=((r=i[t])===null||r===void 0?void 0:r.type)||e.type;return o?typeof o=="string"?o:o.call(a,e):t==="edge"?"line":"circle"}getTheme(t){return j_(this.context.options)[t]||{}}getThemeStyle(t){return this.getTheme(t).style||{}}getThemeStateStyle(t,e){const{state:r={}}=this.getTheme(t);return Object.assign({},...e.map(i=>r[i]||{}))}computePaletteStyle(){const{options:t}=this.context;this.paletteStyle={},this.forEachElementData((e,r)=>{var i,a;const o=Object.assign({},ok((i=this.getTheme(e))===null||i===void 0?void 0:i.palette),ok((a=t[e])===null||a===void 0?void 0:a.palette));o!=null&&o.field&&Object.assign(this.paletteStyle,HU(r,o))})}getPaletteStyle(t,e){const r=this.paletteStyle[e];return r?t==="edge"?{stroke:r}:{fill:r}:{}}computeElementDefaultStyle(t,e){var r;const{options:i}=this.context,a=((r=i[t])===null||r===void 0?void 0:r.style)||{};"transform"in a&&Array.isArray(a.transform)&&(a.transform=[...a.transform]),this.defaultStyle[Z(e.datum)]=ak(a,e)}computeElementsDefaultStyle(t){const{graph:e}=this.context;this.forEachElementData((r,i)=>{const a=i.length;for(let o=0;o<a;o++){const s=i[o];(t===void 0||t.includes(Z(s)))&&this.computeElementDefaultStyle(r,{datum:s,graph:e})}})}getDefaultStyle(t){return this.defaultStyle[t]||{}}getElementState(t){try{const{model:e}=this.context;return e.getElementState(t)}catch{return[]}}getElementStateStyle(t,e,r){var i,a;const{options:o}=this.context,s=((a=(i=o[t])===null||i===void 0?void 0:i.state)===null||a===void 0?void 0:a[e])||{};return ak(s,r)}computeElementStatesStyle(t,e,r){this.stateStyle[Z(r.datum)]=Object.assign({},...e.map(i=>this.getElementStateStyle(t,i,r)))}computeElementsStatesStyle(t){const{graph:e}=this.context;this.forEachElementData((r,i)=>{const a=i.length;for(let o=0;o<a;o++){const s=i[o];if(t===void 0||t.includes(Z(s))){const u=this.getElementState(Z(s));this.computeElementStatesStyle(r,u,{datum:s,graph:e})}}})}getStateStyle(t){return this.stateStyle[t]||{}}computeStyle(t,e){t&&["translate","zIndex"].includes(t)||(this.computePaletteStyle(),this.computeElementsDefaultStyle(e),this.computeElementsStatesStyle(e))}getElement(t){return this.elementMap[t]}getNodes(){return this.context.model.getNodeData().map(({id:t})=>this.elementMap[t])}getEdges(){return this.context.model.getEdgeData().map(t=>this.elementMap[Z(t)])}getCombos(){return this.context.model.getComboData().map(({id:t})=>this.elementMap[t])}getElementComputedStyle(t,e){const r=Z(e),i=this.getThemeStyle(t),a=this.getPaletteStyle(t,r),o=e.style||{},s=this.getDefaultStyle(r),u=this.getThemeStateStyle(t,this.getElementState(r)),c=this.getStateStyle(r),l=Object.assign({},i,a,o,s,u,c);if(t==="combo"){const d=this.context.model.getChildrenData(r),p=l.collapsed?[]:d.map(Z).filter(g=>this.getElement(g));Object.assign(l,{childrenNode:p,childrenData:d})}return l}getDrawData(t){this.init();const e=this.computeChangesAndDrawData(t);if(!e)return null;const{type:r="draw",stage:i=r}=t;return this.markDestroyElement(e.drawData),this.computeStyle(i),{type:r,stage:i,data:e}}draw(t={animation:!0}){const e=this.getDrawData(t);if(!e)return;const{data:{drawData:{add:r,update:i,remove:a}}}=e;return this.destroyElements(a,t),this.createElements(r,t),this.updateElements(i,t),this.setAnimationTask(t,e)}preLayoutDraw(){return ru(this,arguments,void 0,function*(t={animation:!0}){var e,r;const i=this.getDrawData(t);if(!i)return;const{data:{drawData:a}}=i;yield(r=(e=this.context.layout)===null||e===void 0?void 0:e.preLayout)===null||r===void 0?void 0:r.call(e,a);const{add:o,update:s,remove:u}=a;return this.destroyElements(u,t),this.createElements(o,t),this.updateElements(s,t),this.setAnimationTask(t,i)})}setAnimationTask(t,e){const{animation:r,silence:i}=t,{data:{dataChanges:a,drawData:o},stage:s,type:u}=e;return this.context.animation.animate(r,i?{}:{before:()=>this.emit(new Xe(gt.BEFORE_DRAW,{dataChanges:a,animation:r,stage:s,render:u==="render"}),t),beforeAnimate:c=>this.emit(new Tr(gt.BEFORE_ANIMATE,$n.DRAW,c,o),t),afterAnimate:c=>this.emit(new Tr(gt.AFTER_ANIMATE,$n.DRAW,c,o),t),after:()=>this.emit(new Xe(gt.AFTER_DRAW,{dataChanges:a,animation:r,stage:s,render:u==="render",firstRender:this.context.graph.rendered===!1}),t)})}computeChangesAndDrawData(t){const{model:e}=this.context,r=e.getChanges(),i=UP(r);if(i.length===0)return null;const{NodeAdded:a=[],NodeUpdated:o=[],NodeRemoved:s=[],EdgeAdded:u=[],EdgeUpdated:c=[],EdgeRemoved:l=[],ComboAdded:d=[],ComboUpdated:p=[],ComboRemoved:g=[]}=Mh(i,x=>x.type),m=x=>new Map(x.map(E=>{const w=E.value;return[Z(w),w]})),y={add:{nodes:m(a),edges:m(u),combos:m(d)},update:{nodes:m(o),edges:m(c),combos:m(p)},remove:{nodes:m(s),edges:m(l),combos:m(g)}},v=this.transformData(y,t);return e.clearChanges(),{dataChanges:r,drawData:v}}transformData(t,e){const r=this.context.transform.getTransformInstance();return Object.values(r).reduce((i,a)=>a.beforeDraw(i,e),t)}createElement(t,e,r){var i;const a=Z(e);if(this.getElement(a))return;const o=this.getElementType(t,e),s=this.getElementComputedStyle(t,e),u=ji(t,o);if(!u)return ka.warn(`The element ${o} of ${t} is not registered.`);this.emit(new Fo(gt.BEFORE_ELEMENT_CREATE,t,e),r);const c=this.container.appendChild(new u({id:a,context:this.context,style:s}));this.shapeTypeMap[a]=o,this.elementMap[a]=c;const{stage:l="enter"}=r;(i=this.context.animation)===null||i===void 0||i.add({element:c,elementType:t,stage:l,originalStyle:Object.assign({},c.attributes),updatedStyle:s},{after:()=>{var d;this.emit(new Fo(gt.AFTER_ELEMENT_CREATE,t,e),r),(d=c.onCreate)===null||d===void 0||d.call(c)}})}createElements(t,e){const{nodes:r,edges:i,combos:a}=t;[["node",r],["combo",a],["edge",i]].forEach(([o,s])=>{s.forEach(u=>this.createElement(o,u,e))})}getUpdateStageStyle(t,e,r){const{stage:i="update"}=r;if(i==="translate")if(t==="node"||t==="combo"){const{style:{x:a=0,y:o=0,z:s=0}={}}=e;return{x:a,y:o,z:s}}else return{};return this.getElementComputedStyle(t,e)}updateElement(t,e,r){var i;const a=Z(e),{stage:o="update"}=r,s=this.getElement(a);if(!s)return()=>null;this.emit(new Fo(gt.BEFORE_ELEMENT_UPDATE,t,e),r);const u=this.getElementType(t,e),c=this.getUpdateStageStyle(t,e,r);this.shapeTypeMap[a]!==u&&(s.destroy(),delete this.shapeTypeMap[a],delete this.elementMap[a],this.createElement(t,e,{animation:!1,silence:!0}));const l=o!=="visibility"?o:c.visibility==="hidden"?"hide":"show";l==="hide"&&delete c.visibility,(i=this.context.animation)===null||i===void 0||i.add({element:s,elementType:t,stage:l,originalStyle:Object.assign({},s.attributes),updatedStyle:c},{before:()=>{const d=this.elementMap[a];o!=="collapse"&&H1(d,c),o==="visibility"&&(aJ(d,"opacity")||iJ(d,"opacity"),this.visibilityCache.set(d,l==="show"?"visible":"hidden"),l==="show"&&oo(d,"visible"))},after:()=>{var d;const p=this.elementMap[a];o==="collapse"&&H1(p,c),l==="hide"&&oo(p,this.visibilityCache.get(p)),this.emit(new Fo(gt.AFTER_ELEMENT_UPDATE,t,e),r),(d=p.onUpdate)===null||d===void 0||d.call(p)}})}updateElements(t,e){const{nodes:r,edges:i,combos:a}=t;[["node",r],["combo",a],["edge",i]].forEach(([o,s])=>{s.forEach(u=>this.updateElement(o,u,e))})}markDestroyElement(t){Object.values(t.remove).forEach(e=>{e.forEach(r=>{const i=Z(r),a=this.getElement(i);a&&CY(a)})})}destroyElement(t,e,r){var i;const{stage:a="exit"}=r,o=Z(e),s=this.elementMap[o];if(!s)return()=>null;this.emit(new Fo(gt.BEFORE_ELEMENT_DESTROY,t,e),r),(i=this.context.animation)===null||i===void 0||i.add({element:s,elementType:t,stage:a,originalStyle:Object.assign({},s.attributes),updatedStyle:{}},{after:()=>{var u;this.clearElement(o),s.destroy(),(u=s.onDestroy)===null||u===void 0||u.call(s),this.emit(new Fo(gt.AFTER_ELEMENT_DESTROY,t,e),r)}})}destroyElements(t,e){const{nodes:r,edges:i,combos:a}=t;[["combo",a],["edge",i],["node",r]].forEach(([o,s])=>{s.forEach(u=>this.destroyElement(o,u,e))})}clearElement(t){delete this.paletteStyle[t],delete this.defaultStyle[t],delete this.stateStyle[t],delete this.elementMap[t],delete this.shapeTypeMap[t]}alignLayoutResultToElement(t,e){var r,i;const a=(r=t.nodes)===null||r===void 0?void 0:r.find(o=>Z(o)===e);if(a){const o=_r(this.context.model.getNodeLikeDatum(e)),s=_r(a),u=Mn(o,s);(i=t.nodes)===null||i===void 0||i.forEach(c=>{var l,d,p;!((l=c.style)===null||l===void 0)&&l.x&&(c.style.x+=u[0]),!((d=c.style)===null||d===void 0)&&d.y&&(c.style.y+=u[1]),!((p=c.style)===null||p===void 0)&&p.z&&(c.style.z+=u[2]||0)})}}collapseNode(t,e){return ru(this,void 0,void 0,function*(){var r;const{animation:i}=e,a=this.computeChangesAndDrawData({stage:"collapse",animation:i});if(!a)return;const{drawData:o}=a,{add:s,remove:u,update:c}=o;this.markDestroyElement(o);const l={animation:i,stage:"collapse",data:o};this.destroyElements(u,l),this.createElements(s,l),this.updateElements(c,l),yield(r=this.context.animation.animate(i,{beforeAnimate:d=>this.emit(new Tr(gt.BEFORE_ANIMATE,$n.COLLAPSE,d,o),l),afterAnimate:d=>this.emit(new Tr(gt.AFTER_ANIMATE,$n.COLLAPSE,d,o),l)},{collapse:{target:t,descendants:Array.from(u.nodes).map(([,d])=>Z(d)),position:_r(c.nodes.get(t))}}))===null||r===void 0?void 0:r.finished})}expandNode(t,e){return ru(this,void 0,void 0,function*(){var r;const{model:i}=this.context,{animation:a}=e,o=_r(i.getNodeData([t])[0]),s=this.computeChangesAndDrawData({stage:"expand",animation:a});if(this.createElements(s.drawData.add,{animation:!1,stage:"expand",target:t}),this.context.animation.clear(),this.computeStyle("expand"),!s)return;const{drawData:u}=s,{update:c,add:l}=u,d={animation:a,stage:"expand",data:u};l.edges.forEach(p=>c.edges.set(Z(p),p)),l.nodes.forEach(p=>c.nodes.set(Z(p),p)),this.updateElements(c,d),yield(r=this.context.animation.animate(a,{beforeAnimate:p=>this.emit(new Tr(gt.BEFORE_ANIMATE,$n.EXPAND,p,u),d),afterAnimate:p=>this.emit(new Tr(gt.AFTER_ANIMATE,$n.EXPAND,p,u),d)},{expand:{target:t,descendants:Array.from(l.nodes).map(([,p])=>Z(p)),position:o}}))===null||r===void 0?void 0:r.finished})}collapseCombo(t,e){return ru(this,void 0,void 0,function*(){var r;const{model:i,element:a}=this.context;if(i.getAncestorsData(t,me).some(y=>ba(y)))return;const o=a.getElement(t),s=o.getComboPosition(Object.assign(Object.assign({},o.attributes),{collapsed:!0})),u=this.computeChangesAndDrawData({stage:"collapse",animation:e});if(!u)return;const{dataChanges:c,drawData:l}=u;this.markDestroyElement(l);const{update:d,remove:p}=l,g={animation:e,stage:"collapse",data:l};this.destroyElements(p,g),this.updateElements(d,g);const m=y=>Array.from(y).map(([,v])=>Z(v));yield(r=this.context.animation.animate(e,{before:()=>this.emit(new Xe(gt.BEFORE_DRAW,{dataChanges:c,animation:e}),g),beforeAnimate:y=>this.emit(new Tr(gt.BEFORE_ANIMATE,$n.COLLAPSE,y,l),g),afterAnimate:y=>this.emit(new Tr(gt.AFTER_ANIMATE,$n.COLLAPSE,y,l),g),after:()=>this.emit(new Xe(gt.AFTER_DRAW,{dataChanges:c,animation:e}),g)},{collapse:{target:t,descendants:[...m(p.nodes),...m(p.combos)],position:s}}))===null||r===void 0?void 0:r.finished})}expandCombo(t,e){return ru(this,void 0,void 0,function*(){var r;const{model:i}=this.context,a=_r(i.getComboData([t])[0]);this.computeStyle("expand");const o=this.computeChangesAndDrawData({stage:"expand",animation:e});if(!o)return;const{dataChanges:s,drawData:u}=o,{add:c,update:l}=u,d={animation:e,stage:"expand",data:u,target:t};this.createElements(c,d),this.updateElements(l,d);const p=g=>Array.from(g).map(([,m])=>Z(m));yield(r=this.context.animation.animate(e,{before:()=>this.emit(new Xe(gt.BEFORE_DRAW,{dataChanges:s,animation:e}),d),beforeAnimate:g=>this.emit(new Tr(gt.BEFORE_ANIMATE,$n.EXPAND,g,u),d),afterAnimate:g=>this.emit(new Tr(gt.AFTER_ANIMATE,$n.EXPAND,g,u),d),after:()=>this.emit(new Xe(gt.AFTER_DRAW,{dataChanges:s,animation:e}),d)},{expand:{target:t,descendants:[...p(c.nodes),...p(c.combos)],position:a}}))===null||r===void 0?void 0:r.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 Vo=function(n,t,e,r){function i(a){return a instanceof e?a:new e(function(o){o(a)})}return new(e||(e=Promise))(function(a,o){function s(l){try{c(r.next(l))}catch(d){o(d)}}function u(l){try{c(r.throw(l))}catch(d){o(d)}}function c(l){l.done?a(l.value):i(l.value).then(s,u)}c((r=r.apply(n,t||[])).next())})},fJ=function(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(e[r[i]]=n[r[i]]);return e};class pJ{get presetOptions(){return{animation:!!B_(this.context.options,!0)}}get options(){const{options:t}=this.context;return t.layout}constructor(t){this.instances=[],this.context=t}getLayoutInstance(){return this.instances}preLayout(t){return Vo(this,void 0,void 0,function*(){var e,r,i,a;const{graph:o,model:s}=this.context,{add:u}=t;an(o,new Xe(gt.BEFORE_LAYOUT,{type:"pre"}));const c=yield(e=this.context.layout)===null||e===void 0?void 0:e.simulate();(r=c==null?void 0:c.nodes)===null||r===void 0||r.forEach(l=>{const d=Z(l),p=u.nodes.get(d);s.syncNodeLikeDatum(l),p&&Object.assign(p.style,l.style)}),(i=c==null?void 0:c.edges)===null||i===void 0||i.forEach(l=>{const d=Z(l),p=u.edges.get(d);s.syncEdgeDatum(l),p&&Object.assign(p.style,l.style)}),(a=c==null?void 0:c.combos)===null||a===void 0||a.forEach(l=>{const d=Z(l),p=u.combos.get(d);s.syncNodeLikeDatum(l),p&&Object.assign(p.style,l.style)}),an(o,new Xe(gt.AFTER_LAYOUT,{type:"pre"})),this.transformDataAfterLayout("pre",t)})}postLayout(){return Vo(this,arguments,void 0,function*(t=this.options){if(!t)return;const e=Array.isArray(t)?t:[t],{graph:r}=this.context;an(r,new Xe(gt.BEFORE_LAYOUT,{type:"post"}));for(let i=0;i<e.length;i++){const a=e[i],o=this.getLayoutData(a),s=Object.assign(Object.assign({},this.presetOptions),a);an(r,new Xe(gt.BEFORE_STAGE_LAYOUT,{options:s,index:i}));const u=yield this.stepLayout(o,s,i);an(r,new Xe(gt.AFTER_STAGE_LAYOUT,{options:s,index:i})),a.animation||this.updateElementPosition(u,!1)}an(r,new Xe(gt.AFTER_LAYOUT,{type:"post"})),this.transformDataAfterLayout("post")})}transformDataAfterLayout(t,e){const r=this.context.transform.getTransformInstance();Object.values(r).forEach(i=>i.afterLayout(t,e))}simulate(){return Vo(this,void 0,void 0,function*(){if(!this.options)return{};const t=Array.isArray(this.options)?this.options:[this.options];let e={};for(let r=0;r<t.length;r++){const i=t[r],a=this.getLayoutData(i);e=yield this.stepLayout(a,Object.assign(Object.assign(Object.assign({},this.presetOptions),i),{animation:!1}),r)}return e})}stepLayout(t,e,r){return Vo(this,void 0,void 0,function*(){return PY(e)?yield this.treeLayout(t,e,r):yield this.graphLayout(t,e,r)})}graphLayout(t,e,r){return Vo(this,void 0,void 0,function*(){const{animation:i,enableWorker:a,iterations:o=300}=e,s=this.initGraphLayout(e);if(!s)return{};if(this.instances[r]=s,this.instance=s,a){const c=s;return this.supervisor=new NK(c.graphData2LayoutModel(t),c.instance,{iterations:o}),Rl(yield this.supervisor.execute())}if(Pk(s))return i?yield s.execute(t,{onTick:c=>{this.updateElementPosition(c,!1)}}):(s.execute(t),s.stop(),s.tick(o));const u=yield s.execute(t);if(i){const c=this.updateElementPosition(u,i);yield c==null?void 0:c.finished}return u})}treeLayout(t,e,r){return Vo(this,void 0,void 0,function*(){const{type:i,animation:a}=e,o=ji("layout",i);if(!o)return{};const{nodes:s=[],edges:u=[]}=t,c=new qh({nodes:s.map(g=>({id:Z(g),data:g.data||{}})),edges:u.map(g=>({id:Z(g),source:g.source,target:g.target,data:g.data||{}}))});lJ(c);const l={nodes:[],edges:[]},d={nodes:[],edges:[]};c.getRoots(Yr).forEach(g=>{Qo(g,E=>{E.children=c.getSuccessors(E.id)},E=>c.getSuccessors(E.id),"TB");const m=o(g,e),{x:y,y:v,z:x=0}=m;Qo(m,E=>{const{id:w,x:S,y:k,z:A=0}=E;l.nodes.push({id:w,style:{x:y,y:v,z:x}}),d.nodes.push({id:w,style:{x:S,y:k,z:A}})},E=>E.children,"TB")});const p=this.inferTreeLayoutOffset(d);if(RT(d,p),a){RT(l,p),this.updateElementPosition(l,!1);const g=this.updateElementPosition(d,a);yield g==null?void 0:g.finished}return d})}inferTreeLayoutOffset(t){var e;let[r,i]=[1/0,-1/0],[a,o]=[1/0,-1/0];(e=t.nodes)===null||e===void 0||e.forEach(y=>{const{x:v=0,y:x=0}=y.style||{};r=Math.min(r,v),i=Math.max(i,v),a=Math.min(a,x),o=Math.max(o,x)});const{canvas:s}=this.context,u=s.getSize(),[c,l]=s.getCanvasByViewport([0,0]),[d,p]=s.getCanvasByViewport(u);if(r>=c&&i<=d&&a>=l&&o<=p)return[0,0];const g=(c+d)/2,m=(l+p)/2;return[g-(r+i)/2,m-(a+o)/2]}stopLayout(){this.instance&&Pk(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(t){const{nodeFilter:e=()=>!0,comboFilter:r=()=>!0,preLayout:i=!1,isLayoutInvisibleNodes:a=!1}=t,{nodes:o,edges:s,combos:u}=this.context.model.getData(),{element:c,model:l}=this.context,d=x=>c.getElement(x),p=i?x=>{var E;return!a&&(((E=x.style)===null||E===void 0?void 0:E.visibility)==="hidden"||l.getAncestorsData(x.id,Yr).some(ba)||l.getAncestorsData(x.id,me).some(ba))?!1:e(x)}:x=>{const E=Z(x),w=d(E);return!w||Uu(w)?!1:e(x)},g=o.filter(p),m=u.filter(r),y=new Map(g.map(x=>[Z(x),x]));m.forEach(x=>y.set(Z(x),x));const v=s.filter(({source:x,target:E})=>y.has(x)&&y.has(E));return{nodes:g,edges:v,combos:m}}initGraphLayout(t){var e;const{element:r,viewport:i}=this.context,{type:a}=t,o=fJ(t,["type","enableWorker","animation","iterations"]),[s,u]=i.getCanvasSize(),c=[s/2,u/2],l=(e=t==null?void 0:t.nodeSize)!==null&&e!==void 0?e:(y=>{const v=r==null?void 0:r.getElement(y.id);return v?v.attributes.size:r==null?void 0:r.getElementComputedStyle("node",y).size}),d=ji("layout",a);if(!d)return ka.warn(`The layout of ${a} is not registered.`);const p=Object.getPrototypeOf(d.prototype)===AO.prototype?d:DY(d,this.context),g=new p(this.context),m={nodeSize:l,width:s,height:u,center:c};switch(g.id){case"d3-force":case"d3-force-3d":Object.assign(m,{center:{x:s/2,y:u/2,z:0}});break}return ma(g.options,m,o),g}updateElementPosition(t,e){const{model:r,element:i}=this.context;return i?(r.updateData(t),i.draw({animation:e,silence:!0})):null}destroy(){var t;this.stopLayout(),this.context={},(t=this.supervisor)===null||t===void 0||t.kill(),this.supervisor=void 0,this.instance=void 0,this.instances=[],this.animationResult=void 0}}const RT=(n,t)=>{var e;const[r,i]=t;(e=n.nodes)===null||e===void 0||e.forEach(a=>{if(a.style){const{x:o=0,y:s=0}=a.style;a.style.x=o+r,a.style.y=s+i}else a.style={x:r,y:i}})};function gJ(n){return[vJ].reduce((t,e)=>e(t),n)}function vJ(n){return!n.layout||Array.isArray(n.layout)||"preLayout"in n.layout||["antv-dagre","combo-combined","compact-box","circular","concentric","dagre","fishbone","grid","indented","mds","radial","random","snake","dendrogram","mindmap"].includes(n.layout.type)&&(n.layout.preLayout=!0),n}class mJ extends Db{constructor(t){super(t),this.category="plugin",this.setPlugins(this.context.options.plugins||[])}setPlugins(t){this.setExtensions(t)}getPluginInstance(t){const e=this.extensionMap[t];if(e)return e;ka.warn(`Cannot find the plugin ${t}, will try to find it by type.`);const r=this.extensions.find(i=>i.type===t);if(r)return this.extensionMap[r.key]}}const Al=["update-related-edges","collapse-expand-node","collapse-expand-combo","get-edge-actual-ends","arrange-draw-order"];class yJ extends Db{constructor(t){super(t),this.category="transform",this.setTransforms(this.context.options.transforms||[])}getTransforms(){}setTransforms(t){this.setExtensions([...Al.slice(0,Al.length-1),...t,Al[Al.length-1]])}getTransformInstance(t){return t?this.extensionMap[t]:this.extensionMap}}var iu=function(n,t,e,r){function i(a){return a instanceof e?a:new e(function(o){o(a)})}return new(e||(e=Promise))(function(a,o){function s(l){try{c(r.next(l))}catch(d){o(d)}}function u(l){try{c(r.throw(l))}catch(d){o(d)}}function c(l){l.done?a(l.value):i(l.value).then(s,u)}c((r=r.apply(n,t||[])).next())})};class bJ{get padding(){return zi(this.context.options.padding)}get paddingOffset(){const[t,e,r,i]=this.padding,[a,o,s]=[(i-e)/2,(t-r)/2,0];return[a,o,s]}constructor(t){this.landmarkCounter=0,this.context=t;const[e,r]=this.paddingOffset,{zoom:i,rotation:a,x:o=e,y:s=r}=t.options;this.transform({mode:"absolute",scale:i,translate:[o,s],rotate:a},!1)}get camera(){const{canvas:t}=this.context;return new Proxy(t.getCamera(),{get:(e,r)=>{const i=Object.entries(t.getLayers()).filter(([o])=>!["main"].includes(o)).map(([,o])=>o.getCamera()),a=e[r];if(typeof a=="function")return(...o)=>{const s=a.apply(e,o);return i.forEach(u=>{u[r].apply(u,o)}),s}}})}createLandmark(t){return this.camera.createLandmark(`landmark-${this.landmarkCounter++}`,t)}getAnimation(t){const e=B_(this.context.options,t);return e?wu(Object.assign({},e),["easing","duration"]):!1}getCanvasSize(){const{canvas:t}=this.context,{width:e=0,height:r=0}=t.getConfig();return[e,r]}getCanvasCenter(){const{canvas:t}=this.context,{width:e=0,height:r=0}=t.getConfig();return[e/2,r/2,0]}getViewportCenter(){const[t,e]=this.camera.getPosition();return[t,e,0]}getGraphCenter(){return this.context.graph.getViewportByCanvas(this.getCanvasCenter())}getZoom(){return this.camera.getZoom()}getRotation(){return this.camera.getRoll()}getTranslateOptions(t){const{camera:e}=this,{mode:r,translate:i=[]}=t,a=this.getZoom(),o=e.getPosition(),s=e.getFocalPoint(),[u,c]=this.getCanvasCenter(),[l=0,d=0,p=0]=i,g=sh([-l,-d,-p],a);return r==="relative"?{position:rn(o,g),focalPoint:rn(s,g)}:{position:rn([u,c,o[2]],g),focalPoint:rn([u,c,s[2]],g)}}getRotateOptions(t){const{mode:e,rotate:r=0}=t;return{roll:e==="relative"?this.camera.getRoll()+r:r}}getZoomOptions(t){const{zoomRange:e}=this.context.options,r=this.camera.getZoom(),{mode:i,scale:a=1}=t;return dn(i==="relative"?r*a:a,...e)}transform(t,e){return iu(this,void 0,void 0,function*(){const{graph:r}=this.context,{translate:i,rotate:a,scale:o,origin:s}=t;this.cancelAnimation();const u=this.getAnimation(e);if(an(r,new kl(gt.BEFORE_TRANSFORM,t)),!a&&o&&!i&&s&&!u){this.camera.setZoomByViewportPoint(this.getZoomOptions(t),s),an(r,new kl(gt.AFTER_TRANSFORM,t));return}const c={};if(i&&Object.assign(c,this.getTranslateOptions(t)),Xt(a)&&Object.assign(c,this.getRotateOptions(t)),Xt(o)&&Object.assign(c,{zoom:this.getZoomOptions(t)}),u)return an(r,new Tr(gt.BEFORE_ANIMATE,$n.TRANSFORM,null,t)),new Promise(l=>{this.transformResolver=l,this.camera.gotoLandmark(this.createLandmark(c),Object.assign(Object.assign({},u),{onfinish:()=>{an(r,new Tr(gt.AFTER_ANIMATE,$n.TRANSFORM,null,t)),an(r,new kl(gt.AFTER_TRANSFORM,t)),this.transformResolver=void 0,l()}}))});this.camera.gotoLandmark(this.createLandmark(c),{duration:0}),an(r,new kl(gt.AFTER_TRANSFORM,t))})}fitView(t,e){return iu(this,void 0,void 0,function*(){const[r,i,a,o]=this.padding,{when:s="always",direction:u="both"}=t||{},[c,l]=this.context.canvas.getSize(),d=c-o-i,p=l-r-a,g=this.context.canvas.getBounds(),m=this.getBBoxInViewport(g),[y,v]=zu(m),x=u==="x"&&y>=d||u==="y"&&v>=p||u==="both"&&y>=d&&v>=p;if(s==="overflow"&&!x)return yield this.fitCenter({animation:e});const E=d/y,w=p/v,S=u==="x"?E:u==="y"?w:Math.min(E,w),k=this.getAnimation(e);Number.isFinite(S)&&(yield this.transform({mode:"relative",scale:S,translate:rn(Mn(this.getCanvasCenter(),this.getBBoxInViewport(g).center),sh(this.paddingOffset,S))},k))})}fitCenter(t){return iu(this,void 0,void 0,function*(){const e=this.context.canvas.getBounds();yield this.focus(e,t)})}focusElements(t){return iu(this,arguments,void 0,function*(e,r={}){const{element:i}=this.context;if(!i)return;const a=s=>r.shapes?s.getShape(r.shapes).getRenderBounds():s.getRenderBounds(),o=Fu(e.map(s=>a(i.getElement(s))));yield this.focus(o,r)})}focus(t,e){return iu(this,void 0,void 0,function*(){const r=this.context.graph.getViewportByCanvas(t.center),i=e.position||this.getCanvasCenter(),a=Mn(i,r);yield this.transform({mode:"relative",translate:rn(a,this.paddingOffset)},e.animation)})}getBBoxInViewport(t){const{min:e,max:r}=t,{graph:i}=this.context,[a,o]=i.getViewportByCanvas(e),[s,u]=i.getViewportByCanvas(r),c=new ye;return c.setMinMax([a,o,0],[s,u,0]),c}isInViewport(t,e=!1,r=0){const{graph:i}=this.context,a=this.getCanvasSize(),[o,s]=i.getCanvasByViewport([0,0]),[u,c]=i.getCanvasByViewport(a);let l=new ye;return l.setMinMax([o,s,0],[u,c,0]),r&&(l=Aa(l,r)),ss(t)?Xr(t,l):e?sU(t,l):l.intersects(t)}cancelAnimation(){var t,e;!((t=this.camera.landmarks)===null||t===void 0)&&t.length&&this.camera.cancelLandmarkAnimation(),(e=this.transformResolver)===null||e===void 0||e.call(this)}}var ve=function(n,t,e,r){function i(a){return a instanceof e?a:new e(function(o){o(a)})}return new(e||(e=Promise))(function(a,o){function s(l){try{c(r.next(l))}catch(d){o(d)}}function u(l){try{c(r.throw(l))}catch(d){o(d)}}function c(l){l.done?a(l.value):i(l.value).then(s,u)}c((r=r.apply(n,t||[])).next())})};class Md extends Fb{constructor(t){var e;super(),this.options={},this.rendered=!1,this.destroyed=!1,this.context={model:new hJ},this.isCollapsingExpanding=!1,this.onResize=_h(()=>{this.resize()},300),this._setOptions(Object.assign({},Md.defaultOptions,t),!0),this.context.graph=this,this.options.autoResize&&((e=globalThis.addEventListener)===null||e===void 0||e.call(globalThis,"resize",this.onResize))}getOptions(){return this.options}setOptions(t){this._setOptions(t,!1)}_setOptions(t,e){if(this.updateCanvas(t),Object.assign(this.options,gJ(t)),e){const{data:p}=t;p&&this.addData(p);return}const{behaviors:r,combo:i,data:a,edge:o,layout:s,node:u,plugins:c,theme:l,transforms:d}=t;r&&this.setBehaviors(r),a&&this.setData(a),u&&this.setNode(u),o&&this.setEdge(o),i&&this.setCombo(i),s&&this.setLayout(s),l&&this.setTheme(l),c&&this.setPlugins(c),d&&this.setTransforms(d)}getSize(){return this.context.canvas?this.context.canvas.getSize():[this.options.width||0,this.options.height||0]}setSize(t,e){t&&(this.options.width=t),e&&(this.options.height=e),this.resize(t,e)}setZoomRange(t){this.options.zoomRange=t}getZoomRange(){return this.options.zoomRange}setNode(t){this.options.node=t,this.context.model.refreshData()}setEdge(t){this.options.edge=t,this.context.model.refreshData()}setCombo(t){this.options.combo=t,this.context.model.refreshData()}getTheme(){return this.options.theme}setTheme(t){this.options.theme=St(t)?t(this.getTheme()):t}setLayout(t){this.options.layout=St(t)?t(this.getLayout()):t}getLayout(){return this.options.layout}setBehaviors(t){var e;this.options.behaviors=St(t)?t(this.getBehaviors()):t,(e=this.context.behavior)===null||e===void 0||e.setBehaviors(this.options.behaviors)}updateBehavior(t){this.setBehaviors(e=>e.map(r=>typeof r=="object"&&r.key===t.key?Object.assign(Object.assign({},r),t):r))}getBehaviors(){return this.options.behaviors||[]}setPlugins(t){var e;this.options.plugins=St(t)?t(this.getPlugins()):t,(e=this.context.plugin)===null||e===void 0||e.setPlugins(this.options.plugins)}updatePlugin(t){this.setPlugins(e=>e.map(r=>typeof r=="object"&&r.key===t.key?Object.assign(Object.assign({},r),t):r))}getPlugins(){return this.options.plugins||[]}getPluginInstance(t){return this.context.plugin.getPluginInstance(t)}setTransforms(t){var e;this.options.transforms=St(t)?t(this.getTransforms()):t,(e=this.context.transform)===null||e===void 0||e.setTransforms(this.options.transforms)}updateTransform(t){this.setTransforms(e=>e.map(r=>typeof r=="object"&&r.key===t.key?Object.assign(Object.assign({},r),t):r)),this.context.model.refreshData()}getTransforms(){return this.options.transforms||[]}getData(){return this.context.model.getData()}hasNode(t){return this.context.model.hasNode(t)}hasEdge(t){return this.context.model.hasEdge(t)}hasCombo(t){return this.context.model.hasCombo(t)}getElementData(t){return Array.isArray(t)?t.map(e=>this.context.model.getElementDataById(e)):this.context.model.getElementDataById(t)}getNodeData(t){return t===void 0?this.context.model.getNodeData():Array.isArray(t)?this.context.model.getNodeData(t):this.context.model.getNodeLikeDatum(t)}getEdgeData(t){return t===void 0?this.context.model.getEdgeData():Array.isArray(t)?this.context.model.getEdgeData(t):this.context.model.getEdgeDatum(t)}getComboData(t){return t===void 0?this.context.model.getComboData():Array.isArray(t)?this.context.model.getComboData(t):this.context.model.getNodeLikeDatum(t)}setData(t){this.context.model.setData(St(t)?t(this.getData()):t)}addData(t){this.context.model.addData(St(t)?t(this.getData()):t)}addNodeData(t){this.context.model.addNodeData(St(t)?t(this.getNodeData()):t)}addEdgeData(t){this.context.model.addEdgeData(St(t)?t(this.getEdgeData()):t)}addComboData(t){this.context.model.addComboData(St(t)?t(this.getComboData()):t)}addChildrenData(t,e){this.context.model.addChildrenData(t,e)}updateData(t){this.context.model.updateData(St(t)?t(this.getData()):t)}updateNodeData(t){this.context.model.updateNodeData(St(t)?t(this.getNodeData()):t)}updateEdgeData(t){this.context.model.updateEdgeData(St(t)?t(this.getEdgeData()):t)}updateComboData(t){this.context.model.updateComboData(St(t)?t(this.getComboData()):t)}removeData(t){this.context.model.removeData(St(t)?t(this.getData()):t)}removeNodeData(t){this.context.model.removeNodeData(St(t)?t(this.getNodeData()):t)}removeEdgeData(t){this.context.model.removeEdgeData(St(t)?t(this.getEdgeData()):t)}removeComboData(t){this.context.model.removeComboData(St(t)?t(this.getComboData()):t)}getElementType(t){return this.context.model.getElementType(t)}getRelatedEdgesData(t,e="both"){return this.context.model.getRelatedEdgesData(t,e)}getNeighborNodesData(t){return this.context.model.getNeighborNodesData(t)}getAncestorsData(t,e){return this.context.model.getAncestorsData(t,e)}getParentData(t,e){return this.context.model.getParentData(t,e)}getChildrenData(t){return this.context.model.getChildrenData(t)}getDescendantsData(t){return this.context.model.getDescendantsData(t)}getElementDataByState(t,e){return this.context.model.getElementDataByState(t,e)}initCanvas(){return ve(this,void 0,void 0,function*(){var t;if(this.context.canvas)return yield this.context.canvas.ready;const{container:e="container",width:r,height:i,renderer:a,cursor:o,background:s,canvas:u,devicePixelRatio:c=(t=globalThis.devicePixelRatio)!==null&&t!==void 0?t:1}=this.options;if(e instanceof NT)this.context.canvas=e,o&&e.setCursor(o),a&&e.setRenderer(a),yield e.ready;else{const l=fe(e)?document.getElementById(e):e,d=_T(l);this.emit(gt.BEFORE_CANVAS_INIT,{container:l,width:r,height:i});const p=Object.assign(Object.assign({},u),{container:l,width:r||d[0],height:i||d[1],background:s,renderer:a,cursor:o,devicePixelRatio:c}),g=new NT(p);this.context.canvas=g,yield g.ready,this.emit(gt.AFTER_CANVAS_INIT,{canvas:g})}})}updateCanvas(t){var e,r;const{renderer:i,cursor:a,height:o,width:s}=t,u=this.context.canvas;u&&(i&&(this.emit(gt.BEFORE_RENDERER_CHANGE,{renderer:this.options.renderer}),u.setRenderer(i),this.emit(gt.AFTER_RENDERER_CHANGE,{renderer:i})),a&&u.setCursor(a),(Xt(s)||Xt(o))&&this.setSize((e=s??this.options.width)!==null&&e!==void 0?e:0,(r=o??this.options.height)!==null&&r!==void 0?r:0))}initRuntime(){this.context.options=this.options,this.context.batch||(this.context.batch=new sJ(this.context)),this.context.plugin||(this.context.plugin=new mJ(this.context)),this.context.viewport||(this.context.viewport=new bJ(this.context)),this.context.transform||(this.context.transform=new yJ(this.context)),this.context.element||(this.context.element=new dJ(this.context)),this.context.animation||(this.context.animation=new oJ(this.context)),this.context.layout||(this.context.layout=new pJ(this.context)),this.context.behavior||(this.context.behavior=new uJ(this.context))}prepare(){return ve(this,void 0,void 0,function*(){if(yield Promise.resolve(),this.destroyed){console.error(Li("The graph instance has been destroyed"));return}yield this.initCanvas(),this.initRuntime()})}render(){return ve(this,void 0,void 0,function*(){if(yield this.prepare(),an(this,new Xe(gt.BEFORE_RENDER)),this.options.layout)if(!this.rendered&&RY(this.options.layout)){const t=yield this.context.element.preLayoutDraw({type:"render"});yield Promise.all([t==null?void 0:t.finished,this.autoFit()])}else{const t=this.context.element.draw({type:"render"});yield Promise.all([t==null?void 0:t.finished,this.context.layout.postLayout()]),yield this.autoFit()}else{const t=this.context.element.draw({type:"render"});yield Promise.all([t==null?void 0:t.finished,this.autoFit()])}this.rendered=!0,an(this,new Xe(gt.AFTER_RENDER))})}draw(){return ve(this,void 0,void 0,function*(){var t;yield this.prepare(),yield(t=this.context.element.draw())===null||t===void 0?void 0:t.finished})}layout(t){return ve(this,void 0,void 0,function*(){yield this.context.layout.postLayout(t)})}stopLayout(){this.context.layout.stopLayout()}clear(){return ve(this,void 0,void 0,function*(){const{model:t,element:e}=this.context;t.setData({}),t.clearChanges(),e==null||e.clear()})}destroy(){var t;an(this,new Xe(gt.BEFORE_DESTROY));const{layout:e,animation:r,element:i,model:a,canvas:o,behavior:s,plugin:u}=this.context;u==null||u.destroy(),s==null||s.destroy(),e==null||e.destroy(),r==null||r.destroy(),i==null||i.destroy(),a.destroy(),o==null||o.destroy(),this.options={},this.context={},this.off(),(t=globalThis.removeEventListener)===null||t===void 0||t.call(globalThis,"resize",this.onResize),this.destroyed=!0,an(this,new Xe(gt.AFTER_DESTROY))}getCanvas(){return this.context.canvas}resize(t,e){var r;const i=_T((r=this.context.canvas)===null||r===void 0?void 0:r.getContainer()),a=[t||i[0],e||i[1]];if(!this.context.canvas)return;const o=this.context.canvas.getSize();Jn(a,o)||(an(this,new Xe(gt.BEFORE_SIZE_CHANGE,{size:a})),this.context.canvas.resize(...a),an(this,new Xe(gt.AFTER_SIZE_CHANGE,{size:a})))}fitView(t,e){return ve(this,void 0,void 0,function*(){var r;yield(r=this.context.viewport)===null||r===void 0?void 0:r.fitView(t,e)})}fitCenter(t){return ve(this,void 0,void 0,function*(){var e;yield(e=this.context.viewport)===null||e===void 0?void 0:e.fitCenter({animation:t})})}autoFit(){return ve(this,void 0,void 0,function*(){const{autoFit:t}=this.context.options;if(t)if(fe(t))t==="view"?yield this.fitView():t==="center"&&(yield this.fitCenter());else{const{type:e,animation:r}=t;e==="view"?yield this.fitView(t.options,r):e==="center"&&(yield this.fitCenter(r))}})}focusElement(t,e){return ve(this,void 0,void 0,function*(){var r;yield(r=this.context.viewport)===null||r===void 0?void 0:r.focusElements(Array.isArray(t)?t:[t],{animation:e})})}zoomBy(t,e,r){return ve(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",scale:t,origin:r},e)})}zoomTo(t,e,r){return ve(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",scale:t,origin:r},e)})}getZoom(){return this.context.viewport.getZoom()}rotateBy(t,e,r){return ve(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",rotate:t,origin:r},e)})}rotateTo(t,e,r){return ve(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",rotate:t,origin:r},e)})}getRotation(){return this.context.viewport.getRotation()}translateBy(t,e){return ve(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",translate:t},e)})}translateTo(t,e){return ve(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",translate:t},e)})}getPosition(){return Mn([0,0],this.getCanvasByViewport([0,0]))}translateElementBy(t,e){return ve(this,arguments,void 0,function*(r,i,a=!0){var o,s;const[u,c]=An(r)?[r,(o=i)!==null&&o!==void 0?o:!0]:[{[r]:i},a];Object.entries(u).forEach(([l,d])=>this.context.model.translateNodeLikeBy(l,d)),yield(s=this.context.element.draw({animation:c,stage:"translate"}))===null||s===void 0?void 0:s.finished})}translateElementTo(t,e){return ve(this,arguments,void 0,function*(r,i,a=!0){var o,s;const[u,c]=An(r)?[r,(o=i)!==null&&o!==void 0?o:!0]:[{[r]:i},a];Object.entries(u).forEach(([l,d])=>this.context.model.translateNodeLikeTo(l,d)),yield(s=this.context.element.draw({animation:c,stage:"translate"}))===null||s===void 0?void 0:s.finished})}getElementPosition(t){return this.context.model.getElementPosition(t)}getElementRenderStyle(t){return RM(this.context.element.getElement(t).attributes,["context"])}setElementVisibility(t,e){return ve(this,arguments,void 0,function*(r,i,a=!0){var o,s;const[u,c]=An(r)?[r,(o=i)!==null&&o!==void 0?o:!0]:[{[r]:i},a],l={nodes:[],edges:[],combos:[]};Object.entries(u).forEach(([g,m])=>{const y=this.getElementType(g);l[`${y}s`].push({id:g,style:{visibility:m}})});const{model:d,element:p}=this.context;d.preventUpdateNodeLikeHierarchy(()=>{d.updateData(l)}),yield(s=p.draw({animation:c,stage:"visibility"}))===null||s===void 0?void 0:s.finished})}showElement(t,e){return ve(this,void 0,void 0,function*(){const r=Array.isArray(t)?t:[t];yield this.setElementVisibility(Object.fromEntries(r.map(i=>[i,"visible"])),e)})}hideElement(t,e){return ve(this,void 0,void 0,function*(){const r=Array.isArray(t)?t:[t];yield this.setElementVisibility(Object.fromEntries(r.map(i=>[i,"hidden"])),e)})}getElementVisibility(t){var e,r;const i=this.context.element.getElement(t);return(r=(e=i==null?void 0:i.style)===null||e===void 0?void 0:e.visibility)!==null&&r!==void 0?r:"visible"}setElementZIndex(t,e){return ve(this,void 0,void 0,function*(){var r;const i={nodes:[],edges:[],combos:[]},a=An(t)?t:{[t]:e};Object.entries(a).forEach(([u,c])=>{const l=this.getElementType(u);i[`${l}s`].push({id:u,style:{zIndex:c}})});const{model:o,element:s}=this.context;o.preventUpdateNodeLikeHierarchy(()=>o.updateData(i)),yield(r=s.draw({animation:!1,stage:"zIndex"}))===null||r===void 0?void 0:r.finished})}frontElement(t){return ve(this,void 0,void 0,function*(){const e=Array.isArray(t)?t:[t],{model:r}=this.context,i={};e.map(a=>{const o=r.getFrontZIndex(a);if(r.getElementType(a)==="combo"){const s=r.getAncestorsData(a,me).at(-1)||this.getComboData(a),u=[s,...r.getDescendantsData(Z(s))],c=o-OT(s);u.forEach(d=>{i[Z(d)]=this.getElementZIndex(Z(d))+c});const{internal:l}=nY(u.map(Z),d=>r.getRelatedEdgesData(d));l.forEach(d=>{const p=Z(d);i[p]=this.getElementZIndex(p)+c})}else i[a]=o}),yield this.setElementZIndex(i)})}getElementZIndex(t){return OT(this.context.model.getElementDataById(t))}setElementState(t,e){return ve(this,arguments,void 0,function*(r,i,a=!0){var o,s;const[u,c]=An(r)?[r,(o=i)!==null&&o!==void 0?o:!0]:[{[r]:i},a],l=p=>p?Array.isArray(p)?p:[p]:[],d={nodes:[],edges:[],combos:[]};Object.entries(u).forEach(([p,g])=>{const m=this.getElementType(p);d[`${m}s`].push({id:p,states:l(g)})}),this.updateData(d),yield(s=this.context.element.draw({animation:c,stage:"state"}))===null||s===void 0?void 0:s.finished})}getElementState(t){return this.context.model.getElementState(t)}getElementRenderBounds(t){return this.context.element.getElement(t).getRenderBounds()}collapseElement(t){return ve(this,arguments,void 0,function*(e,r=!0){const{model:i,element:a}=this.context;if(ba(i.getNodeLikeData([e])[0])||this.isCollapsingExpanding)return;typeof r=="boolean"&&(r={animation:r,align:!0});const o=i.getElementType(e);yield this.frontElement(e),this.isCollapsingExpanding=!0,i.updateData(o==="node"?{nodes:[{id:e,style:{collapsed:!0}}]}:{combos:[{id:e,style:{collapsed:!0}}]}),o==="node"?yield a.collapseNode(e,r):o==="combo"&&(yield a.collapseCombo(e,!!r.animation)),this.isCollapsingExpanding=!1})}expandElement(t){return ve(this,arguments,void 0,function*(e,r=!0){const{model:i,element:a}=this.context;if(!ba(i.getNodeLikeData([e])[0])||this.isCollapsingExpanding)return;typeof r=="boolean"&&(r={animation:r,align:!0});const o=i.getElementType(e);this.isCollapsingExpanding=!0,i.updateData(o==="node"?{nodes:[{id:e,style:{collapsed:!1}}]}:{combos:[{id:e,style:{collapsed:!1}}]}),o==="node"?yield a.expandNode(e,r):o==="combo"&&(yield a.expandCombo(e,!!r.animation)),this.isCollapsingExpanding=!1})}setElementCollapsibility(t,e){const r=this.getElementType(t);r==="node"?this.updateNodeData([{id:t,style:{collapsed:e}}]):r==="combo"&&this.updateComboData([{id:t,style:{collapsed:e}}])}toDataURL(){return ve(this,arguments,void 0,function*(t={}){return this.context.canvas.toDataURL(t)})}getCanvasByViewport(t){return this.context.canvas.getCanvasByViewport(t)}getViewportByCanvas(t){return this.context.canvas.getViewportByCanvas(t)}getClientByCanvas(t){return this.context.canvas.getClientByCanvas(t)}getCanvasByClient(t){return this.context.canvas.getCanvasByClient(t)}getViewportCenter(){return this.context.viewport.getViewportCenter()}getCanvasCenter(){return this.context.viewport.getCanvasCenter()}on(t,e,r){return super.on(t,e,r)}once(t,e){return super.once(t,e)}off(t,e){return super.off(t,e)}}Md.defaultOptions={autoResize:!1,theme:"light",rotation:0,zoom:1,zoomRange:[.01,10]};const xJ=(n,t)=>{const{source:e,target:r}=t,i=n.getElementDataById(e),a=n.getElementDataById(r),o=vk(i,d=>n.getParentData(d,me)),s=vk(a,d=>n.getParentData(d,me)),u=Z(o),c=Z(s),l={sourceNode:u,targetNode:c};return t.style?Object.assign(t.style,l):t.style=l,t},EJ=(n,t,e)=>{const[r,i]=t,[a,o]=e;if(i===r)return a;const s=(n-r)/(i-r);return a+s*(o-a)},wJ=(n,t,e)=>{const[r,i]=t,[a,o]=e,s=Math.log(n-r+1)/Math.log(i-r+1);return a+s*(o-a)},kJ=(n,t,e,r=2)=>{const[i,a]=t,[o,s]=e,u=Math.pow((n-i)/(a-i),r);return o+u*(s-o)},AJ=(n,t,e)=>{const[r,i]=t,[a,o]=e,s=Math.sqrt((n-r)/(i-r));return a+s*(o-a)};class _d extends i6{constructor(t,e){super(t,ma({},_d.defaultOptions,e)),this.assignSizeByCentrality=(r,i,a,o,s,u)=>{const c=[i,a],l=[o[0],s[0]],d=[o[1],s[1]],p=[o[2],s[2]],g=(m,y)=>{if(typeof u=="function")return u(m,c,y);switch(u){case"linear":return EJ(m,c,y);case"log":return wJ(m,c,y);case"pow":return kJ(m,c,y,2);case"sqrt":return AJ(m,c,y);default:return y[0]}};return[g(r,l),g(r,d),g(r,p)]}}beforeDraw(t){const{model:e}=this.context,r=e.getNodeData(),i=ga(this.options.maxSize),a=ga(this.options.minSize),o=this.getCentralities(this.options.centrality),s=o.size>0?Math.max(...o.values()):0,u=o.size>0?Math.min(...o.values()):0;return r.forEach(c=>{var l;const d=this.assignSizeByCentrality(o.get(Z(c))||0,u,s,a,i,this.options.scale),p=(l=this.context.element)===null||l===void 0?void 0:l.getElement(Z(c)),g={size:d};this.assignLabelStyle(g,d,c,p),(!p||!Il(g,p.attributes))&&lu(t,p?"update":"add","node",ma(c,{style:g}),!0)}),t}assignLabelStyle(t,e,r,i){var a;const o=i?i.config.style:(a=this.context.element)===null||a===void 0?void 0:a.getElementComputedStyle("node",r);if(Object.assign(t,wu(o,["labelFontSize","labelLineHeight"])),this.options.mapLabelSize){const s=this.getLabelSizeByNodeSize(e,1/0,Number(t.labelFontSize));Object.assign(t,{labelFontSize:s,labelLineHeight:s+oU(t.labelPadding)})}return t}getLabelSizeByNodeSize(t,e,r){const i=Math.min(...t)/2,[a,o]=Array.isArray(this.options.mapLabelSize)?this.options.mapLabelSize:[r,e];return Math.min(o,Math.max(i,a))}getCentralities(t){const{model:e}=this.context,r=e.getData();if(typeof t=="function")return t(r);const i=e.getRelatedEdgesData.bind(e);return U_(r,i,t)}}_d.defaultOptions={centrality:{type:"degree"},maxSize:80,minSize:20,scale:"linear",mapLabelSize:!1};const SJ="quadratic",DT=["top","top-right","right","right-bottom","bottom","bottom-left","left","left-top"];class Ru extends i6{constructor(t,e){super(t,Object.assign({},Ru.defaultOptions,e)),this.cacheMergeStyle=new Map,this.getAffectedParallelEdges=r=>{const{add:{edges:i},update:{nodes:a,edges:o,combos:s},remove:{edges:u}}=r,{model:c}=this.context,l=new Map,d=(m,y)=>{c.getRelatedEdgesData(y).forEach(v=>!l.has(Z(v))&&l.set(Z(v),v))};a.forEach(d),s.forEach(d);const p=m=>{const y=new Set(r.remove.edges.keys()),v=c.getEdgeData().filter(x=>!y.has(Z(x))).map(x=>xJ(c,x));CJ(m,v).forEach(x=>{const E=Z(x);l.has(E)||l.set(E,x)})};if(u.size&&u.forEach(p),i.size&&i.forEach(p),o.size){const m=OK(UP(c.getChanges())).update.edges;o.forEach(y=>{var v;p(y);const x=(v=m.find(E=>Z(E.value)===Z(y)))===null||v===void 0?void 0:v.original;x&&!hx(y,x)&&p(x)})}PM(this.options.edges)||l.forEach((m,y)=>!this.options.edges.includes(y)&&l.delete(y));const g=c.getEdgeData().map(Z);return new Map([...l].sort((m,y)=>g.indexOf(m[0])-g.indexOf(y[0])))},this.applyBundlingStyle=(r,i,a)=>{const{edgeMap:o,reverses:s}=LT(i);o.forEach(u=>{u.forEach((c,l,d)=>{var p;const g=d.length,m=c.style||{};if(c.source===c.target){const x=DT.length;m.loopPlacement=DT[l%x],m.loopDist=Math.floor(l/x)*a+50}else if(g===1)m.curveOffset=0;else{const x=(l%2===0?1:-1)*(s[`${c.source}|${c.target}|${l}`]?-1:1);m.curveOffset=g%2===1?x*Math.ceil(l/2)*a*2:x*(Math.floor(l/2)*a*2+a)}const y=Object.assign(c,{type:SJ,style:m}),v=(p=this.context.element)===null||p===void 0?void 0:p.getElement(Z(c));(!v||!Il(y.style,v.attributes))&&lu(r,v?"update":"add","edge",y,!0)})})},this.resetEdgeStyle=r=>{const i=r.style||{},a=this.cacheMergeStyle.get(Z(r))||{};return Object.keys(a).forEach(o=>{Jn(i[o],a[o])&&(r[o]?i[o]=r[o]:delete i[o])}),Object.assign(r,{style:i})},this.applyMergingStyle=(r,i)=>{const{edgeMap:a,reverses:o}=LT(i);a.forEach(s=>{var u;if(s.length===1){const l=s[0],d=(u=this.context.element)===null||u===void 0?void 0:u.getElement(Z(l)),p=this.resetEdgeStyle(l);(!d||!Il(p,d.attributes))&&lu(r,d?"update":"add","edge",p);return}const c=s.map(({source:l,target:d,style:p={}},g)=>{const{startArrow:m,endArrow:y}=p,v={},[x,E]=o[`${l}|${d}|${g}`]?["endArrow","startArrow"]:["startArrow","endArrow"];return Eu(m)&&(v[x]=m),Eu(y)&&(v[E]=y),v}).reduce((l,d)=>Object.assign(Object.assign({},l),d),{});s.forEach((l,d,p)=>{var g;if(d!==0){lu(r,"remove","edge",l);return}const m=Object.assign({},St(this.options.style)?this.options.style(p):this.options.style,{childrenData:p});this.cacheMergeStyle.set(Z(l),m);const y=Object.assign(Object.assign({},l),{type:"line",style:Object.assign(Object.assign(Object.assign({},l.style),c),m)}),v=(g=this.context.element)===null||g===void 0?void 0:g.getElement(Z(l));(!v||!Il(y.style,v.attributes))&&lu(r,v?"update":"add","edge",y,!0)})})}}beforeDraw(t){const e=this.getAffectedParallelEdges(t);return e.size===0||(this.options.mode==="bundle"?this.applyBundlingStyle(t,e,this.options.distance):this.applyMergingStyle(t,e)),t}}Ru.defaultOptions={mode:"bundle",distance:15};const LT=n=>{const t=new Map,e=new Set,r={},i=new Map;for(const[a,o]of n){if(e.has(a))continue;const{source:s,target:u}=o,c=`${s}-${u}`;t.has(c)||(t.set(c,[]),i.set(c,new Set));const l=t.get(c),d=i.get(c);l&&d&&!d.has(a)&&(l.push(o),d.add(a),e.add(a));for(const[p,g]of n)if(!(e.has(p)||p===a)&&hx(o,g)){const m=t.get(c),y=i.get(c);m&&y&&!y.has(p)&&(m.push(g),y.add(p),s===g.target&&u===g.source&&(r[`${g.source}|${g.target}|${m.length-1}`]=!0),e.add(p))}}return{edgeMap:t,reverses:r}},CJ=(n,t,e)=>t.filter(r=>hx(r,n)),hx=(n,t)=>{const{sourceNode:e,targetNode:r}=n.style||{},{sourceNode:i,targetNode:a}=t.style||{};return e===i&&r===a||e===a&&r===i},NJ={css:"//at.alicdn.com/t/a/font_470089_8hnbbf8n4u8.css"},TJ={dragCanvas:!0,zoomCanvas:!0,scrollCanvas:!0,clickSelect:!0,focusElement:!0,hoverActivate:!0,autoAdaptLabel:!0};class MJ{constructor(t={}){Te(this,"options"),this.options={...TJ,...t}}generate(){const t=[];return this.options.dragCanvas&&t.push(this.createDragCanvasConfig()),this.options.zoomCanvas&&t.push(this.createZoomCanvasConfig()),this.options.scrollCanvas&&t.push(this.createScrollCanvasConfig()),this.options.optimizeViewportTransform&&t.push(this.createOptimizeViewportTransformConfig()),this.options.clickSelect&&t.push(this.createClickSelectConfig()),this.options.brushSelect&&t.push(this.createBrushSelectConfig()),this.options.lassoSelect&&t.push(this.createLassoSelectConfig()),this.options.createEdge&&t.push(this.createCreateEdgeConfig()),this.options.dragElement&&t.push(this.createDragElementConfig()),this.options.dragElementForce&&t.push(this.createDragElementForceConfig()),this.options.collapseExpand&&t.push(this.createCollapseExpandConfig()),this.options.focusElement&&t.push(this.createFocusElementConfig()),this.options.hoverActivate&&t.push(this.createHoverActivateConfig()),this.options.fixElementSize&&t.push(this.createFixElementSizeConfig()),this.options.autoAdaptLabel&&t.push(this.createAutoAdaptLabelConfig()),t}createDragCanvasConfig(){const t=this.options.dragCanvas;return typeof t=="boolean"?{type:"drag-canvas"}:{type:"drag-canvas",key:"drag-canvas",direction:"both",...t}}createZoomCanvasConfig(){const t=this.options.zoomCanvas;return typeof t=="boolean"?{type:"zoom-canvas"}:{type:"zoom-canvas",key:"zoom-canvas",sensitivity:1,...t}}createScrollCanvasConfig(){const t=this.options.scrollCanvas;return typeof t=="boolean"?{type:"scroll-canvas"}:{type:"scroll-canvas",key:"scroll-canvas",sensitivity:1,...t}}createOptimizeViewportTransformConfig(){const t=this.options.optimizeViewportTransform;return typeof t=="boolean"?{type:"optimize-viewport-transform"}:{type:"optimize-viewport-transform",key:"optimize-viewport-transform",debounce:200,...t}}createClickSelectConfig(){const t=this.options.clickSelect;return typeof t=="boolean"?{type:"click-select"}:{type:"click-select",key:"click-select",multiple:!1,...t}}createBrushSelectConfig(){const t=this.options.brushSelect;return typeof t=="boolean"?{type:"brush-select"}:{type:"brush-select",key:"brush-select",...t}}createLassoSelectConfig(){const t=this.options.lassoSelect;return typeof t=="boolean"?{type:"lasso-select"}:{type:"lasso-select",key:"lasso-select",...t}}createCreateEdgeConfig(){const t=this.options.createEdge;return typeof t=="boolean"?{type:"create-edge"}:{type:"create-edge",key:"create-edge",...t}}createDragElementConfig(){const t=this.options.dragElement;return typeof t=="boolean"?{type:"drag-element"}:{type:"drag-element",key:"drag-element",...t}}createDragElementForceConfig(){const t=this.options.dragElementForce;return typeof t=="boolean"?{type:"drag-element-force"}:{type:"drag-element-force",key:"drag-element-force",...t}}createCollapseExpandConfig(){const t=this.options.collapseExpand;return typeof t=="boolean"?{type:"collapse-expand"}:{type:"collapse-expand",key:"collapse-expand",...t}}createFocusElementConfig(){const t=this.options.focusElement;return typeof t=="boolean"?{type:"focus-element"}:{type:"focus-element",key:"focus-element",animation:{duration:500,easing:"ease-in"},...t}}createHoverActivateConfig(){const t=this.options.hoverActivate;return typeof t=="boolean"?{type:"hover-activate"}:{type:"hover-activate",key:"hover-activate",animation:!0,degree:0,direction:"both",state:"active",...t}}createFixElementSizeConfig(){const t=this.options.fixElementSize;return typeof t=="boolean"?{type:"fix-element-size"}:{type:"fix-element-size",key:"fix-element-size",...t}}createAutoAdaptLabelConfig(){const t=this.options.autoAdaptLabel;return typeof t=="boolean"?{type:"auto-adapt-label"}:{type:"auto-adapt-label",key:"auto-adapt-label",enable:!0,...t}}}function eb(n={}){return new MJ(n).generate()}function _J(n){const t={minimal:{dragCanvas:!0,zoomCanvas:!0},standard:{dragCanvas:!0,zoomCanvas:!0,scrollCanvas:!0,clickSelect:!0,focusElement:!0,hoverActivate:!0},advanced:{dragCanvas:!0,zoomCanvas:!0,scrollCanvas:!0,optimizeViewportTransform:!0,clickSelect:!0,brushSelect:!0,dragElement:!0,focusElement:!0,hoverActivate:!0,autoAdaptLabel:!0},full:{dragCanvas:!0,zoomCanvas:!0,scrollCanvas:!0,optimizeViewportTransform:!0,clickSelect:!0,brushSelect:!0,lassoSelect:!0,createEdge:!0,dragElement:!0,dragElementForce:!0,collapseExpand:!0,focusElement:!0,hoverActivate:!0,fixElementSize:!0,autoAdaptLabel:!0},preview:{dragCanvas:{direction:"both",sensitivity:1},zoomCanvas:{sensitivity:.8,trigger:["Control"]},scrollCanvas:{sensitivity:1.2},optimizeViewportTransform:{debounce:200},focusElement:{animation:{duration:600,easing:"ease-in-out"}},hoverActivate:{animation:!0,degree:1,direction:"both",state:"highlight"},autoAdaptLabel:!0,clickSelect:!1,brushSelect:!1,lassoSelect:!1,createEdge:!1,dragElement:!1,dragElementForce:!1,collapseExpand:!1}};return eb(t[n]||t.standard)}class OJ{constructor(t={}){Te(this,"options"),this.options=t}generate(){const t=[];return this.options.background&&(this.options.background===!0?t.push({type:"background"}):t.push({type:"background",...this.options.background})),this.options.bubbleSets&&(this.options.bubbleSets===!0?t.push({type:"bubble-sets",members:[]}):t.push({type:"bubble-sets",members:[],...this.options.bubbleSets})),this.options.fullscreen&&(this.options.fullscreen===!0?t.push({type:"fullscreen"}):t.push({type:"fullscreen",...this.options.fullscreen})),this.options.gridLine&&(this.options.gridLine===!0?t.push({type:"grid-line"}):t.push({type:"grid-line",...this.options.gridLine})),this.options.history&&(this.options.history===!0?t.push({type:"history"}):t.push({type:"history",...this.options.history})),this.options.legend&&(this.options.legend===!0?t.push({type:"legend",key:"legend",nodeField:"nodeType",edgeField:"edgeType"}):t.push({type:"legend",key:"legend",...this.options.legend})),this.options.contextmenu&&(this.options.contextmenu===!0?t.push({type:"contextmenu"}):t.push({type:"contextmenu",...this.options.contextmenu})),this.options.snapline&&(this.options.snapline===!0?t.push({type:"snapline"}):t.push({type:"snapline",...this.options.snapline})),this.options.timebar&&(this.options.timebar===!0?t.push({type:"timebar",data:[]}):t.push({type:"timebar",data:[],...this.options.timebar})),this.options.title&&(this.options.title===!0?t.push({type:"title",key:"title"}):t.push({type:"title",key:"title",...this.options.title})),this.options.toolbar&&(this.options.toolbar===!0?t.push({type:"toolbar",getItems:()=>[],onClick:()=>{}}):t.push({type:"toolbar",getItems:()=>[],onClick:()=>{},...this.options.toolbar})),this.options.tooltip&&(this.options.tooltip===!0?t.push({type:"tooltip"}):t.push({type:"tooltip",...this.options.tooltip})),this.options.watermark&&(this.options.watermark===!0?t.push({type:"watermark"}):t.push({type:"watermark",...this.options.watermark})),t}}const PJ={minimal:{},standard:{tooltip:!0,legend:!0},advanced:{tooltip:!0,legend:!0,minimap:!0,toolbar:!0,history:!0},full:{background:!0,bubbleSets:!0,fullscreen:!0,gridLine:!0,history:!0,legend:!0,contextmenu:!0,minimap:!0,snapline:!0,timebar:!0,title:!0,toolbar:!0,tooltip:!0,watermark:!0},preview:{background:{backgroundColor:"#f8f9fa",opacity:"0.8"},fullscreen:{autoFit:!0,trigger:{request:"F",exit:"Esc"}},gridLine:{size:20,stroke:"#e8e8e8",follow:!0},legend:{type:"legend",key:"legend",position:"bottom-right",trigger:"hover",nodeField:"nodeType",edgeField:"edgeType"},title:{type:"title",key:"title",title:"\u77E5\u8BC6\u56FE\u8C31\u9884\u89C8",align:"center"},tooltip:{position:"top-right",trigger:"hover",getContent:async(n,t)=>{var r;const e=t[0];return n.targetType==="node"?`
210
+ */var a6=(function(){function n(t){et(this,n),this.dragndropPluginOptions=t}return nt(n,[{key:"apply",value:function(t){var e=this,r=t.renderingService,i=t.renderingContext,a=i.root.ownerDocument,o=a.defaultView,s=function(u){var c=u.target,l=c===a,d=l&&e.dragndropPluginOptions.isDocumentDraggable?a:c.closest&&c.closest("[draggable=true]");if(d){var p=!1,g=u.timeStamp,m=[u.clientX,u.clientY],y=null,v=[u.clientX,u.clientY],x=(function(){var w=ya(fn().mark(function S(k){var A,N,T,O,M,P;return fn().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(p){L.next=2;break}if(A=k.timeStamp-g,N=Hn([k.clientX,k.clientY],m),!(A<=e.dragndropPluginOptions.dragstartTimeThreshold||N<=e.dragndropPluginOptions.dragstartDistanceThreshold)){L.next=1;break}return L.abrupt("return");case 1:k.type="dragstart",d.dispatchEvent(k),p=!0;case 2:if(k.type="drag",k.dx=k.clientX-v[0],k.dy=k.clientY-v[1],d.dispatchEvent(k),v=[k.clientX,k.clientY],l){L.next=4;break}return T=e.dragndropPluginOptions.overlap==="pointer"?[k.canvasX,k.canvasY]:c.getBounds().center,L.next=3,a.elementsFromPoint(T[0],T[1]);case 3:O=L.sent,M=O[O.indexOf(c)+1],P=(M==null?void 0:M.closest("[droppable=true]"))||(e.dragndropPluginOptions.isDocumentDroppable?a:null),y!==P&&(y&&(k.type="dragleave",k.target=y,y.dispatchEvent(k)),P&&(k.type="dragenter",k.target=P,P.dispatchEvent(k)),y=P,y&&(k.type="dragover",k.target=y,y.dispatchEvent(k)));case 4:case"end":return L.stop()}},S)}));return function(S){return w.apply(this,arguments)}})();o.addEventListener("pointermove",x);var E=function(w){if(p){w.detail={preventClick:!0};var S=w.clone();y&&(S.type="drop",S.target=y,y.dispatchEvent(S)),S.type="dragend",d.dispatchEvent(S),p=!1}o.removeEventListener("pointermove",x)};c.addEventListener("pointerup",E,{once:!0}),c.addEventListener("pointerupoutside",E,{once:!0})}};r.hooks.init.tap(n.tag,function(){o.addEventListener("pointerdown",s)}),r.hooks.destroy.tap(n.tag,function(){o.removeEventListener("pointerdown",s)})}}])})();a6.tag="Dragndrop";var tJ=(function(n){function t(){var e,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return et(this,t),e=Bt(this,t),e.name="dragndrop",e.options=r,e}return zt(t,n),nt(t,[{key:"init",value:function(){this.addRenderingPlugin(new a6(Lt({overlap:"pointer",isDocumentDraggable:!1,isDocumentDroppable:!1,dragstartDistanceThreshold:0,dragstartTimeThreshold:0},this.options)))}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}},{key:"setOptions",value:function(e){Object.assign(this.plugins[0].dragndropPluginOptions,e)}}])})(wa),kT=function(n,t,e,r){function i(a){return a instanceof e?a:new e(function(o){o(a)})}return new(e||(e=Promise))(function(a,o){function s(l){try{c(r.next(l))}catch(d){o(d)}}function u(l){try{c(r.throw(l))}catch(d){o(d)}}function c(l){l.done?a(l.value):i(l.value).then(s,u)}c((r=r.apply(n,t||[])).next())})},AT=function(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(e[r[i]]=n[r[i]]);return e};const ST=["main"],CT=["background","main","label","transient"];function eJ(n){return n.main}class NT{getConfig(){return this.config}getLayer(t="main"){return this.extends.layers[t]||eJ(this.getLayers())}getLayers(){return this.extends.layers}getRenderer(t){return this.extends.renderers[t]}getCamera(t="main"){return this.getLayer(t).getCamera()}getRoot(t="main"){return this.getLayer(t).getRoot()}getContextService(t="main"){return this.getLayer(t).getContextService()}setCursor(t){this.config.cursor=t,this.getLayer().setCursor(t)}get document(){return this.getLayer().document}get context(){return this.getLayer().context}constructor(t){this.config={enableMultiLayer:!0},Object.assign(this.config,t);const e=this.config,{renderer:r,background:i,enableMultiLayer:a}=e,o=AT(e,["renderer","background","cursor","enableMultiLayer"]),s=a?CT:ST,u=TT(r,s),c=Object.fromEntries(s.map(l=>{const d=new I1(Object.assign(Object.assign({},o),{supportsMutipleCanvasesInOneContainer:a,renderer:u[l],background:a?l==="background"?i:void 0:i}));return[l,d]}));MT(c),this.extends={config:this.config,renderer:r,renderers:u,layers:c}}get ready(){return Promise.all(Object.entries(this.getLayers()).map(([,t])=>t.ready))}resize(t,e){Object.assign(this.extends.config,{width:t,height:e}),Object.values(this.getLayers()).forEach(r=>{const i=r.getCamera(),a=i.getPosition(),o=i.getFocalPoint();r.resize(t,e),i.setPosition(a),i.setFocalPoint(o)})}getBounds(t){return Fu(Object.values(this.getLayers()).map(e=>t?e.getRoot().childNodes.find(r=>r.classList.includes(t)):e.getRoot()).filter(e=>(e==null?void 0:e.childNodes.length)>0).map(e=>e.getBounds()))}getContainer(){const t=this.extends.config.container;return typeof t=="string"?document.getElementById(t):t}getSize(){return[this.extends.config.width||0,this.extends.config.height||0]}appendChild(t,e){var r;const i=((r=t.style)===null||r===void 0?void 0:r.$layer)||"main";return this.getLayer(i).appendChild(t,e)}setRenderer(t){if(t===this.extends.renderer)return;const e=TT(t,this.config.enableMultiLayer?CT:ST);this.extends.renderers=e,Object.entries(e).forEach(([r,i])=>this.getLayer(r).setRenderer(i)),MT(this.getLayers())}getCanvasByViewport(t){return oi(this.getLayer().viewport2Canvas(Js(t)))}getViewportByCanvas(t){return oi(this.getLayer().canvas2Viewport(Js(t)))}getViewportByClient(t){return oi(this.getLayer().client2Viewport(Js(t)))}getClientByViewport(t){return oi(this.getLayer().viewport2Client(Js(t)))}getClientByCanvas(t){return this.getClientByViewport(this.getViewportByCanvas(t))}getCanvasByClient(t){const e=this.getLayer(),r=e.client2Viewport(Js(t));return oi(e.viewport2Canvas(r))}toDataURL(){return kT(this,arguments,void 0,function*(t={}){const e=globalThis.devicePixelRatio||1,{mode:r="viewport"}=t,i=AT(t,["mode"]);let[a,o,s,u]=[0,0,0,0];if(r==="viewport")[s,u]=this.getSize();else if(r==="overall"){const x=this.getBounds(),E=zu(x);[a,o]=x.min,[s,u]=E}const c=b1('<div id="virtual-image"></div>'),l=new I1({width:s,height:u,renderer:new gh,devicePixelRatio:e,container:c,background:this.extends.config.background});yield l.ready,l.appendChild(this.getLayer("background").getRoot().cloneNode(!0)),l.appendChild(this.getRoot().cloneNode(!0));const d=this.getLayer("label").getRoot().cloneNode(!0),p=l.viewport2Canvas({x:0,y:0}),g=this.getCanvasByViewport([0,0]);d.translate([g[0]-p.x,g[1]-p.y]),d.scale(1/this.getCamera().getZoom()),l.appendChild(d),l.appendChild(this.getLayer("transient").getRoot().cloneNode(!0));const m=this.getCamera(),y=l.getCamera();if(r==="viewport")y.setZoom(m.getZoom()),y.setPosition(m.getPosition()),y.setFocalPoint(m.getFocalPoint());else if(r==="overall"){const[x,E,w]=y.getPosition(),[S,k,A]=y.getFocalPoint();y.setPosition([x+a,E+o,w]),y.setFocalPoint([S+a,k+o,A])}const v=l.getContextService();return new Promise(x=>{l.addEventListener(cr.RERENDER,()=>kT(this,void 0,void 0,function*(){yield new Promise(w=>setTimeout(w,300));const E=yield v.toDataURL(i);x(E)}))})})}destroy(){Object.values(this.getLayers()).forEach(t=>{t.getCamera().cancelLandmarkAnimation(),t.destroy()})}}function TT(n,t){return Object.fromEntries(t.map(e=>{const r=(n==null?void 0:n(e))||new gh;return r instanceof gh&&r.setConfig({enableDirtyRectangleRendering:!1}),e==="main"?r.registerPlugin(new tJ({isDocumentDraggable:!0,isDocumentDroppable:!0,dragstartDistanceThreshold:10,dragstartTimeThreshold:100})):r.unregisterPlugin(r.getPlugin("dom-interaction")),[e,r]}))}function MT(n){Object.entries(n).forEach(([t,e])=>{const r=e.getContextService().getDomElement();r!=null&&r.style&&(r.style.gridArea="1 / 1 / 2 / 2",r.style.outline="none",r.tabIndex=1,t!=="main"&&(r.style.pointerEvents="none")),r!=null&&r.parentElement&&(r.parentElement.style.display="grid",r.parentElement.style.isolation="isolate")})}const zo=n=>n?parseInt(n):0;function nJ(n){const t=getComputedStyle(n),e=n.clientWidth||zo(t.width),r=n.clientHeight||zo(t.height),i=zo(t.paddingLeft)+zo(t.paddingRight),a=zo(t.paddingTop)+zo(t.paddingBottom);return[e-i,r-a]}function _T(n){if(!n)return[0,0];let t=640,e=480;const[r,i]=nJ(n);t=r||t,e=i||e;const a=1,o=1;return[Math.max(Xt(t)?t:a,a),Math.max(Xt(e)?e:o,o)]}class Td{constructor(t){this.type=t}}class Xe extends Td{constructor(t,e){super(t),this.data=e}}class Tr extends Td{constructor(t,e,r,i){super(t),this.animationType=e,this.animation=r,this.data=i}}class Fo extends Td{constructor(t,e,r){super(t),this.elementType=e,this.data=r}}class kl extends Td{constructor(t,e){super(t),this.data=e}}function an(n,t){n.emit(t.type,t)}function rJ(n){if(!n)return null;if(n instanceof S_)return{type:"canvas",element:n};let t=n;for(;t;){if(Vu(t))return{type:"node",element:t};if(EO(t))return{type:"edge",element:t};if(Bb(t))return{type:"combo",element:t};t=t.parentElement}return null}function OT(n){var t;return((t=n==null?void 0:n.style)===null||t===void 0?void 0:t.zIndex)||0}const yu="cachedStyle",lx=n=>`__${n}__`;function iJ(n,t){const e=Array.isArray(t)?t:[t];lr(n,yu)||Xl(n,yu,{}),e.forEach(r=>{Xl(lr(n,yu),lx(r),n.attributes[r])})}function PT(n,t){return lr(n,[yu,lx(t)])}function aJ(n,t){return lx(t)in(lr(n,yu)||{})}class oJ{constructor(t){this.tasks=[],this.animations=new Set,this.context=t}getTasks(){const t=[...this.tasks];return this.tasks=[],t}add(t,e){this.tasks.push([t,e])}animate(t,e,r){var i,a,o;(i=e==null?void 0:e.before)===null||i===void 0||i.call(e);const s=this.getTasks().map(([c,l])=>{var d,p,g;const{element:m,elementType:y,stage:v}=c,x=eU(this.context.options,y,v,t);(d=l==null?void 0:l.before)===null||d===void 0||d.call(l);const E=x.length?rU(m,this.inferStyle(c,r),x):null;return E?((p=l==null?void 0:l.beforeAnimate)===null||p===void 0||p.call(l,E),E.finished.then(()=>{var w,S;(w=l==null?void 0:l.afterAnimate)===null||w===void 0||w.call(l,E),(S=l==null?void 0:l.after)===null||S===void 0||S.call(l),this.animations.delete(E)})):(g=l==null?void 0:l.after)===null||g===void 0||g.call(l),E}).filter(Boolean);s.forEach(c=>this.animations.add(c));const u=Pb(s);return u?((a=e==null?void 0:e.beforeAnimate)===null||a===void 0||a.call(e,u),u.finished.then(()=>{var c,l;(c=e==null?void 0:e.afterAnimate)===null||c===void 0||c.call(e,u),(l=e==null?void 0:e.after)===null||l===void 0||l.call(e),this.release()})):(o=e==null?void 0:e.after)===null||o===void 0||o.call(e),u}inferStyle(t,e){var r,i;const{element:a,elementType:o,stage:s,originalStyle:u,updatedStyle:c={}}=t;t.modifiedStyle||(t.modifiedStyle=Object.assign(Object.assign({},u),c));const{modifiedStyle:l}=t,d={},p={};if(s==="enter")Object.assign(d,{opacity:0});else if(s==="exit")Object.assign(p,{opacity:0});else if(s==="show")Object.assign(d,{opacity:0}),Object.assign(p,{opacity:(r=PT(a,"opacity"))!==null&&r!==void 0?r:ah("opacity")});else if(s==="hide")Object.assign(d,{opacity:(i=PT(a,"opacity"))!==null&&i!==void 0?i:ah("opacity")}),Object.assign(p,{opacity:0});else if(s==="collapse"){const{collapse:g}=e||{},{target:m,descendants:y,position:v}=g;if(o==="node"){if(y.includes(a.id)){const[x,E,w]=v;Object.assign(p,{x,y:E,z:w})}}else if(o==="combo"){if(a.id===m||y.includes(a.id)){const[x,E]=v;Object.assign(p,{x,y:E,childrenNode:u.childrenNode})}}else o==="edge"&&Object.assign(p,{sourceNode:l.sourceNode,targetNode:l.targetNode})}else if(s==="expand"){const{expand:g}=e||{},{target:m,descendants:y,position:v}=g;if(o==="node"){if(a.id===m||y.includes(a.id)){const[x,E,w]=v;Object.assign(d,{x,y:E,z:w})}}else if(o==="combo"){if(a.id===m||y.includes(a.id)){const[x,E,w]=v;Object.assign(d,{x,y:E,z:w,childrenNode:l.childrenNode})}}else o==="edge"&&Object.assign(d,{sourceNode:l.sourceNode,targetNode:l.targetNode})}return[Object.keys(d).length>0?Object.assign({},u,d):u,Object.keys(p).length>0?Object.assign({},l,p):l]}stop(){this.animations.forEach(t=>t.cancel())}clear(){this.tasks=[]}release(){var t,e;const{canvas:r}=this.context,i=(e=(t=r.document)===null||t===void 0?void 0:t.timeline)===null||e===void 0?void 0:e.animationsWithPromises;i&&(r.document.timeline.animationsWithPromises=i.filter(a=>a.playState!=="finished"))}destroy(){this.stop(),this.animations.clear(),this.tasks=[]}}class sJ{constructor(t){this.batchCount=0,this.context=t}emit(t){const{graph:e}=this.context;e.emit(t.type,t)}startBatch(t=!0){this.batchCount++,this.batchCount===1&&this.emit(new Xe(gt.BATCH_START,{initiate:t}))}endBatch(){this.batchCount--,this.batchCount===0&&this.emit(new Xe(gt.BATCH_END))}get isBatching(){return this.batchCount>0}destroy(){this.context=null}}class uJ extends Db{constructor(t){super(t),this.currentTarget=null,this.currentTargetType=null,this.category="behavior",this.forwardCanvasEvents=e=>{const{target:r}=e,i=rJ(r);if(!i)return;const{graph:a,canvas:o}=this.context,{type:s,element:u}=i;if("destroyed"in u&&(Uu(u)||u.destroyed))return;const{type:c,detail:l,button:d}=e,p=Object.assign(Object.assign({},e),{target:u,targetType:s,originalTarget:r});c===st.POINTER_MOVE&&(this.currentTarget!==u&&(this.currentTarget&&a.emit(`${this.currentTargetType}:${st.POINTER_LEAVE}`,Object.assign(Object.assign({},p),{type:st.POINTER_LEAVE,target:this.currentTarget,targetType:this.currentTargetType})),u&&(Object.assign(p,{type:st.POINTER_ENTER}),a.emit(`${s}:${st.POINTER_ENTER}`,p))),this.currentTarget=u,this.currentTargetType=s),c===st.CLICK&&d===2||(a.emit(`${s}:${c}`,p),a.emit(c,p)),c===st.CLICK&&l===2&&(Object.assign(p,{type:st.DBLCLICK}),a.emit(`${s}:${st.DBLCLICK}`,p),a.emit(st.DBLCLICK,p)),c===st.POINTER_DOWN&&d===2&&(Object.assign(p,{type:st.CONTEXT_MENU,preventDefault:()=>{var g;(g=o.getContainer())===null||g===void 0||g.addEventListener(st.CONTEXT_MENU,m=>m.preventDefault(),{once:!0})}}),a.emit(`${s}:${st.CONTEXT_MENU}`,p),a.emit(st.CONTEXT_MENU,p))},this.forwardContainerEvents=e=>{this.context.graph.emit(e.type,e)},this.forwardEvents(),this.setBehaviors(this.context.options.behaviors||[])}setBehaviors(t){this.setExtensions(t)}forwardEvents(){const t=this.context.canvas.getContainer();t&&[$o.KEY_DOWN,$o.KEY_UP].forEach(r=>{t.addEventListener(r,this.forwardContainerEvents)});const e=this.context.canvas.document;e&&[st.CLICK,st.DBLCLICK,st.POINTER_OVER,st.POINTER_LEAVE,st.POINTER_ENTER,st.POINTER_MOVE,st.POINTER_OUT,st.POINTER_DOWN,st.POINTER_UP,st.CONTEXT_MENU,st.DRAG_START,st.DRAG,st.DRAG_END,st.DRAG_ENTER,st.DRAG_OVER,st.DRAG_LEAVE,st.DROP,st.WHEEL].forEach(r=>{e.addEventListener(r,this.forwardCanvasEvents)})}destroy(){const t=this.context.canvas.getContainer();t&&[$o.KEY_DOWN,$o.KEY_UP].forEach(e=>{t.removeEventListener(e,this.forwardContainerEvents)}),this.context.canvas.document.removeAllEventListeners(),super.destroy()}}var Pu=function(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(e[r[i]]=n[r[i]]);return e};function ea(n,t){const{data:e,style:r}=n,i=Pu(n,["data","style"]),{data:a,style:o}=t,s=Pu(t,["data","style"]),u=Object.assign(Object.assign({},i),s);return(e||a)&&Object.assign(u,{data:Object.assign(Object.assign({},e),a)}),(r||o)&&Object.assign(u,{style:Object.assign(Object.assign({},r),o)}),u}function qy(n){const{data:t,style:e}=n,r=Pu(n,["data","style"]);return t&&(r.data=Object.assign({},t)),e&&(r.style=Object.assign({},e)),r}function Go(n={},t={}){const{states:e=[],data:r={},style:i={},children:a=[]}=n,o=Pu(n,["states","data","style","children"]),{states:s=[],data:u={},style:c={},children:l=[]}=t,d=Pu(t,["states","data","style","children"]),p=(m,y)=>m.length!==y.length?!1:m.every((v,x)=>v===y[x]),g=(m,y)=>{const v=Object.keys(m),x=Object.keys(y);return v.length!==x.length?!1:v.every(E=>m[E]===y[E])};return!(!g(o,d)||!p(a,l)||!p(e,s)||!g(r,u)||!g(i,c))}var cJ=function(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(e[r[i]]=n[r[i]]);return e};function Ky(n){const{id:t=Z(n),style:e,data:r}=n,i=cJ(n,["id","style","data"]),a=Object.assign(Object.assign({},n),{style:Object.assign({},e),data:Object.assign({},r)});return iU(n)?Object.assign({id:t,data:a},i):{id:t,data:a}}function cn(n){return n.data}function lJ(n){if(n.hasTreeStructure(Yr))return;n.attachTreeStructure(Yr);const t=n.getAllEdges();for(const e of t){const{source:r,target:i}=e;n.setParent(i,r,Yr)}}class hJ{constructor(){this.latestRemovedComboIds=new Set,this.comboIds=new Set,this.changes=[],this.batchCount=0,this.isTraceless=!1,this.enableUpdateNodeLikeHierarchy=!0,this.model=new qh}pushChange(t){if(this.isTraceless)return;const{type:e}=t;if(e===Se.NodeUpdated||e===Se.EdgeUpdated||e===Se.ComboUpdated){const{value:r,original:i}=t;this.changes.push({value:qy(r),original:qy(i),type:e})}else this.changes.push({value:qy(t.value),type:e})}getChanges(){return this.changes}clearChanges(){this.changes=[]}batch(t){this.batchCount++,this.model.batch(t),this.batchCount--}isBatching(){return this.batchCount>0}silence(t){this.isTraceless=!0,t(),this.isTraceless=!1}isCombo(t){return this.comboIds.has(t)||this.latestRemovedComboIds.has(t)}getData(){return{nodes:this.getNodeData(),edges:this.getEdgeData(),combos:this.getComboData()}}getNodeData(t){return this.model.getAllNodes().reduce((e,r)=>{const i=cn(r);return this.isCombo(Z(i))||(t===void 0||t.includes(Z(i)))&&e.push(i),e},[])}getEdgeDatum(t){return cn(this.model.getEdge(t))}getEdgeData(t){return this.model.getAllEdges().reduce((e,r)=>{const i=cn(r);return(t===void 0||t.includes(Z(i)))&&e.push(i),e},[])}getComboData(t){return this.model.getAllNodes().reduce((e,r)=>{const i=cn(r);return this.isCombo(Z(i))&&(t===void 0||t.includes(Z(i)))&&e.push(i),e},[])}getRootsData(t=Yr){return this.model.getRoots(t).map(cn)}getAncestorsData(t,e){const{model:r}=this;return!r.hasNode(t)||!r.hasTreeStructure(e)?[]:r.getAncestors(t,e).map(cn)}getDescendantsData(t){const e=this.getElementDataById(t),r=[];return Qo(e,i=>{i!==e&&r.push(i)},i=>this.getChildrenData(Z(i)),"TB"),r}getParentData(t,e){const{model:r}=this;if(!e){ka.warn("The hierarchy structure key is not specified");return}if(!r.hasNode(t)||!r.hasTreeStructure(e))return;const i=r.getParent(t,e);return i?cn(i):void 0}getChildrenData(t){const e=this.getElementType(t)==="node"?Yr:me,{model:r}=this;return!r.hasNode(t)||!r.hasTreeStructure(e)?[]:r.getChildren(t,e).map(cn)}getElementsDataByType(t){return t==="node"?this.getNodeData():t==="edge"?this.getEdgeData():t==="combo"?this.getComboData():[]}getElementDataById(t){return this.getElementType(t)==="edge"?this.getEdgeDatum(t):this.getNodeLikeDatum(t)}getNodeLikeDatum(t){const e=this.model.getNode(t);return cn(e)}getNodeLikeData(t){return this.model.getAllNodes().reduce((e,r)=>{const i=cn(r);return t?t.includes(Z(i))&&e.push(i):e.push(i),e},[])}getElementDataByState(t,e){return this.getElementsDataByType(t).filter(r=>{var i;return(i=r.states)===null||i===void 0?void 0:i.includes(e)})}getElementState(t){var e;return((e=this.getElementDataById(t))===null||e===void 0?void 0:e.states)||[]}hasNode(t){return this.model.hasNode(t)&&!this.isCombo(t)}hasEdge(t){return this.model.hasEdge(t)}hasCombo(t){return this.model.hasNode(t)&&this.isCombo(t)}getRelatedEdgesData(t,e="both"){return this.model.getRelatedEdges(t,e).map(cn)}getNeighborNodesData(t){return this.model.getNeighbors(t).map(cn)}setData(t){const{nodes:e=[],edges:r=[],combos:i=[]}=t,{nodes:a,edges:o,combos:s}=this.getData(),u=mu(a,e,d=>Z(d),Go),c=mu(o,r,d=>Z(d),Go),l=mu(s,i,d=>Z(d),Go);this.batch(()=>{const d={nodes:u.enter,edges:c.enter,combos:l.enter};this.addData(d),this.computeZIndex(d,"add",!0);const p={nodes:u.update,edges:c.update,combos:l.update};this.updateData(p),this.computeZIndex(p,"update",!0);const g={nodes:u.exit.map(Z),edges:c.exit.map(Z),combos:l.exit.map(Z)};this.removeData(g)})}addData(t){const{nodes:e,edges:r,combos:i}=t;this.batch(()=>{this.addComboData(i),this.addNodeData(e),this.addEdgeData(r)}),this.computeZIndex(t,"add")}addNodeData(t=[]){t.length&&(this.model.addNodes(t.map(e=>(this.pushChange({value:e,type:Se.NodeAdded}),Ky(e)))),this.updateNodeLikeHierarchy(t),this.computeZIndex({nodes:t},"add"))}addEdgeData(t=[]){t.length&&(this.model.addEdges(t.map(e=>(this.pushChange({value:e,type:Se.EdgeAdded}),Ky(e)))),this.computeZIndex({edges:t},"add"))}addComboData(t=[]){if(!t.length)return;const{model:e}=this;e.hasTreeStructure(me)||e.attachTreeStructure(me),e.addNodes(t.map(r=>(this.comboIds.add(Z(r)),this.pushChange({value:r,type:Se.ComboAdded}),Ky(r)))),this.updateNodeLikeHierarchy(t),this.computeZIndex({combos:t},"add")}addChildrenData(t,e){const r=this.getNodeLikeDatum(t),i=e.map(Z);this.addNodeData(e),this.updateNodeData([{id:t,children:[...r.children||[],...i]}]),this.addEdgeData(i.map(a=>({source:t,target:a})))}computeZIndex(t,e,r=!1){!r&&this.isBatching()||this.batch(()=>{const{nodes:i=[],edges:a=[],combos:o=[]}=t;o.forEach(s=>{var u,c,l;const d=Z(s);if(e==="add"&&Xt((u=s.style)===null||u===void 0?void 0:u.zIndex)||e==="update"&&!("combo"in s))return;const p=this.getParentData(d,me),g=p?((l=(c=p.style)===null||c===void 0?void 0:c.zIndex)!==null&&l!==void 0?l:0)+1:0;this.preventUpdateNodeLikeHierarchy(()=>{this.updateComboData([{id:d,style:{zIndex:g}}])})}),i.forEach(s=>{var u,c,l;const d=Z(s);if(e==="add"&&Xt((u=s.style)===null||u===void 0?void 0:u.zIndex)||e==="update"&&!("combo"in s)&&!("children"in s))return;let p=0;const g=this.getParentData(d,me);if(g)p=(((c=g.style)===null||c===void 0?void 0:c.zIndex)||0)+1;else{const m=this.getParentData(d,Yr);m&&(p=((l=m==null?void 0:m.style)===null||l===void 0?void 0:l.zIndex)||0)}this.preventUpdateNodeLikeHierarchy(()=>{this.updateNodeData([{id:d,style:{zIndex:p}}])})}),a.forEach(s=>{var u,c,l,d,p;if(Xt((u=s.style)===null||u===void 0?void 0:u.zIndex))return;let{id:g,source:m,target:y}=s;if(!g)g=Z(s);else{const E=this.getEdgeDatum(g);m=E.source,y=E.target}if(!m||!y)return;const v=((l=(c=this.getNodeLikeDatum(m))===null||c===void 0?void 0:c.style)===null||l===void 0?void 0:l.zIndex)||0,x=((p=(d=this.getNodeLikeDatum(y))===null||d===void 0?void 0:d.style)===null||p===void 0?void 0:p.zIndex)||0;this.updateEdgeData([{id:Z(s),style:{zIndex:Math.max(v,x)-1}}])})})}getFrontZIndex(t){var e;const r=this.getElementType(t),i=this.getElementDataById(t),a=this.getData();if(Object.assign(a,{[`${r}s`]:a[`${r}s`].filter(o=>Z(o)!==t)}),r==="combo"&&!ba(i)){const o=new Set(this.getAncestorsData(t,me).map(Z));a.nodes=a.nodes.filter(s=>!o.has(Z(s))),a.combos=a.combos.filter(s=>!o.has(Z(s))),a.edges=a.edges.filter(({source:s,target:u})=>!o.has(s)&&!o.has(u))}return Math.max(((e=i.style)===null||e===void 0?void 0:e.zIndex)||0,0,...Object.values(a).flat().map(o=>{var s;return(((s=o==null?void 0:o.style)===null||s===void 0?void 0:s.zIndex)||0)+1}))}updateNodeLikeHierarchy(t){if(!this.enableUpdateNodeLikeHierarchy)return;const{model:e}=this;t.forEach(r=>{const i=Z(r),a=fl(r);a!==void 0&&(e.hasTreeStructure(me)||e.attachTreeStructure(me),a===null&&this.refreshComboData(i),this.setParent(i,fl(r),me));const o=r.children||[];if(o.length){e.hasTreeStructure(Yr)||e.attachTreeStructure(Yr);const s=o.filter(u=>e.hasNode(u));s.forEach(u=>this.setParent(u,i,Yr)),s.length!==o.length&&this.updateNodeData([{id:i,children:s}])}})}preventUpdateNodeLikeHierarchy(t){this.enableUpdateNodeLikeHierarchy=!1,t(),this.enableUpdateNodeLikeHierarchy=!0}updateData(t){const{nodes:e,edges:r,combos:i}=t;this.batch(()=>{this.updateNodeData(e),this.updateComboData(i),this.updateEdgeData(r)}),this.computeZIndex(t,"update")}updateNodeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch(()=>{const r=[];t.forEach(i=>{const a=Z(i),o=cn(e.getNode(a));if(Go(o,i))return;const s=ea(o,i);this.pushChange({value:s,original:o,type:Se.NodeUpdated}),e.mergeNodeData(a,s),r.push(s)}),this.updateNodeLikeHierarchy(r)}),this.computeZIndex({nodes:t},"update")}refreshData(){const{nodes:t,edges:e,combos:r}=this.getData();t.forEach(i=>{this.pushChange({value:i,original:i,type:Se.NodeUpdated})}),e.forEach(i=>{this.pushChange({value:i,original:i,type:Se.EdgeUpdated})}),r.forEach(i=>{this.pushChange({value:i,original:i,type:Se.ComboUpdated})})}syncNodeLikeDatum(t){const{model:e}=this,r=Z(t);if(!e.hasNode(r))return;const i=cn(e.getNode(r)),a=ea(i,t);e.mergeNodeData(r,a)}syncEdgeDatum(t){const{model:e}=this,r=Z(t);if(!e.hasEdge(r))return;const i=cn(e.getEdge(r)),a=ea(i,t);e.mergeEdgeData(r,a)}updateEdgeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch(()=>{t.forEach(r=>{const i=Z(r),a=cn(e.getEdge(i));if(Go(a,r))return;r.source&&a.source!==r.source&&e.updateEdgeSource(i,r.source),r.target&&a.target!==r.target&&e.updateEdgeTarget(i,r.target);const o=ea(a,r);this.pushChange({value:o,original:a,type:Se.EdgeUpdated}),e.mergeEdgeData(i,o)})}),this.computeZIndex({edges:t},"update")}updateComboData(t=[]){if(!t.length)return;const{model:e}=this;e.batch(()=>{const r=[];t.forEach(i=>{const a=Z(i),o=cn(e.getNode(a));if(Go(o,i))return;const s=ea(o,i);this.pushChange({value:s,original:o,type:Se.ComboUpdated}),e.mergeNodeData(a,s),r.push(s)}),this.updateNodeLikeHierarchy(r)}),this.computeZIndex({combos:t},"update")}setParent(t,e,r,i=!0){if(t===e)return;const a=this.getNodeLikeDatum(t),o=fl(a);if(o!==e&&r===me){const s={id:t,combo:e};this.isCombo(t)?this.syncNodeLikeDatum(s):this.syncNodeLikeDatum(s)}this.model.setParent(t,e,r),i&&r===me&&EB([o,e]).forEach(s=>{s!==void 0&&this.refreshComboData(s)})}refreshComboData(t){const e=this.getComboData([t])[0],r=this.getAncestorsData(t,me);e&&this.pushChange({value:e,original:e,type:Se.ComboUpdated}),r.forEach(i=>{this.pushChange({value:i,original:i,type:Se.ComboUpdated})})}getElementPosition(t){const e=this.getElementDataById(t);return _r(e)}translateNodeLikeBy(t,e){this.isCombo(t)?this.translateComboBy(t,e):this.translateNodeBy(t,e)}translateNodeLikeTo(t,e){this.isCombo(t)?this.translateComboTo(t,e):this.translateNodeTo(t,e)}translateNodeBy(t,e){const r=this.getElementPosition(t),i=rn(r,[...e,0].slice(0,3));this.translateNodeTo(t,i)}translateNodeTo(t,e){const[r=0,i=0,a=0]=e;this.preventUpdateNodeLikeHierarchy(()=>{this.updateNodeData([{id:t,style:{x:r,y:i,z:a}}])})}translateComboBy(t,e){const[r=0,i=0,a=0]=e;if([r,i,a].some(isNaN)||[r,i,a].every(u=>u===0))return;const o=this.getComboData([t])[0];if(!o)return;const s=new Set;Qo(o,u=>{const c=Z(u);if(s.has(c))return;s.add(c);const[l,d,p]=_r(u),g=ea(u,{style:{x:l+r,y:d+i,z:p+a}});this.pushChange({value:g,original:u,type:this.isCombo(c)?Se.ComboUpdated:Se.NodeUpdated}),this.model.mergeNodeData(c,g)},u=>this.getChildrenData(Z(u)),"BT")}translateComboTo(t,e){var r;if(e.some(isNaN))return;const[i=0,a=0,o=0]=e,s=(r=this.getComboData([t]))===null||r===void 0?void 0:r[0];if(!s)return;const[u,c,l]=_r(s),d=i-u,p=a-c,g=o-l;Qo(s,m=>{const y=Z(m),[v,x,E]=_r(m),w=ea(m,{style:{x:v+d,y:x+p,z:E+g}});this.pushChange({value:w,original:m,type:this.isCombo(y)?Se.ComboUpdated:Se.NodeUpdated}),this.model.mergeNodeData(y,w)},m=>this.getChildrenData(Z(m)),"BT")}removeData(t){const{nodes:e,edges:r,combos:i}=t;this.batch(()=>{this.removeEdgeData(r),this.removeNodeData(e),this.removeComboData(i),this.latestRemovedComboIds=new Set(i)})}removeNodeData(t=[]){t.length&&this.batch(()=>{t.forEach(e=>{this.removeEdgeData(this.getRelatedEdgesData(e).map(Z)),this.pushChange({value:this.getNodeData([e])[0],type:Se.NodeRemoved}),this.removeNodeLikeHierarchy(e)}),this.model.removeNodes(t)})}removeEdgeData(t=[]){t.length&&(t.forEach(e=>this.pushChange({value:this.getEdgeData([e])[0],type:Se.EdgeRemoved})),this.model.removeEdges(t))}removeComboData(t=[]){t.length&&this.batch(()=>{t.forEach(e=>{this.pushChange({value:this.getComboData([e])[0],type:Se.ComboRemoved}),this.removeNodeLikeHierarchy(e),this.comboIds.delete(e)}),this.model.removeNodes(t)})}removeNodeLikeHierarchy(t){if(this.model.hasTreeStructure(me)){const e=fl(this.getNodeLikeDatum(t));this.setParent(t,void 0,me,!1),this.model.getChildren(t,me).forEach(r=>{const i=cn(r),a=Z(i);this.setParent(Z(i),e,me,!1);const o=ea(i,{id:Z(i),combo:e});this.pushChange({value:o,original:i,type:this.isCombo(a)?Se.ComboUpdated:Se.NodeUpdated}),this.model.mergeNodeData(Z(i),o)}),Tt(e)||this.refreshComboData(e)}}getElementType(t){if(this.model.hasNode(t))return this.isCombo(t)?"combo":"node";if(this.model.hasEdge(t))return"edge";throw new Error(Li(`Unknown element type of id: ${t}`))}destroy(){const{model:t}=this,e=t.getAllNodes(),r=t.getAllEdges();t.removeEdges(r.map(i=>i.id)),t.removeNodes(e.map(i=>i.id)),this.context={}}}var ru=function(n,t,e,r){function i(a){return a instanceof e?a:new e(function(o){o(a)})}return new(e||(e=Promise))(function(a,o){function s(l){try{c(r.next(l))}catch(d){o(d)}}function u(l){try{c(r.throw(l))}catch(d){o(d)}}function c(l){l.done?a(l.value):i(l.value).then(s,u)}c((r=r.apply(n,t||[])).next())})};class dJ{constructor(t){this.elementMap={},this.shapeTypeMap={},this.paletteStyle={},this.defaultStyle={},this.stateStyle={},this.visibilityCache=new WeakMap,this.context=t}init(){this.initContainer()}initContainer(){if(!this.container||this.container.destroyed){const{canvas:t}=this.context;this.container=t.appendChild(new vi({className:"elements"}))}}emit(t,e){e.silence||an(this.context.graph,t)}forEachElementData(t){so.forEach(e=>{const r=this.context.model.getElementsDataByType(e);t(e,r)})}getElementType(t,e){var r;const{options:i,graph:a}=this.context,o=((r=i[t])===null||r===void 0?void 0:r.type)||e.type;return o?typeof o=="string"?o:o.call(a,e):t==="edge"?"line":"circle"}getTheme(t){return j_(this.context.options)[t]||{}}getThemeStyle(t){return this.getTheme(t).style||{}}getThemeStateStyle(t,e){const{state:r={}}=this.getTheme(t);return Object.assign({},...e.map(i=>r[i]||{}))}computePaletteStyle(){const{options:t}=this.context;this.paletteStyle={},this.forEachElementData((e,r)=>{var i,a;const o=Object.assign({},ok((i=this.getTheme(e))===null||i===void 0?void 0:i.palette),ok((a=t[e])===null||a===void 0?void 0:a.palette));o!=null&&o.field&&Object.assign(this.paletteStyle,HU(r,o))})}getPaletteStyle(t,e){const r=this.paletteStyle[e];return r?t==="edge"?{stroke:r}:{fill:r}:{}}computeElementDefaultStyle(t,e){var r;const{options:i}=this.context,a=((r=i[t])===null||r===void 0?void 0:r.style)||{};"transform"in a&&Array.isArray(a.transform)&&(a.transform=[...a.transform]),this.defaultStyle[Z(e.datum)]=ak(a,e)}computeElementsDefaultStyle(t){const{graph:e}=this.context;this.forEachElementData((r,i)=>{const a=i.length;for(let o=0;o<a;o++){const s=i[o];(t===void 0||t.includes(Z(s)))&&this.computeElementDefaultStyle(r,{datum:s,graph:e})}})}getDefaultStyle(t){return this.defaultStyle[t]||{}}getElementState(t){try{const{model:e}=this.context;return e.getElementState(t)}catch{return[]}}getElementStateStyle(t,e,r){var i,a;const{options:o}=this.context,s=((a=(i=o[t])===null||i===void 0?void 0:i.state)===null||a===void 0?void 0:a[e])||{};return ak(s,r)}computeElementStatesStyle(t,e,r){this.stateStyle[Z(r.datum)]=Object.assign({},...e.map(i=>this.getElementStateStyle(t,i,r)))}computeElementsStatesStyle(t){const{graph:e}=this.context;this.forEachElementData((r,i)=>{const a=i.length;for(let o=0;o<a;o++){const s=i[o];if(t===void 0||t.includes(Z(s))){const u=this.getElementState(Z(s));this.computeElementStatesStyle(r,u,{datum:s,graph:e})}}})}getStateStyle(t){return this.stateStyle[t]||{}}computeStyle(t,e){t&&["translate","zIndex"].includes(t)||(this.computePaletteStyle(),this.computeElementsDefaultStyle(e),this.computeElementsStatesStyle(e))}getElement(t){return this.elementMap[t]}getNodes(){return this.context.model.getNodeData().map(({id:t})=>this.elementMap[t])}getEdges(){return this.context.model.getEdgeData().map(t=>this.elementMap[Z(t)])}getCombos(){return this.context.model.getComboData().map(({id:t})=>this.elementMap[t])}getElementComputedStyle(t,e){const r=Z(e),i=this.getThemeStyle(t),a=this.getPaletteStyle(t,r),o=e.style||{},s=this.getDefaultStyle(r),u=this.getThemeStateStyle(t,this.getElementState(r)),c=this.getStateStyle(r),l=Object.assign({},i,a,o,s,u,c);if(t==="combo"){const d=this.context.model.getChildrenData(r),p=l.collapsed?[]:d.map(Z).filter(g=>this.getElement(g));Object.assign(l,{childrenNode:p,childrenData:d})}return l}getDrawData(t){this.init();const e=this.computeChangesAndDrawData(t);if(!e)return null;const{type:r="draw",stage:i=r}=t;return this.markDestroyElement(e.drawData),this.computeStyle(i),{type:r,stage:i,data:e}}draw(t={animation:!0}){const e=this.getDrawData(t);if(!e)return;const{data:{drawData:{add:r,update:i,remove:a}}}=e;return this.destroyElements(a,t),this.createElements(r,t),this.updateElements(i,t),this.setAnimationTask(t,e)}preLayoutDraw(){return ru(this,arguments,void 0,function*(t={animation:!0}){var e,r;const i=this.getDrawData(t);if(!i)return;const{data:{drawData:a}}=i;yield(r=(e=this.context.layout)===null||e===void 0?void 0:e.preLayout)===null||r===void 0?void 0:r.call(e,a);const{add:o,update:s,remove:u}=a;return this.destroyElements(u,t),this.createElements(o,t),this.updateElements(s,t),this.setAnimationTask(t,i)})}setAnimationTask(t,e){const{animation:r,silence:i}=t,{data:{dataChanges:a,drawData:o},stage:s,type:u}=e;return this.context.animation.animate(r,i?{}:{before:()=>this.emit(new Xe(gt.BEFORE_DRAW,{dataChanges:a,animation:r,stage:s,render:u==="render"}),t),beforeAnimate:c=>this.emit(new Tr(gt.BEFORE_ANIMATE,$n.DRAW,c,o),t),afterAnimate:c=>this.emit(new Tr(gt.AFTER_ANIMATE,$n.DRAW,c,o),t),after:()=>this.emit(new Xe(gt.AFTER_DRAW,{dataChanges:a,animation:r,stage:s,render:u==="render",firstRender:this.context.graph.rendered===!1}),t)})}computeChangesAndDrawData(t){const{model:e}=this.context,r=e.getChanges(),i=UP(r);if(i.length===0)return null;const{NodeAdded:a=[],NodeUpdated:o=[],NodeRemoved:s=[],EdgeAdded:u=[],EdgeUpdated:c=[],EdgeRemoved:l=[],ComboAdded:d=[],ComboUpdated:p=[],ComboRemoved:g=[]}=Mh(i,x=>x.type),m=x=>new Map(x.map(E=>{const w=E.value;return[Z(w),w]})),y={add:{nodes:m(a),edges:m(u),combos:m(d)},update:{nodes:m(o),edges:m(c),combos:m(p)},remove:{nodes:m(s),edges:m(l),combos:m(g)}},v=this.transformData(y,t);return e.clearChanges(),{dataChanges:r,drawData:v}}transformData(t,e){const r=this.context.transform.getTransformInstance();return Object.values(r).reduce((i,a)=>a.beforeDraw(i,e),t)}createElement(t,e,r){var i;const a=Z(e);if(this.getElement(a))return;const o=this.getElementType(t,e),s=this.getElementComputedStyle(t,e),u=ji(t,o);if(!u)return ka.warn(`The element ${o} of ${t} is not registered.`);this.emit(new Fo(gt.BEFORE_ELEMENT_CREATE,t,e),r);const c=this.container.appendChild(new u({id:a,context:this.context,style:s}));this.shapeTypeMap[a]=o,this.elementMap[a]=c;const{stage:l="enter"}=r;(i=this.context.animation)===null||i===void 0||i.add({element:c,elementType:t,stage:l,originalStyle:Object.assign({},c.attributes),updatedStyle:s},{after:()=>{var d;this.emit(new Fo(gt.AFTER_ELEMENT_CREATE,t,e),r),(d=c.onCreate)===null||d===void 0||d.call(c)}})}createElements(t,e){const{nodes:r,edges:i,combos:a}=t;[["node",r],["combo",a],["edge",i]].forEach(([o,s])=>{s.forEach(u=>this.createElement(o,u,e))})}getUpdateStageStyle(t,e,r){const{stage:i="update"}=r;if(i==="translate")if(t==="node"||t==="combo"){const{style:{x:a=0,y:o=0,z:s=0}={}}=e;return{x:a,y:o,z:s}}else return{};return this.getElementComputedStyle(t,e)}updateElement(t,e,r){var i;const a=Z(e),{stage:o="update"}=r,s=this.getElement(a);if(!s)return()=>null;this.emit(new Fo(gt.BEFORE_ELEMENT_UPDATE,t,e),r);const u=this.getElementType(t,e),c=this.getUpdateStageStyle(t,e,r);this.shapeTypeMap[a]!==u&&(s.destroy(),delete this.shapeTypeMap[a],delete this.elementMap[a],this.createElement(t,e,{animation:!1,silence:!0}));const l=o!=="visibility"?o:c.visibility==="hidden"?"hide":"show";l==="hide"&&delete c.visibility,(i=this.context.animation)===null||i===void 0||i.add({element:s,elementType:t,stage:l,originalStyle:Object.assign({},s.attributes),updatedStyle:c},{before:()=>{const d=this.elementMap[a];o!=="collapse"&&H1(d,c),o==="visibility"&&(aJ(d,"opacity")||iJ(d,"opacity"),this.visibilityCache.set(d,l==="show"?"visible":"hidden"),l==="show"&&oo(d,"visible"))},after:()=>{var d;const p=this.elementMap[a];o==="collapse"&&H1(p,c),l==="hide"&&oo(p,this.visibilityCache.get(p)),this.emit(new Fo(gt.AFTER_ELEMENT_UPDATE,t,e),r),(d=p.onUpdate)===null||d===void 0||d.call(p)}})}updateElements(t,e){const{nodes:r,edges:i,combos:a}=t;[["node",r],["combo",a],["edge",i]].forEach(([o,s])=>{s.forEach(u=>this.updateElement(o,u,e))})}markDestroyElement(t){Object.values(t.remove).forEach(e=>{e.forEach(r=>{const i=Z(r),a=this.getElement(i);a&&CY(a)})})}destroyElement(t,e,r){var i;const{stage:a="exit"}=r,o=Z(e),s=this.elementMap[o];if(!s)return()=>null;this.emit(new Fo(gt.BEFORE_ELEMENT_DESTROY,t,e),r),(i=this.context.animation)===null||i===void 0||i.add({element:s,elementType:t,stage:a,originalStyle:Object.assign({},s.attributes),updatedStyle:{}},{after:()=>{var u;this.clearElement(o),s.destroy(),(u=s.onDestroy)===null||u===void 0||u.call(s),this.emit(new Fo(gt.AFTER_ELEMENT_DESTROY,t,e),r)}})}destroyElements(t,e){const{nodes:r,edges:i,combos:a}=t;[["combo",a],["edge",i],["node",r]].forEach(([o,s])=>{s.forEach(u=>this.destroyElement(o,u,e))})}clearElement(t){delete this.paletteStyle[t],delete this.defaultStyle[t],delete this.stateStyle[t],delete this.elementMap[t],delete this.shapeTypeMap[t]}alignLayoutResultToElement(t,e){var r,i;const a=(r=t.nodes)===null||r===void 0?void 0:r.find(o=>Z(o)===e);if(a){const o=_r(this.context.model.getNodeLikeDatum(e)),s=_r(a),u=Mn(o,s);(i=t.nodes)===null||i===void 0||i.forEach(c=>{var l,d,p;!((l=c.style)===null||l===void 0)&&l.x&&(c.style.x+=u[0]),!((d=c.style)===null||d===void 0)&&d.y&&(c.style.y+=u[1]),!((p=c.style)===null||p===void 0)&&p.z&&(c.style.z+=u[2]||0)})}}collapseNode(t,e){return ru(this,void 0,void 0,function*(){var r;const{animation:i}=e,a=this.computeChangesAndDrawData({stage:"collapse",animation:i});if(!a)return;const{drawData:o}=a,{add:s,remove:u,update:c}=o;this.markDestroyElement(o);const l={animation:i,stage:"collapse",data:o};this.destroyElements(u,l),this.createElements(s,l),this.updateElements(c,l),yield(r=this.context.animation.animate(i,{beforeAnimate:d=>this.emit(new Tr(gt.BEFORE_ANIMATE,$n.COLLAPSE,d,o),l),afterAnimate:d=>this.emit(new Tr(gt.AFTER_ANIMATE,$n.COLLAPSE,d,o),l)},{collapse:{target:t,descendants:Array.from(u.nodes).map(([,d])=>Z(d)),position:_r(c.nodes.get(t))}}))===null||r===void 0?void 0:r.finished})}expandNode(t,e){return ru(this,void 0,void 0,function*(){var r;const{model:i}=this.context,{animation:a}=e,o=_r(i.getNodeData([t])[0]),s=this.computeChangesAndDrawData({stage:"expand",animation:a});if(this.createElements(s.drawData.add,{animation:!1,stage:"expand",target:t}),this.context.animation.clear(),this.computeStyle("expand"),!s)return;const{drawData:u}=s,{update:c,add:l}=u,d={animation:a,stage:"expand",data:u};l.edges.forEach(p=>c.edges.set(Z(p),p)),l.nodes.forEach(p=>c.nodes.set(Z(p),p)),this.updateElements(c,d),yield(r=this.context.animation.animate(a,{beforeAnimate:p=>this.emit(new Tr(gt.BEFORE_ANIMATE,$n.EXPAND,p,u),d),afterAnimate:p=>this.emit(new Tr(gt.AFTER_ANIMATE,$n.EXPAND,p,u),d)},{expand:{target:t,descendants:Array.from(l.nodes).map(([,p])=>Z(p)),position:o}}))===null||r===void 0?void 0:r.finished})}collapseCombo(t,e){return ru(this,void 0,void 0,function*(){var r;const{model:i,element:a}=this.context;if(i.getAncestorsData(t,me).some(y=>ba(y)))return;const o=a.getElement(t),s=o.getComboPosition(Object.assign(Object.assign({},o.attributes),{collapsed:!0})),u=this.computeChangesAndDrawData({stage:"collapse",animation:e});if(!u)return;const{dataChanges:c,drawData:l}=u;this.markDestroyElement(l);const{update:d,remove:p}=l,g={animation:e,stage:"collapse",data:l};this.destroyElements(p,g),this.updateElements(d,g);const m=y=>Array.from(y).map(([,v])=>Z(v));yield(r=this.context.animation.animate(e,{before:()=>this.emit(new Xe(gt.BEFORE_DRAW,{dataChanges:c,animation:e}),g),beforeAnimate:y=>this.emit(new Tr(gt.BEFORE_ANIMATE,$n.COLLAPSE,y,l),g),afterAnimate:y=>this.emit(new Tr(gt.AFTER_ANIMATE,$n.COLLAPSE,y,l),g),after:()=>this.emit(new Xe(gt.AFTER_DRAW,{dataChanges:c,animation:e}),g)},{collapse:{target:t,descendants:[...m(p.nodes),...m(p.combos)],position:s}}))===null||r===void 0?void 0:r.finished})}expandCombo(t,e){return ru(this,void 0,void 0,function*(){var r;const{model:i}=this.context,a=_r(i.getComboData([t])[0]);this.computeStyle("expand");const o=this.computeChangesAndDrawData({stage:"expand",animation:e});if(!o)return;const{dataChanges:s,drawData:u}=o,{add:c,update:l}=u,d={animation:e,stage:"expand",data:u,target:t};this.createElements(c,d),this.updateElements(l,d);const p=g=>Array.from(g).map(([,m])=>Z(m));yield(r=this.context.animation.animate(e,{before:()=>this.emit(new Xe(gt.BEFORE_DRAW,{dataChanges:s,animation:e}),d),beforeAnimate:g=>this.emit(new Tr(gt.BEFORE_ANIMATE,$n.EXPAND,g,u),d),afterAnimate:g=>this.emit(new Tr(gt.AFTER_ANIMATE,$n.EXPAND,g,u),d),after:()=>this.emit(new Xe(gt.AFTER_DRAW,{dataChanges:s,animation:e}),d)},{expand:{target:t,descendants:[...p(c.nodes),...p(c.combos)],position:a}}))===null||r===void 0?void 0:r.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 Vo=function(n,t,e,r){function i(a){return a instanceof e?a:new e(function(o){o(a)})}return new(e||(e=Promise))(function(a,o){function s(l){try{c(r.next(l))}catch(d){o(d)}}function u(l){try{c(r.throw(l))}catch(d){o(d)}}function c(l){l.done?a(l.value):i(l.value).then(s,u)}c((r=r.apply(n,t||[])).next())})},fJ=function(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(e[r[i]]=n[r[i]]);return e};class pJ{get presetOptions(){return{animation:!!B_(this.context.options,!0)}}get options(){const{options:t}=this.context;return t.layout}constructor(t){this.instances=[],this.context=t}getLayoutInstance(){return this.instances}preLayout(t){return Vo(this,void 0,void 0,function*(){var e,r,i,a;const{graph:o,model:s}=this.context,{add:u}=t;an(o,new Xe(gt.BEFORE_LAYOUT,{type:"pre"}));const c=yield(e=this.context.layout)===null||e===void 0?void 0:e.simulate();(r=c==null?void 0:c.nodes)===null||r===void 0||r.forEach(l=>{const d=Z(l),p=u.nodes.get(d);s.syncNodeLikeDatum(l),p&&Object.assign(p.style,l.style)}),(i=c==null?void 0:c.edges)===null||i===void 0||i.forEach(l=>{const d=Z(l),p=u.edges.get(d);s.syncEdgeDatum(l),p&&Object.assign(p.style,l.style)}),(a=c==null?void 0:c.combos)===null||a===void 0||a.forEach(l=>{const d=Z(l),p=u.combos.get(d);s.syncNodeLikeDatum(l),p&&Object.assign(p.style,l.style)}),an(o,new Xe(gt.AFTER_LAYOUT,{type:"pre"})),this.transformDataAfterLayout("pre",t)})}postLayout(){return Vo(this,arguments,void 0,function*(t=this.options){if(!t)return;const e=Array.isArray(t)?t:[t],{graph:r}=this.context;an(r,new Xe(gt.BEFORE_LAYOUT,{type:"post"}));for(let i=0;i<e.length;i++){const a=e[i],o=this.getLayoutData(a),s=Object.assign(Object.assign({},this.presetOptions),a);an(r,new Xe(gt.BEFORE_STAGE_LAYOUT,{options:s,index:i}));const u=yield this.stepLayout(o,s,i);an(r,new Xe(gt.AFTER_STAGE_LAYOUT,{options:s,index:i})),a.animation||this.updateElementPosition(u,!1)}an(r,new Xe(gt.AFTER_LAYOUT,{type:"post"})),this.transformDataAfterLayout("post")})}transformDataAfterLayout(t,e){const r=this.context.transform.getTransformInstance();Object.values(r).forEach(i=>i.afterLayout(t,e))}simulate(){return Vo(this,void 0,void 0,function*(){if(!this.options)return{};const t=Array.isArray(this.options)?this.options:[this.options];let e={};for(let r=0;r<t.length;r++){const i=t[r],a=this.getLayoutData(i);e=yield this.stepLayout(a,Object.assign(Object.assign(Object.assign({},this.presetOptions),i),{animation:!1}),r)}return e})}stepLayout(t,e,r){return Vo(this,void 0,void 0,function*(){return PY(e)?yield this.treeLayout(t,e,r):yield this.graphLayout(t,e,r)})}graphLayout(t,e,r){return Vo(this,void 0,void 0,function*(){const{animation:i,enableWorker:a,iterations:o=300}=e,s=this.initGraphLayout(e);if(!s)return{};if(this.instances[r]=s,this.instance=s,a){const c=s;return this.supervisor=new NK(c.graphData2LayoutModel(t),c.instance,{iterations:o}),Rl(yield this.supervisor.execute())}if(Pk(s))return i?yield s.execute(t,{onTick:c=>{this.updateElementPosition(c,!1)}}):(s.execute(t),s.stop(),s.tick(o));const u=yield s.execute(t);if(i){const c=this.updateElementPosition(u,i);yield c==null?void 0:c.finished}return u})}treeLayout(t,e,r){return Vo(this,void 0,void 0,function*(){const{type:i,animation:a}=e,o=ji("layout",i);if(!o)return{};const{nodes:s=[],edges:u=[]}=t,c=new qh({nodes:s.map(g=>({id:Z(g),data:g.data||{}})),edges:u.map(g=>({id:Z(g),source:g.source,target:g.target,data:g.data||{}}))});lJ(c);const l={nodes:[],edges:[]},d={nodes:[],edges:[]};c.getRoots(Yr).forEach(g=>{Qo(g,E=>{E.children=c.getSuccessors(E.id)},E=>c.getSuccessors(E.id),"TB");const m=o(g,e),{x:y,y:v,z:x=0}=m;Qo(m,E=>{const{id:w,x:S,y:k,z:A=0}=E;l.nodes.push({id:w,style:{x:y,y:v,z:x}}),d.nodes.push({id:w,style:{x:S,y:k,z:A}})},E=>E.children,"TB")});const p=this.inferTreeLayoutOffset(d);if(RT(d,p),a){RT(l,p),this.updateElementPosition(l,!1);const g=this.updateElementPosition(d,a);yield g==null?void 0:g.finished}return d})}inferTreeLayoutOffset(t){var e;let[r,i]=[1/0,-1/0],[a,o]=[1/0,-1/0];(e=t.nodes)===null||e===void 0||e.forEach(y=>{const{x:v=0,y:x=0}=y.style||{};r=Math.min(r,v),i=Math.max(i,v),a=Math.min(a,x),o=Math.max(o,x)});const{canvas:s}=this.context,u=s.getSize(),[c,l]=s.getCanvasByViewport([0,0]),[d,p]=s.getCanvasByViewport(u);if(r>=c&&i<=d&&a>=l&&o<=p)return[0,0];const g=(c+d)/2,m=(l+p)/2;return[g-(r+i)/2,m-(a+o)/2]}stopLayout(){this.instance&&Pk(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(t){const{nodeFilter:e=()=>!0,comboFilter:r=()=>!0,preLayout:i=!1,isLayoutInvisibleNodes:a=!1}=t,{nodes:o,edges:s,combos:u}=this.context.model.getData(),{element:c,model:l}=this.context,d=x=>c.getElement(x),p=i?x=>{var E;return!a&&(((E=x.style)===null||E===void 0?void 0:E.visibility)==="hidden"||l.getAncestorsData(x.id,Yr).some(ba)||l.getAncestorsData(x.id,me).some(ba))?!1:e(x)}:x=>{const E=Z(x),w=d(E);return!w||Uu(w)?!1:e(x)},g=o.filter(p),m=u.filter(r),y=new Map(g.map(x=>[Z(x),x]));m.forEach(x=>y.set(Z(x),x));const v=s.filter(({source:x,target:E})=>y.has(x)&&y.has(E));return{nodes:g,edges:v,combos:m}}initGraphLayout(t){var e;const{element:r,viewport:i}=this.context,{type:a}=t,o=fJ(t,["type","enableWorker","animation","iterations"]),[s,u]=i.getCanvasSize(),c=[s/2,u/2],l=(e=t==null?void 0:t.nodeSize)!==null&&e!==void 0?e:(y=>{const v=r==null?void 0:r.getElement(y.id);return v?v.attributes.size:r==null?void 0:r.getElementComputedStyle("node",y).size}),d=ji("layout",a);if(!d)return ka.warn(`The layout of ${a} is not registered.`);const p=Object.getPrototypeOf(d.prototype)===AO.prototype?d:DY(d,this.context),g=new p(this.context),m={nodeSize:l,width:s,height:u,center:c};switch(g.id){case"d3-force":case"d3-force-3d":Object.assign(m,{center:{x:s/2,y:u/2,z:0}});break}return ma(g.options,m,o),g}updateElementPosition(t,e){const{model:r,element:i}=this.context;return i?(r.updateData(t),i.draw({animation:e,silence:!0})):null}destroy(){var t;this.stopLayout(),this.context={},(t=this.supervisor)===null||t===void 0||t.kill(),this.supervisor=void 0,this.instance=void 0,this.instances=[],this.animationResult=void 0}}const RT=(n,t)=>{var e;const[r,i]=t;(e=n.nodes)===null||e===void 0||e.forEach(a=>{if(a.style){const{x:o=0,y:s=0}=a.style;a.style.x=o+r,a.style.y=s+i}else a.style={x:r,y:i}})};function gJ(n){return[vJ].reduce((t,e)=>e(t),n)}function vJ(n){return!n.layout||Array.isArray(n.layout)||"preLayout"in n.layout||["antv-dagre","combo-combined","compact-box","circular","concentric","dagre","fishbone","grid","indented","mds","radial","random","snake","dendrogram","mindmap"].includes(n.layout.type)&&(n.layout.preLayout=!0),n}class mJ extends Db{constructor(t){super(t),this.category="plugin",this.setPlugins(this.context.options.plugins||[])}setPlugins(t){this.setExtensions(t)}getPluginInstance(t){const e=this.extensionMap[t];if(e)return e;ka.warn(`Cannot find the plugin ${t}, will try to find it by type.`);const r=this.extensions.find(i=>i.type===t);if(r)return this.extensionMap[r.key]}}const Al=["update-related-edges","collapse-expand-node","collapse-expand-combo","get-edge-actual-ends","arrange-draw-order"];class yJ extends Db{constructor(t){super(t),this.category="transform",this.setTransforms(this.context.options.transforms||[])}getTransforms(){}setTransforms(t){this.setExtensions([...Al.slice(0,Al.length-1),...t,Al[Al.length-1]])}getTransformInstance(t){return t?this.extensionMap[t]:this.extensionMap}}var iu=function(n,t,e,r){function i(a){return a instanceof e?a:new e(function(o){o(a)})}return new(e||(e=Promise))(function(a,o){function s(l){try{c(r.next(l))}catch(d){o(d)}}function u(l){try{c(r.throw(l))}catch(d){o(d)}}function c(l){l.done?a(l.value):i(l.value).then(s,u)}c((r=r.apply(n,t||[])).next())})};class bJ{get padding(){return zi(this.context.options.padding)}get paddingOffset(){const[t,e,r,i]=this.padding,[a,o,s]=[(i-e)/2,(t-r)/2,0];return[a,o,s]}constructor(t){this.landmarkCounter=0,this.context=t;const[e,r]=this.paddingOffset,{zoom:i,rotation:a,x:o=e,y:s=r}=t.options;this.transform({mode:"absolute",scale:i,translate:[o,s],rotate:a},!1)}get camera(){const{canvas:t}=this.context;return new Proxy(t.getCamera(),{get:(e,r)=>{const i=Object.entries(t.getLayers()).filter(([o])=>!["main"].includes(o)).map(([,o])=>o.getCamera()),a=e[r];if(typeof a=="function")return(...o)=>{const s=a.apply(e,o);return i.forEach(u=>{u[r].apply(u,o)}),s}}})}createLandmark(t){return this.camera.createLandmark(`landmark-${this.landmarkCounter++}`,t)}getAnimation(t){const e=B_(this.context.options,t);return e?wu(Object.assign({},e),["easing","duration"]):!1}getCanvasSize(){const{canvas:t}=this.context,{width:e=0,height:r=0}=t.getConfig();return[e,r]}getCanvasCenter(){const{canvas:t}=this.context,{width:e=0,height:r=0}=t.getConfig();return[e/2,r/2,0]}getViewportCenter(){const[t,e]=this.camera.getPosition();return[t,e,0]}getGraphCenter(){return this.context.graph.getViewportByCanvas(this.getCanvasCenter())}getZoom(){return this.camera.getZoom()}getRotation(){return this.camera.getRoll()}getTranslateOptions(t){const{camera:e}=this,{mode:r,translate:i=[]}=t,a=this.getZoom(),o=e.getPosition(),s=e.getFocalPoint(),[u,c]=this.getCanvasCenter(),[l=0,d=0,p=0]=i,g=sh([-l,-d,-p],a);return r==="relative"?{position:rn(o,g),focalPoint:rn(s,g)}:{position:rn([u,c,o[2]],g),focalPoint:rn([u,c,s[2]],g)}}getRotateOptions(t){const{mode:e,rotate:r=0}=t;return{roll:e==="relative"?this.camera.getRoll()+r:r}}getZoomOptions(t){const{zoomRange:e}=this.context.options,r=this.camera.getZoom(),{mode:i,scale:a=1}=t;return dn(i==="relative"?r*a:a,...e)}transform(t,e){return iu(this,void 0,void 0,function*(){const{graph:r}=this.context,{translate:i,rotate:a,scale:o,origin:s}=t;this.cancelAnimation();const u=this.getAnimation(e);if(an(r,new kl(gt.BEFORE_TRANSFORM,t)),!a&&o&&!i&&s&&!u){this.camera.setZoomByViewportPoint(this.getZoomOptions(t),s),an(r,new kl(gt.AFTER_TRANSFORM,t));return}const c={};if(i&&Object.assign(c,this.getTranslateOptions(t)),Xt(a)&&Object.assign(c,this.getRotateOptions(t)),Xt(o)&&Object.assign(c,{zoom:this.getZoomOptions(t)}),u)return an(r,new Tr(gt.BEFORE_ANIMATE,$n.TRANSFORM,null,t)),new Promise(l=>{this.transformResolver=l,this.camera.gotoLandmark(this.createLandmark(c),Object.assign(Object.assign({},u),{onfinish:()=>{an(r,new Tr(gt.AFTER_ANIMATE,$n.TRANSFORM,null,t)),an(r,new kl(gt.AFTER_TRANSFORM,t)),this.transformResolver=void 0,l()}}))});this.camera.gotoLandmark(this.createLandmark(c),{duration:0}),an(r,new kl(gt.AFTER_TRANSFORM,t))})}fitView(t,e){return iu(this,void 0,void 0,function*(){const[r,i,a,o]=this.padding,{when:s="always",direction:u="both"}=t||{},[c,l]=this.context.canvas.getSize(),d=c-o-i,p=l-r-a,g=this.context.canvas.getBounds(),m=this.getBBoxInViewport(g),[y,v]=zu(m),x=u==="x"&&y>=d||u==="y"&&v>=p||u==="both"&&y>=d&&v>=p;if(s==="overflow"&&!x)return yield this.fitCenter({animation:e});const E=d/y,w=p/v,S=u==="x"?E:u==="y"?w:Math.min(E,w),k=this.getAnimation(e);Number.isFinite(S)&&(yield this.transform({mode:"relative",scale:S,translate:rn(Mn(this.getCanvasCenter(),this.getBBoxInViewport(g).center),sh(this.paddingOffset,S))},k))})}fitCenter(t){return iu(this,void 0,void 0,function*(){const e=this.context.canvas.getBounds();yield this.focus(e,t)})}focusElements(t){return iu(this,arguments,void 0,function*(e,r={}){const{element:i}=this.context;if(!i)return;const a=s=>r.shapes?s.getShape(r.shapes).getRenderBounds():s.getRenderBounds(),o=Fu(e.map(s=>a(i.getElement(s))));yield this.focus(o,r)})}focus(t,e){return iu(this,void 0,void 0,function*(){const r=this.context.graph.getViewportByCanvas(t.center),i=e.position||this.getCanvasCenter(),a=Mn(i,r);yield this.transform({mode:"relative",translate:rn(a,this.paddingOffset)},e.animation)})}getBBoxInViewport(t){const{min:e,max:r}=t,{graph:i}=this.context,[a,o]=i.getViewportByCanvas(e),[s,u]=i.getViewportByCanvas(r),c=new ye;return c.setMinMax([a,o,0],[s,u,0]),c}isInViewport(t,e=!1,r=0){const{graph:i}=this.context,a=this.getCanvasSize(),[o,s]=i.getCanvasByViewport([0,0]),[u,c]=i.getCanvasByViewport(a);let l=new ye;return l.setMinMax([o,s,0],[u,c,0]),r&&(l=Aa(l,r)),ss(t)?Xr(t,l):e?sU(t,l):l.intersects(t)}cancelAnimation(){var t,e;!((t=this.camera.landmarks)===null||t===void 0)&&t.length&&this.camera.cancelLandmarkAnimation(),(e=this.transformResolver)===null||e===void 0||e.call(this)}}var ve=function(n,t,e,r){function i(a){return a instanceof e?a:new e(function(o){o(a)})}return new(e||(e=Promise))(function(a,o){function s(l){try{c(r.next(l))}catch(d){o(d)}}function u(l){try{c(r.throw(l))}catch(d){o(d)}}function c(l){l.done?a(l.value):i(l.value).then(s,u)}c((r=r.apply(n,t||[])).next())})};class Md extends Fb{constructor(t){var e;super(),this.options={},this.rendered=!1,this.destroyed=!1,this.context={model:new hJ},this.isCollapsingExpanding=!1,this.onResize=_h(()=>{this.resize()},300),this._setOptions(Object.assign({},Md.defaultOptions,t),!0),this.context.graph=this,this.options.autoResize&&((e=globalThis.addEventListener)===null||e===void 0||e.call(globalThis,"resize",this.onResize))}getOptions(){return this.options}setOptions(t){this._setOptions(t,!1)}_setOptions(t,e){if(this.updateCanvas(t),Object.assign(this.options,gJ(t)),e){const{data:p}=t;p&&this.addData(p);return}const{behaviors:r,combo:i,data:a,edge:o,layout:s,node:u,plugins:c,theme:l,transforms:d}=t;r&&this.setBehaviors(r),a&&this.setData(a),u&&this.setNode(u),o&&this.setEdge(o),i&&this.setCombo(i),s&&this.setLayout(s),l&&this.setTheme(l),c&&this.setPlugins(c),d&&this.setTransforms(d)}getSize(){return this.context.canvas?this.context.canvas.getSize():[this.options.width||0,this.options.height||0]}setSize(t,e){t&&(this.options.width=t),e&&(this.options.height=e),this.resize(t,e)}setZoomRange(t){this.options.zoomRange=t}getZoomRange(){return this.options.zoomRange}setNode(t){this.options.node=t,this.context.model.refreshData()}setEdge(t){this.options.edge=t,this.context.model.refreshData()}setCombo(t){this.options.combo=t,this.context.model.refreshData()}getTheme(){return this.options.theme}setTheme(t){this.options.theme=St(t)?t(this.getTheme()):t}setLayout(t){this.options.layout=St(t)?t(this.getLayout()):t}getLayout(){return this.options.layout}setBehaviors(t){var e;this.options.behaviors=St(t)?t(this.getBehaviors()):t,(e=this.context.behavior)===null||e===void 0||e.setBehaviors(this.options.behaviors)}updateBehavior(t){this.setBehaviors(e=>e.map(r=>typeof r=="object"&&r.key===t.key?Object.assign(Object.assign({},r),t):r))}getBehaviors(){return this.options.behaviors||[]}setPlugins(t){var e;this.options.plugins=St(t)?t(this.getPlugins()):t,(e=this.context.plugin)===null||e===void 0||e.setPlugins(this.options.plugins)}updatePlugin(t){this.setPlugins(e=>e.map(r=>typeof r=="object"&&r.key===t.key?Object.assign(Object.assign({},r),t):r))}getPlugins(){return this.options.plugins||[]}getPluginInstance(t){return this.context.plugin.getPluginInstance(t)}setTransforms(t){var e;this.options.transforms=St(t)?t(this.getTransforms()):t,(e=this.context.transform)===null||e===void 0||e.setTransforms(this.options.transforms)}updateTransform(t){this.setTransforms(e=>e.map(r=>typeof r=="object"&&r.key===t.key?Object.assign(Object.assign({},r),t):r)),this.context.model.refreshData()}getTransforms(){return this.options.transforms||[]}getData(){return this.context.model.getData()}hasNode(t){return this.context.model.hasNode(t)}hasEdge(t){return this.context.model.hasEdge(t)}hasCombo(t){return this.context.model.hasCombo(t)}getElementData(t){return Array.isArray(t)?t.map(e=>this.context.model.getElementDataById(e)):this.context.model.getElementDataById(t)}getNodeData(t){return t===void 0?this.context.model.getNodeData():Array.isArray(t)?this.context.model.getNodeData(t):this.context.model.getNodeLikeDatum(t)}getEdgeData(t){return t===void 0?this.context.model.getEdgeData():Array.isArray(t)?this.context.model.getEdgeData(t):this.context.model.getEdgeDatum(t)}getComboData(t){return t===void 0?this.context.model.getComboData():Array.isArray(t)?this.context.model.getComboData(t):this.context.model.getNodeLikeDatum(t)}setData(t){this.context.model.setData(St(t)?t(this.getData()):t)}addData(t){this.context.model.addData(St(t)?t(this.getData()):t)}addNodeData(t){this.context.model.addNodeData(St(t)?t(this.getNodeData()):t)}addEdgeData(t){this.context.model.addEdgeData(St(t)?t(this.getEdgeData()):t)}addComboData(t){this.context.model.addComboData(St(t)?t(this.getComboData()):t)}addChildrenData(t,e){this.context.model.addChildrenData(t,e)}updateData(t){this.context.model.updateData(St(t)?t(this.getData()):t)}updateNodeData(t){this.context.model.updateNodeData(St(t)?t(this.getNodeData()):t)}updateEdgeData(t){this.context.model.updateEdgeData(St(t)?t(this.getEdgeData()):t)}updateComboData(t){this.context.model.updateComboData(St(t)?t(this.getComboData()):t)}removeData(t){this.context.model.removeData(St(t)?t(this.getData()):t)}removeNodeData(t){this.context.model.removeNodeData(St(t)?t(this.getNodeData()):t)}removeEdgeData(t){this.context.model.removeEdgeData(St(t)?t(this.getEdgeData()):t)}removeComboData(t){this.context.model.removeComboData(St(t)?t(this.getComboData()):t)}getElementType(t){return this.context.model.getElementType(t)}getRelatedEdgesData(t,e="both"){return this.context.model.getRelatedEdgesData(t,e)}getNeighborNodesData(t){return this.context.model.getNeighborNodesData(t)}getAncestorsData(t,e){return this.context.model.getAncestorsData(t,e)}getParentData(t,e){return this.context.model.getParentData(t,e)}getChildrenData(t){return this.context.model.getChildrenData(t)}getDescendantsData(t){return this.context.model.getDescendantsData(t)}getElementDataByState(t,e){return this.context.model.getElementDataByState(t,e)}initCanvas(){return ve(this,void 0,void 0,function*(){var t;if(this.context.canvas)return yield this.context.canvas.ready;const{container:e="container",width:r,height:i,renderer:a,cursor:o,background:s,canvas:u,devicePixelRatio:c=(t=globalThis.devicePixelRatio)!==null&&t!==void 0?t:1}=this.options;if(e instanceof NT)this.context.canvas=e,o&&e.setCursor(o),a&&e.setRenderer(a),yield e.ready;else{const l=fe(e)?document.getElementById(e):e,d=_T(l);this.emit(gt.BEFORE_CANVAS_INIT,{container:l,width:r,height:i});const p=Object.assign(Object.assign({},u),{container:l,width:r||d[0],height:i||d[1],background:s,renderer:a,cursor:o,devicePixelRatio:c}),g=new NT(p);this.context.canvas=g,yield g.ready,this.emit(gt.AFTER_CANVAS_INIT,{canvas:g})}})}updateCanvas(t){var e,r;const{renderer:i,cursor:a,height:o,width:s}=t,u=this.context.canvas;u&&(i&&(this.emit(gt.BEFORE_RENDERER_CHANGE,{renderer:this.options.renderer}),u.setRenderer(i),this.emit(gt.AFTER_RENDERER_CHANGE,{renderer:i})),a&&u.setCursor(a),(Xt(s)||Xt(o))&&this.setSize((e=s??this.options.width)!==null&&e!==void 0?e:0,(r=o??this.options.height)!==null&&r!==void 0?r:0))}initRuntime(){this.context.options=this.options,this.context.batch||(this.context.batch=new sJ(this.context)),this.context.plugin||(this.context.plugin=new mJ(this.context)),this.context.viewport||(this.context.viewport=new bJ(this.context)),this.context.transform||(this.context.transform=new yJ(this.context)),this.context.element||(this.context.element=new dJ(this.context)),this.context.animation||(this.context.animation=new oJ(this.context)),this.context.layout||(this.context.layout=new pJ(this.context)),this.context.behavior||(this.context.behavior=new uJ(this.context))}prepare(){return ve(this,void 0,void 0,function*(){if(yield Promise.resolve(),this.destroyed){console.error(Li("The graph instance has been destroyed"));return}yield this.initCanvas(),this.initRuntime()})}render(){return ve(this,void 0,void 0,function*(){if(yield this.prepare(),an(this,new Xe(gt.BEFORE_RENDER)),this.options.layout)if(!this.rendered&&RY(this.options.layout)){const t=yield this.context.element.preLayoutDraw({type:"render"});yield Promise.all([t==null?void 0:t.finished,this.autoFit()])}else{const t=this.context.element.draw({type:"render"});yield Promise.all([t==null?void 0:t.finished,this.context.layout.postLayout()]),yield this.autoFit()}else{const t=this.context.element.draw({type:"render"});yield Promise.all([t==null?void 0:t.finished,this.autoFit()])}this.rendered=!0,an(this,new Xe(gt.AFTER_RENDER))})}draw(){return ve(this,void 0,void 0,function*(){var t;yield this.prepare(),yield(t=this.context.element.draw())===null||t===void 0?void 0:t.finished})}layout(t){return ve(this,void 0,void 0,function*(){yield this.context.layout.postLayout(t)})}stopLayout(){this.context.layout.stopLayout()}clear(){return ve(this,void 0,void 0,function*(){const{model:t,element:e}=this.context;t.setData({}),t.clearChanges(),e==null||e.clear()})}destroy(){var t;an(this,new Xe(gt.BEFORE_DESTROY));const{layout:e,animation:r,element:i,model:a,canvas:o,behavior:s,plugin:u}=this.context;u==null||u.destroy(),s==null||s.destroy(),e==null||e.destroy(),r==null||r.destroy(),i==null||i.destroy(),a.destroy(),o==null||o.destroy(),this.options={},this.context={},this.off(),(t=globalThis.removeEventListener)===null||t===void 0||t.call(globalThis,"resize",this.onResize),this.destroyed=!0,an(this,new Xe(gt.AFTER_DESTROY))}getCanvas(){return this.context.canvas}resize(t,e){var r;const i=_T((r=this.context.canvas)===null||r===void 0?void 0:r.getContainer()),a=[t||i[0],e||i[1]];if(!this.context.canvas)return;const o=this.context.canvas.getSize();Jn(a,o)||(an(this,new Xe(gt.BEFORE_SIZE_CHANGE,{size:a})),this.context.canvas.resize(...a),an(this,new Xe(gt.AFTER_SIZE_CHANGE,{size:a})))}fitView(t,e){return ve(this,void 0,void 0,function*(){var r;yield(r=this.context.viewport)===null||r===void 0?void 0:r.fitView(t,e)})}fitCenter(t){return ve(this,void 0,void 0,function*(){var e;yield(e=this.context.viewport)===null||e===void 0?void 0:e.fitCenter({animation:t})})}autoFit(){return ve(this,void 0,void 0,function*(){const{autoFit:t}=this.context.options;if(t)if(fe(t))t==="view"?yield this.fitView():t==="center"&&(yield this.fitCenter());else{const{type:e,animation:r}=t;e==="view"?yield this.fitView(t.options,r):e==="center"&&(yield this.fitCenter(r))}})}focusElement(t,e){return ve(this,void 0,void 0,function*(){var r;yield(r=this.context.viewport)===null||r===void 0?void 0:r.focusElements(Array.isArray(t)?t:[t],{animation:e})})}zoomBy(t,e,r){return ve(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",scale:t,origin:r},e)})}zoomTo(t,e,r){return ve(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",scale:t,origin:r},e)})}getZoom(){return this.context.viewport.getZoom()}rotateBy(t,e,r){return ve(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",rotate:t,origin:r},e)})}rotateTo(t,e,r){return ve(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",rotate:t,origin:r},e)})}getRotation(){return this.context.viewport.getRotation()}translateBy(t,e){return ve(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",translate:t},e)})}translateTo(t,e){return ve(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",translate:t},e)})}getPosition(){return Mn([0,0],this.getCanvasByViewport([0,0]))}translateElementBy(t,e){return ve(this,arguments,void 0,function*(r,i,a=!0){var o,s;const[u,c]=An(r)?[r,(o=i)!==null&&o!==void 0?o:!0]:[{[r]:i},a];Object.entries(u).forEach(([l,d])=>this.context.model.translateNodeLikeBy(l,d)),yield(s=this.context.element.draw({animation:c,stage:"translate"}))===null||s===void 0?void 0:s.finished})}translateElementTo(t,e){return ve(this,arguments,void 0,function*(r,i,a=!0){var o,s;const[u,c]=An(r)?[r,(o=i)!==null&&o!==void 0?o:!0]:[{[r]:i},a];Object.entries(u).forEach(([l,d])=>this.context.model.translateNodeLikeTo(l,d)),yield(s=this.context.element.draw({animation:c,stage:"translate"}))===null||s===void 0?void 0:s.finished})}getElementPosition(t){return this.context.model.getElementPosition(t)}getElementRenderStyle(t){return RM(this.context.element.getElement(t).attributes,["context"])}setElementVisibility(t,e){return ve(this,arguments,void 0,function*(r,i,a=!0){var o,s;const[u,c]=An(r)?[r,(o=i)!==null&&o!==void 0?o:!0]:[{[r]:i},a],l={nodes:[],edges:[],combos:[]};Object.entries(u).forEach(([g,m])=>{const y=this.getElementType(g);l[`${y}s`].push({id:g,style:{visibility:m}})});const{model:d,element:p}=this.context;d.preventUpdateNodeLikeHierarchy(()=>{d.updateData(l)}),yield(s=p.draw({animation:c,stage:"visibility"}))===null||s===void 0?void 0:s.finished})}showElement(t,e){return ve(this,void 0,void 0,function*(){const r=Array.isArray(t)?t:[t];yield this.setElementVisibility(Object.fromEntries(r.map(i=>[i,"visible"])),e)})}hideElement(t,e){return ve(this,void 0,void 0,function*(){const r=Array.isArray(t)?t:[t];yield this.setElementVisibility(Object.fromEntries(r.map(i=>[i,"hidden"])),e)})}getElementVisibility(t){var e,r;const i=this.context.element.getElement(t);return(r=(e=i==null?void 0:i.style)===null||e===void 0?void 0:e.visibility)!==null&&r!==void 0?r:"visible"}setElementZIndex(t,e){return ve(this,void 0,void 0,function*(){var r;const i={nodes:[],edges:[],combos:[]},a=An(t)?t:{[t]:e};Object.entries(a).forEach(([u,c])=>{const l=this.getElementType(u);i[`${l}s`].push({id:u,style:{zIndex:c}})});const{model:o,element:s}=this.context;o.preventUpdateNodeLikeHierarchy(()=>o.updateData(i)),yield(r=s.draw({animation:!1,stage:"zIndex"}))===null||r===void 0?void 0:r.finished})}frontElement(t){return ve(this,void 0,void 0,function*(){const e=Array.isArray(t)?t:[t],{model:r}=this.context,i={};e.map(a=>{const o=r.getFrontZIndex(a);if(r.getElementType(a)==="combo"){const s=r.getAncestorsData(a,me).at(-1)||this.getComboData(a),u=[s,...r.getDescendantsData(Z(s))],c=o-OT(s);u.forEach(d=>{i[Z(d)]=this.getElementZIndex(Z(d))+c});const{internal:l}=nY(u.map(Z),d=>r.getRelatedEdgesData(d));l.forEach(d=>{const p=Z(d);i[p]=this.getElementZIndex(p)+c})}else i[a]=o}),yield this.setElementZIndex(i)})}getElementZIndex(t){return OT(this.context.model.getElementDataById(t))}setElementState(t,e){return ve(this,arguments,void 0,function*(r,i,a=!0){var o,s;const[u,c]=An(r)?[r,(o=i)!==null&&o!==void 0?o:!0]:[{[r]:i},a],l=p=>p?Array.isArray(p)?p:[p]:[],d={nodes:[],edges:[],combos:[]};Object.entries(u).forEach(([p,g])=>{const m=this.getElementType(p);d[`${m}s`].push({id:p,states:l(g)})}),this.updateData(d),yield(s=this.context.element.draw({animation:c,stage:"state"}))===null||s===void 0?void 0:s.finished})}getElementState(t){return this.context.model.getElementState(t)}getElementRenderBounds(t){return this.context.element.getElement(t).getRenderBounds()}collapseElement(t){return ve(this,arguments,void 0,function*(e,r=!0){const{model:i,element:a}=this.context;if(ba(i.getNodeLikeData([e])[0])||this.isCollapsingExpanding)return;typeof r=="boolean"&&(r={animation:r,align:!0});const o=i.getElementType(e);yield this.frontElement(e),this.isCollapsingExpanding=!0,i.updateData(o==="node"?{nodes:[{id:e,style:{collapsed:!0}}]}:{combos:[{id:e,style:{collapsed:!0}}]}),o==="node"?yield a.collapseNode(e,r):o==="combo"&&(yield a.collapseCombo(e,!!r.animation)),this.isCollapsingExpanding=!1})}expandElement(t){return ve(this,arguments,void 0,function*(e,r=!0){const{model:i,element:a}=this.context;if(!ba(i.getNodeLikeData([e])[0])||this.isCollapsingExpanding)return;typeof r=="boolean"&&(r={animation:r,align:!0});const o=i.getElementType(e);this.isCollapsingExpanding=!0,i.updateData(o==="node"?{nodes:[{id:e,style:{collapsed:!1}}]}:{combos:[{id:e,style:{collapsed:!1}}]}),o==="node"?yield a.expandNode(e,r):o==="combo"&&(yield a.expandCombo(e,!!r.animation)),this.isCollapsingExpanding=!1})}setElementCollapsibility(t,e){const r=this.getElementType(t);r==="node"?this.updateNodeData([{id:t,style:{collapsed:e}}]):r==="combo"&&this.updateComboData([{id:t,style:{collapsed:e}}])}toDataURL(){return ve(this,arguments,void 0,function*(t={}){return this.context.canvas.toDataURL(t)})}getCanvasByViewport(t){return this.context.canvas.getCanvasByViewport(t)}getViewportByCanvas(t){return this.context.canvas.getViewportByCanvas(t)}getClientByCanvas(t){return this.context.canvas.getClientByCanvas(t)}getCanvasByClient(t){return this.context.canvas.getCanvasByClient(t)}getViewportCenter(){return this.context.viewport.getViewportCenter()}getCanvasCenter(){return this.context.viewport.getCanvasCenter()}on(t,e,r){return super.on(t,e,r)}once(t,e){return super.once(t,e)}off(t,e){return super.off(t,e)}}Md.defaultOptions={autoResize:!1,theme:"light",rotation:0,zoom:1,zoomRange:[.01,10]};const xJ=(n,t)=>{const{source:e,target:r}=t,i=n.getElementDataById(e),a=n.getElementDataById(r),o=vk(i,d=>n.getParentData(d,me)),s=vk(a,d=>n.getParentData(d,me)),u=Z(o),c=Z(s),l={sourceNode:u,targetNode:c};return t.style?Object.assign(t.style,l):t.style=l,t},EJ=(n,t,e)=>{const[r,i]=t,[a,o]=e;if(i===r)return a;const s=(n-r)/(i-r);return a+s*(o-a)},wJ=(n,t,e)=>{const[r,i]=t,[a,o]=e,s=Math.log(n-r+1)/Math.log(i-r+1);return a+s*(o-a)},kJ=(n,t,e,r=2)=>{const[i,a]=t,[o,s]=e,u=Math.pow((n-i)/(a-i),r);return o+u*(s-o)},AJ=(n,t,e)=>{const[r,i]=t,[a,o]=e,s=Math.sqrt((n-r)/(i-r));return a+s*(o-a)};class _d extends i6{constructor(t,e){super(t,ma({},_d.defaultOptions,e)),this.assignSizeByCentrality=(r,i,a,o,s,u)=>{const c=[i,a],l=[o[0],s[0]],d=[o[1],s[1]],p=[o[2],s[2]],g=(m,y)=>{if(typeof u=="function")return u(m,c,y);switch(u){case"linear":return EJ(m,c,y);case"log":return wJ(m,c,y);case"pow":return kJ(m,c,y,2);case"sqrt":return AJ(m,c,y);default:return y[0]}};return[g(r,l),g(r,d),g(r,p)]}}beforeDraw(t){const{model:e}=this.context,r=e.getNodeData(),i=ga(this.options.maxSize),a=ga(this.options.minSize),o=this.getCentralities(this.options.centrality),s=o.size>0?Math.max(...o.values()):0,u=o.size>0?Math.min(...o.values()):0;return r.forEach(c=>{var l;const d=this.assignSizeByCentrality(o.get(Z(c))||0,u,s,a,i,this.options.scale),p=(l=this.context.element)===null||l===void 0?void 0:l.getElement(Z(c)),g={size:d};this.assignLabelStyle(g,d,c,p),(!p||!Il(g,p.attributes))&&lu(t,p?"update":"add","node",ma(c,{style:g}),!0)}),t}assignLabelStyle(t,e,r,i){var a;const o=i?i.config.style:(a=this.context.element)===null||a===void 0?void 0:a.getElementComputedStyle("node",r);if(Object.assign(t,wu(o,["labelFontSize","labelLineHeight"])),this.options.mapLabelSize){const s=this.getLabelSizeByNodeSize(e,1/0,Number(t.labelFontSize));Object.assign(t,{labelFontSize:s,labelLineHeight:s+oU(t.labelPadding)})}return t}getLabelSizeByNodeSize(t,e,r){const i=Math.min(...t)/2,[a,o]=Array.isArray(this.options.mapLabelSize)?this.options.mapLabelSize:[r,e];return Math.min(o,Math.max(i,a))}getCentralities(t){const{model:e}=this.context,r=e.getData();if(typeof t=="function")return t(r);const i=e.getRelatedEdgesData.bind(e);return U_(r,i,t)}}_d.defaultOptions={centrality:{type:"degree"},maxSize:80,minSize:20,scale:"linear",mapLabelSize:!1};const SJ="quadratic",DT=["top","top-right","right","right-bottom","bottom","bottom-left","left","left-top"];class Ru extends i6{constructor(t,e){super(t,Object.assign({},Ru.defaultOptions,e)),this.cacheMergeStyle=new Map,this.getAffectedParallelEdges=r=>{const{add:{edges:i},update:{nodes:a,edges:o,combos:s},remove:{edges:u}}=r,{model:c}=this.context,l=new Map,d=(m,y)=>{c.getRelatedEdgesData(y).forEach(v=>!l.has(Z(v))&&l.set(Z(v),v))};a.forEach(d),s.forEach(d);const p=m=>{const y=new Set(r.remove.edges.keys()),v=c.getEdgeData().filter(x=>!y.has(Z(x))).map(x=>xJ(c,x));CJ(m,v).forEach(x=>{const E=Z(x);l.has(E)||l.set(E,x)})};if(u.size&&u.forEach(p),i.size&&i.forEach(p),o.size){const m=OK(UP(c.getChanges())).update.edges;o.forEach(y=>{var v;p(y);const x=(v=m.find(E=>Z(E.value)===Z(y)))===null||v===void 0?void 0:v.original;x&&!hx(y,x)&&p(x)})}PM(this.options.edges)||l.forEach((m,y)=>!this.options.edges.includes(y)&&l.delete(y));const g=c.getEdgeData().map(Z);return new Map([...l].sort((m,y)=>g.indexOf(m[0])-g.indexOf(y[0])))},this.applyBundlingStyle=(r,i,a)=>{const{edgeMap:o,reverses:s}=LT(i);o.forEach(u=>{u.forEach((c,l,d)=>{var p;const g=d.length,m=c.style||{};if(c.source===c.target){const x=DT.length;m.loopPlacement=DT[l%x],m.loopDist=Math.floor(l/x)*a+50}else if(g===1)m.curveOffset=0;else{const x=(l%2===0?1:-1)*(s[`${c.source}|${c.target}|${l}`]?-1:1);m.curveOffset=g%2===1?x*Math.ceil(l/2)*a*2:x*(Math.floor(l/2)*a*2+a)}const y=Object.assign(c,{type:SJ,style:m}),v=(p=this.context.element)===null||p===void 0?void 0:p.getElement(Z(c));(!v||!Il(y.style,v.attributes))&&lu(r,v?"update":"add","edge",y,!0)})})},this.resetEdgeStyle=r=>{const i=r.style||{},a=this.cacheMergeStyle.get(Z(r))||{};return Object.keys(a).forEach(o=>{Jn(i[o],a[o])&&(r[o]?i[o]=r[o]:delete i[o])}),Object.assign(r,{style:i})},this.applyMergingStyle=(r,i)=>{const{edgeMap:a,reverses:o}=LT(i);a.forEach(s=>{var u;if(s.length===1){const l=s[0],d=(u=this.context.element)===null||u===void 0?void 0:u.getElement(Z(l)),p=this.resetEdgeStyle(l);(!d||!Il(p,d.attributes))&&lu(r,d?"update":"add","edge",p);return}const c=s.map(({source:l,target:d,style:p={}},g)=>{const{startArrow:m,endArrow:y}=p,v={},[x,E]=o[`${l}|${d}|${g}`]?["endArrow","startArrow"]:["startArrow","endArrow"];return Eu(m)&&(v[x]=m),Eu(y)&&(v[E]=y),v}).reduce((l,d)=>Object.assign(Object.assign({},l),d),{});s.forEach((l,d,p)=>{var g;if(d!==0){lu(r,"remove","edge",l);return}const m=Object.assign({},St(this.options.style)?this.options.style(p):this.options.style,{childrenData:p});this.cacheMergeStyle.set(Z(l),m);const y=Object.assign(Object.assign({},l),{type:"line",style:Object.assign(Object.assign(Object.assign({},l.style),c),m)}),v=(g=this.context.element)===null||g===void 0?void 0:g.getElement(Z(l));(!v||!Il(y.style,v.attributes))&&lu(r,v?"update":"add","edge",y,!0)})})}}beforeDraw(t){const e=this.getAffectedParallelEdges(t);return e.size===0||(this.options.mode==="bundle"?this.applyBundlingStyle(t,e,this.options.distance):this.applyMergingStyle(t,e)),t}}Ru.defaultOptions={mode:"bundle",distance:15};const LT=n=>{const t=new Map,e=new Set,r={},i=new Map;for(const[a,o]of n){if(e.has(a))continue;const{source:s,target:u}=o,c=`${s}-${u}`;t.has(c)||(t.set(c,[]),i.set(c,new Set));const l=t.get(c),d=i.get(c);l&&d&&!d.has(a)&&(l.push(o),d.add(a),e.add(a));for(const[p,g]of n)if(!(e.has(p)||p===a)&&hx(o,g)){const m=t.get(c),y=i.get(c);m&&y&&!y.has(p)&&(m.push(g),y.add(p),s===g.target&&u===g.source&&(r[`${g.source}|${g.target}|${m.length-1}`]=!0),e.add(p))}}return{edgeMap:t,reverses:r}},CJ=(n,t,e)=>t.filter(r=>hx(r,n)),hx=(n,t)=>{const{sourceNode:e,targetNode:r}=n.style||{},{sourceNode:i,targetNode:a}=t.style||{};return e===i&&r===a||e===a&&r===i},NJ={css:"//at.alicdn.com/t/a/font_470089_8hnbbf8n4u8.css"},TJ={dragCanvas:!0,zoomCanvas:!0,scrollCanvas:!0,clickSelect:!0,focusElement:!0,hoverActivate:!0,autoAdaptLabel:!0};class MJ{constructor(t={}){Te(this,"options"),this.options={...TJ,...t}}generate(){const t=[];return this.options.dragCanvas&&t.push(this.createDragCanvasConfig()),this.options.zoomCanvas&&t.push(this.createZoomCanvasConfig()),this.options.scrollCanvas&&t.push(this.createScrollCanvasConfig()),this.options.optimizeViewportTransform&&t.push(this.createOptimizeViewportTransformConfig()),this.options.clickSelect&&t.push(this.createClickSelectConfig()),this.options.brushSelect&&t.push(this.createBrushSelectConfig()),this.options.lassoSelect&&t.push(this.createLassoSelectConfig()),this.options.createEdge&&t.push(this.createCreateEdgeConfig()),this.options.dragElement&&t.push(this.createDragElementConfig()),this.options.dragElementForce&&t.push(this.createDragElementForceConfig()),this.options.collapseExpand&&t.push(this.createCollapseExpandConfig()),this.options.focusElement&&t.push(this.createFocusElementConfig()),this.options.hoverActivate&&t.push(this.createHoverActivateConfig()),this.options.fixElementSize&&t.push(this.createFixElementSizeConfig()),this.options.autoAdaptLabel&&t.push(this.createAutoAdaptLabelConfig()),t}createDragCanvasConfig(){const t=this.options.dragCanvas;return typeof t=="boolean"?{type:"drag-canvas"}:{type:"drag-canvas",key:"drag-canvas",direction:"both",...t}}createZoomCanvasConfig(){const t=this.options.zoomCanvas;return typeof t=="boolean"?{type:"zoom-canvas"}:{type:"zoom-canvas",key:"zoom-canvas",sensitivity:1,...t}}createScrollCanvasConfig(){const t=this.options.scrollCanvas;return typeof t=="boolean"?{type:"scroll-canvas"}:{type:"scroll-canvas",key:"scroll-canvas",sensitivity:1,...t}}createOptimizeViewportTransformConfig(){const t=this.options.optimizeViewportTransform;return typeof t=="boolean"?{type:"optimize-viewport-transform"}:{type:"optimize-viewport-transform",key:"optimize-viewport-transform",debounce:200,...t}}createClickSelectConfig(){const t=this.options.clickSelect;return typeof t=="boolean"?{type:"click-select"}:{type:"click-select",key:"click-select",multiple:!1,...t}}createBrushSelectConfig(){const t=this.options.brushSelect;return typeof t=="boolean"?{type:"brush-select"}:{type:"brush-select",key:"brush-select",...t}}createLassoSelectConfig(){const t=this.options.lassoSelect;return typeof t=="boolean"?{type:"lasso-select"}:{type:"lasso-select",key:"lasso-select",...t}}createCreateEdgeConfig(){const t=this.options.createEdge;return typeof t=="boolean"?{type:"create-edge"}:{type:"create-edge",key:"create-edge",...t}}createDragElementConfig(){const t=this.options.dragElement;return typeof t=="boolean"?{type:"drag-element"}:{type:"drag-element",key:"drag-element",...t}}createDragElementForceConfig(){const t=this.options.dragElementForce;return typeof t=="boolean"?{type:"drag-element-force"}:{type:"drag-element-force",key:"drag-element-force",...t}}createCollapseExpandConfig(){const t=this.options.collapseExpand;return typeof t=="boolean"?{type:"collapse-expand"}:{type:"collapse-expand",key:"collapse-expand",...t}}createFocusElementConfig(){const t=this.options.focusElement;return typeof t=="boolean"?{type:"focus-element"}:{type:"focus-element",key:"focus-element",animation:{duration:500,easing:"ease-in"},...t}}createHoverActivateConfig(){const t=this.options.hoverActivate;return typeof t=="boolean"?{type:"hover-activate"}:{type:"hover-activate",key:"hover-activate",animation:!0,degree:0,direction:"both",state:"active",...t}}createFixElementSizeConfig(){const t=this.options.fixElementSize;return typeof t=="boolean"?{type:"fix-element-size"}:{type:"fix-element-size",key:"fix-element-size",...t}}createAutoAdaptLabelConfig(){const t=this.options.autoAdaptLabel;return typeof t=="boolean"?{type:"auto-adapt-label"}:{type:"auto-adapt-label",key:"auto-adapt-label",enable:!0,...t}}}function eb(n={}){return new MJ(n).generate()}function _J(n){const t={minimal:{dragCanvas:!0,zoomCanvas:!0},standard:{dragCanvas:!0,zoomCanvas:!0,scrollCanvas:!0,clickSelect:!0,focusElement:!0,hoverActivate:!0},advanced:{dragCanvas:!0,zoomCanvas:!0,scrollCanvas:!0,optimizeViewportTransform:!0,clickSelect:!0,brushSelect:!0,dragElement:!0,focusElement:!0,hoverActivate:!0,autoAdaptLabel:!0},full:{dragCanvas:!0,zoomCanvas:!0,scrollCanvas:!0,optimizeViewportTransform:!0,clickSelect:!0,brushSelect:!0,lassoSelect:!0,createEdge:!0,dragElement:!0,dragElementForce:!0,collapseExpand:!0,focusElement:!0,hoverActivate:!0,fixElementSize:!0,autoAdaptLabel:!0},preview:{dragCanvas:{direction:"both",sensitivity:1},zoomCanvas:{sensitivity:.8,trigger:["Control"]},scrollCanvas:{sensitivity:1.2},optimizeViewportTransform:{debounce:200},focusElement:{animation:{duration:600,easing:"ease-in-out"}},hoverActivate:{animation:!0,degree:1,direction:"both",state:"highlight"},autoAdaptLabel:!0,clickSelect:!1,brushSelect:!1,lassoSelect:!1,createEdge:!1,dragElement:!1,dragElementForce:!1,collapseExpand:!1}};return eb(t[n]||t.standard)}class OJ{constructor(t={}){Te(this,"options"),this.options=t}generate(){const t=[];return this.options.background&&(this.options.background===!0?t.push({type:"background"}):t.push({type:"background",...this.options.background})),this.options.bubbleSets&&(this.options.bubbleSets===!0?t.push({type:"bubble-sets",members:[]}):t.push({type:"bubble-sets",members:[],...this.options.bubbleSets})),this.options.fullscreen&&(this.options.fullscreen===!0?t.push({type:"fullscreen"}):t.push({type:"fullscreen",...this.options.fullscreen})),this.options.gridLine&&(this.options.gridLine===!0?t.push({type:"grid-line"}):t.push({type:"grid-line",...this.options.gridLine})),this.options.history&&(this.options.history===!0?t.push({type:"history"}):t.push({type:"history",...this.options.history})),this.options.legend&&(this.options.legend===!0?t.push({type:"legend",key:"legend",nodeField:"nodeType",edgeField:"edgeType"}):t.push({type:"legend",key:"legend",...this.options.legend})),this.options.contextmenu&&(this.options.contextmenu===!0?t.push({type:"contextmenu"}):t.push({type:"contextmenu",...this.options.contextmenu})),this.options.snapline&&(this.options.snapline===!0?t.push({type:"snapline"}):t.push({type:"snapline",...this.options.snapline})),this.options.timebar&&(this.options.timebar===!0?t.push({type:"timebar",data:[]}):t.push({type:"timebar",data:[],...this.options.timebar})),this.options.title&&(this.options.title===!0?t.push({type:"title",key:"title"}):t.push({type:"title",key:"title",...this.options.title})),this.options.toolbar&&(this.options.toolbar===!0?t.push({type:"toolbar",getItems:()=>[],onClick:()=>{}}):t.push({type:"toolbar",getItems:()=>[],onClick:()=>{},...this.options.toolbar})),this.options.tooltip&&(this.options.tooltip===!0?t.push({type:"tooltip"}):t.push({type:"tooltip",...this.options.tooltip})),this.options.watermark&&(this.options.watermark===!0?t.push({type:"watermark"}):t.push({type:"watermark",...this.options.watermark})),t}}const PJ={minimal:{},standard:{tooltip:!0,legend:!0},advanced:{tooltip:!0,legend:!0,minimap:!0,toolbar:!0,history:!0},full:{background:!0,bubbleSets:!0,fullscreen:!0,gridLine:!0,history:!0,legend:!0,contextmenu:!0,minimap:!0,snapline:!0,timebar:!0,title:!0,toolbar:!0,tooltip:!0,watermark:!0},preview:{background:{backgroundColor:"#FAFBFD",opacity:"0.8"},fullscreen:{autoFit:!0,trigger:{request:"F",exit:"Esc"}},gridLine:{size:20,stroke:"#e8e8e8",follow:!0},legend:{type:"legend",key:"legend",position:"bottom-right",trigger:"hover",nodeField:"nodeType",edgeField:"edgeType"},title:{type:"title",key:"title",title:"\u77E5\u8BC6\u56FE\u8C31\u9884\u89C8",align:"center"},tooltip:{position:"top-right",trigger:"hover",getContent:async(n,t)=>{var r;const e=t[0];return n.targetType==="node"?`
211
211
  <div style="padding: 8px; background: #fff; border: 1px solid #d9d9d9; border-radius: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.15);">
212
212
  <div style="font-weight: bold; margin-bottom: 4px;">${((r=e.data)==null?void 0:r.label)||e.id}</div>
213
213
  <div style="color: #666; font-size: 12px;">\u8282\u70B9ID: ${e.id}</div>
214
214
  </div>
215
215
  `:""}}}};function Ah(n={}){return new OJ(n).generate()}function RJ(n,t={}){const e=PJ[n];if(!e)return console.warn(`Unknown plugin preset: ${n}. Using empty configuration.`),Ah(t);const r={...e,...t};return Ah(r)}function Zy(n){return n===void 0?!1:Array.isArray(n)?n.length>0:typeof n=="function"}async function Jy(n,t){return n?typeof n=="function"?n(t):n:[]}function DJ(n,t,e){if(!t)return n;const r=t,i={type:"contextmenu",key:"nodegraph-contextmenu",className:r.className??"nodegraph-contextmenu",trigger:r.trigger??"contextmenu",offset:r.offset??[4,4],enable:o=>{const s=o==null?void 0:o.targetType;return!!(s==="node"&&Zy(r.node)||s==="edge"&&Zy(r.edge)||s==="canvas"&&Zy(r.canvas))},getItems:async o=>{e.lastEventRef.current=o;const s=o==null?void 0:o.targetType;let u=[];s==="node"?u=await Jy(r.node,o):s==="edge"?u=await Jy(r.edge,o):s==="canvas"&&(u=await Jy(r.canvas,o));try{o.__resolvedItems=u}catch{}return u},onClick:(o,s,u)=>{var w,S,k;const c=e.lastEventRef.current,l=c==null?void 0:c.targetType;if(!l||l!=="node"&&l!=="edge"&&l!=="canvas")return;const d=(u==null?void 0:u.id)??((w=c==null?void 0:c.target)==null?void 0:w.id)??(c==null?void 0:c.itemId)??((S=c==null?void 0:c.element)==null?void 0:S.id)??(c==null?void 0:c.elementId)??(c==null?void 0:c.id)??void 0,p=d!=null?String(d):void 0,g=e.getGraph();let m,y;try{l==="node"&&p&&(g!=null&&g.getNodeData)&&(m=g.getNodeData(p)),l==="edge"&&p&&(g!=null&&g.getEdgeData)&&(y=g.getEdgeData(p))}catch{}const v=c==null?void 0:c.__resolvedItems;let x=String(o);if(Array.isArray(v)){const A=v.find(N=>N.value===o);A!=null&&A.name&&(x=A.name)}const E={targetType:l,value:o,name:x,elementId:p,nodeData:m,edgeData:y,graphEvent:c};try{(k=r.onItemClick)==null||k.call(r,E)}catch{}try{e.emit("nodegraph_contextmenu_item",E)}catch{}}},a=n.findIndex(o=>o.type==="contextmenu");if(a>=0){const o=n.slice();return o[a]=i,o}return[...n,i]}const o6=document.createElement("style");o6.innerHTML=`@import url('${NJ.css}');`;document.head.appendChild(o6);const IT="node-graph-fullscreen-host-style";if(typeof document<"u"&&!document.getElementById(IT)){const n=document.createElement("style");n.id=IT,n.textContent=`
216
+ /* \u5168\u5C4F\u5143\u7D20\u8131\u79BB\u539F\u9875\u9762 stacking\uFF0C\u9700\u81EA\u5E26\u80CC\u666F\uFF1B\u5426\u5219\u900F\u660E\u5904\u6613\u4E0E G6 \u753B\u5E03\u8272/\u6D4F\u89C8\u5668\u9ED8\u8BA4\u5C42\u4E0D\u4E00\u81F4 */
216
217
  .node-graph-canvas-host:fullscreen,
217
218
  .node-graph-canvas-host:-webkit-full-screen,
218
219
  .node-graph-canvas-host:-moz-full-screen {
@@ -221,6 +222,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
221
222
  max-width: 100vw;
222
223
  max-height: 100vh;
223
224
  box-sizing: border-box;
225
+ background-color: #FAFBFD;
224
226
  }
225
227
  `,document.head.appendChild(n)}const LJ=n=>{const t=Va(null),[e,r]=lj({width:0,height:0}),i=Va(null),a=Va(n.onReady),o=Va(n.onDestroy);a.current=n.onReady,o.current=n.onDestroy;const s=Va(n.eventEmit);s.current=n.eventEmit;const u=Va(null),c=ii(()=>typeof n.behaviors=="string"?_J(n.behaviors):n.behaviors?eb(n.behaviors):eb(),[n.behaviors]),l=ii(()=>typeof n.plugins=="string"?RJ(n.plugins):n.plugins?Ah(n.plugins):Ah(),[n.plugins]),d=ii(()=>{let v=n.layout;return typeof v=="string"&&(v={type:v}),v},[n.layout]),p=()=>({width:n.width??e.width,height:n.height??e.height}),g=()=>{var x;const v=i.current;i.current=null,v&&((x=o.current)==null||x.call(o,v),v.destroy())},m=()=>{if(!t.current)return null;const{width:v,height:x}=p();if(v<=0||x<=0)return null;const E=(k,A)=>{var N;try{(N=s.current)==null||N.call(s,k,A,()=>{})}catch{}};let w=l;w=DJ(w,n.contextMenu,{lastEventRef:u,emit:E,getGraph:()=>i.current});const S=new Md({container:t.current,width:v,height:x,data:n.data,layout:d,theme:n.theme,behaviors:c,plugins:w,...n.node?{node:n.node}:{},...n.edge?{edge:n.edge}:{}});return S.render(),S},y=v=>{var A,N,T,O;const x=(M,P)=>{var L;try{(L=s.current)==null||L.call(s,M,P,()=>{})}catch{}},E=M=>{var P;try{return(P=v.getNodeData)==null?void 0:P.call(v,M)}catch{return}},w=M=>{var P;try{return(P=v.getEdgeData)==null?void 0:P.call(v,M)}catch{return}},S=async(M,P)=>{var L,j,z;try{const U=((L=v.getElementDataByState)==null?void 0:L.call(v,M,P))??[];if(!Array.isArray(U)||U.length===0)return;const J={};for(const W of U){const at=W==null?void 0:W.id;if(!at)continue;const ut=((j=v.getElementState)==null?void 0:j.call(v,at))??[];J[at]=ut.filter(yt=>yt!==P)}await((z=v.setElementState)==null?void 0:z.call(v,J,!1))}catch{}},k=async(M,P)=>{var L,j;if(P)try{await S(M,"selected");const z=((L=v.getElementState)==null?void 0:L.call(v,P))??[];z.includes("selected")||await((j=v.setElementState)==null?void 0:j.call(v,{[P]:[...z,"selected"]},!1))}catch{}};(A=v.on)==null||A.call(v,"node:click",M=>{var j,z,U;const P=((j=M==null?void 0:M.target)==null?void 0:j.id)??(M==null?void 0:M.itemId)??((z=M==null?void 0:M.element)==null?void 0:z.id)??(M==null?void 0:M.id),L=P?E(String(P)):void 0;(U=n.selectEnable)!=null&&U.node&&k("node",P?String(P):void 0),x("nodegraph_node_selected",{id:P,data:L,event:M})}),(N=v.on)==null||N.call(v,"edge:click",M=>{var j,z,U;const P=((j=M==null?void 0:M.target)==null?void 0:j.id)??(M==null?void 0:M.itemId)??((z=M==null?void 0:M.element)==null?void 0:z.id)??(M==null?void 0:M.id),L=P?w(String(P)):void 0;(U=n.selectEnable)!=null&&U.edge&&k("edge",P?String(P):void 0),x("nodegraph_edge_selected",{id:P,data:L,event:M})}),(T=v.on)==null||T.call(v,"canvas:click",async M=>{await S("node","selected"),await S("edge","selected"),x("nodegraph_selection_cleared",{event:M})}),(O=v.on)==null||O.call(v,"canvas:pointermove",async()=>{await S("node","active"),await S("edge","active")})};return Us(()=>{const v=()=>{if(t.current){const{offsetWidth:E,offsetHeight:w}=t.current;r({width:E,height:w})}};v(),window.addEventListener("resize",v);let x=null;return t.current&&window.ResizeObserver&&(x=new ResizeObserver(v),x.observe(t.current)),()=>{window.removeEventListener("resize",v),x&&x.disconnect()}},[]),Us(()=>{var x;if(i.current||e.width<=0||e.height<=0)return;const v=m();v&&(i.current=v,y(v),(x=a.current)==null||x.call(a,v))},[e.width,e.height]),Us(()=>{var x;if(!i.current)return;g();const v=m();if(v)return i.current=v,y(v),(x=a.current)==null||x.call(a,v),()=>{}},[n.data,n.theme,n.width,n.height,d,c,l,n.contextMenu,n.node,n.edge]),Us(()=>{var w;const v=i.current;if(!v||n.width!=null||n.height!=null||e.width<=0||e.height<=0)return;const{width:x,height:E}=p();try{typeof v.changeSize=="function"?v.changeSize(x,E):typeof v.resize=="function"?v.resize(x,E):typeof v.setSize=="function"?v.setSize(x,E):v.render()}catch{try{(w=v.render)==null||w.call(v)}catch{}}},[e.width,e.height,n.width,n.height]),Us(()=>()=>{g()},[]),nn.jsx("div",{ref:t,className:"node-graph-canvas-host",onContextMenu:v=>v.preventDefault(),style:{width:"100%",height:"100%",minHeight:0}})},bt=new Set,m4=()=>{console.log("\u5F00\u59CB\u6CE8\u518C G6 \u6269\u5C55..."),bt.has("plugin-background")||(re(Kt.PLUGIN,"background",Ed),bt.add("plugin-background")),bt.has("plugin-grid-line")||(re(Kt.PLUGIN,"grid-line",kd),bt.add("plugin-grid-line")),bt.has("plugin-legend")||(re(Kt.PLUGIN,"legend",Sd),bt.add("plugin-legend")),bt.has("plugin-title")||(re(Kt.PLUGIN,"title",qZ),bt.add("plugin-title")),bt.has("plugin-toolbar")||(re(Kt.PLUGIN,"toolbar",Cd),bt.add("plugin-toolbar")),bt.has("plugin-tooltip")||(re(Kt.PLUGIN,"tooltip",Nd),bt.add("plugin-tooltip")),bt.has("plugin-contextmenu")||(re(Kt.PLUGIN,"contextmenu",wd),bt.add("plugin-contextmenu")),bt.has("transform-update-related-edges")||(re(Kt.TRANSFORM,"update-related-edges",Ru),bt.add("transform-update-related-edges")),bt.has("transform-get-edge-actual-ends")||(re(Kt.TRANSFORM,"get-edge-actual-ends",Ru),bt.add("transform-get-edge-actual-ends")),bt.has("transform-arrange-draw-order")||(re(Kt.TRANSFORM,"arrange-draw-order",_d),bt.add("transform-arrange-draw-order")),bt.has("behavior-drag-canvas")||(re(Kt.BEHAVIOR,"drag-canvas",Hh),bt.add("behavior-drag-canvas")),bt.has("behavior-zoom-canvas")||(re(Kt.BEHAVIOR,"zoom-canvas",td),bt.add("behavior-zoom-canvas")),bt.has("behavior-scroll-canvas")||(re(Kt.BEHAVIOR,"scroll-canvas",Qh),bt.add("behavior-scroll-canvas")),bt.has("behavior-optimize-viewport-transform")||(re(Kt.BEHAVIOR,"optimize-viewport-transform",Jh),bt.add("behavior-optimize-viewport-transform")),bt.has("behavior-click-select")||(re(Kt.BEHAVIOR,"click-select",jh),bt.add("behavior-click-select")),bt.has("behavior-drag-element")||(re(Kt.BEHAVIOR,"drag-element",Xh),bt.add("behavior-drag-element")),bt.has("behavior-focus-element")||(re(Kt.BEHAVIOR,"focus-element",Kh),bt.add("behavior-focus-element")),bt.has("behavior-hover-activate")||(re(Kt.BEHAVIOR,"hover-activate",Zh),bt.add("behavior-hover-activate")),bt.has("behavior-auto-adapt-label")||(re(Kt.BEHAVIOR,"auto-adapt-label",Lh),bt.add("behavior-auto-adapt-label")),bt.has("behavior-collapse-expand-node")||(re(Kt.BEHAVIOR,"collapse-expand-node",_u),bt.add("behavior-collapse-expand-node")),bt.has("behavior-collapse-expand-combo")||(re(Kt.BEHAVIOR,"collapse-expand-combo",_u),bt.add("behavior-collapse-expand-combo")),bt.has("node-circle")||(re(Kt.NODE,"circle",zh),bt.add("node-circle")),bt.has("edge-line")||(re(Kt.EDGE,"line",Wh),bt.add("edge-line")),bt.has("edge-quadratic")||(re(Kt.EDGE,"quadratic",$h),bt.add("edge-quadratic")),bt.has("edge-cubic")||(re(Kt.EDGE,"cubic",fo),bt.add("edge-cubic")),bt.has("edge-cubic-horizontal")||(re(Kt.EDGE,"cubic-horizontal",Gh),bt.add("edge-cubic-horizontal")),bt.has("edge-cubic-vertical")||(re(Kt.EDGE,"cubic-vertical",Uh),bt.add("edge-cubic-vertical")),bt.has("edge-cubic-radial")||(re(Kt.EDGE,"cubic-radial",Vh),bt.add("edge-cubic-radial")),bt.has("edge-polyline")||(re(Kt.EDGE,"polyline",Yh),bt.add("edge-polyline")),bt.has("layout-force")||(re(Kt.LAYOUT,"force",S$),bt.add("layout-force")),bt.has("layout-d3-force")||(re(Kt.LAYOUT,"d3-force",Q$),bt.add("layout-d3-force")),bt.has("layout-dagre")||(re(Kt.LAYOUT,"dagre",xd),bt.add("layout-dagre")),console.log("G6 \u6269\u5C55\u6CE8\u518C\u5B8C\u6210\uFF01")};var jl={exports:{}};/**
226
228
  * @license
@@ -296,7 +298,7 @@ function print() { __p += __j.call(arguments, '') }
296
298
  height: 1px;
297
299
  background: #e5e6eb;
298
300
  margin: 2px auto;
299
- `;function c4({showFullscreen:n=!0,onAction:t}){return nn.jsxs(u4,{role:"toolbar","aria-label":"\u56FE\u8C31\u5DE5\u5177\u680F",children:[nn.jsx(Tl,{title:"\u5168\u5C4F",onClick:()=>t("fullscreen"),children:nn.jsx("img",{src:i4,width:20})}),nn.jsx(o1,{}),nn.jsx(Tl,{title:"\u653E\u5927",onClick:()=>t("zoom-in"),children:nn.jsx("img",{src:o4,width:20})}),nn.jsx(o1,{}),nn.jsx(Tl,{title:"\u7F29\u5C0F",onClick:()=>t("zoom-out"),children:nn.jsx("img",{src:s4,width:20})}),nn.jsx(o1,{}),nn.jsx(Tl,{title:"\u56DE\u5230\u4E2D\u5FC3",onClick:()=>t("auto-fit"),children:nn.jsx("img",{src:a4,width:20})})]})}function _6(n){var t;try{const e=(t=n==null?void 0:n.context)==null?void 0:t.canvas;if(e&&typeof e.getContainer=="function"){const r=e.getContainer();return r instanceof HTMLElement?r:null}}catch{}return null}function eM(n){const t=_6(n),e=document.fullscreenElement;return!!(t&&e&&e===t)}function nM(n,t){var e,r,i,a;if(n)try{const o=n.getZoom?n.getZoom():1;switch(t){case"zoom-in":{const s=Math.min(o*1.2,10);n.zoomTo?n.zoomTo(s):n.zoom&&n.zoom(1.2);break}case"zoom-out":{const s=Math.max(o/1.2,.1);n.zoomTo?n.zoomTo(s):n.zoom&&n.zoom(.8);break}case"auto-fit":{n.fitView?n.fitView():n.fitCenter&&n.fitCenter();break}case"fullscreen":{const s=(e=n.getPluginInstance)==null?void 0:e.call(n,"fullscreen");if(s){eM(n)?(r=s.exit)==null||r.call(s):document.fullscreenElement||((i=s.request)==null||i.call(s));return}const u=_6(n);if(!u)return;eM(n)?document.exitFullscreen().catch(()=>{}):document.fullscreenElement||((a=u.requestFullscreen)==null||a.call(u).catch(()=>{}));break}default:break}}catch(o){console.warn("\u6267\u884C\u5DE5\u5177\u680F\u52A8\u4F5C\u5931\u8D25:",o)}}function y4({data:n,behaviors:t,interactionSwitch:e,title:r="\u77E5\u8BC6\u56FE\u8C31\u9884\u89C8",subtitle:i,centerNode:a,backgroundColor:o="#f8f9fa",showGrid:s=!0,showLegend:u=!0,showTooltip:c=!0,showFullscreen:l=!0,showMinimap:d=!1,layout:p,customPlugins:g={},tooltipRender:m,tooltipPosition:y="top",tooltipOffset:v=[0,-5],toolbarMode:x="default",node:E,nodeHoverStyle:w,nodeSelectedStyle:S,edge:k,edgeHoverStyle:A,edgeSelectedStyle:N,eventEmit:T,contextMenu:O,onReady:M,onDestroy:P,tooltipShow:L}){var Y;const j=Va(null),z=ii(()=>{var F;try{if(!n)return console.error("\u6570\u636E\u4E3A\u7A7A"),null;if(!n.nodeList||!n.edgeList)return console.error("\u6570\u636E\u683C\u5F0F\u4E0D\u6B63\u786E\uFF0C\u7F3A\u5C11 nodeList \u6216 edgeList"),null;console.log("\u5F00\u59CB\u8C03\u7528 transformGiengraphToG6...");const K=WJ(n);return console.log("transformed",K),K}catch(K){return console.error("=== \u6570\u636E\u8F6C\u6362\u9519\u8BEF ===",K),console.error("\u9519\u8BEF\u7C7B\u578B:",(F=K==null?void 0:K.constructor)==null?void 0:F.name),console.error("\u539F\u59CB\u6570\u636E:",n),null}},[n]),U=ii(()=>{if(!(z!=null&&z.nodes)||!a)return;if(a.id)return a.id;const F=Object.entries(a).filter(([ot,dt])=>ot!=="id"&&dt!==void 0&&dt!==null);if(F.length===0)return;const K=(ot,dt)=>{if(Array.isArray(ot)){for(const mt of ot)if(mt&&String(mt.name??"")===dt)return mt.value}};for(const ot of z.nodes){const dt=(ot==null?void 0:ot.data)??ot;let mt=!0;for(const[Ot,ne]of F){const Qt=(dt==null?void 0:dt[Ot])??(ot==null?void 0:ot[Ot]),_t=K(dt==null?void 0:dt.properties,Ot);if((Qt!==void 0?Qt:_t)!==ne){mt=!1;break}}if(mt&&(ot!=null&&ot.id))return ot.id}},[z,a]),J=ii(()=>{if(m)return QJ({render:F=>nn.jsx("div",{onWheel:K=>K.stopPropagation(),onTouchMove:K=>K.stopPropagation(),style:{maxWidth:310,maxHeight:300,overflowY:"auto",padding:"10px 12px"},children:m(F)}),containerClassName:"g6-react-tooltip-root"})},[m]),W=ii(()=>{const F={background:{backgroundColor:o,opacity:"0.8"},fullscreen:l||x!=="hide"?{autoFit:!0,trigger:{request:"F",exit:"Esc"}}:!1,gridLine:s?{size:40,stroke:"#e8e8e8",follow:!0}:!1,minimap:!!d,legend:u?{type:"legend",key:"legend",position:"bottom-right",trigger:"hover",nodeField:"nodeType",edgeField:"edgeType",width:300,height:200,backgroundColor:"rgba(255, 255, 255, 0.9)",border:"1px solid #e8e8e8",borderRadius:6,padding:[12,16]}:!1,title:{type:"title",key:"title",title:r,subtitle:i,align:"left"},toolbar:x==="default"?{type:"toolbar",key:"toolbar",position:"top-right",getItems:()=>{const K=[{id:"zoom-in",value:"zoom-in",title:"\u653E\u5927"},{id:"zoom-out",value:"zoom-out",title:"\u7F29\u5C0F"},{id:"auto-fit",value:"auto-fit",title:"\u9002\u5E94\u753B\u5E03"}];return K.push({id:"request-fullscreen",value:"fullscreen",title:"\u5168\u5C4F"}),K},onClick:K=>{nM(j.current,K)}}:!1,tooltip:c?{enable:(K,ot)=>!L||K.targetType==="node"&&(L!=null&&L.node)?!0:!!(K.targetType==="edge"&&(L!=null&&L.edge)),type:"tooltip",key:"tooltip",position:y,trigger:"hover",enterable:!0,offset:v,style:{".tooltip":m?{"background-color":"transparent",border:"none","box-shadow":"none","border-radius":"0",padding:"0",margin:"0","min-width":"0","max-width":"none","max-height":"300px","overflow-y":"auto",transition:"none",filter:"none"}:{"max-height":"300px","overflow-y":"auto"}},getContent:async(K,ot)=>{if(J)return J(K,ot);const dt=ot==null?void 0:ot[0];if(!dt)return"";const mt=dt.data||{},Ot=`<div style="font-weight:600;font-size:12px;padding-bottom:6px;border-bottom:1px solid #E5E6EB;">${mt.name||mt.label||dt.id}</div>`,ne=(()=>{const Qt=new Set(["id","name","nodeType","type","x","y","style","states"]),_t=[];if(Array.isArray(mt==null?void 0:mt.properties)&&mt.properties.length>0)for(const wt of mt.properties)wt&&_t.push({key:String(wt.name??""),value:wt.value});else Object.entries(mt||{}).forEach(([wt,we])=>{!Qt.has(wt)&&we!==void 0&&we!==null&&_t.push({key:wt,value:we})});return`<div>${_t.map(({key:wt,value:we},Et)=>`
301
+ `;function c4({showFullscreen:n=!0,onAction:t}){return nn.jsxs(u4,{role:"toolbar","aria-label":"\u56FE\u8C31\u5DE5\u5177\u680F",children:[nn.jsx(Tl,{title:"\u5168\u5C4F",onClick:()=>t("fullscreen"),children:nn.jsx("img",{src:i4,width:20})}),nn.jsx(o1,{}),nn.jsx(Tl,{title:"\u653E\u5927",onClick:()=>t("zoom-in"),children:nn.jsx("img",{src:o4,width:20})}),nn.jsx(o1,{}),nn.jsx(Tl,{title:"\u7F29\u5C0F",onClick:()=>t("zoom-out"),children:nn.jsx("img",{src:s4,width:20})}),nn.jsx(o1,{}),nn.jsx(Tl,{title:"\u56DE\u5230\u4E2D\u5FC3",onClick:()=>t("auto-fit"),children:nn.jsx("img",{src:a4,width:20})})]})}function _6(n){var t;try{const e=(t=n==null?void 0:n.context)==null?void 0:t.canvas;if(e&&typeof e.getContainer=="function"){const r=e.getContainer();return r instanceof HTMLElement?r:null}}catch{}return null}function eM(n){const t=_6(n),e=document.fullscreenElement;return!!(t&&e&&e===t)}function nM(n,t){var e,r,i,a;if(n)try{const o=n.getZoom?n.getZoom():1;switch(t){case"zoom-in":{const s=Math.min(o*1.2,10);n.zoomTo?n.zoomTo(s):n.zoom&&n.zoom(1.2);break}case"zoom-out":{const s=Math.max(o/1.2,.1);n.zoomTo?n.zoomTo(s):n.zoom&&n.zoom(.8);break}case"auto-fit":{n.fitView?n.fitView():n.fitCenter&&n.fitCenter();break}case"fullscreen":{const s=(e=n.getPluginInstance)==null?void 0:e.call(n,"fullscreen");if(s){eM(n)?(r=s.exit)==null||r.call(s):document.fullscreenElement||((i=s.request)==null||i.call(s));return}const u=_6(n);if(!u)return;eM(n)?document.exitFullscreen().catch(()=>{}):document.fullscreenElement||((a=u.requestFullscreen)==null||a.call(u).catch(()=>{}));break}default:break}}catch(o){console.warn("\u6267\u884C\u5DE5\u5177\u680F\u52A8\u4F5C\u5931\u8D25:",o)}}function y4({data:n,behaviors:t,interactionSwitch:e,title:r="\u77E5\u8BC6\u56FE\u8C31\u9884\u89C8",subtitle:i,centerNode:a,backgroundColor:o="#FAFBFD",showGrid:s=!0,showLegend:u=!0,showTooltip:c=!0,showFullscreen:l=!0,showMinimap:d=!1,layout:p,customPlugins:g={},tooltipRender:m,tooltipPosition:y="top",tooltipOffset:v=[0,-5],toolbarMode:x="default",node:E,nodeHoverStyle:w,nodeSelectedStyle:S,edge:k,edgeHoverStyle:A,edgeSelectedStyle:N,eventEmit:T,contextMenu:O,onReady:M,onDestroy:P,tooltipShow:L}){var Y;const j=Va(null),z=ii(()=>{var F;try{if(!n)return console.error("\u6570\u636E\u4E3A\u7A7A"),null;if(!n.nodeList||!n.edgeList)return console.error("\u6570\u636E\u683C\u5F0F\u4E0D\u6B63\u786E\uFF0C\u7F3A\u5C11 nodeList \u6216 edgeList"),null;console.log("\u5F00\u59CB\u8C03\u7528 transformGiengraphToG6...");const K=WJ(n);return console.log("transformed",K),K}catch(K){return console.error("=== \u6570\u636E\u8F6C\u6362\u9519\u8BEF ===",K),console.error("\u9519\u8BEF\u7C7B\u578B:",(F=K==null?void 0:K.constructor)==null?void 0:F.name),console.error("\u539F\u59CB\u6570\u636E:",n),null}},[n]),U=ii(()=>{if(!(z!=null&&z.nodes)||!a)return;if(a.id)return a.id;const F=Object.entries(a).filter(([ot,dt])=>ot!=="id"&&dt!==void 0&&dt!==null);if(F.length===0)return;const K=(ot,dt)=>{if(Array.isArray(ot)){for(const mt of ot)if(mt&&String(mt.name??"")===dt)return mt.value}};for(const ot of z.nodes){const dt=(ot==null?void 0:ot.data)??ot;let mt=!0;for(const[Ot,ne]of F){const Qt=(dt==null?void 0:dt[Ot])??(ot==null?void 0:ot[Ot]),_t=K(dt==null?void 0:dt.properties,Ot);if((Qt!==void 0?Qt:_t)!==ne){mt=!1;break}}if(mt&&(ot!=null&&ot.id))return ot.id}},[z,a]),J=ii(()=>{if(m)return QJ({render:F=>nn.jsx("div",{onWheel:K=>K.stopPropagation(),onTouchMove:K=>K.stopPropagation(),style:{maxWidth:310,maxHeight:300,overflowY:"auto",padding:"10px 12px"},children:m(F)}),containerClassName:"g6-react-tooltip-root"})},[m]),W=ii(()=>{const F={background:{backgroundColor:o},fullscreen:l||x!=="hide"?{autoFit:!0,trigger:{request:"F",exit:"Esc"}}:!1,gridLine:s?{size:40,stroke:"#e8e8e8",follow:!0}:!1,minimap:!!d,legend:u?{type:"legend",key:"legend",position:"bottom-right",trigger:"hover",nodeField:"nodeType",edgeField:"edgeType",width:300,height:200,backgroundColor:"rgba(255, 255, 255, 0.9)",border:"1px solid #e8e8e8",borderRadius:6,padding:[12,16]}:!1,title:{type:"title",key:"title",title:r,subtitle:i,align:"left"},toolbar:x==="default"?{type:"toolbar",key:"toolbar",position:"top-right",getItems:()=>{const K=[{id:"zoom-in",value:"zoom-in",title:"\u653E\u5927"},{id:"zoom-out",value:"zoom-out",title:"\u7F29\u5C0F"},{id:"auto-fit",value:"auto-fit",title:"\u9002\u5E94\u753B\u5E03"}];return K.push({id:"request-fullscreen",value:"fullscreen",title:"\u5168\u5C4F"}),K},onClick:K=>{nM(j.current,K)}}:!1,tooltip:c?{enable:(K,ot)=>!L||K.targetType==="node"&&(L!=null&&L.node)?!0:!!(K.targetType==="edge"&&(L!=null&&L.edge)),type:"tooltip",key:"tooltip",position:y,trigger:"hover",enterable:!0,offset:v,style:{".tooltip":m?{"background-color":"transparent",border:"none","box-shadow":"none","border-radius":"0",padding:"0",margin:"0","min-width":"0","max-width":"none","max-height":"300px","overflow-y":"auto",transition:"none",filter:"none"}:{"max-height":"300px","overflow-y":"auto"}},getContent:async(K,ot)=>{if(J)return J(K,ot);const dt=ot==null?void 0:ot[0];if(!dt)return"";const mt=dt.data||{},Ot=`<div style="font-weight:600;font-size:12px;padding-bottom:6px;border-bottom:1px solid #E5E6EB;">${mt.name||mt.label||dt.id}</div>`,ne=(()=>{const Qt=new Set(["id","name","nodeType","type","x","y","style","states"]),_t=[];if(Array.isArray(mt==null?void 0:mt.properties)&&mt.properties.length>0)for(const wt of mt.properties)wt&&_t.push({key:String(wt.name??""),value:wt.value});else Object.entries(mt||{}).forEach(([wt,we])=>{!Qt.has(wt)&&we!==void 0&&we!==null&&_t.push({key:wt,value:we})});return`<div>${_t.map(({key:wt,value:we},Et)=>`
300
302
  <div style="display:flex; gap:8px; font-size:12px; line-height:20px; padding:6px 0; ${Et>0?"border-top:1px solid #F2F3F5;":""}">
301
303
  <span style="color:#8F959E; min-width:120px; white-space:nowrap;">${wt}</span>
302
304
  <span style="color:#1F2329; word-break:break-all;">${String(we)}</span>
@@ -1,4 +1,4 @@
1
- import{jsxs as Ee,jsx as V,Fragment as Oi}from"react/jsx-runtime";import*as it from"react";import Ri,{useState as ke,useMemo as s2,useRef as i2,useEffect as Ue,memo as Ar,Suspense as F6,forwardRef as rr,createElement as M1,useImperativeHandle as e3,useCallback as x2,createContext as H6,useContext as O6}from"react";import{ChatMessageAdapter as R6,mergeLiveChunkToNodes as Y6}from"@mxmweb/rtext";import{Icon as m2,useTheme as t3,deepMergeTheme as QA,defaultTheme as _s}from"@mxmweb/zui";import"dayjs";import h2 from"axios";import{message as O2,Popconfirm as z6,Popover as N6,Tooltip as Ti,Switch as j6,Input as PA,Form as B0,ConfigProvider as gn,Modal as G6,Button as Mi,Tree as U6,Tag as V6,Table as X6,Pagination as J6,Empty as Z6,Drawer as i3,Select as A3,Flex as q6,Badge as r3}from"antd";import{R as W6,k as K6,g as Jr,a as Bi}from"./index-CIPEixYE.js";import{u as Bt}from"./index-CpW6Dhpp.js";import{C as n3,G as s3,a as _6}from"./GientechStreamReader-_ih9ja1B.js";import{X as ln}from"./x-CdZQbi--.js";import{c as nr}from"./createLucideIcon-Bj5DlX2s.js";import{L as $s}from"./loader-circle-C1Oa97Sz.js";import{validateFileUpload as a3,showValidationErrors as o3}from"@mxmweb/aichat";import{C as $6}from"./circle-plus-RlDPoPkb.js";/**
1
+ import{jsxs as Ee,jsx as V,Fragment as Oi}from"react/jsx-runtime";import*as it from"react";import Ri,{useState as ke,useMemo as s2,useRef as i2,useEffect as Ue,memo as Ar,Suspense as F6,forwardRef as rr,createElement as M1,useImperativeHandle as e3,useCallback as x2,createContext as H6,useContext as O6}from"react";import{ChatMessageAdapter as R6,mergeLiveChunkToNodes as Y6}from"@mxmweb/rtext";import{Icon as m2,useTheme as t3,deepMergeTheme as QA,defaultTheme as _s}from"@mxmweb/zui";import"dayjs";import h2 from"axios";import{message as O2,Popconfirm as z6,Popover as N6,Tooltip as Ti,Switch as j6,Input as PA,Form as B0,ConfigProvider as gn,Modal as G6,Button as Mi,Tree as U6,Tag as V6,Table as X6,Pagination as J6,Empty as Z6,Drawer as i3,Select as A3,Flex as q6,Badge as r3}from"antd";import{R as W6,k as K6,g as Jr,a as Bi}from"./index-BIS6Xs7b.js";import{u as Bt}from"./index-CpW6Dhpp.js";import{C as n3,G as s3,a as _6}from"./GientechStreamReader-_ih9ja1B.js";import{X as ln}from"./x-CdZQbi--.js";import{c as nr}from"./createLucideIcon-Bj5DlX2s.js";import{L as $s}from"./loader-circle-C1Oa97Sz.js";import{validateFileUpload as a3,showValidationErrors as o3}from"@mxmweb/aichat";import{C as $6}from"./circle-plus-RlDPoPkb.js";/**
2
2
  * @license lucide-react v0.456.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.