camunda-bpmn-js 5.16.0 → 5.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/base-modeler.development.js +57150 -53965
  2. package/dist/base-modeler.production.min.js +45 -45
  3. package/dist/base-navigated-viewer.development.js +1958 -1314
  4. package/dist/base-navigated-viewer.production.min.js +1 -1
  5. package/dist/base-viewer.development.js +1221 -599
  6. package/dist/base-viewer.production.min.js +1 -1
  7. package/dist/camunda-cloud-modeler.development.js +11564 -7177
  8. package/dist/camunda-cloud-modeler.production.min.js +47 -47
  9. package/dist/camunda-cloud-navigated-viewer.development.js +1850 -1171
  10. package/dist/camunda-cloud-navigated-viewer.production.min.js +1 -1
  11. package/dist/camunda-cloud-viewer.development.js +1842 -1185
  12. package/dist/camunda-cloud-viewer.production.min.js +1 -1
  13. package/dist/camunda-platform-modeler.development.js +9064 -4379
  14. package/dist/camunda-platform-modeler.production.min.js +45 -45
  15. package/dist/camunda-platform-navigated-viewer.development.js +1839 -1183
  16. package/dist/camunda-platform-navigated-viewer.production.min.js +1 -1
  17. package/dist/camunda-platform-viewer.development.js +1818 -1184
  18. package/dist/camunda-platform-viewer.production.min.js +1 -1
  19. package/lib/base/Modeler.js +12 -0
  20. package/lib/base/NavigatedViewer.js +10 -0
  21. package/lib/base/Viewer.js +10 -0
  22. package/lib/camunda-cloud/ElementTemplatesValidator.js +10 -0
  23. package/lib/camunda-cloud/Modeler.js +10 -0
  24. package/lib/camunda-cloud/NavigatedViewer.js +10 -0
  25. package/lib/camunda-cloud/Viewer.js +10 -0
  26. package/lib/camunda-cloud/features/external-resources/README.md +1 -1
  27. package/lib/camunda-cloud/features/external-resources/ResourceLoader.d.ts +9 -0
  28. package/lib/camunda-cloud/features/external-resources/ResourceLoader.js +10 -0
  29. package/lib/camunda-cloud/features/external-resources/Resources.d.ts +9 -0
  30. package/lib/camunda-cloud/features/external-resources/Resources.js +10 -0
  31. package/lib/camunda-cloud/features/external-resources/cmd/ComposedCommandHandler.d.ts +9 -0
  32. package/lib/camunda-cloud/features/external-resources/cmd/ComposedCommandHandler.js +10 -0
  33. package/lib/camunda-cloud/features/external-resources/cmd/index.js +10 -0
  34. package/lib/camunda-cloud/features/external-resources/handlers/decision/AppendMenuProvider.js +11 -1
  35. package/lib/camunda-cloud/features/external-resources/handlers/decision/CreateMenuProvider.js +11 -1
  36. package/lib/camunda-cloud/features/external-resources/handlers/decision/ReplaceMenuProvider.js +11 -1
  37. package/lib/camunda-cloud/features/external-resources/handlers/decision/createElement.d.ts +15 -5
  38. package/lib/camunda-cloud/features/external-resources/handlers/decision/createElement.js +29 -4
  39. package/lib/camunda-cloud/features/external-resources/handlers/decision/index.js +10 -0
  40. package/lib/camunda-cloud/features/external-resources/handlers/decision/replaceElement.js +10 -0
  41. package/lib/camunda-cloud/features/external-resources/handlers/decision/searchTerms.d.ts +9 -0
  42. package/lib/camunda-cloud/features/external-resources/handlers/decision/searchTerms.js +10 -0
  43. package/lib/camunda-cloud/features/external-resources/handlers/form/AppendMenuProvider.js +11 -1
  44. package/lib/camunda-cloud/features/external-resources/handlers/form/CreateMenuProvider.js +11 -1
  45. package/lib/camunda-cloud/features/external-resources/handlers/form/ReplaceMenuProvider.js +11 -1
  46. package/lib/camunda-cloud/features/external-resources/handlers/form/createElement.d.ts +15 -1
  47. package/lib/camunda-cloud/features/external-resources/handlers/form/createElement.js +28 -3
  48. package/lib/camunda-cloud/features/external-resources/handlers/form/index.js +10 -0
  49. package/lib/camunda-cloud/features/external-resources/handlers/form/replaceElement.js +10 -0
  50. package/lib/camunda-cloud/features/external-resources/handlers/form/searchTerms.d.ts +9 -0
  51. package/lib/camunda-cloud/features/external-resources/handlers/form/searchTerms.js +10 -0
  52. package/lib/camunda-cloud/features/external-resources/handlers/process/AppendMenuProvider.js +11 -1
  53. package/lib/camunda-cloud/features/external-resources/handlers/process/CreateMenuProvider.js +11 -1
  54. package/lib/camunda-cloud/features/external-resources/handlers/process/ReplaceMenuProvider.js +11 -1
  55. package/lib/camunda-cloud/features/external-resources/handlers/process/createElement.d.ts +14 -5
  56. package/lib/camunda-cloud/features/external-resources/handlers/process/createElement.js +35 -4
  57. package/lib/camunda-cloud/features/external-resources/handlers/process/index.js +10 -0
  58. package/lib/camunda-cloud/features/external-resources/handlers/process/replaceElement.js +10 -0
  59. package/lib/camunda-cloud/features/external-resources/handlers/process/searchTerms.d.ts +9 -0
  60. package/lib/camunda-cloud/features/external-resources/handlers/process/searchTerms.js +10 -0
  61. package/lib/camunda-cloud/features/external-resources/handlers/rpa/AppendMenuProvider.d.ts +6 -0
  62. package/lib/camunda-cloud/features/external-resources/handlers/rpa/AppendMenuProvider.js +41 -0
  63. package/lib/camunda-cloud/features/external-resources/handlers/rpa/CreateMenuProvider.d.ts +6 -0
  64. package/lib/camunda-cloud/features/external-resources/handlers/rpa/CreateMenuProvider.js +41 -0
  65. package/lib/camunda-cloud/features/external-resources/handlers/rpa/ReplaceMenuProvider.d.ts +6 -0
  66. package/lib/camunda-cloud/features/external-resources/handlers/rpa/ReplaceMenuProvider.js +41 -0
  67. package/lib/camunda-cloud/features/external-resources/handlers/rpa/constants.d.ts +12 -0
  68. package/lib/camunda-cloud/features/external-resources/handlers/rpa/constants.js +14 -0
  69. package/lib/camunda-cloud/features/external-resources/handlers/rpa/createElement.d.ts +14 -0
  70. package/lib/camunda-cloud/features/external-resources/handlers/rpa/createElement.js +61 -0
  71. package/lib/camunda-cloud/features/external-resources/handlers/rpa/index.d.ts +8 -0
  72. package/lib/camunda-cloud/features/external-resources/handlers/rpa/index.js +20 -0
  73. package/lib/camunda-cloud/features/external-resources/handlers/rpa/replaceElement.d.ts +15 -0
  74. package/lib/camunda-cloud/features/external-resources/handlers/rpa/replaceElement.js +59 -0
  75. package/lib/camunda-cloud/features/external-resources/handlers/rpa/searchTerms.d.ts +10 -0
  76. package/lib/camunda-cloud/features/external-resources/handlers/rpa/searchTerms.js +11 -0
  77. package/lib/camunda-cloud/features/external-resources/handlers/util/BaseAppendMenuProvider.d.ts +21 -4
  78. package/lib/camunda-cloud/features/external-resources/handlers/util/BaseAppendMenuProvider.js +26 -8
  79. package/lib/camunda-cloud/features/external-resources/handlers/util/BaseCreateMenuProvider.d.ts +19 -3
  80. package/lib/camunda-cloud/features/external-resources/handlers/util/BaseCreateMenuProvider.js +24 -7
  81. package/lib/camunda-cloud/features/external-resources/handlers/util/BaseReplaceMenuProvider.d.ts +6 -2
  82. package/lib/camunda-cloud/features/external-resources/handlers/util/BaseReplaceMenuProvider.js +19 -6
  83. package/lib/camunda-cloud/features/external-resources/index.d.ts +4 -0
  84. package/lib/camunda-cloud/features/external-resources/index.js +13 -1
  85. package/lib/camunda-cloud/features/popup-menu/CamundaDetailsPopupMenuProvider.js +10 -0
  86. package/lib/camunda-cloud/features/popup-menu/index.js +10 -0
  87. package/lib/camunda-cloud/util/commonModules.js +10 -0
  88. package/lib/camunda-platform/Modeler.js +10 -0
  89. package/lib/camunda-platform/NavigatedViewer.js +10 -0
  90. package/lib/camunda-platform/Viewer.js +10 -0
  91. package/lib/camunda-platform/util/commonModules.js +10 -0
  92. package/lib/util/ExtensionElementsUtil.js +10 -0
  93. package/package.json +20 -18
@@ -16,31 +16,27 @@
16
16
  * @return {T[]}
17
17
  */
18
18
 
19
- const nativeToString$2 = Object.prototype.toString;
20
- const nativeHasOwnProperty$2 = Object.prototype.hasOwnProperty;
19
+ const nativeToString$6 = Object.prototype.toString;
20
+ const nativeHasOwnProperty$5 = Object.prototype.hasOwnProperty;
21
21
 
22
- function isUndefined$3(obj) {
22
+ function isUndefined$6(obj) {
23
23
  return obj === undefined;
24
24
  }
25
25
 
26
- function isDefined(obj) {
27
- return obj !== undefined;
28
- }
29
-
30
- function isNil(obj) {
26
+ function isNil$3(obj) {
31
27
  return obj == null;
32
28
  }
33
29
 
34
- function isArray$3(obj) {
35
- return nativeToString$2.call(obj) === '[object Array]';
30
+ function isArray$6(obj) {
31
+ return nativeToString$6.call(obj) === '[object Array]';
36
32
  }
37
33
 
38
- function isObject(obj) {
39
- return nativeToString$2.call(obj) === '[object Object]';
34
+ function isObject$2(obj) {
35
+ return nativeToString$6.call(obj) === '[object Object]';
40
36
  }
41
37
 
42
- function isNumber(obj) {
43
- return nativeToString$2.call(obj) === '[object Number]';
38
+ function isNumber$1(obj) {
39
+ return nativeToString$6.call(obj) === '[object Number]';
44
40
  }
45
41
 
46
42
  /**
@@ -48,8 +44,8 @@
48
44
  *
49
45
  * @return {boolean}
50
46
  */
51
- function isFunction(obj) {
52
- const tag = nativeToString$2.call(obj);
47
+ function isFunction$2(obj) {
48
+ const tag = nativeToString$6.call(obj);
53
49
 
54
50
  return (
55
51
  tag === '[object Function]' ||
@@ -60,10 +56,6 @@
60
56
  );
61
57
  }
62
58
 
63
- function isString(obj) {
64
- return nativeToString$2.call(obj) === '[object String]';
65
- }
66
-
67
59
  /**
68
60
  * Return true, if target owns a property with the given key.
69
61
  *
@@ -72,8 +64,8 @@
72
64
  *
73
65
  * @return {Boolean}
74
66
  */
75
- function has$2(target, key) {
76
- return !isNil(target) && nativeHasOwnProperty$2.call(target, key);
67
+ function has$5(target, key) {
68
+ return !isNil$3(target) && nativeHasOwnProperty$5.call(target, key);
77
69
  }
78
70
 
79
71
  /**
@@ -136,13 +128,13 @@
136
128
  *
137
129
  * @return {Object}
138
130
  */
139
- function find(collection, matcher) {
131
+ function find$2(collection, matcher) {
140
132
 
141
- const matchFn = toMatcher(matcher);
133
+ const matchFn = toMatcher$2(matcher);
142
134
 
143
135
  let match;
144
136
 
145
- forEach$2(collection, function(val, key) {
137
+ forEach$5(collection, function(val, key) {
146
138
  if (matchFn(val, key)) {
147
139
  match = val;
148
140
 
@@ -155,33 +147,6 @@
155
147
  }
156
148
 
157
149
 
158
- /**
159
- * Find element index in collection.
160
- *
161
- * @template T
162
- * @param {Collection<T>} collection
163
- * @param {Matcher<T>} matcher
164
- *
165
- * @return {number | string | undefined}
166
- */
167
- function findIndex(collection, matcher) {
168
-
169
- const matchFn = toMatcher(matcher);
170
-
171
- let idx = isArray$3(collection) ? -1 : undefined;
172
-
173
- forEach$2(collection, function(val, key) {
174
- if (matchFn(val, key)) {
175
- idx = key;
176
-
177
- return false;
178
- }
179
- });
180
-
181
- return idx;
182
- }
183
-
184
-
185
150
  /**
186
151
  * Filter elements in collection.
187
152
  *
@@ -191,13 +156,13 @@
191
156
  *
192
157
  * @return {T[]} result
193
158
  */
194
- function filter(collection, matcher) {
159
+ function filter$2(collection, matcher) {
195
160
 
196
- const matchFn = toMatcher(matcher);
161
+ const matchFn = toMatcher$2(matcher);
197
162
 
198
163
  let result = [];
199
164
 
200
- forEach$2(collection, function(val, key) {
165
+ forEach$5(collection, function(val, key) {
201
166
  if (matchFn(val, key)) {
202
167
  result.push(val);
203
168
  }
@@ -217,20 +182,20 @@
217
182
  *
218
183
  * @return {T} return result that stopped the iteration
219
184
  */
220
- function forEach$2(collection, iterator) {
185
+ function forEach$5(collection, iterator) {
221
186
 
222
187
  let val,
223
188
  result;
224
189
 
225
- if (isUndefined$3(collection)) {
190
+ if (isUndefined$6(collection)) {
226
191
  return;
227
192
  }
228
193
 
229
- const convertKey = isArray$3(collection) ? toNum$2 : identity$2;
194
+ const convertKey = isArray$6(collection) ? toNum$5 : identity$5;
230
195
 
231
196
  for (let key in collection) {
232
197
 
233
- if (has$2(collection, key)) {
198
+ if (has$5(collection, key)) {
234
199
  val = collection[key];
235
200
 
236
201
  result = iterator(val, convertKey(key));
@@ -243,45 +208,6 @@
243
208
  }
244
209
 
245
210
 
246
- /**
247
- * Reduce collection, returning a single result.
248
- *
249
- * @template T
250
- * @template V
251
- *
252
- * @param {Collection<T>} collection
253
- * @param {(result: V, entry: T, index: any) => V} iterator
254
- * @param {V} result
255
- *
256
- * @return {V} result returned from last iterator
257
- */
258
- function reduce(collection, iterator, result) {
259
-
260
- forEach$2(collection, function(value, idx) {
261
- result = iterator(result, value, idx);
262
- });
263
-
264
- return result;
265
- }
266
-
267
-
268
- /**
269
- * Return true if every element in the collection
270
- * matches the criteria.
271
- *
272
- * @param {Object|Array} collection
273
- * @param {Function} matcher
274
- *
275
- * @return {Boolean}
276
- */
277
- function every(collection, matcher) {
278
-
279
- return !!reduce(collection, function(matches, val, key) {
280
- return matches && matcher(val, key);
281
- }, true);
282
- }
283
-
284
-
285
211
  /**
286
212
  * Return true if some elements in the collection
287
213
  * match the criteria.
@@ -293,7 +219,7 @@
293
219
  */
294
220
  function some(collection, matcher) {
295
221
 
296
- return !!find(collection, matcher);
222
+ return !!find$2(collection, matcher);
297
223
  }
298
224
 
299
225
 
@@ -310,7 +236,7 @@
310
236
 
311
237
  let result = [];
312
238
 
313
- forEach$2(collection, function(val, key) {
239
+ forEach$5(collection, function(val, key) {
314
240
  result.push(fn(val, key));
315
241
  });
316
242
 
@@ -318,331 +244,124 @@
318
244
  }
319
245
 
320
246
 
321
- /**
322
- * Create an object pattern matcher.
323
- *
324
- * @example
325
- *
326
- * ```javascript
327
- * const matcher = matchPattern({ id: 1 });
328
- *
329
- * let element = find(elements, matcher);
330
- * ```
331
- *
332
- * @template T
333
- *
334
- * @param {T} pattern
335
- *
336
- * @return { (el: any) => boolean } matcherFn
337
- */
338
- function matchPattern(pattern) {
339
-
340
- return function(el) {
341
-
342
- return every(pattern, function(val, key) {
343
- return el[key] === val;
344
- });
345
-
346
- };
347
- }
348
-
349
-
350
247
  /**
351
248
  * @template T
352
249
  * @param {Matcher<T>} matcher
353
250
  *
354
251
  * @return {MatchFn<T>}
355
252
  */
356
- function toMatcher(matcher) {
357
- return isFunction(matcher) ? matcher : (e) => {
253
+ function toMatcher$2(matcher) {
254
+ return isFunction$2(matcher) ? matcher : (e) => {
358
255
  return e === matcher;
359
256
  };
360
257
  }
361
258
 
362
259
 
363
- function identity$2(arg) {
260
+ function identity$5(arg) {
364
261
  return arg;
365
262
  }
366
263
 
367
- function toNum$2(arg) {
264
+ function toNum$5(arg) {
368
265
  return Number(arg);
369
266
  }
370
267
 
371
- /* global setTimeout clearTimeout */
372
-
373
268
  /**
374
- * @typedef { {
375
- * (...args: any[]): any;
376
- * flush: () => void;
377
- * cancel: () => void;
378
- * } } DebouncedFunction
269
+ * Convenience wrapper for `Object.assign`.
270
+ *
271
+ * @param {Object} target
272
+ * @param {...Object} others
273
+ *
274
+ * @return {Object} the target
379
275
  */
276
+ function assign$6(target, ...others) {
277
+ return Object.assign(target, ...others);
278
+ }
380
279
 
381
280
  /**
382
- * Debounce fn, calling it only once if the given time
383
- * elapsed between calls.
281
+ * Pick all target properties, excluding the given ones.
384
282
  *
385
- * Lodash-style the function exposes methods to `#clear`
386
- * and `#flush` to control internal behavior.
283
+ * @template T
284
+ * @template {any[]} V
387
285
  *
388
- * @param {Function} fn
389
- * @param {Number} timeout
286
+ * @param {T} target
287
+ * @param {V} properties
390
288
  *
391
- * @return {DebouncedFunction} debounced function
289
+ * @return {Omit<T, V>} target
392
290
  */
393
- function debounce(fn, timeout) {
394
-
395
- let timer;
396
-
397
- let lastArgs;
398
- let lastThis;
399
-
400
- let lastNow;
291
+ function omit(target, properties) {
401
292
 
402
- function fire(force) {
293
+ let result = {};
403
294
 
404
- let now = Date.now();
295
+ let obj = Object(target);
405
296
 
406
- let scheduledDiff = force ? 0 : (lastNow + timeout) - now;
297
+ forEach$5(obj, function(prop, key) {
407
298
 
408
- if (scheduledDiff > 0) {
409
- return schedule(scheduledDiff);
299
+ if (properties.indexOf(key) === -1) {
300
+ result[key] = prop;
410
301
  }
302
+ });
411
303
 
412
- fn.apply(lastThis, lastArgs);
413
-
414
- clear();
415
- }
416
-
417
- function schedule(timeout) {
418
- timer = setTimeout(fire, timeout);
419
- }
420
-
421
- function clear() {
422
- if (timer) {
423
- clearTimeout(timer);
424
- }
304
+ return result;
305
+ }
425
306
 
426
- timer = lastNow = lastArgs = lastThis = undefined;
427
- }
307
+ var DEFAULT_RENDER_PRIORITY$1 = 1000;
428
308
 
429
- function flush() {
430
- if (timer) {
431
- fire(true);
432
- }
309
+ /**
310
+ * @typedef {import('../core/Types').ElementLike} Element
311
+ * @typedef {import('../core/Types').ConnectionLike} Connection
312
+ * @typedef {import('../core/Types').ShapeLike} Shape
313
+ *
314
+ * @typedef {import('../core/EventBus').default} EventBus
315
+ */
433
316
 
434
- clear();
435
- }
317
+ /**
318
+ * The base implementation of shape and connection renderers.
319
+ *
320
+ * @param {EventBus} eventBus
321
+ * @param {number} [renderPriority=1000]
322
+ */
323
+ function BaseRenderer(eventBus, renderPriority) {
324
+ var self = this;
436
325
 
437
- /**
438
- * @type { DebouncedFunction }
439
- */
440
- function callback(...args) {
441
- lastNow = Date.now();
326
+ renderPriority = renderPriority || DEFAULT_RENDER_PRIORITY$1;
442
327
 
443
- lastArgs = args;
444
- lastThis = this;
328
+ eventBus.on([ 'render.shape', 'render.connection' ], renderPriority, function(evt, context) {
329
+ var type = evt.type,
330
+ element = context.element,
331
+ visuals = context.gfx,
332
+ attrs = context.attrs;
445
333
 
446
- // ensure an execution is scheduled
447
- if (!timer) {
448
- schedule(timeout);
334
+ if (self.canRender(element)) {
335
+ if (type === 'render.shape') {
336
+ return self.drawShape(visuals, element, attrs);
337
+ } else {
338
+ return self.drawConnection(visuals, element, attrs);
339
+ }
449
340
  }
450
- }
451
-
452
- callback.flush = flush;
453
- callback.cancel = clear;
341
+ });
454
342
 
455
- return callback;
343
+ eventBus.on([ 'render.getShapePath', 'render.getConnectionPath' ], renderPriority, function(evt, element) {
344
+ if (self.canRender(element)) {
345
+ if (evt.type === 'render.getShapePath') {
346
+ return self.getShapePath(element);
347
+ } else {
348
+ return self.getConnectionPath(element);
349
+ }
350
+ }
351
+ });
456
352
  }
457
353
 
458
354
  /**
459
- * Bind function against target <this>.
355
+ * Checks whether an element can be rendered.
460
356
  *
461
- * @param {Function} fn
462
- * @param {Object} target
357
+ * @param {Element} element The element to be rendered.
463
358
  *
464
- * @return {Function} bound function
359
+ * @return {boolean} Whether the element can be rendered.
465
360
  */
466
- function bind$3(fn, target) {
467
- return fn.bind(target);
468
- }
361
+ BaseRenderer.prototype.canRender = function(element) {};
469
362
 
470
363
  /**
471
- * Convenience wrapper for `Object.assign`.
472
- *
473
- * @param {Object} target
474
- * @param {...Object} others
475
- *
476
- * @return {Object} the target
477
- */
478
- function assign$2(target, ...others) {
479
- return Object.assign(target, ...others);
480
- }
481
-
482
- /**
483
- * Sets a nested property of a given object to the specified value.
484
- *
485
- * This mutates the object and returns it.
486
- *
487
- * @template T
488
- *
489
- * @param {T} target The target of the set operation.
490
- * @param {(string|number)[]} path The path to the nested value.
491
- * @param {any} value The value to set.
492
- *
493
- * @return {T}
494
- */
495
- function set$1(target, path, value) {
496
-
497
- let currentTarget = target;
498
-
499
- forEach$2(path, function(key, idx) {
500
-
501
- if (typeof key !== 'number' && typeof key !== 'string') {
502
- throw new Error('illegal key type: ' + typeof key + '. Key should be of type number or string.');
503
- }
504
-
505
- if (key === 'constructor') {
506
- throw new Error('illegal key: constructor');
507
- }
508
-
509
- if (key === '__proto__') {
510
- throw new Error('illegal key: __proto__');
511
- }
512
-
513
- let nextKey = path[idx + 1];
514
- let nextTarget = currentTarget[key];
515
-
516
- if (isDefined(nextKey) && isNil(nextTarget)) {
517
- nextTarget = currentTarget[key] = isNaN(+nextKey) ? {} : [];
518
- }
519
-
520
- if (isUndefined$3(nextKey)) {
521
- if (isUndefined$3(value)) {
522
- delete currentTarget[key];
523
- } else {
524
- currentTarget[key] = value;
525
- }
526
- } else {
527
- currentTarget = nextTarget;
528
- }
529
- });
530
-
531
- return target;
532
- }
533
-
534
- /**
535
- * Pick properties from the given target.
536
- *
537
- * @template T
538
- * @template {any[]} V
539
- *
540
- * @param {T} target
541
- * @param {V} properties
542
- *
543
- * @return Pick<T, V>
544
- */
545
- function pick(target, properties) {
546
-
547
- let result = {};
548
-
549
- let obj = Object(target);
550
-
551
- forEach$2(properties, function(prop) {
552
-
553
- if (prop in obj) {
554
- result[prop] = target[prop];
555
- }
556
- });
557
-
558
- return result;
559
- }
560
-
561
- /**
562
- * Pick all target properties, excluding the given ones.
563
- *
564
- * @template T
565
- * @template {any[]} V
566
- *
567
- * @param {T} target
568
- * @param {V} properties
569
- *
570
- * @return {Omit<T, V>} target
571
- */
572
- function omit(target, properties) {
573
-
574
- let result = {};
575
-
576
- let obj = Object(target);
577
-
578
- forEach$2(obj, function(prop, key) {
579
-
580
- if (properties.indexOf(key) === -1) {
581
- result[key] = prop;
582
- }
583
- });
584
-
585
- return result;
586
- }
587
-
588
- var DEFAULT_RENDER_PRIORITY$1 = 1000;
589
-
590
- /**
591
- * @typedef {import('../core/Types').ElementLike} Element
592
- * @typedef {import('../core/Types').ConnectionLike} Connection
593
- * @typedef {import('../core/Types').ShapeLike} Shape
594
- *
595
- * @typedef {import('../core/EventBus').default} EventBus
596
- */
597
-
598
- /**
599
- * The base implementation of shape and connection renderers.
600
- *
601
- * @param {EventBus} eventBus
602
- * @param {number} [renderPriority=1000]
603
- */
604
- function BaseRenderer(eventBus, renderPriority) {
605
- var self = this;
606
-
607
- renderPriority = renderPriority || DEFAULT_RENDER_PRIORITY$1;
608
-
609
- eventBus.on([ 'render.shape', 'render.connection' ], renderPriority, function(evt, context) {
610
- var type = evt.type,
611
- element = context.element,
612
- visuals = context.gfx,
613
- attrs = context.attrs;
614
-
615
- if (self.canRender(element)) {
616
- if (type === 'render.shape') {
617
- return self.drawShape(visuals, element, attrs);
618
- } else {
619
- return self.drawConnection(visuals, element, attrs);
620
- }
621
- }
622
- });
623
-
624
- eventBus.on([ 'render.getShapePath', 'render.getConnectionPath' ], renderPriority, function(evt, element) {
625
- if (self.canRender(element)) {
626
- if (evt.type === 'render.getShapePath') {
627
- return self.getShapePath(element);
628
- } else {
629
- return self.getConnectionPath(element);
630
- }
631
- }
632
- });
633
- }
634
-
635
- /**
636
- * Checks whether an element can be rendered.
637
- *
638
- * @param {Element} element The element to be rendered.
639
- *
640
- * @return {boolean} Whether the element can be rendered.
641
- */
642
- BaseRenderer.prototype.canRender = function(element) {};
643
-
644
- /**
645
- * Draws a shape.
364
+ * Draws a shape.
646
365
  *
647
366
  * @param {SVGElement} visuals The SVG element to draw the shape into.
648
367
  * @param {Shape} shape The shape to be drawn.
@@ -799,301 +518,711 @@
799
518
  }
800
519
 
801
520
  /**
802
- * Checks whether a value is an instance of Connection.
521
+ * Flatten array, one level deep.
803
522
  *
804
- * @param {any} value
523
+ * @template T
805
524
  *
806
- * @return {boolean}
525
+ * @param {T[][] | T[] | null} [arr]
526
+ *
527
+ * @return {T[]}
807
528
  */
808
- function isConnection(value) {
809
- return isObject(value) && has$2(value, 'waypoints');
529
+
530
+ const nativeToString$5 = Object.prototype.toString;
531
+ const nativeHasOwnProperty$4 = Object.prototype.hasOwnProperty;
532
+
533
+ function isUndefined$5(obj) {
534
+ return obj === undefined;
810
535
  }
811
536
 
812
- /**
813
- * Checks whether a value is an instance of Label.
814
- *
815
- * @param {any} value
816
- *
817
- * @return {boolean}
818
- */
819
- function isLabel(value) {
820
- return isObject(value) && has$2(value, 'labelTarget');
537
+ function isDefined$1(obj) {
538
+ return obj !== undefined;
821
539
  }
822
540
 
823
- /**
824
- * @typedef {import('diagram-js/lib/util/Types').Point} Point
825
- * @typedef {import('diagram-js/lib/util/Types').Rect} Rect
826
- *
827
- * @typedef {import('../model/Types').Element} Element
828
- * @typedef {import('../model/Types').ModdleElement} ModdleElement
829
- */
541
+ function isNil$2(obj) {
542
+ return obj == null;
543
+ }
830
544
 
831
- var DEFAULT_LABEL_SIZE$1 = {
832
- width: 90,
833
- height: 20
834
- };
545
+ function isArray$5(obj) {
546
+ return nativeToString$5.call(obj) === '[object Array]';
547
+ }
835
548
 
836
- var FLOW_LABEL_INDENT = 15;
549
+ function isObject$1(obj) {
550
+ return nativeToString$5.call(obj) === '[object Object]';
551
+ }
837
552
 
553
+ function isNumber(obj) {
554
+ return nativeToString$5.call(obj) === '[object Number]';
555
+ }
838
556
 
839
557
  /**
840
- * Return true if the given semantic has an external label.
841
- *
842
- * @param {Element} semantic
558
+ * @param {any} obj
843
559
  *
844
560
  * @return {boolean}
845
561
  */
846
- function isLabelExternal(semantic) {
847
- return is$1(semantic, 'bpmn:Event') ||
848
- is$1(semantic, 'bpmn:Gateway') ||
849
- is$1(semantic, 'bpmn:DataStoreReference') ||
850
- is$1(semantic, 'bpmn:DataObjectReference') ||
851
- is$1(semantic, 'bpmn:DataInput') ||
852
- is$1(semantic, 'bpmn:DataOutput') ||
853
- is$1(semantic, 'bpmn:SequenceFlow') ||
854
- is$1(semantic, 'bpmn:MessageFlow') ||
855
- is$1(semantic, 'bpmn:Group');
562
+ function isFunction$1(obj) {
563
+ const tag = nativeToString$5.call(obj);
564
+
565
+ return (
566
+ tag === '[object Function]' ||
567
+ tag === '[object AsyncFunction]' ||
568
+ tag === '[object GeneratorFunction]' ||
569
+ tag === '[object AsyncGeneratorFunction]' ||
570
+ tag === '[object Proxy]'
571
+ );
572
+ }
573
+
574
+ function isString$3(obj) {
575
+ return nativeToString$5.call(obj) === '[object String]';
856
576
  }
857
577
 
858
578
  /**
859
- * Get the position of a sequence flow label.
579
+ * Return true, if target owns a property with the given key.
860
580
  *
861
- * @param {Point[]} waypoints
581
+ * @param {Object} target
582
+ * @param {String} key
862
583
  *
863
- * @return {Point}
584
+ * @return {Boolean}
864
585
  */
865
- function getFlowLabelPosition(waypoints) {
866
-
867
- // get the waypoints mid
868
- var mid = waypoints.length / 2 - 1;
869
-
870
- var first = waypoints[Math.floor(mid)];
871
- var second = waypoints[Math.ceil(mid + 0.01)];
872
-
873
- // get position
874
- var position = getWaypointsMid(waypoints);
875
-
876
- // calculate angle
877
- var angle = Math.atan((second.y - first.y) / (second.x - first.x));
878
-
879
- var x = position.x,
880
- y = position.y;
881
-
882
- if (Math.abs(angle) < Math.PI / 2) {
883
- y -= FLOW_LABEL_INDENT;
884
- } else {
885
- x += FLOW_LABEL_INDENT;
886
- }
887
-
888
- return { x: x, y: y };
889
- }
586
+ function has$4(target, key) {
587
+ return !isNil$2(target) && nativeHasOwnProperty$4.call(target, key);
588
+ }
890
589
 
590
+ /**
591
+ * @template T
592
+ * @typedef { (
593
+ * ((e: T) => boolean) |
594
+ * ((e: T, idx: number) => boolean) |
595
+ * ((e: T, key: string) => boolean) |
596
+ * string |
597
+ * number
598
+ * ) } Matcher
599
+ */
891
600
 
892
601
  /**
893
- * Get the middle of a number of waypoints.
894
- *
895
- * @param {Point[]} waypoints
602
+ * @template T
603
+ * @template U
896
604
  *
897
- * @return {Point}
605
+ * @typedef { (
606
+ * ((e: T) => U) | string | number
607
+ * ) } Extractor
898
608
  */
899
- function getWaypointsMid(waypoints) {
900
609
 
901
- var mid = waypoints.length / 2 - 1;
902
610
 
903
- var first = waypoints[Math.floor(mid)];
904
- var second = waypoints[Math.ceil(mid + 0.01)];
611
+ /**
612
+ * @template T
613
+ * @typedef { (val: T, key: any) => boolean } MatchFn
614
+ */
905
615
 
906
- return {
907
- x: first.x + (second.x - first.x) / 2,
908
- y: first.y + (second.y - first.y) / 2
909
- };
910
- }
616
+ /**
617
+ * @template T
618
+ * @typedef { T[] } ArrayCollection
619
+ */
911
620
 
912
621
  /**
913
- * Get the middle of the external label of an element.
914
- *
915
- * @param {Element} element
916
- *
917
- * @return {Point}
622
+ * @template T
623
+ * @typedef { { [key: string]: T } } StringKeyValueCollection
918
624
  */
919
- function getExternalLabelMid(element) {
920
625
 
921
- if (element.waypoints) {
922
- return getFlowLabelPosition(element.waypoints);
923
- } else if (is$1(element, 'bpmn:Group')) {
924
- return {
925
- x: element.x + element.width / 2,
926
- y: element.y + DEFAULT_LABEL_SIZE$1.height / 2
927
- };
928
- } else {
929
- return {
930
- x: element.x + element.width / 2,
931
- y: element.y + element.height + DEFAULT_LABEL_SIZE$1.height / 2
932
- };
933
- }
934
- }
626
+ /**
627
+ * @template T
628
+ * @typedef { { [key: number]: T } } NumberKeyValueCollection
629
+ */
935
630
 
631
+ /**
632
+ * @template T
633
+ * @typedef { StringKeyValueCollection<T> | NumberKeyValueCollection<T> } KeyValueCollection
634
+ */
936
635
 
937
636
  /**
938
- * Return the bounds of an elements label, parsed from the elements DI or
939
- * generated from its bounds.
637
+ * @template T
638
+ * @typedef { KeyValueCollection<T> | ArrayCollection<T> } Collection
639
+ */
640
+
641
+ /**
642
+ * Find element in collection.
940
643
  *
941
- * @param {ModdleElement} di
942
- * @param {Element} element
644
+ * @template T
645
+ * @param {Collection<T>} collection
646
+ * @param {Matcher<T>} matcher
943
647
  *
944
- * @return {Rect}
648
+ * @return {Object}
945
649
  */
946
- function getExternalLabelBounds(di, element) {
947
-
948
- var mid,
949
- size,
950
- bounds,
951
- label = di.label;
650
+ function find$1(collection, matcher) {
952
651
 
953
- if (label && label.bounds) {
954
- bounds = label.bounds;
652
+ const matchFn = toMatcher$1(matcher);
955
653
 
956
- size = {
957
- width: Math.max(DEFAULT_LABEL_SIZE$1.width, bounds.width),
958
- height: bounds.height
959
- };
654
+ let match;
960
655
 
961
- mid = {
962
- x: bounds.x + bounds.width / 2,
963
- y: bounds.y + bounds.height / 2
964
- };
965
- } else {
656
+ forEach$4(collection, function(val, key) {
657
+ if (matchFn(val, key)) {
658
+ match = val;
966
659
 
967
- mid = getExternalLabelMid(element);
660
+ return false;
661
+ }
662
+ });
968
663
 
969
- size = DEFAULT_LABEL_SIZE$1;
970
- }
664
+ return match;
971
665
 
972
- return assign$2({
973
- x: mid.x - size.width / 2,
974
- y: mid.y - size.height / 2
975
- }, size);
976
666
  }
977
667
 
978
- /**
979
- * @param {ModdleElement} semantic
980
- *
981
- * @returns {string}
982
- */
983
- function getLabelAttr(semantic) {
984
- if (
985
- is$1(semantic, 'bpmn:FlowElement') ||
986
- is$1(semantic, 'bpmn:Participant') ||
987
- is$1(semantic, 'bpmn:Lane') ||
988
- is$1(semantic, 'bpmn:SequenceFlow') ||
989
- is$1(semantic, 'bpmn:MessageFlow') ||
990
- is$1(semantic, 'bpmn:DataInput') ||
991
- is$1(semantic, 'bpmn:DataOutput')
992
- ) {
993
- return 'name';
994
- }
995
-
996
- if (is$1(semantic, 'bpmn:TextAnnotation')) {
997
- return 'text';
998
- }
999
-
1000
- if (is$1(semantic, 'bpmn:Group')) {
1001
- return 'categoryValueRef';
1002
- }
1003
- }
1004
668
 
1005
669
  /**
1006
- * @param {ModdleElement} semantic
670
+ * Filter elements in collection.
1007
671
  *
1008
- * @returns {string}
672
+ * @template T
673
+ * @param {Collection<T>} collection
674
+ * @param {Matcher<T>} matcher
675
+ *
676
+ * @return {T[]} result
1009
677
  */
1010
- function getCategoryValue(semantic) {
1011
- var categoryValueRef = semantic['categoryValueRef'];
678
+ function filter$1(collection, matcher) {
1012
679
 
1013
- if (!categoryValueRef) {
1014
- return '';
1015
- }
680
+ const matchFn = toMatcher$1(matcher);
1016
681
 
682
+ let result = [];
1017
683
 
1018
- return categoryValueRef.value || '';
684
+ forEach$4(collection, function(val, key) {
685
+ if (matchFn(val, key)) {
686
+ result.push(val);
687
+ }
688
+ });
689
+
690
+ return result;
1019
691
  }
1020
692
 
693
+
1021
694
  /**
1022
- * @param {Element} element
695
+ * Iterate over collection; returning something
696
+ * (non-undefined) will stop iteration.
1023
697
  *
1024
- * @return {string}
698
+ * @template T
699
+ * @param {Collection<T>} collection
700
+ * @param { ((item: T, idx: number) => (boolean|void)) | ((item: T, key: string) => (boolean|void)) } iterator
701
+ *
702
+ * @return {T} return result that stopped the iteration
1025
703
  */
1026
- function getLabel(element) {
1027
- var semantic = element.businessObject,
1028
- attr = getLabelAttr(semantic);
1029
-
1030
- if (attr) {
1031
-
1032
- if (attr === 'categoryValueRef') {
704
+ function forEach$4(collection, iterator) {
1033
705
 
1034
- return getCategoryValue(semantic);
1035
- }
706
+ let val,
707
+ result;
1036
708
 
1037
- return semantic[attr] || '';
709
+ if (isUndefined$5(collection)) {
710
+ return;
1038
711
  }
1039
- }
1040
712
 
1041
- function ensureImported(element, target) {
713
+ const convertKey = isArray$5(collection) ? toNum$4 : identity$4;
1042
714
 
1043
- if (element.ownerDocument !== target.ownerDocument) {
1044
- try {
715
+ for (let key in collection) {
1045
716
 
1046
- // may fail on webkit
1047
- return target.ownerDocument.importNode(element, true);
1048
- } catch (e) {
717
+ if (has$4(collection, key)) {
718
+ val = collection[key];
1049
719
 
1050
- // ignore
720
+ result = iterator(val, convertKey(key));
721
+
722
+ if (result === false) {
723
+ return val;
724
+ }
1051
725
  }
1052
726
  }
1053
-
1054
- return element;
1055
727
  }
1056
728
 
1057
- /**
1058
- * appendTo utility
1059
- */
1060
-
1061
729
 
1062
730
  /**
1063
- * Append a node to a target element and return the appended node.
731
+ * Reduce collection, returning a single result.
1064
732
  *
1065
- * @param {SVGElement} element
1066
- * @param {SVGElement} target
733
+ * @template T
734
+ * @template V
1067
735
  *
1068
- * @return {SVGElement} the appended node
736
+ * @param {Collection<T>} collection
737
+ * @param {(result: V, entry: T, index: any) => V} iterator
738
+ * @param {V} result
739
+ *
740
+ * @return {V} result returned from last iterator
1069
741
  */
1070
- function appendTo(element, target) {
1071
- return target.appendChild(ensureImported(element, target));
1072
- }
742
+ function reduce(collection, iterator, result) {
1073
743
 
1074
- /**
1075
- * append utility
1076
- */
744
+ forEach$4(collection, function(value, idx) {
745
+ result = iterator(result, value, idx);
746
+ });
747
+
748
+ return result;
749
+ }
1077
750
 
1078
751
 
1079
752
  /**
1080
- * Append a node to an element
753
+ * Return true if every element in the collection
754
+ * matches the criteria.
1081
755
  *
1082
- * @param {SVGElement} element
1083
- * @param {SVGElement} node
756
+ * @param {Object|Array} collection
757
+ * @param {Function} matcher
1084
758
  *
1085
- * @return {SVGElement} the element
759
+ * @return {Boolean}
1086
760
  */
1087
- function append(target, node) {
1088
- appendTo(node, target);
1089
- return target;
1090
- }
761
+ function every(collection, matcher) {
1091
762
 
1092
- /**
1093
- * attribute accessor utility
1094
- */
763
+ return !!reduce(collection, function(matches, val, key) {
764
+ return matches && matcher(val, key);
765
+ }, true);
766
+ }
1095
767
 
1096
- var LENGTH_ATTR = 2;
768
+
769
+ /**
770
+ * Create an object pattern matcher.
771
+ *
772
+ * @example
773
+ *
774
+ * ```javascript
775
+ * const matcher = matchPattern({ id: 1 });
776
+ *
777
+ * let element = find(elements, matcher);
778
+ * ```
779
+ *
780
+ * @template T
781
+ *
782
+ * @param {T} pattern
783
+ *
784
+ * @return { (el: any) => boolean } matcherFn
785
+ */
786
+ function matchPattern(pattern) {
787
+
788
+ return function(el) {
789
+
790
+ return every(pattern, function(val, key) {
791
+ return el[key] === val;
792
+ });
793
+
794
+ };
795
+ }
796
+
797
+
798
+ /**
799
+ * @template T
800
+ * @param {Matcher<T>} matcher
801
+ *
802
+ * @return {MatchFn<T>}
803
+ */
804
+ function toMatcher$1(matcher) {
805
+ return isFunction$1(matcher) ? matcher : (e) => {
806
+ return e === matcher;
807
+ };
808
+ }
809
+
810
+
811
+ function identity$4(arg) {
812
+ return arg;
813
+ }
814
+
815
+ function toNum$4(arg) {
816
+ return Number(arg);
817
+ }
818
+
819
+ /* global setTimeout clearTimeout */
820
+
821
+ /**
822
+ * @typedef { {
823
+ * (...args: any[]): any;
824
+ * flush: () => void;
825
+ * cancel: () => void;
826
+ * } } DebouncedFunction
827
+ */
828
+
829
+ /**
830
+ * Debounce fn, calling it only once if the given time
831
+ * elapsed between calls.
832
+ *
833
+ * Lodash-style the function exposes methods to `#clear`
834
+ * and `#flush` to control internal behavior.
835
+ *
836
+ * @param {Function} fn
837
+ * @param {Number} timeout
838
+ *
839
+ * @return {DebouncedFunction} debounced function
840
+ */
841
+ function debounce(fn, timeout) {
842
+
843
+ let timer;
844
+
845
+ let lastArgs;
846
+ let lastThis;
847
+
848
+ let lastNow;
849
+
850
+ function fire(force) {
851
+
852
+ let now = Date.now();
853
+
854
+ let scheduledDiff = force ? 0 : (lastNow + timeout) - now;
855
+
856
+ if (scheduledDiff > 0) {
857
+ return schedule(scheduledDiff);
858
+ }
859
+
860
+ fn.apply(lastThis, lastArgs);
861
+
862
+ clear();
863
+ }
864
+
865
+ function schedule(timeout) {
866
+ timer = setTimeout(fire, timeout);
867
+ }
868
+
869
+ function clear() {
870
+ if (timer) {
871
+ clearTimeout(timer);
872
+ }
873
+
874
+ timer = lastNow = lastArgs = lastThis = undefined;
875
+ }
876
+
877
+ function flush() {
878
+ if (timer) {
879
+ fire(true);
880
+ }
881
+
882
+ clear();
883
+ }
884
+
885
+ /**
886
+ * @type { DebouncedFunction }
887
+ */
888
+ function callback(...args) {
889
+ lastNow = Date.now();
890
+
891
+ lastArgs = args;
892
+ lastThis = this;
893
+
894
+ // ensure an execution is scheduled
895
+ if (!timer) {
896
+ schedule(timeout);
897
+ }
898
+ }
899
+
900
+ callback.flush = flush;
901
+ callback.cancel = clear;
902
+
903
+ return callback;
904
+ }
905
+
906
+ /**
907
+ * Bind function against target <this>.
908
+ *
909
+ * @param {Function} fn
910
+ * @param {Object} target
911
+ *
912
+ * @return {Function} bound function
913
+ */
914
+ function bind$4(fn, target) {
915
+ return fn.bind(target);
916
+ }
917
+
918
+ /**
919
+ * Convenience wrapper for `Object.assign`.
920
+ *
921
+ * @param {Object} target
922
+ * @param {...Object} others
923
+ *
924
+ * @return {Object} the target
925
+ */
926
+ function assign$5(target, ...others) {
927
+ return Object.assign(target, ...others);
928
+ }
929
+
930
+ /**
931
+ * Checks whether a value is an instance of Connection.
932
+ *
933
+ * @param {any} value
934
+ *
935
+ * @return {boolean}
936
+ */
937
+ function isConnection(value) {
938
+ return isObject$1(value) && has$4(value, 'waypoints');
939
+ }
940
+
941
+ /**
942
+ * Checks whether a value is an instance of Label.
943
+ *
944
+ * @param {any} value
945
+ *
946
+ * @return {boolean}
947
+ */
948
+ function isLabel(value) {
949
+ return isObject$1(value) && has$4(value, 'labelTarget');
950
+ }
951
+
952
+ /**
953
+ * @typedef {import('diagram-js/lib/util/Types').Point} Point
954
+ * @typedef {import('diagram-js/lib/util/Types').Rect} Rect
955
+ *
956
+ * @typedef {import('../model/Types').Element} Element
957
+ * @typedef {import('../model/Types').ModdleElement} ModdleElement
958
+ */
959
+
960
+ var DEFAULT_LABEL_SIZE$1 = {
961
+ width: 90,
962
+ height: 20
963
+ };
964
+
965
+ var FLOW_LABEL_INDENT = 15;
966
+
967
+
968
+ /**
969
+ * Return true if the given semantic has an external label.
970
+ *
971
+ * @param {Element} semantic
972
+ *
973
+ * @return {boolean}
974
+ */
975
+ function isLabelExternal(semantic) {
976
+ return is$1(semantic, 'bpmn:Event') ||
977
+ is$1(semantic, 'bpmn:Gateway') ||
978
+ is$1(semantic, 'bpmn:DataStoreReference') ||
979
+ is$1(semantic, 'bpmn:DataObjectReference') ||
980
+ is$1(semantic, 'bpmn:DataInput') ||
981
+ is$1(semantic, 'bpmn:DataOutput') ||
982
+ is$1(semantic, 'bpmn:SequenceFlow') ||
983
+ is$1(semantic, 'bpmn:MessageFlow') ||
984
+ is$1(semantic, 'bpmn:Group');
985
+ }
986
+
987
+ /**
988
+ * Get the position of a sequence flow label.
989
+ *
990
+ * @param {Point[]} waypoints
991
+ *
992
+ * @return {Point}
993
+ */
994
+ function getFlowLabelPosition(waypoints) {
995
+
996
+ // get the waypoints mid
997
+ var mid = waypoints.length / 2 - 1;
998
+
999
+ var first = waypoints[Math.floor(mid)];
1000
+ var second = waypoints[Math.ceil(mid + 0.01)];
1001
+
1002
+ // get position
1003
+ var position = getWaypointsMid(waypoints);
1004
+
1005
+ // calculate angle
1006
+ var angle = Math.atan((second.y - first.y) / (second.x - first.x));
1007
+
1008
+ var x = position.x,
1009
+ y = position.y;
1010
+
1011
+ if (Math.abs(angle) < Math.PI / 2) {
1012
+ y -= FLOW_LABEL_INDENT;
1013
+ } else {
1014
+ x += FLOW_LABEL_INDENT;
1015
+ }
1016
+
1017
+ return { x: x, y: y };
1018
+ }
1019
+
1020
+
1021
+ /**
1022
+ * Get the middle of a number of waypoints.
1023
+ *
1024
+ * @param {Point[]} waypoints
1025
+ *
1026
+ * @return {Point}
1027
+ */
1028
+ function getWaypointsMid(waypoints) {
1029
+
1030
+ var mid = waypoints.length / 2 - 1;
1031
+
1032
+ var first = waypoints[Math.floor(mid)];
1033
+ var second = waypoints[Math.ceil(mid + 0.01)];
1034
+
1035
+ return {
1036
+ x: first.x + (second.x - first.x) / 2,
1037
+ y: first.y + (second.y - first.y) / 2
1038
+ };
1039
+ }
1040
+
1041
+ /**
1042
+ * Get the middle of the external label of an element.
1043
+ *
1044
+ * @param {Element} element
1045
+ *
1046
+ * @return {Point}
1047
+ */
1048
+ function getExternalLabelMid(element) {
1049
+
1050
+ if (element.waypoints) {
1051
+ return getFlowLabelPosition(element.waypoints);
1052
+ } else if (is$1(element, 'bpmn:Group')) {
1053
+ return {
1054
+ x: element.x + element.width / 2,
1055
+ y: element.y + DEFAULT_LABEL_SIZE$1.height / 2
1056
+ };
1057
+ } else {
1058
+ return {
1059
+ x: element.x + element.width / 2,
1060
+ y: element.y + element.height + DEFAULT_LABEL_SIZE$1.height / 2
1061
+ };
1062
+ }
1063
+ }
1064
+
1065
+
1066
+ /**
1067
+ * Return the bounds of an elements label, parsed from the elements DI or
1068
+ * generated from its bounds.
1069
+ *
1070
+ * @param {ModdleElement} di
1071
+ * @param {Element} element
1072
+ *
1073
+ * @return {Rect}
1074
+ */
1075
+ function getExternalLabelBounds(di, element) {
1076
+
1077
+ var mid,
1078
+ size,
1079
+ bounds,
1080
+ label = di.label;
1081
+
1082
+ if (label && label.bounds) {
1083
+ bounds = label.bounds;
1084
+
1085
+ size = {
1086
+ width: Math.max(DEFAULT_LABEL_SIZE$1.width, bounds.width),
1087
+ height: bounds.height
1088
+ };
1089
+
1090
+ mid = {
1091
+ x: bounds.x + bounds.width / 2,
1092
+ y: bounds.y + bounds.height / 2
1093
+ };
1094
+ } else {
1095
+
1096
+ mid = getExternalLabelMid(element);
1097
+
1098
+ size = DEFAULT_LABEL_SIZE$1;
1099
+ }
1100
+
1101
+ return assign$6({
1102
+ x: mid.x - size.width / 2,
1103
+ y: mid.y - size.height / 2
1104
+ }, size);
1105
+ }
1106
+
1107
+ /**
1108
+ * @param {ModdleElement} semantic
1109
+ *
1110
+ * @returns {string}
1111
+ */
1112
+ function getLabelAttr(semantic) {
1113
+ if (
1114
+ is$1(semantic, 'bpmn:FlowElement') ||
1115
+ is$1(semantic, 'bpmn:Participant') ||
1116
+ is$1(semantic, 'bpmn:Lane') ||
1117
+ is$1(semantic, 'bpmn:SequenceFlow') ||
1118
+ is$1(semantic, 'bpmn:MessageFlow') ||
1119
+ is$1(semantic, 'bpmn:DataInput') ||
1120
+ is$1(semantic, 'bpmn:DataOutput')
1121
+ ) {
1122
+ return 'name';
1123
+ }
1124
+
1125
+ if (is$1(semantic, 'bpmn:TextAnnotation')) {
1126
+ return 'text';
1127
+ }
1128
+
1129
+ if (is$1(semantic, 'bpmn:Group')) {
1130
+ return 'categoryValueRef';
1131
+ }
1132
+ }
1133
+
1134
+ /**
1135
+ * @param {ModdleElement} semantic
1136
+ *
1137
+ * @returns {string}
1138
+ */
1139
+ function getCategoryValue(semantic) {
1140
+ var categoryValueRef = semantic['categoryValueRef'];
1141
+
1142
+ if (!categoryValueRef) {
1143
+ return '';
1144
+ }
1145
+
1146
+
1147
+ return categoryValueRef.value || '';
1148
+ }
1149
+
1150
+ /**
1151
+ * @param {Element} element
1152
+ *
1153
+ * @return {string}
1154
+ */
1155
+ function getLabel(element) {
1156
+ var semantic = element.businessObject,
1157
+ attr = getLabelAttr(semantic);
1158
+
1159
+ if (attr) {
1160
+
1161
+ if (attr === 'categoryValueRef') {
1162
+
1163
+ return getCategoryValue(semantic);
1164
+ }
1165
+
1166
+ return semantic[attr] || '';
1167
+ }
1168
+ }
1169
+
1170
+ function ensureImported(element, target) {
1171
+
1172
+ if (element.ownerDocument !== target.ownerDocument) {
1173
+ try {
1174
+
1175
+ // may fail on webkit
1176
+ return target.ownerDocument.importNode(element, true);
1177
+ } catch (e) {
1178
+
1179
+ // ignore
1180
+ }
1181
+ }
1182
+
1183
+ return element;
1184
+ }
1185
+
1186
+ /**
1187
+ * appendTo utility
1188
+ */
1189
+
1190
+
1191
+ /**
1192
+ * Append a node to a target element and return the appended node.
1193
+ *
1194
+ * @param {SVGElement} element
1195
+ * @param {SVGElement} target
1196
+ *
1197
+ * @return {SVGElement} the appended node
1198
+ */
1199
+ function appendTo(element, target) {
1200
+ return target.appendChild(ensureImported(element, target));
1201
+ }
1202
+
1203
+ /**
1204
+ * append utility
1205
+ */
1206
+
1207
+
1208
+ /**
1209
+ * Append a node to an element
1210
+ *
1211
+ * @param {SVGElement} element
1212
+ * @param {SVGElement} node
1213
+ *
1214
+ * @return {SVGElement} the element
1215
+ */
1216
+ function append(target, node) {
1217
+ appendTo(node, target);
1218
+ return target;
1219
+ }
1220
+
1221
+ /**
1222
+ * attribute accessor utility
1223
+ */
1224
+
1225
+ var LENGTH_ATTR = 2;
1097
1226
 
1098
1227
  var CSS_PROPERTIES = {
1099
1228
  'alignment-baseline': 1,
@@ -1504,7 +1633,7 @@
1504
1633
  */
1505
1634
 
1506
1635
  var TEXT_ENTITIES = /([&<>]{1})/g;
1507
- var ATTR_ENTITIES = /([\n\r"]{1})/g;
1636
+ var ATTR_ENTITIES = /([&<>\n\r"]{1})/g;
1508
1637
 
1509
1638
  var ENTITY_REPLACEMENT = {
1510
1639
  '&': '&amp;',
@@ -2017,7 +2146,7 @@
2017
2146
  * @returns {number}
2018
2147
  */
2019
2148
  function getWidth(bounds, overrides = {}) {
2020
- return has$2(overrides, 'width') ? overrides.width : bounds.width;
2149
+ return has$5(overrides, 'width') ? overrides.width : bounds.width;
2021
2150
  }
2022
2151
 
2023
2152
  /**
@@ -2029,7 +2158,7 @@
2029
2158
  * @returns {number}
2030
2159
  */
2031
2160
  function getHeight(bounds, overrides = {}) {
2032
- return has$2(overrides, 'height') ? overrides.height : bounds.height;
2161
+ return has$5(overrides, 'height') ? overrides.height : bounds.height;
2033
2162
  }
2034
2163
 
2035
2164
  function _mergeNamespaces$2(n, m) {
@@ -2057,15 +2186,15 @@
2057
2186
  * @return {T[]}
2058
2187
  */
2059
2188
 
2060
- const nativeToString$1 = Object.prototype.toString;
2061
- const nativeHasOwnProperty$1 = Object.prototype.hasOwnProperty;
2189
+ const nativeToString$4 = Object.prototype.toString;
2190
+ const nativeHasOwnProperty$3 = Object.prototype.hasOwnProperty;
2062
2191
 
2063
- function isUndefined$2(obj) {
2192
+ function isUndefined$4(obj) {
2064
2193
  return obj === undefined;
2065
2194
  }
2066
2195
 
2067
- function isArray$2(obj) {
2068
- return nativeToString$1.call(obj) === '[object Array]';
2196
+ function isArray$4(obj) {
2197
+ return nativeToString$4.call(obj) === '[object Array]';
2069
2198
  }
2070
2199
 
2071
2200
  /**
@@ -2076,8 +2205,8 @@
2076
2205
  *
2077
2206
  * @return {Boolean}
2078
2207
  */
2079
- function has$1(target, key) {
2080
- return nativeHasOwnProperty$1.call(target, key);
2208
+ function has$3(target, key) {
2209
+ return nativeHasOwnProperty$3.call(target, key);
2081
2210
  }
2082
2211
 
2083
2212
 
@@ -2091,20 +2220,20 @@
2091
2220
  *
2092
2221
  * @return {T} return result that stopped the iteration
2093
2222
  */
2094
- function forEach$1(collection, iterator) {
2223
+ function forEach$3(collection, iterator) {
2095
2224
 
2096
2225
  let val,
2097
2226
  result;
2098
2227
 
2099
- if (isUndefined$2(collection)) {
2228
+ if (isUndefined$4(collection)) {
2100
2229
  return;
2101
2230
  }
2102
2231
 
2103
- const convertKey = isArray$2(collection) ? toNum$1 : identity$1;
2232
+ const convertKey = isArray$4(collection) ? toNum$3 : identity$3;
2104
2233
 
2105
2234
  for (let key in collection) {
2106
2235
 
2107
- if (has$1(collection, key)) {
2236
+ if (has$3(collection, key)) {
2108
2237
  val = collection[key];
2109
2238
 
2110
2239
  result = iterator(val, convertKey(key));
@@ -2117,11 +2246,11 @@
2117
2246
  }
2118
2247
 
2119
2248
 
2120
- function identity$1(arg) {
2249
+ function identity$3(arg) {
2121
2250
  return arg;
2122
2251
  }
2123
2252
 
2124
- function toNum$1(arg) {
2253
+ function toNum$3(arg) {
2125
2254
  return Number(arg);
2126
2255
  }
2127
2256
 
@@ -2133,15 +2262,15 @@
2133
2262
  *
2134
2263
  * @return {Element} the element
2135
2264
  */
2136
- function assign$1(element, ...styleSources) {
2265
+ function assign$4(element, ...styleSources) {
2137
2266
  const target = element.style;
2138
2267
 
2139
- forEach$1(styleSources, function(style) {
2268
+ forEach$3(styleSources, function(style) {
2140
2269
  if (!style) {
2141
2270
  return;
2142
2271
  }
2143
2272
 
2144
- forEach$1(style, function(value, key) {
2273
+ forEach$3(style, function(value, key) {
2145
2274
  target[key] = value;
2146
2275
  });
2147
2276
  });
@@ -2371,7 +2500,7 @@
2371
2500
  // when delegating.
2372
2501
  var forceCaptureEvents$1 = [ 'focus', 'blur' ];
2373
2502
 
2374
- function bind$2(el, selector, type, fn, capture) {
2503
+ function bind$3(el, selector, type, fn, capture) {
2375
2504
  if (forceCaptureEvents$1.indexOf(type) !== -1) {
2376
2505
  capture = true;
2377
2506
  }
@@ -2403,7 +2532,7 @@
2403
2532
  }
2404
2533
 
2405
2534
  var delegate$1 = {
2406
- bind: bind$2,
2535
+ bind: bind$3,
2407
2536
  unbind: unbind$2
2408
2537
  };
2409
2538
 
@@ -2990,7 +3119,7 @@
2990
3119
 
2991
3120
  function drawCircle(parentGfx, width, height, offset, attrs = {}) {
2992
3121
 
2993
- if (isObject(offset)) {
3122
+ if (isObject$2(offset)) {
2994
3123
  attrs = offset;
2995
3124
  offset = 0;
2996
3125
  }
@@ -3016,7 +3145,7 @@
3016
3145
 
3017
3146
  function drawRect(parentGfx, width, height, r, offset, attrs) {
3018
3147
 
3019
- if (isObject(offset)) {
3148
+ if (isObject$2(offset)) {
3020
3149
  attrs = offset;
3021
3150
  offset = 0;
3022
3151
  }
@@ -3111,7 +3240,7 @@
3111
3240
  }
3112
3241
 
3113
3242
  function drawMarker(type, parentGfx, path, attrs) {
3114
- return drawPath(parentGfx, path, assign$2({ 'data-marker': type }, attrs));
3243
+ return drawPath(parentGfx, path, assign$6({ 'data-marker': type }, attrs));
3115
3244
  }
3116
3245
 
3117
3246
  function renderer(type) {
@@ -3658,7 +3787,7 @@
3658
3787
  taskMarkers.push('AdhocMarker');
3659
3788
 
3660
3789
  if (!subprocess) {
3661
- assign$2(attrs, { compensation: attrs.compensation - 18 });
3790
+ assign$6(attrs, { compensation: attrs.compensation - 18 });
3662
3791
  }
3663
3792
  }
3664
3793
 
@@ -3667,12 +3796,12 @@
3667
3796
 
3668
3797
  if (loopCharacteristics) {
3669
3798
 
3670
- assign$2(attrs, {
3799
+ assign$6(attrs, {
3671
3800
  compensation: attrs.compensation - 18,
3672
3801
  });
3673
3802
 
3674
3803
  if (taskMarkers.includes('AdhocMarker')) {
3675
- assign$2(attrs, {
3804
+ assign$6(attrs, {
3676
3805
  seq: -23,
3677
3806
  loop: -18,
3678
3807
  parallel: -24
@@ -3693,18 +3822,18 @@
3693
3822
  }
3694
3823
 
3695
3824
  if (taskMarkers.includes('CompensationMarker') && taskMarkers.length === 1) {
3696
- assign$2(attrs, {
3825
+ assign$6(attrs, {
3697
3826
  compensation: -8
3698
3827
  });
3699
3828
  }
3700
3829
 
3701
- forEach$2(taskMarkers, function(marker) {
3830
+ forEach$5(taskMarkers, function(marker) {
3702
3831
  renderTaskMarker(marker, parentGfx, element, attrs);
3703
3832
  });
3704
3833
  }
3705
3834
 
3706
3835
  function renderLabel(parentGfx, label, attrs = {}) {
3707
- attrs = assign$2({
3836
+ attrs = assign$6({
3708
3837
  size: {
3709
3838
  width: 100
3710
3839
  }
@@ -3750,7 +3879,7 @@
3750
3879
  return renderLabel(parentGfx, getLabel(element), {
3751
3880
  box: box,
3752
3881
  fitBox: true,
3753
- style: assign$2(
3882
+ style: assign$6(
3754
3883
  {},
3755
3884
  textRenderer.getExternalStyle(),
3756
3885
  {
@@ -5109,15 +5238,15 @@
5109
5238
  * @return {T[]}
5110
5239
  */
5111
5240
 
5112
- const nativeToString = Object.prototype.toString;
5113
- const nativeHasOwnProperty = Object.prototype.hasOwnProperty;
5241
+ const nativeToString$3 = Object.prototype.toString;
5242
+ const nativeHasOwnProperty$2 = Object.prototype.hasOwnProperty;
5114
5243
 
5115
- function isUndefined$1(obj) {
5244
+ function isUndefined$3(obj) {
5116
5245
  return obj === undefined;
5117
5246
  }
5118
5247
 
5119
- function isArray$1(obj) {
5120
- return nativeToString.call(obj) === '[object Array]';
5248
+ function isArray$3(obj) {
5249
+ return nativeToString$3.call(obj) === '[object Array]';
5121
5250
  }
5122
5251
 
5123
5252
  /**
@@ -5128,8 +5257,8 @@
5128
5257
  *
5129
5258
  * @return {Boolean}
5130
5259
  */
5131
- function has(target, key) {
5132
- return nativeHasOwnProperty.call(target, key);
5260
+ function has$2(target, key) {
5261
+ return nativeHasOwnProperty$2.call(target, key);
5133
5262
  }
5134
5263
 
5135
5264
 
@@ -5143,20 +5272,20 @@
5143
5272
  *
5144
5273
  * @return {T} return result that stopped the iteration
5145
5274
  */
5146
- function forEach(collection, iterator) {
5275
+ function forEach$2(collection, iterator) {
5147
5276
 
5148
5277
  let val,
5149
5278
  result;
5150
5279
 
5151
- if (isUndefined$1(collection)) {
5280
+ if (isUndefined$3(collection)) {
5152
5281
  return;
5153
5282
  }
5154
5283
 
5155
- const convertKey = isArray$1(collection) ? toNum : identity;
5284
+ const convertKey = isArray$3(collection) ? toNum$2 : identity$2;
5156
5285
 
5157
5286
  for (let key in collection) {
5158
5287
 
5159
- if (has(collection, key)) {
5288
+ if (has$2(collection, key)) {
5160
5289
  val = collection[key];
5161
5290
 
5162
5291
  result = iterator(val, convertKey(key));
@@ -5169,11 +5298,11 @@
5169
5298
  }
5170
5299
 
5171
5300
 
5172
- function identity(arg) {
5301
+ function identity$2(arg) {
5173
5302
  return arg;
5174
5303
  }
5175
5304
 
5176
- function toNum(arg) {
5305
+ function toNum$2(arg) {
5177
5306
  return Number(arg);
5178
5307
  }
5179
5308
 
@@ -5185,15 +5314,15 @@
5185
5314
  *
5186
5315
  * @return {Element} the element
5187
5316
  */
5188
- function assign(element, ...styleSources) {
5317
+ function assign$3(element, ...styleSources) {
5189
5318
  const target = element.style;
5190
5319
 
5191
- forEach(styleSources, function(style) {
5320
+ forEach$2(styleSources, function(style) {
5192
5321
  if (!style) {
5193
5322
  return;
5194
5323
  }
5195
5324
 
5196
- forEach(style, function(value, key) {
5325
+ forEach$2(style, function(value, key) {
5197
5326
  target[key] = value;
5198
5327
  });
5199
5328
  });
@@ -5470,7 +5599,7 @@
5470
5599
  // when delegating.
5471
5600
  var forceCaptureEvents = [ 'focus', 'blur' ];
5472
5601
 
5473
- function bind(el, selector, type, fn, capture) {
5602
+ function bind$2(el, selector, type, fn, capture) {
5474
5603
  if (forceCaptureEvents.indexOf(type) !== -1) {
5475
5604
  capture = true;
5476
5605
  }
@@ -5502,7 +5631,7 @@
5502
5631
  }
5503
5632
 
5504
5633
  var delegate = {
5505
- bind,
5634
+ bind: bind$2,
5506
5635
  unbind
5507
5636
  };
5508
5637
 
@@ -5704,8 +5833,8 @@
5704
5833
  */
5705
5834
  function parsePadding(padding) {
5706
5835
 
5707
- if (isObject(padding)) {
5708
- return assign$2({ top: 0, left: 0, right: 0, bottom: 0 }, padding);
5836
+ if (isObject$1(padding)) {
5837
+ return assign$5({ top: 0, left: 0, right: 0, bottom: 0 }, padding);
5709
5838
  } else {
5710
5839
  return {
5711
5840
  top: padding,
@@ -5899,7 +6028,7 @@
5899
6028
  id: 'helper-svg'
5900
6029
  });
5901
6030
 
5902
- assign(helperSvg, {
6031
+ assign$3(helperSvg, {
5903
6032
  visibility: 'hidden',
5904
6033
  position: 'fixed',
5905
6034
  width: 0,
@@ -5920,7 +6049,7 @@
5920
6049
  */
5921
6050
  function Text(config) {
5922
6051
 
5923
- this._config = assign$2({}, {
6052
+ this._config = assign$5({}, {
5924
6053
  size: DEFAULT_LABEL_SIZE,
5925
6054
  padding: DEFAULT_BOX_PADDING,
5926
6055
  style: {},
@@ -5964,8 +6093,8 @@
5964
6093
  * } }
5965
6094
  */
5966
6095
  Text.prototype.layoutText = function(text, options) {
5967
- var box = assign$2({}, this._config.size, options.box),
5968
- style = assign$2({}, this._config.style, options.style),
6096
+ var box = assign$5({}, this._config.size, options.box),
6097
+ style = assign$5({}, this._config.style, options.style),
5969
6098
  align = parseAlign(options.align || this._config.align),
5970
6099
  padding = parsePadding(options.padding !== undefined ? options.padding : this._config.padding),
5971
6100
  fitBox = options.fitBox || false;
@@ -6021,7 +6150,7 @@
6021
6150
 
6022
6151
  // layout each line taking into account that parent
6023
6152
  // shape might resize to fit text size
6024
- forEach$2(layouted, function(line) {
6153
+ forEach$4(layouted, function(line) {
6025
6154
 
6026
6155
  var x;
6027
6156
 
@@ -6103,7 +6232,7 @@
6103
6232
  */
6104
6233
  function TextRenderer(config) {
6105
6234
 
6106
- var defaultStyle = assign$2({
6235
+ var defaultStyle = assign$6({
6107
6236
  fontFamily: 'Arial, sans-serif',
6108
6237
  fontSize: DEFAULT_FONT_SIZE,
6109
6238
  fontWeight: 'normal',
@@ -6112,7 +6241,7 @@
6112
6241
 
6113
6242
  var fontSize = parseInt(defaultStyle.fontSize, 10) - 1;
6114
6243
 
6115
- var externalStyle = assign$2({}, defaultStyle, {
6244
+ var externalStyle = assign$6({}, defaultStyle, {
6116
6245
  fontSize: fontSize
6117
6246
  }, config && config.externalStyle || {});
6118
6247
 
@@ -6909,7 +7038,7 @@
6909
7038
  * @return {Object}
6910
7039
  */
6911
7040
  function elementData(semantic, di, attrs) {
6912
- return assign$2({
7041
+ return assign$6({
6913
7042
  id: semantic.id,
6914
7043
  type: semantic.$type,
6915
7044
  businessObject: semantic,
@@ -7251,7 +7380,7 @@
7251
7380
  function getBBox(elements, stopRecursion) {
7252
7381
 
7253
7382
  stopRecursion = !!stopRecursion;
7254
- if (!isArray$3(elements)) {
7383
+ if (!isArray$5(elements)) {
7255
7384
  elements = [ elements ];
7256
7385
  }
7257
7386
 
@@ -7260,7 +7389,7 @@
7260
7389
  maxX,
7261
7390
  maxY;
7262
7391
 
7263
- forEach$2(elements, function(element) {
7392
+ forEach$4(elements, function(element) {
7264
7393
 
7265
7394
  // If element is a connection the bbox must be computed first
7266
7395
  var bbox = element;
@@ -7488,7 +7617,7 @@
7488
7617
  /**
7489
7618
  * @type {OverlaysConfigDefault}
7490
7619
  */
7491
- this._overlayDefaults = assign$2({
7620
+ this._overlayDefaults = assign$5({
7492
7621
 
7493
7622
  // no show constraints
7494
7623
  show: null,
@@ -7550,11 +7679,11 @@
7550
7679
  */
7551
7680
  Overlays.prototype.get = function(search) {
7552
7681
 
7553
- if (isString(search)) {
7682
+ if (isString$3(search)) {
7554
7683
  search = { id: search };
7555
7684
  }
7556
7685
 
7557
- if (isString(search.element)) {
7686
+ if (isString$3(search.element)) {
7558
7687
  search.element = this._elementRegistry.get(search.element);
7559
7688
  }
7560
7689
 
@@ -7563,12 +7692,12 @@
7563
7692
 
7564
7693
  // return a list of overlays when searching by element (+type)
7565
7694
  if (container) {
7566
- return search.type ? filter(container.overlays, matchPattern({ type: search.type })) : container.overlays.slice();
7695
+ return search.type ? filter$1(container.overlays, matchPattern({ type: search.type })) : container.overlays.slice();
7567
7696
  } else {
7568
7697
  return [];
7569
7698
  }
7570
7699
  } else if (search.type) {
7571
- return filter(this._overlays, matchPattern({ type: search.type }));
7700
+ return filter$1(this._overlays, matchPattern({ type: search.type }));
7572
7701
  } else {
7573
7702
 
7574
7703
  // return single element when searching by id
@@ -7587,7 +7716,7 @@
7587
7716
  */
7588
7717
  Overlays.prototype.add = function(element, type, overlay) {
7589
7718
 
7590
- if (isObject(type)) {
7719
+ if (isObject$1(type)) {
7591
7720
  overlay = type;
7592
7721
  type = null;
7593
7722
  }
@@ -7610,7 +7739,7 @@
7610
7739
 
7611
7740
  var id = this._ids.next();
7612
7741
 
7613
- overlay = assign$2({}, this._overlayDefaults, overlay, {
7742
+ overlay = assign$5({}, this._overlayDefaults, overlay, {
7614
7743
  id: id,
7615
7744
  type: type,
7616
7745
  element: element,
@@ -7634,13 +7763,13 @@
7634
7763
 
7635
7764
  var overlays = this.get(filter) || [];
7636
7765
 
7637
- if (!isArray$3(overlays)) {
7766
+ if (!isArray$5(overlays)) {
7638
7767
  overlays = [ overlays ];
7639
7768
  }
7640
7769
 
7641
7770
  var self = this;
7642
7771
 
7643
- forEach$2(overlays, function(overlay) {
7772
+ forEach$4(overlays, function(overlay) {
7644
7773
 
7645
7774
  var container = self._getOverlayContainer(overlay.element, true);
7646
7775
 
@@ -7766,7 +7895,7 @@
7766
7895
 
7767
7896
  Overlays.prototype._createOverlayContainer = function(element) {
7768
7897
  var html = domify$1('<div class="djs-overlays" />');
7769
- assign(html, { position: 'absolute' });
7898
+ assign$3(html, { position: 'absolute' });
7770
7899
 
7771
7900
  this._overlayRoot.appendChild(html);
7772
7901
 
@@ -7803,7 +7932,7 @@
7803
7932
 
7804
7933
 
7805
7934
  Overlays.prototype._getOverlayContainer = function(element, raw) {
7806
- var container = find(this._overlayContainers, function(c) {
7935
+ var container = find$1(this._overlayContainers, function(c) {
7807
7936
  return c.element === element;
7808
7937
  });
7809
7938
 
@@ -7831,14 +7960,14 @@
7831
7960
 
7832
7961
  // create proper html elements from
7833
7962
  // overlay HTML strings
7834
- if (isString(html)) {
7963
+ if (isString$3(html)) {
7835
7964
  html = domify$1(html);
7836
7965
  }
7837
7966
 
7838
7967
  overlayContainer = this._getOverlayContainer(element);
7839
7968
 
7840
7969
  htmlContainer = domify$1('<div class="djs-overlay" data-overlay-id="' + id + '">');
7841
- assign(htmlContainer, { position: 'absolute' });
7970
+ assign$3(htmlContainer, { position: 'absolute' });
7842
7971
 
7843
7972
  htmlContainer.appendChild(html);
7844
7973
 
@@ -7876,8 +8005,8 @@
7876
8005
  visible = false;
7877
8006
  } else if (show) {
7878
8007
  if (
7879
- (isDefined(minZoom) && minZoom > viewbox.scale) ||
7880
- (isDefined(maxZoom) && maxZoom < viewbox.scale)
8008
+ (isDefined$1(minZoom) && minZoom > viewbox.scale) ||
8009
+ (isDefined$1(maxZoom) && maxZoom < viewbox.scale)
7881
8010
  ) {
7882
8011
  visible = false;
7883
8012
  }
@@ -7907,16 +8036,16 @@
7907
8036
  maxScale = shouldScale.max;
7908
8037
  }
7909
8038
 
7910
- if (isDefined(minScale) && viewbox.scale < minScale) {
8039
+ if (isDefined$1(minScale) && viewbox.scale < minScale) {
7911
8040
  scale = (1 / viewbox.scale || 1) * minScale;
7912
8041
  }
7913
8042
 
7914
- if (isDefined(maxScale) && viewbox.scale > maxScale) {
8043
+ if (isDefined$1(maxScale) && viewbox.scale > maxScale) {
7915
8044
  scale = (1 / viewbox.scale || 1) * maxScale;
7916
8045
  }
7917
8046
  }
7918
8047
 
7919
- if (isDefined(scale)) {
8048
+ if (isDefined$1(scale)) {
7920
8049
  transform = 'scale(' + scale + ',' + scale + ')';
7921
8050
  }
7922
8051
 
@@ -7928,7 +8057,7 @@
7928
8057
 
7929
8058
  var self = this;
7930
8059
 
7931
- forEach$2(this._overlays, function(overlay) {
8060
+ forEach$4(this._overlays, function(overlay) {
7932
8061
  self._updateOverlayVisibilty(overlay, viewbox);
7933
8062
  });
7934
8063
  };
@@ -7965,7 +8094,7 @@
7965
8094
  var element = e.element;
7966
8095
  var overlays = self.get({ element: element });
7967
8096
 
7968
- forEach$2(overlays, function(o) {
8097
+ forEach$4(overlays, function(o) {
7969
8098
  self.remove(o.id);
7970
8099
  });
7971
8100
 
@@ -7989,7 +8118,7 @@
7989
8118
  var container = self._getOverlayContainer(element, true);
7990
8119
 
7991
8120
  if (container) {
7992
- forEach$2(container.overlays, function(overlay) {
8121
+ forEach$4(container.overlays, function(overlay) {
7993
8122
  self._updateOverlay(overlay);
7994
8123
  });
7995
8124
 
@@ -8026,7 +8155,7 @@
8026
8155
  '<div class="djs-overlay-container" />'
8027
8156
  );
8028
8157
 
8029
- assign(root, {
8158
+ assign$3(root, {
8030
8159
  position: 'absolute',
8031
8160
  width: 0,
8032
8161
  height: 0
@@ -8038,7 +8167,7 @@
8038
8167
  }
8039
8168
 
8040
8169
  function setPosition(el, x, y) {
8041
- assign(el, { left: x + 'px', top: y + 'px' });
8170
+ assign$3(el, { left: x + 'px', top: y + 'px' });
8042
8171
  }
8043
8172
 
8044
8173
  /**
@@ -8212,7 +8341,7 @@
8212
8341
  */
8213
8342
  CommandInterceptor.prototype.on = function(events, hook, priority, handlerFn, unwrap, that) {
8214
8343
 
8215
- if (isFunction(hook) || isNumber(hook)) {
8344
+ if (isFunction$1(hook) || isNumber(hook)) {
8216
8345
  that = unwrap;
8217
8346
  unwrap = handlerFn;
8218
8347
  handlerFn = priority;
@@ -8220,29 +8349,29 @@
8220
8349
  hook = null;
8221
8350
  }
8222
8351
 
8223
- if (isFunction(priority)) {
8352
+ if (isFunction$1(priority)) {
8224
8353
  that = unwrap;
8225
8354
  unwrap = handlerFn;
8226
8355
  handlerFn = priority;
8227
8356
  priority = DEFAULT_PRIORITY$2;
8228
8357
  }
8229
8358
 
8230
- if (isObject(unwrap)) {
8359
+ if (isObject$1(unwrap)) {
8231
8360
  that = unwrap;
8232
8361
  unwrap = false;
8233
8362
  }
8234
8363
 
8235
- if (!isFunction(handlerFn)) {
8364
+ if (!isFunction$1(handlerFn)) {
8236
8365
  throw new Error('handlerFn must be a function');
8237
8366
  }
8238
8367
 
8239
- if (!isArray$3(events)) {
8368
+ if (!isArray$5(events)) {
8240
8369
  events = [ events ];
8241
8370
  }
8242
8371
 
8243
8372
  var eventBus = this._eventBus;
8244
8373
 
8245
- forEach$2(events, function(event) {
8374
+ forEach$4(events, function(event) {
8246
8375
 
8247
8376
  // concat commandStack(.event)?(.hook)?
8248
8377
  var fullEvent = [ 'commandStack', event, hook ].filter(function(e) { return e; }).join('.');
@@ -8376,7 +8505,7 @@
8376
8505
  */
8377
8506
  const hookFn = function(events, priority, handlerFn, unwrap, that) {
8378
8507
 
8379
- if (isFunction(events) || isNumber(events)) {
8508
+ if (isFunction$1(events) || isNumber(events)) {
8380
8509
  that = unwrap;
8381
8510
  unwrap = handlerFn;
8382
8511
  handlerFn = priority;
@@ -8525,7 +8654,7 @@
8525
8654
  var shape = event.element,
8526
8655
  businessObject = getBusinessObject(shape);
8527
8656
 
8528
- var isPresent = find(businessObjectParents, function(element) {
8657
+ var isPresent = find$2(businessObjectParents, function(element) {
8529
8658
  return element === businessObject;
8530
8659
  });
8531
8660
 
@@ -9491,13 +9620,13 @@
9491
9620
  }
9492
9621
 
9493
9622
  function registerEvents(svg) {
9494
- forEach$2(bindings, function(val, key) {
9623
+ forEach$4(bindings, function(val, key) {
9495
9624
  registerEvent(svg, key, val);
9496
9625
  });
9497
9626
  }
9498
9627
 
9499
9628
  function unregisterEvents(svg) {
9500
- forEach$2(bindings, function(val, key) {
9629
+ forEach$4(bindings, function(val, key) {
9501
9630
  unregisterEvent(svg, key, val);
9502
9631
  });
9503
9632
  }
@@ -9568,7 +9697,7 @@
9568
9697
 
9569
9698
  function createHitStyle(classNames, attrs) {
9570
9699
 
9571
- attrs = assign$2({
9700
+ attrs = assign$5({
9572
9701
  stroke: 'white',
9573
9702
  strokeWidth: 15
9574
9703
  }, attrs || {});
@@ -9607,7 +9736,7 @@
9607
9736
  this.removeHits = function(gfx) {
9608
9737
  var hits = all('.djs-hit', gfx);
9609
9738
 
9610
- forEach$2(hits, remove$3);
9739
+ forEach$4(hits, remove$3);
9611
9740
  };
9612
9741
 
9613
9742
  /**
@@ -9666,7 +9795,7 @@
9666
9795
  */
9667
9796
  this.createBoxHit = function(gfx, type, attrs) {
9668
9797
 
9669
- attrs = assign$2({
9798
+ attrs = assign$5({
9670
9799
  x: 0,
9671
9800
  y: 0
9672
9801
  }, attrs);
@@ -9901,7 +10030,7 @@
9901
10030
  var selectedElements = this._selectedElements,
9902
10031
  oldSelection = selectedElements.slice();
9903
10032
 
9904
- if (!isArray$3(elements)) {
10033
+ if (!isArray$5(elements)) {
9905
10034
  elements = elements ? [ elements ] : [];
9906
10035
  }
9907
10036
 
@@ -9918,7 +10047,7 @@
9918
10047
  // selection may be cleared by passing an empty array or null
9919
10048
  // to the method
9920
10049
  if (add) {
9921
- forEach$2(elements, function(element) {
10050
+ forEach$4(elements, function(element) {
9922
10051
  if (selectedElements.indexOf(element) !== -1) {
9923
10052
 
9924
10053
  // already selected
@@ -9985,13 +10114,13 @@
9985
10114
  var oldSelection = event.oldSelection,
9986
10115
  newSelection = event.newSelection;
9987
10116
 
9988
- forEach$2(oldSelection, function(e) {
10117
+ forEach$4(oldSelection, function(e) {
9989
10118
  if (newSelection.indexOf(e) === -1) {
9990
10119
  deselect(e);
9991
10120
  }
9992
10121
  });
9993
10122
 
9994
- forEach$2(newSelection, function(e) {
10123
+ forEach$4(newSelection, function(e) {
9995
10124
  if (oldSelection.indexOf(e) === -1) {
9996
10125
  select(e);
9997
10126
  }
@@ -10034,7 +10163,7 @@
10034
10163
  return;
10035
10164
  }
10036
10165
 
10037
- if (isArray$3(autoSelect)) {
10166
+ if (isArray$5(autoSelect)) {
10038
10167
  selection.select(autoSelect);
10039
10168
  } else {
10040
10169
 
@@ -10061,7 +10190,7 @@
10061
10190
  var shape = elementRegistry.get(event.context.shape.id);
10062
10191
 
10063
10192
  // Always select main shape on move
10064
- var isSelected = find(previousSelection, function(selectedShape) {
10193
+ var isSelected = find$1(previousSelection, function(selectedShape) {
10065
10194
  return shape.id === selectedShape.id;
10066
10195
  });
10067
10196
 
@@ -10153,7 +10282,7 @@
10153
10282
  *
10154
10283
  * @return {boolean}
10155
10284
  */
10156
- function isArray(obj) {
10285
+ function isArray$2(obj) {
10157
10286
  return Array.isArray(obj);
10158
10287
  }
10159
10288
 
@@ -10180,7 +10309,7 @@
10180
10309
  */
10181
10310
  function annotate(...args) {
10182
10311
 
10183
- if (args.length === 1 && isArray(args[0])) {
10312
+ if (args.length === 1 && isArray$2(args[0])) {
10184
10313
  args = args[0];
10185
10314
  }
10186
10315
 
@@ -10325,7 +10454,7 @@
10325
10454
  }
10326
10455
 
10327
10456
  if (typeof fn !== 'function') {
10328
- if (isArray(fn)) {
10457
+ if (isArray$2(fn)) {
10329
10458
  fn = annotate(fn.slice());
10330
10459
  } else {
10331
10460
  throw error(`Cannot invoke "${ fn }". Expected a function!`);
@@ -10624,7 +10753,7 @@
10624
10753
  // helpers ///////////////
10625
10754
 
10626
10755
  function arrayUnwrap(type, value) {
10627
- if (type !== 'value' && isArray(value)) {
10756
+ if (type !== 'value' && isArray$2(value)) {
10628
10757
  value = annotate(value.slice());
10629
10758
  }
10630
10759
 
@@ -10679,9 +10808,9 @@
10679
10808
  });
10680
10809
 
10681
10810
  if (isFrameElement(element)) {
10682
- attr$1(rect, assign$2({}, this.FRAME_STYLE, attrs || {}));
10811
+ attr$1(rect, assign$5({}, this.FRAME_STYLE, attrs || {}));
10683
10812
  } else {
10684
- attr$1(rect, assign$2({}, this.SHAPE_STYLE, attrs || {}));
10813
+ attr$1(rect, assign$5({}, this.SHAPE_STYLE, attrs || {}));
10685
10814
  }
10686
10815
 
10687
10816
  append(visuals, rect);
@@ -10694,7 +10823,7 @@
10694
10823
  */
10695
10824
  DefaultRenderer.prototype.drawConnection = function drawConnection(visuals, connection, attrs) {
10696
10825
 
10697
- var line = createLine(connection.waypoints, assign$2({}, this.CONNECTION_STYLE, attrs || {}));
10826
+ var line = createLine(connection.waypoints, assign$5({}, this.CONNECTION_STYLE, attrs || {}));
10698
10827
  append(visuals, line);
10699
10828
 
10700
10829
  return line;
@@ -10776,7 +10905,7 @@
10776
10905
  this.cls = function(className, traits, additionalAttrs) {
10777
10906
  var attrs = this.style(traits, additionalAttrs);
10778
10907
 
10779
- return assign$2(attrs, { 'class': className });
10908
+ return assign$5(attrs, { 'class': className });
10780
10909
  };
10781
10910
 
10782
10911
  /**
@@ -10790,16 +10919,16 @@
10790
10919
  */
10791
10920
  this.style = function(traits, additionalAttrs) {
10792
10921
 
10793
- if (!isArray$3(traits) && !additionalAttrs) {
10922
+ if (!isArray$5(traits) && !additionalAttrs) {
10794
10923
  additionalAttrs = traits;
10795
10924
  traits = [];
10796
10925
  }
10797
10926
 
10798
10927
  var attrs = reduce(traits, function(attrs, t) {
10799
- return assign$2(attrs, defaultTraits[t] || {});
10928
+ return assign$5(attrs, defaultTraits[t] || {});
10800
10929
  }, {});
10801
10930
 
10802
- return additionalAttrs ? assign$2(attrs, additionalAttrs) : attrs;
10931
+ return additionalAttrs ? assign$5(attrs, additionalAttrs) : attrs;
10803
10932
  };
10804
10933
 
10805
10934
 
@@ -10814,12 +10943,12 @@
10814
10943
  * @return {Object} the style definition
10815
10944
  */
10816
10945
  this.computeStyle = function(custom, traits, defaultStyles) {
10817
- if (!isArray$3(traits)) {
10946
+ if (!isArray$5(traits)) {
10818
10947
  defaultStyles = traits;
10819
10948
  traits = [];
10820
10949
  }
10821
10950
 
10822
- return self.style(traits || [], assign$2({}, defaultStyles, custom || {}));
10951
+ return self.style(traits || [], assign$5({}, defaultStyles, custom || {}));
10823
10952
  };
10824
10953
  }
10825
10954
 
@@ -10974,7 +11103,7 @@
10974
11103
  */
10975
11104
  function createContainer(options) {
10976
11105
 
10977
- options = assign$2({}, { width: '100%', height: '100%' }, options);
11106
+ options = assign$5({}, { width: '100%', height: '100%' }, options);
10978
11107
 
10979
11108
  const container = options.container || document.body;
10980
11109
 
@@ -10984,7 +11113,7 @@
10984
11113
  const parent = document.createElement('div');
10985
11114
  parent.setAttribute('class', 'djs-container djs-parent');
10986
11115
 
10987
- assign(parent, {
11116
+ assign$3(parent, {
10988
11117
  position: 'relative',
10989
11118
  overflow: 'hidden',
10990
11119
  width: ensurePx(options.width),
@@ -11127,7 +11256,7 @@
11127
11256
  // debounce canvas.viewbox.changed events when deferUpdate is set
11128
11257
  // to help with potential performance issues
11129
11258
  if (config.deferUpdate) {
11130
- this._viewboxChanged = debounce(bind$3(this._viewboxChanged, this), 300);
11259
+ this._viewboxChanged = debounce(bind$4(this._viewboxChanged, this), 300);
11131
11260
  }
11132
11261
 
11133
11262
  eventBus.on('diagram.init', () => {
@@ -11469,7 +11598,7 @@
11469
11598
  };
11470
11599
 
11471
11600
  Canvas.prototype._findPlaneForRoot = function(rootElement) {
11472
- return find(this._planes, function(plane) {
11601
+ return find$1(this._planes, function(plane) {
11473
11602
  return plane.rootElement === rootElement;
11474
11603
  });
11475
11604
  };
@@ -11504,7 +11633,7 @@
11504
11633
  return;
11505
11634
  }
11506
11635
 
11507
- forEach$2([ container.gfx, container.secondaryGfx ], function(gfx) {
11636
+ forEach$4([ container.gfx, container.secondaryGfx ], function(gfx) {
11508
11637
  if (gfx) {
11509
11638
 
11510
11639
  // invoke either addClass or removeClass based on mode
@@ -12162,7 +12291,7 @@
12162
12291
 
12163
12292
  if (delta) {
12164
12293
  this._changeViewbox(function() {
12165
- delta = assign$2({ dx: 0, dy: 0 }, delta || {});
12294
+ delta = assign$5({ dx: 0, dy: 0 }, delta || {});
12166
12295
 
12167
12296
  matrix = this._svg.createSVGMatrix().translate(delta.dx, delta.dy).multiply(matrix);
12168
12297
 
@@ -12361,7 +12490,7 @@
12361
12490
  const currentScale = currentMatrix.a;
12362
12491
 
12363
12492
  if (center) {
12364
- centerPoint = assign$2(point, center);
12493
+ centerPoint = assign$5(point, center);
12365
12494
 
12366
12495
  // revert applied viewport transformations
12367
12496
  originalPoint = centerPoint.matrixTransform(currentMatrix.inverse());
@@ -13301,7 +13430,7 @@
13301
13430
  if (!Type) {
13302
13431
  throw new Error('unknown type: <' + type + '>');
13303
13432
  }
13304
- return assign$2(new Type(), attrs);
13433
+ return assign$5(new Type(), attrs);
13305
13434
  }
13306
13435
 
13307
13436
  /**
@@ -13401,7 +13530,7 @@
13401
13530
  */
13402
13531
  ElementFactory.prototype.create = function(type, attrs) {
13403
13532
 
13404
- attrs = assign$2({}, attrs || {});
13533
+ attrs = assign$5({}, attrs || {});
13405
13534
 
13406
13535
  if (!attrs.id) {
13407
13536
  attrs.id = type + '_' + (this._uid++);
@@ -13579,9 +13708,9 @@
13579
13708
  */
13580
13709
  EventBus.prototype.on = function(events, priority, callback, that) {
13581
13710
 
13582
- events = isArray$3(events) ? events : [ events ];
13711
+ events = isArray$5(events) ? events : [ events ];
13583
13712
 
13584
- if (isFunction(priority)) {
13713
+ if (isFunction$1(priority)) {
13585
13714
  that = callback;
13586
13715
  callback = priority;
13587
13716
  priority = DEFAULT_PRIORITY$1;
@@ -13594,7 +13723,7 @@
13594
13723
  var actualCallback = callback;
13595
13724
 
13596
13725
  if (that) {
13597
- actualCallback = bind$3(callback, that);
13726
+ actualCallback = bind$4(callback, that);
13598
13727
 
13599
13728
  // make sure we remember and are able to remove
13600
13729
  // bound callbacks via {@link #off} using the original
@@ -13638,7 +13767,7 @@
13638
13767
  EventBus.prototype.once = function(events, priority, callback, that) {
13639
13768
  var self = this;
13640
13769
 
13641
- if (isFunction(priority)) {
13770
+ if (isFunction$1(priority)) {
13642
13771
  that = callback;
13643
13772
  callback = priority;
13644
13773
  priority = DEFAULT_PRIORITY$1;
@@ -13677,7 +13806,7 @@
13677
13806
  */
13678
13807
  EventBus.prototype.off = function(events, callback) {
13679
13808
 
13680
- events = isArray$3(events) ? events : [ events ];
13809
+ events = isArray$5(events) ? events : [ events ];
13681
13810
 
13682
13811
  var self = this;
13683
13812
 
@@ -14002,7 +14131,7 @@
14002
14131
  };
14003
14132
 
14004
14133
  InternalEvent.prototype.init = function(data) {
14005
- assign$2(this, data || {});
14134
+ assign$5(this, data || {});
14006
14135
  };
14007
14136
 
14008
14137
 
@@ -14201,7 +14330,7 @@
14201
14330
 
14202
14331
  // update all parents of changed and reorganized their children
14203
14332
  // in the correct order (as indicated in our model)
14204
- forEach$2(parents, function(parent) {
14333
+ forEach$4(parents, function(parent) {
14205
14334
 
14206
14335
  var children = parent.children;
14207
14336
 
@@ -14211,7 +14340,7 @@
14211
14340
 
14212
14341
  var childrenGfx = self._getChildrenContainer(parent);
14213
14342
 
14214
- forEach$2(children.slice().reverse(), function(child) {
14343
+ forEach$4(children.slice().reverse(), function(child) {
14215
14344
  var childGfx = elementRegistry.getGraphics(child);
14216
14345
 
14217
14346
  prependTo(childGfx.parentNode, childrenGfx);
@@ -14552,34 +14681,259 @@
14552
14681
  * @return {T}
14553
14682
  */
14554
14683
  /**
14555
- * Invoke the given function, injecting dependencies provided in
14556
- * array notation. Return the result.
14684
+ * Invoke the given function, injecting dependencies provided in
14685
+ * array notation. Return the result.
14686
+ *
14687
+ * @template T
14688
+ *
14689
+ * @param {ArrayFunc<T>} func function to be invoked
14690
+ * @param {InjectionContext} [context] context of the invocation
14691
+ * @param {LocalsMap} [locals] locals provided
14692
+ *
14693
+ * @return {T}
14694
+ */
14695
+ Diagram.prototype.invoke = function(func, context, locals) {
14696
+ return this._injector.invoke(func, context, locals);
14697
+ };
14698
+
14699
+ /**
14700
+ * Destroys the diagram
14701
+ */
14702
+ Diagram.prototype.destroy = function() {
14703
+ this.get('eventBus').fire('diagram.destroy');
14704
+ };
14705
+
14706
+ /**
14707
+ * Clear the diagram, removing all contents.
14708
+ */
14709
+ Diagram.prototype.clear = function() {
14710
+ this.get('eventBus').fire('diagram.clear');
14711
+ };
14712
+
14713
+ /**
14714
+ * Flatten array, one level deep.
14715
+ *
14716
+ * @template T
14717
+ *
14718
+ * @param {T[][] | T[] | null} [arr]
14719
+ *
14720
+ * @return {T[]}
14721
+ */
14722
+
14723
+ const nativeToString$2 = Object.prototype.toString;
14724
+
14725
+ function isString$2(obj) {
14726
+ return nativeToString$2.call(obj) === '[object String]';
14727
+ }
14728
+
14729
+ /**
14730
+ * Convenience wrapper for `Object.assign`.
14731
+ *
14732
+ * @param {Object} target
14733
+ * @param {...Object} others
14734
+ *
14735
+ * @return {Object} the target
14736
+ */
14737
+ function assign$2(target, ...others) {
14738
+ return Object.assign(target, ...others);
14739
+ }
14740
+
14741
+ /**
14742
+ * Flatten array, one level deep.
14743
+ *
14744
+ * @template T
14745
+ *
14746
+ * @param {T[][] | T[] | null} [arr]
14747
+ *
14748
+ * @return {T[]}
14749
+ */
14750
+
14751
+ const nativeToString$1 = Object.prototype.toString;
14752
+ const nativeHasOwnProperty$1 = Object.prototype.hasOwnProperty;
14753
+
14754
+ function isUndefined$2(obj) {
14755
+ return obj === undefined;
14756
+ }
14757
+
14758
+ function isDefined(obj) {
14759
+ return obj !== undefined;
14760
+ }
14761
+
14762
+ function isNil$1(obj) {
14763
+ return obj == null;
14764
+ }
14765
+
14766
+ function isArray$1(obj) {
14767
+ return nativeToString$1.call(obj) === '[object Array]';
14768
+ }
14769
+
14770
+ function isObject(obj) {
14771
+ return nativeToString$1.call(obj) === '[object Object]';
14772
+ }
14773
+
14774
+ function isString$1(obj) {
14775
+ return nativeToString$1.call(obj) === '[object String]';
14776
+ }
14777
+
14778
+ /**
14779
+ * Return true, if target owns a property with the given key.
14780
+ *
14781
+ * @param {Object} target
14782
+ * @param {String} key
14783
+ *
14784
+ * @return {Boolean}
14785
+ */
14786
+ function has$1(target, key) {
14787
+ return !isNil$1(target) && nativeHasOwnProperty$1.call(target, key);
14788
+ }
14789
+
14790
+
14791
+ /**
14792
+ * Iterate over collection; returning something
14793
+ * (non-undefined) will stop iteration.
14794
+ *
14795
+ * @template T
14796
+ * @param {Collection<T>} collection
14797
+ * @param { ((item: T, idx: number) => (boolean|void)) | ((item: T, key: string) => (boolean|void)) } iterator
14798
+ *
14799
+ * @return {T} return result that stopped the iteration
14800
+ */
14801
+ function forEach$1(collection, iterator) {
14802
+
14803
+ let val,
14804
+ result;
14805
+
14806
+ if (isUndefined$2(collection)) {
14807
+ return;
14808
+ }
14809
+
14810
+ const convertKey = isArray$1(collection) ? toNum$1 : identity$1;
14811
+
14812
+ for (let key in collection) {
14813
+
14814
+ if (has$1(collection, key)) {
14815
+ val = collection[key];
14816
+
14817
+ result = iterator(val, convertKey(key));
14818
+
14819
+ if (result === false) {
14820
+ return val;
14821
+ }
14822
+ }
14823
+ }
14824
+ }
14825
+
14826
+
14827
+ function identity$1(arg) {
14828
+ return arg;
14829
+ }
14830
+
14831
+ function toNum$1(arg) {
14832
+ return Number(arg);
14833
+ }
14834
+
14835
+ /**
14836
+ * Bind function against target <this>.
14837
+ *
14838
+ * @param {Function} fn
14839
+ * @param {Object} target
14840
+ *
14841
+ * @return {Function} bound function
14842
+ */
14843
+ function bind(fn, target) {
14844
+ return fn.bind(target);
14845
+ }
14846
+
14847
+ /**
14848
+ * Convenience wrapper for `Object.assign`.
14849
+ *
14850
+ * @param {Object} target
14851
+ * @param {...Object} others
14852
+ *
14853
+ * @return {Object} the target
14854
+ */
14855
+ function assign$1(target, ...others) {
14856
+ return Object.assign(target, ...others);
14857
+ }
14858
+
14859
+ /**
14860
+ * Sets a nested property of a given object to the specified value.
14861
+ *
14862
+ * This mutates the object and returns it.
14863
+ *
14864
+ * @template T
14865
+ *
14866
+ * @param {T} target The target of the set operation.
14867
+ * @param {(string|number)[]} path The path to the nested value.
14868
+ * @param {any} value The value to set.
14869
+ *
14870
+ * @return {T}
14871
+ */
14872
+ function set$1(target, path, value) {
14873
+
14874
+ let currentTarget = target;
14875
+
14876
+ forEach$1(path, function(key, idx) {
14877
+
14878
+ if (typeof key !== 'number' && typeof key !== 'string') {
14879
+ throw new Error('illegal key type: ' + typeof key + '. Key should be of type number or string.');
14880
+ }
14881
+
14882
+ if (key === 'constructor') {
14883
+ throw new Error('illegal key: constructor');
14884
+ }
14885
+
14886
+ if (key === '__proto__') {
14887
+ throw new Error('illegal key: __proto__');
14888
+ }
14889
+
14890
+ let nextKey = path[idx + 1];
14891
+ let nextTarget = currentTarget[key];
14892
+
14893
+ if (isDefined(nextKey) && isNil$1(nextTarget)) {
14894
+ nextTarget = currentTarget[key] = isNaN(+nextKey) ? {} : [];
14895
+ }
14896
+
14897
+ if (isUndefined$2(nextKey)) {
14898
+ if (isUndefined$2(value)) {
14899
+ delete currentTarget[key];
14900
+ } else {
14901
+ currentTarget[key] = value;
14902
+ }
14903
+ } else {
14904
+ currentTarget = nextTarget;
14905
+ }
14906
+ });
14907
+
14908
+ return target;
14909
+ }
14910
+
14911
+ /**
14912
+ * Pick properties from the given target.
14557
14913
  *
14558
14914
  * @template T
14915
+ * @template {any[]} V
14559
14916
  *
14560
- * @param {ArrayFunc<T>} func function to be invoked
14561
- * @param {InjectionContext} [context] context of the invocation
14562
- * @param {LocalsMap} [locals] locals provided
14917
+ * @param {T} target
14918
+ * @param {V} properties
14563
14919
  *
14564
- * @return {T}
14920
+ * @return Pick<T, V>
14565
14921
  */
14566
- Diagram.prototype.invoke = function(func, context, locals) {
14567
- return this._injector.invoke(func, context, locals);
14568
- };
14922
+ function pick(target, properties) {
14569
14923
 
14570
- /**
14571
- * Destroys the diagram
14572
- */
14573
- Diagram.prototype.destroy = function() {
14574
- this.get('eventBus').fire('diagram.destroy');
14575
- };
14924
+ let result = {};
14576
14925
 
14577
- /**
14578
- * Clear the diagram, removing all contents.
14579
- */
14580
- Diagram.prototype.clear = function() {
14581
- this.get('eventBus').fire('diagram.clear');
14582
- };
14926
+ let obj = Object(target);
14927
+
14928
+ forEach$1(properties, function(prop) {
14929
+
14930
+ if (prop in obj) {
14931
+ result[prop] = target[prop];
14932
+ }
14933
+ });
14934
+
14935
+ return result;
14936
+ }
14583
14937
 
14584
14938
  /**
14585
14939
  * Moddle base element.
@@ -14614,7 +14968,7 @@
14614
14968
  prototype = Object.create(Base.prototype);
14615
14969
 
14616
14970
  // initialize default values
14617
- forEach$2(descriptor.properties, function(p) {
14971
+ forEach$1(descriptor.properties, function(p) {
14618
14972
  if (!p.isMany && p.default !== undefined) {
14619
14973
  prototype[p.name] = p.default;
14620
14974
  }
@@ -14633,7 +14987,7 @@
14633
14987
  props.define(this, '$attrs', { value: {} });
14634
14988
  props.define(this, '$parent', { writable: true });
14635
14989
 
14636
- forEach$2(attrs, bind$3(function(val, key) {
14990
+ forEach$1(attrs, bind(function(val, key) {
14637
14991
  this.set(key, val);
14638
14992
  }, this));
14639
14993
  }
@@ -14940,10 +15294,10 @@
14940
15294
  return;
14941
15295
  }
14942
15296
 
14943
- forEach$2(t.properties, bind$3(function(p) {
15297
+ forEach$1(t.properties, bind(function(p) {
14944
15298
 
14945
15299
  // clone property to allow extensions
14946
- p = assign$2({}, p, {
15300
+ p = assign$1({}, p, {
14947
15301
  name: p.ns.localName,
14948
15302
  inherited: inherited
14949
15303
  });
@@ -14987,7 +15341,7 @@
14987
15341
 
14988
15342
  this.properties = properties;
14989
15343
 
14990
- forEach$2(packages, bind$3(this.registerPackage, this));
15344
+ forEach$1(packages, bind(this.registerPackage, this));
14991
15345
  }
14992
15346
 
14993
15347
 
@@ -15003,7 +15357,7 @@
15003
15357
  Registry.prototype.registerPackage = function(pkg) {
15004
15358
 
15005
15359
  // copy package
15006
- pkg = assign$2({}, pkg);
15360
+ pkg = assign$1({}, pkg);
15007
15361
 
15008
15362
  var pkgMap = this.packageMap;
15009
15363
 
@@ -15011,7 +15365,7 @@
15011
15365
  ensureAvailable(pkgMap, pkg, 'uri');
15012
15366
 
15013
15367
  // register types
15014
- forEach$2(pkg.types, bind$3(function(descriptor) {
15368
+ forEach$1(pkg.types, bind(function(descriptor) {
15015
15369
  this.registerType(descriptor, pkg);
15016
15370
  }, this));
15017
15371
 
@@ -15025,11 +15379,11 @@
15025
15379
  */
15026
15380
  Registry.prototype.registerType = function(type, pkg) {
15027
15381
 
15028
- type = assign$2({}, type, {
15382
+ type = assign$1({}, type, {
15029
15383
  superClass: (type.superClass || []).slice(),
15030
15384
  extends: (type.extends || []).slice(),
15031
15385
  properties: (type.properties || []).slice(),
15032
- meta: assign$2((type.meta || {}))
15386
+ meta: assign$1((type.meta || {}))
15033
15387
  });
15034
15388
 
15035
15389
  var ns = parseName(type.name, pkg.prefix),
@@ -15037,7 +15391,7 @@
15037
15391
  propertiesByName = {};
15038
15392
 
15039
15393
  // parse properties
15040
- forEach$2(type.properties, bind$3(function(p) {
15394
+ forEach$1(type.properties, bind(function(p) {
15041
15395
 
15042
15396
  // namespace property names
15043
15397
  var propertyNs = parseName(p.name, ns.prefix),
@@ -15048,7 +15402,7 @@
15048
15402
  p.type = parseName(p.type, propertyNs.prefix).name;
15049
15403
  }
15050
15404
 
15051
- assign$2(p, {
15405
+ assign$1(p, {
15052
15406
  ns: propertyNs,
15053
15407
  name: propertyName
15054
15408
  });
@@ -15057,13 +15411,13 @@
15057
15411
  }, this));
15058
15412
 
15059
15413
  // update ns + name
15060
- assign$2(type, {
15414
+ assign$1(type, {
15061
15415
  ns: ns,
15062
15416
  name: name,
15063
15417
  propertiesByName: propertiesByName
15064
15418
  });
15065
15419
 
15066
- forEach$2(type.extends, bind$3(function(extendsName) {
15420
+ forEach$1(type.extends, bind(function(extendsName) {
15067
15421
  var extendsNameNs = parseName(extendsName, ns.prefix);
15068
15422
 
15069
15423
  var extended = this.typeMap[extendsNameNs.name];
@@ -15081,501 +15435,759 @@
15081
15435
 
15082
15436
 
15083
15437
  /**
15084
- * Traverse the type hierarchy from bottom to top,
15085
- * calling iterator with (type, inherited) for all elements in
15086
- * the inheritance chain.
15438
+ * Traverse the type hierarchy from bottom to top,
15439
+ * calling iterator with (type, inherited) for all elements in
15440
+ * the inheritance chain.
15441
+ *
15442
+ * @param {Object} nsName
15443
+ * @param {Function} iterator
15444
+ * @param {Boolean} [trait=false]
15445
+ */
15446
+ Registry.prototype.mapTypes = function(nsName, iterator, trait) {
15447
+
15448
+ var type = isBuiltIn(nsName.name) ? { name: nsName.name } : this.typeMap[nsName.name];
15449
+
15450
+ var self = this;
15451
+
15452
+ /**
15453
+ * Traverse the selected super type or trait
15454
+ *
15455
+ * @param {String} cls
15456
+ * @param {Boolean} [trait=false]
15457
+ */
15458
+ function traverse(cls, trait) {
15459
+ var parentNs = parseName(cls, isBuiltIn(cls) ? '' : nsName.prefix);
15460
+ self.mapTypes(parentNs, iterator, trait);
15461
+ }
15462
+
15463
+ /**
15464
+ * Traverse the selected trait.
15465
+ *
15466
+ * @param {String} cls
15467
+ */
15468
+ function traverseTrait(cls) {
15469
+ return traverse(cls, true);
15470
+ }
15471
+
15472
+ /**
15473
+ * Traverse the selected super type
15474
+ *
15475
+ * @param {String} cls
15476
+ */
15477
+ function traverseSuper(cls) {
15478
+ return traverse(cls, false);
15479
+ }
15480
+
15481
+ if (!type) {
15482
+ throw new Error('unknown type <' + nsName.name + '>');
15483
+ }
15484
+
15485
+ forEach$1(type.superClass, trait ? traverseTrait : traverseSuper);
15486
+
15487
+ // call iterator with (type, inherited=!trait)
15488
+ iterator(type, !trait);
15489
+
15490
+ forEach$1(type.traits, traverseTrait);
15491
+ };
15492
+
15493
+
15494
+ /**
15495
+ * Returns the effective descriptor for a type.
15496
+ *
15497
+ * @param {String} type the namespaced name (ns:localName) of the type
15498
+ *
15499
+ * @return {Descriptor} the resulting effective descriptor
15500
+ */
15501
+ Registry.prototype.getEffectiveDescriptor = function(name) {
15502
+
15503
+ var nsName = parseName(name);
15504
+
15505
+ var builder = new DescriptorBuilder(nsName);
15506
+
15507
+ this.mapTypes(nsName, function(type, inherited) {
15508
+ builder.addTrait(type, inherited);
15509
+ });
15510
+
15511
+ var descriptor = builder.build();
15512
+
15513
+ // define package link
15514
+ this.definePackage(descriptor, descriptor.allTypes[descriptor.allTypes.length - 1].$pkg);
15515
+
15516
+ return descriptor;
15517
+ };
15518
+
15519
+
15520
+ Registry.prototype.definePackage = function(target, pkg) {
15521
+ this.properties.define(target, '$pkg', { value: pkg });
15522
+ };
15523
+
15524
+
15525
+
15526
+ // helpers ////////////////////////////
15527
+
15528
+ function ensureAvailable(packageMap, pkg, identifierKey) {
15529
+
15530
+ var value = pkg[identifierKey];
15531
+
15532
+ if (value in packageMap) {
15533
+ throw new Error('package with ' + identifierKey + ' <' + value + '> already defined');
15534
+ }
15535
+ }
15536
+
15537
+ /**
15538
+ * A utility that gets and sets properties of model elements.
15539
+ *
15540
+ * @param {Model} model
15541
+ */
15542
+ function Properties(model) {
15543
+ this.model = model;
15544
+ }
15545
+
15546
+
15547
+ /**
15548
+ * Sets a named property on the target element.
15549
+ * If the value is undefined, the property gets deleted.
15550
+ *
15551
+ * @param {Object} target
15552
+ * @param {String} name
15553
+ * @param {Object} value
15554
+ */
15555
+ Properties.prototype.set = function(target, name, value) {
15556
+
15557
+ if (!isString$1(name) || !name.length) {
15558
+ throw new TypeError('property name must be a non-empty string');
15559
+ }
15560
+
15561
+ var property = this.getProperty(target, name);
15562
+
15563
+ var propertyName = property && property.name;
15564
+
15565
+ if (isUndefined$1(value)) {
15566
+
15567
+ // unset the property, if the specified value is undefined;
15568
+ // delete from $attrs (for extensions) or the target itself
15569
+ if (property) {
15570
+ delete target[propertyName];
15571
+ } else {
15572
+ delete target.$attrs[stripGlobal(name)];
15573
+ }
15574
+ } else {
15575
+
15576
+ // set the property, defining well defined properties on the fly
15577
+ // or simply updating them in target.$attrs (for extensions)
15578
+ if (property) {
15579
+ if (propertyName in target) {
15580
+ target[propertyName] = value;
15581
+ } else {
15582
+ defineProperty(target, property, value);
15583
+ }
15584
+ } else {
15585
+ target.$attrs[stripGlobal(name)] = value;
15586
+ }
15587
+ }
15588
+ };
15589
+
15590
+ /**
15591
+ * Returns the named property of the given element
15592
+ *
15593
+ * @param {Object} target
15594
+ * @param {String} name
15595
+ *
15596
+ * @return {Object}
15597
+ */
15598
+ Properties.prototype.get = function(target, name) {
15599
+
15600
+ var property = this.getProperty(target, name);
15601
+
15602
+ if (!property) {
15603
+ return target.$attrs[stripGlobal(name)];
15604
+ }
15605
+
15606
+ var propertyName = property.name;
15607
+
15608
+ // check if access to collection property and lazily initialize it
15609
+ if (!target[propertyName] && property.isMany) {
15610
+ defineProperty(target, property, []);
15611
+ }
15612
+
15613
+ return target[propertyName];
15614
+ };
15615
+
15616
+
15617
+ /**
15618
+ * Define a property on the target element
15619
+ *
15620
+ * @param {Object} target
15621
+ * @param {String} name
15622
+ * @param {Object} options
15623
+ */
15624
+ Properties.prototype.define = function(target, name, options) {
15625
+
15626
+ if (!options.writable) {
15627
+
15628
+ var value = options.value;
15629
+
15630
+ // use getters for read-only variables to support ES6 proxies
15631
+ // cf. https://github.com/bpmn-io/internal-docs/issues/386
15632
+ options = assign$1({}, options, {
15633
+ get: function() { return value; }
15634
+ });
15635
+
15636
+ delete options.value;
15637
+ }
15638
+
15639
+ Object.defineProperty(target, name, options);
15640
+ };
15641
+
15642
+
15643
+ /**
15644
+ * Define the descriptor for an element
15645
+ */
15646
+ Properties.prototype.defineDescriptor = function(target, descriptor) {
15647
+ this.define(target, '$descriptor', { value: descriptor });
15648
+ };
15649
+
15650
+ /**
15651
+ * Define the model for an element
15652
+ */
15653
+ Properties.prototype.defineModel = function(target, model) {
15654
+ this.define(target, '$model', { value: model });
15655
+ };
15656
+
15657
+ /**
15658
+ * Return property with the given name on the element.
15087
15659
  *
15088
- * @param {Object} nsName
15089
- * @param {Function} iterator
15090
- * @param {Boolean} [trait=false]
15660
+ * @param {any} target
15661
+ * @param {string} name
15662
+ *
15663
+ * @return {object | null} property
15091
15664
  */
15092
- Registry.prototype.mapTypes = function(nsName, iterator, trait) {
15665
+ Properties.prototype.getProperty = function(target, name) {
15093
15666
 
15094
- var type = isBuiltIn(nsName.name) ? { name: nsName.name } : this.typeMap[nsName.name];
15667
+ var model = this.model;
15095
15668
 
15096
- var self = this;
15669
+ var property = model.getPropertyDescriptor(target, name);
15097
15670
 
15098
- /**
15099
- * Traverse the selected super type or trait
15100
- *
15101
- * @param {String} cls
15102
- * @param {Boolean} [trait=false]
15103
- */
15104
- function traverse(cls, trait) {
15105
- var parentNs = parseName(cls, isBuiltIn(cls) ? '' : nsName.prefix);
15106
- self.mapTypes(parentNs, iterator, trait);
15671
+ if (property) {
15672
+ return property;
15107
15673
  }
15108
15674
 
15109
- /**
15110
- * Traverse the selected trait.
15111
- *
15112
- * @param {String} cls
15113
- */
15114
- function traverseTrait(cls) {
15115
- return traverse(cls, true);
15675
+ if (name.includes(':')) {
15676
+ return null;
15116
15677
  }
15117
15678
 
15118
- /**
15119
- * Traverse the selected super type
15120
- *
15121
- * @param {String} cls
15122
- */
15123
- function traverseSuper(cls) {
15124
- return traverse(cls, false);
15125
- }
15679
+ const strict = model.config.strict;
15126
15680
 
15127
- if (!type) {
15128
- throw new Error('unknown type <' + nsName.name + '>');
15129
- }
15681
+ if (typeof strict !== 'undefined') {
15682
+ const error = new TypeError(`unknown property <${ name }> on <${ target.$type }>`);
15130
15683
 
15131
- forEach$2(type.superClass, trait ? traverseTrait : traverseSuper);
15684
+ if (strict) {
15685
+ throw error;
15686
+ } else {
15132
15687
 
15133
- // call iterator with (type, inherited=!trait)
15134
- iterator(type, !trait);
15688
+ // eslint-disable-next-line no-undef
15689
+ typeof console !== 'undefined' && console.warn(error);
15690
+ }
15691
+ }
15135
15692
 
15136
- forEach$2(type.traits, traverseTrait);
15693
+ return null;
15137
15694
  };
15138
15695
 
15696
+ function isUndefined$1(val) {
15697
+ return typeof val === 'undefined';
15698
+ }
15699
+
15700
+ function defineProperty(target, property, value) {
15701
+ Object.defineProperty(target, property.name, {
15702
+ enumerable: !property.isReference,
15703
+ writable: true,
15704
+ value: value,
15705
+ configurable: true
15706
+ });
15707
+ }
15708
+
15709
+ function stripGlobal(name) {
15710
+ return name.replace(/^:/, '');
15711
+ }
15712
+
15713
+ // Moddle implementation /////////////////////////////////////////////////
15139
15714
 
15140
15715
  /**
15141
- * Returns the effective descriptor for a type.
15716
+ * @class Moddle
15142
15717
  *
15143
- * @param {String} type the namespaced name (ns:localName) of the type
15718
+ * A model that can be used to create elements of a specific type.
15144
15719
  *
15145
- * @return {Descriptor} the resulting effective descriptor
15720
+ * @example
15721
+ *
15722
+ * var Moddle = require('moddle');
15723
+ *
15724
+ * var pkg = {
15725
+ * name: 'mypackage',
15726
+ * prefix: 'my',
15727
+ * types: [
15728
+ * { name: 'Root' }
15729
+ * ]
15730
+ * };
15731
+ *
15732
+ * var moddle = new Moddle([pkg]);
15733
+ *
15734
+ * @param {Array<Package>} packages the packages to contain
15735
+ *
15736
+ * @param { { strict?: boolean } } [config] moddle configuration
15146
15737
  */
15147
- Registry.prototype.getEffectiveDescriptor = function(name) {
15738
+ function Moddle(packages, config = {}) {
15148
15739
 
15149
- var nsName = parseName(name);
15740
+ this.properties = new Properties(this);
15150
15741
 
15151
- var builder = new DescriptorBuilder(nsName);
15742
+ this.factory = new Factory(this, this.properties);
15743
+ this.registry = new Registry(packages, this.properties);
15152
15744
 
15153
- this.mapTypes(nsName, function(type, inherited) {
15154
- builder.addTrait(type, inherited);
15155
- });
15745
+ this.typeCache = {};
15156
15746
 
15157
- var descriptor = builder.build();
15747
+ this.config = config;
15748
+ }
15158
15749
 
15159
- // define package link
15160
- this.definePackage(descriptor, descriptor.allTypes[descriptor.allTypes.length - 1].$pkg);
15161
15750
 
15162
- return descriptor;
15163
- };
15751
+ /**
15752
+ * Create an instance of the specified type.
15753
+ *
15754
+ * @method Moddle#create
15755
+ *
15756
+ * @example
15757
+ *
15758
+ * var foo = moddle.create('my:Foo');
15759
+ * var bar = moddle.create('my:Bar', { id: 'BAR_1' });
15760
+ *
15761
+ * @param {String|Object} descriptor the type descriptor or name know to the model
15762
+ * @param {Object} attrs a number of attributes to initialize the model instance with
15763
+ * @return {Object} model instance
15764
+ */
15765
+ Moddle.prototype.create = function(descriptor, attrs) {
15766
+ var Type = this.getType(descriptor);
15164
15767
 
15768
+ if (!Type) {
15769
+ throw new Error('unknown type <' + descriptor + '>');
15770
+ }
15165
15771
 
15166
- Registry.prototype.definePackage = function(target, pkg) {
15167
- this.properties.define(target, '$pkg', { value: pkg });
15772
+ return new Type(attrs);
15168
15773
  };
15169
15774
 
15170
15775
 
15776
+ /**
15777
+ * Returns the type representing a given descriptor
15778
+ *
15779
+ * @method Moddle#getType
15780
+ *
15781
+ * @example
15782
+ *
15783
+ * var Foo = moddle.getType('my:Foo');
15784
+ * var foo = new Foo({ 'id' : 'FOO_1' });
15785
+ *
15786
+ * @param {String|Object} descriptor the type descriptor or name know to the model
15787
+ * @return {Object} the type representing the descriptor
15788
+ */
15789
+ Moddle.prototype.getType = function(descriptor) {
15171
15790
 
15172
- // helpers ////////////////////////////
15791
+ var cache = this.typeCache;
15173
15792
 
15174
- function ensureAvailable(packageMap, pkg, identifierKey) {
15793
+ var name = isString$1(descriptor) ? descriptor : descriptor.ns.name;
15175
15794
 
15176
- var value = pkg[identifierKey];
15795
+ var type = cache[name];
15177
15796
 
15178
- if (value in packageMap) {
15179
- throw new Error('package with ' + identifierKey + ' <' + value + '> already defined');
15797
+ if (!type) {
15798
+ descriptor = this.registry.getEffectiveDescriptor(name);
15799
+ type = cache[name] = this.factory.createType(descriptor);
15180
15800
  }
15181
- }
15182
15801
 
15183
- /**
15184
- * A utility that gets and sets properties of model elements.
15185
- *
15186
- * @param {Model} model
15187
- */
15188
- function Properties(model) {
15189
- this.model = model;
15190
- }
15802
+ return type;
15803
+ };
15191
15804
 
15192
15805
 
15193
15806
  /**
15194
- * Sets a named property on the target element.
15195
- * If the value is undefined, the property gets deleted.
15807
+ * Creates an any-element type to be used within model instances.
15196
15808
  *
15197
- * @param {Object} target
15198
- * @param {String} name
15199
- * @param {Object} value
15809
+ * This can be used to create custom elements that lie outside the meta-model.
15810
+ * The created element contains all the meta-data required to serialize it
15811
+ * as part of meta-model elements.
15812
+ *
15813
+ * @method Moddle#createAny
15814
+ *
15815
+ * @example
15816
+ *
15817
+ * var foo = moddle.createAny('vendor:Foo', 'http://vendor', {
15818
+ * value: 'bar'
15819
+ * });
15820
+ *
15821
+ * var container = moddle.create('my:Container', 'http://my', {
15822
+ * any: [ foo ]
15823
+ * });
15824
+ *
15825
+ * // go ahead and serialize the stuff
15826
+ *
15827
+ *
15828
+ * @param {String} name the name of the element
15829
+ * @param {String} nsUri the namespace uri of the element
15830
+ * @param {Object} [properties] a map of properties to initialize the instance with
15831
+ * @return {Object} the any type instance
15200
15832
  */
15201
- Properties.prototype.set = function(target, name, value) {
15202
-
15203
- if (!isString(name) || !name.length) {
15204
- throw new TypeError('property name must be a non-empty string');
15205
- }
15206
-
15207
- var property = this.getProperty(target, name);
15833
+ Moddle.prototype.createAny = function(name, nsUri, properties) {
15208
15834
 
15209
- var propertyName = property && property.name;
15835
+ var nameNs = parseName(name);
15210
15836
 
15211
- if (isUndefined(value)) {
15837
+ var element = {
15838
+ $type: name,
15839
+ $instanceOf: function(type) {
15840
+ return type === this.$type;
15841
+ },
15842
+ get: function(key) {
15843
+ return this[key];
15844
+ },
15845
+ set: function(key, value) {
15846
+ set$1(this, [ key ], value);
15847
+ }
15848
+ };
15212
15849
 
15213
- // unset the property, if the specified value is undefined;
15214
- // delete from $attrs (for extensions) or the target itself
15215
- if (property) {
15216
- delete target[propertyName];
15217
- } else {
15218
- delete target.$attrs[stripGlobal(name)];
15850
+ var descriptor = {
15851
+ name: name,
15852
+ isGeneric: true,
15853
+ ns: {
15854
+ prefix: nameNs.prefix,
15855
+ localName: nameNs.localName,
15856
+ uri: nsUri
15219
15857
  }
15220
- } else {
15858
+ };
15221
15859
 
15222
- // set the property, defining well defined properties on the fly
15223
- // or simply updating them in target.$attrs (for extensions)
15224
- if (property) {
15225
- if (propertyName in target) {
15226
- target[propertyName] = value;
15227
- } else {
15228
- defineProperty(target, property, value);
15229
- }
15860
+ this.properties.defineDescriptor(element, descriptor);
15861
+ this.properties.defineModel(element, this);
15862
+ this.properties.define(element, 'get', { enumerable: false, writable: true });
15863
+ this.properties.define(element, 'set', { enumerable: false, writable: true });
15864
+ this.properties.define(element, '$parent', { enumerable: false, writable: true });
15865
+ this.properties.define(element, '$instanceOf', { enumerable: false, writable: true });
15866
+
15867
+ forEach$1(properties, function(a, key) {
15868
+ if (isObject(a) && a.value !== undefined) {
15869
+ element[a.name] = a.value;
15230
15870
  } else {
15231
- target.$attrs[stripGlobal(name)] = value;
15871
+ element[key] = a;
15232
15872
  }
15233
- }
15873
+ });
15874
+
15875
+ return element;
15234
15876
  };
15235
15877
 
15236
15878
  /**
15237
- * Returns the named property of the given element
15238
- *
15239
- * @param {Object} target
15240
- * @param {String} name
15879
+ * Returns a registered package by uri or prefix
15241
15880
  *
15242
- * @return {Object}
15881
+ * @return {Object} the package
15243
15882
  */
15244
- Properties.prototype.get = function(target, name) {
15245
-
15246
- var property = this.getProperty(target, name);
15247
-
15248
- if (!property) {
15249
- return target.$attrs[stripGlobal(name)];
15250
- }
15251
-
15252
- var propertyName = property.name;
15253
-
15254
- // check if access to collection property and lazily initialize it
15255
- if (!target[propertyName] && property.isMany) {
15256
- defineProperty(target, property, []);
15257
- }
15258
-
15259
- return target[propertyName];
15883
+ Moddle.prototype.getPackage = function(uriOrPrefix) {
15884
+ return this.registry.getPackage(uriOrPrefix);
15260
15885
  };
15261
15886
 
15262
-
15263
15887
  /**
15264
- * Define a property on the target element
15888
+ * Returns a snapshot of all known packages
15265
15889
  *
15266
- * @param {Object} target
15267
- * @param {String} name
15268
- * @param {Object} options
15890
+ * @return {Object} the package
15269
15891
  */
15270
- Properties.prototype.define = function(target, name, options) {
15271
-
15272
- if (!options.writable) {
15273
-
15274
- var value = options.value;
15892
+ Moddle.prototype.getPackages = function() {
15893
+ return this.registry.getPackages();
15894
+ };
15275
15895
 
15276
- // use getters for read-only variables to support ES6 proxies
15277
- // cf. https://github.com/bpmn-io/internal-docs/issues/386
15278
- options = assign$2({}, options, {
15279
- get: function() { return value; }
15280
- });
15896
+ /**
15897
+ * Returns the descriptor for an element
15898
+ */
15899
+ Moddle.prototype.getElementDescriptor = function(element) {
15900
+ return element.$descriptor;
15901
+ };
15281
15902
 
15282
- delete options.value;
15903
+ /**
15904
+ * Returns true if the given descriptor or instance
15905
+ * represents the given type.
15906
+ *
15907
+ * May be applied to this, if element is omitted.
15908
+ */
15909
+ Moddle.prototype.hasType = function(element, type) {
15910
+ if (type === undefined) {
15911
+ type = element;
15912
+ element = this;
15283
15913
  }
15284
15914
 
15285
- Object.defineProperty(target, name, options);
15286
- };
15915
+ var descriptor = element.$model.getElementDescriptor(element);
15287
15916
 
15917
+ return (type in descriptor.allTypesByName);
15918
+ };
15288
15919
 
15289
15920
  /**
15290
- * Define the descriptor for an element
15921
+ * Returns the descriptor of an elements named property
15291
15922
  */
15292
- Properties.prototype.defineDescriptor = function(target, descriptor) {
15293
- this.define(target, '$descriptor', { value: descriptor });
15923
+ Moddle.prototype.getPropertyDescriptor = function(element, property) {
15924
+ return this.getElementDescriptor(element).propertiesByName[property];
15294
15925
  };
15295
15926
 
15296
15927
  /**
15297
- * Define the model for an element
15928
+ * Returns a mapped type's descriptor
15298
15929
  */
15299
- Properties.prototype.defineModel = function(target, model) {
15300
- this.define(target, '$model', { value: model });
15930
+ Moddle.prototype.getTypeDescriptor = function(type) {
15931
+ return this.registry.typeMap[type];
15301
15932
  };
15302
15933
 
15303
15934
  /**
15304
- * Return property with the given name on the element.
15935
+ * Flatten array, one level deep.
15305
15936
  *
15306
- * @param {any} target
15307
- * @param {string} name
15937
+ * @template T
15308
15938
  *
15309
- * @return {object | null} property
15939
+ * @param {T[][] | T[] | null} [arr]
15940
+ *
15941
+ * @return {T[]}
15310
15942
  */
15311
- Properties.prototype.getProperty = function(target, name) {
15312
-
15313
- var model = this.model;
15314
-
15315
- var property = model.getPropertyDescriptor(target, name);
15316
-
15317
- if (property) {
15318
- return property;
15319
- }
15320
-
15321
- if (name.includes(':')) {
15322
- return null;
15323
- }
15324
15943
 
15325
- const strict = model.config.strict;
15944
+ const nativeToString = Object.prototype.toString;
15945
+ const nativeHasOwnProperty = Object.prototype.hasOwnProperty;
15326
15946
 
15327
- if (typeof strict !== 'undefined') {
15328
- const error = new TypeError(`unknown property <${ name }> on <${ target.$type }>`);
15947
+ function isUndefined(obj) {
15948
+ return obj === undefined;
15949
+ }
15329
15950
 
15330
- if (strict) {
15331
- throw error;
15332
- } else {
15951
+ function isNil(obj) {
15952
+ return obj == null;
15953
+ }
15333
15954
 
15334
- // eslint-disable-next-line no-undef
15335
- typeof console !== 'undefined' && console.warn(error);
15336
- }
15337
- }
15955
+ function isArray(obj) {
15956
+ return nativeToString.call(obj) === '[object Array]';
15957
+ }
15338
15958
 
15339
- return null;
15340
- };
15959
+ /**
15960
+ * @param {any} obj
15961
+ *
15962
+ * @return {boolean}
15963
+ */
15964
+ function isFunction(obj) {
15965
+ const tag = nativeToString.call(obj);
15341
15966
 
15342
- function isUndefined(val) {
15343
- return typeof val === 'undefined';
15967
+ return (
15968
+ tag === '[object Function]' ||
15969
+ tag === '[object AsyncFunction]' ||
15970
+ tag === '[object GeneratorFunction]' ||
15971
+ tag === '[object AsyncGeneratorFunction]' ||
15972
+ tag === '[object Proxy]'
15973
+ );
15344
15974
  }
15345
15975
 
15346
- function defineProperty(target, property, value) {
15347
- Object.defineProperty(target, property.name, {
15348
- enumerable: !property.isReference,
15349
- writable: true,
15350
- value: value,
15351
- configurable: true
15352
- });
15976
+ function isString(obj) {
15977
+ return nativeToString.call(obj) === '[object String]';
15353
15978
  }
15354
15979
 
15355
- function stripGlobal(name) {
15356
- return name.replace(/^:/, '');
15980
+ /**
15981
+ * Return true, if target owns a property with the given key.
15982
+ *
15983
+ * @param {Object} target
15984
+ * @param {String} key
15985
+ *
15986
+ * @return {Boolean}
15987
+ */
15988
+ function has(target, key) {
15989
+ return !isNil(target) && nativeHasOwnProperty.call(target, key);
15357
15990
  }
15358
15991
 
15359
- // Moddle implementation /////////////////////////////////////////////////
15992
+ /**
15993
+ * @template T
15994
+ * @typedef { (
15995
+ * ((e: T) => boolean) |
15996
+ * ((e: T, idx: number) => boolean) |
15997
+ * ((e: T, key: string) => boolean) |
15998
+ * string |
15999
+ * number
16000
+ * ) } Matcher
16001
+ */
15360
16002
 
15361
16003
  /**
15362
- * @class Moddle
15363
- *
15364
- * A model that can be used to create elements of a specific type.
15365
- *
15366
- * @example
15367
- *
15368
- * var Moddle = require('moddle');
15369
- *
15370
- * var pkg = {
15371
- * name: 'mypackage',
15372
- * prefix: 'my',
15373
- * types: [
15374
- * { name: 'Root' }
15375
- * ]
15376
- * };
15377
- *
15378
- * var moddle = new Moddle([pkg]);
15379
- *
15380
- * @param {Array<Package>} packages the packages to contain
16004
+ * @template T
16005
+ * @template U
15381
16006
  *
15382
- * @param { { strict?: boolean } } [config] moddle configuration
16007
+ * @typedef { (
16008
+ * ((e: T) => U) | string | number
16009
+ * ) } Extractor
15383
16010
  */
15384
- function Moddle(packages, config = {}) {
15385
16011
 
15386
- this.properties = new Properties(this);
15387
16012
 
15388
- this.factory = new Factory(this, this.properties);
15389
- this.registry = new Registry(packages, this.properties);
16013
+ /**
16014
+ * @template T
16015
+ * @typedef { (val: T, key: any) => boolean } MatchFn
16016
+ */
15390
16017
 
15391
- this.typeCache = {};
16018
+ /**
16019
+ * @template T
16020
+ * @typedef { T[] } ArrayCollection
16021
+ */
15392
16022
 
15393
- this.config = config;
15394
- }
16023
+ /**
16024
+ * @template T
16025
+ * @typedef { { [key: string]: T } } StringKeyValueCollection
16026
+ */
15395
16027
 
16028
+ /**
16029
+ * @template T
16030
+ * @typedef { { [key: number]: T } } NumberKeyValueCollection
16031
+ */
15396
16032
 
15397
16033
  /**
15398
- * Create an instance of the specified type.
15399
- *
15400
- * @method Moddle#create
15401
- *
15402
- * @example
16034
+ * @template T
16035
+ * @typedef { StringKeyValueCollection<T> | NumberKeyValueCollection<T> } KeyValueCollection
16036
+ */
16037
+
16038
+ /**
16039
+ * @template T
16040
+ * @typedef { KeyValueCollection<T> | ArrayCollection<T> } Collection
16041
+ */
16042
+
16043
+ /**
16044
+ * Find element in collection.
15403
16045
  *
15404
- * var foo = moddle.create('my:Foo');
15405
- * var bar = moddle.create('my:Bar', { id: 'BAR_1' });
16046
+ * @template T
16047
+ * @param {Collection<T>} collection
16048
+ * @param {Matcher<T>} matcher
15406
16049
  *
15407
- * @param {String|Object} descriptor the type descriptor or name know to the model
15408
- * @param {Object} attrs a number of attributes to initialize the model instance with
15409
- * @return {Object} model instance
16050
+ * @return {Object}
15410
16051
  */
15411
- Moddle.prototype.create = function(descriptor, attrs) {
15412
- var Type = this.getType(descriptor);
16052
+ function find(collection, matcher) {
15413
16053
 
15414
- if (!Type) {
15415
- throw new Error('unknown type <' + descriptor + '>');
15416
- }
16054
+ const matchFn = toMatcher(matcher);
15417
16055
 
15418
- return new Type(attrs);
15419
- };
16056
+ let match;
16057
+
16058
+ forEach(collection, function(val, key) {
16059
+ if (matchFn(val, key)) {
16060
+ match = val;
16061
+
16062
+ return false;
16063
+ }
16064
+ });
16065
+
16066
+ return match;
16067
+
16068
+ }
15420
16069
 
15421
16070
 
15422
16071
  /**
15423
- * Returns the type representing a given descriptor
15424
- *
15425
- * @method Moddle#getType
15426
- *
15427
- * @example
16072
+ * Find element index in collection.
15428
16073
  *
15429
- * var Foo = moddle.getType('my:Foo');
15430
- * var foo = new Foo({ 'id' : 'FOO_1' });
16074
+ * @template T
16075
+ * @param {Collection<T>} collection
16076
+ * @param {Matcher<T>} matcher
15431
16077
  *
15432
- * @param {String|Object} descriptor the type descriptor or name know to the model
15433
- * @return {Object} the type representing the descriptor
16078
+ * @return {number | string | undefined}
15434
16079
  */
15435
- Moddle.prototype.getType = function(descriptor) {
16080
+ function findIndex(collection, matcher) {
15436
16081
 
15437
- var cache = this.typeCache;
16082
+ const matchFn = toMatcher(matcher);
15438
16083
 
15439
- var name = isString(descriptor) ? descriptor : descriptor.ns.name;
16084
+ let idx = isArray(collection) ? -1 : undefined;
15440
16085
 
15441
- var type = cache[name];
16086
+ forEach(collection, function(val, key) {
16087
+ if (matchFn(val, key)) {
16088
+ idx = key;
15442
16089
 
15443
- if (!type) {
15444
- descriptor = this.registry.getEffectiveDescriptor(name);
15445
- type = cache[name] = this.factory.createType(descriptor);
15446
- }
16090
+ return false;
16091
+ }
16092
+ });
15447
16093
 
15448
- return type;
15449
- };
16094
+ return idx;
16095
+ }
15450
16096
 
15451
16097
 
15452
16098
  /**
15453
- * Creates an any-element type to be used within model instances.
15454
- *
15455
- * This can be used to create custom elements that lie outside the meta-model.
15456
- * The created element contains all the meta-data required to serialize it
15457
- * as part of meta-model elements.
15458
- *
15459
- * @method Moddle#createAny
15460
- *
15461
- * @example
15462
- *
15463
- * var foo = moddle.createAny('vendor:Foo', 'http://vendor', {
15464
- * value: 'bar'
15465
- * });
15466
- *
15467
- * var container = moddle.create('my:Container', 'http://my', {
15468
- * any: [ foo ]
15469
- * });
15470
- *
15471
- * // go ahead and serialize the stuff
16099
+ * Filter elements in collection.
15472
16100
  *
16101
+ * @template T
16102
+ * @param {Collection<T>} collection
16103
+ * @param {Matcher<T>} matcher
15473
16104
  *
15474
- * @param {String} name the name of the element
15475
- * @param {String} nsUri the namespace uri of the element
15476
- * @param {Object} [properties] a map of properties to initialize the instance with
15477
- * @return {Object} the any type instance
16105
+ * @return {T[]} result
15478
16106
  */
15479
- Moddle.prototype.createAny = function(name, nsUri, properties) {
15480
-
15481
- var nameNs = parseName(name);
15482
-
15483
- var element = {
15484
- $type: name,
15485
- $instanceOf: function(type) {
15486
- return type === this.$type;
15487
- },
15488
- get: function(key) {
15489
- return this[key];
15490
- },
15491
- set: function(key, value) {
15492
- set$1(this, [ key ], value);
15493
- }
15494
- };
16107
+ function filter(collection, matcher) {
15495
16108
 
15496
- var descriptor = {
15497
- name: name,
15498
- isGeneric: true,
15499
- ns: {
15500
- prefix: nameNs.prefix,
15501
- localName: nameNs.localName,
15502
- uri: nsUri
15503
- }
15504
- };
16109
+ const matchFn = toMatcher(matcher);
15505
16110
 
15506
- this.properties.defineDescriptor(element, descriptor);
15507
- this.properties.defineModel(element, this);
15508
- this.properties.define(element, 'get', { enumerable: false, writable: true });
15509
- this.properties.define(element, 'set', { enumerable: false, writable: true });
15510
- this.properties.define(element, '$parent', { enumerable: false, writable: true });
15511
- this.properties.define(element, '$instanceOf', { enumerable: false, writable: true });
16111
+ let result = [];
15512
16112
 
15513
- forEach$2(properties, function(a, key) {
15514
- if (isObject(a) && a.value !== undefined) {
15515
- element[a.name] = a.value;
15516
- } else {
15517
- element[key] = a;
16113
+ forEach(collection, function(val, key) {
16114
+ if (matchFn(val, key)) {
16115
+ result.push(val);
15518
16116
  }
15519
16117
  });
15520
16118
 
15521
- return element;
15522
- };
16119
+ return result;
16120
+ }
15523
16121
 
15524
- /**
15525
- * Returns a registered package by uri or prefix
15526
- *
15527
- * @return {Object} the package
15528
- */
15529
- Moddle.prototype.getPackage = function(uriOrPrefix) {
15530
- return this.registry.getPackage(uriOrPrefix);
15531
- };
15532
16122
 
15533
16123
  /**
15534
- * Returns a snapshot of all known packages
16124
+ * Iterate over collection; returning something
16125
+ * (non-undefined) will stop iteration.
15535
16126
  *
15536
- * @return {Object} the package
16127
+ * @template T
16128
+ * @param {Collection<T>} collection
16129
+ * @param { ((item: T, idx: number) => (boolean|void)) | ((item: T, key: string) => (boolean|void)) } iterator
16130
+ *
16131
+ * @return {T} return result that stopped the iteration
15537
16132
  */
15538
- Moddle.prototype.getPackages = function() {
15539
- return this.registry.getPackages();
15540
- };
16133
+ function forEach(collection, iterator) {
15541
16134
 
15542
- /**
15543
- * Returns the descriptor for an element
15544
- */
15545
- Moddle.prototype.getElementDescriptor = function(element) {
15546
- return element.$descriptor;
15547
- };
16135
+ let val,
16136
+ result;
15548
16137
 
15549
- /**
15550
- * Returns true if the given descriptor or instance
15551
- * represents the given type.
15552
- *
15553
- * May be applied to this, if element is omitted.
15554
- */
15555
- Moddle.prototype.hasType = function(element, type) {
15556
- if (type === undefined) {
15557
- type = element;
15558
- element = this;
16138
+ if (isUndefined(collection)) {
16139
+ return;
15559
16140
  }
15560
16141
 
15561
- var descriptor = element.$model.getElementDescriptor(element);
16142
+ const convertKey = isArray(collection) ? toNum : identity;
16143
+
16144
+ for (let key in collection) {
16145
+
16146
+ if (has(collection, key)) {
16147
+ val = collection[key];
16148
+
16149
+ result = iterator(val, convertKey(key));
16150
+
16151
+ if (result === false) {
16152
+ return val;
16153
+ }
16154
+ }
16155
+ }
16156
+ }
15562
16157
 
15563
- return (type in descriptor.allTypesByName);
15564
- };
15565
16158
 
15566
16159
  /**
15567
- * Returns the descriptor of an elements named property
16160
+ * @template T
16161
+ * @param {Matcher<T>} matcher
16162
+ *
16163
+ * @return {MatchFn<T>}
15568
16164
  */
15569
- Moddle.prototype.getPropertyDescriptor = function(element, property) {
15570
- return this.getElementDescriptor(element).propertiesByName[property];
15571
- };
16165
+ function toMatcher(matcher) {
16166
+ return isFunction(matcher) ? matcher : (e) => {
16167
+ return e === matcher;
16168
+ };
16169
+ }
16170
+
16171
+
16172
+ function identity(arg) {
16173
+ return arg;
16174
+ }
16175
+
16176
+ function toNum(arg) {
16177
+ return Number(arg);
16178
+ }
15572
16179
 
15573
16180
  /**
15574
- * Returns a mapped type's descriptor
16181
+ * Convenience wrapper for `Object.assign`.
16182
+ *
16183
+ * @param {Object} target
16184
+ * @param {...Object} others
16185
+ *
16186
+ * @return {Object} the target
15575
16187
  */
15576
- Moddle.prototype.getTypeDescriptor = function(type) {
15577
- return this.registry.typeMap[type];
15578
- };
16188
+ function assign(target, ...others) {
16189
+ return Object.assign(target, ...others);
16190
+ }
15579
16191
 
15580
16192
  var fromCharCode = String.fromCharCode;
15581
16193
 
@@ -16723,7 +17335,7 @@
16723
17335
  * @property {Boolean} lax
16724
17336
  */
16725
17337
 
16726
- assign$2(this, options);
17338
+ assign(this, options);
16727
17339
 
16728
17340
  this.elementsById = {};
16729
17341
  this.references = [];
@@ -16944,7 +17556,7 @@
16944
17556
  model = this.model,
16945
17557
  propNameNs;
16946
17558
 
16947
- forEach$2(attributes, function(value, name) {
17559
+ forEach(attributes, function(value, name) {
16948
17560
 
16949
17561
  var prop = descriptor.propertiesByName[name],
16950
17562
  values;
@@ -16962,7 +17574,7 @@
16962
17574
  // IDREFS: parse references as whitespace-separated list
16963
17575
  values = value.split(' ');
16964
17576
 
16965
- forEach$2(values, function(v) {
17577
+ forEach(values, function(v) {
16966
17578
  context.addReference({
16967
17579
  element: instance,
16968
17580
  property: prop.ns.name,
@@ -17031,7 +17643,7 @@
17031
17643
 
17032
17644
  const elementType = model.getType(normalizedTypeName);
17033
17645
 
17034
- return assign$2({}, property, {
17646
+ return assign({}, property, {
17035
17647
  effectiveType: getModdleDescriptor(elementType).name
17036
17648
  });
17037
17649
  }
@@ -17053,7 +17665,7 @@
17053
17665
  });
17054
17666
 
17055
17667
  if (property) {
17056
- return assign$2({}, property, {
17668
+ return assign({}, property, {
17057
17669
  effectiveType: getModdleDescriptor(elementType).name
17058
17670
  });
17059
17671
  }
@@ -17128,7 +17740,7 @@
17128
17740
  }
17129
17741
 
17130
17742
  if (propertyDesc.isReference) {
17131
- assign$2(newElement, {
17743
+ assign(newElement, {
17132
17744
  element: element
17133
17745
  });
17134
17746
 
@@ -17237,7 +17849,7 @@
17237
17849
  };
17238
17850
  }
17239
17851
 
17240
- assign$2(this, { lax: false }, options);
17852
+ assign(this, { lax: false }, options);
17241
17853
  }
17242
17854
 
17243
17855
  /**
@@ -17292,7 +17904,7 @@
17292
17904
  var model = this.model,
17293
17905
  lax = this.lax;
17294
17906
 
17295
- var context = new Context(assign$2({}, options, { rootHandler: rootHandler })),
17907
+ var context = new Context(assign({}, options, { rootHandler: rootHandler })),
17296
17908
  parser = new Parser({ proxy: true }),
17297
17909
  stack = createStack();
17298
17910
 
@@ -17697,14 +18309,14 @@
17697
18309
 
17698
18310
  function getElementNs(ns, descriptor) {
17699
18311
  if (descriptor.isGeneric) {
17700
- return assign$2({ localName: descriptor.ns.localName }, ns);
18312
+ return assign({ localName: descriptor.ns.localName }, ns);
17701
18313
  } else {
17702
- return assign$2({ localName: nameToAlias(descriptor.ns.localName, descriptor.$pkg) }, ns);
18314
+ return assign({ localName: nameToAlias(descriptor.ns.localName, descriptor.$pkg) }, ns);
17703
18315
  }
17704
18316
  }
17705
18317
 
17706
18318
  function getPropertyNs(ns, descriptor) {
17707
- return assign$2({ localName: descriptor.ns.localName }, ns);
18319
+ return assign({ localName: descriptor.ns.localName }, ns);
17708
18320
  }
17709
18321
 
17710
18322
  function getSerializableProperties(element) {
@@ -17718,7 +18330,7 @@
17718
18330
  }
17719
18331
 
17720
18332
  // do not serialize defaults
17721
- if (!has$2(element, name)) {
18333
+ if (!has(element, name)) {
17722
18334
  return false;
17723
18335
  }
17724
18336
 
@@ -17938,7 +18550,7 @@
17938
18550
  if (this.isLocalNs(effectiveNs)) {
17939
18551
  return { localName: ns.localName };
17940
18552
  } else {
17941
- return assign$2({ localName: ns.localName }, effectiveNs);
18553
+ return assign({ localName: ns.localName }, effectiveNs);
17942
18554
  }
17943
18555
  };
17944
18556
 
@@ -17961,7 +18573,7 @@
17961
18573
  var children = element.$children;
17962
18574
 
17963
18575
  if (children) {
17964
- forEach$2(children, child => {
18576
+ forEach(children, child => {
17965
18577
  this.body.push(new ElementSerializer(this).build(child));
17966
18578
  });
17967
18579
  }
@@ -18021,7 +18633,7 @@
18021
18633
  // parse namespace attributes first
18022
18634
  // and log them. push non namespace attributes to a list
18023
18635
  // and process them later
18024
- forEach$2(genericAttrs, function(value, name) {
18636
+ forEach(genericAttrs, function(value, name) {
18025
18637
 
18026
18638
  var nonNsAttr = self.parseNsAttribute(element, name, value);
18027
18639
 
@@ -18037,7 +18649,7 @@
18037
18649
 
18038
18650
  var self = this;
18039
18651
 
18040
- forEach$2(attributes, function(attr) {
18652
+ forEach(attributes, function(attr) {
18041
18653
 
18042
18654
  try {
18043
18655
  self.addAttribute(self.nsAttributeName(attr.name), attr.value);
@@ -18059,7 +18671,7 @@
18059
18671
  body = this.body,
18060
18672
  element = this.element;
18061
18673
 
18062
- forEach$2(properties, function(p) {
18674
+ forEach(properties, function(p) {
18063
18675
  var value = element.get(p.name),
18064
18676
  isReference = p.isReference,
18065
18677
  isMany = p.isMany;
@@ -18071,11 +18683,11 @@
18071
18683
  if (p.isBody) {
18072
18684
  body.push(new BodySerializer().build(p, value[0]));
18073
18685
  } else if (isSimple(p.type)) {
18074
- forEach$2(value, function(v) {
18686
+ forEach(value, function(v) {
18075
18687
  body.push(new ValueSerializer(self.addTagName(self.nsPropertyTagName(p))).build(p, v));
18076
18688
  });
18077
18689
  } else if (isReference) {
18078
- forEach$2(value, function(v) {
18690
+ forEach(value, function(v) {
18079
18691
  body.push(new ReferenceSerializer(self.addTagName(self.nsPropertyTagName(p))).build(v));
18080
18692
  });
18081
18693
  } else {
@@ -18084,7 +18696,7 @@
18084
18696
  // rather than element name
18085
18697
  var serialization = getSerialization(p);
18086
18698
 
18087
- forEach$2(value, function(v) {
18699
+ forEach(value, function(v) {
18088
18700
  var serializer;
18089
18701
 
18090
18702
  if (serialization) {
@@ -18196,7 +18808,7 @@
18196
18808
  var self = this,
18197
18809
  element = this.element;
18198
18810
 
18199
- forEach$2(properties, function(p) {
18811
+ forEach(properties, function(p) {
18200
18812
 
18201
18813
  var value = element.get(p.name);
18202
18814
 
@@ -18206,7 +18818,7 @@
18206
18818
  value = value.id;
18207
18819
  } else {
18208
18820
  var values = [];
18209
- forEach$2(value, function(v) {
18821
+ forEach(value, function(v) {
18210
18822
  values.push(v.id);
18211
18823
  });
18212
18824
 
@@ -18262,7 +18874,7 @@
18262
18874
  attrs = getNsAttrs(namespaces).concat(attrs);
18263
18875
  }
18264
18876
 
18265
- forEach$2(attrs, function(a) {
18877
+ forEach(attrs, function(a) {
18266
18878
  writer
18267
18879
  .append(' ')
18268
18880
  .append(nsName(a.name)).append('="').append(a.value).append('"');
@@ -18289,7 +18901,7 @@
18289
18901
  .indent();
18290
18902
  }
18291
18903
 
18292
- forEach$2(this.body, function(b) {
18904
+ forEach(this.body, function(b) {
18293
18905
  b.serializeTo(writer);
18294
18906
  });
18295
18907
 
@@ -18404,7 +19016,7 @@
18404
19016
  */
18405
19017
  function Writer(options) {
18406
19018
 
18407
- options = assign$2({ format: false, preamble: true }, options || {});
19019
+ options = assign({ format: false, preamble: true }, options || {});
18408
19020
 
18409
19021
  function toXML(tree, writer) {
18410
19022
  var internalWriter = writer || new SavingWriter();
@@ -18510,7 +19122,7 @@
18510
19122
  */
18511
19123
  BpmnModdle.prototype.fromXML = function(xmlStr, typeName, options) {
18512
19124
 
18513
- if (!isString(typeName)) {
19125
+ if (!isString$2(typeName)) {
18514
19126
  options = typeName;
18515
19127
  typeName = 'bpmn:Definitions';
18516
19128
  }
@@ -22222,7 +22834,7 @@
22222
22834
  function ensureCompatDiRef(businessObject) {
22223
22835
 
22224
22836
  // bpmnElement can have multiple independent DIs
22225
- if (!has$2(businessObject, 'di')) {
22837
+ if (!has$5(businessObject, 'di')) {
22226
22838
  Object.defineProperty(businessObject, 'di', {
22227
22839
  enumerable: false,
22228
22840
  get: function() {
@@ -22258,7 +22870,7 @@
22258
22870
  * @return {ModdleElement}
22259
22871
  */
22260
22872
  function findDisplayCandidate(definitions) {
22261
- return find(definitions.rootElements, function(e) {
22873
+ return find$2(definitions.rootElements, function(e) {
22262
22874
  return is(e, 'bpmn:Process') || is(e, 'bpmn:Collaboration');
22263
22875
  });
22264
22876
  }
@@ -22362,7 +22974,7 @@
22362
22974
  function handlePlane(plane) {
22363
22975
  registerDi(plane);
22364
22976
 
22365
- forEach$2(plane.planeElement, handlePlaneElement);
22977
+ forEach$5(plane.planeElement, handlePlaneElement);
22366
22978
  }
22367
22979
 
22368
22980
  function handlePlaneElement(planeElement) {
@@ -22480,7 +23092,7 @@
22480
23092
  // walk through all processes that have not yet been drawn and draw them
22481
23093
  // if they contain lanes with DI information.
22482
23094
  // we do this to pass the free-floating lane test cases in the MIWG test suite
22483
- var processes = filter(rootElements, function(e) {
23095
+ var processes = filter$2(rootElements, function(e) {
22484
23096
  return !isHandled(e) && is(e, 'bpmn:Process') && e.laneSets;
22485
23097
  });
22486
23098
 
@@ -22492,7 +23104,7 @@
22492
23104
  }
22493
23105
 
22494
23106
  function handleMessageFlows(messageFlows, context) {
22495
- forEach$2(messageFlows, contextual(handleMessageFlow, context));
23107
+ forEach$5(messageFlows, contextual(handleMessageFlow, context));
22496
23108
  }
22497
23109
 
22498
23110
  function handleDataAssociation(association, context) {
@@ -22518,7 +23130,7 @@
22518
23130
 
22519
23131
  function handleArtifacts(artifacts, context) {
22520
23132
 
22521
- forEach$2(artifacts, function(e) {
23133
+ forEach$5(artifacts, function(e) {
22522
23134
  if (is(e, 'bpmn:Association')) {
22523
23135
  deferred.push(function() {
22524
23136
  handleArtifact(e, context);
@@ -22535,8 +23147,8 @@
22535
23147
  return;
22536
23148
  }
22537
23149
 
22538
- forEach$2(ioSpecification.dataInputs, contextual(handleDataInput, context));
22539
- forEach$2(ioSpecification.dataOutputs, contextual(handleDataOutput, context));
23150
+ forEach$5(ioSpecification.dataInputs, contextual(handleDataInput, context));
23151
+ forEach$5(ioSpecification.dataOutputs, contextual(handleDataOutput, context));
22540
23152
  }
22541
23153
 
22542
23154
  var handleSubProcess = this.handleSubProcess = function handleSubProcess(subProcess, context) {
@@ -22563,8 +23175,8 @@
22563
23175
  // * bpmn:CatchEvent
22564
23176
  //
22565
23177
  deferred.push(function() {
22566
- forEach$2(flowNode.dataInputAssociations, contextual(handleDataAssociation, context));
22567
- forEach$2(flowNode.dataOutputAssociations, contextual(handleDataAssociation, context));
23178
+ forEach$5(flowNode.dataInputAssociations, contextual(handleDataAssociation, context));
23179
+ forEach$5(flowNode.dataOutputAssociations, contextual(handleDataAssociation, context));
22568
23180
  });
22569
23181
  }
22570
23182
 
@@ -22591,11 +23203,11 @@
22591
23203
  }
22592
23204
 
22593
23205
  function handleLaneSet(laneSet, context) {
22594
- forEach$2(laneSet.lanes, contextual(handleLane, context));
23206
+ forEach$5(laneSet.lanes, contextual(handleLane, context));
22595
23207
  }
22596
23208
 
22597
23209
  function handleLaneSets(laneSets, context) {
22598
- forEach$2(laneSets, contextual(handleLaneSet, context));
23210
+ forEach$5(laneSets, contextual(handleLaneSet, context));
22599
23211
  }
22600
23212
 
22601
23213
  function handleFlowElementsContainer(container, context) {
@@ -22607,7 +23219,7 @@
22607
23219
  }
22608
23220
 
22609
23221
  function handleFlowElements(flowElements, context) {
22610
- forEach$2(flowElements, function(flowElement) {
23222
+ forEach$5(flowElements, function(flowElement) {
22611
23223
  if (is(flowElement, 'bpmn:SequenceFlow')) {
22612
23224
  deferred.push(function() {
22613
23225
  handleSequenceFlow(flowElement, context);
@@ -22645,7 +23257,7 @@
22645
23257
 
22646
23258
  function handleCollaboration(collaboration, context) {
22647
23259
 
22648
- forEach$2(collaboration.participants, contextual(handleParticipant, context));
23260
+ forEach$5(collaboration.participants, contextual(handleParticipant, context));
22649
23261
 
22650
23262
  deferred.push(function() {
22651
23263
  handleMessageFlows(collaboration.messageFlows, context);
@@ -22658,7 +23270,7 @@
22658
23270
  function wireFlowNodeRefs(lane) {
22659
23271
 
22660
23272
  // wire the virtual flowNodeRefs <-> relationship
22661
- forEach$2(lane.flowNodeRef, function(flowNode) {
23273
+ forEach$5(lane.flowNodeRef, function(flowNode) {
22662
23274
  var lanes = flowNode.get('lanes');
22663
23275
 
22664
23276
  if (lanes) {
@@ -22736,7 +23348,7 @@
22736
23348
 
22737
23349
  // traverse BPMN 2.0 document model,
22738
23350
  // starting at definitions
22739
- forEach$2(diagramsToImport, function(diagram) {
23351
+ forEach$5(diagramsToImport, function(diagram) {
22740
23352
  walker.handleDefinitions(definitions, diagram);
22741
23353
  });
22742
23354
 
@@ -22802,12 +23414,12 @@
22802
23414
  if (is$1(rootElement, 'bpmn:Collaboration')) {
22803
23415
  collaboration = rootElement;
22804
23416
  } else {
22805
- collaboration = find(definitions.rootElements, function(element) {
23417
+ collaboration = find$2(definitions.rootElements, function(element) {
22806
23418
  if (!is$1(element, 'bpmn:Collaboration')) {
22807
23419
  return;
22808
23420
  }
22809
23421
 
22810
- return find(element.participants, function(participant) {
23422
+ return find$2(element.participants, function(participant) {
22811
23423
  return participant.processRef === rootElement;
22812
23424
  });
22813
23425
  });
@@ -22831,7 +23443,7 @@
22831
23443
  var diagramsToImport = [ bpmnDiagram ];
22832
23444
  var handledElements = [ bpmnElement ];
22833
23445
 
22834
- forEach$2(definitions.diagrams, function(diagram) {
23446
+ forEach$5(definitions.diagrams, function(diagram) {
22835
23447
 
22836
23448
  if (!diagram.plane) {
22837
23449
  return;
@@ -22855,7 +23467,7 @@
22855
23467
  function selfAndAllFlowElements(elements) {
22856
23468
  var result = [];
22857
23469
 
22858
- forEach$2(elements, function(element) {
23470
+ forEach$5(elements, function(element) {
22859
23471
  if (!element) {
22860
23472
  return;
22861
23473
  }
@@ -22951,11 +23563,11 @@
22951
23563
  function createLightbox() {
22952
23564
  lightbox = domify$1$1(LIGHTBOX_MARKUP);
22953
23565
 
22954
- assign$1(lightbox, LIGHTBOX_STYLES);
22955
- assign$1(query$1('svg', lightbox), LOGO_STYLES);
22956
- assign$1(query$1('.backdrop', lightbox), BACKDROP_STYLES);
22957
- assign$1(query$1('.notice', lightbox), NOTICE_STYLES);
22958
- assign$1(query$1('.link', lightbox), LINK_STYLES, {
23566
+ assign$4(lightbox, LIGHTBOX_STYLES);
23567
+ assign$4(query$1('svg', lightbox), LOGO_STYLES);
23568
+ assign$4(query$1('.backdrop', lightbox), BACKDROP_STYLES);
23569
+ assign$4(query$1('.notice', lightbox), NOTICE_STYLES);
23570
+ assign$4(query$1('.link', lightbox), LINK_STYLES, {
22959
23571
  'margin': '15px 20px 15px 10px',
22960
23572
  'alignSelf': 'center'
22961
23573
  });
@@ -23095,7 +23707,7 @@
23095
23707
  /**
23096
23708
  * @type {BaseViewerOptions}
23097
23709
  */
23098
- options = assign$2({}, DEFAULT_OPTIONS, options);
23710
+ options = assign$6({}, DEFAULT_OPTIONS, options);
23099
23711
 
23100
23712
  /**
23101
23713
  * @type {Moddle}
@@ -23639,8 +24251,8 @@
23639
24251
 
23640
24252
  const diagramModules = [].concat(staticModules, baseModules, additionalModules);
23641
24253
 
23642
- const diagramOptions = assign$2(omit(options, [ 'additionalModules' ]), {
23643
- canvas: assign$2({}, options.canvas, { container: container }),
24254
+ const diagramOptions = assign$6(omit(options, [ 'additionalModules' ]), {
24255
+ canvas: assign$6({}, options.canvas, { container: container }),
23644
24256
  modules: diagramModules
23645
24257
  });
23646
24258
 
@@ -23673,7 +24285,7 @@
23673
24285
 
23674
24286
  const container = domify$1$1('<div class="bjs-container"></div>');
23675
24287
 
23676
- assign$1(container, {
24288
+ assign$4(container, {
23677
24289
  width: ensureUnit(options.width),
23678
24290
  height: ensureUnit(options.height),
23679
24291
  position: options.position
@@ -23688,7 +24300,7 @@
23688
24300
  * @return {Moddle}
23689
24301
  */
23690
24302
  BaseViewer.prototype._createModdle = function(options) {
23691
- const moddleOptions = assign$2({}, this._moddleExtensions, options.moddleExtensions);
24303
+ const moddleOptions = assign$6({}, this._moddleExtensions, options.moddleExtensions);
23692
24304
 
23693
24305
  return new SimpleBpmnModdle(moddleOptions);
23694
24306
  };
@@ -23730,7 +24342,7 @@
23730
24342
  * Ensure the passed argument is a proper unit (defaulting to px)
23731
24343
  */
23732
24344
  function ensureUnit(val) {
23733
- return val + (isNumber(val) ? 'px' : '');
24345
+ return val + (isNumber$1(val) ? 'px' : '');
23734
24346
  }
23735
24347
 
23736
24348
 
@@ -23747,7 +24359,7 @@
23747
24359
  return null;
23748
24360
  }
23749
24361
 
23750
- return find(definitions.diagrams, function(element) {
24362
+ return find$2(definitions.diagrams, function(element) {
23751
24363
  return element.id === diagramId;
23752
24364
  }) || null;
23753
24365
  }
@@ -23774,8 +24386,8 @@
23774
24386
 
23775
24387
  const linkElement = domify$1$1(linkMarkup);
23776
24388
 
23777
- assign$1(query$1('svg', linkElement), LOGO_STYLES);
23778
- assign$1(linkElement, LINK_STYLES, {
24389
+ assign$4(query$1('svg', linkElement), LOGO_STYLES);
24390
+ assign$4(linkElement, LINK_STYLES, {
23779
24391
  position: 'absolute',
23780
24392
  bottom: '15px',
23781
24393
  right: '15px',
@@ -23862,6 +24474,7 @@
23862
24474
 
23863
24475
  var KEYS_COPY = [ 'c', 'C' ];
23864
24476
  var KEYS_PASTE = [ 'v', 'V' ];
24477
+ var KEYS_DUPLICATE = [ 'd', 'D' ];
23865
24478
  var KEYS_REDO = [ 'y', 'Y' ];
23866
24479
  var KEYS_UNDO = [ 'z', 'Z' ];
23867
24480
 
@@ -23896,7 +24509,7 @@
23896
24509
  * @return {boolean}
23897
24510
  */
23898
24511
  function isKey(keys, event) {
23899
- keys = isArray$3(keys) ? keys : [ keys ];
24512
+ keys = isArray$5(keys) ? keys : [ keys ];
23900
24513
 
23901
24514
  return keys.indexOf(event.key) !== -1 || keys.indexOf(event.code) !== -1;
23902
24515
  }
@@ -23922,6 +24535,13 @@
23922
24535
  return isCmd(event) && isKey(KEYS_PASTE, event);
23923
24536
  }
23924
24537
 
24538
+ /**
24539
+ * @param {KeyboardEvent} event
24540
+ */
24541
+ function isDuplicate(event) {
24542
+ return isCmd(event) && isKey(KEYS_DUPLICATE, event);
24543
+ }
24544
+
23925
24545
  /**
23926
24546
  * @param {KeyboardEvent} event
23927
24547
  */
@@ -24117,7 +24737,7 @@
24117
24737
  * @param {string} [type='keyboard.keydown']
24118
24738
  */
24119
24739
  Keyboard.prototype.addListener = function(priority, listener, type) {
24120
- if (isFunction(priority)) {
24740
+ if (isFunction$1(priority)) {
24121
24741
  type = listener;
24122
24742
  listener = priority;
24123
24743
  priority = DEFAULT_PRIORITY;
@@ -24247,6 +24867,20 @@
24247
24867
  }
24248
24868
  });
24249
24869
 
24870
+ // duplicate
24871
+ // CTRL/CMD + D
24872
+ addListener('duplicate', function(context) {
24873
+
24874
+ var event = context.keyEvent;
24875
+
24876
+ if (isDuplicate(event)) {
24877
+ editorActions.trigger('duplicate');
24878
+
24879
+ return true;
24880
+ }
24881
+ });
24882
+
24883
+
24250
24884
  // zoom in one step
24251
24885
  // CTRL/CMD + +
24252
24886
  addListener('stepZoom', function(context) {
@@ -24339,7 +24973,7 @@
24339
24973
 
24340
24974
  var self = this;
24341
24975
 
24342
- this._config = assign$2({}, DEFAULT_CONFIG, config || {});
24976
+ this._config = assign$5({}, DEFAULT_CONFIG, config || {});
24343
24977
 
24344
24978
  keyboard.addListener(arrowsListener);
24345
24979
 
@@ -24729,7 +25363,7 @@
24729
25363
  this._canvas = canvas;
24730
25364
  this._container = canvas._container;
24731
25365
 
24732
- this._handleWheel = bind$3(this._handleWheel, this);
25366
+ this._handleWheel = bind$4(this._handleWheel, this);
24733
25367
 
24734
25368
  this._totalDelta = 0;
24735
25369
  this._scale = config.scale || DEFAULT_SCALE;
@@ -25773,6 +26407,29 @@
25773
26407
  type: "String"
25774
26408
  }
25775
26409
  ]
26410
+ },
26411
+ {
26412
+ name: "ConditionalFilter",
26413
+ superClass: [
26414
+ "Element"
26415
+ ],
26416
+ meta: {
26417
+ allowedIn: [
26418
+ "bpmn:ConditionalEventDefinition"
26419
+ ]
26420
+ },
26421
+ properties: [
26422
+ {
26423
+ name: "variableNames",
26424
+ isAttr: true,
26425
+ type: "String"
26426
+ },
26427
+ {
26428
+ name: "variableEvents",
26429
+ isAttr: true,
26430
+ type: "String"
26431
+ }
26432
+ ]
25776
26433
  }
25777
26434
  ];
25778
26435
  var zeebeModdle = {
@@ -25784,6 +26441,17 @@
25784
26441
  types: types
25785
26442
  };
25786
26443
 
26444
+ /**
26445
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
26446
+ * under one or more contributor license agreements. See the NOTICE file
26447
+ * distributed with this work for additional information regarding copyright
26448
+ * ownership.
26449
+ *
26450
+ * Camunda licenses this file to you under the MIT; you may not use this file
26451
+ * except in compliance with the MIT License.
26452
+ */
26453
+
26454
+
25787
26455
  const commonModules = [
25788
26456
  iconRendererModule
25789
26457
  ];
@@ -25797,6 +26465,17 @@
25797
26465
  zeebe: zeebeModdle
25798
26466
  };
25799
26467
 
26468
+ /**
26469
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
26470
+ * under one or more contributor license agreements. See the NOTICE file
26471
+ * distributed with this work for additional information regarding copyright
26472
+ * ownership.
26473
+ *
26474
+ * Camunda licenses this file to you under the MIT; you may not use this file
26475
+ * except in compliance with the MIT License.
26476
+ */
26477
+
26478
+
25800
26479
  /**
25801
26480
  * @typedef {import('bpmn-js/lib/BaseViewer').BaseViewerOptions} BaseViewerOptions
25802
26481
  */