@ankhzet/graph 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -19,16 +19,47 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
19
19
  enumerable: !(r = C(t, s)) || r.enumerable
20
20
  });
21
21
  return e;
22
- }, O = (e, t, n) => (D(e, t, "default"), n && D(n, t, "default")), k = (e, t, n = 1) => ({
22
+ }, O = (e, t, n) => (D(e, t, "default"), n && D(n, t, "default")), ee = 16, te = 8, ne = 16, re = 32, ie = class {
23
+ grid;
24
+ gridSize;
25
+ sizes;
26
+ constructor({ grid: e = 16, port: t = 8, lane: n = 16, space: r = 32 } = {}) {
27
+ this.grid = e, this.gridSize = {
28
+ x: e,
29
+ y: e
30
+ }, this.sizes = {
31
+ grid: this.gridSize,
32
+ port: t,
33
+ lane: n,
34
+ space: r
35
+ };
36
+ }
37
+ snap(e) {
38
+ let t = e < 0 ? -1 : 1;
39
+ return t * (Math.round(t * e / this.grid + .5) - .5) * this.grid;
40
+ }
41
+ toGraph({ x: e, y: t }) {
42
+ return {
43
+ x: (e - .5) * this.grid,
44
+ y: (t - .5) * this.grid
45
+ };
46
+ }
47
+ toData({ x: e, y: t }) {
48
+ return {
49
+ x: ~~(this.snap(e) / this.grid + .5),
50
+ y: ~~(this.snap(t) / this.grid + .5)
51
+ };
52
+ }
53
+ }, ae = ({ description: { item: e } }) => e.isolator ? e.title : null, k = (e, t, n = 1) => ({
23
54
  x: ~~(e.x + t.x * n),
24
55
  y: ~~(e.y + t.y * n)
25
- }), A = (e, t) => (n) => n.node === e && n.port === t, ee = (e) => (t) => t.node === e, j = (e, t, n) => {
56
+ }), A = (e, t) => (n) => n.node === e && n.port === t, oe = (e) => (t) => t.node === e, se = (e, t, n) => {
26
57
  if (n) for (let r of n) {
27
58
  let n = t.nodes.findIndex(A(r.node, r.port));
28
59
  n >= 0 !== e && (e ? t.nodes.push(r) : t.nodes.splice(n, 1));
29
60
  }
30
61
  else e || (t.nodes = []);
31
- }, te = (e, t, n, r, i, a, o, s) => {
62
+ }, ce = (e, t, n, r, i, a, o, s) => {
32
63
  if (e === n && t === r || i === o && a === s) return !1;
33
64
  let c = (s - a) * (n - e) - (o - i) * (r - t);
34
65
  if (c === 0) return !1;
@@ -37,7 +68,7 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
37
68
  x: e + l * (n - e),
38
69
  y: t + l * (r - t)
39
70
  };
40
- }, M = class {
71
+ }, j = class {
41
72
  joints = /* @__PURE__ */ new Map();
42
73
  parentId;
43
74
  constructor(e, t) {
@@ -67,13 +98,13 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
67
98
  return !!this.joints.get(e)?.nodes.some(A(t, n));
68
99
  }
69
100
  getPort(e, t) {
70
- let n = this.find(t === void 0 ? (t) => t.nodes.some(ee(e)) : (n) => n.nodes.some(A(e, t)));
101
+ let n = this.find(t === void 0 ? (t) => t.nodes.some(oe(e)) : (n) => n.nodes.some(A(e, t)));
71
102
  if (n) return n.port;
72
103
  }
73
104
  connect({ port: e, target: t, connect: n }) {
74
105
  let r = this.joints.get(e);
75
106
  if (!r) throw Error(`Node ${this.parentId} does not have joint "${e}"`);
76
- return j(n, r, t), r;
107
+ return se(n, r, t), r;
77
108
  }
78
109
  getNodes(e) {
79
110
  return this.joints.get(e)?.nodes;
@@ -86,7 +117,7 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
86
117
  get count() {
87
118
  return this.joints.size;
88
119
  }
89
- }, ne = Symbol("E_CONNECT"), re = Symbol("E_MOVE"), ie = class extends e {
120
+ }, le = Symbol("E_CONNECT"), M = Symbol("E_MOVE"), N = class extends e {
90
121
  id;
91
122
  description;
92
123
  inputs;
@@ -97,7 +128,7 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
97
128
  y: 0
98
129
  };
99
130
  constructor({ id: e, coordinator: t, inputs: n = [], outputs: r = [], ...i }) {
100
- super(), this.id = e, this.coordinator = t, this.description = i, this.inputs = new M(e, n), this.outputs = new M(e, r);
131
+ super(), this.id = e, this.coordinator = t, this.description = i, this.inputs = new j(e, n), this.outputs = new j(e, r);
101
132
  }
102
133
  get title() {
103
134
  return this.description.title;
@@ -112,7 +143,7 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
112
143
  return this.#e;
113
144
  }
114
145
  set position({ x: e, y: t }) {
115
- e = this.coordinator.snap(e), t = this.coordinator.snap(t), !(this.#e.x === e && this.#e.y === t) && (this.#e.x = e, this.#e.y = t, this.dispatchEvent(re, this.#e));
146
+ e = this.coordinator.snap(e), t = this.coordinator.snap(t), !(this.#e.x === e && this.#e.y === t) && (this.#e.x = e, this.#e.y = t, this.dispatchEvent(M, this.#e));
116
147
  }
117
148
  isInput(e, t, n) {
118
149
  return this.inputs.hasAtPort(e, t, n);
@@ -154,7 +185,7 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
154
185
  nodes: a
155
186
  });
156
187
  }
157
- this.dispatchEvent(ne, {
188
+ this.dispatchEvent(le, {
158
189
  connect: t,
159
190
  input: e,
160
191
  source: i,
@@ -165,12 +196,12 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
165
196
  return this.position = e;
166
197
  }
167
198
  onConnect(e) {
168
- return this.handleEvent(ne, e);
199
+ return this.handleEvent(le, e);
169
200
  }
170
201
  onMove(e) {
171
- return this.handleEvent(re, e);
202
+ return this.handleEvent(M, e);
172
203
  }
173
- }, N = class {
204
+ }, P = class {
174
205
  _barriers = {};
175
206
  _isBarrier;
176
207
  map;
@@ -231,7 +262,7 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
231
262
  y: (i.y - r.y) / 2
232
263
  };
233
264
  }
234
- }, ae = class extends N {
265
+ }, ue = class extends P {
235
266
  layers = [];
236
267
  #e = null;
237
268
  get center() {
@@ -292,7 +323,7 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
292
323
  if (n && !1 === t(n)) break;
293
324
  }
294
325
  }
295
- }, oe = class extends N {
326
+ }, de = class extends P {
296
327
  cache = {};
297
328
  hash = null;
298
329
  get center() {
@@ -325,7 +356,7 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
325
356
  }
326
357
  return this.hash = null, a;
327
358
  }
328
- }, se = class {
359
+ }, fe = class {
329
360
  sort(e) {
330
361
  let t = {}, n = {}, r = [];
331
362
  for (let i of e) {
@@ -377,7 +408,7 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
377
408
  leafs: r
378
409
  };
379
410
  }
380
- }, ce = class {
411
+ }, pe = class {
381
412
  sort(e, t, n) {
382
413
  let r = n.pop();
383
414
  for (let e of r);
@@ -390,7 +421,7 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
390
421
  }
391
422
  return n;
392
423
  }
393
- }, le = class {
424
+ }, me = class {
394
425
  isBarrier;
395
426
  klass;
396
427
  constructor(e, t) {
@@ -404,7 +435,7 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
404
435
  getSubGraphs(e, t) {
405
436
  return new this.klass(e, this.isBarrier).getSubGraphs(t);
406
437
  }
407
- }, P = Symbol("changed"), F = class extends e {
438
+ }, F = Symbol("changed"), I = class extends e {
408
439
  all;
409
440
  map = {};
410
441
  constructor(e = []) {
@@ -412,7 +443,7 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
412
443
  }
413
444
  clear() {
414
445
  let e = this.all;
415
- this.all = [], this.map = {}, this.dispatchEvent(P, {
446
+ this.all = [], this.map = {}, this.dispatchEvent(F, {
416
447
  diff: e,
417
448
  added: !1
418
449
  });
@@ -429,22 +460,22 @@ var S = Object.defineProperty, C = Object.getOwnPropertyDescriptor, w = Object.g
429
460
  add(e) {
430
461
  let t = Array.isArray(e) ? e : [e], n = [];
431
462
  for (let e of t) this.all.includes(e) || (n.push(e), this.map[e.id] = e);
432
- return n.length && (this.all = this.all.concat(n), this.dispatchEvent(P)), e;
463
+ return n.length && (this.all = this.all.concat(n), this.dispatchEvent(F)), e;
433
464
  }
434
465
  remove(e) {
435
466
  Array.isArray(e) || (e = [e]);
436
467
  let t = this.all.filter((t) => !e.includes(t.id));
437
468
  if (t.length !== this.all.length) {
438
469
  for (let t of e) delete this.map[t];
439
- this.all = t, this.dispatchEvent(P);
470
+ this.all = t, this.dispatchEvent(F);
440
471
  }
441
472
  return this;
442
473
  }
443
474
  onChange(e) {
444
- return this.handleEvent(P, e);
475
+ return this.handleEvent(F, e);
445
476
  }
446
- }, I = (e, t) => e === t ? !0 : e.length === t.length ? e.every((e, n) => e.id === t[n]?.id) : !1;
447
- function L(e) {
477
+ }, L = (e, t) => e === t ? !0 : e.length === t.length ? e.every((e, n) => e.id === t[n]?.id) : !1;
478
+ function he(e) {
448
479
  let [[t, n]] = l(() => {
449
480
  let t = e();
450
481
  return [t, [
@@ -452,7 +483,7 @@ function L(e) {
452
483
  () => t.all,
453
484
  () => t.all,
454
485
  (e) => e,
455
- I
486
+ L
456
487
  ]];
457
488
  });
458
489
  return o(() => () => {
@@ -461,7 +492,7 @@ function L(e) {
461
492
  }
462
493
  //#endregion
463
494
  //#region src/graph/useDraggable.tsx
464
- var R = (e) => {
495
+ var ge = (e) => {
465
496
  let t = e.position, [n, r] = l(() => ({
466
497
  x: t.x,
467
498
  y: t.y
@@ -495,24 +526,24 @@ var R = (e) => {
495
526
  e.onDrag(t), r(t);
496
527
  })
497
528
  };
498
- }, z = /* @__PURE__ */ E({});
499
- import * as ue from "@pixi/core";
500
- O(z, ue);
501
- import * as de from "@pixi/display";
502
- O(z, de);
503
- import * as fe from "@pixi/sprite";
504
- O(z, fe);
505
- import * as pe from "@pixi/graphics";
506
- O(z, pe);
507
- import * as me from "@pixi/text";
508
- O(z, me);
509
- import * as he from "@pixi/text-bitmap";
510
- O(z, he);
511
- import * as ge from "@pixi/events";
512
- O(z, ge);
529
+ }, R = /* @__PURE__ */ E({});
530
+ import * as _e from "@pixi/core";
531
+ O(R, _e);
532
+ import * as ve from "@pixi/display";
533
+ O(R, ve);
534
+ import * as ye from "@pixi/sprite";
535
+ O(R, ye);
536
+ import * as be from "@pixi/graphics";
537
+ O(R, be);
538
+ import * as xe from "@pixi/text";
539
+ O(R, xe);
540
+ import * as Se from "@pixi/text-bitmap";
541
+ O(R, Se);
542
+ import * as Ce from "@pixi/events";
543
+ O(R, Ce);
513
544
  //#endregion
514
545
  //#region src/graph/render/Batch.ts
515
- var _e = class extends e {
546
+ var z = class extends e {
516
547
  counter;
517
548
  constructor() {
518
549
  super(), this.counter = 0;
@@ -533,12 +564,12 @@ var _e = class extends e {
533
564
  and(e) {
534
565
  return this.handleEvent(".", e);
535
566
  }
536
- }, ve = [
567
+ }, we = [
537
568
  [0, -1],
538
569
  [-1, 0],
539
570
  [0, 1],
540
571
  [1, 0]
541
- ], ye = Math.PI * 2, be = Math.PI / 2, xe = class extends z.Graphics {
572
+ ], Te = Math.PI * 2, Ee = Math.PI / 2, De = class extends R.Graphics {
542
573
  sizeX;
543
574
  sizeY;
544
575
  lineSize;
@@ -550,10 +581,10 @@ var _e = class extends e {
550
581
  #n;
551
582
  #r;
552
583
  constructor(e, { lineSize: t, sizeX: n, sizeY: r, radius: i, color: a }) {
553
- super(), this.lineSize = t, this.color = a, this.sizeX = n, this.sizeY = r, this.#t = new z.Graphics().lineStyle({
584
+ super(), this.lineSize = t, this.color = a, this.sizeX = n, this.sizeY = r, this.#t = new R.Graphics().lineStyle({
554
585
  width: t,
555
586
  color: a
556
- }).drawRoundedRect(0, 0, n, r, i), this.#e = new z.Graphics(), this.#e.position.set(n / 2, r / 2), this.#t.mask = this.#e, this.addChild(e), this.addChild(this.#t), this.addChild(this.#e), this.progress = 0;
587
+ }).drawRoundedRect(0, 0, n, r, i), this.#e = new R.Graphics(), this.#e.position.set(n / 2, r / 2), this.#t.mask = this.#e, this.addChild(e), this.addChild(this.#t), this.addChild(this.#e), this.progress = 0;
557
588
  let o = this.sizeX / 2, s = this.sizeY / 2, c = -o + this.lineSize, l = -s + this.lineSize, u = +o - this.lineSize, d = +s - this.lineSize, f = [
558
589
  [
559
590
  c,
@@ -605,11 +636,11 @@ var _e = class extends e {
605
636
  }
606
637
  update(e) {
607
638
  this.progress = e;
608
- let t = e * ye % ye, n = Math.cos(t - be) * this.sizeX * 2, r = Math.sin(t - be) * this.sizeY * 2, i, a = null, o = 0;
639
+ let t = e * Te % Te, n = Math.cos(t - Ee) * this.sizeX * 2, r = Math.sin(t - Ee) * this.sizeY * 2, i, a = null, o = 0;
609
640
  for (let e = 0; e < this.#r.segments.length; e++) {
610
- let t = this.#r.segments[e], s = te(0, 0, n, r, t[0], t[1], t[2], t[3]);
641
+ let t = this.#r.segments[e], s = ce(0, 0, n, r, t[0], t[1], t[2], t[3]);
611
642
  if (s) {
612
- a = s, o = e === 0 ? s.x > 0 ? 0 : 4 : 4 - e, i = ve[e];
643
+ a = s, o = e === 0 ? s.x > 0 ? 0 : 4 : 4 - e, i = we[e];
613
644
  break;
614
645
  }
615
646
  }
@@ -619,7 +650,7 @@ var _e = class extends e {
619
650
  this.#e.lineTo(a.x + i[0] * this.lineSize * 2, a.y + i[1] * this.lineSize * 2).lineTo(a.x, a.y).lineTo(0, 0).endFill();
620
651
  }
621
652
  }
622
- }, B = class extends z.Graphics {
653
+ }, B = class extends R.Graphics {
623
654
  from;
624
655
  to;
625
656
  angled = !1;
@@ -627,7 +658,7 @@ var _e = class extends e {
627
658
  #e;
628
659
  #t = 2;
629
660
  constructor(e, t, n, r, i = 2) {
630
- super(), this.#e = i, this.from = new z.ObservablePoint(() => this.update(), 0, e, t), this.to = new z.ObservablePoint(() => this.update(), 0, n, r), this.eventMode = "none";
661
+ super(), this.#e = i, this.from = new R.ObservablePoint(() => this.update(), 0, e, t), this.to = new R.ObservablePoint(() => this.update(), 0, n, r), this.eventMode = "none";
631
662
  }
632
663
  moveFromPoint(e) {
633
664
  let t = this.from.x !== e.x || this.from.y !== e.y;
@@ -647,11 +678,11 @@ var _e = class extends e {
647
678
  let { x: e, y: t } = this.from, { x: n, y: r } = this.to, i = n - e, a = r - t, o = i / 2, s = a / 2;
648
679
  return this.clear(), this.lineStyle(this.#t, this.color, this.alpha), this.x = n - o, this.y = r - s, this.angled ? (this.moveTo(-o, -s), this.lineTo(0, -s), this.lineTo(0, s), this.lineTo(o, s)) : (this.moveTo(-o, -s), this.lineTo(o, s)), this.#e && (this.beginFill(this.color, this.alpha), this.drawCircle(-o, -s, this.#e / 2), this.drawCircle(o, s, this.#e / 2), this.endFill()), this;
649
680
  }
650
- }, Se = class extends z.Graphics {
681
+ }, Oe = class extends R.Graphics {
651
682
  from;
652
683
  to;
653
684
  constructor(e, t) {
654
- super(), this.from = new z.Point(e, t), this.to = {};
685
+ super(), this.from = new R.Point(e, t), this.to = {};
655
686
  for (let e of Object.values(this.to)) this.addChild(e);
656
687
  }
657
688
  addTarget(e, t) {
@@ -673,15 +704,15 @@ var _e = class extends e {
673
704
  }
674
705
  return t;
675
706
  }
676
- }, Ce = {
707
+ }, ke = {
677
708
  0: 6710886,
678
709
  2: 16737894,
679
710
  1: 6750054
680
- }, we = {
711
+ }, Ae = {
681
712
  0: 6710886,
682
713
  2: 11167334,
683
714
  1: 16724787
684
- }, Te = (e, t, n) => {
715
+ }, je = (e, t, n) => {
685
716
  let { point: { parent: r, input: i } } = e;
686
717
  if (t.hover) {
687
718
  let a = r === t.point.parent || i === t.point.input ? 2 : 1;
@@ -692,7 +723,7 @@ var _e = class extends e {
692
723
  return a;
693
724
  }
694
725
  return 0;
695
- }, Ee = (e, t) => e.parent === t.parent && e.port === t.port, De = class extends z.Graphics {
726
+ }, Me = (e, t) => e.parent === t.parent && e.port === t.port, Ne = class extends R.Graphics {
696
727
  line1;
697
728
  line2;
698
729
  line12;
@@ -717,14 +748,14 @@ var _e = class extends e {
717
748
  setPosition(e) {
718
749
  return this.x = e.x, this.y = e.y, this;
719
750
  }
720
- }, Oe = class extends Se {
751
+ }, Pe = class extends Oe {
721
752
  start;
722
753
  finish;
723
754
  viable;
724
755
  #e;
725
756
  #t;
726
757
  constructor(e) {
727
- super(e.pos.x, e.pos.y), this.start = e, this.viable = 0, this.#e = this.addTarget(0, 0), this.#t = new De(10, 16724787).hide(), this.addChild(this.#t);
758
+ super(e.pos.x, e.pos.y), this.start = e, this.viable = 0, this.#e = this.addTarget(0, 0), this.#t = new Ne(10, 16724787).hide(), this.addChild(this.#t);
728
759
  }
729
760
  get isRemoving() {
730
761
  return this.start.remove || !!this.finish?.remove;
@@ -737,18 +768,18 @@ var _e = class extends e {
737
768
  x: t + a / 2,
738
769
  y: n + o / 2
739
770
  };
740
- this.#t.setColor(we[this.viable]).setPosition(e).setAngle(s).show(), this.viable === 0 && (this.#e.visible = !1, this.#t.hide());
771
+ this.#t.setColor(Ae[this.viable]).setPosition(e).setAngle(s).show(), this.viable === 0 && (this.#e.visible = !1, this.#t.hide());
741
772
  } else this.#t.hide();
742
- this.#e.setColor(this.isRemoving ? we[this.viable] : Ce[this.viable]).moveToPoint(e);
773
+ this.#e.setColor(this.isRemoving ? Ae[this.viable] : ke[this.viable]).moveToPoint(e);
743
774
  }
744
775
  flail(e) {
745
776
  this.finish || this.setLine(e);
746
777
  }
747
778
  hoverPort(e) {
748
- this.viable = Te(this.start, e, this.isRemoving), this.finish = this.viable === 1 ? e : void 0, this.setLine(e.pos);
779
+ this.viable = je(this.start, e, this.isRemoving), this.finish = this.viable === 1 ? e : void 0, this.setLine(e.pos);
749
780
  }
750
781
  connect({ point: e }) {
751
- if (this.finish && Ee(this.finish.point, e)) {
782
+ if (this.finish && Me(this.finish.point, e)) {
752
783
  let { start: { remove: e, point: t }, finish: { remove: n, point: r } } = this, i = t.input ? t : r, a = t.input ? r : t;
753
784
  return {
754
785
  connect: !(e || n),
@@ -758,8 +789,8 @@ var _e = class extends e {
758
789
  }
759
790
  return !1;
760
791
  }
761
- }, V = class extends z.Container {
762
- static makeFont = (e, t, n) => typeof document < "u" && z.BitmapFont.from(e, t, {
792
+ }, V = class extends R.Container {
793
+ static makeFont = (e, t, n) => typeof document < "u" && R.BitmapFont.from(e, t, {
763
794
  chars: [
764
795
  ["a", "z"],
765
796
  ["A", "Z"],
@@ -777,7 +808,7 @@ var _e = class extends e {
777
808
  fontName: e
778
809
  }));
779
810
  constructor(e, t) {
780
- super(), this.#e = this.addChild(new z.BitmapText(String(e), t));
811
+ super(), this.#e = this.addChild(new R.BitmapText(String(e), t));
781
812
  }
782
813
  set text(e) {
783
814
  this.#e.text = String(e);
@@ -788,7 +819,7 @@ var _e = class extends e {
788
819
  set tint(e) {
789
820
  this.#e.tint = e;
790
821
  }
791
- }, H = Symbol.for("E_PORT_CLICK"), U = Symbol.for("E_PORT_HOVER"), ke = class t extends z.Graphics {
822
+ }, H = Symbol.for("E_PORT_CLICK"), U = Symbol.for("E_PORT_HOVER"), Fe = class t extends R.Graphics {
792
823
  connectorPoint;
793
824
  hasBothLanes;
794
825
  static port = V.factory("nodePort", {
@@ -837,12 +868,12 @@ var _e = class extends e {
837
868
  x: n.x,
838
869
  y: n.y
839
870
  };
840
- }, Ae = (e) => e.__drag_root ? e : e.parent && Ae(e.parent);
841
- function je(e) {
871
+ }, Ie = (e) => e.__drag_root ? e : e.parent && Ie(e.parent);
872
+ function Le(e) {
842
873
  return function(t) {
843
874
  if (e.dispatchEvent(G, !0), t.buttons & 2) return;
844
875
  let n = this._drag_meta = {
845
- root: Ae(this.parent) || (() => {
876
+ root: Ie(this.parent) || (() => {
846
877
  throw Error("Can't find scene root");
847
878
  })(),
848
879
  emitter: e,
@@ -850,8 +881,8 @@ function je(e) {
850
881
  anchor: this.position.clone(),
851
882
  lastPosition: K(t),
852
883
  newPosition: K(t),
853
- onDragEnd: Ne(this),
854
- onDragMove: Me(this)
884
+ onDragEnd: ze(this),
885
+ onDragMove: Re(this)
855
886
  };
856
887
  n.root.addEventListener("pointerup", n.onDragEnd, {
857
888
  capture: !0,
@@ -865,18 +896,18 @@ function je(e) {
865
896
  });
866
897
  };
867
898
  }
868
- var Me = (e) => (t) => {
899
+ var Re = (e) => (t) => {
869
900
  if (!e._drag_meta?.dragging) return;
870
901
  let { newPosition: n, lastPosition: r, anchor: i, emitter: a } = e._drag_meta;
871
902
  K(t, n), n.x -= r.x, n.y -= r.y, a.dispatchEvent(W, {
872
903
  x: i.x + n.x,
873
904
  y: i.y + n.y
874
905
  });
875
- }, Ne = (e) => () => {
906
+ }, ze = (e) => () => {
876
907
  if (!e._drag_meta) return;
877
908
  let { root: t, emitter: n, onDragEnd: r, onDragMove: i } = e._drag_meta;
878
909
  t.removeEventListener("pointerup", r), t.removeEventListener("pointerupoutside", r), t.removeEventListener("pointermove", i), n.dispatchEvent(G, !1), delete e._drag_meta;
879
- }, q = Symbol.for("E_NODE_CONTEXT"), J = Symbol.for("E_CONNECTORS_UPDATE"), Pe = class t extends e {
910
+ }, q = Symbol.for("E_NODE_CONTEXT"), J = Symbol.for("E_CONNECTORS_UPDATE"), Be = class t extends e {
880
911
  static label = V.factory("nodeLabel", {
881
912
  fontSize: 24,
882
913
  align: "center",
@@ -887,7 +918,7 @@ var Me = (e) => (t) => {
887
918
  #e;
888
919
  #t;
889
920
  #n;
890
- #r = je(this);
921
+ #r = Le(this);
891
922
  data;
892
923
  find;
893
924
  ports = /* @__PURE__ */ new Map();
@@ -924,7 +955,7 @@ var Me = (e) => (t) => {
924
955
  #i({ connect: e, input: t, source: { port: n }, target: r }) {
925
956
  let i = this.connectors.find((e) => e.port === n && e.input === t);
926
957
  if (!i) return;
927
- j(e, i, r);
958
+ se(e, i, r);
928
959
  let a = this.ports.get(n);
929
960
  a && a.setActive(!!i.nodes.length);
930
961
  }
@@ -949,7 +980,7 @@ var Me = (e) => (t) => {
949
980
  input: !0,
950
981
  x: n.x,
951
982
  y: n.y,
952
- connector: new Se(r.x, r.y)
983
+ connector: new Oe(r.x, r.y)
953
984
  }), t++;
954
985
  }
955
986
  for (let t of this.data.outputs) this.#n.push({
@@ -1016,7 +1047,7 @@ var Me = (e) => (t) => {
1016
1047
  return o.eventMode = "static", o.addEventListener("pointerdown", (e) => this.handleClick(e)), o.x = this.data.position.x, o.y = this.data.position.y, this.#t = o;
1017
1048
  }
1018
1049
  makeRoundRect({ stroke: e, fill: t, x: n = 0, y: r = 0, width: i, height: a, thickness: o = 1, radius: s = 4 }) {
1019
- let c = new z.Graphics();
1050
+ let c = new R.Graphics();
1020
1051
  return c.lineStyle(o, e), c.beginFill(t), c.drawRoundedRect(0, 0, i, a, s), c.endFill(), c.x = n, c.y = r, c;
1021
1052
  }
1022
1053
  makeLane(e) {
@@ -1028,7 +1059,7 @@ var Me = (e) => (t) => {
1028
1059
  }, e));
1029
1060
  }
1030
1061
  makePort(e, t) {
1031
- let { port: n, x: r, y: i } = e, a = new ke(e, t);
1062
+ let { port: n, x: r, y: i } = e, a = new Fe(e, t);
1032
1063
  return this.ports.set(n, a), a.onClick((t) => {
1033
1064
  if (t.buttons & 2) return this.dispatchEvent(q, {
1034
1065
  event: t,
@@ -1093,13 +1124,13 @@ var Me = (e) => (t) => {
1093
1124
  }
1094
1125
  this.placeConnectors();
1095
1126
  }
1096
- }, Fe = {
1127
+ }, Ve = {
1097
1128
  x: 0,
1098
1129
  y: 0
1099
- }, Ie = (e, t) => e.cell.x === t.cell.x && e.cell.y === t.cell.y && e.count.x === t.count.x && e.count.y === t.count.y && e.size.width === t.size.width && e.size.height === t.size.height, Y = (e, t, n) => e > t ? e < n ? e : n : t, X = (e, t, n, r, i) => Y(e - t / 2, n + i, r - t - i), Le = (e) => {
1130
+ }, He = (e, t) => e.cell.x === t.cell.x && e.cell.y === t.cell.y && e.count.x === t.count.x && e.count.y === t.count.y && e.size.width === t.size.width && e.size.height === t.size.height, Y = (e, t, n) => e > t ? e < n ? e : n : t, X = (e, t, n, r, i) => Y(e - t / 2, n + i, r - t - i), Ue = (e) => {
1100
1131
  let t = Math.ceil(e);
1101
1132
  return t % 2 ? t + 1 : t;
1102
- }, Re = class e extends z.Graphics {
1133
+ }, We = class e extends R.Graphics {
1103
1134
  static text = V.factory("GridBoundary", {
1104
1135
  fontSize: 24,
1105
1136
  fill: 16777215,
@@ -1114,10 +1145,10 @@ var Me = (e) => (t) => {
1114
1145
  #n;
1115
1146
  #r;
1116
1147
  #i;
1117
- #a = new z.Rectangle(0, 0, 0, 0);
1148
+ #a = new R.Rectangle(0, 0, 0, 0);
1118
1149
  #o = {
1119
- cell: Fe,
1120
- count: Fe,
1150
+ cell: Ve,
1151
+ count: Ve,
1121
1152
  size: {
1122
1153
  width: 0,
1123
1154
  height: 0
@@ -1126,13 +1157,13 @@ var Me = (e) => (t) => {
1126
1157
  #s;
1127
1158
  #c;
1128
1159
  constructor(t, n, r = 5) {
1129
- super(), this.cellSize = t, this.colors = n, this.#e = r, this.#s = this.addChild(new z.Container()), this.#c = this.addChild(new z.Container()), this.#n = e.text("", { fontSize: 12 }), this.#t = e.text("", { fontSize: 12 }), this.#i = e.text("", { fontSize: 12 }), this.#r = e.text("", { fontSize: 12 });
1160
+ super(), this.cellSize = t, this.colors = n, this.#e = r, this.#s = this.addChild(new R.Container()), this.#c = this.addChild(new R.Container()), this.#n = e.text("", { fontSize: 12 }), this.#t = e.text("", { fontSize: 12 }), this.#i = e.text("", { fontSize: 12 }), this.#r = e.text("", { fontSize: 12 });
1130
1161
  }
1131
1162
  get lods() {
1132
1163
  return this.colors.length;
1133
1164
  }
1134
1165
  snapSize({ width: e, height: t }, n) {
1135
- let { x: r, y: i } = this.cellSize, a = n ? 2 ** (n - 1) * this.#e : 1, o = a * r, s = a * i, c = Le(e / o), l = Le(t / s);
1166
+ let { x: r, y: i } = this.cellSize, a = n ? 2 ** (n - 1) * this.#e : 1, o = a * r, s = a * i, c = Ue(e / o), l = Ue(t / s);
1136
1167
  return {
1137
1168
  cell: {
1138
1169
  x: o,
@@ -1154,24 +1185,24 @@ var Me = (e) => (t) => {
1154
1185
  viewport(e) {
1155
1186
  this.makeRullers(e);
1156
1187
  let t = this.toMaxSnap(this.#a), n = this.toMaxSnap(e);
1157
- this.#s.x = (e.left + e.width) % n.cell.x, this.#s.y = (e.top + e.height) % n.cell.y, !Ie(t, n) && (this.#a.copyFrom(e), this.#o = n, this.update());
1188
+ this.#s.x = (e.left + e.width) % n.cell.x, this.#s.y = (e.top + e.height) % n.cell.y, !He(t, n) && (this.#a.copyFrom(e), this.#o = n, this.update());
1158
1189
  }
1159
1190
  makeRullers(e) {
1160
1191
  this.#c.removeChildren();
1161
- let t = this.#c.addChild(new z.Graphics()), { left: n, top: r, width: i, height: a } = e, o = n + i, s = r + a, c = Y(o, 1, i - 1), l = Y(s, 1, a - 1);
1192
+ let t = this.#c.addChild(new R.Graphics()), { left: n, top: r, width: i, height: a } = e, o = n + i, s = r + a, c = Y(o, 1, i - 1), l = Y(s, 1, a - 1);
1162
1193
  t.lineStyle(2, 16711680, 1), t.moveTo(0, l), t.lineTo(i, l), t.moveTo(c, 0), t.lineTo(c, a), this.#c.addChild(this.#n, this.#t, this.#i, this.#r), this.#n.text = ~~(-(i + n) / this.cellSize.x), this.#i.text = ~~(-(a + r) / this.cellSize.y), this.#t.text = ~~(-n / this.cellSize.x), this.#r.text = ~~(-r / this.cellSize.y);
1163
1194
  let u = this.#n.height, d = this.#n.width, f = this.#t.width, p = this.#i.width, m = this.#r.width, h = X(l, u, 0, a, 2), g = X(c, p, d + 5, i - f - 5, 2), _ = X(c, m, d + 5, i - f - 5, 2);
1164
1195
  this.#n.x = 2, this.#n.y = h, this.#t.x = i - f - 2, this.#t.y = h, this.#i.x = g, this.#i.y = 2, this.#r.x = _, this.#r.y = a - u - 2;
1165
1196
  }
1166
1197
  makeLOD(e) {
1167
- let t = this.colors[e], { cell: { x: n, y: r }, count: { x: i, y: a }, size: { width: o, height: s } } = this.snapSize(this.#o.size, e), c = new z.Graphics();
1198
+ let t = this.colors[e], { cell: { x: n, y: r }, count: { x: i, y: a }, size: { width: o, height: s } } = this.snapSize(this.#o.size, e), c = new R.Graphics();
1168
1199
  c.lineStyle(.25 * (e + 1), t, 1);
1169
1200
  for (let e = 0; e < i; e++) c.moveTo(n * e, 0), c.lineTo(n * e, s);
1170
1201
  for (let e = 0; e < a; e++) c.moveTo(0, r * e), c.lineTo(o, r * e);
1171
1202
  return c;
1172
1203
  }
1173
1204
  makeGrid() {
1174
- let e = new z.Container();
1205
+ let e = new R.Container();
1175
1206
  for (let t of this.colors.keys()) e.addChild(this.makeLOD(t));
1176
1207
  return e;
1177
1208
  }
@@ -1183,7 +1214,7 @@ var Me = (e) => (t) => {
1183
1214
  i.x = n * e, i.y = r * t, this.#s.addChild(i);
1184
1215
  }
1185
1216
  }
1186
- }, ze = 24, Z = 12, Be = class e extends z.Container {
1217
+ }, Ge = 24, Z = 12, Ke = class e extends R.Container {
1187
1218
  static label = V.factory("menuItem", {
1188
1219
  fontSize: 24,
1189
1220
  align: "center",
@@ -1194,13 +1225,13 @@ var Me = (e) => (t) => {
1194
1225
  #n;
1195
1226
  #r;
1196
1227
  #i = 0;
1197
- #a = ze;
1228
+ #a = Ge;
1198
1229
  #o = !1;
1199
1230
  #s = !1;
1200
1231
  #c = !1;
1201
1232
  index;
1202
1233
  constructor(t, n, r) {
1203
- super(), this.index = t, this.#n = n, this.#s = !!n.separator, this.#r = !!n.group, this.#c = !!n.disabled || this.#r, this.#e = this.addChild(new z.Graphics()), this.#t = this.addChild(e.label(this.label, { fontSize: 12 })), this.eventMode = "static", this.addEventListener("pointerdown", (e) => {
1234
+ super(), this.index = t, this.#n = n, this.#s = !!n.separator, this.#r = !!n.group, this.#c = !!n.disabled || this.#r, this.#e = this.addChild(new R.Graphics()), this.#t = this.addChild(e.label(this.label, { fontSize: 12 })), this.eventMode = "static", this.addEventListener("pointerdown", (e) => {
1204
1235
  this.#c || (e.stopPropagation(), e.preventDefault(), r());
1205
1236
  });
1206
1237
  }
@@ -1241,7 +1272,7 @@ var Me = (e) => (t) => {
1241
1272
  let e = this.width, t = this.height, n = this.#e;
1242
1273
  this.separator ? (n.lineStyle(1, 1638, 1), n.moveTo(Z, 1), n.lineTo(e - Z, 1)) : this.#r ? (n.lineStyle(0, 0, 1), n.beginFill(3355443), n.drawRect(-1, 1, e + 2, t - 2), n.endFill()) : this.hover ? (n.lineStyle(0, 0, 1), n.beginFill(4473924), n.drawRoundedRect(0, 0, e, t, 4), n.endFill()) : n.clear(), this.#t.text = this.#n.label, this.#t.x = Z, this.#t.y = (t - this.#t.height) / 2, this.#t.alpha = this.#c && !this.#r ? .3 : 1, this.#t.tint = this.#r || this.hover ? 16777215 : 0;
1243
1274
  }
1244
- }, Ve = Symbol.for("E_ITEM_SELECT"), He = Symbol.for("E_CLOSE_MENU"), Ue = new z.Point(), We = class extends z.Container {
1275
+ }, qe = Symbol.for("E_ITEM_SELECT"), Je = Symbol.for("E_CLOSE_MENU"), Ye = new R.Point(), Xe = class extends R.Container {
1245
1276
  #e;
1246
1277
  #t;
1247
1278
  #n;
@@ -1249,8 +1280,8 @@ var Me = (e) => (t) => {
1249
1280
  #i;
1250
1281
  #a = -1;
1251
1282
  constructor(t) {
1252
- super(), this.#i = new e(), this.#n = this.addChild(new z.Graphics()), this.#e = this.addChild(new z.Graphics()), this.#t = this.addChild(new z.Container()), this.#r = t.items.map((e, t) => this.#t.addChild(new Be(t, e, () => this.handleSelect(e)))), this.#t.mask = this.#n, this.eventMode = "static", this.addEventListener("pointermove", (e) => {
1253
- this.hoverIndex = this.getItemAtY(e.getLocalPosition(this, Ue).y);
1283
+ super(), this.#i = new e(), this.#n = this.addChild(new R.Graphics()), this.#e = this.addChild(new R.Graphics()), this.#t = this.addChild(new R.Container()), this.#r = t.items.map((e, t) => this.#t.addChild(new Ke(t, e, () => this.handleSelect(e)))), this.#t.mask = this.#n, this.eventMode = "static", this.addEventListener("pointermove", (e) => {
1284
+ this.hoverIndex = this.getItemAtY(e.getLocalPosition(this, Ye).y);
1254
1285
  }), this.addEventListener("pointerleave", () => {
1255
1286
  this.hoverIndex = -1;
1256
1287
  }), this.update();
@@ -1272,16 +1303,16 @@ var Me = (e) => (t) => {
1272
1303
  n && (n.hover = t);
1273
1304
  }
1274
1305
  handleSelect(e) {
1275
- this.#i.dispatchEvent(Ve, e);
1306
+ this.#i.dispatchEvent(qe, e);
1276
1307
  }
1277
1308
  close() {
1278
- this.visible = !1, this.#i.dispatchEvent(He);
1309
+ this.visible = !1, this.#i.dispatchEvent(Je);
1279
1310
  }
1280
1311
  onSelect(e) {
1281
- return this.#i.handleEvent(Ve, e);
1312
+ return this.#i.handleEvent(qe, e);
1282
1313
  }
1283
1314
  onClose(e) {
1284
- return this.#i.handleEvent(He, e);
1315
+ return this.#i.handleEvent(Je, e);
1285
1316
  }
1286
1317
  get width() {
1287
1318
  return Math.max(...this.#r.map((e) => e.labelWidth));
@@ -1297,7 +1328,7 @@ var Me = (e) => (t) => {
1297
1328
  let i = 0;
1298
1329
  for (let t of this.#r) t.y = i, t.resize(e), i += t.height;
1299
1330
  }
1300
- }, Ge = class {
1331
+ }, Ze = class {
1301
1332
  ticker;
1302
1333
  nodes = /* @__PURE__ */ new Map();
1303
1334
  connectors = /* @__PURE__ */ new Map();
@@ -1321,7 +1352,7 @@ var Me = (e) => (t) => {
1321
1352
  #e = t(() => this.ticker.speed = .05, 1e3);
1322
1353
  #t = (e) => this.nodes.get(e);
1323
1354
  constructor({ maxFPS: e, grid: t, gui: n = [] }) {
1324
- this.ticker = new z.Ticker(), this.world = new z.Container(), this.root = new z.Container(), this.overlay = new z.Container(), this.grid = new Re(t.cellSize, t.colors), this.world.sortableChildren = !0, this.ticker.maxFPS = e, this.world.__drag_root = !0, this.gui = n, this.root.addChild(this.grid), this.root.addChild(this.world), this.root.addChild(this.overlay), this.root.addChild(...n), this.ticker.add(this.render.bind(this)), this.world.eventMode = "static", this.world.hitArea = { contains: () => !0 }, this.world.addEventListener("pointermove", (e) => {
1355
+ this.ticker = new R.Ticker(), this.world = new R.Container(), this.root = new R.Container(), this.overlay = new R.Container(), this.grid = new We(t.cellSize, t.colors), this.world.sortableChildren = !0, this.ticker.maxFPS = e, this.world.__drag_root = !0, this.gui = n, this.root.addChild(this.grid), this.root.addChild(this.world), this.root.addChild(this.overlay), this.root.addChild(...n), this.ticker.add(this.render.bind(this)), this.world.eventMode = "static", this.world.hitArea = { contains: () => !0 }, this.world.addEventListener("pointermove", (e) => {
1325
1356
  this.handlePointerMove(this.fromGlobal(e.global));
1326
1357
  }), this.world.addEventListener("pointerdown", (e) => {
1327
1358
  this.handlePointerDown(this.fromGlobal(e.global), e);
@@ -1333,7 +1364,7 @@ var Me = (e) => (t) => {
1333
1364
  get renderer() {
1334
1365
  if (!this._renderer) {
1335
1366
  let { viewport: e } = this.options;
1336
- this._renderer = (0, z.autoDetectRenderer)({
1367
+ this._renderer = (0, R.autoDetectRenderer)({
1337
1368
  width: e.width,
1338
1369
  height: e.height,
1339
1370
  antialias: e.antialias,
@@ -1387,7 +1418,7 @@ var Me = (e) => (t) => {
1387
1418
  this.closeMenu();
1388
1419
  let r = e.getMenu(t, n);
1389
1420
  if (r) {
1390
- let t = this.overlay.addChild(Object.assign(new We(r), n));
1421
+ let t = this.overlay.addChild(Object.assign(new Xe(r), n));
1391
1422
  return t.onSelect((t) => {
1392
1423
  !1 !== e.handleMenu(t.data) && this.closeMenu();
1393
1424
  }), t.onClose(() => {
@@ -1397,7 +1428,7 @@ var Me = (e) => (t) => {
1397
1428
  }
1398
1429
  addNode(e) {
1399
1430
  if (this.#t(e.id)) return;
1400
- let t = new Pe(e, this.#t);
1431
+ let t = new Be(e, this.#t);
1401
1432
  t.onMove((t) => {
1402
1433
  this._pending || this.moveNodeTo(e.id, t);
1403
1434
  }), t.onCapture((t) => {
@@ -1414,7 +1445,7 @@ var Me = (e) => (t) => {
1414
1445
  t && (this.connectNodes(t), this.pending = null);
1415
1446
  return;
1416
1447
  }
1417
- this.pending = new Oe(e);
1448
+ this.pending = new Pe(e);
1418
1449
  }
1419
1450
  }), t.onPortHover((e) => this.pending?.hoverPort(e)), t.onConnectorsUpdate(({ add: e, remove: t }) => {
1420
1451
  if (e) for (let { uid: t, connector: n } of e) this.addConnector(t, n);
@@ -1516,7 +1547,7 @@ var Me = (e) => (t) => {
1516
1547
  }
1517
1548
  updateViewport() {
1518
1549
  let { width: e, height: t, translation: { x: n, y: r } } = this;
1519
- e && t && this.grid.viewport(new z.Rectangle(n - e / 2, r - t / 2, e, t));
1550
+ e && t && this.grid.viewport(new R.Rectangle(n - e / 2, r - t / 2, e, t));
1520
1551
  }
1521
1552
  render() {
1522
1553
  this.renderer?.render(this.root);
@@ -1524,7 +1555,7 @@ var Me = (e) => (t) => {
1524
1555
  update() {
1525
1556
  this.ticker.update();
1526
1557
  }
1527
- }, Ke = "\nPort:\n LMB - start connecting\n LMB + (Meta | Ctrl) - start disconnecting\nCanvas:\n LMB + Shift - drag while connecting/disconnecting", Q = class e extends z.Container {
1558
+ }, Qe = "\nPort:\n LMB - start connecting\n LMB + (Meta | Ctrl) - start disconnecting\nCanvas:\n LMB + Shift - drag while connecting/disconnecting", Q = class e extends R.Container {
1528
1559
  static text = V.factory("GUIText", {
1529
1560
  fontSize: 16,
1530
1561
  align: "left",
@@ -1539,7 +1570,7 @@ var Me = (e) => (t) => {
1539
1570
  ] });
1540
1571
  static makeText = (e) => this.text(e, { fontSize: 8 });
1541
1572
  #e;
1542
- #t = new z.Text("ℹ️", {
1573
+ #t = new R.Text("ℹ️", {
1543
1574
  fontSize: 8,
1544
1575
  lineHeight: 14
1545
1576
  });
@@ -1547,7 +1578,7 @@ var Me = (e) => (t) => {
1547
1578
  #r = !1;
1548
1579
  #i = "";
1549
1580
  #a;
1550
- constructor(e, t = Ke) {
1581
+ constructor(e, t = Qe) {
1551
1582
  super(), this.#a = t, this.addChild(this.#t), this.addChild(this.#n), this.#t.eventMode = "static", this.#t.addEventListener("pointerdown", () => this.legend = !this.legend), this.#n.x = 8, this.#n.y = 8, this.#e = e;
1552
1583
  }
1553
1584
  getMenu(e, t) {
@@ -1571,7 +1602,7 @@ var Me = (e) => (t) => {
1571
1602
  set legend(e) {
1572
1603
  this.#r = e, this.#n.text = this.#i + (this.#r ? this.#a : "");
1573
1604
  }
1574
- }, qe = class extends z.Container {
1605
+ }, $e = class extends R.Container {
1575
1606
  first;
1576
1607
  constructor(e, ...t) {
1577
1608
  super(), this.first = e, this.addChild(e, ...t);
@@ -1579,7 +1610,7 @@ var Me = (e) => (t) => {
1579
1610
  hotSwap(...e) {
1580
1611
  this.removeChildren(), this.addChild(this.first, ...e);
1581
1612
  }
1582
- }, Je = class extends z.Graphics {
1613
+ }, et = class extends R.Graphics {
1583
1614
  #e;
1584
1615
  #t;
1585
1616
  constructor(e) {
@@ -1599,26 +1630,26 @@ var Me = (e) => (t) => {
1599
1630
  }
1600
1631
  };
1601
1632
  O(/* @__PURE__ */ E({
1602
- Batch: () => _e,
1633
+ Batch: () => z,
1603
1634
  E_CONNECTORS_UPDATE: () => J,
1604
1635
  E_NODE_CONTEXT: () => q,
1605
1636
  LANE_HEIGHT: () => 16,
1606
1637
  LANE_WIDTH: () => 16,
1607
1638
  PIXIGUI: () => Q,
1608
- PIXINode: () => Pe,
1609
- PIXIOutlined: () => Je,
1610
- PIXIRenderer: () => Ge,
1611
- PIXIStacked: () => qe,
1639
+ PIXINode: () => Be,
1640
+ PIXIOutlined: () => et,
1641
+ PIXIRenderer: () => Ze,
1642
+ PIXIStacked: () => $e,
1612
1643
  PORT_SIZE: () => 8,
1613
- RectSpinner: () => xe
1614
- }), z);
1644
+ RectSpinner: () => De
1645
+ }), R);
1615
1646
  //#endregion
1616
1647
  //#region src/graph/GraphAdapter.ts
1617
- var Ye = class extends _e {
1648
+ var tt = class extends z {
1618
1649
  renderer;
1619
1650
  nodes = [];
1620
1651
  constructor(e) {
1621
- super(), this.renderer = new Ge(e), this.and(() => this.renderer.render());
1652
+ super(), this.renderer = new Ze(e), this.and(() => this.renderer.render());
1622
1653
  }
1623
1654
  [Symbol.iterator]() {
1624
1655
  return this.nodes[Symbol.iterator]();
@@ -1681,7 +1712,7 @@ var Ye = class extends _e {
1681
1712
  };
1682
1713
  //#endregion
1683
1714
  //#region src/graph/NodeGroups.tsx
1684
- function Xe(e, t) {
1715
+ function nt(e, t) {
1685
1716
  let n = [];
1686
1717
  for (let r of e) {
1687
1718
  let e = t(r);
@@ -1697,23 +1728,23 @@ function Xe(e, t) {
1697
1728
  getAll: () => [r]
1698
1729
  };
1699
1730
  }
1700
- var Ze = (e, t) => {
1731
+ var rt = (e, t) => {
1701
1732
  let n = e.length;
1702
1733
  if (n !== t.length) return !1;
1703
1734
  for (let r = 0; r < n; r++) if (e[r] !== t[r]) return !1;
1704
1735
  return !0;
1705
- }, Qe = (e) => {
1736
+ }, it = (e) => {
1706
1737
  let t = e.map(String);
1707
1738
  return (e) => t.includes(String(e.value));
1708
- }, $e = (e, t) => e.every((e) => t.some((t) => t.value === e.value)) && Ze(e.flatMap(tt), t.flatMap(tt)), et = (e) => e.value, tt = (e) => e.ids, $ = v(function({ items: e, resolver: t, onSelect: n, children: r, ...a }) {
1709
- let { groups: c, getAll: u } = s(() => Xe(e, t), [e, t]), [d, f] = l(u), p = s(() => d.map((e) => String(e.value)), [d]), h = m(({ target: { selectedOptions: e } }) => {
1710
- let t = c.filter(Qe(Array.from(e, et)));
1739
+ }, at = (e, t) => e.every((e) => t.some((t) => t.value === e.value)) && rt(e.flatMap(ot), t.flatMap(ot)), $ = (e) => e.value, ot = (e) => e.ids, st = v(function({ items: e, resolver: t, onSelect: n, children: r, ...a }) {
1740
+ let { groups: c, getAll: u } = s(() => nt(e, t), [e, t]), [d, f] = l(u), p = s(() => d.map((e) => String(e.value)), [d]), h = m(({ target: { selectedOptions: e } }) => {
1741
+ let t = c.filter(it(Array.from(e, $)));
1711
1742
  t && f(t);
1712
1743
  });
1713
1744
  return i(() => void n(d), [d, n]), o(() => {
1714
- let e = c.filter(Qe(d.map(et)));
1745
+ let e = c.filter(it(d.map($)));
1715
1746
  if (e) {
1716
- if ($e(e, d)) return;
1747
+ if (at(e, d)) return;
1717
1748
  f(e);
1718
1749
  } else f(u);
1719
1750
  }, [
@@ -1731,8 +1762,8 @@ var Ze = (e, t) => {
1731
1762
  children: t
1732
1763
  }, String(e)))]
1733
1764
  });
1734
- }), nt = v(({ ref: e, handlers: t, onResize: n, ...r }) => {
1735
- let [o, s] = h(), { bind: c, reset: l } = R(t);
1765
+ }), ct = v(({ ref: e, handlers: t, onResize: n, ...r }) => {
1766
+ let [o, s] = h(), { bind: c, reset: l } = ge(t);
1736
1767
  return a(e, () => ({
1737
1768
  reset: l,
1738
1769
  get element() {
@@ -1745,31 +1776,19 @@ var Ze = (e, t) => {
1745
1776
  });
1746
1777
  }, [o, n]), /* @__PURE__ */ y("div", {
1747
1778
  ref: s,
1748
- style: rt.root,
1779
+ style: lt.root,
1749
1780
  children: /* @__PURE__ */ y("div", {
1750
- style: rt.root,
1781
+ style: lt.root,
1751
1782
  ...c,
1752
1783
  ...r
1753
1784
  })
1754
1785
  });
1755
- }), rt = u.of({ root: {
1786
+ }), lt = u.of({ root: {
1756
1787
  flex: 1,
1757
1788
  display: "flex",
1758
1789
  minWidth: 0,
1759
1790
  minHeight: 0
1760
- } }), it = v(({ onSelect: e, ...t }) => /* @__PURE__ */ y($, {
1761
- resolver: at,
1762
- onSelect: m((t) => e(t.ids)),
1763
- ...t
1764
- })), at = (e) => {
1765
- if (!e.item.isolator) return;
1766
- let t = [e.id];
1767
- return {
1768
- value: e.id,
1769
- label: e.title,
1770
- ids: t
1771
- };
1772
- }, ot = (e, t, { onEdit: n, onConnect: r, onMove: i, onAddPort: a, onDisconnectPort: o, onDeletePort: s, onDelete: c, onSelect: l, onContextMenu: u } = {}) => ({
1791
+ } }), ut = (e, t, { onEdit: n, onConnect: r, onMove: i, onAddPort: a, onDisconnectPort: o, onDeletePort: s, onDelete: c, onSelect: l, onContextMenu: u } = {}) => ({
1773
1792
  canvas: {
1774
1793
  onSelectNode: (t, n) => l?.(t?.item || null, e.toData(n)),
1775
1794
  onContextMenu: (t, n) => u?.(t?.item || null, e.toData(n))
@@ -1799,11 +1818,23 @@ var Ze = (e, t) => {
1799
1818
  onDeletePort: async (e, t) => s?.(e.item, t),
1800
1819
  onDelete: async (e) => c?.(e.item)
1801
1820
  }
1802
- }), st = {
1821
+ }), dt = v(({ onSelect: e, ...t }) => /* @__PURE__ */ y(st, {
1822
+ resolver: ft,
1823
+ onSelect: m((t) => e(t.ids)),
1824
+ ...t
1825
+ })), ft = (e) => {
1826
+ if (!e.item.isolator) return;
1827
+ let t = [e.id];
1828
+ return {
1829
+ value: e.id,
1830
+ label: e.title,
1831
+ ids: t
1832
+ };
1833
+ }, pt = {
1803
1834
  x: 0,
1804
1835
  y: 0
1805
- }, ct = v(function({ innerRef: e, nodes: t, subset: n, coordinator: r, layouter: l, menu: u, onSelectNode: d, onContextMenu: f, ...p }) {
1806
- let h = c(st), g = c(null), _ = s(() => new Q(u), [u]), v = s(() => new Ye({
1836
+ }, mt = v(function({ innerRef: e, nodes: t, subset: n, coordinator: r, layouter: l, menu: u, onSelectNode: d, onContextMenu: f, ...p }) {
1837
+ let h = c(pt), g = c(null), _ = s(() => new Q(u), [u]), v = s(() => new tt({
1807
1838
  maxFPS: 120,
1808
1839
  grid: {
1809
1840
  cellSize: r.gridSize,
@@ -1868,15 +1899,15 @@ var Ze = (e, t) => {
1868
1899
  antialias: !0,
1869
1900
  transparent: !1
1870
1901
  } });
1871
- }, [v]), /* @__PURE__ */ y(nt, {
1902
+ }, [v]), /* @__PURE__ */ y(ct, {
1872
1903
  ref: g,
1873
1904
  handlers: D,
1874
1905
  onResize: b,
1875
1906
  ...p
1876
1907
  });
1877
- }), lt = (e, { onEdit: t, onMove: n, onConnect: r, onDelete: i, onAddPort: a, onDisconnectPort: o, onDeletePort: s }) => {
1908
+ }), ht = (e, { onEdit: t, onMove: n, onConnect: r, onDelete: i, onAddPort: a, onDisconnectPort: o, onDeletePort: s }) => {
1878
1909
  e.onConnect(r), e.onMove((t) => n(e, t)), e.onEditAction(() => t(e)), e.onDeleteAction(() => i(e)), e.onAddPortAction((t) => a(e, t)), e.onDisconnectPortAction(({ port: t }) => o(e, t)), e.onDeletePortAction(({ port: t }) => s(e, t));
1879
- }, ut = (e, t, { added: n, removed: r }) => {
1910
+ }, gt = (e, t, { added: n, removed: r }) => {
1880
1911
  if (n.length) {
1881
1912
  let r = n.reduce((e, t) => (e[t.id] = t, e), {}), i = (t) => r[t] || e.find((e) => e.id === t);
1882
1913
  for (let e of n) {
@@ -1900,11 +1931,11 @@ var Ze = (e, t) => {
1900
1931
  }
1901
1932
  }
1902
1933
  }
1903
- if (t) for (let e of n) lt(e, t);
1934
+ if (t) for (let e of n) ht(e, t);
1904
1935
  e.add(n);
1905
1936
  }
1906
1937
  if (r.length) for (let t of r) e.remove(t);
1907
- }, dt = () => [{
1938
+ }, _t = () => [{
1908
1939
  label: "Add node",
1909
1940
  items: [{
1910
1941
  label: "+ Call",
@@ -1959,13 +1990,13 @@ var Ze = (e, t) => {
1959
1990
  }
1960
1991
  }
1961
1992
  ]
1962
- }], ft = (e, t) => ({
1993
+ }], vt = (e, t) => ({
1963
1994
  getMenu(t, n) {
1964
1995
  let r = {
1965
1996
  action: "add",
1966
1997
  ...e.toData(n)
1967
1998
  };
1968
- return { items: dt().map(({ label: e, items: t }) => [{
1999
+ return { items: _t().map(({ label: e, items: t }) => [{
1969
2000
  label: e,
1970
2001
  group: !0
1971
2002
  }, ...t.map(({ label: e, data: t, ...n }) => ({
@@ -1984,7 +2015,7 @@ var Ze = (e, t) => {
1984
2015
  return;
1985
2016
  }
1986
2017
  }
1987
- }), pt = (e, t) => {
2018
+ }), yt = (e, t) => {
1988
2019
  let n = c([]);
1989
2020
  p(() => {
1990
2021
  let i = t?.filter((e) => !n.current.some(r(e.id))), a = n.current.filter((e) => !t?.some(r(e.id)));
@@ -1992,8 +2023,8 @@ var Ze = (e, t) => {
1992
2023
  if (i) for (let { id: t } of i) e.find(r(t))?.setSelected(!0);
1993
2024
  n.current = t || [];
1994
2025
  }, [t, e]);
1995
- }, mt = (e) => e.startsWith("channel_"), ht = (e) => mt(e) ? e.slice(8) : "", gt = (e) => ({ id: t, name: n, input: r, to: i, port: a }) => {
1996
- let o = ht(n);
2026
+ }, bt = (e) => e.startsWith("channel_"), xt = (e) => bt(e) ? e.slice(8) : "", St = (e) => ({ id: t, name: n, input: r, to: i, port: a }) => {
2027
+ let o = xt(n);
1997
2028
  o && (n = `${r ? "> " : ""}@${o}${r ? "" : " >"}`);
1998
2029
  let s = [];
1999
2030
  if (i) {
@@ -2008,11 +2039,11 @@ var Ze = (e, t) => {
2008
2039
  name: n,
2009
2040
  nodes: s
2010
2041
  };
2011
- }, _t = /* @__PURE__ */ function(e) {
2042
+ }, Ct = /* @__PURE__ */ function(e) {
2012
2043
  return e[e.Idle = 1] = "Idle", e[e.Processing = 2] = "Processing", e[e.Done = 4] = "Done", e[e.Error = 8] = "Error", e[e.Selected = 16] = "Selected", e;
2013
- }({}), vt = /* @__PURE__ */ function(e) {
2044
+ }({}), wt = /* @__PURE__ */ function(e) {
2014
2045
  return e[e.EDIT_NODE = 1] = "EDIT_NODE", e[e.ADD_PORT = 2] = "ADD_PORT", e[e.DISCONNECT_PORT = 3] = "DISCONNECT_PORT", e[e.DELETE_PORT = 4] = "DELETE_PORT", e[e.DELETE_NODE = 5] = "DELETE_NODE", e;
2015
- }({}), yt = class extends ie {
2046
+ }({}), Tt = class extends N {
2016
2047
  #e;
2017
2048
  #t;
2018
2049
  constructor({ finder: e, item: t, coordinator: n, toTitle: r }) {
@@ -2023,8 +2054,8 @@ var Ze = (e, t) => {
2023
2054
  progress: 0,
2024
2055
  id: t.id,
2025
2056
  title: r(t),
2026
- inputs: t.ports.filter(({ input: e }) => !!e).map(gt(e)),
2027
- outputs: t.ports.filter(({ input: e }) => !e).map(gt(e))
2057
+ inputs: t.ports.filter(({ input: e }) => !!e).map(St(e)),
2058
+ outputs: t.ports.filter(({ input: e }) => !e).map(St(e))
2028
2059
  }), this.position = this.coordinator.toGraph(t);
2029
2060
  }
2030
2061
  dispose() {
@@ -2145,13 +2176,13 @@ var Ze = (e, t) => {
2145
2176
  }
2146
2177
  render(e) {
2147
2178
  let t = e.width - 1, n = e.height - 1;
2148
- return this.#t ? this.#t.hotSwap(e) : this.#t = new qe(new Je({
2179
+ return this.#t ? this.#t.hotSwap(e) : this.#t = new $e(new et({
2149
2180
  width: t,
2150
2181
  height: n,
2151
2182
  color: 3407871,
2152
2183
  lineSize: 1,
2153
2184
  radius: 6
2154
- }), e), this.#t.first.active = this.isSelected, this.#e ? this.#e.hotSwap(this.#t) : this.#e = new xe(this.#t, {
2185
+ }), e), this.#t.first.active = this.isSelected, this.#e ? this.#e.hotSwap(this.#t) : this.#e = new De(this.#t, {
2155
2186
  sizeX: t,
2156
2187
  sizeY: n,
2157
2188
  color: 3355647,
@@ -2159,15 +2190,15 @@ var Ze = (e, t) => {
2159
2190
  radius: 6
2160
2191
  }), this.#e.setActive(this.isInProgress), this.#e;
2161
2192
  }
2162
- }, bt = ({ coordinator: e, sync: t, onUpdate: n, store: r, toTitle: i }) => {
2193
+ }, Et = ({ coordinator: e, sync: t, onUpdate: n, store: r, toTitle: i }) => {
2163
2194
  let a = c(t), o = s(() => ({
2164
2195
  subscribe: (e) => r.onChange(e),
2165
2196
  getSnapshot: () => r.get(),
2166
2197
  selector: (e) => e.sort((e, t) => e.id.localeCompare(t.id)),
2167
- is: I
2198
+ is: L
2168
2199
  }), [r]), l = _(o.subscribe, o.getSnapshot, o.getSnapshot, o.selector, o.is), u = g(l), d = m((e) => l.find((t) => t.id === e));
2169
2200
  a.current = t, p(() => {
2170
- let t = (t) => new yt({
2201
+ let t = (t) => new Tt({
2171
2202
  finder: d,
2172
2203
  item: t,
2173
2204
  coordinator: e,
@@ -2184,90 +2215,60 @@ var Ze = (e, t) => {
2184
2215
  removed: []
2185
2216
  });
2186
2217
  }, [l, i]), p(() => x(() => l, n), []);
2187
- }, xt = class {
2188
- grid;
2189
- gridSize;
2190
- sizes;
2191
- constructor({ grid: e = 16, port: t = 8, lane: n = 16, space: r = 32 } = {}) {
2192
- this.grid = e, this.gridSize = {
2193
- x: e,
2194
- y: e
2195
- }, this.sizes = {
2196
- grid: this.gridSize,
2197
- port: t,
2198
- lane: n,
2199
- space: r
2200
- };
2201
- }
2202
- snap(e) {
2203
- let t = e < 0 ? -1 : 1;
2204
- return t * (Math.round(t * e / this.grid + .5) - .5) * this.grid;
2205
- }
2206
- toGraph({ x: e, y: t }) {
2207
- return {
2208
- x: (e - .5) * this.grid,
2209
- y: (t - .5) * this.grid
2210
- };
2211
- }
2212
- toData({ x: e, y: t }) {
2213
- return {
2214
- x: ~~(this.snap(e) / this.grid + .5),
2215
- y: ~~(this.snap(t) / this.grid + .5)
2216
- };
2217
- }
2218
- }, St = v(({ innerRef: e, graph: t, selected: n, sizes: r, handlers: i, children: o, onExport: u, ...f }) => {
2219
- let p = c(null), h = s(() => new xt(r), [r]), g = ft(h, i?.onCreate), [_, v] = L(() => new F()), [x, S] = l(), { canvas: C, loader: w } = ot(h, _, i), T = m(() => u?.(t));
2218
+ }, Dt = v(({ innerRef: e, graph: t, layouter: n, selected: r, sizes: i, handlers: o, children: u, onExport: f, ...p }) => {
2219
+ let h = c(null), g = s(() => new ie(i), [i]), _ = vt(g, o?.onCreate), [v, x] = he(() => new I()), [S, C] = l(), { canvas: w, loader: T } = ut(g, v, o), E = m(() => f?.(t));
2220
2220
  return a(e, () => ({
2221
2221
  get graph() {
2222
- return p.current?.graph;
2222
+ return h.current?.graph;
2223
2223
  },
2224
2224
  get element() {
2225
- return p.current?.element;
2225
+ return h.current?.element;
2226
2226
  }
2227
- })), bt({
2227
+ })), Et({
2228
2228
  store: s(() => {
2229
- let e = new F(t.items);
2229
+ let e = new I(t.items);
2230
2230
  return {
2231
2231
  items: e,
2232
2232
  get: () => e.all,
2233
2233
  onChange: (t) => e.onChange(t)
2234
2234
  };
2235
2235
  }, [t.items]),
2236
- coordinator: h,
2236
+ coordinator: g,
2237
2237
  toTitle: (e) => e.title,
2238
- sync: (e) => ut(_, w, e),
2238
+ sync: (e) => gt(v, T, e),
2239
2239
  onUpdate: () => e?.current?.graph.layout()
2240
- }), pt(v, n), /* @__PURE__ */ b("div", {
2240
+ }), yt(x, r), /* @__PURE__ */ b("div", {
2241
2241
  onContextMenu: d,
2242
- style: Ct.root,
2243
- ...f,
2242
+ style: Ot.root,
2243
+ ...p,
2244
2244
  children: [/* @__PURE__ */ b("div", {
2245
- style: Ct.selector,
2245
+ style: Ot.selector,
2246
2246
  children: [
2247
- o,
2248
- /* @__PURE__ */ y(it, {
2249
- items: v,
2250
- onSelect: S
2247
+ u,
2248
+ /* @__PURE__ */ y(dt, {
2249
+ items: x,
2250
+ onSelect: C
2251
2251
  }),
2252
2252
  /* @__PURE__ */ y("button", {
2253
- onClick: () => S(void 0),
2253
+ onClick: () => C(void 0),
2254
2254
  children: "Update"
2255
2255
  }),
2256
- u && /* @__PURE__ */ y("button", {
2257
- onClick: T,
2256
+ f && /* @__PURE__ */ y("button", {
2257
+ onClick: E,
2258
2258
  children: "Export"
2259
2259
  })
2260
2260
  ]
2261
- }), /* @__PURE__ */ y(ct, {
2262
- innerRef: p,
2263
- coordinator: h,
2264
- nodes: v,
2265
- subset: x,
2266
- menu: g,
2267
- ...C
2261
+ }), /* @__PURE__ */ y(mt, {
2262
+ innerRef: h,
2263
+ coordinator: g,
2264
+ layouter: n,
2265
+ nodes: x,
2266
+ subset: S,
2267
+ menu: _,
2268
+ ...w
2268
2269
  })]
2269
2270
  });
2270
- }), Ct = u.of({
2271
+ }), Ot = u.of({
2271
2272
  root: {
2272
2273
  flex: 1,
2273
2274
  display: "flex",
@@ -2281,6 +2282,6 @@ var Ze = (e, t) => {
2281
2282
  }
2282
2283
  });
2283
2284
  //#endregion
2284
- export { oe as ClusteredLayout, ce as EdgesSort, Ye as GraphAdapter, ct as GraphCanvas, ie as GraphNode, M as GraphNodeJoints, ae as LayeredLayout, le as Layouter, St as ManagedGraph, yt as ManagedGraphNode, vt as MenuActions, $ as NodeGroups, _t as NodeStatus, N as NodesGraph, se as NodesSort, Q as PIXIGUI, F as Store, nt as Viewport, ht as getChannelName, mt as isChannelName, I as isEqualIdentifiables, R as useDraggable, L as useStore };
2285
+ export { de as ClusteredLayout, ie as Coordinates, pe as EdgesSort, ee as GRID_SIZE, tt as GraphAdapter, mt as GraphCanvas, N as GraphNode, j as GraphNodeJoints, ne as LANE_SIZE, ue as LayeredLayout, me as Layouter, Dt as ManagedGraph, Tt as ManagedGraphNode, wt as MenuActions, st as NodeGroups, Ct as NodeStatus, P as NodesGraph, fe as NodesSort, Q as PIXIGUI, te as PORT_SIZE, re as SPACE_SIZE, I as Store, ct as Viewport, xt as getChannelName, ae as groupResolver, bt as isChannelName, L as isEqualIdentifiables, ge as useDraggable, he as useStore };
2285
2286
 
2286
2287
  //# sourceMappingURL=index.js.map