@graphty/graph-io 0.3.48 → 0.3.49

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 (570) hide show
  1. package/dist/chunks/{approximations-C2riR4NT.js → approximations-Bzn3L-je.js} +2 -2
  2. package/dist/chunks/{approximations-C2riR4NT.js.map → approximations-Bzn3L-je.js.map} +1 -1
  3. package/dist/chunks/bends-BGXjv_U4.js +129 -0
  4. package/dist/chunks/bends-BGXjv_U4.js.map +1 -0
  5. package/dist/chunks/{block-Cu22ewuS.js → block-iptrlMBb.js} +906 -164
  6. package/dist/chunks/block-iptrlMBb.js.map +1 -0
  7. package/dist/chunks/choose-CczZJaX_.js +717 -0
  8. package/dist/chunks/choose-CczZJaX_.js.map +1 -0
  9. package/dist/chunks/{codes-CV_Bhcyi.js → codes-BE2xir2k.js} +6 -2
  10. package/dist/chunks/codes-BE2xir2k.js.map +1 -0
  11. package/dist/chunks/{constants-D0LqcsLJ.js → constants-CKkYLPtt.js} +2 -2
  12. package/dist/chunks/{constants-D0LqcsLJ.js.map → constants-CKkYLPtt.js.map} +1 -1
  13. package/dist/chunks/{context-cgmmOxZ2.js → context-C3p0RQxR.js} +5 -4
  14. package/dist/chunks/{context-cgmmOxZ2.js.map → context-C3p0RQxR.js.map} +1 -1
  15. package/dist/chunks/{convert-BcQ8_jMo.js → convert-Ct2zelbQ.js} +7 -2
  16. package/dist/chunks/convert-Ct2zelbQ.js.map +1 -0
  17. package/dist/chunks/{credentials-BiQsnMTb.js → credentials-DXHx7nwR.js} +16 -14
  18. package/dist/chunks/credentials-DXHx7nwR.js.map +1 -0
  19. package/dist/chunks/{cx-export-BEeF6ymo.js → cx-export-Bt6NoqTQ.js} +3 -3
  20. package/dist/chunks/{cx-export-BEeF6ymo.js.map → cx-export-Bt6NoqTQ.js.map} +1 -1
  21. package/dist/chunks/descriptor-B28U25x4.js +60 -0
  22. package/dist/chunks/descriptor-B28U25x4.js.map +1 -0
  23. package/dist/chunks/{descriptor-BJ-W0Jd-.js → descriptor-DLA5kINx.js} +7 -2
  24. package/dist/chunks/descriptor-DLA5kINx.js.map +1 -0
  25. package/dist/chunks/{emit-CD8xnY8s.js → emit-BwHQkZle.js} +1660 -133
  26. package/dist/chunks/emit-BwHQkZle.js.map +1 -0
  27. package/dist/chunks/{escape-DH2Egt-l.js → escape-CuCIzNMB.js} +8 -8
  28. package/dist/chunks/{escape-DH2Egt-l.js.map → escape-CuCIzNMB.js.map} +1 -1
  29. package/dist/chunks/{export-CZ7VRm4I.js → export-Cha4dRFz.js} +45 -387
  30. package/dist/chunks/export-Cha4dRFz.js.map +1 -0
  31. package/dist/chunks/{exporter-Dcw7Ldtq.js → exporter-BP6otMO6.js} +6 -6
  32. package/dist/chunks/{exporter-Dcw7Ldtq.js.map → exporter-BP6otMO6.js.map} +1 -1
  33. package/dist/chunks/{exporter-bxxjOrDZ.js → exporter-D2CETOMK.js} +1222 -156
  34. package/dist/chunks/exporter-D2CETOMK.js.map +1 -0
  35. package/dist/chunks/{exporter-BIdaoIgh.js → exporter-D9yMtocA.js} +7 -7
  36. package/dist/chunks/{exporter-BIdaoIgh.js.map → exporter-D9yMtocA.js.map} +1 -1
  37. package/dist/chunks/{exporter-DtVU80Fa.js → exporter-_jrBTnos.js} +9 -8
  38. package/dist/chunks/{exporter-DtVU80Fa.js.map → exporter-_jrBTnos.js.map} +1 -1
  39. package/dist/chunks/{exporter-ChjL5fmP.js → exporter-nDfxIK5D.js} +9 -8
  40. package/dist/chunks/{exporter-ChjL5fmP.js.map → exporter-nDfxIK5D.js.map} +1 -1
  41. package/dist/chunks/format-BXiAb-1h.js +408 -0
  42. package/dist/chunks/format-BXiAb-1h.js.map +1 -0
  43. package/dist/chunks/{generic-CP6YD34u.js → generic-ymWCETAJ.js} +387 -31
  44. package/dist/chunks/generic-ymWCETAJ.js.map +1 -0
  45. package/dist/chunks/{importer-e3huMZbm.js → importer-B92x1xY5.js} +14 -10
  46. package/dist/chunks/importer-B92x1xY5.js.map +1 -0
  47. package/dist/chunks/{importer-B87_fmVx.js → importer-CT9mJ1nn.js} +326 -84
  48. package/dist/chunks/importer-CT9mJ1nn.js.map +1 -0
  49. package/dist/chunks/{importer-CB_zV5_L.js → importer-DaLTjbds.js} +116 -1102
  50. package/dist/chunks/importer-DaLTjbds.js.map +1 -0
  51. package/dist/chunks/{importer-DPZDN40-.js → importer-GREKMdIf.js} +25 -17
  52. package/dist/chunks/importer-GREKMdIf.js.map +1 -0
  53. package/dist/chunks/{importer-Bji2MeWr.js → importer-PqaaKKnY.js} +13 -10
  54. package/dist/chunks/{importer-Bji2MeWr.js.map → importer-PqaaKKnY.js.map} +1 -1
  55. package/dist/chunks/{importer-Cyy6UseH.js → importer-Vn5QvmmJ.js} +66 -13
  56. package/dist/chunks/importer-Vn5QvmmJ.js.map +1 -0
  57. package/dist/chunks/{importer-CVT-JyDE.js → importer-vRq4h3j5.js} +1469 -356
  58. package/dist/chunks/importer-vRq4h3j5.js.map +1 -0
  59. package/dist/chunks/{input-Ccg9I22A.js → input-CAxt_aV-.js} +4 -4
  60. package/dist/chunks/{input-Ccg9I22A.js.map → input-CAxt_aV-.js.map} +1 -1
  61. package/dist/chunks/{json-elements-By172SVq.js → json-elements-Cq76WjnZ.js} +4 -4
  62. package/dist/chunks/{json-elements-By172SVq.js.map → json-elements-Cq76WjnZ.js.map} +1 -1
  63. package/dist/chunks/{lexicon-u2SI5xcx.js → lexicon-Clf4QIyl.js} +282 -74
  64. package/dist/chunks/lexicon-Clf4QIyl.js.map +1 -0
  65. package/dist/chunks/{ontology-export-BwgMyuF0.js → ontology-export-OMo91mb0.js} +4 -4
  66. package/dist/chunks/{ontology-export-BwgMyuF0.js.map → ontology-export-OMo91mb0.js.map} +1 -1
  67. package/dist/chunks/{records-Cgvxz-Vx.js → records-NJiYvekn.js} +2 -2
  68. package/dist/chunks/{records-Cgvxz-Vx.js.map → records-NJiYvekn.js.map} +1 -1
  69. package/dist/chunks/{report-CgdsL9Hb.js → report-CwMfYa9J.js} +23 -23
  70. package/dist/chunks/{report-CgdsL9Hb.js.map → report-CwMfYa9J.js.map} +1 -1
  71. package/dist/chunks/round-trip-Zm3_ivgq.js +79 -0
  72. package/dist/chunks/round-trip-Zm3_ivgq.js.map +1 -0
  73. package/dist/chunks/{sigv4-LkAzsLAu.js → sigv4-EokFic1V.js} +5 -5
  74. package/dist/chunks/sigv4-EokFic1V.js.map +1 -0
  75. package/dist/chunks/{styles-CaABMoO1.js → styles-CCs214_3.js} +1237 -138
  76. package/dist/chunks/styles-CCs214_3.js.map +1 -0
  77. package/dist/chunks/styles-Cm62yyQX.js +2812 -0
  78. package/dist/chunks/styles-Cm62yyQX.js.map +1 -0
  79. package/dist/chunks/styles-DPQQIig4.js +1928 -0
  80. package/dist/chunks/styles-DPQQIig4.js.map +1 -0
  81. package/dist/chunks/{styles-yed-Cs1nmrjn.js → styles-yed-UMFdNqze.js} +503 -172
  82. package/dist/chunks/styles-yed-UMFdNqze.js.map +1 -0
  83. package/dist/chunks/{text-BuKQVMz2.js → text-ystE2bYi.js} +2 -2
  84. package/dist/chunks/{text-BuKQVMz2.js.map → text-ystE2bYi.js.map} +1 -1
  85. package/dist/csv.js +7 -7
  86. package/dist/cx.js +2 -2
  87. package/dist/cx2.js +2 -2
  88. package/dist/cys.js +1 -1
  89. package/dist/dot.js +5 -4
  90. package/dist/dot.js.map +1 -1
  91. package/dist/gexf.js +42 -12
  92. package/dist/gexf.js.map +1 -1
  93. package/dist/gml.js +847 -193
  94. package/dist/gml.js.map +1 -1
  95. package/dist/graph-io.js +232 -220
  96. package/dist/graph-io.js.map +1 -1
  97. package/dist/graphml.js +3 -3
  98. package/dist/json.js +3 -2
  99. package/dist/neo4j.js +6 -6
  100. package/dist/obo.js +1 -1
  101. package/dist/pajek.js +1 -1
  102. package/dist/positions.js +45 -3
  103. package/dist/positions.js.map +1 -1
  104. package/dist/sources-cypher.js +138 -23
  105. package/dist/sources-cypher.js.map +1 -1
  106. package/dist/sources-ndex.js +2 -2
  107. package/dist/sources-rest.js +16 -6
  108. package/dist/sources-rest.js.map +1 -1
  109. package/dist/sources-sparql.d.ts +1 -0
  110. package/dist/sources-sparql.js +405 -0
  111. package/dist/sources-sparql.js.map +1 -0
  112. package/dist/src/formats/cx/importer.d.ts.map +1 -1
  113. package/dist/src/formats/cx/importer.js +5 -1
  114. package/dist/src/formats/cx/importer.js.map +1 -1
  115. package/dist/src/formats/cx/styles.d.ts +24 -1
  116. package/dist/src/formats/cx/styles.d.ts.map +1 -1
  117. package/dist/src/formats/cx/styles.js +117 -11
  118. package/dist/src/formats/cx/styles.js.map +1 -1
  119. package/dist/src/formats/cx2/importer.d.ts.map +1 -1
  120. package/dist/src/formats/cx2/importer.js +1 -0
  121. package/dist/src/formats/cx2/importer.js.map +1 -1
  122. package/dist/src/formats/cx2/styles.d.ts.map +1 -1
  123. package/dist/src/formats/cx2/styles.js +3 -1
  124. package/dist/src/formats/cx2/styles.js.map +1 -1
  125. package/dist/src/formats/cys/importer.d.ts.map +1 -1
  126. package/dist/src/formats/cys/importer.js +1 -0
  127. package/dist/src/formats/cys/importer.js.map +1 -1
  128. package/dist/src/formats/cys/styles.d.ts +2 -0
  129. package/dist/src/formats/cys/styles.d.ts.map +1 -1
  130. package/dist/src/formats/cys/styles.js +15 -7
  131. package/dist/src/formats/cys/styles.js.map +1 -1
  132. package/dist/src/formats/dot/drawing.d.ts +98 -0
  133. package/dist/src/formats/dot/drawing.d.ts.map +1 -0
  134. package/dist/src/formats/dot/drawing.js +734 -0
  135. package/dist/src/formats/dot/drawing.js.map +1 -0
  136. package/dist/src/formats/dot/importer.d.ts.map +1 -1
  137. package/dist/src/formats/dot/importer.js +108 -31
  138. package/dist/src/formats/dot/importer.js.map +1 -1
  139. package/dist/src/formats/dot/label-places.d.ts +34 -0
  140. package/dist/src/formats/dot/label-places.d.ts.map +1 -0
  141. package/dist/src/formats/dot/label-places.js +179 -0
  142. package/dist/src/formats/dot/label-places.js.map +1 -0
  143. package/dist/src/formats/dot/record.d.ts +50 -0
  144. package/dist/src/formats/dot/record.d.ts.map +1 -0
  145. package/dist/src/formats/dot/record.js +275 -0
  146. package/dist/src/formats/dot/record.js.map +1 -0
  147. package/dist/src/formats/dot/styles.d.ts +62 -2
  148. package/dist/src/formats/dot/styles.d.ts.map +1 -1
  149. package/dist/src/formats/dot/styles.js +1454 -119
  150. package/dist/src/formats/dot/styles.js.map +1 -1
  151. package/dist/src/formats/gexf/dialog-metrics.d.ts +15 -0
  152. package/dist/src/formats/gexf/dialog-metrics.d.ts.map +1 -0
  153. package/dist/src/formats/gexf/dialog-metrics.js +59 -0
  154. package/dist/src/formats/gexf/dialog-metrics.js.map +1 -0
  155. package/dist/src/formats/gexf/importer.d.ts +7 -0
  156. package/dist/src/formats/gexf/importer.d.ts.map +1 -1
  157. package/dist/src/formats/gexf/importer.js +41 -5
  158. package/dist/src/formats/gexf/importer.js.map +1 -1
  159. package/dist/src/formats/gexf/preview.d.ts +77 -0
  160. package/dist/src/formats/gexf/preview.d.ts.map +1 -0
  161. package/dist/src/formats/gexf/preview.js +191 -0
  162. package/dist/src/formats/gexf/preview.js.map +1 -0
  163. package/dist/src/formats/gexf/schema.d.ts.map +1 -1
  164. package/dist/src/formats/gexf/schema.js +2 -1
  165. package/dist/src/formats/gexf/schema.js.map +1 -1
  166. package/dist/src/formats/gexf/styles.d.ts +58 -31
  167. package/dist/src/formats/gexf/styles.d.ts.map +1 -1
  168. package/dist/src/formats/gexf/styles.js +848 -225
  169. package/dist/src/formats/gexf/styles.js.map +1 -1
  170. package/dist/src/formats/gml/importer.d.ts +5 -2
  171. package/dist/src/formats/gml/importer.d.ts.map +1 -1
  172. package/dist/src/formats/gml/importer.js +258 -71
  173. package/dist/src/formats/gml/importer.js.map +1 -1
  174. package/dist/src/formats/gml/index.d.ts +1 -1
  175. package/dist/src/formats/gml/index.d.ts.map +1 -1
  176. package/dist/src/formats/gml/index.js +1 -1
  177. package/dist/src/formats/gml/index.js.map +1 -1
  178. package/dist/src/formats/gml/positions.d.ts +7 -0
  179. package/dist/src/formats/gml/positions.d.ts.map +1 -1
  180. package/dist/src/formats/gml/positions.js +29 -7
  181. package/dist/src/formats/gml/positions.js.map +1 -1
  182. package/dist/src/formats/gml/styles.d.ts.map +1 -1
  183. package/dist/src/formats/gml/styles.js +753 -101
  184. package/dist/src/formats/gml/styles.js.map +1 -1
  185. package/dist/src/formats/graphml/styles-plain.d.ts.map +1 -1
  186. package/dist/src/formats/graphml/styles-plain.js +6 -10
  187. package/dist/src/formats/graphml/styles-plain.js.map +1 -1
  188. package/dist/src/formats/graphml/styles-yed.d.ts +21 -15
  189. package/dist/src/formats/graphml/styles-yed.d.ts.map +1 -1
  190. package/dist/src/formats/graphml/styles-yed.js +692 -161
  191. package/dist/src/formats/graphml/styles-yed.js.map +1 -1
  192. package/dist/src/formats/graphml/styles-yfiles3.d.ts +1 -1
  193. package/dist/src/formats/graphml/styles-yfiles3.d.ts.map +1 -1
  194. package/dist/src/formats/graphml/styles-yfiles3.js +429 -64
  195. package/dist/src/formats/graphml/styles-yfiles3.js.map +1 -1
  196. package/dist/src/formats/graphml/yfiles.d.ts +3 -3
  197. package/dist/src/formats/graphml/yfiles.d.ts.map +1 -1
  198. package/dist/src/formats/graphml/yfiles.js +16 -6
  199. package/dist/src/formats/graphml/yfiles.js.map +1 -1
  200. package/dist/src/formats/json/dialect.d.ts +3 -2
  201. package/dist/src/formats/json/dialect.d.ts.map +1 -1
  202. package/dist/src/formats/json/dialect.js +39 -5
  203. package/dist/src/formats/json/dialect.js.map +1 -1
  204. package/dist/src/formats/json/importer.d.ts +13 -2
  205. package/dist/src/formats/json/importer.d.ts.map +1 -1
  206. package/dist/src/formats/json/importer.js +42 -6
  207. package/dist/src/formats/json/importer.js.map +1 -1
  208. package/dist/src/formats/json/index.d.ts +1 -1
  209. package/dist/src/formats/json/index.d.ts.map +1 -1
  210. package/dist/src/formats/json/index.js +1 -1
  211. package/dist/src/formats/json/index.js.map +1 -1
  212. package/dist/src/formats/json/positions.d.ts +5 -2
  213. package/dist/src/formats/json/positions.d.ts.map +1 -1
  214. package/dist/src/formats/json/positions.js +20 -4
  215. package/dist/src/formats/json/positions.js.map +1 -1
  216. package/dist/src/formats/json/styles.d.ts +12 -1
  217. package/dist/src/formats/json/styles.d.ts.map +1 -1
  218. package/dist/src/formats/json/styles.js +1755 -136
  219. package/dist/src/formats/json/styles.js.map +1 -1
  220. package/dist/src/formats/pajek/draw.d.ts +96 -0
  221. package/dist/src/formats/pajek/draw.d.ts.map +1 -0
  222. package/dist/src/formats/pajek/draw.js +372 -0
  223. package/dist/src/formats/pajek/draw.js.map +1 -0
  224. package/dist/src/formats/pajek/exporter.d.ts.map +1 -1
  225. package/dist/src/formats/pajek/exporter.js +70 -51
  226. package/dist/src/formats/pajek/exporter.js.map +1 -1
  227. package/dist/src/formats/pajek/importer.d.ts +9 -0
  228. package/dist/src/formats/pajek/importer.d.ts.map +1 -1
  229. package/dist/src/formats/pajek/importer.js +233 -102
  230. package/dist/src/formats/pajek/importer.js.map +1 -1
  231. package/dist/src/formats/pajek/index.d.ts +1 -0
  232. package/dist/src/formats/pajek/index.d.ts.map +1 -1
  233. package/dist/src/formats/pajek/index.js.map +1 -1
  234. package/dist/src/formats/pajek/styles.d.ts +15 -7
  235. package/dist/src/formats/pajek/styles.d.ts.map +1 -1
  236. package/dist/src/formats/pajek/styles.js +1278 -114
  237. package/dist/src/formats/pajek/styles.js.map +1 -1
  238. package/dist/src/formats/pajek/syntax.d.ts +10 -1
  239. package/dist/src/formats/pajek/syntax.d.ts.map +1 -1
  240. package/dist/src/formats/pajek/syntax.js +26 -2
  241. package/dist/src/formats/pajek/syntax.js.map +1 -1
  242. package/dist/src/formats/xgmml/emit.d.ts +1 -0
  243. package/dist/src/formats/xgmml/emit.d.ts.map +1 -1
  244. package/dist/src/formats/xgmml/emit.js +65 -5
  245. package/dist/src/formats/xgmml/emit.js.map +1 -1
  246. package/dist/src/formats/xgmml/styles.d.ts +23 -3
  247. package/dist/src/formats/xgmml/styles.d.ts.map +1 -1
  248. package/dist/src/formats/xgmml/styles.js +277 -60
  249. package/dist/src/formats/xgmml/styles.js.map +1 -1
  250. package/dist/src/index.d.ts +4 -3
  251. package/dist/src/index.d.ts.map +1 -1
  252. package/dist/src/index.js +4 -3
  253. package/dist/src/index.js.map +1 -1
  254. package/dist/src/positions/convert.d.ts.map +1 -1
  255. package/dist/src/positions/convert.js +11 -1
  256. package/dist/src/positions/convert.js.map +1 -1
  257. package/dist/src/positions/extract.d.ts.map +1 -1
  258. package/dist/src/positions/extract.js +53 -1
  259. package/dist/src/positions/extract.js.map +1 -1
  260. package/dist/src/positions/index.d.ts +1 -1
  261. package/dist/src/positions/index.d.ts.map +1 -1
  262. package/dist/src/positions/types.d.ts +59 -0
  263. package/dist/src/positions/types.d.ts.map +1 -1
  264. package/dist/src/sources/builtins.d.ts +1 -1
  265. package/dist/src/sources/builtins.d.ts.map +1 -1
  266. package/dist/src/sources/builtins.js +8 -2
  267. package/dist/src/sources/builtins.js.map +1 -1
  268. package/dist/src/sources/context.d.ts.map +1 -1
  269. package/dist/src/sources/context.js +1 -0
  270. package/dist/src/sources/context.js.map +1 -1
  271. package/dist/src/sources/cypher/descriptor.d.ts.map +1 -1
  272. package/dist/src/sources/cypher/descriptor.js +5 -0
  273. package/dist/src/sources/cypher/descriptor.js.map +1 -1
  274. package/dist/src/sources/cypher/index.d.ts.map +1 -1
  275. package/dist/src/sources/cypher/index.js +124 -18
  276. package/dist/src/sources/cypher/index.js.map +1 -1
  277. package/dist/src/sources/cypher/params.d.ts +1 -1
  278. package/dist/src/sources/cypher/params.d.ts.map +1 -1
  279. package/dist/src/sources/cypher/query-builder.d.ts +17 -0
  280. package/dist/src/sources/cypher/query-builder.d.ts.map +1 -1
  281. package/dist/src/sources/cypher/query-builder.js +31 -0
  282. package/dist/src/sources/cypher/query-builder.js.map +1 -1
  283. package/dist/src/sources/ids.d.ts +5 -0
  284. package/dist/src/sources/ids.d.ts.map +1 -1
  285. package/dist/src/sources/ids.js +5 -0
  286. package/dist/src/sources/ids.js.map +1 -1
  287. package/dist/src/sources/params.d.ts +3 -0
  288. package/dist/src/sources/params.d.ts.map +1 -1
  289. package/dist/src/sources/rest/descriptor.d.ts.map +1 -1
  290. package/dist/src/sources/rest/descriptor.js +5 -0
  291. package/dist/src/sources/rest/descriptor.js.map +1 -1
  292. package/dist/src/sources/rest/source.d.ts.map +1 -1
  293. package/dist/src/sources/rest/source.js +15 -0
  294. package/dist/src/sources/rest/source.js.map +1 -1
  295. package/dist/src/sources/sigv4.d.ts +5 -3
  296. package/dist/src/sources/sigv4.d.ts.map +1 -1
  297. package/dist/src/sources/sigv4.js +6 -4
  298. package/dist/src/sources/sigv4.js.map +1 -1
  299. package/dist/src/sources/sparql/descriptor.d.ts +10 -0
  300. package/dist/src/sources/sparql/descriptor.d.ts.map +1 -0
  301. package/dist/src/sources/sparql/descriptor.js +64 -0
  302. package/dist/src/sources/sparql/descriptor.js.map +1 -0
  303. package/dist/src/sources/sparql/index.d.ts +28 -0
  304. package/dist/src/sources/sparql/index.d.ts.map +1 -0
  305. package/dist/src/sources/sparql/index.js +314 -0
  306. package/dist/src/sources/sparql/index.js.map +1 -0
  307. package/dist/src/sources/sparql/ntriples.d.ts +69 -0
  308. package/dist/src/sources/sparql/ntriples.d.ts.map +1 -0
  309. package/dist/src/sources/sparql/ntriples.js +180 -0
  310. package/dist/src/sources/sparql/ntriples.js.map +1 -0
  311. package/dist/src/sources/sparql/params.d.ts +27 -0
  312. package/dist/src/sources/sparql/params.d.ts.map +1 -0
  313. package/dist/src/sources/sparql/params.js +5 -0
  314. package/dist/src/sources/sparql/params.js.map +1 -0
  315. package/dist/src/sources/sparql/query.d.ts +72 -0
  316. package/dist/src/sources/sparql/query.d.ts.map +1 -0
  317. package/dist/src/sources/sparql/query.js +113 -0
  318. package/dist/src/sources/sparql/query.js.map +1 -0
  319. package/dist/src/sources/types.d.ts +31 -0
  320. package/dist/src/sources/types.d.ts.map +1 -1
  321. package/dist/src/styles/annotations.d.ts +61 -5
  322. package/dist/src/styles/annotations.d.ts.map +1 -1
  323. package/dist/src/styles/annotations.js +130 -22
  324. package/dist/src/styles/annotations.js.map +1 -1
  325. package/dist/src/styles/canon/bends.d.ts +46 -0
  326. package/dist/src/styles/canon/bends.d.ts.map +1 -1
  327. package/dist/src/styles/canon/bends.js +123 -0
  328. package/dist/src/styles/canon/bends.js.map +1 -1
  329. package/dist/src/styles/canon/color-tables.d.ts +6 -1
  330. package/dist/src/styles/canon/color-tables.d.ts.map +1 -1
  331. package/dist/src/styles/canon/color-tables.js +10 -4
  332. package/dist/src/styles/canon/color-tables.js.map +1 -1
  333. package/dist/src/styles/canon/color.d.ts +3 -1
  334. package/dist/src/styles/canon/color.d.ts.map +1 -1
  335. package/dist/src/styles/canon/color.js +103 -3
  336. package/dist/src/styles/canon/color.js.map +1 -1
  337. package/dist/src/styles/canon/enums.d.ts +2 -2
  338. package/dist/src/styles/canon/enums.d.ts.map +1 -1
  339. package/dist/src/styles/canon/enums.js +81 -7
  340. package/dist/src/styles/canon/enums.js.map +1 -1
  341. package/dist/src/styles/canon/graphviz.d.ts +12 -3
  342. package/dist/src/styles/canon/graphviz.d.ts.map +1 -1
  343. package/dist/src/styles/canon/graphviz.js +57 -9
  344. package/dist/src/styles/canon/graphviz.js.map +1 -1
  345. package/dist/src/styles/canon/number.d.ts +8 -0
  346. package/dist/src/styles/canon/number.d.ts.map +1 -1
  347. package/dist/src/styles/canon/number.js +18 -0
  348. package/dist/src/styles/canon/number.js.map +1 -1
  349. package/dist/src/styles/canon/text.d.ts +29 -2
  350. package/dist/src/styles/canon/text.d.ts.map +1 -1
  351. package/dist/src/styles/canon/text.js +156 -16
  352. package/dist/src/styles/canon/text.js.map +1 -1
  353. package/dist/src/styles/codes.d.ts +2 -0
  354. package/dist/src/styles/codes.d.ts.map +1 -1
  355. package/dist/src/styles/codes.js +2 -0
  356. package/dist/src/styles/codes.js.map +1 -1
  357. package/dist/src/styles/cyjs/cascade.d.ts.map +1 -1
  358. package/dist/src/styles/cyjs/cascade.js +1015 -79
  359. package/dist/src/styles/cyjs/cascade.js.map +1 -1
  360. package/dist/src/styles/cyjs/defaults-table.d.ts.map +1 -1
  361. package/dist/src/styles/cyjs/defaults-table.js +3 -0
  362. package/dist/src/styles/cyjs/defaults-table.js.map +1 -1
  363. package/dist/src/styles/cyjs/emit.d.ts.map +1 -1
  364. package/dist/src/styles/cyjs/emit.js +202 -9
  365. package/dist/src/styles/cyjs/emit.js.map +1 -1
  366. package/dist/src/styles/cyjs/face.d.ts +20 -0
  367. package/dist/src/styles/cyjs/face.d.ts.map +1 -0
  368. package/dist/src/styles/cyjs/face.js +332 -0
  369. package/dist/src/styles/cyjs/face.js.map +1 -0
  370. package/dist/src/styles/cyjs/mappers.d.ts +44 -1
  371. package/dist/src/styles/cyjs/mappers.d.ts.map +1 -1
  372. package/dist/src/styles/cyjs/mappers.js +461 -26
  373. package/dist/src/styles/cyjs/mappers.js.map +1 -1
  374. package/dist/src/styles/cyjs/routes.d.ts +53 -0
  375. package/dist/src/styles/cyjs/routes.d.ts.map +1 -0
  376. package/dist/src/styles/cyjs/routes.js +360 -0
  377. package/dist/src/styles/cyjs/routes.js.map +1 -0
  378. package/dist/src/styles/cytoscape/charts.d.ts +23 -0
  379. package/dist/src/styles/cytoscape/charts.d.ts.map +1 -0
  380. package/dist/src/styles/cytoscape/charts.js +560 -0
  381. package/dist/src/styles/cytoscape/charts.js.map +1 -0
  382. package/dist/src/styles/cytoscape/emit.d.ts.map +1 -1
  383. package/dist/src/styles/cytoscape/emit.js +156 -48
  384. package/dist/src/styles/cytoscape/emit.js.map +1 -1
  385. package/dist/src/styles/cytoscape/lexicon.d.ts +91 -3
  386. package/dist/src/styles/cytoscape/lexicon.d.ts.map +1 -1
  387. package/dist/src/styles/cytoscape/lexicon.js +387 -77
  388. package/dist/src/styles/cytoscape/lexicon.js.map +1 -1
  389. package/dist/src/styles/cytoscape/mappings.d.ts +30 -0
  390. package/dist/src/styles/cytoscape/mappings.d.ts.map +1 -1
  391. package/dist/src/styles/cytoscape/mappings.js +92 -0
  392. package/dist/src/styles/cytoscape/mappings.js.map +1 -1
  393. package/dist/src/styles/cytoscape/resolve.d.ts +42 -2
  394. package/dist/src/styles/cytoscape/resolve.d.ts.map +1 -1
  395. package/dist/src/styles/cytoscape/resolve.js +623 -17
  396. package/dist/src/styles/cytoscape/resolve.js.map +1 -1
  397. package/dist/src/styles/defaults.d.ts +46 -26
  398. package/dist/src/styles/defaults.d.ts.map +1 -1
  399. package/dist/src/styles/defaults.js +308 -71
  400. package/dist/src/styles/defaults.js.map +1 -1
  401. package/dist/src/styles/index.d.ts +4 -3
  402. package/dist/src/styles/index.d.ts.map +1 -1
  403. package/dist/src/styles/index.js +3 -2
  404. package/dist/src/styles/index.js.map +1 -1
  405. package/dist/src/styles/internal.d.ts +1 -0
  406. package/dist/src/styles/internal.d.ts.map +1 -1
  407. package/dist/src/styles/internal.js +1 -0
  408. package/dist/src/styles/internal.js.map +1 -1
  409. package/dist/src/styles/io/generic.d.ts.map +1 -1
  410. package/dist/src/styles/io/generic.js +56 -16
  411. package/dist/src/styles/io/generic.js.map +1 -1
  412. package/dist/src/styles/io/round-trip.d.ts +56 -0
  413. package/dist/src/styles/io/round-trip.d.ts.map +1 -0
  414. package/dist/src/styles/io/round-trip.js +138 -0
  415. package/dist/src/styles/io/round-trip.js.map +1 -0
  416. package/dist/src/styles/io/writer.d.ts.map +1 -1
  417. package/dist/src/styles/io/writer.js +6 -1
  418. package/dist/src/styles/io/writer.js.map +1 -1
  419. package/dist/src/styles/notes.d.ts.map +1 -1
  420. package/dist/src/styles/notes.js +1 -0
  421. package/dist/src/styles/notes.js.map +1 -1
  422. package/dist/src/styles/plan/features.d.ts +1 -1
  423. package/dist/src/styles/plan/features.d.ts.map +1 -1
  424. package/dist/src/styles/plan/features.js +22 -2
  425. package/dist/src/styles/plan/features.js.map +1 -1
  426. package/dist/src/styles/plan/index.d.ts +1 -1
  427. package/dist/src/styles/plan/index.d.ts.map +1 -1
  428. package/dist/src/styles/plan/index.js +1 -1
  429. package/dist/src/styles/plan/index.js.map +1 -1
  430. package/dist/src/styles/plan/plan.d.ts.map +1 -1
  431. package/dist/src/styles/plan/plan.js +61 -4
  432. package/dist/src/styles/plan/plan.js.map +1 -1
  433. package/dist/src/styles/plan/resolve.d.ts +11 -0
  434. package/dist/src/styles/plan/resolve.d.ts.map +1 -1
  435. package/dist/src/styles/plan/resolve.js +40 -4
  436. package/dist/src/styles/plan/resolve.js.map +1 -1
  437. package/dist/src/styles/slots.d.ts +14 -0
  438. package/dist/src/styles/slots.d.ts.map +1 -0
  439. package/dist/src/styles/slots.js +20 -0
  440. package/dist/src/styles/slots.js.map +1 -0
  441. package/dist/src/styles/types.d.ts +622 -6
  442. package/dist/src/styles/types.d.ts.map +1 -1
  443. package/dist/src/styles/vocabulary.d.ts +3 -2
  444. package/dist/src/styles/vocabulary.d.ts.map +1 -1
  445. package/dist/src/styles/vocabulary.js +203 -0
  446. package/dist/src/styles/vocabulary.js.map +1 -1
  447. package/dist/styles.js +30 -239
  448. package/dist/styles.js.map +1 -1
  449. package/dist/xgmml.js +3 -3
  450. package/package.json +27 -7
  451. package/src/formats/cx/importer.ts +6 -1
  452. package/src/formats/cx/styles.ts +143 -9
  453. package/src/formats/cx2/importer.ts +1 -0
  454. package/src/formats/cx2/styles.ts +3 -1
  455. package/src/formats/cys/importer.ts +1 -0
  456. package/src/formats/cys/styles.ts +27 -5
  457. package/src/formats/dot/drawing.ts +799 -0
  458. package/src/formats/dot/importer.ts +120 -35
  459. package/src/formats/dot/label-places.ts +228 -0
  460. package/src/formats/dot/record.ts +336 -0
  461. package/src/formats/dot/styles.ts +1654 -153
  462. package/src/formats/gexf/dialog-metrics.ts +61 -0
  463. package/src/formats/gexf/importer.ts +50 -5
  464. package/src/formats/gexf/preview.ts +217 -0
  465. package/src/formats/gexf/schema.ts +2 -1
  466. package/src/formats/gexf/styles.ts +1099 -245
  467. package/src/formats/gml/importer.ts +291 -76
  468. package/src/formats/gml/index.ts +1 -1
  469. package/src/formats/gml/positions.ts +29 -7
  470. package/src/formats/gml/styles.ts +851 -109
  471. package/src/formats/graphml/styles-plain.ts +6 -15
  472. package/src/formats/graphml/styles-yed.ts +762 -173
  473. package/src/formats/graphml/styles-yfiles3.ts +485 -63
  474. package/src/formats/graphml/yfiles.ts +19 -6
  475. package/src/formats/json/dialect.ts +41 -5
  476. package/src/formats/json/importer.ts +59 -7
  477. package/src/formats/json/index.ts +1 -0
  478. package/src/formats/json/positions.ts +22 -5
  479. package/src/formats/json/styles.ts +2041 -185
  480. package/src/formats/pajek/draw.ts +458 -0
  481. package/src/formats/pajek/exporter.ts +81 -49
  482. package/src/formats/pajek/importer.ts +278 -103
  483. package/src/formats/pajek/index.ts +1 -0
  484. package/src/formats/pajek/styles.ts +1381 -133
  485. package/src/formats/pajek/syntax.ts +27 -2
  486. package/src/formats/xgmml/emit.ts +73 -5
  487. package/src/formats/xgmml/styles.ts +330 -71
  488. package/src/index.ts +5 -1
  489. package/src/positions/convert.ts +12 -1
  490. package/src/positions/extract.ts +55 -1
  491. package/src/positions/index.ts +1 -0
  492. package/src/positions/types.ts +60 -0
  493. package/src/sources/builtins.ts +8 -1
  494. package/src/sources/context.ts +1 -0
  495. package/src/sources/cypher/descriptor.ts +7 -1
  496. package/src/sources/cypher/index.ts +148 -18
  497. package/src/sources/cypher/params.ts +1 -1
  498. package/src/sources/cypher/query-builder.ts +33 -0
  499. package/src/sources/ids.ts +6 -0
  500. package/src/sources/params.ts +3 -0
  501. package/src/sources/rest/descriptor.ts +5 -0
  502. package/src/sources/rest/source.ts +16 -0
  503. package/src/sources/sigv4.ts +6 -4
  504. package/src/sources/sparql/descriptor.ts +67 -0
  505. package/src/sources/sparql/index.ts +356 -0
  506. package/src/sources/sparql/ntriples.ts +219 -0
  507. package/src/sources/sparql/params.ts +28 -0
  508. package/src/sources/sparql/query.ts +162 -0
  509. package/src/sources/types.ts +35 -0
  510. package/src/styles/annotations.ts +201 -27
  511. package/src/styles/canon/bends.ts +137 -0
  512. package/src/styles/canon/color-tables.ts +10 -4
  513. package/src/styles/canon/color.ts +105 -3
  514. package/src/styles/canon/enums.ts +98 -8
  515. package/src/styles/canon/graphviz.ts +71 -10
  516. package/src/styles/canon/number.ts +19 -0
  517. package/src/styles/canon/text.ts +187 -16
  518. package/src/styles/codes.ts +2 -0
  519. package/src/styles/cyjs/cascade.ts +1160 -84
  520. package/src/styles/cyjs/defaults-table.ts +3 -0
  521. package/src/styles/cyjs/emit.ts +233 -13
  522. package/src/styles/cyjs/face.ts +372 -0
  523. package/src/styles/cyjs/mappers.ts +492 -27
  524. package/src/styles/cyjs/routes.ts +432 -0
  525. package/src/styles/cytoscape/charts.ts +684 -0
  526. package/src/styles/cytoscape/emit.ts +170 -48
  527. package/src/styles/cytoscape/lexicon.ts +431 -78
  528. package/src/styles/cytoscape/mappings.ts +108 -0
  529. package/src/styles/cytoscape/resolve.ts +741 -17
  530. package/src/styles/defaults.ts +417 -108
  531. package/src/styles/index.ts +5 -0
  532. package/src/styles/internal.ts +1 -0
  533. package/src/styles/io/generic.ts +79 -23
  534. package/src/styles/io/round-trip.ts +202 -0
  535. package/src/styles/io/writer.ts +6 -1
  536. package/src/styles/notes.ts +1 -0
  537. package/src/styles/plan/features.ts +23 -2
  538. package/src/styles/plan/index.ts +1 -1
  539. package/src/styles/plan/plan.ts +69 -5
  540. package/src/styles/plan/resolve.ts +47 -4
  541. package/src/styles/slots.ts +25 -0
  542. package/src/styles/types.ts +633 -5
  543. package/src/styles/vocabulary.ts +211 -2
  544. package/dist/chunks/block-Cu22ewuS.js.map +0 -1
  545. package/dist/chunks/choose-Cdx6Enl2.js +0 -57
  546. package/dist/chunks/choose-Cdx6Enl2.js.map +0 -1
  547. package/dist/chunks/codes-CV_Bhcyi.js.map +0 -1
  548. package/dist/chunks/convert-BcQ8_jMo.js.map +0 -1
  549. package/dist/chunks/credentials-BiQsnMTb.js.map +0 -1
  550. package/dist/chunks/descriptor-BJ-W0Jd-.js.map +0 -1
  551. package/dist/chunks/emit-CD8xnY8s.js.map +0 -1
  552. package/dist/chunks/export-CZ7VRm4I.js.map +0 -1
  553. package/dist/chunks/exporter-bxxjOrDZ.js.map +0 -1
  554. package/dist/chunks/format-BMS-1Nxb.js +0 -64
  555. package/dist/chunks/format-BMS-1Nxb.js.map +0 -1
  556. package/dist/chunks/generic-CP6YD34u.js.map +0 -1
  557. package/dist/chunks/importer-B87_fmVx.js.map +0 -1
  558. package/dist/chunks/importer-CB_zV5_L.js.map +0 -1
  559. package/dist/chunks/importer-CVT-JyDE.js.map +0 -1
  560. package/dist/chunks/importer-Cyy6UseH.js.map +0 -1
  561. package/dist/chunks/importer-DPZDN40-.js.map +0 -1
  562. package/dist/chunks/importer-e3huMZbm.js.map +0 -1
  563. package/dist/chunks/lexicon-u2SI5xcx.js.map +0 -1
  564. package/dist/chunks/sigv4-LkAzsLAu.js.map +0 -1
  565. package/dist/chunks/styles-CaABMoO1.js.map +0 -1
  566. package/dist/chunks/styles-P_gmFAOi.js +0 -770
  567. package/dist/chunks/styles-P_gmFAOi.js.map +0 -1
  568. package/dist/chunks/styles-yed-Cs1nmrjn.js.map +0 -1
  569. package/dist/chunks/writer-DvHTl36J.js +0 -449
  570. package/dist/chunks/writer-DvHTl36J.js.map +0 -1
@@ -1,16 +1,17 @@
1
1
  import { GraphFormatError, INVALID_INDEX } from "@graphty/graph-format";
2
- import { R as ROLE_TAKEN_CODE, C as COLUMN_RENAMED_CODE, l as DUPLICATE_ATTRIBUTE_CODE, d as UNKNOWN_ELEMENT_CODE, aD as EMPTY_COLUMN_DROPPED_CODE, a1 as PARENT_CYCLE_CODE, P as PRECISION_CODE, s as UNKNOWN_ENCODING_CODE, Z as JSON_NONSTANDARD_NUMBER_CODE, t as ENCODING_FALLBACK_CODE, u as INVALID_ENCODING_CODE, v as INVALID_UTF8_CODE, O as OPTION_IGNORED_CODE, S as SINK_OPTION_CODE, H as HYPEREDGE_CODE, V as TOO_LARGE_CODE, f as DANGLING_REFERENCE_CODE, W as AMBIGUOUS_GRAPH_NAME_CODE, Y as GRAPH_NOT_FOUND_CODE, i as MULTIPLE_GRAPHS_CODE, I as ID_MERGED_CODE, j as DUPLICATE_EDGE_ID_CODE, k as DUPLICATE_NODE_CODE, m as UNKNOWN_PARENT_CODE, T as BAD_VALUE_CODE, n as MISSING_ENDPOINT_CODE, o as MISSING_ID_CODE, Q as SYNTAX_CODE, E as EMPTY_INPUT_CODE, y as ELEMENT_ISSUE, z as INPUT_ISSUE, K as ImportReportBuilder, p as plural, a as agree, ae as GRAPH_COLUMN_AS_METADATA_CODE, af as TYPEDEF_NODES_CODE, ag as RELATION_ASSUMED_CODE, a8 as COLUMN_AS_PROPERTY_VALUE_CODE, aG as NONFINITE_AS_NULL_CODE, aB as DIRECTION_DROPPED_CODE, ad as NODE_ORDER_CODE } from "./report-CgdsL9Hb.js";
3
- import { c as capabilities, d as resolveImportOptions, g as reportSinkOptions, f as reportUnusedOptions, I as IdCoercer, i as DirectionResolver, w as weightFromValue, u as uniqueColumnName, b as chooseGraph, h as graphChosen, j as declareResolved, p as pairFolding, e as explicitWeights, L as LOSS, a as checkCapabilities, r as resolveExportOptions, S as otherFormatDialect, U as countMixedEdges } from "./export-CZ7VRm4I.js";
4
- import { f as formatF32, a as formatF64 } from "./format-BMS-1Nxb.js";
2
+ import { R as ROLE_TAKEN_CODE, C as COLUMN_RENAMED_CODE, l as DUPLICATE_ATTRIBUTE_CODE, d as UNKNOWN_ELEMENT_CODE, az as EMPTY_COLUMN_DROPPED_CODE, a1 as PARENT_CYCLE_CODE, P as PRECISION_CODE, s as UNKNOWN_ENCODING_CODE, Z as JSON_NONSTANDARD_NUMBER_CODE, t as ENCODING_FALLBACK_CODE, u as INVALID_ENCODING_CODE, v as INVALID_UTF8_CODE, O as OPTION_IGNORED_CODE, S as SINK_OPTION_CODE, H as HYPEREDGE_CODE, V as TOO_LARGE_CODE, f as DANGLING_REFERENCE_CODE, W as AMBIGUOUS_GRAPH_NAME_CODE, Y as GRAPH_NOT_FOUND_CODE, i as MULTIPLE_GRAPHS_CODE, I as ID_MERGED_CODE, j as DUPLICATE_EDGE_ID_CODE, k as DUPLICATE_NODE_CODE, m as UNKNOWN_PARENT_CODE, T as BAD_VALUE_CODE, n as MISSING_ENDPOINT_CODE, o as MISSING_ID_CODE, Q as SYNTAX_CODE, E as EMPTY_INPUT_CODE, y as ELEMENT_ISSUE, z as INPUT_ISSUE, K as ImportReportBuilder, p as plural, a as agree, ae as GRAPH_COLUMN_AS_METADATA_CODE, af as TYPEDEF_NODES_CODE, ag as RELATION_ASSUMED_CODE, a8 as COLUMN_AS_PROPERTY_VALUE_CODE, aD as NONFINITE_AS_NULL_CODE, ax as DIRECTION_DROPPED_CODE, ad as NODE_ORDER_CODE } from "./report-CwMfYa9J.js";
3
+ import { D as DirectionResolver, p as pairFolding, f as formatF32, a as formatF64 } from "./format-BXiAb-1h.js";
4
+ import { c as capabilities, b as resolveImportOptions, f as reportSinkOptions, d as reportUnusedOptions, I as IdCoercer, w as weightFromValue, u as uniqueColumnName, g as chooseGraph, h as graphChosen, i as declareResolved, e as explicitWeights, L as LOSS, a as checkCapabilities, r as resolveExportOptions, P as otherFormatDialect, G as countMixedEdges } from "./export-Cha4dRFz.js";
5
5
  import { j as joinText, e as encodeChunks, i as indentUnit } from "./writer-DxjgHwSe.js";
6
- import { S as STYLE_BLOCK_NAME, t as toolDefaults, u as StyleNotes, v as parseStyleBlock, s as styleFingerprint, a as STYLE_ISSUE, p as plainCell, m as canonBoolean, o as canonText, h as canonNumber, x as blockStyles, g as canonColor, l as canonEnum, j as canonOpacity, r as resolveStyles } from "./block-Cu22ewuS.js";
7
- import { t as trimTrailingZeros } from "./text-BuKQVMz2.js";
8
- import { d as OBOGRAPHS_PREDICATE_TAGS, g as compactOboIri, o as oboColumnDecl, P as PLACEHOLDER_COLUMN, h as synonymScopeOf, O as OBO_NODE_COLUMNS, c as capabilityNotes, s as slotColumn, e as emptyColumnNotes, j as OBO_PURL, f as framelessNodes, m as movedNodes, U as UNWRITTEN_ROLES, n as notePropertyColumn, a as cellOf, v as valuesOf$1, k as OBO_IN_OWL, b as fitsVocabulary, t as textOf, S as SYNONYM_SCOPES } from "./ontology-export-BwgMyuF0.js";
9
- import { r as readText, b as throwIfAborted } from "./input-Ccg9I22A.js";
10
- import { M as MAYBE_UNSAFE_INTEGER, g as MAYBE_INEXACT_EXPONENT, j as rewriteNumbers, l as findDuplicateKeys, m as keysInTextOrder } from "./json-elements-By172SVq.js";
11
- import { c as cytoscapeJsStyles, C as CYTOSCAPE_IMPORT_KEY, t as toCytoscapeStylesheet, a as cyjsHoldsExactly, b as CYJS_EDGE_PROPERTIES, d as CYJS_NODE_PROPERTIES } from "./emit-CD8xnY8s.js";
12
- import { S as StyleApproximations } from "./approximations-C2riR4NT.js";
13
- import { f as flipY } from "./convert-BcQ8_jMo.js";
6
+ import { S as STYLE_BLOCK_NAME, y as toolDefaults, h as StyleNotes, m as parseStyleBlock, o as styleFingerprint, b as STYLE_ISSUE, p as plainCell, k as canonBoolean, f as canonText, c as canonNumber, d as canonColor, a as canonEnum, j as canonOpacity } from "./block-iptrlMBb.js";
7
+ import { t as trimTrailingZeros } from "./text-ystE2bYi.js";
8
+ import { d as OBOGRAPHS_PREDICATE_TAGS, g as compactOboIri, o as oboColumnDecl, P as PLACEHOLDER_COLUMN, h as synonymScopeOf, O as OBO_NODE_COLUMNS, c as capabilityNotes, s as slotColumn, e as emptyColumnNotes, j as OBO_PURL, f as framelessNodes, m as movedNodes, U as UNWRITTEN_ROLES, n as notePropertyColumn, a as cellOf, v as valuesOf$1, k as OBO_IN_OWL, b as fitsVocabulary, t as textOf, S as SYNONYM_SCOPES } from "./ontology-export-OMo91mb0.js";
9
+ import { r as readText, b as throwIfAborted } from "./input-CAxt_aV-.js";
10
+ import { M as MAYBE_UNSAFE_INTEGER, g as MAYBE_INEXACT_EXPONENT, j as rewriteNumbers, l as findDuplicateKeys, m as keysInTextOrder } from "./json-elements-Cq76WjnZ.js";
11
+ import { c as cytoscapeJsStyles, C as CYTOSCAPE_IMPORT_KEY, t as toCytoscapeStylesheet, a as cyjsHoldsExactly, b as CYJS_EDGE_PROPERTIES, d as CYJS_NODE_PROPERTIES } from "./emit-BwHQkZle.js";
12
+ import { S as StyleApproximations } from "./approximations-Bzn3L-je.js";
13
+ import { t as takeFromBlock } from "./round-trip-Zm3_ivgq.js";
14
+ import { f as flipY } from "./convert-Ct2zelbQ.js";
14
15
  const JSON_DIALECTS = Object.freeze([
15
16
  "node-link",
16
17
  "d3",
@@ -85,15 +86,37 @@ function sniffEdgeListDialect(root) {
85
86
  if (record !== void 0) {
86
87
  return record;
87
88
  }
89
+ if (!networkx && firstEdge === null && isVisOptions(root.options)) {
90
+ return "vis";
91
+ }
88
92
  const bare = !hasKey(root, "directed") && !hasKey(root, "multigraph") && !hasKey(root, "graph");
89
93
  return bare && hasKey(root, "links") ? "d3" : "node-link";
90
94
  }
95
+ const VIS_OPTION_GROUPS = [
96
+ "nodes",
97
+ "edges",
98
+ "groups",
99
+ "physics",
100
+ "layout",
101
+ "interaction",
102
+ "manipulation",
103
+ "configure",
104
+ "autoResize",
105
+ "clickToUse",
106
+ "locale",
107
+ "locales",
108
+ "height",
109
+ "width"
110
+ ];
111
+ function isVisOptions(options) {
112
+ return isJsonObject(options) && VIS_OPTION_GROUPS.some((k) => hasKey(options, k));
113
+ }
91
114
  function sniffRecordDialect(firstNode, firstEdge) {
92
115
  if (firstNode !== null && hasKey(firstNode, "key") && !hasKey(firstNode, "id")) {
93
116
  return "graphology";
94
117
  }
95
118
  if (firstEdge === null) {
96
- return void 0;
119
+ return firstNode !== null && hasKey(firstNode, "id") && isJsonObject(firstNode.attributes) ? "graphology" : void 0;
97
120
  }
98
121
  if (!hasKey(firstEdge, "from")) {
99
122
  return hasKey(firstEdge, "undirected") || isJsonObject(firstEdge.attributes) ? "graphology" : void 0;
@@ -251,8 +274,8 @@ function exponentIfUnsafe(text) {
251
274
  }
252
275
  const [, sign, digits] = match;
253
276
  const mantissa = trimTrailingZeros(digits);
254
- const fraction = mantissa.length > 1 ? `.${mantissa.slice(1)}` : "";
255
- return `${sign}${mantissa[0]}${fraction}e+${digits.length - 1}`;
277
+ const fraction2 = mantissa.length > 1 ? `.${mantissa.slice(1)}` : "";
278
+ return `${sign}${mantissa[0]}${fraction2}e+${digits.length - 1}`;
256
279
  }
257
280
  const GRAPH_FORMATS = Object.freeze([
258
281
  "json",
@@ -572,10 +595,11 @@ function clamp(value) {
572
595
  }
573
596
  return Math.min(value, 1);
574
597
  }
598
+ const SIGMA_FIT = { padding: 30 };
575
599
  const Y_DOWN_MARKERS = ["vx", "vy", "fx", "fy", "index", "physics"];
576
600
  function jsonPositions(snapshot) {
577
601
  if (snapshot.nodes.byRole("position") !== null) {
578
- return null;
602
+ return jsonShapeOf(snapshot)?.dialect === "cytoscape" ? { containersFollowChildren: true } : null;
579
603
  }
580
604
  const x = numeric(snapshot.nodes.get("x"));
581
605
  const y = numeric(snapshot.nodes.get("y"));
@@ -583,19 +607,23 @@ function jsonPositions(snapshot) {
583
607
  return null;
584
608
  }
585
609
  const z = numeric(snapshot.nodes.get("z"));
586
- const down = z === null && Y_DOWN_MARKERS.some((name) => snapshot.nodes.get(name) !== null);
610
+ const dialect = jsonShapeOf(snapshot)?.dialect;
611
+ const markers = dialect !== "graphology" && Y_DOWN_MARKERS.some((name) => snapshot.nodes.get(name) !== null);
612
+ const down = z === null && (dialect === "vis" || markers);
587
613
  return {
588
614
  x: x.meta.name,
589
615
  y: y.meta.name,
590
616
  ...z === null ? {} : { z: z.meta.name },
591
617
  yAxis: down ? "down" : "up",
592
- units: down ? "px" : "file"
618
+ units: down ? "px" : "file",
619
+ ...dialect === "graphology" ? { viewerFit: SIGMA_FIT } : {}
593
620
  };
594
621
  }
595
622
  function numeric(column) {
596
623
  const numericDtypes = ["f64", "f32", "i32", "u32", "u8"];
597
624
  return column !== null && column.meta.components === 1 && numericDtypes.includes(column.dtype) ? column : null;
598
625
  }
626
+ const SIGMA_DEFAULT_SETTINGS = { renderEdgeLabels: false, edgeLabelAnchors: "nodeLabels" };
599
627
  const TARGETS = ["node", "edge"];
600
628
  function jsonStyles(snapshot, context) {
601
629
  const src = context.kept;
@@ -736,14 +764,17 @@ function graphologyStyles(snapshot, src, context) {
736
764
  const notes = new StyleNotes();
737
765
  const out = { node: {}, edge: {} };
738
766
  const readFrom = { node: [], edge: [] };
767
+ const edgeLabel = sigmaEdgeLabels(snapshot, src.sigma ?? SIGMA_DEFAULT_SETTINGS);
739
768
  for (const target of TARGETS) {
740
769
  const n = target === "node" ? snapshot.nodeCount : snapshot.edgeCount;
741
770
  const { values, put } = valuesOf(n);
742
771
  const keys = {
743
772
  color: cells(snapshot, target, "color"),
744
773
  size: cells(snapshot, target, "size"),
745
- label: cells(snapshot, target, "label"),
746
- hidden: cells(snapshot, target, "hidden")
774
+ // sigma 4's default styles bind nothing else: it draws an element marked `hidden: true` (sigma 3's key)
775
+ // or `visibility: "hidden"` (its own display-data name) like any other (specimen sheets
776
+ // graphology-specimen-node-sizes-opacity, -edges-lines)
777
+ label: cells(snapshot, target, "label")
747
778
  };
748
779
  readFrom[target].push(...Object.entries(keys).flatMap(([name, c]) => c === null ? [] : [name]));
749
780
  for (let i = 0; i < n; i++) {
@@ -754,7 +785,7 @@ function graphologyStyles(snapshot, src, context) {
754
785
  element: i,
755
786
  budget: context.budget
756
787
  });
757
- readSigmaRow(keys, target, i, put, site);
788
+ readSigmaRow(keys, target, target === "node" || edgeLabel(i), i, put, site);
758
789
  }
759
790
  out[target] = values;
760
791
  }
@@ -771,31 +802,50 @@ function graphologyStyles(snapshot, src, context) {
771
802
  readFrom
772
803
  };
773
804
  }
774
- function readSigmaRow(keys, target, i, put, site) {
775
- const { color, size, label, hidden } = keys;
805
+ function sigmaEdgeLabels(snapshot, settings) {
806
+ if (!settings.renderEdgeLabels) {
807
+ return () => false;
808
+ }
809
+ if (settings.edgeLabelAnchors === "allNodes") {
810
+ return () => true;
811
+ }
812
+ const label = cells(snapshot, "node", "label");
813
+ const shows = (node) => {
814
+ const text = label?.(node);
815
+ return typeof text === "string" ? text !== "" : text !== null && text !== void 0;
816
+ };
817
+ return (i) => shows(snapshot.edgeSource(i)) && shows(snapshot.edgeTarget(i));
818
+ }
819
+ function readSigmaRow(keys, target, labeled, i, put, site) {
820
+ const { color, size, label } = keys;
776
821
  if (color !== null) {
777
822
  const [fill, opacity] = target === "node" ? ["fill", "fillOpacity"] : ["color", "opacity"];
778
823
  putColor(put, fill, opacity, i, color(i), site(fill));
779
824
  }
780
825
  if (size !== null) {
781
- const v = canonNumber(size(i), site("width"));
782
- put("width", i, v);
783
- if (target === "node") {
784
- put("height", i, v);
785
- }
826
+ putSigmaSize(put, target, i, size(i), site);
786
827
  }
787
- if (label !== null) {
788
- put("label", i, canonText(label(i), site("label")));
828
+ if (label !== null && labeled) {
829
+ const text = canonText(label(i), site("label"));
830
+ put("label", i, text === null ? null : text.replaceAll(/[\t\n\f\r]/g, " "));
789
831
  }
790
- if (hidden !== null && canonBoolean(hidden(i), site("visible")) === true) {
791
- put("visible", i, false);
832
+ }
833
+ function putSigmaSize(put, target, i, raw, site) {
834
+ if (target === "node") {
835
+ const v = Number(raw) < 0 ? 0 : canonNumber(raw, site("width"));
836
+ const d = v === null ? null : v * 2;
837
+ put("width", i, d);
838
+ put("height", i, d);
839
+ } else {
840
+ const w = canonNumber(raw, site("width"));
841
+ put("width", i, w === null ? null : w / 2);
792
842
  }
793
843
  }
794
844
  function putColor(put, property, opacity, i, raw, site) {
795
- if (raw === null || raw === void 0 || raw === "") {
845
+ if (raw === null || raw === void 0) {
796
846
  return;
797
847
  }
798
- const c = canonColor(raw, "css", site);
848
+ const c = canonColor(raw, "graphology", site);
799
849
  if (c === null) {
800
850
  return;
801
851
  }
@@ -819,48 +869,27 @@ function blockText(snapshot, src) {
819
869
  return typeof v === "string" ? v : null;
820
870
  }
821
871
  function exactFromBlock(snapshot, text, values, written, holdsExactly) {
822
- if (text === null) {
823
- return;
824
- }
825
- const parsed = parseStyleBlock(text, styleFingerprint(snapshot));
826
- const ex = parsed.ok ? blockStyles(parsed.block, snapshot, "json") : null;
827
- if (ex === null) {
828
- return;
829
- }
830
- for (const target of TARGETS) {
872
+ takeFromBlock(snapshot, text, "json", (target, block, ex) => {
831
873
  const n = target === "node" ? snapshot.nodeCount : snapshot.edgeCount;
832
- const cache = /* @__PURE__ */ new Map();
833
- const resolved = (p) => {
834
- let r = cache.get(p);
835
- if (r === void 0) {
836
- r = resolveStyles(ex, target, p, snapshot);
837
- cache.set(p, r);
838
- }
839
- return r;
840
- };
841
874
  if (holdsExactly !== void 0) {
842
875
  const properties = new Set(
843
876
  ex.styles.rules.filter((r) => r.target === target).flatMap((r) => [...Object.keys(r.set ?? {}), ...Object.keys(r.map ?? {})])
844
877
  );
845
878
  for (const property of properties) {
846
879
  const held = (w) => holdsExactly(target, property, w);
847
- takeUnheld(values[target], property, resolved(property), n, held);
880
+ takeUnheld(values[target], property, block(target, property), n, held);
848
881
  }
849
882
  }
850
- for (const [property, write2] of Object.entries(written[target] ?? {})) {
851
- takeWritten(values[target], property, n, resolved, write2, snapshot);
852
- }
853
- }
854
- }
855
- function takeWritten(column, property, n, resolved, write2, snapshot) {
856
- const want = resolved(property);
857
- for (let i = 0; i < n; i++) {
858
- const w = want[i];
859
- const native = column[property]?.[i] ?? null;
860
- if (native !== w && native !== null && native === write2((p) => resolved(p)[i], i, snapshot)) {
861
- setValue(column, property, n, i, w);
862
- }
863
- }
883
+ const writes = written[target] ?? {};
884
+ return {
885
+ values: values[target],
886
+ properties: Object.keys(writes),
887
+ // a native value the writer made from the block's other values (vis.js's one size for a width) is the
888
+ // block's own value, none included
889
+ readBack: (i, want) => (property) => writes[property](want, i, snapshot),
890
+ take: (_property, _wanted, native) => native !== null
891
+ };
892
+ });
864
893
  }
865
894
  function takeUnheld(values, property, want, n, held) {
866
895
  for (let i = 0; i < n; i++) {
@@ -888,6 +917,15 @@ const VIS_SIZED = /* @__PURE__ */ new Set([
888
917
  "square",
889
918
  "icon"
890
919
  ]);
920
+ const VIS_LABEL_FIT = /* @__PURE__ */ new Map([
921
+ ["box", { square: false, ellipse: false }],
922
+ ["text", { square: false, ellipse: false }],
923
+ ["circle", { square: true, ellipse: false }],
924
+ ["database", { square: true, ellipse: false }],
925
+ ["ellipse", { square: false, ellipse: true }]
926
+ ]);
927
+ const VIS_MARGIN = 5;
928
+ const VIS_FONT_SIZE = 14;
891
929
  const VIS_GROUP_PALETTE = [
892
930
  ["#2B7CE9", "#97C2FC"],
893
931
  ["#FFA500", "#FFFF00"],
@@ -910,6 +948,8 @@ const VIS_GROUP_PALETTE = [
910
948
  ["#C2FABC", "#74D66A"],
911
949
  ["#EE0000", "#990000"]
912
950
  ];
951
+ const VIS_NODE_FILL = "#97C2FC";
952
+ const VIS_NODE_BORDER = "#2B7CE9";
913
953
  const VIS_EDGE_COLOR = "#848484";
914
954
  function visParseColor(text) {
915
955
  let hex = text;
@@ -978,7 +1018,14 @@ function visLayer(o, target) {
978
1018
  set("hidden", o.hidden);
979
1019
  set("label", o.label);
980
1020
  set("title", o.title);
1021
+ set("wrapWidth", isJsonObject(o.widthConstraint) ? o.widthConstraint.maximum : o.widthConstraint);
1022
+ if (isJsonObject(o.scaling)) {
1023
+ set("scalingLabel", o.scaling.label);
1024
+ }
981
1025
  visFontLayer(o.font, set);
1026
+ if (target === "edge" && o.font !== void 0 && o.font !== null) {
1027
+ set("fontText", typeof o.font === "string");
1028
+ }
982
1029
  return layer;
983
1030
  }
984
1031
  function visNodeLayer(o, set) {
@@ -993,8 +1040,104 @@ function visNodeLayer(o, set) {
993
1040
  }
994
1041
  set("shape", o.shape);
995
1042
  set("size", o.size);
1043
+ set("value", o.value);
1044
+ if (isJsonObject(o.scaling)) {
1045
+ set("scalingMin", o.scaling.min);
1046
+ set("scalingMax", o.scaling.max);
1047
+ }
996
1048
  set("borderWidth", o.borderWidth);
997
1049
  set("opacity", o.opacity);
1050
+ set("margin", o.margin);
1051
+ set("widthMin", isJsonObject(o.widthConstraint) ? o.widthConstraint.minimum : o.widthConstraint);
1052
+ set("heightMin", isJsonObject(o.heightConstraint) ? o.heightConstraint.minimum : o.heightConstraint);
1053
+ set("valign", isJsonObject(o.heightConstraint) ? o.heightConstraint.valign : void 0);
1054
+ set("image", isJsonObject(o.image) ? o.image.unselected : o.image);
1055
+ set("brokenImage", o.brokenImage);
1056
+ set("imagePadding", o.imagePadding);
1057
+ if (isJsonObject(o.icon)) {
1058
+ set("iconCode", o.icon.code);
1059
+ set("iconFace", o.icon.face);
1060
+ set("iconSize", o.icon.size);
1061
+ set("iconColor", o.icon.color);
1062
+ set("iconWeight", o.icon.weight);
1063
+ }
1064
+ if (isJsonObject(o.shapeProperties)) {
1065
+ set("useImageSize", o.shapeProperties.useImageSize);
1066
+ set("useBorderWithImage", o.shapeProperties.useBorderWithImage);
1067
+ set("interpolation", o.shapeProperties.interpolation);
1068
+ set("coordinateOrigin", o.shapeProperties.coordinateOrigin);
1069
+ set("borderDashes", o.shapeProperties.borderDashes);
1070
+ set("borderRadius", o.shapeProperties.borderRadius);
1071
+ }
1072
+ }
1073
+ function visImage(layer, shape, box) {
1074
+ const text = (v) => typeof v === "string" && v !== "" ? v : null;
1075
+ const [own, broken] = [text(layer.image), text(layer.brokenImage)];
1076
+ const src = own ?? broken;
1077
+ if (shape !== "image" && shape !== "circularImage" || src === null) {
1078
+ return {};
1079
+ }
1080
+ const circular = shape === "circularImage";
1081
+ const row = {
1082
+ image: src,
1083
+ ...own !== null && broken !== null ? { imageFallback: broken } : {},
1084
+ imageFit: layer.useImageSize === true ? "none" : "cover",
1085
+ imageClip: circular ? "node" : "none",
1086
+ shape: "ellipse"
1087
+ };
1088
+ if (!circular) {
1089
+ row.shape = layer.useBorderWithImage === true ? "rectangle" : "none";
1090
+ }
1091
+ if (layer.interpolation === false) {
1092
+ row.imageSmoothing = false;
1093
+ }
1094
+ const opacity = typeof layer.opacity === "number" && layer.opacity >= 0 && layer.opacity < 1 ? layer.opacity : null;
1095
+ if (opacity !== null) {
1096
+ row.imageOpacity = opacity;
1097
+ }
1098
+ visImagePlace(row, layer, box);
1099
+ return row;
1100
+ }
1101
+ function visImagePlace(row, layer, box) {
1102
+ const pad = visImagePadding(layer.imagePadding);
1103
+ if (pad !== null && layer.useImageSize !== true) {
1104
+ row.imageFit = "none";
1105
+ row.imageWidth = Math.max(0, box.width - pad.left - pad.right);
1106
+ row.imageHeight = Math.max(0, box.height - pad.top - pad.bottom);
1107
+ row.imageOffsetX = (pad.left - pad.right) / 2;
1108
+ row.imageOffsetY = (pad.top - pad.bottom) / 2;
1109
+ }
1110
+ if (layer.coordinateOrigin === "top-left" && row.shape === "none") {
1111
+ row.imageOffsetX = box.width / 2 + (typeof row.imageOffsetX === "number" ? row.imageOffsetX : 0);
1112
+ row.imageOffsetY = box.height / 2 + (typeof row.imageOffsetY === "number" ? row.imageOffsetY : 0);
1113
+ }
1114
+ }
1115
+ function visIcon(layer, site) {
1116
+ const code = typeof layer.iconCode === "string" && layer.iconCode !== "" ? layer.iconCode : null;
1117
+ if (code === null) {
1118
+ return {};
1119
+ }
1120
+ const size = typeof layer.iconSize === "number" && layer.iconSize >= 0 ? layer.iconSize : 50;
1121
+ const color = typeof layer.iconColor === "string" ? canonColor(layer.iconColor, "vis", site) : null;
1122
+ const weight = layer.iconWeight;
1123
+ const bold = weight === "bold" || weight === "bolder" || typeof weight === "number" && weight >= 600;
1124
+ return {
1125
+ glyph: code,
1126
+ glyphFont: typeof layer.iconFace === "string" && layer.iconFace !== "" ? layer.iconFace : "FontAwesome",
1127
+ glyphSize: size,
1128
+ glyphColor: color?.color ?? "#2b7ce9",
1129
+ glyphWeight: bold ? "bold" : "normal"
1130
+ };
1131
+ }
1132
+ function visImagePadding(raw) {
1133
+ const side = (v) => typeof v === "number" && Number.isFinite(v) && v > 0 ? v : 0;
1134
+ let pad = null;
1135
+ if (typeof raw === "number") {
1136
+ pad = { top: side(raw), right: side(raw), bottom: side(raw), left: side(raw) };
1137
+ } else if (isJsonObject(raw)) {
1138
+ pad = { top: side(raw.top), right: side(raw.right), bottom: side(raw.bottom), left: side(raw.left) };
1139
+ }
1140
+ return pad === null || pad.top + pad.right + pad.bottom + pad.left === 0 ? null : pad;
998
1141
  }
999
1142
  function visEdgeLayer(o, set) {
1000
1143
  const { color } = o;
@@ -1008,14 +1151,34 @@ function visEdgeLayer(o, set) {
1008
1151
  set("inherit", own ? false : color.inherit);
1009
1152
  }
1010
1153
  set("width", o.width);
1154
+ set("value", o.value);
1155
+ if (isJsonObject(o.scaling)) {
1156
+ set("scalingMin", o.scaling.min);
1157
+ set("scalingMax", o.scaling.max);
1158
+ }
1011
1159
  set("dashes", o.dashes);
1012
1160
  set("arrows", o.arrows);
1161
+ set("background", o.background);
1162
+ set("smooth", o.smooth);
1163
+ set("selfReference", o.selfReference);
1164
+ set("selfReferenceSize", o.selfReferenceSize);
1165
+ set("physics", o.physics);
1013
1166
  }
1014
1167
  function visFontLayer(font, set) {
1015
1168
  if (isJsonObject(font)) {
1169
+ set("fontMulti", font.multi);
1170
+ set("fontStrokeWidth", font.strokeWidth);
1171
+ set("fontStrokeColor", font.strokeColor);
1172
+ set("fontBackground", font.background);
1173
+ set("fontAlign", font.align);
1016
1174
  set("fontColor", font.color);
1017
1175
  set("fontSize", font.size);
1018
1176
  set("fontFace", font.face);
1177
+ set("fontVadjust", font.vadjust);
1178
+ const mods = ["bold", "ital", "boldital", "mono"].filter((m) => font[m] !== void 0 && font[m] !== null);
1179
+ if (mods.length > 0) {
1180
+ set("fontMods", Object.fromEntries(mods.map((m) => [m, font[m]])));
1181
+ }
1019
1182
  } else if (typeof font === "string") {
1020
1183
  const m = /^\s*(\d+(?:\.\d+)?)(?:px)?\s+(\S+)(?:\s+(\S+))?/.exec(font.slice(0, 256));
1021
1184
  if (m !== null) {
@@ -1046,44 +1209,328 @@ function visValues(layer, target, site, sized) {
1046
1209
  };
1047
1210
  if (target === "node") {
1048
1211
  color("fill", "fillOpacity", layer.fill);
1049
- color("borderColor", null, layer.border);
1212
+ color("borderColor", "borderOpacity", layer.border);
1050
1213
  visNodeValues(layer, sized, put, site);
1051
1214
  } else {
1052
1215
  color("color", "opacity", layer.edgeColor);
1053
1216
  visEdgeValues(layer, put, site);
1217
+ visEdgeBackground(layer, put, color);
1054
1218
  }
1055
1219
  if (layer.hidden !== void 0 && canonBoolean(layer.hidden, site("visible")) === true) {
1056
1220
  put("visible", false);
1057
1221
  }
1058
- if (layer.label !== void 0) {
1059
- put("label", canonText(layer.label, site("label")));
1222
+ visLabelValues(layer, target, put, color, site);
1223
+ return out;
1224
+ }
1225
+ function visEdgeBackground(layer, put, color) {
1226
+ if (!isJsonObject(layer.background)) {
1227
+ return;
1060
1228
  }
1061
- if (layer.title !== void 0) {
1062
- put("tooltip", canonText(layer.title, site("tooltip")));
1229
+ const bg = layer.background;
1230
+ const straight = layer.smooth === false || isJsonObject(layer.smooth) && layer.smooth.enabled === false;
1231
+ color("outlineColor", "outlineOpacity", bg.color);
1232
+ if (bg.enabled !== void 0) {
1233
+ const size = typeof bg.size === "number" ? bg.size : 10;
1234
+ const width = typeof layer.width === "number" ? layer.width : 1;
1235
+ put("outlineWidth", bg.enabled === true && !straight ? Math.max(0, size - width) : 0);
1063
1236
  }
1064
- color("labelColor", null, layer.fontColor);
1237
+ const band = visBandStyle(bg, false);
1238
+ if (band !== null) {
1239
+ put("outlineStyle", band);
1240
+ }
1241
+ }
1242
+ function visLabelValues(layer, target, put, color, site) {
1065
1243
  if (layer.fontSize !== void 0) {
1066
1244
  put("labelSize", canonNumber(layer.fontSize, site("labelSize")));
1067
1245
  }
1068
1246
  if (layer.fontFace !== void 0) {
1069
1247
  put("labelFont", canonText(layer.fontFace, site("labelFont")));
1070
1248
  }
1071
- return out;
1249
+ if (layer.label !== void 0) {
1250
+ visLabelText(layer, target, put, site);
1251
+ }
1252
+ if (typeof layer.wrapWidth === "number" && Number.isFinite(layer.wrapWidth) && layer.wrapWidth > 0) {
1253
+ put("labelWrapWidth", layer.wrapWidth);
1254
+ put("labelWrapSpaceCount", 3);
1255
+ }
1256
+ if (layer.title !== void 0) {
1257
+ put("tooltip", canonText(layer.title, site("tooltip")));
1258
+ }
1259
+ const threshold = isJsonObject(layer.scalingLabel) ? layer.scalingLabel.drawThreshold : void 0;
1260
+ if (typeof threshold === "number" && Number.isFinite(threshold)) {
1261
+ put("labelMinScreenSize", Math.max(0, threshold - 1));
1262
+ }
1263
+ visLabelLook(layer, target, put, color, site);
1264
+ }
1265
+ function visLabelText(layer, target, put, site) {
1266
+ const text = target === "edge" && layer.fontText === true ? "" : canonText(layer.label, site("label"));
1267
+ const marked = typeof text === "string" ? visMarkup(text, layer.fontMulti) : null;
1268
+ put("label", marked?.text ?? text);
1269
+ if (marked !== null) {
1270
+ const runs = visRuns(marked.runs, layer, site("labelRuns"));
1271
+ put("labelRuns", runs);
1272
+ if (runs !== null) {
1273
+ put("labelRunAlign", visRunAlign(layer, target));
1274
+ }
1275
+ }
1276
+ for (const [p, v] of Object.entries(VIS_MOD_VALUES[marked?.mod ?? "normal"] ?? {})) {
1277
+ put(p, v);
1278
+ }
1279
+ }
1280
+ function visLabelLook(layer, target, put, color, site) {
1281
+ color("labelColor", null, layer.fontColor);
1282
+ color("labelBackground", null, layer.fontBackground === "none" ? void 0 : layer.fontBackground);
1283
+ if (typeof layer.fontBackground === "string" && layer.fontBackground !== "none") {
1284
+ put("labelPadding", 0);
1285
+ put("labelLineHeight", 1);
1286
+ }
1287
+ const stroked = typeof layer.fontStrokeWidth === "number" && layer.fontStrokeWidth > 0;
1288
+ color("labelOutlineColor", null, layer.fontStrokeColor ?? (stroked ? "#ffffff" : void 0));
1289
+ if (layer.fontStrokeWidth !== void 0) {
1290
+ put("labelOutlineWidth", canonNumber(layer.fontStrokeWidth, site("labelOutlineWidth")));
1291
+ }
1292
+ if (target === "edge" && typeof layer.fontAlign === "string") {
1293
+ put("labelPosition", layer.fontAlign === "top" || layer.fontAlign === "bottom" ? layer.fontAlign : "center");
1294
+ } else if (target === "node" && typeof layer.fontAlign === "string") {
1295
+ put("labelTextAlign", { center: "center", right: "right" }[layer.fontAlign] ?? "left");
1296
+ }
1297
+ if (typeof layer.fontVadjust === "number" && Number.isFinite(layer.fontVadjust) && layer.fontVadjust !== 0) {
1298
+ put("labelOffsetY", layer.fontVadjust);
1299
+ }
1300
+ }
1301
+ const VIS_MOD_VALUES = {
1302
+ bold: { labelWeight: "bold" },
1303
+ ital: { labelItalic: true },
1304
+ boldital: { labelWeight: "bold", labelItalic: true },
1305
+ mono: { labelFont: "monospace" }
1306
+ };
1307
+ function visTakesOpacity(color) {
1308
+ if (color === void 0) {
1309
+ return true;
1310
+ }
1311
+ return typeof color === "string" && !color.includes("rgba") && (color.includes("rgb") || /^#?(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(color.trim()));
1312
+ }
1313
+ function visBandStyle(bg, round) {
1314
+ if (bg.dashes === void 0 || bg.dashes === false) {
1315
+ return null;
1316
+ }
1317
+ return visDashStyle(bg.dashes === true ? [5, 5] : bg.dashes, typeof bg.size === "number" ? bg.size : 10, round);
1318
+ }
1319
+ function visDashStyle(dashes, width, round) {
1320
+ if (!Array.isArray(dashes)) {
1321
+ return dashes === false ? "solid" : "dashed";
1322
+ }
1323
+ const lengths = dashes.filter((d) => typeof d === "number" && Number.isFinite(d));
1324
+ const pairs = lengths.length % 2 === 1 ? [...lengths, ...lengths] : lengths;
1325
+ const grow = round ? width : 0;
1326
+ const on = pairs.filter((_d, i) => i % 2 === 0).map((d) => Math.max(0, d) + grow);
1327
+ const off = pairs.filter((_d, i) => i % 2 === 1).map((d) => Math.max(0, d - grow));
1328
+ const sum = (xs) => xs.reduce((a, b) => a + b, 0);
1329
+ if (on.length === 0 || sum(off) < 0.1 * (sum(on) + sum(off))) {
1330
+ return "solid";
1331
+ }
1332
+ if (on.every((d) => d <= 1.5 * Math.max(1, width))) {
1333
+ return "dotted";
1334
+ }
1335
+ return Math.max(...on) >= 2 * Math.min(...on) ? "dash-dot" : "dashed";
1336
+ }
1337
+ function visMarkup(text, multi) {
1338
+ const system = VIS_MARKUP_SYSTEM.get(multi);
1339
+ if (system === void 0) {
1340
+ return null;
1341
+ }
1342
+ const state = { bold: false, ital: false, mono: false };
1343
+ const runs = [];
1344
+ const source = text.slice(0, 4096);
1345
+ let i = 0;
1346
+ while (i < source.length) {
1347
+ const tagged = visMarkTag(source, i, system, state);
1348
+ if (tagged > 0) {
1349
+ i += tagged;
1350
+ continue;
1351
+ }
1352
+ const [ch, next] = visMarkChar(source, i, system);
1353
+ runs.push({ text: ch, mod: visMarkMod(state) });
1354
+ i = next;
1355
+ }
1356
+ const mods = new Set(runs.filter((r) => /\S/.test(r.text)).map((r) => r.mod));
1357
+ const only = mods.size === 1 ? [...mods][0] : null;
1358
+ const merged = [];
1359
+ for (const r of runs) {
1360
+ const last = merged.at(-1);
1361
+ if (last?.mod === r.mod) {
1362
+ last.text += r.text;
1363
+ } else {
1364
+ merged.push({ ...r });
1365
+ }
1366
+ }
1367
+ return { text: runs.map((r) => r.text).join(""), mod: only === "normal" ? null : only, runs: merged };
1368
+ }
1369
+ const VIS_MOD_DEFAULTS = {
1370
+ bold: { mod: "bold" },
1371
+ ital: { mod: "italic" },
1372
+ boldital: { mod: "bold italic" },
1373
+ mono: { mod: "", face: "monospace", size: 15, vadjust: 2 }
1374
+ };
1375
+ function visRuns(runs, layer, site) {
1376
+ const own = {
1377
+ face: typeof layer.fontFace === "string" ? layer.fontFace : "arial",
1378
+ size: typeof layer.fontSize === "number" ? layer.fontSize : VIS_FONT_SIZE,
1379
+ color: typeof layer.fontColor === "string" ? layer.fontColor : null,
1380
+ vadjust: typeof layer.fontVadjust === "number" && Number.isFinite(layer.fontVadjust) ? layer.fontVadjust : 0
1381
+ };
1382
+ const mods = isJsonObject(layer.fontMods) ? layer.fontMods : {};
1383
+ let differs = false;
1384
+ const out = runs.map((r) => {
1385
+ const run = { text: r.text };
1386
+ const base = VIS_MOD_DEFAULTS[r.mod];
1387
+ if (base === void 0) {
1388
+ return run;
1389
+ }
1390
+ const given = visModOptions(mods[r.mod]);
1391
+ const modText = typeof given.mod === "string" ? given.mod : base.mod;
1392
+ const face = typeof given.face === "string" ? given.face : base.face ?? own.face;
1393
+ const size = typeof given.size === "number" ? given.size : base.size ?? own.size;
1394
+ const vadjust = typeof given.vadjust === "number" ? given.vadjust : base.vadjust ?? own.vadjust;
1395
+ const color = typeof given.color === "string" ? canonColor(given.color, "vis", site)?.color : null;
1396
+ if (modText.includes("bold")) {
1397
+ run.weight = "bold";
1398
+ }
1399
+ if (modText.includes("italic")) {
1400
+ run.italic = true;
1401
+ }
1402
+ if (face !== null && face !== own.face) {
1403
+ run.font = face;
1404
+ }
1405
+ if (size !== own.size) {
1406
+ run.size = size;
1407
+ }
1408
+ if (Number.isFinite(vadjust) && vadjust !== own.vadjust) {
1409
+ run.shift = vadjust - own.vadjust;
1410
+ }
1411
+ if (typeof color === "string") {
1412
+ run.color = color;
1413
+ }
1414
+ differs ||= Object.keys(run).length > 1;
1415
+ return run;
1416
+ });
1417
+ return differs ? JSON.stringify(out) : null;
1418
+ }
1419
+ function visRunAlign(layer, target) {
1420
+ if (target === "edge") {
1421
+ return { top: "baseline", bottom: "hanging" }[String(layer.fontAlign)] ?? "middle";
1422
+ }
1423
+ const shape = typeof layer.shape === "string" ? layer.shape : "ellipse";
1424
+ return VIS_SIZED.has(shape) ? "hanging" : "middle";
1425
+ }
1426
+ function visBelowGap(size) {
1427
+ return 2 + size / 6;
1428
+ }
1429
+ function visRunsDrop(runs, size) {
1430
+ let parsed;
1431
+ try {
1432
+ parsed = JSON.parse(runs);
1433
+ } catch {
1434
+ return 0;
1435
+ }
1436
+ if (!Array.isArray(parsed)) {
1437
+ return 0;
1438
+ }
1439
+ const lines = [size];
1440
+ for (const run of parsed) {
1441
+ const runSize = typeof run.size === "number" ? run.size : size;
1442
+ (typeof run.text === "string" ? run.text : "").split("\n").forEach((piece, i) => {
1443
+ if (i > 0) {
1444
+ lines.push(size);
1445
+ }
1446
+ if (piece !== "") {
1447
+ lines[lines.length - 1] = Math.max(lines.at(-1) ?? size, runSize);
1448
+ }
1449
+ });
1450
+ }
1451
+ return lines.reduce((sum, h) => sum + h - size, 0) / 2;
1452
+ }
1453
+ function visModOptions(raw) {
1454
+ if (isJsonObject(raw)) {
1455
+ return raw;
1456
+ }
1457
+ if (typeof raw === "string") {
1458
+ const m = /^\s*(\d+(?:\.\d+)?)(?:px)?\s+(\S+)(?:\s+(\S+))?/.exec(raw.slice(0, 256));
1459
+ if (m !== null) {
1460
+ return { size: Number(m[1]), face: m[2], ...m[3] === void 0 ? {} : { color: m[3] } };
1461
+ }
1462
+ }
1463
+ return {};
1464
+ }
1465
+ const VIS_MARKUP_SYSTEM = /* @__PURE__ */ new Map([
1466
+ [true, "html"],
1467
+ ["html", "html"],
1468
+ ["markdown", "md"],
1469
+ ["md", "md"]
1470
+ ]);
1471
+ const VIS_MARKS = {
1472
+ html: { "<b>": "bold", "</b>": "bold", "<i>": "ital", "</i>": "ital", "<code>": "mono", "</code>": "mono" },
1473
+ md: { "*": "bold", _: "ital", "`": "mono" }
1474
+ };
1475
+ function visMarkTag(source, i, system, state) {
1476
+ const marks = VIS_MARKS[system];
1477
+ const tag = Object.keys(marks).find((m) => source.startsWith(m, i));
1478
+ if (tag === void 0) {
1479
+ return 0;
1480
+ }
1481
+ const key = marks[tag];
1482
+ const toggles = system === "html" ? state[key] === tag.startsWith("</") : state[key] || i === 0 || /\s/.test(source[i - 1]);
1483
+ if (!toggles) {
1484
+ return 0;
1485
+ }
1486
+ state[key] = !state[key];
1487
+ return tag.length;
1488
+ }
1489
+ function visMarkChar(source, i, system) {
1490
+ if (system === "md") {
1491
+ return source[i] === "\\" && i + 1 < source.length ? [source[i + 1], i + 2] : [source[i], i + 1];
1492
+ }
1493
+ const entity = [
1494
+ ["&lt;", "<"],
1495
+ ["&amp;", "&"]
1496
+ ].find(([e]) => source.startsWith(e, i));
1497
+ return entity === void 0 ? [source[i], i + 1] : [entity[1], i + entity[0].length];
1498
+ }
1499
+ function visMarkMod(state) {
1500
+ if (state.mono) {
1501
+ return "mono";
1502
+ }
1503
+ if (state.bold) {
1504
+ return state.ital ? "boldital" : "bold";
1505
+ }
1506
+ return state.ital ? "ital" : "normal";
1072
1507
  }
1073
1508
  function visNodeValues(layer, sized, put, site) {
1074
1509
  if (layer.shape !== void 0) {
1075
1510
  put("shape", canonEnum("shape", layer.shape, "vis", site("shape")));
1511
+ if (typeof layer.shape === "string") {
1512
+ put("labelPosition", VIS_SIZED.has(layer.shape) ? "bottom" : "center");
1513
+ }
1076
1514
  }
1077
1515
  if (sized && layer.size !== void 0) {
1078
1516
  const v = canonNumber(layer.size, site("width"));
1079
- put("width", v);
1080
- put("height", v);
1517
+ put("width", v === null ? null : 2 * v);
1518
+ put("height", v === null ? null : 2 * v);
1081
1519
  }
1082
1520
  if (layer.borderWidth !== void 0) {
1083
1521
  put("borderWidth", canonNumber(layer.borderWidth, site("borderWidth")));
1084
1522
  }
1523
+ visNodeOpacityAndDashes(layer, put, site);
1524
+ }
1525
+ function visNodeOpacityAndDashes(layer, put, site) {
1085
1526
  if (layer.opacity !== void 0) {
1086
- put("opacity", canonOpacity(layer.opacity, "vis", site("opacity")));
1527
+ const opacity = canonOpacity(layer.opacity, "vis", site("opacity"));
1528
+ put("opacity", visTakesOpacity(layer.fill) ? opacity : null);
1529
+ put("borderOpacity", visTakesOpacity(layer.border) ? opacity : null);
1530
+ }
1531
+ if (layer.borderDashes !== void 0) {
1532
+ const width = typeof layer.borderWidth === "number" ? layer.borderWidth : 1;
1533
+ put("borderStyle", visDashStyle(layer.borderDashes === true ? [5, 15] : layer.borderDashes, width, false));
1087
1534
  }
1088
1535
  }
1089
1536
  function visEdgeValues(layer, put, site) {
@@ -1094,18 +1541,52 @@ function visEdgeValues(layer, put, site) {
1094
1541
  put("width", canonNumber(layer.width, site("width")));
1095
1542
  }
1096
1543
  if (layer.dashes !== void 0) {
1097
- put("lineStyle", layer.dashes === false || layer.dashes === "false" ? "solid" : "dashed");
1544
+ const width = typeof layer.width === "number" ? layer.width : 1;
1545
+ const dashes = layer.dashes === true ? [5, 5] : layer.dashes;
1546
+ put("lineStyle", layer.dashes === "false" ? "solid" : visDashStyle(dashes, width, true));
1098
1547
  }
1099
1548
  if (layer.arrows !== void 0) {
1100
- const [to, from] = visArrows(layer.arrows, site);
1549
+ const [to, from, middle] = visArrows(layer.arrows, site);
1101
1550
  put("targetArrow", to);
1102
1551
  put("sourceArrow", from);
1552
+ put("midTargetArrow", middle);
1553
+ const scaled = (name) => {
1554
+ const a = isJsonObject(layer.arrows) ? layer.arrows[name] : void 0;
1555
+ return isJsonObject(a) ? a.scaleFactor : void 0;
1556
+ };
1557
+ const scale = scaled("to") ?? scaled("from") ?? scaled("middle");
1558
+ if (scale !== void 0) {
1559
+ put("arrowSize", canonNumber(scale, site("arrowSize")));
1560
+ }
1561
+ visArrowImages(layer.arrows, put, site);
1562
+ }
1563
+ }
1564
+ function visArrowImages(arrows, put, site) {
1565
+ if (!isJsonObject(arrows)) {
1566
+ return;
1567
+ }
1568
+ for (const [name, property] of [
1569
+ ["to", "targetArrow"],
1570
+ ["from", "sourceArrow"],
1571
+ ["middle", "midTargetArrow"]
1572
+ ]) {
1573
+ const a = arrows[name];
1574
+ if (!isJsonObject(a) || a.type !== "image" || typeof a.src !== "string" || a.src === "") {
1575
+ continue;
1576
+ }
1577
+ put(`${property}Image`, a.src);
1578
+ if (a.imageWidth !== void 0) {
1579
+ put(`${property}ImageWidth`, canonNumber(a.imageWidth, site(`${property}ImageWidth`)));
1580
+ }
1581
+ if (a.imageHeight !== void 0) {
1582
+ put(`${property}ImageHeight`, canonNumber(a.imageHeight, site(`${property}ImageHeight`)));
1583
+ }
1103
1584
  }
1104
1585
  }
1105
1586
  function visArrows(arrows, site) {
1106
- const end = (name, property) => {
1587
+ const end = (name, property, absent = "none") => {
1107
1588
  if (typeof arrows === "string") {
1108
- return new RegExp(String.raw`\b${name}\b`).test(arrows.slice(0, 256)) ? "triangle" : "none";
1589
+ return new RegExp(String.raw`\b${name}\b`).test(arrows.slice(0, 256)) ? "triangle" : absent;
1109
1590
  }
1110
1591
  if (!isJsonObject(arrows)) {
1111
1592
  return null;
@@ -1114,12 +1595,15 @@ function visArrows(arrows, site) {
1114
1595
  if (a === true) {
1115
1596
  return "triangle";
1116
1597
  }
1598
+ if (a === void 0) {
1599
+ return absent;
1600
+ }
1117
1601
  if (!isJsonObject(a) || a.enabled === false) {
1118
1602
  return "none";
1119
1603
  }
1120
1604
  return canonEnum("arrow", a.type ?? "arrow", "vis", site(property));
1121
1605
  };
1122
- return [end("to", "targetArrow"), end("from", "sourceArrow")];
1606
+ return [end("to", "targetArrow"), end("from", "sourceArrow"), end("middle", "midTargetArrow", null)];
1123
1607
  }
1124
1608
  function visStyles(snapshot, src, context) {
1125
1609
  const notes = new StyleNotes();
@@ -1137,13 +1621,17 @@ function visStyles(snapshot, src, context) {
1137
1621
  const { groupLayers, paletteRows } = visGroupLayers(n, groupOf, visGroupDefs(src, options));
1138
1622
  context.budget.spend("node", n);
1139
1623
  const node = valuesOf(n);
1140
- const records = nodeRecords(snapshot);
1141
- const rawShape = (layer) => typeof layer.shape === "string" ? layer.shape : null;
1624
+ const shapes = [];
1625
+ const rawRecords = elementRaw(snapshot, "node");
1626
+ const range = visNodeValueRange(n, groupOf, rawRecords, groupLayers, nodeDefaults);
1627
+ const ownGroup = visOwnGroup(groupLayers, visGroupDefs(src, options));
1142
1628
  for (let i = 0; i < n; i++) {
1143
1629
  const g = groupOf(i);
1144
- const own = records(i);
1145
- const group = g === null ? {} : groupLayers.get(g) ?? {};
1146
- const shape = rawShape(own) ?? rawShape(group) ?? rawShape(nodeDefaults) ?? "ellipse";
1630
+ const raw = rawRecords(i);
1631
+ const own = visLayer(raw, "node");
1632
+ const group = g === null ? {} : ownGroup(g, raw);
1633
+ const shape = visShapeOf(own) ?? visShapeOf(group) ?? visShapeOf(nodeDefaults) ?? "ellipse";
1634
+ shapes.push(shape);
1147
1635
  const site = (property) => ({
1148
1636
  notes,
1149
1637
  target: "node",
@@ -1151,8 +1639,8 @@ function visStyles(snapshot, src, context) {
1151
1639
  element: i,
1152
1640
  budget: context.budget
1153
1641
  });
1154
- const merged = { ...nodeDefaults, ...group, ...own };
1155
- for (const [p, v] of Object.entries(visValues(merged, "node", site, VIS_SIZED.has(shape)))) {
1642
+ const merged = visMergedNode(nodeDefaults, group, own, g !== null && raw.color !== void 0);
1643
+ for (const [p, v] of Object.entries(visNodeRow(merged, shape, range, site))) {
1156
1644
  node.put(p, i, v);
1157
1645
  }
1158
1646
  }
@@ -1160,26 +1648,13 @@ function visStyles(snapshot, src, context) {
1160
1648
  if (Object.keys(declaredNode).length > 0) {
1161
1649
  nodeRules.push(rule("node.vis.defaults", "node", "defaults", "declared", { all: true }, declaredNode));
1162
1650
  }
1163
- let k = 0;
1164
- for (const [g, layer] of groupLayers) {
1165
- const set = paletteRows.get(g) ?? visValues(layer, "node", ruleSite("node"), true);
1166
- if (Object.keys(set).length === 0) {
1167
- continue;
1168
- }
1169
- const key = `group.${String(k)}`;
1170
- nodeColumns.set(
1171
- key,
1172
- Array.from({ length: n }, (_v, i) => groupOf(i) === g ? true : null)
1173
- );
1174
- const origin = paletteRows.has(g) ? "tool" : "declared";
1175
- const r = rule(`node.vis.group.${String(k++)}`, "node", "group", origin, { has: { style: key } }, set);
1176
- nodeRules.push({ ...r, facts: { names: [[key, g]] } });
1177
- }
1651
+ visGroupRules(n, groupOf, groupLayers, paletteRows, ruleSite("node"), nodeRules, nodeColumns);
1178
1652
  const toolNode = toolDefaults("vis-network")?.node;
1179
1653
  const borderOf = (i) => node.values.borderColor?.[i] ?? toolNode?.borderColor?.value ?? "#2b7ce9";
1180
- const edge = visEdges(snapshot, visLayer(options.edges, "edge"), borderOf, notes, context);
1654
+ const geometry = visGeometry(snapshot, node.values, shapes);
1655
+ const edge = visEdges(snapshot, visLayer(options.edges, "edge"), borderOf, geometry, notes, context);
1181
1656
  const values = { node: node.values, edge: edge.values };
1182
- exactFromBlock(snapshot, src.block, values, VIS_WRITTEN);
1657
+ exactFromBlock(snapshot, src.block, values, visWritten(snapshot, values.edge));
1183
1658
  return {
1184
1659
  canonical: true,
1185
1660
  dialect: "vis",
@@ -1196,6 +1671,202 @@ function visStyles(snapshot, src, context) {
1196
1671
  }
1197
1672
  };
1198
1673
  }
1674
+ function visShapeOf(layer) {
1675
+ return typeof layer.shape === "string" ? layer.shape : null;
1676
+ }
1677
+ function visNodeValueRange(n, groupOf, rawRecords, groupLayers, nodeDefaults) {
1678
+ return visValueRange(n, (i) => {
1679
+ const g = groupOf(i);
1680
+ const own = visLayer(rawRecords(i), "node").value;
1681
+ const value = own ?? (g === null ? void 0 : groupLayers.get(g)?.value) ?? nodeDefaults.value;
1682
+ return typeof value === "number" && Number.isFinite(value) ? value : null;
1683
+ });
1684
+ }
1685
+ function visMergedNode(nodeDefaults, group, own, ownColorInGroup) {
1686
+ const merged = { ...nodeDefaults, ...group, ...own };
1687
+ if (ownColorInGroup) {
1688
+ merged.fill ??= VIS_NODE_FILL;
1689
+ merged.border ??= VIS_NODE_BORDER;
1690
+ }
1691
+ return merged;
1692
+ }
1693
+ function visNodeRow(merged, shape, range, site) {
1694
+ const sized = VIS_SIZED.has(shape);
1695
+ const row = visValues(merged, "node", site, sized);
1696
+ const shaped = sized ? visSizedShape(merged, shape, visRadius(merged, range, site), site) : visFitShape(merged, shape);
1697
+ if (sized && merged.label !== void 0) {
1698
+ const size = visLabelScaled(merged, range) ?? (typeof merged.fontSize === "number" ? merged.fontSize : VIS_FONT_SIZE);
1699
+ const drop = typeof row.labelRuns === "string" ? visRunsDrop(row.labelRuns, size) : 0;
1700
+ const below = typeof row.labelOffsetY === "number" ? row.labelOffsetY : 0;
1701
+ row.labelOffsetY = below + drop + visBelowGap(size);
1702
+ }
1703
+ for (const p of ["labelOffsetX", "labelOffsetY"]) {
1704
+ const [a, b] = [row[p], shaped[p]];
1705
+ if (typeof a === "number" && typeof b === "number") {
1706
+ shaped[p] = a + b;
1707
+ }
1708
+ }
1709
+ Object.assign(row, shaped);
1710
+ const labelSize = visLabelScaled(merged, range);
1711
+ if (labelSize !== null) {
1712
+ row.labelSize = labelSize;
1713
+ }
1714
+ return row;
1715
+ }
1716
+ function visGroupRules(n, groupOf, groupLayers, paletteRows, site, rules, columns) {
1717
+ let k = 0;
1718
+ for (const [g, layer] of groupLayers) {
1719
+ const set = paletteRows.get(g) ?? visValues(layer, "node", site, true);
1720
+ if (Object.keys(set).length === 0) {
1721
+ continue;
1722
+ }
1723
+ const key = `group.${String(k)}`;
1724
+ columns.set(
1725
+ key,
1726
+ Array.from({ length: n }, (_v, i) => groupOf(i) === g ? true : null)
1727
+ );
1728
+ const origin = paletteRows.has(g) ? "tool" : "declared";
1729
+ const r = rule(`node.vis.group.${String(k++)}`, "node", "group", origin, { has: { style: key } }, set);
1730
+ rules.push({ ...r, facts: { names: [[key, g]] } });
1731
+ }
1732
+ }
1733
+ function visSizedShape(merged, shape, radius, site) {
1734
+ const row = { width: 2 * radius, height: 2 * radius };
1735
+ if (shape === "hexagon") {
1736
+ row.height = Math.sqrt(3) * radius;
1737
+ row.labelOffsetY = (2 - Math.sqrt(3)) * radius / 2;
1738
+ }
1739
+ Object.assign(row, visImage(merged, shape, { width: 2 * radius, height: 2 * radius }));
1740
+ if (shape === "icon") {
1741
+ Object.assign(row, { shape: "none" }, visIcon(merged, site("glyphColor")));
1742
+ }
1743
+ if (shape === "triangleDown") {
1744
+ row.shape = "polygon";
1745
+ row.shapePoints = "-1,1 0,-1 1,1";
1746
+ }
1747
+ return row;
1748
+ }
1749
+ function visFitShape(merged, shape) {
1750
+ const row = visLabelFit(merged, shape);
1751
+ if (merged.margin === 0 && (shape === "box" || shape === "circle" || shape === "database")) {
1752
+ row.visible = false;
1753
+ }
1754
+ if (merged.valign === "top" || merged.valign === "bottom") {
1755
+ row.labelPosition = `inside-${merged.valign}`;
1756
+ } else if (shape === "database") {
1757
+ const m = merged.margin;
1758
+ const top = isJsonObject(m) ? m.top : m;
1759
+ row.labelPosition = "inside-top";
1760
+ row.labelOffsetY = typeof top === "number" && Number.isFinite(top) && top >= 0 ? top : VIS_MARGIN;
1761
+ }
1762
+ if (shape === "box" && typeof merged.borderRadius === "number" && Number.isFinite(merged.borderRadius)) {
1763
+ row.cornerRadius = Math.max(0, merged.borderRadius);
1764
+ }
1765
+ return row;
1766
+ }
1767
+ function visLabelFit(layer, shape) {
1768
+ const fit = VIS_LABEL_FIT.get(shape);
1769
+ if (fit === void 0) {
1770
+ return {};
1771
+ }
1772
+ const length = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : null;
1773
+ const fontSize = length(layer.fontSize) ?? VIS_FONT_SIZE;
1774
+ const lines = typeof layer.label === "string" ? Math.max(1, layer.label.split("\n").length) : 1;
1775
+ const minW = length(layer.widthMin) ?? 0;
1776
+ const minH = length(layer.heightMin) ?? 0;
1777
+ let padX;
1778
+ let padY;
1779
+ let offset = {};
1780
+ if (fit.ellipse) {
1781
+ padX = Math.max(lines * fontSize, minH) / 2;
1782
+ padY = padX;
1783
+ } else {
1784
+ ({ padX, padY, offset } = visMarginPads(layer.margin, fit.square));
1785
+ }
1786
+ const empty = typeof layer.label !== "string" || layer.label === "";
1787
+ const [boxW, boxH] = empty ? [Math.max(minW, 14), Math.max(minH, 14)] : [minW, minH];
1788
+ if (empty && fit.ellipse) {
1789
+ padX = boxH / 2;
1790
+ padY = padX;
1791
+ }
1792
+ const row = {
1793
+ ...offset,
1794
+ labelFit: "bounds",
1795
+ labelPaddingX: padX,
1796
+ labelPaddingY: padY,
1797
+ width: boxW > 0 ? boxW + 2 * padX : 0,
1798
+ height: boxH > 0 ? boxH + 2 * padY : 0
1799
+ };
1800
+ if (fit.square) {
1801
+ row.labelFitSquare = true;
1802
+ }
1803
+ return row;
1804
+ }
1805
+ function visMarginPads(m, square) {
1806
+ const length = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : null;
1807
+ const side = (key) => (isJsonObject(m) ? length(m[key]) : length(m)) ?? VIS_MARGIN;
1808
+ const offset = {};
1809
+ if (!square && side("left") !== side("right")) {
1810
+ offset.labelOffsetX = (side("left") - side("right")) / 2;
1811
+ }
1812
+ if (!square && side("top") !== side("bottom")) {
1813
+ offset.labelOffsetY = (side("top") - side("bottom")) / 2;
1814
+ }
1815
+ return { padX: (side("left") + side("right")) / 2, padY: (side("top") + side("bottom")) / 2, offset };
1816
+ }
1817
+ function visLabelScaled(layer, range) {
1818
+ const value = finiteValue(layer.value);
1819
+ const label = layer.scalingLabel;
1820
+ if (value === null || range === null || !isJsonObject(label) || label.enabled !== true) {
1821
+ return null;
1822
+ }
1823
+ const min = typeof label.min === "number" ? label.min : 14;
1824
+ const max = typeof label.max === "number" ? label.max : 30;
1825
+ return visScaled(value, range, min, max);
1826
+ }
1827
+ const VIS_SIZE = 25;
1828
+ const VIS_SCALING = [10, 30];
1829
+ function visValueRange(n, valueOf) {
1830
+ let min = Infinity;
1831
+ let max = -Infinity;
1832
+ for (let i = 0; i < n; i++) {
1833
+ const v = valueOf(i);
1834
+ if (v !== null) {
1835
+ min = Math.min(min, v);
1836
+ max = Math.max(max, v);
1837
+ }
1838
+ }
1839
+ return min <= max ? [min, max] : null;
1840
+ }
1841
+ const finiteValue = (value) => typeof value === "number" && Number.isFinite(value) ? value : null;
1842
+ function visScaled(value, range, min, max) {
1843
+ const [lo, hi] = range;
1844
+ const scale = hi === lo ? 0.5 : Math.max(0, (value - lo) / (hi - lo));
1845
+ return min + scale * (max - min);
1846
+ }
1847
+ const VIS_EDGE_SCALING = [1, 15];
1848
+ function visEdgeWidth(layer, defaults, range, site) {
1849
+ if (range === null) {
1850
+ return {};
1851
+ }
1852
+ const value = finiteValue(layer.value);
1853
+ if (value !== null) {
1854
+ const min = typeof layer.scalingMin === "number" ? layer.scalingMin : VIS_EDGE_SCALING[0];
1855
+ const max = typeof layer.scalingMax === "number" ? layer.scalingMax : VIS_EDGE_SCALING[1];
1856
+ return { width: visScaled(value, range, min, max) };
1857
+ }
1858
+ return { width: (defaults.width === void 0 ? null : canonNumber(defaults.width, site("width"))) ?? 1 };
1859
+ }
1860
+ function visRadius(layer, range, site) {
1861
+ const value = finiteValue(layer.value);
1862
+ if (value !== null && range !== null) {
1863
+ const min = typeof layer.scalingMin === "number" ? layer.scalingMin : VIS_SCALING[0];
1864
+ const max = typeof layer.scalingMax === "number" ? layer.scalingMax : VIS_SCALING[1];
1865
+ return visScaled(value, range, min, max);
1866
+ }
1867
+ const size = layer.size === void 0 ? null : canonNumber(layer.size, site("width"));
1868
+ return size ?? VIS_SIZE;
1869
+ }
1199
1870
  function visGroupDefs(src, options) {
1200
1871
  if (isJsonObject(options.groups)) {
1201
1872
  return options.groups;
@@ -1221,15 +1892,38 @@ function visGroupLayers(n, groupOf, groupDefs) {
1221
1892
  }
1222
1893
  return { groupLayers, paletteRows };
1223
1894
  }
1224
- function visEdges(snapshot, edgeDefaults, borderOf, notes, context) {
1895
+ function visOwnGroup(groupLayers, groupDefs) {
1896
+ const cache = /* @__PURE__ */ new Map();
1897
+ return (g, own) => {
1898
+ const whole = groupLayers.get(g) ?? {};
1899
+ const def = Object.hasOwn(groupDefs, g) ? groupDefs[g] : null;
1900
+ const skip = Object.keys(own).filter(
1901
+ (k) => k !== "font" && (isJsonObject(def) ? Object.hasOwn(def, k) : k === "color")
1902
+ );
1903
+ if (skip.length === 0) {
1904
+ return whole;
1905
+ }
1906
+ const key = `${g}\0${skip.join("\0")}`;
1907
+ let layer = cache.get(key);
1908
+ if (layer === void 0) {
1909
+ layer = isJsonObject(def) ? visLayer(Object.fromEntries(Object.entries(def).filter(([k]) => !skip.includes(k))), "node") : {};
1910
+ cache.set(key, layer);
1911
+ }
1912
+ return layer;
1913
+ };
1914
+ }
1915
+ function visEdges(snapshot, edgeDefaults, borderOf, geometry, notes, context) {
1225
1916
  const m = snapshot.edgeCount;
1226
1917
  const edge = valuesOf(m);
1227
1918
  const edgeRecords = elementRecords(snapshot, "edge");
1228
1919
  const inherited = new Array(m).fill(null);
1229
1920
  let inheriting = 0;
1921
+ const range = visValueRange(m, (e) => finiteValue({ ...edgeDefaults, ...edgeRecords(e) }.value));
1922
+ let roundCaps = false;
1230
1923
  for (let e = 0; e < m; e++) {
1231
1924
  const own = edgeRecords(e);
1232
- const merged = { ...edgeDefaults, ...own };
1925
+ const bridged = own.dashes === void 0 && Array.isArray(edgeDefaults.dashes) ? { dashes: true } : {};
1926
+ const merged = { ...edgeDefaults, ...own, ...bridged };
1233
1927
  const site = (property) => ({
1234
1928
  notes,
1235
1929
  target: "edge",
@@ -1237,24 +1931,49 @@ function visEdges(snapshot, edgeDefaults, borderOf, notes, context) {
1237
1931
  element: e,
1238
1932
  budget: context.budget
1239
1933
  });
1240
- const vals = visValues(merged, "edge", site, true);
1934
+ const [s, t] = [snapshot.edgeSource(e), snapshot.edgeTarget(e)];
1935
+ const vals = {
1936
+ ...visValues(merged, "edge", site, true),
1937
+ ...visEdgeWidth(merged, edgeDefaults, range, site),
1938
+ ...visRoute(edgeDefaults, own, s, t, geometry),
1939
+ ...visEdgeLabel(merged, range, geometry.at(s), geometry.at(t))
1940
+ };
1941
+ roundCaps ||= merged.hidden !== true && ![void 0, false, "false"].includes(merged.dashes);
1942
+ const band = roundCaps && isJsonObject(merged.background) ? visBandStyle(merged.background, true) : null;
1943
+ if (band !== null) {
1944
+ vals.outlineStyle = band;
1945
+ }
1946
+ const from = visEdgeInherit(vals, own.inherit ?? edgeDefaults.inherit ?? "from", borderOf, s, t);
1241
1947
  for (const [p, v] of Object.entries(vals)) {
1242
1948
  edge.put(p, e, v);
1243
1949
  }
1244
- const inherit = own.inherit ?? edgeDefaults.inherit ?? "from";
1245
- if (inherit === false || inherit === "false") {
1246
- if (vals.color === void 0) {
1247
- edge.put("color", e, VIS_EDGE_COLOR);
1248
- }
1249
- continue;
1250
- }
1251
- if (inherit === "both") {
1252
- notes.add(STYLE_ISSUE.GRADIENT, "edge", "color", { sample: "inherit both", element: e });
1950
+ if (from !== null) {
1951
+ inherited[e] = from;
1952
+ inheriting++;
1253
1953
  }
1254
- inherited[e] = borderOf(inherit === "to" ? snapshot.edgeTarget(e) : snapshot.edgeSource(e));
1255
- inheriting++;
1256
1954
  }
1257
1955
  context.budget.spend("edge", m);
1956
+ const { rules, columns } = visEdgeRules(edgeDefaults, notes, inherited, inheriting);
1957
+ return { values: edge.values, rules, columns };
1958
+ }
1959
+ function visEdgeInherit(vals, inherit, borderOf, s, t) {
1960
+ const inherits = inherit !== false && inherit !== "false";
1961
+ if (inherits) {
1962
+ delete vals.color;
1963
+ }
1964
+ if (inherit === "both") {
1965
+ vals.gradientKind = "linear";
1966
+ vals.gradientColors = `${String(borderOf(s))} ${String(borderOf(t))}`;
1967
+ }
1968
+ if (!inherits) {
1969
+ if (vals.color === void 0) {
1970
+ vals.color = VIS_EDGE_COLOR;
1971
+ }
1972
+ return null;
1973
+ }
1974
+ return borderOf(inherit === "to" ? t : s);
1975
+ }
1976
+ function visEdgeRules(edgeDefaults, notes, inherited, inheriting) {
1258
1977
  const edgeRules = [];
1259
1978
  const edgeColumns = /* @__PURE__ */ new Map();
1260
1979
  const declaredEdge = visValues(edgeDefaults, "edge", (property) => ({ notes, target: "edge", property }), true);
@@ -1273,16 +1992,273 @@ function visEdges(snapshot, edgeDefaults, borderOf, notes, context) {
1273
1992
  facts: { elements: inheriting, reason: "SOURCE_NODE_COLOR" }
1274
1993
  });
1275
1994
  }
1276
- return { values: edge.values, rules: edgeRules, columns: edgeColumns };
1995
+ return { rules: edgeRules, columns: edgeColumns };
1996
+ }
1997
+ function visGeometry(snapshot, nodeValues, shapes) {
1998
+ const whole = (v) => {
1999
+ if (typeof v === "string") {
2000
+ return Number.parseInt(v, 10);
2001
+ }
2002
+ return typeof v === "number" && Number.isFinite(v) ? Math.trunc(v) : Number.NaN;
2003
+ };
2004
+ const [xs, ys] = [cells(snapshot, "node", "x"), cells(snapshot, "node", "y")];
2005
+ const num = (v) => typeof v === "number" && v > 0 ? v : null;
2006
+ return {
2007
+ at: (i) => {
2008
+ const p = [whole(xs?.(i)), whole(ys?.(i))];
2009
+ return Number.isNaN(p[0]) || Number.isNaN(p[1]) ? null : p;
2010
+ },
2011
+ box: (i) => {
2012
+ const [w, h] = [num(nodeValues.width?.[i]), num(nodeValues.height?.[i])];
2013
+ const bw = nodeValues.borderWidth?.[i];
2014
+ return w === null || h === null ? null : [w / 2, h / 2, typeof bw === "number" ? bw : 1, shapes[i]];
2015
+ }
2016
+ };
2017
+ }
2018
+ function visSmooth(...layers) {
2019
+ const s = { enabled: true, type: "dynamic", roundness: 0.5, forceDirection: "none" };
2020
+ for (const l of layers) {
2021
+ if (typeof l === "boolean") {
2022
+ s.enabled = l;
2023
+ } else if (isJsonObject(l)) {
2024
+ s.enabled = typeof l.enabled === "boolean" ? l.enabled : s.enabled;
2025
+ s.type = typeof l.type === "string" ? l.type : s.type;
2026
+ s.roundness = typeof l.roundness === "number" && Number.isFinite(l.roundness) ? l.roundness : s.roundness;
2027
+ s.forceDirection = l.forceDirection ?? s.forceDirection;
2028
+ }
2029
+ }
2030
+ return s;
2031
+ }
2032
+ function visEdgeLabel(merged, range, a, b) {
2033
+ const row = {};
2034
+ const size = visLabelScaled(merged, range);
2035
+ if (size !== null) {
2036
+ row.labelSize = size;
2037
+ }
2038
+ const turn = visLabelTurn(merged.fontAlign, a, b);
2039
+ if (turn !== null) {
2040
+ row.labelRotation = turn;
2041
+ }
2042
+ return row;
2043
+ }
2044
+ function visLabelTurn(align, a, b) {
2045
+ if (typeof align !== "string" || align === "horizontal" || a === null || b === null) {
2046
+ return null;
2047
+ }
2048
+ const [dx, dy] = [a[0] - b[0], a[1] - b[1]];
2049
+ let angle = Math.atan2(dy, dx);
2050
+ if (angle < -1 && dx < 0 || angle > 0 && dx < 0) {
2051
+ angle += Math.PI;
2052
+ }
2053
+ const degrees = Math.round(angle * 180 / Math.PI * 1e4) / 1e4;
2054
+ return degrees < 0 ? degrees + 360 : degrees;
2055
+ }
2056
+ function visStaticVia(from, to, smooth) {
2057
+ const f = smooth.roundness;
2058
+ const [fx, fy] = from;
2059
+ const [tx, ty] = to;
2060
+ const dx = Math.abs(fx - tx);
2061
+ const dy = Math.abs(fy - ty);
2062
+ const step = f * Math.max(dx, dy);
2063
+ const sx = step * (Math.sign(tx - fx) || 1);
2064
+ const sy = step * (Math.sign(ty - fy) || -1);
2065
+ const backX = (1 - f) * dx * (Math.sign(fx - tx) || 1);
2066
+ const backY = (1 - f) * dy * (Math.sign(fy - ty) || 1);
2067
+ switch (smooth.type) {
2068
+ case "discrete":
2069
+ return visDiscreteVia(from, [fx + sx, fy + sy], dx, dy, f);
2070
+ case "diagonalCross":
2071
+ return [fx + sx, fy + sy];
2072
+ case "straightCross":
2073
+ return dx <= dy ? [tx, ty + backY] : [tx + backX, ty];
2074
+ case "horizontal":
2075
+ return [tx + backX, fy];
2076
+ case "vertical":
2077
+ return [fx, ty + backY];
2078
+ case "curvedCW":
2079
+ return visCurvedVia(from, to, f, f * 0.5 + 0.5);
2080
+ case "curvedCCW":
2081
+ return visCurvedVia(from, to, f, -f * 0.5 + 0.5);
2082
+ default:
2083
+ return dx <= dy ? [fx + Math.sign(sx) * Math.min(step, dx), fy + sy] : [fx + sx, fy + Math.sign(sy) * Math.min(step, dy)];
2084
+ }
2085
+ }
2086
+ function visDiscreteVia(from, diagonal, dx, dy, f) {
2087
+ if (dx <= dy) {
2088
+ return [dx < f * dy ? from[0] : diagonal[0], diagonal[1]];
2089
+ }
2090
+ return [diagonal[0], dy < f * dx ? from[1] : diagonal[1]];
2091
+ }
2092
+ function visCurvedVia(from, to, f, turn) {
2093
+ const ex = to[0] - from[0];
2094
+ const ey = from[1] - to[1];
2095
+ const r = (f * 0.5 + 0.5) * Math.hypot(ex, ey);
2096
+ const angle = (Math.atan2(ey, ex) + turn * Math.PI) % (2 * Math.PI);
2097
+ return [from[0] + r * Math.sin(angle), from[1] + r * Math.cos(angle)];
2098
+ }
2099
+ function visCubicVia(from, to, smooth) {
2100
+ const [dx, dy] = [from[0] - to[0], from[1] - to[1]];
2101
+ const r = smooth.roundness;
2102
+ const force = smooth.forceDirection;
2103
+ const across = (Math.abs(dx) > Math.abs(dy) || force === true || force === "horizontal") && force !== "vertical";
2104
+ return across ? [
2105
+ [from[0] - r * dx, from[1]],
2106
+ [to[0] + r * dx, to[1]]
2107
+ ] : [
2108
+ [from[0], from[1] - r * dy],
2109
+ [to[0], to[1] + r * dy]
2110
+ ];
2111
+ }
2112
+ function alongAcross(a, b, p) {
2113
+ const [dx, dy] = [b[0] - a[0], b[1] - a[1]];
2114
+ const [qx, qy] = [p[0] - a[0], p[1] - a[1]];
2115
+ const l2 = dx * dx + dy * dy;
2116
+ return `${fraction((qx * dx + qy * dy) / l2)},${fraction((dy * qx - dx * qy) / l2)}`;
2117
+ }
2118
+ const fraction = (v) => String(Math.round(v * 1e4) / 1e4 || 0);
2119
+ function visRoute(defaults, own, s, t, g) {
2120
+ if (s === t) {
2121
+ return visLoop(defaults, own, g.box(s));
2122
+ }
2123
+ const smooth = visSmooth(defaults.smooth, own.smooth);
2124
+ const [a, b] = [g.at(s), g.at(t)];
2125
+ if (!smooth.enabled || smooth.type === "dynamic" || a === null || b === null || a[0] === b[0] && a[1] === b[1]) {
2126
+ return {};
2127
+ }
2128
+ const controls = smooth.type === "cubicBezier" ? visCubicVia(a, b, smooth) : [visStaticVia(a, b, smooth)];
2129
+ return { curved: true, bendCurve: "bezier", bends: controls.map((p) => alongAcross(a, b, p)).join(" ") };
2130
+ }
2131
+ function visLoop(defaults, own, box) {
2132
+ if (box === null) {
2133
+ return {};
2134
+ }
2135
+ const field = (layer, key) => isJsonObject(layer.selfReference) ? layer.selfReference[key] : void 0;
2136
+ const pick = (...vs) => vs.find((v) => typeof v === "number" && Number.isFinite(v)) ?? null;
2137
+ const radius = pick(field(own, "size"), own.selfReferenceSize, field(defaults, "size"), defaults.selfReferenceSize) ?? 20;
2138
+ const angle = pick(field(own, "angle"), field(defaults, "angle")) ?? Math.PI / 4;
2139
+ const [hw, hh] = box;
2140
+ const reach = visToBorder(box, angle);
2141
+ const [cx, cy] = [Math.cos(angle) * reach, Math.sin(angle) * reach];
2142
+ const behind = [field(own, "renderBehindTheNode"), field(defaults, "renderBehindTheNode")].find(
2143
+ (v) => typeof v === "boolean"
2144
+ );
2145
+ if (behind === false) {
2146
+ return visFrontArc(cx, cy, radius, angle, box);
2147
+ }
2148
+ const round = box[3] === "dot" || box[3] === "circle" || box[3] === "circularImage";
2149
+ if (reach + (round ? hw : Math.hypot(hw, hh)) < radius) {
2150
+ return visRing(cx, cy, radius, angle, box);
2151
+ }
2152
+ const corners = [];
2153
+ for (let k = 0; k <= 4; k++) {
2154
+ const a = angle + Math.PI + k % 4 * Math.PI / 2;
2155
+ const [x, y] = [cx + Math.SQRT2 * radius * Math.cos(a), cy + Math.SQRT2 * radius * Math.sin(a)];
2156
+ corners.push(`${fraction(x / hw)},${fraction(y / hh)}`);
2157
+ }
2158
+ return { curved: true, bendCurve: "midpoints", bends: corners.join(" ") };
2159
+ }
2160
+ const VIS_RING_STEPS = 96;
2161
+ function visRing(cx, cy, radius, angle, box) {
2162
+ const [hw, hh] = box;
2163
+ const points = [];
2164
+ for (let k = 0; k <= VIS_RING_STEPS; k++) {
2165
+ const a = angle + Math.PI + 2 * Math.PI * (k % VIS_RING_STEPS) / VIS_RING_STEPS;
2166
+ points.push(`${fraction((cx + radius * Math.cos(a)) / hw)},${fraction((cy + radius * Math.sin(a)) / hh)}`);
2167
+ }
2168
+ return { curved: false, bends: points.join(" ") };
2169
+ }
2170
+ function visFrontArc(cx, cy, radius, angle, box) {
2171
+ const [x, y] = [cx, -cy];
2172
+ const search = (direction) => {
2173
+ let [low, high] = [angle, angle + Math.PI];
2174
+ let pos = [x, y];
2175
+ for (let iteration = 0; low <= high && iteration < 10; iteration++) {
2176
+ const middle = (low + high) * 0.5;
2177
+ const turn = middle * 2 * Math.PI;
2178
+ pos = [x + radius * Math.cos(turn), y - radius * Math.sin(turn)];
2179
+ const difference = visToBorder(box, Math.atan2(-pos[1], -pos[0])) - Math.hypot(pos[0], pos[1]);
2180
+ if (Math.abs(difference) < 0.05) {
2181
+ break;
2182
+ }
2183
+ if (difference > 0 === direction > 0) {
2184
+ low = middle;
2185
+ } else {
2186
+ high = middle;
2187
+ }
2188
+ }
2189
+ return pos;
2190
+ };
2191
+ const [from, to] = [search(-1), search(1)];
2192
+ const start = Math.atan2(from[1] - y, from[0] - x);
2193
+ let end = Math.atan2(to[1] - y, to[0] - x);
2194
+ if (end < start) {
2195
+ end += 2 * Math.PI;
2196
+ }
2197
+ const [hw, hh] = box;
2198
+ const steps = Math.max(2, Math.ceil((end - start) / (2 * Math.PI) * VIS_RING_STEPS));
2199
+ const points = [];
2200
+ for (let k = 0; k <= steps; k++) {
2201
+ const a = start + (end - start) * k / steps;
2202
+ points.push(`${fraction((x + radius * Math.cos(a)) / hw)},${fraction(-(y + radius * Math.sin(a)) / hh)}`);
2203
+ }
2204
+ return { curved: false, bends: points.join(" ") };
2205
+ }
2206
+ function visToBorder(box, angle) {
2207
+ const [hw, hh, bw, shape] = box;
2208
+ if (shape === "dot" || shape === "circle" || shape === "circularImage") {
2209
+ return hw;
2210
+ }
2211
+ if (shape === "ellipse") {
2212
+ return hw * hh / Math.hypot(Math.sin(angle) * hw, Math.cos(angle) * hh);
2213
+ }
2214
+ return Math.min(Math.abs(hw / Math.cos(angle)), Math.abs(hh / Math.sin(angle))) + bw;
1277
2215
  }
1278
2216
  const VIS_KEYS = {
1279
- node: ["color", "shape", "size", "borderWidth", "opacity", "hidden", "label", "title", "font"],
1280
- edge: ["color", "width", "dashes", "arrows", "hidden", "label", "title", "font"]
2217
+ node: [
2218
+ "color",
2219
+ "shape",
2220
+ "size",
2221
+ "value",
2222
+ "scaling",
2223
+ "borderWidth",
2224
+ "opacity",
2225
+ "hidden",
2226
+ "label",
2227
+ "title",
2228
+ "font",
2229
+ "margin",
2230
+ "widthConstraint",
2231
+ "heightConstraint",
2232
+ "image",
2233
+ "brokenImage",
2234
+ "imagePadding",
2235
+ "icon",
2236
+ "shapeProperties"
2237
+ ],
2238
+ edge: [
2239
+ "color",
2240
+ "width",
2241
+ "value",
2242
+ "scaling",
2243
+ "dashes",
2244
+ "arrows",
2245
+ "hidden",
2246
+ "label",
2247
+ "title",
2248
+ "font",
2249
+ "background",
2250
+ "smooth",
2251
+ "selfReference",
2252
+ "selfReferenceSize",
2253
+ "physics",
2254
+ "widthConstraint"
2255
+ ]
1281
2256
  };
1282
- function nodeRecords(snapshot) {
1283
- return elementRecords(snapshot, "node");
1284
- }
1285
2257
  function elementRecords(snapshot, target) {
2258
+ const raw = elementRaw(snapshot, target);
2259
+ return (i) => visLayer(raw(i), target);
2260
+ }
2261
+ function elementRaw(snapshot, target) {
1286
2262
  const readers = VIS_KEYS[target].map((name) => [name, cells(snapshot, target, name)]).filter((x) => x[1] !== null);
1287
2263
  return (i) => {
1288
2264
  const record = {};
@@ -1292,7 +2268,7 @@ function elementRecords(snapshot, target) {
1292
2268
  record[name] = v;
1293
2269
  }
1294
2270
  }
1295
- return visLayer(record, target);
2271
+ return record;
1296
2272
  };
1297
2273
  }
1298
2274
  function rule(id, target, role, origin, where, set) {
@@ -1355,10 +2331,44 @@ const visSize = (want) => {
1355
2331
  const shape = typeof s === "string" ? visShape(s)[0] : "ellipse";
1356
2332
  return VIS_SIZED.has(shape) ? oneSize(want) : null;
1357
2333
  };
2334
+ const visShapeBack = (want) => {
2335
+ const s = want("shape");
2336
+ return typeof s === "string" ? visShape(s)[0] : "ellipse";
2337
+ };
2338
+ const visShapeFactBack = (property) => (want) => {
2339
+ const shape = visShapeBack(want);
2340
+ const size = visSize(want);
2341
+ if (shape === "hexagon" && typeof size === "number") {
2342
+ return property === "height" ? Math.sqrt(3) * size / 2 : (2 - Math.sqrt(3)) * size / 4;
2343
+ }
2344
+ return property === "labelOffsetY" && shape === "database" ? VIS_MARGIN : null;
2345
+ };
2346
+ const visFitBack = (property) => (want) => {
2347
+ const s = want("shape");
2348
+ const shape = typeof s === "string" ? visShape(s)[0] : "ellipse";
2349
+ return visLabelFit({ fontSize: want("labelSize"), label: want("label") }, shape)[property] ?? null;
2350
+ };
2351
+ function visWritten(snapshot, edgeValues) {
2352
+ const loop = (property) => (want, i) => snapshot.edgeSource(i) === snapshot.edgeTarget(i) ? edgeValues[property]?.[i] ?? null : want(property);
2353
+ return {
2354
+ node: VIS_WRITTEN.node,
2355
+ edge: { ...VIS_WRITTEN.edge, bends: loop("bends"), bendCurve: loop("bendCurve"), curved: loop("curved") }
2356
+ };
2357
+ }
1358
2358
  const VIS_WRITTEN = {
1359
2359
  node: {
1360
- width: visSize,
1361
- height: visSize,
2360
+ width: (want) => visSize(want) ?? visFitBack("width")(want),
2361
+ height: (want) => visShapeFactBack("height")(want) ?? visSize(want) ?? visFitBack("height")(want),
2362
+ labelOffsetY: visShapeFactBack("labelOffsetY"),
2363
+ labelFit: visFitBack("labelFit"),
2364
+ labelPaddingX: visFitBack("labelPaddingX"),
2365
+ labelPaddingY: visFitBack("labelPaddingY"),
2366
+ labelFitSquare: visFitBack("labelFitSquare"),
2367
+ // the writer writes hex colors, whose alpha vis-network's node opacity replaces, the border's too
2368
+ borderOpacity: (want) => {
2369
+ const opacity = want("opacity");
2370
+ return typeof opacity === "number" ? opacity : want("borderOpacity");
2371
+ },
1362
2372
  shape: (want) => {
1363
2373
  const s = want("shape");
1364
2374
  if (typeof s !== "string") {
@@ -1366,6 +2376,17 @@ const VIS_WRITTEN = {
1366
2376
  }
1367
2377
  const site = { notes: new StyleNotes(), target: "node", property: "shape" };
1368
2378
  return canonEnum("shape", visShape(s)[0], "vis", site);
2379
+ },
2380
+ labelPosition: (want) => {
2381
+ const s = want("shape");
2382
+ if (typeof s !== "string") {
2383
+ return null;
2384
+ }
2385
+ const shape = visShape(s)[0];
2386
+ if (shape === "database") {
2387
+ return "inside-top";
2388
+ }
2389
+ return VIS_SIZED.has(shape) ? "bottom" : "center";
1369
2390
  }
1370
2391
  },
1371
2392
  edge: {
@@ -1374,7 +2395,11 @@ const VIS_WRITTEN = {
1374
2395
  if (s === null) {
1375
2396
  return null;
1376
2397
  }
1377
- return s === "solid" ? "solid" : "dashed";
2398
+ if (s === "solid") {
2399
+ return "solid";
2400
+ }
2401
+ const width = want("width");
2402
+ return visDashStyle([5, 5], typeof width === "number" ? width : 1, true);
1378
2403
  },
1379
2404
  targetArrow: (want) => arrowBack(want("targetArrow")),
1380
2405
  sourceArrow: (want) => arrowBack(want("sourceArrow"))
@@ -1406,8 +2431,8 @@ const NATIVE = {
1406
2431
  edge: cyjsProperties(CYJS_EDGE_PROPERTIES, ["curved", "labelItalic", "visible"])
1407
2432
  },
1408
2433
  graphology: {
1409
- node: ["fill", "fillOpacity", "width", "height", "label", "visible"],
1410
- edge: ["color", "opacity", "width", "label", "visible"]
2434
+ node: ["fill", "fillOpacity", "width", "height", "label"],
2435
+ edge: ["color", "opacity", "width", "label"]
1411
2436
  },
1412
2437
  vis: {
1413
2438
  node: [
@@ -1797,18 +2822,27 @@ function writeGraphology$1(out, input, approximated, replaced) {
1797
2822
  writeKey(
1798
2823
  table,
1799
2824
  "size",
1800
- target === "node" ? nodeSizes(p("node", "width"), p("node", "height"), approximated) : p("edge", "width"),
2825
+ target === "node" ? nodeSizes(p("node", "width"), p("node", "height"), approximated).map(
2826
+ (d) => d === null ? null : d / 2
2827
+ ) : (
2828
+ // sigma draws an edge half as wide as its size (readSigmaRow)
2829
+ p("edge", "width").map((w) => typeof w === "number" ? w * 2 : w)
2830
+ ),
1801
2831
  replaced
1802
2832
  );
1803
2833
  writeKey(table, "label", p(target, "label"), replaced);
1804
- writeKey(
1805
- table,
1806
- "hidden",
1807
- p(target, "visible").map((v) => v === false ? true : null),
1808
- replaced
1809
- );
1810
2834
  }
1811
2835
  }
2836
+ function keepScaled(table, sizes, replaced) {
2837
+ const value = table.get("value");
2838
+ if (value === null) {
2839
+ return;
2840
+ }
2841
+ const scaling = sizes.map(
2842
+ (v, i) => typeof v !== "number" || typeof plainCell(value.value(i)) !== "number" ? null : { min: v, max: v }
2843
+ );
2844
+ writeKey(table, "scaling", scaling, replaced);
2845
+ }
1812
2846
  function writeVis$1(out, input, approximated, replaced) {
1813
2847
  const p = (target, property) => input.picture(target, property);
1814
2848
  const font = (target) => {
@@ -1861,7 +2895,8 @@ function writeVis$1(out, input, approximated, replaced) {
1861
2895
  );
1862
2896
  const sizes = nodeSizes(p("node", "width"), p("node", "height"), approximated);
1863
2897
  const shapes = p("node", "shape").map((s, i) => {
1864
- const [shape, exact] = typeof s === "string" ? visShape(s) : [null, true];
2898
+ const [written, exact] = typeof s === "string" ? visShape(s) : [null, true];
2899
+ const shape = written === "dot" && s === "ellipse" && sizes[i] === null ? "ellipse" : written;
1865
2900
  if (!exact) {
1866
2901
  approximated.add("node", "shape", s);
1867
2902
  }
@@ -1871,7 +2906,9 @@ function writeVis$1(out, input, approximated, replaced) {
1871
2906
  return shape;
1872
2907
  });
1873
2908
  writeKey(out.nodes, "shape", shapes, replaced);
1874
- writeKey(out.nodes, "size", sizes, replaced);
2909
+ const radii = sizes.map((d) => d === null ? null : d / 2);
2910
+ writeKey(out.nodes, "size", radii, replaced);
2911
+ keepScaled(out.nodes, radii, replaced);
1875
2912
  writeKey(out.nodes, "borderWidth", p("node", "borderWidth"), replaced);
1876
2913
  writeKey(out.nodes, "opacity", p("node", "opacity"), replaced);
1877
2914
  label(out.nodes, "node");
@@ -1892,7 +2929,9 @@ function writeVis$1(out, input, approximated, replaced) {
1892
2929
  }),
1893
2930
  replaced
1894
2931
  );
1895
- writeKey(out.edges, "width", p("edge", "width"), replaced);
2932
+ const widths = p("edge", "width");
2933
+ writeKey(out.edges, "width", widths, replaced);
2934
+ keepScaled(out.edges, widths, replaced);
1896
2935
  writeKey(
1897
2936
  out.edges,
1898
2937
  "dashes",
@@ -2100,6 +3139,8 @@ const GRAPHOLOGY_NODE_KEYS = /* @__PURE__ */ new Set(["key", "attributes"]);
2100
3139
  const GRAPHOLOGY_EDGE_KEYS = /* @__PURE__ */ new Set(["key", "source", "target", "attributes", "undirected"]);
2101
3140
  const GEPHI_NODE_KEYS = /* @__PURE__ */ new Set(["id", "attributes"]);
2102
3141
  const GEPHI_EDGE_KEYS = /* @__PURE__ */ new Set([...GRAPHOLOGY_EDGE_KEYS, "id"]);
3142
+ const GEPHI_NODE_DISPLAY_KEYS = /* @__PURE__ */ new Set(["label", "x", "y", "size", "color"]);
3143
+ const GEPHI_EDGE_DISPLAY_KEYS = /* @__PURE__ */ new Set(["label", "size", "color"]);
2103
3144
  const VIS_SOURCE_KEYS = Object.freeze(["from"]);
2104
3145
  const VIS_TARGET_KEYS = Object.freeze(["to"]);
2105
3146
  const PATH_DIALECTS = /* @__PURE__ */ new Set([
@@ -2147,9 +3188,26 @@ function resolveJsonOptions(options) {
2147
3188
  oboIds,
2148
3189
  typedefs,
2149
3190
  nodesPath,
2150
- edgesPath
3191
+ edgesPath,
3192
+ sigma: sigmaSettingsOption(o.sigmaSettings)
2151
3193
  };
2152
3194
  }
3195
+ function sigmaSettingsOption(value) {
3196
+ if (value === void 0) {
3197
+ return SIGMA_DEFAULT_SETTINGS;
3198
+ }
3199
+ if (!isJsonObject(value)) {
3200
+ throw unsupportedOption("sigmaSettings", value, ["an object of sigma.js settings"]);
3201
+ }
3202
+ const { renderEdgeLabels = false, edgeLabelAnchors = "nodeLabels" } = value;
3203
+ if (typeof renderEdgeLabels !== "boolean") {
3204
+ throw unsupportedOption("sigmaSettings.renderEdgeLabels", renderEdgeLabels, ["true", "false"]);
3205
+ }
3206
+ if (edgeLabelAnchors !== "nodeLabels" && edgeLabelAnchors !== "allNodes") {
3207
+ throw unsupportedOption("sigmaSettings.edgeLabelAnchors", edgeLabelAnchors, ["nodeLabels", "allNodes"]);
3208
+ }
3209
+ return { renderEdgeLabels, edgeLabelAnchors };
3210
+ }
2153
3211
  function pathOption(name, value) {
2154
3212
  if (value === void 0) {
2155
3213
  return null;
@@ -2778,15 +3836,17 @@ class ImportContext {
2778
3836
  * @param structural - the element keys that are not attributes
2779
3837
  * @param element - the element name for issues
2780
3838
  * @param how - `weightFrom`: the weight key to skip in the dict; `plain`: write the element-level keys under their
2781
- * own names, not with the `#element` suffix
3839
+ * own names, not with the `#element` suffix; `dataKeys`: the dict keys written with the `#data` suffix
2782
3840
  * @param how.weightFrom - the weight key to skip in the dict, or null (the default)
2783
3841
  * @param how.plain - write the element-level keys under their own names (default false)
3842
+ * @param how.dataKeys - the dict keys that name an element-level key, written as `<key>#data` (default none)
2784
3843
  */
2785
3844
  writeNested(writer, row, record, dict, structural, element, how = {}) {
2786
- const { weightFrom = null, plain = false } = how;
3845
+ const { weightFrom = null, plain = false, dataKeys } = how;
2787
3846
  for (const key of Object.keys(dict)) {
2788
3847
  if (key !== weightFrom) {
2789
- writer.write(row, key, dict[key], SUFFIX.data, element);
3848
+ const name = dataKeys?.has(key) === true ? `${key}${SUFFIX.data}` : key;
3849
+ writer.write(row, name, dict[key], SUFFIX.data, element);
2790
3850
  }
2791
3851
  }
2792
3852
  for (const key of Object.keys(record)) {
@@ -3776,7 +4836,7 @@ function importGraphology(ctx, root) {
3776
4836
  ctx.writeGraphDict(root.attributes, "attributes");
3777
4837
  const firstNode = nodes.find((n) => isJsonObject(n));
3778
4838
  const gephi = isJsonObject(firstNode) && !hasKey(firstNode, "key") && hasKey(firstNode, "id");
3779
- ctx.styleSource = { dialect: "graphology", block: blockOf(root), gephi };
4839
+ ctx.styleSource = { dialect: "graphology", block: blockOf(root), gephi, sigma: ctx.json.sigma };
3780
4840
  ctx.reportNodeIdFrom("graphology", "the node key");
3781
4841
  ctx.sink.reserve(nodes.length, edges.length);
3782
4842
  importGraphologyNodes(ctx, nodes, gephi);
@@ -3888,7 +4948,8 @@ function pushGraphologyEdge(ctx, record, element, ids, declared, violations) {
3888
4948
  ctx.setEdgeId(ids, edge, idValue);
3889
4949
  ctx.writeNested(ctx.edges, edge, record, attributes, gephi ? GEPHI_EDGE_KEYS : GRAPHOLOGY_EDGE_KEYS, element, {
3890
4950
  weightFrom: ctx.options.weightFrom,
3891
- plain: gephi
4951
+ plain: gephi,
4952
+ dataKeys: gephi ? GEPHI_EDGE_DISPLAY_KEYS : void 0
3892
4953
  });
3893
4954
  if (declared.allowSelfLoops === false && u === v) {
3894
4955
  violations.selfLoops++;
@@ -3933,7 +4994,10 @@ function pushNestedNode(ctx, id, record, dictKey, structural, element, plain = f
3933
4994
  { element }
3934
4995
  );
3935
4996
  }
3936
- ctx.writeNested(ctx.nodes, index, record, isJsonObject(dict) ? dict : {}, structural, element, { plain });
4997
+ ctx.writeNested(ctx.nodes, index, record, isJsonObject(dict) ? dict : {}, structural, element, {
4998
+ plain,
4999
+ dataKeys: plain ? GEPHI_NODE_DISPLAY_KEYS : void 0
5000
+ });
3937
5001
  } catch (err) {
3938
5002
  ctx.report.recordError(err, { element: String(id) });
3939
5003
  }
@@ -3951,7 +5015,7 @@ function importJgf(ctx, root) {
3951
5015
  `graph.nodes must be an object keyed by id or an array, found ${describe(nodesRaw)}`
3952
5016
  );
3953
5017
  }
3954
- const nodeRecords2 = Array.isArray(nodesRaw) ? nodesRaw : Object.values(nodesRaw ?? {});
5018
+ const nodeRecords = Array.isArray(nodesRaw) ? nodesRaw : Object.values(nodesRaw ?? {});
3955
5019
  const directed = jgfDirected(ctx, graph, edges);
3956
5020
  ctx.setHeader(directed);
3957
5021
  ctx.writeGraphDict(graph.metadata, "graph.metadata");
@@ -3962,18 +5026,18 @@ function importJgf(ctx, root) {
3962
5026
  };
3963
5027
  const label = typeof graph.label === "string" ? graph.label : null;
3964
5028
  ctx.reportNodeIdFrom("jgf", "the node keys");
3965
- ctx.sink.reserve(nodeRecords2.length, edges.length);
5029
+ ctx.sink.reserve(nodeRecords.length, edges.length);
3966
5030
  const labelColumn = ctx.nodes.declareIf(
3967
5031
  { name: "label", dtype: "string", role: "label", nullable: true },
3968
- anyHas(nodeRecords2, "label")
5032
+ anyHas(nodeRecords, "label")
3969
5033
  );
3970
5034
  if (isJsonObject(nodesRaw)) {
3971
5035
  for (const key of jgfNodeKeys(ctx, root, graph, nodesRaw)) {
3972
5036
  pushJgfKeyedNode(ctx, key, nodesRaw[key], labelColumn);
3973
5037
  }
3974
5038
  } else {
3975
- for (let i = 0; i < nodeRecords2.length; i++) {
3976
- pushJgfListedNode(ctx, nodeRecords2[i], labelColumn, `nodes[${i}]`);
5039
+ for (let i = 0; i < nodeRecords.length; i++) {
5040
+ pushJgfListedNode(ctx, nodeRecords[i], labelColumn, `nodes[${i}]`);
3977
5041
  }
3978
5042
  }
3979
5043
  throwIfAborted(ctx.options.signal);
@@ -4700,6 +5764,7 @@ const jsonImporter = Object.freeze({
4700
5764
  "nodeIdKey",
4701
5765
  "nodesPath",
4702
5766
  "oboIds",
5767
+ "sigmaSettings",
4703
5768
  "sourceKey",
4704
5769
  "targetKey",
4705
5770
  "typedefs"
@@ -7560,10 +8625,11 @@ export {
7560
8625
  jsonShapeOf as f,
7561
8626
  extensionOf as g,
7562
8627
  headBytes as h,
7563
- sniffJsonDialectHead as i,
8628
+ sniffFormat as i,
7564
8629
  jsonCapabilities as j,
8630
+ sniffJsonDialectHead as k,
7565
8631
  normalizeMimeType as n,
7566
8632
  rankFormats as r,
7567
- sniffFormat as s
8633
+ sniffJsonDialect as s
7568
8634
  };
7569
- //# sourceMappingURL=exporter-bxxjOrDZ.js.map
8635
+ //# sourceMappingURL=exporter-D2CETOMK.js.map