@diagrammo/dgmo 0.33.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/auto.cjs CHANGED
@@ -29044,63 +29044,6 @@ function ensureArrowMarkers(defs, colors) {
29044
29044
  ).attr("fill", color);
29045
29045
  }
29046
29046
  }
29047
- function edgePolylineMidpoint(points) {
29048
- if (points.length === 0) return { x: 0, y: 0 };
29049
- if (points.length === 1) return { x: points[0].x, y: points[0].y };
29050
- let total = 0;
29051
- const segLen = [];
29052
- for (let k = 1; k < points.length; k++) {
29053
- const len = Math.hypot(
29054
- points[k].x - points[k - 1].x,
29055
- points[k].y - points[k - 1].y
29056
- );
29057
- segLen.push(len);
29058
- total += len;
29059
- }
29060
- let half = total / 2;
29061
- for (let k = 1; k < points.length; k++) {
29062
- const len = segLen[k - 1];
29063
- if (half <= len || k === points.length - 1) {
29064
- const t = len === 0 ? 0 : Math.min(1, half / len);
29065
- return {
29066
- x: points[k - 1].x + (points[k].x - points[k - 1].x) * t,
29067
- y: points[k - 1].y + (points[k].y - points[k - 1].y) * t
29068
- };
29069
- }
29070
- half -= len;
29071
- }
29072
- const last = points[points.length - 1];
29073
- return { x: last.x, y: last.y };
29074
- }
29075
- function resolveEdgeLabelOverlaps(labels) {
29076
- const MAX_PASSES = 8;
29077
- const PAD = 4;
29078
- for (let pass = 0; pass < MAX_PASSES; pass++) {
29079
- let moved = false;
29080
- for (let i = 0; i < labels.length; i++) {
29081
- for (let j = i + 1; j < labels.length; j++) {
29082
- const a = labels[i];
29083
- const b = labels[j];
29084
- const dx = Math.abs(a.x - b.x);
29085
- const dy = Math.abs(a.y - b.y);
29086
- const overlapX = (a.width + b.width) / 2 + PAD - dx;
29087
- const overlapY = (a.height + b.height) / 2 + PAD - dy;
29088
- if (overlapX > 0 && overlapY > 0) {
29089
- const shift = overlapY / 2 + 1;
29090
- if (a.y < b.y) {
29091
- a.y -= shift;
29092
- b.y += shift;
29093
- } else {
29094
- a.y += shift;
29095
- b.y -= shift;
29096
- }
29097
- moved = true;
29098
- }
29099
- }
29100
- }
29101
- if (!moved) break;
29102
- }
29103
- }
29104
29047
  function renderBoxesAndLines(container, parsed, layout, palette, isDark, options) {
29105
29048
  const {
29106
29049
  onClickItem,
@@ -29307,8 +29250,6 @@ function renderBoxesAndLines(container, parsed, layout, palette, isDark, options
29307
29250
  groupG.append("text").attr("class", "bl-group-label").attr("x", gx + group.width / 2).attr("y", gy + 18).attr("text-anchor", "middle").attr("font-family", FONT_FAMILY).attr("font-size", sGroupLabelFontSize).attr("font-weight", "600").attr("fill", palette.text).text(group.label);
29308
29251
  }
29309
29252
  }
29310
- const labelPositions = [];
29311
- const edgeGroups = /* @__PURE__ */ new Map();
29312
29253
  for (let i = 0; i < layout.edges.length; i++) {
29313
29254
  const le = layout.edges[i];
29314
29255
  const color = edgeColorMap.get(i) ?? palette.textMuted;
@@ -29327,7 +29268,6 @@ function renderBoxesAndLines(container, parsed, layout, palette, isDark, options
29327
29268
  const nodeLayout = layoutNodeMap.get(le.source);
29328
29269
  if (nodeLayout) {
29329
29270
  const edgeG2 = diagramG.append("g").attr("class", "bl-edge-group").attr("data-line-number", String(le.lineNumber));
29330
- edgeGroups.set(i, edgeG2);
29331
29271
  const markerId2 = `bl-arrow-${color.replace("#", "")}`;
29332
29272
  const cx = nodeLayout.x;
29333
29273
  const cy = nodeLayout.y;
@@ -29376,7 +29316,6 @@ function renderBoxesAndLines(container, parsed, layout, palette, isDark, options
29376
29316
  }
29377
29317
  if (points.length < 2) continue;
29378
29318
  const edgeG = diagramG.append("g").attr("class", "bl-edge-group").attr("data-line-number", String(le.lineNumber));
29379
- edgeGroups.set(i, edgeG);
29380
29319
  const markerId = `bl-arrow-${color.replace("#", "")}`;
29381
29320
  const gen = le.straight ? lineGeneratorStraight : parsed.direction === "TB" ? lineGeneratorTB : lineGeneratorLR;
29382
29321
  const path = edgeG.append("path").attr("class", "bl-edge").attr("d", gen(points) ?? "").attr("fill", "none").attr("stroke", color).attr("stroke-width", sEdgeStrokeWidth).attr("marker-end", `url(#${markerId})`);
@@ -29384,31 +29323,6 @@ function renderBoxesAndLines(container, parsed, layout, palette, isDark, options
29384
29323
  const revId = `bl-arrow-rev-${color.replace("#", "")}`;
29385
29324
  path.attr("marker-start", `url(#${revId})`);
29386
29325
  }
29387
- if (le.label && le.points.length > 0) {
29388
- const lw = measureText(le.label, sEdgeLabelFontSize);
29389
- const labelH = sEdgeLabelFontSize + 6;
29390
- const mid = edgePolylineMidpoint(le.points);
29391
- let ly = mid.y;
29392
- if (le.parallelCount > 1 && le.yOffset !== 0) {
29393
- ly += (le.yOffset < 0 ? -labelH : labelH) * 0.5;
29394
- }
29395
- labelPositions.push({
29396
- x: mid.x,
29397
- y: ly,
29398
- width: lw + 8,
29399
- height: labelH,
29400
- idx: i
29401
- });
29402
- }
29403
- }
29404
- resolveEdgeLabelOverlaps(labelPositions);
29405
- for (const lp of labelPositions) {
29406
- const le = layout.edges[lp.idx];
29407
- if (!le.label) continue;
29408
- const edgeG = edgeGroups.get(lp.idx);
29409
- const target = edgeG ?? diagramG;
29410
- target.append("rect").attr("x", lp.x - lp.width / 2).attr("y", lp.y - lp.height / 2).attr("width", lp.width).attr("height", lp.height).attr("rx", 3).attr("fill", palette.bg).attr("opacity", 0.85);
29411
- target.append("text").attr("x", lp.x).attr("y", lp.y + sEdgeLabelFontSize / 3).attr("text-anchor", "middle").attr("font-size", sEdgeLabelFontSize).attr("fill", palette.textMuted).text(le.label);
29412
29326
  }
29413
29327
  for (const ln of layout.nodes) {
29414
29328
  const node = nodeMap.get(ln.label);
@@ -29459,8 +29373,8 @@ function renderBoxesAndLines(container, parsed, layout, palette, isDark, options
29459
29373
  nodeG.append("rect").attr("x", x).attr("y", y).attr("width", ln.width).attr("height", ln.height).attr("rx", NODE_RX).attr("ry", NODE_RX).attr("fill", colors.fill).attr("stroke", colors.stroke).attr("stroke-width", sNodeStrokeWidth);
29460
29374
  const desc = node.description;
29461
29375
  if (desc && desc.length > 0 && !hideDescriptions) {
29462
- const MAX_LABEL_LINES3 = 3;
29463
- const fitted = fitLabelToHeader(node.label, ln.width, MAX_LABEL_LINES3);
29376
+ const MAX_LABEL_LINES4 = 3;
29377
+ const fitted = fitLabelToHeader(node.label, ln.width, MAX_LABEL_LINES4);
29464
29378
  const labelLines = fitted.lines;
29465
29379
  const labelLineH = fitted.fontSize * 1.3;
29466
29380
  const labelTotalH = labelLines.length * labelLineH;
@@ -29594,6 +29508,35 @@ function renderBoxesAndLines(container, parsed, layout, palette, isDark, options
29594
29508
  }
29595
29509
  }
29596
29510
  }
29511
+ const labelLayer = diagramG.append("g").attr("class", "bl-edge-labels");
29512
+ const labelLineHeight = sEdgeLabelFontSize * 1.3;
29513
+ for (const le of layout.edges) {
29514
+ if (!le.labelLines || le.labelLines.length === 0) continue;
29515
+ if (le.labelX === void 0 || le.labelY === void 0) continue;
29516
+ const lx = le.labelX;
29517
+ const ly = le.labelY;
29518
+ if (hidden.size > 0) {
29519
+ let isHidden = false;
29520
+ for (const [groupKey, hiddenVals] of hidden) {
29521
+ const val = le.metadata[groupKey];
29522
+ if (val && hiddenVals.has(val.toLowerCase())) {
29523
+ isHidden = true;
29524
+ break;
29525
+ }
29526
+ }
29527
+ if (isHidden) continue;
29528
+ }
29529
+ const lw = le.labelWidth ?? 0;
29530
+ const lh = le.labelHeight ?? sEdgeLabelFontSize + 6;
29531
+ const lines = le.labelLines;
29532
+ const labelG = labelLayer.append("g").attr("class", "bl-edge-label").attr("data-line-number", String(le.lineNumber));
29533
+ labelG.append("rect").attr("x", lx - lw / 2).attr("y", ly - lh / 2).attr("width", lw).attr("height", lh).attr("rx", 3).attr("fill", palette.bg).attr("opacity", 0.72);
29534
+ const text = labelG.append("text").attr("x", lx).attr("text-anchor", "middle").attr("font-family", FONT_FAMILY).attr("font-size", sEdgeLabelFontSize).attr("fill", palette.textMuted);
29535
+ const firstY = ly - (lines.length - 1) / 2 * labelLineHeight + sEdgeLabelFontSize / 3;
29536
+ lines.forEach((line11, k) => {
29537
+ text.append("tspan").attr("x", lx).attr("y", firstY + k * labelLineHeight).text(line11);
29538
+ });
29539
+ }
29597
29540
  const hasDescriptions = parsed.nodes.some(
29598
29541
  (n) => n.description && n.description.length > 0
29599
29542
  );
@@ -29710,6 +29653,222 @@ var init_renderer6 = __esm({
29710
29653
  }
29711
29654
  });
29712
29655
 
29656
+ // src/boxes-and-lines/label-placement.ts
29657
+ function measureEdgeLabel(label, fontSize = EDGE_LABEL_FONT_SIZE6, maxWidth = LABEL_MAX_WIDTH) {
29658
+ let lines = wrapTextToWidth(label, fontSize, maxWidth, { hardBreak: true });
29659
+ if (lines.length > MAX_LABEL_LINES) {
29660
+ const kept = lines.slice(0, MAX_LABEL_LINES - 1);
29661
+ const rest = lines.slice(MAX_LABEL_LINES - 1).join(" ");
29662
+ kept.push(truncateText(rest, fontSize, maxWidth));
29663
+ lines = kept;
29664
+ }
29665
+ let textW = 0;
29666
+ for (const ln of lines) {
29667
+ const w = measureText(ln, fontSize);
29668
+ if (w > textW) textW = w;
29669
+ }
29670
+ return {
29671
+ lines,
29672
+ width: textW + 2 * H_PAD,
29673
+ height: lines.length * fontSize * LABEL_LINE_HEIGHT + 2 * V_PAD
29674
+ };
29675
+ }
29676
+ function edgePolylineMidpoint(points) {
29677
+ return pointAtArcFraction(points, 0.5).p;
29678
+ }
29679
+ function pointAtArcFraction(points, t) {
29680
+ if (points.length === 0) return { p: { x: 0, y: 0 }, nx: 0, ny: 1 };
29681
+ if (points.length === 1)
29682
+ return { p: { x: points[0].x, y: points[0].y }, nx: 0, ny: 1 };
29683
+ const segLen = [];
29684
+ let total = 0;
29685
+ for (let k = 1; k < points.length; k++) {
29686
+ const len = Math.hypot(
29687
+ points[k].x - points[k - 1].x,
29688
+ points[k].y - points[k - 1].y
29689
+ );
29690
+ segLen.push(len);
29691
+ total += len;
29692
+ }
29693
+ let want = total * Math.max(0, Math.min(1, t));
29694
+ for (let k = 1; k < points.length; k++) {
29695
+ const len = segLen[k - 1];
29696
+ if (want <= len || k === points.length - 1) {
29697
+ const f = len === 0 ? 0 : Math.min(1, want / len);
29698
+ const ax = points[k - 1].x;
29699
+ const ay = points[k - 1].y;
29700
+ const bx = points[k].x;
29701
+ const by = points[k].y;
29702
+ const dx = bx - ax;
29703
+ const dy = by - ay;
29704
+ const dlen = Math.hypot(dx, dy) || 1;
29705
+ return {
29706
+ p: { x: ax + dx * f, y: ay + dy * f },
29707
+ nx: -dy / dlen,
29708
+ ny: dx / dlen
29709
+ };
29710
+ }
29711
+ want -= len;
29712
+ }
29713
+ const last = points[points.length - 1];
29714
+ return { p: { x: last.x, y: last.y }, nx: 0, ny: 1 };
29715
+ }
29716
+ function rectFromCenter(cx, cy, w, h) {
29717
+ return {
29718
+ minX: cx - w / 2,
29719
+ minY: cy - h / 2,
29720
+ maxX: cx + w / 2,
29721
+ maxY: cy + h / 2
29722
+ };
29723
+ }
29724
+ function overlapsAny(cx, cy, w, h, obstacles, pad2) {
29725
+ const minX = cx - w / 2 - pad2;
29726
+ const minY = cy - h / 2 - pad2;
29727
+ const maxX = cx + w / 2 + pad2;
29728
+ const maxY = cy + h / 2 + pad2;
29729
+ for (const o of obstacles) {
29730
+ if (minX < o.maxX && maxX > o.minX && minY < o.maxY && maxY > o.minY)
29731
+ return true;
29732
+ }
29733
+ return false;
29734
+ }
29735
+ function slideFractions() {
29736
+ const out = [0.5];
29737
+ for (let k = 1; k <= SLIDE_SAMPLES; k++) {
29738
+ const off = k * 0.08;
29739
+ if (0.5 - off >= 0.12) out.push(0.5 - off);
29740
+ if (0.5 + off <= 0.88) out.push(0.5 + off);
29741
+ }
29742
+ return out;
29743
+ }
29744
+ function findClearPosition(w, h, points, obstacles) {
29745
+ const ts = slideFractions();
29746
+ for (const t of ts) {
29747
+ const { p } = pointAtArcFraction(points, t);
29748
+ if (!overlapsAny(p.x, p.y, w, h, obstacles, BOX_CLEAR_PAD)) return p;
29749
+ }
29750
+ for (let mag = PERP_STEP; mag <= PERP_MAX; mag += PERP_STEP) {
29751
+ for (const t of ts) {
29752
+ const { p, nx, ny } = pointAtArcFraction(points, t);
29753
+ for (const sign of [-1, 1]) {
29754
+ const x = p.x + nx * mag * sign;
29755
+ const y = p.y + ny * mag * sign;
29756
+ if (!overlapsAny(x, y, w, h, obstacles, BOX_CLEAR_PAD)) return { x, y };
29757
+ }
29758
+ }
29759
+ }
29760
+ return null;
29761
+ }
29762
+ function resolveLabelOverlaps(boxes) {
29763
+ const MAX_PASSES = 8;
29764
+ const PAD = 4;
29765
+ for (let pass = 0; pass < MAX_PASSES; pass++) {
29766
+ let moved = false;
29767
+ for (let i = 0; i < boxes.length; i++) {
29768
+ for (let j = i + 1; j < boxes.length; j++) {
29769
+ const a = boxes[i];
29770
+ const b = boxes[j];
29771
+ const dx = Math.abs(a.cx - b.cx);
29772
+ const dy = Math.abs(a.cy - b.cy);
29773
+ const overlapX = (a.w + b.w) / 2 + PAD - dx;
29774
+ const overlapY = (a.h + b.h) / 2 + PAD - dy;
29775
+ if (overlapX > 0 && overlapY > 0) {
29776
+ const shift = overlapY / 2 + 1;
29777
+ if (a.cy < b.cy) {
29778
+ a.cy -= shift;
29779
+ b.cy += shift;
29780
+ } else {
29781
+ a.cy += shift;
29782
+ b.cy -= shift;
29783
+ }
29784
+ moved = true;
29785
+ }
29786
+ }
29787
+ }
29788
+ if (!moved) break;
29789
+ }
29790
+ }
29791
+ function placeEdgeLabels(layout, opts) {
29792
+ const fontSize = opts?.fontSize ?? EDGE_LABEL_FONT_SIZE6;
29793
+ const maxWidth = opts?.maxWidth ?? LABEL_MAX_WIDTH;
29794
+ const obstacles = [];
29795
+ for (const n of layout.nodes)
29796
+ obstacles.push(rectFromCenter(n.x, n.y, n.width, n.height));
29797
+ for (const g of layout.groups)
29798
+ if (g.collapsed)
29799
+ obstacles.push(rectFromCenter(g.x, g.y, g.width, g.height));
29800
+ const boxes = [];
29801
+ layout.edges.forEach((e, idx) => {
29802
+ if (!e.label || e.points.length < 2) return;
29803
+ const m = measureEdgeLabel(e.label, fontSize, maxWidth);
29804
+ const mid = edgePolylineMidpoint(e.points);
29805
+ let cy = mid.y;
29806
+ if (e.parallelCount > 1 && e.yOffset !== 0)
29807
+ cy += (e.yOffset < 0 ? -1 : 1) * (m.height / 2);
29808
+ boxes.push({
29809
+ edgeIdx: idx,
29810
+ cx: mid.x,
29811
+ cy,
29812
+ w: m.width,
29813
+ h: m.height,
29814
+ lines: m.lines,
29815
+ resolved: true
29816
+ });
29817
+ });
29818
+ for (const box of boxes) {
29819
+ if (!overlapsAny(box.cx, box.cy, box.w, box.h, obstacles, BOX_CLEAR_PAD))
29820
+ continue;
29821
+ const e = layout.edges[box.edgeIdx];
29822
+ const clear = findClearPosition(box.w, box.h, e.points, obstacles);
29823
+ if (clear) {
29824
+ box.cx = clear.x;
29825
+ box.cy = clear.y;
29826
+ } else {
29827
+ box.resolved = false;
29828
+ }
29829
+ }
29830
+ resolveLabelOverlaps(boxes);
29831
+ for (const box of boxes) {
29832
+ if (overlapsAny(box.cx, box.cy, box.w, box.h, obstacles, BOX_CLEAR_PAD))
29833
+ box.resolved = false;
29834
+ }
29835
+ const boxByIdx = /* @__PURE__ */ new Map();
29836
+ for (const b of boxes) boxByIdx.set(b.edgeIdx, b);
29837
+ const edges = layout.edges.map((e, idx) => {
29838
+ const b = boxByIdx.get(idx);
29839
+ if (!b) return e;
29840
+ return {
29841
+ ...e,
29842
+ labelX: b.cx,
29843
+ labelY: b.cy,
29844
+ labelWidth: b.w,
29845
+ labelHeight: b.h,
29846
+ labelLines: b.lines
29847
+ };
29848
+ });
29849
+ return {
29850
+ layout: { ...layout, edges },
29851
+ unresolved: boxes.filter((b) => !b.resolved).map((b) => b.edgeIdx)
29852
+ };
29853
+ }
29854
+ var EDGE_LABEL_FONT_SIZE6, LABEL_MAX_WIDTH, MAX_LABEL_LINES, LABEL_LINE_HEIGHT, H_PAD, V_PAD, BOX_CLEAR_PAD, PERP_STEP, PERP_MAX, SLIDE_SAMPLES;
29855
+ var init_label_placement = __esm({
29856
+ "src/boxes-and-lines/label-placement.ts"() {
29857
+ "use strict";
29858
+ init_text_measure();
29859
+ EDGE_LABEL_FONT_SIZE6 = 11;
29860
+ LABEL_MAX_WIDTH = 160;
29861
+ MAX_LABEL_LINES = 3;
29862
+ LABEL_LINE_HEIGHT = 1.3;
29863
+ H_PAD = 6;
29864
+ V_PAD = 3;
29865
+ BOX_CLEAR_PAD = 4;
29866
+ PERP_STEP = 8;
29867
+ PERP_MAX = 40;
29868
+ SLIDE_SAMPLES = 9;
29869
+ }
29870
+ });
29871
+
29713
29872
  // src/boxes-and-lines/layout-layered.ts
29714
29873
  function rng(s) {
29715
29874
  return () => {
@@ -31497,6 +31656,7 @@ function edgeLength(layout) {
31497
31656
  }
31498
31657
  async function layoutBoxesAndLinesSearch(parsed, collapseInfo, opts) {
31499
31658
  const hideDescriptions = opts?.hideDescriptions ?? false;
31659
+ const reserveEdgeLabels = opts?.reserveEdgeLabels ?? false;
31500
31660
  const onProgress = opts?.onProgress;
31501
31661
  const tick = onProgress ? () => new Promise((r) => setTimeout(r)) : () => void 0;
31502
31662
  const collapsedGroupLabels = /* @__PURE__ */ new Set();
@@ -31789,8 +31949,14 @@ async function layoutBoxesAndLinesSearch(parsed, collapseInfo, opts) {
31789
31949
  for (const e of ord(parsed.edges)) {
31790
31950
  const s = srcRep(e.source);
31791
31951
  const t = tgtRep(e.target);
31792
- if (s !== t && g.hasNode(s) && g.hasNode(t))
31793
- g.setEdge(s, t, {}, edgeKey(e));
31952
+ if (s !== t && g.hasNode(s) && g.hasNode(t)) {
31953
+ let edgeLabel = {};
31954
+ if (reserveEdgeLabels && e.label) {
31955
+ const m = measureEdgeLabel(e.label, EDGE_LABEL_FONT_SIZE6);
31956
+ edgeLabel = { width: m.width, height: m.height, labelpos: "c" };
31957
+ }
31958
+ g.setEdge(s, t, edgeLabel, edgeKey(e));
31959
+ }
31794
31960
  }
31795
31961
  import_dagre4.default.layout(g);
31796
31962
  const nodes = parsed.nodes.map((n2) => {
@@ -32021,6 +32187,7 @@ var init_layout_search = __esm({
32021
32187
  init_layout5();
32022
32188
  init_layout_layered();
32023
32189
  init_layout_grouped();
32190
+ init_label_placement();
32024
32191
  DEFAULT_LAMBDA = 4;
32025
32192
  ESCALATE_THRESHOLD = 4;
32026
32193
  ESCALATE_MAX_N = 45;
@@ -32079,9 +32246,9 @@ function estimateLabelLines(label, nodeWidth = NODE_WIDTH) {
32079
32246
  current = word;
32080
32247
  }
32081
32248
  }
32082
- if (lines <= MAX_LABEL_LINES) return Math.min(lines, MAX_LABEL_LINES);
32249
+ if (lines <= MAX_LABEL_LINES2) return Math.min(lines, MAX_LABEL_LINES2);
32083
32250
  }
32084
- return MAX_LABEL_LINES;
32251
+ return MAX_LABEL_LINES2;
32085
32252
  }
32086
32253
  function computeNodeSize(node, reserveValueRow) {
32087
32254
  if (!node.description || node.description.length === 0) {
@@ -32089,7 +32256,7 @@ function computeNodeSize(node, reserveValueRow) {
32089
32256
  }
32090
32257
  const w = DESC_NODE_WIDTH;
32091
32258
  const labelLines = estimateLabelLines(node.label, w);
32092
- const labelHeight = labelLines * 13 * LABEL_LINE_HEIGHT + LABEL_PAD;
32259
+ const labelHeight = labelLines * 13 * LABEL_LINE_HEIGHT2 + LABEL_PAD;
32093
32260
  const maxTextWidth = w - 24;
32094
32261
  let totalRenderedLines = 0;
32095
32262
  for (const line11 of node.description) {
@@ -32113,7 +32280,7 @@ function computeNodeSize(node, reserveValueRow) {
32113
32280
  }
32114
32281
  async function layoutBoxesAndLines(parsed, collapseInfo, layoutOptions) {
32115
32282
  const { layoutBoxesAndLinesSearch: layoutBoxesAndLinesSearch2 } = await Promise.resolve().then(() => (init_layout_search(), layout_search_exports));
32116
- const searched = await layoutBoxesAndLinesSearch2(parsed, collapseInfo, {
32283
+ const searchOpts = {
32117
32284
  ...layoutOptions?.hideDescriptions !== void 0 && {
32118
32285
  hideDescriptions: layoutOptions.hideDescriptions
32119
32286
  },
@@ -32123,12 +32290,23 @@ async function layoutBoxesAndLines(parsed, collapseInfo, layoutOptions) {
32123
32290
  ...layoutOptions?.onProgress !== void 0 && {
32124
32291
  onProgress: layoutOptions.onProgress
32125
32292
  }
32126
- });
32127
- return attachNotes(
32128
- applyParallelEdgeOffsets(searched),
32293
+ };
32294
+ const searched = await layoutBoxesAndLinesSearch2(
32129
32295
  parsed,
32130
- layoutOptions?.collapsedNotes
32131
- );
32296
+ collapseInfo,
32297
+ searchOpts
32298
+ );
32299
+ let placed = placeEdgeLabels(applyParallelEdgeOffsets(searched));
32300
+ if (placed.unresolved.length > 0) {
32301
+ const relaid = await layoutBoxesAndLinesSearch2(parsed, collapseInfo, {
32302
+ ...searchOpts,
32303
+ reserveEdgeLabels: true
32304
+ });
32305
+ const relaidPlaced = placeEdgeLabels(applyParallelEdgeOffsets(relaid));
32306
+ if (relaidPlaced.unresolved.length < placed.unresolved.length)
32307
+ placed = relaidPlaced;
32308
+ }
32309
+ return attachNotes(placed.layout, parsed, layoutOptions?.collapsedNotes);
32132
32310
  }
32133
32311
  function attachNotes(layout, parsed, collapsedNotes) {
32134
32312
  const notesSuppressed = parsed.options?.["no-notes"] === "on";
@@ -32196,6 +32374,7 @@ function attachNotes(layout, parsed, collapsedNotes) {
32196
32374
  points: e.points.map((pt) => ({ x: pt.x + shiftX, y: pt.y + shiftY })),
32197
32375
  ...e.labelX !== void 0 && { labelX: e.labelX + shiftX },
32198
32376
  ...e.labelY !== void 0 && { labelY: e.labelY + shiftY }
32377
+ // labelWidth/labelHeight/labelLines are shift-invariant — carried via spread.
32199
32378
  })) : layout.edges;
32200
32379
  const finalGroups = shifted ? layout.groups.map((grp) => ({
32201
32380
  ...grp,
@@ -32240,11 +32419,12 @@ function applyParallelEdgeOffsets(layout) {
32240
32419
  }))
32241
32420
  };
32242
32421
  }
32243
- var MARGIN5, MAX_PARALLEL_EDGES, PARALLEL_SPACING, PHI, NODE_HEIGHT, NODE_WIDTH, DESC_NODE_WIDTH, DESC_FONT_SIZE2, DESC_LINE_HEIGHT2, DESC_PADDING, SEPARATOR_GAP4, MAX_DESC_LINES2, MAX_LABEL_LINES, LABEL_LINE_HEIGHT, LABEL_PAD, VALUE_ROW_FONT, VALUE_ROW_H;
32422
+ var MARGIN5, MAX_PARALLEL_EDGES, PARALLEL_SPACING, PHI, NODE_HEIGHT, NODE_WIDTH, DESC_NODE_WIDTH, DESC_FONT_SIZE2, DESC_LINE_HEIGHT2, DESC_PADDING, SEPARATOR_GAP4, MAX_DESC_LINES2, MAX_LABEL_LINES2, LABEL_LINE_HEIGHT2, LABEL_PAD, VALUE_ROW_FONT, VALUE_ROW_H;
32244
32423
  var init_layout5 = __esm({
32245
32424
  "src/boxes-and-lines/layout.ts"() {
32246
32425
  "use strict";
32247
32426
  init_text_measure();
32427
+ init_label_placement();
32248
32428
  init_notes();
32249
32429
  MARGIN5 = 40;
32250
32430
  MAX_PARALLEL_EDGES = 5;
@@ -32258,8 +32438,8 @@ var init_layout5 = __esm({
32258
32438
  DESC_PADDING = 8;
32259
32439
  SEPARATOR_GAP4 = 4;
32260
32440
  MAX_DESC_LINES2 = 6;
32261
- MAX_LABEL_LINES = 3;
32262
- LABEL_LINE_HEIGHT = 1.3;
32441
+ MAX_LABEL_LINES2 = 3;
32442
+ LABEL_LINE_HEIGHT2 = 1.3;
32263
32443
  LABEL_PAD = 12;
32264
32444
  VALUE_ROW_FONT = 11;
32265
32445
  VALUE_ROW_H = SEPARATOR_GAP4 + VALUE_ROW_FONT * DESC_LINE_HEIGHT2 + DESC_PADDING;
@@ -32278,7 +32458,7 @@ function tokenize(text) {
32278
32458
  return tokens;
32279
32459
  }
32280
32460
  function tryWrap(tokens, maxWidth, fontSize, maxLines) {
32281
- const availWidth = maxWidth - H_PAD;
32461
+ const availWidth = maxWidth - H_PAD2;
32282
32462
  const lines = [];
32283
32463
  let currentLine = "";
32284
32464
  for (const token of tokens) {
@@ -32303,7 +32483,7 @@ function tryWrap(tokens, maxWidth, fontSize, maxLines) {
32303
32483
  return lines;
32304
32484
  }
32305
32485
  function truncateLastLine(lines, maxWidth, fontSize) {
32306
- const availWidth = maxWidth - H_PAD;
32486
+ const availWidth = maxWidth - H_PAD2;
32307
32487
  const result = [...lines];
32308
32488
  const last = result[result.length - 1];
32309
32489
  if (measureText(last, fontSize) > availWidth) {
@@ -32311,7 +32491,7 @@ function truncateLastLine(lines, maxWidth, fontSize) {
32311
32491
  }
32312
32492
  return result;
32313
32493
  }
32314
- function wrapText(text, maxWidth, baseFontSize, minFontSize, maxLines = MAX_LABEL_LINES2) {
32494
+ function wrapText(text, maxWidth, baseFontSize, minFontSize, maxLines = MAX_LABEL_LINES3) {
32315
32495
  if (!text) return { lines: [""], fontSize: baseFontSize };
32316
32496
  const tokens = tokenize(text);
32317
32497
  for (let fs = baseFontSize; fs >= minFontSize; fs--) {
@@ -32326,7 +32506,7 @@ function wrapText(text, maxWidth, baseFontSize, minFontSize, maxLines = MAX_LABE
32326
32506
  if (allLines.length > maxLines) {
32327
32507
  const last = truncated[truncated.length - 1];
32328
32508
  if (!last.endsWith("\u2026")) {
32329
- const availWidth = maxWidth - H_PAD;
32509
+ const availWidth = maxWidth - H_PAD2;
32330
32510
  if (measureText(last + "\u2026", minFontSize) > availWidth) {
32331
32511
  truncated[truncated.length - 1] = truncateText(
32332
32512
  last,
@@ -32353,7 +32533,7 @@ function computeNodeText(label, description, depth, nodeWidth, hideDescriptions)
32353
32533
  nodeWidth,
32354
32534
  baseFontSize,
32355
32535
  MIN_FONT_SIZE,
32356
- MAX_LABEL_LINES2
32536
+ MAX_LABEL_LINES3
32357
32537
  );
32358
32538
  const descLines = [];
32359
32539
  let descFontSize = DESC_FONT_SIZE3;
@@ -32381,14 +32561,14 @@ function computeNodeText(label, description, depth, nodeWidth, hideDescriptions)
32381
32561
  descFontSize
32382
32562
  };
32383
32563
  }
32384
- var H_PAD, MAX_LABEL_LINES2, MAX_DESC_LINES3, ROOT_FONT_SIZE, MIN_FONT_SIZE, FONT_STEP, DESC_FONT_SIZE3;
32564
+ var H_PAD2, MAX_LABEL_LINES3, MAX_DESC_LINES3, ROOT_FONT_SIZE, MIN_FONT_SIZE, FONT_STEP, DESC_FONT_SIZE3;
32385
32565
  var init_text_wrap = __esm({
32386
32566
  "src/mindmap/text-wrap.ts"() {
32387
32567
  "use strict";
32388
32568
  init_description_helpers();
32389
32569
  init_text_measure();
32390
- H_PAD = 16;
32391
- MAX_LABEL_LINES2 = 3;
32570
+ H_PAD2 = 16;
32571
+ MAX_LABEL_LINES3 = 3;
32392
32572
  MAX_DESC_LINES3 = 2;
32393
32573
  ROOT_FONT_SIZE = 17;
32394
32574
  MIN_FONT_SIZE = 9;
@@ -32775,7 +32955,7 @@ function nodeHeightS(node, hideDescriptions, sc) {
32775
32955
  hideDescriptions
32776
32956
  );
32777
32957
  const labelLineCount = text.labelLines.length;
32778
- const labelH = labelLineCount <= 1 ? SINGLE_LABEL_HEIGHT : LABEL_LINE_HEIGHT2 * labelLineCount;
32958
+ const labelH = labelLineCount <= 1 ? SINGLE_LABEL_HEIGHT : LABEL_LINE_HEIGHT3 * labelLineCount;
32779
32959
  let h = labelH + NODE_V_PAD;
32780
32960
  if (text.descLines.length > 0) {
32781
32961
  h += DESC_LINE_HEIGHT3 * text.descLines.length + 4;
@@ -32795,7 +32975,7 @@ function populateDepthCache(roots) {
32795
32975
  };
32796
32976
  walk(roots, 0);
32797
32977
  }
32798
- var ROOT_WIDTH, DEPTH1_WIDTH, LEAF_WIDTH, SINGLE_LABEL_HEIGHT, LABEL_LINE_HEIGHT2, DESC_LINE_HEIGHT3, NODE_V_PAD, H_GAP2, V_GAP2, MARGIN6, MULTI_ROOT_GAP, nodeDepthCache;
32978
+ var ROOT_WIDTH, DEPTH1_WIDTH, LEAF_WIDTH, SINGLE_LABEL_HEIGHT, LABEL_LINE_HEIGHT3, DESC_LINE_HEIGHT3, NODE_V_PAD, H_GAP2, V_GAP2, MARGIN6, MULTI_ROOT_GAP, nodeDepthCache;
32799
32979
  var init_layout6 = __esm({
32800
32980
  "src/mindmap/layout.ts"() {
32801
32981
  "use strict";
@@ -32806,7 +32986,7 @@ var init_layout6 = __esm({
32806
32986
  DEPTH1_WIDTH = 150;
32807
32987
  LEAF_WIDTH = 120;
32808
32988
  SINGLE_LABEL_HEIGHT = 28;
32809
- LABEL_LINE_HEIGHT2 = 18;
32989
+ LABEL_LINE_HEIGHT3 = 18;
32810
32990
  DESC_LINE_HEIGHT3 = 14;
32811
32991
  NODE_V_PAD = 10;
32812
32992
  H_GAP2 = 40;
@@ -33097,18 +33277,18 @@ function renderMindmap(container, parsed, layout, palette, isDark, onClickItem,
33097
33277
  descFontSize
33098
33278
  } = textLayout;
33099
33279
  const labelLineCount = labelLines.length;
33100
- const labelZoneH = labelLineCount <= 1 ? SINGLE_LABEL_HEIGHT2 : LABEL_LINE_HEIGHT3 * labelLineCount;
33280
+ const labelZoneH = labelLineCount <= 1 ? SINGLE_LABEL_HEIGHT2 : LABEL_LINE_HEIGHT4 * labelLineCount;
33101
33281
  const labelZoneHeight = showDesc ? labelZoneH : node.height;
33102
33282
  const centerX = node.x + node.width / 2;
33103
33283
  if (labelLineCount <= 1) {
33104
33284
  const labelY = node.y + labelZoneHeight / 2 + fontSize * 0.35;
33105
33285
  nodeG.append("text").attr("x", centerX).attr("y", labelY).attr("text-anchor", "middle").attr("font-size", fontSize).attr("font-weight", isRoot ? "bold" : "normal").attr("fill", onFillText).text(labelLines[0]);
33106
33286
  } else {
33107
- const blockH = LABEL_LINE_HEIGHT3 * (labelLineCount - 1);
33287
+ const blockH = LABEL_LINE_HEIGHT4 * (labelLineCount - 1);
33108
33288
  const firstBaselineY = node.y + labelZoneHeight / 2 - blockH / 2 + fontSize * 0.35;
33109
33289
  const textEl = nodeG.append("text").attr("x", centerX).attr("text-anchor", "middle").attr("font-size", fontSize).attr("font-weight", isRoot ? "bold" : "normal").attr("fill", onFillText);
33110
33290
  for (let i = 0; i < labelLines.length; i++) {
33111
- textEl.append("tspan").attr("x", centerX).attr("y", firstBaselineY + i * LABEL_LINE_HEIGHT3).text(labelLines[i]);
33291
+ textEl.append("tspan").attr("x", centerX).attr("y", firstBaselineY + i * LABEL_LINE_HEIGHT4).text(labelLines[i]);
33112
33292
  }
33113
33293
  }
33114
33294
  if (labelLines.length > 1 || labelLines[0] !== node.label) {
@@ -33183,7 +33363,7 @@ function renderMindmapForExport(content, theme, palette) {
33183
33363
  return extractExportSvg(container, theme);
33184
33364
  });
33185
33365
  }
33186
- var d3Selection12, DIAGRAM_PADDING7, TITLE_HEIGHT4, SINGLE_LABEL_HEIGHT2, LABEL_LINE_HEIGHT3, DESC_LINE_HEIGHT4, NODE_RADIUS, ROOT_STROKE_WIDTH, DEPTH_COLOR_KEYS;
33366
+ var d3Selection12, DIAGRAM_PADDING7, TITLE_HEIGHT4, SINGLE_LABEL_HEIGHT2, LABEL_LINE_HEIGHT4, DESC_LINE_HEIGHT4, NODE_RADIUS, ROOT_STROKE_WIDTH, DEPTH_COLOR_KEYS;
33187
33367
  var init_renderer7 = __esm({
33188
33368
  "src/mindmap/renderer.ts"() {
33189
33369
  "use strict";
@@ -33206,7 +33386,7 @@ var init_renderer7 = __esm({
33206
33386
  DIAGRAM_PADDING7 = 20;
33207
33387
  TITLE_HEIGHT4 = 30;
33208
33388
  SINGLE_LABEL_HEIGHT2 = 28;
33209
- LABEL_LINE_HEIGHT3 = 18;
33389
+ LABEL_LINE_HEIGHT4 = 18;
33210
33390
  DESC_LINE_HEIGHT4 = 14;
33211
33391
  NODE_RADIUS = 6;
33212
33392
  ROOT_STROKE_WIDTH = 2.5;
@@ -35873,7 +36053,7 @@ function renderC4Context(container, parsed, layout, palette, isDark, onClickItem
35873
36053
  const labelText = edge.label ?? "";
35874
36054
  const techText = edge.technology ? `[${edge.technology}]` : "";
35875
36055
  const textW = Math.max(
35876
- measureText(labelText, EDGE_LABEL_FONT_SIZE6),
36056
+ measureText(labelText, EDGE_LABEL_FONT_SIZE7),
35877
36057
  measureText(techText, TECH_FONT_SIZE)
35878
36058
  );
35879
36059
  const bgW = textW + 12;
@@ -35884,7 +36064,7 @@ function renderC4Context(container, parsed, layout, palette, isDark, onClickItem
35884
36064
  textY = midPt.y - 4;
35885
36065
  }
35886
36066
  if (labelText) {
35887
- edgeG.append("text").attr("x", midPt.x).attr("y", textY + 4).attr("text-anchor", "middle").attr("fill", edgeColor3).attr("font-size", EDGE_LABEL_FONT_SIZE6).attr("class", "c4-edge-label").text(labelText);
36067
+ edgeG.append("text").attr("x", midPt.x).attr("y", textY + 4).attr("text-anchor", "middle").attr("fill", edgeColor3).attr("font-size", EDGE_LABEL_FONT_SIZE7).attr("class", "c4-edge-label").text(labelText);
35888
36068
  }
35889
36069
  if (techText) {
35890
36070
  edgeG.append("text").attr("x", midPt.x).attr("y", labelText ? textY + 18 : textY + 4).attr("text-anchor", "middle").attr("fill", edgeColor3).attr("font-size", TECH_FONT_SIZE).attr("font-style", "italic").attr("class", "c4-edge-tech").text(techText);
@@ -36068,7 +36248,7 @@ function renderEdges(contentG, edges, palette, onClickItem, obstacleRects) {
36068
36248
  const labelText = edge.label ?? "";
36069
36249
  const techText = edge.technology ? `[${edge.technology}]` : "";
36070
36250
  const textW = Math.max(
36071
- measureText(labelText, EDGE_LABEL_FONT_SIZE6),
36251
+ measureText(labelText, EDGE_LABEL_FONT_SIZE7),
36072
36252
  measureText(techText, TECH_FONT_SIZE)
36073
36253
  );
36074
36254
  const bgW = textW + 12;
@@ -36086,7 +36266,7 @@ function renderEdges(contentG, edges, palette, onClickItem, obstacleRects) {
36086
36266
  });
36087
36267
  }
36088
36268
  }
36089
- placeEdgeLabels(pendingLabels, edges, obstacleRects);
36269
+ placeEdgeLabels2(pendingLabels, edges, obstacleRects);
36090
36270
  for (const lbl of pendingLabels) {
36091
36271
  lbl.edgeG.append("rect").attr("x", lbl.x - lbl.bgW / 2).attr("y", lbl.y - lbl.bgH / 2).attr("width", lbl.bgW).attr("height", lbl.bgH).attr("rx", 3).attr("fill", palette.bg).attr("opacity", 0.9).attr("class", "c4-edge-label-bg");
36092
36272
  let textY = lbl.y;
@@ -36094,7 +36274,7 @@ function renderEdges(contentG, edges, palette, onClickItem, obstacleRects) {
36094
36274
  textY = lbl.y - 4;
36095
36275
  }
36096
36276
  if (lbl.labelText) {
36097
- lbl.edgeG.append("text").attr("x", lbl.x).attr("y", textY + 4).attr("text-anchor", "middle").attr("fill", lbl.edgeColor).attr("font-size", EDGE_LABEL_FONT_SIZE6).attr("class", "c4-edge-label").text(lbl.labelText);
36277
+ lbl.edgeG.append("text").attr("x", lbl.x).attr("y", textY + 4).attr("text-anchor", "middle").attr("fill", lbl.edgeColor).attr("font-size", EDGE_LABEL_FONT_SIZE7).attr("class", "c4-edge-label").text(lbl.labelText);
36098
36278
  }
36099
36279
  if (lbl.techText) {
36100
36280
  lbl.edgeG.append("text").attr("x", lbl.x).attr("y", lbl.labelText ? textY + 18 : textY + 4).attr("text-anchor", "middle").attr("fill", lbl.edgeColor).attr("font-size", TECH_FONT_SIZE).attr("font-style", "italic").attr("class", "c4-edge-tech").text(lbl.techText);
@@ -36175,7 +36355,7 @@ function tangentAt(points, t) {
36175
36355
  }
36176
36356
  return { x: 0, y: 1 };
36177
36357
  }
36178
- function placeEdgeLabels(labels, edges, obstacleRects) {
36358
+ function placeEdgeLabels2(labels, edges, obstacleRects) {
36179
36359
  if (labels.length === 0) return;
36180
36360
  const allPaths = edges.map((e) => e.points);
36181
36361
  const placedRects = [];
@@ -36713,7 +36893,7 @@ function renderC4DeploymentForExport(content, theme, palette) {
36713
36893
  document.body.removeChild(el);
36714
36894
  }
36715
36895
  }
36716
- var d3Selection14, d3Shape6, DIAGRAM_PADDING8, MAX_SCALE5, TITLE_HEIGHT6, TYPE_FONT_SIZE, NAME_FONT_SIZE2, DESC_FONT_SIZE5, DESC_LINE_HEIGHT6, EDGE_LABEL_FONT_SIZE6, TECH_FONT_SIZE, CARD_H_PAD4, CARD_V_PAD4, TYPE_LABEL_HEIGHT2, DIVIDER_GAP2, NAME_HEIGHT2, BOUNDARY_LABEL_FONT_SIZE, BOUNDARY_STROKE_WIDTH, BOUNDARY_RADIUS, DRILL_BAR_HEIGHT, CYLINDER_RY, PERSON_HEAD_R, PERSON_ARM_SPAN, PERSON_LEG_SPAN, PERSON_ICON_W, PERSON_SW, lineGenerator4;
36896
+ var d3Selection14, d3Shape6, DIAGRAM_PADDING8, MAX_SCALE5, TITLE_HEIGHT6, TYPE_FONT_SIZE, NAME_FONT_SIZE2, DESC_FONT_SIZE5, DESC_LINE_HEIGHT6, EDGE_LABEL_FONT_SIZE7, TECH_FONT_SIZE, CARD_H_PAD4, CARD_V_PAD4, TYPE_LABEL_HEIGHT2, DIVIDER_GAP2, NAME_HEIGHT2, BOUNDARY_LABEL_FONT_SIZE, BOUNDARY_STROKE_WIDTH, BOUNDARY_RADIUS, DRILL_BAR_HEIGHT, CYLINDER_RY, PERSON_HEAD_R, PERSON_ARM_SPAN, PERSON_LEG_SPAN, PERSON_ICON_W, PERSON_SW, lineGenerator4;
36717
36897
  var init_renderer9 = __esm({
36718
36898
  "src/c4/renderer.ts"() {
36719
36899
  "use strict";
@@ -36738,7 +36918,7 @@ var init_renderer9 = __esm({
36738
36918
  NAME_FONT_SIZE2 = 14;
36739
36919
  DESC_FONT_SIZE5 = 11;
36740
36920
  DESC_LINE_HEIGHT6 = 16;
36741
- EDGE_LABEL_FONT_SIZE6 = 11;
36921
+ EDGE_LABEL_FONT_SIZE7 = 11;
36742
36922
  TECH_FONT_SIZE = 10;
36743
36923
  CARD_H_PAD4 = 20;
36744
36924
  CARD_V_PAD4 = 14;
@@ -37362,7 +37542,7 @@ function renderFlowchart(container, graph, layout, palette, isDark, onClickItem,
37362
37542
  const sTitleFontSize = ctx.text(TITLE_FONT_SIZE);
37363
37543
  const sTitleY = ctx.structural(TITLE_Y);
37364
37544
  const sNodeFontSize = ctx.text(NODE_FONT_SIZE2);
37365
- const sEdgeLabelFontSize = ctx.text(EDGE_LABEL_FONT_SIZE7);
37545
+ const sEdgeLabelFontSize = ctx.text(EDGE_LABEL_FONT_SIZE8);
37366
37546
  const sEdgeStrokeWidth = ctx.structural(EDGE_STROKE_WIDTH);
37367
37547
  const sNodeStrokeWidth = ctx.structural(NODE_STROKE_WIDTH);
37368
37548
  const sArrowheadW = ctx.structural(ARROWHEAD_W3);
@@ -37588,7 +37768,7 @@ function renderFlowchartForExport(content, theme, palette) {
37588
37768
  document.body.removeChild(container);
37589
37769
  }
37590
37770
  }
37591
- var d3Selection15, DIAGRAM_PADDING9, MAX_SCALE6, NODE_FONT_SIZE2, EDGE_LABEL_FONT_SIZE7, ARROWHEAD_W3, ARROWHEAD_H3, IO_SKEW, SUBROUTINE_INSET, DOC_WAVE_HEIGHT;
37771
+ var d3Selection15, DIAGRAM_PADDING9, MAX_SCALE6, NODE_FONT_SIZE2, EDGE_LABEL_FONT_SIZE8, ARROWHEAD_W3, ARROWHEAD_H3, IO_SKEW, SUBROUTINE_INSET, DOC_WAVE_HEIGHT;
37592
37772
  var init_flowchart_renderer = __esm({
37593
37773
  "src/graph/flowchart-renderer.ts"() {
37594
37774
  "use strict";
@@ -37608,7 +37788,7 @@ var init_flowchart_renderer = __esm({
37608
37788
  DIAGRAM_PADDING9 = 20;
37609
37789
  MAX_SCALE6 = 3;
37610
37790
  NODE_FONT_SIZE2 = 13;
37611
- EDGE_LABEL_FONT_SIZE7 = 11;
37791
+ EDGE_LABEL_FONT_SIZE8 = 11;
37612
37792
  ARROWHEAD_W3 = 10;
37613
37793
  ARROWHEAD_H3 = 7;
37614
37794
  IO_SKEW = 15;
@@ -39042,7 +39222,7 @@ function layoutInfra(computed, expandedNodeIds, collapsedNodes) {
39042
39222
  const midIdx = Math.floor(edge.points.length / 2);
39043
39223
  const midPt = edge.points[midIdx];
39044
39224
  if (midPt) {
39045
- const halfWidth = (measureText(edge.label, EDGE_LABEL_FONT_SIZE8) + 8) / 2;
39225
+ const halfWidth = (measureText(edge.label, EDGE_LABEL_FONT_SIZE9) + 8) / 2;
39046
39226
  if (midPt.x - halfWidth < minX) minX = midPt.x - halfWidth;
39047
39227
  if (midPt.x + halfWidth > maxX) maxX = midPt.x + halfWidth;
39048
39228
  }
@@ -39076,7 +39256,7 @@ function layoutInfra(computed, expandedNodeIds, collapsedNodes) {
39076
39256
  height: totalHeight
39077
39257
  };
39078
39258
  }
39079
- var import_dagre7, MIN_NODE_WIDTH2, NODE_HEADER_HEIGHT, META_LINE_HEIGHT5, NODE_SEPARATOR_GAP, NODE_PAD_BOTTOM, ROLE_DOT_ROW, COLLAPSE_BAR_HEIGHT3, NODE_FONT_SIZE3, META_FONT_SIZE5, EDGE_LABEL_FONT_SIZE8, PADDING_X3, GROUP_PADDING2, GROUP_HEADER_HEIGHT, EDGE_MARGIN, DISPLAY_KEYS, DISPLAY_NAMES, GROUP_GAP2;
39259
+ var import_dagre7, MIN_NODE_WIDTH2, NODE_HEADER_HEIGHT, META_LINE_HEIGHT5, NODE_SEPARATOR_GAP, NODE_PAD_BOTTOM, ROLE_DOT_ROW, COLLAPSE_BAR_HEIGHT3, NODE_FONT_SIZE3, META_FONT_SIZE5, EDGE_LABEL_FONT_SIZE9, PADDING_X3, GROUP_PADDING2, GROUP_HEADER_HEIGHT, EDGE_MARGIN, DISPLAY_KEYS, DISPLAY_NAMES, GROUP_GAP2;
39080
39260
  var init_layout10 = __esm({
39081
39261
  "src/infra/layout.ts"() {
39082
39262
  "use strict";
@@ -39091,7 +39271,7 @@ var init_layout10 = __esm({
39091
39271
  COLLAPSE_BAR_HEIGHT3 = 6;
39092
39272
  NODE_FONT_SIZE3 = 13;
39093
39273
  META_FONT_SIZE5 = 10;
39094
- EDGE_LABEL_FONT_SIZE8 = 11;
39274
+ EDGE_LABEL_FONT_SIZE9 = 11;
39095
39275
  PADDING_X3 = 24;
39096
39276
  GROUP_PADDING2 = 20;
39097
39277
  GROUP_HEADER_HEIGHT = 24;
@@ -39196,7 +39376,7 @@ function buildScaledConstants(ctx) {
39196
39376
  sNodeFontSize: ctx.text(NODE_FONT_SIZE4),
39197
39377
  sMetaFontSize: ctx.text(META_FONT_SIZE6),
39198
39378
  sMetaLineHeight: ctx.structural(META_LINE_HEIGHT6),
39199
- sEdgeLabelFontSize: ctx.text(EDGE_LABEL_FONT_SIZE9),
39379
+ sEdgeLabelFontSize: ctx.text(EDGE_LABEL_FONT_SIZE10),
39200
39380
  sGroupLabelFontSize: ctx.text(GROUP_LABEL_FONT_SIZE2),
39201
39381
  sNodeBorderRadius: ctx.structural(NODE_BORDER_RADIUS),
39202
39382
  sEdgeStrokeWidth: ctx.structural(EDGE_STROKE_WIDTH),
@@ -39925,7 +40105,7 @@ function renderEdgeLabels(svg, edges, nodes, groups, palette, _isDark, animate,
39925
40105
  if (!midPt) continue;
39926
40106
  const labelText = edge.label;
39927
40107
  const g = svg.append("g").attr("class", animate ? "infra-edge-label" : "");
39928
- const textWidth = measureText(labelText, EDGE_LABEL_FONT_SIZE9) + 8;
40108
+ const textWidth = measureText(labelText, EDGE_LABEL_FONT_SIZE10) + 8;
39929
40109
  g.append("rect").attr("x", midPt.x - textWidth / 2).attr("y", midPt.y - 8).attr("width", textWidth).attr("height", 16).attr("rx", 3).attr("fill", palette.bg).attr("opacity", 0.9);
39930
40110
  g.append("text").attr("x", midPt.x).attr("y", midPt.y + 4).attr("text-anchor", "middle").attr("font-family", FONT_FAMILY).attr("font-size", sc.sEdgeLabelFontSize).attr("fill", palette.textMuted).text(labelText);
39931
40111
  if (animate) {
@@ -40535,7 +40715,7 @@ function parseAndLayoutInfra(content) {
40535
40715
  const layout = layoutInfra(computed);
40536
40716
  return { parsed, computed, layout };
40537
40717
  }
40538
- var d3Selection16, d3Shape8, NODE_FONT_SIZE4, META_FONT_SIZE6, META_LINE_HEIGHT6, EDGE_LABEL_FONT_SIZE9, GROUP_LABEL_FONT_SIZE2, NODE_BORDER_RADIUS, OVERLOAD_STROKE_WIDTH, ROLE_DOT_RADIUS, NODE_HEADER_HEIGHT2, NODE_SEPARATOR_GAP2, NODE_PAD_BOTTOM2, LEGEND_FIXED_GAP3, SPEED_BADGE_H_PAD, SPEED_BADGE_V_PAD, SPEED_BADGE_GAP, COLOR_HEALTHY, COLOR_WARNING, COLOR_OVERLOADED, FLOW_SPEED_MIN, FLOW_SPEED_MAX, PARTICLE_R, PARTICLE_COUNT_MIN, PARTICLE_COUNT_MAX, NODE_PULSE_SPEED, NODE_PULSE_OVERLOAD, REJECT_DROP_DISTANCE, REJECT_DURATION_MIN, REJECT_DURATION_MAX, REJECT_COUNT_MIN, REJECT_COUNT_MAX, PROP_DISPLAY, DESC_MAX_CHARS, DESC_MAX_WIDTH, RPS_FORMAT_KEYS, MS_FORMAT_KEYS, PCT_FORMAT_KEYS;
40718
+ var d3Selection16, d3Shape8, NODE_FONT_SIZE4, META_FONT_SIZE6, META_LINE_HEIGHT6, EDGE_LABEL_FONT_SIZE10, GROUP_LABEL_FONT_SIZE2, NODE_BORDER_RADIUS, OVERLOAD_STROKE_WIDTH, ROLE_DOT_RADIUS, NODE_HEADER_HEIGHT2, NODE_SEPARATOR_GAP2, NODE_PAD_BOTTOM2, LEGEND_FIXED_GAP3, SPEED_BADGE_H_PAD, SPEED_BADGE_V_PAD, SPEED_BADGE_GAP, COLOR_HEALTHY, COLOR_WARNING, COLOR_OVERLOADED, FLOW_SPEED_MIN, FLOW_SPEED_MAX, PARTICLE_R, PARTICLE_COUNT_MIN, PARTICLE_COUNT_MAX, NODE_PULSE_SPEED, NODE_PULSE_OVERLOAD, REJECT_DROP_DISTANCE, REJECT_DURATION_MIN, REJECT_DURATION_MAX, REJECT_COUNT_MIN, REJECT_COUNT_MAX, PROP_DISPLAY, DESC_MAX_CHARS, DESC_MAX_WIDTH, RPS_FORMAT_KEYS, MS_FORMAT_KEYS, PCT_FORMAT_KEYS;
40539
40719
  var init_renderer10 = __esm({
40540
40720
  "src/infra/renderer.ts"() {
40541
40721
  "use strict";
@@ -40561,7 +40741,7 @@ var init_renderer10 = __esm({
40561
40741
  NODE_FONT_SIZE4 = 13;
40562
40742
  META_FONT_SIZE6 = 10;
40563
40743
  META_LINE_HEIGHT6 = 14;
40564
- EDGE_LABEL_FONT_SIZE9 = 11;
40744
+ EDGE_LABEL_FONT_SIZE10 = 11;
40565
40745
  GROUP_LABEL_FONT_SIZE2 = 14;
40566
40746
  NODE_BORDER_RADIUS = 8;
40567
40747
  OVERLOAD_STROKE_WIDTH = 3;
@@ -46949,7 +47129,7 @@ function renderState(container, graph, layout, palette, isDark, onClickItem, exp
46949
47129
  const sTitleFontSize = ctx.text(TITLE_FONT_SIZE);
46950
47130
  const sTitleY = ctx.structural(TITLE_Y);
46951
47131
  const sNodeFontSize = ctx.text(NODE_FONT_SIZE6);
46952
- const sEdgeLabelFontSize = ctx.text(EDGE_LABEL_FONT_SIZE10);
47132
+ const sEdgeLabelFontSize = ctx.text(EDGE_LABEL_FONT_SIZE11);
46953
47133
  const sGroupLabelFontSize = ctx.text(GROUP_LABEL_FONT_SIZE3);
46954
47134
  const sEdgeStrokeWidth = ctx.structural(EDGE_STROKE_WIDTH);
46955
47135
  const sNodeStrokeWidth = ctx.structural(NODE_STROKE_WIDTH);
@@ -47229,7 +47409,7 @@ function renderStateForExport(content, theme, palette) {
47229
47409
  document.body.removeChild(container);
47230
47410
  }
47231
47411
  }
47232
- var d3Selection19, DIAGRAM_PADDING12, MAX_SCALE7, NODE_FONT_SIZE6, EDGE_LABEL_FONT_SIZE10, GROUP_LABEL_FONT_SIZE3, ARROWHEAD_W5, ARROWHEAD_H5, PSEUDOSTATE_RADIUS, STATE_CORNER_RADIUS, GROUP_EXTRA_PADDING;
47412
+ var d3Selection19, DIAGRAM_PADDING12, MAX_SCALE7, NODE_FONT_SIZE6, EDGE_LABEL_FONT_SIZE11, GROUP_LABEL_FONT_SIZE3, ARROWHEAD_W5, ARROWHEAD_H5, PSEUDOSTATE_RADIUS, STATE_CORNER_RADIUS, GROUP_EXTRA_PADDING;
47233
47413
  var init_state_renderer = __esm({
47234
47414
  "src/graph/state-renderer.ts"() {
47235
47415
  "use strict";
@@ -47249,7 +47429,7 @@ var init_state_renderer = __esm({
47249
47429
  DIAGRAM_PADDING12 = 20;
47250
47430
  MAX_SCALE7 = 3;
47251
47431
  NODE_FONT_SIZE6 = 13;
47252
- EDGE_LABEL_FONT_SIZE10 = 11;
47432
+ EDGE_LABEL_FONT_SIZE11 = 11;
47253
47433
  GROUP_LABEL_FONT_SIZE3 = 11;
47254
47434
  ARROWHEAD_W5 = 10;
47255
47435
  ARROWHEAD_H5 = 7;
@@ -50071,10 +50251,10 @@ function renderedDescNodeHeight(numLines, scale) {
50071
50251
  return headerH + textBlockH + bottomPad;
50072
50252
  }
50073
50253
  function wrapEdgeLabelText(label, description, maxWidth = EDGE_LABEL_MAX_WIDTH) {
50074
- const labelLines = label ? wrapTextToWidth(label, EDGE_LABEL_FONT_SIZE11, maxWidth) : [];
50254
+ const labelLines = label ? wrapTextToWidth(label, EDGE_LABEL_FONT_SIZE12, maxWidth) : [];
50075
50255
  const descLines = [];
50076
50256
  for (const d of description) {
50077
- descLines.push(...wrapTextToWidth(d, EDGE_LABEL_FONT_SIZE11, maxWidth));
50257
+ descLines.push(...wrapTextToWidth(d, EDGE_LABEL_FONT_SIZE12, maxWidth));
50078
50258
  }
50079
50259
  return { labelLines, descLines };
50080
50260
  }
@@ -50212,9 +50392,9 @@ function computeEdgePaths(layoutNodes, parsed, cx, cy, radius, isClockwise) {
50212
50392
  const lineCount = labelLines.length + descLines.length;
50213
50393
  let labelPxW = 0;
50214
50394
  for (const l of labelLines)
50215
- labelPxW = Math.max(labelPxW, measureText(l, EDGE_LABEL_FONT_SIZE11));
50395
+ labelPxW = Math.max(labelPxW, measureText(l, EDGE_LABEL_FONT_SIZE12));
50216
50396
  for (const l of descLines)
50217
- labelPxW = Math.max(labelPxW, measureText(l, EDGE_LABEL_FONT_SIZE11));
50397
+ labelPxW = Math.max(labelPxW, measureText(l, EDGE_LABEL_FONT_SIZE12));
50218
50398
  const { labelX, labelY, labelAngle } = computeEdgeLabelPosition(
50219
50399
  midAngle,
50220
50400
  radius,
@@ -50316,9 +50496,9 @@ function fitToCanvas(nodes, edges, parsed, _cx, _cy, radius, width, height, _isC
50316
50496
  );
50317
50497
  let textWidth = 0;
50318
50498
  for (const l of labelLines)
50319
- textWidth = Math.max(textWidth, measureText(l, EDGE_LABEL_FONT_SIZE11));
50499
+ textWidth = Math.max(textWidth, measureText(l, EDGE_LABEL_FONT_SIZE12));
50320
50500
  for (const l of descLines)
50321
- textWidth = Math.max(textWidth, measureText(l, EDGE_LABEL_FONT_SIZE11));
50501
+ textWidth = Math.max(textWidth, measureText(l, EDGE_LABEL_FONT_SIZE12));
50322
50502
  if (textWidth === 0) continue;
50323
50503
  const normAngle = (le.labelAngle % (2 * Math.PI) + 2 * Math.PI) % (2 * Math.PI);
50324
50504
  const isRight = normAngle < Math.PI * 0.4 || normAngle > Math.PI * 1.6;
@@ -50392,7 +50572,7 @@ function buildEdgeArc(src, tgt, cx, cy, radius, isClockwise, arrowLength = 0) {
50392
50572
  const midAngle = srcExitAngle + dir * visibleSweep / 2;
50393
50573
  return { path, midAngle };
50394
50574
  }
50395
- var MIN_ARC_ANGLE, LABEL_FONT_SIZE4, CIRCLE_LABEL_FONT_SIZE, DESC_FONT_SIZE6, EDGE_LABEL_FONT_SIZE11, MIN_NODE_WIDTH4, MAX_NODE_WIDTH3, DESC_MIN_WIDTH, DESC_WIDTH_STEP, DESC_TARGET_RATIO, PLAIN_NODE_HEIGHT, HEADER_HEIGHT4, DESC_LINE_HEIGHT7, DESC_PAD_Y, NODE_PAD_X, MIN_CIRCLE_RADIUS, CIRCLE_PAD, RENDERER_DESC_FONT, RENDERER_DESC_FONT_MIN, RENDERER_DESC_LINE_H, RENDERER_DESC_LINE_H_MIN, EDGE_LABEL_MAX_WIDTH;
50575
+ var MIN_ARC_ANGLE, LABEL_FONT_SIZE4, CIRCLE_LABEL_FONT_SIZE, DESC_FONT_SIZE6, EDGE_LABEL_FONT_SIZE12, MIN_NODE_WIDTH4, MAX_NODE_WIDTH3, DESC_MIN_WIDTH, DESC_WIDTH_STEP, DESC_TARGET_RATIO, PLAIN_NODE_HEIGHT, HEADER_HEIGHT4, DESC_LINE_HEIGHT7, DESC_PAD_Y, NODE_PAD_X, MIN_CIRCLE_RADIUS, CIRCLE_PAD, RENDERER_DESC_FONT, RENDERER_DESC_FONT_MIN, RENDERER_DESC_LINE_H, RENDERER_DESC_LINE_H_MIN, EDGE_LABEL_MAX_WIDTH;
50396
50576
  var init_layout14 = __esm({
50397
50577
  "src/cycle/layout.ts"() {
50398
50578
  "use strict";
@@ -50403,7 +50583,7 @@ var init_layout14 = __esm({
50403
50583
  LABEL_FONT_SIZE4 = 13;
50404
50584
  CIRCLE_LABEL_FONT_SIZE = 16;
50405
50585
  DESC_FONT_SIZE6 = 11;
50406
- EDGE_LABEL_FONT_SIZE11 = 11;
50586
+ EDGE_LABEL_FONT_SIZE12 = 11;
50407
50587
  MIN_NODE_WIDTH4 = 70;
50408
50588
  MAX_NODE_WIDTH3 = 260;
50409
50589
  DESC_MIN_WIDTH = 140;
@@ -50548,7 +50728,7 @@ function renderCycle(container, parsed, palette, isDark, onClickItem, exportDims
50548
50728
  const scaledNodeFont = Math.max(6, Math.round(NODE_FONT_SIZE7 * layout.scale));
50549
50729
  const scaledEdgeLabelFont = Math.max(
50550
50730
  6,
50551
- Math.round(EDGE_LABEL_FONT_SIZE12 * layout.scale)
50731
+ Math.round(EDGE_LABEL_FONT_SIZE13 * layout.scale)
50552
50732
  );
50553
50733
  const CIRCLE_LABEL_FONT_SIZE2 = 16;
50554
50734
  const scaledCircleLabelFont = Math.max(
@@ -50711,7 +50891,7 @@ function ensureArrowMarker(defs, color, strokeWidth) {
50711
50891
  const mh = Math.max(1.5, mw * 0.5);
50712
50892
  defs.append("marker").attr("id", id).attr("viewBox", `0 0 ${mw} ${mh}`).attr("refX", mw * 0.1).attr("refY", mh / 2).attr("markerWidth", mw).attr("markerHeight", mh).attr("orient", "auto").append("polygon").attr("points", `0,0 ${mw},${mh / 2} 0,${mh}`).attr("fill", color);
50713
50893
  }
50714
- var d3Selection22, NODE_FONT_SIZE7, DESC_FONT_SIZE7, EDGE_LABEL_FONT_SIZE12, DESC_LINE_HEIGHT8, TITLE_AREA_HEIGHT;
50894
+ var d3Selection22, NODE_FONT_SIZE7, DESC_FONT_SIZE7, EDGE_LABEL_FONT_SIZE13, DESC_LINE_HEIGHT8, TITLE_AREA_HEIGHT;
50715
50895
  var init_renderer15 = __esm({
50716
50896
  "src/cycle/renderer.ts"() {
50717
50897
  "use strict";
@@ -50729,7 +50909,7 @@ var init_renderer15 = __esm({
50729
50909
  init_text_measure();
50730
50910
  NODE_FONT_SIZE7 = 13;
50731
50911
  DESC_FONT_SIZE7 = 11;
50732
- EDGE_LABEL_FONT_SIZE12 = 11;
50912
+ EDGE_LABEL_FONT_SIZE13 = 11;
50733
50913
  DESC_LINE_HEIGHT8 = 15;
50734
50914
  TITLE_AREA_HEIGHT = 50;
50735
50915
  }
@@ -63998,7 +64178,7 @@ pre.dgmo, code.language-dgmo, pre > code.language-dgmo,
63998
64178
 
63999
64179
  // src/auto/index.ts
64000
64180
  init_safe_href();
64001
- var VERSION = "0.33.0";
64181
+ var VERSION = "0.34.0";
64002
64182
  var DEFAULTS = {
64003
64183
  theme: "auto",
64004
64184
  palette: "slate",