compasso 0.4.0 → 0.5.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.
Files changed (100) hide show
  1. package/README.md +115 -5
  2. package/dist/{chunk-ZBDABVIO.js → chunk-2NDET6O5.js} +3 -3
  3. package/dist/{chunk-ZBDABVIO.js.map → chunk-2NDET6O5.js.map} +1 -1
  4. package/dist/{chunk-Q6DVTCXD.js → chunk-3RGYLVTN.js} +18 -6
  5. package/dist/chunk-3RGYLVTN.js.map +1 -0
  6. package/dist/chunk-BM7UJBK5.js +680 -0
  7. package/dist/chunk-BM7UJBK5.js.map +1 -0
  8. package/dist/chunk-DVLWT565.js +372 -0
  9. package/dist/chunk-DVLWT565.js.map +1 -0
  10. package/dist/{chunk-F47C6ZEB.js → chunk-JBDA7E2O.js} +3 -3
  11. package/dist/{chunk-F47C6ZEB.js.map → chunk-JBDA7E2O.js.map} +1 -1
  12. package/dist/chunk-MIJTBYX2.js +982 -0
  13. package/dist/chunk-MIJTBYX2.js.map +1 -0
  14. package/dist/{chunk-JP4N42AY.js → chunk-PJHLWSGD.js} +3 -3
  15. package/dist/{chunk-JP4N42AY.js.map → chunk-PJHLWSGD.js.map} +1 -1
  16. package/dist/{chunk-LRHHUJFZ.js → chunk-RDH4XHA2.js} +3 -3
  17. package/dist/{chunk-LRHHUJFZ.js.map → chunk-RDH4XHA2.js.map} +1 -1
  18. package/dist/{chunk-UJVU7B44.js → chunk-WEHUSHVI.js} +31 -51
  19. package/dist/chunk-WEHUSHVI.js.map +1 -0
  20. package/dist/{chunk-RWPGGWO5.js → chunk-Z66YUOUM.js} +34 -10
  21. package/dist/chunk-Z66YUOUM.js.map +1 -0
  22. package/dist/core/index.cjs +247 -0
  23. package/dist/core/index.cjs.map +1 -1
  24. package/dist/core/index.d.cts +94 -2
  25. package/dist/core/index.d.ts +94 -2
  26. package/dist/core/index.js +1 -1
  27. package/dist/ecomap/index.cjs +34 -11
  28. package/dist/ecomap/index.cjs.map +1 -1
  29. package/dist/ecomap/index.d.cts +12 -0
  30. package/dist/ecomap/index.d.ts +12 -0
  31. package/dist/ecomap/index.js +2 -2
  32. package/dist/fault-tree/index.d.cts +2 -2
  33. package/dist/fault-tree/index.d.ts +2 -2
  34. package/dist/fault-tree/index.js +2 -2
  35. package/dist/fishbone/index.js +2 -2
  36. package/dist/genogram/index.cjs +57 -7
  37. package/dist/genogram/index.cjs.map +1 -1
  38. package/dist/genogram/index.d.cts +22 -6
  39. package/dist/genogram/index.d.ts +22 -6
  40. package/dist/genogram/index.js +2 -2
  41. package/dist/geometry-P-XGqGe7.d.cts +8 -0
  42. package/dist/geometry-P-XGqGe7.d.ts +8 -0
  43. package/dist/grid-BMgUSly1.d.cts +79 -0
  44. package/dist/grid-BMgUSly1.d.ts +79 -0
  45. package/dist/index.cjs +2360 -395
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.d.cts +14 -7
  48. package/dist/index.d.ts +14 -7
  49. package/dist/index.js +10 -8
  50. package/dist/{kinship-DqEklrDN.d.ts → kinship-BF90HyyS.d.ts} +1 -1
  51. package/dist/{kinship-Dy_ijjJV.d.cts → kinship-BOUss5cT.d.cts} +1 -1
  52. package/dist/{labels-RtFw9tX1.d.cts → labels-B0aOMbHy.d.cts} +12 -0
  53. package/dist/{labels-RtFw9tX1.d.ts → labels-B0aOMbHy.d.ts} +12 -0
  54. package/dist/labels-Br8yjc3C.d.cts +29 -0
  55. package/dist/labels-Br8yjc3C.d.ts +29 -0
  56. package/dist/{labels-DNqRkWuI.d.ts → labels-CuLbFyrz.d.ts} +1 -1
  57. package/dist/labels-D1v1RWZd.d.cts +97 -0
  58. package/dist/labels-D1v1RWZd.d.ts +97 -0
  59. package/dist/{labels-CBQ_3Ec9.d.cts → labels-DhQe7I8m.d.cts} +1 -1
  60. package/dist/layered-DmZluAqe.d.cts +72 -0
  61. package/dist/layered-DmZluAqe.d.ts +72 -0
  62. package/dist/locales/pt-br.cjs +53 -0
  63. package/dist/locales/pt-br.cjs.map +1 -1
  64. package/dist/locales/pt-br.d.cts +11 -5
  65. package/dist/locales/pt-br.d.ts +11 -5
  66. package/dist/locales/pt-br.js +50 -1
  67. package/dist/locales/pt-br.js.map +1 -1
  68. package/dist/org-chart/index.cjs +138 -94
  69. package/dist/org-chart/index.cjs.map +1 -1
  70. package/dist/org-chart/index.d.cts +24 -33
  71. package/dist/org-chart/index.d.ts +24 -33
  72. package/dist/org-chart/index.js +2 -2
  73. package/dist/pedigree/index.d.cts +6 -6
  74. package/dist/pedigree/index.d.ts +6 -6
  75. package/dist/pedigree/index.js +2 -2
  76. package/dist/phylo/index.d.cts +2 -2
  77. package/dist/phylo/index.d.ts +2 -2
  78. package/dist/phylo/index.js +2 -2
  79. package/dist/prisma/index.cjs +882 -0
  80. package/dist/prisma/index.cjs.map +1 -0
  81. package/dist/prisma/index.d.cts +174 -0
  82. package/dist/prisma/index.d.ts +174 -0
  83. package/dist/prisma/index.js +4 -0
  84. package/dist/prisma/index.js.map +1 -0
  85. package/dist/{text-DuO_PwYw.d.cts → text-DDVzpwPZ.d.cts} +1 -8
  86. package/dist/{text-DuO_PwYw.d.ts → text-DDVzpwPZ.d.ts} +1 -8
  87. package/dist/{types-BnMG7TCd.d.cts → types-jE2fdM1t.d.cts} +8 -0
  88. package/dist/{types-BnMG7TCd.d.ts → types-jE2fdM1t.d.ts} +8 -0
  89. package/dist/uml/index.cjs +1214 -0
  90. package/dist/uml/index.cjs.map +1 -0
  91. package/dist/uml/index.d.cts +189 -0
  92. package/dist/uml/index.d.ts +189 -0
  93. package/dist/uml/index.js +4 -0
  94. package/dist/uml/index.js.map +1 -0
  95. package/package.json +28 -2
  96. package/dist/chunk-O3BT2O42.js +0 -145
  97. package/dist/chunk-O3BT2O42.js.map +0 -1
  98. package/dist/chunk-Q6DVTCXD.js.map +0 -1
  99. package/dist/chunk-RWPGGWO5.js.map +0 -1
  100. package/dist/chunk-UJVU7B44.js.map +0 -1
@@ -249,6 +249,70 @@ function legendBlock(entries, startY) {
249
249
  var EDGE_STROKE = {
250
250
  distant: { width: 1.5, dash: [4, 4], opacity: 0.55 }};
251
251
 
252
+ // src/core/annotation.ts
253
+ var round = (n) => Math.round(n * 100) / 100;
254
+ var ANNOTATION_INK = "#52525b";
255
+ var DOT_R = 3;
256
+ var TICK_HALF = 3;
257
+ function annotationDot(cx, cy) {
258
+ return `<circle cx="${round(cx)}" cy="${round(cy)}" r="${DOT_R}" fill="${ANNOTATION_INK}" fill-opacity="0.6"/>`;
259
+ }
260
+ function annotationTick(points) {
261
+ if (points.length < 2) return "";
262
+ const i = Math.floor((points.length - 1) / 2);
263
+ const a = points[i];
264
+ const b = points[i + 1] ?? points[i];
265
+ const mx = (a.x + b.x) / 2;
266
+ const my = (a.y + b.y) / 2;
267
+ const horizontal = Math.abs(a.y - b.y) <= Math.abs(a.x - b.x);
268
+ const x1 = horizontal ? mx : mx - TICK_HALF;
269
+ const x2 = horizontal ? mx : mx + TICK_HALF;
270
+ const y1 = horizontal ? my - TICK_HALF : my;
271
+ const y2 = horizontal ? my + TICK_HALF : my;
272
+ return `<line x1="${round(x1)}" y1="${round(y1)}" x2="${round(x2)}" y2="${round(y2)}" stroke="${ANNOTATION_INK}" stroke-width="1.5"/>`;
273
+ }
274
+ function annotationSwatch(x, yCenter) {
275
+ return annotationDot(x + LEGEND_SWATCH_W / 2, yCenter);
276
+ }
277
+
278
+ // src/core/layered.ts
279
+ function packSubtree(node, gaps) {
280
+ const { ownHalfL, ownHalfR, children } = node;
281
+ if (children.length === 0) {
282
+ return { halfL: ownHalfL, halfR: ownHalfR, offsets: [] };
283
+ }
284
+ const xs = [0];
285
+ for (let i = 1; i < children.length; i++) {
286
+ xs.push(xs[i - 1] + children[i - 1].halfR + gaps.siblingGap + children[i].halfL);
287
+ }
288
+ const first = children[0];
289
+ const last = children[children.length - 1];
290
+ const axis = (xs[0] + xs[xs.length - 1]) / 2;
291
+ const offsets = xs.map((x) => x - axis);
292
+ const halfL = Math.max(ownHalfL, axis - (xs[0] - first.halfL));
293
+ const halfR = Math.max(ownHalfR, xs[xs.length - 1] + last.halfR - axis);
294
+ return { halfL, halfR, offsets };
295
+ }
296
+ function allocateLanes(items) {
297
+ const lanes = [];
298
+ for (const it of items) {
299
+ let chosen = -1;
300
+ for (let l = 0; l < lanes.length; l++) {
301
+ if (lanes[l].every((o) => it.hi <= o.lo || it.lo >= o.hi)) {
302
+ chosen = l;
303
+ break;
304
+ }
305
+ }
306
+ if (chosen === -1) {
307
+ chosen = lanes.length;
308
+ lanes.push([]);
309
+ }
310
+ lanes[chosen].push({ lo: it.lo, hi: it.hi });
311
+ it.set(chosen);
312
+ }
313
+ return lanes.length;
314
+ }
315
+
252
316
  // src/org-chart/layout.ts
253
317
  var ORG_LABEL_FONT = 12;
254
318
  var ORG_TITLE_FONT = 10;
@@ -270,26 +334,9 @@ var ORG_BUS_ID_BASE = 2e6;
270
334
  var ORG_DROP_ID_BASE = 3e6;
271
335
  var ORG_ASSIST_ID_BASE = 4e6;
272
336
  var ORG_DOTTED_ID_BASE = 5e6;
273
- var round = (n) => Math.round(n * 100) / 100;
274
- var drawnLeftEdge = (cx, boxW) => round(round(cx) - round(boxW) / 2);
275
- var drawnRightEdge = (cx, boxW) => drawnLeftEdge(cx, boxW) + round(boxW);
276
- function packSubtree(node, gaps) {
277
- const { ownHalfL, ownHalfR, children } = node;
278
- if (children.length === 0) {
279
- return { halfL: ownHalfL, halfR: ownHalfR, offsets: [] };
280
- }
281
- const xs = [0];
282
- for (let i = 1; i < children.length; i++) {
283
- xs.push(xs[i - 1] + children[i - 1].halfR + gaps.siblingGap + children[i].halfL);
284
- }
285
- const first = children[0];
286
- const last = children[children.length - 1];
287
- const axis = (xs[0] + xs[xs.length - 1]) / 2;
288
- const offsets = xs.map((x) => x - axis);
289
- const halfL = Math.max(ownHalfL, axis - (xs[0] - first.halfL));
290
- const halfR = Math.max(ownHalfR, xs[xs.length - 1] + last.halfR - axis);
291
- return { halfL, halfR, offsets };
292
- }
337
+ var round2 = (n) => Math.round(n * 100) / 100;
338
+ var drawnLeftEdge = (cx, boxW) => round2(round2(cx) - round2(boxW) / 2);
339
+ var drawnRightEdge = (cx, boxW) => drawnLeftEdge(cx, boxW) + round2(boxW);
293
340
  function measurePosition(position, maxLabelChars, vacantWord) {
294
341
  const nameLines = position.name === "" ? [] : wrapLabelBalanced(clampLabel(position.name, maxLabelChars), 2);
295
342
  const titleLines = position.title === null ? [] : wrapLabelBalanced(clampLabel(position.title, maxLabelChars), 2);
@@ -440,10 +487,10 @@ function computeOrgChartLayout(input, opts = {}) {
440
487
  const pushNode = (inst) => {
441
488
  nodes.push({
442
489
  positionId: inst.position.id,
443
- cx: round(inst.cx),
444
- top: round(rowTop[inst.depth]),
445
- boxW: round(inst.m.boxW),
446
- boxH: round(inst.m.boxH),
490
+ cx: round2(inst.cx),
491
+ top: round2(rowTop[inst.depth]),
492
+ boxW: round2(inst.m.boxW),
493
+ boxH: round2(inst.m.boxH),
447
494
  style: inst.style,
448
495
  nameLines: inst.m.nameLines,
449
496
  titleLines: inst.m.titleLines,
@@ -451,7 +498,8 @@ function computeOrgChartLayout(input, opts = {}) {
451
498
  vacantMarker: inst.m.vacantMarker,
452
499
  isAssistant: inst.assistReport !== null,
453
500
  depth: inst.depth,
454
- title: inst.title
501
+ title: inst.title,
502
+ annotated: inst.position.annotated ?? false
455
503
  });
456
504
  };
457
505
  const emit = (inst) => {
@@ -465,10 +513,10 @@ function computeOrgChartLayout(input, opts = {}) {
465
513
  const assistMidY = assistTop + a.m.boxH / 2;
466
514
  nodes.push({
467
515
  positionId: a.position.id,
468
- cx: round(a.cx),
469
- top: round(assistTop),
470
- boxW: round(a.m.boxW),
471
- boxH: round(a.m.boxH),
516
+ cx: round2(a.cx),
517
+ top: round2(assistTop),
518
+ boxW: round2(a.m.boxW),
519
+ boxH: round2(a.m.boxH),
472
520
  style: a.style,
473
521
  nameLines: a.m.nameLines,
474
522
  titleLines: a.m.titleLines,
@@ -476,17 +524,19 @@ function computeOrgChartLayout(input, opts = {}) {
476
524
  vacantMarker: a.m.vacantMarker,
477
525
  isAssistant: true,
478
526
  depth: a.depth,
479
- title: a.title
527
+ title: a.title,
528
+ annotated: a.position.annotated ?? false
480
529
  });
481
530
  elements.push({
482
531
  edgeId: ORG_ASSIST_ID_BASE + report.reportId,
483
532
  kind: "assist",
484
533
  points: [
485
- { x: round(inst.cx), y: round(assistMidY) },
486
- { x: drawnRightEdge(a.cx, a.m.boxW), y: round(assistMidY) }
534
+ { x: round2(inst.cx), y: round2(assistMidY) },
535
+ { x: drawnRightEdge(a.cx, a.m.boxW), y: round2(assistMidY) }
487
536
  ],
488
537
  dashed: false,
489
- title: reportTitle("assistant", report.label)
538
+ title: reportTitle("assistant", report.label),
539
+ annotated: report.annotated ?? false
490
540
  });
491
541
  bandY += a.m.boxH + ORG_ASSIST_BAND_DROP;
492
542
  }
@@ -498,11 +548,12 @@ function computeOrgChartLayout(input, opts = {}) {
498
548
  edgeId: ORG_STEM_ID_BASE + inst.position.id,
499
549
  kind: "stem",
500
550
  points: [
501
- { x: round(inst.cx), y: round(boxBottom) },
502
- { x: round(inst.cx), y: round(by) }
551
+ { x: round2(inst.cx), y: round2(boxBottom) },
552
+ { x: round2(inst.cx), y: round2(by) }
503
553
  ],
504
554
  dashed: false,
505
- title: reportTitle("line", null)
555
+ title: reportTitle("line", null),
556
+ annotated: false
506
557
  });
507
558
  const childCxs = inst.lineChildren.map((c) => c.cx);
508
559
  if (inst.lineChildren.length > 1) {
@@ -510,23 +561,28 @@ function computeOrgChartLayout(input, opts = {}) {
510
561
  edgeId: ORG_BUS_ID_BASE + inst.position.id,
511
562
  kind: "bus",
512
563
  points: [
513
- { x: round(Math.min(...childCxs)), y: round(by) },
514
- { x: round(Math.max(...childCxs)), y: round(by) }
564
+ { x: round2(Math.min(...childCxs)), y: round2(by) },
565
+ { x: round2(Math.max(...childCxs)), y: round2(by) }
515
566
  ],
516
567
  dashed: false,
517
- title: reportTitle("line", null)
568
+ title: reportTitle("line", null),
569
+ annotated: false
518
570
  });
519
571
  }
572
+ const lineReports = lineChildIds.get(inst.position.id) ?? [];
573
+ const lineReportByChildId = new Map(lineReports.map((r) => [r.reportId, r]));
520
574
  for (const c of inst.lineChildren) {
575
+ const lineReport = lineReportByChildId.get(c.position.id);
521
576
  elements.push({
522
577
  edgeId: ORG_DROP_ID_BASE + c.position.id,
523
578
  kind: "drop",
524
579
  points: [
525
- { x: round(c.cx), y: round(by) },
526
- { x: round(c.cx), y: round(rowTop[c.depth]) }
580
+ { x: round2(c.cx), y: round2(by) },
581
+ { x: round2(c.cx), y: round2(rowTop[c.depth]) }
527
582
  ],
528
583
  dashed: false,
529
- title: reportTitle("line", null)
584
+ title: reportTitle("line", null),
585
+ annotated: lineReport?.annotated ?? false
530
586
  });
531
587
  }
532
588
  for (const c of inst.lineChildren) emit(c);
@@ -596,13 +652,13 @@ function computeOrgChartLayout(input, opts = {}) {
596
652
  return {
597
653
  r,
598
654
  i,
599
- repMidY: round(nextExitY(r.reportId, rep.midY, rep.boxH)),
600
- mgrMidY: round(nextExitY(r.managerId, mgr.midY, mgr.boxH)),
601
- repBoxEdge: round(rep.boxEdge),
602
- mgrBoxEdge: round(mgr.boxEdge),
603
- repChY: round(channelTop + 2 * i * ORG_MATRIX_LANE_PITCH),
604
- mgrChY: round(channelTop + (2 * i + 1) * ORG_MATRIX_LANE_PITCH),
605
- laneX: round(canvasRight + ORG_MATRIX_GUTTER_GAP + laneOf.get(r.id) * ORG_MATRIX_LANE_PITCH),
655
+ repMidY: round2(nextExitY(r.reportId, rep.midY, rep.boxH)),
656
+ mgrMidY: round2(nextExitY(r.managerId, mgr.midY, mgr.boxH)),
657
+ repBoxEdge: round2(rep.boxEdge),
658
+ mgrBoxEdge: round2(mgr.boxEdge),
659
+ repChY: round2(channelTop + 2 * i * ORG_MATRIX_LANE_PITCH),
660
+ mgrChY: round2(channelTop + (2 * i + 1) * ORG_MATRIX_LANE_PITCH),
661
+ laneX: round2(canvasRight + ORG_MATRIX_GUTTER_GAP + laneOf.get(r.id) * ORG_MATRIX_LANE_PITCH),
606
662
  repEscX: 0,
607
663
  mgrEscX: 0
608
664
  };
@@ -640,14 +696,14 @@ function computeOrgChartLayout(input, opts = {}) {
640
696
  else if (v.side === -1 && bRight < v.escCol - VERT_EPS) band = Math.min(band, v.escCol - bRight);
641
697
  }
642
698
  let lane = 0;
643
- let candidate = round(v.escCol);
699
+ let candidate = round2(v.escCol);
644
700
  while (placed.some((p) => Math.abs(p.x - candidate) < VERT_EPS && yOverlap(p.lo, p.hi, v.lo, v.hi))) {
645
701
  lane += 1;
646
- candidate = round(v.escCol + v.side * lane * ORG_MATRIX_ESCAPE_STEP);
702
+ candidate = round2(v.escCol + v.side * lane * ORG_MATRIX_ESCAPE_STEP);
647
703
  }
648
704
  if (lane > 0 && lane * ORG_MATRIX_ESCAPE_STEP >= band - VERT_EPS) {
649
705
  throw new Error(
650
- `org-chart: escape-column-overflow \u2014 escape vertical nudged ${lane * ORG_MATRIX_ESCAPE_STEP}px from its base column exceeds the ${round(band)}px box-free band`
706
+ `org-chart: escape-column-overflow \u2014 escape vertical nudged ${lane * ORG_MATRIX_ESCAPE_STEP}px from its base column exceeds the ${round2(band)}px box-free band`
651
707
  );
652
708
  }
653
709
  placed.push({ x: candidate, lo: v.lo, hi: v.hi });
@@ -676,7 +732,8 @@ function computeOrgChartLayout(input, opts = {}) {
676
732
  // → into the manager box's edge
677
733
  ]),
678
734
  dashed: true,
679
- title: reportTitle("dotted", g.r.label)
735
+ title: reportTitle("dotted", g.r.label),
736
+ annotated: g.r.annotated ?? false
680
737
  });
681
738
  }
682
739
  }
@@ -692,25 +749,6 @@ function collapseDegenerate(points) {
692
749
  }
693
750
  return out;
694
751
  }
695
- function allocateLanes(items) {
696
- const lanes = [];
697
- for (const it of items) {
698
- let chosen = -1;
699
- for (let l = 0; l < lanes.length; l++) {
700
- if (lanes[l].every((o) => it.hi <= o.lo || it.lo >= o.hi)) {
701
- chosen = l;
702
- break;
703
- }
704
- }
705
- if (chosen === -1) {
706
- chosen = lanes.length;
707
- lanes.push([]);
708
- }
709
- lanes[chosen].push({ lo: it.lo, hi: it.hi });
710
- it.set(chosen);
711
- }
712
- return lanes.length;
713
- }
714
752
 
715
753
  // src/org-chart/svg.ts
716
754
  var GLYPH_STROKE = "#52525b";
@@ -719,25 +757,25 @@ var EDGE_INK = "#71717a";
719
757
  var GLYPH_ATTRS = `fill="transparent" stroke="${GLYPH_STROKE}" stroke-width="2"`;
720
758
  var VACANT_DASH = `stroke-dasharray="6,4"`;
721
759
  var DOTTED = EDGE_STROKE.distant;
722
- var round2 = (n) => Math.round(n * 100) / 100;
760
+ var round3 = (n) => Math.round(n * 100) / 100;
723
761
  var ORG_BOX_PAD_Y2 = 9;
724
762
  function boxSvg(n) {
725
- const left = round2(n.cx - n.boxW / 2);
763
+ const left = round3(n.cx - n.boxW / 2);
726
764
  const pieces = [`<title>${xmlEscape(n.title)}</title>`];
727
765
  if (n.style === "dashed") {
728
766
  pieces.push(
729
767
  `<rect x="${left}" y="${n.top}" width="${n.boxW}" height="${n.boxH}" rx="2" ${GLYPH_ATTRS} ${VACANT_DASH}/>`
730
768
  );
731
- const ix = round2(left + 3);
732
- const iy = round2(n.top + 3);
733
- const iw = round2(n.boxW - 6);
734
- const ih = round2(n.boxH - 6);
769
+ const ix = round3(left + 3);
770
+ const iy = round3(n.top + 3);
771
+ const iw = round3(n.boxW - 6);
772
+ const ih = round3(n.boxH - 6);
735
773
  pieces.push(`<rect x="${ix}" y="${iy}" width="${iw}" height="${ih}" rx="2" ${GLYPH_ATTRS} ${VACANT_DASH}/>`);
736
774
  } else {
737
775
  pieces.push(`<rect x="${left}" y="${n.top}" width="${n.boxW}" height="${n.boxH}" rx="2" ${GLYPH_ATTRS}/>`);
738
776
  }
739
777
  let lineIndex = 0;
740
- const firstBaseline = (i) => round2(n.top + ORG_BOX_PAD_Y2 + ORG_LABEL_LINE_H / 2 + i * ORG_LABEL_LINE_H + ORG_LABEL_FONT * 0.32);
778
+ const firstBaseline = (i) => round3(n.top + ORG_BOX_PAD_Y2 + ORG_LABEL_LINE_H / 2 + i * ORG_LABEL_LINE_H + ORG_LABEL_FONT * 0.32);
741
779
  const textBlock = (lines, font) => {
742
780
  if (lines.length === 0) return "";
743
781
  const tspans = lines.map((line, i) => `<tspan x="${n.cx}" y="${firstBaseline(lineIndex + i)}">${xmlEscape(line)}</tspan>`).join("");
@@ -748,43 +786,45 @@ function boxSvg(n) {
748
786
  pieces.push(textBlock(n.titleLines, ORG_TITLE_FONT));
749
787
  pieces.push(textBlock(n.subtitleLines, ORG_TITLE_FONT));
750
788
  if (n.vacantMarker !== null) pieces.push(textBlock([n.vacantMarker], ORG_TITLE_FONT));
789
+ if (n.annotated) pieces.push(annotationDot(round3(n.cx + n.boxW / 2) - 4, n.top + 4));
751
790
  return `<g data-node-id="p${n.positionId}">${pieces.filter((p) => p !== "").join("")}</g>`;
752
791
  }
753
792
  function elementSvg(el) {
754
793
  const head = `<g data-edge-id="${el.edgeId}"><title>${xmlEscape(el.title)}</title>`;
794
+ const tick = el.annotated ? annotationTick(el.points) : "";
755
795
  if (el.dashed) {
756
796
  const dash = DOTTED.dash === null ? "" : ` stroke-dasharray="${DOTTED.dash[0]},${DOTTED.dash[1]}"`;
757
- return head + `<path d="${pathData(el.points)}" fill="none" stroke="${EDGE_INK}" stroke-width="${DOTTED.width}" stroke-opacity="${DOTTED.opacity}"${dash}/></g>`;
797
+ return head + `<path d="${pathData(el.points)}" fill="none" stroke="${EDGE_INK}" stroke-width="${DOTTED.width}" stroke-opacity="${DOTTED.opacity}"${dash}/>${tick}</g>`;
758
798
  }
759
799
  if (el.points.length === 2) {
760
800
  const a = el.points[0];
761
801
  const b = el.points[1];
762
- return head + `<line x1="${a.x}" y1="${a.y}" x2="${b.x}" y2="${b.y}" stroke="${EDGE_INK}" stroke-width="1.5" stroke-opacity="0.75"/></g>`;
802
+ return head + `<line x1="${a.x}" y1="${a.y}" x2="${b.x}" y2="${b.y}" stroke="${EDGE_INK}" stroke-width="1.5" stroke-opacity="0.75"/>${tick}</g>`;
763
803
  }
764
- return head + `<path d="${pathData(el.points)}" fill="none" stroke="${EDGE_INK}" stroke-width="1.5" stroke-opacity="0.75"/></g>`;
804
+ return head + `<path d="${pathData(el.points)}" fill="none" stroke="${EDGE_INK}" stroke-width="1.5" stroke-opacity="0.75"/>${tick}</g>`;
765
805
  }
766
806
  var MINI_ATTRS = `fill="transparent" stroke="${GLYPH_STROKE}" stroke-width="1.5"`;
767
807
  function lineSwatch(x, y) {
768
- const x1 = round2(x + 2);
769
- const x2 = round2(x + LEGEND_SWATCH_W - 2);
808
+ const x1 = round3(x + 2);
809
+ const x2 = round3(x + LEGEND_SWATCH_W - 2);
770
810
  return `<line x1="${x1}" y1="${y}" x2="${x2}" y2="${y}" stroke="${EDGE_INK}" stroke-width="1.5" stroke-opacity="0.75"/>`;
771
811
  }
772
812
  function assistantSwatch(x, y) {
773
- const stemX = round2(x + LEGEND_SWATCH_W - 4);
774
- const boxX = round2(x + 1);
775
- return `<line x1="${stemX}" y1="${round2(y - 4)}" x2="${stemX}" y2="${y}" stroke="${EDGE_INK}" stroke-width="1.5" stroke-opacity="0.75"/><line x1="${stemX}" y1="${y}" x2="${round2(boxX + 8)}" y2="${y}" stroke="${EDGE_INK}" stroke-width="1.5" stroke-opacity="0.75"/><rect x="${boxX}" y="${round2(y - 3.5)}" width="8" height="7" rx="1" ${MINI_ATTRS}/>`;
813
+ const stemX = round3(x + LEGEND_SWATCH_W - 4);
814
+ const boxX = round3(x + 1);
815
+ return `<line x1="${stemX}" y1="${round3(y - 4)}" x2="${stemX}" y2="${y}" stroke="${EDGE_INK}" stroke-width="1.5" stroke-opacity="0.75"/><line x1="${stemX}" y1="${y}" x2="${round3(boxX + 8)}" y2="${y}" stroke="${EDGE_INK}" stroke-width="1.5" stroke-opacity="0.75"/><rect x="${boxX}" y="${round3(y - 3.5)}" width="8" height="7" rx="1" ${MINI_ATTRS}/>`;
776
816
  }
777
817
  function dottedSwatch(x, y) {
778
- const x1 = round2(x + 2);
779
- const x2 = round2(x + LEGEND_SWATCH_W - 2);
818
+ const x1 = round3(x + 2);
819
+ const x2 = round3(x + LEGEND_SWATCH_W - 2);
780
820
  const dash = DOTTED.dash === null ? "" : ` stroke-dasharray="${DOTTED.dash[0]},${DOTTED.dash[1]}"`;
781
821
  return `<line x1="${x1}" y1="${y}" x2="${x2}" y2="${y}" stroke="${EDGE_INK}" stroke-width="${DOTTED.width}" stroke-opacity="${DOTTED.opacity}"${dash}/>`;
782
822
  }
783
823
  function vacantSwatch(x, y) {
784
- const cx = round2(x + LEGEND_SWATCH_W / 2);
785
- const bx = round2(cx - 8);
786
- const by = round2(y - 5);
787
- return `<rect x="${bx}" y="${by}" width="16" height="10" rx="1" ${MINI_ATTRS} stroke-dasharray="3,2"/><rect x="${round2(bx + 2)}" y="${round2(by + 2)}" width="12" height="6" rx="1" ${MINI_ATTRS} stroke-dasharray="3,2"/>`;
824
+ const cx = round3(x + LEGEND_SWATCH_W / 2);
825
+ const bx = round3(cx - 8);
826
+ const by = round3(y - 5);
827
+ return `<rect x="${bx}" y="${by}" width="16" height="10" rx="1" ${MINI_ATTRS} stroke-dasharray="3,2"/><rect x="${round3(bx + 2)}" y="${round3(by + 2)}" width="12" height="6" rx="1" ${MINI_ATTRS} stroke-dasharray="3,2"/>`;
788
828
  }
789
829
  function orgChartLayoutSvg(layout, opts = {}) {
790
830
  const labels = opts.labels ?? ORG_CHART_SVG_LABELS_EN;
@@ -803,6 +843,9 @@ function orgChartLayoutSvg(layout, opts = {}) {
803
843
  if (hasAssistant) entries.push({ swatch: assistantSwatch, label: labels.legend.assistant });
804
844
  if (hasDotted) entries.push({ swatch: dottedSwatch, label: labels.legend.dotted });
805
845
  if (hasVacant) entries.push({ swatch: vacantSwatch, label: labels.legend.vacant });
846
+ if (opts.annotationLabel !== void 0 && (layout.nodes.some((n) => n.annotated) || layout.elements.some((e) => e.annotated))) {
847
+ entries.push({ swatch: annotationSwatch, label: opts.annotationLabel });
848
+ }
806
849
  const block = legendBlock(entries, layout.height);
807
850
  if (block.svg !== "") {
808
851
  parts.push(block.svg);
@@ -823,7 +866,8 @@ function orgChartSvg(input, opts = {}) {
823
866
  });
824
867
  const svg = orgChartLayoutSvg(layout, {
825
868
  ...opts.legend === false ? { legend: false } : {},
826
- ...opts.svgLabels !== void 0 ? { labels: opts.svgLabels } : {}
869
+ ...opts.svgLabels !== void 0 ? { labels: opts.svgLabels } : {},
870
+ ...opts.annotationLabel !== void 0 ? { annotationLabel: opts.annotationLabel } : {}
827
871
  });
828
872
  return { svg, layout };
829
873
  }