@dynamix-layout/core 1.0.1 → 1.1.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.
@@ -1,2 +1,472 @@
1
- export * from './app/index';
2
- export type * from './type';
1
+ /** @deprecated Internal; removed in 2.0. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
2
+ export declare function areNodeOptionsEqual(a: NodeOptions, b: NodeOptions): boolean;
3
+
4
+ /** @deprecated Internal; removed in 2.0. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
5
+ export declare function areNodeOptionsMapEqual(mapA: Map<string, NodeOptions>, mapB: Map<string, NodeOptions>): boolean;
6
+
7
+ export declare interface BaseNode {
8
+ typNode: NodeTypeWithBond;
9
+ nodName: string;
10
+ uidNode: string;
11
+ nodPart: number;
12
+ nodeDir: boolean;
13
+ nodDims: Dimension;
14
+ nodOpen?: string | boolean;
15
+ }
16
+
17
+ /** @deprecated Internal; removed in 2.0. Splitters are `snapshot.splitters`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
18
+ export declare class Bond {
19
+ dims: Dimension;
20
+ unId: string;
21
+ next: Node_2 | null;
22
+ prev: Node_2 | null;
23
+ host: Node_2 | null;
24
+ constructor(parent?: Node_2 | null, next?: Node_2 | null, prev?: Node_2 | null);
25
+ toJSON(): LayoutTree;
26
+ }
27
+
28
+ export declare type ChangeListener<T> = (newValue: T) => void;
29
+
30
+ /**
31
+ * Coalesces bursts of updates (pointer events can fire several times per
32
+ * frame) into at most one `onFlush` call per animation frame.
33
+ */
34
+ export declare function createFrameScheduler<T>(onFlush: (value: T) => void): FrameScheduler<T>;
35
+
36
+ /** @deprecated Internal; removed in 2.0. Use `layout.subscribe()`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
37
+ export declare function createReactiveState<T>(initialValue: T, comparator?: (a: T, b: T) => boolean): ReactiveValue<T>;
38
+
39
+ /** @deprecated Replaced in 2.0 by `Rect { x, y, width, height }`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
40
+ export declare type Dimension = {
41
+ w: number;
42
+ h: number;
43
+ x: number;
44
+ y: number;
45
+ };
46
+
47
+ export declare type DropArea = 'top' | 'bottom' | 'left' | 'right' | 'contain';
48
+
49
+ /** Where a dragged tab or tabset would land, in viewport coordinates. */
50
+ export declare interface DropPreview {
51
+ area: DropArea;
52
+ left: number;
53
+ top: number;
54
+ width: number;
55
+ height: number;
56
+ }
57
+
58
+ /** @deprecated Replaced in 2.0 by `createLayout(options)`, which returns an independent instance (no static state). See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
59
+ export declare class DynamixLayoutCore {
60
+ static get _root(): Node_2;
61
+ static set _root(value: Node_2);
62
+ static get _tree(): LayoutTree | null;
63
+ static set _tree(value: LayoutTree | null);
64
+ static get _minW(): number;
65
+ static set _minW(value: number);
66
+ static get _minH(): number;
67
+ static set _minH(value: number);
68
+ static get _bond(): number;
69
+ static set _bond(value: number);
70
+ static get _inst(): DynamixLayoutCore | null;
71
+ static set _inst(value: DynamixLayoutCore | null);
72
+ nodeOps: ReactiveValue<Map<string, NodeOptions>>;
73
+ cntdown: ReturnType<typeof setTimeout> | null;
74
+ tabsIds: TabsIds;
75
+ constructor(options?: {
76
+ tabs?: string[];
77
+ tree?: LayoutTree | null;
78
+ minW?: number;
79
+ minH?: number;
80
+ bond?: number;
81
+ uqid?: string;
82
+ tabsIds?: TabsIds;
83
+ /** Generates ids for new nodes and bonds (default `crypto.randomUUID`). */
84
+ createId?: () => string;
85
+ /** Schedules deferred updates (default `setTimeout`/`clearTimeout`). */
86
+ timer?: Timer;
87
+ });
88
+ JSONLayoutIterator(root: LayoutTree): IterableIterator<LayoutTree>;
89
+ NodeLayoutIterator(root: Node_2): IterableIterator<Node_2>;
90
+ NodeLayoutRecursiveIterator(root: Node_2): IterableIterator<Node_2>;
91
+ updateChildDirections(parent: Node_2): void;
92
+ createNodeLayout(root?: LayoutTree | null): void;
93
+ createNodeTreeFromJSONTree(json: LayoutTree, host: Node_2): void;
94
+ createBinaryNodeTreeFromQueue(queue: Queue<string>, host?: Node_2): void;
95
+ createNodeFromJSON(json: LayoutTree): Node_2;
96
+ calcTabsetCountAndMinDim(root?: Node_2, clear?: boolean): void;
97
+ pruneStaleDirections(): void;
98
+ calculateRootAdjustment(): RootAdjustment;
99
+ calcDimensions(root?: Node_2, supress?: boolean): void;
100
+ updateDimension(dim: Dimension, disableTimeout?: boolean, timeout?: number): void;
101
+ updateSlider(id: string, dim: {
102
+ x: number;
103
+ y: number;
104
+ }, disableTimeout?: boolean, timeout?: number): void;
105
+ updateSliderDimension(id: string, dim: {
106
+ x: number;
107
+ y: number;
108
+ }): void;
109
+ updateTree(src: string, des: string, layout: 'top' | 'bottom' | 'left' | 'right' | 'contain'): boolean;
110
+ isOnlyContent(node: Node_2): boolean;
111
+ moveNodeAsTab(src: Node_2, des: Node_2, layout: 'left' | 'right' | 'contain'): void;
112
+ moveRelativeToRoot(src: Node_2, des: Node_2, layout: 'top' | 'bottom' | 'left' | 'right'): void;
113
+ moveRelativeToTabset(src: Node_2, des: Node_2, layout: 'top' | 'bottom' | 'left' | 'right'): void;
114
+ insertNode(des: Node_2, src: Node_2, flag: boolean): void;
115
+ insertNodeWithNewParent(src: Node_2, des: Node_2, flag: boolean): void;
116
+ moveAdjacentNodeToGrandParent(src: Node_2): void;
117
+ removeRelation(src: Node_2, fix?: boolean): Node_2 | undefined;
118
+ removeNode(src: Node_2): void;
119
+ removeKid(kid: Node_2): void;
120
+ clearAllCache(): void;
121
+ }
122
+
123
+ export declare interface FrameScheduler<T> {
124
+ /** Remember `value`; `onFlush` runs with the latest value on the next frame. */
125
+ schedule: (value: T) => void;
126
+ /** Run a pending flush now (e.g. on pointer up). */
127
+ flush: () => void;
128
+ /** Drop a pending flush (e.g. on unmount). */
129
+ cancel: () => void;
130
+ }
131
+
132
+ /**
133
+ * Insertion marker between the tabs of a tab bar. `index` is the tab the
134
+ * marker sits next to. Returns null when the pointer is above or below the bar.
135
+ * @deprecated Replaced in 2.0 by `layout.getDropTarget()` and `layout.getDropIndicatorRect()`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md
136
+ */
137
+ export declare function getNavbarDropPreview(navbarRect: PreviewRect, tabRects: PreviewRect[], clientX: number, clientY: number): (DropPreview & {
138
+ index: number;
139
+ }) | null;
140
+
141
+ /**
142
+ * The half of the whole layout a root-edge drop would take.
143
+ * @deprecated Replaced in 2.0 by `layout.getDropTarget()` and `layout.getDropIndicatorRect()`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md
144
+ */
145
+ export declare function getRootSplitPreview(container: Dimension, side: RootSide): DropPreview;
146
+
147
+ /**
148
+ * Area of a tabset below its tab bar; never negative when squeezed.
149
+ * @deprecated Replaced in 2.0 by `getTabContentRect(tabsetRect, tabBarHeight)`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md
150
+ */
151
+ export declare function getTabBodyRect(tabset: Dimension, tabbarHeight: number): Dimension;
152
+
153
+ /**
154
+ * Splits a tabset into thirds: the outer thirds drop beside it, the middle
155
+ * drops into it as a tab.
156
+ * @deprecated Replaced in 2.0 by `layout.getDropTarget()` and `layout.getDropIndicatorRect()`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md
157
+ */
158
+ export declare function getTabsetDropPreview(rect: PreviewRect, clientX: number, clientY: number): DropPreview;
159
+
160
+ /** @deprecated Replaced in 2.0 by `layout.getDropTarget()` and `layout.getDropIndicatorRect()`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
161
+ export declare function isSameDropPreview(a: Partial<DropPreview>, b: DropPreview): boolean;
162
+
163
+ /** @deprecated Replaced in 2.0 by `LayoutJSON` (v1 trees load automatically; `LayoutTreeV1` describes this shape). See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
164
+ export declare type LayoutTree = Omit<BaseNode, 'nodeDir' | 'nodDims'> & {
165
+ nodKids?: LayoutTree[];
166
+ };
167
+
168
+ /** @deprecated Internal; removed in 2.0. Read layout state from `layout.getSnapshot()` / `subscribe()`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
169
+ declare class Node_2 {
170
+ static cache: NodeCache;
171
+ kids: Queue<Node_2>;
172
+ dims: Dimension;
173
+ unId: string;
174
+ next: Bond | null;
175
+ prev: Bond | null;
176
+ type: 'row' | 'tabset' | 'tab' | 'bond';
177
+ name: string;
178
+ part: number;
179
+ host: Node_2 | null;
180
+ open: string;
181
+ constructor(options?: {
182
+ type?: 'row' | 'tabset' | 'tab' | 'bond';
183
+ host?: Node_2 | null;
184
+ name?: string;
185
+ part?: number;
186
+ dims?: Dimension;
187
+ unId?: string;
188
+ open?: string;
189
+ });
190
+ addBond(parent: Node_2 | null, prev?: Node_2 | null): void;
191
+ getReqDimension(): {
192
+ width: number;
193
+ height: number;
194
+ };
195
+ calcDimensions(): void;
196
+ toJSON(): LayoutTree;
197
+ }
198
+ export { Node_2 as Node }
199
+
200
+ export declare interface NodeCache {
201
+ dimMins: Map<string, {
202
+ minWidth: number;
203
+ minHeight: number;
204
+ }>;
205
+ mapDirs: Map<string, boolean>;
206
+ tabCnts: Map<string, {
207
+ horizontal: number;
208
+ vertical: number;
209
+ }>;
210
+ mapElem: Map<string, Node_2 | Bond>;
211
+ nodOpts: ReactiveValue<Map<string, NodeOptions>>;
212
+ bndOpts: ReactiveValue<Map<string, NodeOptions>>;
213
+ tabOpts: ReactiveValue<Map<string, NodeOptions>>;
214
+ }
215
+
216
+ /** @deprecated Replaced in 2.0 by `TabsetState`, `SplitterState`, `TabState` and `snapshot.rects`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
217
+ export declare interface NodeOptions extends BaseNode {
218
+ nodKids?: BaseNode[];
219
+ }
220
+
221
+ export declare type NodeType = 'row' | 'tabset' | 'tab';
222
+
223
+ export declare type NodeTypeWithBond = NodeType | 'bond';
224
+
225
+ export declare type PreviewRect = Pick<DOMRect, 'left' | 'top' | 'right' | 'bottom' | 'width' | 'height'>;
226
+
227
+ /** @deprecated Internal; removed in 2.0. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
228
+ export declare class Queue<T> {
229
+ private buffer;
230
+ private head;
231
+ private tail;
232
+ private count;
233
+ private capacity;
234
+ constructor(initialCapacity?: number, array?: T[]);
235
+ /**
236
+ * Add element to the back of the queue - O(1) amortized
237
+ * Used for FIFO and FILO patterns
238
+ */
239
+ enqueue(item: T): void;
240
+ /**
241
+ * Add element to the front of the queue - O(1) amortized
242
+ * Used for LIFO and LILO patterns
243
+ */
244
+ enqueueFront(item: T): void;
245
+ /**
246
+ * Insert element at specific logical index - O(n)
247
+ * All elements at and after the index are shifted right
248
+ * @param index - Logical index (0 = front of queue)
249
+ * @param item - Element to insert
250
+ * @returns true if insertion successful, false if index out of bounds
251
+ */
252
+ insert(index: number, item: T): boolean;
253
+ /**
254
+ * Insert array of elements at specific logical index - O(n + m) where n is elements to shift, m is array length
255
+ * All elements at and after the index are shifted right to make room for the entire array
256
+ * @param index - Logical index (0 = front of queue)
257
+ * @param items - Array of elements to insert
258
+ * @returns true if insertion successful, false if index out of bounds
259
+ */
260
+ insertArray(index: number, items: T[]): boolean;
261
+ /**
262
+ * Insert another queue at specific logical index - O(n + m) where n is elements to shift, m is queue size
263
+ * All elements at and after the index are shifted right to make room for the entire queue
264
+ * @param index - Logical index (0 = front of queue)
265
+ * @param queue - Queue to insert
266
+ * @returns true if insertion successful, false if index out of bounds
267
+ */
268
+ insertQueue(index: number, queue: Queue<T>): boolean;
269
+ /**
270
+ * Alias for enqueue (add to back)
271
+ */
272
+ push(item: T): void;
273
+ /**
274
+ * Alias for enqueueFront (add to front)
275
+ */
276
+ unshift(item: T): void;
277
+ /**
278
+ * Remove and return element from front of queue - O(1)
279
+ * Used for FIFO and LIFO patterns
280
+ */
281
+ dequeue(): T | undefined;
282
+ /**
283
+ * Remove and return element from back of queue - O(1)
284
+ * Used for FILO and LILO patterns
285
+ */
286
+ dequeueBack(): T | undefined;
287
+ indexOf(item: T): number;
288
+ remove(item: T): boolean;
289
+ /**
290
+ * Remove element at specific logical index - O(n)
291
+ * All elements after the index are shifted left
292
+ * @param index - Logical index (0 = front of queue)
293
+ * @returns The removed element, or undefined if index out of bounds
294
+ */
295
+ removeAt(index: number): T | undefined;
296
+ /**
297
+ * Alias for dequeue (remove from front)
298
+ */
299
+ shift(): T | undefined;
300
+ /**
301
+ * Alias for dequeueBack (remove from back)
302
+ */
303
+ pop(): T | undefined;
304
+ /**
305
+ * FIFO: First In, First Out
306
+ * Add to back, remove from front
307
+ */
308
+ fifoAdd(item: T): void;
309
+ fifoRemove(): T | undefined;
310
+ /**
311
+ * FILO: First In, Last Out
312
+ * Add to back, remove from back
313
+ */
314
+ filoAdd(item: T): void;
315
+ filoRemove(): T | undefined;
316
+ /**
317
+ * LIFO: Last In, First Out
318
+ * Add to front, remove from front
319
+ */
320
+ lifoAdd(item: T): void;
321
+ lifoRemove(): T | undefined;
322
+ /**
323
+ * LILO: Last In, Last Out
324
+ * Add to front, remove from back
325
+ */
326
+ liloAdd(item: T): void;
327
+ liloRemove(): T | undefined;
328
+ /**
329
+ * Get element at logical index (0 = front of queue) - O(1)
330
+ */
331
+ get(index: number): T | undefined;
332
+ /**
333
+ * Set element at logical index - O(1)
334
+ */
335
+ set(index: number, item: T): boolean;
336
+ /**
337
+ * Get the front element without removing it - O(1)
338
+ */
339
+ peek(): T | undefined;
340
+ /**
341
+ * Get the back element without removing it - O(1)
342
+ */
343
+ peekBack(): T | undefined;
344
+ /**
345
+ * Alias for peek (front element)
346
+ */
347
+ front(): T | undefined;
348
+ /**
349
+ * Alias for peekBack (back element)
350
+ */
351
+ back(): T | undefined;
352
+ /**
353
+ * Get current size of queue - O(1)
354
+ */
355
+ size(): number;
356
+ /**
357
+ * Get current capacity - O(1)
358
+ */
359
+ getCapacity(): number;
360
+ /**
361
+ * Check if queue is empty - O(1)
362
+ */
363
+ isEmpty(): boolean;
364
+ /**
365
+ * Check if queue is full - O(1)
366
+ */
367
+ isFull(): boolean;
368
+ /**
369
+ * Clear all elements from queue - O(1)
370
+ */
371
+ clear(): void;
372
+ /**
373
+ * Convert queue to array (maintains order from front to back) - O(n)
374
+ */
375
+ toArray(): T[];
376
+ /**
377
+ * Forward iterator support for for...of loops - O(n) total
378
+ * Iterates from front to back
379
+ */
380
+ [Symbol.iterator](): IterableIterator<T>;
381
+ /**
382
+ * Forward iterator (same as Symbol.iterator) - O(n) total
383
+ * Iterates from front to back
384
+ */
385
+ forward(): IterableIterator<T>;
386
+ /**
387
+ * Reverse iterator - O(n) total
388
+ * Iterates from back to front
389
+ */
390
+ reverse(): IterableIterator<T>;
391
+ /**
392
+ * Iterator with index information - O(n) total
393
+ * Returns [index, value] pairs from front to back
394
+ */
395
+ entries(): IterableIterator<[number, T]>;
396
+ /**
397
+ * Iterator for keys (indices) - O(n) total
398
+ */
399
+ keys(): IterableIterator<number>;
400
+ /**
401
+ * Iterator for values only - O(n) total
402
+ * Same as Symbol.iterator but more explicit
403
+ */
404
+ values(): IterableIterator<T>;
405
+ /**
406
+ * Get string representation - O(n)
407
+ */
408
+ toString(): string;
409
+ /**
410
+ * Private method to resize buffer when capacity is exceeded
411
+ */
412
+ private resize;
413
+ /**
414
+ * Shift elements left (towards head) to make room for insertion
415
+ * Used when inserting closer to head
416
+ */
417
+ private shiftLeft;
418
+ /**
419
+ * Shift elements right (towards tail) to make room for insertion
420
+ * Used when inserting closer to tail
421
+ */
422
+ private shiftRight;
423
+ /**
424
+ * Shift elements right (towards tail) to fill gap after removal
425
+ * Used when removing closer to head
426
+ */
427
+ private shiftRightForRemoval;
428
+ /**
429
+ * Shift elements left (towards head) to fill gap after removal
430
+ * Used when removing closer to tail
431
+ */
432
+ private shiftLeftForRemoval;
433
+ /**
434
+ * Shift elements left (towards head) to make room for array insertion
435
+ * Used when inserting array closer to head
436
+ */
437
+ private shiftLeftArray;
438
+ /**
439
+ * Shift elements right (towards tail) to make room for array insertion
440
+ * Used when inserting array closer to tail
441
+ */
442
+ private shiftRightArray;
443
+ }
444
+
445
+ export declare interface ReactiveValue<T> {
446
+ get: () => T;
447
+ set: (newValue: T, flag?: boolean) => void;
448
+ onChange: (listener: ChangeListener<T>) => () => void;
449
+ nextChange: () => Promise<T>;
450
+ onChangePromise: (listener: ChangeListener<T>) => () => void;
451
+ triggerChange: () => void;
452
+ }
453
+
454
+ export declare interface RootAdjustment {
455
+ adjustedW: number;
456
+ adjustedH: number;
457
+ wasAdjusted: boolean;
458
+ }
459
+
460
+ export declare type RootSide = Exclude<DropArea, 'contain'>;
461
+
462
+ /** @deprecated Replaced in 2.0 by `applyRect(element, rect)`. See https://github.com/xcode-studio/dynamix-layout/blob/main/docs/migration-v1-to-v2.md */
463
+ export declare function setElementRect(el: HTMLElement, { x, y, w, h }: Dimension): void;
464
+
465
+ export declare type TabsIds = Map<string, string>;
466
+
467
+ declare type Timer = {
468
+ set: (callback: () => void, ms: number) => ReturnType<typeof setTimeout>;
469
+ clear: (handle: ReturnType<typeof setTimeout>) => void;
470
+ };
471
+
472
+ export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamix-layout/core",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
4
  "description": "Dynamix Layout/Core is a JavaScript package for creating dynamic layouts with ease.",
5
5
  "keywords": [
6
6
  "dynamix-layout",
@@ -21,23 +21,27 @@
21
21
  ],
22
22
  "repository": {
23
23
  "type": "git",
24
- "url": "https://github.com/xcode-studio/dynamix-layout.git",
24
+ "url": "git+https://github.com/xcode-studio/dynamix-layout.git",
25
25
  "directory": "packages/core"
26
26
  },
27
27
  "bugs": {
28
28
  "url": "https://github.com/xcode-studio/dynamix-layout/issues"
29
29
  },
30
30
  "homepage": "https://github.com/xcode-studio/dynamix-layout#readme",
31
- "main": "./dist/core.cjs.js",
31
+ "main": "./dist/core.cjs",
32
32
  "module": "./dist/core.es.js",
33
- "browser": "./dist/core.iife.js",
34
33
  "types": "./dist/types/index.d.ts",
35
34
  "typings": "./dist/types/index.d.ts",
36
35
  "exports": {
37
36
  ".": {
38
- "types": "./dist/types/index.d.ts",
39
- "import": "./dist/core.es.js",
40
- "require": "./dist/core.cjs.js"
37
+ "import": {
38
+ "types": "./dist/types/index.d.ts",
39
+ "default": "./dist/core.es.js"
40
+ },
41
+ "require": {
42
+ "types": "./dist/types/index.d.cts",
43
+ "default": "./dist/core.cjs"
44
+ }
41
45
  }
42
46
  },
43
47
  "files": [
@@ -53,13 +57,12 @@
53
57
  },
54
58
  "type": "module",
55
59
  "engines": {
56
- "node": ">=22.16.0",
57
- "pnpm": ">=10.13.1"
60
+ "node": ">=18"
58
61
  },
59
62
  "devDependencies": {
60
- "@changesets/cli": "^2.29.5",
61
- "typescript": "^5.8.3",
62
- "vite": "^7.1.11",
63
+ "@changesets/cli": "^2.31.1",
64
+ "typescript": "^5.9.3",
65
+ "vite": "^7.3.6",
63
66
  "@repo/eslint-config": "0.0.0"
64
67
  },
65
68
  "scripts": {
package/dist/core.cjs.js DELETED
@@ -1,57 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class b{buffer;head=0;tail=0;count=0;capacity;constructor(t=16,e=[]){this.capacity=Math.max(t,e.length),this.buffer=new Array(this.capacity),e.forEach(i=>{this.enqueue(i)})}enqueue(t){this.count===this.capacity&&this.resize(),this.buffer[this.tail]=t,this.tail=(this.tail+1)%this.capacity,this.count++}enqueueFront(t){this.count===this.capacity&&this.resize(),this.head=(this.head-1+this.capacity)%this.capacity,this.buffer[this.head]=t,this.count++}insert(t,e){if(t<0||t>this.count)return!1;if(t===0)return this.enqueueFront(e),!0;if(t===this.count)return this.enqueue(e),!0;this.count===this.capacity&&this.resize();const i=t,n=this.count-t;return i<=n?this.shiftLeft(t,e):this.shiftRight(t,e),this.count++,!0}insertArray(t,e){if(t<0||t>this.count)return!1;if(e.length===0)return!0;if(t===0){for(let d=e.length-1;d>=0;d--)this.enqueueFront(e[d]);return!0}if(t===this.count)return e.forEach(d=>this.enqueue(d)),!0;for(;this.count+e.length>this.capacity;)this.resize();const i=t,n=this.count-t,s=e.length;return i<=n?this.shiftLeftArray(t,e):this.shiftRightArray(t,e),this.count+=s,!0}insertQueue(t,e){if(t<0||t>this.count)return!1;if(e.isEmpty())return!0;const i=e.size();if(t===0){const o=e.toArray();for(let h=o.length-1;h>=0;h--)this.enqueueFront(o[h]);return!0}if(t===this.count){for(const o of e)this.enqueue(o);return!0}for(;this.count+i>this.capacity;)this.resize();const n=e.toArray(),s=t,d=this.count-t;return s<=d?this.shiftLeftArray(t,n):this.shiftRightArray(t,n),this.count+=i,!0}push(t){this.enqueue(t)}unshift(t){this.enqueueFront(t)}dequeue(){if(this.count===0)return;const t=this.buffer[this.head];return this.head=(this.head+1)%this.capacity,this.count--,t}dequeueBack(){if(this.count===0)return;this.tail=(this.tail-1+this.capacity)%this.capacity;const t=this.buffer[this.tail];return this.count--,t}indexOf(t){for(let e=0;e<this.count;e++){const i=(this.head+e)%this.capacity;if(this.buffer[i]===t)return e}return-1}remove(t){const e=this.indexOf(t);return e===-1?!1:(this.removeAt(e),!0)}removeAt(t){if(t<0||t>=this.count)return;if(t===0)return this.dequeue();if(t===this.count-1)return this.dequeueBack();const e=(this.head+t)%this.capacity,i=this.buffer[e],n=t,s=this.count-t-1;return n<=s?this.shiftRightForRemoval(t):this.shiftLeftForRemoval(t),this.count--,i}shift(){return this.dequeue()}pop(){return this.dequeueBack()}fifoAdd(t){this.enqueue(t)}fifoRemove(){return this.dequeue()}filoAdd(t){this.enqueue(t)}filoRemove(){return this.dequeueBack()}lifoAdd(t){this.enqueueFront(t)}lifoRemove(){return this.dequeue()}liloAdd(t){this.enqueueFront(t)}liloRemove(){return this.dequeueBack()}get(t){if(t<0||t>=this.count)return;const e=(this.head+t)%this.capacity;return this.buffer[e]}set(t,e){if(t<0||t>=this.count)return!1;const i=(this.head+t)%this.capacity;return this.buffer[i]=e,!0}peek(){return this.count>0?this.buffer[this.head]:void 0}peekBack(){if(this.count===0)return;const t=(this.tail-1+this.capacity)%this.capacity;return this.buffer[t]}front(){return this.peek()}back(){return this.peekBack()}size(){return this.count}getCapacity(){return this.capacity}isEmpty(){return this.count===0}isFull(){return this.count===this.capacity}clear(){this.head=0,this.tail=0,this.count=0}toArray(){const t=[];for(let e=0;e<this.count;e++){const i=(this.head+e)%this.capacity;t.push(this.buffer[i])}return t}*[Symbol.iterator](){for(let t=0;t<this.count;t++){const e=(this.head+t)%this.capacity;yield this.buffer[e]}}*forward(){for(let t=0;t<this.count;t++){const e=(this.head+t)%this.capacity;yield this.buffer[e]}}*reverse(){for(let t=this.count-1;t>=0;t--){const e=(this.head+t)%this.capacity;yield this.buffer[e]}}*entries(){for(let t=0;t<this.count;t++){const e=(this.head+t)%this.capacity;yield[t,this.buffer[e]]}}*keys(){for(let t=0;t<this.count;t++)yield t}*values(){for(let t=0;t<this.count;t++){const e=(this.head+t)%this.capacity;yield this.buffer[e]}}toString(){return`Queue(${this.toArray().join(", ")})`}resize(){const t=this.capacity*2,e=new Array(t);for(let i=0;i<this.count;i++){const n=(this.head+i)%this.capacity;e[i]=this.buffer[n]}this.buffer=e,this.capacity=t,this.head=0,this.tail=this.count}shiftLeft(t,e){this.head=(this.head-1+this.capacity)%this.capacity;for(let n=0;n<t;n++){const s=(this.head+1+n)%this.capacity,d=(this.head+n)%this.capacity;this.buffer[d]=this.buffer[s]}const i=(this.head+t)%this.capacity;this.buffer[i]=e}shiftRight(t,e){for(let n=this.count-1;n>=t;n--){const s=(this.head+n)%this.capacity,d=(this.head+n+1)%this.capacity;this.buffer[d]=this.buffer[s]}const i=(this.head+t)%this.capacity;this.buffer[i]=e,this.tail=(this.tail+1)%this.capacity}shiftRightForRemoval(t){for(let e=t;e>0;e--){const i=(this.head+e-1)%this.capacity,n=(this.head+e)%this.capacity;this.buffer[n]=this.buffer[i]}this.head=(this.head+1)%this.capacity}shiftLeftForRemoval(t){for(let e=t;e<this.count-1;e++){const i=(this.head+e+1)%this.capacity,n=(this.head+e)%this.capacity;this.buffer[n]=this.buffer[i]}this.tail=(this.tail-1+this.capacity)%this.capacity}shiftLeftArray(t,e){const i=e.length;this.head=(this.head-i+this.capacity)%this.capacity;for(let n=0;n<t;n++){const s=(this.head+i+n)%this.capacity,d=(this.head+n)%this.capacity;this.buffer[d]=this.buffer[s]}for(let n=0;n<i;n++){const s=(this.head+t+n)%this.capacity;this.buffer[s]=e[n]}}shiftRightArray(t,e){const i=e.length;for(let n=this.count-1;n>=t;n--){const s=(this.head+n)%this.capacity,d=(this.head+n+i)%this.capacity;this.buffer[d]=this.buffer[s]}for(let n=0;n<i;n++){const s=(this.head+t+n)%this.capacity;this.buffer[s]=e[n]}this.tail=(this.tail+i)%this.capacity}}function g(I,t=(e,i)=>e===i){let e=I;const i=new Set;let n=[];const s=()=>e,d=(l,f=!1)=>{if(f){e=l;return}t(e,l)||(e=l,i.forEach(m=>m(e)),n.forEach(m=>m(e)),n=[])},o=()=>{i.forEach(l=>l(e)),n.forEach(l=>l(e)),n=[]},h=l=>(i.add(l),()=>i.delete(l)),r=()=>new Promise(l=>{n.push(l)});return{get:s,set:d,onChange:h,nextChange:r,triggerChange:o,onChangePromise:l=>{let f=!0;return(async()=>{for(;f;){const p=await r();if(!f)break;l(p)}})(),()=>{f=!1}}}}function E(I,t){if(I.size!==t.size)return!1;for(const[e,i]of I.entries()){const n=t.get(e);if(!n||!O(i,n))return!1}return!0}function O(I,t){if(I.typNode!==t.typNode||I.nodName!==t.nodName||I.uidNode!==t.uidNode||I.nodPart!==t.nodPart)return!1;const e=I.nodDims,i=t.nodDims;return e.x===i.x&&e.y===i.y&&e.w===i.w&&e.h===i.h}class a{static cache={dimMins:new Map,mapDirs:new Map,tabCnts:new Map,mapElem:new Map,tabOpts:g(new Map,E),nodOpts:g(new Map,E),bndOpts:g(new Map,E)};kids=new b;dims={w:0,h:0,x:0,y:0};unId;next=null;prev=null;type="row";name="";part=0;host=null;open="";constructor(t={}){const e={type:"row",host:null,name:"",part:100,dims:{w:0,h:0,x:0,y:0},unId:crypto.randomUUID(),open:""};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}addBond(t,e=null){if(!e)return;const i=new x(t,this,e);a.cache.mapElem.set(i.unId,i)}getReqDimension(){const t=a.cache.dimMins.get(this.unId),e=a.cache.tabCnts.get(this.unId),i=Math.max(t.minWidth,e.horizontal*c._minW+Math.max(0,e.horizontal-1)*c._bond),n=Math.max(t.minHeight,e.vertical*c._minH+Math.max(0,e.vertical-1)*c._bond);return{width:i,height:n}}calcDimensions(){const t=a.cache.mapDirs.get(this.unId);if(!this.kids)return;let e=0;const i=a.cache.dimMins.get(this.unId)||{minWidth:0,minHeight:0};let n=0;for(const o of this.kids)e+=o.part;if(e===0)return;let s;t?s=this.dims.w-i.minWidth:s=this.dims.h-i.minHeight;let d=s;for(const o of this.kids){const h=a.cache.dimMins.get(o.unId)||{minWidth:0,minHeight:0};if(this.dims.w<i.minWidth)t?(o.dims.w=h.minWidth,o.dims.h=this.dims.h,o.dims.x=this.dims.x+n,o.dims.y=this.dims.y,n+=o.dims.w+c._bond):(o.dims.h=h.minHeight,o.dims.w=this.dims.w,o.dims.y=this.dims.y+n,o.dims.x=this.dims.x,n+=o.dims.h+c._bond);else{const r=o.part/e,u=Math.floor(s*r);if(o===this.kids.peekBack()){t?(o.dims.w=h.minWidth+d,o.dims.h=this.dims.h,o.dims.x=this.dims.x+n,o.dims.y=this.dims.y,n+=o.dims.w+c._bond):(o.dims.h=h.minHeight+d,o.dims.w=this.dims.w,o.dims.y=this.dims.y+n,o.dims.x=this.dims.x,n+=o.dims.h+c._bond);break}t?(o.dims.w=h.minWidth+u,o.dims.h=this.dims.h,o.dims.x=this.dims.x+n,o.dims.y=this.dims.y,n+=o.dims.w+c._bond):(o.dims.h=h.minHeight+u,o.dims.w=this.dims.w,o.dims.y=this.dims.y+n,o.dims.x=this.dims.x,n+=o.dims.h+c._bond),d-=u}o.next&&(t?o.next.dims={w:c._bond,h:o.dims.h,x:o.dims.x+o.dims.w,y:o.dims.y}:o.next.dims={w:o.dims.w,h:c._bond,x:o.dims.x,y:o.dims.y+o.dims.h})}}toJSON(){const t=[];for(const i of this.kids)t.push(i.toJSON());const e={typNode:this.type,nodPart:this.part,nodName:this.name,uidNode:this.unId};return this.open&&(e.nodOpen=this.open),t.length>0&&(e.nodKids=t),e}}class c{static _root;static _tree;static _minW=40;static _minH=40;static _bond=10;static _inst=null;nodeOps;cntdown=null;tabsIds=new Map;constructor(t={}){const e={tabs:[],tree:null,minW:40,minH:40,bond:10,uqid:"dynamix-layout-root",tabsIds:new Map,...t};this.tabsIds=e.tabsIds,e.tree&&(c._tree=e.tree),c._root=new a({unId:e.uqid,name:e.uqid,type:"row"}),this.nodeOps=g(new Map,E),c._minW=e.minW,c._minH=e.minH,c._bond=e.bond;const i=new b(e.tabs.length,e.tabs);c._tree?this.createNodeLayout():this.createBinaryNodeTreeFromQueue(i),c._inst=this}*JSONLayoutIterator(t){const e=new b;for(e.enqueue(t);!e.isEmpty();){const i=e.dequeue();if(i&&(yield i,i.nodKids&&i.nodKids.length>0))for(const n of i.nodKids)e.enqueue(n)}}*NodeLayoutIterator(t){const e=new b;for(e.enqueue(t);!e.isEmpty();){const i=e.dequeue();if(i&&(a.cache.mapElem.set(i.unId,i),yield i,i.kids.size()>0))for(const n of i.kids)e.enqueue(n)}}*NodeLayoutRecursiveIterator(t){for(const e of t.kids)yield*this.NodeLayoutRecursiveIterator(e);yield t}updateChildDirections(t){const e=a.cache.mapDirs.get(t.unId);if(e===void 0){console.warn(`Cannot update child directions for node ${t.unId}; its own direction is not set.`);return}for(const i of t.kids)a.cache.mapDirs.set(i.unId,!e),i.kids.size()>0&&(i.host=t,this.updateChildDirections(i),i.next&&a.cache.mapDirs.set(i.next.unId,!e))}createNodeLayout(t=c._tree){const e=this.JSONLayoutIterator(t),i=this.NodeLayoutIterator(c._root);for(a.cache.mapDirs.set(c._root.unId,!0);;){const n=e.next(),s=i.next();if(n.done||s.done)break;const d=n.value,o=s.value;!d||!o||this.createNodeTreeFromJSONTree(d,o)}this.calcTabsetCountAndMinDim()}createNodeTreeFromJSONTree(t,e){const i=a.cache.mapDirs.get(e.unId);for(const n of t.nodKids||[]){const s=this.createNodeFromJSON(n),d=e.kids.peekBack();s.host=e,s.addBond(s.host,d),e.kids.enqueue(s),a.cache.mapDirs.set(s.unId,!i)}e.type==="tabset"&&a.cache.mapElem.set(e.unId,e),e.type==="tab"&&a.cache.mapElem.set(e.unId,e)}createBinaryNodeTreeFromQueue(t,e=c._root){const i=new b;for(i.enqueue(e),a.cache.mapDirs.set(c._root.unId,!0);!t.isEmpty();){const n=i.dequeue();if(!n)break;const s=a.cache.mapDirs.get(n.unId);if(t.size()==2){const u=t.dequeue(),l=t.dequeue(),f=new a({type:"tabset",host:n}),m=new a({type:"tabset",host:n}),p=new a({type:"tab",host:f,name:u,unId:this.tabsIds.get(u??"")??crypto.randomUUID()}),w=new a({type:"tab",host:m,name:l,unId:this.tabsIds.get(l??"")??crypto.randomUUID()});f.open=p.name,m.open=w.name,f.kids.enqueue(p),m.kids.enqueue(w),n.kids.enqueue(f),n.kids.enqueue(m),m.addBond(n,f),a.cache.mapDirs.set(f.unId,!s),a.cache.mapDirs.set(m.unId,!s),a.cache.mapElem.set(f.unId,f),a.cache.mapElem.set(m.unId,m),a.cache.mapDirs.set(p.unId,s),a.cache.mapDirs.set(w.unId,s),a.cache.mapElem.set(p.unId,p),a.cache.mapElem.set(w.unId,w);break}const d=t.dequeue(),o=new a({type:"tabset",host:n}),h=new a({type:"row",host:n}),r=new a({type:"tab",host:o,name:d,unId:this.tabsIds.get(d??"")??crypto.randomUUID()});o.open=r.name,o.kids.enqueue(r),n.kids.enqueue(o),n.kids.enqueue(h),h.addBond(n,o),a.cache.mapDirs.set(o.unId,!s),a.cache.mapDirs.set(h.unId,!s),a.cache.mapElem.set(o.unId,o),a.cache.mapDirs.set(r.unId,s),a.cache.mapElem.set(r.unId,r),i.enqueue(h)}this.calcTabsetCountAndMinDim()}createNodeFromJSON(t){const e=new a({type:t.typNode,name:t.nodName,unId:t.uidNode,part:t.nodPart,dims:{w:0,h:0,x:0,y:0},open:typeof t.nodOpen=="string"?t.nodOpen:""});return t.typNode==="tab"&&(e.unId=this.tabsIds.get(t.nodName)||t.uidNode),e}calcTabsetCountAndMinDim(t=c._root,e=!0){t===c._root&&e&&(a.cache.tabCnts.clear(),a.cache.dimMins.clear(),a.cache.mapElem.clear(),a.cache.mapElem.clear(),a.cache.mapElem.clear(),a.cache.mapElem.clear(),a.cache.nodOpts.get().clear(),a.cache.bndOpts.get().clear());for(const i of this.NodeLayoutRecursiveIterator(t)){const n=a.cache.tabCnts,s=a.cache.dimMins;a.cache.mapElem.set(i.unId,i);const d=n.set(i.unId,{horizontal:0,vertical:0}).get(i.unId),o=s.set(i.unId,{minWidth:0,minHeight:0}).get(i.unId),h=a.cache.mapDirs.get(i.unId);if(i.type==="tab"&&(a.cache.mapElem.set(i.unId,i),s.set(i.unId,{minWidth:0,minHeight:0})),i.next&&a.cache.mapElem.set(i.next.unId,i.next),i.type==="tabset"&&(a.cache.mapElem.set(i.unId,i),s.set(i.unId,{minWidth:c._minW,minHeight:c._minH}),h?n.set(i.unId,{horizontal:0,vertical:1}):n.set(i.unId,{horizontal:1,vertical:0})),i.type==="row"){for(const r of i.kids){const u=n.get(r.unId),l=s.get(r.unId);u&&(d.horizontal+=u.horizontal,d.vertical+=u.vertical,h?(o.minHeight=Math.max(o.minHeight,l.minHeight),o.minWidth+=l.minWidth):(o.minHeight+=l.minHeight,o.minWidth=Math.max(o.minWidth,l.minWidth)))}h?o.minWidth+=(i.kids.size()-1)*c._bond:o.minHeight+=(i.kids.size()-1)*c._bond}}}calculateRootAdjustment(){const t=c._root.getReqDimension();let e=!1,i=c._root.dims.w,n=c._root.dims.h;return c._root.dims.w<t.width&&(i=t.width,e=!0),c._root.dims.h<t.height&&(n=t.height,e=!0),e&&(c._root.dims.w=i,c._root.dims.h=n),{adjustedW:i,adjustedH:n,wasAdjusted:e}}calcDimensions(t=c._root,e=!1){const i=new Map,n=new Map,s=new Map;t===c._root&&this.calculateRootAdjustment();for(const d of this.NodeLayoutIterator(t)){d.calcDimensions();const o=a.cache.mapDirs.get(d.unId);if(d.type==="tabset"){const h={typNode:d.type,nodName:d.name,uidNode:d.unId,nodPart:d.part,nodOpen:d.open,nodeDir:o,nodKids:Array.from(d.kids).map(r=>{const u={typNode:r.type,nodName:r.name,uidNode:r.unId,nodPart:r.part,nodOpen:d.open===r.name,nodeDir:!o,nodDims:{...d.dims}};return s.set(r.unId,u),u}),nodDims:{...d.dims}};i.set(d.unId,h)}if(d.next&&d.type!=="tab"){const h={typNode:"bond",nodName:d.name,uidNode:d.next.unId,nodeDir:o,nodPart:0,nodDims:{...d.next.dims}};n.set(d.next.unId,h)}}a.cache.nodOpts.set(i,e),a.cache.bndOpts.set(n,e),a.cache.tabOpts.set(s,e)}updateDimension(t,e=!1,i=2){if(c._root.dims=t,e){this.calcDimensions(c._root);return}this.cntdown&&(clearTimeout(this.cntdown),this.cntdown=null),this.cntdown=setTimeout(()=>{this.cntdown=null,this.calcDimensions()},i)}updateSlider(t,e,i=!1,n=2){if(i){this.updateSliderDimension(t,e);return}this.cntdown&&(clearTimeout(this.cntdown),this.cntdown=null),this.cntdown=setTimeout(()=>{this.cntdown=null,this.updateSliderDimension(t,e)},n)}updateSliderDimension(t,e){const i=a.cache.mapElem.get(t);if(!i||!(i instanceof x)){console.warn(`Bond with id ${t} not found or is not a Bond instance`);return}const n=a.cache.mapDirs.get(i.host.unId),s=i.prev,d=i.next,o=i.host;if(!s||!d||!o){console.warn("Missing prev, next, or host node",s,d,o);return}const h=a.cache.dimMins.get(s.unId)||{minWidth:0,minHeight:0},r=a.cache.dimMins.get(d.unId)||{minWidth:0,minHeight:0},u=c._bond/2;if(n){const l=d.dims.x+d.dims.w,f=s.dims.x+h.minWidth+u,m=l-r.minWidth-u,p=Math.max(f,Math.min(m,e.x));i.dims.x=p-u,s.dims.w=i.dims.x-s.dims.x,d.dims.x=p+u,d.dims.w=l-d.dims.x;const w=Math.max(0,s.dims.w-h.minWidth),k=Math.max(0,d.dims.w-r.minWidth),N=w+k,y=s.part+d.part;N>0?(s.part=w/N*y,d.part=k/N*y):(s.part=y/2,d.part=y/2)}else{const l=d.dims.y+d.dims.h,f=s.dims.y+h.minHeight+u,m=l-r.minHeight-u,p=Math.max(f,Math.min(m,e.y));i.dims.y=p-u,s.dims.h=i.dims.y-s.dims.y,d.dims.y=p+u,d.dims.h=l-d.dims.y;const w=Math.max(0,s.dims.h-h.minHeight),k=Math.max(0,d.dims.h-r.minHeight),N=w+k,y=s.part+d.part;N>0?(s.part=w/N*y,d.part=k/N*y):(s.part=y/2,d.part=y/2)}this.calcDimensions(o)}updateTree(t,e,i){const n=a.cache.mapElem.get(t);let s=a.cache.mapElem.get(e);return!n||!(n instanceof a)||!s||!(s instanceof a)?(console.warn(`Source node ${t} not found or is not a Node instance`),!1):n?.type=="tab"&&n.host===s&&s.kids.size()<2?(console.warn("Cannot move to self as it has only one tab"),!1):n?.type=="tabset"&&s?.host===n?(console.warn("Cannot move tabset to self as it is already a child"),!1):!n||!s?(console.warn(`Source or destination node not found: ${t}, ${e}`),!1):n===s?(console.warn("Source and destination nodes are the same, no action taken."),!1):!n.host||!s.host&&s.type!=="row"?(console.warn(`Source node or destination node's host is null: ${n.unId}, ${s.unId}`),!1):s.type==="row"&&i==="contain"?(console.warn(`Cannot move to a row with 'contain' layout: ${s.unId}`),!1):n.type==="row"?!1:(s.type==="tabset"&&i==="contain"&&(s=s.kids.peekBack()||s),s.type==="tab"&&(i==="contain"||i==="left"||i==="right")?this.moveNodeAsTab(n,s,i):s.type==="row"&&i!=="contain"?this.moveRelativeToRoot(n,s,i):s.type==="tabset"&&i!=="contain"&&this.moveRelativeToTabset(n,s,i),this.calcTabsetCountAndMinDim(),this.calcDimensions(c._root,!0),!0)}moveNodeAsTab(t,e,i){if(!e||!e.host){console.warn(`Destination node ${e.unId} has no host, cannot move.`);return}this.removeNode(t);const n=e.host,s=n.kids.indexOf(e);if(s===void 0||s===-1)return;const d=i==="contain"||i==="left",o=d?s:s+1,h=n.kids.get(o+1),r=n.kids.get(o-1),u=e.next,l=e.prev;if(!d&&u?(a.cache.mapElem.delete(u.unId),a.cache.nodOpts.get().delete(u.unId)):d&&l&&(a.cache.mapElem.delete(l.unId),a.cache.nodOpts.get().delete(l.unId)),t.type=="tab")d?(r&&t.addBond(n,r),e.addBond(n,t)):(t.addBond(n,e),h&&h.addBond(n,t)),n.kids.insert(o,t),t.host=n,n.open=t.name;else if(t.type=="tabset"){const f=t.kids.peek(),m=t.kids.peekBack();d?(f&&r&&f.addBond(n,r),m&&e&&e.addBond(n,m)):(f&&e&&f.addBond(n,e),m&&h&&h.addBond(n,m)),n.kids.insertQueue(o,t.kids);for(const p of t.kids)p.host=n,p.next&&(p.next.host=n);n.open=m?m.name:""}this.updateChildDirections(n)}moveRelativeToRoot(t,e,i){this.removeNode(t);const n=a.cache.mapDirs.get(e.unId),s=i==="top"||i==="left";if(t.type==="tab"){const d=new a({type:"tabset",host:e.host});d.kids.enqueue(t),t.host=d,d.open=t.name,n==!1?i==="left"||i==="right"?this.insertNodeWithNewParent(d,e,s):this.insertNode(e,d,s):i==="top"||i==="bottom"?this.insertNodeWithNewParent(d,e,s):this.insertNode(e,d,s)}else t.type==="tabset"&&(n==!1?i==="left"||i==="right"?this.insertNodeWithNewParent(t,e,s):this.insertNode(e,t,s):i==="top"||i==="bottom"?this.insertNodeWithNewParent(t,e,s):this.insertNode(e,t,s))}moveRelativeToTabset(t,e,i){this.removeNode(t);const n=a.cache.mapDirs.get(e.unId),s=i==="top"||i==="left";if(t.type==="tab"){const d=new a({type:"tabset",host:e.host});d.kids.enqueue(t),t.host=d,d.open=t.name,n==!1?i==="top"||i==="bottom"?this.insertNodeWithNewParent(d,e,s):this.insertNode(e,d,s):i==="left"||i==="right"?this.insertNodeWithNewParent(d,e,s):this.insertNode(e,d,s)}else t.type==="tabset"&&(n==!1?i==="top"||i==="bottom"?this.insertNodeWithNewParent(t,e,s):this.insertNode(e,t,s):i==="left"||i==="right"?this.insertNodeWithNewParent(t,e,s):this.insertNode(e,t,s))}insertNode(t,e,i){const n=t.host;if(t==c._root){const l=c._root.kids.peek(),f=c._root.kids.peekBack();i?(c._root.kids.enqueueFront(e),l&&l.addBond(c._root,e)):(c._root.kids.enqueue(e),f&&e.addBond(c._root,f)),e.host=c._root,this.updateChildDirections(c._root);return}if(!n){console.warn(`Destination node ${t.unId} has no host, cannot insert.`);return}const s=n.kids.indexOf(t);if(s===-1){console.warn(`Destination node ${t.unId} not found in its host's kids.`);return}const d=a.cache.mapDirs.get(n.unId);d&&a.cache.mapDirs.set(e.unId,!d);const o=n.kids.get(s+1),h=n.kids.get(s-1),r=t.next,u=t.prev;e.host=n,i?(n.kids.insert(s,e),t.addBond(n,e),h&&e.addBond(n,h),u&&(a.cache.mapElem.delete(u.unId),a.cache.nodOpts.get().delete(u.unId))):(n.kids.insert(s+1,e),e.addBond(n,t),o&&o.addBond(n,e),r&&(a.cache.mapElem.delete(r.unId),a.cache.nodOpts.get().delete(r.unId))),this.updateChildDirections(n)}insertNodeWithNewParent(t,e,i){const n=new b,s=new a({type:"tabset",host:e.host});if(!e||!t){console.warn(`Destination node ${e.unId} has no host, cannot insert.`);return}if(e===c._root){const o=new a({type:"row",host:e});if(e.kids.size()==1&&e.kids.peek()?.type==="tabset"){const h=e.kids.dequeue();if(!h){console.warn(`No kid found in destination node ${e.unId}, cannot insert.`);return}i?(o.kids.enqueue(t),o.kids.enqueue(h),e.kids.enqueue(o),h.addBond(o,t)):(o.kids.enqueue(h),o.kids.enqueue(t),t.addBond(o,h),e.kids.enqueue(o)),t.host=o,h.host=o}else if(e.kids.size()==1&&e.kids.peek()?.type==="row"){const h=e.kids.peek(),r=h?.kids.peek(),u=h?.kids.peekBack();i&&h?(h.kids.enqueueFront(t),r&&r.addBond(h,t)):h&&(h.kids.enqueue(t),u&&t.addBond(h,u)),t.host=h}else if(e.kids.size()>1){const h=new a({type:"row",host:e}),r=new a({type:"row",host:h});for(const u of e.kids)r.kids.enqueue(u),u.host=r,u.next&&(u.next.host=r);t.host=h,e.kids.clear(),i?(h.kids.enqueueFront(t),h.kids.enqueue(r),r.addBond(h,t)):(h.kids.enqueue(r),h.kids.enqueue(t),t.addBond(h,r)),e.kids.enqueue(h)}this.updateChildDirections(e);return}t.host=e,s.host=e,s.kids=e.kids,s.open=e.open;const d=a.cache.mapDirs.get(e.unId);for(const o of s.kids)o.host=s,o.next&&(o.next.host=s),a.cache.mapDirs.set(o.unId,d);for(const o of t.kids)o.host=t,o.next&&(o.next.host=t),a.cache.mapDirs.set(o.unId,d);a.cache.mapDirs.set(s.unId,!d),a.cache.mapDirs.set(t.unId,!d),i?(n.enqueue(t),n.enqueue(s),e.kids=n,e.type="row",s.addBond(e,t)):(n.enqueue(s),n.enqueue(t),e.kids=n,e.type="row",t.addBond(e,s))}moveAdjacentNodeToGrandParent(t){if(!t.host||!t.host.host){console.warn(`Source node ${t.unId} has no host, cannot move.`);return}const e=t.host,i=t.host.host,n=i.kids.indexOf(e),s=i.kids.get(n-1),d=i.kids.get(n+1),o=t.kids.peek(),h=t.kids.peekBack();this.removeKid(e);let r=n;if(t.type=="row"&&e){s&&o&&o.addBond(i,s),d&&h&&d.addBond(i,h);for(const u of t.kids)u.host=i,u.next&&(u.next.host=i),i.kids.insert(r,u),a.cache.mapDirs.set(u.unId,!a.cache.mapDirs.get(i.unId)),a.cache.dimMins.delete(u.unId),r++}else if(t.type=="tabset"){s&&t.addBond(i,s),d&&d.addBond(i,t),i.kids.insert(r,t),t.host=i,a.cache.mapDirs.set(t.unId,!a.cache.mapDirs.get(i.unId));for(const u of t.kids)a.cache.mapDirs.set(u.unId,a.cache.mapDirs.get(i.unId)),a.cache.dimMins.delete(u.unId)}}removeRelation(t,e=!0){const i=t.host,n=t.prev,s=t.next;if(t.host=null,t.next=null,t.prev=null,n&&(n.next=null),s&&(s.prev=null),!e)return t;n&&s&&n.prev&&s.next?n.prev.addBond(i,s.next):n&&n.prev?n.prev.next=null:s&&s.next&&(s.next.prev=null)}removeNode(t){if(!t.host){console.warn("Kid node has no host, cannot remove.");return}const e=t?.host,i=e?.host;if(this.removeKid(t),t.type==="tabset"&&e.kids.size()===1){const n=e.kids.peek();n&&this.moveAdjacentNodeToGrandParent(n)}else if(t.type==="tab"&&e.kids.size()===0&&i.kids.size()===2){this.removeKid(e);const n=i?.kids.peek();n&&this.moveAdjacentNodeToGrandParent(n)}else if(t.type==="tab"&&e.kids.size()===0&&i.kids.size()>2)this.removeKid(e);else if(t.type==="tab"&&e.open===t.name&&e.kids.size()>0){const n=e.kids.peek();n&&(e.open=n.name)}}removeKid(t){if(!t.host){console.warn("Kid node has no host, cannot remove.");return}const e=t.host,i=e.kids.indexOf(t),n=e.kids.get(i+1),s=e.kids.get(i-1),d=t.next,o=t.prev;if(i===-1){console.warn("Kid node not found in its host's kids.");return}d&&(a.cache.mapElem.delete(d.unId),a.cache.nodOpts.get().delete(d.unId)),o&&(a.cache.mapElem.delete(o.unId),a.cache.nodOpts.get().delete(o.unId)),n&&s?n.addBond(e,s):n?n.prev=null:s&&(s.next=null),e.kids.removeAt(i),a.cache.mapElem.delete(t.unId),a.cache.dimMins.delete(t.unId),a.cache.mapDirs.delete(t.unId),a.cache.tabCnts.delete(t.unId),t.type==="tabset"&&a.cache.mapElem.delete(t.unId),t.type==="tab"&&a.cache.mapElem.delete(t.unId),t.host=null,t.next=null,t.prev=null}clearAllCache(){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()}}class x{dims={w:0,h:0,x:0,y:0};unId=crypto.randomUUID();next=null;prev=null;host=null;constructor(t=null,e=null,i=null){this.host=t,this.next=e,this.prev=i,this.next&&(this.next.prev=this),this.prev&&(this.prev.next=this)}toJSON(){return{nodName:this.host?.name||"",typNode:"bond",uidNode:this.unId,nodPart:0,nodOpen:"",nodKids:[]}}}(()=>{if(typeof window>"u")return;const I="color: #03A9F4; font-weight: bold; line-height: 1.2;",t="color: #E0E0E0; font-size: 12px;",e="color: #42a5f5; font-size: 12px;",i="color: #9E9E9E; font-size: 10px;",n=`
2
- ██████╗ ██╗ ██╗ ███╗ ██╗ █████╗ ███╗ ███╗ ██████╗ ██╗ ██╗
3
- ██╔══██╗╚██╗ ██╔╝ ████╗ ██║ ██╔══██╗ ████╗ ████║ ╚═██╔═╝ ╚██╗██╔╝
4
- ██║ ██║ ╚████╔╝ ██╔██╗ ██║ ███████║ ██╔████╔██║ ██║ ╚███╔╝
5
- ██║ ██║ ╚██╔╝ ██║╚██╗██║ ██╔══██║ ██║╚██╔╝██║ ██║ ██╔██╗
6
- ██████╔╝ ██║ ██║ ╚████║ ██║ ██║ ██║ ╚═╝ ██║ ██████╗ ██╔╝ ██╗
7
- ╚═════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝
8
- ██╗ █████╗ ██╗ ██╗ ██████╗ ██╗ ██╗████████╗
9
- ██║ ██╔══██╗ ╚██╗ ██╔╝ ██╔═══██╗ ██║ ██║╚══██╔══╝
10
- ██║ ███████║ ╚████╔╝ ██║ ██║ ██║ ██║ ██║
11
- ██║ ██╔══██║ ╚██╔╝ ██║ ██║ ██║ ██║ ██║
12
- ███████╗ ██║ ██║ ██║ ╚██████╔╝ ╚█████╔╝ ██║
13
- ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚════╝ ╚═╝
14
- `;console.groupCollapsed("%cDYNAMIX LAYOUT (click to expand)","color: #03A9F4; font-weight: bold; font-size: 14px;"),console.log(`%c${n}`,I),console.log("%c A powerful, dynamic layout system 🚀",t),console.log(`%c ⚡ For docs and more info,
15
- ⚡ visit: https://github.com/akash-aman/dynamix-layout`,e),console.log(`%cMIT License
16
-
17
- Copyright (c) 2025 Akash Aman <sir.akashaman@gmail.com> (https://akash.cx)
18
-
19
- Permission is hereby granted, free of charge, to any person obtaining a copy
20
- of this software and associated documentation files (the "Software"), to deal
21
- in the Software without restriction, including without limitation the rights
22
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23
- copies of the Software, and to permit persons to whom the Software is
24
- furnished to do so, subject to the following conditions:
25
-
26
- The above copyright notice and this permission notice shall be included in all
27
- copies or substantial portions of the Software.
28
-
29
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
- SOFTWARE.
36
- `,i),console.groupEnd(),typeof window<"u"&&(window.__DYNAMIX_LAYOUT__={__LICENSE__:`MIT License
37
-
38
- Copyright (c) 2025 Akash Aman <sir.akashaman@gmail.com> (https://akash.cx)
39
-
40
- Permission is hereby granted, free of charge, to any person obtaining a copy
41
- of this software and associated documentation files (the "Software"), to deal
42
- in the Software without restriction, including without limitation the rights
43
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
44
- copies of the Software, and to permit persons to whom the Software is
45
- furnished to do so, subject to the following conditions:
46
-
47
- The above copyright notice and this permission notice shall be included in all
48
- copies or substantial portions of the Software.
49
-
50
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
51
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
52
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
53
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
54
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
55
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
56
- SOFTWARE.
57
- `,__LAYOUT__:c})})();exports.Bond=x;exports.DynamixLayoutCore=c;exports.Node=a;exports.Queue=b;exports.areNodeOptionsEqual=O;exports.areNodeOptionsMapEqual=E;exports.createReactiveState=g;
@@ -1,3 +0,0 @@
1
- import { NodeOptions } from '../type';
2
- export declare function areNodeOptionsMapEqual(mapA: Map<string, NodeOptions>, mapB: Map<string, NodeOptions>): boolean;
3
- export declare function areNodeOptionsEqual(a: NodeOptions, b: NodeOptions): boolean;