@aranzatech/diagrams-bpmn 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -768,8 +768,8 @@ var BPMN_THEME = {
768
768
  fontFamily: "Inter, system-ui, sans-serif",
769
769
  fontSize: 11,
770
770
  labelColor: "#0f172a",
771
- shadow: "0 4px 12px rgba(15, 23, 42, 0.08)",
772
- shadowSelected: "0 0 0 4px rgba(37, 99, 235, 0.14), 0 8px 18px rgba(15, 23, 42, 0.12)",
771
+ shadow: "none",
772
+ shadowSelected: "none",
773
773
  transition: "box-shadow 140ms ease, filter 140ms ease, transform 140ms ease"
774
774
  };
775
775
  function resolveStroke(selected, override) {
@@ -779,8 +779,8 @@ function resolveStroke(selected, override) {
779
779
  function resolveStrokeWidth(selected) {
780
780
  return selected ? BPMN_THEME.strokeWidthSelected : BPMN_THEME.strokeWidth;
781
781
  }
782
- function resolveShapeFilter(selected) {
783
- return selected ? "drop-shadow(0 0 0 rgba(37,99,235,0.2)) drop-shadow(0 8px 14px rgba(15,23,42,0.12))" : "drop-shadow(0 4px 10px rgba(15,23,42,0.08))";
782
+ function resolveShapeFilter(_selected) {
783
+ return void 0;
784
784
  }
785
785
  function resolveNodeShadow(selected) {
786
786
  return selected ? BPMN_THEME.shadowSelected : BPMN_THEME.shadow;
@@ -937,7 +937,7 @@ function StartEventNode({ data, selected }) {
937
937
  const trigger = d.trigger ?? "none";
938
938
  const dashArray = d.isNonInterrupting ? "4 2" : void 0;
939
939
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: SIZE, height: SIZE, position: "relative" }, children: [
940
- /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: SIZE, height: SIZE, style: { overflow: "visible", display: "block", filter: resolveShapeFilter(selected) }, children: [
940
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: SIZE, height: SIZE, style: { overflow: "visible", display: "block", filter: resolveShapeFilter() }, children: [
941
941
  /* @__PURE__ */ jsxRuntime.jsx(
942
942
  "circle",
943
943
  {
@@ -966,7 +966,7 @@ function EndEventNode({ data, selected }) {
966
966
  const fill = d.color?.fill ?? BPMN_THEME.fill;
967
967
  const trigger = d.trigger ?? "none";
968
968
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: SIZE2, height: SIZE2, position: "relative" }, children: [
969
- /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: SIZE2, height: SIZE2, style: { overflow: "visible", display: "block", filter: resolveShapeFilter(selected) }, children: [
969
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: SIZE2, height: SIZE2, style: { overflow: "visible", display: "block", filter: resolveShapeFilter() }, children: [
970
970
  /* @__PURE__ */ jsxRuntime.jsx(
971
971
  "circle",
972
972
  {
@@ -996,7 +996,7 @@ function IntermediateCatchEventNode({ data, selected }) {
996
996
  const fill = d.color?.fill ?? BPMN_THEME.fill;
997
997
  const trigger = d.trigger && d.trigger !== "none" ? d.trigger : "timer";
998
998
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: SIZE3, height: SIZE3, position: "relative" }, children: [
999
- /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: SIZE3, height: SIZE3, style: { overflow: "visible", display: "block", filter: resolveShapeFilter(selected) }, children: [
999
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: SIZE3, height: SIZE3, style: { overflow: "visible", display: "block", filter: resolveShapeFilter() }, children: [
1000
1000
  /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: CX3, cy: CX3, r: R_OUTER, fill, stroke, strokeWidth: sw }),
1001
1001
  /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: CX3, cy: CX3, r: R_INNER, fill: "none", stroke, strokeWidth: sw }),
1002
1002
  /* @__PURE__ */ jsxRuntime.jsx(EventMarker, { cx: CX3, cy: CX3, trigger, filled: false, stroke, bg: fill, r: ICON_R })
@@ -1012,7 +1012,7 @@ function IntermediateThrowEventNode({ data, selected }) {
1012
1012
  const fill = d.color?.fill ?? BPMN_THEME.fill;
1013
1013
  const trigger = d.trigger && d.trigger !== "none" ? d.trigger : "message";
1014
1014
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: SIZE3, height: SIZE3, position: "relative" }, children: [
1015
- /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: SIZE3, height: SIZE3, style: { overflow: "visible", display: "block", filter: resolveShapeFilter(selected) }, children: [
1015
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: SIZE3, height: SIZE3, style: { overflow: "visible", display: "block", filter: resolveShapeFilter() }, children: [
1016
1016
  /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: CX3, cy: CX3, r: R_OUTER, fill, stroke, strokeWidth: sw }),
1017
1017
  /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: CX3, cy: CX3, r: R_INNER, fill: stroke, stroke, strokeWidth: sw }),
1018
1018
  /* @__PURE__ */ jsxRuntime.jsx(EventMarker, { cx: CX3, cy: CX3, trigger, filled: true, stroke: fill, bg: stroke, r: ICON_R })
@@ -1029,7 +1029,7 @@ function BoundaryEventNode({ data, selected }) {
1029
1029
  const trigger = d.trigger && d.trigger !== "none" ? d.trigger : "timer";
1030
1030
  const dashArray = d.isNonInterrupting ? "4 2" : void 0;
1031
1031
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: SIZE3, height: SIZE3, position: "relative" }, children: [
1032
- /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: SIZE3, height: SIZE3, style: { overflow: "visible", display: "block", filter: resolveShapeFilter(selected) }, children: [
1032
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: SIZE3, height: SIZE3, style: { overflow: "visible", display: "block", filter: resolveShapeFilter() }, children: [
1033
1033
  /* @__PURE__ */ jsxRuntime.jsx(
1034
1034
  "circle",
1035
1035
  {
@@ -1304,7 +1304,7 @@ function GatewayNode({ data, selected }) {
1304
1304
  const stroke = resolveStroke(selected, d.color?.stroke);
1305
1305
  const sw = resolveStrokeWidth(selected);
1306
1306
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: SIZE4, height: SIZE4, position: "relative" }, children: [
1307
- /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: SIZE4, height: SIZE4, style: { overflow: "visible", display: "block", filter: resolveShapeFilter(selected) }, children: [
1307
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: SIZE4, height: SIZE4, style: { overflow: "visible", display: "block", filter: resolveShapeFilter() }, children: [
1308
1308
  /* @__PURE__ */ jsxRuntime.jsx(
1309
1309
  "polygon",
1310
1310
  {
@@ -1740,7 +1740,7 @@ function DataObjectNode({ data, selected }) {
1740
1740
  `L ${W} ${FOLD}`
1741
1741
  ].join(" ");
1742
1742
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: W, height: H2, position: "relative" }, children: [
1743
- /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: W, height: H2, style: { overflow: "visible", display: "block", filter: resolveShapeFilter(selected) }, children: [
1743
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: W, height: H2, style: { overflow: "visible", display: "block", filter: resolveShapeFilter() }, children: [
1744
1744
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: path, fill, stroke, strokeWidth: sw }),
1745
1745
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: foldPath2, fill: "none", stroke, strokeWidth: sw })
1746
1746
  ] }),
@@ -1758,7 +1758,7 @@ function DataStoreNode({ data, selected }) {
1758
1758
  const sw = resolveStrokeWidth(selected);
1759
1759
  const fill = d.color?.fill ?? BPMN_THEME.fill;
1760
1760
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: DS_W, height: DS_H, position: "relative" }, children: [
1761
- /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: DS_W, height: DS_H, style: { overflow: "visible", display: "block", filter: resolveShapeFilter(selected) }, children: [
1761
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: DS_W, height: DS_H, style: { overflow: "visible", display: "block", filter: resolveShapeFilter() }, children: [
1762
1762
  /* @__PURE__ */ jsxRuntime.jsx(
1763
1763
  "path",
1764
1764
  {
@@ -1804,7 +1804,7 @@ function DataObjectReferenceNode({ data, selected }) {
1804
1804
  const sw = resolveStrokeWidth(selected);
1805
1805
  const fill = d.color?.fill ?? BPMN_THEME.fill;
1806
1806
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: W2, height: H3, position: "relative" }, children: [
1807
- /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: W2, height: H3, style: { overflow: "visible", display: "block", filter: resolveShapeFilter(selected) }, children: [
1807
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: W2, height: H3, style: { overflow: "visible", display: "block", filter: resolveShapeFilter() }, children: [
1808
1808
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: documentPath(), fill, stroke, strokeWidth: sw }),
1809
1809
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: foldPath(), fill: "none", stroke, strokeWidth: sw }),
1810
1810
  d.isCollection && collectionLines(stroke, sw)
@@ -1819,7 +1819,7 @@ function DataInputNode({ data, selected }) {
1819
1819
  const sw = resolveStrokeWidth(selected);
1820
1820
  const fill = d.color?.fill ?? BPMN_THEME.fill;
1821
1821
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: W2, height: H3, position: "relative" }, children: [
1822
- /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: W2, height: H3, style: { overflow: "visible", display: "block", filter: resolveShapeFilter(selected) }, children: [
1822
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: W2, height: H3, style: { overflow: "visible", display: "block", filter: resolveShapeFilter() }, children: [
1823
1823
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: documentPath(), fill, stroke, strokeWidth: sw }),
1824
1824
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: foldPath(), fill: "none", stroke, strokeWidth: sw }),
1825
1825
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1843,7 +1843,7 @@ function DataOutputNode({ data, selected }) {
1843
1843
  const sw = resolveStrokeWidth(selected);
1844
1844
  const fill = d.color?.fill ?? BPMN_THEME.fill;
1845
1845
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: W2, height: H3, position: "relative" }, children: [
1846
- /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: W2, height: H3, style: { overflow: "visible", display: "block", filter: resolveShapeFilter(selected) }, children: [
1846
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: W2, height: H3, style: { overflow: "visible", display: "block", filter: resolveShapeFilter() }, children: [
1847
1847
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: documentPath(), fill, stroke, strokeWidth: sw }),
1848
1848
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: foldPath(), fill: "none", stroke, strokeWidth: sw }),
1849
1849
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1871,7 +1871,7 @@ function DataStoreReferenceNode({ data, selected }) {
1871
1871
  const sw = resolveStrokeWidth(selected);
1872
1872
  const fill = d.color?.fill ?? BPMN_THEME.fill;
1873
1873
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { width: DS_W2, height: DS_H2, position: "relative" }, children: [
1874
- /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: DS_W2, height: DS_H2, style: { overflow: "visible", display: "block", filter: resolveShapeFilter(selected) }, children: [
1874
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: DS_W2, height: DS_H2, style: { overflow: "visible", display: "block", filter: resolveShapeFilter() }, children: [
1875
1875
  /* @__PURE__ */ jsxRuntime.jsx(
1876
1876
  "path",
1877
1877
  {
@@ -2225,15 +2225,6 @@ var BPMN_NODE_TYPES = {
2225
2225
  };
2226
2226
 
2227
2227
  // src/edges/path.ts
2228
- function getEdgePoints(sourceX, sourceY, targetX, targetY, routingPoints) {
2229
- if (routingPoints && routingPoints.length >= 2) {
2230
- return routingPoints;
2231
- }
2232
- return [
2233
- { x: sourceX, y: sourceY },
2234
- { x: targetX, y: targetY }
2235
- ];
2236
- }
2237
2228
  function getPolylineMidpoint(points) {
2238
2229
  if (points.length === 0) return { x: 0, y: 0 };
2239
2230
  if (points.length === 1) return points[0];
@@ -2297,8 +2288,8 @@ function SequenceFlowEdge({
2297
2288
  }) {
2298
2289
  const d = data;
2299
2290
  const points = d?.routingPoints;
2300
- const polyline = getEdgePoints(sourceX, sourceY, targetX, targetY, points);
2301
- const path = points && points.length >= 2 ? routing.pointsToSvgPath(points) : routing.getOrthogonalPath(sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition);
2291
+ const polyline = points && points.length >= 2 ? [{ x: sourceX, y: sourceY }, ...points.slice(1, -1), { x: targetX, y: targetY }] : [{ x: sourceX, y: sourceY }, { x: targetX, y: targetY }];
2292
+ const path = points && points.length >= 2 ? routing.pointsToSvgPath([{ x: sourceX, y: sourceY }, ...points.slice(1, -1), { x: targetX, y: targetY }]) : routing.getOrthogonalPath(sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition);
2302
2293
  const midpoint = getPolylineMidpoint(polyline);
2303
2294
  const defaultMarkerPath = d?.isDefault ? getDefaultFlowMarkerPath(polyline) : null;
2304
2295
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -2362,8 +2353,8 @@ function MessageFlowEdge({
2362
2353
  }) {
2363
2354
  const d = data;
2364
2355
  const points = d?.routingPoints;
2365
- const polyline = getEdgePoints(sourceX, sourceY, targetX, targetY, points);
2366
- const path = points && points.length >= 2 ? routing.pointsToSvgPath(points) : routing.getOrthogonalPath(sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition);
2356
+ const polyline = points && points.length >= 2 ? [{ x: sourceX, y: sourceY }, ...points.slice(1, -1), { x: targetX, y: targetY }] : [{ x: sourceX, y: sourceY }, { x: targetX, y: targetY }];
2357
+ const path = points && points.length >= 2 ? routing.pointsToSvgPath([{ x: sourceX, y: sourceY }, ...points.slice(1, -1), { x: targetX, y: targetY }]) : routing.getOrthogonalPath(sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition);
2367
2358
  const midpoint = getPolylineMidpoint(polyline);
2368
2359
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2369
2360
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2415,7 +2406,7 @@ function AssociationEdge({
2415
2406
  const d = data;
2416
2407
  const points = d?.routingPoints;
2417
2408
  const direction = d?.associationDirection ?? "none";
2418
- const path = points && points.length >= 2 ? routing.pointsToSvgPath(points) : routing.getOrthogonalPath(sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition);
2409
+ const path = points && points.length >= 2 ? routing.pointsToSvgPath([{ x: sourceX, y: sourceY }, ...points.slice(1, -1), { x: targetX, y: targetY }]) : routing.getOrthogonalPath(sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition);
2419
2410
  return /* @__PURE__ */ jsxRuntime.jsx(
2420
2411
  react.BaseEdge,
2421
2412
  {
@@ -2446,7 +2437,7 @@ function DataAssociationEdge({
2446
2437
  }) {
2447
2438
  const d = data;
2448
2439
  const points = d?.routingPoints;
2449
- const path = points && points.length >= 2 ? routing.pointsToSvgPath(points) : routing.getOrthogonalPath(sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition);
2440
+ const path = points && points.length >= 2 ? routing.pointsToSvgPath([{ x: sourceX, y: sourceY }, ...points.slice(1, -1), { x: targetX, y: targetY }]) : routing.getOrthogonalPath(sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition);
2450
2441
  return /* @__PURE__ */ jsxRuntime.jsx(
2451
2442
  react.BaseEdge,
2452
2443
  {
@@ -3705,14 +3696,30 @@ function createBpmnNode(options) {
3705
3696
  },
3706
3697
  width: options.width ?? size.width,
3707
3698
  height: options.height ?? size.height,
3699
+ zIndex: getBpmnNodeZIndex(options.elementType),
3708
3700
  ...options.parentId ? { parentId: options.parentId } : {},
3701
+ ...options.elementType === "Lane" && options.parentId ? { extent: "parent" } : {},
3709
3702
  ...dragHandle ? { dragHandle } : {}
3710
3703
  };
3711
3704
  }
3705
+ function getBpmnNodeZIndex(elementType) {
3706
+ if (elementType === "Pool") return 0;
3707
+ if (elementType === "Lane") return 1;
3708
+ if (elementType === "BoundaryEvent") return 4;
3709
+ return 3;
3710
+ }
3711
+ function withBpmnNodeZIndexes(nodes) {
3712
+ return nodes.map((node) => {
3713
+ const zIndex = getBpmnNodeZIndex(node.data.elementType);
3714
+ return node.zIndex === zIndex ? node : { ...node, zIndex };
3715
+ });
3716
+ }
3712
3717
  var BPMN_POOL_LANE_LAYOUT = {
3713
3718
  poolHeaderSize: 30,
3714
3719
  laneHeaderSize: 24,
3715
- laneGap: 0
3720
+ laneGap: 0,
3721
+ verticalPoolHeaderSize: 28,
3722
+ minLaneSize: 96
3716
3723
  };
3717
3724
  function getBpmnDragHandleSelector(elementType) {
3718
3725
  if (elementType === "Pool") return ".pool-drag-handle";
@@ -3833,6 +3840,116 @@ function getBpmnPoolLanes(state, poolId) {
3833
3840
  function getNodeDimension(node, axis) {
3834
3841
  return node[axis] ?? node.measured?.[axis] ?? getBpmnElementSize(node.data.elementType)[axis];
3835
3842
  }
3843
+ function getBpmnLaneOrderPosition(lane, orientation) {
3844
+ const size = getBpmnNodeSize(lane);
3845
+ return orientation === "vertical" ? lane.position.x + size.width / 2 : lane.position.y + size.height / 2;
3846
+ }
3847
+ function resizeHorizontalBpmnLanes(lanes, pool) {
3848
+ const poolSize = getBpmnNodeSize(pool);
3849
+ const laneWidth = Math.max(BPMN_POOL_LANE_LAYOUT.minLaneSize, poolSize.width - BPMN_POOL_LANE_LAYOUT.poolHeaderSize);
3850
+ const laneHeight = Math.max(BPMN_POOL_LANE_LAYOUT.minLaneSize, poolSize.height / Math.max(1, lanes.length));
3851
+ return lanes.map((lane, index) => ({
3852
+ ...lane,
3853
+ position: { x: BPMN_POOL_LANE_LAYOUT.poolHeaderSize, y: index * laneHeight },
3854
+ width: laneWidth,
3855
+ height: laneHeight,
3856
+ parentId: pool.id,
3857
+ extent: "parent",
3858
+ zIndex: getBpmnNodeZIndex("Lane"),
3859
+ data: { ...lane.data, orientation: "horizontal", laneIndex: index }
3860
+ }));
3861
+ }
3862
+ function resizeVerticalBpmnLanes(lanes, pool) {
3863
+ const poolSize = getBpmnNodeSize(pool);
3864
+ const laneWidth = Math.max(BPMN_POOL_LANE_LAYOUT.minLaneSize, poolSize.width / Math.max(1, lanes.length));
3865
+ const laneHeight = Math.max(BPMN_POOL_LANE_LAYOUT.minLaneSize, poolSize.height - BPMN_POOL_LANE_LAYOUT.verticalPoolHeaderSize);
3866
+ return lanes.map((lane, index) => ({
3867
+ ...lane,
3868
+ position: { x: index * laneWidth, y: BPMN_POOL_LANE_LAYOUT.verticalPoolHeaderSize },
3869
+ width: laneWidth,
3870
+ height: laneHeight,
3871
+ parentId: pool.id,
3872
+ extent: "parent",
3873
+ zIndex: getBpmnNodeZIndex("Lane"),
3874
+ data: { ...lane.data, orientation: "vertical", laneIndex: index }
3875
+ }));
3876
+ }
3877
+ function layoutBpmnPoolLaneNodes(nodes, poolId) {
3878
+ const pool = nodes.find((node) => node.id === poolId && node.data.elementType === "Pool");
3879
+ if (!pool) return nodes;
3880
+ const orientation = pool.data.orientation === "vertical" ? "vertical" : "horizontal";
3881
+ const lanes = nodes.filter((node) => node.parentId === pool.id && node.data.elementType === "Lane").sort((a, b) => {
3882
+ const aIndex = typeof a.data.laneIndex === "number" ? a.data.laneIndex : void 0;
3883
+ const bIndex = typeof b.data.laneIndex === "number" ? b.data.laneIndex : void 0;
3884
+ if (aIndex !== void 0 || bIndex !== void 0) return (aIndex ?? 0) - (bIndex ?? 0);
3885
+ return getBpmnLaneOrderPosition(a, orientation) - getBpmnLaneOrderPosition(b, orientation);
3886
+ });
3887
+ if (lanes.length === 0) return withBpmnNodeZIndexes(nodes);
3888
+ const laneMap = new Map(
3889
+ (orientation === "vertical" ? resizeVerticalBpmnLanes(lanes, pool) : resizeHorizontalBpmnLanes(lanes, pool)).map((lane) => [lane.id, lane])
3890
+ );
3891
+ return withBpmnNodeZIndexes(nodes.map((node) => laneMap.get(node.id) ?? node));
3892
+ }
3893
+ function reorderBpmnLaneAfterDrop(nodes, laneId) {
3894
+ const lane = nodes.find((node) => node.id === laneId && node.data.elementType === "Lane");
3895
+ if (!lane?.parentId) return nodes;
3896
+ const pool = nodes.find((node) => node.id === lane.parentId && node.data.elementType === "Pool");
3897
+ if (!pool) return nodes;
3898
+ const orientation = pool.data.orientation === "vertical" ? "vertical" : "horizontal";
3899
+ const lanes = nodes.filter((node) => node.parentId === pool.id && node.data.elementType === "Lane").sort((a, b) => getBpmnLaneOrderPosition(a, orientation) - getBpmnLaneOrderPosition(b, orientation));
3900
+ const moved = lanes.find((candidate) => candidate.id === lane.id);
3901
+ if (!moved) return layoutBpmnPoolLaneNodes(nodes, pool.id);
3902
+ const withoutMoved = lanes.filter((candidate) => candidate.id !== lane.id);
3903
+ const movedCenter = getBpmnLaneOrderPosition(lane, orientation);
3904
+ const insertIndex = withoutMoved.findIndex(
3905
+ (candidate) => movedCenter < getBpmnLaneOrderPosition(candidate, orientation)
3906
+ );
3907
+ const ordered = [...withoutMoved];
3908
+ ordered.splice(insertIndex === -1 ? ordered.length : insertIndex, 0, moved);
3909
+ const orderedMap = new Map(ordered.map((candidate, index) => [candidate.id, index]));
3910
+ const sortedByDrop = nodes.map((node) => {
3911
+ if (node.parentId !== pool.id || node.data.elementType !== "Lane") return node;
3912
+ return { ...node, data: { ...node.data, laneIndex: orderedMap.get(node.id) ?? 0 } };
3913
+ });
3914
+ return layoutBpmnPoolLaneNodes(sortedByDrop, pool.id);
3915
+ }
3916
+ function getBpmnNodeSize(node) {
3917
+ return diagramsCore.getNodeSize(node, getBpmnElementSize(node.data.elementType));
3918
+ }
3919
+ function getBpmnNodeAbsolutePosition(state, nodeOrId) {
3920
+ const nodeId = typeof nodeOrId === "string" ? nodeOrId : nodeOrId.id;
3921
+ return diagramsCore.getNodeAbsolutePosition(state, nodeId);
3922
+ }
3923
+ function toBpmnRelativePosition(state, absolutePosition, parentOrId) {
3924
+ return diagramsCore.toRelativeNodePosition(state, absolutePosition, parentOrId);
3925
+ }
3926
+ var BPMN_CONTAINER_PRIORITY = [
3927
+ "Lane",
3928
+ "SubProcess",
3929
+ "EventSubProcess",
3930
+ "Transaction",
3931
+ "AdHocSubProcess",
3932
+ "Pool"
3933
+ ];
3934
+ function findBpmnContainerAt(state, options) {
3935
+ return diagramsCore.findContainingNode(state, {
3936
+ point: options.position,
3937
+ excludeId: options.excludeId,
3938
+ fallbackSize: (node) => getBpmnElementSize(node.data.elementType),
3939
+ predicate: (node) => BPMN_CONTAINER_PRIORITY.includes(node.data.elementType),
3940
+ sort: (a, b) => {
3941
+ const aPriority = BPMN_CONTAINER_PRIORITY.indexOf(a.data.elementType);
3942
+ const bPriority = BPMN_CONTAINER_PRIORITY.indexOf(b.data.elementType);
3943
+ if (aPriority !== bPriority) return aPriority - bPriority;
3944
+ const aSize = getBpmnNodeSize(a);
3945
+ const bSize = getBpmnNodeSize(b);
3946
+ return aSize.width * aSize.height - bSize.width * bSize.height;
3947
+ }
3948
+ });
3949
+ }
3950
+ function getBpmnNodeCenter(node, absolutePosition) {
3951
+ return diagramsCore.getNodeCenterPosition(absolutePosition, getBpmnNodeSize(node));
3952
+ }
3836
3953
  function resolvePoolLaneDirection(pool) {
3837
3954
  return pool.data.orientation === "vertical" ? "horizontal" : "vertical";
3838
3955
  }
@@ -4095,6 +4212,19 @@ function reparentBpmnNodeCommand(options) {
4095
4212
  }
4096
4213
  };
4097
4214
  }
4215
+ function reparentBpmnNodeAtPosition(state, options) {
4216
+ const node = diagramsCore.getNode(state, options.id);
4217
+ if (!node) throw new Error(`Element "${options.id}" does not exist.`);
4218
+ const hitPoint = getBpmnNodeCenter(node, options.position);
4219
+ const parent = isBpmnProcessNode(node.data.elementType) ? findBpmnContainerAt(state, { position: hitPoint, excludeId: node.id }) : void 0;
4220
+ const containment = canContainBpmnElement(parent?.data.elementType, node.data.elementType);
4221
+ if (containment !== true) throw new Error(containment);
4222
+ const nextPosition = parent ? toBpmnRelativePosition(state, options.position, parent) : options.position;
4223
+ return diagramsCore.reparentNode(state, node.id, {
4224
+ ...parent ? { parentId: parent.id } : { parentId: void 0 },
4225
+ position: nextPosition
4226
+ });
4227
+ }
4098
4228
  function resizeBpmnNodeCommand(options) {
4099
4229
  return {
4100
4230
  id: `bpmn.resize.${options.id}`,
@@ -4482,10 +4612,15 @@ exports.createBpmnNodeCommand = createBpmnNodeCommand;
4482
4612
  exports.createSimulation = createSimulation;
4483
4613
  exports.deleteBpmnElementsCommand = deleteBpmnElementsCommand;
4484
4614
  exports.deserializeBpmnDiagram = deserializeBpmnDiagram;
4615
+ exports.findBpmnContainerAt = findBpmnContainerAt;
4485
4616
  exports.fire = fire;
4486
4617
  exports.getBpmnDragHandleSelector = getBpmnDragHandleSelector;
4487
4618
  exports.getBpmnElementSize = getBpmnElementSize;
4488
4619
  exports.getBpmnLaneIndexAtPosition = getBpmnLaneIndexAtPosition;
4620
+ exports.getBpmnNodeAbsolutePosition = getBpmnNodeAbsolutePosition;
4621
+ exports.getBpmnNodeCenter = getBpmnNodeCenter;
4622
+ exports.getBpmnNodeSize = getBpmnNodeSize;
4623
+ exports.getBpmnNodeZIndex = getBpmnNodeZIndex;
4489
4624
  exports.getBpmnPoolLanes = getBpmnPoolLanes;
4490
4625
  exports.getElementMeta = getElementMeta;
4491
4626
  exports.getFireable = getFireable;
@@ -4503,13 +4638,16 @@ exports.isDataType = isDataType;
4503
4638
  exports.isEventType = isEventType;
4504
4639
  exports.isGatewayType = isGatewayType;
4505
4640
  exports.isTaskType = isTaskType;
4641
+ exports.layoutBpmnPoolLaneNodes = layoutBpmnPoolLaneNodes;
4506
4642
  exports.layoutBpmnPoolLanes = layoutBpmnPoolLanes;
4507
4643
  exports.moveBpmnLaneCommand = moveBpmnLaneCommand;
4508
4644
  exports.parseBpmnDiagramDocument = parseBpmnDiagramDocument;
4509
4645
  exports.parseBpmnXml = parseBpmnXml;
4510
4646
  exports.pasteBpmnElementsCommand = pasteBpmnElementsCommand;
4511
4647
  exports.reorderBpmnLane = reorderBpmnLane;
4648
+ exports.reorderBpmnLaneAfterDrop = reorderBpmnLaneAfterDrop;
4512
4649
  exports.reorderBpmnLaneCommand = reorderBpmnLaneCommand;
4650
+ exports.reparentBpmnNodeAtPosition = reparentBpmnNodeAtPosition;
4513
4651
  exports.reparentBpmnNodeCommand = reparentBpmnNodeCommand;
4514
4652
  exports.replaceBpmnNodeCommand = replaceBpmnNodeCommand;
4515
4653
  exports.resizeBpmnNodeCommand = resizeBpmnNodeCommand;
@@ -4523,7 +4661,9 @@ exports.setVariable = setVariable;
4523
4661
  exports.supportsCollapse = supportsCollapse;
4524
4662
  exports.supportsMarkers = supportsMarkers;
4525
4663
  exports.tick = tick;
4664
+ exports.toBpmnRelativePosition = toBpmnRelativePosition;
4526
4665
  exports.validateBpmnConnectionForEdgeType = validateBpmnConnectionForEdgeType;
4527
4666
  exports.validateBpmnDiagram = validateBpmnDiagram;
4667
+ exports.withBpmnNodeZIndexes = withBpmnNodeZIndexes;
4528
4668
  //# sourceMappingURL=index.cjs.map
4529
4669
  //# sourceMappingURL=index.cjs.map