agentic-mermaid 0.3.0 → 0.3.1

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.
Files changed (71) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/agent-core.d.ts +8 -3
  3. package/dist/agent-core.js +2 -2
  4. package/dist/agent.d.ts +2 -2
  5. package/dist/agent.js +4 -4
  6. package/dist/agentic-mermaid-mcp.js +5 -5
  7. package/dist/am.js +6 -6
  8. package/dist/browser-lazy/chunks/architecture-3CGEU363.js +31 -0
  9. package/dist/browser-lazy/chunks/chunk-2U4EUPSI.js +4 -0
  10. package/dist/browser-lazy/chunks/chunk-4IUBLBJJ.js +11 -0
  11. package/dist/browser-lazy/chunks/chunk-4U2TVB2S.js +1 -0
  12. package/dist/browser-lazy/chunks/chunk-5Q4S74UO.js +1 -0
  13. package/dist/browser-lazy/chunks/chunk-6UT2VTFI.js +1 -0
  14. package/dist/browser-lazy/chunks/chunk-7D24ZLOV.js +1 -0
  15. package/dist/browser-lazy/chunks/chunk-A7L4WWVW.js +143 -0
  16. package/dist/browser-lazy/chunks/chunk-CTVVJPMX.js +24 -0
  17. package/dist/browser-lazy/chunks/chunk-DPSSG7LR.js +4 -0
  18. package/dist/browser-lazy/chunks/chunk-EPFMQPXX.js +1 -0
  19. package/dist/browser-lazy/chunks/chunk-FFOHLPDA.js +2 -0
  20. package/dist/browser-lazy/chunks/chunk-FLD63DXE.js +2 -0
  21. package/dist/browser-lazy/chunks/chunk-FXBBGAMJ.js +46 -0
  22. package/dist/browser-lazy/chunks/chunk-GRXCKTHX.js +0 -0
  23. package/dist/browser-lazy/chunks/chunk-HZ4ADQMK.js +1 -0
  24. package/dist/browser-lazy/chunks/chunk-I6VE56S7.js +1 -0
  25. package/dist/browser-lazy/chunks/chunk-JX5ZZY3T.js +1 -0
  26. package/dist/browser-lazy/chunks/chunk-KJVNXJ5Y.js +1 -0
  27. package/dist/browser-lazy/chunks/chunk-KTTWXSIX.js +1 -0
  28. package/dist/browser-lazy/chunks/chunk-M6BT2HIP.js +1 -0
  29. package/dist/browser-lazy/chunks/chunk-MMWVZP6M.js +1 -0
  30. package/dist/browser-lazy/chunks/chunk-OFRMKQA6.js +1 -0
  31. package/dist/browser-lazy/chunks/chunk-P7HMSKHJ.js +1 -0
  32. package/dist/browser-lazy/chunks/chunk-PXRUFH7U.js +1 -0
  33. package/dist/browser-lazy/chunks/chunk-PZEWZT35.js +1 -0
  34. package/dist/browser-lazy/chunks/chunk-RVO6J7S3.js +1 -0
  35. package/dist/browser-lazy/chunks/chunk-STQRDZ67.js +1 -0
  36. package/dist/browser-lazy/chunks/chunk-T7IJ6V4B.js +3 -0
  37. package/dist/browser-lazy/chunks/chunk-VDTSULBU.js +7 -0
  38. package/dist/browser-lazy/chunks/chunk-WEUWIFG3.js +1 -0
  39. package/dist/browser-lazy/chunks/class-B3AVLSIF.js +9 -0
  40. package/dist/browser-lazy/chunks/er-AF4BKKKC.js +9 -0
  41. package/dist/browser-lazy/chunks/flowchart-BE6BQZLZ.js +4 -0
  42. package/dist/browser-lazy/chunks/gantt-U4BMMSEL.js +28 -0
  43. package/dist/browser-lazy/chunks/gitgraph-UPSWNFRP.js +8 -0
  44. package/dist/browser-lazy/chunks/journey-PDZ7FDJR.js +40 -0
  45. package/dist/browser-lazy/chunks/mindmap-BFEUURLS.js +9 -0
  46. package/dist/browser-lazy/chunks/pie-ZFYW5JZO.js +19 -0
  47. package/dist/browser-lazy/chunks/quadrant-XJVEYYXK.js +24 -0
  48. package/dist/browser-lazy/chunks/radar-OVXFNRNC.js +32 -0
  49. package/dist/browser-lazy/chunks/render-core-R4ZGGEFS.js +12 -0
  50. package/dist/browser-lazy/chunks/sequence-AWY6JCSB.js +12 -0
  51. package/dist/browser-lazy/chunks/state-TCE4DXKR.js +4 -0
  52. package/dist/browser-lazy/chunks/timeline-W4ZVT3FF.js +20 -0
  53. package/dist/browser-lazy/chunks/xychart-K3QQACKS.js +36 -0
  54. package/dist/browser-lazy/index.d.ts +1012 -0
  55. package/dist/browser-lazy/index.js +1 -0
  56. package/dist/browser.global.js +322 -321
  57. package/dist/{chunk-AVCWKYII.js → chunk-BSVM3VMO.js} +18 -5
  58. package/dist/{chunk-HFD4MALA.js → chunk-FGO3J7RA.js} +7 -7
  59. package/dist/{chunk-UJNY65QS.js → chunk-JJ7JRYZV.js} +2 -2
  60. package/dist/{chunk-3QCXO4V6.js → chunk-KQMJ37OY.js} +4 -4
  61. package/dist/{chunk-GILQUGFK.js → chunk-MBIR6S3B.js} +2 -2
  62. package/dist/{chunk-WHYJLDYG.js → chunk-XVY324NY.js} +47736 -47665
  63. package/dist/{index-CLwYn6Im.d.ts → index-Do8z5rPq.d.ts} +5409 -5391
  64. package/dist/index.d.ts +1 -1
  65. package/dist/index.js +1 -1
  66. package/dist/mcp-cli-7FLGTEG3.js +17 -0
  67. package/docs/README.md +1 -1
  68. package/docs/browser.md +355 -47
  69. package/package.json +13 -3
  70. package/server.json +2 -2
  71. package/dist/mcp-cli-SJVOGRA6.js +0 -17
@@ -0,0 +1,32 @@
1
+ import{c as We}from"./chunk-6UT2VTFI.js";import{a as Ze}from"./chunk-JX5ZZY3T.js";import"./chunk-A7L4WWVW.js";import"./chunk-KJVNXJ5Y.js";import"./chunk-7D24ZLOV.js";import{a as Me}from"./chunk-DPSSG7LR.js";import{a as xe}from"./chunk-PZEWZT35.js";import{e as fe}from"./chunk-MMWVZP6M.js";import"./chunk-FFOHLPDA.js";import{a as Qe}from"./chunk-I6VE56S7.js";import{a as Ue}from"./chunk-OFRMKQA6.js";import{a as De,b as Be,c as Oe}from"./chunk-FLD63DXE.js";import{e as je,k as ge}from"./chunk-RVO6J7S3.js";import{a as Xe,b as Ne,c as Ye}from"./chunk-EPFMQPXX.js";import{G as qe,H as Ge,I as He,L as Z,N as S,e as ae,ia as j,ka as ce,oa as Ke,qa as Ve,u as Le}from"./chunk-FXBBGAMJ.js";import"./chunk-P7HMSKHJ.js";var St=Object.freeze({id:"radar",upstreamId:"radar",maturity:"experimental",label:"Radar",headers:["radar-beta"],aliases:[],config:{section:"radar",keys:["width","height","marginTop","marginRight","marginBottom","marginLeft","axisScaleFactor","axisLabelFactor","curveTension","useMaxWidth","tickLabels","useWidth"],noopKeys:["useWidth"]},identity:{id:"family:radar",kind:"family",version:"1.0.0",compatibility:{core:"^0.3.0"},provenance:{owner:"agentic-mermaid",source:"built-in"}},collisionPriority:100,semanticChannels:["category"],semanticRoles:["prelude","chrome","grid","pie-slice","point","axis","legend","title"],scenePrimitiveEvidence:[{role:"prelude",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"grid",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"pie-slice",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"point",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"axis",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"legend",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"legend",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"title",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]}],example:`radar-beta
2
+ title Skills
3
+ axis speed["Speed"], power["Power"], range["Range"]
4
+ curve now["Current"]{4, 3, 5}
5
+ curve goal["Target"]{5, 5, 4}
6
+ max 5`,detect:t=>/^radar-beta(?:\s|:|$)/.test(t),detectLoose:t=>/^radar-beta(?:\s|:|$)/.test(t)}),Je=St;function et(t){if(!Number.isFinite(t.min)||t.min<0)throw new Error(`Radar min must be a finite non-negative number, got ${t.min}.`);if(t.max!==void 0&&(!Number.isFinite(t.max)||t.max<0))throw new Error(`Radar max must be a finite non-negative number, got ${t.max}.`);let e=!1,i=1;for(let l of t.curves)for(let n of l.values){if(!Number.isFinite(n)||n<0)throw new Error(`Radar curve "${l.id}" contains a non-finite or negative value.`);(!e||n>i)&&(i=n),e=!0}let r=t.max??(e?i:1);if(!(r>t.min))throw new Error(`Radar scale is degenerate: max (${r}) must be greater than min (${t.min}). Set an explicit \`max\`, or ensure curve values span a range.`);return{min:t.min,max:r}}function tt(t,e){return(Math.min(Math.max(t,e.min),e.max)-e.min)/(e.max-e.min)}var it=64,de=256,Ct=/^radar-beta(?:[\t ]*:)?(?=$|\s)/i,Ft=/^title(?:[\t ]+(.*))?$/i,Mt=/^axis\s+(.+)$/i,Lt=/^curve\s+([\s\S]+)$/i,rt=/^(showLegend|ticks|max|min|graticule)\b(.*)$/i,Wt=/^(?:0|[1-9]\d*|\d+\.\d+|0\.\d+)$/,Ee=String.raw`[\w](?:[\w-]*[\w])?`,ot=String.raw`(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')`,Et=new RegExp(String.raw`^(${Ee})\s*(?:\[\s*(${ot})\s*\])?$`),_t=new RegExp(String.raw`^(${Ee})\s*(?:\[\s*(${ot})\s*\])?\s*\{([\s\S]*)\}$`),zt=new RegExp(String.raw`^(${Ee})(?:\s*:\s*|\s+)(.+)$`);function ye(t,e){let i=[],r=0,l=0,n=null,d=!1,m="";for(let s of t){if(d){m+=s,d=!1;continue}if(n&&s==="\\"){m+=s,d=!0;continue}if(s==='"'||s==="'"){n===s?n=null:n===null&&(n=s),m+=s;continue}n||(s==="["?r++:s==="]"?r--:s==="{"?l++:s==="}"&&l--),s===","&&!n&&r===0&&l===0?(i.push(m.trim()),m=""):m+=s}if(i.push(m.trim()),n||r!==0||l!==0)throw new Error(`Radar ${e} has unbalanced quotes or delimiters.`);if(i.some(s=>s.length===0))throw new Error(`Radar ${e} contains an empty comma-separated entry.`);return i}function at(t,e){let i=t[0];if(i!=='"'&&i!=="'"||t.at(-1)!==i)throw new Error(`Radar ${e} must use a quoted label.`);let r="";for(let l=1;l<t.length-1;l++){let n=t[l];if(n!=="\\"){r+=n;continue}if(l++,l>=t.length-1)throw new Error(`Radar ${e} has an incomplete escape.`);let d=t[l];r+=d==="n"?`
7
+ `:d==="r"?"\r":d==="t"?" ":d==="b"?"\b":d==="f"?"\f":d}return r}function st(t){let e="",i=null,r=!1;for(let l=0;l<t.length;l++){let n=t[l];if(r){e+=n,r=!1;continue}if(i&&n==="\\"){e+=n,r=!0;continue}if(n==='"'||n==="'"){i===n?i=null:i===null&&(i=n),e+=n;continue}if(!i&&n==="%"&&t[l+1]==="%"){for(;l<t.length&&t[l]!==`
8
+ `;)l++;l<t.length&&(e+=`
9
+ `);continue}e+=n}return e}var Tt=["showLegend","graticule","accTitle","accDescr","title","ticks","curve","axis","max","min"];function nt(t,e){for(let i of Tt){if(t.slice(e,e+i.length).toLowerCase()!==i.toLowerCase())continue;let r=t[e+i.length];if(r===void 0||/[\s:]/.test(r))return i}}function At(t){let e=st(t),i=[],r=0;for(;r<e.length;){for(;r<e.length&&/\s/.test(e[r]);)r++;if(r>=e.length)break;let l=r,n=nt(e,r);if(n&&/^(?:title|accTitle)$/i.test(n)){for(;r<e.length&&e[r]!==`
10
+ `&&e[r]!=="\r";)r++;let h=e.slice(l,r).trim();h&&i.push(h);continue}if(n?.toLowerCase()==="accdescr"){let h=r+n.length;for(;h<e.length&&/[\t ]/.test(e[h]);)h++;if(e[h]===":")for(h++;h<e.length&&/[\t ]/.test(e[h]);)h++;if(e[h]==="{"){let v=e.indexOf("}",h+1);if(v<0)throw new Error(`Radar statement is missing a closing "}": "${e.slice(l).trim()}"`);r=v+1,i.push(e.slice(l,r).trim());continue}for(;r<e.length&&e[r]!==`
11
+ `&&e[r]!=="\r";)r++;let x=e.slice(l,r).trim();x&&i.push(x);continue}let d=0,m=0,s=null,k=!1;for(;r<e.length;r++){let h=e[r];if(k){k=!1;continue}if(s&&h==="\\"){k=!0;continue}if(h==='"'||h==="'"){s===h?s=null:s===null&&(s=h);continue}if(!s){if(h==="["?d++:h==="]"?d--:h==="{"?m++:h==="}"&&m--,d<0||m<0)throw new Error(`Radar statement has an unexpected closing delimiter: "${e.slice(l,r+1).trim()}"`);if((h===`
12
+ `||h==="\r")&&d===0&&m===0)break;if(/[\t ]/.test(h)&&d===0&&m===0){let x=r+1;for(;x<e.length&&/[\t ]/.test(e[x]);)x++;let v=r-1;for(;v>=l&&/[\t ]/.test(e[v]);)v--;if(e[v]!==","&&nt(e,x))break}}}if(s||d!==0||m!==0)throw new Error(`Radar statement has unbalanced quotes or delimiters: "${e.slice(l,r).trim()}"`);let R=e.slice(l,r).trim();R&&i.push(R)}return i}function me(t,e){let i=t.trim();if(i.startsWith("-")||i.startsWith("+"))throw new Error(`Radar ${e} "${i}" has a sign \u2014 radar numbers must be non-negative (the grammar has no sign token).`);if(!Wt.test(i))throw new Error(`Radar ${e} "${i}" is not a valid number.`);let r=Number.parseFloat(i);if(!Number.isFinite(r))throw new Error(`Radar ${e} "${i}" is not finite.`);return r}function It(t){let e=me(t,"ticks");if(!Number.isInteger(e)||e<1||e>it)throw new Error(`Radar ticks must be an integer from 1 through ${it}, got "${t.trim()}".`);return e}function Pt(t){let e=t.match(Et);if(!e)throw xe({what:`Invalid radar axis: "${t}"`,expectedForm:'an id (not ending in "-") with an optional quoted label',example:'axis speed["Top Speed"], range'});let i=e[1],r=e[2]!==void 0?Z(at(e[2],`axis "${i}" label`)):i;return{id:i,label:r}}function Dt(t,e){let i=t.match(_t);if(!i)throw xe({what:`Invalid radar curve: "${t}"`,expectedForm:'an id (not ending in "-") with an optional quoted label and a `{\u2026}` value block',example:'curve a["Alice"]{85, 90, 80}'});let r=i[1],l=i[2]!==void 0?Z(at(i[2],`curve "${r}" label`)):r,n=ye(i[3],`curve "${r}" value block`),d=n.map(h=>!/^[+-]?(?:\d|\.)/.test(h)),m=d.some(Boolean),s=d.every(Boolean);if(m&&!s)throw new Error(`Radar curve "${r}" mixes positional and keyed entries \u2014 use one form.`);if(!m)return{id:r,label:l,values:n.map(h=>me(h,`curve "${r}" value`))};if(e.length===0)throw new Error(`Radar curve "${r}" uses keyed entries (axis: value) but no axes are declared.`);let k=new Map;for(let h of n){let x=h.match(zt);if(!x)throw new Error(`Radar curve "${r}" has an invalid keyed entry: "${h}".`);let v=x[1],I=me(x[2],`curve "${r}" entry for "${v}"`);k.has(v)||k.set(v,I)}let R=e.map(h=>{let x=k.get(h.id);if(x===void 0)throw new Error(`Radar curve "${r}" is missing an entry for axis "${h.id}".`);return x});return{id:r,label:l,values:R}}function lt(t,e={}){let i=Be(st(t.join(`
13
+ `)).split(/\r?\n/));Oe(i);let r=i.familyLines.join(`
14
+ `).trimStart();if(!r)throw new Error("Radar chart is empty");let l=r.match(Ct);if(!l)throw new Error(`Radar chart must start with "radar-beta", got: "${r.split(/\r?\n/,1)[0]}"`);let n=At(r.slice(l[0].length)),d=e.title,m={...i.accessibility.title!==void 0?{title:Z(i.accessibility.title)}:{},...i.accessibility.descr!==void 0?{description:Z(i.accessibility.descr)}:{}},s=[],k=[],R=0,h,x=5,v="circle",I=!0;for(let W=0;W<n.length;W++){let D=n[W],E,B=De([D],0);if(B===void 0)throw new Error('Radar accDescr block is missing a closing "}"');if(B!==null){B.title?m.title=Z(B.value):m.description=Z(B.value);continue}if(E=D.match(Ft)){d=Z((E[1]??"").trim());continue}if(E=D.match(Mt)){for(let _ of ye(E[1],"axis list")){if(s.length>=de)throw new Error(`Radar charts support at most ${de} axes.`);s.push(Pt(_))}continue}if(E=D.match(Lt)){for(let _ of ye(E[1],"curve list"))k.push(_);continue}if(rt.test(D)){for(let _ of ye(D,"option list")){let X=_.match(rt);if(!X)throw new Error(`Invalid radar option: "${_}"`);let re=X[1].toLowerCase(),C=X[2].trim();switch(re){case"showlegend":if(!/^(true|false)$/i.test(C))throw new Error(`Radar showLegend must be true or false, got "${C}".`);I=C.toLowerCase()==="true";break;case"ticks":x=It(C);break;case"max":h=me(C,"max");break;case"min":R=me(C,"min");break;case"graticule":if(C!=="circle"&&C!=="polygon")throw new Error(`Radar graticule must be circle or polygon, got "${C}".`);v=C;break}}continue}throw xe({what:`Unrecognized radar chart line: "${D}"`,expectedForm:"a title, accessibility directive, axis, curve, or option (min/max/ticks/graticule/showLegend)",example:"axis a, b, c"})}let q=k.map(W=>Dt(W,s));if(h!==void 0&&h<=R)throw new Error(`Radar max (${h}) must be greater than min (${R}).`);return{title:d,...m.title||m.description?{accessibility:m}:{},axes:s,curves:q,min:R,max:h,ticks:x,graticule:v,showLegend:I}}var p={radius:120,margin:22,titleFontSize:18,titleGap:16,axisFontSize:12.5,axisLabelPad:8,axisLabelMaxWidth:96,axisLabelMinWidth:58,labelClearGap:7,leaderMinPush:9,legendFontSize:13,legendLabelMaxWidth:168,legendSwatch:14,legendGap:30,legendRowGap:9,legendSwatchToText:8,ringLabelFontSize:9.5,tickBoxPadX:4,tickBoxPadY:3,dotRadius:3,curveStrokeWidth:2.2};function _e(t={}){return{nodeLabelFontSize:t.legendFontSize??p.legendFontSize,edgeLabelFontSize:t.axisLabelFontSize??p.axisFontSize,groupHeaderFontSize:t.titleFontSize??p.titleFontSize,nodeLabelFontWeight:500,edgeLabelFontWeight:500,groupHeaderFontWeight:600,nodePaddingX:0,nodePaddingY:0,nodeLineWidth:t.curveStrokeWidth??p.curveStrokeWidth,edgeLineWidth:t.axisStrokeWidth??1,groupCornerRadius:0,groupPaddingX:0,groupPaddingY:0,groupLineWidth:je.outerBox}}function g(t){return Math.round(t*100)/100}function Bt(t,e,i){return Math.min(Math.max(t,e),i)}function se(t,e){return 2*Math.PI*t/e}function ie(t,e,i,r){return{x:t+i*Math.sin(r),y:e-i*Math.cos(r)}}function ct(t,e,i=0){return t.left<e.right+i&&e.left<t.right+i&&t.top<e.bottom+i&&e.top<t.bottom+i}function Ot(t,e,i){if(t.length===0)return"";if(!e||t.length<3)return"M "+t.map(n=>`${g(n.x)} ${g(n.y)}`).join(" L ")+" Z";let r=t.length,l=`M ${g(t[0].x)} ${g(t[0].y)}`;for(let n=0;n<r;n++){let d=t[(n-1+r)%r],m=t[n],s=t[(n+1)%r],k=t[(n+2)%r],R=m.x+(s.x-d.x)*i,h=m.y+(s.y-d.y)*i,x=s.x-(k.x-m.x)*i,v=s.y-(k.y-m.y)*i;l+=` C ${g(R)} ${g(h)} ${g(x)} ${g(v)} ${g(s.x)} ${g(s.y)}`}return l+" Z"}function dt(t,e={},i={},r){let l=ge(e,_e(i),r),n=t.axes.length;if(n>de)throw new Error(`Radar charts support at most ${de} axes.`);let d=p.radius;if(i.width!==void 0||i.height!==void 0){let o=i.width??i.height??p.radius*2,u=i.height??i.width??p.radius*2;d=Bt(Math.min(o,u)/2-56,40,400)}let m=i.axisScaleFactor??1,s=i.axisLabelFactor??1.05,k=i.curveTension??.17,R=t.graticule==="circle"&&k>0,h=et(t),{min:x,max:v}=h,I=o=>d*tt(o,h),q=l.edgeLabelFontSize,W=l.edgeLabelFontWeight,D=q*1.3,E=l.groupHeaderFontSize,B=l.groupHeaderFontWeight,_=Math.max(p.axisLabelMinWidth,Math.min(p.axisLabelMaxWidth,d*1.05)),X=o=>t.axes.map(u=>Me(u.label,o,q,W).split(`
15
+ `)),re=o=>Math.max(0,...o.flat().map(u=>ae(u,q,W))),C=p.axisLabelMaxWidth,G=X(C);for(let o=0;o<8&&re(G)>_&&C>p.axisLabelMinWidth;o++)C=Math.max(p.axisLabelMinWidth,C-12),G=X(C);let le=G.map(o=>Math.max(0,...o.map(u=>ae(u,q,W)))),J=G.map(o=>o.length*D),ne=new Array(n).fill(0);for(let o of t.curves)o.values.length===n&&o.values.forEach((u,b)=>{ne[b]=Math.max(ne[b],I(u))});let N=d*1.05+p.axisLabelPad,he=i.axisLabelFactor===void 0?0:d*(s-1.05),c=t.axes.map((o,u)=>{let b=Math.sin(se(u,n));return b>.3?"start":b<-.3?"end":"middle"}),a=Math.max(d,d*m,...ne)+p.dotRadius+p.labelClearGap,f=new Array(n).fill(0).map((o,u)=>Math.max(0,a+J[u]/2-N)+he),y=new Array(n).fill(!1),$=o=>{let u=se(o,n),b=N+f[o],w=b*Math.sin(u),L=-b*Math.cos(u),T=le[o],M=c[o]==="start"?w:c[o]==="end"?w-T:w-T/2;return{left:M,right:M+T,top:L-J[o]/2,bottom:L+J[o]/2,rx:w,ry:L}},O=[];for(let o=0;o<n;o++){let u=f[o],b=()=>O.some(w=>ct($(o),$(w),2));if(b()){y[o]=!0;let w=6,L=!1;for(let T=0;T<48;T++){if(f[o]=u+w,!b()){L=!0;break}w*=2}if(!L)throw new Error("Radar axis labels could not be placed within finite layout bounds.")}O.push(o)}let F=l.nodeLabelFontSize,z=l.nodeLabelFontWeight,Y=F*1.25,P=t.showLegend&&t.curves.length>0,A=i.legendBoxSize??p.legendSwatch,V=F*(p.legendLabelMaxWidth/p.legendFontSize),be=P?t.curves.map(o=>Me(o.label,V,F,z).split(`
16
+ `)):[],ze=be.map(o=>Math.max(A,o.length*Y)),gt=Math.max(0,...be.flat().map(o=>ae(o,F,z))),ft=P?A+p.legendSwatchToText+gt:0,$e=P?ze.reduce((o,u)=>o+u,0)+Math.max(0,t.curves.length-1)*p.legendRowGap:0,we=i.marginLeft??p.margin,xt=i.marginRight??p.margin,ke=i.marginTop??p.margin,yt=i.marginBottom??p.margin,ue=d*Math.max(1,m),ee=ue,oe=ue,U=ue,te=ue;for(let o=0;o<n;o++){let u=$(o);ee=Math.max(ee,-u.left),oe=Math.max(oe,u.right),U=Math.max(U,-u.top),te=Math.max(te,u.bottom)}if(P&&(U=Math.max(U,$e/2),te=Math.max(te,$e/2)),i.width){let o=i.width/2;ee=Math.max(ee,o),oe=Math.max(oe,o)}if(i.height){let o=i.height/2;U=Math.max(U,o),te=Math.max(te,o)}let Te=t.title?E+p.titleGap:0,bt=P?p.legendGap+ft:0,Ae=we+ee+oe+bt+xt,Re=we+ee,Ie=t.title?ae(t.title,E,B):0,ve=Math.max(0,Ie/2-Re),$t=Math.max(0,Re+Ie/2-Ae),wt=Ae+ve+$t,kt=ke+Te+U+te+yt,H=Re+ve,K=ke+Te+U,Se=[];for(let o=1;n>0&&o<=t.ticks;o++){let u=d*o/t.ticks,b=x+(v-x)*o/t.ticks,w=t.graticule==="polygon"?t.axes.map((L,T)=>{let M=ie(H,K,u,se(T,n));return{x:g(M.x),y:g(M.y)}}):[];Se.push({r:g(u),value:g(b),points:w,emphasized:o===t.ticks})}let Rt=t.axes.map((o,u)=>{let b=se(u,n),w=ie(H,K,d*m,b),L=N+f[u],T=ie(H,K,L,b),M=y[u]||f[u]>p.leaderMinPush?(()=>{let pe=ie(H,K,Math.max(d,d*m)+1,b),Fe=ie(H,K,L-J[u]/2-2,b);return{x1:g(pe.x),y1:g(pe.y),x2:g(Fe.x),y2:g(Fe.y)}})():void 0;return{id:o.id,label:o.label,x:g(w.x),y:g(w.y),labelX:g(T.x),labelY:g(T.y),anchor:c[u],lines:G[u],labelWidth:g(le[u]),leader:M}}),vt=t.curves.map((o,u)=>{let b=o.values.length===n,w=b?o.values.map((L,T)=>{let M=ie(H,K,I(L),se(T,n));return{x:g(M.x),y:g(M.y)}}):[];return{id:o.id,label:o.label,colorIndex:u,areaPath:b?Ot(w,R,k):"",vertices:w,arityMismatch:!b}}),Ce=[];if(i.tickLabels&&n>0){let o=se(0,n)+Math.PI/n;for(let u of[...Se].reverse()){let b=ie(H,K,u.r,o),w=Xt(u.value),L=ae(w,p.ringLabelFontSize,W)+p.tickBoxPadX*2,T=p.ringLabelFontSize+p.tickBoxPadY*2,M={text:w,x:g(b.x),y:g(b.y),w:g(L),h:g(T)},pe={left:M.x-M.w/2,right:M.x+M.w/2,top:M.y-M.h/2,bottom:M.y+M.h/2};Ce.some(Q=>ct(pe,{left:Q.x-Q.w/2,right:Q.x+Q.w/2,top:Q.y-Q.h/2,bottom:Q.y+Q.h/2},1))||Ce.unshift(M)}}let Pe=[];if(P){let o=ve+we+ee+oe+p.legendGap,u=K-$e/2;t.curves.forEach((b,w)=>{let L=ze[w];Pe.push({label:b.label,lines:be[w],colorIndex:w,x:g(o),y:g(u+(L-A)/2),swatchSize:A,textX:g(o+A+p.legendSwatchToText),textY:g(u+L/2)}),u+=L+p.legendRowGap})}return{width:g(wt),height:g(kt),cx:g(H),cy:g(K),radius:g(d),title:t.title?{text:t.title,x:g(H),y:g(ke+E/2),fontSize:E}:void 0,accessibility:t.accessibility?{...t.accessibility}:void 0,rings:Se,axes:Rt,curves:vt,tickLabels:Ce,legend:Pe,polygonGraticule:t.graticule==="polygon",typography:{axisFontSize:q,axisFontWeight:W,legendFontSize:F,legendFontWeight:z,titleFontSize:E,titleFontWeight:B,tickFontSize:p.ringLabelFontSize,tickFontWeight:W},visual:i}}function Xt(t){return Number.isInteger(t)?String(t):String(Math.round(t*100)/100)}var ti={radius:p.radius,axisFontSize:p.axisFontSize,titleFontSize:p.titleFontSize,legendFontSize:p.legendFontSize,dotRadius:p.dotRadius},ii={axisLabelMaxWidth:p.axisLabelMaxWidth,axisLabelMinWidth:p.axisLabelMinWidth,legendLabelMaxWidth:p.legendLabelMaxWidth,leaderMinPush:p.leaderMinPush,tickBoxPadX:p.tickBoxPadX,tickBoxPadY:p.tickBoxPadY};function mt(t,e,i){let r=Le(t,e);if(r!==null&&r>=4.5)return t;let n=[i,"#000000","#ffffff"].map(d=>({color:d,ratio:Le(d,e)})).filter(d=>d.ratio!==null).sort((d,m)=>m.ratio-d.ratio)[0];return n&&n.ratio>=4.5?n.color:i}function pt(t){let{positioned:e,colors:i,resolved:r}=t,l=r.renderOptions,n=i.font??"Inter",d=l.transparent??!1,m=ge(l,_e(e.visual),r.styleFace),s=[],k=Ze(e.curves.length,{accent:i.accent,bg:i.bg,overrides:e.visual.paletteOverrides}),R=e.visual.curveOpacity??.5,h=e.visual.axisColor??m.edgeStrokeColor??"var(--_line)",x=e.visual.graticuleColor??m.edgeStrokeColor??"var(--_line)",v=e.visual.axisStrokeWidth??1,I=e.visual.graticuleStrokeWidth??1,q=e.visual.graticuleOpacity??.7,W=e.visual.titleColor??m.groupTextColor??m.nodeTextColor??"var(--_text)",D=m.nodeBorderColor??"var(--bg)",E=e.visual.axisColor??mt(m.edgeTextColor??i.fg,i.bg,i.fg),B=mt(m.edgeTextColor??i.fg,i.bg,i.fg),_={title:e.accessibility?.title??e.title?.text??"Radar chart",description:e.accessibility?.description},X=ut(e.axes.map(c=>c.id)),re=ut(e.curves.map(c=>c.id)),C=[e.width,e.height,_.title??""];for(let c of e.axes)C.push(c.id);for(let c of e.curves)C.push(c.label);let G=`radar-${Qe(C.join("|"))}`,le=`${G}-title`,J=`${G}-desc`,ne=Yt(m,h,x,E,B,W,D,v,I,q,R),N=[Nt(e,i,d,_,G,le,J)];_.title&&N.push(`<title id="${le}">${S(_.title)}</title>`),_.description&&N.push(`<desc id="${J}">${S(_.description)}</desc>`),N.push(Ge(n,!1,i.shadow,i.embedFontImport));let he=qe(i);he&&N.push(`<defs>${he}</defs>`),N.push(ne),s.push(Ve({id:"prelude",width:e.width,height:e.height,colors:i,transparent:d,font:n,hasMonoFont:!1,extraCss:ne},N.join(`
17
+ `)));for(let c=0;c<e.rings.length;c++){let a=e.rings[c],f=`radar-ring${a.emphasized?" radar-ring-outer":""}`;if(e.polygonGraticule){let y=a.points.map($=>`${$.x},${$.y}`).join(" ");s.push(j({id:`ring:${c}`,role:"grid",geometry:{kind:"polygon",points:a.points},paint:{fill:"none",stroke:x,strokeWidth:String(a.emphasized?I*1.4:I)}},`<polygon class="${f}" points="${y}" fill="none" />`))}else s.push(j({id:`ring:${c}`,role:"grid",geometry:{kind:"circle",cx:e.cx,cy:e.cy,r:a.r},paint:{fill:"none",stroke:x,strokeWidth:String(a.emphasized?I*1.4:I)}},`<circle class="${f}" cx="${e.cx}" cy="${e.cy}" r="${a.r}" fill="none" />`))}for(let[c,a]of e.axes.entries()){let f=X[c];s.push(j({id:`spoke:${f}`,role:"grid",geometry:{kind:"line",x1:e.cx,y1:e.cy,x2:a.x,y2:a.y},paint:{stroke:h,strokeWidth:String(v)}},`<line class="radar-axis-line" x1="${e.cx}" y1="${e.cy}" x2="${a.x}" y2="${a.y}" />`))}for(let[c,a]of e.curves.entries()){if(a.arityMismatch||a.vertices.length===0)continue;let f=re[c],y={category:a.label},$=fe(r.styleFace,"pie-slice",y,{includeFallback:!1}),O=e.visual.paletteOverrides?.[a.colorIndex],F=O??$?.fillColor??k[a.colorIndex],z=O??$?.strokeColor??$?.borderColor??F,Y=$?.lineWidth??m.nodeLineWidth,P=$?.lineWidth!==void 0?` style="stroke-width:${Y}"`:"";if(e.polygonGraticule){let A=a.vertices.map(V=>`${V.x},${V.y}`).join(" ");s.push(j({id:`curve:${f}`,role:"pie-slice",geometry:{kind:"polygon",points:a.vertices},paint:{fill:F,stroke:z,strokeWidth:String(Y),opacity:String(R)},channels:y},`<polygon class="radar-area" points="${A}" fill="${S(F)}" stroke="${S(z)}"${P} fill-opacity="${R}" data-curve="${S(a.label)}" />`))}else s.push(j({id:`curve:${f}`,role:"pie-slice",geometry:{kind:"path",d:a.areaPath},paint:{fill:F,stroke:z,strokeWidth:String(Y),opacity:String(R)},channels:y},`<path class="radar-area" d="${a.areaPath}" fill="${S(F)}" stroke="${S(z)}"${P} fill-opacity="${R}" data-curve="${S(a.label)}" />`))}for(let[c,a]of e.curves.entries()){if(a.arityMismatch)continue;let f=re[c],y={category:a.label},$=fe(r.styleFace,"point",y,{includeFallback:!1}),F=e.visual.paletteOverrides?.[a.colorIndex]??$?.fillColor??k[a.colorIndex],z=$?.strokeColor??$?.borderColor??D,Y=$?.lineWidth??1.2,P=$?` style="fill:${S(F)};stroke:${S(z)};stroke-width:${Y}"`:"";a.vertices.forEach((A,V)=>{s.push(j({id:`dot:${f}:${V}`,role:"point",geometry:{kind:"circle",cx:A.x,cy:A.y,r:3},paint:{fill:F,stroke:z,strokeWidth:String(Y)},channels:y},`<circle class="radar-dot" cx="${A.x}" cy="${A.y}" r="3" fill="${S(F)}"${P} />`))})}for(let[c,a]of e.axes.entries()){if(!a.leader)continue;let f=X[c],y=a.leader;s.push(j({id:`leader:${f}`,role:"grid",geometry:{kind:"line",x1:y.x1,y1:y.y1,x2:y.x2,y2:y.y2},paint:{stroke:x,strokeWidth:"1"}},`<line class="radar-leader" x1="${y.x1}" y1="${y.y1}" x2="${y.x2}" y2="${y.y2}" />`))}for(let c=0;c<e.tickLabels.length;c++){let a=e.tickLabels[c],f=ht(a.x-a.w/2),y=ht(a.y-a.h/2);s.push(j({id:`tick-box:${c}`,role:"grid",geometry:{kind:"rect",x:f,y,width:a.w,height:a.h,rx:4,ry:4},paint:{fill:"var(--bg)",stroke:x,strokeWidth:"0.75"}},`<rect class="radar-tick-box" x="${f}" y="${y}" width="${a.w}" height="${a.h}" rx="4" ry="4" />`))}for(let c=0;c<e.tickLabels.length;c++){let a=e.tickLabels[c];s.push(ce({id:`tick:${c}`,role:"axis",text:a.text,x:a.x,y:a.y,fontSize:e.typography.tickFontSize,anchor:"middle",paint:{fill:B}},`<text class="radar-tick-label" x="${a.x}" y="${a.y}" text-anchor="middle" dominant-baseline="middle" font-size="${e.typography.tickFontSize}" font-weight="${e.typography.tickFontWeight}">${S(a.text)}</text>`))}for(let[c,a]of e.axes.entries()){let f=X[c],y=a.lines,$=-(y.length-1)*.6,O=y.map((F,z)=>`<tspan x="${a.labelX}" dy="${z===0?`${$}em`:"1.2em"}">${S(F)}</tspan>`).join("");s.push(ce({id:`axis-label:${f}`,role:"axis",text:y.join(`
18
+ `),x:a.labelX,y:a.labelY,fontSize:e.typography.axisFontSize,anchor:a.anchor,paint:{fill:E}},`<text class="radar-axis-label" aria-label="${S(a.label)}" x="${a.labelX}" y="${a.labelY}" text-anchor="${a.anchor}" dominant-baseline="middle" font-size="${e.typography.axisFontSize}" font-weight="${e.typography.axisFontWeight}">${O}</text>`))}for(let c of e.legend){let a={category:c.label},f=fe(r.styleFace,"legend",a,{includeFallback:!1}),$=e.visual.paletteOverrides?.[c.colorIndex]??f?.fillColor??k[c.colorIndex],O=f?.strokeColor??f?.borderColor??m.nodeBorderColor??"var(--_node-stroke)",F=f?.lineWidth??1,z=f?` style="fill:${S($)};stroke:${S(O)};stroke-width:${F}"`:"";s.push(j({id:`legend-swatch:${c.colorIndex}`,role:"legend",geometry:{kind:"rect",x:c.x,y:c.y,width:c.swatchSize,height:c.swatchSize,rx:2,ry:2},paint:{fill:$,stroke:O,strokeWidth:String(F),opacity:String(R)},channels:a},`<rect class="radar-legend-swatch" x="${c.x}" y="${c.y}" width="${c.swatchSize}" height="${c.swatchSize}" rx="2" ry="2" fill="${S($)}"${z} fill-opacity="${R}" />`));let Y=-(c.lines.length-1)*.6,P=c.lines.map((A,V)=>`<tspan x="${c.textX}" dy="${V===0?`${Y}em`:"1.2em"}">${S(A)}</tspan>`).join("");s.push(ce({id:`legend-label:${c.colorIndex}`,role:"legend",text:c.lines.join(`
19
+ `),x:c.textX,y:c.textY,fontSize:e.typography.legendFontSize,anchor:"start",paint:{fill:f?.textColor??m.nodeTextColor??"var(--_text)"}},`<text class="radar-legend-text" x="${c.textX}" y="${c.textY}" text-anchor="start" dominant-baseline="middle" font-size="${e.typography.legendFontSize}" font-weight="${e.typography.legendFontWeight}"${f?.textColor?` style="fill:${S(f.textColor)}"`:""}>${P}</text>`))}return e.title&&s.push(ce({id:"title",role:"title",text:e.title.text,x:e.title.x,y:e.title.y,fontSize:e.title.fontSize,anchor:"middle",paint:{fill:W}},`<text class="radar-title" x="${e.title.x}" y="${e.title.y}" text-anchor="middle" dominant-baseline="middle" font-size="${e.title.fontSize}" font-weight="${Math.max(e.typography.titleFontWeight,600)}">${S(e.title.text)}</text>`)),s.push(Ke()),{family:"radar",width:e.width,height:e.height,colors:i,transparent:d,parts:s}}function ht(t){return Math.round(t*100)/100}function Nt(t,e,i,r,l,n,d){let m=t.visual.useMaxWidth?{width:"100%",height:"100%",style:`max-width:${t.width}px`}:{};return He(t.width,t.height,e,i,{...m,attrs:{id:l,"aria-roledescription":"radar chart",...Ue(r.title,r.description,n,d,"radar chart")}})}function ut(t){let e=new Map;for(let r of t)e.set(r,(e.get(r)??0)+1);let i=new Map;return t.map(r=>{if((e.get(r)??0)<=1)return r;let l=i.get(r)??0;return i.set(r,l+1),`${r}#${l}`})}function Yt(t,e,i,r,l,n,d,m,s,k,R){return`<style>
20
+ .radar-ring { stroke: ${i}; stroke-width: ${s}; stroke-opacity: ${k}; fill: none; }
21
+ .radar-ring-outer { stroke-width: ${s*1.4}; stroke-opacity: ${k}; }
22
+ .radar-axis-line { stroke: ${e}; stroke-width: ${m}; }
23
+ .radar-leader { stroke: ${i}; stroke-width: 1; stroke-opacity: 0.5; }
24
+ .radar-area { stroke-width: ${t.nodeLineWidth}; fill-opacity: ${R}; stroke-linejoin: round; }
25
+ .radar-dot { stroke: ${d}; stroke-width: 1.2; }
26
+ .radar-axis-label { fill: ${r}; }
27
+ .radar-tick-box { fill: var(--bg); stroke: ${i}; stroke-opacity: 0.35; stroke-width: 0.75; }
28
+ .radar-tick-label { fill: ${l}; }
29
+ .radar-legend-swatch { stroke: ${t.nodeBorderColor??"var(--_node-stroke)"}; stroke-width: 1; }
30
+ .radar-legend-text { fill: ${t.nodeTextColor??"var(--_text)"}; }
31
+ .radar-title { fill: ${n}; }
32
+ </style>`}var Ri=Ye(Je,{normalizeRequest:t=>({familyConfig:{visual:We(t.source.frontmatter)}}),layout:t=>Ne(dt(lt(t.source.lines,{title:typeof t.source.frontmatter.title=="string"?t.source.frontmatter.title:void 0}),t.renderOptions,t.familyConfig?.visual??We(t.source.frontmatter),t.styleFace),{injectAccessibility:!1}),lowerScene:Xe(pt)});export{Ri as default};
@@ -0,0 +1,12 @@
1
+ import{a as Qn,b as $}from"./chunk-6UT2VTFI.js";import{a as Hn}from"./chunk-4U2TVB2S.js";import{b as Wn,c as qn}from"./chunk-4IUBLBJJ.js";import{b as vn}from"./chunk-T7IJ6V4B.js";import"./chunk-5Q4S74UO.js";import"./chunk-STQRDZ67.js";import{a as mn,b as hn}from"./chunk-A7L4WWVW.js";import{a as Ot,b as kn,c as On}from"./chunk-PXRUFH7U.js";import{b as dn,c as pn}from"./chunk-KJVNXJ5Y.js";import"./chunk-M6BT2HIP.js";import{a as Un,b as Jn,c as Xn,d as Kn,f as Yn,g as Zn}from"./chunk-MMWVZP6M.js";import{b as un,d as fn,f as Rt}from"./chunk-FFOHLPDA.js";import{b as wt,c as Et}from"./chunk-I6VE56S7.js";import"./chunk-FLD63DXE.js";import"./chunk-RVO6J7S3.js";import{$ as Xe,A as Rn,Aa as In,B as xt,Ba as ie,C as Ie,Ca as Pn,Da as Nn,E as kt,Ea as jn,Fa as Ln,Ga as _n,Ha as zn,Ia as Bn,Ja as Gn,K as xn,Ka as Vn,O as z,R as vt,S as wn,d as yn,da as En,g as gn,ga as Mn,h as bn,ha as re,ra as Cn,sa as An,ta as Fn,ua as $n,va as Tn,w as Sn,x as Je,za as Dn}from"./chunk-FXBBGAMJ.js";import{e as He,f as Ue}from"./chunk-P7HMSKHJ.js";function Mt(e,t,n){if(e&&e.length){let[r,i]=t,o=Math.PI/180*n,a=Math.cos(o),s=Math.sin(o);for(let d of e){let[l,c]=d;d[0]=(l-r)*a-(c-i)*s+r,d[1]=(l-r)*s+(c-i)*a+i}}}function vi(e,t,n){let r=[];e.forEach(i=>r.push(...i)),Mt(r,t,n)}function wi(e,t){return e[0]===t[0]&&e[1]===t[1]}function er(e,t,n,r=1){let i=n,o=Math.max(t,.1),a=e[0]&&e[0][0]&&typeof e[0][0]=="number"?[e]:e,s=[0,0];if(i)for(let l of a)Mt(l,s,i);let d=Ei(a,o,r);if(i){for(let l of a)Mt(l,s,-i);vi(d,s,-i)}return d}function Ei(e,t,n){let r=[];for(let l of e){let c=[...l];wi(c[0],c[c.length-1])||c.push([c[0][0],c[0][1]]),c.length>2&&r.push(c)}let i=[];t=Math.max(t,.1);let o=[];for(let l of r)for(let c=0;c<l.length-1;c++){let p=l[c],u=l[c+1];if(p[1]!==u[1]){let f=Math.min(p[1],u[1]);o.push({ymin:f,ymax:Math.max(p[1],u[1]),x:f===p[1]?p[0]:u[0],islope:(u[0]-p[0])/(u[1]-p[1])})}}if(o.sort((l,c)=>l.ymin<c.ymin?-1:l.ymin>c.ymin?1:l.x<c.x?-1:l.x>c.x?1:l.ymax===c.ymax?0:(l.ymax-c.ymax)/Math.abs(l.ymax-c.ymax)),!o.length)return i;let a=[],s=o[0].ymin,d=0;for(;a.length||o.length;){if(o.length){let l=-1;for(let p=0;p<o.length&&!(o[p].ymin>s);p++)l=p;o.splice(0,l+1).forEach(p=>{a.push({s,edge:p})})}if(a=a.filter(l=>!(l.edge.ymax<=s)),a.sort((l,c)=>l.edge.x===c.edge.x?0:(l.edge.x-c.edge.x)/Math.abs(l.edge.x-c.edge.x)),(n!==1||d%t===0)&&a.length>1)for(let l=0;l<a.length;l=l+2){let c=l+1;if(c>=a.length)break;let p=a[l].edge,u=a[c].edge;i.push([[Math.round(p.x),s],[Math.round(u.x),s]])}s+=n,a.forEach(l=>{l.edge.x=l.edge.x+n*l.edge.islope}),d++}return i}function X(e,t){var n;let r=t.hachureAngle+90,i=t.hachureGap;i<0&&(i=t.strokeWidth*4),i=Math.round(Math.max(i,.1));let o=1;return t.roughness>=1&&(((n=t.randomizer)===null||n===void 0?void 0:n.next())||Math.random())>.7&&(o=i),er(e,i,r,o||1)}var oe=class{constructor(t){this.helper=t}fillPolygons(t,n){return this._fillPolygons(t,n)}_fillPolygons(t,n){let r=X(t,n);return{type:"fillSketch",ops:this.renderLines(r,n)}}renderLines(t,n){let r=[];for(let i of t)r.push(...this.helper.doubleLineOps(i[0][0],i[0][1],i[1][0],i[1][1],n));return r}};function se(e){let t=e[0],n=e[1];return Math.sqrt(Math.pow(t[0]-n[0],2)+Math.pow(t[1]-n[1],2))}var Ke=class extends oe{fillPolygons(t,n){let r=n.hachureGap;r<0&&(r=n.strokeWidth*4),r=Math.max(r,.1);let i=Object.assign({},n,{hachureGap:r}),o=X(t,i),a=Math.PI/180*n.hachureAngle,s=[],d=r*.5*Math.cos(a),l=r*.5*Math.sin(a);for(let[p,u]of o)se([p,u])&&s.push([[p[0]-d,p[1]+l],[...u]],[[p[0]+d,p[1]-l],[...u]]);return{type:"fillSketch",ops:this.renderLines(s,n)}}};var Ye=class extends oe{fillPolygons(t,n){let r=this._fillPolygons(t,n),i=Object.assign({},n,{hachureAngle:n.hachureAngle+90}),o=this._fillPolygons(t,i);return r.ops=r.ops.concat(o.ops),r}};var Ze=class{constructor(t){this.helper=t}fillPolygons(t,n){n=Object.assign({},n,{hachureAngle:0});let r=X(t,n);return this.dotsOnLines(r,n)}dotsOnLines(t,n){let r=[],i=n.hachureGap;i<0&&(i=n.strokeWidth*4),i=Math.max(i,.1);let o=n.fillWeight;o<0&&(o=n.strokeWidth/2);let a=i/4;for(let s of t){let d=se(s),l=d/i,c=Math.ceil(l)-1,p=d-c*i,u=(s[0][0]+s[1][0])/2-i/4,f=Math.min(s[0][1],s[1][1]);for(let m=0;m<c;m++){let h=f+p+m*i,y=u-a+Math.random()*2*a,g=h-a+Math.random()*2*a,S=this.helper.ellipse(y,g,o,o,n);r.push(...S.ops)}}return{type:"fillSketch",ops:r}}};var Qe=class{constructor(t){this.helper=t}fillPolygons(t,n){let r=X(t,n);return{type:"fillSketch",ops:this.dashedLine(r,n)}}dashedLine(t,n){let r=n.dashOffset<0?n.hachureGap<0?n.strokeWidth*4:n.hachureGap:n.dashOffset,i=n.dashGap<0?n.hachureGap<0?n.strokeWidth*4:n.hachureGap:n.dashGap,o=[];return t.forEach(a=>{let s=se(a),d=Math.floor(s/(r+i)),l=(s+i-d*(r+i))/2,c=a[0],p=a[1];c[0]>p[0]&&(c=a[1],p=a[0]);let u=Math.atan((p[1]-c[1])/(p[0]-c[0]));for(let f=0;f<d;f++){let m=f*(r+i),h=m+r,y=[c[0]+m*Math.cos(u)+l*Math.cos(u),c[1]+m*Math.sin(u)+l*Math.sin(u)],g=[c[0]+h*Math.cos(u)+l*Math.cos(u),c[1]+h*Math.sin(u)+l*Math.sin(u)];o.push(...this.helper.doubleLineOps(y[0],y[1],g[0],g[1],n))}}),o}};var et=class{constructor(t){this.helper=t}fillPolygons(t,n){let r=n.hachureGap<0?n.strokeWidth*4:n.hachureGap,i=n.zigzagOffset<0?r:n.zigzagOffset;n=Object.assign({},n,{hachureGap:r+i});let o=X(t,n);return{type:"fillSketch",ops:this.zigzagLines(o,i,n)}}zigzagLines(t,n,r){let i=[];return t.forEach(o=>{let a=se(o),s=Math.round(a/(2*n)),d=o[0],l=o[1];d[0]>l[0]&&(d=o[1],l=o[0]);let c=Math.atan((l[1]-d[1])/(l[0]-d[0]));for(let p=0;p<s;p++){let u=p*2*n,f=(p+1)*2*n,m=Math.sqrt(2*Math.pow(n,2)),h=[d[0]+u*Math.cos(c),d[1]+u*Math.sin(c)],y=[d[0]+f*Math.cos(c),d[1]+f*Math.sin(c)],g=[h[0]+m*Math.cos(c+Math.PI/4),h[1]+m*Math.sin(c+Math.PI/4)];i.push(...this.helper.doubleLineOps(h[0],h[1],g[0],g[1],r),...this.helper.doubleLineOps(g[0],g[1],y[0],y[1],r))}}),i}};var j={};function tr(e,t){let n=e.fillStyle||"hachure";if(!j[n])switch(n){case"zigzag":j[n]||(j[n]=new Ke(t));break;case"cross-hatch":j[n]||(j[n]=new Ye(t));break;case"dots":j[n]||(j[n]=new Ze(t));break;case"dashed":j[n]||(j[n]=new Qe(t));break;case"zigzag-line":j[n]||(j[n]=new et(t));break;default:n="hachure",j[n]||(j[n]=new oe(t));break}return j[n]}function nr(){return Math.floor(Math.random()*2**31)}var tt=class{constructor(t){this.seed=t}next(){return this.seed?(2**31-1&(this.seed=Math.imul(48271,this.seed)))/2**31:Math.random()}};var nt={A:7,a:7,C:6,c:6,H:1,h:1,L:2,l:2,M:2,m:2,Q:4,q:4,S:4,s:4,T:2,t:2,V:1,v:1,Z:0,z:0};function Mi(e){let t=new Array;for(;e!=="";)if(e.match(/^([ \t\r\n,]+)/))e=e.substr(RegExp.$1.length);else if(e.match(/^([aAcChHlLmMqQsStTvVzZ])/))t[t.length]={type:0,text:RegExp.$1},e=e.substr(RegExp.$1.length);else if(e.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/))t[t.length]={type:1,text:`${parseFloat(RegExp.$1)}`},e=e.substr(RegExp.$1.length);else return[];return t[t.length]={type:2,text:""},t}function Ct(e,t){return e.type===t}function ve(e){let t=[],n=Mi(e),r="BOD",i=0,o=n[i];for(;!Ct(o,2);){let a=0,s=[];if(r==="BOD")if(o.text==="M"||o.text==="m")i++,a=nt[o.text],r=o.text;else return ve("M0,0"+e);else Ct(o,1)?a=nt[r]:(i++,a=nt[o.text],r=o.text);if(i+a<n.length){for(let d=i;d<i+a;d++){let l=n[d];if(Ct(l,1))s[s.length]=+l.text;else throw new Error("Param not a number: "+r+","+l.text)}if(typeof nt[r]=="number"){let d={key:r,data:s};t.push(d),i+=a,o=n[i],r==="M"&&(r="L"),r==="m"&&(r="l")}else throw new Error("Bad segment: "+r)}else throw new Error("Path data ended short")}return t}function Pe(e){let t=0,n=0,r=0,i=0,o=[];for(let{key:a,data:s}of e)switch(a){case"M":o.push({key:"M",data:[...s]}),[t,n]=s,[r,i]=s;break;case"m":t+=s[0],n+=s[1],o.push({key:"M",data:[t,n]}),r=t,i=n;break;case"L":o.push({key:"L",data:[...s]}),[t,n]=s;break;case"l":t+=s[0],n+=s[1],o.push({key:"L",data:[t,n]});break;case"C":o.push({key:"C",data:[...s]}),t=s[4],n=s[5];break;case"c":{let d=s.map((l,c)=>c%2?l+n:l+t);o.push({key:"C",data:d}),t=d[4],n=d[5];break}case"Q":o.push({key:"Q",data:[...s]}),t=s[2],n=s[3];break;case"q":{let d=s.map((l,c)=>c%2?l+n:l+t);o.push({key:"Q",data:d}),t=d[2],n=d[3];break}case"A":o.push({key:"A",data:[...s]}),t=s[5],n=s[6];break;case"a":t+=s[5],n+=s[6],o.push({key:"A",data:[s[0],s[1],s[2],s[3],s[4],t,n]});break;case"H":o.push({key:"H",data:[...s]}),t=s[0];break;case"h":t+=s[0],o.push({key:"H",data:[t]});break;case"V":o.push({key:"V",data:[...s]}),n=s[0];break;case"v":n+=s[0],o.push({key:"V",data:[n]});break;case"S":o.push({key:"S",data:[...s]}),t=s[2],n=s[3];break;case"s":{let d=s.map((l,c)=>c%2?l+n:l+t);o.push({key:"S",data:d}),t=d[2],n=d[3];break}case"T":o.push({key:"T",data:[...s]}),t=s[0],n=s[1];break;case"t":t+=s[0],n+=s[1],o.push({key:"T",data:[t,n]});break;case"Z":case"z":o.push({key:"Z",data:[]}),t=r,n=i;break}return o}function je(e){let t=[],n="",r=0,i=0,o=0,a=0,s=0,d=0;for(let{key:l,data:c}of e){switch(l){case"M":t.push({key:"M",data:[...c]}),[r,i]=c,[o,a]=c;break;case"C":t.push({key:"C",data:[...c]}),r=c[4],i=c[5],s=c[2],d=c[3];break;case"L":t.push({key:"L",data:[...c]}),[r,i]=c;break;case"H":r=c[0],t.push({key:"L",data:[r,i]});break;case"V":i=c[0],t.push({key:"L",data:[r,i]});break;case"S":{let p=0,u=0;n==="C"||n==="S"?(p=r+(r-s),u=i+(i-d)):(p=r,u=i),t.push({key:"C",data:[p,u,...c]}),s=c[0],d=c[1],r=c[2],i=c[3];break}case"T":{let[p,u]=c,f=0,m=0;n==="Q"||n==="T"?(f=r+(r-s),m=i+(i-d)):(f=r,m=i);let h=r+2*(f-r)/3,y=i+2*(m-i)/3,g=p+2*(f-p)/3,S=u+2*(m-u)/3;t.push({key:"C",data:[h,y,g,S,p,u]}),s=f,d=m,r=p,i=u;break}case"Q":{let[p,u,f,m]=c,h=r+2*(p-r)/3,y=i+2*(u-i)/3,g=f+2*(p-f)/3,S=m+2*(u-m)/3;t.push({key:"C",data:[h,y,g,S,f,m]}),s=p,d=u,r=f,i=m;break}case"A":{let p=Math.abs(c[0]),u=Math.abs(c[1]),f=c[2],m=c[3],h=c[4],y=c[5],g=c[6];p===0||u===0?(t.push({key:"C",data:[r,i,y,g,y,g]}),r=y,i=g):(r!==y||i!==g)&&(rr(r,i,y,g,p,u,f,m,h).forEach(function(k){t.push({key:"C",data:k})}),r=y,i=g);break}case"Z":t.push({key:"Z",data:[]}),r=o,i=a;break}n=l}return t}function Ci(e){return Math.PI*e/180}function Ne(e,t,n){let r=e*Math.cos(n)-t*Math.sin(n),i=e*Math.sin(n)+t*Math.cos(n);return[r,i]}function rr(e,t,n,r,i,o,a,s,d,l){let c=Ci(a),p=[],u=0,f=0,m=0,h=0;if(l)[u,f,m,h]=l;else{[e,t]=Ne(e,t,-c),[n,r]=Ne(n,r,-c);let w=(e-n)/2,x=(t-r)/2,A=w*w/(i*i)+x*x/(o*o);A>1&&(A=Math.sqrt(A),i=A*i,o=A*o);let U=s===d?-1:1,F=i*i,R=o*o,Te=F*R-F*x*x-R*w*w,J=F*x*x+R*w*w,ne=U*Math.sqrt(Math.abs(Te/J));m=ne*i*x/o+(e+n)/2,h=ne*-o*w/i+(t+r)/2,u=Math.asin(parseFloat(((t-h)/o).toFixed(9))),f=Math.asin(parseFloat(((r-h)/o).toFixed(9))),e<m&&(u=Math.PI-u),n<m&&(f=Math.PI-f),u<0&&(u=Math.PI*2+u),f<0&&(f=Math.PI*2+f),d&&u>f&&(u=u-Math.PI*2),!d&&f>u&&(f=f-Math.PI*2)}let y=f-u;if(Math.abs(y)>Math.PI*120/180){let w=f,x=n,A=r;d&&f>u?f=u+Math.PI*120/180*1:f=u+Math.PI*120/180*-1,n=m+i*Math.cos(f),r=h+o*Math.sin(f),p=rr(n,r,x,A,i,o,a,0,d,[f,w,m,h])}y=f-u;let g=Math.cos(u),S=Math.sin(u),k=Math.cos(f),H=Math.sin(f),v=Math.tan(y/4),L=4/3*i*v,Y=4/3*o*v,_=[e,t],N=[e+L*S,t-Y*g],C=[n+L*H,r-Y*k],G=[n,r];if(N[0]=2*_[0]-N[0],N[1]=2*_[1]-N[1],l)return[N,C,G].concat(p);{p=[N,C,G].concat(p);let w=[];for(let x=0;x<p.length;x+=3){let A=Ne(p[x][0],p[x][1],c),U=Ne(p[x+1][0],p[x+1][1],c),F=Ne(p[x+2][0],p[x+2][1],c);w.push([A[0],A[1],U[0],U[1],F[0],F[1]])}return w}}var Ai={randOffset:Ti,randOffsetWithRange:Di,ellipse:$i,doubleLineOps:Ii};function Ft(e,t,n,r,i){return{type:"path",ops:ae(e,t,n,r,i)}}function Le(e,t,n){let r=(e||[]).length;if(r>2){let i=[];for(let o=0;o<r-1;o++)i.push(...ae(e[o][0],e[o][1],e[o+1][0],e[o+1][1],n));return t&&i.push(...ae(e[r-1][0],e[r-1][1],e[0][0],e[0][1],n)),{type:"path",ops:i}}else if(r===2)return Ft(e[0][0],e[0][1],e[1][0],e[1][1],n);return{type:"path",ops:[]}}function Fi(e,t){return Le(e,!0,t)}function ar(e,t,n,r,i){let o=[[e,t],[e+n,t],[e+n,t+r],[e,t+r]];return Fi(o,i)}function $t(e,t){if(e.length){let r=typeof e[0][0]=="number"?[e]:e,i=rt(r[0],1*(1+t.roughness*.2),t),o=t.disableMultiStroke?[]:rt(r[0],1.5*(1+t.roughness*.22),ir(t));for(let a=1;a<r.length;a++){let s=r[a];if(s.length){let d=rt(s,1*(1+t.roughness*.2),t),l=t.disableMultiStroke?[]:rt(s,1.5*(1+t.roughness*.22),ir(t));for(let c of d)c.op!=="move"&&i.push(c);for(let c of l)c.op!=="move"&&o.push(c)}}return{type:"path",ops:i.concat(o)}}return{type:"path",ops:[]}}function $i(e,t,n,r,i){let o=Tt(n,r,i);return st(e,t,i,o).opset}function Tt(e,t,n){let r=Math.sqrt(Math.PI*2*Math.sqrt((Math.pow(e/2,2)+Math.pow(t/2,2))/2)),i=Math.ceil(Math.max(n.curveStepCount,n.curveStepCount/Math.sqrt(200)*r)),o=Math.PI*2/i,a=Math.abs(e/2),s=Math.abs(t/2),d=1-n.curveFitting;return a+=b(a*d,n),s+=b(s*d,n),{increment:o,rx:a,ry:s}}function st(e,t,n,r){let[i,o]=or(r.increment,e,t,r.rx,r.ry,1,r.increment*it(.1,it(.4,1,n),n),n),a=ot(i,null,n);if(!n.disableMultiStroke&&n.roughness!==0){let[s]=or(r.increment,e,t,r.rx,r.ry,1.5,0,n),d=ot(s,null,n);a=a.concat(d)}return{estimatedPoints:o,opset:{type:"path",ops:a}}}function Dt(e,t,n,r,i,o,a,s,d){let l=e,c=t,p=Math.abs(n/2),u=Math.abs(r/2);p+=b(p*.01,d),u+=b(u*.01,d);let f=i,m=o;for(;f<0;)f+=Math.PI*2,m+=Math.PI*2;m-f>Math.PI*2&&(f=0,m=Math.PI*2);let h=Math.PI*2/d.curveStepCount,y=Math.min(h/2,(m-f)/2),g=sr(y,l,c,p,u,f,m,1,d);if(!d.disableMultiStroke){let S=sr(y,l,c,p,u,f,m,1.5,d);g.push(...S)}return a&&(s?g.push(...ae(l,c,l+p*Math.cos(f),c+u*Math.sin(f),d),...ae(l,c,l+p*Math.cos(m),c+u*Math.sin(m),d)):g.push({op:"lineTo",data:[l,c]},{op:"lineTo",data:[l+p*Math.cos(f),c+u*Math.sin(f)]})),{type:"path",ops:g}}function It(e,t){let n=je(Pe(ve(e))),r=[],i=[0,0],o=[0,0];for(let{key:a,data:s}of n)switch(a){case"M":{o=[s[0],s[1]],i=[s[0],s[1]];break}case"L":r.push(...ae(o[0],o[1],s[0],s[1],t)),o=[s[0],s[1]];break;case"C":{let[d,l,c,p,u,f]=s;r.push(...Pi(d,l,c,p,u,f,o,t)),o=[u,f];break}case"Z":r.push(...ae(o[0],o[1],i[0],i[1],t)),o=[i[0],i[1]];break}return{type:"path",ops:r}}function at(e,t){let n=[];for(let r of e)if(r.length){let i=t.maxRandomnessOffset||0,o=r.length;if(o>2){n.push({op:"move",data:[r[0][0]+b(i,t),r[0][1]+b(i,t)]});for(let a=1;a<o;a++)n.push({op:"lineTo",data:[r[a][0]+b(i,t),r[a][1]+b(i,t)]})}}return{type:"fillPath",ops:n}}function ye(e,t){return tr(t,Ai).fillPolygons(e,t)}function cr(e,t,n,r,i,o,a){let s=e,d=t,l=Math.abs(n/2),c=Math.abs(r/2);l+=b(l*.01,a),c+=b(c*.01,a);let p=i,u=o;for(;p<0;)p+=Math.PI*2,u+=Math.PI*2;u-p>Math.PI*2&&(p=0,u=Math.PI*2);let f=(u-p)/a.curveStepCount,m=[];for(let h=p;h<=u;h=h+f)m.push([s+l*Math.cos(h),d+c*Math.sin(h)]);return m.push([s+l*Math.cos(u),d+c*Math.sin(u)]),m.push([s,d]),ye([m],a)}function Ti(e,t){return b(e,t)}function Di(e,t,n){return it(e,t,n)}function Ii(e,t,n,r,i){return ae(e,t,n,r,i,!0)}function ir(e){let t=Object.assign({},e);return t.randomizer=void 0,e.seed&&(t.seed=e.seed+1),t}function lr(e){return e.randomizer||(e.randomizer=new tt(e.seed||0)),e.randomizer.next()}function it(e,t,n,r=1){return n.roughness*r*(lr(n)*(t-e)+e)}function b(e,t,n=1){return it(-e,e,t,n)}function ae(e,t,n,r,i,o=!1){let a=o?i.disableMultiStrokeFill:i.disableMultiStroke,s=At(e,t,n,r,i,!0,!1);if(a)return s;let d=At(e,t,n,r,i,!0,!0);return s.concat(d)}function At(e,t,n,r,i,o,a){let s=Math.pow(e-n,2)+Math.pow(t-r,2),d=Math.sqrt(s),l=1;d<200?l=1:d>500?l=.4:l=-.0016668*d+1.233334;let c=i.maxRandomnessOffset||0;c*c*100>s&&(c=d/10);let p=c/2,u=.2+lr(i)*.2,f=i.bowing*i.maxRandomnessOffset*(r-t)/200,m=i.bowing*i.maxRandomnessOffset*(e-n)/200;f=b(f,i,l),m=b(m,i,l);let h=[],y=()=>b(p,i,l),g=()=>b(c,i,l),S=i.preserveVertices;return o&&(a?h.push({op:"move",data:[e+(S?0:y()),t+(S?0:y())]}):h.push({op:"move",data:[e+(S?0:b(c,i,l)),t+(S?0:b(c,i,l))]})),a?h.push({op:"bcurveTo",data:[f+e+(n-e)*u+y(),m+t+(r-t)*u+y(),f+e+2*(n-e)*u+y(),m+t+2*(r-t)*u+y(),n+(S?0:y()),r+(S?0:y())]}):h.push({op:"bcurveTo",data:[f+e+(n-e)*u+g(),m+t+(r-t)*u+g(),f+e+2*(n-e)*u+g(),m+t+2*(r-t)*u+g(),n+(S?0:g()),r+(S?0:g())]}),h}function rt(e,t,n){if(!e.length)return[];let r=[];r.push([e[0][0]+b(t,n),e[0][1]+b(t,n)]),r.push([e[0][0]+b(t,n),e[0][1]+b(t,n)]);for(let i=1;i<e.length;i++)r.push([e[i][0]+b(t,n),e[i][1]+b(t,n)]),i===e.length-1&&r.push([e[i][0]+b(t,n),e[i][1]+b(t,n)]);return ot(r,null,n)}function ot(e,t,n){let r=e.length,i=[];if(r>3){let o=[],a=1-n.curveTightness;i.push({op:"move",data:[e[1][0],e[1][1]]});for(let s=1;s+2<r;s++){let d=e[s];o[0]=[d[0],d[1]],o[1]=[d[0]+(a*e[s+1][0]-a*e[s-1][0])/6,d[1]+(a*e[s+1][1]-a*e[s-1][1])/6],o[2]=[e[s+1][0]+(a*e[s][0]-a*e[s+2][0])/6,e[s+1][1]+(a*e[s][1]-a*e[s+2][1])/6],o[3]=[e[s+1][0],e[s+1][1]],i.push({op:"bcurveTo",data:[o[1][0],o[1][1],o[2][0],o[2][1],o[3][0],o[3][1]]})}if(t&&t.length===2){let s=n.maxRandomnessOffset;i.push({op:"lineTo",data:[t[0]+b(s,n),t[1]+b(s,n)]})}}else r===3?(i.push({op:"move",data:[e[1][0],e[1][1]]}),i.push({op:"bcurveTo",data:[e[1][0],e[1][1],e[2][0],e[2][1],e[2][0],e[2][1]]})):r===2&&i.push(...At(e[0][0],e[0][1],e[1][0],e[1][1],n,!0,!0));return i}function or(e,t,n,r,i,o,a,s){let d=s.roughness===0,l=[],c=[];if(d){e=e/4,c.push([t+r*Math.cos(-e),n+i*Math.sin(-e)]);for(let p=0;p<=Math.PI*2;p=p+e){let u=[t+r*Math.cos(p),n+i*Math.sin(p)];l.push(u),c.push(u)}c.push([t+r*Math.cos(0),n+i*Math.sin(0)]),c.push([t+r*Math.cos(e),n+i*Math.sin(e)])}else{let p=b(.5,s)-Math.PI/2;c.push([b(o,s)+t+.9*r*Math.cos(p-e),b(o,s)+n+.9*i*Math.sin(p-e)]);let u=Math.PI*2+p-.01;for(let f=p;f<u;f=f+e){let m=[b(o,s)+t+r*Math.cos(f),b(o,s)+n+i*Math.sin(f)];l.push(m),c.push(m)}c.push([b(o,s)+t+r*Math.cos(p+Math.PI*2+a*.5),b(o,s)+n+i*Math.sin(p+Math.PI*2+a*.5)]),c.push([b(o,s)+t+.98*r*Math.cos(p+a),b(o,s)+n+.98*i*Math.sin(p+a)]),c.push([b(o,s)+t+.9*r*Math.cos(p+a*.5),b(o,s)+n+.9*i*Math.sin(p+a*.5)])}return[c,l]}function sr(e,t,n,r,i,o,a,s,d){let l=o+b(.1,d),c=[];c.push([b(s,d)+t+.9*r*Math.cos(l-e),b(s,d)+n+.9*i*Math.sin(l-e)]);for(let p=l;p<=a;p=p+e)c.push([b(s,d)+t+r*Math.cos(p),b(s,d)+n+i*Math.sin(p)]);return c.push([t+r*Math.cos(a),n+i*Math.sin(a)]),c.push([t+r*Math.cos(a),n+i*Math.sin(a)]),ot(c,null,d)}function Pi(e,t,n,r,i,o,a,s){let d=[],l=[s.maxRandomnessOffset||1,(s.maxRandomnessOffset||1)+.3],c=[0,0],p=s.disableMultiStroke?1:2,u=s.preserveVertices;for(let f=0;f<p;f++)f===0?d.push({op:"move",data:[a[0],a[1]]}):d.push({op:"move",data:[a[0]+(u?0:b(l[0],s)),a[1]+(u?0:b(l[0],s))]}),c=u?[i,o]:[i+b(l[f],s),o+b(l[f],s)],d.push({op:"bcurveTo",data:[e+b(l[f],s),t+b(l[f],s),n+b(l[f],s),r+b(l[f],s),c[0],c[1]]});return d}function _e(e){return[...e]}function Pt(e,t=0){let n=e.length;if(n<3)throw new Error("A curve must have at least three points.");let r=[];if(n===3)r.push(_e(e[0]),_e(e[1]),_e(e[2]),_e(e[2]));else{let i=[];i.push(e[0],e[0]);for(let s=1;s<e.length;s++)i.push(e[s]),s===e.length-1&&i.push(e[s]);let o=[],a=1-t;r.push(_e(i[0]));for(let s=1;s+2<i.length;s++){let d=i[s];o[0]=[d[0],d[1]],o[1]=[d[0]+(a*i[s+1][0]-a*i[s-1][0])/6,d[1]+(a*i[s+1][1]-a*i[s-1][1])/6],o[2]=[i[s+1][0]+(a*i[s][0]-a*i[s+2][0])/6,i[s+1][1]+(a*i[s][1]-a*i[s+2][1])/6],o[3]=[i[s+1][0],i[s+1][1]],r.push(o[1],o[2],o[3])}}return r}function Ni(e,t){return Math.sqrt(ct(e,t))}function ct(e,t){return Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)}function ji(e,t,n){let r=ct(t,n);if(r===0)return ct(e,t);let i=((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/r;return i=Math.max(0,Math.min(1,i)),ct(e,ge(t,n,i))}function ge(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n]}function Li(e,t){let n=e[t+0],r=e[t+1],i=e[t+2],o=e[t+3],a=3*r[0]-2*n[0]-o[0];a*=a;let s=3*r[1]-2*n[1]-o[1];s*=s;let d=3*i[0]-2*o[0]-n[0];d*=d;let l=3*i[1]-2*o[1]-n[1];return l*=l,a<d&&(a=d),s<l&&(s=l),a+s}function Nt(e,t,n,r){let i=r||[];if(Li(e,t)<n){let o=e[t+0];i.length?Ni(i[i.length-1],o)>1&&i.push(o):i.push(o),i.push(e[t+3])}else{let a=e[t+0],s=e[t+1],d=e[t+2],l=e[t+3],c=ge(a,s,.5),p=ge(s,d,.5),u=ge(d,l,.5),f=ge(c,p,.5),m=ge(p,u,.5),h=ge(f,m,.5);Nt([a,c,f,h],0,n,i),Nt([h,m,u,l],0,n,i)}return i}function dr(e,t){return lt(e,0,e.length,t)}function lt(e,t,n,r,i){let o=i||[],a=e[t],s=e[n-1],d=0,l=1;for(let c=t+1;c<n-1;++c){let p=ji(e[c],a,s);p>d&&(d=p,l=c)}return Math.sqrt(d)>r?(lt(e,t,l+1,r,o),lt(e,l,n,r,o)):(o.length||o.push(a),o.push(s)),o}function ze(e,t=.15,n){let r=[],i=(e.length-1)/3;for(let o=0;o<i;o++){let a=o*3;Nt(e,a,t,r)}return n&&n>0?lt(r,0,r.length,n):r}function pr(e,t,n){let r=ve(e),i=je(Pe(r)),o=[],a=[],s=[0,0],d=[],l=()=>{d.length>=4&&a.push(...ze(d,t)),d=[]},c=()=>{l(),a.length&&(o.push(a),a=[])};for(let{key:u,data:f}of i)switch(u){case"M":c(),s=[f[0],f[1]],a.push(s);break;case"L":l(),a.push([f[0],f[1]]);break;case"C":if(!d.length){let m=a.length?a[a.length-1]:s;d.push([m[0],m[1]])}d.push([f[0],f[1]]),d.push([f[2],f[3]]),d.push([f[4],f[5]]);break;case"Z":l(),a.push([s[0],s[1]]);break}if(c(),!n)return o;let p=[];for(let u of o){let f=dr(u,n);f.length&&p.push(f)}return p}var B="none",dt=class{constructor(t){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:"#000",strokeWidth:1,curveTightness:0,curveFitting:.95,curveStepCount:9,fillStyle:"hachure",fillWeight:-1,hachureAngle:-41,hachureGap:-1,dashOffset:-1,dashGap:-1,zigzagOffset:-1,seed:0,disableMultiStroke:!1,disableMultiStrokeFill:!1,preserveVertices:!1,fillShapeRoughnessGain:.8},this.config=t||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return nr()}_o(t){return t?Object.assign({},this.defaultOptions,t):this.defaultOptions}_d(t,n,r){return{shape:t,sets:n||[],options:r||this.defaultOptions}}line(t,n,r,i,o){let a=this._o(o);return this._d("line",[Ft(t,n,r,i,a)],a)}rectangle(t,n,r,i,o){let a=this._o(o),s=[],d=ar(t,n,r,i,a);if(a.fill){let l=[[t,n],[t+r,n],[t+r,n+i],[t,n+i]];a.fillStyle==="solid"?s.push(at([l],a)):s.push(ye([l],a))}return a.stroke!==B&&s.push(d),this._d("rectangle",s,a)}ellipse(t,n,r,i,o){let a=this._o(o),s=[],d=Tt(r,i,a),l=st(t,n,a,d);if(a.fill)if(a.fillStyle==="solid"){let c=st(t,n,a,d).opset;c.type="fillPath",s.push(c)}else s.push(ye([l.estimatedPoints],a));return a.stroke!==B&&s.push(l.opset),this._d("ellipse",s,a)}circle(t,n,r,i){let o=this.ellipse(t,n,r,r,i);return o.shape="circle",o}linearPath(t,n){let r=this._o(n);return this._d("linearPath",[Le(t,!1,r)],r)}arc(t,n,r,i,o,a,s=!1,d){let l=this._o(d),c=[],p=Dt(t,n,r,i,o,a,s,!0,l);if(s&&l.fill)if(l.fillStyle==="solid"){let u=Object.assign({},l);u.disableMultiStroke=!0;let f=Dt(t,n,r,i,o,a,!0,!1,u);f.type="fillPath",c.push(f)}else c.push(cr(t,n,r,i,o,a,l));return l.stroke!==B&&c.push(p),this._d("arc",c,l)}curve(t,n){let r=this._o(n),i=[],o=$t(t,r);if(r.fill&&r.fill!==B)if(r.fillStyle==="solid"){let a=$t(t,Object.assign(Object.assign({},r),{disableMultiStroke:!0,roughness:r.roughness?r.roughness+r.fillShapeRoughnessGain:0}));i.push({type:"fillPath",ops:this._mergedShape(a.ops)})}else{let a=[],s=t;if(s.length){let l=typeof s[0][0]=="number"?[s]:s;for(let c of l)c.length<3?a.push(...c):c.length===3?a.push(...ze(Pt([c[0],c[0],c[1],c[2]]),10,(1+r.roughness)/2)):a.push(...ze(Pt(c),10,(1+r.roughness)/2))}a.length&&i.push(ye([a],r))}return r.stroke!==B&&i.push(o),this._d("curve",i,r)}polygon(t,n){let r=this._o(n),i=[],o=Le(t,!0,r);return r.fill&&(r.fillStyle==="solid"?i.push(at([t],r)):i.push(ye([t],r))),r.stroke!==B&&i.push(o),this._d("polygon",i,r)}path(t,n){let r=this._o(n),i=[];if(!t)return this._d("path",i,r);t=(t||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");let o=r.fill&&r.fill!=="transparent"&&r.fill!==B,a=r.stroke!==B,s=!!(r.simplification&&r.simplification<1),d=s?4-4*(r.simplification||1):(1+r.roughness)/2,l=pr(t,1,d),c=It(t,r);if(o)if(r.fillStyle==="solid")if(l.length===1){let p=It(t,Object.assign(Object.assign({},r),{disableMultiStroke:!0,roughness:r.roughness?r.roughness+r.fillShapeRoughnessGain:0}));i.push({type:"fillPath",ops:this._mergedShape(p.ops)})}else i.push(at(l,r));else i.push(ye(l,r));return a&&(s?l.forEach(p=>{i.push(Le(p,!1,r))}):i.push(c)),this._d("path",i,r)}opsToPath(t,n){let r="";for(let i of t.ops){let o=typeof n=="number"&&n>=0?i.data.map(a=>+a.toFixed(n)):i.data;switch(i.op){case"move":r+=`M${o[0]} ${o[1]} `;break;case"bcurveTo":r+=`C${o[0]} ${o[1]}, ${o[2]} ${o[3]}, ${o[4]} ${o[5]} `;break;case"lineTo":r+=`L${o[0]} ${o[1]} `;break}}return r.trim()}toPaths(t){let n=t.sets||[],r=t.options||this.defaultOptions,i=[];for(let o of n){let a=null;switch(o.type){case"path":a={d:this.opsToPath(o),stroke:r.stroke,strokeWidth:r.strokeWidth,fill:B};break;case"fillPath":a={d:this.opsToPath(o),stroke:B,strokeWidth:0,fill:r.fill||B};break;case"fillSketch":a=this.fillSketch(o,r);break}a&&i.push(a)}return i}fillSketch(t,n){let r=n.fillWeight;return r<0&&(r=n.strokeWidth/2),{d:this.opsToPath(t),stroke:n.fill||B,strokeWidth:r,fill:B}}_mergedShape(t){return t.filter((n,r)=>r===0?!0:n.op!=="move")}};var Z=new dt;function ur(e){return{roughness:e?.roughness??1,bowing:e?.bowing??1,passes:e?.passes??2,strokeWidth:e?.strokeWidth??1.6,fill:e?.fill??"none",hachureAngle:e?.hachureAngle??-41,hachureGap:e?.hachureGap??5,fillWeight:e?.fillWeight??.9}}function _i(e,t,n,r,i){return{seed:t,roughness:e.roughness,bowing:e.bowing,stroke:n,strokeWidth:r,disableMultiStroke:e.passes<2,...i?{fill:i,fillStyle:e.fill==="solid"?"solid":"hachure",fillWeight:e.fillWeight,hachureGap:e.hachureGap,hachureAngle:e.hachureAngle}:{},preserveVertices:!1}}function zi(e={}){return[`stroke-linecap="${e.lineCap??"round"}"`,`stroke-linejoin="${e.lineJoin??"round"}"`,...e.miterLimit!==void 0?[`stroke-miterlimit="${z(String(e.miterLimit))}"`]:[],...e.dashArray!==void 0?[`stroke-dasharray="${z(e.dashArray)}"`]:[],...e.dashOffset!==void 0?[`stroke-dashoffset="${z(String(e.dashOffset))}"`]:[],...e.opacity!==void 0?[`stroke-opacity="${z(String(e.opacity))}"`]:[],...e.pathLength!==void 0?[`pathLength="${z(String(e.pathLength))}"`]:[],...e.paintOrder!==void 0?[`paint-order="${z(e.paintOrder)}"`]:[],...e.nonScaling?['vector-effect="non-scaling-stroke"']:[]].join(" ")}function ce(e,t,n,r,i,o={},a){let s=[],d=zi(o),l=d?` ${d}`:" ",c=a===void 0?"":` stroke-opacity="${z(String(a))}"`;for(let p of e){let u=Z.opsToPath(p,2);u&&(p.type==="path"?s.push(`<path d="${u}" fill="none" stroke="${t}" stroke-width="${n}"${l}${c} />`):p.type==="fillPath"?s.push(`<path d="${u}" fill="${r}" fill-opacity="${z(String(a??.92))}" stroke="none" />`):p.type==="fillSketch"&&s.push(`<path d="${u}" fill="none" stroke="${r}" stroke-width="${i.fillWeight}"${c} />`))}return s.join(`
2
+ `)}function Bi(e,t,n,r,i){let o=Math.min(i,n/2,r/2);return`M ${e+o} ${t} L ${e+n-o} ${t} Q ${e+n} ${t} ${e+n} ${t+o} L ${e+n} ${t+r-o} Q ${e+n} ${t+r} ${e+n-o} ${t+r} L ${e+o} ${t+r} Q ${e} ${t+r} ${e} ${t+r-o} L ${e} ${t+o} Q ${e} ${t} ${e+o} ${t} Z`}function fr(e,t,n,r,i,o,a,s,d){return mr(e,t,n,r,i,o,a,s,d)}function mr(e,t,n,r,i,o,a,s,d){let l={...s,...a!==void 0?{dashArray:a}:{}},c=_i(o,t,n,r,i);try{switch(e.kind){case"rect":return(e.rx??0)>.5?ce(Z.path(Bi(e.x,e.y,e.width,e.height,e.rx),c).sets,n,r,i,o,l,d):ce(Z.rectangle(e.x,e.y,e.width,e.height,c).sets,n,r,i,o,l,d);case"circle":return ce(Z.circle(e.cx,e.cy,e.r*2,c).sets,n,r,i,o,l,d);case"ellipse":return ce(Z.ellipse(e.cx,e.cy,e.rx*2,e.ry*2,c).sets,n,r,i,o,l,d);case"line":return ce(Z.line(e.x1,e.y1,e.x2,e.y2,c).sets,n,r,void 0,o,l,d);case"polygon":return ce(Z.polygon(e.points.map(p=>[p.x,p.y]),c).sets,n,r,i,o,l,d);case"polyline":return ce(Z.linearPath(e.points.map(p=>[p.x,p.y]),c).sets,n,r,void 0,o,l,d);case"path":return ce(Z.path(e.d,c).sets,n,r,i,o,l,d);case"compound":return""}}catch{return""}}function we(e,t,n,r,i,o,a,s,d){if(e.sketcher){let l=e.sketcher(t,{seed:n,stroke:r,width:i,fill:o,p:e.p,style:e.ctx.style,dash:a,strokeProjection:s,opacity:d});if(l!==null)return l}return mr(t,n,r,i,o,e.p,a,s,d)}function hr(e,t,n){return e.replace(`<${t} `,`<${t} ${n} `)}function yr(e){if(e===void 0)return 1;let t=typeof e=="number"?e:parseFloat(e);return Number.isNaN(t)?1:t}function pt(e,t){return e!==void 0?e:t}function Gi(e,t){return/style="/.test(e)?e.replace(/style="([^"]*)"/,(n,r)=>{let i=r.trim().length===0||/;\s*$/.test(r)?"":";";return`style="${r}${i}stroke:none"`}):hr(e,t,'style="stroke:none"')}function jt(e,t){return!t||e===""?e:t.kind==="rotate"?`<g transform="rotate(${t.angle} ${t.cx} ${t.cy})">${e}</g>`:e}function Vi(e,t){let n=t.p,r=re(e),i=Dn(r),o=e.geometry.kind==="compound"?e.geometry.children:[e.geometry];if(i.length<o.length)return r;let a=r.split(`
3
+ `),s=c=>a.length===1&&c===0?r:a[c]??"",d=[];for(let c=0;c<o.length;c++){let p=i[c],u=pt(p.attrs.get("stroke"),e.paint.stroke),f=pt(p.attrs.get("fill"),e.paint.fill),m=Et(t.ctx.seed,e.id,`outline:${c}`)||1,h=yr(pt(p.attrs.get("stroke-width"),e.paint.strokeWidth)),y=pt(p.attrs.get("stroke-dasharray"),e.paint.strokeDasharray),g=u!==void 0&&u!=="none"&&h>0,S=f!==void 0&&f!=="none",k=S&&n.fill!=="none"?f:void 0;if(!g){if(k){let L=we(t,o[c],m,"none",0,k,y,void 0,e.paint.opacity);if(L){d.push(jt(L,e.transform));continue}}d.push(s(c));continue}let H=Math.max(.6,Math.min(n.strokeWidth*h,n.strokeWidth*4)),v=we(t,o[c],m,u,H,k,y,void 0,e.paint.opacity);if(!v){d.push(s(c));continue}S&&n.fill==="none"&&!Wi(f)&&d.push(Gi(s(c),p.tag)),d.push(jt(v,e.transform))}let l=d.filter(Boolean).join(`
4
+ `);return e.identity&&!/\sdata-id=/.test(l)?En(l,e.identity):l}function Wi(e){return e.startsWith("var(--_node-fill")||e.startsWith("var(--_group")||e==="var(--bg)"||e==="var(--surface)"}function qi(e,t){let n=re(e);if(e.lineStyle==="invisible"||n==="")return n;let r=e.stroke.color,i=yr(e.stroke.width);if(i<=0)return n;let o=t.p.strokeWidth*i,a=Et(t.ctx.seed,e.id,"stroke")||1,s=e.stroke.dash?typeof e.stroke.dash.array=="string"?e.stroke.dash.array:e.stroke.dash.array.join(" "):void 0,d={...s!==void 0?{dashArray:s}:{},...e.stroke.dash?.offset!==void 0?{dashOffset:e.stroke.dash.offset}:{},lineCap:e.stroke.lineCap,lineJoin:e.stroke.lineJoin,miterLimit:e.stroke.miterLimit,...e.stroke.opacity!==void 0?{opacity:e.stroke.opacity}:{},...e.stroke.pathLength!==void 0?{pathLength:e.stroke.pathLength}:{},...e.stroke.paintOrder!==void 0?{paintOrder:e.stroke.paintOrder}:{},nonScaling:e.stroke.nonScaling},l="",c=e.route.geometry;if(c.kind==="polyline")l=we(t,{kind:"polyline",points:c.points},a,r,o,void 0,s,d);else if(c.kind==="line")l=we(t,c,a,r,o,void 0,s,d);else{let f=Mn(c,e.route.closed);if(f.length===1&&(l=we(t,{kind:"path",d:c.d},a,r,o,void 0,s,d)),!l&&c.points.length>1){let m=f.map((h,y)=>{let g=h.points[0],S=h.points.at(-1),k=h.closed&&g&&S&&(g.x!==S.x||g.y!==S.y)?[...h.points,g]:h.points;return we(t,{kind:"polyline",points:[...k]},a+y,r,o,void 0,s,d)});l=m.every(Boolean)?m.join(`
5
+ `):""}}if(!l)return n;let p=n.replace(/\sstroke-opacity=(?:"[^"]*"|'[^']*')/,' stroke-opacity="0"');return`${p===n?hr(n,e.route.geometry.kind,'stroke-opacity="0"'):p}
6
+ ${jt(l,e.transform)}`}function Hi(e){return re(e).replace(/<text /g,'<text paint-order="stroke" stroke="var(--bg)" stroke-width="3" stroke-linejoin="round" stroke-linecap="round" ')}function Ui(e,t){let n=e?.backdrop??"plain";if(n==="paper-ruled"){let r=['<g data-backdrop="paper-ruled">'];for(let i=26;i<t.height;i+=26)r.push(` <line x1="0" y1="${i}" x2="${t.width}" y2="${i}" stroke="var(--_line)" stroke-width="0.5" opacity="0.14" />`);return r.push("</g>"),r.join(`
7
+ `)}if(n==="grid"){let r=['<g data-backdrop="grid">'];for(let i=22;i<t.width;i+=22)r.push(` <line x1="${i}" y1="0" x2="${i}" y2="${t.height}" stroke="var(--_line)" stroke-width="0.5" opacity="0.10" />`);for(let i=22;i<t.height;i+=22)r.push(` <line x1="0" y1="${i}" x2="${t.width}" y2="${i}" stroke="var(--_line)" stroke-width="0.5" opacity="0.10" />`);return r.push("</g>"),r.join(`
8
+ `)}return""}function Lt(e,t){switch(e.kind){case"document":return re(e);case"shape":return Xe(e.role).sketch==="shape"?Vi(e,t):re(e);case"connector":return Xe(e.role).sketch==="connector"?qi(e,t):re(e);case"text":return Xe(e.role).textHalo?Hi(e):re(e);case"group":return _n(e.open,e.close,e.join,e.children.map(n=>({serialized:Lt(n.node,t),indent:n.indent})))}}function _t(e,t){return{id:e,capabilities:Tn(`backend:${e}`,"sketch",t?"hybrid":"rough"),drawNode(n,r){return Lt(n,{ctx:r,p:ur(r.style),sketcher:t})},render(n,r){let i=Ln(n),o={ctx:r,p:ur(r.style),sketcher:t},a=[];for(let s=0;s<i.parts.length;s++){let d=i.parts[s];if(a.push(Lt(d,o)),s===0&&d.kind==="document"&&d.element==="open"){let l=zn(i,r);l&&a.push(l);let c=Ui(r.style,i);c&&a.push(c)}}return a.join(`
9
+ `)}}}var gr=_t("rough");var{PI:Ji}=Math,Be=Ji+1e-4,br=.5,Sr=[1,1];function Rr(e,t,n,r=i=>i){return e*r(.5-t*(.5-n))}var{min:zt}=Math;function Ar(e,t,n){let r=zt(1,t/n);return zt(1,e+(zt(1,1-r)-e)*(r*.275))}function Xi(e){return[-e[0],-e[1]]}function K(e,t){return[e[0]+t[0],e[1]+t[1]]}function xr(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function ue(e,t){return[e[0]-t[0],e[1]-t[1]]}function Vt(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function pe(e,t){return[e[0]*t,e[1]*t]}function Bt(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e}function Ki(e,t){return[e[0]/t,e[1]/t]}function Fr(e){return[e[1],-e[0]]}function Gt(e,t){let n=t[0];return e[0]=t[1],e[1]=-n,e}function kr(e,t){return e[0]*t[0]+e[1]*t[1]}function Yi(e,t){return e[0]===t[0]&&e[1]===t[1]}function Zi(e){return Math.hypot(e[0],e[1])}function Or(e,t){let n=e[0]-t[0],r=e[1]-t[1];return n*n+r*r}function $r(e){return Ki(e,Zi(e))}function Qi(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function Wt(e,t,n){let r=Math.sin(n),i=Math.cos(n),o=e[0]-t[0],a=e[1]-t[1],s=o*i-a*r,d=o*r+a*i;return[s+t[0],d+t[1]]}function vr(e,t,n,r){let i=Math.sin(r),o=Math.cos(r),a=t[0]-n[0],s=t[1]-n[1],d=a*o-s*i,l=a*i+s*o;return e[0]=d+n[0],e[1]=l+n[1],e}function wr(e,t,n){return K(e,pe(ue(t,e),n))}function eo(e,t,n,r){let i=n[0]-t[0],o=n[1]-t[1];return e[0]=t[0]+i*r,e[1]=t[1]+o*r,e}function Tr(e,t,n){return K(e,pe(t,n))}var M=[0,0],le=[0,0],de=[0,0];function to(e,t){let n=Tr(e,$r(Fr(ue(e,K(e,[1,1])))),-t),r=[],i=1/13;for(let o=i;o<=1;o+=i)r.push(Wt(n,e,Be*2*o));return r}function no(e,t,n){let r=[],i=1/n;for(let o=i;o<=1;o+=i)r.push(Wt(t,e,Be*o));return r}function ro(e,t,n){let r=ue(t,n),i=pe(r,.5),o=pe(r,.51);return[ue(e,i),ue(e,o),K(e,o),K(e,i)]}function io(e,t,n,r){let i=[],o=Tr(e,t,n),a=1/r;for(let s=a;s<1;s+=a)i.push(Wt(o,e,Be*3*s));return i}function oo(e,t,n){return[K(e,pe(t,n)),K(e,pe(t,n*.99)),ue(e,pe(t,n*.99)),ue(e,pe(t,n))]}function Er(e,t,n){return e===!1||e===void 0?0:e===!0?Math.max(t,n):e}function so(e,t,n){return e.slice(0,10).reduce((r,i)=>{let o=i.pressure;return t&&(o=Ar(r,i.distance,n)),(r+o)/2},e[0].pressure)}function ao(e,t={}){let{size:n=16,smoothing:r=.5,thinning:i=.5,simulatePressure:o=!0,easing:a=R=>R,start:s={},end:d={},last:l=!1}=t,{cap:c=!0,easing:p=R=>R*(2-R)}=s,{cap:u=!0,easing:f=R=>--R*R*R+1}=d;if(e.length===0||n<=0)return[];let m=e[e.length-1].runningLength,h=Er(s.taper,n,m),y=Er(d.taper,n,m),g=(n*r)**2,S=[],k=[],H=so(e,o,n),v=Rr(n,i,e[e.length-1].pressure,a),L,Y=e[0].vector,_=e[0].point,N=_,C=_,G=N,w=!1;for(let R=0;R<e.length;R++){let{pressure:Te}=e[R],{point:J,vector:ne,distance:Ri,runningLength:De}=e[R],We=R===e.length-1;if(!We&&m-De<3)continue;i?(o&&(Te=Ar(H,Ri,n)),v=Rr(n,i,Te,a)):v=n/2,L===void 0&&(L=v);let xi=De<h?p(De/h):1,ki=m-De<y?f((m-De)/y):1;v=Math.max(.01,v*Math.min(xi,ki));let cn=(We?e[R]:e[R+1]).vector,St=We?1:kr(ne,cn),Oi=kr(ne,Y)<0&&!w,ln=St!==null&&St<0;if(Oi||ln){Gt(M,Y),Bt(M,M,v);for(let qe=0;qe<=1;qe+=.07692307692307693)Vt(le,J,M),vr(le,le,J,Be*qe),C=[le[0],le[1]],S.push(C),xr(de,J,M),vr(de,de,J,Be*-qe),G=[de[0],de[1]],k.push(G);_=C,N=G,ln&&(w=!0);continue}if(w=!1,We){Gt(M,ne),Bt(M,M,v),S.push(ue(J,M)),k.push(K(J,M));continue}eo(M,cn,ne,St),Gt(M,M),Bt(M,M,v),Vt(le,J,M),C=[le[0],le[1]],(R<=1||Or(_,C)>g)&&(S.push(C),_=C),xr(de,J,M),G=[de[0],de[1]],(R<=1||Or(N,G)>g)&&(k.push(G),N=G),H=Te,Y=ne}let x=[e[0].point[0],e[0].point[1]],A=e.length>1?[e[e.length-1].point[0],e[e.length-1].point[1]]:K(e[0].point,[1,1]),U=[],F=[];if(e.length===1){if(!(h||y)||l)return to(x,L||v)}else{h||y&&e.length===1||(c?U.push(...no(x,k[0],13)):U.push(...ro(x,S[0],k[0])));let R=Fr(Xi(e[e.length-1].vector));y||h&&e.length===1?F.push(A):u?F.push(...io(A,R,v,29)):F.push(...oo(A,R,v))}return S.concat(F,k.reverse(),U)}var Mr=[0,0];function Cr(e){return e!=null&&e>=0}function co(e,t={}){let{streamline:n=.5,size:r=16,last:i=!1}=t;if(e.length===0)return[];let o=.15+(1-n)*.85,a=Array.isArray(e[0])?e:e.map(({x:u,y:f,pressure:m=br})=>[u,f,m]);if(a.length===2){let u=a[1];a=a.slice(0,-1);for(let f=1;f<5;f++)a.push(wr(a[0],u,f/4))}a.length===1&&(a=[...a,[...K(a[0],Sr),...a[0].slice(2)]]);let s=[{point:[a[0][0],a[0][1]],pressure:Cr(a[0][2])?a[0][2]:.25,vector:[...Sr],distance:0,runningLength:0}],d=!1,l=0,c=s[0],p=a.length-1;for(let u=1;u<a.length;u++){let f=i&&u===p?[a[u][0],a[u][1]]:wr(c.point,a[u],o);if(Yi(c.point,f))continue;let m=Qi(f,c.point);if(l+=m,u<p&&!d){if(l<r)continue;d=!0}Vt(Mr,c.point,f),c={point:f,pressure:Cr(a[u][2])?a[u][2]:br,vector:$r(Mr),distance:m,runningLength:l},s.push(c)}return s[0].vector=s[1]?.vector||[0,0],s}function Dr(e,t={}){return ao(co(e,t),t)}var fe=e=>Math.round(e*1e3)/1e3,Ir=(e,t,n)=>e+(t-e)*n,lo=e=>Math.max(0,Math.min(1,e));function Pr(e){switch(e.kind){case"rect":return[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}];case"polygon":return e.points;case"circle":{let t=[];for(let n=0;n<24;n++){let r=n/24*Math.PI*2;t.push({x:e.cx+Math.cos(r)*e.r,y:e.cy+Math.sin(r)*e.r})}return t}case"ellipse":{let t=[];for(let n=0;n<28;n++){let r=n/28*Math.PI*2;t.push({x:e.cx+Math.cos(r)*e.rx,y:e.cy+Math.sin(r)*e.ry})}return t}default:return null}}function po(e){if(e.length<2)return"";let t=[`M${fe(e[0][0])},${fe(e[0][1])}`];for(let n=1;n<e.length;n++){let[r,i]=e[n],[o,a]=e[(n+1)%e.length];t.push(`Q${fe(r)},${fe(i)} ${fe((r+o)/2)},${fe((i+a)/2)}`)}return t.push("Z"),t.join(" ")}function uo(e,t,n,r){let i=n?[...e,e[0]]:e,o=[];for(let s=0;s<i.length-1;s++){let d=i[s],l=i[s+1],c=Math.hypot(l.x-d.x,l.y-d.y)||1,p=Math.max(1,Math.ceil(c/14)),u=-(l.y-d.y)/c,f=(l.x-d.x)/c;for(let m=0;m<p;m++){if(s>0&&m===0)continue;let h=m/p,g=!n&&(s===0&&m===0||s===i.length-2&&m===p)?0:(t()-.5)*2*r,S={x:Ir(d.x,l.x,h)+u*g,y:Ir(d.y,l.y,h)+f*g},k=(s+h)/Math.max(1,i.length-1),H=lo(.52+Math.sin(k*Math.PI*2)*.12+(t()-.5)*.16);o.push([S.x,S.y,H])}}let a=i[i.length-1];return o.push([a.x,a.y,n?o[0]?.[2]??.55:.46]),o}function qt(e,t,n){if(e.length<2)return"";let r=uo(e,t,n.closed,1),i=Dr(r,{size:n.width,thinning:.58,smoothing:.62,streamline:.35,simulatePressure:!1,start:{cap:!0,taper:n.closed?0:10},end:{cap:!0,taper:n.closed?0:14},last:!0});return po(i)}function fo(e,t,n,r,i){let a=e.map(s=>({x:s.x+(t()-.5)*3,y:s.y+(t()-.5)*3})).map((s,d)=>`${d?"L":"M"}${fe(s.x)},${fe(s.y)}`).join(" ")+" Z";return`<path d="${a}" fill="${n}" fill-opacity="${r}" stroke="none" />
10
+ <path d="${a}" fill="none" stroke="${n}" stroke-width="1.4" stroke-opacity="${i}" />`}var mo=(e,t)=>{let n=t.style?.stroke??"jittered",i=(t.style?.fill??"none")==="wash"&&t.fill!==void 0,o=n==="freehand",a=t.opacity===void 0?void 0:Number(t.opacity);if(!i&&!o)return null;let s=[];if(i){let l=wt((t.seed^2654435769)>>>0),c=e.kind==="path"?null:Pr(e);c?s.push(fo(c,l,t.fill,a??t.style?.washOpacity??.3,t.style?.washEdge??.34)):e.kind==="path"&&s.push(`<path d="${e.d}" fill="${t.fill}" fill-opacity="${a??t.style?.washOpacity??.3}" stroke="${t.fill}" stroke-width="1.4" stroke-opacity="${t.style?.washEdge??.34}" />`)}if(o&&!t.dash){let l=wt(t.seed||1),c=Math.max(2.5,t.width*2.2),p="";if(e.kind==="polyline")p=qt(e.points,l,{width:c,closed:!1});else if(e.kind==="line")p=qt([{x:e.x1,y:e.y1},{x:e.x2,y:e.y2}],l,{width:c,closed:!1});else{let u=Pr(e);u&&(p=qt(u,l,{width:c,closed:!0}))}if(p){let u=t.strokeProjection?[...t.strokeProjection.opacity!==void 0?[`opacity="${z(String(t.strokeProjection.opacity))}"`]:[],...t.strokeProjection.paintOrder!==void 0?[`paint-order="${z(t.strokeProjection.paintOrder)}"`]:[]].join(" "):"",f=a===void 0?"":` fill-opacity="${z(String(a))}"`;return s.push(`<path d="${p}" fill="${t.stroke}" stroke="none"${f}${u?` ${u}`:""} />`),s.join(`
11
+ `)}}let d=fr(e,t.seed,t.stroke,t.width,i?void 0:t.fill,t.p,t.dash,t.strokeProjection,t.opacity);return d&&s.push(d),s.length>0?s.join(`
12
+ `):null},Nr=_t("hybrid",mo);var ho=Object.freeze([Bn,gr,Nr]);for(let e of ho)Gn(e);function jr(e,t){return e.match(new RegExp(`\\b${t}\\s*=\\s*(["'])(.*?)\\1`,"i"))?.[2]}function Ht(e,t){return jr(e,"style")?.match(new RegExp(`(?:^|;)\\s*${t}\\s*:\\s*([^;]+)`,"i"))?.[1]?.trim()??jr(e,t)}function Lr(e,t,n){let r=Number.parseFloat(Ht(e,t)??"");return Number.isFinite(r)?r:n}function _r(e,t){let n=Ht(e,"font-weight")?.trim().toLowerCase();if(n===void 0)return t;if(n==="normal")return 400;if(n==="bold")return 700;if(n==="bolder")return t<350?400:t<550?700:900;if(n==="lighter")return t<550?100:t<750?400:700;let r=Number.parseFloat(n);return Number.isFinite(r)?r:t}function yo(e){return/\bclass\s*=\s*(["'])[^"']*\bmono\b/i.test(e)||/(?:^|[,\s])monospace(?:[,\s]|$)/i.test(Ht(e,"font-family")??"")}function go(e,t){let n="";for(let r=t+1;r<e.length;r++){let i=e[r];if(n){i===n&&(n="");continue}if(i==='"'||i==="'"){n=i;continue}if(i===">")return r}return-1}function bo(e){let t=[],n=[],r=0;for(;r<e.length;){let i=e.indexOf("<",r);if(i<0){n.length>0&&r<e.length&&n[n.length-1].children.push({kind:"text-node",raw:e.slice(r)}),r=e.length;break}if(n.length>0&&i>r&&n[n.length-1].children.push({kind:"text-node",raw:e.slice(r,i)}),e.startsWith("<!--",i)){let c=e.indexOf("-->",i+4);if(c<0)return null;r=c+3;continue}let o=go(e,i);if(o<0)return null;let a=e.slice(i,o+1);if(/^<\?/.test(a)||/^<!/.test(a)){r=o+1;continue}let s=a.match(/^<\/\s*([\w:-]+)\s*>$/);if(s){let c=n.pop();if(!c||c.name!==s[1].toLowerCase())return null;c.closeStart=i,r=o+1;continue}let d=a.match(/^<\s*([\w:-]+)([\s\S]*?)(\/?)>$/);if(!d)return null;let l={kind:"element",name:d[1].toLowerCase(),attrs:d[2],openEnd:o+1,closeStart:o+1,children:[]};n.length>0?n[n.length-1].children.push(l):t.push(l),d[3]!=="/"&&n.push(l),r=o+1}return n.length===0?t:null}function zr(e){return e.children.filter(t=>t.kind==="element")}function Br(e,t){let n=t.name==="b"||t.name==="strong";return{size:Lr(t.attrs,"font-size",e.size),weight:n?Math.max(700,_r(t.attrs,e.weight)):_r(t.attrs,e.weight),letterSpacing:Lr(t.attrs,"letter-spacing",e.letterSpacing),mono:e.mono||yo(t.attrs)}}function Ut(e,t){return new RegExp(`\\b${t}\\s*=`,"i").test(e)}function Jt(e){return e.name==="tspan"&&["x","y","dx","dy"].some(t=>Ut(e.attrs,t))}function Gr(e){return zr(e).some(t=>Jt(t)||Gr(t))}function So(e,t){let n=[],r=!1,i=(o,a,s)=>{let d=Br(a,o);if(!(!s&&Jt(o))){if(!s&&Ut(o.attrs,"textLength")){r=!0;return}for(let l of o.children)if(l.kind==="text-node"){let c=He(l.raw);c.length>0&&n.push({text:c,metrics:d})}else i(l,d,!1)}};return i(e,t,!0),{runs:n,blocked:r}}function Ro(e){let t=e.filter(o=>o.text.length>0);if(t.length===0||t.every(o=>o.text.trim().length===0))return null;let n=0,r=0,i=0;for(let o of t){if(!(o.metrics.size>0))return null;let a=yn(o.text).length;r>0&&a>0&&(n+=i),n+=o.metrics.mono?gn(o.text,o.metrics.size,o.metrics.letterSpacing):bn(o.text,o.metrics.size,o.metrics.weight,o.metrics.letterSpacing),r=a,i=o.metrics.letterSpacing}return Math.round(n*1e3)/1e3}function Vr(e,t){let n=bo(e);if(!n)return e;let r=[],i={size:0,weight:400,letterSpacing:0,mono:!1},o=(s,d,l)=>{let c=Br(d,s),p=s.name==="text"&&!l,u=p||l&&Jt(s);if(u&&Ut(s.attrs,"textLength"))return;if(u&&!(p&&Gr(s))){let h=So(s,d),y=h.blocked?null:Ro(h.runs);y!==null&&r.push({offset:s.openEnd-1,text:` textLength="${y}" lengthAdjust="spacingAndGlyphs" data-font-metrics="deterministic-fit"`})}let m=l||p;for(let h of zr(s))o(h,c,m)};for(let s of n)o(s,i,!1);let a=e;for(let s of r.sort((d,l)=>l.offset-d.offset))a=a.slice(0,s.offset)+s.text+a.slice(s.offset);return a}function be(e,t){if(!e||typeof e!="object"||Array.isArray(e))return;let n=e[t];return n&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function xo(e,t,n){if(!n)return[];let r=t&&typeof t=="object"&&!Array.isArray(t)?t:void 0,i=be(t,n.section);if(!i)return r&&n.section in r?[{code:"INEFFECTIVE_CONFIG",field:n.section,message:`${e} config section "${n.section}" must be an object; the invalid value has no effect.`}]:[];let o=new Set(n.keys);return Object.keys(i).filter(a=>!o.has(a)).sort().map(a=>({code:"INEFFECTIVE_CONFIG",field:`${n.section}.${a}`,message:`${e} config field "${a}" is unknown and has no effect; check the spelling or remove it.`}))}var D=(e,t)=>({expected:e,valid:t}),T=D("a finite positive number",e=>typeof e=="number"&&Number.isFinite(e)&&e>0),V=D("a finite non-negative number",e=>typeof e=="number"&&Number.isFinite(e)&&e>=0),ko=D("a finite number",e=>typeof e=="number"&&Number.isFinite(e)),O=D("a boolean",e=>typeof e=="boolean"),Xt=D("a non-empty string",e=>typeof e=="string"&&e.trim().length>0),Kt=D("a non-empty array of strings",e=>Array.isArray(e)&&e.length>0&&e.every(t=>typeof t=="string")),Wr=(...e)=>D(`one of: ${e.join(", ")}`,t=>typeof t=="string"&&e.includes(t)),qr=(...e)=>D(`one of: ${e.join(", ")} (case-insensitive)`,t=>typeof t=="string"&&e.some(n=>n.toLowerCase()===t.toLowerCase())),Ee=(e,t,n=!0)=>D(`a finite number ${n?"from":"greater than"} ${e} through ${t}`,r=>typeof r=="number"&&Number.isFinite(r)&&(n?r>=e:r>e)&&r<=t),Q=e=>D(`a finite positive number no greater than ${e}`,t=>typeof t=="number"&&Number.isFinite(t)&&t>0&&t<=e),ut=e=>D(`a finite non-negative number no greater than ${e}`,t=>typeof t=="number"&&Number.isFinite(t)&&t>=0&&t<=e),Oo=D("a finite positive number or non-empty CSS size string",e=>typeof e=="number"&&Number.isFinite(e)&&e>0||typeof e=="string"&&e.trim().length>0),Ge=(e,t=!1)=>D(`a numeric value${t?` greater than ${e}`:` of at least ${e}`}`,n=>{let r=typeof n=="number"?n:typeof n=="string"&&/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:px)?$/i.test(n.trim())?Number.parseFloat(n):Number.NaN;return Number.isFinite(r)&&(t?r>e:r>=e)}),vo={flowchart:{nodeSpacing:T,rankSpacing:T,wrappingWidth:T},sequence:Object.fromEntries([...["actorMargin","width","height","diagramMarginX","diagramMarginY","messageMargin","noteMargin","activationWidth"].map(e=>[e,V]),["showSequenceNumbers",O]]),timeline:{disableMulticolor:O,sectionFills:Kt,sectionColours:Kt},journey:Object.fromEntries([...["diagramMarginX","diagramMarginY","leftMargin","maxLabelWidth","width","height","taskMargin"].map(e=>[e,T]),...["taskFontSize","titleFontSize"].map(e=>[e,Oo]),...["taskFontFamily","titleColor","titleFontFamily"].map(e=>[e,Xt]),...["actorColours","sectionFills","sectionColours"].map(e=>[e,Kt]),["useMaxWidth",O]]),radar:{width:Q($.dimension),height:Q($.dimension),marginTop:ut($.margin),marginRight:ut($.margin),marginBottom:ut($.margin),marginLeft:ut($.margin),axisScaleFactor:Q($.factor),axisLabelFactor:Ee($.axisLabelFactorMin,$.factor),curveTension:Ee(0,1),useMaxWidth:O,tickLabels:O},class:{nodeSpacing:V,rankSpacing:V,hierarchicalNamespaces:O},er:{layoutDirection:qr("TB","TD","BT","LR","RL"),nodeSpacing:V,rankSpacing:V},architecture:{padding:Ge(0),iconSize:Ge(0,!0),fontSize:Ge(0,!0),nodeSeparation:Ge(0),idealEdgeLengthMultiplier:Ge(0,!0)},xychart:{width:T,height:T,useMaxWidth:O,useWidth:T,titleFontSize:T,titlePadding:V,chartOrientation:Wr("vertical","horizontal"),plotReservedSpacePercent:Ee(0,100,!1),showDataLabel:O,showTitle:O,showLegend:O,legendFontSize:T,legendPadding:V,xAxis:D("an axis-config object",e=>!!e&&typeof e=="object"&&!Array.isArray(e)),yAxis:D("an axis-config object",e=>!!e&&typeof e=="object"&&!Array.isArray(e))},pie:{textPosition:Ee(0,1),donutHole:Ee(0,.9),legendPosition:Wr("top","bottom","left","right","center")},quadrant:Object.fromEntries([...["chartWidth","chartHeight","titleFontSize","quadrantLabelFontSize","xAxisLabelFontSize","yAxisLabelFontSize","pointLabelFontSize","pointRadius"].map(e=>[e,T]),...["titlePadding","quadrantPadding","xAxisLabelPadding","yAxisLabelPadding","pointTextPadding","quadrantInternalBorderStrokeWidth","quadrantExternalBorderStrokeWidth"].map(e=>[e,V]),["useMaxWidth",O]]),gantt:{displayMode:qr("compact"),barHeight:T,topAxis:O,axisFormat:Xt,tickInterval:D('a positive Mermaid interval such as "1day" or "2week"',e=>typeof e=="string"&&/^[1-9]\d*(?:millisecond|second|minute|hour|day|week|month)$/i.test(e.trim()))},mindmap:{padding:V,maxNodeWidth:T},gitgraph:{showBranches:O,showCommitLabel:O,parallelCommits:O,rotateCommitLabel:O,mainBranchName:Xt,mainBranchOrder:ko}},wo={showLabel:O,labelFontSize:T,labelPadding:V,showTitle:O,titleFontSize:T,titlePadding:V,showTick:O,tickLength:V,tickWidth:T,showAxisLine:O,axisLineWidth:T};function Eo(e){let t=be(e,"themeVariables");if(!t||!("radar"in t))return[];let n=be(t,"radar");if(!n)return[{code:"INEFFECTIVE_CONFIG",field:"themeVariables.radar",message:"themeVariables.radar must be an object; the invalid value has no effect."}];let r=new Set(Qn),i=[],o=new Set(["axisStrokeWidth","curveStrokeWidth","graticuleStrokeWidth"]),a=new Set(["axisLabelFontSize","legendFontSize"]),s=new Set(["curveOpacity","graticuleOpacity"]),d=new Set(["axisColor","graticuleColor"]);for(let l of Object.keys(n).sort(Ue)){let c=n[l],p;r.has(l)?o.has(l)&&!Q($.lineWidth).valid(c)?p=Q($.lineWidth).expected:a.has(l)&&!Q($.fontSize).valid(c)?p=Q($.fontSize).expected:l==="legendBoxSize"&&!Q($.legendBoxSize).valid(c)?p=Q($.legendBoxSize).expected:s.has(l)&&!Ee(0,1).valid(c)?p="a finite number from 0 through 1":d.has(l)&&!Ie(c)&&(p="a safe CSS color without url(), variables, or context-breaking characters"):p="a documented radar theme field",p&&i.push({code:"INEFFECTIVE_CONFIG",field:`themeVariables.radar.${l}`,message:`themeVariables.radar.${l} must be ${p}; the invalid value has no effect.`})}return i}function Mo(e,t,n){if(e==="state")return[];if(!n)return[];let r=be(t,n.section),i=e==="radar"?Eo(t):[],o=(a,s)=>{i.push({code:"INEFFECTIVE_CONFIG",field:a,message:`${a} must be ${s}; the invalid value has no effect.`})};if(e==="mindmap"){let a=t&&typeof t=="object"&&!Array.isArray(t)?t:void 0;a&&"layout"in a&&!["tidy-tree","cose-bilkent","radial"].includes(String(a.layout))&&o("layout",'"cose-bilkent", "radial", or "tidy-tree" for mindmap diagrams')}if(!r)return i;for(let[a,s]of Object.entries(vo[e]??{}))a in r&&!s.valid(r[a])&&o(`${n.section}.${a}`,s.expected);if(e==="xychart")for(let a of["xAxis","yAxis"]){let s=r[a];if(!s||typeof s!="object"||Array.isArray(s))continue;let d=s;for(let l of Object.keys(d).sort()){let c=wo[l];c?c.valid(d[l])||o(`xyChart.${a}.${l}`,c.expected):o(`xyChart.${a}.${l}`,"a documented axis-config field")}}return i}function Co(e,t,n){if(!n)return[];let r=be(t,n.section);if(!r)return[];let i=new Set(n.noopKeys??[]);return Object.keys(r).filter(o=>i.has(o)).sort().map(o=>({code:"INEFFECTIVE_CONFIG",field:`${n.section}.${o}`,message:`${e} config field "${o}" is accepted for Mermaid compatibility but has no effect on this renderer.`}))}function Hr(e){let t=new Set;return e.sort((n,r)=>Ue(n.field,r.field)||Ue(n.message,r.message)).filter(n=>{let r=`${n.code}\0${n.field}\0${n.message}`;return t.has(r)?!1:(t.add(r),!0)})}function Ao(e,t,n){if(!n)return[];let r=t.flatMap(i=>{let o=xo(e,i,n),a=be(i,n.section);return e==="state"?a?Hn([a],!0):o:[...o,...Mo(e,i,n),...Co(e,i,n)]});return Hr(r)}function Ur(e,t,n){let r=n??pn(e)?.config;if(!r)return[];if(e.includes(":")){let i=t&&typeof t=="object"&&!Array.isArray(t)?t:void 0,o=be(t,r.section);if(!o)return i&&r.section in i?[{code:"INEFFECTIVE_CONFIG",field:r.section,message:`${e} config section "${r.section}" must be an object; the invalid value has no effect.`}]:[];let a=new Set(r.keys),s=new Set(r.noopKeys??[]);return Hr(Object.keys(o).flatMap(d=>a.has(d)?s.has(d)?[{code:"INEFFECTIVE_CONFIG",field:`${r.section}.${d}`,message:`${e} config field "${d}" is accepted for compatibility but has no effect on this renderer.`}]:[]:[{code:"INEFFECTIVE_CONFIG",field:`${r.section}.${d}`,message:`${e} config field "${d}" is unknown and has no effect; check the spelling or remove it.`}]))}return Ao(e,[t],r)}var ht=2,Me=`render-contract@${ht}`,$o={svg:{availability:"public",security:"enforced",color:"srgb",terminal:"not-applicable",transports:{library:{availability:"direct",entrypoint:"renderMermaidSVG",evidence:["src/index.ts"]},cli:{availability:"direct",entrypoint:"am render",selector:"--format svg",evidence:["src/cli/index.ts"],format:"svg",order:0,help:"SVG markup",default:!0},codeMode:{availability:"direct",entrypoint:"mermaid.renderMermaidSVGWithReceipt",evidence:["src/mcp/facade.ts","src/mcp/sdk-decl.ts"],method:"renderMermaidSVGWithReceipt",optionsType:"SvgRenderOptions",returnType:"RenderedSvg"},localMcp:{availability:"indirect",entrypoint:"execute",selector:"mermaid.renderMermaidSVGWithReceipt",evidence:["src/mcp/server.ts","src/mcp/facade.ts"]},hostedMcp:{availability:"direct",entrypoint:"render_svg",evidence:["src/mcp/hosted-server.ts"]},editor:{availability:"direct",entrypoint:"diagram preview / Save SVG",selector:"renderMermaidSVGWithReceipt",evidence:["editor/js/rendering.js","editor/js/export.js"]},website:{availability:"direct",entrypoint:"website build-time renderMermaidSVG",selector:"embedded examples and diagram assets",evidence:["website/build.ts"]}},evidence:["output-security@2",Me]},png:{availability:"public",security:"enforced",color:"srgb",terminal:"not-applicable",transports:{library:{availability:"direct",entrypoint:"renderMermaidPNG / createMermaidBrowserPNGRenderer",selector:"native Node/Bun or injected browser rasterizer",evidence:["src/agent/png.ts","src/browser-png.ts","src/index.ts"]},cli:{availability:"direct",entrypoint:"am render",selector:"--format png",evidence:["src/cli/index.ts"],format:"png",order:3,help:"PNG bytes; requires --output <file.png>; no watch/multi-input"},codeMode:{availability:"unavailable",entrypoint:"none",reason:"PNG rasterization is a host tool, not a sandbox SDK method",evidence:["src/mcp/sdk-decl.ts","src/mcp/facade.ts"]},localMcp:{availability:"direct",entrypoint:"render_png",evidence:["src/mcp/server.ts"]},hostedMcp:{availability:"direct",entrypoint:"render_png",evidence:["src/mcp/hosted-server.ts"]},editor:{availability:"direct",entrypoint:"Save PNG / Copy PNG",selector:"renderMermaidPNGInBrowserWithReceipt",evidence:["editor/js/export.js","src/browser-png.ts"]},website:{availability:"unavailable",entrypoint:"none",reason:"The site build copies curated PNG assets but exposes no PNG render adapter",evidence:["website/build.ts"]}},evidence:["output-security@2","output-color-profile@1",`png-output-policy@${3}`,Me]},ascii:{availability:"public",security:"enforced",color:"terminal-projected",terminal:"projected",transports:{library:{availability:"direct",entrypoint:"renderMermaidASCII",selector:"useAscii: true",evidence:["src/ascii/index.ts"]},cli:{availability:"direct",entrypoint:"am render",selector:"--format ascii",evidence:["src/cli/index.ts"],format:"ascii",order:1,help:"7-bit ASCII art"},codeMode:{availability:"direct",entrypoint:"mermaid.renderMermaidASCIIWithReceipt",selector:"useAscii: true",evidence:["src/mcp/facade.ts","src/mcp/sdk-decl.ts"],method:"renderMermaidASCIIWithReceipt",optionsType:"AsciiRenderOptions",returnType:"RenderedAscii"},localMcp:{availability:"indirect",entrypoint:"execute",selector:"mermaid.renderMermaidASCIIWithReceipt({ useAscii: true })",evidence:["src/mcp/server.ts","src/mcp/facade.ts"]},hostedMcp:{availability:"direct",entrypoint:"render_ascii",selector:"useAscii: true",evidence:["src/mcp/hosted-server.ts"]},editor:{availability:"direct",entrypoint:"ASCII canvas tab",selector:"renderMermaidASCII({ useAscii: true })",evidence:["editor/js/rendering.js","editor/html/right-panel.html"]},website:{availability:"unavailable",entrypoint:"none",reason:"The site build emits one Unicode diagram asset but no 7-bit ASCII output",evidence:["website/build.ts"]}},evidence:["terminal-style@1",`terminal-output-policy@${1}`,"terminal-control-sanitization",Me]},unicode:{availability:"public",security:"enforced",color:"terminal-projected",terminal:"projected",transports:{library:{availability:"direct",entrypoint:"renderMermaidASCII",selector:"useAscii: false (default)",evidence:["src/ascii/index.ts"]},cli:{availability:"direct",entrypoint:"am render",selector:"--format unicode",evidence:["src/cli/index.ts"],format:"unicode",order:2,help:"Unicode box-drawing text"},codeMode:{availability:"direct",entrypoint:"mermaid.renderMermaidASCIIWithReceipt",selector:"useAscii: false (default)",evidence:["src/mcp/facade.ts","src/mcp/sdk-decl.ts"],method:"renderMermaidASCIIWithReceipt",optionsType:"AsciiRenderOptions",returnType:"RenderedAscii"},localMcp:{availability:"indirect",entrypoint:"execute",selector:"mermaid.renderMermaidASCIIWithReceipt({ useAscii: false })",evidence:["src/mcp/server.ts","src/mcp/facade.ts"]},hostedMcp:{availability:"direct",entrypoint:"render_ascii",selector:"useAscii: false (default)",evidence:["src/mcp/hosted-server.ts"]},editor:{availability:"direct",entrypoint:"Unicode canvas tab",selector:"renderMermaidASCII({ useAscii: false })",evidence:["editor/js/rendering.js","editor/html/right-panel.html"]},website:{availability:"direct",entrypoint:"website build-time renderMermaidASCII",selector:"diagrams/workflow.txt; useAscii: false",evidence:["website/build.ts"]}},evidence:["terminal-style@1",`terminal-output-policy@${1}`,"terminal-control-sanitization",Me]},html:{availability:"public",security:"enforced",color:"terminal-projected",terminal:"projected",transports:{library:{availability:"projected",entrypoint:"renderMermaidASCII",selector:"colorMode: 'html'",evidence:["src/ascii/index.ts"]},cli:{availability:"unavailable",entrypoint:"none",reason:"HTML text is not a standalone CLI format",evidence:["src/cli/index.ts"]},codeMode:{availability:"projected",entrypoint:"mermaid.renderMermaidASCIIWithReceipt",selector:"colorMode: 'html' (terminal projection; not a standalone CLI format)",evidence:["src/mcp/facade.ts","src/mcp/sdk-decl.ts"],method:"renderMermaidASCIIWithReceipt",optionsType:"AsciiRenderOptions",returnType:"RenderedAscii"},localMcp:{availability:"indirect",entrypoint:"execute",selector:"mermaid.renderMermaidASCIIWithReceipt({ colorMode: 'html' })",evidence:["src/mcp/server.ts","src/mcp/facade.ts"]},hostedMcp:{availability:"indirect",entrypoint:"execute",selector:"mermaid.renderMermaidASCIIWithReceipt({ colorMode: 'html' })",evidence:["src/mcp/hosted-server.ts","src/mcp/facade.ts"]},editor:{availability:"unavailable",entrypoint:"none",reason:"The editor exposes diagram, Unicode and ASCII canvas tabs only",evidence:["editor/js/buttons.js","editor/html/right-panel.html"]},website:{availability:"unavailable",entrypoint:"none",reason:"The site does not emit terminal-HTML diagram artifacts",evidence:["website/build.ts"]}},evidence:["terminal-style@1",`terminal-output-policy@${1}`,"terminal-control-sanitization","html-text-escaping",Me]},layout:{availability:"public",security:"not-applicable",color:"not-applicable",terminal:"not-applicable",transports:{library:{availability:"direct",entrypoint:"layoutMermaid",evidence:["src/agent/core.ts"]},cli:{availability:"direct",entrypoint:"am render",selector:"--format layout",evidence:["src/cli/index.ts"],format:"layout",order:4,help:"Layout JSON (nodes, edges, groups, bounds)"},codeMode:{availability:"direct",entrypoint:"mermaid.layoutMermaidWithReceipt",evidence:["src/mcp/facade.ts","src/mcp/sdk-decl.ts"],method:"layoutMermaidWithReceipt",optionsType:"LayoutRenderOptions",returnType:"RenderedLayoutArtifact"},localMcp:{availability:"indirect",entrypoint:"execute",selector:"mermaid.layoutMermaidWithReceipt",evidence:["src/mcp/server.ts","src/mcp/facade.ts"]},hostedMcp:{availability:"indirect",entrypoint:"execute",selector:"mermaid.layoutMermaidWithReceipt",evidence:["src/mcp/hosted-server.ts","src/mcp/facade.ts"]},editor:{availability:"indirect",entrypoint:"verification panel",selector:"verifyMermaid(source).layout (consumed, not exported)",evidence:["editor/js/rendering.js"]},website:{availability:"unavailable",entrypoint:"none",reason:"Website verification consumes layout internally but publishes no layout artifact",evidence:["website/build.ts"]}},evidence:["positioned-artifact@1",Me]}};function Se(e){return Object.freeze({...e,evidence:Object.freeze([...e.evidence])})}var rc=Object.freeze(["library","cli","codeMode","localMcp","hostedMcp","editor","website"]),To=Object.freeze(vt.map(e=>{let t=$o[e];return Object.freeze({id:e,...t,transports:Object.freeze({library:Se(t.transports.library),cli:Se(t.transports.cli),codeMode:Se(t.transports.codeMode),localMcp:Se(t.transports.localMcp),hostedMcp:Se(t.transports.hostedMcp),editor:Se(t.transports.editor),website:Se(t.transports.website)}),evidence:Object.freeze([...t.evidence])})})),ni=Object.freeze(To.filter(e=>e.transports.cli.availability==="direct").sort((e,t)=>e.transports.cli.order-t.transports.cli.order)),ic=Object.freeze(ni.map(e=>e.transports.cli.format)),ri=ni.filter(e=>e.transports.cli.default);if(ri.length!==1)throw new Error("Render output contract must declare exactly one default CLI format");var oc=ri[0].transports.cli.format;var Do=["onConfigDiagnostic"],yt=(e,t)=>({type:"string",description:e,...t===void 0?{}:{default:t}}),Oe=(e,t,n={})=>({type:"number",description:e,...t===void 0?{}:{default:t},...n}),I=(e,t)=>Oe(e,t,{minimum:0}),te=(e,t)=>Oe(e,t,{exclusiveMinimum:0}),Zt=e=>Oe(e,void 0,{minimum:1,maximum:1e3}),ee=(e,t)=>({type:"boolean",description:e,...t===void 0?{}:{default:t}}),P=(e,t)=>({...yt(e,t),"x-agentic-mermaid-runtime-validator":"safeCssPaint"}),ii=(e,t)=>({...yt(e,t),"x-agentic-mermaid-runtime-validator":"safeCssFontFamily"}),Ce=(e,t,n=[])=>({type:"object",description:t,additionalProperties:!1,properties:e,...n.length===0?{}:{required:n}}),Qt={type:"string",enum:["uppercase","lowercase","capitalize"]},Io={groupHeaderHeight:te("Architecture group-header height."),groupFontSize:te("Architecture group-label font size."),groupFontWeight:Zt("Architecture group-label font weight."),groupLetterSpacing:Oe("Architecture group-label letter spacing."),groupFont:ii("Architecture group-label font family."),groupTextTransform:{...Qt,description:"Architecture group-label text transform."},groupPaddingX:I("Horizontal padding inside architecture groups."),groupPaddingY:I("Vertical padding inside architecture groups."),groupLabelPaddingX:I("Horizontal padding around architecture group labels."),groupCornerRadius:I("Architecture group corner radius."),groupLineWidth:I("Architecture group border width."),groupText:P("Architecture group-label color."),serviceFontSize:te("Architecture service-label font size."),serviceFontWeight:Zt("Architecture service-label font weight."),serviceLetterSpacing:Oe("Architecture service-label letter spacing."),serviceTextTransform:{...Qt,description:"Architecture service-label text transform."},servicePaddingX:I("Horizontal padding inside architecture services."),servicePaddingY:I("Vertical padding inside architecture services."),serviceCornerRadius:I("Architecture service corner radius."),serviceLineWidth:I("Architecture service border width."),serviceText:P("Architecture service-label color."),edgeFontSize:te("Architecture connector-label font size."),edgeFontWeight:Zt("Architecture connector-label font weight."),edgeLetterSpacing:Oe("Architecture connector-label letter spacing."),edgeTextTransform:{...Qt,description:"Architecture connector-label text transform."},edgeLineWidth:I("Architecture connector width."),edgeBendRadius:I("Architecture connector bend radius."),edgeStroke:P("Architecture connector color."),edgeText:P("Architecture connector-label color."),iconSize:te("Architecture group icon size."),serviceIconSize:te("Architecture service icon size."),junctionOuterRadius:te("Architecture junction outer radius."),junctionInnerRadius:I("Architecture junction inner radius."),groupSurface:P("Architecture group surface color."),groupHeaderSurface:P("Architecture group-header surface color."),groupBorder:P("Architecture group border color."),serviceSurface:P("Architecture service surface color."),serviceBorder:P("Architecture service border color.")},Po={...Ce(Io,"Sparse architecture visual overrides merged over resolved defaults."),"x-agentic-mermaid-runtime-validator":"architectureVisual"},No=(()=>{let e=Un(),t=e.$defs,n=s=>{if(Array.isArray(s))return s.map(n);if(s===null||typeof s!="object")return s;let d=s,l=d.$ref;if(typeof l=="string"&&l.startsWith("#/$defs/")){let c=t?.[l.slice(8)];if(!c)throw new Error(`StyleSpec schema has unresolved local reference ${l}`);return n(c)}return Object.fromEntries(Object.entries(d).filter(([c])=>c!=="$defs").map(([c,p])=>[c,n(p)]))},{$schema:r,$id:i,title:o,...a}=e;return n(a)})(),Jr={anyOf:[{type:"string",description:"Registered Style or Palette name."},No],"x-agentic-mermaid-validation-expectation":"a registered Style name or StyleSpec"},jo={anyOf:[Jr,{type:"array",items:Jr,description:"Style stack merged from left to right."}],description:"A registered name, inline StyleSpec, or left-to-right stack of either.","x-agentic-mermaid-runtime-validator":"styleInput"},en={anyOf:[{type:"null"},{type:"string"},{type:"number"},{type:"boolean"},{type:"array",items:{$ref:"#/$defs/jsonValue"}},{type:"object",additionalProperties:{$ref:"#/$defs/jsonValue"}}],description:"A finite, acyclic JSON value without prototype keys.","x-agentic-mermaid-validation-expectation":"a finite, acyclic JSON value without prototype keys"};function oi(e){if(typeof e!="object"||e===null||Object.isFrozen(e))return e;for(let t of Object.values(e))oi(t);return Object.freeze(e)}var Xr=["flowchart","state","class","er","architecture"],Lo=["flowchart","state","sequence","timeline","class","er","journey","xychart","pie","quadrant","gantt","mindmap","gitgraph"],Ve=oi({bg:{typeScript:"string",description:"Background color or CSS variable.",defaultLabel:"`#FFFFFF`",validationExpectation:"be a safe non-fetching CSS paint",schema:P("Background color or CSS variable.","#FFFFFF"),terminal:"consumed"},fg:{typeScript:"string",description:"Primary foreground and text color.",defaultLabel:"`#27272A`",validationExpectation:"be a safe non-fetching CSS paint",schema:P("Primary foreground and text color.","#27272A"),terminal:"consumed"},line:{typeScript:"string",description:"Connector and secondary-line color.",defaultLabel:"derived",validationExpectation:"be a safe non-fetching CSS paint",schema:P("Connector and secondary-line color."),terminal:"consumed"},accent:{typeScript:"string",description:"Arrowhead, highlight, and data accent color.",defaultLabel:"derived",validationExpectation:"be a safe non-fetching CSS paint",schema:P("Arrowhead, highlight, and data accent color."),terminal:"consumed"},muted:{typeScript:"string",description:"Secondary text and label color.",defaultLabel:"derived",validationExpectation:"be a safe non-fetching CSS paint",schema:P("Secondary text and label color."),terminal:"projected",terminalNote:"terminal themes have no dedicated muted-text role"},surface:{typeScript:"string",description:"Node and group surface color.",defaultLabel:"derived",validationExpectation:"be a safe non-fetching CSS paint",schema:P("Node and group surface color."),terminal:"projected",terminalNote:"terminal cells do not paint graphical surfaces"},border:{typeScript:"string",description:"Node and group border color.",defaultLabel:"derived",validationExpectation:"be a safe non-fetching CSS paint",schema:P("Node and group border color."),terminal:"consumed"},font:{typeScript:"string",description:"CSS font family or stack.",defaultLabel:"`Inter`",validationExpectation:"be a safe non-fetching CSS font family or stack",schema:ii("CSS font family or stack.","Inter"),terminal:"projected",terminalNote:"the host terminal owns the font face"},style:{typeScript:"StyleInput | StyleInput[]",description:"Registered Style/Palette name, inline StyleSpec, or left-to-right stack.",defaultLabel:"`crisp`",validationExpectation:"be a registered Style name or StyleSpec, or an array of them",schema:jo,terminal:"consumed"},padding:{typeScript:"number",description:"Canvas padding in SVG user units.",defaultLabel:"`40`",validationExpectation:"be a non-negative finite number",schema:I("Canvas padding in SVG user units.",40),terminal:"not-applicable",terminalNote:"terminal output uses paddingX, paddingY, and boxBorderPadding",applicableBuiltinFamilies:["flowchart","state","architecture"]},nodeSpacing:{typeScript:"number",description:"Horizontal spacing between sibling nodes.",defaultLabel:"`24`",validationExpectation:"be a non-negative finite number",schema:I("Horizontal spacing between sibling nodes.",24),terminal:"not-applicable",terminalNote:"terminal layout has a cell-grid spacing contract",applicableBuiltinFamilies:Xr},layerSpacing:{typeScript:"number",description:"Vertical spacing between graph layers.",defaultLabel:"`40`",validationExpectation:"be a non-negative finite number",schema:I("Vertical spacing between graph layers.",40),terminal:"not-applicable",terminalNote:"terminal layout has a cell-grid spacing contract",applicableBuiltinFamilies:Xr},wrappingWidth:{typeScript:"number",description:"Flowchart measured-label wrapping budget in pixels.",defaultLabel:"unset",validationExpectation:"be a positive finite number",schema:te("Flowchart measured-label wrapping budget in pixels."),terminal:"not-applicable",terminalNote:"terminal output uses maxWidth or targetWidth",applicableBuiltinFamilies:["flowchart"]},componentSpacing:{typeScript:"number",description:"Spacing between disconnected graph components for compatible extension families; no built-in family currently consumes it.",defaultLabel:"extension-defined",validationExpectation:"be a non-negative finite number",schema:I("Spacing between disconnected graph components for compatible extension families; no built-in family currently consumes it."),terminal:"not-applicable",terminalNote:"terminal layout has a cell-grid spacing contract",applicableBuiltinFamilies:[]},transparent:{typeScript:"boolean",description:"Omit the painted SVG canvas background.",defaultLabel:"`false`",validationExpectation:"be a boolean",schema:ee("Omit the painted SVG canvas background.",!1),terminal:"projected",terminalNote:"terminal output has no painted canvas background"},interactive:{typeScript:"boolean",description:"Enable hover tooltips for supported chart data points.",defaultLabel:"`false`",validationExpectation:"be a boolean",schema:ee("Enable hover tooltips for supported chart data points.",!1),terminal:"projected",terminalNote:"terminal output is a static semantic projection",applicableBuiltinFamilies:["xychart","pie","quadrant"]},shadow:{typeScript:"boolean",description:"Paint explicit drop shadows on node shapes.",defaultLabel:"`false`",validationExpectation:"be a boolean",schema:ee("Paint explicit drop shadows on node shapes.",!1),terminal:"projected",terminalNote:"elevation projects to borders and labels",applicableBuiltinFamilies:Lo},class:{typeScript:"{ hierarchicalNamespaces?: boolean }",description:"Class-diagram rendering controls.",defaultLabel:"`hierarchicalNamespaces: true`",validationExpectation:"be a class options object",schema:Ce({hierarchicalNamespaces:ee("Nest namespace compounds.",!0)},"Class-diagram rendering controls."),terminal:"not-applicable",terminalNote:"this option configures graphical class layout",applicableBuiltinFamilies:["class"]},architecture:{typeScript:"{ visual?: ArchitectureVisualOverrides }",description:"Sparse architecture renderer visual metric and paint overrides.",defaultLabel:"built-in metrics",validationExpectation:"be an architecture options object",schema:Ce({visual:Po},"Architecture renderer visual metric and paint overrides."),terminal:"not-applicable",terminalNote:"this option configures graphical architecture rendering",applicableBuiltinFamilies:["architecture"]},timeline:{typeScript:"{ maxWidth?: number }",description:"Timeline layout controls.",defaultLabel:"`maxWidth`: unset",validationExpectation:"be a timeline options object",schema:Ce({maxWidth:te("Best-effort width budget for horizontal timelines.")},"Timeline layout controls."),terminal:"not-applicable",terminalNote:"terminal output uses maxWidth or targetWidth",applicableBuiltinFamilies:["timeline"]},journey:{typeScript:"{ experienceCurve?: boolean }",description:"User-journey graphical controls.",defaultLabel:"`experienceCurve: true`",validationExpectation:"be a journey options object",schema:Ce({experienceCurve:ee("Connect journey score markers with an experience curve.",!0)},"User-journey graphical controls."),terminal:"not-applicable",terminalNote:"experience curves are graphical-only",applicableBuiltinFamilies:["journey"]},gantt:{typeScript:"{ dependencyArrows?: boolean; criticalPath?: boolean }",description:"Gantt dependency and critical-path overlays.",defaultLabel:"both `false`",validationExpectation:"be a Gantt options object",schema:Ce({dependencyArrows:ee("Draw scheduled dependency connectors.",!1),criticalPath:ee("Emphasize critical-path tasks and connectors.",!1)},"Gantt dependency and critical-path overlays."),terminal:"not-applicable",terminalNote:"graphical Gantt connector emphasis is not represented in cells",applicableBuiltinFamilies:["gantt"]},mermaidConfig:{typeScript:"MermaidRuntimeConfig",description:"Mermaid-style recursive runtime configuration.",defaultLabel:"source config",validationExpectation:"be a plain JSON object",schema:{type:"object",description:"Mermaid-style recursive runtime configuration.",additionalProperties:{$ref:"#/$defs/jsonValue"}},terminal:"consumed"},embedFontImport:{typeScript:"boolean",description:"Embed the Google Fonts import in SVG styles; PNG forces this off for offline rasterization.",defaultLabel:"`false`",validationExpectation:"be a boolean",schema:ee("Embed the Google Fonts import in SVG styles; PNG forces this off for offline rasterization.",!1),terminal:"not-applicable",terminalNote:"terminal output embeds no web-font import"},compact:{typeScript:"boolean",description:"Compact SVG serialization while preserving agent hooks.",defaultLabel:"`false`",validationExpectation:"be a boolean",schema:ee("Compact SVG serialization while preserving agent hooks.",!1),terminal:"not-applicable",terminalNote:"compact controls SVG serialization"},idPrefix:{typeScript:"string",description:"Non-empty namespace for generated SVG definition IDs and local references.",defaultLabel:"unset",validationExpectation:"be non-empty and contain only ASCII letters, digits, underscore, hyphen, dot, and colon",schema:{...yt("Non-empty namespace for generated SVG definition IDs and local references."),pattern:"^[A-Za-z0-9_.:-]+$"},terminal:"not-applicable",terminalNote:"terminal output has no SVG definition ids"},security:{typeScript:"'default' | 'strict'",description:"Active SVG content is rejected in every mode; strict additionally rejects every external reference. Raw Mermaid themeCSS is rejected in both modes.",defaultLabel:"`default`",validationExpectation:"be default or strict",schema:{type:"string",enum:["default","strict"],description:"Active SVG content is rejected in every mode; strict additionally rejects every external reference. Raw Mermaid themeCSS is rejected in both modes.",default:"default"},terminal:"not-applicable",terminalNote:"terminal text has its own control-character and HTML-color safety projection"},ganttToday:{typeScript:"string",description:"Explicit deterministic date for the Gantt today marker.",defaultLabel:"unset",validationExpectation:"be a string",schema:yt("Explicit deterministic date for the Gantt today marker."),terminal:"consumed",applicableBuiltinFamilies:["gantt"]},seed:{typeScript:"number",description:"Deterministic re-roll seed for stochastic Styles.",defaultLabel:"`0`",validationExpectation:"be a finite number",schema:Oe("Deterministic re-roll seed for stochastic Styles.",0),terminal:"not-applicable",terminalNote:"terminal glyph geometry is deterministic and has no stochastic ink"}}),$e=Object.freeze(Object.keys(Ve)),_o=Object.freeze($e.filter(e=>"applicableBuiltinFamilies"in Ve[e]));function q(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}var zo=new Set(["__proto__","prototype","constructor"]);function Re(e){return q(e)?e:void 0}function Kr(e){let t=n=>Array.isArray(n)?n.map(t):q(n)?Object.fromEntries(Object.entries(n).map(([r,i])=>[r,t(i)])):n;return t(e)}function si(e){let t=String(e[0]??"");for(let n of e.slice(1))t+=typeof n=="number"?`[${n}]`:`.${n}`;return`render option "${t}"`}function ai(e){return Rt(un(e).map(t=>t.path.length>0?`${si(t.path)} ${t.message}`:`render options ${t.message}`),"render options")}function ci(e,t){let n=e.$ref;if(typeof n!="string"||!n.startsWith("#/"))return;let r=t;for(let i of n.slice(2).split("/")){if(!q(r))return;let o=i.replaceAll("~1","/").replaceAll("~0","~");r=r[o]}return Re(r)}function tn(e,t,n){let r=ci(t,n);if(r)return tn(e,r,n);let i=Array.isArray(t.anyOf)?t.anyOf.map(Re).filter(o=>o!==void 0):[];if(i.length>0)return i.some(o=>tn(e,o,n));switch(t.type){case"null":return e===null;case"string":return typeof e=="string";case"number":return typeof e=="number";case"integer":return typeof e=="number";case"boolean":return typeof e=="boolean";case"array":return Array.isArray(e);case"object":return q(e);default:return!0}}function xe(e,t,n,r,i){let o=ci(t,n);if(t.$ref!==void 0)return o?xe(e,o,n,r,i):[{path:r,message:"uses an unresolved schema reference",generic:!1}];let a=Array.isArray(t.anyOf)?t.anyOf.map(Re).filter(c=>c!==void 0):[];if(a.length>0){let c=a.filter(f=>tn(e,f,n)),u=(c.length>0?c:a).map(f=>xe(e,f,n,r,i));if(!u.some(f=>f.length===0)){let f=t["x-agentic-mermaid-validation-expectation"];return c.length===0&&typeof f=="string"?[{path:r,message:`must be ${f}`,generic:!0}]:u.sort((m,h)=>m.length-h.length)[0]??[{path:r,message:"must match an allowed shape",generic:!0}]}}if("const"in t&&e!==t.const)return[{path:r,message:`must equal ${String(t.const)}`,generic:!0}];if(Array.isArray(t.enum)&&!t.enum.includes(e))return[{path:r,message:`must be one of ${t.enum.map(String).join(" | ")}`,generic:!0}];let s=t.type;if(!(s===void 0||s==="null"&&e===null||s==="string"&&typeof e=="string"||s==="number"&&typeof e=="number"&&Number.isFinite(e)||s==="integer"&&typeof e=="number"&&Number.isFinite(e)&&Number.isInteger(e)||s==="boolean"&&typeof e=="boolean"||s==="array"&&Array.isArray(e)||s==="object"&&q(e))){let c=s==="number"?"a finite number":s==="integer"?"a finite integer":s==="object"?"a plain JSON object":s==="array"?"an array":s==="null"?"null":`a ${String(s)}`;return[{path:r,message:`must be ${c}`,generic:!0}]}if(typeof e=="number"){if(typeof t.minimum=="number"&&e<t.minimum)return[{path:r,message:`must be at least ${t.minimum}`,generic:!0}];if(typeof t.exclusiveMinimum=="number"&&e<=t.exclusiveMinimum)return[{path:r,message:`must be greater than ${t.exclusiveMinimum}`,generic:!0}];if(typeof t.maximum=="number"&&e>t.maximum)return[{path:r,message:`must be at most ${t.maximum}`,generic:!0}]}if(typeof e=="string"&&typeof t.pattern=="string"){let c=!1;try{c=new RegExp(t.pattern).test(e)}catch{return[{path:r,message:"uses an invalid schema pattern",generic:!1}]}if(!c)return[{path:r,message:`must match ${t.pattern}`,generic:!0}]}if(Array.isArray(e)&&s==="array"){if(i.has(e))return[{path:r,message:"must be acyclic",generic:!1}];let c=Re(t.items);if(c){i.add(e);try{let p=e.flatMap((u,f)=>xe(u,c,n,[...r,f],i));if(p.length>0)return p}finally{i.delete(e)}}}if(q(e)&&s==="object"){if(i.has(e))return[{path:r,message:"must be acyclic",generic:!1}];i.add(e);try{let c=Re(t.properties)??{},p=Array.isArray(t.required)?t.required.filter(f=>typeof f=="string"):[],u=[];for(let f of p)Object.prototype.hasOwnProperty.call(e,f)||u.push({path:[...r,f],message:"is required",generic:!1});for(let[f,m]of Object.entries(e)){if(zo.has(f)){u.push({path:[...r,f],message:"uses a forbidden prototype key",generic:!1});continue}let h=Re(c[f]);if(h){u.push(...xe(m,h,n,[...r,f],i));continue}if(t.additionalProperties===!1){u.push({path:[...r,f],message:"is not allowed",generic:!1});continue}let y=Re(t.additionalProperties);y&&u.push(...xe(m,y,n,[...r,f],i))}if(u.length>0)return u}finally{i.delete(e)}}let l=t["x-agentic-mermaid-runtime-validator"];if(l==="safeCssColor"&&Ie(e)===void 0)return[{path:r,message:"must be a safe, non-fetching CSS color",generic:!1}];if(l==="safeCssPaint"&&kt(e)===void 0)return[{path:r,message:"must be a safe, non-fetching CSS paint",generic:!1}];if(l==="safeCssFontFamily"&&xt(e)===void 0)return[{path:r,message:"must be a safe, non-fetching CSS font family or stack",generic:!1}];if(l==="styleInput")try{Kn(e)}catch(c){return[{path:r,message:`is invalid: ${c instanceof Error?c.message:String(c)}`,generic:!1}]}if(l==="architectureVisual"&&q(e)){let c=e.junctionOuterRadius,p=e.junctionInnerRadius;if(typeof c=="number"&&typeof p=="number"&&p>c)return[{path:[...r,"junctionInnerRadius"],message:"must not exceed junctionOuterRadius",generic:!1}]}return[]}function li(e){if(!q(e))return["render options must be a plain JSON object"];let t=ai(e);if(t.length>0)return t;let n=[],r=new Set($e),i=Bo();for(let[o,a]of Object.entries(e)){if(!r.has(o)){n.push(`unknown render option "${o}"`);continue}if(a===null){n.push(`render option "${o}" must be omitted instead of null`);continue}let s=Ve[o],d=xe(a,s.schema,i,[o],new Set);d.length>0&&d.every(l=>l.generic&&l.path.length===1)?n.push(`render option "${o}" must ${s.validationExpectation}`):n.push(...d.map(l=>`${si(l.path)} ${l.message}`))}return Rt(n,"render options")}function Bo(){let e={};for(let t of $e){let n=Ve[t],r="terminalNote"in n?n.terminalNote:void 0,i="applicableBuiltinFamilies"in n?n.applicableBuiltinFamilies:void 0;e[t]={...Kr(n.schema),"x-agentic-mermaid-terminal":n.terminal,...r===void 0?{}:{"x-agentic-mermaid-terminal-note":r},...i===void 0?{}:{"x-agentic-mermaid-applicable-builtin-families":[...i]}}}return{$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://agentic-mermaid.dev/schemas/render-options.schema.json",type:"object",additionalProperties:!1,properties:e,$defs:{jsonValue:Kr(en)}}}var nn=class extends Error{constructor(n,r){super(`Parsed Mermaid family "${n}" serialized as family "${r}"`);this.expectedFamilyId=n;this.detectedFamilyId=r}expectedFamilyId;detectedFamilyId;name="ParsedDiagramFamilyMismatchError";code="PARSED_DIAGRAM_FAMILY_MISMATCH"},ke=class extends Error{name="RenderCapabilityError";code="UNSATISFIED_RENDER_CAPABILITIES";output;family;decision;constructor(t,n,r,i){super(t),this.output=n,this.family=Object.freeze({id:r.identity.id,version:r.identity.version}),this.decision=i}toJSON(){return{name:this.name,code:this.code,message:this.message,output:this.output,family:this.family,decision:this.decision}}},on=new WeakMap;function he(e){let t=on.get(e);if(!t)throw new Error("Resolved render request has no internal execution plan");return t}function Go(e,t){if(e.id.startsWith("family:")){let r=new Set(e.applicableRenderOptions??[]);return Object.freeze(t.flatMap(i=>!_o.includes(i)||r.has(i)?[]:[Object.freeze({code:"RENDER_OPTION_NOT_APPLICABLE",feature:`render-option:${i}`,message:`Render option "${i}" does not apply to extension family "${e.id}". Its FamilyDescriptor does not list the field in applicableRenderOptions.`})]))}let n=e.id;return Object.freeze(t.flatMap(r=>{let i=Ve[r];if(!("applicableBuiltinFamilies"in i))return[];let o=i.applicableBuiltinFamilies;if(o.includes(n))return[];let a=o.length===0?"No built-in family currently consumes this option.":`Applicable built-in families: ${o.join(", ")}.`;return[Object.freeze({code:"RENDER_OPTION_NOT_APPLICABLE",feature:`render-option:${r}`,message:`Render option "${r}" does not apply to built-in Mermaid family "${n}". ${a}`})]}))}function Vo(e,t){let n=new Set;return Object.freeze([...e.resolutionDiagnostics??[],...t].flatMap(r=>{let i=Ae(r);return n.has(i)?[]:(n.add(i),[Object.freeze({...r})])}))}function di(e,t=[]){let n=on.get(e)?.executionDecision;return Object.freeze({version:e.version,output:e.output,sharedRequestDigest:e.sharedRequestDigest,requestDigest:e.requestDigest,appearanceDigest:e.appearance.digest,capabilityDecision:e.capabilityDecision,diagnostics:Vo(e,t),...n?{executionDecision:n}:{}})}function bt(e){return Object.freeze({renderOptions:e.renderOptions,...e.appearance.face?{styleFace:e.appearance.face}:{},...e.familyConfig?{familyConfig:e.familyConfig}:{},...e.appearance.family?{familyAppearance:e.appearance.family}:{}})}function Wo(e,t,n){let r={...e},i=a=>Ot[a].some(s=>n?.[s]!==void 0),o=["bg","fg","line","accent","muted","surface","border"];for(let a of o)r[a]===void 0&&!i(a)&&t.colors?.[a]!==void 0&&(r[a]=t.colors[a]);return r.font===void 0&&t.font!==void 0&&(r.font=t.font),r}function rn(e){let t={};for(let n of $e){let r=e[n];r!==void 0&&(t[n]=r)}return t}var qo=new Set(["padding","nodeSpacing","layerSpacing","wrappingWidth","class"]);function Ho(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0&&!Do.includes(t)))}function Uo(e,t=e){return vn(e.lines[0]??e.firstLine,e.originalText,"strict",t.wrapperSource?.length??0,t.lines[0]??t.firstLine)}function Jo(e,t,n){if(n.onConfigDiagnostic!==void 0)throw new TypeError(`Family "${e.id}" request normalizer may not return executable option "onConfigDiagnostic"`);let r=li(Ho(n));if(r.length>0)throw new TypeError(`Family "${e.id}" returned invalid normalized RenderOptions: ${r.join("; ")}`);let i=rn(t),o=rn(n);for(let a of $e)if(!qo.has(a)&&Ae(i[a])!==Ae(o[a]))throw new TypeError(`Family "${e.id}" request normalizer may not rewrite non-geometry option "${a}"`)}function Xo(e,t,n){let r=new Set(["bg","fg","line","accent","muted","surface","border","shadow","font","embedFontImport"]),i=Object.keys(t).find(a=>!r.has(a));if(i)throw new TypeError(`Family "${e.id}" returned unknown appearance color field "${i}"`);let o={...n};for(let a of["bg","fg","line","accent","muted","surface","border"]){let s=t[a];if(s===void 0)continue;let d=kt(s);if(d===void 0)throw new TypeError(`Family "${e.id}" returned an unsafe ${a} paint`);o[a]=d}if(t.font!==void 0){let a=xt(t.font);if(a===void 0)throw new TypeError(`Family "${e.id}" returned an unsafe font family`);if(a!==n.font)throw new TypeError(`Family "${e.id}" request normalizer may not rewrite appearance field "font"`)}if(t.shadow!==void 0){if(typeof t.shadow!="boolean")throw new TypeError(`Family "${e.id}" returned a non-boolean shadow value`);if(t.shadow!==n.shadow)throw new TypeError(`Family "${e.id}" request normalizer may not rewrite appearance field "shadow"`)}if(t.embedFontImport!==void 0){if(typeof t.embedFontImport!="boolean")throw new TypeError(`Family "${e.id}" returned a non-boolean embedFontImport value`);if(t.embedFontImport!==n.embedFontImport)throw new TypeError(`Family "${e.id}" request normalizer may not rewrite appearance field "embedFontImport"`)}return o}var Yr=64,ft=1e5,mt=2e6;function gt(e,t="$",n=0,r=new Set,i={nodes:0,chars:0}){if(typeof e=="string"){if(i.chars+=e.length,i.chars>mt)throw new TypeError(`data exceeds the ${mt}-character aggregate limit at ${t}`);return e}if(e===null||typeof e!="object")return e;if(n>Yr)throw new TypeError(`data exceeds maximum depth ${Yr} at ${t}`);if(++i.nodes>ft)throw new TypeError(`data exceeds the ${ft}-node aggregate limit at ${t}`);if(r.has(e))throw new TypeError(`data must be acyclic at ${t}`);if(Array.isArray(e)){if(e.length>ft)throw new TypeError(`data array exceeds the ${ft}-entry limit at ${t}`);r.add(e);try{let o=[];for(let a=0;a<e.length;a++){if(!Object.prototype.hasOwnProperty.call(e,a))throw new TypeError(`data must not contain a sparse array at ${t}[${a}]`);o.push(gt(e[a],`${t}[${a}]`,n+1,r,i))}return o}finally{r.delete(e)}}if(!q(e))return e;r.add(e);try{let o=Object.create(null);for(let[a,s]of Object.entries(e)){if(i.chars+=a.length,i.chars>mt)throw new TypeError(`data exceeds the ${mt}-character aggregate limit at ${t}.${a}`);s!==void 0&&(o[a]=gt(s,`${t}.${a}`,n+1,r,i))}return o}finally{r.delete(e)}}function Zr(e,t,n){if(t===void 0)return;if(!q(t))throw new TypeError(`Family "${e.id}" returned ${n} data that is not a plain object`);let r;try{r=gt(t)}catch(a){throw new TypeError(`Family "${e.id}" returned invalid ${n} data: ${a instanceof Error?a.message:String(a)}`)}let i={...en,$defs:{jsonValue:en}},o=xe(r,i,i,[`family${n==="config"?"Config":"Appearance"}`],new Set);if(o.length>0){let a=o.map(s=>`${s.path.join(".")} ${s.message}`).join("; ");throw new TypeError(`Family "${e.id}" returned invalid ${n} data: ${a}`)}return E(r)}function Ko(e,t,n,r,i,o){if(!e.normalizeRequest)return{renderOptions:n,colors:r};let a=Object.freeze({source:E(t),renderOptions:E(n),colors:E(r),...i?{style:E(i)}:{},...o?{styleFace:E(o)}:{}}),s=e.normalizeRequest(a);if(s===void 0)return{renderOptions:n,colors:r};let d;try{d=sn(s,`Family "${e.id}" request normalizer result`)}catch(y){throw new TypeError(`Family "${e.id}" request normalizer returned invalid data: ${y instanceof Error?y.message:String(y)}`)}if(!q(d))throw new TypeError(`Family "${e.id}" request normalizer must return a plain object`);let l=Object.keys(d).find(y=>!["renderOptions","familyConfig","appearance"].includes(y));if(l)throw new TypeError(`Family "${e.id}" request normalizer returned unknown field "${l}"`);let c=d,p=c.appearance;if(p!==void 0){let y=p;if(!q(y))throw new TypeError(`Family "${e.id}" request normalizer returned a non-object appearance`);let g=Object.keys(y).find(S=>!["colors","family"].includes(S));if(g)throw new TypeError(`Family "${e.id}" request normalizer returned unknown appearance field "${g}"`)}let u=c.renderOptions??n;Jo(e,n,u);let f=p?.colors?Xo(e,p.colors,r):r,m=Zr(e,c.familyConfig,"config"),h=Zr(e,p?.family,"appearance");return{renderOptions:u,colors:f,...m?{familyConfig:m}:{},...h?{familyAppearance:h}:{}}}function Ae(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(Ae).join(",")}]`;let t=e;return`{${Object.keys(t).sort().filter(n=>t[n]!==void 0).map(n=>`${JSON.stringify(n)}:${Ae(t[n])}`).join(",")}}`}function Fe(e){let t;try{t=sn(e,"render contract digest input")}catch(i){let o=(i instanceof Error?i.message:String(i)).replace("data exceeds maximum depth","data exceeds maximum nesting depth");throw new TypeError(o)}fn(t,"render contract digest input",{allowUndefinedObjectProperties:!0});let n=Ae(t),r=0xcbf29ce484222325n;for(let i=0;i<n.length;i++)r^=BigInt(n.charCodeAt(i)),r=BigInt.asUintN(64,r*0x100000001b3n);return`fnv1a64:${r.toString(16).padStart(16,"0")}`}function E(e,t="$",n=new Set){if(e===null||typeof e!="object")return e;if(n.has(e))throw new TypeError(`render request contains a cycle at ${t}`);let r=Object.getPrototypeOf(e);if(!Array.isArray(e)&&r!==Object.prototype&&r!==null)throw new TypeError(`render request contains a non-JSON object at ${t}`);n.add(e);let i=Array.isArray(e)?e.map((o,a)=>E(o,`${t}[${a}]`,n)):Object.fromEntries(Object.entries(e).map(([o,a])=>[o,E(a,`${t}.${o}`,n)]));return n.delete(e),Object.freeze(i)}function sn(e,t){try{return E(gt(e))}catch(n){throw new TypeError(`${t} could not be snapshotted: ${n instanceof Error?n.message:String(n)}`)}}function Yo(e){if(typeof e!="object"&&typeof e!="function"||e===null)throw new TypeError("Invalid RenderOptions: render options must be an object");let t=[],n;for(let[o,a]of Object.entries(e))o==="onConfigDiagnostic"?n=a:a!==void 0&&t.push([o,a]);if(n!==void 0&&typeof n!="function")throw new TypeError("Invalid RenderOptions: onConfigDiagnostic must be a function");let r=Object.fromEntries(t),i;try{i=sn(r,"RenderOptions")}catch(o){let a=(o instanceof Error?o.message:String(o)).replace("data exceeds maximum depth","render option tree exceeds maximum nesting depth");throw new TypeError(`Invalid RenderOptions: ${a}`)}return Object.freeze({serializable:i,...n===void 0?{}:{onConfigDiagnostic:n}})}function Zo(e){let t=e===void 0?[]:Array.isArray(e)?e:[e];return E(t.flatMap(n=>{if(typeof n!="string"||n==="crisp")return[];let r=Jn(n);return r?[{input:n,canonicalId:r.canonicalId}]:[]}))}function Qo(e){let t=new Set;for(let n of Object.values(Ot))for(let r of n){let i=e.config.themeVariables?.[r];typeof i=="string"&&i.length>0&&Ie(i)===void 0&&t.add(r)}return Object.freeze([...t].sort())}var an="1.0.0";function me(e,t,n=an){return t?[{id:e,version:n}]:[]}function W(e,t=`^${an}`){return{id:e,range:t,level:"required"}}function Qr(e){return`scene-primitive:${e.primitive}/${e.feature}/${e.operation}`}function es(e){let t=new Set(e.scenePrimitiveEvidence.filter(n=>n.applicability==="applicable").map(n=>n.primitive));return Fn.filter(n=>t.has(n.primitive))}function ei(e,t){return e.backend.capabilities.some(n=>n.primitive===t.primitive&&n.feature===t.feature&&n.operation===t.operation&&n.realization!=="unsupported")}function ts(e){return e.resolutions.filter(t=>t.level==="required"&&t.status!=="selected").map(t=>t.id).join(", ")}function ns(e,t,n,r,i,o){let a=ts(o),s=a?` (unsatisfied capabilities: ${a})`:"";return e==="layout"?new ke(`No public layout projection registered for Mermaid family "${t.id}"${s}`,e,t,o):e==="ascii"||e==="unicode"||e==="html"?new ke(`No ASCII renderer registered for Mermaid family ${t.id}${s}`,e,t,o):n.styled&&!t.lowerScene?new ke(`Family "${t.id}" does not support styled rendering (no SceneGraph lowering registered). Render without the style option, or register a lowerScene hook for the family.${s}`,e,t,o):r==="scene"&&t.layout&&t.lowerScene&&!i?new ke(n.styled?`Style "${n.style?.name??"(inline)"}" requires an unavailable SceneGraph backend${s}`:`Default SceneGraph backend is not registered${s}`,e,t,o):new ke(`No SVG renderer registered for Mermaid family ${t.id}${s}`,e,t,o)}function rs(e,t,n,r,i,o){let a,s,d;n==="svg"||n==="png"?(a=t.styled||e.lowerScene?"scene":"family-svg",a==="scene"&&(d=t.styled?t.inferredBackend:"default",s=Vn(d,r.backendPolicy))):n==="layout"?a="layout":a="terminal";let l=a==="scene"?es(e):[],c=s?l.flatMap(g=>me(Qr(g),ei(s,g))):[],p=[{id:e.identity.id,version:e.identity.version},...me("operation:layout",e.layout!==void 0),...me("operation:project-positioned",e.projectPositioned!==void 0),...me("operation:lower-scene",e.lowerScene!==void 0),...me("operation:render-svg",e.renderSvg!==void 0),...me("operation:render-terminal",e.renderAscii!==void 0),...me("core:scene",a==="scene"),...me("backend:scene-renderer",s!==void 0,s?.identity.version),...c],u=[W("core:family-descriptor"),W(e.identity.id,e.identity.version)],f;switch(a){case"scene":u.push(W("core:scene"),W("operation:layout"),W("operation:lower-scene"),W("backend:scene-renderer",s?.identity.version??an),...l.map(g=>W(Qr(g)))),f=!!(e.layout&&e.lowerScene&&s&&l.every(g=>ei(s,g)));break;case"family-svg":u.push(W("operation:layout"),W("operation:render-svg")),f=!!(e.layout&&e.renderSvg);break;case"terminal":u.push(W("operation:render-terminal")),f=e.renderAscii!==void 0;break;case"layout":u.push(W("operation:layout"),W("operation:project-positioned")),f=!!(e.layout&&e.projectPositioned);break}let m=wn(n,{offers:p,requirements:u,outputAvailable:f});if(!m.accepted)throw ns(n,e,t,a,s,m);let h;if(a==="scene"||a==="family-svg"){let g=Object.freeze(a==="scene"?{mode:"scene",requestedId:d,selectedId:s.identity.id,version:s.identity.version,hostPolicy:r.backendPolicy!==void 0}:{mode:"family-svg"}),S={family:Object.freeze({id:e.identity.id,version:e.identity.version}),backend:g};h=Object.freeze({...S,digest:Fe(S)})}let y=i===void 0?void 0:Object.freeze(Ur(e.id,i,e.config).map(g=>Object.freeze({...g})));return Object.freeze({output:n,mode:a,family:e,...s?{backend:s}:{},...d?{requestedBackendId:d}:{},...y===void 0?{}:{configDiagnostics:y},...o?{onConfigDiagnostic:o}:{},capabilityDecision:m,...h?{executionDecision:h}:{}})}function ti(e){return!e.id.startsWith("output:")&&!e.id.startsWith("operation:")&&!e.id.startsWith("backend:")&&!e.id.startsWith("scene-primitive:")&&e.id!=="core:scene"}function is(e){let{family:t,source:n,options:r,style:i,styleFace:o}=e,a=r.security==="strict"?{...r,embedFontImport:!1}:{...r},s=i!==void 0&&Zn(i);s&&(a=Wo(a,i,n.config.themeVariables));let d=r.font??n.config.fontFamily??On(n.config.themeVariables,"fontFamily")??a.font??"Inter",l={...a,font:d,mermaidConfig:n.config},c={...kn(l,n.config,d)},p=Ko(t,n,l,c,i,o),u=E(p.colors),f=Zo(r.style),m=Qo(n),h={version:ht,colors:u,font:d,style:E(i),face:E(o),styled:s,inferredBackend:i?Xn(i):"default",styleReferences:f,...m.length>0?{unsafeThemeColorKeys:m}:{},...p.familyAppearance?{family:p.familyAppearance}:{}},y=E({...h,digest:Fe(h)});return E({renderOptions:E(p.renderOptions),appearance:y,...p.familyConfig?{familyConfig:p.familyConfig}:{}})}function pi(e,t={},n="svg",r,i={}){let o=Yo(t),a=o.serializable,s=a,d=ai(s);if(d.length>0)throw new TypeError(`Invalid RenderOptions: ${d.join("; ")}`);let l=Yn(a.style),c=l.style,p=E(l.face),u=li(s);if(u.length>0)throw new TypeError(`Invalid RenderOptions: ${u.join("; ")}`);let f=He(e),m=hn(f,a.mermaidConfig??{}),h=f===e?m:mn(e),y=Object.freeze({...m,originalText:e}),g=i.familyDescriptor??Uo(y,h);if(i.expectedFamilyId!==void 0&&g.id!==i.expectedFamilyId)throw new nn(i.expectedFamilyId,g.id);let S=Cn(y.config.themeCSS,a.security??"default");if(S)throw new TypeError(S);let k=Object.freeze($e.filter(F=>a[F]!==void 0)),H=Go(g,k),v=is({family:g,source:y,options:a,...c?{style:c}:{},...p?{styleFace:p}:{}}),{appearance:L,renderOptions:Y,familyConfig:_}=v,N=rs(g,L,n,i,a.mermaidConfig,o.onConfigDiagnostic),C=N.capabilityDecision,G=Object.freeze({version:C.version,accepted:C.resolutions.filter(ti).every(F=>F.level!=="required"||F.status==="selected"),resolutions:Object.freeze(C.resolutions.filter(ti))}),w={version:ht,authoredSource:y.originalText,source:y.text,options:rn(Y),appearance:L.digest,..._?{familyConfig:_}:{},capabilities:G},x=Fe(w),A={...w,output:n,outputOptions:r,capabilities:C},U=Object.freeze({version:ht,output:n,source:E(y),renderOptions:Y,appearance:L,..._?{familyConfig:_}:{},capabilityDecision:C,explicitOptionFields:k,...H.length===0?{}:{resolutionDiagnostics:H},sharedRequestDigest:x,requestDigest:Fe(A)});return on.set(U,N),U}function os(e){return"positioned"in e?e:{positioned:e}}function ui(e,t,n=t.source){let r=he(t).family;if(r.id!==e)throw new Error(`Resolved request planned family ${r.id}, not ${e}`);if(!r.layout)throw new Error(`No layout registered for Mermaid family ${e}`);let i=bt(t);return os(r.layout({source:n,renderOptions:i.renderOptions,...i.styleFace?{styleFace:i.styleFace}:{},...i.familyConfig?{familyConfig:i.familyConfig}:{},...i.familyAppearance?{familyAppearance:i.familyAppearance}:{}}))}var fi=new WeakSet;function mi(e){if(fi.has(e))return;fi.add(e);let t=he(e),n=t.configDiagnostics??[];if(n.length===0)return;let r=t.onConfigDiagnostic??(i=>console.warn(i.message));for(let i of n)r(i)}function hi(e,t,n="scene.parts"){e.forEach((r,i)=>{let o=`${n}[${i}]`;t(r,o),r.kind==="group"&&hi(r.children.map(a=>a.node),t,`${o}.children`)})}function yi(e,t){let n=e.id.startsWith("family:"),r=jn(t,Nn,"scene");Pn(r,{mode:n?"external":"internal"});let i=r,o=[];n&&i.family!==e.id&&o.push({code:"SCENE_DOCUMENT",path:"scene.family",message:`external family "${e.id}" emitted a document owned by "${i.family}"`});let a=new Set(e.semanticRoles),s=new Set(e.semanticChannels),d=new Map(e.scenePrimitiveEvidence.map(l=>[`${l.role}\0${l.primitive}`,l]));if(hi(i.parts,(l,c)=>{if(!a.has(l.role)){o.push({code:"SCENE_PRIMITIVE_CLAIM",path:`${c}.role`,message:`emitted undeclared role "${l.role}"`});return}for(let p of Object.keys(l.channels??{}))s.has(p)||o.push({code:"SCENE_CHANNEL_CLAIM",path:`${c}.channels.${p}`,message:`emitted undeclared semantic channel "${p}"`});for(let p of $n(l)){let u=d.get(`${l.role}\0${p}`);(!u||u.applicability!=="applicable"||u.realization==="unsupported")&&o.push({code:"SCENE_PRIMITIVE_CLAIM",path:c,message:`emitted undeclared ${l.role}/${p} primitive`})}}),o.length>0)throw new In(Object.freeze(o));return i}function bi(e,t){let n=e.appearance.colors,r=e.output==="png"&&n.embedFontImport!==!1?{...n,embedFontImport:!1}:n;return{positioned:t.positioned,colors:r,resolved:bt(e)}}function ss(e,t){let n=he(e);if(n.mode!=="scene")throw new Error(`Resolved ${e.output} request has no Scene execution plan`);let r=n.family;return yi(r,r.lowerScene(bi(e,t)))}function gi(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function as(e,t,n){let r=`${n}svg-title`,i=`${n}svg-desc`,o=[],a=[];if(t.title&&(o.push(`aria-labelledby="${r}"`),a.push(`<title id="${r}">${gi(t.title)}</title>`)),t.descr&&(o.push(`aria-describedby="${i}"`),a.push(`<desc id="${i}">${gi(t.descr)}</desc>`)),a.length===0)return e;let s=Sn(e);if(!s||Je(s,"aria-labelledby")||Je(s,"aria-describedby"))return e;let d=`${Je(s,"role")?"":' role="img"'} ${o.join(" ")}`,l=e.slice(s.start,s.end);return Rn(e,s,`${l.slice(0,-1)}${d}>${a.join("")}`)}function cs(e,t,n){let r=he(e);if(r.mode!=="scene"&&r.mode!=="family-svg"||!r.executionDecision)throw new Error(`Resolved ${e.output} request has no graphical execution plan`);let i=e.renderOptions,o=r.family,a=bi(e,t),s;if(r.mode==="scene"){let f=ss(e,t);s=r.backend.backend.render(f,{seed:i.seed??0,...e.appearance.styled?{style:e.appearance.style}:{}})}else s=o.renderSvg(a);ie(s,"backend/family SVG output");let d=xn(s,a.colors);ie(d,"color-resolved SVG output"),d=Vr(d,e.appearance.font),ie(d,"font-geometry-fitted SVG output");let l=i.idPrefix??"";l&&(d=qn(d,l),ie(d,"namespaced SVG output"));let c=e.source.accessibility;(t.injectAccessibility??!0)&&(c.title||c.descr)&&(d=as(d,c,l),ie(d,"accessibility-projected SVG output")),i.compact&&(d=Wn(d),ie(d,"compacted SVG output"));let p=e.output==="png"?"strict":i.security,u=An(d,p);return n.push(...u.diagnostics),d=u.svg,ie(d,"final SVG output"),Object.freeze({svg:d,executionDecision:r.executionDecision})}function ls(e,t){let n=he(e).family.id;return cs(e,ui(n,e),t)}function Si(e,t,n,r,i={}){let o=pi(e,t,n,r,i);mi(o);let a=[],s=ls(o,a),d=di(o,a);return Object.freeze({svg:s.svg,receipt:Object.freeze({...d,graphicalProjectionDigest:Fe(s.svg),executionDecision:s.executionDecision})})}function Fc(e,t,n){return dn(n),Si(e,t,"svg",void 0,{expectedFamilyId:n.id,familyDescriptor:n}).svg}export{Fc as renderLoadedFamilySvg};
@@ -0,0 +1,12 @@
1
+ import{c as Ye,d as Fe}from"./chunk-A7L4WWVW.js";import{f as Ze}from"./chunk-PXRUFH7U.js";import"./chunk-KJVNXJ5Y.js";import{e as xe}from"./chunk-MMWVZP6M.js";import"./chunk-FFOHLPDA.js";import{a as it}from"./chunk-I6VE56S7.js";import{a as rt}from"./chunk-OFRMKQA6.js";import{b as Ne,e as Be}from"./chunk-FLD63DXE.js";import{a as J,c as fe,d as ue,e as ee,g as _e,j as A,k as me}from"./chunk-RVO6J7S3.js";import{a as Xe,b as Oe,c as Ge}from"./chunk-EPFMQPXX.js";import{G as Ke,H as Qe,I as Je,L as G,N as Ve,O as b,P as Z,i as ae,ia as V,j as Le,ja as se,ka as U,l as Ue,la as ce,m as We,na as et,oa as tt,pa as oe,qa as ot,t as je,xa as nt}from"./chunk-FXBBGAMJ.js";import"./chunk-P7HMSKHJ.js";var Lt=Object.freeze({id:"sequence",upstreamId:"sequence",maturity:"stable",label:"Sequence",headers:["sequenceDiagram"],aliases:[],config:{section:"sequence",keys:["actorMargin","width","height","diagramMarginX","diagramMarginY","messageMargin","noteMargin","activationWidth","showSequenceNumbers","boxMargin","boxTextMargin","messageAlign","mirrorActors","bottomMarginAdj","rightAngles","wrap","wrapPadding","labelBoxWidth","labelBoxHeight","hideUnusedParticipants","forceMenus","arrowMarkerAbsolute","noteAlign","actorFontSize","actorFontFamily","actorFontWeight","noteFontSize","noteFontFamily","noteFontWeight","messageFontSize","messageFontFamily","messageFontWeight","useMaxWidth","useWidth"],noopKeys:["actorFontFamily","actorFontSize","actorFontWeight","arrowMarkerAbsolute","bottomMarginAdj","boxMargin","boxTextMargin","forceMenus","hideUnusedParticipants","labelBoxHeight","labelBoxWidth","messageAlign","messageFontFamily","messageFontSize","messageFontWeight","mirrorActors","noteAlign","noteFontFamily","noteFontSize","noteFontWeight","rightAngles","useMaxWidth","useWidth","wrap","wrapPadding"]},identity:{id:"family:sequence",kind:"family",version:"1.0.0",compatibility:{core:"^0.3.0"},provenance:{owner:"agentic-mermaid",source:"built-in"}},collisionPriority:100,semanticChannels:["category"],semanticRoles:["prelude","defs","chrome","actor","lifeline","activation","message","block","group","note","label","icon"],scenePrimitiveEvidence:[{role:"prelude",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"defs",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"defs",primitive:"marker",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"actor",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"actor",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"lifeline",primitive:"connector",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"activation",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"message",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"message",primitive:"connector",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"block",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"block",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"block",primitive:"connector",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"note",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"note",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"label",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"icon",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"icon",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"icon",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]}],example:`sequenceDiagram
2
+ participant U as User
3
+ participant S as Server
4
+ U->>S: request
5
+ S-->>U: response`,detect:e=>/^sequencediagram\s*$/.test(e),detectLoose:e=>/^sequencediagram(?:\s|$)/.test(e)}),at=Lt;var st=["actorMargin","width","height","diagramMarginX","diagramMarginY","messageMargin","noteMargin","activationWidth"],jt=[...st,"showSequenceNumbers"];function ct(e){if(!e||!Ye(e,["sequence"]))return{};let t={};for(let i of st){let n=Fe(e,["sequence",i]);typeof n=="number"&&Number.isFinite(n)&&n>=0&&(t[i]=n)}return Fe(e,["sequence","showSequenceNumbers"])===!0&&(t.showSequenceNumbers=!0),t}function lt(e){let t=e.toLowerCase();return t==="transparent"||t in Le||/^#[0-9a-fA-F]{3,8}$/.test(e)?!0:/^(?:rgb|rgba|hsl|hsla)\([^)]*\)$/i.test(e)}function dt(e){let t=Le[e.toLowerCase()];if(t)return t;let r=Ue(e);if(r)return We(r[0],r[1],r[2]);let i=e.match(/^rgba?\(\s*(\d{1,3})\s*[, ]\s*(\d{1,3})\s*[, ]\s*(\d{1,3})/i);return i?We(Math.min(255,Number.parseInt(i[1],10)),Math.min(255,Number.parseInt(i[2],10)),Math.min(255,Number.parseInt(i[3],10))):null}var Wt=/^(\S+?)(\(\))?\s*(<<-->>|<<->>|-->>|->>|--x|-x|--\)|-\)|-->|->|--[|\\/]|-[|\\/]|[|\\/]--|[|\\/]-)\s*(\(\))?([+-]?)(\S+?)\s*:\s*(.+)$/;function Ct(e){let t=e.match(Wt);return!t||!qt(t[3])?null:{from:t[1],arrow:t[3],activationMark:t[5]||void 0,to:t[6],label:t[7],centralStart:!!t[2],centralEnd:!!t[4]}}function gt(e,t={}){let r=Ne(e);e=r.familyLines;let i={actors:[],messages:[],blocks:[],notes:[],activationEvents:[],boxes:[],...r.accessibility.title!==void 0?{accessibilityTitle:G(r.accessibility.title)}:{},...r.accessibility.descr!==void 0?{accessibilityDescription:G(r.accessibility.descr)}:{}},n=new Set,s=[],c=null,d=t.showSequenceNumbers===!0?{next:1,step:1}:null,f=[],M=[],k=(u,x,w,C,q,E=!1,R=!1)=>{le(i,n,u),le(i,n,C);let D=Rt(x),L={from:u,to:C,label:G(q.trim()),lineStyle:D.lineStyle,startHead:D.startHead,endHead:D.endHead,centralStart:E,centralEnd:R};w==="+"&&(L.activate=!0),w==="-"&&(L.deactivate=!0),d&&(L.number=d.next,d.next=Math.round((d.next+d.step)*100)/100),pt(f,$=>$===C,i,$=>{$.createMessageIndex=i.messages.length}),pt(M,$=>$===u||$===C,i,$=>{$.destroyMessageIndex=i.messages.length}),i.messages.push(L)};for(let u=1;u<e.length;u++){let x=e[u],w=zt(x);if(w){let{id:h,label:y,type:T}=w;n.has(h)||(n.add(h),i.actors.push({id:h,label:y,type:T})),c&&!c.actorIds.includes(h)&&c.actorIds.push(h);continue}let C=Ht(x);if(C){le(i,n,C.actorId);let h=i.actors.find(y=>y.id===C.actorId);h.links={...h.links,...C.links};continue}let q=x.match(/^autonumber(?:\s+(.*))?$/i);if(q){let h=q[1]?.trim()??"";if(/^off$/i.test(h))d=null;else{let y=h.match(/^(\d+(?:\.\d+)?)(?:\s+(\d+(?:\.\d+)?))?$/);d={next:y?Number.parseFloat(y[1]):1,step:y?.[2]!==void 0?Number.parseFloat(y[2]):1}}continue}let E=x.match(/^box(?:\s+(.*))?$/i);if(E){let h=E[1]?.trim()??"",y={actorIds:[]},T=h.match(/^((?:rgb|rgba|hsl|hsla)\([^)]*\))\s*(.*)$/i),m=h;if(T)y.color=T[1],m=T[2]?.trim()??"";else{let p=h.split(/\s+/,1)[0]??"";p&&lt(p)&&(y.color=p,m=h.slice(p.length).trim())}m&&(y.label=G(m)),i.boxes.push(y),c=y;continue}let R=x.match(/^create\s+(participant|actor)\s+(\S+?)(?:\s+as\s+(.+))?$/i);if(R){let h=R[1].toLowerCase(),y=R[2],T=G(R[3]?.trim()??y);n.has(y)||(n.add(y),i.actors.push({id:y,label:T,type:h})),f.push(y);continue}let D=x.match(/^destroy\s+(\S+)$/i);if(D){M.push(D[1]);continue}let L=x.match(/^Note\s+(left of|right of|over)\s+([^:]+):\s*(.+)$/i);if(L){let h=L[1].toLowerCase(),y=L[2].trim(),T=G(L[3].trim()),m=y.split(",").map(F=>F.trim());for(let F of m)le(i,n,F);let p="over";h==="left of"?p="left":h==="right of"&&(p="right"),i.notes.push({actorIds:m,text:T,position:p,afterIndex:i.messages.length-1});continue}let $=x.match(/^(loop|alt|opt|par|critical|break|rect)\s*(.*)$/);if($){let h=$[1],y=$[2]?.trim()??"",T=G(y);s.push({type:h,label:T,startIndex:i.messages.length,dividers:[]});continue}let Y=x.match(/^(else|and)\s*(.*)$/);if(Y&&s.length>0){let h=Y[2]?.trim()??"",y=G(h);s[s.length-1].dividers.push({index:i.messages.length,label:y});continue}if(x==="end"&&s.length>0){let h=s.pop();i.blocks.push({type:h.type,label:h.label,startIndex:h.startIndex,endIndex:Math.max(i.messages.length-1,h.startIndex),dividers:h.dividers});continue}if(x==="end"&&c){c=null;continue}let l=Ct(x);if(l){k(l.from,l.arrow,l.activationMark,l.to,l.label,l.centralStart,l.centralEnd);continue}let v=x.match(/^(activate|deactivate)\s+(\S+)$/i);if(v){let h=v[2];le(i,n,h),i.activationEvents.push({actorId:h,kind:v[1].toLowerCase(),messageIndex:i.messages.length});continue}}return i}var Tt=new Set(["participant","actor","boundary","control","entity","database","collections","queue"]);function zt(e){let t=e.match(/^(participant|actor)\s+([^\s@]+)@\{([\s\S]+)\}(?:\s+as\s+(.+))?$/i);if(t){let n=t[1].toLowerCase(),s=t[2],c={};try{c=JSON.parse(`{${t[3]}}`)}catch{let k=t[3].replace(/(^|[,{])(\s*)([A-Za-z][\w-]*)\s*:/g,'$1$2"$3":').replace(/'([^'\\]*(?:\\.[^'\\]*)*)'/g,(u,x)=>JSON.stringify(x.replace(/\\'/g,"'")));try{c=JSON.parse(`{${k}}`)}catch{return null}}let d=typeof c.type=="string"?c.type.toLowerCase():n;if(!Tt.has(d))throw new Error(`Unknown sequence actor type '${d}'`);let f=d,M=t[4]?.trim()??(typeof c.alias=="string"?c.alias:void 0);return{id:s,label:G(M??s),type:f}}let r=e.match(/^(participant|actor)\s+(\S+?)(?:\s+as\s+(.+))?$/i);if(!r)return null;let i=r[2];return{id:i,label:G(r[3]?.trim()??i),type:r[1].toLowerCase()}}function Ht(e){let t=e.match(/^link\s+(\S+)\s*:\s*(.+?)\s*@\s*(\S+)$/i);if(t)return/^(?:https?:|mailto:)/i.test(t[3])?{actorId:t[1],links:{[t[2].trim()]:t[3]}}:null;let r=e.match(/^links\s+(\S+)\s*:\s*(\{.*\})$/i);if(!r)return null;try{let i=JSON.parse(r[2]),n={};for(let[s,c]of Object.entries(i))typeof c=="string"&&/^(?:https?:|mailto:)/i.test(c)&&(n[s]=c);return Object.keys(n).length>0?{actorId:r[1],links:n}:null}catch{return null}}function qt(e){return/^(?:<<-+>>|-+>>?|-+[)x]|-+[|\\/]|[|\\/]-+)$/.test(e)}function Rt(e){let t=e.includes("--")?"dashed":"solid";return/^<<-+>>$/.test(e)?{lineStyle:t,startHead:"filled",endHead:"filled"}:e.endsWith("x")?{lineStyle:t,startHead:"none",endHead:"cross"}:e.endsWith(")")?{lineStyle:t,startHead:"none",endHead:"open"}:/^-+>>$/.test(e)?{lineStyle:t,startHead:"none",endHead:"filled"}:/^-+>$/.test(e)?{lineStyle:t,startHead:"none",endHead:"none"}:/^[|\\/]-+$/.test(e)?{lineStyle:t,startHead:e.startsWith("/")?"half-bottom":"half-top",endHead:"none"}:/^-+[|\\/]$/.test(e)?{lineStyle:t,startHead:"none",endHead:e.endsWith("/")?"half-bottom":"half-top"}:{lineStyle:t,startHead:"none",endHead:"open"}}function le(e,t,r){t.has(r)||(t.add(r),e.actors.push({id:r,label:r,type:"participant"}))}function pt(e,t,r,i){for(let n=e.length-1;n>=0;n--){let s=e[n];if(!t(s))continue;let c=r.actors.find(d=>d.id===s);c&&i(c),e.splice(n,1)}}function Ce(e){return e.number!==void 0?`${e.number}. ${e.label}`:e.label}var z={padding:30,actorGap:140,actorHeight:40,actorPadX:16,headerGap:26,messageRowHeight:40,selfMessageHeight:30,activationWidth:10,blockPadX:10,blockPadTop:40,blockPadBottom:8,blockHeaderExtra:28,dividerExtra:24,noteWidth:60,notePadX:12,notePadY:6,noteGap:10,boxPadX:8,boxTitleSpace:22,boxPadBottom:8},ne={nodeLabelFontSize:fe.nodeLabel,edgeLabelFontSize:fe.edgeLabel,groupHeaderFontSize:fe.edgeLabel,nodeLabelFontWeight:ue.nodeLabel,edgeLabelFontWeight:ue.edgeLabel,groupHeaderFontWeight:ue.groupHeader,nodePaddingX:z.actorPadX,nodePaddingY:z.notePadY,nodeCornerRadius:4,nodeLineWidth:ee.outerBox,edgeLineWidth:ee.connector,groupCornerRadius:0,groupPaddingX:z.blockPadX,groupPaddingY:8,groupLabelPaddingX:6,groupLineWidth:ee.outerBox};function ht(e,t={},r={},i){let n=me(t,ne,i),s=r.diagramMarginX??z.padding,c=r.diagramMarginY??z.padding,d=r.width??80,f=r.noteMargin??z.noteGap,M=r.activationWidth??z.activationWidth,k=e.actors.map(o=>xe(i,"actor",{category:o.id},{includeFallback:!1})),u=Math.max(r.height??z.actorHeight,...k.map(o=>ae("Mg",o?.fontSize??n.nodeLabelFontSize,o?.fontWeight??n.nodeLabelFontWeight).height+(o?.paddingY??n.nodePaddingY)*2)),x=ae("Mg",ne.edgeLabelFontSize,ne.edgeLabelFontWeight).height,w=ae("Mg",n.edgeLabelFontSize,n.edgeLabelFontWeight).height,C=r.messageMargin??z.messageRowHeight,q=Math.max(C,C+w-x),E=Math.max(z.selfMessageHeight,q-10),R=Math.max(z.blockPadTop,z.blockPadTop+(n.groupHeaderFontSize-ne.groupHeaderFontSize)+(n.groupPaddingY-ne.groupPaddingY)*2),D=Math.max(z.blockHeaderExtra,R+n.groupPaddingY+20-q);if(e.actors.length===0)return{width:0,height:0,accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription,actors:[],lifelines:[],messages:[],activations:[],blocks:[],notes:[],boxes:[],destructions:[]};let L=e.actors.map((o,a)=>{let g=k[a],_=g?.textTransform??n.nodeTextTransform,H=g?.fontSize??n.nodeLabelFontSize,S=g?.fontWeight??n.nodeLabelFontWeight,P=g?.paddingX??n.nodePaddingX,O=A(o.label,_),Q=g?.letterSpacing??n.nodeLetterSpacing,B=Math.max(0,[...O].length-1)*Q,te=J(O,H,S)+B;return Math.max(te+P*2,d)}),$=new Map;for(let o=0;o<e.actors.length;o++)$.set(e.actors[o].id,o);let Y=Array.from({length:Math.max(0,e.actors.length-1)},()=>0);for(let o of e.messages){let a=$.get(o.from),g=$.get(o.to);if(a===void 0||g===void 0||a===g)continue;let _=Math.min(a,g),H=Math.max(a,g),S=H-_,P=A(Ce(o),n.edgeTextTransform),O=Math.max(0,[...P].length-1)*n.edgeLetterSpacing,Q=(J(P,n.edgeLabelFontSize,n.edgeLabelFontWeight)+O+16)/S;for(let B=_;B<H;B++)Y[B]=Math.max(Y[B],Q)}let l=[],v=s+L[0]/2;for(let o=0;o<e.actors.length;o++){if(o>0){let a=(L[o-1]+L[o])/2,g=r.actorMargin!==void 0?a+r.actorMargin:Math.max(z.actorGap,a+40);v+=Math.max(g,Y[o-1]??0)}l.push(v)}let h=(e.boxes??[]).filter(o=>o.actorIds.some(a=>$.has(a))),y=c+(h.length>0?z.boxTitleSpace+6:0),T=e.actors.map((o,a)=>({id:o.id,label:o.label,type:o.type,...o.links?{links:{...o.links}}:{},x:l[a],y,width:L[a],height:u})),m=y+u+z.headerGap,p=[],F=new Map;for(let o of e.blocks){let a=F.get(o.startIndex)??0;F.set(o.startIndex,Math.max(a,D));for(let g of o.dividers){let _=F.get(g.index)??0;F.set(g.index,Math.max(_,z.dividerExtra))}}let W=new Map,ie=new Map,de=new Map;for(let o=0;o<e.actors.length;o++){let a=e.actors[o];if(a.createMessageIndex!==void 0&&a.createMessageIndex<e.messages.length){let g=W.get(a.createMessageIndex)??[];g.push(o),W.set(a.createMessageIndex,g);let _=F.get(a.createMessageIndex)??0;F.set(a.createMessageIndex,Math.max(_,u/2+8))}if(a.destroyMessageIndex!==void 0&&a.destroyMessageIndex<e.messages.length){let g=ie.get(a.destroyMessageIndex)??[];g.push(a.id),ie.set(a.destroyMessageIndex,g)}}let pe=new Map;for(let o of e.notes){let a=pe.get(o.afterIndex)??[];a.push(o),pe.set(o.afterIndex,a)}let be=[],ge=new Map,ye=[],bt=4,$e=new Map;for(let o of e.activationEvents??[]){let a=$e.get(o.messageIndex)??[];a.push(o),$e.set(o.messageIndex,a)}let Te=(o,a)=>{let g=ge.get(o)??[];g.push({startY:a,depth:g.length}),ge.set(o,g)},Se=(o,a)=>{let g=ge.get(o);if(!g||g.length===0)return;let{startY:_,depth:H}=g.pop(),S=$.get(o);S===void 0||a<=_||ye.push({actorId:o,x:l[S]-M/2+H*bt,topY:_,bottomY:a,width:M})},ze=(o,a)=>{for(let g of $e.get(o)??[])g.kind==="activate"?Te(g.actorId,a):Se(g.actorId,a)},He=(o,a)=>{let g=A(o.text,n.nodeTextTransform),_=Math.max(z.noteWidth,J(g,n.nodeLabelFontSize,n.nodeLabelFontWeight)+n.nodePaddingX*2),H=ae(g,n.nodeLabelFontSize,n.nodeLabelFontWeight).height+n.nodePaddingY*2,S=$.get(o.actorIds[0]??"")??0,P;if(o.position==="left")P=l[S]-L[S]/2-_-f;else if(o.position==="right")P=l[S]+L[S]/2+f;else if(o.actorIds.length>1){let O=$.get(o.actorIds[o.actorIds.length-1]??"")??S;P=(l[S]+l[O])/2-_/2}else P=l[S]-_/2;return{text:o.text,x:P,y:a,width:_,height:H,position:o.position,actors:o.actorIds}},ke=pe.get(-1);if(ke&&ke.length>0){let o=m;for(let a of ke){let g=He(a,o);be.push(g),o+=g.height+4}m=Math.max(m,o+q/2)}for(let o=0;o<e.messages.length;o++){let a=e.messages[o],g=$.get(a.from)??0,_=$.get(a.to)??0,H=a.from===a.to,S=F.get(o)??0;S>0&&(m+=S),ze(o,m);let P=l[g],O=l[_];p.push({from:a.from,to:a.to,label:Ce(a),lineStyle:a.lineStyle,startHead:a.startHead,endHead:a.endHead,centralStart:a.centralStart??!1,centralEnd:a.centralEnd??!1,x1:P,x2:O,y:m,isSelf:H});let Q=ie.get(o);if(Q)for(let te of Q)de.set(te,m);a.activate&&Te(a.to,m),a.deactivate&&Se(a.from,m),m+=H?E+q:q,W.has(o)&&(m+=u/2);let B=pe.get(o);if(B&&B.length>0){let te=H?E:0,I=p[o].y+te+14;for(let N of B){let he=He(N,I);be.push(he),I+=he.height+4}m=Math.max(m,I+q/2)}}let qe=Math.max(p[p.length-1]?.y??m,m-q/2);ze(e.messages.length,qe);for(let[o,a]of ge)for(;a.length>0;)Se(o,qe);for(let[o,a]of W){let g=p[o]?.y;if(g!==void 0)for(let _ of a)T[_].y=g-u/2}let ve=e.blocks.map(o=>{let a=p[o.startIndex],g=p[o.endIndex],_=(a?.y??m)-R,H=(g?.y??m)+n.groupPaddingY+12,S=new Set;for(let I=o.startIndex;I<=o.endIndex;I++){let N=e.messages[I];N&&(S.add($.get(N.from)??0),S.add($.get(N.to)??0))}if(S.size===0)for(let I=0;I<e.actors.length;I++)S.add(I);let P=Math.min(...S),O=Math.max(...S),Q=l[P]-L[P]/2-n.groupPaddingX,B=l[O]+L[O]/2+n.groupPaddingX,te=o.dividers.map(I=>{let N=p[I.index],he=N?.y??m,Ie=28;if(I.label&&N?.label){let Mt=A(`[${I.label}]`,n.edgeTextTransform),wt=J(Mt,n.edgeLabelFontSize,n.edgeLabelFontWeight),Pe=Q+8,Ft=Pe+wt,Ae=J(A(N.label,n.edgeTextTransform),n.edgeLabelFontSize,n.edgeLabelFontWeight),De=N.isSelf?N.x1+36:(N.x1+N.x2)/2-Ae/2,_t=De+Ae,Ee=8;Ft+Ee>De&&Pe-Ee<_t&&(Ie=Math.max(36,Math.ceil(24+w)))}return{y:he-Ie,label:I.label}});return{type:o.type,label:o.label,x:Q,y:_,width:B-Q,height:H-_,dividers:te}}),Me=be,yt=m,we=h.map(o=>{let a=o.actorIds.map(S=>$.get(S)).filter(S=>S!==void 0),g=Math.min(...a.map(S=>l[S]-L[S]/2))-z.boxPadX,_=Math.max(...a.map(S=>l[S]+L[S]/2))+z.boxPadX;if(o.label){let S=J(A(o.label,n.groupTextTransform),n.groupHeaderFontSize,n.groupHeaderFontWeight);_=Math.max(_,g+S+z.boxPadX*2)}let H=c;return{label:o.label,color:o.color,x:g,y:H,width:_-g,height:yt+z.boxPadBottom-H}}),Re=m+c,j=s,X=0;for(let o of T)j=Math.min(j,o.x-o.width/2),X=Math.max(X,o.x+o.width/2);for(let o of ve)j=Math.min(j,o.x),X=Math.max(X,o.x+o.width);for(let o of Me)j=Math.min(j,o.x),X=Math.max(X,o.x+o.width);for(let o of we)j=Math.min(j,o.x),X=Math.max(X,o.x+o.width);for(let o of p)if(o.isSelf&&o.label){let _=o.x1+30+8,H=J(A(o.label,n.edgeTextTransform),n.edgeLabelFontSize,n.edgeLabelFontWeight);X=Math.max(X,_+H+8)}let K=j<s?s-j:0;if(K>0){for(let o of T)o.x+=K;for(let o of p)o.x1+=K,o.x2+=K;for(let o of ye)o.x+=K;for(let o of ve)o.x+=K;for(let o of Me)o.x+=K;for(let o of we)o.x+=K;for(let o=0;o<l.length;o++)l[o]+=K}let $t=e.actors.map((o,a)=>({actorId:o.id,x:l[a],topY:T[a].y+u,bottomY:de.get(o.id)??Re-c})),St=e.actors.filter(o=>de.has(o.id)).map(o=>({actorId:o.id,x:l[$.get(o.id)],y:de.get(o.id)})),kt=X+K+s,vt=Re;return{width:Math.max(kt,200),height:Math.max(vt,100),accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription,actors:T,lifelines:$t,messages:p,activations:ye,blocks:ve,notes:Me,boxes:we,destructions:St}}function mt(e){let{positioned:t,colors:r,resolved:i}=e,n=i.renderOptions,s=r.font??"Inter",c=n.transparent??!1,d=[],f=me(n,ne,i.styleFace),M=`seq-${it(t.width,t.height,t.actors.length,t.messages.length)}`,k=`${M}-title`,u=`${M}-desc`,x=rt(t.accessibilityTitle,t.accessibilityDescription,k,u);d.push(ot({id:"prelude",width:t.width,height:t.height,colors:r,transparent:c,font:s,hasMonoFont:!1},Je(t.width,t.height,r,c,x)+`
6
+ `+Qe(s,!1,r.shadow,r.embedFontImport)));let w=[];w.push("<defs>");let C=xt(f);w.push(nt(C));let q=Ke(r);q&&w.push(q),w.push("</defs>"),d.push(et({id:"defs",markerResources:C},w.join(`
7
+ `))),t.accessibilityTitle&&d.push(ce({id:"a11y-title",role:"chrome"},`<title id="${k}">${ut(t.accessibilityTitle)}</title>`)),t.accessibilityDescription&&d.push(ce({id:"a11y-desc",role:"chrome"},`<desc id="${u}">${ut(t.accessibilityDescription)}</desc>`));let E=new Map;for(let l of t.boxes){let v=l.label??"",h=E.get(v)??0;E.set(v,h+1),d.push(Bt(l,f,`box:${v}#${h}`))}let R=new Map;for(let l of t.blocks){let v=R.get(l.type)??0;R.set(l.type,v+1),d.push(Et(l,f,`block:${l.type}#${v}`))}for(let l of t.lifelines)d.push(Pt(l,f));let D=new Map;for(let l of t.blocks){let v=D.get(l.type)??0;D.set(l.type,v+1),d.push(Nt(l,f,`block:${l.type}#${v}`))}let L=new Map;for(let l of t.activations){let v=L.get(l.actorId)??0;L.set(l.actorId,v+1),d.push(At(l,f,`activation:${l.actorId}#${v}`))}let $=new Map;for(let l of t.messages){let v=`${l.from}->${l.to}`,h=$.get(v)??0;$.set(v,h+1),d.push(Dt(l,f,`message:${v}#${h}`))}let Y=new Map;for(let l of t.notes){let v=`${(l.actors??[]).join(",")}@${l.position??"over"}`,h=Y.get(v)??0;Y.set(v,h+1),d.push(Ot(l,f,`note:${v}#${h}`))}for(let l of t.destructions)d.push(Xt(l,f));for(let l of t.actors)d.push(It(l,f,i.styleFace,n.security!=="strict"));return d.push(tt()),{family:"sequence",width:t.width,height:t.height,colors:r,transparent:c,parts:d}}function xt(e){let t=_e.width,r=_e.height,i=e.edgeStrokeColor??"var(--_arrow)",n={size:{width:t,height:r},orient:"auto-start-reverse"},s=[{x:0,y:0},{x:t,y:r/2},{x:0,y:r}];return[{...n,id:"seq-arrow",shape:"arrow",ref:{x:t,y:r/2},geometry:{kind:"polygon",points:s},paint:{fill:i}},{...n,id:"seq-arrow-open",shape:"open-arrow",ref:{x:t,y:r/2},geometry:{kind:"polyline",points:s},paint:{fill:"none",stroke:i,strokeWidth:"1"}},{...n,id:"seq-arrow-cross",shape:"cross",ref:{x:t/2,y:r/2},orient:"auto",geometry:{kind:"path",d:`M1 1 L${t-1} ${r-1} M1 ${r-1} L${t-1} 1`},paint:{fill:"none",stroke:i,strokeWidth:"1.5"}},{...n,id:"seq-arrow-half-top",shape:"open-arrow",ref:{x:t,y:r/2},geometry:{kind:"path",d:`M0 0 L${t} ${r/2}`},paint:{fill:"none",stroke:i,strokeWidth:"1"}},{...n,id:"seq-arrow-half-bottom",shape:"open-arrow",ref:{x:t,y:r/2},geometry:{kind:"path",d:`M0 ${r} L${t} ${r/2}`},paint:{fill:"none",stroke:i,strokeWidth:"1"}}]}function ft(e,t){if(t==="none")return;let r=t==="filled"?"seq-arrow":t==="cross"?"seq-arrow-cross":t==="half-top"?"seq-arrow-half-top":t==="half-bottom"?"seq-arrow-half-bottom":"seq-arrow-open";return xt(e).find(i=>i.id===r)}function It(e,t,r,i){let{id:n,x:s,y:c,width:d,height:f,label:M,type:k}=e,u=[],x=xe(r,"actor",{category:n},{includeFallback:!1}),w=x?.fontSize??t.nodeLabelFontSize,C=x?.fontWeight??t.nodeLabelFontWeight,q=x?.letterSpacing??t.nodeLetterSpacing,E=x?.textTransform??t.nodeTextTransform,R=x?.lineWidth??t.nodeLineWidth,D=x?.fillColor??t.nodeFillColor??"var(--_node-fill)",L=x?.borderColor??t.nodeBorderColor??"var(--_node-stroke)",$=x?.textColor??t.nodeTextColor??"var(--_text)",Y=i&&e.links?` data-links="${b(JSON.stringify(e.links))}" role="link" tabindex="0"`:"",l=`<g class="actor" data-id="${b(n)}" data-label="${b(M)}" data-type="${k}"${Y}>`,v=A(M,E),h=`font-size="${w}" text-anchor="middle" font-weight="${C}"${re(q)} fill="${b($)}"`;if(k==="actor"){let y=f/24*.9,T=s-12*y,m=c+(f-24*y)/2,p=R/y,F=b(x?.borderColor??t.edgeStrokeColor??"var(--_line)");u.push({indent:2,node:ce({id:`actor:${n}:icon`,role:"icon",channels:{category:n}},`<g transform="translate(${T},${m}) scale(${y})">
8
+ <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="${F}" stroke-width="${p}" />
9
+ <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="${F}" stroke-width="${p}" />
10
+ <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="${F}" stroke-width="${p}" />
11
+ </g>`)}),u.push({indent:2,node:U({id:`actor:${n}:label`,role:"label",text:v,x:s,y:c+f+14,fontSize:w,anchor:"middle",paint:{fill:$},channels:{category:n}},Z(v,s,c+f+14,w,h))})}else if(k!=="participant"){let y=b(x?.borderColor??t.edgeStrokeColor??"var(--_line)"),T=b(D),m=s-d/2,p=c+2,F=d,W=Math.max(24,f-4),ie=k==="database"?`<ellipse cx="${s}" cy="${p+5}" rx="${F/2}" ry="5"/><path d="M${m} ${p+5}V${p+W-5}A${F/2} 5 0 0 0 ${m+F} ${p+W-5}V${p+5}"/><ellipse cx="${s}" cy="${p+W-5}" rx="${F/2}" ry="5"/>`:k==="collections"?`<rect x="${m+6}" y="${p}" width="${F-6}" height="${W-6}"/><rect x="${m}" y="${p+6}" width="${F-6}" height="${W-6}"/>`:k==="queue"?`<rect x="${m}" y="${p}" width="${F}" height="${W}" rx="${W/2}"/><line x1="${m+8}" y1="${p+W/2}" x2="${m+F-8}" y2="${p+W/2}"/>`:k==="entity"?`<circle cx="${s}" cy="${p+W/2-3}" r="${Math.min(F,W)/2-3}"/><line x1="${m+5}" y1="${p+W}" x2="${m+F-5}" y2="${p+W}"/>`:k==="boundary"?`<circle cx="${s+3}" cy="${p+W/2}" r="${Math.min(F,W)/2-3}"/><line x1="${m+3}" y1="${p+2}" x2="${m+3}" y2="${p+W-2}"/>`:k==="control"?`<circle cx="${s}" cy="${p+W/2}" r="${Math.min(F,W)/2-3}"/><path d="M${s-4} ${p+4}L${s+4} ${p}L${s+2} ${p+8}"/>`:`<circle cx="${s}" cy="${p+W/2}" r="${Math.min(F,W)/2-3}"/>`;u.push({indent:2,node:ce({id:`actor:${n}:icon`,role:"icon",channels:{category:n}},`<g class="sequence-actor-glyph sequence-actor-${k}" fill="${T}" stroke="${y}" stroke-width="${R}">${ie}</g>`)}),u.push({indent:2,node:U({id:`actor:${n}:label`,role:"label",text:v,x:s,y:c+f+14,fontSize:w,anchor:"middle",paint:{fill:$},channels:{category:n}},Z(v,s,c+f+14,w,h))})}else{let y=s-d/2,T=D,m=L,p=x?.cornerRadius??t.cornerRadius??4;u.push({indent:2,node:V({id:`actor:${n}:box`,role:"actor",geometry:{kind:"rect",x:y,y:c,width:d,height:f,rx:p,ry:p},paint:{fill:T,stroke:m,strokeWidth:String(R)},channels:{category:n}},`<rect x="${y}" y="${c}" width="${d}" height="${f}" rx="${p}" ry="${p}" fill="${b(T)}" stroke="${b(m)}" stroke-width="${R}" />`)}),u.push({indent:2,node:U({id:`actor:${n}:label`,role:"label",text:v,x:s,y:c+f/2,fontSize:w,anchor:"middle",paint:{fill:$},channels:{category:n}},Z(v,s,c+f/2,w,h))})}return e.links&&u.push({indent:2,node:U({id:`actor:${n}:menu`,role:"icon",text:"\u22EF",x:s+d/2-7,y:c+10,fontSize:10,anchor:"middle",paint:{fill:$},channels:{category:n}},`<text class="sequence-actor-menu" x="${s+d/2-7}" y="${c+10}" text-anchor="middle" font-size="10" fill="${b($)}">\u22EF</text>`)}),oe({id:`actor:${n}`,role:"actor",open:l,close:"</g>",children:u,channels:{category:n}})}function Pt(e,t){let r=t.edgeStrokeColor??"var(--_line)",i=Math.max(.75,t.lineWidth*.75);return se({id:`lifeline:${e.actorId}`,role:"lifeline",geometry:{kind:"line",x1:e.x,y1:e.topY,x2:e.x,y2:e.bottomY},lineStyle:"dashed",paint:{stroke:r,strokeWidth:String(i),strokeDasharray:"6 4"}},`<line class="lifeline" data-actor="${b(e.actorId)}" x1="${e.x}" y1="${e.topY}" x2="${e.x}" y2="${e.bottomY}" stroke="${b(r)}" stroke-width="${i}" stroke-dasharray="6 4" />`)}function At(e,t,r){let i=t.nodeFillColor??"var(--_node-fill)",n=t.nodeBorderColor??"var(--_node-stroke)";return V({id:r,role:"activation",geometry:{kind:"rect",x:e.x,y:e.topY,width:e.width,height:e.bottomY-e.topY},paint:{fill:i,stroke:n,strokeWidth:String(ee.innerBox)}},`<rect class="activation" data-actor="${b(e.actorId)}" x="${e.x}" y="${e.topY}" width="${e.width}" height="${e.bottomY-e.topY}" fill="${b(i)}" stroke="${b(n)}" stroke-width="${ee.innerBox}" />`)}function Dt(e,t,r){let i=[],n=e.lineStyle==="dashed"?' stroke-dasharray="6 4"':"",s=ft(t,e.startHead),c=ft(t,e.endHead),d=`${s?` marker-start="url(#${s.id})"`:""}${c?` marker-end="url(#${c.id})"`:""}`,f=t.edgeStrokeColor??"var(--_line)",M=t.edgeTextColor??"var(--_text-muted)",k=A(e.label,t.edgeTextTransform),u={stroke:f,strokeWidth:String(t.lineWidth),...e.lineStyle==="dashed"?{strokeDasharray:"6 4"}:{}},x={endpoints:{from:e.from,to:e.to},relationship:{kind:"sequence-message",direction:e.isSelf?"self":s&&c?"bidirectional":s?"reverse":c?"forward":"undirected"},route:{ownership:"layout"},labels:e.label?[{text:e.label}]:[]},w=`<g class="message" data-label="${b(e.label)}" data-line-style="${e.lineStyle}" data-start-head="${e.startHead}" data-end-head="${e.endHead}" data-central-start="${e.centralStart}" data-central-end="${e.centralEnd}" data-self="${e.isSelf}">`;if(e.isSelf)i.push({indent:2,node:se({id:`${r}:line`,role:"message",geometry:{kind:"polyline",points:[{x:e.x1,y:e.y},{x:e.x1+30,y:e.y},{x:e.x1+30,y:e.y+20},{x:e.x2,y:e.y+20}]},lineStyle:e.lineStyle,paint:u,...s?{startMarker:s}:{},...c?{endMarker:c}:{},...x},`<polyline points="${e.x1},${e.y} ${e.x1+30},${e.y} ${e.x1+30},${e.y+20} ${e.x2},${e.y+20}" fill="none" stroke="${b(f)}" stroke-width="${t.lineWidth}"${n}${d} />`)}),i.push({indent:2,node:U({id:`${r}:label`,role:"label",text:k,x:e.x1+30+8,y:e.y+20/2,fontSize:t.edgeLabelFontSize,anchor:"start",paint:{fill:M}},Z(k,e.x1+30+8,e.y+20/2,t.edgeLabelFontSize,`font-size="${t.edgeLabelFontSize}" text-anchor="start" font-weight="${t.edgeLabelFontWeight}"${re(t.edgeLetterSpacing)} fill="${b(M)}"`))});else{i.push({indent:2,node:se({id:`${r}:line`,role:"message",geometry:{kind:"line",x1:e.x1,y1:e.y,x2:e.x2,y2:e.y},lineStyle:e.lineStyle,paint:u,...s?{startMarker:s}:{},...c?{endMarker:c}:{},...x},`<line x1="${e.x1}" y1="${e.y}" x2="${e.x2}" y2="${e.y}" stroke="${b(f)}" stroke-width="${t.lineWidth}"${n}${d} />`)});let C=(e.x1+e.x2)/2;i.push({indent:2,node:U({id:`${r}:label`,role:"label",text:k,x:C,y:e.y-10,fontSize:t.edgeLabelFontSize,anchor:"middle",paint:{fill:M}},Z(k,C,e.y-10,t.edgeLabelFontSize,`font-size="${t.edgeLabelFontSize}" text-anchor="middle" font-weight="${t.edgeLabelFontWeight}"${re(t.edgeLetterSpacing)} fill="${b(M)}"`))})}return e.centralStart&&i.push({indent:2,node:V({id:`${r}:central-start`,role:"chrome",geometry:{kind:"circle",cx:e.x1,cy:e.y,r:4},paint:{fill:"var(--bg)",stroke:f,strokeWidth:"1.5"}},`<circle class="sequence-central-connection" data-side="start" cx="${e.x1}" cy="${e.y}" r="4" fill="var(--bg)" stroke="${b(f)}" stroke-width="1.5" />`)}),e.centralEnd&&i.push({indent:2,node:V({id:`${r}:central-end`,role:"chrome",geometry:{kind:"circle",cx:e.x2,cy:e.y,r:4},paint:{fill:"var(--bg)",stroke:f,strokeWidth:"1.5"}},`<circle class="sequence-central-connection" data-side="end" cx="${e.x2}" cy="${e.y}" r="4" fill="var(--bg)" stroke="${b(f)}" stroke-width="1.5" />`)}),oe({id:r,role:"message",open:w,close:"</g>",children:i})}function Et(e,t,r){let i=[],n=e.label?` data-label="${b(e.label)}"`:"",s=`<g class="block" data-type="${b(e.type)}"${n}>`,c=t.groupFillColor??"none",d=t.groupBorderColor??"var(--_node-stroke)";i.push({indent:2,node:V({id:`${r}:rect`,role:"block",geometry:{kind:"rect",x:e.x,y:e.y,width:e.width,height:e.height,rx:t.groupCornerRadius,ry:t.groupCornerRadius},paint:{fill:c,stroke:d,strokeWidth:String(t.groupLineWidth)}},`<rect x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" rx="${t.groupCornerRadius}" ry="${t.groupCornerRadius}" fill="${b(c)}" stroke="${b(d)}" stroke-width="${t.groupLineWidth}" />`)});let f=t.edgeStrokeColor??"var(--_line)",M=t.edgeTextColor??"var(--_text-muted)",k=0;for(let u of e.dividers){let x=`${r}:divider#${k}`;k++;let w=Math.max(.75,t.lineWidth*.75);if(i.push({indent:2,node:se({id:x,role:"block",geometry:{kind:"line",x1:e.x,y1:u.y,x2:e.x+e.width,y2:u.y},lineStyle:"dashed",paint:{stroke:f,strokeWidth:String(w),strokeDasharray:"6 4"}},`<line x1="${e.x}" y1="${u.y}" x2="${e.x+e.width}" y2="${u.y}" stroke="${b(f)}" stroke-width="${w}" stroke-dasharray="6 4" />`)}),u.label){let C=A(`[${u.label}]`,t.edgeTextTransform);i.push({indent:2,node:U({id:`${x}:label`,role:"label",text:C,x:e.x+8,y:u.y+14,fontSize:t.edgeLabelFontSize,anchor:"start",paint:{fill:M}},Z(C,e.x+8,u.y+14,t.edgeLabelFontSize,`font-size="${t.edgeLabelFontSize}" text-anchor="start" font-weight="${t.edgeLabelFontWeight}"${re(t.edgeLetterSpacing)} fill="${b(M)}"`))})}}return oe({id:r,role:"block",open:s,close:"</g>",children:i})}function Nt(e,t,r){let i=A(`${e.type}${e.label?` [${e.label}]`:""}`,t.groupTextTransform),n=i.split(`
12
+ `)[0],s=J(n,t.groupHeaderFontSize,t.groupHeaderFontWeight)+t.groupPaddingX*2,c=Math.max(18,t.groupHeaderFontSize+t.groupPaddingY),d=t.groupHeaderFillColor??"var(--_group-hdr)",f=t.groupBorderColor??"var(--_node-stroke)",M=t.groupTextColor??"var(--_text-sec)";return oe({id:`${r}:header-overlay`,role:"block",open:'<g class="sequence-block-header-overlay" pointer-events="none" aria-hidden="true">',close:"</g>",children:[{indent:0,node:V({id:`${r}:tab`,role:"block",geometry:{kind:"rect",x:e.x,y:e.y,width:s,height:c},paint:{fill:d,stroke:f,strokeWidth:String(t.groupLineWidth)}},`<rect x="${e.x}" y="${e.y}" width="${s}" height="${c}" fill="${b(d)}" stroke="${b(f)}" stroke-width="${t.groupLineWidth}" />`)},{indent:0,node:U({id:`${r}:label`,role:"label",text:i,x:e.x+t.groupLabelPaddingX,y:e.y+c/2,fontSize:t.groupHeaderFontSize,anchor:"start",paint:{fill:M}},Z(i,e.x+t.groupLabelPaddingX,e.y+c/2,t.groupHeaderFontSize,`font-size="${t.groupHeaderFontSize}" font-weight="${t.groupHeaderFontWeight}"${t.groupFont?` font-family="${b(t.groupFont)}"`:""}${re(t.groupLetterSpacing)} fill="${b(M)}"`))}]})}function Bt(e,t,r){let i=[],s=`<g class="box"${e.label?` data-label="${b(e.label)}"`:""}>`,c=e.color?.toLowerCase()==="transparent"?"none":e.color,d=c??"color-mix(in srgb, var(--fg) 5%, var(--bg))";if(i.push({indent:2,node:V({id:`${r}:rect`,role:"group",geometry:{kind:"rect",x:e.x,y:e.y,width:e.width,height:e.height,rx:t.groupCornerRadius,ry:t.groupCornerRadius},paint:{fill:d,stroke:"none"}},`<rect x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" rx="${t.groupCornerRadius}" ry="${t.groupCornerRadius}" fill="${b(d)}" stroke="none" />`)}),e.label){let f=A(e.label,t.groupTextTransform),M=Yt(c,t),k=e.x+e.width/2,u=e.y+13;i.push({indent:2,node:U({id:`${r}:title`,role:"label",text:f,x:k,y:u,fontSize:t.groupHeaderFontSize,anchor:"middle",paint:{fill:M}},Z(f,k,u,t.groupHeaderFontSize,`font-size="${t.groupHeaderFontSize}" text-anchor="middle" font-weight="${t.groupHeaderFontWeight}"${t.groupFont?` font-family="${b(t.groupFont)}"`:""}${re(t.groupLetterSpacing)} fill="${b(M)}"`))})}return oe({id:r,role:"group",open:s,close:"</g>",children:i})}function Yt(e,t){let r=t.groupTextColor??"var(--_text-sec)";if(!e||e==="none")return r;let i=dt(e);if(!i)return r;let n=t.groupTextColor;if(n){let s=je(n,i);if(s!==null&&s>=4.5)return n}return Ze(i)??r}function Xt(e,t){let i=t.edgeStrokeColor??"var(--_line)",n=Math.max(1.5,t.lineWidth),s=`M ${e.x-8} ${e.y-8} L ${e.x+8} ${e.y+8} M ${e.x-8} ${e.y+8} L ${e.x+8} ${e.y-8}`;return V({id:`destroy:${e.actorId}`,role:"icon",geometry:{kind:"path",d:s},paint:{stroke:i,strokeWidth:String(n)},channels:{category:e.actorId}},`<path class="destroy-cross" data-actor="${b(e.actorId)}" d="${s}" fill="none" stroke="${b(i)}" stroke-width="${n}" />`)}function Ot(e,t,r){let{x:i,y:n,width:s,height:c}=e,d=e.actors&&e.actors.length>0?` data-actors="${e.actors.map(b).join(",")}"`:"",f=e.position?` data-position="${b(e.position)}"`:"",M=t.nodeFillColor??"var(--bg)",k=t.nodeBorderColor??"var(--_node-stroke)",u=t.nodeTextColor??"var(--_text-muted)",x=t.cornerRadius??0,w=A(e.text,t.nodeTextTransform);return oe({id:r,role:"note",open:`<g class="note"${f}${d}>`,close:"</g>",children:[{indent:2,node:V({id:`${r}:rect`,role:"note",geometry:{kind:"rect",x:i,y:n,width:s,height:c,rx:x,ry:x},paint:{fill:M,stroke:k,strokeWidth:String(ee.innerBox)}},`<rect x="${i}" y="${n}" width="${s}" height="${c}" rx="${x}" ry="${x}" fill="${b(M)}" stroke="${b(k)}" stroke-width="${ee.innerBox}" />`)},{indent:2,node:U({id:`${r}:text`,role:"label",text:w,x:i+s/2,y:n+c/2,fontSize:t.nodeLabelFontSize,anchor:"middle",paint:{fill:u}},Z(w,i+s/2,n+c/2,t.nodeLabelFontSize,`font-size="${t.nodeLabelFontSize}" text-anchor="middle" font-weight="${t.nodeLabelFontWeight}"${re(t.nodeLetterSpacing)} fill="${b(u)}"`))}]})}function re(e){return e!==0?` letter-spacing="${e}"`:""}var ut=Ve;var qo=Ge(at,{normalizeRequest:e=>({familyConfig:{sequence:ct(e.source.frontmatter)}}),layout:e=>{let t=e.familyConfig?.sequence??{},r=Be(gt(e.source.familyLines,t),e.source.accessibility);return Oe(ht(r,e.renderOptions,t,e.styleFace))},lowerScene:Xe(mt)});export{qo as default};
@@ -0,0 +1,4 @@
1
+ import{b as l}from"./chunk-4U2TVB2S.js";import{a as c}from"./chunk-4IUBLBJJ.js";import{a as n}from"./chunk-2U4EUPSI.js";import"./chunk-T7IJ6V4B.js";import"./chunk-5Q4S74UO.js";import"./chunk-STQRDZ67.js";import{c as o}from"./chunk-CTVVJPMX.js";import"./chunk-WEUWIFG3.js";import"./chunk-PXRUFH7U.js";import"./chunk-KJVNXJ5Y.js";import"./chunk-M6BT2HIP.js";import"./chunk-RVO6J7S3.js";import{a,b as r,c as s}from"./chunk-EPFMQPXX.js";import"./chunk-FXBBGAMJ.js";import"./chunk-P7HMSKHJ.js";var d=Object.freeze({id:"state",upstreamId:"stateDiagram",maturity:"stable",label:"State",headers:["stateDiagram","stateDiagram-v2"],aliases:[],config:{section:"state",keys:["arrowMarkerAbsolute","compositTitleSize","defaultRenderer","dividerMargin","edgeLengthFactor","fontSize","fontSizeFactor","forkHeight","forkWidth","labelHeight","miniPadding","nodeSpacing","noteMargin","padding","radius","rankSpacing","sizeUnit","textHeight","titleShift","titleTopMargin"]},identity:{id:"family:state",kind:"family",version:"1.0.0",compatibility:{core:"^0.3.0"},provenance:{owner:"agentic-mermaid",source:"built-in"}},collisionPriority:100,semanticChannels:["status"],semanticRoles:["prelude","defs","chrome","group","group-header","edge","edge-label","node","note","label"],scenePrimitiveEvidence:[{role:"prelude",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"defs",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"defs",primitive:"marker",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group-header",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group-header",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"edge",primitive:"connector",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"edge-label",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"node",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"node",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"note",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"note",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"label",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]}],example:`stateDiagram-v2
2
+ [*] --> Draft
3
+ Draft --> Review : submit
4
+ Review --> [*] : approve`,detect:function(i){let t=(i.split(";")[0]??"").trim().toLowerCase();return/^statediagram(?:-v2)?\s*$/.test(t)},detectLoose:function(i){let t=(i.split(";")[0]??"").trim().toLowerCase();return/^statediagram(?:-v2)?(?:\s|$)/.test(t)}}),p=d;var z=s(p,{normalizeRequest:e=>{let i=l(e.source.frontmatter,e.renderOptions),{stateVisual:t,...m}=i;return{renderOptions:m,...t?{appearance:{family:{visual:t}}}:{}}},layout:e=>{let i=e.familyAppearance?.visual;return r(o(n(e.source.familyText),{...e.renderOptions,...e.styleFace?{styleFace:e.styleFace}:{},...i?{stateVisual:i}:{}}))},lowerScene:a(c)});export{z as default};