livebook/static/assets/classDiagram-v2-c1dfb0e0-RTHQXVLO.js
2023-05-27 07:05:48 +00:00

3 lines
5 KiB
JavaScript

import{a as P,b as L,c as $}from"./chunk-3MCPFTEY.js";import{a as z}from"./chunk-DV6EV644.js";import"./chunk-DJBS3ZP5.js";import"./chunk-2VAHKEM3.js";import"./chunk-GT6PWSKZ.js";import{a as G}from"./chunk-N4T7OBQH.js";import"./chunk-I4NDSNS6.js";import{D as Q,Fa as C,Ga as F,Na as H,g as K,ha as d,l as w,la as N,ra as i,ta as q,z as T}from"./chunk-CRHZHETQ.js";import"./chunk-HA3AQNT4.js";import{a as S,h as B}from"./chunk-2YVZDWG7.js";var ie=B(K(),1),re=B(Q(),1);var E=s=>N.sanitizeText(s,i()),D={dividerMargin:10,padding:5,textHeight:10,curve:void 0},U=function(s,o,f,a){let e=Object.keys(s);d.info("keys:",e),d.info(s),e.forEach(function(r){var y;var l,c;let t=s[r],p={shape:"rect",id:t.id,domId:t.domId,labelText:E(t.id),labelStyle:"",style:"fill: none; stroke: black",padding:(y=(l=i().flowchart)==null?void 0:l.padding)!=null?y:(c=i().class)==null?void 0:c.padding};o.setNode(t.id,p),W(t.classes,o,f,a,t.id),d.info("setNode",p)})},W=function(s,o,f,a,e){let r=Object.keys(s);d.info("keys:",r),d.info(s),r.forEach(function(l){var g,m;var c,t;let n=s[l],p="";n.cssClasses.length>0&&(p=p+" "+n.cssClasses.join(" "));let y={labelStyle:"",style:""},v=(g=n.label)!=null?g:n.id,b=0,h="class_box",u={labelStyle:y.labelStyle,shape:h,labelText:E(v),classData:n,rx:b,ry:b,class:p,style:y.style,id:n.id,domId:n.domId,tooltip:a.db.getTooltip(n.id,e)||"",haveCallback:n.haveCallback,link:n.link,width:n.type==="group"?500:void 0,type:n.type,padding:(m=(c=i().flowchart)==null?void 0:c.padding)!=null?m:(t=i().class)==null?void 0:t.padding};o.setNode(n.id,u),e&&o.setParent(n.id,e),d.info("setNode",u)})},X=function(s,o,f,a){d.info(s),s.forEach(function(e,r){var m;var l,c;let t=e,n="",p={labelStyle:"",style:""},y=t.text,v=0,b="note",h={labelStyle:p.labelStyle,shape:b,labelText:E(y),noteData:t,rx:v,ry:v,class:n,style:p.style,id:t.id,domId:t.id,tooltip:"",type:"note",padding:(m=(l=i().flowchart)==null?void 0:l.padding)!=null?m:(c=i().class)==null?void 0:c.padding};if(o.setNode(t.id,h),d.info("setNode",h),!t.class||!(t.class in a))return;let u=f+r,g={id:`edgeNote${u}`,classes:"relation",pattern:"dotted",arrowhead:"none",startLabelRight:"",endLabelLeft:"",arrowTypeStart:"none",arrowTypeEnd:"none",style:"fill:none",labelStyle:"",curve:C(D.curve,T)};o.setEdge(t.id,t.class,g,u)})},Y=function(s,o){let f=i().flowchart,a=0;s.forEach(function(e){var c;var r;a++;let l={classes:"relation",pattern:e.relation.lineType==1?"dashed":"solid",id:"id"+a,arrowhead:e.type==="arrow_open"?"none":"normal",startLabelRight:e.relationTitle1==="none"?"":e.relationTitle1,endLabelLeft:e.relationTitle2==="none"?"":e.relationTitle2,arrowTypeStart:V(e.relation.type1),arrowTypeEnd:V(e.relation.type2),style:"fill:none",labelStyle:"",curve:C(f==null?void 0:f.curve,T)};if(d.info(l,e),e.style!==void 0){let t=F(e.style);l.style=t.style,l.labelStyle=t.labelStyle}e.text=e.title,e.text===void 0?e.style!==void 0&&(l.arrowheadStyle="fill: #333"):(l.arrowheadStyle="fill: #333",l.labelpos="c",((c=(r=i().flowchart)==null?void 0:r.htmlLabels)!=null?c:i().htmlLabels)?(l.labelType="html",l.label='<span class="edgeLabel">'+e.text+"</span>"):(l.labelType="text",l.label=e.text.replace(N.lineBreakRegex,`
`),e.style===void 0&&(l.style=l.style||"stroke: #333; stroke-width: 1.5px;fill:none"),l.labelStyle=l.labelStyle.replace("color:","fill:"))),o.setEdge(e.id1,e.id2,l,a)})},Z=function(s){D=S(S({},D),s)},j=async function(s,o,f,a){var m,_,A,I;d.info("Drawing class - ",o);let e=(m=i().flowchart)!=null?m:i().class,r=i().securityLevel;d.info("config:",e);let l=(_=e==null?void 0:e.nodeSpacing)!=null?_:50,c=(A=e==null?void 0:e.rankSpacing)!=null?A:50,t=new G({multigraph:!0,compound:!0}).setGraph({rankdir:a.db.getDirection(),nodesep:l,ranksep:c,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}}),n=a.db.getNamespaces(),p=a.db.getClasses(),y=a.db.getRelations(),v=a.db.getNotes();d.info(y),U(n,t,o,a),W(p,t,o,a),Y(y,t),X(v,t,y.length+1,p);let b;r==="sandbox"&&(b=w("#i"+o));let h=r==="sandbox"?w(b.nodes()[0].contentDocument.body):w("body"),u=h.select(`[id="${o}"]`),g=h.select("#"+o+" g");if(await z(g,t,["aggregation","extension","composition","dependency","lollipop"],"classDiagram",o),H.insertTitle(u,"classTitleText",(I=e==null?void 0:e.titleTopMargin)!=null?I:5,a.db.getDiagramTitle()),q(t,u,e==null?void 0:e.diagramPadding,e==null?void 0:e.useMaxWidth),!(e!=null&&e.htmlLabels)){let M=r==="sandbox"?b.nodes()[0].contentDocument:document,J=M.querySelectorAll('[id="'+o+'"] .edgeLabel .label');for(let k of J){let R=k.getBBox(),x=M.createElementNS("http://www.w3.org/2000/svg","rect");x.setAttribute("rx",0),x.setAttribute("ry",0),x.setAttribute("width",R.width),x.setAttribute("height",R.height),k.insertBefore(x,k.firstChild)}}};function V(s){let o;switch(s){case 0:o="aggregation";break;case 1:o="extension";break;case 2:o="composition";break;case 3:o="dependency";break;case 4:o="lollipop";break;default:o="none"}return o}var O={setConf:Z,draw:j},pe={parser:P,db:L,renderer:O,styles:$,init:s=>{s.class||(s.class={}),s.class.arrowMarkerAbsolute=s.arrowMarkerAbsolute,L.clear()}};export{pe as diagram};