livebook/static/assets/chunk-YDUJKTJQ.js

2 lines
11 KiB
JavaScript
Raw Normal View History

2024-01-24 23:02:24 +08:00
import{a as _,b as O,d as k,e as y,f as F,g as G,h as U,i as T,k as A,l as $,m as H,n as M}from"./chunk-RNCRXQUO.js";import{a as R}from"./chunk-RB5OF3IH.js";import{a as L,d as D,f as x,j as J,k as P}from"./chunk-SWZYHCA4.js";import{$a as N,Fa as n,Ia as E,h as B}from"./chunk-KR7JTV7U.js";function m(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Y(e),edges:Z(e)};return x(e.graph())||(t.value=L(e.graph())),t}function Y(e){return D(e.nodes(),function(t){var i=e.node(t),r=e.parent(t),s={v:t};return x(i)||(s.value=i),x(r)||(s.parent=r),s})}function Z(e){return D(e.edges(),function(t){var i=e.edge(t),r={v:t.v,w:t.w};return x(t.name)||(r.name=t.name),x(i)||(r.value=i),r})}var f={},g={},V={},tt=()=>{g={},V={},f={}},S=(e,t)=>(n.trace("In isDecendant",t," ",e," = ",g[t].includes(e)),!!g[t].includes(e)),et=(e,t)=>(n.info("Decendants of ",t," is ",g[t]),n.info("Edge is ",e),e.v===t||e.w===t?!1:g[t]?g[t].includes(e.v)||S(e.v,t)||S(e.w,t)||g[t].includes(e.w):(n.debug("Tilt, ",t,",not in decendants"),!1)),j=(e,t,i,r)=>{n.warn("Copying children of ",e,"root",r,"data",t.node(e),r);let s=t.children(e)||[];e!==r&&s.push(e),n.warn("Copying (nodes) clusterId",e,"nodes",s),s.forEach(c=>{if(t.children(c).length>0)j(c,t,i,r);else{let d=t.node(c);n.info("cp ",c," to ",r," with parent ",e),i.setNode(c,d),r!==t.parent(c)&&(n.warn("Setting parent",c,t.parent(c)),i.setParent(c,t.parent(c))),e!==r&&c!==e?(n.debug("Setting parent",c,e),i.setParent(c,e)):(n.info("In copy ",e,"root",r,"data",t.node(e),r),n.debug("Not Setting parent for node=",c,"cluster!==rootId",e!==r,"node!==clusterId",c!==e));let l=t.edges(c);n.debug("Copying Edges",l),l.forEach(h=>{n.info("Edge",h);let u=t.edge(h.v,h.w,h.name);n.info("Edge data",u,r);try{et(h,r)?(n.info("Copying as ",h.v,h.w,u,h.name),i.setEdge(h.v,h.w,u,h.name),n.info("newGraph edges ",i.edges(),i.edge(i.edges()[0]))):n.info("Skipping copy of edge ",h.v,"-->",h.w," rootId: ",r," clusterId:",e)}catch(w){n.error(w)}})}n.debug("Removing node",c),t.removeNode(c)})},W=(e,t)=>{let i=t.children(e),r=[...i];for(let s of i)V[s]=e,r=[...r,...W(s,t)];return r},p=(e,t)=>{n.trace("Searching",e);let i=t.children(e);if(n.trace("Searching children of id ",e,i),i.length<1)return n.trace("This is a valid node",e),e;for(let r of i){let s=p(r,t);if(s)return n.trace("Found replacement for",e," => ",s),s}},X=e=>!f[e]||!f[e].externalConnections?e:f[e]?f[e].id:e,it=(e,t)=>{if(!e||t>10){n.debug("Opting out, no graph ");return}else n.debug("Opting in, graph ");e.nodes().forEach(function(i){e.children(i).length>0&&(n.warn("Cluster identified",i," Replacement id in edges: ",p(i,e)),g[i]=W(i,e),f[i]={id:p(i,e),clusterData:e.node(i)})}),e.nodes().forEach(function(i){let r=e.children(i),s=e.edges();r.length>0?(n.debug("Cluster identified",i,g),s.forEach(c=>{if(c.v!==i&&c.w!==i){let d=S(c.v,i),l=S(c.w,i);d^l&&(n.warn("Edge: ",c," leaves cluster ",i),n.warn("Decendants of XXX ",i,": ",g[i]),f[i].externalConnections=!0)}})):n.debug("Not a cluster ",i,g)}),e.edges().forEach(function(i){let r=e.edge(i);n.warn("Edge "+i.v+" -> "+i.w+": "+JSON.stringify(i)),n.warn("Edge "+i.v+" -> "+i.w+": "+JSON.stringify(e.edge(i)));let s=i.v,c=i.w;if(n.warn("Fix XXX",f,"ids:",i.v,i.w,"Translating: ",f[i.v]," --- ",f[i.w]),f[i.v]&&f[i.w]&&f[i.v]===f[i.w]){n.warn("Fixing and trixing link to self - removing XXX",i.v,i.w,i.name),n.warn("Fixing and trixing - removing XXX",i.v,i.w,i.name),s=X(i.v),c=X(i.w),e.removeEdge(i.v,i.w,i.name);let d=i.w+"---"+i.v;e.setNode(d,{domId:d,id:d,labelStyle:"",labelText:r.label,padding:0,shape:"labelRect",style:""});let l=structuredClone(r),h=structuredClone(r);l.label="",l.arrowTypeEnd="none",h.label="",l.fromCluster=i.v,h.toCluster=i.v,e.setEdge(s,d,l,i.name+"-cyclic-special"),e.setEdge(d,c,h,i.name+"-cyclic-special")}else(f[i.v]||f[i.w])&&(n.warn("Fixing and trixing - removing XXX",i.v,i.w,i.name),s=X(i.v),c=X(i.w),e.removeEdge(i.v,i.w,i.name),s!==i.v&&(r.fromCluster=i.v),c!==i.w&&(r.toCluster=i.w),n.warn("Fix Replacing with XXX",s,c,i.name),e.setEdge(s,c,r,i.name))}),n.warn("Adju