import{o as e}from"./rolldown-runtime-Bhmf7a9N.js";import"./lucide-7srpeIMw.js";import{D as t,Lt as n,R as r,T as i,_ as a,hn as o,l as s,mn as c,un as l}from"./mermaid-7ea9cbd6-DmivzQ7-.js";import{t as u}from"./line-D5rFyobF.js";import{t as d}from"./graphlib-B7zpM-Rl.js";import{t as f}from"./dagre-GVwvKV-L.js";import{n as p,r as m,t as h}from"./styles-b4e223ce-DbaZhm9A.js";e(o(),1),c();var g=0,_=function(e,t,a,o,s){let c=function(e){switch(e){case s.db.relationType.AGGREGATION:return`aggregation`;case s.db.relationType.EXTENSION:return`extension`;case s.db.relationType.COMPOSITION:return`composition`;case s.db.relationType.DEPENDENCY:return`dependency`;case s.db.relationType.LOLLIPOP:return`lollipop`}};t.points=t.points.filter(e=>!Number.isNaN(e.y));let l=t.points,d=u().x(function(e){return e.x}).y(function(e){return e.y}).curve(n),f=e.append(`path`).attr(`d`,d(l)).attr(`id`,`edge`+g).attr(`class`,`relation`),p=``;o.arrowMarkerAbsolute&&(p=window.location.protocol+`//`+window.location.host+window.location.pathname+window.location.search,p=p.replace(/\(/g,`\\(`),p=p.replace(/\)/g,`\\)`)),a.relation.lineType==1&&f.attr(`class`,`relation dashed-line`),a.relation.lineType==10&&f.attr(`class`,`relation dotted-line`),a.relation.type1!==`none`&&f.attr(`marker-start`,`url(`+p+`#`+c(a.relation.type1)+`Start)`),a.relation.type2!==`none`&&f.attr(`marker-end`,`url(`+p+`#`+c(a.relation.type2)+`End)`);let m,h,_=t.points.length,v=r.calcLabelPosition(t.points);m=v.x,h=v.y;let y,b,x,S;if(_%2!=0&&_>1){let e=r.calcCardinalityPosition(a.relation.type1!==`none`,t.points,t.points[0]),n=r.calcCardinalityPosition(a.relation.type2!==`none`,t.points,t.points[_-1]);i.debug(`cardinality_1_point `+JSON.stringify(e)),i.debug(`cardinality_2_point `+JSON.stringify(n)),y=e.x,b=e.y,x=n.x,S=n.y}if(a.title!==void 0){let t=e.append(`g`).attr(`class`,`classLabel`),n=t.append(`text`).attr(`class`,`label`).attr(`x`,m).attr(`y`,h).attr(`fill`,`red`).attr(`text-anchor`,`middle`).text(a.title);window.label=n;let r=n.node().getBBox();t.insert(`rect`,`:first-child`).attr(`class`,`box`).attr(`x`,r.x-o.padding/2).attr(`y`,r.y-o.padding/2).attr(`width`,r.width+o.padding).attr(`height`,r.height+o.padding)}i.info(`Rendering relation `+JSON.stringify(a)),a.relationTitle1!==void 0&&a.relationTitle1!==`none`&&e.append(`g`).attr(`class`,`cardinality`).append(`text`).attr(`class`,`type1`).attr(`x`,y).attr(`y`,b).attr(`fill`,`black`).attr(`font-size`,`6`).text(a.relationTitle1),a.relationTitle2!==void 0&&a.relationTitle2!==`none`&&e.append(`g`).attr(`class`,`cardinality`).append(`text`).attr(`class`,`type2`).attr(`x`,x).attr(`y`,S).attr(`fill`,`black`).attr(`font-size`,`6`).text(a.relationTitle2),g++},v=function(e,t,n,r){i.debug(`Rendering class `,t,n);let a=t.id,o={id:a,label:t.id,width:0,height:0},s=e.append(`g`).attr(`id`,r.db.lookUpDomId(a)).attr(`class`,`classGroup`),c;c=t.link?s.append(`svg:a`).attr(`xlink:href`,t.link).attr(`target`,t.linkTarget).append(`text`).attr(`y`,n.textHeight+n.padding).attr(`x`,0):s.append(`text`).attr(`y`,n.textHeight+n.padding).attr(`x`,0);let l=!0;t.annotations.forEach(function(e){let t=c.append(`tspan`).text(`«`+e+`»`);l||t.attr(`dy`,n.textHeight),l=!1});let u=y(t),d=c.append(`tspan`).text(u).attr(`class`,`title`);l||d.attr(`dy`,n.textHeight);let f=c.node().getBBox().height,p,m,h;if(t.members.length>0){p=s.append(`line`).attr(`x1`,0).attr(`y1`,n.padding+f+n.dividerMargin/2).attr(`y2`,n.padding+f+n.dividerMargin/2);let e=s.append(`text`).attr(`x`,n.padding).attr(`y`,f+n.dividerMargin+n.textHeight).attr(`fill`,`white`).attr(`class`,`classText`);l=!0,t.members.forEach(function(t){x(e,t,l,n),l=!1}),m=e.node().getBBox()}if(t.methods.length>0){h=s.append(`line`).attr(`x1`,0).attr(`y1`,n.padding+f+n.dividerMargin+m.height).attr(`y2`,n.padding+f+n.dividerMargin+m.height);let e=s.append(`text`).attr(`x`,n.padding).attr(`y`,f+2*n.dividerMargin+m.height+n.textHeight).attr(`fill`,`white`).attr(`class`,`classText`);l=!0,t.methods.forEach(function(t){x(e,t,l,n),l=!1})}let g=s.node().getBBox();var _=` `;t.cssClasses.length>0&&(_+=t.cssClasses.join(` `));let v=s.insert(`rect`,`:first-child`).attr(`x`,0).attr(`y`,0).attr(`width`,g.width+2*n.padding).attr(`height`,g.height+n.padding+.5*n.dividerMargin).attr(`class`,_).node().getBBox().width;return c.node().childNodes.forEach(function(e){e.setAttribute(`x`,(v-e.getBBox().width)/2)}),t.tooltip&&c.insert(`title`).text(t.tooltip),p&&p.attr(`x2`,v),h&&h.attr(`x2`,v),o.width=v,o.height=g.height+n.padding+.5*n.dividerMargin,o},y=function(e){let n=e.id;return e.type&&(n+=`<`+t(e.type)+`>`),n},b=function(e,t,n,r){i.debug(`Rendering note `,t,n);let a=t.id,o={id:a,text:t.text,width:0,height:0},s=e.append(`g`).attr(`id`,a).attr(`class`,`classGroup`),c=s.append(`text`).attr(`y`,n.textHeight+n.padding).attr(`x`,0),l=JSON.parse(`"${t.text}"`).split(`
`);l.forEach(function(e){i.debug(`Adding line: ${e}`),c.append(`tspan`).text(e).attr(`class`,`title`).attr(`dy`,n.textHeight)});let u=s.node().getBBox(),d=s.insert(`rect`,`:first-child`).attr(`x`,0).attr(`y`,0).attr(`width`,u.width+2*n.padding).attr(`height`,u.height+l.length*n.textHeight+n.padding+.5*n.dividerMargin).node().getBBox().width;return c.node().childNodes.forEach(function(e){e.setAttribute(`x`,(d-e.getBBox().width)/2)}),o.width=d,o.height=u.height+l.length*n.textHeight+n.padding+.5*n.dividerMargin,o},x=function(e,t,n,r){let{displayText:i,cssStyle:a}=t.getDisplayDetails(),o=e.append(`tspan`).attr(`x`,r.padding).text(i);a!==``&&o.attr(`style`,t.cssStyle),n||o.attr(`dy`,r.textHeight)},S={getClassTitleString:y,drawClass:v,drawEdge:_,drawNote:b},C={},w=20,T=function(e){let t=Object.entries(C).find(t=>t[1].label===e);if(t)return t[0]},E=function(e){e.append(`defs`).append(`marker`).attr(`id`,`extensionStart`).attr(`class`,`extension`).attr(`refX`,0).attr(`refY`,7).attr(`markerWidth`,190).attr(`markerHeight`,240).attr(`orient`,`auto`).append(`path`).attr(`d`,`M 1,7 L18,13 V 1 Z`),e.append(`defs`).append(`marker`).attr(`id`,`extensionEnd`).attr(`refX`,19).attr(`refY`,7).attr(`markerWidth`,20).attr(`markerHeight`,28).attr(`orient`,`auto`).append(`path`).attr(`d`,`M 1,1 V 13 L18,7 Z`),e.append(`defs`).append(`marker`).attr(`id`,`compositionStart`).attr(`class`,`extension`).attr(`refX`,0).attr(`refY`,7).attr(`markerWidth`,190).attr(`markerHeight`,240).attr(`orient`,`auto`).append(`path`).attr(`d`,`M 18,7 L9,13 L1,7 L9,1 Z`),e.append(`defs`).append(`marker`).attr(`id`,`compositionEnd`).attr(`refX`,19).attr(`refY`,7).attr(`markerWidth`,20).attr(`markerHeight`,28).attr(`orient`,`auto`).append(`path`).attr(`d`,`M 18,7 L9,13 L1,7 L9,1 Z`),e.append(`defs`).append(`marker`).attr(`id`,`aggregationStart`).attr(`class`,`extension`).attr(`refX`,0).attr(`refY`,7).attr(`markerWidth`,190).attr(`markerHeight`,240).attr(`orient`,`auto`).append(`path`).attr(`d`,`M 18,7 L9,13 L1,7 L9,1 Z`),e.append(`defs`).append(`marker`).attr(`id`,`aggregationEnd`).attr(`refX`,19).attr(`refY`,7).attr(`markerWidth`,20).attr(`markerHeight`,28).attr(`orient`,`auto`).append(`path`).attr(`d`,`M 18,7 L9,13 L1,7 L9,1 Z`),e.append(`defs`).append(`marker`).attr(`id`,`dependencyStart`).attr(`class`,`extension`).attr(`refX`,0).attr(`refY`,7).attr(`markerWidth`,190).attr(`markerHeight`,240).attr(`orient`,`auto`).append(`path`).attr(`d`,`M 5,7 L9,13 L1,7 L9,1 Z`),e.append(`defs`).append(`marker`).attr(`id`,`dependencyEnd`).attr(`refX`,19).attr(`refY`,7).attr(`markerWidth`,20).attr(`markerHeight`,28).attr(`orient`,`auto`).append(`path`).attr(`d`,`M 18,7 L9,13 L14,7 L9,1 Z`)},D={parser:p,db:h,renderer:{draw:function(e,t,n,r){let o=a().class;C={},i.info(`Rendering diagram `+e);let c=a().securityLevel,u;c===`sandbox`&&(u=l(`#i`+t));let p=l(c===`sandbox`?u.nodes()[0].contentDocument.body:`body`),m=p.select(`[id='${t}']`);E(m);let h=new d({multigraph:!0});h.setGraph({isMultiGraph:!0}),h.setDefaultEdgeLabel(function(){return{}});let g=r.db.getClasses(),_=Object.keys(g);for(let e of _){let t=g[e],n=S.drawClass(m,t,o,r);C[n.id]=n,h.setNode(n.id,n),i.info(`Org height: `+n.height)}r.db.getRelations().forEach(function(e){i.info(`tjoho`+T(e.id1)+T(e.id2)+JSON.stringify(e)),h.setEdge(T(e.id1),T(e.id2),{relation:e},e.title||`DEFAULT`)}),r.db.getNotes().forEach(function(e){i.debug(`Adding note: ${JSON.stringify(e)}`);let t=S.drawNote(m,e,o,r);C[t.id]=t,h.setNode(t.id,t),e.class&&e.class in g&&h.setEdge(e.id,T(e.class),{relation:{id1:e.id,id2:e.class,relation:{type1:`none`,type2:`none`,lineType:10}}},`DEFAULT`)}),f(h),h.nodes().forEach(function(e){e!==void 0&&h.node(e)!==void 0&&(i.debug(`Node `+e+`: `+JSON.stringify(h.node(e))),p.select(`#`+(r.db.lookUpDomId(e)||e)).attr(`transform`,`translate(`+(h.node(e).x-h.node(e).width/2)+`,`+(h.node(e).y-h.node(e).height/2)+` )`))}),h.edges().forEach(function(e){e!==void 0&&h.edge(e)!==void 0&&(i.debug(`Edge `+e.v+` -> `+e.w+`: `+JSON.stringify(h.edge(e))),S.drawEdge(m,h.edge(e),h.edge(e).relation,o,r))});let v=m.node().getBBox(),y=v.width+w*2,b=v.height+w*2;s(m,b,y,o.useMaxWidth);let x=`${v.x-w} ${v.y-w} ${y} ${b}`;i.debug(`viewBox ${x}`),m.attr(`viewBox`,x)}},styles:m,init:e=>{e.class||={},e.class.arrowMarkerAbsolute=e.arrowMarkerAbsolute,h.clear()}};export{D as diagram};