md/assets/classDiagram-v2-SPY6V32O-CHvx50Pv.js

3 lines
16 KiB
JavaScript
Raw Normal View History

import{m as tt,c as et,i as nt,a as it,p as st}from"./chunk-MKAIFKW5-CG21diy7.js";import{c as at,a as G,s as rt}from"./chunk-BAVOGKFW-BoWJNJ_z.js";import{c as lt,u as ot,s as ct,i as dt,p as M,a as F,b as R}from"./chunk-GWHMDDHB-TVPi_xBu.js";import{_ as g,l as s,d as m,j as T,u as ft,O as ut,P as $,Q as H,R as z,t as ht,e as W,S as J,T as B,U as gt}from"./index-BLRC3hcM.js";import{G as q}from"./graph-BAVL3iS3.js";import{l as wt}from"./layout-Cj2kFiQc.js";import{w as S}from"./json-Du2qFsRS.js";import"./_baseUniq-B6jkvB8l.js";import"./min-Ds95VZp9.js";var u={},x={},Q={},yt=g(()=>{x={},Q={},u={}},"clear"),L=g((e,t)=>(s.trace("In isDescendant",t," ",e," = ",x[t].includes(e)),!!x[t].includes(e)),"isDescendant"),bt=g((e,t)=>(s.info("Descendants of ",t," is ",x[t]),s.info("Edge is ",e),e.v===t||e.w===t?!1:x[t]?x[t].includes(e.v)||L(e.v,t)||L(e.w,t)||x[t].includes(e.w):(s.debug("Tilt, ",t,",not in descendants"),!1)),"edgeInCluster"),U=g((e,t,n,l)=>{s.warn("Copying children of ",e,"root",l,"data",t.node(e),l);const i=t.children(e)||[];e!==l&&i.push(e),s.warn("Copying (nodes) clusterId",e,"nodes",i),i.forEach(a=>{if(t.children(a).length>0)U(a,t,n,l);else{const r=t.node(a);s.info("cp ",a," to ",l," with parent ",e),n.setNode(a,r),l!==t.parent(a)&&(s.warn("Setting parent",a,t.parent(a)),n.setParent(a,t.parent(a))),e!==l&&a!==e?(s.debug("Setting parent",a,e),n.setParent(a,e)):(s.info("In copy ",e,"root",l,"data",t.node(e),l),s.debug("Not Setting parent for node=",a,"cluster!==rootId",e!==l,"node!==clusterId",a!==e));const f=t.edges(a);s.debug("Copying Edges",f),f.forEach(d=>{s.info("Edge",d);const h=t.edge(d.v,d.w,d.name);s.info("Edge data",h,l);try{bt(d,l)?(s.info("Copying as ",d.v,d.w,h,d.name),n.setEdge(d.v,d.w,h,d.name),s.info("newGraph edges ",n.edges(),n.edge(n.edges()[0]))):s.info("Skipping copy of edge ",d.v,"-->",d.w," rootId: ",l," clusterId:",e)}catch(b){s.error(b)}})}s.debug("Removing node",a),t.removeNode(a)})},"copy"),V=g((e,t)=>{const n=t.children(e);let l=[...n];for(const i of n)Q[i]=e,l=[...l,...V(i,t)];return l},"extractDescendants"),k=g((e,t)=>{s.trace("Searching",e);const 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(const l of n){const i=k(l,t);if(i)return s.trace("Found replacement for",e," => ",i),i}},"findNonClusterChild"),X=g(e=>!u[e]||!u[e].externalConnections?e:u[e]?u[e].id:e,"getAnchorId"),mt=g((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: ",k(n,e)),x[n]=V(n,e),u[n]={id:k(n,e),clusterData:e.node(n)})}),e.nodes().forEach(function(n){const l=e.children(n),i=e.edges();l.length>0?(s.debug("Cluster identified",n,x),i.forEach(a=>{if(a.v!==n&&a.w!==n){const r=L(a.v,n),f=L(a.w,n);r^f&&(s.warn("Edge: ",a," leaves cluster ",n),s.warn("Descendants of XXX ",n,": ",x[n]),u[n].externalConnections=!0)}})):s.debug("Not a cluster ",n,x)});for(let n of Object.keys(u)){const l=u[n].id,i=e.parent(l);i!==n&&u[i]&&!u[i].externalConnections&&(u[n].id=i)}e.edges().forEach(function(n){const l=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",u,"ids:",n.v,n.w,"Translating: ",u[n.v]," --- ",u[n.w]),u[n.v]&&u[n.w]&&u[n.v]===u[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=X(n.v),a=X(n.w),e.removeEdge(n.v,n.w,n.name);const r=n.w+"---"+n.v;e.setNode(r,{domId:r,id:r,labelStyle:"",labelText:l.label,padding:0,shape:"labelRect",style:""});const f=structuredClone(l),d=structuredClone(l);f.label="",f.arrowTypeEnd="none",d.label="",f.fromCluster=n.v,d.toCluster=n.v,e.setEdge(i,r,f,n.name+"-cyclic-special"),e.setEdge(r,a,d,n.name+"-cyclic-special")}else if(u[n.v]||u[n.w]){if(s.warn("Fixing and trixing - removing XXX",n.v,n.w,n.name),i=X(n.v),a=X(n.w),e.removeEdge(n.v,n.w,n.name),i!==n.v){const r=e.parent(i);u[r].e
`),i.style===void 0&&(a.style=a.style||"stroke: #333; stroke-width: 1.5px;fill:none"),a.labelStyle=a.labelStyle.replace("color:","fill:"))),t.setEdge(i.id1,i.id2,a,l)})},"addRelations"),Lt=g(function(e){_={..._,...e}},"setConf"),Rt=g(async function(e,t,n,l){s.info("Drawing class - ",t);const i=m().flowchart??m().class,a=m().securityLevel;s.info("config:",i);const r=(i==null?void 0:i.nodeSpacing)??50,f=(i==null?void 0:i.rankSpacing)??50,d=new q({multigraph:!0,compound:!0}).setGraph({rankdir:l.db.getDirection(),nodesep:r,ranksep:f,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}}),h=l.db.getNamespaces(),b=l.db.getClasses(),y=l.db.getRelations(),v=l.db.getNotes();s.info(y),Dt(h,d,t,l),I(b,d,t,l),Bt(y,d),Xt(v,d,y.length+1,b);let w;a==="sandbox"&&(w=T("#i"+t));const c=a==="sandbox"?T(w.nodes()[0].contentDocument.body):T("body"),o=c.select(`[id="${t}"]`),p=c.select("#"+t+" g");if(await kt(p,d,["aggregation","extension","composition","dependency","lollipop"],"classDiagram",t),ft.insertTitle(o,"classTitleText",(i==null?void 0:i.titleTopMargin)??5,l.db.getDiagramTitle()),ut(d,o,i==null?void 0:i.diagramPadding,i==null?void 0:i.useMaxWidth),!(i!=null&&i.htmlLabels)){const E=a==="sandbox"?w.nodes()[0].contentDocument:document,D=E.querySelectorAll('[id="'+t+'"] .edgeLabel .label');for(const N of D){const P=N.getBBox(),C=E.createElementNS("http://www.w3.org/2000/svg","rect");C.setAttribute("rx",0),C.setAttribute("ry",0),C.setAttribute("width",P.width),C.setAttribute("height",P.height),N.insertBefore(C,N.firstChild)}}},"draw");function A(e){let t;switch(e){case 0:t="aggregation";break;case 1:t="extension";break;case 2:t="composition";break;case 3:t="dependency";break;case 4:t="lollipop";break;default:t="none"}return t}g(A,"getArrowMarker");var _t={setConf:Lt,draw:Rt},zt={parser:at,db:G,renderer:_t,styles:rt,init:g(e=>{e.class||(e.class={}),e.class.arrowMarkerAbsolute=e.arrowMarkerAbsolute,G.clear()},"init")};export{zt as diagram};