@diagrammo/dgmo 0.3.2 → 0.4.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/index.js CHANGED
@@ -1285,6 +1285,31 @@ function collectIndentedValues(lines, startIndex) {
1285
1285
  }
1286
1286
  return { values, newIndex: j - 1 };
1287
1287
  }
1288
+ function parseSeriesNames(value, lines, lineIndex, palette) {
1289
+ let rawNames;
1290
+ let series;
1291
+ let newIndex = lineIndex;
1292
+ if (value) {
1293
+ series = value;
1294
+ rawNames = value.split(",").map((s) => s.trim()).filter(Boolean);
1295
+ } else {
1296
+ const collected = collectIndentedValues(lines, lineIndex);
1297
+ newIndex = collected.newIndex;
1298
+ rawNames = collected.values;
1299
+ series = rawNames.join(", ");
1300
+ }
1301
+ const names = [];
1302
+ const nameColors = [];
1303
+ for (const raw of rawNames) {
1304
+ const extracted = extractColor(raw, palette);
1305
+ nameColors.push(extracted.color);
1306
+ names.push(extracted.label);
1307
+ }
1308
+ if (names.length === 1) {
1309
+ series = names[0];
1310
+ }
1311
+ return { series, names, nameColors, newIndex };
1312
+ }
1288
1313
  function parsePipeMetadata(segments, aliasMap = /* @__PURE__ */ new Map()) {
1289
1314
  const metadata = {};
1290
1315
  for (let j = 1; j < segments.length; j++) {
@@ -1590,13 +1615,18 @@ var init_participant_inference = __esm({
1590
1615
 
1591
1616
  // src/utils/arrows.ts
1592
1617
  function parseArrow(line7) {
1618
+ if (BIDI_SYNC_RE.test(line7) || BIDI_ASYNC_RE.test(line7)) {
1619
+ return {
1620
+ error: "Bidirectional arrows are no longer supported. Use two separate lines: 'A -msg-> B' and 'B -msg-> A'"
1621
+ };
1622
+ }
1593
1623
  const patterns = [
1594
- { re: BIDI_SYNC_LABELED_RE, async: false, bidirectional: true },
1595
- { re: BIDI_ASYNC_LABELED_RE, async: true, bidirectional: true },
1596
- { re: SYNC_LABELED_RE, async: false, bidirectional: false },
1597
- { re: ASYNC_LABELED_RE, async: true, bidirectional: false }
1624
+ { re: RETURN_SYNC_LABELED_RE, async: false, isReturn: true },
1625
+ { re: RETURN_ASYNC_LABELED_RE, async: true, isReturn: true },
1626
+ { re: SYNC_LABELED_RE, async: false, isReturn: false },
1627
+ { re: ASYNC_LABELED_RE, async: true, isReturn: false }
1598
1628
  ];
1599
- for (const { re, async: isAsync, bidirectional } of patterns) {
1629
+ for (const { re, async: isAsync, isReturn } of patterns) {
1600
1630
  const m = line7.match(re);
1601
1631
  if (!m) continue;
1602
1632
  const label = m[2].trim();
@@ -1604,29 +1634,40 @@ function parseArrow(line7) {
1604
1634
  for (const arrow of ARROW_CHARS) {
1605
1635
  if (label.includes(arrow)) {
1606
1636
  return {
1607
- error: "Arrow characters (->, ~>) are not allowed inside labels"
1637
+ error: "Arrow characters (->, ~>, <-, <~) are not allowed inside labels"
1608
1638
  };
1609
1639
  }
1610
1640
  }
1641
+ if (isReturn) {
1642
+ return {
1643
+ from: m[3],
1644
+ to: m[1],
1645
+ label,
1646
+ async: isAsync,
1647
+ isReturn: true
1648
+ };
1649
+ }
1611
1650
  return {
1612
1651
  from: m[1],
1613
1652
  to: m[3],
1614
1653
  label,
1615
1654
  async: isAsync,
1616
- bidirectional
1655
+ isReturn: false
1617
1656
  };
1618
1657
  }
1619
1658
  return null;
1620
1659
  }
1621
- var BIDI_SYNC_LABELED_RE, BIDI_ASYNC_LABELED_RE, SYNC_LABELED_RE, ASYNC_LABELED_RE, ARROW_CHARS;
1660
+ var SYNC_LABELED_RE, ASYNC_LABELED_RE, RETURN_SYNC_LABELED_RE, RETURN_ASYNC_LABELED_RE, BIDI_SYNC_RE, BIDI_ASYNC_RE, ARROW_CHARS;
1622
1661
  var init_arrows = __esm({
1623
1662
  "src/utils/arrows.ts"() {
1624
1663
  "use strict";
1625
- BIDI_SYNC_LABELED_RE = /^(\S+)\s+<-(.+)->\s+(\S+)$/;
1626
- BIDI_ASYNC_LABELED_RE = /^(\S+)\s+<~(.+)~>\s+(\S+)$/;
1627
1664
  SYNC_LABELED_RE = /^(\S+)\s+-(.+)->\s+(\S+)$/;
1628
1665
  ASYNC_LABELED_RE = /^(\S+)\s+~(.+)~>\s+(\S+)$/;
1629
- ARROW_CHARS = ["->", "~>", "<->", "<~>"];
1666
+ RETURN_SYNC_LABELED_RE = /^(\S+)\s+<-(.+)-\s+(\S+)$/;
1667
+ RETURN_ASYNC_LABELED_RE = /^(\S+)\s+<~(.+)~\s+(\S+)$/;
1668
+ BIDI_SYNC_RE = /^(\S+)\s+<-(.+)->\s+(\S+)$/;
1669
+ BIDI_ASYNC_RE = /^(\S+)\s+<~(.+)~>\s+(\S+)$/;
1670
+ ARROW_CHARS = ["->", "~>", "<-", "<~"];
1630
1671
  }
1631
1672
  });
1632
1673
 
@@ -1648,36 +1689,6 @@ function isSequenceSection(el) {
1648
1689
  function isSequenceNote(el) {
1649
1690
  return "kind" in el && el.kind === "note";
1650
1691
  }
1651
- function parseReturnLabel(rawLabel) {
1652
- if (!rawLabel) return { label: "" };
1653
- const standaloneMatch = rawLabel.match(/^<-\s*(.*)$/);
1654
- if (standaloneMatch) {
1655
- return {
1656
- label: standaloneMatch[1].trim(),
1657
- standaloneReturn: true
1658
- };
1659
- }
1660
- const arrowReturn = rawLabel.match(ARROW_RETURN_PATTERN);
1661
- if (arrowReturn) {
1662
- return { label: arrowReturn[1].trim(), returnLabel: arrowReturn[2].trim() };
1663
- }
1664
- const umlReturn = rawLabel.match(UML_RETURN_PATTERN);
1665
- if (umlReturn) {
1666
- return { label: umlReturn[1].trim(), returnLabel: umlReturn[2].trim() };
1667
- }
1668
- const lastColon = rawLabel.lastIndexOf(":");
1669
- if (lastColon > 0 && lastColon < rawLabel.length - 1) {
1670
- const afterColon = rawLabel.substring(lastColon + 1);
1671
- if (!afterColon.startsWith("//")) {
1672
- const reqPart = rawLabel.substring(0, lastColon).trim();
1673
- const resPart = afterColon.trim();
1674
- if (reqPart && resPart) {
1675
- return { label: reqPart, returnLabel: resPart };
1676
- }
1677
- }
1678
- }
1679
- return { label: rawLabel };
1680
- }
1681
1692
  function parseSequenceDgmo(content) {
1682
1693
  const result = {
1683
1694
  title: null,
@@ -1777,7 +1788,7 @@ function parseSequenceDgmo(content) {
1777
1788
  continue;
1778
1789
  }
1779
1790
  const colonIndex = trimmed.indexOf(":");
1780
- if (colonIndex > 0 && !trimmed.includes("->") && !trimmed.includes("~>")) {
1791
+ if (colonIndex > 0 && !trimmed.includes("->") && !trimmed.includes("~>") && !trimmed.includes("<-") && !trimmed.includes("<~")) {
1781
1792
  const key = trimmed.substring(0, colonIndex).trim().toLowerCase();
1782
1793
  if (key === "note" || key.startsWith("note ")) {
1783
1794
  } else {
@@ -1906,16 +1917,15 @@ function parseSequenceDgmo(content) {
1906
1917
  }
1907
1918
  if (labeledArrow) {
1908
1919
  contentStarted = true;
1909
- const { from, to, label, async: isAsync2, bidirectional } = labeledArrow;
1920
+ const { from, to, label, async: isAsync, isReturn } = labeledArrow;
1910
1921
  lastMsgFrom = from;
1911
1922
  const msg = {
1912
1923
  from,
1913
1924
  to,
1914
1925
  label,
1915
- returnLabel: void 0,
1916
1926
  lineNumber,
1917
- ...isAsync2 ? { async: true } : {},
1918
- ...bidirectional ? { bidirectional: true } : {}
1927
+ ...isAsync ? { async: true } : {},
1928
+ ...isReturn ? { standaloneReturn: true } : {}
1919
1929
  };
1920
1930
  result.messages.push(msg);
1921
1931
  currentContainer().push(msg);
@@ -1937,27 +1947,50 @@ function parseSequenceDgmo(content) {
1937
1947
  }
1938
1948
  continue;
1939
1949
  }
1940
- const bidiSyncMatch = trimmed.match(
1941
- /^(\S+)\s*<->\s*([^\s:]+)\s*(?::\s*(.+))?$/
1950
+ const colonPostfixSync = trimmed.match(
1951
+ /^(\S+)\s*->\s*([^\s:]+)\s*:\s*(.+)$/
1952
+ );
1953
+ const colonPostfixAsync = trimmed.match(
1954
+ /^(\S+)\s*~>\s*([^\s:]+)\s*:\s*(.+)$/
1942
1955
  );
1943
- const bidiAsyncMatch = trimmed.match(
1944
- /^(\S+)\s*<~>\s*([^\s:]+)\s*(?::\s*(.+))?$/
1956
+ const colonPostfix = colonPostfixSync || colonPostfixAsync;
1957
+ if (colonPostfix) {
1958
+ const a = colonPostfix[1];
1959
+ const b = colonPostfix[2];
1960
+ const msg = colonPostfix[3].trim();
1961
+ const arrowChar = colonPostfixAsync ? "~" : "-";
1962
+ const arrowEnd = colonPostfixAsync ? "~>" : "->";
1963
+ pushError(
1964
+ lineNumber,
1965
+ `Colon syntax is no longer supported. Use '${a} ${arrowChar}${msg}${arrowEnd} ${b}' instead`
1966
+ );
1967
+ continue;
1968
+ }
1969
+ const bidiPlainMatch = trimmed.match(
1970
+ /^(\S+)\s*(?:<->|<~>)\s*(\S+)/
1945
1971
  );
1946
- const bidiMatch = bidiSyncMatch || bidiAsyncMatch;
1947
- if (bidiMatch) {
1972
+ if (bidiPlainMatch) {
1973
+ pushError(
1974
+ lineNumber,
1975
+ "Bidirectional arrows are no longer supported. Use two separate lines: 'A -msg-> B' and 'B -msg-> A'"
1976
+ );
1977
+ continue;
1978
+ }
1979
+ const bareReturnSync = trimmed.match(/^(\S+)\s+<-\s+(\S+)$/);
1980
+ const bareReturnAsync = trimmed.match(/^(\S+)\s+<~\s+(\S+)$/);
1981
+ const bareReturn = bareReturnSync || bareReturnAsync;
1982
+ if (bareReturn) {
1948
1983
  contentStarted = true;
1949
- const from = bidiMatch[1];
1950
- const to = bidiMatch[2];
1984
+ const to = bareReturn[1];
1985
+ const from = bareReturn[2];
1951
1986
  lastMsgFrom = from;
1952
- const rawLabel = bidiMatch[3]?.trim() || "";
1953
- const isBidiAsync = !!bidiAsyncMatch;
1954
1987
  const msg = {
1955
1988
  from,
1956
1989
  to,
1957
- label: rawLabel,
1990
+ label: "",
1958
1991
  lineNumber,
1959
- bidirectional: true,
1960
- ...isBidiAsync ? { async: true } : {}
1992
+ standaloneReturn: true,
1993
+ ...bareReturnAsync ? { async: true } : {}
1961
1994
  };
1962
1995
  result.messages.push(msg);
1963
1996
  currentContainer().push(msg);
@@ -1979,30 +2012,20 @@ function parseSequenceDgmo(content) {
1979
2012
  }
1980
2013
  continue;
1981
2014
  }
1982
- let isAsync = false;
1983
- const asyncArrowMatch = trimmed.match(
1984
- /^(\S+)\s*~>\s*([^\s:]+)\s*(?::\s*(.+))?$/
1985
- );
1986
- const syncArrowMatch = trimmed.match(
1987
- /^(\S+)\s*->\s*([^\s:]+)\s*(?::\s*(.+))?$/
1988
- );
1989
- const arrowMatch = asyncArrowMatch || syncArrowMatch;
1990
- if (asyncArrowMatch) isAsync = true;
1991
- if (arrowMatch) {
2015
+ const bareCallSync = trimmed.match(/^(\S+)\s*->\s*(\S+)$/);
2016
+ const bareCallAsync = trimmed.match(/^(\S+)\s*~>\s*(\S+)$/);
2017
+ const bareCall = bareCallSync || bareCallAsync;
2018
+ if (bareCall) {
1992
2019
  contentStarted = true;
1993
- const from = arrowMatch[1];
1994
- const to = arrowMatch[2];
2020
+ const from = bareCall[1];
2021
+ const to = bareCall[2];
1995
2022
  lastMsgFrom = from;
1996
- const rawLabel = arrowMatch[3]?.trim() || "";
1997
- const { label, returnLabel, standaloneReturn } = isAsync ? { label: rawLabel, returnLabel: void 0, standaloneReturn: void 0 } : parseReturnLabel(rawLabel);
1998
2023
  const msg = {
1999
2024
  from,
2000
2025
  to,
2001
- label,
2002
- returnLabel,
2026
+ label: "",
2003
2027
  lineNumber,
2004
- ...isAsync ? { async: true } : {},
2005
- ...standaloneReturn ? { standaloneReturn: true } : {}
2028
+ ...bareCallAsync ? { async: true } : {}
2006
2029
  };
2007
2030
  result.messages.push(msg);
2008
2031
  currentContainer().push(msg);
@@ -2211,7 +2234,7 @@ function looksLikeSequence(content) {
2211
2234
  return ARROW_PATTERN.test(trimmed);
2212
2235
  });
2213
2236
  }
2214
- var VALID_PARTICIPANT_TYPES, IS_A_PATTERN, POSITION_ONLY_PATTERN, GROUP_HEADING_PATTERN, SECTION_PATTERN, ARROW_PATTERN, ARROW_RETURN_PATTERN, UML_RETURN_PATTERN, NOTE_SINGLE, NOTE_MULTI;
2237
+ var VALID_PARTICIPANT_TYPES, IS_A_PATTERN, POSITION_ONLY_PATTERN, GROUP_HEADING_PATTERN, SECTION_PATTERN, ARROW_PATTERN, NOTE_SINGLE, NOTE_MULTI;
2215
2238
  var init_parser = __esm({
2216
2239
  "src/sequence/parser.ts"() {
2217
2240
  "use strict";
@@ -2234,9 +2257,7 @@ var init_parser = __esm({
2234
2257
  POSITION_ONLY_PATTERN = /^(\S+)\s+position\s+(-?\d+)$/i;
2235
2258
  GROUP_HEADING_PATTERN = /^##\s+(.+?)(?:\(([^)]+)\))?\s*$/;
2236
2259
  SECTION_PATTERN = /^==\s+(.+?)(?:\s*==)?\s*$/;
2237
- ARROW_PATTERN = /\S+\s*(?:<->|<~>|->|~>|-\S+->|~\S+~>|<-\S+->|<~\S+~>)\s*\S+/;
2238
- ARROW_RETURN_PATTERN = /^(.+?)\s*<-\s*(.+)$/;
2239
- UML_RETURN_PATTERN = /^(\w+\([^)]*\))\s*:\s*(.+)$/;
2260
+ ARROW_PATTERN = /\S+\s*(?:<-\S+-|<~\S+~|-\S+->|~\S+~>|->|~>|<-|<~)\s*\S+/;
2240
2261
  NOTE_SINGLE = /^note(?:\s+(right|left)\s+of\s+(\S+))?\s*:\s*(.+)$/i;
2241
2262
  NOTE_MULTI = /^note(?:\s+(right|left)\s+of\s+([^\s:]+))?\s*:?\s*$/i;
2242
2263
  }
@@ -3142,49 +3163,19 @@ function parseChart(content, palette) {
3142
3163
  continue;
3143
3164
  }
3144
3165
  if (key === "series") {
3145
- let rawNames;
3146
- if (value) {
3147
- result.series = value;
3148
- rawNames = value.split(",").map((s) => s.trim()).filter(Boolean);
3149
- } else {
3150
- const collected = collectIndentedValues(lines, i);
3151
- i = collected.newIndex;
3152
- rawNames = collected.values;
3153
- result.series = rawNames.join(", ");
3154
- }
3155
- const names = [];
3156
- const nameColors = [];
3157
- for (const raw of rawNames) {
3158
- const colorMatch = raw.match(/\(([^)]+)\)\s*$/);
3159
- if (colorMatch) {
3160
- const resolved = resolveColor(colorMatch[1].trim(), palette);
3161
- nameColors.push(resolved);
3162
- names.push(raw.substring(0, colorMatch.index).trim());
3163
- } else {
3164
- nameColors.push(void 0);
3165
- names.push(raw);
3166
- }
3167
- }
3168
- if (names.length === 1) {
3169
- result.series = names[0];
3170
- }
3171
- if (names.length > 1) {
3172
- result.seriesNames = names;
3166
+ const parsed = parseSeriesNames(value, lines, i, palette);
3167
+ i = parsed.newIndex;
3168
+ result.series = parsed.series;
3169
+ if (parsed.names.length > 1) {
3170
+ result.seriesNames = parsed.names;
3173
3171
  }
3174
- if (nameColors.some(Boolean)) result.seriesNameColors = nameColors;
3172
+ if (parsed.nameColors.some(Boolean)) result.seriesNameColors = parsed.nameColors;
3175
3173
  continue;
3176
3174
  }
3177
3175
  const parts = value.split(",").map((s) => s.trim());
3178
3176
  const numValue = parseFloat(parts[0]);
3179
3177
  if (!isNaN(numValue)) {
3180
- let rawLabel = trimmed.substring(0, colonIndex).trim();
3181
- let pointColor;
3182
- const colorMatch = rawLabel.match(/\(([^)]+)\)\s*$/);
3183
- if (colorMatch) {
3184
- const resolved = resolveColor(colorMatch[1].trim(), palette);
3185
- pointColor = resolved;
3186
- rawLabel = rawLabel.substring(0, colorMatch.index).trim();
3187
- }
3178
+ const { label: rawLabel, color: pointColor } = extractColor(trimmed.substring(0, colonIndex).trim(), palette);
3188
3179
  const extra = parts.slice(1).map((s) => parseFloat(s)).filter((n) => !isNaN(n));
3189
3180
  result.data.push({
3190
3181
  label: rawLabel,
@@ -3264,13 +3255,10 @@ function parseEChart(content, palette) {
3264
3255
  if (!trimmed) continue;
3265
3256
  const mdCategoryMatch = trimmed.match(/^#{2,}\s+(.+)$/);
3266
3257
  if (mdCategoryMatch) {
3267
- let catName = mdCategoryMatch[1].trim();
3268
- const catColorMatch = catName.match(/\(([^)]+)\)\s*$/);
3269
- if (catColorMatch) {
3270
- const resolved = resolveColor(catColorMatch[1].trim(), palette);
3258
+ const { label: catName, color: catColor } = extractColor(mdCategoryMatch[1].trim(), palette);
3259
+ if (catColor) {
3271
3260
  if (!result.categoryColors) result.categoryColors = {};
3272
- catName = catName.substring(0, catColorMatch.index).trim();
3273
- result.categoryColors[catName] = resolved;
3261
+ result.categoryColors[catName] = catColor;
3274
3262
  }
3275
3263
  currentCategory = catName;
3276
3264
  continue;
@@ -3307,32 +3295,13 @@ function parseEChart(content, palette) {
3307
3295
  continue;
3308
3296
  }
3309
3297
  if (key === "series") {
3310
- let rawNames;
3311
- if (value) {
3312
- result.series = value;
3313
- rawNames = value.split(",").map((s) => s.trim()).filter(Boolean);
3314
- } else {
3315
- const collected = collectIndentedValues(lines, i);
3316
- i = collected.newIndex;
3317
- rawNames = collected.values;
3318
- result.series = rawNames.join(", ");
3298
+ const parsed = parseSeriesNames(value, lines, i, palette);
3299
+ i = parsed.newIndex;
3300
+ result.series = parsed.series;
3301
+ if (parsed.names.length > 1) {
3302
+ result.seriesNames = parsed.names;
3319
3303
  }
3320
- const names = [];
3321
- const nameColors = [];
3322
- for (const raw of rawNames) {
3323
- const colorMatch = raw.match(/\(([^)]+)\)\s*$/);
3324
- if (colorMatch) {
3325
- nameColors.push(resolveColor(colorMatch[1].trim(), palette));
3326
- names.push(raw.substring(0, colorMatch.index).trim());
3327
- } else {
3328
- nameColors.push(void 0);
3329
- names.push(raw);
3330
- }
3331
- }
3332
- if (names.length === 1) {
3333
- result.series = names[0];
3334
- }
3335
- if (nameColors.some(Boolean)) result.seriesNameColors = nameColors;
3304
+ if (parsed.nameColors.some(Boolean)) result.seriesNameColors = parsed.nameColors;
3336
3305
  continue;
3337
3306
  }
3338
3307
  if (key === "xlabel") {
@@ -3394,13 +3363,7 @@ function parseEChart(content, palette) {
3394
3363
  continue;
3395
3364
  }
3396
3365
  if (result.type === "function") {
3397
- let fnName = trimmed.substring(0, colonIndex).trim();
3398
- let fnColor;
3399
- const colorMatch = fnName.match(/\(([^)]+)\)\s*$/);
3400
- if (colorMatch) {
3401
- fnColor = resolveColor(colorMatch[1].trim(), palette);
3402
- fnName = fnName.substring(0, colorMatch.index).trim();
3403
- }
3366
+ const { label: fnName, color: fnColor } = extractColor(trimmed.substring(0, colonIndex).trim(), palette);
3404
3367
  if (!result.functions) result.functions = [];
3405
3368
  result.functions.push({
3406
3369
  name: fnName,
@@ -3415,13 +3378,7 @@ function parseEChart(content, palette) {
3415
3378
  /^(-?[\d.]+)\s*,\s*(-?[\d.]+)(?:\s*,\s*(-?[\d.]+))?$/
3416
3379
  );
3417
3380
  if (scatterMatch) {
3418
- let scatterName = trimmed.substring(0, colonIndex).trim();
3419
- let scatterColor;
3420
- const colorMatch = scatterName.match(/\(([^)]+)\)\s*$/);
3421
- if (colorMatch) {
3422
- scatterColor = resolveColor(colorMatch[1].trim(), palette);
3423
- scatterName = scatterName.substring(0, colorMatch.index).trim();
3424
- }
3381
+ const { label: scatterName, color: scatterColor } = extractColor(trimmed.substring(0, colonIndex).trim(), palette);
3425
3382
  if (!result.scatterPoints) result.scatterPoints = [];
3426
3383
  result.scatterPoints.push({
3427
3384
  name: scatterName,
@@ -3446,13 +3403,7 @@ function parseEChart(content, palette) {
3446
3403
  }
3447
3404
  const numValue = parseFloat(value);
3448
3405
  if (!isNaN(numValue)) {
3449
- let rawLabel = trimmed.substring(0, colonIndex).trim();
3450
- let pointColor;
3451
- const colorMatch = rawLabel.match(/\(([^)]+)\)\s*$/);
3452
- if (colorMatch) {
3453
- pointColor = resolveColor(colorMatch[1].trim(), palette);
3454
- rawLabel = rawLabel.substring(0, colorMatch.index).trim();
3455
- }
3406
+ const { label: rawLabel, color: pointColor } = extractColor(trimmed.substring(0, colonIndex).trim(), palette);
3456
3407
  result.data.push({
3457
3408
  label: rawLabel,
3458
3409
  value: numValue,
@@ -3499,30 +3450,21 @@ function parseEChart(content, palette) {
3499
3450
  }
3500
3451
  return result;
3501
3452
  }
3502
- function buildEChartsOption(parsed, palette, isDark) {
3453
+ function buildChartCommons(parsed, palette, isDark) {
3503
3454
  const textColor = palette.text;
3504
3455
  const axisLineColor = palette.border;
3456
+ const splitLineColor = palette.border;
3505
3457
  const gridOpacity = isDark ? 0.7 : 0.55;
3506
3458
  const colors = getSeriesColors(palette);
3459
+ const titleConfig = parsed.title ? { text: parsed.title, left: "center", top: 8, textStyle: { color: textColor, fontSize: 20, fontWeight: "bold", fontFamily: FONT_FAMILY } } : void 0;
3460
+ const tooltipTheme = { backgroundColor: palette.surface, borderColor: palette.border, textStyle: { color: palette.text } };
3461
+ return { textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig, tooltipTheme };
3462
+ }
3463
+ function buildEChartsOption(parsed, palette, isDark) {
3507
3464
  if (parsed.error) {
3508
3465
  return {};
3509
3466
  }
3510
- const titleConfig = parsed.title ? {
3511
- text: parsed.title,
3512
- left: "center",
3513
- top: 8,
3514
- textStyle: {
3515
- color: textColor,
3516
- fontSize: 20,
3517
- fontWeight: "bold",
3518
- fontFamily: FONT_FAMILY
3519
- }
3520
- } : void 0;
3521
- const tooltipTheme = {
3522
- backgroundColor: palette.surface,
3523
- borderColor: palette.border,
3524
- textStyle: { color: palette.text }
3525
- };
3467
+ const { textColor, axisLineColor, gridOpacity, colors, titleConfig, tooltipTheme } = buildChartCommons(parsed, palette, isDark);
3526
3468
  if (parsed.type === "sankey") {
3527
3469
  return buildSankeyOption(
3528
3470
  parsed,
@@ -3598,8 +3540,7 @@ function buildSankeyOption(parsed, textColor, colors, titleConfig, tooltipTheme)
3598
3540
  }
3599
3541
  }));
3600
3542
  return {
3601
- backgroundColor: "transparent",
3602
- animation: false,
3543
+ ...CHART_BASE,
3603
3544
  title: titleConfig,
3604
3545
  tooltip: {
3605
3546
  show: false,
@@ -3656,8 +3597,7 @@ function buildChordOption(parsed, textColor, colors, titleConfig, tooltipTheme)
3656
3597
  }
3657
3598
  }));
3658
3599
  return {
3659
- backgroundColor: "transparent",
3660
- animation: false,
3600
+ ...CHART_BASE,
3661
3601
  title: titleConfig,
3662
3602
  tooltip: {
3663
3603
  trigger: "item",
@@ -3759,15 +3699,11 @@ function buildFunctionOption(parsed, palette, textColor, axisLineColor, gridOpac
3759
3699
  itemStyle: {
3760
3700
  color: fnColor
3761
3701
  },
3762
- emphasis: {
3763
- focus: "self",
3764
- blurScope: "global"
3765
- }
3702
+ emphasis: EMPHASIS_SELF
3766
3703
  };
3767
3704
  });
3768
3705
  return {
3769
- backgroundColor: "transparent",
3770
- animation: false,
3706
+ ...CHART_BASE,
3771
3707
  title: titleConfig,
3772
3708
  tooltip: {
3773
3709
  trigger: "axis",
@@ -3912,8 +3848,7 @@ function buildScatterOption(parsed, palette, textColor, axisLineColor, gridOpaci
3912
3848
  const xPad = (xMax - xMin) * 0.1 || 1;
3913
3849
  const yPad = (yMax - yMin) * 0.1 || 1;
3914
3850
  return {
3915
- backgroundColor: "transparent",
3916
- animation: false,
3851
+ ...CHART_BASE,
3917
3852
  title: titleConfig,
3918
3853
  tooltip,
3919
3854
  ...legendData && {
@@ -3998,8 +3933,7 @@ function buildHeatmapOption(parsed, palette, textColor, axisLineColor, titleConf
3998
3933
  });
3999
3934
  });
4000
3935
  return {
4001
- backgroundColor: "transparent",
4002
- animation: false,
3936
+ ...CHART_BASE,
4003
3937
  title: titleConfig,
4004
3938
  tooltip: {
4005
3939
  trigger: "item",
@@ -4076,8 +4010,7 @@ function buildHeatmapOption(parsed, palette, textColor, axisLineColor, titleConf
4076
4010
  fontWeight: "bold"
4077
4011
  },
4078
4012
  emphasis: {
4079
- focus: "self",
4080
- blurScope: "global",
4013
+ ...EMPHASIS_SELF,
4081
4014
  itemStyle: {
4082
4015
  shadowBlur: 10,
4083
4016
  shadowColor: "rgba(0, 0, 0, 0.5)"
@@ -4116,8 +4049,7 @@ function buildFunnelOption(parsed, textColor, colors, titleConfig, tooltipTheme)
4116
4049
  minSize: "8%"
4117
4050
  };
4118
4051
  return {
4119
- backgroundColor: "transparent",
4120
- animation: false,
4052
+ ...CHART_BASE,
4121
4053
  title: titleConfig,
4122
4054
  tooltip: {
4123
4055
  trigger: "item",
@@ -4155,8 +4087,7 @@ function buildFunnelOption(parsed, textColor, colors, titleConfig, tooltipTheme)
4155
4087
  lineStyle: { color: textColor, opacity: 0.3 }
4156
4088
  },
4157
4089
  emphasis: {
4158
- focus: "self",
4159
- blurScope: "global",
4090
+ ...EMPHASIS_SELF,
4160
4091
  label: {
4161
4092
  fontSize: 15
4162
4093
  }
@@ -4239,27 +4170,7 @@ function makeGridAxis(type, textColor, axisLineColor, splitLineColor, gridOpacit
4239
4170
  }
4240
4171
  function buildEChartsOptionFromChart(parsed, palette, isDark, chartWidth) {
4241
4172
  if (parsed.error) return {};
4242
- const textColor = palette.text;
4243
- const axisLineColor = palette.border;
4244
- const splitLineColor = palette.border;
4245
- const gridOpacity = isDark ? 0.7 : 0.55;
4246
- const colors = getSeriesColors(palette);
4247
- const titleConfig = parsed.title ? {
4248
- text: parsed.title,
4249
- left: "center",
4250
- top: 8,
4251
- textStyle: {
4252
- color: textColor,
4253
- fontSize: 20,
4254
- fontWeight: "bold",
4255
- fontFamily: FONT_FAMILY
4256
- }
4257
- } : void 0;
4258
- const tooltipTheme = {
4259
- backgroundColor: palette.surface,
4260
- borderColor: palette.border,
4261
- textStyle: { color: palette.text }
4262
- };
4173
+ const { textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig, tooltipTheme } = buildChartCommons(parsed, palette, isDark);
4263
4174
  switch (parsed.type) {
4264
4175
  case "bar":
4265
4176
  return buildBarOption(parsed, textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig, tooltipTheme, chartWidth);
@@ -4279,6 +4190,15 @@ function buildEChartsOptionFromChart(parsed, palette, isDark, chartWidth) {
4279
4190
  return buildPolarAreaOption(parsed, textColor, getSegmentColors(palette, parsed.data.length), titleConfig, tooltipTheme);
4280
4191
  }
4281
4192
  }
4193
+ function makeChartGrid(options) {
4194
+ return {
4195
+ left: options.yLabel ? "12%" : "3%",
4196
+ right: "4%",
4197
+ bottom: options.hasLegend ? "15%" : options.xLabel ? "10%" : "3%",
4198
+ top: options.hasTitle ? "15%" : "5%",
4199
+ containLabel: true
4200
+ };
4201
+ }
4282
4202
  function buildBarOption(parsed, textColor, axisLineColor, splitLineColor, gridOpacity, colors, titleConfig, tooltipTheme, chartWidth) {
4283
4203
  const { xLabel, yLabel } = resolveAxisLabels(parsed);
4284
4204
  const isHorizontal = parsed.orientation === "horizontal";
@@ -4291,31 +4211,21 @@ function buildBarOption(parsed, textColor, axisLineColor, splitLineColor, gridOp
4291
4211
  const categoryAxis = makeGridAxis("category", textColor, axisLineColor, splitLineColor, gridOpacity, isHorizontal ? yLabel : xLabel, labels, hCatGap, !isHorizontal ? chartWidth : void 0);
4292
4212
  const valueAxis = makeGridAxis("value", textColor, axisLineColor, splitLineColor, gridOpacity, isHorizontal ? xLabel : yLabel);
4293
4213
  return {
4294
- backgroundColor: "transparent",
4295
- animation: false,
4214
+ ...CHART_BASE,
4296
4215
  title: titleConfig,
4297
4216
  tooltip: {
4298
4217
  trigger: "axis",
4299
4218
  ...tooltipTheme,
4300
4219
  axisPointer: { type: "shadow" }
4301
4220
  },
4302
- grid: {
4303
- left: yLabel ? "12%" : "3%",
4304
- right: "4%",
4305
- bottom: xLabel ? "10%" : "3%",
4306
- top: parsed.title ? "15%" : "5%",
4307
- containLabel: true
4308
- },
4221
+ grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title }),
4309
4222
  xAxis: isHorizontal ? valueAxis : categoryAxis,
4310
4223
  yAxis: isHorizontal ? categoryAxis : valueAxis,
4311
4224
  series: [
4312
4225
  {
4313
4226
  type: "bar",
4314
4227
  data,
4315
- emphasis: {
4316
- focus: "self",
4317
- blurScope: "global"
4318
- }
4228
+ emphasis: EMPHASIS_SELF
4319
4229
  }
4320
4230
  ]
4321
4231
  };
@@ -4326,21 +4236,14 @@ function buildLineOption(parsed, palette, textColor, axisLineColor, splitLineCol
4326
4236
  const labels = parsed.data.map((d) => d.label);
4327
4237
  const values = parsed.data.map((d) => d.value);
4328
4238
  return {
4329
- backgroundColor: "transparent",
4330
- animation: false,
4239
+ ...CHART_BASE,
4331
4240
  title: titleConfig,
4332
4241
  tooltip: {
4333
4242
  trigger: "axis",
4334
4243
  ...tooltipTheme,
4335
4244
  axisPointer: { type: "line" }
4336
4245
  },
4337
- grid: {
4338
- left: yLabel ? "12%" : "3%",
4339
- right: "4%",
4340
- bottom: xLabel ? "10%" : "3%",
4341
- top: parsed.title ? "15%" : "5%",
4342
- containLabel: true
4343
- },
4246
+ grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title }),
4344
4247
  xAxis: makeGridAxis("category", textColor, axisLineColor, splitLineColor, gridOpacity, xLabel, labels, void 0, chartWidth),
4345
4248
  yAxis: makeGridAxis("value", textColor, axisLineColor, splitLineColor, gridOpacity, yLabel),
4346
4249
  series: [
@@ -4351,10 +4254,7 @@ function buildLineOption(parsed, palette, textColor, axisLineColor, splitLineCol
4351
4254
  symbolSize: 8,
4352
4255
  lineStyle: { color: lineColor, width: 3 },
4353
4256
  itemStyle: { color: lineColor },
4354
- emphasis: {
4355
- focus: "self",
4356
- blurScope: "global"
4357
- }
4257
+ emphasis: EMPHASIS_SELF
4358
4258
  }
4359
4259
  ]
4360
4260
  };
@@ -4376,15 +4276,11 @@ function buildMultiLineOption(parsed, textColor, axisLineColor, splitLineColor,
4376
4276
  symbolSize: 8,
4377
4277
  lineStyle: { color, width: 3 },
4378
4278
  itemStyle: { color },
4379
- emphasis: {
4380
- focus: "self",
4381
- blurScope: "global"
4382
- }
4279
+ emphasis: EMPHASIS_SELF
4383
4280
  };
4384
4281
  });
4385
4282
  return {
4386
- backgroundColor: "transparent",
4387
- animation: false,
4283
+ ...CHART_BASE,
4388
4284
  title: titleConfig,
4389
4285
  tooltip: {
4390
4286
  trigger: "axis",
@@ -4396,13 +4292,7 @@ function buildMultiLineOption(parsed, textColor, axisLineColor, splitLineColor,
4396
4292
  bottom: 10,
4397
4293
  textStyle: { color: textColor }
4398
4294
  },
4399
- grid: {
4400
- left: yLabel ? "12%" : "3%",
4401
- right: "4%",
4402
- bottom: "15%",
4403
- top: parsed.title ? "15%" : "5%",
4404
- containLabel: true
4405
- },
4295
+ grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title, hasLegend: true }),
4406
4296
  xAxis: makeGridAxis("category", textColor, axisLineColor, splitLineColor, gridOpacity, xLabel, labels, void 0, chartWidth),
4407
4297
  yAxis: makeGridAxis("value", textColor, axisLineColor, splitLineColor, gridOpacity, yLabel),
4408
4298
  series
@@ -4414,21 +4304,14 @@ function buildAreaOption(parsed, palette, textColor, axisLineColor, splitLineCol
4414
4304
  const labels = parsed.data.map((d) => d.label);
4415
4305
  const values = parsed.data.map((d) => d.value);
4416
4306
  return {
4417
- backgroundColor: "transparent",
4418
- animation: false,
4307
+ ...CHART_BASE,
4419
4308
  title: titleConfig,
4420
4309
  tooltip: {
4421
4310
  trigger: "axis",
4422
4311
  ...tooltipTheme,
4423
4312
  axisPointer: { type: "line" }
4424
4313
  },
4425
- grid: {
4426
- left: yLabel ? "12%" : "3%",
4427
- right: "4%",
4428
- bottom: xLabel ? "10%" : "3%",
4429
- top: parsed.title ? "15%" : "5%",
4430
- containLabel: true
4431
- },
4314
+ grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title }),
4432
4315
  xAxis: makeGridAxis("category", textColor, axisLineColor, splitLineColor, gridOpacity, xLabel, labels, void 0, chartWidth),
4433
4316
  yAxis: makeGridAxis("value", textColor, axisLineColor, splitLineColor, gridOpacity, yLabel),
4434
4317
  series: [
@@ -4440,10 +4323,7 @@ function buildAreaOption(parsed, palette, textColor, axisLineColor, splitLineCol
4440
4323
  lineStyle: { color: lineColor, width: 3 },
4441
4324
  itemStyle: { color: lineColor },
4442
4325
  areaStyle: { opacity: 0.25 },
4443
- emphasis: {
4444
- focus: "self",
4445
- blurScope: "global"
4446
- }
4326
+ emphasis: EMPHASIS_SELF
4447
4327
  }
4448
4328
  ]
4449
4329
  };
@@ -4467,8 +4347,7 @@ function buildPieOption(parsed, textColor, colors, titleConfig, tooltipTheme, is
4467
4347
  itemStyle: { color: d.color ?? colors[i % colors.length] }
4468
4348
  }));
4469
4349
  return {
4470
- backgroundColor: "transparent",
4471
- animation: false,
4350
+ ...CHART_BASE,
4472
4351
  title: titleConfig,
4473
4352
  tooltip: {
4474
4353
  trigger: "item",
@@ -4486,10 +4365,7 @@ function buildPieOption(parsed, textColor, colors, titleConfig, tooltipTheme, is
4486
4365
  fontFamily: FONT_FAMILY
4487
4366
  },
4488
4367
  labelLine: { show: true },
4489
- emphasis: {
4490
- focus: "self",
4491
- blurScope: "global"
4492
- }
4368
+ emphasis: EMPHASIS_SELF
4493
4369
  }
4494
4370
  ]
4495
4371
  };
@@ -4503,8 +4379,7 @@ function buildRadarOption(parsed, palette, textColor, gridOpacity, colors, title
4503
4379
  max: maxValue
4504
4380
  }));
4505
4381
  return {
4506
- backgroundColor: "transparent",
4507
- animation: false,
4382
+ ...CHART_BASE,
4508
4383
  title: titleConfig,
4509
4384
  tooltip: {
4510
4385
  trigger: "item",
@@ -4546,10 +4421,7 @@ function buildRadarOption(parsed, palette, textColor, gridOpacity, colors, title
4546
4421
  }
4547
4422
  }
4548
4423
  ],
4549
- emphasis: {
4550
- focus: "self",
4551
- blurScope: "global"
4552
- }
4424
+ emphasis: EMPHASIS_SELF
4553
4425
  }
4554
4426
  ]
4555
4427
  };
@@ -4561,8 +4433,7 @@ function buildPolarAreaOption(parsed, textColor, colors, titleConfig, tooltipThe
4561
4433
  itemStyle: { color: d.color ?? colors[i % colors.length] }
4562
4434
  }));
4563
4435
  return {
4564
- backgroundColor: "transparent",
4565
- animation: false,
4436
+ ...CHART_BASE,
4566
4437
  title: titleConfig,
4567
4438
  tooltip: {
4568
4439
  trigger: "item",
@@ -4581,10 +4452,7 @@ function buildPolarAreaOption(parsed, textColor, colors, titleConfig, tooltipThe
4581
4452
  fontFamily: FONT_FAMILY
4582
4453
  },
4583
4454
  labelLine: { show: true },
4584
- emphasis: {
4585
- focus: "self",
4586
- blurScope: "global"
4587
- }
4455
+ emphasis: EMPHASIS_SELF
4588
4456
  }
4589
4457
  ]
4590
4458
  };
@@ -4614,10 +4482,7 @@ function buildBarStackedOption(parsed, textColor, axisLineColor, splitLineColor,
4614
4482
  fontWeight: "bold",
4615
4483
  fontFamily: FONT_FAMILY
4616
4484
  },
4617
- emphasis: {
4618
- focus: "self",
4619
- blurScope: "global"
4620
- }
4485
+ emphasis: EMPHASIS_SELF
4621
4486
  };
4622
4487
  });
4623
4488
  const hCatGap = isHorizontal && yLabel ? Math.max(40, Math.max(...labels.map((l) => l.length)) * 8 + 16) : void 0;
@@ -4625,8 +4490,7 @@ function buildBarStackedOption(parsed, textColor, axisLineColor, splitLineColor,
4625
4490
  const hValueGap = isHorizontal && xLabel ? 40 : void 0;
4626
4491
  const valueAxis = makeGridAxis("value", textColor, axisLineColor, splitLineColor, gridOpacity, isHorizontal ? xLabel : yLabel, void 0, hValueGap);
4627
4492
  return {
4628
- backgroundColor: "transparent",
4629
- animation: false,
4493
+ ...CHART_BASE,
4630
4494
  title: titleConfig,
4631
4495
  tooltip: {
4632
4496
  trigger: "axis",
@@ -4638,13 +4502,7 @@ function buildBarStackedOption(parsed, textColor, axisLineColor, splitLineColor,
4638
4502
  bottom: 10,
4639
4503
  textStyle: { color: textColor }
4640
4504
  },
4641
- grid: {
4642
- left: yLabel ? "12%" : "3%",
4643
- right: "4%",
4644
- bottom: "15%",
4645
- top: parsed.title ? "15%" : "5%",
4646
- containLabel: true
4647
- },
4505
+ grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title, hasLegend: true }),
4648
4506
  xAxis: isHorizontal ? valueAxis : categoryAxis,
4649
4507
  yAxis: isHorizontal ? categoryAxis : valueAxis,
4650
4508
  series
@@ -4691,30 +4549,21 @@ async function renderEChartsForExport(content, theme, palette, options) {
4691
4549
  chart.dispose();
4692
4550
  }
4693
4551
  }
4694
- var ECHART_EXPORT_WIDTH, ECHART_EXPORT_HEIGHT, STANDARD_CHART_TYPES;
4552
+ var EMPHASIS_SELF, CHART_BASE, ECHART_EXPORT_WIDTH, ECHART_EXPORT_HEIGHT;
4695
4553
  var init_echarts = __esm({
4696
4554
  "src/echarts.ts"() {
4697
4555
  "use strict";
4698
4556
  init_fonts();
4699
4557
  init_branding();
4700
- init_colors();
4701
4558
  init_palettes();
4702
4559
  init_chart();
4703
4560
  init_diagnostics();
4704
4561
  init_parsing();
4562
+ init_dgmo_router();
4563
+ EMPHASIS_SELF = { focus: "self", blurScope: "global" };
4564
+ CHART_BASE = { backgroundColor: "transparent", animation: false };
4705
4565
  ECHART_EXPORT_WIDTH = 1200;
4706
4566
  ECHART_EXPORT_HEIGHT = 800;
4707
- STANDARD_CHART_TYPES = /* @__PURE__ */ new Set([
4708
- "bar",
4709
- "line",
4710
- "multi-line",
4711
- "area",
4712
- "pie",
4713
- "doughnut",
4714
- "radar",
4715
- "polar-area",
4716
- "bar-stacked"
4717
- ]);
4718
4567
  }
4719
4568
  });
4720
4569
 
@@ -6044,6 +5893,7 @@ var init_parser7 = __esm({
6044
5893
  var dgmo_router_exports = {};
6045
5894
  __export(dgmo_router_exports, {
6046
5895
  DGMO_CHART_TYPE_MAP: () => DGMO_CHART_TYPE_MAP,
5896
+ STANDARD_CHART_TYPES: () => STANDARD_CHART_TYPES,
6047
5897
  getDgmoFramework: () => getDgmoFramework,
6048
5898
  parseDgmo: () => parseDgmo,
6049
5899
  parseDgmoChartType: () => parseDgmoChartType
@@ -6071,53 +5921,19 @@ function parseDgmoChartType(content) {
6071
5921
  function parseDgmo(content) {
6072
5922
  const chartType = parseDgmoChartType(content);
6073
5923
  if (!chartType) {
6074
- const parsed2 = parseD3(content);
6075
- return { diagnostics: parsed2.diagnostics };
6076
- }
6077
- if (chartType === "sequence") {
6078
- const parsed2 = parseSequenceDgmo(content);
6079
- return { diagnostics: parsed2.diagnostics };
6080
- }
6081
- if (chartType === "flowchart") {
6082
- const parsed2 = parseFlowchart(content);
6083
- return { diagnostics: parsed2.diagnostics };
6084
- }
6085
- if (chartType === "class") {
6086
- const parsed2 = parseClassDiagram(content);
6087
- return { diagnostics: parsed2.diagnostics };
6088
- }
6089
- if (chartType === "er") {
6090
- const parsed2 = parseERDiagram(content);
6091
- return { diagnostics: parsed2.diagnostics };
6092
- }
6093
- if (chartType === "org") {
6094
- const parsed2 = parseOrg(content);
6095
- return { diagnostics: parsed2.diagnostics };
6096
- }
6097
- if (chartType === "kanban") {
6098
- const parsed2 = parseKanban(content);
6099
- return { diagnostics: parsed2.diagnostics };
6100
- }
6101
- if (chartType === "c4") {
6102
- const parsed2 = parseC4(content);
6103
- return { diagnostics: parsed2.diagnostics };
6104
- }
6105
- if (chartType === "initiative-status") {
6106
- const parsed2 = parseInitiativeStatus(content);
6107
- return { diagnostics: parsed2.diagnostics };
5924
+ return { diagnostics: parseD3(content).diagnostics };
6108
5925
  }
6109
- if (STANDARD_CHART_TYPES2.has(chartType)) {
6110
- const parsed2 = parseChart(content);
6111
- return { diagnostics: parsed2.diagnostics };
5926
+ const directParser = PARSE_DISPATCH.get(chartType);
5927
+ if (directParser) return { diagnostics: directParser(content).diagnostics };
5928
+ if (STANDARD_CHART_TYPES.has(chartType)) {
5929
+ return { diagnostics: parseChart(content).diagnostics };
6112
5930
  }
6113
5931
  if (ECHART_TYPES.has(chartType)) {
6114
- const parsed2 = parseEChart(content);
6115
- return { diagnostics: parsed2.diagnostics };
5932
+ return { diagnostics: parseEChart(content).diagnostics };
6116
5933
  }
6117
- const parsed = parseD3(content);
6118
- return { diagnostics: parsed.diagnostics };
5934
+ return { diagnostics: parseD3(content).diagnostics };
6119
5935
  }
6120
- var DGMO_CHART_TYPE_MAP, STANDARD_CHART_TYPES2, ECHART_TYPES;
5936
+ var DGMO_CHART_TYPE_MAP, STANDARD_CHART_TYPES, ECHART_TYPES, PARSE_DISPATCH;
6121
5937
  var init_dgmo_router = __esm({
6122
5938
  "src/dgmo-router.ts"() {
6123
5939
  "use strict";
@@ -6166,7 +5982,7 @@ var init_dgmo_router = __esm({
6166
5982
  c4: "d3",
6167
5983
  "initiative-status": "d3"
6168
5984
  };
6169
- STANDARD_CHART_TYPES2 = /* @__PURE__ */ new Set([
5985
+ STANDARD_CHART_TYPES = /* @__PURE__ */ new Set([
6170
5986
  "bar",
6171
5987
  "line",
6172
5988
  "multi-line",
@@ -6185,6 +6001,16 @@ var init_dgmo_router = __esm({
6185
6001
  "heatmap",
6186
6002
  "funnel"
6187
6003
  ]);
6004
+ PARSE_DISPATCH = /* @__PURE__ */ new Map([
6005
+ ["sequence", (c) => parseSequenceDgmo(c)],
6006
+ ["flowchart", (c) => parseFlowchart(c)],
6007
+ ["class", (c) => parseClassDiagram(c)],
6008
+ ["er", (c) => parseERDiagram(c)],
6009
+ ["org", (c) => parseOrg(c)],
6010
+ ["kanban", (c) => parseKanban(c)],
6011
+ ["c4", (c) => parseC4(c)],
6012
+ ["initiative-status", (c) => parseInitiativeStatus(c)]
6013
+ ]);
6188
6014
  }
6189
6015
  });
6190
6016
 
@@ -12184,7 +12010,7 @@ function buildRenderSequence(messages) {
12184
12010
  type: "return",
12185
12011
  from: top.to,
12186
12012
  to: top.from,
12187
- label: top.returnLabel || "",
12013
+ label: "",
12188
12014
  messageIndex: top.messageIndex
12189
12015
  });
12190
12016
  }
@@ -12210,12 +12036,8 @@ function buildRenderSequence(messages) {
12210
12036
  to: msg.to,
12211
12037
  label: msg.label,
12212
12038
  messageIndex: mi,
12213
- ...msg.async ? { async: true } : {},
12214
- ...msg.bidirectional ? { bidirectional: true } : {}
12039
+ ...msg.async ? { async: true } : {}
12215
12040
  });
12216
- if (msg.bidirectional) {
12217
- continue;
12218
- }
12219
12041
  if (msg.async) {
12220
12042
  continue;
12221
12043
  }
@@ -12224,14 +12046,13 @@ function buildRenderSequence(messages) {
12224
12046
  type: "return",
12225
12047
  from: msg.to,
12226
12048
  to: msg.from,
12227
- label: msg.returnLabel || "",
12049
+ label: "",
12228
12050
  messageIndex: mi
12229
12051
  });
12230
12052
  } else {
12231
12053
  stack.push({
12232
12054
  from: msg.from,
12233
12055
  to: msg.to,
12234
- returnLabel: msg.returnLabel,
12235
12056
  messageIndex: mi
12236
12057
  });
12237
12058
  }
@@ -12242,7 +12063,7 @@ function buildRenderSequence(messages) {
12242
12063
  type: "return",
12243
12064
  from: top.to,
12244
12065
  to: top.from,
12245
- label: top.returnLabel || "",
12066
+ label: "",
12246
12067
  messageIndex: top.messageIndex
12247
12068
  });
12248
12069
  }
@@ -12707,14 +12528,6 @@ function renderSequenceDiagram(container, parsed, palette, isDark, _onNavigateTo
12707
12528
  "points",
12708
12529
  `0,0 ${ARROWHEAD_SIZE},${ARROWHEAD_SIZE / 2} 0,${ARROWHEAD_SIZE}`
12709
12530
  ).attr("fill", "none").attr("stroke", palette.text).attr("stroke-width", 1.2);
12710
- defs.append("marker").attr("id", "seq-arrowhead-reverse").attr("viewBox", `0 0 ${ARROWHEAD_SIZE} ${ARROWHEAD_SIZE}`).attr("refX", 0).attr("refY", ARROWHEAD_SIZE / 2).attr("markerWidth", ARROWHEAD_SIZE).attr("markerHeight", ARROWHEAD_SIZE).attr("orient", "auto").append("polygon").attr(
12711
- "points",
12712
- `${ARROWHEAD_SIZE},0 0,${ARROWHEAD_SIZE / 2} ${ARROWHEAD_SIZE},${ARROWHEAD_SIZE}`
12713
- ).attr("fill", palette.text);
12714
- defs.append("marker").attr("id", "seq-arrowhead-async-reverse").attr("viewBox", `0 0 ${ARROWHEAD_SIZE} ${ARROWHEAD_SIZE}`).attr("refX", 0).attr("refY", ARROWHEAD_SIZE / 2).attr("markerWidth", ARROWHEAD_SIZE).attr("markerHeight", ARROWHEAD_SIZE).attr("orient", "auto").append("polyline").attr(
12715
- "points",
12716
- `${ARROWHEAD_SIZE},0 0,${ARROWHEAD_SIZE / 2} ${ARROWHEAD_SIZE},${ARROWHEAD_SIZE}`
12717
- ).attr("fill", "none").attr("stroke", palette.text).attr("stroke-width", 1.2);
12718
12531
  if (title) {
12719
12532
  const titleEl = svg.append("text").attr("class", "chart-title").attr("x", svgWidth / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", palette.text).attr("font-size", 20).attr("font-weight", "bold").text(title);
12720
12533
  if (parsed.titleLineNumber) {
@@ -12995,17 +12808,10 @@ function renderSequenceDiagram(container, parsed, palette, isDark, _onNavigateTo
12995
12808
  const x1 = arrowEdgeX(step.from, i, goingRight ? "right" : "left");
12996
12809
  const x2 = arrowEdgeX(step.to, i, goingRight ? "left" : "right");
12997
12810
  const markerRef = step.async ? "url(#seq-arrowhead-async)" : "url(#seq-arrowhead)";
12998
- const markerStartRef = step.bidirectional ? step.async ? "url(#seq-arrowhead-async-reverse)" : "url(#seq-arrowhead-reverse)" : null;
12999
- const line7 = svg.append("line").attr("x1", x1).attr("y1", y).attr("x2", x2).attr("y2", y).attr("stroke", palette.text).attr("stroke-width", 1.2).attr("marker-end", markerRef).attr("class", "message-arrow").attr(
12811
+ svg.append("line").attr("x1", x1).attr("y1", y).attr("x2", x2).attr("y2", y).attr("stroke", palette.text).attr("stroke-width", 1.2).attr("marker-end", markerRef).attr("class", "message-arrow").attr(
13000
12812
  "data-line-number",
13001
12813
  String(messages[step.messageIndex].lineNumber)
13002
12814
  ).attr("data-msg-index", String(step.messageIndex)).attr("data-step-index", String(i));
13003
- if (markerStartRef) {
13004
- line7.attr("marker-start", markerStartRef);
13005
- }
13006
- if (step.bidirectional && step.async) {
13007
- line7.attr("stroke-dasharray", "6 4");
13008
- }
13009
12815
  if (step.label) {
13010
12816
  const midX = (x1 + x2) / 2;
13011
12817
  const labelEl = svg.append("text").attr("x", midX).attr("y", y - 8).attr("text-anchor", "middle").attr("fill", palette.text).attr("font-size", 12).attr("class", "message-label").attr(
@@ -13236,6 +13042,32 @@ import * as d3Selection9 from "d3-selection";
13236
13042
  import * as d3Shape6 from "d3-shape";
13237
13043
  import * as d3Array from "d3-array";
13238
13044
  import cloud from "d3-cloud";
13045
+ function renderChartTitle(svg, title, titleLineNumber, width, textColor, onClickItem) {
13046
+ if (!title) return;
13047
+ const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && titleLineNumber ? "pointer" : "default").text(title);
13048
+ if (titleLineNumber) {
13049
+ titleEl.attr("data-line-number", titleLineNumber);
13050
+ if (onClickItem) {
13051
+ titleEl.on("click", () => onClickItem(titleLineNumber)).on("mouseenter", function() {
13052
+ d3Selection9.select(this).attr("opacity", 0.7);
13053
+ }).on("mouseleave", function() {
13054
+ d3Selection9.select(this).attr("opacity", 1);
13055
+ });
13056
+ }
13057
+ }
13058
+ }
13059
+ function initD3Chart(container, palette, exportDims) {
13060
+ d3Selection9.select(container).selectAll(":not([data-d3-tooltip])").remove();
13061
+ const width = exportDims?.width ?? container.clientWidth;
13062
+ const height = exportDims?.height ?? container.clientHeight;
13063
+ if (width <= 0 || height <= 0) return null;
13064
+ const textColor = palette.text;
13065
+ const mutedColor = palette.border;
13066
+ const bgColor = palette.bg;
13067
+ const colors = getSeriesColors(palette);
13068
+ const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
13069
+ return { svg, width, height, textColor, mutedColor, bgColor, colors };
13070
+ }
13239
13071
  function parseTimelineDate(s) {
13240
13072
  const parts = s.split("-").map((p) => parseInt(p, 10));
13241
13073
  const year = parts[0];
@@ -13798,26 +13630,28 @@ function tokenizeFreeformText(text) {
13798
13630
  }
13799
13631
  return Array.from(counts.entries()).map(([text2, count]) => ({ text: text2, weight: count, lineNumber: 0 })).sort((a, b) => b.weight - a.weight);
13800
13632
  }
13801
- function resolveVerticalCollisions(items, minGap) {
13633
+ function resolveVerticalCollisions(items, minGap, maxY) {
13802
13634
  if (items.length === 0) return [];
13803
13635
  const sorted = items.map((it, i) => ({ ...it, idx: i })).sort((a, b) => a.naturalY - b.naturalY);
13804
13636
  const adjustedY = new Array(items.length);
13805
13637
  let prevBottom = -Infinity;
13806
13638
  for (const item of sorted) {
13807
13639
  const halfH = item.height / 2;
13808
- const top = Math.max(item.naturalY - halfH, prevBottom + minGap);
13640
+ let top = Math.max(item.naturalY - halfH, prevBottom + minGap);
13641
+ if (maxY !== void 0) {
13642
+ top = Math.min(top, maxY - item.height);
13643
+ }
13809
13644
  adjustedY[item.idx] = top + halfH;
13810
13645
  prevBottom = top + item.height;
13811
13646
  }
13812
13647
  return adjustedY;
13813
13648
  }
13814
13649
  function renderSlopeChart(container, parsed, palette, isDark, onClickItem, exportDims) {
13815
- d3Selection9.select(container).selectAll(":not([data-d3-tooltip])").remove();
13816
13650
  const { periods, data, title } = parsed;
13817
13651
  if (data.length === 0 || periods.length < 2) return;
13818
- const width = exportDims?.width ?? container.clientWidth;
13819
- const height = exportDims?.height ?? container.clientHeight;
13820
- if (width <= 0 || height <= 0) return;
13652
+ const init2 = initD3Chart(container, palette, exportDims);
13653
+ if (!init2) return;
13654
+ const { svg, width, height, textColor, mutedColor, bgColor, colors } = init2;
13821
13655
  const maxLabelText = data.reduce((longest, item) => {
13822
13656
  const text = `${item.values[item.values.length - 1]} \u2014 ${item.label}`;
13823
13657
  return text.length > longest.length ? text : longest;
@@ -13830,31 +13664,14 @@ function renderSlopeChart(container, parsed, palette, isDark, onClickItem, expor
13830
13664
  );
13831
13665
  const innerWidth = width - SLOPE_MARGIN.left - rightMargin;
13832
13666
  const innerHeight = height - SLOPE_MARGIN.top - SLOPE_MARGIN.bottom;
13833
- const textColor = palette.text;
13834
- const mutedColor = palette.border;
13835
- const bgColor = palette.bg;
13836
- const colors = getSeriesColors(palette);
13837
13667
  const allValues = data.flatMap((d) => d.values);
13838
13668
  const [minVal, maxVal] = d3Array.extent(allValues);
13839
13669
  const valuePadding = (maxVal - minVal) * 0.1 || 1;
13840
13670
  const yScale = d3Scale.scaleLinear().domain([minVal - valuePadding, maxVal + valuePadding]).range([innerHeight, 0]);
13841
13671
  const xScale = d3Scale.scalePoint().domain(periods).range([0, innerWidth]).padding(0);
13842
- const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
13843
13672
  const g = svg.append("g").attr("transform", `translate(${SLOPE_MARGIN.left},${SLOPE_MARGIN.top})`);
13844
13673
  const tooltip = createTooltip(container, palette, isDark);
13845
- if (title) {
13846
- const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
13847
- if (parsed.titleLineNumber) {
13848
- titleEl.attr("data-line-number", parsed.titleLineNumber);
13849
- if (onClickItem) {
13850
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
13851
- d3Selection9.select(this).attr("opacity", 0.7);
13852
- }).on("mouseleave", function() {
13853
- d3Selection9.select(this).attr("opacity", 1);
13854
- });
13855
- }
13856
- }
13857
- }
13674
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
13858
13675
  for (const period of periods) {
13859
13676
  const x = xScale(period);
13860
13677
  g.append("text").attr("x", x).attr("y", -15).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "18px").attr("font-weight", "600").text(period);
@@ -13917,13 +13734,13 @@ function renderSlopeChart(container, parsed, palette, isDark, onClickItem, expor
13917
13734
  naturalY: yScale(item.values[pi]),
13918
13735
  height: leftLabelHeight
13919
13736
  }));
13920
- leftLabelCollisions.set(pi, resolveVerticalCollisions(entries, 4));
13737
+ leftLabelCollisions.set(pi, resolveVerticalCollisions(entries, 4, innerHeight));
13921
13738
  }
13922
13739
  const rightEntries = seriesInfo.map((si) => ({
13923
13740
  naturalY: yScale(si.lastVal),
13924
13741
  height: Math.max(si.labelHeight, SLOPE_LABEL_FONT_SIZE * 1.4)
13925
13742
  }));
13926
- const rightAdjustedY = resolveVerticalCollisions(rightEntries, 4);
13743
+ const rightAdjustedY = resolveVerticalCollisions(rightEntries, 4, innerHeight);
13927
13744
  data.forEach((item, idx) => {
13928
13745
  const si = seriesInfo[idx];
13929
13746
  const color = si.color;
@@ -14063,12 +13880,11 @@ function orderArcNodes(links, order, groups) {
14063
13880
  return allNodes;
14064
13881
  }
14065
13882
  function renderArcDiagram(container, parsed, palette, _isDark, onClickItem, exportDims) {
14066
- d3Selection9.select(container).selectAll(":not([data-d3-tooltip])").remove();
14067
13883
  const { links, title, orientation, arcOrder, arcNodeGroups } = parsed;
14068
13884
  if (links.length === 0) return;
14069
- const width = exportDims?.width ?? container.clientWidth;
14070
- const height = exportDims?.height ?? container.clientHeight;
14071
- if (width <= 0 || height <= 0) return;
13885
+ const init2 = initD3Chart(container, palette, exportDims);
13886
+ if (!init2) return;
13887
+ const { svg, width, height, textColor, mutedColor, bgColor, colors } = init2;
14072
13888
  const isVertical = orientation === "vertical";
14073
13889
  const margin = isVertical ? {
14074
13890
  top: ARC_MARGIN.top,
@@ -14078,10 +13894,6 @@ function renderArcDiagram(container, parsed, palette, _isDark, onClickItem, expo
14078
13894
  } : ARC_MARGIN;
14079
13895
  const innerWidth = width - margin.left - margin.right;
14080
13896
  const innerHeight = height - margin.top - margin.bottom;
14081
- const textColor = palette.text;
14082
- const mutedColor = palette.border;
14083
- const bgColor = palette.bg;
14084
- const colors = getSeriesColors(palette);
14085
13897
  const nodes = orderArcNodes(links, arcOrder, arcNodeGroups);
14086
13898
  const nodeColorMap = /* @__PURE__ */ new Map();
14087
13899
  for (const group of arcNodeGroups) {
@@ -14100,21 +13912,8 @@ function renderArcDiagram(container, parsed, palette, _isDark, onClickItem, expo
14100
13912
  const values = links.map((l) => l.value);
14101
13913
  const [minVal, maxVal] = d3Array.extent(values);
14102
13914
  const strokeScale = d3Scale.scaleLinear().domain([minVal, maxVal]).range([1.5, 6]);
14103
- const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
14104
13915
  const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
14105
- if (title) {
14106
- const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
14107
- if (parsed.titleLineNumber) {
14108
- titleEl.attr("data-line-number", parsed.titleLineNumber);
14109
- if (onClickItem) {
14110
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
14111
- d3Selection9.select(this).attr("opacity", 0.7);
14112
- }).on("mouseleave", function() {
14113
- d3Selection9.select(this).attr("opacity", 1);
14114
- });
14115
- }
14116
- }
14117
- }
13916
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
14118
13917
  const neighbors = /* @__PURE__ */ new Map();
14119
13918
  for (const node of nodes) neighbors.set(node, /* @__PURE__ */ new Set());
14120
13919
  for (const link of links) {
@@ -14650,19 +14449,7 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
14650
14449
  const yScale = d3Scale.scaleLinear().domain([minDate - datePadding, maxDate + datePadding]).range([0, innerHeight]);
14651
14450
  const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
14652
14451
  const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
14653
- if (title) {
14654
- const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
14655
- if (parsed.titleLineNumber) {
14656
- titleEl.attr("data-line-number", parsed.titleLineNumber);
14657
- if (onClickItem) {
14658
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
14659
- d3Selection9.select(this).attr("opacity", 0.7);
14660
- }).on("mouseleave", function() {
14661
- d3Selection9.select(this).attr("opacity", 1);
14662
- });
14663
- }
14664
- }
14665
- }
14452
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
14666
14453
  renderEras(
14667
14454
  g,
14668
14455
  timelineEras,
@@ -14765,19 +14552,7 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
14765
14552
  const sorted = timelineEvents.slice().sort((a, b) => parseTimelineDate(a.date) - parseTimelineDate(b.date));
14766
14553
  const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
14767
14554
  const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
14768
- if (title) {
14769
- const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
14770
- if (parsed.titleLineNumber) {
14771
- titleEl.attr("data-line-number", parsed.titleLineNumber);
14772
- if (onClickItem) {
14773
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
14774
- d3Selection9.select(this).attr("opacity", 0.7);
14775
- }).on("mouseleave", function() {
14776
- d3Selection9.select(this).attr("opacity", 1);
14777
- });
14778
- }
14779
- }
14780
- }
14555
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
14781
14556
  renderEras(
14782
14557
  g,
14783
14558
  timelineEras,
@@ -14909,19 +14684,7 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
14909
14684
  const xScale = d3Scale.scaleLinear().domain([minDate - datePadding, maxDate + datePadding]).range([0, innerWidth]);
14910
14685
  const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
14911
14686
  const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
14912
- if (title) {
14913
- const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
14914
- if (parsed.titleLineNumber) {
14915
- titleEl.attr("data-line-number", parsed.titleLineNumber);
14916
- if (onClickItem) {
14917
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
14918
- d3Selection9.select(this).attr("opacity", 0.7);
14919
- }).on("mouseleave", function() {
14920
- d3Selection9.select(this).attr("opacity", 1);
14921
- });
14922
- }
14923
- }
14924
- }
14687
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
14925
14688
  renderEras(
14926
14689
  g,
14927
14690
  timelineEras,
@@ -15064,19 +14827,7 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
15064
14827
  const xScale = d3Scale.scaleLinear().domain([minDate - datePadding, maxDate + datePadding]).range([0, innerWidth]);
15065
14828
  const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
15066
14829
  const g = svg.append("g").attr("transform", `translate(${margin.left},${margin.top})`);
15067
- if (title) {
15068
- const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
15069
- if (parsed.titleLineNumber) {
15070
- titleEl.attr("data-line-number", parsed.titleLineNumber);
15071
- if (onClickItem) {
15072
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
15073
- d3Selection9.select(this).attr("opacity", 0.7);
15074
- }).on("mouseleave", function() {
15075
- d3Selection9.select(this).attr("opacity", 1);
15076
- });
15077
- }
15078
- }
15079
- }
14830
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
15080
14831
  renderEras(
15081
14832
  g,
15082
14833
  timelineEras,
@@ -15203,17 +14954,13 @@ function getRotateFn(mode) {
15203
14954
  return () => 0;
15204
14955
  }
15205
14956
  function renderWordCloud(container, parsed, palette, _isDark, onClickItem, exportDims) {
15206
- d3Selection9.select(container).selectAll(":not([data-d3-tooltip])").remove();
15207
14957
  const { words, title, cloudOptions } = parsed;
15208
14958
  if (words.length === 0) return;
15209
- const width = exportDims?.width ?? container.clientWidth;
15210
- const height = exportDims?.height ?? container.clientHeight;
15211
- if (width <= 0 || height <= 0) return;
14959
+ const init2 = initD3Chart(container, palette, exportDims);
14960
+ if (!init2) return;
14961
+ const { svg, width, height, textColor, colors } = init2;
15212
14962
  const titleHeight = title ? 40 : 0;
15213
14963
  const cloudHeight = height - titleHeight;
15214
- const textColor = palette.text;
15215
- const bgColor = palette.bg;
15216
- const colors = getSeriesColors(palette);
15217
14964
  const { minSize, maxSize } = cloudOptions;
15218
14965
  const weights = words.map((w) => w.weight);
15219
14966
  const minWeight = Math.min(...weights);
@@ -15224,20 +14971,7 @@ function renderWordCloud(container, parsed, palette, _isDark, onClickItem, expor
15224
14971
  return minSize + t * (maxSize - minSize);
15225
14972
  };
15226
14973
  const rotateFn = getRotateFn(cloudOptions.rotate);
15227
- const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
15228
- if (title) {
15229
- const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
15230
- if (parsed.titleLineNumber) {
15231
- titleEl.attr("data-line-number", parsed.titleLineNumber);
15232
- if (onClickItem) {
15233
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
15234
- d3Selection9.select(this).attr("opacity", 0.7);
15235
- }).on("mouseleave", function() {
15236
- d3Selection9.select(this).attr("opacity", 1);
15237
- });
15238
- }
15239
- }
15240
- }
14974
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
15241
14975
  const g = svg.append("g").attr(
15242
14976
  "transform",
15243
14977
  `translate(${width / 2},${titleHeight + cloudHeight / 2})`
@@ -15288,12 +15022,7 @@ function renderWordCloudAsync(container, parsed, palette, _isDark, exportDims) {
15288
15022
  };
15289
15023
  const rotateFn = getRotateFn(cloudOptions.rotate);
15290
15024
  const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
15291
- if (title) {
15292
- const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").text(title);
15293
- if (parsed.titleLineNumber) {
15294
- titleEl.attr("data-line-number", parsed.titleLineNumber);
15295
- }
15296
- }
15025
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor);
15297
15026
  const g = svg.append("g").attr(
15298
15027
  "transform",
15299
15028
  `translate(${width / 2},${titleHeight + cloudHeight / 2})`
@@ -15424,15 +15153,11 @@ function regionCentroid(circles, inside) {
15424
15153
  return { x: sx / count, y: sy / count };
15425
15154
  }
15426
15155
  function renderVenn(container, parsed, palette, isDark, onClickItem, exportDims) {
15427
- d3Selection9.select(container).selectAll(":not([data-d3-tooltip])").remove();
15428
15156
  const { vennSets, vennOverlaps, vennShowValues, title } = parsed;
15429
15157
  if (vennSets.length < 2) return;
15430
- const width = exportDims?.width ?? container.clientWidth;
15431
- const height = exportDims?.height ?? container.clientHeight;
15432
- if (width <= 0 || height <= 0) return;
15433
- const textColor = palette.text;
15434
- const bgColor = palette.bg;
15435
- const colors = getSeriesColors(palette);
15158
+ const init2 = initD3Chart(container, palette, exportDims);
15159
+ if (!init2) return;
15160
+ const { svg, width, height, textColor, colors } = init2;
15436
15161
  const titleHeight = title ? 40 : 0;
15437
15162
  const radii = vennSets.map((s) => radiusFromArea(s.size));
15438
15163
  const overlapMap = /* @__PURE__ */ new Map();
@@ -15511,21 +15236,8 @@ function renderVenn(container, parsed, palette, isDark, onClickItem, exportDims)
15511
15236
  marginTop,
15512
15237
  marginBottom
15513
15238
  ).map((c) => ({ ...c, y: c.y + titleHeight }));
15514
- const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
15515
15239
  const tooltip = createTooltip(container, palette, isDark);
15516
- if (title) {
15517
- const titleEl = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style("cursor", onClickItem && parsed.titleLineNumber ? "pointer" : "default").text(title);
15518
- if (parsed.titleLineNumber) {
15519
- titleEl.attr("data-line-number", parsed.titleLineNumber);
15520
- if (onClickItem) {
15521
- titleEl.on("click", () => onClickItem(parsed.titleLineNumber)).on("mouseenter", function() {
15522
- d3Selection9.select(this).attr("opacity", 0.7);
15523
- }).on("mouseleave", function() {
15524
- d3Selection9.select(this).attr("opacity", 1);
15525
- });
15526
- }
15527
- }
15528
- }
15240
+ renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
15529
15241
  const circleEls = [];
15530
15242
  const circleGroup = svg.append("g");
15531
15243
  circles.forEach((c, i) => {
@@ -15669,7 +15381,6 @@ function renderVenn(container, parsed, palette, isDark, onClickItem, exportDims)
15669
15381
  });
15670
15382
  }
15671
15383
  function renderQuadrant(container, parsed, palette, isDark, onClickItem, exportDims) {
15672
- d3Selection9.select(container).selectAll(":not([data-d3-tooltip])").remove();
15673
15384
  const {
15674
15385
  title,
15675
15386
  quadrantLabels,
@@ -15681,12 +15392,10 @@ function renderQuadrant(container, parsed, palette, isDark, onClickItem, exportD
15681
15392
  quadrantYAxisLineNumber
15682
15393
  } = parsed;
15683
15394
  if (quadrantPoints.length === 0) return;
15684
- const width = exportDims?.width ?? container.clientWidth;
15685
- const height = exportDims?.height ?? container.clientHeight;
15686
- if (width <= 0 || height <= 0) return;
15687
- const textColor = palette.text;
15395
+ const init2 = initD3Chart(container, palette, exportDims);
15396
+ if (!init2) return;
15397
+ const { svg, width, height, textColor } = init2;
15688
15398
  const mutedColor = palette.textMuted;
15689
- const bgColor = palette.bg;
15690
15399
  const borderColor = palette.border;
15691
15400
  const defaultColors = [
15692
15401
  palette.colors.blue,
@@ -15701,24 +15410,8 @@ function renderQuadrant(container, parsed, palette, isDark, onClickItem, exportD
15701
15410
  const chartHeight = height - margin.top - margin.bottom;
15702
15411
  const xScale = d3Scale.scaleLinear().domain([0, 1]).range([0, chartWidth]);
15703
15412
  const yScale = d3Scale.scaleLinear().domain([0, 1]).range([chartHeight, 0]);
15704
- const svg = d3Selection9.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
15705
15413
  const tooltip = createTooltip(container, palette, isDark);
15706
- if (title) {
15707
- const titleText = svg.append("text").attr("class", "chart-title").attr("x", width / 2).attr("y", 30).attr("text-anchor", "middle").attr("fill", textColor).attr("font-size", "20px").attr("font-weight", "700").style(
15708
- "cursor",
15709
- onClickItem && quadrantTitleLineNumber ? "pointer" : "default"
15710
- ).text(title);
15711
- if (quadrantTitleLineNumber) {
15712
- titleText.attr("data-line-number", quadrantTitleLineNumber);
15713
- }
15714
- if (onClickItem && quadrantTitleLineNumber) {
15715
- titleText.on("click", () => onClickItem(quadrantTitleLineNumber)).on("mouseenter", function() {
15716
- d3Selection9.select(this).attr("opacity", 0.7);
15717
- }).on("mouseleave", function() {
15718
- d3Selection9.select(this).attr("opacity", 1);
15719
- });
15720
- }
15721
- }
15414
+ renderChartTitle(svg, title, quadrantTitleLineNumber, width, textColor, onClickItem);
15722
15415
  const chartG = svg.append("g").attr("transform", `translate(${margin.left}, ${margin.top})`);
15723
15416
  const mixHex = (a, b, pct) => {
15724
15417
  const parse = (h) => {
@@ -15967,6 +15660,38 @@ function renderQuadrant(container, parsed, palette, isDark, onClickItem, exportD
15967
15660
  }
15968
15661
  });
15969
15662
  }
15663
+ async function resolveExportPalette(theme, palette) {
15664
+ if (palette) return palette;
15665
+ const { getPalette: getPalette2 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
15666
+ return theme === "dark" ? getPalette2("nord").dark : getPalette2("nord").light;
15667
+ }
15668
+ function createExportContainer(width, height) {
15669
+ const container = document.createElement("div");
15670
+ container.style.width = `${width}px`;
15671
+ container.style.height = `${height}px`;
15672
+ container.style.position = "absolute";
15673
+ container.style.left = "-9999px";
15674
+ document.body.appendChild(container);
15675
+ return container;
15676
+ }
15677
+ function finalizeSvgExport(container, theme, palette, options) {
15678
+ const svgEl = container.querySelector("svg");
15679
+ if (!svgEl) return "";
15680
+ if (theme === "transparent") {
15681
+ svgEl.style.background = "none";
15682
+ } else if (!svgEl.style.background) {
15683
+ svgEl.style.background = palette.bg;
15684
+ }
15685
+ svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
15686
+ svgEl.style.fontFamily = FONT_FAMILY;
15687
+ const svgHtml = svgEl.outerHTML;
15688
+ document.body.removeChild(container);
15689
+ if (options?.branding !== false) {
15690
+ const brandColor = theme === "transparent" ? "#888" : palette.textMuted;
15691
+ return injectBranding(svgHtml, brandColor);
15692
+ }
15693
+ return svgHtml;
15694
+ }
15970
15695
  async function renderD3ForExport(content, theme, palette, orgExportState, options) {
15971
15696
  const { parseDgmoChartType: parseDgmoChartType2 } = await Promise.resolve().then(() => (init_dgmo_router(), dgmo_router_exports));
15972
15697
  const detectedType = parseDgmoChartType2(content);
@@ -15976,8 +15701,7 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
15976
15701
  const { collapseOrgTree: collapseOrgTree2 } = await Promise.resolve().then(() => (init_collapse(), collapse_exports));
15977
15702
  const { renderOrg: renderOrg2 } = await Promise.resolve().then(() => (init_renderer(), renderer_exports));
15978
15703
  const isDark2 = theme === "dark";
15979
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
15980
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15704
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
15981
15705
  const orgParsed = parseOrg2(content, effectivePalette2);
15982
15706
  if (orgParsed.error) return "";
15983
15707
  const collapsedNodes = orgExportState?.collapsedNodes;
@@ -15994,83 +15718,28 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
15994
15718
  const titleOffset = effectiveParsed.title ? 30 : 0;
15995
15719
  const exportWidth = orgLayout.width + PADDING * 2;
15996
15720
  const exportHeight = orgLayout.height + PADDING * 2 + titleOffset;
15997
- const container2 = document.createElement("div");
15998
- container2.style.width = `${exportWidth}px`;
15999
- container2.style.height = `${exportHeight}px`;
16000
- container2.style.position = "absolute";
16001
- container2.style.left = "-9999px";
16002
- document.body.appendChild(container2);
16003
- try {
16004
- renderOrg2(
16005
- container2,
16006
- effectiveParsed,
16007
- orgLayout,
16008
- effectivePalette2,
16009
- isDark2,
16010
- void 0,
16011
- { width: exportWidth, height: exportHeight },
16012
- activeTagGroup,
16013
- hiddenAttributes
16014
- );
16015
- const svgEl = container2.querySelector("svg");
16016
- if (!svgEl) return "";
16017
- if (theme === "transparent") {
16018
- svgEl.style.background = "none";
16019
- } else if (!svgEl.style.background) {
16020
- svgEl.style.background = effectivePalette2.bg;
16021
- }
16022
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16023
- svgEl.style.fontFamily = FONT_FAMILY;
16024
- const svgHtml = svgEl.outerHTML;
16025
- if (options?.branding !== false) {
16026
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16027
- return injectBranding(svgHtml, brandColor);
16028
- }
16029
- return svgHtml;
16030
- } finally {
16031
- document.body.removeChild(container2);
16032
- }
15721
+ const container2 = createExportContainer(exportWidth, exportHeight);
15722
+ renderOrg2(container2, effectiveParsed, orgLayout, effectivePalette2, isDark2, void 0, { width: exportWidth, height: exportHeight }, activeTagGroup, hiddenAttributes);
15723
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16033
15724
  }
16034
15725
  if (detectedType === "kanban") {
16035
15726
  const { parseKanban: parseKanban2 } = await Promise.resolve().then(() => (init_parser5(), parser_exports5));
16036
15727
  const { renderKanban: renderKanban2 } = await Promise.resolve().then(() => (init_renderer2(), renderer_exports2));
16037
- const isDark2 = theme === "dark";
16038
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16039
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15728
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
16040
15729
  const kanbanParsed = parseKanban2(content, effectivePalette2);
16041
15730
  if (kanbanParsed.error || kanbanParsed.columns.length === 0) return "";
16042
15731
  const container2 = document.createElement("div");
16043
15732
  container2.style.position = "absolute";
16044
15733
  container2.style.left = "-9999px";
16045
15734
  document.body.appendChild(container2);
16046
- try {
16047
- renderKanban2(container2, kanbanParsed, effectivePalette2, isDark2);
16048
- const svgEl = container2.querySelector("svg");
16049
- if (!svgEl) return "";
16050
- if (theme === "transparent") {
16051
- svgEl.style.background = "none";
16052
- } else if (!svgEl.style.background) {
16053
- svgEl.style.background = effectivePalette2.bg;
16054
- }
16055
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16056
- svgEl.style.fontFamily = FONT_FAMILY;
16057
- const svgHtml = svgEl.outerHTML;
16058
- if (options?.branding !== false) {
16059
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16060
- return injectBranding(svgHtml, brandColor);
16061
- }
16062
- return svgHtml;
16063
- } finally {
16064
- document.body.removeChild(container2);
16065
- }
15735
+ renderKanban2(container2, kanbanParsed, effectivePalette2, theme === "dark");
15736
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16066
15737
  }
16067
15738
  if (detectedType === "class") {
16068
15739
  const { parseClassDiagram: parseClassDiagram2 } = await Promise.resolve().then(() => (init_parser2(), parser_exports2));
16069
15740
  const { layoutClassDiagram: layoutClassDiagram2 } = await Promise.resolve().then(() => (init_layout2(), layout_exports2));
16070
15741
  const { renderClassDiagram: renderClassDiagram2 } = await Promise.resolve().then(() => (init_renderer3(), renderer_exports3));
16071
- const isDark2 = theme === "dark";
16072
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16073
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15742
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
16074
15743
  const classParsed = parseClassDiagram2(content, effectivePalette2);
16075
15744
  if (classParsed.error || classParsed.classes.length === 0) return "";
16076
15745
  const classLayout = layoutClassDiagram2(classParsed);
@@ -16078,48 +15747,15 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
16078
15747
  const titleOffset = classParsed.title ? 40 : 0;
16079
15748
  const exportWidth = classLayout.width + PADDING * 2;
16080
15749
  const exportHeight = classLayout.height + PADDING * 2 + titleOffset;
16081
- const container2 = document.createElement("div");
16082
- container2.style.width = `${exportWidth}px`;
16083
- container2.style.height = `${exportHeight}px`;
16084
- container2.style.position = "absolute";
16085
- container2.style.left = "-9999px";
16086
- document.body.appendChild(container2);
16087
- try {
16088
- renderClassDiagram2(
16089
- container2,
16090
- classParsed,
16091
- classLayout,
16092
- effectivePalette2,
16093
- isDark2,
16094
- void 0,
16095
- { width: exportWidth, height: exportHeight }
16096
- );
16097
- const svgEl = container2.querySelector("svg");
16098
- if (!svgEl) return "";
16099
- if (theme === "transparent") {
16100
- svgEl.style.background = "none";
16101
- } else if (!svgEl.style.background) {
16102
- svgEl.style.background = effectivePalette2.bg;
16103
- }
16104
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16105
- svgEl.style.fontFamily = FONT_FAMILY;
16106
- const svgHtml = svgEl.outerHTML;
16107
- if (options?.branding !== false) {
16108
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16109
- return injectBranding(svgHtml, brandColor);
16110
- }
16111
- return svgHtml;
16112
- } finally {
16113
- document.body.removeChild(container2);
16114
- }
15750
+ const container2 = createExportContainer(exportWidth, exportHeight);
15751
+ renderClassDiagram2(container2, classParsed, classLayout, effectivePalette2, theme === "dark", void 0, { width: exportWidth, height: exportHeight });
15752
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16115
15753
  }
16116
15754
  if (detectedType === "er") {
16117
15755
  const { parseERDiagram: parseERDiagram2 } = await Promise.resolve().then(() => (init_parser3(), parser_exports3));
16118
15756
  const { layoutERDiagram: layoutERDiagram2 } = await Promise.resolve().then(() => (init_layout3(), layout_exports3));
16119
15757
  const { renderERDiagram: renderERDiagram2 } = await Promise.resolve().then(() => (init_renderer4(), renderer_exports4));
16120
- const isDark2 = theme === "dark";
16121
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16122
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15758
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
16123
15759
  const erParsed = parseERDiagram2(content, effectivePalette2);
16124
15760
  if (erParsed.error || erParsed.tables.length === 0) return "";
16125
15761
  const erLayout = layoutERDiagram2(erParsed);
@@ -16127,48 +15763,15 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
16127
15763
  const titleOffset = erParsed.title ? 40 : 0;
16128
15764
  const exportWidth = erLayout.width + PADDING * 2;
16129
15765
  const exportHeight = erLayout.height + PADDING * 2 + titleOffset;
16130
- const container2 = document.createElement("div");
16131
- container2.style.width = `${exportWidth}px`;
16132
- container2.style.height = `${exportHeight}px`;
16133
- container2.style.position = "absolute";
16134
- container2.style.left = "-9999px";
16135
- document.body.appendChild(container2);
16136
- try {
16137
- renderERDiagram2(
16138
- container2,
16139
- erParsed,
16140
- erLayout,
16141
- effectivePalette2,
16142
- isDark2,
16143
- void 0,
16144
- { width: exportWidth, height: exportHeight }
16145
- );
16146
- const svgEl = container2.querySelector("svg");
16147
- if (!svgEl) return "";
16148
- if (theme === "transparent") {
16149
- svgEl.style.background = "none";
16150
- } else if (!svgEl.style.background) {
16151
- svgEl.style.background = effectivePalette2.bg;
16152
- }
16153
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16154
- svgEl.style.fontFamily = FONT_FAMILY;
16155
- const svgHtml = svgEl.outerHTML;
16156
- if (options?.branding !== false) {
16157
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16158
- return injectBranding(svgHtml, brandColor);
16159
- }
16160
- return svgHtml;
16161
- } finally {
16162
- document.body.removeChild(container2);
16163
- }
15766
+ const container2 = createExportContainer(exportWidth, exportHeight);
15767
+ renderERDiagram2(container2, erParsed, erLayout, effectivePalette2, theme === "dark", void 0, { width: exportWidth, height: exportHeight });
15768
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16164
15769
  }
16165
15770
  if (detectedType === "initiative-status") {
16166
15771
  const { parseInitiativeStatus: parseInitiativeStatus2 } = await Promise.resolve().then(() => (init_parser7(), parser_exports7));
16167
15772
  const { layoutInitiativeStatus: layoutInitiativeStatus2 } = await Promise.resolve().then(() => (init_layout4(), layout_exports4));
16168
15773
  const { renderInitiativeStatus: renderInitiativeStatus2 } = await Promise.resolve().then(() => (init_renderer5(), renderer_exports5));
16169
- const isDark2 = theme === "dark";
16170
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16171
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15774
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
16172
15775
  const isParsed = parseInitiativeStatus2(content);
16173
15776
  if (isParsed.error || isParsed.nodes.length === 0) return "";
16174
15777
  const isLayout = layoutInitiativeStatus2(isParsed);
@@ -16176,48 +15779,15 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
16176
15779
  const titleOffset = isParsed.title ? 40 : 0;
16177
15780
  const exportWidth = isLayout.width + PADDING * 2;
16178
15781
  const exportHeight = isLayout.height + PADDING * 2 + titleOffset;
16179
- const container2 = document.createElement("div");
16180
- container2.style.width = `${exportWidth}px`;
16181
- container2.style.height = `${exportHeight}px`;
16182
- container2.style.position = "absolute";
16183
- container2.style.left = "-9999px";
16184
- document.body.appendChild(container2);
16185
- try {
16186
- renderInitiativeStatus2(
16187
- container2,
16188
- isParsed,
16189
- isLayout,
16190
- effectivePalette2,
16191
- isDark2,
16192
- void 0,
16193
- { width: exportWidth, height: exportHeight }
16194
- );
16195
- const svgEl = container2.querySelector("svg");
16196
- if (!svgEl) return "";
16197
- if (theme === "transparent") {
16198
- svgEl.style.background = "none";
16199
- } else if (!svgEl.style.background) {
16200
- svgEl.style.background = effectivePalette2.bg;
16201
- }
16202
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16203
- svgEl.style.fontFamily = FONT_FAMILY;
16204
- const svgHtml = svgEl.outerHTML;
16205
- if (options?.branding !== false) {
16206
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16207
- return injectBranding(svgHtml, brandColor);
16208
- }
16209
- return svgHtml;
16210
- } finally {
16211
- document.body.removeChild(container2);
16212
- }
15782
+ const container2 = createExportContainer(exportWidth, exportHeight);
15783
+ renderInitiativeStatus2(container2, isParsed, isLayout, effectivePalette2, theme === "dark", void 0, { width: exportWidth, height: exportHeight });
15784
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16213
15785
  }
16214
15786
  if (detectedType === "c4") {
16215
15787
  const { parseC4: parseC42 } = await Promise.resolve().then(() => (init_parser6(), parser_exports6));
16216
15788
  const { layoutC4Context: layoutC4Context2, layoutC4Containers: layoutC4Containers2, layoutC4Components: layoutC4Components2, layoutC4Deployment: layoutC4Deployment2 } = await Promise.resolve().then(() => (init_layout5(), layout_exports5));
16217
15789
  const { renderC4Context: renderC4Context2, renderC4Containers: renderC4Containers2 } = await Promise.resolve().then(() => (init_renderer6(), renderer_exports6));
16218
- const isDark2 = theme === "dark";
16219
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16220
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15790
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
16221
15791
  const c4Parsed = parseC42(content, effectivePalette2);
16222
15792
  if (c4Parsed.error || c4Parsed.elements.length === 0) return "";
16223
15793
  const c4Level = options?.c4Level ?? "context";
@@ -16229,81 +15799,22 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
16229
15799
  const titleOffset = c4Parsed.title ? 40 : 0;
16230
15800
  const exportWidth = c4Layout.width + PADDING * 2;
16231
15801
  const exportHeight = c4Layout.height + PADDING * 2 + titleOffset;
16232
- const container2 = document.createElement("div");
16233
- container2.style.width = `${exportWidth}px`;
16234
- container2.style.height = `${exportHeight}px`;
16235
- container2.style.position = "absolute";
16236
- container2.style.left = "-9999px";
16237
- document.body.appendChild(container2);
16238
- try {
16239
- const renderFn = c4Level === "deployment" || c4Level === "components" && c4System && c4Container || c4Level === "containers" && c4System ? renderC4Containers2 : renderC4Context2;
16240
- renderFn(
16241
- container2,
16242
- c4Parsed,
16243
- c4Layout,
16244
- effectivePalette2,
16245
- isDark2,
16246
- void 0,
16247
- { width: exportWidth, height: exportHeight }
16248
- );
16249
- const svgEl = container2.querySelector("svg");
16250
- if (!svgEl) return "";
16251
- if (theme === "transparent") {
16252
- svgEl.style.background = "none";
16253
- } else if (!svgEl.style.background) {
16254
- svgEl.style.background = effectivePalette2.bg;
16255
- }
16256
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16257
- svgEl.style.fontFamily = FONT_FAMILY;
16258
- const svgHtml = svgEl.outerHTML;
16259
- if (options?.branding !== false) {
16260
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16261
- return injectBranding(svgHtml, brandColor);
16262
- }
16263
- return svgHtml;
16264
- } finally {
16265
- document.body.removeChild(container2);
16266
- }
15802
+ const container2 = createExportContainer(exportWidth, exportHeight);
15803
+ const renderFn = c4Level === "deployment" || c4Level === "components" && c4System && c4Container || c4Level === "containers" && c4System ? renderC4Containers2 : renderC4Context2;
15804
+ renderFn(container2, c4Parsed, c4Layout, effectivePalette2, theme === "dark", void 0, { width: exportWidth, height: exportHeight });
15805
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16267
15806
  }
16268
15807
  if (detectedType === "flowchart") {
16269
15808
  const { parseFlowchart: parseFlowchart2 } = await Promise.resolve().then(() => (init_flowchart_parser(), flowchart_parser_exports));
16270
15809
  const { layoutGraph: layoutGraph2 } = await Promise.resolve().then(() => (init_layout6(), layout_exports6));
16271
15810
  const { renderFlowchart: renderFlowchart2 } = await Promise.resolve().then(() => (init_flowchart_renderer(), flowchart_renderer_exports));
16272
- const isDark2 = theme === "dark";
16273
- const { getPalette: getPalette3 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16274
- const effectivePalette2 = palette ?? (isDark2 ? getPalette3("nord").dark : getPalette3("nord").light);
15811
+ const effectivePalette2 = await resolveExportPalette(theme, palette);
16275
15812
  const fcParsed = parseFlowchart2(content, effectivePalette2);
16276
15813
  if (fcParsed.error || fcParsed.nodes.length === 0) return "";
16277
15814
  const layout = layoutGraph2(fcParsed);
16278
- const container2 = document.createElement("div");
16279
- container2.style.width = `${EXPORT_WIDTH}px`;
16280
- container2.style.height = `${EXPORT_HEIGHT}px`;
16281
- container2.style.position = "absolute";
16282
- container2.style.left = "-9999px";
16283
- document.body.appendChild(container2);
16284
- try {
16285
- renderFlowchart2(container2, fcParsed, layout, effectivePalette2, isDark2, void 0, {
16286
- width: EXPORT_WIDTH,
16287
- height: EXPORT_HEIGHT
16288
- });
16289
- const svgEl = container2.querySelector("svg");
16290
- if (!svgEl) return "";
16291
- if (theme === "transparent") {
16292
- svgEl.style.background = "none";
16293
- } else if (!svgEl.style.background) {
16294
- svgEl.style.background = effectivePalette2.bg;
16295
- }
16296
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16297
- svgEl.style.fontFamily = FONT_FAMILY;
16298
- const svgHtml = svgEl.outerHTML;
16299
- if (options?.branding !== false) {
16300
- const brandColor = theme === "transparent" ? "#888" : effectivePalette2.textMuted;
16301
- return injectBranding(svgHtml, brandColor);
16302
- }
16303
- return svgHtml;
16304
- } finally {
16305
- document.body.removeChild(container2);
16306
- }
15815
+ const container2 = createExportContainer(EXPORT_WIDTH, EXPORT_HEIGHT);
15816
+ renderFlowchart2(container2, fcParsed, layout, effectivePalette2, theme === "dark", void 0, { width: EXPORT_WIDTH, height: EXPORT_HEIGHT });
15817
+ return finalizeSvgExport(container2, theme, effectivePalette2, options);
16307
15818
  }
16308
15819
  const parsed = parseD3(content, palette);
16309
15820
  if (parsed.error && parsed.type !== "sequence") {
@@ -16319,56 +15830,32 @@ async function renderD3ForExport(content, theme, palette, orgExportState, option
16319
15830
  if (parsed.type === "venn" && parsed.vennSets.length < 2) return "";
16320
15831
  if (parsed.type === "quadrant" && parsed.quadrantPoints.length === 0)
16321
15832
  return "";
15833
+ const effectivePalette = await resolveExportPalette(theme, palette);
16322
15834
  const isDark = theme === "dark";
16323
- const { getPalette: getPalette2 } = await Promise.resolve().then(() => (init_palettes(), palettes_exports));
16324
- const effectivePalette = palette ?? (isDark ? getPalette2("nord").dark : getPalette2("nord").light);
16325
- const container = document.createElement("div");
16326
- container.style.width = `${EXPORT_WIDTH}px`;
16327
- container.style.height = `${EXPORT_HEIGHT}px`;
16328
- container.style.position = "absolute";
16329
- container.style.left = "-9999px";
16330
- document.body.appendChild(container);
15835
+ const container = createExportContainer(EXPORT_WIDTH, EXPORT_HEIGHT);
16331
15836
  const dims = { width: EXPORT_WIDTH, height: EXPORT_HEIGHT };
16332
- try {
16333
- if (parsed.type === "sequence") {
16334
- const { parseSequenceDgmo: parseSequenceDgmo2 } = await Promise.resolve().then(() => (init_parser(), parser_exports));
16335
- const { renderSequenceDiagram: renderSequenceDiagram2 } = await Promise.resolve().then(() => (init_renderer7(), renderer_exports7));
16336
- const seqParsed = parseSequenceDgmo2(content);
16337
- if (seqParsed.error || seqParsed.participants.length === 0) return "";
16338
- renderSequenceDiagram2(container, seqParsed, effectivePalette, isDark, void 0, {
16339
- exportWidth: EXPORT_WIDTH
16340
- });
16341
- } else if (parsed.type === "wordcloud") {
16342
- await renderWordCloudAsync(container, parsed, effectivePalette, isDark, dims);
16343
- } else if (parsed.type === "arc") {
16344
- renderArcDiagram(container, parsed, effectivePalette, isDark, void 0, dims);
16345
- } else if (parsed.type === "timeline") {
16346
- renderTimeline(container, parsed, effectivePalette, isDark, void 0, dims);
16347
- } else if (parsed.type === "venn") {
16348
- renderVenn(container, parsed, effectivePalette, isDark, void 0, dims);
16349
- } else if (parsed.type === "quadrant") {
16350
- renderQuadrant(container, parsed, effectivePalette, isDark, void 0, dims);
16351
- } else {
16352
- renderSlopeChart(container, parsed, effectivePalette, isDark, void 0, dims);
16353
- }
16354
- const svgEl = container.querySelector("svg");
16355
- if (!svgEl) return "";
16356
- if (theme === "transparent") {
16357
- svgEl.style.background = "none";
16358
- } else if (!svgEl.style.background) {
16359
- svgEl.style.background = effectivePalette.bg;
16360
- }
16361
- svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
16362
- svgEl.style.fontFamily = FONT_FAMILY;
16363
- const svgHtml = svgEl.outerHTML;
16364
- if (options?.branding !== false) {
16365
- const brandColor = theme === "transparent" ? "#888" : effectivePalette.textMuted;
16366
- return injectBranding(svgHtml, brandColor);
16367
- }
16368
- return svgHtml;
16369
- } finally {
16370
- document.body.removeChild(container);
15837
+ if (parsed.type === "sequence") {
15838
+ const { parseSequenceDgmo: parseSequenceDgmo2 } = await Promise.resolve().then(() => (init_parser(), parser_exports));
15839
+ const { renderSequenceDiagram: renderSequenceDiagram2 } = await Promise.resolve().then(() => (init_renderer7(), renderer_exports7));
15840
+ const seqParsed = parseSequenceDgmo2(content);
15841
+ if (seqParsed.error || seqParsed.participants.length === 0) return "";
15842
+ renderSequenceDiagram2(container, seqParsed, effectivePalette, isDark, void 0, {
15843
+ exportWidth: EXPORT_WIDTH
15844
+ });
15845
+ } else if (parsed.type === "wordcloud") {
15846
+ await renderWordCloudAsync(container, parsed, effectivePalette, isDark, dims);
15847
+ } else if (parsed.type === "arc") {
15848
+ renderArcDiagram(container, parsed, effectivePalette, isDark, void 0, dims);
15849
+ } else if (parsed.type === "timeline") {
15850
+ renderTimeline(container, parsed, effectivePalette, isDark, void 0, dims);
15851
+ } else if (parsed.type === "venn") {
15852
+ renderVenn(container, parsed, effectivePalette, isDark, void 0, dims);
15853
+ } else if (parsed.type === "quadrant") {
15854
+ renderQuadrant(container, parsed, effectivePalette, isDark, void 0, dims);
15855
+ } else {
15856
+ renderSlopeChart(container, parsed, effectivePalette, isDark, void 0, dims);
16371
15857
  }
15858
+ return finalizeSvgExport(container, theme, effectivePalette, options);
16372
15859
  }
16373
15860
  var DEFAULT_CLOUD_OPTIONS, STOP_WORDS, SLOPE_MARGIN, SLOPE_LABEL_FONT_SIZE, SLOPE_CHAR_WIDTH, ARC_MARGIN, MONTH_ABBR, EXPORT_WIDTH, EXPORT_HEIGHT;
16374
15861
  var init_d3 = __esm({
@@ -17089,6 +16576,7 @@ init_branding();
17089
16576
  export {
17090
16577
  DGMO_CHART_TYPE_MAP,
17091
16578
  RULE_COUNT,
16579
+ STANDARD_CHART_TYPES,
17092
16580
  addDurationToDate,
17093
16581
  applyGroupOrdering,
17094
16582
  applyPositionOverrides,