livebook/static/assets/chunk-5N5GTYLJ.js

2 lines
11 KiB
JavaScript
Raw Normal View History

2023-06-20 23:34:33 +08:00
import{a as R,b as D,d as _,e as x,f as k,g as F,h as G,i as O,j as U,k as A,l as $,m as H}from"./chunk-DNBLW6CQ.js";import{a as P}from"./chunk-2GUY7UNH.js";import{a as J,b as L}from"./chunk-DHRALF6T.js";import{e as T,m as B,r as v}from"./chunk-FHXD2RFP.js";import{da as n,fa as y,h as C,na as N}from"./chunk-RQT2CUZQ.js";function b(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Q(e),edges:Y(e)};return v(e.graph())||(t.value=T(e.graph())),t}function Q(e){return B(e.nodes(),function(t){var i=e.node(t),r=e.parent(t),s={v:t};return v(i)||(s.value=i),v(r)||(s.parent=r),s})}function Y(e){return B(e.edges(),function(t){var i=e.edge(t),r={v:t.v,w:t.w};return v(t.name)||(r.name=t.name),v(i)||(r.value=i),r})}var f={},m={},M={},I=()=>{m={},M={},f={}},S=(e,t)=>(n.trace("In isDecendant",t," ",e," = ",m[t].includes(e)),!!m[t].includes(e)),tt=(e,t)=>(n.info("Decendants of ",t," is ",m[t]),n.info("Edge is ",e),e.v===t||e.w===t?!1:m[t]?m[t].includes(e.v)||S(e.v,t)||S(e.w,t)||m[t].includes(e.w):(n.debug("Tilt, ",t,",not in decendants"),!1)),V=(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(a=>{if(t.children(a).length>0)V(a,t,i,r);else{let h=t.node(a);n.info("cp ",a," to ",r," with parent ",e),i.setNode(a,h),r!==t.parent(a)&&(n.warn("Setting parent",a,t.parent(a)),i.setParent(a,t.parent(a))),e!==r&&a!==e?(n.debug("Setting parent",a,e),i.setParent(a,e)):(n.info("In copy ",e,"root",r,"data",t.node(e),r),n.debug("Not Setting parent for node=",a,"cluster!==rootId",e!==r,"node!==clusterId",a!==e));let l=t.edges(a);n.debug("Copying Edges",l),l.forEach(d=>{n.info("Edge",d);let w=t.edge(d.v,d.w,d.name);n.info("Edge data",w,r);try{tt(d,r)?(n.info("Copying as ",d.v,d.w,w,d.name),i.setEdge(d.v,d.w,w,d.name),n.info("newGraph edges ",i.edges(),i.edge(i.edges()[0]))):n.info("Skipping copy of edge ",d.v,"-->",d.w," rootId: ",r," clusterId:",e)}catch(g){n.error(g)}})}n.debug("Removing node",a),t.removeNode(a)})},j=(e,t)=>{let i=t.children(e),r=[...i];for(let s of i)M[s]=e,r=[...r,...j(s,t)];return r},E=(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=E(r,t);if(s)return n.trace("Found replacement for",e," => ",s),s}},p=e=>!f[e]||!f[e].externalConnections?e:f[e]?f[e].id:e,et=(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: ",E(i,e)),m[i]=j(i,e),f[i]={id:E(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,m),s.forEach(a=>{if(a.v!==i&&a.w!==i){let h=S(a.v,i),l=S(a.w,i);h^l&&(n.warn("Edge: ",a," leaves cluster ",i),n.warn("Decendants of XXX ",i,": ",m[i]),f[i].externalConnections=!0)}})):n.debug("Not a cluster ",i,m)}),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,a=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=p(i.v),a=p(i.w),e.removeEdge(i.v,i.w,i.name);let h=i.w+"---"+i.v;e.setNode(h,{domId:h,id:h,labelStyle:"",labelText:r.label,padding:0,shape:"labelRect",style:""});let l=JSON.parse(JSON.stringify(r)),d=JSON.parse(JSON.stringify(r));l.label="",l.arrowTypeEnd="none",d.label="",l.fromCluster=i.v,d.toCluster=i.v,e.setEdge(s,h,l,i.name+"-cyclic-special"),e.setEdge(h,a,d,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=p(i.v),a=p(i.w),e.removeEdge(i.v,i.w,i.name),s!==i.v&&(r.fromCluster=i.v),a!==i.w&&(r.toCluster=i.w),n.warn("Fix Replacing with XX