3 lines
12 KiB
JavaScript
3 lines
12 KiB
JavaScript
import{a as $,b as P,d as F,e as N,f as M,g as U,h as j,i as R,j as S,m as A,n as H,o as V,p as W}from"./chunk-N4EFGQ5G.min.js";import{b as G}from"./chunk-LXB37CFX.min.js";import{a as k}from"./chunk-RNO6SWHZ.min.js";import{A as L,b as _,j as O,o as p}from"./chunk-K2MRC2FE.min.js";import{Ga as s,Ja as C,h as T,nb as B}from"./chunk-YEACHCAA.min.js";function m(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:tt(e),edges:et(e)};return p(e.graph())||(t.value=_(e.graph())),t}function tt(e){return O(e.nodes(),function(t){var n=e.node(t),r=e.parent(t),i={v:t};return p(n)||(i.value=n),p(r)||(i.parent=r),i})}function et(e){return O(e.edges(),function(t){var n=e.edge(t),r={v:t.v,w:t.w};return p(t.name)||(r.name=t.name),p(n)||(r.value=n),r})}var l={},g={},q={},it=()=>{g={},q={},l={}},J=(e,t)=>(s.trace("In isDescendant",t," ",e," = ",g[t].includes(e)),!!g[t].includes(e)),st=(e,t)=>(s.info("Descendants of ",t," is ",g[t]),s.info("Edge is ",e),e.v===t||e.w===t?!1:g[t]?g[t].includes(e.v)||J(e.v,t)||J(e.w,t)||g[t].includes(e.w):(s.debug("Tilt, ",t,",not in descendants"),!1)),z=(e,t,n,r)=>{s.warn("Copying children of ",e,"root",r,"data",t.node(e),r);let i=t.children(e)||[];e!==r&&i.push(e),s.warn("Copying (nodes) clusterId",e,"nodes",i),i.forEach(a=>{if(t.children(a).length>0)z(a,t,n,r);else{let d=t.node(a);s.info("cp ",a," to ",r," with parent ",e),n.setNode(a,d),r!==t.parent(a)&&(s.warn("Setting parent",a,t.parent(a)),n.setParent(a,t.parent(a))),e!==r&&a!==e?(s.debug("Setting parent",a,e),n.setParent(a,e)):(s.info("In copy ",e,"root",r,"data",t.node(e),r),s.debug("Not Setting parent for node=",a,"cluster!==rootId",e!==r,"node!==clusterId",a!==e));let h=t.edges(a);s.debug("Copying Edges",h),h.forEach(f=>{s.info("Edge",f);let u=t.edge(f.v,f.w,f.name);s.info("Edge data",u,r);try{st(f,r)?(s.info("Copying as ",f.v,f.w,u,f.name),n.setEdge(f.v,f.w,u,f.name),s.info("newGraph edges ",n.edges(),n.edge(n.edges()[0]))):s.info("Skipping copy of edge ",f.v,"-->",f.w," rootId: ",r," clusterId:",e)}catch(w){s.error(w)}})}s.debug("Removing node",a),t.removeNode(a)})},K=(e,t)=>{let n=t.children(e),r=[...n];for(let i of n)q[i]=e,r=[...r,...K(i,t)];return r},X=(e,t)=>{s.trace("Searching",e);let n=t.children(e);if(s.trace("Searching children of id ",e,n),n.length<1)return s.trace("This is a valid node",e),e;for(let r of n){let i=X(r,t);if(i)return s.trace("Found replacement for",e," => ",i),i}},D=e=>!l[e]||!l[e].externalConnections?e:l[e]?l[e].id:e,rt=(e,t)=>{if(!e||t>10){s.debug("Opting out, no graph ");return}else s.debug("Opting in, graph ");e.nodes().forEach(function(n){e.children(n).length>0&&(s.warn("Cluster identified",n," Replacement id in edges: ",X(n,e)),g[n]=K(n,e),l[n]={id:X(n,e),clusterData:e.node(n)})}),e.nodes().forEach(function(n){let r=e.children(n),i=e.edges();r.length>0?(s.debug("Cluster identified",n,g),i.forEach(a=>{if(a.v!==n&&a.w!==n){let d=J(a.v,n),h=J(a.w,n);d^h&&(s.warn("Edge: ",a," leaves cluster ",n),s.warn("Descendants of XXX ",n,": ",g[n]),l[n].externalConnections=!0)}})):s.debug("Not a cluster ",n,g)});for(let n of Object.keys(l)){let r=l[n].id,i=e.parent(r);i!==n&&l[i]&&!l[i].externalConnections&&(l[n].id=i)}e.edges().forEach(function(n){let r=e.edge(n);s.warn("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(n)),s.warn("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(e.edge(n)));let i=n.v,a=n.w;if(s.warn("Fix XXX",l,"ids:",n.v,n.w,"Translating: ",l[n.v]," --- ",l[n.w]),l[n.v]&&l[n.w]&&l[n.v]===l[n.w]){s.warn("Fixing and trixing link to self - removing XXX",n.v,n.w,n.name),s.warn("Fixing and trixing - removing XXX",n.v,n.w,n.name),i=D(n.v),a=D(n.w),e.removeEdge(n.v,n.w,n.name);let d=n.w+"---"+n.v;e.setNode(d,{domId:d,id:d,labelStyle:"",labelText:r.label,padding:0,shape:"labelRect",style:""});let h=structuredClone(r),f=structuredClone(r);h.label="",h.arrowTypeEnd="none",f.label="",h.fromCluster=n.v,f.toCluster=n.v,e.setEdge(i,d,h,n.name+"-cyclic-special"),e.setEdge(d,a,f,n.name+"-cyclic-special")}else if(l[n.v]||l[n.w]){if(s.warn("Fixing and trixing - removing XXX",n.v,n.w,n.name),i=D(n
|
|||
|
|
//# sourceMappingURL=chunk-5FWMXAFW.min.js.map
|