rete-angular-plugin 2.3.2 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1559 @@
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
+ }
347
+ static ɵfac = function ConnectionWrapperComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ConnectionWrapperComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef), i0.ɵɵdirectiveInject(i0.ViewContainerRef), i0.ɵɵdirectiveInject(i0.ComponentFactoryResolver)); };
348
+ 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 });
349
+ }
350
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ConnectionWrapperComponent, [{
351
+ type: Component,
352
+ args: [{
353
+ template: ''
354
+ }]
355
+ }], () => [{ type: i0.ChangeDetectorRef }, { type: i0.ViewContainerRef }, { type: i0.ComponentFactoryResolver }], { data: [{
356
+ type: Input
357
+ }], start: [{
358
+ type: Input
359
+ }], end: [{
360
+ type: Input
361
+ }], path: [{
362
+ type: Input
363
+ }], rendered: [{
364
+ type: Input
365
+ }], connectionComponent: [{
366
+ type: Input
367
+ }] }); })();
368
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ConnectionWrapperComponent, { className: "ConnectionWrapperComponent", filePath: "presets/classic/components/connection/connection-wrapper.component.ts", lineNumber: 10 }); })();
369
+
370
+ /**
371
+ * Classic preset for rendering nodes, connections, controls and sockets.
372
+ */
373
+ function setup$3(props) {
374
+ const positionWatcher = typeof props?.socketPositionWatcher === 'undefined'
375
+ ? getDOMSocketPosition() // fix Type instantiation is excessively deep and possibly infinite.
376
+ : props?.socketPositionWatcher;
377
+ const { node, connection, socket, control } = props?.customize || {};
378
+ return {
379
+ attach(plugin) {
380
+ positionWatcher.attach(plugin);
381
+ },
382
+ update(context) {
383
+ const data = context.data.payload;
384
+ if (context.data.type === 'connection') {
385
+ const { start, end } = context.data;
386
+ return {
387
+ data,
388
+ ...(start ? { start } : {}),
389
+ ...(end ? { end } : {}),
390
+ };
391
+ }
392
+ return { data };
393
+ },
394
+ mount(context, plugin) {
395
+ const parent = plugin.parentScope();
396
+ const emit = parent.emit.bind(parent);
397
+ const rendered = () => {
398
+ emit({ type: 'rendered', data: context.data });
399
+ };
400
+ if (context.data.type === 'node') {
401
+ const component = node ? node(context.data) : NodeComponent;
402
+ return {
403
+ key: `node-${context.data.payload.id}`,
404
+ component,
405
+ props: {
406
+ data: context.data.payload,
407
+ emit,
408
+ rendered
409
+ }
410
+ };
411
+ }
412
+ if (context.data.type === 'connection') {
413
+ const component = connection ? connection(context.data) : ConnectionComponent;
414
+ const id = context.data.payload.id;
415
+ const { sourceOutput, targetInput, source, target } = context.data.payload;
416
+ const { start, end, payload } = context.data;
417
+ return {
418
+ key: `connection-${id}`,
419
+ component: ConnectionWrapperComponent,
420
+ props: {
421
+ connectionComponent: component,
422
+ data: payload,
423
+ start: start || ((change) => positionWatcher.listen(source, 'output', sourceOutput, change)),
424
+ end: end || ((change) => positionWatcher.listen(target, 'input', targetInput, change)),
425
+ path: async (start, end) => {
426
+ const response = await plugin.emit({ type: 'connectionpath', data: { payload, points: [start, end] } });
427
+ if (!response)
428
+ return '';
429
+ const { path, points } = response.data;
430
+ const curvature = 0.3;
431
+ if (!path && points.length !== 2)
432
+ throw new Error('cannot render connection with a custom number of points');
433
+ if (!path)
434
+ return payload.isLoop
435
+ ? loopConnectionPath(points, curvature, 120)
436
+ : classicConnectionPath(points, curvature);
437
+ return path;
438
+ },
439
+ rendered
440
+ }
441
+ };
442
+ }
443
+ if (context.data.type === 'socket') {
444
+ const component = socket ? socket(context.data) : SocketComponent;
445
+ return {
446
+ key: `socket-${getUID()}`,
447
+ component,
448
+ props: {
449
+ data: context.data.payload,
450
+ rendered
451
+ }
452
+ };
453
+ }
454
+ if (context.data.type === 'control') {
455
+ const component = control
456
+ ? control(context.data)
457
+ : (context.data.payload instanceof ClassicPreset.InputControl
458
+ ? ControlComponent
459
+ : null);
460
+ if (component) {
461
+ return {
462
+ key: `control-${context.data.payload.id}`,
463
+ component,
464
+ props: {
465
+ data: context.data.payload,
466
+ rendered
467
+ }
468
+ };
469
+ }
470
+ return;
471
+ }
472
+ return;
473
+ }
474
+ };
475
+ }
476
+
477
+ var index$4 = /*#__PURE__*/Object.freeze({
478
+ __proto__: null,
479
+ setup: setup$3
480
+ });
481
+
482
+ function debounce(cb) {
483
+ return {
484
+ timeout: null,
485
+ cancel() {
486
+ if (this.timeout) {
487
+ window.clearTimeout(this.timeout);
488
+ this.timeout = null;
489
+ }
490
+ },
491
+ call(delay) {
492
+ this.timeout = window.setTimeout(() => {
493
+ cb();
494
+ }, delay);
495
+ }
496
+ };
497
+ }
498
+
499
+ class ContextMenuSearchComponent {
500
+ value;
501
+ update = new EventEmitter();
502
+ static ɵfac = function ContextMenuSearchComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ContextMenuSearchComponent)(); };
503
+ 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) {
504
+ i0.ɵɵelementStart(0, "input", 0);
505
+ i0.ɵɵlistener("input", function ContextMenuSearchComponent_Template_input_input_0_listener($event) { return ctx.update.emit(($event.target == null ? null : $event.target.value) || ""); });
506
+ i0.ɵɵelementEnd();
507
+ } if (rf & 2) {
508
+ i0.ɵɵproperty("value", ctx.value);
509
+ } }, 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}"] });
510
+ }
511
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ContextMenuSearchComponent, [{
512
+ type: Component,
513
+ 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"] }]
514
+ }], null, { value: [{
515
+ type: Input
516
+ }], update: [{
517
+ type: Output
518
+ }] }); })();
519
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ContextMenuSearchComponent, { className: "ContextMenuSearchComponent", filePath: "presets/context-menu/components/search/search.component.ts", lineNumber: 8 }); })();
520
+
521
+ const _c0 = ["*"];
522
+ function ContextMenuItemComponent_div_1_context_menu_item_1_Template(rf, ctx) { if (rf & 1) {
523
+ const _r1 = i0.ɵɵgetCurrentView();
524
+ i0.ɵɵelementStart(0, "context-menu-item", 3);
525
+ 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()); });
526
+ i0.ɵɵtext(1);
527
+ i0.ɵɵelementEnd();
528
+ } if (rf & 2) {
529
+ const item_r2 = ctx.$implicit;
530
+ const ctx_r2 = i0.ɵɵnextContext(2);
531
+ i0.ɵɵproperty("delay", ctx_r2.delay);
532
+ i0.ɵɵadvance();
533
+ i0.ɵɵtextInterpolate1(" ", item_r2.label, " ");
534
+ } }
535
+ function ContextMenuItemComponent_div_1_Template(rf, ctx) { if (rf & 1) {
536
+ i0.ɵɵelementStart(0, "div", 1);
537
+ i0.ɵɵtemplate(1, ContextMenuItemComponent_div_1_context_menu_item_1_Template, 2, 2, "context-menu-item", 2);
538
+ i0.ɵɵelementEnd();
539
+ } if (rf & 2) {
540
+ const ctx_r2 = i0.ɵɵnextContext();
541
+ i0.ɵɵadvance();
542
+ i0.ɵɵproperty("ngForOf", ctx_r2.subitems);
543
+ } }
544
+ class ContextMenuItemComponent {
545
+ cdr;
546
+ subitems;
547
+ delay;
548
+ select = new EventEmitter();
549
+ hide = new EventEmitter();
550
+ get block() { return true; }
551
+ get hasSubitems() { return this.subitems; }
552
+ click(event) {
553
+ event.stopPropagation();
554
+ this.select.emit();
555
+ this.hide.emit();
556
+ }
557
+ pointerdown(event) {
558
+ event.stopPropagation();
559
+ }
560
+ wheel(event) {
561
+ event.stopPropagation();
562
+ }
563
+ hideSubitems = debounce(() => {
564
+ this.visibleSubitems = false;
565
+ this.cdr.detectChanges();
566
+ });
567
+ visibleSubitems = false;
568
+ pointerover() {
569
+ this.hideSubitems.cancel();
570
+ this.visibleSubitems = true;
571
+ this.cdr.detectChanges();
572
+ }
573
+ pointerleave() {
574
+ this.hideSubitems.call(this.delay);
575
+ this.cdr.detectChanges();
576
+ }
577
+ constructor(cdr) {
578
+ this.cdr = cdr;
579
+ this.cdr.detach();
580
+ }
581
+ static ɵfac = function ContextMenuItemComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ContextMenuItemComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
582
+ 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) {
583
+ 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(); });
584
+ } if (rf & 2) {
585
+ i0.ɵɵclassProp("block", ctx.block)("hasSubitems", ctx.hasSubitems);
586
+ } }, 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) {
587
+ i0.ɵɵprojectionDef();
588
+ i0.ɵɵprojection(0);
589
+ i0.ɵɵtemplate(1, ContextMenuItemComponent_div_1_Template, 2, 1, "div", 0);
590
+ } if (rf & 2) {
591
+ i0.ɵɵadvance();
592
+ i0.ɵɵproperty("ngIf", ctx.subitems && ctx.visibleSubitems);
593
+ } }, 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}"] });
594
+ }
595
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ContextMenuItemComponent, [{
596
+ type: Component,
597
+ args: [{ imports: [CommonModule], selector: 'context-menu-item', host: {
598
+ 'data-testid': 'context-menu-item'
599
+ }, 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"] }]
600
+ }], () => [{ type: i0.ChangeDetectorRef }], { subitems: [{
601
+ type: Input
602
+ }], delay: [{
603
+ type: Input
604
+ }], select: [{
605
+ type: Output
606
+ }], hide: [{
607
+ type: Output
608
+ }], block: [{
609
+ type: HostBinding,
610
+ args: ['class.block']
611
+ }], hasSubitems: [{
612
+ type: HostBinding,
613
+ args: ['class.hasSubitems']
614
+ }], click: [{
615
+ type: HostListener,
616
+ args: ['click', ['$event']]
617
+ }], pointerdown: [{
618
+ type: HostListener,
619
+ args: ['pointerdown', ['$event']]
620
+ }], wheel: [{
621
+ type: HostListener,
622
+ args: ['wheel', ['$event']]
623
+ }], pointerover: [{
624
+ type: HostListener,
625
+ args: ['pointerover']
626
+ }], pointerleave: [{
627
+ type: HostListener,
628
+ args: ['pointerleave']
629
+ }] }); })();
630
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ContextMenuItemComponent, { className: "ContextMenuItemComponent", filePath: "presets/context-menu/components/item/item.component.ts", lineNumber: 18 }); })();
631
+
632
+ function ContextMenuComponent_div_0_Template(rf, ctx) { if (rf & 1) {
633
+ const _r1 = i0.ɵɵgetCurrentView();
634
+ i0.ɵɵelementStart(0, "div", 2)(1, "context-menu-search", 3);
635
+ 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)); });
636
+ i0.ɵɵelementEnd()();
637
+ } if (rf & 2) {
638
+ const ctx_r1 = i0.ɵɵnextContext();
639
+ i0.ɵɵadvance();
640
+ i0.ɵɵproperty("value", ctx_r1.filter);
641
+ } }
642
+ function ContextMenuComponent_context_menu_item_1_Template(rf, ctx) { if (rf & 1) {
643
+ const _r3 = i0.ɵɵgetCurrentView();
644
+ i0.ɵɵelementStart(0, "context-menu-item", 4);
645
+ 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()); });
646
+ i0.ɵɵtext(1);
647
+ i0.ɵɵelementEnd();
648
+ } if (rf & 2) {
649
+ const item_r4 = ctx.$implicit;
650
+ const ctx_r1 = i0.ɵɵnextContext();
651
+ i0.ɵɵproperty("delay", ctx_r1.delay)("subitems", item_r4.subitems);
652
+ i0.ɵɵadvance();
653
+ i0.ɵɵtextInterpolate1(" ", item_r4.label, "\n");
654
+ } }
655
+ class ContextMenuComponent {
656
+ cdr;
657
+ items;
658
+ delay;
659
+ searchBar;
660
+ onHide;
661
+ rendered;
662
+ filter = '';
663
+ hide = debounce(() => {
664
+ this.onHide();
665
+ this.cdr.detectChanges();
666
+ });
667
+ customAttribute = '';
668
+ pointerover() {
669
+ this.hide.cancel();
670
+ this.cdr.detectChanges();
671
+ }
672
+ pointerleave() {
673
+ this.hide.call(this.delay);
674
+ this.cdr.detectChanges();
675
+ }
676
+ constructor(cdr) {
677
+ this.cdr = cdr;
678
+ this.cdr.detach();
679
+ }
680
+ ngOnChanges() {
681
+ this.cdr.detectChanges();
682
+ requestAnimationFrame(() => this.rendered());
683
+ }
684
+ setFilter(value) {
685
+ this.filter = value;
686
+ this.cdr.detectChanges();
687
+ }
688
+ getItems() {
689
+ const filterRegexp = new RegExp(this.filter, 'i');
690
+ const filteredList = this.items.filter(item => (item.label.match(filterRegexp)));
691
+ return filteredList;
692
+ }
693
+ ngOnDestroy() {
694
+ if (this.hide)
695
+ this.hide.cancel();
696
+ }
697
+ static ɵfac = function ContextMenuComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ContextMenuComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
698
+ 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) {
699
+ i0.ɵɵlistener("mouseover", function ContextMenuComponent_mouseover_HostBindingHandler() { return ctx.pointerover(); })("mouseleave", function ContextMenuComponent_mouseleave_HostBindingHandler() { return ctx.pointerleave(); });
700
+ } if (rf & 2) {
701
+ i0.ɵɵattribute("rete-context-menu", ctx.customAttribute);
702
+ } }, 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) {
703
+ i0.ɵɵtemplate(0, ContextMenuComponent_div_0_Template, 2, 1, "div", 0)(1, ContextMenuComponent_context_menu_item_1_Template, 2, 3, "context-menu-item", 1);
704
+ } if (rf & 2) {
705
+ i0.ɵɵproperty("ngIf", ctx.searchBar);
706
+ i0.ɵɵadvance();
707
+ i0.ɵɵproperty("ngForOf", ctx.getItems());
708
+ } }, 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}"] });
709
+ }
710
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ContextMenuComponent, [{
711
+ type: Component,
712
+ args: [{ imports: [CommonModule, ContextMenuSearchComponent, ContextMenuItemComponent], host: {
713
+ 'data-testid': 'context-menu'
714
+ }, 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"] }]
715
+ }], () => [{ type: i0.ChangeDetectorRef }], { items: [{
716
+ type: Input
717
+ }], delay: [{
718
+ type: Input
719
+ }], searchBar: [{
720
+ type: Input
721
+ }], onHide: [{
722
+ type: Input
723
+ }], rendered: [{
724
+ type: Input
725
+ }], customAttribute: [{
726
+ type: HostBinding,
727
+ args: ['attr.rete-context-menu']
728
+ }], pointerover: [{
729
+ type: HostListener,
730
+ args: ['mouseover']
731
+ }], pointerleave: [{
732
+ type: HostListener,
733
+ args: ['mouseleave']
734
+ }] }); })();
735
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ContextMenuComponent, { className: "ContextMenuComponent", filePath: "presets/context-menu/components/menu/menu.component.ts", lineNumber: 19 }); })();
736
+
737
+ /**
738
+ * Preset for rendering context menu.
739
+ */
740
+ function setup$2(props) {
741
+ const delay = typeof props?.delay === 'undefined' ? 1000 : props.delay;
742
+ return {
743
+ update(context) {
744
+ if (context.data.type === 'contextmenu') {
745
+ return {
746
+ items: context.data.items,
747
+ delay,
748
+ searchBar: context.data.searchBar,
749
+ onHide: context.data.onHide
750
+ };
751
+ }
752
+ },
753
+ mount(context, plugin) {
754
+ const parent = plugin.parentScope();
755
+ const emit = parent.emit.bind(parent);
756
+ const rendered = () => {
757
+ emit({ type: 'rendered', data: context.data });
758
+ };
759
+ if (context.data.type === 'contextmenu') {
760
+ return {
761
+ key: 'context-menu',
762
+ component: ContextMenuComponent,
763
+ props: {
764
+ items: context.data.items,
765
+ delay,
766
+ searchBar: context.data.searchBar,
767
+ onHide: context.data.onHide,
768
+ rendered
769
+ }
770
+ };
771
+ }
772
+ return null;
773
+ }
774
+ };
775
+ }
776
+
777
+ var index$3 = /*#__PURE__*/Object.freeze({
778
+ __proto__: null,
779
+ setup: setup$2
780
+ });
781
+
782
+ class MiniNodeComponent {
783
+ left;
784
+ top;
785
+ width;
786
+ height;
787
+ get styleLeft() {
788
+ return this.px(this.left);
789
+ }
790
+ get styleTop() {
791
+ return this.px(this.top);
792
+ }
793
+ get styleWidth() {
794
+ return this.px(this.width);
795
+ }
796
+ get styleHeight() {
797
+ return this.px(this.height);
798
+ }
799
+ px(value) {
800
+ return `${value}px`;
801
+ }
802
+ static ɵfac = function MiniNodeComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MiniNodeComponent)(); };
803
+ 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) {
804
+ i0.ɵɵstyleProp("left", ctx.styleLeft)("top", ctx.styleTop)("width", ctx.styleWidth)("height", ctx.styleHeight);
805
+ } }, 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)}"] });
806
+ }
807
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MiniNodeComponent, [{
808
+ type: Component,
809
+ args: [{ selector: 'minimap-mini-node', host: {
810
+ 'data-testid': 'minimap-node'
811
+ }, template: "", styles: [":host{display:block;position:absolute;background:#6e88ffcc;border:1px solid rgba(192,206,212,.6)}\n"] }]
812
+ }], null, { left: [{
813
+ type: Input
814
+ }], top: [{
815
+ type: Input
816
+ }], width: [{
817
+ type: Input
818
+ }], height: [{
819
+ type: Input
820
+ }], styleLeft: [{
821
+ type: HostBinding,
822
+ args: ['style.left']
823
+ }], styleTop: [{
824
+ type: HostBinding,
825
+ args: ['style.top']
826
+ }], styleWidth: [{
827
+ type: HostBinding,
828
+ args: ['style.width']
829
+ }], styleHeight: [{
830
+ type: HostBinding,
831
+ args: ['style.height']
832
+ }] }); })();
833
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MiniNodeComponent, { className: "MiniNodeComponent", filePath: "presets/minimap/components/mini-node/mini-node.component.ts", lineNumber: 11 }); })();
834
+
835
+ function useDrag(translate, getPointer) {
836
+ return {
837
+ start(e) {
838
+ let previous = { ...getPointer(e) };
839
+ function move(moveEvent) {
840
+ const current = { ...getPointer(moveEvent) };
841
+ const dx = current.x - previous.x;
842
+ const dy = current.y - previous.y;
843
+ previous = current;
844
+ translate(dx, dy);
845
+ }
846
+ function up() {
847
+ window.removeEventListener('pointermove', move);
848
+ window.removeEventListener('pointerup', up);
849
+ window.removeEventListener('pointercancel', up);
850
+ }
851
+ window.addEventListener('pointermove', move);
852
+ window.addEventListener('pointerup', up);
853
+ window.addEventListener('pointercancel', up);
854
+ }
855
+ };
856
+ }
857
+
858
+ class MiniViewportComponent {
859
+ left;
860
+ top;
861
+ width;
862
+ height;
863
+ containerWidth;
864
+ translate;
865
+ drag = useDrag((dx, dy) => this.onDrag(dx, dy), e => ({ x: e.pageX, y: e.pageY }));
866
+ get styleLeft() {
867
+ return this.px(this.scale(this.left));
868
+ }
869
+ get styleTop() {
870
+ return this.px(this.scale(this.top));
871
+ }
872
+ get styleWidth() {
873
+ return this.px(this.scale(this.width));
874
+ }
875
+ get styleHeight() {
876
+ return this.px(this.scale(this.height));
877
+ }
878
+ pointerdown(event) {
879
+ event.stopPropagation();
880
+ this.drag.start(event);
881
+ }
882
+ px(value) {
883
+ return `${value}px`;
884
+ }
885
+ scale(v) {
886
+ return v * this.containerWidth;
887
+ }
888
+ invert(v) {
889
+ return v / this.containerWidth;
890
+ }
891
+ onDrag(dx, dy) {
892
+ this.translate(this.invert(-dx), this.invert(-dy));
893
+ }
894
+ static ɵfac = function MiniViewportComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MiniViewportComponent)(); };
895
+ 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) {
896
+ i0.ɵɵlistener("pointerdown", function MiniViewportComponent_pointerdown_HostBindingHandler($event) { return ctx.pointerdown($event); });
897
+ } if (rf & 2) {
898
+ i0.ɵɵstyleProp("left", ctx.styleLeft)("top", ctx.styleTop)("width", ctx.styleWidth)("height", ctx.styleHeight);
899
+ } }, 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}"] });
900
+ }
901
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MiniViewportComponent, [{
902
+ type: Component,
903
+ args: [{ selector: 'minimap-mini-viewport', host: {
904
+ 'data-testid': 'minimap-viewport'
905
+ }, template: "", styles: [":host{display:block;position:absolute;background:#fffb8052;border:1px solid #ffe52b}\n"] }]
906
+ }], null, { left: [{
907
+ type: Input
908
+ }], top: [{
909
+ type: Input
910
+ }], width: [{
911
+ type: Input
912
+ }], height: [{
913
+ type: Input
914
+ }], containerWidth: [{
915
+ type: Input
916
+ }], translate: [{
917
+ type: Input
918
+ }], styleLeft: [{
919
+ type: HostBinding,
920
+ args: ['style.left']
921
+ }], styleTop: [{
922
+ type: HostBinding,
923
+ args: ['style.top']
924
+ }], styleWidth: [{
925
+ type: HostBinding,
926
+ args: ['style.width']
927
+ }], styleHeight: [{
928
+ type: HostBinding,
929
+ args: ['style.height']
930
+ }], pointerdown: [{
931
+ type: HostListener,
932
+ args: ['pointerdown', ['$event']]
933
+ }] }); })();
934
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MiniViewportComponent, { className: "MiniViewportComponent", filePath: "presets/minimap/components/mini-viewport/mini-viewport.component.ts", lineNumber: 13 }); })();
935
+
936
+ function MinimapComponent_minimap_mini_node_0_Template(rf, ctx) { if (rf & 1) {
937
+ i0.ɵɵelement(0, "minimap-mini-node", 2);
938
+ } if (rf & 2) {
939
+ const node_r1 = ctx.$implicit;
940
+ const ctx_r1 = i0.ɵɵnextContext();
941
+ 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));
942
+ } }
943
+ class MinimapComponent {
944
+ el;
945
+ cdr;
946
+ rendered;
947
+ size;
948
+ ratio;
949
+ nodes;
950
+ viewport;
951
+ translate;
952
+ point;
953
+ get width() {
954
+ return this.px(this.size * this.ratio);
955
+ }
956
+ get height() {
957
+ return this.px(this.size);
958
+ }
959
+ pointerdown(event) {
960
+ event.stopPropagation();
961
+ event.preventDefault();
962
+ }
963
+ dblclick(event) {
964
+ event.stopPropagation();
965
+ event.preventDefault();
966
+ if (!this.el.nativeElement)
967
+ return;
968
+ const box = this.el.nativeElement.getBoundingClientRect();
969
+ const x = (event.clientX - box.left) / (this.size * this.ratio);
970
+ const y = (event.clientY - box.top) / (this.size * this.ratio);
971
+ this.point(x, y);
972
+ }
973
+ constructor(el, cdr) {
974
+ this.el = el;
975
+ this.cdr = cdr;
976
+ this.cdr.detach();
977
+ }
978
+ ngOnChanges() {
979
+ this.cdr.detectChanges();
980
+ requestAnimationFrame(() => this.rendered());
981
+ }
982
+ px(value) {
983
+ return `${value}px`;
984
+ }
985
+ scale(value) {
986
+ if (!this.el.nativeElement)
987
+ return 0;
988
+ return value * this.el.nativeElement.clientWidth;
989
+ }
990
+ identifyMiniNode(_, item) {
991
+ return [item.top, item.left].join('_');
992
+ }
993
+ static ɵfac = function MinimapComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MinimapComponent)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
994
+ 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) {
995
+ i0.ɵɵlistener("pointerdown", function MinimapComponent_pointerdown_HostBindingHandler($event) { return ctx.pointerdown($event); })("dblclick", function MinimapComponent_dblclick_HostBindingHandler($event) { return ctx.dblclick($event); });
996
+ } if (rf & 2) {
997
+ i0.ɵɵstyleProp("width", ctx.width)("height", ctx.height);
998
+ } }, 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) {
999
+ i0.ɵɵtemplate(0, MinimapComponent_minimap_mini_node_0_Template, 1, 4, "minimap-mini-node", 0);
1000
+ i0.ɵɵelement(1, "minimap-mini-viewport", 1);
1001
+ } if (rf & 2) {
1002
+ i0.ɵɵproperty("ngForOf", ctx.nodes)("ngForTrackBy", ctx.identifyMiniNode);
1003
+ i0.ɵɵadvance();
1004
+ 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);
1005
+ } }, 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}"] });
1006
+ }
1007
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MinimapComponent, [{
1008
+ type: Component,
1009
+ args: [{ imports: [CommonModule, MiniNodeComponent, MiniViewportComponent], host: {
1010
+ 'data-testid': 'minimap'
1011
+ }, 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"] }]
1012
+ }], () => [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }], { rendered: [{
1013
+ type: Input
1014
+ }], size: [{
1015
+ type: Input
1016
+ }], ratio: [{
1017
+ type: Input
1018
+ }], nodes: [{
1019
+ type: Input
1020
+ }], viewport: [{
1021
+ type: Input
1022
+ }], translate: [{
1023
+ type: Input
1024
+ }], point: [{
1025
+ type: Input
1026
+ }], width: [{
1027
+ type: HostBinding,
1028
+ args: ['style.width']
1029
+ }], height: [{
1030
+ type: HostBinding,
1031
+ args: ['style.height']
1032
+ }], pointerdown: [{
1033
+ type: HostListener,
1034
+ args: ['pointerdown', ['$event']]
1035
+ }], dblclick: [{
1036
+ type: HostListener,
1037
+ args: ['dblclick', ['$event']]
1038
+ }] }); })();
1039
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MinimapComponent, { className: "MinimapComponent", filePath: "presets/minimap/components/minimap/minimap.component.ts", lineNumber: 17 }); })();
1040
+
1041
+ /**
1042
+ * Preset for rendering minimap.
1043
+ */
1044
+ function setup$1(props) {
1045
+ return {
1046
+ update(context) {
1047
+ if (context.data.type === 'minimap') {
1048
+ return {
1049
+ nodes: context.data.nodes,
1050
+ size: props?.size || 200,
1051
+ ratio: context.data.ratio,
1052
+ viewport: context.data.viewport,
1053
+ translate: context.data.translate,
1054
+ point: context.data.point
1055
+ };
1056
+ }
1057
+ return null;
1058
+ },
1059
+ mount(context, plugin) {
1060
+ const parent = plugin.parentScope();
1061
+ const emit = parent.emit.bind(parent);
1062
+ const rendered = () => {
1063
+ emit({ type: 'rendered', data: context.data });
1064
+ };
1065
+ if (context.data.type === 'minimap') {
1066
+ return {
1067
+ key: 'rete-minimap',
1068
+ component: MinimapComponent,
1069
+ props: {
1070
+ nodes: context.data.nodes,
1071
+ size: props?.size || 200,
1072
+ ratio: context.data.ratio,
1073
+ viewport: context.data.viewport,
1074
+ translate: context.data.translate,
1075
+ point: context.data.point,
1076
+ rendered
1077
+ }
1078
+ };
1079
+ }
1080
+ return null;
1081
+ }
1082
+ };
1083
+ }
1084
+
1085
+ var index$2 = /*#__PURE__*/Object.freeze({
1086
+ __proto__: null,
1087
+ setup: setup$1
1088
+ });
1089
+
1090
+ const pinSize = 20;
1091
+ class PinComponent {
1092
+ cdr;
1093
+ position;
1094
+ selected;
1095
+ getPointer;
1096
+ menu = new EventEmitter();
1097
+ translate = new EventEmitter();
1098
+ down = new EventEmitter();
1099
+ drag = useDrag((dx, dy) => {
1100
+ this.translate.emit({ dx, dy });
1101
+ }, () => this.getPointer());
1102
+ get _selected() {
1103
+ return this.selected;
1104
+ }
1105
+ get top() {
1106
+ return `${this.position.y - pinSize / 2}px`;
1107
+ }
1108
+ get left() {
1109
+ return `${this.position.x - pinSize / 2}px`;
1110
+ }
1111
+ pointerdown(event) {
1112
+ event.stopPropagation();
1113
+ event.preventDefault();
1114
+ this.drag.start(event);
1115
+ this.down.emit();
1116
+ }
1117
+ contextmenu(event) {
1118
+ event.stopPropagation();
1119
+ event.preventDefault();
1120
+ this.menu.emit();
1121
+ }
1122
+ constructor(cdr) {
1123
+ this.cdr = cdr;
1124
+ // this.cdr.detach()
1125
+ }
1126
+ ngOnChanges() {
1127
+ // this.cdr.detectChanges()
1128
+ // requestAnimationFrame(() => this.rendered())
1129
+ }
1130
+ static ɵfac = function PinComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PinComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
1131
+ 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) {
1132
+ i0.ɵɵlistener("pointerdown", function PinComponent_pointerdown_HostBindingHandler($event) { return ctx.pointerdown($event); })("contextmenu", function PinComponent_contextmenu_HostBindingHandler($event) { return ctx.contextmenu($event); });
1133
+ } if (rf & 2) {
1134
+ i0.ɵɵstyleProp("top", ctx.top)("left", ctx.left);
1135
+ i0.ɵɵclassProp("selected", ctx._selected);
1136
+ } }, 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}"] });
1137
+ }
1138
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PinComponent, [{
1139
+ type: Component,
1140
+ args: [{ selector: 'reroute-pin', template: '', host: {
1141
+ 'data-testid': 'pin'
1142
+ }, 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"] }]
1143
+ }], () => [{ type: i0.ChangeDetectorRef }], { position: [{
1144
+ type: Input
1145
+ }], selected: [{
1146
+ type: Input
1147
+ }], getPointer: [{
1148
+ type: Input
1149
+ }], menu: [{
1150
+ type: Output
1151
+ }], translate: [{
1152
+ type: Output
1153
+ }], down: [{
1154
+ type: Output
1155
+ }], _selected: [{
1156
+ type: HostBinding,
1157
+ args: ['class.selected']
1158
+ }], top: [{
1159
+ type: HostBinding,
1160
+ args: ['style.top']
1161
+ }], left: [{
1162
+ type: HostBinding,
1163
+ args: ['style.left']
1164
+ }], pointerdown: [{
1165
+ type: HostListener,
1166
+ args: ['pointerdown', ['$event']]
1167
+ }], contextmenu: [{
1168
+ type: HostListener,
1169
+ args: ['contextmenu', ['$event']]
1170
+ }] }); })();
1171
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PinComponent, { className: "PinComponent", filePath: "presets/reroute/components/pin/pin.component.ts", lineNumber: 15 }); })();
1172
+
1173
+ function PinsComponent_reroute_pin_0_Template(rf, ctx) { if (rf & 1) {
1174
+ const _r1 = i0.ɵɵgetCurrentView();
1175
+ i0.ɵɵelementStart(0, "reroute-pin", 1);
1176
+ 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)); });
1177
+ i0.ɵɵelementEnd();
1178
+ } if (rf & 2) {
1179
+ const pin_r2 = ctx.$implicit;
1180
+ const ctx_r2 = i0.ɵɵnextContext();
1181
+ i0.ɵɵproperty("position", pin_r2.position)("selected", pin_r2.selected)("getPointer", ctx_r2.getPointer);
1182
+ } }
1183
+ class PinsComponent {
1184
+ cdr;
1185
+ rendered;
1186
+ pins;
1187
+ down;
1188
+ translate;
1189
+ menu;
1190
+ getPointer;
1191
+ constructor(cdr) {
1192
+ this.cdr = cdr;
1193
+ this.cdr.detach();
1194
+ }
1195
+ ngOnChanges() {
1196
+ this.cdr.detectChanges();
1197
+ requestAnimationFrame(() => this.rendered());
1198
+ }
1199
+ track(_, item) {
1200
+ return item.id;
1201
+ }
1202
+ static ɵfac = function PinsComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PinsComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
1203
+ 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) {
1204
+ i0.ɵɵtemplate(0, PinsComponent_reroute_pin_0_Template, 1, 3, "reroute-pin", 0);
1205
+ } if (rf & 2) {
1206
+ i0.ɵɵproperty("ngForOf", ctx.pins)("ngForTrackBy", ctx.track);
1207
+ } }, dependencies: [CommonModule, i1.NgForOf, PinComponent], encapsulation: 2 });
1208
+ }
1209
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PinsComponent, [{
1210
+ type: Component,
1211
+ 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" }]
1212
+ }], () => [{ type: i0.ChangeDetectorRef }], { rendered: [{
1213
+ type: Input
1214
+ }], pins: [{
1215
+ type: Input
1216
+ }], down: [{
1217
+ type: Input
1218
+ }], translate: [{
1219
+ type: Input
1220
+ }], menu: [{
1221
+ type: Input
1222
+ }], getPointer: [{
1223
+ type: Input
1224
+ }] }); })();
1225
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PinsComponent, { className: "PinsComponent", filePath: "presets/reroute/components/pins/pins.component.ts", lineNumber: 12 }); })();
1226
+
1227
+ /**
1228
+ * Preset for rendering pins.
1229
+ */
1230
+ function setup(props) {
1231
+ const getProps = () => ({
1232
+ menu: props?.contextMenu || (() => null),
1233
+ translate: props?.translate || (() => null),
1234
+ down: props?.pointerdown || (() => null)
1235
+ });
1236
+ return {
1237
+ update(context) {
1238
+ if (context.data.type === 'reroute-pins') {
1239
+ return {
1240
+ ...getProps(),
1241
+ pins: context.data.data.pins
1242
+ };
1243
+ }
1244
+ return null;
1245
+ },
1246
+ mount(context, plugin) {
1247
+ const area = plugin.parentScope(BaseAreaPlugin);
1248
+ const rendered = () => {
1249
+ area.emit({ type: 'rendered', data: context.data });
1250
+ };
1251
+ if (context.data.type === 'reroute-pins') {
1252
+ return {
1253
+ key: 'rete-reroute',
1254
+ component: PinsComponent,
1255
+ props: {
1256
+ ...getProps(),
1257
+ pins: context.data.data.pins,
1258
+ rendered,
1259
+ getPointer: () => area.area.pointer
1260
+ }
1261
+ };
1262
+ }
1263
+ return null;
1264
+ }
1265
+ };
1266
+ }
1267
+
1268
+ var index$1 = /*#__PURE__*/Object.freeze({
1269
+ __proto__: null,
1270
+ setup: setup
1271
+ });
1272
+
1273
+ /**
1274
+ * Built-in presets, responsible for rendering different parts of the editor.
1275
+ * @module
1276
+ */
1277
+
1278
+ var index = /*#__PURE__*/Object.freeze({
1279
+ __proto__: null,
1280
+ classic: index$4,
1281
+ contextMenu: index$3,
1282
+ minimap: index$2,
1283
+ reroute: index$1
1284
+ });
1285
+
1286
+ class ReteModule {
1287
+ static ɵfac = function ReteModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ReteModule)(); };
1288
+ static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ReteModule });
1289
+ static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
1290
+ NodeComponent] });
1291
+ }
1292
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ReteModule, [{
1293
+ type: NgModule,
1294
+ args: [{
1295
+ imports: [
1296
+ CommonModule,
1297
+ RefDirective,
1298
+ NodeComponent,
1299
+ ConnectionComponent,
1300
+ ConnectionWrapperComponent,
1301
+ SocketComponent,
1302
+ ControlComponent
1303
+ ],
1304
+ exports: [
1305
+ RefDirective,
1306
+ NodeComponent,
1307
+ ConnectionComponent,
1308
+ ConnectionWrapperComponent,
1309
+ SocketComponent,
1310
+ ControlComponent
1311
+ ]
1312
+ }]
1313
+ }], null, null); })();
1314
+ (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ReteModule, { imports: [CommonModule,
1315
+ RefDirective,
1316
+ NodeComponent,
1317
+ ConnectionComponent,
1318
+ ConnectionWrapperComponent,
1319
+ SocketComponent,
1320
+ ControlComponent], exports: [RefDirective,
1321
+ NodeComponent,
1322
+ ConnectionComponent,
1323
+ ConnectionWrapperComponent,
1324
+ SocketComponent,
1325
+ ControlComponent] }); })();
1326
+
1327
+ class ReteContextMenuModule {
1328
+ static ɵfac = function ReteContextMenuModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ReteContextMenuModule)(); };
1329
+ static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ReteContextMenuModule });
1330
+ static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
1331
+ ContextMenuComponent,
1332
+ ContextMenuItemComponent] });
1333
+ }
1334
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ReteContextMenuModule, [{
1335
+ type: NgModule,
1336
+ args: [{
1337
+ imports: [
1338
+ CommonModule,
1339
+ ContextMenuComponent,
1340
+ ContextMenuSearchComponent,
1341
+ ContextMenuItemComponent
1342
+ ],
1343
+ exports: [
1344
+ ContextMenuComponent,
1345
+ ContextMenuSearchComponent,
1346
+ ContextMenuItemComponent,
1347
+ ]
1348
+ }]
1349
+ }], null, null); })();
1350
+ (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ReteContextMenuModule, { imports: [CommonModule,
1351
+ ContextMenuComponent,
1352
+ ContextMenuSearchComponent,
1353
+ ContextMenuItemComponent], exports: [ContextMenuComponent,
1354
+ ContextMenuSearchComponent,
1355
+ ContextMenuItemComponent] }); })();
1356
+
1357
+ class ReteMinimapModule {
1358
+ static ɵfac = function ReteMinimapModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ReteMinimapModule)(); };
1359
+ static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ReteMinimapModule });
1360
+ static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
1361
+ MinimapComponent] });
1362
+ }
1363
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ReteMinimapModule, [{
1364
+ type: NgModule,
1365
+ args: [{
1366
+ imports: [
1367
+ CommonModule,
1368
+ MinimapComponent,
1369
+ MiniViewportComponent,
1370
+ MiniNodeComponent
1371
+ ],
1372
+ exports: [
1373
+ MinimapComponent,
1374
+ MiniViewportComponent,
1375
+ MiniNodeComponent
1376
+ ]
1377
+ }]
1378
+ }], null, null); })();
1379
+ (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ReteMinimapModule, { imports: [CommonModule,
1380
+ MinimapComponent,
1381
+ MiniViewportComponent,
1382
+ MiniNodeComponent], exports: [MinimapComponent,
1383
+ MiniViewportComponent,
1384
+ MiniNodeComponent] }); })();
1385
+
1386
+ class ReteRerouteModule {
1387
+ static ɵfac = function ReteRerouteModule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ReteRerouteModule)(); };
1388
+ static ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ReteRerouteModule });
1389
+ static ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule,
1390
+ PinsComponent] });
1391
+ }
1392
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ReteRerouteModule, [{
1393
+ type: NgModule,
1394
+ args: [{
1395
+ imports: [
1396
+ CommonModule,
1397
+ PinsComponent,
1398
+ PinComponent,
1399
+ ],
1400
+ exports: [
1401
+ PinsComponent,
1402
+ PinComponent,
1403
+ ]
1404
+ }]
1405
+ }], null, null); })();
1406
+ (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ReteRerouteModule, { imports: [CommonModule,
1407
+ PinsComponent,
1408
+ PinComponent], exports: [PinsComponent,
1409
+ PinComponent] }); })();
1410
+
1411
+ function reflect(obj) {
1412
+ if (typeof obj !== 'object' || obj === null) {
1413
+ return obj;
1414
+ }
1415
+ return new Proxy(obj, {
1416
+ get(target, prop) {
1417
+ return target[prop];
1418
+ },
1419
+ set(target, prop, value) {
1420
+ target[prop] = value;
1421
+ return true;
1422
+ },
1423
+ has: (target, prop) => prop in target,
1424
+ deleteProperty: (target, prop) => delete target[prop],
1425
+ ownKeys: target => Reflect.ownKeys(target)
1426
+ });
1427
+ }
1428
+
1429
+ function getRenderer() {
1430
+ const elements = new WeakMap();
1431
+ return {
1432
+ get(element) {
1433
+ return elements.get(element);
1434
+ },
1435
+ mount(element, key, component, injector, props) {
1436
+ // LIMITATION: If an element is remounted with the same identifier, the component cannot be replaced
1437
+ let CustomElement = customElements.get(key);
1438
+ if (!CustomElement) {
1439
+ CustomElement = createCustomElement(component, { injector });
1440
+ customElements.define(key, CustomElement);
1441
+ }
1442
+ const ngElement = new CustomElement(injector);
1443
+ Object.keys(props).forEach(key => {
1444
+ ngElement[key] = props[key];
1445
+ });
1446
+ element.appendChild(ngElement);
1447
+ elements.set(element, { key, ngElement });
1448
+ },
1449
+ update({ ngElement }, props) {
1450
+ Object.keys(props).forEach(key => {
1451
+ ngElement.ngElementStrategy.setInputValue(key, reflect(props[key]));
1452
+ });
1453
+ },
1454
+ unmount(element) {
1455
+ const existing = elements.get(element);
1456
+ if (existing) {
1457
+ existing.ngElement.remove();
1458
+ elements.delete(element);
1459
+ }
1460
+ }
1461
+ };
1462
+ }
1463
+ /**
1464
+ * Angular plugin. Renders nodes, connections and other elements using React.
1465
+ * @priority 9
1466
+ * @emits connectionpath
1467
+ * @listens render
1468
+ * @listens unmount
1469
+ */
1470
+ class AngularPlugin extends Scope {
1471
+ params;
1472
+ presets = [];
1473
+ renderer;
1474
+ owners = new WeakMap();
1475
+ /**
1476
+ * @constructor
1477
+ * @param params Plugin properties
1478
+ * @param params.injector Angular's Injector instance
1479
+ */
1480
+ constructor(params) {
1481
+ super('angular-render');
1482
+ this.params = params;
1483
+ this.renderer = getRenderer();
1484
+ this.addPipe(context => {
1485
+ if (!context || typeof context !== 'object' || !('type' in context))
1486
+ return context;
1487
+ if (context.type === 'unmount') {
1488
+ this.unmount(context.data.element);
1489
+ }
1490
+ else if (context.type === 'render') {
1491
+ if ('filled' in context.data && context.data.filled) {
1492
+ return context;
1493
+ }
1494
+ if (this.mount(context.data.element, context)) {
1495
+ return {
1496
+ ...context,
1497
+ data: {
1498
+ ...context.data,
1499
+ filled: true
1500
+ }
1501
+ };
1502
+ }
1503
+ }
1504
+ return context;
1505
+ });
1506
+ }
1507
+ setParent(scope) {
1508
+ super.setParent(scope);
1509
+ this.presets.forEach(preset => {
1510
+ if (preset.attach)
1511
+ preset.attach(this);
1512
+ });
1513
+ }
1514
+ unmount(element) {
1515
+ this.owners.delete(element);
1516
+ this.renderer.unmount(element);
1517
+ }
1518
+ mount(element, context) {
1519
+ const existing = this.renderer.get(element);
1520
+ if (existing) {
1521
+ this.presets.forEach(preset => {
1522
+ if (this.owners.get(element) !== preset)
1523
+ return;
1524
+ const result = preset.update(context, this);
1525
+ if (result) {
1526
+ this.renderer.update(existing, result);
1527
+ }
1528
+ });
1529
+ return true;
1530
+ }
1531
+ for (const preset of this.presets) {
1532
+ const result = preset.mount(context, this);
1533
+ if (!result)
1534
+ continue;
1535
+ const { key, component, props } = result;
1536
+ this.renderer.mount(element, key, component, this.params.injector, props);
1537
+ this.owners.set(element, preset);
1538
+ return true;
1539
+ }
1540
+ return;
1541
+ }
1542
+ /**
1543
+ * Adds a preset to the plugin.
1544
+ * @param preset Preset that can render nodes, connections and other elements.
1545
+ */
1546
+ addPreset(preset) {
1547
+ const local = preset;
1548
+ if (local.attach)
1549
+ local.attach(this);
1550
+ this.presets.push(local);
1551
+ }
1552
+ }
1553
+
1554
+ /**
1555
+ * Generated bundle index. Do not edit.
1556
+ */
1557
+
1558
+ export { AngularPlugin, ConnectionComponent, ConnectionWrapperComponent, ContextMenuComponent, ContextMenuItemComponent, ContextMenuSearchComponent, ControlComponent, MiniNodeComponent, MiniViewportComponent, MinimapComponent, NodeComponent, PinComponent, PinsComponent, index as Presets, RefDirective, ReteContextMenuModule, ReteMinimapModule, ReteModule, ReteRerouteModule, SocketComponent };
1559
+ //# sourceMappingURL=rete-angular-plugin-ng20.mjs.map