@deck.gl-community/graph-layers 9.1.1 → 9.2.0-beta.2

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 (251) hide show
  1. package/dist/_deprecated/old-constants.d.ts +107 -0
  2. package/dist/_deprecated/old-constants.d.ts.map +1 -0
  3. package/dist/_deprecated/old-constants.js +111 -0
  4. package/dist/_deprecated/old-constants.js.map +1 -0
  5. package/dist/core/cache.d.ts +0 -1
  6. package/dist/core/cache.js +0 -1
  7. package/dist/core/constants.d.ts +12 -100
  8. package/dist/core/constants.d.ts.map +1 -1
  9. package/dist/core/constants.js +3 -44
  10. package/dist/core/constants.js.map +1 -1
  11. package/dist/core/graph-engine.d.ts +12 -11
  12. package/dist/core/graph-engine.d.ts.map +1 -1
  13. package/dist/core/graph-engine.js +22 -11
  14. package/dist/core/graph-engine.js.map +1 -1
  15. package/dist/core/graph-layout.d.ts +48 -21
  16. package/dist/core/graph-layout.d.ts.map +1 -1
  17. package/dist/core/graph-layout.js +91 -24
  18. package/dist/core/graph-layout.js.map +1 -1
  19. package/dist/core/interaction-manager.d.ts +6 -4
  20. package/dist/core/interaction-manager.d.ts.map +1 -1
  21. package/dist/core/interaction-manager.js +59 -17
  22. package/dist/core/interaction-manager.js.map +1 -1
  23. package/dist/graph/edge.d.ts +7 -7
  24. package/dist/graph/edge.d.ts.map +1 -1
  25. package/dist/graph/edge.js +3 -6
  26. package/dist/graph/edge.js.map +1 -1
  27. package/dist/graph/graph.d.ts +2 -3
  28. package/dist/graph/graph.js +8 -9
  29. package/dist/graph/graph.js.map +1 -1
  30. package/dist/graph/node.d.ts +7 -8
  31. package/dist/graph/node.d.ts.map +1 -1
  32. package/dist/graph/node.js +3 -5
  33. package/dist/graph/node.js.map +1 -1
  34. package/dist/graph-style-schema.cdn.d.ts +2 -0
  35. package/dist/graph-style-schema.cdn.js +2 -0
  36. package/dist/graph-style-schema.json +12 -0
  37. package/dist/index.cjs +2821 -549
  38. package/dist/index.cjs.map +4 -4
  39. package/dist/index.d.ts +28 -22
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +25 -21
  42. package/dist/index.js.map +1 -1
  43. package/dist/layers/common-layers/flow-path-layer/flow-path-layer-fragment.glsl.d.ts +0 -1
  44. package/dist/layers/common-layers/flow-path-layer/flow-path-layer-fragment.glsl.js +0 -1
  45. package/dist/layers/common-layers/flow-path-layer/flow-path-layer-vertex-tf.glsl.d.ts +0 -1
  46. package/dist/layers/common-layers/flow-path-layer/flow-path-layer-vertex-tf.glsl.js +0 -1
  47. package/dist/layers/common-layers/flow-path-layer/flow-path-layer-vertex.glsl.d.ts +0 -1
  48. package/dist/layers/common-layers/flow-path-layer/flow-path-layer-vertex.glsl.js +0 -1
  49. package/dist/layers/common-layers/flow-path-layer/flow-path-layer.d.ts +0 -1
  50. package/dist/layers/common-layers/flow-path-layer/flow-path-layer.js +0 -1
  51. package/dist/layers/common-layers/marker-layer/atlas-data-url.d.ts +0 -1
  52. package/dist/layers/common-layers/marker-layer/atlas-data-url.js +0 -1
  53. package/dist/layers/common-layers/marker-layer/marker-layer.d.ts +0 -1
  54. package/dist/layers/common-layers/marker-layer/marker-layer.js +2 -3
  55. package/dist/layers/common-layers/marker-layer/marker-list.d.ts +2 -63
  56. package/dist/layers/common-layers/marker-layer/marker-list.d.ts.map +1 -1
  57. package/dist/layers/common-layers/marker-layer/marker-list.js +1 -65
  58. package/dist/layers/common-layers/marker-layer/marker-list.js.map +1 -1
  59. package/dist/layers/common-layers/marker-layer/marker-mapping.d.ts +0 -1
  60. package/dist/layers/common-layers/marker-layer/marker-mapping.js +0 -1
  61. package/dist/layers/common-layers/spline-layer/spline-layer.d.ts +0 -1
  62. package/dist/layers/common-layers/spline-layer/spline-layer.js +0 -1
  63. package/dist/layers/common-layers/zoomable-text-layer/zoomable-text-layer.d.ts +0 -1
  64. package/dist/layers/common-layers/zoomable-text-layer/zoomable-text-layer.js +0 -1
  65. package/dist/layers/edge-attachment-helper.d.ts +15 -0
  66. package/dist/layers/edge-attachment-helper.d.ts.map +1 -0
  67. package/dist/layers/edge-attachment-helper.js +230 -0
  68. package/dist/layers/edge-attachment-helper.js.map +1 -0
  69. package/dist/layers/edge-layer.d.ts +1 -5
  70. package/dist/layers/edge-layer.d.ts.map +1 -1
  71. package/dist/layers/edge-layer.js +9 -11
  72. package/dist/layers/edge-layer.js.map +1 -1
  73. package/dist/layers/edge-layers/arrow-2d-geometry.d.ts +4 -0
  74. package/dist/layers/edge-layers/arrow-2d-geometry.d.ts.map +1 -0
  75. package/dist/layers/edge-layers/arrow-2d-geometry.js +42 -0
  76. package/dist/layers/edge-layers/arrow-2d-geometry.js.map +1 -0
  77. package/dist/layers/edge-layers/curved-edge-layer.d.ts +1 -2
  78. package/dist/layers/edge-layers/curved-edge-layer.js +1 -2
  79. package/dist/layers/edge-layers/edge-arrow-layer.d.ts +21 -0
  80. package/dist/layers/edge-layers/edge-arrow-layer.d.ts.map +1 -0
  81. package/dist/layers/edge-layers/edge-arrow-layer.js +131 -0
  82. package/dist/layers/edge-layers/edge-arrow-layer.js.map +1 -0
  83. package/dist/layers/edge-layers/edge-label-layer.d.ts +1 -2
  84. package/dist/layers/edge-layers/edge-label-layer.js +1 -2
  85. package/dist/layers/edge-layers/flow-layer.d.ts +1 -2
  86. package/dist/layers/edge-layers/flow-layer.js +1 -2
  87. package/dist/layers/edge-layers/path-edge-layer.d.ts +0 -1
  88. package/dist/layers/edge-layers/path-edge-layer.js +0 -1
  89. package/dist/layers/edge-layers/straight-line-edge-layer.d.ts +0 -1
  90. package/dist/layers/edge-layers/straight-line-edge-layer.js +0 -1
  91. package/dist/layers/graph-layer.d.ts +22 -23
  92. package/dist/layers/graph-layer.d.ts.map +1 -1
  93. package/dist/layers/graph-layer.js +218 -62
  94. package/dist/layers/graph-layer.js.map +1 -1
  95. package/dist/layers/node-layers/circle-layer.d.ts +0 -1
  96. package/dist/layers/node-layers/circle-layer.js +0 -1
  97. package/dist/layers/node-layers/image-layer.d.ts +0 -1
  98. package/dist/layers/node-layers/image-layer.js +0 -1
  99. package/dist/layers/node-layers/label-layer.d.ts +1 -2
  100. package/dist/layers/node-layers/label-layer.js +1 -2
  101. package/dist/layers/node-layers/path-rounded-rectangle-layer.d.ts +0 -1
  102. package/dist/layers/node-layers/path-rounded-rectangle-layer.js +1 -2
  103. package/dist/layers/node-layers/rectangle-layer.d.ts +0 -1
  104. package/dist/layers/node-layers/rectangle-layer.js +0 -1
  105. package/dist/layers/node-layers/rounded-rectangle-layer-fragment.d.ts +0 -1
  106. package/dist/layers/node-layers/rounded-rectangle-layer-fragment.js +0 -1
  107. package/dist/layers/node-layers/rounded-rectangle-layer.d.ts +1 -2
  108. package/dist/layers/node-layers/rounded-rectangle-layer.js +2 -3
  109. package/dist/layers/node-layers/zoomable-marker-layer.d.ts +1 -2
  110. package/dist/layers/node-layers/zoomable-marker-layer.js +1 -2
  111. package/dist/layouts/d3-dag/d3-dag-layout.d.ts +117 -0
  112. package/dist/layouts/d3-dag/d3-dag-layout.d.ts.map +1 -0
  113. package/dist/layouts/d3-dag/d3-dag-layout.js +716 -0
  114. package/dist/layouts/d3-dag/d3-dag-layout.js.map +1 -0
  115. package/dist/layouts/d3-force/d3-force-layout.d.ts +4 -4
  116. package/dist/layouts/d3-force/d3-force-layout.d.ts.map +1 -1
  117. package/dist/layouts/d3-force/d3-force-layout.js +25 -10
  118. package/dist/layouts/d3-force/d3-force-layout.js.map +1 -1
  119. package/dist/layouts/d3-force/worker.d.ts +0 -1
  120. package/dist/layouts/d3-force/worker.js +0 -1
  121. package/dist/layouts/experimental/force-multi-graph-layout.d.ts +9 -8
  122. package/dist/layouts/experimental/force-multi-graph-layout.d.ts.map +1 -1
  123. package/dist/layouts/experimental/force-multi-graph-layout.js +15 -11
  124. package/dist/layouts/experimental/force-multi-graph-layout.js.map +1 -1
  125. package/dist/layouts/experimental/hive-plot-layout.d.ts +11 -8
  126. package/dist/layouts/experimental/hive-plot-layout.d.ts.map +1 -1
  127. package/dist/layouts/experimental/hive-plot-layout.js +12 -7
  128. package/dist/layouts/experimental/hive-plot-layout.js.map +1 -1
  129. package/dist/layouts/experimental/radial-layout.d.ts +10 -7
  130. package/dist/layouts/experimental/radial-layout.d.ts.map +1 -1
  131. package/dist/layouts/experimental/radial-layout.js +11 -6
  132. package/dist/layouts/experimental/radial-layout.js.map +1 -1
  133. package/dist/layouts/gpu-force/gpu-force-layout.d.ts +4 -4
  134. package/dist/layouts/gpu-force/gpu-force-layout.d.ts.map +1 -1
  135. package/dist/layouts/gpu-force/gpu-force-layout.js +18 -9
  136. package/dist/layouts/gpu-force/gpu-force-layout.js.map +1 -1
  137. package/dist/layouts/gpu-force/worker.d.ts +0 -1
  138. package/dist/layouts/gpu-force/worker.js +0 -1
  139. package/dist/layouts/simple-layout.d.ts +19 -12
  140. package/dist/layouts/simple-layout.d.ts.map +1 -1
  141. package/dist/layouts/simple-layout.js +26 -15
  142. package/dist/layouts/simple-layout.js.map +1 -1
  143. package/dist/loaders/create-graph.d.ts +1 -2
  144. package/dist/loaders/create-graph.js +3 -4
  145. package/dist/loaders/edge-parsers.d.ts +1 -2
  146. package/dist/loaders/edge-parsers.js +2 -3
  147. package/dist/loaders/edge-parsers.js.map +1 -1
  148. package/dist/loaders/json-loader.d.ts +2 -3
  149. package/dist/loaders/json-loader.d.ts.map +1 -1
  150. package/dist/loaders/json-loader.js +5 -6
  151. package/dist/loaders/json-loader.js.map +1 -1
  152. package/dist/loaders/node-parsers.d.ts +1 -2
  153. package/dist/loaders/node-parsers.js +2 -3
  154. package/dist/loaders/node-parsers.js.map +1 -1
  155. package/dist/loaders/simple-json-graph-loader.d.ts +0 -1
  156. package/dist/loaders/simple-json-graph-loader.d.ts.map +1 -1
  157. package/dist/loaders/simple-json-graph-loader.js +5 -6
  158. package/dist/loaders/simple-json-graph-loader.js.map +1 -1
  159. package/dist/loaders/table-graph-loader.d.ts +3 -4
  160. package/dist/loaders/table-graph-loader.js +5 -6
  161. package/dist/loaders/table-graph-loader.js.map +1 -1
  162. package/dist/style/graph-layer-stylesheet.d.ts +34 -0
  163. package/dist/style/graph-layer-stylesheet.d.ts.map +1 -0
  164. package/dist/style/graph-layer-stylesheet.js +39 -0
  165. package/dist/style/graph-layer-stylesheet.js.map +1 -0
  166. package/dist/style/graph-style-accessor-map.d.ts +93 -0
  167. package/dist/style/graph-style-accessor-map.d.ts.map +1 -0
  168. package/dist/style/graph-style-accessor-map.js +93 -0
  169. package/dist/style/graph-style-accessor-map.js.map +1 -0
  170. package/dist/style/graph-style-engine.d.ts +10 -0
  171. package/dist/style/graph-style-engine.d.ts.map +1 -0
  172. package/dist/style/graph-style-engine.js +163 -0
  173. package/dist/style/graph-style-engine.js.map +1 -0
  174. package/dist/style/graph-stylesheet.schema.d.ts +310 -0
  175. package/dist/style/graph-stylesheet.schema.d.ts.map +1 -0
  176. package/dist/style/graph-stylesheet.schema.js +237 -0
  177. package/dist/style/graph-stylesheet.schema.js.map +1 -0
  178. package/dist/style/style-engine.d.ts +33 -0
  179. package/dist/style/style-engine.d.ts.map +1 -0
  180. package/dist/style/style-engine.js +121 -0
  181. package/dist/style/style-engine.js.map +1 -0
  182. package/dist/style/style-property.d.ts +2 -3
  183. package/dist/style/style-property.d.ts.map +1 -1
  184. package/dist/style/style-property.js +224 -48
  185. package/dist/style/style-property.js.map +1 -1
  186. package/dist/utils/collapsed-chains.d.ts +17 -0
  187. package/dist/utils/collapsed-chains.d.ts.map +1 -0
  188. package/dist/utils/collapsed-chains.js +197 -0
  189. package/dist/utils/collapsed-chains.js.map +1 -0
  190. package/dist/utils/layer-utils.d.ts +0 -1
  191. package/dist/utils/layer-utils.d.ts.map +1 -1
  192. package/dist/utils/layer-utils.js +0 -1
  193. package/dist/utils/log.d.ts +2 -1
  194. package/dist/utils/log.d.ts.map +1 -1
  195. package/dist/utils/log.js +12 -2
  196. package/dist/utils/log.js.map +1 -1
  197. package/dist/utils/node-boundary.d.ts +10 -0
  198. package/dist/utils/node-boundary.d.ts.map +1 -0
  199. package/dist/utils/node-boundary.js +130 -0
  200. package/dist/utils/node-boundary.js.map +1 -0
  201. package/dist/utils/polygon-calculations.d.ts +0 -1
  202. package/dist/utils/polygon-calculations.js +0 -1
  203. package/dist/widgets/long-press-button.d.ts +0 -1
  204. package/dist/widgets/long-press-button.js +0 -1
  205. package/dist/widgets/view-control-widget.d.ts +4 -5
  206. package/dist/widgets/view-control-widget.d.ts.map +1 -1
  207. package/dist/widgets/view-control-widget.js +10 -8
  208. package/dist/widgets/view-control-widget.js.map +1 -1
  209. package/package.json +23 -7
  210. package/src/_deprecated/old-constants.ts +122 -0
  211. package/src/core/constants.ts +21 -43
  212. package/src/core/graph-engine.ts +24 -9
  213. package/src/core/graph-layout.ts +133 -28
  214. package/src/core/interaction-manager.ts +80 -20
  215. package/src/graph/edge.ts +6 -6
  216. package/src/graph/graph.ts +7 -7
  217. package/src/graph/node.ts +6 -6
  218. package/src/index.ts +31 -6
  219. package/src/layers/common-layers/marker-layer/marker-list.ts +62 -64
  220. package/src/layers/edge-attachment-helper.ts +355 -0
  221. package/src/layers/edge-layer.ts +6 -7
  222. package/src/layers/edge-layers/arrow-2d-geometry.ts +51 -0
  223. package/src/layers/edge-layers/edge-arrow-layer.ts +171 -0
  224. package/src/layers/graph-layer.ts +304 -86
  225. package/src/layouts/d3-dag/d3-dag-layout.ts +969 -0
  226. package/src/layouts/d3-force/d3-force-layout.ts +33 -11
  227. package/src/layouts/experimental/force-multi-graph-layout.ts +22 -13
  228. package/src/layouts/experimental/hive-plot-layout.ts +22 -10
  229. package/src/layouts/experimental/radial-layout.ts +20 -8
  230. package/src/layouts/gpu-force/gpu-force-layout.ts +22 -10
  231. package/src/layouts/simple-layout.ts +48 -25
  232. package/src/loaders/edge-parsers.ts +2 -2
  233. package/src/loaders/json-loader.ts +2 -2
  234. package/src/loaders/node-parsers.ts +2 -2
  235. package/src/loaders/simple-json-graph-loader.ts +2 -2
  236. package/src/loaders/table-graph-loader.ts +2 -2
  237. package/src/style/graph-layer-stylesheet.ts +99 -0
  238. package/src/style/graph-style-accessor-map.ts +103 -0
  239. package/src/style/graph-style-engine.ts +229 -0
  240. package/src/style/graph-stylesheet.schema.ts +344 -0
  241. package/src/style/style-engine.ts +168 -0
  242. package/src/style/style-property.ts +314 -51
  243. package/src/utils/collapsed-chains.ts +261 -0
  244. package/src/utils/log.ts +15 -1
  245. package/src/utils/node-boundary.ts +238 -0
  246. package/src/widgets/view-control-widget.tsx +15 -13
  247. package/dist/style/style-sheet.d.ts +0 -11
  248. package/dist/style/style-sheet.d.ts.map +0 -1
  249. package/dist/style/style-sheet.js +0 -253
  250. package/dist/style/style-sheet.js.map +0 -1
  251. package/src/style/style-sheet.ts +0 -277
package/dist/index.cjs CHANGED
@@ -34,26 +34,33 @@ var __publicField = (obj, key, value) => {
34
34
  // dist/index.js
35
35
  var dist_exports = {};
36
36
  __export(dist_exports, {
37
+ D3DagLayout: () => D3DagLayout,
37
38
  D3ForceLayout: () => D3ForceLayout,
39
+ DEFAULT_GRAPH_LAYER_STYLESHEET: () => DEFAULT_GRAPH_LAYER_STYLESHEET,
38
40
  EDGE_DECORATOR_TYPE: () => EDGE_DECORATOR_TYPE,
41
+ EDGE_STATE: () => EDGE_STATE,
39
42
  EDGE_TYPE: () => EDGE_TYPE,
40
43
  Edge: () => Edge,
41
44
  EdgeLayer: () => EdgeLayer,
45
+ ForceMultiGraphLayout: () => ForceMultiGraphLayout,
42
46
  GPUForceLayout: () => GPUForceLayout,
43
47
  Graph: () => Graph,
44
48
  GraphEngine: () => GraphEngine,
45
49
  GraphLayer: () => GraphLayer,
46
50
  GraphLayout: () => GraphLayout,
51
+ GraphStyleEngine: () => GraphStyleEngine,
52
+ GraphStylesheetSchema: () => GraphStylesheetSchema,
53
+ HivePlotLayout: () => HivePlotLayout,
47
54
  JSONLoader: () => JSONLoader2,
55
+ LAYOUT_STATE: () => LAYOUT_STATE,
48
56
  MARKER_TYPE: () => MARKER_TYPE,
49
57
  NODE_STATE: () => NODE_STATE,
50
58
  NODE_TYPE: () => NODE_TYPE,
51
59
  Node: () => Node,
60
+ RadialLayout: () => RadialLayout,
52
61
  SimpleLayout: () => SimpleLayout,
62
+ StyleEngine: () => StyleEngine,
53
63
  ViewControlWidget: () => ViewControlWidget,
54
- _HivePlotLayout: () => HivePlotLayout,
55
- _MultigraphLayout: () => ForceMultiGraphLayout,
56
- _RadialLayout: () => RadialLayout,
57
64
  createGraph: () => createGraph,
58
65
  loadSimpleJSONGraph: () => loadSimpleJSONGraph,
59
66
  log: () => log,
@@ -64,7 +71,18 @@ module.exports = __toCommonJS(dist_exports);
64
71
  // dist/utils/log.js
65
72
  var import_log = require("@probe.gl/log");
66
73
  var log = new import_log.Log({ id: "graph-layers" }).enable();
67
- log.log({ color: import_log.COLOR.CYAN }, "Initialize graph-layers logger.")();
74
+ log.log({ color: import_log.COLOR.CYAN }, "Initialize graph-layers logger.");
75
+ function invokeLogFunction(result) {
76
+ if (typeof result === "function") {
77
+ result();
78
+ }
79
+ }
80
+ function warn(message, ...args) {
81
+ invokeLogFunction(log.warn(message, ...args));
82
+ }
83
+ function error(message, ...args) {
84
+ invokeLogFunction(log.error(message, ...args));
85
+ }
68
86
 
69
87
  // dist/core/cache.js
70
88
  var Cache = class {
@@ -211,7 +229,7 @@ var Graph = class extends EventTarget {
211
229
  const sourceNode = this.findNode(edge.getSourceNodeId());
212
230
  const targetNode = this.findNode(edge.getTargetNodeId());
213
231
  if (!sourceNode || !targetNode) {
214
- log.warn(`Unable to add edge ${edge.id}, source or target node is missing.`)();
232
+ warn(`Unable to add edge ${edge.id}, source or target node is missing.`);
215
233
  return;
216
234
  }
217
235
  this._edgeMap[edge.getId()] = edge;
@@ -244,7 +262,7 @@ var Graph = class extends EventTarget {
244
262
  removeNode(nodeId) {
245
263
  const node = this.findNode(nodeId);
246
264
  if (!node) {
247
- log.warn(`Unable to remove node ${nodeId} - doesn't exist`)();
265
+ warn(`Unable to remove node ${nodeId} - doesn't exist`);
248
266
  return;
249
267
  }
250
268
  node.getConnectedEdges().forEach((e) => {
@@ -276,7 +294,7 @@ var Graph = class extends EventTarget {
276
294
  removeEdge(edgeId) {
277
295
  const edge = this.findEdge(edgeId);
278
296
  if (!edge) {
279
- log.warn(`Unable to remove edge ${edgeId} - doesn't exist`)();
297
+ warn(`Unable to remove edge ${edgeId} - doesn't exist`);
280
298
  return;
281
299
  }
282
300
  const sourceNode = this.findNode(edge.getSourceNodeId());
@@ -302,7 +320,7 @@ var Graph = class extends EventTarget {
302
320
  getConnectedEdges(nodeId) {
303
321
  const node = this.findNode(nodeId);
304
322
  if (!node) {
305
- log.warn(`Unable to find node ${nodeId} - doesn't exist`)();
323
+ warn(`Unable to find node ${nodeId} - doesn't exist`);
306
324
  return [];
307
325
  }
308
326
  return node.getConnectedEdges();
@@ -315,7 +333,7 @@ var Graph = class extends EventTarget {
315
333
  getNodeSiblings(nodeId) {
316
334
  const node = this.findNode(nodeId);
317
335
  if (!node) {
318
- log.warn(`Unable to find node ${nodeId} - doesn't exist`)();
336
+ warn(`Unable to find node ${nodeId} - doesn't exist`);
319
337
  return [];
320
338
  }
321
339
  return node.getSiblingIds().map((siblingNodeId) => this.findNode(siblingNodeId));
@@ -328,7 +346,7 @@ var Graph = class extends EventTarget {
328
346
  getDegree(nodeId) {
329
347
  const node = this.findNode(nodeId);
330
348
  if (!node) {
331
- log.warn(`Unable to find node ${nodeId} - doesn't exist`)();
349
+ warn(`Unable to find node ${nodeId} - doesn't exist`);
332
350
  return 0;
333
351
  }
334
352
  return node.getDegree();
@@ -387,103 +405,6 @@ var Graph = class extends EventTarget {
387
405
  }
388
406
  };
389
407
 
390
- // dist/layers/common-layers/marker-layer/marker-list.js
391
- var MarkerList = {
392
- "bell-filled": "bell-filled",
393
- bell: "bell",
394
- "bookmark-filled": "bookmark-filled",
395
- bookmark: "bookmark",
396
- "cd-filled": "cd-filled",
397
- cd: "cd",
398
- checkmark: "checkmark",
399
- "circle-check-filled": "circle-check-filled",
400
- "circle-check": "circle-check",
401
- "circle-filled": "circle-filled",
402
- "circle-i-filled": "circle-i-filled",
403
- "circle-i": "circle-i",
404
- "circle-minus-filled": "circle-minus-filled",
405
- "circle-minus": "circle-minus",
406
- "circle-plus-filled": "circle-plus-filled",
407
- "circle-plus": "circle-plus",
408
- "circle-questionmark-filled": "circle-questionmark-filled",
409
- "circle-questionmark": "circle-questionmark",
410
- "circle-slash-filled": "circle-slash-filled",
411
- "circle-slash": "circle-slash",
412
- "circle-x-filled": "circle-x-filled",
413
- "circle-x": "circle-x",
414
- circle: "circle",
415
- "diamond-filled": "diamond-filled",
416
- diamond: "diamond",
417
- "flag-filled": "flag-filled",
418
- flag: "flag",
419
- gear: "gear",
420
- "heart-filled": "heart-filled",
421
- heart: "heart",
422
- "location-marker-filled": "location-marker-filled",
423
- "location-marker": "location-marker",
424
- "octagonal-star-filled": "octagonal-star-filled",
425
- "octagonal-star": "octagonal-star",
426
- "person-filled": "person-filled",
427
- person: "person",
428
- "pin-filled": "pin-filled",
429
- pin: "pin",
430
- "plus-small": "plus-small",
431
- plus: "plus",
432
- "rectangle-filled": "rectangle-filled",
433
- rectangle: "rectangle",
434
- "star-filled": "star-filled",
435
- star: "star",
436
- "tag-filled": "tag-filled",
437
- tag: "tag",
438
- "thumb-down-filled": "thumb-down-filled",
439
- "thumb-down": "thumb-down",
440
- "thumb-up": "thumb-up",
441
- "thumb_up-filled": "thumb_up-filled",
442
- "triangle-down-filled": "triangle-down-filled",
443
- "triangle-down": "triangle-down",
444
- "triangle-left-filled": "triangle-left-filled",
445
- "triangle-left": "triangle-left",
446
- "triangle-right-filled": "triangle-right-filled",
447
- "triangle-right": "triangle-right",
448
- "triangle-up-filled": "triangle-up-filled",
449
- "triangle-up": "triangle-up",
450
- "x-small": "x-small",
451
- x: "x"
452
- };
453
-
454
- // dist/core/constants.js
455
- var MARKER_TYPE = MarkerList;
456
- var NODE_STATE = {
457
- DEFAULT: "default",
458
- HOVER: "hover",
459
- DRAGGING: "dragging",
460
- SELECTED: "selected"
461
- };
462
- var EDGE_STATE = {
463
- DEFAULT: "default",
464
- HOVER: "hover",
465
- DRAGGING: "dragging",
466
- SELECTED: "selected"
467
- };
468
- var NODE_TYPE = {
469
- CIRCLE: "CIRCLE",
470
- RECTANGLE: "RECTANGLE",
471
- ROUNDED_RECTANGLE: "ROUNDED_RECTANGLE",
472
- PATH_ROUNDED_RECTANGLE: "PATH_ROUNDED_RECTANGLE",
473
- ICON: "ICON",
474
- LABEL: "LABEL",
475
- MARKER: "MARKER"
476
- };
477
- var EDGE_TYPE = {
478
- SPLINE_CURVE: "SPLINE_CURVE",
479
- LINE: "LINE",
480
- PATH: "PATH"
481
- };
482
- var EDGE_DECORATOR_TYPE = {
483
- LABEL: "EDGE_LABEL",
484
- FLOW: "FLOW"
485
- };
486
-
487
408
  // dist/graph/node.js
488
409
  var Node = class {
489
410
  id;
@@ -492,7 +413,7 @@ var Node = class {
492
413
  /** List edges. */
493
414
  _connectedEdges = {};
494
415
  /** Interaction state of the node. */
495
- state = NODE_STATE.DEFAULT;
416
+ state = "default";
496
417
  /** Can the node be selected? */
497
418
  _selectable;
498
419
  /** Should the state of this node affect the state of the connected edges? */
@@ -602,14 +523,14 @@ var Node = class {
602
523
  }
603
524
  /**
604
525
  * Set node state
605
- * @param state - one of NODE_STATE
526
+ * @param state - the new interaction state of the node
606
527
  */
607
528
  setState(state) {
608
529
  this.state = state;
609
530
  }
610
531
  /**
611
532
  * Get node state
612
- * @returns state - one of NODE_STATE
533
+ * @returns state - the current interaction state of the node
613
534
  */
614
535
  getState() {
615
536
  return this.state;
@@ -668,7 +589,7 @@ var Edge = class {
668
589
  /** Nodes at either end of this edge. */
669
590
  _connectedNodes = {};
670
591
  /** Edge state. */
671
- state = EDGE_STATE.DEFAULT;
592
+ state = "default";
672
593
  /**
673
594
  * The constructor
674
595
  * @param options.id - information about the edge
@@ -738,14 +659,14 @@ var Edge = class {
738
659
  }
739
660
  /**
740
661
  * Set edge state
741
- * @param state - one of EDGE_STATE
662
+ * @param state - the new interaction state for the edge
742
663
  */
743
664
  setState(state) {
744
665
  this.state = state;
745
666
  }
746
667
  /**
747
668
  * Get edge state
748
- * @returns state - one of EDGE_STATE
669
+ * @returns state - the current interaction state for the edge
749
670
  */
750
671
  getState() {
751
672
  return this.state;
@@ -795,32 +716,40 @@ var GraphEngine = class extends EventTarget {
795
716
  getGraphVersion = () => this._graph.version;
796
717
  getLayoutLastUpdate = () => this._layout.version;
797
718
  getLayoutState = () => this._layout.state;
719
+ getLayoutBounds = () => this._layout.getBounds();
798
720
  /** Operations on the graph */
799
721
  lockNodePosition = (node, x, y) => this._layout.lockNodePosition(node, x, y);
800
722
  unlockNodePosition = (node) => this._layout.unlockNodePosition(node);
801
723
  /**
802
724
  * @fires GraphEngine#onLayoutStart
803
725
  */
804
- _onLayoutStart = () => {
805
- this.dispatchEvent(new CustomEvent("onLayoutStart"));
726
+ _onLayoutStart = (event) => {
727
+ log.log(0, "GraphEngine: layout start")();
728
+ const detail = event instanceof CustomEvent ? event.detail : void 0;
729
+ this.dispatchEvent(new CustomEvent("onLayoutStart", { detail }));
806
730
  };
807
731
  /**
808
732
  * @fires GraphEngine#onLayoutChange
809
733
  */
810
- _onLayoutChange = () => {
811
- this.dispatchEvent(new CustomEvent("onLayoutChange"));
734
+ _onLayoutChange = (event) => {
735
+ log.log(0, "GraphEngine: layout update event")();
736
+ const detail = event instanceof CustomEvent ? event.detail : void 0;
737
+ this.dispatchEvent(new CustomEvent("onLayoutChange", { detail }));
812
738
  };
813
739
  /**
814
740
  * @fires GraphEngine#onLayoutDone
815
741
  */
816
- _onLayoutDone = () => {
817
- this.dispatchEvent(new CustomEvent("onLayoutDone"));
742
+ _onLayoutDone = (event) => {
743
+ log.log(0, "GraphEngine: layout end")();
744
+ const detail = event instanceof CustomEvent ? event.detail : void 0;
745
+ this.dispatchEvent(new CustomEvent("onLayoutDone", { detail }));
818
746
  };
819
747
  /**
820
748
  * @fires GraphEngine#onLayoutError
821
749
  */
822
- _onLayoutError = () => {
823
- this.dispatchEvent(new CustomEvent("onLayoutError"));
750
+ _onLayoutError = (event) => {
751
+ const detail = event instanceof CustomEvent ? event.detail : void 0;
752
+ this.dispatchEvent(new CustomEvent("onLayoutError", { detail }));
824
753
  };
825
754
  _onGraphStructureChanged = (entity) => {
826
755
  this._layoutDirty = true;
@@ -835,6 +764,7 @@ var GraphEngine = class extends EventTarget {
835
764
  };
836
765
  /** Layout calculations */
837
766
  run = () => {
767
+ log.log(1, "GraphEngine: run");
838
768
  this._graph.addEventListener("transactionStart", this._onTransactionStart);
839
769
  this._graph.addEventListener("transactionEnd", this._onTransactionEnd);
840
770
  this._graph.addEventListener("onNodeAdded", this._onGraphStructureChanged);
@@ -849,6 +779,7 @@ var GraphEngine = class extends EventTarget {
849
779
  this._layout.start();
850
780
  };
851
781
  clear = () => {
782
+ log.log(1, "GraphEngine: end");
852
783
  this._graph.removeEventListener("transactionStart", this._onTransactionStart);
853
784
  this._graph.removeEventListener("transactionEnd", this._onTransactionEnd);
854
785
  this._graph.removeEventListener("onNodeAdded", this._onGraphStructureChanged);
@@ -868,6 +799,7 @@ var GraphEngine = class extends EventTarget {
868
799
  }
869
800
  };
870
801
  _updateLayout = () => {
802
+ log.log(0, "GraphEngine: layout update");
871
803
  this._layout.updateGraph(this._graph);
872
804
  this._layout.update();
873
805
  this._layoutDirty = false;
@@ -884,8 +816,15 @@ var GraphLayout = class extends EventTarget {
884
816
  _name = "GraphLayout";
885
817
  /** Extra configuration options of the layout. */
886
818
  _options;
819
+ /**
820
+ * Last computed layout bounds in local layout coordinates.
821
+ *
822
+ * Subclasses should update this value by overriding {@link _updateBounds}
823
+ * so it reflects the latest geometry before layout lifecycle events fire.
824
+ */
825
+ _bounds = null;
887
826
  version = 0;
888
- state = "INIT";
827
+ state = "init";
889
828
  /**
890
829
  * Constructor of GraphLayout
891
830
  * @param options extra configuration options of the layout
@@ -905,25 +844,7 @@ var GraphLayout = class extends EventTarget {
905
844
  }
906
845
  return this._name === layout._name && (0, import_lodash.default)(this._options, layout._options);
907
846
  }
908
- /** virtual functions: will be implemented in the child class */
909
- /** first time to pass the graph data into this layout */
910
- initializeGraph(graph) {
911
- }
912
- /** update the existing graph */
913
- updateGraph(graph) {
914
- }
915
- /** start the layout calculation */
916
- start() {
917
- }
918
- /** update the layout calculation */
919
- update() {
920
- }
921
- /** resume the layout calculation */
922
- resume() {
923
- }
924
- /** stop the layout calculation */
925
- stop() {
926
- }
847
+ // Accessors
927
848
  /** access the position of the node in the layout */
928
849
  getNodePosition(node) {
929
850
  return [0, 0];
@@ -931,7 +852,7 @@ var GraphLayout = class extends EventTarget {
931
852
  /** access the layout information of the edge */
932
853
  getEdgePosition(edge) {
933
854
  return {
934
- type: EDGE_TYPE.LINE,
855
+ type: "line",
935
856
  sourcePosition: [0, 0],
936
857
  targetPosition: [0, 0],
937
858
  controlPoints: []
@@ -951,29 +872,101 @@ var GraphLayout = class extends EventTarget {
951
872
  */
952
873
  unlockNodePosition(node) {
953
874
  }
875
+ /** Returns the last computed layout bounds, if available. */
876
+ getBounds() {
877
+ return this._bounds;
878
+ }
954
879
  // INTERNAL METHODS
880
+ /** Hook for subclasses to update bounds prior to emitting events. */
881
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
882
+ _updateBounds() {
883
+ }
884
+ /**
885
+ * Utility for subclasses to derive layout bounds from an iterable of [x, y] positions.
886
+ * @param positions Iterable of node positions.
887
+ * @returns Layout bounds for the supplied positions or `null` if none are finite.
888
+ */
889
+ _calculateBounds(positions) {
890
+ let minX = Number.POSITIVE_INFINITY;
891
+ let maxX = Number.NEGATIVE_INFINITY;
892
+ let minY = Number.POSITIVE_INFINITY;
893
+ let maxY = Number.NEGATIVE_INFINITY;
894
+ for (const position of positions) {
895
+ if (!position) {
896
+ continue;
897
+ }
898
+ const [x, y] = position;
899
+ if (!Number.isFinite(x) || !Number.isFinite(y)) {
900
+ continue;
901
+ }
902
+ minX = Math.min(minX, x);
903
+ maxX = Math.max(maxX, x);
904
+ minY = Math.min(minY, y);
905
+ maxY = Math.max(maxY, y);
906
+ }
907
+ if (minX === Number.POSITIVE_INFINITY) {
908
+ return null;
909
+ }
910
+ return [
911
+ [minX, minY],
912
+ [maxX, maxY]
913
+ ];
914
+ }
915
+ /**
916
+ * Attempt to coerce an arbitrary value into a finite 2D point.
917
+ * @param value Candidate value that may represent a position.
918
+ * @returns Finite [x, y] tuple or null if the value cannot be interpreted.
919
+ */
920
+ _normalizePosition(value) {
921
+ if (Array.isArray(value) && value.length >= 2) {
922
+ const [x, y] = value;
923
+ if (this._isFiniteNumber(x) && this._isFiniteNumber(y)) {
924
+ return [x, y];
925
+ }
926
+ return null;
927
+ }
928
+ if (value && typeof value === "object") {
929
+ const { x, y } = value;
930
+ if (this._isFiniteNumber(x) && this._isFiniteNumber(y)) {
931
+ return [x, y];
932
+ }
933
+ }
934
+ return null;
935
+ }
936
+ _isFiniteNumber(value) {
937
+ return typeof value === "number" && Number.isFinite(value);
938
+ }
955
939
  _updateState(state) {
956
940
  this.state = state;
957
941
  this.version += 1;
958
942
  }
959
943
  /** @fires GraphLayout#onLayoutStart */
960
944
  _onLayoutStart = () => {
961
- this._updateState("CALCULATING");
962
- this.dispatchEvent(new CustomEvent("onLayoutStart"));
945
+ log.log(0, `GraphLayout(${this._name}): start`)();
946
+ this._updateBounds();
947
+ this._updateState("calculating");
948
+ const detail = { bounds: this._bounds };
949
+ this.dispatchEvent(new CustomEvent("onLayoutStart", { detail }));
963
950
  };
964
951
  /** @fires GraphLayout#onLayoutChange */
965
952
  _onLayoutChange = () => {
966
- this._updateState("CALCULATING");
967
- this.dispatchEvent(new CustomEvent("onLayoutChange"));
953
+ log.log(0, `GraphLayout(${this._name}): update`)();
954
+ this._updateBounds();
955
+ this._updateState("calculating");
956
+ const detail = { bounds: this._bounds };
957
+ this.dispatchEvent(new CustomEvent("onLayoutChange", { detail }));
968
958
  };
969
959
  /** @fires GraphLayout#onLayoutDone */
970
960
  _onLayoutDone = () => {
971
- this._updateState("DONE");
972
- this.dispatchEvent(new CustomEvent("onLayoutDone"));
961
+ log.log(0, `GraphLayout(${this._name}): end`)();
962
+ this._updateBounds();
963
+ this._updateState("done");
964
+ const detail = { bounds: this._bounds };
965
+ this.dispatchEvent(new CustomEvent("onLayoutDone", { detail }));
973
966
  };
974
967
  /** @fires GraphLayout#onLayoutError */
975
968
  _onLayoutError = () => {
976
- this._updateState("ERROR");
969
+ this._updateState("error");
977
970
  this.dispatchEvent(new CustomEvent("onLayoutError"));
978
971
  };
979
972
  };
@@ -985,19 +978,16 @@ var _SimpleLayout = class extends GraphLayout {
985
978
  _nodeMap = {};
986
979
  _nodePositionMap = {};
987
980
  constructor(options = {}) {
988
- super({ ..._SimpleLayout.defaultOptions, ...options });
981
+ super({ ..._SimpleLayout.defaultProps, ...options });
989
982
  }
990
983
  initializeGraph(graph) {
991
984
  this.updateGraph(graph);
992
985
  }
993
- _notifyLayoutComplete() {
994
- this._onLayoutStart();
995
- this._onLayoutChange();
996
- this._onLayoutDone();
997
- }
998
986
  start() {
999
987
  this._notifyLayoutComplete();
1000
988
  }
989
+ stop() {
990
+ }
1001
991
  update() {
1002
992
  this._notifyLayoutComplete();
1003
993
  }
@@ -1011,19 +1001,27 @@ var _SimpleLayout = class extends GraphLayout {
1011
1001
  return res;
1012
1002
  }, {});
1013
1003
  this._nodePositionMap = graph.getNodes().reduce((res, node) => {
1014
- res[node.getId()] = this._options.nodePositionAccessor(node);
1004
+ res[node.getId()] = this._normalizePosition(this._options.nodePositionAccessor(node));
1015
1005
  return res;
1016
1006
  }, {});
1017
1007
  }
1018
1008
  setNodePositionAccessor = (accessor) => {
1019
1009
  this._options.nodePositionAccessor = accessor;
1020
1010
  };
1021
- getNodePosition = (node) => this._nodePositionMap[node.getId()];
1011
+ getNodePosition = (node) => {
1012
+ if (!node) {
1013
+ return [0, 0];
1014
+ }
1015
+ const position = this._nodePositionMap[node.getId()];
1016
+ return position ?? [0, 0];
1017
+ };
1022
1018
  getEdgePosition = (edge) => {
1023
- const sourcePos = this._nodePositionMap[edge.getSourceNodeId()];
1024
- const targetPos = this._nodePositionMap[edge.getTargetNodeId()];
1019
+ const sourceNode = this._nodeMap[edge.getSourceNodeId()];
1020
+ const targetNode = this._nodeMap[edge.getTargetNodeId()];
1021
+ const sourcePos = sourceNode ? this.getNodePosition(sourceNode) : [0, 0];
1022
+ const targetPos = targetNode ? this.getNodePosition(targetNode) : [0, 0];
1025
1023
  return {
1026
- type: EDGE_TYPE.LINE,
1024
+ type: "line",
1027
1025
  sourcePosition: sourcePos,
1028
1026
  targetPosition: targetPos,
1029
1027
  controlPoints: []
@@ -1034,9 +1032,18 @@ var _SimpleLayout = class extends GraphLayout {
1034
1032
  this._onLayoutChange();
1035
1033
  this._onLayoutDone();
1036
1034
  };
1035
+ _notifyLayoutComplete() {
1036
+ this._onLayoutStart();
1037
+ this._onLayoutChange();
1038
+ this._onLayoutDone();
1039
+ }
1040
+ _updateBounds() {
1041
+ const positions = Object.values(this._nodePositionMap).map((position) => this._normalizePosition(position));
1042
+ this._bounds = this._calculateBounds(positions);
1043
+ }
1037
1044
  };
1038
1045
  var SimpleLayout = _SimpleLayout;
1039
- __publicField(SimpleLayout, "defaultOptions", {
1046
+ __publicField(SimpleLayout, "defaultProps", {
1040
1047
  nodePositionAccessor: (node) => [node.getPropertyValue("x"), node.getPropertyValue("y")]
1041
1048
  });
1042
1049
 
@@ -1050,7 +1057,7 @@ var _D3ForceLayout = class extends GraphLayout {
1050
1057
  constructor(options) {
1051
1058
  super(options);
1052
1059
  this._options = {
1053
- ..._D3ForceLayout.defaultOptions,
1060
+ ..._D3ForceLayout.defaultProps,
1054
1061
  ...options
1055
1062
  };
1056
1063
  }
@@ -1087,6 +1094,8 @@ var _D3ForceLayout = class extends GraphLayout {
1087
1094
  options: this._options
1088
1095
  });
1089
1096
  this._worker.onmessage = (event) => {
1097
+ var _a;
1098
+ log.log(0, "D3ForceLayout: worker message", (_a = event.data) == null ? void 0 : _a.type, event.data);
1090
1099
  if (event.data.type !== "end") {
1091
1100
  return;
1092
1101
  }
@@ -1103,22 +1112,33 @@ var _D3ForceLayout = class extends GraphLayout {
1103
1112
  throw new Error("Resume unavailable");
1104
1113
  }
1105
1114
  stop() {
1106
- this._worker.terminate();
1115
+ if (this._worker) {
1116
+ this._worker.terminate();
1117
+ this._worker = null;
1118
+ }
1107
1119
  }
1108
1120
  getEdgePosition = (edge) => {
1109
1121
  const sourceNode = this._graph.findNode(edge.getSourceNodeId());
1110
1122
  const targetNode = this._graph.findNode(edge.getTargetNodeId());
1111
- if (!this.getNodePosition(sourceNode) || !this.getNodePosition(targetNode)) {
1123
+ if (!sourceNode || !targetNode) {
1124
+ return null;
1125
+ }
1126
+ const sourcePosition = this.getNodePosition(sourceNode);
1127
+ const targetPosition = this.getNodePosition(targetNode);
1128
+ if (!sourcePosition || !targetPosition) {
1112
1129
  return null;
1113
1130
  }
1114
1131
  return {
1115
- type: EDGE_TYPE.LINE,
1116
- sourcePosition: this.getNodePosition(sourceNode),
1117
- targetPosition: this.getNodePosition(targetNode),
1132
+ type: "line",
1133
+ sourcePosition,
1134
+ targetPosition,
1118
1135
  controlPoints: []
1119
1136
  };
1120
1137
  };
1121
1138
  getNodePosition = (node) => {
1139
+ if (!node) {
1140
+ return null;
1141
+ }
1122
1142
  const d3Node = this._positionsByNodeId.get(node.id);
1123
1143
  if (d3Node) {
1124
1144
  return d3Node.coordinates;
@@ -1143,9 +1163,13 @@ var _D3ForceLayout = class extends GraphLayout {
1143
1163
  d3Node.fx = null;
1144
1164
  d3Node.fy = null;
1145
1165
  };
1166
+ _updateBounds() {
1167
+ const positions = Array.from(this._positionsByNodeId.values(), (data) => data == null ? void 0 : data.coordinates);
1168
+ this._bounds = this._calculateBounds(positions);
1169
+ }
1146
1170
  };
1147
1171
  var D3ForceLayout = _D3ForceLayout;
1148
- __publicField(D3ForceLayout, "defaultOptions", {
1172
+ __publicField(D3ForceLayout, "defaultProps", {
1149
1173
  alpha: 0.3,
1150
1174
  resumeAlpha: 0.1,
1151
1175
  nBodyStrength: -900,
@@ -1154,105 +1178,784 @@ __publicField(D3ForceLayout, "defaultOptions", {
1154
1178
  getCollisionRadius: 0
1155
1179
  });
1156
1180
 
1157
- // dist/layouts/gpu-force/gpu-force-layout.js
1158
- var import_meta2 = {};
1159
- var _GPUForceLayout = class extends GraphLayout {
1160
- _name = "GPU";
1161
- _d3Graph;
1162
- _nodeMap;
1163
- _edgeMap;
1164
- _graph;
1165
- _worker;
1166
- _callbacks;
1181
+ // dist/layouts/d3-dag/d3-dag-layout.js
1182
+ var import_d3_dag = require("d3-dag");
1183
+ var DEFAULT_NODE_SIZE = [140, 120];
1184
+ var DEFAULT_GAP = [0, 0];
1185
+ var LAYERING_FACTORIES = {
1186
+ simplex: import_d3_dag.layeringSimplex,
1187
+ longestPath: import_d3_dag.layeringLongestPath,
1188
+ topological: import_d3_dag.layeringTopological
1189
+ };
1190
+ var DECROSS_FACTORIES = {
1191
+ twoLayer: import_d3_dag.decrossTwoLayer,
1192
+ opt: import_d3_dag.decrossOpt,
1193
+ dfs: import_d3_dag.decrossDfs
1194
+ };
1195
+ var COORD_FACTORIES = {
1196
+ simplex: import_d3_dag.coordSimplex,
1197
+ greedy: import_d3_dag.coordGreedy,
1198
+ quad: import_d3_dag.coordQuad,
1199
+ center: import_d3_dag.coordCenter,
1200
+ topological: import_d3_dag.coordTopological
1201
+ };
1202
+ var LAYOUT_FACTORIES = {
1203
+ sugiyama: () => (0, import_d3_dag.sugiyama)(),
1204
+ grid: () => (0, import_d3_dag.grid)(),
1205
+ zherebko: () => (0, import_d3_dag.zherebko)()
1206
+ };
1207
+ var DAG_ID_SEPARATOR = "::";
1208
+ var _D3DagLayout = class extends GraphLayout {
1209
+ _name = "D3DagLayout";
1210
+ _graph = null;
1211
+ _dag = null;
1212
+ _layoutOperator = null;
1213
+ _rawNodePositions = /* @__PURE__ */ new Map();
1214
+ _rawEdgePoints = /* @__PURE__ */ new Map();
1215
+ _nodePositions = /* @__PURE__ */ new Map();
1216
+ _edgePoints = /* @__PURE__ */ new Map();
1217
+ _edgeControlPoints = /* @__PURE__ */ new Map();
1218
+ _lockedNodePositions = /* @__PURE__ */ new Map();
1219
+ _dagBounds = null;
1220
+ _nodeLookup = /* @__PURE__ */ new Map();
1221
+ _stringIdLookup = /* @__PURE__ */ new Map();
1222
+ _edgeLookup = /* @__PURE__ */ new Map();
1223
+ _incomingParentMap = /* @__PURE__ */ new Map();
1224
+ _chainDescriptors = /* @__PURE__ */ new Map();
1225
+ _nodeToChainId = /* @__PURE__ */ new Map();
1226
+ _collapsedChainState = /* @__PURE__ */ new Map();
1227
+ _hiddenNodeIds = /* @__PURE__ */ new Set();
1167
1228
  constructor(options = {}) {
1168
- const _options = {
1169
- ..._GPUForceLayout.defaultOptions,
1170
- ...options
1171
- };
1172
- super(_options);
1173
- this._name = "GPU";
1174
- this._options = _options;
1175
- this._d3Graph = { nodes: [], edges: [] };
1176
- this._nodeMap = {};
1177
- this._edgeMap = {};
1229
+ super({ ..._D3DagLayout.defaultProps, ...options });
1178
1230
  }
1179
1231
  initializeGraph(graph) {
1232
+ this.updateGraph(graph);
1233
+ }
1234
+ updateGraph(graph) {
1180
1235
  this._graph = graph;
1181
- this._nodeMap = {};
1182
- this._edgeMap = {};
1183
- const d3Nodes = graph.getNodes().map((node) => {
1184
- const id = node.id;
1185
- const locked = node.getPropertyValue("locked") || false;
1186
- const x = node.getPropertyValue("x") || 0;
1187
- const y = node.getPropertyValue("y") || 0;
1188
- const collisionRadius = node.getPropertyValue("collisionRadius") || 0;
1189
- const d3Node = {
1190
- id,
1191
- x,
1192
- y,
1193
- fx: locked ? x : null,
1194
- fy: locked ? y : null,
1195
- collisionRadius,
1196
- locked
1197
- };
1198
- this._nodeMap[node.id] = d3Node;
1199
- return d3Node;
1200
- });
1201
- const d3Edges = graph.getEdges().map((edge) => {
1202
- const d3Edge = {
1203
- id: edge.id,
1204
- source: this._nodeMap[edge.getSourceNodeId()],
1205
- target: this._nodeMap[edge.getTargetNodeId()]
1206
- };
1207
- this._edgeMap[edge.id] = d3Edge;
1208
- return d3Edge;
1209
- });
1210
- this._d3Graph = {
1211
- nodes: d3Nodes,
1212
- edges: d3Edges
1213
- };
1236
+ this._nodeLookup = /* @__PURE__ */ new Map();
1237
+ this._stringIdLookup = /* @__PURE__ */ new Map();
1238
+ this._edgeLookup = /* @__PURE__ */ new Map();
1239
+ this._incomingParentMap = /* @__PURE__ */ new Map();
1240
+ this._chainDescriptors = /* @__PURE__ */ new Map();
1241
+ this._nodeToChainId = /* @__PURE__ */ new Map();
1242
+ this._hiddenNodeIds = /* @__PURE__ */ new Set();
1243
+ for (const node of graph.getNodes()) {
1244
+ const id = node.getId();
1245
+ const key = this._toDagId(id);
1246
+ this._nodeLookup.set(id, node);
1247
+ this._stringIdLookup.set(key, id);
1248
+ }
1249
+ for (const edge of graph.getEdges()) {
1250
+ if (!edge.isDirected()) {
1251
+ continue;
1252
+ }
1253
+ const key = this._edgeKey(edge.getSourceNodeId(), edge.getTargetNodeId());
1254
+ this._edgeLookup.set(key, edge);
1255
+ const targetId = edge.getTargetNodeId();
1256
+ const parents = this._incomingParentMap.get(targetId) ?? [];
1257
+ parents.push(edge.getSourceNodeId());
1258
+ this._incomingParentMap.set(targetId, parents);
1259
+ }
1214
1260
  }
1215
1261
  start() {
1216
- this._engageWorker();
1262
+ this._runLayout();
1217
1263
  }
1218
1264
  update() {
1219
- this._engageWorker();
1265
+ this._runLayout();
1220
1266
  }
1221
- _engageWorker() {
1222
- if (this._worker) {
1223
- this._worker.terminate();
1224
- }
1225
- this._worker = new Worker(new URL("./worker.js", import_meta2.url).href);
1226
- const { alpha, nBodyStrength, nBodyDistanceMin, nBodyDistanceMax, getCollisionRadius } = this._options;
1227
- this._worker.postMessage({
1228
- nodes: this._d3Graph.nodes,
1229
- edges: this._d3Graph.edges,
1230
- options: {
1231
- alpha,
1232
- nBodyStrength,
1233
- nBodyDistanceMin,
1234
- nBodyDistanceMax,
1235
- getCollisionRadius
1236
- }
1237
- });
1238
- this._worker.onmessage = (event) => {
1239
- switch (event.data.type) {
1240
- case "tick":
1241
- this.ticked(event.data);
1242
- break;
1243
- case "end":
1244
- this.ended(event.data);
1245
- break;
1246
- default:
1247
- break;
1248
- }
1249
- };
1267
+ resume() {
1268
+ this._runLayout();
1250
1269
  }
1251
- ticked(data) {
1270
+ stop() {
1252
1271
  }
1253
- ended(data) {
1254
- const { nodes, edges } = data;
1255
- this.updateD3Graph({ nodes, edges });
1272
+ toggleCollapsedChain(chainId) {
1273
+ if (!this._graph) {
1274
+ log.log(1, `D3DagLayout: toggleCollapsedChain(${chainId}) ignored (no graph)`);
1275
+ return;
1276
+ }
1277
+ if (!this._chainDescriptors.has(chainId)) {
1278
+ this._refreshCollapsedChains();
1279
+ }
1280
+ if (!this._chainDescriptors.has(chainId)) {
1281
+ log.log(1, `D3DagLayout: toggleCollapsedChain(${chainId}) skipped (unknown chain)`);
1282
+ return;
1283
+ }
1284
+ const collapsed = this._isChainCollapsed(chainId);
1285
+ const nextState = !collapsed;
1286
+ log.log(0, `D3DagLayout: toggleCollapsedChain(${chainId}) -> ${nextState ? "collapsed" : "expanded"}`);
1287
+ console.log(`D3DagLayout: toggleCollapsedChain(${chainId}) -> ${nextState ? "collapsed" : "expanded"}`);
1288
+ this._collapsedChainState.set(chainId, nextState);
1289
+ this._runLayout();
1290
+ }
1291
+ setCollapsedChains(chainIds) {
1292
+ if (!this._graph) {
1293
+ log.log(1, "D3DagLayout: setCollapsedChains ignored (no graph)");
1294
+ return;
1295
+ }
1296
+ if (!this._chainDescriptors.size) {
1297
+ this._refreshCollapsedChains();
1298
+ }
1299
+ const desired = new Set(chainIds);
1300
+ log.log(0, `D3DagLayout: setCollapsedChains(${desired.size}) requested`);
1301
+ let changed = false;
1302
+ for (const chainId of this._chainDescriptors.keys()) {
1303
+ const next = desired.has(chainId);
1304
+ if (this._isChainCollapsed(chainId) !== next) {
1305
+ this._collapsedChainState.set(chainId, next);
1306
+ changed = true;
1307
+ }
1308
+ }
1309
+ if (changed) {
1310
+ log.log(0, "D3DagLayout: setCollapsedChains -> changes detected, rerunning layout");
1311
+ console.log("D3DagLayout: setCollapsedChains -> changes detected, rerunning layout");
1312
+ this._runLayout();
1313
+ } else {
1314
+ log.log(1, "D3DagLayout: setCollapsedChains -> no changes");
1315
+ console.log("D3DagLayout: setCollapsedChains -> no changes");
1316
+ }
1317
+ }
1318
+ setPipelineOptions(options) {
1319
+ this._options = { ...this._options, ...options };
1320
+ if (options.layout !== void 0 || options.layering !== void 0 || options.decross !== void 0 || options.coord !== void 0 || options.nodeSize !== void 0 || options.gap !== void 0 || options.separation !== void 0) {
1321
+ this._layoutOperator = null;
1322
+ }
1323
+ if (options.collapseLinearChains !== void 0 && this._graph) {
1324
+ this._runLayout();
1325
+ }
1326
+ }
1327
+ getNodePosition(node) {
1328
+ if (this._shouldSkipNode(node.getId())) {
1329
+ return null;
1330
+ }
1331
+ const mappedId = this._mapNodeId(node.getId());
1332
+ return this._nodePositions.get(mappedId) || null;
1333
+ }
1334
+ getEdgePosition(edge) {
1335
+ const mappedSourceId = this._mapNodeId(edge.getSourceNodeId());
1336
+ const mappedTargetId = this._mapNodeId(edge.getTargetNodeId());
1337
+ if (mappedSourceId === mappedTargetId) {
1338
+ return null;
1339
+ }
1340
+ const sourcePosition = this._nodePositions.get(mappedSourceId);
1341
+ const targetPosition = this._nodePositions.get(mappedTargetId);
1342
+ if (!sourcePosition || !targetPosition) {
1343
+ return null;
1344
+ }
1345
+ if (!this._edgePoints.has(edge.getId())) {
1346
+ return null;
1347
+ }
1348
+ const controlPoints = this._edgeControlPoints.get(edge.getId()) || [];
1349
+ const edgeType = controlPoints.length ? "spline-curve" : "line";
1350
+ return {
1351
+ type: edgeType,
1352
+ sourcePosition,
1353
+ targetPosition,
1354
+ controlPoints
1355
+ };
1356
+ }
1357
+ getLinkControlPoints(edge) {
1358
+ return this._edgeControlPoints.get(edge.getId()) || [];
1359
+ }
1360
+ lockNodePosition(node, x, y) {
1361
+ this._lockedNodePositions.set(node.getId(), [x, y]);
1362
+ this._nodePositions.set(node.getId(), [x, y]);
1363
+ this._onLayoutChange();
1364
+ this._onLayoutDone();
1365
+ }
1366
+ unlockNodePosition(node) {
1367
+ this._lockedNodePositions.delete(node.getId());
1368
+ }
1369
+ _runLayout() {
1370
+ if (!this._graph) {
1371
+ return;
1372
+ }
1373
+ this._refreshCollapsedChains();
1374
+ this._onLayoutStart();
1375
+ try {
1376
+ this._dag = this._buildDag();
1377
+ const layout = this._getLayoutOperator();
1378
+ layout(this._dag);
1379
+ this._cacheGeometry();
1380
+ this._onLayoutChange();
1381
+ this._onLayoutDone();
1382
+ } catch (error2) {
1383
+ this._onLayoutError();
1384
+ throw error2;
1385
+ }
1386
+ }
1387
+ _refreshCollapsedChains() {
1388
+ const previousChainCount = this._chainDescriptors.size;
1389
+ if (!this._graph) {
1390
+ if (previousChainCount > 0) {
1391
+ log.log(0, "D3DagLayout: clearing collapsed chains (graph unavailable)");
1392
+ console.log("D3DagLayout: clearing collapsed chains (graph unavailable)");
1393
+ }
1394
+ this._chainDescriptors.clear();
1395
+ this._nodeToChainId.clear();
1396
+ this._hiddenNodeIds.clear();
1397
+ return;
1398
+ }
1399
+ log.log(0, `D3DagLayout: refreshing collapsed chains (previous=${previousChainCount})`);
1400
+ console.log(`D3DagLayout: refreshing collapsed chains (previous=${previousChainCount})`);
1401
+ const collapseDefault = this._options.collapseLinearChains ?? _D3DagLayout.defaultProps.collapseLinearChains;
1402
+ const previousStates = new Map(this._collapsedChainState);
1403
+ this._chainDescriptors.clear();
1404
+ this._nodeToChainId.clear();
1405
+ this._hiddenNodeIds.clear();
1406
+ const nodes = this._graph.getNodes();
1407
+ const candidateNodes = /* @__PURE__ */ new Set();
1408
+ const incomingCache = /* @__PURE__ */ new Map();
1409
+ const outgoingCache = /* @__PURE__ */ new Map();
1410
+ for (const node of nodes) {
1411
+ const incoming = this._getIncomingEdges(node);
1412
+ const outgoing = this._getOutgoingEdges(node);
1413
+ incomingCache.set(node.getId(), incoming);
1414
+ outgoingCache.set(node.getId(), outgoing);
1415
+ if (incoming.length <= 1 && outgoing.length <= 1 && incoming.length + outgoing.length > 0) {
1416
+ candidateNodes.add(node.getId());
1417
+ }
1418
+ }
1419
+ const visited = /* @__PURE__ */ new Set();
1420
+ for (const node of nodes) {
1421
+ const nodeId = node.getId();
1422
+ if (!candidateNodes.has(nodeId) || visited.has(nodeId)) {
1423
+ continue;
1424
+ }
1425
+ const incoming = incomingCache.get(nodeId) ?? [];
1426
+ const hasCandidateParent = incoming.length === 1 && candidateNodes.has(incoming[0].getSourceNodeId());
1427
+ if (hasCandidateParent) {
1428
+ continue;
1429
+ }
1430
+ const chainNodeIds = [];
1431
+ const chainEdgeIds = [];
1432
+ let currentNode = node;
1433
+ while (currentNode) {
1434
+ const currentId = currentNode.getId();
1435
+ if (!candidateNodes.has(currentId) || visited.has(currentId)) {
1436
+ break;
1437
+ }
1438
+ visited.add(currentId);
1439
+ chainNodeIds.push(currentId);
1440
+ const outgoing = outgoingCache.get(currentId) ?? [];
1441
+ if (outgoing.length !== 1) {
1442
+ break;
1443
+ }
1444
+ const nextEdge = outgoing[0];
1445
+ const nextNodeId = nextEdge.getTargetNodeId();
1446
+ if (!candidateNodes.has(nextNodeId)) {
1447
+ break;
1448
+ }
1449
+ const nextIncoming = incomingCache.get(nextNodeId) ?? [];
1450
+ if (nextIncoming.length !== 1) {
1451
+ break;
1452
+ }
1453
+ chainEdgeIds.push(nextEdge.getId());
1454
+ currentNode = this._nodeLookup.get(nextNodeId);
1455
+ }
1456
+ if (chainNodeIds.length > 1) {
1457
+ const chainId = this._createChainId(chainNodeIds);
1458
+ const collapsed = previousStates.has(chainId) ? previousStates.get(chainId) : collapseDefault;
1459
+ this._chainDescriptors.set(chainId, {
1460
+ id: chainId,
1461
+ nodeIds: chainNodeIds,
1462
+ edgeIds: chainEdgeIds,
1463
+ representativeId: chainNodeIds[0]
1464
+ });
1465
+ this._collapsedChainState.set(chainId, collapsed);
1466
+ for (const chainNodeId of chainNodeIds) {
1467
+ this._nodeToChainId.set(chainNodeId, chainId);
1468
+ }
1469
+ }
1470
+ }
1471
+ for (const key of previousStates.keys()) {
1472
+ if (!this._chainDescriptors.has(key)) {
1473
+ this._collapsedChainState.delete(key);
1474
+ }
1475
+ }
1476
+ this._hiddenNodeIds.clear();
1477
+ for (const [chainId, descriptor] of this._chainDescriptors) {
1478
+ const collapsed = this._isChainCollapsed(chainId);
1479
+ if (collapsed) {
1480
+ for (const nodeId of descriptor.nodeIds) {
1481
+ if (nodeId !== descriptor.representativeId) {
1482
+ this._hiddenNodeIds.add(nodeId);
1483
+ }
1484
+ }
1485
+ }
1486
+ }
1487
+ this._updateCollapsedChainNodeMetadata();
1488
+ let collapsedCount = 0;
1489
+ for (const chainId of this._chainDescriptors.keys()) {
1490
+ if (this._isChainCollapsed(chainId)) {
1491
+ collapsedCount++;
1492
+ }
1493
+ }
1494
+ log.log(0, `D3DagLayout: refreshed collapsed chains -> total=${this._chainDescriptors.size}, collapsed=${collapsedCount}`);
1495
+ }
1496
+ _buildDag() {
1497
+ const builder = this._options.dagBuilder ?? _D3DagLayout.defaultProps.dagBuilder;
1498
+ if (typeof builder === "function") {
1499
+ const dag = builder(this._graph);
1500
+ return this._ensureEdgeData(dag);
1501
+ }
1502
+ switch (builder) {
1503
+ case "connect":
1504
+ return this._buildDagWithConnect();
1505
+ case "stratify":
1506
+ return this._buildDagWithStratify();
1507
+ case "graph":
1508
+ default:
1509
+ return this._buildDagWithGraph();
1510
+ }
1511
+ }
1512
+ _buildDagWithGraph() {
1513
+ const dag = (0, import_d3_dag.graph)();
1514
+ const dagNodeLookup = /* @__PURE__ */ new Map();
1515
+ for (const node of this._graph.getNodes()) {
1516
+ if (this._shouldSkipNode(node.getId())) {
1517
+ continue;
1518
+ }
1519
+ const dagNode = dag.node(node);
1520
+ dagNodeLookup.set(node.getId(), dagNode);
1521
+ }
1522
+ for (const edge of this._graph.getEdges()) {
1523
+ if (!edge.isDirected()) {
1524
+ continue;
1525
+ }
1526
+ const sourceId = this._mapNodeId(edge.getSourceNodeId());
1527
+ const targetId = this._mapNodeId(edge.getTargetNodeId());
1528
+ if (sourceId === targetId) {
1529
+ continue;
1530
+ }
1531
+ const source = dagNodeLookup.get(sourceId);
1532
+ const target = dagNodeLookup.get(targetId);
1533
+ if (!source || !target) {
1534
+ continue;
1535
+ }
1536
+ dag.link(source, target, edge);
1537
+ }
1538
+ return dag;
1539
+ }
1540
+ _buildDagWithConnect() {
1541
+ const connect = (0, import_d3_dag.graphConnect)().sourceId(({ source }) => source).targetId(({ target }) => target).nodeDatum((id) => this._nodeLookup.get(this._fromDagId(id)) ?? new Node({ id })).single(true);
1542
+ const data = this._graph.getEdges().filter((edge) => edge.isDirected()).map((edge) => {
1543
+ const sourceId = this._mapNodeId(edge.getSourceNodeId());
1544
+ const targetId = this._mapNodeId(edge.getTargetNodeId());
1545
+ return { sourceId, targetId, edge };
1546
+ }).filter(({ sourceId, targetId }) => sourceId !== targetId).map(({ sourceId, targetId, edge }) => ({
1547
+ source: this._toDagId(sourceId),
1548
+ target: this._toDagId(targetId),
1549
+ edge
1550
+ }));
1551
+ const dag = connect(data);
1552
+ const seenIds = /* @__PURE__ */ new Set();
1553
+ for (const dagNode of dag.nodes()) {
1554
+ const datum = dagNode.data;
1555
+ if (datum instanceof Node) {
1556
+ seenIds.add(datum.getId());
1557
+ }
1558
+ }
1559
+ for (const node of this._graph.getNodes()) {
1560
+ if (this._shouldSkipNode(node.getId())) {
1561
+ continue;
1562
+ }
1563
+ if (!seenIds.has(node.getId())) {
1564
+ dag.node(node);
1565
+ }
1566
+ }
1567
+ return this._ensureEdgeData(dag);
1568
+ }
1569
+ _buildDagWithStratify() {
1570
+ const stratify = (0, import_d3_dag.graphStratify)().id((node) => this._toDagId(node.getId())).parentIds((node) => {
1571
+ const parentIds = this._incomingParentMap.get(node.getId()) ?? [];
1572
+ const mapped = /* @__PURE__ */ new Set();
1573
+ for (const parentId of parentIds) {
1574
+ if (!this._nodeLookup.has(parentId)) {
1575
+ continue;
1576
+ }
1577
+ const mappedId = this._mapNodeId(parentId);
1578
+ if (mappedId === node.getId()) {
1579
+ continue;
1580
+ }
1581
+ mapped.add(this._toDagId(mappedId));
1582
+ }
1583
+ return mapped;
1584
+ });
1585
+ const dag = stratify(this._graph.getNodes().filter((node) => !this._shouldSkipNode(node.getId())));
1586
+ return this._ensureEdgeData(dag);
1587
+ }
1588
+ _isChainCollapsed(chainId) {
1589
+ const collapseDefault = this._options.collapseLinearChains ?? _D3DagLayout.defaultProps.collapseLinearChains;
1590
+ return this._collapsedChainState.get(chainId) ?? collapseDefault;
1591
+ }
1592
+ _shouldSkipNode(nodeId) {
1593
+ return this._hiddenNodeIds.has(nodeId);
1594
+ }
1595
+ _mapNodeId(nodeId) {
1596
+ const chainId = this._nodeToChainId.get(nodeId);
1597
+ if (!chainId) {
1598
+ return nodeId;
1599
+ }
1600
+ const descriptor = this._chainDescriptors.get(chainId);
1601
+ if (!descriptor) {
1602
+ return nodeId;
1603
+ }
1604
+ return this._isChainCollapsed(chainId) ? descriptor.representativeId : nodeId;
1605
+ }
1606
+ _updateCollapsedChainNodeMetadata() {
1607
+ if (!this._graph) {
1608
+ return;
1609
+ }
1610
+ for (const node of this._graph.getNodes()) {
1611
+ const nodeId = node.getId();
1612
+ const chainId = this._nodeToChainId.get(nodeId);
1613
+ if (!chainId) {
1614
+ node.setDataProperty("collapsedChainId", null);
1615
+ node.setDataProperty("collapsedChainLength", 1);
1616
+ node.setDataProperty("collapsedNodeIds", []);
1617
+ node.setDataProperty("collapsedEdgeIds", []);
1618
+ node.setDataProperty("collapsedChainRepresentativeId", null);
1619
+ node.setDataProperty("isCollapsedChain", false);
1620
+ continue;
1621
+ }
1622
+ const descriptor = this._chainDescriptors.get(chainId);
1623
+ if (!descriptor) {
1624
+ node.setDataProperty("collapsedChainId", null);
1625
+ node.setDataProperty("collapsedChainLength", 1);
1626
+ node.setDataProperty("collapsedNodeIds", []);
1627
+ node.setDataProperty("collapsedEdgeIds", []);
1628
+ node.setDataProperty("collapsedChainRepresentativeId", null);
1629
+ node.setDataProperty("isCollapsedChain", false);
1630
+ continue;
1631
+ }
1632
+ const collapsed = this._isChainCollapsed(chainId);
1633
+ node.setDataProperty("collapsedChainId", chainId);
1634
+ node.setDataProperty("collapsedChainLength", collapsed ? descriptor.nodeIds.length : 1);
1635
+ node.setDataProperty("collapsedNodeIds", descriptor.nodeIds);
1636
+ node.setDataProperty("collapsedEdgeIds", descriptor.edgeIds);
1637
+ node.setDataProperty("collapsedChainRepresentativeId", descriptor.representativeId);
1638
+ node.setDataProperty("isCollapsedChain", collapsed);
1639
+ }
1640
+ }
1641
+ _createChainId(nodeIds) {
1642
+ return `chain:${nodeIds.map((id) => this._toDagId(id)).join(">")}`;
1643
+ }
1644
+ _getIncomingEdges(node) {
1645
+ const nodeId = node.getId();
1646
+ return node.getConnectedEdges().filter((edge) => edge.isDirected() && edge.getTargetNodeId() === nodeId);
1647
+ }
1648
+ _getOutgoingEdges(node) {
1649
+ const nodeId = node.getId();
1650
+ return node.getConnectedEdges().filter((edge) => edge.isDirected() && edge.getSourceNodeId() === nodeId);
1651
+ }
1652
+ _ensureEdgeData(dag) {
1653
+ for (const link of dag.links()) {
1654
+ if (link.data instanceof Edge) {
1655
+ continue;
1656
+ }
1657
+ const sourceNode = link.source.data;
1658
+ const targetNode = link.target.data;
1659
+ if (!(sourceNode instanceof Node) || !(targetNode instanceof Node)) {
1660
+ continue;
1661
+ }
1662
+ const key = this._edgeKey(sourceNode.getId(), targetNode.getId());
1663
+ const edge = this._edgeLookup.get(key);
1664
+ if (edge) {
1665
+ link.data = edge;
1666
+ }
1667
+ }
1668
+ return dag;
1669
+ }
1670
+ _getLayoutOperator() {
1671
+ if (this._layoutOperator) {
1672
+ return this._layoutOperator;
1673
+ }
1674
+ const layoutOption = this._options.layout ?? _D3DagLayout.defaultProps.layout;
1675
+ let layout;
1676
+ if (typeof layoutOption === "string") {
1677
+ layout = LAYOUT_FACTORIES[layoutOption]();
1678
+ } else {
1679
+ layout = layoutOption;
1680
+ }
1681
+ if (layout.layering && this._options.layering) {
1682
+ layout = layout.layering(this._resolveLayering(this._options.layering));
1683
+ }
1684
+ if (layout.decross && this._options.decross) {
1685
+ layout = layout.decross(this._resolveDecross(this._options.decross));
1686
+ }
1687
+ if (layout.coord && this._options.coord) {
1688
+ layout = layout.coord(this._resolveCoord(this._options.coord));
1689
+ }
1690
+ const nodeSize = this._options.nodeSize ?? DEFAULT_NODE_SIZE;
1691
+ if (layout.nodeSize) {
1692
+ layout = layout.nodeSize(nodeSize);
1693
+ }
1694
+ const gap = this._options.separation ?? this._options.gap ?? DEFAULT_GAP;
1695
+ if (layout.gap) {
1696
+ layout = layout.gap(gap);
1697
+ }
1698
+ this._layoutOperator = layout;
1699
+ return layout;
1700
+ }
1701
+ _resolveLayering(option) {
1702
+ if (typeof option === "string") {
1703
+ return LAYERING_FACTORIES[option]();
1704
+ }
1705
+ return option;
1706
+ }
1707
+ _resolveDecross(option) {
1708
+ if (typeof option === "string") {
1709
+ return DECROSS_FACTORIES[option]();
1710
+ }
1711
+ return option;
1712
+ }
1713
+ _resolveCoord(option) {
1714
+ if (typeof option === "string") {
1715
+ return COORD_FACTORIES[option]();
1716
+ }
1717
+ return option;
1718
+ }
1719
+ _cacheGeometry() {
1720
+ this._rawNodePositions.clear();
1721
+ this._rawEdgePoints.clear();
1722
+ if (!this._dag) {
1723
+ this._dagBounds = null;
1724
+ this._bounds = null;
1725
+ return;
1726
+ }
1727
+ let minX = Number.POSITIVE_INFINITY;
1728
+ let maxX = Number.NEGATIVE_INFINITY;
1729
+ let minY = Number.POSITIVE_INFINITY;
1730
+ let maxY = Number.NEGATIVE_INFINITY;
1731
+ for (const dagNode of this._dag.nodes()) {
1732
+ const node = dagNode.data;
1733
+ const id = node.getId();
1734
+ const x = dagNode.x ?? 0;
1735
+ const y = dagNode.y ?? 0;
1736
+ minX = Math.min(minX, x);
1737
+ maxX = Math.max(maxX, x);
1738
+ minY = Math.min(minY, y);
1739
+ maxY = Math.max(maxY, y);
1740
+ this._rawNodePositions.set(id, [x, y]);
1741
+ }
1742
+ if (minX === Number.POSITIVE_INFINITY) {
1743
+ this._dagBounds = null;
1744
+ this._bounds = null;
1745
+ this._nodePositions.clear();
1746
+ this._edgePoints.clear();
1747
+ this._edgeControlPoints.clear();
1748
+ return;
1749
+ }
1750
+ this._dagBounds = {
1751
+ minX,
1752
+ maxX,
1753
+ minY,
1754
+ maxY,
1755
+ centerX: (minX + maxX) / 2,
1756
+ centerY: (minY + maxY) / 2
1757
+ };
1758
+ for (const link of this._dag.links()) {
1759
+ const source = link.source.data;
1760
+ const target = link.target.data;
1761
+ const edge = link.data instanceof Edge ? link.data : this._edgeLookup.get(this._edgeKey(source.getId(), target.getId()));
1762
+ if (!edge) {
1763
+ continue;
1764
+ }
1765
+ const points = link.points && link.points.length ? link.points : [[link.source.x ?? 0, link.source.y ?? 0], [link.target.x ?? 0, link.target.y ?? 0]];
1766
+ this._rawEdgePoints.set(edge.getId(), points.map((point) => [...point]));
1767
+ }
1768
+ this._updateTransformedGeometry();
1769
+ }
1770
+ _updateTransformedGeometry() {
1771
+ this._nodePositions.clear();
1772
+ this._edgePoints.clear();
1773
+ this._edgeControlPoints.clear();
1774
+ if (!this._dagBounds) {
1775
+ this._bounds = null;
1776
+ return;
1777
+ }
1778
+ const { offsetX, offsetY } = this._getOffsets();
1779
+ const orientation = this._options.orientation ?? _D3DagLayout.defaultProps.orientation;
1780
+ const transform = (x, y) => {
1781
+ const localX = x - offsetX;
1782
+ const localY = y - offsetY;
1783
+ switch (orientation) {
1784
+ case "BT":
1785
+ return [localX, localY];
1786
+ case "LR":
1787
+ return [localY, localX];
1788
+ case "RL":
1789
+ return [-localY, localX];
1790
+ case "TB":
1791
+ default:
1792
+ return [localX, -localY];
1793
+ }
1794
+ };
1795
+ for (const [id, [x, y]] of this._rawNodePositions) {
1796
+ this._nodePositions.set(id, transform(x, y));
1797
+ }
1798
+ for (const [edgeId, points] of this._rawEdgePoints) {
1799
+ const transformed = points.map(([x, y]) => transform(x, y));
1800
+ this._edgePoints.set(edgeId, transformed);
1801
+ this._edgeControlPoints.set(edgeId, transformed.length > 2 ? transformed.slice(1, -1) : []);
1802
+ }
1803
+ for (const [id, position] of this._lockedNodePositions) {
1804
+ this._nodePositions.set(id, position);
1805
+ }
1806
+ this._bounds = this._calculateBounds(this._nodePositions.values());
1807
+ }
1808
+ _getOffsets() {
1809
+ if (!this._dagBounds) {
1810
+ return { offsetX: 0, offsetY: 0 };
1811
+ }
1812
+ const centerOption = this._options.center ?? true;
1813
+ let offsetX = 0;
1814
+ let offsetY = 0;
1815
+ if (centerOption === true) {
1816
+ offsetX = this._dagBounds.centerX;
1817
+ offsetY = this._dagBounds.centerY;
1818
+ } else if (centerOption && typeof centerOption === "object") {
1819
+ if (centerOption.x) {
1820
+ offsetX = this._dagBounds.centerX;
1821
+ }
1822
+ if (centerOption.y) {
1823
+ offsetY = this._dagBounds.centerY;
1824
+ }
1825
+ }
1826
+ return { offsetX, offsetY };
1827
+ }
1828
+ _updateBounds() {
1829
+ this._bounds = this._calculateBounds(this._nodePositions.values());
1830
+ }
1831
+ _edgeKey(sourceId, targetId) {
1832
+ return `${this._toDagId(sourceId)}${DAG_ID_SEPARATOR}${this._toDagId(targetId)}`;
1833
+ }
1834
+ _toDagId(id) {
1835
+ return String(id);
1836
+ }
1837
+ _fromDagId(id) {
1838
+ return this._stringIdLookup.get(id) ?? id;
1839
+ }
1840
+ };
1841
+ var D3DagLayout = _D3DagLayout;
1842
+ __publicField(D3DagLayout, "defaultProps", {
1843
+ layout: "sugiyama",
1844
+ layering: "topological",
1845
+ decross: "twoLayer",
1846
+ coord: "greedy",
1847
+ nodeSize: DEFAULT_NODE_SIZE,
1848
+ gap: DEFAULT_GAP,
1849
+ separation: DEFAULT_GAP,
1850
+ orientation: "TB",
1851
+ center: true,
1852
+ dagBuilder: "graph",
1853
+ collapseLinearChains: false
1854
+ });
1855
+
1856
+ // dist/layouts/gpu-force/gpu-force-layout.js
1857
+ var import_meta2 = {};
1858
+ var _GPUForceLayout = class extends GraphLayout {
1859
+ _name = "GPU";
1860
+ _d3Graph;
1861
+ _nodeMap;
1862
+ _edgeMap;
1863
+ _graph;
1864
+ _worker = null;
1865
+ _callbacks;
1866
+ constructor(options = {}) {
1867
+ const _options = {
1868
+ ..._GPUForceLayout.defaultProps,
1869
+ ...options
1870
+ };
1871
+ super(_options);
1872
+ this._name = "GPU";
1873
+ this._options = _options;
1874
+ this._d3Graph = { nodes: [], edges: [] };
1875
+ this._nodeMap = {};
1876
+ this._edgeMap = {};
1877
+ this._callbacks = {
1878
+ onLayoutChange: this._onLayoutChange,
1879
+ onLayoutDone: this._onLayoutDone
1880
+ };
1881
+ }
1882
+ initializeGraph(graph) {
1883
+ this._graph = graph;
1884
+ this._nodeMap = {};
1885
+ this._edgeMap = {};
1886
+ const d3Nodes = graph.getNodes().map((node) => {
1887
+ const id = node.id;
1888
+ const locked = node.getPropertyValue("locked") || false;
1889
+ const x = node.getPropertyValue("x") || 0;
1890
+ const y = node.getPropertyValue("y") || 0;
1891
+ const collisionRadius = node.getPropertyValue("collisionRadius") || 0;
1892
+ const d3Node = {
1893
+ id,
1894
+ x,
1895
+ y,
1896
+ fx: locked ? x : null,
1897
+ fy: locked ? y : null,
1898
+ collisionRadius,
1899
+ locked
1900
+ };
1901
+ this._nodeMap[node.id] = d3Node;
1902
+ return d3Node;
1903
+ });
1904
+ const d3Edges = graph.getEdges().map((edge) => {
1905
+ const d3Edge = {
1906
+ id: edge.id,
1907
+ source: this._nodeMap[edge.getSourceNodeId()],
1908
+ target: this._nodeMap[edge.getTargetNodeId()]
1909
+ };
1910
+ this._edgeMap[edge.id] = d3Edge;
1911
+ return d3Edge;
1912
+ });
1913
+ this._d3Graph = {
1914
+ nodes: d3Nodes,
1915
+ edges: d3Edges
1916
+ };
1917
+ }
1918
+ start() {
1919
+ this._engageWorker();
1920
+ }
1921
+ update() {
1922
+ this._engageWorker();
1923
+ }
1924
+ _engageWorker() {
1925
+ if (this._worker) {
1926
+ this._worker.terminate();
1927
+ }
1928
+ this._worker = new Worker(new URL("./worker.js", import_meta2.url).href);
1929
+ const { alpha, nBodyStrength, nBodyDistanceMin, nBodyDistanceMax, getCollisionRadius } = this._options;
1930
+ this._worker.postMessage({
1931
+ nodes: this._d3Graph.nodes,
1932
+ edges: this._d3Graph.edges,
1933
+ options: {
1934
+ alpha,
1935
+ nBodyStrength,
1936
+ nBodyDistanceMin,
1937
+ nBodyDistanceMax,
1938
+ getCollisionRadius
1939
+ }
1940
+ });
1941
+ this._worker.onmessage = (event) => {
1942
+ switch (event.data.type) {
1943
+ case "tick":
1944
+ this.ticked(event.data);
1945
+ break;
1946
+ case "end":
1947
+ this.ended(event.data);
1948
+ break;
1949
+ default:
1950
+ break;
1951
+ }
1952
+ };
1953
+ }
1954
+ ticked(data) {
1955
+ }
1956
+ ended(data) {
1957
+ const { nodes, edges } = data;
1958
+ this.updateD3Graph({ nodes, edges });
1256
1959
  this._onLayoutChange();
1257
1960
  this._onLayoutDone();
1258
1961
  }
@@ -1260,7 +1963,10 @@ var _GPUForceLayout = class extends GraphLayout {
1260
1963
  throw new Error("Resume unavailable");
1261
1964
  }
1262
1965
  stop() {
1263
- this._worker.terminate();
1966
+ if (this._worker) {
1967
+ this._worker.terminate();
1968
+ this._worker = null;
1969
+ }
1264
1970
  }
1265
1971
  // for steaming new data on the same graph
1266
1972
  updateGraph(graph) {
@@ -1335,14 +2041,14 @@ var _GPUForceLayout = class extends GraphLayout {
1335
2041
  const targetPosition = d3Edge && d3Edge.target;
1336
2042
  if (d3Edge && sourcePosition && targetPosition) {
1337
2043
  return {
1338
- type: EDGE_TYPE.LINE,
2044
+ type: "line",
1339
2045
  sourcePosition: [sourcePosition.x, sourcePosition.y],
1340
2046
  targetPosition: [targetPosition.x, targetPosition.y],
1341
2047
  controlPoints: []
1342
2048
  };
1343
2049
  }
1344
2050
  return {
1345
- type: EDGE_TYPE.LINE,
2051
+ type: "line",
1346
2052
  sourcePosition: [0, 0],
1347
2053
  targetPosition: [0, 0],
1348
2054
  controlPoints: []
@@ -1362,9 +2068,13 @@ var _GPUForceLayout = class extends GraphLayout {
1362
2068
  d3Node.fx = null;
1363
2069
  d3Node.fy = null;
1364
2070
  };
2071
+ _updateBounds() {
2072
+ const positions = Object.values(this._nodeMap ?? {}).map((node) => this._normalizePosition(node));
2073
+ this._bounds = this._calculateBounds(positions);
2074
+ }
1365
2075
  };
1366
2076
  var GPUForceLayout = _GPUForceLayout;
1367
- __publicField(GPUForceLayout, "defaultOptions", {
2077
+ __publicField(GPUForceLayout, "defaultProps", {
1368
2078
  alpha: 0.3,
1369
2079
  resumeAlpha: 0.1,
1370
2080
  nBodyStrength: -900,
@@ -1420,7 +2130,7 @@ var _RadialLayout = class extends GraphLayout {
1420
2130
  constructor(options = {}) {
1421
2131
  super(options);
1422
2132
  this._options = {
1423
- ..._RadialLayout.defaultOptions,
2133
+ ..._RadialLayout.defaultProps,
1424
2134
  ...options
1425
2135
  };
1426
2136
  }
@@ -1471,6 +2181,12 @@ var _RadialLayout = class extends GraphLayout {
1471
2181
  this._onLayoutChange();
1472
2182
  this._onLayoutDone();
1473
2183
  }
2184
+ stop() {
2185
+ }
2186
+ resume() {
2187
+ }
2188
+ update() {
2189
+ }
1474
2190
  getNodePosition = (node) => {
1475
2191
  return this._hierarchicalPoints[node.id];
1476
2192
  };
@@ -1502,7 +2218,7 @@ var _RadialLayout = class extends GraphLayout {
1502
2218
  wayPoints.push(this._hierarchicalPoints[nodeId]);
1503
2219
  }
1504
2220
  return {
1505
- type: EDGE_TYPE.SPLINE_CURVE,
2221
+ type: "spline-curve",
1506
2222
  sourcePosition: sourceNodePos,
1507
2223
  targetPosition: targetNodePos,
1508
2224
  controlPoints: wayPoints
@@ -1513,9 +2229,13 @@ var _RadialLayout = class extends GraphLayout {
1513
2229
  this._onLayoutChange();
1514
2230
  this._onLayoutDone();
1515
2231
  };
2232
+ _updateBounds() {
2233
+ const positions = Object.values(this._hierarchicalPoints ?? {}).map((position) => this._normalizePosition(position));
2234
+ this._bounds = this._calculateBounds(positions);
2235
+ }
1516
2236
  };
1517
2237
  var RadialLayout = _RadialLayout;
1518
- __publicField(RadialLayout, "defaultOptions", {
2238
+ __publicField(RadialLayout, "defaultProps", {
1519
2239
  radius: 500
1520
2240
  });
1521
2241
  function rotate(cx, cy, x, y, angle) {
@@ -1541,7 +2261,7 @@ var _ForceMultiGraphLayout = class extends GraphLayout {
1541
2261
  constructor(options = {}) {
1542
2262
  super(options);
1543
2263
  this._options = {
1544
- ..._ForceMultiGraphLayout.defaultOptions,
2264
+ ..._ForceMultiGraphLayout.defaultProps,
1545
2265
  ...options
1546
2266
  };
1547
2267
  }
@@ -1576,6 +2296,8 @@ var _ForceMultiGraphLayout = class extends GraphLayout {
1576
2296
  stop() {
1577
2297
  this._simulator.stop();
1578
2298
  }
2299
+ update() {
2300
+ }
1579
2301
  updateGraph(graph) {
1580
2302
  this._graph = graph;
1581
2303
  const newNodeMap = {};
@@ -1602,7 +2324,7 @@ var _ForceMultiGraphLayout = class extends GraphLayout {
1602
2324
  const firstEdge = betweenEdges[0];
1603
2325
  if (betweenEdges.length === 1) {
1604
2326
  const newD3Edge2 = {
1605
- type: EDGE_TYPE.LINE,
2327
+ type: "line",
1606
2328
  id: firstEdge.getId(),
1607
2329
  source: newNodeMap[firstEdge.getSourceNodeId()],
1608
2330
  target: newNodeMap[firstEdge.getTargetNodeId()],
@@ -1613,7 +2335,7 @@ var _ForceMultiGraphLayout = class extends GraphLayout {
1613
2335
  return;
1614
2336
  }
1615
2337
  const newD3Edge = {
1616
- type: EDGE_TYPE.LINE,
2338
+ type: "line",
1617
2339
  id: pairId,
1618
2340
  source: newNodeMap[firstEdge.getSourceNodeId()],
1619
2341
  target: newNodeMap[firstEdge.getTargetNodeId()],
@@ -1624,7 +2346,7 @@ var _ForceMultiGraphLayout = class extends GraphLayout {
1624
2346
  newD3Edges.push(newD3Edge);
1625
2347
  betweenEdges.forEach((e, idx) => {
1626
2348
  newEdgeMap[e.id] = {
1627
- type: EDGE_TYPE.SPLINE_CURVE,
2349
+ type: "spline-curve",
1628
2350
  id: e.id,
1629
2351
  source: newNodeMap[e.getSourceNodeId()],
1630
2352
  target: newNodeMap[e.getTargetNodeId()],
@@ -1651,7 +2373,7 @@ var _ForceMultiGraphLayout = class extends GraphLayout {
1651
2373
  if (d3Edge) {
1652
2374
  if (!d3Edge.isVirtual) {
1653
2375
  return {
1654
- type: EDGE_TYPE.LINE,
2376
+ type: "line",
1655
2377
  sourcePosition: [d3Edge.source.x, d3Edge.source.y],
1656
2378
  targetPosition: [d3Edge.target.x, d3Edge.target.y],
1657
2379
  controlPoints: []
@@ -1668,14 +2390,14 @@ var _ForceMultiGraphLayout = class extends GraphLayout {
1668
2390
  const offset = Math.max(distance / 10, 5) * (symmetricShape ? Math.floor(index / 2 + 1) : Math.ceil(index / 2));
1669
2391
  const controlPoint = computeControlPoint(sourcePosition, targetPosition, direction, offset);
1670
2392
  return {
1671
- type: EDGE_TYPE.SPLINE_CURVE,
2393
+ type: "spline-curve",
1672
2394
  sourcePosition,
1673
2395
  targetPosition,
1674
2396
  controlPoints: [controlPoint]
1675
2397
  };
1676
2398
  }
1677
2399
  return {
1678
- type: EDGE_TYPE.LINE,
2400
+ type: "line",
1679
2401
  sourcePosition: [0, 0],
1680
2402
  targetPosition: [0, 0],
1681
2403
  controlPoints: []
@@ -1688,9 +2410,13 @@ var _ForceMultiGraphLayout = class extends GraphLayout {
1688
2410
  this._onLayoutChange();
1689
2411
  this._onLayoutDone();
1690
2412
  };
2413
+ _updateBounds() {
2414
+ const positions = Object.values(this._nodeMap ?? {}).map((node) => this._normalizePosition(node));
2415
+ this._bounds = this._calculateBounds(positions);
2416
+ }
1691
2417
  };
1692
2418
  var ForceMultiGraphLayout = _ForceMultiGraphLayout;
1693
- __publicField(ForceMultiGraphLayout, "defaultOptions", {
2419
+ __publicField(ForceMultiGraphLayout, "defaultProps", {
1694
2420
  alpha: 3,
1695
2421
  nBodyStrength: -1200,
1696
2422
  nBodyDistanceMin: 100,
@@ -1720,7 +2446,7 @@ var _HivePlotLayout = class extends GraphLayout {
1720
2446
  constructor(options = {}) {
1721
2447
  super(options);
1722
2448
  this._options = {
1723
- ..._HivePlotLayout.defaultOptions,
2449
+ ..._HivePlotLayout.defaultProps,
1724
2450
  ...options
1725
2451
  };
1726
2452
  }
@@ -1776,6 +2502,12 @@ var _HivePlotLayout = class extends GraphLayout {
1776
2502
  this._onLayoutChange();
1777
2503
  this._onLayoutDone();
1778
2504
  }
2505
+ stop() {
2506
+ }
2507
+ update() {
2508
+ }
2509
+ resume() {
2510
+ }
1779
2511
  getNodePosition = (node) => this._nodePositionMap[node.getId()];
1780
2512
  getEdgePosition = (edge) => {
1781
2513
  const { getNodeAxis } = this._options;
@@ -1789,7 +2521,7 @@ var _HivePlotLayout = class extends GraphLayout {
1789
2521
  const targetNodeAxis = getNodeAxis(targetNode);
1790
2522
  if (sourceNodeAxis === targetNodeAxis) {
1791
2523
  return {
1792
- type: EDGE_TYPE.LINE,
2524
+ type: "line",
1793
2525
  sourcePosition,
1794
2526
  targetPosition,
1795
2527
  controlPoints: []
@@ -1803,7 +2535,7 @@ var _HivePlotLayout = class extends GraphLayout {
1803
2535
  totalAxis: this._totalAxis
1804
2536
  });
1805
2537
  return {
1806
- type: EDGE_TYPE.SPLINE_CURVE,
2538
+ type: "spline-curve",
1807
2539
  sourcePosition,
1808
2540
  targetPosition,
1809
2541
  controlPoints: [controlPoint]
@@ -1814,9 +2546,13 @@ var _HivePlotLayout = class extends GraphLayout {
1814
2546
  this._onLayoutChange();
1815
2547
  this._onLayoutDone();
1816
2548
  };
2549
+ _updateBounds() {
2550
+ const positions = Object.values(this._nodePositionMap ?? {}).map((position) => this._normalizePosition(position));
2551
+ this._bounds = this._calculateBounds(positions);
2552
+ }
1817
2553
  };
1818
2554
  var HivePlotLayout = _HivePlotLayout;
1819
- __publicField(HivePlotLayout, "defaultOptions", {
2555
+ __publicField(HivePlotLayout, "defaultProps", {
1820
2556
  innerRadius: 100,
1821
2557
  outerRadius: 500,
1822
2558
  getNodeAxis: (node) => node.getPropertyValue("group")
@@ -1842,10 +2578,15 @@ function computeControlPoint2({ sourcePosition, sourceNodeAxis, targetPosition,
1842
2578
  }
1843
2579
 
1844
2580
  // dist/layers/graph-layer.js
1845
- var import_core16 = require("@deck.gl/core");
2581
+ var import_core17 = require("@deck.gl/core");
2582
+ var import_layers12 = require("@deck.gl/layers");
2583
+
2584
+ // dist/style/graph-style-engine.js
2585
+ var import_zod2 = require("zod");
1846
2586
 
1847
2587
  // dist/style/style-property.js
1848
2588
  var import_color = __toESM(require("color"), 1);
2589
+ var import_d3_scale = require("d3-scale");
1849
2590
  function getColor(value) {
1850
2591
  if (typeof value === "string") {
1851
2592
  try {
@@ -1854,7 +2595,7 @@ function getColor(value) {
1854
2595
  color[3] *= 255;
1855
2596
  }
1856
2597
  return color;
1857
- } catch (error) {
2598
+ } catch (error2) {
1858
2599
  return [0, 0, 0];
1859
2600
  }
1860
2601
  }
@@ -1949,93 +2690,588 @@ var DEFAULT_STYLES = {
1949
2690
  offset: null,
1950
2691
  scaleWithZoom: true
1951
2692
  };
1952
- function generateAccessor(key, value) {
2693
+ var SCALE_FACTORIES = {
2694
+ linear: () => (0, import_d3_scale.scaleLinear)(),
2695
+ log: () => (0, import_d3_scale.scaleLog)(),
2696
+ pow: () => (0, import_d3_scale.scalePow)(),
2697
+ sqrt: () => (0, import_d3_scale.scaleSqrt)(),
2698
+ quantize: () => (0, import_d3_scale.scaleQuantize)(),
2699
+ quantile: () => (0, import_d3_scale.scaleQuantile)(),
2700
+ ordinal: () => (0, import_d3_scale.scaleOrdinal)()
2701
+ };
2702
+ function createScaleFromConfig(config) {
2703
+ const type = config.type ?? "linear";
2704
+ const factory = SCALE_FACTORIES[type];
2705
+ if (!factory) {
2706
+ warn(`Invalid scale type: ${type}`);
2707
+ throw new Error(`Invalid scale type: ${type}`);
2708
+ }
2709
+ const scale = factory();
2710
+ const anyScale = scale;
2711
+ if (config.domain && "domain" in scale) {
2712
+ anyScale.domain(config.domain);
2713
+ }
2714
+ if (config.range && "range" in scale) {
2715
+ anyScale.range(config.range);
2716
+ }
2717
+ if (typeof config.clamp === "boolean" && "clamp" in scale && typeof anyScale.clamp === "function") {
2718
+ anyScale.clamp(config.clamp);
2719
+ }
2720
+ if (typeof config.nice !== "undefined" && "nice" in scale && typeof anyScale.nice === "function") {
2721
+ anyScale.nice(config.nice);
2722
+ }
2723
+ if (type === "pow" && typeof config.exponent === "number" && "exponent" in scale && typeof anyScale.exponent === "function") {
2724
+ anyScale.exponent(config.exponent);
2725
+ }
2726
+ if (type === "log" && typeof config.base === "number" && "base" in scale && typeof anyScale.base === "function") {
2727
+ anyScale.base(config.base);
2728
+ }
2729
+ if (typeof config.unknown !== "undefined" && "unknown" in scale && typeof scale.unknown === "function") {
2730
+ scale.unknown(config.unknown);
2731
+ }
2732
+ return scale;
2733
+ }
2734
+ function normalizeAttributeReference(key, reference) {
2735
+ if (typeof reference === "string") {
2736
+ const attribute2 = reference.startsWith("@") ? reference.slice(1) : reference;
2737
+ if (!attribute2) {
2738
+ throw new Error(`Invalid attribute reference for ${key}: ${reference}`);
2739
+ }
2740
+ return {
2741
+ attribute: attribute2,
2742
+ fallback: DEFAULT_STYLES[key]
2743
+ };
2744
+ }
2745
+ const { attribute, fallback = DEFAULT_STYLES[key], scale } = reference;
2746
+ if (!attribute) {
2747
+ throw new Error(`Invalid attribute reference for ${key}: ${JSON.stringify(reference)}`);
2748
+ }
2749
+ let scaleFn;
2750
+ let scaleConfig;
2751
+ if (scale) {
2752
+ if (typeof scale === "function") {
2753
+ scaleFn = scale;
2754
+ scaleConfig = scale;
2755
+ } else {
2756
+ scaleFn = createScaleFromConfig(scale);
2757
+ scaleConfig = scale;
2758
+ }
2759
+ }
2760
+ return {
2761
+ attribute,
2762
+ fallback,
2763
+ scale: scaleFn,
2764
+ scaleConfig
2765
+ };
2766
+ }
2767
+ function isAttributeReference(value) {
2768
+ if (typeof value === "string") {
2769
+ return value.startsWith("@");
2770
+ }
2771
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value) && "attribute" in value;
2772
+ }
2773
+ function isStatefulValue(value) {
2774
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value) && !isAttributeReference(value);
2775
+ }
2776
+ function getAttributeValue(datum, attribute) {
2777
+ if (datum && typeof datum.getPropertyValue === "function") {
2778
+ return datum.getPropertyValue(attribute);
2779
+ }
2780
+ if (datum && typeof datum === "object" && attribute in datum) {
2781
+ return datum[attribute];
2782
+ }
2783
+ return void 0;
2784
+ }
2785
+ function mergeUpdateTriggers(...triggers) {
2786
+ const filtered = triggers.filter((trigger) => !(trigger === false || trigger === void 0 || trigger === null));
2787
+ if (!filtered.length) {
2788
+ return false;
2789
+ }
2790
+ if (filtered.length === 1) {
2791
+ return filtered[0];
2792
+ }
2793
+ return filtered;
2794
+ }
2795
+ function createAttributeAccessor(key, attributeRef, formatter) {
2796
+ const accessor = (datum) => {
2797
+ let raw = getAttributeValue(datum, attributeRef.attribute);
2798
+ if (raw === void 0 || raw === null) {
2799
+ raw = attributeRef.fallback;
2800
+ }
2801
+ if (attributeRef.scale) {
2802
+ raw = attributeRef.scale(raw);
2803
+ }
2804
+ const formatted = formatter(raw);
2805
+ if (formatted === null) {
2806
+ warn(`Invalid ${key} value: ${raw}`);
2807
+ throw new Error(`Invalid ${key} value: ${raw}`);
2808
+ }
2809
+ return formatted;
2810
+ };
2811
+ const updateTrigger = {
2812
+ attribute: attributeRef.attribute,
2813
+ scale: attributeRef.scaleConfig ?? null
2814
+ };
2815
+ return { accessor, updateTrigger };
2816
+ }
2817
+ function describeStyleValue(value) {
2818
+ if (typeof value === "string") {
2819
+ return value;
2820
+ }
2821
+ if (typeof value === "number" || typeof value === "boolean" || typeof value === "undefined") {
2822
+ return String(value);
2823
+ }
2824
+ if (value === null) {
2825
+ return "null";
2826
+ }
2827
+ if (typeof value === "function") {
2828
+ return value.name ? `[Function ${value.name}]` : "[Function]";
2829
+ }
2830
+ if (Array.isArray(value)) {
2831
+ return `[${value.map((item) => describeStyleValue(item)).join(", ")}]`;
2832
+ }
2833
+ try {
2834
+ return JSON.stringify(value);
2835
+ } catch {
2836
+ return String(value);
2837
+ }
2838
+ }
2839
+ function parseLeafValue(key, value) {
1953
2840
  const formatter = PROPERTY_FORMATTERS[key] || IDENTITY;
1954
- const valueMap = Object.keys(value).reduce((res, key0) => {
1955
- res[key0] = value[key0];
1956
- return res;
1957
- }, {});
1958
- return (node) => {
1959
- const statefulValue = valueMap[node.state];
1960
- if (!node.state || typeof statefulValue === "undefined") {
1961
- return valueMap.default || DEFAULT_STYLES[key];
2841
+ if (typeof value === "undefined") {
2842
+ const formatted2 = formatter(DEFAULT_STYLES[key]);
2843
+ if (formatted2 === null) {
2844
+ const description = describeStyleValue(value);
2845
+ warn(`Invalid ${key} value: ${description}`);
2846
+ throw new Error(`Invalid ${key} value: ${description}`);
1962
2847
  }
1963
- if (typeof statefulValue === "function") {
1964
- return formatter(statefulValue(node));
2848
+ return { value: formatted2, isAccessor: false, updateTrigger: false };
2849
+ }
2850
+ if (isAttributeReference(value)) {
2851
+ const normalized = normalizeAttributeReference(key, value);
2852
+ const { accessor, updateTrigger } = createAttributeAccessor(key, normalized, formatter);
2853
+ return { value: accessor, isAccessor: true, updateTrigger };
2854
+ }
2855
+ if (typeof value === "function") {
2856
+ return {
2857
+ value: (datum) => formatter(value(datum)),
2858
+ isAccessor: true,
2859
+ updateTrigger: value
2860
+ };
2861
+ }
2862
+ const formatted = formatter(value);
2863
+ if (formatted === null) {
2864
+ const description = describeStyleValue(value);
2865
+ warn(`Invalid ${key} value: ${description}`);
2866
+ throw new Error(`Invalid ${key} value: ${description}`);
2867
+ }
2868
+ return { value: formatted, isAccessor: false, updateTrigger: false };
2869
+ }
2870
+ function createStatefulAccessor(key, value, stateUpdateTrigger) {
2871
+ const valueMap = {};
2872
+ const attributeTriggers = [];
2873
+ for (const state of Object.keys(value)) {
2874
+ const parsed = parseLeafValue(key, value[state]);
2875
+ valueMap[state] = parsed.value;
2876
+ if (parsed.updateTrigger) {
2877
+ attributeTriggers.push(parsed.updateTrigger);
1965
2878
  }
1966
- return formatter(statefulValue);
2879
+ }
2880
+ const defaultValue = typeof valueMap.default !== "undefined" ? valueMap.default : parseLeafValue(key, void 0).value;
2881
+ const accessor = (datum) => {
2882
+ const stateValue = (datum == null ? void 0 : datum.state) ? valueMap[datum.state] : void 0;
2883
+ const candidate = typeof stateValue !== "undefined" ? stateValue : defaultValue;
2884
+ return typeof candidate === "function" ? candidate(datum) : candidate;
1967
2885
  };
2886
+ const updateTrigger = mergeUpdateTriggers(stateUpdateTrigger, ...attributeTriggers);
2887
+ return { accessor, updateTrigger };
1968
2888
  }
1969
2889
  var VALUE_TYPE = {
1970
2890
  ACCESSOR: "ACCESSOR",
1971
2891
  PLAIN_VALUE: "PLAIN_VALUE"
1972
2892
  };
1973
- var StyleProperty = class {
1974
- key;
1975
- _updateTrigger;
1976
- _value;
1977
- _valueType;
1978
- // for getting default style
1979
- static getDefault(key) {
1980
- return DEFAULT_STYLES[key];
2893
+ var StyleProperty = class {
2894
+ key;
2895
+ _updateTrigger;
2896
+ _value;
2897
+ _valueType;
2898
+ // for getting default style
2899
+ static getDefault(key) {
2900
+ return DEFAULT_STYLES[key];
2901
+ }
2902
+ // pass the key and value of the property
2903
+ // and format the value properly.
2904
+ constructor({ key, value, updateTrigger }) {
2905
+ this.key = key;
2906
+ this._updateTrigger = false;
2907
+ if (isStatefulValue(value)) {
2908
+ const { accessor, updateTrigger: triggers } = createStatefulAccessor(key, value, updateTrigger);
2909
+ this._value = accessor;
2910
+ this._valueType = VALUE_TYPE.ACCESSOR;
2911
+ this._updateTrigger = triggers;
2912
+ } else {
2913
+ const parsed = parseLeafValue(key, value);
2914
+ this._value = parsed.value;
2915
+ this._valueType = parsed.isAccessor ? VALUE_TYPE.ACCESSOR : VALUE_TYPE.PLAIN_VALUE;
2916
+ this._updateTrigger = mergeUpdateTriggers(parsed.updateTrigger);
2917
+ }
2918
+ if (this._value === null) {
2919
+ warn(`Invalid ${key} value: ${value}`);
2920
+ throw new Error(`Invalid ${key} value: ${value}`);
2921
+ }
2922
+ }
2923
+ // get the formatted value
2924
+ getValue() {
2925
+ return this._value;
2926
+ }
2927
+ getUpdateTrigger() {
2928
+ return this._updateTrigger;
2929
+ }
2930
+ };
2931
+
2932
+ // dist/style/style-engine.js
2933
+ var DEFAULT_UPDATE_TRIGGERS = {};
2934
+ var StyleEngine = class {
2935
+ type;
2936
+ properties;
2937
+ deckglAccessorMap;
2938
+ deckglUpdateTriggers;
2939
+ stateUpdateTrigger;
2940
+ StylePropertyClass;
2941
+ getDefaultStyleValue;
2942
+ constructor(style, options) {
2943
+ const {
2944
+ deckglAccessorMap,
2945
+ deckglUpdateTriggers = DEFAULT_UPDATE_TRIGGERS,
2946
+ stateUpdateTrigger = false,
2947
+ StylePropertyClass = StyleProperty,
2948
+ // eslint-disable-next-line @typescript-eslint/unbound-method
2949
+ getDefaultStyleValue = StyleProperty.getDefault
2950
+ } = options;
2951
+ const { type: layerType, ...restStyle } = style;
2952
+ if (!layerType || !(layerType in deckglAccessorMap)) {
2953
+ throw new Error(`illegal type: ${layerType}`);
2954
+ }
2955
+ this.type = layerType;
2956
+ this.deckglAccessorMap = deckglAccessorMap;
2957
+ this.deckglUpdateTriggers = deckglUpdateTriggers;
2958
+ this.stateUpdateTrigger = stateUpdateTrigger;
2959
+ this.StylePropertyClass = StylePropertyClass;
2960
+ this.getDefaultStyleValue = getDefaultStyleValue;
2961
+ const rules = Object.keys(restStyle).reduce((res, key) => {
2962
+ const isSelector = key.startsWith(":");
2963
+ if (isSelector) {
2964
+ const state = key.substring(1);
2965
+ res[state] = restStyle[key];
2966
+ return res;
2967
+ }
2968
+ res.default[key] = restStyle[key];
2969
+ return res;
2970
+ }, { default: {} });
2971
+ const attributes = Object.values(rules).reduce((res, rule) => {
2972
+ const attrs = Object.keys(rule || {});
2973
+ const set = /* @__PURE__ */ new Set([...res, ...attrs]);
2974
+ return Array.from(set);
2975
+ }, []);
2976
+ const attrMap = attributes.reduce((res, attr) => {
2977
+ res[attr] = Object.entries(rules).reduce((acc, entry) => {
2978
+ const [state, rule] = entry;
2979
+ if (rule && typeof rule[attr] !== "undefined") {
2980
+ acc[state] = rule[attr];
2981
+ }
2982
+ return acc;
2983
+ }, {});
2984
+ return res;
2985
+ }, {});
2986
+ const simplifiedStyleMap = Object.entries(attrMap).reduce((res, entry) => {
2987
+ const [attr, valueMap] = entry;
2988
+ const states = Object.keys(valueMap);
2989
+ const onlyDefault = states.length === 1 && valueMap.default !== void 0;
2990
+ if (onlyDefault) {
2991
+ res[attr] = valueMap.default;
2992
+ return res;
2993
+ }
2994
+ res[attr] = valueMap;
2995
+ return res;
2996
+ }, {});
2997
+ this.properties = {};
2998
+ for (const key in simplifiedStyleMap) {
2999
+ this.properties[key] = new this.StylePropertyClass({
3000
+ key,
3001
+ value: simplifiedStyleMap[key],
3002
+ updateTrigger: this.stateUpdateTrigger
3003
+ });
3004
+ }
3005
+ }
3006
+ getDeckGLAccessorMapForType() {
3007
+ return this.deckglAccessorMap[this.type];
3008
+ }
3009
+ getDeckGLUpdateTriggersForType() {
3010
+ return this.deckglUpdateTriggers[this.type] || [];
3011
+ }
3012
+ _getProperty(deckglAccessor) {
3013
+ const map = this.getDeckGLAccessorMapForType();
3014
+ if (!map) {
3015
+ throw new Error(`illegal type: ${this.type}`);
3016
+ }
3017
+ const styleProp = map[deckglAccessor];
3018
+ if (!styleProp) {
3019
+ error(`Invalid DeckGL accessor: ${deckglAccessor}`);
3020
+ throw new Error(`Invalid DeckGL accessor: ${deckglAccessor}`);
3021
+ }
3022
+ return this.properties[styleProp];
3023
+ }
3024
+ getDeckGLAccessor(deckglAccessor) {
3025
+ var _a;
3026
+ const property = this._getProperty(deckglAccessor);
3027
+ if (property) {
3028
+ const value = property.getValue();
3029
+ return typeof value === "function" ? value : () => value;
3030
+ }
3031
+ const styleProp = (_a = this.getDeckGLAccessorMapForType()) == null ? void 0 : _a[deckglAccessor];
3032
+ return this.getDefaultStyleValue(styleProp);
3033
+ }
3034
+ getDeckGLAccessorUpdateTrigger(deckglAccessor) {
3035
+ const property = this._getProperty(deckglAccessor);
3036
+ if (property) {
3037
+ return property.getUpdateTrigger();
3038
+ }
3039
+ return false;
3040
+ }
3041
+ getDeckGLAccessors() {
3042
+ const accessorMap = this.getDeckGLAccessorMapForType();
3043
+ return Object.keys(accessorMap).reduce((res, accessor) => {
3044
+ res[accessor] = this.getDeckGLAccessor(accessor);
3045
+ return res;
3046
+ }, {});
3047
+ }
3048
+ getDeckGLUpdateTriggers() {
3049
+ return this.getDeckGLUpdateTriggersForType().reduce((res, accessor) => {
3050
+ res[accessor] = this.getDeckGLAccessorUpdateTrigger(accessor);
3051
+ return res;
3052
+ }, {});
3053
+ }
3054
+ };
3055
+
3056
+ // dist/style/graph-stylesheet.schema.js
3057
+ var import_zod = require("zod");
3058
+ var GraphStylePrimitiveSchema = import_zod.z.union([
3059
+ import_zod.z.string(),
3060
+ import_zod.z.number(),
3061
+ import_zod.z.boolean(),
3062
+ import_zod.z.null(),
3063
+ import_zod.z.array(import_zod.z.union([import_zod.z.string(), import_zod.z.number(), import_zod.z.boolean(), import_zod.z.null()]))
3064
+ ]);
3065
+ var GraphStyleFunctionSchema = import_zod.z.custom((value) => typeof value === "function", {
3066
+ message: "Style functions must be callable."
3067
+ });
3068
+ var GraphStyleScaleTypeEnum = import_zod.z.enum([
3069
+ "linear",
3070
+ "log",
3071
+ "pow",
3072
+ "sqrt",
3073
+ "quantize",
3074
+ "quantile",
3075
+ "ordinal"
3076
+ ]);
3077
+ var GraphStyleScaleSchema = import_zod.z.object({
3078
+ type: GraphStyleScaleTypeEnum.optional(),
3079
+ domain: import_zod.z.array(import_zod.z.union([import_zod.z.number(), import_zod.z.string()])).optional(),
3080
+ range: import_zod.z.array(import_zod.z.any()).optional(),
3081
+ clamp: import_zod.z.boolean().optional(),
3082
+ nice: import_zod.z.union([import_zod.z.boolean(), import_zod.z.number()]).optional(),
3083
+ base: import_zod.z.number().optional(),
3084
+ exponent: import_zod.z.number().optional(),
3085
+ unknown: import_zod.z.any().optional()
3086
+ }).strict();
3087
+ var GraphStyleAttributeReferenceSchema = import_zod.z.union([
3088
+ import_zod.z.string().regex(/^@.+/, 'Attribute reference strings must start with "@" and include an attribute name.'),
3089
+ import_zod.z.object({
3090
+ attribute: import_zod.z.string().min(1, "Attribute name is required."),
3091
+ fallback: GraphStylePrimitiveSchema.optional(),
3092
+ scale: import_zod.z.union([GraphStyleScaleSchema, GraphStyleFunctionSchema]).optional()
3093
+ }).strict()
3094
+ ]);
3095
+ var GraphStyleLeafValueSchema = import_zod.z.union([
3096
+ GraphStylePrimitiveSchema,
3097
+ GraphStyleAttributeReferenceSchema,
3098
+ GraphStyleFunctionSchema
3099
+ ]);
3100
+ var RESERVED_STATE_KEYS = /* @__PURE__ */ new Set(["attribute", "fallback", "scale"]);
3101
+ var GraphStyleStateMapSchema = import_zod.z.record(import_zod.z.string().refine((key) => !RESERVED_STATE_KEYS.has(key), "State overrides must not use reserved keys."), GraphStyleLeafValueSchema);
3102
+ var GraphStyleValueSchema = import_zod.z.union([
3103
+ GraphStyleLeafValueSchema,
3104
+ GraphStyleStateMapSchema
3105
+ ]);
3106
+ var COMMON_DECKGL_PROPS = {
3107
+ getOffset: "offset",
3108
+ opacity: "opacity"
3109
+ };
3110
+ var GRAPH_DECKGL_ACCESSOR_MAP = {
3111
+ circle: {
3112
+ ...COMMON_DECKGL_PROPS,
3113
+ getFillColor: "fill",
3114
+ getLineColor: "stroke",
3115
+ getLineWidth: "strokeWidth",
3116
+ getRadius: "radius"
3117
+ },
3118
+ rectangle: {
3119
+ ...COMMON_DECKGL_PROPS,
3120
+ getWidth: "width",
3121
+ getHeight: "height",
3122
+ getFillColor: "fill",
3123
+ getLineColor: "stroke",
3124
+ getLineWidth: "strokeWidth"
3125
+ },
3126
+ "rounded-rectangle": {
3127
+ ...COMMON_DECKGL_PROPS,
3128
+ getCornerRadius: "cornerRadius",
3129
+ getRadius: "radius",
3130
+ getWidth: "width",
3131
+ getHeight: "height",
3132
+ getFillColor: "fill",
3133
+ getLineColor: "stroke",
3134
+ getLineWidth: "strokeWidth"
3135
+ },
3136
+ "path-rounded-rectangle": {
3137
+ ...COMMON_DECKGL_PROPS,
3138
+ getWidth: "width",
3139
+ getHeight: "height",
3140
+ getFillColor: "fill",
3141
+ getLineColor: "stroke",
3142
+ getLineWidth: "strokeWidth",
3143
+ getCornerRadius: "cornerRadius"
3144
+ },
3145
+ label: {
3146
+ ...COMMON_DECKGL_PROPS,
3147
+ getColor: "color",
3148
+ getText: "text",
3149
+ getSize: "fontSize",
3150
+ getTextAnchor: "textAnchor",
3151
+ getAlignmentBaseline: "alignmentBaseline",
3152
+ getAngle: "angle",
3153
+ scaleWithZoom: "scaleWithZoom",
3154
+ textMaxWidth: "textMaxWidth",
3155
+ textWordBreak: "textWordBreak",
3156
+ textSizeMinPixels: "textSizeMinPixels"
3157
+ },
3158
+ marker: {
3159
+ ...COMMON_DECKGL_PROPS,
3160
+ getColor: "fill",
3161
+ getSize: "size",
3162
+ getMarker: "marker",
3163
+ scaleWithZoom: "scaleWithZoom"
3164
+ },
3165
+ Edge: {
3166
+ getColor: "stroke",
3167
+ getWidth: "strokeWidth"
3168
+ },
3169
+ edge: {
3170
+ getColor: "stroke",
3171
+ getWidth: "strokeWidth"
3172
+ },
3173
+ "edge-label": {
3174
+ getColor: "color",
3175
+ getText: "text",
3176
+ getSize: "fontSize",
3177
+ getTextAnchor: "textAnchor",
3178
+ getAlignmentBaseline: "alignmentBaseline",
3179
+ scaleWithZoom: "scaleWithZoom",
3180
+ textMaxWidth: "textMaxWidth",
3181
+ textWordBreak: "textWordBreak",
3182
+ textSizeMinPixels: "textSizeMinPixels"
3183
+ },
3184
+ flow: {
3185
+ getColor: "color",
3186
+ getWidth: "width",
3187
+ getSpeed: "speed",
3188
+ getTailLength: "tailLength"
3189
+ },
3190
+ arrow: {
3191
+ getColor: "color",
3192
+ getSize: "size",
3193
+ getOffset: "offset"
3194
+ }
3195
+ };
3196
+ var GraphStyleSelectorKeySchema = import_zod.z.string().regex(/^:[^\s]+/, 'Selectors must start with ":".');
3197
+ function createPropertiesSchema(keys) {
3198
+ const shape = keys.reduce((acc, key) => {
3199
+ acc[key] = GraphStyleValueSchema.optional();
3200
+ return acc;
3201
+ }, {});
3202
+ return import_zod.z.object(shape).partial().strict();
3203
+ }
3204
+ var GraphStylesheetVariants = Object.entries(GRAPH_DECKGL_ACCESSOR_MAP).map(([type, accessors]) => {
3205
+ const propertyKeys = Object.values(accessors);
3206
+ const propertyKeySet = new Set(propertyKeys);
3207
+ const propertiesSchema = createPropertiesSchema(propertyKeys);
3208
+ const baseShape = {
3209
+ type: import_zod.z.literal(type)
3210
+ };
3211
+ for (const key of propertyKeys) {
3212
+ baseShape[key] = GraphStyleValueSchema.optional();
1981
3213
  }
1982
- // pass the key and value of the property
1983
- // and format the value properly.
1984
- constructor({ key, value, updateTrigger }) {
1985
- this.key = key;
1986
- this._updateTrigger = false;
1987
- if (typeof value === "object" && !Array.isArray(value)) {
1988
- this._value = generateAccessor(key, value);
1989
- this._valueType = VALUE_TYPE.ACCESSOR;
1990
- this._updateTrigger = updateTrigger;
1991
- } else if (typeof value === "function") {
1992
- const formatter = PROPERTY_FORMATTERS[key] || IDENTITY;
1993
- this._value = (d) => formatter(value(d));
1994
- this._valueType = VALUE_TYPE.ACCESSOR;
1995
- this._updateTrigger = value;
1996
- } else {
1997
- const formatter = PROPERTY_FORMATTERS[key] || IDENTITY;
1998
- this._value = formatter(value);
1999
- this._valueType = VALUE_TYPE.PLAIN_VALUE;
2000
- this._updateTrigger = false;
2001
- }
2002
- if (this._value === null) {
2003
- log.warn(`Invalid ${key} value: ${value}`)();
2004
- throw new Error(`Invalid ${key} value: ${value}`);
3214
+ return import_zod.z.object(baseShape).catchall(import_zod.z.unknown()).superRefine((value, ctx) => {
3215
+ for (const key of Object.keys(value)) {
3216
+ if (key === "type") {
3217
+ continue;
3218
+ }
3219
+ if (propertyKeySet.has(key)) {
3220
+ continue;
3221
+ }
3222
+ if (!key.startsWith(":")) {
3223
+ ctx.addIssue({
3224
+ code: import_zod.z.ZodIssueCode.custom,
3225
+ path: [key],
3226
+ message: `Unknown style property "${key}".`
3227
+ });
3228
+ continue;
3229
+ }
3230
+ if (!GraphStyleSelectorKeySchema.safeParse(key).success) {
3231
+ ctx.addIssue({
3232
+ code: import_zod.z.ZodIssueCode.custom,
3233
+ path: [key],
3234
+ message: 'Selectors must start with ":".'
3235
+ });
3236
+ continue;
3237
+ }
3238
+ const selectorResult = propertiesSchema.safeParse(value[key]);
3239
+ if (!selectorResult.success) {
3240
+ for (const issue of selectorResult.error.issues) {
3241
+ ctx.addIssue({
3242
+ ...issue,
3243
+ path: [key, ...issue.path ?? []]
3244
+ });
3245
+ }
3246
+ }
2005
3247
  }
2006
- }
2007
- // get the formatted value
2008
- getValue() {
2009
- return this._value;
2010
- }
2011
- getUpdateTrigger() {
2012
- return this._updateTrigger;
2013
- }
2014
- };
3248
+ });
3249
+ });
3250
+ var GraphStylesheetSchema = import_zod.z.discriminatedUnion("type", GraphStylesheetVariants);
2015
3251
 
2016
- // dist/style/style-sheet.js
2017
- var COMMON_DECKGL_PROPS = {
3252
+ // dist/style/graph-style-accessor-map.js
3253
+ var COMMON_DECKGL_PROPS2 = {
2018
3254
  getOffset: "offset",
2019
3255
  opacity: "opacity"
2020
3256
  };
2021
- var DECKGL_ACCESSOR_MAP = {
2022
- [NODE_TYPE.CIRCLE]: {
2023
- ...COMMON_DECKGL_PROPS,
3257
+ var GRAPH_DECKGL_ACCESSOR_MAP2 = {
3258
+ circle: {
3259
+ ...COMMON_DECKGL_PROPS2,
2024
3260
  getFillColor: "fill",
2025
3261
  getLineColor: "stroke",
2026
3262
  getLineWidth: "strokeWidth",
2027
3263
  getRadius: "radius"
2028
3264
  },
2029
- [NODE_TYPE.RECTANGLE]: {
2030
- ...COMMON_DECKGL_PROPS,
3265
+ rectangle: {
3266
+ ...COMMON_DECKGL_PROPS2,
2031
3267
  getWidth: "width",
2032
3268
  getHeight: "height",
2033
3269
  getFillColor: "fill",
2034
3270
  getLineColor: "stroke",
2035
3271
  getLineWidth: "strokeWidth"
2036
3272
  },
2037
- [NODE_TYPE.ROUNDED_RECTANGLE]: {
2038
- ...COMMON_DECKGL_PROPS,
3273
+ "rounded-rectangle": {
3274
+ ...COMMON_DECKGL_PROPS2,
2039
3275
  getCornerRadius: "cornerRadius",
2040
3276
  getRadius: "radius",
2041
3277
  getWidth: "width",
@@ -2044,8 +3280,8 @@ var DECKGL_ACCESSOR_MAP = {
2044
3280
  getLineColor: "stroke",
2045
3281
  getLineWidth: "strokeWidth"
2046
3282
  },
2047
- [NODE_TYPE.PATH_ROUNDED_RECTANGLE]: {
2048
- ...COMMON_DECKGL_PROPS,
3283
+ "path-rounded-rectangle": {
3284
+ ...COMMON_DECKGL_PROPS2,
2049
3285
  getWidth: "width",
2050
3286
  getHeight: "height",
2051
3287
  getFillColor: "fill",
@@ -2053,8 +3289,8 @@ var DECKGL_ACCESSOR_MAP = {
2053
3289
  getLineWidth: "strokeWidth",
2054
3290
  getCornerRadius: "cornerRadius"
2055
3291
  },
2056
- [NODE_TYPE.LABEL]: {
2057
- ...COMMON_DECKGL_PROPS,
3292
+ label: {
3293
+ ...COMMON_DECKGL_PROPS2,
2058
3294
  getColor: "color",
2059
3295
  getText: "text",
2060
3296
  getSize: "fontSize",
@@ -2066,19 +3302,22 @@ var DECKGL_ACCESSOR_MAP = {
2066
3302
  textWordBreak: "textWordBreak",
2067
3303
  textSizeMinPixels: "textSizeMinPixels"
2068
3304
  },
2069
- [NODE_TYPE.MARKER]: {
2070
- ...COMMON_DECKGL_PROPS,
3305
+ marker: {
3306
+ ...COMMON_DECKGL_PROPS2,
2071
3307
  getColor: "fill",
2072
3308
  getSize: "size",
2073
3309
  getMarker: "marker",
2074
3310
  scaleWithZoom: "scaleWithZoom"
2075
3311
  },
2076
- // --------- Edge related ---------
2077
3312
  Edge: {
2078
3313
  getColor: "stroke",
2079
3314
  getWidth: "strokeWidth"
2080
3315
  },
2081
- [EDGE_DECORATOR_TYPE.LABEL]: {
3316
+ edge: {
3317
+ getColor: "stroke",
3318
+ getWidth: "strokeWidth"
3319
+ },
3320
+ "edge-label": {
2082
3321
  getColor: "color",
2083
3322
  getText: "text",
2084
3323
  getSize: "fontSize",
@@ -2089,143 +3328,165 @@ var DECKGL_ACCESSOR_MAP = {
2089
3328
  textWordBreak: "textWordBreak",
2090
3329
  textSizeMinPixels: "textSizeMinPixels"
2091
3330
  },
2092
- [EDGE_DECORATOR_TYPE.FLOW]: {
3331
+ flow: {
2093
3332
  getColor: "color",
2094
3333
  getWidth: "width",
2095
3334
  getSpeed: "speed",
2096
3335
  getTailLength: "tailLength"
3336
+ },
3337
+ arrow: {
3338
+ getColor: "color",
3339
+ getSize: "size",
3340
+ getOffset: "offset"
2097
3341
  }
2098
3342
  };
2099
- var DECKGL_UPDATE_TRIGGERS = {
2100
- [NODE_TYPE.CIRCLE]: ["getFillColor", "getRadius", "getLineColor", "getLineWidth"],
2101
- [NODE_TYPE.RECTANGLE]: ["getFillColor", "getLineColor", "getLineWidth"],
2102
- [NODE_TYPE.ROUNDED_RECTANGLE]: [
2103
- "getFillColor",
2104
- "getLineColor",
2105
- "getLineWidth",
2106
- "getCornerRadius"
2107
- ],
2108
- [NODE_TYPE.PATH_ROUNDED_RECTANGLE]: [
2109
- "getFillColor",
2110
- "getLineColor",
2111
- "getLineWidth",
2112
- "getCornerRadius"
2113
- ],
2114
- [NODE_TYPE.LABEL]: [
2115
- "getColor",
2116
- "getText",
2117
- "getSize",
2118
- "getTextAnchor",
2119
- "getAlignmentBaseline",
2120
- "getAngle"
2121
- ],
2122
- [NODE_TYPE.MARKER]: ["getColor", "getSize", "getMarker"],
3343
+
3344
+ // dist/style/graph-style-engine.js
3345
+ var GRAPH_DECKGL_UPDATE_TRIGGERS = {
3346
+ circle: ["getFillColor", "getRadius", "getLineColor", "getLineWidth"],
3347
+ rectangle: ["getFillColor", "getLineColor", "getLineWidth"],
3348
+ "rounded-rectangle": ["getFillColor", "getLineColor", "getLineWidth", "getCornerRadius"],
3349
+ "path-rounded-rectangle": ["getFillColor", "getLineColor", "getLineWidth", "getCornerRadius"],
3350
+ label: ["getColor", "getText", "getSize", "getTextAnchor", "getAlignmentBaseline", "getAngle"],
3351
+ marker: ["getColor", "getSize", "getMarker"],
2123
3352
  Edge: ["getColor", "getWidth"],
2124
- [EDGE_DECORATOR_TYPE.LABEL]: [
2125
- "getColor",
2126
- "getText",
2127
- "getSize",
2128
- "getTextAnchor",
2129
- "getAlignmentBaseline"
2130
- ],
2131
- [EDGE_DECORATOR_TYPE.FLOW]: ["getColor", "getWidth", "getSpeed", "getTailLength"]
3353
+ edge: ["getColor", "getWidth"],
3354
+ "edge-label": ["getColor", "getText", "getSize", "getTextAnchor", "getAlignmentBaseline"],
3355
+ flow: ["getColor", "getWidth", "getSpeed", "getTailLength"],
3356
+ arrow: ["getColor", "getSize", "getOffset"]
2132
3357
  };
2133
- var Stylesheet = class {
2134
- type;
2135
- properties;
2136
- constructor(style, updateTriggers) {
2137
- const { type: layerType, ...restStyle } = style;
2138
- if (!layerType || !(layerType in DECKGL_ACCESSOR_MAP)) {
2139
- throw new Error(`illegal type: ${layerType}`);
2140
- }
2141
- this.type = layerType;
2142
- const rules = Object.keys(restStyle).reduce((res, key) => {
2143
- const isSelector = key.startsWith(":");
2144
- if (isSelector) {
2145
- const state = key.substring(1);
2146
- res[state] = restStyle[key];
2147
- return res;
2148
- }
2149
- res.default[key] = restStyle[key];
2150
- return res;
2151
- }, {
2152
- default: {}
3358
+ function formatStylesheetError(error2) {
3359
+ const details = error2.issues.map((issue) => {
3360
+ const path = issue.path.length ? issue.path.join(".") : "root";
3361
+ return ` \u2022 ${path}: ${issue.message}`;
3362
+ }).join("\n");
3363
+ return `Invalid graph stylesheet:
3364
+ ${details}`;
3365
+ }
3366
+ var GraphStyleEngine = class extends StyleEngine {
3367
+ constructor(style, { stateUpdateTrigger } = {}) {
3368
+ const result = GraphStylesheetSchema.safeParse(style);
3369
+ const parsedStyle = result.success ? result.data : sanitizeStylesheet(style, result.error.issues);
3370
+ super(parsedStyle, {
3371
+ deckglAccessorMap: GRAPH_DECKGL_ACCESSOR_MAP2,
3372
+ deckglUpdateTriggers: GRAPH_DECKGL_UPDATE_TRIGGERS,
3373
+ stateUpdateTrigger
2153
3374
  });
2154
- const attributes = Object.values(rules).reduce((res, rule) => {
2155
- const attrs = Object.keys(rule);
2156
- const set = /* @__PURE__ */ new Set([...res, ...attrs]);
2157
- return Array.from(set);
2158
- }, []);
2159
- const attrMap = attributes.reduce((res, attr) => {
2160
- res[attr] = Object.entries(rules).reduce((acc, entry) => {
2161
- const [state, rule] = entry;
2162
- if (typeof rule[attr] !== "undefined") {
2163
- acc[state] = rule[attr];
2164
- }
2165
- return acc;
2166
- }, {});
2167
- return res;
2168
- }, {});
2169
- const simplifiedStyleMap = Object.entries(attrMap).reduce((res, entry) => {
2170
- const [attr, valueMap] = entry;
2171
- const onlyDefault = Object.keys(valueMap).length === 1 && valueMap.default !== void 0;
2172
- if (onlyDefault) {
2173
- res[attr] = valueMap.default;
2174
- return res;
3375
+ }
3376
+ };
3377
+ function sanitizeStylesheet(style, issues) {
3378
+ if (issues.length) {
3379
+ const details = issues.map((issue) => {
3380
+ const path = issue.path.length ? issue.path.join(".") : "root";
3381
+ return `${path}: ${issue.message}`;
3382
+ }).join("\n \u2022 ");
3383
+ warn(`GraphStyleEngine: stylesheet issues detected:
3384
+ \u2022 ${details}`);
3385
+ }
3386
+ const fallbackTypeCandidate = typeof style.type === "string" ? style.type : void 0;
3387
+ const fallbackCandidates = Array.from(new Set([fallbackTypeCandidate, "edge"].filter((value) => typeof value === "string" && value.length > 0)));
3388
+ for (const candidate of fallbackCandidates) {
3389
+ const sanitized = cloneValue(style);
3390
+ sanitized.type = candidate;
3391
+ for (const issue of issues) {
3392
+ if (!Array.isArray(issue.path) || issue.path.length === 0) {
3393
+ continue;
2175
3394
  }
2176
- res[attr] = valueMap;
2177
- return res;
2178
- }, {});
2179
- this.properties = {};
2180
- for (const key in simplifiedStyleMap) {
2181
- this.properties[key] = new StyleProperty({
2182
- key,
2183
- value: simplifiedStyleMap[key],
2184
- updateTrigger: updateTriggers.stateUpdateTrigger
2185
- });
3395
+ const path = issue.path.filter((segment) => typeof segment === "string" || typeof segment === "number");
3396
+ if (path.length === 0) {
3397
+ continue;
3398
+ }
3399
+ const [rootKey] = path;
3400
+ if (rootKey === void 0 || rootKey === "type") {
3401
+ continue;
3402
+ }
3403
+ if (typeof rootKey === "string" && rootKey.startsWith(":")) {
3404
+ removeNestedProperty(sanitized, path);
3405
+ continue;
3406
+ }
3407
+ if (typeof rootKey !== "string") {
3408
+ continue;
3409
+ }
3410
+ delete sanitized[rootKey];
3411
+ }
3412
+ const result = GraphStylesheetSchema.safeParse(sanitized);
3413
+ if (result.success) {
3414
+ return result.data;
2186
3415
  }
2187
3416
  }
2188
- _getProperty(deckglAccessor) {
2189
- const map = DECKGL_ACCESSOR_MAP[this.type];
2190
- if (!map) {
2191
- throw new Error(`illegal type: ${this.type}`);
3417
+ throw new Error(formatStylesheetError(new import_zod2.ZodError(issues)));
3418
+ }
3419
+ function cloneValue(value) {
3420
+ if (Array.isArray(value)) {
3421
+ return value.map((item) => cloneValue(item));
3422
+ }
3423
+ if (value && typeof value === "object") {
3424
+ if (value instanceof Date) {
3425
+ return new Date(value);
2192
3426
  }
2193
- const styleProp = map[deckglAccessor];
2194
- if (!styleProp) {
2195
- log.error(`Invalid DeckGL accessor: ${deckglAccessor}`)();
2196
- throw new Error(`Invalid DeckGL accessor: ${deckglAccessor}`);
3427
+ if (value instanceof RegExp) {
3428
+ return new RegExp(value.source, value.flags);
2197
3429
  }
2198
- return this.properties[styleProp];
2199
- }
2200
- getDeckGLAccessor(deckglAccessor) {
2201
- const property = this._getProperty(deckglAccessor);
2202
- if (property) {
2203
- return property.getValue();
3430
+ const cloned = {};
3431
+ for (const [key, entryValue] of Object.entries(value)) {
3432
+ cloned[key] = cloneValue(entryValue);
2204
3433
  }
2205
- const styleProp = DECKGL_ACCESSOR_MAP[this.type][deckglAccessor];
2206
- return StyleProperty.getDefault(styleProp);
3434
+ return cloned;
2207
3435
  }
2208
- getDeckGLAccessorUpdateTrigger(deckglAccessor) {
2209
- const property = this._getProperty(deckglAccessor);
2210
- if (property) {
2211
- return property.getUpdateTrigger();
3436
+ return value;
3437
+ }
3438
+ function removeNestedProperty(target, path) {
3439
+ if (path.length === 0) {
3440
+ return;
3441
+ }
3442
+ const [head, ...rest] = path;
3443
+ if (head === void 0) {
3444
+ return;
3445
+ }
3446
+ if (Array.isArray(target)) {
3447
+ const index = typeof head === "number" ? head : Number(head);
3448
+ if (!Number.isInteger(index) || index < 0 || index >= target.length) {
3449
+ return;
2212
3450
  }
2213
- return false;
3451
+ if (rest.length === 0) {
3452
+ target.splice(index, 1);
3453
+ return;
3454
+ }
3455
+ const child2 = target[index];
3456
+ if (!child2 || typeof child2 !== "object") {
3457
+ target.splice(index, 1);
3458
+ return;
3459
+ }
3460
+ removeNestedProperty(child2, rest);
3461
+ if (isEmptyObject(child2)) {
3462
+ target.splice(index, 1);
3463
+ }
3464
+ return;
2214
3465
  }
2215
- getDeckGLAccessors() {
2216
- const accessorMap = DECKGL_ACCESSOR_MAP[this.type];
2217
- return Object.keys(accessorMap).reduce((res, accessor) => {
2218
- res[accessor] = this.getDeckGLAccessor(accessor);
2219
- return res;
2220
- }, {});
3466
+ const recordTarget = target;
3467
+ if (rest.length === 0) {
3468
+ delete recordTarget[head];
3469
+ return;
2221
3470
  }
2222
- getDeckGLUpdateTriggers() {
2223
- return DECKGL_UPDATE_TRIGGERS[this.type].reduce((res, accessor) => {
2224
- res[accessor] = this.getDeckGLAccessorUpdateTrigger(accessor);
2225
- return res;
2226
- }, {});
3471
+ const child = recordTarget[head];
3472
+ if (!child || typeof child !== "object") {
3473
+ delete recordTarget[head];
3474
+ return;
2227
3475
  }
2228
- };
3476
+ removeNestedProperty(child, rest);
3477
+ if (isEmptyObject(child)) {
3478
+ delete recordTarget[head];
3479
+ }
3480
+ }
3481
+ function isEmptyObject(value) {
3482
+ if (Array.isArray(value)) {
3483
+ return value.length === 0;
3484
+ }
3485
+ if (!value || typeof value !== "object") {
3486
+ return false;
3487
+ }
3488
+ return Object.keys(value).length === 0;
3489
+ }
2229
3490
 
2230
3491
  // dist/utils/layer-utils.js
2231
3492
  var mixedGetPosition = (getPosition, getOffset2) => {
@@ -2246,15 +3507,210 @@ var mixedGetPosition = (getPosition, getOffset2) => {
2246
3507
  };
2247
3508
  };
2248
3509
 
3510
+ // dist/utils/collapsed-chains.js
3511
+ var OUTLINE_PADDING = 24;
3512
+ var OUTLINE_CORNER_RADIUS = 16;
3513
+ var OUTLINE_CORNER_SEGMENTS = 6;
3514
+ function resolveLayerId(layer) {
3515
+ var _a;
3516
+ if (!layer) {
3517
+ return "";
3518
+ }
3519
+ if (typeof layer.id === "string") {
3520
+ return layer.id;
3521
+ }
3522
+ if (typeof ((_a = layer.props) == null ? void 0 : _a.id) === "string") {
3523
+ return layer.props.id;
3524
+ }
3525
+ return "";
3526
+ }
3527
+ function classifyChainLayer(layer) {
3528
+ let current = layer ?? null;
3529
+ while (current) {
3530
+ const layerId = resolveLayerId(current);
3531
+ if (layerId.includes("collapsed-chain-markers")) {
3532
+ return "collapsed-marker";
3533
+ }
3534
+ if (layerId.includes("expanded-chain-markers")) {
3535
+ return "expanded-marker";
3536
+ }
3537
+ if (layerId.includes("collapsed-chain-outlines")) {
3538
+ return "collapsed-outline";
3539
+ }
3540
+ if (layerId.includes("expanded-chain-outlines")) {
3541
+ return "expanded-outline";
3542
+ }
3543
+ current = current.parent ?? null;
3544
+ }
3545
+ return null;
3546
+ }
3547
+ function resolveChainInteractionSource(info) {
3548
+ if (!info) {
3549
+ return "node";
3550
+ }
3551
+ const layersToCheck = [];
3552
+ if (info.layer || info.sourceLayer) {
3553
+ if (info.layer) {
3554
+ layersToCheck.push(info.layer);
3555
+ }
3556
+ if (info.sourceLayer && info.sourceLayer !== info.layer) {
3557
+ layersToCheck.push(info.sourceLayer);
3558
+ }
3559
+ } else {
3560
+ layersToCheck.push(info);
3561
+ }
3562
+ for (const layer of layersToCheck) {
3563
+ const classification = classifyChainLayer(layer);
3564
+ if (classification) {
3565
+ return classification;
3566
+ }
3567
+ }
3568
+ return "node";
3569
+ }
3570
+ function isChainRepresentative(node) {
3571
+ const chainId = node.getPropertyValue("collapsedChainId");
3572
+ const nodeIds = node.getPropertyValue("collapsedNodeIds");
3573
+ const representativeId = node.getPropertyValue("collapsedChainRepresentativeId");
3574
+ return Boolean(chainId) && Array.isArray(nodeIds) && nodeIds.length > 1 && representativeId === node.getId();
3575
+ }
3576
+ function getRepresentativeNodes(engine) {
3577
+ if (!engine) {
3578
+ return [];
3579
+ }
3580
+ return engine.getNodes().filter((node) => isChainRepresentative(node));
3581
+ }
3582
+ function createChainOutlineGetter(engine) {
3583
+ if (!engine) {
3584
+ return () => null;
3585
+ }
3586
+ const graph = engine.props.graph;
3587
+ const cache = /* @__PURE__ */ new Map();
3588
+ return (node) => {
3589
+ const chainId = node.getPropertyValue("collapsedChainId");
3590
+ if (!chainId) {
3591
+ return null;
3592
+ }
3593
+ const cacheKey = String(chainId);
3594
+ if (cache.has(cacheKey)) {
3595
+ return cache.get(cacheKey) ?? null;
3596
+ }
3597
+ if (!graph) {
3598
+ cache.set(cacheKey, null);
3599
+ return null;
3600
+ }
3601
+ const collapsedNodeIds = node.getPropertyValue("collapsedNodeIds");
3602
+ if (!Array.isArray(collapsedNodeIds) || collapsedNodeIds.length === 0) {
3603
+ cache.set(cacheKey, null);
3604
+ return null;
3605
+ }
3606
+ let minX = Number.POSITIVE_INFINITY;
3607
+ let maxX = Number.NEGATIVE_INFINITY;
3608
+ let minY = Number.POSITIVE_INFINITY;
3609
+ let maxY = Number.NEGATIVE_INFINITY;
3610
+ for (const nodeId of collapsedNodeIds) {
3611
+ const chainNode = graph.findNode(nodeId);
3612
+ if (chainNode) {
3613
+ const position = engine.getNodePosition(chainNode);
3614
+ if (position) {
3615
+ const [x, y] = position;
3616
+ minX = Math.min(minX, x);
3617
+ maxX = Math.max(maxX, x);
3618
+ minY = Math.min(minY, y);
3619
+ maxY = Math.max(maxY, y);
3620
+ }
3621
+ }
3622
+ }
3623
+ if (!Number.isFinite(minX) || !Number.isFinite(maxX) || !Number.isFinite(minY) || !Number.isFinite(maxY)) {
3624
+ cache.set(cacheKey, null);
3625
+ return null;
3626
+ }
3627
+ const paddedMinX = minX - OUTLINE_PADDING;
3628
+ const paddedMaxX = maxX + OUTLINE_PADDING;
3629
+ const paddedMinY = minY - OUTLINE_PADDING;
3630
+ const paddedMaxY = maxY + OUTLINE_PADDING;
3631
+ const width = paddedMaxX - paddedMinX;
3632
+ const height = paddedMaxY - paddedMinY;
3633
+ if (width <= 0 || height <= 0) {
3634
+ cache.set(cacheKey, null);
3635
+ return null;
3636
+ }
3637
+ const radius = Math.min(OUTLINE_CORNER_RADIUS, width / 2, height / 2);
3638
+ if (radius <= 0) {
3639
+ const polygon2 = [
3640
+ [paddedMinX, paddedMinY],
3641
+ [paddedMinX, paddedMaxY],
3642
+ [paddedMaxX, paddedMaxY],
3643
+ [paddedMaxX, paddedMinY],
3644
+ [paddedMinX, paddedMinY]
3645
+ ];
3646
+ cache.set(cacheKey, polygon2);
3647
+ return polygon2;
3648
+ }
3649
+ const left = paddedMinX;
3650
+ const right = paddedMaxX;
3651
+ const top = paddedMinY;
3652
+ const bottom = paddedMaxY;
3653
+ const polygon = [];
3654
+ const pushArc = (cx, cy, startAngle, endAngle) => {
3655
+ const step = (endAngle - startAngle) / OUTLINE_CORNER_SEGMENTS;
3656
+ for (let i = 1; i <= OUTLINE_CORNER_SEGMENTS; i++) {
3657
+ const angle = startAngle + step * i;
3658
+ polygon.push([cx + radius * Math.cos(angle), cy + radius * Math.sin(angle)]);
3659
+ }
3660
+ };
3661
+ polygon.push([right - radius, top]);
3662
+ pushArc(right - radius, top + radius, -Math.PI / 2, 0);
3663
+ polygon.push([right, bottom - radius]);
3664
+ pushArc(right - radius, bottom - radius, 0, Math.PI / 2);
3665
+ polygon.push([left + radius, bottom]);
3666
+ pushArc(left + radius, bottom - radius, Math.PI / 2, Math.PI);
3667
+ polygon.push([left, top + radius]);
3668
+ pushArc(left + radius, top + radius, Math.PI, 3 * Math.PI / 2);
3669
+ polygon.push(polygon[0]);
3670
+ cache.set(cacheKey, polygon);
3671
+ return polygon;
3672
+ };
3673
+ }
3674
+ function buildCollapsedChainLayers(engine) {
3675
+ if (!engine) {
3676
+ return null;
3677
+ }
3678
+ const representativeNodes = getRepresentativeNodes(engine);
3679
+ if (representativeNodes.length === 0) {
3680
+ return null;
3681
+ }
3682
+ const getChainOutlinePolygon = createChainOutlineGetter(engine);
3683
+ const outlineUpdateTrigger = [engine.getLayoutLastUpdate(), engine.getLayoutState()].join();
3684
+ const collapsedNodes = representativeNodes.filter((node) => Boolean(node.getPropertyValue("isCollapsedChain")));
3685
+ const collapsedOutlineNodes = collapsedNodes.filter((node) => getChainOutlinePolygon(node));
3686
+ const expandedNodes = representativeNodes.filter((node) => !node.getPropertyValue("isCollapsedChain"));
3687
+ const expandedOutlineNodes = expandedNodes.filter((node) => getChainOutlinePolygon(node));
3688
+ return {
3689
+ representativeNodes,
3690
+ collapsedNodes,
3691
+ collapsedOutlineNodes,
3692
+ expandedNodes,
3693
+ expandedOutlineNodes,
3694
+ getChainOutlinePolygon,
3695
+ outlineUpdateTrigger
3696
+ };
3697
+ }
3698
+
2249
3699
  // dist/core/interaction-manager.js
3700
+ function shouldToggleCollapsedChain(isCollapsed, source) {
3701
+ if (isCollapsed) {
3702
+ return true;
3703
+ }
3704
+ return source === "expanded-marker" || source === "expanded-outline";
3705
+ }
2250
3706
  var NODE_TO_EDGE_STATE_MAP = {
2251
- [NODE_STATE.DEFAULT]: EDGE_STATE.DEFAULT,
2252
- [NODE_STATE.HOVER]: EDGE_STATE.HOVER,
2253
- [NODE_STATE.DRAGGING]: EDGE_STATE.DRAGGING,
2254
- [NODE_STATE.SELECTED]: EDGE_STATE.SELECTED
3707
+ default: "default",
3708
+ hover: "hover",
3709
+ dragging: "dragging",
3710
+ selected: "selected"
2255
3711
  };
2256
3712
  function shouldEdgeBeSelected(edge) {
2257
- return edge.getConnectedNodes().some((node) => node.getState() === NODE_STATE.SELECTED && node.shouldHighlightConnectedEdges());
3713
+ return edge.getConnectedNodes().some((node) => node.getState() === "selected" && node.shouldHighlightConnectedEdges());
2258
3714
  }
2259
3715
  function setNodeState(node, state) {
2260
3716
  node.setState(state);
@@ -2262,7 +3718,7 @@ function setNodeState(node, state) {
2262
3718
  node.getConnectedEdges().forEach((edge) => {
2263
3719
  let newEdgeState = NODE_TO_EDGE_STATE_MAP[state];
2264
3720
  if (shouldEdgeBeSelected(edge)) {
2265
- newEdgeState = EDGE_STATE.SELECTED;
3721
+ newEdgeState = "selected";
2266
3722
  }
2267
3723
  edge.setState(newEdgeState);
2268
3724
  });
@@ -2295,18 +3751,46 @@ var InteractionManager = class {
2295
3751
  getLastInteraction() {
2296
3752
  return this._lastInteraction;
2297
3753
  }
3754
+ // eslint-disable-next-line max-statements, complexity
2298
3755
  onClick(info, event) {
3756
+ var _a, _b;
2299
3757
  const { object } = info;
2300
3758
  if (!object) {
2301
3759
  return;
2302
3760
  }
2303
3761
  if (object.isNode) {
3762
+ const node = object;
3763
+ const chainId = node.getPropertyValue("collapsedChainId");
3764
+ const collapsedNodeIds = node.getPropertyValue("collapsedNodeIds");
3765
+ const representativeId = node.getPropertyValue("collapsedChainRepresentativeId");
3766
+ const isCollapsed = Boolean(node.getPropertyValue("isCollapsedChain"));
3767
+ const hasChainMetadata = chainId !== null && chainId !== void 0 && Array.isArray(collapsedNodeIds) && collapsedNodeIds.length > 1 && representativeId !== null && representativeId !== void 0;
3768
+ const isRepresentative = hasChainMetadata && representativeId === node.getId();
3769
+ if (hasChainMetadata && isRepresentative) {
3770
+ const layout = (_b = (_a = this.engine) == null ? void 0 : _a.props) == null ? void 0 : _b.layout;
3771
+ if (layout && typeof layout.toggleCollapsedChain === "function") {
3772
+ const interactionSource = resolveChainInteractionSource(info ?? null);
3773
+ if (shouldToggleCollapsedChain(isCollapsed, interactionSource)) {
3774
+ const action = isCollapsed ? "expand" : "collapse";
3775
+ const chainIdStr = String(chainId);
3776
+ log.log(0, `InteractionManager: ${action} chain ${chainIdStr} via ${interactionSource}`);
3777
+ console.log(`InteractionManager: ${action} chain ${chainIdStr} via ${interactionSource}`);
3778
+ layout.toggleCollapsedChain(chainIdStr);
3779
+ this._lastInteraction = Date.now();
3780
+ this.notifyCallback();
3781
+ if (this.nodeEvents.onClick) {
3782
+ this.nodeEvents.onClick(info, event);
3783
+ }
3784
+ return;
3785
+ }
3786
+ }
3787
+ }
2304
3788
  if (object.isSelectable()) {
2305
3789
  if (this._lastSelectedNode) {
2306
- setNodeState(this._lastSelectedNode, NODE_STATE.DEFAULT);
3790
+ setNodeState(this._lastSelectedNode, "default");
2307
3791
  }
2308
- setNodeState(object, NODE_STATE.SELECTED);
2309
- this._lastSelectedNode = object;
3792
+ setNodeState(node, "selected");
3793
+ this._lastSelectedNode = node;
2310
3794
  this._lastInteraction = Date.now();
2311
3795
  this.notifyCallback();
2312
3796
  }
@@ -2321,8 +3805,8 @@ var InteractionManager = class {
2321
3805
  _mouseLeaveNode() {
2322
3806
  var _a;
2323
3807
  const lastHoveredNode = this._lastHoveredNode;
2324
- if (!(lastHoveredNode.isSelectable() && lastHoveredNode.getState() === NODE_STATE.SELECTED)) {
2325
- const newState = this._lastSelectedNode !== null && this._lastSelectedNode.id === ((_a = this._lastHoveredNode) == null ? void 0 : _a.id) ? NODE_STATE.SELECTED : NODE_STATE.DEFAULT;
3808
+ if (!(lastHoveredNode.isSelectable() && lastHoveredNode.getState() === "selected")) {
3809
+ const newState = this._lastSelectedNode !== null && this._lastSelectedNode.id === ((_a = this._lastHoveredNode) == null ? void 0 : _a.id) ? "selected" : "default";
2326
3810
  setNodeState(lastHoveredNode, newState);
2327
3811
  }
2328
3812
  if (this.nodeEvents.onMouseLeave) {
@@ -2330,7 +3814,7 @@ var InteractionManager = class {
2330
3814
  }
2331
3815
  }
2332
3816
  _mouseEnterNode(info) {
2333
- setNodeState(info.object, NODE_STATE.HOVER);
3817
+ setNodeState(info.object, "hover");
2334
3818
  if (this.nodeEvents.onMouseEnter) {
2335
3819
  this.nodeEvents.onMouseEnter(info);
2336
3820
  }
@@ -2380,7 +3864,7 @@ var InteractionManager = class {
2380
3864
  const x = Math.min(Math.max(coordinates[0], bounds[0]), bounds[2]);
2381
3865
  const y = Math.min(Math.max(coordinates[1], bounds[1]), bounds[3]);
2382
3866
  this.engine.lockNodePosition(info.object, x, y);
2383
- setNodeState(info.object, NODE_STATE.DRAGGING);
3867
+ setNodeState(info.object, "dragging");
2384
3868
  this._lastInteraction = Date.now();
2385
3869
  this.notifyCallback();
2386
3870
  if (this.nodeEvents.onDrag) {
@@ -2394,11 +3878,39 @@ var InteractionManager = class {
2394
3878
  if (this.resumeLayoutAfterDragging) {
2395
3879
  this.engine.resume();
2396
3880
  }
2397
- setNodeState(info.object, NODE_STATE.DEFAULT);
3881
+ setNodeState(info.object, "default");
2398
3882
  this.engine.unlockNodePosition(info.object);
2399
3883
  }
2400
3884
  };
2401
3885
 
3886
+ // dist/style/graph-layer-stylesheet.js
3887
+ var DEFAULT_EDGE_STYLE = {
3888
+ type: "edge",
3889
+ stroke: "black",
3890
+ strokeWidth: 1,
3891
+ decorators: []
3892
+ };
3893
+ var DEFAULT_GRAPH_LAYER_STYLESHEET = {
3894
+ nodes: [],
3895
+ edges: [DEFAULT_EDGE_STYLE]
3896
+ };
3897
+ function normalizeGraphLayerStylesheet({ stylesheet, nodeStyle, edgeStyle }) {
3898
+ const resolvedStylesheet = stylesheet ?? {};
3899
+ const resolvedNodeStyles = Array.isArray(resolvedStylesheet.nodes) ? resolvedStylesheet.nodes : nodeStyle;
3900
+ const resolvedEdgeStyles = resolvedStylesheet.edges ?? edgeStyle;
3901
+ const nodes = Array.isArray(resolvedNodeStyles) ? resolvedNodeStyles.filter(Boolean) : [...DEFAULT_GRAPH_LAYER_STYLESHEET.nodes];
3902
+ const edgeEntries = Array.isArray(resolvedEdgeStyles) ? resolvedEdgeStyles : resolvedEdgeStyles ? [resolvedEdgeStyles] : DEFAULT_GRAPH_LAYER_STYLESHEET.edges;
3903
+ const edges = edgeEntries.filter(Boolean).map((edgeStyleEntry) => ({
3904
+ ...edgeStyleEntry,
3905
+ type: edgeStyleEntry.type ?? "edge",
3906
+ decorators: edgeStyleEntry.decorators ?? []
3907
+ }));
3908
+ return {
3909
+ nodes,
3910
+ edges
3911
+ };
3912
+ }
3913
+
2402
3914
  // dist/layers/node-layers/circle-layer.js
2403
3915
  var import_core = require("@deck.gl/core");
2404
3916
  var import_layers = require("@deck.gl/layers");
@@ -3443,9 +4955,9 @@ __publicField(CurvedEdgeLayer, "layerName", "CurvedEdgeLayer");
3443
4955
 
3444
4956
  // dist/layers/edge-layer.js
3445
4957
  var EDGE_LAYER_MAP = {
3446
- [EDGE_TYPE.LINE]: StraightLineEdgeLayer,
3447
- [EDGE_TYPE.PATH]: PathEdgeLayer,
3448
- [EDGE_TYPE.SPLINE_CURVE]: CurvedEdgeLayer
4958
+ "line": StraightLineEdgeLayer,
4959
+ "path": PathEdgeLayer,
4960
+ "spline-curve": CurvedEdgeLayer
3449
4961
  };
3450
4962
  var EdgeLayer = class extends import_core13.CompositeLayer {
3451
4963
  updateState({ props, oldProps, changeFlags }) {
@@ -3461,9 +4973,9 @@ var EdgeLayer = class extends import_core13.CompositeLayer {
3461
4973
  res[type].push(d);
3462
4974
  return res;
3463
4975
  }, {
3464
- [EDGE_TYPE.LINE]: [],
3465
- [EDGE_TYPE.PATH]: [],
3466
- [EDGE_TYPE.SPLINE_CURVE]: []
4976
+ "line": [],
4977
+ "path": [],
4978
+ "spline-curve": []
3467
4979
  });
3468
4980
  this.setState({ typedEdgeData });
3469
4981
  }
@@ -3753,25 +5265,537 @@ var FlowLayer = class extends import_core15.CompositeLayer {
3753
5265
  renderLayers() {
3754
5266
  const { data, getLayoutInfo, positionUpdateTrigger = 0, stylesheet } = this.props;
3755
5267
  return [
3756
- new FlowPathLayer(this.getSubLayerProps({
3757
- id: "__flow-layer",
3758
- data,
3759
- ...stylesheet.getDeckGLAccessors(),
3760
- getSourcePosition: (e) => getLayoutInfo(e).sourcePosition,
3761
- getTargetPosition: (e) => getLayoutInfo(e).targetPosition,
5268
+ new FlowPathLayer(this.getSubLayerProps({
5269
+ id: "__flow-layer",
5270
+ data,
5271
+ ...stylesheet.getDeckGLAccessors(),
5272
+ getSourcePosition: (e) => getLayoutInfo(e).sourcePosition,
5273
+ getTargetPosition: (e) => getLayoutInfo(e).targetPosition,
5274
+ parameters: {
5275
+ depthTest: false
5276
+ },
5277
+ updateTriggers: {
5278
+ ...stylesheet.getDeckGLUpdateTriggers(),
5279
+ getSourcePosition: positionUpdateTrigger,
5280
+ getTargetPosition: positionUpdateTrigger
5281
+ }
5282
+ }))
5283
+ ];
5284
+ }
5285
+ };
5286
+ __publicField(FlowLayer, "layerName", "FlowLayer");
5287
+
5288
+ // dist/layers/edge-layers/edge-arrow-layer.js
5289
+ var import_core16 = require("@deck.gl/core");
5290
+ var import_mesh_layers = require("@deck.gl/mesh-layers");
5291
+
5292
+ // dist/layers/edge-layers/arrow-2d-geometry.js
5293
+ var import_engine = require("@luma.gl/engine");
5294
+ var Arrow2DGeometry = class extends import_engine.Geometry {
5295
+ constructor(opts = {}) {
5296
+ super(Object.assign({}, opts, {
5297
+ attributes: getArrowAttributes(opts),
5298
+ topology: "triangle-list"
5299
+ }));
5300
+ }
5301
+ };
5302
+ function getArrowAttributes({ length = 1, headWidth = 1 }) {
5303
+ const halfLength = length / 2;
5304
+ const halfWidth = headWidth / 2;
5305
+ const positions = new Float32Array([
5306
+ 0,
5307
+ halfLength,
5308
+ 0,
5309
+ -halfWidth,
5310
+ -halfLength,
5311
+ 0,
5312
+ halfWidth,
5313
+ -halfLength,
5314
+ 0
5315
+ ]);
5316
+ const normals = new Float32Array([0, 0, 1, 0, 0, 1, 0, 0, 1]);
5317
+ const texCoords = new Float32Array([
5318
+ 0.5,
5319
+ 1,
5320
+ 0,
5321
+ 0,
5322
+ 1,
5323
+ 0
5324
+ ]);
5325
+ return {
5326
+ positions: { size: 3, value: positions },
5327
+ normals: { size: 3, value: normals },
5328
+ texCoords: { size: 2, value: texCoords }
5329
+ };
5330
+ }
5331
+
5332
+ // dist/layers/edge-layers/edge-arrow-layer.js
5333
+ var DEFAULT_ARROW_GEOMETRY = new Arrow2DGeometry({ length: 1, headWidth: 0.6 });
5334
+ var DEFAULT_Z = 0;
5335
+ function resolveSize(value) {
5336
+ const numeric = Number(value);
5337
+ return Number.isFinite(numeric) && numeric !== 0 ? numeric : 1;
5338
+ }
5339
+ function getOffsetComponents(offset) {
5340
+ if (!Array.isArray(offset)) {
5341
+ return { along: 0, perpendicular: 0 };
5342
+ }
5343
+ const along = Number(offset[0]);
5344
+ const perpendicular = Number(offset[1]);
5345
+ return {
5346
+ along: Number.isFinite(along) ? along : 0,
5347
+ perpendicular: Number.isFinite(perpendicular) ? perpendicular : 0
5348
+ };
5349
+ }
5350
+ function isEdgeDirected(edge) {
5351
+ if (!edge) {
5352
+ return false;
5353
+ }
5354
+ if (typeof edge.isDirected === "function") {
5355
+ return Boolean(edge.isDirected());
5356
+ }
5357
+ if (typeof edge.directed === "boolean") {
5358
+ return edge.directed;
5359
+ }
5360
+ return false;
5361
+ }
5362
+ function normalizeVector(vector) {
5363
+ const length = Math.hypot(vector[0] ?? 0, vector[1] ?? 0, vector[2] ?? 0);
5364
+ if (length === 0) {
5365
+ return [0, 0, 0];
5366
+ }
5367
+ return [(vector[0] ?? 0) / length, (vector[1] ?? 0) / length, (vector[2] ?? 0) / length];
5368
+ }
5369
+ function getTerminalDirection({ sourcePosition, targetPosition, controlPoints = [] }) {
5370
+ const anchor = controlPoints.length ? controlPoints[controlPoints.length - 1] : sourcePosition;
5371
+ const direction = [
5372
+ (targetPosition[0] ?? 0) - ((anchor == null ? void 0 : anchor[0]) ?? 0),
5373
+ (targetPosition[1] ?? 0) - ((anchor == null ? void 0 : anchor[1]) ?? 0),
5374
+ (targetPosition[2] ?? DEFAULT_Z) - ((anchor == null ? void 0 : anchor[2]) ?? DEFAULT_Z)
5375
+ ];
5376
+ return { target: targetPosition, direction };
5377
+ }
5378
+ function getArrowTransform({ layout, size, offset = null }) {
5379
+ const { target, direction } = getTerminalDirection(layout);
5380
+ const unit = normalizeVector(direction);
5381
+ const hasDirection = unit[0] !== 0 || unit[1] !== 0 || unit[2] !== 0;
5382
+ const resolvedSize = resolveSize(size);
5383
+ const basePosition = [
5384
+ target[0] ?? 0,
5385
+ target[1] ?? 0,
5386
+ target[2] ?? DEFAULT_Z
5387
+ ];
5388
+ if (!hasDirection) {
5389
+ return { position: basePosition, angle: 0 };
5390
+ }
5391
+ const { along, perpendicular } = getOffsetComponents(offset);
5392
+ const alongDistance = resolvedSize * 0.5 + along;
5393
+ const position = [
5394
+ basePosition[0] - unit[0] * alongDistance,
5395
+ basePosition[1] - unit[1] * alongDistance,
5396
+ basePosition[2] - unit[2] * alongDistance
5397
+ ];
5398
+ if (perpendicular) {
5399
+ const perp = [-unit[1], unit[0], 0];
5400
+ position[0] += perp[0] * perpendicular;
5401
+ position[1] += perp[1] * perpendicular;
5402
+ position[2] += perp[2] * perpendicular;
5403
+ }
5404
+ const angle = Math.atan2(unit[0], unit[1]) * 180 / Math.PI;
5405
+ return { position, angle };
5406
+ }
5407
+ var EdgeArrowLayer = class extends import_core16.CompositeLayer {
5408
+ renderLayers() {
5409
+ const { data, getLayoutInfo, positionUpdateTrigger = 0, stylesheet } = this.props;
5410
+ const directedEdges = (data || []).filter(isEdgeDirected);
5411
+ if (!directedEdges.length) {
5412
+ return [];
5413
+ }
5414
+ const { getColor: getColor2, getSize, getOffset: getOffset2 } = stylesheet.getDeckGLAccessors();
5415
+ const updateTriggers = stylesheet.getDeckGLUpdateTriggers();
5416
+ return [
5417
+ new import_mesh_layers.SimpleMeshLayer(this.getSubLayerProps({
5418
+ id: "__edge-arrow-layer",
5419
+ data: directedEdges,
5420
+ mesh: DEFAULT_ARROW_GEOMETRY,
5421
+ getColor: getColor2,
5422
+ getScale: (edge) => {
5423
+ const size = resolveSize(getSize(edge));
5424
+ return [size, size, size];
5425
+ },
5426
+ getOrientation: (edge) => {
5427
+ const layout = getLayoutInfo(edge);
5428
+ const size = resolveSize(getSize(edge));
5429
+ const offset = getOffset2 ? getOffset2(edge) : null;
5430
+ const { angle } = getArrowTransform({ layout, size, offset });
5431
+ return [0, -angle, 0];
5432
+ },
5433
+ getPosition: (edge) => {
5434
+ const layout = getLayoutInfo(edge);
5435
+ const size = resolveSize(getSize(edge));
5436
+ const offset = getOffset2 ? getOffset2(edge) : null;
5437
+ const { position } = getArrowTransform({ layout, size, offset });
5438
+ return position;
5439
+ },
3762
5440
  parameters: {
3763
5441
  depthTest: false
3764
5442
  },
3765
5443
  updateTriggers: {
3766
- ...stylesheet.getDeckGLUpdateTriggers(),
3767
- getSourcePosition: positionUpdateTrigger,
3768
- getTargetPosition: positionUpdateTrigger
5444
+ getColor: updateTriggers.getColor,
5445
+ getScale: updateTriggers.getSize,
5446
+ getOrientation: [
5447
+ positionUpdateTrigger,
5448
+ updateTriggers.getSize,
5449
+ updateTriggers.getOffset
5450
+ ],
5451
+ getPosition: [positionUpdateTrigger, updateTriggers.getSize, updateTriggers.getOffset]
3769
5452
  }
3770
5453
  }))
3771
5454
  ];
3772
5455
  }
3773
5456
  };
3774
- __publicField(FlowLayer, "layerName", "FlowLayer");
5457
+ __publicField(EdgeArrowLayer, "layerName", "EdgeArrowLayer");
5458
+
5459
+ // dist/utils/node-boundary.js
5460
+ var EPSILON = 1e-6;
5461
+ function normalizeDirection(center, target) {
5462
+ const dx = target[0] - center[0];
5463
+ const dy = target[1] - center[1];
5464
+ const length = Math.hypot(dx, dy);
5465
+ if (length <= EPSILON) {
5466
+ return null;
5467
+ }
5468
+ return { unit: [dx / length, dy / length], distance: length };
5469
+ }
5470
+ function projectFromCenter(center, unit, distance) {
5471
+ return [center[0] + unit[0] * distance, center[1] + unit[1] * distance];
5472
+ }
5473
+ function projectToRectangle(center, unit, halfWidth, halfHeight) {
5474
+ const absUx = Math.abs(unit[0]);
5475
+ const absUy = Math.abs(unit[1]);
5476
+ let distance = Number.POSITIVE_INFINITY;
5477
+ if (halfWidth > 0 && absUx > EPSILON) {
5478
+ distance = Math.min(distance, halfWidth / absUx);
5479
+ }
5480
+ if (halfHeight > 0 && absUy > EPSILON) {
5481
+ distance = Math.min(distance, halfHeight / absUy);
5482
+ }
5483
+ if (!Number.isFinite(distance)) {
5484
+ return [...center];
5485
+ }
5486
+ return [center[0] + unit[0] * distance, center[1] + unit[1] * distance];
5487
+ }
5488
+ function resolveCornerRadius(rawCornerRadius, halfWidth, halfHeight) {
5489
+ if (!Number.isFinite(rawCornerRadius) || rawCornerRadius <= 0) {
5490
+ return 0;
5491
+ }
5492
+ let resolved = rawCornerRadius;
5493
+ if (resolved <= 1) {
5494
+ resolved *= Math.min(halfWidth, halfHeight);
5495
+ }
5496
+ return Math.min(resolved, halfWidth, halfHeight);
5497
+ }
5498
+ function intersectsInnerFaces(absX, absY, innerHalfWidth, innerHalfHeight, halfWidth, halfHeight) {
5499
+ const insideVerticalFace = absX <= innerHalfWidth + EPSILON && absY <= halfHeight + EPSILON;
5500
+ const insideHorizontalFace = absY <= innerHalfHeight + EPSILON && absX <= halfWidth + EPSILON;
5501
+ return insideVerticalFace || insideHorizontalFace;
5502
+ }
5503
+ function projectToCornerArc(geometry, unit, innerHalfWidth, innerHalfHeight, cornerRadius, rectanglePoint) {
5504
+ const offsetX = rectanglePoint[0] - geometry.center[0];
5505
+ const offsetY = rectanglePoint[1] - geometry.center[1];
5506
+ const cornerCenter = [
5507
+ geometry.center[0] + Math.sign(offsetX || unit[0]) * innerHalfWidth,
5508
+ geometry.center[1] + Math.sign(offsetY || unit[1]) * innerHalfHeight
5509
+ ];
5510
+ const relativeCornerCenter = [
5511
+ cornerCenter[0] - geometry.center[0],
5512
+ cornerCenter[1] - geometry.center[1]
5513
+ ];
5514
+ const dot = unit[0] * relativeCornerCenter[0] + unit[1] * relativeCornerCenter[1];
5515
+ const centerDistanceSq = relativeCornerCenter[0] * relativeCornerCenter[0] + relativeCornerCenter[1] * relativeCornerCenter[1];
5516
+ const discriminant = dot * dot - (centerDistanceSq - cornerRadius * cornerRadius);
5517
+ if (discriminant < 0) {
5518
+ return rectanglePoint;
5519
+ }
5520
+ const distance = dot - Math.sqrt(Math.max(0, discriminant));
5521
+ return projectFromCenter(geometry.center, unit, distance);
5522
+ }
5523
+ function computeRectangleIntersection(geometry, unit) {
5524
+ const halfWidth = (geometry.width ?? 0) / 2;
5525
+ const halfHeight = (geometry.height ?? 0) / 2;
5526
+ if (halfWidth <= EPSILON || halfHeight <= EPSILON) {
5527
+ return [...geometry.center];
5528
+ }
5529
+ return projectToRectangle(geometry.center, unit, halfWidth, halfHeight);
5530
+ }
5531
+ function computeRoundedRectangleIntersection(geometry, unit) {
5532
+ const halfWidth = (geometry.width ?? 0) / 2;
5533
+ const halfHeight = (geometry.height ?? 0) / 2;
5534
+ if (halfWidth <= EPSILON || halfHeight <= EPSILON) {
5535
+ const radius = geometry.radius ?? Math.min(halfWidth, halfHeight);
5536
+ return projectFromCenter(geometry.center, unit, radius);
5537
+ }
5538
+ const cornerRadius = resolveCornerRadius(geometry.cornerRadius, halfWidth, halfHeight);
5539
+ if (cornerRadius <= EPSILON) {
5540
+ return projectToRectangle(geometry.center, unit, halfWidth, halfHeight);
5541
+ }
5542
+ const innerHalfWidth = Math.max(halfWidth - cornerRadius, 0);
5543
+ const innerHalfHeight = Math.max(halfHeight - cornerRadius, 0);
5544
+ if (innerHalfWidth <= EPSILON || innerHalfHeight <= EPSILON) {
5545
+ const radius = Math.min(halfWidth, halfHeight);
5546
+ return projectFromCenter(geometry.center, unit, radius);
5547
+ }
5548
+ const rectanglePoint = projectToRectangle(geometry.center, unit, halfWidth, halfHeight);
5549
+ const absX = Math.abs(rectanglePoint[0] - geometry.center[0]);
5550
+ const absY = Math.abs(rectanglePoint[1] - geometry.center[1]);
5551
+ const touchesInnerFace = absX <= innerHalfWidth + EPSILON || absY <= innerHalfHeight + EPSILON;
5552
+ if (touchesInnerFace && intersectsInnerFaces(absX, absY, innerHalfWidth, innerHalfHeight, halfWidth, halfHeight)) {
5553
+ return rectanglePoint;
5554
+ }
5555
+ return projectToCornerArc(geometry, unit, innerHalfWidth, innerHalfHeight, cornerRadius, rectanglePoint);
5556
+ }
5557
+ function computeCircleIntersection(geometry, unit, radius) {
5558
+ const effectiveRadius = radius ?? geometry.radius ?? 0;
5559
+ return projectFromCenter(geometry.center, unit, Math.max(effectiveRadius, 0));
5560
+ }
5561
+ var BOUNDARY_COMPUTERS = {
5562
+ circle: (geometry, unit) => computeCircleIntersection(geometry, unit),
5563
+ marker: (geometry, unit) => computeCircleIntersection(geometry, unit),
5564
+ rectangle: (geometry, unit) => computeRectangleIntersection(geometry, unit),
5565
+ "rounded-rectangle": (geometry, unit) => computeRoundedRectangleIntersection(geometry, unit),
5566
+ "path-rounded-rectangle": (geometry, unit) => computeRoundedRectangleIntersection(geometry, unit)
5567
+ };
5568
+ function getNodeBoundaryIntersection(geometry, targetCenter) {
5569
+ const direction = normalizeDirection(geometry.center, targetCenter);
5570
+ if (!direction) {
5571
+ return [...geometry.center];
5572
+ }
5573
+ const handler = geometry.type ? BOUNDARY_COMPUTERS[geometry.type] : void 0;
5574
+ if (handler) {
5575
+ return handler(geometry, direction.unit);
5576
+ }
5577
+ if (geometry.radius && geometry.radius > EPSILON) {
5578
+ return projectFromCenter(geometry.center, direction.unit, geometry.radius);
5579
+ }
5580
+ return [...geometry.center];
5581
+ }
5582
+
5583
+ // dist/layers/edge-attachment-helper.js
5584
+ var GEOMETRY_NODE_TYPES = [
5585
+ "circle",
5586
+ "rectangle",
5587
+ "rounded-rectangle",
5588
+ "path-rounded-rectangle",
5589
+ "marker"
5590
+ ];
5591
+ function evaluateNumericAccessor(accessor, node) {
5592
+ if (typeof accessor === "function") {
5593
+ const value = accessor(node);
5594
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
5595
+ }
5596
+ if (typeof accessor === "number" && Number.isFinite(accessor)) {
5597
+ return accessor;
5598
+ }
5599
+ return void 0;
5600
+ }
5601
+ function evaluateOffsetAccessor(accessor, node) {
5602
+ if (!accessor) {
5603
+ return [0, 0];
5604
+ }
5605
+ let value = accessor;
5606
+ if (typeof accessor === "function") {
5607
+ value = accessor(node);
5608
+ }
5609
+ if (Array.isArray(value) && value.length >= 2) {
5610
+ const offsetX = Number(value[0]);
5611
+ const offsetY = Number(value[1]);
5612
+ if (Number.isFinite(offsetX) && Number.isFinite(offsetY)) {
5613
+ return [offsetX, offsetY];
5614
+ }
5615
+ }
5616
+ return [0, 0];
5617
+ }
5618
+ function normalizePosition(value) {
5619
+ if (!value || typeof value !== "object") {
5620
+ return null;
5621
+ }
5622
+ const candidate = value;
5623
+ if (typeof candidate.length === "number" && candidate.length >= 2) {
5624
+ const x = Number(candidate[0]);
5625
+ const y = Number(candidate[1]);
5626
+ if (Number.isFinite(x) && Number.isFinite(y)) {
5627
+ return [x, y];
5628
+ }
5629
+ }
5630
+ return null;
5631
+ }
5632
+ function resolveAccessorValue(accessor, node) {
5633
+ if (!accessor) {
5634
+ return void 0;
5635
+ }
5636
+ return evaluateNumericAccessor(accessor, node);
5637
+ }
5638
+ function assignDimension(geometry, key, value) {
5639
+ if (typeof value === "number" && Number.isFinite(value)) {
5640
+ geometry[key] = Math.max(value, 0);
5641
+ }
5642
+ }
5643
+ function assignRectangleDimensions(node, accessors, geometry) {
5644
+ assignDimension(geometry, "width", resolveAccessorValue(accessors.getWidth, node));
5645
+ assignDimension(geometry, "height", resolveAccessorValue(accessors.getHeight, node));
5646
+ }
5647
+ var GEOMETRY_APPLIERS = {
5648
+ circle: (node, accessors, geometry) => {
5649
+ assignDimension(geometry, "radius", resolveAccessorValue(accessors.getRadius, node));
5650
+ },
5651
+ marker: (node, accessors, geometry) => {
5652
+ const size = resolveAccessorValue(accessors.getSize, node);
5653
+ assignDimension(geometry, "radius", typeof size === "number" ? size / 2 : void 0);
5654
+ },
5655
+ rectangle: (node, accessors, geometry) => {
5656
+ assignRectangleDimensions(node, accessors, geometry);
5657
+ },
5658
+ "rounded-rectangle": (node, accessors, geometry) => {
5659
+ assignRectangleDimensions(node, accessors, geometry);
5660
+ assignDimension(geometry, "cornerRadius", resolveAccessorValue(accessors.getCornerRadius, node));
5661
+ assignDimension(geometry, "radius", resolveAccessorValue(accessors.getRadius, node));
5662
+ },
5663
+ "path-rounded-rectangle": (node, accessors, geometry) => {
5664
+ assignRectangleDimensions(node, accessors, geometry);
5665
+ assignDimension(geometry, "cornerRadius", resolveAccessorValue(accessors.getCornerRadius, node));
5666
+ }
5667
+ };
5668
+ var EdgeAttachmentHelper = class {
5669
+ getLayoutAccessor({ engine, interactionManager, nodeStyle }) {
5670
+ const nodeAccessorMap = this._buildNodeStyleAccessorMap({
5671
+ engine,
5672
+ interactionManager,
5673
+ nodeStyle
5674
+ });
5675
+ if (nodeAccessorMap.size === 0) {
5676
+ return (edge) => engine.getEdgePosition(edge);
5677
+ }
5678
+ const nodeMap = engine.getNodes().reduce((acc, node) => acc.set(node.getId(), node), /* @__PURE__ */ new Map());
5679
+ return (edge) => this._getAdjustedEdgeLayout(engine, nodeAccessorMap, nodeMap, edge);
5680
+ }
5681
+ _buildNodeStyleAccessorMap({ engine, interactionManager, nodeStyle }) {
5682
+ const nodeAccessorMap = /* @__PURE__ */ new Map();
5683
+ if (!nodeStyle) {
5684
+ return nodeAccessorMap;
5685
+ }
5686
+ const styles = Array.isArray(nodeStyle) ? nodeStyle : [nodeStyle];
5687
+ styles.filter(Boolean).forEach((style) => {
5688
+ const { data = (nodes2) => nodes2, ...restStyle } = style;
5689
+ const type = restStyle.type;
5690
+ if (!type || !GEOMETRY_NODE_TYPES.includes(type)) {
5691
+ return;
5692
+ }
5693
+ let stylesheet = null;
5694
+ try {
5695
+ stylesheet = new GraphStyleEngine(restStyle, {
5696
+ stateUpdateTrigger: interactionManager.getLastInteraction()
5697
+ });
5698
+ } catch (error2) {
5699
+ warn(`GraphLayer: Failed to evaluate node stylesheet for edge attachment (${String(error2.message ?? error2)}).`);
5700
+ return;
5701
+ }
5702
+ const nodes = data(engine.getNodes());
5703
+ if (!Array.isArray(nodes)) {
5704
+ return;
5705
+ }
5706
+ const geometryType = type;
5707
+ const accessors = this._createAccessorsForType(geometryType, stylesheet);
5708
+ nodes.forEach((node) => {
5709
+ const id = node.getId();
5710
+ if (!nodeAccessorMap.has(id)) {
5711
+ nodeAccessorMap.set(id, accessors);
5712
+ }
5713
+ });
5714
+ });
5715
+ return nodeAccessorMap;
5716
+ }
5717
+ _getAdjustedEdgeLayout(engine, nodeAccessorMap, nodeMap, edge) {
5718
+ const layoutInfo = engine.getEdgePosition(edge);
5719
+ if (!layoutInfo) {
5720
+ return layoutInfo;
5721
+ }
5722
+ const sourceNode = nodeMap.get(edge.getSourceNodeId());
5723
+ const targetNode = nodeMap.get(edge.getTargetNodeId());
5724
+ if (!sourceNode || !targetNode) {
5725
+ return layoutInfo;
5726
+ }
5727
+ const sourceGeometry = this._computeNodeGeometry(engine, sourceNode, nodeAccessorMap.get(sourceNode.getId()));
5728
+ const targetGeometry = this._computeNodeGeometry(engine, targetNode, nodeAccessorMap.get(targetNode.getId()));
5729
+ if (!sourceGeometry && !targetGeometry) {
5730
+ return layoutInfo;
5731
+ }
5732
+ return this._applyGeometryToLayout(layoutInfo, sourceGeometry, targetGeometry);
5733
+ }
5734
+ _applyGeometryToLayout(layoutInfo, sourceGeometry, targetGeometry) {
5735
+ const adjustedLayout = { ...layoutInfo };
5736
+ const targetReference = (targetGeometry == null ? void 0 : targetGeometry.center) ?? normalizePosition(layoutInfo.targetPosition);
5737
+ const sourceReference = (sourceGeometry == null ? void 0 : sourceGeometry.center) ?? normalizePosition(layoutInfo.sourcePosition);
5738
+ if (sourceGeometry) {
5739
+ adjustedLayout.sourcePosition = targetReference ? getNodeBoundaryIntersection(sourceGeometry, targetReference) : [...sourceGeometry.center];
5740
+ }
5741
+ if (targetGeometry) {
5742
+ adjustedLayout.targetPosition = sourceReference ? getNodeBoundaryIntersection(targetGeometry, sourceReference) : [...targetGeometry.center];
5743
+ }
5744
+ return adjustedLayout;
5745
+ }
5746
+ _createAccessorsForType(geometryType, stylesheet) {
5747
+ const base = {
5748
+ type: geometryType,
5749
+ getOffset: stylesheet.getDeckGLAccessor("getOffset")
5750
+ };
5751
+ switch (geometryType) {
5752
+ case "circle":
5753
+ base.getRadius = stylesheet.getDeckGLAccessor("getRadius");
5754
+ break;
5755
+ case "marker":
5756
+ base.getSize = stylesheet.getDeckGLAccessor("getSize");
5757
+ break;
5758
+ case "rectangle":
5759
+ base.getWidth = stylesheet.getDeckGLAccessor("getWidth");
5760
+ base.getHeight = stylesheet.getDeckGLAccessor("getHeight");
5761
+ break;
5762
+ case "rounded-rectangle":
5763
+ base.getWidth = stylesheet.getDeckGLAccessor("getWidth");
5764
+ base.getHeight = stylesheet.getDeckGLAccessor("getHeight");
5765
+ base.getCornerRadius = stylesheet.getDeckGLAccessor("getCornerRadius");
5766
+ base.getRadius = stylesheet.getDeckGLAccessor("getRadius");
5767
+ break;
5768
+ case "path-rounded-rectangle":
5769
+ base.getWidth = stylesheet.getDeckGLAccessor("getWidth");
5770
+ base.getHeight = stylesheet.getDeckGLAccessor("getHeight");
5771
+ base.getCornerRadius = stylesheet.getDeckGLAccessor("getCornerRadius");
5772
+ break;
5773
+ default:
5774
+ break;
5775
+ }
5776
+ return base;
5777
+ }
5778
+ _computeNodeGeometry(engine, node, accessors) {
5779
+ const basePosition = engine.getNodePosition(node);
5780
+ if (!basePosition) {
5781
+ return null;
5782
+ }
5783
+ const offset = evaluateOffsetAccessor(accessors == null ? void 0 : accessors.getOffset, node);
5784
+ const center = [basePosition[0] + offset[0], basePosition[1] + offset[1]];
5785
+ const geometry = {
5786
+ type: accessors == null ? void 0 : accessors.type,
5787
+ center
5788
+ };
5789
+ if (!accessors || !accessors.type) {
5790
+ return geometry;
5791
+ }
5792
+ const applier = GEOMETRY_APPLIERS[accessors.type];
5793
+ if (applier) {
5794
+ applier(node, accessors, geometry);
5795
+ }
5796
+ return geometry;
5797
+ }
5798
+ };
3775
5799
 
3776
5800
  // dist/loaders/create-graph.js
3777
5801
  function createGraph(props) {
@@ -3804,7 +5828,7 @@ function createGraph(props) {
3804
5828
  // dist/loaders/node-parsers.js
3805
5829
  function basicNodeParser(node) {
3806
5830
  if (node.id === void 0) {
3807
- log.error("Invalid node: id is missing.")();
5831
+ error("Invalid node: id is missing.");
3808
5832
  return null;
3809
5833
  }
3810
5834
  return { id: node.id };
@@ -3814,7 +5838,7 @@ function basicNodeParser(node) {
3814
5838
  function basicEdgeParser(edge) {
3815
5839
  const { id, directed, sourceId, targetId } = edge;
3816
5840
  if (sourceId === void 0 || targetId === void 0) {
3817
- log.error("Invalid edge: sourceId or targetId is missing.")();
5841
+ error("Invalid edge: sourceId or targetId is missing.");
3818
5842
  return null;
3819
5843
  }
3820
5844
  return {
@@ -3829,7 +5853,7 @@ function basicEdgeParser(edge) {
3829
5853
  var JSONLoader = ({ json, nodeParser = basicNodeParser, edgeParser = basicEdgeParser }) => {
3830
5854
  const { name = "default", nodes, edges } = json;
3831
5855
  if (!nodes) {
3832
- log.error("Invalid graph: nodes is missing.")();
5856
+ error("Invalid graph: nodes is missing.");
3833
5857
  return null;
3834
5858
  }
3835
5859
  const graph = createGraph({ name, nodes, edges, nodeParser, edgeParser });
@@ -3838,27 +5862,33 @@ var JSONLoader = ({ json, nodeParser = basicNodeParser, edgeParser = basicEdgePa
3838
5862
 
3839
5863
  // dist/layers/graph-layer.js
3840
5864
  var NODE_LAYER_MAP = {
3841
- [NODE_TYPE.RECTANGLE]: RectangleLayer,
3842
- [NODE_TYPE.ROUNDED_RECTANGLE]: RoundedRectangleLayer,
3843
- [NODE_TYPE.PATH_ROUNDED_RECTANGLE]: PathBasedRoundedRectangleLayer,
3844
- [NODE_TYPE.ICON]: ImageLayer,
3845
- [NODE_TYPE.CIRCLE]: CircleLayer,
3846
- [NODE_TYPE.LABEL]: LabelLayer,
3847
- [NODE_TYPE.MARKER]: ZoomableMarkerLayer
5865
+ "rectangle": RectangleLayer,
5866
+ "rounded-rectangle": RoundedRectangleLayer,
5867
+ "path-rounded-rectangle": PathBasedRoundedRectangleLayer,
5868
+ "icon": ImageLayer,
5869
+ "circle": CircleLayer,
5870
+ "label": LabelLayer,
5871
+ "marker": ZoomableMarkerLayer
3848
5872
  };
3849
5873
  var EDGE_DECORATOR_LAYER_MAP = {
3850
- [EDGE_DECORATOR_TYPE.LABEL]: EdgeLabelLayer,
3851
- [EDGE_DECORATOR_TYPE.FLOW]: FlowLayer
5874
+ "edge-label": EdgeLabelLayer,
5875
+ "flow": FlowLayer,
5876
+ "arrow": EdgeArrowLayer
3852
5877
  };
3853
5878
  var SHARED_LAYER_PROPS = {
3854
- coordinateSystem: import_core16.COORDINATE_SYSTEM.CARTESIAN,
5879
+ coordinateSystem: import_core17.COORDINATE_SYSTEM.CARTESIAN,
3855
5880
  parameters: {
3856
5881
  depthTest: false
3857
5882
  }
3858
5883
  };
3859
- var GraphLayer = class extends import_core16.CompositeLayer {
5884
+ var NODE_STYLE_DEPRECATION_MESSAGE = "GraphLayer: `nodeStyle` has been replaced by `stylesheet.nodes` and will be removed in a future release.";
5885
+ var EDGE_STYLE_DEPRECATION_MESSAGE = "GraphLayer: `edgeStyle` has been replaced by `stylesheet.edges` and will be removed in a future release.";
5886
+ var NODE_STYLE_DEPRECATION_WARNED = false;
5887
+ var EDGE_STYLE_DEPRECATION_WARNED = false;
5888
+ var GraphLayer = class extends import_core17.CompositeLayer {
3860
5889
  // @ts-expect-error Some typescript confusion due to override of base class state
3861
5890
  state;
5891
+ _edgeAttachmentHelper = new EdgeAttachmentHelper();
3862
5892
  forceUpdate = () => {
3863
5893
  if (this.context && this.context.layerManager) {
3864
5894
  this.setNeedsUpdate();
@@ -3891,11 +5921,44 @@ var GraphLayer = class extends import_core16.CompositeLayer {
3891
5921
  this._setGraphEngine(graphEngine);
3892
5922
  this.state.interactionManager.updateProps(props);
3893
5923
  this.forceUpdate();
5924
+ } else if (changeFlags.propsChanged && props.engine !== oldProps.engine) {
5925
+ this._setGraphEngine(props.engine);
5926
+ this.state.interactionManager.updateProps(props);
5927
+ this.forceUpdate();
3894
5928
  }
3895
5929
  }
3896
5930
  finalize() {
3897
5931
  this._removeGraphEngine();
3898
5932
  }
5933
+ _getResolvedStylesheet() {
5934
+ const { stylesheet, nodeStyle, edgeStyle } = this.props;
5935
+ const usingNodeStyle = typeof nodeStyle !== "undefined";
5936
+ if (usingNodeStyle && !NODE_STYLE_DEPRECATION_WARNED) {
5937
+ warn(NODE_STYLE_DEPRECATION_MESSAGE);
5938
+ NODE_STYLE_DEPRECATION_WARNED = true;
5939
+ }
5940
+ const usingEdgeStyle = typeof edgeStyle !== "undefined";
5941
+ if (usingEdgeStyle && !EDGE_STYLE_DEPRECATION_WARNED) {
5942
+ warn(EDGE_STYLE_DEPRECATION_MESSAGE);
5943
+ EDGE_STYLE_DEPRECATION_WARNED = true;
5944
+ }
5945
+ return normalizeGraphLayerStylesheet({
5946
+ stylesheet,
5947
+ nodeStyle: usingNodeStyle ? nodeStyle : void 0,
5948
+ edgeStyle: usingEdgeStyle ? edgeStyle : void 0
5949
+ });
5950
+ }
5951
+ _createStyleEngine(style, context) {
5952
+ try {
5953
+ return new GraphStyleEngine(style, {
5954
+ stateUpdateTrigger: this.state.interactionManager.getLastInteraction()
5955
+ });
5956
+ } catch (error2) {
5957
+ const message = error2 instanceof Error ? error2.message : String(error2);
5958
+ warn(`GraphLayer: Failed to apply ${context}: ${message}`);
5959
+ return null;
5960
+ }
5961
+ }
3899
5962
  _setGraphEngine(graphEngine) {
3900
5963
  if (graphEngine === this.state.graphEngine) {
3901
5964
  return;
@@ -3916,20 +5979,21 @@ var GraphLayer = class extends import_core16.CompositeLayer {
3916
5979
  }
3917
5980
  createNodeLayers() {
3918
5981
  const engine = this.state.graphEngine;
3919
- const { nodeStyle } = this.props;
3920
- if (!engine || !nodeStyle || !Array.isArray(nodeStyle) || nodeStyle.length === 0) {
5982
+ const { nodes: nodeStyles } = this._getResolvedStylesheet();
5983
+ if (!engine || !Array.isArray(nodeStyles) || nodeStyles.length === 0) {
3921
5984
  return [];
3922
5985
  }
3923
- return nodeStyle.filter(Boolean).map((style, idx) => {
5986
+ const baseLayers = nodeStyles.filter(Boolean).map((style, idx) => {
3924
5987
  const { pickable = true, visible = true, data = (nodes) => nodes, ...restStyle } = style;
3925
5988
  const LayerType = NODE_LAYER_MAP[style.type];
3926
5989
  if (!LayerType) {
3927
- log.error(`Invalid node type: ${style.type}`)();
3928
- throw new Error(`Invalid node type: ${style.type}`);
5990
+ warn(`GraphLayer: Invalid node type "${style.type}".`);
5991
+ return null;
5992
+ }
5993
+ const stylesheet = this._createStyleEngine(restStyle, `node stylesheet "${style.type}"`);
5994
+ if (!stylesheet) {
5995
+ return null;
3929
5996
  }
3930
- const stylesheet = new Stylesheet(restStyle, {
3931
- stateUpdateTrigger: this.state.interactionManager.getLastInteraction()
3932
- });
3933
5997
  const getOffset2 = stylesheet.getDeckGLAccessor("getOffset");
3934
5998
  return new LayerType({
3935
5999
  ...SHARED_LAYER_PROPS,
@@ -3945,55 +6009,68 @@ var GraphLayer = class extends import_core16.CompositeLayer {
3945
6009
  stylesheet,
3946
6010
  visible
3947
6011
  });
3948
- });
6012
+ }).filter(Boolean);
6013
+ const chainLayers = this._createChainOverlayLayers(engine);
6014
+ return [...baseLayers, ...chainLayers];
3949
6015
  }
3950
6016
  createEdgeLayers() {
3951
6017
  const engine = this.state.graphEngine;
3952
- const { edgeStyle } = this.props;
3953
- if (!engine || !edgeStyle) {
6018
+ const { edges: edgeStyles, nodes: nodeStyles } = this._getResolvedStylesheet();
6019
+ if (!engine || !edgeStyles) {
6020
+ return [];
6021
+ }
6022
+ const edgeStyleArray = Array.isArray(edgeStyles) ? edgeStyles : [edgeStyles];
6023
+ if (edgeStyleArray.length === 0) {
3954
6024
  return [];
3955
6025
  }
3956
- return (Array.isArray(edgeStyle) ? edgeStyle : [edgeStyle]).filter(Boolean).flatMap((style, idx) => {
6026
+ const getLayoutInfo = this._edgeAttachmentHelper.getLayoutAccessor({
6027
+ engine,
6028
+ interactionManager: this.state.interactionManager,
6029
+ nodeStyle: nodeStyles
6030
+ });
6031
+ return edgeStyleArray.filter(Boolean).flatMap((style, idx) => {
3957
6032
  const { decorators, data = (edges) => edges, visible = true, ...restEdgeStyle } = style;
3958
- const stylesheet = new Stylesheet({
3959
- type: "Edge",
6033
+ const stylesheet = this._createStyleEngine({
6034
+ type: "edge",
3960
6035
  ...restEdgeStyle
3961
- }, {
3962
- stateUpdateTrigger: this.state.interactionManager.getLastInteraction()
3963
- });
6036
+ }, "edge stylesheet");
6037
+ if (!stylesheet) {
6038
+ return [];
6039
+ }
3964
6040
  const edgeLayer = new EdgeLayer({
3965
6041
  ...SHARED_LAYER_PROPS,
3966
6042
  id: `edge-layer-${idx}`,
3967
6043
  data: data(engine.getEdges()),
3968
- getLayoutInfo: engine.getEdgePosition,
6044
+ getLayoutInfo,
3969
6045
  pickable: true,
3970
6046
  positionUpdateTrigger: [engine.getLayoutLastUpdate(), engine.getLayoutState()].join(),
3971
6047
  stylesheet,
3972
6048
  visible
3973
6049
  });
3974
6050
  if (!decorators || !Array.isArray(decorators) || decorators.length === 0) {
3975
- return edgeLayer;
6051
+ return [edgeLayer];
3976
6052
  }
3977
- const decoratorLayers = decorators.filter(Boolean).flatMap((decoratorStyle, idx2) => {
6053
+ const decoratorLayers = decorators.filter(Boolean).map((decoratorStyle, idx2) => {
3978
6054
  const DecoratorLayer = EDGE_DECORATOR_LAYER_MAP[decoratorStyle.type];
3979
6055
  if (!DecoratorLayer) {
3980
- log.error(`Invalid edge decorator type: ${decoratorStyle.type}`)();
3981
- throw new Error(`Invalid edge decorator type: ${decoratorStyle.type}`);
6056
+ warn(`GraphLayer: Invalid edge decorator type "${decoratorStyle.type}".`);
6057
+ return null;
6058
+ }
6059
+ const decoratorStylesheet = this._createStyleEngine(decoratorStyle, `edge decorator stylesheet "${decoratorStyle.type}"`);
6060
+ if (!decoratorStylesheet) {
6061
+ return null;
3982
6062
  }
3983
- const decoratorStylesheet = new Stylesheet(decoratorStyle, {
3984
- stateUpdateTrigger: this.state.interactionManager.getLastInteraction()
3985
- });
3986
6063
  return new DecoratorLayer({
3987
6064
  ...SHARED_LAYER_PROPS,
3988
6065
  id: `edge-decorator-${idx2}`,
3989
6066
  data: data(engine.getEdges()),
3990
- getLayoutInfo: engine.getEdgePosition,
6067
+ getLayoutInfo,
3991
6068
  pickable: true,
3992
6069
  positionUpdateTrigger: [engine.getLayoutLastUpdate(), engine.getLayoutState()].join(),
3993
6070
  stylesheet: decoratorStylesheet
3994
6071
  });
3995
- });
3996
- return [edgeLayer, decoratorLayers];
6072
+ }).filter(Boolean);
6073
+ return [edgeLayer, ...decoratorLayers];
3997
6074
  });
3998
6075
  }
3999
6076
  onClick(info, event) {
@@ -4014,6 +6091,101 @@ var GraphLayer = class extends import_core16.CompositeLayer {
4014
6091
  renderLayers() {
4015
6092
  return [this.createEdgeLayers(), this.createNodeLayers()];
4016
6093
  }
6094
+ _createChainOverlayLayers(engine) {
6095
+ const chainData = buildCollapsedChainLayers(engine);
6096
+ if (!chainData) {
6097
+ return [];
6098
+ }
6099
+ const { collapsedNodes, collapsedOutlineNodes, expandedNodes, expandedOutlineNodes, getChainOutlinePolygon, outlineUpdateTrigger } = chainData;
6100
+ const layers = [];
6101
+ if (collapsedOutlineNodes.length > 0) {
6102
+ layers.push(new import_layers12.PolygonLayer({
6103
+ ...SHARED_LAYER_PROPS,
6104
+ id: "collapsed-chain-outlines",
6105
+ data: collapsedOutlineNodes,
6106
+ getPolygon: (node) => getChainOutlinePolygon(node),
6107
+ stroked: true,
6108
+ filled: false,
6109
+ getLineColor: [220, 64, 64, 220],
6110
+ getLineWidth: 2,
6111
+ lineWidthUnits: "pixels",
6112
+ lineWidthMinPixels: 2,
6113
+ pickable: true,
6114
+ updateTriggers: {
6115
+ getPolygon: [outlineUpdateTrigger]
6116
+ }
6117
+ }));
6118
+ }
6119
+ const collapsedMarkerStylesheet = this._createStyleEngine({
6120
+ type: "marker",
6121
+ fill: [64, 96, 192, 255],
6122
+ size: 32,
6123
+ marker: "circle-plus-filled",
6124
+ offset: [24, -24],
6125
+ scaleWithZoom: false
6126
+ }, "collapsed chain marker stylesheet");
6127
+ if (collapsedMarkerStylesheet && collapsedNodes.length > 0) {
6128
+ const getOffset2 = collapsedMarkerStylesheet.getDeckGLAccessor("getOffset");
6129
+ layers.push(new ZoomableMarkerLayer({
6130
+ ...SHARED_LAYER_PROPS,
6131
+ id: "collapsed-chain-markers",
6132
+ data: collapsedNodes,
6133
+ getPosition: mixedGetPosition(engine.getNodePosition, getOffset2),
6134
+ pickable: true,
6135
+ positionUpdateTrigger: [
6136
+ engine.getLayoutLastUpdate(),
6137
+ engine.getLayoutState(),
6138
+ collapsedMarkerStylesheet.getDeckGLAccessorUpdateTrigger("getOffset")
6139
+ ].join(),
6140
+ stylesheet: collapsedMarkerStylesheet,
6141
+ visible: true
6142
+ }));
6143
+ }
6144
+ if (expandedOutlineNodes.length > 0) {
6145
+ layers.push(new import_layers12.PolygonLayer({
6146
+ ...SHARED_LAYER_PROPS,
6147
+ id: "expanded-chain-outlines",
6148
+ data: expandedOutlineNodes,
6149
+ getPolygon: (node) => getChainOutlinePolygon(node),
6150
+ stroked: true,
6151
+ filled: false,
6152
+ getLineColor: [64, 96, 192, 200],
6153
+ getLineWidth: 2,
6154
+ lineWidthUnits: "pixels",
6155
+ lineWidthMinPixels: 2,
6156
+ pickable: true,
6157
+ updateTriggers: {
6158
+ getPolygon: [outlineUpdateTrigger]
6159
+ }
6160
+ }));
6161
+ }
6162
+ const expandedMarkerStylesheet = this._createStyleEngine({
6163
+ type: "marker",
6164
+ fill: [64, 96, 192, 255],
6165
+ size: 32,
6166
+ marker: "circle-minus-filled",
6167
+ offset: [24, -24],
6168
+ scaleWithZoom: false
6169
+ }, "expanded chain marker stylesheet");
6170
+ if (expandedMarkerStylesheet && expandedNodes.length > 0) {
6171
+ const getOffset2 = expandedMarkerStylesheet.getDeckGLAccessor("getOffset");
6172
+ layers.push(new ZoomableMarkerLayer({
6173
+ ...SHARED_LAYER_PROPS,
6174
+ id: "expanded-chain-markers",
6175
+ data: expandedNodes,
6176
+ getPosition: mixedGetPosition(engine.getNodePosition, getOffset2),
6177
+ pickable: true,
6178
+ positionUpdateTrigger: [
6179
+ engine.getLayoutLastUpdate(),
6180
+ engine.getLayoutState(),
6181
+ expandedMarkerStylesheet.getDeckGLAccessorUpdateTrigger("getOffset")
6182
+ ].join(),
6183
+ stylesheet: expandedMarkerStylesheet,
6184
+ visible: true
6185
+ }));
6186
+ }
6187
+ return layers;
6188
+ }
4017
6189
  };
4018
6190
  __publicField(GraphLayer, "layerName", "GraphLayer");
4019
6191
  __publicField(GraphLayer, "defaultProps", {
@@ -4022,7 +6194,8 @@ __publicField(GraphLayer, "defaultProps", {
4022
6194
  pickable: true,
4023
6195
  // Graph props
4024
6196
  graphLoader: JSONLoader,
4025
- nodeStyle: [],
6197
+ stylesheet: DEFAULT_GRAPH_LAYER_STYLESHEET,
6198
+ nodeStyle: void 0,
4026
6199
  nodeEvents: {
4027
6200
  onMouseLeave: () => {
4028
6201
  },
@@ -4035,12 +6208,7 @@ __publicField(GraphLayer, "defaultProps", {
4035
6208
  onDrag: () => {
4036
6209
  }
4037
6210
  },
4038
- edgeStyle: {
4039
- stroke: "black",
4040
- strokeWidth: 1,
4041
- // an array of styles for layers
4042
- decorators: []
4043
- },
6211
+ edgeStyle: void 0,
4044
6212
  edgeEvents: {
4045
6213
  onClick: () => {
4046
6214
  },
@@ -4053,6 +6221,7 @@ __publicField(GraphLayer, "defaultProps", {
4053
6221
  // dist/widgets/view-control-widget.js
4054
6222
  var import_jsx_runtime2 = require("preact/jsx-runtime");
4055
6223
  var import_preact2 = require("preact");
6224
+ var import_core18 = require("@deck.gl/core");
4056
6225
 
4057
6226
  // dist/widgets/long-press-button.js
4058
6227
  var import_jsx_runtime = require("preact/jsx-runtime");
@@ -4198,22 +6367,21 @@ __publicField(ViewControl, "defaultProps", {
4198
6367
  style: {},
4199
6368
  className: ""
4200
6369
  });
4201
- var ViewControlWidget = class {
6370
+ var ViewControlWidget = class extends import_core18.Widget {
4202
6371
  id = "zoom";
4203
- props;
4204
6372
  placement = "top-left";
4205
6373
  orientation = "vertical";
4206
6374
  viewId = null;
4207
6375
  viewports = {};
4208
- deck;
4209
6376
  element;
6377
+ className = "deck-widget-view-control";
4210
6378
  constructor(props) {
6379
+ super(props);
4211
6380
  this.props = { ...ViewControl.defaultProps, ...props };
4212
6381
  this.id = props.id || "zoom";
4213
6382
  this.viewId = props.viewId || null;
4214
6383
  this.placement = props.placement || "top-left";
4215
6384
  props.style = props.style || {};
4216
- this.props = props;
4217
6385
  }
4218
6386
  onAdd({ deck }) {
4219
6387
  this.deck = deck;
@@ -4226,14 +6394,16 @@ var ViewControlWidget = class {
4226
6394
  if (style) {
4227
6395
  Object.entries(style).map(([key, value]) => this.element.style.setProperty(key, value));
4228
6396
  }
4229
- const ui = (0, import_jsx_runtime2.jsx)(ViewControl, { ...this.props, zoomBy: this.handleDeltaZoom.bind(this), panBy: this.handlePanBy.bind(this) });
4230
- (0, import_preact2.render)(ui, this.element);
4231
6397
  return this.element;
4232
6398
  }
4233
6399
  onRemove() {
4234
6400
  this.deck = void 0;
4235
6401
  this.element = void 0;
4236
6402
  }
6403
+ onRenderHTML(rootElement) {
6404
+ const ui = (0, import_jsx_runtime2.jsx)(ViewControl, { ...this.props, zoomBy: this.handleDeltaZoom.bind(this), panBy: this.handlePanBy.bind(this) });
6405
+ (0, import_preact2.render)(ui, rootElement);
6406
+ }
4237
6407
  setProps(props) {
4238
6408
  Object.assign(this.props, props);
4239
6409
  }
@@ -4278,10 +6448,112 @@ function loadSimpleJSONGraph(json, options) {
4278
6448
  const { nodeParser = basicNodeParser, edgeParser = basicEdgeParser } = options;
4279
6449
  const { name = "default", nodes, edges } = json;
4280
6450
  if (!nodes) {
4281
- log.error("Invalid graph: nodes is missing.")();
6451
+ error("Invalid graph: nodes is missing.");
4282
6452
  return null;
4283
6453
  }
4284
6454
  const graph = createGraph({ name, nodes, edges, nodeParser, edgeParser });
4285
6455
  return graph;
4286
6456
  }
6457
+
6458
+ // dist/_deprecated/old-constants.js
6459
+ var MARKER_TYPE = {
6460
+ "bell-filled": "bell-filled",
6461
+ bell: "bell",
6462
+ "bookmark-filled": "bookmark-filled",
6463
+ bookmark: "bookmark",
6464
+ "cd-filled": "cd-filled",
6465
+ cd: "cd",
6466
+ checkmark: "checkmark",
6467
+ "circle-check-filled": "circle-check-filled",
6468
+ "circle-check": "circle-check",
6469
+ "circle-filled": "circle-filled",
6470
+ "circle-i-filled": "circle-i-filled",
6471
+ "circle-i": "circle-i",
6472
+ "circle-minus-filled": "circle-minus-filled",
6473
+ "circle-minus": "circle-minus",
6474
+ "circle-plus-filled": "circle-plus-filled",
6475
+ "circle-plus": "circle-plus",
6476
+ "circle-questionmark-filled": "circle-questionmark-filled",
6477
+ "circle-questionmark": "circle-questionmark",
6478
+ "circle-slash-filled": "circle-slash-filled",
6479
+ "circle-slash": "circle-slash",
6480
+ "circle-x-filled": "circle-x-filled",
6481
+ "circle-x": "circle-x",
6482
+ circle: "circle",
6483
+ "diamond-filled": "diamond-filled",
6484
+ diamond: "diamond",
6485
+ "flag-filled": "flag-filled",
6486
+ flag: "flag",
6487
+ gear: "gear",
6488
+ "heart-filled": "heart-filled",
6489
+ heart: "heart",
6490
+ "location-marker-filled": "location-marker-filled",
6491
+ "location-marker": "location-marker",
6492
+ "octagonal-star-filled": "octagonal-star-filled",
6493
+ "octagonal-star": "octagonal-star",
6494
+ "person-filled": "person-filled",
6495
+ person: "person",
6496
+ "pin-filled": "pin-filled",
6497
+ pin: "pin",
6498
+ "plus-small": "plus-small",
6499
+ plus: "plus",
6500
+ "rectangle-filled": "rectangle-filled",
6501
+ rectangle: "rectangle",
6502
+ "star-filled": "star-filled",
6503
+ star: "star",
6504
+ "tag-filled": "tag-filled",
6505
+ tag: "tag",
6506
+ "thumb-down-filled": "thumb-down-filled",
6507
+ "thumb-down": "thumb-down",
6508
+ "thumb-up": "thumb-up",
6509
+ "thumb_up-filled": "thumb_up-filled",
6510
+ "triangle-down-filled": "triangle-down-filled",
6511
+ "triangle-down": "triangle-down",
6512
+ "triangle-left-filled": "triangle-left-filled",
6513
+ "triangle-left": "triangle-left",
6514
+ "triangle-right-filled": "triangle-right-filled",
6515
+ "triangle-right": "triangle-right",
6516
+ "triangle-up-filled": "triangle-up-filled",
6517
+ "triangle-up": "triangle-up",
6518
+ "x-small": "x-small",
6519
+ x: "x"
6520
+ };
6521
+ var NODE_STATE = {
6522
+ DEFAULT: "default",
6523
+ HOVER: "hover",
6524
+ DRAGGING: "dragging",
6525
+ SELECTED: "selected"
6526
+ };
6527
+ var EDGE_STATE = {
6528
+ DEFAULT: "default",
6529
+ HOVER: "hover",
6530
+ DRAGGING: "dragging",
6531
+ SELECTED: "selected"
6532
+ };
6533
+ var NODE_TYPE = {
6534
+ CIRCLE: "circle",
6535
+ RECTANGLE: "rectangle",
6536
+ ROUNDED_RECTANGLE: "rounded-rectangle",
6537
+ PATH_ROUNDED_RECTANGLE: "path-rounded-rectangle",
6538
+ ICON: "icon",
6539
+ LABEL: "label",
6540
+ MARKER: "marker"
6541
+ };
6542
+ var EDGE_TYPE = {
6543
+ SPLINE_CURVE: "spline",
6544
+ LINE: "line",
6545
+ PATH: "path"
6546
+ };
6547
+ var EDGE_DECORATOR_TYPE = {
6548
+ LABEL: "label",
6549
+ FLOW: "flow",
6550
+ ARROW: "arrow"
6551
+ };
6552
+ var LAYOUT_STATE = {
6553
+ INIT: "init",
6554
+ START: "start",
6555
+ CALCULATING: "calculating",
6556
+ DONE: "done",
6557
+ ERROR: "error"
6558
+ };
4287
6559
  //# sourceMappingURL=index.cjs.map