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
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{a as e}from"./chunk-
|
|
1
|
+
import{a as e}from"./chunk-4WON4RCG.js";import"./chunk-TXYQEDUF.js";import"./chunk-MFTQWHUB.js";import{D as t,E as i,N as n,Q as a,R as r,S as o,W as l,X as s,Y as d,Z as c,aa as h,g as g,xa as p}from"./chunk-PS4HSV54.js";import"./chunk-HJVO5VC3.js";import"./chunk-L4UC3KGS.js";import"./chunk-BMZ24VPS.js";import"./chunk-YYF5TS6K.js";import"./chunk-KOO3MCMJ.js";import{d as m}from"./chunk-QOIFBX26.js";import{a as u,e as f,l as y}from"./chunk-CJZMMNPO.js";import{d as x}from"./chunk-F4CQMYR2.js";import{s as b,u as _}from"./chunk-5SZ2YBKG.js";import{d as w}from"./chunk-2R6M4CUH.js";import{a as v,b as k}from"./chunk-HAMXYU5V.js";import{C as F,D as S,a as $,b as M,c as C,d as W,e as R,g as L,h as I,i as z,j as E,o as q}from"./chunk-3QXHJBE3.js";import{M as B,U as T,ba as P,c as O,ca as j,j as A,na as X,oa as N,r as D,x as U}from"./chunk-GK5PSUKH.js";import{c as Y}from"./chunk-ILCWDEZN.js";import{d as H,h as Z,i as J,j as Q,k as G,n as K}from"./chunk-3K25OV6X.js";import{Bb as V,G as ee,K as et,N as ei,Sb as en,_ as ea,a as er,o as eo,tb as el}from"./chunk-SZAI2WB4.js";import{J as es,K as ed}from"./chunk-PJJSDGLB.js";import{a as ec}from"./chunk-YHMTSXIR.js";import"./chunk-QCU5G5PZ.js";var eh=Object.freeze({id:"c4",upstreamId:"c4",maturity:"experimental",label:"C4",headers:["C4Context","C4Container","C4Component","C4Dynamic","C4Deployment"],aliases:[],config:{section:"c4",keys:["diagramMarginX","diagramMarginY","c4ShapeMargin","c4ShapePadding","width","height","boxMargin","nextLinePaddingX","c4ShapeInRow","c4BoundaryInRow","wrap","wrapPadding","maxWidth","compact","typeLegend","personFontSize","personFontWeight","person_bg_color","person_border_color","external_personFontSize","external_personFontWeight","external_person_bg_color","external_person_border_color","systemFontSize","systemFontWeight","system_bg_color","system_border_color","system_dbFontSize","system_dbFontWeight","system_db_bg_color","system_db_border_color","system_queueFontSize","system_queueFontWeight","system_queue_bg_color","system_queue_border_color","external_systemFontSize","external_systemFontWeight","external_system_bg_color","external_system_border_color","external_system_dbFontSize","external_system_dbFontWeight","external_system_db_bg_color","external_system_db_border_color","external_system_queueFontSize","external_system_queueFontWeight","external_system_queue_bg_color","external_system_queue_border_color","containerFontSize","containerFontWeight","container_bg_color","container_border_color","container_dbFontSize","container_dbFontWeight","container_db_bg_color","container_db_border_color","container_queueFontSize","container_queueFontWeight","container_queue_bg_color","container_queue_border_color","external_containerFontSize","external_containerFontWeight","external_container_bg_color","external_container_border_color","external_container_dbFontSize","external_container_dbFontWeight","external_container_db_bg_color","external_container_db_border_color","external_container_queueFontSize","external_container_queueFontWeight","external_container_queue_bg_color","external_container_queue_border_color","componentFontSize","componentFontWeight","component_bg_color","component_border_color","component_dbFontSize","component_dbFontWeight","component_db_bg_color","component_db_border_color","component_queueFontSize","component_queueFontWeight","component_queue_bg_color","component_queue_border_color","external_componentFontSize","external_componentFontWeight","external_component_bg_color","external_component_border_color","external_component_dbFontSize","external_component_dbFontWeight","external_component_db_bg_color","external_component_db_border_color","external_component_queueFontSize","external_component_queueFontWeight","external_component_queue_bg_color","external_component_queue_border_color","boundaryFontSize","boundaryFontWeight","boundary_bg_color","boundary_border_color","nodeFontSize","nodeFontWeight","node_bg_color","node_border_color","useMaxWidth","personFont","personFontFamily","external_personFont","external_personFontFamily","systemFont","systemFontFamily","system_dbFont","system_dbFontFamily","system_queueFont","system_queueFontFamily","external_systemFont","external_systemFontFamily","external_system_dbFont","external_system_dbFontFamily","external_system_queueFont","external_system_queueFontFamily","containerFont","containerFontFamily","container_dbFont","container_dbFontFamily","container_queueFont","container_queueFontFamily","external_containerFont","external_containerFontFamily","external_container_dbFont","external_container_dbFontFamily","external_container_queueFont","external_container_queueFontFamily","componentFont","componentFontFamily","component_dbFont","component_dbFontFamily","component_queueFont","component_queueFontFamily","external_componentFont","external_componentFontFamily","external_component_dbFont","external_component_dbFontFamily","external_component_queueFont","external_component_queueFontFamily","boundaryFont","boundaryFontFamily","nodeFont","nodeFontFamily","messageFont","messageFontFamily","messageFontSize","messageFontWeight"],noopKeys:["useMaxWidth","personFont","personFontFamily","external_personFont","external_personFontFamily","systemFont","systemFontFamily","system_dbFont","system_dbFontFamily","system_queueFont","system_queueFontFamily","external_systemFont","external_systemFontFamily","external_system_dbFont","external_system_dbFontFamily","external_system_queueFont","external_system_queueFontFamily","containerFont","containerFontFamily","container_dbFont","container_dbFontFamily","container_queueFont","container_queueFontFamily","external_containerFont","external_containerFontFamily","external_container_dbFont","external_container_dbFontFamily","external_container_queueFont","external_container_queueFontFamily","componentFont","componentFontFamily","component_dbFont","component_dbFontFamily","component_queueFont","component_queueFontFamily","external_componentFont","external_componentFontFamily","external_component_dbFont","external_component_dbFontFamily","external_component_queueFont","external_component_queueFontFamily","boundaryFont","boundaryFontFamily","nodeFont","nodeFontFamily","messageFont","messageFontFamily","messageFontSize","messageFontWeight"]},identity:{id:"family:c4",kind:"family",version:"1.0.0",compatibility:{core:"0.5.6"},provenance:{owner:"agentic-mermaid",source:"built-in"}},collisionPriority:100,semanticChannels:["category","status"],semanticRoles:["prelude","title","defs","chrome","group","group-header","edge","edge-label","node","label","legend"],scenePrimitiveEvidence:[{role:"prelude",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"title",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"defs",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"defs",primitive:"marker",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group-header",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group-header",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"edge",primitive:"connector",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"edge-label",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"node",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"node",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"label",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"legend",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"legend",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"legend",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]}],example:`C4Context
|
|
2
2
|
Person(user, "Customer")
|
|
3
3
|
System(api, "API", "Serves requests")
|
|
4
4
|
Rel(user, api, "Uses", "HTTPS")`,detect:es,detectLoose:ed}),eg=new Map([["person","person"],["box","rectangle"],["rectangle","rectangle"],["cylinder","database"],["database","database"],["db","database"],["queue","queue"],["pipe","queue"]]);function ep(e){return void 0===e?void 0:eg.get(e.trim().toLowerCase())}function em(e){return ep(e.style.shape)??e.shape}var eu=(e,t,i=0)=>{if(void 0===e)return t;if("number"!=typeof e||!Number.isFinite(e)||e<i||e>1e4)throw RangeError(`Invalid C4 numeric configuration ${JSON.stringify(e)}; expected a finite number from ${i} to 10000`);return e},ef=(e,t)=>{let i=eu(e,t,1);if(!Number.isSafeInteger(i))throw RangeError(`Invalid C4 row count ${JSON.stringify(e)}; expected a positive integer`);return i};function ey(e={},t={}){let i=!0===(e=Object.fromEntries(Object.entries(e).filter(([e,t])=>ev[e]?.valid(t)??!0))).compact;return{compact:i,typeLegend:!1!==e.typeLegend,...void 0===e.maxWidth?{}:{maxWidth:eu(e.maxWidth,1e4,1)},marginX:eu(e.diagramMarginX,i?16:24),marginY:eu(e.diagramMarginY,i?16:24),gap:eu(e.c4ShapeMargin,i?32:56),padding:eu(e.c4ShapePadding,i?10:16,4),minimumWidth:eu(e.width,i?120:150,24),minimumHeight:eu(e.height,i?60:76,24),boundaryPadding:eu(e.boxMargin,i?16:24,12),rowGap:eu(e.nextLinePaddingX,i?36:56),shapesPerRow:ef(e.c4ShapeInRow,3),boundariesPerRow:ef(e.c4BoundaryInRow,2),...!1===e.wrap?{}:{wrapWidth:eu(e.wrapPadding,i?220:260,40)},input:e,themeVariables:t}}function ex(e,t){let i="external"in e?`${e.external?"external_":""}${e.kind}${"database"===e.shape?"_db":"queue"===e.shape?"_queue":""}`:"deployment"===e.kind?"node":"boundary",{input:n,themeVariables:a}=t,r=(t,i)=>{if(void 0===t)return;let n=Y(t,"color"!==i);if(void 0===n)throw new P(`C4 ${e.id}`,i,String(t),`UpdateElementStyle(${e.id})`);return n},o=n[`${i}FontSize`],l=n[`${i}FontWeight`];return{fill:r(e.style.bgColor??n[`${i}_bg_color`]??a[`${i}_bg_color`],"fill"),stroke:r(e.style.borderColor??n[`${i}_border_color`]??a[`${i}_border_color`],"stroke"),text:r(e.style.fontColor??e.style.textColor,"color"),...void 0===o?{}:{fontSize:eu(o,13,1)},...void 0===l?{}:{fontWeight:eu("string"==typeof l&&/^\d+$/.test(l)?Number(l):l,500,1)},dashed:void 0===e.style.lineStyle?"external"in e&&e.external:"dashed"===e.style.lineStyle||"dotted"===e.style.lineStyle}}var eb=["person","external_person",...["system","container","component"].flatMap(e=>["","external_"].flatMap(t=>["","_db","_queue"].map(i=>`${t}${e}${i}`))),"boundary","node"],e_=Object.freeze(["diagramMarginX","diagramMarginY","c4ShapeMargin","c4ShapePadding","width","height","boxMargin","nextLinePaddingX","c4ShapeInRow","c4BoundaryInRow","wrap","wrapPadding","maxWidth","compact","typeLegend",...eb.flatMap(e=>[`${e}FontSize`,`${e}FontWeight`,`${e}_bg_color`,`${e}_border_color`])]),ew=(Object.freeze(["useMaxWidth",...[...eb,"message"].flatMap(e=>[`${e}Font`,`${e}FontFamily`]),"messageFontSize","messageFontWeight"]),Object.freeze({maxWidth:1,diagramMarginX:0,diagramMarginY:0,c4ShapeMargin:0,c4ShapePadding:4,width:24,height:24,boxMargin:12,nextLinePaddingX:0,c4ShapeInRow:1,c4BoundaryInRow:1,wrapPadding:40})),ev=(()=>{let e=Object.assign(Object.create(null),{wrap:f,compact:f,typeLegend:f});for(let[t,i]of Object.entries(ew)){let n=y(i,1e4);e[t]="c4ShapeInRow"===t||"c4BoundaryInRow"===t?u("an integer from 1 through 10000",e=>Number.isSafeInteger(e)&&n.valid(e)):n}for(let t of e_)if(/FontSize$/.test(t)&&(e[t]=y(1,1e4)),/FontWeight$/.test(t)){let i=y(1,1e3);e[t]=u(i.expected,e=>i.valid("string"==typeof e&&/^\d+$/.test(e)?Number(e):e))}return Object.freeze(e)})();function ek(e){let t=new Map([...e.elements,...e.boundaries].map(e=>[e.id,e.id])),i=new Map(e.relationships.map(e=>[e.id,e.id]));return{nodes:t,relationships:i,generated:en([...t.keys(),...i.keys(),...e.legend?.entries.map(e=>e.id)??[]])}}function eF(e){let t=`${e.external?"External ":""}${e.kind[0].toUpperCase()}${e.kind.slice(1)}${"database"===e.shape?": Database":"queue"===e.shape?": Queue":""}`,i=e.style.techn??e.technology;return[e.label,`[${t}${i?`: ${i}`:""}]`,e.description,e.tags.length?`[tags: ${e.tags.join(", ")}]`:void 0,e.sprite?`[sprite: ${e.sprite}]`:void 0].filter(e=>void 0!==e&&""!==e).join(`
|
|
5
5
|
`)}function eS(e){let t="deployment"===e.kind?"Deployment Node":`${"boundary"===e.kind?"":`${e.kind[0].toUpperCase()}${e.kind.slice(1)} `}Boundary`;return[e.label,`[${t}${e.type?`: ${e.type}`:""}]`,e.description,e.tags.length?`[tags: ${e.tags.join(", ")}]`:void 0,e.sprite?`[sprite: ${e.sprite}]`:void 0].filter(e=>void 0!==e&&""!==e).join(`
|
|
6
6
|
`)}function e$(e,t){let i=t.index??("C4Dynamic"===e.variant?String(t.order):void 0);return[`${void 0!==i?`${i}: `:""}${t.label}`,t.technology?`[${t.technology}]`:void 0,t.description,t.tags.length?`[tags: ${t.tags.join(", ")}]`:void 0,t.sprite?`[sprite: ${t.sprite}]`:void 0].filter(e=>void 0!==e&&""!==e).join(`
|
|
7
|
-
`)}function eM(e,t){return e.statements.find(e=>e.id===t)?.span.line}function eC(e,t){let i=ek(e),n=new Map;for(let a of e.elements){let e=`${a.external?"external-":""}${a.kind}:${a.shape}`,r=`${a.external?"External ":""}${a.kind[0].toUpperCase()}${a.kind.slice(1)}${"database"===a.shape?" / Database":"queue"===a.shape?" / Queue":""}`;if(!n.has(e)){let o=t?ex(a,t):void 0;n.set(e,{id:i.generated(`c4:legend:${e}`,["c4","legend",e]),label:r,kind:"element",shape:em(a),external:a.external,style:{...a.style,...o?.fill?{bgColor:o.fill}:{},...o?.stroke?{borderColor:o.stroke}:{}}})}}return[...t?.typeLegend!==!1&&n.size>1||e.legend?.visible?[...n.values()]:[],...e.legend?.visible?e.legend.entries:[]]}var eW=class extends RangeError{code="C4_ROUTE_WORK_LIMIT";constructor(){super("C4_ROUTE_WORK_LIMIT: physical corridor checks exceed 400000; split the diagram or reduce its relationships"),this.name="C4RouteWorkLimitError"}},eR={T:{x:0,y:-1},R:{x:1,y:0},B:{x:0,y:1},L:{x:-1,y:0}},eL=(e,t)=>e.x<=t.x&&e.y<=t.y&&e.x+e.width>=t.x+t.width&&e.y+e.height>=t.y+t.height,eI=e=>({x:e.x+e.width/2,y:e.y+e.height/2});function ez(e,t,i){if("T"===t||"B"===t){let n=e.cylinder?8*(1-Math.sqrt(Math.max(0,1-(2*i-1)**2))):0;return{x:e.x+e.width*i,y:e.y+("B"===t?e.height-n:n)}}let n=e.container?e.headerHeight??0:8*!!e.cylinder;return{x:e.x+("R"===t?e.width:0),y:e.y+n+(e.height-n-8*!!e.cylinder)*i}}function eq(e,t,i,n){return ez(e,t,(i+1)/(n+1))}var eE={T:"B",R:"L",B:"T",L:"R"};function eB(e){if(!e.label||!e.labelPosition||!e.labelBlock)return;let t=e.labelBlock.width+20,i=e.labelBlock.height+16;return{x:e.labelPosition.x-t/2,y:e.labelPosition.y-i/2,width:t,height:i}}var eT=(e,t)=>Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y)),eP=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}),eO=e=>e.flatMap(e=>[e,...eO(e.children)]);function eA(e,t,i){let n=0,a=1;for(let r of["x","y"]){let o=t[r]-e[r],l=i[r]+.01,s=i[r]+("x"===r?i.width:i.height)-.01;if(.001>Math.abs(o)){if(e[r]<=l||e[r]>=s)return!1;continue}let d=(l-e[r])/o,c=(s-e[r])/o;if((n=Math.max(n,Math.min(d,c)))>=(a=Math.min(a,Math.max(d,c))))return!1}return n<a}function ej(e,t){let i=[],n=e.inlineStyle?.["stroke-width"]?1:t*("thick"===e.style?2:1),a=H.width*n,r=(e.inlineStyle?.["stroke-width"]?H.width:H.height)*n/2,o=.375*n;for(let t of[!0,!1]){if(!(t?e.hasArrowStart:e.hasArrowEnd))continue;let n=e.points.at(t?0:-1),l=(t?e.points.slice(1):e.points.slice(0,-1).reverse()).find(e=>n&&Math.hypot(e.x-n.x,e.y-n.y)>.01);if(!n||!l)continue;let s=Math.hypot(n.x-l.x,n.y-l.y),d=(n.x-l.x)/s,c=(n.y-l.y)/s,h=[n,{x:n.x-d*a-c*r,y:n.y-c*a+d*r},{x:n.x-d*a+c*r,y:n.y-c*a-d*r}],g=Math.min(...h.map(e=>e.x)),p=Math.min(...h.map(e=>e.y));i.push({...eP({x:g,y:p,width:Math.max(...h.map(e=>e.x))-g,height:Math.max(...h.map(e=>e.y))-p},o),endpoint:t?e.source:e.target,polygon:h,strokePadding:o})}return i}function eN(e,t){return[...e,...eO(t).flatMap(e=>[{x:e.x,y:e.y,width:e.width,height:e.headerHeight??0},{x:e.x,y:e.y,width:1,height:e.height},{x:e.x+e.width-1,y:e.y,width:1,height:e.height},{x:e.x,y:e.y+e.height-1,width:e.width,height:1}])]}var eX=["C4Context","C4Container","C4Component","C4Dynamic","C4Deployment"],eD=class extends D{},eU=/^(Person|System|Container|Component)(Db|Queue)?(_Ext)?$/,eY={Boundary:"boundary",Enterprise_Boundary:"enterprise",System_Boundary:"system",Container_Boundary:"container",Deployment_Node:"deployment",Node:"deployment",Node_L:"deployment",Node_R:"deployment"},eH=new Set(["Rel","BiRel","Rel_U","Rel_Up","Rel_D","Rel_Down","Rel_L","Rel_Left","Rel_R","Rel_Right","Rel_Back","RelIndex"]),eZ={U:"BT",Up:"BT",D:"TB",Down:"TB",L:"RL",Left:"RL",R:"LR",Right:"LR"},eJ=["elementName","bgColor","fontColor","borderColor","shadowing","shape","sprite","techn","legendText","legendSprite"],eQ=["from","to","textColor","lineColor","offsetX","offsetY"],eV=["tagStereo","bgColor","fontColor","borderColor","shadowing","shape","sprite","techn","legendText","legendSprite"],eG=["tagStereo","textColor","lineColor","lineStyle","sprite","techn","legendText","legendSprite"];function eK(e,t){if(!R("c4"))return;let{start:i,end:n,line:a,column:r}=e.span;L("c4",t,e.raw,{line:a,column:r,offset:i,endOffset:n,unit:"physical"})}function e0(e,t=!0){let i=e.trim();if(i.length>=2&&('"'===i[0]||"'"===i[0])&&i.at(-1)===i[0]){let e=i.slice(1,-1).trim();return t?m(e):e}return t?m(i):i}function e4(e,t,i){let n;for(let a=0;a<e.length;a++)(e[a].name??t[a])===i&&(n=e[a]);if(n)return m(et(e0(n.name?n.raw.replace(/^\s*\$[A-Za-z_][A-Za-z_0-9]*\s*=/,""):n.raw,!1)))}function e1(e,t=[]){return e.length>0&&e.length>=t.length&&e.every((i,n)=>{if(i.name&&(t.includes(i.name)||n<t.length&&"label"!==t[n])||i.raw.includes("%%{"))return!1;let a=(i.name?i.raw.replace(/^\s*\$[A-Za-z_][A-Za-z_0-9]*\s*=/,""):i.raw).trim();return i.name?/^ *\$[A-Za-z_][A-Za-z_0-9]* *= *"[^"]+"$/.test(i.raw):a.startsWith('"')?/^ *"[^"]*"$/.test(i.raw):""===i.raw&&n<e.length-1||n<e.length-1&&a.length>0&&!/^[\$']|[(),\r\n]/.test(a)})}function e2(e,t,i){if(!e.name&&t<i.length-1&&!/^["'$)]/.test(e.raw.trim())&&!e.raw.includes(","))return!1;for(let t of(e.name?e.raw.replace(/^\s*\$[A-Za-z_][A-Za-z_0-9]*\s*=/,""):e.raw).matchAll(/"[^"]*"|'[^']*'|(\$[A-Za-z_][A-Za-z_0-9]*\s*(?:=|["']))/g))if(t[1])return!0;return!1}function e3(e,t){let i=Object.create(null);for(let n=0;n<e.length;n++){let a=e[n],r=a.name??t[n];void 0!==r&&(i[r]=a.value)}return i}function e6(e){return e.startsWith("Person")||e.startsWith("System")?["alias","label","descr","sprite","tags","link"]:["alias","label","techn","descr","sprite","tags","link"]}function e5(e){return"deployment"===eY[e]?["alias","label","type","descr","sprite","tags","link"]:"Boundary"===e?["alias","label","type","tags","link"]:["alias","label","tags","link"]}function e8(e){return"RelIndex"===e?["index","from","to","label","tags","link"]:["from","to","label","techn","descr","sprite","tags","link"]}function e9(e){return e?e.split("+").map(e=>e.trim()).filter(Boolean):[]}function e7(e){return""===e?void 0:e}function te(e,t,i){let n=e[t];if(void 0===n||"label"!==t&&!n.trim())throw Error(`C4: ${i} requires ${"label"===t?"a":"a non-empty"} ${t}`);return n}function tt(e,t,i,n){let a=e4(e,t,"label");return void 0!==a?a:e[t.indexOf("label")]?.name?"":te(i,"label",n)}function ti(e){let{args:t,style:i,effectiveLink:n,statementId:a,...r}=e;return"name"in e?JSON.stringify([e.name,e.args.map(e=>[e.name,e.value])]):JSON.stringify(r)}function tn(e,t,i,n,a="warning"){e.diagnostics.push({code:"UNSUPPORTED_SYNTAX",syntax:i,severity:a,statementId:t,message:n})}var ta=new Set(["UpdateElementStyle","UpdateRelStyle","UpdateLayoutConfig"]);function tr(e,t){return Object.fromEntries(Object.entries(e).filter(([e,i])=>!t.includes(e)&&""!==i))}var to=O(function(t,i){let n=i.positioned,{body:a,config:r,identities:o}=n,l=Z(i.resolved.renderOptions,void 0,i.resolved.styleFace),s=e=>e&&"strict"!==i.resolved.renderOptions.security&&w(e)?` data-href="${ei(e)}" role="link" tabindex="0"`:"",d=(e,t)=>o.generated(`c4:${e}:${t}`,["c4",e,t]),c=(e,i,n,a,r=!1)=>t.shape({id:d(e,i),role:r?"group":"node",geometry:n,paint:a}),h=e=>[`data-id="${ei(e.id)}"`,`data-c4-kind="${ei(e.kind)}"`,`data-c4-macro="${ei(e.macro)}"`,...e.parentId?[`data-parent-id="${ei(e.parentId)}"`]:[],...e.tags.length?[`data-tags="${ei(JSON.stringify(e.tags))}"`]:[],...s(e.effectiveLink??e.link)?[s(e.effectiveLink??e.link)]:[],...e.sprite?[`data-sprite="${ei(e.sprite)}"`]:[],...void 0!==eM(a,e.statementId)?[`data-source-line="${eM(a,e.statementId)}"`]:[],..."external"in e?[`data-external="${e.external}"`,`data-c4-shape="${e.shape}"`,`data-effective-c4-shape="${em(e)}"`]:[`data-alignment="${e.alignment??"center"}"`]].join(" "),g=new Map(a.boundaries.map(e=>[e.id,e])),p=e=>{let n=g.get(e.id),a=ex(n,r),{x:o,y:s,width:m,height:u}=e,f=a.stroke??l.groupBorderColor??"var(--_node-stroke)",y=a.fill??l.groupFillColor??"var(--_group-fill)",x=a.fill??l.groupHeaderFillColor??"var(--_group-hdr)",b=a.text??N(a.fill?{fill:a.fill}:void 0,l.groupTextColor??X("var(--_text-sec)",x,i.colors)),_=e.headerHeight??36,w=[],v=e=>w.push({node:e,indent:2}),k="solid"===n.style.lineStyle?void 0:"dotted"===n.style.lineStyle?"1 3":"dashed"===n.style.lineStyle?"5 3":"deployment"===n.kind?void 0:"6 4";v(c(n.id,"boundary-frame",{kind:"rect",x:o,y:s,width:m,height:u,rx:l.groupCornerRadius,ry:l.groupCornerRadius},{fill:y,stroke:f,strokeWidth:String(l.groupLineWidth),...k?{strokeDasharray:k}:{}},!0));let F={kind:"path",d:el(o,s,m,_,l.groupCornerRadius)},S={fill:x,stroke:f,strokeWidth:String(l.groupLineWidth)};v(t.shape({id:d(n.id,"boundary-band"),role:"group-header",geometry:F,paint:S}));let $=e.labelBlock,M="left"===n.alignment?"start":"right"===n.alignment?"end":"middle",C="left"===n.alignment?o+r.padding:"right"===n.alignment?o+m-r.padding:o+m/2,W=s+_/2;for(let i of(v(t.text({id:d(n.id,"boundary-text"),role:"group-header",text:$.text,block:$,x:C,y:W,fontSize:$.fontSize,fontWeight:$.fontWeight,letterSpacing:$.letterSpacing,anchor:M,paint:{fill:b}})),e.children))v(p(i));return t.group({id:d(n.id,"frame"),role:"group",open:`<g class="cluster c4-boundary" ${h(n)}>`,close:"</g>",children:w,channels:{category:n.kind}})},m=new Map(a.relationships.map(e=>[e.id,e])),u=e({...t,connector:e=>{let n=K(e),a=m.get(n.identity?.id??"");if(!a)return t.connector(e);let r="dotted"===a.style.lineStyle?{...n.stroke,dash:{array:"1 3"}}:n.stroke,o="strict"===i.resolved.renderOptions.security?void 0:a.effectiveLink??a.link,{markers:l}=n,s=n.labels[0],c={className:"edge",data:{style:n.lineStyle,"arrow-start":String(!!l.start),"arrow-end":String(!!l.end),...l.start?{"marker-start":l.start.shape}:{},...l.end?{"marker-end":l.end.shape}:{},...s?{label:er(s.text)}:{},"c4-macro":a.macro,"authored-from":a.from,"authored-to":a.to,order:String(a.order),...void 0!==a.index?{index:a.index}:{},...a.tags.length?{tags:JSON.stringify(a.tags)}:{},...o&&w(o)?{href:o}:{}},...o&&w(o)?{tabIndex:0}:{}},h={id:d(a.id,"relationship"),role:"edge",identity:n.identity,geometry:n.route.geometry,paint:{stroke:r.color,strokeWidth:String(r.width)},lineStyle:n.lineStyle,endpoints:n.endpoints,relationship:{...n.relationship,kind:`c4-${a.macro}`},route:n.route,stroke:r,markers:n.markers,hit:n.hit,labels:n.labels.map(e=>({...e,visual:{kind:"companion",markId:d(a.id,"label-text")},...a.style.textColor?{paint:{...e.paint,fill:a.style.textColor}}:{}})),channels:{category:"relationship",...a.tags.length?{status:a.tags.join(",")}:{}},attributes:c};return t.connector(h)}},i,{surfaces:!1,edgeLabels:!1,beforeEdges:()=>n.groups.map(p)}),f=u.parts,y=n.edges.flatMap(e=>{if(!e.label||!e.labelBlock||!e.labelPosition)return[];let n=m.get(e.id),a=e.labelBlock,{x:r,y:o}=e.labelPosition,s=n.style.textColor??n.style.fontColor??l.edgeTextColor??"var(--_text-sec)",c={kind:"rect",...eB(e),rx:3,ry:3};return[t.group({id:d(n.id,"relationship-label"),role:"edge-label",open:`<g class="edge-label" data-id="${ei(d(n.id,"label"))}" data-role="edge-label" data-edge-id="${ei(n.id)}" data-from="${ei(n.source)}" data-to="${ei(n.target)}">`,close:"</g>",children:[{indent:2,node:t.shape({id:d(n.id,"label-halo"),role:"chrome",geometry:c,paint:{fill:"var(--bg)",stroke:"var(--_inner-stroke)",strokeWidth:"1"}})},{indent:2,node:t.text({id:d(n.id,"label-text"),role:"label",text:a.text,block:a,x:r,y:o,fontSize:a.fontSize,fontWeight:a.fontWeight,letterSpacing:a.letterSpacing,anchor:"middle",paint:{fill:s},pageFill:n.style.textColor??n.style.fontColor??X("var(--_text-sec)","var(--bg)",i.colors)})}]})]});if(f.splice(f.length-1,0,...y,...n.nodes.map(e=>((e,n)=>{let{x:a,y:o,width:s,height:g}=n,p=ex(e,r),m=em(e),u=p.fill??l.nodeFillColor??"var(--_node-fill)",f=p.stroke??l.nodeBorderColor??"var(--_node-stroke)",y=p.text??N(p.fill?{fill:p.fill}:void 0,l.nodeTextColor??X("var(--_text)",u,i.colors)),x={fill:u,stroke:f,strokeWidth:String(l.nodeLineWidth),...p.dashed?{strokeDasharray:"5 3"}:{}},b=[],_=e=>b.push({node:e,indent:2});if("database"===m){let t=`M ${a} ${o+8} A ${s/2} 8 0 0 1 ${a+s} ${o+8} L ${a+s} ${o+g-8} A ${s/2} 8 0 0 1 ${a} ${o+g-8} Z`;_(c(e.id,"surface",{kind:"path",d:t},x)),_(c(e.id,"database-rim",{kind:"ellipse",cx:a+s/2,cy:o+8,rx:s/2,ry:8},{fill:"none",stroke:f,strokeWidth:"1"}))}else{if(_(c(e.id,"surface",{kind:"rect",x:a,y:o,width:s,height:g,rx:l.cornerRadius??0,ry:l.cornerRadius??0},x)),"queue"===m)for(let[t,i]of[a+8,a+s-8].entries())_(c(e.id,`queue-end:${t}`,{kind:"line",x1:i,y1:o,x2:i,y2:o+g},{stroke:f,strokeWidth:"1"}));if("person"===m){let t=a+s/2,i=o+g/2+19-n.labelBlock.height/2-31,r={fill:y,stroke:y,strokeWidth:"1"};_(c(e.id,"person-head",{kind:"circle",cx:t,cy:i,r:7},r));let l=`M ${t-16} ${i+26} Q ${t-16} ${i+11} ${t} ${i+11} Q ${t+16} ${i+11} ${t+16} ${i+26} Z`;_(c(e.id,"person-shoulders",{kind:"path",d:l},r))}}let w=n.labelBlock;return _(t.text({id:d(e.id,"text"),role:"label",text:w.text,block:w,x:a+s/2,y:o+g/2+("person"===m?19:4*("database"===m)),fontSize:w.fontSize,fontWeight:w.fontWeight,letterSpacing:w.letterSpacing,anchor:"middle",paint:{fill:y}})),t.group({id:d(e.id,"card"),role:"node",open:`<g class="node c4-${e.kind}" ${h(e)}>`,close:"</g>",children:b,channels:{category:`${e.external?"external-":""}${e.kind}`,...e.tags.length?{status:e.tags.join(",")}:{}}})})(a.elements.find(t=>t.id===e.id),e))),n.legend){let e=n.legend,a=[],r=eo(i.resolved.styleFace,"legend",{},{includeFallback:!1}),o=r?.textColor??"var(--_text)",s=e.heading,c=e.x+12,h=e.y+8+s.height/2,g=t.text({id:d("legend","heading"),role:"legend",text:s.text,block:s,x:c,y:h,fontSize:s.fontSize,fontWeight:s.fontWeight,letterSpacing:s.letterSpacing,anchor:"start",paint:{fill:o}});a.push({node:g,indent:2});let p=e.y+20+s.height;for(let i of e.entries){let{block:n}=i,s=e.x+38,c=p+n.height/2,h=i.style.borderColor??i.style.lineColor??r?.strokeColor??r?.borderColor??l.nodeBorderColor??"var(--_line)",g=i.style.bgColor??r?.fillColor??l.nodeFillColor??"var(--_node-fill)",m=String(r?.lineWidth??1),u="dotted"===i.style.lineStyle?"1 3":"dashed"===i.style.lineStyle||i.external?"5 3":void 0,f={fill:g,stroke:h,strokeWidth:m,...u?{strokeDasharray:u}:{}},y=e.x+10,x=n.height,b=(e,n)=>a.push({indent:2,node:t.shape({id:d(i.id,e),role:"legend",geometry:n,paint:f})});if("relationship"===i.kind)b("legend-swatch",{kind:"line",x1:y,y1:c,x2:y+18,y2:c});else if("database"===i.shape){let e=Math.min(3,x/4);b("legend-swatch",{kind:"path",d:`M ${y} ${p+e} A 9 ${e} 0 0 1 ${y+18} ${p+e} L ${y+18} ${p+x-e} A 9 ${e} 0 0 1 ${y} ${p+x-e} Z`}),b("legend-rim",{kind:"ellipse",cx:y+9,cy:p+e,rx:9,ry:e})}else if("person"===i.shape){let e=Math.min(3,x/5),t=y+9;b("legend-head",{kind:"circle",cx:t,cy:p+e,r:e}),b("legend-swatch",{kind:"path",d:`M ${y+3} ${p+x} Q ${y+3} ${p+2.5*e} ${t} ${p+2.5*e} Q ${y+15} ${p+2.5*e} ${y+15} ${p+x} Z`})}else if(b("legend-swatch",{kind:"rect",x:y,y:p,width:18,height:x}),"queue"===i.shape)for(let[e,t]of[y+3,y+15].entries())b(`legend-end:${e}`,{kind:"line",x1:t,y1:p,x2:t,y2:p+x});a.push({indent:2,node:t.text({id:d(i.id,"legend-text"),role:"legend",text:n.text,block:n,x:s,y:c,fontSize:n.fontSize,fontWeight:n.fontWeight,letterSpacing:n.letterSpacing,anchor:"start",paint:{fill:o}})}),p+=n.height+10}f.splice(f.length-1,0,t.group({id:d("legend","container"),role:"legend",open:'<g class="c4-legend">',close:"</g>",children:a}))}return{...u,family:"c4",parts:f}}),tl=W(eh,{configDiagnostics:e=>x("c4",e,ev),normalizeRequest:e=>{let t=e.source.authoredWrapperLength??e.source.wrapperSource?.length??0,i=e.source.originalText.slice(0,t),n=function(e){let t=function(e,t){let i="string"==typeof e?e:e.join(`
|
|
7
|
+
`)}function eM(e,t){return e.statements.find(e=>e.id===t)?.span.line}function eC(e,t){let i=ek(e),n=new Map;for(let a of e.elements){let e=`${a.external?"external-":""}${a.kind}:${a.shape}`,r=`${a.external?"External ":""}${a.kind[0].toUpperCase()}${a.kind.slice(1)}${"database"===a.shape?" / Database":"queue"===a.shape?" / Queue":""}`;if(!n.has(e)){let o=t?ex(a,t):void 0;n.set(e,{id:i.generated(`c4:legend:${e}`,["c4","legend",e]),label:r,kind:"element",shape:em(a),external:a.external,style:{...a.style,...o?.fill?{bgColor:o.fill}:{},...o?.stroke?{borderColor:o.stroke}:{}}})}}return[...t?.typeLegend!==!1&&n.size>1||e.legend?.visible?[...n.values()]:[],...e.legend?.visible?e.legend.entries:[]]}var eW=class extends RangeError{code="C4_ROUTE_WORK_LIMIT";constructor(){super("C4_ROUTE_WORK_LIMIT: physical corridor checks exceed 400000; split the diagram or reduce its relationships"),this.name="C4RouteWorkLimitError"}},eR={T:{x:0,y:-1},R:{x:1,y:0},B:{x:0,y:1},L:{x:-1,y:0}},eL=(e,t)=>e.x<=t.x&&e.y<=t.y&&e.x+e.width>=t.x+t.width&&e.y+e.height>=t.y+t.height,eI=e=>({x:e.x+e.width/2,y:e.y+e.height/2});function ez(e,t,i){if("T"===t||"B"===t){let n=e.cylinder?8*(1-Math.sqrt(Math.max(0,1-(2*i-1)**2))):0;return{x:e.x+e.width*i,y:e.y+("B"===t?e.height-n:n)}}let n=e.container?e.headerHeight??0:8*!!e.cylinder;return{x:e.x+("R"===t?e.width:0),y:e.y+n+(e.height-n-8*!!e.cylinder)*i}}function eE(e,t,i,n){return ez(e,t,(i+1)/(n+1))}var eq={T:"B",R:"L",B:"T",L:"R"};function eB(e){if(!e.label||!e.labelPosition||!e.labelBlock)return;let t=e.labelBlock.width+20,i=e.labelBlock.height+16;return{x:e.labelPosition.x-t/2,y:e.labelPosition.y-i/2,width:t,height:i}}var eT=(e,t)=>Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y)),eP=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}),eO=e=>e.flatMap(e=>[e,...eO(e.children)]);function ej(e,t,i){let n=0,a=1;for(let r of["x","y"]){let o=t[r]-e[r],l=i[r]+.01,s=i[r]+("x"===r?i.width:i.height)-.01;if(.001>Math.abs(o)){if(e[r]<=l||e[r]>=s)return!1;continue}let d=(l-e[r])/o,c=(s-e[r])/o;if((n=Math.max(n,Math.min(d,c)))>=(a=Math.min(a,Math.max(d,c))))return!1}return n<a}function eA(e,t){let i=[],n=e.inlineStyle?.["stroke-width"]?1:t*("thick"===e.style?2:1),a=H.width*n,r=(e.inlineStyle?.["stroke-width"]?H.width:H.height)*n/2,o=.375*n;for(let t of[!0,!1]){if(!(t?e.hasArrowStart:e.hasArrowEnd))continue;let n=e.points.at(t?0:-1),l=(t?e.points.slice(1):e.points.slice(0,-1).reverse()).find(e=>n&&Math.hypot(e.x-n.x,e.y-n.y)>.01);if(!n||!l)continue;let s=Math.hypot(n.x-l.x,n.y-l.y),d=(n.x-l.x)/s,c=(n.y-l.y)/s,h=[n,{x:n.x-d*a-c*r,y:n.y-c*a+d*r},{x:n.x-d*a+c*r,y:n.y-c*a-d*r}],g=Math.min(...h.map(e=>e.x)),p=Math.min(...h.map(e=>e.y));i.push({...eP({x:g,y:p,width:Math.max(...h.map(e=>e.x))-g,height:Math.max(...h.map(e=>e.y))-p},o),endpoint:t?e.source:e.target,polygon:h,strokePadding:o})}return i}function eX(e,t){return[...e,...eO(t).flatMap(e=>[{x:e.x,y:e.y,width:e.width,height:e.headerHeight??0},{x:e.x,y:e.y,width:1,height:e.height},{x:e.x+e.width-1,y:e.y,width:1,height:e.height},{x:e.x,y:e.y+e.height-1,width:e.width,height:1}])]}var eN=["C4Context","C4Container","C4Component","C4Dynamic","C4Deployment"],eD=class extends D{},eU=/^(Person|System|Container|Component)(Db|Queue)?(_Ext)?$/,eY={Boundary:"boundary",Enterprise_Boundary:"enterprise",System_Boundary:"system",Container_Boundary:"container",Deployment_Node:"deployment",Node:"deployment",Node_L:"deployment",Node_R:"deployment"},eH=new Set(["Rel","BiRel","Rel_U","Rel_Up","Rel_D","Rel_Down","Rel_L","Rel_Left","Rel_R","Rel_Right","Rel_Back","RelIndex"]),eZ={U:"BT",Up:"BT",D:"TB",Down:"TB",L:"RL",Left:"RL",R:"LR",Right:"LR"},eJ=["elementName","bgColor","fontColor","borderColor","shadowing","shape","sprite","techn","legendText","legendSprite"],eQ=["from","to","textColor","lineColor","offsetX","offsetY"],eG=["tagStereo","bgColor","fontColor","borderColor","shadowing","shape","sprite","techn","legendText","legendSprite"],eK=["tagStereo","textColor","lineColor","lineStyle","sprite","techn","legendText","legendSprite"];function eV(e,t){if(!R("c4"))return;let{start:i,end:n,line:a,column:r}=e.span;L("c4",t,e.raw,{line:a,column:r,offset:i,endOffset:n,unit:"physical"})}function e0(e,t=!0){let i=e.trim();if(i.length>=2&&('"'===i[0]||"'"===i[0])&&i.at(-1)===i[0]){let e=i.slice(1,-1).trim();return t?m(e):e}return t?m(i):i}function e4(e,t,i){let n;for(let a=0;a<e.length;a++)(e[a].name??t[a])===i&&(n=e[a]);if(n)return m(et(e0(n.name?n.raw.replace(/^\s*\$[A-Za-z_][A-Za-z_0-9]*\s*=/,""):n.raw,!1)))}function e1(e,t=[]){return e.length>0&&e.length>=t.length&&e.every((i,n)=>{if(i.name&&(t.includes(i.name)||n<t.length&&"label"!==t[n])||i.raw.includes("%%{"))return!1;let a=(i.name?i.raw.replace(/^\s*\$[A-Za-z_][A-Za-z_0-9]*\s*=/,""):i.raw).trim();return i.name?/^ *\$[A-Za-z_][A-Za-z_0-9]* *= *"[^"]+"$/.test(i.raw):a.startsWith('"')?/^ *"[^"]*"$/.test(i.raw):""===i.raw&&n<e.length-1||n<e.length-1&&a.length>0&&!/^[\$']|[(),\r\n]/.test(a)})}function e2(e,t,i){if(!e.name&&t<i.length-1&&!/^["'$)]/.test(e.raw.trim())&&!e.raw.includes(","))return!1;for(let t of(e.name?e.raw.replace(/^\s*\$[A-Za-z_][A-Za-z_0-9]*\s*=/,""):e.raw).matchAll(/"[^"]*"|'[^']*'|(\$[A-Za-z_][A-Za-z_0-9]*\s*(?:=|["']))/g))if(t[1])return!0;return!1}function e3(e,t){let i=Object.create(null);for(let n=0;n<e.length;n++){let a=e[n],r=a.name??t[n];void 0!==r&&(i[r]=a.value)}return i}function e6(e){return e.startsWith("Person")||e.startsWith("System")?["alias","label","descr","sprite","tags","link"]:["alias","label","techn","descr","sprite","tags","link"]}function e5(e){return"deployment"===eY[e]?["alias","label","type","descr","sprite","tags","link"]:"Boundary"===e?["alias","label","type","tags","link"]:["alias","label","tags","link"]}function e8(e){return"RelIndex"===e?["index","from","to","label","tags","link"]:["from","to","label","techn","descr","sprite","tags","link"]}function e9(e){return e?e.split("+").map(e=>e.trim()).filter(Boolean):[]}function e7(e){return""===e?void 0:e}function te(e,t,i){let n=e[t];if(void 0===n||"label"!==t&&!n.trim())throw Error(`C4: ${i} requires ${"label"===t?"a":"a non-empty"} ${t}`);return n}function tt(e,t,i,n){let a=e4(e,t,"label");return void 0!==a?a:e[t.indexOf("label")]?.name?"":te(i,"label",n)}function ti(e){let{args:t,style:i,effectiveLink:n,statementId:a,...r}=e;return"name"in e?JSON.stringify([e.name,e.args.map(e=>[e.name,e.value])]):JSON.stringify(r)}function tn(e,t,i,n,a="warning"){e.diagnostics.push({code:"UNSUPPORTED_SYNTAX",syntax:i,severity:a,statementId:t,message:n})}var ta=new Set(["UpdateElementStyle","UpdateRelStyle","UpdateLayoutConfig"]);function tr(e,t){return Object.fromEntries(Object.entries(e).filter(([e,i])=>!t.includes(e)&&""!==i))}var to=O(function(t,i){let n=i.positioned,{body:a,config:r,identities:o}=n,l=Z(i.resolved.renderOptions,void 0,i.resolved.styleFace),s=e=>e&&"strict"!==i.resolved.renderOptions.security&&w(e)?` data-href="${ei(e)}" role="link" tabindex="0"`:"",d=(e,t)=>o.generated(`c4:${e}:${t}`,["c4",e,t]),c=(e,i,n,a,r=!1)=>t.shape({id:d(e,i),role:r?"group":"node",geometry:n,paint:a}),h=e=>[`data-id="${ei(e.id)}"`,`data-c4-kind="${ei(e.kind)}"`,`data-c4-macro="${ei(e.macro)}"`,...e.parentId?[`data-parent-id="${ei(e.parentId)}"`]:[],...e.tags.length?[`data-tags="${ei(JSON.stringify(e.tags))}"`]:[],...s(e.effectiveLink??e.link)?[s(e.effectiveLink??e.link)]:[],...e.sprite?[`data-sprite="${ei(e.sprite)}"`]:[],...void 0!==eM(a,e.statementId)?[`data-source-line="${eM(a,e.statementId)}"`]:[],..."external"in e?[`data-external="${e.external}"`,`data-c4-shape="${e.shape}"`,`data-effective-c4-shape="${em(e)}"`]:[`data-alignment="${e.alignment??"center"}"`]].join(" "),g=new Map(a.boundaries.map(e=>[e.id,e])),p=e=>{let n=g.get(e.id),a=ex(n,r),{x:o,y:s,width:m,height:u}=e,f=a.stroke??l.groupBorderColor??"var(--_node-stroke)",y=a.fill??l.groupFillColor??"var(--_group-fill)",x=a.fill??l.groupHeaderFillColor??"var(--_group-hdr)",b=a.text??X(a.fill?{fill:a.fill}:void 0,l.groupTextColor??N("var(--_text-sec)",x,i.colors)),_=e.headerHeight??36,w=[],v=e=>w.push({node:e,indent:2}),k="solid"===n.style.lineStyle?void 0:"dotted"===n.style.lineStyle?"1 3":"dashed"===n.style.lineStyle?"5 3":"deployment"===n.kind?void 0:"6 4";v(c(n.id,"boundary-frame",{kind:"rect",x:o,y:s,width:m,height:u,rx:l.groupCornerRadius,ry:l.groupCornerRadius},{fill:y,stroke:f,strokeWidth:String(l.groupLineWidth),...k?{strokeDasharray:k}:{}},!0));let F={kind:"path",d:el(o,s,m,_,l.groupCornerRadius)},S={fill:x,stroke:f,strokeWidth:String(l.groupLineWidth)};v(t.shape({id:d(n.id,"boundary-band"),role:"group-header",geometry:F,paint:S}));let $=e.labelBlock,M="left"===n.alignment?"start":"right"===n.alignment?"end":"middle",C="left"===n.alignment?o+r.padding:"right"===n.alignment?o+m-r.padding:o+m/2,W=s+_/2;for(let i of(v(t.text({id:d(n.id,"boundary-text"),role:"group-header",text:$.text,block:$,x:C,y:W,fontSize:$.fontSize,fontWeight:$.fontWeight,letterSpacing:$.letterSpacing,anchor:M,paint:{fill:b}})),e.children))v(p(i));return t.group({id:d(n.id,"frame"),role:"group",open:`<g class="cluster c4-boundary" ${h(n)}>`,close:"</g>",children:w,channels:{category:n.kind}})},m=new Map(a.relationships.map(e=>[e.id,e])),u=e({...t,connector:e=>{let n=V(e),a=m.get(n.identity?.id??"");if(!a)return t.connector(e);let r="dotted"===a.style.lineStyle?{...n.stroke,dash:{array:"1 3"}}:n.stroke,o="strict"===i.resolved.renderOptions.security?void 0:a.effectiveLink??a.link,{markers:l}=n,s=n.labels[0],c={className:"edge",data:{style:n.lineStyle,"arrow-start":String(!!l.start),"arrow-end":String(!!l.end),...l.start?{"marker-start":l.start.shape}:{},...l.end?{"marker-end":l.end.shape}:{},...s?{label:er(s.text)}:{},"c4-macro":a.macro,"authored-from":a.from,"authored-to":a.to,order:String(a.order),...void 0!==a.index?{index:a.index}:{},...a.tags.length?{tags:JSON.stringify(a.tags)}:{},...o&&w(o)?{href:o}:{}},...o&&w(o)?{tabIndex:0}:{}},h={id:d(a.id,"relationship"),role:"edge",identity:n.identity,geometry:n.route.geometry,paint:{stroke:r.color,strokeWidth:String(r.width)},lineStyle:n.lineStyle,endpoints:n.endpoints,relationship:{...n.relationship,kind:`c4-${a.macro}`},route:n.route,stroke:r,markers:n.markers,hit:n.hit,labels:n.labels.map(e=>({...e,visual:{kind:"companion",markId:d(a.id,"label-text")},...a.style.textColor?{paint:{...e.paint,fill:a.style.textColor}}:{}})),channels:{category:"relationship",...a.tags.length?{status:a.tags.join(",")}:{}},attributes:c};return t.connector(h)}},i,{surfaces:!1,edgeLabels:!1,beforeEdges:()=>n.groups.map(p)}),f=u.parts,y=n.edges.flatMap(e=>{if(!e.label||!e.labelBlock||!e.labelPosition)return[];let n=m.get(e.id),a=e.labelBlock,{x:r,y:o}=e.labelPosition,s=n.style.textColor??n.style.fontColor??l.edgeTextColor??"var(--_text-sec)",c={kind:"rect",...eB(e),rx:3,ry:3};return[t.group({id:d(n.id,"relationship-label"),role:"edge-label",open:`<g class="edge-label" data-id="${ei(d(n.id,"label"))}" data-role="edge-label" data-edge-id="${ei(n.id)}" data-from="${ei(n.source)}" data-to="${ei(n.target)}">`,close:"</g>",children:[{indent:2,node:t.shape({id:d(n.id,"label-halo"),role:"chrome",geometry:c,paint:{fill:"var(--bg)",stroke:"var(--_inner-stroke)",strokeWidth:"1"}})},{indent:2,node:t.text({id:d(n.id,"label-text"),role:"label",text:a.text,block:a,x:r,y:o,fontSize:a.fontSize,fontWeight:a.fontWeight,letterSpacing:a.letterSpacing,anchor:"middle",paint:{fill:s},pageFill:n.style.textColor??n.style.fontColor??N("var(--_text-sec)","var(--bg)",i.colors)})}]})]});if(f.splice(f.length-1,0,...y,...n.nodes.map(e=>((e,n)=>{let{x:a,y:o,width:s,height:g}=n,p=ex(e,r),m=em(e),u=p.fill??l.nodeFillColor??"var(--_node-fill)",f=p.stroke??l.nodeBorderColor??"var(--_node-stroke)",y=p.text??X(p.fill?{fill:p.fill}:void 0,l.nodeTextColor??N("var(--_text)",u,i.colors)),x={fill:u,stroke:f,strokeWidth:String(l.nodeLineWidth),...p.dashed?{strokeDasharray:"5 3"}:{}},b=[],_=e=>b.push({node:e,indent:2});if("database"===m){let t=`M ${a} ${o+8} A ${s/2} 8 0 0 1 ${a+s} ${o+8} L ${a+s} ${o+g-8} A ${s/2} 8 0 0 1 ${a} ${o+g-8} Z`;_(c(e.id,"surface",{kind:"path",d:t},x)),_(c(e.id,"database-rim",{kind:"ellipse",cx:a+s/2,cy:o+8,rx:s/2,ry:8},{fill:"none",stroke:f,strokeWidth:"1"}))}else{if(_(c(e.id,"surface",{kind:"rect",x:a,y:o,width:s,height:g,rx:l.cornerRadius??0,ry:l.cornerRadius??0},x)),"queue"===m)for(let[t,i]of[a+8,a+s-8].entries())_(c(e.id,`queue-end:${t}`,{kind:"line",x1:i,y1:o,x2:i,y2:o+g},{stroke:f,strokeWidth:"1"}));if("person"===m){let t=a+s/2,i=o+g/2+19-n.labelBlock.height/2-31,r={fill:y,stroke:y,strokeWidth:"1"};_(c(e.id,"person-head",{kind:"circle",cx:t,cy:i,r:7},r));let l=`M ${t-16} ${i+26} Q ${t-16} ${i+11} ${t} ${i+11} Q ${t+16} ${i+11} ${t+16} ${i+26} Z`;_(c(e.id,"person-shoulders",{kind:"path",d:l},r))}}let w=n.labelBlock;return _(t.text({id:d(e.id,"text"),role:"label",text:w.text,block:w,x:a+s/2,y:o+g/2+("person"===m?19:4*("database"===m)),fontSize:w.fontSize,fontWeight:w.fontWeight,letterSpacing:w.letterSpacing,anchor:"middle",paint:{fill:y}})),t.group({id:d(e.id,"card"),role:"node",open:`<g class="node c4-${e.kind}" ${h(e)}>`,close:"</g>",children:b,channels:{category:`${e.external?"external-":""}${e.kind}`,...e.tags.length?{status:e.tags.join(",")}:{}}})})(a.elements.find(t=>t.id===e.id),e))),n.legend){let e=n.legend,a=[],r=eo(i.resolved.styleFace,"legend",{},{includeFallback:!1}),o=r?.textColor??"var(--_text)",s=e.heading,c=e.x+12,h=e.y+8+s.height/2,g=t.text({id:d("legend","heading"),role:"legend",text:s.text,block:s,x:c,y:h,fontSize:s.fontSize,fontWeight:s.fontWeight,letterSpacing:s.letterSpacing,anchor:"start",paint:{fill:o}});a.push({node:g,indent:2});let p=e.y+20+s.height;for(let i of e.entries){let{block:n}=i,s=e.x+38,c=p+n.height/2,h=i.style.borderColor??i.style.lineColor??r?.strokeColor??r?.borderColor??l.nodeBorderColor??"var(--_line)",g=i.style.bgColor??r?.fillColor??l.nodeFillColor??"var(--_node-fill)",m=String(r?.lineWidth??1),u="dotted"===i.style.lineStyle?"1 3":"dashed"===i.style.lineStyle||i.external?"5 3":void 0,f={fill:g,stroke:h,strokeWidth:m,...u?{strokeDasharray:u}:{}},y=e.x+10,x=n.height,b=(e,n)=>a.push({indent:2,node:t.shape({id:d(i.id,e),role:"legend",geometry:n,paint:f})});if("relationship"===i.kind)b("legend-swatch",{kind:"line",x1:y,y1:c,x2:y+18,y2:c});else if("database"===i.shape){let e=Math.min(3,x/4);b("legend-swatch",{kind:"path",d:`M ${y} ${p+e} A 9 ${e} 0 0 1 ${y+18} ${p+e} L ${y+18} ${p+x-e} A 9 ${e} 0 0 1 ${y} ${p+x-e} Z`}),b("legend-rim",{kind:"ellipse",cx:y+9,cy:p+e,rx:9,ry:e})}else if("person"===i.shape){let e=Math.min(3,x/5),t=y+9;b("legend-head",{kind:"circle",cx:t,cy:p+e,r:e}),b("legend-swatch",{kind:"path",d:`M ${y+3} ${p+x} Q ${y+3} ${p+2.5*e} ${t} ${p+2.5*e} Q ${y+15} ${p+2.5*e} ${y+15} ${p+x} Z`})}else if(b("legend-swatch",{kind:"rect",x:y,y:p,width:18,height:x}),"queue"===i.shape)for(let[e,t]of[y+3,y+15].entries())b(`legend-end:${e}`,{kind:"line",x1:t,y1:p,x2:t,y2:p+x});a.push({indent:2,node:t.text({id:d(i.id,"legend-text"),role:"legend",text:n.text,block:n,x:s,y:c,fontSize:n.fontSize,fontWeight:n.fontWeight,letterSpacing:n.letterSpacing,anchor:"start",paint:{fill:o}})}),p+=n.height+10}f.splice(f.length-1,0,t.group({id:d("legend","container"),role:"legend",open:'<g class="c4-legend">',close:"</g>",children:a}))}return{...u,family:"c4",parts:f}}),tl=W(eh,{configDiagnostics:e=>x("c4",e,ev),normalizeRequest:e=>{let t=e.source.authoredWrapperLength??e.source.wrapperSource?.length??0,i=e.source.originalText.slice(0,t),n=function(e){let t=function(e,t){let i="string"==typeof e?e:e.join(`
|
|
8
8
|
`),n=function(e="C4Context"){return{kind:"c4",variant:e,elements:[],boundaries:[],relationships:[],directives:[],statements:[],diagnostics:[],layout:{hints:[]}}}();R("c4")&&z("c4","initialize",n),n.statements=function(e){let t=[],i=0,n=1,a=1,r=!0,o=(r,o="unknown")=>{let l=e.slice(i,r);t.push({id:`c4-statement-${t.length+1}`,kind:o,raw:l,span:{start:i,end:r,line:n,column:a}}),R("c4")&&I("c4",`chunk:${o}`,l,{line:n,column:a,offset:i,endOffset:r,unit:"physical"});let s=e[i-1];for(let e of l)"\r"===e||e===`
|
|
9
9
|
`&&"\r"!==s?(n++,a=1):e!==`
|
|
10
|
-
`&&a++,s=e;i=r};for(;i<e.length;){let t=i;if(/\s|;/.test(e[t])){let i=t+1;for(;i<e.length&&/\s|;/.test(e[i]);)i++;o(i,"trivia");continue}if(e.startsWith("%%",t)){let i=b(e,t),n=i<0?e.length:i,a=!r&&U([e.slice(t,n)],0)?.form==="native";o(n,a?"accessibility":"trivia");continue}if(r){r=!1;let i=b(e,t),n=i<0?e.length:i,a=n;for(let i=t;i<n;i++){if("&"===e[i]){let t=/^&(?:#\d+|#x[0-9a-f]+|[a-z][a-z0-9]*);/i.exec(e.slice(i,n));if(t){i+=t[0].length-1;continue}}if(";"===e[i]){a=i;break}}let l=ec(e.slice(t,a)).trim();if(eX.some(e=>e.toLowerCase()===l.toLowerCase())){o(a,"header");continue}}if("}"===e[t]){o(t+1,"boundary-close");continue}let a=e.slice(t),l=/^[A-Za-z_][A-Za-z_0-9]*/.exec(a)?.[0],s=t+(l?.length??0);for(;s<e.length&&/[ \t\r\n]/.test(e[s]);)s++;if(l&&"("===e[s]){let t=0,i="";for(;s<e.length;s++){let n=e[s];if(i)n===i&&(i="");else if('"'===n||"'"===n)i=n;else if("("===n)t++;else if(")"===n&&0==--t){s++;break}}if(t||i)throw Error(`C4: unclosed ${l} argument list at line ${n}`);let a=s;for(;a<e.length&&/\s/.test(e[a]);)a++;if("{"===e[a]){if(eY[l]){o(a+1,"boundary-open");continue}let t=1;for(i="",s=a+1;s<e.length&&t;s++){let n=e[s];if(i)n===i&&(i="");else if('"'===n||"'"===n)i=n;else if("%"===n&&"%"===e[s+1]){let t=b(e,s+2);s=t<0?e.length:t}else"{"===n?t++:"}"===n&&t--}if(t)throw Error(`C4: unclosed ${l} block at line ${n}`)}o(s);continue}let d=b(e,t);if(/^accDescr[ \t]*:?[ \t]*\{/i.test(a)){let i=e.indexOf("}",t);if(i<0)throw Error(`C4: unclosed accessibility block at line ${n}`);o(i+1,"accessibility");continue}o(d<0?e.length:d)}return t}(i);let a=[],r=new Set,o=new Set,l=!1,s=!1,d=!1;for(let e of n.statements){let i=e.raw.trim();if("trivia"===e.kind){eK(e,"trivia"),!i.startsWith("%%")&&i.includes(";")?(tn(n,e.id,"c4_semicolon_separator","Semicolon statement separators are a reader extension; pinned Mermaid C4 requires line breaks"),s=d=!1):i.startsWith("%%")?d||=s:/[\r\n]/.test(e.raw)&&!d&&(s=!1);continue}if(s&&"boundary-close"!==e.kind&&tn(n,e.id,"c4_statements_on_one_line","Statements sharing a line are a reader extension; pinned Mermaid C4 requires a line break after each statement and after `{`, and a comment after a statement takes its line break"),s=!0,d=!1,!l){let t=ec(i),a=eX.find(e=>e.toLowerCase()===t.toLowerCase());if(!a)throw Error("C4: expected C4Context, C4Container, C4Component, C4Dynamic, or C4Deployment");eK(e,"header"),n.variant=a,R("c4")&&z("c4","set-variant",a),e.kind="header",e.signature=a,l=!0;continue}if("boundary-close"===e.kind){eK(e,"boundary-close");let t=a.pop();if(!t)throw Error(`C4: unmatched closing boundary at line ${e.span.line}`);R("c4")&&z("c4","close-boundary",{id:t}),e.entityId=t;continue}if(j(i)!==i&&tn(n,e.id,"c4_entity_prepass","The global Mermaid entity prepass changes this statement; the writer protects its text fields without changing their values"),/^title\s/i.test(i)){eK(e,"title"),a.length&&tn(n,e.id,"c4_nested_header_directive","Metadata inside a boundary is read as global. Pinned Mermaid requires it at document scope; the writer moves it after the header"),/[#;]/.test(j(i.replace(/^title\s+/i,"")))&&tn(n,e.id,"c4_title_token","The title contains literal token delimiters; serialization writes entity escapes for pinned Mermaid"),n.title=m(et(i.replace(/^title\s+/i,""))),R("c4")&&z("c4","set-title",n.title),e.kind="title",e.signature=n.title;continue}let c=U(i.split(/\r\n?|\n/),0);if(c){eK(e,"accessibility"),a.length&&tn(n,e.id,"c4_nested_header_directive","Metadata inside a boundary is read as global. Pinned Mermaid requires it at document scope; the writer moves it after the header"),c.title||"native"===c.form||""!==c.value||tn(n,e.id,"c4_empty_accessibility_description","An empty accessibility description block is a reader extension; the writer preserves its value in a native metadata comment"),c.title?n.accessibilityTitle=c.value:n.accessibilityDescription=c.value,R("c4")&&z("c4",c.title?"set-accessibility-title":"set-accessibility-description",c.value),e.kind="accessibility",e.entityId=c.title?"title":"description",e.signature=c.value;continue}if(/^accDescription\s+/i.test(i)){eK(e,"accessibility"),n.accessibilityDescription=i.replace(/^accDescription\s+/i,""),R("c4")&&z("c4","set-accessibility-description",n.accessibilityDescription),e.kind="accessibility",e.entityId="description",e.signature=n.accessibilityDescription;continue}let h=/^direction\s+(LR|RL|TB|BT)\s*$/.exec(i);if(h){eK(e,"direction");let t={id:e.id,name:"direction",args:[{value:h[1],raw:h[1]}],category:"layout",statementId:e.id};n.directives.push(t),R("c4")&&z("c4","add-directive",t),e.kind="directive",e.entityId=t.id,e.signature=ti(t);continue}let g=/^([A-Za-z_][A-Za-z_0-9]*)\s*\(([\s\S]*)\)\s*(\{)?$/.exec(i);if(!g){eK(e,"unknown"),tn(n,e.id,"c4_unknown_statement","C4 statement is preserved but has no native interpretation","error");continue}let p=g[1],u=function(e){if(!e.trim())return[];let t=[],i=0,n=0,a="";for(let r=0;r<e.length;r++){let o=e[r];a?o===a&&(a=""):'"'===o||"'"===o?a=o:"("===o?n++:")"===o?n--:","===o&&0===n&&(t.push(e.slice(i,r)),i=r+1)}return t.push(e.slice(i)),t.map(e=>{let t=/^\s*\$([A-Za-z_][A-Za-z_0-9]*)\s*=([\s\S]*)$/.exec(e);return{...t?{name:t[1]}:{},value:e0(t?t[2]:e),raw:e}})}(g[2]);if("UpdateLayoutConfig"===p&&(0===u.length||1===u.length&&!u[0].name&&""===u[0].value)&&!g[3]){a.length&&r.add(a.at(-1)),"("===i[p.length]&&e1(u)||tn(n,e.id,"c4_empty_layout_arguments","An empty layout call is a no-op; the writer supplies the attribute required by pinned Mermaid"),e.kind="trivia";continue}/[\r\n]/.test(g[2].replace(/"[^"]*"|'[^']*'/g,""))&&tn(n,e.id,"c4_multiline_arguments","Line breaks between C4 arguments are a reader extension; quoted multiline text remains supported"),u.some(e=>e.name&&""===e.value)&&tn(n,e.id,"c4_empty_named_argument","Empty named arguments are retained; pinned Mermaid requires a positional empty slot");let f=eU.exec(p),y=!!(f&&!("Person"===f[1]&&f[2]))||Object.hasOwn(eY,p)||eH.has(p)||ta.has(p);if(y&&a.length&&r.add(a.at(-1)),y&&u.some(e2))throw new eD(`C4 argument is ambiguous in ${i}: separate named arguments with commas and use $name="value", or quote the entire value when it is literal text`);if(y&&u.some((e,t)=>{let i=e.raw.trim();return e.name?!/^\$[A-Za-z_][A-Za-z_0-9]*\s*=\s*"/.test(i)&&""!==e.value:i.startsWith("$")||t===u.length-1&&""!==i&&!/^["']/.test(i)})&&tn(n,e.id,"c4_unquoted_argument","Unquoted C4 argument text is read literally here, but pinned Mermaid requires a quoted final argument and quoted named values; serialization writes those values in double quotes"),y&&"("!==i[p.length]&&tn(n,e.id,"c4_space_before_arguments",`Pinned Mermaid reads "(" only straight after ${p} and rejects whitespace between them; ours reads the call. Write ${p}( with no space`),f&&!("Person"===f[1]&&f[2])){if(eK(e,"element"),g[3])throw Error(`C4: ${p} cannot open a boundary`);let i=e3(u,e6(p)),r=te(i,"alias",p);if(o.has(r))throw Error(`C4: duplicate declaration alias ${JSON.stringify(r)}`);o.add(r);let l={id:r,macro:p,kind:f[1].toLowerCase(),external:!!f[3],shape:"Person"===f[1]?"person":"Db"===f[2]?"database":"Queue"===f[2]?"queue":"rectangle",label:tt(u,e6(p),i,p),technology:e7(e4(u,e6(p),"techn")),description:e7(e4(u,e6(p),"descr")),parentId:a.at(-1),tags:e9(i.tags),link:e7(i.link),sprite:e7(i.sprite),style:{},args:u,statementId:e.id};t&&B("nodes",n.elements.length+n.boundaries.length+1),n.elements.push(l),R("c4")&&z("c4","add-element",l),e.kind="element",e.entityId=r,e.signature=ti(l)}else if(eY[p]){if(eK(e,"boundary-open"),!g[3])throw Error(`C4: ${p} requires a boundary block`);let i=e3(u,e5(p)),r=te(i,"alias",p);if(o.has(r))throw Error(`C4: duplicate declaration alias ${JSON.stringify(r)}`);o.add(r);let l={id:r,macro:p,kind:eY[p],label:tt(u,e5(p),i,p),type:e7(e4(u,e5(p),"type")),description:e7(e4(u,e5(p),"descr")),parentId:a.at(-1),tags:e9(i.tags),link:e7(i.link),sprite:e7(i.sprite),style:{},args:u,statementId:e.id,..."Node_L"===p?{alignment:"left"}:"Node_R"===p?{alignment:"right"}:{}};t&&(B("nodes",n.elements.length+n.boundaries.length+1),B("nesting",a.length+1)),n.boundaries.push(l),a.push(r),R("c4")&&z("c4","open-boundary",l),e.entityId=r,e.signature=ti(l)}else if(eH.has(p)){eK(e,"relationship");let i=e3(u,e8(p)),a=te(i,"from",p),r=te(i,"to",p),o="Rel_Back"===p,l={id:"",macro:p,from:a,to:r,source:o?r:a,target:o?a:r,label:tt(u,e8(p),i,p),technology:e7(e4(u,e8(p),"techn")),description:e7(e4(u,e8(p),"descr")),tags:e9(i.tags),link:e7(i.link),sprite:e7(i.sprite),style:{},args:u,statementId:e.id,index:"RelIndex"===p?te(i,"index",p):void 0,order:n.relationships.length+1,bidirectional:"BiRel"===p,reversed:o,direction:eZ[p.slice(4)]};t&&B("edges",n.relationships.length+n.layout.hints.length+1),n.relationships.push(l),R("c4")&&z("c4","add-relationship",l),e.kind="relationship","RelIndex"===p&&u.slice(4).some(e=>!e.name)&&tn(n,e.id,"c4_relindex_positional_metadata","RelIndex positional metadata follows documented tags/link slots; pinned Mermaid instead treats them as technology/description. Named $tags/$link avoids this ambiguity")}else{eK(e,"directive");let t={id:e.id,name:p,args:u,category:"UpdateElementStyle"===p?"element-style":"UpdateRelStyle"===p?"relationship-style":"AddElementTag"===p?"element-tag":"AddRelTag"===p?"relationship-tag":"UpdateLayoutConfig"===p||p.startsWith("Lay_")||p.startsWith("LAYOUT_")?"layout":"ShowLegend"===p||"SHOW_LEGEND"===p||"SHOW_FLOATING_LEGEND"===p?"legend":"AddElementLink"===p||"AddRelLink"===p?"link":"unknown",statementId:e.id};n.directives.push(t),R("c4")&&z("c4","add-directive",t),e.kind="directive",e.entityId=t.id,e.signature=ti(t),"unknown"===t.category?tn(n,e.id,"c4_unknown_macro",`${p} is preserved but has no native interpretation`,"error"):p.startsWith("Update")||tn(n,e.id,"c4_directive_extension",`${p} is a reader extension; pinned Mermaid does not accept this directive`)}let x=f?e6(p):eY[p]?e5(p):eH.has(p)?e8(p):("UpdateElementStyle"===p?eJ:"UpdateRelStyle"===p?eQ:"UpdateLayoutConfig"===p?["c4ShapeInRow","c4BoundaryInRow"]:void 0)??("AddElementTag"===p?eV:"AddRelTag"===p?eG:void 0);if(x){let t=new Set;for(let i=0;i<u.length;i++){let a=u[i],r=a.name??x[i];void 0!==r&&x.includes(r)?t.has(r)&&tn(n,e.id,"c4_duplicate_argument",`${p} assigns ${r} more than once; every argument is retained`,"error"):tn(n,e.id,"c4_unknown_argument",`${p} argument ${a.name??i+1} is retained but has no native interpretation`,"error"),r&&t.add(r)}}u.some(e=>/^\s*'/.test(e.raw)||/\\["']/.test(e.raw))?tn(n,e.id,"c4_quoted_string_extension","Quoted-string extension is preserved; typed edits write Mermaid entity escapes"):!y||e1(u)||n.diagnostics.some(t=>t.statementId===e.id&&["c4_multiline_arguments","c4_empty_named_argument"].includes(t.syntax))||tn(n,e.id,"c4_argument_spelling","Argument text is retained as its native value; the writer emits complete quoted argument tokens instead of ambiguous imported spelling")}if(!l)throw Error("C4: missing diagram header");if(a.length)throw Error(`C4: unclosed boundary ${JSON.stringify(a.at(-1))}`);t&&T(n);let c=en(o),h=new Map(n.statements.map(e=>[e.id,e]));for(let e of n.relationships){if(e.id=c(`c4-rel-${e.order}`,["c4-relationship",e.order]),R("c4")&&z("c4","set-relationship-identity",{id:e.id,order:e.order}),!o.has(e.from)||!o.has(e.to))throw Error(`C4: relationship ${e.id} references an undeclared endpoint`);let t=h.get(e.statementId);t.entityId=e.id,t.signature=ti(e)}for(let e of(!function(e,t=!1){for(let t of[...e.elements,...e.boundaries,...e.relationships])t.style={},delete t.effectiveLink,R("c4")&&z("c4","reset-presentation",{id:t.id,style:t.style});e.layout={hints:[]},R("c4")&&z("c4","reset-layout",e.layout);let i=new Map([...e.elements,...e.boundaries].map(e=>[e.id,e])),n=new Map,a=(e,t)=>JSON.stringify([e,t]);for(let t of e.relationships){let e=a(t.from,t.to),i=n.get(e)??[];i.push(t),n.set(e,i)}let r=(e,t)=>{let i=e3(e.args,t);for(let n of["techn","legendText"]){let a=e4(e.args,t,n);void 0!==a&&(i[n]=a)}return i},o=new Map,l=new Map;for(let t of e.directives){if("element-tag"!==t.category&&"relationship-tag"!==t.category)continue;let e=r(t,"element-tag"===t.category?eV:eG);("element-tag"===t.category?o:l).set(e.tagStereo??"",tr(e,["tagStereo"])),R("c4")&&z("c4","define-tag",{category:t.category,tag:e.tagStereo??"",style:("element-tag"===t.category?o:l).get(e.tagStereo??"")})}for(let t of[...e.elements,...e.boundaries])for(let e of t.tags)Object.assign(t.style,o.get(e)),R("c4")&&z("c4","apply-tag",{id:t.id,tag:e,style:t.style});for(let t of e.relationships)for(let e of t.tags)Object.assign(t.style,l.get(e)),R("c4")&&z("c4","apply-tag",{id:t.id,tag:e,style:t.style});for(let o of e.directives)if("element-style"===o.category){let e=r(o,eJ),t=i.get(e.elementName);if(!t)throw Error(`C4: UpdateElementStyle references undeclared alias ${JSON.stringify(e.elementName)}`);Object.assign(t.style,tr(e,["elementName"])),R("c4")&&z("c4","set-element-style",{id:t.id,style:t.style})}else if("relationship-style"===o.category){let e=e3(o.args,eQ),t=n.get(a(e.from,e.to));if(!t)throw Error("C4: UpdateRelStyle references an undeclared relationship pair");for(let t of["offsetX","offsetY"])if(void 0!==e[t]&&!Number.isFinite(Number(e[t])))throw Error(`C4: ${t} must be finite`);for(let i of t)Object.assign(i.style,tr(e,["from","to"])),R("c4")&&z("c4","set-relationship-style",{id:i.id,style:i.style})}else if("UpdateLayoutConfig"===o.name){let t=e3(o.args,["c4ShapeInRow","c4BoundaryInRow"]);for(let[i,n]of[["c4ShapeInRow","shapesPerRow"],["c4BoundaryInRow","boundariesPerRow"]]){if(void 0===t[i]||""===t[i])continue;let a=Number(t[i]);if(!Number.isSafeInteger(a)||a<1)throw Error(`C4: ${i} must be a positive integer`);e.layout[n]=a,R("c4")&&z("c4","set-layout-option",{name:n,value:a})}}else if(o.name.startsWith("Lay_")){let n=eZ[o.name.slice(4)],a=e3(o.args,["from","to"]);if(!n||!a.from||!a.to||!i.has(a.from)||!i.has(a.to))throw Error(`C4: ${o.name} requires two declared aliases`);n&&a.from&&a.to&&(t&&B("edges",e.relationships.length+e.layout.hints.length+1),e.layout.hints.push({from:a.from,to:a.to,direction:n,statementId:o.statementId}),R("c4")&&z("c4","add-layout-hint",e.layout.hints.at(-1)))}else if("direction"===o.name)e.layout.direction=o.args[0]?.value,R("c4")&&z("c4","set-direction",e.layout.direction);else if("LAYOUT_LEFT_RIGHT"===o.name||"LAYOUT_TOP_DOWN"===o.name)e.layout.direction="LAYOUT_LEFT_RIGHT"===o.name?"LR":"TB",R("c4")&&z("c4","set-direction",e.layout.direction);else if("AddElementLink"===o.name){let e=e3(o.args,["alias","link"]),t=i.get(e.alias);t&&(t.effectiveLink=e.link,R("c4")&&z("c4","set-effective-link",{id:t.id,link:t.effectiveLink}))}else if("AddRelLink"===o.name){let e=e3(o.args,["from","to","link"]);for(let t of n.get(a(e.from,e.to))??[])t.effectiveLink=e.link,R("c4")&&z("c4","set-effective-link",{id:t.id,link:t.effectiveLink})}let s=en([...e.elements,...e.boundaries,...e.relationships].map(e=>e.id));e.legend={visible:e.directives.some(e=>"legend"===e.category),entries:[...[...o.entries()].map(([e,t])=>({id:s(`c4-tag-${e}`,["element-tag",e]),label:t.legendText??e,kind:"element",style:{...t}})),...[...l.entries()].map(([e,t])=>({id:s(`c4-tag-${e}`,["relationship-tag",e]),label:t.legendText??e,kind:"relationship",style:{...t}}))]},R("c4")&&z("c4","set-legend",e.legend)}(n,t),n.boundaries))r.has(e.id)||tn(n,e.statementId,"c4_empty_boundary","An empty boundary is retained; the writer supplies a no-op layout statement because pinned Mermaid requires a statement inside its block");if(n.directives.some(e=>"direction"===e.name)){let e=n.directives.find(e=>"direction"===e.name);tn(n,e.statementId,"c4_direction","A standalone direction directive is a reader extension to legacy C4")}for(let e of[...n.elements,...n.boundaries,...n.relationships])for(let t of(e.sprite&&tn(n,e.statementId,"c4_sprite","C4 sprite metadata is preserved; offline native output uses an explicit text fallback"),void 0===e.style.lineStyle||["solid","dashed","dotted"].includes(e.style.lineStyle)||tn(n,e.statementId,"c4_line_style",`C4 lineStyle ${JSON.stringify(e.style.lineStyle)} is preserved but has no native paint effect; the route uses solid strokes`),Object.keys(e.style)))"shape"===t&&"external"in e&&void 0!==ep(e.style.shape)||["bgColor","fontColor","borderColor","textColor","lineColor","lineStyle","offsetX","offsetY","legendText","techn"].includes(t)||tn(n,e.statementId,"c4_style_property",`C4 style ${t} is preserved as metadata but has no native paint effect`);return n}(e,!0),i=t.diagnostics.find(e=>"error"===e.severity);if(i){let e;throw Error(`C4 unsupported syntax: ${(e=t.statements.find(e=>e.id===i.statementId))?`${i.message} (in: ${e.raw.trim()})`:i.message}`)}return t}(e.source.originalText.slice(t)),a=i.split(/\r\n?|\n/).length-1;for(let e of n.statements)e.span.start+=i.length,e.span.end+=i.length,e.span.line+=a;let r=_(e.source.frontmatter);return void 0===n.title&&void 0!==r&&(n.title=r),void 0!==e.source.accessibility.title&&(n.accessibilityTitle=e.source.accessibility.title),void 0!==e.source.accessibility.descr&&(n.accessibilityDescription=e.source.accessibility.descr),{familyConfig:{model:n,c4:e.source.config.c4??{},themeVariables:e.source.config.themeVariables??{}}}},layout:e=>{let m=e.familyConfig;return C(function(e,m={},u,f={},y={}){var x;let b,_,w,v,k,F,S,$,M,C;T(e);let W=ey({...void 0===m.padding?{}:{diagramMarginX:m.padding,diagramMarginY:m.padding},...void 0===m.nodeSpacing?{}:{c4ShapeMargin:m.nodeSpacing},...void 0===m.layerSpacing?{}:{nextLinePaddingX:m.layerSpacing},...f},y),R=Z(m,void 0,u),L=function(e,t=ey()){for(let t of[...e.elements,...e.boundaries,...e.relationships,...e.legend?.entries??[]]){let e=t.style;A({...void 0===e.bgColor?{}:{fill:e.bgColor},...void 0===e.borderColor&&void 0===e.lineColor?{}:{stroke:e.borderColor??e.lineColor},...void 0===e.fontColor&&void 0===e.textColor?{}:{color:e.fontColor??e.textColor}},`C4 ${t.id}`)}let i=ek(e),n={direction:e.layout.direction??e.layout.hints[0]?.direction??e.relationships.find(e=>e.direction)?.direction??"LR",nodes:new Map,edges:[],subgraphs:[],classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,linkStyles:new Map},a=new Map;for(let t of e.boundaries)a.set(t.id,{id:i.nodes.get(t.id)??t.id,label:eS(t),nodeIds:[],children:[]});for(let t of e.boundaries){let e=a.get(t.id),i=t.parentId&&a.get(t.parentId);i?i.children.push(e):n.subgraphs.push(e)}for(let r of e.elements){let e=i.nodes.get(r.id)??r.id,o=ex(r,t),l=em(r);n.nodes.set(e,{id:e,label:eF(r),shape:"database"===l?"cylinder":"queue"===l?"subroutine":"rectangle",href:r.effectiveLink??r.link}),r.parentId&&a.get(r.parentId)?.nodeIds.push(e),n.nodeStyles.set(e,{...o.fill?{fill:o.fill}:{},...o.stroke?{stroke:o.stroke}:{},...o.text?{color:o.text}:{},...o.dashed?{"stroke-dasharray":"5 3"}:{}})}for(let t of e.relationships){let a=e$(e,t);n.edges.push({id:i.relationships.get(t.id)??t.id,source:t.source,target:t.target,label:a,labelContent:{value:a,prepared:ee(a,"literal")},style:"dashed"===t.style.lineStyle||"dotted"===t.style.lineStyle?"dotted":"solid",hasArrowStart:t.bidirectional,hasArrowEnd:!0}),n.linkStyles.set(n.edges.length-1,A({...t.style.lineColor?{stroke:t.style.lineColor}:{},...t.style.textColor?{color:t.style.textColor}:{}},`UpdateRelStyle(${t.from}, ${t.to})`))}return n}(e,W),I=new Map,z=new Map([...e.elements,...e.boundaries].map(e=>[e.id,e.parentId])),q=e=>{let t=[];for(let i=z.get(e);i&&!t.includes(i);i=z.get(i))t.push(i);return t},B=e=>void 0!==W.input.c4ShapePadding?W.padding:W.compact&&u?.node?.["X"===e?"paddingX":"paddingY"]===void 0?Math.min(W.padding,R["X"===e?"nodePaddingX":"nodePaddingY"]):R["X"===e?"nodePaddingX":"nodePaddingY"],P=e=>{if(void 0===W.wrapWidth)return;if(void 0===W.maxWidth)return W.wrapWidth;let t=void 0===e?0:q(e).length;return Math.max(24,W.minimumWidth-2*B("X")-20,Math.min(W.wrapWidth,W.maxWidth-(W.marginX+40)*2-t*W.boundaryPadding*2-2*B("X")-20))},O=(e,t,i=!1)=>{let n=ex(e,W);return ea(t,{display:"literal",fontSize:n.fontSize??(i?R.groupHeaderFontSize:R.nodeLabelFontSize),fontWeight:n.fontWeight??(i?R.groupHeaderFontWeight:R.nodeLabelFontWeight),transform:i?R.groupTextTransform:R.nodeTextTransform,maxWidth:P(e.id),letterSpacing:i?R.groupLetterSpacing:R.nodeLetterSpacing,fontFamily:n.fontFamily??(i?R.groupFont:void 0)})},j=e.elements.map(e=>{let t=eF(e),i=O(e,t),n=em(e),a=Math.max(W.minimumWidth,i.width+2*B("X")+20*("queue"===n)),r=Math.max(W.minimumHeight,i.height+2*B("Y")+("person"===n?38:16*("database"===n)));return I.set(e.id,{id:e.id,x:0,y:0,width:a,height:r,..."database"===n?{cylinder:!0}:{}}),{...L.nodes.get(e.id),x:0,y:0,width:a,height:r,labelBlock:i,inlineStyle:L.nodeStyles.get(e.id)}}),N=new Map;for(let t of e.boundaries){let e=eS(t),i=O(t,e,!0),n=i.height+2*W.padding,a={id:t.id,label:e,labelBlock:i,x:0,y:0,width:Math.max(W.minimumWidth,i.width+2*W.padding),height:n+2*W.boundaryPadding,headerHeight:n,children:[]};N.set(t.id,a),I.set(t.id,{...a,container:!0})}let X=L.edges.map((t,i)=>({...t,points:[],labelBlock:ea(e$(e,e.relationships[i]),{display:"literal",fontSize:R.edgeLabelFontSize,fontWeight:R.edgeLabelFontWeight,letterSpacing:R.edgeLetterSpacing,transform:R.edgeTextTransform,...void 0===W.maxWidth?{}:{maxWidth:P()}}),inlineStyle:L.linkStyles.get(i),edgeIndex:i}));for(let t of e.boundaries){let e=X.filter(e=>e.source===t.id&&q(e.target).includes(t.id)||e.target===t.id&&q(e.source).includes(t.id));e.length&&(I.get(t.id).bottomPadding=Math.max(W.boundaryPadding,...e.map(e=>(e.labelBlock?.height??0)+48))*e.length)}let D="LR"===L.direction||"RL"===L.direction;for(let[e,t]of I){let i=X.filter(t=>t.source===e||t.target===e),n=Math.max(0,...i.map(e=>(e.labelBlock?.height??0)+28)),a=Math.max(0,...i.map(e=>(e.labelBlock?.width??0)+24)),r=new Map;for(let t of i){let i=t.source===e?t.target:t.source;r.set(i,(r.get(i)??0)+1)}let o=Math.max(0,...r.values());D?t.height=Math.max(t.height,(o+1)*n+(t.headerHeight??0),(i.length+1)*16+(t.headerHeight??0)):t.width=Math.max(t.width,(o+1)*a,(i.length+1)*16)}let U=m.diagramTitle??e.title,Y=void 0===U?void 0:ea(U,{display:"literal",fontSize:J,fontWeight:Q,transform:R.groupTextTransform,letterSpacing:R.groupLetterSpacing,fontFamily:R.groupFont,...void 0===W.maxWidth?{}:{maxWidth:Math.max(24,W.maxWidth-2*W.marginX)}}),H=Y?{text:Y.text,width:Y.width,height:Y.height+V,block:Y}:void 0,K=Math.max(W.gap,...X.map(e=>(e.labelBlock?.width??0)*2+48)),et=Math.max(W.rowGap,...X.map(e=>(e.labelBlock?.height??0)*2+48)),ei=new Map;for(let e of X){let t=JSON.stringify([e.source,e.target].sort());ei.set(t,(ei.get(t)??0)+1)}let en=Math.max(1,...ei.values()),er=en>1?en+1:1,eo=(x={gapX:K*er,gapY:et*er,padding:W.boundaryPadding,marginX:W.marginX+40,marginY:W.marginY+40+(H?.height??0),shapesPerRow:e.layout.shapesPerRow??W.shapesPerRow,boundariesPerRow:e.layout.boundariesPerRow??W.boundariesPerRow,direction:"TD"===L.direction?"TB":L.direction,maxWidth:W.maxWidth},b=new Map([...I].map(([e,t])=>[e,{...t}])),_=[],w=new Map(e.statements.map((e,t)=>[e.id,t])),k=new Map((v=[...e.boundaries,...e.elements].sort((e,t)=>(w.get(e.statementId)??0)-(w.get(t.statementId)??0))).map(e=>[e.id,e.parentId])),F=[...e.layout.hints,...e.relationships.filter(e=>e.direction).map(e=>({from:e.from,to:e.to,direction:e.direction,statementId:e.statementId}))],S=(e,t)=>{let i=new Set;for(;k.get(e)!==t;){if(i.has(e))return;i.add(e);let t=k.get(e);if(!t)return;e=t}return e},M=($=(e,t,i)=>{let n=v.filter(t=>t.parentId===e&&b.has(t.id));for(let e of n)if(b.get(e.id).container&&!t.has(e.id)){let n=new Set(t);n.add(e.id);let a=$(e.id,n,void 0===i?void 0:Math.max(1,i-2*x.padding)),r=b.get(e.id);r.width=Math.max(r.width,a.width+2*x.padding),r.height=Math.max(r.height,a.height+(r.headerHeight??0)+x.padding+Math.max(x.padding,r.bottomPadding??0))}let a=n.some(e=>b.get(e.id).container)?x.boundariesPerRow:x.shapesPerRow,r=x.direction,o="LR"===r||"RL"===r;if(!o&&void 0!==i){let e=Math.max(1,...n.map(e=>b.get(e.id).width)),t=Math.max(1,Math.floor((i+x.gapX)/(e+x.gapX)));a=Math.max(a,Math.ceil(n.length/t))}let l=0,s=0,d=0,c=0,h=0;n.forEach(e=>{let t=b.get(e.id);h&&(h>=a||o&&void 0!==i&&l+t.width>i)&&(o?(l=0,s+=d+x.gapY,d=0):(s=0,l+=c+x.gapX,c=0),h=0),t.x=l,t.y=s,o?l+=t.width+x.gapX:s+=t.height+x.gapY,d=Math.max(d,t.height),c=Math.max(c,t.width),h++});let g=[];for(let t of F){let i=S(t.from,e),n=S(t.to,e);if(!i||!n||i===n||!b.has(i)||!b.has(n))continue;let a="LR"===t.direction||"RL"===t.direction?"x":"y",r="RL"===t.direction||"BT"===t.direction,o=r?n:i,l=r?i:n,s=(e,t,i=new Set)=>e===t||!i.has(e)&&(i.add(e),g.some(n=>n.axis===a&&n.before===e&&s(n.after,t,i)));if(s(l,o)){_.push({code:"C4_LAYOUT_CONFLICT",severity:"warning",statementId:t.statementId,message:`Conflicting C4 ${"x"===a?"horizontal":"vertical"} direction for ${t.from} and ${t.to}; the earlier constraint is retained.`});continue}g.push({before:o,after:l,axis:a,statementId:t.statementId})}if(g.length){for(let e of n){let t=b.get(e.id);g.some(t=>"x"===t.axis&&(t.before===e.id||t.after===e.id))&&(t.x=0),g.some(t=>"y"===t.axis&&(t.before===e.id||t.after===e.id))&&(t.y=0)}let e=()=>{for(let e=0;e<n.length;e++)for(let e of g){let t=b.get(e.before),i=b.get(e.after);i[e.axis]=Math.max(i[e.axis],t[e.axis]+("x"===e.axis?t.width+x.gapX:t.height+x.gapY))}};e();for(let t=0;t<n.length;t++){let t=!1;for(let e=0;e<n.length;e++)for(let i=e+1;i<n.length;i++){let a=b.get(n[e].id),r=b.get(n[i].id);a.x<r.x+r.width&&r.x<a.x+a.width&&a.y<r.y+r.height&&r.y<a.y+a.height&&(r.y=a.y+a.height+x.gapY,t=!0)}if(e(),!t)break}}else if("RL"===r||"BT"===r){let e=Math.max(0,...n.map(e=>{let t=b.get(e.id);return"RL"===r?t.x+t.width:t.y+t.height}));for(let t of n){let i=b.get(t.id);"RL"===r?i.x=e-i.x-i.width:i.y=e-i.y-i.height}}return{width:Math.max(0,...n.map(e=>{let t=b.get(e.id);return t.x+t.width})),height:Math.max(0,...n.map(e=>{let t=b.get(e.id);return t.y+t.height}))}})(void 0,new Set,void 0===x.maxWidth?void 0:Math.max(1,x.maxWidth-2*x.marginX)),(C=(e,t,i,n)=>{for(let a of v.filter(t=>t.parentId===e)){let e=b.get(a.id);!e||n.has(a.id)||(n.add(a.id),e.x+=t,e.y+=i,e.container&&C(a.id,e.x+x.padding,e.y+(e.headerHeight??0)+x.padding,n))}})(void 0,x.marginX,x.marginY,new Set),{boxes:b,width:M.width+2*x.marginX,height:M.height+2*x.marginY,diagnostics:_});for(let e of j)Object.assign(e,eo.boxes.get(e.id));let el=[];for(let t of e.boundaries){let e=N.get(t.id);Object.assign(e,eo.boxes.get(t.id));let i=t.parentId&&N.get(t.parentId);i?i.children.push(e):el.push(e)}(function(e,i,m,u,f){let{edges:y}=i,x=[...e.values()].filter(e=>e.container).map(e=>({...e,id:f.generated(`c4-header-obstacle:${e.id}`,["c4","header-obstacle",e.id]),height:e.headerHeight??1,shape:"rectangle",label:""})),b=[...i.nodes,...x],_=0,w=()=>{if(++_>4e5)throw new eW},v=(e,t,i)=>(w(),h(e,t,i)),k=(e,t,i,n,a)=>{let r={x:eR[t].x*i,y:eR[t].y*i},o=n;for(let t of b){if(w(),t.id===a||!(r.x?e.y>t.y&&e.y<t.y+t.height:e.x>t.x&&e.x<t.x+t.width))continue;let i=r.x>0?t.x-e.x:r.x<0?e.x-t.x-t.width:r.y>0?t.y-e.y:e.y-t.y-t.height;i>=0&&(o=Math.min(o,Math.max(0,i-2)))}return{x:e.x+r.x*o,y:e.y+r.y*o}},F=new Map,S=new Map,$=new Map,M=y.flatMap(t=>{let i=e.get(t.source),n=e.get(t.target);if(!i||!n)return[];let[a,r]=function(e,t){if(e.id===t.id)return["R","B"];if(e.container&&eL(e,t)||t.container&&eL(t,e))return["B","B"];let i=eI(e),n=eI(t);return Math.abs(i.x-n.x)>=Math.abs(i.y-n.y)?i.x<=n.x?["R","L"]:["L","R"]:i.y<=n.y?["B","T"]:["T","B"]}(i,n);for(let[e,t]of[[i.id,a],[n.id,r]]){let i=`${e}\0${t}`;S.set(i,(S.get(i)??0)+1)}return[{edge:t,source:i,target:n,startSide:a,endSide:r}]}),C=new Map;for(let e of M){let t=JSON.stringify([e.source.id,e.target.id].sort()),i=C.get(t)??[];i.push(e),C.set(t,i)}for(let[e,i]of M.entries()){let n,{edge:a,source:r,target:o,startSide:l,endSide:s}=i,d=(e,t)=>{let i=`${e.id}\0${t}`,n=$.get(i)??0;return $.set(i,n+1),{index:n,count:S.get(i)}},c=d(r,l),h=d(o,s),p=eq(r,l,c.index,c.count),m=r.id===o.id?eq(o,s,h.index,h.count):function(e,t,i,n,a,r){let o=eq(i,n,a,r);if(eE[t]!==n)return o;let l="L"===n||"R"===n?"y":"x",s=e[l]-o[l];if(0===s||Math.abs(s)>=8)return o;let d=ez(i,n,0),c=ez(i,n,1),h=(e[l]-d[l])/(c[l]-d[l]);if(!(h>0&&h<1))return o;let g=ez(i,n,h);for(let e=0;e<r;e++)if(e!==a&&8>Math.abs(eq(i,n,e,r)[l]-g[l]))return o;return g}(p,l,o,s,h.index,h.count),f=r.container&&r.id!==o.id&&eL(r,o)?-1:1,y=o.container&&r.id!==o.id&&eL(o,r)?-1:1,x=C.get(JSON.stringify([r.id,o.id].sort())),b="R"===l||"L"===l?Math.max(24,...x.map(e=>(e.edge.labelBlock?.width??0)+32)):Math.max(24,...x.map(e=>(e.edge.labelBlock?.height??0)+24)),_=(x.indexOf(i)-(x.length-1)/2)*b,w=14+e%5*4,v=g(a,u),M=k(p,l,f,Math.max(w,v.start?v.start+(u.edgeBendRadius??0):0),r.id),W=k(m,s,y,Math.max(w,v.end?v.end+(u.edgeBendRadius??0):0),o.id);if(F.set(a,{start:p,end:m,startExit:M,endExit:W}),r.id===o.id){let e=r.x+r.width+w+(a.labelBlock?.width??0)/2,t=r.y+r.height+w+(a.labelBlock?.height??0)/2;n=[M,{x:e,y:M.y},{x:e,y:t},{x:W.x,y:t},W]}else if("R"===l||"L"===l){let e=(M.x+W.x)/2+_;n=[M,{x:e,y:M.y},{x:e,y:W.y},W]}else{let e=(M.y+W.y)/2+_;n=[M,{x:M.x,y:e},{x:W.x,y:e},W]}a.points=t([p,...n,m]),F.get(a).seed=a.points,a.label&&(a.labelPosition=E(a.points))}for(let n of(r(i,m,new Set,u),l(i,m,u),s(i,m,u),c(i,m,u),y)){let a=F.get(n),r=e.get(n.source),o=e.get(n.target),l=Math.abs(eI(r).x-eI(o).x)>=Math.abs(eI(r).y-eI(o).y)?eI(r).x<=eI(o).x?"LR":"RL":eI(r).y<=eI(o).y?"TB":"BT",s={id:f.generated(`${n.id}:routing-source`,["c4",n.id,"routing-source"]),label:"",shape:"rectangle",...a.startExit,width:0,height:0},d={id:f.generated(`${n.id}:routing-target`,["c4",n.id,"routing-target"]),label:"",shape:"rectangle",...a.endExit,width:0,height:0},c={...n,source:s.id,target:d.id,points:t([a.startExit,...a.seed.slice(1,-1),a.endExit])},h=(n.labelBlock?.width??0)/2+10,g=(n.labelBlock?.height??0)/2+8;p([...[...i.nodes,...x].map(e=>e.id===n.source||e.id===n.target?e:{...e,x:e.x-h,y:e.y-g,width:e.width+2*h,height:e.height+2*g}),s,d],[c],{...m,direction:l}),c.points.slice(1).some((e,t)=>b.some(i=>v(c.points[t],e,i)))&&(c.points=function(e,i,n,a){let r=(t,a)=>{let r=[...new Set(n.flatMap(e=>[e[t]-10,e[t]+e[a]+10]))],o=[Math.min(e[t],i[t],...r),Math.max(e[t],i[t],...r)],l=n=>Math.min(Math.abs(n-e[t]),Math.abs(n-i[t]));return[...new Set([...o,...r.sort((e,t)=>l(e)-l(t)||e-t).slice(0,14)])]},o=r("x","width"),l=r("y","height"),s=[];for(let t of o)s.push([e,{x:t,y:e.y},{x:t,y:i.y},i]);for(let t of l)s.push([e,{x:e.x,y:t},{x:i.x,y:t},i]);for(let t of o)for(let n of l)s.push([e,{x:e.x,y:n},{x:t,y:n},{x:t,y:i.y},i]),s.push([e,{x:t,y:e.y},{x:t,y:n},{x:i.x,y:n},i]);let d=e=>e.slice(1).reduce((t,i,n)=>t+Math.hypot(i.x-e[n].x,i.y-e[n].y),0),c=(e,t)=>n.every(i=>!a(e,t,i)),h=e=>e.map(t).sort((e,t)=>d(e)-d(t)||e.length-t.length).find(e=>e.slice(1).every((t,i)=>c(e[i],t))),g=h(s);if(g)return g;let p=l.filter(t=>c(e,{x:e.x,y:t})),m=l.filter(e=>c({x:i.x,y:e},i)),u=o.filter(t=>c(e,{x:t,y:e.y})),f=o.filter(e=>c({x:e,y:i.y},i)),y=[];for(let t of o)for(let n of p)for(let a of m)y.push([e,{x:e.x,y:n},{x:t,y:n},{x:t,y:a},{x:i.x,y:a},i]);for(let t of l)for(let n of u)for(let a of f)y.push([e,{x:n,y:e.y},{x:n,y:t},{x:a,y:t},{x:a,y:i.y},i]);return h(y)}(a.startExit,a.endExit,b,v)??c.points),n.points=t([a.start,...c.points,a.end]),n.labelPosition=E(n.points)}d(i,m,u);let W=[...i.nodes,...x],R={...i,nodes:W},{ctx:L}=a(W,y,m.direction,u,i.groups);for(let e of(L.finalLabelClearance=!0,y))if(e.label)for(let{start:t,end:i}of e.points.slice(1).map((t,i)=>({start:e.points[i],end:t})).sort((e,t)=>Math.abs(t.end.x-t.start.x)+Math.abs(t.end.y-t.start.y)-(Math.abs(e.end.x-e.start.x)+Math.abs(e.end.y-e.start.y)))){let a=n(e,t,i,L);if(a){e.labelPosition=a;break}}for(let t of(s(R,m,u),y)){let i=e.get(t.source),n=e.get(t.target);o(t,t.routeCertificate,{...i,label:"",shape:"rectangle"},{...n,label:"",shape:"rectangle"})}})(eo.boxes,{nodes:j,groups:el,edges:X},L,R,ek(e)),function(e,t,i){let{edges:n}=e,a=eN(e.nodes,e.groups),r=n.flatMap(e=>ej(e,t)),o=[],l=new Map(i.relationships.map(e=>[e.id,e.style])),s=n.flatMap(e=>e.points.slice(1).map((t,i)=>({edge:e,start:e.points[i],end:t})));for(let{edge:e,rect:t}of n.map((e,t)=>({edge:e,index:t,rect:eB(e)})).filter(e=>e.rect).sort((e,t)=>t.rect.width*t.rect.height-e.rect.width*e.rect.height||e.index-t.index)){let i=l.get(e.id),n=e=>Number.isFinite(Number(e))?Number(e):0,d=n(i?.offsetX),c=n(i?.offsetY),h=e=>({x:e.x+d,y:e.y+c}),g=h(e.labelPosition),p=[g],m=t.width,u=t.height,f=t=>{let i={x:t.x-m/2,y:t.y-u/2,width:m,height:u},n=eP(i,3);return[r.reduce((e,t)=>e+eT(n,t),0),a.reduce((e,t)=>e+eT(n,t),0),o.reduce((e,t)=>e+eT(eP(i,4),t),0),s.reduce((t,n)=>t+(n.edge!==e&&eA(n.start,n.end,eP(i,2))?1:0),0)]},y=g,x=f(g);if(x.every(e=>0===e)){e.labelPosition=g,o.push(eB(e));continue}for(let{start:t,end:i}of s.filter(t=>t.edge===e).sort((e,t)=>Math.hypot(t.end.x-t.start.x,t.end.y-t.start.y)-Math.hypot(e.end.x-e.start.x,e.end.y-e.start.y))){let e=Math.hypot(i.x-t.x,i.y-t.y);if(e<.01)continue;let n=-(i.y-t.y)/e,a=(i.x-t.x)/e,r=Math.abs(n)*m/2+Math.abs(a)*u/2;for(let e of[.5,.25,.75,.1,.9])for(let o of[0,r+6,-r-6,r+20,-r-20])p.push(h({x:t.x+(i.x-t.x)*e+n*o,y:t.y+(i.y-t.y)*e+a*o}))}for(let e of(p.sort((e,t)=>Math.hypot(e.x-g.x,e.y-g.y)-Math.hypot(t.x-g.x,t.y-g.y)),p)){let t=f(e),i=t.findIndex((e,t)=>e!==x[t]);if(i>=0&&t[i]<x[i]&&(y=e,x=t),t.every(e=>0===e))break}e.labelPosition=y,o.push(eB(e))}}({nodes:j,groups:el,edges:X},R.lineWidth,e);let es=X.flatMap(e=>{let t=eB(e);return t?[{...t,id:e.id,label:"",shape:"rectangle"}]:[]}),ed=X.flatMap(e=>ej(e,R.lineWidth).map(t=>({...t,id:e.id,label:"",shape:"rectangle"})));i([...j,...es,...ed],X,el,Math.max(W.marginX,W.marginY)+(H?.height??0));let ec=[...j,...N.values(),...es,...ed],eh=Math.max(eo.width,...ec.map(e=>e.x+e.width+W.marginX),...X.flatMap(e=>[...e.points.map(e=>e.x+W.marginX),(e.labelPosition?.x??0)+(e.labelBlock?.width??0)/2+W.marginX]),H?H.width+2*W.marginX:0),eg=Math.max(eo.height,...ec.map(e=>e.y+e.height+W.marginY),...X.flatMap(e=>[...e.points.map(e=>e.y+W.marginY),(e.labelPosition?.y??0)+(e.labelBlock?.height??0)/2+W.marginY])),ep=eC(e,W).map(e=>({...e,block:ea(e.label,{display:"literal",fontSize:R.edgeLabelFontSize,fontWeight:R.edgeLabelFontWeight,letterSpacing:R.edgeLetterSpacing,transform:R.edgeTextTransform,...void 0===W.maxWidth?{}:{maxWidth:Math.max(24,W.maxWidth-2*W.marginX-64)}})})),eu=ea("Legend",{display:"literal",fontSize:u?.text?.fontSize??13,fontWeight:u?.text?.fontWeight??600,letterSpacing:u?.text?.letterSpacing??0,transform:u?.text?.textTransform,...void 0===W.maxWidth?{}:{maxWidth:Math.max(24,W.maxWidth-2*W.marginX-24)}}),ef=ep.length?{x:W.marginX,y:eg+12,width:Math.max(eu.width+24,...ep.map(e=>e.block.width+64)),height:eu.height+20+ep.reduce((e,t)=>e+t.block.height+10,0),heading:eu,entries:ep}:void 0;ef&&(eh=Math.max(eh,ef.x+ef.width+W.marginX),eg=ef.y+ef.height+W.marginY);let eb=[...eo.diagnostics,...function(e,t,i,n){let a=[],{edges:r,nodes:o,groups:l}=t,s=eN(o,l),d=r.map(e=>({edge:e,box:eB(e)})).filter(e=>e.box),c=t=>e.relationships.find(e=>e.id===t.id)?.statementId;for(let{edge:e,box:t}of d)(s.some(e=>eT(t,e)>.01)||d.some(i=>i.edge!==e&&eT(t,i.box)>.01)||r.some(i=>i!==e&&i.points.slice(1).some((e,n)=>eA(i.points[n],e,t))))&&a.push({code:"C4_LABEL_COLLISION",severity:"warning",statementId:c(e),message:`Relationship ${e.id} has a label halo overlapping another label, card, boundary header/frame or relationship route; all authored text is retained.`});let h=eO(l).map(e=>({...e,height:e.headerHeight??0})),g=r.flatMap(e=>ej(e,i).map(t=>({edge:e,head:t})));for(let e of r){let t=g.filter(t=>t.edge===e).map(e=>e.head);((e.hasArrowEnd||e.hasArrowStart)&&!t.length||t.some(e=>d.some(t=>eT(e,t.box)>.01)||[...o,...h].some(t=>t.id!==e.endpoint&&eT(e,t)>.01)||g.some(t=>t.head!==e&&function(e,t){if(.01>=eT(e,t))return!1;for(let i of[e.polygon,t.polygon])for(let[n,a]of i.entries()){let r=i[(n+1)%i.length],o=-(r.y-a.y),l=r.x-a.x,s=Math.hypot(o,l);if(s<.001)continue;let d=e=>e.polygon.map(e=>(e.x*o+e.y*l)/s),c=d(e),h=d(t);if(Math.max(...c)+e.strokePadding<=Math.min(...h)-t.strokePadding+.01||Math.max(...h)+t.strokePadding<=Math.min(...c)-e.strokePadding+.01)return!1}return!0}(e,t.head))||n&&(e.x<-.01||e.y<-.01||e.x+e.width>n.width+.01||e.y+e.height>n.height+.01)))&&a.push({code:"C4_ARROW_OCCLUDED",severity:"warning",statementId:c(e),message:`Relationship ${e.id} has an arrowhead overlapping a label, card, boundary header or another arrowhead, exceeds the final canvas, or lacks a nonzero terminal segment.`})}return a}(e,{nodes:j,groups:el,edges:X},R.lineWidth,{width:eh,height:eg})];return void 0!==W.maxWidth&&eh>W.maxWidth+.01&&eb.push({code:"C4_WIDTH_EXCEEDED",severity:"warning",message:`The requested C4 width ${W.maxWidth}px cannot contain the ${Math.ceil(eh)}px artifact without shrinking or clipping content; minimum card widths, nesting, explicit direction constraints and authored offsets retain precedence.`}),{width:eh,height:eg,...ef?{legend:ef}:{},nodes:j,groups:el,edges:X,...H?{title:G(H,eh,W.marginY)}:{},body:e,config:W,diagnostics:eb,identities:ek(e),textContext:{node:R.nodeTextTransform,edge:R.edgeTextTransform,group:R.groupTextTransform,legendHeading:u?.text?.textTransform,title:U}}}(m.model,e.renderOptions,e.styleFace,m.c4,m.themeVariables))},projectPositioned:$(function({positioned:e,options:t}){let i=e.body,n=e.textContext,a=(e,t,i,n)=>{if(!i||i.prepared.source!==t||"literal"!==i.prepared.display||i.prepared.transform!==n)throw Error("C4 "+e+" changed its retained prepared text")},r=new Map(i.elements.map(e=>[e.id,e])),o=new Map(i.relationships.map(e=>[e.id,e])),l=new Map,s=new Map,d=(e,t)=>{for(let i of e){if(l.has(i.id))throw Error(`C4 boundary "${i.id}" has a repeated positioned frame`);l.set(i.id,i),s.set(i.id,t),d(i.children,i.id)}};d(e.groups);let c=new Set(e.nodes.map(e=>e.id));if(c.size!==e.nodes.length||c.size!==r.size||i.elements.some(e=>!c.has(e.id)))throw Error("C4 positioned cards do not match the authored identities");if(l.size!==i.boundaries.length)throw Error("C4 positioned frames do not match the authored boundaries");let h=new Set(e.edges.map(e=>e.id));if(h.size!==e.edges.length||h.size!==o.size)throw Error("C4 positioned relationships do not match the authored identities");for(let t of e.nodes){let e=eF(r.get(t.id));if(t.label!==e)throw Error("C4 card "+t.id+" changed its authored text");a(t.id,e,t.labelBlock,n.node)}for(let t of e.edges){let e=void 0===t.id?void 0:o.get(t.id);if(!e)throw Error("C4 positioned relationship has no authored interaction identity");let r=e$(i,e),l="dashed"===e.style.lineStyle||"dotted"===e.style.lineStyle?"dotted":"solid";if(t.source!==e.source||t.target!==e.target||t.label!==r||t.style!==l||t.hasArrowStart!==e.bidirectional||!t.hasArrowEnd||(t.startMarker??"arrow")!=="arrow"||(t.endMarker??"arrow")!=="arrow")throw Error("C4 relationship "+t.id+" changed its authored endpoints, label, shaft or markers");a(t.id,r,t.labelBlock,n.edge)}let g=[];for(let t of i.boundaries){let i=l.get(t.id);if(!i||s.get(t.id)!==t.parentId)throw Error(`C4 boundary "${t.id}" changed its authored parent`);let r=eS(t);if(i.label!==r)throw Error("C4 boundary "+t.id+" changed its authored text");a(t.id,r,i.labelBlock,n.group);let o="left"===t.alignment?"start":"right"===t.alignment?"end":"middle",d="left"===t.alignment?i.x+e.config.padding:"right"===t.alignment?i.x+i.width-e.config.padding:i.x+i.width/2,c=i.headerHeight??36;g.push({id:`boundary-label:${t.id}`,text:i.labelBlock?.text??i.label,bounds:F(i.labelBlock,d,i.y+c/2,o),container:k({...i,height:c})})}if(void 0!==n.title!=(void 0!==e.title))throw Error("C4 positioned title does not match the authored title");if(e.title){let t=e.title;a("title",n.title,t.block,n.group),g.push({id:"title",text:t.text,bounds:F(t.block,t.x,t.y),container:k(v(e))})}let p=eC(i,e.config);if(p.length>0!=(void 0!==e.legend))throw Error("C4 positioned legend does not match the authored legend");if(e.legend){let t=e.legend;if(t.entries.length!==p.length||t.entries.some((e,t)=>e.id!==p[t].id))throw Error("C4 positioned legend entries do not match the authored legend");a("legend heading","Legend",t.heading,n.legendHeading);let i=k(t);g.push({id:"legend:heading",text:t.heading.text,bounds:F(t.heading,t.x+12,t.y+8+t.heading.height/2,"start"),container:i});let r=t.y+20+t.heading.height;for(let[e,o]of t.entries.entries())a(o.id,p[e].label,o.block,n.edge),g.push({id:`legend:entry:${o.id}`,text:o.block.text,bounds:F(o.block,t.x+38,r+o.block.height/2,"start"),container:i}),r+=o.block.height+10}return{version:1,nodes:e.nodes.map(e=>{let t=r.get(e.id),i=em(t),n=e.y+e.height/2+("person"===i?19:4*("database"===i));return{id:t.id,x:q(e.x),y:q(e.y),w:q(e.width),h:q(e.height),shape:i,label:t.label,role:"box",...S(e.labelBlock,e.x+e.width/2,n,e),...void 0!==t.parentId?{parentId:t.parentId}:{}}}),edges:e.edges.map(e=>{let i=void 0===e.id?void 0:o.get(e.id);if(!i)throw Error("C4 positioned relationship has no authored interaction identity");return{id:i.id,from:e.source,to:e.target,path:e.points.map(e=>[q(e.x),q(e.y)]),...void 0!==e.label&&e.labelPosition?{label:{x:q(e.labelPosition.x),y:q(e.labelPosition.y),text:e.label,bounds:F(e.labelBlock,e.labelPosition.x,e.labelPosition.y)}}:{},...t.debug&&e.routeCertificate?{route:e.routeCertificate}:{}}}),groups:i.boundaries.map(e=>{let t=l.get(e.id);if(!t)throw Error(`C4 boundary "${e.id}" has no positioned frame`);return{id:e.id,label:e.label,x:q(t.x),y:q(t.y),w:q(t.width),h:q(t.height),members:i.elements.filter(t=>t.parentId===e.id).map(e=>e.id),...void 0!==e.parentId?{parentId:e.parentId}:{}}}),bounds:{w:q(e.width),h:q(e.height)},labels:g}}),lowerScene:M(to)});export{tl as default};
|
|
10
|
+
`&&a++,s=e;i=r};for(;i<e.length;){let t=i;if(/\s|;/.test(e[t])){let i=t+1;for(;i<e.length&&/\s|;/.test(e[i]);)i++;o(i,"trivia");continue}if(e.startsWith("%%",t)){let i=b(e,t),n=i<0?e.length:i,a=!r&&U([e.slice(t,n)],0)?.form==="native";o(n,a?"accessibility":"trivia");continue}if(r){r=!1;let i=b(e,t),n=i<0?e.length:i,a=n;for(let i=t;i<n;i++){if("&"===e[i]){let t=/^&(?:#\d+|#x[0-9a-f]+|[a-z][a-z0-9]*);/i.exec(e.slice(i,n));if(t){i+=t[0].length-1;continue}}if(";"===e[i]){a=i;break}}let l=ec(e.slice(t,a)).trim();if(eN.some(e=>e.toLowerCase()===l.toLowerCase())){o(a,"header");continue}}if("}"===e[t]){o(t+1,"boundary-close");continue}let a=e.slice(t),l=/^[A-Za-z_][A-Za-z_0-9]*/.exec(a)?.[0],s=t+(l?.length??0);for(;s<e.length&&/[ \t\r\n]/.test(e[s]);)s++;if(l&&"("===e[s]){let t=0,i="";for(;s<e.length;s++){let n=e[s];if(i)n===i&&(i="");else if('"'===n||"'"===n)i=n;else if("("===n)t++;else if(")"===n&&0==--t){s++;break}}if(t||i)throw Error(`C4: unclosed ${l} argument list at line ${n}`);let a=s;for(;a<e.length&&/\s/.test(e[a]);)a++;if("{"===e[a]){if(eY[l]){o(a+1,"boundary-open");continue}let t=1;for(i="",s=a+1;s<e.length&&t;s++){let n=e[s];if(i)n===i&&(i="");else if('"'===n||"'"===n)i=n;else if("%"===n&&"%"===e[s+1]){let t=b(e,s+2);s=t<0?e.length:t}else"{"===n?t++:"}"===n&&t--}if(t)throw Error(`C4: unclosed ${l} block at line ${n}`)}o(s);continue}let d=b(e,t);if(/^accDescr[ \t]*:?[ \t]*\{/i.test(a)){let i=e.indexOf("}",t);if(i<0)throw Error(`C4: unclosed accessibility block at line ${n}`);o(i+1,"accessibility");continue}o(d<0?e.length:d)}return t}(i);let a=[],r=new Set,o=new Set,l=!1,s=!1,d=!1;for(let e of n.statements){let i=e.raw.trim();if("trivia"===e.kind){eV(e,"trivia"),!i.startsWith("%%")&&i.includes(";")?(tn(n,e.id,"c4_semicolon_separator","Semicolon statement separators are a reader extension; pinned Mermaid C4 requires line breaks"),s=d=!1):i.startsWith("%%")?d||=s:/[\r\n]/.test(e.raw)&&!d&&(s=!1);continue}if(s&&"boundary-close"!==e.kind&&tn(n,e.id,"c4_statements_on_one_line","Statements sharing a line are a reader extension; pinned Mermaid C4 requires a line break after each statement and after `{`, and a comment after a statement takes its line break"),s=!0,d=!1,!l){let t=ec(i),a=eN.find(e=>e.toLowerCase()===t.toLowerCase());if(!a)throw Error("C4: expected C4Context, C4Container, C4Component, C4Dynamic, or C4Deployment");eV(e,"header"),n.variant=a,R("c4")&&z("c4","set-variant",a),e.kind="header",e.signature=a,l=!0;continue}if("boundary-close"===e.kind){eV(e,"boundary-close");let t=a.pop();if(!t)throw Error(`C4: unmatched closing boundary at line ${e.span.line}`);R("c4")&&z("c4","close-boundary",{id:t}),e.entityId=t;continue}if(A(i)!==i&&tn(n,e.id,"c4_entity_prepass","The global Mermaid entity prepass changes this statement; the writer protects its text fields without changing their values"),/^title\s/i.test(i)){eV(e,"title"),a.length&&tn(n,e.id,"c4_nested_header_directive","Metadata inside a boundary is read as global. Pinned Mermaid requires it at document scope; the writer moves it after the header"),/[#;]/.test(A(i.replace(/^title\s+/i,"")))&&tn(n,e.id,"c4_title_token","The title contains literal token delimiters; serialization writes entity escapes for pinned Mermaid"),n.title=m(et(i.replace(/^title\s+/i,""))),R("c4")&&z("c4","set-title",n.title),e.kind="title",e.signature=n.title;continue}let c=U(i.split(/\r\n?|\n/),0);if(c){eV(e,"accessibility"),a.length&&tn(n,e.id,"c4_nested_header_directive","Metadata inside a boundary is read as global. Pinned Mermaid requires it at document scope; the writer moves it after the header"),c.title||"native"===c.form||""!==c.value||tn(n,e.id,"c4_empty_accessibility_description","An empty accessibility description block is a reader extension; the writer preserves its value in a native metadata comment"),c.title?n.accessibilityTitle=c.value:n.accessibilityDescription=c.value,R("c4")&&z("c4",c.title?"set-accessibility-title":"set-accessibility-description",c.value),e.kind="accessibility",e.entityId=c.title?"title":"description",e.signature=c.value;continue}if(/^accDescription\s+/i.test(i)){eV(e,"accessibility"),n.accessibilityDescription=i.replace(/^accDescription\s+/i,""),R("c4")&&z("c4","set-accessibility-description",n.accessibilityDescription),e.kind="accessibility",e.entityId="description",e.signature=n.accessibilityDescription;continue}let h=/^direction\s+(LR|RL|TB|BT)\s*$/.exec(i);if(h){eV(e,"direction");let t={id:e.id,name:"direction",args:[{value:h[1],raw:h[1]}],category:"layout",statementId:e.id};n.directives.push(t),R("c4")&&z("c4","add-directive",t),e.kind="directive",e.entityId=t.id,e.signature=ti(t);continue}let g=/^([A-Za-z_][A-Za-z_0-9]*)\s*\(([\s\S]*)\)\s*(\{)?$/.exec(i);if(!g){eV(e,"unknown"),tn(n,e.id,"c4_unknown_statement","C4 statement is preserved but has no native interpretation","error");continue}let p=g[1],u=function(e){if(!e.trim())return[];let t=[],i=0,n=0,a="";for(let r=0;r<e.length;r++){let o=e[r];a?o===a&&(a=""):'"'===o||"'"===o?a=o:"("===o?n++:")"===o?n--:","===o&&0===n&&(t.push(e.slice(i,r)),i=r+1)}return t.push(e.slice(i)),t.map(e=>{let t=/^\s*\$([A-Za-z_][A-Za-z_0-9]*)\s*=([\s\S]*)$/.exec(e);return{...t?{name:t[1]}:{},value:e0(t?t[2]:e),raw:e}})}(g[2]);if("UpdateLayoutConfig"===p&&(0===u.length||1===u.length&&!u[0].name&&""===u[0].value)&&!g[3]){a.length&&r.add(a.at(-1)),"("===i[p.length]&&e1(u)||tn(n,e.id,"c4_empty_layout_arguments","An empty layout call is a no-op; the writer supplies the attribute required by pinned Mermaid"),e.kind="trivia";continue}/[\r\n]/.test(g[2].replace(/"[^"]*"|'[^']*'/g,""))&&tn(n,e.id,"c4_multiline_arguments","Line breaks between C4 arguments are a reader extension; quoted multiline text remains supported"),u.some(e=>e.name&&""===e.value)&&tn(n,e.id,"c4_empty_named_argument","Empty named arguments are retained; pinned Mermaid requires a positional empty slot");let f=eU.exec(p),y=!!(f&&!("Person"===f[1]&&f[2]))||Object.hasOwn(eY,p)||eH.has(p)||ta.has(p);if(y&&a.length&&r.add(a.at(-1)),y&&u.some(e2))throw new eD(`C4 argument is ambiguous in ${i}: separate named arguments with commas and use $name="value", or quote the entire value when it is literal text`);if(y&&u.some((e,t)=>{let i=e.raw.trim();return e.name?!/^\$[A-Za-z_][A-Za-z_0-9]*\s*=\s*"/.test(i)&&""!==e.value:i.startsWith("$")||t===u.length-1&&""!==i&&!/^["']/.test(i)})&&tn(n,e.id,"c4_unquoted_argument","Unquoted C4 argument text is read literally here, but pinned Mermaid requires a quoted final argument and quoted named values; serialization writes those values in double quotes"),y&&"("!==i[p.length]&&tn(n,e.id,"c4_space_before_arguments",`Pinned Mermaid reads "(" only straight after ${p} and rejects whitespace between them; ours reads the call. Write ${p}( with no space`),f&&!("Person"===f[1]&&f[2])){if(eV(e,"element"),g[3])throw Error(`C4: ${p} cannot open a boundary`);let i=e3(u,e6(p)),r=te(i,"alias",p);if(o.has(r))throw Error(`C4: duplicate declaration alias ${JSON.stringify(r)}`);o.add(r);let l={id:r,macro:p,kind:f[1].toLowerCase(),external:!!f[3],shape:"Person"===f[1]?"person":"Db"===f[2]?"database":"Queue"===f[2]?"queue":"rectangle",label:tt(u,e6(p),i,p),technology:e7(e4(u,e6(p),"techn")),description:e7(e4(u,e6(p),"descr")),parentId:a.at(-1),tags:e9(i.tags),link:e7(i.link),sprite:e7(i.sprite),style:{},args:u,statementId:e.id};t&&B("nodes",n.elements.length+n.boundaries.length+1),n.elements.push(l),R("c4")&&z("c4","add-element",l),e.kind="element",e.entityId=r,e.signature=ti(l)}else if(eY[p]){if(eV(e,"boundary-open"),!g[3])throw Error(`C4: ${p} requires a boundary block`);let i=e3(u,e5(p)),r=te(i,"alias",p);if(o.has(r))throw Error(`C4: duplicate declaration alias ${JSON.stringify(r)}`);o.add(r);let l={id:r,macro:p,kind:eY[p],label:tt(u,e5(p),i,p),type:e7(e4(u,e5(p),"type")),description:e7(e4(u,e5(p),"descr")),parentId:a.at(-1),tags:e9(i.tags),link:e7(i.link),sprite:e7(i.sprite),style:{},args:u,statementId:e.id,..."Node_L"===p?{alignment:"left"}:"Node_R"===p?{alignment:"right"}:{}};t&&(B("nodes",n.elements.length+n.boundaries.length+1),B("nesting",a.length+1)),n.boundaries.push(l),a.push(r),R("c4")&&z("c4","open-boundary",l),e.entityId=r,e.signature=ti(l)}else if(eH.has(p)){eV(e,"relationship");let i=e3(u,e8(p)),a=te(i,"from",p),r=te(i,"to",p),o="Rel_Back"===p,l={id:"",macro:p,from:a,to:r,source:o?r:a,target:o?a:r,label:tt(u,e8(p),i,p),technology:e7(e4(u,e8(p),"techn")),description:e7(e4(u,e8(p),"descr")),tags:e9(i.tags),link:e7(i.link),sprite:e7(i.sprite),style:{},args:u,statementId:e.id,index:"RelIndex"===p?te(i,"index",p):void 0,order:n.relationships.length+1,bidirectional:"BiRel"===p,reversed:o,direction:eZ[p.slice(4)]};t&&B("edges",n.relationships.length+n.layout.hints.length+1),n.relationships.push(l),R("c4")&&z("c4","add-relationship",l),e.kind="relationship","RelIndex"===p&&u.slice(4).some(e=>!e.name)&&tn(n,e.id,"c4_relindex_positional_metadata","RelIndex positional metadata follows documented tags/link slots; pinned Mermaid instead treats them as technology/description. Named $tags/$link avoids this ambiguity")}else{eV(e,"directive");let t={id:e.id,name:p,args:u,category:"UpdateElementStyle"===p?"element-style":"UpdateRelStyle"===p?"relationship-style":"AddElementTag"===p?"element-tag":"AddRelTag"===p?"relationship-tag":"UpdateLayoutConfig"===p||p.startsWith("Lay_")||p.startsWith("LAYOUT_")?"layout":"ShowLegend"===p||"SHOW_LEGEND"===p||"SHOW_FLOATING_LEGEND"===p?"legend":"AddElementLink"===p||"AddRelLink"===p?"link":"unknown",statementId:e.id};n.directives.push(t),R("c4")&&z("c4","add-directive",t),e.kind="directive",e.entityId=t.id,e.signature=ti(t),"unknown"===t.category?tn(n,e.id,"c4_unknown_macro",`${p} is preserved but has no native interpretation`,"error"):p.startsWith("Update")||tn(n,e.id,"c4_directive_extension",`${p} is a reader extension; pinned Mermaid does not accept this directive`)}let x=f?e6(p):eY[p]?e5(p):eH.has(p)?e8(p):("UpdateElementStyle"===p?eJ:"UpdateRelStyle"===p?eQ:"UpdateLayoutConfig"===p?["c4ShapeInRow","c4BoundaryInRow"]:void 0)??("AddElementTag"===p?eG:"AddRelTag"===p?eK:void 0);if(x){let t=new Set;for(let i=0;i<u.length;i++){let a=u[i],r=a.name??x[i];void 0!==r&&x.includes(r)?t.has(r)&&tn(n,e.id,"c4_duplicate_argument",`${p} assigns ${r} more than once; every argument is retained`,"error"):tn(n,e.id,"c4_unknown_argument",`${p} argument ${a.name??i+1} is retained but has no native interpretation`,"error"),r&&t.add(r)}}u.some(e=>/^\s*'/.test(e.raw)||/\\["']/.test(e.raw))?tn(n,e.id,"c4_quoted_string_extension","Quoted-string extension is preserved; typed edits write Mermaid entity escapes"):!y||e1(u)||n.diagnostics.some(t=>t.statementId===e.id&&["c4_multiline_arguments","c4_empty_named_argument"].includes(t.syntax))||tn(n,e.id,"c4_argument_spelling","Argument text is retained as its native value; the writer emits complete quoted argument tokens instead of ambiguous imported spelling")}if(!l)throw Error("C4: missing diagram header");if(a.length)throw Error(`C4: unclosed boundary ${JSON.stringify(a.at(-1))}`);t&&T(n);let c=en(o),h=new Map(n.statements.map(e=>[e.id,e]));for(let e of n.relationships){if(e.id=c(`c4-rel-${e.order}`,["c4-relationship",e.order]),R("c4")&&z("c4","set-relationship-identity",{id:e.id,order:e.order}),!o.has(e.from)||!o.has(e.to))throw Error(`C4: relationship ${e.id} references an undeclared endpoint`);let t=h.get(e.statementId);t.entityId=e.id,t.signature=ti(e)}for(let e of(!function(e,t=!1){for(let t of[...e.elements,...e.boundaries,...e.relationships])t.style={},delete t.effectiveLink,R("c4")&&z("c4","reset-presentation",{id:t.id,style:t.style});e.layout={hints:[]},R("c4")&&z("c4","reset-layout",e.layout);let i=new Map([...e.elements,...e.boundaries].map(e=>[e.id,e])),n=new Map,a=(e,t)=>JSON.stringify([e,t]);for(let t of e.relationships){let e=a(t.from,t.to),i=n.get(e)??[];i.push(t),n.set(e,i)}let r=(e,t)=>{let i=e3(e.args,t);for(let n of["techn","legendText"]){let a=e4(e.args,t,n);void 0!==a&&(i[n]=a)}return i},o=new Map,l=new Map;for(let t of e.directives){if("element-tag"!==t.category&&"relationship-tag"!==t.category)continue;let e=r(t,"element-tag"===t.category?eG:eK);("element-tag"===t.category?o:l).set(e.tagStereo??"",tr(e,["tagStereo"])),R("c4")&&z("c4","define-tag",{category:t.category,tag:e.tagStereo??"",style:("element-tag"===t.category?o:l).get(e.tagStereo??"")})}for(let t of[...e.elements,...e.boundaries])for(let e of t.tags)Object.assign(t.style,o.get(e)),R("c4")&&z("c4","apply-tag",{id:t.id,tag:e,style:t.style});for(let t of e.relationships)for(let e of t.tags)Object.assign(t.style,l.get(e)),R("c4")&&z("c4","apply-tag",{id:t.id,tag:e,style:t.style});for(let o of e.directives)if("element-style"===o.category){let e=r(o,eJ),t=i.get(e.elementName);if(!t)throw Error(`C4: UpdateElementStyle references undeclared alias ${JSON.stringify(e.elementName)}`);Object.assign(t.style,tr(e,["elementName"])),R("c4")&&z("c4","set-element-style",{id:t.id,style:t.style})}else if("relationship-style"===o.category){let e=e3(o.args,eQ),t=n.get(a(e.from,e.to));if(!t)throw Error("C4: UpdateRelStyle references an undeclared relationship pair");for(let t of["offsetX","offsetY"])if(void 0!==e[t]&&!Number.isFinite(Number(e[t])))throw Error(`C4: ${t} must be finite`);for(let i of t)Object.assign(i.style,tr(e,["from","to"])),R("c4")&&z("c4","set-relationship-style",{id:i.id,style:i.style})}else if("UpdateLayoutConfig"===o.name){let t=e3(o.args,["c4ShapeInRow","c4BoundaryInRow"]);for(let[i,n]of[["c4ShapeInRow","shapesPerRow"],["c4BoundaryInRow","boundariesPerRow"]]){if(void 0===t[i]||""===t[i])continue;let a=Number(t[i]);if(!Number.isSafeInteger(a)||a<1)throw Error(`C4: ${i} must be a positive integer`);e.layout[n]=a,R("c4")&&z("c4","set-layout-option",{name:n,value:a})}}else if(o.name.startsWith("Lay_")){let n=eZ[o.name.slice(4)],a=e3(o.args,["from","to"]);if(!n||!a.from||!a.to||!i.has(a.from)||!i.has(a.to))throw Error(`C4: ${o.name} requires two declared aliases`);n&&a.from&&a.to&&(t&&B("edges",e.relationships.length+e.layout.hints.length+1),e.layout.hints.push({from:a.from,to:a.to,direction:n,statementId:o.statementId}),R("c4")&&z("c4","add-layout-hint",e.layout.hints.at(-1)))}else if("direction"===o.name)e.layout.direction=o.args[0]?.value,R("c4")&&z("c4","set-direction",e.layout.direction);else if("LAYOUT_LEFT_RIGHT"===o.name||"LAYOUT_TOP_DOWN"===o.name)e.layout.direction="LAYOUT_LEFT_RIGHT"===o.name?"LR":"TB",R("c4")&&z("c4","set-direction",e.layout.direction);else if("AddElementLink"===o.name){let e=e3(o.args,["alias","link"]),t=i.get(e.alias);t&&(t.effectiveLink=e.link,R("c4")&&z("c4","set-effective-link",{id:t.id,link:t.effectiveLink}))}else if("AddRelLink"===o.name){let e=e3(o.args,["from","to","link"]);for(let t of n.get(a(e.from,e.to))??[])t.effectiveLink=e.link,R("c4")&&z("c4","set-effective-link",{id:t.id,link:t.effectiveLink})}let s=en([...e.elements,...e.boundaries,...e.relationships].map(e=>e.id));e.legend={visible:e.directives.some(e=>"legend"===e.category),entries:[...[...o.entries()].map(([e,t])=>({id:s(`c4-tag-${e}`,["element-tag",e]),label:t.legendText??e,kind:"element",style:{...t}})),...[...l.entries()].map(([e,t])=>({id:s(`c4-tag-${e}`,["relationship-tag",e]),label:t.legendText??e,kind:"relationship",style:{...t}}))]},R("c4")&&z("c4","set-legend",e.legend)}(n,t),n.boundaries))r.has(e.id)||tn(n,e.statementId,"c4_empty_boundary","An empty boundary is retained; the writer supplies a no-op layout statement because pinned Mermaid requires a statement inside its block");if(n.directives.some(e=>"direction"===e.name)){let e=n.directives.find(e=>"direction"===e.name);tn(n,e.statementId,"c4_direction","A standalone direction directive is a reader extension to legacy C4")}for(let e of[...n.elements,...n.boundaries,...n.relationships])for(let t of(e.sprite&&tn(n,e.statementId,"c4_sprite","C4 sprite metadata is preserved; offline native output uses an explicit text fallback"),void 0===e.style.lineStyle||["solid","dashed","dotted"].includes(e.style.lineStyle)||tn(n,e.statementId,"c4_line_style",`C4 lineStyle ${JSON.stringify(e.style.lineStyle)} is preserved but has no native paint effect; the route uses solid strokes`),Object.keys(e.style)))"shape"===t&&"external"in e&&void 0!==ep(e.style.shape)||["bgColor","fontColor","borderColor","textColor","lineColor","lineStyle","offsetX","offsetY","legendText","techn"].includes(t)||tn(n,e.statementId,"c4_style_property",`C4 style ${t} is preserved as metadata but has no native paint effect`);return n}(e,!0),i=t.diagnostics.find(e=>"error"===e.severity);if(i){let e;throw Error(`C4 unsupported syntax: ${(e=t.statements.find(e=>e.id===i.statementId))?`${i.message} (in: ${e.raw.trim()})`:i.message}`)}return t}(e.source.originalText.slice(t)),a=i.split(/\r\n?|\n/).length-1;for(let e of n.statements)e.span.start+=i.length,e.span.end+=i.length,e.span.line+=a;let r=_(e.source.frontmatter);return void 0===n.title&&void 0!==r&&(n.title=r),void 0!==e.source.accessibility.title&&(n.accessibilityTitle=e.source.accessibility.title),void 0!==e.source.accessibility.descr&&(n.accessibilityDescription=e.source.accessibility.descr),{familyConfig:{model:n,c4:e.source.config.c4??{},themeVariables:e.source.config.themeVariables??{}}}},layout:e=>{let m=e.familyConfig;return C(function(e,m={},u,f={},y={}){var x;let b,_,w,v,k,F,S,$,M,C;T(e);let W=ey({...void 0===m.padding?{}:{diagramMarginX:m.padding,diagramMarginY:m.padding},...void 0===m.nodeSpacing?{}:{c4ShapeMargin:m.nodeSpacing},...void 0===m.layerSpacing?{}:{nextLinePaddingX:m.layerSpacing},...f},y),R=Z(m,void 0,u),L=function(e,t=ey()){for(let t of[...e.elements,...e.boundaries,...e.relationships,...e.legend?.entries??[]]){let e=t.style;j({...void 0===e.bgColor?{}:{fill:e.bgColor},...void 0===e.borderColor&&void 0===e.lineColor?{}:{stroke:e.borderColor??e.lineColor},...void 0===e.fontColor&&void 0===e.textColor?{}:{color:e.fontColor??e.textColor}},`C4 ${t.id}`)}let i=ek(e),n={direction:e.layout.direction??e.layout.hints[0]?.direction??e.relationships.find(e=>e.direction)?.direction??"LR",nodes:new Map,edges:[],subgraphs:[],classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,linkStyles:new Map},a=new Map;for(let t of e.boundaries)a.set(t.id,{id:i.nodes.get(t.id)??t.id,label:eS(t),nodeIds:[],children:[]});for(let t of e.boundaries){let e=a.get(t.id),i=t.parentId&&a.get(t.parentId);i?i.children.push(e):n.subgraphs.push(e)}for(let r of e.elements){let e=i.nodes.get(r.id)??r.id,o=ex(r,t),l=em(r);n.nodes.set(e,{id:e,label:eF(r),shape:"database"===l?"cylinder":"queue"===l?"subroutine":"rectangle",href:r.effectiveLink??r.link}),r.parentId&&a.get(r.parentId)?.nodeIds.push(e),n.nodeStyles.set(e,{...o.fill?{fill:o.fill}:{},...o.stroke?{stroke:o.stroke}:{},...o.text?{color:o.text}:{},...o.dashed?{"stroke-dasharray":"5 3"}:{}})}for(let t of e.relationships){let a=e$(e,t);n.edges.push({id:i.relationships.get(t.id)??t.id,source:t.source,target:t.target,label:a,labelContent:{value:a,prepared:ee(a,"literal")},style:"dashed"===t.style.lineStyle||"dotted"===t.style.lineStyle?"dotted":"solid",hasArrowStart:t.bidirectional,hasArrowEnd:!0}),n.linkStyles.set(n.edges.length-1,j({...t.style.lineColor?{stroke:t.style.lineColor}:{},...t.style.textColor?{color:t.style.textColor}:{}},`UpdateRelStyle(${t.from}, ${t.to})`))}return n}(e,W),I=new Map,z=new Map([...e.elements,...e.boundaries].map(e=>[e.id,e.parentId])),E=e=>{let t=[];for(let i=z.get(e);i&&!t.includes(i);i=z.get(i))t.push(i);return t},B=e=>void 0!==W.input.c4ShapePadding?W.padding:W.compact&&u?.node?.["X"===e?"paddingX":"paddingY"]===void 0?Math.min(W.padding,R["X"===e?"nodePaddingX":"nodePaddingY"]):R["X"===e?"nodePaddingX":"nodePaddingY"],P=e=>{if(void 0===W.wrapWidth)return;if(void 0===W.maxWidth)return W.wrapWidth;let t=void 0===e?0:E(e).length;return Math.max(24,W.minimumWidth-2*B("X")-20,Math.min(W.wrapWidth,W.maxWidth-(W.marginX+40)*2-t*W.boundaryPadding*2-2*B("X")-20))},O=(e,t,i=!1)=>{let n=ex(e,W);return ea(t,{display:"literal",fontSize:n.fontSize??(i?R.groupHeaderFontSize:R.nodeLabelFontSize),fontWeight:n.fontWeight??(i?R.groupHeaderFontWeight:R.nodeLabelFontWeight),transform:i?R.groupTextTransform:R.nodeTextTransform,maxWidth:P(e.id),letterSpacing:i?R.groupLetterSpacing:R.nodeLetterSpacing,fontFamily:n.fontFamily??(i?R.groupFont:void 0)})},A=e.elements.map(e=>{let t=eF(e),i=O(e,t),n=em(e),a=Math.max(W.minimumWidth,i.width+2*B("X")+20*("queue"===n)),r=Math.max(W.minimumHeight,i.height+2*B("Y")+("person"===n?38:16*("database"===n)));return I.set(e.id,{id:e.id,x:0,y:0,width:a,height:r,..."database"===n?{cylinder:!0}:{}}),{...L.nodes.get(e.id),x:0,y:0,width:a,height:r,labelBlock:i,inlineStyle:L.nodeStyles.get(e.id)}}),X=new Map;for(let t of e.boundaries){let e=eS(t),i=O(t,e,!0),n=i.height+2*W.padding,a={id:t.id,label:e,labelBlock:i,x:0,y:0,width:Math.max(W.minimumWidth,i.width+2*W.padding),height:n+2*W.boundaryPadding,headerHeight:n,children:[]};X.set(t.id,a),I.set(t.id,{...a,container:!0})}let N=L.edges.map((t,i)=>({...t,points:[],labelBlock:ea(e$(e,e.relationships[i]),{display:"literal",fontSize:R.edgeLabelFontSize,fontWeight:R.edgeLabelFontWeight,letterSpacing:R.edgeLetterSpacing,transform:R.edgeTextTransform,...void 0===W.maxWidth?{}:{maxWidth:P()}}),inlineStyle:L.linkStyles.get(i),edgeIndex:i}));for(let t of e.boundaries){let e=N.filter(e=>e.source===t.id&&E(e.target).includes(t.id)||e.target===t.id&&E(e.source).includes(t.id));e.length&&(I.get(t.id).bottomPadding=Math.max(W.boundaryPadding,...e.map(e=>(e.labelBlock?.height??0)+48))*e.length)}let D="LR"===L.direction||"RL"===L.direction;for(let[e,t]of I){let i=N.filter(t=>t.source===e||t.target===e),n=Math.max(0,...i.map(e=>(e.labelBlock?.height??0)+28)),a=Math.max(0,...i.map(e=>(e.labelBlock?.width??0)+24)),r=new Map;for(let t of i){let i=t.source===e?t.target:t.source;r.set(i,(r.get(i)??0)+1)}let o=Math.max(0,...r.values());D?t.height=Math.max(t.height,(o+1)*n+(t.headerHeight??0),(i.length+1)*16+(t.headerHeight??0)):t.width=Math.max(t.width,(o+1)*a,(i.length+1)*16)}let U=m.diagramTitle??e.title,Y=void 0===U?void 0:ea(U,{display:"literal",fontSize:J,fontWeight:Q,transform:R.groupTextTransform,letterSpacing:R.groupLetterSpacing,fontFamily:R.groupFont,...void 0===W.maxWidth?{}:{maxWidth:Math.max(24,W.maxWidth-2*W.marginX)}}),H=Y?{text:Y.text,width:Y.width,height:Y.height+G,block:Y}:void 0,V=Math.max(W.gap,...N.map(e=>(e.labelBlock?.width??0)*2+48)),et=Math.max(W.rowGap,...N.map(e=>(e.labelBlock?.height??0)*2+48)),ei=new Map;for(let e of N){let t=JSON.stringify([e.source,e.target].sort());ei.set(t,(ei.get(t)??0)+1)}let en=Math.max(1,...ei.values()),er=en>1?en+1:1,eo=(x={gapX:V*er,gapY:et*er,padding:W.boundaryPadding,marginX:W.marginX+40,marginY:W.marginY+40+(H?.height??0),shapesPerRow:e.layout.shapesPerRow??W.shapesPerRow,boundariesPerRow:e.layout.boundariesPerRow??W.boundariesPerRow,direction:"TD"===L.direction?"TB":L.direction,maxWidth:W.maxWidth},b=new Map([...I].map(([e,t])=>[e,{...t}])),_=[],w=new Map(e.statements.map((e,t)=>[e.id,t])),k=new Map((v=[...e.boundaries,...e.elements].sort((e,t)=>(w.get(e.statementId)??0)-(w.get(t.statementId)??0))).map(e=>[e.id,e.parentId])),F=[...e.layout.hints,...e.relationships.filter(e=>e.direction).map(e=>({from:e.from,to:e.to,direction:e.direction,statementId:e.statementId}))],S=(e,t)=>{let i=new Set;for(;k.get(e)!==t;){if(i.has(e))return;i.add(e);let t=k.get(e);if(!t)return;e=t}return e},M=($=(e,t,i)=>{let n=v.filter(t=>t.parentId===e&&b.has(t.id));for(let e of n)if(b.get(e.id).container&&!t.has(e.id)){let n=new Set(t);n.add(e.id);let a=$(e.id,n,void 0===i?void 0:Math.max(1,i-2*x.padding)),r=b.get(e.id);r.width=Math.max(r.width,a.width+2*x.padding),r.height=Math.max(r.height,a.height+(r.headerHeight??0)+x.padding+Math.max(x.padding,r.bottomPadding??0))}let a=n.some(e=>b.get(e.id).container)?x.boundariesPerRow:x.shapesPerRow,r=x.direction,o="LR"===r||"RL"===r;if(!o&&void 0!==i){let e=Math.max(1,...n.map(e=>b.get(e.id).width)),t=Math.max(1,Math.floor((i+x.gapX)/(e+x.gapX)));a=Math.max(a,Math.ceil(n.length/t))}let l=0,s=0,d=0,c=0,h=0;n.forEach(e=>{let t=b.get(e.id);h&&(h>=a||o&&void 0!==i&&l+t.width>i)&&(o?(l=0,s+=d+x.gapY,d=0):(s=0,l+=c+x.gapX,c=0),h=0),t.x=l,t.y=s,o?l+=t.width+x.gapX:s+=t.height+x.gapY,d=Math.max(d,t.height),c=Math.max(c,t.width),h++});let g=[];for(let t of F){let i=S(t.from,e),n=S(t.to,e);if(!i||!n||i===n||!b.has(i)||!b.has(n))continue;let a="LR"===t.direction||"RL"===t.direction?"x":"y",r="RL"===t.direction||"BT"===t.direction,o=r?n:i,l=r?i:n,s=(e,t,i=new Set)=>e===t||!i.has(e)&&(i.add(e),g.some(n=>n.axis===a&&n.before===e&&s(n.after,t,i)));if(s(l,o)){_.push({code:"C4_LAYOUT_CONFLICT",severity:"warning",statementId:t.statementId,message:`Conflicting C4 ${"x"===a?"horizontal":"vertical"} direction for ${t.from} and ${t.to}; the earlier constraint is retained.`});continue}g.push({before:o,after:l,axis:a,statementId:t.statementId})}if(g.length){for(let e of n){let t=b.get(e.id);g.some(t=>"x"===t.axis&&(t.before===e.id||t.after===e.id))&&(t.x=0),g.some(t=>"y"===t.axis&&(t.before===e.id||t.after===e.id))&&(t.y=0)}let e=()=>{for(let e=0;e<n.length;e++)for(let e of g){let t=b.get(e.before),i=b.get(e.after);i[e.axis]=Math.max(i[e.axis],t[e.axis]+("x"===e.axis?t.width+x.gapX:t.height+x.gapY))}};e();for(let t=0;t<n.length;t++){let t=!1;for(let e=0;e<n.length;e++)for(let i=e+1;i<n.length;i++){let a=b.get(n[e].id),r=b.get(n[i].id);a.x<r.x+r.width&&r.x<a.x+a.width&&a.y<r.y+r.height&&r.y<a.y+a.height&&(r.y=a.y+a.height+x.gapY,t=!0)}if(e(),!t)break}}else if("RL"===r||"BT"===r){let e=Math.max(0,...n.map(e=>{let t=b.get(e.id);return"RL"===r?t.x+t.width:t.y+t.height}));for(let t of n){let i=b.get(t.id);"RL"===r?i.x=e-i.x-i.width:i.y=e-i.y-i.height}}return{width:Math.max(0,...n.map(e=>{let t=b.get(e.id);return t.x+t.width})),height:Math.max(0,...n.map(e=>{let t=b.get(e.id);return t.y+t.height}))}})(void 0,new Set,void 0===x.maxWidth?void 0:Math.max(1,x.maxWidth-2*x.marginX)),(C=(e,t,i,n)=>{for(let a of v.filter(t=>t.parentId===e)){let e=b.get(a.id);!e||n.has(a.id)||(n.add(a.id),e.x+=t,e.y+=i,e.container&&C(a.id,e.x+x.padding,e.y+(e.headerHeight??0)+x.padding,n))}})(void 0,x.marginX,x.marginY,new Set),{boxes:b,width:M.width+2*x.marginX,height:M.height+2*x.marginY,diagnostics:_});for(let e of A)Object.assign(e,eo.boxes.get(e.id));let el=[];for(let t of e.boundaries){let e=X.get(t.id);Object.assign(e,eo.boxes.get(t.id));let i=t.parentId&&X.get(t.parentId);i?i.children.push(e):el.push(e)}(function(e,i,m,u,f){let{edges:y}=i,x=[...e.values()].filter(e=>e.container).map(e=>({...e,id:f.generated(`c4-header-obstacle:${e.id}`,["c4","header-obstacle",e.id]),height:e.headerHeight??1,shape:"rectangle",label:""})),b=[...i.nodes,...x],_=0,w=()=>{if(++_>4e5)throw new eW},v=(e,t,i)=>(w(),h(e,t,i)),k=(e,t,i,n,a)=>{let r={x:eR[t].x*i,y:eR[t].y*i},o=n;for(let t of b){if(w(),t.id===a||!(r.x?e.y>t.y&&e.y<t.y+t.height:e.x>t.x&&e.x<t.x+t.width))continue;let i=r.x>0?t.x-e.x:r.x<0?e.x-t.x-t.width:r.y>0?t.y-e.y:e.y-t.y-t.height;i>=0&&(o=Math.min(o,Math.max(0,i-2)))}return{x:e.x+r.x*o,y:e.y+r.y*o}},F=new Map,S=new Map,$=new Map,M=y.flatMap(t=>{let i=e.get(t.source),n=e.get(t.target);if(!i||!n)return[];let[a,r]=function(e,t){if(e.id===t.id)return["R","B"];if(e.container&&eL(e,t)||t.container&&eL(t,e))return["B","B"];let i=eI(e),n=eI(t);return Math.abs(i.x-n.x)>=Math.abs(i.y-n.y)?i.x<=n.x?["R","L"]:["L","R"]:i.y<=n.y?["B","T"]:["T","B"]}(i,n);for(let[e,t]of[[i.id,a],[n.id,r]]){let i=`${e}\0${t}`;S.set(i,(S.get(i)??0)+1)}return[{edge:t,source:i,target:n,startSide:a,endSide:r}]}),C=new Map;for(let e of M){let t=JSON.stringify([e.source.id,e.target.id].sort()),i=C.get(t)??[];i.push(e),C.set(t,i)}for(let[e,i]of M.entries()){let n,{edge:a,source:r,target:o,startSide:l,endSide:s}=i,d=(e,t)=>{let i=`${e.id}\0${t}`,n=$.get(i)??0;return $.set(i,n+1),{index:n,count:S.get(i)}},c=d(r,l),h=d(o,s),p=eE(r,l,c.index,c.count),m=r.id===o.id?eE(o,s,h.index,h.count):function(e,t,i,n,a,r){let o=eE(i,n,a,r);if(eq[t]!==n)return o;let l="L"===n||"R"===n?"y":"x",s=e[l]-o[l];if(0===s||Math.abs(s)>=8)return o;let d=ez(i,n,0),c=ez(i,n,1),h=(e[l]-d[l])/(c[l]-d[l]);if(!(h>0&&h<1))return o;let g=ez(i,n,h);for(let e=0;e<r;e++)if(e!==a&&8>Math.abs(eE(i,n,e,r)[l]-g[l]))return o;return g}(p,l,o,s,h.index,h.count),f=r.container&&r.id!==o.id&&eL(r,o)?-1:1,y=o.container&&r.id!==o.id&&eL(o,r)?-1:1,x=C.get(JSON.stringify([r.id,o.id].sort())),b="R"===l||"L"===l?Math.max(24,...x.map(e=>(e.edge.labelBlock?.width??0)+32)):Math.max(24,...x.map(e=>(e.edge.labelBlock?.height??0)+24)),_=(x.indexOf(i)-(x.length-1)/2)*b,w=14+e%5*4,v=g(a,u),M=k(p,l,f,Math.max(w,v.start?v.start+(u.edgeBendRadius??0):0),r.id),W=k(m,s,y,Math.max(w,v.end?v.end+(u.edgeBendRadius??0):0),o.id);if(F.set(a,{start:p,end:m,startExit:M,endExit:W}),r.id===o.id){let e=r.x+r.width+w+(a.labelBlock?.width??0)/2,t=r.y+r.height+w+(a.labelBlock?.height??0)/2;n=[M,{x:e,y:M.y},{x:e,y:t},{x:W.x,y:t},W]}else if("R"===l||"L"===l){let e=(M.x+W.x)/2+_;n=[M,{x:e,y:M.y},{x:e,y:W.y},W]}else{let e=(M.y+W.y)/2+_;n=[M,{x:M.x,y:e},{x:W.x,y:e},W]}a.points=t([p,...n,m]),F.get(a).seed=a.points,a.label&&(a.labelPosition=q(a.points))}for(let n of(r(i,m,new Set,u),l(i,m,u),s(i,m,u),c(i,m,u),y)){let a=F.get(n),r=e.get(n.source),o=e.get(n.target),l=Math.abs(eI(r).x-eI(o).x)>=Math.abs(eI(r).y-eI(o).y)?eI(r).x<=eI(o).x?"LR":"RL":eI(r).y<=eI(o).y?"TB":"BT",s={id:f.generated(`${n.id}:routing-source`,["c4",n.id,"routing-source"]),label:"",shape:"rectangle",...a.startExit,width:0,height:0},d={id:f.generated(`${n.id}:routing-target`,["c4",n.id,"routing-target"]),label:"",shape:"rectangle",...a.endExit,width:0,height:0},c={...n,source:s.id,target:d.id,points:t([a.startExit,...a.seed.slice(1,-1),a.endExit])},h=(n.labelBlock?.width??0)/2+10,g=(n.labelBlock?.height??0)/2+8;p([...[...i.nodes,...x].map(e=>e.id===n.source||e.id===n.target?e:{...e,x:e.x-h,y:e.y-g,width:e.width+2*h,height:e.height+2*g}),s,d],[c],{...m,direction:l}),c.points.slice(1).some((e,t)=>b.some(i=>v(c.points[t],e,i)))&&(c.points=function(e,i,n,a){let r=(t,a)=>{let r=[...new Set(n.flatMap(e=>[e[t]-10,e[t]+e[a]+10]))],o=[Math.min(e[t],i[t],...r),Math.max(e[t],i[t],...r)],l=n=>Math.min(Math.abs(n-e[t]),Math.abs(n-i[t]));return[...new Set([...o,...r.sort((e,t)=>l(e)-l(t)||e-t).slice(0,14)])]},o=r("x","width"),l=r("y","height"),s=[];for(let t of o)s.push([e,{x:t,y:e.y},{x:t,y:i.y},i]);for(let t of l)s.push([e,{x:e.x,y:t},{x:i.x,y:t},i]);for(let t of o)for(let n of l)s.push([e,{x:e.x,y:n},{x:t,y:n},{x:t,y:i.y},i]),s.push([e,{x:t,y:e.y},{x:t,y:n},{x:i.x,y:n},i]);let d=e=>e.slice(1).reduce((t,i,n)=>t+Math.hypot(i.x-e[n].x,i.y-e[n].y),0),c=(e,t)=>n.every(i=>!a(e,t,i)),h=e=>e.map(t).sort((e,t)=>d(e)-d(t)||e.length-t.length).find(e=>e.slice(1).every((t,i)=>c(e[i],t))),g=h(s);if(g)return g;let p=l.filter(t=>c(e,{x:e.x,y:t})),m=l.filter(e=>c({x:i.x,y:e},i)),u=o.filter(t=>c(e,{x:t,y:e.y})),f=o.filter(e=>c({x:e,y:i.y},i)),y=[];for(let t of o)for(let n of p)for(let a of m)y.push([e,{x:e.x,y:n},{x:t,y:n},{x:t,y:a},{x:i.x,y:a},i]);for(let t of l)for(let n of u)for(let a of f)y.push([e,{x:n,y:e.y},{x:n,y:t},{x:a,y:t},{x:a,y:i.y},i]);return h(y)}(a.startExit,a.endExit,b,v)??c.points),n.points=t([a.start,...c.points,a.end]),n.labelPosition=q(n.points)}d(i,m,u);let W=[...i.nodes,...x],R={...i,nodes:W},{ctx:L}=a(W,y,m.direction,u,i.groups);for(let e of(L.finalLabelClearance=!0,y))if(e.label)for(let{start:t,end:i}of e.points.slice(1).map((t,i)=>({start:e.points[i],end:t})).sort((e,t)=>Math.abs(t.end.x-t.start.x)+Math.abs(t.end.y-t.start.y)-(Math.abs(e.end.x-e.start.x)+Math.abs(e.end.y-e.start.y)))){let a=n(e,t,i,L);if(a){e.labelPosition=a;break}}for(let t of(s(R,m,u),y)){let i=e.get(t.source),n=e.get(t.target);o(t,t.routeCertificate,{...i,label:"",shape:"rectangle"},{...n,label:"",shape:"rectangle"})}})(eo.boxes,{nodes:A,groups:el,edges:N},L,R,ek(e)),function(e,t,i){let{edges:n}=e,a=eX(e.nodes,e.groups),r=n.flatMap(e=>eA(e,t)),o=[],l=new Map(i.relationships.map(e=>[e.id,e.style])),s=n.flatMap(e=>e.points.slice(1).map((t,i)=>({edge:e,start:e.points[i],end:t})));for(let{edge:e,rect:t}of n.map((e,t)=>({edge:e,index:t,rect:eB(e)})).filter(e=>e.rect).sort((e,t)=>t.rect.width*t.rect.height-e.rect.width*e.rect.height||e.index-t.index)){let i=l.get(e.id),n=e=>Number.isFinite(Number(e))?Number(e):0,d=n(i?.offsetX),c=n(i?.offsetY),h=e=>({x:e.x+d,y:e.y+c}),g=h(e.labelPosition),p=[g],m=t.width,u=t.height,f=t=>{let i={x:t.x-m/2,y:t.y-u/2,width:m,height:u},n=eP(i,3);return[r.reduce((e,t)=>e+eT(n,t),0),a.reduce((e,t)=>e+eT(n,t),0),o.reduce((e,t)=>e+eT(eP(i,4),t),0),s.reduce((t,n)=>t+(n.edge!==e&&ej(n.start,n.end,eP(i,2))?1:0),0)]},y=g,x=f(g);if(x.every(e=>0===e)){e.labelPosition=g,o.push(eB(e));continue}for(let{start:t,end:i}of s.filter(t=>t.edge===e).sort((e,t)=>Math.hypot(t.end.x-t.start.x,t.end.y-t.start.y)-Math.hypot(e.end.x-e.start.x,e.end.y-e.start.y))){let e=Math.hypot(i.x-t.x,i.y-t.y);if(e<.01)continue;let n=-(i.y-t.y)/e,a=(i.x-t.x)/e,r=Math.abs(n)*m/2+Math.abs(a)*u/2;for(let e of[.5,.25,.75,.1,.9])for(let o of[0,r+6,-r-6,r+20,-r-20])p.push(h({x:t.x+(i.x-t.x)*e+n*o,y:t.y+(i.y-t.y)*e+a*o}))}for(let e of(p.sort((e,t)=>Math.hypot(e.x-g.x,e.y-g.y)-Math.hypot(t.x-g.x,t.y-g.y)),p)){let t=f(e),i=t.findIndex((e,t)=>e!==x[t]);if(i>=0&&t[i]<x[i]&&(y=e,x=t),t.every(e=>0===e))break}e.labelPosition=y,o.push(eB(e))}}({nodes:A,groups:el,edges:N},R.lineWidth,e);let es=N.flatMap(e=>{let t=eB(e);return t?[{...t,id:e.id,label:"",shape:"rectangle"}]:[]}),ed=N.flatMap(e=>eA(e,R.lineWidth).map(t=>({...t,id:e.id,label:"",shape:"rectangle"})));i([...A,...es,...ed],N,el,Math.max(W.marginX,W.marginY)+(H?.height??0));let ec=[...A,...X.values(),...es,...ed],eh=Math.max(eo.width,...ec.map(e=>e.x+e.width+W.marginX),...N.flatMap(e=>[...e.points.map(e=>e.x+W.marginX),(e.labelPosition?.x??0)+(e.labelBlock?.width??0)/2+W.marginX]),H?H.width+2*W.marginX:0),eg=Math.max(eo.height,...ec.map(e=>e.y+e.height+W.marginY),...N.flatMap(e=>[...e.points.map(e=>e.y+W.marginY),(e.labelPosition?.y??0)+(e.labelBlock?.height??0)/2+W.marginY])),ep=eC(e,W).map(e=>({...e,block:ea(e.label,{display:"literal",fontSize:R.edgeLabelFontSize,fontWeight:R.edgeLabelFontWeight,letterSpacing:R.edgeLetterSpacing,transform:R.edgeTextTransform,...void 0===W.maxWidth?{}:{maxWidth:Math.max(24,W.maxWidth-2*W.marginX-64)}})})),eu=ea("Legend",{display:"literal",fontSize:u?.text?.fontSize??13,fontWeight:u?.text?.fontWeight??600,letterSpacing:u?.text?.letterSpacing??0,transform:u?.text?.textTransform,...void 0===W.maxWidth?{}:{maxWidth:Math.max(24,W.maxWidth-2*W.marginX-24)}}),ef=ep.length?{x:W.marginX,y:eg+12,width:Math.max(eu.width+24,...ep.map(e=>e.block.width+64)),height:eu.height+20+ep.reduce((e,t)=>e+t.block.height+10,0),heading:eu,entries:ep}:void 0;ef&&(eh=Math.max(eh,ef.x+ef.width+W.marginX),eg=ef.y+ef.height+W.marginY);let eb=[...eo.diagnostics,...function(e,t,i,n){let a=[],{edges:r,nodes:o,groups:l}=t,s=eX(o,l),d=r.map(e=>({edge:e,box:eB(e)})).filter(e=>e.box),c=t=>e.relationships.find(e=>e.id===t.id)?.statementId;for(let{edge:e,box:t}of d)(s.some(e=>eT(t,e)>.01)||d.some(i=>i.edge!==e&&eT(t,i.box)>.01)||r.some(i=>i!==e&&i.points.slice(1).some((e,n)=>ej(i.points[n],e,t))))&&a.push({code:"C4_LABEL_COLLISION",severity:"warning",statementId:c(e),message:`Relationship ${e.id} has a label halo overlapping another label, card, boundary header/frame or relationship route; all authored text is retained.`});let h=eO(l).map(e=>({...e,height:e.headerHeight??0})),g=r.flatMap(e=>eA(e,i).map(t=>({edge:e,head:t})));for(let e of r){let t=g.filter(t=>t.edge===e).map(e=>e.head);((e.hasArrowEnd||e.hasArrowStart)&&!t.length||t.some(e=>d.some(t=>eT(e,t.box)>.01)||[...o,...h].some(t=>t.id!==e.endpoint&&eT(e,t)>.01)||g.some(t=>t.head!==e&&function(e,t){if(.01>=eT(e,t))return!1;for(let i of[e.polygon,t.polygon])for(let[n,a]of i.entries()){let r=i[(n+1)%i.length],o=-(r.y-a.y),l=r.x-a.x,s=Math.hypot(o,l);if(s<.001)continue;let d=e=>e.polygon.map(e=>(e.x*o+e.y*l)/s),c=d(e),h=d(t);if(Math.max(...c)+e.strokePadding<=Math.min(...h)-t.strokePadding+.01||Math.max(...h)+t.strokePadding<=Math.min(...c)-e.strokePadding+.01)return!1}return!0}(e,t.head))||n&&(e.x<-.01||e.y<-.01||e.x+e.width>n.width+.01||e.y+e.height>n.height+.01)))&&a.push({code:"C4_ARROW_OCCLUDED",severity:"warning",statementId:c(e),message:`Relationship ${e.id} has an arrowhead overlapping a label, card, boundary header or another arrowhead, exceeds the final canvas, or lacks a nonzero terminal segment.`})}return a}(e,{nodes:A,groups:el,edges:N},R.lineWidth,{width:eh,height:eg})];return void 0!==W.maxWidth&&eh>W.maxWidth+.01&&eb.push({code:"C4_WIDTH_EXCEEDED",severity:"warning",message:`The requested C4 width ${W.maxWidth}px cannot contain the ${Math.ceil(eh)}px artifact without shrinking or clipping content; minimum card widths, nesting, explicit direction constraints and authored offsets retain precedence.`}),{width:eh,height:eg,...ef?{legend:ef}:{},nodes:A,groups:el,edges:N,...H?{title:K(H,eh,W.marginY)}:{},body:e,config:W,diagnostics:eb,identities:ek(e),textContext:{node:R.nodeTextTransform,edge:R.edgeTextTransform,group:R.groupTextTransform,legendHeading:u?.text?.textTransform,title:U}}}(m.model,e.renderOptions,e.styleFace,m.c4,m.themeVariables))},projectPositioned:$(function({positioned:e,options:t}){let i=e.body,n=e.textContext,a=(e,t,i,n)=>{if(!i||i.prepared.source!==t||"literal"!==i.prepared.display||i.prepared.transform!==n)throw Error("C4 "+e+" changed its retained prepared text")},r=new Map(i.elements.map(e=>[e.id,e])),o=new Map(i.relationships.map(e=>[e.id,e])),l=new Map,s=new Map,d=(e,t)=>{for(let i of e){if(l.has(i.id))throw Error(`C4 boundary "${i.id}" has a repeated positioned frame`);l.set(i.id,i),s.set(i.id,t),d(i.children,i.id)}};d(e.groups);let c=new Set(e.nodes.map(e=>e.id));if(c.size!==e.nodes.length||c.size!==r.size||i.elements.some(e=>!c.has(e.id)))throw Error("C4 positioned cards do not match the authored identities");if(l.size!==i.boundaries.length)throw Error("C4 positioned frames do not match the authored boundaries");let h=new Set(e.edges.map(e=>e.id));if(h.size!==e.edges.length||h.size!==o.size)throw Error("C4 positioned relationships do not match the authored identities");for(let t of e.nodes){let e=eF(r.get(t.id));if(t.label!==e)throw Error("C4 card "+t.id+" changed its authored text");a(t.id,e,t.labelBlock,n.node)}for(let t of e.edges){let e=void 0===t.id?void 0:o.get(t.id);if(!e)throw Error("C4 positioned relationship has no authored interaction identity");let r=e$(i,e),l="dashed"===e.style.lineStyle||"dotted"===e.style.lineStyle?"dotted":"solid";if(t.source!==e.source||t.target!==e.target||t.label!==r||t.style!==l||t.hasArrowStart!==e.bidirectional||!t.hasArrowEnd||(t.startMarker??"arrow")!=="arrow"||(t.endMarker??"arrow")!=="arrow")throw Error("C4 relationship "+t.id+" changed its authored endpoints, label, shaft or markers");a(t.id,r,t.labelBlock,n.edge)}let g=[];for(let t of i.boundaries){let i=l.get(t.id);if(!i||s.get(t.id)!==t.parentId)throw Error(`C4 boundary "${t.id}" changed its authored parent`);let r=eS(t);if(i.label!==r)throw Error("C4 boundary "+t.id+" changed its authored text");a(t.id,r,i.labelBlock,n.group);let o="left"===t.alignment?"start":"right"===t.alignment?"end":"middle",d="left"===t.alignment?i.x+e.config.padding:"right"===t.alignment?i.x+i.width-e.config.padding:i.x+i.width/2,c=i.headerHeight??36;g.push({id:`boundary-label:${t.id}`,text:i.labelBlock?.text??i.label,bounds:F(i.labelBlock,d,i.y+c/2,o),container:k({...i,height:c})})}if(void 0!==n.title!=(void 0!==e.title))throw Error("C4 positioned title does not match the authored title");if(e.title){let t=e.title;a("title",n.title,t.block,n.group),g.push({id:"title",text:t.text,bounds:F(t.block,t.x,t.y),container:k(v(e))})}let p=eC(i,e.config);if(p.length>0!=(void 0!==e.legend))throw Error("C4 positioned legend does not match the authored legend");if(e.legend){let t=e.legend;if(t.entries.length!==p.length||t.entries.some((e,t)=>e.id!==p[t].id))throw Error("C4 positioned legend entries do not match the authored legend");a("legend heading","Legend",t.heading,n.legendHeading);let i=k(t);g.push({id:"legend:heading",text:t.heading.text,bounds:F(t.heading,t.x+12,t.y+8+t.heading.height/2,"start"),container:i});let r=t.y+20+t.heading.height;for(let[e,o]of t.entries.entries())a(o.id,p[e].label,o.block,n.edge),g.push({id:`legend:entry:${o.id}`,text:o.block.text,bounds:F(o.block,t.x+38,r+o.block.height/2,"start"),container:i}),r+=o.block.height+10}return{version:1,nodes:e.nodes.map(e=>{let t=r.get(e.id),i=em(t),n=e.y+e.height/2+("person"===i?19:4*("database"===i));return{id:t.id,x:E(e.x),y:E(e.y),w:E(e.width),h:E(e.height),shape:i,label:t.label,role:"box",...S(e.labelBlock,e.x+e.width/2,n,e),...void 0!==t.parentId?{parentId:t.parentId}:{}}}),edges:e.edges.map(e=>{let i=void 0===e.id?void 0:o.get(e.id);if(!i)throw Error("C4 positioned relationship has no authored interaction identity");return{id:i.id,from:e.source,to:e.target,path:e.points.map(e=>[E(e.x),E(e.y)]),...void 0!==e.label&&e.labelPosition?{label:{x:E(e.labelPosition.x),y:E(e.labelPosition.y),text:e.label,bounds:F(e.labelBlock,e.labelPosition.x,e.labelPosition.y)}}:{},...t.debug&&e.routeCertificate?{route:e.routeCertificate}:{}}}),groups:i.boundaries.map(e=>{let t=l.get(e.id);if(!t)throw Error(`C4 boundary "${e.id}" has no positioned frame`);return{id:e.id,label:e.label,x:E(t.x),y:E(t.y),w:E(t.width),h:E(t.height),members:i.elements.filter(t=>t.parentId===e.id).map(e=>e.id),...void 0!==e.parentId?{parentId:e.parentId}:{}}}),bounds:{w:E(e.width),h:E(e.height)},labels:g}}),lowerScene:M(to)});export{tl as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as e,f as t,s as r,t as n,u as i}from"./chunk-
|
|
1
|
+
import{e as e,f as t,s as r,t as n,u as i}from"./chunk-ILCWDEZN.js";import{Ab as o,Bb as a,Cb as s,Eb as d,Fa as c,Fb as l,Ga as u,Gb as m,Ha as p,Hb as f,Ia as g,Ib as h,Ja as y,N as b,Q as E,V as v,Xa as k,Y as $,Z as x,Za as S,_a as N,ab as w,b as C,ca as z,d as O,db as _,e as T,eb as j,f as M,fb as I,g as D,ga as A,ha as U,ia as P,ja as B,l as R,n as L,ob as F,qb as W,rb as q,s as Y,sb as G,ub as V,vb as K,wb as Z,xb as H}from"./chunk-SZAI2WB4.js";function J(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\\(?:\r\n|[\n\r\f])/g,"").replace(/\\([0-9a-fA-F]{1,6})\s?/g,(e,t)=>{let r=Number.parseInt(t,16);return Number.isFinite(r)?String.fromCodePoint(r):""}).replace(/\\([^\n\r\f])/g,"$1")}var Q=/\s([^\s=<>]+)\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/g,X=/<(?:[^\s<>/:]+:)?(?:animate(?:Motion|Transform)?|set)\b/i,ee=/^on[a-z]/,et=/[(:@\\&]/,er=/^(?:javascript|vbscript|data|file):/,en=/(?:javascript|vbscript|data|file)\s*:/i,ei=/(?:expression|behavior)\s*\(/i,eo=/(?:expression|behavior)\s*\(|-moz-binding\s*:/i,ea=new Set(["amp","lt","gt","quot","apos"]);function es(e){return" "===e||" "===e||e===`
|
|
2
2
|
`||"\r"===e}function ed(e,t){let r=e.charCodeAt(t),n=32|r;if(!(n>=97&&n<=122||95===r))return -1;let i=t+1;for(;j(e[i]);)i++;return i}var ec="http://www.w3.org/XML/1998/namespace";function el(e){return 9===e||10===e||13===e||e>=32&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111}function eu(e){for(let t=e.indexOf("&");t>=0;t=e.indexOf("&",t+1)){let r=e.indexOf(";",t+1);if(r<0)return!1;let n=e.slice(t+1,r);if(n.startsWith("#x")||n.startsWith("#X")){if(!/^[0-9a-f]+$/i.test(n.slice(2))||!el(Number.parseInt(n.slice(2),16)))return!1}else if(n.startsWith("#")){if(!/^[0-9]+$/.test(n.slice(1))||!el(Number.parseInt(n.slice(1),10)))return!1}else if(!ea.has(n))return!1;t=r}return!0}function em(e,t){if(/[\0-\x08\x0b\x0c\x0e-\x1f\ud800-\udfff\ufffe\uffff]/u.test(e))return!1;let r=[],n=!1,i=!1,o=0;for(;o<e.length;){let a;if("<"!==e[o]){let t=e.indexOf("<",o),n=t<0?e.length:t,i=e.slice(o,n);if(0===r.length&&""!==i.trim()||i.includes("]]>")||!eu(i))return!1;o=n;continue}if(e.startsWith("\x3c!--",o)){if(0===r.length)return!1;let t=e.indexOf("--\x3e",o+4),n=t<0?"":e.slice(o+4,t);if(t<0||n.includes("--")||n.endsWith("-"))return!1;o=t+3;continue}if(e.startsWith("<![CDATA[",o)||e.startsWith("<!",o)||e.startsWith("<?",o))return!1;if(e.startsWith("</",o)){let t=ed(e,o+2);if(t<0)return!1;let n=e.slice(o+2,t);if(n.includes(":"))return!1;for(;es(e[t]);)t++;if(">"!==e[t]||r.pop()?.name!==n)return!1;if(o=t+1,0===r.length){if("svg"!==n||i)return!1;i=!0}continue}let s=ed(e,o+1);if(s<0||i)return!1;let d=e.slice(o+1,s);if(d.includes(":"))return!1;if(0===r.length){if(n||"svg"!==d)return!1;n=!0}let c=s,l=new Set,u=[],m=!1;for(;;){let r=es(e[c]);for(;es(e[c]);)c++;if(">"===e[c]){c++;break}if("/"===e[c]&&">"===e[c+1]){m=!0,c+=2;break}if(!r)return!1;let n=ed(e,c);if(n<0)return!1;let i=e.slice(c,n);if(l.has(i))return!1;let o=i.includes(":"),a=o?function(e){let t=e.indexOf(":");if(!(t<=0||t===e.length-1||e.indexOf(":",t+1)>=0))return{prefix:e.slice(0,t),local:e.slice(t+1)}}(i):void 0;if(o&&!a)return!1;for(l.add(i),c=n;es(e[c]);)c++;if("="!==e[c])return!1;for(c++;es(e[c]);)c++;let s=e[c];if('"'!==s&&"'"!==s)return!1;let d=++c;if((c=e.indexOf(s,d))<0)return!1;let p=e.slice(d,c);if(p.includes("<")||!eu(p))return!1;(a||"xmlns"===i)&&u.push({name:i,...a,value:ep(p)}),t?.(i,p),c++}let p=r.at(-1)?.namespaces??new Map([["xml",ec]]),f;for(let e of u){let t="xmlns"===e.name,r="xmlns"===e.prefix;if(!t&&!r)continue;let n=t?"":e.local,i=e.value;if("xmlns"===n||"http://www.w3.org/2000/xmlns/"===i||"xml"===n&&i!==ec||"xml"!==n&&i===ec||""!==n&&""===i)return!1;f||(p=f=new Map(p)),f.set(n,i)}if("http://www.w3.org/2000/svg"!==p.get("")||r.length>0&&"svg"===d)return!1;for(let e of u){if("xmlns"===e.name||"xmlns"===e.prefix)continue;let t=p.get(e.prefix);if(void 0===t)return!1;let r=`${t}\0${e.local}`;if(a||(a=new Set),a.has(r))return!1;a.add(r)}if(o=c,m){if(0===r.length)return!1}else r.push({name:d,namespaces:p})}return n&&i&&0===r.length}function ep(e){if(!e.includes("&"))return e;let t=e;for(let e=0;e<3;e++){let e=t.replace(/&#x([0-9a-f]+);?/gi,(e,t)=>{let r=Number.parseInt(t,16);return Number.isFinite(r)&&r<=1114111?String.fromCodePoint(r):""}).replace(/&#([0-9]+);?/g,(e,t)=>{let r=Number.parseInt(t,10);return Number.isFinite(r)&&r<=1114111?String.fromCodePoint(r):""}).replace(/:?/gi,":").replace(//?/gi,"/").replace(/&tab;?/gi," ").replace(/&newline;?/gi,`
|
|
3
3
|
`).replace(/"?/gi,'"').replace(/'?/gi,"'").replace(/<?/gi,"<").replace(/>?/gi,">").replace(/&?/gi,"&");if(e===t)break;t=e}return t}function ef(e){return ep(e).replace(/[\u0000-\u0020\u007f-\u009f]+/g,"").toLowerCase()}function eg(e){let t=ep(e);if(/[\u0000-\u001f\u007f-\u009f]/.test(t))return!1;let r=t.replace(/ +/g,"").toLowerCase().trim();return!!/^(?:https?:|mailto:)/.test(r)||!/^[a-z][a-z0-9+.-]*:/.test(r)&&r.length>0}function eh(e){let t=J(ep(e)),r=[];for(let e of(/@import\b/i.test(t)&&r.push("@import"),t.matchAll(/url\s*\(\s*(["']?)([\s\S]*?)\1\s*\)/gi))){let t=ef(e[2]);""===t||t.startsWith("#")||r.push(`url(${e[2].trim()})`)}for(let e of t.matchAll(/(?:-webkit-)?(?:image-set|cross-fade)\s*\(/gi))r.push(`${e[0].slice(0,-1).trim()}()`);return r}function ey(e){return!!(eo.test(e)||en.test(e))}var eb=new Set(["clip-path","cursor","fill","filter","marker-end","marker-mid","marker-start","mask","stroke","style"]);function eE(e,t){if(void 0!==e&&""!==e)return"string"!=typeof e?"Mermaid themeCSS must be a string":`Raw Mermaid themeCSS is not allowed in ${t} security mode because selectors can escape an imported SVG; use a declarative StyleSpec`}function ev(e,t,r,n){let i=e.slice(e.lastIndexOf(":")+1).toLowerCase();if(ee.test(i)&&(r.push("inline-event-handler"),n.push("inline-event-handler")),"xml:base"===e.toLowerCase()&&r.push(`xml:base=${t}`),"href"===i||"src"===i||"data"===i){let i=ef(t);""===i||i.startsWith("#")||r.push(i.startsWith("javascript:")?"javascript-url":t),er.test(i)&&n.push(`${e}=${t}`)}if(eb.has(i)||"values"===i||"from"===i||"to"===i){if(!et.test(t))return;let i=J(ep(t));(eh(i).length>0||en.test(i)||ei.test(i))&&r.push(`${e}=${t}`),ey(i)&&n.push(`${e}=${t}`)}}function ek(e,t,r){for(let n of e.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi))ey(J(ep(n[1])))&&r.push("active-css"),t.push(...eh(n[1]));for(let n of["script","foreignObject","image","object","embed","iframe"])RegExp(`<(?:[^\\s<>/:]+:)?${n}\\b`,"i").test(e)&&(t.push(`<${n}>`),"image"!==n&&r.push(`<${n}>`));return X.test(e)&&(t.push("<animation>"),r.push("<animation>")),Object.freeze({active:Object.freeze(r),refs:Object.freeze(t)})}function e$(e){let{refs:t}=_("security",e,()=>(function(e){let t=e.replace(/<!--[\s\S]*?-->/g,""),r=[],n=[];for(let e of function(e){let t=[];for(let r=e.indexOf("<");r>=0;r=e.indexOf("<",r+1)){let n,i=e[r+1];if(i&&"/"!==i&&"!"!==i&&"?"!==i&&/[^\s<>]/.test(i))for(let i=r+1;i<e.length;i++){let o=e[i];if(n)o===n&&(n=void 0);else if('"'===o||"'"===o)n=o;else if(">"===o){t.push(e.slice(r,i+1)),r=i;break}}}return t}(t))for(let t of e.matchAll(RegExp(Q.source,"g")))ev(t[1],function(e){let t=e[0];return('"'===t||"'"===t)&&e[e.length-1]===t?e.slice(1,-1):e}(t[2]),r,n);return ek(t,r,n)})(e));return{ok:0===t.length,refs:[...t]}}function ex(e,t="default"){let r=_("final-security",e,()=>{let t=[],r=[],n=!1,i;if(!em(e,(e,o)=>{if(!n)try{ev(e,o,t,r)}catch(e){n=!0,i=e}}))return!1;if(n)throw i;return ek(e.replace(/<!--[\s\S]*?-->/g,""),t,r)});if(!r)throw Error("OutputSecurityPolicy rejected an invalid SVG document envelope");let{active:n,refs:i}=r;if(n.length>0)throw Error(`OutputSecurityPolicy rejected active content: ${n.join(", ")}`);if("strict"===t&&i.length)throw Error(`OutputSecurityPolicy strict verification failed: ${i.join(", ")}`);return{svg:e,diagnostics:"strict"===t?[]:i.map(e=>({code:"EXTERNAL_REFERENCE",reference:e}))}}var eS=["document","text","shape","container","connector","marker","data-mark"];Object.freeze(eS.map(e=>Object.freeze({primitive:e,operation:"document"===e?"serialize":"render"})));var eN=["measure","layout","bounds","hit-test","render","accessibility","terminal-project","serialize"],ew=["geometry","paint","stroke","transform","identity","relation","labels","markers","resources","interaction","topology","subpaths","closedness","bend-radius","endpoints","direction","hit-geometry","stroke-opacity","stroke-cap","stroke-join","stroke-miter","dash-array","dash-offset","dash-restart","path-length","paint-order","compositing","non-scaling-stroke","marker-orientation","marker-overflow"],eC=Object.freeze([{primitive:"document",feature:"identity",operation:"serialize"},{primitive:"document",feature:"resources",operation:"serialize"},{primitive:"document",feature:"interaction",operation:"accessibility"},{primitive:"text",feature:"geometry",operation:"render"},{primitive:"text",feature:"paint",operation:"render"},{primitive:"text",feature:"labels",operation:"accessibility"},{primitive:"text",feature:"identity",operation:"serialize"},{primitive:"shape",feature:"geometry",operation:"render"},{primitive:"shape",feature:"paint",operation:"render"},{primitive:"shape",feature:"identity",operation:"serialize"},{primitive:"container",feature:"geometry",operation:"render"},{primitive:"container",feature:"paint",operation:"render"},{primitive:"container",feature:"identity",operation:"serialize"},{primitive:"connector",feature:"geometry",operation:"render"},{primitive:"connector",feature:"stroke",operation:"render"},{primitive:"connector",feature:"transform",operation:"render"},{primitive:"connector",feature:"topology",operation:"render"},{primitive:"connector",feature:"subpaths",operation:"render"},{primitive:"connector",feature:"closedness",operation:"render"},{primitive:"connector",feature:"bend-radius",operation:"render"},{primitive:"connector",feature:"stroke-opacity",operation:"render"},{primitive:"connector",feature:"stroke-cap",operation:"render"},{primitive:"connector",feature:"stroke-join",operation:"render"},{primitive:"connector",feature:"stroke-miter",operation:"render"},{primitive:"connector",feature:"dash-array",operation:"render"},{primitive:"connector",feature:"dash-offset",operation:"render"},{primitive:"connector",feature:"dash-restart",operation:"render"},{primitive:"connector",feature:"path-length",operation:"render"},{primitive:"connector",feature:"paint-order",operation:"render"},{primitive:"connector",feature:"compositing",operation:"render"},{primitive:"connector",feature:"non-scaling-stroke",operation:"render"},{primitive:"connector",feature:"marker-orientation",operation:"render"},{primitive:"connector",feature:"marker-overflow",operation:"render"},{primitive:"connector",feature:"endpoints",operation:"serialize"},{primitive:"connector",feature:"direction",operation:"serialize"},{primitive:"connector",feature:"labels",operation:"render"},{primitive:"connector",feature:"labels",operation:"accessibility"},{primitive:"connector",feature:"markers",operation:"render"},{primitive:"connector",feature:"relation",operation:"accessibility"},{primitive:"connector",feature:"interaction",operation:"hit-test"},{primitive:"connector",feature:"hit-geometry",operation:"hit-test"},{primitive:"connector",feature:"identity",operation:"serialize"},{primitive:"marker",feature:"geometry",operation:"render"},{primitive:"marker",feature:"paint",operation:"render"},{primitive:"marker",feature:"identity",operation:"serialize"},{primitive:"data-mark",feature:"geometry",operation:"render"},{primitive:"data-mark",feature:"paint",operation:"render"},{primitive:"data-mark",feature:"identity",operation:"serialize"}].map(e=>Object.freeze(e))),ez=["native","emulated","projected","lossy","unsupported"];function eO(e){switch(e.kind){case"text":return["text"];case"shape":return e.channels?.value===void 0?["shape"]:["shape","data-mark"];case"group":return["container"];case"connector":return["connector"];case"document":return e.markerResources?.length?["document","marker"]:["document"]}}function e_(e,t,r="rough"){let n="crisp"===t?"native":"emulated",i="crisp"===t?"native":"projected",o="src/__tests__/backend-capability-conformance.test.ts",a=e=>"crisp"===t?{realization:"native"}:"geometry"===e||"topology"===e?{realization:"lossy",diagnostic:"The exact authored path remains as an invisible semantic carrier, but arbitrary curves are flattened to typed routed contours for the visible sketch."}:"closedness"===e?{realization:"lossy",diagnostic:"Sketch shafts are rebuilt from routed geometry and do not preserve explicit closed-subpath semantics."}:"bend-radius"===e?{realization:"lossy",diagnostic:"The authored rounded carrier remains exact, but the visible sketch follows its routed polyline and cannot preserve the continuous bend radius."}:"dash-restart"===e?{realization:"lossy",diagnostic:"A rough stroke may contain multiple generated stroke subpaths, so SVG dash restart boundaries can differ."}:"path-length"===e?{realization:"lossy",diagnostic:"One pathLength value spans generated stroke subpaths, so a sketch cannot retain one authored path calibration exactly."}:"hybrid"===r&&("stroke-cap"===e||"stroke-join"===e||"stroke-miter"===e||"non-scaling-stroke"===e)?{realization:"lossy",diagnostic:`Freehand ribbon geometry cannot preserve authored ${e} semantics; dashed Hybrid connectors fall back to the faithful rough projection.`}:"marker-orientation"===e||"marker-overflow"===e?{realization:"projected",diagnostic:"Marker geometry, orientation, and overflow remain in the typed marker projection instead of being sketched."}:{realization:"emulated"},s=[{target:e,primitive:"document",feature:"identity",operation:"serialize",realization:"native",evidence:o},{target:e,primitive:"document",feature:"resources",operation:"serialize",realization:"native",evidence:o},{target:e,primitive:"document",feature:"interaction",operation:"accessibility",realization:"native",evidence:o},{target:e,primitive:"text",feature:"geometry",operation:"render",realization:"native",evidence:o},{target:e,primitive:"text",feature:"paint",operation:"render",realization:"native",evidence:o},{target:e,primitive:"text",feature:"labels",operation:"accessibility",realization:"native",evidence:o},{target:e,primitive:"text",feature:"identity",operation:"serialize",realization:"native",evidence:o},{target:e,primitive:"shape",feature:"geometry",operation:"render",realization:n,evidence:o},{target:e,primitive:"shape",feature:"paint",operation:"render",realization:n,evidence:o},{target:e,primitive:"shape",feature:"identity",operation:"serialize",realization:"native",evidence:o},{target:e,primitive:"container",feature:"geometry",operation:"render",realization:"native",evidence:o},{target:e,primitive:"container",feature:"paint",operation:"render",realization:"native",evidence:o},{target:e,primitive:"container",feature:"identity",operation:"serialize",realization:"native",evidence:o},{target:e,primitive:"connector",feature:"geometry",operation:"render",...a("geometry"),evidence:o},{target:e,primitive:"connector",feature:"stroke",operation:"render",realization:n,evidence:o},...["transform","topology","subpaths","closedness","bend-radius","stroke-opacity","stroke-cap","stroke-join","stroke-miter","dash-array","dash-offset","dash-restart","path-length","paint-order","compositing","non-scaling-stroke","marker-orientation","marker-overflow"].map(t=>({target:e,primitive:"connector",feature:t,operation:"render",...a(t),evidence:o})),{target:e,primitive:"connector",feature:"relation",operation:"accessibility",realization:"native",evidence:o},{target:e,primitive:"connector",feature:"endpoints",operation:"serialize",realization:"native",evidence:o},{target:e,primitive:"connector",feature:"direction",operation:"serialize",realization:"native",evidence:o},{target:e,primitive:"connector",feature:"labels",operation:"render",realization:"native",evidence:o},{target:e,primitive:"connector",feature:"labels",operation:"accessibility",realization:"native",evidence:o},{target:e,primitive:"connector",feature:"markers",operation:"render",realization:i,evidence:o},{target:e,primitive:"connector",feature:"interaction",operation:"hit-test",realization:"native",evidence:o},{target:e,primitive:"connector",feature:"hit-geometry",operation:"hit-test",realization:"native",evidence:o},{target:e,primitive:"connector",feature:"identity",operation:"serialize",realization:"native",evidence:o},{target:e,primitive:"marker",feature:"geometry",operation:"render",realization:i,evidence:o},{target:e,primitive:"marker",feature:"paint",operation:"render",realization:i,evidence:o},{target:e,primitive:"marker",feature:"identity",operation:"serialize",realization:"native",evidence:o},{target:e,primitive:"data-mark",feature:"geometry",operation:"render",realization:n,evidence:o},{target:e,primitive:"data-mark",feature:"paint",operation:"render",realization:n,evidence:o},{target:e,primitive:"data-mark",feature:"identity",operation:"serialize",realization:"native",evidence:o}],d=ej(s);if(!d.valid)throw Error(`Invalid graphical backend capability contract: ${d.diagnostics.join("; ")}`);return Object.freeze(s.map(e=>Object.freeze({...e})))}function eT(e){return[e.target,e.primitive,e.feature,e.operation].join("\0")}function ej(e){let t=[],r=new Set;for(let n=0;n<e.length;n++){let i=e[n],o=eT(i);r.has(o)&&t.push(`claim[${n}]: duplicate target/primitive/feature/operation`),r.add(o),""===i.target.trim()&&t.push(`claim[${n}]: target must not be empty`),""===i.primitive.trim()&&t.push(`claim[${n}]: primitive must not be empty`),""===i.feature.trim()&&t.push(`claim[${n}]: feature must not be empty`),""===i.operation.trim()&&t.push(`claim[${n}]: operation must not be empty`),ez.includes(i.realization)||t.push(`claim[${n}]: invalid realization ${String(i.realization)}`),"lossy"!==i.realization&&"unsupported"!==i.realization||i.diagnostic?.trim()||t.push(`claim[${n}]: ${i.realization} realization requires a diagnostic`)}return{valid:0===t.length,diagnostics:t}}function eM(e,t,r){let n=r.x-t.x,i=r.y-t.y,o=n*n+i*i;if(0===o)return Math.hypot(e.x-t.x,e.y-t.y);let a=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*i)/o));return Math.hypot(e.x-(t.x+a*n),e.y-(t.y+a*i))}function eI(e,t,r=0){return function(e,t,r,n){if("none"===e.hit.pointerEvents)return!1;let i=y(p(n,u(e.transform)));if(!i)return!1;if(e.stroke.nonScaling){let i=function(e,t,r){if("none"===e.hit.pointerEvents)return;let n=B(e.hit.geometry,e.hit.closed);if(0===n.length)return;let i=p(r,u(e.transform)),o=1/0;for(let e of n)o=Math.min(o,eM(t,g(e.start,i),g(e.end,i)));return o}(e,t,n);return void 0!==i&&i<=e.hit.strokeWidth/2+Math.max(0,r)}let o=g(t,i),a=(Math.hypot(i[0]+i[3],i[1]-i[2])+Math.hypot(i[0]-i[3],i[1]+i[2]))/2,s=e.hit.strokeWidth/2+(r>0?r*a:0);return B(e.hit.geometry,e.hit.closed).some(e=>eM(o,e.start,e.end)<=s)}(e,t,r,c)}function eD(e,t){if(0!==e.length&&e.length>t)return t+1;if(!/[^\x00-\x7f]/.test(e))return e.length;let r=0;for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);if(i<=127)r+=1;else if(i<=2047)r+=2;else if(i>=55296&&i<=56319&&n+1<e.length){let t=e.charCodeAt(n+1);t>=56320&&t<=57343?(r+=4,n++):r+=3}else r+=3;if(r>t)return t+1}return r}Object.freeze(["importance","value","category","status","progress","route","emphasis"]);var eA=/^[A-Za-z_][A-Za-z0-9_.:-]*$/,eU=Object.freeze({maxIdLength:256,maxCoordinate:1e6,maxStopsPerGradient:256,maxResources:1e4,maxAggregateStops:2e4,maxSerializationBytes:8e6});function eP(e,t){if(!Number.isFinite(e))throw Error(`Linear gradient ${t} must be finite`);if(Math.abs(e)>eU.maxCoordinate)throw Error(`Linear gradient ${t} must not exceed ${eU.maxCoordinate}`);return e}function eB(t){if(!eA.test(t.id))throw Error(`Linear gradient id ${JSON.stringify(t.id)} must use the safe SVG id grammar`);if(t.id.length>eU.maxIdLength)throw Error(`Linear gradient id must contain at most ${eU.maxIdLength} characters`);if("userSpaceOnUse"!==t.units&&"objectBoundingBox"!==t.units)throw Error(`Linear gradient "${t.id}" units must be userSpaceOnUse or objectBoundingBox`);if(eP(t.x1,"x1"),eP(t.y1,"y1"),eP(t.x2,"x2"),eP(t.y2,"y2"),t.stops.length<2)throw Error(`Linear gradient "${t.id}" must declare at least two stops`);if(t.stops.length>eU.maxStopsPerGradient)throw Error(`Linear gradient "${t.id}" must declare at most ${eU.maxStopsPerGradient} stops`);let r=-1;for(let[n,i]of t.stops.entries()){if(eP(i.offset,`stops[${n}].offset`),i.offset<0||i.offset>1)throw Error(`Linear gradient "${t.id}" stop offsets must be in [0,1]`);if(i.offset<r)throw Error(`Linear gradient "${t.id}" stop offsets must be non-decreasing`);if(r=i.offset,void 0===e(i.color)||/^url\s*\(/i.test(i.color))throw Error(`Linear gradient "${t.id}" stop ${n} must use a safe non-fetching CSS paint`);if(void 0!==i.opacity&&(!Number.isFinite(i.opacity)||i.opacity<0||i.opacity>1))throw Error(`Linear gradient "${t.id}" stop opacity must be in [0,1]`)}}function eR(e,t={}){eB(e);let r=" ".repeat(t.indent??2),n=`${r} `,i=[`id="${b(e.id)}"`,`gradientUnits="${e.units}"`,`x1="${eP(e.x1,"x1")}"`,`y1="${eP(e.y1,"y1")}"`,`x2="${eP(e.x2,"x2")}"`,`y2="${eP(e.y2,"y2")}"`];return[`${r}<linearGradient ${i.join(" ")}>`,...e.stops.map(e=>{var t;return`${n}<stop offset="${t=e.offset,`${Math.round(1e5*t)/1e3}%`}" stop-color="${b(e.color)}"${void 0===e.opacity?"":` stop-opacity="${e.opacity}"`} />`}),`${r}</linearGradient>`].join(`
|
|
4
4
|
`)}function eL(e,t={}){if(e.length>eU.maxResources)throw Error(`A definitions mark may declare at most ${eU.maxResources} linear gradients`);let r=new Set,n=0,i=0,o=[];for(let a of e){if(r.has(a.id))throw Error(`Duplicate linear gradient resource "${a.id}"`);if(r.add(a.id),(n+=a.stops.length)>eU.maxAggregateStops)throw Error(`Linear gradient resources may declare at most ${eU.maxAggregateStops} aggregate stops`);let e=eR(a,t),s=+(0!==o.length),d=eU.maxSerializationBytes-i-s,c=eD(e,Math.max(0,d));if(c>d)throw Error(`Linear gradient serialization exceeds ${eU.maxSerializationBytes} bytes`);i+=c+s,o.push(e)}return o.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{G as e,_ as o}from"./chunk-
|
|
1
|
+
import{G as e,_ as o}from"./chunk-SZAI2WB4.js";var t={nodeLabel:13,edgeLabel:11,groupHeader:12},r={nodeLabel:500,edgeLabel:400,groupHeader:600},n={outerBox:1,innerBox:.75,connector:1},i={width:8,height:5,strokeWidth:.75},d={dash:4,gap:4},a={nodeLabelFontSize:t.nodeLabel,edgeLabelFontSize:t.edgeLabel,groupHeaderFontSize:t.groupHeader,nodeLabelFontWeight:r.nodeLabel,edgeLabelFontWeight:r.edgeLabel,groupHeaderFontWeight:r.groupHeader,nodePaddingX:20,nodePaddingY:10,diamondExtraPadding:24,edgeLineWidth:n.connector,groupCornerRadius:0,groupPaddingX:16,groupPaddingY:16,groupLabelPaddingX:12,groupLineWidth:n.outerBox};function g(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function l(e,...o){for(let e of o){let o=g(e);if(null!=o&&o>0)return o}return e}function u(e,...o){for(let e of o){let o=g(e);if(null!=o&&o>=0)return o}return e}function p(...e){for(let o of e)if("string"==typeof o&&o.trim().length>0)return o}function f(...e){for(let o of e){let e=p(o)?.toLowerCase();if("uppercase"===e||"lowercase"===e||"capitalize"===e)return e}}function s(o,t){if("string"!=typeof o)return e(o,o.display,t);if(!t)return o;let r=e(o,"formatted",t),n=0,i="";for(let e of r.lines)for(let t of e)i+=o.slice(n,t.sourceStart)+t.text,n=t.sourceEnd;return i+o.slice(n)}function c(e={},o=a,t){let r=t??e.styleFace,i=r?.text,d=r?.node,s=r?.edge,h=r?.group,x=u(void 0,h?.paddingX),L=null==o.nodeCornerRadius?u(void 0,d?.cornerRadius):u(o.nodeCornerRadius,d?.cornerRadius);return{nodeLabelFontSize:l(o.nodeLabelFontSize,d?.fontSize,i?.fontSize),edgeLabelFontSize:l(o.edgeLabelFontSize,s?.fontSize,i?.fontSize),groupHeaderFontSize:l(o.groupHeaderFontSize,h?.fontSize,i?.fontSize),nodeLabelFontWeight:l(o.nodeLabelFontWeight,d?.fontWeight,i?.fontWeight),edgeLabelFontWeight:l(o.edgeLabelFontWeight,s?.fontWeight,i?.fontWeight),groupHeaderFontWeight:l(o.groupHeaderFontWeight,h?.fontWeight,i?.fontWeight),nodeTextTransform:f(d?.textTransform,i?.textTransform,o.nodeTextTransform),edgeTextTransform:f(s?.textTransform,i?.textTransform,o.edgeTextTransform),nodeLetterSpacing:g(d?.letterSpacing)??g(i?.letterSpacing)??o.nodeLetterSpacing??0,edgeLetterSpacing:g(s?.letterSpacing)??g(i?.letterSpacing)??o.edgeLetterSpacing??0,groupLetterSpacing:g(h?.letterSpacing)??g(i?.letterSpacing)??o.groupLetterSpacing??0,nodePaddingX:u(o.nodePaddingX,d?.paddingX),nodePaddingY:u(o.nodePaddingY,d?.paddingY),diamondExtraPadding:o.diamondExtraPadding??24,cornerRadius:L,nodeLineWidth:l(o.nodeLineWidth??n.innerBox,d?.lineWidth),nodeFillColor:p(d?.fillColor,o.nodeFillColor),nodeBorderColor:p(d?.borderColor,o.nodeBorderColor),nodeTextColor:p(d?.textColor,i?.textColor,o.nodeTextColor),lineWidth:l(o.edgeLineWidth,s?.lineWidth),edgeBendRadius:u(o.edgeBendRadius??0,s?.bendRadius),edgeStrokeColor:p(s?.strokeColor,o.edgeStrokeColor),edgeTextColor:p(s?.textColor,i?.textColor,o.edgeTextColor),groupFont:p(h?.fontFamily,o.groupFont),groupTextTransform:f(h?.textTransform,i?.textTransform,o.groupTextTransform),groupCornerRadius:u(o.groupCornerRadius,h?.cornerRadius),groupBorderColor:p(h?.borderColor,o.groupBorderColor),groupFillColor:p(h?.fillColor,o.groupFillColor),groupHeaderFillColor:p(h?.headerFillColor,o.groupHeaderFillColor),groupTextColor:p(h?.textColor,i?.textColor,o.groupTextColor),groupPaddingX:x??o.groupPaddingX,groupPaddingY:u(o.groupPaddingY,h?.paddingY),groupLabelPaddingX:x??o.groupLabelPaddingX??o.groupPaddingX,groupLineWidth:l(o.groupLineWidth??n.outerBox,h?.lineWidth)}}var h=18,x=600,L=12;function b(e,t){if(void 0===e)return;let r=o(e,{display:"formatted",transform:t.groupTextTransform,fontSize:h,fontWeight:x,letterSpacing:t.groupLetterSpacing,fontFamily:t.groupFont});return{text:r.text,width:r.width,height:r.height+L,block:r}}function C(e,o,t=o){let r=e.width+2*o;return{width:r,height:e.height-L+2*t,title:S(e,r,t)}}function S(e,o,t){return{text:e.text,x:o/2,y:t+(e.height-L)/2,...e.block?{block:e.block}:{}}}function F(e,o){let t=o.groupTextColor??"var(--_text)";return{id:"diagram-title",role:"title",text:e.text,block:e.block,x:e.x,y:e.y,fontSize:h,fontWeight:x,letterSpacing:o.groupLetterSpacing,anchor:"middle",paint:{fill:t},attributes:{className:"diagram-title"}}}export{t as a,r as b,n as c,i as d,d as e,a as f,s as g,c as h,h as i,x as j,L as k,b as l,C as m,S as n,F as o};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Z as e,a as t,d as n}from"./chunk-
|
|
1
|
+
import{Z as e,a as t,d as n}from"./chunk-GK5PSUKH.js";import{Tb as i}from"./chunk-SZAI2WB4.js";function r(e){return t=>e(t)}function o(e){return n(e,t=>e(t))}function s(e,t={}){return{positioned:e,...t}}function a(e,n){let i=Object.freeze({...e,...n,contractVersion:2,capabilityEvidence:Object.freeze([])});return t(i),i}function u(e){if(!Number.isFinite(e))throw RangeError(`expected a finite number, got ${String(e)}`);return e}e.error.code,e.error.severity,e.warn.code,e.warn.severity,e.error.code,e.error.tier,e.warn.code,e.warn.tier;var l,f={font:"Inter",padding:40,nodeSpacing:28,layerSpacing:i,mergeEdges:!0,thoroughness:3};function d(e){let t=new Map,n=[],i=e=>{let i=t.get(e);return void 0===i&&(i=n.length,t.set(e,i),n.push([])),i};for(let t of e)n[i(t.source)].push(i(t.target));let r=new Uint32Array(n.length),o=[],s=0;return(e,i)=>{if(e===i)return!0;let a=t.get(e),u=t.get(i);if(void 0===a||void 0===u)return!1;for(0xffffffff==++s&&(r.fill(0),s=1),o.length=0,o.push(a),r[a]=s;o.length;)for(let e of n[o.pop()]){if(e===u)return!0;r[e]!==s&&(r[e]=s,o.push(e))}return!1}}function h(e){let t=[];for(let n of e)t.push({x:n.x,y:n.y,right:n.x+n.width,bottom:n.y+n.height}),t.push(...h(n.children));return t}function c(e){let t=0;for(let n=1;n<e.length;n++){let i=e[n].x-e[n-1].x,r=e[n].y-e[n-1].y;t+=Math.sqrt(i*i+r*r)}return t}function g(e){return function(e,t){if(0===e.length)return{point:{x:0,y:0},segmentIndex:0,pathDistance:0};if(1===e.length)return{point:e[0],segmentIndex:0,pathDistance:0};let n=Math.max(0,Math.min(c(e),t)),i=0;for(let t=1;t<e.length;t++){let r=e[t].x-e[t-1].x,o=e[t].y-e[t-1].y,s=Math.sqrt(r*r+o*o);if(0!==s){if(n<=s){let a=n/s;return{point:{x:e[t-1].x+a*r,y:e[t-1].y+a*o},segmentIndex:t,pathDistance:i+n}}n-=s,i+=s}}return{point:e[e.length-1],segmentIndex:e.length-1,pathDistance:i}}(e,c(e)/2).point}function p(e){return"LR"===e?{isHorizontal:!0,main:"x",cross:"y",sign:1,sourceSide:"E",targetSide:"W"}:"RL"===e?{isHorizontal:!0,main:"x",cross:"y",sign:-1,sourceSide:"W",targetSide:"E"}:"BT"===e?{isHorizontal:!1,main:"y",cross:"x",sign:-1,sourceSide:"N",targetSide:"S"}:{isHorizontal:!1,main:"y",cross:"x",sign:1,sourceSide:"S",targetSide:"N"}}function y(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function m(e,t){return e[p(t).main]}function x(e,t){return e[p(t).cross]}function b(e,t){return p(t).isHorizontal?e.height:e.width}function w(e,t){return p(t).isHorizontal?e.width:e.height}function v(e,t){return x(e,t)+b(e,t)/2}function S(e,t){return m(e,t)+w(e,t)/2}function $(e,t,n=0){return e.x<t.x+t.width+n&&e.x+e.width+n>t.x&&e.y<t.y+t.height+n&&e.y+e.height+n>t.y}function I(e,t){for(let n of e){if(n.id===t)return n;let e=I(n.children,t);if(e)return e}}function M(e){let t=globalThis.process?.env?.[e];return"1"===t||"true"===t}function E(...e){M("APL_DEBUG")&&console.error(...e)}function j(e){let t=new Map;return e.map(e=>{let n=`${e.source}->${e.target}`,i=t.get(n)??0;return t.set(n,i+1),`${n}#${i}`})}function k(e){let t=new Map;j(e).forEach((e,n)=>{t.set(e,n),e.endsWith("#0")&&t.set(e.slice(0,-2),n)});for(let n=e.length-1;n>=0;n--){let i=e[n].id;i&&t.set(i,n)}return t}function z(e,t,n,i="middle"){if(e)return{x:u(t-("start"===i?0:"end"===i?e.width:e.width/2)),y:u(n-e.height/2),w:u(e.width),h:u(e.height)}}function B(e,t,n,i,r="middle"){let o=z(e,t,n,r);return o?{labelBounds:o,labelContainer:{x:u(i.x),y:u(i.y),w:u(i.width),h:u(i.height)}}:{}}function H(e){return{id:e.id,x:u(e.x),y:u(e.y),w:u(e.width),h:u(e.height),shape:e.shape,label:e.label,...B(e.labelBlock,e.x+e.width/2,e.y+e.height/2,e)}}function A(e,t={}){let n=e.edges.map((e,t)=>({value:e,index:t})).sort((e,t)=>(e.value.edgeIndex??e.index)-(t.value.edgeIndex??t.index)).map(e=>e.value),i=j(n),r=k(n),o=new Set(e.nodes.map(e=>e.id)),s=[...e.groups];for(let e of s)o.add(e.id),s.push(...e.children);let a=new Map(n.map((e,t)=>{let n=e.id,s=i[t],a=s.replace(/#0$/,"");return[e,n&&!o.has(n)&&r.get(n)===t?n:r.get(a)===t?a:s]}));return{version:1,nodes:e.nodes.map(H),edges:e.edges.map(e=>{var n,i;let r;return n=a.get(e),i=!0===t.debug,r=e.label?e.labelPosition??g(e.points):void 0,{id:n,from:e.source,to:e.target,path:e.points.map(e=>[u(e.x),u(e.y)]),..."invisible"===e.style?{visibility:"hidden"}:{},label:e.label&&r?{x:u(r.x),y:u(r.y),text:e.label,bounds:z(e.labelBlock,r.x,r.y)}:void 0,...i&&e.routeCertificate?{route:e.routeCertificate}:{}}}),groups:function(e,t){let n=[],i=(e,t)=>t.x>=e.x-.5&&t.y>=e.y-.5&&t.x+t.width<=e.x+e.width+.5&&t.y+t.height<=e.y+e.height+.5,r=(e,o)=>{let s=e.nodeIds?new Set(e.nodeIds):void 0,a=t.filter(t=>s?s.has(t.id):i(e,t)&&!e.children.some(e=>i(e,t))).map(e=>e.id);for(let t of(n.push({id:e.id,x:u(e.x),y:u(e.y),w:u(e.width),h:u(e.height),members:a,label:e.label,...o?{parentId:o}:{}}),e.children))r(t,e.id)};for(let t of e)r(t);return n}(e.groups,e.nodes),bounds:{w:u(e.width),h:u(e.height)}}}function D(e){return l?.family===e}function O(e,t,n,i){let r=l;l={family:e,observer:t,mutations:i?.mutations?new Set(i.mutations):void 0};try{let e=n();if(null!==e&&"object"==typeof e&&"then"in e&&"function"==typeof e.then)throw Promise.resolve(e).catch(()=>{}),TypeError("Parser observation scopes must be synchronous");return e}finally{l=r}}function P(e,t){let n=l;if(!(!n||n.family!==e)){l=void 0;try{n.observer(t)}finally{l=n}}}function N(e,t,n,i){D(e)&&P(e,{family:e,unit:"statement",kind:t,text:n,...i?{source:{...i}}:{}})}function T(e,t,n,i){D(e)&&P(e,{family:e,unit:"token",kind:t,text:n,...i?{source:{...i}}:{}})}function W(e,t,n,i){D(e)&&(l?.mutations&&!l.mutations.has(t)||P(e,{family:e,unit:"mutation",kind:t,value:function e(t,n=new Map,i="$"){let r;if(null==t)return null;if("number"==typeof t)return Number.isFinite(t)?t:{$number:String(t)};if("string"==typeof t||"boolean"==typeof t)return t;if("object"!=typeof t)return String(t);let o=n.get(t);if(void 0!==o)return{$ref:o};if(n.set(t,i),t instanceof Date)r=t.toISOString();else if(t instanceof Map)r=[...t].map(([t,r],o)=>[e(t,n,`${i}.${o}.0`),e(r,n,`${i}.${o}.1`)]);else if(t instanceof Set)r=[...t].map((t,r)=>e(t,n,`${i}.${r}`));else if(Array.isArray(t))r=t.map((t,r)=>e(t,n,`${i}.${r}`));else{let o=Object.create(null);for(let[r,s]of Object.entries(t))"function"!=typeof s&&void 0!==s&&(o[r]=e(s,n,`${i}.${r}`));r=o}return n.delete(t),r}(n),...i?{source:{...i}}:{}}))}export{r as a,o as b,s as c,a as d,D as e,O as f,N as g,T as h,W as i,u as j,f as k,d as l,h as m,c as n,g as o,p as p,y as q,m as r,x as s,b as t,w as u,v as v,S as w,$ as x,I as y,M as z,E as A,k as B,z as C,B as D,A as E};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{i as t,j as e,k as o}from"./chunk-
|
|
1
|
+
import{i as t,j as e,k as o}from"./chunk-ILCWDEZN.js";function h(h,n,i,r,s,a){let d=r.font??"Inter",p=t(r);return{family:n,width:i.width,height:i.height,colors:r,transparent:s,parts:[h.documentOpen({id:"prelude",width:i.width,height:i.height,colors:r,transparent:s,font:d,hasMonoFont:!1},`${o(i.width,i.height,r,s)}
|
|
2
2
|
${e(d,!1,r.shadow,r.embedFontImport)}${p?`
|
|
3
3
|
<defs>${p}</defs>`:""}`),...a,h.documentClose()]}}export{h as a};
|