mermaid
Version:
Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.
2 lines (1 loc) • 15.1 kB
JavaScript
import{a as F}from"./chunk-Z2IEFKAF.mjs";import{c as Y,e as q,f as tt}from"./chunk-3DCBE5TA.mjs";import{a as G}from"./chunk-JENJ2NYI.mjs";import{b as ht,d as V,e as O}from"./chunk-FRYFDGAD.mjs";import{e as A}from"./chunk-KNGDTZMA.mjs";import{g as P}from"./chunk-PNVTB6QF.mjs";import{$ as W,n as ct,y as X}from"./chunk-VLFMOWSA.mjs";import{b as L,h as j}from"./chunk-NXZFCOWJ.mjs";import{a as M}from"./chunk-V3YWWTDH.mjs";var it=M(async(h,t,{variant:s="swimlane"}={})=>{let f=s==="pool",m=f?"pool swimlane":"swimlane",x=f?"pool-label swimlane-label":"swimlane-label",p=f?"pool-title swimlane-title":"swimlane-title",k=f?"pool-body swimlane-body":"swimlane-body",T=W(),{theme:B,themeVariables:S,handDrawnSeed:o}=T,{clusterBkg:y,clusterBorder:i,borderColorArray:C}=S,r=i,{labelStyles:a,nodeStyles:e,borderStyles:w,backgroundStyles:n}=V(t),c=h.insert("g").attr("class","cluster "+m+" "+(t.cssClasses||"")).attr("id",t.domId??t.id).attr("data-id",t.id).attr("data-et","cluster").attr("data-look",t.look);P(c,t.colorIndex,B,C);let d=ct(T.flowchart.htmlLabels),g=t.direction==="LR",u=c.insert("g").attr("class","cluster-label "+x),D=await A(u,t.label,{style:t.labelStyle,useHtmlLabels:d,isNode:!0,width:t.width}),l=D.getBBox();if(d){let I=D.children[0],H=j(D);l=I.getBoundingClientRect(),H.attr("width",l.width),H.attr("height",l.height)}let R=t.padding??0,b=t.width<=l.width+R?l.width+R:t.width;t.width<=l.width+R?t.diff=(b-t.width)/2-R:t.diff=-R;let $=t.height,v=t.y-$/2,E=t.y+$/2,J=t.x-b/2,gt=t.swimlaneContentTop!==void 0?t.swimlaneContentTop:v+$/3,at=g?4:0,lt=l.height+2*at,N,U;if(g){let I=Math.max(lt,l.height+2*at),H=J+I,z=Math.max(0,b-I);if(t.look==="handDrawn"){let Q=G.svg(c),st=O(t,{roughness:.7,fill:y,stroke:r,seed:o}),Z=O(t,{roughness:.7,fill:"none",stroke:r,seed:o}),rt=Q.rectangle(J,v,I,$,st);N=c.insert(()=>rt,":first-child").attr("class",p);let et=Q.rectangle(H,v,z,$,Z);U=c.insert(()=>et,":first-child").attr("class",k),N.select("path:nth-child(2)").attr("style",w.join(";")),N.select("path").attr("style",n.join(";").replace("fill","stroke"))}else N=c.insert("rect",":first-child"),U=c.insert("rect",":first-child"),N.attr("class",p).attr("style",e).attr("x",J).attr("y",v).attr("width",I).attr("height",$).attr("fill",y).attr("stroke",r),U.attr("class",k).attr("style",e).attr("x",H).attr("y",v).attr("width",z).attr("height",$).attr("fill","none").attr("stroke",r);let K=J+I/2,_=t.y;u.attr("transform",`translate(${K}, ${_}) rotate(-90) translate(${-l.width/2}, ${-l.height/2})`)}else{let I=Math.max(0,gt-v),H=Math.min(lt,I),z=v+H,K=Math.max(0,E-z),_=t.x-b/2;if(t.look==="handDrawn"){let Z=G.svg(c),rt=O(t,{roughness:.7,fill:y,stroke:r,fillWeight:3,seed:o}),et=O(t,{roughness:.7,fill:"none",stroke:r,seed:o}),ft=Z.rectangle(_,v,b,H,rt);N=c.insert(()=>ft,":first-child").attr("class",p);let dt=Z.rectangle(_,z,b,K,et);U=c.insert(()=>dt,":first-child").attr("class",k),N.select("path:nth-child(2)").attr("style",w.join(";")),N.select("path").attr("style",n.join(";").replace("fill","stroke"))}else N=c.insert("rect",":first-child"),U=c.insert("rect",":first-child"),N.attr("class",p).attr("style",e).attr("x",_).attr("y",v).attr("width",b).attr("height",H).attr("fill",y).attr("stroke",r),U.attr("class",k).attr("style",e).attr("x",_).attr("y",z).attr("width",b).attr("height",K).attr("fill","none").attr("stroke",r);let Q=t.x-l.width/2,st=v+(H-l.height)/2;u.attr("transform",`translate(${Q}, ${st})`)}if(L.trace("Swimlane data ",t,JSON.stringify(t)),a){let I=u.select("span");I&&I.attr("style",a)}return t.offsetX=0,t.width=b,t.height=$,t.offsetY=l.height-R/2,t.intersect=function(I){return Y(t,I)},{cluster:c,labelBBox:l}},"swimlane");var ot=M(async(h,t)=>{L.info("Creating subgraph rect for ",t.id,t);let s=W(),{theme:f,themeVariables:m,handDrawnSeed:x}=s,{clusterBkg:p,clusterBorder:k,borderColorArray:T}=m,{labelStyles:B,nodeStyles:S,borderStyles:o,backgroundStyles:y}=V(t),i=h.insert("g").attr("class","cluster "+t.cssClasses).attr("id",t.domId).attr("data-look",t.look);P(i,t.colorIndex,f,T);let C=X(s),r=i.insert("g").attr("class","cluster-label "),a;t.labelType==="markdown"?a=await A(r,t.label,{style:t.labelStyle,useHtmlLabels:C,isNode:!0,width:t.width}):a=await tt(r,t.label,t.labelStyle||"",!1,!0);let e=a.getBBox();if(X(s)){let l=a.children[0],R=j(a);e=l.getBoundingClientRect(),R.attr("width",e.width),R.attr("height",e.height)}let w=t.width<=e.width+t.padding?e.width+t.padding:t.width;t.width<=e.width+t.padding?t.diff=(w-t.width)/2-t.padding:t.diff=-t.padding;let n=t.height,c=t.x-w/2,d=t.y-n/2;L.trace("Data ",t,JSON.stringify(t));let g;if(t.look==="handDrawn"){let l=G.svg(i),R=O(t,{roughness:.7,fill:p,stroke:k,fillWeight:3,seed:x}),b=l.path(q(c,d,w,n,0),R);g=i.insert(()=>(L.debug("Rough node insert CXC",b),b),":first-child"),g.select("path:nth-child(2)").attr("style",o.join(";")),g.select("path").attr("style",y.join(";").replace("fill","stroke"))}else g=i.insert("rect",":first-child"),g.attr("style",S).attr("rx",t.rx).attr("ry",t.ry).attr("x",c).attr("y",d).attr("width",w).attr("height",n);let{subGraphTitleTopMargin:u}=F(s);if(r.attr("transform",`translate(${t.x-e.width/2}, ${t.y-t.height/2+u})`),B){let l=r.select("span");l&&l.attr("style",B)}let D=g.node().getBBox();return t.offsetX=0,t.width=D.width,t.height=D.height,t.offsetY=e.height-t.padding/2,t.intersect=function(l){return Y(t,l)},{cluster:i,labelBBox:e}},"rect"),ut=M((h,t)=>{let s=h.insert("g").attr("class","note-cluster").attr("id",t.domId),f=s.insert("rect",":first-child"),m=0*t.padding,x=m/2;f.attr("rx",t.rx).attr("ry",t.ry).attr("x",t.x-t.width/2-x).attr("y",t.y-t.height/2-x).attr("width",t.width+m).attr("height",t.height+m).attr("fill","none");let p=f.node().getBBox();return t.width=p.width,t.height=p.height,t.intersect=function(k){return Y(t,k)},{cluster:s,labelBBox:{width:0,height:0}}},"noteGroup"),yt=M(async(h,t)=>{let s=W(),{theme:f,themeVariables:m,handDrawnSeed:x}=s,{altBackground:p,borderColorArray:k,compositeBackground:T,compositeTitleBackground:B,nodeBorder:S}=m,o=h.insert("g").attr("class",t.cssClasses).attr("id",t.domId).attr("data-id",t.id).attr("data-look",t.look);P(o,t.colorIndex,f,k);let y=o.insert("g",":first-child"),i=o.insert("g").attr("class","cluster-label"),C=o.append("rect"),r=await tt(i,t.label,t.labelStyle,void 0,!0),a=r.getBBox();if(X(s)){let b=r.children[0],$=j(r);a=b.getBoundingClientRect(),$.attr("width",a.width),$.attr("height",a.height)}let e=0*t.padding,w=e/2,n=(t.width<=a.width+t.padding?a.width+t.padding:t.width)+e;t.width<=a.width+t.padding?t.diff=(n-t.width)/2-t.padding:t.diff=-t.padding;let c=t.height+e,d=t.height+e-a.height-6,g=t.x-n/2,u=t.y-c/2;t.width=n;let D=t.y-t.height/2-w+a.height+2,l;if(t.look==="handDrawn"){let b=t.cssClasses.includes("statediagram-cluster-alt"),$=G.svg(o),v=t.rx||t.ry?$.path(q(g,u,n,c,10),{roughness:.7,fill:B,fillStyle:"solid",stroke:S,seed:x}):$.rectangle(g,u,n,c,{seed:x});l=o.insert(()=>v,":first-child");let E=$.rectangle(g,D,n,d,{fill:b?p:T,fillStyle:b?"hachure":"solid",stroke:S,seed:x});l=o.insert(()=>v,":first-child"),C=o.insert(()=>E),l.attr("class","outer"),C.attr("class","inner")}else l=y.insert("rect",":first-child"),l.attr("class","outer").attr("x",g).attr("y",u).attr("width",n).attr("height",c).attr("data-look",t.look),C.attr("class","inner").attr("x",g).attr("y",D).attr("width",n).attr("height",d);i.attr("transform",`translate(${t.x-a.width/2}, ${u+1-(X(s)?0:3)})`);let R=l.node().getBBox();return t.height=R.height,t.offsetX=0,t.offsetY=a.height-t.padding/2,t.labelBBox=a,t.intersect=function(b){return Y(t,b)},{cluster:o,labelBBox:a}},"roundedWithTitle"),wt=M(async(h,t)=>{L.info("Creating subgraph rect for ",t.id,t);let s=W(),{themeVariables:f,handDrawnSeed:m}=s,{clusterBkg:x,clusterBorder:p}=f,{labelStyles:k,nodeStyles:T,borderStyles:B,backgroundStyles:S}=V(t),o=h.insert("g").attr("class","cluster "+t.cssClasses).attr("id",t.domId).attr("data-look",t.look),y=X(s),i=o.insert("g").attr("class","cluster-label "),C=await A(i,t.label,{style:t.labelStyle,useHtmlLabels:y,isNode:!0,width:t.width}),r=C.getBBox();if(X(s)){let u=C.children[0],D=j(C);r=u.getBoundingClientRect(),D.attr("width",r.width),D.attr("height",r.height)}let a=t.width<=r.width+t.padding?r.width+t.padding:t.width;t.width<=r.width+t.padding?t.diff=(a-t.width)/2-t.padding:t.diff=-t.padding;let e=t.height,w=t.x-a/2,n=t.y-e/2;L.trace("Data ",t,JSON.stringify(t));let c;if(t.look==="handDrawn"){let u=G.svg(o),D=O(t,{roughness:.7,fill:x,stroke:p,fillWeight:4,seed:m}),l=u.path(q(w,n,a,e,t.rx),D);c=o.insert(()=>(L.debug("Rough node insert CXC",l),l),":first-child"),c.select("path:nth-child(2)").attr("style",B.join(";")),c.select("path").attr("style",S.join(";").replace("fill","stroke"))}else c=o.insert("rect",":first-child"),c.attr("style",T).attr("rx",t.rx).attr("ry",t.ry).attr("x",w).attr("y",n).attr("width",a).attr("height",e);let{subGraphTitleTopMargin:d}=F(s);if(i.attr("transform",`translate(${t.x-r.width/2}, ${t.y-t.height/2+d})`),k){let u=i.select("span");u&&u.attr("style",k)}let g=c.node().getBBox();return t.offsetX=0,t.width=g.width,t.height=g.height,t.offsetY=r.height-t.padding/2,t.intersect=function(u){return Y(t,u)},{cluster:o,labelBBox:r}},"kanbanSection"),pt=M((h,t)=>{let s=W(),{theme:f,themeVariables:m,handDrawnSeed:x}=s,{altBackground:p,nodeBorder:k,borderColorArray:T}=m,B=h.insert("g").attr("class",t.cssClasses).attr("id",t.domId).attr("data-look",t.look);P(B,t.colorIndex,f,T);let S=B.insert("g",":first-child"),o=0*t.padding,y=t.width+o;t.diff=-t.padding;let i=t.height+o,C=t.x-y/2,r=t.y-i/2;t.width=y;let a;if(t.look==="handDrawn"){let n=G.svg(B).rectangle(C,r,y,i,{fill:p??"#efefef",fillStyle:"solid",roughness:.5,strokeLineDash:[5],stroke:k,seed:x});a=B.insert(()=>n,":first-child").attr("class","divider")}else{a=S.insert("rect",":first-child");let w="outer";t.look,w="divider",a.attr("class",w).attr("x",C).attr("y",r).attr("width",y).attr("height",i).attr("data-look",t.look)}let e=a.node().getBBox();return t.height=e.height,t.offsetX=0,t.offsetY=0,t.intersect=function(w){return Y(t,w)},{cluster:B,labelBBox:{}}},"divider"),bt=M(async(h,t,s)=>{L.info(`Creating ${s.cssClass} for `,t.id,t);let f=W(),{theme:m,themeVariables:x,handDrawnSeed:p}=f,{borderColorArray:k}=x,{labelStyles:T,borderStyles:B}=V(t),S=h.insert("g").attr("class","cluster "+s.cssClass+" "+t.cssClasses).attr("id",t.domId??t.id).attr("data-look",t.look);P(S,t.colorIndex,m,k);let o=X(f),y=S.insert("g").attr("class","cluster-label"),i={width:0,height:0},C=t.label?.trim();if(C){let d;if(t.labelType==="markdown"?d=await A(y,t.label,{style:t.labelStyle,useHtmlLabels:o,isNode:!0,width:t.width}):d=await tt(y,t.label,t.labelStyle||"",!1,!0),i=d.getBBox(),o){let g=d.children[0],u=j(d);i=g.getBoundingClientRect(),u.attr("width",i.width),u.attr("height",i.height)}}let r=t.width<=i.width+t.padding?i.width+t.padding:t.width;t.width<=i.width+t.padding?t.diff=(r-t.width)/2-t.padding:t.diff=-t.padding;let a=t.height,e=t.x-r/2,w=t.y-a/2,n;if(t.look==="handDrawn"){let d=G.svg(S),g=O(t,{roughness:s.roughness,fill:s.fill,stroke:s.stroke,strokeWidth:s.strokeWidth,seed:p,...s.fill==="none"?{fillWeight:0}:{fillStyle:"solid"},...s.strokeDash?{strokeLineDash:s.strokeDash}:{}}),u=d.path(q(e,w,r,a,s.rx),g);n=S.insert(()=>u,":first-child"),n.select("path:nth-child(2)").attr("style",B.join(";"))}else n=S.insert("rect",":first-child"),n.attr("rx",s.rx).attr("ry",s.rx).attr("x",e).attr("y",w).attr("width",r).attr("height",a).attr("fill",s.fill).attr("stroke",s.stroke).attr("stroke-width",s.strokeWidth+"px"),s.strokeDash&&n.attr("stroke-dasharray",s.strokeDash.join(", "));if(C){let{subGraphTitleTopMargin:d}=F(f);if(y.attr("transform",`translate(${t.x-i.width/2}, ${t.y-t.height/2+d})`),T){let g=y.select("span");g&&g.attr("style",T)}}let c=n.node().getBBox();return t.offsetX=0,t.width=c.width,t.height=c.height,t.offsetY=i.height-t.padding/2,t.intersect=function(d){return Y(t,d)},{cluster:S,labelBBox:i}},"createContainerGroup"),mt=M(async(h,t)=>{let{themeVariables:s}=W(),f=s.flowContainerStroke||s.secondaryBorderColor;return bt(h,t,{cssClass:"flow-cluster",rx:10,fill:"none",stroke:f,strokeWidth:.75,roughness:.7})},"flowGroup"),xt=M((h,t)=>{let s=h.boundaryType||"rect",f=s==="package"?20:h.padding,m=s==="package"?t.height+10:0,x=Math.max(h.width,t.width+f),p=s==="package"?Math.max(h.height,m+h.padding*2):h.height,k=h.x-x/2,T=h.y-p/2;return{boundaryType:s,width:x,height:p,x:k,y:T,bodyY:T+m,bodyHeight:p-m,tabHeight:m,tabWidth:s==="package"?Math.min(x,Math.max(80,t.width+20)):0}},"getUsecaseSystemBoundaryGeometry"),kt=M(async(h,t)=>{L.info("Creating usecase system boundary for ",t.id,t);let s=W(),{theme:f,themeVariables:m,handDrawnSeed:x}=s,{clusterBkg:p,clusterBorder:k,borderColorArray:T}=m,{labelStyles:B,nodeStyles:S}=V(t),{stylesMap:o}=ht(t),y=t.boundaryType||"rect",i=h.insert("g").attr("class",`cluster usecase-system-boundary usecase-system-boundary-${y} ${t.cssClasses}`).attr("id",typeof t.domId=="string"?t.domId:t.id).attr("data-boundary-type",y).attr("data-look",t.look);P(i,t.colorIndex,f,T);let C=X(s),r=i.insert("g").attr("class","cluster-label system-boundary-title"),a=await A(r,t.label,{style:B,useHtmlLabels:C,isNode:!0}),e=a.getBBox();if(C){let v=a.children[0],E=j(a);e=v.getBoundingClientRect(),E.attr("width",e.width),E.attr("height",e.height)}let w=xt(t,e),{width:n,height:c,x:d,y:g,bodyY:u,bodyHeight:D,tabHeight:l,tabWidth:R}=w;t.diff=t.width<=e.width+t.padding?(n-t.width)/2-t.padding:-t.padding;let b=O(t,{fill:o.get("fill")||p,stroke:o.get("stroke")||k,strokeWidth:o.get("stroke-width")?.replace("px","")||1,seed:x});if(t.look==="handDrawn"){let v=G.svg(i),E=v.rectangle(d,u,n,D,b);if(i.insert(()=>E,":first-child").attr("class","boundary-body label-container"),y==="package"){let J=v.rectangle(d,g,R,l,b);i.insert(()=>J,":first-child").attr("class","boundary-tab system-boundary-package-tab label-container")}}else i.insert("rect",":first-child").attr("class","boundary-body label-container").attr("style",S).attr("x",d).attr("y",u).attr("width",n).attr("height",D),y==="package"&&i.insert("rect",":first-child").attr("class","boundary-tab system-boundary-package-tab label-container").attr("style",S).attr("x",d).attr("y",g).attr("width",R).attr("height",l);let{subGraphTitleTopMargin:$}=F(s);return y==="package"?r.attr("transform",`translate(${d+(R-e.width)/2}, ${g+(l-e.height)/2})`):r.attr("transform",`translate(${t.x-e.width/2}, ${g+$})`),B&&(r.attr("style",B),r.select("span").attr("style",B)),t.offsetX=0,t.width=n,t.height=c,t.offsetY=e.height-t.padding/2,t.labelBBox=e,t.intersect=function(v){return Y(t,v)},{cluster:i,labelBBox:e}},"usecaseSystemBoundary"),Bt=ot,St=M((h,t)=>it(h,t,{variant:"pool"}),"pool"),Ct={rect:ot,squareRect:Bt,roundedWithTitle:yt,noteGroup:ut,divider:pt,kanbanSection:wt,flowGroup:mt,usecaseSystemBoundary:kt,swimlane:it,pool:St},vt=new Set(["noteGroup","divider"]),Ft=M(h=>!vt.has(h??"rect"),"clusterPaintsTitle"),nt=new Map,Kt=M(async(h,t)=>{let s=t.shape||"rect",f=await Ct[s](h,t);return nt.set(t.id,f),f},"insertCluster");var Qt=M(()=>{nt=new Map},"clear");export{Ft as a,Kt as b,Qt as c};