@metadev/daga 4.1.0 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -158,17 +158,67 @@ const translateCoordinate = (oldCoordinate, oldCoordinates, newCoordinates) => {
158
158
  return (oldCoordinate - oldCoordinates[0]) / (oldCoordinates[1] - oldCoordinates[0]) * (newCoordinates[1] - newCoordinates[0]) + newCoordinates[0];
159
159
  };
160
160
  /**
161
- * Moves the coordinates of the given point according to the given changes in coordinates.
161
+ * Moves the coordinates of the given point according to the given changes in coordinates and anchor points.
162
162
  * @public
163
163
  * @param oldPoint A point.
164
164
  * @param oldCoordsX A range of coordinates along the x axis.
165
165
  * @param oldCoordsY A range of coordinates along the y axis.
166
166
  * @param newCoordsX A range of coordinates along the x axis.
167
167
  * @param newCoordsY A range of coordinates along the y axis.
168
+ * @param anchorPointX The horizontal anchor point behavior.
169
+ * @param anchorPointY The vertical anchor point behavior.
168
170
  * @returns A new point.
169
171
  */
170
- const translatePoint = (oldPoint, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY) => {
171
- return [translateCoordinate(oldPoint[0], oldCoordsX, newCoordsX), translateCoordinate(oldPoint[1], oldCoordsY, newCoordsY)];
172
+ const translatePointWithAnchors = (oldPoint, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY, anchorPointX, anchorPointY) => {
173
+ const newX = (() => {
174
+ switch (anchorPointX) {
175
+ case 'start':
176
+ // Always maintain the same distance from the left edge
177
+ return newCoordsX[0] + (oldPoint[0] - oldCoordsX[0]);
178
+ case 'end':
179
+ // Always maintain the same distance from the right edge
180
+ return newCoordsX[1] - (oldCoordsX[1] - oldPoint[0]);
181
+ case 'middle':
182
+ {
183
+ // Always maintain the same relative position from the center
184
+ const oldCenterX = (oldCoordsX[0] + oldCoordsX[1]) / 2;
185
+ const newCenterX = (newCoordsX[0] + newCoordsX[1]) / 2;
186
+ const oldWidth = oldCoordsX[1] - oldCoordsX[0];
187
+ const newWidth = newCoordsX[1] - newCoordsX[0];
188
+ const relativePosition = (oldPoint[0] - oldCenterX) / oldWidth;
189
+ return newCenterX + relativePosition * newWidth;
190
+ }
191
+ case 'floating':
192
+ default:
193
+ // Scale proportionally (original behavior)
194
+ return translateCoordinate(oldPoint[0], oldCoordsX, newCoordsX);
195
+ }
196
+ })();
197
+ const newY = (() => {
198
+ switch (anchorPointY) {
199
+ case 'start':
200
+ // Always maintain the same distance from the top edge
201
+ return newCoordsY[0] + (oldPoint[1] - oldCoordsY[0]);
202
+ case 'end':
203
+ // Always maintain the same distance from the bottom edge
204
+ return newCoordsY[1] - (oldCoordsY[1] - oldPoint[1]);
205
+ case 'middle':
206
+ {
207
+ // Always maintain the same relative position from the center
208
+ const oldCenterY = (oldCoordsY[0] + oldCoordsY[1]) / 2;
209
+ const newCenterY = (newCoordsY[0] + newCoordsY[1]) / 2;
210
+ const oldHeight = oldCoordsY[1] - oldCoordsY[0];
211
+ const newHeight = newCoordsY[1] - newCoordsY[0];
212
+ const relativePosition = (oldPoint[1] - oldCenterY) / oldHeight;
213
+ return newCenterY + relativePosition * newHeight;
214
+ }
215
+ case 'floating':
216
+ default:
217
+ // Scale proportionally (original behavior)
218
+ return translateCoordinate(oldPoint[1], oldCoordsY, newCoordsY);
219
+ }
220
+ })();
221
+ return [newX, newY];
172
222
  };
173
223
  /**
174
224
  * Calculates the euclidean distance between two points.
@@ -265,6 +315,10 @@ exports.ZoomEvents = void 0;
265
315
  ZoomEvents["End"] = "end";
266
316
  })(exports.ZoomEvents || (exports.ZoomEvents = {}));
267
317
 
318
+ const escapeSelector = selector => {
319
+ return selector.replace(/([!"#$%&'()*+,\-./:;<=>?@[\\\]^`{|}])/g, '\\$1');
320
+ };
321
+
268
322
  /**
269
323
  * An enumeration of the possible shapes of a line.
270
324
  * @public
@@ -825,7 +879,7 @@ const numberOfColumns = s => {
825
879
  };
826
880
  const numberOfRows = s => {
827
881
  var _a;
828
- return ((_a = s.match(/\n/g)) === null || _a === undefined ? undefined : _a.length) || 0;
882
+ return ((_a = s.match(/\n/g)) === null || _a === void 0 ? void 0 : _a.length) || 0;
829
883
  };
830
884
 
831
885
  /******************************************************************************
@@ -1022,10 +1076,6 @@ class DiagramEntitySet {
1022
1076
  }
1023
1077
  }
1024
1078
 
1025
- const escapeSelector = selector => {
1026
- return selector.replace(/([!"#$%&'()*+,\-./:;<=>?@[\\\]^`{|}])/g, '\\$1');
1027
- };
1028
-
1029
1079
  /**
1030
1080
  * Default priority value for diagram elements.
1031
1081
  * @private
@@ -1051,14 +1101,14 @@ class DiagramElement {
1051
1101
  */
1052
1102
  get highlighted() {
1053
1103
  var _a, _b;
1054
- return ((_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.userHighlight) === null || _b === undefined ? undefined : _b.contains(this.id)) || false;
1104
+ 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;
1055
1105
  }
1056
1106
  /**
1057
1107
  * Whether this diagram element is currently in the user selection.
1058
1108
  */
1059
1109
  get selected() {
1060
1110
  var _a, _b;
1061
- return ((_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.userSelection) === null || _b === undefined ? undefined : _b.contains(this.id)) || false;
1111
+ 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;
1062
1112
  }
1063
1113
  constructor(model, id) {
1064
1114
  /**
@@ -1087,7 +1137,7 @@ class DiagramElement {
1087
1137
  */
1088
1138
  select() {
1089
1139
  var _a, _b;
1090
- return (_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.selectCanvasView()) === null || _b === undefined ? undefined : _b.select(`[id='${escapeSelector(this.id)}']`);
1140
+ 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)}']`);
1091
1141
  }
1092
1142
  }
1093
1143
  class DiagramElementSet extends DiagramEntitySet {
@@ -1485,7 +1535,7 @@ class ValueSet {
1485
1535
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1486
1536
  getValue(key) {
1487
1537
  var _a;
1488
- const rootAttribute = (_a = this.propertySet.getProperty(key)) === null || _a === undefined ? undefined : _a.rootAttribute;
1538
+ const rootAttribute = (_a = this.propertySet.getProperty(key)) === null || _a === void 0 ? void 0 : _a.rootAttribute;
1489
1539
  if (rootAttribute !== undefined && rootAttribute !== null) {
1490
1540
  this.values[key] = this.getRootElementValue(rootAttribute);
1491
1541
  }
@@ -1570,7 +1620,7 @@ class ValueSet {
1570
1620
  if (property && property.type === exports.Type.Object) {
1571
1621
  return this.getSubValueSet(key).hasAnySetValue();
1572
1622
  }
1573
- return !empty(value) && !equals(value, property === null || property === undefined ? undefined : property.defaultValue);
1623
+ return !empty(value) && !equals(value, property === null || property === void 0 ? void 0 : property.defaultValue);
1574
1624
  }
1575
1625
  /**
1576
1626
  * Checks if any of the values in the set are not empty or the default value.
@@ -1837,20 +1887,24 @@ class DiagramConnection extends DiagramElement {
1837
1887
  }
1838
1888
  set type(type) {
1839
1889
  var _a, _b;
1840
- (_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.userSelection) === null || _b === undefined ? undefined : _b.openInPropertyEditor(undefined);
1841
- this._type = type;
1842
- if (this.valueSet) {
1843
- this.valueSet = new ValueSet(type.propertySet, this);
1890
+ if (type !== this._type) {
1891
+ this._type = type;
1892
+ if (this.valueSet) {
1893
+ this.valueSet = new ValueSet(type.propertySet, this);
1894
+ }
1895
+ (_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userSelection) === null || _b === void 0 ? void 0 : _b.openInPropertyEditor(this, false);
1896
+ this.updateInView();
1844
1897
  }
1845
- this.updateInView();
1846
1898
  }
1847
1899
  get typeString() {
1848
1900
  return this.type.id;
1849
1901
  }
1850
1902
  set typeString(typeString) {
1851
- const type = this.model.connections.types.get(typeString);
1852
- if (type) {
1853
- this.type = type;
1903
+ if (typeString !== this.type.id) {
1904
+ const type = this.model.connections.types.get(typeString);
1905
+ if (type) {
1906
+ this.type = type;
1907
+ }
1854
1908
  }
1855
1909
  }
1856
1910
  /**
@@ -2026,11 +2080,11 @@ class DiagramConnection extends DiagramElement {
2026
2080
  }
2027
2081
  updateInView() {
2028
2082
  var _a;
2029
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateConnectionsInView(this.id);
2083
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateConnectionsInView(this.id);
2030
2084
  }
2031
2085
  raise() {
2032
2086
  var _a;
2033
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
2087
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
2034
2088
  }
2035
2089
  /**
2036
2090
  * Set the start of this connection to the given port or reset this connection's starting port if `undefined`.
@@ -2046,12 +2100,12 @@ class DiagramConnection extends DiagramElement {
2046
2100
  this.start = start;
2047
2101
  if (start !== undefined) {
2048
2102
  start.outgoingConnections.push(this);
2049
- this.startDirection = start === null || start === undefined ? undefined : start.direction;
2050
- this.startCoords = (start === null || start === undefined ? undefined : start.connectionPoint) || [0, 0];
2103
+ this.startDirection = start === null || start === void 0 ? void 0 : start.direction;
2104
+ this.startCoords = (start === null || start === void 0 ? void 0 : start.connectionPoint) || [0, 0];
2051
2105
  }
2052
2106
  } else {
2053
- this.startDirection = start === null || start === undefined ? undefined : start.direction;
2054
- this.startCoords = (start === null || start === undefined ? undefined : start.connectionPoint) || [0, 0];
2107
+ this.startDirection = start === null || start === void 0 ? void 0 : start.direction;
2108
+ this.startCoords = (start === null || start === void 0 ? void 0 : start.connectionPoint) || [0, 0];
2055
2109
  }
2056
2110
  this.updateInView();
2057
2111
  }
@@ -2069,12 +2123,12 @@ class DiagramConnection extends DiagramElement {
2069
2123
  this.end = end;
2070
2124
  if (end !== undefined) {
2071
2125
  end.incomingConnections.push(this);
2072
- this.endDirection = end === null || end === undefined ? undefined : end.direction;
2073
- this.endCoords = (end === null || end === undefined ? undefined : end.connectionPoint) || [0, 0];
2126
+ this.endDirection = end === null || end === void 0 ? void 0 : end.direction;
2127
+ this.endCoords = (end === null || end === void 0 ? void 0 : end.connectionPoint) || [0, 0];
2074
2128
  }
2075
2129
  } else {
2076
- this.endDirection = end === null || end === undefined ? undefined : end.direction;
2077
- this.endCoords = (end === null || end === undefined ? undefined : end.connectionPoint) || [0, 0];
2130
+ this.endDirection = end === null || end === void 0 ? void 0 : end.direction;
2131
+ this.endCoords = (end === null || end === void 0 ? void 0 : end.connectionPoint) || [0, 0];
2078
2132
  }
2079
2133
  this.updateInView();
2080
2134
  }
@@ -2085,7 +2139,7 @@ class DiagramConnection extends DiagramElement {
2085
2139
  */
2086
2140
  tighten() {
2087
2141
  var _a, _b;
2088
- if (((_a = this.start) === null || _a === undefined ? undefined : _a.rootElement) && this.end) {
2142
+ if (((_a = this.start) === null || _a === void 0 ? void 0 : _a.rootElement) && this.end) {
2089
2143
  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]);
2090
2144
  checkAlternativeStartPorts: for (const alternativeStartPort of alternativeStartPortsSortedByDistanceAscending) {
2091
2145
  if (alternativeStartPort === this.end) {
@@ -2119,7 +2173,7 @@ class DiagramConnection extends DiagramElement {
2119
2173
  }
2120
2174
  }
2121
2175
  }
2122
- if (((_b = this.end) === null || _b === undefined ? undefined : _b.rootElement) && this.start) {
2176
+ if (((_b = this.end) === null || _b === void 0 ? void 0 : _b.rootElement) && this.start) {
2123
2177
  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]);
2124
2178
  checkAlternativeEndPorts: for (const alternativeEndPort of alternativeEndPortsSortedByDistanceAscending) {
2125
2179
  if (alternativeEndPort === this.start) {
@@ -2215,8 +2269,8 @@ class DiagramConnectionSet extends DiagramElementSet {
2215
2269
  const connection = this.get(id, true);
2216
2270
  if (connection) {
2217
2271
  // remove from ports
2218
- removeIfExists(((_a = connection.start) === null || _a === undefined ? undefined : _a.outgoingConnections) || [], connection);
2219
- removeIfExists(((_b = connection.end) === null || _b === undefined ? undefined : _b.incomingConnections) || [], connection);
2272
+ removeIfExists(((_a = connection.start) === null || _a === void 0 ? void 0 : _a.outgoingConnections) || [], connection);
2273
+ removeIfExists(((_b = connection.end) === null || _b === void 0 ? void 0 : _b.incomingConnections) || [], connection);
2220
2274
  // remove from set of connections
2221
2275
  super.remove(id);
2222
2276
  // remove from canvas
@@ -2240,7 +2294,9 @@ const DIAGRAM_FIELD_DEFAULTS = {
2240
2294
  selectedColor: '#000000',
2241
2295
  horizontalAlign: exports.HorizontalAlign.Center,
2242
2296
  verticalAlign: exports.VerticalAlign.Center,
2243
- fit: false
2297
+ orientation: exports.Side.Top,
2298
+ fit: false,
2299
+ shrink: true
2244
2300
  };
2245
2301
  /**
2246
2302
  * A field which displays text and is part of a diagram element.
@@ -2259,17 +2315,17 @@ class DiagramField extends DiagramElement {
2259
2315
  }
2260
2316
  set text(value) {
2261
2317
  var _a;
2262
- if (value === null || value === undefined || (value === null || value === undefined ? undefined : value.trim()) === '') {
2318
+ if (value === null || value === undefined || (value === null || value === void 0 ? void 0 : value.trim()) === '') {
2263
2319
  value = this.defaultText;
2264
2320
  }
2265
2321
  this._text = value;
2266
2322
  this.updateInView();
2267
2323
  if (this.fit) {
2268
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.fitFieldRootInView(this.id);
2324
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.fitFieldRootInView(this.id, this.shrink);
2269
2325
  }
2270
2326
  }
2271
- constructor(model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, text, editable, fit) {
2272
- const id = `${rootElement === null || rootElement === undefined ? undefined : rootElement.id}_field`;
2327
+ constructor(model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, orientation, text, editable, fit, shrink) {
2328
+ const id = `${rootElement === null || rootElement === void 0 ? void 0 : rootElement.id}_field`;
2273
2329
  if (model.fields.get(id) !== undefined) {
2274
2330
  throw new Error('DiagramField for rootElement already exists');
2275
2331
  }
@@ -2289,21 +2345,42 @@ class DiagramField extends DiagramElement {
2289
2345
  this.selectedColor = selectedColor;
2290
2346
  this.horizontalAlign = horizontalAlign;
2291
2347
  this.verticalAlign = verticalAlign;
2348
+ if (!isNaN(Number(orientation))) {
2349
+ this.orientation = Number(orientation);
2350
+ } else {
2351
+ switch (orientation) {
2352
+ case exports.Side.Top:
2353
+ this.orientation = 0;
2354
+ break;
2355
+ case exports.Side.Right:
2356
+ this.orientation = 90;
2357
+ break;
2358
+ case exports.Side.Bottom:
2359
+ this.orientation = 180;
2360
+ break;
2361
+ case exports.Side.Left:
2362
+ this.orientation = 270;
2363
+ break;
2364
+ default:
2365
+ this.orientation = 0;
2366
+ }
2367
+ }
2292
2368
  this.defaultText = text;
2293
2369
  this._text = text;
2294
2370
  this.editable = editable;
2295
2371
  this.fit = fit;
2372
+ this.shrink = shrink;
2296
2373
  }
2297
2374
  get removed() {
2298
2375
  return this.selfRemoved || this.rootElement !== undefined && this.rootElement.removed;
2299
2376
  }
2300
2377
  updateInView() {
2301
2378
  var _a;
2302
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateFieldsInView(this.id);
2379
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateFieldsInView(this.id);
2303
2380
  }
2304
2381
  raise() {
2305
2382
  var _a;
2306
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
2383
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
2307
2384
  }
2308
2385
  /**
2309
2386
  * Change the coordinates of this field to the given coordinates.
@@ -2316,7 +2393,7 @@ class DiagramField extends DiagramElement {
2316
2393
  }
2317
2394
  getPriority() {
2318
2395
  var _a;
2319
- return ((_a = this.rootElement) === null || _a === undefined ? undefined : _a.getPriority()) || DEFAULT_PRIORITY;
2396
+ return ((_a = this.rootElement) === null || _a === void 0 ? void 0 : _a.getPriority()) || DEFAULT_PRIORITY;
2320
2397
  }
2321
2398
  }
2322
2399
  class DiagramFieldSet extends DiagramElementSet {
@@ -2332,8 +2409,8 @@ class DiagramFieldSet extends DiagramElementSet {
2332
2409
  * 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.
2333
2410
  * @private
2334
2411
  */
2335
- new(rootElement, coords, fontSize, fontFamily, color, selectedColor, width, height, horizontalAlign, verticalAlign, text, editable, fit) {
2336
- const field = new DiagramField(this.model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, text, editable, fit);
2412
+ new(rootElement, coords, fontSize, fontFamily, color, selectedColor, width, height, horizontalAlign, verticalAlign, orientation, text, editable, fit, shrink) {
2413
+ const field = new DiagramField(this.model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, orientation, text, editable, fit, shrink);
2337
2414
  super.add(field);
2338
2415
  field.updateInView();
2339
2416
  // add this field to its root element
@@ -2347,7 +2424,7 @@ class DiagramFieldSet extends DiagramElementSet {
2347
2424
  const field = this.get(id, true);
2348
2425
  if (field) {
2349
2426
  // remove from root element
2350
- if (((_a = field.rootElement) === null || _a === undefined ? undefined : _a.label) !== undefined) {
2427
+ if (((_a = field.rootElement) === null || _a === void 0 ? void 0 : _a.label) !== undefined) {
2351
2428
  if (field.rootElement.label === field) {
2352
2429
  field.rootElement.label = undefined;
2353
2430
  }
@@ -2360,7 +2437,7 @@ class DiagramFieldSet extends DiagramElementSet {
2360
2437
  }
2361
2438
  }
2362
2439
  const getBottomMargin = config => {
2363
- if ((config === null || config === undefined ? undefined : config.margin) === null || (config === null || config === undefined ? undefined : config.margin) === undefined) {
2440
+ if ((config === null || config === void 0 ? void 0 : config.margin) === null || (config === null || config === void 0 ? void 0 : config.margin) === undefined) {
2364
2441
  return DIAGRAM_FIELD_DEFAULTS.margin;
2365
2442
  } else if (typeof config.margin === 'number') {
2366
2443
  return config.margin;
@@ -2379,7 +2456,7 @@ const getBottomMargin = config => {
2379
2456
  }
2380
2457
  };
2381
2458
  const getLeftMargin = config => {
2382
- if ((config === null || config === undefined ? undefined : config.margin) === null || (config === null || config === undefined ? undefined : config.margin) === undefined) {
2459
+ if ((config === null || config === void 0 ? void 0 : config.margin) === null || (config === null || config === void 0 ? void 0 : config.margin) === undefined) {
2383
2460
  return DIAGRAM_FIELD_DEFAULTS.margin;
2384
2461
  } else if (typeof config.margin === 'number') {
2385
2462
  return config.margin;
@@ -2398,7 +2475,7 @@ const getLeftMargin = config => {
2398
2475
  }
2399
2476
  };
2400
2477
  const getRightMargin = config => {
2401
- if ((config === null || config === undefined ? undefined : config.margin) === null || (config === null || config === undefined ? undefined : config.margin) === undefined) {
2478
+ if ((config === null || config === void 0 ? void 0 : config.margin) === null || (config === null || config === void 0 ? void 0 : config.margin) === undefined) {
2402
2479
  return DIAGRAM_FIELD_DEFAULTS.margin;
2403
2480
  } else if (typeof config.margin === 'number') {
2404
2481
  return config.margin;
@@ -2417,7 +2494,7 @@ const getRightMargin = config => {
2417
2494
  }
2418
2495
  };
2419
2496
  const getTopMargin = config => {
2420
- if ((config === null || config === undefined ? undefined : config.margin) === null || (config === null || config === undefined ? undefined : config.margin) === undefined) {
2497
+ if ((config === null || config === void 0 ? void 0 : config.margin) === null || (config === null || config === void 0 ? void 0 : config.margin) === undefined) {
2421
2498
  return DIAGRAM_FIELD_DEFAULTS.margin;
2422
2499
  } else if (typeof config.margin === 'number') {
2423
2500
  return config.margin;
@@ -2436,7 +2513,7 @@ const getTopMargin = config => {
2436
2513
  }
2437
2514
  };
2438
2515
  const getBottomPadding$1 = config => {
2439
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
2516
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
2440
2517
  return DIAGRAM_FIELD_DEFAULTS.padding;
2441
2518
  } else if (typeof config.padding === 'number') {
2442
2519
  return config.padding;
@@ -2455,7 +2532,7 @@ const getBottomPadding$1 = config => {
2455
2532
  }
2456
2533
  };
2457
2534
  const getLeftPadding$1 = config => {
2458
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
2535
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
2459
2536
  return DIAGRAM_FIELD_DEFAULTS.padding;
2460
2537
  } else if (typeof config.padding === 'number') {
2461
2538
  return config.padding;
@@ -2474,7 +2551,7 @@ const getLeftPadding$1 = config => {
2474
2551
  }
2475
2552
  };
2476
2553
  const getRightPadding$1 = config => {
2477
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
2554
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
2478
2555
  return DIAGRAM_FIELD_DEFAULTS.padding;
2479
2556
  } else if (typeof config.padding === 'number') {
2480
2557
  return config.padding;
@@ -2493,7 +2570,7 @@ const getRightPadding$1 = config => {
2493
2570
  }
2494
2571
  };
2495
2572
  const getTopPadding$1 = config => {
2496
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
2573
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
2497
2574
  return DIAGRAM_FIELD_DEFAULTS.padding;
2498
2575
  } else if (typeof config.padding === 'number') {
2499
2576
  return config.padding;
@@ -2564,6 +2641,8 @@ class DiagramSectionType {
2564
2641
  this.label = options.label || null;
2565
2642
  this.ports = options.ports || [];
2566
2643
  this.priority = options.priority || DEFAULT_PRIORITY;
2644
+ this.resizableX = options.resizableX;
2645
+ this.resizableY = options.resizableY;
2567
2646
  const looks = extractLooksFromConfig(options.look || DIAGRAM_NODE_LOOK_DEFAULTS);
2568
2647
  this.defaultLook = looks.defaultLook;
2569
2648
  this.selectedLook = looks.selectedLook;
@@ -2585,7 +2664,7 @@ class DiagramSection extends DiagramElement {
2585
2664
  */
2586
2665
  get name() {
2587
2666
  var _a;
2588
- return ((_a = this.label) === null || _a === undefined ? undefined : _a.text) || '';
2667
+ return ((_a = this.label) === null || _a === void 0 ? void 0 : _a.text) || '';
2589
2668
  }
2590
2669
  set name(name) {
2591
2670
  if (this.label) {
@@ -2600,15 +2679,15 @@ class DiagramSection extends DiagramElement {
2600
2679
  var _a, _b, _c, _d, _e, _f, _g, _h;
2601
2680
  if (this.selected) {
2602
2681
  if (this.highlighted) {
2603
- return this._selectedAndHighlightedLook !== undefined ? this._selectedAndHighlightedLook : ((_a = this.type) === null || _a === undefined ? undefined : _a.selectedAndHighlightedLook) || ((_b = this.node) === null || _b === undefined ? undefined : _b.look);
2682
+ 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);
2604
2683
  } else {
2605
- return this._selectedLook !== undefined ? this._selectedLook : ((_c = this.type) === null || _c === undefined ? undefined : _c.selectedLook) || ((_d = this.node) === null || _d === undefined ? undefined : _d.look);
2684
+ 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);
2606
2685
  }
2607
2686
  } else {
2608
2687
  if (this.highlighted) {
2609
- return this._highlightedLook !== undefined ? this._highlightedLook : ((_e = this.type) === null || _e === undefined ? undefined : _e.highlightedLook) || ((_f = this.node) === null || _f === undefined ? undefined : _f.look);
2688
+ 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);
2610
2689
  } else {
2611
- return this._defaultLook !== undefined ? this._defaultLook : ((_g = this.type) === null || _g === undefined ? undefined : _g.defaultLook) || ((_h = this.node) === null || _h === undefined ? undefined : _h.look);
2690
+ 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);
2612
2691
  }
2613
2692
  }
2614
2693
  }
@@ -2661,11 +2740,11 @@ class DiagramSection extends DiagramElement {
2661
2740
  }
2662
2741
  updateInView() {
2663
2742
  var _a;
2664
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateSectionsInView(this.id);
2743
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateSectionsInView(this.id);
2665
2744
  }
2666
2745
  raise() {
2667
2746
  var _a;
2668
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
2747
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
2669
2748
  if (this.label) {
2670
2749
  this.label.raise();
2671
2750
  }
@@ -2678,19 +2757,47 @@ class DiagramSection extends DiagramElement {
2678
2757
  }
2679
2758
  get type() {
2680
2759
  var _a, _b, _c, _d, _e;
2681
- 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];
2760
+ 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];
2682
2761
  }
2683
2762
  getMinWidth() {
2684
2763
  var _a, _b, _c, _d;
2685
- 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;
2764
+ 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;
2686
2765
  }
2687
2766
  getMinHeight() {
2688
2767
  var _a, _b, _c, _d;
2689
- 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;
2768
+ 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;
2690
2769
  }
2691
2770
  getPriority() {
2692
2771
  var _a, _b, _c, _d, _e, _f;
2693
- 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;
2772
+ 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;
2773
+ }
2774
+ /**
2775
+ * Returns whether this section can be resized horizontally.
2776
+ * If the section has a specific resizableX setting, it uses that.
2777
+ * Otherwise, it inherits from the parent node's resizableX setting.
2778
+ * @public
2779
+ */
2780
+ getResizableX() {
2781
+ var _a, _b;
2782
+ const sectionType = this.type;
2783
+ if ((sectionType === null || sectionType === void 0 ? void 0 : sectionType.resizableX) !== undefined) {
2784
+ return sectionType.resizableX;
2785
+ }
2786
+ return ((_b = (_a = this.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) || false;
2787
+ }
2788
+ /**
2789
+ * Returns whether this section can be resized vertically.
2790
+ * If the section has a specific resizableY setting, it uses that.
2791
+ * Otherwise, it inherits from the parent node's resizableY setting.
2792
+ * @public
2793
+ */
2794
+ getResizableY() {
2795
+ var _a, _b;
2796
+ const sectionType = this.type;
2797
+ if ((sectionType === null || sectionType === void 0 ? void 0 : sectionType.resizableY) !== undefined) {
2798
+ return sectionType.resizableY;
2799
+ }
2800
+ return ((_b = (_a = this.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) || false;
2694
2801
  }
2695
2802
  /**
2696
2803
  * Get the port of this section which is closest to the given coordinates.
@@ -2850,19 +2957,19 @@ class DiagramSection extends DiagramElement {
2850
2957
  const newCoordsY = [this.coords[1], this.coords[1] + this.height];
2851
2958
  // Move ports to match the new coords.
2852
2959
  for (const port of this.ports) {
2853
- port.move(translatePoint(port.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY));
2960
+ port.move(translatePointWithAnchors(port.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY, port.anchorPointX, port.anchorPointY));
2854
2961
  }
2855
2962
  // Set label's dimensions as a function of ours.
2856
2963
  const type = this.type;
2857
2964
  if (this.label) {
2858
- 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)];
2859
- this.label.width = this.width - getLeftMargin(type === null || type === undefined ? undefined : type.label) - getRightMargin(type === null || type === undefined ? undefined : type.label);
2860
- this.label.height = this.height - getTopMargin(type === null || type === undefined ? undefined : type.label) - getBottomMargin(type === null || type === undefined ? undefined : type.label);
2965
+ 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)];
2966
+ 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);
2967
+ 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);
2861
2968
  this.label.updateInView();
2862
2969
  }
2863
2970
  // Move decorators to match the new coords.
2864
2971
  for (const decorator of this.decorators) {
2865
- decorator.move(translatePoint(decorator.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY));
2972
+ decorator.move(translatePointWithAnchors(decorator.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY, decorator.anchorPointX, decorator.anchorPointY));
2866
2973
  }
2867
2974
  // Update canvas.
2868
2975
  this.getConnections().forEach(c => c.tighten());
@@ -2891,13 +2998,13 @@ class DiagramSectionSet extends DiagramElementSet {
2891
2998
  node.sections.push(section);
2892
2999
  node.updateInView();
2893
3000
  // add section ports
2894
- 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;
3001
+ 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;
2895
3002
  if (sectionPorts && sectionPorts.length > 0) {
2896
3003
  for (let i = 0; i < sectionPorts.length; ++i) {
2897
3004
  const portConfig = sectionPorts[i];
2898
- 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}`);
2899
- if ((_e = port.type) === null || _e === undefined ? undefined : _e.label) {
2900
- const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === undefined ? undefined : _f.label);
3005
+ 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}`, portConfig.anchorPointX || 'floating', portConfig.anchorPointY || 'floating');
3006
+ if ((_e = port.type) === null || _e === void 0 ? void 0 : _e.label) {
3007
+ const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === void 0 ? void 0 : _f.label);
2901
3008
  const labelWidth = 6 * labelConfiguration.fontSize + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
2902
3009
  const labelHeight = labelConfiguration.fontSize + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
2903
3010
  let labelCoords;
@@ -2913,15 +3020,15 @@ class DiagramSectionSet extends DiagramElementSet {
2913
3020
  default:
2914
3021
  labelCoords = port.coords;
2915
3022
  }
2916
- this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
3023
+ 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, labelConfiguration.shrink);
2917
3024
  }
2918
3025
  }
2919
3026
  }
2920
3027
  // add section label
2921
- 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;
3028
+ 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;
2922
3029
  if (sectionLabel) {
2923
3030
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), sectionLabel);
2924
- 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);
3031
+ 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, labelConfiguration.shrink);
2925
3032
  }
2926
3033
  return section;
2927
3034
  }
@@ -3025,7 +3132,7 @@ class DiagramNodeType {
3025
3132
  this.canBeParentless = values.canBeParentless;
3026
3133
  this.childrenTypes = values.childrenTypes;
3027
3134
  this.priority = values.priority;
3028
- this.propertySet = new PropertySet((options === null || options === undefined ? undefined : options.properties) || []);
3135
+ this.propertySet = new PropertySet((options === null || options === void 0 ? void 0 : options.properties) || []);
3029
3136
  }
3030
3137
  }
3031
3138
  /**
@@ -3041,20 +3148,24 @@ class DiagramNode extends DiagramElement {
3041
3148
  }
3042
3149
  set type(type) {
3043
3150
  var _a, _b;
3044
- (_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.userSelection) === null || _b === undefined ? undefined : _b.openInPropertyEditor(undefined);
3045
- this._type = type;
3046
- if (this.valueSet) {
3047
- this.valueSet = new ValueSet(type.propertySet, this);
3151
+ if (type !== this._type) {
3152
+ this._type = type;
3153
+ if (this.valueSet) {
3154
+ this.valueSet = new ValueSet(type.propertySet, this);
3155
+ }
3156
+ (_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userSelection) === null || _b === void 0 ? void 0 : _b.openInPropertyEditor(this, false);
3157
+ this.updateInView();
3048
3158
  }
3049
- this.updateInView();
3050
3159
  }
3051
3160
  get typeString() {
3052
3161
  return this.type.id;
3053
3162
  }
3054
3163
  set typeString(typeString) {
3055
- const type = this.model.nodes.types.get(typeString);
3056
- if (type) {
3057
- this.type = type;
3164
+ if (typeString !== this.type.id) {
3165
+ const type = this.model.nodes.types.get(typeString);
3166
+ if (type) {
3167
+ this.type = type;
3168
+ }
3058
3169
  }
3059
3170
  }
3060
3171
  /**
@@ -3063,7 +3174,7 @@ class DiagramNode extends DiagramElement {
3063
3174
  */
3064
3175
  get name() {
3065
3176
  var _a;
3066
- return ((_a = this.label) === null || _a === undefined ? undefined : _a.text) || '';
3177
+ return ((_a = this.label) === null || _a === void 0 ? void 0 : _a.text) || '';
3067
3178
  }
3068
3179
  set name(name) {
3069
3180
  if (this.label) {
@@ -3153,11 +3264,11 @@ class DiagramNode extends DiagramElement {
3153
3264
  }
3154
3265
  updateInView() {
3155
3266
  var _a;
3156
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateNodesInView(this.id);
3267
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateNodesInView(this.id);
3157
3268
  }
3158
3269
  raise() {
3159
3270
  var _a;
3160
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
3271
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
3161
3272
  for (const section of this.sections) {
3162
3273
  section.raise();
3163
3274
  }
@@ -3264,7 +3375,7 @@ class DiagramNode extends DiagramElement {
3264
3375
  if (!includeRemoved && incomingConnection.removed) {
3265
3376
  continue;
3266
3377
  }
3267
- const otherNode = (_a = incomingConnection.start) === null || _a === undefined ? undefined : _a.getNode();
3378
+ const otherNode = (_a = incomingConnection.start) === null || _a === void 0 ? void 0 : _a.getNode();
3268
3379
  if (otherNode) {
3269
3380
  if (!includeRemoved && otherNode.removed) {
3270
3381
  continue;
@@ -3276,7 +3387,7 @@ class DiagramNode extends DiagramElement {
3276
3387
  if (!includeRemoved && outgoingConnection.removed) {
3277
3388
  continue;
3278
3389
  }
3279
- const otherNode = (_b = outgoingConnection.end) === null || _b === undefined ? undefined : _b.getNode();
3390
+ const otherNode = (_b = outgoingConnection.end) === null || _b === void 0 ? void 0 : _b.getNode();
3280
3391
  if (otherNode) {
3281
3392
  if (!includeRemoved && otherNode.removed) {
3282
3393
  continue;
@@ -3295,7 +3406,7 @@ class DiagramNode extends DiagramElement {
3295
3406
  // eslint-disable-next-line @typescript-eslint/no-this-alias
3296
3407
  let node = this;
3297
3408
  while (node.parent !== undefined) {
3298
- node = node === null || node === undefined ? undefined : node.parent;
3409
+ node = node === null || node === void 0 ? void 0 : node.parent;
3299
3410
  }
3300
3411
  return node;
3301
3412
  }
@@ -3354,21 +3465,42 @@ class DiagramNode extends DiagramElement {
3354
3465
  child.parent = undefined;
3355
3466
  }
3356
3467
  fitToChild(child) {
3468
+ // if the node includes sections, we stretch the sections as well when fitting to a child node
3469
+ // we assume it is most natural to stretch the last row and column of section
3470
+ // TODO: consider being able to configure which row or column gets stretched first
3471
+ const maxSectionIndexX = Math.max(...this.sections.map(s => s.indexXInNode));
3472
+ const maxSectionIndexY = Math.max(...this.sections.map(s => s.indexYInNode));
3357
3473
  const excessLeft = this.coords[0] - child.coords[0] + this.type.leftPadding;
3358
3474
  if (excessLeft >= 0) {
3359
- this.stretch(exports.Side.Left, excessLeft);
3475
+ if (this.sections.length > 0) {
3476
+ this.stretchSections(exports.Side.Left, excessLeft, maxSectionIndexX, maxSectionIndexY);
3477
+ } else {
3478
+ this.stretch(exports.Side.Left, excessLeft);
3479
+ }
3360
3480
  }
3361
3481
  const excessTop = this.coords[1] - child.coords[1] + this.type.topPadding;
3362
3482
  if (excessTop >= 0) {
3363
- this.stretch(exports.Side.Top, excessTop);
3483
+ if (this.sections.length > 0) {
3484
+ this.stretchSections(exports.Side.Top, excessTop, maxSectionIndexX, maxSectionIndexY);
3485
+ } else {
3486
+ this.stretch(exports.Side.Top, excessTop);
3487
+ }
3364
3488
  }
3365
3489
  const excessRight = child.coords[0] + child.width - (this.coords[0] + this.width) + this.type.rightPadding;
3366
3490
  if (excessRight >= 0) {
3367
- this.stretch(exports.Side.Right, excessRight);
3491
+ if (this.sections.length > 0) {
3492
+ this.stretchSections(exports.Side.Right, excessRight, maxSectionIndexX, maxSectionIndexY);
3493
+ } else {
3494
+ this.stretch(exports.Side.Right, excessRight);
3495
+ }
3368
3496
  }
3369
3497
  const excessBottom = child.coords[1] + child.height - (this.coords[1] + this.height) + this.type.bottomPadding;
3370
3498
  if (excessBottom >= 0) {
3371
- this.stretch(exports.Side.Bottom, excessBottom);
3499
+ if (this.sections.length > 0) {
3500
+ this.stretchSections(exports.Side.Bottom, excessBottom, maxSectionIndexX, maxSectionIndexY);
3501
+ } else {
3502
+ this.stretch(exports.Side.Bottom, excessBottom);
3503
+ }
3372
3504
  }
3373
3505
  if (this.parent) {
3374
3506
  // ensure this node also fits inside its parent after stretching
@@ -3583,7 +3715,7 @@ class DiagramNode extends DiagramElement {
3583
3715
  }
3584
3716
  // Move ports to match the new coords.
3585
3717
  for (const port of this.ports) {
3586
- port.move(translatePoint(port.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY));
3718
+ port.move(translatePointWithAnchors(port.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY, port.anchorPointX, port.anchorPointY));
3587
3719
  }
3588
3720
  // Set label's dimensions as a function of ours.
3589
3721
  if (this.label) {
@@ -3594,7 +3726,7 @@ class DiagramNode extends DiagramElement {
3594
3726
  }
3595
3727
  // Move decorators to match the new coords.
3596
3728
  for (const decorator of this.decorators) {
3597
- decorator.move(translatePoint(decorator.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY));
3729
+ decorator.move(translatePointWithAnchors(decorator.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY, decorator.anchorPointX, decorator.anchorPointY));
3598
3730
  }
3599
3731
  // Update canvas.
3600
3732
  this.getConnections().forEach(c => c.tighten());
@@ -3606,7 +3738,7 @@ class DiagramNode extends DiagramElement {
3606
3738
  */
3607
3739
  removeSectionColumn(columnIndex) {
3608
3740
  var _a;
3609
- const margin = ((_a = this.type.sectionGrid) === null || _a === undefined ? undefined : _a.margin) || 0;
3741
+ const margin = ((_a = this.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
3610
3742
  let columnWidth = 0;
3611
3743
  const sections = [...this.sections];
3612
3744
  for (const section of sections) {
@@ -3629,7 +3761,7 @@ class DiagramNode extends DiagramElement {
3629
3761
  */
3630
3762
  removeSectionRow(rowIndex) {
3631
3763
  var _a;
3632
- const margin = ((_a = this.type.sectionGrid) === null || _a === undefined ? undefined : _a.margin) || 0;
3764
+ const margin = ((_a = this.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
3633
3765
  let rowHeight = 0;
3634
3766
  const sections = [...this.sections];
3635
3767
  for (const section of sections) {
@@ -3652,7 +3784,7 @@ class DiagramNode extends DiagramElement {
3652
3784
  */
3653
3785
  copySectionColumn(columnIndex) {
3654
3786
  var _a;
3655
- const margin = ((_a = this.type.sectionGrid) === null || _a === undefined ? undefined : _a.margin) || 0;
3787
+ const margin = ((_a = this.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
3656
3788
  let columnWidth = 0;
3657
3789
  const sections = [...this.sections];
3658
3790
  for (const section of sections) {
@@ -3679,7 +3811,7 @@ class DiagramNode extends DiagramElement {
3679
3811
  */
3680
3812
  copySectionRow(rowIndex) {
3681
3813
  var _a;
3682
- const margin = ((_a = this.type.sectionGrid) === null || _a === undefined ? undefined : _a.margin) || 0;
3814
+ const margin = ((_a = this.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
3683
3815
  let rowHeight = 0;
3684
3816
  const sections = [...this.sections];
3685
3817
  for (const section of sections) {
@@ -3745,10 +3877,10 @@ class DiagramNodeSet extends DiagramElementSet {
3745
3877
  for (let j = 0; j < nodeType.sectionGrid.sections.length; ++j) {
3746
3878
  let widthAccumulator = node.coords[0] + (nodeType.sectionGrid.margin || 0);
3747
3879
  for (let i = 0; i < nodeType.sectionGrid.sections[j].length; ++i) {
3748
- 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}`);
3749
- widthAccumulator += (((_c = nodeType.sectionGrid.defaultWidths) === null || _c === undefined ? undefined : _c[i]) || DIAGRAM_SECTION_DEFAULT_WIDTH) + (nodeType.sectionGrid.margin || 0);
3880
+ 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}`);
3881
+ widthAccumulator += (((_c = nodeType.sectionGrid.defaultWidths) === null || _c === void 0 ? void 0 : _c[i]) || DIAGRAM_SECTION_DEFAULT_WIDTH) + (nodeType.sectionGrid.margin || 0);
3750
3882
  }
3751
- heightAccumulator += (((_d = nodeType.sectionGrid.defaultHeights) === null || _d === undefined ? undefined : _d[j]) || DIAGRAM_SECTION_DEFAULT_HEIGHT) + (nodeType.sectionGrid.margin || 0);
3883
+ heightAccumulator += (((_d = nodeType.sectionGrid.defaultHeights) === null || _d === void 0 ? void 0 : _d[j]) || DIAGRAM_SECTION_DEFAULT_HEIGHT) + (nodeType.sectionGrid.margin || 0);
3752
3884
  }
3753
3885
  }
3754
3886
  // add node ports
@@ -3756,9 +3888,9 @@ class DiagramNodeSet extends DiagramElementSet {
3756
3888
  for (let i = 0; i < nodeType.ports.length; ++i) {
3757
3889
  const portConfig = nodeType.ports[i];
3758
3890
  const portType = portConfig.type !== undefined ? this.model.ports.types.get(portConfig.type) : undefined;
3759
- 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}`);
3760
- if ((_e = port.type) === null || _e === undefined ? undefined : _e.label) {
3761
- const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === undefined ? undefined : _f.label);
3891
+ 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}`, portConfig.anchorPointX || 'floating', portConfig.anchorPointY || 'floating');
3892
+ if ((_e = port.type) === null || _e === void 0 ? void 0 : _e.label) {
3893
+ const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === void 0 ? void 0 : _f.label);
3762
3894
  const labelWidth = 6 * labelConfiguration.fontSize + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
3763
3895
  const labelHeight = labelConfiguration.fontSize + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
3764
3896
  let labelCoords;
@@ -3774,24 +3906,24 @@ class DiagramNodeSet extends DiagramElementSet {
3774
3906
  default:
3775
3907
  labelCoords = port.coords;
3776
3908
  }
3777
- this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
3909
+ 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, labelConfiguration.shrink);
3778
3910
  }
3779
3911
  }
3780
3912
  }
3781
3913
  // add node label
3782
3914
  if (nodeType.label) {
3783
3915
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), nodeType.label);
3784
- 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);
3916
+ 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, labelConfiguration.shrink);
3785
3917
  }
3786
3918
  // add node decorators
3787
3919
  if (nodeType.decorators.length > 0) {
3788
3920
  for (let i = 0; i < nodeType.decorators.length; ++i) {
3789
3921
  const decoratorConfig = nodeType.decorators[i];
3790
- this.model.decorators.new(node, [node.coords[0] + decoratorConfig.coords[0], node.coords[1] + decoratorConfig.coords[1]], decoratorConfig.width, decoratorConfig.height, node.getPriority(), decoratorConfig.html, `${node.id}_decorator_${i}`);
3922
+ this.model.decorators.new(node, [node.coords[0] + decoratorConfig.coords[0], node.coords[1] + decoratorConfig.coords[1]], decoratorConfig.width, decoratorConfig.height, node.getPriority(), decoratorConfig.html, `${node.id}_decorator_${i}`, decoratorConfig.anchorPointX || 'floating', decoratorConfig.anchorPointY || 'floating');
3791
3923
  }
3792
3924
  }
3793
3925
  node.valueSet.resetValues();
3794
- (_g = node.model.canvas) === null || _g === undefined ? undefined : _g.fitNodeInView(node.id);
3926
+ (_g = node.model.canvas) === null || _g === void 0 ? void 0 : _g.fitNodeInView(node.id);
3795
3927
  return node;
3796
3928
  }
3797
3929
  remove(id) {
@@ -3883,7 +4015,7 @@ const filterByOnlyDescendants = nodes => {
3883
4015
  return nodes;
3884
4016
  };
3885
4017
  const getBottomPadding = config => {
3886
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
4018
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
3887
4019
  return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
3888
4020
  } else if (typeof config.padding === 'number') {
3889
4021
  return config.padding;
@@ -3902,7 +4034,7 @@ const getBottomPadding = config => {
3902
4034
  }
3903
4035
  };
3904
4036
  const getLeftPadding = config => {
3905
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
4037
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
3906
4038
  return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
3907
4039
  } else if (typeof config.padding === 'number') {
3908
4040
  return config.padding;
@@ -3921,7 +4053,7 @@ const getLeftPadding = config => {
3921
4053
  }
3922
4054
  };
3923
4055
  const getRightPadding = config => {
3924
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
4056
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
3925
4057
  return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
3926
4058
  } else if (typeof config.padding === 'number') {
3927
4059
  return config.padding;
@@ -3940,7 +4072,7 @@ const getRightPadding = config => {
3940
4072
  }
3941
4073
  };
3942
4074
  const getTopPadding = config => {
3943
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
4075
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
3944
4076
  return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
3945
4077
  } else if (typeof config.padding === 'number') {
3946
4078
  return config.padding;
@@ -4024,20 +4156,25 @@ class DiagramPort extends DiagramElement {
4024
4156
  return this._type;
4025
4157
  }
4026
4158
  set type(type) {
4027
- this._type = type;
4028
- this.updateInView();
4159
+ if (type !== this._type) {
4160
+ this._type = type;
4161
+ this.updateInView();
4162
+ }
4029
4163
  }
4030
4164
  get typeString() {
4031
4165
  var _a;
4032
- return (_a = this.type) === null || _a === undefined ? undefined : _a.id;
4166
+ return (_a = this.type) === null || _a === void 0 ? void 0 : _a.id;
4033
4167
  }
4034
4168
  set typeString(typeString) {
4035
- if (typeString === undefined) {
4036
- this.type = undefined;
4037
- } else {
4038
- const type = this.model.ports.types.get(typeString);
4039
- if (type) {
4040
- this.type = type;
4169
+ var _a;
4170
+ if (typeString !== ((_a = this.type) === null || _a === void 0 ? void 0 : _a.id)) {
4171
+ if (typeString === undefined) {
4172
+ this.type = undefined;
4173
+ } else {
4174
+ const type = this.model.ports.types.get(typeString);
4175
+ if (type) {
4176
+ this.type = type;
4177
+ }
4041
4178
  }
4042
4179
  }
4043
4180
  }
@@ -4046,14 +4183,14 @@ class DiagramPort extends DiagramElement {
4046
4183
  */
4047
4184
  get allowsOutgoing() {
4048
4185
  var _a, _b;
4049
- return ((_a = this.type) === null || _a === undefined ? undefined : _a.allowsOutgoing) !== undefined ? (_b = this.type) === null || _b === undefined ? undefined : _b.allowsOutgoing : true;
4186
+ 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;
4050
4187
  }
4051
4188
  /**
4052
4189
  * Whether this port can be used as a connection end point.
4053
4190
  */
4054
4191
  get allowsIncoming() {
4055
4192
  var _a, _b;
4056
- return ((_a = this.type) === null || _a === undefined ? undefined : _a.allowsIncoming) !== undefined ? (_b = this.type) === null || _b === undefined ? undefined : _b.allowsIncoming : true;
4193
+ 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;
4057
4194
  }
4058
4195
  /**
4059
4196
  * Name of this port. Alias for this port's label's text.
@@ -4061,7 +4198,7 @@ class DiagramPort extends DiagramElement {
4061
4198
  */
4062
4199
  get name() {
4063
4200
  var _a;
4064
- return ((_a = this.label) === null || _a === undefined ? undefined : _a.text) || '';
4201
+ return ((_a = this.label) === null || _a === void 0 ? void 0 : _a.text) || '';
4065
4202
  }
4066
4203
  set name(name) {
4067
4204
  if (this.label) {
@@ -4076,15 +4213,15 @@ class DiagramPort extends DiagramElement {
4076
4213
  var _a, _b, _c, _d;
4077
4214
  if (this.selected) {
4078
4215
  if (this.highlighted) {
4079
- return this._selectedAndHighlightedLook !== undefined ? this._selectedAndHighlightedLook : (_a = this.type || DIAGRAM_PORT_LOOKS) === null || _a === undefined ? undefined : _a.selectedAndHighlightedLook;
4216
+ return this._selectedAndHighlightedLook !== undefined ? this._selectedAndHighlightedLook : (_a = this.type || DIAGRAM_PORT_LOOKS) === null || _a === void 0 ? void 0 : _a.selectedAndHighlightedLook;
4080
4217
  } else {
4081
- return this._selectedLook !== undefined ? this._selectedLook : (_b = this.type || DIAGRAM_PORT_LOOKS) === null || _b === undefined ? undefined : _b.selectedLook;
4218
+ return this._selectedLook !== undefined ? this._selectedLook : (_b = this.type || DIAGRAM_PORT_LOOKS) === null || _b === void 0 ? void 0 : _b.selectedLook;
4082
4219
  }
4083
4220
  } else {
4084
4221
  if (this.highlighted) {
4085
- return this._highlightedLook !== undefined ? this._highlightedLook : (_c = this.type || DIAGRAM_PORT_LOOKS) === null || _c === undefined ? undefined : _c.highlightedLook;
4222
+ return this._highlightedLook !== undefined ? this._highlightedLook : (_c = this.type || DIAGRAM_PORT_LOOKS) === null || _c === void 0 ? void 0 : _c.highlightedLook;
4086
4223
  } else {
4087
- return this._defaultLook !== undefined ? this._defaultLook : (_d = this.type || DIAGRAM_PORT_LOOKS) === null || _d === undefined ? undefined : _d.defaultLook;
4224
+ return this._defaultLook !== undefined ? this._defaultLook : (_d = this.type || DIAGRAM_PORT_LOOKS) === null || _d === void 0 ? void 0 : _d.defaultLook;
4088
4225
  }
4089
4226
  }
4090
4227
  }
@@ -4113,7 +4250,7 @@ class DiagramPort extends DiagramElement {
4113
4250
  */
4114
4251
  get width() {
4115
4252
  var _a;
4116
- return ((_a = this.type) === null || _a === undefined ? undefined : _a.width) || DIAGRAM_PORT_TYPE_DEFAULTS.width;
4253
+ return ((_a = this.type) === null || _a === void 0 ? void 0 : _a.width) || DIAGRAM_PORT_TYPE_DEFAULTS.width;
4117
4254
  }
4118
4255
  /**
4119
4256
  * Current height of this port. Same as the width.
@@ -4122,7 +4259,7 @@ class DiagramPort extends DiagramElement {
4122
4259
  get height() {
4123
4260
  return this.width;
4124
4261
  }
4125
- constructor(model, type, rootElement, coords, connectionPoint, direction, id) {
4262
+ constructor(model, type, rootElement, coords, connectionPoint, direction, id, anchorPointX = 'floating', anchorPointY = 'floating') {
4126
4263
  if (model.ports.get(id) !== undefined) {
4127
4264
  throw new Error(`DiagramPort with id "${id}" already exists`);
4128
4265
  }
@@ -4145,17 +4282,19 @@ class DiagramPort extends DiagramElement {
4145
4282
  this.coords = coords;
4146
4283
  this.connectionPoint = connectionPoint || coords;
4147
4284
  this.direction = direction;
4285
+ this.anchorPointX = anchorPointX;
4286
+ this.anchorPointY = anchorPointY;
4148
4287
  }
4149
4288
  get removed() {
4150
4289
  return this.selfRemoved || this.rootElement !== undefined && this.rootElement.removed;
4151
4290
  }
4152
4291
  updateInView() {
4153
4292
  var _a;
4154
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updatePortsInView(this.id);
4293
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updatePortsInView(this.id);
4155
4294
  }
4156
4295
  raise() {
4157
4296
  var _a;
4158
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
4297
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
4159
4298
  if (this.label) {
4160
4299
  this.label.raise();
4161
4300
  }
@@ -4197,7 +4336,7 @@ class DiagramPort extends DiagramElement {
4197
4336
  }
4198
4337
  getPriority() {
4199
4338
  var _a;
4200
- return ((_a = this.rootElement) === null || _a === undefined ? undefined : _a.getPriority()) || DEFAULT_PRIORITY;
4339
+ return ((_a = this.rootElement) === null || _a === void 0 ? void 0 : _a.getPriority()) || DEFAULT_PRIORITY;
4201
4340
  }
4202
4341
  /**
4203
4342
  * Change the coordinates of this port to the given coordinates and move its labels correspondingly.
@@ -4242,8 +4381,8 @@ class DiagramPortSet extends DiagramElementSet {
4242
4381
  * Instance a new port and add it to this set. This method is normally called when instancing an element with a port and it is rarely called by itself.
4243
4382
  * @private
4244
4383
  */
4245
- new(type, rootElement, coords, connectionPoint, direction, id) {
4246
- const port = new DiagramPort(this.model, type, rootElement, coords, connectionPoint, direction, id);
4384
+ new(type, rootElement, coords, connectionPoint, direction, id, anchorPointX = 'floating', anchorPointY = 'floating') {
4385
+ const port = new DiagramPort(this.model, type, rootElement, coords, connectionPoint, direction, id, anchorPointX, anchorPointY);
4247
4386
  super.add(port);
4248
4387
  port.updateInView();
4249
4388
  // add this port to its root element
@@ -4328,7 +4467,7 @@ class DagaImporter {
4328
4467
  // add node label
4329
4468
  if (newNodeType.label) {
4330
4469
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newNodeType.label);
4331
- 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);
4470
+ 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, labelConfiguration.shrink);
4332
4471
  newField.text = node.label;
4333
4472
  newNode.label = newField;
4334
4473
  model.fields.add(newField);
@@ -4338,19 +4477,19 @@ class DagaImporter {
4338
4477
  for (const child of node.children || []) {
4339
4478
  const newChild = this.importNode(model, child);
4340
4479
  if (newChild !== undefined) {
4341
- (_a = newNode.children) === null || _a === undefined ? undefined : _a.push(newChild);
4480
+ (_a = newNode.children) === null || _a === void 0 ? void 0 : _a.push(newChild);
4342
4481
  newChild.parent = newNode;
4343
4482
  }
4344
4483
  }
4345
4484
  for (const section of node.sections || []) {
4346
4485
  const newSection = new DiagramSection(model, newNode, section.indexXInNode, section.indexYInNode, section.coords, section.width, section.height, section.id);
4347
- (_b = newNode.sections) === null || _b === undefined ? undefined : _b.push(newSection);
4486
+ (_b = newNode.sections) === null || _b === void 0 ? void 0 : _b.push(newSection);
4348
4487
  model.sections.add(newSection);
4349
4488
  if (section.label) {
4350
4489
  // add section label
4351
- 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) {
4352
- 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);
4353
- 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);
4490
+ 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) {
4491
+ 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);
4492
+ 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, labelConfiguration.shrink);
4354
4493
  newField.text = section.label;
4355
4494
  newSection.label = newField;
4356
4495
  model.fields.add(newField);
@@ -4365,8 +4504,8 @@ class DagaImporter {
4365
4504
  model.ports.add(newPort);
4366
4505
  if (port.label) {
4367
4506
  // add port label
4368
- if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType === undefined ? undefined : newPortType.label)) {
4369
- const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType === undefined ? undefined : newPortType.label);
4507
+ if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType === void 0 ? void 0 : newPortType.label)) {
4508
+ const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType === void 0 ? void 0 : newPortType.label);
4370
4509
  let labelCoords;
4371
4510
  switch (newPort.direction) {
4372
4511
  case exports.Side.Top:
@@ -4382,7 +4521,7 @@ class DagaImporter {
4382
4521
  default:
4383
4522
  labelCoords = newPort.coords;
4384
4523
  }
4385
- 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);
4524
+ 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, labelConfiguration.shrink);
4386
4525
  newField.text = port.label;
4387
4526
  newPort.label = newField;
4388
4527
  model.fields.add(newField);
@@ -4412,8 +4551,8 @@ class DagaImporter {
4412
4551
  model.ports.add(newPort);
4413
4552
  if (port.label) {
4414
4553
  // add port label
4415
- if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType === undefined ? undefined : newPortType.label)) {
4416
- const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType === undefined ? undefined : newPortType.label);
4554
+ if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType === void 0 ? void 0 : newPortType.label)) {
4555
+ const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType === void 0 ? void 0 : newPortType.label);
4417
4556
  let labelCoords;
4418
4557
  switch (newPort.direction) {
4419
4558
  case exports.Side.Top:
@@ -4429,7 +4568,7 @@ class DagaImporter {
4429
4568
  default:
4430
4569
  labelCoords = newPort.coords;
4431
4570
  }
4432
- 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);
4571
+ 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, labelConfiguration.shrink);
4433
4572
  newField.text = port.label;
4434
4573
  newPort.label = newField;
4435
4574
  model.fields.add(newField);
@@ -4513,14 +4652,16 @@ class AddNodeCollabAction {
4513
4652
  var _a;
4514
4653
  const node = this.canvas.model.nodes.new(this.typeId, this.coords, this.id);
4515
4654
  if (this.parentId !== undefined) {
4516
- (_a = this.canvas.model.nodes.get(this.parentId)) === null || _a === undefined ? undefined : _a.addChild(node);
4517
- }
4518
- if (this.values !== undefined) {
4519
- node.valueSet.setValues(structuredClone(Object.assign(Object.assign({}, node.valueSet.getValues()), this.values)));
4655
+ (_a = this.canvas.model.nodes.get(this.parentId)) === null || _a === void 0 ? void 0 : _a.addChild(node);
4520
4656
  }
4521
4657
  if (node.label) {
4522
4658
  node.label.text = this.label || '';
4523
4659
  }
4660
+ if (this.values !== undefined) {
4661
+ node.valueSet.setValues(structuredClone(Object.assign(Object.assign({}, node.valueSet.getValues()), this.values)));
4662
+ } else {
4663
+ node.valueSet.resetValues();
4664
+ }
4524
4665
  }
4525
4666
  serialize() {
4526
4667
  return {
@@ -4635,7 +4776,7 @@ class MoveCollabAction {
4635
4776
  const node = this.canvas.model.nodes.get(nodeId, true);
4636
4777
  if (node && timestampWins(this.timestamp, node.geometryTimestamp)) {
4637
4778
  node.move([node.coords[0] + this.delta[0], node.coords[1] + this.delta[1]]);
4638
- (_a = node.parent) === null || _a === undefined ? undefined : _a.fitToChild(node);
4779
+ (_a = node.parent) === null || _a === void 0 ? void 0 : _a.fitToChild(node);
4639
4780
  node.geometryTimestamp = this.timestamp;
4640
4781
  }
4641
4782
  }
@@ -4670,15 +4811,15 @@ class SetGeometryCollabAction {
4670
4811
  if (node && timestampWins(this.timestamp, node.geometryTimestamp)) {
4671
4812
  node.setGeometry(this.to);
4672
4813
  // Re-fit the labels, in case their text has changed since `this.to` was measured.
4673
- if ((_a = node.label) === null || _a === undefined ? undefined : _a.fit) {
4674
- this.canvas.fitFieldRootInView(node.label.id);
4814
+ if ((_a = node.label) === null || _a === void 0 ? void 0 : _a.fit) {
4815
+ this.canvas.fitFieldRootInView(node.label.id, node.label.shrink);
4675
4816
  }
4676
4817
  for (const section of node.sections) {
4677
- if ((_b = section.label) === null || _b === undefined ? undefined : _b.fit) {
4678
- this.canvas.fitFieldRootInView(section.label.id);
4818
+ if ((_b = section.label) === null || _b === void 0 ? void 0 : _b.fit) {
4819
+ this.canvas.fitFieldRootInView(section.label.id, section.label.shrink);
4679
4820
  }
4680
4821
  }
4681
- (_c = node.parent) === null || _c === undefined ? undefined : _c.fitToChild(node);
4822
+ (_c = node.parent) === null || _c === void 0 ? void 0 : _c.fitToChild(node);
4682
4823
  node.geometryTimestamp = this.timestamp;
4683
4824
  }
4684
4825
  }
@@ -4712,9 +4853,9 @@ class SetParentCollabAction {
4712
4853
  const childNode = this.canvas.model.nodes.get(this.childId, true);
4713
4854
  const parentNode = this.parentId !== undefined ? this.canvas.model.nodes.get(this.parentId, true) : undefined;
4714
4855
  if (childNode && (this.parentId !== undefined ? parentNode : true) && timestampWins(this.timestamp, childNode.geometryTimestamp)) {
4715
- (_a = childNode.parent) === null || _a === undefined ? undefined : _a.removeChild(childNode);
4856
+ (_a = childNode.parent) === null || _a === void 0 ? void 0 : _a.removeChild(childNode);
4716
4857
  childNode.setGeometry(this.childGeometry);
4717
- parentNode === null || parentNode === undefined ? undefined : parentNode.addChild(childNode);
4858
+ parentNode === null || parentNode === void 0 ? void 0 : parentNode.addChild(childNode);
4718
4859
  }
4719
4860
  }
4720
4861
  serialize() {
@@ -4811,12 +4952,12 @@ class UpdateValuesCollabAction {
4811
4952
  if (this.id === undefined) {
4812
4953
  return this.canvas.model.valueSet;
4813
4954
  } else {
4814
- return (_a = this.canvas.model.nodes.get(this.id, true) || this.canvas.model.connections.get(this.id, true)) === null || _a === undefined ? undefined : _a.valueSet;
4955
+ 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;
4815
4956
  }
4816
4957
  }
4817
4958
  do() {
4818
4959
  var _a;
4819
- (_a = this.getValueSet()) === null || _a === undefined ? undefined : _a.overwriteValuesLww(this.to, this.timestamp);
4960
+ (_a = this.getValueSet()) === null || _a === void 0 ? void 0 : _a.overwriteValuesLww(this.to, this.timestamp);
4820
4961
  }
4821
4962
  serialize() {
4822
4963
  return {
@@ -5796,7 +5937,7 @@ class DiagramHighlightedEvent extends DiagramEvent {
5796
5937
  * @see DiagramSection
5797
5938
  */
5798
5939
  class DiagramDecorator extends DiagramElement {
5799
- constructor(model, rootElement, coords, width, height, priority, html, id) {
5940
+ constructor(model, rootElement, coords, width, height, priority, html, id, anchorPointX = 'floating', anchorPointY = 'floating') {
5800
5941
  if (model.objects.get(id) !== undefined) {
5801
5942
  throw new Error(`DiagramDecorator with id "${id}" already exists`);
5802
5943
  }
@@ -5810,17 +5951,19 @@ class DiagramDecorator extends DiagramElement {
5810
5951
  this.height = height;
5811
5952
  this.priority = priority;
5812
5953
  this.html = html;
5954
+ this.anchorPointX = anchorPointX;
5955
+ this.anchorPointY = anchorPointY;
5813
5956
  }
5814
5957
  get removed() {
5815
5958
  return this.selfRemoved || this.rootElement !== undefined && this.rootElement.removed;
5816
5959
  }
5817
5960
  updateInView() {
5818
5961
  var _a;
5819
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateDecoratorsInView(this.id);
5962
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateDecoratorsInView(this.id);
5820
5963
  }
5821
5964
  raise() {
5822
5965
  var _a;
5823
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
5966
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
5824
5967
  }
5825
5968
  /**
5826
5969
  * Change the coordinates of this decorator to the given coordinates.
@@ -5855,8 +5998,8 @@ class DiagramDecoratorSet extends DiagramElementSet {
5855
5998
  * @param id The id of the decorator. Cannot be an empty string.
5856
5999
  * @returns The instanced decorator.
5857
6000
  */
5858
- new(rootElement, coords, width, height, priority, html, id) {
5859
- const decorator = new DiagramDecorator(this.model, rootElement, coords, width, height, priority, html, id);
6001
+ new(rootElement, coords, width, height, priority, html, id, anchorPointX = 'floating', anchorPointY = 'floating') {
6002
+ const decorator = new DiagramDecorator(this.model, rootElement, coords, width, height, priority, html, id, anchorPointX, anchorPointY);
5860
6003
  super.add(decorator);
5861
6004
  decorator.updateInView();
5862
6005
  // add this port to its root element
@@ -5905,11 +6048,11 @@ class DiagramObject extends DiagramElement {
5905
6048
  }
5906
6049
  updateInView() {
5907
6050
  var _a;
5908
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateObjectsInView(this.id);
6051
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateObjectsInView(this.id);
5909
6052
  }
5910
6053
  raise() {
5911
6054
  var _a;
5912
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
6055
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
5913
6056
  }
5914
6057
  /**
5915
6058
  * Change the coordinates of this object to the given coordinates.
@@ -6026,7 +6169,7 @@ class DiagramModel {
6026
6169
  */
6027
6170
  clear() {
6028
6171
  var _a, _b;
6029
- (_a = this.canvas) === null || _a === undefined ? undefined : _a.cancelAllUserActions();
6172
+ (_a = this.canvas) === null || _a === void 0 ? void 0 : _a.cancelAllUserActions();
6030
6173
  this.id = undefined;
6031
6174
  this.name = '';
6032
6175
  this.description = undefined;
@@ -6041,7 +6184,7 @@ class DiagramModel {
6041
6184
  this.objects.clear();
6042
6185
  this.decorators.clear();
6043
6186
  this.valueSet.resetValues();
6044
- (_b = this.canvas) === null || _b === undefined ? undefined : _b.updateModelInView();
6187
+ (_b = this.canvas) === null || _b === void 0 ? void 0 : _b.updateModelInView();
6045
6188
  }
6046
6189
  }
6047
6190
 
@@ -6107,7 +6250,6 @@ const updateLook = selection => {
6107
6250
  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);
6108
6251
  };
6109
6252
  const GRID_DEFAULTS = {
6110
- enabled: true,
6111
6253
  style: 'dots',
6112
6254
  color: 'rgba(0, 0, 0, 0.1)',
6113
6255
  snap: false,
@@ -6265,7 +6407,7 @@ class DiagramContextMenu {
6265
6407
  */
6266
6408
  close() {
6267
6409
  var _a;
6268
- (_a = this.contextMenuContainer) === null || _a === undefined ? undefined : _a.remove();
6410
+ (_a = this.contextMenuContainer) === null || _a === void 0 ? void 0 : _a.remove();
6269
6411
  this.contextMenuContainer = undefined;
6270
6412
  }
6271
6413
  }
@@ -6401,11 +6543,11 @@ class DagaExporter {
6401
6543
  for (const port of section.ports) {
6402
6544
  ports.push(Object.assign({
6403
6545
  id: port.id,
6404
- type: (_a = port.type) === null || _a === undefined ? undefined : _a.id,
6546
+ type: (_a = port.type) === null || _a === void 0 ? void 0 : _a.id,
6405
6547
  coords: roundPoint(port.coords),
6406
6548
  connectionPoint: roundPoint(port.connectionPoint),
6407
6549
  direction: port.direction,
6408
- label: ((_b = port.label) === null || _b === undefined ? undefined : _b.text) || ''
6550
+ label: ((_b = port.label) === null || _b === void 0 ? void 0 : _b.text) || ''
6409
6551
  }, includeCollabMeta ? {
6410
6552
  collabMeta: Object.assign({
6411
6553
  removed: port.removed,
@@ -6417,7 +6559,7 @@ class DagaExporter {
6417
6559
  sections.push(Object.assign({
6418
6560
  id: section.id,
6419
6561
  ports,
6420
- label: ((_c = section.label) === null || _c === undefined ? undefined : _c.text) || '',
6562
+ label: ((_c = section.label) === null || _c === void 0 ? void 0 : _c.text) || '',
6421
6563
  indexXInNode: section.indexXInNode,
6422
6564
  indexYInNode: section.indexYInNode,
6423
6565
  coords: roundPoint(section.coords),
@@ -6435,11 +6577,11 @@ class DagaExporter {
6435
6577
  for (const port of node.ports) {
6436
6578
  ports.push(Object.assign({
6437
6579
  id: port.id,
6438
- type: (_d = port.type) === null || _d === undefined ? undefined : _d.id,
6580
+ type: (_d = port.type) === null || _d === void 0 ? void 0 : _d.id,
6439
6581
  coords: roundPoint(port.coords),
6440
6582
  connectionPoint: roundPoint(port.connectionPoint),
6441
6583
  direction: port.direction,
6442
- label: ((_e = port.label) === null || _e === undefined ? undefined : _e.text) || ''
6584
+ label: ((_e = port.label) === null || _e === void 0 ? void 0 : _e.text) || ''
6443
6585
  }, includeCollabMeta ? {
6444
6586
  collabMeta: Object.assign({
6445
6587
  removed: port.removed,
@@ -6454,7 +6596,7 @@ class DagaExporter {
6454
6596
  children,
6455
6597
  sections,
6456
6598
  ports,
6457
- label: ((_f = node.label) === null || _f === undefined ? undefined : _f.text) || '',
6599
+ label: ((_f = node.label) === null || _f === void 0 ? void 0 : _f.text) || '',
6458
6600
  coords: roundPoint(node.coords),
6459
6601
  width: node.width,
6460
6602
  height: node.height,
@@ -6474,8 +6616,8 @@ class DagaExporter {
6474
6616
  return Object.assign({
6475
6617
  id: connection.id,
6476
6618
  type: connection.type.id,
6477
- start: ((_a = connection.start) === null || _a === undefined ? undefined : _a.id) || '',
6478
- end: ((_b = connection.end) === null || _b === undefined ? undefined : _b.id) || '',
6619
+ start: ((_a = connection.start) === null || _a === void 0 ? void 0 : _a.id) || '',
6620
+ end: ((_b = connection.end) === null || _b === void 0 ? void 0 : _b.id) || '',
6479
6621
  startLabel: connection.startLabel,
6480
6622
  middleLabel: connection.middleLabel,
6481
6623
  endLabel: connection.endLabel,
@@ -6690,19 +6832,25 @@ class DiagramUserSelection extends DiagramElementSet {
6690
6832
  * Opens the value set of a diagram model or a diagram element in the property editor.
6691
6833
  * @public
6692
6834
  * @param selection A diagram model or a diagram element with a value set.
6835
+ * @param makeUpdateValuesAction Whether the method should create an UpdateValuesAction.
6693
6836
  * @see PropertyEditor
6837
+ * @see UpdateValuesAction
6694
6838
  */
6695
- openInPropertyEditor(selection) {
6839
+ openInPropertyEditor(selection, makeUpdateValuesAction = true) {
6696
6840
  var _a;
6697
- this.makeUpdateValuesAction();
6698
- const propertyEditor = (_a = this.canvas.parentComponent) === null || _a === undefined ? undefined : _a.propertyEditor;
6841
+ if (makeUpdateValuesAction) {
6842
+ this.makeUpdateValuesAction();
6843
+ }
6844
+ const propertyEditor = (_a = this.canvas.parentComponent) === null || _a === void 0 ? void 0 : _a.propertyEditor;
6699
6845
  if (propertyEditor === undefined) {
6700
6846
  return;
6701
6847
  }
6702
- const selectedValueSet = selection === null || selection === undefined ? undefined : selection.valueSet;
6848
+ const selectedValueSet = selection === null || selection === void 0 ? void 0 : selection.valueSet;
6703
6849
  if (selectedValueSet) {
6704
6850
  this.propertyEditorSelection = selection;
6705
- this.propertyEditorValues = structuredClone(selectedValueSet.getValues());
6851
+ if (makeUpdateValuesAction) {
6852
+ this.propertyEditorValues = structuredClone(selectedValueSet.getValues());
6853
+ }
6706
6854
  if (propertyEditor) {
6707
6855
  if (selection instanceof DiagramNode || selection instanceof DiagramConnection) {
6708
6856
  if (selection instanceof DiagramNode) {
@@ -6741,12 +6889,12 @@ class DiagramUserSelection extends DiagramElementSet {
6741
6889
  const previousSelectionId = this.propertyEditorSelection instanceof DiagramModel ? undefined : this.propertyEditorSelection.id;
6742
6890
  // check if there have been changes in the previously selected ValueSet,
6743
6891
  // and create an UpdateValuesAction if there have
6744
- if (equals(this.propertyEditorValues, (_a = this.propertyEditorSelection) === null || _a === undefined ? undefined : _a.valueSet.getValues())) {
6892
+ if (equals(this.propertyEditorValues, (_a = this.propertyEditorSelection) === null || _a === void 0 ? void 0 : _a.valueSet.getValues())) {
6745
6893
  return;
6746
6894
  }
6747
6895
  const from = this.propertyEditorValues;
6748
- const to = structuredClone((_b = this.propertyEditorSelection) === null || _b === undefined ? undefined : _b.valueSet.getValues());
6749
- const [fromDiff, toDiff] = diffProperties(from, to, (_c = this.propertyEditorSelection) === null || _c === undefined ? undefined : _c.valueSet);
6896
+ const to = structuredClone((_b = this.propertyEditorSelection) === null || _b === void 0 ? void 0 : _b.valueSet.getValues());
6897
+ const [fromDiff, toDiff] = diffProperties(from, to, (_c = this.propertyEditorSelection) === null || _c === void 0 ? void 0 : _c.valueSet);
6750
6898
  const currentAction = new UpdateValuesAction(this.canvas, previousSelectionId, fromDiff, toDiff);
6751
6899
  currentAction.do();
6752
6900
  this.canvas.actionStack.add(currentAction);
@@ -6754,6 +6902,26 @@ class DiagramUserSelection extends DiagramElementSet {
6754
6902
  }
6755
6903
  }
6756
6904
 
6905
+ const degreesToRadians = theta => theta * Math.PI / 180;
6906
+ /**
6907
+ * Calculates the original size of the a rectangle that has been rotated by the given number of degrees resulting in a bounding box of the given size.
6908
+ *
6909
+ * @param width The width of a bounding box.
6910
+ * @param height The height of a bounding box.
6911
+ * @param orientation A rotation in degrees.
6912
+ * @returns The size of the original rectangle.
6913
+ */
6914
+ const unrotate = (width, height, orientation) => {
6915
+ // TODO: this method fails under certain edge cases
6916
+ // like for example, when angle is 45 degrees so sin(theta) == cos(theta)
6917
+ const theta = degreesToRadians(orientation);
6918
+ const orientationSine = Math.sin(theta);
6919
+ const orientationCosine = Math.cos(theta);
6920
+ const oldWidth = (Math.abs(width * orientationCosine) - Math.abs(height * orientationSine)) / (orientationCosine * orientationCosine - orientationSine * orientationSine);
6921
+ const oldHeight = (Math.abs(width * orientationSine) - Math.abs(height * orientationCosine)) / (orientationSine * orientationSine - orientationCosine * orientationCosine);
6922
+ return [oldWidth, oldHeight];
6923
+ };
6924
+
6757
6925
  /**
6758
6926
  * Thickness of the invisible path around a connection used to make it easier to click on, in diagram units.
6759
6927
  * @private
@@ -6780,7 +6948,7 @@ class DiagramCanvas {
6780
6948
  var _a, _b;
6781
6949
  this._connectionType = value;
6782
6950
  // refresh the palette every time connectionType is set so that the palette keeps track of updates to the connectionType
6783
- (_b = (_a = this.parentComponent) === null || _a === undefined ? undefined : _a.palette) === null || _b === undefined ? undefined : _b.refreshPalette();
6951
+ (_b = (_a = this.parentComponent) === null || _a === void 0 ? void 0 : _a.palette) === null || _b === void 0 ? void 0 : _b.refreshPalette();
6784
6952
  }
6785
6953
  /**
6786
6954
  * Constructs a canvas object.
@@ -6806,18 +6974,18 @@ class DiagramCanvas {
6806
6974
  this.model = new DiagramModel(this, undefined, config.name || 'unnamed', '', config.type || '', config.properties || []);
6807
6975
  this.userSelection = new DiagramUserSelection(this);
6808
6976
  this.userHighlight = new DiagramUserHighlight(this);
6809
- this.contextMenu = new DiagramContextMenu(this, (_a = config.canvas) === null || _a === undefined ? undefined : _a.contextMenu);
6810
- this.backgroundColor = ((_b = config.canvas) === null || _b === undefined ? undefined : _b.backgroundColor) || '#FFFFFF';
6811
- 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;
6812
- 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);
6813
- this.gridThickness = Math.abs(((_m = (_l = config.canvas) === null || _l === undefined ? undefined : _l.grid) === null || _m === undefined ? undefined : _m.thickness) || GRID_DEFAULTS.thickness);
6814
- this.gridColor = ((_p = (_o = config.canvas) === null || _o === undefined ? undefined : _o.grid) === null || _p === undefined ? undefined : _p.color) || GRID_DEFAULTS.color;
6815
- 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;
6816
- this.zoomFactor = ((_v = config.canvas) === null || _v === undefined ? undefined : _v.zoomFactor) || 2;
6817
- this.panRate = ((_w = config.canvas) === null || _w === undefined ? undefined : _w.panRate) || 100;
6977
+ this.contextMenu = new DiagramContextMenu(this, (_a = config.canvas) === null || _a === void 0 ? void 0 : _a.contextMenu);
6978
+ this.backgroundColor = ((_b = config.canvas) === null || _b === void 0 ? void 0 : _b.backgroundColor) || '#FFFFFF';
6979
+ 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;
6980
+ 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);
6981
+ 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);
6982
+ 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;
6983
+ 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;
6984
+ this.zoomFactor = ((_v = config.canvas) === null || _v === void 0 ? void 0 : _v.zoomFactor) || 2;
6985
+ this.panRate = ((_w = config.canvas) === null || _w === void 0 ? void 0 : _w.panRate) || 100;
6818
6986
  this.inferConnectionType = config.inferConnectionType || false;
6819
6987
  this.multipleSelectionOn = false;
6820
- this.priorityThresholds = ((_x = config.canvas) === null || _x === undefined ? undefined : _x.priorityThresholds) || [];
6988
+ this.priorityThresholds = ((_x = config.canvas) === null || _x === void 0 ? void 0 : _x.priorityThresholds) || [];
6821
6989
  this.priorityThreshold = this.priorityThresholds ? this.priorityThresholds[0] : undefined;
6822
6990
  this.layoutFormat = config.layoutFormat;
6823
6991
  this.userActions = config.userActions || {};
@@ -6868,7 +7036,7 @@ class DiagramCanvas {
6868
7036
  for (const node of this.model.nodes) {
6869
7037
  this.fitNodeInView(node.id);
6870
7038
  }
6871
- (_b = (_a = this.parentComponent) === null || _a === undefined ? undefined : _a.palette) === null || _b === undefined ? undefined : _b.refreshPalette();
7039
+ (_b = (_a = this.parentComponent) === null || _a === void 0 ? void 0 : _a.palette) === null || _b === void 0 ? void 0 : _b.refreshPalette();
6872
7040
  }
6873
7041
  // View methods
6874
7042
  initView(appendTo) {
@@ -6882,7 +7050,7 @@ class DiagramCanvas {
6882
7050
  var _a;
6883
7051
  // focus on the diagram when clicking so that we can focus on the diagram
6884
7052
  // keyboard events only work if we're focusing on the diagram
6885
- (_a = d3__namespace.select(this.diagramRoot).node()) === null || _a === undefined ? undefined : _a.focus();
7053
+ (_a = d3__namespace.select(this.diagramRoot).node()) === null || _a === void 0 ? void 0 : _a.focus();
6886
7054
  }).on(exports.Events.ContextMenu, event => {
6887
7055
  if (this.dragging) {
6888
7056
  event.preventDefault();
@@ -7022,6 +7190,32 @@ class DiagramCanvas {
7022
7190
  }
7023
7191
  });
7024
7192
  const canvasView = this.selectSVGElement().append('g').attr('class', 'daga-canvas-view').attr('width', `100%`).attr('height', `100%`);
7193
+ canvasView.call(this.zoomBehavior = d3__namespace.zoom().on(exports.ZoomEvents.Zoom, event => {
7194
+ if (event.sourceEvent) {
7195
+ // zoom event was triggered by user
7196
+ if (!this.canUserPerformAction(exports.DiagramActions.Zoom)) {
7197
+ setCursorStyle(exports.CursorStyle.NotAllowed);
7198
+ return;
7199
+ }
7200
+ if (event.sourceEvent.type === exports.Events.Wheel && event.sourceEvent.wheelDelta !== undefined) {
7201
+ if (event.sourceEvent.wheelDelta > 0) {
7202
+ setCursorStyle(exports.CursorStyle.ZoomIn);
7203
+ }
7204
+ if (event.sourceEvent.wheelDelta < 0) {
7205
+ setCursorStyle(exports.CursorStyle.ZoomOut);
7206
+ }
7207
+ } else if (event.sourceEvent.type === exports.Events.MouseMove) {
7208
+ setCursorStyle(exports.CursorStyle.AllScroll);
7209
+ }
7210
+ }
7211
+ this.zoomTransform = event.transform;
7212
+ const transformAttribute = event.transform.toString();
7213
+ this.selectCanvasElements().attr('transform', transformAttribute);
7214
+ d3__namespace.select(`#${this.backgroundPatternId}`).attr('patternTransform', transformAttribute);
7215
+ this.contextMenu.close();
7216
+ }).on(exports.ZoomEvents.End, () => {
7217
+ setCursorStyle();
7218
+ }));
7025
7219
  canvasView.append('rect').attr('x', 0).attr('y', 0).attr('width', `100%`).attr('height', `100%`).attr('fill', this.backgroundColor).attr('stroke-width', '0').on(exports.Events.MouseMove, event => {
7026
7220
  if (this.unfinishedConnection !== undefined) {
7027
7221
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
@@ -7052,60 +7246,35 @@ class DiagramCanvas {
7052
7246
  this.continueMultipleSelection(event);
7053
7247
  }).on(exports.DragEvents.End, event => {
7054
7248
  this.finishMultipleSelection(event);
7055
- })).call(this.zoomBehavior = d3__namespace.zoom().on(exports.ZoomEvents.Zoom, event => {
7056
- if (event.sourceEvent) {
7057
- // zoom event was triggered by user
7058
- if (!this.canUserPerformAction(exports.DiagramActions.Zoom)) {
7059
- setCursorStyle(exports.CursorStyle.NotAllowed);
7060
- return;
7061
- }
7062
- if (event.sourceEvent.type === exports.Events.Wheel && event.sourceEvent.wheelDelta !== undefined) {
7063
- if (event.sourceEvent.wheelDelta > 0) {
7064
- setCursorStyle(exports.CursorStyle.ZoomIn);
7065
- }
7066
- if (event.sourceEvent.wheelDelta < 0) {
7067
- setCursorStyle(exports.CursorStyle.ZoomOut);
7068
- }
7069
- } else if (event.sourceEvent.type === exports.Events.MouseMove) {
7070
- setCursorStyle(exports.CursorStyle.AllScroll);
7071
- }
7072
- }
7073
- this.zoomTransform = event.transform;
7074
- const transformAttribute = event.transform.toString();
7075
- this.selectCanvasElements().attr('transform', transformAttribute);
7076
- d3__namespace.select(`#${this.backgroundPatternId}`).attr('patternTransform', transformAttribute);
7077
- this.contextMenu.close();
7078
- }).on(exports.ZoomEvents.End, () => {
7079
- setCursorStyle();
7080
7249
  }));
7081
7250
  initializeGrid(this, canvasView, this.backgroundPatternId);
7082
7251
  canvasView.append('g').attr('class', 'daga-canvas-elements');
7083
7252
  }
7084
7253
  zoomBy(factor) {
7085
7254
  if (!isNaN(factor)) {
7086
- this.zoomBehavior.scaleBy(this.selectCanvasView().select('rect'), factor);
7255
+ this.zoomBehavior.scaleBy(this.selectCanvasView(), factor);
7087
7256
  }
7088
7257
  }
7089
7258
  zoomTo(level) {
7090
7259
  if (!isNaN(level)) {
7091
- this.zoomBehavior.scaleTo(this.selectCanvasView().select('rect'), level);
7260
+ this.zoomBehavior.scaleTo(this.selectCanvasView(), level);
7092
7261
  }
7093
7262
  }
7094
7263
  translateBy(x, y) {
7095
7264
  if (!isNaN(x) && !isNaN(y)) {
7096
- this.zoomBehavior.translateBy(this.selectCanvasView().select('rect'), x, y);
7265
+ this.zoomBehavior.translateBy(this.selectCanvasView(), x, y);
7097
7266
  }
7098
7267
  }
7099
7268
  translateTo(x, y) {
7100
7269
  if (!isNaN(x) && !isNaN(y)) {
7101
- this.zoomBehavior.translateTo(this.selectCanvasView().select('rect'), x, y);
7270
+ this.zoomBehavior.translateTo(this.selectCanvasView(), x, y);
7102
7271
  }
7103
7272
  }
7104
7273
  center() {
7105
7274
  var _a;
7106
7275
  // if there are no nodes, we have nothing to do here
7107
7276
  if (this.model.nodes.length > 0) {
7108
- const canvasViewBoundingBox = (_a = this.selectCanvasView().select('rect').node()) === null || _a === undefined ? undefined : _a.getBBox();
7277
+ const canvasViewBoundingBox = (_a = this.selectCanvasView().select('rect').node()) === null || _a === void 0 ? void 0 : _a.getBBox();
7109
7278
  const nonRemovedNodes = this.model.nodes.all();
7110
7279
  const minimumX = Math.min(...nonRemovedNodes.map(n => n.coords[0]));
7111
7280
  const maximumX = Math.max(...nonRemovedNodes.map(n => n.coords[0] + n.width));
@@ -7137,8 +7306,8 @@ class DiagramCanvas {
7137
7306
  }
7138
7307
  getCoordinatesOnScreen() {
7139
7308
  var _a;
7140
- const rootBoundingClientRect = (_a = this.selectSVGElement().node()) === null || _a === undefined ? undefined : _a.getBoundingClientRect();
7141
- const rootDimensions = [(rootBoundingClientRect === null || rootBoundingClientRect === undefined ? undefined : rootBoundingClientRect.width) || 0, (rootBoundingClientRect === null || rootBoundingClientRect === undefined ? undefined : rootBoundingClientRect.height) || 0];
7309
+ const rootBoundingClientRect = (_a = this.selectSVGElement().node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
7310
+ const rootDimensions = [(rootBoundingClientRect === null || rootBoundingClientRect === void 0 ? void 0 : rootBoundingClientRect.width) || 0, (rootBoundingClientRect === null || rootBoundingClientRect === void 0 ? void 0 : rootBoundingClientRect.height) || 0];
7142
7311
  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]];
7143
7312
  }
7144
7313
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -7392,8 +7561,8 @@ class DiagramCanvas {
7392
7561
  let updateSelection = this.selectCanvasElements().selectAll('g.diagram-section').data(this.model.sections.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
7393
7562
  const exitSelection = updateSelection.exit();
7394
7563
  const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => {
7395
- var _a, _b, _c, _d, _e;
7396
- 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}`;
7564
+ var _a;
7565
+ return `diagram-section${d.getResizableX() ? ' resizable-x' : ''}${d.getResizableY() ? ' resizable-y' : ''} ${(_a = d.look) === null || _a === void 0 ? void 0 : _a.lookType}`;
7397
7566
  });
7398
7567
  if (ids && ids.length > 0) {
7399
7568
  updateSelection = updateSelection.filter(d => ids.includes(d.id));
@@ -7442,7 +7611,7 @@ class DiagramCanvas {
7442
7611
  if (this.multipleSelectionOn || this.secondaryButton) {
7443
7612
  this.startMultipleSelection(event);
7444
7613
  } else {
7445
- const node = d === null || d === undefined ? undefined : d.node;
7614
+ const node = d === null || d === void 0 ? void 0 : d.node;
7446
7615
  if (node) {
7447
7616
  this.startMovingNode(event, node);
7448
7617
  } else {
@@ -7453,7 +7622,7 @@ class DiagramCanvas {
7453
7622
  if (this.multipleSelectionOn || this.secondaryButton) {
7454
7623
  this.continueMultipleSelection(event);
7455
7624
  } else {
7456
- const node = d === null || d === undefined ? undefined : d.node;
7625
+ const node = d === null || d === void 0 ? void 0 : d.node;
7457
7626
  if (node) {
7458
7627
  this.continueMovingNode(event, node);
7459
7628
  } else {
@@ -7464,7 +7633,7 @@ class DiagramCanvas {
7464
7633
  if (this.multipleSelectionOn || this.secondaryButton) {
7465
7634
  this.finishMultipleSelection(event);
7466
7635
  } else {
7467
- const node = d === null || d === undefined ? undefined : d.node;
7636
+ const node = d === null || d === void 0 ? void 0 : d.node;
7468
7637
  if (node) {
7469
7638
  this.finishMovingNode(event, node);
7470
7639
  } else {
@@ -7475,32 +7644,27 @@ class DiagramCanvas {
7475
7644
  }));
7476
7645
  initializeLook(enterSelection);
7477
7646
  enterSelection.filter('.resizable-x').append('line').attr('class', 'left-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(exports.Events.MouseOver, (_event, d) => {
7478
- var _a, _b;
7479
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7647
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
7480
7648
  setCursorStyle(exports.CursorStyle.EWResize);
7481
7649
  }
7482
7650
  }).on(exports.Events.MouseOut, (_event, d) => {
7483
- var _a, _b;
7484
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7651
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
7485
7652
  setCursorStyle();
7486
7653
  }
7487
7654
  }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
7488
- var _a, _b;
7489
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7655
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
7490
7656
  setCursorStyle(exports.CursorStyle.EWResize);
7491
7657
  this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
7492
7658
  } else {
7493
7659
  setCursorStyle(exports.CursorStyle.NotAllowed);
7494
7660
  }
7495
7661
  }).on(exports.DragEvents.Drag, (event, d) => {
7496
- var _a, _b;
7497
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7662
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
7498
7663
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7499
7664
  d.node.stretchSections(exports.Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
7500
7665
  }
7501
7666
  }).on(exports.DragEvents.End, (event, d) => {
7502
- var _a, _b;
7503
- if (this.canUserPerformAction(exports.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 === exports.DiagramActions.StretchSection) {
7667
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
7504
7668
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7505
7669
  if (this.snapToGrid) {
7506
7670
  pointerCoords = this.getClosestGridPoint(pointerCoords);
@@ -7514,32 +7678,27 @@ class DiagramCanvas {
7514
7678
  setCursorStyle();
7515
7679
  }));
7516
7680
  enterSelection.filter('.resizable-y').append('line').attr('class', 'top-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(exports.Events.MouseOver, (_event, d) => {
7517
- var _a, _b;
7518
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7681
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
7519
7682
  setCursorStyle(exports.CursorStyle.NSResize);
7520
7683
  }
7521
7684
  }).on(exports.Events.MouseOut, (_event, d) => {
7522
- var _a, _b;
7523
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7685
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
7524
7686
  setCursorStyle();
7525
7687
  }
7526
7688
  }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
7527
- var _a, _b;
7528
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7689
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
7529
7690
  setCursorStyle(exports.CursorStyle.NSResize);
7530
7691
  this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
7531
7692
  } else {
7532
7693
  setCursorStyle(exports.CursorStyle.NotAllowed);
7533
7694
  }
7534
7695
  }).on(exports.DragEvents.Drag, (event, d) => {
7535
- var _a, _b;
7536
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7696
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
7537
7697
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7538
7698
  d.node.stretchSections(exports.Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
7539
7699
  }
7540
7700
  }).on(exports.DragEvents.End, (event, d) => {
7541
- var _a, _b;
7542
- if (this.canUserPerformAction(exports.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 === exports.DiagramActions.StretchSection) {
7701
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
7543
7702
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7544
7703
  if (this.snapToGrid) {
7545
7704
  pointerCoords = this.getClosestGridPoint(pointerCoords);
@@ -7553,32 +7712,27 @@ class DiagramCanvas {
7553
7712
  setCursorStyle();
7554
7713
  }));
7555
7714
  enterSelection.filter('.resizable-x').append('line').attr('class', 'right-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(exports.Events.MouseOver, (_event, d) => {
7556
- var _a, _b;
7557
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7715
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
7558
7716
  setCursorStyle(exports.CursorStyle.EWResize);
7559
7717
  }
7560
7718
  }).on(exports.Events.MouseOut, (_event, d) => {
7561
- var _a, _b;
7562
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7719
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
7563
7720
  setCursorStyle();
7564
7721
  }
7565
7722
  }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
7566
- var _a, _b;
7567
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7723
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
7568
7724
  setCursorStyle(exports.CursorStyle.EWResize);
7569
7725
  this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
7570
7726
  } else {
7571
7727
  setCursorStyle(exports.CursorStyle.NotAllowed);
7572
7728
  }
7573
7729
  }).on(exports.DragEvents.Drag, (event, d) => {
7574
- var _a, _b;
7575
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7730
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
7576
7731
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7577
7732
  d.node.stretchSections(exports.Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
7578
7733
  }
7579
7734
  }).on(exports.DragEvents.End, (event, d) => {
7580
- var _a, _b;
7581
- if (this.canUserPerformAction(exports.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 === exports.DiagramActions.StretchSection) {
7735
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
7582
7736
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7583
7737
  if (this.snapToGrid) {
7584
7738
  pointerCoords = this.getClosestGridPoint(pointerCoords);
@@ -7592,32 +7746,27 @@ class DiagramCanvas {
7592
7746
  setCursorStyle();
7593
7747
  }));
7594
7748
  enterSelection.filter('.resizable-y').append('line').attr('class', 'bottom-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(exports.Events.MouseOver, (_event, d) => {
7595
- var _a, _b;
7596
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7749
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
7597
7750
  setCursorStyle(exports.CursorStyle.NSResize);
7598
7751
  }
7599
7752
  }).on(exports.Events.MouseOut, (_event, d) => {
7600
- var _a, _b;
7601
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7753
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
7602
7754
  setCursorStyle();
7603
7755
  }
7604
7756
  }).call(d3__namespace.drag().on(exports.DragEvents.Start, (_event, d) => {
7605
- var _a, _b;
7606
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7757
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
7607
7758
  setCursorStyle(exports.CursorStyle.NSResize);
7608
7759
  this.currentAction = new SetGeometryAction(this, exports.DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
7609
7760
  } else {
7610
7761
  setCursorStyle(exports.CursorStyle.NotAllowed);
7611
7762
  }
7612
7763
  }).on(exports.DragEvents.Drag, (event, d) => {
7613
- var _a, _b;
7614
- if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7764
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
7615
7765
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7616
7766
  d.node.stretchSections(exports.Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
7617
7767
  }
7618
7768
  }).on(exports.DragEvents.End, (event, d) => {
7619
- var _a, _b;
7620
- if (this.canUserPerformAction(exports.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 === exports.DiagramActions.StretchSection) {
7769
+ if (this.canUserPerformAction(exports.DiagramActions.StretchSection) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === exports.DiagramActions.StretchSection && d.node) {
7621
7770
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7622
7771
  if (this.snapToGrid) {
7623
7772
  pointerCoords = this.getClosestGridPoint(pointerCoords);
@@ -7656,13 +7805,13 @@ class DiagramCanvas {
7656
7805
  if (this.unfinishedConnection) {
7657
7806
  const canConnectionFinishAtThisPort =
7658
7807
  // can start at the starting port
7659
- 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) &&
7808
+ 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) &&
7660
7809
  // can end at the ending port
7661
- this.unfinishedConnection.type.canFinishOnType(((_f = (_e = d.getNode()) === null || _e === undefined ? undefined : _e.type) === null || _f === undefined ? undefined : _f.id) || '') && d.allowsIncoming ||
7810
+ 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 ||
7662
7811
  // can start at the ending port
7663
- this.unfinishedConnection.type.canStartFromType(((_h = (_g = d.getNode()) === null || _g === undefined ? undefined : _g.type) === null || _h === undefined ? undefined : _h.id) || '') && d.allowsOutgoing &&
7812
+ 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 &&
7664
7813
  // can end at the starting port
7665
- 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);
7814
+ 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);
7666
7815
  if (!canConnectionFinishAtThisPort) {
7667
7816
  setCursorStyle(exports.CursorStyle.NoDrop);
7668
7817
  }
@@ -7727,8 +7876,8 @@ class DiagramCanvas {
7727
7876
  if (this.canUserPerformAction(exports.DiagramActions.AddConnection) && !d.removed) {
7728
7877
  if (this.unfinishedConnection !== undefined) {
7729
7878
  const endCoords = [event.x, event.y];
7730
- (_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));
7731
- const unfinishedConnectionGhostNode = (_d = this.unfinishedConnectionTracer) === null || _d === undefined ? undefined : _d.node();
7879
+ (_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));
7880
+ const unfinishedConnectionGhostNode = (_d = this.unfinishedConnectionTracer) === null || _d === void 0 ? void 0 : _d.node();
7732
7881
  if (unfinishedConnectionGhostNode) {
7733
7882
  let margin = 2;
7734
7883
  const unfinishedConnectionTotalLength = unfinishedConnectionGhostNode.getTotalLength();
@@ -7769,7 +7918,7 @@ class DiagramCanvas {
7769
7918
  this.finishMultipleSelection(event);
7770
7919
  } else {
7771
7920
  if (this.canUserPerformAction(exports.DiagramActions.AddConnection) && !d.removed) {
7772
- (_a = this.unfinishedConnectionTracer) === null || _a === undefined ? undefined : _a.remove();
7921
+ (_a = this.unfinishedConnectionTracer) === null || _a === void 0 ? void 0 : _a.remove();
7773
7922
  const userHighlight = this.userHighlight.getFocus();
7774
7923
  if (userHighlight instanceof DiagramPort) {
7775
7924
  this.finishConnection(userHighlight);
@@ -7875,11 +8024,11 @@ class DiagramCanvas {
7875
8024
  enterSelection.select('g.diagram-connection-end-label').append('text').style('user-select', 'none');
7876
8025
  mergeSelection.attr('opacity', d => d.removed ? 0.5 : 1).select('path.diagram-connection-path').attr('d', d => {
7877
8026
  var _a, _b;
7878
- 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);
8027
+ 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);
7879
8028
  }).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');
7880
8029
  mergeSelection.select('path.diagram-connection-path-box').attr('d', d => {
7881
8030
  var _a, _b;
7882
- 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);
8031
+ 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);
7883
8032
  }).attr('stroke', 'transparent')
7884
8033
  // allow generating pointer events even when it is transparent
7885
8034
  .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');
@@ -7934,8 +8083,12 @@ class DiagramCanvas {
7934
8083
  this.diagramEvent$.next(diagramEvent);
7935
8084
  if (!diagramEvent.defaultPrevented && this.canUserPerformAction(exports.DiagramActions.EditField) && d.editable && !d.removed) {
7936
8085
  this.currentAction = new EditFieldAction(this, d.id, d.text, '');
7937
- this.createInputField(d.text, d.coords, d.width, d.height, d.fontSize, d.fontFamily || DIAGRAM_FIELD_DEFAULTS.fontFamily, text => {
7938
- d.text = text;
8086
+ this.createInputField(d.text, d.coords, d.width, d.height, d.fontSize, d.fontFamily || DIAGRAM_FIELD_DEFAULTS.fontFamily, d.orientation, _text => {
8087
+ /*
8088
+ Empty for now
8089
+ We should create a better function to stretch the root element as the text expands
8090
+ Bear in mind that DiagramNode.setGeometry() calls DiagramNode.raise(), which breaks the input field
8091
+ */
7939
8092
  }, text => {
7940
8093
  d.text = text;
7941
8094
  if (this.currentAction instanceof EditFieldAction) {
@@ -7999,7 +8152,7 @@ class DiagramCanvas {
7999
8152
  }
8000
8153
  this.secondaryButton = false;
8001
8154
  })).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');
8002
- 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 === exports.HorizontalAlign.Center ? 'center' : d.horizontalAlign === exports.HorizontalAlign.Right ? 'flex-end' : 'flex-start').style('align-items', d => d.verticalAlign === exports.VerticalAlign.Center ? 'center' : d.verticalAlign === exports.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 === exports.HorizontalAlign.Center ? 'center' : d.horizontalAlign === exports.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/>'));
8155
+ 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 === exports.HorizontalAlign.Center ? 'center' : d.horizontalAlign === exports.HorizontalAlign.Right ? 'flex-end' : 'flex-start').style('align-items', d => d.verticalAlign === exports.VerticalAlign.Center ? 'center' : d.verticalAlign === exports.VerticalAlign.Bottom ? 'end' : 'start').select('p').style('max-width', d => d.fit ? 'default' : `${unrotate(d.width, d.height, d.orientation)[0]}px`).style('max-height', d => d.fit ? 'default' : `${unrotate(d.width, d.height, d.orientation)[1]}px`).style('overflow', d => d.fit ? 'default' : 'clip').style('text-overflow', d => d.fit ? 'default' : 'ellipsis').style('text-align', d => d.horizontalAlign === exports.HorizontalAlign.Center ? 'center' : d.horizontalAlign === exports.HorizontalAlign.Right ? 'end' : 'start').style('transform', d => `rotate(${d.orientation}deg)`).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/>'));
8003
8156
  }
8004
8157
  updateObjectsInView(...ids) {
8005
8158
  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);
@@ -8157,7 +8310,7 @@ class DiagramCanvas {
8157
8310
  const pathLength = pathNode.getTotalLength();
8158
8311
  // bind start labels
8159
8312
  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);
8160
- const startLabelBoundingRect = (_a = connectionSelection.select('g.diagram-connection-start-label text').node()) === null || _a === undefined ? undefined : _a.getBoundingClientRect();
8313
+ const startLabelBoundingRect = (_a = connectionSelection.select('g.diagram-connection-start-label text').node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
8161
8314
  if (startLabelBoundingRect) {
8162
8315
  // don't create space for the label if the label is empty
8163
8316
  const boundingWidth = !connection.startLabel ? 0 : startLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
@@ -8168,7 +8321,7 @@ class DiagramCanvas {
8168
8321
  }
8169
8322
  // bind middle labels
8170
8323
  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);
8171
- const middleLabelBoundingRect = (_b = connectionSelection.select('g.diagram-connection-middle-label text').node()) === null || _b === undefined ? undefined : _b.getBoundingClientRect();
8324
+ const middleLabelBoundingRect = (_b = connectionSelection.select('g.diagram-connection-middle-label text').node()) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
8172
8325
  if (middleLabelBoundingRect) {
8173
8326
  // don't create space for the label if the label is empty
8174
8327
  const boundingWidth = !connection.middleLabel ? 0 : middleLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
@@ -8179,7 +8332,7 @@ class DiagramCanvas {
8179
8332
  }
8180
8333
  // bind end labels
8181
8334
  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);
8182
- const endLabelBoundingRect = (_c = connectionSelection.select('g.diagram-connection-end-label text').node()) === null || _c === undefined ? undefined : _c.getBoundingClientRect();
8335
+ const endLabelBoundingRect = (_c = connectionSelection.select('g.diagram-connection-end-label text').node()) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect();
8183
8336
  if (endLabelBoundingRect) {
8184
8337
  // don't create space for the label if the label is empty
8185
8338
  const boundingWidth = !connection.endLabel ? 0 : endLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
@@ -8213,13 +8366,13 @@ class DiagramCanvas {
8213
8366
  }
8214
8367
  if (field.rootElement instanceof DiagramNode || field.rootElement instanceof DiagramSection) {
8215
8368
  const fieldDimensions = this.minimumSizeOfField(field);
8216
- const stretchX = fieldDimensions[0] + getLeftMargin((_a = field.rootElement.type) === null || _a === undefined ? undefined : _a.label) + getRightMargin((_b = field.rootElement.type) === null || _b === undefined ? undefined : _b.label) - field.rootElement.width;
8217
- const stretchY = fieldDimensions[1] + getTopMargin((_c = field.rootElement.type) === null || _c === undefined ? undefined : _c.label) + getBottomMargin((_d = field.rootElement.type) === null || _d === undefined ? undefined : _d.label) - field.rootElement.height;
8369
+ 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;
8370
+ 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;
8218
8371
  return stretchX <= 0 && stretchY <= 0;
8219
8372
  }
8220
8373
  return true;
8221
8374
  }
8222
- fitFieldRootInView(id, shrink) {
8375
+ fitFieldRootInView(id, shrink = true) {
8223
8376
  var _a, _b, _c;
8224
8377
  const field = this.model.fields.get(id);
8225
8378
  if (!field) {
@@ -8251,7 +8404,7 @@ class DiagramCanvas {
8251
8404
  const fieldDimensions = this.minimumSizeOfField(field);
8252
8405
  let minimumFieldWidth = fieldDimensions[0];
8253
8406
  let minimumFieldHeight = fieldDimensions[1];
8254
- for (const section of ((_a = field.rootElement.node) === null || _a === undefined ? undefined : _a.sections) || []) {
8407
+ for (const section of ((_a = field.rootElement.node) === null || _a === void 0 ? void 0 : _a.sections) || []) {
8255
8408
  if (section.label) {
8256
8409
  if (section.indexXInNode === field.rootElement.indexXInNode && section.indexYInNode !== field.rootElement.indexYInNode) {
8257
8410
  minimumFieldWidth = Math.max(minimumFieldWidth, this.minimumSizeOfField(section.label)[0]);
@@ -8267,8 +8420,8 @@ class DiagramCanvas {
8267
8420
  fieldDimensions[1] = minimumFieldHeight;
8268
8421
  }
8269
8422
  const type = field.rootElement.type;
8270
- let stretchX = fieldDimensions[0] + getLeftMargin(type === null || type === undefined ? undefined : type.label) + getRightMargin(type === null || type === undefined ? undefined : type.label) - field.rootElement.width;
8271
- let stretchY = fieldDimensions[1] + getTopMargin(type === null || type === undefined ? undefined : type.label) + getBottomMargin(type === null || type === undefined ? undefined : type.label) - field.rootElement.height;
8423
+ 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;
8424
+ 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;
8272
8425
  if (this.snapToGrid) {
8273
8426
  stretchX = Math.ceil(stretchX / this.gridSize) * this.gridSize;
8274
8427
  stretchY = Math.ceil(stretchY / this.gridSize) * this.gridSize;
@@ -8280,15 +8433,15 @@ class DiagramCanvas {
8280
8433
  if (field.rootElement.height + stretchY < (field.rootElement.getMinHeight() || 0)) {
8281
8434
  stretchY = (field.rootElement.getMinHeight() || 0) - field.rootElement.height;
8282
8435
  }
8283
- if (shrink !== false || stretchX > 0) {
8284
- (_b = field.rootElement.node) === null || _b === undefined ? undefined : _b.stretchSections(exports.Side.Right, stretchX, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
8436
+ if (shrink || stretchX > 0) {
8437
+ (_b = field.rootElement.node) === null || _b === void 0 ? void 0 : _b.stretchSections(exports.Side.Right, stretchX, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
8285
8438
  }
8286
- if (shrink !== false || stretchY > 0) {
8287
- (_c = field.rootElement.node) === null || _c === undefined ? undefined : _c.stretchSections(exports.Side.Bottom, stretchY, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
8439
+ if (shrink || stretchY > 0) {
8440
+ (_c = field.rootElement.node) === null || _c === void 0 ? void 0 : _c.stretchSections(exports.Side.Bottom, stretchY, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
8288
8441
  }
8289
8442
  }
8290
8443
  }
8291
- fitNodeInView(id) {
8444
+ fitNodeInView(id, shrink = true) {
8292
8445
  var _a, _b;
8293
8446
  const node = this.model.nodes.get(id);
8294
8447
  if (!node) {
@@ -8307,10 +8460,14 @@ class DiagramCanvas {
8307
8460
  }
8308
8461
  }
8309
8462
  // add the margin that goes between the rightmost and bottommost points of the sections and the edge of the node
8310
- newNodeWidth += ((_a = node.type.sectionGrid) === null || _a === undefined ? undefined : _a.margin) || 0;
8311
- newNodeHeight += ((_b = node.type.sectionGrid) === null || _b === undefined ? undefined : _b.margin) || 0;
8312
- node.stretch(exports.Side.Right, newNodeWidth - node.width);
8313
- node.stretch(exports.Side.Bottom, newNodeHeight - node.height);
8463
+ newNodeWidth += ((_a = node.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
8464
+ newNodeHeight += ((_b = node.type.sectionGrid) === null || _b === void 0 ? void 0 : _b.margin) || 0;
8465
+ if (shrink || newNodeWidth > node.width) {
8466
+ node.stretch(exports.Side.Right, newNodeWidth - node.width);
8467
+ }
8468
+ if (shrink || newNodeHeight > node.height) {
8469
+ node.stretch(exports.Side.Bottom, newNodeHeight - node.height);
8470
+ }
8314
8471
  }
8315
8472
  }
8316
8473
  selectRoot() {
@@ -8329,18 +8486,18 @@ class DiagramCanvas {
8329
8486
  startConnection(port) {
8330
8487
  var _a, _b, _c, _d;
8331
8488
  if (port.allowsOutgoing || port.allowsIncoming) {
8332
- 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)) {
8489
+ 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)) {
8333
8490
  this.unfinishedConnection = new DiagramConnection(this.model, this.connectionType, port, undefined, UNFINISHED_CONNECTION_ID);
8334
8491
  } else {
8335
8492
  if (this.inferConnectionType) {
8336
8493
  let differentConnectionType = this.model.connections.types.all().find(t => {
8337
8494
  var _a, _b;
8338
- return port.allowsOutgoing && t.canStartFromType(((_b = (_a = port.getNode()) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.id) || '');
8495
+ 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) || '');
8339
8496
  });
8340
8497
  if (differentConnectionType === undefined) {
8341
8498
  differentConnectionType = this.model.connections.types.all().find(t => {
8342
8499
  var _a, _b;
8343
- return port.allowsIncoming && t.canFinishOnType(((_b = (_a = port.getNode()) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.id) || '');
8500
+ 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) || '');
8344
8501
  });
8345
8502
  }
8346
8503
  if (differentConnectionType !== undefined) {
@@ -8355,14 +8512,14 @@ class DiagramCanvas {
8355
8512
  this.userHighlight.clear();
8356
8513
  if (this.unfinishedConnection !== undefined) {
8357
8514
  if (this.unfinishedConnection.start !== port) {
8358
- 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) {
8359
- const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, (_j = this.unfinishedConnection.start) === null || _j === undefined ? undefined : _j.id, port.id);
8515
+ 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) {
8516
+ const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, (_j = this.unfinishedConnection.start) === null || _j === void 0 ? void 0 : _j.id, port.id);
8360
8517
  // clean up the previous unfinished connection
8361
8518
  this.dropConnection();
8362
8519
  addConnectionAction.do();
8363
8520
  this.actionStack.add(addConnectionAction);
8364
- } 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) {
8365
- const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, port.id, (_t = this.unfinishedConnection.start) === null || _t === undefined ? undefined : _t.id);
8521
+ } 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) {
8522
+ const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, port.id, (_t = this.unfinishedConnection.start) === null || _t === void 0 ? void 0 : _t.id);
8366
8523
  // clean up the previous unfinished connection
8367
8524
  this.dropConnection();
8368
8525
  addConnectionAction.do();
@@ -8371,18 +8528,18 @@ class DiagramCanvas {
8371
8528
  if (this.inferConnectionType) {
8372
8529
  let differentConnectionType = this.model.connections.types.all().find(t => {
8373
8530
  var _a, _b, _c, _d, _e, _f, _g, _h;
8374
- 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;
8531
+ 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;
8375
8532
  });
8376
8533
  let invertConnection = false;
8377
8534
  if (differentConnectionType === undefined) {
8378
8535
  differentConnectionType = this.model.connections.types.all().find(t => {
8379
8536
  var _a, _b, _c, _d, _e, _f, _g, _h;
8380
- 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;
8537
+ 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;
8381
8538
  });
8382
8539
  invertConnection = true;
8383
8540
  }
8384
8541
  if (differentConnectionType !== undefined) {
8385
- 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);
8542
+ 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);
8386
8543
  // clean up the previous unfinished connection
8387
8544
  this.dropConnection();
8388
8545
  addConnectionAction.do();
@@ -8404,9 +8561,9 @@ class DiagramCanvas {
8404
8561
  }
8405
8562
  dropConnection() {
8406
8563
  var _a, _b, _c, _d;
8407
- (_a = this.unfinishedConnection) === null || _a === undefined ? undefined : _a.setStart(undefined);
8408
- (_b = this.unfinishedConnection) === null || _b === undefined ? undefined : _b.setEnd(undefined);
8409
- (_d = (_c = this.unfinishedConnection) === null || _c === undefined ? undefined : _c.select()) === null || _d === undefined ? undefined : _d.remove();
8564
+ (_a = this.unfinishedConnection) === null || _a === void 0 ? void 0 : _a.setStart(undefined);
8565
+ (_b = this.unfinishedConnection) === null || _b === void 0 ? void 0 : _b.setEnd(undefined);
8566
+ (_d = (_c = this.unfinishedConnection) === null || _c === void 0 ? void 0 : _c.select()) === null || _d === void 0 ? void 0 : _d.remove();
8410
8567
  this.unfinishedConnection = undefined;
8411
8568
  }
8412
8569
  cancelAllUserActions() {
@@ -8419,7 +8576,7 @@ class DiagramCanvas {
8419
8576
  canUserPerformAction(action) {
8420
8577
  return this.userActions[action] !== false;
8421
8578
  }
8422
- createInputField(text, coords, width, height, fontSize, fontFamily, changeCallback, finishCallback) {
8579
+ createInputField(text, coords, width, height, fontSize, fontFamily, orientation, changeCallback, finishCallback) {
8423
8580
  // if we have a text input open, close it before creating a new one
8424
8581
  this.removeInputField();
8425
8582
  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');
@@ -8451,9 +8608,9 @@ class DiagramCanvas {
8451
8608
  // keep the field from shrinking below its original size
8452
8609
  const newWidth = Math.max(inputFieldWidth, width);
8453
8610
  const newHeight = Math.max(inputFieldHeight, height);
8454
- inputFieldContainer === null || inputFieldContainer === undefined ? undefined : inputFieldContainer.attr('width', `${newWidth}px`);
8611
+ inputFieldContainer === null || inputFieldContainer === void 0 ? void 0 : inputFieldContainer.attr('width', `${newWidth}px`);
8455
8612
  inputField.style('width', `${newWidth}px`);
8456
- inputFieldContainer === null || inputFieldContainer === undefined ? undefined : inputFieldContainer.attr('height', `${newHeight}px`);
8613
+ inputFieldContainer === null || inputFieldContainer === void 0 ? void 0 : inputFieldContainer.attr('height', `${newHeight}px`);
8457
8614
  inputField.style('height', `${newHeight}px`);
8458
8615
  if (changeCallback) {
8459
8616
  changeCallback(value);
@@ -8475,13 +8632,13 @@ class DiagramCanvas {
8475
8632
  var _a, _b, _c;
8476
8633
  // when removing an element, a blur event is emitted
8477
8634
  // we remove the listener for blur so that it doesn't shoot again on element removal
8478
- (_b = (_a = this.inputFieldContainer) === null || _a === undefined ? undefined : _a.select('input')) === null || _b === undefined ? undefined : _b.on(exports.Events.Blur, null);
8479
- (_c = this.inputFieldContainer) === null || _c === undefined ? undefined : _c.remove();
8635
+ (_b = (_a = this.inputFieldContainer) === null || _a === void 0 ? void 0 : _a.select('input')) === null || _b === void 0 ? void 0 : _b.on(exports.Events.Blur, null);
8636
+ (_c = this.inputFieldContainer) === null || _c === void 0 ? void 0 : _c.remove();
8480
8637
  this.inputFieldContainer = undefined;
8481
8638
  }
8482
8639
  minimumSizeOfField(field) {
8483
8640
  var _a, _b;
8484
- const pNode = (_b = (_a = field.select()) === null || _a === undefined ? undefined : _a.select('p')) === null || _b === undefined ? undefined : _b.node();
8641
+ const pNode = (_b = (_a = field.select()) === null || _a === void 0 ? void 0 : _a.select('p')) === null || _b === void 0 ? void 0 : _b.node();
8485
8642
  if (!pNode) {
8486
8643
  // happens when a field has been created but not updated in view yet
8487
8644
  return [0, 0];
@@ -8500,7 +8657,7 @@ class DiagramCanvas {
8500
8657
  this.currentAction = new MoveAction(this, this.userSelection.filter(e => e instanceof DiagramNode).map(n => n.id), d.coords);
8501
8658
  } else {
8502
8659
  const ancestorOfNode = d.getLastAncestor();
8503
- this.currentAction = new SetGeometryAction(this, exports.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));
8660
+ this.currentAction = new SetGeometryAction(this, exports.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));
8504
8661
  }
8505
8662
  } else {
8506
8663
  setCursorStyle(exports.CursorStyle.NotAllowed);
@@ -8553,23 +8710,23 @@ class DiagramCanvas {
8553
8710
  const filteredNodesAtLocation = filterByOnlyDescendants(nodesAtLocationWhichCanHaveNodeAsAChild);
8554
8711
  const droppedOn = filteredNodesAtLocation[filteredNodesAtLocation.length - 1];
8555
8712
  if (droppedOn !== d.parent && (d.type.canBeParentless || droppedOn !== undefined)) {
8556
- const ancestorOfDroppedOn = droppedOn === null || droppedOn === undefined ? undefined : droppedOn.getLastAncestor();
8713
+ const ancestorOfDroppedOn = droppedOn === null || droppedOn === void 0 ? void 0 : droppedOn.getLastAncestor();
8557
8714
  const fromChildGeometry = this.currentAction.from;
8558
- 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));
8559
- (_b = d.parent) === null || _b === undefined ? undefined : _b.removeChild(d);
8715
+ 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));
8716
+ (_b = d.parent) === null || _b === void 0 ? void 0 : _b.removeChild(d);
8560
8717
  if (droppedOn !== undefined) {
8561
8718
  droppedOn.addChild(d);
8562
8719
  }
8563
8720
  setParentAction.toChildGeometry = d.getGeometry(d.id);
8564
- setParentAction.toAncestorGeometry = ancestorOfDroppedOn === null || ancestorOfDroppedOn === undefined ? undefined : ancestorOfDroppedOn.getGeometry(d.id);
8721
+ setParentAction.toAncestorGeometry = ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id);
8565
8722
  this.currentAction = setParentAction;
8566
8723
  } else {
8567
- const ancestorOfNode = d === null || d === undefined ? undefined : d.getLastAncestor();
8568
- this.currentAction.ancestorId = ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.id;
8569
- this.currentAction.fromAncestorGeometry = ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.getGeometry(d.id);
8570
- (_c = d.parent) === null || _c === undefined ? undefined : _c.fitToChild(d);
8724
+ const ancestorOfNode = d === null || d === void 0 ? void 0 : d.getLastAncestor();
8725
+ this.currentAction.ancestorId = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.id;
8726
+ this.currentAction.fromAncestorGeometry = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id);
8727
+ (_c = d.parent) === null || _c === void 0 ? void 0 : _c.fitToChild(d);
8571
8728
  this.currentAction.to = d.getGeometry(d.id);
8572
- this.currentAction.toAncestorGeometry = ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.getGeometry(d.id);
8729
+ this.currentAction.toAncestorGeometry = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id);
8573
8730
  }
8574
8731
  }
8575
8732
  if (this.currentAction !== undefined) {
@@ -8595,14 +8752,14 @@ class DiagramCanvas {
8595
8752
  setCursorStyle(exports.CursorStyle.Crosshair);
8596
8753
  // since the multiple selection rectangle is not affected by zoom,
8597
8754
  // we compensate its coordinates based in the zoom transform to draw it
8598
- (_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);
8755
+ (_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);
8599
8756
  this.dragging = true;
8600
8757
  }
8601
8758
  }
8602
8759
  finishMultipleSelection(event) {
8603
8760
  var _a;
8604
8761
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8605
- (_a = this.multipleSelectionContainer) === null || _a === undefined ? undefined : _a.remove();
8762
+ (_a = this.multipleSelectionContainer) === null || _a === void 0 ? void 0 : _a.remove();
8606
8763
  this.multipleSelectionContainer = undefined;
8607
8764
  this.userSelection.clear();
8608
8765
  for (const node of this.model.nodes) {
@@ -8696,7 +8853,7 @@ class CollabClient {
8696
8853
  const initialModel = message.initialModel;
8697
8854
  new DagaImporter().import(session.canvas.model, initialModel);
8698
8855
  this.startSyncing(session);
8699
- (_a = session.joinRoomResolve) === null || _a === undefined ? undefined : _a.call(session);
8856
+ (_a = session.joinRoomResolve) === null || _a === void 0 ? void 0 : _a.call(session);
8700
8857
  session.joinRoomResolve = undefined;
8701
8858
  break;
8702
8859
  }
@@ -8719,7 +8876,7 @@ class CollabClient {
8719
8876
  session.locator = message.locator;
8720
8877
  this.pendingSessions.delete(message.refId);
8721
8878
  this.sessions.set(session.locator, session);
8722
- (_b = session.createRoomResolve) === null || _b === undefined ? undefined : _b.call(session, session.locator);
8879
+ (_b = session.createRoomResolve) === null || _b === void 0 ? void 0 : _b.call(session, session.locator);
8723
8880
  session.createRoomResolve = undefined;
8724
8881
  // Deliver queued AddMessages now that we have a locator.
8725
8882
  for (const message of session.addQueue) {
@@ -8992,7 +9149,7 @@ class AdjacencyLayout {
8992
9149
  // place nodes according to arrangement
8993
9150
  const maximumWidth = Math.max(...model.nodes.map(n => n.width));
8994
9151
  const maximumHeight = Math.max(...model.nodes.map(n => n.height));
8995
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9152
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
8996
9153
  for (let y = nodeArrangement.minY(); y <= nodeArrangement.maxY(); ++y) {
8997
9154
  for (let x = nodeArrangement.minX(); x <= nodeArrangement.maxX(); ++x) {
8998
9155
  const node = nodeArrangement.get([x, y]);
@@ -9060,7 +9217,7 @@ class BreadthAdjacencyLayout {
9060
9217
  // place nodes according to arrangement
9061
9218
  const maximumWidth = Math.max(...model.nodes.map(n => n.width));
9062
9219
  const maximumHeight = Math.max(...model.nodes.map(n => n.height));
9063
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9220
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
9064
9221
  for (let y = nodeArrangement.minY(); y <= nodeArrangement.maxY(); ++y) {
9065
9222
  for (let x = nodeArrangement.minX(); x <= nodeArrangement.maxX(); ++x) {
9066
9223
  const node = nodeArrangement.get([x, y]);
@@ -9087,7 +9244,7 @@ class BreadthLayout {
9087
9244
  // nothing to arrange...
9088
9245
  return model;
9089
9246
  }
9090
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9247
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
9091
9248
  let nodesToBeArranged = model.nodes.filter(n => !n.parent);
9092
9249
  // Arrange nodes by a breadth first search
9093
9250
  const firstNode = nodesToBeArranged[0];
@@ -9153,8 +9310,8 @@ class ForceLayout {
9153
9310
  return model;
9154
9311
  }
9155
9312
  // as a starting point, we apply a simple layout
9156
- new BreadthLayout().apply(model);
9157
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9313
+ new BreadthLayout(this.gapSize).apply(model);
9314
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
9158
9315
  const coolingFactor = 0.99;
9159
9316
  const minimumTemperature = 1;
9160
9317
  const attractionFactor = 0.1;
@@ -9250,7 +9407,7 @@ class HorizontalLayout {
9250
9407
  // nothing to arrange...
9251
9408
  return model;
9252
9409
  }
9253
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9410
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
9254
9411
  const nodesToBeArranged = model.nodes.filter(n => !n.parent);
9255
9412
  nodesToBeArranged.sort((a, b) => b.type.priority - a.type.priority);
9256
9413
  let widthAccumulator = 0;
@@ -9280,10 +9437,10 @@ class PriorityLayout {
9280
9437
  const minimumPriority = Math.min(...model.nodes.map(n => n.getPriority()));
9281
9438
  if (maximumPriority === minimumPriority) {
9282
9439
  // if there's no disparity in priorities, just use breadth layout
9283
- new BreadthLayout().apply(model);
9440
+ new BreadthLayout(this.gapSize).apply(model);
9284
9441
  return model;
9285
9442
  }
9286
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9443
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
9287
9444
  const nodesToBeArranged = model.nodes.filter(n => !n.parent);
9288
9445
  const nodeArrangement = [];
9289
9446
  const nodesWithMaximumPriorityToBeArranged = model.nodes.filter(n => !n.parent).filter(n => n.getPriority() >= maximumPriority);
@@ -9390,10 +9547,10 @@ class TreeLayout {
9390
9547
  const minimumPriority = Math.min(...model.nodes.map(n => n.getPriority()));
9391
9548
  if (maximumPriority === minimumPriority) {
9392
9549
  // if there's no disparity in priorities, just use breadth layout
9393
- new BreadthLayout().apply(model);
9550
+ new BreadthLayout(this.gapSize).apply(model);
9394
9551
  return model;
9395
9552
  }
9396
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9553
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
9397
9554
  const nodesToBeArranged = model.nodes.filter(n => !n.parent).sort((n1, n2) => n2.getPriority() - n1.getPriority());
9398
9555
  const branches = [];
9399
9556
  while (nodesToBeArranged.length > 0) {
@@ -9487,7 +9644,7 @@ class VerticalLayout {
9487
9644
  // nothing to arrange...
9488
9645
  return model;
9489
9646
  }
9490
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9647
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
9491
9648
  const nodesToBeArranged = model.nodes.filter(n => !n.parent);
9492
9649
  nodesToBeArranged.sort((a, b) => b.type.priority - a.type.priority);
9493
9650
  let heightAccumulator = 0;