@diagrammo/dgmo 0.48.2 → 0.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/.cursorrules +8 -3
  2. package/.github/copilot-instructions.md +8 -3
  3. package/.windsurfrules +8 -3
  4. package/SKILL.md +8 -3
  5. package/dist/advanced.d.ts +444 -1
  6. package/dist/advanced.js +208 -146
  7. package/dist/auto.css +63 -0
  8. package/dist/auto.js +202 -102
  9. package/dist/auto.mjs +6849 -824
  10. package/dist/block.css +63 -0
  11. package/dist/block.d.ts +13 -5
  12. package/dist/block.js +137 -57
  13. package/dist/{charts-d3-QOZHKTCT.js → charts-d3-EW3YQTEA.js} +9 -8
  14. package/dist/chunk-26RVGM44.js +331 -0
  15. package/dist/{chunk-44CM72SQ.js → chunk-2WMBWZY2.js} +3 -3
  16. package/dist/{chunk-L66GEFB6.js → chunk-35BBZDFE.js} +4 -4
  17. package/dist/{chunk-4GRI7MEB.js → chunk-3BIAFYD2.js} +6 -6
  18. package/dist/chunk-3NFJWFNP.js +1474 -0
  19. package/dist/{chunk-76OWZ3BA.js → chunk-4BD7EVPK.js} +2 -2
  20. package/dist/{chunk-MITI6NOL.js → chunk-4FIV4K4Z.js} +9 -9
  21. package/dist/chunk-4HVNZ7WF.js +574 -0
  22. package/dist/{chunk-X5LCYCL5.js → chunk-4NQ3IKUM.js} +2 -2
  23. package/dist/{chunk-PWIHZ6NJ.js → chunk-4UDKKGHH.js} +4 -4
  24. package/dist/{chunk-6NYWYNBI.js → chunk-4XK3FLFB.js} +3 -3
  25. package/dist/chunk-4YNP6O47.js +607 -0
  26. package/dist/{chunk-3MQQNXPD.js → chunk-5FGDJIJX.js} +3 -3
  27. package/dist/{chunk-WCT3NYCV.js → chunk-5LWQH6QV.js} +1 -1
  28. package/dist/chunk-5XCM7UUW.js +261 -0
  29. package/dist/{chunk-RYEGFMUO.js → chunk-5ZZLLBFK.js} +2 -2
  30. package/dist/{chunk-EB6FPQUP.js → chunk-65RTDUZH.js} +3 -3
  31. package/dist/chunk-6CLKNXVP.js +664 -0
  32. package/dist/{chunk-H6PI3KJT.js → chunk-6IUAK7RZ.js} +2 -2
  33. package/dist/{chunk-ZGR7ULFJ.js → chunk-6SA7FJE4.js} +31 -19
  34. package/dist/{chunk-LIOHW36Z.js → chunk-6VE3VLWM.js} +3 -3
  35. package/dist/{chunk-AN2MOO5T.js → chunk-7OVSJI2V.js} +3 -3
  36. package/dist/{chunk-YAA6IID3.js → chunk-7UEMZREK.js} +2 -2
  37. package/dist/{chunk-FCIIHT24.js → chunk-7VLUGEMJ.js} +7 -7
  38. package/dist/{chunk-VOKGH627.js → chunk-AHGF2YYA.js} +13 -3
  39. package/dist/{chunk-3R5POCTZ.js → chunk-AJ2PEY7J.js} +6 -6
  40. package/dist/{chunk-PBHE5UG6.js → chunk-ALRHIR6I.js} +46 -12
  41. package/dist/{chunk-7JEGTRLD.js → chunk-B57V3DWN.js} +3 -3
  42. package/dist/{chunk-ILKORZ3H.js → chunk-BCT5G2VN.js} +7 -7
  43. package/dist/{chunk-TYS6CSS5.js → chunk-BCYVE3N5.js} +2 -2
  44. package/dist/{chunk-ZBWMSD5N.js → chunk-BGJV5ATD.js} +4 -4
  45. package/dist/{chunk-G2H74XJZ.js → chunk-BPIJLRYE.js} +8 -8
  46. package/dist/{chunk-YGJTDXVR.js → chunk-C4GQDB5L.js} +2 -2
  47. package/dist/{chunk-Y2ZE3MSG.js → chunk-C63UWAKM.js} +2 -2
  48. package/dist/{chunk-QEBUY5NY.js → chunk-CEHZOPGM.js} +4 -4
  49. package/dist/{chunk-725LDASD.js → chunk-CLD2OKV7.js} +2 -2
  50. package/dist/{chunk-5QXL4NYS.js → chunk-CLR4A2N2.js} +10 -5
  51. package/dist/{chunk-WBRZJOEC.js → chunk-CMCR5WBW.js} +3 -3
  52. package/dist/{chunk-SML67VPV.js → chunk-D5AVQCDN.js} +3 -3
  53. package/dist/{chunk-2LACINWN.js → chunk-DDTJ5N7Q.js} +9 -9
  54. package/dist/{chunk-FITOLXSX.js → chunk-EOFPYPAU.js} +26 -2
  55. package/dist/{chunk-B65G5DNL.js → chunk-EYN7VFKL.js} +3 -3
  56. package/dist/{chunk-4OHACBGX.js → chunk-F2L5GCQ4.js} +2 -2
  57. package/dist/{chunk-RVMRZAPB.js → chunk-F743CM2N.js} +3 -3
  58. package/dist/{chunk-3JLKYGBQ.js → chunk-F7BFXWNQ.js} +2 -2
  59. package/dist/{chunk-WCSOJFU3.js → chunk-FMKTYMP4.js} +3 -3
  60. package/dist/{chunk-RTLBSQ3G.js → chunk-FUCAB3KQ.js} +3 -3
  61. package/dist/{chunk-SGZYXELT.js → chunk-GB3YZTAM.js} +9 -6
  62. package/dist/{chunk-QLCCJEJI.js → chunk-HBVD67XG.js} +2 -2
  63. package/dist/{chunk-PBAHEPLQ.js → chunk-HGN652MU.js} +7 -6
  64. package/dist/{chunk-3SMGIJDD.js → chunk-HHXOONLX.js} +13 -1
  65. package/dist/{chunk-QOOUC2J5.js → chunk-HQCHYB5F.js} +2 -2
  66. package/dist/chunk-IAEC4KLA.js +492 -0
  67. package/dist/{chunk-J5FIXQRT.js → chunk-IBC35BTK.js} +4 -4
  68. package/dist/{chunk-NURGB5Z4.js → chunk-IFK3GIUW.js} +2 -2
  69. package/dist/{chunk-FANX6UJR.js → chunk-IHLSHCPZ.js} +11 -11
  70. package/dist/{chunk-GMR5MFHJ.js → chunk-IUK7AGD4.js} +2 -2
  71. package/dist/chunk-IVKC4GID.js +32 -0
  72. package/dist/{chunk-OJR3MQYV.js → chunk-JFPY3UJ7.js} +296 -57
  73. package/dist/{chunk-5MLYVTYM.js → chunk-K6HNAY5V.js} +2 -2
  74. package/dist/{chunk-P235SVAH.js → chunk-KQAEKMIX.js} +2 -2
  75. package/dist/{chunk-7DTWEFUE.js → chunk-KUBBJ2CD.js} +10 -10
  76. package/dist/{chunk-BUVJFRPY.js → chunk-KV6Y2HE6.js} +4 -4
  77. package/dist/{chunk-OURHMODR.js → chunk-LG4TWW4U.js} +13 -13
  78. package/dist/{chunk-XAKEUMEJ.js → chunk-LVHPTBO3.js} +3 -3
  79. package/dist/{chunk-ERLBPDGU.js → chunk-MJCG5K2O.js} +2 -2
  80. package/dist/{chunk-THXCFRTU.js → chunk-N4J5KGWG.js} +12 -12
  81. package/dist/{chunk-MZSBFAPJ.js → chunk-NVT6C2VE.js} +9 -9
  82. package/dist/{chunk-AELOBFW5.js → chunk-O5MQPK7E.js} +3 -3
  83. package/dist/{chunk-JM4LEPY3.js → chunk-O7NUCTFU.js} +2 -2
  84. package/dist/{chunk-JED6ZDEE.js → chunk-O7WP4ZD4.js} +2 -2
  85. package/dist/{chunk-ZO27FGJS.js → chunk-PH5X4GIP.js} +2 -2
  86. package/dist/{chunk-B7JUCQUA.js → chunk-PU3AUQPA.js} +4 -4
  87. package/dist/{chunk-YGJZWZTY.js → chunk-PZFVK3IH.js} +2 -2
  88. package/dist/chunk-QQJUTGQH.js +135 -0
  89. package/dist/{chunk-HSH73DP6.js → chunk-RI4NIMFP.js} +99 -39
  90. package/dist/{chunk-33LCUH4H.js → chunk-RTERS6S5.js} +3 -3
  91. package/dist/{chunk-T3UBLACL.js → chunk-SCQ5VPUF.js} +19 -5
  92. package/dist/chunk-SGHSY3LU.js +377 -0
  93. package/dist/{chunk-SRTU6HMQ.js → chunk-SJEGO2QL.js} +8 -8
  94. package/dist/chunk-SQDFK5ZQ.js +273 -0
  95. package/dist/{chunk-PZMETGLY.js → chunk-SVDWQGX2.js} +296 -121
  96. package/dist/{chunk-Z5CGSFJB.js → chunk-T7IKPCMI.js} +4 -4
  97. package/dist/chunk-TC3YWBFO.js +233 -0
  98. package/dist/{chunk-EVCVDTXE.js → chunk-TLKMTQYL.js} +3 -3
  99. package/dist/{chunk-IJZFN3HM.js → chunk-TWQUYVP3.js} +4 -4
  100. package/dist/{chunk-IZMRON6C.js → chunk-UVCXZEGU.js} +2 -2
  101. package/dist/{chunk-CKNVO24D.js → chunk-UWDO3O52.js} +2 -2
  102. package/dist/{chunk-RJE5JTVK.js → chunk-VC3TR4NL.js} +7 -7
  103. package/dist/{chunk-CI2G3OEB.js → chunk-X2CH42BN.js} +9 -9
  104. package/dist/{chunk-6HO5ZTXK.js → chunk-XCC2RENT.js} +2 -2
  105. package/dist/chunk-XHVV4NVW.js +51 -0
  106. package/dist/{chunk-ZJEL4H2R.js → chunk-XJ7J6WOO.js} +9 -9
  107. package/dist/{chunk-ULOEATBZ.js → chunk-XKTN7CZF.js} +106 -29
  108. package/dist/{chunk-IPWPWM6R.js → chunk-YM2BSPYW.js} +111 -10
  109. package/dist/{chunk-BUPDIHML.js → chunk-YRVLP7UU.js} +3 -3
  110. package/dist/{chunk-T2OE3YQB.js → chunk-YTN572Q2.js} +3 -3
  111. package/dist/{chunk-WVAJFAIA.js → chunk-YYX3SU6H.js} +3 -3
  112. package/dist/{chunk-MO5YHHMQ.js → chunk-ZDUQGL3N.js} +2 -2
  113. package/dist/{chunk-Y3J7VR52.js → chunk-ZNQX6QWH.js} +30 -2
  114. package/dist/{chunk-UWN33VNX.js → chunk-ZREZOIGS.js} +8 -8
  115. package/dist/{chunk-6SM5NJQH.js → chunk-ZTLWVRNS.js} +4 -4
  116. package/dist/{chunk-RUNNI6VE.js → chunk-ZXL6MB4R.js} +3 -3
  117. package/dist/cli.cjs +159 -122
  118. package/dist/dgmo-router-ODKPEJ3P.js +79 -0
  119. package/dist/dimensions-WSIJXT5Q.js +22 -0
  120. package/dist/editor.js +4 -1
  121. package/dist/element.js +203 -103
  122. package/dist/element.mjs +6849 -824
  123. package/dist/{flowchart-parser-ZNSKIBVR.js → flowchart-parser-IVZN7CQN.js} +4 -4
  124. package/dist/{flowchart-renderer-SNDSII4D.js → flowchart-renderer-GMI2U3DD.js} +9 -9
  125. package/dist/highlight.js +7 -1
  126. package/dist/index.d.ts +5 -1
  127. package/dist/index.js +193 -232
  128. package/dist/{layout-HRBZPFCN.js → layout-34CLNICW.js} +5 -5
  129. package/dist/{layout-5RA6QWR6.js → layout-4Z5JM7PT.js} +6 -6
  130. package/dist/layout-6RDJHS6E.js +9 -0
  131. package/dist/{layout-7QXCNOVS.js → layout-7H4H46CS.js} +3 -3
  132. package/dist/{layout-46N4JJYK.js → layout-7SKMFYHL.js} +5 -5
  133. package/dist/{layout-HWDSRX5E.js → layout-D42XE4RE.js} +6 -6
  134. package/dist/{layout-EE6GE46Y.js → layout-DC4TVXER.js} +5 -5
  135. package/dist/layout-FGQWRYYW.js +14 -0
  136. package/dist/layout-GZ2CWONU.js +14 -0
  137. package/dist/layout-HQMBPJVS.js +10 -0
  138. package/dist/{layout-UM5F4DJB.js → layout-K2ZN3Q42.js} +5 -5
  139. package/dist/{layout-S2QBYSK2.js → layout-NXG63LWH.js} +3 -3
  140. package/dist/{layout-N76NR4ZO.js → layout-PUQCB6AN.js} +7 -7
  141. package/dist/{layout-HYZPWAK5.js → layout-QNUQLEHU.js} +3 -3
  142. package/dist/layout-S3EK4IYO.js +14 -0
  143. package/dist/{layout-search-OYV77HHS.js → layout-search-QS44PI5R.js} +6 -6
  144. package/dist/{parser-KNSQSKQO.js → parser-4BKIFG2C.js} +5 -5
  145. package/dist/{parser-OV7NOBW6.js → parser-4ROBKVUR.js} +4 -4
  146. package/dist/parser-667RGSUW.js +13 -0
  147. package/dist/{parser-IXSZZQHY.js → parser-BL7Z72EY.js} +4 -4
  148. package/dist/{parser-AQETEVRW.js → parser-CLMFZWCC.js} +4 -4
  149. package/dist/{parser-XKRP7QKP.js → parser-D6ONJQFR.js} +3 -3
  150. package/dist/{parser-2EWECDSA.js → parser-DERPY5KC.js} +4 -4
  151. package/dist/{parser-4OGOBJJ4.js → parser-GFSOPDB7.js} +4 -4
  152. package/dist/{parser-2MFP2H2E.js → parser-HVJFTOXL.js} +3 -3
  153. package/dist/{parser-VQP2UJ6W.js → parser-IKZFTLOJ.js} +3 -3
  154. package/dist/parser-J3P2D6IP.js +13 -0
  155. package/dist/{parser-PQ3POX45.js → parser-JD7OQ2E6.js} +4 -4
  156. package/dist/{parser-O5J4VBII.js → parser-K647FRI4.js} +3 -3
  157. package/dist/{parser-NGU3ETO6.js → parser-KPMN5KKE.js} +4 -4
  158. package/dist/{parser-4FL2CMDG.js → parser-MBJSBTL5.js} +4 -4
  159. package/dist/{parser-TFZFBVWN.js → parser-MCJWF5G3.js} +3 -3
  160. package/dist/{parser-NRAI6O25.js → parser-MRBPXXIV.js} +4 -4
  161. package/dist/{parser-6BTRLKRZ.js → parser-OBQG655V.js} +4 -4
  162. package/dist/{parser-3STE62GB.js → parser-QJYS7KQQ.js} +4 -4
  163. package/dist/{parser-XDVELHRK.js → parser-SMBJO3XN.js} +4 -4
  164. package/dist/{parser-TRTHDFPP.js → parser-TITK4YW6.js} +5 -5
  165. package/dist/{parser-I6KXEYFK.js → parser-TNYX5S7E.js} +4 -4
  166. package/dist/{parser-Y6WTBU76.js → parser-UBGPTIZD.js} +3 -3
  167. package/dist/parser-UGA23PYK.js +14 -0
  168. package/dist/{parser-N5O4IHUN.js → parser-WISPH7LW.js} +4 -4
  169. package/dist/{parser-CFZD5IBL.js → parser-XWUDFJ7P.js} +4 -4
  170. package/dist/parser-ZKF5K2H2.js +15 -0
  171. package/dist/{parser-ZSDPZYQP.js → parser-ZYC3XGNS.js} +4 -4
  172. package/dist/{renderer-AWWAF6XD.js → renderer-4IUPINAE.js} +10 -10
  173. package/dist/renderer-6L3NBEY5.js +24 -0
  174. package/dist/{renderer-ZRNG54CW.js → renderer-6T3KK4S3.js} +11 -11
  175. package/dist/{renderer-KQB7UGDS.js → renderer-7RH2SI3B.js} +3 -3
  176. package/dist/{renderer-6EEZHMH4.js → renderer-A5VFZQQK.js} +9 -9
  177. package/dist/{renderer-5MYBMBYO.js → renderer-BB5PREMY.js} +5 -5
  178. package/dist/{renderer-BYCNMBF7.js → renderer-CGW7QPNA.js} +10 -10
  179. package/dist/{renderer-QIWVHWZO.js → renderer-DAXMXIKD.js} +3 -3
  180. package/dist/{renderer-7MVLWWQD.js → renderer-DKESNMU5.js} +9 -9
  181. package/dist/{renderer-UV6MI64M.js → renderer-HVCU2C3Z.js} +3 -3
  182. package/dist/{renderer-VACVQYML.js → renderer-LWGJFT3D.js} +8 -8
  183. package/dist/{renderer-PGX2TKVS.js → renderer-MFJ7HY2H.js} +8 -8
  184. package/dist/{renderer-B2OMQIQG.js → renderer-MJDDU27W.js} +15 -15
  185. package/dist/{renderer-4JHRUBE6.js → renderer-QL5KO6SK.js} +10 -10
  186. package/dist/{renderer-W4M6QLIJ.js → renderer-QNHUXCRL.js} +14 -14
  187. package/dist/{renderer-ZGNTUWC4.js → renderer-ROV756WT.js} +8 -8
  188. package/dist/{renderer-YY2OSF6E.js → renderer-SQ3JUAI7.js} +9 -9
  189. package/dist/renderer-THD6V5TL.js +22 -0
  190. package/dist/{renderer-5NDVNDAZ.js → renderer-TPIBXNOS.js} +9 -9
  191. package/dist/{renderer-RPOA5YPZ.js → renderer-TYXRHMRI.js} +13 -13
  192. package/dist/{renderer-N43WR5GV.js → renderer-UZF3JROD.js} +11 -11
  193. package/dist/{renderer-6W5462RB.js → renderer-V3JEMWMM.js} +9 -9
  194. package/dist/{renderer-JGBKUCZD.js → renderer-VFUVRNLK.js} +4 -4
  195. package/dist/{renderer-Z7I3W2PP.js → renderer-VICQ4WNY.js} +8 -8
  196. package/dist/renderer-W5RMOURB.js +21 -0
  197. package/dist/renderer-XEKIRPI6.js +23 -0
  198. package/dist/{renderer-CLJHQPBJ.js → renderer-YHXPN3GF.js} +12 -12
  199. package/dist/renderer-radial-MHO2VDXN.js +21 -0
  200. package/dist/{resolver-NOAA7ID7.js → resolver-FHBCO3PL.js} +3 -3
  201. package/dist/{state-parser-Z2V23ATR.js → state-parser-RX3GXOIB.js} +4 -4
  202. package/dist/{state-renderer-B4DQBM6M.js → state-renderer-AJUKGNWU.js} +9 -9
  203. package/docs/ai-integration.md +8 -3
  204. package/docs/language-reference.md +179 -5
  205. package/gallery/fixtures/family.dgmo +23 -0
  206. package/gallery/fixtures/sketch.dgmo +22 -0
  207. package/package.json +1 -1
  208. package/dist/chunk-ODZVHU3R.js +0 -153
  209. package/dist/dgmo-router-X35VLZLM.js +0 -73
  210. package/dist/dimensions-J3FHIMJ6.js +0 -22
  211. package/dist/layout-5T6RH5M6.js +0 -14
  212. package/dist/layout-G23F7LDH.js +0 -9
  213. package/dist/layout-OB3RI63S.js +0 -14
  214. package/dist/parser-JAL2HD4I.js +0 -13
  215. package/dist/renderer-SMIBCRVB.js +0 -24
  216. package/dist/renderer-radial-C32GPJQ7.js +0 -21
@@ -0,0 +1,607 @@
1
+ import {
2
+ SKETCH_DIAGNOSTIC_CODES
3
+ } from "./chunk-XHVV4NVW.js";
4
+ import {
5
+ AUTO_TAG_COLOR_SENTINEL,
6
+ finalizeAutoTagColors,
7
+ injectDefaultTagMetadata,
8
+ matchTagBlockHeading,
9
+ stripDefaultModifier,
10
+ tagAttrKey,
11
+ validateTagGroupNames,
12
+ validateTagValues
13
+ } from "./chunk-HBVD67XG.js";
14
+ import {
15
+ parseInArrowLabel
16
+ } from "./chunk-FFUN5D66.js";
17
+ import {
18
+ normalizeName
19
+ } from "./chunk-NOTA6TEI.js";
20
+ import {
21
+ SKETCH_REGISTRY,
22
+ extractColor,
23
+ measureIndent,
24
+ parseFirstLine,
25
+ splitNameAndMeta,
26
+ stripQuotes,
27
+ warnUnknownMetaKeys,
28
+ withTagAliases
29
+ } from "./chunk-ZNQX6QWH.js";
30
+ import {
31
+ NAME_DIAGNOSTIC_CODES,
32
+ formatDgmoError,
33
+ makeDgmoError,
34
+ makeFail,
35
+ nameMergedMessage,
36
+ suggest
37
+ } from "./chunk-CXK4DZH3.js";
38
+
39
+ // src/sketch/types.ts
40
+ var SKETCH_SHAPE_KINDS = [
41
+ "rectangle",
42
+ "database",
43
+ "queue",
44
+ "person",
45
+ "document",
46
+ "note"
47
+ ];
48
+ function isSketchShapeKind(value) {
49
+ return SKETCH_SHAPE_KINDS.includes(value);
50
+ }
51
+
52
+ // src/sketch/parser.ts
53
+ var EDGE_FORMS = [
54
+ { re: /^<-(.+?)->\s*(.+)$/, heads: "both", dashed: false, labeled: true },
55
+ { re: /^<~(.+?)~>\s*(.+)$/, heads: "both", dashed: true, labeled: true },
56
+ { re: /^<->\s*(.+)$/, heads: "both", dashed: false, labeled: false },
57
+ { re: /^<~>\s*(.+)$/, heads: "both", dashed: true, labeled: false },
58
+ { re: /^-(.+?)->\s*(.+)$/, heads: "one", dashed: false, labeled: true },
59
+ { re: /^~(.+?)~>\s*(.+)$/, heads: "one", dashed: true, labeled: true },
60
+ { re: /^->\s*(.+)$/, heads: "one", dashed: false, labeled: false },
61
+ { re: /^~>\s*(.+)$/, heads: "one", dashed: true, labeled: false },
62
+ { re: /^--\s+(.+)$/, heads: "none", dashed: false, labeled: false },
63
+ { re: /^~~\s+(.+)$/, heads: "none", dashed: true, labeled: false },
64
+ { re: /^-(.+?)-\s+(.+)$/, heads: "none", dashed: false, labeled: true },
65
+ { re: /^~(.+?)~\s+(.+)$/, heads: "none", dashed: true, labeled: true }
66
+ ];
67
+ var EDGE_START_RE = /^[<\-~]/;
68
+ var LEFT_ARROW_RE = /^<[-~](?![-~]?>)/;
69
+ var BOX_RE = /^\[([^\]]*)\]\s*(.*)$/;
70
+ var BOX_TAIL_ALIAS_RE = /^as\s+([A-Za-z][A-Za-z0-9_]{0,11})(?=\s|,|$)\s*,?\s*/;
71
+ var AT_VALUE_RE = /^(-?\d+)\s+(-?\d+)$/;
72
+ function parseSketch(content, palette) {
73
+ const options = {
74
+ noLegend: false,
75
+ solidFill: false,
76
+ noDescriptions: false
77
+ };
78
+ const result = {
79
+ type: "sketch",
80
+ title: null,
81
+ titleLineNumber: null,
82
+ nodes: [],
83
+ edges: [],
84
+ boxes: [],
85
+ tagGroups: [],
86
+ options,
87
+ diagnostics: [],
88
+ error: null
89
+ };
90
+ const fail = makeFail(result);
91
+ const pushError = (line, message, code) => {
92
+ result.diagnostics.push(makeDgmoError(line, message, "error", code));
93
+ };
94
+ const warn = (line, message, code) => {
95
+ result.diagnostics.push(makeDgmoError(line, message, "warning", code));
96
+ };
97
+ if (!content?.trim()) {
98
+ return fail(0, "No content provided");
99
+ }
100
+ const lines = content.split("\n");
101
+ const nodes = [];
102
+ const boxes = [];
103
+ const nodeById = /* @__PURE__ */ new Map();
104
+ const aliasIndex = /* @__PURE__ */ new Map();
105
+ const labelIndex = /* @__PURE__ */ new Map();
106
+ const boxByNorm = /* @__PURE__ */ new Map();
107
+ const pendingEdges = [];
108
+ const tagAliasMap = /* @__PURE__ */ new Map();
109
+ let idCounter = 0;
110
+ const registryFor = () => withTagAliases(SKETCH_REGISTRY, new Set(tagAliasMap.keys()));
111
+ const parseAt = (raw, lineNumber) => {
112
+ if (raw === void 0) return null;
113
+ const m = raw.trim().match(AT_VALUE_RE);
114
+ if (!m) {
115
+ warn(
116
+ lineNumber,
117
+ `Invalid at: value "${raw}" \u2014 expected two integers (at: C R); shape will flow-place`
118
+ );
119
+ return null;
120
+ }
121
+ return { c: parseInt(m[1], 10), r: parseInt(m[2], 10) };
122
+ };
123
+ const liftReserved = (meta, lineNumber) => {
124
+ let shape = "rectangle";
125
+ const shapeRaw = meta["shape"];
126
+ if (shapeRaw !== void 0) {
127
+ const kind = shapeRaw.trim().toLowerCase();
128
+ if (kind === "rectangle" || isSketchShapeKind(kind)) {
129
+ shape = kind;
130
+ } else {
131
+ warn(
132
+ lineNumber,
133
+ `Unknown shape "${shapeRaw}" \u2014 rendered as a rectangle (valid: database, queue, person, document, note)`,
134
+ SKETCH_DIAGNOSTIC_CODES.UNKNOWN_SHAPE
135
+ );
136
+ }
137
+ delete meta["shape"];
138
+ }
139
+ const at = parseAt(meta["at"], lineNumber);
140
+ delete meta["at"];
141
+ delete meta["collapsed"];
142
+ return { shape, at };
143
+ };
144
+ const addShape = (trimmed, lineNumber, box) => {
145
+ const snm = splitNameAndMeta(
146
+ trimmed,
147
+ registryFor(),
148
+ tagAliasMap,
149
+ palette,
150
+ result.diagnostics,
151
+ lineNumber
152
+ );
153
+ let label = stripQuotes(snm.name.trim()).trim();
154
+ if (snm.color) label = `${label} ${snm.color}`.trim();
155
+ if (!label) {
156
+ warn(lineNumber, `Shape line has no name \u2014 ignored`);
157
+ return null;
158
+ }
159
+ const meta = { ...snm.meta };
160
+ warnUnknownMetaKeys(
161
+ meta,
162
+ registryFor(),
163
+ (m) => warn(lineNumber, m),
164
+ snm.name
165
+ );
166
+ const { shape, at } = liftReserved(meta, lineNumber);
167
+ const norm = normalizeName(label);
168
+ if (snm.alias !== void 0 && aliasIndex.has(snm.alias)) {
169
+ warn(
170
+ lineNumber,
171
+ `Duplicate alias "${snm.alias}" \u2014 the first declaration keeps it`
172
+ );
173
+ }
174
+ const alias = snm.alias !== void 0 && !aliasIndex.has(snm.alias) ? snm.alias : void 0;
175
+ if (alias === void 0 && snm.alias === void 0) {
176
+ const existing = labelIndex.get(norm);
177
+ if (existing && existing.length > 0) {
178
+ const first = nodeById.get(existing[0]);
179
+ for (const [k, v] of Object.entries(meta)) {
180
+ if (!(k in first.metadata)) first.metadata[k] = v;
181
+ }
182
+ if (first.at === null && at !== null) first.at = at;
183
+ if (first.shape === "rectangle" && shape !== "rectangle") {
184
+ first.shape = shape;
185
+ }
186
+ warn(
187
+ lineNumber,
188
+ nameMergedMessage({
189
+ incomingDisplay: label,
190
+ incomingLine: lineNumber,
191
+ existingDisplay: first.label,
192
+ existingLine: first.lineNumber
193
+ }),
194
+ NAME_DIAGNOSTIC_CODES.NAME_MERGED
195
+ );
196
+ return first;
197
+ }
198
+ }
199
+ const id = `sketch-node-${++idCounter}`;
200
+ const node = {
201
+ id,
202
+ label,
203
+ ...alias !== void 0 && { alias },
204
+ shape,
205
+ at,
206
+ metadata: meta,
207
+ ...box !== null && { boxLabel: box.label },
208
+ lineNumber
209
+ };
210
+ nodes.push(node);
211
+ nodeById.set(id, node);
212
+ if (alias !== void 0) aliasIndex.set(alias, id);
213
+ const list = labelIndex.get(norm);
214
+ if (list) list.push(id);
215
+ else labelIndex.set(norm, [id]);
216
+ if (box !== null) box.children.push(id);
217
+ return node;
218
+ };
219
+ const parseBoxTail = (tail, lineNumber) => {
220
+ let rest = tail.trim();
221
+ let alias;
222
+ const aliasMatch = rest.match(BOX_TAIL_ALIAS_RE);
223
+ if (aliasMatch) {
224
+ alias = aliasMatch[1];
225
+ rest = rest.slice(aliasMatch[0].length);
226
+ }
227
+ let collapsed = false;
228
+ rest = rest.replace(/(^|,|\s)collapsed(?=\s|,|$)/i, (_m, pre) => {
229
+ collapsed = true;
230
+ return pre === "," ? "," : pre;
231
+ });
232
+ const meta = {};
233
+ let at = null;
234
+ for (const seg of rest.split(",")) {
235
+ const t = seg.trim();
236
+ if (!t) continue;
237
+ const colonIdx = t.indexOf(":");
238
+ if (colonIdx < 0) {
239
+ warn(lineNumber, `Unrecognized box metadata "${t}" \u2014 ignored`);
240
+ continue;
241
+ }
242
+ const rawKey = t.slice(0, colonIdx).trim().toLowerCase();
243
+ const value = t.slice(colonIdx + 1).trim();
244
+ if (rawKey === "at") {
245
+ at = parseAt(value, lineNumber);
246
+ } else if (value) {
247
+ meta[tagAliasMap.get(rawKey) ?? rawKey] = value;
248
+ }
249
+ }
250
+ return { ...alias !== void 0 && { alias }, at, collapsed, meta };
251
+ };
252
+ const openBox = (label, tail, lineNumber) => {
253
+ const norm = normalizeName(label);
254
+ const existing = boxByNorm.get(norm);
255
+ const { alias, at, collapsed, meta } = parseBoxTail(tail, lineNumber);
256
+ if (existing) {
257
+ warn(
258
+ lineNumber,
259
+ `Box "${label}" already declared on line ${existing.lineNumber} \u2014 shapes are added to it`
260
+ );
261
+ return existing;
262
+ }
263
+ const box = {
264
+ id: `[${norm}]`,
265
+ label: label.trim(),
266
+ ...alias !== void 0 && { alias },
267
+ at,
268
+ metadata: meta,
269
+ collapsed,
270
+ children: [],
271
+ lineNumber
272
+ };
273
+ boxes.push(box);
274
+ boxByNorm.set(norm, box);
275
+ if (alias !== void 0) {
276
+ if (aliasIndex.has(alias)) {
277
+ warn(
278
+ lineNumber,
279
+ `Duplicate alias "${alias}" \u2014 the first declaration keeps it`
280
+ );
281
+ } else {
282
+ aliasIndex.set(alias, box.id);
283
+ }
284
+ }
285
+ return box;
286
+ };
287
+ const addEdge = (trimmed, lineNumber, sourceId) => {
288
+ for (const form of EDGE_FORMS) {
289
+ const m = trimmed.match(form.re);
290
+ if (!m) continue;
291
+ let label;
292
+ let targetRegion;
293
+ if (form.labeled) {
294
+ const labelResult = parseInArrowLabel(m[1], lineNumber);
295
+ result.diagnostics.push(...labelResult.diagnostics);
296
+ label = labelResult.label;
297
+ targetRegion = m[2];
298
+ } else {
299
+ targetRegion = m[1];
300
+ }
301
+ const snm = splitNameAndMeta(
302
+ targetRegion.trim(),
303
+ registryFor(),
304
+ tagAliasMap,
305
+ palette,
306
+ result.diagnostics,
307
+ lineNumber,
308
+ { peelAlias: false }
309
+ );
310
+ let targetRaw = snm.name.trim();
311
+ if (snm.color) targetRaw = `${targetRaw} ${snm.color}`.trim();
312
+ const meta = { ...snm.meta };
313
+ delete meta["at"];
314
+ delete meta["shape"];
315
+ warnUnknownMetaKeys(meta, registryFor(), (msg) => warn(lineNumber, msg));
316
+ if (!targetRaw) {
317
+ warn(lineNumber, `Edge has no target \u2014 ignored`);
318
+ return;
319
+ }
320
+ pendingEdges.push({
321
+ sourceId,
322
+ targetRaw,
323
+ ...label !== void 0 && { label },
324
+ heads: form.heads,
325
+ dashed: form.dashed,
326
+ metadata: meta,
327
+ lineNumber
328
+ });
329
+ return;
330
+ }
331
+ if (LEFT_ARROW_RE.test(trimmed)) {
332
+ pushError(
333
+ lineNumber,
334
+ `Left-pointing arrows are not supported \u2014 write the edge from the other side (B -> A instead of A <- B)`
335
+ );
336
+ return;
337
+ }
338
+ warn(lineNumber, `Malformed edge "${trimmed}" \u2014 ignored`);
339
+ };
340
+ let firstLineConsumed = false;
341
+ let contentStarted = false;
342
+ let currentTagGroup = null;
343
+ let currentBox = null;
344
+ let currentShape = null;
345
+ for (let i = 0; i < lines.length; i++) {
346
+ const raw = lines[i];
347
+ const lineNumber = i + 1;
348
+ const trimmed = raw.trim();
349
+ if (!trimmed) {
350
+ currentTagGroup = null;
351
+ continue;
352
+ }
353
+ if (trimmed.startsWith("//")) continue;
354
+ const indent = measureIndent(raw);
355
+ if (!firstLineConsumed) {
356
+ firstLineConsumed = true;
357
+ const firstLine = parseFirstLine(trimmed);
358
+ if (firstLine?.chartType !== "sketch") {
359
+ let msg = `Expected chart type "sketch", got "${firstLine?.chartType ?? trimmed.split(/\s+/)[0]}"`;
360
+ const hint = suggest(firstLine?.chartType ?? "", ["sketch"]);
361
+ if (hint) msg += `. ${hint}`;
362
+ return fail(lineNumber, msg);
363
+ }
364
+ result.title = firstLine.title ?? null;
365
+ result.titleLineNumber = lineNumber;
366
+ continue;
367
+ }
368
+ if (indent === 0) {
369
+ const tagBlockMatch = matchTagBlockHeading(trimmed);
370
+ if (tagBlockMatch) {
371
+ if (contentStarted) {
372
+ pushError(
373
+ lineNumber,
374
+ "Tag groups must appear before sketch content",
375
+ "E_TAG_DECLARED_AFTER_CONTENT"
376
+ );
377
+ continue;
378
+ }
379
+ currentTagGroup = {
380
+ name: tagBlockMatch.name,
381
+ ...tagBlockMatch.alias !== void 0 && {
382
+ alias: tagBlockMatch.alias
383
+ },
384
+ entries: [],
385
+ lineNumber
386
+ };
387
+ if (tagBlockMatch.alias) {
388
+ tagAliasMap.set(
389
+ tagBlockMatch.alias.toLowerCase(),
390
+ tagAttrKey(tagBlockMatch.name)
391
+ );
392
+ }
393
+ tagAliasMap.set(
394
+ tagAttrKey(tagBlockMatch.name),
395
+ tagAttrKey(tagBlockMatch.name)
396
+ );
397
+ if (tagBlockMatch.inlineValues) {
398
+ for (const entry of tagBlockMatch.inlineValues) {
399
+ const { text: cleanEntry, isDefault } = stripDefaultModifier(entry);
400
+ const { label, color } = extractColor(
401
+ cleanEntry,
402
+ palette,
403
+ result.diagnostics,
404
+ lineNumber
405
+ );
406
+ if (isDefault) currentTagGroup.defaultValue = label;
407
+ currentTagGroup.entries.push({
408
+ value: label,
409
+ color: color ?? AUTO_TAG_COLOR_SENTINEL,
410
+ lineNumber
411
+ });
412
+ }
413
+ }
414
+ result.tagGroups.push(currentTagGroup);
415
+ continue;
416
+ }
417
+ }
418
+ if (currentTagGroup && indent > 0) {
419
+ const { text: cleanEntry, isDefault } = stripDefaultModifier(trimmed);
420
+ const { label, color } = extractColor(
421
+ cleanEntry,
422
+ palette,
423
+ result.diagnostics,
424
+ lineNumber
425
+ );
426
+ if (isDefault) currentTagGroup.defaultValue = label;
427
+ currentTagGroup.entries.push({
428
+ value: label,
429
+ color: color ?? AUTO_TAG_COLOR_SENTINEL,
430
+ lineNumber
431
+ });
432
+ continue;
433
+ }
434
+ currentTagGroup = null;
435
+ if (indent === 0 && /^no-legend\s*$/i.test(trimmed)) {
436
+ options.noLegend = true;
437
+ continue;
438
+ }
439
+ if (indent === 0 && /^solid-fill\s*$/i.test(trimmed)) {
440
+ options.solidFill = true;
441
+ continue;
442
+ }
443
+ if (indent === 0 && /^no-descriptions\s*$/i.test(trimmed)) {
444
+ options.noDescriptions = true;
445
+ continue;
446
+ }
447
+ contentStarted = true;
448
+ if (trimmed.startsWith(">")) {
449
+ const descLine = trimmed.slice(1).replace(/^ /, "");
450
+ if (indent > 0 && currentShape && indent > currentShape.indent) {
451
+ const node2 = nodeById.get(currentShape.id);
452
+ if (node2) {
453
+ node2.description = node2.description === void 0 ? descLine : `${node2.description}
454
+ ${descLine}`;
455
+ }
456
+ } else {
457
+ warn(
458
+ lineNumber,
459
+ `Description "${trimmed}" has no shape \u2014 indent it under the shape it describes`
460
+ );
461
+ }
462
+ continue;
463
+ }
464
+ if (EDGE_START_RE.test(trimmed)) {
465
+ if (indent > 0 && currentShape && indent > currentShape.indent) {
466
+ addEdge(trimmed, lineNumber, currentShape.id);
467
+ } else if (indent > 0 && currentBox && indent > currentBox.indent) {
468
+ addEdge(trimmed, lineNumber, currentBox.box.id);
469
+ } else {
470
+ warn(
471
+ lineNumber,
472
+ `Edge "${trimmed}" has no source shape \u2014 indent it under the shape it leaves from`
473
+ );
474
+ }
475
+ continue;
476
+ }
477
+ const boxMatch = trimmed.match(BOX_RE);
478
+ if (boxMatch) {
479
+ const label = boxMatch[1].trim();
480
+ if (!label) {
481
+ warn(lineNumber, "Box has no label \u2014 ignored");
482
+ continue;
483
+ }
484
+ if (indent > 0 && currentBox && indent > currentBox.indent) {
485
+ pushError(
486
+ lineNumber,
487
+ `Box "${label}" is nested inside "${currentBox.box.label}" \u2014 sketch boxes are one level only; its shapes join the outer box`,
488
+ SKETCH_DIAGNOSTIC_CODES.NESTED_BOX
489
+ );
490
+ continue;
491
+ }
492
+ currentBox = {
493
+ box: openBox(label, boxMatch[2] ?? "", lineNumber),
494
+ indent
495
+ };
496
+ currentShape = null;
497
+ continue;
498
+ }
499
+ if (indent === 0) {
500
+ currentBox = null;
501
+ const node2 = addShape(trimmed, lineNumber, null);
502
+ currentShape = node2 ? { id: node2.id, indent } : null;
503
+ continue;
504
+ }
505
+ if (currentBox && indent > currentBox.indent) {
506
+ const node2 = addShape(trimmed, lineNumber, currentBox.box);
507
+ currentShape = node2 ? { id: node2.id, indent } : currentShape;
508
+ continue;
509
+ }
510
+ warn(
511
+ lineNumber,
512
+ `Indented line "${trimmed}" has no parent box \u2014 treated as a top-level shape`
513
+ );
514
+ const node = addShape(trimmed, lineNumber, null);
515
+ currentShape = node ? { id: node.id, indent } : currentShape;
516
+ }
517
+ const allTargets = [
518
+ ...aliasIndex.keys(),
519
+ ...nodes.map((n) => n.label),
520
+ ...boxes.map((b) => b.label)
521
+ ];
522
+ for (const pe of pendingEdges) {
523
+ let targetId;
524
+ const bracketMatch = pe.targetRaw.match(/^\[([^\]]*)\]$/);
525
+ if (bracketMatch) {
526
+ targetId = boxByNorm.get(normalizeName(bracketMatch[1]))?.id ?? null;
527
+ } else if (aliasIndex.has(pe.targetRaw)) {
528
+ targetId = aliasIndex.get(pe.targetRaw);
529
+ } else {
530
+ const norm = normalizeName(stripQuotes(pe.targetRaw).trim());
531
+ const labelHits = labelIndex.get(norm) ?? [];
532
+ if (labelHits.length > 1) {
533
+ pushError(
534
+ pe.lineNumber,
535
+ `Edge target "${pe.targetRaw}" matches more than one shape \u2014 give each duplicate an alias (as x) and target the alias`,
536
+ SKETCH_DIAGNOSTIC_CODES.AMBIGUOUS_TARGET
537
+ );
538
+ continue;
539
+ }
540
+ targetId = labelHits[0] ?? boxByNorm.get(norm)?.id ?? null;
541
+ }
542
+ if (targetId === null) {
543
+ let msg = `Unknown edge target "${pe.targetRaw}"`;
544
+ const hint = suggest(pe.targetRaw, allTargets);
545
+ if (hint) msg += `. ${hint}`;
546
+ warn(pe.lineNumber, msg);
547
+ continue;
548
+ }
549
+ if (targetId === pe.sourceId) {
550
+ warn(pe.lineNumber, `Edge from "${pe.targetRaw}" to itself \u2014 ignored`);
551
+ continue;
552
+ }
553
+ result.edges.push({
554
+ sourceId: pe.sourceId,
555
+ targetId,
556
+ ...pe.label !== void 0 && { label: pe.label },
557
+ heads: pe.heads,
558
+ dashed: pe.dashed,
559
+ metadata: pe.metadata,
560
+ lineNumber: pe.lineNumber
561
+ });
562
+ }
563
+ finalizeAutoTagColors(result.tagGroups, palette);
564
+ if (result.tagGroups.length > 0) {
565
+ const tagKeys = result.tagGroups.map((g) => tagAttrKey(g.name));
566
+ for (const box of boxes) {
567
+ for (const childId of box.children) {
568
+ const child = nodeById.get(childId);
569
+ if (!child) continue;
570
+ for (const k of tagKeys) {
571
+ if (!(k in child.metadata) && box.metadata[k] !== void 0) {
572
+ child.metadata[k] = box.metadata[k];
573
+ }
574
+ }
575
+ }
576
+ }
577
+ injectDefaultTagMetadata(
578
+ [...nodes, ...boxes],
579
+ result.tagGroups
580
+ );
581
+ validateTagValues(
582
+ [...nodes, ...boxes, ...result.edges],
583
+ result.tagGroups,
584
+ (line, message) => warn(line, message),
585
+ suggest
586
+ );
587
+ validateTagGroupNames(
588
+ result.tagGroups,
589
+ (line, message) => warn(line, message)
590
+ );
591
+ }
592
+ result.nodes = nodes;
593
+ result.boxes = boxes;
594
+ if (nodes.length === 0 && boxes.length === 0 && !result.error) {
595
+ const diag = makeDgmoError(1, "No shapes found in sketch");
596
+ result.diagnostics.push(diag);
597
+ result.error = formatDgmoError(diag);
598
+ }
599
+ return result;
600
+ }
601
+
602
+ export {
603
+ SKETCH_SHAPE_KINDS,
604
+ isSketchShapeKind,
605
+ parseSketch
606
+ };
607
+ //# sourceMappingURL=chunk-4YNP6O47.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  tryCollectNote
3
- } from "./chunk-5MLYVTYM.js";
3
+ } from "./chunk-K6HNAY5V.js";
4
4
  import {
5
5
  resolveNotes
6
6
  } from "./chunk-FMDSF3OV.js";
@@ -17,7 +17,7 @@ import {
17
17
  measureIndent,
18
18
  parseFirstLine,
19
19
  tryParseSharedOption
20
- } from "./chunk-Y3J7VR52.js";
20
+ } from "./chunk-ZNQX6QWH.js";
21
21
  import {
22
22
  resolveColorWithDiagnostic
23
23
  } from "./chunk-TLVIHFRO.js";
@@ -412,4 +412,4 @@ export {
412
412
  parseState,
413
413
  looksLikeState
414
414
  };
415
- //# sourceMappingURL=chunk-3MQQNXPD.js.map
415
+ //# sourceMappingURL=chunk-5FGDJIJX.js.map
@@ -157,4 +157,4 @@ export {
157
157
  truncateText,
158
158
  wrapTextToWidth
159
159
  };
160
- //# sourceMappingURL=chunk-WCT3NYCV.js.map
160
+ //# sourceMappingURL=chunk-5LWQH6QV.js.map