import{_asw,anasT,aoasF,apasM,aqasY,lasi,das_,arasj,asasH,atasq,Sasz,auasO,avasK,awasQ,axasU,ayasV}from"./index-tOBB4d1H.js";import{Gask}from"./graph-CxC82Dbv.js";import{lasW}from"./layout-Par6p52e.js";import{wasy}from"./json-CseEsORE.js";import"./reduce-D_AZ2Ezs.js";import"./min-B9CBIDjB.js";vard=newMap,N=newMap,P=newMap,Z=w(()=>{N.clear(),P.clear(),d.clear()},"clear"),D=w((n,t)=>{conste=N.get(t)||[];returni.trace("In isDescendant",t," ",n," = ",e.includes(n)),e.includes(n)},"isDescendant"),$=w((n,t)=>{conste=N.get(t)||[];returni.info("Descendants of ",t," is ",e),i.info("Edge is ",n),n.v===t||n.w===t?!1:e?e.includes(n.v)||D(n.v,t)||D(n.w,t)||e.includes(n.w):(i.debug("Tilt, ",t,",not in descendants"),!1)},"edgeInCluster"),B=w((n,t,e,o)=>{i.warn("Copying children of ",n,"root",o,"data",t.node(n),o);constl=t.children(n)||[];n!==o&&l.push(n),i.warn("Copying (nodes) clusterId",n,"nodes",l),l.forEach(c=>{if(t.children(c).length>0)B(c,t,e,o);else{constr=t.node(c);i.info("cp ",c," to ",o," with parent ",n),e.setNode(c,r),o!==t.parent(c)&&(i.warn("Setting parent",c,t.parent(c)),e.setParent(c,t.parent(c))),n!==o&&c!==n?(i.debug("Setting parent",c,n),e.setParent(c,n)):(i.info("In copy ",n,"root",o,"data",t.node(n),o),i.debug("Not Setting parent for node=",c,"cluster!==rootId",n!==o,"node!==clusterId",c!==n));constg=t.edges(c);i.debug("Copying Edges",g),g.forEach(a=>{i.info("Edge",a);constu=t.edge(a.v,a.w,a.name);i.info("Edge data",u,o);try{$(a,o)?(i.info("Copying as ",a.v,a.w,u,a.name),e.setEdge(a.v,a.w,u,a.name),i.info("newGraph edges ",e.edges(),e.edge(e.edges()[0]))):i.info("Skipping copy of edge ",a.v,"-->",a.w," rootId: ",o," clusterId:",n)}catch(X){i.error(X)}})}i.debug("Removing node",c),t.removeNode(c)})},"copy"),J=w((n,t)=>{conste=t.children(n);leto=[...e];for(constlofe)P.set(l,n),o=[...o,...J(l,t)];returno},"extractDescendants"),L=w((n,t,e)=>{consto=n.edges().filter(a=>a.v===t||a.w===t),l=n.edges().filter(a=>a.v===e||a.w===e),c=o.map(a=>({v:a.v===t?e:a.v,w:a.w===t?t:a.w})),r=l.map(a=>({v:a.v,w:a.w}));returnc.filter(a=>r.some(u=>a.v===u.v&&a.w===u.w))},"findCommonEdges"),C=w((n,t,e)=>{consto=t.children(n);if(i.trace("Searching children of id ",n,o),o.length<1)returnn;letl;for(constcofo){constr=C(c,t,e),g=L(t,e,r);if(r)if(g.length>0)l=r;elsereturnr}returnl},"findNonClusterChild"),S=w(n=>!d.has(n)||!d.get(n).externalConnections?n:d.has(n)?d.get(n).id:n,"getAnchorId"),I=w((n,t)=>{if(!n||t>10){i.debug("Opting out, no graph ");return}elsei.debug("Opting in, graph ");n.nodes().forEach(function(e){n.children(e).length>0&&(i.warn("Cluster identified",e," Replacement id in edges: ",C(e,n,e)),N.set(e,J(e,n)),d.set(e,{id:C(e,n,e),clusterData:n.node(e)}))}),n.nodes().forEach(function(e){consto=n.children(e),l=n.edges();o.length>0?(i.debug("Cluster identified",e,N),l.forEach(c=>{constr=D(c.v,e),g=D(c.w,e);r^g&&(i.warn("Edge: ",c," leaves cluster ",e),i.warn("Descendants of XXX ",e,": ",N.get(e)),d.get(e).externalConnections=!0)})):i.debug("Not a cluster ",e,N)});for(leteofd.keys()){consto=d.get(e).id,l=n.parent(o);l!==e&&d.has(l)&&!d.get(l).externalConnections&&(d.get(e).id=l)}n.edges().forEach(function(e){consto=n.edge(e);i.warn("Edge "+e.v+" -> "+e.w+": "+JSON.stringify(e)),i.warn("Edge "+e.v+" -> "+e.w+": "+JSON.stringify(n.edge(e)));letl=e.v,c=e.w;if(i.warn("Fix XXX",d,"ids:",e.v,e.w,"Translating: ",d.get(e.v)," --- ",d.get(e.w)),d.get(e.v)&&d.get(e.w)&&d.get(e.v)===d.get(e.w)){i.warn("Fixing and trying link to self - removing XXX",e.v,e.w,e.name),i.warn("Fixing and trying - removing XXX",e.v,e.w,e.name),l=S(e.v),c=S(e.w),n.removeEdge(e.v,e.w,e.name);constr=e.w+"---"+e.v+"---1",g=e.w+"---"+e.v+"---2";n.setNode(r,{domId:r,id:r,labelStyle:"",label:"",padding:0,shape:"labelRect",style:"",width:10,height:10}),n.setNode(g,{domId:g,id:g,labelStyle:"",padding:0,shape:"labelRect",style:"",width:10,height:10});consta=structuredClone(o),u=structuredClone(o),X=structuredClone(o);a.label="",a.arrowTypeEnd="none",a.id=e.name+"-cyclic-special-1",u.arrowTypeEnd="non