@a-multilayout-splitter/core 6.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1667 @@
1
+ var _e = Object.defineProperty;
2
+ var Be = (t, e, n) => e in t ? _e(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var ae = (t, e, n) => Be(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { jsx as k, jsxs as le, Fragment as Oe } from "react/jsx-runtime";
5
+ import q, { useState as te, useRef as G, useEffect as O, useCallback as D, useMemo as X, createContext as ne, useContext as re, forwardRef as qe, useImperativeHandle as je } from "react";
6
+ function gt(t, e) {
7
+ e ? (t.classList.add("a-split-hidden"), t.style.flexGrow = "0", t.style.flexShrink = "0", t.style.flexBasis = "0") : (t.classList.remove("a-split-hidden"), t.style.flexGrow = "", t.style.flexShrink = "");
8
+ }
9
+ function Xe(t, e, n = {}) {
10
+ return new Promise((i) => {
11
+ const a = n.duration || 300;
12
+ if (!n.animate) {
13
+ t.style.flexBasis = e, i();
14
+ return;
15
+ }
16
+ t.style.transition = `flex-basis ${a}ms ease`, t.offsetHeight, t.style.flexBasis = e, setTimeout(() => {
17
+ t.style.transition = "", i();
18
+ }, a);
19
+ });
20
+ }
21
+ function mt(t) {
22
+ return {
23
+ ...t,
24
+ collapsed: !t.collapsed
25
+ };
26
+ }
27
+ function St(t, e) {
28
+ return t.findIndex((n) => n.id === e);
29
+ }
30
+ function Ye(t) {
31
+ return !t.collapsed;
32
+ }
33
+ function zt(t) {
34
+ return t.filter(Ye);
35
+ }
36
+ function wt(t) {
37
+ return document.querySelector(`[data-pane-id="${t}"]`);
38
+ }
39
+ function yt(t, e, n) {
40
+ return Math.max(e, Math.min(n, t));
41
+ }
42
+ function vt(t, e, n, i = {}) {
43
+ return {
44
+ id: t,
45
+ size: e,
46
+ content: n,
47
+ collapsed: i.collapsed ?? !1,
48
+ minSize: i.minSize ?? 0,
49
+ maxSize: i.maxSize ?? 100
50
+ };
51
+ }
52
+ function xt(t, e) {
53
+ return {
54
+ ...t,
55
+ size: e
56
+ };
57
+ }
58
+ function bt(t, e) {
59
+ return t.map((n) => {
60
+ const i = e.get(n.id);
61
+ return i ? { ...n, ...i } : n;
62
+ });
63
+ }
64
+ function Pt(t, e) {
65
+ return {
66
+ ...t,
67
+ size: e.size,
68
+ collapsed: e.collapsed
69
+ };
70
+ }
71
+ function $t(t) {
72
+ return {
73
+ id: t.id,
74
+ size: t.size,
75
+ collapsed: t.collapsed
76
+ };
77
+ }
78
+ function We(t, e) {
79
+ return !0;
80
+ }
81
+ function $e(t, e) {
82
+ return typeof e == "boolean" ? e : Array.isArray(e) ? e.length > 0 && typeof e[0] == "boolean" ? e[t - 1] === !0 : e.includes(t) : !1;
83
+ }
84
+ function Ee(t, e) {
85
+ return typeof e == "boolean" ? e : Array.isArray(e) ? e.length > 0 && typeof e[0] == "boolean" ? e[t - 1] !== !1 : e.includes(t) : !0;
86
+ }
87
+ function Ie(t, e) {
88
+ return typeof e == "boolean" ? e : Array.isArray(e) ? e.length > 0 && typeof e[0] == "boolean" ? e[t - 1] === !0 : e.includes(t) : !1;
89
+ }
90
+ function Je(t, e = [], n = [], i = [], a = [], z = "split") {
91
+ const [f, S] = te(() => q.Children.toArray(t).map((g, h) => ({
92
+ id: `${z}-pane-${h}`,
93
+ size: e[h] || "100%",
94
+ collapsed: n[h] || !1,
95
+ minSize: i[h] || 0,
96
+ maxSize: a[h] || 100,
97
+ content: g
98
+ }))), P = G(t);
99
+ O(() => {
100
+ const l = q.Children.toArray(t), g = q.Children.toArray(P.current);
101
+ l.length === f.length && S((h) => {
102
+ let r = !1;
103
+ const s = h.map((o, c) => {
104
+ const m = l[c], C = g[c];
105
+ return m !== C ? (r = !0, { ...o, content: m }) : o;
106
+ });
107
+ return r ? s : h;
108
+ }), P.current = t;
109
+ }, [t, f.length]);
110
+ const x = D(
111
+ (l) => {
112
+ S((g) => {
113
+ const h = l.position ?? g.length, r = {
114
+ id: `${z}-pane-${Date.now()}`,
115
+ size: l.size,
116
+ collapsed: l.collapsed || !1,
117
+ minSize: l.minSize || 0,
118
+ maxSize: l.maxSize || 100,
119
+ content: l.content
120
+ }, s = [...g];
121
+ return s.splice(h, 0, r), Ue(s, h, l.size);
122
+ });
123
+ },
124
+ [z]
125
+ ), b = D((l) => {
126
+ S((g) => {
127
+ if (l < 0 || l >= g.length) return g;
128
+ const h = [...g], r = h.splice(l, 1)[0];
129
+ return r ? Ze(h, r.size) : h;
130
+ });
131
+ }, []), u = D((l) => {
132
+ S((g) => {
133
+ if (l < 0 || l >= g.length) return g;
134
+ const h = g[l];
135
+ if (!h) return g;
136
+ const r = [...g];
137
+ r[l] = {
138
+ ...h,
139
+ collapsed: !h.collapsed
140
+ };
141
+ const s = document.querySelector(`[data-pane-id="${h.id}"]`);
142
+ if (s) {
143
+ const o = r[l];
144
+ (o == null ? void 0 : o.collapsed) ?? !1 ? (s.classList.add("a-split-hidden"), s.style.flexGrow = "0") : (s.classList.remove("a-split-hidden"), s.style.flexGrow = "");
145
+ }
146
+ return r;
147
+ });
148
+ }, []), y = D((l, g, h) => {
149
+ S((r) => {
150
+ if (l < 0 || l >= r.length) return r;
151
+ const s = r[l];
152
+ if (!s) return r;
153
+ const o = [...r];
154
+ o[l] = { ...s, size: g, flexGrow: void 0 };
155
+ const c = document.querySelector(`[data-pane-id="${s.id}"]`);
156
+ return c && Xe(c, g, h || { animate: !1 }), o;
157
+ });
158
+ }, []), p = D(() => f, [f]), $ = D((l) => {
159
+ S((g) => {
160
+ const h = [...l].sort((o, c) => c - o);
161
+ let r = [...g], s = 0;
162
+ if (h.forEach((o) => {
163
+ if (o >= 0 && o < r.length) {
164
+ const c = r.splice(o, 1)[0];
165
+ c && (s += parseFloat(c.size) || 0);
166
+ }
167
+ }), r.length > 0 && s > 0) {
168
+ const o = s / r.length;
169
+ r = r.map((c) => ({
170
+ ...c,
171
+ size: `${(parseFloat(c.size) || 0) + o}%`
172
+ }));
173
+ }
174
+ return r;
175
+ });
176
+ }, []), F = D((l, g) => {
177
+ S((h) => {
178
+ if (l < 0 || l >= h.length || g < 0 || g >= h.length || l === g)
179
+ return h;
180
+ const r = [...h], s = r[l];
181
+ return r[l] = r[g], r[g] = s, r;
182
+ });
183
+ }, []), A = D((l, g) => {
184
+ S((h) => {
185
+ if (l < 0 || l >= h.length) return h;
186
+ const r = h[l];
187
+ if (!r || r.collapsed) return h;
188
+ const s = g == null ? void 0 : g.direction;
189
+ let o;
190
+ s === "left" ? o = l + 1 : s === "right" ? o = l - 1 : o = l < h.length - 1 ? l + 1 : l - 1;
191
+ const c = h.map((m, C) => C === l ? { ...m, collapsed: !0, flexGrow: 0 } : C === o && !m.collapsed ? { ...m, flexGrow: 1 } : m.collapsed ? m : { ...m, flexGrow: 0 });
192
+ if (g != null && g.animate) {
193
+ const m = document.querySelector(`[data-pane-id="${r.id}"]`);
194
+ m && (m.style.transition = `flex-basis ${g.duration || 300}ms ease`, setTimeout(() => {
195
+ m.style.transition = "";
196
+ }, g.duration || 300));
197
+ }
198
+ return c;
199
+ });
200
+ }, []), R = D((l, g) => {
201
+ S((h) => {
202
+ if (l < 0 || l >= h.length) return h;
203
+ const r = h[l];
204
+ if (!r || !r.collapsed) return h;
205
+ const s = h.filter((m) => !m.collapsed).length + 1, o = h.length;
206
+ let c = [...h];
207
+ if (c[l] = { ...r, collapsed: !1, flexGrow: void 0 }, s === o)
208
+ c = c.map((m) => ({
209
+ ...m,
210
+ flexGrow: void 0
211
+ }));
212
+ else {
213
+ const m = g == null ? void 0 : g.direction;
214
+ let C;
215
+ if (m === "left" ? C = l + 1 : m === "right" ? C = l - 1 : C = l < h.length - 1 ? l + 1 : l - 1, C >= 0 && C < c.length) {
216
+ const T = c[C];
217
+ T && T.flexGrow === 1 && (c[C] = { ...T, flexGrow: void 0 });
218
+ }
219
+ }
220
+ if (g != null && g.animate) {
221
+ const m = document.querySelector(`[data-pane-id="${r.id}"]`);
222
+ m && (m.style.transition = `flex-basis ${g.duration || 300}ms ease`, setTimeout(() => {
223
+ m.style.transition = "";
224
+ }, g.duration || 300));
225
+ }
226
+ return c;
227
+ });
228
+ }, []), L = D((l, g) => {
229
+ S((h) => {
230
+ if (l < 0 || l >= h.length) return h;
231
+ const r = h[l];
232
+ if (!r) return h;
233
+ const s = parseFloat(r.size) || 0, o = Math.max(r.minSize || 0, Math.min(r.maxSize || 100, s + g)), c = [...h];
234
+ c[l] = { ...r, size: `${o}%` };
235
+ const m = document.querySelector(`[data-pane-id="${r.id}"]`);
236
+ return m && (m.style.flexBasis = `${o}%`), c;
237
+ });
238
+ }, []);
239
+ return {
240
+ panes: f,
241
+ addPane: x,
242
+ removePane: b,
243
+ togglePane: u,
244
+ setPaneSize: y,
245
+ getPaneState: p,
246
+ removePanes: $,
247
+ swapPanes: F,
248
+ collapsePane: A,
249
+ expandPane: R,
250
+ resizePane: L
251
+ };
252
+ }
253
+ function Ue(t, e, n) {
254
+ const i = parseFloat(n);
255
+ if (!n.includes("%"))
256
+ return t;
257
+ const f = t.filter((P, x) => x !== e).reduce((P, x) => P + parseFloat(x.size), 0), S = (100 - i) / f;
258
+ return t.map((P, x) => {
259
+ if (x === e) return P;
260
+ const u = parseFloat(P.size) * S;
261
+ return {
262
+ ...P,
263
+ size: P.size.includes("%") ? `${u}%` : P.size
264
+ };
265
+ });
266
+ }
267
+ function Ze(t, e) {
268
+ if (t.length === 0) return t;
269
+ const n = parseFloat(e);
270
+ if (!e.includes("%"))
271
+ return t;
272
+ const a = n / t.length;
273
+ return t.map((z) => {
274
+ if (!z.size.includes("%")) return z;
275
+ const S = parseFloat(z.size) + a;
276
+ return {
277
+ ...z,
278
+ size: `${S}%`
279
+ };
280
+ });
281
+ }
282
+ function Qe(t, e) {
283
+ let n = null, i = 0;
284
+ return function(...z) {
285
+ const f = Date.now();
286
+ f - i >= e ? (t(...z), i = f) : (n && clearTimeout(n), n = setTimeout(() => {
287
+ t(...z), i = Date.now();
288
+ }, e - (f - i)));
289
+ };
290
+ }
291
+ function Ke(t, e) {
292
+ let n = null;
293
+ return function(...a) {
294
+ n && clearTimeout(n), n = setTimeout(() => {
295
+ t(...a);
296
+ }, e);
297
+ };
298
+ }
299
+ function et(t, e, n = {}) {
300
+ const { onDragStart: i, onDragMove: a, onDragEnd: z } = n, f = G(null), S = G(null), P = D(
301
+ (y, p) => {
302
+ var c, m;
303
+ p.preventDefault(), p.stopPropagation();
304
+ const $ = p.target;
305
+ if ($.closest("button") || $.tagName === "BUTTON")
306
+ return;
307
+ const F = t.current;
308
+ if (!F) return;
309
+ const A = Array.from(F.children), R = (y - 1) * 2, L = y * 2, l = A[R], g = A[L];
310
+ if (!l || !g || l.classList.contains("a-split-hidden") || g.classList.contains("a-split-hidden"))
311
+ return;
312
+ const h = "touches" in p ? ((c = p.touches[0]) == null ? void 0 : c.clientX) ?? 0 : p.clientX, r = "touches" in p ? ((m = p.touches[0]) == null ? void 0 : m.clientY) ?? 0 : p.clientY, s = Array.from(F.querySelectorAll(".a-split-handlebar")).filter(
313
+ (C) => C.parentElement === F
314
+ );
315
+ let o = 0;
316
+ s.forEach((C) => {
317
+ const T = C, I = window.getComputedStyle(T);
318
+ if (e === "horizontal") {
319
+ const V = parseFloat(I.marginLeft) || 0, j = parseFloat(I.marginRight) || 0;
320
+ o += T.offsetWidth + V + j;
321
+ } else {
322
+ const V = parseFloat(I.marginTop) || 0, j = parseFloat(I.marginBottom) || 0;
323
+ o += T.offsetHeight + V + j;
324
+ }
325
+ }), f.current = {
326
+ active: !0,
327
+ paneIndex: y,
328
+ startX: h,
329
+ startY: r,
330
+ prevElement: l,
331
+ nextElement: g,
332
+ prevInitialWidth: l.offsetWidth,
333
+ nextInitialWidth: g.offsetWidth,
334
+ prevInitialHeight: l.offsetHeight,
335
+ nextInitialHeight: g.offsetHeight,
336
+ containerWidth: F.offsetWidth - (e === "horizontal" ? o : 0),
337
+ containerHeight: F.offsetHeight - (e === "vertical" ? o : 0),
338
+ minPrevSize: parseFloat(l.getAttribute("data-min-size") || "0"),
339
+ maxPrevSize: parseFloat(l.getAttribute("data-max-size") || "100"),
340
+ minNextSize: parseFloat(g.getAttribute("data-min-size") || "0"),
341
+ maxNextSize: parseFloat(g.getAttribute("data-max-size") || "100")
342
+ }, S.current = null, i == null || i({ paneIndex: y });
343
+ },
344
+ [t, i, e]
345
+ ), x = D(
346
+ (y) => {
347
+ var I, V;
348
+ const p = f.current;
349
+ if (!(p != null && p.active)) return null;
350
+ const $ = e === "horizontal", F = "touches" in y ? ((I = y.touches[0]) == null ? void 0 : I.clientX) ?? 0 : y.clientX, A = "touches" in y ? ((V = y.touches[0]) == null ? void 0 : V.clientY) ?? 0 : y.clientY, R = $ ? F - p.startX : A - p.startY, L = $ ? p.containerWidth : p.containerHeight, l = $ ? p.prevInitialWidth : p.prevInitialHeight, g = $ ? p.nextInitialWidth : p.nextInitialHeight;
351
+ let h = l + R, r = g - R;
352
+ h < 0 && (h = 0), r < 0 && (r = 0);
353
+ const s = h / L * 100, o = r / L * 100, c = s <= p.minPrevSize, m = s >= p.maxPrevSize, C = o <= p.minNextSize, T = o >= p.maxNextSize;
354
+ return c || m || C || T ? null : {
355
+ prevSize: s,
356
+ nextSize: o,
357
+ prevSizePx: h,
358
+ nextSizePx: r,
359
+ state: p
360
+ };
361
+ },
362
+ [e]
363
+ ), b = D(
364
+ Qe((y) => {
365
+ const p = x(y);
366
+ if (!p) return;
367
+ const { prevSize: $, nextSize: F, prevSizePx: A, nextSizePx: R, state: L } = p, { prevInitialWidth: l, prevInitialHeight: g } = L, h = e === "horizontal" ? l : g;
368
+ Math.abs(p.prevSizePx - h) <= 1 || (S.current = { prevSize: $, nextSize: F }, requestAnimationFrame(() => {
369
+ if (!L.prevElement || !L.nextElement) return;
370
+ const r = L.prevElement.style.flexBasis.includes("%"), s = L.nextElement.style.flexBasis.includes("%");
371
+ r ? L.prevElement.style.flexBasis = `${$}%` : L.prevElement.style.flexBasis = `${A}px`, s ? L.nextElement.style.flexBasis = `${F}%` : L.nextElement.style.flexBasis = `${R}px`;
372
+ }), a == null || a({ paneIndex: L.paneIndex, prevSize: $, nextSize: F }));
373
+ }, 16),
374
+ [x, e, a]
375
+ ), u = D((y) => {
376
+ const p = f.current;
377
+ if (!(p != null && p.active)) return;
378
+ const $ = x(y);
379
+ $ && (S.current = { prevSize: $.prevSize, nextSize: $.nextSize });
380
+ const F = S.current;
381
+ F && (z == null || z({ paneIndex: p.paneIndex, prevSize: F.prevSize, nextSize: F.nextSize })), f.current = null, S.current = null;
382
+ }, [x, z]);
383
+ return O(() => {
384
+ const y = b, p = u;
385
+ return window.addEventListener("mousemove", y), window.addEventListener("mouseup", p), window.addEventListener("touchmove", y, { passive: !1 }), window.addEventListener("touchend", p), () => {
386
+ window.removeEventListener("mousemove", y), window.removeEventListener("mouseup", p), window.removeEventListener("touchmove", y), window.removeEventListener("touchend", p);
387
+ };
388
+ }, [b, u]), {
389
+ handleMouseDown: P
390
+ };
391
+ }
392
+ function tt(t, e, n) {
393
+ const i = D(
394
+ Ke((f) => {
395
+ if (t)
396
+ try {
397
+ const S = `${e}-${n}`, P = f.map((x) => ({
398
+ id: x.id,
399
+ size: x.size,
400
+ collapsed: x.collapsed
401
+ }));
402
+ localStorage.setItem(S, JSON.stringify(P));
403
+ } catch (S) {
404
+ console.warn("Failed to save split state to localStorage:", S);
405
+ }
406
+ }, 300),
407
+ [t, e, n]
408
+ ), a = D(() => {
409
+ if (!t) return null;
410
+ try {
411
+ const f = `${e}-${n}`, S = localStorage.getItem(f);
412
+ return S ? JSON.parse(S) : null;
413
+ } catch (f) {
414
+ return console.warn("Failed to load split state from localStorage:", f), null;
415
+ }
416
+ }, [t, e, n]), z = D(() => {
417
+ if (t)
418
+ try {
419
+ const f = `${e}-${n}`;
420
+ localStorage.removeItem(f);
421
+ } catch (f) {
422
+ console.warn("Failed to clear split state from localStorage:", f);
423
+ }
424
+ }, [t, e, n]);
425
+ return {
426
+ save: i,
427
+ load: a,
428
+ clear: z
429
+ };
430
+ }
431
+ function nt(t, e, n, i) {
432
+ const a = G(e), z = G(n);
433
+ return a.current = e, z.current = n, X(() => ({
434
+ splitId: t,
435
+ getState: () => a.current(),
436
+ dispatch: (S) => z.current(S),
437
+ getElement: () => i.current,
438
+ getPanes: () => a.current().panes
439
+ }), [t, i]);
440
+ }
441
+ const Ae = ne(0);
442
+ function Ce() {
443
+ return re(Ae);
444
+ }
445
+ const ce = ({
446
+ level: t = 0,
447
+ children: e
448
+ }) => /* @__PURE__ */ k(Ae.Provider, { value: t, children: e });
449
+ ce.displayName = "NestingProvider";
450
+ function Et(t) {
451
+ const e = (n) => {
452
+ const i = Ce();
453
+ return /* @__PURE__ */ k(ce, { level: i + 1, children: /* @__PURE__ */ k(t, { ...n }) });
454
+ };
455
+ return e.displayName = `withNesting(${t.displayName || t.name || "Component"})`, e;
456
+ }
457
+ const Fe = ({
458
+ index: t,
459
+ mode: e,
460
+ disabled: n,
461
+ lineBar: i,
462
+ onMouseDown: a,
463
+ onTouchStart: z,
464
+ onCollapse: f,
465
+ onExpand: S,
466
+ renderCustom: P,
467
+ leftPaneCollapsed: x = !1,
468
+ rightPaneCollapsed: b = !1,
469
+ explicitlyDisabled: u = !1
470
+ }) => {
471
+ if (P)
472
+ return /* @__PURE__ */ k(
473
+ "div",
474
+ {
475
+ className: "a-split-handlebar",
476
+ onMouseDown: (c) => !n && a(c),
477
+ onTouchStart: (c) => !n && (z ? z(c) : a(c)),
478
+ children: P({
479
+ index: t,
480
+ mode: e,
481
+ disabled: n,
482
+ lineBar: i,
483
+ onMouseDown: a,
484
+ onTouchStart: z || a,
485
+ onCollapse: f,
486
+ onExpand: S
487
+ }, t)
488
+ }
489
+ );
490
+ const y = [
491
+ "a-split-handlebar",
492
+ e === "horizontal" ? "a-split-handlebar-horizontal" : "a-split-handlebar-vertical",
493
+ n ? "a-split-handlebar-disabled" : "",
494
+ i ? "a-split-handlebar-line" : ""
495
+ ].filter(Boolean).join(" "), p = (o) => {
496
+ o.stopPropagation(), b ? S == null || S("right") : f == null || f("left");
497
+ }, $ = (o) => {
498
+ o.stopPropagation(), x ? S == null || S("left") : f == null || f("right");
499
+ }, F = !i && !u, A = e === "horizontal";
500
+ return /* @__PURE__ */ k(
501
+ "div",
502
+ {
503
+ className: y,
504
+ onMouseDown: (o) => !n && a(o),
505
+ onTouchStart: (o) => !n && a(o),
506
+ style: { cursor: n ? "default" : A ? "col-resize" : "row-resize" },
507
+ children: F && /* @__PURE__ */ le(Oe, { children: [
508
+ /* @__PURE__ */ k(
509
+ "button",
510
+ {
511
+ className: `a-split-collapse-btn a-split-collapse-btn-${A ? "left" : "top"}${x && !b ? " hidden" : ""}`,
512
+ onClick: p,
513
+ "aria-label": b ? `Expand ${A ? "right" : "bottom"} pane` : `Collapse ${A ? "left" : "top"} pane`,
514
+ title: b ? `Expand ${A ? "right" : "bottom"} pane` : `Collapse ${A ? "left" : "top"} pane`,
515
+ children: /* @__PURE__ */ k("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ k("path", { d: A ? "M8 3L4 6L8 9" : "M3 8L6 4L9 8", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
516
+ }
517
+ ),
518
+ /* @__PURE__ */ k("div", { className: `a-split-grip-icon${x || b ? " hidden" : ""}`, "aria-hidden": "true", children: A ? /* @__PURE__ */ le("svg", { width: "8", height: "24", viewBox: "0 0 8 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
519
+ /* @__PURE__ */ k("circle", { cx: "4", cy: "4", r: "2.5", fill: "currentColor" }),
520
+ /* @__PURE__ */ k("circle", { cx: "4", cy: "12", r: "2.5", fill: "currentColor" }),
521
+ /* @__PURE__ */ k("circle", { cx: "4", cy: "20", r: "2.5", fill: "currentColor" })
522
+ ] }) : /* @__PURE__ */ le("svg", { width: "24", height: "8", viewBox: "0 0 24 8", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
523
+ /* @__PURE__ */ k("circle", { cx: "4", cy: "4", r: "2.5", fill: "currentColor" }),
524
+ /* @__PURE__ */ k("circle", { cx: "12", cy: "4", r: "2.5", fill: "currentColor" }),
525
+ /* @__PURE__ */ k("circle", { cx: "20", cy: "4", r: "2.5", fill: "currentColor" })
526
+ ] }) }),
527
+ /* @__PURE__ */ k(
528
+ "button",
529
+ {
530
+ className: `a-split-collapse-btn a-split-collapse-btn-${A ? "right" : "bottom"}${b && !x ? " hidden" : ""}`,
531
+ onClick: $,
532
+ "aria-label": x ? `Expand ${A ? "left" : "top"} pane` : `Collapse ${A ? "right" : "bottom"} pane`,
533
+ title: x ? `Expand ${A ? "left" : "top"} pane` : `Collapse ${A ? "right" : "bottom"} pane`,
534
+ children: /* @__PURE__ */ k("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ k("path", { d: A ? "M4 3L8 6L4 9" : "M3 4L6 8L9 4", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
535
+ }
536
+ )
537
+ ] })
538
+ }
539
+ );
540
+ };
541
+ Fe.displayName = "DragHandle";
542
+ function It(t, e) {
543
+ if (e.includes("vw")) {
544
+ const n = parseFloat(e);
545
+ return t / 100 * window.innerWidth * (n / 100);
546
+ }
547
+ if (e.includes("vh")) {
548
+ const n = parseFloat(e);
549
+ return t / 100 * window.innerHeight * (n / 100);
550
+ }
551
+ if (e.includes("px")) {
552
+ const n = parseFloat(e);
553
+ return t / 100 * n;
554
+ }
555
+ return e.includes("%") ? (console.warn("Percentage reference not fully supported, assuming viewport"), t / 100 * window.innerWidth * (parseFloat(e) / 100)) : t / 100 * parseFloat(e);
556
+ }
557
+ function At(t, e) {
558
+ if (e.includes("vw")) {
559
+ const n = parseFloat(e), i = window.innerWidth * (n / 100);
560
+ return t / i * 100;
561
+ }
562
+ if (e.includes("vh")) {
563
+ const n = parseFloat(e), i = window.innerHeight * (n / 100);
564
+ return t / i * 100;
565
+ }
566
+ if (e.includes("px")) {
567
+ const n = parseFloat(e);
568
+ return t / n * 100;
569
+ }
570
+ if (e.includes("%")) {
571
+ console.warn("Percentage reference not fully supported, assuming viewport");
572
+ const n = window.innerWidth * (parseFloat(e) / 100);
573
+ return t / n * 100;
574
+ }
575
+ return t / parseFloat(e) * 100;
576
+ }
577
+ function Ct(t, e, n) {
578
+ const i = parseFloat(t);
579
+ return t.includes("%") ? n === "px" ? `${i / 100 * e}px` : t : t.includes("px") ? n === "%" ? `${i / e * 100}%` : t : n === "px" ? `${i}px` : `${i / e * 100}%`;
580
+ }
581
+ function J(t) {
582
+ const e = parseFloat(t);
583
+ return t.includes("%") ? { value: e, unit: "%" } : t.includes("px") ? { value: e, unit: "px" } : t.includes("vw") ? { value: e, unit: "vw" } : t.includes("vh") ? { value: e, unit: "vh" } : t.includes("fr") ? { value: e, unit: "fr" } : { value: e, unit: "px" };
584
+ }
585
+ function Ft(t, e) {
586
+ const n = J(t), i = J(e);
587
+ return n.unit === i.unit;
588
+ }
589
+ function Dt(t, e, n, i) {
590
+ return `${Math.max(e, Math.min(n, t))}${i}`;
591
+ }
592
+ function Ht(t) {
593
+ if (t.length === 0) return { total: 0, unit: "px" };
594
+ const e = t[0];
595
+ if (!e) return { total: 0, unit: "px" };
596
+ const n = J(e.size);
597
+ let i = 0;
598
+ for (const a of t) {
599
+ const z = J(a.size);
600
+ z.unit === n.unit || console.warn(
601
+ `Mixed units detected: ${n.unit} and ${z.unit}. Results may be inaccurate.`
602
+ ), i += z.value;
603
+ }
604
+ return { total: i, unit: n.unit };
605
+ }
606
+ function Nt(t, e) {
607
+ const n = [];
608
+ if (t.length === 0)
609
+ return n.push("No panes defined"), { valid: !1, errors: n };
610
+ const i = t.filter((a) => a.size.includes("%"));
611
+ if (i.length > 0) {
612
+ const a = i.reduce((z, f) => z + parseFloat(f.size), 0);
613
+ a > 100.1 && n.push(`Total percentage (${a}%) exceeds 100%`);
614
+ }
615
+ return t.forEach((a, z) => {
616
+ a.minSize < 0 && n.push(`Pane ${z}: minSize cannot be negative`), a.maxSize < a.minSize && n.push(`Pane ${z}: maxSize (${a.maxSize}) less than minSize (${a.minSize})`), a.maxSize > 100 && n.push(`Pane ${z}: maxSize (${a.maxSize}%) exceeds 100%`);
617
+ }), { valid: n.length === 0, errors: n };
618
+ }
619
+ function rt(t, e) {
620
+ const n = J(t);
621
+ switch (n.unit) {
622
+ case "%":
623
+ return t;
624
+ case "px":
625
+ return t;
626
+ case "vw":
627
+ return `${n.value / 100 * window.innerWidth}px`;
628
+ case "vh":
629
+ return `${n.value / 100 * window.innerHeight}px`;
630
+ case "fr":
631
+ return "0";
632
+ default:
633
+ return `${n.value}px`;
634
+ }
635
+ }
636
+ function it(t, e = !1) {
637
+ if (e)
638
+ return { flexGrow: 0, flexShrink: 0 };
639
+ const n = J(t.size);
640
+ return n.unit === "%" ? { flexGrow: 1, flexShrink: 1 } : n.unit === "fr" ? { flexGrow: n.value, flexShrink: 1 } : { flexGrow: 0, flexShrink: 0 };
641
+ }
642
+ function Lt(t, e, n) {
643
+ const i = J(t);
644
+ return i.unit === "%" ? i.value / 100 * e : i.unit === "px" ? i.value : i.unit === "vw" ? i.value / 100 * window.innerWidth : i.unit === "vh" ? i.value / 100 * window.innerHeight : i.value;
645
+ }
646
+ const st = 11;
647
+ function kt(t, e, n = 0) {
648
+ const i = t.offsetWidth, a = t.offsetHeight, z = e === "horizontal" ? i : a, f = n * st, S = z - f;
649
+ return { width: i, height: a, primary: z, availableForPanes: S };
650
+ }
651
+ function Tt(t) {
652
+ const e = t.filter((a) => a.size.includes("%"));
653
+ if (e.length === 0)
654
+ return t;
655
+ const n = e.reduce((a, z) => a + parseFloat(z.size), 0);
656
+ if (Math.abs(n - 100) < 0.01)
657
+ return t;
658
+ const i = 100 / n;
659
+ return t.map((a) => {
660
+ if (!a.size.includes("%")) return a;
661
+ const f = parseFloat(a.size) * i;
662
+ return {
663
+ ...a,
664
+ size: `${f}%`
665
+ };
666
+ });
667
+ }
668
+ function Rt(t, e, n) {
669
+ const i = e + n;
670
+ return !(i < t.minSize || i > t.maxSize);
671
+ }
672
+ function Mt(t) {
673
+ return t === "horizontal" ? "width" : "height";
674
+ }
675
+ function Gt(t) {
676
+ return t === "horizontal" ? "clientX" : "clientY";
677
+ }
678
+ const De = ({
679
+ id: t,
680
+ size: e,
681
+ collapsed: n,
682
+ minSize: i,
683
+ maxSize: a,
684
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
685
+ mode: z,
686
+ content: f,
687
+ flexGrow: S
688
+ }) => {
689
+ const P = e || "100%", x = {
690
+ size: P
691
+ }, { flexGrow: b, flexShrink: u } = it(x, n), y = S !== void 0 ? S : b, p = n ? "0" : rt(P);
692
+ return /* @__PURE__ */ k(
693
+ "div",
694
+ {
695
+ "data-pane-id": t,
696
+ "data-min-size": i,
697
+ "data-max-size": a,
698
+ className: `a-split-pane${n ? " a-split-hidden" : ""}`,
699
+ style: {
700
+ flexBasis: p,
701
+ flexGrow: y,
702
+ flexShrink: u,
703
+ overflow: n ? "hidden" : "auto"
704
+ },
705
+ children: f
706
+ }
707
+ );
708
+ };
709
+ De.displayName = "Pane";
710
+ class ot {
711
+ constructor(e) {
712
+ ae(this, "plugins", []);
713
+ ae(this, "context");
714
+ this.context = e;
715
+ }
716
+ /**
717
+ * Registers a set of plugins and triggers their initialization.
718
+ */
719
+ registerPlugins(e) {
720
+ this.plugins = e, this.plugins.forEach((n) => {
721
+ n.onInit && n.onInit(this.context);
722
+ });
723
+ }
724
+ /**
725
+ * Cleans up all plugins and triggers their destruction hooks.
726
+ */
727
+ destroy() {
728
+ this.plugins.forEach((e) => {
729
+ e.onDestroy && e.onDestroy(this.context);
730
+ }), this.plugins = [];
731
+ }
732
+ /**
733
+ * Notifies plugins when a pane is added.
734
+ */
735
+ onPaneAdd(e) {
736
+ this.plugins.forEach((n) => {
737
+ n.onPaneAdd && n.onPaneAdd(e, this.context);
738
+ });
739
+ }
740
+ /**
741
+ * Notifies plugins when a pane is removed.
742
+ */
743
+ onPaneRemove(e) {
744
+ this.plugins.forEach((n) => {
745
+ n.onPaneRemove && n.onPaneRemove(e, this.context);
746
+ });
747
+ }
748
+ /**
749
+ * Notifies plugins when a pane is collapsed.
750
+ */
751
+ onPaneCollapse(e) {
752
+ this.plugins.forEach((n) => {
753
+ n.onPaneCollapse && n.onPaneCollapse(e, this.context);
754
+ });
755
+ }
756
+ /**
757
+ * Notifies plugins when a pane is expanded.
758
+ */
759
+ onPaneExpand(e) {
760
+ this.plugins.forEach((n) => {
761
+ n.onPaneExpand && n.onPaneExpand(e, this.context);
762
+ });
763
+ }
764
+ /**
765
+ * Notifies plugins when a drag operation begins.
766
+ */
767
+ onDragStart(e) {
768
+ this.plugins.forEach((n) => {
769
+ n.onDragStart && n.onDragStart(e, this.context);
770
+ });
771
+ }
772
+ /**
773
+ * Notifies plugins during drag movement.
774
+ * Plugins can return false to cancel the default drag behavior.
775
+ */
776
+ onDragMove(e) {
777
+ let n = !0;
778
+ for (const i of this.plugins)
779
+ i.onDragMove && i.onDragMove(e, this.context) === !1 && (n = !1);
780
+ return n;
781
+ }
782
+ /**
783
+ * Notifies plugins when a drag operation ends.
784
+ */
785
+ onDragEnd(e) {
786
+ this.plugins.forEach((n) => {
787
+ n.onDragEnd && n.onDragEnd(e, this.context);
788
+ });
789
+ }
790
+ /**
791
+ * Notifies plugins when the split container is resized.
792
+ */
793
+ onResize(e) {
794
+ this.plugins.forEach((n) => {
795
+ n.onResize && n.onResize(e, this.context);
796
+ });
797
+ }
798
+ /**
799
+ * Allows plugins to provide a custom handlebar renderer.
800
+ * Returns the first valid renderer found.
801
+ */
802
+ renderHandle(e) {
803
+ for (const n of this.plugins)
804
+ if (n.renderHandle) {
805
+ const i = n.renderHandle(e, this.context);
806
+ if (i)
807
+ return i;
808
+ }
809
+ return null;
810
+ }
811
+ /**
812
+ * Allows plugins to provide a custom pane wrapper.
813
+ * Returns the first valid renderer found.
814
+ */
815
+ renderPane(e) {
816
+ for (const n of this.plugins)
817
+ if (n.renderPane) {
818
+ const i = n.renderPane(e, this.context);
819
+ if (i)
820
+ return i;
821
+ }
822
+ return null;
823
+ }
824
+ /**
825
+ * Retrieves all registered plugins.
826
+ */
827
+ getPlugins() {
828
+ return this.plugins;
829
+ }
830
+ /**
831
+ * Retrieves a specific plugin by its unique name.
832
+ */
833
+ getPlugin(e) {
834
+ return this.plugins.find((n) => n.name === e);
835
+ }
836
+ /**
837
+ * Checks if a plugin with the given name is currently registered.
838
+ */
839
+ hasPlugin(e) {
840
+ return this.plugins.some((n) => n.name === e);
841
+ }
842
+ }
843
+ const at = qe((t, e) => {
844
+ const {
845
+ id: n,
846
+ mode: i = "horizontal",
847
+ initialSizes: a = [],
848
+ minSizes: z = [],
849
+ maxSizes: f = [],
850
+ collapsed: S = [],
851
+ disable: P = !1,
852
+ visible: x = !0,
853
+ lineBar: b = !1,
854
+ renderBar: u,
855
+ plugins: y = [],
856
+ enableSessionStorage: p = !1,
857
+ width: $ = null,
858
+ height: F = null,
859
+ className: A = "",
860
+ style: R = {},
861
+ fixClass: L = !1,
862
+ children: l,
863
+ onDragging: g,
864
+ onDragEnd: h,
865
+ onLayoutChange: r
866
+ } = t, s = G(`split-${Math.random().toString(36).slice(2, 11)}`), o = n || s.current, c = G(null), m = G(null), C = Ce(), T = !L && C > 2;
867
+ O(() => {
868
+ var v, w;
869
+ if (typeof globalThis < "u" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
870
+ ((w = (v = globalThis.process) == null ? void 0 : v.env) == null ? void 0 : w.NODE_ENV) !== "production") {
871
+ if (a.length > 0) {
872
+ const E = q.Children.toArray(l);
873
+ a.length !== E.length && console.warn(`[Split] initialSizes length (${a.length}) doesn't match children count (${E.length})`), a.forEach((N, B) => {
874
+ if (typeof N == "string") {
875
+ const K = parseFloat(N);
876
+ if (isNaN(K) && console.warn(`[Split] Invalid size at index ${B}: "${N}". Expected format: "50%", "100px", etc.`), N.includes("%")) {
877
+ const ee = parseFloat(N);
878
+ (ee < 0 || ee > 100) && console.warn(`[Split] Size at index ${B} is out of range: "${N}". Percentage should be 0-100.`);
879
+ }
880
+ }
881
+ });
882
+ const H = a.reduce((N, B) => typeof B == "string" && B.includes("%") ? N + parseFloat(B) : N, 0);
883
+ H > 100 && console.warn(`[Split] Total percentage (${H}%) exceeds 100%. Sizes will be normalized.`);
884
+ }
885
+ if ((z.length > 0 || f.length > 0) && (z.forEach((E, H) => {
886
+ const N = f[H];
887
+ N !== void 0 && E > N && console.warn(`[Split] minSize (${E}) is greater than maxSize (${N}) at index ${H}`), (E < 0 || E > 100) && console.warn(`[Split] minSize at index ${H} is out of range: ${E}. Should be 0-100.`);
888
+ }), f.forEach((E, H) => {
889
+ (E < 0 || E > 100) && console.warn(`[Split] maxSize at index ${H} is out of range: ${E}. Should be 0-100.`);
890
+ })), S.length > 0) {
891
+ const E = q.Children.toArray(l);
892
+ S.length !== E.length && console.warn(`[Split] collapsed length (${S.length}) doesn't match children count (${E.length})`);
893
+ }
894
+ }
895
+ }, [a, z, f, S, l]);
896
+ const { panes: I, addPane: V, removePane: j, togglePane: Y, setPaneSize: _, getPaneState: ue, removePanes: de, swapPanes: fe, collapsePane: U, expandPane: Z, resizePane: he } = Je(
897
+ l,
898
+ a,
899
+ S,
900
+ z,
901
+ f,
902
+ o
903
+ ), [M, pe] = te(null);
904
+ O(() => (M && M.active ? (document.body.classList.add("a-split-body-dragging"), document.body.classList.add(i === "horizontal" ? "a-split-body-dragging-horizontal" : "a-split-body-dragging-vertical")) : (document.body.classList.remove("a-split-body-dragging"), document.body.classList.remove("a-split-body-dragging-horizontal"), document.body.classList.remove("a-split-body-dragging-vertical")), () => {
905
+ document.body.classList.remove("a-split-body-dragging"), document.body.classList.remove("a-split-body-dragging-horizontal"), document.body.classList.remove("a-split-body-dragging-vertical");
906
+ }), [M, i]);
907
+ const ke = D(() => ({
908
+ panes: I,
909
+ mode: i,
910
+ dragState: M
911
+ }), [I, i, M]), Te = D(
912
+ (d) => {
913
+ switch (d.type) {
914
+ case "ADD_PANE":
915
+ V(d.payload);
916
+ break;
917
+ case "REMOVE_PANE":
918
+ j(d.payload);
919
+ break;
920
+ case "TOGGLE_PANE":
921
+ Y(d.payload);
922
+ break;
923
+ case "SET_PANE_SIZE":
924
+ _(d.payload.index, d.payload.size);
925
+ break;
926
+ case "RESTORE_STATE":
927
+ d.payload.panes.forEach((v, w) => {
928
+ _(w, v.size), v.collapsed && Y(w);
929
+ });
930
+ break;
931
+ case "ADJUST_PANE_SIZE":
932
+ if (d.payload && (M == null ? void 0 : M.paneIndex) != null) {
933
+ const v = M.paneIndex, w = I[v];
934
+ if (w) {
935
+ const E = parseFloat(w.size), H = d.payload.direction === "grow" ? d.payload.amount : -d.payload.amount, N = Math.max(w.minSize || 0, Math.min(w.maxSize || 100, E + H));
936
+ _(v, `${N}%`);
937
+ }
938
+ }
939
+ break;
940
+ }
941
+ },
942
+ [V, j, Y, _, I, M]
943
+ ), ge = nt(o, ke, Te, c);
944
+ O(() => {
945
+ if (y.length > 0)
946
+ return m.current = new ot(ge), m.current.registerPlugins(y), () => {
947
+ var d;
948
+ (d = m.current) == null || d.destroy(), m.current = null;
949
+ };
950
+ }, [y, ge]);
951
+ const ie = tt(p, `split-state-${o}`, i);
952
+ O(() => {
953
+ const d = ie.load();
954
+ d && d.length === I.length && d.forEach((v, w) => {
955
+ I[w] && v.id === I[w].id && (_(w, v.size), v.collapsed !== I[w].collapsed && Y(w));
956
+ });
957
+ }, []), O(() => {
958
+ ie.save(I);
959
+ }, [I, ie]);
960
+ const me = G(!0), Se = G(q.Children.count(l)), se = G(a);
961
+ O(() => {
962
+ if (!c.current || a.length === 0) return;
963
+ const d = q.Children.count(l), v = d !== Se.current, w = a.length !== se.current.length || a.some((E, H) => E !== se.current[H]);
964
+ (me.current || v || w) && (a.forEach((E, H) => {
965
+ _(H, E);
966
+ }), me.current = !1, Se.current = d, se.current = a);
967
+ }, [l, a]);
968
+ const oe = G(S);
969
+ O(() => {
970
+ !c.current || !S.some((v, w) => v !== oe.current[w]) && oe.current.length === S.length || (oe.current = S, S.forEach((v, w) => {
971
+ const E = I[w];
972
+ E && E.collapsed !== v && (v ? U(w) : Z(w));
973
+ }));
974
+ }, [S, I, U, Z]), O(() => {
975
+ c.current && I.forEach((d, v) => {
976
+ var E;
977
+ const w = (E = c.current) == null ? void 0 : E.querySelector(`[data-pane-id="${d.id}"]`);
978
+ if (w) {
979
+ const H = z[v], N = f[v];
980
+ H !== void 0 && w.setAttribute("data-min-size", String(z[v])), N !== void 0 && w.setAttribute("data-max-size", String(f[v]));
981
+ }
982
+ });
983
+ }, [z, f, I]), O(() => {
984
+ if (!c.current) return;
985
+ c.current.querySelectorAll(".a-split-handlebar").forEach((v, w) => {
986
+ const E = v, H = w + 1;
987
+ $e(H, P) ? (E.classList.add("a-split-handlebar-disabled"), E.style.cursor = "default") : (E.classList.remove("a-split-handlebar-disabled"), E.style.cursor = i === "horizontal" ? "col-resize" : "row-resize");
988
+ const B = Ee(H, x);
989
+ E.style.display = B ? "" : "none", Ie(H, b) ? E.classList.add("a-split-handlebar-line") : E.classList.remove("a-split-handlebar-line");
990
+ });
991
+ }, [P, x, b, i]);
992
+ const { handleMouseDown: ze } = et(c, i, {
993
+ onDragStart: (d) => {
994
+ var w;
995
+ pe({ active: !0, paneIndex: d.paneIndex }), (w = m.current) == null || w.onDragStart(d);
996
+ const v = I[d.paneIndex];
997
+ v && (r == null || r(d.paneIndex, v.id, "dragging", null));
998
+ },
999
+ onDragMove: (d) => {
1000
+ var w;
1001
+ (((w = m.current) == null ? void 0 : w.onDragMove(d)) ?? !0) && (g == null || g(d.prevSize, d.nextSize, d.paneIndex));
1002
+ },
1003
+ onDragEnd: (d) => {
1004
+ var w;
1005
+ _(d.paneIndex - 1, `${d.prevSize}%`), _(d.paneIndex, `${d.nextSize}%`), pe(null), (w = m.current) == null || w.onDragEnd(d), h == null || h(d.prevSize, d.nextSize, d.paneIndex);
1006
+ const v = I[d.paneIndex];
1007
+ v && (r == null || r(d.paneIndex, v.id, "dragged", null));
1008
+ }
1009
+ }), Re = D(
1010
+ (d, v) => {
1011
+ var E;
1012
+ const w = v === "left" ? d - 1 : d;
1013
+ if (w >= 0 && w < I.length) {
1014
+ U(w, { direction: v });
1015
+ const H = I[w];
1016
+ H && ((E = m.current) == null || E.onPaneCollapse({ pane: H, index: w, direction: v }), r == null || r(w, H.id, "close", v));
1017
+ }
1018
+ },
1019
+ [I, U, r]
1020
+ ), Me = D(
1021
+ (d, v) => {
1022
+ var E;
1023
+ const w = v === "left" ? d - 1 : d;
1024
+ if (w >= 0 && w < I.length) {
1025
+ Z(w, { direction: v });
1026
+ const H = I[w];
1027
+ H && ((E = m.current) == null || E.onPaneExpand({ pane: H, index: w, direction: v }), r == null || r(w, H.id, "open", v));
1028
+ }
1029
+ },
1030
+ [I, Z, r]
1031
+ );
1032
+ je(
1033
+ e,
1034
+ () => ({
1035
+ addPane: V,
1036
+ removePane: j,
1037
+ togglePane: Y,
1038
+ setPaneSize: _,
1039
+ getPaneState: ue,
1040
+ removePanes: de,
1041
+ swapPanes: fe,
1042
+ collapsePane: U,
1043
+ expandPane: Z,
1044
+ resizePane: he,
1045
+ getSnapshot: () => {
1046
+ const d = c.current, v = d ? i === "horizontal" ? d.offsetWidth : d.offsetHeight : 0;
1047
+ return {
1048
+ panes: I.map((w) => ({ ...w })),
1049
+ totalSize: v,
1050
+ mode: i,
1051
+ timestamp: Date.now()
1052
+ };
1053
+ },
1054
+ restore: (d) => {
1055
+ if (d.mode !== i) {
1056
+ console.warn(`Cannot restore snapshot with different mode. Current: ${i}, Snapshot: ${d.mode}`);
1057
+ return;
1058
+ }
1059
+ d.panes.forEach((v, w) => {
1060
+ I[w] && (_(w, v.size), v.collapsed !== I[w].collapsed && Y(w));
1061
+ });
1062
+ }
1063
+ }),
1064
+ [V, j, Y, _, ue, de, fe, U, Z, he, I, i]
1065
+ );
1066
+ const Ge = X(() => ({
1067
+ display: "flex",
1068
+ flexDirection: i === "horizontal" ? "row" : "column",
1069
+ width: $ || "100%",
1070
+ height: F || "100%",
1071
+ overflow: "hidden",
1072
+ ...R
1073
+ }), [i, $, F, R]), Ve = X(() => {
1074
+ const d = ["a-split-container"];
1075
+ return i === "vertical" && d.push("a-split-vertical"), (L || T) && d.push("a-split-fix"), M != null && M.active && d.push("a-split-dragging"), A && d.push(A), d.join(" ");
1076
+ }, [i, L, T, A, M == null ? void 0 : M.active]);
1077
+ return /* @__PURE__ */ k("div", { ref: c, id: o, className: Ve, style: Ge, children: (() => {
1078
+ const d = [];
1079
+ return I.forEach((v, w) => {
1080
+ var H;
1081
+ const E = /* @__PURE__ */ k(ce, { level: C + 1, children: v.content });
1082
+ if (d.push(
1083
+ /* @__PURE__ */ k(
1084
+ De,
1085
+ {
1086
+ id: v.id,
1087
+ size: v.size,
1088
+ collapsed: v.collapsed,
1089
+ minSize: v.minSize,
1090
+ maxSize: v.maxSize,
1091
+ mode: i,
1092
+ content: E,
1093
+ flexGrow: v.flexGrow
1094
+ },
1095
+ v.id
1096
+ )
1097
+ ), w < I.length - 1) {
1098
+ const N = w + 1, B = I[w + 1];
1099
+ if (!B) return;
1100
+ const K = We(), ee = Ee(N, x), we = Ie(N, b), ye = v.collapsed || !1, ve = B.collapsed || !1, xe = $e(N, P), be = xe || ye || ve;
1101
+ if (ee && K) {
1102
+ const Pe = (H = m.current) == null ? void 0 : H.renderHandle({
1103
+ index: N,
1104
+ mode: i,
1105
+ disabled: be,
1106
+ lineBar: we,
1107
+ onMouseDown: (W) => ze(N, W)
1108
+ });
1109
+ Pe ? d.push(/* @__PURE__ */ k(q.Fragment, { children: Pe }, `handlebar-${N}`)) : d.push(
1110
+ /* @__PURE__ */ k(
1111
+ Fe,
1112
+ {
1113
+ index: N,
1114
+ mode: i,
1115
+ disabled: be,
1116
+ lineBar: we,
1117
+ explicitlyDisabled: xe,
1118
+ onMouseDown: (W) => ze(N, W),
1119
+ onCollapse: (W) => Re(N, W),
1120
+ onExpand: (W) => Me(N, W),
1121
+ renderCustom: u,
1122
+ leftPaneCollapsed: ye,
1123
+ rightPaneCollapsed: ve
1124
+ },
1125
+ `handlebar-${N}`
1126
+ )
1127
+ );
1128
+ }
1129
+ }
1130
+ }), d;
1131
+ })() });
1132
+ });
1133
+ at.displayName = "Split";
1134
+ function Vt(t = {}) {
1135
+ const {
1136
+ mode: e = "horizontal",
1137
+ initialPanes: n = [],
1138
+ initialSizes: i = [],
1139
+ minSizes: a = [],
1140
+ maxSizes: z = [],
1141
+ onPaneChange: f
1142
+ } = t, [S, P] = te(() => n.length > 0 ? n : i.map((r, s) => ({
1143
+ id: `pane-${s}`,
1144
+ size: r,
1145
+ collapsed: !1,
1146
+ minSize: a[s] || 0,
1147
+ maxSize: z[s] || 100,
1148
+ content: null
1149
+ }))), [x] = te(!1), b = G(!1), u = D(
1150
+ (r) => {
1151
+ P((s) => {
1152
+ const o = typeof r == "function" ? r(s) : r;
1153
+ return !b.current && f && f(o), o;
1154
+ });
1155
+ },
1156
+ [f]
1157
+ ), y = D(
1158
+ (r) => {
1159
+ u((s) => {
1160
+ const o = r.position ?? s.length, c = {
1161
+ id: `pane-${Date.now()}`,
1162
+ size: r.size,
1163
+ collapsed: r.collapsed || !1,
1164
+ minSize: r.minSize || 0,
1165
+ maxSize: r.maxSize || 100,
1166
+ content: r.content
1167
+ }, m = [...s];
1168
+ return m.splice(o, 0, c), m;
1169
+ });
1170
+ },
1171
+ [u]
1172
+ ), p = D(
1173
+ (r) => {
1174
+ u((s) => {
1175
+ if (r < 0 || r >= s.length) return s;
1176
+ const o = [...s], c = o.splice(r, 1)[0];
1177
+ if (c && o.length > 0) {
1178
+ const C = (parseFloat(c.size) || 0) / o.length;
1179
+ return o.map((T) => ({
1180
+ ...T,
1181
+ size: `${(parseFloat(T.size) || 0) + C}%`
1182
+ }));
1183
+ }
1184
+ return o;
1185
+ });
1186
+ },
1187
+ [u]
1188
+ ), $ = D(
1189
+ (r) => {
1190
+ u((s) => {
1191
+ const o = [...r].sort((C, T) => T - C);
1192
+ let c = [...s], m = 0;
1193
+ if (o.forEach((C) => {
1194
+ if (C >= 0 && C < c.length) {
1195
+ const T = c.splice(C, 1)[0];
1196
+ T && (m += parseFloat(T.size) || 0);
1197
+ }
1198
+ }), c.length > 0 && m > 0) {
1199
+ const C = m / c.length;
1200
+ c = c.map((T) => ({
1201
+ ...T,
1202
+ size: `${(parseFloat(T.size) || 0) + C}%`
1203
+ }));
1204
+ }
1205
+ return c;
1206
+ });
1207
+ },
1208
+ [u]
1209
+ ), F = D(
1210
+ (r) => {
1211
+ u((s) => {
1212
+ if (r < 0 || r >= s.length) return s;
1213
+ const o = s[r];
1214
+ if (!o) return s;
1215
+ const c = [...s];
1216
+ return c[r] = {
1217
+ ...o,
1218
+ collapsed: !o.collapsed
1219
+ }, c;
1220
+ });
1221
+ },
1222
+ [u]
1223
+ ), A = D(
1224
+ (r) => {
1225
+ u((s) => {
1226
+ if (r < 0 || r >= s.length) return s;
1227
+ const o = s[r];
1228
+ if (!o || o.collapsed) return s;
1229
+ const c = [...s];
1230
+ return c[r] = { ...o, collapsed: !0 }, c;
1231
+ });
1232
+ },
1233
+ [u]
1234
+ ), R = D(
1235
+ (r) => {
1236
+ u((s) => {
1237
+ if (r < 0 || r >= s.length) return s;
1238
+ const o = s[r];
1239
+ if (!o || !o.collapsed) return s;
1240
+ const c = [...s];
1241
+ return c[r] = { ...o, collapsed: !1 }, c;
1242
+ });
1243
+ },
1244
+ [u]
1245
+ ), L = D(
1246
+ (r, s, o) => {
1247
+ u((c) => {
1248
+ if (r < 0 || r >= c.length) return c;
1249
+ const m = c[r];
1250
+ if (!m) return c;
1251
+ const C = [...c];
1252
+ return C[r] = { ...m, size: s }, C;
1253
+ });
1254
+ },
1255
+ [u]
1256
+ ), l = D(
1257
+ (r, s) => {
1258
+ u((o) => {
1259
+ if (r < 0 || r >= o.length || s < 0 || s >= o.length || r === s)
1260
+ return o;
1261
+ const c = [...o], m = c[r];
1262
+ return c[r] = c[s], c[s] = m, c;
1263
+ });
1264
+ },
1265
+ [u]
1266
+ ), g = D(() => ({
1267
+ panes: S.map((r) => ({ ...r })),
1268
+ totalSize: 0,
1269
+ mode: e,
1270
+ timestamp: Date.now()
1271
+ }), [S, e]), h = D(
1272
+ (r) => {
1273
+ if (r.mode !== e) {
1274
+ console.warn(
1275
+ `Cannot restore snapshot with different mode. Current: ${e}, Snapshot: ${r.mode}`
1276
+ );
1277
+ return;
1278
+ }
1279
+ b.current = !0, u(
1280
+ (s) => r.panes.map((o, c) => {
1281
+ const m = s.find((C) => C.id === o.id) || s[c];
1282
+ return {
1283
+ id: o.id,
1284
+ size: o.size,
1285
+ collapsed: o.collapsed,
1286
+ // Preserve existing values, or use defaults if no matching pane found
1287
+ minSize: (m == null ? void 0 : m.minSize) ?? 0,
1288
+ maxSize: (m == null ? void 0 : m.maxSize) ?? 100,
1289
+ content: (m == null ? void 0 : m.content) ?? null
1290
+ };
1291
+ })
1292
+ ), b.current = !1, f && P((s) => (f(s), s));
1293
+ },
1294
+ [e, u, f]
1295
+ );
1296
+ return X(
1297
+ () => ({
1298
+ panes: S,
1299
+ mode: e,
1300
+ isDragging: x,
1301
+ addPane: y,
1302
+ removePane: p,
1303
+ removePanes: $,
1304
+ togglePane: F,
1305
+ collapsePane: A,
1306
+ expandPane: R,
1307
+ setPaneSize: L,
1308
+ swapPanes: l,
1309
+ setPanes: u,
1310
+ getSnapshot: g,
1311
+ restore: h
1312
+ }),
1313
+ [
1314
+ S,
1315
+ e,
1316
+ x,
1317
+ y,
1318
+ p,
1319
+ $,
1320
+ F,
1321
+ A,
1322
+ R,
1323
+ L,
1324
+ l,
1325
+ u,
1326
+ g,
1327
+ h
1328
+ ]
1329
+ );
1330
+ }
1331
+ function _t(t) {
1332
+ return t;
1333
+ }
1334
+ function Bt(t = {}) {
1335
+ const {
1336
+ storage: e = "localStorage",
1337
+ key: n,
1338
+ debounceDelay: i = 300
1339
+ } = t;
1340
+ let a = null;
1341
+ const z = (b) => n || `a-multilayout-splitter:${b}`, f = () => typeof window > "u" ? null : e === "localStorage" ? window.localStorage : window.sessionStorage, S = (b, u) => {
1342
+ const y = f();
1343
+ if (y)
1344
+ try {
1345
+ const p = z(b), $ = JSON.stringify({
1346
+ panes: u.panes.map((F) => ({
1347
+ id: F.id,
1348
+ size: F.size,
1349
+ collapsed: F.collapsed
1350
+ })),
1351
+ mode: u.mode,
1352
+ timestamp: Date.now()
1353
+ });
1354
+ y.setItem(p, $);
1355
+ } catch (p) {
1356
+ console.error("Failed to save split state:", p);
1357
+ }
1358
+ }, P = (b) => {
1359
+ const u = f();
1360
+ if (!u) return null;
1361
+ try {
1362
+ const y = z(b), p = u.getItem(y);
1363
+ return p ? JSON.parse(p) : null;
1364
+ } catch (y) {
1365
+ return console.error("Failed to load split state:", y), null;
1366
+ }
1367
+ }, x = (b, u) => {
1368
+ a && clearTimeout(a), a = setTimeout(() => {
1369
+ S(b, u), a = null;
1370
+ }, i);
1371
+ };
1372
+ return {
1373
+ name: "persistence",
1374
+ version: "1.0.0",
1375
+ onInit(b) {
1376
+ const u = P(b.splitId), y = u == null ? void 0 : u.panes;
1377
+ y && y.length > 0 ? setTimeout(() => {
1378
+ b.getState().panes.length === y.length && b.dispatch({
1379
+ type: "RESTORE_STATE",
1380
+ payload: { panes: y }
1381
+ });
1382
+ }, 0) : setTimeout(() => {
1383
+ const p = b.getState();
1384
+ S(b.splitId, p);
1385
+ }, 0);
1386
+ },
1387
+ onDragEnd(b, u) {
1388
+ setTimeout(() => {
1389
+ const y = u.getState();
1390
+ x(u.splitId, y);
1391
+ }, 0);
1392
+ },
1393
+ onPaneAdd(b, u) {
1394
+ setTimeout(() => {
1395
+ const y = u.getState();
1396
+ x(u.splitId, y);
1397
+ }, 0);
1398
+ },
1399
+ onPaneRemove(b, u) {
1400
+ setTimeout(() => {
1401
+ const y = u.getState();
1402
+ x(u.splitId, y);
1403
+ }, 0);
1404
+ },
1405
+ onPaneCollapse(b, u) {
1406
+ setTimeout(() => {
1407
+ const y = u.getState();
1408
+ x(u.splitId, y);
1409
+ }, 0);
1410
+ },
1411
+ onPaneExpand(b, u) {
1412
+ setTimeout(() => {
1413
+ const y = u.getState();
1414
+ x(u.splitId, y);
1415
+ }, 0);
1416
+ },
1417
+ onDestroy() {
1418
+ a && (clearTimeout(a), a = null);
1419
+ }
1420
+ };
1421
+ }
1422
+ function Ot(t, e = "localStorage") {
1423
+ const n = e === "localStorage" ? window.localStorage : window.sessionStorage;
1424
+ try {
1425
+ const i = `a-multilayout-splitter:${t}`;
1426
+ n.removeItem(i);
1427
+ } catch (i) {
1428
+ console.error("Failed to clear persisted state:", i);
1429
+ }
1430
+ }
1431
+ function qt(t = {}) {
1432
+ const {
1433
+ enableArrowKeys: e = !0,
1434
+ enableNumberKeys: n = !0,
1435
+ stepSize: i = 5,
1436
+ enableTabNavigation: a = !0
1437
+ } = t;
1438
+ let z = 0, f = null;
1439
+ const S = (P, x) => {
1440
+ if (!P) return;
1441
+ const u = P.querySelectorAll(".a-split-pane")[x];
1442
+ u && (u.focus(), u.setAttribute("tabindex", "0"), z = x);
1443
+ };
1444
+ return {
1445
+ name: "keyboard",
1446
+ version: "1.0.0",
1447
+ onInit(P) {
1448
+ const x = P.getElement();
1449
+ if (!x) return;
1450
+ x.setAttribute("tabindex", "0"), x.querySelectorAll(".a-split-pane").forEach((u, y) => {
1451
+ u.setAttribute("tabindex", y === 0 ? "0" : "-1");
1452
+ }), f = (u) => {
1453
+ const y = P.getState(), p = y.panes;
1454
+ if (e && (u.key === "ArrowLeft" || u.key === "ArrowRight" || u.key === "ArrowUp" || u.key === "ArrowDown")) {
1455
+ u.preventDefault();
1456
+ const $ = y.mode === "horizontal", F = $ && u.key === "ArrowRight" || !$ && u.key === "ArrowDown", A = z, R = p[A], L = A < p.length - 1 ? A + 1 : A - 1, l = p[L];
1457
+ if (!R || !l) return;
1458
+ const g = parseFloat(R.size), h = parseFloat(l.size), r = F ? i : -i;
1459
+ let s = g + r, o = h - r;
1460
+ const c = R.minSize || 0, m = R.maxSize || 100, C = l.minSize || 0, T = l.maxSize || 100;
1461
+ s = Math.max(c, Math.min(m, s)), o = Math.max(C, Math.min(T, o));
1462
+ const I = g + h;
1463
+ s + o !== I && (s === c || s === m ? o = I - s : s = I - o), P.dispatch({
1464
+ type: "SET_PANE_SIZE",
1465
+ payload: { index: A, size: `${s}%` }
1466
+ }), P.dispatch({
1467
+ type: "SET_PANE_SIZE",
1468
+ payload: { index: L, size: `${o}%` }
1469
+ });
1470
+ }
1471
+ if (n) {
1472
+ const $ = parseInt(u.key, 10);
1473
+ if (!isNaN($) && $ >= 1 && $ <= 9) {
1474
+ const F = $ - 1;
1475
+ F < p.length && S(x, F);
1476
+ }
1477
+ }
1478
+ if (a && u.key === "Tab") {
1479
+ u.preventDefault();
1480
+ let $ = u.shiftKey ? z - 1 : z + 1;
1481
+ $ < 0 ? $ = p.length - 1 : $ >= p.length && ($ = 0), S(x, $);
1482
+ }
1483
+ }, x.addEventListener("keydown", f);
1484
+ },
1485
+ onDestroy(P) {
1486
+ const x = P.getElement();
1487
+ x && f && (x.removeEventListener("keydown", f), f = null);
1488
+ }
1489
+ };
1490
+ }
1491
+ function jt(t, e) {
1492
+ return {
1493
+ name: "custom-handle",
1494
+ version: "1.0.0",
1495
+ renderHandle(n) {
1496
+ return q.createElement(t, {
1497
+ ...n,
1498
+ ...e
1499
+ });
1500
+ }
1501
+ };
1502
+ }
1503
+ function Xt(t) {
1504
+ return {
1505
+ name: "custom-handle-render",
1506
+ version: "1.0.0",
1507
+ renderHandle(e) {
1508
+ return t(e);
1509
+ }
1510
+ };
1511
+ }
1512
+ const He = ne(null), Ne = ne(null), Le = ne(null);
1513
+ function Yt({
1514
+ id: t,
1515
+ mode: e = "horizontal",
1516
+ enableSessionStorage: n = !1,
1517
+ storageKey: i = `split-state-${t}`,
1518
+ children: a,
1519
+ _panes: z = [],
1520
+ _addPane: f,
1521
+ _removePane: S,
1522
+ _togglePane: P,
1523
+ _setPaneSize: x,
1524
+ _getPaneState: b
1525
+ }) {
1526
+ const u = G({ isDragging: !1, activeHandlebar: null }), y = X(
1527
+ () => ({
1528
+ id: t,
1529
+ mode: e,
1530
+ enableSessionStorage: n,
1531
+ storageKey: i
1532
+ }),
1533
+ [t, e, n, i]
1534
+ ), p = X(
1535
+ () => ({
1536
+ panes: z,
1537
+ isDragging: u.current.isDragging,
1538
+ activeHandlebar: u.current.activeHandlebar
1539
+ }),
1540
+ [z, u.current.isDragging, u.current.activeHandlebar]
1541
+ ), $ = X(
1542
+ () => ({
1543
+ addPane: f || (() => console.warn("addPane not available")),
1544
+ removePane: S || (() => console.warn("removePane not available")),
1545
+ togglePane: P || (() => console.warn("togglePane not available")),
1546
+ setPaneSize: x || (() => console.warn("setPaneSize not available")),
1547
+ getPaneState: b || (() => []),
1548
+ setDragging: (F, A) => {
1549
+ u.current.isDragging = F, u.current.activeHandlebar = A ?? null;
1550
+ }
1551
+ }),
1552
+ [f, S, P, x, b]
1553
+ );
1554
+ return /* @__PURE__ */ k(He.Provider, { value: y, children: /* @__PURE__ */ k(Ne.Provider, { value: p, children: /* @__PURE__ */ k(Le.Provider, { value: $, children: a }) }) });
1555
+ }
1556
+ function lt() {
1557
+ const t = re(He);
1558
+ if (!t)
1559
+ throw new Error("useSplitConfig must be used within SplitProvider");
1560
+ return t;
1561
+ }
1562
+ function Q() {
1563
+ const t = re(Ne);
1564
+ if (!t)
1565
+ throw new Error("useSplitState must be used within SplitProvider");
1566
+ return t;
1567
+ }
1568
+ function ct() {
1569
+ return re(Le);
1570
+ }
1571
+ function Wt() {
1572
+ const t = ct();
1573
+ if (!t)
1574
+ throw new Error("useSplit must be used within SplitProvider");
1575
+ return {
1576
+ config: lt(),
1577
+ state: Q(),
1578
+ actions: t
1579
+ };
1580
+ }
1581
+ function ut(t) {
1582
+ const { panes: e } = Q();
1583
+ return e[t];
1584
+ }
1585
+ function Jt() {
1586
+ const { panes: t } = Q();
1587
+ return t.length;
1588
+ }
1589
+ function Ut() {
1590
+ const { isDragging: t } = Q();
1591
+ return t;
1592
+ }
1593
+ function Zt(t) {
1594
+ const e = ut(t);
1595
+ return (e == null ? void 0 : e.collapsed) ?? !1;
1596
+ }
1597
+ function Qt() {
1598
+ const { panes: t } = Q();
1599
+ return X(() => t.filter((e) => !e.collapsed), [t]);
1600
+ }
1601
+ export {
1602
+ Fe as DragHandle,
1603
+ ce as NestingProvider,
1604
+ De as PaneComponent,
1605
+ ot as PluginManager,
1606
+ at as Split,
1607
+ Yt as SplitProvider,
1608
+ Xe as animatePaneSize,
1609
+ gt as applyCollapseState,
1610
+ bt as batchUpdatePanes,
1611
+ rt as calculateFlexBasis,
1612
+ it as calculateFlexValues,
1613
+ Lt as calculateHandlebarPosition,
1614
+ Ht as calculateTotalSize,
1615
+ Rt as canResize,
1616
+ Dt as clampSize,
1617
+ Ot as clearPersistedState,
1618
+ yt as constrainSize,
1619
+ vt as createPane,
1620
+ _t as createPlugin,
1621
+ jt as customHandlePlugin,
1622
+ Xt as customHandleRenderPlugin,
1623
+ Ke as debounce,
1624
+ at as default,
1625
+ St as findPaneIndex,
1626
+ Mt as getAxisProperty,
1627
+ kt as getContainerDimensions,
1628
+ Gt as getCoordinateProperty,
1629
+ wt as getPaneElement,
1630
+ zt as getVisiblePanes,
1631
+ Ft as haveSameUnit,
1632
+ $e as isHandlebarDisabled,
1633
+ Ee as isHandlebarVisible,
1634
+ Ie as isLineBarStyle,
1635
+ Ye as isPaneVisible,
1636
+ qt as keyboardPlugin,
1637
+ Tt as normalizePaneSizes,
1638
+ Ct as normalizeSize,
1639
+ J as parseSize,
1640
+ It as percentageToPixel,
1641
+ Bt as persistencePlugin,
1642
+ At as pixelToPercentage,
1643
+ Pt as restorePaneState,
1644
+ $t as serializePaneState,
1645
+ We as shouldShowHandlebar,
1646
+ Qe as throttle,
1647
+ mt as togglePaneCollapse,
1648
+ xt as updatePaneSize,
1649
+ et as useDragHandler,
1650
+ Zt as useIsCollapsed,
1651
+ Ut as useIsDragging,
1652
+ Ce as useNestingLevel,
1653
+ ut as usePane,
1654
+ Jt as usePaneCount,
1655
+ Je as usePaneManager,
1656
+ tt as usePersistence,
1657
+ nt as usePluginContext,
1658
+ Wt as useSplit,
1659
+ ct as useSplitActions,
1660
+ lt as useSplitConfig,
1661
+ Vt as useSplitController,
1662
+ Q as useSplitState,
1663
+ Qt as useVisiblePanes,
1664
+ Nt as validatePaneSizes,
1665
+ Et as withNesting
1666
+ };
1667
+ //# sourceMappingURL=index.js.map