@aranzatech/diagrams-bpmn 0.1.3 → 0.2.1

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 (66) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +121 -0
  3. package/dist/catalog-OVnBDD8R.d.ts +9 -0
  4. package/dist/catalog-OWfI_yHU.d.cts +9 -0
  5. package/dist/{chunk-W3ROOC6E.js → chunk-33AR3PXF.js} +177 -40
  6. package/dist/chunk-33AR3PXF.js.map +1 -0
  7. package/dist/{chunk-3AFZDIMQ.js → chunk-ECTJRD7Z.js} +3 -3
  8. package/dist/{chunk-3AFZDIMQ.js.map → chunk-ECTJRD7Z.js.map} +1 -1
  9. package/dist/{chunk-NXMUX67A.js → chunk-H3YMTGFG.js} +79 -38
  10. package/dist/chunk-H3YMTGFG.js.map +1 -0
  11. package/dist/chunk-KALSGH4D.js +36 -0
  12. package/dist/chunk-KALSGH4D.js.map +1 -0
  13. package/dist/{chunk-DNR5WBQH.js → chunk-L5Z22RLX.js} +81 -20
  14. package/dist/chunk-L5Z22RLX.js.map +1 -0
  15. package/dist/chunk-OZKTOILD.js +3 -0
  16. package/dist/chunk-OZKTOILD.js.map +1 -0
  17. package/dist/{chunk-4AX573IV.js → chunk-RLAJNRF2.js} +3 -3
  18. package/dist/{chunk-4AX573IV.js.map → chunk-RLAJNRF2.js.map} +1 -1
  19. package/dist/chunk-YQTIODXH.js +532 -0
  20. package/dist/chunk-YQTIODXH.js.map +1 -0
  21. package/dist/chunk-ZFGQVLHB.js +226 -0
  22. package/dist/chunk-ZFGQVLHB.js.map +1 -0
  23. package/dist/edges/index.cjs +1 -1
  24. package/dist/edges/index.cjs.map +1 -1
  25. package/dist/edges/index.js +2 -2
  26. package/dist/elements/index.cjs +81 -17
  27. package/dist/elements/index.cjs.map +1 -1
  28. package/dist/elements/index.d.cts +4 -6
  29. package/dist/elements/index.d.ts +4 -6
  30. package/dist/elements/index.js +3 -2
  31. package/dist/index.cjs +1120 -118
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.cts +10 -63
  34. package/dist/index.d.ts +10 -63
  35. package/dist/index.js +9 -42
  36. package/dist/index.js.map +1 -1
  37. package/dist/modeling/index.cjs +1241 -0
  38. package/dist/modeling/index.cjs.map +1 -0
  39. package/dist/modeling/index.d.cts +146 -0
  40. package/dist/modeling/index.d.ts +146 -0
  41. package/dist/modeling/index.js +5 -0
  42. package/dist/modeling/index.js.map +1 -0
  43. package/dist/nodes/index.cjs +91 -38
  44. package/dist/nodes/index.cjs.map +1 -1
  45. package/dist/nodes/index.js +2 -2
  46. package/dist/types-BxjCV2oX.d.ts +20 -0
  47. package/dist/{types-C78d_Kdh.d.cts → types-DznxZxpV.d.cts} +17 -19
  48. package/dist/{types-C78d_Kdh.d.ts → types-DznxZxpV.d.ts} +17 -19
  49. package/dist/types-vVi5T7qj.d.cts +20 -0
  50. package/dist/validation/index.cjs +848 -0
  51. package/dist/validation/index.cjs.map +1 -0
  52. package/dist/validation/index.d.cts +25 -0
  53. package/dist/validation/index.d.ts +25 -0
  54. package/dist/validation/index.js +5 -0
  55. package/dist/validation/index.js.map +1 -0
  56. package/dist/xml/index.cjs +215 -54
  57. package/dist/xml/index.cjs.map +1 -1
  58. package/dist/xml/index.d.cts +4 -19
  59. package/dist/xml/index.d.ts +4 -19
  60. package/dist/xml/index.js +2 -2
  61. package/package.json +16 -4
  62. package/dist/chunk-23B2IGK5.js +0 -24
  63. package/dist/chunk-23B2IGK5.js.map +0 -1
  64. package/dist/chunk-DNR5WBQH.js.map +0 -1
  65. package/dist/chunk-NXMUX67A.js.map +0 -1
  66. package/dist/chunk-W3ROOC6E.js.map +0 -1
@@ -0,0 +1,1241 @@
1
+ 'use strict';
2
+
3
+ var diagramsCore = require('@aranzatech/diagrams-core');
4
+ var serialization = require('@aranzatech/diagrams-core/serialization');
5
+
6
+ // src/modeling/index.ts
7
+
8
+ // src/elements/catalog.ts
9
+ var BPMN_ELEMENT_CATALOG = {
10
+ // ─── Events ──────────────────────────────────────────────────────────────────
11
+ StartEvent: {
12
+ label: "Start Event",
13
+ icon: "Circle",
14
+ category: "event",
15
+ defaultWidth: 36,
16
+ defaultHeight: 36,
17
+ handlePolicy: "source",
18
+ orientation: "free",
19
+ isContainer: false,
20
+ acceptsBoundaryEvents: false,
21
+ eventSemantics: "start",
22
+ canBeStart: true,
23
+ canBeEnd: false,
24
+ maxIncoming: 0,
25
+ maxOutgoing: 1
26
+ },
27
+ EndEvent: {
28
+ label: "End Event",
29
+ icon: "CircleDot",
30
+ category: "event",
31
+ defaultWidth: 36,
32
+ defaultHeight: 36,
33
+ handlePolicy: "target",
34
+ orientation: "free",
35
+ isContainer: false,
36
+ acceptsBoundaryEvents: false,
37
+ eventSemantics: "end",
38
+ canBeStart: false,
39
+ canBeEnd: true,
40
+ maxOutgoing: 0
41
+ },
42
+ IntermediateCatchEvent: {
43
+ label: "Intermediate Catch Event",
44
+ icon: "Clock3",
45
+ category: "event",
46
+ defaultWidth: 36,
47
+ defaultHeight: 36,
48
+ handlePolicy: "all",
49
+ orientation: "free",
50
+ isContainer: false,
51
+ acceptsBoundaryEvents: false,
52
+ eventSemantics: "intermediateCatch",
53
+ canBeStart: false,
54
+ canBeEnd: false
55
+ },
56
+ IntermediateThrowEvent: {
57
+ label: "Intermediate Throw Event",
58
+ icon: "Send",
59
+ category: "event",
60
+ defaultWidth: 36,
61
+ defaultHeight: 36,
62
+ handlePolicy: "all",
63
+ orientation: "free",
64
+ isContainer: false,
65
+ acceptsBoundaryEvents: false,
66
+ eventSemantics: "intermediateThrow",
67
+ canBeStart: false,
68
+ canBeEnd: false
69
+ },
70
+ BoundaryEvent: {
71
+ label: "Boundary Event",
72
+ icon: "AlarmClock",
73
+ category: "event",
74
+ defaultWidth: 36,
75
+ defaultHeight: 36,
76
+ handlePolicy: "source",
77
+ orientation: "free",
78
+ isContainer: false,
79
+ acceptsBoundaryEvents: false,
80
+ eventSemantics: "boundary",
81
+ canBeStart: false,
82
+ canBeEnd: false,
83
+ maxIncoming: 0
84
+ },
85
+ // ─── Tasks ───────────────────────────────────────────────────────────────────
86
+ Task: {
87
+ label: "Task",
88
+ icon: "CheckSquare",
89
+ category: "task",
90
+ defaultWidth: 120,
91
+ defaultHeight: 60,
92
+ handlePolicy: "all",
93
+ orientation: "free",
94
+ isContainer: false,
95
+ acceptsBoundaryEvents: true,
96
+ supportsMarkers: true,
97
+ canBeStart: false,
98
+ canBeEnd: false
99
+ },
100
+ UserTask: {
101
+ label: "User Task",
102
+ icon: "UserRound",
103
+ category: "task",
104
+ defaultWidth: 120,
105
+ defaultHeight: 60,
106
+ handlePolicy: "all",
107
+ orientation: "free",
108
+ isContainer: false,
109
+ acceptsBoundaryEvents: true,
110
+ supportsMarkers: true,
111
+ canBeStart: false,
112
+ canBeEnd: false
113
+ },
114
+ ServiceTask: {
115
+ label: "Service Task",
116
+ icon: "Cog",
117
+ category: "task",
118
+ defaultWidth: 120,
119
+ defaultHeight: 60,
120
+ handlePolicy: "all",
121
+ orientation: "free",
122
+ isContainer: false,
123
+ acceptsBoundaryEvents: true,
124
+ supportsMarkers: true,
125
+ canBeStart: false,
126
+ canBeEnd: false
127
+ },
128
+ ScriptTask: {
129
+ label: "Script Task",
130
+ icon: "FileCode",
131
+ category: "task",
132
+ defaultWidth: 120,
133
+ defaultHeight: 60,
134
+ handlePolicy: "all",
135
+ orientation: "free",
136
+ isContainer: false,
137
+ acceptsBoundaryEvents: true,
138
+ supportsMarkers: true,
139
+ canBeStart: false,
140
+ canBeEnd: false
141
+ },
142
+ ManualTask: {
143
+ label: "Manual Task",
144
+ icon: "Hand",
145
+ category: "task",
146
+ defaultWidth: 120,
147
+ defaultHeight: 60,
148
+ handlePolicy: "all",
149
+ orientation: "free",
150
+ isContainer: false,
151
+ acceptsBoundaryEvents: true,
152
+ supportsMarkers: true,
153
+ canBeStart: false,
154
+ canBeEnd: false
155
+ },
156
+ BusinessRuleTask: {
157
+ label: "Business Rule Task",
158
+ icon: "Table2",
159
+ category: "task",
160
+ defaultWidth: 120,
161
+ defaultHeight: 60,
162
+ handlePolicy: "all",
163
+ orientation: "free",
164
+ isContainer: false,
165
+ acceptsBoundaryEvents: true,
166
+ supportsMarkers: true,
167
+ canBeStart: false,
168
+ canBeEnd: false
169
+ },
170
+ ReceiveTask: {
171
+ label: "Receive Task",
172
+ icon: "Inbox",
173
+ category: "task",
174
+ defaultWidth: 120,
175
+ defaultHeight: 60,
176
+ handlePolicy: "all",
177
+ orientation: "free",
178
+ isContainer: false,
179
+ acceptsBoundaryEvents: true,
180
+ supportsMarkers: true,
181
+ canBeStart: false,
182
+ canBeEnd: false
183
+ },
184
+ SendTask: {
185
+ label: "Send Task",
186
+ icon: "Send",
187
+ category: "task",
188
+ defaultWidth: 120,
189
+ defaultHeight: 60,
190
+ handlePolicy: "all",
191
+ orientation: "free",
192
+ isContainer: false,
193
+ acceptsBoundaryEvents: true,
194
+ supportsMarkers: true,
195
+ canBeStart: false,
196
+ canBeEnd: false
197
+ },
198
+ CallActivity: {
199
+ label: "Call Activity",
200
+ icon: "ExternalLink",
201
+ category: "task",
202
+ defaultWidth: 120,
203
+ defaultHeight: 60,
204
+ handlePolicy: "all",
205
+ orientation: "free",
206
+ isContainer: false,
207
+ acceptsBoundaryEvents: true,
208
+ supportsMarkers: true,
209
+ canBeStart: false,
210
+ canBeEnd: false
211
+ },
212
+ // ─── Gateways ────────────────────────────────────────────────────────────────
213
+ ExclusiveGateway: {
214
+ label: "Exclusive Gateway",
215
+ icon: "X",
216
+ category: "gateway",
217
+ defaultWidth: 50,
218
+ defaultHeight: 50,
219
+ handlePolicy: "all",
220
+ orientation: "free",
221
+ isContainer: false,
222
+ acceptsBoundaryEvents: false,
223
+ canBeStart: false,
224
+ canBeEnd: false
225
+ },
226
+ InclusiveGateway: {
227
+ label: "Inclusive Gateway",
228
+ icon: "Circle",
229
+ category: "gateway",
230
+ defaultWidth: 50,
231
+ defaultHeight: 50,
232
+ handlePolicy: "all",
233
+ orientation: "free",
234
+ isContainer: false,
235
+ acceptsBoundaryEvents: false,
236
+ canBeStart: false,
237
+ canBeEnd: false
238
+ },
239
+ ParallelGateway: {
240
+ label: "Parallel Gateway",
241
+ icon: "Plus",
242
+ category: "gateway",
243
+ defaultWidth: 50,
244
+ defaultHeight: 50,
245
+ handlePolicy: "all",
246
+ orientation: "free",
247
+ isContainer: false,
248
+ acceptsBoundaryEvents: false,
249
+ canBeStart: false,
250
+ canBeEnd: false
251
+ },
252
+ EventBasedGateway: {
253
+ label: "Event-Based Gateway",
254
+ icon: "Radio",
255
+ category: "gateway",
256
+ defaultWidth: 50,
257
+ defaultHeight: 50,
258
+ handlePolicy: "all",
259
+ orientation: "free",
260
+ isContainer: false,
261
+ acceptsBoundaryEvents: false,
262
+ canBeStart: false,
263
+ canBeEnd: false,
264
+ maxIncoming: 1
265
+ },
266
+ ComplexGateway: {
267
+ label: "Complex Gateway",
268
+ icon: "Asterisk",
269
+ category: "gateway",
270
+ defaultWidth: 50,
271
+ defaultHeight: 50,
272
+ handlePolicy: "all",
273
+ orientation: "free",
274
+ isContainer: false,
275
+ acceptsBoundaryEvents: false,
276
+ canBeStart: false,
277
+ canBeEnd: false
278
+ },
279
+ // ─── Containers ───────────────────────────────────────────────────────────────
280
+ SubProcess: {
281
+ label: "Sub-Process",
282
+ icon: "PlusSquare",
283
+ category: "container",
284
+ defaultWidth: 350,
285
+ defaultHeight: 200,
286
+ handlePolicy: "all",
287
+ orientation: "horizontal",
288
+ isContainer: true,
289
+ acceptsBoundaryEvents: true,
290
+ supportsCollapse: true,
291
+ supportsMarkers: true,
292
+ canBeStart: false,
293
+ canBeEnd: false
294
+ },
295
+ Transaction: {
296
+ label: "Transaction",
297
+ icon: "Receipt",
298
+ category: "container",
299
+ defaultWidth: 350,
300
+ defaultHeight: 200,
301
+ handlePolicy: "all",
302
+ orientation: "horizontal",
303
+ isContainer: true,
304
+ acceptsBoundaryEvents: true,
305
+ supportsCollapse: true,
306
+ supportsMarkers: true,
307
+ canBeStart: false,
308
+ canBeEnd: false
309
+ },
310
+ EventSubProcess: {
311
+ label: "Event Sub-Process",
312
+ icon: "CircleDotDashed",
313
+ category: "container",
314
+ defaultWidth: 350,
315
+ defaultHeight: 200,
316
+ handlePolicy: "all",
317
+ orientation: "horizontal",
318
+ isContainer: true,
319
+ acceptsBoundaryEvents: false,
320
+ supportsCollapse: true,
321
+ supportsMarkers: true,
322
+ canBeStart: false,
323
+ canBeEnd: false
324
+ },
325
+ AdHocSubProcess: {
326
+ label: "Ad-Hoc Sub-Process",
327
+ icon: "Waves",
328
+ category: "container",
329
+ defaultWidth: 350,
330
+ defaultHeight: 200,
331
+ handlePolicy: "all",
332
+ orientation: "horizontal",
333
+ isContainer: true,
334
+ acceptsBoundaryEvents: true,
335
+ supportsCollapse: true,
336
+ supportsMarkers: true,
337
+ canBeStart: false,
338
+ canBeEnd: false
339
+ },
340
+ Pool: {
341
+ label: "Pool",
342
+ icon: "Rows3",
343
+ category: "container",
344
+ defaultWidth: 600,
345
+ defaultHeight: 200,
346
+ handlePolicy: "none",
347
+ orientation: "horizontal",
348
+ isContainer: true,
349
+ acceptsBoundaryEvents: false,
350
+ canBeStart: false,
351
+ canBeEnd: false,
352
+ maxIncoming: 0,
353
+ maxOutgoing: 0
354
+ },
355
+ Lane: {
356
+ label: "Lane",
357
+ icon: "PanelTop",
358
+ category: "container",
359
+ defaultWidth: 600,
360
+ defaultHeight: 120,
361
+ handlePolicy: "none",
362
+ orientation: "horizontal",
363
+ isContainer: true,
364
+ acceptsBoundaryEvents: false,
365
+ canBeStart: false,
366
+ canBeEnd: false,
367
+ maxIncoming: 0,
368
+ maxOutgoing: 0
369
+ },
370
+ // ─── Artifacts ────────────────────────────────────────────────────────────────
371
+ Annotation: {
372
+ label: "Text Annotation",
373
+ icon: "StickyNote",
374
+ category: "artifact",
375
+ defaultWidth: 100,
376
+ defaultHeight: 60,
377
+ handlePolicy: "none",
378
+ orientation: "free",
379
+ isContainer: false,
380
+ acceptsBoundaryEvents: false,
381
+ canBeStart: false,
382
+ canBeEnd: false,
383
+ maxIncoming: 0,
384
+ maxOutgoing: 0
385
+ },
386
+ Group: {
387
+ label: "Group",
388
+ icon: "Group",
389
+ category: "artifact",
390
+ defaultWidth: 300,
391
+ defaultHeight: 200,
392
+ handlePolicy: "none",
393
+ orientation: "free",
394
+ isContainer: false,
395
+ acceptsBoundaryEvents: false,
396
+ canBeStart: false,
397
+ canBeEnd: false,
398
+ maxIncoming: 0,
399
+ maxOutgoing: 0
400
+ },
401
+ // ─── Data (BPMN 2.0 §10.3) ───────────────────────────────────────────────────
402
+ DataObject: {
403
+ label: "Data Object",
404
+ icon: "File",
405
+ category: "data",
406
+ defaultWidth: 36,
407
+ defaultHeight: 50,
408
+ handlePolicy: "all",
409
+ orientation: "free",
410
+ isContainer: false,
411
+ acceptsBoundaryEvents: false,
412
+ canBeStart: false,
413
+ canBeEnd: false,
414
+ maxIncoming: 0,
415
+ maxOutgoing: 0
416
+ },
417
+ DataObjectReference: {
418
+ label: "Data Object Reference",
419
+ icon: "FileSymlink",
420
+ category: "data",
421
+ defaultWidth: 36,
422
+ defaultHeight: 50,
423
+ handlePolicy: "all",
424
+ orientation: "free",
425
+ isContainer: false,
426
+ acceptsBoundaryEvents: false,
427
+ canBeStart: false,
428
+ canBeEnd: false,
429
+ maxIncoming: 0,
430
+ maxOutgoing: 0
431
+ },
432
+ DataInput: {
433
+ label: "Data Input",
434
+ icon: "FileInput",
435
+ category: "data",
436
+ defaultWidth: 36,
437
+ defaultHeight: 50,
438
+ handlePolicy: "all",
439
+ orientation: "free",
440
+ isContainer: false,
441
+ acceptsBoundaryEvents: false,
442
+ canBeStart: false,
443
+ canBeEnd: false,
444
+ maxIncoming: 0
445
+ },
446
+ DataOutput: {
447
+ label: "Data Output",
448
+ icon: "FileOutput",
449
+ category: "data",
450
+ defaultWidth: 36,
451
+ defaultHeight: 50,
452
+ handlePolicy: "all",
453
+ orientation: "free",
454
+ isContainer: false,
455
+ acceptsBoundaryEvents: false,
456
+ canBeStart: false,
457
+ canBeEnd: false,
458
+ maxOutgoing: 0
459
+ },
460
+ DataStore: {
461
+ label: "Data Store",
462
+ icon: "Database",
463
+ category: "data",
464
+ defaultWidth: 50,
465
+ defaultHeight: 50,
466
+ handlePolicy: "all",
467
+ orientation: "free",
468
+ isContainer: false,
469
+ acceptsBoundaryEvents: false,
470
+ canBeStart: false,
471
+ canBeEnd: false,
472
+ maxIncoming: 0,
473
+ maxOutgoing: 0
474
+ },
475
+ DataStoreReference: {
476
+ label: "Data Store Reference",
477
+ icon: "DatabaseZap",
478
+ category: "data",
479
+ defaultWidth: 50,
480
+ defaultHeight: 50,
481
+ handlePolicy: "all",
482
+ orientation: "free",
483
+ isContainer: false,
484
+ acceptsBoundaryEvents: false,
485
+ canBeStart: false,
486
+ canBeEnd: false,
487
+ maxIncoming: 0,
488
+ maxOutgoing: 0
489
+ },
490
+ // ─── Conversation (BPMN 2.0 §12) ─────────────────────────────────────────────
491
+ Conversation: {
492
+ label: "Conversation",
493
+ icon: "MessageCircle",
494
+ category: "conversation",
495
+ defaultWidth: 60,
496
+ defaultHeight: 52,
497
+ handlePolicy: "all",
498
+ orientation: "free",
499
+ isContainer: false,
500
+ acceptsBoundaryEvents: false,
501
+ canBeStart: false,
502
+ canBeEnd: false
503
+ },
504
+ SubConversation: {
505
+ label: "Sub-Conversation",
506
+ icon: "MessagesSquare",
507
+ category: "conversation",
508
+ defaultWidth: 60,
509
+ defaultHeight: 52,
510
+ handlePolicy: "all",
511
+ orientation: "free",
512
+ isContainer: true,
513
+ acceptsBoundaryEvents: false,
514
+ supportsCollapse: true,
515
+ canBeStart: false,
516
+ canBeEnd: false
517
+ },
518
+ CallConversation: {
519
+ label: "Call Conversation",
520
+ icon: "PhoneCall",
521
+ category: "conversation",
522
+ defaultWidth: 60,
523
+ defaultHeight: 52,
524
+ handlePolicy: "all",
525
+ orientation: "free",
526
+ isContainer: false,
527
+ acceptsBoundaryEvents: false,
528
+ canBeStart: false,
529
+ canBeEnd: false
530
+ },
531
+ // ─── Choreography (BPMN 2.0 §11) ─────────────────────────────────────────────
532
+ ChoreographyTask: {
533
+ label: "Choreography Task",
534
+ icon: "ArrowLeftRight",
535
+ category: "choreography",
536
+ defaultWidth: 120,
537
+ defaultHeight: 80,
538
+ handlePolicy: "all",
539
+ orientation: "horizontal",
540
+ isContainer: false,
541
+ acceptsBoundaryEvents: false,
542
+ canBeStart: false,
543
+ canBeEnd: false
544
+ },
545
+ SubChoreography: {
546
+ label: "Sub-Choreography",
547
+ icon: "BoxSelect",
548
+ category: "choreography",
549
+ defaultWidth: 120,
550
+ defaultHeight: 80,
551
+ handlePolicy: "all",
552
+ orientation: "horizontal",
553
+ isContainer: true,
554
+ acceptsBoundaryEvents: false,
555
+ supportsCollapse: true,
556
+ canBeStart: false,
557
+ canBeEnd: false
558
+ },
559
+ CallChoreography: {
560
+ label: "Call Choreography",
561
+ icon: "Phone",
562
+ category: "choreography",
563
+ defaultWidth: 120,
564
+ defaultHeight: 80,
565
+ handlePolicy: "all",
566
+ orientation: "horizontal",
567
+ isContainer: false,
568
+ acceptsBoundaryEvents: false,
569
+ canBeStart: false,
570
+ canBeEnd: false
571
+ }
572
+ };
573
+ function getElementMeta(type) {
574
+ return BPMN_ELEMENT_CATALOG[type];
575
+ }
576
+ var BPMN_RESIZABLE_ELEMENT_TYPES = [
577
+ "Task",
578
+ "UserTask",
579
+ "ServiceTask",
580
+ "ScriptTask",
581
+ "ManualTask",
582
+ "BusinessRuleTask",
583
+ "ReceiveTask",
584
+ "SendTask",
585
+ "CallActivity",
586
+ "SubProcess",
587
+ "Transaction",
588
+ "EventSubProcess",
589
+ "AdHocSubProcess",
590
+ "Pool",
591
+ "Lane",
592
+ "Annotation",
593
+ "Group",
594
+ "SubConversation",
595
+ "ChoreographyTask",
596
+ "SubChoreography",
597
+ "CallChoreography"
598
+ ];
599
+ var BPMN_MIN_SIZE_OVERRIDES = {
600
+ Task: { minWidth: 80, minHeight: 48 },
601
+ UserTask: { minWidth: 80, minHeight: 48 },
602
+ ServiceTask: { minWidth: 80, minHeight: 48 },
603
+ ScriptTask: { minWidth: 80, minHeight: 48 },
604
+ ManualTask: { minWidth: 80, minHeight: 48 },
605
+ BusinessRuleTask: { minWidth: 80, minHeight: 48 },
606
+ ReceiveTask: { minWidth: 80, minHeight: 48 },
607
+ SendTask: { minWidth: 80, minHeight: 48 },
608
+ CallActivity: { minWidth: 80, minHeight: 48 },
609
+ SubProcess: { minWidth: 160, minHeight: 100 },
610
+ Transaction: { minWidth: 160, minHeight: 100 },
611
+ EventSubProcess: { minWidth: 160, minHeight: 100 },
612
+ AdHocSubProcess: { minWidth: 160, minHeight: 100 },
613
+ Pool: { minWidth: 240, minHeight: 120 },
614
+ Lane: { minWidth: 240, minHeight: 80 },
615
+ Annotation: { minWidth: 80, minHeight: 40 },
616
+ Group: { minWidth: 120, minHeight: 80 },
617
+ SubConversation: { minWidth: 60, minHeight: 52 },
618
+ ChoreographyTask: { minWidth: 100, minHeight: 70 },
619
+ SubChoreography: { minWidth: 100, minHeight: 70 },
620
+ CallChoreography: { minWidth: 100, minHeight: 70 }
621
+ };
622
+ var resizableTypes = new Set(BPMN_RESIZABLE_ELEMENT_TYPES);
623
+ function isBpmnElementResizable(type) {
624
+ return resizableTypes.has(type);
625
+ }
626
+ function getBpmnElementSize(type) {
627
+ const meta = getElementMeta(type);
628
+ const min = BPMN_MIN_SIZE_OVERRIDES[type];
629
+ return {
630
+ width: meta.defaultWidth,
631
+ height: meta.defaultHeight,
632
+ minWidth: meta.minWidth ?? min?.minWidth ?? meta.defaultWidth,
633
+ minHeight: meta.minHeight ?? min?.minHeight ?? meta.defaultHeight,
634
+ resizable: meta.resizable ?? isBpmnElementResizable(type)
635
+ };
636
+ }
637
+
638
+ // src/elements/guards.ts
639
+ var GATEWAY_TYPES = /* @__PURE__ */ new Set([
640
+ "ExclusiveGateway",
641
+ "InclusiveGateway",
642
+ "ParallelGateway",
643
+ "EventBasedGateway",
644
+ "ComplexGateway"
645
+ ]);
646
+ var EVENT_TYPES = /* @__PURE__ */ new Set([
647
+ "StartEvent",
648
+ "EndEvent",
649
+ "IntermediateCatchEvent",
650
+ "IntermediateThrowEvent",
651
+ "BoundaryEvent"
652
+ ]);
653
+ var DATA_TYPES = /* @__PURE__ */ new Set([
654
+ "DataObject",
655
+ "DataObjectReference",
656
+ "DataInput",
657
+ "DataOutput",
658
+ "DataStore",
659
+ "DataStoreReference"
660
+ ]);
661
+ function isGatewayType(type) {
662
+ return GATEWAY_TYPES.has(type);
663
+ }
664
+ function isEventType(type) {
665
+ return EVENT_TYPES.has(type);
666
+ }
667
+ function isDataType(type) {
668
+ return DATA_TYPES.has(type);
669
+ }
670
+ function acceptsBoundaryEvents(type) {
671
+ return BPMN_ELEMENT_CATALOG[type].acceptsBoundaryEvents;
672
+ }
673
+ function getHandlePolicy(type) {
674
+ return BPMN_ELEMENT_CATALOG[type].handlePolicy;
675
+ }
676
+
677
+ // src/modeling/index.ts
678
+ function createBpmnNode(options) {
679
+ const size = getBpmnElementSize(options.elementType);
680
+ const meta = BPMN_ELEMENT_CATALOG[options.elementType];
681
+ const orientation = options.data?.orientation ?? meta.orientation;
682
+ const dragHandle = getBpmnDragHandleSelector(options.elementType);
683
+ return {
684
+ id: options.id,
685
+ type: options.elementType,
686
+ position: options.position,
687
+ data: {
688
+ elementType: options.elementType,
689
+ orientation,
690
+ ...options.label ? { label: options.label } : {},
691
+ ...options.data ?? {}
692
+ },
693
+ width: options.width ?? size.width,
694
+ height: options.height ?? size.height,
695
+ ...options.parentId ? { parentId: options.parentId } : {},
696
+ ...dragHandle ? { dragHandle } : {}
697
+ };
698
+ }
699
+ var BPMN_POOL_LANE_LAYOUT = {
700
+ poolHeaderSize: 30,
701
+ laneHeaderSize: 24,
702
+ laneGap: 0
703
+ };
704
+ function getBpmnDragHandleSelector(elementType) {
705
+ if (elementType === "Pool") return ".pool-drag-handle";
706
+ if (elementType === "Lane") return ".lane-drag-handle";
707
+ return void 0;
708
+ }
709
+ var BPMN_SELECTION_STYLE = {
710
+ nodeOutline: "#2563eb",
711
+ edgeStroke: "#2563eb",
712
+ handleFill: "#ffffff",
713
+ handleStroke: "#2563eb",
714
+ resizeHandleSize: 8,
715
+ routingPointRadius: 5
716
+ };
717
+ var BPMN_ROUTABLE_EDGE_TYPES = [
718
+ "sequenceFlow",
719
+ "messageFlow",
720
+ "association",
721
+ "dataAssociation",
722
+ "conversationLink"
723
+ ];
724
+ var BPMN_EDGE_CONNECTION_RULES = {
725
+ sequenceFlow: {
726
+ edgeType: "sequenceFlow",
727
+ sourceCategories: ["flowNode"],
728
+ targetCategories: ["flowNode"],
729
+ allowSameParent: true,
730
+ allowDifferentParent: false
731
+ },
732
+ messageFlow: {
733
+ edgeType: "messageFlow",
734
+ sourceCategories: ["flowNode"],
735
+ targetCategories: ["flowNode"],
736
+ allowSameParent: false,
737
+ allowDifferentParent: true
738
+ },
739
+ association: {
740
+ edgeType: "association",
741
+ sourceCategories: ["flowNode", "artifact", "data"],
742
+ targetCategories: ["flowNode", "artifact", "data"],
743
+ allowSameParent: true,
744
+ allowDifferentParent: true
745
+ },
746
+ dataAssociation: {
747
+ edgeType: "dataAssociation",
748
+ sourceCategories: ["flowNode", "data"],
749
+ targetCategories: ["flowNode", "data"],
750
+ allowSameParent: true,
751
+ allowDifferentParent: true
752
+ },
753
+ conversationLink: {
754
+ edgeType: "conversationLink",
755
+ sourceCategories: ["conversation", "flowNode"],
756
+ targetCategories: ["conversation", "flowNode"],
757
+ allowSameParent: true,
758
+ allowDifferentParent: true
759
+ }
760
+ };
761
+ function inferBpmnEdgeType(state, sourceId, targetId) {
762
+ const source = diagramsCore.getNode(state, sourceId);
763
+ const target = diagramsCore.getNode(state, targetId);
764
+ if (!source || !target) return "sequenceFlow";
765
+ if (isDataType(source.data.elementType) || isDataType(target.data.elementType)) {
766
+ return "dataAssociation";
767
+ }
768
+ if (source.data.elementType === "Annotation" || target.data.elementType === "Annotation" || source.data.elementType === "Group" || target.data.elementType === "Group") {
769
+ return "association";
770
+ }
771
+ if (source.data.elementType === "Conversation" || source.data.elementType === "SubConversation" || source.data.elementType === "CallConversation" || target.data.elementType === "Conversation" || target.data.elementType === "SubConversation" || target.data.elementType === "CallConversation") {
772
+ return "conversationLink";
773
+ }
774
+ if (source.parentId && target.parentId && source.parentId !== target.parentId) {
775
+ return "messageFlow";
776
+ }
777
+ return "sequenceFlow";
778
+ }
779
+ function canUseSequenceFlow(type) {
780
+ const meta = BPMN_ELEMENT_CATALOG[type];
781
+ return meta.handlePolicy !== "none" && !isDataType(type) && type !== "Annotation" && type !== "Group" && meta.category !== "conversation";
782
+ }
783
+ function matchesConnectionCategory(type, categories) {
784
+ return categories.some((category) => {
785
+ if (category === type) return true;
786
+ if (category === "flowNode") return canUseSequenceFlow(type);
787
+ if (category === "data") return isDataType(type);
788
+ if (category === "artifact") return type === "Annotation" || type === "Group";
789
+ if (category === "conversation") return BPMN_ELEMENT_CATALOG[type].category === "conversation";
790
+ return false;
791
+ });
792
+ }
793
+ function isBpmnEdgeRoutingEditable(edgeType) {
794
+ return BPMN_ROUTABLE_EDGE_TYPES.includes(edgeType);
795
+ }
796
+ function isBpmnProcessNode(type) {
797
+ return isEventType(type) || isGatewayType(type) || type.includes("Task") || type === "CallActivity" || type === "SubProcess" || type === "Transaction" || type === "EventSubProcess" || type === "AdHocSubProcess";
798
+ }
799
+ function canContainBpmnElement(parentType, childType) {
800
+ if (!parentType) return true;
801
+ if (parentType === "Pool") {
802
+ return childType === "Lane" || isBpmnProcessNode(childType) ? true : "Pools can contain lanes or BPMN process nodes.";
803
+ }
804
+ if (parentType === "Lane") {
805
+ return isBpmnProcessNode(childType) ? true : "Lanes can only contain BPMN process nodes.";
806
+ }
807
+ if (parentType === "SubProcess" || parentType === "Transaction" || parentType === "EventSubProcess" || parentType === "AdHocSubProcess") {
808
+ return isBpmnProcessNode(childType) ? true : "Subprocesses can only contain BPMN process nodes.";
809
+ }
810
+ return `${parentType} cannot contain BPMN child elements.`;
811
+ }
812
+ function getDirectBpmnChildren(state, parentId) {
813
+ return state.nodes.filter((node) => node.parentId === parentId);
814
+ }
815
+ function getBpmnPoolLanes(state, poolId) {
816
+ return getDirectBpmnChildren(state, poolId).filter(
817
+ (node) => node.data.elementType === "Lane"
818
+ );
819
+ }
820
+ function getNodeDimension(node, axis) {
821
+ return node[axis] ?? node.measured?.[axis] ?? getBpmnElementSize(node.data.elementType)[axis];
822
+ }
823
+ function resolvePoolLaneDirection(pool) {
824
+ return pool.data.orientation === "vertical" ? "horizontal" : "vertical";
825
+ }
826
+ function getBpmnLaneIndexAtPosition(state, poolId, position) {
827
+ const pool = diagramsCore.getNode(state, poolId);
828
+ if (!pool) return 0;
829
+ const lanes = getBpmnPoolLanes(state, poolId);
830
+ const direction = resolvePoolLaneDirection(pool);
831
+ const axis = direction === "vertical" ? "y" : "x";
832
+ const sizeKey = direction === "vertical" ? "height" : "width";
833
+ for (let index = 0; index < lanes.length; index += 1) {
834
+ const lane = lanes[index];
835
+ const midpoint = lane.position[axis] + getNodeDimension(lane, sizeKey) / 2;
836
+ if (position[axis] < midpoint) return index;
837
+ }
838
+ return lanes.length;
839
+ }
840
+ function sortBpmnLanes(state, poolId, laneId, index) {
841
+ const lanes = getBpmnPoolLanes(state, poolId);
842
+ const currentIndex = lanes.findIndex((lane) => lane.id === laneId);
843
+ if (currentIndex < 0) return state;
844
+ const orderedIds = lanes.map((lane) => lane.id);
845
+ const [moved] = orderedIds.splice(currentIndex, 1);
846
+ orderedIds.splice(Math.max(0, Math.min(index, orderedIds.length)), 0, moved);
847
+ const order = new Map(orderedIds.map((id, laneIndex) => [id, laneIndex]));
848
+ return {
849
+ ...state,
850
+ nodes: [...state.nodes].sort((a, b) => {
851
+ const aOrder = order.get(a.id);
852
+ const bOrder = order.get(b.id);
853
+ if (aOrder === void 0 && bOrder === void 0) return 0;
854
+ if (aOrder === void 0) return -1;
855
+ if (bOrder === void 0) return 1;
856
+ return aOrder - bOrder;
857
+ })
858
+ };
859
+ }
860
+ function layoutBpmnPoolLanes(state, poolId) {
861
+ const pool = diagramsCore.getNode(state, poolId);
862
+ if (!pool) return state;
863
+ const poolSize = getBpmnElementSize("Pool");
864
+ const direction = resolvePoolLaneDirection(pool);
865
+ const lanes = getBpmnPoolLanes(state, poolId);
866
+ let cursor = direction === "vertical" ? BPMN_POOL_LANE_LAYOUT.poolHeaderSize : 0;
867
+ let next = state;
868
+ for (const lane of lanes) {
869
+ const laneSize = getBpmnElementSize("Lane");
870
+ const width = direction === "vertical" ? Math.max(poolSize.minWidth - BPMN_POOL_LANE_LAYOUT.poolHeaderSize, lane.width ?? laneSize.width) : lane.width ?? laneSize.width;
871
+ const height = direction === "vertical" ? lane.height ?? laneSize.height : Math.max(poolSize.minHeight - BPMN_POOL_LANE_LAYOUT.poolHeaderSize, lane.height ?? laneSize.height);
872
+ next = diagramsCore.patchNode(next, lane.id, {
873
+ position: direction === "vertical" ? { x: BPMN_POOL_LANE_LAYOUT.poolHeaderSize, y: cursor } : { x: cursor, y: BPMN_POOL_LANE_LAYOUT.poolHeaderSize },
874
+ width,
875
+ height,
876
+ data: { orientation: pool.data.orientation ?? "horizontal" }
877
+ });
878
+ cursor += (direction === "vertical" ? height : width) + BPMN_POOL_LANE_LAYOUT.laneGap;
879
+ }
880
+ const minWidth = direction === "vertical" ? poolSize.minWidth : Math.max(poolSize.minWidth, cursor);
881
+ const minHeight = direction === "vertical" ? Math.max(poolSize.minHeight, cursor) : poolSize.minHeight;
882
+ return diagramsCore.resizeNode(next, poolId, { width: minWidth, height: minHeight });
883
+ }
884
+ function reorderBpmnLane(state, options) {
885
+ return layoutBpmnPoolLanes(
886
+ sortBpmnLanes(state, options.poolId, options.laneId, options.index),
887
+ options.poolId
888
+ );
889
+ }
890
+ function validateBpmnConnectionForEdgeType(state, edgeType, source, target) {
891
+ const rule = BPMN_EDGE_CONNECTION_RULES[edgeType];
892
+ if (!matchesConnectionCategory(source.data.elementType, rule.sourceCategories)) {
893
+ return `${edgeType} cannot start from ${source.data.elementType}.`;
894
+ }
895
+ if (!matchesConnectionCategory(target.data.elementType, rule.targetCategories)) {
896
+ return `${edgeType} cannot target ${target.data.elementType}.`;
897
+ }
898
+ const sameParent = (source.parentId ?? null) === (target.parentId ?? null);
899
+ if (sameParent && rule.allowSameParent === false) {
900
+ return `${edgeType} must connect BPMN elements in different participants/scopes.`;
901
+ }
902
+ if (!sameParent && rule.allowDifferentParent === false) {
903
+ return `${edgeType} must stay inside the same BPMN participant/scope.`;
904
+ }
905
+ if (edgeType === "sequenceFlow") {
906
+ if (source.data.elementType === "EndEvent") return "End events cannot have outgoing sequence flows.";
907
+ if (target.data.elementType === "StartEvent") return "Start events cannot have incoming sequence flows.";
908
+ return validateEdgeCardinality(state, edgeType, source, target);
909
+ }
910
+ return true;
911
+ }
912
+ function validateEdgeCardinality(state, edgeType, source, target) {
913
+ if (edgeType !== "sequenceFlow") return true;
914
+ const sourceMax = BPMN_ELEMENT_CATALOG[source.data.elementType].maxOutgoing;
915
+ const targetMax = BPMN_ELEMENT_CATALOG[target.data.elementType].maxIncoming;
916
+ const outgoing = diagramsCore.getOutgoingEdges(state, source.id).filter(
917
+ (edge) => edge.data?.edgeType === "sequenceFlow"
918
+ );
919
+ const incoming = diagramsCore.getIncomingEdges(state, target.id).filter(
920
+ (edge) => edge.data?.edgeType === "sequenceFlow"
921
+ );
922
+ if (sourceMax !== void 0 && outgoing.length >= sourceMax) {
923
+ return `${source.data.elementType} cannot have more than ${sourceMax} outgoing sequence flow(s).`;
924
+ }
925
+ if (targetMax !== void 0 && incoming.length >= targetMax) {
926
+ return `${target.data.elementType} cannot have more than ${targetMax} incoming sequence flow(s).`;
927
+ }
928
+ return true;
929
+ }
930
+ var bpmnConnectionValidators = [
931
+ ({ state, source, target }) => {
932
+ if (source.id === target.id) return "BPMN self-connections are not allowed.";
933
+ const edgeType = inferBpmnEdgeType(state, source.id, target.id);
934
+ if (getHandlePolicy(source.data.elementType) === "none" || getHandlePolicy(target.data.elementType) === "none") {
935
+ return "Elements without BPMN connection handles cannot be directly connected.";
936
+ }
937
+ if (edgeType === "sequenceFlow") {
938
+ return validateBpmnConnectionForEdgeType(state, edgeType, source, target);
939
+ }
940
+ return validateBpmnConnectionForEdgeType(state, edgeType, source, target);
941
+ }
942
+ ];
943
+ var BPMN_MODELING_RULES = diagramsCore.createModelingRules({
944
+ connect: [
945
+ ({ state, source, target }) => {
946
+ if (!source || !target) return false;
947
+ for (const validator of bpmnConnectionValidators) {
948
+ const result = validator({
949
+ state,
950
+ source,
951
+ target,
952
+ existingEdges: state.edges
953
+ });
954
+ if (result !== true) return result;
955
+ }
956
+ return true;
957
+ }
958
+ ],
959
+ drop: [
960
+ ({ node, parent }) => {
961
+ if (!node || !parent) return true;
962
+ if (node.data.elementType === "BoundaryEvent") {
963
+ return acceptsBoundaryEvents(parent.data.elementType) ? true : "Boundary events can only be attached to tasks or subprocesses.";
964
+ }
965
+ return canContainBpmnElement(parent.data.elementType, node.data.elementType);
966
+ }
967
+ ],
968
+ reparent: [
969
+ ({ node, parent }) => {
970
+ if (!node || !parent) return true;
971
+ if (node.data.elementType === "BoundaryEvent") {
972
+ return acceptsBoundaryEvents(parent.data.elementType) ? true : "Boundary events can only be reparented to tasks or subprocesses.";
973
+ }
974
+ return canContainBpmnElement(parent?.data.elementType, node.data.elementType);
975
+ }
976
+ ],
977
+ delete: [() => true],
978
+ resize: [
979
+ ({ node }) => !node || isBpmnElementResizable(node.data.elementType) ? true : `${node.data.elementType} is not resizable in BPMN.`
980
+ ]
981
+ });
982
+ function createBpmnNodeCommand(options) {
983
+ return {
984
+ id: `bpmn.createNode.${options.id}`,
985
+ label: `Create ${options.elementType}`,
986
+ execute: (state) => diagramsCore.addNode(state, createBpmnNode(options))
987
+ };
988
+ }
989
+ function connectBpmnCommand(options) {
990
+ return {
991
+ id: `bpmn.connect.${options.id ?? `${options.source}-${options.target}`}`,
992
+ label: "Connect BPMN elements",
993
+ execute: (state) => {
994
+ const edgeType = options.edgeType ?? inferBpmnEdgeType(state, options.source, options.target);
995
+ const source = diagramsCore.getNode(state, options.source);
996
+ const target = diagramsCore.getNode(state, options.target);
997
+ if (!source) throw new Error(`Source node "${options.source}" does not exist.`);
998
+ if (!target) throw new Error(`Target node "${options.target}" does not exist.`);
999
+ const validation = validateBpmnConnectionForEdgeType(state, edgeType, source, target);
1000
+ if (validation !== true) throw new Error(validation);
1001
+ return diagramsCore.connectNodes(
1002
+ state,
1003
+ {
1004
+ source: options.source,
1005
+ target: options.target,
1006
+ type: edgeType,
1007
+ ...options.sourceHandle !== void 0 ? { sourceHandle: options.sourceHandle } : {},
1008
+ ...options.targetHandle !== void 0 ? { targetHandle: options.targetHandle } : {},
1009
+ ...options.id ? { id: options.id } : {},
1010
+ data: {
1011
+ edgeType,
1012
+ ...options.label ? { label: options.label } : {},
1013
+ ...options.data ?? {}
1014
+ }
1015
+ },
1016
+ []
1017
+ );
1018
+ }
1019
+ };
1020
+ }
1021
+ function attachBoundaryEventCommand(boundaryId, hostId) {
1022
+ return {
1023
+ id: `bpmn.attachBoundary.${boundaryId}.${hostId}`,
1024
+ label: "Attach boundary event",
1025
+ execute: (state) => {
1026
+ const host = diagramsCore.getNode(state, hostId);
1027
+ if (!host || !acceptsBoundaryEvents(host.data.elementType)) {
1028
+ throw new Error(`Element "${hostId}" cannot host boundary events.`);
1029
+ }
1030
+ const boundary = diagramsCore.getNode(state, boundaryId);
1031
+ if (!boundary || boundary.data.elementType !== "BoundaryEvent") {
1032
+ throw new Error(`Element "${boundaryId}" is not a boundary event.`);
1033
+ }
1034
+ const reparented = diagramsCore.reparentNode(state, boundaryId, { parentId: hostId });
1035
+ return diagramsCore.patchNode(reparented, boundaryId, {
1036
+ data: { attachedToRef: hostId }
1037
+ });
1038
+ }
1039
+ };
1040
+ }
1041
+ function replaceBpmnNodeCommand(options) {
1042
+ return {
1043
+ id: `bpmn.replaceNode.${options.id}.${options.elementType}`,
1044
+ label: `Replace with ${options.elementType}`,
1045
+ execute: (state) => {
1046
+ const current = diagramsCore.getNode(state, options.id);
1047
+ if (!current) throw new Error(`Element "${options.id}" does not exist.`);
1048
+ const meta = BPMN_ELEMENT_CATALOG[options.elementType];
1049
+ return diagramsCore.replaceNode(state, options.id, {
1050
+ ...current,
1051
+ type: options.elementType,
1052
+ width: options.width ?? current.width ?? meta.defaultWidth,
1053
+ height: options.height ?? current.height ?? meta.defaultHeight,
1054
+ data: {
1055
+ ...current.data,
1056
+ elementType: options.elementType,
1057
+ ...options.label ? { label: options.label } : {},
1058
+ ...options.data ?? {}
1059
+ }
1060
+ });
1061
+ }
1062
+ };
1063
+ }
1064
+ function reparentBpmnNodeCommand(options) {
1065
+ return {
1066
+ id: `bpmn.reparent.${options.id}.${options.parentId ?? "root"}`,
1067
+ label: "Reparent BPMN element",
1068
+ execute: (state) => {
1069
+ const node = diagramsCore.getNode(state, options.id);
1070
+ const parent = options.parentId ? diagramsCore.getNode(state, options.parentId) : void 0;
1071
+ if (!node) throw new Error(`Element "${options.id}" does not exist.`);
1072
+ if (parent && node.data.elementType === "BoundaryEvent" && !acceptsBoundaryEvents(parent.data.elementType)) {
1073
+ throw new Error("Boundary events can only be reparented to tasks or subprocesses.");
1074
+ }
1075
+ const containment = canContainBpmnElement(parent?.data.elementType, node.data.elementType);
1076
+ if (containment !== true) throw new Error(containment);
1077
+ const reparented = diagramsCore.reparentNode(state, options.id, {
1078
+ ...options.parentId !== void 0 ? { parentId: options.parentId } : {},
1079
+ ...options.position ? { position: options.position } : {}
1080
+ });
1081
+ return parent?.data.elementType === "Pool" && node.data.elementType === "Lane" ? layoutBpmnPoolLanes(reparented, parent.id) : reparented;
1082
+ }
1083
+ };
1084
+ }
1085
+ function resizeBpmnNodeCommand(options) {
1086
+ return {
1087
+ id: `bpmn.resize.${options.id}`,
1088
+ label: "Resize BPMN element",
1089
+ execute: (state) => {
1090
+ const node = diagramsCore.getNode(state, options.id);
1091
+ if (!node) throw new Error(`Element "${options.id}" does not exist.`);
1092
+ const size = getBpmnElementSize(node.data.elementType);
1093
+ if (!size.resizable) {
1094
+ throw new Error(`${node.data.elementType} is not resizable in BPMN.`);
1095
+ }
1096
+ return diagramsCore.resizeNode(state, options.id, {
1097
+ width: options.width === void 0 ? void 0 : Math.max(size.minWidth, options.width),
1098
+ height: options.height === void 0 ? void 0 : Math.max(size.minHeight, options.height)
1099
+ });
1100
+ }
1101
+ };
1102
+ }
1103
+ function reorderBpmnLaneCommand(options) {
1104
+ return {
1105
+ id: `bpmn.reorderLane.${options.poolId}.${options.laneId}`,
1106
+ label: "Reorder BPMN lane",
1107
+ execute: (state) => {
1108
+ const pool = diagramsCore.getNode(state, options.poolId);
1109
+ const lane = diagramsCore.getNode(state, options.laneId);
1110
+ if (!pool || pool.data.elementType !== "Pool") {
1111
+ throw new Error(`Element "${options.poolId}" is not a pool.`);
1112
+ }
1113
+ if (!lane || lane.data.elementType !== "Lane" || lane.parentId !== options.poolId) {
1114
+ throw new Error(`Element "${options.laneId}" is not a lane in pool "${options.poolId}".`);
1115
+ }
1116
+ return reorderBpmnLane(state, options);
1117
+ }
1118
+ };
1119
+ }
1120
+ function moveBpmnLaneCommand(options) {
1121
+ return {
1122
+ id: `bpmn.moveLane.${options.poolId}.${options.laneId}`,
1123
+ label: "Move BPMN lane",
1124
+ execute: (state) => reorderBpmnLane(state, {
1125
+ poolId: options.poolId,
1126
+ laneId: options.laneId,
1127
+ index: getBpmnLaneIndexAtPosition(state, options.poolId, options.position)
1128
+ })
1129
+ };
1130
+ }
1131
+ function routeBpmnEdgeCommand(options) {
1132
+ return {
1133
+ id: `bpmn.routeEdge.${options.id}`,
1134
+ label: "Route BPMN edge",
1135
+ execute: (state) => {
1136
+ const edge = state.edges.find((item) => item.id === options.id);
1137
+ if (!edge) throw new Error(`Edge "${options.id}" does not exist.`);
1138
+ const edgeType = edge.data?.edgeType;
1139
+ if (!edgeType || !isBpmnEdgeRoutingEditable(edgeType)) {
1140
+ throw new Error(`${edgeType ?? "edge"} routing points cannot be edited.`);
1141
+ }
1142
+ return diagramsCore.patchEdge(state, options.id, {
1143
+ data: { routingPoints: options.routingPoints }
1144
+ });
1145
+ }
1146
+ };
1147
+ }
1148
+ function deleteBpmnElementsCommand(ids) {
1149
+ return {
1150
+ id: `bpmn.delete.${ids.join(".")}`,
1151
+ label: "Delete BPMN elements",
1152
+ execute: (state) => diagramsCore.removeElements(state, ids)
1153
+ };
1154
+ }
1155
+ function copyBpmnElements(state, selection) {
1156
+ return diagramsCore.copyElements(state, selection);
1157
+ }
1158
+ function pasteBpmnElementsCommand(clipboard, options = {}) {
1159
+ return {
1160
+ id: "bpmn.paste",
1161
+ label: "Paste BPMN elements",
1162
+ execute: (state) => diagramsCore.pasteElements(state, clipboard, options)
1163
+ };
1164
+ }
1165
+ function selectBpmnElementsCommand(selection) {
1166
+ return {
1167
+ id: "bpmn.select",
1168
+ label: "Select BPMN elements",
1169
+ execute: (state) => diagramsCore.setSelection(state, diagramsCore.createSelectionState(selection.nodeIds, selection.edgeIds))
1170
+ };
1171
+ }
1172
+ function createBpmnDiagramDocument(state, options = {}) {
1173
+ return serialization.createDiagramDocument(diagramsCore.normalizeDiagramState(state), {
1174
+ ...options,
1175
+ diagramType: "bpmn"
1176
+ });
1177
+ }
1178
+ function serializeBpmnDiagram(state, options = {}) {
1179
+ return serialization.serializeDiagram(diagramsCore.normalizeDiagramState(state), {
1180
+ ...options,
1181
+ diagramType: "bpmn"
1182
+ });
1183
+ }
1184
+ function parseBpmnDiagramDocument(json) {
1185
+ const document = serialization.parseDiagramDocument(json);
1186
+ if (document.diagramType && document.diagramType !== "bpmn") {
1187
+ throw new Error(`Expected a BPMN diagram document, received "${document.diagramType}".`);
1188
+ }
1189
+ return document;
1190
+ }
1191
+ function deserializeBpmnDiagram(json) {
1192
+ const document = parseBpmnDiagramDocument(json);
1193
+ return serialization.deserializeDiagram(JSON.stringify(document));
1194
+ }
1195
+ function runBpmnCommand(stack, command) {
1196
+ return diagramsCore.executeCommand(stack, command);
1197
+ }
1198
+ function runBpmnCommands(stack, commands, options = {}) {
1199
+ return diagramsCore.executeCommands(stack, commands, options);
1200
+ }
1201
+
1202
+ exports.BPMN_EDGE_CONNECTION_RULES = BPMN_EDGE_CONNECTION_RULES;
1203
+ exports.BPMN_MODELING_RULES = BPMN_MODELING_RULES;
1204
+ exports.BPMN_POOL_LANE_LAYOUT = BPMN_POOL_LANE_LAYOUT;
1205
+ exports.BPMN_ROUTABLE_EDGE_TYPES = BPMN_ROUTABLE_EDGE_TYPES;
1206
+ exports.BPMN_SELECTION_STYLE = BPMN_SELECTION_STYLE;
1207
+ exports.attachBoundaryEventCommand = attachBoundaryEventCommand;
1208
+ exports.bpmnConnectionValidators = bpmnConnectionValidators;
1209
+ exports.canContainBpmnElement = canContainBpmnElement;
1210
+ exports.connectBpmnCommand = connectBpmnCommand;
1211
+ exports.copyBpmnElements = copyBpmnElements;
1212
+ exports.createBpmnDiagramDocument = createBpmnDiagramDocument;
1213
+ exports.createBpmnNode = createBpmnNode;
1214
+ exports.createBpmnNodeCommand = createBpmnNodeCommand;
1215
+ exports.deleteBpmnElementsCommand = deleteBpmnElementsCommand;
1216
+ exports.deserializeBpmnDiagram = deserializeBpmnDiagram;
1217
+ exports.getBpmnDragHandleSelector = getBpmnDragHandleSelector;
1218
+ exports.getBpmnElementSize = getBpmnElementSize;
1219
+ exports.getBpmnLaneIndexAtPosition = getBpmnLaneIndexAtPosition;
1220
+ exports.getBpmnPoolLanes = getBpmnPoolLanes;
1221
+ exports.inferBpmnEdgeType = inferBpmnEdgeType;
1222
+ exports.isBpmnEdgeRoutingEditable = isBpmnEdgeRoutingEditable;
1223
+ exports.isBpmnElementResizable = isBpmnElementResizable;
1224
+ exports.isBpmnProcessNode = isBpmnProcessNode;
1225
+ exports.layoutBpmnPoolLanes = layoutBpmnPoolLanes;
1226
+ exports.moveBpmnLaneCommand = moveBpmnLaneCommand;
1227
+ exports.parseBpmnDiagramDocument = parseBpmnDiagramDocument;
1228
+ exports.pasteBpmnElementsCommand = pasteBpmnElementsCommand;
1229
+ exports.reorderBpmnLane = reorderBpmnLane;
1230
+ exports.reorderBpmnLaneCommand = reorderBpmnLaneCommand;
1231
+ exports.reparentBpmnNodeCommand = reparentBpmnNodeCommand;
1232
+ exports.replaceBpmnNodeCommand = replaceBpmnNodeCommand;
1233
+ exports.resizeBpmnNodeCommand = resizeBpmnNodeCommand;
1234
+ exports.routeBpmnEdgeCommand = routeBpmnEdgeCommand;
1235
+ exports.runBpmnCommand = runBpmnCommand;
1236
+ exports.runBpmnCommands = runBpmnCommands;
1237
+ exports.selectBpmnElementsCommand = selectBpmnElementsCommand;
1238
+ exports.serializeBpmnDiagram = serializeBpmnDiagram;
1239
+ exports.validateBpmnConnectionForEdgeType = validateBpmnConnectionForEdgeType;
1240
+ //# sourceMappingURL=index.cjs.map
1241
+ //# sourceMappingURL=index.cjs.map