@metadev/daga 4.0.2 → 4.2.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.
package/index.esm.js CHANGED
@@ -804,7 +804,7 @@ const numberOfColumns = s => {
804
804
  };
805
805
  const numberOfRows = s => {
806
806
  var _a;
807
- return ((_a = s.match(/\n/g)) === null || _a === undefined ? undefined : _a.length) || 0;
807
+ return ((_a = s.match(/\n/g)) === null || _a === void 0 ? void 0 : _a.length) || 0;
808
808
  };
809
809
 
810
810
  /******************************************************************************
@@ -1030,14 +1030,14 @@ class DiagramElement {
1030
1030
  */
1031
1031
  get highlighted() {
1032
1032
  var _a, _b;
1033
- return ((_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.userHighlight) === null || _b === undefined ? undefined : _b.contains(this.id)) || false;
1033
+ return ((_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userHighlight) === null || _b === void 0 ? void 0 : _b.contains(this.id)) || false;
1034
1034
  }
1035
1035
  /**
1036
1036
  * Whether this diagram element is currently in the user selection.
1037
1037
  */
1038
1038
  get selected() {
1039
1039
  var _a, _b;
1040
- return ((_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.userSelection) === null || _b === undefined ? undefined : _b.contains(this.id)) || false;
1040
+ return ((_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userSelection) === null || _b === void 0 ? void 0 : _b.contains(this.id)) || false;
1041
1041
  }
1042
1042
  constructor(model, id) {
1043
1043
  /**
@@ -1066,7 +1066,7 @@ class DiagramElement {
1066
1066
  */
1067
1067
  select() {
1068
1068
  var _a, _b;
1069
- return (_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.selectCanvasView()) === null || _b === undefined ? undefined : _b.select(`[id='${escapeSelector(this.id)}']`);
1069
+ return (_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.selectCanvasView()) === null || _b === void 0 ? void 0 : _b.select(`[id='${escapeSelector(this.id)}']`);
1070
1070
  }
1071
1071
  }
1072
1072
  class DiagramElementSet extends DiagramEntitySet {
@@ -1464,7 +1464,7 @@ class ValueSet {
1464
1464
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1465
1465
  getValue(key) {
1466
1466
  var _a;
1467
- const rootAttribute = (_a = this.propertySet.getProperty(key)) === null || _a === undefined ? undefined : _a.rootAttribute;
1467
+ const rootAttribute = (_a = this.propertySet.getProperty(key)) === null || _a === void 0 ? void 0 : _a.rootAttribute;
1468
1468
  if (rootAttribute !== undefined && rootAttribute !== null) {
1469
1469
  this.values[key] = this.getRootElementValue(rootAttribute);
1470
1470
  }
@@ -1549,7 +1549,7 @@ class ValueSet {
1549
1549
  if (property && property.type === Type.Object) {
1550
1550
  return this.getSubValueSet(key).hasAnySetValue();
1551
1551
  }
1552
- return !empty(value) && !equals(value, property === null || property === undefined ? undefined : property.defaultValue);
1552
+ return !empty(value) && !equals(value, property === null || property === void 0 ? void 0 : property.defaultValue);
1553
1553
  }
1554
1554
  /**
1555
1555
  * Checks if any of the values in the set are not empty or the default value.
@@ -1670,10 +1670,8 @@ class ValueSet {
1670
1670
  this.values[key] = structuredClone(property.defaultValue);
1671
1671
  }
1672
1672
  if (rootAttribute !== undefined && rootAttribute !== null) {
1673
- if (property.defaultValue !== undefined && !equals(this.values[key], property.defaultValue)) {
1673
+ if (property.defaultValue !== undefined && !equals(this.getRootElementValue(rootAttribute), property.defaultValue)) {
1674
1674
  this.setRootElementValue(rootAttribute, this.values[key]);
1675
- } else {
1676
- this.values[key] = this.getRootElementValue(rootAttribute);
1677
1675
  }
1678
1676
  }
1679
1677
  if (property.basic) {
@@ -1818,7 +1816,7 @@ class DiagramConnection extends DiagramElement {
1818
1816
  }
1819
1817
  set type(type) {
1820
1818
  var _a, _b;
1821
- (_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.userSelection) === null || _b === undefined ? undefined : _b.openInPropertyEditor(undefined);
1819
+ (_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userSelection) === null || _b === void 0 ? void 0 : _b.openInPropertyEditor(undefined);
1822
1820
  this._type = type;
1823
1821
  if (this.valueSet) {
1824
1822
  this.valueSet = new ValueSet(type.propertySet, this);
@@ -2007,11 +2005,11 @@ class DiagramConnection extends DiagramElement {
2007
2005
  }
2008
2006
  updateInView() {
2009
2007
  var _a;
2010
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateConnectionsInView(this.id);
2008
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateConnectionsInView(this.id);
2011
2009
  }
2012
2010
  raise() {
2013
2011
  var _a;
2014
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
2012
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
2015
2013
  }
2016
2014
  /**
2017
2015
  * Set the start of this connection to the given port or reset this connection's starting port if `undefined`.
@@ -2027,12 +2025,12 @@ class DiagramConnection extends DiagramElement {
2027
2025
  this.start = start;
2028
2026
  if (start !== undefined) {
2029
2027
  start.outgoingConnections.push(this);
2030
- this.startDirection = start === null || start === undefined ? undefined : start.direction;
2031
- this.startCoords = (start === null || start === undefined ? undefined : start.connectionPoint) || [0, 0];
2028
+ this.startDirection = start === null || start === void 0 ? void 0 : start.direction;
2029
+ this.startCoords = (start === null || start === void 0 ? void 0 : start.connectionPoint) || [0, 0];
2032
2030
  }
2033
2031
  } else {
2034
- this.startDirection = start === null || start === undefined ? undefined : start.direction;
2035
- this.startCoords = (start === null || start === undefined ? undefined : start.connectionPoint) || [0, 0];
2032
+ this.startDirection = start === null || start === void 0 ? void 0 : start.direction;
2033
+ this.startCoords = (start === null || start === void 0 ? void 0 : start.connectionPoint) || [0, 0];
2036
2034
  }
2037
2035
  this.updateInView();
2038
2036
  }
@@ -2050,12 +2048,12 @@ class DiagramConnection extends DiagramElement {
2050
2048
  this.end = end;
2051
2049
  if (end !== undefined) {
2052
2050
  end.incomingConnections.push(this);
2053
- this.endDirection = end === null || end === undefined ? undefined : end.direction;
2054
- this.endCoords = (end === null || end === undefined ? undefined : end.connectionPoint) || [0, 0];
2051
+ this.endDirection = end === null || end === void 0 ? void 0 : end.direction;
2052
+ this.endCoords = (end === null || end === void 0 ? void 0 : end.connectionPoint) || [0, 0];
2055
2053
  }
2056
2054
  } else {
2057
- this.endDirection = end === null || end === undefined ? undefined : end.direction;
2058
- this.endCoords = (end === null || end === undefined ? undefined : end.connectionPoint) || [0, 0];
2055
+ this.endDirection = end === null || end === void 0 ? void 0 : end.direction;
2056
+ this.endCoords = (end === null || end === void 0 ? void 0 : end.connectionPoint) || [0, 0];
2059
2057
  }
2060
2058
  this.updateInView();
2061
2059
  }
@@ -2066,7 +2064,7 @@ class DiagramConnection extends DiagramElement {
2066
2064
  */
2067
2065
  tighten() {
2068
2066
  var _a, _b;
2069
- if (((_a = this.start) === null || _a === undefined ? undefined : _a.rootElement) && this.end) {
2067
+ if (((_a = this.start) === null || _a === void 0 ? void 0 : _a.rootElement) && this.end) {
2070
2068
  const alternativeStartPortsSortedByDistanceAscending = this.start.rootElement.ports.map(p => [p, p.distanceTo(this.end.coords)]).sort((a, b) => a[1] - b[1]).map(a => a[0]);
2071
2069
  checkAlternativeStartPorts: for (const alternativeStartPort of alternativeStartPortsSortedByDistanceAscending) {
2072
2070
  if (alternativeStartPort === this.end) {
@@ -2100,7 +2098,7 @@ class DiagramConnection extends DiagramElement {
2100
2098
  }
2101
2099
  }
2102
2100
  }
2103
- if (((_b = this.end) === null || _b === undefined ? undefined : _b.rootElement) && this.start) {
2101
+ if (((_b = this.end) === null || _b === void 0 ? void 0 : _b.rootElement) && this.start) {
2104
2102
  const alternativeEndPortsSortedByDistanceAscending = this.end.rootElement.ports.map(p => [p, p.distanceTo(this.start.coords)]).sort((a, b) => a[1] - b[1]).map(a => a[0]);
2105
2103
  checkAlternativeEndPorts: for (const alternativeEndPort of alternativeEndPortsSortedByDistanceAscending) {
2106
2104
  if (alternativeEndPort === this.start) {
@@ -2196,8 +2194,8 @@ class DiagramConnectionSet extends DiagramElementSet {
2196
2194
  const connection = this.get(id, true);
2197
2195
  if (connection) {
2198
2196
  // remove from ports
2199
- removeIfExists(((_a = connection.start) === null || _a === undefined ? undefined : _a.outgoingConnections) || [], connection);
2200
- removeIfExists(((_b = connection.end) === null || _b === undefined ? undefined : _b.incomingConnections) || [], connection);
2197
+ removeIfExists(((_a = connection.start) === null || _a === void 0 ? void 0 : _a.outgoingConnections) || [], connection);
2198
+ removeIfExists(((_b = connection.end) === null || _b === void 0 ? void 0 : _b.incomingConnections) || [], connection);
2201
2199
  // remove from set of connections
2202
2200
  super.remove(id);
2203
2201
  // remove from canvas
@@ -2221,6 +2219,7 @@ const DIAGRAM_FIELD_DEFAULTS = {
2221
2219
  selectedColor: '#000000',
2222
2220
  horizontalAlign: HorizontalAlign.Center,
2223
2221
  verticalAlign: VerticalAlign.Center,
2222
+ orientation: Side.Top,
2224
2223
  fit: false
2225
2224
  };
2226
2225
  /**
@@ -2240,17 +2239,17 @@ class DiagramField extends DiagramElement {
2240
2239
  }
2241
2240
  set text(value) {
2242
2241
  var _a;
2243
- if (value === null || value === undefined || (value === null || value === undefined ? undefined : value.trim()) === '') {
2242
+ if (value === null || value === undefined || (value === null || value === void 0 ? void 0 : value.trim()) === '') {
2244
2243
  value = this.defaultText;
2245
2244
  }
2246
2245
  this._text = value;
2247
2246
  this.updateInView();
2248
2247
  if (this.fit) {
2249
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.fitFieldRootInView(this.id);
2248
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.fitFieldRootInView(this.id);
2250
2249
  }
2251
2250
  }
2252
- constructor(model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, text, editable, fit) {
2253
- const id = `${rootElement === null || rootElement === undefined ? undefined : rootElement.id}_field`;
2251
+ constructor(model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, orientation, text, editable, fit) {
2252
+ const id = `${rootElement === null || rootElement === void 0 ? void 0 : rootElement.id}_field`;
2254
2253
  if (model.fields.get(id) !== undefined) {
2255
2254
  throw new Error('DiagramField for rootElement already exists');
2256
2255
  }
@@ -2270,6 +2269,7 @@ class DiagramField extends DiagramElement {
2270
2269
  this.selectedColor = selectedColor;
2271
2270
  this.horizontalAlign = horizontalAlign;
2272
2271
  this.verticalAlign = verticalAlign;
2272
+ this.orientation = orientation;
2273
2273
  this.defaultText = text;
2274
2274
  this._text = text;
2275
2275
  this.editable = editable;
@@ -2280,11 +2280,11 @@ class DiagramField extends DiagramElement {
2280
2280
  }
2281
2281
  updateInView() {
2282
2282
  var _a;
2283
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateFieldsInView(this.id);
2283
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateFieldsInView(this.id);
2284
2284
  }
2285
2285
  raise() {
2286
2286
  var _a;
2287
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
2287
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
2288
2288
  }
2289
2289
  /**
2290
2290
  * Change the coordinates of this field to the given coordinates.
@@ -2297,7 +2297,7 @@ class DiagramField extends DiagramElement {
2297
2297
  }
2298
2298
  getPriority() {
2299
2299
  var _a;
2300
- return ((_a = this.rootElement) === null || _a === undefined ? undefined : _a.getPriority()) || DEFAULT_PRIORITY;
2300
+ return ((_a = this.rootElement) === null || _a === void 0 ? void 0 : _a.getPriority()) || DEFAULT_PRIORITY;
2301
2301
  }
2302
2302
  }
2303
2303
  class DiagramFieldSet extends DiagramElementSet {
@@ -2313,8 +2313,8 @@ class DiagramFieldSet extends DiagramElementSet {
2313
2313
  * Instance a new field and add it to this set. This method is normally called when instancing an element with a field and it is rarely called by itself.
2314
2314
  * @private
2315
2315
  */
2316
- new(rootElement, coords, fontSize, fontFamily, color, selectedColor, width, height, horizontalAlign, verticalAlign, text, editable, fit) {
2317
- const field = new DiagramField(this.model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, text, editable, fit);
2316
+ new(rootElement, coords, fontSize, fontFamily, color, selectedColor, width, height, horizontalAlign, verticalAlign, orientation, text, editable, fit) {
2317
+ const field = new DiagramField(this.model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, orientation, text, editable, fit);
2318
2318
  super.add(field);
2319
2319
  field.updateInView();
2320
2320
  // add this field to its root element
@@ -2328,7 +2328,7 @@ class DiagramFieldSet extends DiagramElementSet {
2328
2328
  const field = this.get(id, true);
2329
2329
  if (field) {
2330
2330
  // remove from root element
2331
- if (((_a = field.rootElement) === null || _a === undefined ? undefined : _a.label) !== undefined) {
2331
+ if (((_a = field.rootElement) === null || _a === void 0 ? void 0 : _a.label) !== undefined) {
2332
2332
  if (field.rootElement.label === field) {
2333
2333
  field.rootElement.label = undefined;
2334
2334
  }
@@ -2341,7 +2341,7 @@ class DiagramFieldSet extends DiagramElementSet {
2341
2341
  }
2342
2342
  }
2343
2343
  const getBottomMargin = config => {
2344
- if ((config === null || config === undefined ? undefined : config.margin) === null || (config === null || config === undefined ? undefined : config.margin) === undefined) {
2344
+ if ((config === null || config === void 0 ? void 0 : config.margin) === null || (config === null || config === void 0 ? void 0 : config.margin) === undefined) {
2345
2345
  return DIAGRAM_FIELD_DEFAULTS.margin;
2346
2346
  } else if (typeof config.margin === 'number') {
2347
2347
  return config.margin;
@@ -2360,7 +2360,7 @@ const getBottomMargin = config => {
2360
2360
  }
2361
2361
  };
2362
2362
  const getLeftMargin = config => {
2363
- if ((config === null || config === undefined ? undefined : config.margin) === null || (config === null || config === undefined ? undefined : config.margin) === undefined) {
2363
+ if ((config === null || config === void 0 ? void 0 : config.margin) === null || (config === null || config === void 0 ? void 0 : config.margin) === undefined) {
2364
2364
  return DIAGRAM_FIELD_DEFAULTS.margin;
2365
2365
  } else if (typeof config.margin === 'number') {
2366
2366
  return config.margin;
@@ -2379,7 +2379,7 @@ const getLeftMargin = config => {
2379
2379
  }
2380
2380
  };
2381
2381
  const getRightMargin = config => {
2382
- if ((config === null || config === undefined ? undefined : config.margin) === null || (config === null || config === undefined ? undefined : config.margin) === undefined) {
2382
+ if ((config === null || config === void 0 ? void 0 : config.margin) === null || (config === null || config === void 0 ? void 0 : config.margin) === undefined) {
2383
2383
  return DIAGRAM_FIELD_DEFAULTS.margin;
2384
2384
  } else if (typeof config.margin === 'number') {
2385
2385
  return config.margin;
@@ -2398,7 +2398,7 @@ const getRightMargin = config => {
2398
2398
  }
2399
2399
  };
2400
2400
  const getTopMargin = config => {
2401
- if ((config === null || config === undefined ? undefined : config.margin) === null || (config === null || config === undefined ? undefined : config.margin) === undefined) {
2401
+ if ((config === null || config === void 0 ? void 0 : config.margin) === null || (config === null || config === void 0 ? void 0 : config.margin) === undefined) {
2402
2402
  return DIAGRAM_FIELD_DEFAULTS.margin;
2403
2403
  } else if (typeof config.margin === 'number') {
2404
2404
  return config.margin;
@@ -2417,7 +2417,7 @@ const getTopMargin = config => {
2417
2417
  }
2418
2418
  };
2419
2419
  const getBottomPadding$1 = config => {
2420
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
2420
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
2421
2421
  return DIAGRAM_FIELD_DEFAULTS.padding;
2422
2422
  } else if (typeof config.padding === 'number') {
2423
2423
  return config.padding;
@@ -2436,7 +2436,7 @@ const getBottomPadding$1 = config => {
2436
2436
  }
2437
2437
  };
2438
2438
  const getLeftPadding$1 = config => {
2439
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
2439
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
2440
2440
  return DIAGRAM_FIELD_DEFAULTS.padding;
2441
2441
  } else if (typeof config.padding === 'number') {
2442
2442
  return config.padding;
@@ -2455,7 +2455,7 @@ const getLeftPadding$1 = config => {
2455
2455
  }
2456
2456
  };
2457
2457
  const getRightPadding$1 = config => {
2458
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
2458
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
2459
2459
  return DIAGRAM_FIELD_DEFAULTS.padding;
2460
2460
  } else if (typeof config.padding === 'number') {
2461
2461
  return config.padding;
@@ -2474,7 +2474,7 @@ const getRightPadding$1 = config => {
2474
2474
  }
2475
2475
  };
2476
2476
  const getTopPadding$1 = config => {
2477
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
2477
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
2478
2478
  return DIAGRAM_FIELD_DEFAULTS.padding;
2479
2479
  } else if (typeof config.padding === 'number') {
2480
2480
  return config.padding;
@@ -2566,7 +2566,7 @@ class DiagramSection extends DiagramElement {
2566
2566
  */
2567
2567
  get name() {
2568
2568
  var _a;
2569
- return ((_a = this.label) === null || _a === undefined ? undefined : _a.text) || '';
2569
+ return ((_a = this.label) === null || _a === void 0 ? void 0 : _a.text) || '';
2570
2570
  }
2571
2571
  set name(name) {
2572
2572
  if (this.label) {
@@ -2581,15 +2581,15 @@ class DiagramSection extends DiagramElement {
2581
2581
  var _a, _b, _c, _d, _e, _f, _g, _h;
2582
2582
  if (this.selected) {
2583
2583
  if (this.highlighted) {
2584
- return this._selectedAndHighlightedLook !== undefined ? this._selectedAndHighlightedLook : ((_a = this.type) === null || _a === undefined ? undefined : _a.selectedAndHighlightedLook) || ((_b = this.node) === null || _b === undefined ? undefined : _b.look);
2584
+ return this._selectedAndHighlightedLook !== undefined ? this._selectedAndHighlightedLook : ((_a = this.type) === null || _a === void 0 ? void 0 : _a.selectedAndHighlightedLook) || ((_b = this.node) === null || _b === void 0 ? void 0 : _b.look);
2585
2585
  } else {
2586
- return this._selectedLook !== undefined ? this._selectedLook : ((_c = this.type) === null || _c === undefined ? undefined : _c.selectedLook) || ((_d = this.node) === null || _d === undefined ? undefined : _d.look);
2586
+ return this._selectedLook !== undefined ? this._selectedLook : ((_c = this.type) === null || _c === void 0 ? void 0 : _c.selectedLook) || ((_d = this.node) === null || _d === void 0 ? void 0 : _d.look);
2587
2587
  }
2588
2588
  } else {
2589
2589
  if (this.highlighted) {
2590
- return this._highlightedLook !== undefined ? this._highlightedLook : ((_e = this.type) === null || _e === undefined ? undefined : _e.highlightedLook) || ((_f = this.node) === null || _f === undefined ? undefined : _f.look);
2590
+ return this._highlightedLook !== undefined ? this._highlightedLook : ((_e = this.type) === null || _e === void 0 ? void 0 : _e.highlightedLook) || ((_f = this.node) === null || _f === void 0 ? void 0 : _f.look);
2591
2591
  } else {
2592
- return this._defaultLook !== undefined ? this._defaultLook : ((_g = this.type) === null || _g === undefined ? undefined : _g.defaultLook) || ((_h = this.node) === null || _h === undefined ? undefined : _h.look);
2592
+ return this._defaultLook !== undefined ? this._defaultLook : ((_g = this.type) === null || _g === void 0 ? void 0 : _g.defaultLook) || ((_h = this.node) === null || _h === void 0 ? void 0 : _h.look);
2593
2593
  }
2594
2594
  }
2595
2595
  }
@@ -2642,11 +2642,11 @@ class DiagramSection extends DiagramElement {
2642
2642
  }
2643
2643
  updateInView() {
2644
2644
  var _a;
2645
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateSectionsInView(this.id);
2645
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateSectionsInView(this.id);
2646
2646
  }
2647
2647
  raise() {
2648
2648
  var _a;
2649
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
2649
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
2650
2650
  if (this.label) {
2651
2651
  this.label.raise();
2652
2652
  }
@@ -2659,19 +2659,19 @@ class DiagramSection extends DiagramElement {
2659
2659
  }
2660
2660
  get type() {
2661
2661
  var _a, _b, _c, _d, _e;
2662
- return (_e = (_d = (_c = (_b = (_a = this.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.sectionGrid) === null || _c === undefined ? undefined : _c.sections) === null || _d === undefined ? undefined : _d[this.indexYInNode]) === null || _e === undefined ? undefined : _e[this.indexXInNode];
2662
+ return (_e = (_d = (_c = (_b = (_a = this.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.sectionGrid) === null || _c === void 0 ? void 0 : _c.sections) === null || _d === void 0 ? void 0 : _d[this.indexYInNode]) === null || _e === void 0 ? void 0 : _e[this.indexXInNode];
2663
2663
  }
2664
2664
  getMinWidth() {
2665
2665
  var _a, _b, _c, _d;
2666
- return ((_d = (_c = (_b = (_a = this.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.sectionGrid) === null || _c === undefined ? undefined : _c.minWidths) === null || _d === undefined ? undefined : _d[this.indexXInNode]) || DIAGRAM_SECTION_MIN_WIDTH;
2666
+ return ((_d = (_c = (_b = (_a = this.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.sectionGrid) === null || _c === void 0 ? void 0 : _c.minWidths) === null || _d === void 0 ? void 0 : _d[this.indexXInNode]) || DIAGRAM_SECTION_MIN_WIDTH;
2667
2667
  }
2668
2668
  getMinHeight() {
2669
2669
  var _a, _b, _c, _d;
2670
- return ((_d = (_c = (_b = (_a = this.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.sectionGrid) === null || _c === undefined ? undefined : _c.minHeights) === null || _d === undefined ? undefined : _d[this.indexYInNode]) || DIAGRAM_SECTION_MIN_HEIGHT;
2670
+ return ((_d = (_c = (_b = (_a = this.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.sectionGrid) === null || _c === void 0 ? void 0 : _c.minHeights) === null || _d === void 0 ? void 0 : _d[this.indexYInNode]) || DIAGRAM_SECTION_MIN_HEIGHT;
2671
2671
  }
2672
2672
  getPriority() {
2673
2673
  var _a, _b, _c, _d, _e, _f;
2674
- return ((_f = (_e = (_d = (_c = (_b = (_a = this.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.sectionGrid) === null || _c === undefined ? undefined : _c.sections) === null || _d === undefined ? undefined : _d[this.indexYInNode]) === null || _e === undefined ? undefined : _e[this.indexXInNode]) === null || _f === undefined ? undefined : _f.priority) || DEFAULT_PRIORITY;
2674
+ return ((_f = (_e = (_d = (_c = (_b = (_a = this.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.sectionGrid) === null || _c === void 0 ? void 0 : _c.sections) === null || _d === void 0 ? void 0 : _d[this.indexYInNode]) === null || _e === void 0 ? void 0 : _e[this.indexXInNode]) === null || _f === void 0 ? void 0 : _f.priority) || DEFAULT_PRIORITY;
2675
2675
  }
2676
2676
  /**
2677
2677
  * Get the port of this section which is closest to the given coordinates.
@@ -2836,9 +2836,9 @@ class DiagramSection extends DiagramElement {
2836
2836
  // Set label's dimensions as a function of ours.
2837
2837
  const type = this.type;
2838
2838
  if (this.label) {
2839
- this.label.coords = [this.coords[0] + getLeftMargin(type === null || type === undefined ? undefined : type.label), this.coords[1] + getTopMargin(type === null || type === undefined ? undefined : type.label)];
2840
- this.label.width = this.width - getLeftMargin(type === null || type === undefined ? undefined : type.label) - getRightMargin(type === null || type === undefined ? undefined : type.label);
2841
- this.label.height = this.height - getTopMargin(type === null || type === undefined ? undefined : type.label) - getBottomMargin(type === null || type === undefined ? undefined : type.label);
2839
+ this.label.coords = [this.coords[0] + getLeftMargin(type === null || type === void 0 ? void 0 : type.label), this.coords[1] + getTopMargin(type === null || type === void 0 ? void 0 : type.label)];
2840
+ this.label.width = this.width - getLeftMargin(type === null || type === void 0 ? void 0 : type.label) - getRightMargin(type === null || type === void 0 ? void 0 : type.label);
2841
+ this.label.height = this.height - getTopMargin(type === null || type === void 0 ? void 0 : type.label) - getBottomMargin(type === null || type === void 0 ? void 0 : type.label);
2842
2842
  this.label.updateInView();
2843
2843
  }
2844
2844
  // Move decorators to match the new coords.
@@ -2872,13 +2872,13 @@ class DiagramSectionSet extends DiagramElementSet {
2872
2872
  node.sections.push(section);
2873
2873
  node.updateInView();
2874
2874
  // add section ports
2875
- const sectionPorts = (_d = (_c = (_b = (_a = node.type.sectionGrid) === null || _a === undefined ? undefined : _a.sections) === null || _b === undefined ? undefined : _b[indexYInNode]) === null || _c === undefined ? undefined : _c[indexXInNode]) === null || _d === undefined ? undefined : _d.ports;
2875
+ const sectionPorts = (_d = (_c = (_b = (_a = node.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.sections) === null || _b === void 0 ? void 0 : _b[indexYInNode]) === null || _c === void 0 ? void 0 : _c[indexXInNode]) === null || _d === void 0 ? void 0 : _d.ports;
2876
2876
  if (sectionPorts && sectionPorts.length > 0) {
2877
2877
  for (let i = 0; i < sectionPorts.length; ++i) {
2878
2878
  const portConfig = sectionPorts[i];
2879
- const port = this.model.ports.new(portConfig.type !== undefined ? this.model.ports.types.get(portConfig.type) : undefined, section, [section.coords[0] + (portConfig.coords[0] || 0), section.coords[1] + (portConfig.coords[1] || 0)], portConfig.connectionPoint !== undefined ? [section.coords[0] + (portConfig.connectionPoint[0] || 0), section.coords[1] + (portConfig.connectionPoint[1] || 0)] : undefined, portConfig === null || portConfig === undefined ? undefined : portConfig.direction, `${section.id}_${i}`);
2880
- if ((_e = port.type) === null || _e === undefined ? undefined : _e.label) {
2881
- const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === undefined ? undefined : _f.label);
2879
+ const port = this.model.ports.new(portConfig.type !== undefined ? this.model.ports.types.get(portConfig.type) : undefined, section, [section.coords[0] + (portConfig.coords[0] || 0), section.coords[1] + (portConfig.coords[1] || 0)], portConfig.connectionPoint !== undefined ? [section.coords[0] + (portConfig.connectionPoint[0] || 0), section.coords[1] + (portConfig.connectionPoint[1] || 0)] : undefined, portConfig === null || portConfig === void 0 ? void 0 : portConfig.direction, `${section.id}_${i}`);
2880
+ if ((_e = port.type) === null || _e === void 0 ? void 0 : _e.label) {
2881
+ const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === void 0 ? void 0 : _f.label);
2882
2882
  const labelWidth = 6 * labelConfiguration.fontSize + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
2883
2883
  const labelHeight = labelConfiguration.fontSize + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
2884
2884
  let labelCoords;
@@ -2894,15 +2894,15 @@ class DiagramSectionSet extends DiagramElementSet {
2894
2894
  default:
2895
2895
  labelCoords = port.coords;
2896
2896
  }
2897
- this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
2897
+ this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit);
2898
2898
  }
2899
2899
  }
2900
2900
  }
2901
2901
  // add section label
2902
- const sectionLabel = (_k = (_j = (_h = (_g = node.type.sectionGrid) === null || _g === undefined ? undefined : _g.sections) === null || _h === undefined ? undefined : _h[indexYInNode]) === null || _j === undefined ? undefined : _j[indexXInNode]) === null || _k === undefined ? undefined : _k.label;
2902
+ const sectionLabel = (_k = (_j = (_h = (_g = node.type.sectionGrid) === null || _g === void 0 ? void 0 : _g.sections) === null || _h === void 0 ? void 0 : _h[indexYInNode]) === null || _j === void 0 ? void 0 : _j[indexXInNode]) === null || _k === void 0 ? void 0 : _k.label;
2903
2903
  if (sectionLabel) {
2904
2904
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), sectionLabel);
2905
- this.model.fields.new(section, [section.coords[0] + getLeftMargin(labelConfiguration), section.coords[1] + getTopMargin(labelConfiguration)], labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, section.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), section.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
2905
+ this.model.fields.new(section, [section.coords[0] + getLeftMargin(labelConfiguration), section.coords[1] + getTopMargin(labelConfiguration)], labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, section.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), section.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit);
2906
2906
  }
2907
2907
  return section;
2908
2908
  }
@@ -3006,7 +3006,7 @@ class DiagramNodeType {
3006
3006
  this.canBeParentless = values.canBeParentless;
3007
3007
  this.childrenTypes = values.childrenTypes;
3008
3008
  this.priority = values.priority;
3009
- this.propertySet = new PropertySet((options === null || options === undefined ? undefined : options.properties) || []);
3009
+ this.propertySet = new PropertySet((options === null || options === void 0 ? void 0 : options.properties) || []);
3010
3010
  }
3011
3011
  }
3012
3012
  /**
@@ -3022,7 +3022,7 @@ class DiagramNode extends DiagramElement {
3022
3022
  }
3023
3023
  set type(type) {
3024
3024
  var _a, _b;
3025
- (_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.userSelection) === null || _b === undefined ? undefined : _b.openInPropertyEditor(undefined);
3025
+ (_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userSelection) === null || _b === void 0 ? void 0 : _b.openInPropertyEditor(undefined);
3026
3026
  this._type = type;
3027
3027
  if (this.valueSet) {
3028
3028
  this.valueSet = new ValueSet(type.propertySet, this);
@@ -3044,7 +3044,7 @@ class DiagramNode extends DiagramElement {
3044
3044
  */
3045
3045
  get name() {
3046
3046
  var _a;
3047
- return ((_a = this.label) === null || _a === undefined ? undefined : _a.text) || '';
3047
+ return ((_a = this.label) === null || _a === void 0 ? void 0 : _a.text) || '';
3048
3048
  }
3049
3049
  set name(name) {
3050
3050
  if (this.label) {
@@ -3134,20 +3134,20 @@ class DiagramNode extends DiagramElement {
3134
3134
  }
3135
3135
  updateInView() {
3136
3136
  var _a;
3137
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateNodesInView(this.id);
3137
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateNodesInView(this.id);
3138
3138
  }
3139
3139
  raise() {
3140
3140
  var _a;
3141
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
3141
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
3142
+ for (const section of this.sections) {
3143
+ section.raise();
3144
+ }
3142
3145
  if (this.label) {
3143
3146
  this.label.raise();
3144
3147
  }
3145
3148
  for (const port of this.ports) {
3146
3149
  port.raise();
3147
3150
  }
3148
- for (const section of this.sections) {
3149
- section.raise();
3150
- }
3151
3151
  for (const decorator of this.decorators) {
3152
3152
  decorator.raise();
3153
3153
  }
@@ -3245,7 +3245,7 @@ class DiagramNode extends DiagramElement {
3245
3245
  if (!includeRemoved && incomingConnection.removed) {
3246
3246
  continue;
3247
3247
  }
3248
- const otherNode = (_a = incomingConnection.start) === null || _a === undefined ? undefined : _a.getNode();
3248
+ const otherNode = (_a = incomingConnection.start) === null || _a === void 0 ? void 0 : _a.getNode();
3249
3249
  if (otherNode) {
3250
3250
  if (!includeRemoved && otherNode.removed) {
3251
3251
  continue;
@@ -3257,7 +3257,7 @@ class DiagramNode extends DiagramElement {
3257
3257
  if (!includeRemoved && outgoingConnection.removed) {
3258
3258
  continue;
3259
3259
  }
3260
- const otherNode = (_b = outgoingConnection.end) === null || _b === undefined ? undefined : _b.getNode();
3260
+ const otherNode = (_b = outgoingConnection.end) === null || _b === void 0 ? void 0 : _b.getNode();
3261
3261
  if (otherNode) {
3262
3262
  if (!includeRemoved && otherNode.removed) {
3263
3263
  continue;
@@ -3276,7 +3276,7 @@ class DiagramNode extends DiagramElement {
3276
3276
  // eslint-disable-next-line @typescript-eslint/no-this-alias
3277
3277
  let node = this;
3278
3278
  while (node.parent !== undefined) {
3279
- node = node === null || node === undefined ? undefined : node.parent;
3279
+ node = node === null || node === void 0 ? void 0 : node.parent;
3280
3280
  }
3281
3281
  return node;
3282
3282
  }
@@ -3581,6 +3581,106 @@ class DiagramNode extends DiagramElement {
3581
3581
  this.getConnections().forEach(c => c.tighten());
3582
3582
  this.updateInView();
3583
3583
  }
3584
+ /**
3585
+ * Removes all sections with the given index along the x axis.
3586
+ * @public
3587
+ */
3588
+ removeSectionColumn(columnIndex) {
3589
+ var _a;
3590
+ const margin = ((_a = this.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
3591
+ let columnWidth = 0;
3592
+ const sections = [...this.sections];
3593
+ for (const section of sections) {
3594
+ if (section.indexYInNode === columnIndex) {
3595
+ columnWidth = Math.max(columnWidth, section.width);
3596
+ this.model.sections.remove(section.id);
3597
+ }
3598
+ }
3599
+ for (const section of sections) {
3600
+ if (section.indexYInNode > columnIndex) {
3601
+ --section.indexYInNode;
3602
+ section.move([section.coords[0] - columnWidth - margin, section.coords[1]]);
3603
+ }
3604
+ }
3605
+ this.stretch(Side.Right, -margin - columnWidth);
3606
+ }
3607
+ /**
3608
+ * Removes all sections with the given index along the y axis.
3609
+ * @public
3610
+ */
3611
+ removeSectionRow(rowIndex) {
3612
+ var _a;
3613
+ const margin = ((_a = this.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
3614
+ let rowHeight = 0;
3615
+ const sections = [...this.sections];
3616
+ for (const section of sections) {
3617
+ if (section.indexXInNode === rowIndex) {
3618
+ rowHeight = Math.max(rowHeight, section.height);
3619
+ this.model.sections.remove(section.id);
3620
+ }
3621
+ }
3622
+ for (const section of sections) {
3623
+ if (section.indexYInNode > rowIndex) {
3624
+ --section.indexXInNode;
3625
+ section.move([section.coords[0], section.coords[1] - rowHeight - margin]);
3626
+ }
3627
+ }
3628
+ this.stretch(Side.Bottom, -margin - rowHeight);
3629
+ }
3630
+ /**
3631
+ * Creates a copy of all sections with the given index along the x axis.
3632
+ * @public
3633
+ */
3634
+ copySectionColumn(columnIndex) {
3635
+ var _a;
3636
+ const margin = ((_a = this.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
3637
+ let columnWidth = 0;
3638
+ const sections = [...this.sections];
3639
+ for (const section of sections) {
3640
+ if (section.indexXInNode === columnIndex) {
3641
+ columnWidth = Math.max(columnWidth, section.width);
3642
+ let newSectionIdIndexX = section.indexXInNode + 1;
3643
+ while (this.model.sections.get(`${section.id}_copy_${newSectionIdIndexX}_${section.indexYInNode}`, true) !== undefined) {
3644
+ ++newSectionIdIndexX;
3645
+ }
3646
+ this.model.sections.new(this, section.indexXInNode + 1, section.indexYInNode, [section.coords[0] + section.width + margin, section.coords[1]], section.width, section.height, `${section.id}_copy_${newSectionIdIndexX}_${section.indexYInNode}`);
3647
+ }
3648
+ }
3649
+ for (const section of sections) {
3650
+ if (section.indexXInNode > columnIndex) {
3651
+ ++section.indexXInNode;
3652
+ section.move([section.coords[0] + columnWidth + margin, section.coords[1]]);
3653
+ }
3654
+ }
3655
+ this.stretch(Side.Right, margin + columnWidth);
3656
+ }
3657
+ /**
3658
+ * Creates a copy of all sections with the given index along the y axis.
3659
+ * @public
3660
+ */
3661
+ copySectionRow(rowIndex) {
3662
+ var _a;
3663
+ const margin = ((_a = this.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
3664
+ let rowHeight = 0;
3665
+ const sections = [...this.sections];
3666
+ for (const section of sections) {
3667
+ if (section.indexYInNode === rowIndex) {
3668
+ rowHeight = Math.max(rowHeight, section.height);
3669
+ let newSectionIdIndexY = section.indexYInNode + 1;
3670
+ while (this.model.sections.get(`${section.id}_copy_${section.indexXInNode}_${newSectionIdIndexY}`, true) !== undefined) {
3671
+ ++newSectionIdIndexY;
3672
+ }
3673
+ this.model.sections.new(this, section.indexXInNode, section.indexYInNode + 1, [section.coords[0], section.coords[1] + section.height + margin], section.width, section.height, `${section.id}_copy_${section.indexXInNode}_${newSectionIdIndexY}`);
3674
+ }
3675
+ }
3676
+ for (const section of sections) {
3677
+ if (section.indexYInNode > rowIndex) {
3678
+ ++section.indexYInNode;
3679
+ section.move([section.coords[0], section.coords[1] + rowHeight + margin]);
3680
+ }
3681
+ }
3682
+ this.stretch(Side.Bottom, margin + rowHeight);
3683
+ }
3584
3684
  }
3585
3685
  class DiagramNodeSet extends DiagramElementSet {
3586
3686
  /**
@@ -3626,10 +3726,10 @@ class DiagramNodeSet extends DiagramElementSet {
3626
3726
  for (let j = 0; j < nodeType.sectionGrid.sections.length; ++j) {
3627
3727
  let widthAccumulator = node.coords[0] + (nodeType.sectionGrid.margin || 0);
3628
3728
  for (let i = 0; i < nodeType.sectionGrid.sections[j].length; ++i) {
3629
- this.model.sections.new(node, i, j, [widthAccumulator, heightAccumulator], ((_a = nodeType.sectionGrid.defaultWidths) === null || _a === undefined ? undefined : _a[i]) || DIAGRAM_SECTION_DEFAULT_WIDTH, ((_b = nodeType.sectionGrid.defaultHeights) === null || _b === undefined ? undefined : _b[j]) || DIAGRAM_SECTION_DEFAULT_HEIGHT, `${node.id}_${j}_${i}`);
3630
- widthAccumulator += (((_c = nodeType.sectionGrid.defaultWidths) === null || _c === undefined ? undefined : _c[i]) || DIAGRAM_SECTION_DEFAULT_WIDTH) + (nodeType.sectionGrid.margin || 0);
3729
+ this.model.sections.new(node, i, j, [widthAccumulator, heightAccumulator], ((_a = nodeType.sectionGrid.defaultWidths) === null || _a === void 0 ? void 0 : _a[i]) || DIAGRAM_SECTION_DEFAULT_WIDTH, ((_b = nodeType.sectionGrid.defaultHeights) === null || _b === void 0 ? void 0 : _b[j]) || DIAGRAM_SECTION_DEFAULT_HEIGHT, `${node.id}_${j}_${i}`);
3730
+ widthAccumulator += (((_c = nodeType.sectionGrid.defaultWidths) === null || _c === void 0 ? void 0 : _c[i]) || DIAGRAM_SECTION_DEFAULT_WIDTH) + (nodeType.sectionGrid.margin || 0);
3631
3731
  }
3632
- heightAccumulator += (((_d = nodeType.sectionGrid.defaultHeights) === null || _d === undefined ? undefined : _d[j]) || DIAGRAM_SECTION_DEFAULT_HEIGHT) + (nodeType.sectionGrid.margin || 0);
3732
+ heightAccumulator += (((_d = nodeType.sectionGrid.defaultHeights) === null || _d === void 0 ? void 0 : _d[j]) || DIAGRAM_SECTION_DEFAULT_HEIGHT) + (nodeType.sectionGrid.margin || 0);
3633
3733
  }
3634
3734
  }
3635
3735
  // add node ports
@@ -3638,8 +3738,8 @@ class DiagramNodeSet extends DiagramElementSet {
3638
3738
  const portConfig = nodeType.ports[i];
3639
3739
  const portType = portConfig.type !== undefined ? this.model.ports.types.get(portConfig.type) : undefined;
3640
3740
  const port = this.model.ports.new(portType, node, [node.coords[0] + portConfig.coords[0], node.coords[1] + portConfig.coords[1]], portConfig.connectionPoint !== undefined ? [node.coords[0] + (portConfig.connectionPoint[0] || 0), node.coords[1] + (portConfig.connectionPoint[1] || 0)] : undefined, portConfig.direction, `${node.id}_port_${i}`);
3641
- if ((_e = port.type) === null || _e === undefined ? undefined : _e.label) {
3642
- const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === undefined ? undefined : _f.label);
3741
+ if ((_e = port.type) === null || _e === void 0 ? void 0 : _e.label) {
3742
+ const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === void 0 ? void 0 : _f.label);
3643
3743
  const labelWidth = 6 * labelConfiguration.fontSize + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
3644
3744
  const labelHeight = labelConfiguration.fontSize + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
3645
3745
  let labelCoords;
@@ -3655,14 +3755,14 @@ class DiagramNodeSet extends DiagramElementSet {
3655
3755
  default:
3656
3756
  labelCoords = port.coords;
3657
3757
  }
3658
- this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
3758
+ this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit);
3659
3759
  }
3660
3760
  }
3661
3761
  }
3662
3762
  // add node label
3663
3763
  if (nodeType.label) {
3664
3764
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), nodeType.label);
3665
- this.model.fields.new(node, [node.coords[0] + getLeftMargin(labelConfiguration), node.coords[1] + getTopMargin(labelConfiguration)], labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, node.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), node.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
3765
+ this.model.fields.new(node, [node.coords[0] + getLeftMargin(labelConfiguration), node.coords[1] + getTopMargin(labelConfiguration)], labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, node.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), node.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit);
3666
3766
  }
3667
3767
  // add node decorators
3668
3768
  if (nodeType.decorators.length > 0) {
@@ -3672,7 +3772,7 @@ class DiagramNodeSet extends DiagramElementSet {
3672
3772
  }
3673
3773
  }
3674
3774
  node.valueSet.resetValues();
3675
- (_g = node.model.canvas) === null || _g === undefined ? undefined : _g.fitNodeInView(node.id);
3775
+ (_g = node.model.canvas) === null || _g === void 0 ? void 0 : _g.fitNodeInView(node.id);
3676
3776
  return node;
3677
3777
  }
3678
3778
  remove(id) {
@@ -3764,7 +3864,7 @@ const filterByOnlyDescendants = nodes => {
3764
3864
  return nodes;
3765
3865
  };
3766
3866
  const getBottomPadding = config => {
3767
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
3867
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
3768
3868
  return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
3769
3869
  } else if (typeof config.padding === 'number') {
3770
3870
  return config.padding;
@@ -3783,7 +3883,7 @@ const getBottomPadding = config => {
3783
3883
  }
3784
3884
  };
3785
3885
  const getLeftPadding = config => {
3786
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
3886
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
3787
3887
  return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
3788
3888
  } else if (typeof config.padding === 'number') {
3789
3889
  return config.padding;
@@ -3802,7 +3902,7 @@ const getLeftPadding = config => {
3802
3902
  }
3803
3903
  };
3804
3904
  const getRightPadding = config => {
3805
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
3905
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
3806
3906
  return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
3807
3907
  } else if (typeof config.padding === 'number') {
3808
3908
  return config.padding;
@@ -3821,7 +3921,7 @@ const getRightPadding = config => {
3821
3921
  }
3822
3922
  };
3823
3923
  const getTopPadding = config => {
3824
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
3924
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
3825
3925
  return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
3826
3926
  } else if (typeof config.padding === 'number') {
3827
3927
  return config.padding;
@@ -3910,7 +4010,7 @@ class DiagramPort extends DiagramElement {
3910
4010
  }
3911
4011
  get typeString() {
3912
4012
  var _a;
3913
- return (_a = this.type) === null || _a === undefined ? undefined : _a.id;
4013
+ return (_a = this.type) === null || _a === void 0 ? void 0 : _a.id;
3914
4014
  }
3915
4015
  set typeString(typeString) {
3916
4016
  if (typeString === undefined) {
@@ -3927,14 +4027,14 @@ class DiagramPort extends DiagramElement {
3927
4027
  */
3928
4028
  get allowsOutgoing() {
3929
4029
  var _a, _b;
3930
- return ((_a = this.type) === null || _a === undefined ? undefined : _a.allowsOutgoing) !== undefined ? (_b = this.type) === null || _b === undefined ? undefined : _b.allowsOutgoing : true;
4030
+ return ((_a = this.type) === null || _a === void 0 ? void 0 : _a.allowsOutgoing) !== undefined ? (_b = this.type) === null || _b === void 0 ? void 0 : _b.allowsOutgoing : true;
3931
4031
  }
3932
4032
  /**
3933
4033
  * Whether this port can be used as a connection end point.
3934
4034
  */
3935
4035
  get allowsIncoming() {
3936
4036
  var _a, _b;
3937
- return ((_a = this.type) === null || _a === undefined ? undefined : _a.allowsIncoming) !== undefined ? (_b = this.type) === null || _b === undefined ? undefined : _b.allowsIncoming : true;
4037
+ return ((_a = this.type) === null || _a === void 0 ? void 0 : _a.allowsIncoming) !== undefined ? (_b = this.type) === null || _b === void 0 ? void 0 : _b.allowsIncoming : true;
3938
4038
  }
3939
4039
  /**
3940
4040
  * Name of this port. Alias for this port's label's text.
@@ -3942,7 +4042,7 @@ class DiagramPort extends DiagramElement {
3942
4042
  */
3943
4043
  get name() {
3944
4044
  var _a;
3945
- return ((_a = this.label) === null || _a === undefined ? undefined : _a.text) || '';
4045
+ return ((_a = this.label) === null || _a === void 0 ? void 0 : _a.text) || '';
3946
4046
  }
3947
4047
  set name(name) {
3948
4048
  if (this.label) {
@@ -3957,15 +4057,15 @@ class DiagramPort extends DiagramElement {
3957
4057
  var _a, _b, _c, _d;
3958
4058
  if (this.selected) {
3959
4059
  if (this.highlighted) {
3960
- return this._selectedAndHighlightedLook !== undefined ? this._selectedAndHighlightedLook : (_a = this.type || DIAGRAM_PORT_LOOKS) === null || _a === undefined ? undefined : _a.selectedAndHighlightedLook;
4060
+ return this._selectedAndHighlightedLook !== undefined ? this._selectedAndHighlightedLook : (_a = this.type || DIAGRAM_PORT_LOOKS) === null || _a === void 0 ? void 0 : _a.selectedAndHighlightedLook;
3961
4061
  } else {
3962
- return this._selectedLook !== undefined ? this._selectedLook : (_b = this.type || DIAGRAM_PORT_LOOKS) === null || _b === undefined ? undefined : _b.selectedLook;
4062
+ return this._selectedLook !== undefined ? this._selectedLook : (_b = this.type || DIAGRAM_PORT_LOOKS) === null || _b === void 0 ? void 0 : _b.selectedLook;
3963
4063
  }
3964
4064
  } else {
3965
4065
  if (this.highlighted) {
3966
- return this._highlightedLook !== undefined ? this._highlightedLook : (_c = this.type || DIAGRAM_PORT_LOOKS) === null || _c === undefined ? undefined : _c.highlightedLook;
4066
+ return this._highlightedLook !== undefined ? this._highlightedLook : (_c = this.type || DIAGRAM_PORT_LOOKS) === null || _c === void 0 ? void 0 : _c.highlightedLook;
3967
4067
  } else {
3968
- return this._defaultLook !== undefined ? this._defaultLook : (_d = this.type || DIAGRAM_PORT_LOOKS) === null || _d === undefined ? undefined : _d.defaultLook;
4068
+ return this._defaultLook !== undefined ? this._defaultLook : (_d = this.type || DIAGRAM_PORT_LOOKS) === null || _d === void 0 ? void 0 : _d.defaultLook;
3969
4069
  }
3970
4070
  }
3971
4071
  }
@@ -3994,7 +4094,7 @@ class DiagramPort extends DiagramElement {
3994
4094
  */
3995
4095
  get width() {
3996
4096
  var _a;
3997
- return ((_a = this.type) === null || _a === undefined ? undefined : _a.width) || DIAGRAM_PORT_TYPE_DEFAULTS.width;
4097
+ return ((_a = this.type) === null || _a === void 0 ? void 0 : _a.width) || DIAGRAM_PORT_TYPE_DEFAULTS.width;
3998
4098
  }
3999
4099
  /**
4000
4100
  * Current height of this port. Same as the width.
@@ -4032,11 +4132,11 @@ class DiagramPort extends DiagramElement {
4032
4132
  }
4033
4133
  updateInView() {
4034
4134
  var _a;
4035
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updatePortsInView(this.id);
4135
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updatePortsInView(this.id);
4036
4136
  }
4037
4137
  raise() {
4038
4138
  var _a;
4039
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
4139
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
4040
4140
  if (this.label) {
4041
4141
  this.label.raise();
4042
4142
  }
@@ -4078,7 +4178,7 @@ class DiagramPort extends DiagramElement {
4078
4178
  }
4079
4179
  getPriority() {
4080
4180
  var _a;
4081
- return ((_a = this.rootElement) === null || _a === undefined ? undefined : _a.getPriority()) || DEFAULT_PRIORITY;
4181
+ return ((_a = this.rootElement) === null || _a === void 0 ? void 0 : _a.getPriority()) || DEFAULT_PRIORITY;
4082
4182
  }
4083
4183
  /**
4084
4184
  * Change the coordinates of this port to the given coordinates and move its labels correspondingly.
@@ -4209,7 +4309,7 @@ class DagaImporter {
4209
4309
  // add node label
4210
4310
  if (newNodeType.label) {
4211
4311
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newNodeType.label);
4212
- const newField = new DiagramField(model, newNode, [newNode.coords[0] + getLeftMargin(labelConfiguration), newNode.coords[1] + getTopMargin(labelConfiguration)], newNode.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newNode.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
4312
+ const newField = new DiagramField(model, newNode, [newNode.coords[0] + getLeftMargin(labelConfiguration), newNode.coords[1] + getTopMargin(labelConfiguration)], newNode.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newNode.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit);
4213
4313
  newField.text = node.label;
4214
4314
  newNode.label = newField;
4215
4315
  model.fields.add(newField);
@@ -4219,19 +4319,19 @@ class DagaImporter {
4219
4319
  for (const child of node.children || []) {
4220
4320
  const newChild = this.importNode(model, child);
4221
4321
  if (newChild !== undefined) {
4222
- (_a = newNode.children) === null || _a === undefined ? undefined : _a.push(newChild);
4322
+ (_a = newNode.children) === null || _a === void 0 ? void 0 : _a.push(newChild);
4223
4323
  newChild.parent = newNode;
4224
4324
  }
4225
4325
  }
4226
4326
  for (const section of node.sections || []) {
4227
4327
  const newSection = new DiagramSection(model, newNode, section.indexXInNode, section.indexYInNode, section.coords, section.width, section.height, section.id);
4228
- (_b = newNode.sections) === null || _b === undefined ? undefined : _b.push(newSection);
4328
+ (_b = newNode.sections) === null || _b === void 0 ? void 0 : _b.push(newSection);
4229
4329
  model.sections.add(newSection);
4230
4330
  if (section.label) {
4231
4331
  // add section label
4232
- if ((_f = (_e = (_d = (_c = newNodeType.sectionGrid) === null || _c === undefined ? undefined : _c.sections) === null || _d === undefined ? undefined : _d[section.indexYInNode]) === null || _e === undefined ? undefined : _e[section.indexXInNode]) === null || _f === undefined ? undefined : _f.label) {
4233
- const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_k = (_j = (_h = (_g = newNodeType.sectionGrid) === null || _g === undefined ? undefined : _g.sections) === null || _h === undefined ? undefined : _h[section.indexYInNode]) === null || _j === undefined ? undefined : _j[section.indexXInNode]) === null || _k === undefined ? undefined : _k.label);
4234
- const newField = new DiagramField(model, newSection, [newSection.coords[0] + getLeftMargin(labelConfiguration), newSection.coords[1] + getTopMargin(labelConfiguration)], newSection.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newSection.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
4332
+ if ((_f = (_e = (_d = (_c = newNodeType.sectionGrid) === null || _c === void 0 ? void 0 : _c.sections) === null || _d === void 0 ? void 0 : _d[section.indexYInNode]) === null || _e === void 0 ? void 0 : _e[section.indexXInNode]) === null || _f === void 0 ? void 0 : _f.label) {
4333
+ const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_k = (_j = (_h = (_g = newNodeType.sectionGrid) === null || _g === void 0 ? void 0 : _g.sections) === null || _h === void 0 ? void 0 : _h[section.indexYInNode]) === null || _j === void 0 ? void 0 : _j[section.indexXInNode]) === null || _k === void 0 ? void 0 : _k.label);
4334
+ const newField = new DiagramField(model, newSection, [newSection.coords[0] + getLeftMargin(labelConfiguration), newSection.coords[1] + getTopMargin(labelConfiguration)], newSection.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newSection.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit);
4235
4335
  newField.text = section.label;
4236
4336
  newSection.label = newField;
4237
4337
  model.fields.add(newField);
@@ -4246,8 +4346,8 @@ class DagaImporter {
4246
4346
  model.ports.add(newPort);
4247
4347
  if (port.label) {
4248
4348
  // add port label
4249
- if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType === undefined ? undefined : newPortType.label)) {
4250
- const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType === undefined ? undefined : newPortType.label);
4349
+ if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType === void 0 ? void 0 : newPortType.label)) {
4350
+ const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType === void 0 ? void 0 : newPortType.label);
4251
4351
  let labelCoords;
4252
4352
  switch (newPort.direction) {
4253
4353
  case Side.Top:
@@ -4263,7 +4363,7 @@ class DagaImporter {
4263
4363
  default:
4264
4364
  labelCoords = newPort.coords;
4265
4365
  }
4266
- const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
4366
+ const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit);
4267
4367
  newField.text = port.label;
4268
4368
  newPort.label = newField;
4269
4369
  model.fields.add(newField);
@@ -4293,8 +4393,8 @@ class DagaImporter {
4293
4393
  model.ports.add(newPort);
4294
4394
  if (port.label) {
4295
4395
  // add port label
4296
- if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType === undefined ? undefined : newPortType.label)) {
4297
- const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType === undefined ? undefined : newPortType.label);
4396
+ if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType === void 0 ? void 0 : newPortType.label)) {
4397
+ const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType === void 0 ? void 0 : newPortType.label);
4298
4398
  let labelCoords;
4299
4399
  switch (newPort.direction) {
4300
4400
  case Side.Top:
@@ -4310,7 +4410,7 @@ class DagaImporter {
4310
4410
  default:
4311
4411
  labelCoords = newPort.coords;
4312
4412
  }
4313
- const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
4413
+ const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit);
4314
4414
  newField.text = port.label;
4315
4415
  newPort.label = newField;
4316
4416
  model.fields.add(newField);
@@ -4394,14 +4494,16 @@ class AddNodeCollabAction {
4394
4494
  var _a;
4395
4495
  const node = this.canvas.model.nodes.new(this.typeId, this.coords, this.id);
4396
4496
  if (this.parentId !== undefined) {
4397
- (_a = this.canvas.model.nodes.get(this.parentId)) === null || _a === undefined ? undefined : _a.addChild(node);
4398
- }
4399
- if (this.values !== undefined) {
4400
- node.valueSet.setValues(structuredClone(Object.assign(Object.assign({}, node.valueSet.getValues()), this.values)));
4497
+ (_a = this.canvas.model.nodes.get(this.parentId)) === null || _a === void 0 ? void 0 : _a.addChild(node);
4401
4498
  }
4402
4499
  if (node.label) {
4403
4500
  node.label.text = this.label || '';
4404
4501
  }
4502
+ if (this.values !== undefined) {
4503
+ node.valueSet.setValues(structuredClone(Object.assign(Object.assign({}, node.valueSet.getValues()), this.values)));
4504
+ } else {
4505
+ node.valueSet.resetValues();
4506
+ }
4405
4507
  }
4406
4508
  serialize() {
4407
4509
  return {
@@ -4418,6 +4520,54 @@ class AddNodeCollabAction {
4418
4520
  return new AddNodeCollabAction(canvas, serialized.id, serialized.typeId, serialized.coords, serialized.parentId, serialized.label, serialized.values);
4419
4521
  }
4420
4522
  }
4523
+ /**
4524
+ * Collaborative action which consists of adding or removing sections in a node.
4525
+ * @private
4526
+ * @see AddNodeAction
4527
+ */
4528
+ class AddSectionCollabAction {
4529
+ constructor(canvas, nodeId, copyColumnIndex, copyRowIndex, removeColumnIndex, removeRowIndex, timestamp) {
4530
+ this.canvas = canvas;
4531
+ this.nodeId = nodeId;
4532
+ this.copyColumnIndex = copyColumnIndex;
4533
+ this.copyRowIndex = copyRowIndex;
4534
+ this.removeColumnIndex = removeColumnIndex;
4535
+ this.removeRowIndex = removeRowIndex;
4536
+ this.timestamp = timestamp;
4537
+ }
4538
+ do() {
4539
+ const node = this.canvas.model.nodes.get(this.nodeId);
4540
+ if (node && timestampWins(this.timestamp, node.geometryTimestamp)) {
4541
+ if (this.copyColumnIndex !== undefined) {
4542
+ node.copySectionColumn(this.copyColumnIndex);
4543
+ }
4544
+ if (this.copyRowIndex !== undefined) {
4545
+ node.copySectionRow(this.copyRowIndex);
4546
+ }
4547
+ if (this.removeColumnIndex !== undefined) {
4548
+ node.removeSectionColumn(this.removeColumnIndex);
4549
+ }
4550
+ if (this.removeRowIndex !== undefined) {
4551
+ node.removeSectionRow(this.removeRowIndex);
4552
+ }
4553
+ node.geometryTimestamp = this.timestamp;
4554
+ }
4555
+ }
4556
+ serialize() {
4557
+ return {
4558
+ type: 'addSection',
4559
+ nodeId: this.nodeId,
4560
+ copyColumnIndex: this.copyColumnIndex,
4561
+ copyRowIndex: this.copyRowIndex,
4562
+ removeColumnIndex: this.removeColumnIndex,
4563
+ removeRowIndex: this.removeRowIndex,
4564
+ timestamp: this.timestamp
4565
+ };
4566
+ }
4567
+ static deserialize(canvas, serialized) {
4568
+ return new AddSectionCollabAction(canvas, serialized.nodeId, serialized.copyColumnIndex, serialized.copyRowIndex, serialized.removeColumnIndex, serialized.removeRowIndex, serialized.timestamp);
4569
+ }
4570
+ }
4421
4571
  /**
4422
4572
  * Collaborative which consists of applying a layout to the diagram which can change the location of several nodes.
4423
4573
  * @private
@@ -4468,7 +4618,7 @@ class MoveCollabAction {
4468
4618
  const node = this.canvas.model.nodes.get(nodeId, true);
4469
4619
  if (node && timestampWins(this.timestamp, node.geometryTimestamp)) {
4470
4620
  node.move([node.coords[0] + this.delta[0], node.coords[1] + this.delta[1]]);
4471
- (_a = node.parent) === null || _a === undefined ? undefined : _a.fitToChild(node);
4621
+ (_a = node.parent) === null || _a === void 0 ? void 0 : _a.fitToChild(node);
4472
4622
  node.geometryTimestamp = this.timestamp;
4473
4623
  }
4474
4624
  }
@@ -4503,15 +4653,15 @@ class SetGeometryCollabAction {
4503
4653
  if (node && timestampWins(this.timestamp, node.geometryTimestamp)) {
4504
4654
  node.setGeometry(this.to);
4505
4655
  // Re-fit the labels, in case their text has changed since `this.to` was measured.
4506
- if ((_a = node.label) === null || _a === undefined ? undefined : _a.fit) {
4656
+ if ((_a = node.label) === null || _a === void 0 ? void 0 : _a.fit) {
4507
4657
  this.canvas.fitFieldRootInView(node.label.id);
4508
4658
  }
4509
4659
  for (const section of node.sections) {
4510
- if ((_b = section.label) === null || _b === undefined ? undefined : _b.fit) {
4660
+ if ((_b = section.label) === null || _b === void 0 ? void 0 : _b.fit) {
4511
4661
  this.canvas.fitFieldRootInView(section.label.id);
4512
4662
  }
4513
4663
  }
4514
- (_c = node.parent) === null || _c === undefined ? undefined : _c.fitToChild(node);
4664
+ (_c = node.parent) === null || _c === void 0 ? void 0 : _c.fitToChild(node);
4515
4665
  node.geometryTimestamp = this.timestamp;
4516
4666
  }
4517
4667
  }
@@ -4545,9 +4695,9 @@ class SetParentCollabAction {
4545
4695
  const childNode = this.canvas.model.nodes.get(this.childId, true);
4546
4696
  const parentNode = this.parentId !== undefined ? this.canvas.model.nodes.get(this.parentId, true) : undefined;
4547
4697
  if (childNode && (this.parentId !== undefined ? parentNode : true) && timestampWins(this.timestamp, childNode.geometryTimestamp)) {
4548
- (_a = childNode.parent) === null || _a === undefined ? undefined : _a.removeChild(childNode);
4698
+ (_a = childNode.parent) === null || _a === void 0 ? void 0 : _a.removeChild(childNode);
4549
4699
  childNode.setGeometry(this.childGeometry);
4550
- parentNode === null || parentNode === undefined ? undefined : parentNode.addChild(childNode);
4700
+ parentNode === null || parentNode === void 0 ? void 0 : parentNode.addChild(childNode);
4551
4701
  }
4552
4702
  }
4553
4703
  serialize() {
@@ -4644,12 +4794,12 @@ class UpdateValuesCollabAction {
4644
4794
  if (this.id === undefined) {
4645
4795
  return this.canvas.model.valueSet;
4646
4796
  } else {
4647
- return (_a = this.canvas.model.nodes.get(this.id, true) || this.canvas.model.connections.get(this.id, true)) === null || _a === undefined ? undefined : _a.valueSet;
4797
+ return (_a = this.canvas.model.nodes.get(this.id, true) || this.canvas.model.connections.get(this.id, true)) === null || _a === void 0 ? void 0 : _a.valueSet;
4648
4798
  }
4649
4799
  }
4650
4800
  do() {
4651
4801
  var _a;
4652
- (_a = this.getValueSet()) === null || _a === undefined ? undefined : _a.overwriteValuesLww(this.to, this.timestamp);
4802
+ (_a = this.getValueSet()) === null || _a === void 0 ? void 0 : _a.overwriteValuesLww(this.to, this.timestamp);
4653
4803
  }
4654
4804
  serialize() {
4655
4805
  return {
@@ -4834,6 +4984,12 @@ class CollabEngine {
4834
4984
  action.do();
4835
4985
  break;
4836
4986
  }
4987
+ case 'addSection':
4988
+ {
4989
+ const action = AddSectionCollabAction.deserialize(this.canvas, message);
4990
+ action.do();
4991
+ break;
4992
+ }
4837
4993
  case 'applyLayout':
4838
4994
  {
4839
4995
  const action = ApplyLayoutCollabAction.deserialize(this.canvas, message);
@@ -4996,6 +5152,12 @@ var DiagramActions;
4996
5152
  * @see AddNodeAction
4997
5153
  */
4998
5154
  DiagramActions["AddNode"] = "add-node";
5155
+ /**
5156
+ * Action that corresponds to the addition or removal of sections in a node.
5157
+ * @public
5158
+ * @see AddSectionAction
5159
+ */
5160
+ DiagramActions["AddSectionAction"] = "add-section";
4999
5161
  /**
5000
5162
  * Action that corresponds to applying a layout which changes the location of several nodes.
5001
5163
  * @public
@@ -5637,11 +5799,11 @@ class DiagramDecorator extends DiagramElement {
5637
5799
  }
5638
5800
  updateInView() {
5639
5801
  var _a;
5640
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateDecoratorsInView(this.id);
5802
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateDecoratorsInView(this.id);
5641
5803
  }
5642
5804
  raise() {
5643
5805
  var _a;
5644
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
5806
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
5645
5807
  }
5646
5808
  /**
5647
5809
  * Change the coordinates of this decorator to the given coordinates.
@@ -5726,11 +5888,11 @@ class DiagramObject extends DiagramElement {
5726
5888
  }
5727
5889
  updateInView() {
5728
5890
  var _a;
5729
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateObjectsInView(this.id);
5891
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateObjectsInView(this.id);
5730
5892
  }
5731
5893
  raise() {
5732
5894
  var _a;
5733
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
5895
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
5734
5896
  }
5735
5897
  /**
5736
5898
  * Change the coordinates of this object to the given coordinates.
@@ -5847,7 +6009,7 @@ class DiagramModel {
5847
6009
  */
5848
6010
  clear() {
5849
6011
  var _a, _b;
5850
- (_a = this.canvas) === null || _a === undefined ? undefined : _a.cancelAllUserActions();
6012
+ (_a = this.canvas) === null || _a === void 0 ? void 0 : _a.cancelAllUserActions();
5851
6013
  this.id = undefined;
5852
6014
  this.name = '';
5853
6015
  this.description = undefined;
@@ -5862,7 +6024,7 @@ class DiagramModel {
5862
6024
  this.objects.clear();
5863
6025
  this.decorators.clear();
5864
6026
  this.valueSet.resetValues();
5865
- (_b = this.canvas) === null || _b === undefined ? undefined : _b.updateModelInView();
6027
+ (_b = this.canvas) === null || _b === void 0 ? void 0 : _b.updateModelInView();
5866
6028
  }
5867
6029
  }
5868
6030
 
@@ -5928,7 +6090,6 @@ const updateLook = selection => {
5928
6090
  selection.filter('.stretchable-image-look').select('image.bottom-right-image').attr('x', d => d.width - d.look.rightMargin).attr('y', d => d.height - d.look.bottomMargin).attr('width', d => d.look.rightMargin).attr('height', d => d.look.bottomMargin).attr('href', d => d.look.backgroundImageBottomRight);
5929
6091
  };
5930
6092
  const GRID_DEFAULTS = {
5931
- enabled: true,
5932
6093
  style: 'dots',
5933
6094
  color: 'rgba(0, 0, 0, 0.1)',
5934
6095
  snap: false,
@@ -6086,7 +6247,7 @@ class DiagramContextMenu {
6086
6247
  */
6087
6248
  close() {
6088
6249
  var _a;
6089
- (_a = this.contextMenuContainer) === null || _a === undefined ? undefined : _a.remove();
6250
+ (_a = this.contextMenuContainer) === null || _a === void 0 ? void 0 : _a.remove();
6090
6251
  this.contextMenuContainer = undefined;
6091
6252
  }
6092
6253
  }
@@ -6222,11 +6383,11 @@ class DagaExporter {
6222
6383
  for (const port of section.ports) {
6223
6384
  ports.push(Object.assign({
6224
6385
  id: port.id,
6225
- type: (_a = port.type) === null || _a === undefined ? undefined : _a.id,
6386
+ type: (_a = port.type) === null || _a === void 0 ? void 0 : _a.id,
6226
6387
  coords: roundPoint(port.coords),
6227
6388
  connectionPoint: roundPoint(port.connectionPoint),
6228
6389
  direction: port.direction,
6229
- label: ((_b = port.label) === null || _b === undefined ? undefined : _b.text) || ''
6390
+ label: ((_b = port.label) === null || _b === void 0 ? void 0 : _b.text) || ''
6230
6391
  }, includeCollabMeta ? {
6231
6392
  collabMeta: Object.assign({
6232
6393
  removed: port.removed,
@@ -6238,7 +6399,7 @@ class DagaExporter {
6238
6399
  sections.push(Object.assign({
6239
6400
  id: section.id,
6240
6401
  ports,
6241
- label: ((_c = section.label) === null || _c === undefined ? undefined : _c.text) || '',
6402
+ label: ((_c = section.label) === null || _c === void 0 ? void 0 : _c.text) || '',
6242
6403
  indexXInNode: section.indexXInNode,
6243
6404
  indexYInNode: section.indexYInNode,
6244
6405
  coords: roundPoint(section.coords),
@@ -6256,11 +6417,11 @@ class DagaExporter {
6256
6417
  for (const port of node.ports) {
6257
6418
  ports.push(Object.assign({
6258
6419
  id: port.id,
6259
- type: (_d = port.type) === null || _d === undefined ? undefined : _d.id,
6420
+ type: (_d = port.type) === null || _d === void 0 ? void 0 : _d.id,
6260
6421
  coords: roundPoint(port.coords),
6261
6422
  connectionPoint: roundPoint(port.connectionPoint),
6262
6423
  direction: port.direction,
6263
- label: ((_e = port.label) === null || _e === undefined ? undefined : _e.text) || ''
6424
+ label: ((_e = port.label) === null || _e === void 0 ? void 0 : _e.text) || ''
6264
6425
  }, includeCollabMeta ? {
6265
6426
  collabMeta: Object.assign({
6266
6427
  removed: port.removed,
@@ -6275,7 +6436,7 @@ class DagaExporter {
6275
6436
  children,
6276
6437
  sections,
6277
6438
  ports,
6278
- label: ((_f = node.label) === null || _f === undefined ? undefined : _f.text) || '',
6439
+ label: ((_f = node.label) === null || _f === void 0 ? void 0 : _f.text) || '',
6279
6440
  coords: roundPoint(node.coords),
6280
6441
  width: node.width,
6281
6442
  height: node.height,
@@ -6295,8 +6456,8 @@ class DagaExporter {
6295
6456
  return Object.assign({
6296
6457
  id: connection.id,
6297
6458
  type: connection.type.id,
6298
- start: ((_a = connection.start) === null || _a === undefined ? undefined : _a.id) || '',
6299
- end: ((_b = connection.end) === null || _b === undefined ? undefined : _b.id) || '',
6459
+ start: ((_a = connection.start) === null || _a === void 0 ? void 0 : _a.id) || '',
6460
+ end: ((_b = connection.end) === null || _b === void 0 ? void 0 : _b.id) || '',
6300
6461
  startLabel: connection.startLabel,
6301
6462
  middleLabel: connection.middleLabel,
6302
6463
  endLabel: connection.endLabel,
@@ -6516,11 +6677,11 @@ class DiagramUserSelection extends DiagramElementSet {
6516
6677
  openInPropertyEditor(selection) {
6517
6678
  var _a;
6518
6679
  this.makeUpdateValuesAction();
6519
- const propertyEditor = (_a = this.canvas.parentComponent) === null || _a === undefined ? undefined : _a.propertyEditor;
6680
+ const propertyEditor = (_a = this.canvas.parentComponent) === null || _a === void 0 ? void 0 : _a.propertyEditor;
6520
6681
  if (propertyEditor === undefined) {
6521
6682
  return;
6522
6683
  }
6523
- const selectedValueSet = selection === null || selection === undefined ? undefined : selection.valueSet;
6684
+ const selectedValueSet = selection === null || selection === void 0 ? void 0 : selection.valueSet;
6524
6685
  if (selectedValueSet) {
6525
6686
  this.propertyEditorSelection = selection;
6526
6687
  this.propertyEditorValues = structuredClone(selectedValueSet.getValues());
@@ -6562,12 +6723,12 @@ class DiagramUserSelection extends DiagramElementSet {
6562
6723
  const previousSelectionId = this.propertyEditorSelection instanceof DiagramModel ? undefined : this.propertyEditorSelection.id;
6563
6724
  // check if there have been changes in the previously selected ValueSet,
6564
6725
  // and create an UpdateValuesAction if there have
6565
- if (equals(this.propertyEditorValues, (_a = this.propertyEditorSelection) === null || _a === undefined ? undefined : _a.valueSet.getValues())) {
6726
+ if (equals(this.propertyEditorValues, (_a = this.propertyEditorSelection) === null || _a === void 0 ? void 0 : _a.valueSet.getValues())) {
6566
6727
  return;
6567
6728
  }
6568
6729
  const from = this.propertyEditorValues;
6569
- const to = structuredClone((_b = this.propertyEditorSelection) === null || _b === undefined ? undefined : _b.valueSet.getValues());
6570
- const [fromDiff, toDiff] = diffProperties(from, to, (_c = this.propertyEditorSelection) === null || _c === undefined ? undefined : _c.valueSet);
6730
+ const to = structuredClone((_b = this.propertyEditorSelection) === null || _b === void 0 ? void 0 : _b.valueSet.getValues());
6731
+ const [fromDiff, toDiff] = diffProperties(from, to, (_c = this.propertyEditorSelection) === null || _c === void 0 ? void 0 : _c.valueSet);
6571
6732
  const currentAction = new UpdateValuesAction(this.canvas, previousSelectionId, fromDiff, toDiff);
6572
6733
  currentAction.do();
6573
6734
  this.canvas.actionStack.add(currentAction);
@@ -6601,7 +6762,7 @@ class DiagramCanvas {
6601
6762
  var _a, _b;
6602
6763
  this._connectionType = value;
6603
6764
  // refresh the palette every time connectionType is set so that the palette keeps track of updates to the connectionType
6604
- (_b = (_a = this.parentComponent) === null || _a === undefined ? undefined : _a.palette) === null || _b === undefined ? undefined : _b.refreshPalette();
6765
+ (_b = (_a = this.parentComponent) === null || _a === void 0 ? void 0 : _a.palette) === null || _b === void 0 ? void 0 : _b.refreshPalette();
6605
6766
  }
6606
6767
  /**
6607
6768
  * Constructs a canvas object.
@@ -6627,18 +6788,18 @@ class DiagramCanvas {
6627
6788
  this.model = new DiagramModel(this, undefined, config.name || 'unnamed', '', config.type || '', config.properties || []);
6628
6789
  this.userSelection = new DiagramUserSelection(this);
6629
6790
  this.userHighlight = new DiagramUserHighlight(this);
6630
- this.contextMenu = new DiagramContextMenu(this, (_a = config.canvas) === null || _a === undefined ? undefined : _a.contextMenu);
6631
- this.backgroundColor = ((_b = config.canvas) === null || _b === undefined ? undefined : _b.backgroundColor) || '#FFFFFF';
6632
- this.gridStyle = (_e = (_d = (_c = config.canvas) === null || _c === undefined ? undefined : _c.grid) === null || _d === undefined ? undefined : _d.style) !== null && _e !== undefined ? _e : GRID_DEFAULTS.style;
6633
- this.gridSize = ((_g = (_f = config.canvas) === null || _f === undefined ? undefined : _f.grid) === null || _g === undefined ? undefined : _g.enabled) === false || ((_h = config.canvas) === null || _h === undefined ? undefined : _h.grid) === undefined ? 0 : Math.abs(((_k = (_j = config.canvas) === null || _j === undefined ? undefined : _j.grid) === null || _k === undefined ? undefined : _k.spacing) || GRID_DEFAULTS.spacing);
6634
- this.gridThickness = Math.abs(((_m = (_l = config.canvas) === null || _l === undefined ? undefined : _l.grid) === null || _m === undefined ? undefined : _m.thickness) || GRID_DEFAULTS.thickness);
6635
- this.gridColor = ((_p = (_o = config.canvas) === null || _o === undefined ? undefined : _o.grid) === null || _p === undefined ? undefined : _p.color) || GRID_DEFAULTS.color;
6636
- this.snapToGrid = ((_r = (_q = config.canvas) === null || _q === undefined ? undefined : _q.grid) === null || _r === undefined ? undefined : _r.enabled) === false || ((_s = config.canvas) === null || _s === undefined ? undefined : _s.grid) === undefined ? false : ((_u = (_t = config.canvas) === null || _t === undefined ? undefined : _t.grid) === null || _u === undefined ? undefined : _u.snap) || GRID_DEFAULTS.snap;
6637
- this.zoomFactor = ((_v = config.canvas) === null || _v === undefined ? undefined : _v.zoomFactor) || 2;
6638
- this.panRate = ((_w = config.canvas) === null || _w === undefined ? undefined : _w.panRate) || 100;
6791
+ this.contextMenu = new DiagramContextMenu(this, (_a = config.canvas) === null || _a === void 0 ? void 0 : _a.contextMenu);
6792
+ this.backgroundColor = ((_b = config.canvas) === null || _b === void 0 ? void 0 : _b.backgroundColor) || '#FFFFFF';
6793
+ this.gridStyle = (_e = (_d = (_c = config.canvas) === null || _c === void 0 ? void 0 : _c.grid) === null || _d === void 0 ? void 0 : _d.style) !== null && _e !== void 0 ? _e : GRID_DEFAULTS.style;
6794
+ this.gridSize = ((_g = (_f = config.canvas) === null || _f === void 0 ? void 0 : _f.grid) === null || _g === void 0 ? void 0 : _g.enabled) === false || ((_h = config.canvas) === null || _h === void 0 ? void 0 : _h.grid) === undefined ? 0 : Math.abs(((_k = (_j = config.canvas) === null || _j === void 0 ? void 0 : _j.grid) === null || _k === void 0 ? void 0 : _k.spacing) || GRID_DEFAULTS.spacing);
6795
+ this.gridThickness = Math.abs(((_m = (_l = config.canvas) === null || _l === void 0 ? void 0 : _l.grid) === null || _m === void 0 ? void 0 : _m.thickness) || GRID_DEFAULTS.thickness);
6796
+ this.gridColor = ((_p = (_o = config.canvas) === null || _o === void 0 ? void 0 : _o.grid) === null || _p === void 0 ? void 0 : _p.color) || GRID_DEFAULTS.color;
6797
+ this.snapToGrid = ((_r = (_q = config.canvas) === null || _q === void 0 ? void 0 : _q.grid) === null || _r === void 0 ? void 0 : _r.enabled) === false || ((_s = config.canvas) === null || _s === void 0 ? void 0 : _s.grid) === undefined ? false : ((_u = (_t = config.canvas) === null || _t === void 0 ? void 0 : _t.grid) === null || _u === void 0 ? void 0 : _u.snap) || GRID_DEFAULTS.snap;
6798
+ this.zoomFactor = ((_v = config.canvas) === null || _v === void 0 ? void 0 : _v.zoomFactor) || 2;
6799
+ this.panRate = ((_w = config.canvas) === null || _w === void 0 ? void 0 : _w.panRate) || 100;
6639
6800
  this.inferConnectionType = config.inferConnectionType || false;
6640
6801
  this.multipleSelectionOn = false;
6641
- this.priorityThresholds = ((_x = config.canvas) === null || _x === undefined ? undefined : _x.priorityThresholds) || [];
6802
+ this.priorityThresholds = ((_x = config.canvas) === null || _x === void 0 ? void 0 : _x.priorityThresholds) || [];
6642
6803
  this.priorityThreshold = this.priorityThresholds ? this.priorityThresholds[0] : undefined;
6643
6804
  this.layoutFormat = config.layoutFormat;
6644
6805
  this.userActions = config.userActions || {};
@@ -6689,7 +6850,7 @@ class DiagramCanvas {
6689
6850
  for (const node of this.model.nodes) {
6690
6851
  this.fitNodeInView(node.id);
6691
6852
  }
6692
- (_b = (_a = this.parentComponent) === null || _a === undefined ? undefined : _a.palette) === null || _b === undefined ? undefined : _b.refreshPalette();
6853
+ (_b = (_a = this.parentComponent) === null || _a === void 0 ? void 0 : _a.palette) === null || _b === void 0 ? void 0 : _b.refreshPalette();
6693
6854
  }
6694
6855
  // View methods
6695
6856
  initView(appendTo) {
@@ -6703,7 +6864,7 @@ class DiagramCanvas {
6703
6864
  var _a;
6704
6865
  // focus on the diagram when clicking so that we can focus on the diagram
6705
6866
  // keyboard events only work if we're focusing on the diagram
6706
- (_a = d3.select(this.diagramRoot).node()) === null || _a === undefined ? undefined : _a.focus();
6867
+ (_a = d3.select(this.diagramRoot).node()) === null || _a === void 0 ? void 0 : _a.focus();
6707
6868
  }).on(Events.ContextMenu, event => {
6708
6869
  if (this.dragging) {
6709
6870
  event.preventDefault();
@@ -6926,7 +7087,7 @@ class DiagramCanvas {
6926
7087
  var _a;
6927
7088
  // if there are no nodes, we have nothing to do here
6928
7089
  if (this.model.nodes.length > 0) {
6929
- const canvasViewBoundingBox = (_a = this.selectCanvasView().select('rect').node()) === null || _a === undefined ? undefined : _a.getBBox();
7090
+ const canvasViewBoundingBox = (_a = this.selectCanvasView().select('rect').node()) === null || _a === void 0 ? void 0 : _a.getBBox();
6930
7091
  const nonRemovedNodes = this.model.nodes.all();
6931
7092
  const minimumX = Math.min(...nonRemovedNodes.map(n => n.coords[0]));
6932
7093
  const maximumX = Math.max(...nonRemovedNodes.map(n => n.coords[0] + n.width));
@@ -6958,8 +7119,8 @@ class DiagramCanvas {
6958
7119
  }
6959
7120
  getCoordinatesOnScreen() {
6960
7121
  var _a;
6961
- const rootBoundingClientRect = (_a = this.selectSVGElement().node()) === null || _a === undefined ? undefined : _a.getBoundingClientRect();
6962
- const rootDimensions = [(rootBoundingClientRect === null || rootBoundingClientRect === undefined ? undefined : rootBoundingClientRect.width) || 0, (rootBoundingClientRect === null || rootBoundingClientRect === undefined ? undefined : rootBoundingClientRect.height) || 0];
7122
+ const rootBoundingClientRect = (_a = this.selectSVGElement().node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
7123
+ const rootDimensions = [(rootBoundingClientRect === null || rootBoundingClientRect === void 0 ? void 0 : rootBoundingClientRect.width) || 0, (rootBoundingClientRect === null || rootBoundingClientRect === void 0 ? void 0 : rootBoundingClientRect.height) || 0];
6963
7124
  return [[-this.zoomTransform.x / this.zoomTransform.k, -this.zoomTransform.y / this.zoomTransform.k], [(rootDimensions[0] - this.zoomTransform.x) / this.zoomTransform.k, (rootDimensions[1] - this.zoomTransform.y) / this.zoomTransform.k]];
6964
7125
  }
6965
7126
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -7214,7 +7375,7 @@ class DiagramCanvas {
7214
7375
  const exitSelection = updateSelection.exit();
7215
7376
  const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => {
7216
7377
  var _a, _b, _c, _d, _e;
7217
- return `diagram-section${((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) ? ' resizable-x' : ''}${((_d = (_c = d.node) === null || _c === undefined ? undefined : _c.type) === null || _d === undefined ? undefined : _d.resizableY) ? ' resizable-y' : ''} ${(_e = d.look) === null || _e === undefined ? undefined : _e.lookType}`;
7378
+ return `diagram-section${((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) ? ' resizable-x' : ''}${((_d = (_c = d.node) === null || _c === void 0 ? void 0 : _c.type) === null || _d === void 0 ? void 0 : _d.resizableY) ? ' resizable-y' : ''} ${(_e = d.look) === null || _e === void 0 ? void 0 : _e.lookType}`;
7218
7379
  });
7219
7380
  if (ids && ids.length > 0) {
7220
7381
  updateSelection = updateSelection.filter(d => ids.includes(d.id));
@@ -7263,7 +7424,7 @@ class DiagramCanvas {
7263
7424
  if (this.multipleSelectionOn || this.secondaryButton) {
7264
7425
  this.startMultipleSelection(event);
7265
7426
  } else {
7266
- const node = d === null || d === undefined ? undefined : d.node;
7427
+ const node = d === null || d === void 0 ? void 0 : d.node;
7267
7428
  if (node) {
7268
7429
  this.startMovingNode(event, node);
7269
7430
  } else {
@@ -7274,7 +7435,7 @@ class DiagramCanvas {
7274
7435
  if (this.multipleSelectionOn || this.secondaryButton) {
7275
7436
  this.continueMultipleSelection(event);
7276
7437
  } else {
7277
- const node = d === null || d === undefined ? undefined : d.node;
7438
+ const node = d === null || d === void 0 ? void 0 : d.node;
7278
7439
  if (node) {
7279
7440
  this.continueMovingNode(event, node);
7280
7441
  } else {
@@ -7285,7 +7446,7 @@ class DiagramCanvas {
7285
7446
  if (this.multipleSelectionOn || this.secondaryButton) {
7286
7447
  this.finishMultipleSelection(event);
7287
7448
  } else {
7288
- const node = d === null || d === undefined ? undefined : d.node;
7449
+ const node = d === null || d === void 0 ? void 0 : d.node;
7289
7450
  if (node) {
7290
7451
  this.finishMovingNode(event, node);
7291
7452
  } else {
@@ -7297,17 +7458,17 @@ class DiagramCanvas {
7297
7458
  initializeLook(enterSelection);
7298
7459
  enterSelection.filter('.resizable-x').append('line').attr('class', 'left-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(Events.MouseOver, (_event, d) => {
7299
7460
  var _a, _b;
7300
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7461
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
7301
7462
  setCursorStyle(CursorStyle.EWResize);
7302
7463
  }
7303
7464
  }).on(Events.MouseOut, (_event, d) => {
7304
7465
  var _a, _b;
7305
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7466
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
7306
7467
  setCursorStyle();
7307
7468
  }
7308
7469
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
7309
7470
  var _a, _b;
7310
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7471
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
7311
7472
  setCursorStyle(CursorStyle.EWResize);
7312
7473
  this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
7313
7474
  } else {
@@ -7315,13 +7476,13 @@ class DiagramCanvas {
7315
7476
  }
7316
7477
  }).on(DragEvents.Drag, (event, d) => {
7317
7478
  var _a, _b;
7318
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7479
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
7319
7480
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7320
7481
  d.node.stretchSections(Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
7321
7482
  }
7322
7483
  }).on(DragEvents.End, (event, d) => {
7323
7484
  var _a, _b;
7324
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection) {
7485
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection) {
7325
7486
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7326
7487
  if (this.snapToGrid) {
7327
7488
  pointerCoords = this.getClosestGridPoint(pointerCoords);
@@ -7336,17 +7497,17 @@ class DiagramCanvas {
7336
7497
  }));
7337
7498
  enterSelection.filter('.resizable-y').append('line').attr('class', 'top-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(Events.MouseOver, (_event, d) => {
7338
7499
  var _a, _b;
7339
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7500
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
7340
7501
  setCursorStyle(CursorStyle.NSResize);
7341
7502
  }
7342
7503
  }).on(Events.MouseOut, (_event, d) => {
7343
7504
  var _a, _b;
7344
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7505
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
7345
7506
  setCursorStyle();
7346
7507
  }
7347
7508
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
7348
7509
  var _a, _b;
7349
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7510
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
7350
7511
  setCursorStyle(CursorStyle.NSResize);
7351
7512
  this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
7352
7513
  } else {
@@ -7354,13 +7515,13 @@ class DiagramCanvas {
7354
7515
  }
7355
7516
  }).on(DragEvents.Drag, (event, d) => {
7356
7517
  var _a, _b;
7357
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7518
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
7358
7519
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7359
7520
  d.node.stretchSections(Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
7360
7521
  }
7361
7522
  }).on(DragEvents.End, (event, d) => {
7362
7523
  var _a, _b;
7363
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection) {
7524
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection) {
7364
7525
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7365
7526
  if (this.snapToGrid) {
7366
7527
  pointerCoords = this.getClosestGridPoint(pointerCoords);
@@ -7375,17 +7536,17 @@ class DiagramCanvas {
7375
7536
  }));
7376
7537
  enterSelection.filter('.resizable-x').append('line').attr('class', 'right-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(Events.MouseOver, (_event, d) => {
7377
7538
  var _a, _b;
7378
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7539
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
7379
7540
  setCursorStyle(CursorStyle.EWResize);
7380
7541
  }
7381
7542
  }).on(Events.MouseOut, (_event, d) => {
7382
7543
  var _a, _b;
7383
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7544
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
7384
7545
  setCursorStyle();
7385
7546
  }
7386
7547
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
7387
7548
  var _a, _b;
7388
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7549
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
7389
7550
  setCursorStyle(CursorStyle.EWResize);
7390
7551
  this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
7391
7552
  } else {
@@ -7393,13 +7554,13 @@ class DiagramCanvas {
7393
7554
  }
7394
7555
  }).on(DragEvents.Drag, (event, d) => {
7395
7556
  var _a, _b;
7396
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7557
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed) {
7397
7558
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7398
7559
  d.node.stretchSections(Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
7399
7560
  }
7400
7561
  }).on(DragEvents.End, (event, d) => {
7401
7562
  var _a, _b;
7402
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection) {
7563
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection) {
7403
7564
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7404
7565
  if (this.snapToGrid) {
7405
7566
  pointerCoords = this.getClosestGridPoint(pointerCoords);
@@ -7414,17 +7575,17 @@ class DiagramCanvas {
7414
7575
  }));
7415
7576
  enterSelection.filter('.resizable-y').append('line').attr('class', 'bottom-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(Events.MouseOver, (_event, d) => {
7416
7577
  var _a, _b;
7417
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7578
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
7418
7579
  setCursorStyle(CursorStyle.NSResize);
7419
7580
  }
7420
7581
  }).on(Events.MouseOut, (_event, d) => {
7421
7582
  var _a, _b;
7422
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7583
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
7423
7584
  setCursorStyle();
7424
7585
  }
7425
7586
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
7426
7587
  var _a, _b;
7427
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7588
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
7428
7589
  setCursorStyle(CursorStyle.NSResize);
7429
7590
  this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
7430
7591
  } else {
@@ -7432,13 +7593,13 @@ class DiagramCanvas {
7432
7593
  }
7433
7594
  }).on(DragEvents.Drag, (event, d) => {
7434
7595
  var _a, _b;
7435
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7596
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed) {
7436
7597
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7437
7598
  d.node.stretchSections(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
7438
7599
  }
7439
7600
  }).on(DragEvents.End, (event, d) => {
7440
7601
  var _a, _b;
7441
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection) {
7602
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection) {
7442
7603
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7443
7604
  if (this.snapToGrid) {
7444
7605
  pointerCoords = this.getClosestGridPoint(pointerCoords);
@@ -7477,13 +7638,13 @@ class DiagramCanvas {
7477
7638
  if (this.unfinishedConnection) {
7478
7639
  const canConnectionFinishAtThisPort =
7479
7640
  // can start at the starting port
7480
- this.unfinishedConnection.type.canStartFromType(((_c = (_b = (_a = this.unfinishedConnection.start) === null || _a === undefined ? undefined : _a.getNode()) === null || _b === undefined ? undefined : _b.type) === null || _c === undefined ? undefined : _c.id) || '') && ((_d = this.unfinishedConnection.start) === null || _d === undefined ? undefined : _d.allowsOutgoing) &&
7641
+ this.unfinishedConnection.type.canStartFromType(((_c = (_b = (_a = this.unfinishedConnection.start) === null || _a === void 0 ? void 0 : _a.getNode()) === null || _b === void 0 ? void 0 : _b.type) === null || _c === void 0 ? void 0 : _c.id) || '') && ((_d = this.unfinishedConnection.start) === null || _d === void 0 ? void 0 : _d.allowsOutgoing) &&
7481
7642
  // can end at the ending port
7482
- this.unfinishedConnection.type.canFinishOnType(((_f = (_e = d.getNode()) === null || _e === undefined ? undefined : _e.type) === null || _f === undefined ? undefined : _f.id) || '') && d.allowsIncoming ||
7643
+ this.unfinishedConnection.type.canFinishOnType(((_f = (_e = d.getNode()) === null || _e === void 0 ? void 0 : _e.type) === null || _f === void 0 ? void 0 : _f.id) || '') && d.allowsIncoming ||
7483
7644
  // can start at the ending port
7484
- this.unfinishedConnection.type.canStartFromType(((_h = (_g = d.getNode()) === null || _g === undefined ? undefined : _g.type) === null || _h === undefined ? undefined : _h.id) || '') && d.allowsOutgoing &&
7645
+ this.unfinishedConnection.type.canStartFromType(((_h = (_g = d.getNode()) === null || _g === void 0 ? void 0 : _g.type) === null || _h === void 0 ? void 0 : _h.id) || '') && d.allowsOutgoing &&
7485
7646
  // can end at the starting port
7486
- this.unfinishedConnection.type.canFinishOnType(((_l = (_k = (_j = this.unfinishedConnection.start) === null || _j === undefined ? undefined : _j.getNode()) === null || _k === undefined ? undefined : _k.type) === null || _l === undefined ? undefined : _l.id) || '') && ((_m = this.unfinishedConnection.start) === null || _m === undefined ? undefined : _m.allowsIncoming);
7647
+ this.unfinishedConnection.type.canFinishOnType(((_l = (_k = (_j = this.unfinishedConnection.start) === null || _j === void 0 ? void 0 : _j.getNode()) === null || _k === void 0 ? void 0 : _k.type) === null || _l === void 0 ? void 0 : _l.id) || '') && ((_m = this.unfinishedConnection.start) === null || _m === void 0 ? void 0 : _m.allowsIncoming);
7487
7648
  if (!canConnectionFinishAtThisPort) {
7488
7649
  setCursorStyle(CursorStyle.NoDrop);
7489
7650
  }
@@ -7548,8 +7709,8 @@ class DiagramCanvas {
7548
7709
  if (this.canUserPerformAction(DiagramActions.AddConnection) && !d.removed) {
7549
7710
  if (this.unfinishedConnection !== undefined) {
7550
7711
  const endCoords = [event.x, event.y];
7551
- (_a = this.unfinishedConnectionTracer) === null || _a === undefined ? undefined : _a.attr('d', getConnectionPath(this.unfinishedConnection.look.shape, this.unfinishedConnection.startCoords, endCoords, this.unfinishedConnection.startDirection, this.unfinishedConnection.endDirection, this.unfinishedConnection.look.thickness, (_b = this.unfinishedConnection.startMarkerLook) === null || _b === undefined ? undefined : _b.width, (_c = this.unfinishedConnection.endMarkerLook) === null || _c === undefined ? undefined : _c.width));
7552
- const unfinishedConnectionGhostNode = (_d = this.unfinishedConnectionTracer) === null || _d === undefined ? undefined : _d.node();
7712
+ (_a = this.unfinishedConnectionTracer) === null || _a === void 0 ? void 0 : _a.attr('d', getConnectionPath(this.unfinishedConnection.look.shape, this.unfinishedConnection.startCoords, endCoords, this.unfinishedConnection.startDirection, this.unfinishedConnection.endDirection, this.unfinishedConnection.look.thickness, (_b = this.unfinishedConnection.startMarkerLook) === null || _b === void 0 ? void 0 : _b.width, (_c = this.unfinishedConnection.endMarkerLook) === null || _c === void 0 ? void 0 : _c.width));
7713
+ const unfinishedConnectionGhostNode = (_d = this.unfinishedConnectionTracer) === null || _d === void 0 ? void 0 : _d.node();
7553
7714
  if (unfinishedConnectionGhostNode) {
7554
7715
  let margin = 2;
7555
7716
  const unfinishedConnectionTotalLength = unfinishedConnectionGhostNode.getTotalLength();
@@ -7590,7 +7751,7 @@ class DiagramCanvas {
7590
7751
  this.finishMultipleSelection(event);
7591
7752
  } else {
7592
7753
  if (this.canUserPerformAction(DiagramActions.AddConnection) && !d.removed) {
7593
- (_a = this.unfinishedConnectionTracer) === null || _a === undefined ? undefined : _a.remove();
7754
+ (_a = this.unfinishedConnectionTracer) === null || _a === void 0 ? void 0 : _a.remove();
7594
7755
  const userHighlight = this.userHighlight.getFocus();
7595
7756
  if (userHighlight instanceof DiagramPort) {
7596
7757
  this.finishConnection(userHighlight);
@@ -7696,11 +7857,11 @@ class DiagramCanvas {
7696
7857
  enterSelection.select('g.diagram-connection-end-label').append('text').style('user-select', 'none');
7697
7858
  mergeSelection.attr('opacity', d => d.removed ? 0.5 : 1).select('path.diagram-connection-path').attr('d', d => {
7698
7859
  var _a, _b;
7699
- return getConnectionPath(d.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.look.thickness, (_a = d.startMarkerLook) === null || _a === undefined ? undefined : _a.width, (_b = d.endMarkerLook) === null || _b === undefined ? undefined : _b.width);
7860
+ return getConnectionPath(d.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.look.thickness, (_a = d.startMarkerLook) === null || _a === void 0 ? void 0 : _a.width, (_b = d.endMarkerLook) === null || _b === void 0 ? void 0 : _b.width);
7700
7861
  }).attr('marker-start', d => `url(#${d.id}-start-marker)`).attr('marker-end', d => `url(#${d.id}-end-marker)`).attr('stroke', d => d.look.color).attr('stroke-width', d => `${d.look.thickness}px`).attr('stroke-dasharray', d => lineStyleDasharray(d.look.style, d.look.thickness)).attr('fill', 'none');
7701
7862
  mergeSelection.select('path.diagram-connection-path-box').attr('d', d => {
7702
7863
  var _a, _b;
7703
- return getConnectionPath(d.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.look.thickness, (_a = d.startMarkerLook) === null || _a === undefined ? undefined : _a.width, (_b = d.endMarkerLook) === null || _b === undefined ? undefined : _b.width);
7864
+ return getConnectionPath(d.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.look.thickness, (_a = d.startMarkerLook) === null || _a === void 0 ? void 0 : _a.width, (_b = d.endMarkerLook) === null || _b === void 0 ? void 0 : _b.width);
7704
7865
  }).attr('stroke', 'transparent')
7705
7866
  // allow generating pointer events even when it is transparent
7706
7867
  .attr('pointer-events', 'stroke').attr('stroke-width', d => `${d.look.thickness + CONNECTION_PATH_BOX_THICKNESS}px`).attr('stroke-dasharray', d => lineStyleDasharray(d.look.style, d.look.thickness)).attr('fill', 'none');
@@ -7755,8 +7916,12 @@ class DiagramCanvas {
7755
7916
  this.diagramEvent$.next(diagramEvent);
7756
7917
  if (!diagramEvent.defaultPrevented && this.canUserPerformAction(DiagramActions.EditField) && d.editable && !d.removed) {
7757
7918
  this.currentAction = new EditFieldAction(this, d.id, d.text, '');
7758
- this.createInputField(d.text, d.coords, d.width, d.height, d.fontSize, d.fontFamily || DIAGRAM_FIELD_DEFAULTS.fontFamily, text => {
7759
- d.text = text;
7919
+ this.createInputField(d.text, d.coords, d.width, d.height, d.fontSize, d.fontFamily || DIAGRAM_FIELD_DEFAULTS.fontFamily, d.orientation, text => {
7920
+ /*
7921
+ Empty for now
7922
+ We should create a better function to stretch the root element as the text expands
7923
+ Bear in mind that DiagramNode.setGeometry() calls DiagramNode.raise(), which breaks the input field
7924
+ */
7760
7925
  }, text => {
7761
7926
  d.text = text;
7762
7927
  if (this.currentAction instanceof EditFieldAction) {
@@ -7820,7 +7985,24 @@ class DiagramCanvas {
7820
7985
  }
7821
7986
  this.secondaryButton = false;
7822
7987
  })).append('xhtml:div').style('width', '100%').style('height', '100%').style('display', 'flex').append('xhtml:p').style('box-sizing', 'border-box').style('outline', 0).style('margin', 0).style('border', 0).style('padding', 0).style('user-select', 'none').style('font-kerning', 'none').style('white-space', 'nowrap');
7823
- mergeSelection.attr('x', 0).attr('y', 0).attr('width', d => `${d.width}px`).attr('height', d => `${d.height}px`).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1).select('div').style('justify-content', d => d.horizontalAlign === HorizontalAlign.Center ? 'center' : d.horizontalAlign === HorizontalAlign.Right ? 'flex-end' : 'flex-start').style('align-items', d => d.verticalAlign === VerticalAlign.Center ? 'center' : d.verticalAlign === VerticalAlign.Bottom ? 'end' : 'start').select('p').style('max-width', d => d.fit ? 'default' : '100%').style('max-height', d => d.fit ? 'default' : '100%').style('overflow', d => d.fit ? 'default' : 'hidden').style('text-overflow', d => d.fit ? 'default' : 'ellipsis').style('text-align', d => d.horizontalAlign === HorizontalAlign.Center ? 'center' : d.horizontalAlign === HorizontalAlign.Right ? 'end' : 'start').style('font-size', d => `${d.fontSize}px`).style('font-family', d => d.fontFamily || "'Wonder Unit Sans', sans-serif").style('font-weight', d => d.highlighted ? 600 : 400).style('color', d => d.selected ? d.selectedColor || '#000000' : d.color || '#000000').html(d => d.text.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g, '<br/>'));
7988
+ mergeSelection.attr('x', 0).attr('y', 0).attr('width', d => `${d.width}px`).attr('height', d => `${d.height}px`).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1).select('div').style('justify-content', d => d.horizontalAlign === HorizontalAlign.Center ? 'center' : d.horizontalAlign === HorizontalAlign.Right ? 'flex-end' : 'flex-start').style('align-items', d => d.verticalAlign === VerticalAlign.Center ? 'center' : d.verticalAlign === VerticalAlign.Bottom ? 'end' : 'start').select('p').style('max-width', d => d.fit ? 'default' : '100%').style('max-height', d => d.fit ? 'default' : '100%').style('overflow', d => d.fit ? 'default' : 'hidden').style('text-overflow', d => d.fit ? 'default' : 'ellipsis').style('text-align', d => d.horizontalAlign === HorizontalAlign.Center ? 'center' : d.horizontalAlign === HorizontalAlign.Right ? 'end' : 'start').style('transform', d => {
7989
+ if (!isNaN(Number(d.orientation))) {
7990
+ return `rotate(${d.orientation}deg)`;
7991
+ } else {
7992
+ switch (d.orientation) {
7993
+ case Side.Top:
7994
+ return 'rotate(0deg)';
7995
+ case Side.Right:
7996
+ return 'rotate(90deg)';
7997
+ case Side.Bottom:
7998
+ return 'rotate(180deg)';
7999
+ case Side.Left:
8000
+ return 'rotate(270deg)';
8001
+ default:
8002
+ return 'rotate(0deg)';
8003
+ }
8004
+ }
8005
+ }).style('font-size', d => `${d.fontSize}px`).style('font-family', d => d.fontFamily || "'Wonder Unit Sans', sans-serif").style('font-weight', d => d.highlighted ? 600 : 400).style('color', d => d.selected ? d.selectedColor || '#000000' : d.color || '#000000').html(d => d.text.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g, '<br/>'));
7824
8006
  }
7825
8007
  updateObjectsInView(...ids) {
7826
8008
  let updateSelection = this.selectCanvasElements().selectAll('foreignObject.diagram-object').data(this.model.objects.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
@@ -7970,7 +8152,7 @@ class DiagramCanvas {
7970
8152
  }
7971
8153
  updateConnectionLabelsInView(connection) {
7972
8154
  var _a, _b, _c;
7973
- const connectionSelection = this.selectCanvasView().select(`g.diagram-connection#${connection.id}`);
8155
+ const connectionSelection = this.selectCanvasView().select(`[id='${escapeSelector(connection.id)}']`);
7974
8156
  const pathSelection = connectionSelection.select('path');
7975
8157
  const pathNode = pathSelection.node();
7976
8158
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), connection.type.label);
@@ -7978,7 +8160,7 @@ class DiagramCanvas {
7978
8160
  const pathLength = pathNode.getTotalLength();
7979
8161
  // bind start labels
7980
8162
  connectionSelection.select('g.diagram-connection-start-label text').attr('x', 0).attr('y', labelConfiguration.fontSize / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.fontFamily).attr('font-size', labelConfiguration.fontSize).attr('fill', connection.selected ? labelConfiguration.selectedColor : labelConfiguration.color).style('font-kerning', 'none').text(connection.startLabel);
7981
- const startLabelBoundingRect = (_a = connectionSelection.select('g.diagram-connection-start-label text').node()) === null || _a === undefined ? undefined : _a.getBoundingClientRect();
8163
+ const startLabelBoundingRect = (_a = connectionSelection.select('g.diagram-connection-start-label text').node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
7982
8164
  if (startLabelBoundingRect) {
7983
8165
  // don't create space for the label if the label is empty
7984
8166
  const boundingWidth = !connection.startLabel ? 0 : startLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
@@ -7989,7 +8171,7 @@ class DiagramCanvas {
7989
8171
  }
7990
8172
  // bind middle labels
7991
8173
  connectionSelection.select('g.diagram-connection-middle-label text').attr('x', 0).attr('y', labelConfiguration.fontSize / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.fontFamily).attr('font-size', labelConfiguration.fontSize).attr('fill', connection.selected ? labelConfiguration.selectedColor : labelConfiguration.color).style('font-kerning', 'none').text(connection.middleLabel);
7992
- const middleLabelBoundingRect = (_b = connectionSelection.select('g.diagram-connection-middle-label text').node()) === null || _b === undefined ? undefined : _b.getBoundingClientRect();
8174
+ const middleLabelBoundingRect = (_b = connectionSelection.select('g.diagram-connection-middle-label text').node()) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
7993
8175
  if (middleLabelBoundingRect) {
7994
8176
  // don't create space for the label if the label is empty
7995
8177
  const boundingWidth = !connection.middleLabel ? 0 : middleLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
@@ -8000,7 +8182,7 @@ class DiagramCanvas {
8000
8182
  }
8001
8183
  // bind end labels
8002
8184
  connectionSelection.select('g.diagram-connection-end-label text').attr('x', 0).attr('y', labelConfiguration.fontSize / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.fontFamily).attr('font-size', labelConfiguration.fontSize).attr('fill', connection.selected ? labelConfiguration.selectedColor : labelConfiguration.color).style('font-kerning', 'none').text(connection.endLabel);
8003
- const endLabelBoundingRect = (_c = connectionSelection.select('g.diagram-connection-end-label text').node()) === null || _c === undefined ? undefined : _c.getBoundingClientRect();
8185
+ const endLabelBoundingRect = (_c = connectionSelection.select('g.diagram-connection-end-label text').node()) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect();
8004
8186
  if (endLabelBoundingRect) {
8005
8187
  // don't create space for the label if the label is empty
8006
8188
  const boundingWidth = !connection.endLabel ? 0 : endLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
@@ -8012,7 +8194,7 @@ class DiagramCanvas {
8012
8194
  }
8013
8195
  }
8014
8196
  updateConnectionMarkersInView(connection) {
8015
- const connectionSelection = this.selectCanvasView().select(`g.diagram-connection#${connection.id}`);
8197
+ const connectionSelection = this.selectCanvasView().select(`[id='${escapeSelector(connection.id)}']`);
8016
8198
  const startMarkerSelection = connectionSelection.select('marker.diagram-connection-start-marker');
8017
8199
  const endMarkerSelection = connectionSelection.select('marker.diagram-connection-end-marker');
8018
8200
  if (connection.startMarkerLook !== null) {
@@ -8026,13 +8208,27 @@ class DiagramCanvas {
8026
8208
  endMarkerSelection.attr('orient', 'auto-start-reverse').attr('markerWidth', 0).attr('markerHeight', 0);
8027
8209
  }
8028
8210
  }
8029
- fitFieldRootInView(id) {
8211
+ fieldRootFitsInView(id) {
8212
+ var _a, _b, _c, _d;
8213
+ const field = this.model.fields.get(id);
8214
+ if (!field) {
8215
+ return false;
8216
+ }
8217
+ if (field.rootElement instanceof DiagramNode || field.rootElement instanceof DiagramSection) {
8218
+ const fieldDimensions = this.minimumSizeOfField(field);
8219
+ const stretchX = fieldDimensions[0] + getLeftMargin((_a = field.rootElement.type) === null || _a === void 0 ? void 0 : _a.label) + getRightMargin((_b = field.rootElement.type) === null || _b === void 0 ? void 0 : _b.label) - field.rootElement.width;
8220
+ const stretchY = fieldDimensions[1] + getTopMargin((_c = field.rootElement.type) === null || _c === void 0 ? void 0 : _c.label) + getBottomMargin((_d = field.rootElement.type) === null || _d === void 0 ? void 0 : _d.label) - field.rootElement.height;
8221
+ return stretchX <= 0 && stretchY <= 0;
8222
+ }
8223
+ return true;
8224
+ }
8225
+ fitFieldRootInView(id, shrink) {
8030
8226
  var _a, _b, _c;
8031
8227
  const field = this.model.fields.get(id);
8032
8228
  if (!field) {
8033
8229
  return;
8034
8230
  }
8035
- if (field.rootElement instanceof DiagramNode && field.fit) {
8231
+ if (field.rootElement instanceof DiagramNode) {
8036
8232
  const fieldDimensions = this.minimumSizeOfField(field);
8037
8233
  let stretchX = fieldDimensions[0] + getLeftMargin(field.rootElement.type.label) + getRightMargin(field.rootElement.type.label) - field.rootElement.width;
8038
8234
  let stretchY = fieldDimensions[1] + getTopMargin(field.rootElement.type.label) + getBottomMargin(field.rootElement.type.label) - field.rootElement.height;
@@ -8047,14 +8243,18 @@ class DiagramCanvas {
8047
8243
  if (field.rootElement.height + stretchY < field.rootElement.type.minHeight) {
8048
8244
  stretchY = field.rootElement.type.minHeight - field.rootElement.height;
8049
8245
  }
8050
- field.rootElement.stretch(Side.Right, stretchX);
8051
- field.rootElement.stretch(Side.Bottom, stretchY);
8246
+ if (shrink !== false || stretchX > 0) {
8247
+ field.rootElement.stretch(Side.Right, stretchX);
8248
+ }
8249
+ if (shrink !== false || stretchY > 0) {
8250
+ field.rootElement.stretch(Side.Bottom, stretchY);
8251
+ }
8052
8252
  }
8053
- if (field.rootElement instanceof DiagramSection && field.fit) {
8253
+ if (field.rootElement instanceof DiagramSection) {
8054
8254
  const fieldDimensions = this.minimumSizeOfField(field);
8055
8255
  let minimumFieldWidth = fieldDimensions[0];
8056
8256
  let minimumFieldHeight = fieldDimensions[1];
8057
- for (const section of ((_a = field.rootElement.node) === null || _a === undefined ? undefined : _a.sections) || []) {
8257
+ for (const section of ((_a = field.rootElement.node) === null || _a === void 0 ? void 0 : _a.sections) || []) {
8058
8258
  if (section.label) {
8059
8259
  if (section.indexXInNode === field.rootElement.indexXInNode && section.indexYInNode !== field.rootElement.indexYInNode) {
8060
8260
  minimumFieldWidth = Math.max(minimumFieldWidth, this.minimumSizeOfField(section.label)[0]);
@@ -8070,8 +8270,8 @@ class DiagramCanvas {
8070
8270
  fieldDimensions[1] = minimumFieldHeight;
8071
8271
  }
8072
8272
  const type = field.rootElement.type;
8073
- let stretchX = fieldDimensions[0] + getLeftMargin(type === null || type === undefined ? undefined : type.label) + getRightMargin(type === null || type === undefined ? undefined : type.label) - field.rootElement.width;
8074
- let stretchY = fieldDimensions[1] + getTopMargin(type === null || type === undefined ? undefined : type.label) + getBottomMargin(type === null || type === undefined ? undefined : type.label) - field.rootElement.height;
8273
+ let stretchX = fieldDimensions[0] + getLeftMargin(type === null || type === void 0 ? void 0 : type.label) + getRightMargin(type === null || type === void 0 ? void 0 : type.label) - field.rootElement.width;
8274
+ let stretchY = fieldDimensions[1] + getTopMargin(type === null || type === void 0 ? void 0 : type.label) + getBottomMargin(type === null || type === void 0 ? void 0 : type.label) - field.rootElement.height;
8075
8275
  if (this.snapToGrid) {
8076
8276
  stretchX = Math.ceil(stretchX / this.gridSize) * this.gridSize;
8077
8277
  stretchY = Math.ceil(stretchY / this.gridSize) * this.gridSize;
@@ -8083,8 +8283,12 @@ class DiagramCanvas {
8083
8283
  if (field.rootElement.height + stretchY < (field.rootElement.getMinHeight() || 0)) {
8084
8284
  stretchY = (field.rootElement.getMinHeight() || 0) - field.rootElement.height;
8085
8285
  }
8086
- (_b = field.rootElement.node) === null || _b === undefined ? undefined : _b.stretchSections(Side.Right, stretchX, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
8087
- (_c = field.rootElement.node) === null || _c === undefined ? undefined : _c.stretchSections(Side.Bottom, stretchY, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
8286
+ if (shrink !== false || stretchX > 0) {
8287
+ (_b = field.rootElement.node) === null || _b === void 0 ? void 0 : _b.stretchSections(Side.Right, stretchX, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
8288
+ }
8289
+ if (shrink !== false || stretchY > 0) {
8290
+ (_c = field.rootElement.node) === null || _c === void 0 ? void 0 : _c.stretchSections(Side.Bottom, stretchY, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
8291
+ }
8088
8292
  }
8089
8293
  }
8090
8294
  fitNodeInView(id) {
@@ -8106,8 +8310,8 @@ class DiagramCanvas {
8106
8310
  }
8107
8311
  }
8108
8312
  // add the margin that goes between the rightmost and bottommost points of the sections and the edge of the node
8109
- newNodeWidth += ((_a = node.type.sectionGrid) === null || _a === undefined ? undefined : _a.margin) || 0;
8110
- newNodeHeight += ((_b = node.type.sectionGrid) === null || _b === undefined ? undefined : _b.margin) || 0;
8313
+ newNodeWidth += ((_a = node.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
8314
+ newNodeHeight += ((_b = node.type.sectionGrid) === null || _b === void 0 ? void 0 : _b.margin) || 0;
8111
8315
  node.stretch(Side.Right, newNodeWidth - node.width);
8112
8316
  node.stretch(Side.Bottom, newNodeHeight - node.height);
8113
8317
  }
@@ -8128,18 +8332,18 @@ class DiagramCanvas {
8128
8332
  startConnection(port) {
8129
8333
  var _a, _b, _c, _d;
8130
8334
  if (port.allowsOutgoing || port.allowsIncoming) {
8131
- if (this.connectionType && (this.connectionType.canStartFromType(((_b = (_a = port.getNode()) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.id) || '') && port.allowsOutgoing || this.connectionType.canFinishOnType(((_d = (_c = port.getNode()) === null || _c === undefined ? undefined : _c.type) === null || _d === undefined ? undefined : _d.id) || '') && port.allowsIncoming)) {
8335
+ if (this.connectionType && (this.connectionType.canStartFromType(((_b = (_a = port.getNode()) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.id) || '') && port.allowsOutgoing || this.connectionType.canFinishOnType(((_d = (_c = port.getNode()) === null || _c === void 0 ? void 0 : _c.type) === null || _d === void 0 ? void 0 : _d.id) || '') && port.allowsIncoming)) {
8132
8336
  this.unfinishedConnection = new DiagramConnection(this.model, this.connectionType, port, undefined, UNFINISHED_CONNECTION_ID);
8133
8337
  } else {
8134
8338
  if (this.inferConnectionType) {
8135
8339
  let differentConnectionType = this.model.connections.types.all().find(t => {
8136
8340
  var _a, _b;
8137
- return port.allowsOutgoing && t.canStartFromType(((_b = (_a = port.getNode()) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.id) || '');
8341
+ return port.allowsOutgoing && t.canStartFromType(((_b = (_a = port.getNode()) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.id) || '');
8138
8342
  });
8139
8343
  if (differentConnectionType === undefined) {
8140
8344
  differentConnectionType = this.model.connections.types.all().find(t => {
8141
8345
  var _a, _b;
8142
- return port.allowsIncoming && t.canFinishOnType(((_b = (_a = port.getNode()) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.id) || '');
8346
+ return port.allowsIncoming && t.canFinishOnType(((_b = (_a = port.getNode()) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.id) || '');
8143
8347
  });
8144
8348
  }
8145
8349
  if (differentConnectionType !== undefined) {
@@ -8154,14 +8358,14 @@ class DiagramCanvas {
8154
8358
  this.userHighlight.clear();
8155
8359
  if (this.unfinishedConnection !== undefined) {
8156
8360
  if (this.unfinishedConnection.start !== port) {
8157
- if (this.unfinishedConnection.type.canStartFromType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a === undefined ? undefined : _a.start) === null || _b === undefined ? undefined : _b.getNode()) === null || _c === undefined ? undefined : _c.type) === null || _d === undefined ? undefined : _d.id) || '') && ((_f = (_e = this.unfinishedConnection) === null || _e === undefined ? undefined : _e.start) === null || _f === undefined ? undefined : _f.allowsOutgoing) && this.unfinishedConnection.type.canFinishOnType(((_h = (_g = port.getNode()) === null || _g === undefined ? undefined : _g.type) === null || _h === undefined ? undefined : _h.id) || '') && port.allowsIncoming) {
8158
- const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, (_j = this.unfinishedConnection.start) === null || _j === undefined ? undefined : _j.id, port.id);
8361
+ if (this.unfinishedConnection.type.canStartFromType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a === void 0 ? void 0 : _a.start) === null || _b === void 0 ? void 0 : _b.getNode()) === null || _c === void 0 ? void 0 : _c.type) === null || _d === void 0 ? void 0 : _d.id) || '') && ((_f = (_e = this.unfinishedConnection) === null || _e === void 0 ? void 0 : _e.start) === null || _f === void 0 ? void 0 : _f.allowsOutgoing) && this.unfinishedConnection.type.canFinishOnType(((_h = (_g = port.getNode()) === null || _g === void 0 ? void 0 : _g.type) === null || _h === void 0 ? void 0 : _h.id) || '') && port.allowsIncoming) {
8362
+ const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, (_j = this.unfinishedConnection.start) === null || _j === void 0 ? void 0 : _j.id, port.id);
8159
8363
  // clean up the previous unfinished connection
8160
8364
  this.dropConnection();
8161
8365
  addConnectionAction.do();
8162
8366
  this.actionStack.add(addConnectionAction);
8163
- } else if (this.unfinishedConnection.type.canFinishOnType(((_o = (_m = (_l = (_k = this.unfinishedConnection) === null || _k === undefined ? undefined : _k.start) === null || _l === undefined ? undefined : _l.getNode()) === null || _m === undefined ? undefined : _m.type) === null || _o === undefined ? undefined : _o.id) || '') && ((_q = (_p = this.unfinishedConnection) === null || _p === undefined ? undefined : _p.start) === null || _q === undefined ? undefined : _q.allowsIncoming) && this.unfinishedConnection.type.canStartFromType(((_s = (_r = port.getNode()) === null || _r === undefined ? undefined : _r.type) === null || _s === undefined ? undefined : _s.id) || '') && port.allowsOutgoing) {
8164
- const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, port.id, (_t = this.unfinishedConnection.start) === null || _t === undefined ? undefined : _t.id);
8367
+ } else if (this.unfinishedConnection.type.canFinishOnType(((_o = (_m = (_l = (_k = this.unfinishedConnection) === null || _k === void 0 ? void 0 : _k.start) === null || _l === void 0 ? void 0 : _l.getNode()) === null || _m === void 0 ? void 0 : _m.type) === null || _o === void 0 ? void 0 : _o.id) || '') && ((_q = (_p = this.unfinishedConnection) === null || _p === void 0 ? void 0 : _p.start) === null || _q === void 0 ? void 0 : _q.allowsIncoming) && this.unfinishedConnection.type.canStartFromType(((_s = (_r = port.getNode()) === null || _r === void 0 ? void 0 : _r.type) === null || _s === void 0 ? void 0 : _s.id) || '') && port.allowsOutgoing) {
8368
+ const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, port.id, (_t = this.unfinishedConnection.start) === null || _t === void 0 ? void 0 : _t.id);
8165
8369
  // clean up the previous unfinished connection
8166
8370
  this.dropConnection();
8167
8371
  addConnectionAction.do();
@@ -8170,18 +8374,18 @@ class DiagramCanvas {
8170
8374
  if (this.inferConnectionType) {
8171
8375
  let differentConnectionType = this.model.connections.types.all().find(t => {
8172
8376
  var _a, _b, _c, _d, _e, _f, _g, _h;
8173
- return t.canStartFromType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a === undefined ? undefined : _a.start) === null || _b === undefined ? undefined : _b.getNode()) === null || _c === undefined ? undefined : _c.type) === null || _d === undefined ? undefined : _d.id) || '') && ((_f = (_e = this.unfinishedConnection) === null || _e === undefined ? undefined : _e.start) === null || _f === undefined ? undefined : _f.allowsOutgoing) && t.canFinishOnType(((_h = (_g = port.getNode()) === null || _g === undefined ? undefined : _g.type) === null || _h === undefined ? undefined : _h.id) || '') && port.allowsIncoming;
8377
+ return t.canStartFromType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a === void 0 ? void 0 : _a.start) === null || _b === void 0 ? void 0 : _b.getNode()) === null || _c === void 0 ? void 0 : _c.type) === null || _d === void 0 ? void 0 : _d.id) || '') && ((_f = (_e = this.unfinishedConnection) === null || _e === void 0 ? void 0 : _e.start) === null || _f === void 0 ? void 0 : _f.allowsOutgoing) && t.canFinishOnType(((_h = (_g = port.getNode()) === null || _g === void 0 ? void 0 : _g.type) === null || _h === void 0 ? void 0 : _h.id) || '') && port.allowsIncoming;
8174
8378
  });
8175
8379
  let invertConnection = false;
8176
8380
  if (differentConnectionType === undefined) {
8177
8381
  differentConnectionType = this.model.connections.types.all().find(t => {
8178
8382
  var _a, _b, _c, _d, _e, _f, _g, _h;
8179
- return t.canFinishOnType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a === undefined ? undefined : _a.start) === null || _b === undefined ? undefined : _b.getNode()) === null || _c === undefined ? undefined : _c.type) === null || _d === undefined ? undefined : _d.id) || '') && ((_f = (_e = this.unfinishedConnection) === null || _e === undefined ? undefined : _e.start) === null || _f === undefined ? undefined : _f.allowsIncoming) && t.canStartFromType(((_h = (_g = port.getNode()) === null || _g === undefined ? undefined : _g.type) === null || _h === undefined ? undefined : _h.id) || '') && port.allowsOutgoing;
8383
+ return t.canFinishOnType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a === void 0 ? void 0 : _a.start) === null || _b === void 0 ? void 0 : _b.getNode()) === null || _c === void 0 ? void 0 : _c.type) === null || _d === void 0 ? void 0 : _d.id) || '') && ((_f = (_e = this.unfinishedConnection) === null || _e === void 0 ? void 0 : _e.start) === null || _f === void 0 ? void 0 : _f.allowsIncoming) && t.canStartFromType(((_h = (_g = port.getNode()) === null || _g === void 0 ? void 0 : _g.type) === null || _h === void 0 ? void 0 : _h.id) || '') && port.allowsOutgoing;
8180
8384
  });
8181
8385
  invertConnection = true;
8182
8386
  }
8183
8387
  if (differentConnectionType !== undefined) {
8184
- const addConnectionAction = new AddConnectionAction(this, differentConnectionType, invertConnection ? port.id : (_u = this.unfinishedConnection.start) === null || _u === undefined ? undefined : _u.id, invertConnection ? (_v = this.unfinishedConnection.start) === null || _v === undefined ? undefined : _v.id : port.id);
8388
+ const addConnectionAction = new AddConnectionAction(this, differentConnectionType, invertConnection ? port.id : (_u = this.unfinishedConnection.start) === null || _u === void 0 ? void 0 : _u.id, invertConnection ? (_v = this.unfinishedConnection.start) === null || _v === void 0 ? void 0 : _v.id : port.id);
8185
8389
  // clean up the previous unfinished connection
8186
8390
  this.dropConnection();
8187
8391
  addConnectionAction.do();
@@ -8203,9 +8407,9 @@ class DiagramCanvas {
8203
8407
  }
8204
8408
  dropConnection() {
8205
8409
  var _a, _b, _c, _d;
8206
- (_a = this.unfinishedConnection) === null || _a === undefined ? undefined : _a.setStart(undefined);
8207
- (_b = this.unfinishedConnection) === null || _b === undefined ? undefined : _b.setEnd(undefined);
8208
- (_d = (_c = this.unfinishedConnection) === null || _c === undefined ? undefined : _c.select()) === null || _d === undefined ? undefined : _d.remove();
8410
+ (_a = this.unfinishedConnection) === null || _a === void 0 ? void 0 : _a.setStart(undefined);
8411
+ (_b = this.unfinishedConnection) === null || _b === void 0 ? void 0 : _b.setEnd(undefined);
8412
+ (_d = (_c = this.unfinishedConnection) === null || _c === void 0 ? void 0 : _c.select()) === null || _d === void 0 ? void 0 : _d.remove();
8209
8413
  this.unfinishedConnection = undefined;
8210
8414
  }
8211
8415
  cancelAllUserActions() {
@@ -8218,7 +8422,7 @@ class DiagramCanvas {
8218
8422
  canUserPerformAction(action) {
8219
8423
  return this.userActions[action] !== false;
8220
8424
  }
8221
- createInputField(text, coords, width, height, fontSize, fontFamily, changeCallback, finishCallback) {
8425
+ createInputField(text, coords, width, height, fontSize, fontFamily, orientation, changeCallback, finishCallback) {
8222
8426
  // if we have a text input open, close it before creating a new one
8223
8427
  this.removeInputField();
8224
8428
  const inputFieldContainer = this.selectCanvasElements().append('foreignObject').attr('x', `${coords[0]}px`).attr('y', `${coords[1]}px`).attr('width', `${width}px`).attr('height', `${height}px`).style('box-sizing', 'border-box').style('border', '1px solid');
@@ -8250,9 +8454,9 @@ class DiagramCanvas {
8250
8454
  // keep the field from shrinking below its original size
8251
8455
  const newWidth = Math.max(inputFieldWidth, width);
8252
8456
  const newHeight = Math.max(inputFieldHeight, height);
8253
- inputFieldContainer === null || inputFieldContainer === undefined ? undefined : inputFieldContainer.attr('width', `${newWidth}px`);
8457
+ inputFieldContainer === null || inputFieldContainer === void 0 ? void 0 : inputFieldContainer.attr('width', `${newWidth}px`);
8254
8458
  inputField.style('width', `${newWidth}px`);
8255
- inputFieldContainer === null || inputFieldContainer === undefined ? undefined : inputFieldContainer.attr('height', `${newHeight}px`);
8459
+ inputFieldContainer === null || inputFieldContainer === void 0 ? void 0 : inputFieldContainer.attr('height', `${newHeight}px`);
8256
8460
  inputField.style('height', `${newHeight}px`);
8257
8461
  if (changeCallback) {
8258
8462
  changeCallback(value);
@@ -8274,13 +8478,13 @@ class DiagramCanvas {
8274
8478
  var _a, _b, _c;
8275
8479
  // when removing an element, a blur event is emitted
8276
8480
  // we remove the listener for blur so that it doesn't shoot again on element removal
8277
- (_b = (_a = this.inputFieldContainer) === null || _a === undefined ? undefined : _a.select('input')) === null || _b === undefined ? undefined : _b.on(Events.Blur, null);
8278
- (_c = this.inputFieldContainer) === null || _c === undefined ? undefined : _c.remove();
8481
+ (_b = (_a = this.inputFieldContainer) === null || _a === void 0 ? void 0 : _a.select('input')) === null || _b === void 0 ? void 0 : _b.on(Events.Blur, null);
8482
+ (_c = this.inputFieldContainer) === null || _c === void 0 ? void 0 : _c.remove();
8279
8483
  this.inputFieldContainer = undefined;
8280
8484
  }
8281
8485
  minimumSizeOfField(field) {
8282
8486
  var _a, _b;
8283
- const pNode = (_b = (_a = field.select()) === null || _a === undefined ? undefined : _a.select('p')) === null || _b === undefined ? undefined : _b.node();
8487
+ const pNode = (_b = (_a = field.select()) === null || _a === void 0 ? void 0 : _a.select('p')) === null || _b === void 0 ? void 0 : _b.node();
8284
8488
  if (!pNode) {
8285
8489
  // happens when a field has been created but not updated in view yet
8286
8490
  return [0, 0];
@@ -8299,7 +8503,7 @@ class DiagramCanvas {
8299
8503
  this.currentAction = new MoveAction(this, this.userSelection.filter(e => e instanceof DiagramNode).map(n => n.id), d.coords);
8300
8504
  } else {
8301
8505
  const ancestorOfNode = d.getLastAncestor();
8302
- this.currentAction = new SetGeometryAction(this, DiagramActions.MoveNode, d.id, d.getGeometry(), d.getGeometry(), ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.id, ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.getGeometry(d.id), ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.getGeometry(d.id));
8506
+ this.currentAction = new SetGeometryAction(this, DiagramActions.MoveNode, d.id, d.getGeometry(), d.getGeometry(), ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.id, ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id), ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id));
8303
8507
  }
8304
8508
  } else {
8305
8509
  setCursorStyle(CursorStyle.NotAllowed);
@@ -8352,23 +8556,23 @@ class DiagramCanvas {
8352
8556
  const filteredNodesAtLocation = filterByOnlyDescendants(nodesAtLocationWhichCanHaveNodeAsAChild);
8353
8557
  const droppedOn = filteredNodesAtLocation[filteredNodesAtLocation.length - 1];
8354
8558
  if (droppedOn !== d.parent && (d.type.canBeParentless || droppedOn !== undefined)) {
8355
- const ancestorOfDroppedOn = droppedOn === null || droppedOn === undefined ? undefined : droppedOn.getLastAncestor();
8559
+ const ancestorOfDroppedOn = droppedOn === null || droppedOn === void 0 ? void 0 : droppedOn.getLastAncestor();
8356
8560
  const fromChildGeometry = this.currentAction.from;
8357
- const setParentAction = new SetParentAction(this, d.id, (_a = d.parent) === null || _a === undefined ? undefined : _a.id, droppedOn === null || droppedOn === undefined ? undefined : droppedOn.id, fromChildGeometry, d.getGeometry(), ancestorOfDroppedOn === null || ancestorOfDroppedOn === undefined ? undefined : ancestorOfDroppedOn.id, ancestorOfDroppedOn === null || ancestorOfDroppedOn === undefined ? undefined : ancestorOfDroppedOn.getGeometry(d.id), ancestorOfDroppedOn === null || ancestorOfDroppedOn === undefined ? undefined : ancestorOfDroppedOn.getGeometry(d.id));
8358
- (_b = d.parent) === null || _b === undefined ? undefined : _b.removeChild(d);
8561
+ const setParentAction = new SetParentAction(this, d.id, (_a = d.parent) === null || _a === void 0 ? void 0 : _a.id, droppedOn === null || droppedOn === void 0 ? void 0 : droppedOn.id, fromChildGeometry, d.getGeometry(), ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.id, ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id), ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id));
8562
+ (_b = d.parent) === null || _b === void 0 ? void 0 : _b.removeChild(d);
8359
8563
  if (droppedOn !== undefined) {
8360
8564
  droppedOn.addChild(d);
8361
8565
  }
8362
8566
  setParentAction.toChildGeometry = d.getGeometry(d.id);
8363
- setParentAction.toAncestorGeometry = ancestorOfDroppedOn === null || ancestorOfDroppedOn === undefined ? undefined : ancestorOfDroppedOn.getGeometry(d.id);
8567
+ setParentAction.toAncestorGeometry = ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id);
8364
8568
  this.currentAction = setParentAction;
8365
8569
  } else {
8366
- const ancestorOfNode = d === null || d === undefined ? undefined : d.getLastAncestor();
8367
- this.currentAction.ancestorId = ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.id;
8368
- this.currentAction.fromAncestorGeometry = ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.getGeometry(d.id);
8369
- (_c = d.parent) === null || _c === undefined ? undefined : _c.fitToChild(d);
8570
+ const ancestorOfNode = d === null || d === void 0 ? void 0 : d.getLastAncestor();
8571
+ this.currentAction.ancestorId = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.id;
8572
+ this.currentAction.fromAncestorGeometry = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id);
8573
+ (_c = d.parent) === null || _c === void 0 ? void 0 : _c.fitToChild(d);
8370
8574
  this.currentAction.to = d.getGeometry(d.id);
8371
- this.currentAction.toAncestorGeometry = ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.getGeometry(d.id);
8575
+ this.currentAction.toAncestorGeometry = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id);
8372
8576
  }
8373
8577
  }
8374
8578
  if (this.currentAction !== undefined) {
@@ -8394,14 +8598,14 @@ class DiagramCanvas {
8394
8598
  setCursorStyle(CursorStyle.Crosshair);
8395
8599
  // since the multiple selection rectangle is not affected by zoom,
8396
8600
  // we compensate its coordinates based in the zoom transform to draw it
8397
- (_d = (_c = (_b = (_a = this.multipleSelectionContainer) === null || _a === undefined ? undefined : _a.attr('x', Math.min(this.draggingFrom[0], pointerCoords[0]) * this.zoomTransform.k + this.zoomTransform.x)) === null || _b === undefined ? undefined : _b.attr('y', Math.min(this.draggingFrom[1], pointerCoords[1]) * this.zoomTransform.k + this.zoomTransform.y)) === null || _c === undefined ? undefined : _c.attr('width', Math.abs(this.draggingFrom[0] - pointerCoords[0]) * this.zoomTransform.k)) === null || _d === undefined ? undefined : _d.attr('height', Math.abs(this.draggingFrom[1] - pointerCoords[1]) * this.zoomTransform.k);
8601
+ (_d = (_c = (_b = (_a = this.multipleSelectionContainer) === null || _a === void 0 ? void 0 : _a.attr('x', Math.min(this.draggingFrom[0], pointerCoords[0]) * this.zoomTransform.k + this.zoomTransform.x)) === null || _b === void 0 ? void 0 : _b.attr('y', Math.min(this.draggingFrom[1], pointerCoords[1]) * this.zoomTransform.k + this.zoomTransform.y)) === null || _c === void 0 ? void 0 : _c.attr('width', Math.abs(this.draggingFrom[0] - pointerCoords[0]) * this.zoomTransform.k)) === null || _d === void 0 ? void 0 : _d.attr('height', Math.abs(this.draggingFrom[1] - pointerCoords[1]) * this.zoomTransform.k);
8398
8602
  this.dragging = true;
8399
8603
  }
8400
8604
  }
8401
8605
  finishMultipleSelection(event) {
8402
8606
  var _a;
8403
8607
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8404
- (_a = this.multipleSelectionContainer) === null || _a === undefined ? undefined : _a.remove();
8608
+ (_a = this.multipleSelectionContainer) === null || _a === void 0 ? void 0 : _a.remove();
8405
8609
  this.multipleSelectionContainer = undefined;
8406
8610
  this.userSelection.clear();
8407
8611
  for (const node of this.model.nodes) {
@@ -8495,7 +8699,7 @@ class CollabClient {
8495
8699
  const initialModel = message.initialModel;
8496
8700
  new DagaImporter().import(session.canvas.model, initialModel);
8497
8701
  this.startSyncing(session);
8498
- (_a = session.joinRoomResolve) === null || _a === undefined ? undefined : _a.call(session);
8702
+ (_a = session.joinRoomResolve) === null || _a === void 0 ? void 0 : _a.call(session);
8499
8703
  session.joinRoomResolve = undefined;
8500
8704
  break;
8501
8705
  }
@@ -8518,7 +8722,7 @@ class CollabClient {
8518
8722
  session.locator = message.locator;
8519
8723
  this.pendingSessions.delete(message.refId);
8520
8724
  this.sessions.set(session.locator, session);
8521
- (_b = session.createRoomResolve) === null || _b === undefined ? undefined : _b.call(session, session.locator);
8725
+ (_b = session.createRoomResolve) === null || _b === void 0 ? void 0 : _b.call(session, session.locator);
8522
8726
  session.createRoomResolve = undefined;
8523
8727
  // Deliver queued AddMessages now that we have a locator.
8524
8728
  for (const message of session.addQueue) {
@@ -8773,6 +8977,9 @@ class Grid {
8773
8977
  * @public
8774
8978
  */
8775
8979
  class AdjacencyLayout {
8980
+ constructor(gapSize) {
8981
+ this.gapSize = gapSize;
8982
+ }
8776
8983
  apply(model) {
8777
8984
  var _a;
8778
8985
  if (model.nodes.length === 0) {
@@ -8788,7 +8995,7 @@ class AdjacencyLayout {
8788
8995
  // place nodes according to arrangement
8789
8996
  const maximumWidth = Math.max(...model.nodes.map(n => n.width));
8790
8997
  const maximumHeight = Math.max(...model.nodes.map(n => n.height));
8791
- const gapSize = (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
8998
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
8792
8999
  for (let y = nodeArrangement.minY(); y <= nodeArrangement.maxY(); ++y) {
8793
9000
  for (let x = nodeArrangement.minX(); x <= nodeArrangement.maxX(); ++x) {
8794
9001
  const node = nodeArrangement.get([x, y]);
@@ -8816,6 +9023,9 @@ const arrangeNode = (node, nodeArrangement, coords, nodesToBeArranged) => {
8816
9023
  * @public
8817
9024
  */
8818
9025
  class BreadthAdjacencyLayout {
9026
+ constructor(gapSize) {
9027
+ this.gapSize = gapSize;
9028
+ }
8819
9029
  apply(model) {
8820
9030
  var _a;
8821
9031
  if (model.nodes.length === 0) {
@@ -8853,7 +9063,7 @@ class BreadthAdjacencyLayout {
8853
9063
  // place nodes according to arrangement
8854
9064
  const maximumWidth = Math.max(...model.nodes.map(n => n.width));
8855
9065
  const maximumHeight = Math.max(...model.nodes.map(n => n.height));
8856
- const gapSize = (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9066
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
8857
9067
  for (let y = nodeArrangement.minY(); y <= nodeArrangement.maxY(); ++y) {
8858
9068
  for (let x = nodeArrangement.minX(); x <= nodeArrangement.maxX(); ++x) {
8859
9069
  const node = nodeArrangement.get([x, y]);
@@ -8871,13 +9081,16 @@ class BreadthAdjacencyLayout {
8871
9081
  * @public
8872
9082
  */
8873
9083
  class BreadthLayout {
9084
+ constructor(gapSize) {
9085
+ this.gapSize = gapSize;
9086
+ }
8874
9087
  apply(model) {
8875
9088
  var _a;
8876
9089
  if (model.nodes.length === 0) {
8877
9090
  // nothing to arrange...
8878
9091
  return model;
8879
9092
  }
8880
- const gapSize = (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9093
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
8881
9094
  let nodesToBeArranged = model.nodes.filter(n => !n.parent);
8882
9095
  // Arrange nodes by a breadth first search
8883
9096
  const firstNode = nodesToBeArranged[0];
@@ -8933,6 +9146,9 @@ class BreadthLayout {
8933
9146
  * @public
8934
9147
  */
8935
9148
  class ForceLayout {
9149
+ constructor(gapSize) {
9150
+ this.gapSize = gapSize;
9151
+ }
8936
9152
  apply(model) {
8937
9153
  var _a;
8938
9154
  if (model.nodes.length === 0) {
@@ -8941,7 +9157,7 @@ class ForceLayout {
8941
9157
  }
8942
9158
  // as a starting point, we apply a simple layout
8943
9159
  new BreadthLayout().apply(model);
8944
- const gapSize = (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9160
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
8945
9161
  const coolingFactor = 0.99;
8946
9162
  const minimumTemperature = 1;
8947
9163
  const attractionFactor = 0.1;
@@ -9028,13 +9244,16 @@ class ForceLayout {
9028
9244
  * @public
9029
9245
  */
9030
9246
  class HorizontalLayout {
9247
+ constructor(gapSize) {
9248
+ this.gapSize = gapSize;
9249
+ }
9031
9250
  apply(model) {
9032
9251
  var _a;
9033
9252
  if (model.nodes.length === 0) {
9034
9253
  // nothing to arrange...
9035
9254
  return model;
9036
9255
  }
9037
- const gapSize = (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9256
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
9038
9257
  const nodesToBeArranged = model.nodes.filter(n => !n.parent);
9039
9258
  nodesToBeArranged.sort((a, b) => b.type.priority - a.type.priority);
9040
9259
  let widthAccumulator = 0;
@@ -9051,6 +9270,9 @@ class HorizontalLayout {
9051
9270
  * @public
9052
9271
  */
9053
9272
  class PriorityLayout {
9273
+ constructor(gapSize) {
9274
+ this.gapSize = gapSize;
9275
+ }
9054
9276
  apply(model) {
9055
9277
  var _a;
9056
9278
  if (model.nodes.length === 0) {
@@ -9064,7 +9286,7 @@ class PriorityLayout {
9064
9286
  new BreadthLayout().apply(model);
9065
9287
  return model;
9066
9288
  }
9067
- const gapSize = (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9289
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
9068
9290
  const nodesToBeArranged = model.nodes.filter(n => !n.parent);
9069
9291
  const nodeArrangement = [];
9070
9292
  const nodesWithMaximumPriorityToBeArranged = model.nodes.filter(n => !n.parent).filter(n => n.getPriority() >= maximumPriority);
@@ -9158,6 +9380,9 @@ class PriorityLayout {
9158
9380
  * @public
9159
9381
  */
9160
9382
  class TreeLayout {
9383
+ constructor(gapSize) {
9384
+ this.gapSize = gapSize;
9385
+ }
9161
9386
  apply(model) {
9162
9387
  var _a;
9163
9388
  if (model.nodes.length === 0) {
@@ -9171,7 +9396,7 @@ class TreeLayout {
9171
9396
  new BreadthLayout().apply(model);
9172
9397
  return model;
9173
9398
  }
9174
- const gapSize = (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9399
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
9175
9400
  const nodesToBeArranged = model.nodes.filter(n => !n.parent).sort((n1, n2) => n2.getPriority() - n1.getPriority());
9176
9401
  const branches = [];
9177
9402
  while (nodesToBeArranged.length > 0) {
@@ -9256,13 +9481,16 @@ class Branch {
9256
9481
  * @public
9257
9482
  */
9258
9483
  class VerticalLayout {
9484
+ constructor(gapSize) {
9485
+ this.gapSize = gapSize;
9486
+ }
9259
9487
  apply(model) {
9260
9488
  var _a;
9261
9489
  if (model.nodes.length === 0) {
9262
9490
  // nothing to arrange...
9263
9491
  return model;
9264
9492
  }
9265
- const gapSize = (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9493
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
9266
9494
  const nodesToBeArranged = model.nodes.filter(n => !n.parent);
9267
9495
  nodesToBeArranged.sort((a, b) => b.type.priority - a.type.priority);
9268
9496
  let heightAccumulator = 0;