@dynamix-layout/core 1.2.0 → 2.0.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.
package/dist/core.es.js DELETED
@@ -1,1381 +0,0 @@
1
- class g {
2
- buffer;
3
- head = 0;
4
- tail = 0;
5
- count = 0;
6
- capacity;
7
- constructor(t = 16, e = []) {
8
- this.capacity = Math.max(t, e.length), this.buffer = new Array(this.capacity), e.forEach((n) => {
9
- this.enqueue(n);
10
- });
11
- }
12
- enqueue(t) {
13
- this.count === this.capacity && this.resize(), this.buffer[this.tail] = t, this.tail = (this.tail + 1) % this.capacity, this.count++;
14
- }
15
- enqueueFront(t) {
16
- this.count === this.capacity && this.resize(), this.head = (this.head - 1 + this.capacity) % this.capacity, this.buffer[this.head] = t, this.count++;
17
- }
18
- insert(t, e) {
19
- if (t < 0 || t > this.count)
20
- return !1;
21
- if (t === 0)
22
- return this.enqueueFront(e), !0;
23
- if (t === this.count)
24
- return this.enqueue(e), !0;
25
- this.count === this.capacity && this.resize();
26
- const n = t, i = this.count - t;
27
- return n <= i ? this.shiftLeft(t, e) : this.shiftRight(t, e), this.count++, !0;
28
- }
29
- insertArray(t, e) {
30
- if (t < 0 || t > this.count)
31
- return !1;
32
- if (e.length === 0)
33
- return !0;
34
- if (t === 0) {
35
- for (let r = e.length - 1; r >= 0; r--)
36
- this.enqueueFront(e[r]);
37
- return !0;
38
- }
39
- if (t === this.count)
40
- return e.forEach((r) => this.enqueue(r)), !0;
41
- for (; this.count + e.length > this.capacity; )
42
- this.resize();
43
- const n = t, i = this.count - t, s = e.length;
44
- return n <= i ? this.shiftLeftArray(t, e) : this.shiftRightArray(t, e), this.count += s, !0;
45
- }
46
- insertQueue(t, e) {
47
- if (t < 0 || t > this.count)
48
- return !1;
49
- if (e.isEmpty())
50
- return !0;
51
- const n = e.size();
52
- if (t === 0) {
53
- const h = e.toArray();
54
- for (let u = h.length - 1; u >= 0; u--)
55
- this.enqueueFront(h[u]);
56
- return !0;
57
- }
58
- if (t === this.count) {
59
- for (const h of e)
60
- this.enqueue(h);
61
- return !0;
62
- }
63
- for (; this.count + n > this.capacity; )
64
- this.resize();
65
- const i = e.toArray(), s = t, r = this.count - t;
66
- return s <= r ? this.shiftLeftArray(t, i) : this.shiftRightArray(t, i), this.count += n, !0;
67
- }
68
- push(t) {
69
- this.enqueue(t);
70
- }
71
- unshift(t) {
72
- this.enqueueFront(t);
73
- }
74
- dequeue() {
75
- if (this.count === 0)
76
- return;
77
- const t = this.buffer[this.head];
78
- return this.head = (this.head + 1) % this.capacity, this.count--, t;
79
- }
80
- dequeueBack() {
81
- if (this.count === 0)
82
- return;
83
- this.tail = (this.tail - 1 + this.capacity) % this.capacity;
84
- const t = this.buffer[this.tail];
85
- return this.count--, t;
86
- }
87
- indexOf(t) {
88
- for (let e = 0; e < this.count; e++) {
89
- const n = (this.head + e) % this.capacity;
90
- if (this.buffer[n] === t)
91
- return e;
92
- }
93
- return -1;
94
- }
95
- remove(t) {
96
- const e = this.indexOf(t);
97
- return e === -1 ? !1 : (this.removeAt(e), !0);
98
- }
99
- removeAt(t) {
100
- if (t < 0 || t >= this.count)
101
- return;
102
- if (t === 0)
103
- return this.dequeue();
104
- if (t === this.count - 1)
105
- return this.dequeueBack();
106
- const e = (this.head + t) % this.capacity, n = this.buffer[e], i = t, s = this.count - t - 1;
107
- return i <= s ? this.shiftRightForRemoval(t) : this.shiftLeftForRemoval(t), this.count--, n;
108
- }
109
- shift() {
110
- return this.dequeue();
111
- }
112
- pop() {
113
- return this.dequeueBack();
114
- }
115
- fifoAdd(t) {
116
- this.enqueue(t);
117
- }
118
- fifoRemove() {
119
- return this.dequeue();
120
- }
121
- filoAdd(t) {
122
- this.enqueue(t);
123
- }
124
- filoRemove() {
125
- return this.dequeueBack();
126
- }
127
- lifoAdd(t) {
128
- this.enqueueFront(t);
129
- }
130
- lifoRemove() {
131
- return this.dequeue();
132
- }
133
- liloAdd(t) {
134
- this.enqueueFront(t);
135
- }
136
- liloRemove() {
137
- return this.dequeueBack();
138
- }
139
- get(t) {
140
- if (t < 0 || t >= this.count)
141
- return;
142
- const e = (this.head + t) % this.capacity;
143
- return this.buffer[e];
144
- }
145
- set(t, e) {
146
- if (t < 0 || t >= this.count)
147
- return !1;
148
- const n = (this.head + t) % this.capacity;
149
- return this.buffer[n] = e, !0;
150
- }
151
- peek() {
152
- return this.count > 0 ? this.buffer[this.head] : void 0;
153
- }
154
- peekBack() {
155
- if (this.count === 0) return;
156
- const t = (this.tail - 1 + this.capacity) % this.capacity;
157
- return this.buffer[t];
158
- }
159
- front() {
160
- return this.peek();
161
- }
162
- back() {
163
- return this.peekBack();
164
- }
165
- size() {
166
- return this.count;
167
- }
168
- getCapacity() {
169
- return this.capacity;
170
- }
171
- isEmpty() {
172
- return this.count === 0;
173
- }
174
- isFull() {
175
- return this.count === this.capacity;
176
- }
177
- clear() {
178
- this.head = 0, this.tail = 0, this.count = 0;
179
- }
180
- toArray() {
181
- const t = [];
182
- for (let e = 0; e < this.count; e++) {
183
- const n = (this.head + e) % this.capacity;
184
- t.push(this.buffer[n]);
185
- }
186
- return t;
187
- }
188
- *[Symbol.iterator]() {
189
- for (let t = 0; t < this.count; t++) {
190
- const e = (this.head + t) % this.capacity;
191
- yield this.buffer[e];
192
- }
193
- }
194
- *forward() {
195
- for (let t = 0; t < this.count; t++) {
196
- const e = (this.head + t) % this.capacity;
197
- yield this.buffer[e];
198
- }
199
- }
200
- *reverse() {
201
- for (let t = this.count - 1; t >= 0; t--) {
202
- const e = (this.head + t) % this.capacity;
203
- yield this.buffer[e];
204
- }
205
- }
206
- *entries() {
207
- for (let t = 0; t < this.count; t++) {
208
- const e = (this.head + t) % this.capacity;
209
- yield [t, this.buffer[e]];
210
- }
211
- }
212
- *keys() {
213
- for (let t = 0; t < this.count; t++)
214
- yield t;
215
- }
216
- *values() {
217
- for (let t = 0; t < this.count; t++) {
218
- const e = (this.head + t) % this.capacity;
219
- yield this.buffer[e];
220
- }
221
- }
222
- toString() {
223
- return `Queue(${this.toArray().join(", ")})`;
224
- }
225
- resize() {
226
- const t = this.capacity * 2, e = new Array(t);
227
- for (let n = 0; n < this.count; n++) {
228
- const i = (this.head + n) % this.capacity;
229
- e[n] = this.buffer[i];
230
- }
231
- this.buffer = e, this.capacity = t, this.head = 0, this.tail = this.count;
232
- }
233
- shiftLeft(t, e) {
234
- this.head = (this.head - 1 + this.capacity) % this.capacity;
235
- for (let i = 0; i < t; i++) {
236
- const s = (this.head + 1 + i) % this.capacity, r = (this.head + i) % this.capacity;
237
- this.buffer[r] = this.buffer[s];
238
- }
239
- const n = (this.head + t) % this.capacity;
240
- this.buffer[n] = e;
241
- }
242
- shiftRight(t, e) {
243
- for (let i = this.count - 1; i >= t; i--) {
244
- const s = (this.head + i) % this.capacity, r = (this.head + i + 1) % this.capacity;
245
- this.buffer[r] = this.buffer[s];
246
- }
247
- const n = (this.head + t) % this.capacity;
248
- this.buffer[n] = e, this.tail = (this.tail + 1) % this.capacity;
249
- }
250
- shiftRightForRemoval(t) {
251
- for (let e = t; e > 0; e--) {
252
- const n = (this.head + e - 1) % this.capacity, i = (this.head + e) % this.capacity;
253
- this.buffer[i] = this.buffer[n];
254
- }
255
- this.head = (this.head + 1) % this.capacity;
256
- }
257
- shiftLeftForRemoval(t) {
258
- for (let e = t; e < this.count - 1; e++) {
259
- const n = (this.head + e + 1) % this.capacity, i = (this.head + e) % this.capacity;
260
- this.buffer[i] = this.buffer[n];
261
- }
262
- this.tail = (this.tail - 1 + this.capacity) % this.capacity;
263
- }
264
- shiftLeftArray(t, e) {
265
- const n = e.length;
266
- this.head = (this.head - n + this.capacity) % this.capacity;
267
- for (let i = 0; i < t; i++) {
268
- const s = (this.head + n + i) % this.capacity, r = (this.head + i) % this.capacity;
269
- this.buffer[r] = this.buffer[s];
270
- }
271
- for (let i = 0; i < n; i++) {
272
- const s = (this.head + t + i) % this.capacity;
273
- this.buffer[s] = e[i];
274
- }
275
- }
276
- shiftRightArray(t, e) {
277
- const n = e.length;
278
- for (let i = this.count - 1; i >= t; i--) {
279
- const s = (this.head + i) % this.capacity, r = (this.head + i + n) % this.capacity;
280
- this.buffer[r] = this.buffer[s];
281
- }
282
- for (let i = 0; i < n; i++) {
283
- const s = (this.head + t + i) % this.capacity;
284
- this.buffer[s] = e[i];
285
- }
286
- this.tail = (this.tail + n) % this.capacity;
287
- }
288
- }
289
- function T(o, t = (e, n) => e === n) {
290
- let e = o;
291
- const n = /* @__PURE__ */ new Set();
292
- let i = [];
293
- const s = () => e, r = (l, m = !1) => {
294
- if (m) {
295
- e = l;
296
- return;
297
- }
298
- t(e, l) || (e = l, n.forEach((p) => p(e)), i.forEach((p) => p(e)), i = []);
299
- }, h = () => {
300
- n.forEach((l) => l(e)), i.forEach((l) => l(e)), i = [];
301
- }, u = (l) => (n.add(l), () => n.delete(l)), f = () => new Promise((l) => {
302
- i.push(l);
303
- });
304
- return {
305
- get: s,
306
- set: r,
307
- onChange: u,
308
- nextChange: f,
309
- triggerChange: h,
310
- onChangePromise: (l) => {
311
- let m = !0;
312
- return (async () => {
313
- for (; m; ) {
314
- const I = await f();
315
- if (!m) break;
316
- l(I);
317
- }
318
- })(), () => {
319
- m = !1;
320
- };
321
- }
322
- };
323
- }
324
- function E(o, t) {
325
- if (o.size !== t.size) return !1;
326
- for (const [e, n] of o.entries()) {
327
- const i = t.get(e);
328
- if (!i || !C(n, i))
329
- return !1;
330
- }
331
- return !0;
332
- }
333
- function C(o, t) {
334
- if (o.typNode !== t.typNode || o.nodName !== t.nodName || o.uidNode !== t.uidNode || o.nodPart !== t.nodPart || o.nodFold !== t.nodFold || o.nodMaxd !== t.nodMaxd || o.nodHidden !== t.nodHidden || o.nodLocked !== t.nodLocked) return !1;
335
- const e = o.nodDims, n = t.nodDims;
336
- return e.x === n.x && e.y === n.y && e.w === n.w && e.h === n.h;
337
- }
338
- const D = () => crypto.randomUUID(), O = {
339
- set: (o, t) => setTimeout(o, t),
340
- clear: (o) => clearTimeout(o)
341
- }, c = {
342
- createId: D,
343
- timer: O,
344
- root: void 0,
345
- tree: null,
346
- minW: 40,
347
- minH: 40,
348
- bond: 10,
349
- inst: null,
350
- maximized: null,
351
- collapsedSize: 40,
352
- foldSeq: 0
353
- };
354
- class a {
355
- static cache = {
356
- dimMins: /* @__PURE__ */ new Map(),
357
- mapDirs: /* @__PURE__ */ new Map(),
358
- tabCnts: /* @__PURE__ */ new Map(),
359
- mapElem: /* @__PURE__ */ new Map(),
360
- tabOpts: T(
361
- /* @__PURE__ */ new Map(),
362
- E
363
- ),
364
- nodOpts: T(
365
- /* @__PURE__ */ new Map(),
366
- E
367
- ),
368
- bndOpts: T(
369
- /* @__PURE__ */ new Map(),
370
- E
371
- )
372
- };
373
- kids = new g();
374
- dims = { w: 0, h: 0, x: 0, y: 0 };
375
- unId;
376
- next = null;
377
- prev = null;
378
- type = "row";
379
- name = "";
380
- part = 0;
381
- host = null;
382
- open = "";
383
- collapsed = !1;
384
- foldedAt = 0;
385
- constructor(t = {}) {
386
- const e = {
387
- type: "row",
388
- host: null,
389
- name: "",
390
- part: 100,
391
- dims: { w: 0, h: 0, x: 0, y: 0 },
392
- unId: c.createId(),
393
- open: ""
394
- };
395
- this.type = t.type ?? e.type, this.host = t.host ?? e.host, this.name = t.name ?? e.name, this.part = t.part ?? e.part, this.dims = t.dims ?? e.dims, this.open = t.open ?? e.open, this.unId = t.unId || e.unId;
396
- }
397
- addBond(t, e = null) {
398
- if (!e) return;
399
- const n = new A(t, this, e);
400
- a.cache.mapElem.set(n.unId, n);
401
- }
402
- getReqDimension() {
403
- const t = a.cache.dimMins.get(this.unId), e = a.cache.tabCnts.get(this.unId), n = Math.max(
404
- t.minWidth,
405
- e.horizontal * c.minW + Math.max(0, e.horizontal - 1) * c.bond
406
- ), i = Math.max(
407
- t.minHeight,
408
- e.vertical * c.minH + Math.max(0, e.vertical - 1) * c.bond
409
- );
410
- return {
411
- width: n,
412
- height: i
413
- };
414
- }
415
- calcDimensions() {
416
- const t = a.cache.mapDirs.get(this.unId);
417
- if (!this.kids) return;
418
- let e = 0;
419
- const n = a.cache.dimMins.get(this.unId) || {
420
- minWidth: 0,
421
- minHeight: 0
422
- };
423
- let i = 0, s;
424
- for (const d of this.kids)
425
- d.collapsed || (e += d.part, s = d);
426
- if (e === 0) return;
427
- let r;
428
- t ? r = this.dims.w - n.minWidth : r = this.dims.h - n.minHeight;
429
- const h = r < 0;
430
- let u = 0, f = 0;
431
- for (const d of this.kids) {
432
- const l = a.cache.dimMins.get(d.unId) || {
433
- minWidth: 0,
434
- minHeight: 0
435
- };
436
- let m = 0;
437
- if (!h && !d.collapsed) {
438
- u += d.part;
439
- const p = d === s ? r : Math.round(r * u / e);
440
- m = p - f, f = p;
441
- }
442
- t ? (d.dims.w = l.minWidth + m, d.dims.h = this.dims.h, d.dims.x = this.dims.x + i, d.dims.y = this.dims.y, i += d.dims.w + c.bond) : (d.dims.h = l.minHeight + m, d.dims.w = this.dims.w, d.dims.y = this.dims.y + i, d.dims.x = this.dims.x, i += d.dims.h + c.bond), d.next && (t ? d.next.dims = {
443
- w: c.bond,
444
- h: d.dims.h,
445
- x: d.dims.x + d.dims.w,
446
- y: d.dims.y
447
- } : d.next.dims = {
448
- w: d.dims.w,
449
- h: c.bond,
450
- x: d.dims.x,
451
- y: d.dims.y + d.dims.h
452
- });
453
- }
454
- }
455
- toJSON() {
456
- const t = [];
457
- for (const n of this.kids)
458
- t.push(n.toJSON());
459
- const e = {
460
- typNode: this.type,
461
- nodPart: this.part,
462
- nodName: this.name,
463
- uidNode: this.unId
464
- };
465
- return this.open && (e.nodOpen = this.open), this.collapsed && (e.nodFold = !0), this === c.root && c.maximized && (e.nodMaxd = c.maximized), t.length > 0 && (e.nodKids = t), e;
466
- }
467
- }
468
- class A {
469
- dims = { w: 0, h: 0, x: 0, y: 0 };
470
- unId = c.createId();
471
- next = null;
472
- prev = null;
473
- host = null;
474
- constructor(t = null, e = null, n = null) {
475
- this.host = t, this.next = e, this.prev = n, this.next && (this.next.prev = this), this.prev && (this.prev.next = this);
476
- }
477
- toJSON() {
478
- return {
479
- nodName: this.host?.name || "",
480
- typNode: "bond",
481
- uidNode: this.unId,
482
- nodPart: 0,
483
- nodOpen: "",
484
- nodKids: []
485
- };
486
- }
487
- }
488
- function* W(o) {
489
- const t = new g();
490
- for (t.enqueue(o); !t.isEmpty(); ) {
491
- const e = t.dequeue();
492
- if (e && (yield e, e.nodKids && e.nodKids.length > 0))
493
- for (const n of e.nodKids)
494
- t.enqueue(n);
495
- }
496
- }
497
- function* L(o) {
498
- const t = new g();
499
- for (t.enqueue(o); !t.isEmpty(); ) {
500
- const e = t.dequeue();
501
- if (e && (a.cache.mapElem.set(e.unId, e), yield e, e.kids.size() > 0))
502
- for (const n of e.kids)
503
- t.enqueue(n);
504
- }
505
- }
506
- function* P(o, t) {
507
- for (const e of t.kids)
508
- yield* o.NodeLayoutRecursiveIterator(e);
509
- yield t;
510
- }
511
- function K(o, t) {
512
- const e = a.cache.mapDirs.get(t.unId);
513
- if (e === void 0) {
514
- console.warn(
515
- `Cannot update child directions for node ${t.unId}; its own direction is not set.`
516
- );
517
- return;
518
- }
519
- for (const n of t.kids)
520
- a.cache.mapDirs.set(n.unId, !e), n.kids.size() > 0 && (n.host = t, o.updateChildDirections(n), n.next && a.cache.mapDirs.set(n.next.unId, !e));
521
- }
522
- function U(o, t = c.tree) {
523
- if (!t) return;
524
- const e = o.JSONLayoutIterator(t), n = o.NodeLayoutIterator(c.root);
525
- for (a.cache.mapDirs.set(c.root.unId, !0); ; ) {
526
- const i = e.next(), s = n.next();
527
- if (i.done || s.done)
528
- break;
529
- const r = i.value, h = s.value;
530
- !r || !h || o.createNodeTreeFromJSONTree(r, h);
531
- }
532
- o.calcTabsetCountAndMinDim();
533
- }
534
- function $(o, t, e) {
535
- const n = a.cache.mapDirs.get(e.unId);
536
- for (const i of t.nodKids || []) {
537
- const s = o.createNodeFromJSON(i), r = e.kids.peekBack();
538
- s.host = e, s.addBond(s.host, r), e.kids.enqueue(s), a.cache.mapDirs.set(s.unId, !n);
539
- }
540
- e.type === "tabset" && a.cache.mapElem.set(e.unId, e), e.type === "tab" && a.cache.mapElem.set(e.unId, e);
541
- }
542
- function _(o, t, e = c.root) {
543
- const n = new g();
544
- for (n.enqueue(e), a.cache.mapDirs.set(c.root.unId, !0); !t.isEmpty(); ) {
545
- const i = n.dequeue();
546
- if (!i)
547
- break;
548
- const s = a.cache.mapDirs.get(i.unId);
549
- if (t.size() === 1) {
550
- const d = t.dequeue(), l = new a({ type: "tabset", host: i }), m = new a({
551
- type: "tab",
552
- host: l,
553
- name: d,
554
- unId: o.tabsIds.get(d ?? "") ?? c.createId()
555
- });
556
- l.open = m.name, l.kids.enqueue(m), i.kids.enqueue(l), a.cache.mapDirs.set(l.unId, !s), a.cache.mapDirs.set(m.unId, s), a.cache.mapElem.set(l.unId, l), a.cache.mapElem.set(m.unId, m);
557
- break;
558
- }
559
- if (t.size() == 2) {
560
- const d = t.dequeue(), l = t.dequeue(), m = new a({ type: "tabset", host: i }), p = new a({ type: "tabset", host: i }), I = new a({
561
- type: "tab",
562
- host: m,
563
- name: d,
564
- unId: o.tabsIds.get(d ?? "") ?? c.createId()
565
- }), y = new a({
566
- type: "tab",
567
- host: p,
568
- name: l,
569
- unId: o.tabsIds.get(l ?? "") ?? c.createId()
570
- });
571
- m.open = I.name, p.open = y.name, m.kids.enqueue(I), p.kids.enqueue(y), i.kids.enqueue(m), i.kids.enqueue(p), p.addBond(i, m), a.cache.mapDirs.set(m.unId, !s), a.cache.mapDirs.set(p.unId, !s), a.cache.mapElem.set(m.unId, m), a.cache.mapElem.set(p.unId, p), a.cache.mapDirs.set(I.unId, s), a.cache.mapDirs.set(y.unId, s), a.cache.mapElem.set(I.unId, I), a.cache.mapElem.set(y.unId, y);
572
- break;
573
- }
574
- const r = t.dequeue(), h = new a({ type: "tabset", host: i }), u = new a({ type: "row", host: i }), f = new a({
575
- type: "tab",
576
- host: h,
577
- name: r,
578
- unId: o.tabsIds.get(r ?? "") ?? c.createId()
579
- });
580
- h.open = f.name, h.kids.enqueue(f), i.kids.enqueue(h), i.kids.enqueue(u), u.addBond(i, h), a.cache.mapDirs.set(h.unId, !s), a.cache.mapDirs.set(u.unId, !s), a.cache.mapElem.set(h.unId, h), a.cache.mapDirs.set(f.unId, s), a.cache.mapElem.set(f.unId, f), n.enqueue(u);
581
- }
582
- o.calcTabsetCountAndMinDim();
583
- }
584
- function Y(o, t) {
585
- const e = new a({
586
- type: t.typNode,
587
- name: t.nodName,
588
- unId: t.uidNode,
589
- part: t.nodPart,
590
- dims: { w: 0, h: 0, x: 0, y: 0 },
591
- open: typeof t.nodOpen == "string" ? t.nodOpen : ""
592
- });
593
- return e.collapsed = t.typNode === "tabset" && t.nodFold === !0, t.typNode === "tab" && (e.unId = o.tabsIds.get(t.nodName) || t.uidNode), e;
594
- }
595
- function N(o) {
596
- const t = a.cache.mapElem.get(o);
597
- return t instanceof a && t.type === "tabset" ? t : null;
598
- }
599
- function G(o = c.root) {
600
- let t = 0;
601
- const e = (n) => {
602
- n.type === "tabset" && t++;
603
- for (const i of n.kids) e(i);
604
- };
605
- return e(o), t;
606
- }
607
- function v(o) {
608
- return o.type === "tabset" && !!o.host && o.host.kids.size() > 1;
609
- }
610
- function S() {
611
- return G() > 1;
612
- }
613
- function R() {
614
- const o = c.maximized;
615
- return o ? N(o) : null;
616
- }
617
- function H(o, t) {
618
- let e = null;
619
- for (const n of o.kids)
620
- n === t || !n.collapsed || (!e || n.foldedAt > e.foldedAt) && (e = n);
621
- e && (e.collapsed = !1);
622
- }
623
- function J(o = c.root) {
624
- let t = !1;
625
- const e = (n) => {
626
- n.type === "tabset" && (n.unId === c.maximized && (t = !0), n.collapsed && !v(n) && (n.collapsed = !1)), n.type !== "tab" && n.kids.size() > 0 && [...n.kids].every((s) => s.collapsed) && H(n);
627
- for (const i of n.kids) e(i);
628
- };
629
- e(o), t || (c.maximized = null);
630
- }
631
- function M(o, t) {
632
- return !N(t) || !S() || c.maximized === t ? !1 : (c.maximized = t, o.calcDimensions(), !0);
633
- }
634
- function z(o) {
635
- return c.maximized ? (c.maximized = null, o.calcDimensions(), !0) : !1;
636
- }
637
- function Q(o, t) {
638
- return c.maximized === t ? z(o) : M(o, t);
639
- }
640
- function q(o, t) {
641
- const e = N(t);
642
- if (!e || e.collapsed || !v(e)) return !1;
643
- c.maximized = null, e.collapsed = !0, e.foldedAt = ++c.foldSeq;
644
- const n = e.host;
645
- return [...n.kids].every((i) => i.collapsed) && H(n, e), o.calcTabsetCountAndMinDim(), o.calcDimensions(), !0;
646
- }
647
- function F(o, t) {
648
- const e = N(t);
649
- return !e || !e.collapsed ? !1 : (e.collapsed = !1, o.calcTabsetCountAndMinDim(), o.calcDimensions(), !0);
650
- }
651
- function j(o, t) {
652
- const e = N(t);
653
- return e ? e.collapsed ? F(o, t) : q(o, t) : !1;
654
- }
655
- function V(o, t = c.root, e = !0) {
656
- t === c.root && e && (J(t), a.cache.tabCnts.clear(), a.cache.dimMins.clear(), a.cache.mapElem.clear(), a.cache.nodOpts.get().clear(), a.cache.bndOpts.get().clear());
657
- for (const n of o.NodeLayoutRecursiveIterator(t)) {
658
- const i = a.cache.tabCnts, s = a.cache.dimMins;
659
- a.cache.mapElem.set(n.unId, n);
660
- const r = i.set(n.unId, {
661
- horizontal: 0,
662
- vertical: 0
663
- }).get(n.unId), h = s.set(n.unId, {
664
- minWidth: 0,
665
- minHeight: 0
666
- }).get(n.unId), u = a.cache.mapDirs.get(n.unId);
667
- if (n.type === "tab" && (a.cache.mapElem.set(n.unId, n), s.set(n.unId, {
668
- minWidth: 0,
669
- minHeight: 0
670
- })), n.next && a.cache.mapElem.set(n.next.unId, n.next), n.type === "tabset" && (a.cache.mapElem.set(n.unId, n), s.set(n.unId, {
671
- minWidth: c.minW,
672
- minHeight: c.minH
673
- }), u ? i.set(n.unId, {
674
- horizontal: 0,
675
- vertical: 1
676
- }) : i.set(n.unId, {
677
- horizontal: 1,
678
- vertical: 0
679
- }), n.collapsed && n.host && (a.cache.mapDirs.get(n.host.unId) ? (s.set(n.unId, {
680
- minWidth: c.collapsedSize,
681
- minHeight: c.minH
682
- }), i.get(n.unId).horizontal = 0) : (s.set(n.unId, {
683
- minWidth: c.minW,
684
- minHeight: c.collapsedSize
685
- }), i.get(n.unId).vertical = 0))), n.type === "row") {
686
- for (const f of n.kids) {
687
- const d = i.get(f.unId), l = s.get(f.unId);
688
- d && (r.horizontal += d.horizontal, r.vertical += d.vertical, u ? (h.minHeight = Math.max(
689
- h.minHeight,
690
- l.minHeight
691
- ), h.minWidth += l.minWidth) : (h.minHeight += l.minHeight, h.minWidth = Math.max(
692
- h.minWidth,
693
- l.minWidth
694
- )));
695
- }
696
- u ? h.minWidth += (n.kids.size() - 1) * c.bond : h.minHeight += (n.kids.size() - 1) * c.bond;
697
- }
698
- }
699
- t === c.root && e && o.pruneStaleDirections();
700
- }
701
- function X() {
702
- for (const o of a.cache.mapDirs.keys())
703
- a.cache.mapElem.has(o) || a.cache.mapDirs.delete(o);
704
- }
705
- function Z() {
706
- const o = c.root.getReqDimension();
707
- let t = !1, e = c.root.dims.w, n = c.root.dims.h;
708
- return c.root.dims.w < o.width && (e = o.width, t = !0), c.root.dims.h < o.height && (n = o.height, t = !0), t && (c.root.dims.w = e, c.root.dims.h = n), {
709
- adjustedW: e,
710
- adjustedH: n,
711
- wasAdjusted: t
712
- };
713
- }
714
- function tt(o, t = c.root, e = !1) {
715
- const n = t === c.root, i = (d) => n ? /* @__PURE__ */ new Map() : new Map(d.get()), s = i(a.cache.nodOpts), r = i(a.cache.bndOpts), h = i(a.cache.tabOpts);
716
- n && o.calculateRootAdjustment();
717
- const u = R(), f = S();
718
- for (const d of o.NodeLayoutIterator(t)) {
719
- d.calcDimensions();
720
- const l = a.cache.mapDirs.get(d.unId);
721
- if (d.type === "tabset") {
722
- const m = d === u, p = !!u && !m, I = m ? { ...c.root.dims } : { ...d.dims }, y = {
723
- typNode: d.type,
724
- nodName: d.name,
725
- uidNode: d.unId,
726
- nodPart: d.part,
727
- nodOpen: d.open,
728
- nodeDir: l,
729
- nodFold: d.collapsed && !m,
730
- nodMaxd: m,
731
- nodHidden: p,
732
- nodFoldable: v(d),
733
- nodMaximizable: f,
734
- nodKids: Array.from(d.kids).map((b) => {
735
- const k = {
736
- typNode: b.type,
737
- nodName: b.name,
738
- uidNode: b.unId,
739
- nodPart: b.part,
740
- nodOpen: d.open === b.name,
741
- nodeDir: !l,
742
- nodHidden: p,
743
- nodFold: d.collapsed && !m,
744
- nodDims: { ...I }
745
- };
746
- return h.set(b.unId, k), k;
747
- }),
748
- nodDims: I
749
- };
750
- s.set(d.unId, y);
751
- }
752
- if (d.next && d.type !== "tab") {
753
- const m = {
754
- typNode: "bond",
755
- nodName: d.name,
756
- uidNode: d.next.unId,
757
- nodeDir: l,
758
- nodPart: 0,
759
- nodHidden: !!u,
760
- nodLocked: d.collapsed || !!d.next.next?.collapsed,
761
- nodDims: {
762
- ...d.next.dims
763
- }
764
- };
765
- r.set(d.next.unId, m);
766
- }
767
- }
768
- a.cache.nodOpts.set(s, e), a.cache.bndOpts.set(r, e), a.cache.tabOpts.set(h, e);
769
- }
770
- function et(o, t, e = !1, n = 2) {
771
- if (c.root.dims = t, e) {
772
- o.calcDimensions(c.root);
773
- return;
774
- }
775
- o.cntdown && (c.timer.clear(o.cntdown), o.cntdown = null), o.cntdown = c.timer.set(() => {
776
- o.cntdown = null, o.calcDimensions();
777
- }, n);
778
- }
779
- function nt(o, t, e, n = !1, i = 2) {
780
- if (n) {
781
- o.updateSliderDimension(t, e);
782
- return;
783
- }
784
- o.cntdown && (c.timer.clear(o.cntdown), o.cntdown = null), o.cntdown = c.timer.set(() => {
785
- o.cntdown = null, o.updateSliderDimension(t, e);
786
- }, i);
787
- }
788
- function it(o, t, e) {
789
- const n = a.cache.mapElem.get(t);
790
- if (!n || !(n instanceof A)) {
791
- console.warn(`Bond with id ${t} not found or is not a Bond instance`);
792
- return;
793
- }
794
- const i = a.cache.mapDirs.get(n.host.unId), s = n.prev, r = n.next, h = n.host;
795
- if (!s || !r || !h) {
796
- console.warn("Missing prev, next, or host node", s, r, h);
797
- return;
798
- }
799
- if (s.collapsed || r.collapsed || c.maximized)
800
- return;
801
- const u = a.cache.dimMins.get(s.unId) || {
802
- minWidth: 0,
803
- minHeight: 0
804
- }, f = a.cache.dimMins.get(r.unId) || {
805
- minWidth: 0,
806
- minHeight: 0
807
- }, d = c.bond / 2;
808
- if (i) {
809
- const l = r.dims.x + r.dims.w, m = s.dims.x + u.minWidth + d, p = l - f.minWidth - d, I = Math.max(m, Math.min(p, e.x));
810
- n.dims.x = I - d, s.dims.w = n.dims.x - s.dims.x, r.dims.x = I + d, r.dims.w = l - r.dims.x;
811
- const y = Math.max(0, s.dims.w - u.minWidth), b = Math.max(0, r.dims.w - f.minWidth), k = y + b, x = s.part + r.part;
812
- k > 0 ? (s.part = y / k * x, r.part = b / k * x) : (s.part = x / 2, r.part = x / 2);
813
- } else {
814
- const l = r.dims.y + r.dims.h, m = s.dims.y + u.minHeight + d, p = l - f.minHeight - d, I = Math.max(m, Math.min(p, e.y));
815
- n.dims.y = I - d, s.dims.h = n.dims.y - s.dims.y, r.dims.y = I + d, r.dims.h = l - r.dims.y;
816
- const y = Math.max(0, s.dims.h - u.minHeight), b = Math.max(0, r.dims.h - f.minHeight), k = y + b, x = s.part + r.part;
817
- k > 0 ? (s.part = y / k * x, r.part = b / k * x) : (s.part = x / 2, r.part = x / 2);
818
- }
819
- o.calcDimensions(h);
820
- }
821
- function ot(o, t, e, n) {
822
- const i = a.cache.mapElem.get(t);
823
- let s = a.cache.mapElem.get(e);
824
- return !i || !(i instanceof a) || !s || !(s instanceof a) ? (console.warn(`Source node ${t} not found or is not a Node instance`), !1) : i?.type == "tab" && i.host === s && s.kids.size() < 2 ? (console.warn("Cannot move to self as it has only one tab"), !1) : i?.type == "tabset" && s?.host === i ? (console.warn("Cannot move tabset to self as it is already a child"), !1) : !i || !s ? (console.warn(`Source or destination node not found: ${t}, ${e}`), !1) : i === s ? (console.warn(
825
- "Source and destination nodes are the same, no action taken."
826
- ), !1) : !i.host || !s.host && s.type !== "row" ? (console.warn(
827
- `Source node or destination node's host is null: ${i.unId}, ${s.unId}`
828
- ), !1) : s.type === "row" && s !== c.root ? (console.warn(`Cannot move relative to a nested row: ${s.unId}`), !1) : s.type === "row" && n === "contain" ? (console.warn(
829
- `Cannot move to a row with 'contain' layout: ${s.unId}`
830
- ), !1) : i.type === "row" || (s.type === "tabset" && n === "contain" && (s = s.kids.peekBack() || s), i === s) ? !1 : o.isOnlyContent(i) ? (console.warn("Cannot move the only tabset or tab in the layout"), !1) : (c.maximized = null, i.collapsed = !1, s.type === "tab" && (n === "contain" || n === "left" || n === "right") ? o.moveNodeAsTab(i, s, n) : s.type === "row" && n !== "contain" ? o.moveRelativeToRoot(i, s, n) : s.type === "tabset" && n !== "contain" && o.moveRelativeToTabset(i, s, n), o.calcTabsetCountAndMinDim(), o.calcDimensions(c.root, !0), !0);
831
- }
832
- function st(o, t) {
833
- let e = 0;
834
- for (const n of o.NodeLayoutRecursiveIterator(c.root))
835
- n.type === "tabset" && e++;
836
- return e !== 1 ? !1 : t.type === "tabset" || t.type === "tab" && t.host?.kids.size() === 1;
837
- }
838
- function at(o, t, e, n) {
839
- if (!e || !e.host) {
840
- console.warn(`Destination node ${e.unId} has no host, cannot move.`);
841
- return;
842
- }
843
- o.removeNode(t);
844
- const i = e.host, s = i.kids.indexOf(e);
845
- if (s === void 0 || s === -1)
846
- return;
847
- const r = n === "contain" || n === "left", h = r ? s : s + 1, u = i.kids.get(h + 1), f = i.kids.get(h - 1), d = e.next, l = e.prev;
848
- if (!r && d ? a.cache.mapElem.delete(d.unId) : r && l && a.cache.mapElem.delete(l.unId), t.type == "tab")
849
- r ? (f && t.addBond(i, f), e.addBond(i, t)) : (t.addBond(i, e), u && u.addBond(i, t)), i.kids.insert(h, t), t.host = i, i.open = t.name, i.collapsed = !1;
850
- else if (t.type == "tabset") {
851
- const m = t.kids.peek(), p = t.kids.peekBack();
852
- r ? (m && f && m.addBond(i, f), p && e && e.addBond(i, p)) : (m && e && m.addBond(i, e), p && u && u.addBond(i, p)), i.kids.insertQueue(h, t.kids);
853
- for (const I of t.kids)
854
- I.host = i, I.next && (I.next.host = i);
855
- i.open = p ? p.name : "", i.collapsed = !1;
856
- }
857
- o.updateChildDirections(i);
858
- }
859
- const rt = {
860
- root: (o, t) => o === t,
861
- tabset: (o, t) => o !== t
862
- };
863
- function B(o, t, e, n, i) {
864
- if (o.removeNode(t), t.type !== "tab" && t.type !== "tabset") return;
865
- const s = a.cache.mapDirs.get(e.unId) === !1, r = n === "left" || n === "right", h = n === "top" || n === "left";
866
- let u = t;
867
- t.type === "tab" && (u = new a({ type: "tabset", host: e.host }), u.kids.enqueue(t), u.open = t.name, t.host = u), rt[i](s, r) ? o.insertNodeWithNewParent(u, e, h) : o.insertNode(e, u, h);
868
- }
869
- function dt(o, t, e, n) {
870
- B(o, t, e, n, "root");
871
- }
872
- function ct(o, t, e, n) {
873
- B(o, t, e, n, "tabset");
874
- }
875
- function ht(o, t, e, n) {
876
- const i = t.host;
877
- if (t == c.root) {
878
- const l = c.root.kids.peek(), m = c.root.kids.peekBack();
879
- n ? (c.root.kids.enqueueFront(e), l && l.addBond(c.root, e)) : (c.root.kids.enqueue(e), m && e.addBond(c.root, m)), e.host = c.root, o.updateChildDirections(c.root);
880
- return;
881
- }
882
- if (!i) {
883
- console.warn(`Destination node ${t.unId} has no host, cannot insert.`);
884
- return;
885
- }
886
- const s = i.kids.indexOf(t);
887
- if (s === -1) {
888
- console.warn(
889
- `Destination node ${t.unId} not found in its host's kids.`
890
- );
891
- return;
892
- }
893
- const r = a.cache.mapDirs.get(i.unId);
894
- r && a.cache.mapDirs.set(e.unId, !r);
895
- const h = i.kids.get(s + 1), u = i.kids.get(s - 1), f = t.next, d = t.prev;
896
- e.host = i, n ? (i.kids.insert(s, e), t.addBond(i, e), u && e.addBond(i, u), d && a.cache.mapElem.delete(d.unId)) : (i.kids.insert(s + 1, e), e.addBond(i, t), h && h.addBond(i, e), f && a.cache.mapElem.delete(f.unId)), o.updateChildDirections(i);
897
- }
898
- function ut(o, t, e, n) {
899
- const i = new g(), s = new a({ type: "tabset", host: e.host });
900
- if (!e || !t) {
901
- console.warn(`Destination node ${e.unId} has no host, cannot insert.`);
902
- return;
903
- }
904
- if (e === c.root) {
905
- const h = new a({ type: "row", host: e });
906
- if (e.kids.size() === 0)
907
- e.kids.enqueue(t), t.host = e;
908
- else if (e.kids.size() == 1 && e.kids.peek()?.type === "tabset") {
909
- const u = e.kids.dequeue();
910
- if (!u) {
911
- console.warn(
912
- `No kid found in destination node ${e.unId}, cannot insert.`
913
- );
914
- return;
915
- }
916
- n ? (h.kids.enqueue(t), h.kids.enqueue(u), e.kids.enqueue(h), u.addBond(h, t)) : (h.kids.enqueue(u), h.kids.enqueue(t), t.addBond(h, u), e.kids.enqueue(h)), t.host = h, u.host = h;
917
- } else if (e.kids.size() == 1 && e.kids.peek()?.type === "row") {
918
- const u = e.kids.peek(), f = u?.kids.peek(), d = u?.kids.peekBack();
919
- n && u ? (u.kids.enqueueFront(t), f && f.addBond(u, t)) : u && (u.kids.enqueue(t), d && t.addBond(u, d)), t.host = u;
920
- } else if (e.kids.size() > 1) {
921
- const u = new a({ type: "row", host: e }), f = new a({ type: "row", host: u });
922
- for (const d of e.kids)
923
- f.kids.enqueue(d), d.host = f, d.next && (d.next.host = f);
924
- t.host = u, e.kids.clear(), n ? (u.kids.enqueueFront(t), u.kids.enqueue(f), f.addBond(u, t)) : (u.kids.enqueue(f), u.kids.enqueue(t), t.addBond(u, f)), e.kids.enqueue(u);
925
- }
926
- o.updateChildDirections(e);
927
- return;
928
- }
929
- t.host = e, s.host = e, s.kids = e.kids, s.open = e.open;
930
- const r = a.cache.mapDirs.get(e.unId);
931
- for (const h of s.kids)
932
- h.host = s, h.next && (h.next.host = s), a.cache.mapDirs.set(h.unId, r);
933
- for (const h of t.kids)
934
- h.host = t, h.next && (h.next.host = t), a.cache.mapDirs.set(h.unId, r);
935
- a.cache.mapDirs.set(s.unId, !r), a.cache.mapDirs.set(t.unId, !r), n ? (i.enqueue(t), i.enqueue(s), e.kids = i, e.type = "row", s.addBond(e, t)) : (i.enqueue(s), i.enqueue(t), e.kids = i, e.type = "row", t.addBond(e, s));
936
- }
937
- function lt(o, t) {
938
- if (!t.host || !t.host.host) {
939
- console.warn(`Source node ${t.unId} has no host, cannot move.`);
940
- return;
941
- }
942
- const e = t.host, n = t.host.host, i = n.kids.indexOf(e), s = n.kids.get(i - 1), r = n.kids.get(i + 1), h = t.kids.peek(), u = t.kids.peekBack();
943
- o.removeKid(e);
944
- let f = i;
945
- if (t.type == "row" && e) {
946
- s && h && h.addBond(n, s), r && u && r.addBond(n, u);
947
- for (const d of t.kids)
948
- d.host = n, d.next && (d.next.host = n), n.kids.insert(f, d), a.cache.mapDirs.set(
949
- d.unId,
950
- !a.cache.mapDirs.get(n.unId)
951
- ), a.cache.dimMins.delete(d.unId), f++;
952
- } else if (t.type == "tabset") {
953
- s && t.addBond(n, s), r && r.addBond(n, t), n.kids.insert(f, t), t.host = n, a.cache.mapDirs.set(t.unId, !a.cache.mapDirs.get(n.unId));
954
- for (const d of t.kids)
955
- a.cache.mapDirs.set(
956
- d.unId,
957
- a.cache.mapDirs.get(n.unId)
958
- ), a.cache.dimMins.delete(d.unId);
959
- }
960
- }
961
- function ft(o, t = !0) {
962
- const e = o.host, n = o.prev, i = o.next;
963
- if (o.host = null, o.next = null, o.prev = null, n && (n.next = null), i && (i.prev = null), !t)
964
- return o;
965
- n && i && n.prev && i.next ? n.prev.addBond(e, i.next) : n && n.prev ? n.prev.next = null : i && i.next && (i.next.prev = null);
966
- }
967
- function mt(o, t) {
968
- if (!t.host) {
969
- console.warn("Kid node has no host, cannot remove.");
970
- return;
971
- }
972
- const e = t?.host, n = e?.host;
973
- if (o.removeKid(t), t.type === "tabset" && e.kids.size() === 1) {
974
- const i = e.kids.peek();
975
- i && o.moveAdjacentNodeToGrandParent(i);
976
- } else if (t.type === "tab" && e.kids.size() === 0 && n.kids.size() === 2) {
977
- o.removeKid(e);
978
- const i = n?.kids.peek();
979
- i && o.moveAdjacentNodeToGrandParent(i);
980
- } else if (t.type === "tab" && e.kids.size() === 0 && n.kids.size() > 2)
981
- o.removeKid(e);
982
- else if (t.type === "tab" && e.open === t.name && e.kids.size() > 0) {
983
- const i = e.kids.peek();
984
- i && (e.open = i.name);
985
- }
986
- }
987
- function pt(o) {
988
- if (!o.host) {
989
- console.warn("Kid node has no host, cannot remove.");
990
- return;
991
- }
992
- const t = o.host, e = t.kids.indexOf(o), n = t.kids.get(e + 1), i = t.kids.get(e - 1), s = o.next, r = o.prev;
993
- if (e === -1) {
994
- console.warn("Kid node not found in its host's kids.");
995
- return;
996
- }
997
- s && a.cache.mapElem.delete(s.unId), r && a.cache.mapElem.delete(r.unId), n && i ? n.addBond(t, i) : n ? n.prev = null : i && (i.next = null), t.kids.removeAt(e), a.cache.mapElem.delete(o.unId), a.cache.dimMins.delete(o.unId), a.cache.mapDirs.delete(o.unId), a.cache.tabCnts.delete(o.unId), o.type === "tabset" && a.cache.mapElem.delete(o.unId), o.type === "tab" && a.cache.mapElem.delete(o.unId), o.host = null, o.next = null, o.prev = null;
998
- }
999
- function It() {
1000
- a.cache.dimMins.clear(), a.cache.mapDirs.clear(), a.cache.tabCnts.clear(), a.cache.mapElem.clear(), a.cache.nodOpts.get().clear(), a.cache.bndOpts.get().clear();
1001
- }
1002
- class w {
1003
- static get _root() {
1004
- return c.root;
1005
- }
1006
- static set _root(t) {
1007
- c.root = t;
1008
- }
1009
- static get _tree() {
1010
- return c.tree;
1011
- }
1012
- static set _tree(t) {
1013
- c.tree = t;
1014
- }
1015
- static get _minW() {
1016
- return c.minW;
1017
- }
1018
- static set _minW(t) {
1019
- c.minW = t;
1020
- }
1021
- static get _minH() {
1022
- return c.minH;
1023
- }
1024
- static set _minH(t) {
1025
- c.minH = t;
1026
- }
1027
- static get _bond() {
1028
- return c.bond;
1029
- }
1030
- static set _bond(t) {
1031
- c.bond = t;
1032
- }
1033
- static get _inst() {
1034
- return c.inst;
1035
- }
1036
- static set _inst(t) {
1037
- c.inst = t;
1038
- }
1039
- nodeOps;
1040
- cntdown = null;
1041
- tabsIds = /* @__PURE__ */ new Map();
1042
- constructor(t = {}) {
1043
- const e = {
1044
- tabs: [],
1045
- tree: null,
1046
- minW: 40,
1047
- minH: 40,
1048
- bond: 10,
1049
- uqid: "dynamix-layout-root",
1050
- tabsIds: /* @__PURE__ */ new Map(),
1051
- ...t
1052
- };
1053
- this.tabsIds = e.tabsIds, c.createId = e.createId ?? D, c.timer = e.timer ?? O, c.collapsedSize = e.collapsedSize ?? e.minH, w._tree = e.tree ?? null, c.maximized = e.tree?.nodMaxd ?? null, w._root = new a({
1054
- unId: e.uqid,
1055
- name: e.uqid,
1056
- type: "row"
1057
- }), this.nodeOps = T(
1058
- /* @__PURE__ */ new Map(),
1059
- E
1060
- ), w._minW = e.minW, w._minH = e.minH, w._bond = e.bond;
1061
- const n = new g(e.tabs.length, e.tabs);
1062
- w._tree ? this.createNodeLayout() : this.createBinaryNodeTreeFromQueue(n), w._inst = this;
1063
- }
1064
- *JSONLayoutIterator(t) {
1065
- yield* W(t);
1066
- }
1067
- *NodeLayoutIterator(t) {
1068
- yield* L(t);
1069
- }
1070
- *NodeLayoutRecursiveIterator(t) {
1071
- yield* P(this, t);
1072
- }
1073
- updateChildDirections(t) {
1074
- return K(this, t);
1075
- }
1076
- createNodeLayout(t = w._tree) {
1077
- return U(this, t);
1078
- }
1079
- createNodeTreeFromJSONTree(t, e) {
1080
- return $(this, t, e);
1081
- }
1082
- createBinaryNodeTreeFromQueue(t, e = w._root) {
1083
- return _(this, t, e);
1084
- }
1085
- createNodeFromJSON(t) {
1086
- return Y(this, t);
1087
- }
1088
- calcTabsetCountAndMinDim(t = w._root, e = !0) {
1089
- return V(this, t, e);
1090
- }
1091
- pruneStaleDirections() {
1092
- return X();
1093
- }
1094
- calculateRootAdjustment() {
1095
- return Z();
1096
- }
1097
- calcDimensions(t = w._root, e = !1) {
1098
- return tt(this, t, e);
1099
- }
1100
- updateDimension(t, e = !1, n = 2) {
1101
- return et(this, t, e, n);
1102
- }
1103
- updateSlider(t, e, n = !1, i = 2) {
1104
- return nt(this, t, e, n, i);
1105
- }
1106
- updateSliderDimension(t, e) {
1107
- return it(this, t, e);
1108
- }
1109
- updateTree(t, e, n) {
1110
- return ot(this, t, e, n);
1111
- }
1112
- isOnlyContent(t) {
1113
- return st(this, t);
1114
- }
1115
- moveNodeAsTab(t, e, n) {
1116
- return at(this, t, e, n);
1117
- }
1118
- moveRelativeToRoot(t, e, n) {
1119
- return dt(this, t, e, n);
1120
- }
1121
- moveRelativeToTabset(t, e, n) {
1122
- return ct(this, t, e, n);
1123
- }
1124
- insertNode(t, e, n) {
1125
- return ht(this, t, e, n);
1126
- }
1127
- insertNodeWithNewParent(t, e, n) {
1128
- return ut(this, t, e, n);
1129
- }
1130
- moveAdjacentNodeToGrandParent(t) {
1131
- return lt(this, t);
1132
- }
1133
- removeRelation(t, e = !0) {
1134
- return ft(t, e);
1135
- }
1136
- removeNode(t) {
1137
- return mt(this, t);
1138
- }
1139
- removeKid(t) {
1140
- return pt(t);
1141
- }
1142
- clearAllCache() {
1143
- return It();
1144
- }
1145
- get maximizedId() {
1146
- return R()?.unId ?? null;
1147
- }
1148
- maximize(t) {
1149
- return M(this, t);
1150
- }
1151
- restore() {
1152
- return z(this);
1153
- }
1154
- toggleMaximize(t) {
1155
- return Q(this, t);
1156
- }
1157
- collapse(t) {
1158
- return q(this, t);
1159
- }
1160
- expand(t) {
1161
- return F(this, t);
1162
- }
1163
- toggleCollapse(t) {
1164
- return j(this, t);
1165
- }
1166
- }
1167
- const yt = 6;
1168
- function bt(o, t, e) {
1169
- const { left: n, top: i, width: s, height: r } = o, h = t - n, u = e - i;
1170
- return h < s / 3 ? { area: "left", left: n, top: i, width: s / 2, height: r } : h > 2 * s / 3 ? {
1171
- area: "right",
1172
- left: n + s / 2,
1173
- top: i,
1174
- width: s / 2,
1175
- height: r
1176
- } : u < r / 3 ? { area: "top", left: n, top: i, width: s, height: r / 2 } : u > 2 * r / 3 ? {
1177
- area: "bottom",
1178
- left: n,
1179
- top: i + r / 2,
1180
- width: s,
1181
- height: r / 2
1182
- } : {
1183
- area: "contain",
1184
- left: n + s * 0.1,
1185
- top: i + r * 0.1,
1186
- width: s * 0.8,
1187
- height: r * 0.8
1188
- };
1189
- }
1190
- function kt(o, t) {
1191
- const { x: e, y: n, w: i, h: s } = o;
1192
- switch (t) {
1193
- case "left":
1194
- return { area: t, left: e, top: n, width: i / 2, height: s };
1195
- case "right":
1196
- return {
1197
- area: t,
1198
- left: e + i / 2,
1199
- top: n,
1200
- width: i / 2,
1201
- height: s
1202
- };
1203
- case "top":
1204
- return { area: t, left: e, top: n, width: i, height: s / 2 };
1205
- case "bottom":
1206
- return {
1207
- area: t,
1208
- left: e,
1209
- top: n + s / 2,
1210
- width: i,
1211
- height: s / 2
1212
- };
1213
- }
1214
- }
1215
- function xt(o, t, e, n) {
1216
- if (t.length === 0 || n < o.top || n > o.bottom) return null;
1217
- const i = t[0], s = t[t.length - 1];
1218
- let r = yt;
1219
- if (e > s.right)
1220
- return {
1221
- index: t.length - 1,
1222
- area: "right",
1223
- left: s.right + 1,
1224
- top: s.top,
1225
- width: r - 2,
1226
- height: s.height
1227
- };
1228
- if (e < i.left)
1229
- return {
1230
- index: 0,
1231
- area: "left",
1232
- left: i.left - r + 1,
1233
- top: i.top,
1234
- width: r - 2,
1235
- height: i.height
1236
- };
1237
- let h = 0, u = 1 / 0, f = !1;
1238
- t.forEach((m, p) => {
1239
- const I = m.left + m.width / 2, y = Math.abs(e - I);
1240
- y < u && (u = y, h = p, f = e < I);
1241
- });
1242
- const d = f ? h > 0 : h < t.length - 1;
1243
- t.length > 1 && d && (r = t[1].left - i.right);
1244
- const l = t[h];
1245
- return {
1246
- index: h,
1247
- area: f ? "left" : "right",
1248
- left: f ? l.left - r + 1 : l.right + 1,
1249
- top: l.top,
1250
- width: r - 2,
1251
- height: l.height
1252
- };
1253
- }
1254
- function gt(o, t) {
1255
- return o.area === t.area && o.left === t.left && o.top === t.top && o.width === t.width && o.height === t.height;
1256
- }
1257
- function wt(o, { x: t, y: e, w: n, h: i }) {
1258
- o.style.left = `${t}px`, o.style.top = `${e}px`, o.style.width = `${n}px`, o.style.height = `${i}px`;
1259
- }
1260
- function Nt(o, t) {
1261
- return {
1262
- x: o.x,
1263
- y: o.y + t,
1264
- w: o.w,
1265
- h: Math.max(0, o.h - t)
1266
- };
1267
- }
1268
- function Tt(o, t) {
1269
- const { x: e, y: n, w: i, h: s } = o.nodDims, r = o.nodeDir === !1;
1270
- return o.nodFold && r ? { rect: { x: e + i, y: n, w: s, h: i }, rotated: !0 } : { rect: { x: e, y: n, w: i, h: t }, rotated: !1 };
1271
- }
1272
- function Et(o, t) {
1273
- wt(o, t.rect), o.style.transformOrigin = "0 0", o.style.transform = t.rotated ? "rotate(90deg)" : "";
1274
- }
1275
- function vt(o) {
1276
- let t = null, e = null;
1277
- const n = () => {
1278
- e = null;
1279
- const i = t;
1280
- t = null, i && o(i.value);
1281
- };
1282
- return {
1283
- schedule(i) {
1284
- t = { value: i }, e === null && (e = requestAnimationFrame(n));
1285
- },
1286
- flush() {
1287
- e !== null && (cancelAnimationFrame(e), n());
1288
- },
1289
- cancel() {
1290
- e !== null && cancelAnimationFrame(e), e = null, t = null;
1291
- }
1292
- };
1293
- }
1294
- (() => {
1295
- if (typeof window > "u") return;
1296
- const o = "color: #03A9F4; font-weight: bold; line-height: 1.2;", t = "color: #E0E0E0; font-size: 12px;", e = "color: #42a5f5; font-size: 12px;", n = "color: #9E9E9E; font-size: 10px;", i = `
1297
- ██████╗ ██╗ ██╗ ███╗ ██╗ █████╗ ███╗ ███╗ ██████╗ ██╗ ██╗
1298
- ██╔══██╗╚██╗ ██╔╝ ████╗ ██║ ██╔══██╗ ████╗ ████║ ╚═██╔═╝ ╚██╗██╔╝
1299
- ██║ ██║ ╚████╔╝ ██╔██╗ ██║ ███████║ ██╔████╔██║ ██║ ╚███╔╝
1300
- ██║ ██║ ╚██╔╝ ██║╚██╗██║ ██╔══██║ ██║╚██╔╝██║ ██║ ██╔██╗
1301
- ██████╔╝ ██║ ██║ ╚████║ ██║ ██║ ██║ ╚═╝ ██║ ██████╗ ██╔╝ ██╗
1302
- ╚═════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝
1303
- ██╗ █████╗ ██╗ ██╗ ██████╗ ██╗ ██╗████████╗
1304
- ██║ ██╔══██╗ ╚██╗ ██╔╝ ██╔═══██╗ ██║ ██║╚══██╔══╝
1305
- ██║ ███████║ ╚████╔╝ ██║ ██║ ██║ ██║ ██║
1306
- ██║ ██╔══██║ ╚██╔╝ ██║ ██║ ██║ ██║ ██║
1307
- ███████╗ ██║ ██║ ██║ ╚██████╔╝ ╚█████╔╝ ██║
1308
- ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚════╝ ╚═╝
1309
- `;
1310
- console.groupCollapsed(
1311
- "%cDYNAMIX LAYOUT (click to expand)",
1312
- "color: #03A9F4; font-weight: bold; font-size: 14px;"
1313
- ), console.log(`%c${i}`, o), console.log("%c A powerful, dynamic layout system 🚀", t), console.log(
1314
- `%c ⚡ For docs and more info,
1315
- ⚡ visit: https://github.com/xcode-studio/dynamix-layout`,
1316
- e
1317
- ), console.log(`%cMIT License
1318
-
1319
- Copyright (c) 2025 Akash Aman <sir.akashaman@gmail.com> (https://akash.cx)
1320
-
1321
- Permission is hereby granted, free of charge, to any person obtaining a copy
1322
- of this software and associated documentation files (the "Software"), to deal
1323
- in the Software without restriction, including without limitation the rights
1324
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1325
- copies of the Software, and to permit persons to whom the Software is
1326
- furnished to do so, subject to the following conditions:
1327
-
1328
- The above copyright notice and this permission notice shall be included in all
1329
- copies or substantial portions of the Software.
1330
-
1331
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1332
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1333
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1334
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1335
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1336
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1337
- SOFTWARE.
1338
- `, n), console.groupEnd(), typeof window < "u" && (window.__DYNAMIX_LAYOUT__ = {
1339
- __LICENSE__: `MIT License
1340
-
1341
- Copyright (c) 2025 Akash Aman <sir.akashaman@gmail.com> (https://akash.cx)
1342
-
1343
- Permission is hereby granted, free of charge, to any person obtaining a copy
1344
- of this software and associated documentation files (the "Software"), to deal
1345
- in the Software without restriction, including without limitation the rights
1346
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1347
- copies of the Software, and to permit persons to whom the Software is
1348
- furnished to do so, subject to the following conditions:
1349
-
1350
- The above copyright notice and this permission notice shall be included in all
1351
- copies or substantial portions of the Software.
1352
-
1353
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1354
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1355
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1356
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1357
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1358
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1359
- SOFTWARE.
1360
- `,
1361
- __LAYOUT__: w
1362
- });
1363
- })();
1364
- export {
1365
- A as Bond,
1366
- w as DynamixLayoutCore,
1367
- a as Node,
1368
- g as Queue,
1369
- C as areNodeOptionsEqual,
1370
- E as areNodeOptionsMapEqual,
1371
- vt as createFrameScheduler,
1372
- T as createReactiveState,
1373
- xt as getNavbarDropPreview,
1374
- kt as getRootSplitPreview,
1375
- Nt as getTabBodyRect,
1376
- Tt as getTabbarPlacement,
1377
- bt as getTabsetDropPreview,
1378
- gt as isSameDropPreview,
1379
- Et as placeTabbar,
1380
- wt as setElementRect
1381
- };