Files
static-php-cli/assets/chunks/wardleyDiagram-NUSXRM2D.CtyamWnD.js

21 lines
24 KiB
JavaScript
Raw Normal View History

import{_ as y,s as Mt,g as Ct,t as Lt,q as Nt,a as zt,b as At,l as Q,L as Xt,e as Et,A as Tt,c as H,i as Yt}from"./mermaid.core.FcP8wBwW.js";import{p as Bt}from"./chunk-4BX2VUAB.DRMGnluz.js";import{p as Rt}from"./wardley-RL74JXVD.BA-8CGC6.js";import"./framework.C2AwuPrQ.js";import"./min.CT2il0xb.js";import"./baseUniq.CeiE9d8M.js";var q=y((a,r)=>{const e=a<=1?a*100:a;if(e<0||e>100)throw new Error(`${r} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${a}`);return e},"toPercent"),E=y((a,r,e)=>({x:q(r,`${e} evolution`),y:q(a,`${e} visibility`)}),"toCoordinates"),K=y(a=>{if(a){if(a==="+<>")return"bidirectional";if(a==="+<")return"backward";if(a==="+>")return"forward"}},"getFlowFromPort"),Ft=y(a=>{if(!a?.startsWith("+"))return{};const e=/^\+'([^']*)'/.exec(a)?.[1];return a.includes("<>")?{flow:"bidirectional",label:e}:a.includes("<")?{flow:"backward",label:e}:a.includes(">")?{flow:"forward",label:e}:{label:e}},"extractFlowFromArrow"),Ot=y((a,r)=>{if(Bt(a,r),a.size&&r.setSize(a.size.width,a.size.height),a.evolution){const e=a.evolution.stages.map(s=>s.secondName?`${s.name.trim()} / ${s.secondName.trim()}`:s.name.trim()),x=a.evolution.stages.filter(s=>s.boundary!==void 0).map(s=>s.boundary);r.updateAxes({stages:e,stageBoundaries:x})}if(a.anchors.forEach(e=>{const x=E(e.visibility,e.evolution,`Anchor "${e.name}"`);r.addNode(e.name,e.name,x.x,x.y,"anchor")}),a.components.forEach(e=>{const x=E(e.visibility,e.evolution,`Component "${e.name}"`),s=e.label?(e.label.negX?-1:1)*e.label.offsetX:void 0,d=e.label?(e.label.negY?-1:1)*e.label.offsetY:void 0,m=e.decorator?.strategy;r.addNode(e.name,e.name,x.x,x.y,"component",s,d,e.inertia,m)}),a.notes.forEach(e=>{const x=E(e.visibility,e.evolution,`Note "${e.text}"`);r.addNote(e.text,x.x,x.y)}),a.pipelines.forEach(e=>{const x=r.getNode(e.parent);if(!x||typeof x.y!="number")throw new Error(`Pipeline "${e.parent}" must reference an existing component with coordinates.`);const s=x.y;r.startPipeline(e.parent),e.components.forEach(d=>{const m=`${e.parent}_${d.name}`,M=d.label?(d.label.negX?-1:1)*d.label.offsetX:void 0,g=d.label?(d.label.negY?-1:1)*d.label.offsetY:void 0,I=q(d.evolution,`Pipeline component "${d.name}" evolution`);r.addNode(m,d.name,I,s,"pipeline-component",M,g),r.addPipelineComponent(e.parent,m)})}),a.links.forEach(e=>{const x=!!e.arrow&&(e.arrow.includes("-.->")||e.arrow.includes(".-."));let s=K(e.fromPort)??K(e.toPort);const{flow:d,label:m}=Ft(e.arrow);!s&&d&&(s=d);const M=e.linkLabel,g=m??M;r.addLink(e.from,e.to,x,g,s)}),a.evolves.forEach(e=>{const x=r.getNode(e.component);if(x?.y!==void 0){const s=q(e.target,`Evolve target for "${e.component}"`);r.addTrend(e.component,s,x.y)}}),a.annotations.length>0){const e=a.annotations[0],x=E(e.x,e.y,"Annotations box");r.setAnnotationsBox(x.x,x.y)}a.annotation.forEach(e=>{const x=E(e.x,e.y,`Annotation ${e.number}`);r.addAnnotation(e.number,[{x:x.x,y:x.y}],e.text)}),a.accelerators.forEach(e=>{const x=E(e.x,e.y,`Accelerator "${e.name}"`);r.addAccelerator(e.name,x.x,x.y)}),a.deaccelerators.forEach(e=>{const x=E(e.x,e.y,`Deaccelerator "${e.name}"`);r.addDeaccelerator(e.name,x.x,x.y)})},"populateDb"),tt={parser:{yy:void 0},parse:y(async a=>{const r=await Rt("wardley",a);Q.debug(r);const e=tt.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.");Ot(r,e)},"parse")},Y,It=(Y=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={}}addNode(r){const e=this.nodes.get(r.id)??{id:r.id,label:r.label},x={...e,...r,className:r.className??e.className,labelOffsetX:r.labelOffsetX??e.labelOffsetX,labelOffsetY:r.labelOffsetY??e.labelOffsetY};this.nodes.set(r.id,x)}addLink(r){this.links.push(r)}addTrend(r){this.trends.set(r.nodeId,r)}startPipeline(r){this.pipelines.set(r,{nodeId:r,componentIds:[]});const e=this.nodes.get(r);e&&(e.isPipelineParent=!0)}addPipelin
`+a);const s=qt(),d=Gt(),m=s.nodeRadius*1.6,M=x.db,g=M.getWardleyData(),I=M.getDiagramTitle(),C=g.size?.width??s.width,b=g.size?.height??s.height,B=Xt(r);B.selectAll("*").remove(),Et(B,b,C,s.useMaxWidth),B.attr("viewBox",`0 0 ${C} ${b}`);const v=B.append("g").attr("class","wardley-map"),j=B.append("defs");j.append("marker").attr("id",`arrow-${r}`).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",d.evolutionStroke).attr("stroke","none"),j.append("marker").attr("id",`link-arrow-end-${r}`).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",d.linkStroke).attr("stroke","none"),j.append("marker").attr("id",`link-arrow-start-${r}`).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",d.linkStroke).attr("stroke","none"),v.append("rect").attr("class","wardley-background").attr("width",C).attr("height",b).attr("fill",d.backgroundColor);const R=C-s.padding*2,F=b-s.padding*2;I&&v.append("text").attr("class","wardley-title").attr("x",C/2).attr("y",s.padding/2).attr("fill",d.axisTextColor).attr("font-size",s.axisFontSize*1.05).attr("font-weight","bold").attr("text-anchor","middle").attr("dominant-baseline","middle").text(I);const z=y(t=>s.padding+t/100*R,"projectX"),A=y(t=>b-s.padding-t/100*F,"projectY"),W=v.append("g").attr("class","wardley-axes");W.append("line").attr("x1",s.padding).attr("x2",C-s.padding).attr("y1",b-s.padding).attr("y2",b-s.padding).attr("stroke",d.axisColor).attr("stroke-width",1),W.append("line").attr("x1",s.padding).attr("x2",s.padding).attr("y1",s.padding).attr("y2",b-s.padding).attr("stroke",d.axisColor).attr("stroke-width",1);const yt=g.axes.xLabel??"Evolution",mt=g.axes.yLabel??"Visibility";W.append("text").attr("class","wardley-axis-label wardley-axis-label-x").attr("x",s.padding+R/2).attr("y",b-s.padding/4).attr("fill",d.axisTextColor).attr("font-size",s.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").text(yt),W.append("text").attr("class","wardley-axis-label wardley-axis-label-y").attr("x",s.padding/3).attr("y",s.padding+F/2).attr("fill",d.axisTextColor).attr("font-size",s.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").attr("transform",`rotate(-90 ${s.padding/3} ${s.padding+F/2})`).text(mt);const O=g.axes.stages&&g.axes.stages.length>0?g.axes.stages:Dt;if(O.length>0){const t=v.append("g").attr("class","wardley-stages"),n=g.axes.stageBoundaries,o=[];if(n&&n.length===O.length){let i=0;n.forEach(p=>{o.push({start:i,end:p}),i=p})}else{const i=1/O.length;O.forEach((p,l)=>{o.push({start:l*i,end:(l+1)*i})})}O.forEach((i,p)=>{const l=o[p],h=s.padding+l.start*R,f=s.padding+l.end*R,u=(h+f)/2;p>0&&t.append("line").attr("x1",h).attr("x2",h).attr("y1",s.padding).attr("y2",b-s.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",u).attr("y",b-s.padding/1.5).attr("fill",d.axisTextColor).attr("font-size",s.axisFontSize-2).attr("text-anchor","middle").text(i)})}if(s.showGrid){const t=v.append("g").attr("class","wardley-grid");for(let n=1;n<4;n++){const o=n/4,i=s.padding+R*o;t.append("line").attr("x1",i).attr("x2",i).attr("y1",s.padding).attr("y2",b-s.padding).attr("stroke",d.gridColor).attr("stroke-dasharray","2 6"),t.append("line").attr("x1",s.padding).attr("x2",C-s.padding).attr("y1",b-s.padding-F*o).attr("y2",b-s.padding-F*o).attr("stroke",d.gridColor).attr("stroke-dasharray","2 6")}}const c=new Map;if(g.nodes.forEach(t=>{c.set(t.id,{x:z(t.x),y:A(t.y),node:t})}),g.pipelines.length>0){const t=v.append("g").attr("class","wardley-pipelines"),n=v.append("g").attr("class","wardley-pipeline-links");g.pipelines.forEach(o=>{if(o.componentIds.length===0)retur
M ${o} ${i-l/2}
L ${o+p-h} ${i-l/2}
L ${o+p-h} ${i-l/2-8}
L ${o+p} ${i}
L ${o+p-h} ${i+l/2+8}
L ${o+p-h} ${i+l/2}
L ${o} ${i+l/2}
Z
`;t.append("path").attr("d",f).attr("fill","white").attr("stroke",d.componentStroke).attr("stroke-width",1),t.append("text").attr("x",o+p/2).attr("y",i+l/2+15).attr("text-anchor","middle").attr("font-size",10).attr("fill",d.axisTextColor).attr("font-weight","bold").text(n.name)})}if(g.deaccelerators.length>0){const t=v.append("g").attr("class","wardley-deaccelerators");g.deaccelerators.forEach(n=>{const o=z(n.x),i=A(n.y),p=60,l=30,h=20,f=`
M ${o+p} ${i-l/2}
L ${o+h} ${i-l/2}
L ${o+h} ${i-l/2-8}
L ${o} ${i}
L ${o+h} ${i+l/2+8}
L ${o+h} ${i+l/2}
L ${o+p} ${i+l/2}
Z
`;t.append("path").attr("d",f).attr("fill","white").attr("stroke",d.componentStroke).attr("stroke-width",1),t.append("text").attr("x",o+p/2).attr("y",i+l/2+15).attr("text-anchor","middle").attr("font-size",10).attr("fill",d.axisTextColor).attr("font-weight","bold").text(n.name)})}},"draw"),jt={draw:Ht},te={parser:tt,db:Wt,renderer:jt,styles:y(()=>"","styles")};export{te as diagram};