@zombie-mermaid/svg-renderer 5.13.0 → 5.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +59 -60
- package/dist/index.js +28 -29
- package/dist/shared/index.d.ts +18 -4
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -43,21 +43,21 @@ import{DEFAULTS as e,applyThemeVariables as t,buildStyleBlock as n,checkGraphSiz
|
|
|
43
43
|
`);a.push(d`<g><title>${La(t)}</title>`)}let s=0;e.keys.length>0&&(s=I(e.keys.join(`,`),Oa.keySize,Oa.keyWeight)+8,a.push(d`<rect x="${t+6}" y="${n-7}" width="${s}" height="14" rx="2" ry="2" `+`fill="var(--_key-badge)" />`),a.push(d`<text x="${t+6+s/2}" y="${n}" text-anchor="middle" dy="${z}" `+d`font-size="${Oa.keySize}" font-weight="${Oa.keyWeight}" fill="${i??`var(--_text-sec)`}">${e.keys.join(`,`)}</text>`));let c=t+8+(s>0?s+6:0);a.push(d`<text x="${c}" y="${n}" class="mono" dy="${z}" `+d`font-size="${Oa.attrSize}" font-weight="${Oa.attrWeight}">`+d`<tspan fill="${i??`var(--_text-muted)`}">${La(e.type)}</tspan></text>`);let l=t+r-8;return a.push(d`<text x="${l}" y="${n}" class="mono" text-anchor="end" dy="${z}" `+d`font-size="${Oa.attrSize}" font-weight="${Oa.attrWeight}">`+d`<tspan fill="${i??`var(--_text-sec)`}">${La(e.name)}</tspan></text>`),o&&a.push(`</g>`),a.join(`
|
|
44
44
|
`)}function Ma(e){if(e.points.length<2)return``;let t=e.points.map(e=>d`${e.x},${e.y}`).join(` `),n=e.identifying?``:` stroke-dasharray="6 4"`,r=e.label?d` data-label="${c(e.label)}"`:``,i=[`class="er-relationship"`,d`data-entity1="${c(e.entity1)}"`,d`data-entity2="${c(e.entity2)}"`,d`data-cardinality1="${e.cardinality1}"`,d`data-cardinality2="${e.cardinality2}"`,d`data-identifying="${e.identifying}"`];return d`<polyline ${i.join(` `)}${r} points="${t}" fill="none" stroke="var(--_line)" `+d`stroke-width="${R.connector}"${n} />`}function Na(e,t){if(!e.label||e.points.length<2)return``;let n=e.labelPoint??Ia(e.points),r=_(e.label,t.edgeLabel,L.edgeLabel),i=r.width+8,a=r.height+6;return d`<rect x="${n.x-i/2}" y="${n.y-a/2}" width="${i}" height="${a}" rx="2" ry="2" `+`fill="var(--bg)" stroke="var(--_inner-stroke)" stroke-width="0.5" />`+d`\n${C(e.label,n.x,n.y,t.edgeLabel,d`text-anchor="middle" font-size="${t.edgeLabel}" font-weight="${L.edgeLabel}" fill="color-mix(in srgb, var(--fg) ${Da}%, var(--bg))"`)}`}function Pa(e){if(e.points.length<2)return``;let t=[],n=e.points[0],r=e.points[1];t.push(Fa(n,r,e.cardinality1));let i=e.points[e.points.length-1],a=e.points[e.points.length-2];return t.push(Fa(i,a,e.cardinality2)),t.join(`
|
|
45
45
|
`)}function Fa(e,t,n){let r=[],i=R.connector+.25,a=e.x-t.x,o=e.y-t.y,s=Math.sqrt(a*a+o*o);if(s===0)return``;let c=a/s,l=o/s,u=-l,f=c,p=e.x-c*4,m=e.y-l*4,h=e.x-c*16,g=e.y-l*16,_=n===`one`||n===`zero-one`,v=n===`many`||n===`zero-many`,y=n===`zero-one`||n===`zero-many`;if(_){r.push(d`<line x1="${p+u*6}" y1="${m+f*6}" `+d`x2="${p-u*6}" y2="${m-f*6}" `+d`stroke="var(--_line)" stroke-width="${i}" />`);let e=p-c*4,t=m-l*4;r.push(d`<line x1="${e+u*6}" y1="${t+f*6}" `+d`x2="${e-u*6}" y2="${t-f*6}" `+d`stroke="var(--_line)" stroke-width="${i}" />`)}if(v){let e=p,t=m;r.push(d`<line x1="${e+u*7}" y1="${t+f*7}" `+d`x2="${h}" y2="${g}" `+d`stroke="var(--_line)" stroke-width="${i}" />`),r.push(d`<line x1="${e}" y1="${t}" `+d`x2="${h}" y2="${g}" `+d`stroke="var(--_line)" stroke-width="${i}" />`),r.push(d`<line x1="${e-u*7}" y1="${t-f*7}" `+d`x2="${h}" y2="${g}" `+d`stroke="var(--_line)" stroke-width="${i}" />`)}if(n===`many`){let t=e.x-c*20,n=e.y-l*20;r.push(d`<line x1="${t+u*6}" y1="${n+f*6}" `+d`x2="${t-u*6}" y2="${n-f*6}" `+d`stroke="var(--_line)" stroke-width="${i}" />`)}if(y){let t=v?20:12,n=e.x-c*t,a=e.y-l*t;r.push(d`<circle cx="${n}" cy="${a}" r="4" `+d`fill="var(--bg)" stroke="var(--_line)" stroke-width="${i}" />`)}return r.join(`
|
|
46
|
-
`)}function Ia(e){if(e.length===0)return{x:0,y:0};if(e.length===1)return e[0];let t=0;for(let n=1;n<e.length;n++){let r=e[n].x-e[n-1].x,i=e[n].y-e[n-1].y;t+=Math.sqrt(r*r+i*i)}if(t===0)return e[0];let n=t/2,r=0;for(let t=1;t<e.length;t++){let i=e[t].x-e[t-1].x,a=e[t].y-e[t-1].y,o=Math.sqrt(i*i+a*a);if(r+o>=n){let s=o>0?(n-r)/o:0;return{x:e[t-1].x+i*s,y:e[t-1].y+a*s}}r+=o}return e[e.length-1]}var La=l,Ra={padding:30,actorGap:140,actorHeight:40,actorPadX:16,headerGap:20,messageRowHeight:40,selfMessageHeight:30,activationWidth:10,blockPadX:10,blockPadTop:40,blockPadBottom:8,blockHeaderExtra:28,dividerExtra:24,noteWidth:60,notePadX:12,notePadY:6,noteGap:10,noteOffsetAfterMessage:8,noteStackGap:4,boxPad:10};function za(e){return e+8}var Ba=14,Va=new Set([`boundary`,`control`,`entity`,`database`]);function Ha(e){return e.type===`actor`||Va.has(e.participantType)}var Ua=4;function Wa(e,t,n){return 14+_(e,t,n).height/2}function Ga(e){return{...Ra,actorHeight:e?.actorHeight??Ra.actorHeight,headerGap:e?.headerGap??Ra.headerGap,messageRowHeight:e?.messageRowHeight??Ra.messageRowHeight,noteOffsetAfterMessage:e?.noteOffsetAfterMessage??Ra.noteOffsetAfterMessage,noteStackGap:e?.noteStackGap??Ra.noteStackGap}}var Ka=16
|
|
47
|
-
`)}function
|
|
46
|
+
`)}function Ia(e){if(e.length===0)return{x:0,y:0};if(e.length===1)return e[0];let t=0;for(let n=1;n<e.length;n++){let r=e[n].x-e[n-1].x,i=e[n].y-e[n-1].y;t+=Math.sqrt(r*r+i*i)}if(t===0)return e[0];let n=t/2,r=0;for(let t=1;t<e.length;t++){let i=e[t].x-e[t-1].x,a=e[t].y-e[t-1].y,o=Math.sqrt(i*i+a*a);if(r+o>=n){let s=o>0?(n-r)/o:0;return{x:e[t-1].x+i*s,y:e[t-1].y+a*s}}r+=o}return e[e.length-1]}var La=l,Ra={padding:30,actorGap:140,actorHeight:40,actorPadX:16,headerGap:20,messageRowHeight:40,selfMessageHeight:30,activationWidth:10,blockPadX:10,blockPadTop:40,blockPadBottom:8,blockHeaderExtra:28,dividerExtra:24,noteWidth:60,notePadX:12,notePadY:6,noteGap:10,noteOffsetAfterMessage:8,noteStackGap:4,boxPad:10};function za(e){return e+8}var Ba=14,Va=new Set([`boundary`,`control`,`entity`,`database`]);function Ha(e){return e.type===`actor`||Va.has(e.participantType)}var Ua=4;function Wa(e,t,n){return 14+_(e,t,n).height/2}function Ga(e){return{...Ra,actorHeight:e?.actorHeight??Ra.actorHeight,headerGap:e?.headerGap??Ra.headerGap,messageRowHeight:e?.messageRowHeight??Ra.messageRowHeight,noteOffsetAfterMessage:e?.noteOffsetAfterMessage??Ra.noteOffsetAfterMessage,noteStackGap:e?.noteStackGap??Ra.noteStackGap}}var Ka=16;function qa(e,t,n){let r=new Map(e.actors.map((e,t)=>[e.id,t]));for(let i of e.messages){if(!i.label)continue;let e=r.get(i.from),a=r.get(i.to),o=_(i.label,n,L.edgeLabel).width,s=e===a?[[e-1,e],[e,e+1]]:[[Math.min(e,a),Math.max(e,a)]],c=e===a?o/2+Ka:o+32;for(let[e,n]of s){if(e<0||n>=t.length)continue;let r=0;for(let i=e+1;i<=n;i++)r+=t[i];if(r>=c)continue;let i=(c-r)/(n-e);for(let r=e+1;r<=n;r++)t[r]+=i}}}function Ja(e,t={}){if(e.actors.length===0)return{width:0,height:0,actors:[],lifelines:[],messages:[],activations:[],blocks:[],notes:[],boxes:[]};let n=Ga(t.sequence),r=qe(t.fontSizes),i=e.actors.map(e=>{let t=I(e.label,r.nodeLabel,L.nodeLabel);return Math.max(t+n.actorPadX*2,80)}),a=i.map((e,t)=>t===0?0:Math.max(n.actorGap,(i[t-1]+e)/2+40));qa(e,a,r.edgeLabel);let o=[],s=n.padding+i[0]/2;for(let t=0;t<e.actors.length;t++)s+=a[t],o.push(s);let c=new Map;for(let t=0;t<e.actors.length;t++)c.set(e.actors[t].id,t);let l=e.boxes.filter(e=>e.actorIds.length>0),u=l.some(e=>e.label!==``),d=l.length===0?0:n.boxPad+(u?za(r.edgeLabel):0),f=n.padding+d,p=e.actors.map((e,t)=>({id:e.id,label:e.label,type:e.type,...e.participantType!==void 0&&{participantType:e.participantType},x:o[t],y:f,width:i[t],height:n.actorHeight})),m=l.map(e=>{let t=e.actorIds.map(e=>c.get(e)??0),r=Math.min(...t),a=Math.max(...t),s=o[r]-i[r]/2-n.boxPad,l=o[a]+i[a]/2+n.boxPad,u={label:e.label,x:s,y:n.padding,width:l-s,height:0};return e.color!==void 0&&(u.color=e.color),u}),h=e.actors.map(e=>Ha(e)?Wa(e.label,r.nodeLabel,L.nodeLabel):0),g=Math.max(0,...e.actors.map((e,t)=>e.createdAt===void 0?h[t]:0)),_=r.edgeLabel+12,v=f+n.actorHeight+Math.max(n.headerGap,g>0?g+Ua+_:0),y=[],b=new Map;for(let t of e.blocks){let e=b.get(t.startIndex)??0;b.set(t.startIndex,Math.max(e,n.blockHeaderExtra));for(let e of t.dividers){let t=b.get(e.index)??0;b.set(e.index,Math.max(t,n.dividerExtra))}}let x=new Map;for(let t of e.notes){let e=x.get(t.afterIndex)??[];e.push(t),x.set(t.afterIndex,e)}let S=[],C=x.get(-1);if(C&&C.length>0){let e=v;for(let t of C){let a=Math.max(n.noteWidth,I(t.text,r.edgeLabel,L.edgeLabel)+n.notePadX*2),s=r.edgeLabel+n.notePadY*2,l=c.get(t.actorIds[0]??``)??0,u;if(t.position===`left`)u=o[l]-i[l]/2-a-n.noteGap;else if(t.position===`right`)u=o[l]+i[l]/2+n.noteGap;else if(t.actorIds.length>1){let e=c.get(t.actorIds[t.actorIds.length-1]??``)??l;u=(o[l]+o[e])/2-a/2}else u=o[l]-a/2;S.push({text:t.text,x:u,y:e,width:a,height:s,position:t.position,actors:t.actorIds}),e+=s+n.noteStackGap}v=Math.max(v,e+n.messageRowHeight/2)}let w=new Map,T=[],E=n.activationWidth/2;function D(e,t){let n=w.get(e)??[];w.set(e,n);let r=n.length;n.push({startY:t,depth:r})}function O(e,t){let r=w.get(e);if(!r||r.length===0)return;let{startY:i,depth:a}=r.pop(),s=c.get(e)??0,l=a*E;T.push({actorId:e,x:o[s]-n.activationWidth/2+l,topY:i,bottomY:t,width:n.activationWidth,depth:a})}let k=new Map;for(let t of e.activations){let e=k.get(t.afterIndex)??[];e.push(t),k.set(t.afterIndex,e)}function A(e,t){for(let n of k.get(e)??[])n.kind===`start`?D(n.actorId,t):O(n.actorId,t)}A(-1,v);for(let t=0;t<e.messages.length;t++){let a=e.messages[t],s=c.get(a.from)??0,l=c.get(a.to)??0,u=a.from===a.to,d=b.get(t)??0;d>0&&(v+=d);let f=o[s],p=o[l],m=!u&&e.actors[l].createdAt===t;if(m){let e=i[l]/2;p+=f<p?-e:e}y.push({from:a.from,to:a.to,label:a.label,lineStyle:a.lineStyle,arrowHead:a.arrowHead,x1:f,x2:p,y:v,isSelf:u,bidirectional:a.bidirectional??!1,seqNumber:a.seqNumber}),a.activate&&D(a.to,v),a.deactivate&&O(a.from,v),A(t,v),v+=u?n.selfMessageHeight+n.messageRowHeight:n.messageRowHeight,m&&(v+=n.actorHeight/2);let h=x.get(t);if(h&&h.length>0){let e=u?n.selfMessageHeight:0,a=y[t].y+e+n.noteOffsetAfterMessage;for(let e of h){let t=Math.max(n.noteWidth,I(e.text,r.edgeLabel,L.edgeLabel)+n.notePadX*2),s=r.edgeLabel+n.notePadY*2,l=c.get(e.actorIds[0]??``)??0,u;if(e.position===`left`)u=o[l]-i[l]/2-t-n.noteGap;else if(e.position===`right`)u=o[l]+i[l]/2+n.noteGap;else if(e.actorIds.length>1){let n=c.get(e.actorIds[e.actorIds.length-1]??``)??l;u=(o[l]+o[n])/2-t/2}else u=o[l]-t/2;S.push({text:e.text,x:u,y:a,width:t,height:s,position:e.position,actors:e.actorIds}),a+=s+n.noteStackGap}v=Math.max(v,a+n.messageRowHeight/2)}}for(let[e,t]of w)for(let{startY:r,depth:i}of t){let t=c.get(e)??0,a=i*E;T.push({actorId:e,x:o[t]-n.activationWidth/2+a,topY:r,bottomY:v-n.messageRowHeight/2,width:n.activationWidth,depth:i})}T.sort((e,t)=>e.depth-t.depth);let ee=e.blocks.map(t=>{let a=y[t.startIndex],s=y[t.endIndex],l=(a?.y??v)-n.blockPadTop,u=(s?.y??v)+n.blockPadBottom+12,d=new Set;for(let n=t.startIndex;n<=t.endIndex;n++){let t=e.messages[n];t&&(d.add(c.get(t.from)??0),d.add(c.get(t.to)??0))}if(d.size===0)for(let t=0;t<e.actors.length;t++)d.add(t);let f=Math.min(...d),p=Math.max(...d),m=o[f]-i[f]/2-n.blockPadX,h=o[p]+i[p]/2+n.blockPadX,g=t.dividers.map(e=>{let t=y[e.index],n=t?.y??v,i=28;if(e.label&&t?.label){let n=I(`[${e.label}]`,r.edgeLabel,L.edgeLabel),a=m+8,o=a+n,s=I(t.label,r.edgeLabel,L.edgeLabel),c=(t.x1+t.x2)/2-s/2,l=c+s;o>c&&a<l&&(i=36)}return{y:n-i,label:e.label}});return{type:t.type,label:t.label,...t.color===void 0?{}:{color:t.color},x:m,y:l,width:h-m,height:u-l,dividers:g}}),j=S,te=v+n.padding,M=n.padding,N=0;for(let e of p)M=Math.min(M,e.x-e.width/2),N=Math.max(N,e.x+e.width/2);for(let e of ee)M=Math.min(M,e.x),N=Math.max(N,e.x+e.width);for(let e of j)M=Math.min(M,e.x),N=Math.max(N,e.x+e.width);for(let e of m)M=Math.min(M,e.x),N=Math.max(N,e.x+e.width);for(let e of y)if(e.isSelf&&(N=Math.max(N,e.x1+30+8),e.label)){let t=I(e.label,r.edgeLabel,L.edgeLabel)/2+8;N=Math.max(N,e.x1+t),M=Math.min(M,e.x1-t)}let P=M<n.padding?n.padding-M:0;if(P>0){for(let e of p)e.x+=P;for(let e of y)e.x1+=P,e.x2+=P;for(let e of T)e.x+=P;for(let e of ee)e.x+=P;for(let e of j)e.x+=P;for(let e of m)e.x+=P;for(let e=0;e<o.length;e++)o[e]+=P}for(let t=0;t<e.actors.length;t++){let r=e.actors[t].createdAt;r!==void 0&&(p[t].y=(y[r]?.y??v)-n.actorHeight/2)}let ne=e.actors.map((e,t)=>{let r=e.destroyedAt,i={actorId:e.id,x:o[t],topY:p[t].y+n.actorHeight+(h[t]>0?h[t]+Ua:0),bottomY:r===void 0?te-n.padding:y[r]?.y??v};return r!==void 0&&(i.destroyed=!0),i});for(let e of m)e.height=te-n.padding+n.boxPad-e.y;let F=N+P+n.padding;return{width:Math.max(F,200),height:Math.max(te,100),actors:p,lifelines:ne,messages:y,activations:T,blocks:ee,notes:j,boxes:m}}function Ya(e,t,r=`Inter`,i=!1,a=Ke,o,s,c,l={}){let u=[];u.push(wi(M(e.width,e.height,t,i,s,c,void 0,l.styleAttribute,l.description),o)),u.push(n(r,!1,l.nonce,l.bodyFont)),u.push(`<defs>`),u.push(Xa()),u.push(`</defs>`);for(let t of e.boxes)u.push(ho(t,a));for(let t of e.blocks)u.push(_o(t,a));let d=oo(e,a);for(let t of e.lifelines)u.push(co(t,d));for(let t of e.activations)u.push(uo(t));for(let t of e.messages)u.push(fo(t,a));for(let t of e.notes)u.push(vo(t,a));for(let t of e.actors)u.push(Qa(t,a));return u.push(`</svg>`),u.join(`
|
|
47
|
+
`)}function Xa(){let e=Ze.width,t=Ze.height;return d` <marker id="seq-arrow" markerWidth="${e}" markerHeight="${t}" refX="${e}" refY="${t/2}" orient="auto-start-reverse">`+d`\n <polygon points="0 0, ${e} ${t/2}, 0 ${t}" fill="var(--_arrow)" />`+`
|
|
48
48
|
</marker>`+d`\n <marker id="seq-arrow-open" markerWidth="${e}" markerHeight="${t}" refX="${e}" refY="${t/2}" orient="auto-start-reverse">`+d`\n <polyline points="0 0, ${e} ${t/2}, 0 ${t}" fill="none" stroke="var(--_arrow)" stroke-width="1" />`+`
|
|
49
|
-
</marker>`}var
|
|
50
|
-
</g>`),f.push(` `+C(s,r,i+o+14,t.nodeLabel,p))}else if(Ha(e)){let e=o/24*.9,n=R.outerBox/e,a=d`fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="${n}"`,c=d`fill="none" stroke="var(--_node-stroke)" stroke-width="${n}"`,l=
|
|
51
|
-
`)}var
|
|
52
|
-
`)[0]??``,t.edgeLabel,L.groupHeader)+16;n.push({x0:r.x,x1:r.x+e,y0:r.y,y1:r.y+
|
|
53
|
-
`);if(!e.destroyed)return n;let{x:r,bottomY:i}=e,a=
|
|
54
|
-
`)}function
|
|
55
|
-
`)}function
|
|
49
|
+
</marker>`}var Za={boundary:(e,t)=>`\n <circle cx="15" cy="12" r="8" ${e} />\n <path d="M1 6V18M1 12H7" ${t} />`,control:(e,t)=>`\n <circle cx="12" cy="13" r="9" ${e} />\n <path d="M13 1L10 4L13 7" ${t} />`,entity:(e,t)=>`\n <circle cx="12" cy="11" r="9" ${e} />\n <path d="M3 22H21" ${t} />`,database:(e,t)=>`\n <path d="M2 5A10 3.5 0 0 1 22 5V19A10 3.5 0 0 1 2 19Z" ${e} />\n <path d="M2 5A10 3.5 0 0 0 22 5" ${t} />`};function Qa(e,t){let{id:n,x:r,y:i,width:a,height:o,label:s,type:l,participantType:u}=e,f=[],p=d`font-size="${t.nodeLabel}" text-anchor="middle" font-weight="${L.nodeLabel}" fill="var(--_text)"`;if(f.push(d`<g class="actor" data-id="${c(n)}" data-label="${c(s)}" data-type="${l}">`),l===`actor`){let e=o/24*.9,n=r-12*e,a=i+(o-24*e)/2,c=R.outerBox/e,l=`var(--_line)`;f.push(d` <g transform="translate(${n},${a}) scale(${e})">`+d`\n <path d="M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z" fill="none" stroke="${l}" stroke-width="${c}" />`+d`\n <path d="M15 10C15 11.6569 13.6569 13 12 13C10.3431 13 9 11.6569 9 10C9 8.34315 10.3431 7 12 7C13.6569 7 15 8.34315 15 10Z" fill="none" stroke="${l}" stroke-width="${c}" />`+d`\n <path d="M5.62842 18.3563C7.08963 17.0398 9.39997 16 12 16C14.6 16 16.9104 17.0398 18.3716 18.3563" fill="none" stroke="${l}" stroke-width="${c}" />`+`
|
|
50
|
+
</g>`),f.push(` `+C(s,r,i+o+14,t.nodeLabel,p))}else if(Ha(e)){let e=o/24*.9,n=R.outerBox/e,a=d`fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="${n}"`,c=d`fill="none" stroke="var(--_node-stroke)" stroke-width="${n}"`,l=Za[u](a,c);f.push(d` <g transform="translate(${r-12*e},${i+(o-24*e)/2}) scale(${e})">${l}\n </g>`),f.push(` `+C(s,r,i+o+14,t.nodeLabel,p))}else{let e=r-a/2,n=d`fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="${R.outerBox}"`,c=r,l=i+o/2;if(u===`queue`){let t=o/2,r=e+8,s=e+a-8;f.push(d` <path d="M${r},${i}H${s}A${8},${t} 0 0 1 ${s},${i+o}H${r}A${8},${t} 0 0 1 ${r},${i}Z" ${n} />`,d` <path d="M${s},${i}A${8},${t} 0 0 0 ${s},${i+o}" fill="none" stroke="var(--_node-stroke)" stroke-width="${R.outerBox}" />`)}else u===`collections`?(f.push(d` <rect x="${e+4}" y="${i}" width="${a-4}" height="${o-4}" rx="4" ry="4" ${n} />`,d` <rect x="${e}" y="${i+4}" width="${a-4}" height="${o-4}" rx="4" ry="4" ${n} />`),c=r-2,l=i+2+(o-4)/2):f.push(d` <rect x="${e}" y="${i}" width="${a}" height="${o}" rx="4" ry="4" ${n} />`);f.push(` `+C(s,c,l,t.nodeLabel,p))}return f.push(`</g>`),f.join(`
|
|
51
|
+
`)}var $a=30,eo=20,to=10,no=18,ro=3,io=2,ao=3;function oo(e,t){let n=[],r=e=>_(e,t.edgeLabel,L.edgeLabel),i=(e,t,i)=>{let a=r(e);n.push({x0:t-a.width/2,x1:t+a.width/2,y0:i-a.height/2,y1:i+a.height/2})},a=(e,t,i)=>{let a=r(e);n.push({x0:t,x1:t+a.width,y0:i-a.height/2,y1:i+a.height/2})};for(let t of e.messages)t.label&&i(t.label,(t.x1+t.x2)/2,t.y-to);for(let r of e.blocks){if(go(r))continue;let e=I(`${r.type}${r.label?` [${r.label}]`:``}`.split(`
|
|
52
|
+
`)[0]??``,t.edgeLabel,L.groupHeader)+16;n.push({x0:r.x,x1:r.x+e,y0:r.y,y1:r.y+no});for(let e of r.dividers)e.label&&a(`[${e.label}]`,r.x+8,e.y+14)}return n}function so(e,t){let n=t.filter(t=>e.x>t.x0-ro&&e.x<t.x1+ro&&t.y1+io>e.topY&&t.y0-io<e.bottomY).map(e=>[e.y0-io,e.y1+io]).sort((e,t)=>e[0]-t[0]),r=[],i=e.topY;for(let[e,t]of n)e-i>=ao&&r.push([i,e]),i=Math.max(i,t);return e.bottomY-i>=ao&&r.push([i,e.bottomY]),r.length>0?r:[[e.topY,e.bottomY]]}function co(e,t){let n=so(e,t).map(([t,n])=>d`<line class="lifeline" data-actor="${c(e.actorId)}" `+d`x1="${e.x}" y1="${t}" x2="${e.x}" y2="${n}" `+`stroke="var(--_line)" stroke-width="0.75" stroke-dasharray="6 4" />`).join(`
|
|
53
|
+
`);if(!e.destroyed)return n;let{x:r,bottomY:i}=e,a=lo;return n+d`\n<path class="destroy" data-actor="${c(e.actorId)}" `+d`d="M${r-a} ${i-a} L${r+a} ${i+a} M${r+a} ${i-a} L${r-a} ${i+a}" `+d`fill="none" stroke="var(--_line)" stroke-width="${R.outerBox}" stroke-linecap="round" />`}var lo=8;function uo(e){return d`<rect class="activation" data-actor="${c(e.actorId)}" `+d`x="${e.x}" y="${e.topY}" width="${e.width}" height="${e.bottomY-e.topY}" `+d`fill="var(--_node-fill)" stroke="var(--_node-stroke)" stroke-width="${R.innerBox}" />`}function fo(e,t){let n=[],r=e.lineStyle===`dashed`?` stroke-dasharray="6 4"`:``,i=e.arrowHead===`filled`?`seq-arrow`:`seq-arrow-open`,a=e.bidirectional?d` marker-start="url(#${i})"`:``;if(n.push(d`<g class="message" data-from="${c(e.from)}" data-to="${c(e.to)}" `+d`data-label="${c(e.label)}" data-line-style="${e.lineStyle}" `+d`data-arrow-head="${e.arrowHead}" data-self="${e.isSelf}" data-bidirectional="${e.bidirectional}">`),e.isSelf){let t=$a,o=eo;n.push(d` <polyline points="${e.x1},${e.y} ${e.x1+t},${e.y} ${e.x1+t},${e.y+o} ${e.x2},${e.y+o}" `+d`fill="none" stroke="var(--_line)" stroke-width="${R.connector}"${r} marker-end="url(#${i})"${a} />`)}else n.push(d` <line x1="${e.x1}" y1="${e.y}" x2="${e.x2}" y2="${e.y}" `+d`stroke="var(--_line)" stroke-width="${R.connector}"${r} marker-end="url(#${i})"${a} />`);return n.push(` `+C(e.label,(e.x1+e.x2)/2,e.y-to,t.edgeLabel,d`font-size="${t.edgeLabel}" text-anchor="middle" font-weight="${L.edgeLabel}" fill="var(--_text-muted)"`)),e.seqNumber!==void 0&&n.push(` `+po(e,t)),n.push(`</g>`),n.join(`
|
|
54
|
+
`)}function po(e,t){let n=Math.max(t.edgeLabel-2,8),r=e.bidirectional?e.x1+Math.sign(e.x2-e.x1)*(8+Ze.width):e.x1;return`<g class="seq-number">`+d`<circle cx="${r}" cy="${e.y}" r="${8}" fill="var(--bg)" stroke="var(--_arrow)" stroke-width="${R.innerBox}" />`+C(String(e.seqNumber),r,e.y,n,d`font-size="${n}" text-anchor="middle" font-weight="${L.edgeLabel}" fill="var(--_arrow)"`)+`</g>`}var mo=35;function ho(e,t){let n=e.label?d` data-label="${c(e.label)}"`:``,r=e.color===void 0?``:d` data-color="${c(e.color)}"`,i=e.color===void 0?`none`:d`color-mix(in srgb, ${c(e.color)} ${mo}%, var(--bg))`,a=[d`<g class="participant-box"${n}${r}>`,d` <rect x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" rx="4" ry="4" `+d`fill="${i}" stroke="var(--_node-stroke)" stroke-width="${R.innerBox}" />`];return e.label&&a.push(` `+C(e.label,e.x+e.width/2,e.y+za(t.edgeLabel)/2,t.edgeLabel,d`font-size="${t.edgeLabel}" text-anchor="middle" font-weight="${L.groupHeader}" fill="var(--_text-sec)"`)),a.push(`</g>`),a.join(`
|
|
55
|
+
`)}function go(e){return e.type===`rect`&&e.color!==void 0}function _o(e,t){let n=[];if(go(e))return[d`<g class="block" data-type="rect" data-color="${c(e.color)}">`,d` <rect x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" `+d`fill="${c(e.color)}" />`,`</g>`].join(`
|
|
56
56
|
`);let r=e.label?d` data-label="${c(e.label)}"`:``;n.push(d`<g class="block" data-type="${c(e.type)}"${r}>`),n.push(d` <rect x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" `+d`rx="0" ry="0" fill="none" stroke="var(--_node-stroke)" stroke-width="${R.outerBox}" />`);let i=d`${e.type}${e.label?d` [${e.label}]`:``}`,a=i.split(`
|
|
57
|
-
`)[0],o=I(a,t.edgeLabel,L.groupHeader)+16,s=
|
|
58
|
-
`)}function
|
|
59
|
-
</g>`}var K={plotWidth:600,plotHeight:340,padding:22,titleFontSize:18,titleFontWeight:600,titleHeight:42,axisLabelFontSize:14,axisLabelFontWeight:400,axisTitleFontSize:15,axisTitleFontWeight:500,xLabelHeight:38,yLabelWidth:58,yLabelGap:18,axisTitlePad:30,tickLength:4,barPadRatio:.2,barGroupGap:0,maxBarWidth:40,legendFontSize:14,legendFontWeight:400,legendHeight:28,legendSwatchW:14,legendSwatchH:14,legendGap:6,legendItemGap:16};function xo(e,t={}){return e.horizontal?Co(e):So(e)}function So(e){let t=!!e.title,n=!!e.xAxis.title,r=!!e.yAxis.title,i=e.series.length>1,a=e.yAxis.range;if(!a)throw Error(`XY chart: y-axis range was not set by the parser`);let o=x(a.min,a.max),s=jo(o),c=Math.max(...s.map(e=>I(e,K.axisLabelFontSize,K.axisLabelFontWeight)),K.yLabelWidth),l=K.padding+(t?K.titleHeight:0)+(i?K.legendHeight:0),u=K.padding+K.xLabelHeight+(n?K.axisTitlePad:0),d=K.padding+c+K.yLabelGap+(r?K.axisTitlePad:0),f=K.padding,p=K.plotWidth,m=K.plotHeight,h=d+p+f,g=l+m+u,_={x:d,y:l,width:p,height:m},v=wo(e),y=e=>d+(e+.5)*(p/v),b=p/v,S=e=>{let t=(e-a.min)/(a.max-a.min||1);return l+m-t*m},C=Oo(e,y,l+m,b),w=o.map((e,t)=>({label:s[t],x:d,y:S(e),tx:d-K.tickLength,ty:S(e),labelX:d-K.yLabelGap,labelY:S(e),textAnchor:`end`})),T=o.map(e=>({x1:d,y1:S(e),x2:d+p,y2:S(e)})),E=To(e,v),D=e.series.map((e,t)=>t),O=ko(e,y,S,b,a.min,E,D),k=Ao(e,y,S,E,D),A=K.padding+(t?K.titleHeight:0)+K.legendHeight/2,ee=i?No(e,h/2,A,D):[],j={x1:d,y1:l+m,x2:d+p,y2:l+m},te={x1:d,y1:l,x2:d,y2:l+m},M={ticks:C,line:j,...e.xAxis.title?{title:{text:e.xAxis.title,x:d+p/2,y:g-K.padding}}:{}},N={ticks:w,line:te,...e.yAxis.title?{title:{text:e.yAxis.title,x:K.padding+4,y:l+m/2,rotate:-90}}:{}};return{width:h,height:g,title:e.title?{text:e.title,x:h/2,y:K.padding+K.titleFontSize}:void 0,xAxis:M,yAxis:N,plotArea:_,bars:O,lines:k,gridLines:T,legend:ee}}function Co(e){let t=!!e.title,n=!!e.xAxis.title,r=!!e.yAxis.title,i=e.series.length>1,a=e.yAxis.range;if(!a)throw Error(`XY chart: y-axis range was not set by the parser`);let o=x(a.min,a.max),s=jo(o),c=wo(e),l=To(e,c),u=Math.max(...l.map(e=>I(e,K.axisLabelFontSize,K.axisLabelFontWeight)),40),d=K.padding+(t?K.titleHeight:0)+(i?K.legendHeight:0),f=K.padding+K.xLabelHeight+(r?K.axisTitlePad:0),p=K.padding+u+K.yLabelGap+(n?K.axisTitlePad:0),m=Math.max(K.padding,I(s[s.length-1],K.axisLabelFontSize,K.axisLabelFontWeight)/2+4),h=K.plotWidth,g=K.plotHeight,_=p+h+m,v=d+g+f,y={x:p,y:d,width:h,height:g},b=e=>{let t=(e-a.min)/(a.max-a.min||1);return p+t*h},S=g/c,C=e=>d+(e+.5)*S,w=o.map((e,t)=>({label:s[t],x:b(e),y:d+g,tx:b(e),ty:d+g+K.tickLength,labelX:b(e),labelY:d+g+18,textAnchor:`middle`})),T=l.map((e,t)=>({label:e,x:p,y:C(t),tx:p-K.tickLength,ty:C(t),labelX:p-K.yLabelGap,labelY:C(t),textAnchor:`end`})),E=o.map(e=>({x1:b(e),y1:d,x2:b(e),y2:d+g})),D=e.series.map((e,t)=>t),O=e.series.filter(e=>e.type===`bar`).length,k=[];if(O>0){let t=S*(1-K.barPadRatio),n=O>1?(t-(O-1)*K.barGroupGap)/O:t,r=Math.min(n,K.maxBarWidth),i=O>1?r*O+K.barGroupGap*(O-1):r,o=0,s=0;for(let t of e.series){if(t.type!==`bar`){s++;continue}for(let e=0;e<t.data.length;e++){let n=C(e)-i/2+o*(r+K.barGroupGap),c=b(Math.max(t.data[e],a.min)),u=b(Math.max(0,a.min));k.push({x:Math.min(u,c),y:n,width:Math.abs(c-u),height:r,value:t.data[e],label:l[e],seriesIndex:o,colorIndex:D[s]})}o++,s++}}let A=[],ee=0,j=0;for(let t of e.series){if(t.type!==`line`){j++;continue}let e=t.data.map((e,t)=>({x:b(e),y:C(t),value:e,label:l[t]}));A.push({points:e,seriesIndex:ee,colorIndex:D[j]}),ee++,j++}let te={x1:p,y1:d+g,x2:p+h,y2:d+g},M={x1:p,y1:d,x2:p,y2:d+g},N={ticks:w,line:te,...e.yAxis.title?{title:{text:e.yAxis.title,x:p+h/2,y:v-K.padding}}:{}},P={ticks:T,line:M,...e.xAxis.title?{title:{text:e.xAxis.title,x:K.padding+4,y:d+g/2,rotate:-90}}:{}},ne=e.title?{text:e.title,x:_/2,y:K.padding+K.titleFontSize}:void 0,F=K.padding+(t?K.titleHeight:0)+K.legendHeight/2;return{width:_,height:v,horizontal:!0,title:ne,xAxis:N,yAxis:P,plotArea:y,bars:k,lines:A,gridLines:E,legend:i?No(e,_/2,F,D):[]}}function wo(e){if(e.xAxis.categories)return e.xAxis.categories.length;for(let t of e.series)if(t.data.length>0)return t.data.length;return 1}function To(e,t){if(e.xAxis.categories)return e.xAxis.categories;if(e.xAxis.range){let{min:n,max:r}=e.xAxis.range,i=t>1?(r-n)/(t-1):0;return Array.from({length:t},(e,t)=>Mo(n+i*t))}return Array.from({length:t},(e,t)=>String(t+1))}var Eo=8;function Do(e,t){let n=e.map(e=>I(e,K.axisLabelFontSize,K.axisLabelFontWeight));for(let r=1;r<e.length;r++){let i=!0;for(let a=0;a+r<e.length;a+=r)if(r*t-(n[a]+n[a+r])/2<Eo){i=!1;break}if(i)return r}return Math.max(1,e.length)}function Oo(e,t,n,r){let i=To(e,wo(e)),a=Do(i,r);return i.map((e,r)=>({label:r%a===0?e:``,x:t(r),y:n,tx:t(r),ty:n+K.tickLength,labelX:t(r),labelY:n+18,textAnchor:`middle`}))}function ko(e,t,n,r,i,a,o){let s=e.series.filter(e=>e.type===`bar`).length;if(s===0)return[];let c=r*(1-K.barPadRatio),l=s>1?(c-(s-1)*K.barGroupGap)/s:c,u=Math.min(l,K.maxBarWidth),d=s>1?u*s+K.barGroupGap*(s-1):u,f=[],p=0,m=0;for(let r of e.series){if(r.type!==`bar`){m++;continue}for(let e=0;e<r.data.length;e++){let s=t(e)-d/2+p*(u+K.barGroupGap),c=n(r.data[e]),l=n(Math.max(0,i));f.push({x:s,y:Math.min(c,l),width:u,height:Math.abs(l-c),value:r.data[e],label:a[e],seriesIndex:p,colorIndex:o[m]})}p++,m++}return f}function Ao(e,t,n,r,i){let a=[],o=0,s=0;for(let c of e.series){if(c.type!==`line`){s++;continue}let e=c.data.map((e,i)=>({x:t(i),y:n(e),value:e,label:r[i]}));a.push({points:e,seriesIndex:o,colorIndex:i[s]}),o++,s++}return a}function jo(e){let t=e.length>1?Math.abs(e[1]-e[0]):0,n=t>0&&t<1?Math.ceil(-Math.log10(t)-1e-9):0;return e.map(e=>String(Number.isInteger(e)&&n===0?e:Number(e.toFixed(n))))}function Mo(e){return Number.isInteger(e)?String(e):e.toFixed(+(Math.abs(e)<10))}function No(e,t,n,r){let i=[],a=0,o=0;for(let t=0;t<e.series.length;t++){let s=e.series[t],c=s.type===`bar`?`Bar ${a+1}`:`Line ${o+1}`;i.push({label:c,x:0,y:n,type:s.type,seriesIndex:s.type===`bar`?a:o,colorIndex:r[t]}),s.type===`bar`?a++:o++}let s=i.map(e=>{let t=I(e.label,K.legendFontSize,K.legendFontWeight);return K.legendSwatchW+K.legendGap+t}),c=t-(s.reduce((e,t)=>e+t,0)+(i.length-1)*K.legendItemGap)/2;for(let e=0;e<i.length;e++)i[e].x=c,c+=s[e]+K.legendItemGap;return i}var q={titleSize:18,titleWeight:600,axisTitleSize:15,axisTitleWeight:500,labelSize:14,labelWeight:400,legendSize:14,legendWeight:400,dotRadius:5,lineWidth:2.5,barRadius:8},J={fontSize:15,fontWeight:500,height:32,padX:14,offsetY:12,rx:8,minY:4,pointerSize:6};function Po(e,t,r=`Inter`,i=!1,a=!1,o,s,c,l={}){let u=[],d=Math.max(0,...e.bars.map(e=>e.colorIndex),...e.lines.map(e=>e.colorIndex)),f=wi(M(e.width,e.height,t,i,s,c,void 0,l.styleAttribute,l.description).replace(`<svg `,`<svg data-xychart-colors="${d}" `),o);u.push(f),u.push(n(r,!1,l.nonce,l.bodyFont));let p=Math.max(...e.lines.map(e=>e.points.length),0),m=p>0&&p<=12,{style:h,defs:g}=Fo(e,a,m,t.accent,t.bg,l.nonce);u.push(h),g&&u.push(g);let{plotArea:_}=e,v=e.xAxis.ticks.map(e=>e.x),y=e.horizontal?e.yAxis.ticks.map(e=>e.y):e.gridLines.map(e=>e.y1),b=v.length>1?Math.abs(v[1]-v[0]):_.width/6,x=y.length>1?Math.abs(y[1]-y[0]):_.height/6,S=b/Math.max(1,Math.round(b/20)),C=x/Math.max(1,Math.round(x/20)),w=v[0]??_.x,T=y[0]??_.y,E=w-Math.ceil((w-_.x)/S)*S,D=T-Math.ceil((T-_.y)/C)*C;for(let e=D;e<=_.y+_.height+.5;e+=C)for(let t=E;t<=_.x+_.width+.5;t+=S)u.push(`<circle cx="${Y(t)}" cy="${Y(e)}" r="1.5" class="xychart-grid"/>`);let O=[];for(let t of e.bars){let n=` data-value="${t.value}"${t.label?` data-label="${X(t.label)}"`:``}`,r=e.horizontal?Lo(t.x,t.y,t.width,t.height,q.barRadius):Io(t.x,t.y,t.width,t.height,q.barRadius);if(u.push(`<path d="${r}" class="xychart-bar xychart-color-${t.colorIndex}"${n}/>`),a){let e=Ho(t.value),n=t.label?`${t.label}: ${e}`:e,r=Vo(t.x+t.width/2,t.y,e);O.push(`<g class="xychart-bar-group"><rect x="${Y(t.x)}" y="${Y(t.y)}" width="${Y(t.width)}" height="${Y(t.height)}" fill="transparent"/><title>${X(n)}</title>`+r+`</g>`)}}for(let t of e.lines){if(t.points.length===0)continue;let n=e.horizontal?Ro(t.points):zo(t.points);u.push(`<path d="${n}" class="xychart-line-shadow xychart-color-${t.colorIndex}" transform="translate(0,2)"/>`),u.push(`<path d="${n}" class="xychart-line xychart-color-${t.colorIndex}"/>`)}let k=[];if(a||m){let t=new Map;for(let n of e.legend)n.type===`line`&&t.set(n.seriesIndex,n.label);let n=new Map;for(let t of e.lines)for(let e of t.points){let r=Y(e.x),i=n.get(r)??[];n.set(r,i),i.push({x:e.x,y:e.y,value:e.value,label:e.label,seriesIndex:t.seriesIndex,colorIndex:t.colorIndex})}for(let e of n.values()){let n=e[0].x,r=e[0].label||``;if(a&&e.length>1){let i=Math.min(...e.map(e=>e.y)),a=Math.max(...e.map(e=>e.y)),o=q.dotRadius*3,s=`<rect x="${Y(n-o)}" y="${Y(i-o)}" width="${Y(o*2)}" height="${Y(a-i+o*2)}" fill="transparent" class="xychart-hit"/>`,c=e.map(e=>({text:Ho(e.value),legendLabel:t.get(e.seriesIndex)||`Line ${e.seriesIndex+1}`})),l=Bo(n,i-q.dotRadius,r,c),u=c.map(e=>e.text),d=r?`${r}: ${u.join(` · `)}`:u.join(` · `),f=`<g class="xychart-dot-group">${s}`;for(let t of e){let e=` data-value="${t.value}"${t.label?` data-label="${X(t.label)}"`:``}`;f+=`<circle cx="${Y(t.x)}" cy="${Y(t.y)}" r="${q.dotRadius}" class="xychart-dot xychart-color-${t.colorIndex}"${e}/>`}f+=`<title>${X(d)}</title>${l}</g>`,k.push(f)}else if(a){let t=e[0],r=` data-value="${t.value}"${t.label?` data-label="${X(t.label)}"`:``}`,i=Ho(t.value),a=t.label?`${t.label}: ${i}`:i,o=Vo(n,t.y-q.dotRadius,i),s=m?`<circle cx="${Y(n)}" cy="${Y(t.y)}" r="${q.dotRadius*3}" fill="transparent" class="xychart-hit"/>`:``;k.push(`<g class="xychart-dot-group">${s}<circle cx="${Y(t.x)}" cy="${Y(t.y)}" r="${q.dotRadius}" class="xychart-dot xychart-color-${t.colorIndex}"${r}/><title>${X(a)}</title>${o}</g>`)}else for(let t of e){let e=` data-value="${t.value}"${t.label?` data-label="${X(t.label)}"`:``}`;u.push(`<circle cx="${Y(t.x)}" cy="${Y(t.y)}" r="${q.dotRadius}" class="xychart-dot xychart-color-${t.colorIndex}"${e}/>`)}}}for(let t of e.xAxis.ticks)t.label!==``&&u.push(`<text x="${t.labelX}" y="${t.labelY}" text-anchor="${t.textAnchor}" font-size="${q.labelSize}" font-weight="${q.labelWeight}" dy="${z}" class="xychart-label">${X(t.label)}</text>`);for(let t of e.yAxis.ticks)u.push(`<text x="${t.labelX}" y="${t.labelY}" text-anchor="${t.textAnchor}" font-size="${q.labelSize}" font-weight="${q.labelWeight}" dy="${z}" class="xychart-label">${X(t.label)}</text>`);if(e.xAxis.title){let t=e.xAxis.title,n=t.rotate?` transform="rotate(${t.rotate},${t.x},${t.y})"`:``;u.push(`<text x="${t.x}" y="${t.y}" text-anchor="middle"${n} font-size="${q.axisTitleSize}" font-weight="${q.axisTitleWeight}" dy="${z}" class="xychart-axis-title">${X(t.text)}</text>`)}if(e.yAxis.title){let t=e.yAxis.title,n=t.rotate?` transform="rotate(${t.rotate},${t.x},${t.y})"`:``;u.push(`<text x="${t.x}" y="${t.y}" text-anchor="middle"${n} font-size="${q.axisTitleSize}" font-weight="${q.axisTitleWeight}" dy="${z}" class="xychart-axis-title">${X(t.text)}</text>`)}e.title&&u.push(`<text x="${e.title.x}" y="${e.title.y}" text-anchor="middle" font-size="${q.titleSize}" font-weight="${q.titleWeight}" dy="${z}" class="xychart-title">${X(e.title.text)}</text>`);for(let t of e.legend){if(t.type===`bar`)u.push(`<rect x="${t.x}" y="${t.y-7}" width="14" height="14" rx="3" class="xychart-bar xychart-color-${t.colorIndex}"/>`);else{let e=t.y;u.push(`<line x1="${t.x}" y1="${e}" x2="${t.x+14}" y2="${e}" stroke-width="${q.lineWidth}" stroke-linecap="round" class="xychart-legend-line xychart-color-${t.colorIndex}"/>`)}u.push(`<text x="${t.x+14+6}" y="${t.y}" text-anchor="start" font-size="${q.legendSize}" font-weight="${q.legendWeight}" dy="${z}" class="xychart-label">${X(t.label)}</text>`)}for(let e of O)u.push(e);for(let e of k)u.push(e);return u.push(`</svg>`),u.join(`
|
|
60
|
-
`)}function
|
|
57
|
+
`)[0],o=I(a,t.edgeLabel,L.groupHeader)+16,s=no;n.push(d` <rect x="${e.x}" y="${e.y}" width="${o}" height="${s}" `+d`fill="var(--_group-hdr)" stroke="var(--_node-stroke)" stroke-width="${R.outerBox}" />`),n.push(` `+C(i,e.x+6,e.y+s/2,t.edgeLabel,d`font-size="${t.edgeLabel}" font-weight="${L.groupHeader}" fill="var(--_text-sec)"`));for(let r of e.dividers)n.push(d` <line x1="${e.x}" y1="${r.y}" x2="${e.x+e.width}" y2="${r.y}" `+`stroke="var(--_line)" stroke-width="0.75" stroke-dasharray="6 4" />`),r.label&&n.push(` `+C(d`[${r.label}]`,e.x+8,r.y+14,t.edgeLabel,d`font-size="${t.edgeLabel}" text-anchor="start" font-weight="${L.edgeLabel}" fill="var(--_text-muted)"`));return n.push(`</g>`),n.join(`
|
|
58
|
+
`)}function vo(e,t){let{x:n,y:r,width:i,height:a}=e,o=e.actors&&e.actors.length>0?d` data-actors="${e.actors.map(c).join(`,`)}"`:``,s=e.position?d` data-position="${c(e.position)}"`:``,l=[d`${n},${r}`,d`${n+i-6},${r}`,d`${n+i},${r+6}`,d`${n+i},${r+a}`,d`${n},${r+a}`].join(` `);return d`<g class="note"${s}${o}>`+d`\n <polygon points="${l}" `+d`fill="var(--bg)" stroke="var(--_node-stroke)" stroke-width="${R.innerBox}" />`+d`\n <polygon points="${n+i-6},${r} ${n+i},${r+6} ${n+i-6},${r+6}" `+d`fill="var(--_inner-stroke)" stroke="var(--_node-stroke)" stroke-width="${R.innerBox}" />`+d`\n ${C(e.text,n+i/2,r+a/2,t.edgeLabel,d`font-size="${t.edgeLabel}" text-anchor="middle" font-weight="${L.edgeLabel}" fill="var(--_text-muted)"`)}`+`
|
|
59
|
+
</g>`}var K={plotWidth:600,plotHeight:340,padding:22,titleFontSize:18,titleFontWeight:600,titleHeight:42,axisLabelFontSize:14,axisLabelFontWeight:400,axisTitleFontSize:15,axisTitleFontWeight:500,xLabelHeight:38,yLabelWidth:58,yLabelGap:18,axisTitlePad:30,tickLength:4,barPadRatio:.2,barGroupGap:0,maxBarWidth:40,legendFontSize:14,legendFontWeight:400,legendHeight:28,legendSwatchW:14,legendSwatchH:14,legendGap:6,legendItemGap:16};function yo(e,t={}){return e.horizontal?xo(e):bo(e)}function bo(e){let t=!!e.title,n=!!e.xAxis.title,r=!!e.yAxis.title,i=e.series.length>1,a=e.yAxis.range;if(!a)throw Error(`XY chart: y-axis range was not set by the parser`);let o=x(a.min,a.max),s=ko(o),c=Math.max(...s.map(e=>I(e,K.axisLabelFontSize,K.axisLabelFontWeight)),K.yLabelWidth),l=K.padding+(t?K.titleHeight:0)+(i?K.legendHeight:0),u=K.padding+K.xLabelHeight+(n?K.axisTitlePad:0),d=K.padding+c+K.yLabelGap+(r?K.axisTitlePad:0),f=K.padding,p=K.plotWidth,m=K.plotHeight,h=d+p+f,g=l+m+u,_={x:d,y:l,width:p,height:m},v=So(e),y=e=>d+(e+.5)*(p/v),b=p/v,S=e=>{let t=(e-a.min)/(a.max-a.min||1);return l+m-t*m},C=Eo(e,y,l+m,b),w=o.map((e,t)=>({label:s[t],x:d,y:S(e),tx:d-K.tickLength,ty:S(e),labelX:d-K.yLabelGap,labelY:S(e),textAnchor:`end`})),T=o.map(e=>({x1:d,y1:S(e),x2:d+p,y2:S(e)})),E=Co(e,v),D=e.series.map((e,t)=>t),O=Do(e,y,S,b,a.min,E,D),k=Oo(e,y,S,E,D),A=K.padding+(t?K.titleHeight:0)+K.legendHeight/2,ee=i?jo(e,h/2,A,D):[],j={x1:d,y1:l+m,x2:d+p,y2:l+m},te={x1:d,y1:l,x2:d,y2:l+m},M={ticks:C,line:j,...e.xAxis.title?{title:{text:e.xAxis.title,x:d+p/2,y:g-K.padding}}:{}},N={ticks:w,line:te,...e.yAxis.title?{title:{text:e.yAxis.title,x:K.padding+4,y:l+m/2,rotate:-90}}:{}};return{width:h,height:g,title:e.title?{text:e.title,x:h/2,y:K.padding+K.titleFontSize}:void 0,xAxis:M,yAxis:N,plotArea:_,bars:O,lines:k,gridLines:T,legend:ee}}function xo(e){let t=!!e.title,n=!!e.xAxis.title,r=!!e.yAxis.title,i=e.series.length>1,a=e.yAxis.range;if(!a)throw Error(`XY chart: y-axis range was not set by the parser`);let o=x(a.min,a.max),s=ko(o),c=So(e),l=Co(e,c),u=Math.max(...l.map(e=>I(e,K.axisLabelFontSize,K.axisLabelFontWeight)),40),d=K.padding+(t?K.titleHeight:0)+(i?K.legendHeight:0),f=K.padding+K.xLabelHeight+(r?K.axisTitlePad:0),p=K.padding+u+K.yLabelGap+(n?K.axisTitlePad:0),m=Math.max(K.padding,I(s[s.length-1],K.axisLabelFontSize,K.axisLabelFontWeight)/2+4),h=K.plotWidth,g=K.plotHeight,_=p+h+m,v=d+g+f,y={x:p,y:d,width:h,height:g},b=e=>{let t=(e-a.min)/(a.max-a.min||1);return p+t*h},S=g/c,C=e=>d+(e+.5)*S,w=o.map((e,t)=>({label:s[t],x:b(e),y:d+g,tx:b(e),ty:d+g+K.tickLength,labelX:b(e),labelY:d+g+18,textAnchor:`middle`})),T=l.map((e,t)=>({label:e,x:p,y:C(t),tx:p-K.tickLength,ty:C(t),labelX:p-K.yLabelGap,labelY:C(t),textAnchor:`end`})),E=o.map(e=>({x1:b(e),y1:d,x2:b(e),y2:d+g})),D=e.series.map((e,t)=>t),O=e.series.filter(e=>e.type===`bar`).length,k=[];if(O>0){let t=S*(1-K.barPadRatio),n=O>1?(t-(O-1)*K.barGroupGap)/O:t,r=Math.min(n,K.maxBarWidth),i=O>1?r*O+K.barGroupGap*(O-1):r,o=0,s=0;for(let t of e.series){if(t.type!==`bar`){s++;continue}for(let e=0;e<t.data.length;e++){let n=C(e)-i/2+o*(r+K.barGroupGap),c=b(Math.max(t.data[e],a.min)),u=b(Math.max(0,a.min));k.push({x:Math.min(u,c),y:n,width:Math.abs(c-u),height:r,value:t.data[e],label:l[e],seriesIndex:o,colorIndex:D[s]})}o++,s++}}let A=[],ee=0,j=0;for(let t of e.series){if(t.type!==`line`){j++;continue}let e=t.data.map((e,t)=>({x:b(e),y:C(t),value:e,label:l[t]}));A.push({points:e,seriesIndex:ee,colorIndex:D[j]}),ee++,j++}let te={x1:p,y1:d+g,x2:p+h,y2:d+g},M={x1:p,y1:d,x2:p,y2:d+g},N={ticks:w,line:te,...e.yAxis.title?{title:{text:e.yAxis.title,x:p+h/2,y:v-K.padding}}:{}},P={ticks:T,line:M,...e.xAxis.title?{title:{text:e.xAxis.title,x:K.padding+4,y:d+g/2,rotate:-90}}:{}},ne=e.title?{text:e.title,x:_/2,y:K.padding+K.titleFontSize}:void 0,F=K.padding+(t?K.titleHeight:0)+K.legendHeight/2;return{width:_,height:v,horizontal:!0,title:ne,xAxis:N,yAxis:P,plotArea:y,bars:k,lines:A,gridLines:E,legend:i?jo(e,_/2,F,D):[]}}function So(e){if(e.xAxis.categories)return e.xAxis.categories.length;for(let t of e.series)if(t.data.length>0)return t.data.length;return 1}function Co(e,t){if(e.xAxis.categories)return e.xAxis.categories;if(e.xAxis.range){let{min:n,max:r}=e.xAxis.range,i=t>1?(r-n)/(t-1):0;return Array.from({length:t},(e,t)=>Ao(n+i*t))}return Array.from({length:t},(e,t)=>String(t+1))}var wo=8;function To(e,t){let n=e.map(e=>I(e,K.axisLabelFontSize,K.axisLabelFontWeight));for(let r=1;r<e.length;r++){let i=!0;for(let a=0;a+r<e.length;a+=r)if(r*t-(n[a]+n[a+r])/2<wo){i=!1;break}if(i)return r}return Math.max(1,e.length)}function Eo(e,t,n,r){let i=Co(e,So(e)),a=To(i,r);return i.map((e,r)=>({label:r%a===0?e:``,x:t(r),y:n,tx:t(r),ty:n+K.tickLength,labelX:t(r),labelY:n+18,textAnchor:`middle`}))}function Do(e,t,n,r,i,a,o){let s=e.series.filter(e=>e.type===`bar`).length;if(s===0)return[];let c=r*(1-K.barPadRatio),l=s>1?(c-(s-1)*K.barGroupGap)/s:c,u=Math.min(l,K.maxBarWidth),d=s>1?u*s+K.barGroupGap*(s-1):u,f=[],p=0,m=0;for(let r of e.series){if(r.type!==`bar`){m++;continue}for(let e=0;e<r.data.length;e++){let s=t(e)-d/2+p*(u+K.barGroupGap),c=n(r.data[e]),l=n(Math.max(0,i));f.push({x:s,y:Math.min(c,l),width:u,height:Math.abs(l-c),value:r.data[e],label:a[e],seriesIndex:p,colorIndex:o[m]})}p++,m++}return f}function Oo(e,t,n,r,i){let a=[],o=0,s=0;for(let c of e.series){if(c.type!==`line`){s++;continue}let e=c.data.map((e,i)=>({x:t(i),y:n(e),value:e,label:r[i]}));a.push({points:e,seriesIndex:o,colorIndex:i[s]}),o++,s++}return a}function ko(e){let t=e.length>1?Math.abs(e[1]-e[0]):0,n=t>0&&t<1?Math.ceil(-Math.log10(t)-1e-9):0;return e.map(e=>String(Number.isInteger(e)&&n===0?e:Number(e.toFixed(n))))}function Ao(e){return Number.isInteger(e)?String(e):e.toFixed(+(Math.abs(e)<10))}function jo(e,t,n,r){let i=[],a=0,o=0;for(let t=0;t<e.series.length;t++){let s=e.series[t],c=s.type===`bar`?`Bar ${a+1}`:`Line ${o+1}`;i.push({label:c,x:0,y:n,type:s.type,seriesIndex:s.type===`bar`?a:o,colorIndex:r[t]}),s.type===`bar`?a++:o++}let s=i.map(e=>{let t=I(e.label,K.legendFontSize,K.legendFontWeight);return K.legendSwatchW+K.legendGap+t}),c=t-(s.reduce((e,t)=>e+t,0)+(i.length-1)*K.legendItemGap)/2;for(let e=0;e<i.length;e++)i[e].x=c,c+=s[e]+K.legendItemGap;return i}var q={titleSize:18,titleWeight:600,axisTitleSize:15,axisTitleWeight:500,labelSize:14,labelWeight:400,legendSize:14,legendWeight:400,dotRadius:5,lineWidth:2.5,barRadius:8},J={fontSize:15,fontWeight:500,height:32,padX:14,offsetY:12,rx:8,minY:4,pointerSize:6};function Mo(e,t,r=`Inter`,i=!1,a=!1,o,s,c,l={}){let u=[],d=Math.max(0,...e.bars.map(e=>e.colorIndex),...e.lines.map(e=>e.colorIndex)),f=wi(M(e.width,e.height,t,i,s,c,void 0,l.styleAttribute,l.description).replace(`<svg `,`<svg data-xychart-colors="${d}" `),o);u.push(f),u.push(n(r,!1,l.nonce,l.bodyFont));let p=Math.max(...e.lines.map(e=>e.points.length),0),m=p>0&&p<=12,{style:h,defs:g}=No(e,a,m,t.accent,t.bg,l.nonce);u.push(h),g&&u.push(g);let{plotArea:_}=e,v=e.xAxis.ticks.map(e=>e.x),y=e.horizontal?e.yAxis.ticks.map(e=>e.y):e.gridLines.map(e=>e.y1),b=v.length>1?Math.abs(v[1]-v[0]):_.width/6,x=y.length>1?Math.abs(y[1]-y[0]):_.height/6,S=b/Math.max(1,Math.round(b/20)),C=x/Math.max(1,Math.round(x/20)),w=v[0]??_.x,T=y[0]??_.y,E=w-Math.ceil((w-_.x)/S)*S,D=T-Math.ceil((T-_.y)/C)*C;for(let e=D;e<=_.y+_.height+.5;e+=C)for(let t=E;t<=_.x+_.width+.5;t+=S)u.push(`<circle cx="${Y(t)}" cy="${Y(e)}" r="1.5" class="xychart-grid"/>`);let O=[];for(let t of e.bars){let n=` data-value="${t.value}"${t.label?` data-label="${X(t.label)}"`:``}`,r=e.horizontal?Fo(t.x,t.y,t.width,t.height,q.barRadius):Po(t.x,t.y,t.width,t.height,q.barRadius);if(u.push(`<path d="${r}" class="xychart-bar xychart-color-${t.colorIndex}"${n}/>`),a){let e=Bo(t.value),n=t.label?`${t.label}: ${e}`:e,r=zo(t.x+t.width/2,t.y,e);O.push(`<g class="xychart-bar-group"><rect x="${Y(t.x)}" y="${Y(t.y)}" width="${Y(t.width)}" height="${Y(t.height)}" fill="transparent"/><title>${X(n)}</title>`+r+`</g>`)}}for(let t of e.lines){if(t.points.length===0)continue;let n=e.horizontal?Io(t.points):Lo(t.points);u.push(`<path d="${n}" class="xychart-line-shadow xychart-color-${t.colorIndex}" transform="translate(0,2)"/>`),u.push(`<path d="${n}" class="xychart-line xychart-color-${t.colorIndex}"/>`)}let k=[];if(a||m){let t=new Map;for(let n of e.legend)n.type===`line`&&t.set(n.seriesIndex,n.label);let n=new Map;for(let t of e.lines)for(let e of t.points){let r=Y(e.x),i=n.get(r)??[];n.set(r,i),i.push({x:e.x,y:e.y,value:e.value,label:e.label,seriesIndex:t.seriesIndex,colorIndex:t.colorIndex})}for(let e of n.values()){let n=e[0].x,r=e[0].label||``;if(a&&e.length>1){let i=Math.min(...e.map(e=>e.y)),a=Math.max(...e.map(e=>e.y)),o=q.dotRadius*3,s=`<rect x="${Y(n-o)}" y="${Y(i-o)}" width="${Y(o*2)}" height="${Y(a-i+o*2)}" fill="transparent" class="xychart-hit"/>`,c=e.map(e=>({text:Bo(e.value),legendLabel:t.get(e.seriesIndex)||`Line ${e.seriesIndex+1}`})),l=Ro(n,i-q.dotRadius,r,c),u=c.map(e=>e.text),d=r?`${r}: ${u.join(` · `)}`:u.join(` · `),f=`<g class="xychart-dot-group">${s}`;for(let t of e){let e=` data-value="${t.value}"${t.label?` data-label="${X(t.label)}"`:``}`;f+=`<circle cx="${Y(t.x)}" cy="${Y(t.y)}" r="${q.dotRadius}" class="xychart-dot xychart-color-${t.colorIndex}"${e}/>`}f+=`<title>${X(d)}</title>${l}</g>`,k.push(f)}else if(a){let t=e[0],r=` data-value="${t.value}"${t.label?` data-label="${X(t.label)}"`:``}`,i=Bo(t.value),a=t.label?`${t.label}: ${i}`:i,o=zo(n,t.y-q.dotRadius,i),s=m?`<circle cx="${Y(n)}" cy="${Y(t.y)}" r="${q.dotRadius*3}" fill="transparent" class="xychart-hit"/>`:``;k.push(`<g class="xychart-dot-group">${s}<circle cx="${Y(t.x)}" cy="${Y(t.y)}" r="${q.dotRadius}" class="xychart-dot xychart-color-${t.colorIndex}"${r}/><title>${X(a)}</title>${o}</g>`)}else for(let t of e){let e=` data-value="${t.value}"${t.label?` data-label="${X(t.label)}"`:``}`;u.push(`<circle cx="${Y(t.x)}" cy="${Y(t.y)}" r="${q.dotRadius}" class="xychart-dot xychart-color-${t.colorIndex}"${e}/>`)}}}for(let t of e.xAxis.ticks)t.label!==``&&u.push(`<text x="${t.labelX}" y="${t.labelY}" text-anchor="${t.textAnchor}" font-size="${q.labelSize}" font-weight="${q.labelWeight}" dy="${z}" class="xychart-label">${X(t.label)}</text>`);for(let t of e.yAxis.ticks)u.push(`<text x="${t.labelX}" y="${t.labelY}" text-anchor="${t.textAnchor}" font-size="${q.labelSize}" font-weight="${q.labelWeight}" dy="${z}" class="xychart-label">${X(t.label)}</text>`);if(e.xAxis.title){let t=e.xAxis.title,n=t.rotate?` transform="rotate(${t.rotate},${t.x},${t.y})"`:``;u.push(`<text x="${t.x}" y="${t.y}" text-anchor="middle"${n} font-size="${q.axisTitleSize}" font-weight="${q.axisTitleWeight}" dy="${z}" class="xychart-axis-title">${X(t.text)}</text>`)}if(e.yAxis.title){let t=e.yAxis.title,n=t.rotate?` transform="rotate(${t.rotate},${t.x},${t.y})"`:``;u.push(`<text x="${t.x}" y="${t.y}" text-anchor="middle"${n} font-size="${q.axisTitleSize}" font-weight="${q.axisTitleWeight}" dy="${z}" class="xychart-axis-title">${X(t.text)}</text>`)}e.title&&u.push(`<text x="${e.title.x}" y="${e.title.y}" text-anchor="middle" font-size="${q.titleSize}" font-weight="${q.titleWeight}" dy="${z}" class="xychart-title">${X(e.title.text)}</text>`);for(let t of e.legend){if(t.type===`bar`)u.push(`<rect x="${t.x}" y="${t.y-7}" width="14" height="14" rx="3" class="xychart-bar xychart-color-${t.colorIndex}"/>`);else{let e=t.y;u.push(`<line x1="${t.x}" y1="${e}" x2="${t.x+14}" y2="${e}" stroke-width="${q.lineWidth}" stroke-linecap="round" class="xychart-legend-line xychart-color-${t.colorIndex}"/>`)}u.push(`<text x="${t.x+14+6}" y="${t.y}" text-anchor="start" font-size="${q.legendSize}" font-weight="${q.legendWeight}" dy="${z}" class="xychart-label">${X(t.label)}</text>`)}for(let e of O)u.push(e);for(let e of k)u.push(e);return u.push(`</svg>`),u.join(`
|
|
60
|
+
`)}function No(e,t,n,r,i,a){let o=r??F,s=new Set;for(let t of e.bars)s.add(t.colorIndex);for(let t of e.lines)s.add(t.colorIndex);let c=[];for(let e of[...s].sort((e,t)=>e-t)){let t=e===0?`var(--accent, ${F})`:ce(e,o,i);c.push(` --xychart-color-${e}: ${t};`),c.push(` --xychart-bar-fill-${e}: color-mix(in srgb, var(--bg) 75%, var(--xychart-color-${e}) 25%);`)}let l=[];for(let e of[...s].sort((e,t)=>e-t)){let t=`var(--xychart-color-${e})`;l.push(` .xychart-bar.xychart-color-${e} { stroke: ${t}; fill: var(--xychart-bar-fill-${e}); }`),l.push(` path.xychart-color-${e}, line.xychart-color-${e} { stroke: ${t}; }`),l.push(` circle.xychart-color-${e} { fill: ${t}; }`)}let u=t?`
|
|
61
61
|
.xychart-tip { opacity: 0; pointer-events: none; }
|
|
62
62
|
.xychart-tip-bg { fill: var(--_text); filter: drop-shadow(0 1px 3px color-mix(in srgb, var(--fg) 20%, transparent)); }
|
|
63
63
|
.xychart-tip-text { fill: var(--bg); font-size: ${J.fontSize}px; font-weight: ${J.fontWeight}; }
|
|
@@ -75,7 +75,7 @@ import{DEFAULTS as e,applyThemeVariables as t,buildStyleBlock as n,checkGraphSiz
|
|
|
75
75
|
.xychart-title { fill: var(--_text); }${d}
|
|
76
76
|
${l.join(`
|
|
77
77
|
`)}${u}
|
|
78
|
-
</style>`,defs:``}}function
|
|
78
|
+
</style>`,defs:``}}function Po(e,t,n,r,i){let a=Math.min(i,n/2,r/2);return a<=0?`M${Y(e)},${Y(t)} h${Y(n)} v${Y(r)} h${Y(-n)} Z`:[`M${Y(e)},${Y(t+a)}`,`Q${Y(e)},${Y(t)} ${Y(e+a)},${Y(t)}`,`L${Y(e+n-a)},${Y(t)}`,`Q${Y(e+n)},${Y(t)} ${Y(e+n)},${Y(t+a)}`,`L${Y(e+n)},${Y(t+r-a)}`,`Q${Y(e+n)},${Y(t+r)} ${Y(e+n-a)},${Y(t+r)}`,`L${Y(e+a)},${Y(t+r)}`,`Q${Y(e)},${Y(t+r)} ${Y(e)},${Y(t+r-a)}`,`Z`].join(` `)}function Fo(e,t,n,r,i){let a=Math.min(i,n/2,r/2);return a<=0?`M${Y(e)},${Y(t)} h${Y(n)} v${Y(r)} h${Y(-n)} Z`:[`M${Y(e+a)},${Y(t)}`,`L${Y(e+n-a)},${Y(t)}`,`Q${Y(e+n)},${Y(t)} ${Y(e+n)},${Y(t+a)}`,`L${Y(e+n)},${Y(t+r-a)}`,`Q${Y(e+n)},${Y(t+r)} ${Y(e+n-a)},${Y(t+r)}`,`L${Y(e+a)},${Y(t+r)}`,`Q${Y(e)},${Y(t+r)} ${Y(e)},${Y(t+r-a)}`,`L${Y(e)},${Y(t+a)}`,`Q${Y(e)},${Y(t)} ${Y(e+a)},${Y(t)}`,`Z`].join(` `)}function Io(e){return e.map((e,t)=>`${t===0?`M`:`L`}${Y(e.x)},${Y(e.y)}`).join(` `)}function Lo(e){if(e.length===0)return``;if(e.length===1)return`M${Y(e[0].x)},${Y(e[0].y)}`;if(e.length===2)return`M${Y(e[0].x)},${Y(e[0].y)} L${Y(e[1].x)},${Y(e[1].y)}`;let t=e.length,n=[],r=[];for(let i=0;i<t-1;i++)n.push(e[i+1].x-e[i].x),r.push(n[i]===0?0:(e[i+1].y-e[i].y)/n[i]);let i=Array(t).fill(0);for(let e=1;e<t-1;e++){let t=r[e-1],a=r[e];if(t*a<=0)continue;let o=2*n[e]+n[e-1],s=n[e]+2*n[e-1];i[e]=(o+s)/(o/t+s/a)}let a=(e,t,n,r)=>{let i=((2*e+t)*n-e*r)/(e+t);return i*n<=0?i=0:n*r<=0&&Math.abs(i)>3*Math.abs(n)&&(i=3*n),i};i[0]=a(n[0],n[1],r[0],r[1]),i[t-1]=a(n[t-2],n[t-3],r[t-2],r[t-3]);let o=`M${Y(e[0].x)},${Y(e[0].y)}`;for(let r=0;r<t-1;r++){let t=n[r]/3,a=e[r].x+t,s=e[r].y+i[r]*t,c=e[r+1].x-t,l=e[r+1].y-i[r+1]*t;o+=` C${Y(a)},${Y(s)} ${Y(c)},${Y(l)} ${Y(e[r+1].x)},${Y(e[r+1].y)}`}return o}function Ro(e,t,n,r){let i=I(n,J.fontSize,600),a=Math.max(...r.map(e=>{let t=I(e.legendLabel,J.fontSize,J.fontWeight),n=I(e.text,J.fontSize,J.fontWeight);return t+10+n})),o=Math.max(i,a)+J.padX*2,s=26+r.length*20+6,c=Math.max(J.minY,t-J.offsetY-s-J.pointerSize),l=e-o/2,u=e,d=c+s,f=J.pointerSize,p=`<polygon points="${Y(u-f)},${Y(d)} ${Y(u+f)},${Y(d)} ${Y(u)},${Y(d+f)}" class="xychart-tip xychart-tip-ptr"/>`,m=`<rect x="${Y(l)}" y="${Y(c)}" width="${Y(o)}" height="${s}" rx="${J.rx}" class="xychart-tip xychart-tip-bg"/>`;m+=p;let h=c+6+10;m+=`<text x="${Y(e)}" y="${Y(h)}" text-anchor="middle" font-weight="600" font-size="${J.fontSize}" dy="${z}" class="xychart-tip xychart-tip-text">${X(n)}</text>`;let g=l+J.padX,_=l+o-J.padX;for(let e of r)h+=20,m+=`<text x="${Y(g)}" y="${Y(h)}" text-anchor="start" font-size="${J.fontSize}" font-weight="${J.fontWeight}" dy="${z}" class="xychart-tip xychart-tip-text">${X(e.legendLabel)}</text>`,m+=`<text x="${Y(_)}" y="${Y(h)}" text-anchor="end" font-size="${J.fontSize}" font-weight="${J.fontWeight}" dy="${z}" class="xychart-tip xychart-tip-text">${X(e.text)}</text>`;return m}function zo(e,t,n){let r=I(n,J.fontSize,J.fontWeight)+J.padX*2,i=J.height,a=Math.max(J.minY,t-J.offsetY-i-J.pointerSize),o=e-r/2,s=e,c=a+i/2,l=e,u=a+i,d=J.pointerSize,f=`<polygon points="${Y(l-d)},${Y(u)} ${Y(l+d)},${Y(u)} ${Y(l)},${Y(u+d)}" class="xychart-tip xychart-tip-ptr"/>`;return`<rect x="${Y(o)}" y="${Y(a)}" width="${Y(r)}" height="${i}" rx="${J.rx}" class="xychart-tip xychart-tip-bg"/>`+f+`<text x="${Y(s)}" y="${Y(c)}" text-anchor="middle" dy="${z}" class="xychart-tip xychart-tip-text">${X(n)}</text>`}function Bo(e){return Number.isInteger(e)?e.toLocaleString(`en-US`):e.toFixed(+(Math.abs(e)<10))}function Y(e){return String(Math.round(e*10)/10)}function X(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var Z={height:450,margin:40,legendRectSize:18,legendSpacing:4,textPosition:.75,outerStrokeWidth:2,titleFontSize:25,sectionFontSize:17,legendFontSize:17,fontWeight:400,paletteSize:12,highlightScale:1.05,minPercent:1},Vo=Math.PI*2;function Q(e){return String(Math.round(e*100)/100)}function Ho(e,t,n,r){return{x:e+n*Math.sin(r),y:t-n*Math.cos(r)}}function Uo(e,t,n,r,i,a=0){if(i-r>=Vo-1e-9){let r=(n,r)=>`M${Q(e)},${Q(t-n)}A${Q(n)},${Q(n)},0,1,${r},${Q(e)},${Q(t+n)}A${Q(n)},${Q(n)},0,1,${r},${Q(e)},${Q(t-n)}`;return r(n,1)+(a>0?r(a,0):``)+`Z`}let o=Ho(e,t,n,r),s=Ho(e,t,n,i),c=+(i-r>Math.PI),l=`M${Q(o.x)},${Q(o.y)}A${Q(n)},${Q(n)},0,${c},1,${Q(s.x)},${Q(s.y)}`;if(a<=0)return`${l}L${Q(e)},${Q(t)}Z`;let u=Ho(e,t,a,i),d=Ho(e,t,a,r);return`${l}L${Q(u.x)},${Q(u.y)}A${Q(a)},${Q(a)},0,${c},0,${Q(d.x)},${Q(d.y)}Z`}function Wo(e,t,n){return n?`${e} [${String(t)}]`:e}function Go(e,t={}){let n=Z.height,r=n,i=Math.min(r,n)/2-Z.margin,a=r/2,o=n/2,s=e.slices.reduce((e,t)=>e+t.value,0),c=e.slices.map((e,t)=>({slice:e,colorIndex:t%Z.paletteSize})).filter(({slice:e})=>e.value/s*100>=Z.minPercent),l=c.reduce((e,t)=>e+t.slice.value,0),u=Z.legendRectSize+Z.legendSpacing,d=e.slices.length,f=d>0?e.legendPosition??`right`:`right`,p=e.slices.map(t=>Wo(t.label,t.value,e.showData)),m=Math.max(0,...p.map(e=>I(e,Z.legendFontSize,Z.fontWeight))),h=Z.legendRectSize+Z.legendSpacing,g=u*d,_=f===`left`?m+h:0,v=f===`top`?g+u:0,y=a-m/2-h,b=o-g/2,x={right:{x:a+12*Z.legendRectSize,y:b},left:{x:a-i-h,y:b},center:{x:y,y:b},top:{x:y,y:o-i},bottom:{x:y,y:o+i+u}}[f],S=h+m,C=d>0&&(f===`left`||f===`right`)?r+Z.margin+S:r+Z.margin,w=f===`top`||f===`bottom`?n+g:n,T=e.title??``,E=T.length>0?I(T,Z.titleFontSize,Z.fontWeight):0,D=a-E/2,O=a+E/2,k=x.x,A=x.x+S,ee=x.y,j=x.y+g-u+Z.legendRectSize,te=Math.min(0,D,d>0?k:0),M=Math.max(C,O,d>0?A:0),N=d>0?Math.min(0,ee):0,P=d>0?Math.max(w,j):n,ne=-te,F=-N,re=a+_+ne,ie=o+v+F,ae=[],oe=0,se=e.donutHole??0,ce=se>0&&se<=.9?se*i:0,le=i*(e.textPosition??Z.textPosition);for(let{slice:t,colorIndex:n}of c){let r=oe,a=oe+t.value/l*Vo;oe=a;let o=Ho(re,ie,le,(r+a)/2),c=e.highlightSlice!==void 0&&e.highlightSlice!==`hover`&&e.highlightSlice!==``&&e.highlightSlice===t.label,u=c?Z.highlightScale:1;ae.push({label:t.label,value:t.value,colorIndex:n,startAngle:r,endAngle:a,path:Uo(re,ie,i*u,r,a,ce*u),percentText:`${(t.value/s*100).toFixed(0)}%`,labelX:o.x,labelY:o.y,...c?{highlighted:c}:{}})}let ue=p.map((e,t)=>{let n=x.x+ne,r=x.y+t*u+F;return{text:e,colorIndex:t%Z.paletteSize,x:n,y:r,size:Z.legendRectSize,textX:n+Z.legendRectSize+Z.legendSpacing,textY:r+Z.legendRectSize-Z.legendSpacing}});return{width:Math.ceil(M-te),height:Math.ceil(P-N),cx:re,cy:ie,radius:i,outerRadius:i+Z.outerStrokeWidth/2,title:T.length>0?{text:T,x:a+ne,y:o+F-(n-50)/2}:void 0,slices:ae,legend:ue,accTitle:e.accTitle,accDescr:e.accDescr,sliceColors:e.sliceColors}}function Ko(e){return String(Math.round(e*100)/100)}function qo(e,t,n){return e===0?`var(--accent, ${F})`:ce(e,t??F,n)}function Jo(e,t,n){let r=new Set;for(let t of e.slices)r.add(t.colorIndex);for(let t of e.legend)r.add(t.colorIndex);let i=[...r].sort((e,t)=>e-t),a=i.map(n=>` --pie-color-${n}: ${e.sliceColors?.[n]??qo(n,t.accent,t.bg)};`),o=i.map(e=>` .pie-color-${e} { fill: var(--pie-color-${e}); }\n rect.pie-color-${e} { stroke: var(--pie-color-${e}); }`),s=e.slices.some(e=>e.highlighted)?`
|
|
79
79
|
.pie-slice.pie-highlight { opacity: 1; }`:``,c=a.length>0?`\n svg {\n${a.join(`
|
|
80
80
|
`)}\n }`:``;return`${A(n)}
|
|
81
81
|
.pie-outer { fill: none; stroke: var(--fg); stroke-width: ${Z.outerStrokeWidth}px; }
|
|
@@ -85,22 +85,21 @@ ${l.join(`
|
|
|
85
85
|
.pie-legend-text { fill: var(--_text); font-size: ${Z.legendFontSize}px; font-weight: ${Z.fontWeight}; }${c}
|
|
86
86
|
${o.join(`
|
|
87
87
|
`)}
|
|
88
|
-
</style>`}function
|
|
89
|
-
`)}var
|
|
88
|
+
</style>`}function Yo(e,t,r=`Inter`,i=!1,a,o,s,u={}){let d=[];d.push(wi(M(e.width,e.height,t,i,o??e.accTitle,s,void 0,u.styleAttribute,e.accDescr),a)),d.push(n(r,!1,u.nonce,u.bodyFont)),d.push(Jo(e,t,u.nonce)),d.push(`<circle cx="${Ko(e.cx)}" cy="${Ko(e.cy)}" r="${Ko(e.outerRadius)}" class="pie-outer"/>`);for(let t of e.slices)d.push(`<path d="${t.path}" class="pie-slice${t.highlighted?` pie-highlight`:``} pie-color-${t.colorIndex}" data-label="${c(t.label)}" data-value="${t.value}"/>`);for(let t of e.slices)d.push(`<text x="${Ko(t.labelX)}" y="${Ko(t.labelY)}" text-anchor="middle" class="pie-slice-label">${l(t.percentText)}</text>`);e.title&&d.push(`<text x="${Ko(e.title.x)}" y="${Ko(e.title.y)}" text-anchor="middle" class="pie-title">${l(e.title.text)}</text>`);for(let t of e.legend)d.push(`<g class="pie-legend"><rect x="${Ko(t.x)}" y="${Ko(t.y)}" width="${t.size}" height="${t.size}" class="pie-legend-swatch pie-color-${t.colorIndex}"/><text x="${Ko(t.textX)}" y="${Ko(t.textY)}" class="pie-legend-text">${l(t.text)}</text></g>`);return d.push(`</svg>`),d.join(`
|
|
89
|
+
`)}var Xo={titlePadding:10,titleFontSize:20,quadrantPadding:5,xAxisLabelPadding:5,yAxisLabelPadding:5,xAxisLabelFontSize:16,yAxisLabelFontSize:16,quadrantLabelFontSize:16,quadrantTextTopPadding:5,pointTextPadding:5,pointLabelFontSize:12,pointRadius:5,quadrantInternalBorderStrokeWidth:1,quadrantExternalBorderStrokeWidth:2,xAxisPosition:`top`,yAxisPosition:`left`,width:500,height:500,axisLabelPadding:5,axisLabelFontSize:16,internalBorderWidth:1,externalBorderWidth:2},Zo={chartWidth:500,chartHeight:500};function Qo(e){return{anchor:`middle`,baseline:`hanging`,rotation:0,...e}}function $o(e){let t={...Xo,...Zo,...e.config},n=e.points.length>0,r=!!(e.xAxisLeft||e.xAxisRight),i=!!(e.yAxisBottom||e.yAxisTop),a=!!e.title,o=t.xAxisLabelPadding*2+t.xAxisLabelFontSize,s=t.yAxisLabelPadding*2+t.yAxisLabelFontSize,c=a?t.titleFontSize+t.titlePadding*2:0,l=!n&&t.xAxisPosition===`top`,u=l&&r?o:0,d=!l&&r?o:0,f=t.yAxisPosition===`left`&&i?s:0,p=t.yAxisPosition===`right`&&i?s:0,m=t.quadrantPadding+f,h=t.quadrantPadding+u+c,g=t.chartWidth-t.quadrantPadding*2-f-p,_=t.chartHeight-t.quadrantPadding*2-u-d-c,v=g/2,y=_/2,b=[[m+v,h],[m,h],[m,h+y],[m+v,h+y]].map(([r,i],a)=>({index:a,x:r,y:i,width:v,height:y,text:Qo({text:e.quadrants[a],x:r+v/2,y:n?i+t.quadrantTextTopPadding:i+y/2,fontSize:t.quadrantLabelFontSize,baseline:n?`hanging`:`middle`})})),x=t.quadrantExternalBorderStrokeWidth/2,S=(e,n,r,i)=>({x1:e,y1:n,x2:r,y2:i,strokeWidth:t.quadrantExternalBorderStrokeWidth,kind:`external`}),C=(e,n,r,i)=>({x1:e,y1:n,x2:r,y2:i,strokeWidth:t.quadrantInternalBorderStrokeWidth,kind:`internal`}),w=[S(m-x,h,m+g+x,h),S(m+g,h+x,m+g,h+_-x),S(m-x,h+_,m+g+x,h+_),S(m,h+x,m,h+_-x),C(m+v,h+x,m+v,h+_-x),C(m+x,h+y,m+g-x,h+y)],T=[],E=l?t.xAxisLabelPadding+c:t.xAxisLabelPadding+h+_+t.quadrantPadding,D=!!e.xAxisRight,O=(e,n)=>T.push(Qo({text:e,x:n,y:E,fontSize:t.xAxisLabelFontSize,anchor:D?`middle`:`start`}));r&&e.xAxisLeft&&O(e.xAxisLeft,m+(D?v/2:0)),r&&e.xAxisRight&&O(e.xAxisRight,m+v+v/2);let k=t.yAxisPosition===`left`?t.yAxisLabelPadding:t.yAxisLabelPadding+m+g+t.quadrantPadding,A=!!e.yAxisTop,ee=(e,n)=>T.push(Qo({text:e,x:k,y:n,fontSize:t.yAxisLabelFontSize,anchor:A?`middle`:`start`,rotation:-90}));i&&e.yAxisBottom&&ee(e.yAxisBottom,h+_-(A?y/2:0)),i&&e.yAxisTop&&ee(e.yAxisTop,h+y-y/2);let j=[...e.points].reverse().map(e=>{let n=m+e.x*g,r=h+_-e.y*_;return{x:n,y:r,radius:e.radius??t.pointRadius,color:e.color,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth??`0px`,text:Qo({text:e.label,x:n,y:r+t.pointTextPadding,fontSize:t.pointLabelFontSize})}});return{width:t.chartWidth,height:t.chartHeight,themeColors:e.themeColors,title:a?Qo({text:e.title,x:t.chartWidth/2,y:t.titlePadding,fontSize:t.titleFontSize}):void 0,quadrants:b,lines:w,axisLabels:T,points:j}}function es(e){return String(Math.round(e*100)/100)}var ts=[14,10,6,3];function ns(e,t){let n=`var(--accent, ${F})`,r=`color-mix(in srgb, ${n} 35%, var(--bg))`,i=ts.map((e,t)=>` .quadrant-cell-${t} { fill: color-mix(in srgb, ${n} ${e}%, var(--bg)); }`),a=e.points.flatMap((e,t)=>{let n=[e.color&&`fill: ${e.color};`,e.strokeColor&&`stroke: ${e.strokeColor};`,e.strokeWidth!==`0px`&&`stroke-width: ${e.strokeWidth};`].filter(Boolean);return n.length>0?[` .quadrant-point-${t} { ${n.join(` `)} }`]:[]}),o=e.themeColors??{},s=[...[1,2,3,4].flatMap(e=>[o[`quadrant${e}Fill`]&&` .quadrant-cell-${e-1} { fill: ${o[`quadrant${e}Fill`]}; }`,o[`quadrant${e}TextFill`]&&` .quadrant:nth-child(${e}) .quadrant-label { fill: ${o[`quadrant${e}TextFill`]}; }`]),o.quadrantPointFill&&` .quadrant-point { fill: ${o.quadrantPointFill}; stroke: ${o.quadrantPointFill}; }`,o.quadrantPointTextFill&&` .quadrant-point-label { fill: ${o.quadrantPointTextFill}; }`,o.quadrantXAxisTextFill&&` .quadrant-axis-label[transform$="rotate(0)"] { fill: ${o.quadrantXAxisTextFill}; }`,o.quadrantYAxisTextFill&&` .quadrant-axis-label[transform$="rotate(-90)"] { fill: ${o.quadrantYAxisTextFill}; }`,o.quadrantTitleFill&&` .quadrant-title { fill: ${o.quadrantTitleFill}; }`,o.quadrantInternalBorderStrokeFill&&` .quadrant-line-internal { stroke: ${o.quadrantInternalBorderStrokeFill}; }`,o.quadrantExternalBorderStrokeFill&&` .quadrant-line-external { stroke: ${o.quadrantExternalBorderStrokeFill}; }`].filter(Boolean);return`${A(t)}
|
|
90
90
|
${i.join(`
|
|
91
91
|
`)}
|
|
92
92
|
.quadrant-line { stroke: ${r}; }
|
|
93
93
|
.quadrant-text { fill: var(--_text); }
|
|
94
|
-
.quadrant-point { fill: var(--fg); stroke: var(--fg); stroke-width: 0px; }${a.
|
|
95
|
-
`+
|
|
96
|
-
`)
|
|
97
|
-
|
|
98
|
-
`)}
|
|
99
|
-
`))
|
|
100
|
-
`)
|
|
101
|
-
`)
|
|
102
|
-
`)}function
|
|
103
|
-
`)}function sc(e){let
|
|
104
|
-
`)}function
|
|
105
|
-
`)}
|
|
106
|
-
`)}var _c={type:`xychart`,parse:_e,layoutForSvg:xo,renderSvg(e,t,n){let r=n.interactivity===void 0?n.interactive??!1:n.interactivity===`full`;return Po(e,t.colors,t.font,t.transparent,r,t.embedSource,t.title,t.decorative,t.emit)}},vc={type:`sequence`,parse:ge,layoutForSvg:Ya,renderSvg(e,t){return Xa(e,t.colors,t.font,t.transparent,t.fontSizes,t.embedSource,t.title,t.decorative,t.emit)}};function yc(e){return(e.interactivity??`static`)!==`none`}function bc(e){return(e.interactivity??`static`)===`full`}var xc={type:`class`,parse:de,layoutForSvg:Qi,renderSvg(e,t,n){return ia(e,t.colors,t.font,t.transparent,t.fontSizes,t.embedSource,t.title,t.decorative,yc(n),t.emit)}},Sc={type:`er`,parse:fe,layoutForSvg(e,t){return Ea(P(e,t.direction),t)},renderSvg(e,t){return ka(e,t.colors,t.font,t.transparent,t.fontSizes,t.embedSource,t.title,t.decorative,t.emit)}},Cc={type:`flowchart`,parse:(e,t)=>pe(t),layoutForSvg(e,t){return{graph:gr(P(e,t.direction),t),curve:t.curve??e.initConfig?.curve??`linear`}},renderSvg(e,t,n){return Dr(e.graph,t.colors,t.font,t.transparent,t.fontSizes,e.curve,t.embedSource,bc(n),yc(n),t.title,t.decorative,t.emit)}},wc={type:`c4`,parse:ue,layoutForSvg(e,t){return rc(e,t)},renderSvg(e,t){return ic(e,t.colors,t.font,t.transparent,t.fontSizes,t.embedSource,t.title,t.decorative,t.emit)}},Tc={xychart:_c,er:Sc,sequence:vc,class:xc,flowchart:Cc,architecture:{type:`architecture`,parse:le,layoutForSvg(e,t){return{graph:mr(P(re(e),t.direction),t),curve:t.curve??`linear`}},renderSvg:Cc.renderSvg},c4:wc,pie:{type:`pie`,parse:(e,t)=>me(t),layoutForSvg:(e,t)=>qo(t.honorThemeVariables?e:{...e,sliceColors:void 0},t),renderSvg(e,t){return Zo(e,t.colors,t.font,t.transparent,t.embedSource,t.title,t.decorative,t.emit)}},quadrant:{type:`quadrant`,parse:(e,t)=>he(t),layoutForSvg:e=>es(e),renderSvg(e,t){return as(e,t.colors,t.font,t.transparent,t.embedSource,t.title,t.decorative,t.emit)}}};function Ec(t){return{bg:t.bg??e.bg,fg:t.fg??e.fg,line:t.line,accent:t.accent,muted:t.muted??(t.bg||t.fg?void 0:e.muted),surface:t.surface,border:t.border}}function Dc(e={}){return N(Ec(e),e.transparent)}function Oc(e){return{nonce:e.nonce,styleAttribute:e.styleAttribute,bodyFont:xe(e)}}function kc(e,t={}){let{svg:n,colors:r}=Mc(e,t),i=Ac(n);return t.resolveColors?zi(i,r):i}function Ac(e){let t=new Set(Array.from(e.matchAll(/\sid="([^"]+)"/g),e=>e[1]??``));if(t.size===0)return e;let n=2166136261;for(let t=0;t<e.length;t++)n=Math.imul(n^e.charCodeAt(t),16777619);let r=`zm${(n>>>0).toString(36)}-`,i=e=>t.has(e)&&!e.startsWith(`zm-`)?r+e:e;return e.replace(/(\sid=")([^"]+)"/g,(e,t,n)=>`${t}${i(n)}"`).replace(/url\(#([^)]+)\)/g,(e,t)=>`url(#${i(t)})`).replace(/(href=")#([^"]+)"/g,(e,t,n)=>`${t}#${i(n)}"`)}function jc(e){let t=u(ve(e)).text;Tc[o(t)].parse(k(t),t)}function Mc(e,n){i(`maxInputLength`,e.length,n.limits),a(e,n.limits);let s=u(ve(e)),c=s.text,l=n.font??`Inter`;O(g(l));let d=n.transparent??!1,f=qe(n.fontSizes),p=o(c),m=n.embedSource?e:void 0,h=n.title??s.accTitle,_=n.decorative,v={...Oc(n),description:s.accDescr},y=k(c),b=Tc[p],x=b.parse(y,c),S=x;S.nodes instanceof Map&&Array.isArray(S.edges)&&r(S.nodes.size,S.edges.length,n.limits);let C=b.layoutForSvg(x,n),w=Ec(n.honorThemeVariables?t(n,x.initConfig):n),T={colors:w,font:l,transparent:d,fontSizes:f,embedSource:m,title:h,decorative:_,emit:v};return{svg:b.renderSvg(C,T,n),colors:w}}async function Nc(e,t={}){return t.embedFont===`subset`&&await be(),kc(e,t)}var Pc=kc,Fc=Nc;export{Ba as ACTOR_LABEL_OFFSET,Ze as ARROW_HEAD,Ye as ASYMMETRIC_NOTCH,W as CLS,$e as ELK_DIRECTION_FALLBACK,Me as ElkNotRegisteredError,Ke as FONT_SIZES,L as FONT_WEIGHTS,Je as GROUP_HEADER_CONTENT_PAD,it as INLINE_CENTERED_EDGE_LABEL,We as MONO_FONT,Ge as MONO_FONT_STACK,Xe as NODE_PADDING,Z as PIE,Qo as QUADRANT,R as STROKE_WIDTHS,z as TEXT_BASELINE_SHIFT,nt as baseElkLayoutOptions,za as boxLabelHeight,ot as buildElkEdge,at as buildElkEdgeLabel,rt as buildElkLeafNode,Qe as buildSvgStyleBlock,Yi as classBackEdges,Wi as classNoteId,Ot as clipEdgeToShape,_r as convertToElkFormat,Le as createLayoutCache,et as directionToElk,Be as elkLayoutSync,tt as elkPadding,Ue as estimateMonoTextWidth,I as estimateTextWidth,Ni as evaluateCssColorValue,Gt as extractEdgeLabelPosition,Wt as extractEdgePoints,jo as formatTickLabels,Ha as hasLabelBelowIcon,Qi as layoutClassDiagramSync,Ea as layoutErDiagramSync,gr as layoutFlowchartSync,mr as layoutGraphSync,qo as layoutPieChart,es as layoutQuadrantChart,Ya as layoutSequenceDiagram,xo as layoutXYChart,be as loadEmbeddedFont,b as niceTickValues,Yo as pieColorValue,De as pointsToPath,Ne as registerElk,ia as renderClassSvg,ka as renderErSvg,Fc as renderMermaid,kc as renderMermaidSVG,Nc as renderMermaidSVGAsync,Pc as renderMermaidSync,Zo as renderPieSvg,as as renderQuadrantSvg,Xa as renderSequenceSvg,Dr as renderSvg,Po as renderXYChartSvg,zi as resolveCssColors,qe as resolveFontSizes,zo as smoothCurvePath,Ro as straightLinePath,Dc as themeCssVariables,jc as validateMermaid,wi as withDataSrc,Do as xLabelStep};
|
|
94
|
+
.quadrant-point { fill: var(--fg); stroke: var(--fg); stroke-width: 0px; }${[...s,...a].map(e=>`
|
|
95
|
+
`+e).join(``)}
|
|
96
|
+
</style>`}function rs(e,t){return e.text?`<text x="0" y="0" class="quadrant-text ${t}" font-size="${e.fontSize}" dominant-baseline="${e.baseline}" text-anchor="${e.anchor}" transform="translate(${es(e.x)}, ${es(e.y)}) rotate(${e.rotation})">${l(e.text)}</text>`:``}function is(e,t,r=`Inter`,i=!1,a,o,s,c={}){let l=[];l.push(wi(M(e.width,e.height,t,i,o,s,void 0,c.styleAttribute,c.description),a)),l.push(n(r,!1,c.nonce,c.bodyFont)),l.push(ns(e,c.nonce)),l.push(`<g class="quadrants">`);for(let t of e.quadrants)l.push(`<g class="quadrant"><rect x="${es(t.x)}" y="${es(t.y)}" width="${es(t.width)}" height="${es(t.height)}" class="quadrant-cell-${t.index}"/>${rs(t.text,`quadrant-label`)}</g>`);l.push(`</g>`),l.push(`<g class="border">`);for(let t of e.lines)l.push(`<line x1="${es(t.x1)}" y1="${es(t.y1)}" x2="${es(t.x2)}" y2="${es(t.y2)}" stroke-width="${t.strokeWidth}" class="quadrant-line quadrant-line-${t.kind}"/>`);l.push(`</g>`),l.push(`<g class="data-points">`),e.points.forEach((e,t)=>{let n=e.color||e.strokeColor||e.strokeWidth!==`0px`?` quadrant-point-${t}`:``;l.push(`<g class="data-point"><circle cx="${es(e.x)}" cy="${es(e.y)}" r="${e.radius}" class="quadrant-point${n}"/>${rs(e.text,`quadrant-point-label`)}</g>`)}),l.push(`</g>`),l.push(`<g class="labels">`);for(let t of e.axisLabels)l.push(`<g class="label">${rs(t,`quadrant-axis-label`)}</g>`);return l.push(`</g>`),l.push(`<g class="title">`),e.title&&l.push(rs(e.title,`quadrant-title`)),l.push(`</g>`),l.push(`</svg>`),l.join(`
|
|
97
|
+
`)}var as=2048,os=[569,569,727,1139,1139,1821,1366,391,682,682,797,1196,569,682,569,569,1139,1139,1139,1139,1139,1139,1139,1139,1139,1139,569,569,1196,1196,1196,1139,2079,1366,1366,1479,1479,1366,1251,1593,1479,569,1024,1366,1139,1706,1479,1593,1366,1593,1479,1366,1251,1479,1366,1933,1366,1366,1251,569,569,569,961,1139,682,1139,1139,1024,1139,1139,569,1139,1139,455,455,1024,455,1706,1139,1139,1139,1139,682,1024,569,1139,1024,1479,1024,1024,1024,684,532,684,1196],ss=[569,682,971,1139,1139,1821,1479,487,682,682,797,1196,569,682,569,569,1139,1139,1139,1139,1139,1139,1139,1139,1139,1139,682,682,1196,1196,1196,1251,1992,1479,1479,1479,1479,1366,1251,1593,1479,569,1139,1479,1251,1706,1479,1593,1366,1593,1479,1366,1251,1479,1366,1933,1366,1366,1251,682,569,682,1196,1139,682,1139,1251,1139,1251,1139,682,1251,1251,569,569,1139,569,1821,1251,1251,1251,1251,797,1139,682,1251,1139,1593,1139,1139,1024,801,573,801,1196];function cs(e,t){let n=e.codePointAt(0);if(!(n<32||n>126))return(t?ss:os)[n-32]/as}var $={width:216,diagramMarginX:50,diagramMarginY:10,shapeMargin:50,shapePadding:20,shapeInRow:4,boundaryInRow:2,nextLinePaddingX:0,screenWidth:1440,nameSize:14,typeSize:10.5,descrSize:11.5,messageSize:12,boundarySize:14,nameLine:15.35,typeLine:15.72,descrLine:17.1,descrExtraLine:12.48,textScale:.922,boundaryLabelHeight:18,boundaryTypeHeight:16.1,boundaryDescrHeight:14.4,rootHeadingHeight:47,titleExtra:60,cornerRadius:12,strokeWidth:2,personRx:.177,personRxMaxOfHeight:.45,personHeadRatio:.23,personHeadMin:16,personHeadMax:56,personHeadOverlap:.27,dbTrim:3.91,queueExtra:10},ls=$.width-2*$.shapePadding;function us(e,t,n){let r=[];for(let i of e.split(`
|
|
98
|
+
`)){let e=``;for(let a of i.split(/\s+/).filter(Boolean)){let i=e?`${e} ${a}`:a;e&&gs(i,n,400)>t?(r.push(e),e=a):e=i}r.push(e)}return r}function ds(e,t){let n=Math.min(Math.max(e*$.personHeadRatio,$.personHeadMin),$.personHeadMax),r=n*(2-$.personHeadOverlap),i=t===void 0?1/0:t-r;return{rx:Math.min(e*$.personRx,i*$.personRxMaxOfHeight),headRadius:n,pillTop:r}}function fs(e,t){return e*$.nameLine+$.typeLine+ps(t)}function ps(e){return e===0?0:$.descrLine+(e-1)*$.descrExtraLine}function ms(e){let t=e/2;return{rx:t,ry:t/(2.5+e/50)}}function hs(e){let t=e/2;return{rx:t/(2.5+e/50),ry:t}}function gs(e,t,n){let r=0;for(let i of e){let e=cs(i,n>=600);r+=e===void 0?I(i,t,n)*$.textScale:e*t}return r}function _s(e,t,n,r){let i=fs(t,n),a=i+2*$.shapePadding,o=Math.max($.width,r+2*$.shapePadding);if(e.kind===`person`)return{width:o,height:ds(o).pillTop+a,textHeight:i};if(e.shape===`db`){let{ry:e}=ms(o);return{width:o,height:a+2*e-$.dbTrim,textHeight:i}}if(e.shape===`queue`){let e=i+$.queueExtra,{rx:t}=hs(e);return{width:o+3*t,height:e,textHeight:i}}return{width:o,height:a,textHeight:i}}function vs(e){let t=`#ffffff`;if(e.external)switch(e.kind){case`person`:return{fill:`#686868`,stroke:`#8a8a8a`,text:t};case`system`:return{fill:`#999999`,stroke:`#8a8a8a`,text:t};case`container`:return{fill:`#b3b3b3`,stroke:`#a6a6a6`,text:t};case`component`:return{fill:`#cccccc`,stroke:`#bfbfbf`,text:t}}switch(e.kind){case`person`:return{fill:`#08427b`,stroke:`#073b6f`,text:t};case`system`:return{fill:`#1168bd`,stroke:`#3c7fc0`,text:t};case`container`:return{fill:`#438dd5`,stroke:`#3c7fc0`,text:t};case`component`:return{fill:`#85bbf0`,stroke:`#78a8d8`,text:t}}}var ys=$.messageSize+5;function bs(e){return e.labelLines??ae(e)}function xs(e){let t=e.labelPosition;return t?bs(e).map((n,r,i)=>({cx:e.technology!==void 0&&r===i.length-1&&e.technologyX!==void 0?e.technologyX:t.x,cy:t.y+r*ys,w:gs(n,$.messageSize,400),h:$.messageSize})):[]}function Ss(){return{next:{cnt:0}}}function Cs(e,t,n,r,i){e.next.startx=e.startx=t,e.next.stopx=e.stopx=n,e.next.starty=e.starty=r,e.next.stopy=e.stopy=i}function ws(e,t,n,r){let i=e[t];e[t]=i===void 0?n:r(n,i)}function Ts(e,t){e.next.cnt+=1;let n=$.shapeMargin,r=e.next.startx===e.next.stopx?e.next.stopx+n:e.next.stopx+n*2,i=r+t.width,a=e.next.starty+n*2,o=a+t.height;(r>=e.widthLimit||i>=e.widthLimit||e.next.cnt>$.shapeInRow)&&(r=e.next.startx+n+$.nextLinePaddingX,a=e.next.stopy+n*2,e.next.stopx=i=r+t.width,e.next.starty=e.next.stopy,e.next.stopy=o=a+t.height,e.next.cnt=1),t.x=r,t.y=a,ws(e,`startx`,r,Math.min),ws(e,`starty`,a,Math.min),ws(e,`stopx`,i,Math.max),ws(e,`stopy`,o,Math.max),ws(e.next,`startx`,r,Math.min),ws(e.next,`starty`,a,Math.min),ws(e.next,`stopx`,i,Math.max),ws(e.next,`stopy`,o,Math.max)}function Es(e){let t=us(e.label,ls,$.nameSize),n=e.description?us(e.description,ls,$.descrSize):[],r=Math.max(...t.map(e=>gs(e,$.nameSize,700)),gs(oe(e),$.typeSize,400),...n.map(e=>gs(e,$.descrSize,400)));return{el:e,nameLines:t,descriptionLines:n,x:0,y:0,..._s(e,t.length,n.length,r)}}function Ds(e){let t=new Set,n=new Map(e.elements.map(e=>[e.alias,e])),r=e=>{let i=e.elementAliases.flatMap(e=>{t.add(e);let r=n.get(e);return r?[r]:[]});return{alias:e.alias,boundary:e,elements:i,children:e.children.map(r)}},i=e.boundaries.map(r);return{alias:`global`,elements:e.elements.filter(e=>!t.has(e.alias)),children:i}}function Os(e){let t=new Map,n=[],r=$.diagramMarginX,i=$.diagramMarginY,a=(e,n)=>{for(let r of n){let n=Es(r);t.set(r.alias,n),Ts(e,n)}e.stopx+=$.shapeMargin,e.stopy+=$.shapeMargin},o=(e,t,s)=>{let c=Ss();c.widthLimit=e.widthLimit/Math.min($.boundaryInRow,t.length);for(let[l,u]of t.entries()){let t=u.boundary,d=0,f=d+8;d=f+$.boundaryLabelHeight;let p;t&&ie(t)&&(p=d+5,d=p+$.boundaryTypeHeight);let m;if(t?.description&&(m=d+20,d=m+$.boundaryDescrHeight),t||(d=$.rootHeadingHeight),l===0||l%$.boundaryInRow===0){let t=e.startx+$.diagramMarginX,n=e.stopy+$.diagramMarginY+d;Cs(c,t,t,n,n)}else{let e=c.stopx===c.startx?c.startx:c.stopx+$.diagramMarginX;Cs(c,e,e,c.starty,c.starty)}if(u.elements.length>0&&a(c,u.elements),u.children.length>0&&o(c,u.children,s+1),t){let e=c.stopx-c.startx,r=c.stopy-c.starty;e===0&&(e=$.width,c.stopx=c.startx+e),r===0&&(r=d+$.shapeMargin),n.push({alias:t.alias,label:t.label,...t.type?{type:t.type}:{},...t.description?{description:t.description}:{},x:c.startx,y:c.starty,width:e,height:r,depth:s,labelY:f,...p===void 0?{}:{typeY:p},...m===void 0?{}:{descrY:m}})}e.stopy=Math.max(c.stopy+$.shapeMargin,e.stopy),e.stopx=Math.max(c.stopx+$.shapeMargin,e.stopx),r=Math.max(r,e.stopx),i=Math.max(i,e.stopy)}},s=Ss();return Cs(s,$.diagramMarginX,$.diagramMarginX,$.diagramMarginY,$.diagramMarginY),s.widthLimit=$.screenWidth,o(s,[e],-1),{elements:t,boundaries:n,maxX:r,maxY:i}}function ks(e,t){let n=e.x+e.width/2,r=e.y+e.height/2,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(i===0&&a===0)return{x:n,y:r};let c,l;if(Math.abs(a)*o>Math.abs(i)*s){let e=a<0?-s:s;c=e*i/a,l=e}else{let e=i<0?-o:o;c=e,l=e*a/i}return{x:n+c,y:r+l}}function As(e,t){let n=ds(e.width,e.height),r=e.x+e.width/2,i=e.y+e.height/2,a=e.width,o=e.height,s=-o/2+n.headRadius,c=-o/2+n.pillTop,l=n.rx,u=(e,t,n,r,i,a)=>Array.from({length:r},(o,s)=>{let c=(i+s*(a-i)/(r-1))*Math.PI/180;return{x:e-n*Math.cos(c),y:t-n*Math.sin(c)}}),d=Math.asin(Math.min(1,(c-s)/n.headRadius))*180/Math.PI,f=[...u(0,s,n.headRadius,24,180+d,-d),...u(-a/2+l,c+l,l,12,90,0),...u(-a/2+l,o/2-l,l,12,360,270),...u(a/2-l,o/2-l,l,12,270,180),...u(a/2-l,c+l,l,12,180,90)];return Ms({x:r,y:i},t,f.map(e=>({x:r+e.x,y:i+e.y})))}function js(e,t,n,r){let i=t.y-e.y,a=e.x-t.x,o=t.x*e.y-e.x*t.y,s=i*n.x+a*n.y+o,c=i*r.x+a*r.y+o;if(s!==0&&c!==0&&s*c>0)return;let l=r.y-n.y,u=n.x-r.x,d=r.x*n.y-n.x*r.y,f=l*e.x+u*e.y+d,p=l*t.x+u*t.y+d;if(f!==0&&p!==0&&f*p>0)return;let m=i*u-l*a;if(m===0)return;let h=Math.abs(m/2),g=a*d-u*o,_=g<0?(g-h)/m:(g+h)/m;return g=l*o-i*d,{x:_,y:g<0?(g-h)/m:(g+h)/m}}function Ms(e,t,n){let r,i=1/0;return n.forEach((a,o)=>{let s=js(e,t,a,n[(o+1)%n.length]);if(!s)return;let c=Math.hypot(s.x-t.x,s.y-t.y);c<i&&(r=s,i=c)}),r??e}var Ns=1e-6;function Ps(e,t){let n=ks(e,t),r=e.x+e.width/2,i=e.y+e.height/2,{rx:a,ry:o}=ms(e.width),s=n.x-r,c=Math.abs(s)<e.width/2-Ns||Math.abs(Math.abs(s)-e.width/2)<=Ns&&Math.abs(n.y-i)>e.height/2-o;if(a===0||!c)return n;let l=o*o*(1-s*s/(a*a)),u=o-(l>0?Math.sqrt(l):l);return t.y-i>0&&(u=-u),{x:n.x,y:n.y+u}}function Fs(e,t){let n=ks(e,t),r=e.x+e.width/2,i=e.y+e.height/2,{rx:a,ry:o}=hs(e.height),s=n.y-i,c=Math.abs(s)<e.height/2-Ns||Math.abs(Math.abs(s)-e.height/2)<=Ns&&Math.abs(n.x-r)>e.width/2-a;if(o===0||!c)return n;let l=a*a*(1-s*s/(o*o)),u=a-Math.sqrt(Math.abs(l));return t.x-r>0&&(u=-u),{x:n.x+u,y:n.y}}function Is(e,t){let n=e.el;return n?.kind===`person`?As(e,t):n?.shape===`db`?Ps(e,t):n?.shape===`queue`?Fs(e,t):ks(e,t)}var Ls=e=>({x:e.x+e.width/2,y:e.y+e.height/2});function Rs(e,t,n,r){let i=n.get(e.from),a=n.get(e.to),o=Is(i,Ls(a)),s=Is(a,Ls(i)),c=s.x-o.x,l=s.y-o.y,u=e=>({x:e.x,y:e.y+r}),d={...e,points:[u(o),u(s)]};if(t>0&&(d.curve=u({x:o.x+c/2-c/4,y:o.y+l/2})),ae(e).length>0){let t={x:Math.min(o.x,s.x)+Math.abs(c)/2,y:Math.min(o.y,s.y)+Math.abs(l)/2},n=ae(e)[0],r=e.label!==``||e.index!==void 0?gs(n??``,$.messageSize,400):0;if(d.labelPosition=u({x:t.x+r/2,y:t.y}),e.technology){let n=gs(`[${e.technology}]`,$.messageSize,400);d.technologyX=t.x+Math.max(r,n)/2}}return d}var zs=2,Bs=6,Vs=2,Hs=[0,14,-14,28,-28],Us=[.75,.55,.4],Ws=1e3,Gs=100,Ks=10,qs=2,Js=5,Ys=4,Xs=e=>({x0:e.cx-e.w/2,x1:e.cx+e.w/2,y0:e.cy-e.h/2,y1:e.cy+e.h/2}),Zs=(e,t)=>e.x0<t.x1+zs&&e.x1>t.x0-zs&&e.y0<t.y1+zs&&e.y1>t.y0-zs;function Qs(e){let t=e.points[0],n=e.points[e.points.length-1],r=e.curve,i=Math.hypot(n.x-t.x,n.y-t.y),a=Math.max(1,Math.ceil(i/Ys));return Array.from({length:a+1},(e,i)=>{let o=i/a;if(!r)return{x:t.x+(n.x-t.x)*o,y:t.y+(n.y-t.y)*o};let s=1-o;return{x:s*s*t.x+2*s*o*r.x+o*o*n.x,y:s*s*t.y+2*s*o*r.y+o*o*n.y}})}function $s(e){return e.flatMap(e=>{let t=(e,t,n,r,i)=>({x0:e-i,x1:t+i,y0:n-i,y1:r+i,weight:Gs}),n=(n,r,i,a)=>{let o=gs(n,i,a),s=e.x+e.width/2;return t(s-o/2,s+o/2,e.y+r-i/2,e.y+r+i/2,Js)},r=ie({...e,elementAliases:[],children:[]});return[t(e.x,e.x+e.width,e.y,e.y,qs),t(e.x,e.x+e.width,e.y+e.height,e.y+e.height,qs),t(e.x,e.x,e.y,e.y+e.height,qs),t(e.x+e.width,e.x+e.width,e.y,e.y+e.height,qs),n(e.label,e.labelY,$.boundarySize+2,700),...r?[n(r,e.typeY,$.boundarySize,400)]:[],...e.description?[n(e.description,e.descrY,$.boundarySize-2,400)]:[]]})}function ec(e,t){return xs({...e,labelLines:t.lines,labelPosition:t.position,...t.technologyX===void 0?{}:{technologyX:t.technologyX}}).map(Xs)}function tc(e,t,n,r){let i=e.points[0],a=e.points[e.points.length-1],o=e.labelPosition;if(!o||!i||!a)return;let s=a.x-i.x,c=a.y-i.y,l=Math.hypot(s,c),u=ae(e),d=e.label!==``||e.index!==void 0,f=d?gs(u[0],$.messageSize,400):0,p=o.x-f/2,m=[{variant:{lines:u,position:o,...e.technologyX===void 0?{}:{technologyX:e.technologyX}},cost:0}];if(d){let t=e.technology?[`[${e.technology}]`]:[],n=new Set([u.join(`
|
|
99
|
+
`)]);Us.forEach((e,r)=>{let i=us(u[0],f*e,$.messageSize),a=[...i,...t].join(`
|
|
100
|
+
`);if(n.has(a))return;n.add(a);let s=Math.max(...i.map(e=>gs(e,$.messageSize,400)));m.push({variant:{lines:[...i,...t],position:{x:p+s/2,y:o.y}},cost:25*(r+1)})})}let h=l===0?0:s/l,g=l===0?0:c/l,_=l/2+Math.max(...Hs)+zs,v=m.flatMap(t=>ec(e,t.variant)),y={x0:Math.min(...v.map(e=>e.x0))-_,x1:Math.max(...v.map(e=>e.x1))+_,y0:Math.min(...v.map(e=>e.y0))-_,y1:Math.max(...v.map(e=>e.y1))+_},b=e=>e.x0<y.x1&&e.x1>y.x0&&e.y0<y.y1&&e.y1>y.y0,x=[...t,...r].filter(b),S=Math.max(Vs,l/200),C=n.filter(e=>b({x0:Math.min(...e.map(e=>e.x)),x1:Math.max(...e.map(e=>e.x)),y0:Math.min(...e.map(e=>e.y)),y1:Math.max(...e.map(e=>e.y))})),w=C.map(e=>({x0:Math.min(...e.map(e=>e.x)),x1:Math.max(...e.map(e=>e.x)),y0:Math.min(...e.map(e=>e.y)),y1:Math.max(...e.map(e=>e.y))})),T,E=e=>T?.penalty===0&&e>=T.cost;for(let{variant:t,cost:n}of m){let r=ec(e,t);for(let e of Hs)if(!E(n+2*Math.abs(e)))for(let i=0;i<=l/2&&!E(n+2*Math.abs(e)+i);i+=S)for(let a of i===0?[1]:[1,-1]){let o=a*i,s={x:o*h-e*g,y:o*g+e*h},c=r.map(e=>({x0:e.x0+s.x,x1:e.x1+s.x,y0:e.y0+s.y,y1:e.y1+s.y})),l=0,u=T?.penalty??1/0;for(let e of c){if(l>u)break;for(let t of x)if(Zs(e,t)&&(l+=t.weight),l>u)break;if(l>u)break;for(let[t,n]of C.entries()){let r=w[t];r.x1<=e.x0||r.x0>=e.x1||r.y1<=e.y0||r.y0>=e.y1||n.some(t=>t.x>e.x0&&t.x<e.x1&&t.y>e.y0&&t.y<e.y1)&&(l+=Ks)}}let d=n+i+2*Math.abs(e);(!T||l<T.penalty||l===T.penalty&&d<T.cost)&&(T={v:t,at:s,penalty:l,cost:d})}}let{v:D,at:O}=T;e.labelPosition={x:D.position.x+O.x,y:D.position.y+O.y},D.lines!==u&&(e.labelLines=D.lines),D.technologyX===void 0?delete e.technologyX:e.technologyX=D.technologyX+O.x,r.push(...xs(e).map(e=>({...Xs(e),weight:Gs})))}function nc(e,t={}){if(e.elements.length===0&&e.boundaries.length===0){let t={variant:e.variant,width:0,height:0,elements:[],boundaries:[],relationships:[]};if(e.title){let n=2*$.diagramMarginY+$.titleExtra;t.title=e.title,t.width=Math.ceil(2*$.diagramMarginX+gs(e.title,16,400)),t.height=n,t.titlePosition={x:$.diagramMarginX,y:n/2}}return t}let n=Os(Ds(e)),r=e.title?$.titleExtra:0,i=$.diagramMarginY+r,a=e.elements.flatMap(e=>{let t=n.elements.get(e.alias);return t?[{...e,x:t.x,y:t.y+i,width:t.width,height:t.height,nameLines:t.nameLines,descriptionLines:t.descriptionLines}]:[]}),o=[...n.boundaries].sort((e,t)=>e.depth-t.depth).map(e=>({...e,y:e.y+i})),s=new Map;for(let e of n.elements.values())s.set(e.el.alias,e);for(let e of n.boundaries)s.set(e.alias,e);let c=e.relationships.map((e,t)=>Rs(e,t,s,i)),l=[...a.map(e=>({x0:e.x-Bs,x1:e.x+e.width+Bs,y0:e.y-Bs,y1:e.y+e.height+Bs,weight:Ws})),...$s(o)],u=c.map(Qs),d=[];c.forEach((e,t)=>tc(e,l,u.filter((e,n)=>n!==t),d));let f=n.maxX+$.diagramMarginX,p=n.maxY+$.diagramMarginY+r,m={variant:e.variant,width:f,height:p,elements:a,boundaries:o,relationships:c};return e.title&&(m.title=e.title,m.titlePosition={x:(n.maxX-$.diagramMarginX)/2-4*$.diagramMarginX,y:$.diagramMarginY+$.diagramMarginY+i}),m}function rc(e,t,r=`Inter`,i=!1,a=Ke,o,s,c,u={}){let f=[];f.push(wi(M(e.width,e.height,t,i,s??e.title,c,void 0,u.styleAttribute,u.description),o)),f.push(n(r,!1,u.nonce,u.bodyFont)),e.title&&e.titlePosition&&f.push(d`<text class="c4-title" x="${e.titlePosition.x}" y="${e.titlePosition.y}" dy="${z}" `+d`font-size="16" fill="var(--_text)">${l(e.title)}</text>`);for(let t of e.boundaries)f.push(ac(t));for(let t of e.elements)f.push(oc(t));for(let t of e.relationships)f.push(mc(t));for(let t of e.relationships)f.push(hc(t));return f.push(`</svg>`),f.filter(Boolean).join(`
|
|
101
|
+
`)}function ic(e,t,n,r,i){return d` <text x="${t}" y="${n}" text-anchor="middle" dy="${z}" font-size="${r}" `+d`${i}>${l(e)}</text>`}function ac(e){let t=[];t.push(d`<g class="c4-boundary" data-id="${c(e.alias)}" data-label="${c(e.label)}" data-depth="${e.depth}">`),t.push(d` <rect x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" rx="2.5" ry="2.5" `+`fill="none" stroke="var(--_text)" stroke-width="1" stroke-dasharray="7,7" />`);let n=e.x+e.width/2;t.push(ic(e.label,n,e.y+(e.labelY??8),$.boundarySize+2,`font-weight="700" fill="var(--_text)"`));let r=ie({alias:e.alias,label:e.label,...e.type?{type:e.type}:{},elementAliases:[],children:[]});return r&&e.typeY!==void 0&&t.push(ic(r,n,e.y+e.typeY,$.boundarySize,`fill="var(--_text)"`)),e.description&&e.descrY!==void 0&&t.push(ic(e.description,n,e.y+e.descrY,$.boundarySize-2,`fill="var(--_text)"`)),t.push(`</g>`),t.join(`
|
|
102
|
+
`)}function oc(e){let t=vs(e),{x:n,y:r,width:i,height:a}=e,o=n+i/2,s=fs(e.nameLines.length,e.descriptionLines.length),l=[];l.push(d`<g class="c4-element" data-id="${c(e.alias)}" data-kind="${e.kind}" data-shape="${e.shape}" `+d`data-external="${e.external}" data-label="${c(e.label)}">`);let u,f=o;if(e.kind===`person`)l.push(...cc(e,t)),u=r+ds(i).pillTop+$.shapePadding;else if(e.shape===`db`){l.push(...lc(e,t));let{ry:n}=ms(i);u=r+(2*n+a)/2-s/2}else if(e.shape===`queue`){l.push(...uc(e,t));let{rx:n}=hs(a);f=o-n,u=r+a/2-s/2}else l.push(d` <rect x="${n}" y="${r}" width="${i}" height="${a}" rx="${$.cornerRadius}" ry="${$.cornerRadius}" `+d`fill="${t.fill}" stroke="${t.stroke}" stroke-width="${$.strokeWidth}" />`),u=r+$.shapePadding;let p=u;for(let n of e.nameLines)l.push(ic(n,f,p+$.nameLine/2,$.nameSize,d`font-weight="700" fill="${t.text}"`)),p+=$.nameLine;return l.push(ic(oe(e),f,p+$.typeLine/2,$.typeSize,d`fill="${t.text}"`)),p+=$.typeLine,e.descriptionLines.forEach((e,n)=>{l.push(ic(e,f,p+$.descrLine/2+n*$.descrExtraLine,$.descrSize,d`fill="${t.text}"`))}),p+=ps(e.descriptionLines.length),l.push(`</g>`),l.join(`
|
|
103
|
+
`)}function sc(e){let{x:t,y:n,width:r,height:i}=e,{rx:a,headRadius:o,pillTop:s}=ds(r,i),c=t+r/2,l=n+s,u=n+i,f=Math.sqrt(Math.max(0,o*o-(l-(n+o))**2));return d`M ${t+a} ${l} H ${c-f} A ${o} ${o} 0 1 1 ${c+f} ${l} `+d`H ${t+r-a} A ${a} ${a} 0 0 1 ${t+r} ${l+a} V ${u-a} `+d`A ${a} ${a} 0 0 1 ${t+r-a} ${u} H ${t+a} `+d`A ${a} ${a} 0 0 1 ${t} ${u-a} V ${l+a} `+d`A ${a} ${a} 0 0 1 ${t+a} ${l} Z`}function cc(e,t){return[d` <path class="c4-person-shape" d="${sc(e)}" fill="${t.fill}" stroke="${t.stroke}" stroke-width="${$.strokeWidth}" />`]}function lc(e,t){let{x:n,y:r,width:i,height:a}=e,{rx:o,ry:s}=ms(i),c=d`fill="${t.fill}" stroke="${t.stroke}" stroke-width="${$.strokeWidth}"`;return[d` <path d="M ${n} ${r+s} L ${n} ${r+a-s} A ${o} ${s} 0 0 0 ${n+i} ${r+a-s} L ${n+i} ${r+s} Z" ${c} />`,d` <ellipse cx="${n+o}" cy="${r+s}" rx="${o}" ry="${s}" ${c} />`]}function uc(e,t){let{x:n,y:r,width:i,height:a}=e,{rx:o,ry:s}=hs(a),c=d`fill="${t.fill}" stroke="${t.stroke}" stroke-width="${$.strokeWidth}"`;return[d` <path d="M ${n+i-o} ${r} H ${n+o} A ${o} ${s} 0 0 0 ${n+o} ${r+a} H ${n+i-o} Z" ${c} />`,d` <ellipse cx="${n+i-o}" cy="${r+s}" rx="${o}" ry="${s}" ${c} />`]}function dc(e,t){let n=e.x-t.x,r=e.y-t.y,i=Math.hypot(n,r);if(i===0)return``;let a=n/i,o=r/i,s=e.x-a*10,c=e.y-o*10;return d`<polygon class="c4-arrowhead" points="${e.x},${e.y} ${s-o*5},${c+a*5} ${s+o*5},${c-a*5}" `+`fill="var(--_text)" />`}var fc=3,pc=1;function mc(e){let[t,n]=[e.points[0],e.points[e.points.length-1]];if(!t||!n||t===n)return``;let r=[`class="c4-relationship"`,d`data-from="${c(e.from)}"`,d`data-to="${c(e.to)}"`];e.label&&r.push(d`data-label="${c(e.label)}"`),e.technology&&r.push(d`data-technology="${c(e.technology)}"`);let i=e.curve?d`M ${t.x},${t.y} Q ${e.curve.x},${e.curve.y} ${n.x},${n.y}`:d`M ${t.x},${t.y} L ${n.x},${n.y}`,a=d`<path ${r.join(` `)} d="${i}" fill="none" stroke="var(--_text)" stroke-width="1" />`,o=e.curve??t,s=e.curve??n,l=dc(n,o),u=dc(t,s);return[a,...e.bidirectional?[l,u]:[e.reversed?u:l]].filter(Boolean).join(`
|
|
104
|
+
`)}function hc(e){let t=bs(e),n=xs(e);if(n.length===0)return``;let r=[d`<g class="c4-relationship-label" data-from="${c(e.from)}" data-to="${c(e.to)}">`],i=Math.min(...n.map(e=>e.cx-e.w/2))-fc,a=Math.max(...n.map(e=>e.cx+e.w/2))+fc,o=n[0].cy-n[0].h/2-pc,s=n[n.length-1],l=s.cy+s.h/2+pc;return r.push(d` <rect class="c4-label-plate" x="${i}" y="${o}" width="${a-i}" height="${l-o}" rx="2" ry="2" fill="var(--bg)" />`),t.forEach((i,a)=>{let o=e.technology!==void 0&&a===t.length-1,s=n[a];r.push(ic(i,s.cx,s.cy,$.messageSize,o?`font-style="italic" fill="var(--_text)"`:`fill="var(--_text)"`))}),r.push(`</g>`),r.join(`
|
|
105
|
+
`)}var gc={type:`xychart`,parse:_e,layoutForSvg:yo,renderSvg(e,t,n){let r=n.interactivity===void 0?n.interactive??!1:n.interactivity===`full`;return Mo(e,t.colors,t.font,t.transparent,r,t.embedSource,t.title,t.decorative,t.emit)}},_c={type:`sequence`,parse:ge,layoutForSvg:Ja,renderSvg(e,t){return Ya(e,t.colors,t.font,t.transparent,t.fontSizes,t.embedSource,t.title,t.decorative,t.emit)}};function vc(e){return(e.interactivity??`static`)!==`none`}function yc(e){return(e.interactivity??`static`)===`full`}var bc={type:`class`,parse:de,layoutForSvg:Qi,renderSvg(e,t,n){return ia(e,t.colors,t.font,t.transparent,t.fontSizes,t.embedSource,t.title,t.decorative,vc(n),t.emit)}},xc={type:`er`,parse:fe,layoutForSvg(e,t){return Ea(P(e,t.direction),t)},renderSvg(e,t){return ka(e,t.colors,t.font,t.transparent,t.fontSizes,t.embedSource,t.title,t.decorative,t.emit)}},Sc={type:`flowchart`,parse:(e,t)=>pe(t),layoutForSvg(e,t){return{graph:gr(P(e,t.direction),t),curve:t.curve??e.initConfig?.curve??`linear`}},renderSvg(e,t,n){return Dr(e.graph,t.colors,t.font,t.transparent,t.fontSizes,e.curve,t.embedSource,yc(n),vc(n),t.title,t.decorative,t.emit)}},Cc={type:`c4`,parse:ue,layoutForSvg(e,t){return nc(e,t)},renderSvg(e,t){return rc(e,t.colors,t.font,t.transparent,t.fontSizes,t.embedSource,t.title,t.decorative,t.emit)}},wc={xychart:gc,er:xc,sequence:_c,class:bc,flowchart:Sc,architecture:{type:`architecture`,parse:le,layoutForSvg(e,t){return{graph:mr(P(re(e),t.direction),t),curve:t.curve??`linear`}},renderSvg:Sc.renderSvg},c4:Cc,pie:{type:`pie`,parse:(e,t)=>me(t),layoutForSvg:(e,t)=>Go(t.honorThemeVariables?e:{...e,sliceColors:void 0},t),renderSvg(e,t){return Yo(e,t.colors,t.font,t.transparent,t.embedSource,t.title,t.decorative,t.emit)}},quadrant:{type:`quadrant`,parse:(e,t)=>he(t),layoutForSvg:(e,t)=>$o(t.honorThemeVariables?e:{...e,themeColors:void 0}),renderSvg(e,t){return is(e,t.colors,t.font,t.transparent,t.embedSource,t.title,t.decorative,t.emit)}}};function Tc(t){return{bg:t.bg??e.bg,fg:t.fg??e.fg,line:t.line,accent:t.accent,muted:t.muted??(t.bg||t.fg?void 0:e.muted),surface:t.surface,border:t.border}}function Ec(e={}){return N(Tc(e),e.transparent)}function Dc(e){return{nonce:e.nonce,styleAttribute:e.styleAttribute,bodyFont:xe(e)}}function Oc(e,t={}){let{svg:n,colors:r}=jc(e,t),i=kc(n);return t.resolveColors?zi(i,r):i}function kc(e){let t=new Set(Array.from(e.matchAll(/\sid="([^"]+)"/g),e=>e[1]??``));if(t.size===0)return e;let n=2166136261;for(let t=0;t<e.length;t++)n=Math.imul(n^e.charCodeAt(t),16777619);let r=`zm${(n>>>0).toString(36)}-`,i=e=>t.has(e)&&!e.startsWith(`zm-`)?r+e:e;return e.replace(/(\sid=")([^"]+)"/g,(e,t,n)=>`${t}${i(n)}"`).replace(/url\(#([^)]+)\)/g,(e,t)=>`url(#${i(t)})`).replace(/(href=")#([^"]+)"/g,(e,t,n)=>`${t}#${i(n)}"`)}function Ac(e){let t=u(ve(e)).text;wc[o(t)].parse(k(t),t)}function jc(e,n){i(`maxInputLength`,e.length,n.limits),a(e,n.limits);let s=u(ve(e)),c=s.text,l=n.font??`Inter`;O(g(l));let d=n.transparent??!1,f=qe(n.fontSizes),p=o(c),m=n.embedSource?e:void 0,h=n.title??s.accTitle,_=n.decorative,v={...Dc(n),description:s.accDescr},y=k(c),b=wc[p],x=b.parse(y,c),S=x;S.nodes instanceof Map&&Array.isArray(S.edges)&&r(S.nodes.size,S.edges.length,n.limits);let C=b.layoutForSvg(x,n),w=Tc(n.honorThemeVariables?t(n,x.initConfig):n),T={colors:w,font:l,transparent:d,fontSizes:f,embedSource:m,title:h,decorative:_,emit:v};return{svg:b.renderSvg(C,T,n),colors:w}}async function Mc(e,t={}){return t.embedFont===`subset`&&await be(),Oc(e,t)}var Nc=Oc,Pc=Mc;export{Ba as ACTOR_LABEL_OFFSET,Ze as ARROW_HEAD,Ye as ASYMMETRIC_NOTCH,W as CLS,$e as ELK_DIRECTION_FALLBACK,Me as ElkNotRegisteredError,Ke as FONT_SIZES,L as FONT_WEIGHTS,Je as GROUP_HEADER_CONTENT_PAD,it as INLINE_CENTERED_EDGE_LABEL,We as MONO_FONT,Ge as MONO_FONT_STACK,Xe as NODE_PADDING,Z as PIE,Xo as QUADRANT,R as STROKE_WIDTHS,z as TEXT_BASELINE_SHIFT,nt as baseElkLayoutOptions,za as boxLabelHeight,ot as buildElkEdge,at as buildElkEdgeLabel,rt as buildElkLeafNode,Qe as buildSvgStyleBlock,Yi as classBackEdges,Wi as classNoteId,Ot as clipEdgeToShape,_r as convertToElkFormat,Le as createLayoutCache,et as directionToElk,Be as elkLayoutSync,tt as elkPadding,Ue as estimateMonoTextWidth,I as estimateTextWidth,Ni as evaluateCssColorValue,Gt as extractEdgeLabelPosition,Wt as extractEdgePoints,ko as formatTickLabels,Ha as hasLabelBelowIcon,Qi as layoutClassDiagramSync,Ea as layoutErDiagramSync,gr as layoutFlowchartSync,mr as layoutGraphSync,Go as layoutPieChart,$o as layoutQuadrantChart,Ja as layoutSequenceDiagram,yo as layoutXYChart,be as loadEmbeddedFont,b as niceTickValues,qo as pieColorValue,De as pointsToPath,Ne as registerElk,ia as renderClassSvg,ka as renderErSvg,Pc as renderMermaid,Oc as renderMermaidSVG,Mc as renderMermaidSVGAsync,Nc as renderMermaidSync,Yo as renderPieSvg,is as renderQuadrantSvg,Ya as renderSequenceSvg,Dr as renderSvg,Mo as renderXYChartSvg,zi as resolveCssColors,qe as resolveFontSizes,Lo as smoothCurvePath,Io as straightLinePath,Ec as themeCssVariables,Ac as validateMermaid,wi as withDataSrc,To as xLabelStep};
|
package/dist/shared/index.d.ts
CHANGED
|
@@ -489,19 +489,33 @@ export declare function pointsToPath(points: Point[], curve?: CurveStyle): strin
|
|
|
489
489
|
|
|
490
490
|
/** Mermaid's default `quadrantChart` config. */
|
|
491
491
|
export declare const QUADRANT: {
|
|
492
|
-
readonly width: 500;
|
|
493
|
-
readonly height: 500;
|
|
494
492
|
readonly titlePadding: 10;
|
|
495
493
|
readonly titleFontSize: 20;
|
|
496
494
|
readonly quadrantPadding: 5;
|
|
497
|
-
readonly
|
|
498
|
-
readonly
|
|
495
|
+
readonly xAxisLabelPadding: 5;
|
|
496
|
+
readonly yAxisLabelPadding: 5;
|
|
497
|
+
readonly xAxisLabelFontSize: 16;
|
|
498
|
+
readonly yAxisLabelFontSize: 16;
|
|
499
499
|
readonly quadrantLabelFontSize: 16;
|
|
500
500
|
readonly quadrantTextTopPadding: 5;
|
|
501
501
|
readonly pointTextPadding: 5;
|
|
502
502
|
readonly pointLabelFontSize: 12;
|
|
503
503
|
readonly pointRadius: 5;
|
|
504
|
+
readonly quadrantInternalBorderStrokeWidth: 1;
|
|
505
|
+
readonly quadrantExternalBorderStrokeWidth: 2;
|
|
506
|
+
readonly xAxisPosition: "top";
|
|
507
|
+
readonly yAxisPosition: "left";
|
|
508
|
+
/** @deprecated Use `chartWidth`; removed in the next major. */
|
|
509
|
+
readonly width: 500;
|
|
510
|
+
/** @deprecated Use `chartHeight`; removed in the next major. */
|
|
511
|
+
readonly height: 500;
|
|
512
|
+
/** @deprecated Use `xAxisLabelPadding` / `yAxisLabelPadding`; removed in the next major. */
|
|
513
|
+
readonly axisLabelPadding: 5;
|
|
514
|
+
/** @deprecated Use `xAxisLabelFontSize` / `yAxisLabelFontSize`; removed in the next major. */
|
|
515
|
+
readonly axisLabelFontSize: 16;
|
|
516
|
+
/** @deprecated Use `quadrantInternalBorderStrokeWidth`; removed in the next major. */
|
|
504
517
|
readonly internalBorderWidth: 1;
|
|
518
|
+
/** @deprecated Use `quadrantExternalBorderStrokeWidth`; removed in the next major. */
|
|
505
519
|
readonly externalBorderWidth: 2;
|
|
506
520
|
};
|
|
507
521
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zombie-mermaid/svg-renderer",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.14.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "SVG rendering primitives and the ELK-backed layout engine behind zombie-mermaid's SVG output (maintained continuation of beautiful-mermaid).",
|
|
6
6
|
"keywords": [
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"entities": "^7.0.1",
|
|
53
|
-
"@zombie-mermaid/
|
|
54
|
-
"@zombie-mermaid/
|
|
53
|
+
"@zombie-mermaid/mermaid-parser": "5.14.0",
|
|
54
|
+
"@zombie-mermaid/core": "5.14.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"elkjs": "^0.11.0 || ^0.12.0"
|