2026-05-31 13:54:31 +02:00

79 lines
25 KiB
JavaScript

import{a as pt}from"./chunk-JQRUD6KW.mjs";import{a as ct}from"./chunk-2T2R6R2M.mjs";import"./chunk-UP6H54XL.mjs";import"./chunk-UXSXWOXI.mjs";import"./chunk-C62D2QBJ.mjs";import"./chunk-CEXFNPSA.mjs";import"./chunk-RERM46MO.mjs";import"./chunk-J5EP6P6S.mjs";import"./chunk-RLI5ZMPA.mjs";import"./chunk-2UTLFMKG.mjs";import"./chunk-RKZBBQEN.mjs";import{a as gt}from"./chunk-LRIF4GLE.mjs";import{o as Z}from"./chunk-QA3QBVWF.mjs";import"./chunk-KNLZD3CH.mjs";import{O as rt,S as at,T as nt,U as ot,V as st,W as it,X as lt,Y as dt,_ as Y,h as tt,t as et}from"./chunk-67TQ5CYL.mjs";import{b as G}from"./chunk-7W6UQGC5.mjs";import"./chunk-KGYTTC2M.mjs";import"./chunk-4R4BOZG6.mjs";import{a as m}from"./chunk-AQ6EADP3.mjs";var j=m((n,a)=>{let e=n<=1?n*100:n;if(e<0||e>100)throw new Error(`${a} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${n}`);return e},"toPercent"),L=m((n,a,e)=>({x:j(a,`${e} evolution`),y:j(n,`${e} visibility`)}),"toCoordinates"),ut=m(n=>{if(n){if(n==="+<>")return"bidirectional";if(n==="+<")return"backward";if(n==="+>")return"forward"}},"getFlowFromPort"),$t=m(n=>{if(!n?.startsWith("+"))return{};let e=/^\+'([^']*)'/.exec(n)?.[1];return n.includes("<>")?{flow:"bidirectional",label:e}:n.includes("<")?{flow:"backward",label:e}:n.includes(">")?{flow:"forward",label:e}:{label:e}},"extractFlowFromArrow"),Nt=m((n,a)=>{if(pt(n,a),n.size&&a.setSize(n.size.width,n.size.height),n.evolution){let e=n.evolution.stages.map(r=>r.secondName?`${r.name.trim()} / ${r.secondName.trim()}`:r.name.trim()),u=n.evolution.stages.filter(r=>r.boundary!==void 0).map(r=>r.boundary);a.updateAxes({stages:e,stageBoundaries:u})}if(n.anchors.forEach(e=>{let u=L(e.visibility,e.evolution,`Anchor "${e.name}"`);a.addNode(e.name,e.name,u.x,u.y,"anchor")}),n.components.forEach(e=>{let u=L(e.visibility,e.evolution,`Component "${e.name}"`),r=e.label?(e.label.negX?-1:1)*e.label.offsetX:void 0,l=e.label?(e.label.negY?-1:1)*e.label.offsetY:void 0,h=e.decorator?.strategy;a.addNode(e.name,e.name,u.x,u.y,"component",r,l,e.inertia,h)}),n.notes.forEach(e=>{let u=L(e.visibility,e.evolution,`Note "${e.text}"`);a.addNote(e.text,u.x,u.y)}),n.pipelines.forEach(e=>{let u=a.getNode(e.parent);if(!u||typeof u.y!="number")throw new Error(`Pipeline "${e.parent}" must reference an existing component with coordinates.`);let r=u.y;a.startPipeline(e.parent),e.components.forEach(l=>{let h=`${e.parent}_${l.name}`,S=l.label?(l.label.negX?-1:1)*l.label.offsetX:void 0,y=l.label?(l.label.negY?-1:1)*l.label.offsetY:void 0,I=j(l.evolution,`Pipeline component "${l.name}" evolution`);a.addNode(h,l.name,I,r,"pipeline-component",S,y),a.addPipelineComponent(e.parent,h)})}),n.links.forEach(e=>{let u=!!e.arrow&&(e.arrow.includes("-.->")||e.arrow.includes(".-.")),r=ut(e.fromPort)??ut(e.toPort),{flow:l,label:h}=$t(e.arrow);!r&&l&&(r=l);let S=e.linkLabel,y=h??S;a.addLink(a.resolveNodeId(e.from),a.resolveNodeId(e.to),u,y,r)}),n.evolves.forEach(e=>{let u=a.getNode(e.component);if(u?.y!==void 0){let r=j(e.target,`Evolve target for "${e.component}"`);a.addTrend(e.component,r,u.y)}}),n.annotations.length>0){let e=n.annotations[0],u=L(e.x,e.y,"Annotations box");a.setAnnotationsBox(u.x,u.y)}n.annotation.forEach(e=>{let u=L(e.x,e.y,`Annotation ${e.number}`);a.addAnnotation(e.number,[{x:u.x,y:u.y}],e.text)}),n.accelerators.forEach(e=>{let u=L(e.x,e.y,`Accelerator "${e.name}"`);a.addAccelerator(e.name,u.x,u.y)}),n.deaccelerators.forEach(e=>{let u=L(e.x,e.y,`Deaccelerator "${e.name}"`);a.addDeaccelerator(e.name,u.x,u.y)})},"populateDb"),U={parser:{yy:void 0},parse:m(async n=>{let a=await ct("wardley",n);G.debug(a);let e=U.parser?.yy;if(!e||typeof e.addNode!="function")throw new Error("parser.parser?.yy was not a WardleyDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");Nt(a,e)},"parse")};var q=class{constructor(){this.nodes=new Map;this.links=[];this.trends=new Map;this.pipelines=new Map;this.annotations=[];this.notes=[];this.accelerators=[];this.deaccelerators=[];this.axes={}}static{m(this,"WardleyBuilder")}addNode(a){let e=this.nodes.get(a.id)??{id:a.id,label:a.label},u={...e,...a,className:a.className??e.className,labelOffsetX:a.labelOffsetX??e.labelOffsetX,labelOffsetY:a.labelOffsetY??e.labelOffsetY};this.nodes.set(a.id,u)}addLink(a){this.links.push(a)}addTrend(a){this.trends.set(a.nodeId,a)}startPipeline(a){this.pipelines.set(a,{nodeId:a,componentIds:[]});let e=this.nodes.get(a);e&&(e.isPipelineParent=!0)}addPipelineComponent(a,e){let u=this.pipelines.get(a);u&&u.componentIds.push(e);let r=this.nodes.get(e);r&&(r.inPipeline=!0)}addAnnotation(a){this.annotations.push(a)}addNote(a){this.notes.push(a)}addAccelerator(a){this.accelerators.push(a)}addDeaccelerator(a){this.deaccelerators.push(a)}setAnnotationsBox(a,e){this.annotationsBox={x:a,y:e}}setAxes(a){this.axes={...this.axes,...a}}setSize(a,e){this.size={width:a,height:e}}getNode(a){return this.nodes.get(a)}resolveNodeId(a){if(this.nodes.has(a))return a;for(let[e,u]of this.nodes)if(u.label===a)return e;return a}build(){let a=[];for(let e of this.nodes.values()){if(typeof e.x!="number"||typeof e.y!="number")throw new Error(`Node "${e.label}" is missing coordinates`);a.push(e)}return{nodes:a,links:[...this.links],trends:[...this.trends.values()],pipelines:[...this.pipelines.values()],annotations:[...this.annotations],notes:[...this.notes],accelerators:[...this.accelerators],deaccelerators:[...this.deaccelerators],annotationsBox:this.annotationsBox,axes:{...this.axes},size:this.size}}clear(){this.nodes.clear(),this.links=[],this.trends.clear(),this.pipelines.clear(),this.annotations=[],this.notes=[],this.accelerators=[],this.deaccelerators=[],this.annotationsBox=void 0,this.axes={},this.size=void 0}};var w=new q;function Mt(){return Y()["wardley-beta"]}m(Mt,"getConfig");function vt(n,a,e,u,r,l,h,S,y){w.addNode({id:n,label:a,x:e,y:u,className:r,labelOffsetX:l,labelOffsetY:h,inertia:S,sourceStrategy:y})}m(vt,"addNode");function Tt(n,a,e=!1,u,r){w.addLink({source:n,target:a,dashed:e,label:u,flow:r})}m(Tt,"addLink");function At(n,a,e){w.addTrend({nodeId:n,targetX:a,targetY:e})}m(At,"addTrend");function Lt(n,a,e){w.addAnnotation({number:n,coordinates:a,text:e})}m(Lt,"addAnnotation");function zt(n,a,e){w.addNote({text:n,x:a,y:e})}m(zt,"addNote");function Xt(n,a,e){w.addAccelerator({name:n,x:a,y:e})}m(Xt,"addAccelerator");function Bt(n,a,e){w.addDeaccelerator({name:n,x:a,y:e})}m(Bt,"addDeaccelerator");function Et(n,a){w.setAnnotationsBox(n,a)}m(Et,"setAnnotationsBox");function Dt(n,a){w.setSize(n,a)}m(Dt,"setSize");function Yt(n){w.startPipeline(n)}m(Yt,"startPipeline");function It(n,a){w.addPipelineComponent(n,a)}m(It,"addPipelineComponent");function Ot(n){w.setAxes(n)}m(Ot,"updateAxes");function Rt(n){return w.getNode(n)}m(Rt,"getNode");function Ft(n){return w.resolveNodeId(n)}m(Ft,"resolveNodeId");function Gt(){return w.build()}m(Gt,"getWardleyData");function jt(){w.clear(),at()}m(jt,"clear");var ft={getConfig:Mt,addNode:vt,addLink:Tt,addTrend:At,addAnnotation:Lt,addNote:zt,addAccelerator:Xt,addDeaccelerator:Bt,setAnnotationsBox:Et,setSize:Dt,startPipeline:Yt,addPipelineComponent:It,updateAxes:Ot,getNode:Rt,resolveNodeId:Ft,getWardleyData:Gt,clear:jt,setAccTitle:nt,getAccTitle:ot,setDiagramTitle:lt,getDiagramTitle:dt,getAccDescription:it,setAccDescription:st};var qt=["Genesis","Custom Built","Product","Commodity"],Ht=m(()=>{let{themeVariables:n}=Y();return{backgroundColor:n.wardley?.backgroundColor??n.background??"#fff",axisColor:n.wardley?.axisColor??"#000",axisTextColor:n.wardley?.axisTextColor??n.primaryTextColor??"#222",gridColor:n.wardley?.gridColor??"rgba(100, 100, 100, 0.2)",componentFill:n.wardley?.componentFill??"#fff",componentStroke:n.wardley?.componentStroke??"#000",componentLabelColor:n.wardley?.componentLabelColor??n.primaryTextColor??"#222",linkStroke:n.wardley?.linkStroke??"#000",evolutionStroke:n.wardley?.evolutionStroke??"#dc3545",annotationStroke:n.wardley?.annotationStroke??"#000",annotationTextColor:n.wardley?.annotationTextColor??n.primaryTextColor??"#222",annotationFill:n.wardley?.annotationFill??n.background??"#fff"}},"getTheme"),Vt=m(()=>{let n=Y()["wardley-beta"];return{width:n?.width??900,height:n?.height??600,padding:n?.padding??48,nodeRadius:n?.nodeRadius??6,nodeLabelOffset:n?.nodeLabelOffset??8,axisFontSize:n?.axisFontSize??12,labelFontSize:n?.labelFontSize??10,showGrid:n?.showGrid??!1,useMaxWidth:n?.useMaxWidth??!0}},"getConfigValues"),_t=m((n,a,e,u)=>{G.debug(`Rendering Wardley map
`+n);let r=Vt(),l=Ht(),h=r.nodeRadius*1.6,S=u.db,y=S.getWardleyData(),I=S.getDiagramTitle(),$=y.size?.width??r.width,k=y.size?.height??r.height,X=gt(a);X.selectAll("*").remove(),rt(X,k,$,r.useMaxWidth),X.attr("viewBox",`0 0 ${$} ${k}`);let W=X.append("g").attr("class","wardley-map"),H=X.append("defs");H.append("marker").attr("id",`arrow-${a}`).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",6).attr("markerHeight",6).attr("orient","auto-start-reverse").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("fill",l.evolutionStroke).attr("stroke","none"),H.append("marker").attr("id",`link-arrow-end-${a}`).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("fill",l.linkStroke).attr("stroke","none"),H.append("marker").attr("id",`link-arrow-start-${a}`).attr("viewBox","0 0 10 10").attr("refX",1).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("path").attr("d","M 10 0 L 0 5 L 10 10 z").attr("fill",l.linkStroke).attr("stroke","none"),W.append("rect").attr("class","wardley-background").attr("width",$).attr("height",k).attr("fill",l.backgroundColor);let B=$-r.padding*2,E=k-r.padding*2;I&&W.append("text").attr("class","wardley-title").attr("x",$/2).attr("y",r.padding/2).attr("fill",l.axisTextColor).attr("font-size",r.axisFontSize*1.05).attr("font-weight","bold").attr("text-anchor","middle").attr("dominant-baseline","middle").text(I);let v=m(t=>r.padding+t/100*B,"projectX"),T=m(t=>k-r.padding-t/100*E,"projectY"),O=W.append("g").attr("class","wardley-axes");O.append("line").attr("x1",r.padding).attr("x2",$-r.padding).attr("y1",k-r.padding).attr("y2",k-r.padding).attr("stroke",l.axisColor).attr("stroke-width",1),O.append("line").attr("x1",r.padding).attr("x2",r.padding).attr("y1",r.padding).attr("y2",k-r.padding).attr("stroke",l.axisColor).attr("stroke-width",1);let mt=y.axes.xLabel??"Evolution",ht=y.axes.yLabel??"Visibility";O.append("text").attr("class","wardley-axis-label wardley-axis-label-x").attr("x",r.padding+B/2).attr("y",k-r.padding/4).attr("fill",l.axisTextColor).attr("font-size",r.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").text(mt),O.append("text").attr("class","wardley-axis-label wardley-axis-label-y").attr("x",r.padding/3).attr("y",r.padding+E/2).attr("fill",l.axisTextColor).attr("font-size",r.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").attr("transform",`rotate(-90 ${r.padding/3} ${r.padding+E/2})`).text(ht);let D=y.axes.stages&&y.axes.stages.length>0?y.axes.stages:qt;if(D.length>0){let t=W.append("g").attr("class","wardley-stages"),s=y.axes.stageBoundaries,o=[];if(s&&s.length===D.length){let i=0;s.forEach(p=>{o.push({start:i,end:p}),i=p})}else{let i=1/D.length;D.forEach((p,d)=>{o.push({start:d*i,end:(d+1)*i})})}D.forEach((i,p)=>{let d=o[p],g=r.padding+d.start*B,f=r.padding+d.end*B,x=(g+f)/2;p>0&&t.append("line").attr("x1",g).attr("x2",g).attr("y1",r.padding).attr("y2",k-r.padding).attr("stroke","#000").attr("stroke-width",1).attr("stroke-dasharray","5 5").attr("opacity",.8),t.append("text").attr("class","wardley-stage-label").attr("x",x).attr("y",k-r.padding/1.5).attr("fill",l.axisTextColor).attr("font-size",r.axisFontSize-2).attr("text-anchor","middle").text(i)})}if(r.showGrid){let t=W.append("g").attr("class","wardley-grid");for(let s=1;s<4;s++){let o=s/4,i=r.padding+B*o;t.append("line").attr("x1",i).attr("x2",i).attr("y1",r.padding).attr("y2",k-r.padding).attr("stroke",l.gridColor).attr("stroke-dasharray","2 6"),t.append("line").attr("x1",r.padding).attr("x2",$-r.padding).attr("y1",k-r.padding-E*o).attr("y2",k-r.padding-E*o).attr("stroke",l.gridColor).attr("stroke-dasharray","2 6")}}let c=new Map;if(y.nodes.forEach(t=>{c.set(t.id,{x:v(t.x),y:T(t.y),node:t})}),y.pipelines.length>0){let t=W.append("g").attr("class","wardley-pipelines"),s=W.append("g").attr("class","wardley-pipeline-links");y.pipelines.forEach(o=>{if(o.componentIds.length===0)return;let i=o.componentIds.map(f=>({id:f,pos:c.get(f),node:y.nodes.find(x=>x.id===f)})).filter(f=>f.pos&&f.node).sort((f,x)=>f.node.x-x.node.x);for(let f=0;f<i.length-1;f++){let x=i[f],b=i[f+1];s.append("line").attr("class","wardley-pipeline-evolution-link").attr("x1",x.pos.x).attr("y1",x.pos.y).attr("x2",b.pos.x).attr("y2",b.pos.y).attr("stroke",l.linkStroke).attr("stroke-width",1).attr("stroke-dasharray","4 4")}let p=1/0,d=-1/0,g=0;if(o.componentIds.forEach(f=>{let x=c.get(f);x&&(p=Math.min(p,x.x),d=Math.max(d,x.x),g=x.y)}),p!==1/0&&d!==-1/0){let x=r.nodeRadius*4,b=g-x/2,P=c.get(o.nodeId);if(P){let M=(p+d)/2;P.x=M,P.y=b-h/6}t.append("rect").attr("class","wardley-pipeline-box").attr("x",p-15).attr("y",b).attr("width",d-p+30).attr("height",x).attr("fill","none").attr("stroke",l.axisColor).attr("stroke-width",1.5).attr("rx",4).attr("ry",4)}})}let J=W.append("g").attr("class","wardley-links"),K=new Map;y.pipelines.forEach(t=>{K.set(t.nodeId,new Set(t.componentIds))});let Q=y.links.filter(t=>!(!c.has(t.source)||!c.has(t.target)||K.get(t.target)?.has(t.source)));J.selectAll("line").data(Q).enter().append("line").attr("class",t=>`wardley-link${t.dashed?" wardley-link--dashed":""}`).attr("x1",t=>{let s=c.get(t.source),o=c.get(t.target),p=y.nodes.find(x=>x.id===t.source).isPipelineParent?h/Math.sqrt(2):r.nodeRadius,d=o.x-s.x,g=o.y-s.y,f=Math.sqrt(d*d+g*g);return s.x+d/f*p}).attr("y1",t=>{let s=c.get(t.source),o=c.get(t.target),p=y.nodes.find(x=>x.id===t.source).isPipelineParent?h/Math.sqrt(2):r.nodeRadius,d=o.x-s.x,g=o.y-s.y,f=Math.sqrt(d*d+g*g);return s.y+g/f*p}).attr("x2",t=>{let s=c.get(t.source),o=c.get(t.target),p=y.nodes.find(x=>x.id===t.target).isPipelineParent?h/Math.sqrt(2):r.nodeRadius,d=s.x-o.x,g=s.y-o.y,f=Math.sqrt(d*d+g*g);return o.x+d/f*p}).attr("y2",t=>{let s=c.get(t.source),o=c.get(t.target),p=y.nodes.find(x=>x.id===t.target).isPipelineParent?h/Math.sqrt(2):r.nodeRadius,d=s.x-o.x,g=s.y-o.y,f=Math.sqrt(d*d+g*g);return o.y+g/f*p}).attr("stroke",l.linkStroke).attr("stroke-width",1).attr("stroke-dasharray",t=>t.dashed?"6 6":null).attr("marker-end",t=>t.flow==="forward"||t.flow==="bidirectional"?`url(#link-arrow-end-${a})`:null).attr("marker-start",t=>t.flow==="backward"||t.flow==="bidirectional"?`url(#link-arrow-start-${a})`:null),J.selectAll("text").data(Q.filter(t=>t.label)).enter().append("text").attr("class","wardley-link-label").attr("x",t=>{let s=c.get(t.source),o=c.get(t.target),i=(s.x+o.x)/2,p=o.y-s.y,d=o.x-s.x,g=Math.sqrt(d*d+p*p),f=8,x=p/g;return i+x*f}).attr("y",t=>{let s=c.get(t.source),o=c.get(t.target),i=(s.y+o.y)/2,p=o.x-s.x,d=o.y-s.y,g=Math.sqrt(p*p+d*d),f=8,x=-p/g;return i+x*f}).attr("fill",l.axisTextColor).attr("font-size",r.labelFontSize).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("transform",t=>{let s=c.get(t.source),o=c.get(t.target),i=(s.x+o.x)/2,p=(s.y+o.y)/2,d=o.x-s.x,g=o.y-s.y,f=Math.sqrt(d*d+g*g),x=8,b=g/f,P=-d/f,M=i+b*x,R=p+P*x,z=Math.atan2(g,d)*180/Math.PI;return(z>90||z<-90)&&(z+=180),`rotate(${z} ${M} ${R})`}).text(t=>t.label);let bt=W.append("g").attr("class","wardley-trends"),wt=y.trends.map(t=>{let s=c.get(t.nodeId);if(!s)return null;let o=v(t.targetX),i=T(t.targetY),p=o-s.x,d=i-s.y,g=Math.sqrt(p*p+d*d),f=r.nodeRadius+2,x=g>f?o-p/g*f:o,b=g>f?i-d/g*f:i;return{origin:s,targetX:o,targetY:i,adjustedX2:x,adjustedY2:b}}).filter(t=>t!==null);bt.selectAll("line").data(wt).enter().append("line").attr("class","wardley-trend").attr("x1",t=>t.origin.x).attr("y1",t=>t.origin.y).attr("x2",t=>t.adjustedX2).attr("y2",t=>t.adjustedY2).attr("stroke",l.evolutionStroke).attr("stroke-width",1).attr("stroke-dasharray","4 4").attr("marker-end",`url(#arrow-${a})`);let N=W.append("g").attr("class","wardley-nodes").selectAll("g").data(y.nodes).enter().append("g").attr("class",t=>["wardley-node",t.className?`wardley-node--${t.className}`:""].filter(Boolean).join(" "));N.filter(t=>t.sourceStrategy==="outsource").append("circle").attr("class","wardley-outsource-overlay").attr("cx",t=>c.get(t.id).x).attr("cy",t=>c.get(t.id).y).attr("r",r.nodeRadius*2).attr("fill","#666").attr("stroke",l.componentStroke).attr("stroke-width",1),N.filter(t=>t.sourceStrategy==="buy").append("circle").attr("class","wardley-buy-overlay").attr("cx",t=>c.get(t.id).x).attr("cy",t=>c.get(t.id).y).attr("r",r.nodeRadius*2).attr("fill","#ccc").attr("stroke",l.componentStroke).attr("stroke-width",1),N.filter(t=>t.sourceStrategy==="build").append("circle").attr("class","wardley-build-overlay").attr("cx",t=>c.get(t.id).x).attr("cy",t=>c.get(t.id).y).attr("r",r.nodeRadius*2).attr("fill","#eee").attr("stroke","#000").attr("stroke-width",1);let A=N.filter(t=>t.sourceStrategy==="market");A.append("circle").attr("class","wardley-market-overlay").attr("cx",t=>c.get(t.id).x).attr("cy",t=>c.get(t.id).y).attr("r",r.nodeRadius*2).attr("fill","white").attr("stroke",l.componentStroke).attr("stroke-width",1),N.filter(t=>!t.isPipelineParent&&t.sourceStrategy!=="market"&&t.className!=="anchor").append("circle").attr("cx",t=>c.get(t.id).x).attr("cy",t=>c.get(t.id).y).attr("r",r.nodeRadius).attr("fill",l.componentFill).attr("stroke",l.componentStroke).attr("stroke-width",1);let V=r.nodeRadius*.7,C=r.nodeRadius*1.2;if(A.append("line").attr("class","wardley-market-line").attr("x1",t=>c.get(t.id).x).attr("y1",t=>c.get(t.id).y-C).attr("x2",t=>c.get(t.id).x-C*Math.cos(Math.PI/6)).attr("y2",t=>c.get(t.id).y+C*Math.sin(Math.PI/6)).attr("stroke",l.componentStroke).attr("stroke-width",1),A.append("line").attr("class","wardley-market-line").attr("x1",t=>c.get(t.id).x-C*Math.cos(Math.PI/6)).attr("y1",t=>c.get(t.id).y+C*Math.sin(Math.PI/6)).attr("x2",t=>c.get(t.id).x+C*Math.cos(Math.PI/6)).attr("y2",t=>c.get(t.id).y+C*Math.sin(Math.PI/6)).attr("stroke",l.componentStroke).attr("stroke-width",1),A.append("line").attr("class","wardley-market-line").attr("x1",t=>c.get(t.id).x+C*Math.cos(Math.PI/6)).attr("y1",t=>c.get(t.id).y+C*Math.sin(Math.PI/6)).attr("x2",t=>c.get(t.id).x).attr("y2",t=>c.get(t.id).y-C).attr("stroke",l.componentStroke).attr("stroke-width",1),A.append("circle").attr("class","wardley-market-dot").attr("cx",t=>c.get(t.id).x).attr("cy",t=>c.get(t.id).y-C).attr("r",V).attr("fill","white").attr("stroke",l.componentStroke).attr("stroke-width",2),A.append("circle").attr("class","wardley-market-dot").attr("cx",t=>c.get(t.id).x-C*Math.cos(Math.PI/6)).attr("cy",t=>c.get(t.id).y+C*Math.sin(Math.PI/6)).attr("r",V).attr("fill","white").attr("stroke",l.componentStroke).attr("stroke-width",2),A.append("circle").attr("class","wardley-market-dot").attr("cx",t=>c.get(t.id).x+C*Math.cos(Math.PI/6)).attr("cy",t=>c.get(t.id).y+C*Math.sin(Math.PI/6)).attr("r",V).attr("fill","white").attr("stroke",l.componentStroke).attr("stroke-width",2),N.filter(t=>t.isPipelineParent===!0).append("rect").attr("x",t=>c.get(t.id).x-h/2).attr("y",t=>c.get(t.id).y-h/2).attr("width",h).attr("height",h).attr("fill",l.componentFill).attr("stroke",l.componentStroke).attr("stroke-width",1),N.filter(t=>t.inertia===!0).append("line").attr("class","wardley-inertia").attr("x1",t=>{let s=c.get(t.id),o=t.isPipelineParent?h/2+15:r.nodeRadius+15;return t.sourceStrategy&&(o+=r.nodeRadius+10),s.x+o}).attr("y1",t=>{let s=c.get(t.id),o=t.isPipelineParent?h:r.nodeRadius*2;return s.y-o/2}).attr("x2",t=>{let s=c.get(t.id),o=t.isPipelineParent?h/2+15:r.nodeRadius+15;return t.sourceStrategy&&(o+=r.nodeRadius+10),s.x+o}).attr("y2",t=>{let s=c.get(t.id),o=t.isPipelineParent?h:r.nodeRadius*2;return s.y+o/2}).attr("stroke",l.componentStroke).attr("stroke-width",6),N.append("text").attr("x",t=>{let s=c.get(t.id);if(t.className==="anchor")return t.labelOffsetX!==void 0?s.x+t.labelOffsetX:s.x;let o=r.nodeLabelOffset;t.sourceStrategy&&t.labelOffsetX===void 0&&(o+=10);let i=t.labelOffsetX??o;return s.x+i}).attr("y",t=>{let s=c.get(t.id);if(t.className==="anchor")return t.labelOffsetY!==void 0?s.y+t.labelOffsetY:s.y-3;let o=-r.nodeLabelOffset;t.sourceStrategy&&t.labelOffsetY===void 0&&(o-=10);let i=t.labelOffsetY??o;return s.y+i}).attr("class","wardley-node-label").attr("fill",t=>t.className==="evolved"?l.evolutionStroke:t.className==="anchor"?"#000":l.componentLabelColor).attr("font-size",r.labelFontSize).attr("font-weight",t=>t.className==="anchor"?"bold":"normal").attr("text-anchor",t=>t.className==="anchor"?"middle":"start").attr("dominant-baseline",t=>t.className==="anchor"?"middle":"auto").text(t=>t.label),y.annotations.length>0){let t=W.append("g").attr("class","wardley-annotations");if(y.annotations.forEach(s=>{let o=s.coordinates.map(i=>({x:v(i.x),y:T(i.y)}));if(o.length>1)for(let i=0;i<o.length-1;i++)t.append("line").attr("class","wardley-annotation-line").attr("x1",o[i].x).attr("y1",o[i].y).attr("x2",o[i+1].x).attr("y2",o[i+1].y).attr("stroke",l.axisColor).attr("stroke-width",1.5).attr("stroke-dasharray","4 4");o.forEach(i=>{let p=t.append("g").attr("class","wardley-annotation");p.append("circle").attr("cx",i.x).attr("cy",i.y).attr("r",10).attr("fill","white").attr("stroke",l.axisColor).attr("stroke-width",1.5),p.append("text").attr("x",i.x).attr("y",i.y).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",10).attr("fill",l.axisTextColor).attr("font-weight","bold").text(s.number)})}),y.annotationsBox){let s=v(y.annotationsBox.x),o=T(y.annotationsBox.y),i=10,p=16,d=11,g=t.append("g").attr("class","wardley-annotations-box"),f=[...y.annotations].filter(b=>b.text).sort((b,P)=>b.number-P.number),x=[];if(f.forEach((b,P)=>{let M=g.append("text").attr("x",s+i).attr("y",o+i+(P+1)*p).attr("font-size",d).attr("fill",l.axisTextColor).attr("text-anchor","start").attr("dominant-baseline","middle").text(`${b.number}. ${b.text}`);x.push(M)}),x.length>0){let b=0,P=0;x.forEach(_=>{let F=_.node(),Pt=F.getComputedTextLength();b=Math.max(b,Pt);let St=F.getBBox();P=Math.max(P,St.height)});let M=b+i*2+105,R=f.length*p+i*2+P/2,z=r.padding,kt=$-r.padding-M,Ct=r.padding,Wt=k-r.padding-R;s=Math.max(z,Math.min(s,kt)),o=Math.max(Ct,Math.min(o,Wt)),x.forEach((_,F)=>{_.attr("x",s+i).attr("y",o+i+(F+1)*p)}),g.insert("rect","text").attr("x",s).attr("y",o).attr("width",M).attr("height",R).attr("fill","white").attr("stroke",l.axisColor).attr("stroke-width",1.5).attr("rx",4).attr("ry",4)}}}if(y.notes.length>0){let t=W.append("g").attr("class","wardley-notes");y.notes.forEach(s=>{let o=v(s.x),i=T(s.y);t.append("text").attr("x",o).attr("y",i).attr("text-anchor","start").attr("font-size",11).attr("fill",l.axisTextColor).attr("font-weight","bold").text(s.text)})}if(y.accelerators.length>0){let t=W.append("g").attr("class","wardley-accelerators");y.accelerators.forEach(s=>{let o=v(s.x),i=T(s.y),p=60,d=30,g=20,f=`
M ${o} ${i-d/2}
L ${o+p-g} ${i-d/2}
L ${o+p-g} ${i-d/2-8}
L ${o+p} ${i}
L ${o+p-g} ${i+d/2+8}
L ${o+p-g} ${i+d/2}
L ${o} ${i+d/2}
Z
`;t.append("path").attr("d",f).attr("fill","white").attr("stroke",l.componentStroke).attr("stroke-width",1),t.append("text").attr("x",o+p/2).attr("y",i+d/2+15).attr("text-anchor","middle").attr("font-size",10).attr("fill",l.axisTextColor).attr("font-weight","bold").text(s.name)})}if(y.deaccelerators.length>0){let t=W.append("g").attr("class","wardley-deaccelerators");y.deaccelerators.forEach(s=>{let o=v(s.x),i=T(s.y),p=60,d=30,g=20,f=`
M ${o+p} ${i-d/2}
L ${o+g} ${i-d/2}
L ${o+g} ${i-d/2-8}
L ${o} ${i}
L ${o+g} ${i+d/2+8}
L ${o+g} ${i+d/2}
L ${o+p} ${i+d/2}
Z
`;t.append("path").attr("d",f).attr("fill","white").attr("stroke",l.componentStroke).attr("stroke-width",1),t.append("text").attr("x",o+p/2).attr("y",i+d/2+15).attr("text-anchor","middle").attr("font-size",10).attr("fill",l.axisTextColor).attr("font-weight","bold").text(s.name)})}},"draw"),yt={draw:_t};var xt=m(({wardley:n}={})=>{let a=tt(),e=et(),u=Z(a,e.themeVariables),r=Z(u.wardley,n);return`
.wardley-background {
fill: ${r.backgroundColor};
}
.wardley-axes line, .wardley-axes path {
stroke: ${r.axisColor};
}
.wardley-axis-label {
fill: ${r.axisTextColor};
}
.wardley-stage-label {
fill: ${r.axisTextColor};
}
.wardley-grid line {
stroke: ${r.gridColor};
}
.wardley-node circle {
fill: ${r.componentFill};
stroke: ${r.componentStroke};
}
.wardley-node-label {
fill: ${r.componentLabelColor};
}
.wardley-link {
stroke: ${r.linkStroke};
}
.wardley-link--dashed {
stroke-dasharray: 4 4;
}
.wardley-link-label {
fill: ${r.axisTextColor};
}
.wardley-trend line {
stroke: ${r.evolutionStroke};
}
.wardley-annotation-line {
stroke: ${r.annotationStroke};
}
.wardley-annotation circle {
fill: ${r.annotationFill};
stroke: ${r.annotationStroke};
}
.wardley-annotation text {
fill: ${r.annotationTextColor};
}
.wardley-annotations-box rect {
fill: ${r.annotationFill};
stroke: ${r.annotationStroke};
}
.wardley-annotations-box text {
fill: ${r.annotationTextColor};
}
.wardley-pipeline-box {
stroke: ${r.componentStroke};
}
.wardley-notes text {
fill: ${r.axisTextColor};
}
`},"styles");var We={parser:U,db:ft,renderer:yt,styles:xt};export{We as diagram};