agentic-mermaid 0.5.4 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENT_NATIVE.md +5 -9
- package/CHANGELOG.md +66 -0
- package/Instructions_for_agents.md +171 -97
- package/README.md +1 -1
- package/dist/agent-core.d.ts +7 -7
- package/dist/agent-core.js +1 -1
- package/dist/agent.d.ts +9 -10
- package/dist/agent.js +1 -1
- package/dist/agentic-mermaid-mcp.js +1 -1
- package/dist/am.js +1 -1
- package/dist/browser-lazy/chunks/{agentic-producer-core-ECZ3CMZM.js → agentic-producer-core-MYYZCUJS.js} +1 -1
- package/dist/browser-lazy/chunks/{architecture-H5LTMKQW.js → architecture-OHEIJI33.js} +6 -6
- package/dist/browser-lazy/chunks/{block-566X6FNV.js → block-DMBSQUFZ.js} +6 -6
- package/dist/browser-lazy/chunks/{builtin-backends-VAFEZXKY.js → builtin-backends-JTN3XG37.js} +3 -3
- package/dist/browser-lazy/chunks/{c4-ZXFDLBFK.js → c4-TK5GVVGU.js} +3 -3
- package/dist/browser-lazy/chunks/{chunk-7UFOFWBA.js → chunk-2R6M4CUH.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-YVNJDVQO.js → chunk-3K25OV6X.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-QVSZOF5M.js → chunk-3QXHJBE3.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-IUI4DYC3.js → chunk-4G652M75.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-LBXXKLIR.js → chunk-4WON4RCG.js} +3 -3
- package/dist/browser-lazy/chunks/{chunk-V6I2VGNQ.js → chunk-5SZ2YBKG.js} +9 -9
- package/dist/browser-lazy/chunks/{chunk-XHU3A432.js → chunk-CJZMMNPO.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-5LKPDHPC.js → chunk-F4CQMYR2.js} +4 -4
- package/dist/browser-lazy/chunks/{chunk-G4JBA7HU.js → chunk-GK5PSUKH.js} +3 -3
- package/dist/browser-lazy/chunks/{chunk-VRZKI33U.js → chunk-HAMXYU5V.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-Z7UHFVKN.js → chunk-IFUYPCDA.js} +6 -6
- package/dist/browser-lazy/chunks/{chunk-3JTYTXA6.js → chunk-ILCWDEZN.js} +4 -4
- package/dist/browser-lazy/chunks/{chunk-64JFHCJC.js → chunk-JJFXEH35.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-PXTLV57R.js → chunk-KOO3MCMJ.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-A7V5VDKN.js → chunk-LO25KEJY.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-TT5GR5EJ.js → chunk-MGB5QQEH.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-PSZEE64O.js → chunk-NVZKY7UI.js} +8 -8
- package/dist/browser-lazy/chunks/{chunk-6UOOATQR.js → chunk-PA7YKMP5.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-NKW2ZNCD.js → chunk-PS4HSV54.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-OBI5U5XU.js → chunk-QG67RIGQ.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-J57YRC2M.js → chunk-QOIFBX26.js} +1 -1
- package/dist/browser-lazy/chunks/chunk-QQCKPJF3.js +1 -0
- package/dist/browser-lazy/chunks/{chunk-O34YYEQV.js → chunk-QXSPMZ67.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-4NILRBC7.js → chunk-QYORAVMZ.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-OFOS57WQ.js → chunk-SC7LXD2V.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-EIYLJ4FI.js → chunk-SZAI2WB4.js} +12 -12
- package/dist/browser-lazy/chunks/{chunk-37FZNMPR.js → chunk-TXYQEDUF.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-2JQXRKBC.js → chunk-VR6YRNUZ.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-7TTFBJYA.js → chunk-WNTLLJPT.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-62MR3LWJ.js → chunk-YYF5TS6K.js} +1 -1
- package/dist/browser-lazy/chunks/{class-XIFNVBFE.js → class-QOJOM2XO.js} +8 -8
- package/dist/browser-lazy/chunks/{er-VEUYJBGG.js → er-2W6UXQT7.js} +6 -6
- package/dist/browser-lazy/chunks/{eventmodeling-G7DITZX7.js → eventmodeling-IVAFIO2U.js} +9 -9
- package/dist/browser-lazy/chunks/{flowchart-SSFIU4EU.js → flowchart-Y6OWQ46O.js} +1 -1
- package/dist/browser-lazy/chunks/{gantt-HQNVDX2B.js → gantt-BXTFJPZM.js} +6 -6
- package/dist/browser-lazy/chunks/{gitgraph-Z5MN6M6L.js → gitgraph-PW6R75SQ.js} +4 -4
- package/dist/browser-lazy/chunks/{ishikawa-UEERNFQV.js → ishikawa-GFX3XQQZ.js} +2 -2
- package/dist/browser-lazy/chunks/{journey-3BEWWGB5.js → journey-Q3M2GVKJ.js} +7 -7
- package/dist/browser-lazy/chunks/{kanban-2WFNCWLB.js → kanban-WVGVXROE.js} +11 -11
- package/dist/browser-lazy/chunks/{mindmap-R2C6SNYR.js → mindmap-CEDNSFJ6.js} +6 -6
- package/dist/browser-lazy/chunks/{packet-GMVCI5YZ.js → packet-Z56OVP2O.js} +3 -3
- package/dist/browser-lazy/chunks/{pie-WER45DKC.js → pie-FOJURIAM.js} +7 -7
- package/dist/browser-lazy/chunks/{quadrant-NCUPSFKN.js → quadrant-OGUQEK5C.js} +4 -4
- package/dist/browser-lazy/chunks/{radar-WLYS4YC5.js → radar-XTAUIQIJ.js} +9 -9
- package/dist/browser-lazy/chunks/render-core-QRFSDWGQ.js +3 -0
- package/dist/browser-lazy/chunks/{requirement-AK3NWMJ6.js → requirement-KEJ7ILX2.js} +7 -7
- package/dist/browser-lazy/chunks/{sankey-C2DY6WVU.js → sankey-ODWGDRAM.js} +8 -8
- package/dist/browser-lazy/chunks/{sequence-D4WJB44W.js → sequence-4ZNQR7S7.js} +1 -1
- package/dist/browser-lazy/chunks/{state-YUQVESE7.js → state-6IWPVJ4C.js} +2 -2
- package/dist/browser-lazy/chunks/{timeline-BMBJJXWR.js → timeline-LPJMPVPV.js} +4 -4
- package/dist/browser-lazy/chunks/{treemap-B66XBZZ6.js → treemap-2KFOQZRA.js} +4 -4
- package/dist/browser-lazy/chunks/xychart-KIPWFNVQ.js +16 -0
- package/dist/browser-lazy/chunks/{zenuml-62RLYFWP.js → zenuml-2ABFLOUP.js} +6 -6
- package/dist/browser-lazy/index.js +1 -1
- package/dist/browser.global.js +436 -436
- package/dist/chunk-3QC3FE2X.js +4 -0
- package/dist/{chunk-XU5LPD2D.js → chunk-5BYN55G4.js} +1 -1
- package/dist/chunk-5XKELJT2.js +2 -0
- package/dist/chunk-7HIKKNPP.js +150 -0
- package/dist/chunk-A5TX2FW5.js +2 -0
- package/dist/chunk-AS6A6XHE.js +2 -0
- package/dist/{chunk-DOFB572I.js → chunk-CGCGMO4U.js} +15 -15
- package/dist/chunk-GO4CS5KS.js +52 -0
- package/dist/{chunk-KXMANAST.js → chunk-JRLCGATA.js} +47 -47
- package/dist/{chunk-7XYB2LNC.js → chunk-K6TYUPTW.js} +2 -2
- package/dist/{chunk-HINRNKPO.js → chunk-QVP364DJ.js} +2 -2
- package/dist/chunk-V5RFODN6.js +2 -0
- package/dist/cli-PVKOWT4V.js +191 -0
- package/dist/elk-constructor.js +1 -1
- package/dist/{index-Bvhprdxz.d.ts → index-Bs7imZCS.d.ts} +14 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/{jsonl-RPJY6YWO.js → jsonl-5N4DTV7P.js} +2 -2
- package/dist/mcp-cli-EPIA7DTH.js +2 -0
- package/dist/{paint-certification-BoLyr006.d.ts → paint-certification-aIPtFDcn.d.ts} +2 -2
- package/dist/server-X6OFY2ZN.js +527 -0
- package/dist/{svg-styles-BnCoXyYe.d.ts → svg-styles-DfHloZTH.d.ts} +1 -1
- package/dist/svg-styles.d.ts +1 -1
- package/dist/svg-styles.js +1 -1
- package/dist/svg.d.ts +4 -4
- package/dist/svg.js +1 -1
- package/dist/{types-CLVJCaH2.d.ts → types-DkUbM48-.d.ts} +1 -1
- package/dist/zenuml/chunks/{appearance-5RM5MVM2.js → appearance-ROFRJDW7.js} +1 -1
- package/dist/zenuml/chunks/{builtin-backends-UTNWL4N3.js → builtin-backends-LM2A6WWK.js} +2 -2
- package/dist/zenuml/chunks/{chunk-ZNZRIISS.js → chunk-E6ZQYSVJ.js} +2 -2
- package/dist/zenuml/chunks/{chunk-IARQ24W3.js → chunk-KCHXQ5UA.js} +2 -2
- package/dist/zenuml/chunks/{chunk-3A6S6GNB.js → chunk-TEDVLVJM.js} +1 -1
- package/dist/zenuml/chunks/{chunk-CNLL4BGF.js → chunk-WD3ZPN3X.js} +1 -1
- package/dist/zenuml/chunks/{chunk-6J4BGPB2.js → chunk-WUHZDXTF.js} +24 -24
- package/dist/zenuml/chunks/{chunk-55WS466K.js → chunk-ZGLUBUQJ.js} +9 -9
- package/dist/zenuml/chunks/{render-core-ECIWU5ZS.js → render-core-WTHYSKBN.js} +2 -2
- package/dist/zenuml/chunks/{zenuml-N3LZMB2G.js → zenuml-3TCHUQJZ.js} +8 -8
- package/dist/zenuml.d.ts +2 -2
- package/dist/zenuml.js +1 -1
- package/docs/api.md +84 -4
- package/docs/quality.md +6 -3
- package/docs/style-authoring.md +23 -0
- package/docs/testing-strategy.md +59 -52
- package/examples/styles/readme-hero.md +4 -3
- package/package.json +4 -4
- package/server.json +2 -2
- package/skills/agentic-mermaid-diagram-workflow/SKILL.md +19 -154
- package/skills/agentic-mermaid-diagram-workflow/references/code-mode.md +12 -2
- package/skills/agentic-mermaid-diagram-workflow/references/hosted-mcp.md +5 -1
- package/dist/browser-lazy/chunks/chunk-6GPDLZFQ.js +0 -1
- package/dist/browser-lazy/chunks/render-core-42UVWIPF.js +0 -3
- package/dist/browser-lazy/chunks/xychart-HAVFROGT.js +0 -16
- package/dist/chunk-2DNGDTJD.js +0 -2
- package/dist/chunk-4F2UGYTM.js +0 -4
- package/dist/chunk-EHJI3QYE.js +0 -52
- package/dist/chunk-MKE7GNYU.js +0 -146
- package/dist/chunk-U4MT3RRE.js +0 -2
- package/dist/chunk-VUFVLGTH.js +0 -2
- package/dist/chunk-WYIB6BUR.js +0 -2
- package/dist/cli-ZYIDBYNS.js +0 -226
- package/dist/mcp-cli-YVDCORWA.js +0 -2
- package/dist/server-4JGAVXR3.js +0 -524
- package/docs/MCP-DIRECTORY-LISTINGS.md +0 -145
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{$ as ui,A as Z,B as Rr,Ba as Yi,C as Mr,D as $r,E as Or,Eb as Qi,F as Cr,G as Dr,Ga as zi,H as vr,Ha as St,Hb as _t,I as Ar,Ia as Ki,J as Xt,Jb as Zi,K as Ir,L as dt,M as Pr,N as Ur,O as Hr,P as Yr,Q as zr,R as Kr,S as Xr,T as Jr,V as en,W as ri,X as ii,Y as ai,Z as di,_ as ci,aa as mi,b as Q,ba as lt,c as Ht,ca as ut,da as fi,ea as mt,f as it,fa as pi,ga as gi,h as Pe,ha as hi,ia as bi,ja as ki,l as Yt,la as Ni,ma as Fi,na as Vi,o as or,oa as Bi,p as O,pa as V,qa as ji,sa as v,ta as Hi,ua as Oe,v as br,va as Ve,w as Ee,x as xr,y as kr,z as Sr}from"./chunk-JRLCGATA.js";import{$a as nr,$b as mr,$d as Nr,$i as an,Ah as Ne,Bd as Lr,Bh as ht,Ca as Kn,Cb as ar,Ch as Fe,Da as Xn,Dg as li,Ea as Jn,Eh as oe,Fa as Qn,Fc as hr,Ga as Ut,Gc as Te,Ge as Br,Gh as bt,Hb as Le,Hh as Me,Ih as Oi,Jc as ke,Jh as Ci,Ji as Wi,Kh as Di,Ki as Gi,Lh as vi,Li as Ui,Me as jr,Nc as st,Pb as sr,Pc as Er,Qa as ie,Qe as qr,Ra as Zn,Re as Wr,Ub as dr,Uc as _r,Ve as le,Vg as yi,Wb as lr,We as _e,Wh as Ai,Xb as ur,Xh as Ii,Zd as Jt,_a as tr,_d as Tr,_i as xt,a as Ze,ae as Qt,af as ct,ai as Pi,aj as sn,b as be,bc as ot,bh as U,bi as wi,c as ce,ca as qn,cg as Qr,ci as Li,cj as dn,d as jn,da as Wn,dg as Zr,dj as kt,ea as et,ec as fr,eh as Si,fa as Wt,gf as Gr,gg as ei,gh as pt,gj as Xi,ha as tt,hc as at,he as Fr,hh as gt,hi as Ti,hj as Rt,ib as rt,ig as Zt,ih as Ri,ij as Ji,jh as Ei,ji as qi,jj as Et,ka as Gn,ke as Vr,kh as _i,lg as ti,lh as nn,mg as ni,mh as Mi,mi as $e,ni as on,oc as xe,og as oi,pa as Un,pb as ir,pd as wr,qa as nt,rh as $i,sa as zn,tc as pr,tg as si,ub as we,wa as Gt,wc as gr,yc as yr,yh as yt,zh as rn}from"./chunk-GO4CS5KS.js";import{Ba as qt,Cb as Bn,Cc as Yn,Ed as ft,Ic as er,Sa as X,Uc as rr,V as jt,d as Ln,dd as xi,fa as Nn,g as Bt,h as Tn,ha as L,nb as J,s as fe,tb as Fn,ub as Vn,v as Je,xc as Hn,yd as tn,zb as Qe}from"./chunk-CGCGMO4U.js";import{A as pe,C as Kt,a as q,b as E,z as Y}from"./chunk-O7H2UX5K.js";import{b as zt,g as cr}from"./chunk-3LGLPG33.js";import{decodeXML as eo}from"entities";function to(e){return{kind:e.kind,feedbackEdges:la(e),actions:Ce(e),...e.body.kind==="gantt"?ua(e):{}}}function ca(e){const t=v(e);return t.ok?q(to(t.value)):E(t.error)}function la(e){let t=null;if(e.body.kind==="flowchart")t=e.body.graph;else if(e.body.kind==="state")t=mt(e.body);else if(e.kind==="flowchart"&&e.body.kind==="opaque"){try{t=ei(e.canonicalSource)}catch{t=null}}if(!t)return[];const n=Oi(t);return t.edges.flatMap((i,r)=>n[r]==="feedback"?[{edgeIndex:r,from:i.source,to:i.target,label:i.label,routeClass:"feedback"}]:[])}function ua(e){if(e.body.kind!=="gantt")return{};try{const t=ie(e.canonicalSource);const n=_e(le(t.lines),t.frontmatter);const i=$e(n);return i.analysis?{gantt:{criticalPathTaskIds:[...i.analysis.criticalPathTaskIds],slackByTaskId:{...i.analysis.slackByTaskId},projectStart:i.analysis.projectStart,projectEnd:i.analysis.projectEnd,entryTaskIds:[...i.analysis.entryTaskIds],sinkTaskIds:[...i.analysis.sinkTaskIds]}}:{}}catch{return{}}}function Ce(e){const t=e.body.kind==="opaque"||e.body.kind==="extension"||e.body.kind==="preserved"?e.body.source:e.canonicalSource;const n=[];if(e.kind==="flowchart")n.push(...fa(t));if(e.kind==="class")n.push(...ma(t));if(e.kind==="sequence")n.push(...pa(t));if(e.body.kind==="gantt")n.push(...ya(e));if(e.body.kind==="kanban"){const r=tr(e.meta.frontmatter);for(const o of e.body.columns)for(const a of o.tasks){const s=a.metadata.ticket;const d=typeof s==="string"?nr(r.ticketBaseUrl,s):void 0;if(d)n.push(H("kanban",a.id,"href",d,e.source.nodes.get(a.id)?.line,d))}}if(e.body.kind==="c4"){const r=e.body;for(const[o,a,s]of[[r.elements,e.source.nodes,"node"],[r.boundaries,e.source.groups,"group"],[r.relationships,e.source.edges,"edge"]])for(const d of o){const m=d.effectiveLink??d.link;if(m!==void 0)n.push({...H("c4",d.id,"href",m,a.get(d.id)?.line,m),regionId:`${s}:${d.id}`})}}const i=new Map;return n.map(r=>{const o=`${r.family}:${r.target}`;const a=i.get(o)??0;i.set(o,a+1);return{id:`action:${r.family}:${r.target}:${a}`,regionId:`node:${r.target}`,...r}})}function ma(e){const t=[];const n=new Map;let i=false;const r=e.split(/\r?\n/);const o=r.flatMap((a,s)=>Tr(a).map(d=>({text:d,line:s+1})));for(const a of cn(eo(e))){const s=o[a.line-1];const d=s?.line??a.line;const m=Jt(a.text);const u=Jt(s?.text.trim()??"");for(const[y,p]of m.entries()){if(i){if(p.trim()==="}")i=false;continue}const b=Nr(p);if(b?.opensBody){i=true;continue}const S=u.length===m.length&&eo(u[y])===p?u[y]:void 0;const _=S===void 0?null:Vr(S);if(_){if(_.tooltip!==void 0)n.set(_.id,_.tooltip);const D=n.get(_.id);t.push({...H("class",_.id,"href",_.href,d,_.href),...D!==void 0?{tooltip:D}:{}});continue}if(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/.test(p))continue;const P=p.match(/^(callback)\s+(`[^`]+`(?:~[^~]+~)?|[\w$]+(?:~[^~]+~)?)\s+(.+)$/i);if(P){const D=Qt(P[2]);if(D)t.push(H("class",D.id,"callback",P[3],d));continue}const G=p.match(/^(click|link)\s+(`[^`]+`(?:~[^~]+~)?|[\w$]+(?:~[^~]+~)?)\s+(.+)$/i);if(!G)continue;if((p.match(/"/g)?.length??0)%2!==0)continue;const M=Qt(G[2]);if(!M)continue;const w=G[3].trim();const k=w.match(/^(href|call|callback)\s+(.+)$/i);const C=k?.[1]?.toLowerCase();if(C==="call"||C==="callback"){t.push(H("class",M.id,C,k[2],d))}else{const D=C==="href"?k[2]:w;t.push(H("class",M.id,G[1].toLowerCase()==="link"||io(D)?"href":"callback",D,d))}}}return t}function fa(e){const t=[];const n=cn(e,true);for(const i of yr(n.map(r=>r.text))){const r={text:i.text,line:n[i.line].line};for(const o of Zt(r.text)){if(!o||o.startsWith("%%"))continue;let a=o.match(/^href\s+(\S+)\s+(.+)$/i);if(a){t.push(H("flowchart",a[1],"href",a[2],r.line));continue}a=o.match(/^click\s+(\S+)\s+(.+)$/i);if(!a)continue;const s=a[1];const d=a[2].trim();const m=d.match(/^(href|call)\s+(.+)$/i);const u=d.match(/^callback(?:\s+(.+))?$/i);if(m?.[1]?.toLowerCase()==="href")t.push(H("flowchart",s,"href",m[2],r.line));else if(m?.[1]?.toLowerCase()==="call")t.push(H("flowchart",s,"call",m[2],r.line));else if(u)t.push(H("flowchart",s,"callback",u[1]??"",r.line));else t.push(H("flowchart",s,io(d)?"href":"callback",d,r.line))}}return t}function cn(e,t=false){const n=e.split(/\r?\n/);const i=[];for(let o=0;o<n.length;o++){const a=nt(n,o);if(a===void 0)break;if(a===null)i.push({text:n[o].trim(),line:o+1});else{if(a.suffixLine)i.push({text:a.suffixLine.trim(),line:a.endIndex+1});o=a.endIndex}}if(!t)return i;let r=false;for(const o of i){const a=!r&&Zt(o.text).some(d=>/^(?:click|href)\s+/i.test(d.trim()));if(a)continue;const s=ga(o.text,r);r=s.open;o.text=s.text.trim()}return i}function pa(e){return cn(e).flatMap(t=>{const n=dr(t.text);return n?Object.values(n.links).map(i=>H("sequence",n.actorId,"href",i,t.line)):[]})}function ga(e,t){const n=t?'"`':"";const i=`${n}${e}`;const r=pr(i);const o=i.split("");for(const a of r.regions){if(a.kind==="markdown")o.fill(" ",a.start,a.end)}return{text:o.join("").slice(n.length),open:r.openAtEnd.includes("markdown")}}function ya(e){if(e.body.kind!=="gantt")return[];try{const t=le(tt(e.canonicalSource));return t.clicks.map(n=>H("gantt",n.taskId,n.action,n.rest,n.line))}catch{return[]}}function H(e,t,n,i,r,o){const a=n==="href"?o??no(i):void 0;const s=a!==void 0&&!ro(a);return{family:e,target:t,action:n,raw:i,line:r,href:a,executable:false,security:n==="href"?s?"unsafe":"safe":"source-only",message:n==="href"?s?"Unsafe href is source-only and must be stripped by strict renderers.":"Href is an action record; non-SVG renderers keep it as source-only metadata.":"Callbacks/calls are recorded for analysis but are never executed."}}function no(e){const t=e.trim();const n=t[0];if(n==='"'||n==="'"){let i="";for(let r=1;r<t.length;r++){const o=t[r];if(o===n)return i;if(o==="\\"&&r+1<t.length){const a=t[r+1];if(a===n||a==="\\"){i+=a;r++;continue}}i+=o}return i}return t.split(/\s+/)[0]??""}function ro(e){return er(e)}function io(e){const t=e.trim();const n=no(e);const i=t[0]==='"'||t[0]==="'";return i||ro(n)&&/^(?:https?:|mailto:|#|\/|\.\/|\.\.)/i.test(n)}var ln={version:1,routeIntent:"shared-route-classes",svgSource:"route-contract classifyRoutes() + certificates",asciiSource:"family terminal geometry with owned cells, route classes, markers and intentional bundles",degradationWarnings:["ASCII_RENDER_FAILED","ASCII_EDGE_REGION_UNMAPPED","TERMINAL_OWNERSHIP_UNAVAILABLE"]};function ha(e,t={}){const n=Oe(e);try{const{rendered:i,model:r}=Ki(n,t);const o=ki(i);const a=i.terminalStyle.diagnostics.map(u=>({code:u.code,severity:"degraded",message:u.message,...u.cell?{cell:u.cell}:{}}));if(!o)a.push({code:"TERMINAL_OWNERSHIP_UNAVAILABLE",severity:"degraded",message:"This family returns terminal text without owned geometry; element regions cannot be established from its string output."});const s=r.parsed();const d=o?.regions()??[];if(s.ok)for(const u of d){const y=u.kind==="node"?s.value.source.nodes.get(u.id):s.value.source.groups.get(u.id);if(u.sourceLine===void 0&&y)u.sourceLine=y.line}const m=s.ok?Ce(s.value).map(ba):[];return{ascii:i.text,regions:d,actions:m,warnings:a,routeParity:ln}}catch(i){if(i instanceof yt)throw i;return{ascii:"",regions:[],actions:[],warnings:[{code:"ASCII_RENDER_FAILED",severity:"degraded",message:"ASCII/Unicode renderer failed; no route parity evidence is available."}],routeParity:ln}}}function ba(e){const t=n=>n===void 0?void 0:Nn(n);return{...e,raw:t(e.raw),href:t(e.href),tooltip:t(e.tooltip),message:t(e.message)}}var xa=new Set(["\u250C","\u256D"]);var ka=new Set(["\u2510","\u256E"]);var Sa=new Set(["\u25BA","\u25B6",">"]);var Ra=new Set(["\u25C4","\u25C0","<"]);var Ea=new Set(["\u25BC","v"]);var _a=new Set(["\u25B2","^"]);function Ma(e){const t=[];let n=0;for(let i=0;i<e.length;i++){const r=e[i];for(let o=0;o<r.length;o++){const a=r[o];const s=xa.has(a)||a==="+"&&$a(e,o,i);if(!s)continue;const d=Oa(e,o,i);if(d){d.id=`N${n++}`;t.push(d)}}}return t}function $a(e,t,n){const i=e[n]?.[t+1];const r=e[n+1]?.[t];return i==="-"&&r==="|"}function Oa(e,t,n){const i=e[n];let r=-1;for(let s=t+1;s<i.length;s++){const d=i[s];if(ka.has(d)||d==="+"){r=s;break}if(d!=="\u2500"&&d!=="-")break}if(r<0)return null;let o=-1;for(let s=n+1;s<e.length;s++){const d=e[s]?.[t];if(d==="\u2514"||d==="\u2570"||d==="+"){o=s;break}if(d!=="\u2502"&&d!=="|")break}if(o<0)return null;const a=[];for(let s=n+1;s<o;s++){const d=(e[s]??"").slice(t+1,r).replace(/[│|]/g," ").trim();if(d)a.push(d)}return{id:"",label:a.join(" ").trim(),top:n,left:t,bottom:o,right:r}}function B(e,t,n,i=1){for(const r of e){if(t>=r.left-i&&t<=r.right+i&&n>=r.top-i&&n<=r.bottom+i)return r}return null}function Ca(e,t){const n=[];const i=new Set;for(let r=0;r<e.length;r++){const o=e[r];for(let a=0;a<o.length;a++){const s=o[a];let d=null;let m=null;if(Sa.has(s)){d=B(t,a+1,r);m=Da(e,t,a,r)}else if(Ra.has(s)){d=B(t,a-1,r);m=va(e,t,a,r)}else if(Ea.has(s)){d=B(t,a,r+1);m=Aa(e,t,a,r)}else if(_a.has(s)){d=B(t,a,r-1);m=Ia(e,t,a,r)}if(m&&d&&m.id!==d.id){const u=`${m.id}->${d.id}`;if(!i.has(u)){i.add(u);n.push([m.id,d.id])}}}}return n}var $t=new Set(["\u2500","-","\u252C","\u2534","\u253C","\u251C","\u2524","+"]);var Mt=new Set(["\u2502","|","\u252C","\u2534","\u253C","\u251C","\u2524","+"]);function Da(e,t,n,i){for(let r=n-1;r>=0;r--){const o=B(t,r,i);if(o)return o;if(!$t.has(e[i]?.[r]??"")){const a=B(t,r,i-1),s=B(t,r,i+1);return a??s??null}}return null}function va(e,t,n,i){for(let r=n+1;r<(e[i]?.length??0);r++){const o=B(t,r,i);if(o)return o;if(!$t.has(e[i]?.[r]??""))break}return null}function Aa(e,t,n,i){let r=n;for(let o=i-1;o>=0;o--){const a=B(t,r,o);if(a)return a;const s=e[o]?.[r]??"";const d="\u252C\u2534\u253C\u251C\u2524\u2510\u250C\u256E\u256D".includes(s);if(d&&!Mt.has(e[o-1]?.[r]??"")){const y=oo(e,r,o);if(y===null){const p=B(t,r-1,o),b=B(t,r+1,o);return p??b??null}r=y;continue}if(Mt.has(s))continue;if($t.has(s)){const y=oo(e,r,o);if(y!==null){r=y;continue}const p=B(t,r-1,o),b=B(t,r+1,o);return p??b??null}const m=B(t,r-1,o),u=B(t,r+1,o);return m??u??null}return null}function oo(e,t,n){const i=r=>e[n-1]?.[r]??"";for(let r=0;r<200;r++){for(const o of[t-r,t+r]){const a=e[n]?.[o]??"";if(!$t.has(a)&&!"\u2510\u250C\u256E\u256D".includes(a))continue;if(Mt.has(i(o)))return o}}return null}function Ia(e,t,n,i){for(let r=i+1;r<e.length;r++){const o=B(t,n,r);if(o)return o;if(!Mt.has(e[r]?.[n]??""))break}return null}function Pa(e){return/["[\]{}()]/.test(e)?`["${e.replace(/"/g,""")}"]`:`[${e}]`}function wa(e,t={}){if(!e.trim())return E([{code:"EMPTY",message:"empty ASCII input"}]);const n=e.replace(/\[[0-9;]*m/g,"").split(/\r?\n/);const i=Ma(n);if(i.length===0)return E([{code:"NO_BOXES",message:"no boxes detected in ASCII; not a recognized flowchart render"}]);const r=Ca(n,i);const o=t.direction??"LR";const a=[`flowchart ${o}`];for(const s of i)a.push(` ${s.id}${Pa(s.label||s.id)}`);for(const[s,d]of r)a.push(` ${s} --> ${d}`);return q(a.join("\n"))}var Be;function La(){if(Be!==void 0)return Be;Be=null;try{const e=globalThis.process;const t=e?.getBuiltinModule?.("node:fs");if(typeof t?.appendFileSync==="function")Be=t.appendFileSync}catch{}return Be}function ae(e,t){const n=globalThis.process?.env?.AM_TRACE_LOG;if(!n)return;const i=t===void 0?{verb:e}:{verb:e,ok:t};try{La()?.(n,JSON.stringify(i)+"\n")}catch{}}var ue=(e=true)=>({type:"string",required:e});var un=()=>({type:"number",required:false});var mn=()=>({type:"object-or-null",required:true});var ao={upsert_participant:{fields:{participant:mn(),index:un()}},remove_participant:{fields:{id:ue()}},rename_participant:{fields:{id:ue(),newId:ue()}},insert_statement:{fields:{statement:mn(),parentId:ue(false),branchIndex:un(),index:un()}},remove_statement:{fields:{id:ue()}},set_statement:{fields:{id:ue(),statement:mn()}},set_title:{fields:{title:ue(false)}},set_accessibility_title:{fields:{title:ue(false)}},set_accessibility_description:{fields:{description:ue(false)}}};var Se=(e=true)=>({type:"string",required:e});var so=(e=true)=>({type:"number",required:e});var fn=()=>({type:"object-or-null",required:true});var co={insert_frame:{fields:{frame:fn(),index:so(false)}},remove_frame:{fields:{id:Se()}},move_frame:{fields:{id:Se(),index:so()}},set_frame:{fields:{id:Se(),frame:fn()}},set_entities:{fields:{entities:{type:"string-array",required:true}}},set_notes:{fields:{notes:{type:"object-array",required:true}}},set_specifications:{fields:{specifications:{type:"object-array",required:true}}},set_data:{fields:{id:Se(),data:fn()}},set_title:{fields:{title:Se(false)}},set_accessibility_title:{fields:{title:Se(false)}},set_accessibility_description:{fields:{description:Se(false)}}};var I=(e=true)=>({type:"string",required:e});var Ot=(e=true)=>({type:"number",required:e});var pn={add_column:{fields:{id:I(),label:I(),index:Ot(false)}},remove_column:{fields:{id:I(),removeTasks:{type:"boolean",required:false}}},set_column_label:{fields:{id:I(),label:I()}},move_column:{fields:{id:I(),index:Ot()}},add_task:{fields:{column:I(),id:I(),label:I(),metadata:{type:"object-or-null",required:false},index:Ot(false)}},remove_task:{fields:{id:I()}},set_task_label:{fields:{id:I(),label:I()}},set_task_metadata:{fields:{id:I(),metadata:{type:"object-or-null",required:true}}},move_task:{fields:{id:I(),column:I(),index:Ot(false)}},set_icon:{fields:{id:I(),icon:I(false)}},set_class:{fields:{id:I(),className:I(false)}},set_accessibility_title:{fields:{title:I(false)}},set_accessibility_description:{fields:{description:I(false)}}};var ml=Object.keys(pn);var je=(e=true)=>({type:"string",required:e});var ge=(e=true)=>({type:"number",required:e});var gn={set_title:{fields:{title:je(false)}},set_accessibility_title:{fields:{title:je(false)}},set_accessibility_description:{fields:{description:je(false)}},add_field:{fields:{label:je(),bits:ge(),index:ge(false)}},remove_field:{fields:{index:ge()}},set_field_label:{fields:{index:ge(),label:je()}},set_field_bits:{fields:{index:ge(),bits:ge()}},move_field:{fields:{from:ge(),to:ge()}}};var pl=Object.keys(gn);var lo=["rectangle","service","rounded","diamond","stadium","circle","ellipse","subroutine","doublecircle","hexagon","cylinder","asymmetric","trapezoid","trapezoid-alt","lean-r","lean-l","state-start","state-end"];var Ta=["solid","dotted","thick","invisible"];var uo=["sync","reply","async","async-dashed","lost","lost-dashed"];var Na=["participant","actor"];var Fa=["alt","opt","loop","par","par_over"];var yn=["inheritance","composition","aggregation","association","dependency","realization","link-solid","link-dashed","lollipop"];var mo=["one-only","zero-or-one","zero-or-many","one-or-many","parent"];var Ct=["L","R","T","B"];var Dt=["item","group"];var Va=["bar","line"];var Ba=["x","y"];var ja=["active","done","crit"];var fo=["default","rect","rounded","circle","cloud","bang","hexagon"];var hn=["NORMAL","REVERSE","HIGHLIGHT"];var qa=["circle","polygon"];var l=(e=true)=>({type:"string",required:e});var g=(e=true)=>({type:"number",required:e});var F=(e=true)=>({type:"boolean",required:e});var bn=(e=true)=>({type:"number-or-null",required:e});var xn=(e=true)=>({type:"boolean-or-null",required:e});var x=(e=true)=>({type:"string-or-null",required:e});var z=(e=true)=>({type:"string-array",required:e});var vt=(e=true)=>({type:"number-array",required:e});var ye=(e=true)=>({type:"object-or-null",required:e});var po=(e=true)=>({type:"object-array",required:e});var R=(e,t=true,n=false)=>({type:"enum",values:e,nullable:n,required:t});var h=(e,t)=>({...e,note:t});var go=[...lo,...Zr().filter(e=>!lo.includes(e))];var Wa=["TD","TB","LR","BT","RL"];var Ga={add_node:{fields:{id:l(),label:l(),shape:h(R(go,false),"default: rectangle; also accepts Mermaid v11 @{ shape } names/aliases (e.g. manual-input)"),parent:l(false)}},remove_node:{fields:{id:l()}},rename_node:{fields:{from:l(),to:l()}},set_label:{fields:{target:h(l(),'a node id, an authored edge ID (e1), or "from->to"/"from->to#k"; an id a node and an edge share names the node'),label:l()}},add_edge:{fields:{from:l(),to:l(),label:l(false),style:h(R(Ta,false),"default: solid")}},remove_edge:{fields:{id:h(l(),'an authored edge ID (e1), or "from->to"/"from->to#k" for the k-th parallel edge')}},set_shape:{fields:{id:l(),shape:h(R(go),"a geometry name or a Mermaid v11 @{ shape } name/alias; v11 names render with the documented geometry mapping and serialize with the authored spelling")}},set_direction:{fields:{direction:R(Wa),subgraph:h(l(false),"omit to set the diagram direction; a subgraph id sets that subgraph's direction override")}},add_subgraph:{fields:{id:l(),label:l(false),parent:h(l(false),"nest inside this subgraph"),members:h(z(false),"existing node ids MOVED into the new subgraph")}},remove_subgraph:{fields:{id:l(),removeMembers:h(F(false),"default false: dissolve \u2014 members move to the parent scope; true also removes member nodes and their edges")}},move_node:{fields:{id:l(),subgraph:h(x(),"target subgraph id; null moves the node to the top level")}},define_class:{fields:{name:l(),style:h(l(),'CSS-like pairs, e.g. "fill:#f96,stroke:#333,stroke-width:2px"')}},set_node_class:{fields:{id:l(),className:h(x(),"assigns a classDef name (define_class or source classDef); null removes the assignment")}},set_node_style:{fields:{id:l(),style:h(x(),'inline style pairs, e.g. "fill:#bbf"; null clears')}}};var yo=["TD","TB","LR","BT","RL"];var Ua=["left","right"];var Ha={add_state:{fields:{id:l(),label:x(false),parent:x(false),region:g(false)}},remove_state:{fields:{id:l(),recursive:h(F(false),"default false: refuse a non-empty composite; true removes the whole subtree (transitions + notes cascade)")}},rename_state:{fields:{from:l(),to:l()}},set_state_label:{fields:{id:l(),label:x()}},add_transition:{fields:{from:h(l(),'a state id, "[*]", or a history ref like "X[H]"'),to:h(l(),'a state id, "[*]", or a history ref like "X[H]"'),label:x(false),parent:x(false),region:g(false)}},remove_transition:{fields:{index:g(false),from:l(false),to:l(false),parent:x(false),region:g(false)},requireOneOf:["index","from","to"]},set_transition_label:{fields:{index:g(false),from:l(false),to:l(false),label:x(),parent:x(false),region:g(false)},requireOneOf:["index","from","to"]},make_composite:{fields:{id:l(),members:z(),label:x(false)}},set_direction:{fields:{direction:R(yo),state:h(x(false),"omit to set the diagram direction; a composite id sets that composite's direction override")}},move_state:{fields:{id:l(),parent:h(x(),"target composite id; null moves the state to the top level"),region:g(false)}},dissolve_composite:{fields:{id:h(l(),"children and inner transitions hoist into the parent scope; rejects while transitions/notes still reference the composite")}},add_note:{fields:{target:l(),side:h(R(Ua,false),"default: right"),text:h(l(),"multi-line text serializes as a block note")}},remove_note:{fields:{index:g()}},set_note_text:{fields:{index:g(),text:l()}},add_floating_note:{fields:{id:l(),text:l(),parent:x(false),region:g(false)}},remove_floating_note:{fields:{id:l()}},set_floating_note_text:{fields:{id:l(),text:l()}},define_class:{fields:{name:l(),style:h(l(),'CSS-like pairs, e.g. "fill:#f96,stroke:#333"')}},set_state_class:{fields:{id:l(),className:x()}},set_state_style:{fields:{id:l(),style:h(x(),"inline style pairs; null clears")}},set_transition_style:{fields:{index:g(false),default:F(false),style:x(),parent:x(false),region:g(false)},requireOneOf:["index","default"]}};var Ya={add_participant:{fields:{id:l(),label:l(false),participantKind:R(Na,false)}},remove_participant:{fields:{id:l()}},add_message:{fields:{from:l(),to:l(),text:l(),wrap:F(false),style:h(R(uo,false),"default: sync"),index:h(g(false),"top-level insert position; default: append")}},remove_message:{fields:{index:g()}},set_message_text:{fields:{index:g(),text:l()}},set_message_wrap:{fields:{index:g(),wrap:h(xn(),"null inherits the diagram configuration")}},move_message:{fields:{from:h(g(),"top-level message index"),to:h(g(),"top-level target position")}},set_participant_label:{fields:{id:l(),label:l()}},add_fragment:{fields:{fragmentKind:R(Fa),label:l(false),index:h(g(false),"fragment insert position; default: append")}},remove_fragment:{fields:{index:g()}},set_fragment_label:{fields:{index:g(),label:x()}},add_fragment_branch:{fields:{fragmentIndex:g(),label:l(false)}},set_fragment_branch_label:{fields:{fragmentIndex:g(),branchIndex:g(),label:x()}},add_fragment_message:{fields:{fragmentIndex:g(),branchIndex:h(g(false),"default: 0"),from:l(),to:l(),text:l(),wrap:F(false),style:h(R(uo,false),"default: sync"),index:h(g(false),"message insert position; default: append")}},remove_fragment_message:{fields:{fragmentIndex:g(),branchIndex:h(g(false),"default: 0"),index:g()}},set_fragment_message_text:{fields:{fragmentIndex:g(),branchIndex:h(g(false),"default: 0"),index:g(),text:l()}},set_fragment_message_wrap:{fields:{fragmentIndex:g(),branchIndex:h(g(false),"default: 0"),index:g(),wrap:h(xn(),"null inherits the diagram configuration")}}};var za={set_title:{fields:{title:x()}},add_section:{fields:{label:l(),index:h(g(false),"insert position; omit to append")}},remove_section:{fields:{index:g()}},set_section_label:{fields:{index:g(),label:l()}},add_period:{fields:{sectionIndex:g(),label:l(),events:z(false),index:h(g(false),"insert position; omit to append")}},remove_period:{fields:{sectionIndex:g(),periodIndex:g()}},set_period_label:{fields:{sectionIndex:g(),periodIndex:g(),label:l()}},add_event:{fields:{sectionIndex:g(),periodIndex:g(),text:l(),index:h(g(false),"insert position; omit to append")}},remove_event:{fields:{sectionIndex:g(),periodIndex:g(),eventIndex:g()}},set_event_text:{fields:{sectionIndex:g(),periodIndex:g(),eventIndex:g(),text:l()}},move_period:{fields:{fromSection:g(),fromIndex:g(),toSection:g(),toIndex:h(g(),"insert position in the target section, applied after removal")}},move_event:{fields:{fromSection:g(),fromPeriod:g(),fromIndex:g(),toSection:g(),toPeriod:g(),toIndex:h(g(),"insert position in the target period, applied after removal")}},move_section:{fields:{from:g(),to:g()}},set_accessibility_title:{fields:{title:x()}},set_accessibility_description:{fields:{description:x()}}};var Ka={set_title:{fields:{title:x()}},add_class:{fields:{id:l(),label:l(false),generic:h(l(false),"Mermaid generic parameter text without surrounding ~ delimiters"),members:z(false),namespace:h(l(false),'dot path, e.g. "Platform.Auth"; declared on demand')}},remove_class:{fields:{id:l()}},rename_class:{fields:{from:l(),to:l()}},set_class_generic:{fields:{class:l(),generic:h(x(),"parameter text without ~ delimiters; null removes it")}},add_member:{fields:{class:l(),text:l()}},remove_member:{fields:{class:l(),index:g()}},add_interface:{fields:{class:h(l(),"existing ordinary class; the interface is a new distinct occurrence"),label:h(l(),"non-empty portable interface endpoint name; repeated labels remain independent"),side:h(R(["from","to"],false),"default: to \u2014 Class --() Interface; from writes Interface ()-- Class"),relationLabel:h(l(false),"optional connector label, separate from the interface name"),lineStyle:h(R(["solid","dashed"],false),"default: solid")}},add_relation:{fields:{from:l(),to:l(),relKind:h(R(yn),"class endpoint relationship; use add_interface for a lone lollipop, which creates a distinct interface occurrence"),label:l(false),markerAt:h(R(["from","to","both","none"],false),"marker endpoints; omit for the relation kind default"),fromKind:R(yn,false),toKind:R(yn,false),lineStyle:h(R(["solid","dashed"],false),"independent shaft style; must agree with style-specific endpoint kinds")}},remove_relation:{fields:{index:g()}},add_note:{fields:{text:l(),for:l(false)}},remove_note:{fields:{index:g()}},set_class_namespace:{fields:{class:l(),namespace:h(x(),"dot path moves the class into that namespace (declared on demand); null moves it to the top level")}},define_class:{fields:{name:l(),style:h(l(),'CSS-like pairs, e.g. "fill:#f96,stroke:#333"')}},set_css_class:{fields:{class:l(),className:x()}},set_class_style:{fields:{class:l(),style:x()}}};var Xa={add_entity:{fields:{id:l(),label:l(false),attributes:z(false)}},remove_entity:{fields:{id:l()}},rename_entity:{fields:{from:l(),to:l()}},set_entity_label:{fields:{entity:l(),label:x()}},add_attribute:{fields:{entity:l(),text:l()}},remove_attribute:{fields:{entity:l(),index:g()}},add_relation:{fields:{from:l(),to:l(),leftCard:R(mo),rightCard:R(mo.filter(e=>e!=="parent")),dashed:F(false),label:l(false)}},remove_relation:{fields:{index:g()}},set_direction:{fields:{direction:R(yo)}},define_class:{fields:{name:l(),style:l()}},set_entity_class:{fields:{entity:l(),className:x()}},set_entity_style:{fields:{entity:l(),style:x()}}};var Ja={set_title:{fields:{title:x()}},add_section:{fields:{label:l(),index:h(g(false),"insert position; omit to append")}},remove_section:{fields:{index:g()}},set_section_label:{fields:{index:g(),label:l()}},add_task:{fields:{sectionIndex:g(),text:l(),score:h(g(),"finite number 1..5"),actors:z(false),index:h(g(false),"insert position; omit to append")}},remove_task:{fields:{sectionIndex:g(),taskIndex:g()}},set_task_text:{fields:{sectionIndex:g(),taskIndex:g(),text:l()}},set_task_score:{fields:{sectionIndex:g(),taskIndex:g(),score:h(g(),"finite number 1..5")}},set_task_actors:{fields:{sectionIndex:g(),taskIndex:g(),actors:z()}},rename_actor:{fields:{from:l(),to:l()}},move_task:{fields:{fromSection:g(),fromIndex:g(),toSection:g(),toIndex:h(g(),"insert position in the target section, applied after removal")}},move_section:{fields:{from:g(),to:g()}},set_accessibility_title:{fields:{title:x()}},set_accessibility_description:{fields:{description:x()}}};var Qa={set_title:{fields:{title:x()}},set_accessibility_title:{fields:{title:x()}},set_accessibility_description:{fields:{description:x()}},add_service:{fields:{id:l(),label:l(false),icon:x(false),iconText:x(false),group:x(false)}},remove_service:{fields:{id:l()}},rename_service:{fields:{from:l(),to:l()}},set_service_label:{fields:{id:l(),label:l()}},set_service_icon:{fields:{id:l(),icon:x()}},set_service_icon_text:{fields:{id:l(),text:x()}},move_service:{fields:{id:l(),group:x()}},add_junction:{fields:{id:l(),group:x(false)}},remove_junction:{fields:{id:l()}},rename_junction:{fields:{from:l(),to:l()}},move_junction:{fields:{id:l(),group:x()}},add_group:{fields:{id:l(),label:l(false),icon:x(false),parent:x(false)}},set_group_label:{fields:{id:l(),label:l()}},remove_group:{fields:{id:l()}},add_edge:{fields:{from:l(),to:l(),fromSide:R(Ct),toSide:R(Ct),fromBoundary:R(Dt,false),toBoundary:R(Dt,false),label:x(false),hasArrowStart:F(false),hasArrowEnd:F(false)}},update_edge:{fields:{index:g(),from:l(false),to:l(false),fromSide:R(Ct,false),toSide:R(Ct,false),fromBoundary:R(Dt,false),toBoundary:R(Dt,false),label:x(false),hasArrowStart:F(false),hasArrowEnd:F(false)}},remove_edge:{fields:{index:g(false),id:l(false)},requireOneOf:["index","id"]}};var Za={set_title:{fields:{title:x()}},set_x_axis:{fields:{axis:ye()}},set_y_axis:{fields:{axis:ye()}},add_series:{fields:{kind2:h(R(Va),"series type \u2014 the field is named kind2, not kind"),name:x(false),values:vt()}},remove_series:{fields:{index:g()}},set_series_values:{fields:{index:g(),values:vt()}},set_series_name:{fields:{index:g(),name:x()}},reorder_series:{fields:{from:g(),to:g()}},set_orientation:{fields:{horizontal:h(F(),"true = horizontal, false = vertical (the default)")}},set_data_point:{fields:{seriesIndex:g(),index:h(g(),"0-based position within the series values"),value:h(g(),"finite")}}};var es={set_title:{fields:{title:x()}},set_show_data:{fields:{showData:F()}},add_slice:{fields:{label:l(),value:h(g(),"> 0, finite")}},remove_slice:{fields:{label:l()}},rename_slice:{fields:{from:l(),to:l()}},set_slice_value:{fields:{label:l(),value:h(g(),"> 0, finite")}},reorder_slice:{fields:{from:g(),to:g()}}};var ts={set_title:{fields:{title:x()}},set_axis_labels:{fields:{axis:R(Ba),near:x(),far:x(false)}},set_quadrant_label:{fields:{quadrant:g(),label:x()}},add_point:{fields:{label:l(),x:h(g(),"0..1"),y:h(g(),"0..1")}},remove_point:{fields:{label:l()}},move_point:{fields:{label:l(),x:h(g(),"0..1"),y:h(g(),"0..1")}},rename_point:{fields:{from:l(),to:l()}}};var ns={set_title:{fields:{title:x()}},add_section:{fields:{label:l()}},rename_section:{fields:{index:g(),label:l()}},remove_section:{fields:{index:g()}},add_task:{fields:{sectionIndex:g(),label:l(),taskId:l(false),tags:z(false),start:h(l(false),'date, or "after <taskId>"'),end:h(l(),'date, a duration like "3d", or "until <taskId>"'),index:h(g(false),"insert position; omit to append \u2014 inserting into an implicit-start chain re-chains the follower onto the new task")}},remove_task:{fields:{sectionIndex:g(),taskIndex:g()}},rename_task:{fields:{sectionIndex:g(),taskIndex:g(),label:l()}},set_task_status:{fields:{sectionIndex:g(),taskIndex:g(),status:R(ja,true,true)}},set_task_dates:{fields:{sectionIndex:g(),taskIndex:g(),start:x(false),end:l(false)}},set_task_flags:{fields:{sectionIndex:g(),taskIndex:g(),milestone:F(false),vert:F(false)}},set_task_id:{fields:{sectionIndex:g(),taskIndex:g(),taskId:h(x(),"renames rewrite after/until references; null clears (rejected while referenced)")}},move_task:{fields:{fromSection:g(),fromIndex:g(),toSection:g(),toIndex:h(g(),"insert position in the target section, applied after removal \u2014 rejected if the move would change an implicit-start task's predecessor")}},move_section:{fields:{from:g(),to:g()}}};var rs={add_node:{fields:{id:l(),label:l(),parent:l(),shape:R(fo,false),index:g(false)}},remove_node:{fields:{id:l(),recursive:F(false)}},rename_node:{fields:{from:l(),to:l()}},set_label:{fields:{id:l(),label:l()}},move_node:{fields:{id:l(),parent:l(),index:g(false)}},set_shape:{fields:{id:l(),shape:R(fo)}},set_icon:{fields:{id:l(),icon:x()}},set_node_class:{fields:{id:l(),className:x()}},set_accessibility_title:{fields:{title:x()}},set_accessibility_description:{fields:{description:x()}}};var is={append_commit:{fields:{id:l(false),message:l(false),type:R(hn,false),tags:z(false)}},create_branch:{fields:{name:l(),order:g(false)}},checkout_branch:{fields:{name:l()}},merge_branch:{fields:{name:l(),id:l(false),type:R(hn,false),tags:z(false)}},cherry_pick:{fields:{id:l(),parent:l(false),tags:z(false)}},set_commit_message:{fields:{id:l(),message:x()}},set_commit_type:{fields:{id:l(),type:R(hn)}},set_commit_tags:{fields:{id:l(),tags:z()}},rename_branch:{fields:{from:l(),to:l()}},set_accessibility_title:{fields:{title:x()}},set_accessibility_description:{fields:{description:x()}}};var os={set_title:{fields:{title:x()}},add_axis:{fields:{id:l(),label:x(false),index:h(g(false),"insert position; omit to append"),fill:h(g(false),"value written to every existing curve for the new axis; default: min")}},remove_axis:{fields:{id:l()}},rename_axis:{fields:{from:l(),to:l()}},set_axis_label:{fields:{id:l(),label:x()}},reorder_axis:{fields:{from:g(),to:h(g(),"permutes every curve's value vector identically")}},add_curve:{fields:{id:l(),label:x(false),values:h(vt(),"one value per axis, in axis order"),index:g(false)}},remove_curve:{fields:{id:l()}},set_curve_values:{fields:{id:l(),values:h(vt(),"length must equal the axis count")}},set_curve_value:{fields:{curve:l(),axis:l(),value:h(g(),"non-negative, finite")}},set_curve_label:{fields:{id:l(),label:x()}},rename_curve:{fields:{from:l(),to:l()}},reorder_curve:{fields:{from:g(),to:g()}},set_config:{fields:{max:h(bn(false),"> min; null resets auto-max"),min:h(bn(false),"null resets 0"),ticks:h(bn(false),`integer 1..${li}; null resets 5`),graticule:R(qa,false,true),showLegend:h(xn(false),"null resets true")}}};var as={add_link:{fields:{source:l(),target:l(),value:h(g(),"non-negative, finite"),index:h(g(false),"insert position; omit to append")}},remove_link:{fields:{source:l(),target:l(),occurrence:h(g(false),"disambiguates parallel duplicate rows; default 0")}},set_link_value:{fields:{source:l(),target:l(),value:h(g(),"non-negative, finite"),occurrence:g(false)}},rename_node:{fields:{from:l(),to:h(l(),"rejects an existing label \u2014 renaming must not merge nodes")}}};var ss={add_element:{fields:{element:h(ye(),"required record: id, label; optional macro, kind (person/system/container/component), shape (person/rectangle/database/queue), external, technology, description, parentId, tags, link, sprite; null is refused")}},update_element:{fields:{id:l(),changes:h(ye(),"element fields to change; use rename_element/reparent_element for identity or containment")}},rename_element:{fields:{from:l(),to:l()}},reparent_element:{fields:{id:l(),parentId:x()}},remove_element:{fields:{id:l(),cascade:h(F(false),"default false: refuse referenced elements; true also removes referencing relationships")}},add_boundary:{fields:{boundary:h(ye(),"required record: id, label; optional macro, kind (boundary/enterprise/system/container/deployment), type, description, parentId, tags, link, sprite; null is refused")}},update_boundary:{fields:{id:l(),changes:ye()}},rename_boundary:{fields:{from:l(),to:l()}},reparent_boundary:{fields:{id:l(),parentId:x()}},remove_boundary:{fields:{id:l(),cascade:h(F(false),"default false: refuse nonempty/referenced boundaries; true removes subtree and referencing relationships")}},add_relationship:{fields:{relationship:h(ye(),"required record: from, to, label; optional macro (Rel/BiRel/Rel_Back/Rel_U/Rel_D/Rel_L/Rel_R/RelIndex), technology, description, index, tags, link, sprite; parallel relationships remain distinct")}},update_relationship:{fields:{id:l(),changes:h(ye(),"relationship fields to change, addressed by the unique interaction id, not an endpoint pair")}},remove_relationship:{fields:{id:l()}},set_title:{fields:{title:x()}},set_variant:{fields:{variant:R(["C4Context","C4Container","C4Component","C4Dynamic","C4Deployment"])}},add_directive:{fields:{name:h(l(),"portable Mermaid UpdateElementStyle, UpdateRelStyle or UpdateLayoutConfig"),args:h(po(),"ordered records {value:string,name?:string}; named arguments omit the $ prefix")}},update_directive:{fields:{id:l(),args:po()}},remove_directive:{fields:{id:l()}}};var he={zenuml:ao,eventmodeling:co,flowchart:Ga,state:Ha,sequence:Ya,timeline:za,class:Ka,er:Xa,journey:Ja,architecture:Qa,xychart:Za,pie:es,quadrant:ts,gantt:ns,mindmap:rs,gitgraph:is,radar:os,sankey:as,c4:ss,packet:gn,kanban:pn,requirement:Dr,treemap:Ar,ishikawa:Or,block:Mr};function ee(e){return Object.hasOwn(he,e)}function ds(e,t){const n=e.length,i=t.length;const r=Array.from({length:n+1},(o,a)=>[a,...Array(i).fill(0)]);for(let o=0;o<=i;o++)r[0][o]=o;for(let o=1;o<=n;o++)for(let a=1;a<=i;a++)r[o][a]=Math.min(r[o-1][a]+1,r[o][a-1]+1,r[o-1][a-1]+(e[o-1]===t[a-1]?0:1));return r[n][i]}function ho(e,t){let n;let i=Infinity;for(const r of t){const o=ds(e.toLowerCase(),r.toLowerCase());if(o<i){i=o;n=r}}return n!==void 0&&i<=Math.max(2,Math.ceil(n.length*.4))?n:void 0}function kn(e){switch(e.type){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"number-or-null":return"number | null";case"boolean-or-null":return"boolean | null";case"string-or-null":return"string | null";case"string-array":return"string[]";case"number-array":return"number[]";case"object-array":return"object[]";case"object-or-null":return"object | null";case"enum":return`one of ${e.values.map(t=>JSON.stringify(t)).join(", ")}${e.nullable?" | null":""}`}}function cs(e,t){switch(e.type){case"string":return typeof t==="string";case"number":return typeof t==="number"&&Number.isFinite(t);case"boolean":return typeof t==="boolean";case"number-or-null":return t===null||typeof t==="number"&&Number.isFinite(t);case"boolean-or-null":return t===null||typeof t==="boolean";case"string-or-null":return t===null||typeof t==="string";case"string-array":return Array.isArray(t)&&t.every(n=>typeof n==="string");case"number-array":return Array.isArray(t)&&t.every(n=>typeof n==="number"&&Number.isFinite(n));case"object-array":return Array.isArray(t)&&t.every(n=>n!==null&&typeof n==="object"&&!Array.isArray(n));case"object-or-null":return t===null||typeof t==="object"&&!Array.isArray(t);case"enum":return e.nullable===true&&t===null||typeof t==="string"&&e.values.includes(t)}}function At(e){const t=new Set;const n=i=>{if(i===null||i===void 0||typeof i==="string"||typeof i==="boolean"||typeof i==="number")return i;if(typeof i!=="object")throw new TypeError("operation values must be plain JSON data");if(t.has(i))throw new TypeError("operation data must not contain cycles");t.add(i);try{if(Array.isArray(i)){const s=Object.getPrototypeOf(i);if(s!==Array.prototype)throw new TypeError("operation arrays must use the standard array prototype");const d=Object.getOwnPropertyDescriptors(i);const m=d.length?.value;if(!Number.isSafeInteger(m)||m<0)throw new TypeError("operation arrays must have a readable length");const u=Reflect.ownKeys(i);if(u.some(p=>typeof p==="symbol"||p!=="length"&&!/^(0|[1-9]\d*)$/.test(p))){throw new TypeError("operation arrays must not carry symbols or named properties")}const y=[];for(let p=0;p<m;p++){const b=d[String(p)];if(!b||!("value"in b)||b.enumerable!==true){throw new TypeError("operation arrays must be dense own-data arrays")}y.push(n(b.value))}return y}const r=Object.getPrototypeOf(i);if(r!==Object.prototype&&r!==null){throw new TypeError("operation records must be plain objects")}const o=Object.getOwnPropertyDescriptors(i);const a=Object.create(null);for(const s of Reflect.ownKeys(i)){if(typeof s==="symbol")throw new TypeError("operation records must not carry symbol keys");const d=o[s];if(!d||!("value"in d)||d.enumerable!==true){throw new TypeError("operation records must contain enumerable own data fields")}a[s]=n(d.value)}return a}finally{t.delete(i)}};try{return{ok:true,value:n(e)}}catch{return{ok:false,message:"operation must be a plain own-data JSON object"}}}function bo(e,t){return{code:"INVALID_OP",reason:"unreadable_op",family:e,message:t,validFields:Object.keys(he[e])}}function ls(e,t){const n=he[e];if(Array.isArray(t)){return{code:"INVALID_OP",reason:"expected_single_op",family:e,message:at(e,t),validFields:Object.keys(n)}}if(!t||typeof t!=="object"){return{code:"INVALID_OP",reason:"unknown_kind",family:e,message:at(e,t),validFields:Object.keys(n)}}const i=t;const r=i.kind;if(typeof r!=="string"||!Object.hasOwn(n,r)){const s=Object.keys(n);const d=typeof r==="string"?ho(r,s):void 0;return{code:"INVALID_OP",reason:"unknown_kind",family:e,opKind:typeof r==="string"?r:void 0,message:`${at(e,t)}${d?` Did you mean "${d}"?`:""}`,validFields:s,didYouMean:d}}const o=n[r];const a=Object.keys(o.fields);for(const s of Object.keys(i)){if(s==="kind")continue;if(!Object.hasOwn(o.fields,s)){const d=ho(s,a);return{code:"INVALID_OP",reason:"unknown_field",family:e,opKind:r,field:s,message:`Unknown field "${s}" for ${e} op "${r}".${d?` Did you mean "${d}"?`:""} Valid fields: ${a.join(", ")}.`,validFields:a,didYouMean:d}}}for(const[s,d]of Object.entries(o.fields)){if(!d.required)continue;if(i[s]===void 0){return{code:"INVALID_OP",reason:"missing_field",family:e,opKind:r,field:s,message:`Missing required field "${s}" (${kn(d)}) for ${e} op "${r}". Fields: ${a.join(", ")}.`,validFields:a}}}if(o.requireOneOf&&!o.requireOneOf.some(s=>i[s]!==void 0)){return{code:"INVALID_OP",reason:"require_one_of",family:e,opKind:r,message:`${e} op "${r}" requires at least one of: ${o.requireOneOf.join(", ")}.`,validFields:a}}for(const[s,d]of Object.entries(o.fields)){if(i[s]===void 0)continue;if(!cs(d,i[s])){return{code:"INVALID_OP",reason:"wrong_type",family:e,opKind:r,field:s,message:`Field "${s}" of ${e} op "${r}" must be ${kn(d)}, got ${JSON.stringify(i[s])}.`,validFields:a}}}return null}function It(e,t){const n=At(t);if(!n.ok)return bo(e,n.message);try{return ls(e,n.value)}catch{return bo(e,"operation could not be validated as plain JSON data")}}function xo(e){if(!ee(e)){throw new RangeError(`family must be one of: ${Object.keys(he).join(", ")}`)}const t={};for(const[n,i]of Object.entries(he[e])){t[n]=Object.entries(i.fields).map(([r,o])=>o.required?r:`${r}?`)}return t}function us(e){if(!ee(e)){throw new RangeError(`family must be one of: ${Object.keys(he).join(", ")}`)}const t={};for(const[n,i]of Object.entries(he[e])){t[n]=Object.entries(i.fields).map(([r,o])=>({name:r,required:o.required,type:kn(o),...o.note!==void 0?{note:o.note}:{}}))}return t}function ms(e){const t=xo(e);return Object.entries(t).map(([n,i])=>`${n}(${i.join(", ")})`)}function ps(e,t){const n=Sn(e,t);ae("mutate",n.ok);return n}function Sn(e,t,n=false,i){if(e.body.kind==="preserved"){return E({code:e.body.diagnostic.code==="UNKNOWN_HEADER"?"UNKNOWN_HEADER":"UNSUPPORTED_FAMILY",message:`${e.body.diagnostic.message}; the exact source remains preserved and cannot accept structured mutation`})}if(e.body.kind==="extension"){return E({code:"INVALID_OP",message:`Registered external family "${e.kind}" has no typed mutation contract in FamilyDescriptor v2`})}const r=O(e.kind);if(r?.mutate&&r.serialize){if(i&&(i.mutator!==r.mutate||i.body!==e.body)){i.mutator=r.mutate;i.body=e.body;i.apply=bi(r.mutate,e.body)}const o=i?.apply?Ni(e):e;const a=i?.apply?i.apply(t):r.mutate(e.body,t);if(!a.ok)return a;try{a.value=mr(a.value)}catch(s){if(!(s instanceof lr))throw s;return E({code:"INVALID_OP",message:s.message})}if(i)i.body=a.value;e=Fi(o,a.value,t);return n?q({...e,body:a.value}):ko(e,a.value)}return E({code:"INVALID_OP",message:`Unsupported mutable diagram kind: ${e.kind}`})}function ko(e,t){if(t.kind==="preserved"||t.kind==="extension")return E({code:"INVALID_OP",message:"This source has no typed mutation contract"});const n=O(e.kind);const i=fr(t);const r=i===void 0?e.meta:{...e.meta,accessibility:i};let o=r;try{if(t.kind==="eventmodeling")o=Sr(t,r);if(t.kind==="zenuml")o=kr(t.title,r,e.body.kind==="zenuml"&&t.title===e.body.title)}catch(p){return E({code:"INVALID_OP",message:p instanceof Error?p.message:String(p)})}const a=Vi(ot(n.serialize(t,o),o.accessibility),e.kind,t,o);const s=ji(o,"verbatim",a,e.kind)+a;const d=v(s);if(!d.ok){return E({code:"INVALID_OP",message:`Mutation produced source that could not be reparsed: ${d.error.map(p=>p.message).join("; ")}`})}const m=d.value.kind===e.kind;const u=d.value.body.kind===t.kind;const y=!u&&d.value.body.kind==="opaque"&&n.verify?.(t,{}).some(p=>p.code==="EMPTY_DIAGRAM")===true;if(!m||!u&&!y){return E({code:"INVALID_OP",message:`Mutation changed semantic family while reparsing: expected ${e.kind}/${t.kind}, got ${d.value.kind}/${d.value.body.kind}`})}if(i&&(i.title!==d.value.meta.accessibility.title||i.descr!==d.value.meta.accessibility.descr)){return E({code:"INVALID_OP",message:"Accessibility text cannot be serialized by this family without changing its value; remove directive openers or description block delimiters"})}return q({...e,body:t,meta:{...d.value.meta,...e.meta.droppedComments?{droppedComments:e.meta.droppedComments}:{}},canonicalSource:s,source:d.value.source})}function qe(e,t){let n=e;const i={};for(let o=0;o<t.length;o++){const a=So(n,t[o],true,i);if(!a.ok)return E({...a.error,opIndex:o});n=a.value}if(!t.length)return q(e);const r=ko(n,n.body);return r.ok?r:E({...r.error,opIndex:t.length-1})}function gs(e,t){return So(e,t,false)}function Rn(e,t){const n=ys(e,t);ae("mutate",n.ok);return n}function ys(e,t){if(e.body.kind!=="opaque"||e.body.family!==e.kind)return E({code:"INVALID_OP",message:"Source-preserving mutation requires an opaque body of its parsed family; use mutate for structured bodies"});const n=O(e.kind);if(!n?.mutateSource||!ee(e.kind))return E({code:"UNSUPPORTED_FAMILY",message:`${e.kind} has no source-preserving mutation contract`});const i=At(t);const r=It(e.kind,i.ok?i.value:t);if(r)return E(r);const o=(e.meta.wrapperSource??"")+e.body.source;try{const a=n.mutateSource(o,i.ok?i.value:t);if(!a.ok)return a;const s=Hr(o,a.value);if(s===o)return q({source:o,diagram:e});const d=v(s);if(!d.ok)return E({code:"INVALID_OP",message:`Source-preserving mutation could not be reparsed: ${d.error.map(u=>u.message).join("; ")}`});if(d.value.kind!==e.kind||d.value.body.kind!=="opaque")return E({code:"INVALID_OP",message:"Source-preserving mutation changed family or source-preserved representation"});const m=u=>({...u,comments:u.comments.map(y=>y.text)});if(!Yr(m(e.meta),m(d.value.meta)))return E({code:"INVALID_OP",message:"Source-preserving mutation changed configuration, accessibility or comment metadata"});return q({source:s,diagram:d.value})}catch(a){return E({code:"INVALID_OP",message:a instanceof Error?a.message:String(a)})}}function So(e,t,n,i){if(ee(e.kind)){const o=At(t);const a=o.ok?o.value:t;const s=It(e.kind,a);if(s){ae("mutate",false);return E(s)}const d=Sn(e,a,n,i);ae("mutate",d.ok);return d}const r=Sn(e,t,n,i);ae("mutate",r.ok);return r}function hs(e,t){switch(e){case"flowchart":return{kind:"flowchart",graph:{direction:t.direction??"TD",nodes:new Map,edges:[],subgraphs:[],classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,linkStyles:new Map}};case"state":return{kind:"state",states:[],transitions:[],direction:t.direction};case"sequence":return{kind:"sequence",participants:[],messages:[],statements:[]};case"timeline":return{kind:"timeline",sections:[]};case"class":return{kind:"class",classes:[],relations:[],notes:[]};case"er":return{kind:"er",entities:[],relations:[]};case"journey":return{kind:"journey",sections:[]};case"architecture":return{kind:"architecture",groups:[],services:[],junctions:[],edges:[]};case"xychart":return{kind:"xychart",series:[]};case"pie":return{kind:"pie",showData:false,slices:[]};case"quadrant":return{kind:"quadrant",quadrants:[void 0,void 0,void 0,void 0],points:[]};case"gantt":return{kind:"gantt",sections:[],statements:[]};case"mindmap":return{kind:"mindmap",root:{id:"root",label:"root",shape:"default",children:[]}};case"gitgraph":return{kind:"gitgraph",direction:"LR",mainBranchName:"main",commits:[],branches:[{name:"main",order:0,sequence:0}],statements:[]};case"radar":return{kind:"radar",axes:[],curves:[],min:0,ticks:5,graticule:"circle",showLegend:true};case"sankey":return{kind:"sankey",links:[]};case"c4":return wr(t.c4Variant);case"packet":return{kind:"packet",fields:[]};case"kanban":return{kind:"kanban",columns:[]};case"requirement":return{kind:"requirement",direction:"TB",requirements:[],elements:[],relations:[],classDefs:[]};case"treemap":return{kind:"treemap",nodes:[],classDefs:Object.create(null)};case"zenuml":return{kind:"zenuml",participants:[],statements:[]};case"eventmodeling":return{kind:"eventmodeling",frames:[],entities:[],data:Object.create(null),notes:[],specifications:[]};case"ishikawa":return{kind:"ishikawa",nodes:[]};case"block":return{kind:"block",root:{id:"root",type:"composite",children:[]},edges:[],classDefs:[]}}}function Pt(e,t={}){ae("build");const n=hs(e,t);if(!n)throw new Error(`createMermaid: unknown diagram kind "${String(e)}"`);const i={kind:e,body:n,meta:{initDirectives:[],comments:[],accessibility:{}},source:{nodes:new Map,edges:new Map,groups:new Map,labels:new Map},canonicalSource:""};return{...i,canonicalSource:V(i)}}function bs(e,t,n={}){const i=Pt(e,n);return qe(i,t)}function xs(e,t,n){const i=fe(e);const r=fe(t);if(!i||!r||i[3]!==1||r[3]!==1)return void 0;const o=n/100;return Ln(i[0]*o+r[0]*(1-o),i[1]*o+r[1]*(1-o),i[2]*o+r[2]*(1-o))}function De(e,t){if(!e)return void 0;const n=t.appearance.colors;const i=m=>xs(n.fg,n.bg,m);const r=Vn(n)?Fn(n):void 0;const o=r?{text:r.text,textSec:r.textSec,textMuted:r.textMuted,textFaint:r.textFaint,line:r.line,arrow:r.arrow,nodeFill:r.nodeFill,nodeStroke:r.nodeStroke,groupHdr:r.groupHdr,innerStroke:r.innerStroke,keyBadge:r.keyBadge}:{text:n.fg,textSec:n.muted??i(J.textSec),textMuted:n.muted??i(J.textMuted),textFaint:i(J.textFaint),line:n.line??i(J.line),arrow:n.accent??i(J.arrow),nodeFill:n.surface??i(J.nodeFill),nodeStroke:n.border??i(J.nodeStroke),groupHdr:i(J.groupHeader),innerStroke:i(J.innerStroke),keyBadge:i(J.keyBadge)};const a={"--bg":n.bg,"--fg":n.fg,"--_text":o.text,"--_text-sec":o.textSec,"--_text-muted":o.textMuted,"--_text-faint":o.textFaint,"--_line":o.line,"--_arrow":o.arrow,"--_node-fill":o.nodeFill,"--_node-stroke":o.nodeStroke,"--_group-fill":n.bg,"--_group-hdr":o.groupHdr,"--_inner-stroke":o.innerStroke,"--_key-badge":o.keyBadge};const s={"--line":n.line,"--accent":n.accent,"--muted":n.muted,"--surface":n.surface,"--border":n.border,...a};const d=e.match(/^var\(\s*(--[a-z0-9_-]+)(?:\s*,[\s\S]*)?\)$/i)?.[1];return d&&Object.hasOwn(s,d)?s[d]:e}function K(e,t){return{code:cr[e.action].code,constraint:e.kind,...t,message:`${t.message} Recovery: ${zt[e.kind].recovery}`}}function Ro(e,t){const n=e.channels??{};const i=t.channels??{};const r=o=>Object.entries(o).sort(([a],[s])=>Qe(a,s));return JSON.stringify(r(n))===JSON.stringify(r(i))}function Eo(e){const t=[];for(const n of e){if(n.kind==="text")t.push(n);else if(n.kind==="group")t.push(...Eo(n.children.map(i=>i.node)))}return t}function ks(e,t){const n=qt(e.geometry);if(!n)return false;const i=Eo([t]);return i.length>0&&i.every(r=>r.x>=n.x0&&r.x<=n.x1&&r.y>=n.y0&&r.y<=n.y1)}function Ss(e,t,n){const i=r=>r[r.length-1];return i(e.filter(r=>r.role===t.role&&Ro(r,t)))??(n?i(e.filter(r=>r.role===n.role&&Ro(r,n))):void 0)??i(e.filter(r=>ks(r,t)))}function _o(e,t,n,i,r){const o=[];for(const a of e){if(a.kind==="shape"){if(a.paint.fill!==void 0&&a.paint.fill!=="none"&&a.paint.fill!=="transparent")o.push(a);continue}const s=Ss(o,a,r);const d=s?.paint.fill??t;if(a.kind==="text"){if(!i||a.role===i)n.push({node:a,background:d});continue}if(a.kind==="group"){_o(a.children.map(m=>m.node),d,n,i,a)}}}function Rs(e,t,n){const i=e.minimum??4.5;if(n.renderOptions.transparent){return K(e,{measurement:"unmeasurable",minimum:i,message:"Final contrast is unmeasurable for transparent output because the host backdrop is unknown; no ratio was fabricated."})}const r=De(n.appearance.colors.bg,n);const o=[];_o(t.parts,r,o,e.role);if(o.length===0){return K(e,{measurement:"not-applicable",minimum:i,...e.role?{role:e.role}:{},message:`Contrast constraint has no applicable text mark${e.role?` for role ${e.role}`:""}.`})}const a=o.map(u=>{const y=De(u.node.paint.fill,n);const p=De(u.background,n);const b=y&&p?Je(y,p,r):null;return{...u,foreground:y,background:p,ratio:b}});const s=a.filter(u=>u.ratio!==null).sort((u,y)=>u.ratio-y.ratio)[0];if(s&&s.ratio<i){const u=Math.round(s.ratio*100)/100;return K(e,{measurement:"measurable",minimum:i,ratio:u,role:s.node.role,mark:s.node.id,foreground:s.foreground,background:s.background,message:`Final ${s.node.role} contrast is ${u}:1; expected at least ${i}:1. Paint remains unchanged.`})}const d=a.find(u=>u.ratio===null);if(d){return K(e,{measurement:"unmeasurable",minimum:i,role:d.node.role,mark:d.node.id,...d.foreground?{foreground:d.foreground}:{},...d.background?{background:d.background}:{},message:"Final contrast is unmeasurable because an effective paint pair is unresolved; no ratio was fabricated."})}const m=Math.round(s.ratio*100)/100;return K(e,{measurement:"measurable",minimum:i,ratio:m,role:s.node.role,mark:s.node.id,foreground:s.foreground,background:s.background,message:`Final ${s.node.role} contrast is ${m}:1 and meets ${i}:1.`})}function Es(e,t){const n=fe(e);const i=fe(t);if(!n||!i)return e.trim().toLowerCase()===t.trim().toLowerCase();return n.every((r,o)=>Math.abs(r-i[o])<1e-6)}function _s(e,t,n){const i=De(n.appearance.colors.accent,n);if(!i)return K(e,{measurement:"unmeasurable",maximum:e.maxFraction,message:"Accent-area constraint is unmeasurable because no concrete accent paint is resolved."});let r=0;let o=0;Ve(t.parts,s=>{if(s.kind!=="shape"||s.role==="chrome")return;const d=De(s.paint.fill,n);if(!d||d==="none"||d==="transparent")return;const m=qt(s.geometry);if(!m)return;const u=Math.max(0,m.x1-m.x0)*Math.max(0,m.y1-m.y0);r+=u;if(Es(d,i))o+=u});if(r===0)return K(e,{measurement:"not-applicable",maximum:e.maxFraction,message:"Accent-area constraint has no applicable filled shape area."});const a=Math.round(o/r*1e4)/1e4;return K(e,{measurement:"measurable",actual:a,maximum:e.maxFraction,message:a>e.maxFraction?`Accent fill covers ${(a*100).toFixed(2)}% of applicable shape area; maximum is ${(e.maxFraction*100).toFixed(2)}%. Paint remains unchanged.`:`Accent fill area is within the configured maximum.`})}function Ms(e,t,n){const i=[];Ve(t.parts,r=>{if(r.role!==e.role)return;const o=r.kind==="connector"?[r.stroke.color]:r.kind==="shape"||r.kind==="text"?[r.paint.fill,r.paint.stroke]:[];for(const a of o){const s=De(a,n);if(s&&s!=="none")i.push({mark:r.id,value:s})}});if(i.length===0)return K(e,{measurement:"not-applicable",role:e.role,message:`Mono-role constraint has no applicable paint for role ${e.role}.`});for(const r of i){const o=fe(r.value);if(!o)return K(e,{measurement:"unmeasurable",role:e.role,mark:r.mark,message:`Mono-role paint ${r.value} is unresolved; no monochrome verdict was fabricated.`});if(Math.abs(o[0]-o[1])>1||Math.abs(o[1]-o[2])>1){return K(e,{measurement:"measurable",role:e.role,mark:r.mark,foreground:r.value,message:`Role ${e.role} uses chromatic paint ${r.value}; the mono-role constraint does not repaint it.`})}}return K(e,{measurement:"measurable",role:e.role,message:`Role ${e.role} uses only measurable monochrome paint.`})}var $s={contrast:Rs,"accent-area":_s,"mono-role":Ms};function Os(e,t,n){const i=$s[e.kind];return i(e,t,n)}function Mo(e,t){const n=t.appearance.style?.constraints??[];const i=n.map(r=>Os(r,e,t)).filter(r=>{if(r.measurement!=="measurable")return true;if(r.constraint==="contrast")return(r.ratio??Infinity)<(r.minimum??4.5);if(r.constraint==="accent-area")return(r.actual??0)>(r.maximum??1);return r.foreground!==void 0});return i}var Cs=[[qi,"engine"],[Gi,"engine"],[Pe,"engine"],[ar,"engine"],[yt,"engine"],[pt,"config"],[gt,"config"],[Ri,"config"],[Yn,"config"],[Ne,"config"],[Mi,"config"],[rn,"config"],[xi,"config"],[Kn,"source"],[jr,"source"],[si,"source"],[oi,"source"],[rt,"source"],[Gr,"source"],[Te,"source"],[we,"source"],[Wi,"source"],[Ui,"source"],[Ti,"source"],[ce,"source"]];var Ds=[TypeError,RangeError,ReferenceError];var vs=new Set(["SCENE_FIDELITY","SCENE_PRIMITIVE_CLAIM","SCENE_CHANNEL_CLAIM"]);function $o(e){const t=new Set;let n=e;let i=e;while(i instanceof Error&&!t.has(i)){const r=i;t.add(r);if(r instanceof qn){return r.attempts.length>0&&r.attempts.every(a=>a.violations.some(s=>s.endsWith(": duplicate identity")))?"source":"engine"}if(r instanceof tn){return r.diagnostics.length>0&&r.diagnostics.every(a=>vs.has(a.code))?"engine":"source"}const o=Cs.find(([a])=>r instanceof a);if(o)return o[1];n=r;i=r.cause}return n instanceof Error&&Ds.some(r=>Object.getPrototypeOf(n)===r.prototype)?"engine":"source"}var me=class extends Error{family;operation;constructor(t,n,i){const r=i instanceof Error?i.message:String(i);super(`Mermaid family "${t}" ${n} hook failed: ${r}`,{cause:i});this.name="FamilyLayoutError";this.family=t;this.operation=n}};function wt(e,t,n={}){const i=ht(t);const r=i.family;if(r.id!==e.kind){throw new Error(`Resolved request planned family ${r.id}, not ${e.kind}`)}if(!r.layout||!r.projectPositioned)return null;if(t.renderOptions.layoutSafety==="strict"&&(!r.lowerScene||e.kind.startsWith("family:")))throw new me(e.kind,"projectPositioned",new Ne("Strict layout safety requires native Scene evidence"));let o;try{o=kt(e.kind,t,t.source,n)}catch(d){throw new me(e.kind,"layout",d)}let a;try{a=dn(o)??jt(i.textMeasurement,()=>r.projectPositioned({positioned:o.positioned,options:n}))}catch(d){throw new me(e.kind,"projectPositioned",d)}const s=En(e.kind,a);if(r.lowerScene&&!e.kind.startsWith("family:")){const d=Xi(t,o);if(t.renderOptions.layoutSafety==="strict"&&d.status!=="passed")throw new ce(d);Ze(s,d);if(n.debug)s.paintCertification=d}return{request:t,layoutResult:o,positioned:o.positioned,rendered:s}}function As(e){const t=ht(e).family;if(!t.layout||!t.projectPositioned)throw new Error(`No public layout projection registered for Mermaid family "${t.id}"`);if(e.renderOptions.layoutSafety==="strict"&&(!t.lowerScene||t.id.startsWith("family:")))throw new me(t.id,"projectPositioned",new Ne("Strict layout safety requires native Scene evidence"))}function om(e,t,n={}){const i=ht(e);const r=i.family;if(!r.projectPositioned)return null;As(e);const o=dn(t);if(o)return En(r.id,sn(t)?an(o):o);const a=sn(t)?an(t):t;try{const s=jt(i.textMeasurement,()=>r.projectPositioned({positioned:a.positioned,options:n}));return En(r.id,s)}catch(s){throw new me(r.id,"projectPositioned",s)}}function Is(e){switch(e.body.kind){case"xychart":return e.body.series.length>0;case"pie":return e.body.slices.length>0;case"gantt":return e.body.sections.some(t=>t.tasks.length>0);default:return false}}function En(e,t){const n={version:t.version,kind:e,nodes:t.nodes,edges:t.edges,groups:t.groups,bounds:t.bounds};if(t.certificates!==void 0)n.certificates=t.certificates;if(t.labels!==void 0)n.labels=t.labels;return n}function Ps(e,t,n={}){const i=O(e);if(!i?.projectPositioned)return null;return i.projectPositioned({positioned:t,options:n})}function ws(e){return Hi(e)}function Lt(e,t={}){const n=O(e.kind);if(!n?.layout||!n.projectPositioned)return null;const i={debug:t.debug};const r=ws(e);const o=Is(e);const a=m=>{const u=t.output??"layout";const y=bt(m,t.renderOptions??{},u,u==="layout"?i:void 0);if(t.assertScenes)ft(y);return wt(e,y,i)};let s;try{s=a(r)}catch(m){if(!o)throw m;const u=V(e);if(u===r)throw m;return a(u)}if(!o||s.rendered.nodes.length>0)return s;const d=V(e);return d===r?s:a(d)}function Co(e,t,n={}){return wt(e,t,n)?.rendered??null}function Do(e){try{const t=ie(e.canonicalSource);const n=_e(le(t.lines),t.frontmatter);$e(n);return null}catch(t){const n=t instanceof Error?t.message:String(t);if(n.startsWith("GANTT_EMPTY"))return{code:"EMPTY_DIAGRAM"};return t instanceof rt?{code:"RENDER_FAILED",reason:n,origin:"source"}:{code:"UNRESOLVABLE_SCHEDULE",reason:n}}}function We(e,t={}){const n=[];const i=.5;for(const r of e.nodes){if(r.x<-i||r.x+r.w>e.bounds.w+i)n.push({code:"OFF_CANVAS",target:r.id,axis:"x"});if(r.y<-i||r.y+r.h>e.bounds.h+i)n.push({code:"OFF_CANVAS",target:r.id,axis:"y"})}for(const r of e.edges){for(const[o,a]of r.path){if(o<-i||o>e.bounds.w+i){n.push({code:"OFF_CANVAS",target:r.id,axis:"x"});break}}for(const[o,a]of r.path){if(a<-i||a>e.bounds.h+i){n.push({code:"OFF_CANVAS",target:r.id,axis:"y"});break}}}for(const r of e.labels??[]){if(r.visibility==="hidden"||r.visibility==="semantic"||!r.bounds)continue;const{x:o,y:a,w:s,h:d}=r.bounds;if(o<-i||o+s>e.bounds.w+i)n.push({code:"OFF_CANVAS",target:r.id,axis:"x"});if(a<-i||a+d>e.bounds.h+i)n.push({code:"OFF_CANVAS",target:r.id,axis:"y"})}if(t.nodeOverlaps){for(let r=0;r<e.nodes.length;r++){for(let o=r+1;o<e.nodes.length;o++){const a=e.nodes[r],s=e.nodes[o];const d=Math.max(0,Math.min(a.x+a.w,s.x+s.w)-Math.max(a.x,s.x));const m=Math.max(0,Math.min(a.y+a.h,s.y+s.h)-Math.max(a.y,s.y));const u=d*m;if(u>i)n.push({code:"NODE_OVERLAP",a:a.id,b:s.id,areaPx:Math.round(u)})}}}if(t.groupContainment){const r=new Map(e.nodes.map(o=>[o.id,o]));for(const o of e.groups){for(const a of o.members){const s=r.get(a);if(!s)continue;const d=t.groupContainment==="center"?s.x+s.w/2>=o.x-i&&s.y+s.h/2>=o.y-i&&s.x+s.w/2<=o.x+o.w+i&&s.y+s.h/2<=o.y+o.h+i:s.x>=o.x-i&&s.y>=o.y-i&&s.x+s.w<=o.x+o.w+i&&s.y+s.h<=o.y+o.h+i;if(!d)n.push({code:"GROUP_BREACH",group:o.id,member:a})}}}if(t.edgeAnchors){const r=new Map(e.nodes.map(o=>[o.id,o]));for(const o of e.edges){const a=o.path[0];const s=o.path[o.path.length-1];const d=r.get(o.from);const m=r.get(o.to);if(a&&d&&!Oo(a[0],a[1],d,i))n.push({code:"ROUTE_SHAPE_MISANCHOR",edge:o.id,node:d.id});if(s&&m&&!Oo(s[0],s[1],m,i))n.push({code:"ROUTE_SHAPE_MISANCHOR",edge:o.id,node:m.id})}}return n}function Oo(e,t,n,i){const r=(Math.abs(e-n.x)<=i||Math.abs(e-(n.x+n.w))<=i)&&t>=n.y-i&&t<=n.y+n.h+i;const o=(Math.abs(t-n.y)<=i||Math.abs(t-(n.y+n.h))<=i)&&e>=n.x-i&&e<=n.x+n.w+i;return r||o}function vo(e){const t=[];const n=.5;for(const r of e.nodes){if(r.x<-n||r.x+r.w>e.bounds.w+n)t.push({code:"OFF_CANVAS",target:r.id,axis:"x"});if(r.y<-n||r.y+r.h>e.bounds.h+n)t.push({code:"OFF_CANVAS",target:r.id,axis:"y"})}const i=new Map(e.nodes.map(r=>[r.id,r]));for(const r of e.groups){for(const o of r.members){const a=i.get(o);if(!a)continue;const s=a.x>=r.x-n&&a.y>=r.y-n&&a.x+a.w<=r.x+r.w+n&&a.y+a.h<=r.y+r.h+n;if(!s)t.push({code:"GROUP_BREACH",group:r.id,member:o})}}return t}var Io=new Set(["flowchart","state","class","er","block","requirement"]);var Ls=new Set([...Io,"quadrant","treemap"]);function Po(e,t,n,i){const r=new Set;let o=0,a=0;for(let s=0;s<t.types.length;s++){if(t.types[s]!==n&&t.types[s]!==i)continue;const d=t.starts[s];while(o+1<e.length&&a+e[o].length<d)a+=e[o++].length+1;if(!e[o].slice(0,d-a).trim())r.add(o+1)}return r}function Ts(e,t){const n=[...e];const i=n.findIndex(r=>r.trim()&&!r.trimStart().startsWith("%%"));if(i>=0){let r=0;for(let s=0;s<i;s++){const d=Xn(t.originalText,r);r=d+(t.originalText[d]==="\r"&&t.originalText[d+1]==="\n"?2:1)}const o=Qn(t,r);const a=/^[^\S\r\n]*requirement(?:Diagram)?(?=$|[\s;%])/i.exec(t.text.slice(o));if(a){const s=Jn(t,o+a[0].length,"end");n[i]="requirementDiagram"+n[i].slice(s-r)}}return Po(n,_r(n.join("\n")),46,47)}function wo(e,t){const n=v(e);if(!n.ok||n.value.body.kind==="opaque"||n.value.body.kind==="preserved")return void 0;const{comments:i,wrapperSource:r,...o}=n.value.meta;return JSON.stringify([o,n.value.body],(a,s)=>s instanceof Map?[...s]:s instanceof Set?[...s]:t&&typeof s==="string"&&s.includes("<")?Ut(s).upstreamText:s)}function Ao(e,t,n,i){const r=i&&t.some(s=>s.reason==="html-attribute-quotes");const o=n(r);if(o===void 0)return true;let a=e;for(const s of[...t].sort((d,m)=>m.originalStart-d.originalStart)){const d=s.reason==="style-semicolon"?" ".repeat(s.originalEnd-s.originalStart):"'";a=a.slice(0,s.originalStart)+d+a.slice(s.originalEnd)}return wo(a,r)!==o}function Ge(e){const t=typeof e==="string"?e:e.originalText;if(!t.includes("<")&&!t.includes("style")&&!t.includes("classDef"))return[];const n=typeof e==="string"?Ut(t):e;if(!n.changes.some(k=>k.reason==="html-attribute-quotes"||k.reason==="style-semicolon"))return[];const i=Un(Gn(n.text),"loose");const r=et(t)?.source.length??0;const o=[...t.matchAll(new RegExp(Wt.source,"gm"))];const a=t.split(/\r\n?|\n/);let s;let d;let m;const u=k=>{if(!s){s=new Set;const C=t.slice(0,r).match(/\r\n?|\n/g)?.length??0;const D=t.replace(new RegExp(Wt.source,"gm"),A=>A.replace(/[^\r\n]/g," ")).split(/\r\n?|\n/).map((A,N)=>N<C?"":A);d=D.slice();const ne=i?.statementEnds?.(D);for(let A=0;A<D.length;A++){const N=nt(D,A);const re=N===void 0?D.length-1:N?N.endIndex:zn(ne,A,D.length);for(let j=A+1;j<=re;j++)s.add(j+1);if(N!==null)for(let j=A;j<=re;j++)d[j]="";A=re}}return s.has(k)};const y=k=>{if(i?.id==="flowchart")return gr(a[k-1]??"").length===1;if(i?.id!=="class"&&i?.id!=="er"&&i?.id!=="block"&&i?.id!=="requirement")return true;if(!m){try{if(i.id==="class")m=Fr(d);else if(i.id==="er")m=Br(d);else if(i.id==="block")m=Po(d,Er(d.join("\n")),18,11);else m=Ts(d,n)}catch{m=new Set}}return m.has(k)};const p=new Map;for(const k of n.changes){if(k.reason!=="html-attribute-quotes"&&k.reason!=="style-semicolon")continue;if(k.reason==="style-semicolon"){if(k.originalStart<r)continue;if(/^\s*%%/.test(a[k.line-1]??""))continue;const C=/^\s*(style|classDef)\s/.exec(a[k.line-1]??"")?.[1];const D=C==="classDef"?Ls:Io;const ne=a[k.line-1].slice(k.col-1+k.originalEnd-k.originalStart);if(C&&i&&D.has(i.id)&&!ne.trim()&&!u(k.line)&&y(k.line))continue;let A=0,N=o.length;while(A<N){const j=A+Math.floor((N-A)/2);if(o[j].index<=k.originalStart)A=j+1;else N=j}const re=o[A-1];if(re&&k.originalStart<re.index+re[0].length)continue}p.set(k.line,[...p.get(k.line)??[],k])}if(p.size===0)return[];let b=false;if(i?.id==="flowchart"){try{const{config:k}=ie(t);b=String(k.htmlLabels??k.flowchart?.htmlLabels??true)!=="false"}catch{b=false}}const S=new Map;const _=k=>{if(!S.has(k))S.set(k,wo(t,k));return S.get(k)};const P=[...p.values()].flat();const G=[...new Set(P.map(k=>k.reason))];let M=G.filter(k=>Ao(t,P.filter(C=>C.reason===k),_,b));if(M.length===0&&G.length>1&&Ao(t,P,_,b))M=G;const w=new Map;for(const[k,C]of p){const D=M.filter(ne=>C.some(A=>A.reason===ne));if(D.length>0)w.set(k,D.map(ne=>ne==="html-attribute-quotes"?"rewrites double-quoted HTML-like attributes to single quotes":"removes a style/classDef semicolon"))}return[...w].sort(([k],[C])=>k-C).map(([k,C])=>({code:"UNSUPPORTED_SYNTAX",syntax:"mermaid_cleanup",line:k,message:`Mermaid's cleanup changed this line: it ${[...C].join(" and ")} before parsing. Agentic Mermaid retains the authored text; use entity codes for literal punctuation when exporting to Mermaid.`}))}function _n(e){let t=0,n=0;for(const i of e){t++;if(i.regions){for(const r of i.regions){const o=_n(r.states);t+=o.nodes;n+=o.edges+r.transitions.length}}else{if(i.states&&i.states.length){const r=_n(i.states);t+=r.nodes;n+=r.edges}if(i.transitions)n+=i.transitions.length}}return{nodes:t,edges:n}}function Lo(e){let t=0;for(const n of e){t++;t+=Lo(n.children)}return t}function Mn(e){const t=e.body;switch(t.kind){case"flowchart":{const n=t.graph;return{nodes:n.nodes.size,edges:n.edges.length,groups:Lo(n.subgraphs)}}case"sequence":return{nodes:t.participants.length,edges:ut(t).length,groups:0};case"state":{const n=_n(t.states);return{nodes:n.nodes,edges:n.edges+t.transitions.length,groups:0}}case"class":return{nodes:t.classes.length,edges:t.relations.length,groups:(t.namespaces??[]).length};case"er":return{nodes:t.entities.length,edges:t.relations.length,groups:(t.groups??[]).length};case"timeline":{let n=0;for(const i of t.sections)for(const r of i.periods)n+=1+r.events.length;return{nodes:n,edges:0,groups:t.sections.length}}case"journey":{let n=0;for(const i of t.sections)n+=i.tasks.length;return{nodes:n,edges:0,groups:t.sections.length}}case"architecture":return{nodes:t.services.length+t.junctions.length,edges:t.edges.length,groups:t.groups.length};case"xychart":return{nodes:t.series.length,edges:0,groups:0};case"pie":return{nodes:t.slices.length,edges:0,groups:0};case"quadrant":return{nodes:t.points.length,edges:0,groups:0};case"gantt":{let n=0;for(const i of t.sections)n+=i.tasks.length;return{nodes:n,edges:0,groups:t.sections.length}}case"mindmap":{let n=0,i=0;const r=o=>{n++;i+=o.children.length;o.children.forEach(r)};r(t.root);return{nodes:n,edges:i,groups:0}}case"gitgraph":return{nodes:t.commits.length,edges:t.commits.reduce((n,i)=>n+i.parents.length,0),groups:t.branches.length};case"radar":return{nodes:t.curves.reduce((n,i)=>n+i.values.length,0),edges:0,groups:t.axes.length};case"c4":return{nodes:t.elements.length,edges:t.relationships.length,groups:t.boundaries.length};case"sankey":{const n=new Set;for(const i of t.links){n.add(i.source);n.add(i.target)}return{nodes:n.size,edges:t.links.length,groups:0}}case"zenuml":{const n=xe(t);return{nodes:n.actors.filter(i=>!i.external).length,edges:n.messages.length,groups:n.blocks.length}}case"eventmodeling":return{nodes:t.frames.length,edges:ke(t).length,groups:st(t).length};case"packet":case"kanban":case"requirement":case"block":case"treemap":case"ishikawa":return dt(t);case"opaque":case"extension":case"preserved":return null;default:{const n=t;void n;return null}}}function Ns(e,t){return e.nodes===t.nodes&&e.edges===t.edges&&e.groups===t.groups}function $n(e,t){if(!e)return[];if(!t)return[{code:"CONTENT_DROPPED_ON_ROUNDTRIP",before:e,after:{nodes:0,edges:0,groups:0}}];if(!Ns(e,t))return[{code:"CONTENT_DROPPED_ON_ROUNDTRIP",before:e,after:t}];return[]}function Fs(e){const t=[e.meta.frontmatter,...e.meta.initDirectives.map(r=>r.parsed)];const n=O(e.kind);const i=nn(e.kind,t,n?.config,n?.configDiagnostics);try{Bi(e.meta,e.kind)}catch(r){i.push({code:"UNSUPPORTED_SYNTAX",syntax:"mermaid_wrapper_config",message:r instanceof Error?r.message:String(r)})}return i}var Vs=new Set(["rectangle","service","rounded","diamond","stadium","circle","ellipse","subroutine","doublecircle","hexagon","cylinder","asymmetric","trapezoid","trapezoid-alt","lean-r","lean-l","state-start","state-end","state-fork","state-join","state-choice","state-history"]);function Bs(e){if(e.meta.accessibility.title!==void 0||e.meta.accessibility.descr!==void 0)return false;if(e.body.kind==="opaque"){const n=e.kind==="timeline"?ie(e.body.source).familyText:e.body.source;return To(e.kind,n)}const t=O(e.kind)?.serialize;if(!t)return false;try{return To(e.kind,ot(t(e.body),e.meta.accessibility))}catch{return false}}function To(e,t){const n=t.split(/[;\n]/).map(o=>o.trim()).filter(o=>o&&!o.startsWith("%%"));if(n.length===0)return true;if(n.length>1)return false;const i=n[0].toLowerCase();const r=(Yt(e)?.headers??[e]).map(o=>o.toLowerCase());return r.some(o=>i===o||i.startsWith(`${o} `))}function js(e){try{const t=Mn(e);if(!t)return[];const n=v(V(e));if(!n.ok)return $n(t,null);const i=Mn(n.value);if(!i)return[];return $n(t,i)}catch{return[]}}function Ae(e,t={}){return qs(e,t)}function qs(e,t,n){ae("verify");let i;try{i=typeof e==="string"?v(e):{ok:true,value:e}}catch(u){if(!(u instanceof we))throw u;const y=T([Ft(u,()=>"fails")],U(typeof e==="string"?"flowchart":e.kind),t,false);return{...y,ok:false,checks:{...y.checks,renderability:"failed"}}}const r=i.ok?[...dd(i.value),...js(i.value)]:[];const o=Ws(e,t,i,n);const a=new Set(t.suppress??[]);const s=$(o.warnings,r.filter(u=>!a.has(u.code)));const d=(t.suppress??[]).some(u=>pe[u]==="error");const m=s.some(u=>u.code==="RENDER_FAILED"||u.code==="INTERNAL_ERROR");return{...o,warnings:s,checks:{renderability:m?"failed":o.ok&&!d?"passed":"not-checked",sourceLoss:r.length>0||o.checks?.sourceLoss==="detected"?"detected":"not-detected",taskCorrectness:"not-checked"}}}function Ws(e,t,n,i){if(!n.ok){const o=n.error[0]?.code;const a=typeof e==="string"&&o!=="INVALID_FRONTMATTER"&&o!=="CONFIG_REJECTED"&&jn(ie(e).firstLine);const s=[...a?en(e):[],...typeof e==="string"&&o!=="INVALID_FRONTMATTER"&&o!=="CONFIG_REJECTED"?Ge(e):[]];return{...T([Us(n.error),...s],U("flowchart"),t),ok:false}}if(n.value.body.kind==="preserved"){const{diagnostic:o}=n.value.body;return T([{code:"RENDER_FAILED",reason:`${o.code}: ${o.message}`,origin:"source"}],U(n.value.kind),t,false)}const r=Ys(n.value,t,typeof e==="string"?e:void 0,i);try{const o=typeof e==="string"?e:V(n.value);const a=Zn(o,t.renderOptions?.mermaidConfig??{});if(n.value.kind==="architecture")bt(o,t.renderOptions??{},"svg");else _i(a.config.themeVariables,n.value.kind,t.renderOptions);Ei(a.frontmatter,n.value.kind)}catch(o){return T([r.failure(o)],U(n.value.kind),t,false)}try{const o=cd(n.value,t,r,typeof e==="string"?e:void 0);return zs(Hs(o,t,r),t,r,i)}catch(o){if(!(o instanceof ce||o instanceof me||o instanceof gt||o instanceof pt||o instanceof we))throw o;const a=o instanceof ce?{layoutCertification:o.certification}:{};return{...T([r.failure(o)],U(n.value.kind),t,false),...a}}}function Ft(e,t,n=""){const i=Wn(e);if(i)throw i;const r=`${n}${e instanceof Error?e.message:String(e)}`;const o=$o(e);return o==="engine"?{code:"INTERNAL_ERROR",reason:r,defaultRender:t()}:{code:"RENDER_FAILED",reason:r,origin:o}}function Gs(e,t,n){try{const{onConfigDiagnostic:i,...r}=t.renderOptions??{};const o=Oe(n??e);Et(o.source,r,"svg",void 0,{expectedFamilyId:o.expectedFamilyId});return"succeeds-unchecked"}catch{return"fails"}}function Us(e){if(e.every(t=>t.code==="EMPTY"))return{code:"EMPTY_DIAGRAM"};return{code:"RENDER_FAILED",reason:e.map(t=>t.message).join("; "),origin:e.some(t=>t.code==="CONFIG_REJECTED"||t.code==="FAMILY_DESCRIPTOR_CONTRACT")?"config":"source"}}function Hs(e,t,n){if(!e.ok)return e;try{const i=n();const r=i?.request.appearance.style?.constraints;if(!i||!r||r.length===0)return e;const o=Rt(i.request,i.layoutResult);const a=new Set(t.suppress??[]);const s=Mo(o,i.request).filter(d=>!a.has(d.code));return{...e,ok:e.ok&&!s.some(d=>pe[d.code]==="error"),warnings:[...e.warnings,...s]}}catch{return e}}function Ys(e,t,n,i){let r=false;let o=null;let a;let s;const d=(m,u)=>Ft(m,()=>s??=Gs(e,t,n),u);return Object.assign(()=>{if(r){if(a!==void 0)throw a;return o}r=true;try{if(i){const m=Me(i.source,t.renderOptions??{},"svg",void 0,{expectedFamilyId:e.kind});xt(m);ft(m);o=wt(e,m);if(o)i.artifact=o}else{o=Lt(e,{renderOptions:t.renderOptions,output:"svg",assertScenes:true})}return o}catch(m){a=m;throw m}},{failure:d})}function zs(e,t,n,i){if(!e.ok||(t.suppress??[]).some(r=>r==="RENDER_FAILED"||pe[r]==="error"))return e;try{const r=n();if(!r)throw new Error(`Mermaid family "${e.layout.kind}" has no positioned graphical artifact`);const o=Ji(r.request,r.layoutResult,i?.diagnostics??[]);if(i)i.rendered=o;return{...e,...o.layoutCertification?{layoutCertification:o.layoutCertification}:{}}}catch(r){return{...e,ok:false,...r instanceof ce?{layoutCertification:r.certification}:{},warnings:[...e.warnings,n.failure(r)]}}}function Ks(e){try{const t=ie(e.canonicalSource);const n=_e(le(t.lines),t.frontmatter);const i=n.todayMarker?.style;if(i===void 0)return[];return[...Wr(i).ignored].sort().map(r=>({code:"INEFFECTIVE_CONFIG",field:`todayMarker.${r}`,message:`Gantt todayMarker style property "${r}" is accepted for Mermaid compatibility but is not applied to the today line (wired, sanitized properties: ${qr.join(", ")}).`}))}catch{return[]}}function Xs(e){if(e.kind!=="flowchart"||e.body.kind!=="flowchart")return[];const t=[];for(const n of e.body.graph.nodes.values()){if(!n.semanticShape)continue;const i=Qr(n.semanticShape);if(!i||i.exact)continue;t.push({code:"UNSUPPORTED_SYNTAX",syntax:"flowchart_shape_substitution",node:n.id,message:`Mermaid v11 shape "${n.authoredShape??n.semanticShape}" (${i.description}) has no dedicated renderer yet; node "${n.id}" renders with the nearest geometry "${i.geometry}".`})}return t}function Js(e){if(e.body.kind!=="quadrant")return[];const t=new Set;const n=i=>{for(const r of i?.extra??[])t.add(r.slice(0,r.indexOf(":")).trim())};for(const i of e.body.points)n(i.style);for(const i of Object.values(e.body.classDefs??{}))n(i);return[...t].sort().map(i=>({code:"UNSUPPORTED_SYNTAX",syntax:"quadrant_style_property",message:`Quadrant style property "${i}" is preserved in source for upstream compatibility but has no effect on rendered points (rendered properties: radius, color, stroke-color, stroke-width).`}))}function Qs(e){if(e.body.kind!=="treemap")return[];return e.canonicalSource.split(/\r?\n/).flatMap((t,n)=>/["']\s*[:,]\s*[\d.,]*_/.test(t)?[{code:"UNSUPPORTED_SYNTAX",syntax:"treemap_numeric_separator",line:Ee(e.source,n+1),message:"Underscores in Treemap quantities are read as digit separators; Mermaid 12.2.0 does not preserve that quantity. Canonical edits write the full numeric value without underscores."}]:[])}var Zs={eventmodeling:Rr,architecture:Ur,block:$r,ishikawa:Cr,requirement:vr,class:Xr,er:Jr,flowchart:ri,gantt:ii,journey:ai,mindmap:di,quadrant:ci,radar:ui,sankey:mi,sequence:fi,state:pi,timeline:gi,xychart:hi};function ed(e,t){const n=Zs[e.kind];if(!n)return[];const i=t?.split(/\r\n?|\n/);const r=i?o=>i[Ee(e.source,o)-1]:o=>xr(e.source,o);return On(n(e.canonicalSource,r),o=>Ee(e.source,o))}function On(e,t){return e.map(n=>n.code==="UNSUPPORTED_SYNTAX"&&n.line!==void 0?{...n,line:t(n.line)}:n)}function td(e,t){const n=e.body.kind==="opaque"?ur(e.body.source,O(e.kind)?.statementEnds):void 0;const i=e.meta.wrapperSource??"";const r=et(i);const o=r&&r.yaml===""?[{code:"UNSUPPORTED_SYNTAX",syntax:"empty_frontmatter",line:i.slice(0,i.indexOf("---")).split(/\r\n?|\n/).length,message:"Frontmatter without a content line is read as no configuration. Pinned Mermaid rejects adjacent delimiters; serialization omits them."}]:[];if(n)o.push({code:"UNSUPPORTED_SYNTAX",syntax:"accessibility_directive_text",message:n});for(const s of e.meta.initDirectives)if(/\}\s+%%\s*$/.test(s.raw))o.push({code:"UNSUPPORTED_SYNTAX",syntax:"separated_directive_close",message:"Directive closing delimiters must be contiguous in pinned Mermaid. Native reading repairs the separated close; canonical serialization emits }%%."});const a=br(e.source);if(a)return[...o,...Ge(a)];if(t!==void 0)return[...o,...Ge(t)];return[...o,...Ge(e.canonicalSource).map(s=>s.code==="UNSUPPORTED_SYNTAX"&&s.line!==void 0?{...s,line:Ee(e.source,s.line)}:s)]}function nd(e){try{const t=e();if(t?.request.renderOptions.transparent)return[];const n=t?.request.familyConfig?.visual;const i=n?.axisColor;if(typeof i!=="string")return[];const r=t.request.appearance.colors.bg;const o=Je(i,r);if(o===null||o>=4.5)return[];const a=Math.round(o*100)/100;return[{code:"LOW_CONTRAST",field:"themeVariables.radar.axisColor",foreground:i,background:r,ratio:a,minimum:4.5,message:`Authored Radar axis label color ${i} has contrast ${a}:1 against ${r}; expected at least 4.5:1. The color is preserved as authored.`}]}catch{return[]}}function rd(e){try{const t=e()?.layoutResult.positioned;if(t?.body.kind!=="c4")return[];return t.diagnostics.map(n=>{const i=t.body.statements.find(r=>r.id===n.statementId);if(n.code==="C4_LABEL_COLLISION"||n.code==="C4_ARROW_OCCLUDED"){return{code:"CONTENT_OCCLUDED",target:i?.entityId??"C4 layout",feature:n.code==="C4_ARROW_OCCLUDED"?"marker":"label",line:i?.span.line,message:`${n.code}: ${n.message}`}}if(n.code==="C4_WIDTH_EXCEEDED")return{code:"LAYOUT_LIMIT_EXCEEDED",constraint:"c4.maxWidth",message:`${n.code}: ${n.message}`};return{code:"UNSUPPORTED_SYNTAX",line:i?.span.line,syntax:n.code.toLowerCase(),message:`${n.code}: ${Lr(t.body,n)}`}})}catch{return[]}}function id(e,t){try{const n=t()?.positioned;const i=n?.widthFit;return i?.status==="exceeded"?[{code:"LAYOUT_LIMIT_EXCEEDED",constraint:`${e}.maxWidth`,message:`The requested ${e} width ${i.maxWidth}px cannot contain the ${i.width}px artifact within the bounded fitting policy; legend text, selected typography and existing scale annotations are retained.`}]:[]}catch{return[]}}function od(e){try{const t=e()?.positioned;if(!t?.hiddenLabels.length)return[];return[{code:"LABELS_HIDDEN",target:"data-labels",labels:t.hiddenLabels,message:"Treemap labels do not fit their value-proportional cells; enlarge the canvas or reduce the hierarchy."}]}catch{return[]}}function ad(e){try{const t=e()?.positioned;if(!t)return[];const n=[];if(t.hiddenTitle){n.push({code:"LABELS_HIDDEN",target:"title",labels:[t.hiddenTitle],message:`XY chart does not draw its title because it does not fit: ${t.hiddenTitle}. Enlarge the chart, shorten the title, or lower xyChart.plotReservedSpacePercent.`})}const i=t.hiddenCategoryLabels??[];const r=t.hiddenLegendLabels??[];if(r.length>0){n.push({code:"LABELS_HIDDEN",target:"legend",labels:r,message:`XY chart does not draw ${r.length} legend ${r.length===1?"entry":"entries"} because the legend does not fit: ${r.join(", ")}. Enlarge the chart, shorten the series names, or lower xyChart.plotReservedSpacePercent.`})}if(i.length>0){const a=t.horizontal?"Shorten the category names, widen the chart, or lower xyChart.plotReservedSpacePercent.":"Shorten the category names, or call set_orientation {horizontal: true} to list categories down the side.";n.push({code:"LABELS_HIDDEN",target:"x-axis",labels:i,message:`XY chart does not draw ${i.length} x-axis category ${i.length===1?"name":"names"} because ${i.length===1?"it does":"they do"} not fit: ${i.join(", ")}. ${a}`})}const o=t.unlabeledBars??[];if(o.length>0){const a=o.map(s=>`${s.label??""} = ${yi(s.value)}`.trim());n.push({code:"LABELS_HIDDEN",target:"data-labels",labels:a,message:`XY chart does not draw ${o.length} bar value ${o.length===1?"label":"labels"} because neither the bar nor the plot beyond it has room: ${a.join(", ")}. Widen the value range or enlarge the chart.`})}return n}catch{return[]}}function sd(e){try{const t=e()?.positioned;const n=(t?.points??[]).filter(i=>i.labelHidden).map(i=>i.label);if(n.length===0)return[];return[{code:"LABELS_HIDDEN",target:"point-labels",labels:n,message:`Quadrant chart does not draw ${n.length} point ${n.length===1?"label":"labels"} because ${n.length===1?"it collides":"they collide"} with labels placed first: ${n.join(", ")}. Spread the points, shorten the names, or enlarge the chart.`}]}catch{return[]}}function Bo(e){if(e.body.kind==="preserved")return[];if(e.body.kind==="extension"){const i=O(e.kind);return i?.configDiagnostics?nn(e.kind,[e.meta.frontmatter,...e.meta.initDirectives.map(r=>r.parsed)],i.config,i.configDiagnostics):[]}const t=e;const n=t.kind==="gantt"?Ks(t):[];return $(n,Fs(t))}function Xf(e){const t=v(e);return t.ok?Bo(t.value):[]}function dd(e){return e.meta.droppedComments?.length?[{code:"COMMENT_DROPPED",count:e.meta.droppedComments.length,lines:e.meta.droppedComments.map(t=>t.line)}]:[]}function cd(e,t,n,i){const r=t.labelCharCap??Kt;const o=td(e,i);const a=fd(e,t,n);const s=Bo(e);if(e.body.kind==="extension"){return ld(e,r,t,$($(o,a),s),n)}const d=e;const m=d.kind==="flowchart"?$(On(en(d.canonicalSource),M=>Ee(d.source,M)),Xs(d)):d.kind==="quadrant"?Js(d):d.kind==="treemap"?Qs(d):[];const u=$(m,ed(d,i));if(["block","sankey","mindmap","ishikawa"].includes(d.kind)&&(d.meta.accessibility.title!==void 0||d.meta.accessibility.descr!==void 0)&&!u.some(M=>M.code==="UNSUPPORTED_SYNTAX"&&M.syntax===`${d.kind}_accessibility`)){u.push({code:"UNSUPPORTED_SYNTAX",syntax:`${d.kind}_accessibility`,message:`${d.kind} accessibility metadata is carried in native comments on export. External Mermaid ignores this metadata; diagram topology is preserved.`})}const y=Bs(d);const p=d.meta.wrapperSource?.match(/\n/g)?.length??0;const b=On(a,M=>M+p);let S=$($($($(o,b),u),s),y?[{code:"EMPTY_DIAGRAM"}]:[]);if(d.body.kind==="class"&&(d.meta.accessibility.title!==void 0||d.meta.accessibility.descr!==void 0)){S=S.filter(M=>M.code!=="EMPTY_DIAGRAM")}if(d.body.kind==="sequence")return Fo(yd(d,r,t,n),S,t);if(d.body.kind==="timeline")return Fo(gd(d,r,t,n),S,t);if(d.body.kind==="gantt"){const M=Do(d);if(M){return T($(S,[M]),U(d.kind),t,false)}const w=ve(d,n);const k=w.layout;const C=$(vo(k),w.warnings);return T($(S,C),k,t)}if(d.body.kind==="class"||d.body.kind==="er"||d.body.kind==="journey"||d.body.kind==="architecture"||d.body.kind==="xychart"||d.body.kind==="pie"||d.body.kind==="quadrant"||d.body.kind==="mindmap"||d.body.kind==="gitgraph"||d.body.kind==="radar"||d.body.kind==="sankey"||d.body.kind==="c4"||d.body.kind==="packet"||d.body.kind==="kanban"||d.body.kind==="requirement"||d.body.kind==="block"||d.body.kind==="treemap"||d.body.kind==="zenuml"||d.body.kind==="eventmodeling"||d.body.kind==="ishikawa"){const M=ve(d,n);const w=M.layout;const k=d.body.kind==="class"||d.body.kind==="er"?We(w,{edgeAnchors:true,nodeOverlaps:true,groupContainment:d.body.kind==="class"}):We(w,{nodeOverlaps:d.body.kind==="journey"||d.body.kind==="c4",groupContainment:d.body.kind==="xychart"||d.body.kind==="quadrant"?"center":d.body.kind==="journey"||d.body.kind==="c4"});const C=d.body.kind==="radar"?nd(n):d.body.kind==="xychart"?ad(n):d.body.kind==="quadrant"?sd(n):d.body.kind==="c4"?rd(n):d.body.kind==="treemap"?od(n):[];const D=d.body.kind==="pie"||d.body.kind==="radar"?id(d.body.kind,n):[];return T($($($($(S,k),M.warnings),C),D),w,t)}if(d.body.kind==="state"){const M=mt(d.body);if(M.nodes.size===0)return T($([{code:"EMPTY_DIAGRAM"}],S),U(d.kind),t);const{warnings:w,layout:k}=No(M,d,r,n);return T($(w,S),k,t)}if(d.body.kind==="opaque"){const M=y;const w=O(d.kind);const k=(w?.extractLabels??Q)(d.body.source);const C=M?[{code:"EMPTY_DIAGRAM"}]:[];if(!M&&!S.some(N=>N.code==="UNSUPPORTED_SYNTAX")){C.push({code:"UNSUPPORTED_SYNTAX",syntax:`${d.kind}_opaque`,message:`This ${d.kind} diagram uses syntax the structured parser does not model; it is preserved verbatim as source. Typed mutation (the ${d.kind} \`as*\` narrower) is unavailable \u2014 edit the source directly, or verify/render it as-is.`})}const D=new Set;for(const N of k){const re=Z(N.target,N.text,r);if(!re)continue;const j=`${N.target}:${N.text}`;if(D.has(j))continue;D.add(j);C.push(re)}const ne=ve(d,n);const A=ne.layout;return T($($(C,S),ne.warnings),A,t,false)}const _=d.body.graph;if(_.nodes.size===0)return T([{code:"EMPTY_DIAGRAM"}],U(d.kind),t);const{warnings:P,layout:G}=No(_,d,r,n);return T($(P,S),G,t)}function ld(e,t,n,i,r){const o=[...i];const a=O(e.kind);const s=(a?.extractLabels??Q)(e.body.source);const d=new Set;for(const u of s){const y=Z(u.target,u.text,t);if(!y)continue;const p=`${u.target}:${u.text}`;if(d.has(p))continue;d.add(p);o.push(y)}const m=ve(e,r);return T([...o,...m.warnings],m.layout,n,false)}function ve(e,t){try{const n=t();return n?{layout:n.rendered,warnings:[]}:{layout:U(e.kind),warnings:[{code:"RENDER_FAILED",reason:`Mermaid family "${e.kind}" has no public layout projection registered`,origin:"config"}]}}catch(n){return{layout:U(e.kind),warnings:[t.failure(n)]}}}function No(e,t,n,i){const r=ud(e,n);const o=pd(e);let a;try{a=i()}catch(u){return{warnings:[i.failure(u),...r,...o],layout:U(t.kind)}}if(!a||!hd(a.positioned)){return{warnings:[{code:"UNSUPPORTED_SYNTAX",syntax:"positioned_artifact",message:`The ${t.kind} family did not produce its declared positioned-graph artifact.`},...r,...o],layout:U(t.kind)}}const s=a.positioned;const d=a.rendered;const m=[...r];m.push(...md(s,e));for(const u of Di(s,e)){m.push({code:"ROUTE_HITCH",edge:u.edge,deviationPx:u.deviationPx})}m.push(...vi(s,e));m.push(...o);return{warnings:m,layout:d}}function ud(e,t){const n=[];for(const i of e.edges){const r=e.nodes.has(i.source)||Boolean(Nt(e.subgraphs,i.source));const o=e.nodes.has(i.target)||Boolean(Nt(e.subgraphs,i.target));if(!r||!o){n.push({code:"EDGE_MISANCHORED",edge:`${i.source}->${i.target}`,from:r?i.source:void 0,to:o?i.target:void 0})}}for(const[i,r]of e.nodes){if(!Vs.has(r.shape))n.push({code:"UNKNOWN_SHAPE",node:i,shape:String(r.shape)});const o=Z(i,L(r.label,r.labelContent),t,"plain");if(o)n.push(o)}for(const i of e.edges){const r=i.label?Z(`${i.source}->${i.target}`,L(i.label,i.labelContent),t,"plain"):null;if(r)n.push(r)}return n}function md(e,t){const n=[];for(const i of e.nodes){if(i.x<0||i.x+i.width>e.width+1)n.push({code:"OFF_CANVAS",target:i.id,axis:"x"});if(i.y<0||i.y+i.height>e.height+1)n.push({code:"OFF_CANVAS",target:i.id,axis:"y"})}for(const i of e.groups){const r=o=>{const a=Nt(t.subgraphs,o.id);if(a)for(const s of e.nodes){if(!a.nodeIds.includes(s.id))continue;const d=s.x>=o.x&&s.y>=o.y&&s.x+s.width<=o.x+o.width+.5&&s.y+s.height<=o.y+o.height+.5;if(!d)n.push({code:"GROUP_BREACH",group:o.id,member:s.id})}for(const s of o.children)r(s)};r(i)}for(let i=0;i<e.nodes.length;i++){for(let r=i+1;r<e.nodes.length;r++){const o=e.nodes[i],a=e.nodes[r];const s=bd(o,a);if(s>0)n.push({code:"NODE_OVERLAP",a:o.id,b:a.id,areaPx:Math.round(s)})}}for(const i of e.edges){const r=xd(i.points);if(r>0)n.push({code:"ROUTE_SELF_CROSS",edge:`${i.source}->${i.target}`,count:r})}return n}function $(e,t){if(t.length===0)return e;const n=new Set(e.map(Vo));const i=t.filter(r=>!n.has(Vo(r)));return i.length===0?e:[...e,...i]}function fd(e,t,n){const i=O(e.kind);if(!i?.verify)return e.body.kind==="extension"?[{code:"RENDER_FAILED",reason:`Mermaid family "${e.kind}" has no verify hook registered`,origin:"config"}]:[];try{let r=e.body;if(e.body.kind==="extension"){const o=e;if(!Bn(o.descriptorIdentity,i.identity)){const a=v(V(e));if(!a.ok||a.value.kind!==e.kind||a.value.body.kind!=="extension"){return[{code:"RENDER_FAILED",reason:`Mermaid family "${e.kind}" could not reparse source under its current descriptor before verification`,origin:"source"}]}r=a.value.body}}return i.verify(r,t)}catch(r){return[n.failure(r,`Mermaid family "${e.kind}" verify hook failed: `)]}}function Fo(e,t,n){if(t.length===0)return e;const i=$(e.warnings,t);if(i===e.warnings)return e;const r=T(i,e.layout,n,false);return e.checks?.sourceLoss==="detected"?{...r,checks:{...r.checks,sourceLoss:"detected"}}:r}function Vo(e){if(e.code==="UNSUPPORTED_SYNTAX")return`${e.code}:${e.syntax}:${e.line??""}:${e.node??""}`;if(e.code==="RENDER_FAILED"||e.code==="INTERNAL_ERROR")return`${e.code}:${e.reason}`;if("target"in e)return`${e.code}:${e.target}`;if("edge"in e)return`${e.code}:${e.edge}`;if("node"in e)return`${e.code}:${e.node}`;if("group"in e)return`${e.code}:${e.group}`;if("a"in e&&"b"in e)return`${e.code}:${e.a}|${e.b}`;return e.code}function pd(e){const t=[];const n=ni(e.edges);const i=ti(e.edges).map((p,b)=>{const S=e.edges[b].id;return S&&n.get(S)===b?S:p});const r=new Map;e.edges.forEach((p,b)=>{const S=JSON.stringify({source:p.source,target:p.target,label:p.label??"",style:p.style,hasArrowStart:p.hasArrowStart,hasArrowEnd:p.hasArrowEnd,startMarker:p.startMarker??"arrow",endMarker:p.endMarker??"arrow"});const _=i[b];const P=r.get(S);if(P){t.push({code:"DUPLICATE_EDGE",edge:_,duplicateOf:P.edge,from:p.source,to:p.target,label:p.label})}else{r.set(S,{edge:_,from:p.source,to:p.target,label:p.label})}});const o=new Map;e.edges.forEach((p,b)=>{const S=e.nodes.get(p.source);if(!S||S.shape!=="diamond"||p.source===p.target)return;const _=o.get(p.source)??{labeled:0,unlabeled:[]};if(p.label&&p.label.trim().length>0)_.labeled++;else _.unlabeled.push(i[b]);o.set(p.source,_)});for(const[p,b]of o){if(b.labeled+b.unlabeled.length<2)continue;for(const S of b.unlabeled){t.push({code:"DECISION_BRANCH_UNLABELED",node:p,edge:S})}}const a=Array.from(e.nodes.keys());if(a.length===0||e.edges.length===0)return t;const s=new Map(a.map(p=>[p,0]));const d=new Map(a.map(p=>[p,[]]));for(const p of e.edges){if(!e.nodes.has(p.source)||!e.nodes.has(p.target))continue;s.set(p.target,(s.get(p.target)??0)+1);d.get(p.source).push(p.target)}const m=a.filter(p=>(s.get(p)??0)===0);if(m.length===0)return t;const u=new Set(m);const y=[...m];for(let p=0;p<y.length;p++){for(const b of d.get(y[p])??[]){if(u.has(b))continue;u.add(b);y.push(b)}}for(const p of a){if(!u.has(p))t.push({code:"UNREACHABLE_NODE",node:p})}return t}function gd(e,t,n,i){const r=e.body;const o=ve(e,i);const a=o.layout;const s=[];const d=r.sections.length>0||r.title!==void 0||r.accessibilityTitle!==void 0||r.accessibilityDescription!==void 0;if(!d)return T([{code:"EMPTY_DIAGRAM"}],a,n);const m=(u,y)=>{const p=y!==void 0?Z(u,y,t,"literal"):null;if(p)s.push(p)};m("title",r.title);for(const u of r.sections){m(u.id,u.label);for(const y of u.periods){m(y.id,y.label);for(const p of y.events)m(p.id,p.text)}}return T($($(s,We(a,{nodeOverlaps:true,groupContainment:true})),o.warnings),a,n)}function yd(e,t,n,i){const r=e.body;const o=ve(e,i);const a=o.layout;const s=[];const d=r.statements.some(b=>b.kind==="opaque-block"&&b.lines.some(S=>S.trim().length>0&&!Gt(S)));const m=ut(r);if(r.participants.length===0&&m.length===0&&!d){return T([{code:"EMPTY_DIAGRAM"}],a,n,false)}const u=new Set(r.participants.map(b=>b.id));m.forEach((b,S)=>{if(!u.has(b.from)||!u.has(b.to)){s.push({code:"EDGE_MISANCHORED",edge:`msg#${S}:${b.from}->${b.to}`,from:u.has(b.from)?b.from:void 0,to:u.has(b.to)?b.to:void 0})}const _=Z(`msg#${S}:${b.from}->${b.to}`,L(b.text,b.textContent),t);if(_)s.push(_)});for(const b of r.participants){const S=Z(b.id,L(b.label,b.labelContent),t);if(S)s.push(S)}for(const b of r.statements)if(b.kind==="fragment"){if(b.fragment.label){const S=Z(`fragment:${b.fragment.fragmentKind}`,L(b.fragment.label,b.fragment.labelContent),t);if(S)s.push(S)}for(const[S,_]of b.fragment.branches.entries())if(_.label){const P=Z(`fragment:${b.fragment.fragmentKind}:branch#${S}`,L(_.label,_.labelContent),t);if(P)s.push(P)}}const y=r.statements.filter(b=>b.kind==="opaque-block").flatMap(b=>b.lines).filter(b=>!Gt(b));if(y.length>0){s.push({code:"UNSUPPORTED_SYNTAX",syntax:"sequence_opaque_segment",message:"This sequence contains source-preserved constructs that are not represented in describe/facts or typed fragment operations. Inspect the source directly before relying on semantic read-back."});const b=O(e.kind);const S=(b?.extractLabels??Q)(y.join("\n"));const _=new Set;for(const P of S){const G=Le(P.text);const M=Z(P.target,L(G.value,G.content),t);if(!M)continue;const w=`${P.target}:${P.text}`;if(_.has(w))continue;_.add(w);s.push(M)}}const p=r.participants.length===0&&m.length===0;return T($($(s,We(a,{nodeOverlaps:true})),o.warnings),a,n,p)}function hd(e){const t=e;return Array.isArray(t.nodes)&&Array.isArray(t.edges)&&Array.isArray(t.groups)}function T(e,t,n,i=true){const r={renderability:"not-checked",sourceLoss:e.some(d=>d.code==="COMMENT_DROPPED"||d.code==="CONTENT_DROPPED_ON_ROUNDTRIP")?"detected":"not-detected",taskCorrectness:"not-checked"};const o=new Set(n.suppress??[]);const a=e.filter(d=>!o.has(d.code));const s=!a.some(d=>pe[d.code]==="error");if(i&&!o.has("UNSUPPORTED_SYNTAX")&&!a.some(d=>d.code==="RENDER_FAILED"||d.code==="INTERNAL_ERROR")&&t.nodes.length===0&&t.edges.length===0&&t.groups.length===0&&t.bounds.w===0&&t.bounds.h===0&&!a.some(d=>d.code==="EMPTY_DIAGRAM")&&!a.some(d=>d.code==="UNSUPPORTED_SYNTAX"&&d.syntax==="empty_layout")){return{ok:s,checks:r,warnings:[...a,{code:"UNSUPPORTED_SYNTAX",syntax:"empty_layout",message:"The source carries content, but the local layout renders nothing (0x0 canvas with no nodes, edges, or groups)."}],layout:t}}return{ok:s,warnings:a,layout:t,checks:r}}function bd(e,t){const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x));const i=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return n*i}function xd(e){if(e.length<4)return 0;let t=0;for(let n=0;n<e.length-1;n++)for(let i=n+2;i<e.length-1;i++){if(n===0&&i===e.length-2)continue;if(kd(e[n],e[n+1],e[i],e[i+1]))t++}return t}function kd(e,t,n,i){const r=Tt(i.x-n.x,i.y-n.y,e.x-n.x,e.y-n.y);const o=Tt(i.x-n.x,i.y-n.y,t.x-n.x,t.y-n.y);const a=Tt(t.x-e.x,t.y-e.y,n.x-e.x,n.y-e.y);const s=Tt(t.x-e.x,t.y-e.y,i.x-e.x,i.y-e.y);return(r>0&&o<0||r<0&&o>0)&&(a>0&&s<0||a<0&&s>0)}function Tt(e,t,n,i){return e*i-n*t}function Nt(e,t){for(const n of e){if(n.id===t)return n;const i=Nt(n.children,t);if(i)return i}return null}function jo(e){return JSON.parse(JSON.stringify({ok:e.ok,warnings:e.warnings,checks:e.checks}))}function qo(e){try{if(!Array.isArray(e)||Object.getPrototypeOf(e)!==Array.prototype)return{ok:false};const t=Object.getOwnPropertyDescriptors(e);const n=t.length?.value;if(!Number.isSafeInteger(n)||n<0)return{ok:false};const i=Reflect.ownKeys(e);if(i.some(o=>typeof o==="symbol"||o!=="length"&&!/^(0|[1-9]\d*)$/.test(o)))return{ok:false};const r=[];for(let o=0;o<n;o++){const a=t[String(o)];if(!a||!("value"in a)||a.enumerable!==true)return{ok:false};r.push(a.value)}return{ok:true,value:r}}catch{return{ok:false}}}function Wo(e,t,n){const i=qo(t);if(!i.ok){return E({code:"INVALID_OP",message:"`ops` must be an array of op objects",opIndex:-1})}const r=i.value;let o;try{o=Pt(e,n)}catch(a){return E({code:"INVALID_OP",message:a instanceof Error?a.message:String(a),opIndex:-1})}return qe(o,r)}function Sd(e){let t;let n;let i;let r;try{if(!Hn(e)){return{ok:false,family:null,error:{code:"INVALID_OP",message:"applyOps input must be a plain object"}}};({source:t,family:n,ops:i,mode:r}=e)}catch{return{ok:false,family:null,error:{code:"INVALID_OP",message:"applyOps input must be a readable plain object"}}}const o=qo(i);if(!o.ok){return{ok:false,family:typeof n==="string"&&ee(n)?n:null,error:{code:"INVALID_OP",message:"`ops` must be an array of op objects"}}}const a=o.value;if(r!==void 0&&r!=="structured"&&r!=="source-preserving")return{ok:false,family:null,error:{code:"INVALID_OP",message:"`mode` must be structured or source-preserving"}};if(r==="source-preserving"&&typeof t!=="string")return{ok:false,family:null,error:{code:"INVALID_OP",message:"Source-preserving mode requires existing source, not a blank-slate build"}};if(t!==void 0&&typeof t!=="string"){return{ok:false,family:null,error:{code:"INVALID_OP",message:"`source` must be a string when provided"}}}if(n!==void 0&&typeof n!=="string"){return{ok:false,family:null,error:{code:"INVALID_OP",message:"`family` must be a string when provided"}}}if(typeof t==="string"&&typeof n==="string"){return{ok:false,family:ee(n)?n:null,error:{code:"INVALID_OP",message:"applyOps accepts either `source` or `family`, not both"}}}let s;let d;if(typeof t==="string"&&t.trim().length>0){const u=v(t);if(!u.ok){const y=u.error[0];return{ok:false,family:null,error:{code:y?.code??"PARSE_ERROR",message:u.error.map(p=>p.message).join("; ")||"could not parse source"}}}s=u.value;d=s;if(!ee(s.kind)){return{ok:false,family:s.kind,error:{code:"INVALID_OP",message:`family "${s.kind}" has no structured ops; edit it as source text`}}}if(a.length===0){return{ok:false,family:s.kind,error:{code:"INVALID_OP",message:"`ops` must contain at least one op object"}}}}else if(typeof n==="string"){if(!ee(n)){return{ok:false,family:null,error:{code:"INVALID_OP",message:`unknown family "${n}"`}}}if(a.length===0){return{ok:false,family:n,error:{code:"INVALID_OP",message:"`ops` must contain at least one op object"}}}const u=Wo(n,a);if(!u.ok){const{opIndex:y,...p}=u.error;return{ok:false,family:n,opIndex:y>=0?y:void 0,error:p}}return Cn(u.value)}else{return{ok:false,family:null,error:{code:"INVALID_OP",message:"applyOps requires either `source` (to edit) or `family` (to build)"}}}if(r==="source-preserving"){let u=d,y=t;for(let p=0;p<a.length;p++){const b=Rn(u,a[p]);if(!b.ok)return{ok:false,family:s.kind,opIndex:p,error:b.error};u=b.value.diagram;y=b.value.source}return Cn(u,d,y)}const m=qe(s,a);if(!m.ok){const{opIndex:u,...y}=m.error;return{ok:false,family:s.kind,opIndex:u,error:y}}s=m.value;return Cn(s,d)}function Rd(e,t){const n=Ae(e);if(n.checks?.sourceLoss==="detected")return{accepted:false,verification:n};if(n.ok)return{accepted:true,verification:n};const i=n.warnings.filter(r=>pe[r.code]==="error");if(t&&i.length>0&&i.every(r=>r.code==="INTERNAL_ERROR")){const r=a=>a.code==="INTERNAL_ERROR"?`${a.defaultRender}\0${a.reason}`:void 0;const o=new Set(Ae(t).warnings.map(r).filter(a=>a!==void 0));if(i.every(a=>o.has(r(a))))return{accepted:true,verification:n}}if(e.body.kind==="opaque"||e.body.kind==="preserved"||e.body.kind==="extension"||!O(e.kind)?.mutate||i.length===0||i.some(r=>r.code!=="EMPTY_DIAGRAM")){return{accepted:false,verification:n}}try{_t(V(e));return{accepted:true,verification:n}}catch(r){return{accepted:false,verification:{...n,warnings:[...n.warnings,Ft(r,()=>"fails")]}}}}function Cn(e,t,n){const{accepted:i,verification:r}=Rd(e,t);const o=jo(r);if(!i){return{ok:false,family:e.kind,error:{code:"VERIFY_FAILED",message:"mutated diagram failed verify; source was not emitted",details:o.warnings}}}return{ok:true,family:e.kind,source:n??V(e),...n!==void 0?{mode:"source-preserving"}:{},verify:o}}function Ed(e){if("elementId"in e)return vd(e);return _d(e)}function _d(e){if("family"in e)return $d(e);return Md(e)}function Md(e){switch(e.invariant){case"straight":case"explained-detour":case"bundle":case"outer-feedback":case"feedback-detour":case"self-loop":case"container-attach":case"unverified-shape":return"edge-route";default:return Re(e)}}function $d(e){switch(e.family){case"class":case"er":return Od(e.invariant);case"architecture":return Cd(e.invariant);case"zenuml":case"sequence":return Dd(e.invariant);default:return Re(e)}}function Od(e){switch(e){case"orthogonal-box":case"unverified-family-route":return"edge-route";default:return Re(e)}}function Cd(e){switch(e){case"side-anchored":case"unverified-family-route":return"edge-route";default:return Re(e)}}function Dd(e){switch(e){case"lifeline-message":case"self-message":case"unverified-family-route":return"edge-route";default:return Re(e)}}function vd(e){switch(e.family){case"timeline":case"xychart":case"pie":case"quadrant":case"gantt":return Ad(e.invariant);default:return Re(e.family)}}function Ad(e){switch(e){case"timeline-interval":case"plot-contained":case"legend-contained":case"section-contained":case"unverified-family-layout":return"region-containment";default:return Re(e)}}function Re(e){throw new Error(`Unhandled layout certificate variant: ${JSON.stringify(e)}`)}function Ue(e){const t=[];f(t,`family ${e.kind}`);if(e.meta.accessibility.title)f(t,`accessibility title ${c(e.meta.accessibility.title)}`);if(e.meta.accessibility.descr)f(t,`accessibility descr ${c(e.meta.accessibility.descr)}`);switch(e.body.kind){case"flowchart":{const n=e.body.graph;f(t,`direction ${n.direction}`);for(const r of n.nodes.values()){f(t,`node ${c(r.id)} : ${c(r.label||r.id)}`);f(t,`node ${c(r.id)} shape ${c(r.shape)}`)}const i=(r,o)=>{for(const a of r){f(t,`group ${c(a.id)} : ${c(a.label||a.id)}`);if(o)f(t,`group ${c(a.id)} parent ${c(o)}`);if(a.direction)f(t,`group ${c(a.id)} direction ${a.direction}`);for(const s of a.nodeIds)f(t,`group ${c(a.id)} contains ${c(s)}`);i(a.children,a.id)}};i(n.subgraphs);n.edges.forEach((r,o)=>{const a=`edge ${c(r.source)} -> ${c(r.target)}`;f(t,r.label?`${a} : ${c(r.label)}`:a);f(t,`edge#${o} ${c(r.source)} -> ${c(r.target)}${r.label?` : ${c(r.label)}`:""}`);if(r.style!=="solid")f(t,`${a} style ${r.style}`)});break}case"state":wd(t,e.body);break;case"sequence":Ld(t,e.body);break;case"timeline":Td(t,e.body);break;case"class":Nd(t,e.body);break;case"er":Fd(t,e.body);break;case"journey":Vd(t,e.body);break;case"architecture":Bd(t,e.body);break;case"xychart":jd(t,e.body);break;case"pie":qd(t,e.body);break;case"quadrant":Wd(t,e.body);break;case"gantt":Gd(t,e.body);break;case"mindmap":Ud(t,e.body);break;case"gitgraph":Hd(t,e.body);break;case"radar":{if(e.body.title!==void 0)f(t,`title ${c(e.body.title)}`);e.body.axes.forEach((n,i)=>f(t,`axis#${i} ${c(n.id)} : ${c(n.label)}`));e.body.curves.forEach((n,i)=>f(t,`curve#${i} ${c(n.id)} : ${c(n.label)} {${n.values.join(",")}}`));f(t,`scale ${e.body.min}..${e.body.max??"auto"} ticks ${e.body.ticks} graticule ${e.body.graticule}`);break}case"c4":{const n=e.body;const i=r=>/^[A-Za-z_][A-Za-z_0-9-]*$/.test(r)?r:JSON.stringify(r);f(t,`variant ${n.variant}`);if(n.title!==void 0)f(t,`title ${c(n.title)}`);for(const r of n.boundaries){f(t,`boundary ${i(r.id)} ${r.kind} : ${c(r.label)}`);if(r.parentId!==void 0)f(t,`boundary ${i(r.id)} parent ${i(r.parentId)}`);if(r.type!==void 0)f(t,`boundary ${i(r.id)} type ${c(r.type)}`);if(r.description!==void 0)f(t,`boundary ${i(r.id)} description ${c(r.description)}`)}for(const r of n.elements){f(t,`element ${i(r.id)} ${r.kind} ${r.external?"external":"internal"} ${r.shape} : ${c(r.label)}`);if(r.parentId!==void 0)f(t,`element ${i(r.id)} parent ${i(r.parentId)}`);if(r.technology!==void 0)f(t,`element ${i(r.id)} technology ${c(r.technology)}`);if(r.description!==void 0)f(t,`element ${i(r.id)} description ${c(r.description)}`)}for(const r of n.relationships){f(t,`interaction#${r.order} ${i(r.id)} ${i(r.source)} ${r.bidirectional?"<->":"->"} ${i(r.target)} : ${c(r.label)}`);f(t,`interaction#${r.order} macro ${r.macro} authored ${i(r.from)} -> ${i(r.to)}`);if(r.index!==void 0)f(t,`interaction#${r.order} index ${c(r.index)}`);if(r.technology!==void 0)f(t,`interaction#${r.order} technology ${c(r.technology)}`);if(r.description!==void 0)f(t,`interaction#${r.order} description ${c(r.description)}`);if(r.direction!==void 0)f(t,`interaction#${r.order} direction ${r.direction}`)}for(const r of[...n.elements,...n.boundaries,...n.relationships]){if(r.tags.length)f(t,`c4 ${i(r.id)} tags ${r.tags.map(i).join(",")}`);if(r.link!==void 0)f(t,`c4 ${i(r.id)} link ${JSON.stringify(r.link)}`);if(r.effectiveLink!==void 0)f(t,`c4 ${i(r.id)} effective link ${JSON.stringify(r.effectiveLink)}`);if(r.sprite!==void 0)f(t,`c4 ${i(r.id)} sprite ${JSON.stringify(r.sprite)}`);for(const o of Object.keys(r.style).sort())f(t,`c4 ${i(r.id)} style ${o} ${JSON.stringify(r.style[o])}`)}break}case"sankey":{e.body.links.forEach((n,i)=>f(t,`link#${i} ${c(n.source)} -> ${c(n.target)} : ${n.value}`));break}case"zenuml":{if(e.body.title!==void 0)f(t,`title ${JSON.stringify(e.body.title)}`);const n=xe(e.body,{message:({message:i,kind:r,callAncestors:o,scopes:a})=>{f(t,`message#${c(i.id)} kind ${r}`);if(o.length)f(t,`message#${c(i.id)} call-parent ${c(o.at(-1))}`);for(const s of a)f(t,`message#${c(i.id)} fragment#${c(s.fragmentId)} branch#${s.branchIndex}`)},note:({note:i,callAncestors:r,scopes:o})=>{f(t,`note#${c(i.id)} ${i.position} ${i.actorIds.map(a=>JSON.stringify(a)).join(",")} after-index ${i.afterIndex} : ${c(X(L(i.text,i.textContent)))}`);if(r.length)f(t,`note#${c(i.id)} call-parent ${c(r.at(-1))}`);for(const a of o)f(t,`note#${c(i.id)} fragment#${c(a.fragmentId)} branch#${a.branchIndex}`)},fragment:({fragment:i,branches:r,callAncestors:o,scopes:a})=>{f(t,`fragment#${c(i.id)} kind ${i.type}`);if(o.length)f(t,`fragment#${c(i.id)} call-parent ${c(o.at(-1))}`);const s=a.at(-1);if(s)f(t,`fragment#${c(i.id)} parent ${c(s.fragmentId)} branch#${s.branchIndex}`);r.forEach((d,m)=>{const u=m===0?i.condition:d.condition;f(t,`fragment#${c(i.id)} branch#${m} ${d.kind}${u===void 0?"":` : ${c(u)}`}`)})}});for(const i of n.actors)if(!i.external){f(t,`participant ${c(i.id)} : ${c(i.label)}`);f(t,`participant ${c(i.id)} type ${i.type}`)}for(const i of n.actors)if(i.external)f(t,`external-endpoint ${c(i.id)}`);for(const i of n.messages){f(t,`message ${c(i.from)} -> ${c(i.to)} : ${c(i.label)}`);f(t,`message#${c(i.id)} ${c(i.from)} -> ${c(i.to)} : ${c(i.label)}${i.lineStyle==="dashed"?" reply":""}`);if(i.parentId)f(t,`message#${c(i.id)} parent ${c(i.parentId)}`)}for(const i of n.blocks)f(t,`fragment ${c(i.id)} ${i.type} : ${c(i.label)}`);break}case"eventmodeling":if(e.body.title!==void 0)f(t,`title ${JSON.stringify(e.body.title)}`);e.body.frames.forEach((n,i)=>f(t,`frame#${i} ${JSON.stringify(n)}`));ke(e.body).forEach(n=>f(t,`relation ${n.from} -> ${n.to} ${n.explicit?"explicit":"inferred"}`));Object.entries(e.body.data).forEach(([n,i])=>f(t,`data ${n} ${JSON.stringify(i)}`));e.body.notes.forEach(n=>f(t,`note ${JSON.stringify(n)}`));e.body.specifications.forEach(n=>f(t,`specification ${JSON.stringify(n)}`));break;case"packet":case"kanban":case"requirement":case"block":case"treemap":case"ishikawa":t.push(...Pr(e.body));break;case"opaque":{f(t,`opaque ${e.body.family}`);const n=O(e.kind);const i=(n?.extractLabels??Q)(e.body.source);i.forEach((r,o)=>f(t,`label#${o} ${c(r.target||"")} : ${c(r.text)}`));break}case"extension":{const n=O(e.kind);const i=(n?.extractLabels??Q)(e.body.source);i.forEach((r,o)=>f(t,`label#${o} ${c(r.target||"")} : ${c(r.text)}`));break}case"preserved":f(t,`preserved ${e.body.preservation.upstreamFamilyId??e.body.preservation.header}`);break;default:{const n=e.body;void n}}return Array.from(new Set(t)).sort()}function Id(e){const t=v(e);return t.ok?q(Ue(t.value)):E(t.error)}function Uo(e,t){const n=Ue(e);const i=new Set(n);const r=Yd(t);const o=zd(t);const a=r.filter(d=>!i.has(d));let s=o.filter(d=>i.has(d));if(vn(t)&&t.exact){const d=new Set(r);s=[...s,...n.filter(m=>!d.has(m))]}s=Array.from(new Set(s)).sort();return{ok:a.length===0&&s.length===0,missing:a,unexpected:s,facts:n}}function Pd(e,t){const n=v(e);return n.ok?q(Uo(n.value,t)):E(n.error)}function wd(e,t){if(t.direction)f(e,`direction ${t.direction}`);const n=(i,r,o)=>{for(const a of i){f(e,`state ${c(a.id)}`);if(a.label)f(e,`state ${c(a.id)} : ${c(a.label)}`);if(a.stereotype)f(e,`state ${c(a.id)} stereotype ${c(a.stereotype)}`);if(o)f(e,`state ${c(a.id)} parent ${c(o)}`);if(a.states!==void 0||a.regions!==void 0){f(e,`composite ${c(a.id)}`);if(a.direction)f(e,`state ${c(a.id)} direction ${a.direction}`);if(a.regions)a.regions.forEach((s,d)=>{f(e,`state ${c(a.id)} region ${d}`);n(s.states,s.transitions,a.id)});else n(a.states??[],a.transitions??[],a.id)}if(a.className)f(e,`state ${c(a.id)} class ${c(a.className)}`);if(a.style)f(e,`state ${c(a.id)} styled`)}for(const a of r)f(e,Dn(a.from,a.to,a.label))};n(t.states,t.transitions);for(const[i,r]of(t.notes??[]).entries()){f(e,`note#${i} ${r.side} of ${c(r.target)} : ${c(r.text)}`)}for(const i of t.floatingNotes??[]){f(e,`floating note ${c(i.id)}${i.scope?` in ${c(i.scope.parent)}${i.scope.region!==void 0?` region ${i.scope.region}`:""}`:""} : ${c(i.text)}`)}}function Ld(e,t){t.participants.forEach((i,r)=>{f(e,`${i.kind} ${c(i.id)} : ${c(i.label||i.id)}`);f(e,`participant#${r} ${c(i.id)} : ${c(i.label||i.id)}`);if(i.wrap!==void 0)f(e,`participant#${r} wrap ${i.wrap}`)});lt(t).forEach((i,r)=>{const o=i.message;f(e,`message ${c(o.from)} -> ${c(o.to)} : ${c(o.text)}`);f(e,`message#${r} ${i.scope==="top-level"?"top-level":`fragment#${i.fragmentIndex} branch#${i.branchIndex}`} ${c(o.from)} -> ${c(o.to)} : ${c(o.text)}`);if(o.style!=="sync")f(e,`message#${r} style ${o.style}`);if(o.wrap!==void 0)f(e,`message#${r} wrap ${o.wrap}`)});t.statements.forEach((i,r)=>{if(i.kind!=="opaque-block")return;sr(i.lines).statements.forEach((o,a)=>{const s=o.syntax;if(s?.kind==="message"){const d=s.message;const m=c(Le(d.label).value);f(e,`message ${c(d.from)} -> ${c(d.to)} : ${m}`);f(e,`preserved-message#${r}.${a} ${c(d.from)} -> ${c(d.to)} : ${m}`)}else if(s?.kind==="title")f(e,`title ${c(Le(s.text).value)}`)})});const n=t.statements.filter(i=>i.kind==="fragment");n.forEach((i,r)=>{if(i.kind!=="fragment")return;f(e,`fragment#${r} ${i.fragment.fragmentKind}`);if(i.fragment.wrap!==void 0)f(e,`fragment#${r} wrap ${i.fragment.wrap}`);i.fragment.branches.forEach((o,a)=>{const s=o.label??(a===0?i.fragment.label:void 0);f(e,`fragment#${r} branch#${a}${s?` : ${c(s)}`:""}`);if(o.wrap!==void 0)f(e,`fragment#${r} branch#${a} wrap ${o.wrap}`)})})}function Td(e,t){if(t.title)f(e,`title ${c(t.title)}`);t.sections.forEach((n,i)=>{if(n.label)f(e,`section ${c(n.label)}`);n.periods.forEach((r,o)=>{f(e,`period ${c(r.label)}`);if(n.label)f(e,`period ${c(r.label)} section ${c(n.label)}`);r.events.forEach((a,s)=>{f(e,`event ${c(r.label)} : ${c(a.text)}`);f(e,`event#${i}.${o}.${s} ${c(r.label)} : ${c(a.text)}`)})})})}function Nd(e,t){if(t.title)f(e,`title ${c(t.title)}`);for(const n of t.namespaces??[]){f(e,`namespace ${c(n.name)}${n.label?` : ${c(n.label)}`:""}`)}for(const n of t.classes){if(n.isInterface){f(e,`interface ${c(n.id)} : ${c(n.label??n.id)}`);continue}f(e,`class ${c(n.id)}`);if(n.generic)f(e,`class ${c(n.id)} generic ${c(n.generic)}`);if(n.label)f(e,`class ${c(n.id)} : ${c(n.label)}`);if(n.namespace)f(e,`class ${c(n.id)} in namespace ${c(n.namespace)}`);for(const i of n.members)f(e,`member ${c(n.id)} ${c(i)}`)}t.relations.forEach((n,i)=>{const r=`${n.fromCardinality?` ${c(n.fromCardinality)}`:""}${n.toCardinality?` ${c(n.toCardinality)}`:""}`;f(e,`relation ${c(n.from)} ${n.kind} ${c(n.to)}${n.label?` : ${c(n.label)}`:""}`);f(e,`relation#${i} ${c(n.from)} ${n.kind} ${c(n.to)}${r}${n.label?` : ${c(n.label)}`:""}`);const o=zr(n);f(e,`relation#${i} ${c(n.from)} ${n.kind} ${c(n.to)} marker ${o.at}`);f(e,`relation#${i} ${c(n.from)} ${n.kind} ${c(n.to)} line ${Kr(n)}`);if(o.at==="both"){f(e,`relation#${i} from marker ${o.from}`);f(e,`relation#${i} to marker ${o.to}`)}});t.notes.forEach((n,i)=>f(e,`note#${i}${n.for?` ${c(n.for)}`:""} : ${c(n.text)}`))}function Fd(e,t){if(t.direction)f(e,`direction ${t.direction}`);for(const n of t.groups??[])f(e,`er group ${c(n.id)} label ${c(n.label)}${n.parentId?` parent ${c(n.parentId)}`:""}${n.direction?` direction ${n.direction}`:""}`);for(const n of t.entities){f(e,`entity ${c(n.id)}${n.label?` label ${c(n.label)}`:""}${n.groupId?` group ${c(n.groupId)}`:""}`);if(n.className)f(e,`entity ${c(n.id)} class ${c(n.className)}`);if(n.style)f(e,`entity ${c(n.id)} styled`);for(const i of n.attributes)f(e,`attribute ${c(n.id)} ${c(i.text)}`)}t.relations.forEach((n,i)=>{const r=`relation ${c(n.from)} ${n.leftCard} ${n.dashed?"..":"--"} ${n.rightCard} ${c(n.to)}${n.label?` : ${c(n.label)}`:""}`;f(e,r);f(e,`relation#${i} ${r.slice("relation ".length)}`)})}function Vd(e,t){const n=(o,a)=>c(X(L(o,a)));if(t.title)f(e,`title ${n(t.title,t.titleContent)}`);t.sections.forEach((o,a)=>{if(o.label)f(e,`section ${n(o.label,o.labelContent)}`);o.tasks.forEach((s,d)=>{const m=s.actors.length?` actors ${s.actors.map((u,y)=>n(u,s.actorContents?.[y])).join(", ")}`:"";f(e,`journey task ${n(s.text,s.textContent)} score ${String(s.score)}${m}`);f(e,`journey task#${a}.${d} ${n(s.text,s.textContent)} score ${String(s.score)}${m}`);if(o.label)f(e,`journey task ${n(s.text,s.textContent)} section ${n(o.label,o.labelContent)}`)})});const i=t.sections.flatMap(o=>o.tasks);f(e,`journey sections ${t.sections.length}`);f(e,`journey tasks ${i.length}`);const r=new Map;for(const o of i)for(const[a,s]of o.actors.entries()){const d=ct(s,o.actorContents?.[a]);r.set(d,{actor:n(s,o.actorContents?.[a]),count:(r.get(d)?.count??0)+1})}f(e,`journey actors ${r.size}`);if(i.length>0){const o=i.map(m=>m.score);const a=Math.min(...o);const s=Math.max(...o);const d=Math.round(o.reduce((m,u)=>m+u,0)/o.length*100)/100;f(e,`journey score range ${a}..${s}`);f(e,`journey average score ${te(d)}`);for(const m of i){if(m.score===a)f(e,`journey lowest task ${n(m.text,m.textContent)} score ${String(m.score)}`);if(m.score===s)f(e,`journey highest task ${n(m.text,m.textContent)} score ${String(m.score)}`)}}for(const{actor:o,count:a}of r.values())f(e,`journey actor ${o} tasks ${a}`)}function Bd(e,t){if(t.title)f(e,`title ${c(t.title)}`);if(t.accessibilityTitle)f(e,`accessibility title ${c(t.accessibilityTitle)}`);if(t.accessibilityDescription)f(e,`accessibility description ${c(t.accessibilityDescription)}`);for(const n of t.groups){f(e,`group ${c(n.id)} : ${c(n.label||n.id)}`);if(n.icon)f(e,`group ${c(n.id)} icon ${c(n.icon)}`);if(n.parentId)f(e,`group ${c(n.id)} parent ${c(n.parentId)}`)}for(const n of t.services){f(e,`service ${c(n.id)} : ${c(n.label||n.id)}`);if(n.icon)f(e,`service ${c(n.id)} icon ${c(n.icon)}`);if(n.parentId)f(e,`service ${c(n.id)} parent ${c(n.parentId)}`)}for(const n of t.junctions){f(e,`junction ${c(n.id)}`);if(n.parentId)f(e,`junction ${c(n.id)} parent ${c(n.parentId)}`)}t.edges.forEach((n,i)=>{const r=`${c(n.source.id)}${n.source.boundary==="group"?"{group}":""}:${n.source.side}`;const o=`${c(n.target.id)}${n.target.boundary==="group"?"{group}":""}:${n.target.side}`;const a=`edge ${r} -> ${o}`;f(e,n.label?`${a} : ${c(n.label)}`:a);f(e,`edge#${i} ${r} -> ${o}${n.label?` : ${c(n.label)}`:""}`)})}function jd(e,t){if(t.title)f(e,`title ${c(de(t.title))}`);if(t.horizontal)f(e,"orientation horizontal");Go(e,"x-axis",t.xAxis);Go(e,"y-axis",t.yAxis);t.series.forEach((n,i)=>{const r=n.name?c(de(n.name)):`series#${i}`;f(e,`series ${r} ${n.kind} [${n.values.map(te).join(",")}]`);f(e,`series#${i} ${n.kind} ${r} [${n.values.map(te).join(",")}]`);n.pointLabels?.forEach((o,a)=>{if(o!==void 0)f(e,`series#${i} point#${a} : ${c(o)}`)})})}function qd(e,t){if(t.title)f(e,`title ${c(de(t.title))}`);if(t.showData)f(e,"showData true");t.slices.forEach((n,i)=>{f(e,`slice ${c(de(n.label))} = ${te(n.value)}`);f(e,`slice#${i} ${c(de(n.label))} = ${te(n.value)}`)})}function Wd(e,t){if(t.title)f(e,`title ${c(de(t.title))}`);if(t.xAxis)f(e,`x-axis ${c(t.xAxis.near)}${t.xAxis.far?` -> ${c(t.xAxis.far)}`:""}`);if(t.yAxis)f(e,`y-axis ${c(t.yAxis.near)}${t.yAxis.far?` -> ${c(t.yAxis.far)}`:""}`);t.quadrants.forEach((n,i)=>{if(n)f(e,`quadrant ${i+1} : ${c(n)}`)});t.points.forEach((n,i)=>{f(e,`point ${c(de(n.label))} @ ${te(n.x)},${te(n.y)}`);f(e,`point#${i} ${c(de(n.label))} @ ${te(n.x)},${te(n.y)}`)})}function Gd(e,t){if(t.title)f(e,`title ${c(t.title)}`);t.sections.forEach((n,i)=>{if(n.label)f(e,`section ${c(n.label)}`);n.tasks.forEach((r,o)=>{f(e,`task ${c(r.label)}`);f(e,`task#${i}.${o} ${c(r.label)}`);if(r.taskId)f(e,`task ${c(r.label)} id ${c(r.taskId)}`);if(n.label)f(e,`task ${c(r.label)} section ${c(n.label)}`);for(const a of r.tags)f(e,`task ${c(r.label)} tag ${a}`);if(r.start)f(e,`task ${c(r.label)} start ${c(r.start)}`);f(e,`task ${c(r.label)} end ${c(r.end)}`)})})}function Ud(e,t){const n=(i,r)=>{f(e,`node ${c(i.id)} : ${c(i.label)}`);f(e,`node ${c(i.id)} shape ${i.shape}`);if(r)f(e,Dn(r,i.id));if(i.icon)f(e,`node ${c(i.id)} icon ${c(i.icon)}`);if(i.className)f(e,`node ${c(i.id)} class ${c(i.className)}`);i.children.forEach(o=>n(o,i.id))};n(t.root)}function Hd(e,t){f(e,`direction ${t.direction}`);for(const n of t.branches){f(e,`branch ${c(n.name)} order ${n.order}`);if(n.head)f(e,`branch ${c(n.name)} head ${c(n.head)}`)}for(const n of t.commits){f(e,`commit ${c(n.id)} branch ${c(n.branch)}`);f(e,`commit ${c(n.id)} type ${n.type}`);if(n.sourceId)f(e,`commit ${c(n.id)} source-id ${c(n.sourceId)}`);if(n.message)f(e,`commit ${c(n.id)} message ${c(n.message)}`);n.tags.forEach(i=>f(e,`commit ${c(n.id)} tag ${c(i)}`));n.parents.forEach(i=>f(e,Dn(i,n.id,n.source==="commit"?void 0:n.source)))}}function Go(e,t,n){if(!n)return;if(n.name)f(e,`${t} name ${c(de(n.name))}`);if(n.categories)f(e,`${t} categories ${n.categories.map(i=>c(de(i))).join(", ")}`);if(n.range)f(e,`${t} range ${te(n.range.min)} -> ${te(n.range.max)}`)}function Dn(e,t,n){return`edge ${c(e)} -> ${c(t)}${n?` : ${c(n)}`:""}`}function f(e,t){e.push(t.replace(/\s+$/g,""))}function c(e){return String(e??"").trim().replace(/\r\n/g,"\n").replace(/\r/g,"\n").replace(/\n/g,"\\n").replace(/\t/g,"\\t")}function de(e){return e.replace(/^"(.*)"$/,"$1")}function te(e){return Number.isInteger(e)?String(e):String(Number(e.toPrecision(12)))}function se(e){if(!Array.isArray(e))return[];return e.map(t=>typeof t==="string"?t:String(t))}function Yd(e){if(Array.isArray(e))return se(e);if(!vn(e))return[];return Ho([...se(e.include),...se(e.expected),...se(e.require),...se(e.required)])}function zd(e){if(!vn(e))return[];return Ho([...se(e.exclude),...se(e.absent),...se(e.forbid),...se(e.forbidden),...se(e.unexpected)])}function vn(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function Ho(e){return Array.from(new Set(e))}var Kd=["text","json","facts"];function jp(e){return Kd.includes(e)}function Xd(e,t={}){const n=v(e);if(!n.ok){const i=Array.isArray(n.error)?n.error[0]:void 0;if(t.format==="json"){return JSON.stringify({error:i?.message??"parse error",nodes:[],edges:[]})}if(t.format==="facts")return`error parse ${i?.message??"parse error"}`;return`Unparseable Mermaid source: ${i?.message??"parse error"}.`}return zo(n.value,t)}function zo(e,t={}){if(t.format==="json")return JSON.stringify(Ko(e));if(t.format==="facts")return Ue(e).join("\n");if(e.body.kind==="flowchart")return Zd(e);if(e.body.kind==="state")return ec(e.body);if(e.body.kind==="sequence")return tc(e);if(e.body.kind==="timeline")return nc(e);if(e.body.kind==="class")return dc(e);if(e.body.kind==="er")return cc(e);if(e.body.kind==="journey")return rc(e.body);if(e.body.kind==="architecture")return ic(e.body);if(e.body.kind==="xychart")return oc(e.body);if(e.body.kind==="gantt")return lc(e);if(e.body.kind==="pie")return ac(e.body);if(e.body.kind==="quadrant")return sc(e.body);if(e.body.kind==="mindmap")return Jd(e.body);if(e.body.kind==="gitgraph")return Qd(e.body);if(e.body.kind==="radar"){const i=e.body.axes.map(a=>a.label).join(", ");const r=e.body.curves.map(a=>a.label).join(", ");const o=e.body.title?`"${e.body.title}" `:"";return`A radar chart ${o}comparing ${e.body.curves.length} curve(s)${r?` (${r})`:""} across ${e.body.axes.length} axis/axes${i?` (${i})`:""}.`}if(e.body.kind==="c4")return`A ${e.body.variant} architecture diagram${e.body.title?` "${e.body.title}"`:""} with ${e.body.elements.length} element(s), ${e.body.boundaries.length} boundary/boundaries and ${e.body.relationships.length} interaction(s).`;if(e.body.kind==="sankey"){const i=new Set;for(const o of e.body.links){i.add(o.source);i.add(o.target)}const r=e.body.links.reduce((o,a)=>o+a.value,0);return`A sankey diagram flowing ${r} across ${e.body.links.length} link(s) between ${i.size} node(s).`}if(e.body.kind==="zenuml"){const i=xe(e.body);return`A ZenUML interaction${i.title===void 0?"":` titled ${JSON.stringify(i.title)}`} with ${i.actors.filter(r=>!r.external).length} participants, ${i.messages.length} messages and ${i.blocks.length} control scopes.`}if(e.body.kind==="eventmodeling")return`An Event Modeling diagram with ${e.body.frames.length} frames and ${ke(e.body).length} relations.`;if(Xt(e.body)){const i=dt(e.body);return`A ${e.kind} diagram with ${i.nodes} item(s), ${i.groups} group(s) and ${i.edges} relationship(s).`}if(e.body.kind==="opaque")return Yo(e.kind,e.body.source);if(e.body.kind==="extension")return Yo(e.kind,e.body.source);if(e.body.kind==="preserved")return`An unregistered ${e.body.preservation.upstreamFamilyId??e.body.preservation.header} diagram preserved as source. ${e.body.diagnostic.message}`;const n=e.body;void n;return`A ${e.kind} diagram.`}function Ko(e){const t={kind:e.kind,nodes:[],edges:[],entryPoints:[],sinks:[]};if(e.body.kind==="flowchart"){const r=e.body.graph;for(const o of r.nodes.values())t.nodes.push({id:o.id,label:o.label||o.id});for(const o of r.edges)t.edges.push({from:o.source,to:o.target,label:o.label||void 0})}else if(e.body.kind==="state"){const r=(o,a)=>{for(const s of o){t.nodes.push({id:s.id,label:s.label||s.id});if(s.regions)for(const d of s.regions)r(d.states,d.transitions);else if(s.states!==void 0)r(s.states,s.transitions??[])}for(const s of a)t.edges.push({from:s.from,to:s.to,label:s.label||void 0})};r(e.body.states,e.body.transitions)}else if(e.body.kind==="sequence"){for(const r of e.body.participants)t.nodes.push({id:r.id,label:r.label||r.id});lt(e.body).forEach(r=>{const o=r.message;t.edges.push({from:o.from,to:o.to,label:o.text||void 0,...r.scope==="fragment"?{sequence:{fragmentIndex:r.fragmentIndex,branchIndex:r.branchIndex,fragmentKind:r.fragmentKind,...r.branchLabel??(r.branchIndex===0?r.fragmentLabel:void 0)?{branchLabel:r.branchLabel??r.fragmentLabel}:{}}}:{}})})}else if(e.body.kind==="class"){for(const r of e.body.classes)t.nodes.push({id:r.id,label:r.label||r.id});for(const r of e.body.relations)t.edges.push({from:r.from,to:r.to,label:r.label||r.kind})}else if(e.body.kind==="er"){for(const r of e.body.entities)t.nodes.push({id:r.id,label:r.label||r.id});for(const r of e.body.relations)t.edges.push({from:r.from,to:r.to,label:r.label||void 0})}else if(e.body.kind==="timeline"){for(const r of e.body.sections)for(const o of r.periods){t.nodes.push({id:o.id,label:o.label})}}else if(e.body.kind==="journey"){for(const r of e.body.sections)for(const o of r.tasks){const a=o.actors.length?`; ${o.actors.map((s,d)=>X(L(s,o.actorContents?.[d]))).join(", ")}`:"";t.nodes.push({id:o.id,label:`${X(L(o.text,o.textContent))} (score ${o.score}${a})`})}}else if(e.body.kind==="architecture"){for(const r of e.body.groups)t.nodes.push({id:r.id,label:r.label||r.id});for(const r of e.body.services)t.nodes.push({id:r.id,label:r.label||r.id});for(const r of e.body.junctions)t.nodes.push({id:r.id,label:r.id});for(const r of e.body.edges)t.edges.push({from:r.source.id,to:r.target.id,label:r.label||void 0})}else if(e.body.kind==="xychart"){for(const r of e.body.series)t.nodes.push({id:r.id,label:r.name||`${r.kind} series`})}else if(e.body.kind==="gantt"){for(const o of e.body.sections)for(const a of o.tasks){t.nodes.push({id:a.taskId??a.id,label:a.label})}const r=new Map;for(const o of e.body.sections)for(const a of o.tasks)if(a.taskId)r.set(a.taskId,a.taskId);for(const o of e.body.sections)for(const a of o.tasks){for(const[s,d]of[[a.start,"after"],[a.end,"until"]]){const m=s?.match(/^(?:after|until)\s+(.+)$/);if(!m||!s.startsWith(d))continue;for(const u of m[1].split(/\s+/).filter(Boolean)){if(r.has(u))t.edges.push({from:u,to:a.taskId??a.id,label:d})}}}}else if(e.body.kind==="pie"){for(const r of e.body.slices)t.nodes.push({id:r.id,label:`${r.label} (${r.value})`})}else if(e.body.kind==="quadrant"){e.body.points.forEach((r,o)=>t.nodes.push({id:`point-${o}`,label:`${r.label} [${r.x}, ${r.y}]`}))}else if(e.body.kind==="mindmap"){const r=(o,a)=>{t.nodes.push({id:o.id,label:o.label});if(a)t.edges.push({from:a,to:o.id});o.children.forEach(s=>r(s,o.id))};r(e.body.root)}else if(e.body.kind==="gitgraph"){for(const r of e.body.commits){t.nodes.push({id:r.id,label:r.message||r.sourceId||r.id});r.parents.forEach(o=>t.edges.push({from:o,to:r.id,label:r.source==="commit"?void 0:r.source}))}}else if(e.body.kind==="radar"){e.body.axes.forEach((r,o)=>t.nodes.push({id:`axis-${o}`,label:r.label}));e.body.curves.forEach((r,o)=>t.nodes.push({id:`curve-${o}`,label:r.label}))}else if(e.body.kind==="c4"){for(const r of e.body.boundaries)t.nodes.push({id:r.id,label:wi(r),c4:{category:"boundary",kind:r.kind,...r.parentId===void 0?{}:{parentId:r.parentId}}});for(const r of e.body.elements)t.nodes.push({id:r.id,label:Pi(r),c4:{category:"element",kind:r.kind,external:r.external,shape:r.shape,effectiveShape:ir(r),...r.parentId===void 0?{}:{parentId:r.parentId}}});for(const r of e.body.relationships){const{id:o,order:a,index:s,macro:d,direction:m,bidirectional:u,reversed:y}=r;t.edges.push({from:r.source,to:r.target,label:Li(e.body,r),c4:{id:o,order:a,macro:d,bidirectional:u,reversed:y,authoredFrom:r.from,authoredTo:r.to,...s===void 0?{}:{index:s},...m===void 0?{}:{direction:m}}})}}else if(e.body.kind==="sankey"){const r=new Set;for(const o of e.body.links){for(const a of[o.source,o.target]){if(r.has(a))continue;r.add(a);t.nodes.push({id:a,label:a})}t.edges.push({from:o.source,to:o.target,label:String(o.value)})}}else if(e.body.kind==="zenuml"){const r=[];const o=xe(e.body,{message:({message:a,kind:s,sourceId:d,callAncestors:m,scopes:u})=>{t.edges.push({from:a.from,to:a.to,label:a.label,zenuml:{id:a.id,kind:s,sourceId:d,callAncestors:m,scopes:u}})},note:({note:a,sourceId:s,callAncestors:d,scopes:m})=>{r.push({id:a.id,label:X(L(a.text,a.textContent)),...a.parentId?{parentId:a.parentId}:{},zenuml:{kind:"note",sourceId:s,actorIds:a.actorIds,position:a.position,afterIndex:a.afterIndex,callAncestors:d,scopes:m}})}});if(o.title!==void 0)t.title=o.title;t.nodes.push(...o.actors.map(a=>({id:a.id,label:a.external?"External caller":a.label,...a.external?{external:true}:{zenuml:{kind:"participant",type:a.type}}})),...r)}else if(e.body.kind==="eventmodeling"){const r=st(e.body);t.nodes.push(...r.map(o=>({id:o.id,label:o.label})));t.nodes.push(...e.body.frames.map(o=>({id:o.id,label:o.entity,parentId:r.find(a=>a.members.includes(o.id)).id})));t.edges.push(...ke(e.body))}else if(Xt(e.body)){const r=Ir(e.body);t.nodes.push(...r.nodes);t.edges.push(...r.edges)}else if(e.body.kind==="opaque"){const r=O(e.kind);const o=(r?.extractLabels??Q)(e.body.source);o.forEach((a,s)=>t.nodes.push({id:a.target||`label-${s}`,label:a.text}))}else if(e.body.kind==="extension"){const r=O(e.kind);const o=(r?.extractLabels??Q)(e.body.source);o.forEach((a,s)=>t.nodes.push({id:a.target||`label-${s}`,label:a.text}))}else if(e.body.kind==="preserved"){}else{const r=e.body;void r}const n=new Set(t.edges.map(r=>r.to));const i=new Set(t.edges.map(r=>r.from));for(const r of t.edges)if(r.c4?.bidirectional){n.add(r.from);i.add(r.to)}for(const r of t.nodes){if(!n.has(r.id)&&i.has(r.id))t.entryPoints.push(r.id);if(!i.has(r.id)&&n.has(r.id))t.sinks.push(r.id)}return t}function Jd(e){let t=0;let n=0;const i=e.root.children.map(o=>o.label);const r=o=>{t++;if(o.children.length===0)n++;o.children.forEach(r)};r(e.root);return`A ${t}-node mindmap rooted at ${e.root.label}, with ${n} leaves.${i.length?` Main branches: ${i.join(", ")}.`:""}`}function Qd(e){const t=e.commits.filter(i=>i.source==="merge").length;const n=e.commits.filter(i=>i.source==="cherry-pick").length;return`A GitGraph with ${e.commits.length} commits across ${e.branches.length} branches, including ${t} merges and ${n} cherry-picks. Branches: ${e.branches.map(i=>i.name).join(", ")}.`}function Zd(e){const t=e.body.graph;const n=Array.from(t.nodes.values());const i=n.map(p=>p.id);const r=t.edges;const o=n.map(p=>p.label||p.id);const a=new Map;const s=new Map;for(const p of i){a.set(p,0);s.set(p,0)}for(const p of r){s.set(p.source,(s.get(p.source)??0)+1);a.set(p.target,(a.get(p.target)??0)+1)}const d=i.filter(p=>(a.get(p)??0)===0&&(s.get(p)??0)>0);const m=i.filter(p=>(s.get(p)??0)===0&&(a.get(p)??0)>0);const u=r.map(p=>{const b=p.label?` (${p.label})`:"";return`${p.source} -> ${p.target}${b}`});let y=`A ${n.length}-node flowchart with ${r.length} edges. Nodes: ${o.join(", ")}.`;if(u.length>0)y+=` Edges: ${u.join("; ")}.`;if(d.length>0)y+=` Entry points: ${d.join(", ")}.`;if(m.length>0)y+=` Sinks: ${m.join(", ")}.`;return y}function ec(e){const t=[];const n=[];const i=(u,y)=>{for(const p of u){t.push(p);if(p.regions)for(const b of p.regions)i(b.states,b.transitions);else if(p.states!==void 0)i(p.states,p.transitions??[])}n.push(...y)};i(e.states,e.transitions);const r=t.filter(u=>u.states!==void 0||u.regions!==void 0);const o=t.map(u=>u.label||u.id);const a=n.map(u=>{const y=u.label?` (${u.label})`:"";return`${u.from} -> ${u.to}${y}`});const s=e.transitions.filter(u=>u.from==="[*]").map(u=>u.to);let d=`A state diagram with ${t.length} states and ${n.length} transitions.`;if(r.length>0)d+=` Composite states: ${r.map(u=>u.label||u.id).join(", ")}.`;if(o.length>0)d+=` States: ${o.join(", ")}.`;const m=t.filter(u=>u.stereotype).map(u=>`${u.label||u.id} (${u.stereotype})`);if(m.length>0)d+=` Pseudostates: ${m.join(", ")}.`;if((e.notes??[]).length>0){d+=` Notes: ${e.notes.map(u=>`${u.side} of ${u.target}: ${u.text}`).join("; ")}.`}if(e.floatingNotes?.length)d+=` Floating notes: ${e.floatingNotes.map(u=>`${u.id}${u.scope?` in ${u.scope.parent}${u.scope.region!==void 0?` region ${u.scope.region}`:""}`:""}: ${u.text}`).join("; ")}.`;if(a.length>0)d+=` Transitions: ${a.join("; ")}.`;if(s.length>0)d+=` Initial: ${s.join(", ")}.`;return d}function tc(e){const t=e.body.participants;const n=t.map(a=>a.label||a.id).join(", ");let i=`A sequence diagram between ${n||"(no participants)"}.`;const r=[];let o=0;for(const a of e.body.statements){if(a.kind==="message"){const d=e.body.messages[a.ref];if(d)r.push(`message ${d.from} -> ${d.to}: ${d.text}`);continue}if(a.kind!=="fragment")continue;const s=a.fragment.branches.map((d,m)=>{const u=d.label??(m===0?a.fragment.label:void 0);const y=d.messages.map(p=>`${p.from} -> ${p.to}: ${p.text}`).join("; ")||"no messages";return`branch ${m}${u?` (${u})`:""}: ${y}`});r.push(`fragment ${o} (${a.fragment.fragmentKind}): ${s.join(" | ")}`);o++}if(r.length>0)i+=` Interactions in source order: ${r.join("; ")}.`;return i}function nc(e){const t=e.body.sections;const n=t.map(o=>o.label||o.id);const i=[];for(const o of t)for(const a of o.periods)i.push(a.label);let r=`A timeline with ${t.length} sections.`;if(n.length>0)r+=` Sections: ${n.join(", ")}.`;if(i.length>0)r+=` Periods: ${i.join(", ")}.`;return r}function rc(e){const t=e.sections;const n=t.reduce((s,d)=>s+d.tasks.length,0);const i=new Map(t.flatMap(s=>s.tasks.flatMap(d=>d.actors.map((m,u)=>[ct(m,d.actorContents?.[u]),X(L(m,d.actorContents?.[u]))]))));let r=`A user journey${e.title?` titled "${X(L(e.title,e.titleContent))}"`:""} with ${t.length} sections and ${n} tasks.`;const o=t.flatMap(s=>s.label===void 0?[]:[X(L(s.label,s.labelContent))]);if(o.length>0)r+=` Sections: ${o.join(", ")}.`;const a=t.flatMap(s=>s.tasks.map(d=>`${X(L(d.text,d.textContent))} (${d.score})`));if(a.length>0)r+=` Tasks: ${a.join(", ")}.`;if(i.size>0)r+=` Actors: ${[...i.values()].join(", ")}.`;return r}function ic(e){const t=e.groups;const n=e.services;const i=e.junctions;const r=e.edges;let o=`An architecture diagram${e.title?` titled "${e.title}"`:""} with ${t.length} groups, ${n.length} services, and ${r.length} connections.`;if(e.accessibilityTitle)o+=` Accessible title: ${e.accessibilityTitle}.`;if(e.accessibilityDescription)o+=` Accessible description: ${e.accessibilityDescription.replace(/\n/g," ")}.`;if(t.length>0)o+=` Groups: ${t.map(s=>s.label||s.id).join(", ")}.`;if(n.length>0)o+=` Services: ${n.map(s=>s.label||s.id).join(", ")}.`;if(i.length>0)o+=` Junctions: ${i.map(s=>s.id).join(", ")}.`;const a=r.map(s=>`${s.source.id} -> ${s.target.id}${s.label?` (${s.label})`:""}`);if(a.length>0)o+=` Connections: ${a.join("; ")}.`;return o}function oc(e){const t=e.series;const n=e.horizontal?"horizontal ":"";let i=`An ${n}XY chart${e.title?` titled "${e.title}"`:""} with ${t.length} series.`;const r=(s,d)=>{if(!d)return void 0;const m=[];if(d.name!==void 0)m.push(`"${d.name}"`);if(d.categories)m.push(`categories ${d.categories.join(", ")}`);if(d.range)m.push(`range ${d.range.min}\u2013${d.range.max}`);return m.length>0?`${s}: ${m.join(", ")}`:void 0};const o=[r("x-axis",e.xAxis),r("y-axis",e.yAxis)].filter(s=>s!==void 0);if(o.length>0)i+=` Axes \u2014 ${o.join("; ")}.`;const a=t.map(s=>`${s.kind}${s.name?` ${s.name}`:""} [${s.values.join(", ")}]`);if(a.length>0)i+=` Series: ${a.join("; ")}.`;return i}function ac(e){let t=`A pie chart${e.title?` titled "${e.title}"`:""} with ${e.slices.length} slices.`;const n=e.slices.map(i=>`${i.label} (${i.value})`);if(n.length>0)t+=` Slices: ${n.join(", ")}.`;return t}function sc(e){let t=`A quadrant chart${e.title?` titled "${e.title}"`:""} with ${e.points.length} points.`;const n=e.quadrants.filter(r=>Boolean(r));if(n.length>0)t+=` Quadrants: ${n.join(", ")}.`;const i=e.points.map(r=>`${r.label} [${r.x}, ${r.y}]`);if(i.length>0)t+=` Points: ${i.join(", ")}.`;return t}function dc(e){const t=e.body.classes.filter(d=>!d.isInterface);const n=e.body.classes.filter(d=>d.isInterface);const i=e.body.relations;const r=t.map(d=>d.generic?`${d.id}<${d.generic}>`:d.id);const o=i.map(d=>`${d.from} ${d.kind} ${d.to}`);let a=`A class diagram with ${t.length} classes.`;if(r.length>0)a+=` Classes: ${r.join(", ")}.`;if(n.length>0)a+=` Interfaces: ${n.map(d=>d.label??d.id).join(", ")}.`;const s=e.body.namespaces??[];if(s.length>0){const d=s.map(m=>{const u=t.filter(y=>y.namespace===m.name).map(y=>y.id);return`${m.name} [${u.join(", ")}]`});a+=` Namespaces: ${d.join("; ")}.`}if(o.length>0)a+=` Relations: ${o.join("; ")}.`;return a}function cc(e){const t=e.body.entities;const n=e.body.relations;const i=t.map(a=>a.label?`${a.id} ("${a.label}")`:a.id);const r=n.map(a=>{const s=a.label?` (${a.label})`:"";return`${a.from} ${a.leftCard}-${a.rightCard} ${a.to}${s}`});let o=`An ER diagram with ${t.length} entities.`;if(i.length>0)o+=` Entities: ${i.join(", ")}.`;if(r.length>0)o+=` Relations: ${r.join("; ")}.`;return o}function lc(e){const t=e.body;const n=t.sections.flatMap(a=>a.tasks);let i=`A Gantt chart${t.title?` titled "${t.title}"`:""} with ${t.sections.filter(a=>a.label!==void 0).length} sections and ${n.length} tasks.`;try{const a=$e(le(tt(e.canonicalSource)));if(a.tasks.length>0){const s=a.dateOnly?"%Y-%m-%d":"%Y-%m-%d %H:%M";i+=` Schedule: ${on(a.timeMin,s)} to ${on(a.timeMax,s)}.`}else i+=" No tasks scheduled.";if(a.analysis&&a.analysis.criticalPathTaskIds.length>0){i+=` Critical path: ${a.analysis.criticalPathTaskIds.join(" -> ")}.`}}catch{}const r=t.sections.map(a=>a.label).filter(a=>a!==void 0);if(r.length>0)i+=` Sections: ${r.join(", ")}.`;const o=n.map(a=>{const s=[];const d=a.tags.find(m=>m==="done"||m==="active"||m==="crit");if(d)s.push(d);if(a.tags.includes("milestone"))s.push("milestone");if(a.tags.includes("vert"))s.push("vert marker");if(a.start)s.push(a.start);s.push(a.end);return`${a.label} (${s.join(", ")})`});if(o.length>0)i+=` Tasks: ${o.join("; ")}.`;return i}function Yo(e,t){const n=O(e);const i=(n?.extractLabels??Q)(t).map(s=>s.text);const r=Array.from(new Set(i)).filter(Boolean);const o=e==="xychart"?"XY chart":e;let a=`A ${o} diagram with a source-level body (structured editing not exposed).`;if(r.length>0)a+=` Labels: ${r.join(", ")}.`;return a}var Ie=Object.freeze({security:"strict",embedFontImport:false});function Qo(e){return e instanceof Error?e.message:String(e)}function He(e){const t=v(e.example);if(!t.ok){throw new Error(t.error.map(n=>`${n.code}: ${n.message}`).join("; "))}if(t.value.kind!==e.id){throw new Error(`canonical example routed to "${t.value.kind}" instead of "${e.id}"`)}return t.value}function mc(e){const t=He(e);return{kind:t.kind,..."descriptorIdentity"in t?{descriptorIdentity:t.descriptorIdentity}:{},meta:t.meta,body:t.body,canonicalSource:t.canonicalSource}}function Xo(e){const t=V(He(e));const n=v(t);if(!n.ok){throw new Error(`serialized canonical example did not reparse: ${n.error.map(r=>r.message).join("; ")}`)}if(n.value.kind!==e.id){throw new Error(`serializer changed family identity to "${n.value.kind}"`)}const i=V(n.value);if(i!==t){throw new Error("serializer is not byte-stable after parse \u2192 serialize \u2192 reparse")}return{serialized:t,reparsedKind:n.value.kind,canonicalSource:n.value.canonicalSource}}function fc(e){const t=He(e);const n=Lt(t,{output:"layout",renderOptions:Ie});if(!n)throw new Error(`canonical example has no public positioned-layout projection`);const i=[n.positioned.width,n.positioned.height];const r=[n.rendered.bounds.w,n.rendered.bounds.h];if([...i,...r].some(o=>!Number.isFinite(o)||o<=0)){throw new Error("canonical example layout and projected bounds must be finite and positive")}if(n.rendered.nodes.length+n.rendered.edges.length+n.rendered.groups.length===0){throw new Error("canonical example layout must expose at least one semantic node, edge, or group")}return{layout:n.rendered,receiptDigest:oe(Fe(n.request))}}function pc(e){const t=Me(e.example,Ie,"svg");const n=kt(e.id,t);const i=Rt(t,n);const r=new Set;Ve(i.parts,a=>{for(const s of rr(a))r.add(`${a.role}\0${s}`)});const o=e.scenePrimitiveEvidence.filter(a=>a.applicability==="applicable").filter(a=>!r.has(`${a.role}\0${a.primitive}`)).map(a=>`${a.role}/${a.primitive}`);if(o.length>0){throw new Error(`canonical example did not witness declared positive Scene cells: ${o.join(", ")}`)}return{sceneDigest:oe(i),cells:[...r].sort(),receiptDigest:oe(Fe(t))}}function gc(e){const t=Et(e.example,Ie,"svg");const n=Qi(e.example,Ie);return{svg:t.svg,svgReceiptDigest:oe(t.receipt),pngSvg:n.svg,pngReceiptDigest:oe(n.receipt),rasterBackground:n.rasterBackground,rasterDimensions:n.rasterDimensions}}function yc(e){const t=[];for(const n of[true,false]){for(const i of Yi){const r=n?"ascii":"unicode";let o;try{o=St(e.example,{...Ie,useAscii:n,colorMode:i})}catch(a){throw new Error(`${r}/${i} terminal witness failed: ${Qo(a)}`)}t.push({encoding:r,colorMode:i,textDigest:oe(o.text),receiptDigest:oe(o.receipt)})}}return{outputs:t}}function hc(e){const t=Ae(e.example,{renderOptions:Ie});if(!t.ok){const n=t.warnings.map(i=>i.code==="RENDER_FAILED"||i.code==="INTERNAL_ERROR"?`${i.code}: ${i.reason}`:i.code);throw new Error(`canonical example failed verification: ${n.join(", ")}`)}return t}function Jo(e,t){switch(t){case"detection":{const n=He(e);return{family:n.kind,canonicalSource:n.canonicalSource}}case"source-preservation":{const n=He(e);return{family:n.kind,canonicalSource:n.canonicalSource,roundtrip:Xo(e)}}case"parse":return mc(e);case"serialize":return Xo(e);case"mutation":throw new Error("external structured mutation is not an executable native capability");case"verify":return hc(e);case"layout":return fc(e);case"scene":return pc(e);case"svg":return gc(e);case"terminal":return yc(e)}}function bc(e,t){const n=e.capabilityEvidence.find(r=>r.capability===t).state;if(n!=="native"){return Object.freeze({capability:t,declaredState:n,status:"unverified-extension",diagnostic:`Descriptor declares "${n}"; no executable native claim was made.`})}const i=`family-example@${it}/${e.id}/${t}`;try{const r=oe(Jo(e,t));const o=oe(Jo(e,t));if(r!==o){throw new Error(`canonical example was nondeterministic (${r} != ${o})`)}return Object.freeze({capability:t,declaredState:n,status:"passed",witnessId:i})}catch(r){return Object.freeze({capability:t,declaredState:n,status:"failed",diagnostic:Qo(r)})}}function xc(e){const t=Object.freeze(Ht.map(n=>bc(e,n)));return Object.freeze({version:it,familyId:e.id,example:e.example,passed:t.every(n=>n.declaredState!=="native"||n.status==="passed"),capabilities:t})}function kc(e){const t=or(e,$i);try{const n=xc(t.descriptor);if(!n.passed)throw new Pe(n);return t.commit(n)}catch(n){t.rollback();throw n}}var ra={maxCrossingsRatio:.05,minLabelLegibility:.85,whitespaceBand:[.05,.55],minLabelEdgeProximity:4,minNodeSpacing:8,elementDensityBand:[.02,6],minTextContrast:4.5,aspectBand:[.2,5]};var ia={paintCertification:{basis:"derived",severity:"primary",note:"Final native paint evidence reports visibility and bounded inspection separately from label fit."},edgeCrossings:{basis:"evidence",severity:"primary",note:"Crossings are the single aesthetic with the strongest human-subject evidence (Purchase 1997/2002). Weight this violation highest."},labelLegibility:{basis:"derived",severity:"secondary",note:"Prepared text must fit its retained available region. Labels without retained geometry are reported as unmeasured."},labelEdgeProximity:{basis:"chosen",severity:"secondary",note:"Edge-labels overlapping nodes hurt readability, but the 4px floor is chosen, not validated against perception."},minimumNodeSpacing:{basis:"chosen",severity:"secondary",note:"Box clearance catches cramped layouts, but the 8px floor is a conservative implementation threshold rather than a perceptual constant."},elementDensity:{basis:"chosen",severity:"secondary",note:"Elements per canvas area distinguishes crowded marks from large boxes; the default band is a regression guard, not a universal aesthetic optimum."},minimumTextContrast:{basis:"standard",severity:"secondary",note:"The 4.5:1 floor follows WCAG AA normal-text contrast. Callers should supply resolved surface colors when a style uses non-default fills."},whitespaceBalance:{basis:"chosen",severity:"secondary",note:'A node/canvas fill band is a rough proxy for "too sparse / too dense"; the literature gives weak support and the band is hand-set.'},aspectRatio:{basis:"sanity",severity:"sanity",note:"Aspect ratio is a guardrail against absurd canvases, not an aesthetic; Purchase did not find it drives comprehension."}};var W=1e-9;function oa(e,t={}){const n=Ai(e);const i=e.edges.map(a=>({source:a.from,target:a.to,style:a.visibility==="hidden"?"invisible":"solid",points:a.path.map(([s,d])=>({x:s,y:d}))}));let r=0,o=0;for(const a of e.edges){if(a.visibility==="hidden")continue;let s;for(let d=1;d<a.path.length;d++){const m=a.path[d-1],u=a.path[d];const y=u[0]-m[0],p=u[1]-m[1],b=Math.hypot(y,p);if(b<=W)continue;const S=[y/b,p/b];if(s&&(Math.abs(s[0]*S[1]-s[1]*S[0])>W||s[0]*S[0]+s[1]*S[1]<0))r++;s=S;o+=b}}return{...be(e)?{paintCertification:be(e)}:{},edgeCrossings:Oc(e.edges),labelLegibility:Cc(e),labelMeasurement:{measuredNodes:e.nodes.filter(a=>a.label&&a.labelVisibility!=="hidden"&&a.labelVisibility!=="semantic"&&a.labelBounds).length,unmeasuredNodes:e.nodes.filter(a=>a.label&&a.labelVisibility!=="hidden"&&a.labelVisibility!=="semantic"&&!a.labelBounds).length,hiddenNodes:e.nodes.filter(a=>a.label&&a.labelVisibility==="hidden").length,semanticNodes:e.nodes.filter(a=>a.label&&a.labelVisibility==="semantic").length,measuredEdges:e.edges.filter(a=>a.label?.bounds).length,unmeasuredEdges:e.edges.filter(a=>a.label&&!a.label.bounds).length,measuredLabels:(e.labels??[]).filter(a=>a.text&&a.visibility!=="hidden"&&a.visibility!=="semantic"&&a.bounds).length,unmeasuredLabels:(e.labels??[]).filter(a=>a.text&&a.visibility!=="hidden"&&a.visibility!=="semantic"&&!a.bounds).length,hiddenLabels:(e.labels??[]).filter(a=>a.text&&a.visibility==="hidden").length,semanticLabels:(e.labels??[]).filter(a=>a.text&&a.visibility==="semantic").length},whitespaceBalance:Dc(e),labelEdgeProximity:Pc(e),...n?{labelConflicts:n}:{},routeOverlaps:{parallel:Ii(i),opposing:Ci(i)},routeGeometry:{bends:r,length:o,area:e.bounds.w*e.bounds.h},minimumNodeSpacing:Ec(e),elementDensity:_c(e),minimumTextContrast:$c(t),aspectRatio:e.bounds.h>0?e.bounds.w/e.bounds.h:Infinity,nodeCount:e.nodes.length,edgeCount:e.edges.length}}function Sc(e,t={},n={}){const i={...ra,...t};const r=oa(e,n);const o=[];const a=(y,p)=>o.push({metric:y,severity:ia[y].severity,message:p});if(r.paintCertification&&r.paintCertification.status!=="passed")a("paintCertification",`paint layout ${r.paintCertification.status}: ${r.paintCertification.issues.map(y=>y.message).join("; ")}`);const s=e.edges.reduce((y,p)=>y+(p.visibility==="hidden"?0:1),0);const d=Math.max(1,s*(s-1)/2);if(r.edgeCrossings/d>i.maxCrossingsRatio){a("edgeCrossings",`edge crossings ${r.edgeCrossings}/${d} (${(r.edgeCrossings/d*100).toFixed(1)}%) > cap ${(i.maxCrossingsRatio*100).toFixed(1)}%`)}if(r.labelLegibility<i.minLabelLegibility){a("labelLegibility",`label legibility ${(r.labelLegibility*100).toFixed(0)}% < min ${(i.minLabelLegibility*100).toFixed(0)}%`)}if(r.labelMeasurement.unmeasuredNodes>0){a("labelLegibility",`label fit unmeasured for ${r.labelMeasurement.unmeasuredNodes} visible labels`)}if(r.labelMeasurement.unmeasuredEdges>0){a("labelEdgeProximity",`edge-label clearance unmeasured for ${r.labelMeasurement.unmeasuredEdges} labels`)}if(r.labelMeasurement.unmeasuredLabels>0){a("labelLegibility",`label fit unmeasured for ${r.labelMeasurement.unmeasuredLabels} painted labels`)}const m=e.kind==="quadrant"||e.kind==="xychart"||e.kind==="radar";if((!m||t.whitespaceBand!==void 0)&&(r.whitespaceBalance<i.whitespaceBand[0]||r.whitespaceBalance>i.whitespaceBand[1])){a("whitespaceBalance",`whitespace balance ${(r.whitespaceBalance*100).toFixed(1)}% outside band [${i.whitespaceBand[0]*100}\u2013${i.whitespaceBand[1]*100}]%`)}if(r.labelEdgeProximity<i.minLabelEdgeProximity){a("labelEdgeProximity",`edge-label clearance ${r.labelEdgeProximity}px < min ${i.minLabelEdgeProximity}px`)}if(r.nodeCount>=2&&r.minimumNodeSpacing<i.minNodeSpacing){a("minimumNodeSpacing",`minimum node spacing ${r.minimumNodeSpacing}px < min ${i.minNodeSpacing}px`)}if(r.nodeCount>0&&(r.elementDensity<i.elementDensityBand[0]||r.elementDensity>i.elementDensityBand[1])){a("elementDensity",`element density ${r.elementDensity.toFixed(2)} outside band [${i.elementDensityBand[0]}\u2013${i.elementDensityBand[1]}] per 10,000px\xB2`)}if(r.minimumTextContrast===null){a("minimumTextContrast","minimum text contrast is unmeasurable because one or more requested paints could not be resolved")}else if(r.minimumTextContrast<i.minTextContrast){a("minimumTextContrast",`minimum text contrast ${r.minimumTextContrast.toFixed(2)}:1 < min ${i.minTextContrast}:1`)}if(r.aspectRatio<i.aspectBand[0]||r.aspectRatio>i.aspectBand[1]){a("aspectRatio",`aspect ratio ${r.aspectRatio.toFixed(2)} outside band [${i.aspectBand[0]}\u2013${i.aspectBand[1]}]`)}const u={primary:0,secondary:1,sanity:2};o.sort((y,p)=>u[y.severity]-u[p.severity]);return{ok:o.length===0,metrics:r,ranked:o}}function Rc(e){let t=Infinity;let n=Infinity;let i=-Infinity;let r=-Infinity;for(const o of e){t=Math.min(t,o.box.x);n=Math.min(n,o.box.y);i=Math.max(i,o.box.x+o.box.w);r=Math.max(r,o.box.y+o.box.h)}return{x:t,y:n,w:i-t,h:r-n}}function An(e){const t=Rc(e);if(e.length<=8)return{box:t,items:e};const n=t.w>=t.h?"x":"y";const i=[...e].sort((o,a)=>(n==="x"?o.box.x+o.box.w/2-a.box.x-a.box.w/2:o.box.y+o.box.h/2-a.box.y-a.box.h/2)||Qe(o.node.id,a.node.id));const r=Math.floor(i.length/2);return{box:t,left:An(i.slice(0,r)),right:An(i.slice(r))}}function Zo(e){const t=e.id.match(/^(bar|line)#(\d+):pt#(\d+)$/);if(!t)return void 0;return{type:t[1],series:Number(t[2]),point:Number(t[3])}}function ea(e){const t=e.id.match(/^dot:(.+):(\d+)$/);if(!t)return void 0;return{curve:t[1],vertex:Number(t[2])}}function aa(e,t,n){if(e==="quadrant"&&t.dataPosition&&n.dataPosition&&t.dataPosition.x===n.dataPosition.x&&t.dataPosition.y===n.dataPosition.y)return false;if(e==="xychart"){const i=Zo(t);const r=Zo(n);if(!i||!r)return true;if(i.type!==r.type)return i.point!==r.point;return i.series===r.series||i.point!==r.point}if(e==="radar"){const i=ea(t);const r=ea(n);if(!i||!r)return true;const o=t.x===n.x&&t.y===n.y&&t.w===n.w&&t.h===n.h;return i.curve===r.curve||i.vertex!==r.vertex||!o}return true}function Ye(e,t,n,i){if(Xe(e.box,t.box)>=i)return i;if(e.items&&t.items){for(const o of e.items)for(const a of t.items){if(!aa(n,o.node,a.node))continue;i=Math.min(i,Xe(o.box,a.box));if(i===0)return 0}return i}const r=!t.items&&e.items?false:!e.items&&(t.items||e.box.w*e.box.h>=t.box.w*t.box.h);if(r){i=Ye(e.left,t,n,i);return Ye(e.right,t,n,i)}i=Ye(e,t.left,n,i);return Ye(e,t.right,n,i)}function In(e,t,n=Infinity){if(e.items){for(let i=0;i<e.items.length;i++)for(let r=i+1;r<e.items.length;r++){const o=e.items[i],a=e.items[r];if(!aa(t,o.node,a.node))continue;n=Math.min(n,Xe(o.box,a.box));if(n===0)return 0}return n}n=In(e.left,t,n);if(n===0)return 0;n=In(e.right,t,n);if(n===0)return 0;return Ye(e.left,e.right,t,n)}function Ec(e){if(e.nodes.length<2)return Infinity;const t=e.nodes.map(n=>({node:n,box:wn(n)}));return In(An(t),e.kind)}function _c(e){const t=e.bounds.w*e.bounds.h;if(t<=0)return Infinity;return(e.nodes.length+e.edges.length)/(t/1e4)}function Ke(e){return fe(e)??void 0}function Pn(e,t){return Tn(Bt(e),Bt(t))}function ze(e,t){const n=e[3];return[0,1,2].map(i=>e[i]*n+t[i]*(1-n))}function sa(e){const t=Ke(e);return t&&t[3]===1?[t[0],t[1],t[2]]:void 0}function Mc(e,t,n){const i=Ke(e);const r=Ke(t);const o=sa(n);if(!i||!r||!o)return void 0;const a=ze(r,o);return Pn(ze(i,a),a)}function $c(e){if(e.textPairs!==void 0){if(e.textPairs.length===0)return null;const a=e.background??"#FFFFFF";let s=Infinity;for(const d of e.textPairs){const m=Mc(d.foreground,d.background,a);if(m===void 0)return null;s=Math.min(s,m)}return s}const t=Ke(e.foreground??"#27272A");const n=sa(e.background??"#FFFFFF");if(!t||!n)return null;const i=e.surfaces??[];const r=i.map(Ke);if(r.some(a=>a===void 0))return null;let o=Pn(ze(t,n),n);for(const a of r){const s=ze(a,n);o=Math.min(o,Pn(ze(t,s),s))}return o}function Oc(e){return Si(e.map(t=>({points:t.path.map(([n,i])=>({x:n,y:i})),visible:t.visibility!=="hidden"})))}function Cc(e){const t={x:0,y:0,w:e.bounds.w,h:e.bounds.h};const n=[...e.nodes.map(o=>({text:o.label,bounds:o.labelBounds,container:o.labelContainer??wn(o),visibility:o.labelVisibility})),...(e.labels??[]).map(o=>({...o,container:o.container??t}))];const i=n.filter(o=>o.text&&o.visibility!=="hidden"&&o.visibility!=="semantic"&&o.bounds);if(i.length===0)return 1;let r=0;for(const o of i){const a=o.bounds;const s=o.container;if(a.x>=s.x-W&&a.y>=s.y-W&&a.x+a.w<=s.x+s.w+W&&a.y+a.h<=s.y+s.h+W)r++}return r/i.length}function Dc(e){const t=e.bounds.w*e.bounds.h;if(t<=0)return 0;let n=0;for(const i of e.nodes)n+=i.w*i.h;return Math.min(1,n/t)}function wn(e){return{x:e.x,y:e.y,w:e.w,h:e.h}}function Xe(e,t){const n=Math.max(0,Math.max(e.x-(t.x+t.w),t.x-(e.x+e.w)));const i=Math.max(0,Math.max(e.y-(t.y+t.h),t.y-(e.y+e.h)));return Math.hypot(n,i)}function ta(e,t){return e[0]>=t.x&&e[0]<=t.x+t.w&&e[1]>=t.y&&e[1]<=t.y+t.h}function na(e,t){const n=Math.max(0,Math.max(t.x-e[0],e[0]-(t.x+t.w)));const i=Math.max(0,Math.max(t.y-e[1],e[1]-(t.y+t.h)));return Math.hypot(n,i)}function vc(e,t,n){const i=n[0]-t[0];const r=n[1]-t[1];const o=i*i+r*r;if(o===0)return Math.hypot(e[0]-t[0],e[1]-t[1]);const a=Math.max(0,Math.min(1,((e[0]-t[0])*i+(e[1]-t[1])*r)/o));const s=t[0]+a*i;const d=t[1]+a*r;return Math.hypot(e[0]-s,e[1]-d)}function Vt(e,t,n,i){const r=(u,y,p)=>(y[0]-u[0])*(p[1]-u[1])-(y[1]-u[1])*(p[0]-u[0]);const o=(u,y,p)=>y[0]>=Math.min(u[0],p[0])-W&&y[0]<=Math.max(u[0],p[0])+W&&y[1]>=Math.min(u[1],p[1])-W&&y[1]<=Math.max(u[1],p[1])+W;const a=r(e,t,n);const s=r(e,t,i);const d=r(n,i,e);const m=r(n,i,t);if(Math.abs(a)<=W&&o(e,n,t))return true;if(Math.abs(s)<=W&&o(e,i,t))return true;if(Math.abs(d)<=W&&o(n,e,i))return true;if(Math.abs(m)<=W&&o(n,t,i))return true;return a>0!==s>0&&d>0!==m>0}function Ac(e,t,n){if(ta(e,n)||ta(t,n))return true;const i=[n.x,n.y];const r=[n.x+n.w,n.y];const o=[n.x+n.w,n.y+n.h];const a=[n.x,n.y+n.h];return Vt(e,t,i,r)||Vt(e,t,r,o)||Vt(e,t,o,a)||Vt(e,t,a,i)}function Ic(e,t,n){if(Ac(t,n,e))return 0;const i=[[e.x,e.y],[e.x+e.w,e.y],[e.x+e.w,e.y+e.h],[e.x,e.y+e.h]];return Math.min(na(t,e),na(n,e),...i.map(r=>vc(r,t,n)))}function Pc(e){let t=Infinity;const n=e.edges.filter(i=>i.label?.bounds!==void 0).map(i=>({edge:i,box:i.label.bounds}));for(const{edge:i,box:r}of n){for(const o of e.nodes){if(o.id===i.from||o.id===i.to)continue;const a=Xe(r,wn(o));if(a<t)t=a}}for(let i=0;i<n.length;i++){for(let r=i+1;r<n.length;r++){const o=Xe(n[i].box,n[r].box);if(o<t)t=o}}for(const{edge:i,box:r}of n){for(const o of e.edges){if(o===i||o.visibility==="hidden")continue;for(let a=0;a<o.path.length-1;a++){const s=Ic(r,o.path[a],o.path[a+1]);if(s<t)t=s}}}return t}function da(e,t){const n=[{id:"canvas",kind:"canvas",bounds:{x:Y(0),y:Y(0),w:t.bounds.w,h:t.bounds.h}}];const i=new Map;for(const o of t.groups)for(const a of o.members)i.set(a,o.id);const r=Lc(e);for(const o of t.groups){n.push({id:`group:${o.id}`,kind:o.regionKind??wc(t.kind),elementId:o.id,parentId:o.parentId?`group:${o.parentId}`:"canvas",bounds:{x:o.x,y:o.y,w:o.w,h:o.h},sourceLine:e.source.groups.get(o.id)?.line??r.groups.get(o.id)})}for(const o of t.nodes){n.push({id:`node:${o.id}`,kind:"node",elementId:o.id,parentId:o.parentId!==void 0?`group:${o.parentId}`:i.has(o.id)?`group:${i.get(o.id)}`:"canvas",bounds:{x:o.x,y:o.y,w:o.w,h:o.h},sourceLine:e.source.nodes.get(o.id)?.line??r.nodes.get(o.id)})}for(const o of t.edges){const a=o.path.map(d=>d[0]);const s=o.path.map(d=>d[1]);if(a.length>0&&s.length>0){const d=Math.min(...a),m=Math.max(...a),u=Math.min(...s),y=Math.max(...s);n.push({id:`edge:${o.id}`,kind:"edge",elementId:o.id,parentId:"canvas",bounds:{x:Y(d),y:Y(u),w:Y(Math.max(1,m-d)),h:Y(Math.max(1,y-u))}})}if(o.label){const d=Math.max(1,o.label.text.length*7);const m=14;const u=e.kind==="sequence"&&o.from===o.to?o.label.x:o.label.x-d/2;n.push({id:`label:${o.id}`,kind:"label",elementId:o.id,parentId:`edge:${o.id}`,bounds:{x:Y(u),y:Y(o.label.y-m/2),w:Y(d),h:Y(m)}})}}return n}function wc(e){switch(e){case"flowchart":case"state":case"class":case"er":case"architecture":return"cluster";case"gitgraph":return"lane";case"timeline":case"journey":case"gantt":return"band";case"sequence":case"quadrant":return"compartment";case"xychart":return"plot";case"radar":return"ring";default:return"group"}}function Lc(e){const t=new Map;const n=new Map;const i=e.body.kind==="opaque"||e.body.kind==="extension"?e.body.source:e.canonicalSource;const r=i.split(/\r?\n/);for(let o=0;o<r.length;o++){const a=r[o];const s=a.match(/^\s*subgraph\s+([A-Za-z0-9_:-]+)/);if(s?.[1]&&!n.has(s[1]))n.set(s[1],o+1);for(const d of a.matchAll(/(?:^|[\s&;])([A-Za-z][A-Za-z0-9_:-]*)(?=\s*(?:\[|\(|\{|--|==|-.|$))/g)){const m=d[1];if(m==="subgraph"||m==="end"||m===e.kind)continue;if(!t.has(m))t.set(m,o+1)}}return{nodes:t,groups:n}}function fb(e,t={}){return _t(e,t)}function pb(e,t={}){return Zi(e,t)}function gb(e,t={}){return zi(e,t)}function yb(e,t={}){return St(e,t)}function Tc(e,t={}){const{debug:n,regions:i,actions:r,...o}=t;const a={debug:n,regions:i,actions:r};const s=Oe(e);const d=s.source;const m=Me(d,o,"layout",a,{expectedFamilyId:s.expectedFamilyId});xt(m);let u;if(typeof e==="string"){const p=v(d);if(!p.ok)throw new Error(p.error.map(b=>b.message).join("; "));u=p.value}else{u=e}const y=Co(u,m,{debug:n});if(!y)throw new Error(`No public layout projection registered for Mermaid family "${u.kind}"`);return{layout:Nc(u,y,a),receipt:{...Fe(m),...be(y)?{layoutCertification:be(y)}:{}}}}function hb(e,t={}){if(e.body.kind==="preserved"){throw new Te(hr(e.body))}return Tc(e,t).layout}function Nc(e,t,n){const i=n.debug||n.regions;const r=n.debug||n.actions;if(!i&&!r)return t;const o={...t};if(i)o.regions=da(e,t);if(r){const s=new Set([...t.nodes,...t.groups,...t.edges].map(d=>d.id));o.actions=(e.body.kind==="extension"||e.body.kind==="preserved"?[]:Ce(e)).filter(d=>s.has(d.target)).map(d=>({...d,regionId:d.regionId??`node:${d.target}`}))}const a=be(t);if(a)Ze(o,a);return o}export{to as a,ca as b,Ce as c,ln as d,ha as e,wa as f,ae as g,ee as h,It as i,xo as j,us as k,ms as l,ps as m,qe as n,gs as o,Rn as p,Pt as q,bs as r,As as s,om as t,Ps as u,Ae as v,Xf as w,jo as x,Wo as y,Sd as z,Rd as A,Ed as B,Ue as C,Id as D,Uo as E,Pd as F,Kd as G,jp as H,Xd as I,zo as J,Ko as K,kc as L,ra as M,ia as N,oa as O,Sc as P,da as Q,fb as R,pb as S,gb as T,yb as U,Tc as V,hb as W};
|
|
2
|
+
//# sourceMappingURL=chunk-A5TX2FW5.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as i,ka as c}from"./chunk-JRLCGATA.js";import{Gc as n,gf as o,gh as s,hh as a,ib as t,ih as d}from"./chunk-GO4CS5KS.js";function g(e){if(e instanceof i)return{code:e.code,message:e.message,partId:e.partId,feature:e.feature};if(e instanceof n){return{code:e.code,message:e.message,line:e.line,preservation:e.preservation,help:e.help}}if(e instanceof c){return{code:e.code,message:e.message,requestedWidth:e.requestedWidth,requiredWidth:e.requiredWidth,family:e.family,reason:e.reason}}if(e instanceof t){return{code:e.code,message:e.message,subject:e.subject,property:e.property,value:e.value}}if(e instanceof o){return{code:e.code,message:e.message,subject:e.subject,property:e.property,value:e.value}}if(e instanceof s){return{code:e.code,message:e.message,key:e.key,value:e.value}}if(e instanceof d){return{code:e.code,message:e.message,path:e.path,value:e.value}}if(e instanceof a){return{code:e.code,message:e.message,field:e.field,value:e.value}}return void 0}function y(e){return g(e)??{code:"RENDER_FAILED",message:"Rendering failed"}}export{g as a,y as b};
|
|
2
|
+
//# sourceMappingURL=chunk-AS6A6XHE.js.map
|