@esfaenza/es-diagrams 11.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +1 -0
  2. package/bundles/esfaenza-es-diagrams.umd.js +1748 -0
  3. package/bundles/esfaenza-es-diagrams.umd.js.map +1 -0
  4. package/esfaenza-es-diagrams.d.ts +9 -0
  5. package/esfaenza-es-diagrams.metadata.json +1 -0
  6. package/esm2015/esfaenza-es-diagrams.js +10 -0
  7. package/esm2015/lib/components/es-diagram.component.js +396 -0
  8. package/esm2015/lib/esdiagram.module.js +28 -0
  9. package/esm2015/lib/extensions/ReactiveExtensions.js +34 -0
  10. package/esm2015/lib/extensions/ResizeSensor.js +71 -0
  11. package/esm2015/lib/models/EsDiagramModuleConfig.js +6 -0
  12. package/esm2015/lib/models/component/contextmenu/ContextMenuCommand.js +6 -0
  13. package/esm2015/lib/models/component/contextmenu/ContextMenuOptions.js +7 -0
  14. package/esm2015/lib/models/component/grouping/ExpandCollapseOptions.js +6 -0
  15. package/esm2015/lib/models/component/nodes/NodeHTMLTemplate.js +6 -0
  16. package/esm2015/lib/models/component/nodes/NodeTemplate.js +6 -0
  17. package/esm2015/lib/models/component/nodes/ZoomLevelBasedTemplate.js +6 -0
  18. package/esm2015/lib/models/layouts/BreadthFirstLayoutOptionsImpl.js +35 -0
  19. package/esm2015/lib/models/layouts/CircleLayoutOptionsImpl.js +27 -0
  20. package/esm2015/lib/models/layouts/ConcentricLayoutOptionsImpl.js +64 -0
  21. package/esm2015/lib/models/layouts/CoseLayoutOptionsImpl.js +83 -0
  22. package/esm2015/lib/models/layouts/DagreLayoutOptionsImpl.js +52 -0
  23. package/esm2015/lib/models/layouts/GridLayoutOptionsImpl.js +38 -0
  24. package/esm2015/lib/models/layouts/NullLayoutOptionsImpl.js +15 -0
  25. package/esm2015/lib/models/layouts/PresetLayoutOptionsImpl.js +24 -0
  26. package/esm2015/lib/models/layouts/RandomLayoutOptionsImpl.js +36 -0
  27. package/esm2015/lib/models/layouts/base/AnimateLayoutOptionsImpl.js +42 -0
  28. package/esm2015/lib/models/layouts/base/BaseLayoutOptionsImpl.js +18 -0
  29. package/esm2015/lib/models/layouts/base/ShapedLayoutOptionsImpl.js +48 -0
  30. package/esm2015/lib/services/es-diagram.dispatcher.js +86 -0
  31. package/esm2015/lib/services/es-diagram.loc.js +17 -0
  32. package/esm2015/lib/services/es-diagram.service.js +106 -0
  33. package/esm2015/lib/tokens.js +10 -0
  34. package/esm2015/public-api.js +24 -0
  35. package/fesm2015/esfaenza-es-diagrams.js +1254 -0
  36. package/fesm2015/esfaenza-es-diagrams.js.map +1 -0
  37. package/lib/components/es-diagram.component.d.ts +243 -0
  38. package/lib/esdiagram.module.d.ts +5 -0
  39. package/lib/extensions/ReactiveExtensions.d.ts +17 -0
  40. package/lib/extensions/ResizeSensor.d.ts +43 -0
  41. package/lib/models/EsDiagramModuleConfig.d.ts +13 -0
  42. package/lib/models/component/contextmenu/ContextMenuCommand.d.ts +27 -0
  43. package/lib/models/component/contextmenu/ContextMenuOptions.d.ts +71 -0
  44. package/lib/models/component/grouping/ExpandCollapseOptions.d.ts +22 -0
  45. package/lib/models/component/nodes/NodeHTMLTemplate.d.ts +14 -0
  46. package/lib/models/component/nodes/NodeTemplate.d.ts +13 -0
  47. package/lib/models/component/nodes/ZoomLevelBasedTemplate.d.ts +14 -0
  48. package/lib/models/layouts/BreadthFirstLayoutOptionsImpl.d.ts +40 -0
  49. package/lib/models/layouts/CircleLayoutOptionsImpl.d.ts +28 -0
  50. package/lib/models/layouts/ConcentricLayoutOptionsImpl.d.ts +74 -0
  51. package/lib/models/layouts/CoseLayoutOptionsImpl.d.ts +80 -0
  52. package/lib/models/layouts/DagreLayoutOptionsImpl.d.ts +48 -0
  53. package/lib/models/layouts/GridLayoutOptionsImpl.d.ts +39 -0
  54. package/lib/models/layouts/NullLayoutOptionsImpl.d.ts +12 -0
  55. package/lib/models/layouts/PresetLayoutOptionsImpl.d.ts +37 -0
  56. package/lib/models/layouts/RandomLayoutOptionsImpl.d.ts +33 -0
  57. package/lib/models/layouts/base/AnimateLayoutOptionsImpl.d.ts +40 -0
  58. package/lib/models/layouts/base/BaseLayoutOptionsImpl.d.ts +15 -0
  59. package/lib/models/layouts/base/ShapedLayoutOptionsImpl.d.ts +46 -0
  60. package/lib/services/es-diagram.dispatcher.d.ts +41 -0
  61. package/lib/services/es-diagram.loc.d.ts +49 -0
  62. package/lib/services/es-diagram.service.d.ts +49 -0
  63. package/lib/tokens.d.ts +9 -0
  64. package/package.json +25 -0
  65. package/public-api.d.ts +20 -0
@@ -0,0 +1,1748 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('cytoscape'), require('@angular/forms'), require('@angular/common')) :
3
+ typeof define === 'function' && define.amd ? define('@esfaenza/es-diagrams', ['exports', '@angular/core', 'cytoscape', '@angular/forms', '@angular/common'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.esfaenza = global.esfaenza || {}, global.esfaenza['es-diagrams'] = {}), global.ng.core, global.cy_, global.ng.forms, global.ng.common));
5
+ }(this, (function (exports, i0, cy_, forms, common) { 'use strict';
6
+
7
+ function _interopNamespace(e) {
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () {
17
+ return e[k];
18
+ }
19
+ });
20
+ }
21
+ });
22
+ }
23
+ n['default'] = e;
24
+ return Object.freeze(n);
25
+ }
26
+
27
+ var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28
+ var cy___namespace = /*#__PURE__*/_interopNamespace(cy_);
29
+
30
+ /**
31
+ * Definizione di un comando del Context menù
32
+ */
33
+ var ContextMenuCommand = /** @class */ (function () {
34
+ function ContextMenuCommand() {
35
+ }
36
+ return ContextMenuCommand;
37
+ }());
38
+
39
+ /**
40
+ * Opzioni che gestiscono il context menu. Quando una di queste opzioni non viene assegnata viene mantenuto il default, assicurarsi quindi di modificare solo
41
+ * le proprietà che si vogliono effettivamente cambiare rispetto ai default
42
+ */
43
+ var ContextMenuOptions = /** @class */ (function () {
44
+ function ContextMenuOptions() {
45
+ }
46
+ return ContextMenuOptions;
47
+ }());
48
+
49
+ /**
50
+ * Opzioni native per l'estensione expand-collapse di cytoscape
51
+ */
52
+ var ExpandCollapseOptions = /** @class */ (function () {
53
+ function ExpandCollapseOptions() {
54
+ }
55
+ return ExpandCollapseOptions;
56
+ }());
57
+
58
+ /**
59
+ * Classe che indica per una data query quali template applicare
60
+ */
61
+ var NodeHTMLTemplate = /** @class */ (function () {
62
+ function NodeHTMLTemplate() {
63
+ }
64
+ return NodeHTMLTemplate;
65
+ }());
66
+
67
+ /**
68
+ * Classe che rappresenta un template HTML applicabile ad un nodo
69
+ */
70
+ var NodeTemplate = /** @class */ (function () {
71
+ function NodeTemplate() {
72
+ }
73
+ return NodeTemplate;
74
+ }());
75
+
76
+ /**
77
+ * Classe che rappresenta il template HTML di un nodo da utilizzare per un certo livello di zoom
78
+ */
79
+ var ZoomLevelBasedTemplate = /** @class */ (function () {
80
+ function ZoomLevelBasedTemplate() {
81
+ }
82
+ return ZoomLevelBasedTemplate;
83
+ }());
84
+
85
+ /**
86
+ * Opzioni di layout di base che si collegano al **ready** e allo **stop** eventualmente per aggiungere del log addizionale
87
+ */
88
+ var BaseLayoutOptionsImpl = /** @class */ (function () {
89
+ function BaseLayoutOptionsImpl() {
90
+ }
91
+ /**
92
+ * Per ora ignoro lato documentale dato che sono placholder
93
+ * @ignore
94
+ */
95
+ BaseLayoutOptionsImpl.prototype.ready = function (e) {
96
+ };
97
+ /**
98
+ * Per ora ignoro lato documentale dato che sono placholder
99
+ * @ignore
100
+ */
101
+ BaseLayoutOptionsImpl.prototype.stop = function (e) {
102
+ };
103
+ return BaseLayoutOptionsImpl;
104
+ }());
105
+
106
+ /*! *****************************************************************************
107
+ Copyright (c) Microsoft Corporation.
108
+
109
+ Permission to use, copy, modify, and/or distribute this software for any
110
+ purpose with or without fee is hereby granted.
111
+
112
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
113
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
114
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
115
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
116
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
117
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
118
+ PERFORMANCE OF THIS SOFTWARE.
119
+ ***************************************************************************** */
120
+ /* global Reflect, Promise */
121
+ var extendStatics = function (d, b) {
122
+ extendStatics = Object.setPrototypeOf ||
123
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
124
+ function (d, b) { for (var p in b)
125
+ if (Object.prototype.hasOwnProperty.call(b, p))
126
+ d[p] = b[p]; };
127
+ return extendStatics(d, b);
128
+ };
129
+ function __extends(d, b) {
130
+ if (typeof b !== "function" && b !== null)
131
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
132
+ extendStatics(d, b);
133
+ function __() { this.constructor = d; }
134
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
135
+ }
136
+ var __assign = function () {
137
+ __assign = Object.assign || function __assign(t) {
138
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
139
+ s = arguments[i];
140
+ for (var p in s)
141
+ if (Object.prototype.hasOwnProperty.call(s, p))
142
+ t[p] = s[p];
143
+ }
144
+ return t;
145
+ };
146
+ return __assign.apply(this, arguments);
147
+ };
148
+ function __rest(s, e) {
149
+ var t = {};
150
+ for (var p in s)
151
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
152
+ t[p] = s[p];
153
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
154
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
155
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
156
+ t[p[i]] = s[p[i]];
157
+ }
158
+ return t;
159
+ }
160
+ function __decorate(decorators, target, key, desc) {
161
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
162
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
163
+ r = Reflect.decorate(decorators, target, key, desc);
164
+ else
165
+ for (var i = decorators.length - 1; i >= 0; i--)
166
+ if (d = decorators[i])
167
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
168
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
169
+ }
170
+ function __param(paramIndex, decorator) {
171
+ return function (target, key) { decorator(target, key, paramIndex); };
172
+ }
173
+ function __metadata(metadataKey, metadataValue) {
174
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
175
+ return Reflect.metadata(metadataKey, metadataValue);
176
+ }
177
+ function __awaiter(thisArg, _arguments, P, generator) {
178
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
179
+ return new (P || (P = Promise))(function (resolve, reject) {
180
+ function fulfilled(value) { try {
181
+ step(generator.next(value));
182
+ }
183
+ catch (e) {
184
+ reject(e);
185
+ } }
186
+ function rejected(value) { try {
187
+ step(generator["throw"](value));
188
+ }
189
+ catch (e) {
190
+ reject(e);
191
+ } }
192
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
193
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
194
+ });
195
+ }
196
+ function __generator(thisArg, body) {
197
+ var _ = { label: 0, sent: function () { if (t[0] & 1)
198
+ throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
199
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
200
+ function verb(n) { return function (v) { return step([n, v]); }; }
201
+ function step(op) {
202
+ if (f)
203
+ throw new TypeError("Generator is already executing.");
204
+ while (_)
205
+ try {
206
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
207
+ return t;
208
+ if (y = 0, t)
209
+ op = [op[0] & 2, t.value];
210
+ switch (op[0]) {
211
+ case 0:
212
+ case 1:
213
+ t = op;
214
+ break;
215
+ case 4:
216
+ _.label++;
217
+ return { value: op[1], done: false };
218
+ case 5:
219
+ _.label++;
220
+ y = op[1];
221
+ op = [0];
222
+ continue;
223
+ case 7:
224
+ op = _.ops.pop();
225
+ _.trys.pop();
226
+ continue;
227
+ default:
228
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
229
+ _ = 0;
230
+ continue;
231
+ }
232
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
233
+ _.label = op[1];
234
+ break;
235
+ }
236
+ if (op[0] === 6 && _.label < t[1]) {
237
+ _.label = t[1];
238
+ t = op;
239
+ break;
240
+ }
241
+ if (t && _.label < t[2]) {
242
+ _.label = t[2];
243
+ _.ops.push(op);
244
+ break;
245
+ }
246
+ if (t[2])
247
+ _.ops.pop();
248
+ _.trys.pop();
249
+ continue;
250
+ }
251
+ op = body.call(thisArg, _);
252
+ }
253
+ catch (e) {
254
+ op = [6, e];
255
+ y = 0;
256
+ }
257
+ finally {
258
+ f = t = 0;
259
+ }
260
+ if (op[0] & 5)
261
+ throw op[1];
262
+ return { value: op[0] ? op[1] : void 0, done: true };
263
+ }
264
+ }
265
+ var __createBinding = Object.create ? (function (o, m, k, k2) {
266
+ if (k2 === undefined)
267
+ k2 = k;
268
+ Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
269
+ }) : (function (o, m, k, k2) {
270
+ if (k2 === undefined)
271
+ k2 = k;
272
+ o[k2] = m[k];
273
+ });
274
+ function __exportStar(m, o) {
275
+ for (var p in m)
276
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
277
+ __createBinding(o, m, p);
278
+ }
279
+ function __values(o) {
280
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
281
+ if (m)
282
+ return m.call(o);
283
+ if (o && typeof o.length === "number")
284
+ return {
285
+ next: function () {
286
+ if (o && i >= o.length)
287
+ o = void 0;
288
+ return { value: o && o[i++], done: !o };
289
+ }
290
+ };
291
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
292
+ }
293
+ function __read(o, n) {
294
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
295
+ if (!m)
296
+ return o;
297
+ var i = m.call(o), r, ar = [], e;
298
+ try {
299
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
300
+ ar.push(r.value);
301
+ }
302
+ catch (error) {
303
+ e = { error: error };
304
+ }
305
+ finally {
306
+ try {
307
+ if (r && !r.done && (m = i["return"]))
308
+ m.call(i);
309
+ }
310
+ finally {
311
+ if (e)
312
+ throw e.error;
313
+ }
314
+ }
315
+ return ar;
316
+ }
317
+ /** @deprecated */
318
+ function __spread() {
319
+ for (var ar = [], i = 0; i < arguments.length; i++)
320
+ ar = ar.concat(__read(arguments[i]));
321
+ return ar;
322
+ }
323
+ /** @deprecated */
324
+ function __spreadArrays() {
325
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++)
326
+ s += arguments[i].length;
327
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
328
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
329
+ r[k] = a[j];
330
+ return r;
331
+ }
332
+ function __spreadArray(to, from, pack) {
333
+ if (pack || arguments.length === 2)
334
+ for (var i = 0, l = from.length, ar; i < l; i++) {
335
+ if (ar || !(i in from)) {
336
+ if (!ar)
337
+ ar = Array.prototype.slice.call(from, 0, i);
338
+ ar[i] = from[i];
339
+ }
340
+ }
341
+ return to.concat(ar || Array.prototype.slice.call(from));
342
+ }
343
+ function __await(v) {
344
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
345
+ }
346
+ function __asyncGenerator(thisArg, _arguments, generator) {
347
+ if (!Symbol.asyncIterator)
348
+ throw new TypeError("Symbol.asyncIterator is not defined.");
349
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
350
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
351
+ function verb(n) { if (g[n])
352
+ i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
353
+ function resume(n, v) { try {
354
+ step(g[n](v));
355
+ }
356
+ catch (e) {
357
+ settle(q[0][3], e);
358
+ } }
359
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
360
+ function fulfill(value) { resume("next", value); }
361
+ function reject(value) { resume("throw", value); }
362
+ function settle(f, v) { if (f(v), q.shift(), q.length)
363
+ resume(q[0][0], q[0][1]); }
364
+ }
365
+ function __asyncDelegator(o) {
366
+ var i, p;
367
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
368
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
369
+ }
370
+ function __asyncValues(o) {
371
+ if (!Symbol.asyncIterator)
372
+ throw new TypeError("Symbol.asyncIterator is not defined.");
373
+ var m = o[Symbol.asyncIterator], i;
374
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
375
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
376
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
377
+ }
378
+ function __makeTemplateObject(cooked, raw) {
379
+ if (Object.defineProperty) {
380
+ Object.defineProperty(cooked, "raw", { value: raw });
381
+ }
382
+ else {
383
+ cooked.raw = raw;
384
+ }
385
+ return cooked;
386
+ }
387
+ ;
388
+ var __setModuleDefault = Object.create ? (function (o, v) {
389
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
390
+ }) : function (o, v) {
391
+ o["default"] = v;
392
+ };
393
+ function __importStar(mod) {
394
+ if (mod && mod.__esModule)
395
+ return mod;
396
+ var result = {};
397
+ if (mod != null)
398
+ for (var k in mod)
399
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
400
+ __createBinding(result, mod, k);
401
+ __setModuleDefault(result, mod);
402
+ return result;
403
+ }
404
+ function __importDefault(mod) {
405
+ return (mod && mod.__esModule) ? mod : { default: mod };
406
+ }
407
+ function __classPrivateFieldGet(receiver, state, kind, f) {
408
+ if (kind === "a" && !f)
409
+ throw new TypeError("Private accessor was defined without a getter");
410
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
411
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
412
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
413
+ }
414
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
415
+ if (kind === "m")
416
+ throw new TypeError("Private method is not writable");
417
+ if (kind === "a" && !f)
418
+ throw new TypeError("Private accessor was defined without a setter");
419
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
420
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
421
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
422
+ }
423
+
424
+ /**
425
+ * Classe base con le opzioni di layout valide per tutti i layout animati
426
+ */
427
+ var AnimateLayoutOptionsImpl = /** @class */ (function (_super) {
428
+ __extends(AnimateLayoutOptionsImpl, _super);
429
+ /** @ignore */
430
+ function AnimateLayoutOptionsImpl() {
431
+ var _this = _super.call(this) || this;
432
+ /**
433
+ * Livello di zoom da impostare (si consiglia fit = **false** se viene impostato)
434
+ */
435
+ _this.zoom = null;
436
+ /**
437
+ * Livello di pan da impostare (si consiglia fit = **false** se viene impostato)
438
+ */
439
+ _this.pan = null;
440
+ /**
441
+ * Indica se animare il cambio di posizione dei nodi
442
+ */
443
+ _this.animate = false;
444
+ /**
445
+ * Con **animate** a true indica la durata dell'animazione
446
+ */
447
+ _this.animationDuration = 500;
448
+ /**
449
+ * Abilita o no l'easing dell'animazione, può essere una stringa come ad esempio "ease-in-out-cubic" o altre funzioni scritte allo stesso modo prese da https://easings.net/
450
+ */
451
+ _this.animationEasing = undefined;
452
+ /**
453
+ * Funzione che indica se un nodo dev'essere animato o no.
454
+ * Tutti i nodi sono animati di default.
455
+ * Tutti i nodi che non vengono animati verranno posizionati appena inizia l'animazione
456
+ *
457
+ * @param {any} node Nodo per cui decidere se abilitare l'animazione o no
458
+ * @param {number} i Indice del nodo corrente
459
+ *
460
+ * @returns {boolean} **true** se il nodo dev'essere animato, **false** altrimenti
461
+ */
462
+ _this.animateFilter = function (node, i) { return true; };
463
+ return _this;
464
+ }
465
+ return AnimateLayoutOptionsImpl;
466
+ }(BaseLayoutOptionsImpl));
467
+
468
+ /**
469
+ * Classe base per gli algoritmi "Shaped"
470
+ */
471
+ var ShapedLayoutOptionsImpl = /** @class */ (function (_super) {
472
+ __extends(ShapedLayoutOptionsImpl, _super);
473
+ /** @ignore */
474
+ function ShapedLayoutOptionsImpl() {
475
+ var _this = _super.call(this) || this;
476
+ /**
477
+ * Indica se adattare al contenitore
478
+ */
479
+ _this.fit = true;
480
+ /**
481
+ * Padding rispetto al contenitore
482
+ */
483
+ _this.padding = 30;
484
+ /**
485
+ * Specifica le dimensioni esatte al cui interno effettuare il layouting, specificato come **{ x1, y1, x2, y2 }** o **{ x1, y1, w, h }**
486
+ */
487
+ _this.boundingBox = null;
488
+ /**
489
+ * Fa in modo che i nodi non si accavallino, ma se il contenitore non ha abbastanza spazio potrebbero andare in overflow
490
+ */
491
+ _this.avoidOverlap = true;
492
+ /**
493
+ * Include o esclude le dimensioni delle label dei nodi nel calcolo delle posizioni
494
+ */
495
+ _this.nodeDimensionsIncludeLabels = false;
496
+ /**
497
+ * Moltiplicatore delle dimensioni per espandere/restringere le dimensioni globali del diagramma
498
+ */
499
+ _this.spacingFactor = 1;
500
+ /**
501
+ * Funzione di ordinamento per ordinare i nodi
502
+ */
503
+ _this.sort = null;
504
+ /**
505
+ * Funzione per la trasformazione delle posizioni dei nodi
506
+ *
507
+ * @param {any} node Nodo
508
+ * @param {any} position Posizione iniziale
509
+ *
510
+ * @returns {any} Posizione finale
511
+ */
512
+ _this.transform = function (node, position) { return position; };
513
+ return _this;
514
+ }
515
+ return ShapedLayoutOptionsImpl;
516
+ }(AnimateLayoutOptionsImpl));
517
+
518
+ /**
519
+ * Default per l'implementazione dell'algoritmo Breadth First
520
+ */
521
+ var BreadthFirstLayoutOptionsImpl = /** @class */ (function (_super) {
522
+ __extends(BreadthFirstLayoutOptionsImpl, _super);
523
+ /** @ignore */
524
+ function BreadthFirstLayoutOptionsImpl() {
525
+ var _this = _super.call(this) || this;
526
+ /**
527
+ * Nome dell'algoritmo di layouting
528
+ */
529
+ _this.name = 'breadthfirst';
530
+ /**
531
+ * Indica se l'albero è diretto in basso. Se false i collegamenti fra i nodi possono andare in qualsiasi direzione
532
+ */
533
+ _this.directed = false;
534
+ /**
535
+ * Se **true** i livelli vengono ordinati in cerchi concentrici, se **false** vengono oridnati dall'alto al basso
536
+ */
537
+ _this.circle = false;
538
+ /**
539
+ * Indica che i nodi verranno shiftati in base al proprio livello in modo da evitare collegamenti inversi (solo per i DAG)
540
+ */
541
+ _this.maximal = false;
542
+ /**
543
+ * Indica se creare una griglia in cui ordinare i nodi del DAG (Solo quando la proprietà **circle** è a **false**)
544
+ */
545
+ _this.grid = false;
546
+ /**
547
+ * Indica se escludere le label dei nodi quando vengono calcolati i limiti del layout
548
+ */
549
+ _this.nodeDimensionsIncludeLabels = false;
550
+ return _this;
551
+ }
552
+ return BreadthFirstLayoutOptionsImpl;
553
+ }(ShapedLayoutOptionsImpl));
554
+
555
+ /**
556
+ * Default per l'implementazione dell'algoritmo Circle
557
+ */
558
+ var CircleLayoutOptionsImpl = /** @class */ (function (_super) {
559
+ __extends(CircleLayoutOptionsImpl, _super);
560
+ /** @ignore */
561
+ function CircleLayoutOptionsImpl() {
562
+ var _this = _super.call(this) || this;
563
+ /**
564
+ * Nome dell'algoritmo di layouting
565
+ */
566
+ _this.name = 'circle';
567
+ /**
568
+ * Angolo da cui i nodi partono, in radianti (Default: **3 / 2 * Math.PI**)
569
+ */
570
+ _this.startAngle = 3 / 2 * Math.PI;
571
+ /**
572
+ * Numero di radianti fra il primo e l'ultimo nodo. Di default viene utilizzata l'intera circonferenza
573
+ */
574
+ _this.sweep = null;
575
+ /**
576
+ * Indica se andare in senso orario (**true**) o antiorario (**false**)
577
+ */
578
+ _this.clockwise = true; // whether the layout should go clockwise (true) or counterclockwise/anticlockwise (false)
579
+ return _this;
580
+ }
581
+ return CircleLayoutOptionsImpl;
582
+ }(ShapedLayoutOptionsImpl));
583
+
584
+ /**
585
+ * Default per l'implementazione dell'algoritmo Concentric
586
+ */
587
+ var ConcentricLayoutOptionsImpl = /** @class */ (function () {
588
+ function ConcentricLayoutOptionsImpl() {
589
+ /**
590
+ * Nome dell'algoritmo di layouting
591
+ */
592
+ this.name = 'concentric';
593
+ /**
594
+ * Angolo da cui i nodi partono, in radianti (Default: **3 / 2 * Math.PI**)
595
+ */
596
+ this.startAngle = 3 / 2 * Math.PI;
597
+ /**
598
+ * Include o esclude le dimensioni delle label dei nodi nel calcolo delle posizioni
599
+ */
600
+ this.nodeDimensionsIncludeLabels = true;
601
+ /**
602
+ * Indica se i livelli devono essere o non essere equidistanti, potrebbe causare overflow dal contenitore
603
+ */
604
+ this.equidistant = false;
605
+ /**
606
+ * Distanza minima dall'esterno dei nodi, utilizzato per aggiustare il raggio
607
+ */
608
+ this.minNodeSpacingnumber = 10;
609
+ /**
610
+ * Specifica le dimensioni esatte al cui interno effettuare il layouting, specificato come **{ x1, y1, x2, y2 }** o **{ x1, y1, w, h }**
611
+ */
612
+ this.boundingBox = null;
613
+ /**
614
+ * Altezza dell'area di layout (sovrascrive quella del contenitore)
615
+ */
616
+ this.height = null;
617
+ /**
618
+ * Larghezza dell'area di layout (sovrascrive quella del contenitore)
619
+ */
620
+ this.width = null;
621
+ /**
622
+ * Moltiplicatore delle dimensioni per espandere/restringere le dimensioni globali del diagramma
623
+ */
624
+ this.spacingFactor = 1;
625
+ }
626
+ /**
627
+ * Funzione di cui si può fare override per assegnare un valore ad ogni nodo. I nodi con valore più alto saranno piazzati verso il centro
628
+ *
629
+ * @param {any} node Nodo
630
+ *
631
+ * @returns {number} Valore su cui ordinare i nodi verso il centro
632
+ */
633
+ ConcentricLayoutOptionsImpl.prototype.concentric = function (node) {
634
+ return node.degree();
635
+ };
636
+ /**
637
+ * Funzione di cui si può fare override per calcolare la variazione dei valori concentrici per ogni livello
638
+ *
639
+ * @param {any} nodes Gruppo di nodi del livello
640
+ *
641
+ * @returns {number} Variazione dei valori concentrici
642
+ */
643
+ ConcentricLayoutOptionsImpl.prototype.levelWidth = function (nodes) {
644
+ return nodes.maxDegree() / 4;
645
+ };
646
+ return ConcentricLayoutOptionsImpl;
647
+ }());
648
+
649
+ /**
650
+ * Default per l'implementazione dell'algoritmo Cose
651
+ */
652
+ var CoseLayoutOptionsImpl = /** @class */ (function (_super) {
653
+ __extends(CoseLayoutOptionsImpl, _super);
654
+ /** @ignore */
655
+ function CoseLayoutOptionsImpl() {
656
+ var _this = _super.call(this) || this;
657
+ /**
658
+ * Nome dell'algoritmo di layouting
659
+ */
660
+ _this.name = 'cose';
661
+ /**
662
+ * Se **animate** è **true**, l'animazione parte solo dopo questo numero di millisecondi (Evita flickering su animazioni veloci)
663
+ */
664
+ _this.animationThreshold = 250;
665
+ /**
666
+ * Numero di iterazioni fra aggiornamenti consecutivi della posizione a schermo
667
+ */
668
+ _this.refresh = 20;
669
+ /**
670
+ * Se **true** la posizione iniziale dei nodi è casuale, se **false** utilizza la posizione originale
671
+ */
672
+ _this.randomize = false;
673
+ /**
674
+ * Spazio extra fra i componenti di un grafo non-compound
675
+ */
676
+ _this.componentSpacing = 40;
677
+ /**
678
+ * Moltiplicatore della repulsione fra nodi in caso di overlap
679
+ */
680
+ _this.nodeOverlap = 4;
681
+ /**
682
+ * Moltiplicatore di nesting per il calcolo della lunghezza ideale dei collegamenti nested
683
+ */
684
+ _this.nestingFactor = 1.2;
685
+ /**
686
+ * Costante di gravità
687
+ */
688
+ _this.gravity = 1;
689
+ /**
690
+ * Numero massimo di iterazioni da eseguire
691
+ */
692
+ _this.numIter = 1000;
693
+ /**
694
+ * Temperatura iniziale (massima distanza fra i nodi)
695
+ */
696
+ _this.initialTemp = 1000;
697
+ /**
698
+ * Fattore di raffreddamento. Ad ogni iterazione verrà sottratto ad **initialTemp**
699
+ */
700
+ _this.coolingFactor = 0.99;
701
+ /**
702
+ * Soglia minima di temperatura. Una volta raggiunta il layout si considera terminato
703
+ */
704
+ _this.minTemp = 1.0;
705
+ /**
706
+ * Moltiplicatore della repulsione fra nodi in caso di assenza di overlap. Funzione overrideabile per ogni node
707
+ *
708
+ * @param {any} node Nodo
709
+ *
710
+ * @returns {number} Moltiplicazione di repulsione
711
+ */
712
+ _this.nodeRepulsion = function (node) { return 2048; };
713
+ /**
714
+ * Lunghezza ideale dei collegamenti non nested. Funzione overrideabile per ogni collegamento
715
+ *
716
+ * @param {any} edge Collegamento
717
+ *
718
+ * @returns {number} Lunghezza ideale
719
+ */
720
+ _this.idealEdgeLength = function (edge) { return 32; };
721
+ /**
722
+ * Divisore per calcolare le forze applicate ad un collegamento. Funzione overrideabile per ogni collegamento
723
+ *
724
+ * @param {any} edge Collegamento
725
+ *
726
+ * @returns {number} Indice di elasticità
727
+ */
728
+ _this.edgeElasticity = function (edge) { return 32; };
729
+ return _this;
730
+ }
731
+ return CoseLayoutOptionsImpl;
732
+ }(ShapedLayoutOptionsImpl));
733
+
734
+ /**
735
+ * Default per l'implementazione dell'algoritmo Dagre
736
+ */
737
+ var DagreLayoutOptionsImpl = /** @class */ (function (_super) {
738
+ __extends(DagreLayoutOptionsImpl, _super);
739
+ /** @ignore */
740
+ function DagreLayoutOptionsImpl() {
741
+ var _this = _super.call(this) || this;
742
+ /**
743
+ * Nome dell'algoritmo di layouting
744
+ */
745
+ _this.name = 'dagre';
746
+ /**
747
+ * Distanza fra nodi adiacenti dello stesso rango
748
+ */
749
+ _this.nodeSep = null;
750
+ /**
751
+ * Distanza fra collegamenti adiacenti nello stesso rango
752
+ */
753
+ _this.edgeSep = null;
754
+ /**
755
+ * Distanza fra ogni rango
756
+ */
757
+ _this.rankSep = null;
758
+ // TB for top to bottom flow, 'LR' for left to right
759
+ /**
760
+ * Direzione di disegno: LR = Sinistra a Destra, TB = Sopra a Sotto
761
+ */
762
+ _this.rankDir = 'TB';
763
+ /**
764
+ * Algoritmo che si occupa di assegnare un rango ad ogni nodo
765
+ */
766
+ _this.ranker = null;
767
+ /**
768
+ * Numero di ranghi fra la sorgente e la destinazione di un collegamento
769
+ *
770
+ * @param {any} edge Collegamento di cui calcolare la differenza di rango
771
+ *
772
+ * @returns {number} Differenza di rango
773
+ */
774
+ _this.minLen = function (edge) { return 1; };
775
+ /**
776
+ * Peso del collegamento, più è alto più generalmente risulterà corto
777
+ *
778
+ * @param {any} edge Collegamento di cui calcolare il peso
779
+ *
780
+ * @returns {number} Peso
781
+ */
782
+ _this.edgeWeight = function (edge) { return 1; };
783
+ return _this;
784
+ }
785
+ return DagreLayoutOptionsImpl;
786
+ }(ShapedLayoutOptionsImpl));
787
+
788
+ /**
789
+ * Default per l'implementazione dell'algoritmo Grid
790
+ */
791
+ var GridLayoutOptionsImpl = /** @class */ (function (_super) {
792
+ __extends(GridLayoutOptionsImpl, _super);
793
+ /** @ignore */
794
+ function GridLayoutOptionsImpl() {
795
+ var _this = _super.call(this) || this;
796
+ /**
797
+ * Nome dell'algoritmo di layouting
798
+ */
799
+ _this.name = 'grid';
800
+ /**
801
+ * Spazio extra attorno ai nodi quando **avoidOverlap** è **true**
802
+ */
803
+ _this.avoidOverlapPadding = 10;
804
+ /**
805
+ * Se **true** cerca di utilizzare il minor spazio possibile, se **false** usa tutto lo spazio che ha a disposizione
806
+ */
807
+ _this.condense = false;
808
+ /**
809
+ * Forzatura del numero di righe della griglia
810
+ */
811
+ _this.rows = null;
812
+ /**
813
+ * Forzatura del numero di colonne della griglia
814
+ */
815
+ _this.cols = null;
816
+ /**
817
+ * Dato un nodo restituisce un indice di riga e di colonna della griglia in cui metterlo
818
+ *
819
+ * @param {NodeSingular} node Nodo
820
+ * @returns {{ row: number, col: number }} Oggetto che identifica una posizione della griglia
821
+ */
822
+ _this.position = null;
823
+ return _this;
824
+ }
825
+ return GridLayoutOptionsImpl;
826
+ }(ShapedLayoutOptionsImpl));
827
+
828
+ /**
829
+ * Pseudo implementazione di un algoritmo vuoto che non fa nulla
830
+ */
831
+ var NullLayoutOptionsImpl = /** @class */ (function (_super) {
832
+ __extends(NullLayoutOptionsImpl, _super);
833
+ /** @ignore */
834
+ function NullLayoutOptionsImpl() {
835
+ var _this = _super.call(this) || this;
836
+ /**
837
+ * Nome dell'algoritmo di layouting
838
+ */
839
+ _this.name = 'null';
840
+ return _this;
841
+ }
842
+ return NullLayoutOptionsImpl;
843
+ }(BaseLayoutOptionsImpl));
844
+
845
+ /**
846
+ * Default per l'implementazione dell'algoritmo Preset (Posiziona i nodi in base alla loro proprietà **position**)
847
+ */
848
+ var PresetLayoutOptionsImpl = /** @class */ (function (_super) {
849
+ __extends(PresetLayoutOptionsImpl, _super);
850
+ /** @ignore */
851
+ function PresetLayoutOptionsImpl() {
852
+ var _this = _super.call(this) || this;
853
+ /**
854
+ * Nome dell'algoritmo di layouting
855
+ */
856
+ _this.name = 'preset';
857
+ /**
858
+ * Funzione per la trasformazione delle posizioni dei nodi
859
+ *
860
+ * @param {any} node Nodo
861
+ * @param {any} position Posizione iniziale
862
+ *
863
+ * @returns {any} Posizione finale
864
+ */
865
+ _this.transform = function (node, position) { return position; };
866
+ return _this;
867
+ }
868
+ return PresetLayoutOptionsImpl;
869
+ }(AnimateLayoutOptionsImpl));
870
+
871
+ /**
872
+ * Default per l'implementazione dell'algoritmo Random
873
+ */
874
+ var RandomLayoutOptionsImpl = /** @class */ (function (_super) {
875
+ __extends(RandomLayoutOptionsImpl, _super);
876
+ /** @ignore */
877
+ function RandomLayoutOptionsImpl() {
878
+ var _this = _super.call(this) || this;
879
+ /**
880
+ * Nome dell'algoritmo di layouting
881
+ */
882
+ _this.name = 'random';
883
+ /**
884
+ * Indica se adattare al contenitore
885
+ */
886
+ _this.fit = true;
887
+ /**
888
+ * Padding rispetto al contenitore
889
+ */
890
+ _this.padding = 20;
891
+ /**
892
+ * Specifica le dimensioni esatte al cui interno effettuare il layouting, specificato come **{ x1, y1, x2, y2 }** o **{ x1, y1, w, h }**
893
+ */
894
+ _this.boundingBox = null;
895
+ /**
896
+ * Funzione per la trasformazione delle posizioni dei nodi
897
+ *
898
+ * @param {any} node Nodo
899
+ * @param {any} position Posizione iniziale
900
+ *
901
+ * @returns {any} Posizione finale
902
+ */
903
+ _this.transform = function (node, position) { return position; };
904
+ return _this;
905
+ }
906
+ return RandomLayoutOptionsImpl;
907
+ }(AnimateLayoutOptionsImpl));
908
+
909
+ /**
910
+ * Classe di configurazione per il Modulo
911
+ */
912
+ var EsDiagramModuleConfig = /** @class */ (function () {
913
+ function EsDiagramModuleConfig() {
914
+ }
915
+ return EsDiagramModuleConfig;
916
+ }());
917
+
918
+ /**
919
+ * Token che indica la lingua da utilizzare, sono supportate "it-IT" ed "en-US"
920
+ */
921
+ var DIA_LOCALE = new i0.InjectionToken('DIA_LOCALE');
922
+ /**
923
+ * Token che indica se attivare la modalità di debug (messaggi a console)
924
+ */
925
+ var DIA_DEBUG_MODE = new i0.InjectionToken('DIA_DEBUG_MODE');
926
+
927
+ /**
928
+ * Oggetto statico di localizzazione per i messaggi
929
+ */
930
+ var Loc = {
931
+ "Module": { "en-US": "Module", "it-IT": "Il Modulo" },
932
+ "Received an undefined module. Make sure you are correctly loading it": { "en-US": "Received an undefined module. Make sure you are correctly loading it", "it-IT": "Ricevuto modulo non definito. Assicurati di caricarlo correttamente" },
933
+ "Module not available. Loading it now": { "en-US": "Module not available. Loading it now", "it-IT": "Modulo non disponibile. Lo carico ora" },
934
+ "Module already loaded": { "en-US": "Module already loaded", "it-IT": "Modulo già caricato" },
935
+ "Diagram container size has changed, redrawing": { "en-US": "Diagram container size has changed, redrawing", "it-IT": "La dimensione del contenitore del diagramma è cambiata, ridisegno" },
936
+ "Module cannot be loaded": { "en-US": "Module cannot be loaded", "it-IT": "Impossibile caricare il modulo" },
937
+ "Redraw based on dynamic Input change is supported only for 'Elements' and 'Layout' inputs, please destroy the component and recreate it with the new settings": { "en-US": "Redraw based on dynamic Input change is supported only for 'Elements' and 'Layout' inputs, please destroy the component and recreate it with the new settings", "it-IT": "Il cambio e aggiornamento dinamico degli Input è supportato solo per gli Input 'Elements' e 'Layout', distruggi il componente e ricrealo con le nuove impostazioni", },
938
+ "is loaded and managed directly by this library. You don't need to import it or use it directly, just be sure to set the relative options": { "en-US": "is loaded and managed directly by this library. You don't need to import it or use it directly, just be sure to set the relative options", "it-IT": "viene caricato e gestito nativamente dalla libreria. Non c'è bisogno di reimportarlo, né di configurarlo (usare le opzioni specifiche)" },
939
+ "If you don't specify a source and a target for an edge you have to write its id in the format {source}-{target}": { "en-US": "If you don't specify a source and a target for an edge you have to write its id in the format {source}-{target}", "it-IT": "Se non è specificata una sorgente e una destinazione per il collegamento è opportuno scriverne l'id nel formato {sorgente}-{destinazione}" },
940
+ "Elements have been changed after diagram initialization": { "en-US": "Elements have been changed after diagram initialization", "it-IT": "Rilevato un cambio di Elementi dopo l'inizializzazione del Diagramma" },
941
+ "Layout have been changed after diagram initialization": { "en-US": "Layout have been changed after diagram initialization", "it-IT": "Rilevato un cambio di Layout dopo l'inizializzazione del Diagramma" }
942
+ };
943
+
944
+ /** @ignore */ var cytoscape$1 = cy___namespace;
945
+ /**
946
+ * Loader dei moduli di Cytoscape. Utilizza una cache per tenerseli in memoria a livello di applicazione
947
+ * in modo da non dover ricaricare nulla dopo avere usato un modulo almeno una volta
948
+ */
949
+ var EsDiagramService = /** @class */ (function () {
950
+ /**
951
+ * Costruttore
952
+ *
953
+ * @ignore
954
+ */
955
+ function EsDiagramService(DIA_LOCALE, DIA_DEBUG_MODE) {
956
+ this.DIA_LOCALE = DIA_LOCALE;
957
+ this.DIA_DEBUG_MODE = DIA_DEBUG_MODE;
958
+ /**
959
+ * Cache dei moduli caricati
960
+ */
961
+ this.modulesCache = {};
962
+ }
963
+ /**
964
+ * Permette di importare, se serve un dato tema o localizzazione
965
+ *
966
+ * @param {'cytoscape-expand-collapse' | 'cytoscape-cxtmenu' | 'cytoscape-html-node' | 'cytoscape-dagre'} moduleId Nome del modulo di Cytoscape da importare (dev'essere il nome della cartella in node_modules)
967
+ *
968
+ * @returns {Promise<void | cytoscape.Ext>} Funzione di estensione per Cytoscape presa dal modulo richiesto
969
+ */
970
+ EsDiagramService.prototype.importIfNeeded = function (moduleId) {
971
+ return __awaiter(this, void 0, void 0, function () {
972
+ var _a;
973
+ var _this = this;
974
+ return __generator(this, function (_b) {
975
+ switch (_b.label) {
976
+ case 0:
977
+ if (!!this.modulesCache[moduleId]) return [3 /*break*/, 7];
978
+ this.log("I", this.loc("Module not available. Loading it now") + ": " + moduleId, false);
979
+ _a = moduleId;
980
+ switch (_a) {
981
+ case "cytoscape-cxtmenu": return [3 /*break*/, 1];
982
+ case "cytoscape-expand-collapse": return [3 /*break*/, 2];
983
+ case "cytoscape-html-node": return [3 /*break*/, 3];
984
+ case "cytoscape-dagre": return [3 /*break*/, 4];
985
+ }
986
+ return [3 /*break*/, 6];
987
+ case 1: return [2 /*return*/, import('cytoscape-cxtmenu').then(function (module) { return _this.modulesCache[moduleId] = module.default; }).catch(function (err) { return _this.handleError(moduleId, err); })];
988
+ case 2: return [2 /*return*/, import('cytoscape-expand-collapse').then(function (module) { return _this.modulesCache[moduleId] = module.default; }).catch(function (err) { return _this.handleError(moduleId, err); })];
989
+ case 3: return [2 /*return*/, import('@esfaenza/cytoscape-html-node').then(function (module) { return _this.modulesCache[moduleId] = module.register; }).catch(function (err) { return _this.handleError(moduleId, err); })];
990
+ case 4: return [4 /*yield*/, import('dagre').catch(function (err) { return _this.handleError("dagre", err); })];
991
+ case 5:
992
+ _b.sent();
993
+ return [2 /*return*/, import('cytoscape-dagre').then(function (module) { return _this.modulesCache[moduleId] = module.default; }).catch(function (err) { return _this.handleError(moduleId, err); })];
994
+ case 6: return [3 /*break*/, 8];
995
+ case 7:
996
+ // I moduli non devono mai essere ricaricati nel globale, quindi invece che restituire la copia della cache restituisco vuoto
997
+ this.log("I", this.loc("Module already loaded") + ": " + moduleId, false);
998
+ return [2 /*return*/, new Promise(function (resolve) { resolve(null); })];
999
+ case 8: return [2 /*return*/];
1000
+ }
1001
+ });
1002
+ });
1003
+ };
1004
+ /**
1005
+ * Gestione degli errori di caricamento dei moduli qualora qualcuno utilizzasse un modulo non installato
1006
+ *
1007
+ * @param {string} moduleId Nome del modulo che si è cercato di caricare
1008
+ * @param {any} err Errore restituito dalla promise di caricamento
1009
+ */
1010
+ EsDiagramService.prototype.handleError = function (moduleId, err) {
1011
+ this.log("E", this.loc("Module cannot be loaded") + ": " + moduleId + " - " + err, false);
1012
+ };
1013
+ /**
1014
+ * Scrittore di log a console. Attivo solo quando la libreria è in modalità di Debug
1015
+ *
1016
+ * @param {'E' | 'I' | 'W'} severity Tipo di messaggio (Errore, Info, Warning)
1017
+ * @param {string} text Testo da tradurre
1018
+ * @param {boolean} requiresTranslation Indica se **text** è una frase già tradotta o se è da tradurre
1019
+ */
1020
+ EsDiagramService.prototype.log = function (severity, text, requiresTranslation) {
1021
+ if (requiresTranslation === void 0) { requiresTranslation = true; }
1022
+ if (!this.DIA_DEBUG_MODE)
1023
+ return;
1024
+ var message = "@esfaenza/diagrams: " + (requiresTranslation ? this.loc(text) : text);
1025
+ switch (severity) {
1026
+ case 'E':
1027
+ console.error(message);
1028
+ break;
1029
+ case 'I':
1030
+ console.info(message);
1031
+ break;
1032
+ case 'W':
1033
+ console.warn(message);
1034
+ break;
1035
+ }
1036
+ };
1037
+ /**
1038
+ * Metodo di localizzazione dei messaggi
1039
+ *
1040
+ * @param {string} text Messaggio da tradurre
1041
+ *
1042
+ * @returns {string} Messaggio tradotto
1043
+ */
1044
+ EsDiagramService.prototype.loc = function (text) {
1045
+ return Loc[text][this.DIA_LOCALE];
1046
+ };
1047
+ return EsDiagramService;
1048
+ }());
1049
+ EsDiagramService.decorators = [
1050
+ { type: i0.Injectable }
1051
+ ];
1052
+ EsDiagramService.ctorParameters = function () { return [
1053
+ { type: String, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [DIA_LOCALE,] }] },
1054
+ { type: String, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [DIA_DEBUG_MODE,] }] }
1055
+ ]; };
1056
+
1057
+ /**
1058
+ * Classe che si occupa del dispatch delle operazioni di rendering degli oggetti utilizzando una coda
1059
+ */
1060
+ var EsDiagramDispatcher = /** @class */ (function () {
1061
+ /**
1062
+ * @ignore
1063
+ */
1064
+ function EsDiagramDispatcher(logs) {
1065
+ this.logs = logs;
1066
+ /**
1067
+ * Coda di inizializzazioni ancora da eseguire. Quando questa è vuota significa che nessuno sta creando oggetti
1068
+ */
1069
+ this.Initializations = [];
1070
+ /**
1071
+ * Lista degli oggetti inizializzati e attivi in un dato momento (viene registrata la proprietà **name**). Non è possibile registrare due grafici con lo stesso identificativo
1072
+ */
1073
+ this.Initialized = [];
1074
+ }
1075
+ /**
1076
+ * Registra un oggetto da visualizzare insieme alla propria funzione di creazione. Quest'ultima sarà differita fino a che tutti gli oggetti
1077
+ * precedentemente registati non hanno finito la fase di inizializzazione
1078
+ *
1079
+ * @param {string} name Identificativo dell'oggetto da registrare
1080
+ * @param {Function} creationFunction Funzione che fisicamente dovrà occuparsi della creazione dell'oggetto
1081
+ */
1082
+ EsDiagramDispatcher.prototype.register = function (name, creationFunction) {
1083
+ if (this.Initialized.indexOf(name) != -1)
1084
+ throw "Attempting to register a duplicate object '" + name + "'. Make sure the 'name' properties of your diagram are univoque";
1085
+ this.log("DISPATCHER: Registering diagram creation function execution for " + name);
1086
+ this.Initializations.push({ name: name, function: creationFunction });
1087
+ if (this.Initializations.length == 1) {
1088
+ this.log("DISPATCHER: Initial drain started");
1089
+ this.drainInitQueues();
1090
+ }
1091
+ };
1092
+ /**
1093
+ * Deregistra un oggetto presente. Chiamata generalmente al dispose dell'oggetto in questione quando non dev'essere più mostrato nella pagina corrente
1094
+ *
1095
+ * @param {string} name Identificativo dell'oggetto da deregistrare
1096
+ */
1097
+ EsDiagramDispatcher.prototype.deregister = function (name) {
1098
+ var index = this.Initialized.indexOf(name);
1099
+ if (index == -1) {
1100
+ //Questo succede quando si cerca di distruggere l'oggetto mentre sta venendo graficato
1101
+ this.log("DISPATCHER: Registration missing for object " + name + " it was probably destroyed during load");
1102
+ return;
1103
+ }
1104
+ this.log("DISPATCHER: Object deregistered " + name);
1105
+ this.Initialized.splice(index, 1);
1106
+ };
1107
+ /**
1108
+ * Metodo che esegue in maniera sequenziale le funzioni di inizializzazione degli oggetti finché presenti
1109
+ * in modo che nessun oggetto possa essere inizializzato contemporaneamente ad un altro
1110
+ */
1111
+ EsDiagramDispatcher.prototype.drainInitQueues = function () {
1112
+ var _this = this;
1113
+ var toExecute = this.Initializations[0];
1114
+ this.log("DISPATCHER: Executing initialization function for object " + toExecute.name);
1115
+ toExecute.function().then(function () {
1116
+ _this.log("DISPATCHER: initialization for object " + toExecute.name + " is done");
1117
+ _this.Initialized.push(toExecute.name);
1118
+ _this.Initializations.splice(0, 1);
1119
+ if (_this.Initializations.length >= 1) {
1120
+ _this.log("DISPATCHER: Found queued initializations. Continuing");
1121
+ _this.drainInitQueues();
1122
+ }
1123
+ else
1124
+ _this.log("DISPATCHER: queue is over, nothing more to do");
1125
+ });
1126
+ };
1127
+ /**
1128
+ * @ignore
1129
+ */
1130
+ EsDiagramDispatcher.prototype.log = function (text) {
1131
+ if (this.logs)
1132
+ console.log("@esfaenza/es-diagrams: " + text);
1133
+ };
1134
+ return EsDiagramDispatcher;
1135
+ }());
1136
+ EsDiagramDispatcher.decorators = [
1137
+ { type: i0.Injectable }
1138
+ ];
1139
+ EsDiagramDispatcher.ctorParameters = function () { return [
1140
+ { type: Boolean, decorators: [{ type: i0.Inject, args: [DIA_DEBUG_MODE,] }] }
1141
+ ]; };
1142
+
1143
+ // Grabbata felicemente da amcharts, rimuovendo helper interni, cose strane e instupidendola un po':
1144
+ // https://github.com/amcharts/amcharts4/blob/7fbb61e90363a2373e6130800dee06b8a62f3aab/src/.internal/core/utils/ResizeSensor.ts
1145
+ /**
1146
+ * Classe di utilità che tiene d'occhio i cambiamenti di dimensione di un elemento. Un **ResizeSensor** può controllare al massimo un elemento
1147
+ */
1148
+ var ResizeSensor = /** @class */ (function () {
1149
+ /**
1150
+ * Costruttore
1151
+ *
1152
+ * @param {HTMLElement} element Elemento HTML da controllare
1153
+ * @param {Function} callback Callback da chiamare quando le dimensioni di **element** cambiano
1154
+ */
1155
+ function ResizeSensor(element, callback) {
1156
+ /**
1157
+ * Riferimento all'observer nativo
1158
+ */
1159
+ this.observer = null;
1160
+ /**
1161
+ * Indica se questo oggetto è stato distrutto o no
1162
+ */
1163
+ this.Disposed = false;
1164
+ /**
1165
+ * Elemento da controllare e callback da chiamare quando le dimensioni dell'elemento cambiano
1166
+ */
1167
+ this.target = null;
1168
+ this.makeSensor();
1169
+ this.addTarget(element, callback);
1170
+ }
1171
+ /**
1172
+ * Distruttore
1173
+ */
1174
+ ResizeSensor.prototype.dispose = function () {
1175
+ if (!this.Disposed) {
1176
+ this.Disposed = true;
1177
+ this.removeTarget();
1178
+ }
1179
+ };
1180
+ /**
1181
+ * Creazione del sensore che sarà collegato all'elemento da osservare dal metodo **addTarget**
1182
+ */
1183
+ ResizeSensor.prototype.makeSensor = function () {
1184
+ var _this = this;
1185
+ if (typeof ResizeObserver == "undefined")
1186
+ throw "Resize Observer non è definito. Si prega di utilizzare un browser vero";
1187
+ this.observer = new ResizeObserver(function (entries) {
1188
+ for (var i = 0; i < entries.length; ++i) {
1189
+ if (_this.target && _this.target.targetEl === entries[i].target)
1190
+ _this.target.callback();
1191
+ }
1192
+ });
1193
+ };
1194
+ /**
1195
+ * Dice al sensore di osservare l'elemento **targetEl**, richiamando **callback** qualora le dimensioni cambino
1196
+ *
1197
+ * @param {HTMLElement} targetEl Elemento HTML da controllare
1198
+ * @param {Function} callback Callback da chiamare quando le dimensioni di **element** cambiano
1199
+ */
1200
+ ResizeSensor.prototype.addTarget = function (targetEl, callback) {
1201
+ this.observer.observe(targetEl, { box: "content-box" });
1202
+ this.target = { targetEl: targetEl, callback: callback };
1203
+ };
1204
+ /**
1205
+ * Rimuove l'elemento HTML attuale dall'osservazione del **ResizeObserver**
1206
+ */
1207
+ ResizeSensor.prototype.removeTarget = function () {
1208
+ if (!this.target)
1209
+ return;
1210
+ this.observer.unobserve(this.target.targetEl);
1211
+ this.target = null;
1212
+ };
1213
+ return ResizeSensor;
1214
+ }());
1215
+
1216
+ /**
1217
+ * Classe che fornisce metodi reattivi di estensione. Per ora implementato solo uno pseudo-throttle
1218
+ */
1219
+ var ReactiveExtensions = /** @class */ (function () {
1220
+ function ReactiveExtensions() {
1221
+ /**
1222
+ * Cache di tutti i timer in esecuzione
1223
+ */
1224
+ this.executionTimers = {};
1225
+ }
1226
+ /**
1227
+ * Esecuzione deleyata di una funzione. Se viene richiamata nuovamente prima di venire eseguita dopo il delay, il delay viene resettato
1228
+ *
1229
+ * @param {string} id Id per aiutare il servizio a distinguere funzioni con nome uguale chiamate da componenti diversi
1230
+ * @param {Function} func Funzione da chiamare al termine del throttle
1231
+ * @param {number} throttleTime Tempo di throttling in millisecondi
1232
+ */
1233
+ ReactiveExtensions.prototype.throttle = function (id, func, throttleTime) {
1234
+ var _this = this;
1235
+ if (throttleTime === void 0) { throttleTime = 0; }
1236
+ var key = func.name + "_" + id;
1237
+ //Se ho la funzione che vuole eseguire ripulisco quel timeout
1238
+ if (this.executionTimers[key])
1239
+ clearTimeout(this.executionTimers[key]);
1240
+ //Ricreo il timeout per eseguire quella funzione dopo throttleTime millisecondi
1241
+ var executionTimer = setTimeout(function () { func(); _this.executionTimers[key] = null; }, throttleTime);
1242
+ this.executionTimers[key] = executionTimer;
1243
+ };
1244
+ return ReactiveExtensions;
1245
+ }());
1246
+ ReactiveExtensions.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ReactiveExtensions_Factory() { return new ReactiveExtensions(); }, token: ReactiveExtensions, providedIn: "root" });
1247
+ ReactiveExtensions.decorators = [
1248
+ { type: i0.Injectable, args: [{ providedIn: "root" },] }
1249
+ ];
1250
+
1251
+ /** @ignore */ var cytoscape = cy___namespace;
1252
+ /**
1253
+ * Componente che si occupa di graficare un diagramma e di gestirne il ciclo di vita
1254
+ */
1255
+ var EsDiagramComponent = /** @class */ (function () {
1256
+ /**
1257
+ * Costruttore
1258
+ *
1259
+ * @ignore
1260
+ */
1261
+ function EsDiagramComponent(service, dispatcher, exts) {
1262
+ this.service = service;
1263
+ this.dispatcher = dispatcher;
1264
+ this.exts = exts;
1265
+ /**
1266
+ * Nome del diagramma, fondamentale assegnarlo per permettere alla libreria di schedularne la creazione
1267
+ */
1268
+ this.name = "";
1269
+ /**
1270
+ * Indica se utilizzare il menù contestuale a ruota attorno ad ogni nodo
1271
+ */
1272
+ this.UseContextMenu = false;
1273
+ /**
1274
+ * Dice al componente se il diagramma deve utilizzare il sistema di estensione per l'expand e collapse dei gruppi
1275
+ */
1276
+ this.UseExpandCollapse = false;
1277
+ /**
1278
+ * Blocco completo delle opzioni, alternativo all'assegnazione di **Elements**, **NodeStyles**, **EdgeStyles**, e **Layout**.
1279
+ *
1280
+ * Qualora entrambe venissero specificate verrà effettuata un'unione fra queste opzioni e quelle specificate, dando priorità alle specificate
1281
+ */
1282
+ this.NativeOptions = {};
1283
+ /**
1284
+ * Aggiorna automaticamente le dimensioni del diagramma quando cambiano le dimensioni della finestra
1285
+ */
1286
+ this.AutoupdateSize = true;
1287
+ /**
1288
+ * Indica di mantenere la posizione dei nodi qualora venissero cambiati dall'Input **Elements**.
1289
+ *
1290
+ * Se l'ID di un nodo è uguale all'ID di un nodo presente in precedenza, il nuovo nodo ne erediterà la posizione
1291
+ */
1292
+ this.PreserveElementsPosition = true;
1293
+ /**
1294
+ * Qualora venisse modificato l'Input **Elements**, piuttosto che mettere semplicemente il nuovo Elemento in base al Layout precedente, applica anche un'animazione
1295
+ *
1296
+ * Funziona solamente se il **Layout** corrente del diagramma supporta le animazioni
1297
+ */
1298
+ this.AnimateLayoutChanges = true;
1299
+ /**
1300
+ * Periodo di throttle da quando viene effettuato un resize a quando ricalcolare le dimensioni del diagramma.
1301
+ *
1302
+ * Può essere tenuto a 0 (redraw istantaneo) finché non ci sono problemi di prestazioni con eventualmente tanti resize a poca distanza l'uno dall'altro.
1303
+ */
1304
+ this.ResizeThrottleTime = 0;
1305
+ /**
1306
+ * Fornisce il global della libreria (namespace **cytoscape**) e si aspetta che dopo operazioni di importazione
1307
+ * lasciate all'utente vengano aggiunti tutti i moduli desiderati.
1308
+ *
1309
+ * È **fondamentale** che il primo parametro (il nome del modulo) sia uguale a ciò di cui viene fatto il require in modo che la libreria
1310
+ * possa controllare che il modulo importato non sia già stato importato in precedenza
1311
+ *
1312
+ * ## Esempio:
1313
+ *
1314
+ * ```typescript
1315
+ * (global) => {
1316
+ * return import("cytoscape-extension-library").then(module => global.use("cytoscape-extension-library", module.default));
1317
+ *
1318
+ * ...
1319
+ * }
1320
+ * ```
1321
+ */
1322
+ this.ExtensionModulesImporter = null;
1323
+ /**
1324
+ * Fornisce l'istanza attuale di Cytoscape da cui è possibile prendere le librerie di estensione caricate in **ExtensionModulesImporter**
1325
+ * e configurarle in base ai comportamenti specifici
1326
+ *
1327
+ * ## Esempio:
1328
+ *
1329
+ * ```typescript
1330
+ * (cytoscapeCore) => {
1331
+ * // Fare questo lavoro per ogni estensione caricata
1332
+ * let extensionConfiguration = { ... };
1333
+ * let extensionInstance = cytoscapeCore.extensionLibrary(extensionConfiguration);
1334
+ * extensionInstance.doSomethingSpecificToThisExtension();
1335
+ *
1336
+ * ...
1337
+ * }
1338
+ * ```
1339
+ */
1340
+ this.ExtensionModulesApplyer = null;
1341
+ /**
1342
+ * Evento lanciato al click di un nodo, contiene l'oggetto **data** del nodo in questione
1343
+ */
1344
+ this.onNodeClick = new i0.EventEmitter();
1345
+ /**
1346
+ * Indica se il rendering del diagramma è terminato
1347
+ */
1348
+ this.Rendered = false;
1349
+ /**
1350
+ * Api dell'estensione expand-collapse per permettere di effettuare operazioni dall'esterno del diagramma. Vengono valorizzate se **UseExpandCollapse** è **true**
1351
+ */
1352
+ this.ExpandCollapseApi = null;
1353
+ }
1354
+ /**
1355
+ * @ignore
1356
+ *
1357
+ * Angular Pipeline
1358
+ */
1359
+ EsDiagramComponent.prototype.ngAfterViewInit = function () {
1360
+ if (!this.service || !this.dispatcher)
1361
+ throw "Il modulo @esfaenza/diagrams non è stato importato con il forRoot();";
1362
+ this.dispatchLoadChart();
1363
+ };
1364
+ /**
1365
+ * All'onDestroy ripulisco la memoria dal diagramma
1366
+ */
1367
+ EsDiagramComponent.prototype.ngOnDestroy = function () {
1368
+ this.resizeObserver.dispose();
1369
+ this.resizeObserver = null;
1370
+ if (this.cy) {
1371
+ this.service.log("I", "Diagram" + " " + this.name + ": Unloading destroyed diagram", false);
1372
+ this.cy.destroy();
1373
+ this.dispatcher.deregister(this.name);
1374
+ }
1375
+ else
1376
+ this.service.log("I", "Chart " + this.name + ": Unloading uncreated chart component. It probably was a duplicated", false);
1377
+ };
1378
+ /**
1379
+ * Registra il diagramma attuale nel Dispatcher in modo che venga caricato appena possibile
1380
+ */
1381
+ EsDiagramComponent.prototype.dispatchLoadChart = function () {
1382
+ var _this = this;
1383
+ this.dispatcher.register(this.name, function () { return _this.render(); });
1384
+ };
1385
+ /**
1386
+ * @ignore
1387
+ *
1388
+ * Angular Pipeline: Gestione ri-graficazione del diagramma, se possibile
1389
+ */
1390
+ EsDiagramComponent.prototype.ngOnChanges = function (changes) {
1391
+ var toCheck = ["Templates", "UseContextMenu", "ContextMenuOptions", "UseExpandCollapse", "ExpandCollapseOptions", "NodeStyles", "EdgeStyles", "NativeOptions"];
1392
+ if (this.Rendered && toCheck.some(function (t) { return changes[t]; }))
1393
+ this.service.log("W", "Redraw based on dynamic Input change is supported only for 'Elements' and 'Layout' inputs, please destroy the component and recreate it with the new settings");
1394
+ var elementChanges = changes["Elements"];
1395
+ var layoutChanges = changes["Layout"];
1396
+ if (elementChanges && !elementChanges.firstChange) {
1397
+ this.service.log("I", "Elements have been changed after diagram initialization");
1398
+ // Cambiamento agli Elementi: ripulisco gli elementi vecchi, prendo i nuovi, li sistemo e li riassegno.
1399
+ // Se il nuovo Input Elements è roba strana mi limito a ripulire il diagramma
1400
+ // Se cytoscape aveva già degli elementi precedentemente ne prendo le posizioni in modo da ridisegnarli partendo dallo stesso punto (carino per le animazioni)
1401
+ var elements = elementChanges === null || elementChanges === void 0 ? void 0 : elementChanges.currentValue;
1402
+ var previous_elements = this.PreserveElementsPosition ? this.cy.nodes() : null;
1403
+ this.cy.elements().remove();
1404
+ if (elements && elements.length && elements.length > 0) {
1405
+ this.reviewCytoscapeElements(elements, previous_elements);
1406
+ this.cy.add(elements);
1407
+ // Se solo gli elementi cambiano, riapplico il Layout precedente
1408
+ if (!layoutChanges && this.LastLayout) {
1409
+ // Se devo animare le modifche al layout forzo il parametro relativo
1410
+ if (this.AnimateLayoutChanges)
1411
+ this.LastLayout.animate = true;
1412
+ this.cy.layout(this.LastLayout).run();
1413
+ }
1414
+ }
1415
+ }
1416
+ // Se il layout cambia lo applico e me lo salvo come layout precedente per il futuro
1417
+ if (layoutChanges && !layoutChanges.firstChange) {
1418
+ this.service.log("I", "Layout have been changed after diagram initialization");
1419
+ this.LastLayout = JSON.parse(JSON.stringify(layoutChanges.currentValue));
1420
+ this.cy.layout(this.LastLayout).run();
1421
+ }
1422
+ };
1423
+ /**
1424
+ * Effettua il rendering del diagramma
1425
+ */
1426
+ EsDiagramComponent.prototype.render = function () {
1427
+ return __awaiter(this, void 0, void 0, function () {
1428
+ var cyOptions;
1429
+ return __generator(this, function (_a) {
1430
+ switch (_a.label) {
1431
+ case 0:
1432
+ cyOptions = this.getCompletedOptions();
1433
+ this.NodesHierarchy = cyOptions.elements && cyOptions.elements.some(function (t) { return t.data.parent; });
1434
+ // Carico eventuali classi di estensione che servono
1435
+ return [4 /*yield*/, this.performModulesLoading()];
1436
+ case 1:
1437
+ // Carico eventuali classi di estensione che servono
1438
+ _a.sent();
1439
+ // Genero il diagramma
1440
+ this.cy = cytoscape(cyOptions);
1441
+ // Collego gli eventi al componente
1442
+ this.bindCytoscapeEvents();
1443
+ // Utilizzo le classi di estensione caricate precedentemente per fare il resto delle mie operazioni
1444
+ this.performOperationsWithLoadedModules();
1445
+ // Imposto la variabile Rendered a true in modo che se da adesso vengono fatte modifiche che dovrebbero causare un redraw posso accorgermene
1446
+ // e mandare a cagare lo stronzo di turno
1447
+ this.Rendered = true;
1448
+ // Se devo aggiornare in automatico in base alla dimensione del contenitore collego il ResizeObserver
1449
+ if (this.AutoupdateSize)
1450
+ this.listenOnChanges();
1451
+ return [2 /*return*/];
1452
+ }
1453
+ });
1454
+ });
1455
+ };
1456
+ /**
1457
+ * Registra l'ascolto al contenitore del grafico e in caso di modifiche alla dimensione, al massimo una volta ogni 500 millisecondi, lo ridisegna
1458
+ */
1459
+ EsDiagramComponent.prototype.listenOnChanges = function () {
1460
+ var _this = this;
1461
+ this.resizeObserver = new ResizeSensor(this.cyGraph.nativeElement, function () {
1462
+ _this.exts.throttle(_this.name, _this.onContainerSizeChanged.bind(_this), _this.ResizeThrottleTime);
1463
+ });
1464
+ };
1465
+ /**
1466
+ * Funzione che si occupa di gestire il repaint del diagramma
1467
+ */
1468
+ EsDiagramComponent.prototype.onContainerSizeChanged = function () {
1469
+ this.service.log("I", "Diagram container size has changed, redrawing");
1470
+ this.cy.resize();
1471
+ this.cy.fit();
1472
+ };
1473
+ /**
1474
+ * Collega tutti gli eventi che mi possono servire e li espone in output
1475
+ */
1476
+ EsDiagramComponent.prototype.bindCytoscapeEvents = function () {
1477
+ var _this = this;
1478
+ this.cy.bind('click', 'node', function (event) {
1479
+ _this.onNodeClick.emit({ data: event.target.data() });
1480
+ });
1481
+ // Altri eventi...
1482
+ };
1483
+ /**
1484
+ * Metodo che serve per caricare tutte le estensioni della libreria in base a ciò che viene utilizzato
1485
+ */
1486
+ EsDiagramComponent.prototype.performModulesLoading = function () {
1487
+ return __awaiter(this, void 0, void 0, function () {
1488
+ var wrappedCytoscape;
1489
+ var _this = this;
1490
+ return __generator(this, function (_a) {
1491
+ switch (_a.label) {
1492
+ case 0:
1493
+ if (!(this.Layout.name == 'dagre')) return [3 /*break*/, 2];
1494
+ return [4 /*yield*/, this.loadInternal("cytoscape-dagre")];
1495
+ case 1:
1496
+ _a.sent();
1497
+ _a.label = 2;
1498
+ case 2:
1499
+ if (!(this.NodeHTMLTemplates && this.NodeHTMLTemplates.length > 0)) return [3 /*break*/, 4];
1500
+ return [4 /*yield*/, this.loadInternal("cytoscape-html-node")];
1501
+ case 3:
1502
+ _a.sent();
1503
+ _a.label = 4;
1504
+ case 4:
1505
+ if (!this.UseContextMenu) return [3 /*break*/, 6];
1506
+ return [4 /*yield*/, this.loadInternal("cytoscape-cxtmenu")];
1507
+ case 5:
1508
+ _a.sent();
1509
+ _a.label = 6;
1510
+ case 6:
1511
+ if (!(this.NodesHierarchy && this.UseExpandCollapse)) return [3 /*break*/, 8];
1512
+ return [4 /*yield*/, this.loadInternal("cytoscape-expand-collapse")];
1513
+ case 7:
1514
+ _a.sent();
1515
+ _a.label = 8;
1516
+ case 8:
1517
+ if (!this.ExtensionModulesImporter) return [3 /*break*/, 10];
1518
+ wrappedCytoscape = {
1519
+ use: function (moduleName, module) {
1520
+ if (!module)
1521
+ _this.service.log("E", _this.service.loc("Received an undefined module. Make sure you are correctly loading it") + ": " + moduleName, false);
1522
+ if (["cytoscape-dagre", "cytoscape-html-node", "cytoscape-cxtmenu", "cytoscape-expand-collapse"].includes(moduleName))
1523
+ _this.service.log("W", _this.service.loc("Module") + " " + moduleName + " " + _this.service.loc("is loaded and managed directly by this library. You don't need to import it or use it directly, just be sure to set the relative options"), false);
1524
+ else
1525
+ cytoscape.use(module);
1526
+ }
1527
+ };
1528
+ return [4 /*yield*/, this.ExtensionModulesImporter(wrappedCytoscape)];
1529
+ case 9:
1530
+ _a.sent();
1531
+ _a.label = 10;
1532
+ case 10: return [2 /*return*/];
1533
+ }
1534
+ });
1535
+ });
1536
+ };
1537
+ /**
1538
+ * Metodo che serve per caricare tutte le estensioni della libreria in base a ciò che viene utilizzato con le opzioni definite dagli Input
1539
+ */
1540
+ EsDiagramComponent.prototype.performOperationsWithLoadedModules = function () {
1541
+ var anyCy = this.cy;
1542
+ // Utilizzo del layout, lo salvo per poterlo riutilizzare in futuro
1543
+ if (this.Layout) {
1544
+ this.LastLayout = JSON.parse(JSON.stringify(this.Layout));
1545
+ this.cy.layout(this.LastLayout).run();
1546
+ }
1547
+ // Utilizzo dell'HTML node
1548
+ if (this.NodeHTMLTemplates && this.NodeHTMLTemplates.length > 0) {
1549
+ var htmlnode = anyCy.htmlnode();
1550
+ htmlnode.createHtmlNode(cytoscape, this.cy, this.NodeHTMLTemplates);
1551
+ }
1552
+ // Utilizzo del Context Menu
1553
+ if (this.UseContextMenu)
1554
+ anyCy.cxtmenu(this.ContextMenuOptions);
1555
+ // Utilizzo dell'expand collapse solo quando c'è una gerarchia di nodi
1556
+ if (this.NodesHierarchy && this.UseExpandCollapse)
1557
+ this.ExpandCollapseApi = anyCy.expandCollapse(this.ExpandCollapseOptions);
1558
+ // Utilizzo di estensioni extra, implementazione affidata al programmatore
1559
+ if (this.ExtensionModulesApplyer)
1560
+ this.ExtensionModulesApplyer(this.cy);
1561
+ };
1562
+ /**
1563
+ * Metodo interno per il caricamento dei moduli di estensione
1564
+ *
1565
+ * @param {'cytoscape-expand-collapse' | 'cytoscape-cxtmenu' | 'cytoscape-html-node' | 'cytoscape-dagre'} moduleId Modulo da caricare
1566
+ */
1567
+ EsDiagramComponent.prototype.loadInternal = function (moduleId) {
1568
+ return __awaiter(this, void 0, void 0, function () {
1569
+ var toLoad;
1570
+ return __generator(this, function (_a) {
1571
+ switch (_a.label) {
1572
+ case 0: return [4 /*yield*/, this.service.importIfNeeded(moduleId)];
1573
+ case 1:
1574
+ toLoad = _a.sent();
1575
+ if (toLoad)
1576
+ cytoscape.use(toLoad);
1577
+ return [2 /*return*/];
1578
+ }
1579
+ });
1580
+ });
1581
+ };
1582
+ /**
1583
+ * Metodo che basandosi sulle opzioni native eventualmente assegnate le completa con gli Input addizionali
1584
+ *
1585
+ * @returns {cy_.CytoscapeOptions} Opzioni finali unite da Input ed opzioni native
1586
+ */
1587
+ EsDiagramComponent.prototype.getCompletedOptions = function () {
1588
+ var opts = this.NativeOptions || {};
1589
+ opts.container = this.cyGraph.nativeElement;
1590
+ opts.style = opts.style || [];
1591
+ // Per tutte le cose per cui gli Input hanno priorità sovrascrivo gli originali delle opzioni
1592
+ if (this.NodeStyles || this.EdgeStyles) {
1593
+ opts.style = [];
1594
+ if (this.NodeStyles)
1595
+ opts.style.push({ selector: 'node', css: this.NodeStyles });
1596
+ if (this.EdgeStyles)
1597
+ opts.style.push({ selector: 'edge', css: this.EdgeStyles });
1598
+ }
1599
+ if (this.Elements)
1600
+ opts.elements = this.Elements;
1601
+ this.reviewCytoscapeElements(opts.elements);
1602
+ if (this.Layout)
1603
+ opts.layout = this.Layout;
1604
+ if (this.Readonly) {
1605
+ // Questo coso fa effetti strani....
1606
+ //opts.autolock = true;
1607
+ opts.autoungrabify = true;
1608
+ opts.autounselectify = true;
1609
+ opts.boxSelectionEnabled = false;
1610
+ opts.userZoomingEnabled = false;
1611
+ opts.userPanningEnabled = false;
1612
+ }
1613
+ return opts;
1614
+ };
1615
+ /**
1616
+ * Aggiustamenti degli elementi di Cytoscape.
1617
+ *
1618
+ * I nodi non vengono toccati.
1619
+ *
1620
+ * Per ogni edge viene controllato se è specificata una sorgente ed una destinazione, in caso contrario si cerca di dedurli dall'ID
1621
+ *
1622
+ * @param {cytoscape.ElementDefinition[]} elements Elementi da sistemare
1623
+ */
1624
+ EsDiagramComponent.prototype.reviewCytoscapeElements = function (elements, prevPositions) {
1625
+ var hasPreviousPositions = prevPositions && prevPositions.length > 0;
1626
+ var positionCache = {};
1627
+ if (hasPreviousPositions) {
1628
+ for (var i = 0; i < prevPositions.length; i++) {
1629
+ var item = prevPositions[i];
1630
+ if (!positionCache[item.data().id])
1631
+ positionCache[item.data().id] = item.position();
1632
+ }
1633
+ }
1634
+ for (var i = 0; i < elements.length; i++) {
1635
+ var el = elements[i];
1636
+ if (el.group == "edges" && (!el.data.source && !el.data.target)) {
1637
+ if (!el.data.id.includes("-"))
1638
+ this.service.log("E", "If you don't specify a source and a target for an edge you have to write its id in the format {source}-{target}");
1639
+ else {
1640
+ var sourceTarget = el.data.id.split('-');
1641
+ el.data.source = sourceTarget[0].trim();
1642
+ el.data.target = sourceTarget[1].trim();
1643
+ }
1644
+ }
1645
+ if (hasPreviousPositions && el.group == "nodes")
1646
+ el.position = positionCache[el.data.id];
1647
+ }
1648
+ };
1649
+ return EsDiagramComponent;
1650
+ }());
1651
+ EsDiagramComponent.decorators = [
1652
+ { type: i0.Component, args: [{
1653
+ selector: 'es-diagram',
1654
+ template: "<div #graph class=\"graph-wrapper {{name}}\"></div>",
1655
+ styles: [".graph-wrapper{height:100%;width:100%}.html-node-notransition{transition:none!important;transform:none!important}\n"]
1656
+ },] }
1657
+ ];
1658
+ EsDiagramComponent.ctorParameters = function () { return [
1659
+ { type: EsDiagramService, decorators: [{ type: i0.Optional }] },
1660
+ { type: EsDiagramDispatcher, decorators: [{ type: i0.Optional }] },
1661
+ { type: ReactiveExtensions }
1662
+ ]; };
1663
+ EsDiagramComponent.propDecorators = {
1664
+ cyGraph: [{ type: i0.ViewChild, args: ['graph',] }],
1665
+ name: [{ type: i0.Input }],
1666
+ UseContextMenu: [{ type: i0.Input }],
1667
+ ContextMenuOptions: [{ type: i0.Input }],
1668
+ UseExpandCollapse: [{ type: i0.Input }],
1669
+ ExpandCollapseOptions: [{ type: i0.Input }],
1670
+ NativeOptions: [{ type: i0.Input }],
1671
+ Elements: [{ type: i0.Input }],
1672
+ NodeStyles: [{ type: i0.Input }],
1673
+ EdgeStyles: [{ type: i0.Input }],
1674
+ Readonly: [{ type: i0.Input }],
1675
+ AutoupdateSize: [{ type: i0.Input }],
1676
+ PreserveElementsPosition: [{ type: i0.Input }],
1677
+ AnimateLayoutChanges: [{ type: i0.Input }],
1678
+ ResizeThrottleTime: [{ type: i0.Input }],
1679
+ Layout: [{ type: i0.Input }],
1680
+ NodeHTMLTemplates: [{ type: i0.Input }],
1681
+ ExtensionModulesImporter: [{ type: i0.Input }],
1682
+ ExtensionModulesApplyer: [{ type: i0.Input }],
1683
+ onNodeClick: [{ type: i0.Output }]
1684
+ };
1685
+
1686
+ var EsDiagramModule = /** @class */ (function () {
1687
+ function EsDiagramModule() {
1688
+ }
1689
+ EsDiagramModule.forRoot = function (config) {
1690
+ return {
1691
+ ngModule: EsDiagramModule,
1692
+ providers: [
1693
+ EsDiagramService,
1694
+ EsDiagramDispatcher,
1695
+ { provide: DIA_LOCALE, useValue: (config === null || config === void 0 ? void 0 : config.locale) || 'it-IT' },
1696
+ { provide: DIA_DEBUG_MODE, useValue: (config === null || config === void 0 ? void 0 : config.debugMode) || false },
1697
+ ]
1698
+ };
1699
+ };
1700
+ return EsDiagramModule;
1701
+ }());
1702
+ EsDiagramModule.decorators = [
1703
+ { type: i0.NgModule, args: [{
1704
+ declarations: [EsDiagramComponent],
1705
+ imports: [common.CommonModule, forms.FormsModule, forms.ReactiveFormsModule, common.CommonModule],
1706
+ exports: [EsDiagramComponent]
1707
+ },] }
1708
+ ];
1709
+
1710
+ /*
1711
+ * Public API Surface of cytoscape-angular
1712
+ */
1713
+
1714
+ /**
1715
+ * Generated bundle index. Do not edit.
1716
+ */
1717
+
1718
+ exports.BaseLayoutOptionsImpl = BaseLayoutOptionsImpl;
1719
+ exports.BreadthFirstLayoutOptionsImpl = BreadthFirstLayoutOptionsImpl;
1720
+ exports.CircleLayoutOptionsImpl = CircleLayoutOptionsImpl;
1721
+ exports.ConcentricLayoutOptionsImpl = ConcentricLayoutOptionsImpl;
1722
+ exports.ContextMenuCommand = ContextMenuCommand;
1723
+ exports.ContextMenuOptions = ContextMenuOptions;
1724
+ exports.CoseLayoutOptionsImpl = CoseLayoutOptionsImpl;
1725
+ exports.DagreLayoutOptionsImpl = DagreLayoutOptionsImpl;
1726
+ exports.EsDiagramComponent = EsDiagramComponent;
1727
+ exports.EsDiagramModule = EsDiagramModule;
1728
+ exports.EsDiagramModuleConfig = EsDiagramModuleConfig;
1729
+ exports.ExpandCollapseOptions = ExpandCollapseOptions;
1730
+ exports.GridLayoutOptionsImpl = GridLayoutOptionsImpl;
1731
+ exports.NodeHTMLTemplate = NodeHTMLTemplate;
1732
+ exports.NodeTemplate = NodeTemplate;
1733
+ exports.NullLayoutOptionsImpl = NullLayoutOptionsImpl;
1734
+ exports.PresetLayoutOptionsImpl = PresetLayoutOptionsImpl;
1735
+ exports.RandomLayoutOptionsImpl = RandomLayoutOptionsImpl;
1736
+ exports.ShapedLayoutOptionsImpl = ShapedLayoutOptionsImpl;
1737
+ exports.ZoomLevelBasedTemplate = ZoomLevelBasedTemplate;
1738
+ exports.ɵa = AnimateLayoutOptionsImpl;
1739
+ exports.ɵb = EsDiagramService;
1740
+ exports.ɵc = DIA_LOCALE;
1741
+ exports.ɵd = DIA_DEBUG_MODE;
1742
+ exports.ɵe = EsDiagramDispatcher;
1743
+ exports.ɵf = ReactiveExtensions;
1744
+
1745
+ Object.defineProperty(exports, '__esModule', { value: true });
1746
+
1747
+ })));
1748
+ //# sourceMappingURL=esfaenza-es-diagrams.umd.js.map