rete-angular-plugin 2.3.2 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/12/bundles/rete-angular-plugin-ng12.umd.js +1 -0
  2. package/12/bundles/rete-angular-plugin-ng12.umd.js.map +1 -1
  3. package/12/esm2015/presets/classic/components/connection/connection-wrapper.component.js +2 -1
  4. package/12/fesm2015/rete-angular-plugin-ng12.js +1 -0
  5. package/12/fesm2015/rete-angular-plugin-ng12.js.map +1 -1
  6. package/13/esm2020/presets/classic/components/connection/connection-wrapper.component.mjs +2 -1
  7. package/13/fesm2015/rete-angular-plugin-ng13.mjs +1 -0
  8. package/13/fesm2015/rete-angular-plugin-ng13.mjs.map +1 -1
  9. package/13/fesm2020/rete-angular-plugin-ng13.mjs +1 -0
  10. package/13/fesm2020/rete-angular-plugin-ng13.mjs.map +1 -1
  11. package/14/esm2020/presets/classic/components/connection/connection-wrapper.component.mjs +2 -1
  12. package/14/fesm2015/rete-angular-plugin-ng14.mjs +1 -0
  13. package/14/fesm2015/rete-angular-plugin-ng14.mjs.map +1 -1
  14. package/14/fesm2020/rete-angular-plugin-ng14.mjs +1 -0
  15. package/14/fesm2020/rete-angular-plugin-ng14.mjs.map +1 -1
  16. package/15/esm2020/presets/classic/components/connection/connection-wrapper.component.mjs +2 -1
  17. package/15/fesm2015/rete-angular-plugin-ng15.mjs +1 -0
  18. package/15/fesm2015/rete-angular-plugin-ng15.mjs.map +1 -1
  19. package/15/fesm2020/rete-angular-plugin-ng15.mjs +1 -0
  20. package/15/fesm2020/rete-angular-plugin-ng15.mjs.map +1 -1
  21. package/16/esm2022/presets/classic/components/connection/connection-wrapper.component.mjs +2 -1
  22. package/16/fesm2022/rete-angular-plugin-ng16.mjs +1 -0
  23. package/16/fesm2022/rete-angular-plugin-ng16.mjs.map +1 -1
  24. package/17/esm2022/presets/classic/components/connection/connection-wrapper.component.mjs +2 -1
  25. package/17/fesm2022/rete-angular-plugin-ng17.mjs +1 -0
  26. package/17/fesm2022/rete-angular-plugin-ng17.mjs.map +1 -1
  27. package/18/esm2022/presets/classic/components/connection/connection-wrapper.component.mjs +2 -1
  28. package/18/fesm2022/rete-angular-plugin-ng18.mjs +1 -0
  29. package/18/fesm2022/rete-angular-plugin-ng18.mjs.map +1 -1
  30. package/19/fesm2022/rete-angular-plugin-ng19.mjs +1 -0
  31. package/19/fesm2022/rete-angular-plugin-ng19.mjs.map +1 -1
  32. package/20/fesm2022/rete-angular-plugin-ng20.mjs +1560 -0
  33. package/20/fesm2022/rete-angular-plugin-ng20.mjs.map +1 -0
  34. package/20/index.d.ts +553 -0
  35. package/20/package.json +22 -0
  36. package/CHANGELOG.md +14 -0
  37. package/bundles/rete-angular-plugin.umd.js +1 -0
  38. package/bundles/rete-angular-plugin.umd.js.map +1 -1
  39. package/esm2015/presets/classic/components/connection/connection-wrapper.component.js +2 -1
  40. package/fesm2015/rete-angular-plugin.js +1 -0
  41. package/fesm2015/rete-angular-plugin.js.map +1 -1
  42. package/package.json +4 -4
@@ -0,0 +1,1560 @@
1
+ import { getUID, ClassicPreset, Scope } from 'rete';
2
+ import { getDOMSocketPosition, loopConnectionPath, classicConnectionPath } from 'rete-render-utils';
3
+ import * as i0 from '@angular/core';
4
+ import { Directive, Input, Component, HostBinding, HostListener, EventEmitter, Output, NgModule } from '@angular/core';
5
+ import * as i1 from '@angular/common';
6
+ import { CommonModule } from '@angular/common';
7
+ import { BaseAreaPlugin } from 'rete-area-plugin';
8
+ import { createCustomElement } from '@angular/elements';
9
+
10
+ class RefDirective {
11
+ el;
12
+ data;
13
+ emit;
14
+ constructor(el) {
15
+ this.el = el;
16
+ }
17
+ ngOnChanges() {
18
+ this.emit({ type: 'render', data: { ...this.data, element: this.el.nativeElement } });
19
+ }
20
+ ngOnDestroy() {
21
+ this.emit({ type: 'unmount', data: { element: this.el.nativeElement } });
22
+ }
23
+ static ɵfac = function RefDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || RefDirective)(i0.ɵɵdirectiveInject(i0.ElementRef)); };
24
+ static ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: RefDirective, selectors: [["", "refComponent", ""]], inputs: { data: "data", emit: "emit" }, features: [i0.ɵɵNgOnChangesFeature] });
25
+ }
26
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RefDirective, [{
27
+ type: Directive,
28
+ args: [{
29
+ selector: '[refComponent]'
30
+ }]
31
+ }], () => [{ type: i0.ElementRef }], { data: [{
32
+ type: Input
33
+ }], emit: [{
34
+ type: Input
35
+ }] }); })();
36
+
37
+ const _c0$1 = (a0, a1, a2, a3) => ({ type: "socket", side: "output", key: a0, nodeId: a1, payload: a2, seed: a3 });
38
+ const _c1 = a0 => ({ type: "control", payload: a0 });
39
+ const _c2 = (a0, a1, a2, a3) => ({ type: "socket", side: "input", key: a0, nodeId: a1, payload: a2, seed: a3 });
40
+ function NodeComponent_div_2_Template(rf, ctx) { if (rf & 1) {
41
+ i0.ɵɵelementStart(0, "div", 4)(1, "div", 5);
42
+ i0.ɵɵtext(2);
43
+ i0.ɵɵelementEnd();
44
+ i0.ɵɵelement(3, "div", 6);
45
+ i0.ɵɵelementEnd();
46
+ } if (rf & 2) {
47
+ const output_r1 = ctx.$implicit;
48
+ const ctx_r1 = i0.ɵɵnextContext();
49
+ i0.ɵɵattribute("data-testid", "output-" + output_r1.key);
50
+ i0.ɵɵadvance(2);
51
+ i0.ɵɵtextInterpolate(output_r1.value == null ? null : output_r1.value.label);
52
+ i0.ɵɵadvance();
53
+ i0.ɵɵproperty("data", i0.ɵɵpureFunction4(4, _c0$1, output_r1.key, ctx_r1.data.id, output_r1.value == null ? null : output_r1.value.socket, ctx_r1.seed))("emit", ctx_r1.emit);
54
+ } }
55
+ function NodeComponent_div_4_Template(rf, ctx) { if (rf & 1) {
56
+ i0.ɵɵelement(0, "div", 7);
57
+ } if (rf & 2) {
58
+ const control_r3 = ctx.$implicit;
59
+ const ctx_r1 = i0.ɵɵnextContext();
60
+ i0.ɵɵproperty("data", i0.ɵɵpureFunction1(3, _c1, control_r3.value))("emit", ctx_r1.emit);
61
+ i0.ɵɵattribute("data-testid", "control-" + control_r3.key);
62
+ } }
63
+ function NodeComponent_div_6_div_2_Template(rf, ctx) { if (rf & 1) {
64
+ i0.ɵɵelementStart(0, "div", 12);
65
+ i0.ɵɵtext(1);
66
+ i0.ɵɵelementEnd();
67
+ } if (rf & 2) {
68
+ const input_r4 = i0.ɵɵnextContext().$implicit;
69
+ i0.ɵɵadvance();
70
+ i0.ɵɵtextInterpolate(input_r4.value == null ? null : input_r4.value.label);
71
+ } }
72
+ function NodeComponent_div_6_Template(rf, ctx) { if (rf & 1) {
73
+ i0.ɵɵelementStart(0, "div", 8);
74
+ i0.ɵɵelement(1, "div", 9);
75
+ i0.ɵɵtemplate(2, NodeComponent_div_6_div_2_Template, 2, 1, "div", 10);
76
+ i0.ɵɵelement(3, "div", 11);
77
+ i0.ɵɵelementEnd();
78
+ } if (rf & 2) {
79
+ const input_r4 = ctx.$implicit;
80
+ const ctx_r1 = i0.ɵɵnextContext();
81
+ i0.ɵɵattribute("data-testid", "input-" + input_r4.key);
82
+ i0.ɵɵadvance();
83
+ i0.ɵɵproperty("data", i0.ɵɵpureFunction4(8, _c2, input_r4.key, ctx_r1.data.id, input_r4.value == null ? null : input_r4.value.socket, ctx_r1.seed))("emit", ctx_r1.emit);
84
+ i0.ɵɵadvance();
85
+ i0.ɵɵproperty("ngIf", !(input_r4.value == null ? null : input_r4.value.control) || !(input_r4.value == null ? null : input_r4.value.showControl));
86
+ i0.ɵɵadvance();
87
+ i0.ɵɵstyleProp("display", (input_r4.value == null ? null : input_r4.value.control) && (input_r4.value == null ? null : input_r4.value.showControl) ? "" : "none");
88
+ i0.ɵɵproperty("data", i0.ɵɵpureFunction1(13, _c1, input_r4.value == null ? null : input_r4.value.control))("emit", ctx_r1.emit);
89
+ } }
90
+ class NodeComponent {
91
+ cdr;
92
+ data;
93
+ emit;
94
+ rendered;
95
+ seed = 0;
96
+ get width() {
97
+ return this.data.width;
98
+ }
99
+ get height() {
100
+ return this.data.height;
101
+ }
102
+ get selected() {
103
+ return this.data.selected;
104
+ }
105
+ constructor(cdr) {
106
+ this.cdr = cdr;
107
+ this.cdr.detach();
108
+ }
109
+ ngOnChanges() {
110
+ this.cdr.detectChanges();
111
+ requestAnimationFrame(() => this.rendered());
112
+ this.seed++; // force render sockets
113
+ }
114
+ sortByIndex(a, b) {
115
+ const ai = a.value?.index || 0;
116
+ const bi = b.value?.index || 0;
117
+ return ai - bi;
118
+ }
119
+ static ɵfac = function NodeComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || NodeComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
120
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: NodeComponent, selectors: [["ng-component"]], hostAttrs: ["data-testid", "node"], hostVars: 6, hostBindings: function NodeComponent_HostBindings(rf, ctx) { if (rf & 2) {
121
+ i0.ɵɵstyleProp("width", ctx.width, "px")("height", ctx.height, "px");
122
+ i0.ɵɵclassProp("selected", ctx.selected);
123
+ } }, inputs: { data: "data", emit: "emit", rendered: "rendered" }, features: [i0.ɵɵNgOnChangesFeature], decls: 8, vars: 13, consts: [["data-testid", "title", 1, "title"], ["class", "output", 4, "ngFor", "ngForOf"], ["class", "control", "refComponent", "", 3, "data", "emit", 4, "ngFor", "ngForOf"], ["class", "input", 4, "ngFor", "ngForOf"], [1, "output"], ["data-testid", "output-title", 1, "output-title"], ["refComponent", "", "data-testid", "output-socket", 1, "output-socket", 3, "data", "emit"], ["refComponent", "", 1, "control", 3, "data", "emit"], [1, "input"], ["refComponent", "", "data-testid", "input-socket", 1, "input-socket", 3, "data", "emit"], ["class", "input-title", "data-testid", "input-title", 4, "ngIf"], ["refComponent", "", "data-testid", "input-control", 1, "input-control", 3, "data", "emit"], ["data-testid", "input-title", 1, "input-title"]], template: function NodeComponent_Template(rf, ctx) { if (rf & 1) {
124
+ i0.ɵɵelementStart(0, "div", 0);
125
+ i0.ɵɵtext(1);
126
+ i0.ɵɵelementEnd();
127
+ i0.ɵɵtemplate(2, NodeComponent_div_2_Template, 4, 9, "div", 1);
128
+ i0.ɵɵpipe(3, "keyvalue");
129
+ i0.ɵɵtemplate(4, NodeComponent_div_4_Template, 1, 5, "div", 2);
130
+ i0.ɵɵpipe(5, "keyvalue");
131
+ i0.ɵɵtemplate(6, NodeComponent_div_6_Template, 4, 15, "div", 3);
132
+ i0.ɵɵpipe(7, "keyvalue");
133
+ } if (rf & 2) {
134
+ i0.ɵɵadvance();
135
+ i0.ɵɵtextInterpolate(ctx.data.label);
136
+ i0.ɵɵadvance();
137
+ i0.ɵɵproperty("ngForOf", i0.ɵɵpipeBind2(3, 4, ctx.data.outputs, ctx.sortByIndex));
138
+ i0.ɵɵadvance(2);
139
+ i0.ɵɵproperty("ngForOf", i0.ɵɵpipeBind2(5, 7, ctx.data.controls, ctx.sortByIndex));
140
+ i0.ɵɵadvance(2);
141
+ i0.ɵɵproperty("ngForOf", i0.ɵɵpipeBind2(7, 10, ctx.data.inputs, ctx.sortByIndex));
142
+ } }, dependencies: [CommonModule, i1.NgForOf, i1.NgIf, i1.KeyValuePipe, RefDirective], styles: ["[_nghost-%COMP%]{display:block;background:#6e88ffcc;border:2px solid #4e58bf;border-radius:10px;cursor:pointer;box-sizing:border-box;width:180px;height:auto;padding-bottom:6px;position:relative;-webkit-user-select:none;user-select:none;line-height:initial;font-family:Arial}[_nghost-%COMP%]:hover{background:#8299ffcc}.selected[_nghost-%COMP%]{background:#ffd92c;border-color:#e3c000}[_nghost-%COMP%] .title[_ngcontent-%COMP%]{color:#fff;font-family:sans-serif;font-size:18px;padding:8px}[_nghost-%COMP%] .output[_ngcontent-%COMP%]{text-align:right}[_nghost-%COMP%] .input[_ngcontent-%COMP%]{text-align:left}[_nghost-%COMP%] .input-title[_ngcontent-%COMP%], [_nghost-%COMP%] .output-title[_ngcontent-%COMP%]{vertical-align:middle;color:#fff;display:inline-block;font-family:sans-serif;font-size:14px;margin:6px;line-height:24px}[_nghost-%COMP%] .input-title[hidden][_ngcontent-%COMP%], [_nghost-%COMP%] .output-title[hidden][_ngcontent-%COMP%]{display:none}[_nghost-%COMP%] .output-socket[_ngcontent-%COMP%]{text-align:right;margin-right:-18px;display:inline-block}[_nghost-%COMP%] .input-socket[_ngcontent-%COMP%]{text-align:left;margin-left:-18px;display:inline-block}[_nghost-%COMP%] .input-control[_ngcontent-%COMP%]{z-index:1;width:calc(100% - 36px);vertical-align:middle;display:inline-block}[_nghost-%COMP%] .control[_ngcontent-%COMP%]{padding:6px 18px}"] });
143
+ }
144
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NodeComponent, [{
145
+ type: Component,
146
+ args: [{ imports: [CommonModule, RefDirective], host: {
147
+ 'data-testid': 'node'
148
+ }, template: "<div class=\"title\" data-testid=\"title\">{{data.label}}</div>\n<div class=\"output\" *ngFor=\"let output of data.outputs | keyvalue: sortByIndex\" [attr.data-testid]=\"'output-'+output.key\">\n <div class=\"output-title\" data-testid=\"output-title\">{{output.value?.label}}</div>\n <div\n class=\"output-socket\"\n refComponent\n [data]=\"{type: 'socket', side: 'output', key: output.key, nodeId: data.id, payload: output.value?.socket, seed: seed }\"\n [emit]=\"emit\"\n data-testid=\"output-socket\"\n ></div>\n</div>\n<div\n class=\"control\"\n *ngFor=\"let control of data.controls | keyvalue: sortByIndex\"\n refComponent\n [data]=\"{type: 'control', payload: control.value }\"\n [emit]=\"emit\"\n [attr.data-testid]=\"'control-'+control.key\"\n></div>\n<div class=\"input\" *ngFor=\"let input of data.inputs | keyvalue: sortByIndex\" [attr.data-testid]=\"'input-'+input.key\">\n <div\n class=\"input-socket\"\n refComponent\n [data]=\"{type: 'socket', side: 'input', key: input.key, nodeId: data.id, payload: input.value?.socket, seed: seed }\"\n [emit]=\"emit\"\n data-testid=\"input-socket\"\n ></div>\n <div class=\"input-title\" data-testid=\"input-title\" *ngIf=\"!input.value?.control || !input.value?.showControl\">{{input.value?.label}}</div>\n <div\n class=\"input-control\"\n [style.display]=\"input.value?.control && input.value?.showControl ? '' : 'none'\"\n refComponent\n [data]=\"{type: 'control', payload: input.value?.control }\"\n [emit]=\"emit\"\n data-testid=\"input-control\"\n ></div>\n</div>\n", styles: [":host{display:block;background:#6e88ffcc;border:2px solid #4e58bf;border-radius:10px;cursor:pointer;box-sizing:border-box;width:180px;height:auto;padding-bottom:6px;position:relative;-webkit-user-select:none;user-select:none;line-height:initial;font-family:Arial}:host:hover{background:#8299ffcc}:host.selected{background:#ffd92c;border-color:#e3c000}:host .title{color:#fff;font-family:sans-serif;font-size:18px;padding:8px}:host .output{text-align:right}:host .input{text-align:left}:host .input-title,:host .output-title{vertical-align:middle;color:#fff;display:inline-block;font-family:sans-serif;font-size:14px;margin:6px;line-height:24px}:host .input-title[hidden],:host .output-title[hidden]{display:none}:host .output-socket{text-align:right;margin-right:-18px;display:inline-block}:host .input-socket{text-align:left;margin-left:-18px;display:inline-block}:host .input-control{z-index:1;width:calc(100% - 36px);vertical-align:middle;display:inline-block}:host .control{padding:6px 18px}\n"] }]
149
+ }], () => [{ type: i0.ChangeDetectorRef }], { data: [{
150
+ type: Input
151
+ }], emit: [{
152
+ type: Input
153
+ }], rendered: [{
154
+ type: Input
155
+ }], width: [{
156
+ type: HostBinding,
157
+ args: ['style.width.px']
158
+ }], height: [{
159
+ type: HostBinding,
160
+ args: ['style.height.px']
161
+ }], selected: [{
162
+ type: HostBinding,
163
+ args: ['class.selected']
164
+ }] }); })();
165
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(NodeComponent, { className: "NodeComponent", filePath: "presets/classic/components/node/node.component.ts", lineNumber: 20 }); })();
166
+
167
+ class SocketComponent {
168
+ cdr;
169
+ data;
170
+ rendered;
171
+ get title() {
172
+ return this.data.name;
173
+ }
174
+ constructor(cdr) {
175
+ this.cdr = cdr;
176
+ this.cdr.detach();
177
+ }
178
+ ngOnChanges() {
179
+ this.cdr.detectChanges();
180
+ requestAnimationFrame(() => this.rendered());
181
+ }
182
+ static ɵfac = function SocketComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || SocketComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
183
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SocketComponent, selectors: [["ng-component"]], hostVars: 1, hostBindings: function SocketComponent_HostBindings(rf, ctx) { if (rf & 2) {
184
+ i0.ɵɵdomProperty("title", ctx.title);
185
+ } }, inputs: { data: "data", rendered: "rendered" }, features: [i0.ɵɵNgOnChangesFeature], decls: 0, vars: 0, template: function SocketComponent_Template(rf, ctx) { }, styles: ["[_nghost-%COMP%]{display:inline-block;cursor:pointer;border:1px solid white;border-radius:12px;width:24px;height:24px;margin:6px;vertical-align:middle;background:#96b38a;z-index:2;box-sizing:border-box}[_nghost-%COMP%]:hover{border-width:4px}.multiple[_nghost-%COMP%]{border-color:#ff0}.output[_nghost-%COMP%]{margin-right:-12px}.input[_nghost-%COMP%]{margin-left:-12px}"] });
186
+ }
187
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SocketComponent, [{
188
+ type: Component,
189
+ args: [{ template: ``, styles: [":host{display:inline-block;cursor:pointer;border:1px solid white;border-radius:12px;width:24px;height:24px;margin:6px;vertical-align:middle;background:#96b38a;z-index:2;box-sizing:border-box}:host:hover{border-width:4px}:host.multiple{border-color:#ff0}:host.output{margin-right:-12px}:host.input{margin-left:-12px}\n"] }]
190
+ }], () => [{ type: i0.ChangeDetectorRef }], { data: [{
191
+ type: Input
192
+ }], rendered: [{
193
+ type: Input
194
+ }], title: [{
195
+ type: HostBinding,
196
+ args: ['title']
197
+ }] }); })();
198
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(SocketComponent, { className: "SocketComponent", filePath: "presets/classic/components/socket/socket.component.ts", lineNumber: 7 }); })();
199
+
200
+ class ControlComponent {
201
+ cdr;
202
+ data;
203
+ rendered;
204
+ pointerdown(event) {
205
+ event.stopPropagation();
206
+ }
207
+ constructor(cdr) {
208
+ this.cdr = cdr;
209
+ this.cdr.detach();
210
+ }
211
+ ngOnChanges(changes) {
212
+ const seed = changes['seed'];
213
+ const data = changes['data'];
214
+ if ((seed && seed.currentValue !== seed.previousValue)
215
+ || (data && data.currentValue !== data.previousValue)) {
216
+ this.cdr.detectChanges();
217
+ }
218
+ requestAnimationFrame(() => this.rendered());
219
+ }
220
+ onChange(e) {
221
+ const target = e.target;
222
+ const value = (this.data.type === 'number'
223
+ ? +target.value
224
+ : target.value);
225
+ this.data.setValue(value);
226
+ this.cdr.detectChanges();
227
+ }
228
+ static ɵfac = function ControlComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ControlComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
229
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ControlComponent, selectors: [["ng-component"]], hostBindings: function ControlComponent_HostBindings(rf, ctx) { if (rf & 1) {
230
+ i0.ɵɵlistener("pointerdown", function ControlComponent_pointerdown_HostBindingHandler($event) { return ctx.pointerdown($event); });
231
+ } }, inputs: { data: "data", rendered: "rendered" }, features: [i0.ɵɵNgOnChangesFeature], decls: 1, vars: 3, consts: [[3, "input", "value", "readonly", "type"]], template: function ControlComponent_Template(rf, ctx) { if (rf & 1) {
232
+ i0.ɵɵelementStart(0, "input", 0);
233
+ i0.ɵɵlistener("input", function ControlComponent_Template_input_input_0_listener($event) { return ctx.onChange($event); });
234
+ i0.ɵɵelementEnd();
235
+ } if (rf & 2) {
236
+ i0.ɵɵproperty("value", ctx.data.value)("readonly", ctx.data.readonly)("type", ctx.data.type);
237
+ } }, styles: ["input[_ngcontent-%COMP%]{width:100%;border-radius:30px;background-color:#fff;padding:2px 6px;border:1px solid #999;font-size:110%;box-sizing:border-box}"] });
238
+ }
239
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ControlComponent, [{
240
+ type: Component,
241
+ args: [{ template: "<input\n [value]=\"data.value\"\n [readonly]=\"data.readonly\"\n [type]=\"data.type\"\n (input)=\"onChange($event)\"\n/>\n", styles: ["input{width:100%;border-radius:30px;background-color:#fff;padding:2px 6px;border:1px solid #999;font-size:110%;box-sizing:border-box}\n"] }]
242
+ }], () => [{ type: i0.ChangeDetectorRef }], { data: [{
243
+ type: Input
244
+ }], rendered: [{
245
+ type: Input
246
+ }], pointerdown: [{
247
+ type: HostListener,
248
+ args: ['pointerdown', ['$event']]
249
+ }] }); })();
250
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ControlComponent, { className: "ControlComponent", filePath: "presets/classic/components/control/control.component.ts", lineNumber: 8 }); })();
251
+
252
+ class ConnectionComponent {
253
+ data;
254
+ start;
255
+ end;
256
+ path;
257
+ static ɵfac = function ConnectionComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ConnectionComponent)(); };
258
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ConnectionComponent, selectors: [["connection"]], inputs: { data: "data", start: "start", end: "end", path: "path" }, decls: 2, vars: 1, consts: [["data-testid", "connection"]], template: function ConnectionComponent_Template(rf, ctx) { if (rf & 1) {
259
+ i0.ɵɵnamespaceSVG();
260
+ i0.ɵɵelementStart(0, "svg", 0);
261
+ i0.ɵɵelement(1, "path");
262
+ i0.ɵɵelementEnd();
263
+ } if (rf & 2) {
264
+ i0.ɵɵadvance();
265
+ i0.ɵɵattribute("d", ctx.path);
266
+ } }, styles: ["svg[_ngcontent-%COMP%]{overflow:visible!important;position:absolute;pointer-events:none;width:9999px;height:9999px}svg[_ngcontent-%COMP%] path[_ngcontent-%COMP%]{fill:none;stroke-width:5px;stroke:#4682b4;pointer-events:auto}"] });
267
+ }
268
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ConnectionComponent, [{
269
+ type: Component,
270
+ args: [{ selector: 'connection', template: "<svg data-testid=\"connection\">\n <path [attr.d]=\"path\" />\n</svg>\n", styles: ["svg{overflow:visible!important;position:absolute;pointer-events:none;width:9999px;height:9999px}svg path{fill:none;stroke-width:5px;stroke:#4682b4;pointer-events:auto}\n"] }]
271
+ }], null, { data: [{
272
+ type: Input
273
+ }], start: [{
274
+ type: Input
275
+ }], end: [{
276
+ type: Input
277
+ }], path: [{
278
+ type: Input
279
+ }] }); })();
280
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ConnectionComponent, { className: "ConnectionComponent", filePath: "presets/classic/components/connection/connection.component.ts", lineNumber: 12 }); })();
281
+
282
+ class ConnectionWrapperComponent {
283
+ cdr;
284
+ viewContainerRef;
285
+ componentFactoryResolver;
286
+ data;
287
+ start;
288
+ end;
289
+ path;
290
+ rendered;
291
+ connectionComponent;
292
+ ref;
293
+ startOb = null;
294
+ get _start() {
295
+ return 'x' in this.start ? this.start : this.startOb;
296
+ }
297
+ endOb = null;
298
+ get _end() {
299
+ return 'x' in this.end ? this.end : this.endOb;
300
+ }
301
+ _path;
302
+ constructor(cdr, viewContainerRef, componentFactoryResolver) {
303
+ this.cdr = cdr;
304
+ this.viewContainerRef = viewContainerRef;
305
+ this.componentFactoryResolver = componentFactoryResolver;
306
+ this.cdr.detach();
307
+ }
308
+ async ngOnChanges() {
309
+ await this.updatePath();
310
+ requestAnimationFrame(() => this.rendered());
311
+ this.cdr.detectChanges();
312
+ this.update();
313
+ }
314
+ async updatePath() {
315
+ if (this._start && this._end) {
316
+ this._path = await this.path(this._start, this._end);
317
+ }
318
+ }
319
+ ngOnInit() {
320
+ if (typeof this.start === 'function') {
321
+ this.start(async (value) => {
322
+ this.startOb = value;
323
+ await this.updatePath();
324
+ this.cdr.detectChanges();
325
+ this.update();
326
+ });
327
+ }
328
+ if (typeof this.end === 'function') {
329
+ this.end(async (value) => {
330
+ this.endOb = value;
331
+ await this.updatePath();
332
+ this.cdr.detectChanges();
333
+ this.update();
334
+ });
335
+ }
336
+ const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.connectionComponent);
337
+ this.viewContainerRef.clear();
338
+ this.ref = this.viewContainerRef.createComponent(componentFactory);
339
+ this.update();
340
+ }
341
+ update() {
342
+ this.ref.instance.data = this.data;
343
+ this.ref.instance.start = this._start;
344
+ this.ref.instance.end = this._end;
345
+ this.ref.instance.path = this._path;
346
+ this.ref.changeDetectorRef.markForCheck();
347
+ }
348
+ static ɵfac = function ConnectionWrapperComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ConnectionWrapperComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef), i0.ɵɵdirectiveInject(i0.ViewContainerRef), i0.ɵɵdirectiveInject(i0.ComponentFactoryResolver)); };
349
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ConnectionWrapperComponent, selectors: [["ng-component"]], inputs: { data: "data", start: "start", end: "end", path: "path", rendered: "rendered", connectionComponent: "connectionComponent" }, features: [i0.ɵɵNgOnChangesFeature], decls: 0, vars: 0, template: function ConnectionWrapperComponent_Template(rf, ctx) { }, encapsulation: 2 });
350
+ }
351
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ConnectionWrapperComponent, [{
352
+ type: Component,
353
+ args: [{
354
+ template: ''
355
+ }]
356
+ }], () => [{ type: i0.ChangeDetectorRef }, { type: i0.ViewContainerRef }, { type: i0.ComponentFactoryResolver }], { data: [{
357
+ type: Input
358
+ }], start: [{
359
+ type: Input
360
+ }], end: [{
361
+ type: Input
362
+ }], path: [{
363
+ type: Input
364
+ }], rendered: [{
365
+ type: Input
366
+ }], connectionComponent: [{
367
+ type: Input
368
+ }] }); })();
369
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ConnectionWrapperComponent, { className: "ConnectionWrapperComponent", filePath: "presets/classic/components/connection/connection-wrapper.component.ts", lineNumber: 10 }); })();
370
+
371
+ /**
372
+ * Classic preset for rendering nodes, connections, controls and sockets.
373
+ */
374
+ function setup$3(props) {
375
+ const positionWatcher = typeof props?.socketPositionWatcher === 'undefined'
376
+ ? getDOMSocketPosition() // fix Type instantiation is excessively deep and possibly infinite.
377
+ : props?.socketPositionWatcher;
378
+ const { node, connection, socket, control } = props?.customize || {};
379
+ return {
380
+ attach(plugin) {
381
+ positionWatcher.attach(plugin);
382
+ },
383
+ update(context) {
384
+ const data = context.data.payload;
385
+ if (context.data.type === 'connection') {
386
+ const { start, end } = context.data;
387
+ return {
388
+ data,
389
+ ...(start ? { start } : {}),
390
+ ...(end ? { end } : {}),
391
+ };
392
+ }
393
+ return { data };
394
+ },
395
+ mount(context, plugin) {
396
+ const parent = plugin.parentScope();
397
+ const emit = parent.emit.bind(parent);
398
+ const rendered = () => {
399
+ emit({ type: 'rendered', data: context.data });
400
+ };
401
+ if (context.data.type === 'node') {
402
+ const component = node ? node(context.data) : NodeComponent;
403
+ return {
404
+ key: `node-${context.data.payload.id}`,
405
+ component,
406
+ props: {
407
+ data: context.data.payload,
408
+ emit,
409
+ rendered
410
+ }
411
+ };
412
+ }
413
+ if (context.data.type === 'connection') {
414
+ const component = connection ? connection(context.data) : ConnectionComponent;
415
+ const id = context.data.payload.id;
416
+ const { sourceOutput, targetInput, source, target } = context.data.payload;
417
+ const { start, end, payload } = context.data;
418
+ return {
419
+ key: `connection-${id}`,
420
+ component: ConnectionWrapperComponent,
421
+ props: {
422
+ connectionComponent: component,
423
+ data: payload,
424
+ start: start || ((change) => positionWatcher.listen(source, 'output', sourceOutput, change)),
425
+ end: end || ((change) => positionWatcher.listen(target, 'input', targetInput, change)),
426
+ path: async (start, end) => {
427
+ const response = await plugin.emit({ type: 'connectionpath', data: { payload, points: [start, end] } });
428
+ if (!response)
429
+ return '';
430
+ const { path, points } = response.data;
431
+ const curvature = 0.3;
432
+ if (!path && points.length !== 2)
433
+ throw new Error('cannot render connection with a custom number of points');
434
+ if (!path)
435
+ return payload.isLoop
436
+ ? loopConnectionPath(points, curvature, 120)
437
+ : classicConnectionPath(points, curvature);
438
+ return path;
439
+ },
440
+ rendered
441
+ }
442
+ };
443
+ }
444
+ if (context.data.type === 'socket') {
445
+ const component = socket ? socket(context.data) : SocketComponent;
446
+ return {
447
+ key: `socket-${getUID()}`,
448
+ component,
449
+ props: {
450
+ data: context.data.payload,
451
+ rendered
452
+ }
453
+ };
454
+ }
455
+ if (context.data.type === 'control') {
456
+ const component = control
457
+ ? control(context.data)
458
+ : (context.data.payload instanceof ClassicPreset.InputControl
459
+ ? ControlComponent
460
+ : null);
461
+ if (component) {
462
+ return {
463
+ key: `control-${context.data.payload.id}`,
464
+ component,
465
+ props: {
466
+ data: context.data.payload,
467
+ rendered
468
+ }
469
+ };
470
+ }
471
+ return;
472
+ }
473
+ return;
474
+ }
475
+ };
476
+ }
477
+
478
+ var index$4 = /*#__PURE__*/Object.freeze({
479
+ __proto__: null,
480
+ setup: setup$3
481
+ });
482
+
483
+ function debounce(cb) {
484
+ return {
485
+ timeout: null,
486
+ cancel() {
487
+ if (this.timeout) {
488
+ window.clearTimeout(this.timeout);
489
+ this.timeout = null;
490
+ }
491
+ },
492
+ call(delay) {
493
+ this.timeout = window.setTimeout(() => {
494
+ cb();
495
+ }, delay);
496
+ }
497
+ };
498
+ }
499
+
500
+ class ContextMenuSearchComponent {
501
+ value;
502
+ update = new EventEmitter();
503
+ static ɵfac = function ContextMenuSearchComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ContextMenuSearchComponent)(); };
504
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ContextMenuSearchComponent, selectors: [["context-menu-search"]], inputs: { value: "value" }, outputs: { update: "update" }, decls: 1, vars: 1, consts: [["data-testid", "context-menu-search-input", 1, "search", 3, "input", "value"]], template: function ContextMenuSearchComponent_Template(rf, ctx) { if (rf & 1) {
505
+ i0.ɵɵelementStart(0, "input", 0);
506
+ i0.ɵɵlistener("input", function ContextMenuSearchComponent_Template_input_input_0_listener($event) { return ctx.update.emit(($event.target == null ? null : $event.target.value) || ""); });
507
+ i0.ɵɵelementEnd();
508
+ } if (rf & 2) {
509
+ i0.ɵɵproperty("value", ctx.value);
510
+ } }, styles: [".search[_ngcontent-%COMP%]{color:#fff;padding:1px 8px;border:1px solid white;border-radius:10px;font-size:16px;font-family:serif;width:100%;box-sizing:border-box;background:transparent}"] });
511
+ }
512
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ContextMenuSearchComponent, [{
513
+ type: Component,
514
+ args: [{ selector: 'context-menu-search', template: "<input class=\"search\" [value]=\"value\" (input)=\"update.emit($any($event.target)?.value || '')\"\n data-testid=\"context-menu-search-input\" />\n", styles: [".search{color:#fff;padding:1px 8px;border:1px solid white;border-radius:10px;font-size:16px;font-family:serif;width:100%;box-sizing:border-box;background:transparent}\n"] }]
515
+ }], null, { value: [{
516
+ type: Input
517
+ }], update: [{
518
+ type: Output
519
+ }] }); })();
520
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ContextMenuSearchComponent, { className: "ContextMenuSearchComponent", filePath: "presets/context-menu/components/search/search.component.ts", lineNumber: 8 }); })();
521
+
522
+ const _c0 = ["*"];
523
+ function ContextMenuItemComponent_div_1_context_menu_item_1_Template(rf, ctx) { if (rf & 1) {
524
+ const _r1 = i0.ɵɵgetCurrentView();
525
+ i0.ɵɵelementStart(0, "context-menu-item", 3);
526
+ i0.ɵɵlistener("select", function ContextMenuItemComponent_div_1_context_menu_item_1_Template_context_menu_item_select_0_listener() { const item_r2 = i0.ɵɵrestoreView(_r1).$implicit; return i0.ɵɵresetView(item_r2.handler()); })("hide", function ContextMenuItemComponent_div_1_context_menu_item_1_Template_context_menu_item_hide_0_listener() { i0.ɵɵrestoreView(_r1); const ctx_r2 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r2.hide.emit()); });
527
+ i0.ɵɵtext(1);
528
+ i0.ɵɵelementEnd();
529
+ } if (rf & 2) {
530
+ const item_r2 = ctx.$implicit;
531
+ const ctx_r2 = i0.ɵɵnextContext(2);
532
+ i0.ɵɵproperty("delay", ctx_r2.delay);
533
+ i0.ɵɵadvance();
534
+ i0.ɵɵtextInterpolate1(" ", item_r2.label, " ");
535
+ } }
536
+ function ContextMenuItemComponent_div_1_Template(rf, ctx) { if (rf & 1) {
537
+ i0.ɵɵelementStart(0, "div", 1);
538
+ i0.ɵɵtemplate(1, ContextMenuItemComponent_div_1_context_menu_item_1_Template, 2, 2, "context-menu-item", 2);
539
+ i0.ɵɵelementEnd();
540
+ } if (rf & 2) {
541
+ const ctx_r2 = i0.ɵɵnextContext();
542
+ i0.ɵɵadvance();
543
+ i0.ɵɵproperty("ngForOf", ctx_r2.subitems);
544
+ } }
545
+ class ContextMenuItemComponent {
546
+ cdr;
547
+ subitems;
548
+ delay;
549
+ select = new EventEmitter();
550
+ hide = new EventEmitter();
551
+ get block() { return true; }
552
+ get hasSubitems() { return this.subitems; }
553
+ click(event) {
554
+ event.stopPropagation();
555
+ this.select.emit();
556
+ this.hide.emit();
557
+ }
558
+ pointerdown(event) {
559
+ event.stopPropagation();
560
+ }
561
+ wheel(event) {
562
+ event.stopPropagation();
563
+ }
564
+ hideSubitems = debounce(() => {
565
+ this.visibleSubitems = false;
566
+ this.cdr.detectChanges();
567
+ });
568
+ visibleSubitems = false;
569
+ pointerover() {
570
+ this.hideSubitems.cancel();
571
+ this.visibleSubitems = true;
572
+ this.cdr.detectChanges();
573
+ }
574
+ pointerleave() {
575
+ this.hideSubitems.call(this.delay);
576
+ this.cdr.detectChanges();
577
+ }
578
+ constructor(cdr) {
579
+ this.cdr = cdr;
580
+ this.cdr.detach();
581
+ }
582
+ static ɵfac = function ContextMenuItemComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ContextMenuItemComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
583
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ContextMenuItemComponent, selectors: [["context-menu-item"]], hostAttrs: ["data-testid", "context-menu-item"], hostVars: 4, hostBindings: function ContextMenuItemComponent_HostBindings(rf, ctx) { if (rf & 1) {
584
+ i0.ɵɵlistener("click", function ContextMenuItemComponent_click_HostBindingHandler($event) { return ctx.click($event); })("pointerdown", function ContextMenuItemComponent_pointerdown_HostBindingHandler($event) { return ctx.pointerdown($event); })("wheel", function ContextMenuItemComponent_wheel_HostBindingHandler($event) { return ctx.wheel($event); })("pointerover", function ContextMenuItemComponent_pointerover_HostBindingHandler() { return ctx.pointerover(); })("pointerleave", function ContextMenuItemComponent_pointerleave_HostBindingHandler() { return ctx.pointerleave(); });
585
+ } if (rf & 2) {
586
+ i0.ɵɵclassProp("block", ctx.block)("hasSubitems", ctx.hasSubitems);
587
+ } }, inputs: { subitems: "subitems", delay: "delay" }, outputs: { select: "select", hide: "hide" }, ngContentSelectors: _c0, decls: 2, vars: 1, consts: [["class", "subitems", 4, "ngIf"], [1, "subitems"], [3, "delay", "select", "hide", 4, "ngFor", "ngForOf"], [3, "select", "hide", "delay"]], template: function ContextMenuItemComponent_Template(rf, ctx) { if (rf & 1) {
588
+ i0.ɵɵprojectionDef();
589
+ i0.ɵɵprojection(0);
590
+ i0.ɵɵtemplate(1, ContextMenuItemComponent_div_1_Template, 2, 1, "div", 0);
591
+ } if (rf & 2) {
592
+ i0.ɵɵadvance();
593
+ i0.ɵɵproperty("ngIf", ctx.subitems && ctx.visibleSubitems);
594
+ } }, dependencies: [ContextMenuItemComponent, CommonModule, i1.NgForOf, i1.NgIf], styles: ["@charset \"UTF-8\";.hasSubitems[_nghost-%COMP%]:after{content:\"\\25ba\";position:absolute;opacity:.6;right:5px;top:5px;font-family:initial}.subitems[_ngcontent-%COMP%]{position:absolute;top:0;left:100%;width:120px}", ".block[_ngcontent-%COMP%]{display:block;color:#fff;padding:4px;border-bottom:1px solid rgba(69,103,255,.8);background-color:#6e88ffcc;cursor:pointer;width:100%;position:relative}.block[_ngcontent-%COMP%]:first-child{border-top-left-radius:5px;border-top-right-radius:5px}.block[_ngcontent-%COMP%]:last-child{border-bottom-left-radius:5px;border-bottom-right-radius:5px}.block[_ngcontent-%COMP%]:hover{background-color:#8299ffcc}"] });
595
+ }
596
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ContextMenuItemComponent, [{
597
+ type: Component,
598
+ args: [{ imports: [CommonModule], selector: 'context-menu-item', host: {
599
+ 'data-testid': 'context-menu-item'
600
+ }, template: "<ng-content></ng-content>\n<div class=\"subitems\" *ngIf=\"subitems && visibleSubitems\">\n <context-menu-item *ngFor=\"let item of subitems\" [delay]=\"delay\" (select)=\"item.handler()\" (hide)=\"hide.emit()\">\n {{ item.label }}\n </context-menu-item>\n</div>\n", styles: ["@charset \"UTF-8\";:host(.hasSubitems):after{content:\"\\25ba\";position:absolute;opacity:.6;right:5px;top:5px;font-family:initial}.subitems{position:absolute;top:0;left:100%;width:120px}\n", ".block{display:block;color:#fff;padding:4px;border-bottom:1px solid rgba(69,103,255,.8);background-color:#6e88ffcc;cursor:pointer;width:100%;position:relative}.block:first-child{border-top-left-radius:5px;border-top-right-radius:5px}.block:last-child{border-bottom-left-radius:5px;border-bottom-right-radius:5px}.block:hover{background-color:#8299ffcc}\n"] }]
601
+ }], () => [{ type: i0.ChangeDetectorRef }], { subitems: [{
602
+ type: Input
603
+ }], delay: [{
604
+ type: Input
605
+ }], select: [{
606
+ type: Output
607
+ }], hide: [{
608
+ type: Output
609
+ }], block: [{
610
+ type: HostBinding,
611
+ args: ['class.block']
612
+ }], hasSubitems: [{
613
+ type: HostBinding,
614
+ args: ['class.hasSubitems']
615
+ }], click: [{
616
+ type: HostListener,
617
+ args: ['click', ['$event']]
618
+ }], pointerdown: [{
619
+ type: HostListener,
620
+ args: ['pointerdown', ['$event']]
621
+ }], wheel: [{
622
+ type: HostListener,
623
+ args: ['wheel', ['$event']]
624
+ }], pointerover: [{
625
+ type: HostListener,
626
+ args: ['pointerover']
627
+ }], pointerleave: [{
628
+ type: HostListener,
629
+ args: ['pointerleave']
630
+ }] }); })();
631
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ContextMenuItemComponent, { className: "ContextMenuItemComponent", filePath: "presets/context-menu/components/item/item.component.ts", lineNumber: 18 }); })();
632
+
633
+ function ContextMenuComponent_div_0_Template(rf, ctx) { if (rf & 1) {
634
+ const _r1 = i0.ɵɵgetCurrentView();
635
+ i0.ɵɵelementStart(0, "div", 2)(1, "context-menu-search", 3);
636
+ i0.ɵɵlistener("update", function ContextMenuComponent_div_0_Template_context_menu_search_update_1_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.setFilter($event)); });
637
+ i0.ɵɵelementEnd()();
638
+ } if (rf & 2) {
639
+ const ctx_r1 = i0.ɵɵnextContext();
640
+ i0.ɵɵadvance();
641
+ i0.ɵɵproperty("value", ctx_r1.filter);
642
+ } }
643
+ function ContextMenuComponent_context_menu_item_1_Template(rf, ctx) { if (rf & 1) {
644
+ const _r3 = i0.ɵɵgetCurrentView();
645
+ i0.ɵɵelementStart(0, "context-menu-item", 4);
646
+ i0.ɵɵlistener("select", function ContextMenuComponent_context_menu_item_1_Template_context_menu_item_select_0_listener() { const item_r4 = i0.ɵɵrestoreView(_r3).$implicit; return i0.ɵɵresetView(item_r4.handler()); })("hide", function ContextMenuComponent_context_menu_item_1_Template_context_menu_item_hide_0_listener() { i0.ɵɵrestoreView(_r3); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.onHide()); });
647
+ i0.ɵɵtext(1);
648
+ i0.ɵɵelementEnd();
649
+ } if (rf & 2) {
650
+ const item_r4 = ctx.$implicit;
651
+ const ctx_r1 = i0.ɵɵnextContext();
652
+ i0.ɵɵproperty("delay", ctx_r1.delay)("subitems", item_r4.subitems);
653
+ i0.ɵɵadvance();
654
+ i0.ɵɵtextInterpolate1(" ", item_r4.label, "\n");
655
+ } }
656
+ class ContextMenuComponent {
657
+ cdr;
658
+ items;
659
+ delay;
660
+ searchBar;
661
+ onHide;
662
+ rendered;
663
+ filter = '';
664
+ hide = debounce(() => {
665
+ this.onHide();
666
+ this.cdr.detectChanges();
667
+ });
668
+ customAttribute = '';
669
+ pointerover() {
670
+ this.hide.cancel();
671
+ this.cdr.detectChanges();
672
+ }
673
+ pointerleave() {
674
+ this.hide.call(this.delay);
675
+ this.cdr.detectChanges();
676
+ }
677
+ constructor(cdr) {
678
+ this.cdr = cdr;
679
+ this.cdr.detach();
680
+ }
681
+ ngOnChanges() {
682
+ this.cdr.detectChanges();
683
+ requestAnimationFrame(() => this.rendered());
684
+ }
685
+ setFilter(value) {
686
+ this.filter = value;
687
+ this.cdr.detectChanges();
688
+ }
689
+ getItems() {
690
+ const filterRegexp = new RegExp(this.filter, 'i');
691
+ const filteredList = this.items.filter(item => (item.label.match(filterRegexp)));
692
+ return filteredList;
693
+ }
694
+ ngOnDestroy() {
695
+ if (this.hide)
696
+ this.hide.cancel();
697
+ }
698
+ static ɵfac = function ContextMenuComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ContextMenuComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
699
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ContextMenuComponent, selectors: [["ng-component"]], hostAttrs: ["data-testid", "context-menu"], hostVars: 1, hostBindings: function ContextMenuComponent_HostBindings(rf, ctx) { if (rf & 1) {
700
+ i0.ɵɵlistener("mouseover", function ContextMenuComponent_mouseover_HostBindingHandler() { return ctx.pointerover(); })("mouseleave", function ContextMenuComponent_mouseleave_HostBindingHandler() { return ctx.pointerleave(); });
701
+ } if (rf & 2) {
702
+ i0.ɵɵattribute("rete-context-menu", ctx.customAttribute);
703
+ } }, inputs: { items: "items", delay: "delay", searchBar: "searchBar", onHide: "onHide", rendered: "rendered" }, features: [i0.ɵɵNgOnChangesFeature], decls: 2, vars: 2, consts: [["class", "block", 4, "ngIf"], [3, "delay", "subitems", "select", "hide", 4, "ngFor", "ngForOf"], [1, "block"], [3, "update", "value"], [3, "select", "hide", "delay", "subitems"]], template: function ContextMenuComponent_Template(rf, ctx) { if (rf & 1) {
704
+ i0.ɵɵtemplate(0, ContextMenuComponent_div_0_Template, 2, 1, "div", 0)(1, ContextMenuComponent_context_menu_item_1_Template, 2, 3, "context-menu-item", 1);
705
+ } if (rf & 2) {
706
+ i0.ɵɵproperty("ngIf", ctx.searchBar);
707
+ i0.ɵɵadvance();
708
+ i0.ɵɵproperty("ngForOf", ctx.getItems());
709
+ } }, dependencies: [CommonModule, i1.NgForOf, i1.NgIf, ContextMenuSearchComponent, ContextMenuItemComponent], styles: ["[_nghost-%COMP%]{display:block;padding:10px;width:120px;margin-top:-20px;margin-left:-60px}", ".block[_ngcontent-%COMP%]{display:block;color:#fff;padding:4px;border-bottom:1px solid rgba(69,103,255,.8);background-color:#6e88ffcc;cursor:pointer;width:100%;position:relative}.block[_ngcontent-%COMP%]:first-child{border-top-left-radius:5px;border-top-right-radius:5px}.block[_ngcontent-%COMP%]:last-child{border-bottom-left-radius:5px;border-bottom-right-radius:5px}.block[_ngcontent-%COMP%]:hover{background-color:#8299ffcc}"] });
710
+ }
711
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ContextMenuComponent, [{
712
+ type: Component,
713
+ args: [{ imports: [CommonModule, ContextMenuSearchComponent, ContextMenuItemComponent], host: {
714
+ 'data-testid': 'context-menu'
715
+ }, template: "<div class=\"block\" *ngIf=\"searchBar\">\n <context-menu-search [value]=\"filter\" (update)=\"setFilter($event)\"></context-menu-search>\n</div>\n\n<context-menu-item *ngFor=\"let item of getItems()\" [delay]=\"delay\" (select)=\"item.handler()\" [subitems]=\"item.subitems\"\n (hide)=\"onHide()\">\n {{ item.label }}\n</context-menu-item>\n", styles: [":host{display:block;padding:10px;width:120px;margin-top:-20px;margin-left:-60px}\n", ".block{display:block;color:#fff;padding:4px;border-bottom:1px solid rgba(69,103,255,.8);background-color:#6e88ffcc;cursor:pointer;width:100%;position:relative}.block:first-child{border-top-left-radius:5px;border-top-right-radius:5px}.block:last-child{border-bottom-left-radius:5px;border-bottom-right-radius:5px}.block:hover{background-color:#8299ffcc}\n"] }]
716
+ }], () => [{ type: i0.ChangeDetectorRef }], { items: [{
717
+ type: Input
718
+ }], delay: [{
719
+ type: Input
720
+ }], searchBar: [{
721
+ type: Input
722
+ }], onHide: [{
723
+ type: Input
724
+ }], rendered: [{
725
+ type: Input
726
+ }], customAttribute: [{
727
+ type: HostBinding,
728
+ args: ['attr.rete-context-menu']
729
+ }], pointerover: [{
730
+ type: HostListener,
731
+ args: ['mouseover']
732
+ }], pointerleave: [{
733
+ type: HostListener,
734
+ args: ['mouseleave']
735
+ }] }); })();
736
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ContextMenuComponent, { className: "ContextMenuComponent", filePath: "presets/context-menu/components/menu/menu.component.ts", lineNumber: 19 }); })();
737
+
738
+ /**
739
+ * Preset for rendering context menu.
740
+ */
741
+ function setup$2(props) {
742
+ const delay = typeof props?.delay === 'undefined' ? 1000 : props.delay;
743
+ return {
744
+ update(context) {
745
+ if (context.data.type === 'contextmenu') {
746
+ return {
747
+ items: context.data.items,
748
+ delay,
749
+ searchBar: context.data.searchBar,
750
+ onHide: context.data.onHide
751
+ };
752
+ }
753
+ },
754
+ mount(context, plugin) {
755
+ const parent = plugin.parentScope();
756
+ const emit = parent.emit.bind(parent);
757
+ const rendered = () => {
758
+ emit({ type: 'rendered', data: context.data });
759
+ };
760
+ if (context.data.type === 'contextmenu') {
761
+ return {
762
+ key: 'context-menu',
763
+ component: ContextMenuComponent,
764
+ props: {
765
+ items: context.data.items,
766
+ delay,
767
+ searchBar: context.data.searchBar,
768
+ onHide: context.data.onHide,
769
+ rendered
770
+ }
771
+ };
772
+ }
773
+ return null;
774
+ }
775
+ };
776
+ }
777
+
778
+ var index$3 = /*#__PURE__*/Object.freeze({
779
+ __proto__: null,
780
+ setup: setup$2
781
+ });
782
+
783
+ class MiniNodeComponent {
784
+ left;
785
+ top;
786
+ width;
787
+ height;
788
+ get styleLeft() {
789
+ return this.px(this.left);
790
+ }
791
+ get styleTop() {
792
+ return this.px(this.top);
793
+ }
794
+ get styleWidth() {
795
+ return this.px(this.width);
796
+ }
797
+ get styleHeight() {
798
+ return this.px(this.height);
799
+ }
800
+ px(value) {
801
+ return `${value}px`;
802
+ }
803
+ static ɵfac = function MiniNodeComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MiniNodeComponent)(); };
804
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MiniNodeComponent, selectors: [["minimap-mini-node"]], hostAttrs: ["data-testid", "minimap-node"], hostVars: 8, hostBindings: function MiniNodeComponent_HostBindings(rf, ctx) { if (rf & 2) {
805
+ i0.ɵɵstyleProp("left", ctx.styleLeft)("top", ctx.styleTop)("width", ctx.styleWidth)("height", ctx.styleHeight);
806
+ } }, inputs: { left: "left", top: "top", width: "width", height: "height" }, decls: 0, vars: 0, template: function MiniNodeComponent_Template(rf, ctx) { }, styles: ["[_nghost-%COMP%]{display:block;position:absolute;background:#6e88ffcc;border:1px solid rgba(192,206,212,.6)}"] });
807
+ }
808
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MiniNodeComponent, [{
809
+ type: Component,
810
+ args: [{ selector: 'minimap-mini-node', host: {
811
+ 'data-testid': 'minimap-node'
812
+ }, template: "", styles: [":host{display:block;position:absolute;background:#6e88ffcc;border:1px solid rgba(192,206,212,.6)}\n"] }]
813
+ }], null, { left: [{
814
+ type: Input
815
+ }], top: [{
816
+ type: Input
817
+ }], width: [{
818
+ type: Input
819
+ }], height: [{
820
+ type: Input
821
+ }], styleLeft: [{
822
+ type: HostBinding,
823
+ args: ['style.left']
824
+ }], styleTop: [{
825
+ type: HostBinding,
826
+ args: ['style.top']
827
+ }], styleWidth: [{
828
+ type: HostBinding,
829
+ args: ['style.width']
830
+ }], styleHeight: [{
831
+ type: HostBinding,
832
+ args: ['style.height']
833
+ }] }); })();
834
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MiniNodeComponent, { className: "MiniNodeComponent", filePath: "presets/minimap/components/mini-node/mini-node.component.ts", lineNumber: 11 }); })();
835
+
836
+ function useDrag(translate, getPointer) {
837
+ return {
838
+ start(e) {
839
+ let previous = { ...getPointer(e) };
840
+ function move(moveEvent) {
841
+ const current = { ...getPointer(moveEvent) };
842
+ const dx = current.x - previous.x;
843
+ const dy = current.y - previous.y;
844
+ previous = current;
845
+ translate(dx, dy);
846
+ }
847
+ function up() {
848
+ window.removeEventListener('pointermove', move);
849
+ window.removeEventListener('pointerup', up);
850
+ window.removeEventListener('pointercancel', up);
851
+ }
852
+ window.addEventListener('pointermove', move);
853
+ window.addEventListener('pointerup', up);
854
+ window.addEventListener('pointercancel', up);
855
+ }
856
+ };
857
+ }
858
+
859
+ class MiniViewportComponent {
860
+ left;
861
+ top;
862
+ width;
863
+ height;
864
+ containerWidth;
865
+ translate;
866
+ drag = useDrag((dx, dy) => this.onDrag(dx, dy), e => ({ x: e.pageX, y: e.pageY }));
867
+ get styleLeft() {
868
+ return this.px(this.scale(this.left));
869
+ }
870
+ get styleTop() {
871
+ return this.px(this.scale(this.top));
872
+ }
873
+ get styleWidth() {
874
+ return this.px(this.scale(this.width));
875
+ }
876
+ get styleHeight() {
877
+ return this.px(this.scale(this.height));
878
+ }
879
+ pointerdown(event) {
880
+ event.stopPropagation();
881
+ this.drag.start(event);
882
+ }
883
+ px(value) {
884
+ return `${value}px`;
885
+ }
886
+ scale(v) {
887
+ return v * this.containerWidth;
888
+ }
889
+ invert(v) {
890
+ return v / this.containerWidth;
891
+ }
892
+ onDrag(dx, dy) {
893
+ this.translate(this.invert(-dx), this.invert(-dy));
894
+ }
895
+ static ɵfac = function MiniViewportComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MiniViewportComponent)(); };
896
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MiniViewportComponent, selectors: [["minimap-mini-viewport"]], hostAttrs: ["data-testid", "minimap-viewport"], hostVars: 8, hostBindings: function MiniViewportComponent_HostBindings(rf, ctx) { if (rf & 1) {
897
+ i0.ɵɵlistener("pointerdown", function MiniViewportComponent_pointerdown_HostBindingHandler($event) { return ctx.pointerdown($event); });
898
+ } if (rf & 2) {
899
+ i0.ɵɵstyleProp("left", ctx.styleLeft)("top", ctx.styleTop)("width", ctx.styleWidth)("height", ctx.styleHeight);
900
+ } }, inputs: { left: "left", top: "top", width: "width", height: "height", containerWidth: "containerWidth", translate: "translate" }, decls: 0, vars: 0, template: function MiniViewportComponent_Template(rf, ctx) { }, styles: ["[_nghost-%COMP%]{display:block;position:absolute;background:#fffb8052;border:1px solid #ffe52b}"] });
901
+ }
902
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MiniViewportComponent, [{
903
+ type: Component,
904
+ args: [{ selector: 'minimap-mini-viewport', host: {
905
+ 'data-testid': 'minimap-viewport'
906
+ }, template: "", styles: [":host{display:block;position:absolute;background:#fffb8052;border:1px solid #ffe52b}\n"] }]
907
+ }], null, { left: [{
908
+ type: Input
909
+ }], top: [{
910
+ type: Input
911
+ }], width: [{
912
+ type: Input
913
+ }], height: [{
914
+ type: Input
915
+ }], containerWidth: [{
916
+ type: Input
917
+ }], translate: [{
918
+ type: Input
919
+ }], styleLeft: [{
920
+ type: HostBinding,
921
+ args: ['style.left']
922
+ }], styleTop: [{
923
+ type: HostBinding,
924
+ args: ['style.top']
925
+ }], styleWidth: [{
926
+ type: HostBinding,
927
+ args: ['style.width']
928
+ }], styleHeight: [{
929
+ type: HostBinding,
930
+ args: ['style.height']
931
+ }], pointerdown: [{
932
+ type: HostListener,
933
+ args: ['pointerdown', ['$event']]
934
+ }] }); })();
935
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MiniViewportComponent, { className: "MiniViewportComponent", filePath: "presets/minimap/components/mini-viewport/mini-viewport.component.ts", lineNumber: 13 }); })();
936
+
937
+ function MinimapComponent_minimap_mini_node_0_Template(rf, ctx) { if (rf & 1) {
938
+ i0.ɵɵelement(0, "minimap-mini-node", 2);
939
+ } if (rf & 2) {
940
+ const node_r1 = ctx.$implicit;
941
+ const ctx_r1 = i0.ɵɵnextContext();
942
+ i0.ɵɵproperty("left", ctx_r1.scale(node_r1.left))("top", ctx_r1.scale(node_r1.top))("width", ctx_r1.scale(node_r1.width))("height", ctx_r1.scale(node_r1.height));
943
+ } }
944
+ class MinimapComponent {
945
+ el;
946
+ cdr;
947
+ rendered;
948
+ size;
949
+ ratio;
950
+ nodes;
951
+ viewport;
952
+ translate;
953
+ point;
954
+ get width() {
955
+ return this.px(this.size * this.ratio);
956
+ }
957
+ get height() {
958
+ return this.px(this.size);
959
+ }
960
+ pointerdown(event) {
961
+ event.stopPropagation();
962
+ event.preventDefault();
963
+ }
964
+ dblclick(event) {
965
+ event.stopPropagation();
966
+ event.preventDefault();
967
+ if (!this.el.nativeElement)
968
+ return;
969
+ const box = this.el.nativeElement.getBoundingClientRect();
970
+ const x = (event.clientX - box.left) / (this.size * this.ratio);
971
+ const y = (event.clientY - box.top) / (this.size * this.ratio);
972
+ this.point(x, y);
973
+ }
974
+ constructor(el, cdr) {
975
+ this.el = el;
976
+ this.cdr = cdr;
977
+ this.cdr.detach();
978
+ }
979
+ ngOnChanges() {
980
+ this.cdr.detectChanges();
981
+ requestAnimationFrame(() => this.rendered());
982
+ }
983
+ px(value) {
984
+ return `${value}px`;
985
+ }
986
+ scale(value) {
987
+ if (!this.el.nativeElement)
988
+ return 0;
989
+ return value * this.el.nativeElement.clientWidth;
990
+ }
991
+ identifyMiniNode(_, item) {
992
+ return [item.top, item.left].join('_');
993
+ }
994
+ static ɵfac = function MinimapComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MinimapComponent)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
995
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MinimapComponent, selectors: [["ng-component"]], hostAttrs: ["data-testid", "minimap"], hostVars: 4, hostBindings: function MinimapComponent_HostBindings(rf, ctx) { if (rf & 1) {
996
+ i0.ɵɵlistener("pointerdown", function MinimapComponent_pointerdown_HostBindingHandler($event) { return ctx.pointerdown($event); })("dblclick", function MinimapComponent_dblclick_HostBindingHandler($event) { return ctx.dblclick($event); });
997
+ } if (rf & 2) {
998
+ i0.ɵɵstyleProp("width", ctx.width)("height", ctx.height);
999
+ } }, inputs: { rendered: "rendered", size: "size", ratio: "ratio", nodes: "nodes", viewport: "viewport", translate: "translate", point: "point" }, features: [i0.ɵɵNgOnChangesFeature], decls: 2, vars: 8, consts: [[3, "left", "top", "width", "height", 4, "ngFor", "ngForOf", "ngForTrackBy"], [3, "left", "top", "width", "height", "containerWidth", "translate"], [3, "left", "top", "width", "height"]], template: function MinimapComponent_Template(rf, ctx) { if (rf & 1) {
1000
+ i0.ɵɵtemplate(0, MinimapComponent_minimap_mini_node_0_Template, 1, 4, "minimap-mini-node", 0);
1001
+ i0.ɵɵelement(1, "minimap-mini-viewport", 1);
1002
+ } if (rf & 2) {
1003
+ i0.ɵɵproperty("ngForOf", ctx.nodes)("ngForTrackBy", ctx.identifyMiniNode);
1004
+ i0.ɵɵadvance();
1005
+ i0.ɵɵproperty("left", ctx.viewport.left)("top", ctx.viewport.top)("width", ctx.viewport.width)("height", ctx.viewport.height)("containerWidth", ctx.el.nativeElement == null ? null : ctx.el.nativeElement.clientWidth)("translate", ctx.translate);
1006
+ } }, dependencies: [CommonModule, i1.NgForOf, MiniNodeComponent, MiniViewportComponent], styles: ["[_nghost-%COMP%]{position:absolute;right:24px;bottom:24px;background:#e5eaefa6;padding:20px;overflow:hidden;border:1px solid #b1b7ff;border-radius:8px;box-sizing:border-box}"] });
1007
+ }
1008
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MinimapComponent, [{
1009
+ type: Component,
1010
+ args: [{ imports: [CommonModule, MiniNodeComponent, MiniViewportComponent], host: {
1011
+ 'data-testid': 'minimap'
1012
+ }, template: "<minimap-mini-node *ngFor=\"let node of nodes; trackBy: identifyMiniNode\" [left]=\"scale(node.left)\"\n [top]=\"scale(node.top)\" [width]=\"scale(node.width)\" [height]=\"scale(node.height)\">\n\n</minimap-mini-node>\n<minimap-mini-viewport [left]=\"viewport.left\" [top]=\"viewport.top\" [width]=\"viewport.width\" [height]=\"viewport.height\"\n [containerWidth]=\"el.nativeElement?.clientWidth\" [translate]=\"translate\"></minimap-mini-viewport>\n", styles: [":host{position:absolute;right:24px;bottom:24px;background:#e5eaefa6;padding:20px;overflow:hidden;border:1px solid #b1b7ff;border-radius:8px;box-sizing:border-box}\n"] }]
1013
+ }], () => [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }], { rendered: [{
1014
+ type: Input
1015
+ }], size: [{
1016
+ type: Input
1017
+ }], ratio: [{
1018
+ type: Input
1019
+ }], nodes: [{
1020
+ type: Input
1021
+ }], viewport: [{
1022
+ type: Input
1023
+ }], translate: [{
1024
+ type: Input
1025
+ }], point: [{
1026
+ type: Input
1027
+ }], width: [{
1028
+ type: HostBinding,
1029
+ args: ['style.width']
1030
+ }], height: [{
1031
+ type: HostBinding,
1032
+ args: ['style.height']
1033
+ }], pointerdown: [{
1034
+ type: HostListener,
1035
+ args: ['pointerdown', ['$event']]
1036
+ }], dblclick: [{
1037
+ type: HostListener,
1038
+ args: ['dblclick', ['$event']]
1039
+ }] }); })();
1040
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MinimapComponent, { className: "MinimapComponent", filePath: "presets/minimap/components/minimap/minimap.component.ts", lineNumber: 17 }); })();
1041
+
1042
+ /**
1043
+ * Preset for rendering minimap.
1044
+ */
1045
+ function setup$1(props) {
1046
+ return {
1047
+ update(context) {
1048
+ if (context.data.type === 'minimap') {
1049
+ return {
1050
+ nodes: context.data.nodes,
1051
+ size: props?.size || 200,
1052
+ ratio: context.data.ratio,
1053
+ viewport: context.data.viewport,
1054
+ translate: context.data.translate,
1055
+ point: context.data.point
1056
+ };
1057
+ }
1058
+ return null;
1059
+ },
1060
+ mount(context, plugin) {
1061
+ const parent = plugin.parentScope();
1062
+ const emit = parent.emit.bind(parent);
1063
+ const rendered = () => {
1064
+ emit({ type: 'rendered', data: context.data });
1065
+ };
1066
+ if (context.data.type === 'minimap') {
1067
+ return {
1068
+ key: 'rete-minimap',
1069
+ component: MinimapComponent,
1070
+ props: {
1071
+ nodes: context.data.nodes,
1072
+ size: props?.size || 200,
1073
+ ratio: context.data.ratio,
1074
+ viewport: context.data.viewport,
1075
+ translate: context.data.translate,
1076
+ point: context.data.point,
1077
+ rendered
1078
+ }
1079
+ };
1080
+ }
1081
+ return null;
1082
+ }
1083
+ };
1084
+ }
1085
+
1086
+ var index$2 = /*#__PURE__*/Object.freeze({
1087
+ __proto__: null,
1088
+ setup: setup$1
1089
+ });
1090
+
1091
+ const pinSize = 20;
1092
+ class PinComponent {
1093
+ cdr;
1094
+ position;
1095
+ selected;
1096
+ getPointer;
1097
+ menu = new EventEmitter();
1098
+ translate = new EventEmitter();
1099
+ down = new EventEmitter();
1100
+ drag = useDrag((dx, dy) => {
1101
+ this.translate.emit({ dx, dy });
1102
+ }, () => this.getPointer());
1103
+ get _selected() {
1104
+ return this.selected;
1105
+ }
1106
+ get top() {
1107
+ return `${this.position.y - pinSize / 2}px`;
1108
+ }
1109
+ get left() {
1110
+ return `${this.position.x - pinSize / 2}px`;
1111
+ }
1112
+ pointerdown(event) {
1113
+ event.stopPropagation();
1114
+ event.preventDefault();
1115
+ this.drag.start(event);
1116
+ this.down.emit();
1117
+ }
1118
+ contextmenu(event) {
1119
+ event.stopPropagation();
1120
+ event.preventDefault();
1121
+ this.menu.emit();
1122
+ }
1123
+ constructor(cdr) {
1124
+ this.cdr = cdr;
1125
+ // this.cdr.detach()
1126
+ }
1127
+ ngOnChanges() {
1128
+ // this.cdr.detectChanges()
1129
+ // requestAnimationFrame(() => this.rendered())
1130
+ }
1131
+ static ɵfac = function PinComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PinComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
1132
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PinComponent, selectors: [["reroute-pin"]], hostAttrs: ["data-testid", "pin"], hostVars: 6, hostBindings: function PinComponent_HostBindings(rf, ctx) { if (rf & 1) {
1133
+ i0.ɵɵlistener("pointerdown", function PinComponent_pointerdown_HostBindingHandler($event) { return ctx.pointerdown($event); })("contextmenu", function PinComponent_contextmenu_HostBindingHandler($event) { return ctx.contextmenu($event); });
1134
+ } if (rf & 2) {
1135
+ i0.ɵɵstyleProp("top", ctx.top)("left", ctx.left);
1136
+ i0.ɵɵclassProp("selected", ctx._selected);
1137
+ } }, inputs: { position: "position", selected: "selected", getPointer: "getPointer" }, outputs: { menu: "menu", translate: "translate", down: "down" }, features: [i0.ɵɵNgOnChangesFeature], decls: 0, vars: 0, template: function PinComponent_Template(rf, ctx) { }, styles: ["[_nghost-%COMP%]{display:block;width:20px;height:20px;box-sizing:border-box;background:#4682b4;border:2px solid white;border-radius:20px;position:absolute}.selected[_nghost-%COMP%]{background:#ffd92c}"] });
1138
+ }
1139
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PinComponent, [{
1140
+ type: Component,
1141
+ args: [{ selector: 'reroute-pin', template: '', host: {
1142
+ 'data-testid': 'pin'
1143
+ }, styles: [":host{display:block;width:20px;height:20px;box-sizing:border-box;background:#4682b4;border:2px solid white;border-radius:20px;position:absolute}:host.selected{background:#ffd92c}\n"] }]
1144
+ }], () => [{ type: i0.ChangeDetectorRef }], { position: [{
1145
+ type: Input
1146
+ }], selected: [{
1147
+ type: Input
1148
+ }], getPointer: [{
1149
+ type: Input
1150
+ }], menu: [{
1151
+ type: Output
1152
+ }], translate: [{
1153
+ type: Output
1154
+ }], down: [{
1155
+ type: Output
1156
+ }], _selected: [{
1157
+ type: HostBinding,
1158
+ args: ['class.selected']
1159
+ }], top: [{
1160
+ type: HostBinding,
1161
+ args: ['style.top']
1162
+ }], left: [{
1163
+ type: HostBinding,
1164
+ args: ['style.left']
1165
+ }], pointerdown: [{
1166
+ type: HostListener,
1167
+ args: ['pointerdown', ['$event']]
1168
+ }], contextmenu: [{
1169
+ type: HostListener,
1170
+ args: ['contextmenu', ['$event']]
1171
+ }] }); })();
1172
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PinComponent, { className: "PinComponent", filePath: "presets/reroute/components/pin/pin.component.ts", lineNumber: 15 }); })();
1173
+
1174
+ function PinsComponent_reroute_pin_0_Template(rf, ctx) { if (rf & 1) {
1175
+ const _r1 = i0.ɵɵgetCurrentView();
1176
+ i0.ɵɵelementStart(0, "reroute-pin", 1);
1177
+ i0.ɵɵlistener("menu", function PinsComponent_reroute_pin_0_Template_reroute_pin_menu_0_listener() { const pin_r2 = i0.ɵɵrestoreView(_r1).$implicit; const ctx_r2 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r2.menu && ctx_r2.menu(pin_r2.id)); })("translate", function PinsComponent_reroute_pin_0_Template_reroute_pin_translate_0_listener($event) { const pin_r2 = i0.ɵɵrestoreView(_r1).$implicit; const ctx_r2 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r2.translate && ctx_r2.translate(pin_r2.id, $event.dx, $event.dy)); })("down", function PinsComponent_reroute_pin_0_Template_reroute_pin_down_0_listener() { const pin_r2 = i0.ɵɵrestoreView(_r1).$implicit; const ctx_r2 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r2.down && ctx_r2.down(pin_r2.id)); });
1178
+ i0.ɵɵelementEnd();
1179
+ } if (rf & 2) {
1180
+ const pin_r2 = ctx.$implicit;
1181
+ const ctx_r2 = i0.ɵɵnextContext();
1182
+ i0.ɵɵproperty("position", pin_r2.position)("selected", pin_r2.selected)("getPointer", ctx_r2.getPointer);
1183
+ } }
1184
+ class PinsComponent {
1185
+ cdr;
1186
+ rendered;
1187
+ pins;
1188
+ down;
1189
+ translate;
1190
+ menu;
1191
+ getPointer;
1192
+ constructor(cdr) {
1193
+ this.cdr = cdr;
1194
+ this.cdr.detach();
1195
+ }
1196
+ ngOnChanges() {
1197
+ this.cdr.detectChanges();
1198
+ requestAnimationFrame(() => this.rendered());
1199
+ }
1200
+ track(_, item) {
1201
+ return item.id;
1202
+ }
1203
+ static ɵfac = function PinsComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PinsComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
1204
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PinsComponent, selectors: [["ng-component"]], inputs: { rendered: "rendered", pins: "pins", down: "down", translate: "translate", menu: "menu", getPointer: "getPointer" }, features: [i0.ɵɵNgOnChangesFeature], decls: 1, vars: 2, consts: [[3, "position", "selected", "getPointer", "menu", "translate", "down", 4, "ngFor", "ngForOf", "ngForTrackBy"], [3, "menu", "translate", "down", "position", "selected", "getPointer"]], template: function PinsComponent_Template(rf, ctx) { if (rf & 1) {
1205
+ i0.ɵɵtemplate(0, PinsComponent_reroute_pin_0_Template, 1, 3, "reroute-pin", 0);
1206
+ } if (rf & 2) {
1207
+ i0.ɵɵproperty("ngForOf", ctx.pins)("ngForTrackBy", ctx.track);
1208
+ } }, dependencies: [CommonModule, i1.NgForOf, PinComponent], encapsulation: 2 });
1209
+ }
1210
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PinsComponent, [{
1211
+ type: Component,
1212
+ args: [{ imports: [CommonModule, PinComponent], template: "<reroute-pin *ngFor=\"let pin of pins; trackBy: track\" [position]=\"pin.position\" [selected]=\"pin.selected\"\n (menu)=\"menu && menu(pin.id)\" (translate)=\"translate && translate(pin.id, $event.dx, $event.dy)\"\n (down)=\"down && down(pin.id)\" [getPointer]=\"getPointer\"></reroute-pin>\n" }]
1213
+ }], () => [{ type: i0.ChangeDetectorRef }], { rendered: [{
1214
+ type: Input
1215
+ }], pins: [{
1216
+ type: Input
1217
+ }], down: [{
1218
+ type: Input
1219
+ }], translate: [{
1220
+ type: Input
1221
+ }], menu: [{
1222
+ type: Input
1223
+ }], getPointer: [{
1224
+ type: Input
1225
+ }] }); })();
1226
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PinsComponent, { className: "PinsComponent", filePath: "presets/reroute/components/pins/pins.component.ts", lineNumber: 12 }); })();
1227
+
1228
+ /**
1229
+ * Preset for rendering pins.
1230
+ */
1231
+ function setup(props) {
1232
+ const getProps = () => ({
1233
+ menu: props?.contextMenu || (() => null),
1234
+ translate: props?.translate || (() => null),
1235
+ down: props?.pointerdown || (() => null)
1236
+ });
1237
+ return {
1238
+ update(context) {
1239
+ if (context.data.type === 'reroute-pins') {
1240
+ return {
1241
+ ...getProps(),
1242
+ pins: context.data.data.pins
1243
+ };
1244
+ }
1245
+ return null;
1246
+ },
1247
+ mount(context, plugin) {
1248
+ const area = plugin.parentScope(BaseAreaPlugin);
1249
+ const rendered = () => {
1250
+ area.emit({ type: 'rendered', data: context.data });
1251
+ };
1252
+ if (context.data.type === 'reroute-pins') {
1253
+ return {
1254
+ key: 'rete-reroute',
1255
+ component: PinsComponent,
1256
+ props: {
1257
+ ...getProps(),
1258
+ pins: context.data.data.pins,
1259
+ rendered,
1260
+ getPointer: () => area.area.pointer
1261
+ }
1262
+ };
1263
+ }
1264
+ return null;
1265
+ }
1266
+ };
1267
+ }
1268
+
1269
+ var index$1 = /*#__PURE__*/Object.freeze({
1270
+ __proto__: null,
1271
+ setup: setup
1272
+ });
1273
+
1274
+ /**
1275
+ * Built-in presets, responsible for rendering different parts of the editor.
1276
+ * @module
1277
+ */
1278
+
1279
+ var index = /*#__PURE__*/Object.freeze({
1280
+ __proto__: null,
1281
+ classic: index$4,
1282
+ contextMenu: index$3,
1283
+ minimap: index$2,
1284
+ reroute: index$1
1285
+ });
1286
+
1287
+ class ReteModule {
1288
+ static ɵfac = function ReteModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ReteModule)(); };
1289
+ static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ReteModule });
1290
+ static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
1291
+ NodeComponent] });
1292
+ }
1293
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ReteModule, [{
1294
+ type: NgModule,
1295
+ args: [{
1296
+ imports: [
1297
+ CommonModule,
1298
+ RefDirective,
1299
+ NodeComponent,
1300
+ ConnectionComponent,
1301
+ ConnectionWrapperComponent,
1302
+ SocketComponent,
1303
+ ControlComponent
1304
+ ],
1305
+ exports: [
1306
+ RefDirective,
1307
+ NodeComponent,
1308
+ ConnectionComponent,
1309
+ ConnectionWrapperComponent,
1310
+ SocketComponent,
1311
+ ControlComponent
1312
+ ]
1313
+ }]
1314
+ }], null, null); })();
1315
+ (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ReteModule, { imports: [CommonModule,
1316
+ RefDirective,
1317
+ NodeComponent,
1318
+ ConnectionComponent,
1319
+ ConnectionWrapperComponent,
1320
+ SocketComponent,
1321
+ ControlComponent], exports: [RefDirective,
1322
+ NodeComponent,
1323
+ ConnectionComponent,
1324
+ ConnectionWrapperComponent,
1325
+ SocketComponent,
1326
+ ControlComponent] }); })();
1327
+
1328
+ class ReteContextMenuModule {
1329
+ static ɵfac = function ReteContextMenuModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ReteContextMenuModule)(); };
1330
+ static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ReteContextMenuModule });
1331
+ static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
1332
+ ContextMenuComponent,
1333
+ ContextMenuItemComponent] });
1334
+ }
1335
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ReteContextMenuModule, [{
1336
+ type: NgModule,
1337
+ args: [{
1338
+ imports: [
1339
+ CommonModule,
1340
+ ContextMenuComponent,
1341
+ ContextMenuSearchComponent,
1342
+ ContextMenuItemComponent
1343
+ ],
1344
+ exports: [
1345
+ ContextMenuComponent,
1346
+ ContextMenuSearchComponent,
1347
+ ContextMenuItemComponent,
1348
+ ]
1349
+ }]
1350
+ }], null, null); })();
1351
+ (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ReteContextMenuModule, { imports: [CommonModule,
1352
+ ContextMenuComponent,
1353
+ ContextMenuSearchComponent,
1354
+ ContextMenuItemComponent], exports: [ContextMenuComponent,
1355
+ ContextMenuSearchComponent,
1356
+ ContextMenuItemComponent] }); })();
1357
+
1358
+ class ReteMinimapModule {
1359
+ static ɵfac = function ReteMinimapModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ReteMinimapModule)(); };
1360
+ static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ReteMinimapModule });
1361
+ static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
1362
+ MinimapComponent] });
1363
+ }
1364
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ReteMinimapModule, [{
1365
+ type: NgModule,
1366
+ args: [{
1367
+ imports: [
1368
+ CommonModule,
1369
+ MinimapComponent,
1370
+ MiniViewportComponent,
1371
+ MiniNodeComponent
1372
+ ],
1373
+ exports: [
1374
+ MinimapComponent,
1375
+ MiniViewportComponent,
1376
+ MiniNodeComponent
1377
+ ]
1378
+ }]
1379
+ }], null, null); })();
1380
+ (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ReteMinimapModule, { imports: [CommonModule,
1381
+ MinimapComponent,
1382
+ MiniViewportComponent,
1383
+ MiniNodeComponent], exports: [MinimapComponent,
1384
+ MiniViewportComponent,
1385
+ MiniNodeComponent] }); })();
1386
+
1387
+ class ReteRerouteModule {
1388
+ static ɵfac = function ReteRerouteModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ReteRerouteModule)(); };
1389
+ static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ReteRerouteModule });
1390
+ static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
1391
+ PinsComponent] });
1392
+ }
1393
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ReteRerouteModule, [{
1394
+ type: NgModule,
1395
+ args: [{
1396
+ imports: [
1397
+ CommonModule,
1398
+ PinsComponent,
1399
+ PinComponent,
1400
+ ],
1401
+ exports: [
1402
+ PinsComponent,
1403
+ PinComponent,
1404
+ ]
1405
+ }]
1406
+ }], null, null); })();
1407
+ (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ReteRerouteModule, { imports: [CommonModule,
1408
+ PinsComponent,
1409
+ PinComponent], exports: [PinsComponent,
1410
+ PinComponent] }); })();
1411
+
1412
+ function reflect(obj) {
1413
+ if (typeof obj !== 'object' || obj === null) {
1414
+ return obj;
1415
+ }
1416
+ return new Proxy(obj, {
1417
+ get(target, prop) {
1418
+ return target[prop];
1419
+ },
1420
+ set(target, prop, value) {
1421
+ target[prop] = value;
1422
+ return true;
1423
+ },
1424
+ has: (target, prop) => prop in target,
1425
+ deleteProperty: (target, prop) => delete target[prop],
1426
+ ownKeys: target => Reflect.ownKeys(target)
1427
+ });
1428
+ }
1429
+
1430
+ function getRenderer() {
1431
+ const elements = new WeakMap();
1432
+ return {
1433
+ get(element) {
1434
+ return elements.get(element);
1435
+ },
1436
+ mount(element, key, component, injector, props) {
1437
+ // LIMITATION: If an element is remounted with the same identifier, the component cannot be replaced
1438
+ let CustomElement = customElements.get(key);
1439
+ if (!CustomElement) {
1440
+ CustomElement = createCustomElement(component, { injector });
1441
+ customElements.define(key, CustomElement);
1442
+ }
1443
+ const ngElement = new CustomElement(injector);
1444
+ Object.keys(props).forEach(key => {
1445
+ ngElement[key] = props[key];
1446
+ });
1447
+ element.appendChild(ngElement);
1448
+ elements.set(element, { key, ngElement });
1449
+ },
1450
+ update({ ngElement }, props) {
1451
+ Object.keys(props).forEach(key => {
1452
+ ngElement.ngElementStrategy.setInputValue(key, reflect(props[key]));
1453
+ });
1454
+ },
1455
+ unmount(element) {
1456
+ const existing = elements.get(element);
1457
+ if (existing) {
1458
+ existing.ngElement.remove();
1459
+ elements.delete(element);
1460
+ }
1461
+ }
1462
+ };
1463
+ }
1464
+ /**
1465
+ * Angular plugin. Renders nodes, connections and other elements using React.
1466
+ * @priority 9
1467
+ * @emits connectionpath
1468
+ * @listens render
1469
+ * @listens unmount
1470
+ */
1471
+ class AngularPlugin extends Scope {
1472
+ params;
1473
+ presets = [];
1474
+ renderer;
1475
+ owners = new WeakMap();
1476
+ /**
1477
+ * @constructor
1478
+ * @param params Plugin properties
1479
+ * @param params.injector Angular's Injector instance
1480
+ */
1481
+ constructor(params) {
1482
+ super('angular-render');
1483
+ this.params = params;
1484
+ this.renderer = getRenderer();
1485
+ this.addPipe(context => {
1486
+ if (!context || typeof context !== 'object' || !('type' in context))
1487
+ return context;
1488
+ if (context.type === 'unmount') {
1489
+ this.unmount(context.data.element);
1490
+ }
1491
+ else if (context.type === 'render') {
1492
+ if ('filled' in context.data && context.data.filled) {
1493
+ return context;
1494
+ }
1495
+ if (this.mount(context.data.element, context)) {
1496
+ return {
1497
+ ...context,
1498
+ data: {
1499
+ ...context.data,
1500
+ filled: true
1501
+ }
1502
+ };
1503
+ }
1504
+ }
1505
+ return context;
1506
+ });
1507
+ }
1508
+ setParent(scope) {
1509
+ super.setParent(scope);
1510
+ this.presets.forEach(preset => {
1511
+ if (preset.attach)
1512
+ preset.attach(this);
1513
+ });
1514
+ }
1515
+ unmount(element) {
1516
+ this.owners.delete(element);
1517
+ this.renderer.unmount(element);
1518
+ }
1519
+ mount(element, context) {
1520
+ const existing = this.renderer.get(element);
1521
+ if (existing) {
1522
+ this.presets.forEach(preset => {
1523
+ if (this.owners.get(element) !== preset)
1524
+ return;
1525
+ const result = preset.update(context, this);
1526
+ if (result) {
1527
+ this.renderer.update(existing, result);
1528
+ }
1529
+ });
1530
+ return true;
1531
+ }
1532
+ for (const preset of this.presets) {
1533
+ const result = preset.mount(context, this);
1534
+ if (!result)
1535
+ continue;
1536
+ const { key, component, props } = result;
1537
+ this.renderer.mount(element, key, component, this.params.injector, props);
1538
+ this.owners.set(element, preset);
1539
+ return true;
1540
+ }
1541
+ return;
1542
+ }
1543
+ /**
1544
+ * Adds a preset to the plugin.
1545
+ * @param preset Preset that can render nodes, connections and other elements.
1546
+ */
1547
+ addPreset(preset) {
1548
+ const local = preset;
1549
+ if (local.attach)
1550
+ local.attach(this);
1551
+ this.presets.push(local);
1552
+ }
1553
+ }
1554
+
1555
+ /**
1556
+ * Generated bundle index. Do not edit.
1557
+ */
1558
+
1559
+ export { AngularPlugin, ConnectionComponent, ConnectionWrapperComponent, ContextMenuComponent, ContextMenuItemComponent, ContextMenuSearchComponent, ControlComponent, MiniNodeComponent, MiniViewportComponent, MinimapComponent, NodeComponent, PinComponent, PinsComponent, index as Presets, RefDirective, ReteContextMenuModule, ReteMinimapModule, ReteModule, ReteRerouteModule, SocketComponent };
1560
+ //# sourceMappingURL=rete-angular-plugin-ng20.mjs.map