@metadev/daga 5.1.1 → 5.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.esm.js CHANGED
@@ -101,6 +101,53 @@ var VerticalAlign;
101
101
  VerticalAlign["Bottom"] = "bottom";
102
102
  })(VerticalAlign || (VerticalAlign = {}));
103
103
 
104
+ /******************************************************************************
105
+ Copyright (c) Microsoft Corporation.
106
+
107
+ Permission to use, copy, modify, and/or distribute this software for any
108
+ purpose with or without fee is hereby granted.
109
+
110
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
111
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
112
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
113
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
114
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
115
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
116
+ PERFORMANCE OF THIS SOFTWARE.
117
+ ***************************************************************************** */
118
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
119
+
120
+
121
+ function __rest(s, e) {
122
+ var t = {};
123
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
124
+ t[p] = s[p];
125
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
126
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
127
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
128
+ t[p[i]] = s[p[i]];
129
+ }
130
+ return t;
131
+ }
132
+
133
+ function __classPrivateFieldGet(receiver, state, kind, f) {
134
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
135
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
136
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
137
+ }
138
+
139
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
140
+ if (kind === "m") throw new TypeError("Private method is not writable");
141
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
142
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
143
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
144
+ }
145
+
146
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
147
+ var e = new Error(message);
148
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
149
+ };
150
+
104
151
  /**
105
152
  * Round the coordinates of the given point to the nearest whole number.
106
153
  * @public
@@ -1193,40 +1240,6 @@ const clone = o => {
1193
1240
  return res;
1194
1241
  };
1195
1242
 
1196
- /******************************************************************************
1197
- Copyright (c) Microsoft Corporation.
1198
-
1199
- Permission to use, copy, modify, and/or distribute this software for any
1200
- purpose with or without fee is hereby granted.
1201
-
1202
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1203
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1204
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1205
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1206
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1207
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1208
- PERFORMANCE OF THIS SOFTWARE.
1209
- ***************************************************************************** */
1210
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
1211
-
1212
-
1213
- function __rest(s, e) {
1214
- var t = {};
1215
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1216
- t[p] = s[p];
1217
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
1218
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1219
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1220
- t[p[i]] = s[p[i]];
1221
- }
1222
- return t;
1223
- }
1224
-
1225
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1226
- var e = new Error(message);
1227
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1228
- };
1229
-
1230
1243
  /**
1231
1244
  * Converts a configuration for a look into an easier to consult object of fully qualified looks for each case.
1232
1245
  *
@@ -1484,6 +1497,7 @@ const diffProperties = (a, b, valueSet) => {
1484
1497
  */
1485
1498
  const isObject = x => x !== undefined && x !== null && x.constructor === Object;
1486
1499
 
1500
+ var _ValueSet_instances, _a$1, _ValueSet_values, _ValueSet_valueSets, _ValueSet_ownTimestamps, _ValueSet_constructSubValueSet;
1487
1501
  /**
1488
1502
  * A set of values corresponding to a set of properties.
1489
1503
  * @public
@@ -1491,17 +1505,18 @@ const isObject = x => x !== undefined && x !== null && x.constructor === Object;
1491
1505
  */
1492
1506
  class ValueSet {
1493
1507
  constructor(propertySet, rootElement) {
1508
+ _ValueSet_instances.add(this);
1494
1509
  this.displayedProperties = [];
1495
1510
  this.hiddenProperties = [];
1496
- this.values = {};
1497
- this.valueSets = {};
1511
+ _ValueSet_values.set(this, {});
1512
+ _ValueSet_valueSets.set(this, {});
1498
1513
  /**
1499
1514
  * Collaborative timestamps for all keys in this.values that have ever been set,
1500
1515
  * even if since they've since been set to the default value.
1501
1516
  *
1502
1517
  * Object values (in this.valueSets) store their own timestamps separately.
1503
1518
  */
1504
- this.ownTimestamps = {};
1519
+ _ValueSet_ownTimestamps.set(this, {});
1505
1520
  this.propertySet = propertySet;
1506
1521
  this.rootElement = rootElement;
1507
1522
  this.resetValues();
@@ -1576,16 +1591,16 @@ class ValueSet {
1576
1591
  */
1577
1592
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1578
1593
  getValue(key) {
1579
- var _a;
1580
- const rootAttribute = (_a = this.propertySet.getProperty(key)) === null || _a === void 0 ? void 0 : _a.rootAttribute;
1594
+ var _b;
1595
+ const rootAttribute = (_b = this.propertySet.getProperty(key)) === null || _b === void 0 ? void 0 : _b.rootAttribute;
1581
1596
  if (rootAttribute !== undefined && rootAttribute !== null) {
1582
- this.values[key] = this.getRootElementValue(rootAttribute);
1597
+ __classPrivateFieldGet(this, _ValueSet_values, "f")[key] = this.getRootElementValue(rootAttribute);
1583
1598
  }
1584
1599
  const property = this.propertySet.getProperty(key);
1585
1600
  if (property.type === Type.Object) {
1586
- return this.valueSets[key].getValues();
1601
+ return __classPrivateFieldGet(this, _ValueSet_valueSets, "f")[key].getValues();
1587
1602
  } else {
1588
- return this.values[key];
1603
+ return __classPrivateFieldGet(this, _ValueSet_values, "f")[key];
1589
1604
  }
1590
1605
  }
1591
1606
  /**
@@ -1598,7 +1613,7 @@ class ValueSet {
1598
1613
  for (const key in this.propertySet.propertyMap) {
1599
1614
  const property = this.propertySet.getProperty(key);
1600
1615
  if (property.type === Type.Object) {
1601
- result[key] = this.valueSets[key].getValues();
1616
+ result[key] = __classPrivateFieldGet(this, _ValueSet_valueSets, "f")[key].getValues();
1602
1617
  } else {
1603
1618
  result[key] = this.getValue(key);
1604
1619
  }
@@ -1615,7 +1630,7 @@ class ValueSet {
1615
1630
  for (const key in keys) {
1616
1631
  const property = this.propertySet.getProperty(key);
1617
1632
  if (property.type === Type.Object) {
1618
- result[key] = this.valueSets[key].getValuesForKeys(keys[key]);
1633
+ result[key] = __classPrivateFieldGet(this, _ValueSet_valueSets, "f")[key].getValuesForKeys(keys[key]);
1619
1634
  } else {
1620
1635
  result[key] = this.getValue(key);
1621
1636
  }
@@ -1632,9 +1647,9 @@ class ValueSet {
1632
1647
  for (const key in this.propertySet.propertyMap) {
1633
1648
  const property = this.propertySet.getProperty(key);
1634
1649
  if (property.type === Type.Object) {
1635
- result[key] = this.valueSets[key].getTimestamps();
1650
+ result[key] = __classPrivateFieldGet(this, _ValueSet_valueSets, "f")[key].getTimestamps();
1636
1651
  } else {
1637
- const timestamp = this.ownTimestamps[key];
1652
+ const timestamp = __classPrivateFieldGet(this, _ValueSet_ownTimestamps, "f")[key];
1638
1653
  if (timestamp) result[key] = timestamp;
1639
1654
  }
1640
1655
  }
@@ -1687,9 +1702,9 @@ class ValueSet {
1687
1702
  const property = this.propertySet.getProperty(key);
1688
1703
  if (property) {
1689
1704
  if (property.type === Type.Object) {
1690
- this.valueSets[key].setValues(value);
1705
+ __classPrivateFieldGet(this, _ValueSet_valueSets, "f")[key].setValues(value);
1691
1706
  } else {
1692
- this.values[key] = value;
1707
+ __classPrivateFieldGet(this, _ValueSet_values, "f")[key] = value;
1693
1708
  if (!equals(value, property.defaultValue)) {
1694
1709
  this.displayProperty(property);
1695
1710
  }
@@ -1710,7 +1725,7 @@ class ValueSet {
1710
1725
  for (const key in values) {
1711
1726
  const property = this.propertySet.getProperty(key);
1712
1727
  if (property.type === Type.Object) {
1713
- this.valueSets[key].setValues(values[key]);
1728
+ __classPrivateFieldGet(this, _ValueSet_valueSets, "f")[key].setValues(values[key]);
1714
1729
  } else {
1715
1730
  this.setValue(key, values[key]);
1716
1731
  }
@@ -1722,13 +1737,13 @@ class ValueSet {
1722
1737
  * @param values An object containing all the CollabTimestamps in the set.
1723
1738
  */
1724
1739
  setTimestamps(timestamps) {
1725
- this.ownTimestamps = {};
1740
+ __classPrivateFieldSet(this, _ValueSet_ownTimestamps, {}, "f");
1726
1741
  for (const key in timestamps) {
1727
1742
  const property = this.propertySet.getProperty(key);
1728
1743
  if (property.type === Type.Object) {
1729
- this.valueSets[key].setTimestamps(timestamps[key]);
1744
+ __classPrivateFieldGet(this, _ValueSet_valueSets, "f")[key].setTimestamps(timestamps[key]);
1730
1745
  } else {
1731
- this.ownTimestamps[key] = timestamps[key];
1746
+ __classPrivateFieldGet(this, _ValueSet_ownTimestamps, "f")[key] = timestamps[key];
1732
1747
  }
1733
1748
  }
1734
1749
  }
@@ -1741,7 +1756,7 @@ class ValueSet {
1741
1756
  for (const key in values) {
1742
1757
  const property = this.propertySet.getProperty(key);
1743
1758
  if (property.type === Type.Object) {
1744
- this.valueSets[key].overwriteValues(values[key]);
1759
+ __classPrivateFieldGet(this, _ValueSet_valueSets, "f")[key].overwriteValues(values[key]);
1745
1760
  } else {
1746
1761
  this.setValue(key, values[key]);
1747
1762
  }
@@ -1756,11 +1771,11 @@ class ValueSet {
1756
1771
  for (const key in values) {
1757
1772
  const property = this.propertySet.getProperty(key);
1758
1773
  if (property.type === Type.Object) {
1759
- this.valueSets[key].overwriteValuesLww(values[key], timestamp);
1774
+ __classPrivateFieldGet(this, _ValueSet_valueSets, "f")[key].overwriteValuesLww(values[key], timestamp);
1760
1775
  } else {
1761
- if (timestampWins(timestamp, this.ownTimestamps[key])) {
1776
+ if (timestampWins(timestamp, __classPrivateFieldGet(this, _ValueSet_ownTimestamps, "f")[key])) {
1762
1777
  this.setValue(key, values[key]);
1763
- this.ownTimestamps[key] = timestamp;
1778
+ __classPrivateFieldGet(this, _ValueSet_ownTimestamps, "f")[key] = timestamp;
1764
1779
  }
1765
1780
  }
1766
1781
  }
@@ -1773,18 +1788,18 @@ class ValueSet {
1773
1788
  resetValues() {
1774
1789
  this.displayedProperties = [];
1775
1790
  this.hiddenProperties = [];
1776
- this.ownTimestamps = {};
1791
+ __classPrivateFieldSet(this, _ValueSet_ownTimestamps, {}, "f");
1777
1792
  for (const key in this.propertySet.propertyMap) {
1778
1793
  const property = this.propertySet.getProperty(key);
1779
1794
  const rootAttribute = property.rootAttribute;
1780
1795
  if (property.type === Type.Object) {
1781
- this.valueSets[key] = this.constructSubValueSet(key);
1796
+ __classPrivateFieldGet(this, _ValueSet_valueSets, "f")[key] = __classPrivateFieldGet(this, _ValueSet_instances, "m", _ValueSet_constructSubValueSet).call(this, key);
1782
1797
  } else {
1783
- this.values[key] = clone(property.defaultValue);
1798
+ __classPrivateFieldGet(this, _ValueSet_values, "f")[key] = clone(property.defaultValue);
1784
1799
  }
1785
1800
  if (rootAttribute !== undefined && rootAttribute !== null) {
1786
1801
  if (property.defaultValue !== undefined && !equals(this.getRootElementValue(rootAttribute), property.defaultValue)) {
1787
- this.setRootElementValue(rootAttribute, this.values[key]);
1802
+ this.setRootElementValue(rootAttribute, __classPrivateFieldGet(this, _ValueSet_values, "f")[key]);
1788
1803
  }
1789
1804
  }
1790
1805
  if (property.basic !== false) {
@@ -1794,19 +1809,6 @@ class ValueSet {
1794
1809
  }
1795
1810
  }
1796
1811
  }
1797
- /**
1798
- * Constructs a ValueSet with its corresponding PropertySet representing the values of the object.
1799
- * @private
1800
- * @param key Key that the ValueSet is under.
1801
- * @returns The constructed ValueSet.
1802
- */
1803
- constructSubValueSet(key) {
1804
- const property = this.propertySet.getProperty(key);
1805
- const propertySet = new PropertySet(property.properties);
1806
- const valueSet = new ValueSet(propertySet, this.rootElement);
1807
- valueSet.overwriteValues(clone(property.defaultValue));
1808
- return valueSet;
1809
- }
1810
1812
  /**
1811
1813
  * Gets the ValueSet under the given key when there are nested ValueSets.
1812
1814
  * @private
@@ -1814,7 +1816,7 @@ class ValueSet {
1814
1816
  * @returns A ValueSet.
1815
1817
  */
1816
1818
  getSubValueSet(key) {
1817
- return this.valueSets[key];
1819
+ return __classPrivateFieldGet(this, _ValueSet_valueSets, "f")[key];
1818
1820
  }
1819
1821
  /**
1820
1822
  * Moves the given property to the list of displayed properties.
@@ -1839,6 +1841,13 @@ class ValueSet {
1839
1841
  }
1840
1842
  }
1841
1843
  }
1844
+ _a$1 = ValueSet, _ValueSet_values = new WeakMap(), _ValueSet_valueSets = new WeakMap(), _ValueSet_ownTimestamps = new WeakMap(), _ValueSet_instances = new WeakSet(), _ValueSet_constructSubValueSet = function _ValueSet_constructSubValueSet(key) {
1845
+ const property = this.propertySet.getProperty(key);
1846
+ const propertySet = new PropertySet(property.properties);
1847
+ const valueSet = new _a$1(propertySet, this.rootElement);
1848
+ valueSet.overwriteValues(clone(property.defaultValue));
1849
+ return valueSet;
1850
+ };
1842
1851
 
1843
1852
  /**
1844
1853
  * Represents a collection of diagram entities of a type that exists as part of a diagram model.
@@ -1976,6 +1985,7 @@ class DiagramEntitySet {
1976
1985
  }
1977
1986
  }
1978
1987
 
1988
+ var _DiagramElement_id;
1979
1989
  /**
1980
1990
  * Default priority value for diagram elements.
1981
1991
  * @private
@@ -1993,7 +2003,7 @@ class DiagramElement {
1993
2003
  * @public
1994
2004
  */
1995
2005
  get id() {
1996
- return this._id;
2006
+ return __classPrivateFieldGet(this, _DiagramElement_id, "f");
1997
2007
  }
1998
2008
  /**
1999
2009
  * Whether this diagram element is currently in the user highlight.
@@ -2011,6 +2021,7 @@ class DiagramElement {
2011
2021
  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;
2012
2022
  }
2013
2023
  constructor(model, id) {
2024
+ _DiagramElement_id.set(this, void 0);
2014
2025
  /**
2015
2026
  * Whether this diagram element has itself been explicitly removed.
2016
2027
  *
@@ -2029,7 +2040,7 @@ class DiagramElement {
2029
2040
  */
2030
2041
  this.selfRemovedTimestamp = null;
2031
2042
  this.model = model;
2032
- this._id = id;
2043
+ __classPrivateFieldSet(this, _DiagramElement_id, id, "f");
2033
2044
  }
2034
2045
  /**
2035
2046
  * Obtain the selection of this element.
@@ -2040,6 +2051,7 @@ class DiagramElement {
2040
2051
  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)}']`);
2041
2052
  }
2042
2053
  }
2054
+ _DiagramElement_id = new WeakMap();
2043
2055
  class DiagramElementSet extends DiagramEntitySet {
2044
2056
  all(includeRemoved = false) {
2045
2057
  if (includeRemoved) {
@@ -2117,6 +2129,7 @@ class DiagramElementSet extends DiagramEntitySet {
2117
2129
  }
2118
2130
  }
2119
2131
 
2132
+ var _DiagramConnection_type, _DiagramConnectionSet_model;
2120
2133
  /**
2121
2134
  * Default values of the parameters of a diagram connection.
2122
2135
  * @private
@@ -2201,12 +2214,12 @@ class DiagramConnectionType {
2201
2214
  */
2202
2215
  class DiagramConnection extends DiagramElement {
2203
2216
  get type() {
2204
- return this._type;
2217
+ return __classPrivateFieldGet(this, _DiagramConnection_type, "f");
2205
2218
  }
2206
2219
  set type(type) {
2207
2220
  var _a, _b;
2208
- if (type !== this._type) {
2209
- this._type = type;
2221
+ if (type !== __classPrivateFieldGet(this, _DiagramConnection_type, "f")) {
2222
+ __classPrivateFieldSet(this, _DiagramConnection_type, type, "f");
2210
2223
  if (this.valueSet) {
2211
2224
  this.valueSet = new ValueSet(type.propertySet, this);
2212
2225
  }
@@ -2402,6 +2415,7 @@ class DiagramConnection extends DiagramElement {
2402
2415
  throw new Error(`DiagramConnection cannot have an empty or null id`);
2403
2416
  }
2404
2417
  super(model, id);
2418
+ _DiagramConnection_type.set(this, void 0);
2405
2419
  /**
2406
2420
  * Coordinates of the start point of this connection.
2407
2421
  * @public
@@ -2432,7 +2446,7 @@ class DiagramConnection extends DiagramElement {
2432
2446
  * @public
2433
2447
  */
2434
2448
  this.points = [];
2435
- this._type = type;
2449
+ __classPrivateFieldSet(this, _DiagramConnection_type, type, "f");
2436
2450
  this.valueSet = new ValueSet(type.propertySet, this);
2437
2451
  this.originalData = {};
2438
2452
  this.setStart(start);
@@ -2609,6 +2623,7 @@ class DiagramConnection extends DiagramElement {
2609
2623
  }
2610
2624
  }
2611
2625
  }
2626
+ _DiagramConnection_type = new WeakMap();
2612
2627
  class DiagramConnectionSet extends DiagramElementSet {
2613
2628
  /**
2614
2629
  * Instance a set of connections for the given model. This method is used internally.
@@ -2616,12 +2631,13 @@ class DiagramConnectionSet extends DiagramElementSet {
2616
2631
  */
2617
2632
  constructor(model) {
2618
2633
  super();
2634
+ _DiagramConnectionSet_model.set(this, void 0);
2619
2635
  /**
2620
2636
  * Set of the possible types of connection that the connections of this set can have.
2621
2637
  * @public
2622
2638
  */
2623
2639
  this.types = new DiagramEntitySet();
2624
- this.model = model;
2640
+ __classPrivateFieldSet(this, _DiagramConnectionSet_model, model, "f");
2625
2641
  }
2626
2642
  /**
2627
2643
  * Instance a new connection and add it to this set.
@@ -2644,7 +2660,7 @@ class DiagramConnectionSet extends DiagramElementSet {
2644
2660
  }
2645
2661
  connectionType = foundConnectionType;
2646
2662
  }
2647
- const connection = new DiagramConnection(this.model, connectionType, start, end, id);
2663
+ const connection = new DiagramConnection(__classPrivateFieldGet(this, _DiagramConnectionSet_model, "f"), connectionType, start, end, id);
2648
2664
  super.add(connection);
2649
2665
  connection.updateInView();
2650
2666
  connection.valueSet.resetValues();
@@ -2666,6 +2682,7 @@ class DiagramConnectionSet extends DiagramElementSet {
2666
2682
  }
2667
2683
  }
2668
2684
  }
2685
+ _DiagramConnectionSet_model = new WeakMap();
2669
2686
 
2670
2687
  /**
2671
2688
  * The different modes for when a node or section can be resized.
@@ -2689,6 +2706,7 @@ var ResizableMode;
2689
2706
  ResizableMode[ResizableMode["Never"] = 2] = "Never";
2690
2707
  })(ResizableMode || (ResizableMode = {}));
2691
2708
 
2709
+ var _DiagramField_text, _DiagramFieldSet_model;
2692
2710
  /**
2693
2711
  * Default values of the parameters of a diagram field.
2694
2712
  * @private
@@ -2725,14 +2743,14 @@ class DiagramField extends DiagramElement {
2725
2743
  * @public
2726
2744
  */
2727
2745
  get text() {
2728
- return this._text;
2746
+ return __classPrivateFieldGet(this, _DiagramField_text, "f");
2729
2747
  }
2730
2748
  set text(value) {
2731
2749
  var _a;
2732
2750
  if (value === null || value === undefined || (value === null || value === void 0 ? void 0 : value.trim()) === '') {
2733
2751
  value = this.defaultText;
2734
2752
  }
2735
- this._text = value;
2753
+ __classPrivateFieldSet(this, _DiagramField_text, value, "f");
2736
2754
  this.updateInView();
2737
2755
  if (this.fit) {
2738
2756
  (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.fitFieldRootInView(this.id, this.shrink);
@@ -2763,6 +2781,7 @@ class DiagramField extends DiagramElement {
2763
2781
  throw new Error('DiagramField for rootElement already exists');
2764
2782
  }
2765
2783
  super(model, id);
2784
+ _DiagramField_text.set(this, void 0);
2766
2785
  /**
2767
2786
  * Collaborative timestamp for text.
2768
2787
  * @public
@@ -2801,7 +2820,7 @@ class DiagramField extends DiagramElement {
2801
2820
  this.highlightedLook = looks.highlightedLook;
2802
2821
  this.selectedAndHighlightedLook = looks.selectedAndHighlightedLook;
2803
2822
  this.defaultText = text;
2804
- this._text = text;
2823
+ __classPrivateFieldSet(this, _DiagramField_text, text, "f");
2805
2824
  this.editable = editable;
2806
2825
  this.fit = fit;
2807
2826
  this.shrink = shrink;
@@ -2831,6 +2850,7 @@ class DiagramField extends DiagramElement {
2831
2850
  return ((_a = this.rootElement) === null || _a === void 0 ? void 0 : _a.getPriority()) || DEFAULT_PRIORITY;
2832
2851
  }
2833
2852
  }
2853
+ _DiagramField_text = new WeakMap();
2834
2854
  class DiagramFieldSet extends DiagramElementSet {
2835
2855
  /**
2836
2856
  * Instance a set of fields for the given model. This method is used internally.
@@ -2838,14 +2858,15 @@ class DiagramFieldSet extends DiagramElementSet {
2838
2858
  */
2839
2859
  constructor(model) {
2840
2860
  super();
2841
- this.model = model;
2861
+ _DiagramFieldSet_model.set(this, void 0);
2862
+ __classPrivateFieldSet(this, _DiagramFieldSet_model, model, "f");
2842
2863
  }
2843
2864
  /**
2844
2865
  * 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.
2845
2866
  * @private
2846
2867
  */
2847
2868
  new(rootElement, coords, width, height, horizontalAlign, verticalAlign, orientation, multiline, look, text, editable, fit, shrink) {
2848
- const field = new DiagramField(this.model, rootElement, coords, width, height, horizontalAlign, verticalAlign, orientation, multiline, look, text, editable, fit, shrink);
2869
+ const field = new DiagramField(__classPrivateFieldGet(this, _DiagramFieldSet_model, "f"), rootElement, coords, width, height, horizontalAlign, verticalAlign, orientation, multiline, look, text, editable, fit, shrink);
2849
2870
  super.add(field);
2850
2871
  field.updateInView();
2851
2872
  // add this field to its root element
@@ -2871,6 +2892,7 @@ class DiagramFieldSet extends DiagramElementSet {
2871
2892
  }
2872
2893
  }
2873
2894
  }
2895
+ _DiagramFieldSet_model = new WeakMap();
2874
2896
  const getBottomMargin = config => {
2875
2897
  if ((config === null || config === void 0 ? void 0 : config.margin) === null || (config === null || config === void 0 ? void 0 : config.margin) === undefined) {
2876
2898
  return DIAGRAM_FIELD_DEFAULTS.margin;
@@ -3079,6 +3101,7 @@ class DiagramResizer {
3079
3101
  }
3080
3102
  const DIAGRAM_DEFAULT_RESIZER = new DiagramResizer(DIAGRAM_RESIZER_DEFAULTS);
3081
3103
 
3104
+ var _DiagramSectionSet_model;
3082
3105
  /**
3083
3106
  * Default value of the default width of a diagram section.
3084
3107
  * @private
@@ -3566,7 +3589,8 @@ class DiagramSectionSet extends DiagramElementSet {
3566
3589
  */
3567
3590
  constructor(model) {
3568
3591
  super();
3569
- this.model = model;
3592
+ _DiagramSectionSet_model.set(this, void 0);
3593
+ __classPrivateFieldSet(this, _DiagramSectionSet_model, model, "f");
3570
3594
  }
3571
3595
  /**
3572
3596
  * Instance a new section and add it to this set. This method is normally called when instancing an element with a section and it is rarely called by itself.
@@ -3574,7 +3598,7 @@ class DiagramSectionSet extends DiagramElementSet {
3574
3598
  */
3575
3599
  new(node, indexXInNode, indexYInNode, coords, width, height, id) {
3576
3600
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
3577
- const section = new DiagramSection(this.model, node, indexXInNode, indexYInNode, coords, width, height, id);
3601
+ const section = new DiagramSection(__classPrivateFieldGet(this, _DiagramSectionSet_model, "f"), node, indexXInNode, indexYInNode, coords, width, height, id);
3578
3602
  super.add(section);
3579
3603
  section.updateInView();
3580
3604
  // add this section to its node
@@ -3585,7 +3609,7 @@ class DiagramSectionSet extends DiagramElementSet {
3585
3609
  if (sectionPorts && sectionPorts.length > 0) {
3586
3610
  for (let i = 0; i < sectionPorts.length; ++i) {
3587
3611
  const portConfig = sectionPorts[i];
3588
- 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');
3612
+ const port = __classPrivateFieldGet(this, _DiagramSectionSet_model, "f").ports.new(portConfig.type !== undefined ? __classPrivateFieldGet(this, _DiagramSectionSet_model, "f").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');
3589
3613
  if ((_e = port.type) === null || _e === void 0 ? void 0 : _e.label) {
3590
3614
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === void 0 ? void 0 : _f.label);
3591
3615
  labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
@@ -3604,7 +3628,7 @@ class DiagramSectionSet extends DiagramElementSet {
3604
3628
  default:
3605
3629
  labelCoords = port.coords;
3606
3630
  }
3607
- this.model.fields.new(port, labelCoords, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
3631
+ __classPrivateFieldGet(this, _DiagramSectionSet_model, "f").fields.new(port, labelCoords, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
3608
3632
  }
3609
3633
  }
3610
3634
  }
@@ -3613,7 +3637,7 @@ class DiagramSectionSet extends DiagramElementSet {
3613
3637
  if (sectionLabel) {
3614
3638
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), sectionLabel);
3615
3639
  labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
3616
- this.model.fields.new(section, [section.coords[0] + getLeftMargin(labelConfiguration), section.coords[1] + getTopMargin(labelConfiguration)], section.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), section.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
3640
+ __classPrivateFieldGet(this, _DiagramSectionSet_model, "f").fields.new(section, [section.coords[0] + getLeftMargin(labelConfiguration), section.coords[1] + getTopMargin(labelConfiguration)], section.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), section.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
3617
3641
  }
3618
3642
  return section;
3619
3643
  }
@@ -3622,11 +3646,11 @@ class DiagramSectionSet extends DiagramElementSet {
3622
3646
  if (section) {
3623
3647
  // remove all ports
3624
3648
  while (section.ports.length > 0) {
3625
- this.model.ports.remove(section.ports[0].id);
3649
+ __classPrivateFieldGet(this, _DiagramSectionSet_model, "f").ports.remove(section.ports[0].id);
3626
3650
  }
3627
3651
  // remove label
3628
3652
  if (section.label) {
3629
- this.model.fields.remove(section.label.id);
3653
+ __classPrivateFieldGet(this, _DiagramSectionSet_model, "f").fields.remove(section.label.id);
3630
3654
  }
3631
3655
  // remove from root element
3632
3656
  if (section.node) {
@@ -3639,7 +3663,9 @@ class DiagramSectionSet extends DiagramElementSet {
3639
3663
  }
3640
3664
  }
3641
3665
  }
3666
+ _DiagramSectionSet_model = new WeakMap();
3642
3667
 
3668
+ var _DiagramNode_type, _DiagramNodeSet_model;
3643
3669
  /**
3644
3670
  * Default values of the look of a diagram node.
3645
3671
  * @private
@@ -3670,6 +3696,7 @@ const DIAGRAM_NODE_TYPE_DEFAULTS = {
3670
3696
  defaultHeight: 1,
3671
3697
  minWidth: 1,
3672
3698
  minHeight: 1,
3699
+ defaultZ: 0,
3673
3700
  resizableX: false,
3674
3701
  resizableY: false,
3675
3702
  snapToGridOffset: [0, 0, 0, 0],
@@ -3699,6 +3726,7 @@ class DiagramNodeType {
3699
3726
  this.defaultHeight = values.defaultHeight;
3700
3727
  this.minWidth = values.minWidth;
3701
3728
  this.minHeight = values.minHeight;
3729
+ this.defaultZ = values.defaultZ;
3702
3730
  if (typeof options.resizableX === 'undefined') {
3703
3731
  this.resizerX = new DiagramResizer({
3704
3732
  mode: ResizableMode.Never
@@ -3750,12 +3778,12 @@ class DiagramNodeType {
3750
3778
  */
3751
3779
  class DiagramNode extends DiagramElement {
3752
3780
  get type() {
3753
- return this._type;
3781
+ return __classPrivateFieldGet(this, _DiagramNode_type, "f");
3754
3782
  }
3755
3783
  set type(type) {
3756
3784
  var _a, _b;
3757
- if (type !== this._type) {
3758
- this._type = type;
3785
+ if (type !== __classPrivateFieldGet(this, _DiagramNode_type, "f")) {
3786
+ __classPrivateFieldSet(this, _DiagramNode_type, type, "f");
3759
3787
  if (this.valueSet) {
3760
3788
  this.valueSet = new ValueSet(type.propertySet, this);
3761
3789
  }
@@ -3848,6 +3876,7 @@ class DiagramNode extends DiagramElement {
3848
3876
  throw new Error(`DiagramNode cannot have an empty or null id`);
3849
3877
  }
3850
3878
  super(model, id);
3879
+ _DiagramNode_type.set(this, void 0);
3851
3880
  /**
3852
3881
  * Nodes contained within this node.
3853
3882
  * @public
@@ -3873,12 +3902,13 @@ class DiagramNode extends DiagramElement {
3873
3902
  * @public
3874
3903
  */
3875
3904
  this.geometryTimestamp = null;
3876
- this._type = type;
3905
+ __classPrivateFieldSet(this, _DiagramNode_type, type, "f");
3877
3906
  this.valueSet = new ValueSet(type.propertySet, this);
3878
3907
  this.originalData = {};
3879
3908
  this.coords = coords;
3880
3909
  this.width = type.defaultWidth;
3881
3910
  this.height = type.defaultHeight;
3911
+ this.z = type.defaultZ;
3882
3912
  }
3883
3913
  get removed() {
3884
3914
  return this.selfRemoved;
@@ -3906,6 +3936,16 @@ class DiagramNode extends DiagramElement {
3906
3936
  child.raise();
3907
3937
  }
3908
3938
  }
3939
+ /**
3940
+ * Put this element above other elements in the view if they have a lower z coordinate.
3941
+ */
3942
+ raiseWithZ() {
3943
+ this.raise();
3944
+ const overlappingNodesWithHigherPriority = this.model.nodes.filter(n => n.id !== this.id && n.z > this.z && rectanglesIntersect([n.coords, [n.coords[0] + n.width, n.coords[1] + n.height]], [this.coords, [this.coords[0] + this.width, this.coords[1] + this.height]]));
3945
+ for (const n of overlappingNodesWithHigherPriority) {
3946
+ n.raiseWithZ();
3947
+ }
3948
+ }
3909
3949
  getPriority() {
3910
3950
  return this.type.priority;
3911
3951
  }
@@ -4209,6 +4249,7 @@ class DiagramNode extends DiagramElement {
4209
4249
  }
4210
4250
  this.setGeometry({
4211
4251
  coords,
4252
+ z: this.z,
4212
4253
  width: this.width,
4213
4254
  height: this.height,
4214
4255
  // We already moved the sections above - skip changing them in setDimensions.
@@ -4260,6 +4301,7 @@ class DiagramNode extends DiagramElement {
4260
4301
  }
4261
4302
  this.setGeometry({
4262
4303
  coords: [newCoordsX[0], newCoordsY[0]],
4304
+ z: this.z,
4263
4305
  width: newCoordsX[1] - newCoordsX[0],
4264
4306
  height: newCoordsY[1] - newCoordsY[0],
4265
4307
  // we ignore this.sections, the stretching of a node with sections is handled in the stretchSections method
@@ -4367,6 +4409,7 @@ class DiagramNode extends DiagramElement {
4367
4409
  }
4368
4410
  return {
4369
4411
  coords: [...this.coords],
4412
+ z: this.z,
4370
4413
  width: this.width,
4371
4414
  height: this.height,
4372
4415
  sections,
@@ -4383,6 +4426,7 @@ class DiagramNode extends DiagramElement {
4383
4426
  const oldCoordsX = [this.coords[0], this.coords[0] + this.width];
4384
4427
  const oldCoordsY = [this.coords[1], this.coords[1] + this.height];
4385
4428
  this.coords = [...geometry.coords];
4429
+ this.z = geometry.z;
4386
4430
  this.width = geometry.width;
4387
4431
  this.height = geometry.height;
4388
4432
  const newCoordsX = [this.coords[0], this.coords[0] + this.width];
@@ -4523,6 +4567,7 @@ class DiagramNode extends DiagramElement {
4523
4567
  this.stretch(Side.Bottom, margin + rowHeight);
4524
4568
  }
4525
4569
  }
4570
+ _DiagramNode_type = new WeakMap();
4526
4571
  class DiagramNodeSet extends DiagramElementSet {
4527
4572
  /**
4528
4573
  * Instance a set of nodes for the given model. This method is used internally.
@@ -4530,12 +4575,13 @@ class DiagramNodeSet extends DiagramElementSet {
4530
4575
  */
4531
4576
  constructor(model) {
4532
4577
  super();
4578
+ _DiagramNodeSet_model.set(this, void 0);
4533
4579
  /**
4534
4580
  * Set of the possible types of node that the nodes of this set can have.
4535
4581
  * @public
4536
4582
  */
4537
4583
  this.types = new DiagramEntitySet();
4538
- this.model = model;
4584
+ __classPrivateFieldSet(this, _DiagramNodeSet_model, model, "f");
4539
4585
  }
4540
4586
  /**
4541
4587
  * Instance a new node and add it to this set.
@@ -4557,7 +4603,7 @@ class DiagramNodeSet extends DiagramElementSet {
4557
4603
  }
4558
4604
  nodeType = foundNodeType;
4559
4605
  }
4560
- const node = new DiagramNode(this.model, nodeType, coords, id);
4606
+ const node = new DiagramNode(__classPrivateFieldGet(this, _DiagramNodeSet_model, "f"), nodeType, coords, id);
4561
4607
  super.add(node);
4562
4608
  node.updateInView();
4563
4609
  // add node sections
@@ -4567,7 +4613,7 @@ class DiagramNodeSet extends DiagramElementSet {
4567
4613
  for (let j = 0; j < nodeType.sectionGrid.sections.length; ++j) {
4568
4614
  let widthAccumulator = node.coords[0] + (nodeType.sectionGrid.margin || 0);
4569
4615
  for (let i = 0; i < nodeType.sectionGrid.sections[j].length; ++i) {
4570
- 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}`);
4616
+ __classPrivateFieldGet(this, _DiagramNodeSet_model, "f").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}`);
4571
4617
  widthAccumulator += (((_c = nodeType.sectionGrid.defaultWidths) === null || _c === void 0 ? void 0 : _c[i]) || DIAGRAM_SECTION_DEFAULT_WIDTH) + (nodeType.sectionGrid.margin || 0);
4572
4618
  }
4573
4619
  heightAccumulator += (((_d = nodeType.sectionGrid.defaultHeights) === null || _d === void 0 ? void 0 : _d[j]) || DIAGRAM_SECTION_DEFAULT_HEIGHT) + (nodeType.sectionGrid.margin || 0);
@@ -4577,8 +4623,8 @@ class DiagramNodeSet extends DiagramElementSet {
4577
4623
  if (nodeType.ports.length > 0) {
4578
4624
  for (let i = 0; i < nodeType.ports.length; ++i) {
4579
4625
  const portConfig = nodeType.ports[i];
4580
- const portType = portConfig.type !== undefined ? this.model.ports.types.get(portConfig.type) : undefined;
4581
- 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');
4626
+ const portType = portConfig.type !== undefined ? __classPrivateFieldGet(this, _DiagramNodeSet_model, "f").ports.types.get(portConfig.type) : undefined;
4627
+ const port = __classPrivateFieldGet(this, _DiagramNodeSet_model, "f").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');
4582
4628
  if ((_e = port.type) === null || _e === void 0 ? void 0 : _e.label) {
4583
4629
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === void 0 ? void 0 : _f.label);
4584
4630
  labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
@@ -4597,7 +4643,7 @@ class DiagramNodeSet extends DiagramElementSet {
4597
4643
  default:
4598
4644
  labelCoords = port.coords;
4599
4645
  }
4600
- this.model.fields.new(port, labelCoords, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
4646
+ __classPrivateFieldGet(this, _DiagramNodeSet_model, "f").fields.new(port, labelCoords, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
4601
4647
  }
4602
4648
  }
4603
4649
  }
@@ -4605,13 +4651,13 @@ class DiagramNodeSet extends DiagramElementSet {
4605
4651
  if (nodeType.label) {
4606
4652
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), nodeType.label);
4607
4653
  labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
4608
- this.model.fields.new(node, [node.coords[0] + getLeftMargin(labelConfiguration), node.coords[1] + getTopMargin(labelConfiguration)], node.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), node.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
4654
+ __classPrivateFieldGet(this, _DiagramNodeSet_model, "f").fields.new(node, [node.coords[0] + getLeftMargin(labelConfiguration), node.coords[1] + getTopMargin(labelConfiguration)], node.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), node.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, labelConfiguration.multiline, labelConfiguration.look, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
4609
4655
  }
4610
4656
  // add node decorators
4611
4657
  if (nodeType.decorators.length > 0) {
4612
4658
  for (let i = 0; i < nodeType.decorators.length; ++i) {
4613
4659
  const decoratorConfig = nodeType.decorators[i];
4614
- this.model.decorators.new(node, [node.coords[0] + decoratorConfig.coords[0], node.coords[1] + decoratorConfig.coords[1]], decoratorConfig.width, decoratorConfig.height, node.getPriority(), decoratorConfig.svg, `${node.id}_decorator_${i}`, decoratorConfig.anchorPointX || 'floating', decoratorConfig.anchorPointY || 'floating');
4660
+ __classPrivateFieldGet(this, _DiagramNodeSet_model, "f").decorators.new(node, [node.coords[0] + decoratorConfig.coords[0], node.coords[1] + decoratorConfig.coords[1]], decoratorConfig.width, decoratorConfig.height, node.getPriority(), decoratorConfig.svg, `${node.id}_decorator_${i}`, decoratorConfig.anchorPointX || 'floating', decoratorConfig.anchorPointY || 'floating');
4615
4661
  }
4616
4662
  }
4617
4663
  node.valueSet.resetValues();
@@ -4627,23 +4673,23 @@ class DiagramNodeSet extends DiagramElementSet {
4627
4673
  }
4628
4674
  // remove all children
4629
4675
  while (node.children.length > 0) {
4630
- this.model.nodes.remove(node.children[0].id);
4676
+ __classPrivateFieldGet(this, _DiagramNodeSet_model, "f").nodes.remove(node.children[0].id);
4631
4677
  }
4632
4678
  // remove all sections
4633
4679
  while (node.sections.length > 0) {
4634
- this.model.sections.remove(node.sections[0].id);
4680
+ __classPrivateFieldGet(this, _DiagramNodeSet_model, "f").sections.remove(node.sections[0].id);
4635
4681
  }
4636
4682
  // remove all ports
4637
4683
  while (node.ports.length > 0) {
4638
- this.model.ports.remove(node.ports[0].id);
4684
+ __classPrivateFieldGet(this, _DiagramNodeSet_model, "f").ports.remove(node.ports[0].id);
4639
4685
  }
4640
4686
  // remove all decorators
4641
4687
  while (node.decorators.length > 0) {
4642
- this.model.decorators.remove(node.decorators[0].id);
4688
+ __classPrivateFieldGet(this, _DiagramNodeSet_model, "f").decorators.remove(node.decorators[0].id);
4643
4689
  }
4644
4690
  // remove label
4645
4691
  if (node.label) {
4646
- this.model.fields.remove(node.label.id);
4692
+ __classPrivateFieldGet(this, _DiagramNodeSet_model, "f").fields.remove(node.label.id);
4647
4693
  }
4648
4694
  // remove from set of nodes
4649
4695
  super.remove(id);
@@ -4668,6 +4714,7 @@ class DiagramNodeSet extends DiagramElementSet {
4668
4714
  return nodesAtLocation;
4669
4715
  }
4670
4716
  }
4717
+ _DiagramNodeSet_model = new WeakMap();
4671
4718
  /**
4672
4719
  * Removes any nodes from the given list which are a descendant of another node in the list.
4673
4720
  * @param nodes A list of nodes.
@@ -4775,6 +4822,7 @@ const getTopPadding = config => {
4775
4822
  }
4776
4823
  };
4777
4824
 
4825
+ var _DiagramDecoratorSet_model;
4778
4826
  /**
4779
4827
  * A foreign object which is inserted with arbitrary SVG code into a diagram.
4780
4828
  * Similar to a diagram object, but it's part of a node or section and it moves and stretches as its geometry changes.
@@ -4833,7 +4881,8 @@ class DiagramDecoratorSet extends DiagramElementSet {
4833
4881
  */
4834
4882
  constructor(model) {
4835
4883
  super();
4836
- this.model = model;
4884
+ _DiagramDecoratorSet_model.set(this, void 0);
4885
+ __classPrivateFieldSet(this, _DiagramDecoratorSet_model, model, "f");
4837
4886
  }
4838
4887
  /**
4839
4888
  * Instance a new decorator and add it to this set.
@@ -4847,7 +4896,7 @@ class DiagramDecoratorSet extends DiagramElementSet {
4847
4896
  * @returns The instanced decorator.
4848
4897
  */
4849
4898
  new(rootElement, coords, width, height, priority, svg, id, anchorPointX = 'floating', anchorPointY = 'floating') {
4850
- const decorator = new DiagramDecorator(this.model, rootElement, coords, width, height, priority, svg, id, anchorPointX, anchorPointY);
4899
+ const decorator = new DiagramDecorator(__classPrivateFieldGet(this, _DiagramDecoratorSet_model, "f"), rootElement, coords, width, height, priority, svg, id, anchorPointX, anchorPointY);
4851
4900
  super.add(decorator);
4852
4901
  decorator.updateInView();
4853
4902
  // add this port to its root element
@@ -4870,7 +4919,9 @@ class DiagramDecoratorSet extends DiagramElementSet {
4870
4919
  }
4871
4920
  }
4872
4921
  }
4922
+ _DiagramDecoratorSet_model = new WeakMap();
4873
4923
 
4924
+ var _DiagramObjectSet_model;
4874
4925
  /**
4875
4926
  * A foreign object which is inserted with arbitrary SVG code into a diagram.
4876
4927
  * Diagram objects are not serialized with other diagram elements.
@@ -4922,7 +4973,8 @@ class DiagramObjectSet extends DiagramElementSet {
4922
4973
  */
4923
4974
  constructor(model) {
4924
4975
  super();
4925
- this.model = model;
4976
+ _DiagramObjectSet_model.set(this, void 0);
4977
+ __classPrivateFieldSet(this, _DiagramObjectSet_model, model, "f");
4926
4978
  }
4927
4979
  /**
4928
4980
  * Instance a new object and add it to this set.
@@ -4936,7 +4988,7 @@ class DiagramObjectSet extends DiagramElementSet {
4936
4988
  * @returns The instanced object.
4937
4989
  */
4938
4990
  new(coords, width, height, priority, svg, id) {
4939
- const object = new DiagramObject(this.model, coords, width, height, priority, svg, id);
4991
+ const object = new DiagramObject(__classPrivateFieldGet(this, _DiagramObjectSet_model, "f"), coords, width, height, priority, svg, id);
4940
4992
  super.add(object);
4941
4993
  object.updateInView();
4942
4994
  return object;
@@ -4951,7 +5003,9 @@ class DiagramObjectSet extends DiagramElementSet {
4951
5003
  }
4952
5004
  }
4953
5005
  }
5006
+ _DiagramObjectSet_model = new WeakMap();
4954
5007
 
5008
+ var _DiagramPort_type, _DiagramPortSet_model;
4955
5009
  /**
4956
5010
  * Default values of the look of a diagram port.
4957
5011
  * @private
@@ -5014,11 +5068,11 @@ class DiagramPortType {
5014
5068
  */
5015
5069
  class DiagramPort extends DiagramElement {
5016
5070
  get type() {
5017
- return this._type;
5071
+ return __classPrivateFieldGet(this, _DiagramPort_type, "f");
5018
5072
  }
5019
5073
  set type(type) {
5020
- if (type !== this._type) {
5021
- this._type = type;
5074
+ if (type !== __classPrivateFieldGet(this, _DiagramPort_type, "f")) {
5075
+ __classPrivateFieldSet(this, _DiagramPort_type, type, "f");
5022
5076
  this.updateInView();
5023
5077
  }
5024
5078
  }
@@ -5143,6 +5197,7 @@ class DiagramPort extends DiagramElement {
5143
5197
  throw new Error(`DiagramPort cannot have an empty or null id`);
5144
5198
  }
5145
5199
  super(model, id);
5200
+ _DiagramPort_type.set(this, void 0);
5146
5201
  /**
5147
5202
  * Connections that start at this port.
5148
5203
  * @public
@@ -5153,7 +5208,7 @@ class DiagramPort extends DiagramElement {
5153
5208
  * @public
5154
5209
  */
5155
5210
  this.incomingConnections = [];
5156
- this._type = type;
5211
+ __classPrivateFieldSet(this, _DiagramPort_type, type, "f");
5157
5212
  this.rootElement = rootElement;
5158
5213
  this.coords = coords;
5159
5214
  this.connectionPoint = connectionPoint || coords;
@@ -5241,6 +5296,7 @@ class DiagramPort extends DiagramElement {
5241
5296
  return distanceBetweenPoints(this.coords, coords);
5242
5297
  }
5243
5298
  }
5299
+ _DiagramPort_type = new WeakMap();
5244
5300
  class DiagramPortSet extends DiagramElementSet {
5245
5301
  /**
5246
5302
  * Instance a set of ports for the given model. This method is used internally.
@@ -5248,19 +5304,20 @@ class DiagramPortSet extends DiagramElementSet {
5248
5304
  */
5249
5305
  constructor(model) {
5250
5306
  super();
5307
+ _DiagramPortSet_model.set(this, void 0);
5251
5308
  /**
5252
5309
  * Set of the possible types of port that the ports of this set can have.
5253
5310
  * @public
5254
5311
  */
5255
5312
  this.types = new DiagramEntitySet();
5256
- this.model = model;
5313
+ __classPrivateFieldSet(this, _DiagramPortSet_model, model, "f");
5257
5314
  }
5258
5315
  /**
5259
5316
  * 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.
5260
5317
  * @private
5261
5318
  */
5262
5319
  new(type, rootElement, coords, connectionPoint, direction, id, anchorPointX = 'floating', anchorPointY = 'floating') {
5263
- const port = new DiagramPort(this.model, type, rootElement, coords, connectionPoint, direction, id, anchorPointX, anchorPointY);
5320
+ const port = new DiagramPort(__classPrivateFieldGet(this, _DiagramPortSet_model, "f"), type, rootElement, coords, connectionPoint, direction, id, anchorPointX, anchorPointY);
5264
5321
  super.add(port);
5265
5322
  port.updateInView();
5266
5323
  // add this port to its root element
@@ -5274,14 +5331,14 @@ class DiagramPortSet extends DiagramElementSet {
5274
5331
  if (port) {
5275
5332
  // remove all connections
5276
5333
  while (port.outgoingConnections.length > 0) {
5277
- this.model.connections.remove(port.outgoingConnections[0].id);
5334
+ __classPrivateFieldGet(this, _DiagramPortSet_model, "f").connections.remove(port.outgoingConnections[0].id);
5278
5335
  }
5279
5336
  while (port.incomingConnections.length > 0) {
5280
- this.model.connections.remove(port.incomingConnections[0].id);
5337
+ __classPrivateFieldGet(this, _DiagramPortSet_model, "f").connections.remove(port.incomingConnections[0].id);
5281
5338
  }
5282
5339
  // remove label
5283
5340
  if (port.label) {
5284
- this.model.fields.remove(port.label.id);
5341
+ __classPrivateFieldGet(this, _DiagramPortSet_model, "f").fields.remove(port.label.id);
5285
5342
  }
5286
5343
  // remove from root element
5287
5344
  if (port.rootElement instanceof DiagramNode || port.rootElement instanceof DiagramSection) {
@@ -5294,6 +5351,7 @@ class DiagramPortSet extends DiagramElementSet {
5294
5351
  }
5295
5352
  }
5296
5353
  }
5354
+ _DiagramPortSet_model = new WeakMap();
5297
5355
 
5298
5356
  /**
5299
5357
  * Importer which imports a diagram from its daga model representation.
@@ -5530,6 +5588,7 @@ class DagaImporter {
5530
5588
  }
5531
5589
  }
5532
5590
 
5591
+ var _SetSelfRemovedCollabAction_instances, _SetSelfRemovedCollabAction_doOne;
5533
5592
  /**
5534
5593
  * Collaborative action which consists of adding a node.
5535
5594
  * @private
@@ -5559,6 +5618,7 @@ class AddNodeCollabAction {
5559
5618
  } else {
5560
5619
  node.valueSet.resetValues();
5561
5620
  }
5621
+ node.raiseWithZ();
5562
5622
  }
5563
5623
  serialize() {
5564
5624
  return {
@@ -5717,6 +5777,7 @@ class SetGeometryCollabAction {
5717
5777
  }
5718
5778
  }
5719
5779
  (_c = node.parent) === null || _c === void 0 ? void 0 : _c.fitToChild(node);
5780
+ node.raiseWithZ();
5720
5781
  node.geometryTimestamp = this.timestamp;
5721
5782
  }
5722
5783
  }
@@ -5881,6 +5942,7 @@ class UpdateValuesCollabAction {
5881
5942
  */
5882
5943
  class SetSelfRemovedCollabAction {
5883
5944
  constructor(canvas, nodeIds, sectionIds, portIds, connectionIds, fieldIds, selfRemoved, timestamp) {
5945
+ _SetSelfRemovedCollabAction_instances.add(this);
5884
5946
  this.canvas = canvas;
5885
5947
  this.nodeIds = nodeIds;
5886
5948
  this.sectionIds = sectionIds;
@@ -5890,27 +5952,21 @@ class SetSelfRemovedCollabAction {
5890
5952
  this.selfRemoved = selfRemoved;
5891
5953
  this.timestamp = timestamp;
5892
5954
  }
5893
- doOne(elt) {
5894
- if (elt && timestampWins(this.timestamp, elt.selfRemovedTimestamp)) {
5895
- elt.selfRemoved = this.selfRemoved;
5896
- elt.selfRemovedTimestamp = this.timestamp;
5897
- }
5898
- }
5899
5955
  do() {
5900
5956
  for (const nodeId of this.nodeIds) {
5901
- this.doOne(this.canvas.model.nodes.get(nodeId, true));
5957
+ __classPrivateFieldGet(this, _SetSelfRemovedCollabAction_instances, "m", _SetSelfRemovedCollabAction_doOne).call(this, this.canvas.model.nodes.get(nodeId, true));
5902
5958
  }
5903
5959
  for (const sectionId of this.sectionIds) {
5904
- this.doOne(this.canvas.model.sections.get(sectionId, true));
5960
+ __classPrivateFieldGet(this, _SetSelfRemovedCollabAction_instances, "m", _SetSelfRemovedCollabAction_doOne).call(this, this.canvas.model.sections.get(sectionId, true));
5905
5961
  }
5906
5962
  for (const portId of this.portIds) {
5907
- this.doOne(this.canvas.model.ports.get(portId, true));
5963
+ __classPrivateFieldGet(this, _SetSelfRemovedCollabAction_instances, "m", _SetSelfRemovedCollabAction_doOne).call(this, this.canvas.model.ports.get(portId, true));
5908
5964
  }
5909
5965
  for (const connectionId of this.connectionIds) {
5910
- this.doOne(this.canvas.model.connections.get(connectionId, true));
5966
+ __classPrivateFieldGet(this, _SetSelfRemovedCollabAction_instances, "m", _SetSelfRemovedCollabAction_doOne).call(this, this.canvas.model.connections.get(connectionId, true));
5911
5967
  }
5912
5968
  for (const fieldId of this.fieldIds) {
5913
- this.doOne(this.canvas.model.fields.get(fieldId, true));
5969
+ __classPrivateFieldGet(this, _SetSelfRemovedCollabAction_instances, "m", _SetSelfRemovedCollabAction_doOne).call(this, this.canvas.model.fields.get(fieldId, true));
5914
5970
  }
5915
5971
  // update view
5916
5972
  this.canvas.updateNodesInView(...this.nodeIds);
@@ -5937,6 +5993,12 @@ class SetSelfRemovedCollabAction {
5937
5993
  return new SetSelfRemovedCollabAction(canvas, serialized.nodeIds, serialized.sectionIds, serialized.portIds, serialized.connectionIds, serialized.fieldIds, serialized.removed, serialized.timestamp);
5938
5994
  }
5939
5995
  }
5996
+ _SetSelfRemovedCollabAction_instances = new WeakSet(), _SetSelfRemovedCollabAction_doOne = function _SetSelfRemovedCollabAction_doOne(elt) {
5997
+ if (elt && timestampWins(this.timestamp, elt.selfRemovedTimestamp)) {
5998
+ elt.selfRemoved = this.selfRemoved;
5999
+ elt.selfRemovedTimestamp = this.timestamp;
6000
+ }
6001
+ };
5940
6002
  /**
5941
6003
  * Collaborative action which consists of pasting elements from an external source into a diagram.
5942
6004
  *
@@ -6108,13 +6170,19 @@ class CollabEngine {
6108
6170
  }
6109
6171
  }
6110
6172
 
6173
+ var _ActionStack_canvas;
6111
6174
  /**
6112
6175
  * A stack of recent actions taken by the user.
6113
6176
  * @private
6114
6177
  */
6115
6178
  class ActionStack {
6116
6179
  constructor(canvas, maximum) {
6117
- this.canvas = canvas;
6180
+ /**
6181
+ * Canvas that this action stack belongs to.
6182
+ * @private
6183
+ */
6184
+ _ActionStack_canvas.set(this, void 0);
6185
+ __classPrivateFieldSet(this, _ActionStack_canvas, canvas, "f");
6118
6186
  this.maximum = maximum;
6119
6187
  this.history = [];
6120
6188
  this.index = 0;
@@ -6134,7 +6202,7 @@ class ActionStack {
6134
6202
  this.history.push(action);
6135
6203
  ++this.index;
6136
6204
  }
6137
- this.canvas.diagramChange$.next({
6205
+ __classPrivateFieldGet(this, _ActionStack_canvas, "f").diagramChange$.next({
6138
6206
  action,
6139
6207
  method: DiagramActionMethod.Do
6140
6208
  });
@@ -6153,7 +6221,7 @@ class ActionStack {
6153
6221
  hasEffect = action.undo();
6154
6222
  } while (!hasEffect && this.index > 0);
6155
6223
  }
6156
- this.canvas.diagramChange$.next({
6224
+ __classPrivateFieldGet(this, _ActionStack_canvas, "f").diagramChange$.next({
6157
6225
  action,
6158
6226
  method: DiagramActionMethod.Undo
6159
6227
  });
@@ -6172,12 +6240,13 @@ class ActionStack {
6172
6240
  ++this.index;
6173
6241
  } while (!hasEffect && this.index < this.history.length);
6174
6242
  }
6175
- this.canvas.diagramChange$.next({
6243
+ __classPrivateFieldGet(this, _ActionStack_canvas, "f").diagramChange$.next({
6176
6244
  action,
6177
6245
  method: DiagramActionMethod.Redo
6178
6246
  });
6179
6247
  }
6180
6248
  }
6249
+ _ActionStack_canvas = new WeakMap();
6181
6250
  /**
6182
6251
  * The different methods of an action.
6183
6252
  * @private
@@ -6947,14 +7016,28 @@ class DiagramModel {
6947
7016
  }
6948
7017
 
6949
7018
  /**
6950
- * Checks if the given mouse event was produced with a secondary button press.
7019
+ * Checks if the given pointer event was produced with a secondary button press.
6951
7020
  * @private
6952
- * @param event A mouse event.
6953
- * @returns `true` if the given mouse event was produced with a secondary button press, `false` otherwise.
7021
+ * @param event A pointer event.
7022
+ * @returns `true` if the given pointer event was produced with a secondary button press, `false` otherwise.
6954
7023
  */
6955
7024
  const isSecondaryButton = event => {
6956
7025
  return !!event.button;
6957
7026
  };
7027
+ /**
7028
+ * Obtain the pointer event which is valid for passing to the `d3.pointer()` function.
7029
+ * @param event A pointer event.
7030
+ * @returns A pointer event which can be passed to the `d3.pointer()` function.
7031
+ */
7032
+ const getEventHoldingCoordinates = event => {
7033
+ if (event.type === 'drag' || event.type === 'start' || event.type === 'end') {
7034
+ const sourceEvent = event.sourceEvent;
7035
+ if (sourceEvent && (sourceEvent.type === 'touchmove' || sourceEvent.type === 'touchstart' || sourceEvent.type === 'touchend')) {
7036
+ return sourceEvent.touches[0] || sourceEvent.changedTouches[0];
7037
+ }
7038
+ }
7039
+ return event;
7040
+ };
6958
7041
  /**
6959
7042
  * Get the SVG path of a diagram connection.
6960
7043
  * @private
@@ -7161,6 +7244,7 @@ const getGridSpacingY = gridConfig => {
7161
7244
  return value;
7162
7245
  };
7163
7246
 
7247
+ var _DiagramContextMenu_canvas, _DiagramContextMenu_config, _DiagramContextMenu_contextMenuContainer;
7164
7248
  const CONTEXT_MENU_MENU_RADIUS = 96;
7165
7249
  const CONTEXT_MENU_BUTTON_RADIUS = 32;
7166
7250
  const CONTEXT_MENU_TOTAL_RADIUS = CONTEXT_MENU_MENU_RADIUS + CONTEXT_MENU_BUTTON_RADIUS;
@@ -7181,8 +7265,11 @@ class DiagramContextMenu {
7181
7265
  * @param canvas A canvas.
7182
7266
  */
7183
7267
  constructor(canvas, config) {
7184
- this.canvas = canvas;
7185
- this.config = config || CONTEXT_MENU_DEFAULTS;
7268
+ _DiagramContextMenu_canvas.set(this, void 0);
7269
+ _DiagramContextMenu_config.set(this, void 0);
7270
+ _DiagramContextMenu_contextMenuContainer.set(this, void 0);
7271
+ __classPrivateFieldSet(this, _DiagramContextMenu_canvas, canvas, "f");
7272
+ __classPrivateFieldSet(this, _DiagramContextMenu_config, config || CONTEXT_MENU_DEFAULTS, "f");
7186
7273
  }
7187
7274
  /**
7188
7275
  * Opens the context menu at the location determined by the given mouse event.
@@ -7191,11 +7278,11 @@ class DiagramContextMenu {
7191
7278
  */
7192
7279
  open(event) {
7193
7280
  this.close();
7194
- const coordsRelativeToRoot = this.canvas.getPointerLocationRelativeToRoot(event);
7195
- const coordsRelativeToCanvas = this.canvas.getPointerLocationRelativeToCanvas(event);
7281
+ const coordsRelativeToRoot = __classPrivateFieldGet(this, _DiagramContextMenu_canvas, "f").getPointerLocationRelativeToRoot(event);
7282
+ const coordsRelativeToCanvas = __classPrivateFieldGet(this, _DiagramContextMenu_canvas, "f").getPointerLocationRelativeToCanvas(event);
7196
7283
  // append to the root (svg) element so the context menu is not affected by zoom transforms on the canvas view
7197
- const contextMenuContainer = this.canvas.selectSVGElement().append('foreignObject').attr('class', 'daga-context-menu').attr('x', `${coordsRelativeToRoot[0] - CONTEXT_MENU_TOTAL_RADIUS}px`).attr('y', `${coordsRelativeToRoot[1] - CONTEXT_MENU_TOTAL_RADIUS}px`).attr('width', `${2 * CONTEXT_MENU_TOTAL_RADIUS}px`).attr('height', `${2 * CONTEXT_MENU_TOTAL_RADIUS}px`).style('pointer-events', 'none').on(Events.ContextMenu, newEvent => {
7198
- if (this.canvas.canUserPerformAction(DiagramActions.ContextMenu)) {
7284
+ const contextMenuContainer = __classPrivateFieldGet(this, _DiagramContextMenu_canvas, "f").selectSVGElement().append('foreignObject').attr('class', 'daga-context-menu').attr('x', `${coordsRelativeToRoot[0] - CONTEXT_MENU_TOTAL_RADIUS}px`).attr('y', `${coordsRelativeToRoot[1] - CONTEXT_MENU_TOTAL_RADIUS}px`).attr('width', `${2 * CONTEXT_MENU_TOTAL_RADIUS}px`).attr('height', `${2 * CONTEXT_MENU_TOTAL_RADIUS}px`).style('pointer-events', 'none').on(Events.ContextMenu, newEvent => {
7285
+ if (__classPrivateFieldGet(this, _DiagramContextMenu_canvas, "f").canUserPerformAction(DiagramActions.ContextMenu)) {
7199
7286
  event.preventDefault();
7200
7287
  this.open(newEvent);
7201
7288
  }
@@ -7203,9 +7290,9 @@ class DiagramContextMenu {
7203
7290
  event.preventDefault();
7204
7291
  this.close();
7205
7292
  });
7206
- this.contextMenuContainer = contextMenuContainer;
7293
+ __classPrivateFieldSet(this, _DiagramContextMenu_contextMenuContainer, contextMenuContainer, "f");
7207
7294
  const buttons = [];
7208
- if (!(this.canvas.userSelection.length === 0) && this.canvas.canUserPerformAction(DiagramActions.Clipboard) && this.canvas.canUserPerformAction(DiagramActions.Remove)) {
7295
+ if (!(__classPrivateFieldGet(this, _DiagramContextMenu_canvas, "f").userSelection.length === 0) && __classPrivateFieldGet(this, _DiagramContextMenu_canvas, "f").canUserPerformAction(DiagramActions.Clipboard) && __classPrivateFieldGet(this, _DiagramContextMenu_canvas, "f").canUserPerformAction(DiagramActions.Remove)) {
7209
7296
  buttons.push({
7210
7297
  name: 'CUT',
7211
7298
  imageClass: 'daga-cut',
@@ -7215,7 +7302,7 @@ class DiagramContextMenu {
7215
7302
  }
7216
7303
  });
7217
7304
  }
7218
- if (!(this.canvas.userSelection.length === 0) && this.canvas.canUserPerformAction(DiagramActions.Clipboard)) {
7305
+ if (!(__classPrivateFieldGet(this, _DiagramContextMenu_canvas, "f").userSelection.length === 0) && __classPrivateFieldGet(this, _DiagramContextMenu_canvas, "f").canUserPerformAction(DiagramActions.Clipboard)) {
7219
7306
  buttons.push({
7220
7307
  name: 'COPY',
7221
7308
  imageClass: 'daga-copy',
@@ -7225,7 +7312,7 @@ class DiagramContextMenu {
7225
7312
  }
7226
7313
  });
7227
7314
  }
7228
- if (this.canvas.canUserPerformAction(DiagramActions.Paste)) {
7315
+ if (__classPrivateFieldGet(this, _DiagramContextMenu_canvas, "f").canUserPerformAction(DiagramActions.Paste)) {
7229
7316
  buttons.push({
7230
7317
  name: 'PASTE',
7231
7318
  imageClass: 'daga-paste',
@@ -7235,7 +7322,7 @@ class DiagramContextMenu {
7235
7322
  }
7236
7323
  });
7237
7324
  }
7238
- if (!(this.canvas.userSelection.length === 0) && this.canvas.canUserPerformAction(DiagramActions.Remove)) {
7325
+ if (!(__classPrivateFieldGet(this, _DiagramContextMenu_canvas, "f").userSelection.length === 0) && __classPrivateFieldGet(this, _DiagramContextMenu_canvas, "f").canUserPerformAction(DiagramActions.Remove)) {
7239
7326
  buttons.push({
7240
7327
  name: 'DELETE',
7241
7328
  imageClass: 'daga-delete',
@@ -7245,8 +7332,8 @@ class DiagramContextMenu {
7245
7332
  }
7246
7333
  });
7247
7334
  }
7248
- for (const customButton of this.config.customButtons || CONTEXT_MENU_DEFAULTS.customButtons) {
7249
- if (customButton.condition !== undefined ? customButton.condition(this.canvas) : true) {
7335
+ for (const customButton of __classPrivateFieldGet(this, _DiagramContextMenu_config, "f").customButtons || CONTEXT_MENU_DEFAULTS.customButtons) {
7336
+ if (customButton.condition !== undefined ? customButton.condition(__classPrivateFieldGet(this, _DiagramContextMenu_canvas, "f")) : true) {
7250
7337
  buttons.push(customButton);
7251
7338
  }
7252
7339
  }
@@ -7265,12 +7352,12 @@ class DiagramContextMenu {
7265
7352
  const buttonContainer = contextMenuContainer.append('xhtml:div').attr('class', `daga-context-menu-button ${button.onPress !== undefined ? ' daga-clickable' : ''}`).attr('tabindex', 0).style('position', 'absolute').style('box-sizing', 'border-box').style('width', `${2 * CONTEXT_MENU_BUTTON_RADIUS}px`).style('height', `${2 * CONTEXT_MENU_BUTTON_RADIUS}px`).style('border-radius', `${CONTEXT_MENU_BUTTON_RADIUS}px`).style('pointer-events', 'auto').on(Events.Click, event => {
7266
7353
  if (buttonOnPress) {
7267
7354
  event.preventDefault();
7268
- buttonOnPress(this.canvas);
7355
+ buttonOnPress(__classPrivateFieldGet(this, _DiagramContextMenu_canvas, "f"));
7269
7356
  }
7270
7357
  }).on(Events.KeyDown, event => {
7271
7358
  if (buttonOnPress && event.key === Keys.Enter) {
7272
7359
  event.preventDefault();
7273
- buttonOnPress(this.canvas);
7360
+ buttonOnPress(__classPrivateFieldGet(this, _DiagramContextMenu_canvas, "f"));
7274
7361
  }
7275
7362
  });
7276
7363
  if (button.imageClass !== undefined) {
@@ -7293,11 +7380,13 @@ class DiagramContextMenu {
7293
7380
  */
7294
7381
  close() {
7295
7382
  var _a;
7296
- (_a = this.contextMenuContainer) === null || _a === void 0 ? void 0 : _a.remove();
7297
- this.contextMenuContainer = undefined;
7383
+ (_a = __classPrivateFieldGet(this, _DiagramContextMenu_contextMenuContainer, "f")) === null || _a === void 0 ? void 0 : _a.remove();
7384
+ __classPrivateFieldSet(this, _DiagramContextMenu_contextMenuContainer, undefined, "f");
7298
7385
  }
7299
7386
  }
7387
+ _DiagramContextMenu_canvas = new WeakMap(), _DiagramContextMenu_config = new WeakMap(), _DiagramContextMenu_contextMenuContainer = new WeakMap();
7300
7388
 
7389
+ var _DiagramUserHighlight_canvas, _DiagramUserHighlight_focus, _DiagramUserHighlight_highlightSections;
7301
7390
  /**
7302
7391
  * Stores the functionality regarding the user highlight of a diagram canvas.
7303
7392
  * @public
@@ -7311,9 +7400,14 @@ class DiagramUserHighlight extends DiagramElementSet {
7311
7400
  */
7312
7401
  constructor(canvas, highlightSections = true) {
7313
7402
  super();
7314
- this.focus = undefined;
7315
- this.canvas = canvas;
7316
- this.highlightSections = highlightSections;
7403
+ _DiagramUserHighlight_canvas.set(this, void 0);
7404
+ _DiagramUserHighlight_focus.set(this, undefined);
7405
+ /**
7406
+ * Whether sections can be highlighted individually or the whole node must be highlighted when highlighting a section.
7407
+ */
7408
+ _DiagramUserHighlight_highlightSections.set(this, void 0);
7409
+ __classPrivateFieldSet(this, _DiagramUserHighlight_canvas, canvas, "f");
7410
+ __classPrivateFieldSet(this, _DiagramUserHighlight_highlightSections, highlightSections, "f");
7317
7411
  }
7318
7412
  /**
7319
7413
  * Gets the focus of the user highlight, which is the element where the current user highlight started regardless of which other elements were highlighted as a consequence.
@@ -7321,7 +7415,7 @@ class DiagramUserHighlight extends DiagramElementSet {
7321
7415
  * @returns A diagram element.
7322
7416
  */
7323
7417
  getFocus() {
7324
- return this.focus;
7418
+ return __classPrivateFieldGet(this, _DiagramUserHighlight_focus, "f");
7325
7419
  }
7326
7420
  /**
7327
7421
  * Unhighlights all highlighted elements and highlights the given element as the main element of the user highlight.
@@ -7329,7 +7423,7 @@ class DiagramUserHighlight extends DiagramElementSet {
7329
7423
  */
7330
7424
  focusOn(element) {
7331
7425
  this.clear();
7332
- this.focus = element;
7426
+ __classPrivateFieldSet(this, _DiagramUserHighlight_focus, element, "f");
7333
7427
  if ((element instanceof DiagramField || element instanceof DiagramDecorator) && element.rootElement) {
7334
7428
  this.focusOn(element.rootElement);
7335
7429
  } else {
@@ -7339,51 +7433,51 @@ class DiagramUserHighlight extends DiagramElementSet {
7339
7433
  add(element) {
7340
7434
  super.add(element);
7341
7435
  if (element instanceof DiagramNode) {
7342
- if (!this.highlightSections) {
7436
+ if (!__classPrivateFieldGet(this, _DiagramUserHighlight_highlightSections, "f")) {
7343
7437
  for (const section of element.sections) {
7344
7438
  super.add(section);
7345
7439
  for (const port of section.ports) {
7346
7440
  super.add(port);
7347
- this.canvas.updatePortsInView(port.id);
7441
+ __classPrivateFieldGet(this, _DiagramUserHighlight_canvas, "f").updatePortsInView(port.id);
7348
7442
  }
7349
7443
  if (section.label) {
7350
7444
  super.add(section.label);
7351
- this.canvas.updateFieldsInView(section.label.id);
7445
+ __classPrivateFieldGet(this, _DiagramUserHighlight_canvas, "f").updateFieldsInView(section.label.id);
7352
7446
  }
7353
- this.canvas.updateSectionsInView(section.id);
7447
+ __classPrivateFieldGet(this, _DiagramUserHighlight_canvas, "f").updateSectionsInView(section.id);
7354
7448
  }
7355
7449
  }
7356
7450
  for (const port of element.ports) {
7357
7451
  super.add(port);
7358
- this.canvas.updatePortsInView(port.id);
7452
+ __classPrivateFieldGet(this, _DiagramUserHighlight_canvas, "f").updatePortsInView(port.id);
7359
7453
  }
7360
7454
  if (element.label) {
7361
7455
  super.add(element.label);
7362
- this.canvas.updateFieldsInView(element.label.id);
7456
+ __classPrivateFieldGet(this, _DiagramUserHighlight_canvas, "f").updateFieldsInView(element.label.id);
7363
7457
  }
7364
- this.canvas.updateNodesInView(element.id);
7458
+ __classPrivateFieldGet(this, _DiagramUserHighlight_canvas, "f").updateNodesInView(element.id);
7365
7459
  } else if (element instanceof DiagramSection) {
7366
- if (!this.highlightSections && element.node) {
7460
+ if (!__classPrivateFieldGet(this, _DiagramUserHighlight_highlightSections, "f") && element.node) {
7367
7461
  this.add(element.node);
7368
7462
  } else {
7369
7463
  for (const port of element.ports) {
7370
7464
  super.add(port);
7371
- this.canvas.updatePortsInView(port.id);
7465
+ __classPrivateFieldGet(this, _DiagramUserHighlight_canvas, "f").updatePortsInView(port.id);
7372
7466
  }
7373
7467
  if (element.label) {
7374
7468
  super.add(element.label);
7375
- this.canvas.updateFieldsInView(element.label.id);
7469
+ __classPrivateFieldGet(this, _DiagramUserHighlight_canvas, "f").updateFieldsInView(element.label.id);
7376
7470
  }
7377
- this.canvas.updateSectionsInView(element.id);
7471
+ __classPrivateFieldGet(this, _DiagramUserHighlight_canvas, "f").updateSectionsInView(element.id);
7378
7472
  }
7379
7473
  } else if (element instanceof DiagramPort) {
7380
7474
  if (element.label) {
7381
7475
  super.add(element.label);
7382
- this.canvas.updateFieldsInView(element.label.id);
7476
+ __classPrivateFieldGet(this, _DiagramUserHighlight_canvas, "f").updateFieldsInView(element.label.id);
7383
7477
  }
7384
- this.canvas.updatePortsInView(element.id);
7478
+ __classPrivateFieldGet(this, _DiagramUserHighlight_canvas, "f").updatePortsInView(element.id);
7385
7479
  } else if (element instanceof DiagramConnection) {
7386
- this.canvas.updateConnectionsInView(element.id);
7480
+ __classPrivateFieldGet(this, _DiagramUserHighlight_canvas, "f").updateConnectionsInView(element.id);
7387
7481
  }
7388
7482
  }
7389
7483
  clear() {
@@ -7392,9 +7486,10 @@ class DiagramUserHighlight extends DiagramElementSet {
7392
7486
  this.remove(entity.id);
7393
7487
  entity.updateInView();
7394
7488
  }
7395
- this.focus = undefined;
7489
+ __classPrivateFieldSet(this, _DiagramUserHighlight_focus, undefined, "f");
7396
7490
  }
7397
7491
  }
7492
+ _DiagramUserHighlight_canvas = new WeakMap(), _DiagramUserHighlight_focus = new WeakMap(), _DiagramUserHighlight_highlightSections = new WeakMap();
7398
7493
 
7399
7494
  const DAGA_FILE_VERSION = 1;
7400
7495
 
@@ -7606,6 +7701,7 @@ class DagaExporter {
7606
7701
  }
7607
7702
  }
7608
7703
 
7704
+ var _DiagramUserSelection_instances, _DiagramUserSelection_canvas, _DiagramUserSelection_diagramPropertiesText, _DiagramUserSelection_propertyEditorSelection, _DiagramUserSelection_propertyEditorValues, _DiagramUserSelection_makeUpdateValuesAction;
7609
7705
  /**
7610
7706
  * Text to display by default as the title of the property editor when editing the properties of a diagram's value set.
7611
7707
  * @private
@@ -7626,12 +7722,17 @@ class DiagramUserSelection extends DiagramElementSet {
7626
7722
  */
7627
7723
  constructor(canvas, diagramPropertiesText) {
7628
7724
  super();
7629
- this.canvas = canvas;
7725
+ _DiagramUserSelection_instances.add(this);
7726
+ _DiagramUserSelection_canvas.set(this, void 0);
7727
+ _DiagramUserSelection_diagramPropertiesText.set(this, void 0);
7728
+ _DiagramUserSelection_propertyEditorSelection.set(this, void 0);
7729
+ _DiagramUserSelection_propertyEditorValues.set(this, void 0);
7730
+ __classPrivateFieldSet(this, _DiagramUserSelection_canvas, canvas, "f");
7630
7731
  // TODO: would be a good idea to be able to configure how often this fires, or whether at all
7631
- this.canvas.propertyEditorChanges$.pipe(debounceTime(2000)).subscribe(() => {
7632
- this.makeUpdateValuesAction();
7732
+ __classPrivateFieldGet(this, _DiagramUserSelection_canvas, "f").propertyEditorChanges$.pipe(debounceTime(2000)).subscribe(() => {
7733
+ __classPrivateFieldGet(this, _DiagramUserSelection_instances, "m", _DiagramUserSelection_makeUpdateValuesAction).call(this);
7633
7734
  });
7634
- this.diagramPropertiesText = diagramPropertiesText !== undefined ? diagramPropertiesText : DIAGRAM_PROPERTIES_DEFAULT_TEXT;
7735
+ __classPrivateFieldSet(this, _DiagramUserSelection_diagramPropertiesText, diagramPropertiesText !== undefined ? diagramPropertiesText : DIAGRAM_PROPERTIES_DEFAULT_TEXT, "f");
7635
7736
  }
7636
7737
  add(element) {
7637
7738
  if (this.contains(element.id)) {
@@ -7640,9 +7741,9 @@ class DiagramUserSelection extends DiagramElementSet {
7640
7741
  }
7641
7742
  if (this.length === 0) {
7642
7743
  // if there is nothing else selected, open our selection in the property editor
7643
- if (this.propertyEditorSelection === undefined && (element instanceof DiagramNode || element instanceof DiagramConnection)) {
7744
+ if (__classPrivateFieldGet(this, _DiagramUserSelection_propertyEditorSelection, "f") === undefined && (element instanceof DiagramNode || element instanceof DiagramConnection)) {
7644
7745
  this.openInPropertyEditor(element);
7645
- } else if (this.propertyEditorSelection === undefined && element instanceof DiagramSection) {
7746
+ } else if (__classPrivateFieldGet(this, _DiagramUserSelection_propertyEditorSelection, "f") === undefined && element instanceof DiagramSection) {
7646
7747
  this.openInPropertyEditor(element.node);
7647
7748
  } else {
7648
7749
  this.openInPropertyEditor(undefined);
@@ -7664,7 +7765,7 @@ class DiagramUserSelection extends DiagramElementSet {
7664
7765
  remove(id) {
7665
7766
  const element = this.get(id);
7666
7767
  if (element) {
7667
- if (this.propertyEditorSelection === element) {
7768
+ if (__classPrivateFieldGet(this, _DiagramUserSelection_propertyEditorSelection, "f") === element) {
7668
7769
  this.openInPropertyEditor(undefined);
7669
7770
  }
7670
7771
  super.remove(id);
@@ -7735,9 +7836,9 @@ class DiagramUserSelection extends DiagramElementSet {
7735
7836
  fieldIdsToBeDeleted.push(userSelectionElement.id);
7736
7837
  }
7737
7838
  }
7738
- const removeAction = new RemoveAction(this.canvas, nodeIdsToBeDeleted, sectionIdsToBeDeleted, portIdsToBeDeleted, connectionIdsToBeDeleted, fieldIdsToBeDeleted);
7839
+ const removeAction = new RemoveAction(__classPrivateFieldGet(this, _DiagramUserSelection_canvas, "f"), nodeIdsToBeDeleted, sectionIdsToBeDeleted, portIdsToBeDeleted, connectionIdsToBeDeleted, fieldIdsToBeDeleted);
7739
7840
  removeAction.do();
7740
- this.canvas.actionStack.add(removeAction);
7841
+ __classPrivateFieldGet(this, _DiagramUserSelection_canvas, "f").actionStack.add(removeAction);
7741
7842
  }
7742
7843
  }
7743
7844
  /**
@@ -7780,8 +7881,8 @@ class DiagramUserSelection extends DiagramElementSet {
7780
7881
  if (userSelection.type !== 'daga-user-selection') {
7781
7882
  return;
7782
7883
  }
7783
- const action = new PasteAction(this.canvas, userSelection.nodes, userSelection.connections, coords);
7784
- this.canvas.actionStack.add(action);
7884
+ const action = new PasteAction(__classPrivateFieldGet(this, _DiagramUserSelection_canvas, "f"), userSelection.nodes, userSelection.connections, coords);
7885
+ __classPrivateFieldGet(this, _DiagramUserSelection_canvas, "f").actionStack.add(action);
7785
7886
  action.do();
7786
7887
  } catch (_a) {
7787
7888
  return;
@@ -7799,17 +7900,17 @@ class DiagramUserSelection extends DiagramElementSet {
7799
7900
  openInPropertyEditor(selection, makeUpdateValuesAction = true) {
7800
7901
  var _a;
7801
7902
  if (makeUpdateValuesAction) {
7802
- this.makeUpdateValuesAction();
7903
+ __classPrivateFieldGet(this, _DiagramUserSelection_instances, "m", _DiagramUserSelection_makeUpdateValuesAction).call(this);
7803
7904
  }
7804
- const propertyEditor = (_a = this.canvas.parentComponent) === null || _a === void 0 ? void 0 : _a.propertyEditor;
7905
+ const propertyEditor = (_a = __classPrivateFieldGet(this, _DiagramUserSelection_canvas, "f").parentComponent) === null || _a === void 0 ? void 0 : _a.propertyEditor;
7805
7906
  if (propertyEditor === undefined) {
7806
7907
  return;
7807
7908
  }
7808
7909
  const selectedValueSet = selection === null || selection === void 0 ? void 0 : selection.valueSet;
7809
7910
  if (selectedValueSet) {
7810
- this.propertyEditorSelection = selection;
7911
+ __classPrivateFieldSet(this, _DiagramUserSelection_propertyEditorSelection, selection, "f");
7811
7912
  if (makeUpdateValuesAction) {
7812
- this.propertyEditorValues = clone(selectedValueSet.getValues());
7913
+ __classPrivateFieldSet(this, _DiagramUserSelection_propertyEditorValues, clone(selectedValueSet.getValues()), "f");
7813
7914
  }
7814
7915
  if (propertyEditor) {
7815
7916
  if (selection instanceof DiagramNode || selection instanceof DiagramConnection) {
@@ -7826,42 +7927,43 @@ class DiagramUserSelection extends DiagramElementSet {
7826
7927
  propertyEditor.valueSet = undefined;
7827
7928
  propertyEditor.valueSet = selectedValueSet;
7828
7929
  } else {
7829
- propertyEditor.title = this.diagramPropertiesText;
7930
+ propertyEditor.title = __classPrivateFieldGet(this, _DiagramUserSelection_diagramPropertiesText, "f");
7830
7931
  // force the update of the valueSet
7831
7932
  propertyEditor.valueSet = undefined;
7832
7933
  propertyEditor.valueSet = selectedValueSet;
7833
7934
  }
7834
7935
  }
7835
7936
  } else {
7836
- this.propertyEditorSelection = undefined;
7837
- this.propertyEditorValues = undefined;
7937
+ __classPrivateFieldSet(this, _DiagramUserSelection_propertyEditorSelection, undefined, "f");
7938
+ __classPrivateFieldSet(this, _DiagramUserSelection_propertyEditorValues, undefined, "f");
7838
7939
  if (propertyEditor) {
7839
7940
  propertyEditor.title = '';
7840
7941
  propertyEditor.valueSet = undefined;
7841
7942
  }
7842
7943
  }
7843
7944
  }
7844
- makeUpdateValuesAction() {
7845
- var _a, _b, _c;
7846
- if (this.propertyEditorSelection === undefined || this.propertyEditorValues === undefined) {
7847
- return;
7848
- }
7849
- const previousSelectionId = this.propertyEditorSelection instanceof DiagramModel ? undefined : this.propertyEditorSelection.id;
7850
- // check if there have been changes in the previously selected ValueSet,
7851
- // and create an UpdateValuesAction if there have
7852
- if (equals(this.propertyEditorValues, (_a = this.propertyEditorSelection) === null || _a === void 0 ? void 0 : _a.valueSet.getValues())) {
7853
- return;
7854
- }
7855
- const from = this.propertyEditorValues;
7856
- const to = clone((_b = this.propertyEditorSelection) === null || _b === void 0 ? void 0 : _b.valueSet.getValues());
7857
- const [fromDiff, toDiff] = diffProperties(from, to, (_c = this.propertyEditorSelection) === null || _c === void 0 ? void 0 : _c.valueSet);
7858
- const currentAction = new UpdateValuesAction(this.canvas, previousSelectionId, fromDiff, toDiff);
7859
- currentAction.do();
7860
- this.canvas.actionStack.add(currentAction);
7861
- this.propertyEditorValues = to;
7862
- }
7863
7945
  }
7946
+ _DiagramUserSelection_canvas = new WeakMap(), _DiagramUserSelection_diagramPropertiesText = new WeakMap(), _DiagramUserSelection_propertyEditorSelection = new WeakMap(), _DiagramUserSelection_propertyEditorValues = new WeakMap(), _DiagramUserSelection_instances = new WeakSet(), _DiagramUserSelection_makeUpdateValuesAction = function _DiagramUserSelection_makeUpdateValuesAction() {
7947
+ var _a, _b, _c;
7948
+ if (__classPrivateFieldGet(this, _DiagramUserSelection_propertyEditorSelection, "f") === undefined || __classPrivateFieldGet(this, _DiagramUserSelection_propertyEditorValues, "f") === undefined) {
7949
+ return;
7950
+ }
7951
+ const previousSelectionId = __classPrivateFieldGet(this, _DiagramUserSelection_propertyEditorSelection, "f") instanceof DiagramModel ? undefined : __classPrivateFieldGet(this, _DiagramUserSelection_propertyEditorSelection, "f").id;
7952
+ // check if there have been changes in the previously selected ValueSet,
7953
+ // and create an UpdateValuesAction if there have
7954
+ if (equals(__classPrivateFieldGet(this, _DiagramUserSelection_propertyEditorValues, "f"), (_a = __classPrivateFieldGet(this, _DiagramUserSelection_propertyEditorSelection, "f")) === null || _a === void 0 ? void 0 : _a.valueSet.getValues())) {
7955
+ return;
7956
+ }
7957
+ const from = __classPrivateFieldGet(this, _DiagramUserSelection_propertyEditorValues, "f");
7958
+ const to = clone((_b = __classPrivateFieldGet(this, _DiagramUserSelection_propertyEditorSelection, "f")) === null || _b === void 0 ? void 0 : _b.valueSet.getValues());
7959
+ const [fromDiff, toDiff] = diffProperties(from, to, (_c = __classPrivateFieldGet(this, _DiagramUserSelection_propertyEditorSelection, "f")) === null || _c === void 0 ? void 0 : _c.valueSet);
7960
+ const currentAction = new UpdateValuesAction(__classPrivateFieldGet(this, _DiagramUserSelection_canvas, "f"), previousSelectionId, fromDiff, toDiff);
7961
+ currentAction.do();
7962
+ __classPrivateFieldGet(this, _DiagramUserSelection_canvas, "f").actionStack.add(currentAction);
7963
+ __classPrivateFieldSet(this, _DiagramUserSelection_propertyEditorValues, to, "f");
7964
+ };
7864
7965
 
7966
+ var _DiagramCanvas_instances, _a, _DiagramCanvas_canvasCount, _DiagramCanvas_diagramRoot, _DiagramCanvas_connectionType, _DiagramCanvas_gridPatternId, _DiagramCanvas_ancillaryGridPatternIds, _DiagramCanvas_zoomBehavior, _DiagramCanvas_zoomTransform, _DiagramCanvas_priorityThreshold, _DiagramCanvas_priorityThresholds, _DiagramCanvas_unfinishedConnection, _DiagramCanvas_unfinishedConnectionTracer, _DiagramCanvas_unfinishedConnectionPort, _DiagramCanvas_inputFieldContainer, _DiagramCanvas_multipleSelectionContainer, _DiagramCanvas_draggingFrom, _DiagramCanvas_dragging, _DiagramCanvas_secondaryButton, _DiagramCanvas_currentAction, _DiagramCanvas_updateConnectionLabelsInView, _DiagramCanvas_updateConnectionMarkersInView, _DiagramCanvas_startConnection, _DiagramCanvas_finishConnection, _DiagramCanvas_dropConnection, _DiagramCanvas_createInputField, _DiagramCanvas_removeInputField, _DiagramCanvas_minimumSizeOfField, _DiagramCanvas_setFieldTextAndWrap, _DiagramCanvas_setFieldText, _DiagramCanvas_startMovingNode, _DiagramCanvas_continueMovingNode, _DiagramCanvas_finishMovingNode, _DiagramCanvas_startMultipleSelection, _DiagramCanvas_continueMultipleSelection, _DiagramCanvas_finishMultipleSelection;
7865
7967
  /**
7866
7968
  * Thickness of the invisible path around a connection used to make it easier to click on, in diagram units.
7867
7969
  * @private
@@ -7876,13 +7978,13 @@ const ACTION_STACK_SIZE = 25;
7876
7978
  const UNFINISHED_CONNECTION_ID = 'diagram-connection-unfinished';
7877
7979
  class DiagramCanvas {
7878
7980
  get connectionType() {
7879
- return this._connectionType;
7981
+ return __classPrivateFieldGet(this, _DiagramCanvas_connectionType, "f");
7880
7982
  }
7881
7983
  set connectionType(value) {
7882
- var _a, _b;
7883
- this._connectionType = value;
7984
+ var _b, _c;
7985
+ __classPrivateFieldSet(this, _DiagramCanvas_connectionType, value, "f");
7884
7986
  // refresh the palette every time connectionType is set so that the palette keeps track of updates to the connectionType
7885
- (_b = (_a = this.parentComponent) === null || _a === void 0 ? void 0 : _a.palette) === null || _b === void 0 ? void 0 : _b.refreshPalette();
7987
+ (_c = (_b = this.parentComponent) === null || _b === void 0 ? void 0 : _b.palette) === null || _c === void 0 ? void 0 : _c.refreshPalette();
7886
7988
  }
7887
7989
  /**
7888
7990
  * Constructs a canvas object.
@@ -7891,45 +7993,62 @@ class DiagramCanvas {
7891
7993
  * @param config The configuration object used to set the parameters of this canvas.
7892
7994
  */
7893
7995
  constructor(parentComponent, config) {
7894
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
7895
- this.gridPatternId = `daga-grid-pattern-id-${++DiagramCanvas.canvasCount}`;
7896
- this.ancillaryGridPatternIds = [];
7897
- this.zoomTransform = d3.zoomIdentity;
7996
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
7997
+ var _z, _0;
7998
+ _DiagramCanvas_instances.add(this);
7999
+ _DiagramCanvas_diagramRoot.set(this, void 0);
8000
+ _DiagramCanvas_connectionType.set(this, void 0);
8001
+ _DiagramCanvas_gridPatternId.set(this, `daga-grid-pattern-id-${__classPrivateFieldSet(_z = _a, _a, (_0 = __classPrivateFieldGet(_z, _a, "f", _DiagramCanvas_canvasCount), ++_0), "f", _DiagramCanvas_canvasCount)}`);
8002
+ _DiagramCanvas_ancillaryGridPatternIds.set(this, []);
8003
+ _DiagramCanvas_zoomBehavior.set(this, void 0);
8004
+ _DiagramCanvas_zoomTransform.set(this, d3.zoomIdentity);
8005
+ _DiagramCanvas_priorityThreshold.set(this, void 0);
8006
+ _DiagramCanvas_priorityThresholds.set(this, void 0);
8007
+ _DiagramCanvas_unfinishedConnection.set(this, void 0);
8008
+ /**
8009
+ * Invisible path followed by an unfinished connection. Used for making unfinished connections stop before the cursor rather than stopping right at the cursor.
8010
+ */
8011
+ _DiagramCanvas_unfinishedConnectionTracer.set(this, void 0);
8012
+ _DiagramCanvas_unfinishedConnectionPort.set(this, void 0);
8013
+ _DiagramCanvas_inputFieldContainer.set(this, void 0);
8014
+ _DiagramCanvas_multipleSelectionContainer.set(this, void 0);
7898
8015
  // used to distinguish drags from clicks when dragging elements and during multiple selection
7899
- this.draggingFrom = [0, 0];
8016
+ _DiagramCanvas_draggingFrom.set(this, [0, 0]);
7900
8017
  // used to distinguish drags from clicks during multiple selection
7901
- this.dragging = false;
8018
+ _DiagramCanvas_dragging.set(this, false);
7902
8019
  // used to track whether a click is secondary or primary
7903
- this.secondaryButton = false;
8020
+ _DiagramCanvas_secondaryButton.set(this, false);
8021
+ // current action that started but hasn't finished yet
8022
+ _DiagramCanvas_currentAction.set(this, void 0);
7904
8023
  this.validatorChange$ = new Subject();
7905
8024
  this.diagramChange$ = new Subject();
7906
8025
  this.diagramEvent$ = new Subject();
7907
8026
  this.propertyEditorChanges$ = new Subject();
7908
8027
  this.parentComponent = parentComponent;
7909
8028
  this.model = new DiagramModel(this, undefined, config.name || 'unnamed', '', config.type || '', config.properties || []);
7910
- this.userSelection = new DiagramUserSelection(this, (_b = (_a = config.components) === null || _a === void 0 ? void 0 : _a.propertyEditor) === null || _b === void 0 ? void 0 : _b.title);
7911
- this.userHighlight = new DiagramUserHighlight(this, ((_c = config.canvas) === null || _c === void 0 ? void 0 : _c.highlightSections) !== false);
7912
- this.contextMenu = new DiagramContextMenu(this, (_d = config.canvas) === null || _d === void 0 ? void 0 : _d.contextMenu);
8029
+ this.userSelection = new DiagramUserSelection(this, (_c = (_b = config.components) === null || _b === void 0 ? void 0 : _b.propertyEditor) === null || _c === void 0 ? void 0 : _c.title);
8030
+ this.userHighlight = new DiagramUserHighlight(this, ((_d = config.canvas) === null || _d === void 0 ? void 0 : _d.highlightSections) !== false);
8031
+ this.contextMenu = new DiagramContextMenu(this, (_e = config.canvas) === null || _e === void 0 ? void 0 : _e.contextMenu);
7913
8032
  // TODO
7914
- this.backgroundConfig = (_f = (_e = config.canvas) === null || _e === void 0 ? void 0 : _e.background) !== null && _f !== void 0 ? _f : BACKGROUND_DEFAULTS;
7915
- this.gridConfig = applyGridDefaults((_g = config.canvas) === null || _g === void 0 ? void 0 : _g.grid);
8033
+ this.backgroundConfig = (_g = (_f = config.canvas) === null || _f === void 0 ? void 0 : _f.background) !== null && _g !== void 0 ? _g : BACKGROUND_DEFAULTS;
8034
+ this.gridConfig = applyGridDefaults((_h = config.canvas) === null || _h === void 0 ? void 0 : _h.grid);
7916
8035
  this.ancillaryGridsConfig = [];
7917
- for (let i = 0; i < (((_j = (_h = config.canvas) === null || _h === void 0 ? void 0 : _h.ancillaryGrids) === null || _j === void 0 ? void 0 : _j.length) || 0); ++i) {
7918
- this.ancillaryGridsConfig.push(applyGridDefaults((_l = (_k = config.canvas) === null || _k === void 0 ? void 0 : _k.ancillaryGrids) === null || _l === void 0 ? void 0 : _l[i]));
7919
- this.ancillaryGridPatternIds.push(`${this.gridPatternId}-ancillary-${i}`);
7920
- }
7921
- this.zoomFactor = ((_m = config.canvas) === null || _m === void 0 ? void 0 : _m.zoomFactor) || 2;
7922
- this.panRate = ((_o = config.canvas) === null || _o === void 0 ? void 0 : _o.panRate) || 100;
7923
- this.inferConnectionType = ((_p = config.connectionSettings) === null || _p === void 0 ? void 0 : _p.inferConnectionType) || false;
7924
- this.autoTightenConnections = ((_q = config.connectionSettings) === null || _q === void 0 ? void 0 : _q.autoTighten) !== false;
7925
- this.tightenConnectionsAcrossPortTypes = ((_r = config.connectionSettings) === null || _r === void 0 ? void 0 : _r.tightenAcrossPortTypes) || false;
7926
- this.allowConnectionLoops = ((_s = config.connectionSettings) === null || _s === void 0 ? void 0 : _s.allowLoops) || false;
7927
- this.allowSharingPorts = ((_t = config.connectionSettings) === null || _t === void 0 ? void 0 : _t.sharePorts) !== false;
7928
- this.allowSharingBothPorts = ((_u = config.connectionSettings) === null || _u === void 0 ? void 0 : _u.shareBothPorts) || false;
7929
- this.portHighlightRadius = ((_v = config.connectionSettings) === null || _v === void 0 ? void 0 : _v.portHighlightRadius) || 100;
8036
+ for (let i = 0; i < (((_k = (_j = config.canvas) === null || _j === void 0 ? void 0 : _j.ancillaryGrids) === null || _k === void 0 ? void 0 : _k.length) || 0); ++i) {
8037
+ this.ancillaryGridsConfig.push(applyGridDefaults((_m = (_l = config.canvas) === null || _l === void 0 ? void 0 : _l.ancillaryGrids) === null || _m === void 0 ? void 0 : _m[i]));
8038
+ __classPrivateFieldGet(this, _DiagramCanvas_ancillaryGridPatternIds, "f").push(`${__classPrivateFieldGet(this, _DiagramCanvas_gridPatternId, "f")}-ancillary-${i}`);
8039
+ }
8040
+ this.zoomFactor = ((_o = config.canvas) === null || _o === void 0 ? void 0 : _o.zoomFactor) || 2;
8041
+ this.panRate = ((_p = config.canvas) === null || _p === void 0 ? void 0 : _p.panRate) || 100;
8042
+ this.inferConnectionType = ((_q = config.connectionSettings) === null || _q === void 0 ? void 0 : _q.inferConnectionType) || false;
8043
+ this.autoTightenConnections = ((_r = config.connectionSettings) === null || _r === void 0 ? void 0 : _r.autoTighten) !== false;
8044
+ this.tightenConnectionsAcrossPortTypes = ((_s = config.connectionSettings) === null || _s === void 0 ? void 0 : _s.tightenAcrossPortTypes) || false;
8045
+ this.allowConnectionLoops = ((_t = config.connectionSettings) === null || _t === void 0 ? void 0 : _t.allowLoops) || false;
8046
+ this.allowSharingPorts = ((_u = config.connectionSettings) === null || _u === void 0 ? void 0 : _u.sharePorts) !== false;
8047
+ this.allowSharingBothPorts = ((_v = config.connectionSettings) === null || _v === void 0 ? void 0 : _v.shareBothPorts) || false;
8048
+ this.portHighlightRadius = ((_w = config.connectionSettings) === null || _w === void 0 ? void 0 : _w.portHighlightRadius) || 100;
7930
8049
  this.multipleSelectionOn = false;
7931
- this.priorityThresholds = ((_w = config.canvas) === null || _w === void 0 ? void 0 : _w.priorityThresholds) || [];
7932
- this.priorityThreshold = this.priorityThresholds ? this.priorityThresholds[0] : undefined;
8050
+ __classPrivateFieldSet(this, _DiagramCanvas_priorityThresholds, ((_x = config.canvas) === null || _x === void 0 ? void 0 : _x.priorityThresholds) || [], "f");
8051
+ __classPrivateFieldSet(this, _DiagramCanvas_priorityThreshold, __classPrivateFieldGet(this, _DiagramCanvas_priorityThresholds, "f") ? __classPrivateFieldGet(this, _DiagramCanvas_priorityThresholds, "f")[0] : undefined, "f");
7933
8052
  this.layoutFormat = config.layoutFormat;
7934
8053
  this.userActions = config.userActions || {};
7935
8054
  this.validators = [];
@@ -7955,7 +8074,7 @@ class DiagramCanvas {
7955
8074
  const connectionType = new DiagramConnectionType(Object.assign(Object.assign({}, config.connectionTypeDefaults), connectionTypeConfig));
7956
8075
  this.model.connections.types.add(connectionType);
7957
8076
  }
7958
- this._connectionType = ((_x = config === null || config === void 0 ? void 0 : config.connectionSettings) === null || _x === void 0 ? void 0 : _x.defaultConnection) !== undefined ? this.model.connections.types.get(config.connectionSettings.defaultConnection) : undefined;
8077
+ __classPrivateFieldSet(this, _DiagramCanvas_connectionType, ((_y = config === null || config === void 0 ? void 0 : config.connectionSettings) === null || _y === void 0 ? void 0 : _y.defaultConnection) !== undefined ? this.model.connections.types.get(config.connectionSettings.defaultConnection) : undefined, "f");
7959
8078
  }
7960
8079
  }
7961
8080
  addValidator(validator) {
@@ -7967,38 +8086,38 @@ class DiagramCanvas {
7967
8086
  this.validatorChange$.next();
7968
8087
  }
7969
8088
  getPriorityThresholdOptions() {
7970
- return this.priorityThresholds;
8089
+ return __classPrivateFieldGet(this, _DiagramCanvas_priorityThresholds, "f");
7971
8090
  }
7972
8091
  getPriorityThreshold() {
7973
- return this.priorityThreshold;
8092
+ return __classPrivateFieldGet(this, _DiagramCanvas_priorityThreshold, "f");
7974
8093
  }
7975
8094
  setPriorityThreshold(priority) {
7976
- var _a, _b;
7977
- this.priorityThreshold = priority;
8095
+ var _b, _c;
8096
+ __classPrivateFieldSet(this, _DiagramCanvas_priorityThreshold, priority, "f");
7978
8097
  this.updateModelInView();
7979
8098
  for (const node of this.model.nodes) {
7980
8099
  this.fitNodeInView(node.id);
7981
8100
  }
7982
- (_b = (_a = this.parentComponent) === null || _a === void 0 ? void 0 : _a.palette) === null || _b === void 0 ? void 0 : _b.refreshPalette();
8101
+ (_c = (_b = this.parentComponent) === null || _b === void 0 ? void 0 : _b.palette) === null || _c === void 0 ? void 0 : _c.refreshPalette();
7983
8102
  }
7984
8103
  // View methods
7985
8104
  initView(appendTo) {
7986
8105
  const appendToSelection = d3.select(appendTo);
7987
8106
  // remove all children
7988
8107
  appendToSelection.html('');
7989
- this.diagramRoot = appendToSelection.append('div').node();
8108
+ __classPrivateFieldSet(this, _DiagramCanvas_diagramRoot, appendToSelection.append('div').node(), "f");
7990
8109
  this.selectRoot().attr('tabindex', 0) // make element focusable
7991
8110
  .style('width', '100%').style('height', '100%').append('svg').style('width', '100%').style('height', '100%');
7992
8111
  this.selectRoot().on(Events.Click, () => {
7993
- var _a;
8112
+ var _b;
7994
8113
  // focus on the diagram when clicking so that we can focus on the diagram
7995
8114
  // keyboard events only work if we're focusing on the diagram
7996
- (_a = this.selectRoot().node()) === null || _a === void 0 ? void 0 : _a.focus();
8115
+ (_b = this.selectRoot().node()) === null || _b === void 0 ? void 0 : _b.focus();
7997
8116
  }).on(Events.ContextMenu, event => {
7998
- if (this.dragging) {
8117
+ if (__classPrivateFieldGet(this, _DiagramCanvas_dragging, "f")) {
7999
8118
  event.preventDefault();
8000
8119
  event.stopPropagation();
8001
- this.dragging = false;
8120
+ __classPrivateFieldSet(this, _DiagramCanvas_dragging, false, "f");
8002
8121
  return;
8003
8122
  }
8004
8123
  const diagramEvent = new DiagramSecondaryClickEvent(event, null);
@@ -8107,33 +8226,33 @@ class DiagramCanvas {
8107
8226
  if (this.canUserPerformAction(DiagramActions.Zoom)) {
8108
8227
  event.preventDefault();
8109
8228
  // move left, faster if we're zoomed out and slower if we're zoomed in
8110
- this.translateBy(this.panRate / this.zoomTransform.k, 0);
8229
+ this.translateBy(this.panRate / __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k, 0);
8111
8230
  }
8112
8231
  }
8113
8232
  if (event.key === Keys.ArrowRight) {
8114
8233
  if (this.canUserPerformAction(DiagramActions.Zoom)) {
8115
8234
  event.preventDefault();
8116
8235
  // move right, faster if we're zoomed out and slower if we're zoomed in
8117
- this.translateBy(-this.panRate / this.zoomTransform.k, 0);
8236
+ this.translateBy(-this.panRate / __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k, 0);
8118
8237
  }
8119
8238
  }
8120
8239
  if (event.key === Keys.ArrowDown) {
8121
8240
  if (this.canUserPerformAction(DiagramActions.Zoom)) {
8122
8241
  event.preventDefault();
8123
8242
  // move down, faster if we're zoomed out and slower if we're zoomed in
8124
- this.translateBy(0, -this.panRate / this.zoomTransform.k);
8243
+ this.translateBy(0, -this.panRate / __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k);
8125
8244
  }
8126
8245
  }
8127
8246
  if (event.key === Keys.ArrowUp) {
8128
8247
  if (this.canUserPerformAction(DiagramActions.Zoom)) {
8129
8248
  event.preventDefault();
8130
8249
  // move up, faster if we're zoomed out and slower if we're zoomed in
8131
- this.translateBy(0, this.panRate / this.zoomTransform.k);
8250
+ this.translateBy(0, this.panRate / __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k);
8132
8251
  }
8133
8252
  }
8134
8253
  });
8135
8254
  const canvasView = this.selectSVGElement().append('g').attr('class', 'daga-canvas-view').attr('width', `100%`).attr('height', `100%`);
8136
- canvasView.call(this.zoomBehavior = d3.zoom().filter(event => {
8255
+ canvasView.call(__classPrivateFieldSet(this, _DiagramCanvas_zoomBehavior, d3.zoom().filter(event => {
8137
8256
  // Disable double-click zoom by filtering out dblclick events
8138
8257
  return event.type !== Events.DoubleClick;
8139
8258
  }).on(ZoomEvents.Zoom, event => {
@@ -8154,29 +8273,29 @@ class DiagramCanvas {
8154
8273
  setCursorStyle(CursorStyle.AllScroll);
8155
8274
  }
8156
8275
  }
8157
- this.zoomTransform = event.transform;
8276
+ __classPrivateFieldSet(this, _DiagramCanvas_zoomTransform, event.transform, "f");
8158
8277
  const transformAttribute = event.transform.toString();
8159
8278
  this.selectCanvasElements().attr('transform', transformAttribute);
8160
- for (const gridPatternId of [this.gridPatternId, ...this.ancillaryGridPatternIds]) {
8279
+ for (const gridPatternId of [__classPrivateFieldGet(this, _DiagramCanvas_gridPatternId, "f"), ...__classPrivateFieldGet(this, _DiagramCanvas_ancillaryGridPatternIds, "f")]) {
8161
8280
  this.selectCanvasView().select(`#${gridPatternId}`).attr('patternTransform', transformAttribute);
8162
8281
  }
8163
8282
  this.contextMenu.close();
8164
- this.diagramEvent$.next(new DiagramZoomEvent([this.zoomTransform.x, this.zoomTransform.y], this.zoomTransform.k));
8283
+ this.diagramEvent$.next(new DiagramZoomEvent([__classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").x, __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").y], __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k));
8165
8284
  }).on(ZoomEvents.End, () => {
8166
8285
  setCursorStyle();
8167
- }));
8286
+ }), "f"));
8168
8287
  const canvasDefs = canvasView.append('defs');
8169
8288
  const canvasBackground = [];
8170
8289
  canvasBackground.push(initializeBackground(canvasView, this.backgroundConfig).attr('class', 'daga-background'));
8171
8290
  for (let i = 0; i < this.ancillaryGridsConfig.length; ++i) {
8172
- canvasBackground.push(initializeGrid(this, canvasView, canvasDefs, this.ancillaryGridPatternIds[i], this.ancillaryGridsConfig[i]));
8291
+ canvasBackground.push(initializeGrid(this, canvasView, canvasDefs, __classPrivateFieldGet(this, _DiagramCanvas_ancillaryGridPatternIds, "f")[i], this.ancillaryGridsConfig[i]));
8173
8292
  }
8174
- canvasBackground.push(initializeGrid(this, canvasView, canvasDefs, this.gridPatternId, this.gridConfig));
8293
+ canvasBackground.push(initializeGrid(this, canvasView, canvasDefs, __classPrivateFieldGet(this, _DiagramCanvas_gridPatternId, "f"), this.gridConfig));
8175
8294
  for (const canvasBackgroundElement of canvasBackground) {
8176
8295
  canvasBackgroundElement.on(Events.MouseMove, event => {
8177
- if (this.unfinishedConnection !== undefined) {
8296
+ if (__classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f") !== undefined) {
8178
8297
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8179
- this.unfinishedConnection.endCoords = pointerCoords;
8298
+ __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").endCoords = pointerCoords;
8180
8299
  }
8181
8300
  });
8182
8301
  canvasBackgroundElement.on(Events.MouseOver, () => {
@@ -8201,55 +8320,55 @@ class DiagramCanvas {
8201
8320
  canvasBackgroundElement.call(d3.drag().filter(event => {
8202
8321
  return this.multipleSelectionOn || isSecondaryButton(event);
8203
8322
  }).on(DragEvents.Start, event => {
8204
- this.startMultipleSelection(event);
8323
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_startMultipleSelection).call(this, event);
8205
8324
  }).on(DragEvents.Drag, event => {
8206
- this.continueMultipleSelection(event);
8325
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_continueMultipleSelection).call(this, event);
8207
8326
  }).on(DragEvents.End, event => {
8208
- this.finishMultipleSelection(event);
8327
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_finishMultipleSelection).call(this, event);
8209
8328
  }));
8210
8329
  }
8211
8330
  canvasView.append('g').attr('class', 'daga-canvas-elements');
8212
8331
  }
8213
8332
  getZoomLevel() {
8214
- return this.zoomTransform.k;
8333
+ return __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k;
8215
8334
  }
8216
8335
  zoomBy(factor) {
8217
8336
  if (!isNaN(factor)) {
8218
- this.zoomBehavior.scaleBy(this.selectCanvasView(), factor);
8337
+ __classPrivateFieldGet(this, _DiagramCanvas_zoomBehavior, "f").scaleBy(this.selectCanvasView(), factor);
8219
8338
  }
8220
8339
  }
8221
8340
  zoomTo(level) {
8222
8341
  if (!isNaN(level)) {
8223
- this.zoomBehavior.scaleTo(this.selectCanvasView(), level);
8342
+ __classPrivateFieldGet(this, _DiagramCanvas_zoomBehavior, "f").scaleTo(this.selectCanvasView(), level);
8224
8343
  }
8225
8344
  }
8226
8345
  getViewCoordinates() {
8227
- var _a, _b, _c;
8228
- const canvasViewBoundingBox = (_c = (_b = (_a = this.selectCanvasView()) === null || _a === void 0 ? void 0 : _a.select('.daga-background')) === null || _b === void 0 ? void 0 : _b.node()) === null || _c === void 0 ? void 0 : _c.getBBox();
8346
+ var _b, _c, _d;
8347
+ const canvasViewBoundingBox = (_d = (_c = (_b = this.selectCanvasView()) === null || _b === void 0 ? void 0 : _b.select('.daga-background')) === null || _c === void 0 ? void 0 : _c.node()) === null || _d === void 0 ? void 0 : _d.getBBox();
8229
8348
  /*
8230
8349
  transform the coordinates of the zoomTransform to the coordinates
8231
8350
  needed to point the zoomTransfrom to the center of the screen to
8232
8351
  ensure that canvas.translateTo(getViewCoordinates()) has no effect
8233
8352
  */
8234
- return [((canvasViewBoundingBox.width + canvasViewBoundingBox.x) / 2 - this.zoomTransform.x) / this.zoomTransform.k, ((canvasViewBoundingBox.height + canvasViewBoundingBox.y) / 2 - this.zoomTransform.y) / this.zoomTransform.k];
8353
+ return [((canvasViewBoundingBox.width + canvasViewBoundingBox.x) / 2 - __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").x) / __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k, ((canvasViewBoundingBox.height + canvasViewBoundingBox.y) / 2 - __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").y) / __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k];
8235
8354
  }
8236
8355
  translateBy(x, y) {
8237
8356
  if (!isNaN(x) && !isNaN(y)) {
8238
- this.zoomBehavior.translateBy(this.selectCanvasView(), x, y);
8357
+ __classPrivateFieldGet(this, _DiagramCanvas_zoomBehavior, "f").translateBy(this.selectCanvasView(), x, y);
8239
8358
  }
8240
8359
  }
8241
8360
  translateTo(x, y) {
8242
8361
  if (!isNaN(x) && !isNaN(y)) {
8243
- this.zoomBehavior.translateTo(this.selectCanvasView(), x, y);
8362
+ __classPrivateFieldGet(this, _DiagramCanvas_zoomBehavior, "f").translateTo(this.selectCanvasView(), x, y);
8244
8363
  }
8245
8364
  }
8246
8365
  zoomAndPanTo(x, y, z, duration) {
8247
8366
  if (!duration || duration <= 0) {
8248
- this.zoomBehavior.scaleTo(this.selectCanvasView(), z);
8249
- this.zoomBehavior.translateTo(this.selectCanvasView(), x, y);
8367
+ __classPrivateFieldGet(this, _DiagramCanvas_zoomBehavior, "f").scaleTo(this.selectCanvasView(), z);
8368
+ __classPrivateFieldGet(this, _DiagramCanvas_zoomBehavior, "f").translateTo(this.selectCanvasView(), x, y);
8250
8369
  return;
8251
8370
  }
8252
- this.zoomBehavior.interpolate(d3.interpolate);
8371
+ __classPrivateFieldGet(this, _DiagramCanvas_zoomBehavior, "f").interpolate(d3.interpolate);
8253
8372
  const [startingX, startingY] = this.getViewCoordinates();
8254
8373
  const startingZoom = this.getZoomLevel();
8255
8374
  const targetX = x,
@@ -8263,8 +8382,8 @@ class DiagramCanvas {
8263
8382
  const currentX = value * (targetX - startingX) + startingX;
8264
8383
  const currentY = value * (targetY - startingY) + startingY;
8265
8384
  const currentZoom = value * (targetZoom - startingZoom) + startingZoom;
8266
- this.zoomBehavior.scaleTo(this.selectCanvasView(), currentZoom);
8267
- this.zoomBehavior.translateTo(this.selectCanvasView(), currentX, currentY);
8385
+ __classPrivateFieldGet(this, _DiagramCanvas_zoomBehavior, "f").scaleTo(this.selectCanvasView(), currentZoom);
8386
+ __classPrivateFieldGet(this, _DiagramCanvas_zoomBehavior, "f").translateTo(this.selectCanvasView(), currentX, currentY);
8268
8387
  }
8269
8388
  } catch (e) {
8270
8389
  console.warn('Animation has been interrupted.', e);
@@ -8274,10 +8393,10 @@ class DiagramCanvas {
8274
8393
  });
8275
8394
  }
8276
8395
  center(nodeIds, maxZoomLevel, duration) {
8277
- var _a;
8396
+ var _b;
8278
8397
  // if there are no nodes, we have nothing to do here
8279
8398
  if (this.model.nodes.length > 0) {
8280
- const canvasViewBoundingBox = (_a = this.selectCanvasView().select('.daga-background').node()) === null || _a === void 0 ? void 0 : _a.getBBox();
8399
+ const canvasViewBoundingBox = (_b = this.selectCanvasView().select('.daga-background').node()) === null || _b === void 0 ? void 0 : _b.getBBox();
8281
8400
  if (!canvasViewBoundingBox.width || !canvasViewBoundingBox.height) {
8282
8401
  // prevent errors if the width or height is invalid
8283
8402
  return;
@@ -8319,35 +8438,19 @@ class DiagramCanvas {
8319
8438
  return [pointX, pointY];
8320
8439
  }
8321
8440
  getCoordinatesOnScreen() {
8322
- var _a;
8323
- const rootBoundingClientRect = (_a = this.selectSVGElement().node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
8441
+ var _b;
8442
+ const rootBoundingClientRect = (_b = this.selectSVGElement().node()) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
8324
8443
  const rootDimensions = [(rootBoundingClientRect === null || rootBoundingClientRect === void 0 ? void 0 : rootBoundingClientRect.width) || 0, (rootBoundingClientRect === null || rootBoundingClientRect === void 0 ? void 0 : rootBoundingClientRect.height) || 0];
8325
- 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]];
8326
- }
8327
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8328
- getEventHoldingCoordinates(event) {
8329
- if (event.type === 'drag' || event.type === 'start' || event.type === 'end') {
8330
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8331
- const sourceEvent = event.sourceEvent;
8332
- if (sourceEvent && (sourceEvent.type === 'touchmove' || sourceEvent.type === 'touchstart' || sourceEvent.type === 'touchend')) {
8333
- return (
8334
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8335
- event.sourceEvent.touches[0] ||
8336
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8337
- event.sourceEvent.changedTouches[0]
8338
- );
8339
- }
8340
- }
8341
- return event;
8444
+ return [[-__classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").x / __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k, -__classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").y / __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k], [(rootDimensions[0] - __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").x) / __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k, (rootDimensions[1] - __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").y) / __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k]];
8342
8445
  }
8343
8446
  getPointerLocationRelativeToCanvas(event) {
8344
- return d3.pointer(this.getEventHoldingCoordinates(event), this.selectCanvasElements().node());
8447
+ return d3.pointer(getEventHoldingCoordinates(event), this.selectCanvasElements().node());
8345
8448
  }
8346
8449
  getPointerLocationRelativeToRoot(event) {
8347
- return d3.pointer(this.getEventHoldingCoordinates(event), this.selectSVGElement().node());
8450
+ return d3.pointer(getEventHoldingCoordinates(event), this.selectSVGElement().node());
8348
8451
  }
8349
8452
  getPointerLocationRelativeToBody(event) {
8350
- return d3.pointer(this.getEventHoldingCoordinates(event), d3.select('body').node());
8453
+ return d3.pointer(getEventHoldingCoordinates(event), d3.select('body').node());
8351
8454
  }
8352
8455
  getPointerLocationRelativeToScreen(event) {
8353
8456
  const pointerLocationRelativeToBody = this.getPointerLocationRelativeToBody(event);
@@ -8363,7 +8466,7 @@ class DiagramCanvas {
8363
8466
  this.updateDecoratorsInView();
8364
8467
  }
8365
8468
  updateNodesInView(...ids) {
8366
- let updateSelection = this.selectCanvasElements().selectAll('g.diagram-node').data(this.model.nodes.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
8469
+ let updateSelection = this.selectCanvasElements().selectAll('g.diagram-node').data(this.model.nodes.filter(e => __classPrivateFieldGet(this, _DiagramCanvas_priorityThreshold, "f") !== undefined ? e.getPriority() >= __classPrivateFieldGet(this, _DiagramCanvas_priorityThreshold, "f") : true), d => d.id);
8367
8470
  const exitSelection = updateSelection.exit();
8368
8471
  const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => `diagram-node${needsResizerX(d) ? ' resizable-x' : ''}${needsResizerY(d) ? ' resizable-y' : ''}${needsResizerXY(d) ? ' resizable-xy' : ''} ${d.type.defaultLook.lookType}`);
8369
8472
  if (ids && ids.length > 0) {
@@ -8372,7 +8475,7 @@ class DiagramCanvas {
8372
8475
  const mergeSelection = enterSelection.merge(updateSelection);
8373
8476
  exitSelection.remove();
8374
8477
  enterSelection.on(Events.MouseOver, (_event, d) => {
8375
- if (!this.dragging) {
8478
+ if (!__classPrivateFieldGet(this, _DiagramCanvas_dragging, "f")) {
8376
8479
  this.userHighlight.focusOn(d);
8377
8480
  this.diagramEvent$.next(new DiagramHighlightedEvent(d));
8378
8481
  }
@@ -8385,10 +8488,10 @@ class DiagramCanvas {
8385
8488
  this.userSelection.toggle(d);
8386
8489
  this.diagramEvent$.next(new DiagramSelectionEvent([d], d.selected));
8387
8490
  }).on(Events.ContextMenu, (event, d) => {
8388
- if (this.dragging) {
8491
+ if (__classPrivateFieldGet(this, _DiagramCanvas_dragging, "f")) {
8389
8492
  event.preventDefault();
8390
8493
  event.stopPropagation();
8391
- this.dragging = false;
8494
+ __classPrivateFieldSet(this, _DiagramCanvas_dragging, false, "f");
8392
8495
  return;
8393
8496
  }
8394
8497
  const diagramEvent = new DiagramSecondaryClickEvent(event, d);
@@ -8405,27 +8508,27 @@ class DiagramCanvas {
8405
8508
  const diagramEvent = new DiagramDoubleClickEvent(event, d);
8406
8509
  this.diagramEvent$.next(diagramEvent);
8407
8510
  }).call(d3.drag().filter(event => {
8408
- this.secondaryButton = isSecondaryButton(event);
8511
+ __classPrivateFieldSet(this, _DiagramCanvas_secondaryButton, isSecondaryButton(event), "f");
8409
8512
  return true;
8410
8513
  }).on(DragEvents.Start, (event, d) => {
8411
- if (this.multipleSelectionOn || this.secondaryButton) {
8412
- this.startMultipleSelection(event);
8514
+ if (this.multipleSelectionOn || __classPrivateFieldGet(this, _DiagramCanvas_secondaryButton, "f")) {
8515
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_startMultipleSelection).call(this, event);
8413
8516
  } else {
8414
- this.startMovingNode(event, d);
8517
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_startMovingNode).call(this, event, d);
8415
8518
  }
8416
8519
  }).on(DragEvents.Drag, (event, d) => {
8417
- if (this.multipleSelectionOn || this.secondaryButton) {
8418
- this.continueMultipleSelection(event);
8520
+ if (this.multipleSelectionOn || __classPrivateFieldGet(this, _DiagramCanvas_secondaryButton, "f")) {
8521
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_continueMultipleSelection).call(this, event);
8419
8522
  } else {
8420
- this.continueMovingNode(event, d);
8523
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_continueMovingNode).call(this, event, d);
8421
8524
  }
8422
8525
  }).on(DragEvents.End, (event, d) => {
8423
- if (this.multipleSelectionOn || this.secondaryButton) {
8424
- this.finishMultipleSelection(event);
8526
+ if (this.multipleSelectionOn || __classPrivateFieldGet(this, _DiagramCanvas_secondaryButton, "f")) {
8527
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_finishMultipleSelection).call(this, event);
8425
8528
  } else {
8426
- this.finishMovingNode(event, d);
8529
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_finishMovingNode).call(this, event, d);
8427
8530
  }
8428
- this.secondaryButton = false;
8531
+ __classPrivateFieldSet(this, _DiagramCanvas_secondaryButton, false, "f");
8429
8532
  }));
8430
8533
  initializeLook(enterSelection);
8431
8534
  enterSelection.filter('.resizable-x').append('rect').attr('class', 'left-resizer').on(Events.MouseOver, (_event, d) => {
@@ -8439,7 +8542,7 @@ class DiagramCanvas {
8439
8542
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8440
8543
  if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8441
8544
  setCursorStyle(CursorStyle.EWResize);
8442
- this.currentAction = new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8545
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry()), "f");
8443
8546
  } else {
8444
8547
  setCursorStyle(CursorStyle.NotAllowed);
8445
8548
  }
@@ -8449,7 +8552,7 @@ class DiagramCanvas {
8449
8552
  d.stretch(Side.Left, d.coords[0] - pointerCoords[0]);
8450
8553
  }
8451
8554
  }).on(DragEvents.End, (event, d) => {
8452
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
8555
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof SetGeometryAction && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").intent === DiagramActions.StretchNode) {
8453
8556
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8454
8557
  if (this.gridConfig.snap) {
8455
8558
  pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
@@ -8457,10 +8560,10 @@ class DiagramCanvas {
8457
8560
  pointerCoords[1] += d.type.snapToGridOffset[1];
8458
8561
  }
8459
8562
  d.stretch(Side.Left, d.coords[0] - pointerCoords[0]);
8460
- this.currentAction.to = d.getGeometry();
8461
- this.currentAction.do();
8462
- this.actionStack.add(this.currentAction);
8463
- this.currentAction = undefined;
8563
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").to = d.getGeometry();
8564
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").do();
8565
+ this.actionStack.add(__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f"));
8566
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
8464
8567
  }
8465
8568
  setCursorStyle();
8466
8569
  }));
@@ -8475,7 +8578,7 @@ class DiagramCanvas {
8475
8578
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8476
8579
  if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed) {
8477
8580
  setCursorStyle(CursorStyle.EWResize);
8478
- this.currentAction = new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8581
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry()), "f");
8479
8582
  } else {
8480
8583
  setCursorStyle(CursorStyle.NotAllowed);
8481
8584
  }
@@ -8485,7 +8588,7 @@ class DiagramCanvas {
8485
8588
  d.stretch(Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
8486
8589
  }
8487
8590
  }).on(DragEvents.End, (event, d) => {
8488
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
8591
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableX() && !d.removed && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof SetGeometryAction && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").intent === DiagramActions.StretchNode) {
8489
8592
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8490
8593
  if (this.gridConfig.snap) {
8491
8594
  pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[2], pointerCoords[1] - d.type.snapToGridOffset[3]]);
@@ -8493,10 +8596,10 @@ class DiagramCanvas {
8493
8596
  pointerCoords[1] += d.type.snapToGridOffset[3];
8494
8597
  }
8495
8598
  d.stretch(Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
8496
- this.currentAction.to = d.getGeometry();
8497
- this.currentAction.do();
8498
- this.actionStack.add(this.currentAction);
8499
- this.currentAction = undefined;
8599
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").to = d.getGeometry();
8600
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").do();
8601
+ this.actionStack.add(__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f"));
8602
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
8500
8603
  }
8501
8604
  setCursorStyle();
8502
8605
  }));
@@ -8511,7 +8614,7 @@ class DiagramCanvas {
8511
8614
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8512
8615
  if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8513
8616
  setCursorStyle(CursorStyle.NSResize);
8514
- this.currentAction = new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8617
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry()), "f");
8515
8618
  } else {
8516
8619
  setCursorStyle(CursorStyle.NotAllowed);
8517
8620
  }
@@ -8521,7 +8624,7 @@ class DiagramCanvas {
8521
8624
  d.stretch(Side.Top, d.coords[1] - pointerCoords[1]);
8522
8625
  }
8523
8626
  }).on(DragEvents.End, (event, d) => {
8524
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
8627
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof SetGeometryAction && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").intent === DiagramActions.StretchNode) {
8525
8628
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8526
8629
  if (this.gridConfig.snap) {
8527
8630
  pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
@@ -8529,10 +8632,10 @@ class DiagramCanvas {
8529
8632
  pointerCoords[1] += d.type.snapToGridOffset[1];
8530
8633
  }
8531
8634
  d.stretch(Side.Top, d.coords[1] - pointerCoords[1]);
8532
- this.currentAction.to = d.getGeometry();
8533
- this.currentAction.do();
8534
- this.actionStack.add(this.currentAction);
8535
- this.currentAction = undefined;
8635
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").to = d.getGeometry();
8636
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").do();
8637
+ this.actionStack.add(__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f"));
8638
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
8536
8639
  }
8537
8640
  setCursorStyle();
8538
8641
  }));
@@ -8547,7 +8650,7 @@ class DiagramCanvas {
8547
8650
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8548
8651
  if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed) {
8549
8652
  setCursorStyle(CursorStyle.NSResize);
8550
- this.currentAction = new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8653
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry()), "f");
8551
8654
  } else {
8552
8655
  setCursorStyle(CursorStyle.NotAllowed);
8553
8656
  }
@@ -8557,7 +8660,7 @@ class DiagramCanvas {
8557
8660
  d.stretch(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
8558
8661
  }
8559
8662
  }).on(DragEvents.End, (event, d) => {
8560
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
8663
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableY() && !d.removed && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof SetGeometryAction && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").intent === DiagramActions.StretchNode) {
8561
8664
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8562
8665
  if (this.gridConfig.snap) {
8563
8666
  pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[2], pointerCoords[1] - d.type.snapToGridOffset[3]]);
@@ -8565,10 +8668,10 @@ class DiagramCanvas {
8565
8668
  pointerCoords[1] += d.type.snapToGridOffset[3];
8566
8669
  }
8567
8670
  d.stretch(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
8568
- this.currentAction.to = d.getGeometry();
8569
- this.currentAction.do();
8570
- this.actionStack.add(this.currentAction);
8571
- this.currentAction = undefined;
8671
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").to = d.getGeometry();
8672
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").do();
8673
+ this.actionStack.add(__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f"));
8674
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
8572
8675
  }
8573
8676
  setCursorStyle();
8574
8677
  }));
@@ -8583,7 +8686,7 @@ class DiagramCanvas {
8583
8686
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8584
8687
  if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8585
8688
  setCursorStyle(CursorStyle.NWSEResize);
8586
- this.currentAction = new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8689
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry()), "f");
8587
8690
  } else {
8588
8691
  setCursorStyle(CursorStyle.NotAllowed);
8589
8692
  }
@@ -8594,7 +8697,7 @@ class DiagramCanvas {
8594
8697
  d.stretch(Side.Top, d.coords[1] - pointerCoords[1]);
8595
8698
  }
8596
8699
  }).on(DragEvents.End, (event, d) => {
8597
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
8700
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof SetGeometryAction && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").intent === DiagramActions.StretchNode) {
8598
8701
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8599
8702
  if (this.gridConfig.snap) {
8600
8703
  pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
@@ -8603,10 +8706,10 @@ class DiagramCanvas {
8603
8706
  }
8604
8707
  d.stretch(Side.Left, d.coords[0] - pointerCoords[0]);
8605
8708
  d.stretch(Side.Top, d.coords[1] - pointerCoords[1]);
8606
- this.currentAction.to = d.getGeometry();
8607
- this.currentAction.do();
8608
- this.actionStack.add(this.currentAction);
8609
- this.currentAction = undefined;
8709
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").to = d.getGeometry();
8710
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").do();
8711
+ this.actionStack.add(__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f"));
8712
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
8610
8713
  }
8611
8714
  setCursorStyle();
8612
8715
  }));
@@ -8621,7 +8724,7 @@ class DiagramCanvas {
8621
8724
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8622
8725
  if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8623
8726
  setCursorStyle(CursorStyle.NESWResize);
8624
- this.currentAction = new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8727
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry()), "f");
8625
8728
  } else {
8626
8729
  setCursorStyle(CursorStyle.NotAllowed);
8627
8730
  }
@@ -8632,7 +8735,7 @@ class DiagramCanvas {
8632
8735
  d.stretch(Side.Top, d.coords[1] - pointerCoords[1]);
8633
8736
  }
8634
8737
  }).on(DragEvents.End, (event, d) => {
8635
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
8738
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof SetGeometryAction && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").intent === DiagramActions.StretchNode) {
8636
8739
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8637
8740
  if (this.gridConfig.snap) {
8638
8741
  pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
@@ -8641,10 +8744,10 @@ class DiagramCanvas {
8641
8744
  }
8642
8745
  d.stretch(Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
8643
8746
  d.stretch(Side.Top, d.coords[1] - pointerCoords[1]);
8644
- this.currentAction.to = d.getGeometry();
8645
- this.currentAction.do();
8646
- this.actionStack.add(this.currentAction);
8647
- this.currentAction = undefined;
8747
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").to = d.getGeometry();
8748
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").do();
8749
+ this.actionStack.add(__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f"));
8750
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
8648
8751
  }
8649
8752
  setCursorStyle();
8650
8753
  }));
@@ -8659,7 +8762,7 @@ class DiagramCanvas {
8659
8762
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8660
8763
  if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8661
8764
  setCursorStyle(CursorStyle.NESWResize);
8662
- this.currentAction = new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8765
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry()), "f");
8663
8766
  } else {
8664
8767
  setCursorStyle(CursorStyle.NotAllowed);
8665
8768
  }
@@ -8670,7 +8773,7 @@ class DiagramCanvas {
8670
8773
  d.stretch(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
8671
8774
  }
8672
8775
  }).on(DragEvents.End, (event, d) => {
8673
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
8776
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof SetGeometryAction && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").intent === DiagramActions.StretchNode) {
8674
8777
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8675
8778
  if (this.gridConfig.snap) {
8676
8779
  pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
@@ -8679,10 +8782,10 @@ class DiagramCanvas {
8679
8782
  }
8680
8783
  d.stretch(Side.Left, d.coords[0] - pointerCoords[0]);
8681
8784
  d.stretch(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
8682
- this.currentAction.to = d.getGeometry();
8683
- this.currentAction.do();
8684
- this.actionStack.add(this.currentAction);
8685
- this.currentAction = undefined;
8785
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").to = d.getGeometry();
8786
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").do();
8787
+ this.actionStack.add(__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f"));
8788
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
8686
8789
  }
8687
8790
  setCursorStyle();
8688
8791
  }));
@@ -8697,7 +8800,7 @@ class DiagramCanvas {
8697
8800
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8698
8801
  if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed) {
8699
8802
  setCursorStyle(CursorStyle.NWSEResize);
8700
- this.currentAction = new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry());
8803
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, new SetGeometryAction(this, DiagramActions.StretchNode, d.id, d.getGeometry(), d.getGeometry()), "f");
8701
8804
  } else {
8702
8805
  setCursorStyle(CursorStyle.NotAllowed);
8703
8806
  }
@@ -8708,7 +8811,7 @@ class DiagramCanvas {
8708
8811
  d.stretch(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
8709
8812
  }
8710
8813
  }).on(DragEvents.End, (event, d) => {
8711
- if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchNode) {
8814
+ if (this.canUserPerformAction(DiagramActions.StretchNode) && d.getResizableXY() && !d.removed && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof SetGeometryAction && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").intent === DiagramActions.StretchNode) {
8712
8815
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8713
8816
  if (this.gridConfig.snap) {
8714
8817
  pointerCoords = this.getClosestGridPoint([pointerCoords[0] - d.type.snapToGridOffset[0], pointerCoords[1] - d.type.snapToGridOffset[1]]);
@@ -8717,10 +8820,10 @@ class DiagramCanvas {
8717
8820
  }
8718
8821
  d.stretch(Side.Right, pointerCoords[0] - (d.coords[0] + d.width));
8719
8822
  d.stretch(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height));
8720
- this.currentAction.to = d.getGeometry();
8721
- this.currentAction.do();
8722
- this.actionStack.add(this.currentAction);
8723
- this.currentAction = undefined;
8823
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").to = d.getGeometry();
8824
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").do();
8825
+ this.actionStack.add(__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f"));
8826
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
8724
8827
  }
8725
8828
  setCursorStyle();
8726
8829
  }));
@@ -8736,11 +8839,11 @@ class DiagramCanvas {
8736
8839
  mergeSelection.filter('.resizable-xy').select('rect.bottom-right-resizer').style('pointer-events', d => d.getResizableXY() ? 'initial' : 'none').attr('x', d => d.width - d.getResizerXY().thickness + d.getResizerXY().outerMargin).attr('y', d => d.height - d.getResizerXY().thickness + d.getResizerXY().outerMargin).attr('width', d => d.getResizerXY().thickness).attr('height', d => d.getResizerXY().thickness).attr('fill', d => d.getResizerXY().getLook(d).fillColor || 'transparent').attr('stroke', d => d.getResizerXY().getLook(d).borderColor || 'transparent').attr('stroke-width', d => d.getResizerXY().getLook(d).borderThickness || 0);
8737
8840
  }
8738
8841
  updateSectionsInView(...ids) {
8739
- 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);
8842
+ let updateSelection = this.selectCanvasElements().selectAll('g.diagram-section').data(this.model.sections.filter(e => __classPrivateFieldGet(this, _DiagramCanvas_priorityThreshold, "f") !== undefined ? e.getPriority() >= __classPrivateFieldGet(this, _DiagramCanvas_priorityThreshold, "f") : true), d => d.id);
8740
8843
  const exitSelection = updateSelection.exit();
8741
8844
  const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => {
8742
- var _a;
8743
- return `diagram-section${needsResizerX(d) ? ' resizable-x' : ''}${needsResizerY(d) ? ' resizable-y' : ''}${needsResizerXY(d) ? ' resizable-xy' : ''} ${(_a = d.look) === null || _a === void 0 ? void 0 : _a.lookType}`;
8845
+ var _b;
8846
+ return `diagram-section${needsResizerX(d) ? ' resizable-x' : ''}${needsResizerY(d) ? ' resizable-y' : ''}${needsResizerXY(d) ? ' resizable-xy' : ''} ${(_b = d.look) === null || _b === void 0 ? void 0 : _b.lookType}`;
8744
8847
  });
8745
8848
  if (ids && ids.length > 0) {
8746
8849
  updateSelection = updateSelection.filter(d => ids.includes(d.id));
@@ -8748,7 +8851,7 @@ class DiagramCanvas {
8748
8851
  const mergeSelection = enterSelection.merge(updateSelection);
8749
8852
  exitSelection.remove();
8750
8853
  enterSelection.on(Events.MouseOver, (_event, d) => {
8751
- if (!this.dragging) {
8854
+ if (!__classPrivateFieldGet(this, _DiagramCanvas_dragging, "f")) {
8752
8855
  this.userHighlight.focusOn(d);
8753
8856
  this.diagramEvent$.next(new DiagramHighlightedEvent(d));
8754
8857
  }
@@ -8762,10 +8865,10 @@ class DiagramCanvas {
8762
8865
  this.userSelection.toggle(elementToBeToggled);
8763
8866
  this.diagramEvent$.next(new DiagramSelectionEvent([elementToBeToggled], elementToBeToggled.selected));
8764
8867
  }).on(Events.ContextMenu, (event, d) => {
8765
- if (this.dragging) {
8868
+ if (__classPrivateFieldGet(this, _DiagramCanvas_dragging, "f")) {
8766
8869
  event.preventDefault();
8767
8870
  event.stopPropagation();
8768
- this.dragging = false;
8871
+ __classPrivateFieldSet(this, _DiagramCanvas_dragging, false, "f");
8769
8872
  return;
8770
8873
  }
8771
8874
  const diagramEvent = new DiagramSecondaryClickEvent(event, d);
@@ -8783,42 +8886,42 @@ class DiagramCanvas {
8783
8886
  const diagramEvent = new DiagramDoubleClickEvent(event, d);
8784
8887
  this.diagramEvent$.next(diagramEvent);
8785
8888
  }).call(d3.drag().filter(event => {
8786
- this.secondaryButton = isSecondaryButton(event);
8889
+ __classPrivateFieldSet(this, _DiagramCanvas_secondaryButton, isSecondaryButton(event), "f");
8787
8890
  return true;
8788
8891
  }).on(DragEvents.Start, (event, d) => {
8789
- if (this.multipleSelectionOn || this.secondaryButton) {
8790
- this.startMultipleSelection(event);
8892
+ if (this.multipleSelectionOn || __classPrivateFieldGet(this, _DiagramCanvas_secondaryButton, "f")) {
8893
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_startMultipleSelection).call(this, event);
8791
8894
  } else {
8792
8895
  const node = d === null || d === void 0 ? void 0 : d.node;
8793
8896
  if (node) {
8794
- this.startMovingNode(event, node);
8897
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_startMovingNode).call(this, event, node);
8795
8898
  } else {
8796
8899
  setCursorStyle(CursorStyle.NotAllowed);
8797
8900
  }
8798
8901
  }
8799
8902
  }).on(DragEvents.Drag, (event, d) => {
8800
- if (this.multipleSelectionOn || this.secondaryButton) {
8801
- this.continueMultipleSelection(event);
8903
+ if (this.multipleSelectionOn || __classPrivateFieldGet(this, _DiagramCanvas_secondaryButton, "f")) {
8904
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_continueMultipleSelection).call(this, event);
8802
8905
  } else {
8803
8906
  const node = d === null || d === void 0 ? void 0 : d.node;
8804
8907
  if (node) {
8805
- this.continueMovingNode(event, node);
8908
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_continueMovingNode).call(this, event, node);
8806
8909
  } else {
8807
8910
  setCursorStyle(CursorStyle.NotAllowed);
8808
8911
  }
8809
8912
  }
8810
8913
  }).on(DragEvents.End, (event, d) => {
8811
- if (this.multipleSelectionOn || this.secondaryButton) {
8812
- this.finishMultipleSelection(event);
8914
+ if (this.multipleSelectionOn || __classPrivateFieldGet(this, _DiagramCanvas_secondaryButton, "f")) {
8915
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_finishMultipleSelection).call(this, event);
8813
8916
  } else {
8814
8917
  const node = d === null || d === void 0 ? void 0 : d.node;
8815
8918
  if (node) {
8816
- this.finishMovingNode(event, node);
8919
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_finishMovingNode).call(this, event, node);
8817
8920
  } else {
8818
8921
  setCursorStyle();
8819
8922
  }
8820
8923
  }
8821
- this.secondaryButton = false;
8924
+ __classPrivateFieldSet(this, _DiagramCanvas_secondaryButton, false, "f");
8822
8925
  }));
8823
8926
  initializeLook(enterSelection);
8824
8927
  enterSelection.filter('.resizable-x').append('rect').attr('class', 'left-resizer').on(Events.MouseOver, (_event, d) => {
@@ -8832,7 +8935,7 @@ class DiagramCanvas {
8832
8935
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8833
8936
  if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
8834
8937
  setCursorStyle(CursorStyle.EWResize);
8835
- this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
8938
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry()), "f");
8836
8939
  } else {
8837
8940
  setCursorStyle(CursorStyle.NotAllowed);
8838
8941
  }
@@ -8842,16 +8945,16 @@ class DiagramCanvas {
8842
8945
  d.node.stretchSections(Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
8843
8946
  }
8844
8947
  }).on(DragEvents.End, (event, d) => {
8845
- if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
8948
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof SetGeometryAction && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").intent === DiagramActions.StretchSection && d.node) {
8846
8949
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8847
8950
  if (this.gridConfig.snap) {
8848
8951
  pointerCoords = this.getClosestGridPoint(pointerCoords);
8849
8952
  }
8850
8953
  d.node.stretchSections(Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
8851
- this.currentAction.to = d.node.getGeometry();
8852
- this.currentAction.do();
8853
- this.actionStack.add(this.currentAction);
8854
- this.currentAction = undefined;
8954
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").to = d.node.getGeometry();
8955
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").do();
8956
+ this.actionStack.add(__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f"));
8957
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
8855
8958
  }
8856
8959
  setCursorStyle();
8857
8960
  }));
@@ -8866,7 +8969,7 @@ class DiagramCanvas {
8866
8969
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8867
8970
  if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
8868
8971
  setCursorStyle(CursorStyle.EWResize);
8869
- this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
8972
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry()), "f");
8870
8973
  } else {
8871
8974
  setCursorStyle(CursorStyle.NotAllowed);
8872
8975
  }
@@ -8876,16 +8979,16 @@ class DiagramCanvas {
8876
8979
  d.node.stretchSections(Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
8877
8980
  }
8878
8981
  }).on(DragEvents.End, (event, d) => {
8879
- if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
8982
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof SetGeometryAction && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").intent === DiagramActions.StretchSection && d.node) {
8880
8983
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8881
8984
  if (this.gridConfig.snap) {
8882
8985
  pointerCoords = this.getClosestGridPoint(pointerCoords);
8883
8986
  }
8884
8987
  d.node.stretchSections(Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
8885
- this.currentAction.to = d.node.getGeometry();
8886
- this.currentAction.do();
8887
- this.actionStack.add(this.currentAction);
8888
- this.currentAction = undefined;
8988
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").to = d.node.getGeometry();
8989
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").do();
8990
+ this.actionStack.add(__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f"));
8991
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
8889
8992
  }
8890
8993
  setCursorStyle();
8891
8994
  }));
@@ -8900,7 +9003,7 @@ class DiagramCanvas {
8900
9003
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8901
9004
  if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
8902
9005
  setCursorStyle(CursorStyle.NSResize);
8903
- this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
9006
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry()), "f");
8904
9007
  } else {
8905
9008
  setCursorStyle(CursorStyle.NotAllowed);
8906
9009
  }
@@ -8910,16 +9013,16 @@ class DiagramCanvas {
8910
9013
  d.node.stretchSections(Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
8911
9014
  }
8912
9015
  }).on(DragEvents.End, (event, d) => {
8913
- if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
9016
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof SetGeometryAction && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").intent === DiagramActions.StretchSection && d.node) {
8914
9017
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8915
9018
  if (this.gridConfig.snap) {
8916
9019
  pointerCoords = this.getClosestGridPoint(pointerCoords);
8917
9020
  }
8918
9021
  d.node.stretchSections(Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
8919
- this.currentAction.to = d.node.getGeometry();
8920
- this.currentAction.do();
8921
- this.actionStack.add(this.currentAction);
8922
- this.currentAction = undefined;
9022
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").to = d.node.getGeometry();
9023
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").do();
9024
+ this.actionStack.add(__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f"));
9025
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
8923
9026
  }
8924
9027
  setCursorStyle();
8925
9028
  }));
@@ -8934,7 +9037,7 @@ class DiagramCanvas {
8934
9037
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8935
9038
  if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
8936
9039
  setCursorStyle(CursorStyle.NSResize);
8937
- this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
9040
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry()), "f");
8938
9041
  } else {
8939
9042
  setCursorStyle(CursorStyle.NotAllowed);
8940
9043
  }
@@ -8944,16 +9047,16 @@ class DiagramCanvas {
8944
9047
  d.node.stretchSections(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
8945
9048
  }
8946
9049
  }).on(DragEvents.End, (event, d) => {
8947
- if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
9050
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof SetGeometryAction && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").intent === DiagramActions.StretchSection && d.node) {
8948
9051
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8949
9052
  if (this.gridConfig.snap) {
8950
9053
  pointerCoords = this.getClosestGridPoint(pointerCoords);
8951
9054
  }
8952
9055
  d.node.stretchSections(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
8953
- this.currentAction.to = d.node.getGeometry();
8954
- this.currentAction.do();
8955
- this.actionStack.add(this.currentAction);
8956
- this.currentAction = undefined;
9056
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").to = d.node.getGeometry();
9057
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").do();
9058
+ this.actionStack.add(__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f"));
9059
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
8957
9060
  }
8958
9061
  setCursorStyle();
8959
9062
  }));
@@ -8968,7 +9071,7 @@ class DiagramCanvas {
8968
9071
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
8969
9072
  if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && d.node) {
8970
9073
  setCursorStyle(CursorStyle.NWSEResize);
8971
- this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
9074
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry()), "f");
8972
9075
  } else {
8973
9076
  setCursorStyle(CursorStyle.NotAllowed);
8974
9077
  }
@@ -8979,17 +9082,17 @@ class DiagramCanvas {
8979
9082
  d.node.stretchSections(Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
8980
9083
  }
8981
9084
  }).on(DragEvents.End, (event, d) => {
8982
- if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
9085
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof SetGeometryAction && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").intent === DiagramActions.StretchSection && d.node) {
8983
9086
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8984
9087
  if (this.gridConfig.snap) {
8985
9088
  pointerCoords = this.getClosestGridPoint(pointerCoords);
8986
9089
  }
8987
9090
  d.node.stretchSections(Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
8988
9091
  d.node.stretchSections(Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
8989
- this.currentAction.to = d.node.getGeometry();
8990
- this.currentAction.do();
8991
- this.actionStack.add(this.currentAction);
8992
- this.currentAction = undefined;
9092
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").to = d.node.getGeometry();
9093
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").do();
9094
+ this.actionStack.add(__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f"));
9095
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
8993
9096
  }
8994
9097
  setCursorStyle();
8995
9098
  }));
@@ -9004,7 +9107,7 @@ class DiagramCanvas {
9004
9107
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
9005
9108
  if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && d.node) {
9006
9109
  setCursorStyle(CursorStyle.NESWResize);
9007
- this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
9110
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry()), "f");
9008
9111
  } else {
9009
9112
  setCursorStyle(CursorStyle.NotAllowed);
9010
9113
  }
@@ -9015,17 +9118,17 @@ class DiagramCanvas {
9015
9118
  d.node.stretchSections(Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
9016
9119
  }
9017
9120
  }).on(DragEvents.End, (event, d) => {
9018
- if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
9121
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof SetGeometryAction && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").intent === DiagramActions.StretchSection && d.node) {
9019
9122
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
9020
9123
  if (this.gridConfig.snap) {
9021
9124
  pointerCoords = this.getClosestGridPoint(pointerCoords);
9022
9125
  }
9023
9126
  d.node.stretchSections(Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
9024
9127
  d.node.stretchSections(Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
9025
- this.currentAction.to = d.node.getGeometry();
9026
- this.currentAction.do();
9027
- this.actionStack.add(this.currentAction);
9028
- this.currentAction = undefined;
9128
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").to = d.node.getGeometry();
9129
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").do();
9130
+ this.actionStack.add(__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f"));
9131
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
9029
9132
  }
9030
9133
  setCursorStyle();
9031
9134
  }));
@@ -9040,7 +9143,7 @@ class DiagramCanvas {
9040
9143
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
9041
9144
  if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && d.node) {
9042
9145
  setCursorStyle(CursorStyle.NESWResize);
9043
- this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
9146
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry()), "f");
9044
9147
  } else {
9045
9148
  setCursorStyle(CursorStyle.NotAllowed);
9046
9149
  }
@@ -9051,17 +9154,17 @@ class DiagramCanvas {
9051
9154
  d.node.stretchSections(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
9052
9155
  }
9053
9156
  }).on(DragEvents.End, (event, d) => {
9054
- if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
9157
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof SetGeometryAction && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").intent === DiagramActions.StretchSection && d.node) {
9055
9158
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
9056
9159
  if (this.gridConfig.snap) {
9057
9160
  pointerCoords = this.getClosestGridPoint(pointerCoords);
9058
9161
  }
9059
9162
  d.node.stretchSections(Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
9060
9163
  d.node.stretchSections(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
9061
- this.currentAction.to = d.node.getGeometry();
9062
- this.currentAction.do();
9063
- this.actionStack.add(this.currentAction);
9064
- this.currentAction = undefined;
9164
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").to = d.node.getGeometry();
9165
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").do();
9166
+ this.actionStack.add(__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f"));
9167
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
9065
9168
  }
9066
9169
  setCursorStyle();
9067
9170
  }));
@@ -9076,7 +9179,7 @@ class DiagramCanvas {
9076
9179
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
9077
9180
  if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && d.node) {
9078
9181
  setCursorStyle(CursorStyle.NWSEResize);
9079
- this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
9182
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry()), "f");
9080
9183
  } else {
9081
9184
  setCursorStyle(CursorStyle.NotAllowed);
9082
9185
  }
@@ -9087,17 +9190,17 @@ class DiagramCanvas {
9087
9190
  d.node.stretchSections(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
9088
9191
  }
9089
9192
  }).on(DragEvents.End, (event, d) => {
9090
- if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
9193
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableXY() && !d.removed && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof SetGeometryAction && __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").intent === DiagramActions.StretchSection && d.node) {
9091
9194
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
9092
9195
  if (this.gridConfig.snap) {
9093
9196
  pointerCoords = this.getClosestGridPoint(pointerCoords);
9094
9197
  }
9095
9198
  d.node.stretchSections(Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
9096
9199
  d.node.stretchSections(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
9097
- this.currentAction.to = d.node.getGeometry();
9098
- this.currentAction.do();
9099
- this.actionStack.add(this.currentAction);
9100
- this.currentAction = undefined;
9200
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").to = d.node.getGeometry();
9201
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").do();
9202
+ this.actionStack.add(__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f"));
9203
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
9101
9204
  }
9102
9205
  setCursorStyle();
9103
9206
  }));
@@ -9113,7 +9216,7 @@ class DiagramCanvas {
9113
9216
  mergeSelection.filter('.resizable-xy').select('rect.bottom-right-resizer').style('pointer-events', d => d.getResizableXY() ? 'initial' : 'none').attr('x', d => d.width - d.getResizerXY().thickness + d.getResizerXY().outerMargin).attr('y', d => d.height - d.getResizerXY().thickness + d.getResizerXY().outerMargin).attr('width', d => d.getResizerXY().thickness).attr('height', d => d.getResizerXY().thickness).attr('fill', d => d.getResizerXY().getLook(d).fillColor || 'transparent').attr('stroke', d => d.getResizerXY().getLook(d).borderColor || 'transparent').attr('stroke-width', d => d.getResizerXY().getLook(d).borderThickness || 0);
9114
9217
  }
9115
9218
  updatePortsInView(...ids) {
9116
- let updateSelection = this.selectCanvasElements().selectAll('g.diagram-port').data(this.model.ports.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
9219
+ let updateSelection = this.selectCanvasElements().selectAll('g.diagram-port').data(this.model.ports.filter(e => __classPrivateFieldGet(this, _DiagramCanvas_priorityThreshold, "f") !== undefined ? e.getPriority() >= __classPrivateFieldGet(this, _DiagramCanvas_priorityThreshold, "f") : true), d => d.id);
9117
9220
  const exitSelection = updateSelection.exit();
9118
9221
  const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => `diagram-port ${d.look.lookType}`);
9119
9222
  if (ids && ids.length > 0) {
@@ -9122,28 +9225,28 @@ class DiagramCanvas {
9122
9225
  const mergeSelection = enterSelection.merge(updateSelection);
9123
9226
  exitSelection.remove();
9124
9227
  enterSelection.on(Events.MouseOver, (_event, d) => {
9125
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
9126
- if (!this.unfinishedConnection && !this.dragging) {
9228
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
9229
+ if (!__classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f") && !__classPrivateFieldGet(this, _DiagramCanvas_dragging, "f")) {
9127
9230
  // if there is an unfinished connection, the port will be highlighted automatically if the pointer is close
9128
9231
  this.userHighlight.focusOn(d);
9129
9232
  this.diagramEvent$.next(new DiagramHighlightedEvent(d));
9130
9233
  }
9131
- if (this.unfinishedConnection) {
9234
+ if (__classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f")) {
9132
9235
  const canConnectionFinishAtThisPort =
9133
9236
  // can start at the starting port
9134
- 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) &&
9237
+ __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").type.canStartFromType(((_d = (_c = (_b = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").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) || '') && ((_e = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").start) === null || _e === void 0 ? void 0 : _e.allowsOutgoing) &&
9135
9238
  // can end at the ending port
9136
- 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 ||
9239
+ __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").type.canFinishOnType(((_g = (_f = d.getNode()) === null || _f === void 0 ? void 0 : _f.type) === null || _g === void 0 ? void 0 : _g.id) || '') && d.allowsIncoming ||
9137
9240
  // can start at the ending port
9138
- 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 &&
9241
+ __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").type.canStartFromType(((_j = (_h = d.getNode()) === null || _h === void 0 ? void 0 : _h.type) === null || _j === void 0 ? void 0 : _j.id) || '') && d.allowsOutgoing &&
9139
9242
  // can end at the starting port
9140
- 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);
9243
+ __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").type.canFinishOnType(((_m = (_l = (_k = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").start) === null || _k === void 0 ? void 0 : _k.getNode()) === null || _l === void 0 ? void 0 : _l.type) === null || _m === void 0 ? void 0 : _m.id) || '') && ((_o = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").start) === null || _o === void 0 ? void 0 : _o.allowsIncoming);
9141
9244
  if (!canConnectionFinishAtThisPort) {
9142
9245
  setCursorStyle(CursorStyle.NoDrop);
9143
9246
  }
9144
9247
  }
9145
9248
  }).on(Events.MouseOut, () => {
9146
- if (this.unfinishedConnection) {
9249
+ if (__classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f")) {
9147
9250
  setCursorStyle(CursorStyle.Grabbing);
9148
9251
  }
9149
9252
  }).on(Events.Click, (event, d) => {
@@ -9156,10 +9259,10 @@ class DiagramCanvas {
9156
9259
  this.userSelection.toggle(elementToBeToggled);
9157
9260
  this.diagramEvent$.next(new DiagramSelectionEvent([elementToBeToggled], elementToBeToggled.selected));
9158
9261
  }).on(Events.ContextMenu, (event, d) => {
9159
- if (this.dragging) {
9262
+ if (__classPrivateFieldGet(this, _DiagramCanvas_dragging, "f")) {
9160
9263
  event.preventDefault();
9161
9264
  event.stopPropagation();
9162
- this.dragging = false;
9265
+ __classPrivateFieldSet(this, _DiagramCanvas_dragging, false, "f");
9163
9266
  return;
9164
9267
  }
9165
9268
  const diagramEvent = new DiagramSecondaryClickEvent(event, d);
@@ -9177,33 +9280,33 @@ class DiagramCanvas {
9177
9280
  const diagramEvent = new DiagramDoubleClickEvent(event, d);
9178
9281
  this.diagramEvent$.next(diagramEvent);
9179
9282
  }).call(d3.drag().filter(event => {
9180
- this.secondaryButton = isSecondaryButton(event);
9283
+ __classPrivateFieldSet(this, _DiagramCanvas_secondaryButton, isSecondaryButton(event), "f");
9181
9284
  return true;
9182
9285
  }).on(DragEvents.Start, (event, d) => {
9183
- if (this.multipleSelectionOn || this.secondaryButton) {
9184
- this.startMultipleSelection(event);
9286
+ if (this.multipleSelectionOn || __classPrivateFieldGet(this, _DiagramCanvas_secondaryButton, "f")) {
9287
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_startMultipleSelection).call(this, event);
9185
9288
  } else {
9186
9289
  if (this.canUserPerformAction(DiagramActions.AddConnection) && (this.allowSharingPorts || d.incomingConnections.filter(c => !c.removed).length === 0 && d.outgoingConnections.filter(c => !c.removed).length === 0) && !d.removed) {
9187
9290
  setCursorStyle(CursorStyle.Grabbing);
9188
- this.startConnection(d);
9291
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_startConnection).call(this, d);
9189
9292
  // should be true after having called this.startConnection()
9190
- if (this.unfinishedConnection) {
9191
- this.unfinishedConnectionTracer = this.selectCanvasElements().append('path').attr('stroke', 'none').attr('fill', 'none');
9293
+ if (__classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f")) {
9294
+ __classPrivateFieldSet(this, _DiagramCanvas_unfinishedConnectionTracer, this.selectCanvasElements().append('path').attr('stroke', 'none').attr('fill', 'none'), "f");
9192
9295
  }
9193
9296
  } else {
9194
9297
  setCursorStyle(CursorStyle.NotAllowed);
9195
9298
  }
9196
9299
  }
9197
9300
  }).on(DragEvents.Drag, (event, d) => {
9198
- var _a, _b, _c, _d, _e;
9199
- if (this.multipleSelectionOn || this.secondaryButton) {
9200
- this.continueMultipleSelection(event);
9301
+ var _b, _c, _d, _e, _f;
9302
+ if (this.multipleSelectionOn || __classPrivateFieldGet(this, _DiagramCanvas_secondaryButton, "f")) {
9303
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_continueMultipleSelection).call(this, event);
9201
9304
  } else {
9202
9305
  if (this.canUserPerformAction(DiagramActions.AddConnection) && !d.removed) {
9203
- if (this.unfinishedConnection !== undefined) {
9306
+ if (__classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f") !== undefined) {
9204
9307
  const endCoords = [event.x, event.y];
9205
- (_a = this.unfinishedConnectionTracer) === null || _a === void 0 ? void 0 : _a.attr('d', getConnectionPath(this.unfinishedConnection.look.shape || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.shape, this.unfinishedConnection.startCoords, endCoords, this.unfinishedConnection.startDirection, this.unfinishedConnection.endDirection, this.unfinishedConnection.points, this.unfinishedConnection.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_b = this.unfinishedConnection.type.defaultStartMarkerLook) === null || _b === void 0 ? void 0 : _b.width, (_c = this.unfinishedConnection.type.defaultEndMarkerLook) === null || _c === void 0 ? void 0 : _c.width));
9206
- const unfinishedConnectionGhostNode = (_d = this.unfinishedConnectionTracer) === null || _d === void 0 ? void 0 : _d.node();
9308
+ (_b = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnectionTracer, "f")) === null || _b === void 0 ? void 0 : _b.attr('d', getConnectionPath(__classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").look.shape || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.shape, __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").startCoords, endCoords, __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").startDirection, __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").endDirection, __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").points, __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_c = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").type.defaultStartMarkerLook) === null || _c === void 0 ? void 0 : _c.width, (_d = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").type.defaultEndMarkerLook) === null || _d === void 0 ? void 0 : _d.width));
9309
+ const unfinishedConnectionGhostNode = (_e = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnectionTracer, "f")) === null || _e === void 0 ? void 0 : _e.node();
9207
9310
  if (unfinishedConnectionGhostNode) {
9208
9311
  let margin = 2;
9209
9312
  const unfinishedConnectionTotalLength = unfinishedConnectionGhostNode.getTotalLength();
@@ -9211,13 +9314,13 @@ class DiagramCanvas {
9211
9314
  margin = 0;
9212
9315
  }
9213
9316
  const beforeUnfinishedConnectionEnd = unfinishedConnectionGhostNode.getPointAtLength(unfinishedConnectionTotalLength - margin);
9214
- this.unfinishedConnection.endCoords = [beforeUnfinishedConnectionEnd.x, beforeUnfinishedConnectionEnd.y];
9317
+ __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").endCoords = [beforeUnfinishedConnectionEnd.x, beforeUnfinishedConnectionEnd.y];
9215
9318
  } else {
9216
9319
  // if it fails, just use the event coordinates
9217
- this.unfinishedConnection.endCoords = endCoords;
9320
+ __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").endCoords = endCoords;
9218
9321
  }
9219
9322
  this.updateConnectionsInView(UNFINISHED_CONNECTION_ID);
9220
- (_e = this.unfinishedConnectionPort) === null || _e === void 0 ? void 0 : _e.raise(false);
9323
+ (_f = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnectionPort, "f")) === null || _f === void 0 ? void 0 : _f.raise(false);
9221
9324
  // highlight closest target port
9222
9325
  if (this.model.ports.length > 0) {
9223
9326
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
@@ -9240,17 +9343,17 @@ class DiagramCanvas {
9240
9343
  }
9241
9344
  }
9242
9345
  }).on(DragEvents.End, (event, d) => {
9243
- var _a;
9244
- if (this.multipleSelectionOn || this.secondaryButton) {
9245
- this.finishMultipleSelection(event);
9346
+ var _b;
9347
+ if (this.multipleSelectionOn || __classPrivateFieldGet(this, _DiagramCanvas_secondaryButton, "f")) {
9348
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_finishMultipleSelection).call(this, event);
9246
9349
  } else {
9247
9350
  if (this.canUserPerformAction(DiagramActions.AddConnection) && !d.removed) {
9248
- (_a = this.unfinishedConnectionTracer) === null || _a === void 0 ? void 0 : _a.remove();
9351
+ (_b = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnectionTracer, "f")) === null || _b === void 0 ? void 0 : _b.remove();
9249
9352
  const userHighlight = this.userHighlight.getFocus();
9250
9353
  if (userHighlight instanceof DiagramPort) {
9251
- this.finishConnection(userHighlight);
9354
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_finishConnection).call(this, userHighlight);
9252
9355
  } else if (userHighlight instanceof DiagramField && userHighlight.rootElement instanceof DiagramPort) {
9253
- this.finishConnection(userHighlight.rootElement);
9356
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_finishConnection).call(this, userHighlight.rootElement);
9254
9357
  } else if (userHighlight instanceof DiagramNode || userHighlight instanceof DiagramSection || userHighlight instanceof DiagramField) {
9255
9358
  let targetRootElement;
9256
9359
  if (userHighlight instanceof DiagramNode || userHighlight instanceof DiagramSection) {
@@ -9258,22 +9361,22 @@ class DiagramCanvas {
9258
9361
  } else if (userHighlight.rootElement instanceof DiagramNode || userHighlight.rootElement instanceof DiagramSection) {
9259
9362
  targetRootElement = userHighlight.rootElement;
9260
9363
  } else {
9261
- this.dropConnection();
9364
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_dropConnection).call(this);
9262
9365
  return;
9263
9366
  }
9264
9367
  const closestPort = targetRootElement.getClosestPortToPoint([event.x, event.y]);
9265
9368
  if (closestPort !== undefined) {
9266
- this.finishConnection(closestPort);
9369
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_finishConnection).call(this, closestPort);
9267
9370
  } else {
9268
- this.dropConnection();
9371
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_dropConnection).call(this);
9269
9372
  }
9270
9373
  } else {
9271
- this.dropConnection();
9374
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_dropConnection).call(this);
9272
9375
  }
9273
9376
  }
9274
9377
  setCursorStyle();
9275
9378
  }
9276
- this.secondaryButton = false;
9379
+ __classPrivateFieldSet(this, _DiagramCanvas_secondaryButton, false, "f");
9277
9380
  }));
9278
9381
  enterSelection.filter('.image-look').append('image');
9279
9382
  initializeLook(enterSelection);
@@ -9281,9 +9384,9 @@ class DiagramCanvas {
9281
9384
  updateLook(mergeSelection);
9282
9385
  }
9283
9386
  updateConnectionsInView(...ids) {
9284
- const connectionList = this.model.connections.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true);
9285
- if (this.unfinishedConnection) {
9286
- connectionList.push(this.unfinishedConnection);
9387
+ const connectionList = this.model.connections.filter(e => __classPrivateFieldGet(this, _DiagramCanvas_priorityThreshold, "f") !== undefined ? e.getPriority() >= __classPrivateFieldGet(this, _DiagramCanvas_priorityThreshold, "f") : true);
9388
+ if (__classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f")) {
9389
+ connectionList.push(__classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f"));
9287
9390
  }
9288
9391
  let updateSelection = this.selectCanvasElements().selectAll('g.diagram-connection').data(connectionList, d => d.id);
9289
9392
  const exitSelection = updateSelection.exit();
@@ -9294,7 +9397,7 @@ class DiagramCanvas {
9294
9397
  const mergeSelection = enterSelection.merge(updateSelection);
9295
9398
  exitSelection.remove();
9296
9399
  enterSelection.on(Events.MouseOver, (_event, d) => {
9297
- if (d.end !== undefined && !this.dragging) {
9400
+ if (d.end !== undefined && !__classPrivateFieldGet(this, _DiagramCanvas_dragging, "f")) {
9298
9401
  this.userHighlight.focusOn(d);
9299
9402
  this.diagramEvent$.next(new DiagramHighlightedEvent(d));
9300
9403
  }
@@ -9307,10 +9410,10 @@ class DiagramCanvas {
9307
9410
  this.userSelection.toggle(d);
9308
9411
  this.diagramEvent$.next(new DiagramSelectionEvent([d], d.selected));
9309
9412
  }).on(Events.ContextMenu, (event, d) => {
9310
- if (this.dragging) {
9413
+ if (__classPrivateFieldGet(this, _DiagramCanvas_dragging, "f")) {
9311
9414
  event.preventDefault();
9312
9415
  event.stopPropagation();
9313
- this.dragging = false;
9416
+ __classPrivateFieldSet(this, _DiagramCanvas_dragging, false, "f");
9314
9417
  return;
9315
9418
  }
9316
9419
  const diagramEvent = new DiagramSecondaryClickEvent(event, d);
@@ -9327,14 +9430,14 @@ class DiagramCanvas {
9327
9430
  const diagramEvent = new DiagramDoubleClickEvent(event, d);
9328
9431
  this.diagramEvent$.next(diagramEvent);
9329
9432
  }).call(d3.drag().filter(event => {
9330
- this.secondaryButton = isSecondaryButton(event);
9433
+ __classPrivateFieldSet(this, _DiagramCanvas_secondaryButton, isSecondaryButton(event), "f");
9331
9434
  return true;
9332
9435
  }).on(DragEvents.Start, event => {
9333
- this.startMultipleSelection(event);
9436
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_startMultipleSelection).call(this, event);
9334
9437
  }).on(DragEvents.Drag, event => {
9335
- this.continueMultipleSelection(event);
9438
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_continueMultipleSelection).call(this, event);
9336
9439
  }).on(DragEvents.End, event => {
9337
- this.finishMultipleSelection(event);
9440
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_finishMultipleSelection).call(this, event);
9338
9441
  }));
9339
9442
  enterSelection.append('path').attr('class', 'diagram-connection-path');
9340
9443
  enterSelection.append('path').attr('class', 'diagram-connection-path-box');
@@ -9350,22 +9453,22 @@ class DiagramCanvas {
9350
9453
  enterSelection.select('g.diagram-connection-end-label').append('path');
9351
9454
  enterSelection.select('g.diagram-connection-end-label').append('text').style('user-select', 'none');
9352
9455
  mergeSelection.attr('opacity', d => d.removed ? 0.5 : 1).select('path.diagram-connection-path').attr('d', d => {
9353
- var _a, _b;
9354
- return getConnectionPath(d.look.shape || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.points, d.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_a = d.type.defaultStartMarkerLook) === null || _a === void 0 ? void 0 : _a.width, (_b = d.type.defaultEndMarkerLook) === null || _b === void 0 ? void 0 : _b.width);
9456
+ var _b, _c;
9457
+ return getConnectionPath(d.look.shape || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.points, d.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_b = d.type.defaultStartMarkerLook) === null || _b === void 0 ? void 0 : _b.width, (_c = d.type.defaultEndMarkerLook) === null || _c === void 0 ? void 0 : _c.width);
9355
9458
  }).attr('marker-start', d => `url(#${d.id}-start-marker)`).attr('marker-end', d => `url(#${d.id}-end-marker)`).attr('stroke', d => d.look.color || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.color).attr('stroke-width', d => d.look.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness).attr('stroke-dasharray', d => lineStyleDasharray(d.look.style || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.style, d.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness)).attr('fill', 'none');
9356
9459
  mergeSelection.select('path.diagram-connection-path-box').attr('d', d => {
9357
- var _a, _b;
9358
- return getConnectionPath(d.look.shape || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.points, d.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_a = d.type.defaultStartMarkerLook) === null || _a === void 0 ? void 0 : _a.width, (_b = d.type.defaultEndMarkerLook) === null || _b === void 0 ? void 0 : _b.width);
9460
+ var _b, _c;
9461
+ return getConnectionPath(d.look.shape || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.points, d.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness, (_b = d.type.defaultStartMarkerLook) === null || _b === void 0 ? void 0 : _b.width, (_c = d.type.defaultEndMarkerLook) === null || _c === void 0 ? void 0 : _c.width);
9359
9462
  }).attr('stroke', 'transparent')
9360
9463
  // allow generating pointer events even when it is transparent
9361
9464
  .attr('pointer-events', 'stroke').attr('stroke-width', d => (d.look.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness) + CONNECTION_PATH_BOX_THICKNESS).attr('stroke-dasharray', d => lineStyleDasharray(d.look.style || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.style, d.type.defaultLook.thickness || DIAGRAM_CONNECTION_TYPE_DEFAULTS.look.thickness)).attr('fill', 'none');
9362
9465
  mergeSelection.data().forEach(connection => {
9363
- this.updateConnectionLabelsInView(connection);
9364
- this.updateConnectionMarkersInView(connection);
9466
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_updateConnectionLabelsInView).call(this, connection);
9467
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_updateConnectionMarkersInView).call(this, connection);
9365
9468
  });
9366
9469
  }
9367
9470
  updateFieldsInView(...ids) {
9368
- let updateSelection = this.selectCanvasElements().selectAll('g.diagram-field').data(this.model.fields.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
9471
+ let updateSelection = this.selectCanvasElements().selectAll('g.diagram-field').data(this.model.fields.filter(e => __classPrivateFieldGet(this, _DiagramCanvas_priorityThreshold, "f") !== undefined ? e.getPriority() >= __classPrivateFieldGet(this, _DiagramCanvas_priorityThreshold, "f") : true), d => d.id);
9369
9472
  const exitSelection = updateSelection.exit();
9370
9473
  const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', 'diagram-field');
9371
9474
  if (ids && ids.length > 0) {
@@ -9374,7 +9477,7 @@ class DiagramCanvas {
9374
9477
  const mergeSelection = enterSelection.merge(updateSelection);
9375
9478
  exitSelection.remove();
9376
9479
  enterSelection.on(Events.MouseOver, (_event, d) => {
9377
- if (!this.dragging) {
9480
+ if (!__classPrivateFieldGet(this, _DiagramCanvas_dragging, "f")) {
9378
9481
  this.userHighlight.focusOn(d);
9379
9482
  this.diagramEvent$.next(new DiagramHighlightedEvent(d));
9380
9483
  }
@@ -9388,10 +9491,10 @@ class DiagramCanvas {
9388
9491
  this.userSelection.toggle(elementToBeToggled);
9389
9492
  this.diagramEvent$.next(new DiagramSelectionEvent([elementToBeToggled], elementToBeToggled.selected));
9390
9493
  }).on(Events.ContextMenu, (event, d) => {
9391
- if (this.dragging) {
9494
+ if (__classPrivateFieldGet(this, _DiagramCanvas_dragging, "f")) {
9392
9495
  event.preventDefault();
9393
9496
  event.stopPropagation();
9394
- this.dragging = false;
9497
+ __classPrivateFieldSet(this, _DiagramCanvas_dragging, false, "f");
9395
9498
  return;
9396
9499
  }
9397
9500
  const diagramEvent = new DiagramSecondaryClickEvent(event, d);
@@ -9409,15 +9512,14 @@ class DiagramCanvas {
9409
9512
  const diagramEvent = new DiagramDoubleClickEvent(event, d);
9410
9513
  this.diagramEvent$.next(diagramEvent);
9411
9514
  if (!diagramEvent.defaultPrevented && this.canUserPerformAction(DiagramActions.EditField) && d.editable && !d.removed) {
9412
- this.currentAction = new EditFieldAction(this, d.id, d.text, '');
9413
9515
  this.openTextInput(d.id);
9414
9516
  }
9415
9517
  }).call(d3.drag().filter(event => {
9416
- this.secondaryButton = isSecondaryButton(event);
9518
+ __classPrivateFieldSet(this, _DiagramCanvas_secondaryButton, isSecondaryButton(event), "f");
9417
9519
  return true;
9418
9520
  }).on(DragEvents.Start, (event, d) => {
9419
- if (this.multipleSelectionOn || this.secondaryButton) {
9420
- this.startMultipleSelection(event);
9521
+ if (this.multipleSelectionOn || __classPrivateFieldGet(this, _DiagramCanvas_secondaryButton, "f")) {
9522
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_startMultipleSelection).call(this, event);
9421
9523
  } else {
9422
9524
  let node;
9423
9525
  if (d.rootElement instanceof DiagramNode) {
@@ -9426,14 +9528,14 @@ class DiagramCanvas {
9426
9528
  node = d.rootElement.node;
9427
9529
  }
9428
9530
  if (node) {
9429
- this.startMovingNode(event, node);
9531
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_startMovingNode).call(this, event, node);
9430
9532
  } else {
9431
9533
  setCursorStyle(CursorStyle.NotAllowed);
9432
9534
  }
9433
9535
  }
9434
9536
  }).on(DragEvents.Drag, (event, d) => {
9435
- if (this.multipleSelectionOn || this.secondaryButton) {
9436
- this.continueMultipleSelection(event);
9537
+ if (this.multipleSelectionOn || __classPrivateFieldGet(this, _DiagramCanvas_secondaryButton, "f")) {
9538
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_continueMultipleSelection).call(this, event);
9437
9539
  } else {
9438
9540
  let node;
9439
9541
  if (d.rootElement instanceof DiagramNode) {
@@ -9442,14 +9544,14 @@ class DiagramCanvas {
9442
9544
  node = d.rootElement.node;
9443
9545
  }
9444
9546
  if (node) {
9445
- this.continueMovingNode(event, node);
9547
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_continueMovingNode).call(this, event, node);
9446
9548
  } else {
9447
9549
  setCursorStyle(CursorStyle.NotAllowed);
9448
9550
  }
9449
9551
  }
9450
9552
  }).on(DragEvents.End, (event, d) => {
9451
- if (this.multipleSelectionOn || this.secondaryButton) {
9452
- this.finishMultipleSelection(event);
9553
+ if (this.multipleSelectionOn || __classPrivateFieldGet(this, _DiagramCanvas_secondaryButton, "f")) {
9554
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_finishMultipleSelection).call(this, event);
9453
9555
  } else {
9454
9556
  let node;
9455
9557
  if (d.rootElement instanceof DiagramNode) {
@@ -9458,24 +9560,24 @@ class DiagramCanvas {
9458
9560
  node = d.rootElement.node;
9459
9561
  }
9460
9562
  if (node) {
9461
- this.finishMovingNode(event, node);
9563
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_finishMovingNode).call(this, event, node);
9462
9564
  } else {
9463
9565
  setCursorStyle();
9464
9566
  }
9465
9567
  }
9466
- this.secondaryButton = false;
9568
+ __classPrivateFieldSet(this, _DiagramCanvas_secondaryButton, false, "f");
9467
9569
  }));
9468
9570
  enterSelection.append('text').style('user-select', 'none').style('font-kerning', 'none').style('white-space', 'nowrap');
9469
9571
  enterSelection.append('rect');
9470
9572
  mergeSelection.attr('x', 0).attr('y', 0).attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]}) rotate(${d.orientation} ${d.width / 2} ${d.height / 2})`).attr('opacity', d => d.removed ? 0.5 : 1).select('text').attr('x', d => d.horizontalAlign === HorizontalAlign.Center ? d.width / 2 : d.horizontalAlign === HorizontalAlign.Right ? d.width : 0).attr('text-anchor', d => d.horizontalAlign === HorizontalAlign.Center ? 'middle' : d.horizontalAlign === HorizontalAlign.Right ? 'end' : 'start').attr('y', d => d.verticalAlign === VerticalAlign.Center ? d.height / 2 : d.verticalAlign === VerticalAlign.Bottom ? d.height : 0).attr('dominant-baseline', d => d.verticalAlign === VerticalAlign.Center ? 'middle' : d.verticalAlign === VerticalAlign.Bottom ? 'auto' : 'hanging').attr('font-size', d => d.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize).attr('font-family', d => d.look.fontFamily || "'Wonder Unit Sans', sans-serif").attr('font-weight', d => d.look.fontWeight || DIAGRAM_FIELD_DEFAULTS.look.fontWeight).attr('fill', d => d.look.fontColor || DIAGRAM_FIELD_DEFAULTS.look.fontColor).style('font-kerning', 'none').each(d => {
9471
- this.setFieldTextAndWrap(d);
9573
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_setFieldTextAndWrap).call(this, d);
9472
9574
  });
9473
9575
  mergeSelection
9474
9576
  // add a transparent rectangle to capture pointer events on the text
9475
9577
  .select('rect').attr('x', 0).attr('y', 0).attr('width', d => d.width).attr('height', d => d.height).attr('fill', 'transparent');
9476
9578
  }
9477
9579
  updateObjectsInView(...ids) {
9478
- let updateSelection = this.selectCanvasElements().selectAll('g.diagram-object').data(this.model.objects.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
9580
+ let updateSelection = this.selectCanvasElements().selectAll('g.diagram-object').data(this.model.objects.filter(e => __classPrivateFieldGet(this, _DiagramCanvas_priorityThreshold, "f") !== undefined ? e.getPriority() >= __classPrivateFieldGet(this, _DiagramCanvas_priorityThreshold, "f") : true), d => d.id);
9479
9581
  const exitSelection = updateSelection.exit();
9480
9582
  const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', 'diagram-object');
9481
9583
  if (ids && ids.length > 0) {
@@ -9485,10 +9587,10 @@ class DiagramCanvas {
9485
9587
  mergeSelection.attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).html(d => d.svg);
9486
9588
  exitSelection.remove();
9487
9589
  enterSelection.on(Events.ContextMenu, (event, d) => {
9488
- if (this.dragging) {
9590
+ if (__classPrivateFieldGet(this, _DiagramCanvas_dragging, "f")) {
9489
9591
  event.preventDefault();
9490
9592
  event.stopPropagation();
9491
- this.dragging = false;
9593
+ __classPrivateFieldSet(this, _DiagramCanvas_dragging, false, "f");
9492
9594
  return;
9493
9595
  }
9494
9596
  const diagramEvent = new DiagramSecondaryClickEvent(event, d);
@@ -9501,24 +9603,24 @@ class DiagramCanvas {
9501
9603
  const diagramEvent = new DiagramDoubleClickEvent(event, d);
9502
9604
  this.diagramEvent$.next(diagramEvent);
9503
9605
  }).call(d3.drag().filter(event => {
9504
- this.secondaryButton = isSecondaryButton(event);
9606
+ __classPrivateFieldSet(this, _DiagramCanvas_secondaryButton, isSecondaryButton(event), "f");
9505
9607
  return true;
9506
9608
  }).on(DragEvents.Start, event => {
9507
- if (this.multipleSelectionOn || this.secondaryButton) {
9508
- this.startMultipleSelection(event);
9609
+ if (this.multipleSelectionOn || __classPrivateFieldGet(this, _DiagramCanvas_secondaryButton, "f")) {
9610
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_startMultipleSelection).call(this, event);
9509
9611
  }
9510
9612
  }).on(DragEvents.Drag, event => {
9511
- if (this.multipleSelectionOn || this.secondaryButton) {
9512
- this.continueMultipleSelection(event);
9613
+ if (this.multipleSelectionOn || __classPrivateFieldGet(this, _DiagramCanvas_secondaryButton, "f")) {
9614
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_continueMultipleSelection).call(this, event);
9513
9615
  }
9514
9616
  }).on(DragEvents.End, event => {
9515
- if (this.multipleSelectionOn || this.secondaryButton) {
9516
- this.finishMultipleSelection(event);
9617
+ if (this.multipleSelectionOn || __classPrivateFieldGet(this, _DiagramCanvas_secondaryButton, "f")) {
9618
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_finishMultipleSelection).call(this, event);
9517
9619
  }
9518
9620
  }));
9519
9621
  }
9520
9622
  updateDecoratorsInView(...ids) {
9521
- let updateSelection = this.selectCanvasElements().selectAll('g.diagram-decorator').data(this.model.decorators.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
9623
+ let updateSelection = this.selectCanvasElements().selectAll('g.diagram-decorator').data(this.model.decorators.filter(e => __classPrivateFieldGet(this, _DiagramCanvas_priorityThreshold, "f") !== undefined ? e.getPriority() >= __classPrivateFieldGet(this, _DiagramCanvas_priorityThreshold, "f") : true), d => d.id);
9522
9624
  const exitSelection = updateSelection.exit();
9523
9625
  const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', 'diagram-decorator');
9524
9626
  if (ids && ids.length > 0) {
@@ -9528,7 +9630,7 @@ class DiagramCanvas {
9528
9630
  mergeSelection.attr('width', d => d.width).attr('height', d => d.height).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).html(d => d.svg);
9529
9631
  exitSelection.remove();
9530
9632
  enterSelection.on(Events.MouseOver, (_event, d) => {
9531
- if (!this.dragging) {
9633
+ if (!__classPrivateFieldGet(this, _DiagramCanvas_dragging, "f")) {
9532
9634
  this.userHighlight.focusOn(d);
9533
9635
  this.diagramEvent$.next(new DiagramHighlightedEvent(d));
9534
9636
  }
@@ -9544,10 +9646,10 @@ class DiagramCanvas {
9544
9646
  this.diagramEvent$.next(new DiagramSelectionEvent([elementToBeToggled], elementToBeToggled.selected));
9545
9647
  }
9546
9648
  }).on(Events.ContextMenu, (event, d) => {
9547
- if (this.dragging) {
9649
+ if (__classPrivateFieldGet(this, _DiagramCanvas_dragging, "f")) {
9548
9650
  event.preventDefault();
9549
9651
  event.stopPropagation();
9550
- this.dragging = false;
9652
+ __classPrivateFieldSet(this, _DiagramCanvas_dragging, false, "f");
9551
9653
  return;
9552
9654
  }
9553
9655
  const diagramEvent = new DiagramSecondaryClickEvent(event, d);
@@ -9567,11 +9669,11 @@ class DiagramCanvas {
9567
9669
  const diagramEvent = new DiagramDoubleClickEvent(event, d);
9568
9670
  this.diagramEvent$.next(diagramEvent);
9569
9671
  }).call(d3.drag().filter(event => {
9570
- this.secondaryButton = isSecondaryButton(event);
9672
+ __classPrivateFieldSet(this, _DiagramCanvas_secondaryButton, isSecondaryButton(event), "f");
9571
9673
  return true;
9572
9674
  }).on(DragEvents.Start, (event, d) => {
9573
- if (this.multipleSelectionOn || this.secondaryButton) {
9574
- this.startMultipleSelection(event);
9675
+ if (this.multipleSelectionOn || __classPrivateFieldGet(this, _DiagramCanvas_secondaryButton, "f")) {
9676
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_startMultipleSelection).call(this, event);
9575
9677
  } else {
9576
9678
  let node;
9577
9679
  if (d.rootElement instanceof DiagramNode) {
@@ -9580,14 +9682,14 @@ class DiagramCanvas {
9580
9682
  node = d.rootElement.node;
9581
9683
  }
9582
9684
  if (node) {
9583
- this.startMovingNode(event, node);
9685
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_startMovingNode).call(this, event, node);
9584
9686
  } else {
9585
9687
  setCursorStyle(CursorStyle.NotAllowed);
9586
9688
  }
9587
9689
  }
9588
9690
  }).on(DragEvents.Drag, (event, d) => {
9589
- if (this.multipleSelectionOn || this.secondaryButton) {
9590
- this.continueMultipleSelection(event);
9691
+ if (this.multipleSelectionOn || __classPrivateFieldGet(this, _DiagramCanvas_secondaryButton, "f")) {
9692
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_continueMultipleSelection).call(this, event);
9591
9693
  } else {
9592
9694
  let node;
9593
9695
  if (d.rootElement instanceof DiagramNode) {
@@ -9596,14 +9698,14 @@ class DiagramCanvas {
9596
9698
  node = d.rootElement.node;
9597
9699
  }
9598
9700
  if (node) {
9599
- this.continueMovingNode(event, node);
9701
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_continueMovingNode).call(this, event, node);
9600
9702
  } else {
9601
9703
  setCursorStyle(CursorStyle.NotAllowed);
9602
9704
  }
9603
9705
  }
9604
9706
  }).on(DragEvents.End, (event, d) => {
9605
- if (this.multipleSelectionOn || this.secondaryButton) {
9606
- this.finishMultipleSelection(event);
9707
+ if (this.multipleSelectionOn || __classPrivateFieldGet(this, _DiagramCanvas_secondaryButton, "f")) {
9708
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_finishMultipleSelection).call(this, event);
9607
9709
  } else {
9608
9710
  let node;
9609
9711
  if (d.rootElement instanceof DiagramNode) {
@@ -9612,187 +9714,76 @@ class DiagramCanvas {
9612
9714
  node = d.rootElement.node;
9613
9715
  }
9614
9716
  if (node) {
9615
- this.finishMovingNode(event, node);
9717
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_finishMovingNode).call(this, event, node);
9616
9718
  } else {
9617
9719
  setCursorStyle();
9618
9720
  }
9619
9721
  }
9620
- this.secondaryButton = false;
9722
+ __classPrivateFieldSet(this, _DiagramCanvas_secondaryButton, false, "f");
9621
9723
  }));
9622
9724
  }
9623
- updateConnectionLabelsInView(connection) {
9624
- var _a, _b, _c;
9625
- const connectionSelection = this.selectCanvasView().select(`[id='${escapeSelector(connection.id)}']`);
9626
- const pathSelection = connectionSelection.select('path');
9627
- const pathNode = pathSelection.node();
9628
- const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), connection.type.label);
9629
- labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
9630
- if (pathNode) {
9631
- const pathLength = pathNode.getTotalLength();
9632
- let startLabelShiftX = 0;
9633
- let startLabelShiftY = 0;
9634
- let middleLabelShiftX = 0;
9635
- let middleLabelShiftY = 0;
9636
- let endLabelShiftX = 0;
9637
- let endLabelShiftY = 0;
9638
- if (labelConfiguration.look.fillColor === 'transparent') {
9639
- // background color is transparent / not set, so we find an alternative position for the label
9640
- const deltaX = connection.endCoords[0] - connection.startCoords[0];
9641
- const deltaY = connection.endCoords[1] - connection.startCoords[1];
9642
- switch (connection.startDirection) {
9643
- case Side.Top:
9644
- startLabelShiftX = deltaX >= 0 ? -0.5 : 0.5;
9645
- endLabelShiftX = startLabelShiftX;
9646
- break;
9647
- case Side.Bottom:
9648
- startLabelShiftX = deltaX >= 0 ? -0.5 : 0.5;
9649
- endLabelShiftX = startLabelShiftX;
9650
- break;
9651
- case Side.Left:
9652
- startLabelShiftY = deltaY > 0 ? -0.5 : 0.5;
9653
- endLabelShiftY = startLabelShiftY;
9654
- break;
9655
- case Side.Right:
9656
- startLabelShiftY = deltaY > 0 ? -0.5 : 0.5;
9657
- endLabelShiftY = startLabelShiftY;
9658
- break;
9659
- default:
9660
- startLabelShiftX = 0.5;
9661
- endLabelShiftX = startLabelShiftX;
9662
- startLabelShiftY = -0.5;
9663
- endLabelShiftY = startLabelShiftY;
9664
- }
9665
- switch (connection.endDirection) {
9666
- case Side.Top:
9667
- endLabelShiftX = deltaX >= 0 ? 0.5 : -0.5;
9668
- break;
9669
- case Side.Bottom:
9670
- endLabelShiftX = deltaX >= 0 ? 0.5 : -0.5;
9671
- break;
9672
- case Side.Left:
9673
- endLabelShiftY = deltaY > 0 ? 0.5 : -0.5;
9674
- break;
9675
- case Side.Right:
9676
- endLabelShiftY = deltaY > 0 ? 0.5 : -0.5;
9677
- break;
9678
- default:
9679
- endLabelShiftX = 0.5;
9680
- endLabelShiftY = -0.5;
9681
- }
9682
- if (Math.abs(deltaX) >= Math.abs(deltaY)) {
9683
- // horizontal quadrant
9684
- middleLabelShiftX = deltaX > 0 ? -0.5 : 0.5;
9685
- middleLabelShiftY = deltaY > 0 ? 0.5 : -0.5;
9686
- } else {
9687
- // vertical quadrant
9688
- middleLabelShiftX = deltaX > 0 ? 0.5 : -0.5;
9689
- middleLabelShiftY = deltaY > 0 ? -0.5 : 0.5;
9690
- }
9691
- }
9692
- // bind start labels
9693
- connectionSelection.select('g.diagram-connection-start-label text').attr('x', 0).attr('y', (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.look.fontFamily || DIAGRAM_FIELD_DEFAULTS.look.fontFamily).attr('font-size', labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize).attr('fill', labelConfiguration.look.fontColor || DIAGRAM_FIELD_DEFAULTS.look.fontColor).text(connection.startLabel);
9694
- const startLabelBoundingRect = (_a = connectionSelection.select('g.diagram-connection-start-label text').node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
9695
- if (startLabelBoundingRect) {
9696
- // don't create space for the label if the label is empty
9697
- const boundingWidth = !connection.startLabel ? 0 : startLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
9698
- const boundingHeight = !connection.startLabel ? 0 : startLabelBoundingRect.height / this.zoomTransform.k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
9699
- let pathStartLabelPoint;
9700
- switch (connection.startDirection) {
9701
- case Side.Left:
9702
- pathStartLabelPoint = pathNode.getPointAtLength(getRightMargin(labelConfiguration) + boundingWidth / 2);
9703
- break;
9704
- case Side.Right:
9705
- pathStartLabelPoint = pathNode.getPointAtLength(getLeftMargin(labelConfiguration) + boundingWidth / 2);
9706
- break;
9707
- case Side.Top:
9708
- pathStartLabelPoint = pathNode.getPointAtLength(getBottomMargin(labelConfiguration) + boundingHeight / 2);
9709
- break;
9710
- case Side.Bottom:
9711
- pathStartLabelPoint = pathNode.getPointAtLength(getTopMargin(labelConfiguration) + boundingHeight / 2);
9712
- break;
9713
- default:
9714
- pathStartLabelPoint = pathNode.getPointAtLength(Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
9715
- }
9716
- connectionSelection.select('g.diagram-connection-start-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.look.fillColor || DIAGRAM_FIELD_DEFAULTS.look.fillColor).attr('stroke', 'none');
9717
- connectionSelection.select('g.diagram-connection-start-label').attr('transform', `translate(${pathStartLabelPoint.x + startLabelShiftX * boundingWidth},${pathStartLabelPoint.y + startLabelShiftY * boundingHeight})`);
9718
- }
9719
- // bind middle labels
9720
- connectionSelection.select('g.diagram-connection-middle-label text').attr('x', 0).attr('y', (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.look.fontFamily || DIAGRAM_FIELD_DEFAULTS.look.fontFamily).attr('font-size', labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize).attr('fill', labelConfiguration.look.fontColor || DIAGRAM_FIELD_DEFAULTS.look.fillColor).style('font-kerning', 'none').text(connection.middleLabel);
9721
- const middleLabelBoundingRect = (_b = connectionSelection.select('g.diagram-connection-middle-label text').node()) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
9722
- if (middleLabelBoundingRect) {
9723
- // don't create space for the label if the label is empty
9724
- const boundingWidth = !connection.middleLabel ? 0 : middleLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
9725
- const boundingHeight = !connection.middleLabel ? 0 : middleLabelBoundingRect.height / this.zoomTransform.k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
9726
- const pathMiddleLabelPoint = pathNode.getPointAtLength(pathLength / 2);
9727
- connectionSelection.select('g.diagram-connection-middle-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.look.fillColor || DIAGRAM_FIELD_DEFAULTS.look.fillColor).attr('stroke', 'none');
9728
- connectionSelection.select('g.diagram-connection-middle-label').attr('transform', `translate(${pathMiddleLabelPoint.x + middleLabelShiftX * boundingWidth},${pathMiddleLabelPoint.y + middleLabelShiftY * boundingHeight})`);
9729
- }
9730
- // bind end labels
9731
- connectionSelection.select('g.diagram-connection-end-label text').attr('x', 0).attr('y', (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.look.fontFamily || DIAGRAM_FIELD_DEFAULTS.look.fontFamily).attr('font-size', labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize).attr('fill', labelConfiguration.look.fontColor || DIAGRAM_FIELD_DEFAULTS.look.fontColor).style('font-kerning', 'none').text(connection.endLabel);
9732
- const endLabelBoundingRect = (_c = connectionSelection.select('g.diagram-connection-end-label text').node()) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect();
9733
- if (endLabelBoundingRect) {
9734
- // don't create space for the label if the label is empty
9735
- const boundingWidth = !connection.endLabel ? 0 : endLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
9736
- const boundingHeight = !connection.endLabel ? 0 : endLabelBoundingRect.height / this.zoomTransform.k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
9737
- let pathEndLabelPoint;
9738
- switch (connection.endDirection) {
9739
- case Side.Left:
9740
- pathEndLabelPoint = pathNode.getPointAtLength(pathLength - (getRightMargin(labelConfiguration) + boundingWidth / 2));
9741
- break;
9742
- case Side.Right:
9743
- pathEndLabelPoint = pathNode.getPointAtLength(pathLength - (getLeftMargin(labelConfiguration) + boundingWidth / 2));
9744
- break;
9745
- case Side.Top:
9746
- pathEndLabelPoint = pathNode.getPointAtLength(pathLength - (getBottomMargin(labelConfiguration) + boundingHeight / 2));
9747
- break;
9748
- case Side.Bottom:
9749
- pathEndLabelPoint = pathNode.getPointAtLength(pathLength - (getTopMargin(labelConfiguration) + boundingHeight / 2));
9750
- break;
9751
- default:
9752
- pathEndLabelPoint = pathNode.getPointAtLength(pathLength - Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
9753
- }
9754
- connectionSelection.select('g.diagram-connection-end-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.look.fillColor || DIAGRAM_FIELD_DEFAULTS.look.fillColor).attr('stroke', 'none');
9755
- connectionSelection.select('g.diagram-connection-end-label').attr('transform', `translate(${pathEndLabelPoint.x + endLabelShiftX * boundingWidth},${pathEndLabelPoint.y + endLabelShiftY * boundingHeight})`);
9756
- }
9757
- }
9758
- }
9759
- updateConnectionMarkersInView(connection) {
9760
- const connectionSelection = this.selectCanvasView().select(`[id='${escapeSelector(connection.id)}']`);
9761
- const startMarkerSelection = connectionSelection.select('marker.diagram-connection-start-marker');
9762
- const endMarkerSelection = connectionSelection.select('marker.diagram-connection-end-marker');
9763
- if (connection.startMarkerLook !== null) {
9764
- startMarkerSelection.attr('orient', 'auto-start-reverse').attr('markerWidth', connection.startMarkerLook.width).attr('markerHeight', connection.startMarkerLook.height).attr('refX', connection.startMarkerLook.refX).attr('refY', connection.startMarkerLook.refY).select('image').attr('href', connection.startMarkerLook.image).attr('width', connection.startMarkerLook.width).attr('height', connection.startMarkerLook.height);
9765
- } else {
9766
- startMarkerSelection.attr('orient', 'auto-start-reverse').attr('markerWidth', 0).attr('markerHeight', 0);
9767
- }
9768
- if (connection.endMarkerLook !== null) {
9769
- endMarkerSelection.attr('orient', 'auto-start-reverse').attr('markerWidth', connection.endMarkerLook.width).attr('markerHeight', connection.endMarkerLook.height).attr('refX', connection.endMarkerLook.refX).attr('refY', connection.endMarkerLook.refY).select('image').attr('href', connection.endMarkerLook.image).attr('width', connection.endMarkerLook.width).attr('height', connection.endMarkerLook.height);
9770
- } else {
9771
- endMarkerSelection.attr('orient', 'auto-start-reverse').attr('markerWidth', 0).attr('markerHeight', 0);
9725
+ bringToFront(node) {
9726
+ const overlappingNodes = this.model.nodes.filter(n => n.id !== node.id && rectanglesIntersect([n.coords, [n.coords[0] + n.width, n.coords[1] + n.height]], [node.coords, [node.coords[0] + node.width, node.coords[1] + node.height]]));
9727
+ let maximumZ = node.z;
9728
+ for (const n of overlappingNodes) {
9729
+ if (n.z > maximumZ) {
9730
+ maximumZ = n.z;
9731
+ }
9772
9732
  }
9733
+ maximumZ += 1;
9734
+ const action = new SetGeometryAction(this, DiagramActions.MoveNode, node.id, node.getGeometry(), node.getGeometry());
9735
+ node.setGeometry(Object.assign(Object.assign({}, node.getGeometry()), {
9736
+ z: maximumZ
9737
+ }));
9738
+ node.raiseWithZ();
9739
+ action.to = node.getGeometry();
9740
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, action, "f");
9741
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").do();
9742
+ this.actionStack.add(__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f"));
9743
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
9744
+ }
9745
+ sendToBack(node) {
9746
+ const overlappingNodes = this.model.nodes.filter(n => n.id !== node.id && rectanglesIntersect([n.coords, [n.coords[0] + n.width, n.coords[1] + n.height]], [node.coords, [node.coords[0] + node.width, node.coords[1] + node.height]]));
9747
+ let minimumZ = node.z;
9748
+ for (const n of overlappingNodes) {
9749
+ if (n.z < minimumZ) {
9750
+ minimumZ = n.z;
9751
+ }
9752
+ }
9753
+ minimumZ -= 1;
9754
+ const action = new SetGeometryAction(this, DiagramActions.MoveNode, node.id, node.getGeometry(), node.getGeometry());
9755
+ node.setGeometry(Object.assign(Object.assign({}, node.getGeometry()), {
9756
+ z: minimumZ
9757
+ }));
9758
+ node.raiseWithZ();
9759
+ action.to = node.getGeometry();
9760
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, action, "f");
9761
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").do();
9762
+ this.actionStack.add(__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f"));
9763
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
9773
9764
  }
9774
9765
  fieldRootFitsInView(id) {
9775
- var _a, _b, _c, _d;
9766
+ var _b, _c, _d, _e;
9776
9767
  const field = this.model.fields.get(id);
9777
9768
  if (!field) {
9778
9769
  return false;
9779
9770
  }
9780
9771
  if (field.rootElement instanceof DiagramNode || field.rootElement instanceof DiagramSection) {
9781
- const fieldDimensions = this.minimumSizeOfField(field);
9782
- 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;
9783
- 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;
9772
+ const fieldDimensions = __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_minimumSizeOfField).call(this, field);
9773
+ const stretchX = fieldDimensions[0] + getLeftMargin((_b = field.rootElement.type) === null || _b === void 0 ? void 0 : _b.label) + getRightMargin((_c = field.rootElement.type) === null || _c === void 0 ? void 0 : _c.label) - field.rootElement.width;
9774
+ const stretchY = fieldDimensions[1] + getTopMargin((_d = field.rootElement.type) === null || _d === void 0 ? void 0 : _d.label) + getBottomMargin((_e = field.rootElement.type) === null || _e === void 0 ? void 0 : _e.label) - field.rootElement.height;
9784
9775
  return stretchX <= 0 && stretchY <= 0;
9785
9776
  }
9786
9777
  return true;
9787
9778
  }
9788
9779
  fitFieldRootInView(id, shrink = true) {
9789
- var _a, _b, _c;
9780
+ var _b, _c, _d;
9790
9781
  const field = this.model.fields.get(id);
9791
9782
  if (!field) {
9792
9783
  return;
9793
9784
  }
9794
9785
  if (field.rootElement instanceof DiagramNode) {
9795
- const fieldDimensions = this.minimumSizeOfField(field);
9786
+ const fieldDimensions = __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_minimumSizeOfField).call(this, field);
9796
9787
  let stretchX = fieldDimensions[0] + getLeftMargin(field.rootElement.type.label) + getRightMargin(field.rootElement.type.label) - field.rootElement.width;
9797
9788
  let stretchY = fieldDimensions[1] + getTopMargin(field.rootElement.type.label) + getBottomMargin(field.rootElement.type.label) - field.rootElement.height;
9798
9789
  const spacingX = getGridSpacingX(this.gridConfig);
@@ -9818,15 +9809,15 @@ class DiagramCanvas {
9818
9809
  }
9819
9810
  }
9820
9811
  if (field.rootElement instanceof DiagramSection) {
9821
- const fieldDimensions = this.minimumSizeOfField(field);
9812
+ const fieldDimensions = __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_minimumSizeOfField).call(this, field);
9822
9813
  let minimumFieldWidth = fieldDimensions[0];
9823
9814
  let minimumFieldHeight = fieldDimensions[1];
9824
- for (const section of ((_a = field.rootElement.node) === null || _a === void 0 ? void 0 : _a.sections) || []) {
9815
+ for (const section of ((_b = field.rootElement.node) === null || _b === void 0 ? void 0 : _b.sections) || []) {
9825
9816
  if (section.label) {
9826
9817
  if (section.indexXInNode === field.rootElement.indexXInNode && section.indexYInNode !== field.rootElement.indexYInNode) {
9827
- minimumFieldWidth = Math.max(minimumFieldWidth, this.minimumSizeOfField(section.label)[0]);
9818
+ minimumFieldWidth = Math.max(minimumFieldWidth, __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_minimumSizeOfField).call(this, section.label)[0]);
9828
9819
  } else if (section.indexXInNode !== field.rootElement.indexXInNode && section.indexYInNode === field.rootElement.indexYInNode) {
9829
- minimumFieldHeight = Math.max(minimumFieldHeight, this.minimumSizeOfField(section.label)[1]);
9820
+ minimumFieldHeight = Math.max(minimumFieldHeight, __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_minimumSizeOfField).call(this, section.label)[1]);
9830
9821
  }
9831
9822
  }
9832
9823
  }
@@ -9855,25 +9846,25 @@ class DiagramCanvas {
9855
9846
  stretchY = (field.rootElement.getMinHeight() || 0) - field.rootElement.height;
9856
9847
  }
9857
9848
  if (shrink || stretchX > 0) {
9858
- (_b = field.rootElement.node) === null || _b === void 0 ? void 0 : _b.stretchSections(Side.Right, stretchX, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
9849
+ (_c = field.rootElement.node) === null || _c === void 0 ? void 0 : _c.stretchSections(Side.Right, stretchX, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
9859
9850
  }
9860
9851
  if (shrink || stretchY > 0) {
9861
- (_c = field.rootElement.node) === null || _c === void 0 ? void 0 : _c.stretchSections(Side.Bottom, stretchY, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
9852
+ (_d = field.rootElement.node) === null || _d === void 0 ? void 0 : _d.stretchSections(Side.Bottom, stretchY, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
9862
9853
  }
9863
9854
  }
9864
9855
  }
9865
9856
  fitNodeInView(id, shrink = true) {
9866
- var _a, _b;
9857
+ var _b, _c;
9867
9858
  const node = this.model.nodes.get(id);
9868
9859
  if (!node) {
9869
9860
  return;
9870
9861
  }
9871
- if (node.sections.length > 0 && this.priorityThreshold) {
9862
+ if (node.sections.length > 0 && __classPrivateFieldGet(this, _DiagramCanvas_priorityThreshold, "f")) {
9872
9863
  let newNodeWidth = 0;
9873
9864
  let newNodeHeight = 0;
9874
9865
  // calculate newNodeWidth, newNodeHeight as the rightmost and bottommost points of any of the sections of the node
9875
9866
  for (const section of node.sections) {
9876
- if (section.getPriority() >= this.priorityThreshold) {
9867
+ if (section.getPriority() >= __classPrivateFieldGet(this, _DiagramCanvas_priorityThreshold, "f")) {
9877
9868
  const sectionLastXCoordRelativeToNode = section.coords[0] + section.width - node.coords[0];
9878
9869
  const sectionLastYCoordRelativeToNode = section.coords[1] + section.height - node.coords[1];
9879
9870
  newNodeWidth = Math.max(newNodeWidth, sectionLastXCoordRelativeToNode);
@@ -9881,8 +9872,8 @@ class DiagramCanvas {
9881
9872
  }
9882
9873
  }
9883
9874
  // add the margin that goes between the rightmost and bottommost points of the sections and the edge of the node
9884
- newNodeWidth += ((_a = node.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
9885
- newNodeHeight += ((_b = node.type.sectionGrid) === null || _b === void 0 ? void 0 : _b.margin) || 0;
9875
+ newNodeWidth += ((_b = node.type.sectionGrid) === null || _b === void 0 ? void 0 : _b.margin) || 0;
9876
+ newNodeHeight += ((_c = node.type.sectionGrid) === null || _c === void 0 ? void 0 : _c.margin) || 0;
9886
9877
  if (shrink || newNodeWidth > node.width) {
9887
9878
  node.stretch(Side.Right, newNodeWidth - node.width);
9888
9879
  }
@@ -9892,7 +9883,7 @@ class DiagramCanvas {
9892
9883
  }
9893
9884
  }
9894
9885
  selectRoot() {
9895
- return d3.select(this.diagramRoot);
9886
+ return d3.select(__classPrivateFieldGet(this, _DiagramCanvas_diagramRoot, "f"));
9896
9887
  }
9897
9888
  selectSVGElement() {
9898
9889
  return this.selectRoot().select('svg');
@@ -9903,107 +9894,10 @@ class DiagramCanvas {
9903
9894
  selectCanvasElements() {
9904
9895
  return this.selectCanvasView().select(`.daga-canvas-elements`);
9905
9896
  }
9906
- // User actions
9907
- startConnection(port) {
9908
- var _a, _b, _c, _d;
9909
- if (port.allowsOutgoing || port.allowsIncoming) {
9910
- 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)) {
9911
- this.unfinishedConnection = new DiagramConnection(this.model, this.connectionType, port, undefined, UNFINISHED_CONNECTION_ID);
9912
- this.unfinishedConnectionPort = port;
9913
- } else {
9914
- if (this.inferConnectionType) {
9915
- let differentConnectionType = this.model.connections.types.all().find(t => {
9916
- var _a, _b;
9917
- 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) || '');
9918
- });
9919
- if (differentConnectionType === undefined) {
9920
- differentConnectionType = this.model.connections.types.all().find(t => {
9921
- var _a, _b;
9922
- 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) || '');
9923
- });
9924
- }
9925
- if (differentConnectionType !== undefined) {
9926
- this.unfinishedConnection = new DiagramConnection(this.model, differentConnectionType, port, undefined, UNFINISHED_CONNECTION_ID);
9927
- this.unfinishedConnectionPort = port;
9928
- }
9929
- }
9930
- }
9931
- }
9932
- }
9933
- finishConnection(port) {
9934
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
9935
- this.userHighlight.clear();
9936
- if (this.unfinishedConnection !== undefined) {
9937
- if (!this.allowConnectionLoops && this.unfinishedConnection.start === port) {
9938
- this.dropConnection();
9939
- return;
9940
- }
9941
- if (!this.allowSharingPorts && (port.incomingConnections.filter(c => !c.removed).length > 0 || port.outgoingConnections.filter(c => !c.removed).length > 0)) {
9942
- this.dropConnection();
9943
- return;
9944
- }
9945
- if (!this.allowSharingBothPorts && this.model.connections.find(c => {
9946
- var _a, _b;
9947
- return !c.removed && (c.start === ((_a = this.unfinishedConnection) === null || _a === void 0 ? void 0 : _a.start) && c.end === port || c.end === ((_b = this.unfinishedConnection) === null || _b === void 0 ? void 0 : _b.start) && c.start === port);
9948
- }) !== undefined) {
9949
- this.dropConnection();
9950
- return;
9951
- }
9952
- 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) {
9953
- const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, (_j = this.unfinishedConnection.start) === null || _j === void 0 ? void 0 : _j.id, port.id);
9954
- // clean up the previous unfinished connection
9955
- this.dropConnection();
9956
- addConnectionAction.do();
9957
- this.actionStack.add(addConnectionAction);
9958
- } 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) {
9959
- const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, port.id, (_t = this.unfinishedConnection.start) === null || _t === void 0 ? void 0 : _t.id);
9960
- // clean up the previous unfinished connection
9961
- this.dropConnection();
9962
- addConnectionAction.do();
9963
- this.actionStack.add(addConnectionAction);
9964
- } else {
9965
- if (this.inferConnectionType) {
9966
- let differentConnectionType = this.model.connections.types.all().find(t => {
9967
- var _a, _b, _c, _d, _e, _f, _g, _h;
9968
- 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;
9969
- });
9970
- let invertConnection = false;
9971
- if (differentConnectionType === undefined) {
9972
- differentConnectionType = this.model.connections.types.all().find(t => {
9973
- var _a, _b, _c, _d, _e, _f, _g, _h;
9974
- 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;
9975
- });
9976
- invertConnection = true;
9977
- }
9978
- if (differentConnectionType !== undefined) {
9979
- 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);
9980
- // clean up the previous unfinished connection
9981
- this.dropConnection();
9982
- addConnectionAction.do();
9983
- this.actionStack.add(addConnectionAction);
9984
- } else {
9985
- // error: connection target of wrong type and no allowed type can be found
9986
- this.dropConnection();
9987
- }
9988
- } else {
9989
- // error: connection target of wrong type and can't guess for a different type
9990
- this.dropConnection();
9991
- }
9992
- }
9993
- }
9994
- }
9995
- dropConnection() {
9996
- var _a, _b, _c, _d;
9997
- (_a = this.unfinishedConnection) === null || _a === void 0 ? void 0 : _a.setStart(undefined);
9998
- (_b = this.unfinishedConnection) === null || _b === void 0 ? void 0 : _b.setEnd(undefined);
9999
- (_d = (_c = this.unfinishedConnection) === null || _c === void 0 ? void 0 : _c.select()) === null || _d === void 0 ? void 0 : _d.remove();
10000
- this.unfinishedConnection = undefined;
10001
- this.unfinishedConnectionPort = undefined;
10002
- }
10003
9897
  cancelAllUserActions() {
10004
- this.currentAction = undefined;
10005
- this.dropConnection();
10006
- this.removeInputField();
9898
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
9899
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_dropConnection).call(this);
9900
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_removeInputField).call(this);
10007
9901
  this.contextMenu.close();
10008
9902
  this.userSelection.clear();
10009
9903
  }
@@ -10013,7 +9907,8 @@ class DiagramCanvas {
10013
9907
  openTextInput(id) {
10014
9908
  const field = this.model.fields.get(id);
10015
9909
  if (field) {
10016
- this.createInputField(field.text, field.coords, field.width, field.height, field.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize, field.look.fontFamily || DIAGRAM_FIELD_DEFAULTS.look.fontFamily, field.orientation, field.multiline, () => {
9910
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, new EditFieldAction(this, field.id, field.text, ''), "f");
9911
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_createInputField).call(this, field.text, field.coords, field.width, field.height, field.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize, field.look.fontFamily || DIAGRAM_FIELD_DEFAULTS.look.fontFamily, field.orientation, field.multiline, () => {
10017
9912
  // (_text)
10018
9913
  /*
10019
9914
  Empty for now
@@ -10022,257 +9917,483 @@ class DiagramCanvas {
10022
9917
  */
10023
9918
  }, text => {
10024
9919
  field.text = text;
10025
- if (this.currentAction instanceof EditFieldAction) {
10026
- this.currentAction.to = text;
10027
- this.currentAction.do();
10028
- this.actionStack.add(this.currentAction);
10029
- this.currentAction = undefined;
9920
+ if (__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof EditFieldAction) {
9921
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").to = text;
9922
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").do();
9923
+ this.actionStack.add(__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f"));
9924
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
10030
9925
  }
10031
9926
  });
10032
9927
  }
10033
9928
  }
10034
- createInputField(text, coords, width, height, fontSize, fontFamily, orientation, multiline, changeCallback, finishCallback) {
10035
- // if we have a text input open, close it before creating a new one
10036
- this.removeInputField();
10037
- 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');
10038
- this.inputFieldContainer = inputFieldContainer;
10039
- const inputField = inputFieldContainer.append('xhtml:textarea');
10040
- let inputFieldWidth;
10041
- let inputFieldHeight;
10042
- inputField.text(text).style('box-sizing', 'border-box').style('width', `${width}px`).style('height', `${height}px`).style('font-size', `${fontSize}px`).style('font-family', fontFamily).style('resize', 'none').style('outline', 0).style('border', 0).style('margin', 0).style('padding', 0).on(Events.KeyDown, event => {
10043
- event.stopPropagation();
10044
- if (event.key === Keys.Escape || event.key === Keys.Enter && !multiline) {
10045
- const value = inputField.property('value') || '';
10046
- this.removeInputField();
10047
- if (finishCallback) {
10048
- finishCallback(value);
10049
- }
10050
- }
10051
- }).on(Events.KeyUp, event => {
10052
- event.stopPropagation();
10053
- }).on(Events.Input, () => {
10054
- const value = inputField.property('value');
10055
- inputField.attr('cols', numberOfColumns(value) + 1);
10056
- inputField.attr('rows', numberOfRows(value) + 1);
10057
- // reset width and height so that later the scrollWidth and scrollHeight are fit to the size of the text
10058
- inputField.style('width', '');
10059
- inputField.style('height', '');
10060
- // add one diagram unit of margin of error
10061
- inputFieldWidth = inputField.property('scrollWidth') + 1;
10062
- inputFieldHeight = inputField.property('scrollHeight') + 1;
10063
- // keep the field from shrinking below its original size
10064
- const newWidth = Math.max(inputFieldWidth, width);
10065
- const newHeight = Math.max(inputFieldHeight, height);
10066
- inputFieldContainer === null || inputFieldContainer === void 0 ? void 0 : inputFieldContainer.attr('width', `${newWidth}px`);
10067
- inputField.style('width', `${newWidth}px`);
10068
- inputFieldContainer === null || inputFieldContainer === void 0 ? void 0 : inputFieldContainer.attr('height', `${newHeight}px`);
10069
- inputField.style('height', `${newHeight}px`);
10070
- if (changeCallback) {
10071
- changeCallback(value);
9929
+ }
9930
+ _a = DiagramCanvas, _DiagramCanvas_diagramRoot = new WeakMap(), _DiagramCanvas_connectionType = new WeakMap(), _DiagramCanvas_gridPatternId = new WeakMap(), _DiagramCanvas_ancillaryGridPatternIds = new WeakMap(), _DiagramCanvas_zoomBehavior = new WeakMap(), _DiagramCanvas_zoomTransform = new WeakMap(), _DiagramCanvas_priorityThreshold = new WeakMap(), _DiagramCanvas_priorityThresholds = new WeakMap(), _DiagramCanvas_unfinishedConnection = new WeakMap(), _DiagramCanvas_unfinishedConnectionTracer = new WeakMap(), _DiagramCanvas_unfinishedConnectionPort = new WeakMap(), _DiagramCanvas_inputFieldContainer = new WeakMap(), _DiagramCanvas_multipleSelectionContainer = new WeakMap(), _DiagramCanvas_draggingFrom = new WeakMap(), _DiagramCanvas_dragging = new WeakMap(), _DiagramCanvas_secondaryButton = new WeakMap(), _DiagramCanvas_currentAction = new WeakMap(), _DiagramCanvas_instances = new WeakSet(), _DiagramCanvas_updateConnectionLabelsInView = function _DiagramCanvas_updateConnectionLabelsInView(connection) {
9931
+ var _b, _c, _d;
9932
+ const connectionSelection = this.selectCanvasView().select(`[id='${escapeSelector(connection.id)}']`);
9933
+ const pathSelection = connectionSelection.select('path');
9934
+ const pathNode = pathSelection.node();
9935
+ const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), connection.type.label);
9936
+ labelConfiguration.look = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS.look), labelConfiguration.look);
9937
+ if (pathNode) {
9938
+ const pathLength = pathNode.getTotalLength();
9939
+ let startLabelShiftX = 0;
9940
+ let startLabelShiftY = 0;
9941
+ let middleLabelShiftX = 0;
9942
+ let middleLabelShiftY = 0;
9943
+ let endLabelShiftX = 0;
9944
+ let endLabelShiftY = 0;
9945
+ if (labelConfiguration.look.fillColor === 'transparent') {
9946
+ // background color is transparent / not set, so we find an alternative position for the label
9947
+ const deltaX = connection.endCoords[0] - connection.startCoords[0];
9948
+ const deltaY = connection.endCoords[1] - connection.startCoords[1];
9949
+ switch (connection.startDirection) {
9950
+ case Side.Top:
9951
+ startLabelShiftX = deltaX >= 0 ? -0.5 : 0.5;
9952
+ endLabelShiftX = startLabelShiftX;
9953
+ break;
9954
+ case Side.Bottom:
9955
+ startLabelShiftX = deltaX >= 0 ? -0.5 : 0.5;
9956
+ endLabelShiftX = startLabelShiftX;
9957
+ break;
9958
+ case Side.Left:
9959
+ startLabelShiftY = deltaY > 0 ? -0.5 : 0.5;
9960
+ endLabelShiftY = startLabelShiftY;
9961
+ break;
9962
+ case Side.Right:
9963
+ startLabelShiftY = deltaY > 0 ? -0.5 : 0.5;
9964
+ endLabelShiftY = startLabelShiftY;
9965
+ break;
9966
+ default:
9967
+ startLabelShiftX = 0.5;
9968
+ endLabelShiftX = startLabelShiftX;
9969
+ startLabelShiftY = -0.5;
9970
+ endLabelShiftY = startLabelShiftY;
10072
9971
  }
10073
- }).on(Events.Click, event => {
10074
- event.stopPropagation();
10075
- }).on(Events.FocusOut, () => {
10076
- const value = inputField.property('value');
10077
- this.removeInputField();
10078
- if (finishCallback) {
10079
- finishCallback(value);
9972
+ switch (connection.endDirection) {
9973
+ case Side.Top:
9974
+ endLabelShiftX = deltaX >= 0 ? 0.5 : -0.5;
9975
+ break;
9976
+ case Side.Bottom:
9977
+ endLabelShiftX = deltaX >= 0 ? 0.5 : -0.5;
9978
+ break;
9979
+ case Side.Left:
9980
+ endLabelShiftY = deltaY > 0 ? 0.5 : -0.5;
9981
+ break;
9982
+ case Side.Right:
9983
+ endLabelShiftY = deltaY > 0 ? 0.5 : -0.5;
9984
+ break;
9985
+ default:
9986
+ endLabelShiftX = 0.5;
9987
+ endLabelShiftY = -0.5;
10080
9988
  }
10081
- });
10082
- const htmlInput = inputField.node();
10083
- htmlInput.focus();
10084
- htmlInput.select();
9989
+ if (Math.abs(deltaX) >= Math.abs(deltaY)) {
9990
+ // horizontal quadrant
9991
+ middleLabelShiftX = deltaX > 0 ? -0.5 : 0.5;
9992
+ middleLabelShiftY = deltaY > 0 ? 0.5 : -0.5;
9993
+ } else {
9994
+ // vertical quadrant
9995
+ middleLabelShiftX = deltaX > 0 ? 0.5 : -0.5;
9996
+ middleLabelShiftY = deltaY > 0 ? -0.5 : 0.5;
9997
+ }
9998
+ }
9999
+ // bind start labels
10000
+ connectionSelection.select('g.diagram-connection-start-label text').attr('x', 0).attr('y', (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.look.fontFamily || DIAGRAM_FIELD_DEFAULTS.look.fontFamily).attr('font-size', labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize).attr('fill', labelConfiguration.look.fontColor || DIAGRAM_FIELD_DEFAULTS.look.fontColor).text(connection.startLabel);
10001
+ const startLabelBoundingRect = (_b = connectionSelection.select('g.diagram-connection-start-label text').node()) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
10002
+ if (startLabelBoundingRect) {
10003
+ // don't create space for the label if the label is empty
10004
+ const boundingWidth = !connection.startLabel ? 0 : startLabelBoundingRect.width / __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
10005
+ const boundingHeight = !connection.startLabel ? 0 : startLabelBoundingRect.height / __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
10006
+ let pathStartLabelPoint;
10007
+ switch (connection.startDirection) {
10008
+ case Side.Left:
10009
+ pathStartLabelPoint = pathNode.getPointAtLength(getRightMargin(labelConfiguration) + boundingWidth / 2);
10010
+ break;
10011
+ case Side.Right:
10012
+ pathStartLabelPoint = pathNode.getPointAtLength(getLeftMargin(labelConfiguration) + boundingWidth / 2);
10013
+ break;
10014
+ case Side.Top:
10015
+ pathStartLabelPoint = pathNode.getPointAtLength(getBottomMargin(labelConfiguration) + boundingHeight / 2);
10016
+ break;
10017
+ case Side.Bottom:
10018
+ pathStartLabelPoint = pathNode.getPointAtLength(getTopMargin(labelConfiguration) + boundingHeight / 2);
10019
+ break;
10020
+ default:
10021
+ pathStartLabelPoint = pathNode.getPointAtLength(Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
10022
+ }
10023
+ connectionSelection.select('g.diagram-connection-start-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.look.fillColor || DIAGRAM_FIELD_DEFAULTS.look.fillColor).attr('stroke', 'none');
10024
+ connectionSelection.select('g.diagram-connection-start-label').attr('transform', `translate(${pathStartLabelPoint.x + startLabelShiftX * boundingWidth},${pathStartLabelPoint.y + startLabelShiftY * boundingHeight})`);
10025
+ }
10026
+ // bind middle labels
10027
+ connectionSelection.select('g.diagram-connection-middle-label text').attr('x', 0).attr('y', (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.look.fontFamily || DIAGRAM_FIELD_DEFAULTS.look.fontFamily).attr('font-size', labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize).attr('fill', labelConfiguration.look.fontColor || DIAGRAM_FIELD_DEFAULTS.look.fillColor).style('font-kerning', 'none').text(connection.middleLabel);
10028
+ const middleLabelBoundingRect = (_c = connectionSelection.select('g.diagram-connection-middle-label text').node()) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect();
10029
+ if (middleLabelBoundingRect) {
10030
+ // don't create space for the label if the label is empty
10031
+ const boundingWidth = !connection.middleLabel ? 0 : middleLabelBoundingRect.width / __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
10032
+ const boundingHeight = !connection.middleLabel ? 0 : middleLabelBoundingRect.height / __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
10033
+ const pathMiddleLabelPoint = pathNode.getPointAtLength(pathLength / 2);
10034
+ connectionSelection.select('g.diagram-connection-middle-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.look.fillColor || DIAGRAM_FIELD_DEFAULTS.look.fillColor).attr('stroke', 'none');
10035
+ connectionSelection.select('g.diagram-connection-middle-label').attr('transform', `translate(${pathMiddleLabelPoint.x + middleLabelShiftX * boundingWidth},${pathMiddleLabelPoint.y + middleLabelShiftY * boundingHeight})`);
10036
+ }
10037
+ // bind end labels
10038
+ connectionSelection.select('g.diagram-connection-end-label text').attr('x', 0).attr('y', (labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.look.fontFamily || DIAGRAM_FIELD_DEFAULTS.look.fontFamily).attr('font-size', labelConfiguration.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize).attr('fill', labelConfiguration.look.fontColor || DIAGRAM_FIELD_DEFAULTS.look.fontColor).style('font-kerning', 'none').text(connection.endLabel);
10039
+ const endLabelBoundingRect = (_d = connectionSelection.select('g.diagram-connection-end-label text').node()) === null || _d === void 0 ? void 0 : _d.getBoundingClientRect();
10040
+ if (endLabelBoundingRect) {
10041
+ // don't create space for the label if the label is empty
10042
+ const boundingWidth = !connection.endLabel ? 0 : endLabelBoundingRect.width / __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
10043
+ const boundingHeight = !connection.endLabel ? 0 : endLabelBoundingRect.height / __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
10044
+ let pathEndLabelPoint;
10045
+ switch (connection.endDirection) {
10046
+ case Side.Left:
10047
+ pathEndLabelPoint = pathNode.getPointAtLength(pathLength - (getRightMargin(labelConfiguration) + boundingWidth / 2));
10048
+ break;
10049
+ case Side.Right:
10050
+ pathEndLabelPoint = pathNode.getPointAtLength(pathLength - (getLeftMargin(labelConfiguration) + boundingWidth / 2));
10051
+ break;
10052
+ case Side.Top:
10053
+ pathEndLabelPoint = pathNode.getPointAtLength(pathLength - (getBottomMargin(labelConfiguration) + boundingHeight / 2));
10054
+ break;
10055
+ case Side.Bottom:
10056
+ pathEndLabelPoint = pathNode.getPointAtLength(pathLength - (getTopMargin(labelConfiguration) + boundingHeight / 2));
10057
+ break;
10058
+ default:
10059
+ pathEndLabelPoint = pathNode.getPointAtLength(pathLength - Math.max(getLeftMargin(labelConfiguration) + boundingWidth / 2, getRightMargin(labelConfiguration) + boundingWidth / 2, getTopMargin(labelConfiguration) + boundingHeight / 2, getBottomMargin(labelConfiguration) + boundingHeight / 2));
10060
+ }
10061
+ connectionSelection.select('g.diagram-connection-end-label path').attr('d', pillPath(-boundingWidth / 2, -boundingHeight / 2, boundingWidth, boundingHeight)).attr('fill', labelConfiguration.look.fillColor || DIAGRAM_FIELD_DEFAULTS.look.fillColor).attr('stroke', 'none');
10062
+ connectionSelection.select('g.diagram-connection-end-label').attr('transform', `translate(${pathEndLabelPoint.x + endLabelShiftX * boundingWidth},${pathEndLabelPoint.y + endLabelShiftY * boundingHeight})`);
10063
+ }
10085
10064
  }
10086
- removeInputField() {
10087
- var _a, _b, _c;
10088
- // when removing an element, a blur event is emitted
10089
- // we remove the listener for blur so that it doesn't shoot again on element removal
10090
- (_b = (_a = this.inputFieldContainer) === null || _a === void 0 ? void 0 : _a.select('input')) === null || _b === void 0 ? void 0 : _b.on(Events.Blur, null);
10091
- (_c = this.inputFieldContainer) === null || _c === void 0 ? void 0 : _c.remove();
10092
- this.inputFieldContainer = undefined;
10065
+ }, _DiagramCanvas_updateConnectionMarkersInView = function _DiagramCanvas_updateConnectionMarkersInView(connection) {
10066
+ const connectionSelection = this.selectCanvasView().select(`[id='${escapeSelector(connection.id)}']`);
10067
+ const startMarkerSelection = connectionSelection.select('marker.diagram-connection-start-marker');
10068
+ const endMarkerSelection = connectionSelection.select('marker.diagram-connection-end-marker');
10069
+ if (connection.startMarkerLook !== null) {
10070
+ startMarkerSelection.attr('orient', 'auto-start-reverse').attr('markerWidth', connection.startMarkerLook.width).attr('markerHeight', connection.startMarkerLook.height).attr('refX', connection.startMarkerLook.refX).attr('refY', connection.startMarkerLook.refY).select('image').attr('href', connection.startMarkerLook.image).attr('width', connection.startMarkerLook.width).attr('height', connection.startMarkerLook.height);
10071
+ } else {
10072
+ startMarkerSelection.attr('orient', 'auto-start-reverse').attr('markerWidth', 0).attr('markerHeight', 0);
10093
10073
  }
10094
- minimumSizeOfField(field) {
10095
- var _a, _b;
10096
- const textNode = (_b = (_a = field.select()) === null || _a === void 0 ? void 0 : _a.select('text')) === null || _b === void 0 ? void 0 : _b.node();
10097
- if (!textNode) {
10098
- // happens when a field has been created but not updated in view yet
10099
- return [0, 0];
10074
+ if (connection.endMarkerLook !== null) {
10075
+ endMarkerSelection.attr('orient', 'auto-start-reverse').attr('markerWidth', connection.endMarkerLook.width).attr('markerHeight', connection.endMarkerLook.height).attr('refX', connection.endMarkerLook.refX).attr('refY', connection.endMarkerLook.refY).select('image').attr('href', connection.endMarkerLook.image).attr('width', connection.endMarkerLook.width).attr('height', connection.endMarkerLook.height);
10076
+ } else {
10077
+ endMarkerSelection.attr('orient', 'auto-start-reverse').attr('markerWidth', 0).attr('markerHeight', 0);
10078
+ }
10079
+ }, _DiagramCanvas_startConnection = function _DiagramCanvas_startConnection(port) {
10080
+ var _b, _c, _d, _e;
10081
+ if (port.allowsOutgoing || port.allowsIncoming) {
10082
+ if (this.connectionType && (this.connectionType.canStartFromType(((_c = (_b = port.getNode()) === null || _b === void 0 ? void 0 : _b.type) === null || _c === void 0 ? void 0 : _c.id) || '') && port.allowsOutgoing || this.connectionType.canFinishOnType(((_e = (_d = port.getNode()) === null || _d === void 0 ? void 0 : _d.type) === null || _e === void 0 ? void 0 : _e.id) || '') && port.allowsIncoming)) {
10083
+ __classPrivateFieldSet(this, _DiagramCanvas_unfinishedConnection, new DiagramConnection(this.model, this.connectionType, port, undefined, UNFINISHED_CONNECTION_ID), "f");
10084
+ __classPrivateFieldSet(this, _DiagramCanvas_unfinishedConnectionPort, port, "f");
10085
+ } else {
10086
+ if (this.inferConnectionType) {
10087
+ let differentConnectionType = this.model.connections.types.all().find(t => {
10088
+ var _b, _c;
10089
+ return port.allowsOutgoing && t.canStartFromType(((_c = (_b = port.getNode()) === null || _b === void 0 ? void 0 : _b.type) === null || _c === void 0 ? void 0 : _c.id) || '');
10090
+ });
10091
+ if (differentConnectionType === undefined) {
10092
+ differentConnectionType = this.model.connections.types.all().find(t => {
10093
+ var _b, _c;
10094
+ return port.allowsIncoming && t.canFinishOnType(((_c = (_b = port.getNode()) === null || _b === void 0 ? void 0 : _b.type) === null || _c === void 0 ? void 0 : _c.id) || '');
10095
+ });
10096
+ }
10097
+ if (differentConnectionType !== undefined) {
10098
+ __classPrivateFieldSet(this, _DiagramCanvas_unfinishedConnection, new DiagramConnection(this.model, differentConnectionType, port, undefined, UNFINISHED_CONNECTION_ID), "f");
10099
+ __classPrivateFieldSet(this, _DiagramCanvas_unfinishedConnectionPort, port, "f");
10100
+ }
10101
+ }
10100
10102
  }
10101
- const textBoundingBox = textNode.getBoundingClientRect();
10102
- return [textBoundingBox.width / this.zoomTransform.k, textBoundingBox.height / this.zoomTransform.k];
10103
10103
  }
10104
- setFieldTextAndWrap(field) {
10105
- var _a, _b, _c, _d;
10106
- const textSelection = (_a = field.select()) === null || _a === void 0 ? void 0 : _a.select('text');
10107
- const textNode = textSelection === null || textSelection === void 0 ? void 0 : textSelection.node();
10108
- if (textSelection && textNode) {
10109
- this.setFieldText(field, textSelection, field.text);
10110
- } else {
10111
- // can happen if a field has been created but not updated in view yet
10112
- // not sure if this still happens but should check just in case
10104
+ }, _DiagramCanvas_finishConnection = function _DiagramCanvas_finishConnection(port) {
10105
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
10106
+ this.userHighlight.clear();
10107
+ if (__classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f") !== undefined) {
10108
+ if (!this.allowConnectionLoops && __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").start === port) {
10109
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_dropConnection).call(this);
10110
+ return;
10111
+ }
10112
+ if (!this.allowSharingPorts && (port.incomingConnections.filter(c => !c.removed).length > 0 || port.outgoingConnections.filter(c => !c.removed).length > 0)) {
10113
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_dropConnection).call(this);
10113
10114
  return;
10114
10115
  }
10115
- if (field.fit) {
10116
- // no need to wrap
10116
+ if (!this.allowSharingBothPorts && this.model.connections.find(c => {
10117
+ var _b, _c;
10118
+ return !c.removed && (c.start === ((_b = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f")) === null || _b === void 0 ? void 0 : _b.start) && c.end === port || c.end === ((_c = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f")) === null || _c === void 0 ? void 0 : _c.start) && c.start === port);
10119
+ }) !== undefined) {
10120
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_dropConnection).call(this);
10117
10121
  return;
10118
10122
  }
10119
- let minimumSize = this.minimumSizeOfField(field);
10120
- while (minimumSize[0] > field.width || minimumSize[1] > field.height) {
10121
- const textString = ((_d = (_c = (_b = textSelection === null || textSelection === void 0 ? void 0 : textSelection.html()) === null || _b === void 0 ? void 0 : _b.replace(/<\/tspan>/g, '\n')) === null || _c === void 0 ? void 0 : _c.replace(/<tspan[^>]*>/g, '')) === null || _d === void 0 ? void 0 : _d.slice(0, -1)) || '';
10122
- let newTextString = '...';
10123
- if (textString.endsWith('...')) {
10124
- newTextString = textString.slice(0, -4) + '...';
10123
+ if (__classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").type.canStartFromType(((_e = (_d = (_c = (_b = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f")) === null || _b === void 0 ? void 0 : _b.start) === null || _c === void 0 ? void 0 : _c.getNode()) === null || _d === void 0 ? void 0 : _d.type) === null || _e === void 0 ? void 0 : _e.id) || '') && ((_g = (_f = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f")) === null || _f === void 0 ? void 0 : _f.start) === null || _g === void 0 ? void 0 : _g.allowsOutgoing) && __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").type.canFinishOnType(((_j = (_h = port.getNode()) === null || _h === void 0 ? void 0 : _h.type) === null || _j === void 0 ? void 0 : _j.id) || '') && port.allowsIncoming) {
10124
+ const addConnectionAction = new AddConnectionAction(this, __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").type, (_k = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").start) === null || _k === void 0 ? void 0 : _k.id, port.id);
10125
+ // clean up the previous unfinished connection
10126
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_dropConnection).call(this);
10127
+ addConnectionAction.do();
10128
+ this.actionStack.add(addConnectionAction);
10129
+ } else if (__classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").type.canFinishOnType(((_p = (_o = (_m = (_l = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f")) === null || _l === void 0 ? void 0 : _l.start) === null || _m === void 0 ? void 0 : _m.getNode()) === null || _o === void 0 ? void 0 : _o.type) === null || _p === void 0 ? void 0 : _p.id) || '') && ((_r = (_q = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f")) === null || _q === void 0 ? void 0 : _q.start) === null || _r === void 0 ? void 0 : _r.allowsIncoming) && __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").type.canStartFromType(((_t = (_s = port.getNode()) === null || _s === void 0 ? void 0 : _s.type) === null || _t === void 0 ? void 0 : _t.id) || '') && port.allowsOutgoing) {
10130
+ const addConnectionAction = new AddConnectionAction(this, __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").type, port.id, (_u = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").start) === null || _u === void 0 ? void 0 : _u.id);
10131
+ // clean up the previous unfinished connection
10132
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_dropConnection).call(this);
10133
+ addConnectionAction.do();
10134
+ this.actionStack.add(addConnectionAction);
10135
+ } else {
10136
+ if (this.inferConnectionType) {
10137
+ let differentConnectionType = this.model.connections.types.all().find(t => {
10138
+ var _b, _c, _d, _e, _f, _g, _h, _j;
10139
+ return t.canStartFromType(((_e = (_d = (_c = (_b = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f")) === null || _b === void 0 ? void 0 : _b.start) === null || _c === void 0 ? void 0 : _c.getNode()) === null || _d === void 0 ? void 0 : _d.type) === null || _e === void 0 ? void 0 : _e.id) || '') && ((_g = (_f = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f")) === null || _f === void 0 ? void 0 : _f.start) === null || _g === void 0 ? void 0 : _g.allowsOutgoing) && t.canFinishOnType(((_j = (_h = port.getNode()) === null || _h === void 0 ? void 0 : _h.type) === null || _j === void 0 ? void 0 : _j.id) || '') && port.allowsIncoming;
10140
+ });
10141
+ let invertConnection = false;
10142
+ if (differentConnectionType === undefined) {
10143
+ differentConnectionType = this.model.connections.types.all().find(t => {
10144
+ var _b, _c, _d, _e, _f, _g, _h, _j;
10145
+ return t.canFinishOnType(((_e = (_d = (_c = (_b = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f")) === null || _b === void 0 ? void 0 : _b.start) === null || _c === void 0 ? void 0 : _c.getNode()) === null || _d === void 0 ? void 0 : _d.type) === null || _e === void 0 ? void 0 : _e.id) || '') && ((_g = (_f = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f")) === null || _f === void 0 ? void 0 : _f.start) === null || _g === void 0 ? void 0 : _g.allowsIncoming) && t.canStartFromType(((_j = (_h = port.getNode()) === null || _h === void 0 ? void 0 : _h.type) === null || _j === void 0 ? void 0 : _j.id) || '') && port.allowsOutgoing;
10146
+ });
10147
+ invertConnection = true;
10148
+ }
10149
+ if (differentConnectionType !== undefined) {
10150
+ const addConnectionAction = new AddConnectionAction(this, differentConnectionType, invertConnection ? port.id : (_v = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").start) === null || _v === void 0 ? void 0 : _v.id, invertConnection ? (_w = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f").start) === null || _w === void 0 ? void 0 : _w.id : port.id);
10151
+ // clean up the previous unfinished connection
10152
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_dropConnection).call(this);
10153
+ addConnectionAction.do();
10154
+ this.actionStack.add(addConnectionAction);
10155
+ } else {
10156
+ // error: connection target of wrong type and no allowed type can be found
10157
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_dropConnection).call(this);
10158
+ }
10125
10159
  } else {
10126
- newTextString = textString.slice(0, -1) + '...';
10127
- }
10128
- if (textSelection) {
10129
- this.setFieldText(field, textSelection, newTextString);
10130
- }
10131
- if (newTextString === '...') {
10132
- // if no more characters can be removed and the new text is a bare ellipsis, stop the execution
10133
- return;
10160
+ // error: connection target of wrong type and can't guess for a different type
10161
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_dropConnection).call(this);
10162
+ }
10163
+ }
10164
+ }
10165
+ }, _DiagramCanvas_dropConnection = function _DiagramCanvas_dropConnection() {
10166
+ var _b, _c, _d, _e;
10167
+ (_b = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f")) === null || _b === void 0 ? void 0 : _b.setStart(undefined);
10168
+ (_c = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f")) === null || _c === void 0 ? void 0 : _c.setEnd(undefined);
10169
+ (_e = (_d = __classPrivateFieldGet(this, _DiagramCanvas_unfinishedConnection, "f")) === null || _d === void 0 ? void 0 : _d.select()) === null || _e === void 0 ? void 0 : _e.remove();
10170
+ __classPrivateFieldSet(this, _DiagramCanvas_unfinishedConnection, undefined, "f");
10171
+ __classPrivateFieldSet(this, _DiagramCanvas_unfinishedConnectionPort, undefined, "f");
10172
+ }, _DiagramCanvas_createInputField = function _DiagramCanvas_createInputField(text, coords, width, height, fontSize, fontFamily, orientation, multiline, changeCallback, finishCallback) {
10173
+ // if we have a text input open, close it before creating a new one
10174
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_removeInputField).call(this);
10175
+ 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');
10176
+ __classPrivateFieldSet(this, _DiagramCanvas_inputFieldContainer, inputFieldContainer, "f");
10177
+ const inputField = inputFieldContainer.append('xhtml:textarea');
10178
+ let inputFieldWidth;
10179
+ let inputFieldHeight;
10180
+ inputField.text(text).style('box-sizing', 'border-box').style('width', `${width}px`).style('height', `${height}px`).style('font-size', `${fontSize}px`).style('font-family', fontFamily).style('resize', 'none').style('outline', 0).style('border', 0).style('margin', 0).style('padding', 0).on(Events.KeyDown, event => {
10181
+ event.stopPropagation();
10182
+ if (event.key === Keys.Escape || event.key === Keys.Enter && !multiline) {
10183
+ const value = inputField.property('value') || '';
10184
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_removeInputField).call(this);
10185
+ if (finishCallback) {
10186
+ finishCallback(value);
10134
10187
  }
10135
- minimumSize = this.minimumSizeOfField(field);
10136
10188
  }
10137
- }
10138
- setFieldText(field, textSelection, text) {
10139
- const lines = text.split('\n');
10140
- textSelection.html('');
10141
- for (let i = 0; i < lines.length; ++i) {
10142
- textSelection.append('tspan').attr('x', field.horizontalAlign === HorizontalAlign.Center ? field.width / 2 : field.horizontalAlign === HorizontalAlign.Right ? field.width : 0).attr('y', field.verticalAlign === VerticalAlign.Center ? (i + 0.5 - lines.length / 2) * (field.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) + field.height / 2 : field.verticalAlign === VerticalAlign.Bottom ? field.height - (lines.length - i - 1) * (field.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) : i * (field.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)).text(lines[i]);
10189
+ }).on(Events.KeyUp, event => {
10190
+ event.stopPropagation();
10191
+ }).on(Events.Input, () => {
10192
+ const value = inputField.property('value');
10193
+ inputField.attr('cols', numberOfColumns(value) + 1);
10194
+ inputField.attr('rows', numberOfRows(value) + 1);
10195
+ // reset width and height so that later the scrollWidth and scrollHeight are fit to the size of the text
10196
+ inputField.style('width', '');
10197
+ inputField.style('height', '');
10198
+ // add one diagram unit of margin of error
10199
+ inputFieldWidth = inputField.property('scrollWidth') + 1;
10200
+ inputFieldHeight = inputField.property('scrollHeight') + 1;
10201
+ // keep the field from shrinking below its original size
10202
+ const newWidth = Math.max(inputFieldWidth, width);
10203
+ const newHeight = Math.max(inputFieldHeight, height);
10204
+ inputFieldContainer === null || inputFieldContainer === void 0 ? void 0 : inputFieldContainer.attr('width', `${newWidth}px`);
10205
+ inputField.style('width', `${newWidth}px`);
10206
+ inputFieldContainer === null || inputFieldContainer === void 0 ? void 0 : inputFieldContainer.attr('height', `${newHeight}px`);
10207
+ inputField.style('height', `${newHeight}px`);
10208
+ if (changeCallback) {
10209
+ changeCallback(value);
10210
+ }
10211
+ }).on(Events.Click, event => {
10212
+ event.stopPropagation();
10213
+ }).on(Events.FocusOut, () => {
10214
+ const value = inputField.property('value');
10215
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_removeInputField).call(this);
10216
+ if (finishCallback) {
10217
+ finishCallback(value);
10143
10218
  }
10144
- }
10145
- /**
10146
- * Method to call to start the moving of a node triggered by a user drag event.
10147
- */
10148
- startMovingNode(event, d) {
10149
- if (this.canUserPerformAction(DiagramActions.MoveNode) && !d.removed) {
10150
- setCursorStyle(CursorStyle.Grabbing);
10151
- this.draggingFrom = [event.x, event.y];
10152
- if (d.selected && this.userSelection.count(e => e instanceof DiagramNode) > 1) {
10153
- this.currentAction = new MoveAction(this, this.userSelection.filter(e => e instanceof DiagramNode).map(n => n.id), d.coords);
10154
- } else {
10155
- const ancestorOfNode = d.getLastAncestor();
10156
- this.currentAction = new SetGeometryAction(this, DiagramActions.MoveNode, d.id, d.getGeometry(), d.getGeometry(), ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.id, ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id), ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id));
10157
- }
10219
+ });
10220
+ const htmlInput = inputField.node();
10221
+ htmlInput.focus();
10222
+ htmlInput.select();
10223
+ }, _DiagramCanvas_removeInputField = function _DiagramCanvas_removeInputField() {
10224
+ var _b, _c, _d;
10225
+ // when removing an element, a blur event is emitted
10226
+ // we remove the listener for blur so that it does not emit again on element removal
10227
+ (_c = (_b = __classPrivateFieldGet(this, _DiagramCanvas_inputFieldContainer, "f")) === null || _b === void 0 ? void 0 : _b.select('input')) === null || _c === void 0 ? void 0 : _c.on(Events.Blur, null);
10228
+ (_d = __classPrivateFieldGet(this, _DiagramCanvas_inputFieldContainer, "f")) === null || _d === void 0 ? void 0 : _d.remove();
10229
+ __classPrivateFieldSet(this, _DiagramCanvas_inputFieldContainer, undefined, "f");
10230
+ }, _DiagramCanvas_minimumSizeOfField = function _DiagramCanvas_minimumSizeOfField(field) {
10231
+ var _b, _c;
10232
+ const textNode = (_c = (_b = field.select()) === null || _b === void 0 ? void 0 : _b.select('text')) === null || _c === void 0 ? void 0 : _c.node();
10233
+ if (!textNode) {
10234
+ // happens when a field has been created but not updated in view yet
10235
+ return [0, 0];
10236
+ }
10237
+ const textBoundingBox = textNode.getBoundingClientRect();
10238
+ return [textBoundingBox.width / __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k, textBoundingBox.height / __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k];
10239
+ }, _DiagramCanvas_setFieldTextAndWrap = function _DiagramCanvas_setFieldTextAndWrap(field) {
10240
+ var _b, _c, _d, _e;
10241
+ const textSelection = (_b = field.select()) === null || _b === void 0 ? void 0 : _b.select('text');
10242
+ const textNode = textSelection === null || textSelection === void 0 ? void 0 : textSelection.node();
10243
+ if (textSelection && textNode) {
10244
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_setFieldText).call(this, field, textSelection, field.text);
10245
+ } else {
10246
+ // can happen if a field has been created but not updated in view yet
10247
+ // not sure if this still happens but should check just in case
10248
+ return;
10249
+ }
10250
+ if (field.fit) {
10251
+ // no need to wrap
10252
+ return;
10253
+ }
10254
+ let minimumSize = __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_minimumSizeOfField).call(this, field);
10255
+ while (minimumSize[0] > field.width || minimumSize[1] > field.height) {
10256
+ const textString = ((_e = (_d = (_c = textSelection === null || textSelection === void 0 ? void 0 : textSelection.html()) === null || _c === void 0 ? void 0 : _c.replace(/<\/tspan>/g, '\n')) === null || _d === void 0 ? void 0 : _d.replace(/<tspan[^>]*>/g, '')) === null || _e === void 0 ? void 0 : _e.slice(0, -1)) || '';
10257
+ let newTextString = '...';
10258
+ if (textString.endsWith('...')) {
10259
+ newTextString = textString.slice(0, -4) + '...';
10158
10260
  } else {
10159
- setCursorStyle(CursorStyle.NotAllowed);
10261
+ newTextString = textString.slice(0, -1) + '...';
10160
10262
  }
10161
- }
10162
- /**
10163
- * Method to call to continue the moving of a node triggered by a user drag event.
10164
- */
10165
- continueMovingNode(event, d) {
10166
- if (this.canUserPerformAction(DiagramActions.MoveNode) && (this.currentAction instanceof MoveAction || this.currentAction instanceof SetGeometryAction) && !d.removed) {
10167
- const newNodeCoords = [event.x - d.width / 2, event.y - d.height / 2];
10168
- if (d.selected) {
10169
- this.userSelection.move([newNodeCoords[0] - d.coords[0], newNodeCoords[1] - d.coords[1]]);
10170
- } else {
10171
- d.move(newNodeCoords);
10172
- }
10173
- this.userHighlight.clear();
10174
- this.dragging = true;
10175
- this.diagramEvent$.next(new DiagramDraggingNodeEvent(d));
10263
+ if (textSelection) {
10264
+ __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_setFieldText).call(this, field, textSelection, newTextString);
10176
10265
  }
10177
- }
10178
- /**
10179
- * Method to call to finish the moving of a node triggered by a user drag event.
10180
- */
10181
- finishMovingNode(event, d) {
10182
- var _a, _b, _c, _d;
10183
- if (this.canUserPerformAction(DiagramActions.MoveNode) && !d.removed) {
10184
- // prevent drag behavior if mouse hasn't moved
10185
- if (this.draggingFrom[0] !== event.x || this.draggingFrom[1] !== event.y) {
10186
- let newNodeCoords = [event.x - d.width / 2, event.y - d.height / 2];
10187
- if ((_a = this.gridConfig) === null || _a === void 0 ? void 0 : _a.snap) {
10188
- newNodeCoords = this.getClosestGridPoint([newNodeCoords[0] - d.type.snapToGridOffset[0], newNodeCoords[1] - d.type.snapToGridOffset[1]]);
10189
- newNodeCoords[0] += d.type.snapToGridOffset[0];
10190
- newNodeCoords[1] += d.type.snapToGridOffset[1];
10191
- }
10192
- if (this.currentAction instanceof MoveAction) {
10193
- const movingFrom = this.currentAction.delta;
10194
- this.currentAction.delta = [newNodeCoords[0] - movingFrom[0], newNodeCoords[1] - movingFrom[1]];
10195
- // reset position of node prior to moving it again
10196
- if (d.selected) {
10197
- this.userSelection.move([movingFrom[0] - d.coords[0], movingFrom[1] - d.coords[1]]);
10198
- } else {
10199
- d.move(movingFrom);
10200
- }
10201
- } else if (this.currentAction instanceof SetGeometryAction) {
10202
- d.move(newNodeCoords);
10203
- // if moving a single node, we can change the node's parent,
10204
- // so we check whether we dropped this node on a potential parent
10205
- const nodesAtLocation = this.model.nodes.getAtCoordinates(event.x, event.y).filter(n => n.id !== d.id && !n.isDescendantOf(d));
10206
- // filter by which nodes can have this node as a child
10207
- const nodesAtLocationWhichCanHaveNodeAsAChild = nodesAtLocation.filter(n => n.type.childrenTypes.includes(d.type.id));
10208
- // filter by which nodes don't have descendants in this collection
10209
- const filteredNodesAtLocation = filterByOnlyDescendants(nodesAtLocationWhichCanHaveNodeAsAChild);
10210
- const droppedOn = filteredNodesAtLocation[filteredNodesAtLocation.length - 1];
10211
- if (droppedOn !== d.parent && (d.type.canBeParentless || droppedOn !== undefined)) {
10212
- const ancestorOfDroppedOn = droppedOn === null || droppedOn === void 0 ? void 0 : droppedOn.getLastAncestor();
10213
- const fromChildGeometry = this.currentAction.from;
10214
- const setParentAction = new SetParentAction(this, d.id, (_b = d.parent) === null || _b === void 0 ? void 0 : _b.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));
10215
- (_c = d.parent) === null || _c === void 0 ? void 0 : _c.removeChild(d);
10216
- if (droppedOn !== undefined) {
10217
- droppedOn.addChild(d);
10218
- }
10219
- setParentAction.toChildGeometry = d.getGeometry(d.id);
10220
- setParentAction.toAncestorGeometry = ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id);
10221
- this.currentAction = setParentAction;
10222
- } else {
10223
- const ancestorOfNode = d === null || d === void 0 ? void 0 : d.getLastAncestor();
10224
- this.currentAction.ancestorId = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.id;
10225
- this.currentAction.fromAncestorGeometry = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id);
10226
- (_d = d.parent) === null || _d === void 0 ? void 0 : _d.fitToChild(d);
10227
- this.currentAction.to = d.getGeometry(d.id);
10228
- this.currentAction.toAncestorGeometry = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id);
10229
- }
10230
- }
10231
- if (this.currentAction !== undefined) {
10232
- this.currentAction.do();
10233
- this.actionStack.add(this.currentAction);
10234
- this.currentAction = undefined;
10235
- }
10236
- }
10266
+ if (newTextString === '...') {
10267
+ // if no more characters can be removed and the new text is a bare ellipsis, stop the execution
10268
+ return;
10237
10269
  }
10238
- setCursorStyle();
10239
- this.dragging = false;
10270
+ minimumSize = __classPrivateFieldGet(this, _DiagramCanvas_instances, "m", _DiagramCanvas_minimumSizeOfField).call(this, field);
10240
10271
  }
10241
- startMultipleSelection(event) {
10242
- this.draggingFrom = this.getPointerLocationRelativeToCanvas(event);
10243
- // we put the multiple selection rectangle in the diagram svg element
10244
- // so it's not affected by the zoom level in the diagram elements
10245
- this.multipleSelectionContainer = this.selectSVGElement().append('rect').attr('stroke', '#0E74B6').attr('fill', 'rgba(14, 116, 182, 0.06)');
10272
+ }, _DiagramCanvas_setFieldText = function _DiagramCanvas_setFieldText(field, textSelection, text) {
10273
+ const lines = text.split('\n');
10274
+ textSelection.html('');
10275
+ for (let i = 0; i < lines.length; ++i) {
10276
+ textSelection.append('tspan').attr('x', field.horizontalAlign === HorizontalAlign.Center ? field.width / 2 : field.horizontalAlign === HorizontalAlign.Right ? field.width : 0).attr('y', field.verticalAlign === VerticalAlign.Center ? (i + 0.5 - lines.length / 2) * (field.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) + field.height / 2 : field.verticalAlign === VerticalAlign.Bottom ? field.height - (lines.length - i - 1) * (field.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize) : i * (field.look.fontSize || DIAGRAM_FIELD_DEFAULTS.look.fontSize)).text(lines[i]);
10246
10277
  }
10247
- continueMultipleSelection(event) {
10248
- var _a, _b, _c, _d;
10249
- const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
10250
- if (this.draggingFrom[0] !== pointerCoords[0] || this.draggingFrom[1] !== pointerCoords[1]) {
10251
- setCursorStyle(CursorStyle.Crosshair);
10252
- // since the multiple selection rectangle is not affected by zoom,
10253
- // we compensate its coordinates based in the zoom transform to draw it
10254
- (_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);
10255
- this.dragging = true;
10278
+ }, _DiagramCanvas_startMovingNode = function _DiagramCanvas_startMovingNode(event, d) {
10279
+ if (this.canUserPerformAction(DiagramActions.MoveNode) && !d.removed) {
10280
+ setCursorStyle(CursorStyle.Grabbing);
10281
+ __classPrivateFieldSet(this, _DiagramCanvas_draggingFrom, [event.x, event.y], "f");
10282
+ if (d.selected && this.userSelection.count(e => e instanceof DiagramNode) > 1) {
10283
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, new MoveAction(this, this.userSelection.filter(e => e instanceof DiagramNode).map(n => n.id), d.coords), "f");
10284
+ } else {
10285
+ const ancestorOfNode = d.getLastAncestor();
10286
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, new SetGeometryAction(this, DiagramActions.MoveNode, d.id, d.getGeometry(), d.getGeometry(), ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.id, ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id), ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id)), "f");
10256
10287
  }
10288
+ } else {
10289
+ setCursorStyle(CursorStyle.NotAllowed);
10257
10290
  }
10258
- finishMultipleSelection(event) {
10259
- var _a;
10260
- const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
10261
- (_a = this.multipleSelectionContainer) === null || _a === void 0 ? void 0 : _a.remove();
10262
- this.multipleSelectionContainer = undefined;
10263
- this.userSelection.clear();
10264
- for (const node of this.model.nodes) {
10265
- if (rectanglesIntersect([node.coords, [node.coords[0] + node.width, node.coords[1] + node.height]], [this.draggingFrom, pointerCoords])) {
10266
- this.userSelection.add(node);
10267
- }
10291
+ }, _DiagramCanvas_continueMovingNode = function _DiagramCanvas_continueMovingNode(event, d) {
10292
+ if (this.canUserPerformAction(DiagramActions.MoveNode) && (__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof MoveAction || __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof SetGeometryAction) && !d.removed) {
10293
+ const newNodeCoords = [event.x - d.width / 2, event.y - d.height / 2];
10294
+ if (d.selected) {
10295
+ this.userSelection.move([newNodeCoords[0] - d.coords[0], newNodeCoords[1] - d.coords[1]]);
10296
+ } else {
10297
+ d.move(newNodeCoords);
10268
10298
  }
10269
- this.multipleSelectionOn = false;
10270
- this.diagramEvent$.next(new DiagramSelectionEvent(this.userSelection.all(), true));
10271
- setCursorStyle();
10272
- }
10273
- }
10274
- DiagramCanvas.canvasCount = 0;
10299
+ this.userHighlight.clear();
10300
+ __classPrivateFieldSet(this, _DiagramCanvas_dragging, true, "f");
10301
+ this.diagramEvent$.next(new DiagramDraggingNodeEvent(d));
10302
+ }
10303
+ }, _DiagramCanvas_finishMovingNode = function _DiagramCanvas_finishMovingNode(event, d) {
10304
+ var _b, _c, _d, _e;
10305
+ if (this.canUserPerformAction(DiagramActions.MoveNode) && !d.removed) {
10306
+ // prevent drag behavior if mouse hasn't moved
10307
+ if (__classPrivateFieldGet(this, _DiagramCanvas_draggingFrom, "f")[0] !== event.x || __classPrivateFieldGet(this, _DiagramCanvas_draggingFrom, "f")[1] !== event.y) {
10308
+ let newNodeCoords = [event.x - d.width / 2, event.y - d.height / 2];
10309
+ if ((_b = this.gridConfig) === null || _b === void 0 ? void 0 : _b.snap) {
10310
+ newNodeCoords = this.getClosestGridPoint([newNodeCoords[0] - d.type.snapToGridOffset[0], newNodeCoords[1] - d.type.snapToGridOffset[1]]);
10311
+ newNodeCoords[0] += d.type.snapToGridOffset[0];
10312
+ newNodeCoords[1] += d.type.snapToGridOffset[1];
10313
+ }
10314
+ if (__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof MoveAction) {
10315
+ const movingFrom = __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").delta;
10316
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").delta = [newNodeCoords[0] - movingFrom[0], newNodeCoords[1] - movingFrom[1]];
10317
+ // reset position of node prior to moving it again
10318
+ if (d.selected) {
10319
+ this.userSelection.move([movingFrom[0] - d.coords[0], movingFrom[1] - d.coords[1]]);
10320
+ } else {
10321
+ d.move(movingFrom);
10322
+ }
10323
+ } else if (__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") instanceof SetGeometryAction) {
10324
+ d.move(newNodeCoords);
10325
+ // if moving a single node, we can change the node's parent,
10326
+ // so we check whether we dropped this node on a potential parent
10327
+ const nodesAtLocation = this.model.nodes.getAtCoordinates(event.x, event.y).filter(n => n.id !== d.id && !n.isDescendantOf(d));
10328
+ // filter by which nodes can have this node as a child
10329
+ const nodesAtLocationWhichCanHaveNodeAsAChild = nodesAtLocation.filter(n => n.type.childrenTypes.includes(d.type.id));
10330
+ // filter by which nodes don't have descendants in this collection
10331
+ const filteredNodesAtLocation = filterByOnlyDescendants(nodesAtLocationWhichCanHaveNodeAsAChild);
10332
+ const droppedOn = filteredNodesAtLocation[filteredNodesAtLocation.length - 1];
10333
+ if (droppedOn !== d.parent && (d.type.canBeParentless || droppedOn !== undefined)) {
10334
+ const ancestorOfDroppedOn = droppedOn === null || droppedOn === void 0 ? void 0 : droppedOn.getLastAncestor();
10335
+ const fromChildGeometry = __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").from;
10336
+ const setParentAction = new SetParentAction(this, d.id, (_c = d.parent) === null || _c === void 0 ? void 0 : _c.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));
10337
+ (_d = d.parent) === null || _d === void 0 ? void 0 : _d.removeChild(d);
10338
+ if (droppedOn !== undefined) {
10339
+ droppedOn.addChild(d);
10340
+ }
10341
+ setParentAction.toChildGeometry = d.getGeometry(d.id);
10342
+ setParentAction.toAncestorGeometry = ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id);
10343
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, setParentAction, "f");
10344
+ } else {
10345
+ const ancestorOfNode = d === null || d === void 0 ? void 0 : d.getLastAncestor();
10346
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").ancestorId = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.id;
10347
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").fromAncestorGeometry = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id);
10348
+ (_e = d.parent) === null || _e === void 0 ? void 0 : _e.fitToChild(d);
10349
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").to = d.getGeometry(d.id);
10350
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").toAncestorGeometry = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id);
10351
+ }
10352
+ }
10353
+ if (__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f") !== undefined) {
10354
+ __classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f").do();
10355
+ this.actionStack.add(__classPrivateFieldGet(this, _DiagramCanvas_currentAction, "f"));
10356
+ __classPrivateFieldSet(this, _DiagramCanvas_currentAction, undefined, "f");
10357
+ }
10358
+ }
10359
+ }
10360
+ setCursorStyle();
10361
+ __classPrivateFieldSet(this, _DiagramCanvas_dragging, false, "f");
10362
+ }, _DiagramCanvas_startMultipleSelection = function _DiagramCanvas_startMultipleSelection(event) {
10363
+ __classPrivateFieldSet(this, _DiagramCanvas_draggingFrom, this.getPointerLocationRelativeToCanvas(event), "f");
10364
+ // we put the multiple selection rectangle in the diagram svg element
10365
+ // so it's not affected by the zoom level in the diagram elements
10366
+ __classPrivateFieldSet(this, _DiagramCanvas_multipleSelectionContainer, this.selectSVGElement().append('rect').attr('stroke', '#0E74B6').attr('fill', 'rgba(14, 116, 182, 0.06)'), "f");
10367
+ }, _DiagramCanvas_continueMultipleSelection = function _DiagramCanvas_continueMultipleSelection(event) {
10368
+ var _b, _c, _d, _e;
10369
+ const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
10370
+ if (__classPrivateFieldGet(this, _DiagramCanvas_draggingFrom, "f")[0] !== pointerCoords[0] || __classPrivateFieldGet(this, _DiagramCanvas_draggingFrom, "f")[1] !== pointerCoords[1]) {
10371
+ setCursorStyle(CursorStyle.Crosshair);
10372
+ // since the multiple selection rectangle is not affected by zoom,
10373
+ // we compensate its coordinates based in the zoom transform to draw it
10374
+ (_e = (_d = (_c = (_b = __classPrivateFieldGet(this, _DiagramCanvas_multipleSelectionContainer, "f")) === null || _b === void 0 ? void 0 : _b.attr('x', Math.min(__classPrivateFieldGet(this, _DiagramCanvas_draggingFrom, "f")[0], pointerCoords[0]) * __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k + __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").x)) === null || _c === void 0 ? void 0 : _c.attr('y', Math.min(__classPrivateFieldGet(this, _DiagramCanvas_draggingFrom, "f")[1], pointerCoords[1]) * __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k + __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").y)) === null || _d === void 0 ? void 0 : _d.attr('width', Math.abs(__classPrivateFieldGet(this, _DiagramCanvas_draggingFrom, "f")[0] - pointerCoords[0]) * __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k)) === null || _e === void 0 ? void 0 : _e.attr('height', Math.abs(__classPrivateFieldGet(this, _DiagramCanvas_draggingFrom, "f")[1] - pointerCoords[1]) * __classPrivateFieldGet(this, _DiagramCanvas_zoomTransform, "f").k);
10375
+ __classPrivateFieldSet(this, _DiagramCanvas_dragging, true, "f");
10376
+ }
10377
+ }, _DiagramCanvas_finishMultipleSelection = function _DiagramCanvas_finishMultipleSelection(event) {
10378
+ var _b;
10379
+ const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
10380
+ (_b = __classPrivateFieldGet(this, _DiagramCanvas_multipleSelectionContainer, "f")) === null || _b === void 0 ? void 0 : _b.remove();
10381
+ __classPrivateFieldSet(this, _DiagramCanvas_multipleSelectionContainer, undefined, "f");
10382
+ this.userSelection.clear();
10383
+ for (const node of this.model.nodes) {
10384
+ if (rectanglesIntersect([node.coords, [node.coords[0] + node.width, node.coords[1] + node.height]], [__classPrivateFieldGet(this, _DiagramCanvas_draggingFrom, "f"), pointerCoords])) {
10385
+ this.userSelection.add(node);
10386
+ }
10387
+ }
10388
+ this.multipleSelectionOn = false;
10389
+ this.diagramEvent$.next(new DiagramSelectionEvent(this.userSelection.all(), true));
10390
+ setCursorStyle();
10391
+ };
10392
+ _DiagramCanvas_canvasCount = {
10393
+ value: 0
10394
+ };
10275
10395
 
10396
+ var _CollabClient_instances, _CollabClient_webSocket, _CollabClient_sendQueue, _CollabClient_sessions, _CollabClient_pendingSessions, _CollabClient_onOpen, _CollabClient_onMessage, _CollabClient_onClose, _CollabClient_onError, _CollabClient_send, _CollabClient_receive, _CollabClient_startSyncing;
10276
10397
  const VERSION = '0.0.1';
10277
10398
  /**
10278
10399
  * The client that communicates with the daga-server over WebSockets.
@@ -10282,24 +10403,26 @@ const VERSION = '0.0.1';
10282
10403
  */
10283
10404
  class CollabClient {
10284
10405
  constructor(dagaServer, userId) {
10285
- this.sendQueue = [];
10406
+ _CollabClient_instances.add(this);
10407
+ _CollabClient_webSocket.set(this, void 0);
10408
+ _CollabClient_sendQueue.set(this, []);
10286
10409
  /**
10287
10410
  * Joined sessions by locator.
10288
10411
  */
10289
- this.sessions = new Map();
10412
+ _CollabClient_sessions.set(this, new Map());
10290
10413
  /**
10291
10414
  * Created but unacked sessions by refId.
10292
10415
  */
10293
- this.pendingSessions = new Map();
10416
+ _CollabClient_pendingSessions.set(this, new Map());
10294
10417
  this.dagaServer = dagaServer;
10295
10418
  this.userId = userId;
10296
10419
  this.clientId = v4();
10297
- this.ws = new WebSocket(this.dagaServer, 'esgrima');
10298
- this.ws.addEventListener('open', this.onOpen.bind(this));
10299
- this.ws.addEventListener('message', this.onMessage.bind(this));
10300
- this.ws.addEventListener('close', this.onClose.bind(this));
10301
- this.ws.addEventListener('error', this.onError.bind(this));
10302
- this.send({
10420
+ __classPrivateFieldSet(this, _CollabClient_webSocket, new WebSocket(this.dagaServer, 'esgrima'), "f");
10421
+ __classPrivateFieldGet(this, _CollabClient_webSocket, "f").addEventListener('open', __classPrivateFieldGet(this, _CollabClient_instances, "m", _CollabClient_onOpen).bind(this));
10422
+ __classPrivateFieldGet(this, _CollabClient_webSocket, "f").addEventListener('message', __classPrivateFieldGet(this, _CollabClient_instances, "m", _CollabClient_onMessage).bind(this));
10423
+ __classPrivateFieldGet(this, _CollabClient_webSocket, "f").addEventListener('close', __classPrivateFieldGet(this, _CollabClient_instances, "m", _CollabClient_onClose).bind(this));
10424
+ __classPrivateFieldGet(this, _CollabClient_webSocket, "f").addEventListener('error', __classPrivateFieldGet(this, _CollabClient_instances, "m", _CollabClient_onError).bind(this));
10425
+ __classPrivateFieldGet(this, _CollabClient_instances, "m", _CollabClient_send).call(this, {
10303
10426
  type: 'HELO',
10304
10427
  clientId: this.clientId,
10305
10428
  userId: this.userId,
@@ -10307,86 +10430,6 @@ class CollabClient {
10307
10430
  ts: now()
10308
10431
  });
10309
10432
  }
10310
- onOpen() {
10311
- // Send queued messages.
10312
- for (const serialized of this.sendQueue) {
10313
- this.ws.send(serialized);
10314
- }
10315
- this.sendQueue = [];
10316
- }
10317
- onMessage(e) {
10318
- const serialized = e.data;
10319
- const message = JSON.parse(serialized);
10320
- this.receive(message);
10321
- }
10322
- onClose(e) {
10323
- console.error('WebSocket closed', e);
10324
- }
10325
- onError(e) {
10326
- console.error('WebSocket error', e);
10327
- }
10328
- /**
10329
- * Internal send method. Use instead of calling ws.send directly.
10330
- */
10331
- send(message) {
10332
- const serialized = JSON.stringify(message);
10333
- if (this.ws.readyState === WebSocket.OPEN) {
10334
- this.ws.send(serialized);
10335
- } else {
10336
- // Queue until after we connect.
10337
- this.sendQueue.push(serialized);
10338
- }
10339
- }
10340
- /**
10341
- * Internal receive method. Use instead of handling ws receive events directly.
10342
- */
10343
- receive(message) {
10344
- var _a, _b;
10345
- switch (message.type) {
10346
- case 'EACK':
10347
- {
10348
- const session = this.sessions.get(message.locator);
10349
- if (session === undefined) {
10350
- throw new Error(`EACK for unknown locator: "${message.locator}"`);
10351
- }
10352
- const initialModel = message.initialModel;
10353
- new DagaImporter().import(session.canvas.model, initialModel);
10354
- this.startSyncing(session);
10355
- (_a = session.joinRoomResolve) === null || _a === void 0 ? void 0 : _a.call(session);
10356
- session.joinRoomResolve = undefined;
10357
- break;
10358
- }
10359
- case 'ADD':
10360
- {
10361
- const session = this.sessions.get(message.locator);
10362
- if (session === undefined) {
10363
- throw new Error(`ADD for unknown locator: "${message.locator}"`);
10364
- }
10365
- const action = message.payload;
10366
- session.canvas.collabEngine.receive(action);
10367
- break;
10368
- }
10369
- case 'CACK':
10370
- {
10371
- const session = this.pendingSessions.get(message.refId);
10372
- if (session === undefined) {
10373
- throw new Error(`CACK for unknown refId: "${message.refId}"`);
10374
- }
10375
- session.locator = message.locator;
10376
- this.pendingSessions.delete(message.refId);
10377
- this.sessions.set(session.locator, session);
10378
- (_b = session.createRoomResolve) === null || _b === void 0 ? void 0 : _b.call(session, session.locator);
10379
- session.createRoomResolve = undefined;
10380
- // Deliver queued AddMessages now that we have a locator.
10381
- for (const message of session.addQueue) {
10382
- this.send(Object.assign(Object.assign({}, message), {
10383
- locator: session.locator
10384
- }));
10385
- }
10386
- session.addQueue = [];
10387
- }
10388
- }
10389
- }
10390
10433
  /**
10391
10434
  * Creates and joins a room. The given canvas becomes collaborative, starting
10392
10435
  * with its current model.
@@ -10401,7 +10444,7 @@ class CollabClient {
10401
10444
  canvas.collabEngine.isInRoom = true;
10402
10445
  const refId = v4();
10403
10446
  const initialModel = new DagaExporter().export(canvas.model, true);
10404
- this.send({
10447
+ __classPrivateFieldGet(this, _CollabClient_instances, "m", _CollabClient_send).call(this, {
10405
10448
  type: 'CREA',
10406
10449
  clientId: this.clientId,
10407
10450
  userId: this.userId,
@@ -10414,10 +10457,10 @@ class CollabClient {
10414
10457
  locator: null,
10415
10458
  addQueue: []
10416
10459
  };
10417
- this.pendingSessions.set(refId, session);
10460
+ __classPrivateFieldGet(this, _CollabClient_pendingSessions, "f").set(refId, session);
10418
10461
  // We need to start queuing local AddMessages immediately, in case the user edits
10419
10462
  // the diagram while the CREA message is in-flight.
10420
- this.startSyncing(session);
10463
+ __classPrivateFieldGet(this, _CollabClient_instances, "m", _CollabClient_startSyncing).call(this, session);
10421
10464
  return new Promise(resolve => {
10422
10465
  session.createRoomResolve = resolve;
10423
10466
  });
@@ -10436,7 +10479,7 @@ class CollabClient {
10436
10479
  throw new Error('Canvas is already in a room');
10437
10480
  }
10438
10481
  canvas.collabEngine.isInRoom = true;
10439
- this.send({
10482
+ __classPrivateFieldGet(this, _CollabClient_instances, "m", _CollabClient_send).call(this, {
10440
10483
  type: 'ENRO',
10441
10484
  clientId: this.clientId,
10442
10485
  userId: this.userId,
@@ -10448,36 +10491,104 @@ class CollabClient {
10448
10491
  locator,
10449
10492
  addQueue: []
10450
10493
  };
10451
- this.sessions.set(locator, session);
10494
+ __classPrivateFieldGet(this, _CollabClient_sessions, "f").set(locator, session);
10452
10495
  return new Promise(resolve => {
10453
10496
  session.joinRoomResolve = resolve;
10454
10497
  });
10455
10498
  }
10456
- startSyncing(session) {
10457
- // Sync AddMessages from us to the server.
10458
- session.canvas.collabEngine.onSend = action => {
10459
- if (session.locator === null) {
10460
- // Queue until we receive the locator in the CACK message.
10461
- session.addQueue.push({
10462
- type: 'ADD',
10463
- clientId: this.clientId,
10464
- userId: this.userId,
10465
- payload: action,
10466
- ts: now()
10467
- });
10468
- } else {
10469
- this.send({
10470
- type: 'ADD',
10471
- clientId: this.clientId,
10472
- userId: this.userId,
10473
- locator: session.locator,
10474
- payload: action,
10475
- ts: now()
10476
- });
10477
- }
10478
- };
10479
- }
10480
10499
  }
10500
+ _CollabClient_webSocket = new WeakMap(), _CollabClient_sendQueue = new WeakMap(), _CollabClient_sessions = new WeakMap(), _CollabClient_pendingSessions = new WeakMap(), _CollabClient_instances = new WeakSet(), _CollabClient_onOpen = function _CollabClient_onOpen() {
10501
+ // Send queued messages.
10502
+ for (const serialized of __classPrivateFieldGet(this, _CollabClient_sendQueue, "f")) {
10503
+ __classPrivateFieldGet(this, _CollabClient_webSocket, "f").send(serialized);
10504
+ }
10505
+ __classPrivateFieldSet(this, _CollabClient_sendQueue, [], "f");
10506
+ }, _CollabClient_onMessage = function _CollabClient_onMessage(e) {
10507
+ const serialized = e.data;
10508
+ const message = JSON.parse(serialized);
10509
+ __classPrivateFieldGet(this, _CollabClient_instances, "m", _CollabClient_receive).call(this, message);
10510
+ }, _CollabClient_onClose = function _CollabClient_onClose(e) {
10511
+ console.error('WebSocket closed', e);
10512
+ }, _CollabClient_onError = function _CollabClient_onError(e) {
10513
+ console.error('WebSocket error', e);
10514
+ }, _CollabClient_send = function _CollabClient_send(message) {
10515
+ const serialized = JSON.stringify(message);
10516
+ if (__classPrivateFieldGet(this, _CollabClient_webSocket, "f").readyState === WebSocket.OPEN) {
10517
+ __classPrivateFieldGet(this, _CollabClient_webSocket, "f").send(serialized);
10518
+ } else {
10519
+ // Queue until after we connect.
10520
+ __classPrivateFieldGet(this, _CollabClient_sendQueue, "f").push(serialized);
10521
+ }
10522
+ }, _CollabClient_receive = function _CollabClient_receive(message) {
10523
+ var _a, _b;
10524
+ switch (message.type) {
10525
+ case 'EACK':
10526
+ {
10527
+ const session = __classPrivateFieldGet(this, _CollabClient_sessions, "f").get(message.locator);
10528
+ if (session === undefined) {
10529
+ throw new Error(`EACK for unknown locator: "${message.locator}"`);
10530
+ }
10531
+ const initialModel = message.initialModel;
10532
+ new DagaImporter().import(session.canvas.model, initialModel);
10533
+ __classPrivateFieldGet(this, _CollabClient_instances, "m", _CollabClient_startSyncing).call(this, session);
10534
+ (_a = session.joinRoomResolve) === null || _a === void 0 ? void 0 : _a.call(session);
10535
+ session.joinRoomResolve = undefined;
10536
+ break;
10537
+ }
10538
+ case 'ADD':
10539
+ {
10540
+ const session = __classPrivateFieldGet(this, _CollabClient_sessions, "f").get(message.locator);
10541
+ if (session === undefined) {
10542
+ throw new Error(`ADD for unknown locator: "${message.locator}"`);
10543
+ }
10544
+ const action = message.payload;
10545
+ session.canvas.collabEngine.receive(action);
10546
+ break;
10547
+ }
10548
+ case 'CACK':
10549
+ {
10550
+ const session = __classPrivateFieldGet(this, _CollabClient_pendingSessions, "f").get(message.refId);
10551
+ if (session === undefined) {
10552
+ throw new Error(`CACK for unknown refId: "${message.refId}"`);
10553
+ }
10554
+ session.locator = message.locator;
10555
+ __classPrivateFieldGet(this, _CollabClient_pendingSessions, "f").delete(message.refId);
10556
+ __classPrivateFieldGet(this, _CollabClient_sessions, "f").set(session.locator, session);
10557
+ (_b = session.createRoomResolve) === null || _b === void 0 ? void 0 : _b.call(session, session.locator);
10558
+ session.createRoomResolve = undefined;
10559
+ // Deliver queued AddMessages now that we have a locator.
10560
+ for (const message of session.addQueue) {
10561
+ __classPrivateFieldGet(this, _CollabClient_instances, "m", _CollabClient_send).call(this, Object.assign(Object.assign({}, message), {
10562
+ locator: session.locator
10563
+ }));
10564
+ }
10565
+ session.addQueue = [];
10566
+ }
10567
+ }
10568
+ }, _CollabClient_startSyncing = function _CollabClient_startSyncing(session) {
10569
+ // Sync AddMessages from us to the server.
10570
+ session.canvas.collabEngine.onSend = action => {
10571
+ if (session.locator === null) {
10572
+ // Queue until we receive the locator in the CACK message.
10573
+ session.addQueue.push({
10574
+ type: 'ADD',
10575
+ clientId: this.clientId,
10576
+ userId: this.userId,
10577
+ payload: action,
10578
+ ts: now()
10579
+ });
10580
+ } else {
10581
+ __classPrivateFieldGet(this, _CollabClient_instances, "m", _CollabClient_send).call(this, {
10582
+ type: 'ADD',
10583
+ clientId: this.clientId,
10584
+ userId: this.userId,
10585
+ locator: session.locator,
10586
+ payload: action,
10587
+ ts: now()
10588
+ });
10589
+ }
10590
+ };
10591
+ };
10481
10592
  /**
10482
10593
  * Returns the current timestamp for a message's ts field.
10483
10594
  */
@@ -10485,66 +10596,67 @@ function now() {
10485
10596
  return new Date().toISOString();
10486
10597
  }
10487
10598
 
10599
+ var _Grid_grid, _Grid_offsetX, _Grid_offsetY;
10488
10600
  /**
10489
10601
  * A two dimensional array of elements of the given class that can extend infinitely in any direction, both positive and negative.
10490
10602
  * @private
10491
10603
  */
10492
10604
  class Grid {
10493
10605
  constructor() {
10494
- this.grid = [[undefined]];
10495
- this.offsetX = 0;
10496
- this.offsetY = 0;
10606
+ _Grid_grid.set(this, [[undefined]]);
10607
+ _Grid_offsetX.set(this, 0);
10608
+ _Grid_offsetY.set(this, 0);
10497
10609
  }
10498
10610
  /**
10499
10611
  * Get the minimum x coordinate among the elements in the grid.
10500
10612
  */
10501
10613
  minX() {
10502
- return -this.offsetX;
10614
+ return -__classPrivateFieldGet(this, _Grid_offsetX, "f");
10503
10615
  }
10504
10616
  /**
10505
10617
  * Get the maximum x coordinate among the elements in the grid.
10506
10618
  */
10507
10619
  maxX() {
10508
- return this.width() - 1 - this.offsetX;
10620
+ return this.width() - 1 - __classPrivateFieldGet(this, _Grid_offsetX, "f");
10509
10621
  }
10510
10622
  /**
10511
10623
  * Get the minimum y coordinate among the elements in the grid.
10512
10624
  */
10513
10625
  minY() {
10514
- return -this.offsetY;
10626
+ return -__classPrivateFieldGet(this, _Grid_offsetY, "f");
10515
10627
  }
10516
10628
  /**
10517
10629
  * Get the maximum y coordinate among the elements in the grid.
10518
10630
  */
10519
10631
  maxY() {
10520
- return this.height() - 1 - this.offsetY;
10632
+ return this.height() - 1 - __classPrivateFieldGet(this, _Grid_offsetY, "f");
10521
10633
  }
10522
10634
  /**
10523
10635
  * Get the total extension of the grid along the x axis.
10524
10636
  */
10525
10637
  width() {
10526
- return this.grid[0].length;
10638
+ return __classPrivateFieldGet(this, _Grid_grid, "f")[0].length;
10527
10639
  }
10528
10640
  /**
10529
10641
  * Get the total extension of the grid along the y axis.
10530
10642
  */
10531
10643
  height() {
10532
- return this.grid.length;
10644
+ return __classPrivateFieldGet(this, _Grid_grid, "f").length;
10533
10645
  }
10534
10646
  /**
10535
10647
  * Add a new column at the start of the x axis.
10536
10648
  */
10537
10649
  addColumnLeft() {
10538
- for (const row of this.grid) {
10650
+ for (const row of __classPrivateFieldGet(this, _Grid_grid, "f")) {
10539
10651
  row.splice(0, 0, undefined);
10540
10652
  }
10541
- this.offsetX = this.offsetX + 1;
10653
+ __classPrivateFieldSet(this, _Grid_offsetX, __classPrivateFieldGet(this, _Grid_offsetX, "f") + 1, "f");
10542
10654
  }
10543
10655
  /**
10544
10656
  * Add a new column at the end of the x axis.
10545
10657
  */
10546
10658
  addColumnRight() {
10547
- for (const row of this.grid) {
10659
+ for (const row of __classPrivateFieldGet(this, _Grid_grid, "f")) {
10548
10660
  row.push(undefined);
10549
10661
  }
10550
10662
  }
@@ -10553,28 +10665,28 @@ class Grid {
10553
10665
  */
10554
10666
  addRowTop() {
10555
10667
  const newRow = [];
10556
- for (let i = 0; i < this.grid[0].length; ++i) {
10668
+ for (let i = 0; i < __classPrivateFieldGet(this, _Grid_grid, "f")[0].length; ++i) {
10557
10669
  newRow.push(undefined);
10558
10670
  }
10559
- this.grid.splice(0, 0, newRow);
10560
- this.offsetY = this.offsetY + 1;
10671
+ __classPrivateFieldGet(this, _Grid_grid, "f").splice(0, 0, newRow);
10672
+ __classPrivateFieldSet(this, _Grid_offsetY, __classPrivateFieldGet(this, _Grid_offsetY, "f") + 1, "f");
10561
10673
  }
10562
10674
  /**
10563
10675
  * Add a new row at the end of the y axis.
10564
10676
  */
10565
10677
  addRowBottom() {
10566
10678
  const newRow = [];
10567
- for (let i = 0; i < this.grid[0].length; ++i) {
10679
+ for (let i = 0; i < __classPrivateFieldGet(this, _Grid_grid, "f")[0].length; ++i) {
10568
10680
  newRow.push(undefined);
10569
10681
  }
10570
- this.grid.push(newRow);
10682
+ __classPrivateFieldGet(this, _Grid_grid, "f").push(newRow);
10571
10683
  }
10572
10684
  /**
10573
10685
  * Get the element at the given coordinates or undefined if there is no element at the given coordinates.
10574
10686
  */
10575
10687
  get(coords) {
10576
- if (this.grid[coords[1] + this.offsetY]) {
10577
- return this.grid[coords[1] + this.offsetY][coords[0] + this.offsetX];
10688
+ if (__classPrivateFieldGet(this, _Grid_grid, "f")[coords[1] + __classPrivateFieldGet(this, _Grid_offsetY, "f")]) {
10689
+ return __classPrivateFieldGet(this, _Grid_grid, "f")[coords[1] + __classPrivateFieldGet(this, _Grid_offsetY, "f")][coords[0] + __classPrivateFieldGet(this, _Grid_offsetX, "f")];
10578
10690
  }
10579
10691
  return undefined;
10580
10692
  }
@@ -10582,19 +10694,19 @@ class Grid {
10582
10694
  * Set the element at the given coordinates to the given element.
10583
10695
  */
10584
10696
  set(coords, value) {
10585
- while (coords[0] < -this.offsetX) {
10697
+ while (coords[0] < -__classPrivateFieldGet(this, _Grid_offsetX, "f")) {
10586
10698
  this.addColumnLeft();
10587
10699
  }
10588
- while (coords[0] >= this.width() - this.offsetX) {
10700
+ while (coords[0] >= this.width() - __classPrivateFieldGet(this, _Grid_offsetX, "f")) {
10589
10701
  this.addColumnRight();
10590
10702
  }
10591
- while (coords[1] < -this.offsetY) {
10703
+ while (coords[1] < -__classPrivateFieldGet(this, _Grid_offsetY, "f")) {
10592
10704
  this.addRowTop();
10593
10705
  }
10594
- while (coords[1] >= this.height() - this.offsetY) {
10706
+ while (coords[1] >= this.height() - __classPrivateFieldGet(this, _Grid_offsetY, "f")) {
10595
10707
  this.addRowBottom();
10596
10708
  }
10597
- this.grid[coords[1] + this.offsetY][coords[0] + this.offsetX] = value;
10709
+ __classPrivateFieldGet(this, _Grid_grid, "f")[coords[1] + __classPrivateFieldGet(this, _Grid_offsetY, "f")][coords[0] + __classPrivateFieldGet(this, _Grid_offsetX, "f")] = value;
10598
10710
  }
10599
10711
  /**
10600
10712
  * Get the closest coordinates to the given coordinates that are not set to an element.
@@ -10624,6 +10736,7 @@ class Grid {
10624
10736
  }
10625
10737
  }
10626
10738
  }
10739
+ _Grid_grid = new WeakMap(), _Grid_offsetX = new WeakMap(), _Grid_offsetY = new WeakMap();
10627
10740
 
10628
10741
  /**
10629
10742
  * A layout which places adjacent nodes close by, placing nodes in order according to depth first search.